@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.
- package/dist/es/northlight.d.ts +3 -3
- package/dist/es/northlight.js +74 -22
- package/dist/es/northlight.js.map +1 -1
- package/dist/umd/northlight.cjs +74 -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 +3 -3
package/dist/umd/northlight.cjs
CHANGED
|
@@ -342,12 +342,16 @@
|
|
|
342
342
|
};
|
|
343
343
|
|
|
344
344
|
const luminosity = (hexcolor) => {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
345
|
+
if (!hexcolor || typeof hexcolor !== "string")
|
|
346
|
+
return Number.NaN;
|
|
347
|
+
let color = hexcolor.trim();
|
|
348
|
+
if (!/^#?[0-9a-f]{3}([0-9a-f]{3})?$/i.test(color)) {
|
|
349
|
+
return Number.NaN;
|
|
348
350
|
}
|
|
351
|
+
if (color[0] === "#")
|
|
352
|
+
color = color.slice(1);
|
|
349
353
|
if (color.length === 3) {
|
|
350
|
-
color = color.split("").map((
|
|
354
|
+
color = color.split("").map((h) => h + h).join("");
|
|
351
355
|
}
|
|
352
356
|
const r = parseInt(color.substring(0, 2), 16);
|
|
353
357
|
const g = parseInt(color.substring(2, 4), 16);
|
|
@@ -356,16 +360,28 @@
|
|
|
356
360
|
return brightness;
|
|
357
361
|
};
|
|
358
362
|
|
|
363
|
+
function safeUseToken(tokenOrValue) {
|
|
364
|
+
try {
|
|
365
|
+
return system.useToken("colors", tokenOrValue);
|
|
366
|
+
} catch (e) {
|
|
367
|
+
return tokenOrValue;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
359
370
|
const getContrastColor = (color) => {
|
|
360
|
-
const
|
|
361
|
-
const
|
|
362
|
-
const
|
|
363
|
-
const
|
|
364
|
-
const
|
|
365
|
-
const
|
|
366
|
-
const
|
|
367
|
-
const
|
|
368
|
-
|
|
371
|
+
const textDefault = system.useToken("colors", "text.default");
|
|
372
|
+
const textInverted = system.useToken("colors", "text.inverted");
|
|
373
|
+
const normalized = typeof color === "string" ? color.trim() : color;
|
|
374
|
+
const isHex = /^#?[0-9a-f]{3}([0-9a-f]{3})?$/i.test(normalized);
|
|
375
|
+
const bgResolved = isHex ? normalized[0] === "#" ? normalized : `#${normalized}` : safeUseToken(normalized);
|
|
376
|
+
const lInverted = luminosity(textInverted);
|
|
377
|
+
const lDefault = luminosity(textDefault);
|
|
378
|
+
const threshold = (lInverted + lDefault) / 2;
|
|
379
|
+
const brightColor = lInverted > lDefault ? textInverted : textDefault;
|
|
380
|
+
const darkColor = lInverted > lDefault ? textDefault : textInverted;
|
|
381
|
+
const lBg = luminosity(bgResolved);
|
|
382
|
+
if (Number.isNaN(lBg))
|
|
383
|
+
return void 0;
|
|
384
|
+
return lBg >= threshold ? darkColor : brightColor;
|
|
369
385
|
};
|
|
370
386
|
|
|
371
387
|
const ring = {
|
|
@@ -762,14 +778,14 @@
|
|
|
762
778
|
}
|
|
763
779
|
}),
|
|
764
780
|
brandSubdued: ({ theme: { colors: color } }) => ({
|
|
765
|
-
color: color.text.button.
|
|
781
|
+
color: color.text.button.brandSubdued,
|
|
766
782
|
bgColor: color.background.button.ghost,
|
|
767
783
|
_hover: {
|
|
768
784
|
bg: color.background.button.brand,
|
|
769
785
|
color: color.text.inverted,
|
|
770
786
|
_disabled: {
|
|
771
787
|
bgColor: color.background.button.ghost,
|
|
772
|
-
color: color.text.button.
|
|
788
|
+
color: color.text.button.brandSubdued
|
|
773
789
|
}
|
|
774
790
|
},
|
|
775
791
|
_active: {
|
|
@@ -840,6 +856,38 @@
|
|
|
840
856
|
bg: color.bg.ai.hover,
|
|
841
857
|
color: color.text.inverted
|
|
842
858
|
}
|
|
859
|
+
}),
|
|
860
|
+
accent: ({ theme: { colors: color } }) => ({
|
|
861
|
+
color: color.text.button.accent,
|
|
862
|
+
bgColor: color.background.button.ghost,
|
|
863
|
+
_hover: {
|
|
864
|
+
bg: color.background.button["ghost-active"],
|
|
865
|
+
color: color.text.button.accent,
|
|
866
|
+
_disabled: {
|
|
867
|
+
bgColor: color.background.button.ghost,
|
|
868
|
+
color: color.text.button.accent
|
|
869
|
+
}
|
|
870
|
+
},
|
|
871
|
+
_active: {
|
|
872
|
+
bg: color.background.button["ghost-active"],
|
|
873
|
+
color: color.text.button.accent
|
|
874
|
+
}
|
|
875
|
+
}),
|
|
876
|
+
sidebar: ({ theme: { colors: color } }) => ({
|
|
877
|
+
color: color.text.button.sidebar,
|
|
878
|
+
bgColor: color.background.button.sidebar,
|
|
879
|
+
_hover: {
|
|
880
|
+
bg: color.background.button["sidebar-hover"],
|
|
881
|
+
color: color.text.button.sidebar,
|
|
882
|
+
_disabled: {
|
|
883
|
+
bgColor: color.background.button.ghost,
|
|
884
|
+
color: color.text.button.sidebar
|
|
885
|
+
}
|
|
886
|
+
},
|
|
887
|
+
_active: {
|
|
888
|
+
bg: color.background.button["sidebar-active"],
|
|
889
|
+
color: color.text.button["sidebar-active"]
|
|
890
|
+
}
|
|
843
891
|
})
|
|
844
892
|
},
|
|
845
893
|
defaultProps: {
|
|
@@ -1624,7 +1672,8 @@
|
|
|
1624
1672
|
variants: {
|
|
1625
1673
|
solid: ({ theme: { colors }, bgColor, colorScheme, currentTheme }) => {
|
|
1626
1674
|
const processedColorScheme = processColorSchemeBasedOnTheme({ currentTheme, colorScheme });
|
|
1627
|
-
const
|
|
1675
|
+
const tagBgColorRaw = bgColor != null ? bgColor : colors[processedColorScheme] && colors[processedColorScheme][500] ? colors[processedColorScheme][500] : processedColorScheme;
|
|
1676
|
+
const tagBgColor = typeof tagBgColorRaw === "string" ? tagBgColorRaw.trim() : tagBgColorRaw;
|
|
1628
1677
|
const tagColor = getContrastColor(react.useToken("colors", tagBgColor));
|
|
1629
1678
|
return {
|
|
1630
1679
|
container: {
|
|
@@ -1635,7 +1684,8 @@
|
|
|
1635
1684
|
},
|
|
1636
1685
|
subtle: ({ theme: { colors }, colorScheme, bgColor, currentTheme }) => {
|
|
1637
1686
|
const processedColorScheme = processColorSchemeBasedOnTheme({ currentTheme, colorScheme });
|
|
1638
|
-
const
|
|
1687
|
+
const tagBgColorRaw = bgColor != null ? bgColor : colors[processedColorScheme] && colors[processedColorScheme][100] ? colors[processedColorScheme][100] : processedColorScheme;
|
|
1688
|
+
const tagBgColor = typeof tagBgColorRaw === "string" ? tagBgColorRaw.trim() : tagBgColorRaw;
|
|
1639
1689
|
const tagColor = getContrastColor(react.useToken("colors", tagBgColor));
|
|
1640
1690
|
return {
|
|
1641
1691
|
container: {
|
|
@@ -3554,12 +3604,13 @@
|
|
|
3554
3604
|
};
|
|
3555
3605
|
},
|
|
3556
3606
|
variants: {
|
|
3557
|
-
solid: ({ colorScheme, theme: { colors }, currentTheme }) => {
|
|
3607
|
+
solid: ({ colorScheme, theme: { colors }, currentTheme, bg, bgColor }) => {
|
|
3608
|
+
var _a;
|
|
3558
3609
|
const processedColorScheme = processColorSchemeBasedOnTheme({ currentTheme, colorScheme });
|
|
3559
|
-
const
|
|
3610
|
+
const finalBg = (_a = bg != null ? bg : bgColor) != null ? _a : processedColorScheme === "mediatoolBlue" ? colors[processedColorScheme][500] : colors[processedColorScheme] && colors[processedColorScheme][500];
|
|
3560
3611
|
return {
|
|
3561
|
-
bgColor,
|
|
3562
|
-
color: getContrastColor(
|
|
3612
|
+
bgColor: finalBg,
|
|
3613
|
+
color: getContrastColor(finalBg != null ? finalBg : react.useToken("colors", processedColorScheme))
|
|
3563
3614
|
};
|
|
3564
3615
|
},
|
|
3565
3616
|
outline: ({ colorScheme, theme: { colors }, currentTheme }) => {
|
|
@@ -3594,7 +3645,8 @@
|
|
|
3594
3645
|
}
|
|
3595
3646
|
},
|
|
3596
3647
|
defaultProps: {
|
|
3597
|
-
size: "sm"
|
|
3648
|
+
size: "sm",
|
|
3649
|
+
variant: "solid"
|
|
3598
3650
|
}
|
|
3599
3651
|
};
|
|
3600
3652
|
|