@northlight/ui 2.36.10 → 2.36.12

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.
@@ -542,7 +542,7 @@ interface BlinkerProps {
542
542
  */
543
543
  declare const Blinker: ({ color, size, isBlinking, ...rest }: BlinkerProps) => JSX.Element;
544
544
 
545
- type ButtonVariants = 'default' | 'danger' | 'success' | 'brand' | 'brandSubdued' | 'link' | 'ghost' | 'ai' | 'outline' | 'solid';
545
+ type ButtonVariants = 'default' | 'danger' | 'success' | 'brand' | 'brandSubdued' | 'link' | 'ghost' | 'ai' | 'outline' | 'solid' | 'accent' | 'sidebar';
546
546
  type ButtonProps = Omit<ButtonProps$1, 'as' | 'size'> & {
547
547
  variant?: ButtonVariants;
548
548
  size?: 'xs' | 'sm' | 'md' | 'lg';
@@ -590,7 +590,7 @@ type ButtonProps = Omit<ButtonProps$1, 'as' | 'size'> & {
590
590
  * @example (Example)
591
591
  * (?
592
592
  * +
593
- * const variants = ['link', 'success', 'default', 'danger', 'brand',
593
+ * const variants = ['link', 'success', 'default', 'danger', 'brand', 'accent',
594
594
  * 'ghost', 'ai', 'outline', 'brandSubdued', 'solid']
595
595
  *
596
596
  * const ExampleButton = () => {
@@ -2589,7 +2589,7 @@ declare const useOverflowGroup: () => {
2589
2589
  containerRef: (node: any) => void;
2590
2590
  };
2591
2591
 
2592
- declare const getContrastColor: (color: string) => "text.default" | "text.inverted";
2592
+ declare const getContrastColor: (color: string) => "text.default" | "text.inverted" | undefined;
2593
2593
 
2594
2594
  declare const luminosity: (hexcolor: string) => number;
2595
2595
 
@@ -364,12 +364,16 @@ const useDidUpdateEffect = (effect, dependencies) => {
364
364
  };
365
365
 
366
366
  const luminosity = (hexcolor) => {
367
- let color = hexcolor;
368
- if (color.slice(0, 1) === "#") {
369
- color = color.slice(1);
367
+ if (!hexcolor || typeof hexcolor !== "string")
368
+ return Number.NaN;
369
+ let color = hexcolor.trim();
370
+ if (!/^#?[0-9a-f]{3}([0-9a-f]{3})?$/i.test(color)) {
371
+ return Number.NaN;
370
372
  }
373
+ if (color[0] === "#")
374
+ color = color.slice(1);
371
375
  if (color.length === 3) {
372
- color = color.split("").map((hex) => hex + hex).join("");
376
+ color = color.split("").map((h) => h + h).join("");
373
377
  }
374
378
  const r = parseInt(color.substring(0, 2), 16);
375
379
  const g = parseInt(color.substring(2, 4), 16);
@@ -378,16 +382,28 @@ const luminosity = (hexcolor) => {
378
382
  return brightness;
379
383
  };
380
384
 
385
+ function safeUseToken(tokenOrValue) {
386
+ try {
387
+ return useToken("colors", tokenOrValue);
388
+ } catch (e) {
389
+ return tokenOrValue;
390
+ }
391
+ }
381
392
  const getContrastColor = (color) => {
382
- const colorTwo = useToken("colors", "text.default");
383
- const colorOne = useToken("colors", "text.inverted");
384
- const colorInHex = useToken("colors", color);
385
- const l1 = luminosity(colorOne);
386
- const l2 = luminosity(colorTwo);
387
- const threshold = (l1 + l2) / 2;
388
- const brightColor = l1 > l2 ? colorOne : colorTwo;
389
- const darkColor = l1 > l2 ? colorTwo : colorOne;
390
- return luminosity(colorInHex) >= threshold ? darkColor : brightColor;
393
+ const textDefault = useToken("colors", "text.default");
394
+ const textInverted = useToken("colors", "text.inverted");
395
+ const normalized = typeof color === "string" ? color.trim() : color;
396
+ const isHex = /^#?[0-9a-f]{3}([0-9a-f]{3})?$/i.test(normalized);
397
+ const bgResolved = isHex ? normalized[0] === "#" ? normalized : `#${normalized}` : safeUseToken(normalized);
398
+ const lInverted = luminosity(textInverted);
399
+ const lDefault = luminosity(textDefault);
400
+ const threshold = (lInverted + lDefault) / 2;
401
+ const brightColor = lInverted > lDefault ? textInverted : textDefault;
402
+ const darkColor = lInverted > lDefault ? textDefault : textInverted;
403
+ const lBg = luminosity(bgResolved);
404
+ if (Number.isNaN(lBg))
405
+ return void 0;
406
+ return lBg >= threshold ? darkColor : brightColor;
391
407
  };
392
408
 
393
409
  const ring = {
@@ -784,14 +800,14 @@ const Button$1 = {
784
800
  }
785
801
  }),
786
802
  brandSubdued: ({ theme: { colors: color } }) => ({
787
- color: color.text.button.link,
803
+ color: color.text.button.brandSubdued,
788
804
  bgColor: color.background.button.ghost,
789
805
  _hover: {
790
806
  bg: color.background.button.brand,
791
807
  color: color.text.inverted,
792
808
  _disabled: {
793
809
  bgColor: color.background.button.ghost,
794
- color: color.text.button.link
810
+ color: color.text.button.brandSubdued
795
811
  }
796
812
  },
797
813
  _active: {
@@ -862,6 +878,38 @@ const Button$1 = {
862
878
  bg: color.bg.ai.hover,
863
879
  color: color.text.inverted
864
880
  }
881
+ }),
882
+ accent: ({ theme: { colors: color } }) => ({
883
+ color: color.text.button.accent,
884
+ bgColor: color.background.button.ghost,
885
+ _hover: {
886
+ bg: color.background.button["ghost-active"],
887
+ color: color.text.button.accent,
888
+ _disabled: {
889
+ bgColor: color.background.button.ghost,
890
+ color: color.text.button.accent
891
+ }
892
+ },
893
+ _active: {
894
+ bg: color.background.button["ghost-active"],
895
+ color: color.text.button.accent
896
+ }
897
+ }),
898
+ sidebar: ({ theme: { colors: color } }) => ({
899
+ color: color.text.button.sidebar,
900
+ bgColor: color.background.button.sidebar,
901
+ _hover: {
902
+ bg: color.background.button["sidebar-hover"],
903
+ color: color.text.button.sidebar,
904
+ _disabled: {
905
+ bgColor: color.background.button.ghost,
906
+ color: color.text.button.sidebar
907
+ }
908
+ },
909
+ _active: {
910
+ bg: color.background.button["sidebar-active"],
911
+ color: color.text.button["sidebar-active"]
912
+ }
865
913
  })
866
914
  },
867
915
  defaultProps: {
@@ -1646,7 +1694,8 @@ const Tag$1 = {
1646
1694
  variants: {
1647
1695
  solid: ({ theme: { colors }, bgColor, colorScheme, currentTheme }) => {
1648
1696
  const processedColorScheme = processColorSchemeBasedOnTheme({ currentTheme, colorScheme });
1649
- const tagBgColor = bgColor != null ? bgColor : colors[processedColorScheme] && colors[processedColorScheme][500] ? colors[processedColorScheme][500] : processedColorScheme;
1697
+ const tagBgColorRaw = bgColor != null ? bgColor : colors[processedColorScheme] && colors[processedColorScheme][500] ? colors[processedColorScheme][500] : processedColorScheme;
1698
+ const tagBgColor = typeof tagBgColorRaw === "string" ? tagBgColorRaw.trim() : tagBgColorRaw;
1650
1699
  const tagColor = getContrastColor(useToken$1("colors", tagBgColor));
1651
1700
  return {
1652
1701
  container: {
@@ -1657,7 +1706,8 @@ const Tag$1 = {
1657
1706
  },
1658
1707
  subtle: ({ theme: { colors }, colorScheme, bgColor, currentTheme }) => {
1659
1708
  const processedColorScheme = processColorSchemeBasedOnTheme({ currentTheme, colorScheme });
1660
- const tagBgColor = bgColor != null ? bgColor : colors[processedColorScheme] && colors[processedColorScheme][100] ? colors[processedColorScheme][100] : processedColorScheme;
1709
+ const tagBgColorRaw = bgColor != null ? bgColor : colors[processedColorScheme] && colors[processedColorScheme][100] ? colors[processedColorScheme][100] : processedColorScheme;
1710
+ const tagBgColor = typeof tagBgColorRaw === "string" ? tagBgColorRaw.trim() : tagBgColorRaw;
1661
1711
  const tagColor = getContrastColor(useToken$1("colors", tagBgColor));
1662
1712
  return {
1663
1713
  container: {
@@ -3576,12 +3626,13 @@ const Badge$1 = {
3576
3626
  };
3577
3627
  },
3578
3628
  variants: {
3579
- solid: ({ colorScheme, theme: { colors }, currentTheme }) => {
3629
+ solid: ({ colorScheme, theme: { colors }, currentTheme, bg, bgColor }) => {
3630
+ var _a;
3580
3631
  const processedColorScheme = processColorSchemeBasedOnTheme({ currentTheme, colorScheme });
3581
- const bgColor = processedColorScheme === "mediatoolBlue" ? colors[processedColorScheme][500] : colors[processedColorScheme] && colors[processedColorScheme][500];
3632
+ const finalBg = (_a = bg != null ? bg : bgColor) != null ? _a : processedColorScheme === "mediatoolBlue" ? colors[processedColorScheme][500] : colors[processedColorScheme] && colors[processedColorScheme][500];
3582
3633
  return {
3583
- bgColor,
3584
- color: getContrastColor(bgColor != null ? bgColor : useToken$1("colors", processedColorScheme))
3634
+ bgColor: finalBg,
3635
+ color: getContrastColor(finalBg != null ? finalBg : useToken$1("colors", processedColorScheme))
3585
3636
  };
3586
3637
  },
3587
3638
  outline: ({ colorScheme, theme: { colors }, currentTheme }) => {
@@ -3616,7 +3667,8 @@ const Badge$1 = {
3616
3667
  }
3617
3668
  },
3618
3669
  defaultProps: {
3619
- size: "sm"
3670
+ size: "sm",
3671
+ variant: "solid"
3620
3672
  }
3621
3673
  };
3622
3674