@aurora-ds/theme 1.2.9 → 1.5.0

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/dist/index.d.cts CHANGED
@@ -2,6 +2,26 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode, CSSProperties } from 'react';
3
3
  export { CSSProperties } from 'react';
4
4
 
5
+ /**
6
+ * Responsive breakpoints for mobile-first design
7
+ * Based on common device widths
8
+ *
9
+ * - xs: Extra small devices (phones in portrait)
10
+ * - sm: Small devices (phones in landscape, small tablets)
11
+ * - md: Medium devices (tablets)
12
+ * - lg: Large devices (desktops)
13
+ * - xl: Extra large devices (large desktops)
14
+ * - 2xl: Extra extra large devices (wide screens)
15
+ */
16
+ type BaseBreakpoints = {
17
+ xs: string;
18
+ sm: string;
19
+ md: string;
20
+ lg: string;
21
+ xl: string;
22
+ '2xl': string;
23
+ };
24
+
5
25
  /**
6
26
  * Base color tokens following modern design system semantics
7
27
  */
@@ -11,15 +31,24 @@ type BaseColors = {
11
31
  primaryHover: string;
12
32
  primaryActive: string;
13
33
  primarySubtle: string;
34
+ primaryDisabled: string;
14
35
  secondary: string;
15
36
  onSecondary: string;
16
37
  secondaryHover: string;
17
38
  secondaryActive: string;
18
39
  secondarySubtle: string;
40
+ secondaryDisabled: string;
19
41
  accent: string;
20
42
  onAccent: string;
21
43
  accentHover: string;
44
+ accentActive: string;
22
45
  accentSubtle: string;
46
+ tertiary: string;
47
+ onTertiary: string;
48
+ tertiaryHover: string;
49
+ tertiaryActive: string;
50
+ tertiarySubtle: string;
51
+ tertiaryDisabled: string;
23
52
  background: string;
24
53
  surface: string;
25
54
  surfaceHover: string;
@@ -52,6 +81,7 @@ type BaseColors = {
52
81
  infoSubtle: string;
53
82
  link: string;
54
83
  linkHover: string;
84
+ linkActive: string;
55
85
  linkVisited: string;
56
86
  focus: string;
57
87
  disabled: string;
@@ -86,6 +116,7 @@ type BaseRadius = {
86
116
  md: string;
87
117
  lg: string;
88
118
  xl: string;
119
+ '2xl': string;
89
120
  full: string;
90
121
  };
91
122
 
@@ -99,6 +130,9 @@ type BaseShadows = {
99
130
  md: string;
100
131
  lg: string;
101
132
  xl: string;
133
+ '2xl': string;
134
+ inner: string;
135
+ focus: string;
102
136
  };
103
137
 
104
138
  /**
@@ -136,6 +170,7 @@ type BaseLineHeight = {
136
170
  tight: number;
137
171
  normal: number;
138
172
  relaxed: number;
173
+ loose: number;
139
174
  };
140
175
 
141
176
  /**
@@ -145,9 +180,12 @@ type BaseZIndex = {
145
180
  behind: number;
146
181
  base: number;
147
182
  dropdown: number;
183
+ sticky: number;
148
184
  overlay: number;
149
185
  modal: number;
186
+ popover: number;
150
187
  tooltip: number;
188
+ toast: number;
151
189
  };
152
190
 
153
191
  /**
@@ -159,6 +197,26 @@ type BaseTransition = {
159
197
  slow: string;
160
198
  };
161
199
 
200
+ /**
201
+ * Base opacity scale for consistent transparency
202
+ */
203
+ type BaseOpacity = {
204
+ /** Fully transparent - 0 */
205
+ none: number;
206
+ /** Very low opacity - 0.05 */
207
+ lowest: number;
208
+ /** Low opacity - 0.1 */
209
+ low: number;
210
+ /** Medium-low opacity - 0.25 */
211
+ medium: number;
212
+ /** Medium-high opacity - 0.5 */
213
+ high: number;
214
+ /** High opacity - 0.75 */
215
+ higher: number;
216
+ /** Fully opaque - 1 */
217
+ full: number;
218
+ };
219
+
162
220
  /**
163
221
  * Standard theme type with all required tokens
164
222
  */
@@ -172,6 +230,8 @@ type Theme = {
172
230
  lineHeight: BaseLineHeight;
173
231
  zIndex: BaseZIndex;
174
232
  transition: BaseTransition;
233
+ opacity: BaseOpacity;
234
+ breakpoints: BaseBreakpoints;
175
235
  };
176
236
 
177
237
  /**
@@ -357,6 +417,14 @@ declare const defaultZIndex: Theme['zIndex'];
357
417
  * Default transition scale
358
418
  */
359
419
  declare const defaultTransition: Theme['transition'];
420
+ /**
421
+ * Default opacity scale
422
+ */
423
+ declare const defaultOpacity: Theme['opacity'];
424
+ /**
425
+ * Default responsive breakpoints
426
+ */
427
+ declare const defaultBreakpoints: Theme['breakpoints'];
360
428
  /**
361
429
  * Default colors (using indigo palette)
362
430
  */
@@ -462,108 +530,108 @@ declare const indigoDark: ColorPalette$9;
462
530
 
463
531
  type ColorPalette$8 = Theme['colors'];
464
532
  /**
465
- * Blue light palette - Modern, accessible color scheme
533
+ * Blue light palette - Classic, accessible color scheme
466
534
  * Follows WCAG AA contrast guidelines
467
535
  */
468
536
  declare const blueLight: ColorPalette$8;
469
537
  /**
470
- * Blue dark palette - Modern, accessible color scheme
538
+ * Blue dark palette - Classic, accessible color scheme
471
539
  * Follows WCAG AA contrast guidelines
472
540
  */
473
541
  declare const blueDark: ColorPalette$8;
474
542
 
475
543
  type ColorPalette$7 = Theme['colors'];
476
544
  /**
477
- * Rose light palette - Modern, accessible color scheme
545
+ * Rose light palette - Elegant, accessible color scheme
478
546
  * Follows WCAG AA contrast guidelines
479
547
  */
480
548
  declare const roseLight: ColorPalette$7;
481
549
  /**
482
- * Rose dark palette - Modern, accessible color scheme
550
+ * Rose dark palette - Elegant, accessible color scheme
483
551
  * Follows WCAG AA contrast guidelines
484
552
  */
485
553
  declare const roseDark: ColorPalette$7;
486
554
 
487
555
  type ColorPalette$6 = Theme['colors'];
488
556
  /**
489
- * Emerald light palette - Modern, accessible color scheme
557
+ * Emerald light palette - Fresh, accessible color scheme
490
558
  * Follows WCAG AA contrast guidelines
491
559
  */
492
560
  declare const emeraldLight: ColorPalette$6;
493
561
  /**
494
- * Emerald dark palette - Modern, accessible color scheme
562
+ * Emerald dark palette - Fresh, accessible color scheme
495
563
  * Follows WCAG AA contrast guidelines
496
564
  */
497
565
  declare const emeraldDark: ColorPalette$6;
498
566
 
499
567
  type ColorPalette$5 = Theme['colors'];
500
568
  /**
501
- * Teal light palette - Modern, accessible color scheme
569
+ * Teal light palette - Cool, accessible color scheme
502
570
  * Follows WCAG AA contrast guidelines
503
571
  */
504
572
  declare const tealLight: ColorPalette$5;
505
573
  /**
506
- * Teal dark palette - Modern, accessible color scheme
574
+ * Teal dark palette - Cool, accessible color scheme
507
575
  * Follows WCAG AA contrast guidelines
508
576
  */
509
577
  declare const tealDark: ColorPalette$5;
510
578
 
511
579
  type ColorPalette$4 = Theme['colors'];
512
580
  /**
513
- * Violet light palette - Modern, accessible color scheme
581
+ * Violet light palette - Creative, accessible color scheme
514
582
  * Follows WCAG AA contrast guidelines
515
583
  */
516
584
  declare const violetLight: ColorPalette$4;
517
585
  /**
518
- * Violet dark palette - Modern, accessible color scheme
586
+ * Violet dark palette - Creative, accessible color scheme
519
587
  * Follows WCAG AA contrast guidelines
520
588
  */
521
589
  declare const violetDark: ColorPalette$4;
522
590
 
523
591
  type ColorPalette$3 = Theme['colors'];
524
592
  /**
525
- * Amber light palette - Modern, accessible color scheme
593
+ * Amber light palette - Warm, accessible color scheme
526
594
  * Follows WCAG AA contrast guidelines
527
595
  */
528
596
  declare const amberLight: ColorPalette$3;
529
597
  /**
530
- * Amber dark palette - Modern, accessible color scheme
598
+ * Amber dark palette - Warm, accessible color scheme
531
599
  * Follows WCAG AA contrast guidelines
532
600
  */
533
601
  declare const amberDark: ColorPalette$3;
534
602
 
535
603
  type ColorPalette$2 = Theme['colors'];
536
604
  /**
537
- * Cyan light palette - Modern, accessible color scheme
605
+ * Cyan light palette - Fresh, accessible color scheme
538
606
  * Follows WCAG AA contrast guidelines
539
607
  */
540
608
  declare const cyanLight: ColorPalette$2;
541
609
  /**
542
- * Cyan dark palette - Modern, accessible color scheme
610
+ * Cyan dark palette - Fresh, accessible color scheme
543
611
  * Follows WCAG AA contrast guidelines
544
612
  */
545
613
  declare const cyanDark: ColorPalette$2;
546
614
 
547
615
  type ColorPalette$1 = Theme['colors'];
548
616
  /**
549
- * Slate light palette - Modern, accessible color scheme
617
+ * Slate light palette - Professional, accessible color scheme
550
618
  * Follows WCAG AA contrast guidelines
551
619
  */
552
620
  declare const slateLight: ColorPalette$1;
553
621
  /**
554
- * Slate dark palette - Modern, accessible color scheme
622
+ * Slate dark palette - Professional, accessible color scheme
555
623
  * Follows WCAG AA contrast guidelines
556
624
  */
557
625
  declare const slateDark: ColorPalette$1;
558
626
 
559
627
  type ColorPalette = Theme['colors'];
560
628
  /**
561
- * Gray light palette - Modern, accessible color scheme
629
+ * Gray light palette - Clean, accessible color scheme
562
630
  * Follows WCAG AA contrast guidelines
563
631
  */
564
632
  declare const grayLight: ColorPalette;
565
633
  /**
566
- * Gray dark palette - Modern, accessible color scheme
634
+ * Gray dark palette - Clean, accessible color scheme
567
635
  * Follows WCAG AA contrast guidelines
568
636
  */
569
637
  declare const grayDark: ColorPalette;
@@ -788,4 +856,159 @@ declare const insertRule: (rule: string) => void;
788
856
  */
789
857
  declare const sanitizeCssValue: (value: string) => string;
790
858
 
791
- 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, blueDark, blueLight, 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, tealDark, tealLight, transparent, useTheme, violet, violetDark, violetLight, white, yellow };
859
+ /**
860
+ * WCAG Contrast Utilities
861
+ *
862
+ * Utilities for checking color contrast ratios according to WCAG 2.1 guidelines.
863
+ *
864
+ * @example
865
+ * ```ts
866
+ * import { getContrastRatio, meetsWCAG, checkThemeContrast } from '@aurora-ds/theme'
867
+ *
868
+ * // Check contrast between two colors
869
+ * const ratio = getContrastRatio('#ffffff', '#000000') // 21
870
+ *
871
+ * // Check if colors meet WCAG standards
872
+ * meetsWCAG('#ffffff', '#767676', 'AA') // true for large text
873
+ * meetsWCAG('#ffffff', '#767676', 'AAA') // false
874
+ *
875
+ * // Check all theme color pairs
876
+ * const issues = checkThemeContrast(myTheme)
877
+ * ```
878
+ */
879
+ /**
880
+ * WCAG contrast level requirements
881
+ * - AA: 4.5:1 for normal text, 3:1 for large text
882
+ * - AAA: 7:1 for normal text, 4.5:1 for large text
883
+ */
884
+ type WCAGLevel = 'AA' | 'AAA';
885
+ /**
886
+ * Result of a contrast check
887
+ */
888
+ type ContrastResult = {
889
+ /** The two colors being compared */
890
+ colors: [string, string];
891
+ /** The contrast ratio (1-21) */
892
+ ratio: number;
893
+ /** Whether it passes WCAG AA for normal text (4.5:1) */
894
+ passesAA: boolean;
895
+ /** Whether it passes WCAG AA for large text (3:1) */
896
+ passesAALarge: boolean;
897
+ /** Whether it passes WCAG AAA for normal text (7:1) */
898
+ passesAAA: boolean;
899
+ /** Whether it passes WCAG AAA for large text (4.5:1) */
900
+ passesAAALarge: boolean;
901
+ };
902
+ /**
903
+ * Theme contrast check result
904
+ */
905
+ type ThemeContrastIssue = {
906
+ /** Name of the color pair (e.g., "primary/onPrimary") */
907
+ pair: string;
908
+ /** Foreground color name */
909
+ foreground: string;
910
+ /** Background color name */
911
+ background: string;
912
+ /** The contrast ratio */
913
+ ratio: number;
914
+ /** Required minimum ratio */
915
+ required: number;
916
+ /** WCAG level that failed */
917
+ level: 'AA' | 'AALarge';
918
+ };
919
+ /**
920
+ * Calculate the contrast ratio between two colors
921
+ * @see https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio
922
+ *
923
+ * @param foreground - Foreground color (hex)
924
+ * @param background - Background color (hex)
925
+ * @returns Contrast ratio (1-21), or null if colors are invalid
926
+ *
927
+ * @example
928
+ * ```ts
929
+ * getContrastRatio('#ffffff', '#000000') // 21
930
+ * getContrastRatio('#ffffff', '#ffffff') // 1
931
+ * getContrastRatio('#6366f1', '#ffffff') // ~4.5
932
+ * ```
933
+ */
934
+ declare const getContrastRatio: (foreground: string, background: string) => number | null;
935
+ /**
936
+ * Check if two colors meet WCAG contrast requirements
937
+ *
938
+ * @param foreground - Foreground color (hex)
939
+ * @param background - Background color (hex)
940
+ * @param level - WCAG level to check ('AA' or 'AAA')
941
+ * @param largeText - Whether this is for large text (14pt bold or 18pt+)
942
+ * @returns Whether the contrast meets the specified WCAG level
943
+ *
944
+ * @example
945
+ * ```ts
946
+ * meetsWCAG('#ffffff', '#6366f1', 'AA') // true
947
+ * meetsWCAG('#ffffff', '#6366f1', 'AAA') // false
948
+ * meetsWCAG('#ffffff', '#94a3b8', 'AA', true) // true (large text)
949
+ * ```
950
+ */
951
+ declare const meetsWCAG: (foreground: string, background: string, level?: WCAGLevel, largeText?: boolean) => boolean;
952
+ /**
953
+ * Get detailed contrast information between two colors
954
+ *
955
+ * @param foreground - Foreground color (hex)
956
+ * @param background - Background color (hex)
957
+ * @returns Detailed contrast result or null if colors are invalid
958
+ *
959
+ * @example
960
+ * ```ts
961
+ * const result = checkContrast('#ffffff', '#6366f1')
962
+ * // {
963
+ * // colors: ['#ffffff', '#6366f1'],
964
+ * // ratio: 4.54,
965
+ * // passesAA: true,
966
+ * // passesAALarge: true,
967
+ * // passesAAA: false,
968
+ * // passesAAALarge: true
969
+ * // }
970
+ * ```
971
+ */
972
+ declare const checkContrast: (foreground: string, background: string) => ContrastResult | null;
973
+ /**
974
+ * Check all important color pairs in a theme for WCAG compliance
975
+ *
976
+ * @param theme - The theme to check
977
+ * @param level - Minimum WCAG level to require ('AA' or 'AAA')
978
+ * @returns Array of contrast issues found
979
+ *
980
+ * @example
981
+ * ```ts
982
+ * import { checkThemeContrast, defaultTheme } from '@aurora-ds/theme'
983
+ *
984
+ * const issues = checkThemeContrast(defaultTheme)
985
+ * if (issues.length > 0) {
986
+ * console.warn('Theme has contrast issues:', issues)
987
+ * }
988
+ *
989
+ * // Check for AAA compliance
990
+ * const strictIssues = checkThemeContrast(defaultTheme, 'AAA')
991
+ * ```
992
+ */
993
+ declare const checkThemeContrast: (theme: {
994
+ colors: Record<string, string>;
995
+ }, level?: WCAGLevel) => ThemeContrastIssue[];
996
+ /**
997
+ * Get a suggested color that meets WCAG contrast requirements
998
+ * Adjusts the lightness of the foreground color to meet the target ratio
999
+ *
1000
+ * @param foreground - Current foreground color (hex)
1001
+ * @param background - Background color (hex)
1002
+ * @param targetRatio - Desired contrast ratio (default 4.5 for AA)
1003
+ * @returns Adjusted foreground color or null if adjustment isn't possible
1004
+ *
1005
+ * @example
1006
+ * ```ts
1007
+ * // If #94a3b8 on #ffffff doesn't meet AA
1008
+ * const suggested = suggestContrastColor('#94a3b8', '#ffffff', 4.5)
1009
+ * // Returns a darker shade that meets the requirement
1010
+ * ```
1011
+ */
1012
+ declare const suggestContrastColor: (foreground: string, background: string, targetRatio?: number) => string | null;
1013
+
1014
+ export { type BaseBreakpoints, type BaseColors, type BaseFontSize, type BaseFontWeight, type BaseLineHeight, type BaseOpacity, type BaseRadius, type BaseShadows, type BaseSpacing, type BaseTransition, type BaseZIndex, type ColorName, type ColorScale, type ColorShade, type ContrastResult, type DeepPartial, type ExtendTheme, type ExtendedTheme, type FontFaceOptions, type PaletteName, type StyleFunction, type StyleWithPseudos, type Theme, type ThemeContrastIssue, type ThemeOverride, ThemeProvider, type ThemeProviderProps, type WCAGLevel, amber, amberDark, amberLight, black, blue, blueDark, blueLight, checkContrast, checkThemeContrast, clearSSRRules, colors, createStyles, createTheme, createThemeVariant, cssVar, cssVariables, current, cyan, cyanDark, cyanLight, defaultBreakpoints, defaultColors, defaultDarkColors, defaultDarkTheme, defaultFontSize, defaultFontWeight, defaultLineHeight, defaultOpacity, defaultRadius, defaultShadows, defaultSpacing, defaultTheme, defaultTransition, defaultZIndex, emerald, emeraldDark, emeraldLight, fontFace, fuchsia, getContrastRatio, getSSRRulesArray, getSSRStyleTag, getSSRStyles, getTheme, gray, grayDark, grayLight, green, indigo, indigoDark, indigoLight, injectCssVariables, insertRule, keyframes, lime, meetsWCAG, mergeThemes, orange, palettes, pink, purple, red, rose, roseDark, roseLight, sanitizeCssValue, setThemeContextGetter, sky, slate, slateDark, slateLight, stone, suggestContrastColor, teal, tealDark, tealLight, transparent, useTheme, violet, violetDark, violetLight, white, yellow };