@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.mjs
CHANGED
|
@@ -3165,43 +3165,27 @@ function PostSidebarSection({
|
|
|
3165
3165
|
}
|
|
3166
3166
|
|
|
3167
3167
|
// src/components/ui/hsl-color-input.tsx
|
|
3168
|
-
import { useState as useState7,
|
|
3168
|
+
import { useState as useState7, useEffect as useEffect5, useCallback } from "react";
|
|
3169
3169
|
import { HslColorPicker } from "react-colorful";
|
|
3170
|
+
import * as Popover2 from "@radix-ui/react-popover";
|
|
3170
3171
|
import { jsx as jsx49, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
3171
3172
|
function parseHsl(value) {
|
|
3172
3173
|
if (!value) return { h: 0, s: 0, l: 0 };
|
|
3173
3174
|
const parts = value.trim().split(/\s+/);
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3175
|
+
return {
|
|
3176
|
+
h: parseFloat(parts[0]) || 0,
|
|
3177
|
+
s: parseFloat(parts[1]) || 0,
|
|
3178
|
+
l: parseFloat(parts[2]) || 0
|
|
3179
|
+
};
|
|
3178
3180
|
}
|
|
3179
3181
|
function formatHsl(color) {
|
|
3180
3182
|
return `${Math.round(color.h)} ${Math.round(color.s)}% ${Math.round(color.l)}%`;
|
|
3181
3183
|
}
|
|
3182
|
-
function HslColorInput({
|
|
3183
|
-
value,
|
|
3184
|
-
onChange,
|
|
3185
|
-
className,
|
|
3186
|
-
inputClassName,
|
|
3187
|
-
disabled
|
|
3188
|
-
}) {
|
|
3189
|
-
const [open, setOpen] = useState7(false);
|
|
3184
|
+
function HslColorInput({ value, onChange, className, inputClassName, disabled }) {
|
|
3190
3185
|
const [inputVal, setInputVal] = useState7(value);
|
|
3191
|
-
const containerRef = useRef4(null);
|
|
3192
3186
|
useEffect5(() => {
|
|
3193
3187
|
setInputVal(value);
|
|
3194
3188
|
}, [value]);
|
|
3195
|
-
useEffect5(() => {
|
|
3196
|
-
if (!open) return;
|
|
3197
|
-
const handler = (e) => {
|
|
3198
|
-
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
3199
|
-
setOpen(false);
|
|
3200
|
-
}
|
|
3201
|
-
};
|
|
3202
|
-
document.addEventListener("mousedown", handler);
|
|
3203
|
-
return () => document.removeEventListener("mousedown", handler);
|
|
3204
|
-
}, [open]);
|
|
3205
3189
|
const hslColor = parseHsl(value);
|
|
3206
3190
|
const cssColor = value ? `hsl(${value})` : "transparent";
|
|
3207
3191
|
const handlePickerChange = useCallback((color) => {
|
|
@@ -3212,39 +3196,56 @@ function HslColorInput({
|
|
|
3212
3196
|
const handleInputChange = (e) => {
|
|
3213
3197
|
const v = e.target.value;
|
|
3214
3198
|
setInputVal(v);
|
|
3215
|
-
if (/^\d
|
|
3199
|
+
if (/^\d+(\.\d+)?\s+\d+(\.\d+)?%?\s+\d+(\.\d+)?%?$/.test(v.trim())) {
|
|
3216
3200
|
onChange(v);
|
|
3217
3201
|
}
|
|
3218
3202
|
};
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
"
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3203
|
+
return /* @__PURE__ */ jsxs33("div", { className: cn("flex items-center gap-1.5", className), children: [
|
|
3204
|
+
/* @__PURE__ */ jsxs33(Popover2.Root, { children: [
|
|
3205
|
+
/* @__PURE__ */ jsx49(Popover2.Trigger, { asChild: true, disabled, children: /* @__PURE__ */ jsx49(
|
|
3206
|
+
"button",
|
|
3207
|
+
{
|
|
3208
|
+
type: "button",
|
|
3209
|
+
className: cn(
|
|
3210
|
+
"w-5 h-5 rounded border border-white/10 shrink-0 transition-all",
|
|
3211
|
+
"hover:scale-110 hover:border-white/30 focus:outline-none focus:ring-1 focus:ring-white/20",
|
|
3212
|
+
disabled && "opacity-50 cursor-not-allowed"
|
|
3213
|
+
),
|
|
3214
|
+
style: { background: cssColor },
|
|
3215
|
+
"aria-label": "Open color picker"
|
|
3216
|
+
}
|
|
3217
|
+
) }),
|
|
3218
|
+
/* @__PURE__ */ jsx49(Popover2.Portal, { children: /* @__PURE__ */ jsxs33(
|
|
3219
|
+
Popover2.Content,
|
|
3220
|
+
{
|
|
3221
|
+
sideOffset: 8,
|
|
3222
|
+
align: "start",
|
|
3223
|
+
className: cn(
|
|
3224
|
+
"z-[9999] rounded-xl shadow-2xl p-3",
|
|
3225
|
+
"bg-[#1a1c2e] border border-white/10",
|
|
3226
|
+
"flex flex-col gap-3",
|
|
3227
|
+
"animate-in fade-in-0 zoom-in-95"
|
|
3228
|
+
),
|
|
3229
|
+
children: [
|
|
3230
|
+
/* @__PURE__ */ jsx49(HslColorPicker, { color: hslColor, onChange: handlePickerChange }),
|
|
3231
|
+
/* @__PURE__ */ jsxs33("div", { className: "flex items-center gap-2", children: [
|
|
3232
|
+
/* @__PURE__ */ jsx49("div", { className: "w-6 h-6 rounded border border-white/10 shrink-0", style: { background: cssColor } }),
|
|
3233
|
+
/* @__PURE__ */ jsx49("span", { className: "text-xs font-mono text-white/50 truncate", children: value || "none" })
|
|
3234
|
+
] }),
|
|
3235
|
+
/* @__PURE__ */ jsx49(Popover2.Arrow, { className: "fill-white/10" })
|
|
3236
|
+
]
|
|
3237
|
+
}
|
|
3238
|
+
) })
|
|
3239
|
+
] }),
|
|
3239
3240
|
/* @__PURE__ */ jsx49(
|
|
3240
3241
|
"input",
|
|
3241
3242
|
{
|
|
3242
3243
|
type: "text",
|
|
3243
3244
|
value: inputVal,
|
|
3244
3245
|
onChange: handleInputChange,
|
|
3245
|
-
onBlur:
|
|
3246
|
+
onBlur: () => setInputVal(value),
|
|
3246
3247
|
disabled,
|
|
3247
|
-
placeholder: "
|
|
3248
|
+
placeholder: "H S% L%",
|
|
3248
3249
|
className: cn(
|
|
3249
3250
|
"w-28 bg-white/5 border border-white/10 rounded px-1.5 py-0.5",
|
|
3250
3251
|
"text-xs text-white/70 font-mono outline-none",
|
|
@@ -3253,30 +3254,7 @@ function HslColorInput({
|
|
|
3253
3254
|
inputClassName
|
|
3254
3255
|
)
|
|
3255
3256
|
}
|
|
3256
|
-
)
|
|
3257
|
-
open && /* @__PURE__ */ jsxs33("div", { className: cn(
|
|
3258
|
-
"absolute z-50 top-full left-0 mt-2",
|
|
3259
|
-
"bg-[#1a1c2e] border border-white/10 rounded-xl shadow-2xl p-3",
|
|
3260
|
-
"flex flex-col gap-3"
|
|
3261
|
-
), children: [
|
|
3262
|
-
/* @__PURE__ */ jsx49(
|
|
3263
|
-
HslColorPicker,
|
|
3264
|
-
{
|
|
3265
|
-
color: hslColor,
|
|
3266
|
-
onChange: handlePickerChange
|
|
3267
|
-
}
|
|
3268
|
-
),
|
|
3269
|
-
/* @__PURE__ */ jsxs33("div", { className: "flex items-center gap-2", children: [
|
|
3270
|
-
/* @__PURE__ */ jsx49(
|
|
3271
|
-
"div",
|
|
3272
|
-
{
|
|
3273
|
-
className: "w-6 h-6 rounded border border-white/10 shrink-0",
|
|
3274
|
-
style: { background: cssColor }
|
|
3275
|
-
}
|
|
3276
|
-
),
|
|
3277
|
-
/* @__PURE__ */ jsx49("span", { className: "text-xs font-mono text-white/50 truncate", children: value || "none" })
|
|
3278
|
-
] })
|
|
3279
|
-
] })
|
|
3257
|
+
)
|
|
3280
3258
|
] });
|
|
3281
3259
|
}
|
|
3282
3260
|
|