@mortenbrudvik/waveui 0.7.0 → 0.9.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 (439) hide show
  1. package/README.md +564 -155
  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/InfoButton.cjs +2 -0
  63. package/dist/components/data-display/InfoButton.cjs.map +1 -0
  64. package/dist/components/data-display/InfoButton.mjs +173 -0
  65. package/dist/components/data-display/InfoButton.mjs.map +1 -0
  66. package/dist/components/data-display/InfoLabel.cjs +1 -1
  67. package/dist/components/data-display/InfoLabel.cjs.map +1 -1
  68. package/dist/components/data-display/InfoLabel.mjs +36 -92
  69. package/dist/components/data-display/InfoLabel.mjs.map +1 -1
  70. package/dist/components/data-display/List.cjs +1 -1
  71. package/dist/components/data-display/List.cjs.map +1 -1
  72. package/dist/components/data-display/List.mjs +175 -174
  73. package/dist/components/data-display/List.mjs.map +1 -1
  74. package/dist/components/data-display/Persona.cjs +1 -1
  75. package/dist/components/data-display/Persona.cjs.map +1 -1
  76. package/dist/components/data-display/Persona.mjs +31 -29
  77. package/dist/components/data-display/Persona.mjs.map +1 -1
  78. package/dist/components/data-display/PresenceBadge.cjs +1 -1
  79. package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
  80. package/dist/components/data-display/PresenceBadge.mjs +25 -24
  81. package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
  82. package/dist/components/data-display/Tag.cjs +1 -1
  83. package/dist/components/data-display/Tag.cjs.map +1 -1
  84. package/dist/components/data-display/Tag.mjs +87 -82
  85. package/dist/components/data-display/Tag.mjs.map +1 -1
  86. package/dist/components/feedback/MessageBar.cjs +1 -1
  87. package/dist/components/feedback/MessageBar.cjs.map +1 -1
  88. package/dist/components/feedback/MessageBar.mjs +129 -71
  89. package/dist/components/feedback/MessageBar.mjs.map +1 -1
  90. package/dist/components/feedback/MessageBar.parts.cjs +2 -0
  91. package/dist/components/feedback/MessageBar.parts.cjs.map +1 -0
  92. package/dist/components/feedback/MessageBar.parts.mjs +84 -0
  93. package/dist/components/feedback/MessageBar.parts.mjs.map +1 -0
  94. package/dist/components/feedback/MessageBar.reflow.cjs +2 -0
  95. package/dist/components/feedback/MessageBar.reflow.cjs.map +1 -0
  96. package/dist/components/feedback/MessageBar.reflow.mjs +74 -0
  97. package/dist/components/feedback/MessageBar.reflow.mjs.map +1 -0
  98. package/dist/components/feedback/MessageBar.status.cjs +1 -1
  99. package/dist/components/feedback/MessageBar.status.cjs.map +1 -1
  100. package/dist/components/feedback/MessageBar.status.mjs +2 -1
  101. package/dist/components/feedback/MessageBar.status.mjs.map +1 -1
  102. package/dist/components/feedback/ProgressBar.cjs +1 -1
  103. package/dist/components/feedback/ProgressBar.cjs.map +1 -1
  104. package/dist/components/feedback/ProgressBar.mjs +44 -43
  105. package/dist/components/feedback/ProgressBar.mjs.map +1 -1
  106. package/dist/components/feedback/Skeleton.cjs +1 -1
  107. package/dist/components/feedback/Skeleton.cjs.map +1 -1
  108. package/dist/components/feedback/Skeleton.mjs +26 -24
  109. package/dist/components/feedback/Skeleton.mjs.map +1 -1
  110. package/dist/components/feedback/Spinner.cjs +1 -1
  111. package/dist/components/feedback/Spinner.cjs.map +1 -1
  112. package/dist/components/feedback/Spinner.mjs +32 -31
  113. package/dist/components/feedback/Spinner.mjs.map +1 -1
  114. package/dist/components/feedback/Toast.cjs +1 -1
  115. package/dist/components/feedback/Toast.cjs.map +1 -1
  116. package/dist/components/feedback/Toast.context.cjs +2 -0
  117. package/dist/components/feedback/Toast.context.cjs.map +1 -0
  118. package/dist/components/feedback/Toast.context.mjs +23 -0
  119. package/dist/components/feedback/Toast.context.mjs.map +1 -0
  120. package/dist/components/feedback/Toast.mjs +10 -342
  121. package/dist/components/feedback/Toast.mjs.map +1 -1
  122. package/dist/components/feedback/Toast.parts.cjs +2 -0
  123. package/dist/components/feedback/Toast.parts.cjs.map +1 -0
  124. package/dist/components/feedback/Toast.parts.mjs +98 -0
  125. package/dist/components/feedback/Toast.parts.mjs.map +1 -0
  126. package/dist/components/feedback/Toast.root.cjs +2 -0
  127. package/dist/components/feedback/Toast.root.cjs.map +1 -0
  128. package/dist/components/feedback/Toast.root.mjs +109 -0
  129. package/dist/components/feedback/Toast.root.mjs.map +1 -0
  130. package/dist/components/feedback/Toaster.cjs +2 -0
  131. package/dist/components/feedback/Toaster.cjs.map +1 -0
  132. package/dist/components/feedback/Toaster.mjs +564 -0
  133. package/dist/components/feedback/Toaster.mjs.map +1 -0
  134. package/dist/components/input/AlphaSlider.cjs +2 -0
  135. package/dist/components/input/AlphaSlider.cjs.map +1 -0
  136. package/dist/components/input/AlphaSlider.mjs +115 -0
  137. package/dist/components/input/AlphaSlider.mjs.map +1 -0
  138. package/dist/components/input/Checkbox.cjs +1 -1
  139. package/dist/components/input/Checkbox.cjs.map +1 -1
  140. package/dist/components/input/Checkbox.mjs +87 -70
  141. package/dist/components/input/Checkbox.mjs.map +1 -1
  142. package/dist/components/input/ColorArea.cjs +2 -0
  143. package/dist/components/input/ColorArea.cjs.map +1 -0
  144. package/dist/components/input/ColorArea.mjs +204 -0
  145. package/dist/components/input/ColorArea.mjs.map +1 -0
  146. package/dist/components/input/ColorPicker.cjs +5 -5
  147. package/dist/components/input/ColorPicker.cjs.map +1 -1
  148. package/dist/components/input/ColorPicker.mjs +142 -165
  149. package/dist/components/input/ColorPicker.mjs.map +1 -1
  150. package/dist/components/input/ColorPicker.parts.cjs +2 -0
  151. package/dist/components/input/ColorPicker.parts.cjs.map +1 -0
  152. package/dist/components/input/ColorPicker.parts.mjs +192 -0
  153. package/dist/components/input/ColorPicker.parts.mjs.map +1 -0
  154. package/dist/components/input/ColorSlider.cjs +2 -0
  155. package/dist/components/input/ColorSlider.cjs.map +1 -0
  156. package/dist/components/input/ColorSlider.mjs +138 -0
  157. package/dist/components/input/ColorSlider.mjs.map +1 -0
  158. package/dist/components/input/Combobox.cjs +1 -1
  159. package/dist/components/input/Combobox.cjs.map +1 -1
  160. package/dist/components/input/Combobox.expand.cjs +1 -1
  161. package/dist/components/input/Combobox.expand.cjs.map +1 -1
  162. package/dist/components/input/Combobox.expand.mjs +22 -22
  163. package/dist/components/input/Combobox.expand.mjs.map +1 -1
  164. package/dist/components/input/Combobox.mjs +151 -141
  165. package/dist/components/input/Combobox.mjs.map +1 -1
  166. package/dist/components/input/DatePicker.cjs +1 -1
  167. package/dist/components/input/DatePicker.cjs.map +1 -1
  168. package/dist/components/input/DatePicker.mjs +239 -234
  169. package/dist/components/input/DatePicker.mjs.map +1 -1
  170. package/dist/components/input/Dropdown.cjs +1 -1
  171. package/dist/components/input/Dropdown.cjs.map +1 -1
  172. package/dist/components/input/Dropdown.mjs +109 -100
  173. package/dist/components/input/Dropdown.mjs.map +1 -1
  174. package/dist/components/input/Field.cjs +1 -1
  175. package/dist/components/input/Field.cjs.map +1 -1
  176. package/dist/components/input/Field.mjs +139 -105
  177. package/dist/components/input/Field.mjs.map +1 -1
  178. package/dist/components/input/Input.cjs +1 -1
  179. package/dist/components/input/Input.cjs.map +1 -1
  180. package/dist/components/input/Input.mjs +80 -55
  181. package/dist/components/input/Input.mjs.map +1 -1
  182. package/dist/components/input/Label.cjs +1 -1
  183. package/dist/components/input/Label.cjs.map +1 -1
  184. package/dist/components/input/Label.mjs +19 -12
  185. package/dist/components/input/Label.mjs.map +1 -1
  186. package/dist/components/input/Option.cjs +1 -1
  187. package/dist/components/input/Option.cjs.map +1 -1
  188. package/dist/components/input/Option.mjs +100 -98
  189. package/dist/components/input/Option.mjs.map +1 -1
  190. package/dist/components/input/RadioGroup.cjs +1 -1
  191. package/dist/components/input/RadioGroup.cjs.map +1 -1
  192. package/dist/components/input/RadioGroup.mjs +89 -88
  193. package/dist/components/input/RadioGroup.mjs.map +1 -1
  194. package/dist/components/input/Rating.cjs +1 -1
  195. package/dist/components/input/Rating.cjs.map +1 -1
  196. package/dist/components/input/Rating.item.cjs +2 -0
  197. package/dist/components/input/Rating.item.cjs.map +1 -0
  198. package/dist/components/input/Rating.item.mjs +255 -0
  199. package/dist/components/input/Rating.item.mjs.map +1 -0
  200. package/dist/components/input/Rating.mjs +152 -152
  201. package/dist/components/input/Rating.mjs.map +1 -1
  202. package/dist/components/input/SearchBox.cjs +1 -1
  203. package/dist/components/input/SearchBox.cjs.map +1 -1
  204. package/dist/components/input/SearchBox.mjs +162 -132
  205. package/dist/components/input/SearchBox.mjs.map +1 -1
  206. package/dist/components/input/Select.cjs +1 -1
  207. package/dist/components/input/Select.cjs.map +1 -1
  208. package/dist/components/input/Select.mjs +34 -24
  209. package/dist/components/input/Select.mjs.map +1 -1
  210. package/dist/components/input/Slider.cjs +1 -1
  211. package/dist/components/input/Slider.cjs.map +1 -1
  212. package/dist/components/input/Slider.mjs +78 -54
  213. package/dist/components/input/Slider.mjs.map +1 -1
  214. package/dist/components/input/SpinButton.cjs +1 -1
  215. package/dist/components/input/SpinButton.cjs.map +1 -1
  216. package/dist/components/input/SpinButton.mjs +202 -99
  217. package/dist/components/input/SpinButton.mjs.map +1 -1
  218. package/dist/components/input/SwatchPicker.cjs +1 -1
  219. package/dist/components/input/SwatchPicker.cjs.map +1 -1
  220. package/dist/components/input/SwatchPicker.mjs +38 -37
  221. package/dist/components/input/SwatchPicker.mjs.map +1 -1
  222. package/dist/components/input/Switch.cjs +1 -1
  223. package/dist/components/input/Switch.cjs.map +1 -1
  224. package/dist/components/input/Switch.mjs +75 -58
  225. package/dist/components/input/Switch.mjs.map +1 -1
  226. package/dist/components/input/TagPicker.cjs +1 -1
  227. package/dist/components/input/TagPicker.cjs.map +1 -1
  228. package/dist/components/input/TagPicker.mjs +199 -169
  229. package/dist/components/input/TagPicker.mjs.map +1 -1
  230. package/dist/components/input/Textarea.cjs +1 -1
  231. package/dist/components/input/Textarea.cjs.map +1 -1
  232. package/dist/components/input/Textarea.mjs +31 -23
  233. package/dist/components/input/Textarea.mjs.map +1 -1
  234. package/dist/components/input/TimePicker.cjs +1 -1
  235. package/dist/components/input/TimePicker.cjs.map +1 -1
  236. package/dist/components/input/TimePicker.mjs +185 -177
  237. package/dist/components/input/TimePicker.mjs.map +1 -1
  238. package/dist/components/input/colorName.cjs +2 -0
  239. package/dist/components/input/colorName.cjs.map +1 -0
  240. package/dist/components/input/colorName.mjs +30 -0
  241. package/dist/components/input/colorName.mjs.map +1 -0
  242. package/dist/components/input/colorUtils.cjs +1 -1
  243. package/dist/components/input/colorUtils.cjs.map +1 -1
  244. package/dist/components/input/colorUtils.mjs +154 -56
  245. package/dist/components/input/colorUtils.mjs.map +1 -1
  246. package/dist/components/input/fieldLabel.cjs +2 -0
  247. package/dist/components/input/fieldLabel.cjs.map +1 -0
  248. package/dist/components/input/fieldLabel.mjs +17 -0
  249. package/dist/components/input/fieldLabel.mjs.map +1 -0
  250. package/dist/components/input/inputLook.cjs +2 -0
  251. package/dist/components/input/inputLook.cjs.map +1 -0
  252. package/dist/components/input/inputLook.mjs +28 -0
  253. package/dist/components/input/inputLook.mjs.map +1 -0
  254. package/dist/components/input/pickerStyles.cjs +1 -1
  255. package/dist/components/input/pickerStyles.cjs.map +1 -1
  256. package/dist/components/input/pickerStyles.mjs +42 -4
  257. package/dist/components/input/pickerStyles.mjs.map +1 -1
  258. package/dist/components/layout/Accordion.cjs +1 -1
  259. package/dist/components/layout/Accordion.cjs.map +1 -1
  260. package/dist/components/layout/Accordion.mjs +130 -129
  261. package/dist/components/layout/Accordion.mjs.map +1 -1
  262. package/dist/components/layout/Card.cjs +1 -1
  263. package/dist/components/layout/Card.cjs.map +1 -1
  264. package/dist/components/layout/Card.mjs +78 -77
  265. package/dist/components/layout/Card.mjs.map +1 -1
  266. package/dist/components/layout/Carousel.cjs +1 -1
  267. package/dist/components/layout/Carousel.cjs.map +1 -1
  268. package/dist/components/layout/Carousel.mjs +111 -110
  269. package/dist/components/layout/Carousel.mjs.map +1 -1
  270. package/dist/components/layout/Flex.cjs +1 -1
  271. package/dist/components/layout/Flex.cjs.map +1 -1
  272. package/dist/components/layout/Flex.mjs +22 -21
  273. package/dist/components/layout/Flex.mjs.map +1 -1
  274. package/dist/components/layout/Grid.cjs +1 -1
  275. package/dist/components/layout/Grid.cjs.map +1 -1
  276. package/dist/components/layout/Grid.mjs +19 -18
  277. package/dist/components/layout/Grid.mjs.map +1 -1
  278. package/dist/components/layout/Overflow.cjs +1 -1
  279. package/dist/components/layout/Overflow.cjs.map +1 -1
  280. package/dist/components/layout/Overflow.mjs +92 -91
  281. package/dist/components/layout/Overflow.mjs.map +1 -1
  282. package/dist/components/layout/Stack.cjs +1 -1
  283. package/dist/components/layout/Stack.cjs.map +1 -1
  284. package/dist/components/layout/Stack.mjs +14 -13
  285. package/dist/components/layout/Stack.mjs.map +1 -1
  286. package/dist/components/layout/TabList.cjs +1 -1
  287. package/dist/components/layout/TabList.cjs.map +1 -1
  288. package/dist/components/layout/TabList.mjs +118 -117
  289. package/dist/components/layout/TabList.mjs.map +1 -1
  290. package/dist/components/layout/Tree.cjs +1 -1
  291. package/dist/components/layout/Tree.cjs.map +1 -1
  292. package/dist/components/layout/Tree.context.cjs +2 -0
  293. package/dist/components/layout/Tree.context.cjs.map +1 -0
  294. package/dist/components/layout/Tree.context.mjs +33 -0
  295. package/dist/components/layout/Tree.context.mjs.map +1 -0
  296. package/dist/components/layout/Tree.core.cjs +2 -0
  297. package/dist/components/layout/Tree.core.cjs.map +1 -0
  298. package/dist/components/layout/Tree.core.mjs +416 -0
  299. package/dist/components/layout/Tree.core.mjs.map +1 -0
  300. package/dist/components/layout/Tree.itemPersonaLayout.cjs +2 -0
  301. package/dist/components/layout/Tree.itemPersonaLayout.cjs.map +1 -0
  302. package/dist/components/layout/Tree.itemPersonaLayout.mjs +46 -0
  303. package/dist/components/layout/Tree.itemPersonaLayout.mjs.map +1 -0
  304. package/dist/components/layout/Tree.mjs +7 -215
  305. package/dist/components/layout/Tree.mjs.map +1 -1
  306. package/dist/components/layout/Tree.selection.cjs +2 -0
  307. package/dist/components/layout/Tree.selection.cjs.map +1 -0
  308. package/dist/components/layout/Tree.selection.mjs +73 -0
  309. package/dist/components/layout/Tree.selection.mjs.map +1 -0
  310. package/dist/components/navigation/Breadcrumb.cjs +1 -1
  311. package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
  312. package/dist/components/navigation/Breadcrumb.mjs +76 -75
  313. package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
  314. package/dist/components/navigation/Menu.group.cjs +1 -1
  315. package/dist/components/navigation/Menu.group.cjs.map +1 -1
  316. package/dist/components/navigation/Menu.group.mjs +39 -37
  317. package/dist/components/navigation/Menu.group.mjs.map +1 -1
  318. package/dist/components/navigation/Menu.items.cjs +1 -1
  319. package/dist/components/navigation/Menu.items.cjs.map +1 -1
  320. package/dist/components/navigation/Menu.items.mjs +67 -61
  321. package/dist/components/navigation/Menu.items.mjs.map +1 -1
  322. package/dist/components/navigation/Menu.link.cjs +1 -1
  323. package/dist/components/navigation/Menu.link.cjs.map +1 -1
  324. package/dist/components/navigation/Menu.link.mjs +34 -28
  325. package/dist/components/navigation/Menu.link.mjs.map +1 -1
  326. package/dist/components/navigation/Menu.popover.cjs +1 -1
  327. package/dist/components/navigation/Menu.popover.cjs.map +1 -1
  328. package/dist/components/navigation/Menu.popover.mjs +114 -113
  329. package/dist/components/navigation/Menu.popover.mjs.map +1 -1
  330. package/dist/components/navigation/Menu.root.cjs +1 -1
  331. package/dist/components/navigation/Menu.root.cjs.map +1 -1
  332. package/dist/components/navigation/Menu.root.mjs +171 -170
  333. package/dist/components/navigation/Menu.root.mjs.map +1 -1
  334. package/dist/components/navigation/Menu.selectable.cjs +1 -1
  335. package/dist/components/navigation/Menu.selectable.cjs.map +1 -1
  336. package/dist/components/navigation/Menu.selectable.mjs +85 -63
  337. package/dist/components/navigation/Menu.selectable.mjs.map +1 -1
  338. package/dist/components/navigation/Menu.splitGroup.cjs +1 -1
  339. package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -1
  340. package/dist/components/navigation/Menu.splitGroup.mjs +27 -26
  341. package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -1
  342. package/dist/components/navigation/Menu.trigger.cjs +1 -1
  343. package/dist/components/navigation/Menu.trigger.cjs.map +1 -1
  344. package/dist/components/navigation/Menu.trigger.mjs +6 -6
  345. package/dist/components/navigation/Nav.cjs +1 -1
  346. package/dist/components/navigation/Nav.cjs.map +1 -1
  347. package/dist/components/navigation/Nav.mjs +170 -155
  348. package/dist/components/navigation/Nav.mjs.map +1 -1
  349. package/dist/components/navigation/Pagination.cjs +1 -1
  350. package/dist/components/navigation/Pagination.cjs.map +1 -1
  351. package/dist/components/navigation/Pagination.mjs +73 -65
  352. package/dist/components/navigation/Pagination.mjs.map +1 -1
  353. package/dist/components/navigation/Stepper.cjs +1 -1
  354. package/dist/components/navigation/Stepper.cjs.map +1 -1
  355. package/dist/components/navigation/Stepper.mjs +110 -109
  356. package/dist/components/navigation/Stepper.mjs.map +1 -1
  357. package/dist/components/overlays/Dialog.cjs +1 -1
  358. package/dist/components/overlays/Dialog.cjs.map +1 -1
  359. package/dist/components/overlays/Dialog.mjs +109 -108
  360. package/dist/components/overlays/Dialog.mjs.map +1 -1
  361. package/dist/components/overlays/Drawer.cjs +1 -1
  362. package/dist/components/overlays/Drawer.cjs.map +1 -1
  363. package/dist/components/overlays/Drawer.mjs +110 -109
  364. package/dist/components/overlays/Drawer.mjs.map +1 -1
  365. package/dist/components/overlays/Popover.cjs +1 -1
  366. package/dist/components/overlays/Popover.cjs.map +1 -1
  367. package/dist/components/overlays/Popover.mjs +148 -151
  368. package/dist/components/overlays/Popover.mjs.map +1 -1
  369. package/dist/components/overlays/Popover.shared.cjs +1 -1
  370. package/dist/components/overlays/Popover.shared.cjs.map +1 -1
  371. package/dist/components/overlays/Popover.shared.mjs +82 -77
  372. package/dist/components/overlays/Popover.shared.mjs.map +1 -1
  373. package/dist/components/overlays/TeachingPopover.cjs +1 -1
  374. package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
  375. package/dist/components/overlays/TeachingPopover.mjs +41 -37
  376. package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
  377. package/dist/components/overlays/Tooltip.cjs +1 -1
  378. package/dist/components/overlays/Tooltip.cjs.map +1 -1
  379. package/dist/components/overlays/Tooltip.mjs +87 -86
  380. package/dist/components/overlays/Tooltip.mjs.map +1 -1
  381. package/dist/components/portal/Portal.cjs +1 -1
  382. package/dist/components/portal/Portal.cjs.map +1 -1
  383. package/dist/components/portal/Portal.mjs +33 -32
  384. package/dist/components/portal/Portal.mjs.map +1 -1
  385. package/dist/components/provider/WaveProvider.cjs +1 -1
  386. package/dist/components/provider/WaveProvider.cjs.map +1 -1
  387. package/dist/components/provider/WaveProvider.mjs +36 -29
  388. package/dist/components/provider/WaveProvider.mjs.map +1 -1
  389. package/dist/components/table/DataGrid.cjs +1 -1
  390. package/dist/components/table/DataGrid.cjs.map +1 -1
  391. package/dist/components/table/DataGrid.mjs +228 -227
  392. package/dist/components/table/DataGrid.mjs.map +1 -1
  393. package/dist/components/table/Table.cjs +1 -1
  394. package/dist/components/table/Table.cjs.map +1 -1
  395. package/dist/components/table/Table.mjs +60 -59
  396. package/dist/components/table/Table.mjs.map +1 -1
  397. package/dist/components/typography/Text.cjs +1 -1
  398. package/dist/components/typography/Text.cjs.map +1 -1
  399. package/dist/components/typography/Text.mjs +12 -11
  400. package/dist/components/typography/Text.mjs.map +1 -1
  401. package/dist/hooks/useFieldControl.cjs.map +1 -1
  402. package/dist/hooks/useFieldControl.mjs.map +1 -1
  403. package/dist/hooks/useMediaQuery.cjs +2 -0
  404. package/dist/hooks/useMediaQuery.cjs.map +1 -0
  405. package/dist/hooks/useMediaQuery.mjs +20 -0
  406. package/dist/hooks/useMediaQuery.mjs.map +1 -0
  407. package/dist/hooks/usePrefersReducedMotion.cjs +1 -1
  408. package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -1
  409. package/dist/hooks/usePrefersReducedMotion.mjs +4 -18
  410. package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -1
  411. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  412. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  413. package/dist/hooks/useRovingTabIndex.mjs +3 -3
  414. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  415. package/dist/index.cjs +1 -1
  416. package/dist/index.d.cts +2890 -197
  417. package/dist/index.d.ts +2890 -197
  418. package/dist/index.mjs +101 -87
  419. package/dist/lib/classNames.cjs +2 -0
  420. package/dist/lib/classNames.cjs.map +1 -0
  421. package/dist/lib/classNames.mjs +423 -0
  422. package/dist/lib/classNames.mjs.map +1 -0
  423. package/dist/lib/color.cjs +2 -0
  424. package/dist/lib/color.cjs.map +1 -0
  425. package/dist/lib/color.mjs +86 -0
  426. package/dist/lib/color.mjs.map +1 -0
  427. package/dist/lib/globalRegistry.cjs.map +1 -1
  428. package/dist/lib/globalRegistry.mjs.map +1 -1
  429. package/dist/lib/styles.cjs +1 -1
  430. package/dist/lib/styles.cjs.map +1 -1
  431. package/dist/lib/styles.mjs +21 -4
  432. package/dist/lib/styles.mjs.map +1 -1
  433. package/dist/lib/toaster.cjs +2 -0
  434. package/dist/lib/toaster.cjs.map +1 -0
  435. package/dist/lib/toaster.mjs +77 -0
  436. package/dist/lib/toaster.mjs.map +1 -0
  437. package/dist/styles.css +1 -1
  438. package/package.json +1 -1
  439. package/src/styles/tokens.css +13 -0
