@webdevarif/dashui 0.3.12 → 0.3.13
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +80 -107
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -107
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3213,8 +3213,7 @@ var ColorPicker = ({
|
|
|
3213
3213
|
notifyRef.current = onChange;
|
|
3214
3214
|
}, [onChange]);
|
|
3215
3215
|
const notify = useCallback((h, s, l, a) => {
|
|
3216
|
-
|
|
3217
|
-
notifyRef.current?.(hex);
|
|
3216
|
+
notifyRef.current?.(Color.hsl(h, s, l).alpha(a / 100).hexa());
|
|
3218
3217
|
}, []);
|
|
3219
3218
|
const setHue = useCallback((h) => {
|
|
3220
3219
|
setHueState(h);
|
|
@@ -3232,7 +3231,7 @@ var ColorPicker = ({
|
|
|
3232
3231
|
setAlphaState(a);
|
|
3233
3232
|
notify(hue, saturation, lightness, a);
|
|
3234
3233
|
}, [hue, saturation, lightness, notify]);
|
|
3235
|
-
return /* @__PURE__ */ jsx49(ColorPickerContext.Provider, { value: { hue, saturation, lightness, alpha, setHue, setSaturation, setLightness, setAlpha,
|
|
3234
|
+
return /* @__PURE__ */ jsx49(ColorPickerContext.Provider, { value: { hue, saturation, lightness, alpha, mode, setHue, setSaturation, setLightness, setAlpha, setMode }, children: /* @__PURE__ */ jsx49("div", { className: cn("flex flex-col gap-3", className), ...props, children }) });
|
|
3236
3235
|
};
|
|
3237
3236
|
var ColorPickerSelection = memo(({ className, ...props }) => {
|
|
3238
3237
|
const containerRef = useRef4(null);
|
|
@@ -3256,8 +3255,7 @@ var ColorPickerSelection = memo(({ className, ...props }) => {
|
|
|
3256
3255
|
setPosX(x);
|
|
3257
3256
|
setPosY(y);
|
|
3258
3257
|
setSaturation(x * 100);
|
|
3259
|
-
|
|
3260
|
-
setLightness(topL * (1 - y));
|
|
3258
|
+
setLightness((x < 0.01 ? 100 : 50 + 50 * (1 - x)) * (1 - y));
|
|
3261
3259
|
}, [isDragging, setSaturation, setLightness]);
|
|
3262
3260
|
useEffect5(() => {
|
|
3263
3261
|
if (!isDragging) return;
|
|
@@ -3285,11 +3283,7 @@ var ColorPickerSelection = memo(({ className, ...props }) => {
|
|
|
3285
3283
|
"div",
|
|
3286
3284
|
{
|
|
3287
3285
|
className: "pointer-events-none absolute h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white",
|
|
3288
|
-
style: {
|
|
3289
|
-
left: `${posX * 100}%`,
|
|
3290
|
-
top: `${posY * 100}%`,
|
|
3291
|
-
boxShadow: "0 0 0 1px rgba(0,0,0,0.6)"
|
|
3292
|
-
}
|
|
3286
|
+
style: { left: `${posX * 100}%`, top: `${posY * 100}%`, boxShadow: "0 0 0 1px rgba(0,0,0,0.6)" }
|
|
3293
3287
|
}
|
|
3294
3288
|
)
|
|
3295
3289
|
}
|
|
@@ -3298,85 +3292,42 @@ var ColorPickerSelection = memo(({ className, ...props }) => {
|
|
|
3298
3292
|
ColorPickerSelection.displayName = "ColorPickerSelection";
|
|
3299
3293
|
var ColorPickerHue = ({ className, ...props }) => {
|
|
3300
3294
|
const { hue, setHue } = useColorPicker();
|
|
3301
|
-
return /* @__PURE__ */ jsxs33(
|
|
3302
|
-
Slider.
|
|
3303
|
-
{
|
|
3304
|
-
|
|
3305
|
-
max: 360,
|
|
3306
|
-
step: 1,
|
|
3307
|
-
value: [hue],
|
|
3308
|
-
onValueChange: ([h]) => setHue(h),
|
|
3309
|
-
...props,
|
|
3310
|
-
children: [
|
|
3311
|
-
/* @__PURE__ */ jsx49(Slider.Track, { className: "relative h-3 w-full grow rounded-full bg-[linear-gradient(90deg,#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00)]", children: /* @__PURE__ */ jsx49(Slider.Range, { className: "absolute h-full" }) }),
|
|
3312
|
-
/* @__PURE__ */ jsx49(Slider.Thumb, { className: "block h-4 w-4 rounded-full border-2 border-white shadow-md focus:outline-none", style: { boxShadow: "0 0 0 1px rgba(0,0,0,0.4)" } })
|
|
3313
|
-
]
|
|
3314
|
-
}
|
|
3315
|
-
);
|
|
3295
|
+
return /* @__PURE__ */ jsxs33(Slider.Root, { className: cn("relative flex h-4 w-full touch-none items-center", className), max: 360, step: 1, value: [hue], onValueChange: ([h]) => setHue(h), ...props, children: [
|
|
3296
|
+
/* @__PURE__ */ jsx49(Slider.Track, { className: "relative h-3 w-full grow rounded-full bg-[linear-gradient(90deg,#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00)]", children: /* @__PURE__ */ jsx49(Slider.Range, { className: "absolute h-full" }) }),
|
|
3297
|
+
/* @__PURE__ */ jsx49(Slider.Thumb, { className: "block h-4 w-4 rounded-full border-2 border-white shadow-md focus:outline-none", style: { boxShadow: "0 0 0 1px rgba(0,0,0,0.4)" } })
|
|
3298
|
+
] });
|
|
3316
3299
|
};
|
|
3317
3300
|
var ColorPickerAlpha = ({ className, ...props }) => {
|
|
3318
3301
|
const { alpha, setAlpha, hue, saturation, lightness } = useColorPicker();
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
{
|
|
3323
|
-
|
|
3324
|
-
max: 100,
|
|
3325
|
-
step: 1,
|
|
3326
|
-
value: [alpha],
|
|
3327
|
-
onValueChange: ([a]) => setAlpha(a),
|
|
3328
|
-
...props,
|
|
3329
|
-
children: [
|
|
3330
|
-
/* @__PURE__ */ jsx49(
|
|
3331
|
-
Slider.Track,
|
|
3332
|
-
{
|
|
3333
|
-
className: "relative h-3 w-full grow rounded-full",
|
|
3334
|
-
style: {
|
|
3335
|
-
backgroundImage: `linear-gradient(90deg, transparent, ${solidColor}), url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==")`
|
|
3336
|
-
},
|
|
3337
|
-
children: /* @__PURE__ */ jsx49(Slider.Range, { className: "absolute h-full" })
|
|
3338
|
-
}
|
|
3339
|
-
),
|
|
3340
|
-
/* @__PURE__ */ jsx49(Slider.Thumb, { className: "block h-4 w-4 rounded-full border-2 border-white shadow-md focus:outline-none", style: { boxShadow: "0 0 0 1px rgba(0,0,0,0.4)" } })
|
|
3341
|
-
]
|
|
3342
|
-
}
|
|
3343
|
-
);
|
|
3344
|
-
};
|
|
3345
|
-
var ColorPickerHexOutput = ({ className, ...props }) => {
|
|
3346
|
-
const { hue, saturation, lightness, alpha } = useColorPicker();
|
|
3347
|
-
const hex = Color.hsl(hue, saturation, lightness).alpha(alpha / 100).hex();
|
|
3348
|
-
return /* @__PURE__ */ jsxs33("div", { className: cn("flex items-center gap-1.5 px-1", className), ...props, children: [
|
|
3349
|
-
/* @__PURE__ */ jsx49("div", { className: "w-5 h-5 rounded border border-white/20 shrink-0", style: { background: `hsl(${hue},${saturation}%,${lightness}%)` } }),
|
|
3350
|
-
/* @__PURE__ */ jsx49("span", { className: "text-xs font-mono text-white/50 flex-1", children: hex })
|
|
3302
|
+
return /* @__PURE__ */ jsxs33(Slider.Root, { className: cn("relative flex h-4 w-full touch-none items-center", className), max: 100, step: 1, value: [alpha], onValueChange: ([a]) => setAlpha(a), ...props, children: [
|
|
3303
|
+
/* @__PURE__ */ jsx49(Slider.Track, { className: "relative h-3 w-full grow rounded-full", style: {
|
|
3304
|
+
backgroundImage: `linear-gradient(90deg,transparent,hsl(${hue},${saturation}%,${lightness}%)),url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==")`
|
|
3305
|
+
}, children: /* @__PURE__ */ jsx49(Slider.Range, { className: "absolute h-full" }) }),
|
|
3306
|
+
/* @__PURE__ */ jsx49(Slider.Thumb, { className: "block h-4 w-4 rounded-full border-2 border-white shadow-md focus:outline-none", style: { boxShadow: "0 0 0 1px rgba(0,0,0,0.4)" } })
|
|
3351
3307
|
] });
|
|
3352
3308
|
};
|
|
3353
3309
|
var ColorPickerEyeDropper = ({ className, ...props }) => {
|
|
3354
3310
|
const { setHue, setSaturation, setLightness, setAlpha } = useColorPicker();
|
|
3355
|
-
const pick = async () => {
|
|
3356
|
-
try {
|
|
3357
|
-
const result = await new EyeDropper().open();
|
|
3358
|
-
const c = Color(result.sRGBHex);
|
|
3359
|
-
setHue(c.hue());
|
|
3360
|
-
setSaturation(c.saturationl());
|
|
3361
|
-
setLightness(c.lightness());
|
|
3362
|
-
setAlpha(100);
|
|
3363
|
-
} catch {
|
|
3364
|
-
}
|
|
3365
|
-
};
|
|
3366
3311
|
return /* @__PURE__ */ jsx49(
|
|
3367
3312
|
"button",
|
|
3368
3313
|
{
|
|
3369
3314
|
type: "button",
|
|
3370
|
-
onClick: pick,
|
|
3371
3315
|
title: "Eye dropper",
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3316
|
+
onClick: async () => {
|
|
3317
|
+
try {
|
|
3318
|
+
const r = await new EyeDropper().open();
|
|
3319
|
+
const c = Color(r.sRGBHex);
|
|
3320
|
+
setHue(c.hue());
|
|
3321
|
+
setSaturation(c.saturationl());
|
|
3322
|
+
setLightness(c.lightness());
|
|
3323
|
+
setAlpha(100);
|
|
3324
|
+
} catch {
|
|
3325
|
+
}
|
|
3326
|
+
},
|
|
3327
|
+
className: cn("shrink-0 focus:outline-none", className),
|
|
3328
|
+
style: { width: 32, height: 32, display: "flex", alignItems: "center", justifyContent: "center", borderRadius: 6, border: "1px solid rgba(255,255,255,0.12)", backgroundColor: "rgba(255,255,255,0.05)", color: "rgba(255,255,255,0.5)", cursor: "pointer" },
|
|
3378
3329
|
...props,
|
|
3379
|
-
children: /* @__PURE__ */ jsxs33("svg", {
|
|
3330
|
+
children: /* @__PURE__ */ jsxs33("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [
|
|
3380
3331
|
/* @__PURE__ */ jsx49("path", { d: "M9.53 16.122a3 3 0 0 0-5.78 1.128 2.25 2.25 0 0 1-2.4 2.245 4.5 4.5 0 0 0 8.4-2.245c0-.399-.078-.78-.22-1.128Z" }),
|
|
3381
3332
|
/* @__PURE__ */ jsx49("path", { d: "m13.5 10.5 2.25-2.25m0 0 2.25-2.25M15.75 8.25l2.25 2.25M15.75 8.25 13.5 6m4.5-1.5 1.5-1.5" }),
|
|
3382
3333
|
/* @__PURE__ */ jsx49("path", { d: "M6.75 7.5 10.5 4.5c.5-.375 1.25-.375 1.5 0l6.75 6.75c.375.5.375 1.25 0 1.5L15 16.5" })
|
|
@@ -3386,25 +3337,31 @@ var ColorPickerEyeDropper = ({ className, ...props }) => {
|
|
|
3386
3337
|
};
|
|
3387
3338
|
var ColorPickerOutput = ({ className, ...props }) => {
|
|
3388
3339
|
const { mode, setMode } = useColorPicker();
|
|
3389
|
-
return /* @__PURE__ */ jsxs33(
|
|
3390
|
-
/* @__PURE__ */ jsx49(SelectTrigger, { className: cn("h-7 w-[4.5rem] shrink-0 text-xs px-2 border-white/10 bg-white/5 text-white/70 rounded-md", className), children: /* @__PURE__ */ jsx49(SelectValue, {}) }),
|
|
3340
|
+
return /* @__PURE__ */ jsxs33("div", { className: cn("relative shrink-0", className), ...props, children: [
|
|
3391
3341
|
/* @__PURE__ */ jsx49(
|
|
3392
|
-
|
|
3342
|
+
"select",
|
|
3393
3343
|
{
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3344
|
+
value: mode,
|
|
3345
|
+
onChange: (e) => setMode(e.target.value),
|
|
3346
|
+
style: {
|
|
3347
|
+
height: 32,
|
|
3348
|
+
width: 72,
|
|
3349
|
+
backgroundColor: "rgba(255,255,255,0.06)",
|
|
3350
|
+
border: "1px solid rgba(255,255,255,0.12)",
|
|
3351
|
+
borderRadius: 6,
|
|
3352
|
+
color: "rgba(255,255,255,0.75)",
|
|
3353
|
+
fontSize: 12,
|
|
3354
|
+
paddingLeft: 8,
|
|
3355
|
+
paddingRight: 24,
|
|
3356
|
+
outline: "none",
|
|
3357
|
+
cursor: "pointer",
|
|
3358
|
+
appearance: "none",
|
|
3359
|
+
WebkitAppearance: "none"
|
|
3360
|
+
},
|
|
3361
|
+
children: ["HEX", "HSL", "RGB"].map((f) => /* @__PURE__ */ jsx49("option", { value: f, style: { backgroundColor: "#1e2130", color: "rgba(255,255,255,0.8)" }, children: f }, f))
|
|
3406
3362
|
}
|
|
3407
|
-
)
|
|
3363
|
+
),
|
|
3364
|
+
/* @__PURE__ */ jsx49("svg", { style: { position: "absolute", right: 6, top: "50%", transform: "translateY(-50%)", width: 12, height: 12, color: "rgba(255,255,255,0.35)", pointerEvents: "none" }, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: /* @__PURE__ */ jsx49("path", { d: "m6 9 6 6 6-6" }) })
|
|
3408
3365
|
] });
|
|
3409
3366
|
};
|
|
3410
3367
|
var ColorPickerFormat = ({ className, ...props }) => {
|
|
@@ -3430,23 +3387,22 @@ var ColorPickerFormat = ({ className, ...props }) => {
|
|
|
3430
3387
|
const tryApply = (raw) => {
|
|
3431
3388
|
try {
|
|
3432
3389
|
if (mode === "HEX") {
|
|
3433
|
-
const
|
|
3434
|
-
const c = Color(hex);
|
|
3390
|
+
const c = Color(raw.startsWith("#") ? raw : `#${raw}`);
|
|
3435
3391
|
setHue(c.hue());
|
|
3436
3392
|
setSaturation(c.saturationl());
|
|
3437
3393
|
setLightness(c.lightness());
|
|
3438
3394
|
setAlpha(c.alpha() * 100);
|
|
3439
3395
|
} else if (mode === "HSL") {
|
|
3440
|
-
const
|
|
3441
|
-
if (
|
|
3442
|
-
setHue(+
|
|
3443
|
-
setSaturation(+
|
|
3444
|
-
setLightness(+
|
|
3396
|
+
const p = raw.split(/[\s,%]+/).filter(Boolean);
|
|
3397
|
+
if (p.length >= 3) {
|
|
3398
|
+
setHue(+p[0]);
|
|
3399
|
+
setSaturation(+p[1]);
|
|
3400
|
+
setLightness(+p[2]);
|
|
3445
3401
|
}
|
|
3446
3402
|
} else if (mode === "RGB") {
|
|
3447
|
-
const
|
|
3448
|
-
if (
|
|
3449
|
-
const c = Color.rgb(+
|
|
3403
|
+
const p = raw.split(/[\s,]+/).filter(Boolean);
|
|
3404
|
+
if (p.length >= 3) {
|
|
3405
|
+
const c = Color.rgb(+p[0], +p[1], +p[2]);
|
|
3450
3406
|
setHue(c.hue());
|
|
3451
3407
|
setSaturation(c.saturationl());
|
|
3452
3408
|
setLightness(c.lightness());
|
|
@@ -3472,15 +3428,32 @@ var ColorPickerFormat = ({ className, ...props }) => {
|
|
|
3472
3428
|
tryApply(localVal);
|
|
3473
3429
|
setFocused(false);
|
|
3474
3430
|
},
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3431
|
+
style: {
|
|
3432
|
+
flex: 1,
|
|
3433
|
+
minWidth: 0,
|
|
3434
|
+
height: 32,
|
|
3435
|
+
backgroundColor: "rgba(255,255,255,0.05)",
|
|
3436
|
+
border: "1px solid rgba(255,255,255,0.12)",
|
|
3437
|
+
borderRadius: 6,
|
|
3438
|
+
padding: "0 8px",
|
|
3439
|
+
color: "rgba(255,255,255,0.75)",
|
|
3440
|
+
fontSize: 12,
|
|
3441
|
+
fontFamily: "monospace",
|
|
3442
|
+
outline: "none"
|
|
3443
|
+
},
|
|
3444
|
+
className,
|
|
3480
3445
|
...props
|
|
3481
3446
|
}
|
|
3482
3447
|
);
|
|
3483
3448
|
};
|
|
3449
|
+
var ColorPickerHexOutput = ({ className, ...props }) => {
|
|
3450
|
+
const { hue, saturation, lightness } = useColorPicker();
|
|
3451
|
+
const hex = Color.hsl(hue, saturation, lightness).hex();
|
|
3452
|
+
return /* @__PURE__ */ jsxs33("div", { className: cn("flex items-center gap-1.5 px-0.5", className), ...props, children: [
|
|
3453
|
+
/* @__PURE__ */ jsx49("div", { className: "w-5 h-5 rounded border border-white/20 shrink-0", style: { background: `hsl(${hue},${saturation}%,${lightness}%)` } }),
|
|
3454
|
+
/* @__PURE__ */ jsx49("span", { className: "text-xs font-mono text-white/50", children: hex })
|
|
3455
|
+
] });
|
|
3456
|
+
};
|
|
3484
3457
|
|
|
3485
3458
|
// src/components/ui/hsl-color-input.tsx
|
|
3486
3459
|
import { jsx as jsx50, jsxs as jsxs34 } from "react/jsx-runtime";
|