@webdevarif/dashui 0.3.6 → 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 +84 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +84 -34
- 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
|
@@ -3380,9 +3380,13 @@ var ColorPicker = ({
|
|
|
3380
3380
|
var ColorPickerSelection = (0, import_react.memo)(({ className, ...props }) => {
|
|
3381
3381
|
const containerRef = (0, import_react.useRef)(null);
|
|
3382
3382
|
const [isDragging, setIsDragging] = (0, import_react.useState)(false);
|
|
3383
|
-
const
|
|
3384
|
-
const [
|
|
3385
|
-
const
|
|
3383
|
+
const { hue, saturation, lightness, setSaturation, setLightness } = useColorPicker();
|
|
3384
|
+
const [posX, setPosX] = (0, import_react.useState)(() => saturation / 100);
|
|
3385
|
+
const [posY, setPosY] = (0, import_react.useState)(() => {
|
|
3386
|
+
const x = saturation / 100;
|
|
3387
|
+
const topL = x < 0.01 ? 100 : 50 + 50 * (1 - x);
|
|
3388
|
+
return topL > 0 ? Math.max(0, Math.min(1, 1 - lightness / topL)) : 0;
|
|
3389
|
+
});
|
|
3386
3390
|
const bg = (0, import_react.useMemo)(
|
|
3387
3391
|
() => `linear-gradient(0deg,rgba(0,0,0,1),rgba(0,0,0,0)),linear-gradient(90deg,rgba(255,255,255,1),rgba(255,255,255,0)),hsl(${hue},100%,50%)`,
|
|
3388
3392
|
[hue]
|
|
@@ -3525,42 +3529,88 @@ var ColorPickerEyeDropper = ({ className, ...props }) => {
|
|
|
3525
3529
|
};
|
|
3526
3530
|
var ColorPickerOutput = ({ className, ...props }) => {
|
|
3527
3531
|
const { mode, setMode } = useColorPicker();
|
|
3528
|
-
return /* @__PURE__ */ (0, import_jsx_runtime49.
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
"h-7 bg-white/
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
}
|
|
3540
|
-
);
|
|
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
|
+
] });
|
|
3541
3545
|
};
|
|
3542
3546
|
var ColorPickerFormat = ({ className, ...props }) => {
|
|
3543
|
-
const { hue, saturation, lightness, alpha, mode } = useColorPicker();
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
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 {
|
|
3552
3560
|
}
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
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
|
+
};
|
|
3556
3594
|
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
3557
3595
|
"input",
|
|
3558
3596
|
{
|
|
3559
|
-
readOnly: true,
|
|
3560
3597
|
type: "text",
|
|
3561
|
-
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
|
+
},
|
|
3562
3611
|
className: cn(
|
|
3563
|
-
"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",
|
|
3564
3614
|
className
|
|
3565
3615
|
),
|
|
3566
3616
|
...props
|
|
@@ -3658,7 +3708,7 @@ function HslColorInput({ value, onChange, className, inputClassName, disabled })
|
|
|
3658
3708
|
sideOffset: 6,
|
|
3659
3709
|
align: "start",
|
|
3660
3710
|
className: cn(
|
|
3661
|
-
"z-[9999] rounded-xl shadow-2xl p-3 w-[
|
|
3711
|
+
"z-[9999] rounded-xl shadow-2xl p-3 w-[220px]",
|
|
3662
3712
|
"bg-[#0f1117] border border-white/10",
|
|
3663
3713
|
"focus:outline-none"
|
|
3664
3714
|
),
|
|
@@ -3673,9 +3723,9 @@ function HslColorInput({ value, onChange, className, inputClassName, disabled })
|
|
|
3673
3723
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerAlpha, {})
|
|
3674
3724
|
] })
|
|
3675
3725
|
] }),
|
|
3676
|
-
/* @__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: [
|
|
3677
3727
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerOutput, {}),
|
|
3678
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerFormat, {})
|
|
3728
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerFormat, { className: "min-w-0" })
|
|
3679
3729
|
] })
|
|
3680
3730
|
] }, hexValue)
|
|
3681
3731
|
}
|