@northlight/ui 2.36.10 → 2.36.11
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/es/northlight.d.ts +1 -1
- package/dist/es/northlight.js +42 -22
- package/dist/es/northlight.js.map +1 -1
- package/dist/umd/northlight.cjs +42 -22
- package/dist/umd/northlight.cjs.map +1 -1
- package/dist/umd/northlight.min.cjs +3 -3
- package/dist/umd/northlight.min.cjs.map +1 -1
- package/package.json +2 -2
package/dist/es/northlight.d.ts
CHANGED
|
@@ -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
|
|
package/dist/es/northlight.js
CHANGED
|
@@ -364,12 +364,16 @@ const useDidUpdateEffect = (effect, dependencies) => {
|
|
|
364
364
|
};
|
|
365
365
|
|
|
366
366
|
const luminosity = (hexcolor) => {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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((
|
|
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
|
|
383
|
-
const
|
|
384
|
-
const
|
|
385
|
-
const
|
|
386
|
-
const
|
|
387
|
-
const
|
|
388
|
-
const
|
|
389
|
-
const
|
|
390
|
-
|
|
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.
|
|
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.
|
|
810
|
+
color: color.text.button.brandSubdued
|
|
795
811
|
}
|
|
796
812
|
},
|
|
797
813
|
_active: {
|
|
@@ -1646,7 +1662,8 @@ const Tag$1 = {
|
|
|
1646
1662
|
variants: {
|
|
1647
1663
|
solid: ({ theme: { colors }, bgColor, colorScheme, currentTheme }) => {
|
|
1648
1664
|
const processedColorScheme = processColorSchemeBasedOnTheme({ currentTheme, colorScheme });
|
|
1649
|
-
const
|
|
1665
|
+
const tagBgColorRaw = bgColor != null ? bgColor : colors[processedColorScheme] && colors[processedColorScheme][500] ? colors[processedColorScheme][500] : processedColorScheme;
|
|
1666
|
+
const tagBgColor = typeof tagBgColorRaw === "string" ? tagBgColorRaw.trim() : tagBgColorRaw;
|
|
1650
1667
|
const tagColor = getContrastColor(useToken$1("colors", tagBgColor));
|
|
1651
1668
|
return {
|
|
1652
1669
|
container: {
|
|
@@ -1657,7 +1674,8 @@ const Tag$1 = {
|
|
|
1657
1674
|
},
|
|
1658
1675
|
subtle: ({ theme: { colors }, colorScheme, bgColor, currentTheme }) => {
|
|
1659
1676
|
const processedColorScheme = processColorSchemeBasedOnTheme({ currentTheme, colorScheme });
|
|
1660
|
-
const
|
|
1677
|
+
const tagBgColorRaw = bgColor != null ? bgColor : colors[processedColorScheme] && colors[processedColorScheme][100] ? colors[processedColorScheme][100] : processedColorScheme;
|
|
1678
|
+
const tagBgColor = typeof tagBgColorRaw === "string" ? tagBgColorRaw.trim() : tagBgColorRaw;
|
|
1661
1679
|
const tagColor = getContrastColor(useToken$1("colors", tagBgColor));
|
|
1662
1680
|
return {
|
|
1663
1681
|
container: {
|
|
@@ -3576,12 +3594,13 @@ const Badge$1 = {
|
|
|
3576
3594
|
};
|
|
3577
3595
|
},
|
|
3578
3596
|
variants: {
|
|
3579
|
-
solid: ({ colorScheme, theme: { colors }, currentTheme }) => {
|
|
3597
|
+
solid: ({ colorScheme, theme: { colors }, currentTheme, bg, bgColor }) => {
|
|
3598
|
+
var _a;
|
|
3580
3599
|
const processedColorScheme = processColorSchemeBasedOnTheme({ currentTheme, colorScheme });
|
|
3581
|
-
const
|
|
3600
|
+
const finalBg = (_a = bg != null ? bg : bgColor) != null ? _a : processedColorScheme === "mediatoolBlue" ? colors[processedColorScheme][500] : colors[processedColorScheme] && colors[processedColorScheme][500];
|
|
3582
3601
|
return {
|
|
3583
|
-
bgColor,
|
|
3584
|
-
color: getContrastColor(
|
|
3602
|
+
bgColor: finalBg,
|
|
3603
|
+
color: getContrastColor(finalBg != null ? finalBg : useToken$1("colors", processedColorScheme))
|
|
3585
3604
|
};
|
|
3586
3605
|
},
|
|
3587
3606
|
outline: ({ colorScheme, theme: { colors }, currentTheme }) => {
|
|
@@ -3616,7 +3635,8 @@ const Badge$1 = {
|
|
|
3616
3635
|
}
|
|
3617
3636
|
},
|
|
3618
3637
|
defaultProps: {
|
|
3619
|
-
size: "sm"
|
|
3638
|
+
size: "sm",
|
|
3639
|
+
variant: "solid"
|
|
3620
3640
|
}
|
|
3621
3641
|
};
|
|
3622
3642
|
|