@hex-core/components 1.3.1 → 1.5.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.
Files changed (222) hide show
  1. package/README.md +183 -9
  2. package/dist/_tsup-dts-rollup.d.ts +3105 -0
  3. package/dist/accordion.d.ts +4 -0
  4. package/dist/accordion.js +62 -0
  5. package/dist/accordion.js.map +1 -0
  6. package/dist/alert-dialog.d.ts +11 -0
  7. package/dist/alert-dialog.js +125 -0
  8. package/dist/alert-dialog.js.map +1 -0
  9. package/dist/alert.d.ts +4 -0
  10. package/dist/alert.js +54 -0
  11. package/dist/alert.js.map +1 -0
  12. package/dist/aspect-ratio.d.ts +1 -0
  13. package/dist/aspect-ratio.js +8 -0
  14. package/dist/aspect-ratio.js.map +1 -0
  15. package/dist/avatar.d.ts +3 -0
  16. package/dist/avatar.js +44 -0
  17. package/dist/avatar.js.map +1 -0
  18. package/dist/badge.d.ts +3 -0
  19. package/dist/badge.js +36 -0
  20. package/dist/badge.js.map +1 -0
  21. package/dist/breadcrumb.d.ts +7 -0
  22. package/dist/breadcrumb.js +120 -0
  23. package/dist/breadcrumb.js.map +1 -0
  24. package/dist/button.d.ts +3 -0
  25. package/dist/button.js +113 -0
  26. package/dist/button.js.map +1 -0
  27. package/dist/calendar.d.ts +1 -0
  28. package/dist/calendar.js +126 -0
  29. package/dist/calendar.js.map +1 -0
  30. package/dist/card.d.ts +6 -0
  31. package/dist/card.js +68 -0
  32. package/dist/card.js.map +1 -0
  33. package/dist/checkbox.d.ts +2 -0
  34. package/dist/checkbox.js +65 -0
  35. package/dist/checkbox.js.map +1 -0
  36. package/dist/citation.d.ts +2 -0
  37. package/dist/citation.js +70 -0
  38. package/dist/citation.js.map +1 -0
  39. package/dist/cluster.d.ts +3 -0
  40. package/dist/cluster.js +50 -0
  41. package/dist/cluster.js.map +1 -0
  42. package/dist/code-block-copy.d.ts +2 -0
  43. package/dist/code-block-copy.js +108 -0
  44. package/dist/code-block-copy.js.map +1 -0
  45. package/dist/code-block.d.ts +3 -0
  46. package/dist/code-block.js +90 -0
  47. package/dist/code-block.js.map +1 -0
  48. package/dist/collapsible.d.ts +3 -0
  49. package/dist/collapsible.js +10 -0
  50. package/dist/collapsible.js.map +1 -0
  51. package/dist/color-picker.d.ts +2 -0
  52. package/dist/color-picker.js +321 -0
  53. package/dist/color-picker.js.map +1 -0
  54. package/dist/combobox.d.ts +3 -0
  55. package/dist/combobox.js +226 -0
  56. package/dist/combobox.js.map +1 -0
  57. package/dist/command.d.ts +9 -0
  58. package/dist/command.js +232 -0
  59. package/dist/command.js.map +1 -0
  60. package/dist/composer.d.ts +2 -0
  61. package/dist/composer.js +75 -0
  62. package/dist/composer.js.map +1 -0
  63. package/dist/container.d.ts +3 -0
  64. package/dist/container.js +39 -0
  65. package/dist/container.js.map +1 -0
  66. package/dist/context-menu.d.ts +12 -0
  67. package/dist/context-menu.js +130 -0
  68. package/dist/context-menu.js.map +1 -0
  69. package/dist/data-table.d.ts +2 -0
  70. package/dist/data-table.js +103 -0
  71. package/dist/data-table.js.map +1 -0
  72. package/dist/date-picker.d.ts +2 -0
  73. package/dist/date-picker.js +221 -0
  74. package/dist/date-picker.js.map +1 -0
  75. package/dist/dialog.d.ts +11 -0
  76. package/dist/dialog.js +125 -0
  77. package/dist/dialog.js.map +1 -0
  78. package/dist/drawer.d.ts +10 -0
  79. package/dist/drawer.js +82 -0
  80. package/dist/drawer.js.map +1 -0
  81. package/dist/dropdown-menu.d.ts +13 -0
  82. package/dist/dropdown-menu.js +133 -0
  83. package/dist/dropdown-menu.js.map +1 -0
  84. package/dist/dropzone.d.ts +3 -0
  85. package/dist/dropzone.js +194 -0
  86. package/dist/dropzone.js.map +1 -0
  87. package/dist/file-tree.d.ts +3 -0
  88. package/dist/file-tree.js +322 -0
  89. package/dist/file-tree.js.map +1 -0
  90. package/dist/form.d.ts +8 -0
  91. package/dist/form.js +114 -0
  92. package/dist/form.js.map +1 -0
  93. package/dist/grid.d.ts +3 -0
  94. package/dist/grid.js +58 -0
  95. package/dist/grid.js.map +1 -0
  96. package/dist/hover-card.d.ts +3 -0
  97. package/dist/hover-card.js +34 -0
  98. package/dist/hover-card.js.map +1 -0
  99. package/dist/index.d.ts +298 -1652
  100. package/dist/index.js +1157 -5493
  101. package/dist/index.js.map +1 -1
  102. package/dist/input-otp.d.ts +5 -0
  103. package/dist/input-otp.js +71 -0
  104. package/dist/input-otp.js.map +1 -0
  105. package/dist/input.d.ts +2 -0
  106. package/dist/input.js +40 -0
  107. package/dist/input.js.map +1 -0
  108. package/dist/label.d.ts +2 -0
  109. package/dist/label.js +22 -0
  110. package/dist/label.js.map +1 -0
  111. package/dist/loading-indicator.d.ts +3 -0
  112. package/dist/loading-indicator.js +64 -0
  113. package/dist/loading-indicator.js.map +1 -0
  114. package/dist/markdown.d.ts +2 -0
  115. package/dist/markdown.js +28 -0
  116. package/dist/markdown.js.map +1 -0
  117. package/dist/menubar.d.ts +11 -0
  118. package/dist/menubar.js +106 -0
  119. package/dist/menubar.js.map +1 -0
  120. package/dist/message-actions.d.ts +2 -0
  121. package/dist/message-actions.js +28 -0
  122. package/dist/message-actions.js.map +1 -0
  123. package/dist/message-list.d.ts +2 -0
  124. package/dist/message-list.js +49 -0
  125. package/dist/message-list.js.map +1 -0
  126. package/dist/message.d.ts +3 -0
  127. package/dist/message.js +35 -0
  128. package/dist/message.js.map +1 -0
  129. package/dist/multi-combobox.d.ts +3 -0
  130. package/dist/multi-combobox.js +258 -0
  131. package/dist/multi-combobox.js.map +1 -0
  132. package/dist/navigation-menu.d.ts +9 -0
  133. package/dist/navigation-menu.js +108 -0
  134. package/dist/navigation-menu.js.map +1 -0
  135. package/dist/pagination.d.ts +7 -0
  136. package/dist/pagination.js +195 -0
  137. package/dist/pagination.js.map +1 -0
  138. package/dist/popover.d.ts +4 -0
  139. package/dist/popover.js +35 -0
  140. package/dist/popover.js.map +1 -0
  141. package/dist/progress.d.ts +1 -0
  142. package/dist/progress.js +38 -0
  143. package/dist/progress.js.map +1 -0
  144. package/dist/radio-group.d.ts +2 -0
  145. package/dist/radio-group.js +44 -0
  146. package/dist/radio-group.js.map +1 -0
  147. package/dist/reasoning.d.ts +2 -0
  148. package/dist/reasoning.js +90 -0
  149. package/dist/reasoning.js.map +1 -0
  150. package/dist/resizable.d.ts +3 -0
  151. package/dist/resizable.js +66 -0
  152. package/dist/resizable.js.map +1 -0
  153. package/dist/schemas.d.ts +72 -0
  154. package/dist/schemas.js +5491 -0
  155. package/dist/schemas.js.map +1 -0
  156. package/dist/scroll-area.d.ts +3 -0
  157. package/dist/scroll-area.js +55 -0
  158. package/dist/scroll-area.js.map +1 -0
  159. package/dist/select.d.ts +8 -0
  160. package/dist/select.js +136 -0
  161. package/dist/select.js.map +1 -0
  162. package/dist/separator.d.ts +2 -0
  163. package/dist/separator.js +29 -0
  164. package/dist/separator.js.map +1 -0
  165. package/dist/sheet.d.ts +10 -0
  166. package/dist/sheet.js +140 -0
  167. package/dist/sheet.js.map +1 -0
  168. package/dist/sidebar.d.ts +8 -0
  169. package/dist/sidebar.js +201 -0
  170. package/dist/sidebar.js.map +1 -0
  171. package/dist/skeleton.d.ts +1 -0
  172. package/dist/skeleton.js +21 -0
  173. package/dist/skeleton.js.map +1 -0
  174. package/dist/slider.d.ts +2 -0
  175. package/dist/slider.js +55 -0
  176. package/dist/slider.js.map +1 -0
  177. package/dist/sonner.d.ts +2 -0
  178. package/dist/sonner.js +27 -0
  179. package/dist/sonner.js.map +1 -0
  180. package/dist/spacer.d.ts +3 -0
  181. package/dist/spacer.js +43 -0
  182. package/dist/spacer.js.map +1 -0
  183. package/dist/stack.d.ts +3 -0
  184. package/dist/stack.js +49 -0
  185. package/dist/stack.js.map +1 -0
  186. package/dist/stepper.d.ts +4 -0
  187. package/dist/stepper.js +226 -0
  188. package/dist/stepper.js.map +1 -0
  189. package/dist/suggestion.d.ts +2 -0
  190. package/dist/suggestion.js +55 -0
  191. package/dist/suggestion.js.map +1 -0
  192. package/dist/switch.d.ts +2 -0
  193. package/dist/switch.js +47 -0
  194. package/dist/switch.js.map +1 -0
  195. package/dist/table.d.ts +8 -0
  196. package/dist/table.js +85 -0
  197. package/dist/table.js.map +1 -0
  198. package/dist/tabs.d.ts +4 -0
  199. package/dist/tabs.js +57 -0
  200. package/dist/tabs.js.map +1 -0
  201. package/dist/textarea.d.ts +2 -0
  202. package/dist/textarea.js +36 -0
  203. package/dist/textarea.js.map +1 -0
  204. package/dist/time-picker.d.ts +2 -0
  205. package/dist/time-picker.js +50 -0
  206. package/dist/time-picker.js.map +1 -0
  207. package/dist/timeline.d.ts +4 -0
  208. package/dist/timeline.js +84 -0
  209. package/dist/timeline.js.map +1 -0
  210. package/dist/toggle-group.d.ts +2 -0
  211. package/dist/toggle-group.js +83 -0
  212. package/dist/toggle-group.js.map +1 -0
  213. package/dist/toggle.d.ts +2 -0
  214. package/dist/toggle.js +49 -0
  215. package/dist/toggle.js.map +1 -0
  216. package/dist/tool-call.d.ts +2 -0
  217. package/dist/tool-call.js +133 -0
  218. package/dist/tool-call.js.map +1 -0
  219. package/dist/tooltip.d.ts +4 -0
  220. package/dist/tooltip.js +33 -0
  221. package/dist/tooltip.js.map +1 -0
  222. package/package.json +71 -16
