@webdevarif/dashui 0.3.2 → 0.3.3
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 +48 -70
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -71
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -543,7 +543,7 @@ interface HslColorInputProps {
|
|
|
543
543
|
inputClassName?: string;
|
|
544
544
|
disabled?: boolean;
|
|
545
545
|
}
|
|
546
|
-
declare function HslColorInput({ value, onChange, className, inputClassName, disabled
|
|
546
|
+
declare function HslColorInput({ value, onChange, className, inputClassName, disabled }: HslColorInputProps): react_jsx_runtime.JSX.Element;
|
|
547
547
|
|
|
548
548
|
declare function useDisclosure(initial?: boolean): {
|
|
549
549
|
isOpen: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -543,7 +543,7 @@ interface HslColorInputProps {
|
|
|
543
543
|
inputClassName?: string;
|
|
544
544
|
disabled?: boolean;
|
|
545
545
|
}
|
|
546
|
-
declare function HslColorInput({ value, onChange, className, inputClassName, disabled
|
|
546
|
+
declare function HslColorInput({ value, onChange, className, inputClassName, disabled }: HslColorInputProps): react_jsx_runtime.JSX.Element;
|
|
547
547
|
|
|
548
548
|
declare function useDisclosure(initial?: boolean): {
|
|
549
549
|
isOpen: boolean;
|
package/dist/index.js
CHANGED
|
@@ -3310,41 +3310,25 @@ function PostSidebarSection({
|
|
|
3310
3310
|
// src/components/ui/hsl-color-input.tsx
|
|
3311
3311
|
var import_react = require("react");
|
|
3312
3312
|
var import_react_colorful = require("react-colorful");
|
|
3313
|
+
var Popover2 = __toESM(require("@radix-ui/react-popover"));
|
|
3313
3314
|
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
3314
3315
|
function parseHsl(value) {
|
|
3315
3316
|
if (!value) return { h: 0, s: 0, l: 0 };
|
|
3316
3317
|
const parts = value.trim().split(/\s+/);
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3318
|
+
return {
|
|
3319
|
+
h: parseFloat(parts[0]) || 0,
|
|
3320
|
+
s: parseFloat(parts[1]) || 0,
|
|
3321
|
+
l: parseFloat(parts[2]) || 0
|
|
3322
|
+
};
|
|
3321
3323
|
}
|
|
3322
3324
|
function formatHsl(color) {
|
|
3323
3325
|
return `${Math.round(color.h)} ${Math.round(color.s)}% ${Math.round(color.l)}%`;
|
|
3324
3326
|
}
|
|
3325
|
-
function HslColorInput({
|
|
3326
|
-
value,
|
|
3327
|
-
onChange,
|
|
3328
|
-
className,
|
|
3329
|
-
inputClassName,
|
|
3330
|
-
disabled
|
|
3331
|
-
}) {
|
|
3332
|
-
const [open, setOpen] = (0, import_react.useState)(false);
|
|
3327
|
+
function HslColorInput({ value, onChange, className, inputClassName, disabled }) {
|
|
3333
3328
|
const [inputVal, setInputVal] = (0, import_react.useState)(value);
|
|
3334
|
-
const containerRef = (0, import_react.useRef)(null);
|
|
3335
3329
|
(0, import_react.useEffect)(() => {
|
|
3336
3330
|
setInputVal(value);
|
|
3337
3331
|
}, [value]);
|
|
3338
|
-
(0, import_react.useEffect)(() => {
|
|
3339
|
-
if (!open) return;
|
|
3340
|
-
const handler = (e) => {
|
|
3341
|
-
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
3342
|
-
setOpen(false);
|
|
3343
|
-
}
|
|
3344
|
-
};
|
|
3345
|
-
document.addEventListener("mousedown", handler);
|
|
3346
|
-
return () => document.removeEventListener("mousedown", handler);
|
|
3347
|
-
}, [open]);
|
|
3348
3332
|
const hslColor = parseHsl(value);
|
|
3349
3333
|
const cssColor = value ? `hsl(${value})` : "transparent";
|
|
3350
3334
|
const handlePickerChange = (0, import_react.useCallback)((color) => {
|
|
@@ -3355,39 +3339,56 @@ function HslColorInput({
|
|
|
3355
3339
|
const handleInputChange = (e) => {
|
|
3356
3340
|
const v = e.target.value;
|
|
3357
3341
|
setInputVal(v);
|
|
3358
|
-
if (/^\d
|
|
3342
|
+
if (/^\d+(\.\d+)?\s+\d+(\.\d+)?%?\s+\d+(\.\d+)?%?$/.test(v.trim())) {
|
|
3359
3343
|
onChange(v);
|
|
3360
3344
|
}
|
|
3361
3345
|
};
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
"
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3346
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: cn("flex items-center gap-1.5", className), children: [
|
|
3347
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Popover2.Root, { children: [
|
|
3348
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Popover2.Trigger, { asChild: true, disabled, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
3349
|
+
"button",
|
|
3350
|
+
{
|
|
3351
|
+
type: "button",
|
|
3352
|
+
className: cn(
|
|
3353
|
+
"w-5 h-5 rounded border border-white/10 shrink-0 transition-all",
|
|
3354
|
+
"hover:scale-110 hover:border-white/30 focus:outline-none focus:ring-1 focus:ring-white/20",
|
|
3355
|
+
disabled && "opacity-50 cursor-not-allowed"
|
|
3356
|
+
),
|
|
3357
|
+
style: { background: cssColor },
|
|
3358
|
+
"aria-label": "Open color picker"
|
|
3359
|
+
}
|
|
3360
|
+
) }),
|
|
3361
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Popover2.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
|
|
3362
|
+
Popover2.Content,
|
|
3363
|
+
{
|
|
3364
|
+
sideOffset: 8,
|
|
3365
|
+
align: "start",
|
|
3366
|
+
className: cn(
|
|
3367
|
+
"z-[9999] rounded-xl shadow-2xl p-3",
|
|
3368
|
+
"bg-[#1a1c2e] border border-white/10",
|
|
3369
|
+
"flex flex-col gap-3",
|
|
3370
|
+
"animate-in fade-in-0 zoom-in-95"
|
|
3371
|
+
),
|
|
3372
|
+
children: [
|
|
3373
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_react_colorful.HslColorPicker, { color: hslColor, onChange: handlePickerChange }),
|
|
3374
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3375
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "w-6 h-6 rounded border border-white/10 shrink-0", style: { background: cssColor } }),
|
|
3376
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "text-xs font-mono text-white/50 truncate", children: value || "none" })
|
|
3377
|
+
] }),
|
|
3378
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Popover2.Arrow, { className: "fill-white/10" })
|
|
3379
|
+
]
|
|
3380
|
+
}
|
|
3381
|
+
) })
|
|
3382
|
+
] }),
|
|
3382
3383
|
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
3383
3384
|
"input",
|
|
3384
3385
|
{
|
|
3385
3386
|
type: "text",
|
|
3386
3387
|
value: inputVal,
|
|
3387
3388
|
onChange: handleInputChange,
|
|
3388
|
-
onBlur:
|
|
3389
|
+
onBlur: () => setInputVal(value),
|
|
3389
3390
|
disabled,
|
|
3390
|
-
placeholder: "
|
|
3391
|
+
placeholder: "H S% L%",
|
|
3391
3392
|
className: cn(
|
|
3392
3393
|
"w-28 bg-white/5 border border-white/10 rounded px-1.5 py-0.5",
|
|
3393
3394
|
"text-xs text-white/70 font-mono outline-none",
|
|
@@ -3396,30 +3397,7 @@ function HslColorInput({
|
|
|
3396
3397
|
inputClassName
|
|
3397
3398
|
)
|
|
3398
3399
|
}
|
|
3399
|
-
)
|
|
3400
|
-
open && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: cn(
|
|
3401
|
-
"absolute z-50 top-full left-0 mt-2",
|
|
3402
|
-
"bg-[#1a1c2e] border border-white/10 rounded-xl shadow-2xl p-3",
|
|
3403
|
-
"flex flex-col gap-3"
|
|
3404
|
-
), children: [
|
|
3405
|
-
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
3406
|
-
import_react_colorful.HslColorPicker,
|
|
3407
|
-
{
|
|
3408
|
-
color: hslColor,
|
|
3409
|
-
onChange: handlePickerChange
|
|
3410
|
-
}
|
|
3411
|
-
),
|
|
3412
|
-
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3413
|
-
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
3414
|
-
"div",
|
|
3415
|
-
{
|
|
3416
|
-
className: "w-6 h-6 rounded border border-white/10 shrink-0",
|
|
3417
|
-
style: { background: cssColor }
|
|
3418
|
-
}
|
|
3419
|
-
),
|
|
3420
|
-
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "text-xs font-mono text-white/50 truncate", children: value || "none" })
|
|
3421
|
-
] })
|
|
3422
|
-
] })
|
|
3400
|
+
)
|
|
3423
3401
|
] });
|
|
3424
3402
|
}
|
|
3425
3403
|
|