@webdevarif/dashui 0.3.5 → 0.3.7
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 +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +137 -82
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +136 -83
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -556,6 +556,8 @@ interface ColorPickerContextValue {
|
|
|
556
556
|
setSaturation: (s: number) => void;
|
|
557
557
|
setLightness: (l: number) => void;
|
|
558
558
|
setAlpha: (a: number) => void;
|
|
559
|
+
mode: string;
|
|
560
|
+
setMode: (mode: string) => void;
|
|
559
561
|
}
|
|
560
562
|
declare const useColorPicker: () => ColorPickerContextValue;
|
|
561
563
|
type ColorPickerProps = HTMLAttributes<HTMLDivElement> & {
|
|
@@ -568,6 +570,10 @@ declare const ColorPickerHue: ({ className, ...props }: Omit<ComponentProps<type
|
|
|
568
570
|
declare const ColorPickerAlpha: ({ className, ...props }: Omit<ComponentProps<typeof Slider.Root>, "value" | "onValueChange" | "max" | "step">) => react_jsx_runtime.JSX.Element;
|
|
569
571
|
declare const ColorPickerHexOutput: ({ className, ...props }: HTMLAttributes<HTMLDivElement>) => react_jsx_runtime.JSX.Element;
|
|
570
572
|
declare const ColorPickerEyeDropper: ({ className, ...props }: HTMLAttributes<HTMLButtonElement>) => react_jsx_runtime.JSX.Element;
|
|
573
|
+
type ColorPickerOutputProps = HTMLAttributes<HTMLDivElement>;
|
|
574
|
+
declare const ColorPickerOutput: ({ className, ...props }: ColorPickerOutputProps) => react_jsx_runtime.JSX.Element;
|
|
575
|
+
type ColorPickerFormatProps = HTMLAttributes<HTMLDivElement>;
|
|
576
|
+
declare const ColorPickerFormat: ({ className, ...props }: ColorPickerFormatProps) => react_jsx_runtime.JSX.Element;
|
|
571
577
|
|
|
572
578
|
declare function useDisclosure(initial?: boolean): {
|
|
573
579
|
isOpen: boolean;
|
|
@@ -653,4 +659,4 @@ interface SkeletonProps {
|
|
|
653
659
|
}
|
|
654
660
|
declare function Skeleton({ width, height, rounded, style }: SkeletonProps): react_jsx_runtime.JSX.Element;
|
|
655
661
|
|
|
656
|
-
export { Alert, type AlertProps, AppShell, type AppShellProps, AuthButton, AuthCard, AuthDivider, AuthField, AuthFootnote, AuthHeader, AuthLogo, AuthShell, Badge, type BadgeProps, type Breadcrumb, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, ColorPicker, ColorPickerAlpha, ColorPickerEyeDropper, ColorPickerHexOutput, ColorPickerHue, ColorPickerSelection, type Column, ConfirmDialog, type ConfirmDialogProps, DashboardLayout, type DashboardLayoutProps, DataTable, type DataTableProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, type EmptyStateProps, FormField, type FormFieldProps, FormLayout, type FormLayoutProps, FormSection, type FormSectionProps, HslColorInput, ImagePickerField, type ImagePickerFieldProps, Input, type InputProps, Label, LoadingSpinner, type LoadingSpinnerProps, MediaCard, type MediaCardFile, type MediaCardProps, MediaGrid, type MediaGridProps, MediaPickerDialog, type MediaPickerDialogFolder, type MediaPickerDialogProps, type NavItem, NotificationBell, type NotificationBellProps, Page, type PageProps, PageSection, type PageSectionProps, Pagination, type PaginationProps, PlanBadge, type PlanBadgeProps, type PlanId, Popover, PopoverContent, PopoverTrigger, PostEditorShell, type PostEditorShellProps, PostFiltersBar, type PostFiltersBarProps, type PostListItem, PostListTable, type PostListTableProps, PostSidebarSection, type PostSidebarSectionProps, type PostStatus, PostStatusBadge, type PostStatusBadgeProps, SearchBar, type SearchBarProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sidebar, type SidebarItem, type SidebarProps, Skeleton, SlugInput, type SlugInputProps, type Stat, Stats, type StatsProps, StorageBar, type StorageBarProps, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, type TextareaProps, ThemeToggle, type ThemeToggleProps, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TopBar, type TopBarProps, type UploadItem, badgeVariants, buttonVariants, cn, useColorPicker, useDisclosure, usePagination };
|
|
662
|
+
export { Alert, type AlertProps, AppShell, type AppShellProps, AuthButton, AuthCard, AuthDivider, AuthField, AuthFootnote, AuthHeader, AuthLogo, AuthShell, Badge, type BadgeProps, type Breadcrumb, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, ColorPicker, ColorPickerAlpha, ColorPickerEyeDropper, ColorPickerFormat, ColorPickerHexOutput, ColorPickerHue, ColorPickerOutput, ColorPickerSelection, type Column, ConfirmDialog, type ConfirmDialogProps, DashboardLayout, type DashboardLayoutProps, DataTable, type DataTableProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, type EmptyStateProps, FormField, type FormFieldProps, FormLayout, type FormLayoutProps, FormSection, type FormSectionProps, HslColorInput, ImagePickerField, type ImagePickerFieldProps, Input, type InputProps, Label, LoadingSpinner, type LoadingSpinnerProps, MediaCard, type MediaCardFile, type MediaCardProps, MediaGrid, type MediaGridProps, MediaPickerDialog, type MediaPickerDialogFolder, type MediaPickerDialogProps, type NavItem, NotificationBell, type NotificationBellProps, Page, type PageProps, PageSection, type PageSectionProps, Pagination, type PaginationProps, PlanBadge, type PlanBadgeProps, type PlanId, Popover, PopoverContent, PopoverTrigger, PostEditorShell, type PostEditorShellProps, PostFiltersBar, type PostFiltersBarProps, type PostListItem, PostListTable, type PostListTableProps, PostSidebarSection, type PostSidebarSectionProps, type PostStatus, PostStatusBadge, type PostStatusBadgeProps, SearchBar, type SearchBarProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sidebar, type SidebarItem, type SidebarProps, Skeleton, SlugInput, type SlugInputProps, type Stat, Stats, type StatsProps, StorageBar, type StorageBarProps, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, type TextareaProps, ThemeToggle, type ThemeToggleProps, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TopBar, type TopBarProps, type UploadItem, badgeVariants, buttonVariants, cn, useColorPicker, useDisclosure, usePagination };
|
package/dist/index.d.ts
CHANGED
|
@@ -556,6 +556,8 @@ interface ColorPickerContextValue {
|
|
|
556
556
|
setSaturation: (s: number) => void;
|
|
557
557
|
setLightness: (l: number) => void;
|
|
558
558
|
setAlpha: (a: number) => void;
|
|
559
|
+
mode: string;
|
|
560
|
+
setMode: (mode: string) => void;
|
|
559
561
|
}
|
|
560
562
|
declare const useColorPicker: () => ColorPickerContextValue;
|
|
561
563
|
type ColorPickerProps = HTMLAttributes<HTMLDivElement> & {
|
|
@@ -568,6 +570,10 @@ declare const ColorPickerHue: ({ className, ...props }: Omit<ComponentProps<type
|
|
|
568
570
|
declare const ColorPickerAlpha: ({ className, ...props }: Omit<ComponentProps<typeof Slider.Root>, "value" | "onValueChange" | "max" | "step">) => react_jsx_runtime.JSX.Element;
|
|
569
571
|
declare const ColorPickerHexOutput: ({ className, ...props }: HTMLAttributes<HTMLDivElement>) => react_jsx_runtime.JSX.Element;
|
|
570
572
|
declare const ColorPickerEyeDropper: ({ className, ...props }: HTMLAttributes<HTMLButtonElement>) => react_jsx_runtime.JSX.Element;
|
|
573
|
+
type ColorPickerOutputProps = HTMLAttributes<HTMLDivElement>;
|
|
574
|
+
declare const ColorPickerOutput: ({ className, ...props }: ColorPickerOutputProps) => react_jsx_runtime.JSX.Element;
|
|
575
|
+
type ColorPickerFormatProps = HTMLAttributes<HTMLDivElement>;
|
|
576
|
+
declare const ColorPickerFormat: ({ className, ...props }: ColorPickerFormatProps) => react_jsx_runtime.JSX.Element;
|
|
571
577
|
|
|
572
578
|
declare function useDisclosure(initial?: boolean): {
|
|
573
579
|
isOpen: boolean;
|
|
@@ -653,4 +659,4 @@ interface SkeletonProps {
|
|
|
653
659
|
}
|
|
654
660
|
declare function Skeleton({ width, height, rounded, style }: SkeletonProps): react_jsx_runtime.JSX.Element;
|
|
655
661
|
|
|
656
|
-
export { Alert, type AlertProps, AppShell, type AppShellProps, AuthButton, AuthCard, AuthDivider, AuthField, AuthFootnote, AuthHeader, AuthLogo, AuthShell, Badge, type BadgeProps, type Breadcrumb, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, ColorPicker, ColorPickerAlpha, ColorPickerEyeDropper, ColorPickerHexOutput, ColorPickerHue, ColorPickerSelection, type Column, ConfirmDialog, type ConfirmDialogProps, DashboardLayout, type DashboardLayoutProps, DataTable, type DataTableProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, type EmptyStateProps, FormField, type FormFieldProps, FormLayout, type FormLayoutProps, FormSection, type FormSectionProps, HslColorInput, ImagePickerField, type ImagePickerFieldProps, Input, type InputProps, Label, LoadingSpinner, type LoadingSpinnerProps, MediaCard, type MediaCardFile, type MediaCardProps, MediaGrid, type MediaGridProps, MediaPickerDialog, type MediaPickerDialogFolder, type MediaPickerDialogProps, type NavItem, NotificationBell, type NotificationBellProps, Page, type PageProps, PageSection, type PageSectionProps, Pagination, type PaginationProps, PlanBadge, type PlanBadgeProps, type PlanId, Popover, PopoverContent, PopoverTrigger, PostEditorShell, type PostEditorShellProps, PostFiltersBar, type PostFiltersBarProps, type PostListItem, PostListTable, type PostListTableProps, PostSidebarSection, type PostSidebarSectionProps, type PostStatus, PostStatusBadge, type PostStatusBadgeProps, SearchBar, type SearchBarProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sidebar, type SidebarItem, type SidebarProps, Skeleton, SlugInput, type SlugInputProps, type Stat, Stats, type StatsProps, StorageBar, type StorageBarProps, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, type TextareaProps, ThemeToggle, type ThemeToggleProps, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TopBar, type TopBarProps, type UploadItem, badgeVariants, buttonVariants, cn, useColorPicker, useDisclosure, usePagination };
|
|
662
|
+
export { Alert, type AlertProps, AppShell, type AppShellProps, AuthButton, AuthCard, AuthDivider, AuthField, AuthFootnote, AuthHeader, AuthLogo, AuthShell, Badge, type BadgeProps, type Breadcrumb, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, ColorPicker, ColorPickerAlpha, ColorPickerEyeDropper, ColorPickerFormat, ColorPickerHexOutput, ColorPickerHue, ColorPickerOutput, ColorPickerSelection, type Column, ConfirmDialog, type ConfirmDialogProps, DashboardLayout, type DashboardLayoutProps, DataTable, type DataTableProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, type EmptyStateProps, FormField, type FormFieldProps, FormLayout, type FormLayoutProps, FormSection, type FormSectionProps, HslColorInput, ImagePickerField, type ImagePickerFieldProps, Input, type InputProps, Label, LoadingSpinner, type LoadingSpinnerProps, MediaCard, type MediaCardFile, type MediaCardProps, MediaGrid, type MediaGridProps, MediaPickerDialog, type MediaPickerDialogFolder, type MediaPickerDialogProps, type NavItem, NotificationBell, type NotificationBellProps, Page, type PageProps, PageSection, type PageSectionProps, Pagination, type PaginationProps, PlanBadge, type PlanBadgeProps, type PlanId, Popover, PopoverContent, PopoverTrigger, PostEditorShell, type PostEditorShellProps, PostFiltersBar, type PostFiltersBarProps, type PostListItem, PostListTable, type PostListTableProps, PostSidebarSection, type PostSidebarSectionProps, type PostStatus, PostStatusBadge, type PostStatusBadgeProps, SearchBar, type SearchBarProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sidebar, type SidebarItem, type SidebarProps, Skeleton, SlugInput, type SlugInputProps, type Stat, Stats, type StatsProps, StorageBar, type StorageBarProps, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, type TextareaProps, ThemeToggle, type ThemeToggleProps, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TopBar, type TopBarProps, type UploadItem, badgeVariants, buttonVariants, cn, useColorPicker, useDisclosure, usePagination };
|
package/dist/index.js
CHANGED
|
@@ -52,8 +52,10 @@ __export(index_exports, {
|
|
|
52
52
|
ColorPicker: () => ColorPicker,
|
|
53
53
|
ColorPickerAlpha: () => ColorPickerAlpha,
|
|
54
54
|
ColorPickerEyeDropper: () => ColorPickerEyeDropper,
|
|
55
|
+
ColorPickerFormat: () => ColorPickerFormat,
|
|
55
56
|
ColorPickerHexOutput: () => ColorPickerHexOutput,
|
|
56
57
|
ColorPickerHue: () => ColorPickerHue,
|
|
58
|
+
ColorPickerOutput: () => ColorPickerOutput,
|
|
57
59
|
ColorPickerSelection: () => ColorPickerSelection,
|
|
58
60
|
ConfirmDialog: () => ConfirmDialog,
|
|
59
61
|
DashboardLayout: () => DashboardLayout,
|
|
@@ -3348,6 +3350,7 @@ var ColorPicker = ({
|
|
|
3348
3350
|
const [saturation, setSaturationState] = (0, import_react.useState)(initial.saturationl());
|
|
3349
3351
|
const [lightness, setLightnessState] = (0, import_react.useState)(initial.lightness());
|
|
3350
3352
|
const [alpha, setAlphaState] = (0, import_react.useState)(initial.alpha() * 100);
|
|
3353
|
+
const [mode, setMode] = (0, import_react.useState)("HEX");
|
|
3351
3354
|
const notifyRef = (0, import_react.useRef)(onChange);
|
|
3352
3355
|
(0, import_react.useEffect)(() => {
|
|
3353
3356
|
notifyRef.current = onChange;
|
|
@@ -3372,14 +3375,18 @@ var ColorPicker = ({
|
|
|
3372
3375
|
setAlphaState(a);
|
|
3373
3376
|
notify(hue, saturation, lightness, a);
|
|
3374
3377
|
}, [hue, saturation, lightness, notify]);
|
|
3375
|
-
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(ColorPickerContext.Provider, { value: { hue, saturation, lightness, alpha, setHue, setSaturation, setLightness, setAlpha }, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: cn("flex flex-col gap-3", className), ...props, children }) });
|
|
3378
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(ColorPickerContext.Provider, { value: { hue, saturation, lightness, alpha, setHue, setSaturation, setLightness, setAlpha, mode, setMode }, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: cn("flex flex-col gap-3", className), ...props, children }) });
|
|
3376
3379
|
};
|
|
3377
3380
|
var ColorPickerSelection = (0, import_react.memo)(({ className, ...props }) => {
|
|
3378
3381
|
const containerRef = (0, import_react.useRef)(null);
|
|
3379
3382
|
const [isDragging, setIsDragging] = (0, import_react.useState)(false);
|
|
3380
|
-
const
|
|
3381
|
-
const [
|
|
3382
|
-
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
|
+
});
|
|
3383
3390
|
const bg = (0, import_react.useMemo)(
|
|
3384
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%)`,
|
|
3385
3392
|
[hue]
|
|
@@ -3520,10 +3527,54 @@ var ColorPickerEyeDropper = ({ className, ...props }) => {
|
|
|
3520
3527
|
}
|
|
3521
3528
|
);
|
|
3522
3529
|
};
|
|
3530
|
+
var ColorPickerOutput = ({ className, ...props }) => {
|
|
3531
|
+
const { mode, setMode } = useColorPicker();
|
|
3532
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
3533
|
+
"select",
|
|
3534
|
+
{
|
|
3535
|
+
value: mode,
|
|
3536
|
+
onChange: (e) => setMode(e.target.value),
|
|
3537
|
+
className: cn(
|
|
3538
|
+
"h-7 bg-white/5 border border-white/10 rounded-md text-xs text-white/60 px-1.5 outline-none",
|
|
3539
|
+
"hover:border-white/20 focus:border-white/30 cursor-pointer shrink-0",
|
|
3540
|
+
className
|
|
3541
|
+
),
|
|
3542
|
+
children: ["HEX", "HSL", "RGB"].map((f) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("option", { value: f, className: "bg-[#1a1c2e]", children: f }, f))
|
|
3543
|
+
}
|
|
3544
|
+
);
|
|
3545
|
+
};
|
|
3546
|
+
var ColorPickerFormat = ({ className, ...props }) => {
|
|
3547
|
+
const { hue, saturation, lightness, alpha, mode } = useColorPicker();
|
|
3548
|
+
let displayValue = "";
|
|
3549
|
+
try {
|
|
3550
|
+
const c = import_color.default.hsl(hue, saturation, lightness).alpha(alpha / 100);
|
|
3551
|
+
if (mode === "HEX") displayValue = c.hex();
|
|
3552
|
+
else if (mode === "HSL") displayValue = `${Math.round(hue)} ${Math.round(saturation)}% ${Math.round(lightness)}%`;
|
|
3553
|
+
else if (mode === "RGB") {
|
|
3554
|
+
const rgb = c.rgb().array().map(Math.round);
|
|
3555
|
+
displayValue = `${rgb[0]}, ${rgb[1]}, ${rgb[2]}`;
|
|
3556
|
+
}
|
|
3557
|
+
} catch {
|
|
3558
|
+
displayValue = "";
|
|
3559
|
+
}
|
|
3560
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
3561
|
+
"input",
|
|
3562
|
+
{
|
|
3563
|
+
readOnly: true,
|
|
3564
|
+
type: "text",
|
|
3565
|
+
value: displayValue,
|
|
3566
|
+
className: cn(
|
|
3567
|
+
"flex-1 h-7 bg-white/5 border border-white/10 rounded-md px-2 text-xs text-white/50 font-mono outline-none",
|
|
3568
|
+
className
|
|
3569
|
+
),
|
|
3570
|
+
...props
|
|
3571
|
+
}
|
|
3572
|
+
);
|
|
3573
|
+
};
|
|
3523
3574
|
|
|
3524
3575
|
// src/components/ui/hsl-color-input.tsx
|
|
3525
3576
|
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
3526
|
-
function
|
|
3577
|
+
function hslToHex(hsl) {
|
|
3527
3578
|
if (!hsl) return "#000000";
|
|
3528
3579
|
try {
|
|
3529
3580
|
const parts = hsl.trim().split(/\s+/);
|
|
@@ -3535,13 +3586,10 @@ function hslStringToHex(hsl) {
|
|
|
3535
3586
|
return "#000000";
|
|
3536
3587
|
}
|
|
3537
3588
|
}
|
|
3538
|
-
function
|
|
3589
|
+
function hexToHsl(hex) {
|
|
3539
3590
|
try {
|
|
3540
|
-
const c = (0, import_color2.default)(hex);
|
|
3541
|
-
|
|
3542
|
-
const s = Math.round(c.saturationl());
|
|
3543
|
-
const l = Math.round(c.lightness());
|
|
3544
|
-
return `${h} ${s}% ${l}%`;
|
|
3591
|
+
const c = (0, import_color2.default)(hex.startsWith("#") ? hex : `#${hex}`);
|
|
3592
|
+
return `${Math.round(c.hue())} ${Math.round(c.saturationl())}% ${Math.round(c.lightness())}%`;
|
|
3545
3593
|
} catch {
|
|
3546
3594
|
return "0 0% 0%";
|
|
3547
3595
|
}
|
|
@@ -3549,88 +3597,93 @@ function hexToHslString(hex) {
|
|
|
3549
3597
|
function ColorReader({ onHexChange }) {
|
|
3550
3598
|
const { hue, saturation, lightness, alpha } = useColorPicker();
|
|
3551
3599
|
(0, import_react2.useEffect)(() => {
|
|
3552
|
-
|
|
3553
|
-
|
|
3600
|
+
try {
|
|
3601
|
+
const hex = import_color2.default.hsl(hue, saturation, lightness).alpha(alpha / 100).hex();
|
|
3602
|
+
onHexChange(hex);
|
|
3603
|
+
} catch {
|
|
3604
|
+
}
|
|
3554
3605
|
}, [hue, saturation, lightness, alpha, onHexChange]);
|
|
3555
3606
|
return null;
|
|
3556
3607
|
}
|
|
3557
3608
|
function HslColorInput({ value, onChange, className, inputClassName, disabled }) {
|
|
3558
3609
|
const [open, setOpen] = (0, import_react2.useState)(false);
|
|
3559
|
-
const
|
|
3560
|
-
(0, import_react2.useEffect)(() => {
|
|
3561
|
-
setInputVal(value);
|
|
3562
|
-
}, [value]);
|
|
3563
|
-
const hexValue = hslStringToHex(value);
|
|
3610
|
+
const hexValue = hslToHex(value);
|
|
3564
3611
|
const cssColor = value ? `hsl(${value})` : "transparent";
|
|
3565
|
-
const
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
onChange
|
|
3612
|
+
const pendingHexRef = (0, import_react2.useRef)(hexValue);
|
|
3613
|
+
const onChangeRef = (0, import_react2.useRef)(onChange);
|
|
3614
|
+
(0, import_react2.useEffect)(() => {
|
|
3615
|
+
onChangeRef.current = onChange;
|
|
3569
3616
|
}, [onChange]);
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
{
|
|
3589
|
-
sideOffset: 8,
|
|
3590
|
-
align: "start",
|
|
3591
|
-
className: cn(
|
|
3592
|
-
"z-[9999] rounded-xl shadow-2xl p-3 w-[220px]",
|
|
3593
|
-
"bg-[#1a1c2e] border border-white/10",
|
|
3594
|
-
"focus:outline-none"
|
|
3595
|
-
),
|
|
3596
|
-
onInteractOutside: () => setOpen(false),
|
|
3597
|
-
children: open && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(ColorPicker, { defaultValue: hexValue, children: [
|
|
3598
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorReader, { onHexChange: handlePickerHex }),
|
|
3599
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerSelection, { className: "h-36 rounded-lg" }),
|
|
3600
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3601
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerEyeDropper, {}),
|
|
3602
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex flex-col gap-1.5 flex-1", children: [
|
|
3603
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerHue, {}),
|
|
3604
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerAlpha, {})
|
|
3605
|
-
] })
|
|
3606
|
-
] }),
|
|
3607
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerHexOutput, {})
|
|
3608
|
-
] })
|
|
3609
|
-
}
|
|
3610
|
-
) })
|
|
3611
|
-
] }),
|
|
3612
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
3613
|
-
"input",
|
|
3617
|
+
(0, import_react2.useEffect)(() => {
|
|
3618
|
+
if (open) pendingHexRef.current = hexValue;
|
|
3619
|
+
}, [open, hexValue]);
|
|
3620
|
+
const handleHexChange = (0, import_react2.useCallback)((hex) => {
|
|
3621
|
+
pendingHexRef.current = hex;
|
|
3622
|
+
}, []);
|
|
3623
|
+
const handleOpenChange = (0, import_react2.useCallback)((newOpen) => {
|
|
3624
|
+
if (!newOpen && open) {
|
|
3625
|
+
const pending = pendingHexRef.current;
|
|
3626
|
+
if (pending && pending !== hexValue) {
|
|
3627
|
+
onChangeRef.current(hexToHsl(pending));
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
setOpen(newOpen);
|
|
3631
|
+
}, [open, hexValue]);
|
|
3632
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Popover2.Root, { open, onOpenChange: disabled ? void 0 : handleOpenChange, children: [
|
|
3633
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Popover2.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
3634
|
+
"button",
|
|
3614
3635
|
{
|
|
3615
|
-
type: "
|
|
3616
|
-
value: inputVal,
|
|
3617
|
-
onChange: (e) => {
|
|
3618
|
-
setInputVal(e.target.value);
|
|
3619
|
-
if (/^\d+(\.\d+)?\s+\d+(\.\d+)?%\s+\d+(\.\d+)?%$/.test(e.target.value.trim())) {
|
|
3620
|
-
onChange(e.target.value.trim());
|
|
3621
|
-
}
|
|
3622
|
-
},
|
|
3623
|
-
onBlur: () => setInputVal(value),
|
|
3636
|
+
type: "button",
|
|
3624
3637
|
disabled,
|
|
3625
|
-
placeholder: "H S% L%",
|
|
3626
3638
|
className: cn(
|
|
3627
|
-
"
|
|
3628
|
-
"
|
|
3629
|
-
"
|
|
3630
|
-
|
|
3631
|
-
|
|
3639
|
+
"flex items-center gap-2 px-2 py-1 rounded-lg border border-white/10",
|
|
3640
|
+
"bg-white/5 hover:border-white/20 hover:bg-white/[0.08] transition-colors",
|
|
3641
|
+
"text-xs text-white/60 font-mono min-w-[7.5rem] justify-start",
|
|
3642
|
+
"focus:outline-none focus:border-white/30",
|
|
3643
|
+
disabled && "opacity-50 cursor-not-allowed",
|
|
3644
|
+
className
|
|
3645
|
+
),
|
|
3646
|
+
"aria-label": "Pick color",
|
|
3647
|
+
children: [
|
|
3648
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
3649
|
+
"span",
|
|
3650
|
+
{
|
|
3651
|
+
className: "w-4 h-4 rounded-full border border-white/20 shrink-0 inline-block",
|
|
3652
|
+
style: { background: cssColor }
|
|
3653
|
+
}
|
|
3654
|
+
),
|
|
3655
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: hexValue.toUpperCase() })
|
|
3656
|
+
]
|
|
3632
3657
|
}
|
|
3633
|
-
)
|
|
3658
|
+
) }),
|
|
3659
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Popover2.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
3660
|
+
Popover2.Content,
|
|
3661
|
+
{
|
|
3662
|
+
sideOffset: 6,
|
|
3663
|
+
align: "start",
|
|
3664
|
+
className: cn(
|
|
3665
|
+
"z-[9999] rounded-xl shadow-2xl p-3 w-[14rem]",
|
|
3666
|
+
"bg-[#0f1117] border border-white/10",
|
|
3667
|
+
"focus:outline-none"
|
|
3668
|
+
),
|
|
3669
|
+
onInteractOutside: () => handleOpenChange(false),
|
|
3670
|
+
children: open && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(ColorPicker, { defaultValue: hexValue, className: "gap-2.5", children: [
|
|
3671
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorReader, { onHexChange: handleHexChange }),
|
|
3672
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerSelection, { className: "h-32 w-full rounded-lg" }),
|
|
3673
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
3674
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerEyeDropper, {}),
|
|
3675
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex flex-col gap-1.5 flex-1", children: [
|
|
3676
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerHue, {}),
|
|
3677
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerAlpha, {})
|
|
3678
|
+
] })
|
|
3679
|
+
] }),
|
|
3680
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
3681
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerOutput, {}),
|
|
3682
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerFormat, {})
|
|
3683
|
+
] })
|
|
3684
|
+
] }, hexValue)
|
|
3685
|
+
}
|
|
3686
|
+
) })
|
|
3634
3687
|
] });
|
|
3635
3688
|
}
|
|
3636
3689
|
|
|
@@ -3998,8 +4051,10 @@ var import_next_themes2 = require("next-themes");
|
|
|
3998
4051
|
ColorPicker,
|
|
3999
4052
|
ColorPickerAlpha,
|
|
4000
4053
|
ColorPickerEyeDropper,
|
|
4054
|
+
ColorPickerFormat,
|
|
4001
4055
|
ColorPickerHexOutput,
|
|
4002
4056
|
ColorPickerHue,
|
|
4057
|
+
ColorPickerOutput,
|
|
4003
4058
|
ColorPickerSelection,
|
|
4004
4059
|
ConfirmDialog,
|
|
4005
4060
|
DashboardLayout,
|