@@ -0,0 +1,108 @@
1
+ "use client";
2
+ import * as React from 'react';
3
+ import { clsx } from 'clsx';
4
+ import { twMerge } from 'tailwind-merge';
5
+ import { jsx, jsxs } from 'react/jsx-runtime';
6
+
7
+ function cn(...inputs) {
8
+ return twMerge(clsx(inputs));
9
+ }
10
+ var RESET_DELAY_MS = 1500;
11
+ function CodeBlockCopy({ code, className, ...props }) {
12
+ const [state, setState] = React.useState("idle");
13
+ React.useEffect(() => {
14
+ if (state === "idle") return;
15
+ const id = window.setTimeout(() => setState("idle"), RESET_DELAY_MS);
16
+ return () => window.clearTimeout(id);
17
+ }, [state]);
18
+ async function handleClick() {
19
+ try {
20
+ await navigator.clipboard.writeText(code);
21
+ setState("copied");
22
+ } catch {
23
+ setState("error");
24
+ }
25
+ }
26
+ const ariaLabel = state === "copied" ? "Copied" : state === "error" ? "Copy failed" : "Copy code";
27
+ return /* @__PURE__ */ jsx(
28
+ "button",
29
+ {
30
+ type: "button",
31
+ onClick: handleClick,
32
+ "aria-label": ariaLabel,
33
+ title: ariaLabel,
34
+ className: cn(
35
+ "inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground",
36
+ "transition-all duration-[var(--duration-normal,200ms)] ease-out",
37
+ "hover:bg-foreground/10 hover:text-foreground",
38
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
39
+ className
40
+ ),
41
+ ...props,
42
+ children: state === "copied" ? /* @__PURE__ */ jsx(CheckGlyph, {}) : state === "error" ? /* @__PURE__ */ jsx(ErrorGlyph, {}) : /* @__PURE__ */ jsx(CopyGlyph, {})
43
+ }
44
+ );
45
+ }
46
+ function CopyGlyph() {
47
+ return /* @__PURE__ */ jsxs(
48
+ "svg",
49
+ {
50
+ "aria-hidden": true,
51
+ viewBox: "0 0 16 16",
52
+ width: "13",
53
+ height: "13",
54
+ fill: "none",
55
+ stroke: "currentColor",
56
+ strokeWidth: "1.5",
57
+ strokeLinecap: "round",
58
+ strokeLinejoin: "round",
59
+ children: [
60
+ /* @__PURE__ */ jsx("rect", { x: "5", y: "5", width: "9", height: "9", rx: "1.5" }),
61
+ /* @__PURE__ */ jsx("path", { d: "M11 5V3.5A1.5 1.5 0 0 0 9.5 2h-6A1.5 1.5 0 0 0 2 3.5v6A1.5 1.5 0 0 0 3.5 11H5" })
62
+ ]
63
+ }
64
+ );
65
+ }
66
+ function CheckGlyph() {
67
+ return /* @__PURE__ */ jsx(
68
+ "svg",
69
+ {
70
+ "aria-hidden": true,
71
+ viewBox: "0 0 16 16",
72
+ width: "13",
73
+ height: "13",
74
+ fill: "none",
75
+ stroke: "currentColor",
76
+ strokeWidth: "1.5",
77
+ strokeLinecap: "round",
78
+ strokeLinejoin: "round",
79
+ className: "text-emerald-500",
80
+ children: /* @__PURE__ */ jsx("path", { d: "M3 8l3.5 3.5L13 5" })
81
+ }
82
+ );
83
+ }
84
+ function ErrorGlyph() {
85
+ return /* @__PURE__ */ jsxs(
86
+ "svg",
87
+ {
88
+ "aria-hidden": true,
89
+ viewBox: "0 0 16 16",
90
+ width: "13",
91
+ height: "13",
92
+ fill: "none",
93
+ stroke: "currentColor",
94
+ strokeWidth: "1.5",
95
+ strokeLinecap: "round",
96
+ strokeLinejoin: "round",
97
+ className: "text-destructive",
98
+ children: [
99
+ /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "6.5" }),
100
+ /* @__PURE__ */ jsx("path", { d: "M8 5v3.5M8 11v.01" })
101
+ ]
102
+ }
103
+ );
104
+ }
105
+
106
+ export { CodeBlockCopy };
107
+ //# sourceMappingURL=code-block-copy.js.map
108
+ //# sourceMappingURL=code-block-copy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/utils.ts","../src/ai/code-block/code-block-copy.tsx"],"names":[],"mappings":";;;;;AAQO,SAAS,MAAM,MAAA,EAAsB;AAC3C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC5B;ACLA,IAAM,cAAA,GAAiB,IAAA;AAyBvB,SAAS,cAAc,EAAE,IAAA,EAAM,SAAA,EAAW,GAAG,OAAM,EAAuB;AACzE,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAU,eAAoB,MAAM,CAAA;AAE1D,EAAM,gBAAU,MAAM;AACrB,IAAA,IAAI,UAAU,MAAA,EAAQ;AACtB,IAAA,MAAM,KAAK,MAAA,CAAO,UAAA,CAAW,MAAM,QAAA,CAAS,MAAM,GAAG,cAAc,CAAA;AACnE,IAAA,OAAO,MAAM,MAAA,CAAO,YAAA,CAAa,EAAE,CAAA;AAAA,EACpC,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AAEV,EAAA,eAAe,WAAA,GAAc;AAC5B,IAAA,IA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EAAK,CAAA,EAAE,mBAAA,EAAoB;AAAA;AAAA;AAAA,GAC7B;AAEF","file":"code-block-copy.js","sourcesContent":["import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Merge class names with Tailwind CSS conflict resolution.\n * @param inputs - Class values (strings, arrays, objects) to merge\n * @returns A single merged class string with Tailwind conflicts resolved\n */\nexport function cn(...inputs: ClassValue[]) {\n\treturn twMerge(clsx(inputs));\n}\n","\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nconst RESET_DELAY_MS = 1500;\n\n/**\n * Copy-to-clipboard button for the `CodeBlock` header. Lives in a\n * client-only file so the surrounding `CodeBlock` (an async Server\n * Component) can render server-side while this island hydrates on the\n * client for `navigator.clipboard` access.\n *\n * @example\n * <CodeBlockCopy code={code} />\n */\nexport interface CodeBlockCopyProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n\t/** The code text to copy. Must be plain text (not the highlighted HTML). */\n\tcode: string;\n}\n\n/**\n * Renders the copy button. Switches to a check icon for ~1.5s after a\n * successful copy.\n *\n * @param props - the raw code string\n * @returns A button that copies on click\n */\ntype CopyState = \"idle\" | \"copied\" | \"error\";\n\nfunction CodeBlockCopy({ code, className, ...props }: CodeBlockCopyProps) {\n\tconst [state, setState] = React.useState<CopyState>(\"idle\");\n\n\tReact.useEffect(() => {\n\t\tif (state === \"idle\") return;\n\t\tconst id = window.setTimeout(() => setState(\"idle\"), RESET_DELAY_MS);\n\t\treturn () => window.clearTimeout(id);\n\t}, [state]);\n\n\tasync function handleClick() {\n\t\ttry {\n\t\t\tawait navigator.clipboard.writeText(code);\n\t\t\tsetState(\"copied\");\n\t\t} catch {\n\t\t\tsetState(\"error\");\n\t\t}\n\t}\n\n\tconst ariaLabel =\n\t\tstate === \"copied\" ? \"Copied\" : state === \"error\" ? \"Copy failed\" : \"Copy code\";\n\n\treturn (\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tonClick={handleClick}\n\t\t\taria-label={ariaLabel}\n\t\t\ttitle={ariaLabel}\n\t\t\tclassName={cn(\n\t\t\t\t\"inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground\",\n\t\t\t\t\"transition-all duration-[var(--duration-normal,200ms)] ease-out\",\n\t\t\t\t\"hover:bg-foreground/10 hover:text-foreground\",\n\t\t\t\t\"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t>\n\t\t\t{state === \"copied\" ? <CheckGlyph /> : state === \"error\" ? <ErrorGlyph /> : <CopyGlyph />}\n\t\t</button>\n\t);\n}\n\nfunction CopyGlyph() {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\twidth=\"13\"\n\t\t\theight=\"13\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeWidth=\"1.5\"\n\t\t\tstrokeLinecap=\"round\"\n\t\t\tstrokeLinejoin=\"round\"\n\t\t>\n\t\t\t<rect x=\"5\" y=\"5\" width=\"9\" height=\"9\" rx=\"1.5\" />\n\t\t\t<path d=\"M11 5V3.5A1.5 1.5 0 0 0 9.5 2h-6A1.5 1.5 0 0 0 2 3.5v6A1.5 1.5 0 0 0 3.5 11H5\" />\n\t\t</svg>\n\t);\n}\n\nfunction CheckGlyph() {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\twidth=\"13\"\n\t\t\theight=\"13\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeWidth=\"1.5\"\n\t\t\tstrokeLinecap=\"round\"\n\t\t\tstrokeLinejoin=\"round\"\n\t\t\tclassName=\"text-emerald-500\"\n\t\t>\n\t\t\t<path d=\"M3 8l3.5 3.5L13 5\" />\n\t\t</svg>\n\t);\n}\n\nfunction ErrorGlyph() {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\twidth=\"13\"\n\t\t\theight=\"13\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeWidth=\"1.5\"\n\t\t\tstrokeLinecap=\"round\"\n\t\t\tstrokeLinejoin=\"round\"\n\t\t\tclassName=\"text-destructive\"\n\t\t>\n\t\t\t<circle cx=\"8\" cy=\"8\" r=\"6.5\" />\n\t\t\t<path d=\"M8 5v3.5M8 11v.01\" />\n\t\t</svg>\n\t);\n}\n\nexport { CodeBlockCopy };\n"]}
@@ -0,0 +1,3 @@
1
+ export { SupportedLang_alias_1 as SupportedLang } from './_tsup-dts-rollup.js';
2
+ export { CodeBlockProps_alias_1 as CodeBlockProps } from './_tsup-dts-rollup.js';
3
+ export { CodeBlock_alias_1 as CodeBlock } from './_tsup-dts-rollup.js';
@@ -0,0 +1,90 @@
1
+ import { cache } from 'react';
2
+ import { codeToHtml } from 'shiki';
3
+ import { clsx } from 'clsx';
4
+ import { twMerge } from 'tailwind-merge';
5
+ import { CodeBlockCopy } from './code-block-copy.js';
6
+ import { jsxs, jsx } from 'react/jsx-runtime';
7
+
8
+ // src/ai/code-block/code-block.tsx
9
+ function cn(...inputs) {
10
+ return twMerge(clsx(inputs));
11
+ }
12
+ var LABEL_TO_LANG = {
13
+ pnpm: "bash",
14
+ npm: "bash",
15
+ yarn: "bash",
16
+ bun: "bash",
17
+ bash: "bash",
18
+ sh: "bash",
19
+ shell: "bash",
20
+ zsh: "bash",
21
+ ts: "ts",
22
+ typescript: "ts",
23
+ tsx: "tsx",
24
+ js: "js",
25
+ javascript: "js",
26
+ jsx: "jsx",
27
+ json: "json",
28
+ css: "css",
29
+ html: "html",
30
+ md: "md",
31
+ markdown: "md",
32
+ py: "py",
33
+ python: "py",
34
+ text: "text",
35
+ prompt: "text",
36
+ plain: "text"
37
+ };
38
+ var DEFAULT_THEMES = { light: "github-light", dark: "github-dark" };
39
+ var cachedCodeToHtml = cache(
40
+ async (code, lang, themesKey, themes) => {
41
+ return codeToHtml(code, { lang, themes, defaultColor: false });
42
+ }
43
+ );
44
+ function resolveLang(label, language) {
45
+ if (language) return language;
46
+ if (label) {
47
+ const fromLabel = LABEL_TO_LANG[label.toLowerCase()];
48
+ if (fromLabel) return fromLabel;
49
+ }
50
+ return "text";
51
+ }
52
+ async function CodeBlock({
53
+ code,
54
+ label,
55
+ language,
56
+ themes = DEFAULT_THEMES,
57
+ className
58
+ }) {
59
+ const lang = resolveLang(label, language);
60
+ const themesKey = `${themes.light}|${themes.dark}`;
61
+ const html = await cachedCodeToHtml(code, lang, themesKey, themes);
62
+ const displayLabel = label ?? lang;
63
+ return /* @__PURE__ */ jsxs(
64
+ "div",
65
+ {
66
+ className: cn(
67
+ "group relative overflow-hidden rounded-lg border bg-card text-card-foreground",
68
+ className
69
+ ),
70
+ children: [
71
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b bg-muted/40 px-3 py-1.5", children: [
72
+ /* @__PURE__ */ jsx("span", { className: "font-mono text-xs font-medium text-muted-foreground", children: displayLabel }),
73
+ /* @__PURE__ */ jsx(CodeBlockCopy, { code })
74
+ ] }),
75
+ /* @__PURE__ */ jsx(
76
+ "div",
77
+ {
78
+ "data-shiki": "",
79
+ className: "overflow-x-auto p-4 font-mono text-sm [&_pre]:!bg-transparent",
80
+ dangerouslySetInnerHTML: { __html: html }
81
+ }
82
+ )
83
+ ]
84
+ }
85
+ );
86
+ }
87
+
88
+ export { CodeBlock };
89
+ //# sourceMappingURL=code-block.js.map
90
+ //# sourceMappingURL=code-block.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/utils.ts","../src/ai/code-block/code-block.tsx"],"names":[],"mappings":";;;;;;;;AAQO,SAAS,MAAM,MAAA,EAAsB;AAC3C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC5B;ACi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SAAA;AAAA,EACvB;AACA,EAAA,OAAO,MAAA;AACR;AAmCA,eAAe,SAAA,CAAU;AAAA,EACxB,IAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA,GAAS,cAAA;AAAA,EACT;AACD,CAAA,EAAmB;AAClB,EAAA,MAAM,IAAA,GAAO,WAAA,CAAY,KAAA,EAAO,QAAQ,CAAA;AACxC,EAAA,MAAM,YAAY,CAAA,EAAG,MAAA,CAAO,KAAK,CAAA,CAAA,EAAI,OAAO,IAAI,CAAA,CAAA;AAChD,EAAA,MAAM,OAAO,MAAM,gBAAA,CAAiB,IAAA,EAAM,IAAA,EAAM,WAAW,MAAM,CAAA;AACjE,EAAA,MAAM,eAAe,KAAA,IAAS,IAAA;AAE9B,EAAA,uBACC,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACA,SAAA,EAAW,EAAA;AAAA,QACV,+EAAA;AAAA,QACA;AAAA,OACD;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAA,IAAA,CAAC,KAAA,EAAA,EAAI,WAAU,oEAAA,EACd,QAAA,EAAA;AAAA,0BAAA,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,qDAAA,EAAuD,QAAA,EAAA,YAAA,EAAa,CAAA;AAAA,0BACpF,GAAA,CAAC,iBAAc,IAAA,EAAY;AAAA,SAAA,EAC5B,CAAA;AAAA,wBACA,GAAA;AAAA,UAAC,KAAA;AAAA,UAAA;AAAA,YACA,YAAA,EAAW,EAAA;AAAA,YACX,SAAA,EAAU,+DAAA;AAAA,YAEV,uBAAA,EAAyB,EAAE,MAAA,EAAQ,IAAA;AAAK;AAAA;AACzC;AAAA;AAAA,GACD;AAEF","file":"code-block.js","sourcesContent":["import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Merge class names with Tailwind CSS conflict resolution.\n * @param inputs - Class values (strings, arrays, objects) to merge\n * @returns A single merged class string with Tailwind conflicts resolved\n */\nexport function cn(...inputs: ClassValue[]) {\n\treturn twMerge(clsx(inputs));\n}\n","import * as React from \"react\";\nimport { cache } from \"react\";\nimport { codeToHtml } from \"shiki\";\nimport { cn } from \"../../lib/utils.js\";\nimport { CodeBlockCopy } from \"./code-block-copy.js\";\n\n/**\n * Languages we surface in the prop type. Plain literal union of real\n * Shiki grammar IDs — kept literal (not `Extract<BundledLanguage, …>`)\n * because Shiki's full bundled-language union is 600+ literals, and\n * deriving from it forced the rollup-dts pass past a 4GB heap. The\n * literals here are all standard Shiki grammar IDs; if Shiki removes\n * one upstream, `codeToHtml` will throw at runtime — acceptable trade.\n */\nexport type SupportedLang =\n\t| \"bash\"\n\t| \"ts\"\n\t| \"tsx\"\n\t| \"js\"\n\t| \"jsx\"\n\t| \"json\"\n\t| \"css\"\n\t| \"html\"\n\t| \"md\"\n\t| \"py\"\n\t| \"text\";\n\nconst LABEL_TO_LANG: Record<string, SupportedLang> = {\n\tpnpm: \"bash\",\n\tnpm: \"bash\",\n\tyarn: \"bash\",\n\tbun: \"bash\",\n\tbash: \"bash\",\n\tsh: \"bash\",\n\tshell: \"bash\",\n\tzsh: \"bash\",\n\tts: \"ts\",\n\ttypescript: \"ts\",\n\ttsx: \"tsx\",\n\tjs: \"js\",\n\tjavascript: \"js\",\n\tjsx: \"jsx\",\n\tjson: \"json\",\n\tcss: \"css\",\n\thtml: \"html\",\n\tmd: \"md\",\n\tmarkdown: \"md\",\n\tpy: \"py\",\n\tpython: \"py\",\n\ttext: \"text\",\n\tprompt: \"text\",\n\tplain: \"text\",\n};\n\nconst DEFAULT_THEMES = { light: \"github-light\", dark: \"github-dark\" } as const;\n\n/**\n * Per-render-tree memoization of `codeToHtml`. React's `cache()` dedupes\n * identical (code, lang, theme) combos within a single RSC render pass —\n * useful when a page renders many copies of the same install snippet.\n * Shiki itself caches grammars/themes per process, so this layer only\n * eliminates duplicate parse + tokenize work within one request.\n */\nconst cachedCodeToHtml = cache(\n\tasync (code: string, lang: SupportedLang, themesKey: string, themes: { light: string; dark: string }) => {\n\t\tvoid themesKey;\n\t\treturn codeToHtml(code, { lang, themes, defaultColor: false });\n\t},\n);\n\nfunction resolveLang(label?: string, language?: SupportedLang): SupportedLang {\n\tif (language) return language;\n\tif (label) {\n\t\tconst fromLabel = LABEL_TO_LANG[label.toLowerCase()];\n\t\tif (fromLabel) return fromLabel;\n\t}\n\treturn \"text\";\n}\n\n/**\n * Syntax-highlighted code block with a language-label header and a copy\n * button. Highlighting runs server-side via Shiki using a dual-theme\n * (default: github-light / github-dark) so the same HTML flips on\n * `data-theme`/`prefers-color-scheme` without client-side rehydration.\n *\n * Async Server Component — render inside RSC trees or pre-render in\n * static contexts. For client-side streaming code blocks, plug Streamdown's\n * built-in code rendering via `Markdown components={{ pre: … }}` instead.\n *\n * @example\n * <CodeBlock label=\"pnpm\" code=\"pnpm add @hex-core/components\" />\n * @example\n * <CodeBlock language=\"tsx\" code={src} />\n */\nexport interface CodeBlockProps {\n\tcode: string;\n\t/** Optional header label (e.g. \"pnpm\", \"tsx\"). Inferred from `language` if omitted. */\n\tlabel?: string;\n\t/** Explicit Shiki grammar key. Overrides inference from `label`. */\n\tlanguage?: SupportedLang;\n\t/** Override the default github-light / github-dark theme pair. */\n\tthemes?: { light: string; dark: string };\n\tclassName?: string;\n}\n\n/**\n * Async Server Component that highlights `code` server-side and emits the\n * resulting HTML with a header + copy island.\n *\n * @param props - code, optional label/language/themes\n * @returns A bordered card wrapping the highlighted code\n */\nasync function CodeBlock({\n\tcode,\n\tlabel,\n\tlanguage,\n\tthemes = DEFAULT_THEMES,\n\tclassName,\n}: CodeBlockProps) {\n\tconst lang = resolveLang(label, language);\n\tconst themesKey = `${themes.light}|${themes.dark}`;\n\tconst html = await cachedCodeToHtml(code, lang, themesKey, themes);\n\tconst displayLabel = label ?? lang;\n\n\treturn (\n\t\t<div\n\t\t\tclassName={cn(\n\t\t\t\t\"group relative overflow-hidden rounded-lg border bg-card text-card-foreground\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t>\n\t\t\t<div className=\"flex items-center justify-between border-b bg-muted/40 px-3 py-1.5\">\n\t\t\t\t<span className=\"font-mono text-xs font-medium text-muted-foreground\">{displayLabel}</span>\n\t\t\t\t<CodeBlockCopy code={code} />\n\t\t\t</div>\n\t\t\t<div\n\t\t\t\tdata-shiki=\"\"\n\t\t\t\tclassName=\"overflow-x-auto p-4 font-mono text-sm [&_pre]:!bg-transparent\"\n\t\t\t\t// biome-ignore lint/security/noDangerouslySetInnerHtml: Shiki output is trusted server-rendered HTML\n\t\t\t\tdangerouslySetInnerHTML={{ __html: html }}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport { CodeBlock };\n"]}
@@ -0,0 +1,3 @@
1
+ export { Collapsible_alias_1 as Collapsible } from './_tsup-dts-rollup.js';
2
+ export { CollapsibleTrigger_alias_1 as CollapsibleTrigger } from './_tsup-dts-rollup.js';
3
+ export { CollapsibleContent_alias_1 as CollapsibleContent } from './_tsup-dts-rollup.js';
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
3
+
4
+ var Collapsible = CollapsiblePrimitive.Root;
5
+ var CollapsibleTrigger2 = CollapsiblePrimitive.CollapsibleTrigger;
6
+ var CollapsibleContent2 = CollapsiblePrimitive.CollapsibleContent;
7
+
8
+ export { Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger };
9
+ //# sourceMappingURL=collapsible.js.map
10
+ //# sourceMappingURL=collapsible.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/collapsible/collapsible.tsx"],"names":["CollapsibleTrigger","CollapsibleContent"],"mappings":";;AAKA,IAAM,WAAA,GAAmC,oBAAA,CAAA;AAGzC,IAAMA,mBAAAA,GAA0C,oBAAA,CAAA;AAGhD,IAAMC,mBAAAA,GAA0C,oBAAA,CAAA","file":"collapsible.js","sourcesContent":["\"use client\";\n\nimport * as CollapsiblePrimitive from \"@radix-ui/react-collapsible\";\n\n/** Root container controlling the expanded state of the content. */\nconst Collapsible = CollapsiblePrimitive.Root;\n\n/** The element that toggles the Collapsible open/closed. */\nconst CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;\n\n/** The collapsible content shown/hidden by the trigger. */\nconst CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;\n\nexport { Collapsible, CollapsibleTrigger, CollapsibleContent };\n"]}
@@ -0,0 +1,2 @@
1
+ export { ColorPickerProps_alias_1 as ColorPickerProps } from './_tsup-dts-rollup.js';
2
+ export { ColorPicker_alias_1 as ColorPicker } from './_tsup-dts-rollup.js';
@@ -0,0 +1,321 @@
1
+ "use client";
2
+ import * as React5 from 'react';
3
+ import { clsx } from 'clsx';
4
+ import { twMerge } from 'tailwind-merge';
5
+ import { jsx, jsxs } from 'react/jsx-runtime';
6
+ import * as LabelPrimitive from '@radix-ui/react-label';
7
+ import { cva } from 'class-variance-authority';
8
+ import * as SliderPrimitive from '@radix-ui/react-slider';
9
+ import * as PopoverPrimitive from '@radix-ui/react-popover';
10
+
11
+ function cn(...inputs) {
12
+ return twMerge(clsx(inputs));
13
+ }
14
+
15
+ // src/lib/color.ts
16
+ function parseHslTriplet(triplet) {
17
+ const parts = triplet.trim().split(/\s+/);
18
+ return {
19
+ h: Number.parseFloat(parts[0]) || 0,
20
+ s: Number.parseFloat(parts[1]) || 0,
21
+ l: Number.parseFloat(parts[2]) || 0
22
+ };
23
+ }
24
+ function formatHslTriplet({ h, s, l }) {
25
+ const round = (n) => Math.abs(n - Math.round(n)) < 1e-6 ? `${Math.round(n)}` : n.toFixed(1);
26
+ return `${Math.round(h)} ${round(s)}% ${round(l)}%`;
27
+ }
28
+ function hslToRgb(h, s, l) {
29
+ const sN = s / 100;
30
+ const lN = l / 100;
31
+ const k = (n) => (n + h / 30) % 12;
32
+ const a = sN * Math.min(lN, 1 - lN);
33
+ const f = (n) => lN - a * Math.max(-1, Math.min(k(n) - 3, 9 - k(n), 1));
34
+ return {
35
+ r: Math.round(255 * f(0)),
36
+ g: Math.round(255 * f(8)),
37
+ b: Math.round(255 * f(4))
38
+ };
39
+ }
40
+ function rgbToHsl(r, g, b) {
41
+ const rN = r / 255;
42
+ const gN = g / 255;
43
+ const bN = b / 255;
44
+ const max = Math.max(rN, gN, bN);
45
+ const min = Math.min(rN, gN, bN);
46
+ let h = 0;
47
+ let s = 0;
48
+ const l = (max + min) / 2;
49
+ if (max !== min) {
50
+ const d = max - min;
51
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
52
+ if (max === rN) h = (gN - bN) / d + (gN < bN ? 6 : 0);
53
+ else if (max === gN) h = (bN - rN) / d + 2;
54
+ else h = (rN - gN) / d + 4;
55
+ h /= 6;
56
+ }
57
+ return { h: h * 360, s: s * 100, l: l * 100 };
58
+ }
59
+ function hslTripletToHex(triplet) {
60
+ const { h, s, l } = parseHslTriplet(triplet);
61
+ const { r, g, b } = hslToRgb(h, s, l);
62
+ const toHex = (n) => n.toString(16).padStart(2, "0");
63
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
64
+ }
65
+ function hexToHslTriplet(hex) {
66
+ const clean = hex.trim().replace(/^#/, "");
67
+ let normalized;
68
+ if (/^[0-9a-fA-F]{3}$/.test(clean)) {
69
+ normalized = clean.split("").map((c) => c + c).join("");
70
+ } else if (/^[0-9a-fA-F]{6}$/.test(clean)) {
71
+ normalized = clean;
72
+ } else {
73
+ return null;
74
+ }
75
+ const r = Number.parseInt(normalized.slice(0, 2), 16);
76
+ const g = Number.parseInt(normalized.slice(2, 4), 16);
77
+ const b = Number.parseInt(normalized.slice(4, 6), 16);
78
+ return formatHslTriplet(rgbToHsl(r, g, b));
79
+ }
80
+ var Input = React5.forwardRef(
81
+ ({ className, type, ...props }, ref) => {
82
+ return /* @__PURE__ */ jsx(
83
+ "input",
84
+ {
85
+ type,
86
+ className: cn(
87
+ "flex h-[var(--control-height-md,2.5rem)] w-full rounded-md border border-input bg-background px-[var(--space-3,0.75rem)] py-[var(--space-2,0.5rem)] text-sm",
88
+ "transition-all duration-[var(--duration-normal,200ms)] ease-out",
89
+ // inset-ring gives a self-borne edge so the input field is visible on flat
90
+ // surfaces (token border alone is too low-contrast on bg-background=white).
91
+ "shadow-sm inset-ring-1 inset-ring-foreground/[0.06]",
92
+ "file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground",
93
+ "placeholder:text-muted-foreground",
94
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
95
+ "focus-visible:shadow-md focus-visible:border-ring/50",
96
+ "hover:border-ring/30 hover:shadow-md",
97
+ "disabled:cursor-not-allowed disabled:opacity-50",
98
+ className
99
+ ),
100
+ ref,
101
+ ...props
102
+ }
103
+ );
104
+ }
105
+ );
106
+ Input.displayName = "Input";
107
+ var labelVariants = cva(
108
+ "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
109
+ );
110
+ var Label = React5.forwardRef(
111
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx(LabelPrimitive.Root, { ref, className: cn(labelVariants(), className), ...props })
112
+ );
113
+ Label.displayName = "Label";
114
+ var Slider = React5.forwardRef(({ className, thumbLabels, ...props }, ref) => {
115
+ const values = props.value ?? props.defaultValue ?? [0];
116
+ const rootLabel = props["aria-label"];
117
+ const rootLabelledBy = props["aria-labelledby"];
118
+ if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production" && thumbLabels && thumbLabels.length !== values.length) {
119
+ console.warn(
120
+ `Slider: thumbLabels.length (${thumbLabels.length}) does not match value.length (${values.length}). Missing labels fall back to indexed names; extra labels are ignored.`
121
+ );
122
+ }
123
+ return /* @__PURE__ */ jsxs(
124
+ SliderPrimitive.Root,
125
+ {
126
+ ref,
127
+ className: cn("relative flex w-full touch-none select-none items-center", className),
128
+ ...props,
129
+ children: [
130
+ /* @__PURE__ */ jsx(SliderPrimitive.Track, { className: "relative h-2 w-full grow overflow-hidden rounded-full border border-foreground/[0.08] bg-secondary", children: /* @__PURE__ */ jsx(SliderPrimitive.Range, { className: "absolute h-full bg-primary" }) }),
131
+ values.map((_, i) => {
132
+ const explicit = thumbLabels?.[i];
133
+ const fallback = values.length === 1 ? rootLabel : rootLabel ? `${rootLabel} (${i + 1} of ${values.length})` : void 0;
134
+ return /* @__PURE__ */ jsx(
135
+ SliderPrimitive.Thumb,
136
+ {
137
+ "aria-label": explicit ?? fallback,
138
+ "aria-labelledby": explicit || fallback ? void 0 : rootLabelledBy,
139
+ className: cn(
140
+ "block h-5 w-5 rounded-full border-2 border-primary bg-background",
141
+ "transition-all duration-[var(--duration-normal,200ms)] ease-out shadow-md",
142
+ "hover:shadow-lg hover:scale-110",
143
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
144
+ "disabled:pointer-events-none disabled:opacity-50"
145
+ )
146
+ },
147
+ i
148
+ );
149
+ })
150
+ ]
151
+ }
152
+ );
153
+ });
154
+ Slider.displayName = "Slider";
155
+ var Popover = PopoverPrimitive.Root;
156
+ var PopoverTrigger = PopoverPrimitive.Trigger;
157
+ var PopoverContent = React5.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
158
+ PopoverPrimitive.Content,
159
+ {
160
+ ref,
161
+ align,
162
+ sideOffset,
163
+ className: cn(
164
+ "z-50 w-72 rounded-md border border-foreground/[0.08] bg-popover p-[var(--space-4,1rem)] text-popover-foreground shadow-md outline-none",
165
+ "data-[state=open]:animate-in data-[state=closed]:animate-out",
166
+ "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
167
+ "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
168
+ "data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
169
+ className
170
+ ),
171
+ ...props
172
+ }
173
+ ) }));
174
+ PopoverContent.displayName = "PopoverContent";
175
+ var INTEGER_EPSILON = 1e-6;
176
+ var looksInteger = (n) => Math.abs(n - Math.round(n)) < INTEGER_EPSILON;
177
+ function ColorPicker({
178
+ value,
179
+ onChange,
180
+ disabled,
181
+ "aria-label": ariaLabel = "Pick color",
182
+ className
183
+ }) {
184
+ const hsl = React5.useMemo(() => parseHslTriplet(value), [value]);
185
+ const hex = React5.useMemo(() => hslTripletToHex(value), [value]);
186
+ const update = React5.useCallback(
187
+ (patch) => {
188
+ onChange(formatHslTriplet({ ...hsl, ...patch }));
189
+ },
190
+ [hsl, onChange]
191
+ );
192
+ const hexInputRef = React5.useRef(null);
193
+ const [hexBuffer, setHexBuffer] = React5.useState(hex);
194
+ React5.useEffect(() => {
195
+ if (typeof document === "undefined" || document.activeElement !== hexInputRef.current) {
196
+ setHexBuffer(hex);
197
+ }
198
+ }, [hex]);
199
+ const handleHexChange = (e) => {
200
+ const next = e.target.value;
201
+ setHexBuffer(next);
202
+ const triplet = hexToHslTriplet(next);
203
+ if (triplet !== null) onChange(triplet);
204
+ };
205
+ const hexId = React5.useId();
206
+ return /* @__PURE__ */ jsxs(Popover, { children: [
207
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
208
+ "button",
209
+ {
210
+ type: "button",
211
+ disabled,
212
+ "aria-label": ariaLabel,
213
+ className: cn(
214
+ "inline-flex h-9 items-center gap-2 rounded-md border border-input bg-background px-3 text-sm shadow-sm",
215
+ "transition-all duration-[var(--duration-normal,200ms)] ease-out",
216
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
217
+ "hover:shadow-md disabled:pointer-events-none disabled:opacity-50",
218
+ className
219
+ ),
220
+ children: [
221
+ /* @__PURE__ */ jsx(
222
+ "span",
223
+ {
224
+ "aria-hidden": "true",
225
+ className: "h-5 w-5 rounded-sm border border-border",
226
+ style: { backgroundColor: `hsl(${value})` }
227
+ }
228
+ ),
229
+ /* @__PURE__ */ jsx("span", { className: "font-mono text-xs uppercase", children: hex })
230
+ ]
231
+ }
232
+ ) }),
233
+ /* @__PURE__ */ jsx(PopoverContent, { className: "w-72 p-4", align: "start", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
234
+ /* @__PURE__ */ jsx(
235
+ SliderRow,
236
+ {
237
+ label: "Hue",
238
+ suffix: "\xB0",
239
+ value: hsl.h,
240
+ max: 360,
241
+ step: 1,
242
+ onChange: (h) => update({ h })
243
+ }
244
+ ),
245
+ /* @__PURE__ */ jsx(
246
+ SliderRow,
247
+ {
248
+ label: "Saturation",
249
+ suffix: "%",
250
+ value: hsl.s,
251
+ max: 100,
252
+ step: 0.1,
253
+ onChange: (s) => update({ s })
254
+ }
255
+ ),
256
+ /* @__PURE__ */ jsx(
257
+ SliderRow,
258
+ {
259
+ label: "Lightness",
260
+ suffix: "%",
261
+ value: hsl.l,
262
+ max: 100,
263
+ step: 0.1,
264
+ onChange: (l) => update({ l })
265
+ }
266
+ ),
267
+ /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
268
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-1", children: [
269
+ /* @__PURE__ */ jsx(Label, { htmlFor: hexId, className: "text-xs", children: "Hex" }),
270
+ /* @__PURE__ */ jsx(
271
+ Input,
272
+ {
273
+ id: hexId,
274
+ ref: hexInputRef,
275
+ value: hexBuffer,
276
+ onChange: handleHexChange,
277
+ className: "font-mono text-xs uppercase",
278
+ spellCheck: false,
279
+ autoComplete: "off"
280
+ }
281
+ )
282
+ ] }),
283
+ /* @__PURE__ */ jsx(
284
+ "span",
285
+ {
286
+ "aria-hidden": "true",
287
+ className: "h-9 w-9 shrink-0 rounded-md border border-border",
288
+ style: { backgroundColor: `hsl(${value})` }
289
+ }
290
+ )
291
+ ] })
292
+ ] }) })
293
+ ] });
294
+ }
295
+ function SliderRow({ label, suffix, value, max, step, onChange }) {
296
+ const display = looksInteger(value) ? `${Math.round(value)}` : value.toFixed(1);
297
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
298
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
299
+ /* @__PURE__ */ jsx(Label, { className: "text-xs", children: label }),
300
+ /* @__PURE__ */ jsxs("span", { className: "font-mono text-xs tabular-nums text-muted-foreground", children: [
301
+ display,
302
+ suffix
303
+ ] })
304
+ ] }),
305
+ /* @__PURE__ */ jsx(
306
+ Slider,
307
+ {
308
+ value: [value],
309
+ min: 0,
310
+ max,
311
+ step,
312
+ "aria-label": label,
313
+ onValueChange: (values) => onChange(values[0] ?? 0)
314
+ }
315
+ )
316
+ ] });
317
+ }
318
+
319
+ export { ColorPicker };
320
+ //# sourceMappingURL=color-picker.js.map
321
+ //# sourceMappingURL=color-picker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/utils.ts","../src/lib/color.ts","../src/primitives/input/input.tsx","../src/primitives/label/label.tsx","../src/primitives/slider/slider.tsx","../src/components/popover/popover.tsx","../src/components/color-picker/color-picker.tsx"],"names":["React","React2","jsx","React3","React4","jsxs"],"mappings":";;;;;;;;;AAQO,SAAS,MAAM,MAAA,EAAsB;AAC3C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC5B;;;AC4BO,SAAS,gBAAgB,OAAA,EAA6B;AAC5D,EAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,IAAA,EAAK,CAAE,MAAM,KAAK,CAAA;AACxC,EAAA,OAAO;AAAA,IACN,GAAG,MAAA,CAAO,UAAA,CAAW,KAAA,CAAM,CAAC,CAAC,CAAA,IAAK,CAAA;AAAA,IAClC,GAAG,MAAA,CAAO,UAAA,CAAW,KAAA,CAAM,CAAC,CAAC,CAAA,IAAK,CAAA;AAAA,IAClC,GAAG,MAAA,CAAO,UAAA,CAAW,KAAA,CAAM,CAAC,CAAC,CAAA,IAAK;AAAA,GACnC;AACD;AAOO,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M,UAAS,EAAmB;AACjF,EAAA,MAAM,OAAA,GAAU,YAAA,CAAa,KAAK,CAAA,GAAI,CAAA,EAAG,IAAA,CAAK,KAAA,CAAM,KAAK,CAAC,CAAA,CAAA,GAAK,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA;AAC9E,EAAA,uBACCG,IAAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,aAAA,EACd,QAAA,EAAA;AAAA,oBAAAA,IAAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,mCAAA,EACd,QAAA,EAAA;AAAA,sBAAAH,GAAAA,CAAC,KAAA,EAAA,EAAM,SAAA,EAAU,SAAA,EAAW,QAAA,EAAA,KAAA,EAAM,CAAA;AAAA,sBAClCG,IAAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,sDAAA,EACd,QAAA,EAAA;AAAA,QAAA,OAAA;AAAA,QACA;AAAA,OAAA,EACF;AAAA,KAAA,EACD,CAAA;AAAA,oBACAH,GAAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACA,KAAA,EAAO,CAAC,KAAK,CAAA;AAAA,QACb,GAAA,EAAK,CAAA;AAAA,QACL,GAAA;AAAA,QACA,IAAA;AAAA,QACA,YAAA,EAAY,KAAA;AAAA,QACZ,eAAe,CAAC,MAAA,KAAW,SAAS,MAAA,CAAO,CAAC,KAAK,CAAC;AAAA;AAAA;AACnD,GAAA,EACD,CAAA;AAEF","file":"color-picker.js","sourcesContent":["import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Merge class names with Tailwind CSS conflict resolution.\n * @param inputs - Class values (strings, arrays, objects) to merge\n * @returns A single merged class string with Tailwind conflicts resolved\n */\nexport function cn(...inputs: ClassValue[]) {\n\treturn twMerge(clsx(inputs));\n}\n","/**\n * Color conversion utilities for the HSL-triplet token format used across\n * `@hex-core/tokens` themes (`H S% L%`, e.g. `\"240 5.9% 10%\"` — no `hsl()`\n * wrapper, no commas).\n *\n * The triplet is the round-trip-safe serialization for Hex UI: tokens flow\n * triplet → CSS `hsl(var(--token))` → rendered color, and the ColorPicker\n * component edits triplets directly. Hex/RGB conversions are display\n * adapters, not the source of truth.\n */\n\n/** Parsed HSL components. `h` is degrees (0–360); `s` and `l` are percentages (0–100). */\nexport interface HslTriplet {\n\th: number;\n\ts: number;\n\tl: number;\n}\n\n/** Parsed RGB components. Each channel is 0–255. */\nexport interface RgbColor {\n\tr: number;\n\tg: number;\n\tb: number;\n}\n\n/**\n * Parse an HSL triplet string into numeric components.\n *\n * Note: malformed input silently coerces to `{0,0,0}` (pure black) rather than\n * returning an error signal. Callers that need to distinguish \"user typed\n * black\" from \"user typed garbage\" should validate the input format first.\n * `hexToHslTriplet` returns `null` for malformed hex; this asymmetry is\n * intentional — triplets feed CSS variables where any non-color value would\n * already break rendering.\n *\n * @param triplet - String in the form `\"<H> <S>% <L>%\"` (e.g. `\"240 5.9% 10%\"`).\n * @returns Numeric components, or `{0,0,0}` if the input is malformed.\n */\nexport function parseHslTriplet(triplet: string): HslTriplet {\n\tconst parts = triplet.trim().split(/\\s+/);\n\treturn {\n\t\th: Number.parseFloat(parts[0]) || 0,\n\t\ts: Number.parseFloat(parts[1]) || 0,\n\t\tl: Number.parseFloat(parts[2]) || 0,\n\t};\n}\n\n/**\n * Format HSL components into an HSL triplet string (the canonical token format).\n * @param hsl - Numeric components.\n * @returns Triplet in the form `\"<H> <S>% <L>%\"`.\n */\nexport function formatHslTriplet({ h, s, l }: HslTriplet): string {\n\t// Tolerant integer check: rgbToHsl can produce values like 5.0000000001 due\n\t// to float arithmetic; format those as \"5\" rather than \"5.0\".\n\tconst round = (n: number) =>\n\t\tMath.abs(n - Math.round(n)) < 1e-6 ? `${Math.round(n)}` : n.toFixed(1);\n\treturn `${Math.round(h)} ${round(s)}% ${round(l)}%`;\n}\n\n/**\n * Convert HSL components to RGB.\n * @param h - Hue (0–360).\n * @param s - Saturation (0–100).\n * @param l - Lightness (0–100).\n * @returns RGB channels (0–255, rounded).\n */\nexport function hslToRgb(h: number, s: number, l: number): RgbColor {\n\tconst sN = s / 100;\n\tconst lN = l / 100;\n\tconst k = (n: number) => (n + h / 30) % 12;\n\tconst a = sN * Math.min(lN, 1 - lN);\n\tconst f = (n: number) => lN - a * Math.max(-1, Math.min(k(n) - 3, 9 - k(n), 1));\n\treturn {\n\t\tr: Math.round(255 * f(0)),\n\t\tg: Math.round(255 * f(8)),\n\t\tb: Math.round(255 * f(4)),\n\t};\n}\n\n/**\n * Convert RGB components to HSL.\n * @param r - Red (0–255).\n * @param g - Green (0–255).\n * @param b - Blue (0–255).\n * @returns HSL components (h: 0–360, s: 0–100, l: 0–100).\n */\nexport function rgbToHsl(r: number, g: number, b: number): HslTriplet {\n\tconst rN = r / 255;\n\tconst gN = g / 255;\n\tconst bN = b / 255;\n\tconst max = Math.max(rN, gN, bN);\n\tconst min = Math.min(rN, gN, bN);\n\tlet h = 0;\n\tlet s = 0;\n\tconst l = (max + min) / 2;\n\tif (max !== min) {\n\t\tconst d = max - min;\n\t\ts = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n\t\tif (max === rN) h = (gN - bN) / d + (gN < bN ? 6 : 0);\n\t\telse if (max === gN) h = (bN - rN) / d + 2;\n\t\telse h = (rN - gN) / d + 4;\n\t\th /= 6;\n\t}\n\treturn { h: h * 360, s: s * 100, l: l * 100 };\n}\n\n/**\n * Convert an HSL triplet to a 6-digit hex string.\n * @param triplet - HSL triplet (e.g. `\"240 5.9% 10%\"`).\n * @returns Lowercase hex string with leading `#` (e.g. `\"#181a1f\"`).\n */\nexport function hslTripletToHex(triplet: string): string {\n\tconst { h, s, l } = parseHslTriplet(triplet);\n\tconst { r, g, b } = hslToRgb(h, s, l);\n\tconst toHex = (n: number) => n.toString(16).padStart(2, \"0\");\n\treturn `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n}\n\n/**\n * Convert a hex string to an HSL triplet.\n * Accepts 3-digit (`#abc`) or 6-digit (`#aabbcc`) hex with optional `#`.\n * @param hex - Hex color string.\n * @returns HSL triplet, or `null` if the input is malformed.\n */\nexport function hexToHslTriplet(hex: string): string | null {\n\tconst clean = hex.trim().replace(/^#/, \"\");\n\tlet normalized: string;\n\tif (/^[0-9a-fA-F]{3}$/.test(clean)) {\n\t\tnormalized = clean\n\t\t\t.split(\"\")\n\t\t\t.map((c) => c + c)\n\t\t\t.join(\"\");\n\t} else if (/^[0-9a-fA-F]{6}$/.test(clean)) {\n\t\tnormalized = clean;\n\t} else {\n\t\treturn null;\n\t}\n\tconst r = Number.parseInt(normalized.slice(0, 2), 16);\n\tconst g = Number.parseInt(normalized.slice(2, 4), 16);\n\tconst b = Number.parseInt(normalized.slice(4, 6), 16);\n\treturn formatHslTriplet(rgbToHsl(r, g, b));\n}\n","import * as React from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nexport type InputProps = React.InputHTMLAttributes<HTMLInputElement>;\n\nconst Input = React.forwardRef<HTMLInputElement, InputProps>(\n\t({ className, type, ...props }, ref) => {\n\t\treturn (\n\t\t\t<input\n\t\t\t\ttype={type}\n\t\t\t\tclassName={cn(\n\t\t\t\t\t\"flex h-[var(--control-height-md,2.5rem)] w-full rounded-md border border-input bg-background px-[var(--space-3,0.75rem)] py-[var(--space-2,0.5rem)] text-sm\",\n\t\t\t\t\t\"transition-all duration-[var(--duration-normal,200ms)] ease-out\",\n\t\t\t\t\t// inset-ring gives a self-borne edge so the input field is visible on flat\n\t\t\t\t\t// surfaces (token border alone is too low-contrast on bg-background=white).\n\t\t\t\t\t\"shadow-sm inset-ring-1 inset-ring-foreground/[0.06]\",\n\t\t\t\t\t\"file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground\",\n\t\t\t\t\t\"placeholder:text-muted-foreground\",\n\t\t\t\t\t\"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\",\n\t\t\t\t\t\"focus-visible:shadow-md focus-visible:border-ring/50\",\n\t\t\t\t\t\"hover:border-ring/30 hover:shadow-md\",\n\t\t\t\t\t\"disabled:cursor-not-allowed disabled:opacity-50\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t);\n\t},\n);\nInput.displayName = \"Input\";\n\nexport { Input };\n","\"use client\";\n\nimport * as LabelPrimitive from \"@radix-ui/react-label\";\nimport { type VariantProps, cva } from \"class-variance-authority\";\nimport * as React from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nconst labelVariants = cva(\n\t\"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70\",\n);\n\nexport interface LabelProps\n\textends React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>,\n\t\tVariantProps<typeof labelVariants> {}\n\nconst Label = React.forwardRef<React.ComponentRef<typeof LabelPrimitive.Root>, LabelProps>(\n\t({ className, ...props }, ref) => (\n\t\t<LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />\n\t),\n);\nLabel.displayName = \"Label\";\n\nexport { Label };\n","\"use client\";\n\nimport * as SliderPrimitive from \"@radix-ui/react-slider\";\nimport * as React from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\n// Local ambient — components run in browsers where bundlers (Next, Vite, tsup)\n// replace `process.env.NODE_ENV` at build time. Avoids pulling @types/node into\n// the components package just for one dev-mode warning.\ndeclare const process: { env?: { NODE_ENV?: string } } | undefined;\n\ninterface SliderProps\n\textends React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root> {\n\t/**\n\t * Per-thumb accessible labels. When the slider has multiple thumbs, pass\n\t * one entry per thumb (e.g. [\"Minimum\", \"Maximum\"]). For a single-thumb\n\t * slider, the Root's `aria-label` / `aria-labelledby` is mirrored onto\n\t * the thumb automatically — pass `thumbLabels` only when those defaults\n\t * are insufficient.\n\t */\n\tthumbLabels?: string[];\n}\n\n/**\n * A range input with one or more draggable thumbs.\n * Built on Radix UI Slider with keyboard controls (arrows, Home, End, PageUp/Down).\n */\nconst Slider = React.forwardRef<\n\tReact.ComponentRef<typeof SliderPrimitive.Root>,\n\tSliderProps\n>(({ className, thumbLabels, ...props }, ref) => {\n\tconst values = props.value ?? props.defaultValue ?? [0];\n\tconst rootLabel = props[\"aria-label\"];\n\tconst rootLabelledBy = props[\"aria-labelledby\"];\n\n\tif (\n\t\ttypeof process !== \"undefined\" &&\n\t\tprocess.env?.NODE_ENV !== \"production\" &&\n\t\tthumbLabels &&\n\t\tthumbLabels.length !== values.length\n\t) {\n\t\tconsole.warn(\n\t\t\t`Slider: thumbLabels.length (${thumbLabels.length}) does not match value.length (${values.length}). ` +\n\t\t\t\t`Missing labels fall back to indexed names; extra labels are ignored.`,\n\t\t);\n\t}\n\n\treturn (\n\t\t<SliderPrimitive.Root\n\t\t\tref={ref}\n\t\t\tclassName={cn(\"relative flex w-full touch-none select-none items-center\", className)}\n\t\t\t{...props}\n\t\t>\n\t\t\t<SliderPrimitive.Track className=\"relative h-2 w-full grow overflow-hidden rounded-full border border-foreground/[0.08] bg-secondary\">\n\t\t\t\t<SliderPrimitive.Range className=\"absolute h-full bg-primary\" />\n\t\t\t</SliderPrimitive.Track>\n\t\t\t{values.map((_, i) => {\n\t\t\t\tconst explicit = thumbLabels?.[i];\n\t\t\t\tconst fallback =\n\t\t\t\t\tvalues.length === 1\n\t\t\t\t\t\t? rootLabel\n\t\t\t\t\t\t: rootLabel\n\t\t\t\t\t\t\t? `${rootLabel} (${i + 1} of ${values.length})`\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\treturn (\n\t\t\t\t\t<SliderPrimitive.Thumb\n\t\t\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: Radix renders one thumb per value by index\n\t\t\t\t\t\tkey={i}\n\t\t\t\t\t\taria-label={explicit ?? fallback}\n\t\t\t\t\t\taria-labelledby={\n\t\t\t\t\t\t\texplicit || fallback ? undefined : rootLabelledBy\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\"block h-5 w-5 rounded-full border-2 border-primary bg-background\",\n\t\t\t\t\t\t\t\"transition-all duration-[var(--duration-normal,200ms)] ease-out shadow-md\",\n\t\t\t\t\t\t\t\"hover:shadow-lg hover:scale-110\",\n\t\t\t\t\t\t\t\"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\",\n\t\t\t\t\t\t\t\"disabled:pointer-events-none disabled:opacity-50\",\n\t\t\t\t\t\t)}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t})}\n\t\t</SliderPrimitive.Root>\n\t);\n});\nSlider.displayName = \"Slider\";\n\nexport type { SliderProps };\n\nexport { Slider };\n","\"use client\";\n\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport * as React from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\n/** Root container for a popover. */\nconst Popover = PopoverPrimitive.Root;\n\n/** The element that anchors and opens the popover. */\nconst PopoverTrigger = PopoverPrimitive.Trigger;\n\n/** Helper to explicitly anchor the popover to a different element. */\nconst PopoverAnchor = PopoverPrimitive.Anchor;\n\n/** The floating popover content panel. */\nconst PopoverContent = React.forwardRef<\n\tReact.ComponentRef<typeof PopoverPrimitive.Content>,\n\tReact.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>\n>(({ className, align = \"center\", sideOffset = 4, ...props }, ref) => (\n\t<PopoverPrimitive.Portal>\n\t\t<PopoverPrimitive.Content\n\t\t\tref={ref}\n\t\t\talign={align}\n\t\t\tsideOffset={sideOffset}\n\t\t\tclassName={cn(\n\t\t\t\t\"z-50 w-72 rounded-md border border-foreground/[0.08] bg-popover p-[var(--space-4,1rem)] text-popover-foreground shadow-md outline-none\",\n\t\t\t\t\"data-[state=open]:animate-in data-[state=closed]:animate-out\",\n\t\t\t\t\"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n\t\t\t\t\"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95\",\n\t\t\t\t\"data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t</PopoverPrimitive.Portal>\n));\nPopoverContent.displayName = \"PopoverContent\";\n\nexport { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };\n","\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"../../lib/utils.js\";\nimport {\n\tformatHslTriplet,\n\thexToHslTriplet,\n\thslTripletToHex,\n\tparseHslTriplet,\n} from \"../../lib/color.js\";\nimport { Input } from \"../../primitives/input/input.js\";\nimport { Label } from \"../../primitives/label/label.js\";\nimport { Slider } from \"../../primitives/slider/slider.js\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../popover/popover.js\";\n\n/** Tolerance for treating a float as integer-valued (handles arithmetic drift in HSL roundtrips). */\nconst INTEGER_EPSILON = 1e-6;\n\nconst looksInteger = (n: number) => Math.abs(n - Math.round(n)) < INTEGER_EPSILON;\n\n/** Props for the ColorPicker component. */\nexport interface ColorPickerProps {\n\t/**\n\t * Current color as an HSL triplet string (`\"<H> <S>% <L>%\"`, e.g. `\"240 5.9% 10%\"`).\n\t * Match the format used by `@hex-core/tokens`; round-trip safe.\n\t */\n\tvalue: string;\n\t/**\n\t * Called with the next HSL triplet whenever the user drags a slider or commits a valid hex value.\n\t * Not called for invalid hex input — the picker keeps the prior value until the input parses cleanly.\n\t */\n\tonChange: (value: string) => void;\n\t/**\n\t * Disable interaction. Native `disabled` attribute is set on the trigger so the\n\t * popover doesn't open via mouse or keyboard activation. Tab focus still lands\n\t * on the trigger per browser defaults; if you want to fully remove it from the\n\t * tab order, wrap in a parent that handles `tabIndex` accordingly.\n\t */\n\tdisabled?: boolean;\n\t/** Accessible name for the trigger button (defaults to \"Pick color\"). */\n\t\"aria-label\"?: string;\n\t/** Additional class names merged onto the trigger. */\n\tclassName?: string;\n}\n\n/**\n * HSL-native color picker. Edits an HSL triplet directly via three sliders\n * (H/S/L), with a hex input as a display adapter.\n *\n * Round-trip safe: triplet → hex → triplet preserves the slider state because\n * sliders are the source of truth and hex updates them only when valid.\n *\n * @param props - Controlled component; `value` and `onChange` are required.\n * @returns A trigger button that opens a popover with H/S/L sliders + hex input.\n * @example\n * ```tsx\n * const [color, setColor] = React.useState(\"240 5.9% 10%\");\n * <ColorPicker value={color} onChange={setColor} aria-label=\"Primary color\" />\n * ```\n */\nfunction ColorPicker({\n\tvalue,\n\tonChange,\n\tdisabled,\n\t\"aria-label\": ariaLabel = \"Pick color\",\n\tclassName,\n}: ColorPickerProps) {\n\t// Memoize so the slider-row callbacks below are stable across renders with\n\t// the same `value`; downstream `Slider`s avoid spurious re-mounts.\n\tconst hsl = React.useMemo(() => parseHslTriplet(value), [value]);\n\tconst hex = React.useMemo(() => hslTripletToHex(value), [value]);\n\n\tconst update = React.useCallback(\n\t\t(patch: Partial<typeof hsl>) => {\n\t\t\tonChange(formatHslTriplet({ ...hsl, ...patch }));\n\t\t},\n\t\t[hsl, onChange],\n\t);\n\n\t// Hex input is locally controlled so the user can type intermediate states\n\t// (e.g. \"#1a\") without committing. Sync the buffer to the canonical hex\n\t// whenever the input is NOT focused — typing into a focused input must not\n\t// be clobbered by a parent re-render reflecting our own `onChange`.\n\tconst hexInputRef = React.useRef<HTMLInputElement>(null);\n\tconst [hexBuffer, setHexBuffer] = React.useState(hex);\n\tReact.useEffect(() => {\n\t\tif (\n\t\t\ttypeof document === \"undefined\" ||\n\t\t\tdocument.activeElement !== hexInputRef.current\n\t\t) {\n\t\t\tsetHexBuffer(hex);\n\t\t}\n\t}, [hex]);\n\n\tconst handleHexChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\tconst next = e.target.value;\n\t\tsetHexBuffer(next);\n\t\tconst triplet = hexToHslTriplet(next);\n\t\tif (triplet !== null) onChange(triplet);\n\t};\n\n\tconst hexId = React.useId();\n\n\treturn (\n\t\t<Popover>\n\t\t\t<PopoverTrigger asChild>\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\taria-label={ariaLabel}\n\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\"inline-flex h-9 items-center gap-2 rounded-md border border-input bg-background px-3 text-sm shadow-sm\",\n\t\t\t\t\t\t\"transition-all duration-[var(--duration-normal,200ms)] ease-out\",\n\t\t\t\t\t\t\"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\",\n\t\t\t\t\t\t\"hover:shadow-md disabled:pointer-events-none disabled:opacity-50\",\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tclassName=\"h-5 w-5 rounded-sm border border-border\"\n\t\t\t\t\t\tstyle={{ backgroundColor: `hsl(${value})` }}\n\t\t\t\t\t/>\n\t\t\t\t\t<span className=\"font-mono text-xs uppercase\">{hex}</span>\n\t\t\t\t</button>\n\t\t\t</PopoverTrigger>\n\t\t\t<PopoverContent className=\"w-72 p-4\" align=\"start\">\n\t\t\t\t<div className=\"space-y-4\">\n\t\t\t\t\t<SliderRow\n\t\t\t\t\t\tlabel=\"Hue\"\n\t\t\t\t\t\tsuffix=\"°\"\n\t\t\t\t\t\tvalue={hsl.h}\n\t\t\t\t\t\tmax={360}\n\t\t\t\t\t\tstep={1}\n\t\t\t\t\t\tonChange={(h) => update({ h })}\n\t\t\t\t\t/>\n\t\t\t\t\t<SliderRow\n\t\t\t\t\t\tlabel=\"Saturation\"\n\t\t\t\t\t\tsuffix=\"%\"\n\t\t\t\t\t\tvalue={hsl.s}\n\t\t\t\t\t\tmax={100}\n\t\t\t\t\t\tstep={0.1}\n\t\t\t\t\t\tonChange={(s) => update({ s })}\n\t\t\t\t\t/>\n\t\t\t\t\t<SliderRow\n\t\t\t\t\t\tlabel=\"Lightness\"\n\t\t\t\t\t\tsuffix=\"%\"\n\t\t\t\t\t\tvalue={hsl.l}\n\t\t\t\t\t\tmax={100}\n\t\t\t\t\t\tstep={0.1}\n\t\t\t\t\t\tonChange={(l) => update({ l })}\n\t\t\t\t\t/>\n\t\t\t\t\t<div className=\"flex items-end gap-2\">\n\t\t\t\t\t\t<div className=\"flex-1 space-y-1\">\n\t\t\t\t\t\t\t<Label htmlFor={hexId} className=\"text-xs\">\n\t\t\t\t\t\t\t\tHex\n\t\t\t\t\t\t\t</Label>\n\t\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\t\tid={hexId}\n\t\t\t\t\t\t\t\tref={hexInputRef}\n\t\t\t\t\t\t\t\tvalue={hexBuffer}\n\t\t\t\t\t\t\t\tonChange={handleHexChange}\n\t\t\t\t\t\t\t\tclassName=\"font-mono text-xs uppercase\"\n\t\t\t\t\t\t\t\tspellCheck={false}\n\t\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\tclassName=\"h-9 w-9 shrink-0 rounded-md border border-border\"\n\t\t\t\t\t\t\tstyle={{ backgroundColor: `hsl(${value})` }}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</PopoverContent>\n\t\t</Popover>\n\t);\n}\n\ninterface SliderRowProps {\n\tlabel: string;\n\tsuffix: string;\n\tvalue: number;\n\tmax: number;\n\tstep: number;\n\tonChange: (next: number) => void;\n}\n\n/**\n * One labeled slider row inside the ColorPicker popover. Internal helper —\n * not exported.\n * @param props - Slider config + value-change callback.\n */\nfunction SliderRow({ label, suffix, value, max, step, onChange }: SliderRowProps) {\n\tconst display = looksInteger(value) ? `${Math.round(value)}` : value.toFixed(1);\n\treturn (\n\t\t<div className=\"space-y-1.5\">\n\t\t\t<div className=\"flex items-center justify-between\">\n\t\t\t\t<Label className=\"text-xs\">{label}</Label>\n\t\t\t\t<span className=\"font-mono text-xs tabular-nums text-muted-foreground\">\n\t\t\t\t\t{display}\n\t\t\t\t\t{suffix}\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t\t<Slider\n\t\t\t\tvalue={[value]}\n\t\t\t\tmin={0}\n\t\t\t\tmax={max}\n\t\t\t\tstep={step}\n\t\t\t\taria-label={label}\n\t\t\t\tonValueChange={(values) => onChange(values[0] ?? 0)}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport { ColorPicker };\n"]}