najm-kit 2.1.36 → 2.1.37
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.mjs +39 -10
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1621,6 +1621,23 @@ var PRESET_COLORS = [
|
|
|
1621
1621
|
"#000000"
|
|
1622
1622
|
];
|
|
1623
1623
|
var DEFAULT_FORMATS = ["hex", "rgb", "hsl", "oklch"];
|
|
1624
|
+
var CSS_VAR_RE = /^var\(\s*(--[\w-]+)\s*(?:,\s*(.+))?\)$/;
|
|
1625
|
+
function resolvePickerColor(value, themeContainer) {
|
|
1626
|
+
let current = value.trim();
|
|
1627
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1628
|
+
for (let depth = 0; depth < 10; depth += 1) {
|
|
1629
|
+
if (parseColor(current)) return current;
|
|
1630
|
+
const match = current.match(CSS_VAR_RE);
|
|
1631
|
+
if (!match) return current;
|
|
1632
|
+
const [, property, fallback] = match;
|
|
1633
|
+
if (seen.has(property)) return fallback?.trim() || current;
|
|
1634
|
+
seen.add(property);
|
|
1635
|
+
const target = themeContainer ?? (typeof document !== "undefined" ? document.documentElement : null);
|
|
1636
|
+
const resolved = target?.style.getPropertyValue(property).trim() || (target && typeof getComputedStyle === "function" ? getComputedStyle(target).getPropertyValue(property).trim() : "");
|
|
1637
|
+
current = resolved || fallback?.trim() || current;
|
|
1638
|
+
}
|
|
1639
|
+
return current;
|
|
1640
|
+
}
|
|
1624
1641
|
function ColorPickerInput(props) {
|
|
1625
1642
|
if (props.mode === "popover") {
|
|
1626
1643
|
return /* @__PURE__ */ jsx(PopoverColorPicker, { ...props });
|
|
@@ -1640,6 +1657,8 @@ function SwatchesColorPicker({
|
|
|
1640
1657
|
hideSwatches = false
|
|
1641
1658
|
}) {
|
|
1642
1659
|
const inputRef = useRef(null);
|
|
1660
|
+
const themeContainer = React__default.useContext(NajmThemeContainerCtx);
|
|
1661
|
+
const resolvedValue = resolvePickerColor(value, themeContainer);
|
|
1643
1662
|
return /* @__PURE__ */ jsxs(
|
|
1644
1663
|
BaseInput,
|
|
1645
1664
|
{
|
|
@@ -1665,7 +1684,7 @@ function SwatchesColorPicker({
|
|
|
1665
1684
|
{
|
|
1666
1685
|
ref: inputRef,
|
|
1667
1686
|
type: "color",
|
|
1668
|
-
value: toPickerHex(
|
|
1687
|
+
value: toPickerHex(resolvedValue),
|
|
1669
1688
|
onChange: (e) => onChange(e.target.value),
|
|
1670
1689
|
disabled,
|
|
1671
1690
|
className: "sr-only"
|
|
@@ -1708,7 +1727,9 @@ function PopoverColorPicker({
|
|
|
1708
1727
|
formats = DEFAULT_FORMATS,
|
|
1709
1728
|
output = "preserve"
|
|
1710
1729
|
}) {
|
|
1711
|
-
const
|
|
1730
|
+
const themeContainer = React__default.useContext(NajmThemeContainerCtx);
|
|
1731
|
+
const resolvedValue = resolvePickerColor(value, themeContainer);
|
|
1732
|
+
const initialFormat = formats.includes(detectFormat(resolvedValue)) ? detectFormat(resolvedValue) : formats[0] ?? "hex";
|
|
1712
1733
|
const [activeFormat, setActiveFormat] = useState(initialFormat);
|
|
1713
1734
|
const [draft, setDraft] = useState(value);
|
|
1714
1735
|
useEffect(() => {
|
|
@@ -1754,7 +1775,7 @@ function PopoverColorPicker({
|
|
|
1754
1775
|
"span",
|
|
1755
1776
|
{
|
|
1756
1777
|
className: "w-8 h-8 rounded-md border border-border shrink-0",
|
|
1757
|
-
style: { backgroundColor:
|
|
1778
|
+
style: { backgroundColor: value }
|
|
1758
1779
|
}
|
|
1759
1780
|
),
|
|
1760
1781
|
/* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground font-mono truncate", children: value })
|
|
@@ -1765,7 +1786,9 @@ function PopoverColorPicker({
|
|
|
1765
1786
|
/* @__PURE__ */ jsx(
|
|
1766
1787
|
HexColorPicker,
|
|
1767
1788
|
{
|
|
1768
|
-
color: toPickerHex(
|
|
1789
|
+
color: toPickerHex(
|
|
1790
|
+
draft === value ? resolvedValue : resolvePickerColor(draft, themeContainer)
|
|
1791
|
+
),
|
|
1769
1792
|
onChange: handlePickerChange,
|
|
1770
1793
|
style: { width: "100%" }
|
|
1771
1794
|
}
|
|
@@ -2744,7 +2767,18 @@ var THEME_TOKEN_GROUPS = [
|
|
|
2744
2767
|
{
|
|
2745
2768
|
id: "surface",
|
|
2746
2769
|
label: "Surface",
|
|
2747
|
-
tokens: [
|
|
2770
|
+
tokens: [
|
|
2771
|
+
"background",
|
|
2772
|
+
"foreground",
|
|
2773
|
+
"card",
|
|
2774
|
+
"card-foreground",
|
|
2775
|
+
"popover",
|
|
2776
|
+
"popover-foreground",
|
|
2777
|
+
"muted",
|
|
2778
|
+
"muted-foreground",
|
|
2779
|
+
"destructive",
|
|
2780
|
+
"destructive-foreground"
|
|
2781
|
+
]
|
|
2748
2782
|
},
|
|
2749
2783
|
{
|
|
2750
2784
|
id: "brand",
|
|
@@ -2760,11 +2794,6 @@ var THEME_TOKEN_GROUPS = [
|
|
|
2760
2794
|
"accent-foreground"
|
|
2761
2795
|
]
|
|
2762
2796
|
},
|
|
2763
|
-
{
|
|
2764
|
-
id: "feedback",
|
|
2765
|
-
label: "Feedback",
|
|
2766
|
-
tokens: ["muted", "muted-foreground", "destructive", "destructive-foreground"]
|
|
2767
|
-
},
|
|
2768
2797
|
{
|
|
2769
2798
|
id: "border-focus",
|
|
2770
2799
|
label: "Border & Focus",
|