@aurora-ds/theme 3.0.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.dev.md +424 -0
- package/README.md +102 -587
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -586
- package/dist/index.d.ts +60 -586
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,286 +1,21 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
-
export { CSSProperties } from 'react';
|
|
4
3
|
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
readonly none: "0";
|
|
15
|
-
readonly '2xs': "0.125rem";
|
|
16
|
-
readonly xs: "0.25rem";
|
|
17
|
-
readonly sm: "0.5rem";
|
|
18
|
-
readonly md: "1rem";
|
|
19
|
-
readonly lg: "1.5rem";
|
|
20
|
-
readonly xl: "2rem";
|
|
21
|
-
readonly '2xl': "3rem";
|
|
22
|
-
readonly '3xl': "4rem";
|
|
23
|
-
readonly '4xl': "6rem";
|
|
24
|
-
readonly '5xl': "8rem";
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Default border radius scale
|
|
28
|
-
*/
|
|
29
|
-
declare const defaultRadius: {
|
|
30
|
-
readonly none: "0";
|
|
31
|
-
readonly xs: "0.125rem";
|
|
32
|
-
readonly sm: "0.25rem";
|
|
33
|
-
readonly md: "0.375rem";
|
|
34
|
-
readonly lg: "0.5rem";
|
|
35
|
-
readonly xl: "0.75rem";
|
|
36
|
-
readonly '2xl': "1rem";
|
|
37
|
-
readonly full: "9999px";
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Default shadow scale
|
|
41
|
-
*/
|
|
42
|
-
declare const defaultShadows: {
|
|
43
|
-
readonly none: "none";
|
|
44
|
-
readonly xs: "0 1px 2px 0 rgb(0 0 0 / 0.05)";
|
|
45
|
-
readonly sm: "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)";
|
|
46
|
-
readonly md: "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)";
|
|
47
|
-
readonly lg: "0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)";
|
|
48
|
-
readonly xl: "0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)";
|
|
49
|
-
readonly '2xl': "0 25px 50px -12px rgb(0 0 0 / 0.25)";
|
|
50
|
-
readonly inner: "inset 0 2px 4px 0 rgb(0 0 0 / 0.05)";
|
|
51
|
-
readonly focus: "0 0 0 3px rgb(99 102 241 / 0.4)";
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Default font size scale
|
|
55
|
-
*/
|
|
56
|
-
declare const defaultFontSize: {
|
|
57
|
-
readonly '2xs': "0.625rem";
|
|
58
|
-
readonly xs: "0.75rem";
|
|
59
|
-
readonly sm: "0.875rem";
|
|
60
|
-
readonly md: "1rem";
|
|
61
|
-
readonly lg: "1.25rem";
|
|
62
|
-
readonly xl: "1.5rem";
|
|
63
|
-
readonly '2xl': "2rem";
|
|
64
|
-
readonly '3xl': "2.5rem";
|
|
65
|
-
readonly '4xl': "3rem";
|
|
66
|
-
readonly '5xl': "4rem";
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Default font weight scale
|
|
70
|
-
*/
|
|
71
|
-
declare const defaultFontWeight: {
|
|
72
|
-
readonly light: 300;
|
|
73
|
-
readonly regular: 400;
|
|
74
|
-
readonly medium: 500;
|
|
75
|
-
readonly semibold: 600;
|
|
76
|
-
readonly bold: 700;
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Default line height scale
|
|
80
|
-
*/
|
|
81
|
-
declare const defaultLineHeight: {
|
|
82
|
-
readonly none: 1;
|
|
83
|
-
readonly tight: 1.25;
|
|
84
|
-
readonly normal: 1.5;
|
|
85
|
-
readonly relaxed: 1.75;
|
|
86
|
-
readonly loose: 2;
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Default z-index scale
|
|
90
|
-
*/
|
|
91
|
-
declare const defaultZIndex: {
|
|
92
|
-
readonly behind: -1;
|
|
93
|
-
readonly base: 0;
|
|
94
|
-
readonly dropdown: 1000;
|
|
95
|
-
readonly sticky: 1100;
|
|
96
|
-
readonly overlay: 1300;
|
|
97
|
-
readonly modal: 1400;
|
|
98
|
-
readonly popover: 1500;
|
|
99
|
-
readonly tooltip: 1600;
|
|
100
|
-
readonly toast: 1700;
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* Default transition scale
|
|
104
|
-
*/
|
|
105
|
-
declare const defaultTransition: {
|
|
106
|
-
readonly fast: "150ms ease-out";
|
|
107
|
-
readonly normal: "250ms ease-out";
|
|
108
|
-
readonly slow: "350ms ease-out";
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* Default opacity scale
|
|
112
|
-
*/
|
|
113
|
-
declare const defaultOpacity: {
|
|
114
|
-
readonly none: 0;
|
|
115
|
-
readonly lowest: 0.05;
|
|
116
|
-
readonly low: 0.1;
|
|
117
|
-
readonly medium: 0.25;
|
|
118
|
-
readonly high: 0.5;
|
|
119
|
-
readonly higher: 0.75;
|
|
120
|
-
readonly full: 1;
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
* Default responsive breakpoints
|
|
124
|
-
*/
|
|
125
|
-
declare const defaultBreakpoints: {
|
|
126
|
-
readonly xs: "480px";
|
|
127
|
-
readonly sm: "640px";
|
|
128
|
-
readonly md: "768px";
|
|
129
|
-
readonly lg: "1024px";
|
|
130
|
-
readonly xl: "1280px";
|
|
131
|
-
readonly '2xl': "1536px";
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Responsive breakpoints for mobile-first design
|
|
136
|
-
* Type inferred automatically from defaultBreakpoints values
|
|
137
|
-
*
|
|
138
|
-
* - xs: Extra small devices (phones in portrait)
|
|
139
|
-
* - sm: Small devices (phones in landscape, small tablets)
|
|
140
|
-
* - md: Medium devices (tablets)
|
|
141
|
-
* - lg: Large devices (desktops)
|
|
142
|
-
* - xl: Extra large devices (large desktops)
|
|
143
|
-
* - 2xl: Extra extra large devices (wide screens)
|
|
144
|
-
*/
|
|
145
|
-
type BaseBreakpoints = typeof defaultBreakpoints;
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Base color tokens following modern design system semantics - V2
|
|
149
|
-
*/
|
|
150
|
-
type BaseColors = {
|
|
151
|
-
background: string;
|
|
152
|
-
surface: string;
|
|
153
|
-
surfaceHover: string;
|
|
154
|
-
surfaceActive: string;
|
|
155
|
-
text: string;
|
|
156
|
-
textSecondary: string;
|
|
157
|
-
textTertiary: string;
|
|
158
|
-
primary: string;
|
|
159
|
-
primaryHover: string;
|
|
160
|
-
primaryActive: string;
|
|
161
|
-
primarySubtle: string;
|
|
162
|
-
primaryDisabled: string;
|
|
163
|
-
onPrimary: string;
|
|
164
|
-
secondary: string;
|
|
165
|
-
secondaryHover: string;
|
|
166
|
-
secondaryActive: string;
|
|
167
|
-
secondarySubtle: string;
|
|
168
|
-
secondaryDisabled: string;
|
|
169
|
-
onSecondary: string;
|
|
170
|
-
border: string;
|
|
171
|
-
disabled: string;
|
|
172
|
-
disabledText: string;
|
|
173
|
-
success: string;
|
|
174
|
-
successSubtle: string;
|
|
175
|
-
warning: string;
|
|
176
|
-
warningSubtle: string;
|
|
177
|
-
error: string;
|
|
178
|
-
errorHover: string;
|
|
179
|
-
errorSubtle: string;
|
|
180
|
-
onError: string;
|
|
181
|
-
info: string;
|
|
182
|
-
infoSubtle: string;
|
|
183
|
-
link: string;
|
|
184
|
-
linkHover: string;
|
|
185
|
-
linkActive: string;
|
|
186
|
-
linkDisabled: string;
|
|
187
|
-
};
|
|
4
|
+
/** Registry for theme type via module augmentation */
|
|
5
|
+
interface ThemeRegistry {
|
|
6
|
+
}
|
|
7
|
+
/** @internal */
|
|
8
|
+
type InferredTheme = ThemeRegistry extends {
|
|
9
|
+
theme: infer T;
|
|
10
|
+
} ? T : Record<string, any>;
|
|
11
|
+
/** Theme type, inferred from ThemeRegistry */
|
|
12
|
+
type Theme<T = InferredTheme> = T extends Record<string, any> ? T : Record<string, any>;
|
|
188
13
|
|
|
189
14
|
/**
|
|
190
|
-
*
|
|
191
|
-
*
|
|
15
|
+
* Creates a typed theme. Type is validated against ThemeRegistry.
|
|
16
|
+
* The theme must match the structure defined in your module augmentation.
|
|
192
17
|
*/
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Border radius scale
|
|
197
|
-
* Type inferred automatically from defaultRadius values
|
|
198
|
-
*/
|
|
199
|
-
type BaseRadius = typeof defaultRadius;
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Shadow scale for elevation
|
|
203
|
-
* Type inferred automatically from defaultShadows values
|
|
204
|
-
*/
|
|
205
|
-
type BaseShadows = typeof defaultShadows;
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Font size scale
|
|
209
|
-
* Type inferred automatically from defaultFontSize values
|
|
210
|
-
*/
|
|
211
|
-
type BaseFontSize = typeof defaultFontSize;
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Font weight scale
|
|
215
|
-
* Type inferred automatically from defaultFontWeight values
|
|
216
|
-
*/
|
|
217
|
-
type BaseFontWeight = typeof defaultFontWeight;
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Line height scale
|
|
221
|
-
* Type inferred automatically from defaultLineHeight values
|
|
222
|
-
*/
|
|
223
|
-
type BaseLineHeight = typeof defaultLineHeight;
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Z-index scale for layering
|
|
227
|
-
* Type inferred automatically from defaultZIndex values
|
|
228
|
-
*/
|
|
229
|
-
type BaseZIndex = typeof defaultZIndex;
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Transition timing scale
|
|
233
|
-
* Type inferred automatically from defaultTransition values
|
|
234
|
-
*/
|
|
235
|
-
type BaseTransition = typeof defaultTransition;
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Base opacity scale for consistent transparency
|
|
239
|
-
* Type inferred automatically from defaultOpacity values
|
|
240
|
-
*/
|
|
241
|
-
type BaseOpacity = typeof defaultOpacity;
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* @deprecated Don't use Theme directly. Use `typeof yourTheme` instead.
|
|
245
|
-
*
|
|
246
|
-
* The Theme type has been removed in favor of type inference.
|
|
247
|
-
* This forces better type safety and prevents issues with custom themes.
|
|
248
|
-
*
|
|
249
|
-
* @example
|
|
250
|
-
* ```ts
|
|
251
|
-
* // ✅ DO THIS - Infer type from your theme
|
|
252
|
-
* const myTheme = createTheme({
|
|
253
|
-
* colors: { brand: '#000', accent: '#fff' }
|
|
254
|
-
* })
|
|
255
|
-
* type MyTheme = typeof myTheme
|
|
256
|
-
*
|
|
257
|
-
* type Props = {
|
|
258
|
-
* color: keyof MyTheme['colors'] // Type-safe!
|
|
259
|
-
* }
|
|
260
|
-
*
|
|
261
|
-
* // ❌ DON'T DO THIS
|
|
262
|
-
* import type { Theme } from '@aurora-ds/theme' // Theme no longer exists!
|
|
263
|
-
* ```
|
|
264
|
-
*/
|
|
265
|
-
type Theme = never;
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Minimum structure for a theme
|
|
269
|
-
* Allows any extensions while preserving type safety
|
|
270
|
-
*/
|
|
271
|
-
type ThemeStructure = {
|
|
272
|
-
colors: Record<string, string>;
|
|
273
|
-
spacing: Record<string, string>;
|
|
274
|
-
radius: Record<string, string>;
|
|
275
|
-
shadows: Record<string, string>;
|
|
276
|
-
fontSize: Record<string, string>;
|
|
277
|
-
fontWeight: Record<string, number>;
|
|
278
|
-
lineHeight: Record<string, number>;
|
|
279
|
-
zIndex: Record<string, number>;
|
|
280
|
-
transition: Record<string, string>;
|
|
281
|
-
opacity: Record<string, number>;
|
|
282
|
-
breakpoints: Record<string, string>;
|
|
283
|
-
};
|
|
18
|
+
declare const createTheme: <T extends Theme>(values: T) => T;
|
|
284
19
|
|
|
285
20
|
/**
|
|
286
21
|
* Color scale type - 12 shades from 25 to 950
|
|
@@ -300,151 +35,7 @@ type ColorScale = {
|
|
|
300
35
|
950: string;
|
|
301
36
|
};
|
|
302
37
|
|
|
303
|
-
/**
|
|
304
|
-
* Available shade values (keys of ColorScale)
|
|
305
|
-
*/
|
|
306
|
-
type ColorShade = keyof ColorScale;
|
|
307
|
-
|
|
308
|
-
type ThemeProviderProps<TTheme extends ThemeStructure = ThemeStructure> = {
|
|
309
|
-
theme: TTheme;
|
|
310
|
-
children?: ReactNode;
|
|
311
|
-
};
|
|
312
|
-
/**
|
|
313
|
-
* Theme provider component
|
|
314
|
-
* Provides theme context to all child components
|
|
315
|
-
* Accepts any theme structure created with createTheme()
|
|
316
|
-
*
|
|
317
|
-
* @example
|
|
318
|
-
* ```tsx
|
|
319
|
-
* const myTheme = createTheme({
|
|
320
|
-
* colors: { primary: '#007bff', background: '#fff' }
|
|
321
|
-
* })
|
|
322
|
-
*
|
|
323
|
-
* <ThemeProvider theme={myTheme}>
|
|
324
|
-
* <App />
|
|
325
|
-
* </ThemeProvider>
|
|
326
|
-
* ```
|
|
327
|
-
*/
|
|
328
|
-
declare const ThemeProvider: <TTheme extends ThemeStructure>({ theme, children }: ThemeProviderProps<TTheme>) => react_jsx_runtime.JSX.Element;
|
|
329
|
-
/**
|
|
330
|
-
* Hook to access the current theme
|
|
331
|
-
* Returns the theme provided by ThemeProvider with exact inferred types
|
|
332
|
-
*
|
|
333
|
-
* @example
|
|
334
|
-
* ```tsx
|
|
335
|
-
* const myTheme = createTheme({ colors: { brand: '#000' } })
|
|
336
|
-
*
|
|
337
|
-
* function MyComponent() {
|
|
338
|
-
* const theme = useTheme() // theme.colors.brand is accessible!
|
|
339
|
-
* }
|
|
340
|
-
* ```
|
|
341
|
-
*
|
|
342
|
-
* @throws {Error} If used outside a ThemeProvider
|
|
343
|
-
*/
|
|
344
|
-
declare const useTheme: <TTheme extends ThemeStructure = ThemeStructure>() => TTheme;
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Default palette - V3
|
|
348
|
-
* A clean, modern palette using Indigo as primary and Slate as neutral
|
|
349
|
-
*
|
|
350
|
-
* This palette is optional and serves as a reference/starting point.
|
|
351
|
-
* You can use it directly, customize it, or create your own from scratch.
|
|
352
|
-
*
|
|
353
|
-
* @example
|
|
354
|
-
* ```ts
|
|
355
|
-
* // Use as-is
|
|
356
|
-
* const theme = createTheme({ colors: defaultPalette })
|
|
357
|
-
*
|
|
358
|
-
* // Customize specific colors
|
|
359
|
-
* const theme = createTheme({
|
|
360
|
-
* colors: {
|
|
361
|
-
* ...defaultPalette,
|
|
362
|
-
* primary: '#custom-color',
|
|
363
|
-
* }
|
|
364
|
-
* })
|
|
365
|
-
*
|
|
366
|
-
* // Or create your own from scratch
|
|
367
|
-
* const theme = createTheme({
|
|
368
|
-
* colors: { primary: '#...', background: '#...' }
|
|
369
|
-
* })
|
|
370
|
-
* ```
|
|
371
|
-
*/
|
|
372
|
-
declare const defaultPalette: BaseColors;
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Create a theme with custom color tokens - V3
|
|
376
|
-
* Colors are optional - if not provided, defaultPalette is used
|
|
377
|
-
* All other tokens use defaults and can be optionally overridden
|
|
378
|
-
*
|
|
379
|
-
* @param config - Theme configuration (all optional)
|
|
380
|
-
*
|
|
381
|
-
* @example
|
|
382
|
-
* ```ts
|
|
383
|
-
* // Use defaultPalette (quickest way to start)
|
|
384
|
-
* const theme = createTheme()
|
|
385
|
-
*
|
|
386
|
-
* // Customize defaultPalette
|
|
387
|
-
* const theme = createTheme({
|
|
388
|
-
* colors: {
|
|
389
|
-
* ...defaultPalette,
|
|
390
|
-
* primary: '#custom'
|
|
391
|
-
* }
|
|
392
|
-
* })
|
|
393
|
-
*
|
|
394
|
-
* // Or create your own colors from scratch
|
|
395
|
-
* const theme = createTheme({
|
|
396
|
-
* colors: {
|
|
397
|
-
* brand: '#007bff',
|
|
398
|
-
* surface: '#ffffff',
|
|
399
|
-
* text: '#212529',
|
|
400
|
-
* }
|
|
401
|
-
* })
|
|
402
|
-
* ```
|
|
403
|
-
*/
|
|
404
|
-
declare const createTheme: <const TConfig extends {
|
|
405
|
-
colors?: Record<string, string>;
|
|
406
|
-
spacing?: Record<string, string>;
|
|
407
|
-
radius?: Record<string, string>;
|
|
408
|
-
shadows?: Record<string, string>;
|
|
409
|
-
fontSize?: Record<string, string>;
|
|
410
|
-
fontWeight?: Record<string, number>;
|
|
411
|
-
lineHeight?: Record<string, number>;
|
|
412
|
-
zIndex?: Record<string, number>;
|
|
413
|
-
transition?: Record<string, string>;
|
|
414
|
-
opacity?: Record<string, number>;
|
|
415
|
-
breakpoints?: Record<string, string>;
|
|
416
|
-
} = object>(config?: TConfig) => {
|
|
417
|
-
readonly colors: TConfig["colors"] extends Record<string, string> ? TConfig["colors"] : typeof defaultPalette;
|
|
418
|
-
readonly spacing: TConfig["spacing"] extends Record<string, string> ? TConfig["spacing"] : typeof defaultSpacing;
|
|
419
|
-
readonly radius: TConfig["radius"] extends Record<string, string> ? TConfig["radius"] : typeof defaultRadius;
|
|
420
|
-
readonly shadows: TConfig["shadows"] extends Record<string, string> ? TConfig["shadows"] : typeof defaultShadows;
|
|
421
|
-
readonly fontSize: TConfig["fontSize"] extends Record<string, string> ? TConfig["fontSize"] : typeof defaultFontSize;
|
|
422
|
-
readonly fontWeight: TConfig["fontWeight"] extends Record<string, number> ? TConfig["fontWeight"] : typeof defaultFontWeight;
|
|
423
|
-
readonly lineHeight: TConfig["lineHeight"] extends Record<string, number> ? TConfig["lineHeight"] : typeof defaultLineHeight;
|
|
424
|
-
readonly zIndex: TConfig["zIndex"] extends Record<string, number> ? TConfig["zIndex"] : typeof defaultZIndex;
|
|
425
|
-
readonly transition: TConfig["transition"] extends Record<string, string> ? TConfig["transition"] : typeof defaultTransition;
|
|
426
|
-
readonly opacity: TConfig["opacity"] extends Record<string, number> ? TConfig["opacity"] : typeof defaultOpacity;
|
|
427
|
-
readonly breakpoints: TConfig["breakpoints"] extends Record<string, string> ? TConfig["breakpoints"] : typeof defaultBreakpoints;
|
|
428
|
-
};
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* Color Scales - Modern color palettes with shades from 25 to 950
|
|
432
|
-
*
|
|
433
|
-
* Scales are only accessible via the colors object to maintain consistency
|
|
434
|
-
*
|
|
435
|
-
* @example
|
|
436
|
-
* ```ts
|
|
437
|
-
* import { colors } from '@aurora-ui/theme'
|
|
438
|
-
*
|
|
439
|
-
* colors.indigo[500] // '#6366f1'
|
|
440
|
-
* colors.emerald[400] // '#34d399'
|
|
441
|
-
* colors.gray[900] // '#18181b'
|
|
442
|
-
* ```
|
|
443
|
-
*/
|
|
444
|
-
/**
|
|
445
|
-
* All color scales organized by name
|
|
446
|
-
* All scales and special values are only accessible via this object
|
|
447
|
-
*/
|
|
38
|
+
/** All color scales (19 scales with 12 shades each) */
|
|
448
39
|
declare const colors: {
|
|
449
40
|
readonly gray: ColorScale;
|
|
450
41
|
readonly slate: ColorScale;
|
|
@@ -471,9 +62,39 @@ declare const colors: {
|
|
|
471
62
|
readonly current: "currentColor";
|
|
472
63
|
};
|
|
473
64
|
|
|
65
|
+
type ThemeProviderProps = {
|
|
66
|
+
theme: Theme;
|
|
67
|
+
children?: ReactNode;
|
|
68
|
+
};
|
|
474
69
|
/**
|
|
475
|
-
*
|
|
70
|
+
* Provides the theme to all child components.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```tsx
|
|
74
|
+
* <ThemeProvider theme={lightTheme}>
|
|
75
|
+
* <App />
|
|
76
|
+
* </ThemeProvider>
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
declare const ThemeProvider: ({ theme, children }: ThemeProviderProps) => react_jsx_runtime.JSX.Element;
|
|
80
|
+
/**
|
|
81
|
+
* Hook to access the current theme.
|
|
82
|
+
*
|
|
83
|
+
* Type is automatically inferred from ThemeRegistry (module augmentation).
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```tsx
|
|
87
|
+
* function MyComponent() {
|
|
88
|
+
* const theme = useTheme()
|
|
89
|
+
* return <div style={{ color: theme.colors.primary }} />
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @throws {Error} If used outside a ThemeProvider
|
|
476
94
|
*/
|
|
95
|
+
declare const useTheme: () => Theme;
|
|
96
|
+
|
|
97
|
+
/** CSS properties with support for pseudo-classes, media/container queries, and complex selectors */
|
|
477
98
|
type StyleWithPseudos = CSSProperties & {
|
|
478
99
|
[key: `:${string}`]: CSSProperties;
|
|
479
100
|
[key: `@media ${string}`]: CSSProperties;
|
|
@@ -481,194 +102,47 @@ type StyleWithPseudos = CSSProperties & {
|
|
|
481
102
|
[key: `@supports ${string}`]: CSSProperties;
|
|
482
103
|
[key: `& ${string}` | `&>${string}` | `&:${string}` | `&[${string}`]: CSSProperties;
|
|
483
104
|
};
|
|
484
|
-
/**
|
|
485
|
-
* Type for a function that returns StyleWithPseudos with any parameters
|
|
486
|
-
*/
|
|
105
|
+
/** Function that returns StyleWithPseudos */
|
|
487
106
|
type StyleFunction = (...args: never[]) => StyleWithPseudos;
|
|
488
|
-
/**
|
|
489
|
-
* Type for @font-face options
|
|
490
|
-
*/
|
|
107
|
+
/** Options for @font-face */
|
|
491
108
|
type FontFaceOptions = {
|
|
492
|
-
/** Font family name */
|
|
493
109
|
fontFamily: string;
|
|
494
|
-
/** Font source(s) - URL or local() */
|
|
495
110
|
src: string;
|
|
496
|
-
/** Font style */
|
|
497
111
|
fontStyle?: 'normal' | 'italic' | 'oblique';
|
|
498
|
-
/** Font weight */
|
|
499
112
|
fontWeight?: number | string;
|
|
500
|
-
/** Display behavior */
|
|
501
113
|
fontDisplay?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
|
|
502
|
-
/** Unicode character range */
|
|
503
114
|
unicodeRange?: string;
|
|
504
115
|
};
|
|
505
116
|
|
|
506
117
|
/**
|
|
507
|
-
*
|
|
508
|
-
*
|
|
509
|
-
* Supports custom themes via generic parameter.
|
|
510
|
-
*
|
|
511
|
-
* @example
|
|
512
|
-
* ```ts
|
|
513
|
-
* // Basic usage
|
|
514
|
-
* const STYLES = createStyles((theme) => ({
|
|
515
|
-
* root: {
|
|
516
|
-
* display: 'flex',
|
|
517
|
-
* padding: theme.spacing.md,
|
|
518
|
-
* ':hover': { backgroundColor: theme.colors.primary },
|
|
519
|
-
* }
|
|
520
|
-
* }))
|
|
521
|
-
*
|
|
522
|
-
* // With explicit theme type
|
|
523
|
-
* const myTheme = createTheme({ colors: { brand: '#007bff' } })
|
|
524
|
-
*
|
|
525
|
-
* const STYLES = createStyles((theme) => ({
|
|
526
|
-
* root: {
|
|
527
|
-
* backgroundColor: theme.colors.primary, // TypeScript knows the structure!
|
|
528
|
-
* }
|
|
529
|
-
* }))
|
|
530
|
-
* ```
|
|
118
|
+
* Creates styles with theme support. Type is inferred from ThemeRegistry.
|
|
119
|
+
* Supports pseudo-classes, media queries, and complex selectors.
|
|
531
120
|
*/
|
|
532
|
-
declare const createStyles: <T extends Record<string, StyleWithPseudos | StyleFunction> = Record<string, StyleWithPseudos | StyleFunction>>(stylesOrCreator: T | ((theme:
|
|
533
|
-
/**
|
|
534
|
-
* Create a typed createStyles function pre-configured with your custom theme type.
|
|
535
|
-
* This eliminates the need to specify the theme type on every createStyles call.
|
|
536
|
-
*
|
|
537
|
-
* @example
|
|
538
|
-
* ```ts
|
|
539
|
-
* // 1. Define your theme
|
|
540
|
-
* const myTheme = createTheme({
|
|
541
|
-
* colors: {
|
|
542
|
-
* brand: '#007bff',
|
|
543
|
-
* surface: '#ffffff',
|
|
544
|
-
* }
|
|
545
|
-
* })
|
|
546
|
-
*
|
|
547
|
-
* // 2. Create a pre-typed createStyles function (do this once)
|
|
548
|
-
* export const createStyles = createTypedStyles<typeof myTheme>()
|
|
549
|
-
*
|
|
550
|
-
* // 3. Use it everywhere without specifying the type!
|
|
551
|
-
* const STYLES = createStyles((theme) => ({
|
|
552
|
-
* button: {
|
|
553
|
-
* backgroundColor: theme.colors.primary, // ✅ TypeScript knows!
|
|
554
|
-
* },
|
|
555
|
-
* }))
|
|
556
|
-
* ```
|
|
557
|
-
*/
|
|
558
|
-
declare const createTypedStyles: <TTheme extends ThemeStructure = ThemeStructure>() => <T extends Record<string, StyleWithPseudos | StyleFunction>>(stylesOrCreator: T | ((theme: TTheme) => T)) => { [K in keyof T]: T[K] extends (...args: infer TArgs) => StyleWithPseudos ? (...args: TArgs) => string : string; };
|
|
121
|
+
declare const createStyles: <T extends Record<string, StyleWithPseudos | StyleFunction> = Record<string, StyleWithPseudos | StyleFunction>>(stylesOrCreator: T | ((theme: Theme) => T)) => { [K in keyof T]: T[K] extends (...args: infer TArgs) => StyleWithPseudos ? (...args: TArgs) => string : string; };
|
|
559
122
|
|
|
560
|
-
/**
|
|
561
|
-
* Create and inject keyframes
|
|
562
|
-
*
|
|
563
|
-
* @example
|
|
564
|
-
* ```ts
|
|
565
|
-
* const fadeIn = keyframes({
|
|
566
|
-
* from: { opacity: 0 },
|
|
567
|
-
* to: { opacity: 1 }
|
|
568
|
-
* })
|
|
569
|
-
*
|
|
570
|
-
* const STYLES = createStyles({
|
|
571
|
-
* animated: { animation: `${fadeIn} 0.3s ease-in-out` }
|
|
572
|
-
* })
|
|
573
|
-
* ```
|
|
574
|
-
*/
|
|
123
|
+
/** Creates and injects a @keyframes rule, returns the animation name */
|
|
575
124
|
declare const keyframes: (frames: Record<string, CSSProperties>) => string;
|
|
576
125
|
|
|
577
|
-
/**
|
|
578
|
-
* Inject a @font-face rule
|
|
579
|
-
*
|
|
580
|
-
* @example
|
|
581
|
-
* ```ts
|
|
582
|
-
* fontFace({
|
|
583
|
-
* fontFamily: 'MyFont',
|
|
584
|
-
* src: "url('/fonts/myfont.woff2') format('woff2')",
|
|
585
|
-
* fontWeight: 400,
|
|
586
|
-
* fontStyle: 'normal',
|
|
587
|
-
* fontDisplay: 'swap'
|
|
588
|
-
* })
|
|
589
|
-
* ```
|
|
590
|
-
*/
|
|
126
|
+
/** Injects a @font-face rule and returns the font family name */
|
|
591
127
|
declare const fontFace: (options: FontFaceOptions) => string;
|
|
592
128
|
|
|
593
|
-
/**
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
*
|
|
597
|
-
* @example
|
|
598
|
-
* ```ts
|
|
599
|
-
* // In ThemeProvider
|
|
600
|
-
* injectCssVariables(theme, 'aurora')
|
|
601
|
-
* // Generates: :root { --aurora-colors-primary: #2563EB; ... }
|
|
602
|
-
* ```
|
|
603
|
-
*/
|
|
604
|
-
declare const injectCssVariables: (theme: ThemeStructure, prefix?: string) => void;
|
|
605
|
-
/**
|
|
606
|
-
* Helper to use a CSS variable from the theme
|
|
607
|
-
*
|
|
608
|
-
* @example
|
|
609
|
-
* ```ts
|
|
610
|
-
* const STYLES = createStyles({
|
|
611
|
-
* root: { color: cssVar('colors-primary') }
|
|
612
|
-
* })
|
|
613
|
-
* // Generates: color: var(--theme-colors-primary)
|
|
614
|
-
* ```
|
|
615
|
-
*/
|
|
129
|
+
/** Injects CSS variables from theme into :root */
|
|
130
|
+
declare const injectCssVariables: (theme: Theme, prefix?: string) => void;
|
|
131
|
+
/** Returns a CSS var() reference for a theme path */
|
|
616
132
|
declare const cssVar: (path: string, fallback?: string) => string;
|
|
617
|
-
/**
|
|
618
|
-
* Create CSS variable references from a typed object
|
|
619
|
-
* Returns an object with the same structure where values are var() references
|
|
620
|
-
*
|
|
621
|
-
* @example
|
|
622
|
-
* ```ts
|
|
623
|
-
* const vars = cssVariables({
|
|
624
|
-
* primaryColor: '#007bff',
|
|
625
|
-
* spacing: '1rem',
|
|
626
|
-
* })
|
|
627
|
-
* // vars.primaryColor === 'var(--primary-color)'
|
|
628
|
-
* ```
|
|
629
|
-
*/
|
|
133
|
+
/** Creates CSS variable references from an object */
|
|
630
134
|
declare const cssVariables: <T extends Record<string, string | number>>(variables: T, options?: {
|
|
631
135
|
prefix?: string;
|
|
632
136
|
inject?: boolean;
|
|
633
137
|
}) => { [K in keyof T]: string; };
|
|
634
138
|
|
|
635
|
-
/**
|
|
636
|
-
* SSR: Get all collected CSS rules as a single string
|
|
637
|
-
* @returns The CSS content to inject into HTML
|
|
638
|
-
*/
|
|
139
|
+
/** SSR: Returns all collected CSS rules as a single string */
|
|
639
140
|
declare const getSSRStyles: () => string;
|
|
640
|
-
/**
|
|
641
|
-
* SSR: Get styles as a <style> tag ready to inject
|
|
642
|
-
* @returns The complete style tag to inject into <head>
|
|
643
|
-
*/
|
|
141
|
+
/** SSR: Returns styles wrapped in a style tag */
|
|
644
142
|
declare const getSSRStyleTag: () => string;
|
|
645
|
-
/**
|
|
646
|
-
* SSR: Clear the collected rules buffer
|
|
647
|
-
* Call at the beginning of each SSR request to ensure clean state
|
|
648
|
-
*/
|
|
143
|
+
/** SSR: Clears the collected rules buffer */
|
|
649
144
|
declare const clearSSRRules: () => void;
|
|
650
|
-
/**
|
|
651
|
-
* SSR: Get raw CSS rules as an array
|
|
652
|
-
* @returns Array of CSS rules
|
|
653
|
-
*/
|
|
145
|
+
/** SSR: Returns raw CSS rules as an array */
|
|
654
146
|
declare const getSSRRulesArray: () => string[];
|
|
655
147
|
|
|
656
|
-
|
|
657
|
-
* Set the theme getter
|
|
658
|
-
*/
|
|
659
|
-
declare const setThemeContextGetter: (getter: (() => ThemeStructure | undefined) | null) => (() => ThemeStructure | undefined) | null;
|
|
660
|
-
/**
|
|
661
|
-
* Get the current theme
|
|
662
|
-
*/
|
|
663
|
-
declare const getTheme: () => ThemeStructure | undefined;
|
|
664
|
-
/**
|
|
665
|
-
* Insert a CSS rule
|
|
666
|
-
*/
|
|
667
|
-
declare const insertRule: (rule: string) => void;
|
|
668
|
-
/**
|
|
669
|
-
* Sanitize a CSS value to prevent injection attacks
|
|
670
|
-
* Returns the sanitized value or 'unset' if the value is dangerous
|
|
671
|
-
*/
|
|
672
|
-
declare const sanitizeCssValue: (value: string) => string;
|
|
673
|
-
|
|
674
|
-
export { type BaseBreakpoints, type BaseColors, type BaseFontSize, type BaseFontWeight, type BaseLineHeight, type BaseOpacity, type BaseRadius, type BaseShadows, type BaseSpacing, type BaseTransition, type BaseZIndex, type ColorScale, type ColorShade, type FontFaceOptions, type StyleFunction, type StyleWithPseudos, type Theme, ThemeProvider, type ThemeProviderProps, clearSSRRules, colors, createStyles, createTheme, createTypedStyles, cssVar, cssVariables, defaultBreakpoints, defaultFontSize, defaultFontWeight, defaultLineHeight, defaultOpacity, defaultPalette, defaultRadius, defaultShadows, defaultSpacing, defaultTransition, defaultZIndex, fontFace, getSSRRulesArray, getSSRStyleTag, getSSRStyles, getTheme, injectCssVariables, insertRule, keyframes, sanitizeCssValue, setThemeContextGetter, useTheme };
|
|
148
|
+
export { type FontFaceOptions, type StyleWithPseudos, ThemeProvider, type ThemeRegistry, clearSSRRules, colors, createStyles, createTheme, cssVar, cssVariables, fontFace, getSSRRulesArray, getSSRStyleTag, getSSRStyles, injectCssVariables, keyframes, useTheme };
|