@webdevarif/dashui 0.3.7 → 0.3.9
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 +68 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3386,42 +3386,79 @@ var ColorPickerEyeDropper = ({ className, ...props }) => {
|
|
|
3386
3386
|
};
|
|
3387
3387
|
var ColorPickerOutput = ({ className, ...props }) => {
|
|
3388
3388
|
const { mode, setMode } = useColorPicker();
|
|
3389
|
-
return /* @__PURE__ */
|
|
3390
|
-
"
|
|
3391
|
-
{
|
|
3392
|
-
|
|
3393
|
-
onChange: (e) => setMode(e.target.value),
|
|
3394
|
-
className: cn(
|
|
3395
|
-
"h-7 bg-white/5 border border-white/10 rounded-md text-xs text-white/60 px-1.5 outline-none",
|
|
3396
|
-
"hover:border-white/20 focus:border-white/30 cursor-pointer shrink-0",
|
|
3397
|
-
className
|
|
3398
|
-
),
|
|
3399
|
-
children: ["HEX", "HSL", "RGB"].map((f) => /* @__PURE__ */ jsx49("option", { value: f, className: "bg-[#1a1c2e]", children: f }, f))
|
|
3400
|
-
}
|
|
3401
|
-
);
|
|
3389
|
+
return /* @__PURE__ */ jsxs33(Select, { value: mode, onValueChange: setMode, children: [
|
|
3390
|
+
/* @__PURE__ */ jsx49(SelectTrigger, { className: cn("h-7 w-[4.5rem] shrink-0 text-xs px-2 border-white/10 bg-white/5 rounded-md", className), children: /* @__PURE__ */ jsx49(SelectValue, {}) }),
|
|
3391
|
+
/* @__PURE__ */ jsx49(SelectContent, { children: ["HEX", "HSL", "RGB"].map((f) => /* @__PURE__ */ jsx49(SelectItem, { value: f, className: "text-xs", children: f }, f)) })
|
|
3392
|
+
] });
|
|
3402
3393
|
};
|
|
3403
3394
|
var ColorPickerFormat = ({ className, ...props }) => {
|
|
3404
|
-
const { hue, saturation, lightness, alpha, mode } = useColorPicker();
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3395
|
+
const { hue, saturation, lightness, alpha, mode, setHue, setSaturation, setLightness, setAlpha } = useColorPicker();
|
|
3396
|
+
const [focused, setFocused] = useState7(false);
|
|
3397
|
+
const [localVal, setLocalVal] = useState7("");
|
|
3398
|
+
const computedVal = (() => {
|
|
3399
|
+
try {
|
|
3400
|
+
const c = Color.hsl(hue, saturation, lightness).alpha(alpha / 100);
|
|
3401
|
+
if (mode === "HEX") return c.hex().toUpperCase();
|
|
3402
|
+
if (mode === "HSL") return `${Math.round(hue)} ${Math.round(saturation)}% ${Math.round(lightness)}%`;
|
|
3403
|
+
if (mode === "RGB") {
|
|
3404
|
+
const [r, g, b] = c.rgb().array().map(Math.round);
|
|
3405
|
+
return `${r}, ${g}, ${b}`;
|
|
3406
|
+
}
|
|
3407
|
+
} catch {
|
|
3413
3408
|
}
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3409
|
+
return "";
|
|
3410
|
+
})();
|
|
3411
|
+
useEffect5(() => {
|
|
3412
|
+
if (!focused) setLocalVal(computedVal);
|
|
3413
|
+
}, [computedVal, focused]);
|
|
3414
|
+
const tryApply = (raw) => {
|
|
3415
|
+
try {
|
|
3416
|
+
if (mode === "HEX") {
|
|
3417
|
+
const hex = raw.startsWith("#") ? raw : `#${raw}`;
|
|
3418
|
+
const c = Color(hex);
|
|
3419
|
+
setHue(c.hue());
|
|
3420
|
+
setSaturation(c.saturationl());
|
|
3421
|
+
setLightness(c.lightness());
|
|
3422
|
+
setAlpha(c.alpha() * 100);
|
|
3423
|
+
} else if (mode === "HSL") {
|
|
3424
|
+
const parts = raw.split(/[\s,%]+/).filter(Boolean);
|
|
3425
|
+
if (parts.length >= 3) {
|
|
3426
|
+
setHue(+parts[0]);
|
|
3427
|
+
setSaturation(+parts[1]);
|
|
3428
|
+
setLightness(+parts[2]);
|
|
3429
|
+
}
|
|
3430
|
+
} else if (mode === "RGB") {
|
|
3431
|
+
const parts = raw.split(/[\s,]+/).filter(Boolean);
|
|
3432
|
+
if (parts.length >= 3) {
|
|
3433
|
+
const c = Color.rgb(+parts[0], +parts[1], +parts[2]);
|
|
3434
|
+
setHue(c.hue());
|
|
3435
|
+
setSaturation(c.saturationl());
|
|
3436
|
+
setLightness(c.lightness());
|
|
3437
|
+
}
|
|
3438
|
+
}
|
|
3439
|
+
} catch {
|
|
3440
|
+
}
|
|
3441
|
+
};
|
|
3417
3442
|
return /* @__PURE__ */ jsx49(
|
|
3418
3443
|
"input",
|
|
3419
3444
|
{
|
|
3420
|
-
readOnly: true,
|
|
3421
3445
|
type: "text",
|
|
3422
|
-
value:
|
|
3446
|
+
value: focused ? localVal : computedVal,
|
|
3447
|
+
onChange: (e) => {
|
|
3448
|
+
setLocalVal(e.target.value);
|
|
3449
|
+
tryApply(e.target.value);
|
|
3450
|
+
},
|
|
3451
|
+
onFocus: () => {
|
|
3452
|
+
setFocused(true);
|
|
3453
|
+
setLocalVal(computedVal);
|
|
3454
|
+
},
|
|
3455
|
+
onBlur: () => {
|
|
3456
|
+
tryApply(localVal);
|
|
3457
|
+
setFocused(false);
|
|
3458
|
+
},
|
|
3423
3459
|
className: cn(
|
|
3424
|
-
"flex-1 h-7 bg-white/5 border border-white/10 rounded-md px-2
|
|
3460
|
+
"flex-1 min-w-0 h-7 bg-white/5 border border-white/10 rounded-md px-2",
|
|
3461
|
+
"text-xs text-white/70 font-mono outline-none focus:border-white/30",
|
|
3425
3462
|
className
|
|
3426
3463
|
),
|
|
3427
3464
|
...props
|
|
@@ -3519,7 +3556,7 @@ function HslColorInput({ value, onChange, className, inputClassName, disabled })
|
|
|
3519
3556
|
sideOffset: 6,
|
|
3520
3557
|
align: "start",
|
|
3521
3558
|
className: cn(
|
|
3522
|
-
"z-[9999] rounded-xl shadow-2xl p-3 w-[
|
|
3559
|
+
"z-[9999] rounded-xl shadow-2xl p-3 w-[220px]",
|
|
3523
3560
|
"bg-[#0f1117] border border-white/10",
|
|
3524
3561
|
"focus:outline-none"
|
|
3525
3562
|
),
|
|
@@ -3534,9 +3571,9 @@ function HslColorInput({ value, onChange, className, inputClassName, disabled })
|
|
|
3534
3571
|
/* @__PURE__ */ jsx50(ColorPickerAlpha, {})
|
|
3535
3572
|
] })
|
|
3536
3573
|
] }),
|
|
3537
|
-
/* @__PURE__ */ jsxs34("div", { className: "flex items-center gap-1.5", children: [
|
|
3574
|
+
/* @__PURE__ */ jsxs34("div", { className: "flex items-center gap-1.5 min-w-0", children: [
|
|
3538
3575
|
/* @__PURE__ */ jsx50(ColorPickerOutput, {}),
|
|
3539
|
-
/* @__PURE__ */ jsx50(ColorPickerFormat, {})
|
|
3576
|
+
/* @__PURE__ */ jsx50(ColorPickerFormat, { className: "min-w-0" })
|
|
3540
3577
|
] })
|
|
3541
3578
|
] }, hexValue)
|
|
3542
3579
|
}
|