@webdevarif/dashui 0.3.7 → 0.3.8
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.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +77 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -572,7 +572,7 @@ declare const ColorPickerHexOutput: ({ className, ...props }: HTMLAttributes<HTM
|
|
|
572
572
|
declare const ColorPickerEyeDropper: ({ className, ...props }: HTMLAttributes<HTMLButtonElement>) => react_jsx_runtime.JSX.Element;
|
|
573
573
|
type ColorPickerOutputProps = HTMLAttributes<HTMLDivElement>;
|
|
574
574
|
declare const ColorPickerOutput: ({ className, ...props }: ColorPickerOutputProps) => react_jsx_runtime.JSX.Element;
|
|
575
|
-
type ColorPickerFormatProps = HTMLAttributes<
|
|
575
|
+
type ColorPickerFormatProps = HTMLAttributes<HTMLInputElement>;
|
|
576
576
|
declare const ColorPickerFormat: ({ className, ...props }: ColorPickerFormatProps) => react_jsx_runtime.JSX.Element;
|
|
577
577
|
|
|
578
578
|
declare function useDisclosure(initial?: boolean): {
|
package/dist/index.d.ts
CHANGED
|
@@ -572,7 +572,7 @@ declare const ColorPickerHexOutput: ({ className, ...props }: HTMLAttributes<HTM
|
|
|
572
572
|
declare const ColorPickerEyeDropper: ({ className, ...props }: HTMLAttributes<HTMLButtonElement>) => react_jsx_runtime.JSX.Element;
|
|
573
573
|
type ColorPickerOutputProps = HTMLAttributes<HTMLDivElement>;
|
|
574
574
|
declare const ColorPickerOutput: ({ className, ...props }: ColorPickerOutputProps) => react_jsx_runtime.JSX.Element;
|
|
575
|
-
type ColorPickerFormatProps = HTMLAttributes<
|
|
575
|
+
type ColorPickerFormatProps = HTMLAttributes<HTMLInputElement>;
|
|
576
576
|
declare const ColorPickerFormat: ({ className, ...props }: ColorPickerFormatProps) => react_jsx_runtime.JSX.Element;
|
|
577
577
|
|
|
578
578
|
declare function useDisclosure(initial?: boolean): {
|
package/dist/index.js
CHANGED
|
@@ -3529,42 +3529,88 @@ var ColorPickerEyeDropper = ({ className, ...props }) => {
|
|
|
3529
3529
|
};
|
|
3530
3530
|
var ColorPickerOutput = ({ className, ...props }) => {
|
|
3531
3531
|
const { mode, setMode } = useColorPicker();
|
|
3532
|
-
return /* @__PURE__ */ (0, import_jsx_runtime49.
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
"h-7 bg-white/
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
}
|
|
3544
|
-
);
|
|
3532
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: cn("relative shrink-0", className), children: [
|
|
3533
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
3534
|
+
"select",
|
|
3535
|
+
{
|
|
3536
|
+
value: mode,
|
|
3537
|
+
onChange: (e) => setMode(e.target.value),
|
|
3538
|
+
className: "appearance-none h-7 bg-white/8 border border-white/10 rounded-md text-xs text-white/70 pl-2 pr-6 outline-none hover:border-white/20 cursor-pointer",
|
|
3539
|
+
style: { backgroundColor: "rgba(255,255,255,0.05)" },
|
|
3540
|
+
children: ["HEX", "HSL", "RGB"].map((f) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("option", { value: f, style: { background: "#1a1c2e" }, children: f }, f))
|
|
3541
|
+
}
|
|
3542
|
+
),
|
|
3543
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("svg", { className: "pointer-events-none absolute right-1.5 top-1/2 -translate-y-1/2 w-3 h-3 text-white/40", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("path", { d: "m6 9 6 6 6-6" }) })
|
|
3544
|
+
] });
|
|
3545
3545
|
};
|
|
3546
3546
|
var ColorPickerFormat = ({ className, ...props }) => {
|
|
3547
|
-
const { hue, saturation, lightness, alpha, mode } = useColorPicker();
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3547
|
+
const { hue, saturation, lightness, alpha, mode, setHue, setSaturation, setLightness, setAlpha } = useColorPicker();
|
|
3548
|
+
const [focused, setFocused] = (0, import_react.useState)(false);
|
|
3549
|
+
const [localVal, setLocalVal] = (0, import_react.useState)("");
|
|
3550
|
+
const computedVal = (() => {
|
|
3551
|
+
try {
|
|
3552
|
+
const c = import_color.default.hsl(hue, saturation, lightness).alpha(alpha / 100);
|
|
3553
|
+
if (mode === "HEX") return c.hex().toUpperCase();
|
|
3554
|
+
if (mode === "HSL") return `${Math.round(hue)} ${Math.round(saturation)}% ${Math.round(lightness)}%`;
|
|
3555
|
+
if (mode === "RGB") {
|
|
3556
|
+
const [r, g, b] = c.rgb().array().map(Math.round);
|
|
3557
|
+
return `${r}, ${g}, ${b}`;
|
|
3558
|
+
}
|
|
3559
|
+
} catch {
|
|
3556
3560
|
}
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3561
|
+
return "";
|
|
3562
|
+
})();
|
|
3563
|
+
(0, import_react.useEffect)(() => {
|
|
3564
|
+
if (!focused) setLocalVal(computedVal);
|
|
3565
|
+
}, [computedVal, focused]);
|
|
3566
|
+
const tryApply = (raw) => {
|
|
3567
|
+
try {
|
|
3568
|
+
if (mode === "HEX") {
|
|
3569
|
+
const hex = raw.startsWith("#") ? raw : `#${raw}`;
|
|
3570
|
+
const c = (0, import_color.default)(hex);
|
|
3571
|
+
setHue(c.hue());
|
|
3572
|
+
setSaturation(c.saturationl());
|
|
3573
|
+
setLightness(c.lightness());
|
|
3574
|
+
setAlpha(c.alpha() * 100);
|
|
3575
|
+
} else if (mode === "HSL") {
|
|
3576
|
+
const parts = raw.split(/[\s,%]+/).filter(Boolean);
|
|
3577
|
+
if (parts.length >= 3) {
|
|
3578
|
+
setHue(+parts[0]);
|
|
3579
|
+
setSaturation(+parts[1]);
|
|
3580
|
+
setLightness(+parts[2]);
|
|
3581
|
+
}
|
|
3582
|
+
} else if (mode === "RGB") {
|
|
3583
|
+
const parts = raw.split(/[\s,]+/).filter(Boolean);
|
|
3584
|
+
if (parts.length >= 3) {
|
|
3585
|
+
const c = import_color.default.rgb(+parts[0], +parts[1], +parts[2]);
|
|
3586
|
+
setHue(c.hue());
|
|
3587
|
+
setSaturation(c.saturationl());
|
|
3588
|
+
setLightness(c.lightness());
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
} catch {
|
|
3592
|
+
}
|
|
3593
|
+
};
|
|
3560
3594
|
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
3561
3595
|
"input",
|
|
3562
3596
|
{
|
|
3563
|
-
readOnly: true,
|
|
3564
3597
|
type: "text",
|
|
3565
|
-
value:
|
|
3598
|
+
value: focused ? localVal : computedVal,
|
|
3599
|
+
onChange: (e) => {
|
|
3600
|
+
setLocalVal(e.target.value);
|
|
3601
|
+
tryApply(e.target.value);
|
|
3602
|
+
},
|
|
3603
|
+
onFocus: () => {
|
|
3604
|
+
setFocused(true);
|
|
3605
|
+
setLocalVal(computedVal);
|
|
3606
|
+
},
|
|
3607
|
+
onBlur: () => {
|
|
3608
|
+
tryApply(localVal);
|
|
3609
|
+
setFocused(false);
|
|
3610
|
+
},
|
|
3566
3611
|
className: cn(
|
|
3567
|
-
"flex-1 h-7 bg-white/5 border border-white/10 rounded-md px-2
|
|
3612
|
+
"flex-1 min-w-0 h-7 bg-white/5 border border-white/10 rounded-md px-2",
|
|
3613
|
+
"text-xs text-white/70 font-mono outline-none focus:border-white/30",
|
|
3568
3614
|
className
|
|
3569
3615
|
),
|
|
3570
3616
|
...props
|
|
@@ -3662,7 +3708,7 @@ function HslColorInput({ value, onChange, className, inputClassName, disabled })
|
|
|
3662
3708
|
sideOffset: 6,
|
|
3663
3709
|
align: "start",
|
|
3664
3710
|
className: cn(
|
|
3665
|
-
"z-[9999] rounded-xl shadow-2xl p-3 w-[
|
|
3711
|
+
"z-[9999] rounded-xl shadow-2xl p-3 w-[220px]",
|
|
3666
3712
|
"bg-[#0f1117] border border-white/10",
|
|
3667
3713
|
"focus:outline-none"
|
|
3668
3714
|
),
|
|
@@ -3677,9 +3723,9 @@ function HslColorInput({ value, onChange, className, inputClassName, disabled })
|
|
|
3677
3723
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerAlpha, {})
|
|
3678
3724
|
] })
|
|
3679
3725
|
] }),
|
|
3680
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
3726
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center gap-1.5 min-w-0", children: [
|
|
3681
3727
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerOutput, {}),
|
|
3682
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerFormat, {})
|
|
3728
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerFormat, { className: "min-w-0" })
|
|
3683
3729
|
] })
|
|
3684
3730
|
] }, hexValue)
|
|
3685
3731
|
}
|