@zonsh/ui 0.0.0-stage → 0.2.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 (388) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +76 -2
  3. package/assets/illustrations/drawing/bracket-construction-dark.svg +77 -0
  4. package/assets/illustrations/drawing/bracket-construction-filled-dark.svg +50 -0
  5. package/assets/illustrations/drawing/bracket-construction-filled.svg +50 -0
  6. package/assets/illustrations/drawing/bracket-construction.svg +77 -0
  7. package/assets/illustrations/drawing/crescent-dark.svg +28 -0
  8. package/assets/illustrations/drawing/crescent-guides-dark.svg +33 -0
  9. package/assets/illustrations/drawing/crescent-guides.svg +33 -0
  10. package/assets/illustrations/drawing/crescent.svg +28 -0
  11. package/assets/illustrations/drawing/eclipse-dark.svg +187 -0
  12. package/assets/illustrations/drawing/eclipse-guides-dark.svg +191 -0
  13. package/assets/illustrations/drawing/eclipse-guides.svg +191 -0
  14. package/assets/illustrations/drawing/eclipse.svg +187 -0
  15. package/assets/illustrations/drawing/elevation-guides-dark.svg +31 -0
  16. package/assets/illustrations/drawing/elevation-guides-plain-dark.svg +9 -0
  17. package/assets/illustrations/drawing/elevation-guides-plain.svg +9 -0
  18. package/assets/illustrations/drawing/elevation-guides.svg +31 -0
  19. package/assets/illustrations/drawing/horizon-dark.svg +30 -0
  20. package/assets/illustrations/drawing/horizon.svg +30 -0
  21. package/assets/illustrations/drawing/nib-study-dark.svg +107 -0
  22. package/assets/illustrations/drawing/nib-study-plain-dark.svg +93 -0
  23. package/assets/illustrations/drawing/nib-study-plain.svg +93 -0
  24. package/assets/illustrations/drawing/nib-study.svg +107 -0
  25. package/assets/illustrations/editorial/assistant-640.webp +0 -0
  26. package/assets/illustrations/editorial/assistant.webp +0 -0
  27. package/assets/illustrations/editorial/automation-640.webp +0 -0
  28. package/assets/illustrations/editorial/automation.webp +0 -0
  29. package/assets/illustrations/editorial/bracket-left-640.webp +0 -0
  30. package/assets/illustrations/editorial/bracket-left.webp +0 -0
  31. package/assets/illustrations/editorial/bracket-right-640.webp +0 -0
  32. package/assets/illustrations/editorial/bracket-right.webp +0 -0
  33. package/assets/illustrations/editorial/custom-software-640.webp +0 -0
  34. package/assets/illustrations/editorial/custom-software.webp +0 -0
  35. package/assets/illustrations/editorial/digitalization-640.webp +0 -0
  36. package/assets/illustrations/editorial/digitalization.webp +0 -0
  37. package/assets/illustrations/editorial/integration-640.webp +0 -0
  38. package/assets/illustrations/editorial/integration.webp +0 -0
  39. package/assets/illustrations/editorial/problem-640.webp +0 -0
  40. package/assets/illustrations/editorial/problem.webp +0 -0
  41. package/assets/illustrations/editorial/process-analysis-640.webp +0 -0
  42. package/assets/illustrations/editorial/process-analysis.webp +0 -0
  43. package/assets/illustrations/editorial/process-concept-640.webp +0 -0
  44. package/assets/illustrations/editorial/process-concept.webp +0 -0
  45. package/assets/illustrations/editorial/process-development-640.webp +0 -0
  46. package/assets/illustrations/editorial/process-development.webp +0 -0
  47. package/assets/illustrations/editorial/process-discovery-640.webp +0 -0
  48. package/assets/illustrations/editorial/process-discovery.webp +0 -0
  49. package/assets/illustrations/editorial/process-maintenance-640.webp +0 -0
  50. package/assets/illustrations/editorial/process-maintenance.webp +0 -0
  51. package/assets/illustrations/editorial/process-prototype-640.webp +0 -0
  52. package/assets/illustrations/editorial/process-prototype.webp +0 -0
  53. package/assets/illustrations/editorial/process-testing-640.webp +0 -0
  54. package/assets/illustrations/editorial/process-testing.webp +0 -0
  55. package/assets/illustrations/iso/automation-dark.svg +6 -0
  56. package/assets/illustrations/iso/automation.svg +6 -0
  57. package/assets/illustrations/iso/bar-chart-dark.svg +6 -0
  58. package/assets/illustrations/iso/bar-chart.svg +6 -0
  59. package/assets/illustrations/iso/brackets-classic-dark.svg +6 -0
  60. package/assets/illustrations/iso/brackets-classic.svg +6 -0
  61. package/assets/illustrations/iso/brackets-dark.svg +6 -0
  62. package/assets/illustrations/iso/brackets.svg +6 -0
  63. package/assets/illustrations/iso/city-dark.svg +6 -0
  64. package/assets/illustrations/iso/city.svg +6 -0
  65. package/assets/illustrations/iso/conveyor-dark.svg +6 -0
  66. package/assets/illustrations/iso/conveyor.svg +6 -0
  67. package/assets/illustrations/iso/database-dark.svg +6 -0
  68. package/assets/illustrations/iso/database.svg +6 -0
  69. package/assets/illustrations/iso/documents-dark.svg +6 -0
  70. package/assets/illustrations/iso/documents.svg +6 -0
  71. package/assets/illustrations/iso/inbox-dark.svg +6 -0
  72. package/assets/illustrations/iso/inbox.svg +6 -0
  73. package/assets/illustrations/iso/laptop-dark.svg +6 -0
  74. package/assets/illustrations/iso/laptop.svg +6 -0
  75. package/assets/illustrations/iso/monitor-dark.svg +6 -0
  76. package/assets/illustrations/iso/monitor.svg +6 -0
  77. package/assets/illustrations/iso/pipeline-dark.svg +6 -0
  78. package/assets/illustrations/iso/pipeline.svg +6 -0
  79. package/assets/illustrations/iso/platform-dark.svg +6 -0
  80. package/assets/illustrations/iso/platform.svg +6 -0
  81. package/assets/illustrations/iso/server-dark.svg +6 -0
  82. package/assets/illustrations/iso/server.svg +6 -0
  83. package/assets/illustrations/iso/spreadsheet-dark.svg +6 -0
  84. package/assets/illustrations/iso/spreadsheet.svg +6 -0
  85. package/assets/illustrations/iso/timeline-dark.svg +6 -0
  86. package/assets/illustrations/iso/timeline.svg +6 -0
  87. package/assets/illustrations/sheet/construction.svg +115 -0
  88. package/assets/illustrations/sheet/crescent.svg +40 -0
  89. package/assets/illustrations/sheet/limb.svg +42 -0
  90. package/assets/illustrations/sheet/stress-axis.svg +119 -0
  91. package/assets/illustrations/sheet/totality.svg +215 -0
  92. package/assets/illustrations/sheet/vertical-metrics.svg +43 -0
  93. package/assets/logo-left.svg +1 -0
  94. package/assets/logo-right.svg +1 -0
  95. package/assets/logo.svg +1 -0
  96. package/dist/components/_overlay.d.ts +47 -0
  97. package/dist/components/_overlay.js +59 -0
  98. package/dist/components/accordion.d.ts +32 -0
  99. package/dist/components/accordion.js +39 -0
  100. package/dist/components/alert-dialog.d.ts +45 -0
  101. package/dist/components/alert-dialog.js +56 -0
  102. package/dist/components/alert.d.ts +35 -0
  103. package/dist/components/alert.js +42 -0
  104. package/dist/components/ascii-field.d.ts +34 -0
  105. package/dist/components/ascii-field.js +410 -0
  106. package/dist/components/aspect-ratio.d.ts +14 -0
  107. package/dist/components/aspect-ratio.js +17 -0
  108. package/dist/components/avatar.d.ts +42 -0
  109. package/dist/components/avatar.js +55 -0
  110. package/dist/components/badge.d.ts +70 -0
  111. package/dist/components/badge.js +62 -0
  112. package/dist/components/breadcrumb.d.ts +22 -0
  113. package/dist/components/breadcrumb.js +32 -0
  114. package/dist/components/button-group.d.ts +30 -0
  115. package/dist/components/button-group.js +47 -0
  116. package/dist/components/button.d.ts +53 -0
  117. package/dist/components/button.js +130 -0
  118. package/dist/components/calendar.d.ts +26 -0
  119. package/dist/components/calendar.js +164 -0
  120. package/dist/components/card.d.ts +42 -0
  121. package/dist/components/card.js +76 -0
  122. package/dist/components/carousel.d.ts +90 -0
  123. package/dist/components/carousel.js +213 -0
  124. package/dist/components/chart.d.ts +180 -0
  125. package/dist/components/chart.js +286 -0
  126. package/dist/components/checkbox.d.ts +23 -0
  127. package/dist/components/checkbox.js +43 -0
  128. package/dist/components/code-block.d.ts +45 -0
  129. package/dist/components/code-block.js +58 -0
  130. package/dist/components/code-highlight.d.ts +13 -0
  131. package/dist/components/code-highlight.js +107 -0
  132. package/dist/components/collapsible.d.ts +20 -0
  133. package/dist/components/collapsible.js +32 -0
  134. package/dist/components/color-picker.d.ts +85 -0
  135. package/dist/components/color-picker.js +407 -0
  136. package/dist/components/combobox.d.ts +81 -0
  137. package/dist/components/combobox.js +100 -0
  138. package/dist/components/command.d.ts +112 -0
  139. package/dist/components/command.js +212 -0
  140. package/dist/components/context-menu.d.ts +29 -0
  141. package/dist/components/context-menu.js +35 -0
  142. package/dist/components/conversation.d.ts +27 -0
  143. package/dist/components/conversation.js +293 -0
  144. package/dist/components/copy-button.d.ts +46 -0
  145. package/dist/components/copy-button.js +118 -0
  146. package/dist/components/data-table.d.ts +175 -0
  147. package/dist/components/data-table.js +302 -0
  148. package/dist/components/date-picker.d.ts +91 -0
  149. package/dist/components/date-picker.js +207 -0
  150. package/dist/components/dialog.d.ts +48 -0
  151. package/dist/components/dialog.js +92 -0
  152. package/dist/components/direction.d.ts +16 -0
  153. package/dist/components/direction.js +18 -0
  154. package/dist/components/drawer.d.ts +60 -0
  155. package/dist/components/drawer.js +76 -0
  156. package/dist/components/empty.d.ts +31 -0
  157. package/dist/components/empty.js +50 -0
  158. package/dist/components/feature-list.d.ts +54 -0
  159. package/dist/components/feature-list.js +43 -0
  160. package/dist/components/field.d.ts +15 -0
  161. package/dist/components/field.js +36 -0
  162. package/dist/components/file-drop.d.ts +55 -0
  163. package/dist/components/file-drop.js +197 -0
  164. package/dist/components/filter-bar.d.ts +106 -0
  165. package/dist/components/filter-bar.js +296 -0
  166. package/dist/components/form.d.ts +33 -0
  167. package/dist/components/form.js +34 -0
  168. package/dist/components/graph.d.ts +105 -0
  169. package/dist/components/graph.js +786 -0
  170. package/dist/components/illustration.d.ts +85 -0
  171. package/dist/components/illustration.js +165 -0
  172. package/dist/components/input-group.d.ts +127 -0
  173. package/dist/components/input-group.js +292 -0
  174. package/dist/components/input.d.ts +16 -0
  175. package/dist/components/input.js +25 -0
  176. package/dist/components/item.d.ts +64 -0
  177. package/dist/components/item.js +116 -0
  178. package/dist/components/kbd.d.ts +33 -0
  179. package/dist/components/kbd.js +38 -0
  180. package/dist/components/label.d.ts +12 -0
  181. package/dist/components/label.js +24 -0
  182. package/dist/components/layout.d.ts +136 -0
  183. package/dist/components/layout.js +162 -0
  184. package/dist/components/logo.d.ts +54 -0
  185. package/dist/components/logo.js +96 -0
  186. package/dist/components/menu.d.ts +60 -0
  187. package/dist/components/menu.js +138 -0
  188. package/dist/components/menubar.d.ts +62 -0
  189. package/dist/components/menubar.js +223 -0
  190. package/dist/components/message.d.ts +42 -0
  191. package/dist/components/message.js +56 -0
  192. package/dist/components/meter.d.ts +31 -0
  193. package/dist/components/meter.js +25 -0
  194. package/dist/components/native-select.d.ts +26 -0
  195. package/dist/components/native-select.js +35 -0
  196. package/dist/components/navigation-menu.d.ts +42 -0
  197. package/dist/components/navigation-menu.js +97 -0
  198. package/dist/components/number-field.d.ts +36 -0
  199. package/dist/components/number-field.js +153 -0
  200. package/dist/components/otp-field.d.ts +35 -0
  201. package/dist/components/otp-field.js +94 -0
  202. package/dist/components/pagination.d.ts +31 -0
  203. package/dist/components/pagination.js +70 -0
  204. package/dist/components/pdf-viewer.d.ts +69 -0
  205. package/dist/components/pdf-viewer.js +929 -0
  206. package/dist/components/popover.d.ts +33 -0
  207. package/dist/components/popover.js +48 -0
  208. package/dist/components/preview-card.d.ts +25 -0
  209. package/dist/components/preview-card.js +22 -0
  210. package/dist/components/progress.d.ts +27 -0
  211. package/dist/components/progress.js +23 -0
  212. package/dist/components/prompt-input.d.ts +131 -0
  213. package/dist/components/prompt-input.js +403 -0
  214. package/dist/components/quote.d.ts +22 -0
  215. package/dist/components/quote.js +15 -0
  216. package/dist/components/radio-group.d.ts +18 -0
  217. package/dist/components/radio-group.js +34 -0
  218. package/dist/components/reasoning.d.ts +31 -0
  219. package/dist/components/reasoning.js +70 -0
  220. package/dist/components/resizable.d.ts +38 -0
  221. package/dist/components/resizable.js +41 -0
  222. package/dist/components/response.d.ts +30 -0
  223. package/dist/components/response.js +538 -0
  224. package/dist/components/scroll-area.d.ts +33 -0
  225. package/dist/components/scroll-area.js +31 -0
  226. package/dist/components/select.d.ts +35 -0
  227. package/dist/components/select.js +60 -0
  228. package/dist/components/separator.d.ts +14 -0
  229. package/dist/components/separator.js +17 -0
  230. package/dist/components/sidebar.d.ts +147 -0
  231. package/dist/components/sidebar.js +489 -0
  232. package/dist/components/site-header.d.ts +59 -0
  233. package/dist/components/site-header.js +67 -0
  234. package/dist/components/skeleton.d.ts +31 -0
  235. package/dist/components/skeleton.js +29 -0
  236. package/dist/components/slider.d.ts +24 -0
  237. package/dist/components/slider.js +129 -0
  238. package/dist/components/sources.d.ts +25 -0
  239. package/dist/components/sources.js +35 -0
  240. package/dist/components/spinner.d.ts +36 -0
  241. package/dist/components/spinner.js +72 -0
  242. package/dist/components/suggestions.d.ts +20 -0
  243. package/dist/components/suggestions.js +18 -0
  244. package/dist/components/switch.d.ts +14 -0
  245. package/dist/components/switch.js +26 -0
  246. package/dist/components/table.d.ts +162 -0
  247. package/dist/components/table.js +758 -0
  248. package/dist/components/tabs.d.ts +25 -0
  249. package/dist/components/tabs.js +162 -0
  250. package/dist/components/tag.d.ts +41 -0
  251. package/dist/components/tag.js +88 -0
  252. package/dist/components/tags-input.d.ts +40 -0
  253. package/dist/components/tags-input.js +239 -0
  254. package/dist/components/textarea.d.ts +13 -0
  255. package/dist/components/textarea.js +16 -0
  256. package/dist/components/theme.d.ts +41 -0
  257. package/dist/components/theme.js +112 -0
  258. package/dist/components/time-field.d.ts +51 -0
  259. package/dist/components/time-field.js +437 -0
  260. package/dist/components/timeline.d.ts +76 -0
  261. package/dist/components/timeline.js +99 -0
  262. package/dist/components/toast.d.ts +72 -0
  263. package/dist/components/toast.js +196 -0
  264. package/dist/components/toggle-group.d.ts +41 -0
  265. package/dist/components/toggle-group.js +140 -0
  266. package/dist/components/toggle.d.ts +23 -0
  267. package/dist/components/toggle.js +35 -0
  268. package/dist/components/tool-call.d.ts +52 -0
  269. package/dist/components/tool-call.js +57 -0
  270. package/dist/components/toolbar.d.ts +17 -0
  271. package/dist/components/toolbar.js +34 -0
  272. package/dist/components/tooltip.d.ts +42 -0
  273. package/dist/components/tooltip.js +47 -0
  274. package/dist/components/tree.d.ts +75 -0
  275. package/dist/components/tree.js +636 -0
  276. package/dist/components/typography.d.ts +134 -0
  277. package/dist/components/typography.js +176 -0
  278. package/dist/components/video-player.d.ts +276 -0
  279. package/dist/components/video-player.js +1352 -0
  280. package/dist/components/whiteboard.d.ts +80 -0
  281. package/dist/components/whiteboard.js +389 -0
  282. package/dist/index.d.ts +85 -0
  283. package/dist/index.js +86 -0
  284. package/dist/lib/cn.d.ts +20 -0
  285. package/dist/lib/cn.js +38 -0
  286. package/dist/lib/code-highlight.d.ts +31 -0
  287. package/dist/lib/code-highlight.js +24 -0
  288. package/dist/lib/code-theme.d.ts +19 -0
  289. package/dist/lib/code-theme.js +140 -0
  290. package/dist/lib/collapse-row.d.ts +9 -0
  291. package/dist/lib/collapse-row.js +129 -0
  292. package/dist/lib/digit-roll.d.ts +21 -0
  293. package/dist/lib/digit-roll.js +31 -0
  294. package/dist/lib/editorial-assets.d.ts +16 -0
  295. package/dist/lib/editorial-assets.js +56 -0
  296. package/dist/lib/figure/catalog.d.ts +127 -0
  297. package/dist/lib/figure/catalog.js +130 -0
  298. package/dist/lib/figure/figures/automation.d.ts +7 -0
  299. package/dist/lib/figure/figures/automation.js +143 -0
  300. package/dist/lib/figure/figures/bar-chart.d.ts +7 -0
  301. package/dist/lib/figure/figures/bar-chart.js +99 -0
  302. package/dist/lib/figure/figures/brackets-classic.d.ts +11 -0
  303. package/dist/lib/figure/figures/brackets-classic.js +170 -0
  304. package/dist/lib/figure/figures/brackets.d.ts +8 -0
  305. package/dist/lib/figure/figures/brackets.js +84 -0
  306. package/dist/lib/figure/figures/city.d.ts +7 -0
  307. package/dist/lib/figure/figures/city.js +93 -0
  308. package/dist/lib/figure/figures/conveyor.d.ts +7 -0
  309. package/dist/lib/figure/figures/conveyor.js +97 -0
  310. package/dist/lib/figure/figures/database.d.ts +7 -0
  311. package/dist/lib/figure/figures/database.js +65 -0
  312. package/dist/lib/figure/figures/documents.d.ts +7 -0
  313. package/dist/lib/figure/figures/documents.js +83 -0
  314. package/dist/lib/figure/figures/inbox.d.ts +7 -0
  315. package/dist/lib/figure/figures/inbox.js +92 -0
  316. package/dist/lib/figure/figures/laptop.d.ts +7 -0
  317. package/dist/lib/figure/figures/laptop.js +67 -0
  318. package/dist/lib/figure/figures/monitor.d.ts +7 -0
  319. package/dist/lib/figure/figures/monitor.js +59 -0
  320. package/dist/lib/figure/figures/pipeline.d.ts +8 -0
  321. package/dist/lib/figure/figures/pipeline.js +117 -0
  322. package/dist/lib/figure/figures/platform.d.ts +7 -0
  323. package/dist/lib/figure/figures/platform.js +117 -0
  324. package/dist/lib/figure/figures/server.d.ts +7 -0
  325. package/dist/lib/figure/figures/server.js +115 -0
  326. package/dist/lib/figure/figures/spreadsheet.d.ts +7 -0
  327. package/dist/lib/figure/figures/spreadsheet.js +87 -0
  328. package/dist/lib/figure/figures/timeline.d.ts +7 -0
  329. package/dist/lib/figure/figures/timeline.js +65 -0
  330. package/dist/lib/figure/kernel.d.ts +152 -0
  331. package/dist/lib/figure/kernel.js +576 -0
  332. package/dist/lib/figure/parts.d.ts +42 -0
  333. package/dist/lib/figure/parts.js +126 -0
  334. package/dist/lib/form-reset.d.ts +11 -0
  335. package/dist/lib/form-reset.js +22 -0
  336. package/dist/lib/glide.d.ts +53 -0
  337. package/dist/lib/glide.js +138 -0
  338. package/dist/lib/graph-layout.d.ts +58 -0
  339. package/dist/lib/graph-layout.js +200 -0
  340. package/dist/lib/illustration-drawings.d.ts +89 -0
  341. package/dist/lib/illustration-drawings.js +539 -0
  342. package/dist/lib/illustration-info.d.ts +37 -0
  343. package/dist/lib/illustration-info.js +22 -0
  344. package/dist/lib/illustration-library.d.ts +87 -0
  345. package/dist/lib/illustration-library.js +352 -0
  346. package/dist/lib/logo-geometry.d.ts +29 -0
  347. package/dist/lib/logo-geometry.js +67 -0
  348. package/dist/lib/markdown-guard.d.ts +16 -0
  349. package/dist/lib/markdown-guard.js +123 -0
  350. package/dist/lib/merge-refs.d.ts +10 -0
  351. package/dist/lib/merge-refs.js +26 -0
  352. package/dist/lib/motion.d.ts +6 -0
  353. package/dist/lib/motion.js +12 -0
  354. package/dist/lib/pdf-worker.d.ts +1 -0
  355. package/dist/lib/pdf-worker.js +6 -0
  356. package/dist/lib/pdf.d.ts +19 -0
  357. package/dist/lib/pdf.js +58 -0
  358. package/dist/lib/platform.d.ts +33 -0
  359. package/dist/lib/platform.js +68 -0
  360. package/dist/lib/room.d.ts +25 -0
  361. package/dist/lib/room.js +46 -0
  362. package/dist/lib/table-fit.d.ts +143 -0
  363. package/dist/lib/table-fit.js +577 -0
  364. package/dist/lib/theme-script.d.ts +18 -0
  365. package/dist/lib/theme-script.js +29 -0
  366. package/dist/styles/expressive.css +188 -0
  367. package/dist/styles/fonts.css +145 -0
  368. package/dist/styles/index.css +206 -0
  369. package/dist/styles/material.css +313 -0
  370. package/dist/styles/parts/ai.css +360 -0
  371. package/dist/styles/parts/brand.css +75 -0
  372. package/dist/styles/parts/controls.css +725 -0
  373. package/dist/styles/parts/data.css +222 -0
  374. package/dist/styles/parts/editorial.css +120 -0
  375. package/dist/styles/parts/feedback.css +273 -0
  376. package/dist/styles/parts/foundations.css +166 -0
  377. package/dist/styles/parts/graph.css +214 -0
  378. package/dist/styles/parts/inputs.css +261 -0
  379. package/dist/styles/parts/isometric.css +124 -0
  380. package/dist/styles/parts/navigation.css +232 -0
  381. package/dist/styles/parts/overlays.css +250 -0
  382. package/dist/styles/parts/pdf.css +154 -0
  383. package/dist/styles/parts/react-flow.css +519 -0
  384. package/dist/styles/parts/whiteboard.css +855 -0
  385. package/dist/styles/tokens.css +290 -0
  386. package/dist/vite.d.ts +116 -0
  387. package/dist/vite.js +129 -0
  388. package/package.json +189 -3
