@aurora-ds/theme 1.2.8 → 1.4.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
@@ -11,15 +11,24 @@ type BaseColors = {
11
11
  primaryHover: string;
12
12
  primaryActive: string;
13
13
  primarySubtle: string;
14
+ primaryDisabled: string;
14
15
  secondary: string;
15
16
  onSecondary: string;
16
17
  secondaryHover: string;
17
18
  secondaryActive: string;
18
19
  secondarySubtle: string;
20
+ secondaryDisabled: string;
19
21
  accent: string;
20
22
  onAccent: string;
21
23
  accentHover: string;
24
+ accentActive: string;
22
25
  accentSubtle: string;
26
+ tertiary: string;
27
+ onTertiary: string;
28
+ tertiaryHover: string;
29
+ tertiaryActive: string;
30
+ tertiarySubtle: string;
31
+ tertiaryDisabled: string;
23
32
  background: string;
24
33
  surface: string;
25
34
  surfaceHover: string;
@@ -52,6 +61,7 @@ type BaseColors = {
52
61
  infoSubtle: string;
53
62
  link: string;
54
63
  linkHover: string;
64
+ linkActive: string;
55
65
  linkVisited: string;
56
66
  focus: string;
57
67
  disabled: string;
@@ -86,6 +96,7 @@ type BaseRadius = {
86
96
  md: string;
87
97
  lg: string;
88
98
  xl: string;
99
+ '2xl': string;
89
100
  full: string;
90
101
  };
91
102
 
@@ -99,6 +110,9 @@ type BaseShadows = {
99
110
  md: string;
100
111
  lg: string;
101
112
  xl: string;
113
+ '2xl': string;
114
+ inner: string;
115
+ focus: string;
102
116
  };
103
117
 
104
118
  /**
@@ -136,6 +150,7 @@ type BaseLineHeight = {
136
150
  tight: number;
137
151
  normal: number;
138
152
  relaxed: number;
153
+ loose: number;
139
154
  };
140
155
 
141
156
  /**
@@ -145,9 +160,12 @@ type BaseZIndex = {
145
160
  behind: number;
146
161
  base: number;
147
162
  dropdown: number;
163
+ sticky: number;
148
164
  overlay: number;
149
165
  modal: number;
166
+ popover: number;
150
167
  tooltip: number;
168
+ toast: number;
151
169
  };
152
170
 
153
171
  /**
@@ -159,6 +177,26 @@ type BaseTransition = {
159
177
  slow: string;
160
178
  };
161
179
 
180
+ /**
181
+ * Base opacity scale for consistent transparency
182
+ */
183
+ type BaseOpacity = {
184
+ /** Fully transparent - 0 */
185
+ none: number;
186
+ /** Very low opacity - 0.05 */
187
+ lowest: number;
188
+ /** Low opacity - 0.1 */
189
+ low: number;
190
+ /** Medium-low opacity - 0.25 */
191
+ medium: number;
192
+ /** Medium-high opacity - 0.5 */
193
+ high: number;
194
+ /** High opacity - 0.75 */
195
+ higher: number;
196
+ /** Fully opaque - 1 */
197
+ full: number;
198
+ };
199
+
162
200
  /**
163
201
  * Standard theme type with all required tokens
164
202
  */
@@ -172,6 +210,7 @@ type Theme = {
172
210
  lineHeight: BaseLineHeight;
173
211
  zIndex: BaseZIndex;
174
212
  transition: BaseTransition;
213
+ opacity: BaseOpacity;
175
214
  };
176
215
 
177
216
  /**
@@ -357,6 +396,10 @@ declare const defaultZIndex: Theme['zIndex'];
357
396
  * Default transition scale
358
397
  */
359
398
  declare const defaultTransition: Theme['transition'];
399
+ /**
400
+ * Default opacity scale
401
+ */
402
+ declare const defaultOpacity: Theme['opacity'];
360
403
  /**
361
404
  * Default colors (using indigo palette)
362
405
  */
@@ -448,98 +491,122 @@ declare const colors: {
448
491
  readonly current: "currentColor";
449
492
  };
450
493
 
451
- type ColorPalette$7 = Theme['colors'];
494
+ type ColorPalette$9 = Theme['colors'];
452
495
  /**
453
496
  * Indigo light palette - Modern, accessible color scheme
454
497
  * Follows WCAG AA contrast guidelines
455
498
  */
456
- declare const indigoLight: ColorPalette$7;
499
+ declare const indigoLight: ColorPalette$9;
457
500
  /**
458
501
  * Indigo dark palette - Modern, accessible color scheme
459
502
  * Follows WCAG AA contrast guidelines
460
503
  */
461
- declare const indigoDark: ColorPalette$7;
504
+ declare const indigoDark: ColorPalette$9;
505
+
506
+ type ColorPalette$8 = Theme['colors'];
507
+ /**
508
+ * Blue light palette - Classic, accessible color scheme
509
+ * Follows WCAG AA contrast guidelines
510
+ */
511
+ declare const blueLight: ColorPalette$8;
512
+ /**
513
+ * Blue dark palette - Classic, accessible color scheme
514
+ * Follows WCAG AA contrast guidelines
515
+ */
516
+ declare const blueDark: ColorPalette$8;
517
+
518
+ type ColorPalette$7 = Theme['colors'];
519
+ /**
520
+ * Rose light palette - Elegant, accessible color scheme
521
+ * Follows WCAG AA contrast guidelines
522
+ */
523
+ declare const roseLight: ColorPalette$7;
524
+ /**
525
+ * Rose dark palette - Elegant, accessible color scheme
526
+ * Follows WCAG AA contrast guidelines
527
+ */
528
+ declare const roseDark: ColorPalette$7;
462
529
 
463
530
  type ColorPalette$6 = Theme['colors'];
464
531
  /**
465
- * Rose light palette - Modern, accessible color scheme
532
+ * Emerald light palette - Fresh, accessible color scheme
466
533
  * Follows WCAG AA contrast guidelines
467
534
  */
468
- declare const roseLight: ColorPalette$6;
535
+ declare const emeraldLight: ColorPalette$6;
469
536
  /**
470
- * Rose dark palette - Modern, accessible color scheme
537
+ * Emerald dark palette - Fresh, accessible color scheme
471
538
  * Follows WCAG AA contrast guidelines
472
539
  */
473
- declare const roseDark: ColorPalette$6;
540
+ declare const emeraldDark: ColorPalette$6;
474
541
 
475
542
  type ColorPalette$5 = Theme['colors'];
476
543
  /**
477
- * Emerald light palette - Modern, accessible color scheme
544
+ * Teal light palette - Cool, accessible color scheme
478
545
  * Follows WCAG AA contrast guidelines
479
546
  */
480
- declare const emeraldLight: ColorPalette$5;
547
+ declare const tealLight: ColorPalette$5;
481
548
  /**
482
- * Emerald dark palette - Modern, accessible color scheme
549
+ * Teal dark palette - Cool, accessible color scheme
483
550
  * Follows WCAG AA contrast guidelines
484
551
  */
485
- declare const emeraldDark: ColorPalette$5;
552
+ declare const tealDark: ColorPalette$5;
486
553
 
487
554
  type ColorPalette$4 = Theme['colors'];
488
555
  /**
489
- * Violet light palette - Modern, accessible color scheme
556
+ * Violet light palette - Creative, accessible color scheme
490
557
  * Follows WCAG AA contrast guidelines
491
558
  */
492
559
  declare const violetLight: ColorPalette$4;
493
560
  /**
494
- * Violet dark palette - Modern, accessible color scheme
561
+ * Violet dark palette - Creative, accessible color scheme
495
562
  * Follows WCAG AA contrast guidelines
496
563
  */
497
564
  declare const violetDark: ColorPalette$4;
498
565
 
499
566
  type ColorPalette$3 = Theme['colors'];
500
567
  /**
501
- * Amber light palette - Modern, accessible color scheme
568
+ * Amber light palette - Warm, accessible color scheme
502
569
  * Follows WCAG AA contrast guidelines
503
570
  */
504
571
  declare const amberLight: ColorPalette$3;
505
572
  /**
506
- * Amber dark palette - Modern, accessible color scheme
573
+ * Amber dark palette - Warm, accessible color scheme
507
574
  * Follows WCAG AA contrast guidelines
508
575
  */
509
576
  declare const amberDark: ColorPalette$3;
510
577
 
511
578
  type ColorPalette$2 = Theme['colors'];
512
579
  /**
513
- * Cyan light palette - Modern, accessible color scheme
580
+ * Cyan light palette - Fresh, accessible color scheme
514
581
  * Follows WCAG AA contrast guidelines
515
582
  */
516
583
  declare const cyanLight: ColorPalette$2;
517
584
  /**
518
- * Cyan dark palette - Modern, accessible color scheme
585
+ * Cyan dark palette - Fresh, accessible color scheme
519
586
  * Follows WCAG AA contrast guidelines
520
587
  */
521
588
  declare const cyanDark: ColorPalette$2;
522
589
 
523
590
  type ColorPalette$1 = Theme['colors'];
524
591
  /**
525
- * Slate light palette - Modern, accessible color scheme
592
+ * Slate light palette - Professional, accessible color scheme
526
593
  * Follows WCAG AA contrast guidelines
527
594
  */
528
595
  declare const slateLight: ColorPalette$1;
529
596
  /**
530
- * Slate dark palette - Modern, accessible color scheme
597
+ * Slate dark palette - Professional, accessible color scheme
531
598
  * Follows WCAG AA contrast guidelines
532
599
  */
533
600
  declare const slateDark: ColorPalette$1;
534
601
 
535
602
  type ColorPalette = Theme['colors'];
536
603
  /**
537
- * Gray light palette - Modern, accessible color scheme
604
+ * Gray light palette - Clean, accessible color scheme
538
605
  * Follows WCAG AA contrast guidelines
539
606
  */
540
607
  declare const grayLight: ColorPalette;
541
608
  /**
542
- * Gray dark palette - Modern, accessible color scheme
609
+ * Gray dark palette - Clean, accessible color scheme
543
610
  * Follows WCAG AA contrast guidelines
544
611
  */
545
612
  declare const grayDark: ColorPalette;
@@ -764,4 +831,159 @@ declare const insertRule: (rule: string) => void;
764
831
  */
765
832
  declare const sanitizeCssValue: (value: string) => string;
766
833
 
767
- 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 };
834
+ /**
835
+ * WCAG Contrast Utilities
836
+ *
837
+ * Utilities for checking color contrast ratios according to WCAG 2.1 guidelines.
838
+ *
839
+ * @example
840
+ * ```ts
841
+ * import { getContrastRatio, meetsWCAG, checkThemeContrast } from '@aurora-ds/theme'
842
+ *
843
+ * // Check contrast between two colors
844
+ * const ratio = getContrastRatio('#ffffff', '#000000') // 21
845
+ *
846
+ * // Check if colors meet WCAG standards
847
+ * meetsWCAG('#ffffff', '#767676', 'AA') // true for large text
848
+ * meetsWCAG('#ffffff', '#767676', 'AAA') // false
849
+ *
850
+ * // Check all theme color pairs
851
+ * const issues = checkThemeContrast(myTheme)
852
+ * ```
853
+ */
854
+ /**
855
+ * WCAG contrast level requirements
856
+ * - AA: 4.5:1 for normal text, 3:1 for large text
857
+ * - AAA: 7:1 for normal text, 4.5:1 for large text
858
+ */
859
+ type WCAGLevel = 'AA' | 'AAA';
860
+ /**
861
+ * Result of a contrast check
862
+ */
863
+ type ContrastResult = {
864
+ /** The two colors being compared */
865
+ colors: [string, string];
866
+ /** The contrast ratio (1-21) */
867
+ ratio: number;
868
+ /** Whether it passes WCAG AA for normal text (4.5:1) */
869
+ passesAA: boolean;
870
+ /** Whether it passes WCAG AA for large text (3:1) */
871
+ passesAALarge: boolean;
872
+ /** Whether it passes WCAG AAA for normal text (7:1) */
873
+ passesAAA: boolean;
874
+ /** Whether it passes WCAG AAA for large text (4.5:1) */
875
+ passesAAALarge: boolean;
876
+ };
877
+ /**
878
+ * Theme contrast check result
879
+ */
880
+ type ThemeContrastIssue = {
881
+ /** Name of the color pair (e.g., "primary/onPrimary") */
882
+ pair: string;
883
+ /** Foreground color name */
884
+ foreground: string;
885
+ /** Background color name */
886
+ background: string;
887
+ /** The contrast ratio */
888
+ ratio: number;
889
+ /** Required minimum ratio */
890
+ required: number;
891
+ /** WCAG level that failed */
892
+ level: 'AA' | 'AALarge';
893
+ };
894
+ /**
895
+ * Calculate the contrast ratio between two colors
896
+ * @see https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio
897
+ *
898
+ * @param foreground - Foreground color (hex)
899
+ * @param background - Background color (hex)
900
+ * @returns Contrast ratio (1-21), or null if colors are invalid
901
+ *
902
+ * @example
903
+ * ```ts
904
+ * getContrastRatio('#ffffff', '#000000') // 21
905
+ * getContrastRatio('#ffffff', '#ffffff') // 1
906
+ * getContrastRatio('#6366f1', '#ffffff') // ~4.5
907
+ * ```
908
+ */
909
+ declare const getContrastRatio: (foreground: string, background: string) => number | null;
910
+ /**
911
+ * Check if two colors meet WCAG contrast requirements
912
+ *
913
+ * @param foreground - Foreground color (hex)
914
+ * @param background - Background color (hex)
915
+ * @param level - WCAG level to check ('AA' or 'AAA')
916
+ * @param largeText - Whether this is for large text (14pt bold or 18pt+)
917
+ * @returns Whether the contrast meets the specified WCAG level
918
+ *
919
+ * @example
920
+ * ```ts
921
+ * meetsWCAG('#ffffff', '#6366f1', 'AA') // true
922
+ * meetsWCAG('#ffffff', '#6366f1', 'AAA') // false
923
+ * meetsWCAG('#ffffff', '#94a3b8', 'AA', true) // true (large text)
924
+ * ```
925
+ */
926
+ declare const meetsWCAG: (foreground: string, background: string, level?: WCAGLevel, largeText?: boolean) => boolean;
927
+ /**
928
+ * Get detailed contrast information between two colors
929
+ *
930
+ * @param foreground - Foreground color (hex)
931
+ * @param background - Background color (hex)
932
+ * @returns Detailed contrast result or null if colors are invalid
933
+ *
934
+ * @example
935
+ * ```ts
936
+ * const result = checkContrast('#ffffff', '#6366f1')
937
+ * // {
938
+ * // colors: ['#ffffff', '#6366f1'],
939
+ * // ratio: 4.54,
940
+ * // passesAA: true,
941
+ * // passesAALarge: true,
942
+ * // passesAAA: false,
943
+ * // passesAAALarge: true
944
+ * // }
945
+ * ```
946
+ */
947
+ declare const checkContrast: (foreground: string, background: string) => ContrastResult | null;
948
+ /**
949
+ * Check all important color pairs in a theme for WCAG compliance
950
+ *
951
+ * @param theme - The theme to check
952
+ * @param level - Minimum WCAG level to require ('AA' or 'AAA')
953
+ * @returns Array of contrast issues found
954
+ *
955
+ * @example
956
+ * ```ts
957
+ * import { checkThemeContrast, defaultTheme } from '@aurora-ds/theme'
958
+ *
959
+ * const issues = checkThemeContrast(defaultTheme)
960
+ * if (issues.length > 0) {
961
+ * console.warn('Theme has contrast issues:', issues)
962
+ * }
963
+ *
964
+ * // Check for AAA compliance
965
+ * const strictIssues = checkThemeContrast(defaultTheme, 'AAA')
966
+ * ```
967
+ */
968
+ declare const checkThemeContrast: (theme: {
969
+ colors: Record<string, string>;
970
+ }, level?: WCAGLevel) => ThemeContrastIssue[];
971
+ /**
972
+ * Get a suggested color that meets WCAG contrast requirements
973
+ * Adjusts the lightness of the foreground color to meet the target ratio
974
+ *
975
+ * @param foreground - Current foreground color (hex)
976
+ * @param background - Background color (hex)
977
+ * @param targetRatio - Desired contrast ratio (default 4.5 for AA)
978
+ * @returns Adjusted foreground color or null if adjustment isn't possible
979
+ *
980
+ * @example
981
+ * ```ts
982
+ * // If #94a3b8 on #ffffff doesn't meet AA
983
+ * const suggested = suggestContrastColor('#94a3b8', '#ffffff', 4.5)
984
+ * // Returns a darker shade that meets the requirement
985
+ * ```
986
+ */
987
+ declare const suggestContrastColor: (foreground: string, background: string, targetRatio?: number) => string | null;
988
+
989
+ export { 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, 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 };