@webdevarif/dashui 0.3.5 → 0.3.6
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 +130 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +129 -80
- 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,7 +3375,7 @@ 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);
|
|
@@ -3520,10 +3523,54 @@ var ColorPickerEyeDropper = ({ className, ...props }) => {
|
|
|
3520
3523
|
}
|
|
3521
3524
|
);
|
|
3522
3525
|
};
|
|
3526
|
+
var ColorPickerOutput = ({ className, ...props }) => {
|
|
3527
|
+
const { mode, setMode } = useColorPicker();
|
|
3528
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
3529
|
+
"select",
|
|
3530
|
+
{
|
|
3531
|
+
value: mode,
|
|
3532
|
+
onChange: (e) => setMode(e.target.value),
|
|
3533
|
+
className: cn(
|
|
3534
|
+
"h-7 bg-white/5 border border-white/10 rounded-md text-xs text-white/60 px-1.5 outline-none",
|
|
3535
|
+
"hover:border-white/20 focus:border-white/30 cursor-pointer shrink-0",
|
|
3536
|
+
className
|
|
3537
|
+
),
|
|
3538
|
+
children: ["HEX", "HSL", "RGB"].map((f) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("option", { value: f, className: "bg-[#1a1c2e]", children: f }, f))
|
|
3539
|
+
}
|
|
3540
|
+
);
|
|
3541
|
+
};
|
|
3542
|
+
var ColorPickerFormat = ({ className, ...props }) => {
|
|
3543
|
+
const { hue, saturation, lightness, alpha, mode } = useColorPicker();
|
|
3544
|
+
let displayValue = "";
|
|
3545
|
+
try {
|
|
3546
|
+
const c = import_color.default.hsl(hue, saturation, lightness).alpha(alpha / 100);
|
|
3547
|
+
if (mode === "HEX") displayValue = c.hex();
|
|
3548
|
+
else if (mode === "HSL") displayValue = `${Math.round(hue)} ${Math.round(saturation)}% ${Math.round(lightness)}%`;
|
|
3549
|
+
else if (mode === "RGB") {
|
|
3550
|
+
const rgb = c.rgb().array().map(Math.round);
|
|
3551
|
+
displayValue = `${rgb[0]}, ${rgb[1]}, ${rgb[2]}`;
|
|
3552
|
+
}
|
|
3553
|
+
} catch {
|
|
3554
|
+
displayValue = "";
|
|
3555
|
+
}
|
|
3556
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
3557
|
+
"input",
|
|
3558
|
+
{
|
|
3559
|
+
readOnly: true,
|
|
3560
|
+
type: "text",
|
|
3561
|
+
value: displayValue,
|
|
3562
|
+
className: cn(
|
|
3563
|
+
"flex-1 h-7 bg-white/5 border border-white/10 rounded-md px-2 text-xs text-white/50 font-mono outline-none",
|
|
3564
|
+
className
|
|
3565
|
+
),
|
|
3566
|
+
...props
|
|
3567
|
+
}
|
|
3568
|
+
);
|
|
3569
|
+
};
|
|
3523
3570
|
|
|
3524
3571
|
// src/components/ui/hsl-color-input.tsx
|
|
3525
3572
|
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
3526
|
-
function
|
|
3573
|
+
function hslToHex(hsl) {
|
|
3527
3574
|
if (!hsl) return "#000000";
|
|
3528
3575
|
try {
|
|
3529
3576
|
const parts = hsl.trim().split(/\s+/);
|
|
@@ -3535,13 +3582,10 @@ function hslStringToHex(hsl) {
|
|
|
3535
3582
|
return "#000000";
|
|
3536
3583
|
}
|
|
3537
3584
|
}
|
|
3538
|
-
function
|
|
3585
|
+
function hexToHsl(hex) {
|
|
3539
3586
|
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}%`;
|
|
3587
|
+
const c = (0, import_color2.default)(hex.startsWith("#") ? hex : `#${hex}`);
|
|
3588
|
+
return `${Math.round(c.hue())} ${Math.round(c.saturationl())}% ${Math.round(c.lightness())}%`;
|
|
3545
3589
|
} catch {
|
|
3546
3590
|
return "0 0% 0%";
|
|
3547
3591
|
}
|
|
@@ -3549,88 +3593,93 @@ function hexToHslString(hex) {
|
|
|
3549
3593
|
function ColorReader({ onHexChange }) {
|
|
3550
3594
|
const { hue, saturation, lightness, alpha } = useColorPicker();
|
|
3551
3595
|
(0, import_react2.useEffect)(() => {
|
|
3552
|
-
|
|
3553
|
-
|
|
3596
|
+
try {
|
|
3597
|
+
const hex = import_color2.default.hsl(hue, saturation, lightness).alpha(alpha / 100).hex();
|
|
3598
|
+
onHexChange(hex);
|
|
3599
|
+
} catch {
|
|
3600
|
+
}
|
|
3554
3601
|
}, [hue, saturation, lightness, alpha, onHexChange]);
|
|
3555
3602
|
return null;
|
|
3556
3603
|
}
|
|
3557
3604
|
function HslColorInput({ value, onChange, className, inputClassName, disabled }) {
|
|
3558
3605
|
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);
|
|
3606
|
+
const hexValue = hslToHex(value);
|
|
3564
3607
|
const cssColor = value ? `hsl(${value})` : "transparent";
|
|
3565
|
-
const
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
onChange
|
|
3608
|
+
const pendingHexRef = (0, import_react2.useRef)(hexValue);
|
|
3609
|
+
const onChangeRef = (0, import_react2.useRef)(onChange);
|
|
3610
|
+
(0, import_react2.useEffect)(() => {
|
|
3611
|
+
onChangeRef.current = onChange;
|
|
3569
3612
|
}, [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",
|
|
3613
|
+
(0, import_react2.useEffect)(() => {
|
|
3614
|
+
if (open) pendingHexRef.current = hexValue;
|
|
3615
|
+
}, [open, hexValue]);
|
|
3616
|
+
const handleHexChange = (0, import_react2.useCallback)((hex) => {
|
|
3617
|
+
pendingHexRef.current = hex;
|
|
3618
|
+
}, []);
|
|
3619
|
+
const handleOpenChange = (0, import_react2.useCallback)((newOpen) => {
|
|
3620
|
+
if (!newOpen && open) {
|
|
3621
|
+
const pending = pendingHexRef.current;
|
|
3622
|
+
if (pending && pending !== hexValue) {
|
|
3623
|
+
onChangeRef.current(hexToHsl(pending));
|
|
3624
|
+
}
|
|
3625
|
+
}
|
|
3626
|
+
setOpen(newOpen);
|
|
3627
|
+
}, [open, hexValue]);
|
|
3628
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Popover2.Root, { open, onOpenChange: disabled ? void 0 : handleOpenChange, children: [
|
|
3629
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Popover2.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
3630
|
+
"button",
|
|
3614
3631
|
{
|
|
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),
|
|
3632
|
+
type: "button",
|
|
3624
3633
|
disabled,
|
|
3625
|
-
placeholder: "H S% L%",
|
|
3626
3634
|
className: cn(
|
|
3627
|
-
"
|
|
3628
|
-
"
|
|
3629
|
-
"
|
|
3630
|
-
|
|
3631
|
-
|
|
3635
|
+
"flex items-center gap-2 px-2 py-1 rounded-lg border border-white/10",
|
|
3636
|
+
"bg-white/5 hover:border-white/20 hover:bg-white/[0.08] transition-colors",
|
|
3637
|
+
"text-xs text-white/60 font-mono min-w-[7.5rem] justify-start",
|
|
3638
|
+
"focus:outline-none focus:border-white/30",
|
|
3639
|
+
disabled && "opacity-50 cursor-not-allowed",
|
|
3640
|
+
className
|
|
3641
|
+
),
|
|
3642
|
+
"aria-label": "Pick color",
|
|
3643
|
+
children: [
|
|
3644
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
3645
|
+
"span",
|
|
3646
|
+
{
|
|
3647
|
+
className: "w-4 h-4 rounded-full border border-white/20 shrink-0 inline-block",
|
|
3648
|
+
style: { background: cssColor }
|
|
3649
|
+
}
|
|
3650
|
+
),
|
|
3651
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: hexValue.toUpperCase() })
|
|
3652
|
+
]
|
|
3632
3653
|
}
|
|
3633
|
-
)
|
|
3654
|
+
) }),
|
|
3655
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Popover2.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
3656
|
+
Popover2.Content,
|
|
3657
|
+
{
|
|
3658
|
+
sideOffset: 6,
|
|
3659
|
+
align: "start",
|
|
3660
|
+
className: cn(
|
|
3661
|
+
"z-[9999] rounded-xl shadow-2xl p-3 w-[14rem]",
|
|
3662
|
+
"bg-[#0f1117] border border-white/10",
|
|
3663
|
+
"focus:outline-none"
|
|
3664
|
+
),
|
|
3665
|
+
onInteractOutside: () => handleOpenChange(false),
|
|
3666
|
+
children: open && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(ColorPicker, { defaultValue: hexValue, className: "gap-2.5", children: [
|
|
3667
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorReader, { onHexChange: handleHexChange }),
|
|
3668
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerSelection, { className: "h-32 w-full rounded-lg" }),
|
|
3669
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
3670
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerEyeDropper, {}),
|
|
3671
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex flex-col gap-1.5 flex-1", children: [
|
|
3672
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerHue, {}),
|
|
3673
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerAlpha, {})
|
|
3674
|
+
] })
|
|
3675
|
+
] }),
|
|
3676
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
3677
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerOutput, {}),
|
|
3678
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ColorPickerFormat, {})
|
|
3679
|
+
] })
|
|
3680
|
+
] }, hexValue)
|
|
3681
|
+
}
|
|
3682
|
+
) })
|
|
3634
3683
|
] });
|
|
3635
3684
|
}
|
|
3636
3685
|
|
|
@@ -3998,8 +4047,10 @@ var import_next_themes2 = require("next-themes");
|
|
|
3998
4047
|
ColorPicker,
|
|
3999
4048
|
ColorPickerAlpha,
|
|
4000
4049
|
ColorPickerEyeDropper,
|
|
4050
|
+
ColorPickerFormat,
|
|
4001
4051
|
ColorPickerHexOutput,
|
|
4002
4052
|
ColorPickerHue,
|
|
4053
|
+
ColorPickerOutput,
|
|
4003
4054
|
ColorPickerSelection,
|
|
4004
4055
|
ConfirmDialog,
|
|
4005
4056
|
DashboardLayout,
|