@@ -1,96 +1,113 @@
1
1
  "use client";
2
2
  import { cn as e } from "../../lib/cn.mjs";
3
- import { warnDeprecated as t, warnOnce as n } from "../../lib/dev.mjs";
4
- import { materialiseSlotContent as ee, slotRendersContent as r } from "../../lib/slot.mjs";
5
- import { composeEventHandlers as te } from "../../lib/composeEventHandlers.mjs";
6
- import { useControllable as ne } from "../../hooks/useControllable.mjs";
7
- import { useId as i } from "../../hooks/useId.mjs";
8
- import { useMergedRefs as a } from "../../hooks/useMergedRefs.mjs";
3
+ import { warnDeprecated as t, warnOnce as ee } from "../../lib/dev.mjs";
4
+ import { materialiseSlotContent as n, slotRendersContent as r } from "../../lib/slot.mjs";
5
+ import { composeEventHandlers as i } from "../../lib/composeEventHandlers.mjs";
6
+ import { checkboxClassNames as a } from "../../lib/classNames.mjs";
7
+ import { useControllable as te } from "../../hooks/useControllable.mjs";
8
+ import { useId as o } from "../../hooks/useId.mjs";
9
+ import { useMergedRefs as ne } from "../../hooks/useMergedRefs.mjs";
9
10
  import { focusableDisabledProps as re, joinIds as ie } from "../../lib/aria.mjs";