@@ -0,0 +1,85 @@
1
+ import * as React from "react";
2
+ import { type PopoverContentProps } from "./popover.js";
3
+ export type ColorFormat = "hex" | "rgb" | "hsl" | "oklch";
4
+ export type ColorPickerPreset = string | {
5
+ value: string;
6
+ label: string;
7
+ };
8
+ export interface ColorPickerPanelProps extends Omit<React.ComponentProps<"div">, "defaultValue" | "onChange" | "color"> {
9
+ /** The colour as a CSS string: hex, `rgb()`, `hsl()` or `oklch()`. Leave `undefined` for uncontrolled. */
10
+ value?: string;
11
+ defaultValue?: string;
12
+ /** Called as the colour changes — on every step of a drag — with the colour in `format`. */
13
+ onValueChange?: (value: string) => void;
14
+ /** How the value is written: `"hex"` (default, `#rrggbb`), `"rgb"`, `"hsl"` or `"oklch"`. */
15
+ format?: ColorFormat;
16
+ /** Add an opacity slider; the value gains an alpha (`#rrggbbaa`, `oklch(… / 80%)`). */
17
+ alpha?: boolean;
18
+ /** Colours to pick in one click, under the value: values, or `{ value, label }` with a name. */
19
+ presets?: ColorPickerPreset[];
20
+ disabled?: boolean;
21
+ /** Accessible names for the parts. */
22
+ labels?: {
23
+ area?: string;
24
+ hue?: string;
25
+ alpha?: string;
26
+ input?: string;
27
+ presets?: string;
28
+ };
29
+ }
30
+ /**
31
+ * ColorPickerPanel — the picker without its popover, to sit in a page or a panel: a saturation ×
32
+ * brightness area at the colour's hue, a hue slider, an optional opacity slider, a text field for
33
+ * the value and optional presets. Controlled (`value` + `onValueChange`) or uncontrolled
34
+ * (`defaultValue`); the value is a CSS colour string in `format`.
35
+ */
36
+ export declare function ColorPickerPanel({ value, defaultValue, onValueChange, format, ...props }: ColorPickerPanelProps): React.JSX.Element;
37
+ export interface ColorSwatchProps extends React.ComponentProps<"span"> {
38
+ /** Any CSS colour. A translucent one shows over a checkerboard. */
39
+ color: string;
40
+ }
41
+ /**
42
+ * ColorSwatch — a colour as a small square: 16px, 5px corners, a `--field-edge` border, over a
43
+ * checkerboard so transparency shows. Decorative (`aria-hidden`): say the colour in text beside it.
44
+ */
45
+ export declare function ColorSwatch({ color, className, style, ...props }: ColorSwatchProps): React.JSX.Element;
46
+ declare const triggerSizes: {
47
+ readonly sm: "min-h-(--control-h-sm) gap-2 px-2.5 text-xs";
48
+ readonly default: "min-h-(--control-h) gap-2.5 pr-2.5 pl-2.5 text-[13px]";
49
+ };
50
+ export interface ColorPickerProps extends Pick<ColorPickerPanelProps, "value" | "defaultValue" | "onValueChange" | "format" | "alpha" | "presets" | "disabled" | "labels"> {
51
+ /** `sm` (30px) for dense surfaces; `default` (38px) everywhere else. */
52
+ size?: keyof typeof triggerSizes;
53
+ /** Submits the value in a hidden input. Default: the `Field`'s name. */
54
+ name?: string;
55
+ /**
56
+ * A colour must be picked: while there is none the picker is `valueMissing`, which stops a
57
+ * form's submit and marks the `Field` invalid.
58
+ */
59
+ required?: boolean;
60
+ id?: string;
61
+ /** Shown in the trigger while there is no value. */
62
+ placeholder?: string;
63
+ open?: boolean;
64
+ defaultOpen?: boolean;
65
+ onOpenChange?: (open: boolean) => void;
66
+ /** Classes for the trigger. */
67
+ className?: string;
68
+ /** Props for the popover panel: `side`, `align`, `className` … */
69
+ popover?: Omit<PopoverContentProps, "children">;
70
+ "aria-label"?: string;
71
+ "aria-labelledby"?: string;
72
+ "aria-describedby"?: string;
73
+ }
74
+ /**
75
+ * ColorPicker — a recessed trigger like a `Select` trigger, with a swatch and the value in Licht
76
+ * Mono, that opens a popover holding the `ColorPickerPanel`: a saturation × brightness area at the
77
+ * colour's hue, a hue slider, optional opacity, the value as text and optional presets.
78
+ *
79
+ * Use it where the person's colour is the content — a label, a calendar, a brand colour, a
80
+ * chart series of their own. The chrome around the colour stays monochrome. The rule people
81
+ * break: a picker for a choice among a few named colours. Those are a `RadioGroup` or a
82
+ * `ToggleGroup` of tones, with names.
83
+ */
84
+ export declare function ColorPicker({ value, defaultValue, onValueChange, format, size, name, required, placeholder, open, defaultOpen, onOpenChange, className, popover, disabled, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...panel }: ColorPickerProps): React.JSX.Element;
85
+ export {};
@@ -0,0 +1,407 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Field as BaseField } from "@base-ui/react/field";
4
+ import { CheckIcon, ChevronsUpDownIcon } from "lucide-react";
5
+ import * as React from "react";
6
+ import { cn, sx } from "../lib/cn.js";
7
+ import { Input } from "./input.js";
8
+ import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
9
+ import { Slider } from "./slider.js";
10
+ const clamp = (v, min = 0, max = 1) => Math.min(max, Math.max(min, v));
11
+ const round = (v, digits) => Number(v.toFixed(digits));
12
+ function hsvToRgb({ h, s, v }) {
13
+ const f = (n) => {
14
+ const k = (n + h / 60) % 6;
15
+ return v - v * s * clamp(Math.min(k, 4 - k));
16
+ };
17
+ return [f(5), f(3), f(1)];
18
+ }
19
+ /** `prev` lends its hue to a grey, and its hue and saturation to black. */
20
+ function rgbToHsv([r, g, b], a, prev) {
21
+ const max = Math.max(r, g, b);
22
+ const d = max - Math.min(r, g, b);
23
+ if (max < 1e-6)
24
+ return { h: prev?.h ?? 0, s: prev?.s ?? 0, v: 0, a };
25
+ if (d < 1e-6)
26
+ return { h: prev?.h ?? 0, s: 0, v: max, a };
27
+ const h = max === r ? ((g - b) / d) % 6 : max === g ? (b - r) / d + 2 : (r - g) / d + 4;
28
+ return { h: (h * 60 + 360) % 360, s: d / max, v: max, a };
29
+ }
30
+ function hslToRgb(h, s, l) {
31
+ const k = (n) => (n + h / 30) % 12;
32
+ const c = s * Math.min(l, 1 - l);
33
+ const f = (n) => l - c * clamp(Math.min(k(n) - 3, 9 - k(n)), -1, 1);
34
+ return [f(0), f(8), f(4)];
35
+ }
36
+ /* OKLCH, for the theme work: read and written through linear sRGB. */
37
+ const toLinear = (v) => (v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);
38
+ const toGamma = (v) => (v <= 0.0031308 ? 12.92 * v : 1.055 * v ** (1 / 2.4) - 0.055);
39
+ /** OKLCH to linear sRGB, unclamped: a channel outside 0–1 means the colour is outside sRGB. */
40
+ function oklchToLinear(l, c, h) {
41
+ const a = c * Math.cos((h * Math.PI) / 180);
42
+ const b = c * Math.sin((h * Math.PI) / 180);
43
+ const l_ = (l + 0.3963377774 * a + 0.2158037573 * b) ** 3;
44
+ const m_ = (l - 0.1055613458 * a - 0.0638541728 * b) ** 3;
45
+ const s_ = (l - 0.0894841775 * a - 1.291485548 * b) ** 3;
46
+ return [
47
+ 4.0767416621 * l_ - 3.3077115913 * m_ + 0.2309699292 * s_,
48
+ -1.2684380046 * l_ + 2.6097574011 * m_ - 0.3413193965 * s_,
49
+ -0.0041960863 * l_ - 0.7034186147 * m_ + 1.707614701 * s_,
50
+ ];
51
+ }
52
+ function rgbToOklch(rgb) {
53
+ const [r, g, b] = rgb.map(toLinear);
54
+ const l_ = Math.cbrt(0.4122214708 * r + 0.5363015719 * g + 0.0514459929 * b);
55
+ const m_ = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
56
+ const s_ = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
57
+ const L = 0.2104542553 * l_ + 0.793617785 * m_ - 0.0040720468 * s_;
58
+ const A = 1.9779984951 * l_ - 2.428592205 * m_ + 0.4505937099 * s_;
59
+ const B = 0.0259040371 * l_ + 0.7827717662 * m_ - 0.808675766 * s_;
60
+ return { l: clamp(L), c: Math.hypot(A, B), h: ((Math.atan2(B, A) * 180) / Math.PI + 360) % 360 };
61
+ }
62
+ /** An OKLCH colour in sRGB: keeps lightness and hue and lowers chroma until it fits. */
63
+ function oklchToRgb(l, c, h) {
64
+ const fits = (chroma) => oklchToLinear(l, chroma, h).every((v) => v >= -1e-4 && v <= 1 + 1e-4);
65
+ let chroma = c;
66
+ if (!fits(c)) {
67
+ let lo = 0;
68
+ for (let i = 0; i < 24; i++) {
69
+ const mid = (lo + chroma) / 2;
70
+ if (fits(mid))
71
+ lo = mid;
72
+ else
73
+ chroma = mid;
74
+ }
75
+ chroma = lo;
76
+ }
77
+ return oklchToLinear(l, chroma, h).map((v) => toGamma(clamp(v)));
78
+ }
79
+ /* Reading. */
80
+ const NUMBER = String.raw `(-?(?:\d+(?:\.\d*)?|\.\d+))`;
81
+ const alphaOf = (a, percent) => a === undefined ? 1 : clamp(Number(a) / (percent ? 100 : 1));
82
+ /**
83
+ * Reads #rgb[a], #rrggbb[aa], rgb()/rgba(), hsl()/hsla() and oklch(), with commas or spaces and
84
+ * an optional alpha. `prev` keeps the hue of a grey. Returns null for anything else — also for
85
+ * numbers too large to be numbers, so a colour is never NaN.
86
+ */
87
+ function parseColor(input, prev) {
88
+ const color = readColor(input, prev);
89
+ return color && [color.h, color.s, color.v, color.a].every(Number.isFinite) ? color : null;
90
+ }
91
+ function readColor(input, prev) {
92
+ const value = input.trim().toLowerCase();
93
+ const hex = /^#?([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.exec(value)?.[1];
94
+ if (hex) {
95
+ const full = hex.length <= 4 ? [...hex].map((d) => d + d).join("") : hex;
96
+ const [r = 0, g = 0, b = 0, a = 255] = full.match(/../g).map((p) => parseInt(p, 16) / 255);
97
+ return rgbToHsv([r, g, b], a, prev);
98
+ }
99
+ const fn = /^(rgba?|hsla?|oklch)\((.*)\)$/.exec(value);
100
+ if (!fn)
101
+ return null;
102
+ const [, name = "", body = ""] = fn;
103
+ const args = new RegExp(String.raw `^\s*${NUMBER}(%?)(?:deg)?[\s,]+${NUMBER}(%?)[\s,]+${NUMBER}(%?)(?:deg)?\s*(?:[,/]\s*${NUMBER}(%?))?\s*$`).exec(body.replace(/\bnone\b/g, "0"));
104
+ if (!args)
105
+ return null;
106
+ const [, x = "0", xp, y = "0", yp, z = "0", zp, a, ap] = args;
107
+ const alpha = alphaOf(a, ap);
108
+ if (name.startsWith("rgb")) {
109
+ const channel = (v, percent) => clamp(Number(v) / (percent ? 100 : 255));
110
+ return rgbToHsv([channel(x, xp), channel(y, yp), channel(z, zp)], alpha, prev);
111
+ }
112
+ if (name.startsWith("hsl")) {
113
+ const h = ((Number(x) % 360) + 360) % 360;
114
+ const rgb = hslToRgb(h, clamp(Number(y) / 100), clamp(Number(z) / 100));
115
+ // Hue is given outright: keep it even for a grey.
116
+ return rgbToHsv(rgb, alpha, { ...(prev ?? { s: 0, v: 0, a: 1 }), h });
117
+ }
118
+ const l = clamp(Number(x) / (xp ? 100 : 1));
119
+ const c = Math.max(0, Number(y) / (yp ? 100 / 0.4 : 1));
120
+ const h = ((Number(z) % 360) + 360) % 360;
121
+ return rgbToHsv(oklchToRgb(l, c, h), alpha, prev);
122
+ }
123
+ const byte = (v) => Math.round(clamp(v) * 255);
124
+ const percent = (v) => `${Math.round(v * 100)}%`;
125
+ const withAlpha = (body, a) => (a < 1 ? `${body} / ${percent(a)}` : body);
126
+ function formatColor(color, format) {
127
+ const rgb = hsvToRgb(color);
128
+ switch (format) {
129
+ case "rgb":
130
+ return `rgb(${withAlpha(rgb.map(byte).join(" "), color.a)})`;
131
+ case "hsl": {
132
+ const l = color.v * (1 - color.s / 2);
133
+ const s = l <= 0 || l >= 1 ? 0 : (color.v - l) / Math.min(l, 1 - l);
134
+ return `hsl(${withAlpha(`${Math.round(color.h) % 360} ${percent(s)} ${percent(l)}`, color.a)})`;
135
+ }
136
+ case "oklch": {
137
+ const { l, c, h } = rgbToOklch(rgb);
138
+ const grey = c < 0.0005;
139
+ return `oklch(${withAlpha(`${round(l, 3)} ${grey ? 0 : round(c, 3)} ${grey ? 0 : round(h, 1)}`, color.a)})`;
140
+ }
141
+ default:
142
+ return `#${[...rgb, ...(color.a < 1 ? [color.a] : [])]
143
+ .map((v) => byte(v).toString(16).padStart(2, "0"))
144
+ .join("")}`;
145
+ }
146
+ }
147
+ /** What the browser paints. */
148
+ const cssColor = (color) => formatColor(color, "rgb");
149
+ /** Whether dark ink reads better than light ink on this colour (OKLCH lightness). */
150
+ const isLight = (color) => rgbToOklch(hsvToRgb(color)).l > 0.65;
151
+ /* ── State ──────────────────────────────────────────────────────────────────── */
152
+ const FALLBACK = { h: 0, s: 0, v: 0.6, a: 1 };
153
+ /**
154
+ * The value as a string (controlled or not) and as HSV. The HSV copy is the truth while someone
155
+ * picks — it keeps the hue of a grey and the saturation of black — and is read again from the
156
+ * string only when the value changes from outside.
157
+ */
158
+ function useColorValue({ value, defaultValue, onValueChange, format, }) {
159
+ const [inner, setInner] = React.useState(defaultValue ?? "");
160
+ const current = value ?? inner;
161
+ const [color, setColor] = React.useState(() => parseColor(current) ?? FALLBACK);
162
+ const emitted = React.useRef(current);
163
+ if (current !== emitted.current) {
164
+ // Set during render (React's pattern for state derived from props): no frame with the old colour.
165
+ emitted.current = current;
166
+ const parsed = parseColor(current, color);
167
+ if (parsed)
168
+ setColor(parsed);
169
+ }
170
+ const change = (next) => {
171
+ setColor(next);
172
+ const text = formatColor(next, format);
173
+ if (text === emitted.current)
174
+ return;
175
+ emitted.current = text;
176
+ if (value === undefined)
177
+ setInner(text);
178
+ onValueChange?.(text);
179
+ };
180
+ /** A form's reset: an uncontrolled picker goes back to its default, as a native input does. */
181
+ const reset = () => setInner(defaultValue ?? "");
182
+ return { text: current, color, change, reset };
183
+ }
184
+ /**
185
+ * White to the pure hue left to right, darkened to black top to bottom — two gradients over the
186
+ * hue, edge to edge. A press anywhere jumps the thumb there and drags it; the arrow keys step it
187
+ * (Shift, Page Up/Down, Home and End for bigger steps). One focusable thumb with `role="slider"`
188
+ * carries both values in its text.
189
+ */
190
+ function ColorArea({ color, onChange, disabled, label }) {
191
+ const thumb = React.useRef(null);
192
+ const move = (event) => {
193
+ const box = event.currentTarget.getBoundingClientRect();
194
+ const s = clamp((event.clientX - box.left) / box.width);
195
+ const v = 1 - clamp((event.clientY - box.top) / box.height);
196
+ onChange({ ...color, s, v });
197
+ };
198
+ const onKeyDown = (event) => {
199
+ const step = event.shiftKey ? 0.1 : 0.01;
200
+ const steps = {
201
+ ArrowRight: { s: color.s + step },
202
+ ArrowLeft: { s: color.s - step },
203
+ ArrowUp: { v: color.v + step },
204
+ ArrowDown: { v: color.v - step },
205
+ PageUp: { v: color.v + 0.1 },
206
+ PageDown: { v: color.v - 0.1 },
207
+ Home: { s: 0 },
208
+ End: { s: 1 },
209
+ };
210
+ const next = steps[event.key];
211
+ if (!next)
212
+ return;
213
+ event.preventDefault();
214
+ // Snap to whole percents, so steps from a dragged position land on round values.
215
+ const snap = (v) => clamp(Math.round(v * 100) / 100);
216
+ onChange({ ...color, s: snap(next.s ?? color.s), v: snap(next.v ?? color.v) });
217
+ };
218
+ const saturation = Math.round(color.s * 100);
219
+ const brightness = Math.round(color.v * 100);
220
+ return (_jsxs("div", { "data-slot": "color-picker-area", "data-disabled": disabled ? "" : undefined,
221
+ // The colour is the content: a contrast theme (forced colours) must not paint over it.
222
+ className: "relative aspect-[3/2] w-full shrink-0 touch-none rounded-item forced-color-adjust-none select-none data-disabled:opacity-55", style: {
223
+ background: `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${round(color.h, 2)} 100% 50%))`,
224
+ }, onPointerDown: (event) => {
225
+ if (disabled || event.button !== 0)
226
+ return;
227
+ event.preventDefault();
228
+ event.currentTarget.setPointerCapture(event.pointerId);
229
+ thumb.current?.focus({ preventScroll: true });
230
+ move(event);
231
+ }, onPointerMove: (event) => {
232
+ if (event.currentTarget.hasPointerCapture(event.pointerId))
233
+ move(event);
234
+ }, children: [_jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-0 rounded-item border border-control-edge shadow-field" }), _jsx("div", { ref: thumb, role: "slider", tabIndex: disabled ? -1 : 0, "aria-label": label, "aria-roledescription": "2D slider", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": saturation, "aria-valuetext": `Saturation ${saturation}%, brightness ${brightness}%`, "aria-disabled": disabled || undefined, "data-slot": "color-picker-area-thumb", onKeyDown: disabled ? undefined : onKeyDown, className: cn("absolute size-[18px] -translate-x-1/2 -translate-y-1/2 cursor-grab rounded-full border-2 border-white shadow-thumb forced-color-adjust-auto active:cursor-grabbing", "focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-control-focus", disabled && "cursor-not-allowed"), style: {
235
+ // Rounded: read from oklch(), the server's maths and the browser's can differ in the
236
+ // last digits, and the page would not hydrate.
237
+ left: `${round(color.s * 100, 2)}%`,
238
+ top: `${round((1 - color.v) * 100, 2)}%`,
239
+ background: cssColor({ ...color, a: 1 }),
240
+ } })] }));
241
+ }
242
+ /* ── Panel ──────────────────────────────────────────────────────────────────── */
243
+ /** The hue circle at full saturation: red, yellow, green, cyan, blue, magenta and back to red. */
244
+ const hueTrack = `linear-gradient(to right, ${[0, 60, 120, 180, 240, 300, 360]
245
+ .map((h) => `hsl(${h} 100% 50%)`)
246
+ .join(", ")})`;
247
+ const checker = "repeating-conic-gradient(var(--field-edge) 0 25%, var(--field-surface) 0 50%) 0 0 / 8px 8px";
248
+ /*
249
+ * The Slider, its track painted: a 12px band of colour with a hairline, no indicator, and a thumb
250
+ * that wears the colour it sits on inside a white ring, like the area's.
251
+ */
252
+ const paintedSlider = cn("[&_[data-slot=slider-control]]:py-0.5", "[&_[data-slot=slider-indicator]]:hidden", "[&_[data-slot=slider-track]]:h-3 [&_[data-slot=slider-track]]:border-control-edge [&_[data-slot=slider-track]]:[background:var(--color-picker-track)]!",
253
+ // The colours are the content, also in a contrast theme; the thumb keeps the forced colours.
254
+ "[&_[data-slot=slider-thumb]]:forced-color-adjust-auto [&_[data-slot=slider-track]]:forced-color-adjust-none", "[&_[data-slot=slider-thumb]]:border-2 [&_[data-slot=slider-thumb]]:border-white [&_[data-slot=slider-thumb]]:[background:var(--color-picker-thumb)]!");
255
+ const inputLabels = {
256
+ hex: "Hex value",
257
+ rgb: "RGB value",
258
+ hsl: "HSL value",
259
+ oklch: "OKLCH value",
260
+ };
261
+ /**
262
+ * A Field of its own around each of the panel's controls. Base UI's slider and text field join the
263
+ * Field around them: inside a picker's Field they would take the picker's place as its control (its
264
+ * value in a Form), and each other's id. `contents`, so the layout doesn't see it.
265
+ */
266
+ function OwnField({ children }) {
267
+ return _jsx(BaseField.Root, { className: "contents", children: children });
268
+ }
269
+ function PanelBody({ color, text, onColorChange, format = "hex", alpha = false, presets, disabled, labels, className, ...props }) {
270
+ const [draft, setDraft] = React.useState(text);
271
+ const [invalid, setInvalid] = React.useState(false);
272
+ React.useEffect(() => {
273
+ setDraft(text);
274
+ setInvalid(false);
275
+ }, [text]);
276
+ const commit = () => {
277
+ if (draft === text)
278
+ return;
279
+ const parsed = parseColor(draft, color);
280
+ if (!parsed)
281
+ return setInvalid(true);
282
+ const next = alpha ? parsed : { ...parsed, a: 1 };
283
+ // The same colour written another way (or with different spacing): show it in the format.
284
+ if (formatColor(next, format) === text)
285
+ setDraft(text);
286
+ onColorChange(next);
287
+ };
288
+ const opaque = cssColor({ ...color, a: 1 });
289
+ const hue = Math.round(color.h) % 360;
290
+ return (_jsxs("div", { "data-slot": "color-picker-panel", className: cn("flex w-full min-w-0 flex-col gap-3", className), ...props, children: [_jsx(ColorArea, { color: color, onChange: onColorChange, disabled: disabled, label: labels?.area ?? "Saturation and brightness" }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(OwnField, { children: _jsx(Slider, { "data-slot": "color-picker-hue", min: 0, max: 360, step: 1, thumbAlignment: "edge", value: Math.round(color.h), onValueChange: (h) => onColorChange({ ...color, h }), thumbLabels: [labels?.hue ?? "Hue"], disabled: disabled, className: paintedSlider, style: {
291
+ "--color-picker-track": hueTrack,
292
+ "--color-picker-thumb": `hsl(${hue} 100% 50%)`,
293
+ } }) }), alpha && (_jsx(OwnField, { children: _jsx(Slider, { "data-slot": "color-picker-alpha", min: 0, max: 1, step: 0.01, thumbAlignment: "edge", value: color.a, onValueChange: (a) => onColorChange({ ...color, a }), format: { style: "percent" }, thumbLabels: [labels?.alpha ?? "Opacity"], disabled: disabled, className: paintedSlider, style: {
294
+ "--color-picker-track": `linear-gradient(to right, transparent, ${opaque}), ${checker}`,
295
+ "--color-picker-thumb": `linear-gradient(${cssColor(color)}, ${cssColor(color)}), ${checker}`,
296
+ } }) }))] }), _jsx(OwnField, { children: _jsx(Input, { size: "sm", "data-slot": "color-picker-input", "aria-label": labels?.input ?? inputLabels[format], "aria-invalid": invalid || undefined, spellCheck: false, autoComplete: "off", disabled: disabled, value: draft, onChange: (event) => {
297
+ setDraft(event.target.value);
298
+ setInvalid(false);
299
+ }, onBlur: commit, onKeyDown: (event) => {
300
+ // An IME's Enter picks its characters (229 marks it in Safari): not a value yet.
301
+ if (event.nativeEvent.isComposing || event.keyCode === 229)
302
+ return;
303
+ if (event.key === "Enter" && draft !== text) {
304
+ // Enter puts the typed colour in; in a form, it doesn't also submit it.
305
+ event.preventDefault();
306
+ commit();
307
+ }
308
+ if (event.key === "Escape" && draft !== text) {
309
+ // Put the value back first; a second Escape closes the popover.
310
+ event.preventDefault();
311
+ event.stopPropagation();
312
+ setDraft(text);
313
+ setInvalid(false);
314
+ }
315
+ }, className: "font-mono text-xs tabular-nums" }) }), presets && presets.length > 0 && (_jsx("div", { role: "group", "aria-label": labels?.presets ?? "Presets", "data-slot": "color-picker-presets", className: "flex flex-wrap gap-1", children: presets.map((preset) => {
316
+ const { value, label } = typeof preset === "string" ? { value: preset, label: preset } : preset;
317
+ const parsed = parseColor(value, color);
318
+ if (!parsed)
319
+ return null;
320
+ const current = formatColor(parsed, "hex") === formatColor(color, "hex");
321
+ return (_jsx("button", { type: "button", "aria-label": label, "aria-pressed": current, disabled: disabled, "data-slot": "color-picker-preset", "data-current": current ? "" : undefined, onClick: () => onColorChange(alpha ? parsed : { ...parsed, a: 1 }), className: "grid size-(--control-inset-sm) cursor-pointer place-items-center rounded-checkbox border border-control-edge focus-ring forced-color-adjust-none disabled:cursor-not-allowed disabled:opacity-55 forced-colors:focus-visible:outline-[CanvasText]", style: { background: cssColor(parsed) }, children: current && (_jsx(CheckIcon, { "aria-hidden": true, className: "size-3.5",
322
+ // Colour is the content here: the tick takes whichever ink reads on it.
323
+ style: { color: isLight(parsed) ? "oklch(0.2 0 0)" : "oklch(0.98 0 0)" } })) }, value));
324
+ }) }))] }));
325
+ }
326
+ /**
327
+ * ColorPickerPanel — the picker without its popover, to sit in a page or a panel: a saturation ×
328
+ * brightness area at the colour's hue, a hue slider, an optional opacity slider, a text field for
329
+ * the value and optional presets. Controlled (`value` + `onValueChange`) or uncontrolled
330
+ * (`defaultValue`); the value is a CSS colour string in `format`.
331
+ */
332
+ export function ColorPickerPanel({ value, defaultValue, onValueChange, format = "hex", ...props }) {
333
+ const state = useColorValue({ value, defaultValue, onValueChange, format });
334
+ return (_jsx(PanelBody, { color: state.color, text: state.text, onColorChange: state.change, format: format, ...props }));
335
+ }
336
+ /**
337
+ * ColorSwatch — a colour as a small square: 16px, 5px corners, a `--field-edge` border, over a
338
+ * checkerboard so transparency shows. Decorative (`aria-hidden`): say the colour in text beside it.
339
+ */
340
+ export function ColorSwatch({ color, className, style, ...props }) {
341
+ return (_jsx("span", { "aria-hidden": true, "data-slot": "color-swatch", className: cn("relative inline-block size-4 shrink-0 overflow-hidden rounded-checkbox border border-field-edge forced-color-adjust-none", className), style: { background: checker, ...style }, ...props, children: _jsx("span", { className: "absolute inset-0", style: { background: color } }) }));
342
+ }
343
+ /* ── ColorPicker ────────────────────────────────────────────────────────────── */
344
+ const triggerSizes = {
345
+ sm: "min-h-(--control-h-sm) gap-2 px-2.5 text-xs",
346
+ default: "min-h-(--control-h) gap-2.5 pr-2.5 pl-2.5 text-[13px]",
347
+ };
348
+ /**
349
+ * ColorPicker — a recessed trigger like a `Select` trigger, with a swatch and the value in Licht
350
+ * Mono, that opens a popover holding the `ColorPickerPanel`: a saturation × brightness area at the
351
+ * colour's hue, a hue slider, optional opacity, the value as text and optional presets.
352
+ *
353
+ * Use it where the person's colour is the content — a label, a calendar, a brand colour, a
354
+ * chart series of their own. The chrome around the colour stays monochrome. The rule people
355
+ * break: a picker for a choice among a few named colours. Those are a `RadioGroup` or a
356
+ * `ToggleGroup` of tones, with names.
357
+ */
358
+ export function ColorPicker({ value, defaultValue, onValueChange, format = "hex", size = "default", name, required, placeholder = "Pick a colour", open, defaultOpen, onOpenChange, className, popover, disabled, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...panel }) {
359
+ const state = useColorValue({ value, defaultValue, onValueChange, format });
360
+ const empty = state.text === "";
361
+ const trigger = React.useRef(null);
362
+ const valueId = React.useId();
363
+ const reset = React.useRef(state.reset);
364
+ reset.current = state.reset;
365
+ // The Field's input, and what tells the Field that focus has left the picker (for
366
+ // `validationMode="onBlur"`), set below where the Field's handlers are.
367
+ const fieldInput = React.useRef(null);
368
+ const leave = React.useRef(() => { });
369
+ React.useEffect(() => {
370
+ const form = trigger.current?.form;
371
+ if (!form)
372
+ return;
373
+ const onReset = () => reset.current();
374
+ form.addEventListener("reset", onReset);
375
+ return () => form.removeEventListener("reset", onReset);
376
+ }, []);
377
+ return (_jsxs(Popover, { open: open, defaultOpen: defaultOpen, onOpenChange: onOpenChange, children: [_jsxs(BaseField.Control, { ref: fieldInput, "data-slot": "color-picker-trigger", "data-size": size, "data-placeholder": empty || undefined,
378
+ // The value is the Field's own input's, out of sight beside the trigger, as in Base UI's
379
+ // Select: a native form submits it under `name` (or the Field's), a Form reads it for
380
+ // `onFormSubmit`, and its `required` blocks a submit while it is empty; a submit that finds
381
+ // it so focuses it, and it hands focus on to the trigger. The trigger's name is its label
382
+ // and the value, so the colour is read out with it.
383
+ value: state.text, name: name, render: (control) => {
384
+ const { ref: fieldRef, name: formName, value: formValue, onChange: fieldChange, onBlur: fieldBlur, ...button } = control;
385
+ const labelledBy = button["aria-labelledby"] ?? (button["aria-label"] ? button.id : undefined);
386
+ leave.current = () => {
387
+ if (fieldInput.current)
388
+ fieldBlur?.({ currentTarget: fieldInput.current });
389
+ };
390
+ return (_jsxs(_Fragment, { children: [_jsx(PopoverTrigger, { ...button, ref: trigger, "aria-labelledby": labelledBy ? `${labelledBy} ${valueId}` : undefined, onBlur: (event) => {
391
+ // Into the panel isn't away.
392
+ const to = event.relatedTarget;
393
+ if (!to?.closest('[data-slot="color-picker-content"]'))
394
+ leave.current();
395
+ } }), _jsx("input", { ref: fieldRef, name: formName, value: formValue ?? "", onChange: fieldChange, required: required, disabled: button.disabled, "aria-hidden": true, tabIndex: -1, autoComplete: "off", onFocus: () => trigger.current?.focus(), className: "sr-only" })] }));
396
+ }, id: id, disabled: disabled, ...Object.fromEntries(Object.entries({
397
+ "aria-label": ariaLabel,
398
+ "aria-labelledby": ariaLabelledBy,
399
+ "aria-describedby": ariaDescribedBy,
400
+ }).filter(([, v]) => v !== undefined)), className: cn("group/trigger inline-flex w-full min-w-40 material-field cursor-pointer items-center rounded-control text-start font-mono leading-none whitespace-nowrap tabular-nums outline-none select-none", "disabled:cursor-not-allowed disabled:opacity-55", triggerSizes[size], className), children: [_jsx(ColorSwatch, { color: empty ? "transparent" : cssColor(state.color), className: size === "sm" ? "size-4" : "size-5" }), _jsx("span", { id: valueId, "data-slot": "color-picker-value", className: cn("flex-1 truncate", empty && "text-control-muted"), children: empty ? placeholder : state.text }), _jsx(ChevronsUpDownIcon, { "aria-hidden": true, className: "size-4 shrink-0 text-muted-foreground transition-colors duration-(--duration) ease-brand group-hover/trigger:not-group-data-disabled/trigger:text-foreground" })] }), _jsx(PopoverContent, { align: "start", ...popover, "data-slot": "color-picker-content", className: sx("p-3", popover?.className), onBlur: (event) => {
401
+ popover?.onBlur?.(event);
402
+ // Out of the panel, and not back to the trigger: the field is left.
403
+ const to = event.relatedTarget;
404
+ if (!event.currentTarget.contains(to) && to !== trigger.current)
405
+ leave.current();
406
+ }, children: _jsx(PanelBody, { color: state.color, text: state.text, onColorChange: state.change, format: format, disabled: disabled, ...panel }) })] }));
407
+ }
@@ -0,0 +1,81 @@
1
+ import { Combobox as BaseCombobox } from "@base-ui/react/combobox";
2
+ import * as React from "react";
3
+ /**
4
+ * Combobox — a `Select` you can type into: the input filters a fixed list of options.
5
+ *
6
+ * Pass `items` (flat, or grouped as `{ value, items }[]`) and render them with a function child
7
+ * of `<ComboboxList>`. Add `multiple` and `<ComboboxChips>` for several values. Use it once a list
8
+ * is long enough that scrolling hurts (roughly 15+ options). The rule people break: using it for
9
+ * free-text search — a combobox only accepts listed values.
10
+ */
11
+ export declare function Combobox<Value, Multiple extends boolean | undefined = false, Item = Value>({ inputRef, ...props }: BaseCombobox.Root.Props<Value, Multiple, Item>): React.JSX.Element;
12
+ declare const groupSizes: {
13
+ readonly sm: "min-h-(--control-h-sm) gap-0.5 py-0.5 ps-2.5 pe-0.5 text-[13px]";
14
+ readonly default: "min-h-(--control-h) gap-0.5 py-[3px] ps-3.5 pe-[3px] text-base sm:text-[15px]";
15
+ };
16
+ export interface ComboboxInputProps extends Omit<BaseCombobox.Input.Props, "size" | "className"> {
17
+ /** `sm` (30px) for dense surfaces; `default` (38px) everywhere else. */
18
+ size?: keyof typeof groupSizes;
19
+ /** Show the chevron button that opens the list. */
20
+ showTrigger?: boolean;
21
+ /** Show a clear button while a value is selected. */
22
+ showClear?: boolean;
23
+ /** Classes for the visible field (the input group), not the bare `<input>`. */
24
+ className?: string;
25
+ }
26
+ /**
27
+ * ComboboxInput — the recessed field the user types into, with an optional clear button and
28
+ * a chevron trigger. Inside `<ComboboxChips>` it renders as the bare text input after the chips.
29
+ */
30
+ export declare function ComboboxInput({ size, showTrigger, showClear, className, ...props }: ComboboxInputProps): React.JSX.Element;
31
+ export interface ComboboxChipsProps<Value = any> extends Omit<BaseCombobox.Chips.Props, "children"> {
32
+ /**
33
+ * The chips and a trailing `<ComboboxInput />`. Pass a function to receive the selected
34
+ * values: `{(value: Service[]) => <>{value.map(…)}<ComboboxInput /></>}`.
35
+ */
36
+ children?: React.ReactNode | ((value: Value[]) => React.ReactNode);
37
+ }
38
+ /**
39
+ * ComboboxChips — the field for a `multiple` combobox: selected values as raised 30px chips,
40
+ * followed by the text input. Backspace at the start of the input removes the last chip.
41
+ */
42
+ export declare function ComboboxChips<Value = any>({ className, children, ...props }: ComboboxChipsProps<Value>): React.JSX.Element;
43
+ export interface ComboboxChipProps extends BaseCombobox.Chip.Props {
44
+ /** Accessible name for the remove button. Defaults to "Remove {label}" for string children. */
45
+ removeLabel?: string;
46
+ }
47
+ /** ComboboxChip — one selected value, with a remove button. */
48
+ export declare function ComboboxChip({ className, children, removeLabel, ...props }: ComboboxChipProps): React.JSX.Element;
49
+ export interface ComboboxContentProps extends BaseCombobox.Popup.Props {
50
+ /** Positioner props: side, align, sideOffset, collisionPadding … */
51
+ positioner?: Omit<BaseCombobox.Positioner.Props, "children">;
52
+ }
53
+ /**
54
+ * ComboboxContent — the popup: menu material, 12px corners, as wide as the field. Place
55
+ * `<ComboboxEmpty>` and `<ComboboxList>` inside it.
56
+ */
57
+ export declare function ComboboxContent({ className, children, positioner, dir, ...props }: ComboboxContentProps): React.JSX.Element;
58
+ /**
59
+ * ComboboxList — the scrolling listbox, in a ScrollArea: a thin bar while you scroll or point at
60
+ * it, and edges that fade where there is more. Give it a function child to render each
61
+ * (filtered) item.
62
+ */
63
+ export interface ComboboxListProps extends Omit<BaseCombobox.List.Props, "className"> {
64
+ /** A class string: the list is rendered as ScrollArea's viewport, which merges strings only. */
65
+ className?: string;
66
+ }
67
+ export declare function ComboboxList({ className, children, ...props }: ComboboxListProps): React.JSX.Element;
68
+ /** ComboboxItem — a 38px option with a 7px radius and a check when selected, like `SelectItem`. */
69
+ export declare function ComboboxItem({ className, children, ...props }: BaseCombobox.Item.Props): React.JSX.Element;
70
+ /**
71
+ * ComboboxEmpty — shown only when nothing matches the query. Say what to do next
72
+ * ("No service matches. Try a broader word."), not just "No results".
73
+ */
74
+ export declare function ComboboxEmpty({ className, ...props }: BaseCombobox.Empty.Props): React.JSX.Element;
75
+ /** ComboboxGroup — a labelled section. Pair with `<ComboboxGroupLabel>` and `<ComboboxCollection>`. */
76
+ export declare function ComboboxGroup({ className, ...props }: BaseCombobox.Group.Props): React.JSX.Element;
77
+ export declare function ComboboxGroupLabel({ className, ...props }: BaseCombobox.GroupLabel.Props): React.JSX.Element;
78
+ /** ComboboxCollection — renders a group's filtered items (function child), inside `<ComboboxGroup>`. */
79
+ export declare const ComboboxCollection: typeof BaseCombobox.Collection;
80
+ export declare function ComboboxSeparator({ className, ...props }: BaseCombobox.Separator.Props): React.JSX.Element;
81
+ export {};