@hyunsdev/ui 0.1.0
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/LICENSE +674 -0
- package/README.md +89 -0
- package/SKILL.md +38 -0
- package/dist/WindowContext-DybYtZJa.d.ts +50 -0
- package/dist/_styles-BbTx89aX.d.ts +3 -0
- package/dist/chunk-23KUNTRD.js +49 -0
- package/dist/chunk-23KUNTRD.js.map +1 -0
- package/dist/chunk-3RTSANKB.js +51 -0
- package/dist/chunk-3RTSANKB.js.map +1 -0
- package/dist/chunk-4QIWBOF4.js +129 -0
- package/dist/chunk-4QIWBOF4.js.map +1 -0
- package/dist/chunk-5JCWC7IU.js +293 -0
- package/dist/chunk-5JCWC7IU.js.map +1 -0
- package/dist/chunk-6ANDNGHD.js +33 -0
- package/dist/chunk-6ANDNGHD.js.map +1 -0
- package/dist/chunk-7W7QZHEZ.js +42 -0
- package/dist/chunk-7W7QZHEZ.js.map +1 -0
- package/dist/chunk-BHO4WT2N.js +51 -0
- package/dist/chunk-BHO4WT2N.js.map +1 -0
- package/dist/chunk-BI3KKBIC.js +11 -0
- package/dist/chunk-BI3KKBIC.js.map +1 -0
- package/dist/chunk-D3SP7GL3.js +55 -0
- package/dist/chunk-D3SP7GL3.js.map +1 -0
- package/dist/chunk-D7W4RSQX.js +115 -0
- package/dist/chunk-D7W4RSQX.js.map +1 -0
- package/dist/chunk-DN2AEEA2.js +11 -0
- package/dist/chunk-DN2AEEA2.js.map +1 -0
- package/dist/chunk-ETTKFCO6.js +84 -0
- package/dist/chunk-ETTKFCO6.js.map +1 -0
- package/dist/chunk-GJT7TDBS.js +66 -0
- package/dist/chunk-GJT7TDBS.js.map +1 -0
- package/dist/chunk-HZT6RQYZ.js +109 -0
- package/dist/chunk-HZT6RQYZ.js.map +1 -0
- package/dist/chunk-JB2QZV7K.js +60 -0
- package/dist/chunk-JB2QZV7K.js.map +1 -0
- package/dist/chunk-KJJB2PVC.js +21 -0
- package/dist/chunk-KJJB2PVC.js.map +1 -0
- package/dist/chunk-NE3IVPMO.js +31 -0
- package/dist/chunk-NE3IVPMO.js.map +1 -0
- package/dist/chunk-O2BG2KSY.js +23 -0
- package/dist/chunk-O2BG2KSY.js.map +1 -0
- package/dist/chunk-OUFGNJ3V.js +1726 -0
- package/dist/chunk-OUFGNJ3V.js.map +1 -0
- package/dist/chunk-PLZMCJSL.js +351 -0
- package/dist/chunk-PLZMCJSL.js.map +1 -0
- package/dist/chunk-POG5DZBT.js +104 -0
- package/dist/chunk-POG5DZBT.js.map +1 -0
- package/dist/chunk-SECZM6JE.js +170 -0
- package/dist/chunk-SECZM6JE.js.map +1 -0
- package/dist/chunk-T64WPXSC.js +48 -0
- package/dist/chunk-T64WPXSC.js.map +1 -0
- package/dist/chunk-TU5CYBB4.js +90 -0
- package/dist/chunk-TU5CYBB4.js.map +1 -0
- package/dist/chunk-UVAI2U6X.js +153 -0
- package/dist/chunk-UVAI2U6X.js.map +1 -0
- package/dist/chunk-UXCBLYG6.js +142 -0
- package/dist/chunk-UXCBLYG6.js.map +1 -0
- package/dist/chunk-VUR4MQMH.js +53 -0
- package/dist/chunk-VUR4MQMH.js.map +1 -0
- package/dist/chunk-WIEKNG4S.js +26 -0
- package/dist/chunk-WIEKNG4S.js.map +1 -0
- package/dist/chunk-WIZ4OLOB.js +23 -0
- package/dist/chunk-WIZ4OLOB.js.map +1 -0
- package/dist/chunk-WJRJBMFN.js +21 -0
- package/dist/chunk-WJRJBMFN.js.map +1 -0
- package/dist/chunk-YUPLJP3F.js +33 -0
- package/dist/chunk-YUPLJP3F.js.map +1 -0
- package/dist/chunk-Z7ITPSUF.js +184 -0
- package/dist/chunk-Z7ITPSUF.js.map +1 -0
- package/dist/chunk-ZC76ALSI.js +75 -0
- package/dist/chunk-ZC76ALSI.js.map +1 -0
- package/dist/code-block-core-xkE94Rk5.d.ts +30 -0
- package/dist/components/accordion.d.ts +9 -0
- package/dist/components/accordion.js +98 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/alert-dialog.d.ts +26 -0
- package/dist/components/alert-dialog.js +341 -0
- package/dist/components/alert-dialog.js.map +1 -0
- package/dist/components/alert.d.ts +13 -0
- package/dist/components/alert.js +76 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/aspect-ratio.d.ts +6 -0
- package/dist/components/aspect-ratio.js +12 -0
- package/dist/components/aspect-ratio.js.map +1 -0
- package/dist/components/avatar.d.ts +13 -0
- package/dist/components/avatar.js +19 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +11 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/breadcrumb.d.ts +13 -0
- package/dist/components/breadcrumb.js +102 -0
- package/dist/components/breadcrumb.js.map +1 -0
- package/dist/components/button-group.d.ts +16 -0
- package/dist/components/button-group.js +15 -0
- package/dist/components/button-group.js.map +1 -0
- package/dist/components/button.d.ts +14 -0
- package/dist/components/button.js +11 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/calendar.d.ts +14 -0
- package/dist/components/calendar.js +13 -0
- package/dist/components/calendar.js.map +1 -0
- package/dist/components/card.d.ts +13 -0
- package/dist/components/card.js +21 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/carousel.d.ts +32 -0
- package/dist/components/carousel.js +196 -0
- package/dist/components/carousel.js.map +1 -0
- package/dist/components/chart.d.ts +46 -0
- package/dist/components/chart.js +254 -0
- package/dist/components/chart.js.map +1 -0
- package/dist/components/checkbox.d.ts +6 -0
- package/dist/components/checkbox.js +41 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/code-block-core.d.ts +3 -0
- package/dist/components/code-block-core.js +13 -0
- package/dist/components/code-block-core.js.map +1 -0
- package/dist/components/code-block-custom.d.ts +20 -0
- package/dist/components/code-block-custom.js +16 -0
- package/dist/components/code-block-custom.js.map +1 -0
- package/dist/components/code-block-shiki.d.ts +13 -0
- package/dist/components/code-block-shiki.js +15 -0
- package/dist/components/code-block-shiki.js.map +1 -0
- package/dist/components/code-block.d.ts +5 -0
- package/dist/components/code-block.js +14 -0
- package/dist/components/code-block.js.map +1 -0
- package/dist/components/collapsible.d.ts +8 -0
- package/dist/components/collapsible.js +24 -0
- package/dist/components/collapsible.js.map +1 -0
- package/dist/components/collection.d.ts +63 -0
- package/dist/components/collection.js +598 -0
- package/dist/components/collection.js.map +1 -0
- package/dist/components/color-dot.d.ts +19 -0
- package/dist/components/color-dot.js +41 -0
- package/dist/components/color-dot.js.map +1 -0
- package/dist/components/color-picker.d.ts +12 -0
- package/dist/components/color-picker.js +142 -0
- package/dist/components/color-picker.js.map +1 -0
- package/dist/components/combobox.d.ts +74 -0
- package/dist/components/combobox.js +610 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/command.d.ts +21 -0
- package/dist/components/command.js +31 -0
- package/dist/components/command.js.map +1 -0
- package/dist/components/date-picker.d.ts +43 -0
- package/dist/components/date-picker.js +235 -0
- package/dist/components/date-picker.js.map +1 -0
- package/dist/components/dialog.d.ts +25 -0
- package/dist/components/dialog.js +31 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/drawer.d.ts +15 -0
- package/dist/components/drawer.js +124 -0
- package/dist/components/drawer.js.map +1 -0
- package/dist/components/dropdown-menu.d.ts +34 -0
- package/dist/components/dropdown-menu.js +248 -0
- package/dist/components/dropdown-menu.js.map +1 -0
- package/dist/components/empty.d.ts +15 -0
- package/dist/components/empty.js +104 -0
- package/dist/components/empty.js.map +1 -0
- package/dist/components/field.d.ts +29 -0
- package/dist/components/field.js +214 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/format-bytes.d.ts +12 -0
- package/dist/components/format-bytes.js +30 -0
- package/dist/components/format-bytes.js.map +1 -0
- package/dist/components/format-number.d.ts +12 -0
- package/dist/components/format-number.js +30 -0
- package/dist/components/format-number.js.map +1 -0
- package/dist/components/gauge.d.ts +11 -0
- package/dist/components/gauge.js +82 -0
- package/dist/components/gauge.js.map +1 -0
- package/dist/components/hover-card.d.ts +8 -0
- package/dist/components/hover-card.js +45 -0
- package/dist/components/hover-card.js.map +1 -0
- package/dist/components/input-group.d.ts +24 -0
- package/dist/components/input-group.js +23 -0
- package/dist/components/input-group.js.map +1 -0
- package/dist/components/input-otp.d.ts +20 -0
- package/dist/components/input-otp.js +95 -0
- package/dist/components/input-otp.js.map +1 -0
- package/dist/components/input.d.ts +9 -0
- package/dist/components/input.js +9 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/item.d.ts +27 -0
- package/dist/components/item.js +182 -0
- package/dist/components/item.js.map +1 -0
- package/dist/components/kbd.d.ts +6 -0
- package/dist/components/kbd.js +34 -0
- package/dist/components/kbd.js.map +1 -0
- package/dist/components/label.d.ts +6 -0
- package/dist/components/label.js +9 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/loading-bar.d.ts +8 -0
- package/dist/components/loading-bar.js +127 -0
- package/dist/components/loading-bar.js.map +1 -0
- package/dist/components/loading-dots.d.ts +5 -0
- package/dist/components/loading-dots.js +45 -0
- package/dist/components/loading-dots.js.map +1 -0
- package/dist/components/main-provider.d.ts +7 -0
- package/dist/components/main-provider.js +12 -0
- package/dist/components/main-provider.js.map +1 -0
- package/dist/components/mark.d.ts +11 -0
- package/dist/components/mark.js +44 -0
- package/dist/components/mark.js.map +1 -0
- package/dist/components/pagination.d.ts +21 -0
- package/dist/components/pagination.js +114 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/popover.d.ts +12 -0
- package/dist/components/popover.js +22 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/prev-next-navigation.d.ts +15 -0
- package/dist/components/prev-next-navigation.js +85 -0
- package/dist/components/prev-next-navigation.js.map +1 -0
- package/dist/components/progress.d.ts +6 -0
- package/dist/components/progress.js +38 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/radio-group.d.ts +7 -0
- package/dist/components/radio-group.js +57 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/relative-time.d.ts +16 -0
- package/dist/components/relative-time.js +75 -0
- package/dist/components/relative-time.js.map +1 -0
- package/dist/components/resizable.d.ts +10 -0
- package/dist/components/resizable.js +45 -0
- package/dist/components/resizable.js.map +1 -0
- package/dist/components/scroll-area.d.ts +7 -0
- package/dist/components/scroll-area.js +11 -0
- package/dist/components/scroll-area.js.map +1 -0
- package/dist/components/select.d.ts +20 -0
- package/dist/components/select.js +189 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/separator.d.ts +6 -0
- package/dist/components/separator.js +9 -0
- package/dist/components/separator.js.map +1 -0
- package/dist/components/sheet.d.ts +16 -0
- package/dist/components/sheet.js +25 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/show-more.d.ts +15 -0
- package/dist/components/show-more.js +79 -0
- package/dist/components/show-more.js.map +1 -0
- package/dist/components/skeleton.d.ts +5 -0
- package/dist/components/skeleton.js +8 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/slider.d.ts +6 -0
- package/dist/components/slider.js +65 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/components/snippet.d.ts +13 -0
- package/dist/components/snippet.js +135 -0
- package/dist/components/snippet.js.map +1 -0
- package/dist/components/sonner.d.ts +6 -0
- package/dist/components/sonner.js +10 -0
- package/dist/components/sonner.js.map +1 -0
- package/dist/components/spinner.d.ts +5 -0
- package/dist/components/spinner.js +8 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/stat.d.ts +17 -0
- package/dist/components/stat.js +71 -0
- package/dist/components/stat.js.map +1 -0
- package/dist/components/steps.d.ts +17 -0
- package/dist/components/steps.js +133 -0
- package/dist/components/steps.js.map +1 -0
- package/dist/components/switch.d.ts +8 -0
- package/dist/components/switch.js +44 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/table.d.ts +12 -0
- package/dist/components/table.js +101 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.d.ts +14 -0
- package/dist/components/tabs.js +88 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/textarea.d.ts +5 -0
- package/dist/components/textarea.js +9 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/theme-provider.d.ts +10 -0
- package/dist/components/theme-provider.js +14 -0
- package/dist/components/theme-provider.js.map +1 -0
- package/dist/components/time-picker.d.ts +17 -0
- package/dist/components/time-picker.js +219 -0
- package/dist/components/time-picker.js.map +1 -0
- package/dist/components/timeline.d.ts +17 -0
- package/dist/components/timeline.js +138 -0
- package/dist/components/timeline.js.map +1 -0
- package/dist/components/toggle-group.d.ts +14 -0
- package/dist/components/toggle-group.js +82 -0
- package/dist/components/toggle-group.js.map +1 -0
- package/dist/components/toggle.d.ts +12 -0
- package/dist/components/toggle.js +11 -0
- package/dist/components/toggle.js.map +1 -0
- package/dist/components/tooltip.d.ts +9 -0
- package/dist/components/tooltip.js +15 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/components/typography.d.ts +17 -0
- package/dist/components/typography.js +91 -0
- package/dist/components/typography.js.map +1 -0
- package/dist/hooks/use-mobile.d.ts +3 -0
- package/dist/hooks/use-mobile.js +7 -0
- package/dist/hooks/use-mobile.js.map +1 -0
- package/dist/hooks/use-theme.d.ts +3 -0
- package/dist/hooks/use-theme.js +8 -0
- package/dist/hooks/use-theme.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts/center/index.d.ts +18 -0
- package/dist/layouts/center/index.js +73 -0
- package/dist/layouts/center/index.js.map +1 -0
- package/dist/layouts/chat/index.d.ts +42 -0
- package/dist/layouts/chat/index.js +191 -0
- package/dist/layouts/chat/index.js.map +1 -0
- package/dist/layouts/command/index.d.ts +2 -0
- package/dist/layouts/command/index.js +1 -0
- package/dist/layouts/command/index.js.map +1 -0
- package/dist/layouts/panel/index.d.ts +55 -0
- package/dist/layouts/panel/index.js +513 -0
- package/dist/layouts/panel/index.js.map +1 -0
- package/dist/layouts/presentation/index.d.ts +14 -0
- package/dist/layouts/presentation/index.js +100 -0
- package/dist/layouts/presentation/index.js.map +1 -0
- package/dist/layouts/site/index.d.ts +17 -0
- package/dist/layouts/site/index.js +82 -0
- package/dist/layouts/site/index.js.map +1 -0
- package/dist/layouts/window/index.d.ts +223 -0
- package/dist/layouts/window/index.js +127 -0
- package/dist/layouts/window/index.js.map +1 -0
- package/dist/layouts/workbench/index.d.ts +281 -0
- package/dist/layouts/workbench/index.js +2457 -0
- package/dist/layouts/workbench/index.js.map +1 -0
- package/dist/lib/format.d.ts +15 -0
- package/dist/lib/format.js +9 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/theme.d.ts +22 -0
- package/dist/lib/theme.js +25 -0
- package/dist/lib/theme.js.map +1 -0
- package/dist/lib/utils.d.ts +5 -0
- package/dist/lib/utils.js +7 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/styles/fonts.css +1 -0
- package/dist/styles/globals.css +717 -0
- package/dist/styles/tokens.css +693 -0
- package/package.json +137 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn
|
|
3
|
+
} from "../chunk-DN2AEEA2.js";
|
|
4
|
+
|
|
5
|
+
// src/components/color-dot.tsx
|
|
6
|
+
import "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
var colorDotColors = {
|
|
9
|
+
accent: "text-text-accent",
|
|
10
|
+
"on-accent": "text-text-on-accent",
|
|
11
|
+
normal: "text-text-normal",
|
|
12
|
+
muted: "text-text-muted",
|
|
13
|
+
faint: "text-text-faint",
|
|
14
|
+
info: "text-text-info",
|
|
15
|
+
success: "text-text-success",
|
|
16
|
+
warning: "text-text-warning",
|
|
17
|
+
error: "text-text-error"
|
|
18
|
+
};
|
|
19
|
+
function ColorDot({
|
|
20
|
+
className,
|
|
21
|
+
color = "normal",
|
|
22
|
+
...props
|
|
23
|
+
}) {
|
|
24
|
+
return /* @__PURE__ */ jsx(
|
|
25
|
+
"span",
|
|
26
|
+
{
|
|
27
|
+
"data-slot": "color-dot",
|
|
28
|
+
"data-color": color,
|
|
29
|
+
className: cn(
|
|
30
|
+
"inline-block size-2.5 shrink-0 rounded-full bg-current",
|
|
31
|
+
colorDotColors[color],
|
|
32
|
+
className
|
|
33
|
+
),
|
|
34
|
+
...props
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
ColorDot
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=color-dot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/color-dot.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { cn } from \"@hyunsdev/ui/lib/utils\"\n\nconst colorDotColors = {\n accent: \"text-text-accent\",\n \"on-accent\": \"text-text-on-accent\",\n normal: \"text-text-normal\",\n muted: \"text-text-muted\",\n faint: \"text-text-faint\",\n info: \"text-text-info\",\n success: \"text-text-success\",\n warning: \"text-text-warning\",\n error: \"text-text-error\",\n} as const\n\ntype ColorDotColor = keyof typeof colorDotColors\n\nfunction ColorDot({\n className,\n color = \"normal\",\n ...props\n}: React.ComponentProps<\"span\"> & { color?: ColorDotColor }) {\n return (\n <span\n data-slot=\"color-dot\"\n data-color={color}\n className={cn(\n \"inline-block size-2.5 shrink-0 rounded-full bg-current\",\n colorDotColors[color],\n className,\n )}\n {...props}\n />\n )\n}\n\nexport { ColorDot, type ColorDotColor }\n"],"mappings":";;;;;AAAA,OAAuB;AAwBnB;AApBJ,IAAM,iBAAiB;AAAA,EACrB,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AAAA,EACP,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACT;AAIA,SAAS,SAAS;AAAA,EAChB;AAAA,EACA,QAAQ;AAAA,EACR,GAAG;AACL,GAA6D;AAC3D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,cAAY;AAAA,MACZ,WAAW;AAAA,QACT;AAAA,QACA,eAAe,KAAK;AAAA,QACpB;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { F as FieldControlSize } from '../_styles-BbTx89aX.js';
|
|
3
|
+
|
|
4
|
+
type ColorPickerProps = Omit<React.ComponentProps<"input">, "defaultValue" | "onChange" | "size" | "type" | "value"> & {
|
|
5
|
+
value?: string;
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
onValueChange?: (value: string) => void;
|
|
8
|
+
size?: FieldControlSize;
|
|
9
|
+
};
|
|
10
|
+
declare function ColorPicker({ className, value, defaultValue, onValueChange, onBlur, disabled, id, readOnly, size, ...props }: ColorPickerProps): React.JSX.Element;
|
|
11
|
+
|
|
12
|
+
export { ColorPicker, type ColorPickerProps };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
InputGroup,
|
|
4
|
+
InputGroupAddon,
|
|
5
|
+
InputGroupInput
|
|
6
|
+
} from "../chunk-UVAI2U6X.js";
|
|
7
|
+
import "../chunk-NE3IVPMO.js";
|
|
8
|
+
import "../chunk-YUPLJP3F.js";
|
|
9
|
+
import "../chunk-TU5CYBB4.js";
|
|
10
|
+
import "../chunk-O2BG2KSY.js";
|
|
11
|
+
import {
|
|
12
|
+
cn
|
|
13
|
+
} from "../chunk-DN2AEEA2.js";
|
|
14
|
+
|
|
15
|
+
// src/components/color-picker.tsx
|
|
16
|
+
import * as React from "react";
|
|
17
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
var DEFAULT_COLOR_PICKER_VALUE = "#000000";
|
|
19
|
+
var HEX_COLOR_PATTERN = /^#[0-9a-fA-F]{6}$/;
|
|
20
|
+
function normalizeHexColor(value) {
|
|
21
|
+
if (!value) {
|
|
22
|
+
return void 0;
|
|
23
|
+
}
|
|
24
|
+
const trimmedValue = value.trim();
|
|
25
|
+
if (!HEX_COLOR_PATTERN.test(trimmedValue)) {
|
|
26
|
+
return void 0;
|
|
27
|
+
}
|
|
28
|
+
return trimmedValue.toLowerCase();
|
|
29
|
+
}
|
|
30
|
+
function ColorPicker({
|
|
31
|
+
className,
|
|
32
|
+
value,
|
|
33
|
+
defaultValue,
|
|
34
|
+
onValueChange,
|
|
35
|
+
onBlur,
|
|
36
|
+
disabled,
|
|
37
|
+
id,
|
|
38
|
+
readOnly,
|
|
39
|
+
size = "default",
|
|
40
|
+
...props
|
|
41
|
+
}) {
|
|
42
|
+
const inputId = React.useId();
|
|
43
|
+
const colorInputId = React.useId();
|
|
44
|
+
const isControlled = value !== void 0;
|
|
45
|
+
const [internalValue, setInternalValue] = React.useState(
|
|
46
|
+
normalizeHexColor(defaultValue) ?? DEFAULT_COLOR_PICKER_VALUE
|
|
47
|
+
);
|
|
48
|
+
const committedValue = normalizeHexColor(isControlled ? value : internalValue) ?? DEFAULT_COLOR_PICKER_VALUE;
|
|
49
|
+
const [draftValue, setDraftValue] = React.useState(committedValue);
|
|
50
|
+
React.useEffect(() => {
|
|
51
|
+
setDraftValue(committedValue);
|
|
52
|
+
}, [committedValue]);
|
|
53
|
+
function updateValue(nextValue) {
|
|
54
|
+
if (readOnly) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const normalizedValue = normalizeHexColor(nextValue);
|
|
58
|
+
if (!normalizedValue) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
setDraftValue(normalizedValue);
|
|
62
|
+
if (!isControlled) {
|
|
63
|
+
setInternalValue(normalizedValue);
|
|
64
|
+
}
|
|
65
|
+
if (normalizedValue !== committedValue) {
|
|
66
|
+
onValueChange?.(normalizedValue);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return /* @__PURE__ */ jsxs(
|
|
70
|
+
InputGroup,
|
|
71
|
+
{
|
|
72
|
+
"data-slot": "color-picker",
|
|
73
|
+
"data-disabled": disabled || void 0,
|
|
74
|
+
size,
|
|
75
|
+
className,
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ jsx(InputGroupAddon, { align: "inline-start", className: "cursor-pointer pl-1.5", children: /* @__PURE__ */ jsxs(
|
|
78
|
+
"span",
|
|
79
|
+
{
|
|
80
|
+
"data-slot": "color-picker-swatch",
|
|
81
|
+
className: cn(
|
|
82
|
+
"border-border has-[:focus-visible]:ring-focus-ring relative block size-5 overflow-hidden rounded-[min(var(--radius-sm),6px)] border bg-[linear-gradient(45deg,var(--color-background-secondary)_25%,transparent_25%),linear-gradient(-45deg,var(--color-background-secondary)_25%,transparent_25%),linear-gradient(45deg,transparent_75%,var(--color-background-secondary)_75%),linear-gradient(-45deg,transparent_75%,var(--color-background-secondary)_75%)] bg-[length:8px_8px] bg-[position:0_0,0_4px,4px_-4px,-4px_0] group-data-[size=sm]/input-group:size-4.5 has-[:focus-visible]:ring-3",
|
|
83
|
+
disabled && "opacity-50"
|
|
84
|
+
),
|
|
85
|
+
children: [
|
|
86
|
+
/* @__PURE__ */ jsx(
|
|
87
|
+
"span",
|
|
88
|
+
{
|
|
89
|
+
"aria-hidden": "true",
|
|
90
|
+
className: "absolute inset-0",
|
|
91
|
+
style: { backgroundColor: committedValue }
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
/* @__PURE__ */ jsx(
|
|
95
|
+
"input",
|
|
96
|
+
{
|
|
97
|
+
id: `${id ?? colorInputId}-native`,
|
|
98
|
+
type: "color",
|
|
99
|
+
value: committedValue,
|
|
100
|
+
disabled: disabled || readOnly,
|
|
101
|
+
"aria-label": "Select color",
|
|
102
|
+
className: "absolute inset-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed",
|
|
103
|
+
onChange: (event) => updateValue(event.target.value)
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
) }),
|
|
109
|
+
/* @__PURE__ */ jsx(
|
|
110
|
+
InputGroupInput,
|
|
111
|
+
{
|
|
112
|
+
...props,
|
|
113
|
+
id: id ?? inputId,
|
|
114
|
+
type: "text",
|
|
115
|
+
value: draftValue,
|
|
116
|
+
disabled,
|
|
117
|
+
readOnly,
|
|
118
|
+
spellCheck: false,
|
|
119
|
+
autoCapitalize: "none",
|
|
120
|
+
autoComplete: "off",
|
|
121
|
+
inputMode: "text",
|
|
122
|
+
pattern: "#[0-9a-fA-F]{6}",
|
|
123
|
+
onChange: (event) => {
|
|
124
|
+
const nextValue = event.target.value;
|
|
125
|
+
setDraftValue(nextValue);
|
|
126
|
+
updateValue(nextValue);
|
|
127
|
+
},
|
|
128
|
+
onBlur: (event) => {
|
|
129
|
+
setDraftValue(committedValue);
|
|
130
|
+
onBlur?.(event);
|
|
131
|
+
},
|
|
132
|
+
className: "font-mono uppercase placeholder:normal-case"
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
export {
|
|
140
|
+
ColorPicker
|
|
141
|
+
};
|
|
142
|
+
//# sourceMappingURL=color-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/color-picker.tsx"],"sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\n\nimport { InputGroup, InputGroupAddon, InputGroupInput } from \"@hyunsdev/ui/components/input-group\"\nimport { cn } from \"@hyunsdev/ui/lib/utils\"\n\nimport type { FieldControlSize } from \"./_styles\"\n\nconst DEFAULT_COLOR_PICKER_VALUE = \"#000000\"\nconst HEX_COLOR_PATTERN = /^#[0-9a-fA-F]{6}$/\n\ntype ColorPickerProps = Omit<\n React.ComponentProps<\"input\">,\n \"defaultValue\" | \"onChange\" | \"size\" | \"type\" | \"value\"\n> & {\n value?: string\n defaultValue?: string\n onValueChange?: (value: string) => void\n size?: FieldControlSize\n}\n\nfunction normalizeHexColor(value: string | undefined) {\n if (!value) {\n return undefined\n }\n\n const trimmedValue = value.trim()\n\n if (!HEX_COLOR_PATTERN.test(trimmedValue)) {\n return undefined\n }\n\n return trimmedValue.toLowerCase()\n}\n\nfunction ColorPicker({\n className,\n value,\n defaultValue,\n onValueChange,\n onBlur,\n disabled,\n id,\n readOnly,\n size = \"default\",\n ...props\n}: ColorPickerProps) {\n const inputId = React.useId()\n const colorInputId = React.useId()\n const isControlled = value !== undefined\n const [internalValue, setInternalValue] = React.useState(\n normalizeHexColor(defaultValue) ?? DEFAULT_COLOR_PICKER_VALUE,\n )\n const committedValue =\n normalizeHexColor(isControlled ? value : internalValue) ?? DEFAULT_COLOR_PICKER_VALUE\n const [draftValue, setDraftValue] = React.useState(committedValue)\n\n React.useEffect(() => {\n setDraftValue(committedValue)\n }, [committedValue])\n\n function updateValue(nextValue: string) {\n if (readOnly) {\n return\n }\n\n const normalizedValue = normalizeHexColor(nextValue)\n\n if (!normalizedValue) {\n return\n }\n\n setDraftValue(normalizedValue)\n\n if (!isControlled) {\n setInternalValue(normalizedValue)\n }\n\n if (normalizedValue !== committedValue) {\n onValueChange?.(normalizedValue)\n }\n }\n\n return (\n <InputGroup\n data-slot=\"color-picker\"\n data-disabled={disabled || undefined}\n size={size}\n className={className}\n >\n <InputGroupAddon align=\"inline-start\" className=\"cursor-pointer pl-1.5\">\n <span\n data-slot=\"color-picker-swatch\"\n className={cn(\n \"border-border has-[:focus-visible]:ring-focus-ring relative block size-5 overflow-hidden rounded-[min(var(--radius-sm),6px)] border bg-[linear-gradient(45deg,var(--color-background-secondary)_25%,transparent_25%),linear-gradient(-45deg,var(--color-background-secondary)_25%,transparent_25%),linear-gradient(45deg,transparent_75%,var(--color-background-secondary)_75%),linear-gradient(-45deg,transparent_75%,var(--color-background-secondary)_75%)] bg-[length:8px_8px] bg-[position:0_0,0_4px,4px_-4px,-4px_0] group-data-[size=sm]/input-group:size-4.5 has-[:focus-visible]:ring-3\",\n disabled && \"opacity-50\",\n )}\n >\n <span\n aria-hidden=\"true\"\n className=\"absolute inset-0\"\n style={{ backgroundColor: committedValue }}\n />\n <input\n id={`${id ?? colorInputId}-native`}\n type=\"color\"\n value={committedValue}\n disabled={disabled || readOnly}\n aria-label=\"Select color\"\n className=\"absolute inset-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed\"\n onChange={(event) => updateValue(event.target.value)}\n />\n </span>\n </InputGroupAddon>\n <InputGroupInput\n {...props}\n id={id ?? inputId}\n type=\"text\"\n value={draftValue}\n disabled={disabled}\n readOnly={readOnly}\n spellCheck={false}\n autoCapitalize=\"none\"\n autoComplete=\"off\"\n inputMode=\"text\"\n pattern=\"#[0-9a-fA-F]{6}\"\n onChange={(event) => {\n const nextValue = event.target.value\n\n setDraftValue(nextValue)\n updateValue(nextValue)\n }}\n onBlur={(event) => {\n setDraftValue(committedValue)\n onBlur?.(event)\n }}\n className=\"font-mono uppercase placeholder:normal-case\"\n />\n </InputGroup>\n )\n}\n\nexport { ColorPicker, type ColorPickerProps }\n"],"mappings":";;;;;;;;;;;;;;;AAEA,YAAY,WAAW;AA0Ff,SAOE,KAPF;AAnFR,IAAM,6BAA6B;AACnC,IAAM,oBAAoB;AAY1B,SAAS,kBAAkB,OAA2B;AACpD,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,QAAM,eAAe,MAAM,KAAK;AAEhC,MAAI,CAAC,kBAAkB,KAAK,YAAY,GAAG;AACzC,WAAO;AAAA,EACT;AAEA,SAAO,aAAa,YAAY;AAClC;AAEA,SAAS,YAAY;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,GAAG;AACL,GAAqB;AACnB,QAAM,UAAgB,YAAM;AAC5B,QAAM,eAAqB,YAAM;AACjC,QAAM,eAAe,UAAU;AAC/B,QAAM,CAAC,eAAe,gBAAgB,IAAU;AAAA,IAC9C,kBAAkB,YAAY,KAAK;AAAA,EACrC;AACA,QAAM,iBACJ,kBAAkB,eAAe,QAAQ,aAAa,KAAK;AAC7D,QAAM,CAAC,YAAY,aAAa,IAAU,eAAS,cAAc;AAEjE,EAAM,gBAAU,MAAM;AACpB,kBAAc,cAAc;AAAA,EAC9B,GAAG,CAAC,cAAc,CAAC;AAEnB,WAAS,YAAY,WAAmB;AACtC,QAAI,UAAU;AACZ;AAAA,IACF;AAEA,UAAM,kBAAkB,kBAAkB,SAAS;AAEnD,QAAI,CAAC,iBAAiB;AACpB;AAAA,IACF;AAEA,kBAAc,eAAe;AAE7B,QAAI,CAAC,cAAc;AACjB,uBAAiB,eAAe;AAAA,IAClC;AAEA,QAAI,oBAAoB,gBAAgB;AACtC,sBAAgB,eAAe;AAAA,IACjC;AAAA,EACF;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,iBAAe,YAAY;AAAA,MAC3B;AAAA,MACA;AAAA,MAEA;AAAA,4BAAC,mBAAgB,OAAM,gBAAe,WAAU,yBAC9C;AAAA,UAAC;AAAA;AAAA,YACC,aAAU;AAAA,YACV,WAAW;AAAA,cACT;AAAA,cACA,YAAY;AAAA,YACd;AAAA,YAEA;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACC,eAAY;AAAA,kBACZ,WAAU;AAAA,kBACV,OAAO,EAAE,iBAAiB,eAAe;AAAA;AAAA,cAC3C;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACC,IAAI,GAAG,MAAM,YAAY;AAAA,kBACzB,MAAK;AAAA,kBACL,OAAO;AAAA,kBACP,UAAU,YAAY;AAAA,kBACtB,cAAW;AAAA,kBACX,WAAU;AAAA,kBACV,UAAU,CAAC,UAAU,YAAY,MAAM,OAAO,KAAK;AAAA;AAAA,cACrD;AAAA;AAAA;AAAA,QACF,GACF;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACE,GAAG;AAAA,YACJ,IAAI,MAAM;AAAA,YACV,MAAK;AAAA,YACL,OAAO;AAAA,YACP;AAAA,YACA;AAAA,YACA,YAAY;AAAA,YACZ,gBAAe;AAAA,YACf,cAAa;AAAA,YACb,WAAU;AAAA,YACV,SAAQ;AAAA,YACR,UAAU,CAAC,UAAU;AACnB,oBAAM,YAAY,MAAM,OAAO;AAE/B,4BAAc,SAAS;AACvB,0BAAY,SAAS;AAAA,YACvB;AAAA,YACA,QAAQ,CAAC,UAAU;AACjB,4BAAc,cAAc;AAC5B,uBAAS,KAAK;AAAA,YAChB;AAAA,YACA,WAAU;AAAA;AAAA,QACZ;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Command } from 'cmdk';
|
|
3
|
+
import { Badge } from './badge.js';
|
|
4
|
+
import { CommandGroup, CommandItem, CommandList } from './command.js';
|
|
5
|
+
import { PopoverContent } from './popover.js';
|
|
6
|
+
import 'class-variance-authority/types';
|
|
7
|
+
import 'class-variance-authority';
|
|
8
|
+
import './dialog.js';
|
|
9
|
+
import '@radix-ui/react-dialog';
|
|
10
|
+
import '@radix-ui/react-popover';
|
|
11
|
+
|
|
12
|
+
type ComboboxOption = {
|
|
13
|
+
value: string;
|
|
14
|
+
label: string;
|
|
15
|
+
keywords?: readonly string[];
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
group?: string | undefined;
|
|
18
|
+
};
|
|
19
|
+
type ComboboxSharedProps = {
|
|
20
|
+
options: readonly ComboboxOption[];
|
|
21
|
+
query?: string | undefined;
|
|
22
|
+
defaultQuery?: string | undefined;
|
|
23
|
+
onQueryChange?: (query: string) => void;
|
|
24
|
+
open?: boolean | undefined;
|
|
25
|
+
defaultOpen?: boolean | undefined;
|
|
26
|
+
onOpenChange?: (open: boolean) => void;
|
|
27
|
+
creatable?: boolean;
|
|
28
|
+
loading?: boolean;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
invalid?: boolean;
|
|
31
|
+
placeholder?: string;
|
|
32
|
+
emptyMessage?: React.ReactNode;
|
|
33
|
+
loadingMessage?: React.ReactNode;
|
|
34
|
+
createLabel?: (query: string) => React.ReactNode;
|
|
35
|
+
onCreateOption?: (query: string) => void;
|
|
36
|
+
id?: string;
|
|
37
|
+
className?: string;
|
|
38
|
+
children?: React.ReactNode;
|
|
39
|
+
};
|
|
40
|
+
type SingleComboboxProps = ComboboxSharedProps & {
|
|
41
|
+
multiple?: false;
|
|
42
|
+
value?: string | undefined;
|
|
43
|
+
defaultValue?: string | undefined;
|
|
44
|
+
onValueChange?: (value: string | undefined) => void;
|
|
45
|
+
};
|
|
46
|
+
type MultiComboboxProps = ComboboxSharedProps & {
|
|
47
|
+
multiple: true;
|
|
48
|
+
value?: string[] | undefined;
|
|
49
|
+
defaultValue?: string[] | undefined;
|
|
50
|
+
onValueChange?: (value: string[]) => void;
|
|
51
|
+
};
|
|
52
|
+
type ComboboxProps = SingleComboboxProps | MultiComboboxProps;
|
|
53
|
+
declare function Combobox(props: ComboboxProps & Omit<React.ComponentProps<"div">, keyof ComboboxProps>): React.JSX.Element;
|
|
54
|
+
declare function ComboboxTrigger({ className, children, leadingIcon, ...props }: React.ComponentProps<"div"> & {
|
|
55
|
+
leadingIcon?: React.ReactNode;
|
|
56
|
+
}): React.JSX.Element;
|
|
57
|
+
declare function ComboboxInput({ className, onFocus, onKeyDown, ...props }: Omit<React.ComponentProps<typeof Command.Input>, "value" | "onValueChange" | "disabled" | "placeholder">): React.JSX.Element;
|
|
58
|
+
declare function ComboboxContent({ className, style, children, onOpenAutoFocus, ...props }: React.ComponentProps<typeof PopoverContent>): React.JSX.Element;
|
|
59
|
+
declare function ComboboxList({ className, children, ...props }: React.ComponentProps<typeof CommandList>): React.JSX.Element;
|
|
60
|
+
declare function ComboboxGroup({ className, children, ...props }: React.ComponentProps<typeof CommandGroup>): React.JSX.Element;
|
|
61
|
+
declare function ComboboxItem({ option, className, children, ...props }: Omit<React.ComponentProps<typeof CommandItem>, "value" | "onSelect"> & {
|
|
62
|
+
option: ComboboxOption;
|
|
63
|
+
}): React.JSX.Element;
|
|
64
|
+
declare function ComboboxEmpty({ className, children, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
65
|
+
declare function ComboboxLoading({ className, children, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
66
|
+
declare function ComboboxTags({ className, children, ...props }: React.ComponentProps<"div">): React.JSX.Element | null;
|
|
67
|
+
declare function ComboboxTag({ option, className, children, ...props }: React.ComponentProps<typeof Badge> & {
|
|
68
|
+
option: ComboboxOption;
|
|
69
|
+
}): React.JSX.Element;
|
|
70
|
+
declare function ComboboxClear({ className, children, ...props }: Omit<React.ComponentProps<"button">, "children"> & {
|
|
71
|
+
children?: React.ReactNode;
|
|
72
|
+
}): React.JSX.Element | null;
|
|
73
|
+
|
|
74
|
+
export { Combobox, ComboboxClear, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxList, ComboboxLoading, type ComboboxOption, type ComboboxProps, ComboboxTag, ComboboxTags, ComboboxTrigger };
|