10
11
  import { useFieldContext as ae, useFieldControl as oe } from "../../hooks/useFieldControl.mjs";
11
- import { focusRing as se, forcedColors as o } from "../../lib/styles.mjs";
12
- import { CheckIcon as s, SubtractIcon as c } from "../../lib/icons.mjs";
13
- import { useFormReset as l } from "../../hooks/useFormReset.mjs";
14
- import { HiddenInput as ce } from "../internal/HiddenInput.mjs";
12
+ import { focusRing as se, forcedColors as s } from "../../lib/styles.mjs";
13
+ import { CheckIcon as ce, SubtractIcon as le } from "../../lib/icons.mjs";
14
+ import { useFormReset as c } from "../../hooks/useFormReset.mjs";
15
+ import { HiddenInput as l } from "../internal/HiddenInput.mjs";
15
16
  import * as u from "react";
16
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
17
+ import { jsx as d, jsxs as ue } from "react/jsx-runtime";
17
18
  //#region src/components/input/Checkbox.tsx
18
- var p = "forced-colors:border-[Highlight] forced-colors:bg-[Highlight]", m = "forced-colors:border-[GrayText] forced-colors:bg-[Canvas]", le = "forced-colors:text-[GrayText] forced-colors:forced-color-adjust-none", h = ({ checked: h, defaultChecked: g = !1, indeterminate: _ = !1, onCheckedChange: ue, onChange: v, disabled: y = !1, disabledFocusable: b = !1, label: x, labelPosition: S = "after", name: C, value: w, required: T, form: E, id: D, "aria-label": O, "aria-labelledby": k, "aria-describedby": A, "aria-invalid": j, "aria-required": M, "aria-errormessage": N, "aria-details": P, "aria-disabled": F, autoFocus: I, tabIndex: de, onClick: L, onFocus: R, onBlur: z, onKeyDown: B, onKeyUp: V, controlRef: H, className: fe, children: pe, ref: me, ...he }) => {
19
- v !== void 0 && t("Checkbox", "onChange", "onCheckedChange");
20
- let U = r(pe);
19
+ var de = "forced-colors:border-[Highlight] forced-colors:bg-[Highlight]", fe = "forced-colors:border-[GrayText] forced-colors:bg-[Canvas]", pe = "forced-colors:text-[GrayText] forced-colors:forced-color-adjust-none", f = {
20
+ medium: {
21
+ box: "h-[18px] w-[18px]",
22
+ glyph: 12,
23
+ offset: "mt-px"
24
+ },
25
+ large: {
26
+ box: "h-[22px] w-[22px]",
27
+ glyph: 16,
28
+ offset: "-mt-px"
29
+ }
30
+ }, p = {
31
+ square: "rounded-xs",
32
+ circular: "rounded-full"
33
+ }, m = ({ checked: m, defaultChecked: h = !1, indeterminate: g = !1, onCheckedChange: me, onChange: _, disabled: v = !1, disabledFocusable: y = !1, label: b, labelPosition: x = "after", size: S = "medium", shape: C = "square", name: w, value: T, required: E, form: D, id: O, "aria-label": k, "aria-labelledby": A, "aria-describedby": j, "aria-invalid": M, "aria-required": N, "aria-errormessage": P, "aria-details": F, "aria-disabled": I, autoFocus: L, tabIndex: R, onClick: z, onFocus: he, onBlur: ge, onKeyDown: _e, onKeyUp: ve, controlRef: ye, className: be, children: xe, ref: Se, ...Ce }) => {
34
+ _ !== void 0 && t("Checkbox", "onChange", "onCheckedChange");
35
+ let B = r(xe);
21
36
  u.useEffect(() => {
22
- U && n("Checkbox:children", "Checkbox: children are not rendered. Pass the label in `label`.");
23
- }, [U]);
24
- let [W, G] = ne(h, g, (e) => {
25
- ue?.(e), v?.(e);
26
- }), ge = i("checkbox"), K = i("checkbox-label"), q = ae(), J = oe({
27
- id: D,
28
- "aria-label": O,
29
- "aria-labelledby": k,
30
- "aria-describedby": A,
31
- "aria-invalid": j,
32
- "aria-required": M ?? T
33
- }), _e = T ?? q?.required ?? !1, Y = r(x), ve = Y && J["aria-label"] === void 0 ? ie(J["aria-labelledby"], q && J.id === q.controlId ? q.labelId : void 0, K) : J["aria-labelledby"], X = u.useRef(null), ye = a(X, H);
34
- l(X, () => G(g), E);
35
- let be = W || _, Z = y || b, Q = Z ? le : o.selectedLeaf, $ = Y ? /* @__PURE__ */ d("span", {
36
- id: K,
37
- className: "text-body-1 text-foreground",
38
- children: ee(x)
37
+ B && ee("Checkbox:children", "Checkbox: children are not rendered. Pass the label in `label`.");
38
+ }, [B]);
39
+ let [V, H] = te(m, h, (e) => {
40
+ me?.(e), _?.(e);
41
+ }), we = o("checkbox"), U = o("checkbox-label"), W = ae(), G = oe({
42
+ id: O,
43
+ "aria-label": k,
44
+ "aria-labelledby": A,
45
+ "aria-describedby": j,
46
+ "aria-invalid": M,
47
+ "aria-required": N ?? E
48
+ }), Te = E ?? W?.required ?? !1, K = r(b), Ee = K && G["aria-label"] === void 0 ? ie(G["aria-labelledby"], W && G.id === W.controlId ? W.labelId : void 0, U) : G["aria-labelledby"], q = u.useRef(null), De = ne(q, ye);
49
+ c(q, () => H(h), D);
50
+ let Oe = V || g, J = Object.hasOwn(f, S) ? S : "medium", Y = Object.hasOwn(p, C) ? C : "square", X = f[J], ke = p[Y], Z = v || y, Q = Z ? pe : s.selectedLeaf, $ = K ? /* @__PURE__ */ d("span", {
51
+ id: U,
52
+ className: e(a.label, "text-body-1 text-foreground"),
53
+ children: n(b)
39
54
  }) : null;
40
- return /* @__PURE__ */ f("label", {
41
- ref: me,
42
- "data-label-position": S,
43
- className: e("relative inline-flex items-start gap-2 select-none", Z ? "cursor-not-allowed opacity-50 has-focus-visible:opacity-100" : "cursor-pointer", fe),
44
- ...he,
55
+ return /* @__PURE__ */ ue("label", {
56
+ ref: Se,
57
+ "data-label-position": x,
58
+ "data-size": J,
59
+ "data-shape": Y,
60
+ className: e(a.root, "relative inline-flex items-start gap-2 select-none", Z ? "cursor-not-allowed opacity-50 has-focus-visible:opacity-100" : "cursor-pointer", be),
61
+ ...Ce,
45
62
  children: [
46
- S === "before" && $,
63
+ x === "before" && $,
47
64
  /* @__PURE__ */ d("button", {
48
- id: ge,
65
+ id: we,
49
66
  type: "button",
50
- ...J,
51
- "aria-labelledby": ve,
52
- "aria-errormessage": N,
53
- "aria-details": P,
54
- "aria-disabled": F,
55
- autoFocus: I,
56
- tabIndex: de,
57
- onFocus: R,
58
- onBlur: z,
59
- onKeyDown: B,
60
- onKeyUp: V,
61
- ref: ye,
67
+ ...G,
68
+ "aria-labelledby": Ee,
69
+ "aria-errormessage": P,
70
+ "aria-details": F,
71
+ "aria-disabled": I,
72
+ autoFocus: L,
73
+ tabIndex: R,
74
+ onFocus: he,
75
+ onBlur: ge,
76
+ onKeyDown: _e,
77
+ onKeyUp: ve,
78
+ ref: De,
62
79
  role: "checkbox",
63
- "aria-checked": _ ? "mixed" : W,
64
- disabled: y && !b,
65
- ...re(b, { reachable: !0 }),
66
- onClick: b ? (e) => {
80
+ "aria-checked": g ? "mixed" : V,
81
+ disabled: v && !y,
82
+ ...re(y, { reachable: !0 }),
83
+ onClick: y ? (e) => {
67
84
  e.preventDefault(), e.stopPropagation();
68
- } : te(L, () => G((e) => !e)),
69
- className: e("flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-xs border p-0 transition-colors motion-reduce:transition-none", Y && "mt-px", se, be ? e("border-primary bg-primary text-primary-foreground", Z ? m : p) : e("border-stroke-accessible bg-transparent", Z ? o.disabled : o.control)),
70
- children: _ ? /* @__PURE__ */ d(c, {
71
- size: 12,
85
+ } : i(z, () => H((e) => !e)),
86
+ className: e(a.indicator, e("flex shrink-0 items-center justify-center border p-0 transition-colors motion-reduce:transition-none", X.box, ke), K && X.offset, se, Oe ? e("border-primary bg-primary text-primary-foreground", Z ? fe : de) : e("border-stroke-accessible bg-transparent", Z ? s.disabled : s.control)),
87
+ children: g ? /* @__PURE__ */ d(le, {
88
+ size: X.glyph,
72
89
  className: Q
73
- }) : W ? /* @__PURE__ */ d(s, {
74
- size: 12,
90
+ }) : V ? /* @__PURE__ */ d(ce, {
91
+ size: X.glyph,
75
92
  className: Q
76
93
  }) : null
77
94
  }),
78
- S !== "before" && $,
79
- /* @__PURE__ */ d(ce, {
95
+ x !== "before" && $,
96
+ /* @__PURE__ */ d(l, {
80
97
  type: "checkbox",
81
- name: C,
82
- form: E,
98
+ name: w,
99
+ form: D,
83
100
  disabled: Z,
84
- value: w,
85
- checked: W,
86
- required: _e,
87
- onInvalid: () => X.current?.focus()
101
+ value: T,
102
+ checked: V,
103
+ required: Te,
104
+ onInvalid: () => q.current?.focus()
88
105
  })
89
106
  ]
90
107
  });
91
108
  };
92
- h.displayName = "Checkbox";
109
+ m.displayName = "Checkbox";
93
110
  //#endregion
94
- export { h as Checkbox };
111
+ export { m as Checkbox };
95
112
 
96
113
  //# sourceMappingURL=Checkbox.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.mjs","names":["useId","useId$1","React","checkedBox","disabledCheckedBox","disabledGlyph","Checkbox","checkedProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","ariaDetails","ariaDisabled","rest","onChange","warnDeprecated","hasChildren","slotRendersContent","children","warnOnce","checked","setChecked","useControllable","defaultChecked","onCheckedChange","next","generatedId","labelTextId","field","useFieldContext","fieldProps","useFieldControl","required","isRequired","hasLabel","label","labelledBy","joinIds","buttonRef","mergedControlRef","useMergedRefs","controlRef","form","on","indeterminate","unavailable","disabled","disabledFocusable","glyphClassName","forcedColors","labelText","materialiseSlotContent","labelPosition","cn","className","focusableDisabledProps","event","composeEventHandlers","onClick","prev","focusRing","SubtractIcon","CheckIcon","HiddenInput"],"sources":["../../../src/components/input/Checkbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { focusableDisabledProps, joinIds } from '../../lib/aria';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { CheckIcon, SubtractIcon } from '../../lib/icons';\nimport { materialiseSlotContent, slotRendersContent } from '../../lib/slot';\nimport { focusRing, forcedColors } from '../../lib/styles';\nimport type { LabelPosition } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { 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';\n\n/*\n * Forced colors: the focusable box keeps system-color utilities, so the browser still forces its\n * focus outline and border; only the glyph (the leaf indicator) opts out of forced colors. A\n * disabled box draws a GrayText glyph and border on Canvas, without the Highlight fill.\n */\nconst checkedBox = 'forced-colors:border-[Highlight] forced-colors:bg-[Highlight]';\nconst disabledCheckedBox = 'forced-colors:border-[GrayText] forced-colors:bg-[Canvas]';\nconst disabledGlyph = 'forced-colors:text-[GrayText] forced-colors:forced-color-adjust-none';\n\n/** Handlers that run on the `role=\"checkbox\"` button instead of the root label (C-ROUTING). */\ntype CheckboxControlHandlers = 'onClick' | 'onFocus' | 'onBlur' | 'onKeyDown' | 'onKeyUp';\n\n/** Where a Checkbox renders its label: after the box (default) or before it. */\nexport type CheckboxLabelPosition = Extract<LabelPosition, 'before' | 'after'>;\n\n/** Properties for the Checkbox component. */\nexport interface CheckboxProps extends Omit<\n React.HTMLAttributes<HTMLLabelElement>,\n 'onChange' | 'defaultChecked' | CheckboxControlHandlers\n> {\n /** Controlled checked state. */\n checked?: boolean;\n /** Initial checked state for uncontrolled usage (also the value a form reset restores).\n * @default false\n */\n defaultChecked?: boolean;\n /**\n * Shows the mixed state: the dash glyph and `aria-checked=\"mixed\"`, whatever `checked` is. A\n * click still toggles `checked` and calls `onCheckedChange`, but the checkbox keeps showing and\n * announcing \"mixed\" until you clear `indeterminate`. For a tri-state \"select all\", derive\n * `checked` and `indeterminate` from the items and set every item in `onCheckedChange`.\n * @default false\n */\n indeterminate?: boolean;\n /** Called with the new checked state when it changes (not for no-op updates). */\n onCheckedChange?: (checked: boolean) => void;\n /**\n * Called with the new checked state when it changes.\n * @deprecated Use `onCheckedChange`.\n */\n onChange?: (checked: boolean) => void;\n /** Whether the checkbox is disabled and non-interactive. */\n disabled?: boolean;\n /**\n * Marks the checkbox unavailable but keeps it focusable and in the tab order: for a disabled\n * checkbox that needs a Tooltip, or one in a toolbar. Renders `aria-disabled=\"true\"`,\n * `data-disabled` and `data-disabled-focusable` on the checkbox instead of the native `disabled`\n * attribute. The checkbox cannot be toggled and is not submitted with its form; your `onClick`\n * is not called, and a click on the checkbox (or Space and Enter) does not reach ancestor click\n * handlers, as for a natively disabled control. Wins over `disabled` when both are set. In a\n * roving container (a `Toolbar`) it stays in the arrow-key order.\n * @default false\n */\n disabledFocusable?: boolean;\n /**\n * Label next to the control (any phrasing content, links included, but no other form\n * controls). It names the control through `aria-labelledby`, after a consumer or Field\n * `aria-labelledby`; a consumer `aria-label` names it instead. Clicking its text toggles the\n * control; clicking a link inside it follows the link. `children` are not rendered: pass the\n * label here.\n */\n label?: React.ReactNode;\n /**\n * Where the label renders: after the control (default) or before it. The DOM order follows the\n * visual order.\n * @default 'after'\n */\n labelPosition?: CheckboxLabelPosition;\n /**\n * Form field name. With a name, the checkbox takes part in native form submission: it submits\n * `name=value` while checked.\n */\n name?: string;\n /** Value submitted while checked.\n * @default 'on'\n */\n value?: string;\n /** The form must not be submitted while the checkbox is unchecked (native validation). */\n required?: boolean;\n /** Id of the form the checkbox belongs to, when it is rendered outside that form. */\n form?: string;\n /** Click handler of the checkbox control (the `role=\"checkbox\"` button). */\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n /** Focus handler of the checkbox control. */\n onFocus?: React.FocusEventHandler<HTMLButtonElement>;\n /** Blur handler of the checkbox control. */\n onBlur?: React.FocusEventHandler<HTMLButtonElement>;\n /** Keydown handler of the checkbox control. */\n onKeyDown?: React.KeyboardEventHandler<HTMLButtonElement>;\n /** Keyup handler of the checkbox control. */\n onKeyUp?: React.KeyboardEventHandler<HTMLButtonElement>;\n /** Ref to the focusable `role=\"checkbox\"` button. */\n controlRef?: React.Ref<HTMLButtonElement>;\n /** Ref to the root `<label>` element. */\n ref?: React.Ref<HTMLLabelElement>;\n}\n\n/**\n * A checkbox for a boolean (or mixed) choice, drawn as a `role=\"checkbox\"` button inside a\n * `<label>`.\n *\n * - The root `<label>` receives `ref`, `className`, `style` and `data-*`; the control receives\n * `id`, `aria-label`/`-labelledby`/`-describedby`/`-invalid`/`-required`/`-errormessage`/\n * `-details`/`-disabled`, `tabIndex`, `autoFocus` and the click, focus and key handlers\n * (`controlRef` exposes it). A consumer `onClick` runs once per activation, before the toggle;\n * `preventDefault()` in it cancels the toggle.\n * - Inside a `Field` it is named by the Field label (followed by its own `label` text) and described\n * by the Field message and hint.\n * - With `name` (or `required`) it takes part in native forms like `<input type=\"checkbox\">`, and\n * a form reset restores `defaultChecked`.\n * - `label` takes rich content (a link to the terms) and renders after the box, or before it with\n * `labelPosition=\"before\"` (the root carries `data-label-position`). The box lines up with the\n * first line of a label that wraps or has a second line. `children` are not rendered (a\n * development warning says so).\n */\nexport const Checkbox = ({\n checked: checkedProp,\n defaultChecked = false,\n indeterminate = false,\n onCheckedChange,\n onChange,\n disabled = false,\n disabledFocusable = false,\n label,\n labelPosition = 'after',\n name,\n value,\n required,\n form,\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 'aria-disabled': ariaDisabled,\n autoFocus,\n tabIndex,\n onClick,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n controlRef,\n className,\n children,\n ref,\n ...rest\n}: CheckboxProps) => {\n if (onChange !== undefined) warnDeprecated('Checkbox', 'onChange', 'onCheckedChange');\n const hasChildren = slotRendersContent(children);\n React.useEffect(() => {\n if (hasChildren) {\n warnOnce(\n 'Checkbox:children',\n 'Checkbox: children are not rendered. Pass the label in `label`.',\n );\n }\n }, [hasChildren]);\n const [checked, setChecked] = useControllable(checkedProp, defaultChecked, (next: boolean) => {\n onCheckedChange?.(next);\n onChange?.(next);\n });\n\n const generatedId = useId('checkbox');\n const labelTextId = useId('checkbox-label');\n const field = useFieldContext();\n const fieldProps = useFieldControl({\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n // An explicit `required={false}` wins over a required Field, so aria-required always matches\n // the native validation below (`isRequired`).\n 'aria-required': ariaRequired ?? required,\n });\n const isRequired = required ?? field?.required ?? false;\n // `0` is a label; `null`, `false`, `''` and empty collections are not (C-SLOTS).\n const hasLabel = slotRendersContent(label);\n // The label text names the control through aria-labelledby, disabled or not: axe exempts the\n // dimmed text of a disabled control only when the control references it this way (its <label>\n // exemption covers native inputs only). A consumer aria-label still names the control alone.\n // The ids already there (the consumer's, the Field label from useFieldControl) come first, then\n // the Field label whose <label htmlFor> targets this control (aria-labelledby would hide it), so\n // the name keeps every label.\n const labelledBy =\n hasLabel && fieldProps['aria-label'] === undefined\n ? joinIds(\n fieldProps['aria-labelledby'],\n field && fieldProps.id === field.controlId ? field.labelId : undefined,\n labelTextId,\n )\n : fieldProps['aria-labelledby'];\n\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const mergedControlRef = useMergedRefs(buttonRef, controlRef);\n useFormReset(buttonRef, () => setChecked(defaultChecked), form);\n\n const on = checked || indeterminate;\n // Focusable-disabled wins over `disabled`: the box stays focusable but looks and acts disabled.\n const unavailable = disabled || disabledFocusable;\n // The glyph is the forced-colors leaf; the box stays on system colors (see `checkedBox`).\n const glyphClassName = unavailable ? disabledGlyph : forcedColors.selectedLeaf;\n const labelText = hasLabel ? (\n <span id={labelTextId} className=\"text-body-1 text-foreground\">\n {materialiseSlotContent(label)}\n </span>\n ) : null;\n\n return (\n <label\n ref={ref}\n data-label-position={labelPosition}\n className={cn(\n // items-start: the box lines up with the first line of a label that wraps or has a second\n // line, not with its middle.\n 'relative inline-flex items-start gap-2 select-none',\n // The dimmed look lifts while a focus ring shows inside the root (the control's, under\n // disabledFocusable, or a link's in the label): opacity would dim the ring below 3:1.\n unavailable\n ? 'cursor-not-allowed opacity-50 has-focus-visible:opacity-100'\n : 'cursor-pointer',\n className,\n )}\n {...rest}\n >\n {labelPosition === 'before' && labelText}\n <button\n id={generatedId}\n type=\"button\"\n {...fieldProps}\n aria-labelledby={labelledBy}\n aria-errormessage={ariaErrorMessage}\n aria-details={ariaDetails}\n aria-disabled={ariaDisabled}\n autoFocus={autoFocus}\n tabIndex={tabIndex}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n ref={mergedControlRef}\n role=\"checkbox\"\n aria-checked={indeterminate ? 'mixed' : checked}\n disabled={disabled && !disabledFocusable}\n {...focusableDisabledProps(disabledFocusable, { reachable: true })}\n onClick={\n disabledFocusable\n ? // Clicks, Space and Enter (which click a button) neither toggle nor reach `onClick`,\n // and, as a natively disabled control dispatches no click, no ancestor sees them.\n (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n event.stopPropagation();\n }\n : composeEventHandlers(onClick, () => setChecked((prev) => !prev))\n }\n className={cn(\n // p-0 and the unchecked bg-transparent are set here, not left to the native reset, which\n // any app button style overrides (C-NATIVE).\n 'flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-xs border p-0 transition-colors motion-reduce:transition-none',\n // Centred on the 20px first line of the label text.\n hasLabel && 'mt-px',\n focusRing,\n on\n ? cn(\n 'border-primary bg-primary text-primary-foreground',\n unavailable ? disabledCheckedBox : checkedBox,\n )\n : cn(\n 'border-stroke-accessible bg-transparent',\n unavailable ? forcedColors.disabled : forcedColors.control,\n ),\n )}\n >\n {indeterminate ? (\n <SubtractIcon size={12} className={glyphClassName} />\n ) : checked ? (\n <CheckIcon size={12} className={glyphClassName} />\n ) : null}\n </button>\n {labelPosition !== 'before' && labelText}\n <HiddenInput\n type=\"checkbox\"\n name={name}\n form={form}\n disabled={unavailable}\n value={value}\n checked={checked}\n required={isRequired}\n onInvalid={() => buttonRef.current?.focus()}\n />\n </label>\n );\n};\n\nCheckbox.displayName = 'Checkbox';\n"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,IAAMG,IAAa,iEACbC,IAAqB,6DACrBC,KAAgB,wEA4GTC,KAAY,EACvB,SAASC,GACT,oBAAiB,IACjB,mBAAgB,IAChB,qBACA,aACA,cAAW,IACX,uBAAoB,IACpB,UACA,mBAAgB,SAChB,SACA,UACA,aACA,SACA,OACA,cAAcC,GACd,mBAAmBC,GACnB,oBAAoBC,GACpB,gBAAgBC,GAChB,iBAAiBC,GACjB,qBAAqBC,GACrB,gBAAgBC,GAChB,iBAAiBC,GACjB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zC;EAdN,UAAA;GAgBGuC,MAAkB,YAAYF;GAC/B,kBAAC,UAAD;IACE,IAAIxB;IACJ,MAAK;IACL,GAAII;IACJ,mBAAiBM;IACjB,qBAAmB1B;IACnB,gBAAcC;IACd,iBAAeC;IACJ;IACD;IACD;IACD;IACG;IACF;IACT,KAAK2B;IACL,MAAK;IACL,gBAAcK,IAAgB,UAAUxB;IACxC,UAAU0B,KAAY,CAACC;IACvB,GAAIQ,GAAuBR,GAAmB,EAAE,WAAW,GAAK,CAAC;IACjE,SACEA,KAGK,MAA+C;KAE9C,AADAS,EAAM,eAAe,GACrBA,EAAM,gBAAgB;IACxB,IACAC,GAAqBC,SAAerC,GAAY,MAAS,CAACsC,CAAI,CAAC;IAErE,WAAWN,EAGT,qIAEAnB,KAAY,SACZ0B,IACAjB,KACIU,EACE,qDACAR,IAAc5C,IAAqBD,CACrC,IACAqD,EACE,2CACAR,IAAcI,EAAa,WAAWA,EAAa,OACrD,CACN;IAEC,UAAAL,IACC,kBAACiB,GAAD;KAAc,MAAM;KAAI,WAAWb;IAAiB,CAAA,IAClD5B,IACF,kBAAC0C,GAAD;KAAW,MAAM;KAAI,WAAWd;IAAiB,CAAA,IAC/C;GACE,CAAA;GACPI,MAAkB,YAAYF;GAC/B,kBAACa,IAAD;IACE,MAAK;IACC;IACA;IACN,UAAUlB;IACH;IACE;IACT,UAAUZ;IACV,iBAAiBK,EAAU,SAAS,MAAM;GAC3C,CAAA;EACI;;AAEX;AAEA,EAAS,cAAc"}
1
+ {"version":3,"file":"Checkbox.mjs","names":["useId","useId$1","React","checkedBox","disabledCheckedBox","disabledGlyph","CHECKBOX_SIZE","CHECKBOX_SHAPE","Checkbox","checkedProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","ariaDetails","ariaDisabled","rest","onChange","warnDeprecated","hasChildren","slotRendersContent","children","warnOnce","checked","setChecked","useControllable","defaultChecked","onCheckedChange","next","generatedId","labelTextId","field","useFieldContext","fieldProps","useFieldControl","required","isRequired","hasLabel","label","labelledBy","joinIds","buttonRef","mergedControlRef","useMergedRefs","controlRef","form","on","indeterminate","resolvedSize","size","resolvedShape","shape","sizeMetrics","shapeClass","unavailable","disabled","disabledFocusable","glyphClassName","forcedColors","labelText","cn","checkboxClassNames","materialiseSlotContent","labelPosition","className","focusableDisabledProps","event","composeEventHandlers","onClick","prev","focusRing","SubtractIcon","CheckIcon","HiddenInput"],"sources":["../../../src/components/input/Checkbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { focusableDisabledProps, joinIds } from '../../lib/aria';\nimport { checkboxClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { CheckIcon, SubtractIcon } from '../../lib/icons';\nimport { materialiseSlotContent, slotRendersContent } from '../../lib/slot';\nimport { focusRing, forcedColors } from '../../lib/styles';\nimport type { LabelPosition, Shape, Size } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { 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';\n\n/*\n * Forced colors: the focusable box keeps system-color utilities, so the browser still forces its\n * focus outline and border; only the glyph (the leaf indicator) opts out of forced colors. A\n * disabled box draws a GrayText glyph and border on Canvas, without the Highlight fill.\n */\nconst checkedBox = 'forced-colors:border-[Highlight] forced-colors:bg-[Highlight]';\nconst disabledCheckedBox = 'forced-colors:border-[GrayText] forced-colors:bg-[Canvas]';\nconst disabledGlyph = 'forced-colors:text-[GrayText] forced-colors:forced-color-adjust-none';\n\n/** Handlers that run on the `role=\"checkbox\"` button instead of the root label (C-ROUTING). */\ntype CheckboxControlHandlers = 'onClick' | 'onFocus' | 'onBlur' | 'onKeyDown' | 'onKeyUp';\n\n/** Where a Checkbox renders its label: after the box (default) or before it. */\nexport type CheckboxLabelPosition = Extract<LabelPosition, 'before' | 'after'>;\n\n/** Size of the box: an 18px box (the 0.7 look) or a 22px box with a bigger glyph. */\nexport type CheckboxSize = Extract<Size, 'medium' | 'large'>;\n\n/** Shape of the box: square corners (the 0.7 look) or a circular, round box. */\nexport type CheckboxShape = Extract<Shape, 'square' | 'circular'>;\n\n/** Per-size box, glyph and label-offset classes. */\nconst CHECKBOX_SIZE: Readonly<\n Record<CheckboxSize, { box: string; glyph: number; offset: string }>\n> = {\n medium: { box: 'h-[18px] w-[18px]', glyph: 12, offset: 'mt-px' },\n large: { box: 'h-[22px] w-[22px]', glyph: 16, offset: '-mt-px' },\n};\n\n/** Per-shape corner classes. */\nconst CHECKBOX_SHAPE: Readonly<Record<CheckboxShape, string>> = {\n square: 'rounded-xs',\n circular: 'rounded-full',\n};\n\n/** Properties for the Checkbox component. */\nexport interface CheckboxProps extends Omit<\n React.HTMLAttributes<HTMLLabelElement>,\n 'onChange' | 'defaultChecked' | CheckboxControlHandlers\n> {\n /** Controlled checked state. */\n checked?: boolean;\n /** Initial checked state for uncontrolled usage (also the value a form reset restores).\n * @default false\n */\n defaultChecked?: boolean;\n /**\n * Shows the mixed state: the dash glyph and `aria-checked=\"mixed\"`, whatever `checked` is. A\n * click still toggles `checked` and calls `onCheckedChange`, but the checkbox keeps showing and\n * announcing \"mixed\" until you clear `indeterminate`. For a tri-state \"select all\", derive\n * `checked` and `indeterminate` from the items and set every item in `onCheckedChange`.\n * @default false\n */\n indeterminate?: boolean;\n /** Called with the new checked state when it changes (not for no-op updates). */\n onCheckedChange?: (checked: boolean) => void;\n /**\n * Called with the new checked state when it changes.\n * @deprecated Use `onCheckedChange`.\n */\n onChange?: (checked: boolean) => void;\n /** Whether the checkbox is disabled and non-interactive. */\n disabled?: boolean;\n /**\n * Marks the checkbox unavailable but keeps it focusable and in the tab order: for a disabled\n * checkbox that needs a Tooltip, or one in a toolbar. Renders `aria-disabled=\"true\"`,\n * `data-disabled` and `data-disabled-focusable` on the checkbox instead of the native `disabled`\n * attribute. The checkbox cannot be toggled and is not submitted with its form; your `onClick`\n * is not called, and a click on the checkbox (or Space and Enter) does not reach ancestor click\n * handlers, as for a natively disabled control. Wins over `disabled` when both are set. In a\n * roving container (a `Toolbar`) it stays in the arrow-key order.\n * @default false\n */\n disabledFocusable?: boolean;\n /**\n * Label next to the control (any phrasing content, links included, but no other form\n * controls). It names the control through `aria-labelledby`, after a consumer or Field\n * `aria-labelledby`; a consumer `aria-label` names it instead. Clicking its text toggles the\n * control; clicking a link inside it follows the link. `children` are not rendered: pass the\n * label here.\n */\n label?: React.ReactNode;\n /**\n * Where the label renders: after the control (default) or before it. The DOM order follows the\n * visual order.\n * @default 'after'\n */\n labelPosition?: CheckboxLabelPosition;\n /**\n * Size of the box: an 18px box (the 0.7 look) or a 22px box with a bigger glyph. Unlike the\n * text controls and pickers, Checkbox does not read a surrounding Field's size or a\n * WaveProvider's input defaults: this prop is the only source of its size.\n * @default 'medium'\n */\n size?: CheckboxSize;\n /**\n * Shape of the box: square corners (the 0.7 look) or a circular, round box.\n * @default 'square'\n */\n shape?: CheckboxShape;\n /**\n * Form field name. With a name, the checkbox takes part in native form submission: it submits\n * `name=value` while checked.\n */\n name?: string;\n /** Value submitted while checked.\n * @default 'on'\n */\n value?: string;\n /** The form must not be submitted while the checkbox is unchecked (native validation). */\n required?: boolean;\n /** Id of the form the checkbox belongs to, when it is rendered outside that form. */\n form?: string;\n /** Click handler of the checkbox control (the `role=\"checkbox\"` button). */\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n /** Focus handler of the checkbox control. */\n onFocus?: React.FocusEventHandler<HTMLButtonElement>;\n /** Blur handler of the checkbox control. */\n onBlur?: React.FocusEventHandler<HTMLButtonElement>;\n /** Keydown handler of the checkbox control. */\n onKeyDown?: React.KeyboardEventHandler<HTMLButtonElement>;\n /** Keyup handler of the checkbox control. */\n onKeyUp?: React.KeyboardEventHandler<HTMLButtonElement>;\n /** Ref to the focusable `role=\"checkbox\"` button. */\n controlRef?: React.Ref<HTMLButtonElement>;\n /** Ref to the root `<label>` element. */\n ref?: React.Ref<HTMLLabelElement>;\n}\n\n/**\n * A checkbox for a boolean (or mixed) choice, drawn as a `role=\"checkbox\"` button inside a\n * `<label>`.\n *\n * - The root `<label>` receives `ref`, `className`, `style` and `data-*`; the control receives\n * `id`, `aria-label`/`-labelledby`/`-describedby`/`-invalid`/`-required`/`-errormessage`/\n * `-details`/`-disabled`, `tabIndex`, `autoFocus` and the click, focus and key handlers\n * (`controlRef` exposes it). A consumer `onClick` runs once per activation, before the toggle;\n * `preventDefault()` in it cancels the toggle.\n * - Inside a `Field` it is named by the Field label (followed by its own `label` text) and described\n * by the Field message and hint.\n * - With `name` (or `required`) it takes part in native forms like `<input type=\"checkbox\">`, and\n * a form reset restores `defaultChecked`.\n * - `label` takes rich content (a link to the terms) and renders after the box, or before it with\n * `labelPosition=\"before\"` (the root carries `data-label-position`). The box lines up with the\n * first line of a label that wraps or has a second line. `children` are not rendered (a\n * development warning says so).\n * - `size` (`medium`, `large`) and `shape` (`square`, `circular`) set the box's dimensions and\n * corners; the root carries `data-size` and `data-shape`. Checkbox does not read a surrounding\n * `Field`'s size or a `WaveProvider`'s input defaults.\n */\nexport const Checkbox = ({\n checked: checkedProp,\n defaultChecked = false,\n indeterminate = false,\n onCheckedChange,\n onChange,\n disabled = false,\n disabledFocusable = false,\n label,\n labelPosition = 'after',\n size = 'medium',\n shape = 'square',\n name,\n value,\n required,\n form,\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 'aria-disabled': ariaDisabled,\n autoFocus,\n tabIndex,\n onClick,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n controlRef,\n className,\n children,\n ref,\n ...rest\n}: CheckboxProps) => {\n if (onChange !== undefined) warnDeprecated('Checkbox', 'onChange', 'onCheckedChange');\n const hasChildren = slotRendersContent(children);\n React.useEffect(() => {\n if (hasChildren) {\n warnOnce(\n 'Checkbox:children',\n 'Checkbox: children are not rendered. Pass the label in `label`.',\n );\n }\n }, [hasChildren]);\n const [checked, setChecked] = useControllable(checkedProp, defaultChecked, (next: boolean) => {\n onCheckedChange?.(next);\n onChange?.(next);\n });\n\n const generatedId = useId('checkbox');\n const labelTextId = useId('checkbox-label');\n const field = useFieldContext();\n const fieldProps = useFieldControl({\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n // An explicit `required={false}` wins over a required Field, so aria-required always matches\n // the native validation below (`isRequired`).\n 'aria-required': ariaRequired ?? required,\n });\n const isRequired = required ?? field?.required ?? false;\n // `0` is a label; `null`, `false`, `''` and empty collections are not (C-SLOTS).\n const hasLabel = slotRendersContent(label);\n // The label text names the control through aria-labelledby, disabled or not: axe exempts the\n // dimmed text of a disabled control only when the control references it this way (its <label>\n // exemption covers native inputs only). A consumer aria-label still names the control alone.\n // The ids already there (the consumer's, the Field label from useFieldControl) come first, then\n // the Field label whose <label htmlFor> targets this control (aria-labelledby would hide it), so\n // the name keeps every label.\n const labelledBy =\n hasLabel && fieldProps['aria-label'] === undefined\n ? joinIds(\n fieldProps['aria-labelledby'],\n field && fieldProps.id === field.controlId ? field.labelId : undefined,\n labelTextId,\n )\n : fieldProps['aria-labelledby'];\n\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const mergedControlRef = useMergedRefs(buttonRef, controlRef);\n useFormReset(buttonRef, () => setChecked(defaultChecked), form);\n\n const on = checked || indeterminate;\n // A size or shape outside the unions (from untyped code) renders, and is reported in the data\n // attributes, as the default: TypeScript rejects one, but the value still reaches this render.\n const resolvedSize: CheckboxSize = Object.hasOwn(CHECKBOX_SIZE, size) ? size : 'medium';\n const resolvedShape: CheckboxShape = Object.hasOwn(CHECKBOX_SHAPE, shape) ? shape : 'square';\n const sizeMetrics = CHECKBOX_SIZE[resolvedSize];\n const shapeClass = CHECKBOX_SHAPE[resolvedShape];\n // Focusable-disabled wins over `disabled`: the box stays focusable but looks and acts disabled.\n const unavailable = disabled || disabledFocusable;\n // The glyph is the forced-colors leaf; the box stays on system colors (see `checkedBox`).\n const glyphClassName = unavailable ? disabledGlyph : forcedColors.selectedLeaf;\n const labelText = hasLabel ? (\n <span id={labelTextId} className={cn(checkboxClassNames.label, 'text-body-1 text-foreground')}>\n {materialiseSlotContent(label)}\n </span>\n ) : null;\n\n return (\n <label\n ref={ref}\n data-label-position={labelPosition}\n data-size={resolvedSize}\n data-shape={resolvedShape}\n className={cn(\n checkboxClassNames.root,\n // items-start: the box lines up with the first line of a label that wraps or has a second\n // line, not with its middle.\n 'relative inline-flex items-start gap-2 select-none',\n // The dimmed look lifts while a focus ring shows inside the root (the control's, under\n // disabledFocusable, or a link's in the label): opacity would dim the ring below 3:1.\n unavailable\n ? 'cursor-not-allowed opacity-50 has-focus-visible:opacity-100'\n : 'cursor-pointer',\n className,\n )}\n {...rest}\n >\n {labelPosition === 'before' && labelText}\n <button\n id={generatedId}\n type=\"button\"\n {...fieldProps}\n aria-labelledby={labelledBy}\n aria-errormessage={ariaErrorMessage}\n aria-details={ariaDetails}\n aria-disabled={ariaDisabled}\n autoFocus={autoFocus}\n tabIndex={tabIndex}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n ref={mergedControlRef}\n role=\"checkbox\"\n aria-checked={indeterminate ? 'mixed' : checked}\n disabled={disabled && !disabledFocusable}\n {...focusableDisabledProps(disabledFocusable, { reachable: true })}\n onClick={\n disabledFocusable\n ? // Clicks, Space and Enter (which click a button) neither toggle nor reach `onClick`,\n // and, as a natively disabled control dispatches no click, no ancestor sees them.\n (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n event.stopPropagation();\n }\n : composeEventHandlers(onClick, () => setChecked((prev) => !prev))\n }\n className={cn(\n checkboxClassNames.indicator,\n // p-0 and the unchecked bg-transparent are set here, not left to the native reset, which\n // any app button style overrides (C-NATIVE).\n cn(\n 'flex shrink-0 items-center justify-center border p-0 transition-colors motion-reduce:transition-none',\n sizeMetrics.box,\n shapeClass,\n ),\n // Centred on the label's 20px first line: nudged down at medium, up at large.\n hasLabel && sizeMetrics.offset,\n focusRing,\n on\n ? cn(\n 'border-primary bg-primary text-primary-foreground',\n unavailable ? disabledCheckedBox : checkedBox,\n )\n : cn(\n 'border-stroke-accessible bg-transparent',\n unavailable ? forcedColors.disabled : forcedColors.control,\n ),\n )}\n >\n {indeterminate ? (\n <SubtractIcon size={sizeMetrics.glyph} className={glyphClassName} />\n ) : checked ? (\n <CheckIcon size={sizeMetrics.glyph} className={glyphClassName} />\n ) : null}\n </button>\n {labelPosition !== 'before' && labelText}\n <HiddenInput\n type=\"checkbox\"\n name={name}\n form={form}\n disabled={unavailable}\n value={value}\n checked={checked}\n required={isRequired}\n onInvalid={() => buttonRef.current?.focus()}\n />\n </label>\n );\n};\n\nCheckbox.displayName = 'Checkbox';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,IAAMG,KAAa,iEACbC,KAAqB,6DACrBC,KAAgB,wEAehBC,IAEF;CACF,QAAQ;EAAE,KAAK;EAAqB,OAAO;EAAI,QAAQ;CAAQ;CAC/D,OAAO;EAAE,KAAK;EAAqB,OAAO;EAAI,QAAQ;CAAS;AACjE,GAGMC,IAA0D;CAC9D,QAAQ;CACR,UAAU;AACZ,GAqHaC,KAAY,EACvB,SAASC,GACT,oBAAiB,IACjB,mBAAgB,IAChB,qBACA,aACA,cAAW,IACX,uBAAoB,IACpB,UACA,mBAAgB,SAChB,UAAO,UACP,WAAQ,UACR,SACA,UACA,aACA,SACA,OACA,cAAcC,GACd,mBAAmBC,GACnB,oBAAoBC,GACpB,gBAAgBC,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iBK,EAAU,SAAS,MAAM;GAC3C,CAAA;EACI;;AAEX;AAEA,EAAS,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"),a=require("../../hooks/useEventCallback.cjs"),o=require("../../lib/direction.cjs"),s=require("../../hooks/useMergedRefs.cjs"),c=require("../../hooks/useFieldControl.cjs"),ee=require("../../hooks/useMediaQuery.cjs"),l=require("../../hooks/useFormReset.cjs"),u=require("../internal/HiddenInput.cjs"),d=require("./colorUtils.cjs"),f=require("./ColorPicker.parts.cjs"),p=require("../../lib/events.cjs");let m=require("react");m=e.__toESM(m,1);let h=require("react/jsx-runtime");var te={saturation:`Saturation`,brightness:`Brightness`,roleDescription:`2D slider`};function g(e){return Math.min(100,Math.max(0,e))}var _=`(pointer: coarse)`,v=({value:e,defaultValue:v,onValueChange:y,shape:b,labels:x,disabled:S=!1,name:C,form:w,required:ne,controlRef:re,className:ie,style:ae,id:oe,"aria-label":se,"aria-labelledby":T,"aria-describedby":ce,"aria-invalid":le,"aria-required":E,"aria-errormessage":ue,autoFocus:de,tabIndex:fe,onKeyDown:D,onPointerDown:O,onPointerMove:k,ref:A,...j})=>{let M=f.useColorPartState({value:e,defaultValue:v,onValueChange:y,disabled:S}),{picker:N}=M,P={...te,...N&&{saturation:N.labels.saturation,brightness:N.labels.brightness,roleDescription:N.labels.roleDescription,colorName:N.labels.colorName,valueText:N.labels.valueText},...x},F=b??N?.shape??`rounded`,I=M.color,L=d.displayColor(I),R=d.toPercent(L.s),z=d.toPercent(L.v),[B,V]=m.useState(`saturation`),pe=ee.useMediaQuery(_),H=m.useRef(null),[U,me]=m.useState(0),W=m.useRef(null),G=m.useRef(null),K=m.useRef(null),he=s.useMergedRefs(A,W),ge=s.useMergedRefs(G,re),q=m.useRef(0);m.useLayoutEffect(()=>{q.current!==U&&(q.current=U,(B===`saturation`?G:K).current?.focus({preventScroll:!0}))},[B,U]);let _e=c.useFieldContext(),{"aria-invalid":J,"aria-required":ve,required:ye,...be}=c.useFieldControl({id:oe,"aria-label":se??(N&&T===void 0?N.labels.area:void 0),"aria-labelledby":T,"aria-describedby":ce,"aria-invalid":le},{labelable:!1}),xe=J!==void 0&&J!==!1&&J!==`false`&&ue||void 0,Se=ne??(E===!0||E===`true`||(_e?.required??!1));l.useFormReset(W,M.reset,w);let Y=(e,t)=>{t!==(e===`saturation`?R:z)&&M.setColor(e===`saturation`?{...I,s:t/100}:{...I,v:t/100})},Ce=n.composeEventHandlers(D,e=>{if(M.disabled||!p.isOwnEvent(e)||e.nativeEvent.isComposing||e.altKey||e.ctrlKey||e.metaKey)return;let t=e.shiftKey?10:1,n,r;switch(e.key){case`ArrowLeft`:case`ArrowRight`:{let i=o.getArrowIntent(e.key,{orientation:`horizontal`,dir:o.getDirection(e.currentTarget)});n=`saturation`,r=R+(i===`next`?t:-t);break}case`ArrowUp`:n=`value`,r=z+t;break;case`ArrowDown`:n=`value`,r=z-t;break;case`PageUp`:n=`value`,r=z+10;break;case`PageDown`:n=`value`,r=z-10;break;case`Home`:n=`saturation`,r=0;break;case`End`:n=`saturation`,r=100;break;default:return}e.preventDefault(),n!==B&&V(n),me(e=>e+1),Y(n,g(r))}),X=e=>t=>{M.disabled||(e!==B&&V(e),Y(e,g(Math.round(Number(t.currentTarget.value)))))},we=e=>()=>{e!==B&&V(e)},Z=a.useEventCallback(e=>{let t=H.current;if(!t)return;let n=t.getBoundingClientRect();if(n.width<=0||n.height<=0)return;let r=Math.min(1,Math.max(0,(e.clientX-n.left)/n.width)),i=o.getDirection(e.currentTarget)===`rtl`?1-r:r,a=Math.min(1,Math.max(0,1-(e.clientY-n.top)/n.height));(i!==L.s||a!==L.v)&&M.setColor({...I,s:i,v:a})}),Te=a.useEventCallback(()=>{(B===`saturation`?G:K).current?.focus({preventScroll:!0,focusVisible:!1})}),Ee=n.composeEventHandlers(O,e=>{!M.disabled&&e.button===0&&e.isPrimary&&p.isOwnEvent(e)&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),Z(e),Te())}),De=n.composeEventHandlers(k,e=>{!M.disabled&&e.currentTarget.hasPointerCapture(e.pointerId)&&Z(e)}),Q={saturation:P.saturation,brightness:P.brightness,colorName:P.colorName,valueText:P.valueText},Oe={...ae,"--wave-color-area-gradient":d.colorAreaGradient(L.h),"--wave-color-area-x":d.toPosition(L.s),"--wave-color-area-y":d.toPosition(L.v),"--wave-color-thumb":i.hsvToHex({h:L.h,s:L.s,v:L.v})},$=e=>({type:`range`,min:0,max:100,step:1,disabled:M.disabled,"aria-roledescription":P.roleDescription,"aria-invalid":J,"aria-errormessage":xe,tabIndex:e===B?fe??0:-1,"aria-hidden":e!==B&&!pe||void 0,onChange:X(e),onFocus:we(e),className:`sr-only`});return(0,h.jsxs)(`div`,{role:`group`,"data-disabled":M.disabled?``:void 0,...be,className:t.cn(r.colorAreaClassNames.root,`group/color-area relative h-40 w-full min-w-40 touch-none select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,F===`square`?`rounded-none`:`rounded`,ie),style:Oe,...j,ref:he,onKeyDown:Ce,onPointerDown:Ee,onPointerMove:De,children:[(0,h.jsx)(`div`,{ref:H,"aria-hidden":`true`,className:t.cn(r.colorAreaClassNames.field,`absolute inset-0 rounded-[inherit] bg-(image:--wave-color-area-gradient) wave-rtl:-scale-x-100 forced-colors:forced-color-adjust-none`)}),(0,h.jsx)(`span`,{"aria-hidden":`true`,className:t.cn(r.colorAreaClassNames.thumb,d.COLOR_THUMB_CLASSES,`start-(--wave-color-area-x) bottom-(--wave-color-area-y) -translate-x-1/2 wave-rtl:translate-x-1/2 translate-y-1/2`,`group-has-[:focus-visible]/color-area:ring-2 group-has-[:focus-visible]/color-area:ring-background forced-colors:group-has-[:focus-visible]/color-area:ring-[Canvas] group-has-[:focus-visible]/color-area:outline-2 group-has-[:focus-visible]/color-area:outline-offset-2 group-has-[:focus-visible]/color-area:outline-ring forced-colors:group-has-[:focus-visible]/color-area:outline-[Highlight]`)}),(0,h.jsx)(`input`,{...$(`saturation`),ref:ge,value:R,"aria-label":P.saturation,"aria-valuetext":d.areaValueText(L,`saturation`,Q),autoFocus:de}),(0,h.jsx)(`input`,{...$(`value`),ref:K,value:z,"aria-label":P.brightness,"aria-orientation":`vertical`,"aria-valuetext":d.areaValueText(L,`value`,Q)}),!N&&(0,h.jsx)(u.HiddenInput,{type:`text`,name:C,form:w,disabled:M.disabled,value:i.hsvToHex(I),required:Se,onInvalid:()=>(B===`saturation`?G:K).current?.focus()})]})};v.displayName=`ColorArea`,exports.ColorArea=v;
2
+ //# sourceMappingURL=ColorArea.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorArea.cjs","names":["useColorPartState","displayColor","toPercent","React","useMediaQuery","useMergedRefs","useFieldContext","useFieldControl","composeEventHandlers","isOwnEvent","getArrowIntent","getDirection","useEventCallback","colorAreaGradient","toPosition","hsvToHex","cn","colorAreaClassNames","COLOR_THUMB_CLASSES","areaValueText","HiddenInput","require_runtime","require_cn","require_composeEventHandlers","require_classNames","require_color","require_useEventCallback","require_direction","require_useMergedRefs","require_useFieldControl","require_useMediaQuery","require_useFormReset","require_HiddenInput","require_colorUtils","require_ColorPicker_parts","require_events","react","react_jsx_runtime","DEFAULT_LABELS","clampPercent","value","COARSE_POINTER","ColorArea","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","rest","part","strings","picker","labels","resolvedShape","shape","color","shown","saturation","brightness","activeAxis","setActiveAxis","coarsePointer","fieldRef","focusToken","setFocusToken","rootRef","saturationRef","brightnessRef","mergedRootRef","ref","mergedSaturationRef","controlRef","handledFocusTokenRef","field","invalid","_ariaRequired","_required","groupProps","errorMessageId","isRequired","required","form","applyAxis","percent","axis","handleKeyDown","onKeyDown","event","step","next","intent","token","handleInputChange","handleInputFocus","moveToPointer","fieldElement","rect","x","s","v","focusActiveAxis","handlePointerDown","onPointerDown","handlePointerMove","onPointerMove","textLabels","areaStyle","style","inputProps","tabIndex","className"],"sources":["../../../src/components/input/ColorArea.tsx"],"sourcesContent":["import * as React from 'react';\nimport { colorAreaClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { hsvToHex } from '../../lib/color';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { isOwnEvent } from '../../lib/events';\nimport type { ColorPickerShape, HsvColor } from '../../lib/types';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { useColorPartState } from './ColorPicker.parts';\nimport {\n COLOR_THUMB_CLASSES,\n areaValueText,\n colorAreaGradient,\n displayColor,\n toPercent,\n toPosition,\n} from './colorUtils';\n\n/** Texts of a ColorArea, for localisation. Every key is optional. */\nexport interface ColorAreaLabels {\n /** Name of the horizontal slider.\n * @default 'Saturation'\n */\n saturation?: string;\n /** Name of the vertical slider (the `value` channel).\n * @default 'Brightness'\n */\n brightness?: string;\n /** Role description of both sliders.\n * @default '2D slider'\n */\n roleDescription?: string;\n /** Names the color at the end of each value text; return `''` to leave it out.\n * @default an English namer (\"dark blue\")\n */\n colorName?: (color: HsvColor) => string;\n /** Replaces a whole value text, for languages whose order differs. */\n valueText?: (color: HsvColor, channel: 'saturation' | 'value') => string;\n}\n\n/** Properties for the ColorArea component. */\nexport interface ColorAreaProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'defaultValue' | 'onChange'\n> {\n /**\n * The color (Fluent's `color`). Inside a ColorPicker, leave `value` and `defaultValue` out to\n * bind the area 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, a pointer move or assistive technology) that\n * changes it (Fluent's `onChange`). A bound area calls it too.\n */\n onValueChange?: (value: HsvColor) => void;\n /**\n * `'square'` removes the corner radius (the thumb stays round). Bound to a ColorPicker, the\n * picker's shape unless you pass one.\n * @default 'rounded'\n */\n shape?: ColorPickerShape;\n /** Texts of the area; bound to a ColorPicker, the picker's `labels` fill the keys you leave out. */\n labels?: ColorAreaLabels;\n /**\n * Unavailable: both inputs are natively disabled, pointer presses are ignored and the area is\n * dimmed. A bound area is also 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 area 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 group supports neither, so neither is set on it.\n */\n required?: boolean;\n /** Ref to the saturation `<input type=\"range\">`. */\n controlRef?: React.Ref<HTMLInputElement>;\n /** Ref to the root `role=\"group\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** The two axes: saturation (x) and brightness (y, the `value` channel). */\ntype AreaAxis = 'saturation' | 'value';\n\nconst DEFAULT_LABELS = {\n saturation: 'Saturation',\n brightness: 'Brightness',\n roleDescription: '2D slider',\n} as const;\n\n/** A whole percentage clamped to 0–100. */\nfunction clampPercent(value: number): number {\n return Math.min(100, Math.max(0, value));\n}\n\n/** Touch-primary devices expose both inputs, so a touch screen reader can swipe each (D19). */\nconst COARSE_POINTER = '(pointer: coarse)';\n\n/**\n * A 2-D color field: saturation from left to right (mirrored in right-to-left layouts) and\n * brightness from bottom to top, at the value's hue. ArrowLeft and ArrowRight move saturation by\n * 1 %, ArrowUp and ArrowDown brightness; Shift with an arrow moves by 10, Page Up and Page Down\n * move brightness by 10, and Home and End set saturation to 0 and 100. A press or drag (mouse,\n * touch or pen) moves the thumb to the pointer. It is one Tab stop holding two sliders for\n * assistive technology, \"Saturation\" and \"Brightness\", whose value texts start with their own\n * channel and name the color; focus follows the axis a key moves, and unless the primary pointer\n * is coarse (touch), only the slider with the Tab stop is exposed. Inside a ColorPicker, leave\n * `value` and `defaultValue` out and it binds to the picker. Fluent's\n * `ColorArea`, with `value`/`onValueChange` for its `color`/`onChange`.\n *\n * @example\n * <ColorArea aria-label=\"Accent color\" value={color} onValueChange={setColor} />\n */\nexport const ColorArea = ({\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 autoFocus,\n tabIndex,\n onKeyDown,\n onPointerDown,\n onPointerMove,\n ref,\n ...rest\n}: ColorAreaProps) => {\n const part = useColorPartState({ value, defaultValue, onValueChange, disabled });\n const { picker } = part;\n const strings = {\n ...DEFAULT_LABELS,\n ...(picker && {\n saturation: picker.labels.saturation,\n brightness: picker.labels.brightness,\n roleDescription: picker.labels.roleDescription,\n colorName: picker.labels.colorName,\n valueText: picker.labels.valueText,\n }),\n ...labels,\n };\n const resolvedShape = shape ?? picker?.shape ?? 'rounded';\n const color = part.color;\n const shown = displayColor(color);\n const saturation = toPercent(shown.s);\n const brightness = toPercent(shown.v);\n\n const [activeAxis, setActiveAxis] = React.useState<AreaAxis>('saturation');\n const coarsePointer = useMediaQuery(COARSE_POINTER);\n const fieldRef = React.useRef<HTMLDivElement>(null);\n // Bumped on every handled key (not only an axis change), so the layout effect below moves focus\n // to the axis's input even when the key's axis is the one an earlier assistive-technology change\n // already made the Tab stop, without moving focus; focusing an input that already has focus does\n // nothing. Never bumped for an AT-driven change (`handleInputChange`) or a real focus event. A\n // plain counter, not a ref: react-hooks/refs only allows a ref's `current` to be touched from an\n // effect, a ref callback or a function assigned directly to a JSX handler prop, not one passed\n // through `composeEventHandlers`.\n const [focusToken, setFocusToken] = React.useState(0);\n const rootRef = React.useRef<HTMLDivElement>(null);\n const saturationRef = React.useRef<HTMLInputElement>(null);\n const brightnessRef = React.useRef<HTMLInputElement>(null);\n const mergedRootRef = useMergedRefs(ref, rootRef);\n const mergedSaturationRef = useMergedRefs(saturationRef, controlRef);\n /** The last `focusToken` this component already moved focus for (read/written in the effect only). */\n const handledFocusTokenRef = React.useRef(0);\n\n React.useLayoutEffect(() => {\n if (handledFocusTokenRef.current === focusToken) return;\n handledFocusTokenRef.current = focusToken;\n (activeAxis === 'saturation' ? saturationRef : brightnessRef).current?.focus({\n preventScroll: true,\n });\n }, [activeAxis, focusToken]);\n\n const field = useFieldContext();\n const fieldProps = useFieldControl(\n {\n id,\n 'aria-label':\n ariaLabel ?? (picker && ariaLabelledBy === undefined ? picker.labels.area : undefined),\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 `required` (ARIA 1.2): the invalid\n // state goes to both inputs and the required state to the hidden input.\n const {\n 'aria-invalid': invalid,\n 'aria-required': _ariaRequired,\n required: _required,\n ...groupProps\n } = fieldProps;\n const isInvalid = invalid !== undefined && invalid !== false && invalid !== 'false';\n const errorMessageId = (isInvalid && ariaErrorMessage) || undefined;\n const isRequired =\n required ?? (ariaRequired === true || ariaRequired === 'true' || (field?.required ?? false));\n\n useFormReset(rootRef, part.reset, form);\n\n /** Applies a whole percentage to one axis, keeping the other channels as given. */\n const applyAxis = (axis: AreaAxis, percent: number) => {\n if (percent === (axis === 'saturation' ? saturation : brightness)) return;\n part.setColor(\n axis === 'saturation' ? { ...color, s: percent / 100 } : { ...color, v: percent / 100 },\n );\n };\n\n const handleKeyDown = composeEventHandlers(\n onKeyDown,\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (part.disabled || !isOwnEvent(event) || event.nativeEvent.isComposing) return;\n // A key with Alt, Ctrl or Meta belongs to the browser (Alt+Left is \"back\").\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const step = event.shiftKey ? 10 : 1;\n let axis: AreaAxis;\n let next: number;\n switch (event.key) {\n case 'ArrowLeft':\n case 'ArrowRight': {\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n axis = 'saturation';\n next = saturation + (intent === 'next' ? step : -step);\n break;\n }\n case 'ArrowUp':\n axis = 'value';\n next = brightness + step;\n break;\n case 'ArrowDown':\n axis = 'value';\n next = brightness - step;\n break;\n case 'PageUp':\n axis = 'value';\n next = brightness + 10;\n break;\n case 'PageDown':\n axis = 'value';\n next = brightness - 10;\n break;\n case 'Home':\n axis = 'saturation';\n next = 0;\n break;\n case 'End':\n axis = 'saturation';\n next = 100;\n break;\n default:\n return;\n }\n // Prevented, so the native range input never moves on its own.\n event.preventDefault();\n if (axis !== activeAxis) setActiveAxis(axis);\n // Every handled key moves focus to its axis's input, even when an earlier\n // assistive-technology change already made that axis the Tab stop.\n setFocusToken((token) => token + 1);\n applyAxis(axis, clampPercent(next));\n },\n );\n\n /** A change event from assistive technology (a swipe): that input becomes the Tab stop. */\n const handleInputChange = (axis: AreaAxis) => (event: React.ChangeEvent<HTMLInputElement>) => {\n if (part.disabled) return;\n if (axis !== activeAxis) setActiveAxis(axis);\n applyAxis(axis, clampPercent(Math.round(Number(event.currentTarget.value))));\n };\n\n const handleInputFocus = (axis: AreaAxis) => () => {\n if (axis !== activeAxis) setActiveAxis(axis);\n };\n\n // Both read a ref (`fieldRef`, or `saturationRef`/`brightnessRef`): `useEventCallback` (a custom\n // hook, opaque to react-hooks/refs) keeps that safe to call from the handler below, unlike a\n // plain function or `React.useCallback` passed into the generic `composeEventHandlers`.\n /** Moves the thumb to the pointer: saturation along x (mirrored in RTL), brightness along y. */\n const moveToPointer = useEventCallback((event: React.PointerEvent<HTMLDivElement>) => {\n const fieldElement = fieldRef.current;\n if (!fieldElement) return;\n const rect = fieldElement.getBoundingClientRect();\n if (rect.width <= 0 || rect.height <= 0) return;\n const x = Math.min(1, Math.max(0, (event.clientX - rect.left) / rect.width));\n const s = getDirection(event.currentTarget) === 'rtl' ? 1 - x : x;\n const v = Math.min(1, Math.max(0, 1 - (event.clientY - rect.top) / rect.height));\n if (s === shown.s && v === shown.v) return;\n part.setColor({ ...color, s, v });\n });\n /**\n * Focuses the input of the active axis (the press moves focus there instead of the point),\n * without the focus ring: Chromium treats this script focus as keyboard focus, where the\n * browser's own focus of a pressed control shows none. Browsers without the `focusVisible`\n * option ignore it.\n */\n const focusActiveAxis = useEventCallback(() => {\n const options: FocusOptions = { preventScroll: true, focusVisible: false };\n (activeAxis === 'saturation' ? saturationRef : brightnessRef).current?.focus(options);\n });\n\n const handlePointerDown = composeEventHandlers(\n onPointerDown,\n (event: React.PointerEvent<HTMLDivElement>) => {\n if (part.disabled || event.button !== 0 || !event.isPrimary || !isOwnEvent(event)) return;\n // No text selection and no focus move of the press: focus goes to the Tab stop instead.\n event.preventDefault();\n event.currentTarget.setPointerCapture(event.pointerId);\n moveToPointer(event);\n focusActiveAxis();\n },\n );\n\n // The drag lasts while the root holds the pointer; losing the capture (pointerup,\n // lostpointercapture) ends it.\n const handlePointerMove = composeEventHandlers(\n onPointerMove,\n (event: React.PointerEvent<HTMLDivElement>) => {\n if (part.disabled || !event.currentTarget.hasPointerCapture(event.pointerId)) return;\n moveToPointer(event);\n },\n );\n\n const textLabels = {\n saturation: strings.saturation,\n brightness: strings.brightness,\n colorName: strings.colorName,\n valueText: strings.valueText,\n };\n\n const areaStyle = {\n ...style,\n '--wave-color-area-gradient': colorAreaGradient(shown.h),\n '--wave-color-area-x': toPosition(shown.s),\n '--wave-color-area-y': toPosition(shown.v),\n '--wave-color-thumb': hsvToHex({ h: shown.h, s: shown.s, v: shown.v }),\n } as React.CSSProperties;\n\n const inputProps = (axis: AreaAxis) => ({\n type: 'range' as const,\n min: 0,\n max: 100,\n step: 1,\n disabled: part.disabled,\n 'aria-roledescription': strings.roleDescription,\n 'aria-invalid': invalid,\n 'aria-errormessage': errorMessageId,\n // One Tab stop: the input used last (C-ROUTING: a consumer tabIndex applies to it).\n tabIndex: axis === activeAxis ? (tabIndex ?? 0) : -1,\n // Where the primary pointer is not coarse, desktop screen readers meet one 2-D slider: the\n // input without the Tab stop is hidden (it stays focusable by script, never by Tab).\n 'aria-hidden': axis !== activeAxis && !coarsePointer ? true : undefined,\n onChange: handleInputChange(axis),\n onFocus: handleInputFocus(axis),\n className: 'sr-only',\n });\n\n return (\n <div\n role=\"group\"\n data-disabled={part.disabled ? '' : undefined}\n {...groupProps}\n className={cn(\n colorAreaClassNames.root,\n 'group/color-area relative h-40 w-full min-w-40 touch-none select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50',\n resolvedShape === 'square' ? 'rounded-none' : 'rounded',\n className,\n )}\n style={areaStyle}\n {...rest}\n ref={mergedRootRef}\n onKeyDown={handleKeyDown}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n >\n <div\n ref={fieldRef}\n aria-hidden=\"true\"\n className={cn(\n colorAreaClassNames.field,\n 'absolute inset-0 rounded-[inherit] bg-(image:--wave-color-area-gradient) wave-rtl:-scale-x-100 forced-colors:forced-color-adjust-none',\n )}\n />\n <span\n aria-hidden=\"true\"\n className={cn(\n colorAreaClassNames.thumb,\n COLOR_THUMB_CLASSES,\n 'start-(--wave-color-area-x) bottom-(--wave-color-area-y) -translate-x-1/2 wave-rtl:translate-x-1/2 translate-y-1/2',\n 'group-has-[:focus-visible]/color-area:ring-2 group-has-[:focus-visible]/color-area:ring-background forced-colors:group-has-[:focus-visible]/color-area:ring-[Canvas] group-has-[:focus-visible]/color-area:outline-2 group-has-[:focus-visible]/color-area:outline-offset-2 group-has-[:focus-visible]/color-area:outline-ring forced-colors:group-has-[:focus-visible]/color-area:outline-[Highlight]',\n )}\n />\n <input\n {...inputProps('saturation')}\n ref={mergedSaturationRef}\n value={saturation}\n aria-label={strings.saturation}\n aria-valuetext={areaValueText(shown, 'saturation', textLabels)}\n autoFocus={autoFocus}\n />\n <input\n {...inputProps('value')}\n ref={brightnessRef}\n value={brightness}\n aria-label={strings.brightness}\n aria-orientation=\"vertical\"\n aria-valuetext={areaValueText(shown, 'value', textLabels)}\n />\n {!picker && (\n <HiddenInput\n type=\"text\"\n name={name}\n form={form}\n disabled={part.disabled}\n value={hsvToHex(color)}\n required={isRequired}\n onInvalid={() =>\n (activeAxis === 'saturation' ? saturationRef : brightnessRef).current?.focus()\n }\n />\n )}\n </div>\n );\n};\n\nColorArea.displayName = 'ColorArea';\n"],"mappings":"orBAkGA,IAAMsC,GAAiB,CACrB,WAAY,aACZ,WAAY,aACZ,gBAAiB,WACnB,EAGA,SAASC,EAAa,EAAuB,CAC3C,OAAO,KAAK,IAAI,IAAK,KAAK,IAAI,EAAGC,CAAK,CAAC,CACzC,CAGA,IAAMC,EAAiB,oBAiBVC,GAAa,CACxB,QACA,eACA,gBACA,QACA,SACA,WAAW,GACX,OACA,OACA,YACA,cACA,aACA,SACA,MACA,aAAcC,GACd,kBAAmBC,EACnB,mBAAoBC,GACpB,eAAgBC,GAChB,gBAAiBC,EACjB,oBAAqBC,GACrB,aACA,YACA,YACA,gBACA,gBACA,MACA,GAAGC,KACiB,CACpB,IAAMC,EAAOlD,EAAAA,kBAAkB,CAAE,QAAO,eAAc,gBAAe,UAAS,CAAC,EACzE,CAAE,UAAWkD,EACbC,EAAU,CACd,GAAGb,GACH,GAAIc,GAAU,CACZ,WAAYA,EAAO,OAAO,WAC1B,WAAYA,EAAO,OAAO,WAC1B,gBAAiBA,EAAO,OAAO,gBAC/B,UAAWA,EAAO,OAAO,UACzB,UAAWA,EAAO,OAAO,SAC3B,EACA,GAAGC,CACL,EACMC,EAAgBC,GAASH,GAAQ,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MAAOb,EACP,aAAYP,EAAQ,WACpB,iBAAgBhC,EAAAA,cAAcsC,EAAO,aAAciD,CAAU,EAClD,YACZ,CAAA,GACD,EAAArE,EAAA,IAAA,CAAC,QAAD,CACE,GAAIwE,EAAW,OAAO,EACtB,IAAKzC,EACL,MAAOT,EACP,aAAYR,EAAQ,WACpB,mBAAiB,WACjB,iBAAgBhC,EAAAA,cAAcsC,EAAO,QAASiD,CAAU,CACzD,CAAA,EACA,CAACtD,IACA,EAAAf,EAAA,IAAA,CAACjB,EAAAA,YAAD,CACE,KAAK,OACC,OACA,OACN,SAAU8B,EAAK,SACf,MAAOnC,EAAAA,SAASyC,CAAK,EACrB,SAAUwB,GACV,eACGpB,IAAe,aAAeO,EAAgBC,EAAA,CAAe,SAAS,MAAM,CAEhF,CAAA,CAEA,GAET,EAEA,EAAU,YAAc"}
@@ -0,0 +1,204 @@
1
+ "use client";
2
+ import { cn as e } from "../../lib/cn.mjs";
3
+ import { composeEventHandlers as t } from "../../lib/composeEventHandlers.mjs";
4
+ import { colorAreaClassNames as n } from "../../lib/classNames.mjs";
5
+ import { hsvToHex as r } from "../../lib/color.mjs";
6
+ import { useEventCallback as i } from "../../hooks/useEventCallback.mjs";
7
+ import { getArrowIntent as a, getDirection as o } from "../../lib/direction.mjs";
8
+ import { useMergedRefs as s } from "../../hooks/useMergedRefs.mjs";
9
+ import { useFieldContext as ee, useFieldControl as c } from "../../hooks/useFieldControl.mjs";
10
+ import { useMediaQuery as l } from "../../hooks/useMediaQuery.mjs";
11
+ import { useFormReset as u } from "../../hooks/useFormReset.mjs";
12
+ import { HiddenInput as te } from "../internal/HiddenInput.mjs";
13
+ import { COLOR_THUMB_CLASSES as ne, areaValueText as d, colorAreaGradient as re, displayColor as ie, toPercent as f, toPosition as p } from "./colorUtils.mjs";
14
+ import { useColorPartState as m } from "./ColorPicker.parts.mjs";
15
+ import { isOwnEvent as h } from "../../lib/events.mjs";
16
+ import * as g from "react";
17
+ import { jsx as _, jsxs as ae } from "react/jsx-runtime";
18
+ //#region src/components/input/ColorArea.tsx
19
+ var oe = {
20
+ saturation: "Saturation",
21
+ brightness: "Brightness",
22
+ roleDescription: "2D slider"
23
+ };
24
+ function v(e) {
25
+ return Math.min(100, Math.max(0, e));
26
+ }
27
+ var se = "(pointer: coarse)", y = ({ value: y, defaultValue: ce, onValueChange: le, shape: ue, labels: de, disabled: fe = !1, name: pe, form: b, required: me, controlRef: he, className: ge, style: _e, id: ve, "aria-label": ye, "aria-labelledby": x, "aria-describedby": S, "aria-invalid": C, "aria-required": w, "aria-errormessage": T, autoFocus: E, tabIndex: D, onKeyDown: O, onPointerDown: k, onPointerMove: A, ref: j, ...M }) => {
28
+ let N = m({
29
+ value: y,
30
+ defaultValue: ce,
31
+ onValueChange: le,
32
+ disabled: fe
33
+ }), { picker: P } = N, F = {
34
+ ...oe,
35
+ ...P && {
36
+ saturation: P.labels.saturation,
37
+ brightness: P.labels.brightness,
38
+ roleDescription: P.labels.roleDescription,
39
+ colorName: P.labels.colorName,
40
+ valueText: P.labels.valueText
41
+ },
42
+ ...de
43
+ }, be = ue ?? P?.shape ?? "rounded", I = N.color, L = ie(I), R = f(L.s), z = f(L.v), [B, V] = g.useState("saturation"), xe = l(se), H = g.useRef(null), [U, Se] = g.useState(0), W = g.useRef(null), G = g.useRef(null), K = g.useRef(null), Ce = s(j, W), we = s(G, he), q = g.useRef(0);
44
+ g.useLayoutEffect(() => {
45
+ q.current !== U && (q.current = U, (B === "saturation" ? G : K).current?.focus({ preventScroll: !0 }));
46
+ }, [B, U]);
47
+ let Te = ee(), { "aria-invalid": J, "aria-required": Ee, required: De, ...Oe } = c({
48
+ id: ve,
49
+ "aria-label": ye ?? (P && x === void 0 ? P.labels.area : void 0),
50
+ "aria-labelledby": x,
51
+ "aria-describedby": S,
52
+ "aria-invalid": C
53
+ }, { labelable: !1 }), ke = J !== void 0 && J !== !1 && J !== "false" && T || void 0, Ae = me ?? (w === !0 || w === "true" || (Te?.required ?? !1));
54
+ u(W, N.reset, b);
55
+ let Y = (e, t) => {
56
+ t !== (e === "saturation" ? R : z) && N.setColor(e === "saturation" ? {
57
+ ...I,
58
+ s: t / 100
59
+ } : {
60
+ ...I,
61
+ v: t / 100
62
+ });
63
+ }, X = t(O, (e) => {
64
+ if (N.disabled || !h(e) || e.nativeEvent.isComposing || e.altKey || e.ctrlKey || e.metaKey) return;
65
+ let t = e.shiftKey ? 10 : 1, n, r;
66
+ switch (e.key) {
67
+ case "ArrowLeft":
68
+ case "ArrowRight": {
69
+ let i = a(e.key, {
70
+ orientation: "horizontal",
71
+ dir: o(e.currentTarget)
72
+ });
73
+ n = "saturation", r = R + (i === "next" ? t : -t);
74
+ break;
75
+ }
76
+ case "ArrowUp":
77
+ n = "value", r = z + t;
78
+ break;
79
+ case "ArrowDown":
80
+ n = "value", r = z - t;
81
+ break;
82
+ case "PageUp":
83
+ n = "value", r = z + 10;
84
+ break;
85
+ case "PageDown":
86
+ n = "value", r = z - 10;
87
+ break;
88
+ case "Home":
89
+ n = "saturation", r = 0;
90
+ break;
91
+ case "End":
92
+ n = "saturation", r = 100;
93
+ break;
94
+ default: return;
95
+ }
96
+ e.preventDefault(), n !== B && V(n), Se((e) => e + 1), Y(n, v(r));
97
+ }), je = (e) => (t) => {
98
+ N.disabled || (e !== B && V(e), Y(e, v(Math.round(Number(t.currentTarget.value)))));
99
+ }, Me = (e) => () => {
100
+ e !== B && V(e);
101
+ }, Z = i((e) => {
102
+ let t = H.current;
103
+ if (!t) return;
104
+ let n = t.getBoundingClientRect();
105
+ if (n.width <= 0 || n.height <= 0) return;
106
+ let r = Math.min(1, Math.max(0, (e.clientX - n.left) / n.width)), i = o(e.currentTarget) === "rtl" ? 1 - r : r, a = Math.min(1, Math.max(0, 1 - (e.clientY - n.top) / n.height));
107
+ (i !== L.s || a !== L.v) && N.setColor({
108
+ ...I,
109
+ s: i,
110
+ v: a
111
+ });
112
+ }), Ne = i(() => {
113
+ (B === "saturation" ? G : K).current?.focus({
114
+ preventScroll: !0,
115
+ focusVisible: !1
116
+ });
117
+ }), Pe = t(k, (e) => {
118
+ !N.disabled && e.button === 0 && e.isPrimary && h(e) && (e.preventDefault(), e.currentTarget.setPointerCapture(e.pointerId), Z(e), Ne());
119
+ }), Fe = t(A, (e) => {
120
+ !N.disabled && e.currentTarget.hasPointerCapture(e.pointerId) && Z(e);
121
+ }), Q = {
122
+ saturation: F.saturation,
123
+ brightness: F.brightness,
124
+ colorName: F.colorName,
125
+ valueText: F.valueText
126
+ }, Ie = {
127
+ ..._e,
128
+ "--wave-color-area-gradient": re(L.h),
129
+ "--wave-color-area-x": p(L.s),
130
+ "--wave-color-area-y": p(L.v),
131
+ "--wave-color-thumb": r({
132
+ h: L.h,
133
+ s: L.s,
134
+ v: L.v
135
+ })
136
+ }, $ = (e) => ({
137
+ type: "range",
138
+ min: 0,
139
+ max: 100,
140
+ step: 1,
141
+ disabled: N.disabled,
142
+ "aria-roledescription": F.roleDescription,
143
+ "aria-invalid": J,
144
+ "aria-errormessage": ke,
145
+ tabIndex: e === B ? D ?? 0 : -1,
146
+ "aria-hidden": e !== B && !xe || void 0,
147
+ onChange: je(e),
148
+ onFocus: Me(e),
149
+ className: "sr-only"
150
+ });
151
+ return /* @__PURE__ */ ae("div", {
152
+ role: "group",
153
+ "data-disabled": N.disabled ? "" : void 0,
154
+ ...Oe,
155
+ className: e(n.root, "group/color-area relative h-40 w-full min-w-40 touch-none select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50", be === "square" ? "rounded-none" : "rounded", ge),
156
+ style: Ie,
157
+ ...M,
158
+ ref: Ce,
159
+ onKeyDown: X,
160
+ onPointerDown: Pe,
161
+ onPointerMove: Fe,
162
+ children: [
163
+ /* @__PURE__ */ _("div", {
164
+ ref: H,
165
+ "aria-hidden": "true",
166
+ className: e(n.field, "absolute inset-0 rounded-[inherit] bg-(image:--wave-color-area-gradient) wave-rtl:-scale-x-100 forced-colors:forced-color-adjust-none")
167
+ }),
168
+ /* @__PURE__ */ _("span", {
169
+ "aria-hidden": "true",
170
+ className: e(n.thumb, ne, "start-(--wave-color-area-x) bottom-(--wave-color-area-y) -translate-x-1/2 wave-rtl:translate-x-1/2 translate-y-1/2", "group-has-[:focus-visible]/color-area:ring-2 group-has-[:focus-visible]/color-area:ring-background forced-colors:group-has-[:focus-visible]/color-area:ring-[Canvas] group-has-[:focus-visible]/color-area:outline-2 group-has-[:focus-visible]/color-area:outline-offset-2 group-has-[:focus-visible]/color-area:outline-ring forced-colors:group-has-[:focus-visible]/color-area:outline-[Highlight]")
171
+ }),
172
+ /* @__PURE__ */ _("input", {
173
+ ...$("saturation"),
174
+ ref: we,
175
+ value: R,
176
+ "aria-label": F.saturation,
177
+ "aria-valuetext": d(L, "saturation", Q),
178
+ autoFocus: E
179
+ }),
180
+ /* @__PURE__ */ _("input", {
181
+ ...$("value"),
182
+ ref: K,
183
+ value: z,
184
+ "aria-label": F.brightness,
185
+ "aria-orientation": "vertical",
186
+ "aria-valuetext": d(L, "value", Q)
187
+ }),
188
+ !P && /* @__PURE__ */ _(te, {
189
+ type: "text",
190
+ name: pe,
191
+ form: b,
192
+ disabled: N.disabled,
193
+ value: r(I),
194
+ required: Ae,
195
+ onInvalid: () => (B === "saturation" ? G : K).current?.focus()
196
+ })
197
+ ]
198
+ });
199
+ };
200
+ y.displayName = "ColorArea";
201
+ //#endregion
202
+ export { y as ColorArea };
203
+
204
+ //# sourceMappingURL=ColorArea.mjs.map