@@ -7,56 +7,39 @@ import type {
77 Styles ,
88} from "@dash-ui/styles" ;
99import * as React from "react" ;
10- /**
11- * A hook for consuming dash context from the provider
12- */
13- export declare function useDash ( ) : DashContextValue ;
14- export interface DashContextValue {
15- /**
16- * A `styles()` instance
17- */
18- styles : Styles ;
19- }
20- /**
21- * The Dash context provider. Use this to control the `styles()` instance
22- * your app is using.
23- *
24- * @param root0
25- * @param root0.styles
26- * @param root0.children
27- */
28- export declare function DashProvider ( {
29- styles,
30- children,
31- } : DashProviderProps ) : JSX . Element ;
32- export interface DashProviderProps {
33- /**
34- * A `styles()` instance. Defaults to the default instance in `@dash-ui/styles`
35- */
36- styles ?: Styles ;
37- children ?: React . ReactNode ;
38- }
3910/**
4011 * A component for creating an inline `<style>` tag that is unmounted when
4112 * the component unmounts.
4213 *
4314 * @param root0
4415 * @param root0.css
16+ * @param root0.styles
4517 */
46- export declare function Inline ( { css : input } : InlineProps ) : JSX . Element | null ;
47- export interface InlineProps {
18+ export declare function Inline <
19+ Tokens extends DashTokens ,
20+ Themes extends DashThemes
21+ > ( { styles, css : input } : InlineProps < Tokens , Themes > ) : JSX . Element | null ;
22+ export interface InlineProps <
23+ Tokens extends DashTokens ,
24+ Themes extends DashThemes
25+ > {
26+ /**
27+ * A Dash `styles` instance
28+ */
29+ styles : Styles < Tokens , Themes > ;
4830 /**
4931 * The CSS you want to inline in the DOM.
5032 *
5133 * @example
5234 * const Component => <Inline css={({color}) => `html { color: ${color.text}; }` }/>
5335 */
54- css : string | StyleCallback | StyleObject ;
36+ css : string | StyleCallback < Tokens , Themes > | StyleObject ;
5537}
5638/**
5739 * A hook for inserting transient global styles into the DOM. These styles
5840 * will be injected when the hook mounts and flushed when the hook unmounts.
5941 *
42+ * @param styles - A Dash `styles` instance
6043 * @param value - Global CSS to inject into the DOM and flush when the hook unmounts
6144 * @param deps - A dependency array that will force the hook to re-insert global styles
6245 * @example
@@ -73,57 +56,72 @@ export interface InlineProps {
7356 * )
7457 * }
7558 */
76- export declare function useGlobal (
77- value : string | StyleCallback | StyleObject | null | 0 | undefined | false ,
59+ export declare function useGlobal <
60+ Tokens extends DashTokens ,
61+ Themes extends DashThemes
62+ > (
63+ styles : Styles < Tokens , Themes > ,
64+ value :
65+ | string
66+ | StyleCallback < Tokens , Themes >
67+ | StyleObject
68+ | null
69+ | 0
70+ | undefined
71+ | false ,
7872 deps ?: React . DependencyList
7973) : void ;
8074/**
8175 * A hook for inserting transient CSS tokens into the DOM. These tokens
8276 * will be injected when the hook mounts and flushed when the hook unmounts.
8377 *
78+ * @param styles - A Dash `styles` instance
8479 * @param value - CSS tokens to inject into the DOM and flush when the hook unmounts
8580 * @param deps - A dependency array that will force the hook to re-insert tokens
8681 * @example
8782 * const Component = () => {
8883 * const [userFontSize, setUserFontSize] = React.useState('100%')
8984 *
9085 * useTokens(
86+ * styles,
9187 * {fontSize: userFontSize},
9288 * [userFontSize]
9389 * )
9490 * }
9591 */
96- export declare function useTokens (
97- value : DeepPartial < DashTokens > | Falsy ,
92+ export declare function useTokens <
93+ Tokens extends DashTokens ,
94+ Themes extends DashThemes
95+ > (
96+ styles : Styles < Tokens , Themes > ,
97+ value : Parameters < Styles < Tokens , Themes > [ "insertTokens" ] > [ 0 ] | Falsy ,
9898 deps ?: React . DependencyList
9999) : void ;
100100/**
101101 * A hook for inserting transient CSS theme tokens into the DOM. These tokens
102102 * will be injected when the hook mounts and flushed when the hook unmounts.
103103 *
104+ * @param styles - A Dash `styles` instance
104105 * @param value - Themes to inject into the DOM and flush when the hook unmounts
105106 * @param deps - A dependency array that will force the hook to re-insert themes
106107 * @example
107108 * const Component = () => {
108109 * const [color, setColor] = React.useState('aliceblue')
109110 *
110111 * useThemes(
112+ * styles,
111113 * {
112114 * dark: {color}
113115 * },
114116 * [color]
115117 * )
116118 * }
117119 */
118- export declare function useThemes (
119- value : DeepPartial < DashThemes > | Falsy ,
120+ export declare function useThemes <
121+ Tokens extends DashTokens ,
122+ Themes extends DashThemes
123+ > (
124+ styles : Styles < Tokens , Themes > ,
125+ value : Parameters < Styles < Tokens , Themes > [ "insertThemes" ] > [ 0 ] | Falsy ,
120126 deps ?: React . DependencyList
121127) : void ;
122- declare type DeepPartial < T > = T extends ( ...args : any [ ] ) => any
123- ? T
124- : T extends Record < string , any >
125- ? {
126- [ P in keyof T ] ?: DeepPartial < T [ P ] > ;
127- }
128- : T ;
129- export { } ;
0 commit comments