@mortenbrudvik/waveui 0.7.0 → 0.8.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 (408) hide show
  1. package/README.md +395 -132
  2. package/dist/components/button/Button.cjs +1 -1
  3. package/dist/components/button/Button.cjs.map +1 -1
  4. package/dist/components/button/Button.mjs +36 -35
  5. package/dist/components/button/Button.mjs.map +1 -1
  6. package/dist/components/button/Button.slots.cjs +1 -1
  7. package/dist/components/button/Button.slots.cjs.map +1 -1
  8. package/dist/components/button/Button.slots.mjs +31 -21
  9. package/dist/components/button/Button.slots.mjs.map +1 -1
  10. package/dist/components/button/CompoundButton.cjs +1 -1
  11. package/dist/components/button/CompoundButton.cjs.map +1 -1
  12. package/dist/components/button/CompoundButton.mjs +31 -29
  13. package/dist/components/button/CompoundButton.mjs.map +1 -1
  14. package/dist/components/button/Link.cjs +1 -1
  15. package/dist/components/button/Link.cjs.map +1 -1
  16. package/dist/components/button/Link.mjs +24 -23
  17. package/dist/components/button/Link.mjs.map +1 -1
  18. package/dist/components/button/MenuButton.cjs +1 -1
  19. package/dist/components/button/MenuButton.cjs.map +1 -1
  20. package/dist/components/button/MenuButton.mjs +29 -28
  21. package/dist/components/button/MenuButton.mjs.map +1 -1
  22. package/dist/components/button/SplitButton.cjs +1 -1
  23. package/dist/components/button/SplitButton.cjs.map +1 -1
  24. package/dist/components/button/SplitButton.mjs +46 -45
  25. package/dist/components/button/SplitButton.mjs.map +1 -1
  26. package/dist/components/button/ToggleButton.cjs +1 -1
  27. package/dist/components/button/ToggleButton.cjs.map +1 -1
  28. package/dist/components/button/ToggleButton.mjs +38 -35
  29. package/dist/components/button/ToggleButton.mjs.map +1 -1
  30. package/dist/components/button/Toolbar.cjs +1 -1
  31. package/dist/components/button/Toolbar.cjs.map +1 -1
  32. package/dist/components/button/Toolbar.mjs +43 -42
  33. package/dist/components/button/Toolbar.mjs.map +1 -1
  34. package/dist/components/button/Toolbar.parts.cjs +1 -1
  35. package/dist/components/button/Toolbar.parts.cjs.map +1 -1
  36. package/dist/components/button/Toolbar.parts.mjs +76 -81
  37. package/dist/components/button/Toolbar.parts.mjs.map +1 -1
  38. package/dist/components/data-display/Avatar.cjs +1 -1
  39. package/dist/components/data-display/Avatar.cjs.map +1 -1
  40. package/dist/components/data-display/Avatar.mjs +72 -67
  41. package/dist/components/data-display/Avatar.mjs.map +1 -1
  42. package/dist/components/data-display/AvatarGroup.cjs +1 -1
  43. package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
  44. package/dist/components/data-display/AvatarGroup.mjs +89 -88
  45. package/dist/components/data-display/AvatarGroup.mjs.map +1 -1
  46. package/dist/components/data-display/Badge.cjs +1 -1
  47. package/dist/components/data-display/Badge.cjs.map +1 -1
  48. package/dist/components/data-display/Badge.mjs +17 -16
  49. package/dist/components/data-display/Badge.mjs.map +1 -1
  50. package/dist/components/data-display/CounterBadge.cjs +1 -1
  51. package/dist/components/data-display/CounterBadge.cjs.map +1 -1
  52. package/dist/components/data-display/CounterBadge.mjs +18 -17
  53. package/dist/components/data-display/CounterBadge.mjs.map +1 -1
  54. package/dist/components/data-display/Divider.cjs +1 -1
  55. package/dist/components/data-display/Divider.cjs.map +1 -1
  56. package/dist/components/data-display/Divider.mjs +31 -30
  57. package/dist/components/data-display/Divider.mjs.map +1 -1
  58. package/dist/components/data-display/Image.cjs +1 -1
  59. package/dist/components/data-display/Image.cjs.map +1 -1
  60. package/dist/components/data-display/Image.mjs +16 -15
  61. package/dist/components/data-display/Image.mjs.map +1 -1
  62. package/dist/components/data-display/InfoLabel.cjs +1 -1
  63. package/dist/components/data-display/InfoLabel.cjs.map +1 -1
  64. package/dist/components/data-display/InfoLabel.mjs +74 -73
  65. package/dist/components/data-display/InfoLabel.mjs.map +1 -1
  66. package/dist/components/data-display/List.cjs +1 -1
  67. package/dist/components/data-display/List.cjs.map +1 -1
  68. package/dist/components/data-display/List.mjs +175 -174
  69. package/dist/components/data-display/List.mjs.map +1 -1
  70. package/dist/components/data-display/Persona.cjs +1 -1
  71. package/dist/components/data-display/Persona.cjs.map +1 -1
  72. package/dist/components/data-display/Persona.mjs +31 -29
  73. package/dist/components/data-display/Persona.mjs.map +1 -1
  74. package/dist/components/data-display/PresenceBadge.cjs +1 -1
  75. package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
  76. package/dist/components/data-display/PresenceBadge.mjs +25 -24
  77. package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
  78. package/dist/components/data-display/Tag.cjs +1 -1
  79. package/dist/components/data-display/Tag.cjs.map +1 -1
  80. package/dist/components/data-display/Tag.mjs +87 -82
  81. package/dist/components/data-display/Tag.mjs.map +1 -1
  82. package/dist/components/feedback/MessageBar.cjs +1 -1
  83. package/dist/components/feedback/MessageBar.cjs.map +1 -1
  84. package/dist/components/feedback/MessageBar.mjs +129 -71
  85. package/dist/components/feedback/MessageBar.mjs.map +1 -1
  86. package/dist/components/feedback/MessageBar.parts.cjs +2 -0
  87. package/dist/components/feedback/MessageBar.parts.cjs.map +1 -0
  88. package/dist/components/feedback/MessageBar.parts.mjs +84 -0
  89. package/dist/components/feedback/MessageBar.parts.mjs.map +1 -0
  90. package/dist/components/feedback/MessageBar.reflow.cjs +2 -0
  91. package/dist/components/feedback/MessageBar.reflow.cjs.map +1 -0
  92. package/dist/components/feedback/MessageBar.reflow.mjs +74 -0
  93. package/dist/components/feedback/MessageBar.reflow.mjs.map +1 -0
  94. package/dist/components/feedback/MessageBar.status.cjs +1 -1
  95. package/dist/components/feedback/MessageBar.status.cjs.map +1 -1
  96. package/dist/components/feedback/MessageBar.status.mjs +2 -1
  97. package/dist/components/feedback/MessageBar.status.mjs.map +1 -1
  98. package/dist/components/feedback/ProgressBar.cjs +1 -1
  99. package/dist/components/feedback/ProgressBar.cjs.map +1 -1
  100. package/dist/components/feedback/ProgressBar.mjs +44 -43
  101. package/dist/components/feedback/ProgressBar.mjs.map +1 -1
  102. package/dist/components/feedback/Skeleton.cjs +1 -1
  103. package/dist/components/feedback/Skeleton.cjs.map +1 -1
  104. package/dist/components/feedback/Skeleton.mjs +26 -24
  105. package/dist/components/feedback/Skeleton.mjs.map +1 -1
  106. package/dist/components/feedback/Spinner.cjs +1 -1
  107. package/dist/components/feedback/Spinner.cjs.map +1 -1
  108. package/dist/components/feedback/Spinner.mjs +32 -31
  109. package/dist/components/feedback/Spinner.mjs.map +1 -1
  110. package/dist/components/feedback/Toast.cjs +1 -1
  111. package/dist/components/feedback/Toast.cjs.map +1 -1
  112. package/dist/components/feedback/Toast.context.cjs +2 -0
  113. package/dist/components/feedback/Toast.context.cjs.map +1 -0
  114. package/dist/components/feedback/Toast.context.mjs +23 -0
  115. package/dist/components/feedback/Toast.context.mjs.map +1 -0
  116. package/dist/components/feedback/Toast.mjs +10 -342
  117. package/dist/components/feedback/Toast.mjs.map +1 -1
  118. package/dist/components/feedback/Toast.parts.cjs +2 -0
  119. package/dist/components/feedback/Toast.parts.cjs.map +1 -0
  120. package/dist/components/feedback/Toast.parts.mjs +98 -0
  121. package/dist/components/feedback/Toast.parts.mjs.map +1 -0
  122. package/dist/components/feedback/Toast.root.cjs +2 -0
  123. package/dist/components/feedback/Toast.root.cjs.map +1 -0
  124. package/dist/components/feedback/Toast.root.mjs +109 -0
  125. package/dist/components/feedback/Toast.root.mjs.map +1 -0
  126. package/dist/components/feedback/Toaster.cjs +2 -0
  127. package/dist/components/feedback/Toaster.cjs.map +1 -0
  128. package/dist/components/feedback/Toaster.mjs +564 -0
  129. package/dist/components/feedback/Toaster.mjs.map +1 -0
  130. package/dist/components/input/AlphaSlider.cjs +2 -0
  131. package/dist/components/input/AlphaSlider.cjs.map +1 -0
  132. package/dist/components/input/AlphaSlider.mjs +115 -0
  133. package/dist/components/input/AlphaSlider.mjs.map +1 -0
  134. package/dist/components/input/Checkbox.cjs +1 -1
  135. package/dist/components/input/Checkbox.cjs.map +1 -1
  136. package/dist/components/input/Checkbox.mjs +47 -46
  137. package/dist/components/input/Checkbox.mjs.map +1 -1
  138. package/dist/components/input/ColorArea.cjs +2 -0
  139. package/dist/components/input/ColorArea.cjs.map +1 -0
  140. package/dist/components/input/ColorArea.mjs +204 -0
  141. package/dist/components/input/ColorArea.mjs.map +1 -0
  142. package/dist/components/input/ColorPicker.cjs +5 -5
  143. package/dist/components/input/ColorPicker.cjs.map +1 -1
  144. package/dist/components/input/ColorPicker.mjs +142 -165
  145. package/dist/components/input/ColorPicker.mjs.map +1 -1
  146. package/dist/components/input/ColorPicker.parts.cjs +2 -0
  147. package/dist/components/input/ColorPicker.parts.cjs.map +1 -0
  148. package/dist/components/input/ColorPicker.parts.mjs +192 -0
  149. package/dist/components/input/ColorPicker.parts.mjs.map +1 -0
  150. package/dist/components/input/ColorSlider.cjs +2 -0
  151. package/dist/components/input/ColorSlider.cjs.map +1 -0
  152. package/dist/components/input/ColorSlider.mjs +138 -0
  153. package/dist/components/input/ColorSlider.mjs.map +1 -0
  154. package/dist/components/input/Combobox.cjs +1 -1
  155. package/dist/components/input/Combobox.cjs.map +1 -1
  156. package/dist/components/input/Combobox.expand.cjs +1 -1
  157. package/dist/components/input/Combobox.expand.cjs.map +1 -1
  158. package/dist/components/input/Combobox.expand.mjs +9 -9
  159. package/dist/components/input/Combobox.expand.mjs.map +1 -1
  160. package/dist/components/input/Combobox.mjs +90 -85
  161. package/dist/components/input/Combobox.mjs.map +1 -1
  162. package/dist/components/input/DatePicker.cjs +1 -1
  163. package/dist/components/input/DatePicker.cjs.map +1 -1
  164. package/dist/components/input/DatePicker.mjs +186 -185
  165. package/dist/components/input/DatePicker.mjs.map +1 -1
  166. package/dist/components/input/Dropdown.cjs +1 -1
  167. package/dist/components/input/Dropdown.cjs.map +1 -1
  168. package/dist/components/input/Dropdown.mjs +71 -68
  169. package/dist/components/input/Dropdown.mjs.map +1 -1
  170. package/dist/components/input/Field.cjs +1 -1
  171. package/dist/components/input/Field.cjs.map +1 -1
  172. package/dist/components/input/Field.mjs +113 -112
  173. package/dist/components/input/Field.mjs.map +1 -1
  174. package/dist/components/input/Input.cjs +1 -1
  175. package/dist/components/input/Input.cjs.map +1 -1
  176. package/dist/components/input/Input.mjs +55 -54
  177. package/dist/components/input/Input.mjs.map +1 -1
  178. package/dist/components/input/Label.cjs +1 -1
  179. package/dist/components/input/Label.cjs.map +1 -1
  180. package/dist/components/input/Label.mjs +12 -11
  181. package/dist/components/input/Label.mjs.map +1 -1
  182. package/dist/components/input/Option.cjs +1 -1
  183. package/dist/components/input/Option.cjs.map +1 -1
  184. package/dist/components/input/Option.mjs +100 -98
  185. package/dist/components/input/Option.mjs.map +1 -1
  186. package/dist/components/input/RadioGroup.cjs +1 -1
  187. package/dist/components/input/RadioGroup.cjs.map +1 -1
  188. package/dist/components/input/RadioGroup.mjs +89 -88
  189. package/dist/components/input/RadioGroup.mjs.map +1 -1
  190. package/dist/components/input/Rating.cjs +1 -1
  191. package/dist/components/input/Rating.cjs.map +1 -1
  192. package/dist/components/input/Rating.mjs +110 -109
  193. package/dist/components/input/Rating.mjs.map +1 -1
  194. package/dist/components/input/SearchBox.cjs +1 -1
  195. package/dist/components/input/SearchBox.cjs.map +1 -1
  196. package/dist/components/input/SearchBox.mjs +118 -119
  197. package/dist/components/input/SearchBox.mjs.map +1 -1
  198. package/dist/components/input/Select.cjs +1 -1
  199. package/dist/components/input/Select.cjs.map +1 -1
  200. package/dist/components/input/Select.mjs +25 -24
  201. package/dist/components/input/Select.mjs.map +1 -1
  202. package/dist/components/input/Slider.cjs +1 -1
  203. package/dist/components/input/Slider.cjs.map +1 -1
  204. package/dist/components/input/Slider.mjs +47 -46
  205. package/dist/components/input/Slider.mjs.map +1 -1
  206. package/dist/components/input/SpinButton.cjs +1 -1
  207. package/dist/components/input/SpinButton.cjs.map +1 -1
  208. package/dist/components/input/SpinButton.mjs +76 -75
  209. package/dist/components/input/SpinButton.mjs.map +1 -1
  210. package/dist/components/input/SwatchPicker.cjs +1 -1
  211. package/dist/components/input/SwatchPicker.cjs.map +1 -1
  212. package/dist/components/input/SwatchPicker.mjs +38 -37
  213. package/dist/components/input/SwatchPicker.mjs.map +1 -1
  214. package/dist/components/input/Switch.cjs +1 -1
  215. package/dist/components/input/Switch.cjs.map +1 -1
  216. package/dist/components/input/Switch.mjs +65 -64
  217. package/dist/components/input/Switch.mjs.map +1 -1
  218. package/dist/components/input/TagPicker.cjs +1 -1
  219. package/dist/components/input/TagPicker.cjs.map +1 -1
  220. package/dist/components/input/TagPicker.mjs +161 -157
  221. package/dist/components/input/TagPicker.mjs.map +1 -1
  222. package/dist/components/input/Textarea.cjs +1 -1
  223. package/dist/components/input/Textarea.cjs.map +1 -1
  224. package/dist/components/input/Textarea.mjs +24 -23
  225. package/dist/components/input/Textarea.mjs.map +1 -1
  226. package/dist/components/input/TimePicker.cjs +1 -1
  227. package/dist/components/input/TimePicker.cjs.map +1 -1
  228. package/dist/components/input/TimePicker.mjs +202 -199
  229. package/dist/components/input/TimePicker.mjs.map +1 -1
  230. package/dist/components/input/colorName.cjs +2 -0
  231. package/dist/components/input/colorName.cjs.map +1 -0
  232. package/dist/components/input/colorName.mjs +30 -0
  233. package/dist/components/input/colorName.mjs.map +1 -0
  234. package/dist/components/input/colorUtils.cjs +1 -1
  235. package/dist/components/input/colorUtils.cjs.map +1 -1
  236. package/dist/components/input/colorUtils.mjs +154 -56
  237. package/dist/components/input/colorUtils.mjs.map +1 -1
  238. package/dist/components/layout/Accordion.cjs +1 -1
  239. package/dist/components/layout/Accordion.cjs.map +1 -1
  240. package/dist/components/layout/Accordion.mjs +130 -129
  241. package/dist/components/layout/Accordion.mjs.map +1 -1
  242. package/dist/components/layout/Card.cjs +1 -1
  243. package/dist/components/layout/Card.cjs.map +1 -1
  244. package/dist/components/layout/Card.mjs +78 -77
  245. package/dist/components/layout/Card.mjs.map +1 -1
  246. package/dist/components/layout/Carousel.cjs +1 -1
  247. package/dist/components/layout/Carousel.cjs.map +1 -1
  248. package/dist/components/layout/Carousel.mjs +111 -110
  249. package/dist/components/layout/Carousel.mjs.map +1 -1
  250. package/dist/components/layout/Flex.cjs +1 -1
  251. package/dist/components/layout/Flex.cjs.map +1 -1
  252. package/dist/components/layout/Flex.mjs +22 -21
  253. package/dist/components/layout/Flex.mjs.map +1 -1
  254. package/dist/components/layout/Grid.cjs +1 -1
  255. package/dist/components/layout/Grid.cjs.map +1 -1
  256. package/dist/components/layout/Grid.mjs +19 -18
  257. package/dist/components/layout/Grid.mjs.map +1 -1
  258. package/dist/components/layout/Overflow.cjs +1 -1
  259. package/dist/components/layout/Overflow.cjs.map +1 -1
  260. package/dist/components/layout/Overflow.mjs +92 -91
  261. package/dist/components/layout/Overflow.mjs.map +1 -1
  262. package/dist/components/layout/Stack.cjs +1 -1
  263. package/dist/components/layout/Stack.cjs.map +1 -1
  264. package/dist/components/layout/Stack.mjs +14 -13
  265. package/dist/components/layout/Stack.mjs.map +1 -1
  266. package/dist/components/layout/TabList.cjs +1 -1
  267. package/dist/components/layout/TabList.cjs.map +1 -1
  268. package/dist/components/layout/TabList.mjs +118 -117
  269. package/dist/components/layout/TabList.mjs.map +1 -1
  270. package/dist/components/layout/Tree.cjs +1 -1
  271. package/dist/components/layout/Tree.cjs.map +1 -1
  272. package/dist/components/layout/Tree.context.cjs +2 -0
  273. package/dist/components/layout/Tree.context.cjs.map +1 -0
  274. package/dist/components/layout/Tree.context.mjs +33 -0
  275. package/dist/components/layout/Tree.context.mjs.map +1 -0
  276. package/dist/components/layout/Tree.core.cjs +2 -0
  277. package/dist/components/layout/Tree.core.cjs.map +1 -0
  278. package/dist/components/layout/Tree.core.mjs +416 -0
  279. package/dist/components/layout/Tree.core.mjs.map +1 -0
  280. package/dist/components/layout/Tree.itemPersonaLayout.cjs +2 -0
  281. package/dist/components/layout/Tree.itemPersonaLayout.cjs.map +1 -0
  282. package/dist/components/layout/Tree.itemPersonaLayout.mjs +46 -0
  283. package/dist/components/layout/Tree.itemPersonaLayout.mjs.map +1 -0
  284. package/dist/components/layout/Tree.mjs +7 -215
  285. package/dist/components/layout/Tree.mjs.map +1 -1
  286. package/dist/components/layout/Tree.selection.cjs +2 -0
  287. package/dist/components/layout/Tree.selection.cjs.map +1 -0
  288. package/dist/components/layout/Tree.selection.mjs +73 -0
  289. package/dist/components/layout/Tree.selection.mjs.map +1 -0
  290. package/dist/components/navigation/Breadcrumb.cjs +1 -1
  291. package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
  292. package/dist/components/navigation/Breadcrumb.mjs +76 -75
  293. package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
  294. package/dist/components/navigation/Menu.group.cjs +1 -1
  295. package/dist/components/navigation/Menu.group.cjs.map +1 -1
  296. package/dist/components/navigation/Menu.group.mjs +39 -37
  297. package/dist/components/navigation/Menu.group.mjs.map +1 -1
  298. package/dist/components/navigation/Menu.items.cjs +1 -1
  299. package/dist/components/navigation/Menu.items.cjs.map +1 -1
  300. package/dist/components/navigation/Menu.items.mjs +67 -61
  301. package/dist/components/navigation/Menu.items.mjs.map +1 -1
  302. package/dist/components/navigation/Menu.link.cjs +1 -1
  303. package/dist/components/navigation/Menu.link.cjs.map +1 -1
  304. package/dist/components/navigation/Menu.link.mjs +34 -28
  305. package/dist/components/navigation/Menu.link.mjs.map +1 -1
  306. package/dist/components/navigation/Menu.popover.cjs +1 -1
  307. package/dist/components/navigation/Menu.popover.cjs.map +1 -1
  308. package/dist/components/navigation/Menu.popover.mjs +110 -109
  309. package/dist/components/navigation/Menu.popover.mjs.map +1 -1
  310. package/dist/components/navigation/Menu.root.cjs +1 -1
  311. package/dist/components/navigation/Menu.root.cjs.map +1 -1
  312. package/dist/components/navigation/Menu.root.mjs +171 -170
  313. package/dist/components/navigation/Menu.root.mjs.map +1 -1
  314. package/dist/components/navigation/Menu.selectable.cjs +1 -1
  315. package/dist/components/navigation/Menu.selectable.cjs.map +1 -1
  316. package/dist/components/navigation/Menu.selectable.mjs +85 -63
  317. package/dist/components/navigation/Menu.selectable.mjs.map +1 -1
  318. package/dist/components/navigation/Menu.splitGroup.cjs +1 -1
  319. package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -1
  320. package/dist/components/navigation/Menu.splitGroup.mjs +27 -26
  321. package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -1
  322. package/dist/components/navigation/Menu.trigger.cjs +1 -1
  323. package/dist/components/navigation/Menu.trigger.cjs.map +1 -1
  324. package/dist/components/navigation/Menu.trigger.mjs +6 -6
  325. package/dist/components/navigation/Nav.cjs +1 -1
  326. package/dist/components/navigation/Nav.cjs.map +1 -1
  327. package/dist/components/navigation/Nav.mjs +170 -155
  328. package/dist/components/navigation/Nav.mjs.map +1 -1
  329. package/dist/components/navigation/Pagination.cjs +1 -1
  330. package/dist/components/navigation/Pagination.cjs.map +1 -1
  331. package/dist/components/navigation/Pagination.mjs +73 -65
  332. package/dist/components/navigation/Pagination.mjs.map +1 -1
  333. package/dist/components/navigation/Stepper.cjs +1 -1
  334. package/dist/components/navigation/Stepper.cjs.map +1 -1
  335. package/dist/components/navigation/Stepper.mjs +110 -109
  336. package/dist/components/navigation/Stepper.mjs.map +1 -1
  337. package/dist/components/overlays/Dialog.cjs +1 -1
  338. package/dist/components/overlays/Dialog.cjs.map +1 -1
  339. package/dist/components/overlays/Dialog.mjs +109 -108
  340. package/dist/components/overlays/Dialog.mjs.map +1 -1
  341. package/dist/components/overlays/Drawer.cjs +1 -1
  342. package/dist/components/overlays/Drawer.cjs.map +1 -1
  343. package/dist/components/overlays/Drawer.mjs +110 -109
  344. package/dist/components/overlays/Drawer.mjs.map +1 -1
  345. package/dist/components/overlays/Popover.cjs +1 -1
  346. package/dist/components/overlays/Popover.cjs.map +1 -1
  347. package/dist/components/overlays/Popover.mjs +229 -227
  348. package/dist/components/overlays/Popover.mjs.map +1 -1
  349. package/dist/components/overlays/TeachingPopover.cjs +1 -1
  350. package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
  351. package/dist/components/overlays/TeachingPopover.mjs +41 -37
  352. package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
  353. package/dist/components/overlays/Tooltip.cjs +1 -1
  354. package/dist/components/overlays/Tooltip.cjs.map +1 -1
  355. package/dist/components/overlays/Tooltip.mjs +87 -86
  356. package/dist/components/overlays/Tooltip.mjs.map +1 -1
  357. package/dist/components/portal/Portal.cjs +1 -1
  358. package/dist/components/portal/Portal.cjs.map +1 -1
  359. package/dist/components/portal/Portal.mjs +33 -32
  360. package/dist/components/portal/Portal.mjs.map +1 -1
  361. package/dist/components/provider/WaveProvider.cjs +1 -1
  362. package/dist/components/provider/WaveProvider.cjs.map +1 -1
  363. package/dist/components/provider/WaveProvider.mjs +31 -30
  364. package/dist/components/provider/WaveProvider.mjs.map +1 -1
  365. package/dist/components/table/DataGrid.cjs +1 -1
  366. package/dist/components/table/DataGrid.cjs.map +1 -1
  367. package/dist/components/table/DataGrid.mjs +228 -227
  368. package/dist/components/table/DataGrid.mjs.map +1 -1
  369. package/dist/components/table/Table.cjs +1 -1
  370. package/dist/components/table/Table.cjs.map +1 -1
  371. package/dist/components/table/Table.mjs +60 -59
  372. package/dist/components/table/Table.mjs.map +1 -1
  373. package/dist/components/typography/Text.cjs +1 -1
  374. package/dist/components/typography/Text.cjs.map +1 -1
  375. package/dist/components/typography/Text.mjs +12 -11
  376. package/dist/components/typography/Text.mjs.map +1 -1
  377. package/dist/hooks/useMediaQuery.cjs +2 -0
  378. package/dist/hooks/useMediaQuery.cjs.map +1 -0
  379. package/dist/hooks/useMediaQuery.mjs +20 -0
  380. package/dist/hooks/useMediaQuery.mjs.map +1 -0
  381. package/dist/hooks/usePrefersReducedMotion.cjs +1 -1
  382. package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -1
  383. package/dist/hooks/usePrefersReducedMotion.mjs +4 -18
  384. package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -1
  385. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  386. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  387. package/dist/hooks/useRovingTabIndex.mjs +3 -3
  388. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  389. package/dist/index.cjs +1 -1
  390. package/dist/index.d.cts +2089 -102
  391. package/dist/index.d.ts +2089 -102
  392. package/dist/index.mjs +99 -87
  393. package/dist/lib/classNames.cjs +2 -0
  394. package/dist/lib/classNames.cjs.map +1 -0
  395. package/dist/lib/classNames.mjs +415 -0
  396. package/dist/lib/classNames.mjs.map +1 -0
  397. package/dist/lib/color.cjs +2 -0
  398. package/dist/lib/color.cjs.map +1 -0
  399. package/dist/lib/color.mjs +86 -0
  400. package/dist/lib/color.mjs.map +1 -0
  401. package/dist/lib/globalRegistry.cjs.map +1 -1
  402. package/dist/lib/globalRegistry.mjs.map +1 -1
  403. package/dist/lib/toaster.cjs +2 -0
  404. package/dist/lib/toaster.cjs.map +1 -0
  405. package/dist/lib/toaster.mjs +77 -0
  406. package/dist/lib/toaster.mjs.map +1 -0
  407. package/dist/styles.css +1 -1
  408. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPicker.mjs","names":["useId","useId$1","React","DEFAULT_COLOR","DEFAULT_LABELS","DEFAULT_PRESETS","resolvePresets","items","invalid","translucent","seen","preset","presets","color","parsed","parseHexColor","hasAlpha","stringLabel","isBlankDraft","trimmed","text","hasAlphaDigits","digits","ColorPicker","valueProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","rest","onChange","warnDeprecated","rawDefault","defaultValue","initialValue","normalizeHexColor","strings","labels","setColor","useControllable","onValueChange","next","alpha","opacity","alphaToOpacity","commit","formatHexColor","rgb","nextAlpha","draft","setDraft","syncedColor","setSyncedColor","hexText","draftInvalid","isHexDraft","presetItems","invalidPresets","translucentPresets","invalidPresetKey","translucentPresetKey","invalidValue","warnOnce","rootRef","hexInputRef","mergedRef","useMergedRefs","ref","field","useFieldContext","groupInvalid","_ariaRequired","_required","groupProps","useFieldControl","fieldInvalid","isRequired","required","errorMessageId","form","errorId","hexAriaInvalid","hexInvalidLook","isInvalidLook","handleHexChange","typed","parseHexInput","finishHexDraft","handleHexKeyDown","handlePreset","handleOpacityChange","opacityToAlpha","selectedPreset","cn","className","joinIds","inputFocus","FieldContext","SwatchPicker","showOpacity","HiddenInput"],"sources":["../../../src/components/input/ColorPicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { joinIds } from '../../lib/aria';\nimport { focusRing, inputFocus, inputInvalid } from '../../lib/styles';\nimport { useControllable } from '../../hooks/useControllable';\nimport { FieldContext, useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { isInvalidLook } from './Input';\nimport { SwatchPicker } from './SwatchPicker';\nimport type { SwatchItem } from './SwatchPicker';\nimport {\n alphaToOpacity,\n formatHexColor,\n isHexDraft,\n normalizeHexColor,\n opacityToAlpha,\n parseHexColor,\n parseHexInput,\n} from './colorUtils';\n\n/** A named preset color. */\nexport interface ColorPickerPreset {\n /**\n * Hex color (`#rrggbb`; `#rgb` is expanded). A preset has no opacity of its own: picking it keeps\n * the current opacity, so its alpha digits (`#rgba`, `#rrggbbaa`) are ignored. An alpha below\n * `f`/`ff` logs a development warning; an opaque one (`#rgbf`, `#rrggbbff`) changes nothing.\n */\n color: string;\n /** Accessible name of the preset swatch, e.g. `'Cranberry'`. */\n label: string;\n}\n\n/**\n * Texts of the ColorPicker's own parts, for localisation. Every key is optional; missing keys use\n * the English default.\n */\nexport interface ColorPickerLabels {\n /** Visible caption above the hex field.\n * @default 'Hex'\n */\n hex?: string;\n /** Accessible name of the hex text field.\n * @default 'Hex color value'\n */\n hexInput?: string;\n /** Error text shown (and used as the hex field's description) while the typed text can never be\n * a hex color, or when the field is left with text that is not one (such as `#12345`).\n * @default 'Enter a hex color such as #0f6cbd.'\n */\n hexError?: string;\n /** Accessible name of the preset swatches radiogroup.\n * @default 'Preset colors'\n */\n presets?: string;\n /** Visible label and accessible name of the opacity slider.\n * @default 'Opacity'\n */\n opacity?: string;\n}\n\n/** Properties for the ColorPicker component. */\nexport interface ColorPickerProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue'\n> {\n /**\n * Controlled hex color: `#rrggbb`, or `#rrggbbaa` with an alpha byte (e.g. `'#0f6cbd80'` for\n * 50% opacity). Other formats are not supported (development warning).\n */\n value?: string;\n /**\n * Initial hex color for uncontrolled usage (also what a form reset restores). Like every edit it\n * is shown, submitted and reported as a lowercase `#rrggbb`, or `#rrggbbaa` when it is not fully\n * opaque (`'#ABC'` becomes `'#aabbcc'`).\n * @default '#0f6cbd'\n */\n defaultValue?: string;\n /**\n * Called with the new color when it changes: a lowercase `#rrggbb`, or `#rrggbbaa` when the color\n * is not fully opaque.\n */\n onValueChange?: (color: string) => void;\n /**\n * Called with the new color when it changes.\n * @deprecated Use `onValueChange`.\n */\n onChange?: (color: string) => void;\n /**\n * Preset colors shown as quick-select swatches. Pass `{ color, label }` objects so screen reader\n * users hear a name; a plain hex string is announced by its hex code. Non-hex presets are\n * skipped (development warning). Picking a preset keeps the current opacity, so a preset's alpha\n * digits are ignored. With an alpha below `f`/`ff` (`#rgba`, `#rrggbbaa`) there is a development\n * warning, and a string preset is announced by the `#rrggbb` color it applies; an opaque alpha\n * (`#rgbf`, `#rrggbbff`) changes nothing, and the string stays the name as written.\n * @default Blue, Red, Green, Yellow, Purple, Teal, Pink and Black (Fluent brand colors)\n */\n presets?: ReadonlyArray<string | ColorPickerPreset>;\n /** Whether to show the opacity slider. The opacity is the alpha byte of `value`.\n * @default false\n */\n showOpacity?: boolean;\n /** Texts of the picker's own parts (hex field, error, presets, opacity), for localisation. */\n labels?: ColorPickerLabels;\n /** Form field name. With a name, the current color is submitted with the form. */\n name?: string;\n /**\n * Marks the hidden form input as required (a color is always chosen, so it never blocks). A\n * consumer `aria-required` has the same effect: `role=\"group\"` does not support it, so it is not\n * rendered on the group.\n */\n required?: boolean;\n /** Id of the form the picker belongs to, when it is rendered outside that form. */\n form?: string;\n /** Ref to the root `role=\"group\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// wave-allow-color: default color value (user color data, C-TOKENS exception)\nconst DEFAULT_COLOR = '#0f6cbd';\n\nconst DEFAULT_LABELS: Required<ColorPickerLabels> = {\n hex: 'Hex',\n hexInput: 'Hex color value',\n hexError: `Enter a hex color such as ${DEFAULT_COLOR}.`,\n presets: 'Preset colors',\n opacity: 'Opacity',\n};\n\nconst DEFAULT_PRESETS: readonly ColorPickerPreset[] = [\n { color: '#0f6cbd', label: 'Blue' }, // wave-allow-color: preset swatch data\n { color: '#d13438', label: 'Red' }, // wave-allow-color: preset swatch data\n { color: '#107c10', label: 'Green' }, // wave-allow-color: preset swatch data\n { color: '#ffb900', label: 'Yellow' }, // wave-allow-color: preset swatch data\n { color: '#5c2d91', label: 'Purple' }, // wave-allow-color: preset swatch data\n { color: '#008272', label: 'Teal' }, // wave-allow-color: preset swatch data\n { color: '#e3008c', label: 'Pink' }, // wave-allow-color: preset swatch data\n { color: '#242424', label: 'Black' }, // wave-allow-color: preset swatch data\n];\n\ninterface ResolvedPresets {\n items: SwatchItem[];\n /** Presets that are not hex colors (skipped). */\n invalid: string[];\n /** Presets with an alpha byte below 255, which a preset cannot apply (ignored). */\n translucent: string[];\n}\n\n/** Normalises presets to swatch items keyed by their lowercase `#rrggbb` (duplicates dropped). */\nfunction resolvePresets(presets: ReadonlyArray<string | ColorPickerPreset>): ResolvedPresets {\n const items: SwatchItem[] = [];\n const invalid: string[] = [];\n const translucent: string[] = [];\n const seen = new Set<string>();\n for (const preset of presets) {\n const color = typeof preset === 'string' ? preset : preset.color;\n const parsed = parseHexColor(color);\n if (!parsed) {\n invalid.push(color);\n continue;\n }\n // Picking a preset keeps the current opacity, so its own alpha never applies.\n const hasAlpha = parsed.alpha !== 255;\n if (hasAlpha) translucent.push(color);\n if (seen.has(parsed.rgb)) continue;\n seen.add(parsed.rgb);\n // A string preset is announced by its hex code: the color it applies, without the alpha.\n const stringLabel = hasAlpha ? parsed.rgb : color;\n items.push({\n value: parsed.rgb,\n color: parsed.rgb,\n label: typeof preset === 'string' ? stringLabel : preset.label,\n });\n }\n return { items, invalid, translucent };\n}\n\n/** The hex field's text while the user edits it (`null` state = the field shows the value). */\ninterface HexDraft {\n /** The typed text. */\n text: string;\n /** Kept after leaving the field because it is not a hex color, so it is flagged as invalid. */\n flagged: boolean;\n}\n\n/** A hex draft without digits (`''` or a lone `#`): leaving the field shows the value again. */\nfunction isBlankDraft(text: string): boolean {\n const trimmed = text.trim();\n return trimmed === '' || trimmed === '#';\n}\n\n/** Whether typed hex text carries its own alpha digits (`#rgba` or `#rrggbbaa`). */\nfunction hasAlphaDigits(text: string): boolean {\n const digits = text.trim().replace(/^#/, '').length;\n return digits === 4 || digits === 8;\n}\n\n/**\n * A color picker: a preview, a hex text field, optional preset swatches and an optional opacity\n * slider, grouped as a named `role=\"group\"`.\n *\n * - **Value**: a hex color, `#rrggbb` or `#rrggbbaa`. The opacity slider shows and edits the\n * value's alpha byte; picking a preset or typing a 6-digit hex keeps the current opacity.\n * - **Hex field**: the text is a draft (surrounding whitespace is dropped). Complete 6- or 8-digit\n * values are applied while typing; text that can never be a hex color is flagged at once\n * (`aria-invalid` plus the `hexError` description). Leaving the field or pressing Enter applies\n * a short `#rgb` (keeping the current opacity) or `#rgba`, then shows the current value again\n * (also when a controlled parent rejected the typed color); an empty field (or a lone `#`) also\n * shows the current value again. Any other text is kept and flagged instead of being thrown\n * away, until it is corrected, cleared, or the value changes from elsewhere (a preset, the\n * opacity slider, the parent, a form reset). Enter still submits the surrounding form, with the\n * color just applied; while the text is flagged, the form submits the last applied color.\n * - **Presets** render as a SwatchPicker radiogroup (\"Preset colors\"): one tab stop, arrow keys\n * move and pick, and the selected preset shows a ring and a check glyph.\n * - **Naming**: `aria-label`/`aria-labelledby` name the group; inside a `Field` its label does, and\n * the Field's hint and error describe the group. The invalid state (`aria-invalid`, from the\n * Field or the prop) is set on the hex field, since `role=\"group\"` does not support it, and the\n * hex field is then also described by the Field's error and by a consumer `aria-errormessage`\n * (which is routed to the hex field too). A consumer `aria-required` makes the hidden form input\n * required instead of reaching the group. The texts of the picker's own parts are localised with\n * `labels`.\n * - **Forms**: with `name` the color is submitted with the form; a form reset restores\n * `defaultValue` and reports it through `onValueChange` only when the color changes.\n *\n * @example\n * <ColorPicker aria-label=\"Accent color\" showOpacity value={color} onValueChange={setColor} />\n */\nexport const ColorPicker = ({\n value: valueProp,\n defaultValue,\n onValueChange,\n onChange,\n presets = DEFAULT_PRESETS,\n showOpacity = false,\n labels,\n name,\n required,\n form,\n className,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n ref,\n ...rest\n}: ColorPickerProps) => {\n if (onChange !== undefined) warnDeprecated('ColorPicker', 'onChange', 'onValueChange');\n // The default is written like every edit (C-FORMS): the picker shows, submits and restores it as\n // a lowercase `#rrggbb`/`#rrggbbaa`. A value that is not a hex color stays as given (warning\n // below).\n const rawDefault = defaultValue ?? DEFAULT_COLOR;\n const initialValue = normalizeHexColor(rawDefault) ?? rawDefault;\n const strings = { ...DEFAULT_LABELS, ...labels };\n const [color, setColor] = useControllable(valueProp, initialValue, (next: string) => {\n onValueChange?.(next);\n onChange?.(next);\n });\n\n const parsed = parseHexColor(color);\n const alpha = parsed?.alpha ?? 255;\n const opacity = alphaToOpacity(alpha);\n\n /** The single commit path: every edit is `#rrggbb` + an alpha byte. */\n const commit = (rgb: string, nextAlpha: number) => setColor(formatHexColor(rgb, nextAlpha));\n\n // The hex text is a draft over `color` while the user edits it (null = show `color`).\n const [draft, setDraft] = React.useState<HexDraft | null>(null);\n // A value change from elsewhere (a preset, the opacity slider, the parent, a form reset) replaces\n // a flagged draft, so the field never shows stale text next to the new preview (input-pickers#25).\n // While the user types, the draft is not flagged and stays.\n const [syncedColor, setSyncedColor] = React.useState(color);\n if (color !== syncedColor) {\n setSyncedColor(color);\n if (draft?.flagged) setDraft(null);\n }\n const hexText = draft?.text ?? color;\n // Text that can never be a hex color is flagged while typing; an incomplete one once the user\n // leaves the field with it (`flagged`).\n const draftInvalid =\n draft !== null && !isBlankDraft(draft.text) && (draft.flagged || !isHexDraft(draft.text));\n\n const {\n items: presetItems,\n invalid: invalidPresets,\n translucent: translucentPresets,\n } = resolvePresets(presets);\n const invalidPresetKey = invalidPresets.join('\\n');\n const translucentPresetKey = translucentPresets.join('\\n');\n const invalidValue = parsed ? null : color;\n\n React.useEffect(() => {\n if (invalidValue !== null) {\n warnOnce(\n 'ColorPicker:invalid-value',\n `ColorPicker: \"${invalidValue}\" is not a hex color (#rrggbb or #rrggbbaa). Pass a hex value; the opacity slider is disabled until then.`,\n );\n }\n }, [invalidValue]);\n React.useEffect(() => {\n if (!invalidPresetKey) return;\n for (const preset of invalidPresetKey.split('\\n')) {\n warnOnce(\n `ColorPicker:invalid-preset:${preset}`,\n `ColorPicker: preset \"${preset}\" is not a hex color (#rgb or #rrggbb) and is not shown.`,\n );\n }\n }, [invalidPresetKey]);\n React.useEffect(() => {\n if (!translucentPresetKey) return;\n for (const preset of translucentPresetKey.split('\\n')) {\n warnOnce(\n `ColorPicker:alpha-preset:${preset}`,\n `ColorPicker: preset \"${preset}\" has an alpha byte, which is ignored: picking a preset keeps the current opacity. Pass the color as #rgb or #rrggbb.`,\n );\n }\n }, [translucentPresetKey]);\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const hexInputRef = React.useRef<HTMLInputElement>(null);\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, rootRef);\n\n const field = useFieldContext();\n const fieldProps = useFieldControl(\n {\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n },\n { labelable: false },\n );\n // A group supports neither aria-invalid, aria-required nor a native `required` (ARIA 1.2): the\n // invalid state goes to the hex field and the required state to the hidden form input.\n const {\n 'aria-invalid': groupInvalid,\n 'aria-required': _ariaRequired,\n required: _required,\n ...groupProps\n } = fieldProps;\n // Any invalid state from outside (the prop or the Field, `grammar`/`spelling` included) is set on\n // the hex field as is; only `true` shows the error look.\n const fieldInvalid =\n groupInvalid !== undefined && groupInvalid !== false && groupInvalid !== 'false';\n // A consumer aria-required is not supported on the group either: it requires the hidden input.\n const isRequired =\n required ?? (ariaRequired === true || ariaRequired === 'true' || (field?.required ?? false));\n // The consumer's error message belongs to the invalid state set from outside (the prop or the\n // Field), so it is routed to the hex field only while that state is set.\n const errorMessageId = (fieldInvalid && ariaErrorMessage) || undefined;\n\n useFormReset(\n rootRef,\n () => {\n // Only a real change is reported: the same color in another spelling (a controlled `#ABC`\n // against the default `#aabbcc`) is not one.\n if ((normalizeHexColor(color) ?? color) !== initialValue) setColor(initialValue);\n setDraft(null);\n },\n form,\n );\n\n const errorId = useId('wave-color-picker-error');\n // The hex field carries the picker's invalid state: its own flagged text, or the Field's/prop's.\n const hexAriaInvalid = draftInvalid ? true : fieldInvalid ? groupInvalid : undefined;\n const hexInvalidLook = isInvalidLook(false, hexAriaInvalid);\n\n const handleHexChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n // Surrounding whitespace (a pasted `'#abcdef '`) is dropped, so the text that is checked,\n // committed and shown is the same.\n let text = e.target.value.trim();\n if (text !== '' && !text.startsWith('#')) text = `#${text}`;\n setDraft({ text, flagged: false });\n const typed = parseHexInput(text);\n // A 6-digit hex keeps the current opacity; an 8-digit one brings its own alpha.\n if (typed) commit(typed.rgb, hasAlphaDigits(text) ? typed.alpha : alpha);\n };\n\n /** Finishes the hex draft when the field is left or Enter is pressed. */\n const finishHexDraft = () => {\n if (draft === null || draft.flagged) return;\n const typed = parseHexColor(draft.text);\n if (typed || isBlankDraft(draft.text)) {\n // A short `#rgb` (current opacity) or `#rgba` is applied here; complete 6- and 8-digit\n // values were applied while typing, so a rejecting parent is not asked twice. Then the field\n // shows the current value (also when a controlled parent rejected it).\n if (typed && !parseHexInput(draft.text)) {\n commit(typed.rgb, hasAlphaDigits(draft.text) ? typed.alpha : alpha);\n }\n setDraft(null);\n return;\n }\n // Text that is not a hex color is kept and flagged instead of silently thrown away (WCAG 3.3.1).\n setDraft({ text: draft.text, flagged: true });\n };\n\n const handleHexKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n // Not prevented: Enter still submits the surrounding form, which then carries the color just\n // applied (the submit follows the keydown, after React has rendered the new value).\n if (e.key === 'Enter' && !e.defaultPrevented && !e.nativeEvent.isComposing) finishHexDraft();\n };\n\n const handlePreset = (rgb: string) => {\n // Only a preset color is committed. The presets' own form reset reports `''` (no swatch): it\n // is ignored here, and the picker's reset restores `defaultValue` (input-basic#12).\n const preset = parseHexColor(rgb);\n if (!preset) return;\n setDraft(null);\n commit(preset.rgb, alpha);\n };\n\n const handleOpacityChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (!parsed) return;\n commit(parsed.rgb, opacityToAlpha(Number(e.target.value)));\n };\n\n const selectedPreset = parsed ? parsed.rgb : '';\n\n return (\n <div\n role=\"group\"\n {...groupProps}\n className={cn(\n 'relative inline-flex flex-col gap-3 rounded border border-border bg-background p-3 shadow-4',\n className,\n )}\n {...rest}\n ref={mergedRef}\n >\n {/* Color preview and hex input */}\n <div className=\"flex items-center gap-2\">\n <div\n data-color-preview=\"\"\n className=\"h-10 w-10 shrink-0 rounded border border-border\"\n style={{ backgroundColor: parsed ? formatHexColor(parsed.rgb, parsed.alpha) : color }}\n aria-hidden=\"true\"\n />\n <label className=\"flex flex-col gap-1\">\n <span className=\"text-caption-1 text-muted-foreground\">{strings.hex}</span>\n <input\n ref={hexInputRef}\n type=\"text\"\n value={hexText}\n onChange={handleHexChange}\n onKeyDown={handleHexKeyDown}\n onBlur={finishHexDraft}\n aria-label={strings.hexInput}\n aria-invalid={hexAriaInvalid}\n aria-errormessage={errorMessageId}\n aria-describedby={joinIds(\n draftInvalid && errorId,\n field?.validationMessageId ?? (fieldInvalid ? field?.errorId : undefined),\n errorMessageId,\n )}\n maxLength={9}\n spellCheck={false}\n autoComplete=\"off\"\n className={cn(\n 'w-24 rounded border border-input border-b-stroke-accessible bg-background px-2 py-1 text-body-1 text-foreground',\n inputFocus,\n hexInvalidLook && inputInvalid,\n )}\n />\n </label>\n </div>\n {draftInvalid && (\n <span id={errorId} className=\"text-caption-1 text-error\">\n {strings.hexError}\n </span>\n )}\n\n {/* Preset swatches: the Field wiring (id, label, hint/error, invalid, required) stays on the\n group, so the nested radiogroup does not read the surrounding FieldContext. */}\n {presetItems.length > 0 && (\n <FieldContext.Provider value={null}>\n <SwatchPicker\n items={presetItems}\n value={selectedPreset}\n onValueChange={handlePreset}\n aria-label={strings.presets}\n size=\"small\"\n shape=\"rounded\"\n />\n </FieldContext.Provider>\n )}\n\n {/* Opacity slider */}\n {showOpacity && (\n <div className=\"flex items-center gap-2\">\n <span className=\"w-14 text-caption-1 text-muted-foreground\">{strings.opacity}</span>\n <input\n type=\"range\"\n min={0}\n max={100}\n value={opacity}\n onChange={handleOpacityChange}\n disabled={!parsed}\n aria-label={strings.opacity}\n aria-valuetext={`${opacity}%`}\n className={cn(\n 'h-1 flex-1 accent-primary disabled:cursor-not-allowed disabled:opacity-50',\n focusRing,\n )}\n />\n <span className=\"w-10 text-end text-caption-1 text-muted-foreground\">{opacity}%</span>\n </div>\n )}\n\n <HiddenInput\n type=\"text\"\n name={name}\n form={form}\n value={color}\n required={isRequired}\n onInvalid={() => hexInputRef.current?.focus()}\n />\n </div>\n );\n};\n\nColorPicker.displayName = 'ColorPicker';\n"],"mappings":";;;;;;;;;;;;;;;;;AA0HA,IAAMG,IAAgB,WAEhBC,IAA8C;CAClD,KAAK;CACL,UAAU;CACV,UAAU,6BA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AM;GAC7C,CAAA;EACE;;AAET;AAEA,EAAY,cAAc"}
1
+ {"version":3,"file":"ColorPicker.mjs","names":["_Fragment","React","DEFAULT_PRESETS","resolvePresets","items","invalid","translucent","seen","preset","presets","color","parsed","parseHexColor","hasAlpha","stringLabel","deriveWorkingColor","next","hexToHsv","hex","previous","ColorPickerRoot","valueProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","rest","onChange","warnDeprecated","rawDefault","defaultValue","initialValue","normalizeHexColor","strings","DEFAULT_COLOR_PICKER_LABELS","labels","setColor","useControllable","onValueChange","alpha","opacity","alphaToOpacity","presetItems","invalidPresets","translucentPresets","invalidPresetKey","translucentPresetKey","invalidValue","warnOnce","rootRef","hexInputRef","mergedRef","useMergedRefs","ref","registerHexInput","input","draftResetKey","setDraftResetKey","field","useFieldContext","groupInvalid","_ariaRequired","_required","groupProps","useFieldControl","fieldInvalid","isRequired","required","errorMessageId","key","form","pickPreset","useEventCallback","rgb","formatHexColor","hsv","setHsvState","DEFAULT_PART_COLOR","normalized","hsvToHex","setHsv","context","shape","focusInvalidTarget","root","getFirstTabbable","cn","colorPickerClassNames","className","ColorPickerContext","FieldContext","slotRendersContent","children","Fragment","ColorArea","ColorSlider","ColorPickerPreview","ColorPickerHexField","ColorPickerSwatches","showOpacity","AlphaSlider","HiddenInput","ColorPicker"],"sources":["../../../src/components/input/ColorPicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { colorPickerClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { hexToHsv, hsvToHex } from '../../lib/color';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { getFirstTabbable } from '../../lib/focus';\nimport { slotRendersContent } from '../../lib/slot';\nimport type { ColorPickerShape, HsvColor } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { FieldContext, useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { AlphaSlider } from './AlphaSlider';\nimport { ColorArea } from './ColorArea';\nimport { ColorSlider } from './ColorSlider';\nimport type { SwatchItem } from './SwatchPicker';\nimport {\n ColorPickerContext,\n ColorPickerHexField,\n ColorPickerPreview,\n ColorPickerSwatches,\n DEFAULT_COLOR,\n DEFAULT_COLOR_PICKER_LABELS,\n DEFAULT_PART_COLOR,\n type ColorPickerContextValue,\n type ColorPickerLabels,\n} from './ColorPicker.parts';\nimport { alphaToOpacity, formatHexColor, normalizeHexColor, parseHexColor } from './colorUtils';\n\nexport { ColorPickerHexField, ColorPickerPreview, ColorPickerSwatches };\nexport type { ColorPickerLabels };\nexport type {\n ColorPickerHexFieldProps,\n ColorPickerPreviewProps,\n ColorPickerSwatchesProps,\n} from './ColorPicker.parts';\n\n/** A named preset color. */\nexport interface ColorPickerPreset {\n /**\n * Hex color (`#rrggbb`; `#rgb` is expanded). A preset has no opacity of its own: picking it keeps\n * the current opacity, so its alpha digits (`#rgba`, `#rrggbbaa`) are ignored. An alpha below\n * `f`/`ff` logs a development warning; an opaque one (`#rgbf`, `#rrggbbff`) changes nothing.\n */\n color: string;\n /** Accessible name of the preset swatch, e.g. `'Cranberry'`. */\n label: string;\n}\n\n/** Properties for the ColorPicker component. */\nexport interface ColorPickerProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue'\n> {\n /**\n * Controlled hex color: `#rrggbb`, or `#rrggbbaa` with an alpha byte (e.g. `'#0f6cbd80'` for\n * 50% opacity). Other formats are not supported (development warning).\n */\n value?: string;\n /**\n * Initial hex color for uncontrolled usage (also what a form reset restores). Like every edit it\n * is shown, submitted and reported as a lowercase `#rrggbb`, or `#rrggbbaa` when it is not fully\n * opaque (`'#ABC'` becomes `'#aabbcc'`).\n * @default '#0f6cbd'\n */\n defaultValue?: string;\n /**\n * Called with the new color when it changes: a lowercase `#rrggbb`, or `#rrggbbaa` when the color\n * is not fully opaque.\n */\n onValueChange?: (color: string) => void;\n /**\n * Called with the new color when it changes.\n * @deprecated Use `onValueChange`.\n */\n onChange?: (color: string) => void;\n /**\n * Preset colors shown as quick-select swatches. Pass `{ color, label }` objects so screen reader\n * users hear a name; a plain hex string is announced by its hex code. Non-hex presets are\n * skipped (development warning). Picking a preset keeps the current opacity, so a preset's alpha\n * digits are ignored. With an alpha below `f`/`ff` (`#rgba`, `#rrggbbaa`) there is a development\n * warning, and a string preset is announced by the `#rrggbb` color it applies; an opaque alpha\n * (`#rgbf`, `#rrggbbff`) changes nothing, and the string stays the name as written. With\n * `children`, the presets feed only `ColorPicker.Swatches`.\n * @default Blue, Red, Green, Yellow, Purple, Teal, Pink and Black (Fluent brand colors)\n */\n presets?: ReadonlyArray<string | ColorPickerPreset>;\n /**\n * Whether the default layout shows the opacity row: the caption, an alpha slider (0–100 %,\n * named by `labels.opacity`) and the percentage. The opacity is the alpha byte of `value`. Does\n * nothing with `children`.\n * @default false\n */\n showOpacity?: boolean;\n /** Texts of the picker's own parts and of the color parts bound to it, for localisation. */\n labels?: ColorPickerLabels;\n /**\n * `'square'` removes the corner radius of the preview and of the area and the rails of the\n * color parts bound to it, including those of the default layout.\n * @default 'rounded'\n */\n shape?: ColorPickerShape;\n /**\n * Your own layout: `ColorArea`, `ColorSlider` and `AlphaSlider` (bound to the picker while they\n * have neither `value` nor `defaultValue`) and the parts `ColorPicker.HexField`,\n * `ColorPicker.Swatches` and `ColorPicker.Preview`. Without children the picker renders its\n * default layout. With children, `showOpacity` does nothing and `presets` feed only\n * `ColorPicker.Swatches`.\n */\n children?: React.ReactNode;\n /** Form field name. With a name, the current color is submitted with the form. */\n name?: string;\n /**\n * Marks the hidden form input as required (a color is always chosen, so it never blocks). A\n * consumer `aria-required` has the same effect: `role=\"group\"` does not support it, so it is not\n * rendered on the group.\n */\n required?: boolean;\n /** Id of the form the picker belongs to, when it is rendered outside that form. */\n form?: string;\n /** Ref to the root `role=\"group\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst DEFAULT_PRESETS: readonly ColorPickerPreset[] = [\n { color: '#0f6cbd', label: 'Blue' }, // wave-allow-color: preset swatch data\n { color: '#d13438', label: 'Red' }, // wave-allow-color: preset swatch data\n { color: '#107c10', label: 'Green' }, // wave-allow-color: preset swatch data\n { color: '#ffb900', label: 'Yellow' }, // wave-allow-color: preset swatch data\n { color: '#5c2d91', label: 'Purple' }, // wave-allow-color: preset swatch data\n { color: '#008272', label: 'Teal' }, // wave-allow-color: preset swatch data\n { color: '#e3008c', label: 'Pink' }, // wave-allow-color: preset swatch data\n { color: '#242424', label: 'Black' }, // wave-allow-color: preset swatch data\n];\n\ninterface ResolvedPresets {\n items: SwatchItem[];\n /** Presets that are not hex colors (skipped). */\n invalid: string[];\n /** Presets with an alpha byte below 255, which a preset cannot apply (ignored). */\n translucent: string[];\n}\n\n/** Normalises presets to swatch items keyed by their lowercase `#rrggbb` (duplicates dropped). */\nfunction resolvePresets(presets: ReadonlyArray<string | ColorPickerPreset>): ResolvedPresets {\n const items: SwatchItem[] = [];\n const invalid: string[] = [];\n const translucent: string[] = [];\n const seen = new Set<string>();\n for (const preset of presets) {\n const color = typeof preset === 'string' ? preset : preset.color;\n const parsed = parseHexColor(color);\n if (!parsed) {\n invalid.push(color);\n continue;\n }\n // Picking a preset keeps the current opacity, so its own alpha never applies.\n const hasAlpha = parsed.alpha !== 255;\n if (hasAlpha) translucent.push(color);\n if (seen.has(parsed.rgb)) continue;\n seen.add(parsed.rgb);\n // A string preset is announced by its hex code: the color it applies, without the alpha.\n const stringLabel = hasAlpha ? parsed.rgb : color;\n items.push({\n value: parsed.rgb,\n color: parsed.rgb,\n label: typeof preset === 'string' ? stringLabel : preset.label,\n });\n }\n return { items, invalid, translucent };\n}\n\n/**\n * The working color for a hex value that differs from it: the value's HSV, keeping the previous\n * hue when the new color has no hue of its own (a gray, white or black) and the previous\n * saturation too at zero brightness, so a hue slider does not jump to red when the color reaches\n * gray. `hsvToHex` of the result is `hex` again.\n */\nfunction deriveWorkingColor(hex: string, previous: HsvColor): HsvColor {\n const next = hexToHsv(hex);\n if (!next) return previous;\n if (next.v === 0) return { ...next, h: previous.h, s: previous.s };\n if (next.s === 0) return { ...next, h: previous.h };\n return next;\n}\n\n// The ColorPicker root, documented on the exported `ColorPicker` const.\nconst ColorPickerRoot = ({\n value: valueProp,\n defaultValue,\n onValueChange,\n onChange,\n presets = DEFAULT_PRESETS,\n showOpacity = false,\n labels,\n shape = 'rounded',\n name,\n required,\n form,\n className,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n children,\n ref,\n ...rest\n}: ColorPickerProps) => {\n if (onChange !== undefined) warnDeprecated('ColorPicker', 'onChange', 'onValueChange');\n // The default is written like every edit (C-FORMS): the picker shows, submits and restores it as\n // a lowercase `#rrggbb`/`#rrggbbaa`. A value that is not a hex color stays as given (warning\n // below).\n const rawDefault = defaultValue ?? DEFAULT_COLOR;\n const initialValue = normalizeHexColor(rawDefault) ?? rawDefault;\n const strings = React.useMemo(() => ({ ...DEFAULT_COLOR_PICKER_LABELS, ...labels }), [labels]);\n const [color, setColor] = useControllable(valueProp, initialValue, (next: string) => {\n onValueChange?.(next);\n onChange?.(next);\n });\n\n const parsed = React.useMemo(() => parseHexColor(color), [color]);\n const alpha = parsed?.alpha ?? 255;\n const opacity = alphaToOpacity(alpha);\n\n const {\n items: presetItems,\n invalid: invalidPresets,\n translucent: translucentPresets,\n } = React.useMemo(() => resolvePresets(presets), [presets]);\n const invalidPresetKey = invalidPresets.join('\\n');\n const translucentPresetKey = translucentPresets.join('\\n');\n const invalidValue = parsed ? null : color;\n\n React.useEffect(() => {\n if (invalidValue !== null) {\n warnOnce(\n 'ColorPicker:invalid-value',\n `ColorPicker: \"${invalidValue}\" is not a hex color (#rrggbb or #rrggbbaa). Pass a hex value; the color area and sliders are disabled until then.`,\n );\n }\n }, [invalidValue]);\n React.useEffect(() => {\n if (!invalidPresetKey) return;\n for (const preset of invalidPresetKey.split('\\n')) {\n warnOnce(\n `ColorPicker:invalid-preset:${preset}`,\n `ColorPicker: preset \"${preset}\" is not a hex color (#rgb or #rrggbb) and is not shown.`,\n );\n }\n }, [invalidPresetKey]);\n React.useEffect(() => {\n if (!translucentPresetKey) return;\n for (const preset of translucentPresetKey.split('\\n')) {\n warnOnce(\n `ColorPicker:alpha-preset:${preset}`,\n `ColorPicker: preset \"${preset}\" has an alpha byte, which is ignored: picking a preset keeps the current opacity. Pass the color as #rgb or #rrggbb.`,\n );\n }\n }, [translucentPresetKey]);\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const hexInputRef = React.useRef<HTMLInputElement | null>(null);\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, rootRef);\n const registerHexInput = React.useCallback((input: HTMLInputElement | null) => {\n hexInputRef.current = input;\n }, []);\n // Changes whenever the hex field must drop its draft: a form reset or a preset pick.\n const [draftResetKey, setDraftResetKey] = React.useState(0);\n\n const field = useFieldContext();\n const fieldProps = useFieldControl(\n {\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n },\n { labelable: false },\n );\n // A group supports neither aria-invalid, aria-required nor a native `required` (ARIA 1.2): the\n // invalid state goes to the hex field and the required state to the hidden form input.\n const {\n 'aria-invalid': groupInvalid,\n 'aria-required': _ariaRequired,\n required: _required,\n ...groupProps\n } = fieldProps;\n const fieldInvalid =\n groupInvalid !== undefined && groupInvalid !== false && groupInvalid !== 'false';\n // A consumer aria-required is not supported on the group either: it requires the hidden input.\n const isRequired =\n required ?? (ariaRequired === true || ariaRequired === 'true' || (field?.required ?? false));\n // The consumer's error message belongs to the invalid state set from outside (the prop or the\n // Field), so it is routed to the hex field only while that state is set.\n const errorMessageId = (fieldInvalid && ariaErrorMessage) || undefined;\n\n useFormReset(\n rootRef,\n () => {\n // Only a real change is reported: the same color in another spelling (a controlled `#ABC`\n // against the default `#aabbcc`) is not one.\n if ((normalizeHexColor(color) ?? color) !== initialValue) setColor(initialValue);\n setDraftResetKey((key) => key + 1);\n },\n form,\n );\n\n const pickPreset = useEventCallback((rgb: string) => {\n // Only a preset color is committed. The presets' own form reset reports `''` (no swatch): it\n // is ignored here, and the picker's reset restores `defaultValue` (input-basic#12).\n const preset = parseHexColor(rgb);\n if (!preset) return;\n setDraftResetKey((key) => key + 1);\n setColor(formatHexColor(preset.rgb, alpha));\n });\n\n // The working color: HSV, so hue and saturation survive gray, white and black (hex keeps\n // neither). The value stays the source of truth: whenever it differs from the working color (a\n // change from outside, a form reset, or a controlled parent that ignored onValueChange), the\n // working color follows it. A parent that accepts a change sets exactly `hsvToHex(hsv)`, so the\n // working color is kept.\n const [hsv, setHsvState] = React.useState<HsvColor>(() =>\n deriveWorkingColor(color, DEFAULT_PART_COLOR),\n );\n const normalized = parsed ? formatHexColor(parsed.rgb, parsed.alpha) : null;\n if (normalized !== null && hsvToHex(hsv) !== normalized) {\n setHsvState(deriveWorkingColor(normalized, hsv));\n }\n const setHsv = useEventCallback((next: HsvColor) => {\n if (!parsed) return;\n setHsvState(next);\n setColor(hsvToHex(next));\n });\n\n const context = React.useMemo<ColorPickerContextValue>(\n () => ({\n hsv,\n setHsv,\n color,\n parsed,\n setColor,\n pickPreset,\n presetItems,\n shape,\n labels: strings,\n disabled: parsed === null,\n draftResetKey,\n field,\n groupInvalid,\n errorMessageId,\n registerHexInput,\n }),\n [\n hsv,\n setHsv,\n color,\n parsed,\n setColor,\n pickPreset,\n presetItems,\n shape,\n strings,\n draftResetKey,\n field,\n groupInvalid,\n errorMessageId,\n registerHexInput,\n ],\n );\n\n /** The hidden input's `onInvalid`: the hex field when there is one, else the first tabbable element. */\n const focusInvalidTarget = () => {\n const root = rootRef.current;\n (hexInputRef.current ?? (root ? getFirstTabbable(root) : null))?.focus();\n };\n\n return (\n <div\n role=\"group\"\n {...groupProps}\n className={cn(\n colorPickerClassNames.root,\n 'relative inline-flex flex-col gap-3 rounded border border-border bg-background p-3 shadow-4',\n className,\n )}\n {...rest}\n ref={mergedRef}\n >\n <ColorPickerContext.Provider value={context}>\n {/* The Field wiring (id, label, hint and error, invalid, required) stays on the group:\n the parts inside never read the surrounding FieldContext. */}\n <FieldContext.Provider value={null}>\n {slotRendersContent(children) ? (\n children\n ) : (\n <>\n <ColorArea />\n <ColorSlider />\n <div className=\"flex items-start gap-2\">\n <ColorPickerPreview />\n <ColorPickerHexField />\n </div>\n <ColorPickerSwatches />\n {showOpacity && (\n <div className=\"flex items-center gap-2\">\n <span\n className={cn(\n colorPickerClassNames.opacityLabel,\n 'w-14 text-caption-1 text-muted-foreground',\n )}\n >\n {strings.opacity}\n </span>\n <AlphaSlider className=\"min-w-0 flex-1\" />\n <span\n className={cn(\n colorPickerClassNames.opacityValue,\n 'w-10 text-end text-caption-1 text-muted-foreground',\n )}\n >\n {opacity}%\n </span>\n </div>\n )}\n </>\n )}\n </FieldContext.Provider>\n </ColorPickerContext.Provider>\n <HiddenInput\n type=\"text\"\n name={name}\n form={form}\n value={color}\n required={isRequired}\n onInvalid={focusInvalidTarget}\n />\n </div>\n );\n};\n\nColorPickerRoot.displayName = 'ColorPicker';\n\n/**\n * A color picker whose value is a hex string (`#rrggbb`, or `#rrggbbaa` with an alpha byte),\n * grouped as a named `role=\"group\"`.\n *\n * - **Default layout** (no children): a color area (saturation and brightness) and a hue slider,\n * then a preview and the hex field, preset swatches and, with `showOpacity`, an opacity row\n * whose slider is an `AlphaSlider` (0–100 %). Dragging to gray, white or black keeps the hue.\n * - **Your own layout** (children): `ColorArea`, `ColorSlider` and `AlphaSlider`, which bind to\n * the picker while they have neither `value` nor `defaultValue`, and the parts\n * `ColorPicker.HexField`, `ColorPicker.Swatches` and `ColorPicker.Preview`.\n * - **Hex field**: the text is a draft. Complete 6- and 8-digit values apply while typing; text\n * that can never be a hex color is flagged at once (`aria-invalid` plus the `hexError`\n * description). Leaving the field or pressing Enter applies a short `#rgb` (keeping the current\n * opacity) or `#rgba`, then shows the current value again; other text stays flagged until it is\n * corrected, cleared, or the value changes from elsewhere. Enter still submits the surrounding\n * form, with the color just applied.\n * - **Presets** render as a SwatchPicker radiogroup (\"Preset colors\"): one tab stop, arrow keys\n * move and pick, and picking keeps the current opacity.\n * - **Naming**: `aria-label`/`aria-labelledby` name the group; inside a `Field` its label does,\n * and the Field's hint and error describe the group. The invalid state (`aria-invalid`, from the\n * Field or the prop) is set on the hex field, since `role=\"group\"` does not support it, and a\n * consumer `aria-errormessage` goes there too. A consumer `aria-required` makes the hidden form\n * input required instead. The built-in texts are localised with `labels`.\n * - **Forms**: with `name` the color is submitted with the form; a form reset restores\n * `defaultValue` and reports it through `onValueChange` only when the color changes.\n *\n * React Server Components cannot dot into a client module: import the flat names\n * `ColorPickerHexField`, `ColorPickerSwatches` and `ColorPickerPreview` there;\n * `ColorPicker.HexField` etc. work in client files.\n *\n * @example\n * <ColorPicker aria-label=\"Accent color\" showOpacity value={color} onValueChange={setColor} />\n *\n * <ColorPicker aria-label=\"Accent color\" value={color} onValueChange={setColor}>\n * <ColorArea />\n * <ColorSlider />\n * <ColorPicker.HexField />\n * </ColorPicker>\n */\nexport const ColorPicker = /* @__PURE__ */ Object.assign(ColorPickerRoot, {\n HexField: ColorPickerHexField,\n Swatches: ColorPickerSwatches,\n Preview: ColorPickerPreview,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8HA,IAAME,KAAgD;CACpD;EAAE,OAAO;EAAW,OAAO;CAAO;CAClC;EAAE,OAAO;EAAW,OAAO;CAAM;CACjC;EAAE,OAAO;EAAW,OAAO;CAAQ;CACnC;EAAE,OAAO;EAAW,OAAO;CAAS;CACpC;EAAE,OAAO;EAAW,OAAO;CAAS;CACpC;E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;AAyC9B,IAAamB,IAA8B,uBAAO,OAAOpF,GAAiB;CACxE,UAAU+E;CACV,UAAUC;CACV,SAASF;AACX,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/composeEventHandlers.cjs"),i=require("../../lib/classNames.cjs"),a=require("../../hooks/useControllable.cjs"),o=require("../../hooks/useId.cjs"),s=require("../../hooks/useMergedRefs.cjs"),c=require("../../lib/aria.cjs"),l=require("../../lib/styles.cjs"),u=require("./Input.cjs"),d=require("./colorUtils.cjs"),f=require("./SwatchPicker.cjs");let p=require("react");p=e.__toESM(p,1);let m=require("react/jsx-runtime");var h=`#0f6cbd`,g={h:208,s:.92,v:.74},_={hex:`Hex`,hexInput:`Hex color value`,hexError:`Enter a hex color such as ${h}.`,presets:`Preset colors`,opacity:`Opacity`,area:`Saturation and brightness`,saturation:`Saturation`,brightness:`Brightness`,roleDescription:`2D slider`,hue:`Hue`,transparency:`Transparency`},v=p.createContext(null);v.displayName=`ColorPickerContext`;function y(){return p.useContext(v)}var b=()=>{};function x({value:e,defaultValue:t,onValueChange:n,disabled:r}){let i=y(),o=i!==null&&e===void 0&&t===void 0?i:null,s=t??g,[c,l]=a.useControllable(e,s,o?void 0:n);return o?{picker:o,color:o.hsv,setColor:e=>{o.setHsv(e),n?.(e)},reset:b,disabled:r||o.disabled}:{picker:null,color:c,setColor:l,reset:()=>{d.sameColor(c,s)||l(s)},disabled:r}}var S={hsv:g,setHsv:b,color:h,parsed:null,setColor:b,pickPreset:b,presetItems:[],shape:`rounded`,labels:_,disabled:!0,draftResetKey:0,field:null,groupInvalid:void 0,errorMessageId:void 0,registerHexInput:b};function C(e){return p.useContext(v)||(n.reportMissingContext(e,`<ColorPicker>`),S)}function w(e){let t=e.trim();return t===``||t===`#`}function T(e){let t=e.trim().replace(/^#/,``).length;return t===4||t===8}var E=({id:e,"aria-label":n,"aria-labelledby":a,"aria-describedby":f,"aria-invalid":h,"aria-errormessage":g,"aria-details":_,"aria-required":v,autoFocus:y,tabIndex:b,onFocus:x,onBlur:S,onKeyDown:E,onKeyUp:D,inputMode:O,enterKeyHint:k,autoCapitalize:ee,autoCorrect:te,spellCheck:ne,controlRef:re,className:A,ref:j,...M})=>{let N=C(`ColorPicker.HexField`),{color:P,parsed:ie,field:F,groupInvalid:I,errorMessageId:L,labels:R}=N,z=ie?.alpha??255,[B,V]=p.useState(null),[H,U]=p.useState(P);P!==H&&(U(P),B?.flagged&&V(null));let[W,G]=p.useState(N.draftResetKey);N.draftResetKey!==W&&(G(N.draftResetKey),V(null));let K=B?.text??P,q=B!==null&&!w(B.text)&&(B.flagged||!d.isHexDraft(B.text)),J=I!==void 0&&I!==!1&&I!==`false`,Y=o.useId(`wave-color-picker-error`),X=h??(q?!0:J?I:void 0),ae=u.isInvalidLook(!1,X),oe=p.useRef(null),se=s.useMergedRefs(oe,re,N.registerHexInput),Z=(e,t)=>N.setColor(d.formatHexColor(e,t)),Q=e=>{let t=e.target.value.trim();t!==``&&!t.startsWith(`#`)&&(t=`#${t}`),V({text:t,flagged:!1});let n=d.parseHexInput(t);n&&Z(n.rgb,T(t)?n.alpha:z)},$=()=>{if(B===null||B.flagged)return;let e=d.parseHexColor(B.text);if(e||w(B.text)){e&&!d.parseHexInput(B.text)&&Z(e.rgb,T(B.text)?e.alpha:z),V(null);return}V({text:B.text,flagged:!0})},ce=r.composeEventHandlers(S,$),le=r.composeEventHandlers(E,e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&$()});return(0,m.jsxs)(`label`,{ref:j,className:t.cn(i.colorPickerHexFieldClassNames.root,`flex min-w-0 flex-col gap-1`,A),...M,children:[(0,m.jsx)(`span`,{className:t.cn(i.colorPickerHexFieldClassNames.label,`text-caption-1 text-muted-foreground`),children:R.hex}),(0,m.jsx)(`input`,{ref:se,id:e,type:`text`,value:K,onChange:Q,onKeyDown:le,onKeyUp:D,onFocus:x,onBlur:ce,"aria-label":n??(a===void 0?R.hexInput:void 0),"aria-labelledby":a,"aria-invalid":X,"aria-errormessage":g??L,"aria-describedby":c.joinIds(q&&Y,F?.validationMessageId??(J?F?.errorId:void 0),L,f),"aria-details":_,"aria-required":v,autoFocus:y,tabIndex:b,inputMode:O,enterKeyHint:k,autoCapitalize:ee,autoCorrect:te,spellCheck:ne??!1,maxLength:9,autoComplete:`off`,className:t.cn(i.colorPickerHexFieldClassNames.input,`w-24 rounded border border-input border-b-stroke-accessible bg-background px-2 py-1 text-body-1 text-foreground`,l.inputFocus,ae&&`border-destructive focus:border-b-destructive`)}),q&&(0,m.jsx)(`span`,{id:Y,className:t.cn(i.colorPickerHexFieldClassNames.errorMessage,`text-caption-1 text-error`),children:R.hexError})]})};E.displayName=`ColorPickerHexField`;var D=({className:e,"aria-label":n,size:r=`small`,shape:a=`rounded`,...o})=>{let s=C(`ColorPicker.Swatches`);return s.presetItems.length===0?null:(0,m.jsx)(f.SwatchPicker,{"aria-label":n??(o[`aria-labelledby`]===void 0?s.labels.presets:void 0),size:r,shape:a,...o,className:t.cn(i.colorPickerSwatchesClassNames.root,e),items:s.presetItems,value:s.parsed?s.parsed.rgb:``,onValueChange:s.pickPreset})};D.displayName=`ColorPickerSwatches`;var O=({className:e,style:n,ref:r,...a})=>{let o=C(`ColorPicker.Preview`),s=o.parsed?d.formatHexColor(o.parsed.rgb,o.parsed.alpha):o.color;return(0,m.jsx)(`div`,{"data-color-preview":``,"aria-hidden":`true`,...a,ref:r,className:t.cn(i.colorPickerPreviewClassNames.root,`h-10 w-10 shrink-0 rounded border border-border forced-colors:forced-color-adjust-none`,o.shape===`square`&&`rounded-none`,e),style:{...n,backgroundColor:s}})};O.displayName=`ColorPickerPreview`,exports.ColorPickerContext=v,exports.ColorPickerHexField=E,exports.ColorPickerPreview=O,exports.ColorPickerSwatches=D,exports.DEFAULT_COLOR=h,exports.DEFAULT_COLOR_PICKER_LABELS=_,exports.DEFAULT_PART_COLOR=g,exports.useColorPartState=x,exports.useColorPickerContext=y,exports.usePickerPartContext=C;
2
+ //# sourceMappingURL=ColorPicker.parts.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorPicker.parts.cjs","names":["React","useControllable","sameColor","isHexDraft","useId","isInvalidLook","useMergedRefs","formatHexColor","parseHexInput","parseHexColor","composeEventHandlers","cn","colorPickerHexFieldClassNames","joinIds","inputFocus","SwatchPicker","colorPickerSwatchesClassNames","colorPickerPreviewClassNames","require_runtime","require_cn","require_dev","require_composeEventHandlers","require_classNames","require_useControllable","require_useId","require_useMergedRefs","require_aria","require_styles","require_Input","require_colorUtils","require_SwatchPicker","react","react_jsx_runtime","DEFAULT_COLOR","DEFAULT_PART_COLOR","DEFAULT_COLOR_PICKER_LABELS","ColorPickerContext","useColorPickerContext","noop","useColorPartState","context","picker","value","defaultValue","initial","own","setOwn","onValueChange","next","disabled","INERT_PICKER_CONTEXT","usePickerPartContext","componentName","isBlankDraft","trimmed","text","hasAlphaDigits","digits","ColorPickerHexField","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaErrorMessage","ariaDetails","ariaRequired","rest","alpha","parsed","draft","setDraft","syncedColor","setSyncedColor","color","seenResetKey","setSeenResetKey","hexText","draftInvalid","fieldInvalid","groupInvalid","errorId","resolvedInvalid","invalidLook","inputRef","mergedInputRef","controlRef","commit","rgb","nextAlpha","handleChange","event","typed","finishDraft","handleBlur","onBlur","handleKeyDown","onKeyDown","className","labels","errorMessageId","field","spellCheck","ColorPickerSwatches","ColorPickerPreview","shown","style"],"sources":["../../../src/components/input/ColorPicker.parts.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useControllable } from '../../hooks/useControllable';\nimport type { FieldContextValue } from '../../hooks/useFieldControl';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { joinIds } from '../../lib/aria';\nimport {\n colorPickerHexFieldClassNames,\n colorPickerPreviewClassNames,\n colorPickerSwatchesClassNames,\n} from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { reportMissingContext } from '../../lib/dev';\nimport { inputFocus, inputInvalid } from '../../lib/styles';\nimport type { ColorPickerShape, HsvColor } from '../../lib/types';\nimport { isInvalidLook } from './Input';\nimport { SwatchPicker, type SwatchItem, type SwatchPickerProps } from './SwatchPicker';\nimport {\n formatHexColor,\n isHexDraft,\n parseHexColor,\n parseHexInput,\n sameColor,\n type HexColor,\n} from './colorUtils';\n\n/*\n * The picker's labels and context, and how the standalone color parts bind to it (spec P3-05,\n * D21). `ColorArea`, `ColorSlider` and `AlphaSlider` read the context; `ColorPicker.tsx` provides\n * it and renders the picker-only parts. This module never imports `ColorPicker.tsx`.\n */\n\n// wave-allow-color: default color value (user color data, C-TOKENS exception)\nexport const DEFAULT_COLOR = '#0f6cbd';\n\n/** The default color of a standalone part: the default picker color in HSV. */\nexport const DEFAULT_PART_COLOR: HsvColor = { h: 208, s: 0.92, v: 0.74 };\n\n/**\n * Texts of the ColorPicker's own parts and of the color parts bound to it, for localisation.\n * Every key is optional; missing keys use the English default.\n */\nexport interface ColorPickerLabels {\n /** Visible caption above the hex field.\n * @default 'Hex'\n */\n hex?: string;\n /** Accessible name of the hex text field.\n * @default 'Hex color value'\n */\n hexInput?: string;\n /** Error text shown (and used as the hex field's description) while the typed text can never be\n * a hex color, or when the field is left with text that is not one (such as `#12345`).\n * @default 'Enter a hex color such as #0f6cbd.'\n */\n hexError?: string;\n /** Accessible name of the preset swatches radiogroup.\n * @default 'Preset colors'\n */\n presets?: string;\n /** Visible label of the opacity row and accessible name of the opacity slider (a bound\n * `AlphaSlider`).\n * @default 'Opacity'\n */\n opacity?: string;\n /** Accessible name of a bound `ColorArea`'s group.\n * @default 'Saturation and brightness'\n */\n area?: string;\n /** Name of a bound area's saturation slider and of a bound `channel=\"saturation\"` slider.\n * @default 'Saturation'\n */\n saturation?: string;\n /** Name of a bound area's brightness slider and of a bound `channel=\"value\"` slider.\n * @default 'Brightness'\n */\n brightness?: string;\n /** Role description of a bound area's two sliders.\n * @default '2D slider'\n */\n roleDescription?: string;\n /** Name of a bound hue slider.\n * @default 'Hue'\n */\n hue?: string;\n /** Name of a bound `AlphaSlider` with `transparency`.\n * @default 'Transparency'\n */\n transparency?: string;\n /** Names the color at the end of the bound parts' value texts; return `''` to leave it out.\n * @default an English namer (\"dark blue\")\n */\n colorName?: (color: HsvColor) => string;\n /** Replaces a whole value text of a bound part, for languages whose order differs. */\n valueText?: (color: HsvColor, channel: 'hue' | 'saturation' | 'value' | 'alpha') => string;\n}\n\n/** The labels with every string default filled in (the two functions stay optional). */\nexport type ResolvedColorPickerLabels = Required<\n Omit<ColorPickerLabels, 'colorName' | 'valueText'>\n> &\n Pick<ColorPickerLabels, 'colorName' | 'valueText'>;\n\nexport const DEFAULT_COLOR_PICKER_LABELS: ResolvedColorPickerLabels = {\n hex: 'Hex',\n hexInput: 'Hex color value',\n hexError: `Enter a hex color such as ${DEFAULT_COLOR}.`,\n presets: 'Preset colors',\n opacity: 'Opacity',\n area: 'Saturation and brightness',\n saturation: 'Saturation',\n brightness: 'Brightness',\n roleDescription: '2D slider',\n hue: 'Hue',\n transparency: 'Transparency',\n};\n\n/** What a ColorPicker shares with its parts and with the color parts bound to it. */\nexport interface ColorPickerContextValue {\n /** The working color: HSV, so hue and saturation survive gray, white and black. */\n hsv: HsvColor;\n /** Writes the working color from a bound part and reports its hex (only when the hex changes). */\n setHsv: (next: HsvColor) => void;\n /** The picker's value as given: a hex string, or a value that is not one (as given). */\n color: string;\n /** The value parsed (`#rrggbb` and the alpha byte), `null` while it is not a hex color. */\n parsed: HexColor | null;\n /** Writes the value as hex text (the hex field). */\n setColor: (next: string) => void;\n /** Applies a preset's `#rrggbb` at the current opacity and drops the hex field's draft. */\n pickPreset: (rgb: string) => void;\n /** The picker's presets as swatch items (values are `#rrggbb`). */\n presetItems: readonly SwatchItem[];\n /** The picker's `shape`, inherited by the bound parts and `ColorPicker.Preview`. */\n shape: ColorPickerShape;\n /** The picker's labels with every string default filled in. */\n labels: ResolvedColorPickerLabels;\n /** `true` while the value is not a hex color: the bound parts are disabled until one arrives. */\n disabled: boolean;\n /** Changes whenever the hex field must drop its draft: a form reset or a preset pick. */\n draftResetKey: number;\n /** The Field around the picker (its parts render in a `null` Field context). */\n field: FieldContextValue | null;\n /** The invalid state set on the picker from outside (its `aria-invalid` or the Field's), as given. */\n groupInvalid: React.AriaAttributes['aria-invalid'];\n /** The consumer's `aria-errormessage`, routed to the hex field while that state is set. */\n errorMessageId: string | undefined;\n /** The hex field registers its `<input>` here (the hidden input's `onInvalid` focuses it). */\n registerHexInput: (input: HTMLInputElement | null) => void;\n}\n\nexport const ColorPickerContext = React.createContext<ColorPickerContextValue | null>(null);\nColorPickerContext.displayName = 'ColorPickerContext';\n\n/** The enclosing ColorPicker's context, or `null` outside one (the standalone parts need none). */\nexport function useColorPickerContext(): ColorPickerContextValue | null {\n return React.useContext(ColorPickerContext);\n}\n\n/** What a color part passes to {@link useColorPartState}. */\nexport interface ColorPartOptions {\n value: HsvColor | undefined;\n defaultValue: HsvColor | undefined;\n onValueChange: ((value: HsvColor) => void) | undefined;\n disabled: boolean;\n}\n\n/** Where a color part's color lives: in the enclosing picker (bound) or in the part. */\nexport interface ColorPartState {\n /** The enclosing picker when the part binds to it, else `null`. */\n picker: ColorPickerContextValue | null;\n /** The color as given (bound: the picker's working color). */\n color: HsvColor;\n /**\n * Writes a new color. Bound: the picker's working color, then the part's own `onValueChange`\n * (a part given only the callback listens; C-NAMING). Otherwise the part's state, through\n * `useControllable`.\n */\n setColor: (next: HsvColor) => void;\n /** Restores `defaultValue` on a form reset, reporting only a real change; nothing while bound. */\n reset: () => void;\n /** The part's `disabled`, or the picker's disabled state while bound. */\n disabled: boolean;\n}\n\nconst noop = () => {};\n\n/**\n * The binding rule of `ColorArea`, `ColorSlider` and `AlphaSlider` (D21): inside a ColorPicker, a\n * part with neither `value` nor `defaultValue` reads and writes the picker's working color;\n * anywhere else, or with either prop, it keeps its own color.\n */\nexport function useColorPartState({\n value,\n defaultValue,\n onValueChange,\n disabled,\n}: ColorPartOptions): ColorPartState {\n const context = useColorPickerContext();\n const picker =\n context !== null && value === undefined && defaultValue === undefined ? context : null;\n const initial = defaultValue ?? DEFAULT_PART_COLOR;\n const [own, setOwn] = useControllable(value, initial, picker ? undefined : onValueChange);\n if (picker) {\n return {\n picker,\n color: picker.hsv,\n setColor: (next) => {\n picker.setHsv(next);\n onValueChange?.(next);\n },\n reset: noop,\n disabled: disabled || picker.disabled,\n };\n }\n return {\n picker: null,\n color: own,\n setColor: setOwn,\n reset: () => {\n if (!sameColor(own, initial)) setOwn(initial);\n },\n disabled,\n };\n}\n\n// ---------------------------------------------------------------------------------------------\n// The picker-only parts: ColorPicker.HexField, ColorPicker.Swatches, ColorPicker.Preview\n// ---------------------------------------------------------------------------------------------\n\n/** The context a misplaced part renders with in production (C-CONTEXT). */\nconst INERT_PICKER_CONTEXT: ColorPickerContextValue = {\n hsv: DEFAULT_PART_COLOR,\n setHsv: noop,\n color: DEFAULT_COLOR,\n parsed: null,\n setColor: noop,\n pickPreset: noop,\n presetItems: [],\n shape: 'rounded',\n labels: DEFAULT_COLOR_PICKER_LABELS,\n disabled: true,\n draftResetKey: 0,\n field: null,\n groupInvalid: undefined,\n errorMessageId: undefined,\n registerHexInput: noop,\n};\n\n/**\n * The context of a picker-only part: throws `[WaveUI] <name> must be used within <ColorPicker>`\n * in development; logs once and returns an inert value in production (C-CONTEXT).\n */\nexport function usePickerPartContext(componentName: string): ColorPickerContextValue {\n const context = React.useContext(ColorPickerContext);\n if (context) return context;\n reportMissingContext(componentName, '<ColorPicker>');\n return INERT_PICKER_CONTEXT;\n}\n\n/** The hex field's text while the user edits it (`null` state: the field shows the value). */\ninterface HexDraft {\n /** The typed text. */\n text: string;\n /** Kept after leaving the field because it is not a hex color, so it is flagged as invalid. */\n flagged: boolean;\n}\n\n/** A hex draft without digits (`''` or a lone `#`): leaving the field shows the value again. */\nfunction isBlankDraft(text: string): boolean {\n const trimmed = text.trim();\n return trimmed === '' || trimmed === '#';\n}\n\n/** Whether typed hex text carries its own alpha digits (`#rgba` or `#rrggbbaa`). */\nfunction hasAlphaDigits(text: string): boolean {\n const digits = text.trim().replace(/^#/, '').length;\n return digits === 4 || digits === 8;\n}\n\n/**\n * Properties for the ColorPickerHexField sub-component. `id`, the labelling and validation\n * `aria-*` (`aria-label`, `aria-labelledby`, `aria-describedby`, `aria-invalid`,\n * `aria-errormessage`, `aria-details`, `aria-required`), `autoFocus`, `tabIndex`, the focus and key\n * handlers and the text-entry attributes (`inputMode`, `enterKeyHint`, `autoCapitalize`,\n * `autoCorrect`, `spellCheck`) go to the `<input>`; everything else stays on the outer label.\n */\nexport interface ColorPickerHexFieldProps extends React.HTMLAttributes<HTMLElement> {\n /** Ref to the hex `<input>`. */\n controlRef?: React.Ref<HTMLInputElement>;\n /** Ref to the field's outer element: the label around the caption, the input and the error. */\n ref?: React.Ref<HTMLLabelElement>;\n}\n\n/**\n * The hex text field of a ColorPicker: a caption, the input and its error. The text is a draft:\n * complete 6- and 8-digit values apply while typing, text that can never be a hex color is\n * flagged at once, and leaving the field (or Enter) applies a short `#rgb`/`#rgba` and shows the\n * value again; other text stays flagged until it is corrected, cleared, or the value changes from\n * elsewhere (a preset, another part, the parent, a form reset). Inside a Field it carries the\n * Field's invalid state and error. Must be inside a ColorPicker. Also exported as\n * `ColorPickerHexField` (import the flat name in React Server Components).\n */\nexport const ColorPickerHexField = ({\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-errormessage': ariaErrorMessage,\n 'aria-details': ariaDetails,\n 'aria-required': ariaRequired,\n autoFocus,\n tabIndex,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n inputMode,\n enterKeyHint,\n autoCapitalize,\n autoCorrect,\n spellCheck,\n controlRef,\n className,\n ref,\n ...rest\n}: ColorPickerHexFieldProps) => {\n const picker = usePickerPartContext('ColorPicker.HexField');\n const { color, parsed, field, groupInvalid, errorMessageId, labels } = picker;\n const alpha = parsed?.alpha ?? 255;\n\n // The hex text is a draft over `color` while the user edits it (null: show `color`).\n const [draft, setDraft] = React.useState<HexDraft | null>(null);\n // A value change from elsewhere replaces a flagged draft (input-pickers#25); while the user\n // types, the draft is not flagged and stays.\n const [syncedColor, setSyncedColor] = React.useState(color);\n if (color !== syncedColor) {\n setSyncedColor(color);\n if (draft?.flagged) setDraft(null);\n }\n // A form reset or a preset pick drops any draft.\n const [seenResetKey, setSeenResetKey] = React.useState(picker.draftResetKey);\n if (picker.draftResetKey !== seenResetKey) {\n setSeenResetKey(picker.draftResetKey);\n setDraft(null);\n }\n const hexText = draft?.text ?? color;\n const draftInvalid =\n draft !== null && !isBlankDraft(draft.text) && (draft.flagged || !isHexDraft(draft.text));\n // Any invalid state from outside (the picker's prop or the Field) is set on the input as is;\n // only `true` shows the error look.\n const fieldInvalid =\n groupInvalid !== undefined && groupInvalid !== false && groupInvalid !== 'false';\n const errorId = useId('wave-color-picker-error');\n const resolvedInvalid =\n ariaInvalid ?? (draftInvalid ? true : fieldInvalid ? groupInvalid : undefined);\n const invalidLook = isInvalidLook(false, resolvedInvalid);\n const inputRef = React.useRef<HTMLInputElement>(null);\n const mergedInputRef = useMergedRefs(inputRef, controlRef, picker.registerHexInput);\n\n /** The single commit path: every edit is `#rrggbb` + an alpha byte. */\n const commit = (rgb: string, nextAlpha: number) =>\n picker.setColor(formatHexColor(rgb, nextAlpha));\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n // Surrounding whitespace (a pasted `'#abcdef '`) is dropped, so the text that is checked,\n // committed and shown is the same.\n let text = event.target.value.trim();\n if (text !== '' && !text.startsWith('#')) text = `#${text}`;\n setDraft({ text, flagged: false });\n const typed = parseHexInput(text);\n // A 6-digit hex keeps the current opacity; an 8-digit one brings its own alpha.\n if (typed) commit(typed.rgb, hasAlphaDigits(text) ? typed.alpha : alpha);\n };\n\n /** Finishes the draft when the field is left or Enter is pressed. */\n const finishDraft = () => {\n if (draft === null || draft.flagged) return;\n const typed = parseHexColor(draft.text);\n if (typed || isBlankDraft(draft.text)) {\n // A short `#rgb` (current opacity) or `#rgba` is applied here; complete values were\n // applied while typing, so a rejecting parent is not asked twice. Then the field shows the\n // current value (also when a controlled parent rejected it).\n if (typed && !parseHexInput(draft.text)) {\n commit(typed.rgb, hasAlphaDigits(draft.text) ? typed.alpha : alpha);\n }\n setDraft(null);\n return;\n }\n // Text that is not a hex color is kept and flagged instead of thrown away (WCAG 3.3.1).\n setDraft({ text: draft.text, flagged: true });\n };\n\n const handleBlur = composeEventHandlers(onBlur, finishDraft);\n // Not prevented: Enter still submits the surrounding form, with the color just applied.\n const handleKeyDown = composeEventHandlers(\n onKeyDown,\n (event: React.KeyboardEvent<HTMLElement>) => {\n if (event.key === 'Enter' && !event.nativeEvent.isComposing) finishDraft();\n },\n );\n\n return (\n <label\n ref={ref}\n className={cn(colorPickerHexFieldClassNames.root, 'flex min-w-0 flex-col gap-1', className)}\n {...rest}\n >\n <span\n className={cn(colorPickerHexFieldClassNames.label, 'text-caption-1 text-muted-foreground')}\n >\n {labels.hex}\n </span>\n <input\n ref={mergedInputRef}\n id={id}\n type=\"text\"\n value={hexText}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n onFocus={onFocus}\n onBlur={handleBlur}\n aria-label={ariaLabel ?? (ariaLabelledBy === undefined ? labels.hexInput : undefined)}\n aria-labelledby={ariaLabelledBy}\n aria-invalid={resolvedInvalid}\n aria-errormessage={ariaErrorMessage ?? errorMessageId}\n aria-describedby={joinIds(\n draftInvalid && errorId,\n field?.validationMessageId ?? (fieldInvalid ? field?.errorId : undefined),\n errorMessageId,\n ariaDescribedBy,\n )}\n aria-details={ariaDetails}\n aria-required={ariaRequired}\n autoFocus={autoFocus}\n tabIndex={tabIndex}\n inputMode={inputMode}\n enterKeyHint={enterKeyHint}\n autoCapitalize={autoCapitalize}\n autoCorrect={autoCorrect}\n spellCheck={spellCheck ?? false}\n maxLength={9}\n autoComplete=\"off\"\n className={cn(\n colorPickerHexFieldClassNames.input,\n 'w-24 rounded border border-input border-b-stroke-accessible bg-background px-2 py-1 text-body-1 text-foreground',\n inputFocus,\n invalidLook && inputInvalid,\n )}\n />\n {draftInvalid && (\n <span\n id={errorId}\n className={cn(colorPickerHexFieldClassNames.errorMessage, 'text-caption-1 text-error')}\n >\n {labels.hexError}\n </span>\n )}\n </label>\n );\n};\n\nColorPickerHexField.displayName = 'ColorPickerHexField';\n\n/** Properties for the ColorPickerSwatches sub-component: the picker's `presets` as a SwatchPicker. */\nexport type ColorPickerSwatchesProps = Omit<\n SwatchPickerProps,\n 'items' | 'value' | 'defaultValue' | 'onValueChange' | 'onChange' | 'name' | 'form' | 'required'\n>;\n\n/**\n * The picker's `presets` as swatches (a SwatchPicker named by `labels.presets`, small and rounded\n * unless you pass `size` or `shape`). Picking one keeps the opacity. Renders nothing without\n * presets. Must be inside a ColorPicker. Also exported as `ColorPickerSwatches`.\n */\nexport const ColorPickerSwatches = ({\n className,\n 'aria-label': ariaLabel,\n size = 'small',\n shape = 'rounded',\n ...rest\n}: ColorPickerSwatchesProps) => {\n const picker = usePickerPartContext('ColorPicker.Swatches');\n if (picker.presetItems.length === 0) return null;\n return (\n <SwatchPicker\n aria-label={\n ariaLabel ?? (rest['aria-labelledby'] === undefined ? picker.labels.presets : undefined)\n }\n size={size}\n shape={shape}\n {...rest}\n className={cn(colorPickerSwatchesClassNames.root, className)}\n items={picker.presetItems}\n value={picker.parsed ? picker.parsed.rgb : ''}\n onValueChange={picker.pickPreset}\n />\n );\n};\n\nColorPickerSwatches.displayName = 'ColorPickerSwatches';\n\n/** Properties for the ColorPickerPreview sub-component. */\nexport interface ColorPickerPreviewProps extends React.HTMLAttributes<HTMLDivElement> {\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * A swatch of the picker's current color (decorative, `aria-hidden`); it keeps its color in forced\n * colors and follows the picker's `shape`. Must be inside a ColorPicker. Also exported as\n * `ColorPickerPreview`.\n */\nexport const ColorPickerPreview = ({ className, style, ref, ...rest }: ColorPickerPreviewProps) => {\n const picker = usePickerPartContext('ColorPicker.Preview');\n const shown = picker.parsed\n ? formatHexColor(picker.parsed.rgb, picker.parsed.alpha)\n : picker.color;\n return (\n <div\n data-color-preview=\"\"\n aria-hidden=\"true\"\n {...rest}\n ref={ref}\n className={cn(\n colorPickerPreviewClassNames.root,\n 'h-10 w-10 shrink-0 rounded border border-border forced-colors:forced-color-adjust-none',\n picker.shape === 'square' && 'rounded-none',\n className,\n )}\n style={{ ...style, backgroundColor: shown }}\n />\n );\n};\n\nColorPickerPreview.displayName = 'ColorPickerPreview';\n"],"mappings":"ujBAkCA,IAAaiC,EAAgB,UAGhBC,EAA+B,CAAE,EAAG,IAAK,EAAG,IAAM,EAAG,GAAK,EAmE1DC,EAAyD,CACpE,IAAK,MACL,SAAU,kBACV,SAAU,6BAA6BF,EAAc,GACrD,QAAS,gBACT,QAAS,UACT,KAAM,4BACN,WAAY,aACZ,WAAY,aACZ,gBAAiB,YACjB,IAAK,MACL,aAAc,cAChB,EAoCaG,EAAqBpC,EAAM,cAA8C,IAAI,EAC1F,EAAmB,YAAc,qBAGjC,SAAgBqC,GAAwD,CACtE,OAAOrC,EAAM,WAAWoC,CAAkB,CAC5C,CA4BA,IAAME,MAAa,CAAC,EAOpB,SAAgBC,EAAkB,CAChC,QACA,eACA,gBACA,YACmC,CACnC,IAAMC,EAAUH,EAAsB,EAChCI,EACJD,IAAY,MAAQE,IAAU,IAAA,IAAaC,IAAiB,IAAA,GAAYH,EAAU,KAC9EI,EAAUD,GAAgBT,EAC1B,CAACW,EAAKC,GAAU7C,EAAAA,gBAAgByC,EAAOE,EAASH,EAAS,IAAA,GAAYM,CAAa,EAaxF,OAZIN,EACK,C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CAAC,OAAD,CACE,GAAIgD,EACJ,UAAWrE,EAAAA,GAAGC,EAAAA,8BAA8B,aAAc,2BAA2B,EAEpF,SAAAsF,EAAO,QACJ,CAAA,CAEH,GAEX,EAEA,EAAoB,YAAc,sBAalC,IAAaI,GAAuB,CAClC,YACA,aAAc3C,EACd,OAAO,QACP,QAAQ,UACR,GAAGO,KAC2B,CAC9B,IAAMzB,EAASU,EAAqB,sBAAsB,EAE1D,OADIV,EAAO,YAAY,SAAW,EAAU,MAE1C,EAAAT,EAAA,IAAA,CAACjB,EAAAA,aAAD,CACE,aACE4C,IAAcO,EAAK,qBAAuB,IAAA,GAAYzB,EAAO,OAAO,QAAU,IAAA,IAE1E,OACC,QACP,GAAIyB,EACJ,UAAWvD,EAAAA,GAAGK,EAAAA,8BAA8B,KAAMiF,CAAS,EAC3D,MAAOxD,EAAO,YACd,MAAOA,EAAO,OAASA,EAAO,OAAO,IAAM,GAC3C,cAAeA,EAAO,UACvB,CAAA,CAEL,EAEA,EAAoB,YAAc,sBAYlC,IAAa8D,GAAsB,CAAE,YAAW,QAAO,MAAK,GAAGrC,KAAoC,CACjG,IAAMzB,EAASU,EAAqB,qBAAqB,EACnDqD,EAAQ/D,EAAO,OACjBlC,EAAAA,eAAekC,EAAO,OAAO,IAAKA,EAAO,OAAO,KAAK,EACrDA,EAAO,MACX,OACE,EAAAT,EAAA,IAAA,CAAC,MAAD,CACE,qBAAmB,GACnB,cAAY,OACZ,GAAIkC,EACC,MACL,UAAWvD,EAAAA,GACTM,EAAAA,6BAA6B,KAC7B,yFACAwB,EAAO,QAAU,UAAY,eAC7BwD,CACF,EACA,MAAO,CAAE,GAAGQ,EAAO,gBAAiBD,CAAM,CAC3C,CAAA,CAEL,EAEA,EAAmB,YAAc"}
@@ -0,0 +1,192 @@
1
+ "use client";
2
+ import { cn as e } from "../../lib/cn.mjs";
3
+ import { reportMissingContext as t } from "../../lib/dev.mjs";
4
+ import { composeEventHandlers as n } from "../../lib/composeEventHandlers.mjs";
5
+ import { colorPickerHexFieldClassNames as r, colorPickerPreviewClassNames as i, colorPickerSwatchesClassNames as a } from "../../lib/classNames.mjs";
6
+ import { useControllable as o } from "../../hooks/useControllable.mjs";
7
+ import { useId as s } from "../../hooks/useId.mjs";
8
+ import { useMergedRefs as c } from "../../hooks/useMergedRefs.mjs";
9
+ import { joinIds as l } from "../../lib/aria.mjs";
10
+ import { inputFocus as ee } from "../../lib/styles.mjs";
11
+ import { isInvalidLook as u } from "./Input.mjs";
12
+ import { formatHexColor as d, isHexDraft as te, parseHexColor as ne, parseHexInput as f, sameColor as p } from "./colorUtils.mjs";
13
+ import { SwatchPicker as m } from "./SwatchPicker.mjs";
14
+ import * as h from "react";
15
+ import { jsx as g, jsxs as re } from "react/jsx-runtime";
16
+ //#region src/components/input/ColorPicker.parts.tsx
17
+ var _ = "#0f6cbd", v = {
18
+ h: 208,
19
+ s: .92,
20
+ v: .74
21
+ }, y = {
22
+ hex: "Hex",
23
+ hexInput: "Hex color value",
24
+ hexError: `Enter a hex color such as ${_}.`,
25
+ presets: "Preset colors",
26
+ opacity: "Opacity",
27
+ area: "Saturation and brightness",
28
+ saturation: "Saturation",
29
+ brightness: "Brightness",
30
+ roleDescription: "2D slider",
31
+ hue: "Hue",
32
+ transparency: "Transparency"
33
+ }, b = h.createContext(null);
34
+ b.displayName = "ColorPickerContext";
35
+ function x() {
36
+ return h.useContext(b);
37
+ }
38
+ var S = () => {};
39
+ function C({ value: e, defaultValue: t, onValueChange: n, disabled: r }) {
40
+ let i = x(), a = i !== null && e === void 0 && t === void 0 ? i : null, s = t ?? v, [c, l] = o(e, s, a ? void 0 : n);
41
+ return a ? {
42
+ picker: a,
43
+ color: a.hsv,
44
+ setColor: (e) => {
45
+ a.setHsv(e), n?.(e);
46
+ },
47
+ reset: S,
48
+ disabled: r || a.disabled
49
+ } : {
50
+ picker: null,
51
+ color: c,
52
+ setColor: l,
53
+ reset: () => {
54
+ p(c, s) || l(s);
55
+ },
56
+ disabled: r
57
+ };
58
+ }
59
+ var w = {
60
+ hsv: v,
61
+ setHsv: S,
62
+ color: _,
63
+ parsed: null,
64
+ setColor: S,
65
+ pickPreset: S,
66
+ presetItems: [],
67
+ shape: "rounded",
68
+ labels: y,
69
+ disabled: !0,
70
+ draftResetKey: 0,
71
+ field: null,
72
+ groupInvalid: void 0,
73
+ errorMessageId: void 0,
74
+ registerHexInput: S
75
+ };
76
+ function T(e) {
77
+ return h.useContext(b) || (t(e, "<ColorPicker>"), w);
78
+ }
79
+ function E(e) {
80
+ let t = e.trim();
81
+ return t === "" || t === "#";
82
+ }
83
+ function D(e) {
84
+ let t = e.trim().replace(/^#/, "").length;
85
+ return t === 4 || t === 8;
86
+ }
87
+ var O = ({ id: t, "aria-label": i, "aria-labelledby": a, "aria-describedby": o, "aria-invalid": p, "aria-errormessage": m, "aria-details": _, "aria-required": v, autoFocus: y, tabIndex: b, onFocus: x, onBlur: S, onKeyDown: C, onKeyUp: w, inputMode: O, enterKeyHint: k, autoCapitalize: A, autoCorrect: j, spellCheck: M, controlRef: N, className: P, ref: F, ...ie }) => {
88
+ let I = T("ColorPicker.HexField"), { color: L, parsed: ae, field: R, groupInvalid: z, errorMessageId: B, labels: V } = I, H = ae?.alpha ?? 255, [U, W] = h.useState(null), [G, K] = h.useState(L);
89
+ L !== G && (K(L), U?.flagged && W(null));
90
+ let [q, oe] = h.useState(I.draftResetKey);
91
+ I.draftResetKey !== q && (oe(I.draftResetKey), W(null));
92
+ let se = U?.text ?? L, J = U !== null && !E(U.text) && (U.flagged || !te(U.text)), Y = z !== void 0 && z !== !1 && z !== "false", X = s("wave-color-picker-error"), Z = p ?? (J ? !0 : Y ? z : void 0), ce = u(!1, Z), le = h.useRef(null), ue = c(le, N, I.registerHexInput), Q = (e, t) => I.setColor(d(e, t)), de = (e) => {
93
+ let t = e.target.value.trim();
94
+ t !== "" && !t.startsWith("#") && (t = `#${t}`), W({
95
+ text: t,
96
+ flagged: !1
97
+ });
98
+ let n = f(t);
99
+ n && Q(n.rgb, D(t) ? n.alpha : H);
100
+ }, $ = () => {
101
+ if (U === null || U.flagged) return;
102
+ let e = ne(U.text);
103
+ if (e || E(U.text)) {
104
+ e && !f(U.text) && Q(e.rgb, D(U.text) ? e.alpha : H), W(null);
105
+ return;
106
+ }
107
+ W({
108
+ text: U.text,
109
+ flagged: !0
110
+ });
111
+ }, fe = n(S, $), pe = n(C, (e) => {
112
+ e.key === "Enter" && !e.nativeEvent.isComposing && $();
113
+ });
114
+ return /* @__PURE__ */ re("label", {
115
+ ref: F,
116
+ className: e(r.root, "flex min-w-0 flex-col gap-1", P),
117
+ ...ie,
118
+ children: [
119
+ /* @__PURE__ */ g("span", {
120
+ className: e(r.label, "text-caption-1 text-muted-foreground"),
121
+ children: V.hex
122
+ }),
123
+ /* @__PURE__ */ g("input", {
124
+ ref: ue,
125
+ id: t,
126
+ type: "text",
127
+ value: se,
128
+ onChange: de,
129
+ onKeyDown: pe,
130
+ onKeyUp: w,
131
+ onFocus: x,
132
+ onBlur: fe,
133
+ "aria-label": i ?? (a === void 0 ? V.hexInput : void 0),
134
+ "aria-labelledby": a,
135
+ "aria-invalid": Z,
136
+ "aria-errormessage": m ?? B,
137
+ "aria-describedby": l(J && X, R?.validationMessageId ?? (Y ? R?.errorId : void 0), B, o),
138
+ "aria-details": _,
139
+ "aria-required": v,
140
+ autoFocus: y,
141
+ tabIndex: b,
142
+ inputMode: O,
143
+ enterKeyHint: k,
144
+ autoCapitalize: A,
145
+ autoCorrect: j,
146
+ spellCheck: M ?? !1,
147
+ maxLength: 9,
148
+ autoComplete: "off",
149
+ className: e(r.input, "w-24 rounded border border-input border-b-stroke-accessible bg-background px-2 py-1 text-body-1 text-foreground", ee, ce && "border-destructive focus:border-b-destructive")
150
+ }),
151
+ J && /* @__PURE__ */ g("span", {
152
+ id: X,
153
+ className: e(r.errorMessage, "text-caption-1 text-error"),
154
+ children: V.hexError
155
+ })
156
+ ]
157
+ });
158
+ };
159
+ O.displayName = "ColorPickerHexField";
160
+ var k = ({ className: t, "aria-label": n, size: r = "small", shape: i = "rounded", ...o }) => {
161
+ let s = T("ColorPicker.Swatches");
162
+ return s.presetItems.length === 0 ? null : /* @__PURE__ */ g(m, {
163
+ "aria-label": n ?? (o["aria-labelledby"] === void 0 ? s.labels.presets : void 0),
164
+ size: r,
165
+ shape: i,
166
+ ...o,
167
+ className: e(a.root, t),
168
+ items: s.presetItems,
169
+ value: s.parsed ? s.parsed.rgb : "",
170
+ onValueChange: s.pickPreset
171
+ });
172
+ };
173
+ k.displayName = "ColorPickerSwatches";
174
+ var A = ({ className: t, style: n, ref: r, ...a }) => {
175
+ let o = T("ColorPicker.Preview"), s = o.parsed ? d(o.parsed.rgb, o.parsed.alpha) : o.color;
176
+ return /* @__PURE__ */ g("div", {
177
+ "data-color-preview": "",
178
+ "aria-hidden": "true",
179
+ ...a,
180
+ ref: r,
181
+ className: e(i.root, "h-10 w-10 shrink-0 rounded border border-border forced-colors:forced-color-adjust-none", o.shape === "square" && "rounded-none", t),
182
+ style: {
183
+ ...n,
184
+ backgroundColor: s
185
+ }
186
+ });
187
+ };
188
+ A.displayName = "ColorPickerPreview";
189
+ //#endregion
190
+ export { b as ColorPickerContext, O as ColorPickerHexField, A as ColorPickerPreview, k as ColorPickerSwatches, _ as DEFAULT_COLOR, y as DEFAULT_COLOR_PICKER_LABELS, v as DEFAULT_PART_COLOR, C as useColorPartState, x as useColorPickerContext, T as usePickerPartContext };
191
+
192
+ //# sourceMappingURL=ColorPicker.parts.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorPicker.parts.mjs","names":["useId","useId$1","React","DEFAULT_COLOR","DEFAULT_PART_COLOR","DEFAULT_COLOR_PICKER_LABELS","ColorPickerContext","useColorPickerContext","noop","useColorPartState","context","picker","value","defaultValue","initial","own","setOwn","useControllable","onValueChange","next","disabled","sameColor","INERT_PICKER_CONTEXT","usePickerPartContext","reportMissingContext","componentName","isBlankDraft","trimmed","text","hasAlphaDigits","digits","ColorPickerHexField","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaErrorMessage","ariaDetails","ariaRequired","rest","alpha","parsed","draft","setDraft","syncedColor","setSyncedColor","color","seenResetKey","setSeenResetKey","hexText","draftInvalid","isHexDraft","fieldInvalid","groupInvalid","errorId","resolvedInvalid","invalidLook","isInvalidLook","inputRef","mergedInputRef","useMergedRefs","controlRef","commit","formatHexColor","rgb","nextAlpha","handleChange","event","typed","parseHexInput","finishDraft","parseHexColor","handleBlur","composeEventHandlers","onBlur","handleKeyDown","onKeyDown","cn","colorPickerHexFieldClassNames","className","labels","errorMessageId","joinIds","field","spellCheck","inputFocus","ColorPickerSwatches","SwatchPicker","colorPickerSwatchesClassNames","ColorPickerPreview","shown","colorPickerPreviewClassNames","style"],"sources":["../../../src/components/input/ColorPicker.parts.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useControllable } from '../../hooks/useControllable';\nimport type { FieldContextValue } from '../../hooks/useFieldControl';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { joinIds } from '../../lib/aria';\nimport {\n colorPickerHexFieldClassNames,\n colorPickerPreviewClassNames,\n colorPickerSwatchesClassNames,\n} from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { reportMissingContext } from '../../lib/dev';\nimport { inputFocus, inputInvalid } from '../../lib/styles';\nimport type { ColorPickerShape, HsvColor } from '../../lib/types';\nimport { isInvalidLook } from './Input';\nimport { SwatchPicker, type SwatchItem, type SwatchPickerProps } from './SwatchPicker';\nimport {\n formatHexColor,\n isHexDraft,\n parseHexColor,\n parseHexInput,\n sameColor,\n type HexColor,\n} from './colorUtils';\n\n/*\n * The picker's labels and context, and how the standalone color parts bind to it (spec P3-05,\n * D21). `ColorArea`, `ColorSlider` and `AlphaSlider` read the context; `ColorPicker.tsx` provides\n * it and renders the picker-only parts. This module never imports `ColorPicker.tsx`.\n */\n\n// wave-allow-color: default color value (user color data, C-TOKENS exception)\nexport const DEFAULT_COLOR = '#0f6cbd';\n\n/** The default color of a standalone part: the default picker color in HSV. */\nexport const DEFAULT_PART_COLOR: HsvColor = { h: 208, s: 0.92, v: 0.74 };\n\n/**\n * Texts of the ColorPicker's own parts and of the color parts bound to it, for localisation.\n * Every key is optional; missing keys use the English default.\n */\nexport interface ColorPickerLabels {\n /** Visible caption above the hex field.\n * @default 'Hex'\n */\n hex?: string;\n /** Accessible name of the hex text field.\n * @default 'Hex color value'\n */\n hexInput?: string;\n /** Error text shown (and used as the hex field's description) while the typed text can never be\n * a hex color, or when the field is left with text that is not one (such as `#12345`).\n * @default 'Enter a hex color such as #0f6cbd.'\n */\n hexError?: string;\n /** Accessible name of the preset swatches radiogroup.\n * @default 'Preset colors'\n */\n presets?: string;\n /** Visible label of the opacity row and accessible name of the opacity slider (a bound\n * `AlphaSlider`).\n * @default 'Opacity'\n */\n opacity?: string;\n /** Accessible name of a bound `ColorArea`'s group.\n * @default 'Saturation and brightness'\n */\n area?: string;\n /** Name of a bound area's saturation slider and of a bound `channel=\"saturation\"` slider.\n * @default 'Saturation'\n */\n saturation?: string;\n /** Name of a bound area's brightness slider and of a bound `channel=\"value\"` slider.\n * @default 'Brightness'\n */\n brightness?: string;\n /** Role description of a bound area's two sliders.\n * @default '2D slider'\n */\n roleDescription?: string;\n /** Name of a bound hue slider.\n * @default 'Hue'\n */\n hue?: string;\n /** Name of a bound `AlphaSlider` with `transparency`.\n * @default 'Transparency'\n */\n transparency?: string;\n /** Names the color at the end of the bound parts' value texts; return `''` to leave it out.\n * @default an English namer (\"dark blue\")\n */\n colorName?: (color: HsvColor) => string;\n /** Replaces a whole value text of a bound part, for languages whose order differs. */\n valueText?: (color: HsvColor, channel: 'hue' | 'saturation' | 'value' | 'alpha') => string;\n}\n\n/** The labels with every string default filled in (the two functions stay optional). */\nexport type ResolvedColorPickerLabels = Required<\n Omit<ColorPickerLabels, 'colorName' | 'valueText'>\n> &\n Pick<ColorPickerLabels, 'colorName' | 'valueText'>;\n\nexport const DEFAULT_COLOR_PICKER_LABELS: ResolvedColorPickerLabels = {\n hex: 'Hex',\n hexInput: 'Hex color value',\n hexError: `Enter a hex color such as ${DEFAULT_COLOR}.`,\n presets: 'Preset colors',\n opacity: 'Opacity',\n area: 'Saturation and brightness',\n saturation: 'Saturation',\n brightness: 'Brightness',\n roleDescription: '2D slider',\n hue: 'Hue',\n transparency: 'Transparency',\n};\n\n/** What a ColorPicker shares with its parts and with the color parts bound to it. */\nexport interface ColorPickerContextValue {\n /** The working color: HSV, so hue and saturation survive gray, white and black. */\n hsv: HsvColor;\n /** Writes the working color from a bound part and reports its hex (only when the hex changes). */\n setHsv: (next: HsvColor) => void;\n /** The picker's value as given: a hex string, or a value that is not one (as given). */\n color: string;\n /** The value parsed (`#rrggbb` and the alpha byte), `null` while it is not a hex color. */\n parsed: HexColor | null;\n /** Writes the value as hex text (the hex field). */\n setColor: (next: string) => void;\n /** Applies a preset's `#rrggbb` at the current opacity and drops the hex field's draft. */\n pickPreset: (rgb: string) => void;\n /** The picker's presets as swatch items (values are `#rrggbb`). */\n presetItems: readonly SwatchItem[];\n /** The picker's `shape`, inherited by the bound parts and `ColorPicker.Preview`. */\n shape: ColorPickerShape;\n /** The picker's labels with every string default filled in. */\n labels: ResolvedColorPickerLabels;\n /** `true` while the value is not a hex color: the bound parts are disabled until one arrives. */\n disabled: boolean;\n /** Changes whenever the hex field must drop its draft: a form reset or a preset pick. */\n draftResetKey: number;\n /** The Field around the picker (its parts render in a `null` Field context). */\n field: FieldContextValue | null;\n /** The invalid state set on the picker from outside (its `aria-invalid` or the Field's), as given. */\n groupInvalid: React.AriaAttributes['aria-invalid'];\n /** The consumer's `aria-errormessage`, routed to the hex field while that state is set. */\n errorMessageId: string | undefined;\n /** The hex field registers its `<input>` here (the hidden input's `onInvalid` focuses it). */\n registerHexInput: (input: HTMLInputElement | null) => void;\n}\n\nexport const ColorPickerContext = React.createContext<ColorPickerContextValue | null>(null);\nColorPickerContext.displayName = 'ColorPickerContext';\n\n/** The enclosing ColorPicker's context, or `null` outside one (the standalone parts need none). */\nexport function useColorPickerContext(): ColorPickerContextValue | null {\n return React.useContext(ColorPickerContext);\n}\n\n/** What a color part passes to {@link useColorPartState}. */\nexport interface ColorPartOptions {\n value: HsvColor | undefined;\n defaultValue: HsvColor | undefined;\n onValueChange: ((value: HsvColor) => void) | undefined;\n disabled: boolean;\n}\n\n/** Where a color part's color lives: in the enclosing picker (bound) or in the part. */\nexport interface ColorPartState {\n /** The enclosing picker when the part binds to it, else `null`. */\n picker: ColorPickerContextValue | null;\n /** The color as given (bound: the picker's working color). */\n color: HsvColor;\n /**\n * Writes a new color. Bound: the picker's working color, then the part's own `onValueChange`\n * (a part given only the callback listens; C-NAMING). Otherwise the part's state, through\n * `useControllable`.\n */\n setColor: (next: HsvColor) => void;\n /** Restores `defaultValue` on a form reset, reporting only a real change; nothing while bound. */\n reset: () => void;\n /** The part's `disabled`, or the picker's disabled state while bound. */\n disabled: boolean;\n}\n\nconst noop = () => {};\n\n/**\n * The binding rule of `ColorArea`, `ColorSlider` and `AlphaSlider` (D21): inside a ColorPicker, a\n * part with neither `value` nor `defaultValue` reads and writes the picker's working color;\n * anywhere else, or with either prop, it keeps its own color.\n */\nexport function useColorPartState({\n value,\n defaultValue,\n onValueChange,\n disabled,\n}: ColorPartOptions): ColorPartState {\n const context = useColorPickerContext();\n const picker =\n context !== null && value === undefined && defaultValue === undefined ? context : null;\n const initial = defaultValue ?? DEFAULT_PART_COLOR;\n const [own, setOwn] = useControllable(value, initial, picker ? undefined : onValueChange);\n if (picker) {\n return {\n picker,\n color: picker.hsv,\n setColor: (next) => {\n picker.setHsv(next);\n onValueChange?.(next);\n },\n reset: noop,\n disabled: disabled || picker.disabled,\n };\n }\n return {\n picker: null,\n color: own,\n setColor: setOwn,\n reset: () => {\n if (!sameColor(own, initial)) setOwn(initial);\n },\n disabled,\n };\n}\n\n// ---------------------------------------------------------------------------------------------\n// The picker-only parts: ColorPicker.HexField, ColorPicker.Swatches, ColorPicker.Preview\n// ---------------------------------------------------------------------------------------------\n\n/** The context a misplaced part renders with in production (C-CONTEXT). */\nconst INERT_PICKER_CONTEXT: ColorPickerContextValue = {\n hsv: DEFAULT_PART_COLOR,\n setHsv: noop,\n color: DEFAULT_COLOR,\n parsed: null,\n setColor: noop,\n pickPreset: noop,\n presetItems: [],\n shape: 'rounded',\n labels: DEFAULT_COLOR_PICKER_LABELS,\n disabled: true,\n draftResetKey: 0,\n field: null,\n groupInvalid: undefined,\n errorMessageId: undefined,\n registerHexInput: noop,\n};\n\n/**\n * The context of a picker-only part: throws `[WaveUI] <name> must be used within <ColorPicker>`\n * in development; logs once and returns an inert value in production (C-CONTEXT).\n */\nexport function usePickerPartContext(componentName: string): ColorPickerContextValue {\n const context = React.useContext(ColorPickerContext);\n if (context) return context;\n reportMissingContext(componentName, '<ColorPicker>');\n return INERT_PICKER_CONTEXT;\n}\n\n/** The hex field's text while the user edits it (`null` state: the field shows the value). */\ninterface HexDraft {\n /** The typed text. */\n text: string;\n /** Kept after leaving the field because it is not a hex color, so it is flagged as invalid. */\n flagged: boolean;\n}\n\n/** A hex draft without digits (`''` or a lone `#`): leaving the field shows the value again. */\nfunction isBlankDraft(text: string): boolean {\n const trimmed = text.trim();\n return trimmed === '' || trimmed === '#';\n}\n\n/** Whether typed hex text carries its own alpha digits (`#rgba` or `#rrggbbaa`). */\nfunction hasAlphaDigits(text: string): boolean {\n const digits = text.trim().replace(/^#/, '').length;\n return digits === 4 || digits === 8;\n}\n\n/**\n * Properties for the ColorPickerHexField sub-component. `id`, the labelling and validation\n * `aria-*` (`aria-label`, `aria-labelledby`, `aria-describedby`, `aria-invalid`,\n * `aria-errormessage`, `aria-details`, `aria-required`), `autoFocus`, `tabIndex`, the focus and key\n * handlers and the text-entry attributes (`inputMode`, `enterKeyHint`, `autoCapitalize`,\n * `autoCorrect`, `spellCheck`) go to the `<input>`; everything else stays on the outer label.\n */\nexport interface ColorPickerHexFieldProps extends React.HTMLAttributes<HTMLElement> {\n /** Ref to the hex `<input>`. */\n controlRef?: React.Ref<HTMLInputElement>;\n /** Ref to the field's outer element: the label around the caption, the input and the error. */\n ref?: React.Ref<HTMLLabelElement>;\n}\n\n/**\n * The hex text field of a ColorPicker: a caption, the input and its error. The text is a draft:\n * complete 6- and 8-digit values apply while typing, text that can never be a hex color is\n * flagged at once, and leaving the field (or Enter) applies a short `#rgb`/`#rgba` and shows the\n * value again; other text stays flagged until it is corrected, cleared, or the value changes from\n * elsewhere (a preset, another part, the parent, a form reset). Inside a Field it carries the\n * Field's invalid state and error. Must be inside a ColorPicker. Also exported as\n * `ColorPickerHexField` (import the flat name in React Server Components).\n */\nexport const ColorPickerHexField = ({\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-errormessage': ariaErrorMessage,\n 'aria-details': ariaDetails,\n 'aria-required': ariaRequired,\n autoFocus,\n tabIndex,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n inputMode,\n enterKeyHint,\n autoCapitalize,\n autoCorrect,\n spellCheck,\n controlRef,\n className,\n ref,\n ...rest\n}: ColorPickerHexFieldProps) => {\n const picker = usePickerPartContext('ColorPicker.HexField');\n const { color, parsed, field, groupInvalid, errorMessageId, labels } = picker;\n const alpha = parsed?.alpha ?? 255;\n\n // The hex text is a draft over `color` while the user edits it (null: show `color`).\n const [draft, setDraft] = React.useState<HexDraft | null>(null);\n // A value change from elsewhere replaces a flagged draft (input-pickers#25); while the user\n // types, the draft is not flagged and stays.\n const [syncedColor, setSyncedColor] = React.useState(color);\n if (color !== syncedColor) {\n setSyncedColor(color);\n if (draft?.flagged) setDraft(null);\n }\n // A form reset or a preset pick drops any draft.\n const [seenResetKey, setSeenResetKey] = React.useState(picker.draftResetKey);\n if (picker.draftResetKey !== seenResetKey) {\n setSeenResetKey(picker.draftResetKey);\n setDraft(null);\n }\n const hexText = draft?.text ?? color;\n const draftInvalid =\n draft !== null && !isBlankDraft(draft.text) && (draft.flagged || !isHexDraft(draft.text));\n // Any invalid state from outside (the picker's prop or the Field) is set on the input as is;\n // only `true` shows the error look.\n const fieldInvalid =\n groupInvalid !== undefined && groupInvalid !== false && groupInvalid !== 'false';\n const errorId = useId('wave-color-picker-error');\n const resolvedInvalid =\n ariaInvalid ?? (draftInvalid ? true : fieldInvalid ? groupInvalid : undefined);\n const invalidLook = isInvalidLook(false, resolvedInvalid);\n const inputRef = React.useRef<HTMLInputElement>(null);\n const mergedInputRef = useMergedRefs(inputRef, controlRef, picker.registerHexInput);\n\n /** The single commit path: every edit is `#rrggbb` + an alpha byte. */\n const commit = (rgb: string, nextAlpha: number) =>\n picker.setColor(formatHexColor(rgb, nextAlpha));\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n // Surrounding whitespace (a pasted `'#abcdef '`) is dropped, so the text that is checked,\n // committed and shown is the same.\n let text = event.target.value.trim();\n if (text !== '' && !text.startsWith('#')) text = `#${text}`;\n setDraft({ text, flagged: false });\n const typed = parseHexInput(text);\n // A 6-digit hex keeps the current opacity; an 8-digit one brings its own alpha.\n if (typed) commit(typed.rgb, hasAlphaDigits(text) ? typed.alpha : alpha);\n };\n\n /** Finishes the draft when the field is left or Enter is pressed. */\n const finishDraft = () => {\n if (draft === null || draft.flagged) return;\n const typed = parseHexColor(draft.text);\n if (typed || isBlankDraft(draft.text)) {\n // A short `#rgb` (current opacity) or `#rgba` is applied here; complete values were\n // applied while typing, so a rejecting parent is not asked twice. Then the field shows the\n // current value (also when a controlled parent rejected it).\n if (typed && !parseHexInput(draft.text)) {\n commit(typed.rgb, hasAlphaDigits(draft.text) ? typed.alpha : alpha);\n }\n setDraft(null);\n return;\n }\n // Text that is not a hex color is kept and flagged instead of thrown away (WCAG 3.3.1).\n setDraft({ text: draft.text, flagged: true });\n };\n\n const handleBlur = composeEventHandlers(onBlur, finishDraft);\n // Not prevented: Enter still submits the surrounding form, with the color just applied.\n const handleKeyDown = composeEventHandlers(\n onKeyDown,\n (event: React.KeyboardEvent<HTMLElement>) => {\n if (event.key === 'Enter' && !event.nativeEvent.isComposing) finishDraft();\n },\n );\n\n return (\n <label\n ref={ref}\n className={cn(colorPickerHexFieldClassNames.root, 'flex min-w-0 flex-col gap-1', className)}\n {...rest}\n >\n <span\n className={cn(colorPickerHexFieldClassNames.label, 'text-caption-1 text-muted-foreground')}\n >\n {labels.hex}\n </span>\n <input\n ref={mergedInputRef}\n id={id}\n type=\"text\"\n value={hexText}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n onFocus={onFocus}\n onBlur={handleBlur}\n aria-label={ariaLabel ?? (ariaLabelledBy === undefined ? labels.hexInput : undefined)}\n aria-labelledby={ariaLabelledBy}\n aria-invalid={resolvedInvalid}\n aria-errormessage={ariaErrorMessage ?? errorMessageId}\n aria-describedby={joinIds(\n draftInvalid && errorId,\n field?.validationMessageId ?? (fieldInvalid ? field?.errorId : undefined),\n errorMessageId,\n ariaDescribedBy,\n )}\n aria-details={ariaDetails}\n aria-required={ariaRequired}\n autoFocus={autoFocus}\n tabIndex={tabIndex}\n inputMode={inputMode}\n enterKeyHint={enterKeyHint}\n autoCapitalize={autoCapitalize}\n autoCorrect={autoCorrect}\n spellCheck={spellCheck ?? false}\n maxLength={9}\n autoComplete=\"off\"\n className={cn(\n colorPickerHexFieldClassNames.input,\n 'w-24 rounded border border-input border-b-stroke-accessible bg-background px-2 py-1 text-body-1 text-foreground',\n inputFocus,\n invalidLook && inputInvalid,\n )}\n />\n {draftInvalid && (\n <span\n id={errorId}\n className={cn(colorPickerHexFieldClassNames.errorMessage, 'text-caption-1 text-error')}\n >\n {labels.hexError}\n </span>\n )}\n </label>\n );\n};\n\nColorPickerHexField.displayName = 'ColorPickerHexField';\n\n/** Properties for the ColorPickerSwatches sub-component: the picker's `presets` as a SwatchPicker. */\nexport type ColorPickerSwatchesProps = Omit<\n SwatchPickerProps,\n 'items' | 'value' | 'defaultValue' | 'onValueChange' | 'onChange' | 'name' | 'form' | 'required'\n>;\n\n/**\n * The picker's `presets` as swatches (a SwatchPicker named by `labels.presets`, small and rounded\n * unless you pass `size` or `shape`). Picking one keeps the opacity. Renders nothing without\n * presets. Must be inside a ColorPicker. Also exported as `ColorPickerSwatches`.\n */\nexport const ColorPickerSwatches = ({\n className,\n 'aria-label': ariaLabel,\n size = 'small',\n shape = 'rounded',\n ...rest\n}: ColorPickerSwatchesProps) => {\n const picker = usePickerPartContext('ColorPicker.Swatches');\n if (picker.presetItems.length === 0) return null;\n return (\n <SwatchPicker\n aria-label={\n ariaLabel ?? (rest['aria-labelledby'] === undefined ? picker.labels.presets : undefined)\n }\n size={size}\n shape={shape}\n {...rest}\n className={cn(colorPickerSwatchesClassNames.root, className)}\n items={picker.presetItems}\n value={picker.parsed ? picker.parsed.rgb : ''}\n onValueChange={picker.pickPreset}\n />\n );\n};\n\nColorPickerSwatches.displayName = 'ColorPickerSwatches';\n\n/** Properties for the ColorPickerPreview sub-component. */\nexport interface ColorPickerPreviewProps extends React.HTMLAttributes<HTMLDivElement> {\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * A swatch of the picker's current color (decorative, `aria-hidden`); it keeps its color in forced\n * colors and follows the picker's `shape`. Must be inside a ColorPicker. Also exported as\n * `ColorPickerPreview`.\n */\nexport const ColorPickerPreview = ({ className, style, ref, ...rest }: ColorPickerPreviewProps) => {\n const picker = usePickerPartContext('ColorPicker.Preview');\n const shown = picker.parsed\n ? formatHexColor(picker.parsed.rgb, picker.parsed.alpha)\n : picker.color;\n return (\n <div\n data-color-preview=\"\"\n aria-hidden=\"true\"\n {...rest}\n ref={ref}\n className={cn(\n colorPickerPreviewClassNames.root,\n 'h-10 w-10 shrink-0 rounded border border-border forced-colors:forced-color-adjust-none',\n picker.shape === 'square' && 'rounded-none',\n className,\n )}\n style={{ ...style, backgroundColor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E,IAAQ/E,EAAO,SACjBoD,EAAepD,EAAO,OAAO,KAAKA,EAAO,OAAO,KAAK,IACrDA,EAAO;CACX,OACE,kBAAC,OAAD;EACE,sBAAmB;EACnB,eAAY;EACZ,GAAI4B;EACC;EACL,WAAWsC,EACTc,EAA6B,MAC7B,0FACAhF,EAAO,UAAU,YAAY,gBAC7BoE,CACF;EACA,OAAO;GAAE,GAAGa;GAAO,iBAAiBF;EAAM;CAC3C,CAAA;AAEL;AAEA,EAAmB,cAAc"}
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/composeEventHandlers.cjs"),r=require("../../lib/classNames.cjs"),i=require("../../lib/color.cjs"),ee=require("../../lib/direction.cjs"),a=require("../../hooks/useMergedRefs.cjs"),o=require("../../hooks/useFieldControl.cjs"),te=require("../../hooks/useFormReset.cjs"),s=require("../internal/HiddenInput.cjs"),c=require("./colorUtils.cjs"),l=require("./ColorPicker.parts.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("react/jsx-runtime");var f={hue:`Hue`,saturation:`Saturation`,brightness:`Brightness`},p={hue:`hue`,saturation:`saturation`,value:`brightness`},m=({channel:e=`hue`,orientation:m=`horizontal`,value:ne,defaultValue:h,onValueChange:g,shape:_,labels:v,disabled:y=!1,name:b,form:x,required:S,controlRef:re,className:C,style:w,id:T,"aria-label":E,"aria-labelledby":D,"aria-describedby":O,"aria-invalid":k,"aria-required":A,"aria-errormessage":j,"aria-details":M,autoFocus:N,tabIndex:P,onFocus:F,onBlur:I,onKeyDown:L,onKeyUp:R,ref:z,...B})=>{let V=l.useColorPartState({value:ne,defaultValue:h,onValueChange:g,disabled:y}),{picker:H}=V,U={...f,...H&&{hue:H.labels.hue,saturation:H.labels.saturation,brightness:H.labels.brightness,colorName:H.labels.colorName,valueText:H.labels.valueText},...v},W=_??H?.shape??`rounded`,G=m===`vertical`,K=c.displayColor(V.color),q=e===`hue`?360:100,J=e===`hue`?Math.round(K.h):c.toPercent(e===`saturation`?K.s:K.v),Y=o.useFieldContext(),{"aria-required":ie,required:ae,...X}=o.useFieldControl({id:T,"aria-label":E??(Y===null&&D===void 0?U[p[e]]:void 0),"aria-labelledby":D,"aria-describedby":O,"aria-invalid":k}),Z=X[`aria-invalid`],oe=Z!==void 0&&Z!==!1&&Z!==`false`,se=S??(A===!0||A===`true`||(Y?.required??!1)),Q=u.useRef(null),ce=a.useMergedRefs(Q,re);te.useFormReset(Q,V.reset,x);let $=t=>{if(t===J)return;let n=V.color;V.setColor(e===`hue`?{...n,h:t}:e===`saturation`?{...n,s:t/100}:{...n,v:t/100})},le=n.composeEventHandlers(L,e=>{if(V.disabled||e.nativeEvent.isComposing)return;let t=c.railKeyTarget(e.key,e,ee.getDirection(e.currentTarget),J,q);t!==null&&(e.preventDefault(),$(t))}),ue=e=>{V.disabled||$(Math.min(q,Math.max(0,Math.round(Number(e.currentTarget.value)))))},de={...w,"--wave-color-slider-gradient":c.colorSliderGradient(e,K,m),"--wave-color-slider-position":c.toPosition(J/q),"--wave-color-thumb":e===`hue`?i.hsvToHex({h:K.h,s:1,v:1}):i.hsvToHex({h:K.h,s:K.s,v:K.v})};return(0,d.jsxs)(`div`,{"data-orientation":m,"data-channel":e,"data-disabled":V.disabled?``:void 0,className:t.cn(r.colorSliderClassNames.root,`group/color-slider relative flex touch-none select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,G?c.RAIL_ROOT_VERTICAL:c.RAIL_ROOT_HORIZONTAL,C),style:de,...B,ref:z,children:[(0,d.jsx)(`div`,{"aria-hidden":`true`,className:t.cn(r.colorSliderClassNames.rail,`rounded-full forced-colors:forced-color-adjust-none`,c.RAIL_GRADIENT,G?c.RAIL_TRACK_VERTICAL:c.RAIL_TRACK_HORIZONTAL,W===`square`&&`rounded-none`)}),(0,d.jsx)(`input`,{type:`range`,...X,ref:ce,min:0,max:q,step:1,value:J,disabled:V.disabled,dir:G?`ltr`:void 0,"aria-orientation":G?`vertical`:void 0,"aria-valuetext":c.sliderValueText(K,e,U),"aria-errormessage":oe&&j||void 0,"aria-details":M,autoFocus:N,tabIndex:P,onFocus:F,onBlur:I,onKeyDown:le,onKeyUp:R,onChange:ue,className:t.cn(c.RAIL_INPUT_CLASSES,G?c.RAIL_INPUT_VERTICAL:c.RAIL_INPUT_HORIZONTAL)}),(0,d.jsx)(`span`,{"aria-hidden":`true`,className:G?c.THUMB_TRACK_VERTICAL:c.THUMB_TRACK_HORIZONTAL,children:(0,d.jsx)(`span`,{className:t.cn(r.colorSliderClassNames.thumb,c.COLOR_THUMB_CLASSES,G?c.THUMB_POSITION_VERTICAL:c.THUMB_POSITION_HORIZONTAL,`group-has-[:focus-visible]/color-slider:ring-2 group-has-[:focus-visible]/color-slider:ring-background forced-colors:group-has-[:focus-visible]/color-slider:ring-[Canvas] group-has-[:focus-visible]/color-slider:outline-2 group-has-[:focus-visible]/color-slider:outline-offset-2 group-has-[:focus-visible]/color-slider:outline-ring forced-colors:group-has-[:focus-visible]/color-slider:outline-[Highlight]`)})}),!H&&(0,d.jsx)(s.HiddenInput,{type:`text`,name:b,form:x,disabled:V.disabled,value:i.hsvToHex(V.color),required:se,onInvalid:()=>Q.current?.focus()})]})};m.displayName=`ColorSlider`,exports.ColorSlider=m;
2
+ //# sourceMappingURL=ColorSlider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorSlider.cjs","names":["useColorPartState","displayColor","toPercent","useFieldContext","useFieldControl","React","useMergedRefs","composeEventHandlers","railKeyTarget","getDirection","colorSliderGradient","toPosition","hsvToHex","cn","colorSliderClassNames","RAIL_ROOT_VERTICAL","RAIL_ROOT_HORIZONTAL","RAIL_GRADIENT","RAIL_TRACK_VERTICAL","RAIL_TRACK_HORIZONTAL","sliderValueText","RAIL_INPUT_CLASSES","RAIL_INPUT_VERTICAL","RAIL_INPUT_HORIZONTAL","THUMB_TRACK_VERTICAL","THUMB_TRACK_HORIZONTAL","COLOR_THUMB_CLASSES","THUMB_POSITION_VERTICAL","THUMB_POSITION_HORIZONTAL","HiddenInput","require_runtime","require_cn","require_composeEventHandlers","require_classNames","require_color","require_direction","require_useMergedRefs","require_useFieldControl","require_useFormReset","require_HiddenInput","require_colorUtils","require_ColorPicker_parts","react","react_jsx_runtime","DEFAULT_LABELS","NAME_KEY","ColorSlider","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","ariaDetails","rest","part","strings","picker","labels","resolvedShape","shape","vertical","orientation","shown","max","channel","current","field","_ariaRequired","_required","inputFieldProps","invalid","isInvalid","isRequired","required","inputRef","mergedControlRef","controlRef","form","apply","next","color","handleKeyDown","onKeyDown","event","target","handleChange","sliderStyle","style","className"],"sources":["../../../src/components/input/ColorSlider.tsx"],"sourcesContent":["import * as React from 'react';\nimport { colorSliderClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { hsvToHex } from '../../lib/color';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { getDirection } from '../../lib/direction';\nimport type { ColorPickerShape, HsvColor, Orientation } from '../../lib/types';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { useColorPartState } from './ColorPicker.parts';\nimport {\n COLOR_THUMB_CLASSES,\n RAIL_GRADIENT,\n RAIL_INPUT_CLASSES,\n RAIL_INPUT_HORIZONTAL,\n RAIL_INPUT_VERTICAL,\n RAIL_ROOT_HORIZONTAL,\n RAIL_ROOT_VERTICAL,\n RAIL_TRACK_HORIZONTAL,\n RAIL_TRACK_VERTICAL,\n THUMB_POSITION_HORIZONTAL,\n THUMB_POSITION_VERTICAL,\n THUMB_TRACK_HORIZONTAL,\n THUMB_TRACK_VERTICAL,\n colorSliderGradient,\n displayColor,\n railKeyTarget,\n sliderValueText,\n toPercent,\n toPosition,\n} from './colorUtils';\n\n/** Texts of a ColorSlider, for localisation. Every key is optional. */\nexport interface ColorSliderLabels {\n /** Name of a hue slider.\n * @default 'Hue'\n */\n hue?: string;\n /** Name of a `channel=\"saturation\"` slider.\n * @default 'Saturation'\n */\n saturation?: string;\n /** Name of a `channel=\"value\"` slider.\n * @default 'Brightness'\n */\n brightness?: string;\n /** Names the color at the end of a hue slider's value text; return `''` to leave it out.\n * @default an English namer (\"blue\")\n */\n colorName?: (color: HsvColor) => string;\n /** Replaces the value text, for languages whose order differs. */\n valueText?: (color: HsvColor, channel: 'hue' | 'saturation' | 'value') => string;\n}\n\n/** Properties for the ColorSlider component. */\nexport interface ColorSliderProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'defaultValue' | 'onChange'\n> {\n /** The channel the slider edits.\n * @default 'hue'\n */\n channel?: 'hue' | 'saturation' | 'value';\n /** `'vertical'` draws the rail from bottom to top (Fluent's `vertical`).\n * @default 'horizontal'\n */\n orientation?: Orientation;\n /**\n * The color (Fluent's `color`). Inside a ColorPicker, leave `value` and `defaultValue` out to\n * bind the slider to the picker.\n */\n value?: HsvColor;\n /**\n * Initial color for uncontrolled usage (also what a form reset restores).\n * @default the brand blue, `{ h: 208, s: 0.92, v: 0.74 }` (`#0f6cbd`)\n */\n defaultValue?: HsvColor;\n /**\n * Called with the new color on every step (a key, the pointer or assistive technology) that\n * changes it (Fluent's `onChange`). A bound slider calls it too.\n */\n onValueChange?: (value: HsvColor) => void;\n /**\n * `'square'` removes the corner radius of the rail (the thumb stays round). Bound to a\n * ColorPicker, the picker's shape unless you pass one.\n * @default 'rounded'\n */\n shape?: ColorPickerShape;\n /** Texts of the slider; bound to a ColorPicker, the picker's `labels` fill the keys you leave out. */\n labels?: ColorSliderLabels;\n /**\n * Unavailable: the input is natively disabled and the slider dimmed. A bound slider is also\n * disabled while the picker's value is not a hex color.\n * @default false\n */\n disabled?: boolean;\n /** Form field name: the color is submitted as hex (`hsvToHex`). Ignored while bound to a ColorPicker. */\n name?: string;\n /** Id of the form the slider belongs to, when it is rendered outside that form. */\n form?: string;\n /**\n * Marks the hidden form input required (a color is always set, so it never blocks). A consumer\n * `aria-required` does the same: a slider supports neither, so neither is set on it.\n */\n required?: boolean;\n /** Ref to the `<input type=\"range\">`. */\n controlRef?: React.Ref<HTMLInputElement>;\n /** Ref to the root element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst DEFAULT_LABELS = { hue: 'Hue', saturation: 'Saturation', brightness: 'Brightness' } as const;\n\n/** The `labels` key that names each channel. */\nconst NAME_KEY = { hue: 'hue', saturation: 'saturation', value: 'brightness' } as const;\n\n/**\n * A slider for one channel of an HSV color: hue (the default), saturation or brightness\n * (`channel=\"value\"`), horizontal (mirrored in right-to-left layouts) or vertical (bottom to top).\n * The arrow keys move by 1 (hue in degrees, the others in percent), Shift with an arrow and Page\n * Up or Page Down by 10, Home and End to the ends. It is named by `aria-label`, else the\n * surrounding Field's label, else \"Hue\", \"Saturation\" or \"Brightness\"; a hue slider's value text\n * names the color (\"210°, blue\"). Inside a ColorPicker, leave `value` and `defaultValue` out and\n * it binds to the picker. Fluent's `ColorSlider`, with `value`/`onValueChange` for its\n * `color`/`onChange` and `orientation` for its `vertical`.\n *\n * @example\n * <ColorSlider value={color} onValueChange={setColor} />\n */\nexport const ColorSlider = ({\n channel = 'hue',\n orientation = 'horizontal',\n value,\n defaultValue,\n onValueChange,\n shape,\n labels,\n disabled = false,\n name,\n form,\n required,\n controlRef,\n className,\n style,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n 'aria-details': ariaDetails,\n autoFocus,\n tabIndex,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n ref,\n ...rest\n}: ColorSliderProps) => {\n const part = useColorPartState({ value, defaultValue, onValueChange, disabled });\n const { picker } = part;\n const strings = {\n ...DEFAULT_LABELS,\n ...(picker && {\n hue: picker.labels.hue,\n saturation: picker.labels.saturation,\n brightness: picker.labels.brightness,\n colorName: picker.labels.colorName,\n valueText: picker.labels.valueText,\n }),\n ...labels,\n };\n const resolvedShape = shape ?? picker?.shape ?? 'rounded';\n const vertical = orientation === 'vertical';\n const shown = displayColor(part.color);\n const max = channel === 'hue' ? 360 : 100;\n const current =\n channel === 'hue'\n ? Math.round(shown.h)\n : toPercent(channel === 'saturation' ? shown.s : shown.v);\n\n const field = useFieldContext();\n const fieldProps = useFieldControl({\n id,\n // The built-in name only without a Field: an aria-label would beat the Field's <label for>.\n 'aria-label':\n ariaLabel ??\n (field === null && ariaLabelledBy === undefined ? strings[NAME_KEY[channel]] : undefined),\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n });\n // A slider supports neither aria-required nor a native `required`: the hidden input carries it.\n const { 'aria-required': _ariaRequired, required: _required, ...inputFieldProps } = fieldProps;\n const invalid = inputFieldProps['aria-invalid'];\n const isInvalid = invalid !== undefined && invalid !== false && invalid !== 'false';\n const isRequired =\n required ?? (ariaRequired === true || ariaRequired === 'true' || (field?.required ?? false));\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const mergedControlRef = useMergedRefs(inputRef, controlRef);\n useFormReset(inputRef, part.reset, form);\n\n /** Applies a value of the slider's range (the hue in degrees, the others in percent). */\n const apply = (next: number) => {\n if (next === current) return;\n const color = part.color;\n part.setColor(\n channel === 'hue'\n ? { ...color, h: next }\n : channel === 'saturation'\n ? { ...color, s: next / 100 }\n : { ...color, v: next / 100 },\n );\n };\n\n const handleKeyDown = composeEventHandlers(\n onKeyDown,\n (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (part.disabled || event.nativeEvent.isComposing) return;\n const target = railKeyTarget(\n event.key,\n event,\n getDirection(event.currentTarget),\n current,\n max,\n );\n if (target === null) return;\n event.preventDefault();\n apply(target);\n },\n );\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (part.disabled) return;\n apply(Math.min(max, Math.max(0, Math.round(Number(event.currentTarget.value)))));\n };\n\n const sliderStyle = {\n ...style,\n '--wave-color-slider-gradient': colorSliderGradient(channel, shown, orientation),\n '--wave-color-slider-position': toPosition(current / max),\n '--wave-color-thumb':\n channel === 'hue'\n ? hsvToHex({ h: shown.h, s: 1, v: 1 })\n : hsvToHex({ h: shown.h, s: shown.s, v: shown.v }),\n } as React.CSSProperties;\n\n return (\n <div\n data-orientation={orientation}\n data-channel={channel}\n data-disabled={part.disabled ? '' : undefined}\n className={cn(\n colorSliderClassNames.root,\n 'group/color-slider relative flex touch-none select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50',\n vertical ? RAIL_ROOT_VERTICAL : RAIL_ROOT_HORIZONTAL,\n className,\n )}\n style={sliderStyle}\n {...rest}\n ref={ref}\n >\n <div\n aria-hidden=\"true\"\n className={cn(\n colorSliderClassNames.rail,\n 'rounded-full forced-colors:forced-color-adjust-none',\n RAIL_GRADIENT,\n vertical ? RAIL_TRACK_VERTICAL : RAIL_TRACK_HORIZONTAL,\n resolvedShape === 'square' && 'rounded-none',\n )}\n />\n <input\n type=\"range\"\n {...inputFieldProps}\n ref={mergedControlRef}\n min={0}\n max={max}\n step={1}\n value={current}\n disabled={part.disabled}\n dir={vertical ? 'ltr' : undefined}\n aria-orientation={vertical ? 'vertical' : undefined}\n aria-valuetext={sliderValueText(shown, channel, strings)}\n aria-errormessage={(isInvalid && ariaErrorMessage) || undefined}\n aria-details={ariaDetails}\n autoFocus={autoFocus}\n tabIndex={tabIndex}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n onChange={handleChange}\n className={cn(RAIL_INPUT_CLASSES, vertical ? RAIL_INPUT_VERTICAL : RAIL_INPUT_HORIZONTAL)}\n />\n <span aria-hidden=\"true\" className={vertical ? THUMB_TRACK_VERTICAL : THUMB_TRACK_HORIZONTAL}>\n <span\n className={cn(\n colorSliderClassNames.thumb,\n COLOR_THUMB_CLASSES,\n vertical ? THUMB_POSITION_VERTICAL : THUMB_POSITION_HORIZONTAL,\n 'group-has-[:focus-visible]/color-slider:ring-2 group-has-[:focus-visible]/color-slider:ring-background forced-colors:group-has-[:focus-visible]/color-slider:ring-[Canvas] group-has-[:focus-visible]/color-slider:outline-2 group-has-[:focus-visible]/color-slider:outline-offset-2 group-has-[:focus-visible]/color-slider:outline-ring forced-colors:group-has-[:focus-visible]/color-slider:outline-[Highlight]',\n )}\n />\n </span>\n {!picker && (\n <HiddenInput\n type=\"text\"\n name={name}\n form={form}\n disabled={part.disabled}\n value={hsvToHex(part.color)}\n required={isRequired}\n onInvalid={() => inputRef.current?.focus()}\n />\n )}\n </div>\n );\n};\n\nColorSlider.displayName = 'ColorSlider';\n"],"mappings":"0jBAiHA,IAAM4C,EAAiB,CAAE,IAAK,MAAO,WAAY,aAAc,WAAY,YAAa,EAGlFC,EAAW,CAAE,IAAK,MAAO,WAAY,aAAc,MAAO,YAAa,EAehEC,GAAe,CAC1B,UAAU,MACV,cAAc,aACd,SACA,eACA,gBACA,QACA,SACA,WAAW,GACX,OACA,OACA,WACA,cACA,YACA,QACA,KACA,aAAcC,EACd,kBAAmBC,EACnB,mBAAoBC,EACpB,eAAgBC,EAChB,gBAAiBC,EACjB,oBAAqBC,EACrB,eAAgBC,EAChB,YACA,WACA,UACA,SACA,YACA,UACA,MACA,GAAGC,KACmB,CACtB,IAAMC,EAAOvD,EAAAA,kBAAkB,CAAE,SAAO,eAAc,gBAAe,UAAS,CAAC,EACzE,CAAE,UAAWuD,EACbC,EAAU,CACd,GAAGZ,EACH,GAAIa,GAAU,CACZ,IAAKA,EAAO,OAAO,IACnB,WAAYA,EAAO,OAAO,WAC1B,WAAYA,EAAO,OAAO,WAC1B,UAAWA,EAAO,OAAO,UACzB,UAAWA,EAAO,OAAO,SAC3B,EACA,GAAGC,CACL,EACMC,EAAgBC,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