@aurora-ds/theme 1.0.3

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.
@@ -0,0 +1,685 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode, CSSProperties } from 'react';
3
+ export { CSSProperties } from 'react';
4
+
5
+ /**
6
+ * Base color tokens following modern design system semantics
7
+ */
8
+ type BaseColors = {
9
+ primary: string;
10
+ onPrimary: string;
11
+ primaryHover: string;
12
+ primaryActive: string;
13
+ primarySubtle: string;
14
+ secondary: string;
15
+ onSecondary: string;
16
+ secondaryHover: string;
17
+ secondaryActive: string;
18
+ secondarySubtle: string;
19
+ accent: string;
20
+ onAccent: string;
21
+ accentHover: string;
22
+ accentSubtle: string;
23
+ background: string;
24
+ surface: string;
25
+ surfaceHover: string;
26
+ surfaceActive: string;
27
+ elevated: string;
28
+ overlay: string;
29
+ text: string;
30
+ textSecondary: string;
31
+ textTertiary: string;
32
+ textInverse: string;
33
+ border: string;
34
+ borderHover: string;
35
+ borderFocus: string;
36
+ borderSubtle: string;
37
+ success: string;
38
+ onSuccess: string;
39
+ successHover: string;
40
+ successSubtle: string;
41
+ warning: string;
42
+ onWarning: string;
43
+ warningHover: string;
44
+ warningSubtle: string;
45
+ error: string;
46
+ onError: string;
47
+ errorHover: string;
48
+ errorSubtle: string;
49
+ info: string;
50
+ onInfo: string;
51
+ infoHover: string;
52
+ infoSubtle: string;
53
+ link: string;
54
+ linkHover: string;
55
+ linkVisited: string;
56
+ focus: string;
57
+ disabled: string;
58
+ disabledText: string;
59
+ };
60
+
61
+ /**
62
+ * Spacing scale with semantic naming
63
+ * Based on 4px unit system
64
+ */
65
+ type BaseSpacing = {
66
+ none: string;
67
+ xs: string;
68
+ sm: string;
69
+ md: string;
70
+ lg: string;
71
+ xl: string;
72
+ };
73
+
74
+ /**
75
+ * Border radius scale
76
+ */
77
+ type BaseRadius = {
78
+ none: string;
79
+ xs: string;
80
+ sm: string;
81
+ md: string;
82
+ lg: string;
83
+ xl: string;
84
+ full: string;
85
+ };
86
+
87
+ /**
88
+ * Shadow scale for elevation
89
+ */
90
+ type BaseShadows = {
91
+ none: string;
92
+ xs: string;
93
+ sm: string;
94
+ md: string;
95
+ lg: string;
96
+ xl: string;
97
+ };
98
+
99
+ /**
100
+ * Font size scale
101
+ */
102
+ type BaseFontSize = {
103
+ xs: string;
104
+ sm: string;
105
+ md: string;
106
+ lg: string;
107
+ xl: string;
108
+ };
109
+
110
+ /**
111
+ * Font weight scale
112
+ */
113
+ type BaseFontWeight = {
114
+ light: number;
115
+ regular: number;
116
+ medium: number;
117
+ semibold: number;
118
+ bold: number;
119
+ };
120
+
121
+ /**
122
+ * Line height scale
123
+ */
124
+ type BaseLineHeight = {
125
+ none: number;
126
+ tight: number;
127
+ normal: number;
128
+ relaxed: number;
129
+ };
130
+
131
+ /**
132
+ * Z-index scale for layering
133
+ */
134
+ type BaseZIndex = {
135
+ behind: number;
136
+ base: number;
137
+ dropdown: number;
138
+ overlay: number;
139
+ modal: number;
140
+ tooltip: number;
141
+ };
142
+
143
+ /**
144
+ * Transition timing scale
145
+ */
146
+ type BaseTransition = {
147
+ fast: string;
148
+ normal: string;
149
+ slow: string;
150
+ };
151
+
152
+ /**
153
+ * Standard theme type with all required tokens
154
+ */
155
+ type Theme = {
156
+ colors: BaseColors;
157
+ spacing: BaseSpacing;
158
+ radius: BaseRadius;
159
+ shadows: BaseShadows;
160
+ fontSize: BaseFontSize;
161
+ fontWeight: BaseFontWeight;
162
+ lineHeight: BaseLineHeight;
163
+ zIndex: BaseZIndex;
164
+ transition: BaseTransition;
165
+ };
166
+
167
+ /**
168
+ * Generic theme type that allows extending base tokens
169
+ */
170
+ type ExtendedTheme<TColors extends BaseColors = BaseColors, TSpacing extends BaseSpacing = BaseSpacing, TRadius extends BaseRadius = BaseRadius, TShadows extends BaseShadows = BaseShadows, TFontSize extends BaseFontSize = BaseFontSize, TFontWeight extends BaseFontWeight = BaseFontWeight, TLineHeight extends BaseLineHeight = BaseLineHeight, TZIndex extends BaseZIndex = BaseZIndex, TTransition extends BaseTransition = BaseTransition, TExtensions extends Record<string, unknown> = Record<string, never>> = {
171
+ colors: TColors;
172
+ spacing: TSpacing;
173
+ radius: TRadius;
174
+ shadows: TShadows;
175
+ fontSize: TFontSize;
176
+ fontWeight: TFontWeight;
177
+ lineHeight: TLineHeight;
178
+ zIndex: TZIndex;
179
+ transition: TTransition;
180
+ } & TExtensions;
181
+ /**
182
+ * Helper type to create a custom theme with extensions
183
+ */
184
+ type ExtendTheme<T extends Partial<Theme> & Record<string, unknown>> = Theme & T;
185
+ /**
186
+ * Utility type to deeply make all properties optional
187
+ */
188
+ type DeepPartial<T> = {
189
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
190
+ };
191
+ /**
192
+ * Type for theme overrides
193
+ */
194
+ type ThemeOverride<T extends Theme = Theme> = DeepPartial<T>;
195
+
196
+ /**
197
+ * Color scale type - 12 shades from 25 to 950
198
+ */
199
+ type ColorScale = {
200
+ 25: string;
201
+ 50: string;
202
+ 100: string;
203
+ 200: string;
204
+ 300: string;
205
+ 400: string;
206
+ 500: string;
207
+ 600: string;
208
+ 700: string;
209
+ 800: string;
210
+ 900: string;
211
+ 950: string;
212
+ };
213
+
214
+ /**
215
+ * Available color scale names
216
+ */
217
+ type ColorName = 'gray' | 'slate' | 'stone' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose';
218
+
219
+ /**
220
+ * Available shade values (keys of ColorScale)
221
+ */
222
+ type ColorShade = keyof ColorScale;
223
+
224
+ /**
225
+ * Available palette preset names
226
+ */
227
+ type PaletteName = 'indigo' | 'rose' | 'emerald' | 'violet' | 'amber' | 'cyan' | 'slate' | 'gray';
228
+
229
+ type ThemeProviderProps<T extends Theme = Theme> = {
230
+ theme: T;
231
+ children?: ReactNode;
232
+ };
233
+ /**
234
+ * Theme provider component
235
+ * Provides theme context to all child components
236
+ *
237
+ * @example
238
+ * ```tsx
239
+ * // With default theme
240
+ * <ThemeProvider theme={defaultTheme}>
241
+ * <App />
242
+ * </ThemeProvider>
243
+ *
244
+ * // With custom extended theme
245
+ * <ThemeProvider theme={myCustomTheme}>
246
+ * <App />
247
+ * </ThemeProvider>
248
+ * ```
249
+ */
250
+ declare const ThemeProvider: <T extends Theme>({ theme, children }: ThemeProviderProps<T>) => react_jsx_runtime.JSX.Element;
251
+ /**
252
+ * Hook to access the current theme
253
+ * Use the generic parameter to get proper typing for extended themes
254
+ *
255
+ * @example
256
+ * ```tsx
257
+ * // Basic usage
258
+ * const theme = useTheme()
259
+ *
260
+ * // With custom theme type
261
+ * const theme = useTheme<MyCustomTheme>()
262
+ * ```
263
+ *
264
+ * @throws {Error} If used outside a ThemeProvider
265
+ */
266
+ declare const useTheme: <T extends Theme = Theme>() => T;
267
+
268
+ /**
269
+ * Create a theme by merging a base theme with overrides
270
+ *
271
+ * @example
272
+ * ```ts
273
+ * const myTheme = createTheme(defaultTheme, {
274
+ * colors: {
275
+ * primary: '#ff0000',
276
+ * // Only override what you need
277
+ * },
278
+ * spacing: {
279
+ * md: '1.5rem',
280
+ * },
281
+ * })
282
+ * ```
283
+ */
284
+ declare const createTheme: <T extends Theme>(baseTheme: T, overrides: DeepPartial<T>) => T;
285
+ /**
286
+ * Merge multiple theme overrides into one
287
+ * Later overrides take precedence
288
+ *
289
+ * @example
290
+ * ```ts
291
+ * const theme = mergeThemes(
292
+ * baseTheme,
293
+ * brandOverrides,
294
+ * darkModeOverrides,
295
+ * userPreferences
296
+ * )
297
+ * ```
298
+ */
299
+ declare const mergeThemes: <T extends Theme>(baseTheme: T, ...overrides: DeepPartial<T>[]) => T;
300
+ /**
301
+ * Create a theme extension factory
302
+ * Useful for creating theme variants (dark mode, high contrast, etc.)
303
+ *
304
+ * @example
305
+ * ```ts
306
+ * const createDarkVariant = createThemeVariant({
307
+ * colors: {
308
+ * background: '#1a1a1a',
309
+ * text: '#ffffff',
310
+ * },
311
+ * })
312
+ *
313
+ * const darkTheme = createDarkVariant(lightTheme)
314
+ * ```
315
+ */
316
+ declare const createThemeVariant: <T extends Theme>(variantOverrides: DeepPartial<T>) => (baseTheme: T) => T;
317
+
318
+ /**
319
+ * Default spacing scale
320
+ */
321
+ declare const defaultSpacing: Theme['spacing'];
322
+ /**
323
+ * Default border radius scale
324
+ */
325
+ declare const defaultRadius: Theme['radius'];
326
+ /**
327
+ * Default shadow scale
328
+ */
329
+ declare const defaultShadows: Theme['shadows'];
330
+ /**
331
+ * Default font size scale
332
+ */
333
+ declare const defaultFontSize: Theme['fontSize'];
334
+ /**
335
+ * Default font weight scale
336
+ */
337
+ declare const defaultFontWeight: Theme['fontWeight'];
338
+ /**
339
+ * Default line height scale
340
+ */
341
+ declare const defaultLineHeight: Theme['lineHeight'];
342
+ /**
343
+ * Default z-index scale
344
+ */
345
+ declare const defaultZIndex: Theme['zIndex'];
346
+ /**
347
+ * Default transition scale
348
+ */
349
+ declare const defaultTransition: Theme['transition'];
350
+ /**
351
+ * Default colors (using indigo palette)
352
+ */
353
+ declare const defaultColors: BaseColors;
354
+ /**
355
+ * Default dark colors (using indigo palette)
356
+ */
357
+ declare const defaultDarkColors: BaseColors;
358
+ /**
359
+ * Complete default light theme
360
+ */
361
+ declare const defaultTheme: Theme;
362
+ /**
363
+ * Complete default dark theme
364
+ */
365
+ declare const defaultDarkTheme: Theme;
366
+
367
+ declare const gray: ColorScale;
368
+
369
+ declare const slate: ColorScale;
370
+
371
+ declare const stone: ColorScale;
372
+
373
+ declare const red: ColorScale;
374
+
375
+ declare const orange: ColorScale;
376
+
377
+ declare const amber: ColorScale;
378
+
379
+ declare const yellow: ColorScale;
380
+
381
+ declare const lime: ColorScale;
382
+
383
+ declare const green: ColorScale;
384
+
385
+ declare const emerald: ColorScale;
386
+
387
+ declare const teal: ColorScale;
388
+
389
+ declare const cyan: ColorScale;
390
+
391
+ declare const sky: ColorScale;
392
+
393
+ declare const blue: ColorScale;
394
+
395
+ declare const indigo: ColorScale;
396
+
397
+ declare const violet: ColorScale;
398
+
399
+ declare const purple: ColorScale;
400
+
401
+ declare const fuchsia: ColorScale;
402
+
403
+ declare const pink: ColorScale;
404
+
405
+ declare const rose: ColorScale;
406
+
407
+ declare const white = "#ffffff";
408
+ declare const black = "#000000";
409
+ declare const transparent = "transparent";
410
+ declare const current = "currentColor";
411
+ /**
412
+ * All color scales organized by name
413
+ */
414
+ declare const colors: {
415
+ readonly gray: ColorScale;
416
+ readonly slate: ColorScale;
417
+ readonly stone: ColorScale;
418
+ readonly red: ColorScale;
419
+ readonly orange: ColorScale;
420
+ readonly amber: ColorScale;
421
+ readonly yellow: ColorScale;
422
+ readonly lime: ColorScale;
423
+ readonly green: ColorScale;
424
+ readonly emerald: ColorScale;
425
+ readonly teal: ColorScale;
426
+ readonly cyan: ColorScale;
427
+ readonly sky: ColorScale;
428
+ readonly blue: ColorScale;
429
+ readonly indigo: ColorScale;
430
+ readonly violet: ColorScale;
431
+ readonly purple: ColorScale;
432
+ readonly fuchsia: ColorScale;
433
+ readonly pink: ColorScale;
434
+ readonly rose: ColorScale;
435
+ readonly white: "#ffffff";
436
+ readonly black: "#000000";
437
+ readonly transparent: "transparent";
438
+ readonly current: "currentColor";
439
+ };
440
+
441
+ type ColorPalette$7 = Theme['colors'];
442
+ declare const indigoLight: ColorPalette$7;
443
+ declare const indigoDark: ColorPalette$7;
444
+
445
+ type ColorPalette$6 = Theme['colors'];
446
+ declare const roseLight: ColorPalette$6;
447
+ declare const roseDark: ColorPalette$6;
448
+
449
+ type ColorPalette$5 = Theme['colors'];
450
+ declare const emeraldLight: ColorPalette$5;
451
+ declare const emeraldDark: ColorPalette$5;
452
+
453
+ type ColorPalette$4 = Theme['colors'];
454
+ declare const violetLight: ColorPalette$4;
455
+ declare const violetDark: ColorPalette$4;
456
+
457
+ type ColorPalette$3 = Theme['colors'];
458
+ declare const amberLight: ColorPalette$3;
459
+ declare const amberDark: ColorPalette$3;
460
+
461
+ type ColorPalette$2 = Theme['colors'];
462
+ declare const cyanLight: ColorPalette$2;
463
+ declare const cyanDark: ColorPalette$2;
464
+
465
+ type ColorPalette$1 = Theme['colors'];
466
+ declare const slateLight: ColorPalette$1;
467
+ declare const slateDark: ColorPalette$1;
468
+
469
+ type ColorPalette = Theme['colors'];
470
+ declare const grayLight: ColorPalette;
471
+ declare const grayDark: ColorPalette;
472
+
473
+ /**
474
+ * All available color palettes organized by name
475
+ */
476
+ declare const palettes: {
477
+ readonly indigo: {
478
+ readonly light: BaseColors;
479
+ readonly dark: BaseColors;
480
+ };
481
+ readonly rose: {
482
+ readonly light: BaseColors;
483
+ readonly dark: BaseColors;
484
+ };
485
+ readonly emerald: {
486
+ readonly light: BaseColors;
487
+ readonly dark: BaseColors;
488
+ };
489
+ readonly violet: {
490
+ readonly light: BaseColors;
491
+ readonly dark: BaseColors;
492
+ };
493
+ readonly amber: {
494
+ readonly light: BaseColors;
495
+ readonly dark: BaseColors;
496
+ };
497
+ readonly cyan: {
498
+ readonly light: BaseColors;
499
+ readonly dark: BaseColors;
500
+ };
501
+ readonly slate: {
502
+ readonly light: BaseColors;
503
+ readonly dark: BaseColors;
504
+ };
505
+ readonly gray: {
506
+ readonly light: BaseColors;
507
+ readonly dark: BaseColors;
508
+ };
509
+ };
510
+
511
+ /**
512
+ * Extended type to support pseudo-classes, media queries, container queries, supports and complex selectors
513
+ */
514
+ type StyleWithPseudos = CSSProperties & {
515
+ [key: `:${string}`]: CSSProperties;
516
+ [key: `@media ${string}`]: CSSProperties;
517
+ [key: `@container ${string}`]: CSSProperties;
518
+ [key: `@supports ${string}`]: CSSProperties;
519
+ [key: `& ${string}` | `&>${string}` | `&:${string}` | `&[${string}`]: CSSProperties;
520
+ };
521
+ /**
522
+ * Type for a function that returns StyleWithPseudos with any parameters
523
+ */
524
+ type StyleFunction = (...args: never[]) => StyleWithPseudos;
525
+ /**
526
+ * Type for @font-face options
527
+ */
528
+ type FontFaceOptions = {
529
+ /** Font family name */
530
+ fontFamily: string;
531
+ /** Font source(s) - URL or local() */
532
+ src: string;
533
+ /** Font style */
534
+ fontStyle?: 'normal' | 'italic' | 'oblique';
535
+ /** Font weight */
536
+ fontWeight?: number | string;
537
+ /** Display behavior */
538
+ fontDisplay?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
539
+ /** Unicode character range */
540
+ unicodeRange?: string;
541
+ };
542
+
543
+ /**
544
+ * Create typed styles with support for pseudo-classes, media queries, container queries, feature queries and complex selectors
545
+ *
546
+ * Supports custom extended themes via generic parameter.
547
+ *
548
+ * @example
549
+ * ```ts
550
+ * // Basic usage with default theme
551
+ * const STYLES = createStyles((theme) => ({
552
+ * root: {
553
+ * display: 'flex',
554
+ * padding: theme.spacing.md,
555
+ * ':hover': { backgroundColor: theme.colors.backgroundHover },
556
+ * }
557
+ * }))
558
+ *
559
+ * // With custom extended theme
560
+ * type MyTheme = Theme & { colors: BaseColors & { accent: string } }
561
+ *
562
+ * const STYLES = createStyles<MyTheme>((theme) => ({
563
+ * root: {
564
+ * backgroundColor: theme.colors.accent, // TypeScript knows about accent!
565
+ * }
566
+ * }))
567
+ * ```
568
+ */
569
+ declare const createStyles: <TTheme extends Theme = Theme, T extends Record<string, StyleWithPseudos | StyleFunction> = Record<string, StyleWithPseudos | StyleFunction>>(stylesOrCreator: T | ((theme: TTheme) => T)) => { [K in keyof T]: T[K] extends (...args: infer TArgs) => StyleWithPseudos ? (...args: TArgs) => string : string; };
570
+
571
+ /**
572
+ * Create and inject keyframes
573
+ *
574
+ * @example
575
+ * ```ts
576
+ * const fadeIn = keyframes({
577
+ * from: { opacity: 0 },
578
+ * to: { opacity: 1 }
579
+ * })
580
+ *
581
+ * const STYLES = createStyles({
582
+ * animated: { animation: `${fadeIn} 0.3s ease-in-out` }
583
+ * })
584
+ * ```
585
+ */
586
+ declare const keyframes: (frames: Record<string, CSSProperties>) => string;
587
+
588
+ /**
589
+ * Inject a @font-face rule
590
+ *
591
+ * @example
592
+ * ```ts
593
+ * fontFace({
594
+ * fontFamily: 'MyFont',
595
+ * src: "url('/fonts/myfont.woff2') format('woff2')",
596
+ * fontWeight: 400,
597
+ * fontStyle: 'normal',
598
+ * fontDisplay: 'swap'
599
+ * })
600
+ * ```
601
+ */
602
+ declare const fontFace: (options: FontFaceOptions) => string;
603
+
604
+ /**
605
+ * Create CSS variables from the theme
606
+ * Injects variables into :root
607
+ *
608
+ * @example
609
+ * ```ts
610
+ * // In ThemeProvider
611
+ * injectCssVariables(theme, 'aurora')
612
+ * // Generates: :root { --aurora-colors-primary: #2563EB; ... }
613
+ * ```
614
+ */
615
+ declare const injectCssVariables: (theme: Theme, prefix?: string) => void;
616
+ /**
617
+ * Helper to use a CSS variable from the theme
618
+ *
619
+ * @example
620
+ * ```ts
621
+ * const STYLES = createStyles({
622
+ * root: { color: cssVar('colors-primary') }
623
+ * })
624
+ * // Generates: color: var(--theme-colors-primary)
625
+ * ```
626
+ */
627
+ declare const cssVar: (path: string, fallback?: string) => string;
628
+ /**
629
+ * Create CSS variable references from a typed object
630
+ * Returns an object with the same structure where values are var() references
631
+ *
632
+ * @example
633
+ * ```ts
634
+ * const vars = cssVariables({
635
+ * primaryColor: '#007bff',
636
+ * spacing: '1rem',
637
+ * })
638
+ * // vars.primaryColor === 'var(--primary-color)'
639
+ * ```
640
+ */
641
+ declare const cssVariables: <T extends Record<string, string | number>>(variables: T, options?: {
642
+ prefix?: string;
643
+ inject?: boolean;
644
+ }) => { [K in keyof T]: string; };
645
+
646
+ /**
647
+ * SSR: Get all collected CSS rules as a single string
648
+ * @returns The CSS content to inject into HTML
649
+ */
650
+ declare const getSSRStyles: () => string;
651
+ /**
652
+ * SSR: Get styles as a <style> tag ready to inject
653
+ * @returns The complete style tag to inject into <head>
654
+ */
655
+ declare const getSSRStyleTag: () => string;
656
+ /**
657
+ * SSR: Clear the collected rules buffer
658
+ * Call at the beginning of each SSR request to ensure clean state
659
+ */
660
+ declare const clearSSRRules: () => void;
661
+ /**
662
+ * SSR: Get raw CSS rules as an array
663
+ * @returns Array of CSS rules
664
+ */
665
+ declare const getSSRRulesArray: () => string[];
666
+
667
+ /**
668
+ * Set the theme getter
669
+ */
670
+ declare const setThemeContextGetter: (getter: (() => Theme | undefined) | null) => (() => Theme | undefined) | null;
671
+ /**
672
+ * Get the current theme
673
+ */
674
+ declare const getTheme: () => Theme | undefined;
675
+ /**
676
+ * Insert a CSS rule
677
+ */
678
+ declare const insertRule: (rule: string) => void;
679
+ /**
680
+ * Sanitize a CSS value to prevent injection attacks
681
+ * Returns the sanitized value or 'unset' if the value is dangerous
682
+ */
683
+ declare const sanitizeCssValue: (value: string) => string;
684
+
685
+ export { type BaseColors, type BaseFontSize, type BaseFontWeight, type BaseLineHeight, type BaseRadius, type BaseShadows, type BaseSpacing, type BaseTransition, type BaseZIndex, type ColorName, type ColorScale, type ColorShade, type DeepPartial, type ExtendTheme, type ExtendedTheme, type FontFaceOptions, type PaletteName, type StyleFunction, type StyleWithPseudos, type Theme, type ThemeOverride, ThemeProvider, type ThemeProviderProps, amber, amberDark, amberLight, black, blue, clearSSRRules, colors, createStyles, createTheme, createThemeVariant, cssVar, cssVariables, current, cyan, cyanDark, cyanLight, defaultColors, defaultDarkColors, defaultDarkTheme, defaultFontSize, defaultFontWeight, defaultLineHeight, defaultRadius, defaultShadows, defaultSpacing, defaultTheme, defaultTransition, defaultZIndex, emerald, emeraldDark, emeraldLight, fontFace, fuchsia, getSSRRulesArray, getSSRStyleTag, getSSRStyles, getTheme, gray, grayDark, grayLight, green, indigo, indigoDark, indigoLight, injectCssVariables, insertRule, keyframes, lime, mergeThemes, orange, palettes, pink, purple, red, rose, roseDark, roseLight, sanitizeCssValue, setThemeContextGetter, sky, slate, slateDark, slateLight, stone, teal, transparent, useTheme, violet, violetDark, violetLight, white, yellow };