@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,196 +1,196 @@
1
1
  "use client";
2
2
  import { cn as e } from "../../lib/cn.mjs";
3
3
  import { warnDeprecated as t, warnOnce as n } from "../../lib/dev.mjs";
4
- import { composeEventHandlers as r } from "../../lib/composeEventHandlers.mjs";
5
- import { useControllable as i } from "../../hooks/useControllable.mjs";
6
- import { getArrowIntent as a, getDirection as o } from "../../lib/direction.mjs";
7
- import { useRovingTabIndex as s } from "../../hooks/useRovingTabIndex.mjs";
8
- import { useMergedRefs as c } from "../../hooks/useMergedRefs.mjs";
9
- import { useFieldContext as l, useFieldControl as u } from "../../hooks/useFieldControl.mjs";
10
- import { focusRing as d } from "../../lib/styles.mjs";
11
- import { StarIcon as f } from "../../lib/icons.mjs";
12
- import { useFormReset as p } from "../../hooks/useFormReset.mjs";
13
- import { HiddenInput as m } from "../internal/HiddenInput.mjs";
14
- import * as h from "react";
15
- import { jsx as g, jsxs as _ } from "react/jsx-runtime";
4
+ import { slotRendersContent as r } from "../../lib/slot.mjs";
5
+ import { composeEventHandlers as i } from "../../lib/composeEventHandlers.mjs";
6
+ import { ratingClassNames as a, ratingDisplayClassNames as o } from "../../lib/classNames.mjs";
7
+ import { useEventCallback as s } from "../../hooks/useEventCallback.mjs";
8
+ import { useControllable as c } from "../../hooks/useControllable.mjs";
9
+ import { getArrowIntent as l, getDirection as u } from "../../lib/direction.mjs";
10
+ import { useRovingTabIndex as d } from "../../hooks/useRovingTabIndex.mjs";
11
+ import { useMergedRefs as f } from "../../hooks/useMergedRefs.mjs";
12
+ import { useFieldContext as p, useFieldControl as m } from "../../hooks/useFieldControl.mjs";
13
+ import { useFormReset as h } from "../../hooks/useFormReset.mjs";
14
+ import { HiddenInput as g } from "../internal/HiddenInput.mjs";
15
+ import { isOwnEvent as ee } from "../../lib/events.mjs";
16
+ import { INERT_RATING_CONTEXT as te, RatingContext as _, RatingItem as v, StarGlyph as y, ratingItems as b, resolveRatingColor as x, useRatingItemChecks as S, useRatingItemRegistry as C, useStarGlyphs as w } from "./Rating.item.mjs";
17
+ import * as T from "react";
18
+ import { jsx as E, jsxs as D } from "react/jsx-runtime";
16
19
  //#region src/components/input/Rating.tsx
17
- var v = (e) => `${e} star${e === 1 ? "" : "s"}`, y = {
18
- "extra-small": "h-3 w-3",
19
- small: "h-4 w-4",
20
- medium: "h-5 w-5",
21
- large: "h-6 w-6",
22
- "extra-large": "h-8 w-8"
23
- }, b = {
24
- "extra-small": "p-1.5",
25
- small: "p-1",
26
- medium: "p-0.5",
27
- large: "p-0.5",
28
- "extra-large": "p-0.5"
29
- };
30
- function x({ filled: e, className: t }) {
31
- return e ? /* @__PURE__ */ g(f, { className: t }) : /* @__PURE__ */ g(f, {
32
- className: t,
33
- fill: "none",
34
- stroke: "currentColor",
35
- strokeWidth: 1.5
36
- });
37
- }
38
- var S = ({ value: n, defaultValue: f, onValueChange: S, onChange: C, max: w = 5, size: T = "medium", disabled: E = !1, name: D, required: O, form: k, labels: A, className: j, id: M, "aria-label": N, "aria-labelledby": P, "aria-describedby": F, "aria-invalid": ee, "aria-required": te, onKeyDown: ne, onFocus: I, onMouseLeave: L, ref: R, ...z }) => {
39
- C !== void 0 && t("Rating", "onChange", "onValueChange");
40
- let B = f ?? 0, [V, H] = i(n, B, (e) => {
41
- S?.(e), C?.(e);
42
- }), [U, W] = h.useState(0), [G, K] = h.useState(E);
43
- G !== E && (K(E), E && W(0));
44
- let q = E ? V : U || V, { containerProps: J, getTabIndex: Y, focusValue: X } = s({ activeValue: V > 0 ? String(V) : null }), re = (e) => {
45
- if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) return;
20
+ var O = (e) => `${e} star${e === 1 ? "" : "s"}`, k = ({ value: n, defaultValue: o, onValueChange: te, onChange: v, max: y = 5, step: k, size: A = "medium", color: ne, iconFilled: re, iconOutline: j, disabled: M = !1, name: N, required: P, form: F, labels: I, className: L, children: R, id: z, "aria-label": B, "aria-labelledby": V, "aria-describedby": H, "aria-invalid": U, "aria-required": ie, onKeyDown: ae, onFocus: oe, onMouseLeave: se, ref: ce, ...le }) => {
21
+ v !== void 0 && t("Rating", "onChange", "onValueChange");
22
+ let W = o ?? 0, [G, K] = c(n, W, (e) => {
23
+ te?.(e), v?.(e);
24
+ }), q = k === .5 ? .5 : 1, [ue, J] = T.useState(0), [de, fe] = T.useState(M);
25
+ de !== M && (fe(M), M && J(0));
26
+ let Y = M ? G : ue || G, { containerProps: X, getTabIndex: pe, focusValue: me } = d({ activeValue: G >= q ? String(Math.floor(G / q) * q) : null }), he = (e) => Math.floor(e / q) * q + q, ge = (e) => Math.ceil(e / q) * q - q, _e = (e) => {
27
+ if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || !ee(e)) return;
46
28
  let t;
47
- if (e.key === "Home") t = 1;
48
- else if (e.key === "End") t = w;
49
- else if (e.key === "ArrowUp") t = V + 1;
50
- else if (e.key === "ArrowDown") t = V - 1;
29
+ if (e.key === "Home") t = q;
30
+ else if (e.key === "End") t = y;
31
+ else if (e.key === "ArrowUp") t = he(G);
32
+ else if (e.key === "ArrowDown") t = ge(G);
51
33
  else {
52
- let n = a(e.key, {
34
+ let n = l(e.key, {
53
35
  orientation: "horizontal",
54
- dir: o(e.currentTarget)
36
+ dir: u(e.currentTarget)
55
37
  });
56
38
  if (!n) return;
57
- t = n === "next" ? V + 1 : V - 1;
39
+ t = n === "next" ? he(G) : ge(G);
58
40
  }
59
- e.preventDefault(), t = Math.min(t, w), !(E || t < 1 || t === V) && (X(String(t)), H(t));
60
- }, Z = h.useRef(null), ie = c(R, J.ref, Z), ae = l(), Q = u({
61
- id: M,
62
- "aria-label": N,
63
- "aria-labelledby": P,
64
- "aria-describedby": F,
65
- "aria-invalid": ee,
66
- "aria-required": te ?? O
67
- }, { labelable: !1 }), oe = O ?? ae?.required ?? !1, $ = Q["aria-label"] === void 0 && Q["aria-labelledby"] === void 0 ? "Rating" : void 0;
68
- p(Z, () => H(B), k);
69
- let se = () => {
41
+ e.preventDefault(), t = Math.min(t, y), !(M || t < q || t === G) && (me(String(t)), K(t));
42
+ }, Z = T.useRef(null), ve = f(ce, X.ref, Z), ye = p(), Q = m({
43
+ id: z,
44
+ "aria-label": B,
45
+ "aria-labelledby": V,
46
+ "aria-describedby": H,
47
+ "aria-invalid": U,
48
+ "aria-required": ie ?? P
49
+ }, { labelable: !1 }), be = P ?? ye?.required ?? !1, xe = Q["aria-label"] === void 0 && Q["aria-labelledby"] === void 0 ? "Rating" : void 0;
50
+ h(Z, () => K(W), F);
51
+ let Se = () => {
70
52
  Z.current?.querySelector("[data-roving-value][tabindex=\"0\"]")?.focus();
71
- }, ce = y[T], le = A?.star ?? v;
72
- return /* @__PURE__ */ _("div", {
53
+ }, Ce = s((e) => {
54
+ Z.current?.querySelector(`[data-roving-value="${e}"]`)?.focus({ preventScroll: !0 });
55
+ }), $ = x(ne), we = w("Rating", re, j), Te = I?.star ?? O, { registerItem: Ee, counts: De } = C(), Oe = r(R);
56
+ S(De, y, Oe);
57
+ let ke = T.useMemo(() => ({
58
+ kind: "input",
59
+ value: G,
60
+ drawnValue: Y,
61
+ step: q,
62
+ max: y,
63
+ size: A,
64
+ color: $,
65
+ glyphs: we,
66
+ disabled: M,
67
+ starLabel: Te,
68
+ getTabIndex: pe,
69
+ choose: (e, t) => {
70
+ K(e), t && Ce(String(e));
71
+ },
72
+ preview: J,
73
+ registerItem: Ee
74
+ }), [
75
+ G,
76
+ Y,
77
+ q,
78
+ y,
79
+ A,
80
+ $,
81
+ we,
82
+ M,
83
+ Te,
84
+ pe,
85
+ K,
86
+ Ce,
87
+ Ee
88
+ ]);
89
+ return /* @__PURE__ */ D("div", {
73
90
  role: "radiogroup",
74
- "aria-label": $,
91
+ "aria-label": xe,
75
92
  ...Q,
76
- "aria-disabled": E || void 0,
77
- className: e("relative inline-flex items-center gap-0.5", E && "pointer-events-none opacity-50", j),
78
- ...z,
79
- ref: ie,
93
+ "aria-disabled": M || void 0,
94
+ "data-color": $,
95
+ className: e(a.root, "relative inline-flex items-center gap-0.5", M && "pointer-events-none opacity-50", L),
96
+ ...le,
97
+ ref: ve,
80
98
  "data-roving-container": "",
81
- onKeyDown: r(ne, re),
82
- onFocus: r(I, J.onFocus, { checkDefaultPrevented: !1 }),
83
- onMouseLeave: r(L, () => W(0), { checkDefaultPrevented: !1 }),
84
- children: [Array.from({ length: w }, (t, n) => {
85
- let r = n + 1, i = String(r), a = q >= r;
86
- return /* @__PURE__ */ g("button", {
87
- type: "button",
88
- role: "radio",
89
- "aria-checked": V === r,
90
- "aria-label": le(r, w),
91
- "data-roving-value": i,
92
- tabIndex: E ? -1 : Y(i),
93
- disabled: E,
94
- className: e("inline-flex cursor-pointer rounded border-0 bg-transparent transition-colors motion-reduce:transition-none disabled:cursor-not-allowed", b[T], d, a ? "text-rating" : "text-stroke-accessible"),
95
- onClick: () => {
96
- E || H(r);
97
- },
98
- onMouseEnter: () => {
99
- E || W(r);
100
- },
101
- children: /* @__PURE__ */ g(x, {
102
- filled: a,
103
- className: ce
104
- })
105
- }, i);
106
- }), /* @__PURE__ */ g(m, {
99
+ onKeyDown: i(ae, _e),
100
+ onFocus: i(oe, X.onFocus, { checkDefaultPrevented: !1 }),
101
+ onMouseLeave: i(se, () => J(0), { checkDefaultPrevented: !1 }),
102
+ children: [/* @__PURE__ */ E(_.Provider, {
103
+ value: ke,
104
+ children: b(R, y)
105
+ }), /* @__PURE__ */ E(g, {
107
106
  type: "radio",
108
- name: D,
109
- form: k,
110
- disabled: E,
111
- value: V > 0 ? String(V) : "",
112
- required: oe,
113
- onInvalid: se
107
+ name: N,
108
+ form: F,
109
+ disabled: M,
110
+ value: G > 0 ? String(G) : "",
111
+ required: be,
112
+ onInvalid: Se
114
113
  })]
115
114
  });
116
115
  };
117
- S.displayName = "Rating";
118
- var C = {
116
+ k.displayName = "Rating";
117
+ var A = {
119
118
  "extra-small": "text-caption-1",
120
119
  small: "text-caption-1",
121
120
  medium: "text-body-1",
122
121
  large: "text-body-2",
123
122
  "extra-large": "text-body-2"
124
- }, w = (e, t, n) => `Rating: ${n} out of ${t}`, T = (e, t) => e === 1 ? "1 rating" : `${t} ratings`;
125
- function E(e) {
123
+ }, ne = (e, t, n) => `Rating: ${n} out of ${t}`, re = (e, t) => e === 1 ? "1 rating" : `${t} ratings`;
124
+ function j(e) {
126
125
  if (e !== void 0) try {
127
126
  return Intl.getCanonicalLocales(e), e;
128
127
  } catch {
129
128
  return;
130
129
  }
131
130
  }
132
- var D = ({ value: t, max: r = 5, size: i = "medium", showValue: a = !1, count: o, compact: s = !1, locale: c, labels: l, className: u, ref: d, ...f }) => {
133
- let p = y[i], m = E(c), v = c !== void 0 && m === void 0;
134
- h.useEffect(() => {
135
- v && n(`RatingDisplay:invalid-locale:${c}`, `RatingDisplay: \`locale\` "${c}" is not a valid BCP 47 language tag (use hyphens, as in "en-US"). The runtime default locale formats the value instead, so the server and the browser may render different text.`);
136
- }, [v, c]);
137
- let b = new Intl.NumberFormat(m, { maximumFractionDigits: 1 }).format(t), S = o === void 0 ? void 0 : new Intl.NumberFormat(m).format(o), D = (l?.rating ?? w)(t, r, b), O = o === void 0 || S === void 0 ? D : `${D}, ${(l?.count ?? T)(o, S)}`, k = a || s || o !== void 0, A = C[i];
138
- return /* @__PURE__ */ _("div", {
139
- ref: d,
131
+ var M = ({ value: t, max: i = 5, size: a = "medium", color: s, iconFilled: c, iconOutline: l, showValue: u = !1, count: d, compact: f = !1, locale: p, labels: m, className: h, children: g, ref: ee, ...v }) => {
132
+ let O = j(p), k = p !== void 0 && O === void 0;
133
+ T.useEffect(() => {
134
+ k && n(`RatingDisplay:invalid-locale:${p}`, `RatingDisplay: \`locale\` "${p}" is not a valid BCP 47 language tag (use hyphens, as in "en-US"). The runtime default locale formats the value instead, so the server and the browser may render different text.`);
135
+ }, [k, p]);
136
+ let M = new Intl.NumberFormat(O, { maximumFractionDigits: 1 }).format(t), N = d === void 0 ? void 0 : new Intl.NumberFormat(O).format(d), P = (m?.rating ?? ne)(t, i, M), F = d === void 0 || N === void 0 ? P : `${P}, ${(m?.count ?? re)(d, N)}`, I = u || f || d !== void 0, L = A[a], R = x(s), z = w("RatingDisplay", c, l), { registerItem: B, counts: V } = C(), H = !f && r(g);
137
+ S(V, i, H);
138
+ let U = T.useMemo(() => ({
139
+ ...te,
140
+ kind: "display",
141
+ value: t,
142
+ drawnValue: t,
143
+ max: i,
144
+ size: a,
145
+ color: R,
146
+ glyphs: z,
147
+ registerItem: B
148
+ }), [
149
+ t,
150
+ i,
151
+ a,
152
+ R,
153
+ z,
154
+ B
155
+ ]);
156
+ return /* @__PURE__ */ D("div", {
157
+ ref: ee,
140
158
  role: "img",
141
- "aria-label": O,
142
- "data-compact": s ? "" : void 0,
143
- className: e("inline-flex items-center gap-0.5", u),
144
- ...f,
159
+ "aria-label": F,
160
+ "data-compact": f ? "" : void 0,
161
+ "data-color": R,
162
+ className: e(o.root, "inline-flex items-center gap-0.5", h),
163
+ ...v,
145
164
  children: [
146
- s ? /* @__PURE__ */ g("span", {
147
- className: "inline-flex text-rating",
148
- children: /* @__PURE__ */ g(x, {
149
- filled: !0,
150
- className: p
151
- })
152
- }) : Array.from({ length: r }, (n, r) => {
153
- let i = Math.round(Math.min(1, Math.max(0, t - r)) * 100);
154
- if (i > 0 && i < 100) return /* @__PURE__ */ _("span", {
155
- className: "relative inline-flex text-stroke-accessible",
156
- children: [/* @__PURE__ */ g(x, {
157
- filled: !1,
158
- className: p
159
- }), /* @__PURE__ */ g("span", {
160
- className: "absolute inset-y-0 start-0 flex overflow-hidden text-rating",
161
- style: { width: `${i}%` },
162
- children: /* @__PURE__ */ g(x, {
163
- filled: !0,
164
- className: e(p, "shrink-0")
165
- })
166
- })]
167
- }, r);
168
- let a = i === 100;
169
- return /* @__PURE__ */ g("span", {
170
- className: e("inline-flex", a ? "text-rating" : "text-stroke-accessible"),
171
- children: /* @__PURE__ */ g(x, {
172
- filled: a,
173
- className: p
174
- })
175
- }, r);
165
+ f ? /* @__PURE__ */ E(y, {
166
+ starClassName: o.star,
167
+ iconClassName: o.icon,
168
+ fraction: 1,
169
+ size: a,
170
+ color: R,
171
+ glyphs: z
172
+ }) : /* @__PURE__ */ E(_.Provider, {
173
+ value: U,
174
+ children: b(g, i)
176
175
  }),
177
- k && /* @__PURE__ */ g("span", {
178
- className: e("ms-1 font-semibold text-foreground", A),
179
- children: b
176
+ I && /* @__PURE__ */ E("span", {
177
+ className: e(o.value, "ms-1 font-semibold text-foreground", L),
178
+ children: M
180
179
  }),
181
- S !== void 0 && /* @__PURE__ */ _("span", {
182
- className: e("ms-1 text-muted-foreground", A),
180
+ N !== void 0 && /* @__PURE__ */ D("span", {
181
+ className: e(o.count, "ms-1 text-muted-foreground", L),
183
182
  children: [
184
183
  "(",
185
- S,
184
+ N,
186
185
  ")"
187
186
  ]
188
187
  })
189
188
  ]
190
189
  });
191
190
  };
192
- D.displayName = "RatingDisplay";
191
+ M.displayName = "RatingDisplay";
192
+ var N = /* @__PURE__ */ Object.assign(k, { Item: v }), P = /* @__PURE__ */ Object.assign(M, { Item: v }), F = v;
193
193
  //#endregion
194
- export { S as Rating, D as RatingDisplay };
194
+ export { N as Rating, P as RatingDisplay, F as RatingDisplayItem, v as RatingItem };
195
195
 
196
196
  //# sourceMappingURL=Rating.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Rating.mjs","names":["React","defaultStarLabel","value","sizeMap","targetPaddingMap","Star","filled","StarIcon","Rating","valueProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","rest","onChange","warnDeprecated","initialValue","defaultValue","setValue","useControllable","onValueChange","next","hovered","setHovered","prevDisabled","setPrevDisabled","disabled","displayValue","useRovingTabIndex","handleKeyDown","max","intent","getArrowIntent","getDirection","focusValue","rootRef","mergedRef","useMergedRefs","ref","containerProps","field","useFieldContext","fieldProps","useFieldControl","required","isRequired","defaultName","form","focusTabStop","starSize","size","starLabel","labels","cn","className","composeEventHandlers","onKeyDown","onFocus","onMouseLeave","starValue","i","key","getTabIndex","focusRing","HiddenInput","textSizeMap","defaultRatingLabel","formattedValue","defaultCountLabel","count","formattedCount","supportedLocale","locale","RatingDisplay","formatLocale","invalidLocale","warnOnce","ratingName","name","showText","showValue","compact","textSize","percent"],"sources":["../../../src/components/input/Rating.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { StarIcon } from '../../lib/icons';\nimport { focusRing } from '../../lib/styles';\nimport type { Size } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useRovingTabIndex } from '../../hooks/useRovingTabIndex';\nimport { HiddenInput } from '../internal/HiddenInput';\n\n/**\n * The Rating's built-in star names, for localization. Each member is optional and falls back to\n * its English default.\n */\nexport interface RatingLabels {\n /**\n * Accessible name of the star that chooses `value` (1 to `max`).\n * @default (value) => value === 1 ? '1 star' : `${value} stars`\n */\n star?: (value: number, max: number) => string;\n}\n\nconst defaultStarLabel = (value: number) => `${value} star${value !== 1 ? 's' : ''}`;\n\n/** Properties for the Rating component. */\nexport interface RatingProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue'\n> {\n /** Controlled rating value (`0` = no rating). */\n value?: number;\n /** Initial rating for uncontrolled usage (also the value a form reset restores).\n * @default 0\n */\n defaultValue?: number;\n /** Called with the new rating when it changes (not when the current star is chosen again). */\n onValueChange?: (value: number) => void;\n /**\n * Called with the new rating, exactly like `onValueChange`: only when the rating changes (0.4\n * also called it when the current star was clicked again, or a key was pressed at an end).\n * @deprecated Use `onValueChange`.\n */\n onChange?: (value: number) => void;\n /** Maximum number of stars.\n * @default 5\n */\n max?: number;\n /** Size of the star icons. Every size keeps a target of at least 24×24px.\n * @default 'medium'\n */\n size?: Size;\n /** Whether the rating is disabled and non-interactive.\n * @default false\n */\n disabled?: boolean;\n /**\n * Form field name. With a name, the chosen rating is submitted with the form (nothing while no\n * star is chosen).\n */\n name?: string;\n /** A star must be chosen before the form can be submitted (native validation). */\n required?: boolean;\n /** Id of the form the rating belongs to, when it is rendered outside that form. */\n form?: string;\n /**\n * Names of the stars (\"1 star\", \"2 stars\", …), for localization. The group's own name is\n * `aria-label` (default \"Rating\"). Unset members keep their English defaults.\n */\n labels?: RatingLabels;\n /** Ref to the `role=\"radiogroup\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Built-in texts of RatingDisplay, for localization. */\nexport interface RatingDisplayLabels {\n /**\n * Accessible name. `formattedValue` is `value` formatted with `locale` (as shown).\n * @default (value, max, formattedValue) => `Rating: ${formattedValue} out of ${max}`\n */\n rating?: (value: number, max: number, formattedValue: string) => string;\n /**\n * Count part of the name.\n * @default (count, formatted) => count === 1 ? '1 rating' : `${formatted} ratings`\n */\n count?: (count: number, formattedCount: string) => string;\n}\n\n/** Properties for the RatingDisplay (read-only) component. */\nexport interface RatingDisplayProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Rating value to display. A fraction is drawn as a partly filled star (`4.6` fills 60% of the\n * fifth star), so the stars show the value the accessible name reports.\n */\n value: number;\n /** Maximum number of stars.\n * @default 5\n */\n max?: number;\n /** Size of the star icons (and of the value and count text).\n * @default 'medium'\n */\n size?: Size;\n /**\n * Shows the value as text after the stars, formatted with `locale` (up to one decimal).\n * @default false\n */\n showValue?: boolean;\n /**\n * Number of ratings: shown as \"(1,160)\" after the value with the locale's digit grouping, and\n * added to the accessible name (\"…, 1,160 ratings\").\n */\n count?: number;\n /**\n * One filled star followed by the value (and the count) instead of `max` stars. Implies\n * `showValue`.\n * @default false\n */\n compact?: boolean;\n /**\n * BCP 47 locale of the value and count formatting (runtime default when omitted; pass it when\n * rendering on the server). A tag `Intl` rejects (the POSIX `de_DE`, a typo) falls back to the\n * runtime default locale (development warning).\n */\n locale?: string;\n /** Built-in texts, for localization. */\n labels?: RatingDisplayLabels;\n /** Ref to the root element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst sizeMap: Record<Size, string> = {\n 'extra-small': 'h-3 w-3',\n small: 'h-4 w-4',\n medium: 'h-5 w-5',\n large: 'h-6 w-6',\n 'extra-large': 'h-8 w-8',\n};\n\n/** Padding that gives every interactive star a target of at least 24×24px (WCAG 2.5.8). */\nconst targetPaddingMap: Record<Size, string> = {\n 'extra-small': 'p-1.5', // 12px icon + 12px\n small: 'p-1', // 16px icon + 8px\n medium: 'p-0.5', // 20px icon + 4px\n large: 'p-0.5',\n 'extra-large': 'p-0.5',\n};\n\n/** A filled star, or an outlined one (the outline keeps a 3:1 non-text contrast). */\nfunction Star({ filled, className }: { filled: boolean; className: string }) {\n return filled ? (\n <StarIcon className={className} />\n ) : (\n <StarIcon className={className} fill=\"none\" stroke=\"currentColor\" strokeWidth={1.5} />\n );\n}\n\n/**\n * A star rating input (`role=\"radiogroup\"` of `role=\"radio\"` stars).\n *\n * - One tab stop (the chosen star, else the first). Keys choose relative to the current rating and\n * move focus to the chosen star, as in 0.4: Right/Up one star more, Left/Down one fewer\n * (Left/Right mirrored under `dir=\"rtl\"`), Home/End the first/last star. From an empty rating,\n * Right/Up/Home choose 1 star. Keys at the ends (and Left/Down while empty) emit nothing.\n * - The keyboard cannot clear a rating: Left/Down stop at 1 star (APG radio group; 0.4 went down\n * to 0). Only a controlled `value={0}` (or a form reset while `defaultValue` is 0) clears it.\n * - `onValueChange` (and the deprecated `onChange` alias) fire only when the rating changes, so\n * choosing the current star again calls neither.\n * - Hovering previews a value; the preview never outlives the hover or a disabled state.\n * - Inside a `Field` it is named by the Field label (instead of the default \"Rating\") and\n * described by its hint and error. The stars are named \"1 star\", \"2 stars\", …; `labels`\n * localizes these names.\n * - With `name` (or `required`) it takes part in native forms; a form reset restores\n * `defaultValue`.\n */\nexport const Rating = ({\n value: valueProp,\n defaultValue,\n onValueChange,\n onChange,\n max = 5,\n size = 'medium',\n disabled = false,\n name,\n required,\n form,\n labels,\n className,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n onKeyDown,\n onFocus,\n onMouseLeave,\n ref,\n ...rest\n}: RatingProps) => {\n if (onChange !== undefined) warnDeprecated('Rating', 'onChange', 'onValueChange');\n const initialValue = defaultValue ?? 0;\n const [value, setValue] = useControllable(valueProp, initialValue, (next: number) => {\n onValueChange?.(next);\n onChange?.(next);\n });\n\n const [hovered, setHovered] = React.useState(0);\n // A hover preview must not survive the rating becoming disabled (adjust state during render).\n const [prevDisabled, setPrevDisabled] = React.useState(disabled);\n if (prevDisabled !== disabled) {\n setPrevDisabled(disabled);\n if (disabled) setHovered(0);\n }\n const displayValue = disabled ? value : hovered || value;\n\n // Roving tab stop (the chosen star, else the first) and focus moves; the keys are handled below.\n const { containerProps, getTabIndex, focusValue } = useRovingTabIndex({\n activeValue: value > 0 ? String(value) : null,\n });\n\n // Keys count from the current rating, not from the focused star (0.4 semantics): from an empty\n // rating, Tab lands on the unchosen first star and Right/Up/Home choose it. Never wraps.\n const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) return;\n let next: number;\n if (e.key === 'Home') next = 1;\n else if (e.key === 'End') next = max;\n else if (e.key === 'ArrowUp') next = value + 1;\n else if (e.key === 'ArrowDown') next = value - 1;\n else {\n const intent = getArrowIntent(e.key, {\n orientation: 'horizontal',\n dir: getDirection(e.currentTarget),\n });\n if (!intent) return;\n next = intent === 'next' ? value + 1 : value - 1;\n }\n e.preventDefault();\n next = Math.min(next, max);\n // The ends are no-ops (nothing is emitted, focus stays), and Left/Down never clear to 0.\n if (disabled || next < 1 || next === value) return;\n focusValue(String(next));\n setValue(next);\n };\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, containerProps.ref, rootRef);\n\n const field = useFieldContext();\n const fieldProps = useFieldControl(\n {\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n // An explicit `required={false}` wins over a required Field, so aria-required always\n // matches the native validation below (`isRequired`).\n 'aria-required': ariaRequired ?? required,\n },\n { labelable: false },\n );\n const isRequired = required ?? field?.required ?? false;\n const defaultName =\n fieldProps['aria-label'] === undefined && fieldProps['aria-labelledby'] === undefined\n ? 'Rating'\n : undefined;\n\n useFormReset(rootRef, () => setValue(initialValue), form);\n\n const focusTabStop = () => {\n rootRef.current?.querySelector<HTMLElement>('[data-roving-value][tabindex=\"0\"]')?.focus();\n };\n\n const starSize = sizeMap[size];\n const starLabel = labels?.star ?? defaultStarLabel;\n\n return (\n <div\n role=\"radiogroup\"\n aria-label={defaultName}\n {...fieldProps}\n aria-disabled={disabled || undefined}\n className={cn(\n 'relative inline-flex items-center gap-0.5',\n disabled && 'pointer-events-none opacity-50',\n className,\n )}\n {...rest}\n ref={mergedRef}\n data-roving-container=\"\"\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n onFocus={composeEventHandlers(onFocus, containerProps.onFocus, {\n checkDefaultPrevented: false,\n })}\n onMouseLeave={composeEventHandlers(onMouseLeave, () => setHovered(0), {\n checkDefaultPrevented: false,\n })}\n >\n {Array.from({ length: max }, (_, i) => {\n const starValue = i + 1;\n const key = String(starValue);\n const filled = displayValue >= starValue;\n return (\n <button\n key={key}\n type=\"button\"\n role=\"radio\"\n aria-checked={value === starValue}\n aria-label={starLabel(starValue, max)}\n data-roving-value={key}\n tabIndex={disabled ? -1 : getTabIndex(key)}\n disabled={disabled}\n className={cn(\n 'inline-flex cursor-pointer rounded border-0 bg-transparent transition-colors motion-reduce:transition-none disabled:cursor-not-allowed',\n targetPaddingMap[size],\n focusRing,\n filled ? 'text-rating' : 'text-stroke-accessible',\n )}\n onClick={() => {\n // Choosing the current star again is a no-op for both callbacks (useControllable).\n if (!disabled) setValue(starValue);\n }}\n onMouseEnter={() => {\n if (!disabled) setHovered(starValue);\n }}\n >\n <Star filled={filled} className={starSize} />\n </button>\n );\n })}\n <HiddenInput\n type=\"radio\"\n name={name}\n form={form}\n disabled={disabled}\n value={value > 0 ? String(value) : ''}\n required={isRequired}\n onInvalid={focusTabStop}\n />\n </div>\n );\n};\nRating.displayName = 'Rating';\n\n/** Text size of the value and the count, following the star size. */\nconst textSizeMap: Record<Size, string> = {\n 'extra-small': 'text-caption-1',\n small: 'text-caption-1',\n medium: 'text-body-1',\n large: 'text-body-2',\n 'extra-large': 'text-body-2',\n};\n\nconst defaultRatingLabel = (_value: number, max: number, formattedValue: string) =>\n `Rating: ${formattedValue} out of ${max}`;\nconst defaultCountLabel = (count: number, formattedCount: string) =>\n count === 1 ? '1 rating' : `${formattedCount} ratings`;\n\n/** `locale` when `Intl` accepts it as a language tag, else `undefined` (the runtime default). */\nfunction supportedLocale(locale: string | undefined): string | undefined {\n if (locale === undefined) return undefined;\n try {\n Intl.getCanonicalLocales(locale);\n return locale;\n } catch {\n return undefined;\n }\n}\n\n/**\n * A read-only star rating (`role=\"img\"` named \"Rating: <value> out of <max>\"). A fractional value\n * is drawn with a partly filled star, so the stars and the name show the same value.\n *\n * - `showValue` adds the value as text after the stars, `count` the number of ratings (\"(1,160)\",\n * also added to the name), and `compact` shows one filled star with the value instead of `max`\n * stars (the root carries `data-compact`). Without them only the stars show.\n * - The value (up to one decimal) and the count are formatted with `locale`, in the text and in\n * the name; `labels` localizes the name. Pass `locale` when rendering on the server.\n */\nexport const RatingDisplay = ({\n value,\n max = 5,\n size = 'medium',\n showValue = false,\n count,\n compact = false,\n locale,\n labels,\n className,\n ref,\n ...rest\n}: RatingDisplayProps) => {\n const starSize = sizeMap[size];\n const formatLocale = supportedLocale(locale);\n const invalidLocale = locale !== undefined && formatLocale === undefined;\n React.useEffect(() => {\n if (invalidLocale) {\n warnOnce(\n `RatingDisplay:invalid-locale:${locale}`,\n `RatingDisplay: \\`locale\\` \"${locale}\" is not a valid BCP 47 language tag (use hyphens, as ` +\n 'in \"en-US\"). The runtime default locale formats the value instead, so the server and ' +\n 'the browser may render different text.',\n );\n }\n }, [invalidLocale, locale]);\n\n const formattedValue = new Intl.NumberFormat(formatLocale, { maximumFractionDigits: 1 }).format(\n value,\n );\n const formattedCount =\n count === undefined ? undefined : new Intl.NumberFormat(formatLocale).format(count);\n const ratingName = (labels?.rating ?? defaultRatingLabel)(value, max, formattedValue);\n const name =\n count === undefined || formattedCount === undefined\n ? ratingName\n : `${ratingName}, ${(labels?.count ?? defaultCountLabel)(count, formattedCount)}`;\n const showText = showValue || compact || count !== undefined;\n const textSize = textSizeMap[size];\n\n return (\n <div\n ref={ref}\n role=\"img\"\n aria-label={name}\n data-compact={compact ? '' : undefined}\n className={cn('inline-flex items-center gap-0.5', className)}\n {...rest}\n >\n {compact ? (\n <span className=\"inline-flex text-rating\">\n <Star filled className={starSize} />\n </span>\n ) : (\n Array.from({ length: max }, (_, i) => {\n // The share of this star that the value covers, in whole percent.\n const percent = Math.round(Math.min(1, Math.max(0, value - i)) * 100);\n if (percent > 0 && percent < 100) {\n // The outline of an empty star, with the filled star clipped to the fraction over it\n // from the inline start (the reading direction of the stars, also under RTL).\n return (\n <span key={i} className=\"relative inline-flex text-stroke-accessible\">\n <Star filled={false} className={starSize} />\n <span\n className=\"absolute inset-y-0 start-0 flex overflow-hidden text-rating\"\n style={{ width: `${percent}%` }}\n >\n <Star filled className={cn(starSize, 'shrink-0')} />\n </span>\n </span>\n );\n }\n const filled = percent === 100;\n return (\n <span\n key={i}\n className={cn('inline-flex', filled ? 'text-rating' : 'text-stroke-accessible')}\n >\n <Star filled={filled} className={starSize} />\n </span>\n );\n })\n )}\n {showText && (\n <span className={cn('ms-1 font-semibold text-foreground', textSize)}>{formattedValue}</span>\n )}\n {formattedCount !== undefined && (\n <span className={cn('ms-1 text-muted-foreground', textSize)}>({formattedCount})</span>\n )}\n </div>\n );\n};\nRatingDisplay.displayName = 'RatingDisplay';\n"],"mappings":";;;;;;;;;;;;;;;;AA2BA,IAAMC,KAAoB,MAAkB,GAAGC,EAAM,OAAOA,MAAU,IAAU,KAAN,OA4GpEC,IAAgC;CACpC,eAAe;CACf,OAAO;CACP,QAAQ;CACR,OAAO;CACP,eAAe;AACjB,GAGMC,IAAyC;CAC7C,eAAe;CACf,OAAO;CACP,QAAQ;CACR,OAAO;CACP,eAAe;AACjB;AAGA,SAASC,EAAK,EAAE,WAAQ,gBAAqD;CAC3E,OAAOC,IACL,kBAACC,GAAD,EAAqB,aAAY,CAAA,IAEjC,kBAACA,GAAD;EAAqB;EAAW,MAAK;EAAO,QAAO;EAAe,aAAa;CAAM,CAAA;AAEzF;AAoBA,IAAaC,KAAU,EACrB,OAAOC,GACP,iBACA,kBACA,aACA,SAAM,GACN,UAAO,UACP,cAAW,IACX,SACA,aACA,SACA,WACA,cACA,OACA,cAAcC,GACd,mBAAmBC,GACnB,oBAAoBC,GACpB,gBAAgBC,IAChB,iBAAiBC,IACjB,eACA,YACA,iBACA,QACA,GAAGC,QACc;CACjB,AAAIC,MAAa,KAAA,KAAWC,EAAe,UAAU,YAAY,eAAe;CAChF,IAAM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AAmB,KAAA,KAClB,kBAAC,QAAD;IAAM,WAAWjB,EAAG,8BAA8B6B,CAAQ;IAA1D,UAAA;KAA6D;KAAEZ;KAAe;IAAO;;EAEpF;;AAET;AACA,EAAc,cAAc"}
1
+ {"version":3,"file":"Rating.mjs","names":["React","defaultStarLabel","value","RatingRoot","valueProp","stepProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","rest","onChange","warnDeprecated","initialValue","defaultValue","setValue","useControllable","onValueChange","next","step","hovered","setHovered","prevDisabled","setPrevDisabled","disabled","drawnValue","useRovingTabIndex","up","v","down","handleKeyDown","isOwnEvent","max","intent","getArrowIntent","getDirection","focusValue","rootRef","mergedRef","useMergedRefs","ref","containerProps","field","useFieldContext","fieldProps","useFieldControl","required","isRequired","defaultName","form","focusTabStop","focusChosen","useEventCallback","key","resolvedColor","resolveRatingColor","color","glyphs","useStarGlyphs","iconFilled","iconOutline","starLabel","labels","useRatingItemRegistry","hasItems","slotRendersContent","children","counts","context","focus","size","getTabIndex","registerItem","cn","ratingClassNames","className","composeEventHandlers","onKeyDown","onFocus","onMouseLeave","RatingContext","ratingItems","HiddenInput","textSizeMap","defaultRatingLabel","formattedValue","defaultCountLabel","count","formattedCount","supportedLocale","locale","RatingDisplayRoot","formatLocale","invalidLocale","warnOnce","ratingName","name","showText","showValue","compact","textSize","INERT_RATING_CONTEXT","ratingDisplayClassNames","StarGlyph","Rating","RatingItem","RatingDisplay","RatingDisplayItem"],"sources":["../../../src/components/input/Rating.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ratingClassNames, ratingDisplayClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { isOwnEvent } from '../../lib/events';\nimport { slotRendersContent, type Slot } from '../../lib/slot';\nimport type { Size } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useRovingTabIndex } from '../../hooks/useRovingTabIndex';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport {\n INERT_RATING_CONTEXT,\n RatingContext,\n RatingItem,\n ratingItems,\n resolveRatingColor,\n StarGlyph,\n useRatingItemChecks,\n useRatingItemRegistry,\n useStarGlyphs,\n type RatingColor,\n type RatingContextValue,\n} from './Rating.item';\n\n/**\n * The Rating's built-in star names, for localization. Each member is optional and falls back to\n * its English default.\n */\nexport interface RatingLabels {\n /**\n * Accessible name of the radio that chooses `value`: a whole star (1 to `max`), and with\n * `step={0.5}` a half value too (\"2.5 stars\").\n * @default (value) => value === 1 ? '1 star' : `${value} stars`\n */\n star?: (value: number, max: number) => string;\n}\n\nconst defaultStarLabel = (value: number) => `${value} star${value !== 1 ? 's' : ''}`;\n\n/** Properties for the Rating component. */\nexport interface RatingProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue' | 'color'\n> {\n /**\n * Controlled rating value (`0` = no rating): a whole number of stars, or with `step={0.5}` a\n * multiple of 0.5. A value between two steps (2.7) checks no radio, is drawn as the step below\n * it (2.5) and holds the tab stop there; the keys move it to the next or previous step.\n */\n value?: number;\n /** Initial rating for uncontrolled usage (also the value a form reset restores).\n * @default 0\n */\n defaultValue?: number;\n /** Called with the new rating when it changes (not when the current star is chosen again). */\n onValueChange?: (value: number) => void;\n /**\n * Called with the new rating, exactly like `onValueChange`: only when the rating changes (0.4\n * also called it when the current star was clicked again, or a key was pressed at an end).\n * @deprecated Use `onValueChange`.\n */\n onChange?: (value: number) => void;\n /** Maximum number of stars.\n * @default 5\n */\n max?: number;\n /**\n * The grain of the rating: `1` (whole stars) or `0.5` (half stars). With `0.5`, each star stays\n * one pointer target of at least 24×24px (a larger `size` keeps a larger one): the half is\n * chosen by the pointer's position over it (the half at the inline start, which mirrors under\n * `dir=\"rtl\"`), and two transparent radios per star, the half value then the full value, serve\n * the keyboard and screen readers. The keys then move by half a star. A value other than `0.5`\n * (from untyped code) counts as `1`. RatingDisplay has no `step`: it draws any fraction.\n * @default 1\n */\n step?: 0.5 | 1;\n /** Size of the star icons. Every size keeps a target of at least 24×24px.\n * @default 'medium'\n */\n size?: Size;\n /**\n * Color of the filled stars: `marigold` (default), `brand` or `neutral`; unfilled stars keep a\n * 3:1 outline. Fluent's default is `neutral`. A value outside the three (from untyped code)\n * renders as `marigold`; the root carries `data-color` with the resolved value.\n * @default 'marigold'\n */\n color?: RatingColor;\n /**\n * The glyph of a filled star. `iconFilled` and `iconOutline` are the glyphs of a filled and an\n * unfilled star, as a pair; decorative. Fluent's RatingDisplay takes one `icon`; here a filled\n * and an unfilled star must differ by shape, not by color alone.\n *\n * - Each glyph is sized by `size` (an SVG child fills the star) and takes the star's color\n * (paint it with `currentColor`). A half-filled star (`step={0.5}`) clips the filled glyph\n * over the unfilled one from the inline start.\n * - `null`, `undefined` and a value that renders nothing draw the default star. A value that\n * renders nothing, and a pair with only one of the two set, log a development warning.\n * - A `<button>` or `Button` element (or a slot object whose `as` is one) is not nested in the\n * star: its children become the glyph (the default star when they render nothing), its props\n * are dropped, and a development warning says so (in place of the warning for a value that\n * renders nothing).\n * - A `Rating.Item` that sets its own pair draws that one instead.\n */\n iconFilled?: Slot<'span'>;\n /**\n * The glyph of an unfilled star, as a pair with `iconFilled` (its rules apply); decorative.\n * Fluent's RatingDisplay takes one `icon`; here a filled and an unfilled star must differ by\n * shape, not by color alone.\n */\n iconOutline?: Slot<'span'>;\n /** Whether the rating is disabled and non-interactive.\n * @default false\n */\n disabled?: boolean;\n /**\n * Form field name. With a name, the chosen rating is submitted with the form (nothing while no\n * star is chosen).\n */\n name?: string;\n /** A star must be chosen before the form can be submitted (native validation). */\n required?: boolean;\n /** Id of the form the rating belongs to, when it is rendered outside that form. */\n form?: string;\n /**\n * Names of the stars (\"1 star\", \"2 stars\", …, and \"2.5 stars\" for a half value), for\n * localization. The group's own name is `aria-label` (default \"Rating\"). Unset members keep\n * their English defaults.\n */\n labels?: RatingLabels;\n /**\n * Custom stars: one `Rating.Item` per value from 1 to `max`, in place of the generated stars\n * (when the children render content). `max` still sets the key range and the star names.\n */\n children?: React.ReactNode;\n /** Ref to the `role=\"radiogroup\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Built-in texts of RatingDisplay, for localization. */\nexport interface RatingDisplayLabels {\n /**\n * Accessible name. `formattedValue` is `value` formatted with `locale` (as shown).\n * @default (value, max, formattedValue) => `Rating: ${formattedValue} out of ${max}`\n */\n rating?: (value: number, max: number, formattedValue: string) => string;\n /**\n * Count part of the name.\n * @default (count, formatted) => count === 1 ? '1 rating' : `${formatted} ratings`\n */\n count?: (count: number, formattedCount: string) => string;\n}\n\n/** Properties for the RatingDisplay (read-only) component. */\nexport interface RatingDisplayProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'> {\n /**\n * Rating value to display. A fraction is drawn as a partly filled star (`4.6` fills 60% of the\n * fifth star), so the stars show the value the accessible name reports.\n */\n value: number;\n /** Maximum number of stars.\n * @default 5\n */\n max?: number;\n /** Size of the star icons (and of the value and count text).\n * @default 'medium'\n */\n size?: Size;\n /**\n * Color of the filled stars: `marigold` (default), `brand` or `neutral`; unfilled stars keep a\n * 3:1 outline. Fluent's default is `neutral`. A value outside the three (from untyped code)\n * renders as `marigold`; the root carries `data-color` with the resolved value.\n * @default 'marigold'\n */\n color?: RatingColor;\n /**\n * The glyph of a filled star. `iconFilled` and `iconOutline` are the glyphs of a filled and an\n * unfilled star, as a pair; decorative. Fluent's RatingDisplay takes one `icon`; here a filled\n * and an unfilled star must differ by shape, not by color alone.\n *\n * - Each glyph is sized by `size` (an SVG child fills the star) and takes the star's color\n * (paint it with `currentColor`). A partly filled star clips the filled glyph over the\n * unfilled one from the inline start, and the `compact` star is the filled glyph.\n * - `null`, `undefined` and a value that renders nothing draw the default star. A value that\n * renders nothing, and a pair with only one of the two set, log a development warning.\n * - A `<button>` or `Button` element (or a slot object whose `as` is one) is not nested in the\n * star: its children become the glyph (the default star when they render nothing), its props\n * are dropped, and a development warning says so (in place of the warning for a value that\n * renders nothing).\n * - A `RatingDisplay.Item` that sets its own pair draws that one instead.\n */\n iconFilled?: Slot<'span'>;\n /**\n * The glyph of an unfilled star, as a pair with `iconFilled` (its rules apply); decorative.\n * Fluent's RatingDisplay takes one `icon`; here a filled and an unfilled star must differ by\n * shape, not by color alone.\n */\n iconOutline?: Slot<'span'>;\n /**\n * Shows the value as text after the stars, formatted with `locale` (up to one decimal).\n * @default false\n */\n showValue?: boolean;\n /**\n * Number of ratings: shown as \"(1,160)\" after the value with the locale's digit grouping, and\n * added to the accessible name (\"…, 1,160 ratings\").\n */\n count?: number;\n /**\n * One filled star followed by the value (and the count) instead of `max` stars. Implies\n * `showValue`.\n * @default false\n */\n compact?: boolean;\n /**\n * BCP 47 locale of the value and count formatting (runtime default when omitted; pass it when\n * rendering on the server). A tag `Intl` rejects (the POSIX `de_DE`, a typo) falls back to the\n * runtime default locale (development warning).\n */\n locale?: string;\n /** Built-in texts, for localization. */\n labels?: RatingDisplayLabels;\n /**\n * Custom stars: one `RatingDisplay.Item` per value from 1 to `max`, in place of the generated\n * stars (when the children render content). A `compact` display ignores them.\n */\n children?: React.ReactNode;\n /** Ref to the root element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst RatingRoot = ({\n value: valueProp,\n defaultValue,\n onValueChange,\n onChange,\n max = 5,\n step: stepProp,\n size = 'medium',\n color,\n iconFilled,\n iconOutline,\n disabled = false,\n name,\n required,\n form,\n labels,\n className,\n children,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n onKeyDown,\n onFocus,\n onMouseLeave,\n ref,\n ...rest\n}: RatingProps) => {\n if (onChange !== undefined) warnDeprecated('Rating', 'onChange', 'onValueChange');\n const initialValue = defaultValue ?? 0;\n const [value, setValue] = useControllable(valueProp, initialValue, (next: number) => {\n onValueChange?.(next);\n onChange?.(next);\n });\n // The items draw whole or half stars only, so the keys move by one of the two (untyped code\n // may pass another number).\n const step: 0.5 | 1 = stepProp === 0.5 ? 0.5 : 1;\n\n const [hovered, setHovered] = React.useState(0);\n // A hover preview must not survive the rating becoming disabled (adjust state during render).\n const [prevDisabled, setPrevDisabled] = React.useState(disabled);\n if (prevDisabled !== disabled) {\n setPrevDisabled(disabled);\n if (disabled) setHovered(0);\n }\n const drawnValue = disabled ? value : hovered || value;\n\n // Roving tab stop (the radio of the chosen value, else the first) and focus moves; the keys are\n // handled below. A value between two steps holds the tab stop on the radio below it (D23).\n const { containerProps, getTabIndex, focusValue } = useRovingTabIndex({\n activeValue: value >= step ? String(Math.floor(value / step) * step) : null,\n });\n\n // The next and previous multiples of `step`: a value between two steps (a controlled 2.7 at\n // step 0.5) moves to the step above or below it (3 or 2.5).\n const up = (v: number) => Math.floor(v / step) * step + step;\n const down = (v: number) => Math.ceil(v / step) * step - step;\n\n // Keys count from the current rating, not from the focused radio (0.4 semantics): from an empty\n // rating, Tab lands on the unchosen first radio and Right/Up/Home choose it. Never wraps.\n // Keys from a portal rendered among the children (a popup opened from one) are not the rating's.\n const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || !isOwnEvent(e)) return;\n let next: number;\n if (e.key === 'Home') next = step;\n else if (e.key === 'End') next = max;\n else if (e.key === 'ArrowUp') next = up(value);\n else if (e.key === 'ArrowDown') next = down(value);\n else {\n const intent = getArrowIntent(e.key, {\n orientation: 'horizontal',\n dir: getDirection(e.currentTarget),\n });\n if (!intent) return;\n next = intent === 'next' ? up(value) : down(value);\n }\n e.preventDefault();\n next = Math.min(next, max);\n // The ends are no-ops (nothing is emitted, focus stays), and Left/Down never clear to 0.\n if (disabled || next < step || next === value) return;\n focusValue(String(next));\n setValue(next);\n };\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, containerProps.ref, rootRef);\n\n const field = useFieldContext();\n const fieldProps = useFieldControl(\n {\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n // An explicit `required={false}` wins over a required Field, so aria-required always\n // matches the native validation below (`isRequired`).\n 'aria-required': ariaRequired ?? required,\n },\n { labelable: false },\n );\n const isRequired = required ?? field?.required ?? false;\n const defaultName =\n fieldProps['aria-label'] === undefined && fieldProps['aria-labelledby'] === undefined\n ? 'Rating'\n : undefined;\n\n useFormReset(rootRef, () => setValue(initialValue), form);\n\n const focusTabStop = () => {\n rootRef.current?.querySelector<HTMLElement>('[data-roving-value][tabindex=\"0\"]')?.focus();\n };\n\n // A pointer click on a half star focuses the radio it chose, so the keyboard continues from\n // there, without scrolling: the star is under the pointer already (D22).\n const focusChosen = useEventCallback((key: string) => {\n rootRef.current\n ?.querySelector<HTMLElement>(`[data-roving-value=\"${key}\"]`)\n ?.focus({ preventScroll: true });\n });\n\n const resolvedColor = resolveRatingColor(color);\n const glyphs = useStarGlyphs('Rating', iconFilled, iconOutline);\n const starLabel = labels?.star ?? defaultStarLabel;\n const { registerItem, counts } = useRatingItemRegistry();\n // Whether the root draws its own children instead of the `max` generated stars (D26): the\n // generated stars always cover every value on their own, so only a custom item set can leave\n // one missing.\n const hasItems = slotRendersContent(children);\n useRatingItemChecks(counts, max, hasItems);\n const context = React.useMemo<RatingContextValue>(\n () => ({\n kind: 'input',\n value,\n drawnValue,\n step,\n max,\n size,\n color: resolvedColor,\n glyphs,\n disabled,\n starLabel,\n getTabIndex,\n choose: (next, focus) => {\n setValue(next);\n if (focus) focusChosen(String(next));\n },\n preview: setHovered,\n registerItem,\n }),\n [\n value,\n drawnValue,\n step,\n max,\n size,\n resolvedColor,\n glyphs,\n disabled,\n starLabel,\n getTabIndex,\n setValue,\n focusChosen,\n registerItem,\n ],\n );\n\n return (\n <div\n role=\"radiogroup\"\n aria-label={defaultName}\n {...fieldProps}\n aria-disabled={disabled || undefined}\n data-color={resolvedColor}\n className={cn(\n ratingClassNames.root,\n 'relative inline-flex items-center gap-0.5',\n disabled && 'pointer-events-none opacity-50',\n className,\n )}\n {...rest}\n ref={mergedRef}\n data-roving-container=\"\"\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n onFocus={composeEventHandlers(onFocus, containerProps.onFocus, {\n checkDefaultPrevented: false,\n })}\n onMouseLeave={composeEventHandlers(onMouseLeave, () => setHovered(0), {\n checkDefaultPrevented: false,\n })}\n >\n <RatingContext.Provider value={context}>{ratingItems(children, max)}</RatingContext.Provider>\n <HiddenInput\n type=\"radio\"\n name={name}\n form={form}\n disabled={disabled}\n value={value > 0 ? String(value) : ''}\n required={isRequired}\n onInvalid={focusTabStop}\n />\n </div>\n );\n};\nRatingRoot.displayName = 'Rating';\n\n/** Text size of the value and the count, following the star size. */\nconst textSizeMap: Record<Size, string> = {\n 'extra-small': 'text-caption-1',\n small: 'text-caption-1',\n medium: 'text-body-1',\n large: 'text-body-2',\n 'extra-large': 'text-body-2',\n};\n\nconst defaultRatingLabel = (_value: number, max: number, formattedValue: string) =>\n `Rating: ${formattedValue} out of ${max}`;\nconst defaultCountLabel = (count: number, formattedCount: string) =>\n count === 1 ? '1 rating' : `${formattedCount} ratings`;\n\n/** `locale` when `Intl` accepts it as a language tag, else `undefined` (the runtime default). */\nfunction supportedLocale(locale: string | undefined): string | undefined {\n if (locale === undefined) return undefined;\n try {\n Intl.getCanonicalLocales(locale);\n return locale;\n } catch {\n return undefined;\n }\n}\n\nconst RatingDisplayRoot = ({\n value,\n max = 5,\n size = 'medium',\n color,\n iconFilled,\n iconOutline,\n showValue = false,\n count,\n compact = false,\n locale,\n labels,\n className,\n children,\n ref,\n ...rest\n}: RatingDisplayProps) => {\n const formatLocale = supportedLocale(locale);\n const invalidLocale = locale !== undefined && formatLocale === undefined;\n React.useEffect(() => {\n if (invalidLocale) {\n warnOnce(\n `RatingDisplay:invalid-locale:${locale}`,\n `RatingDisplay: \\`locale\\` \"${locale}\" is not a valid BCP 47 language tag (use hyphens, as ` +\n 'in \"en-US\"). The runtime default locale formats the value instead, so the server and ' +\n 'the browser may render different text.',\n );\n }\n }, [invalidLocale, locale]);\n\n const formattedValue = new Intl.NumberFormat(formatLocale, { maximumFractionDigits: 1 }).format(\n value,\n );\n const formattedCount =\n count === undefined ? undefined : new Intl.NumberFormat(formatLocale).format(count);\n const ratingName = (labels?.rating ?? defaultRatingLabel)(value, max, formattedValue);\n const name =\n count === undefined || formattedCount === undefined\n ? ratingName\n : `${ratingName}, ${(labels?.count ?? defaultCountLabel)(count, formattedCount)}`;\n const showText = showValue || compact || count !== undefined;\n const textSize = textSizeMap[size];\n\n const resolvedColor = resolveRatingColor(color);\n const glyphs = useStarGlyphs('RatingDisplay', iconFilled, iconOutline);\n const { registerItem, counts } = useRatingItemRegistry();\n // A compact display ignores `children` (D26): it never renders items of its own, so a value\n // from 1 to `max` without an item is never \"missing\" on purpose.\n const hasItems = !compact && slotRendersContent(children);\n useRatingItemChecks(counts, max, hasItems);\n // Read-only: the stars take the inert actions (they choose, preview and rove nothing).\n const context = React.useMemo<RatingContextValue>(\n () => ({\n ...INERT_RATING_CONTEXT,\n kind: 'display',\n value,\n drawnValue: value,\n max,\n size,\n color: resolvedColor,\n glyphs,\n registerItem,\n }),\n [value, max, size, resolvedColor, glyphs, registerItem],\n );\n\n return (\n <div\n ref={ref}\n role=\"img\"\n aria-label={name}\n data-compact={compact ? '' : undefined}\n data-color={resolvedColor}\n className={cn(ratingDisplayClassNames.root, 'inline-flex items-center gap-0.5', className)}\n {...rest}\n >\n {compact ? (\n <StarGlyph\n starClassName={ratingDisplayClassNames.star}\n iconClassName={ratingDisplayClassNames.icon}\n fraction={1}\n size={size}\n color={resolvedColor}\n glyphs={glyphs}\n />\n ) : (\n <RatingContext.Provider value={context}>\n {ratingItems(children, max)}\n </RatingContext.Provider>\n )}\n {showText && (\n <span\n className={cn(\n ratingDisplayClassNames.value,\n 'ms-1 font-semibold text-foreground',\n textSize,\n )}\n >\n {formattedValue}\n </span>\n )}\n {formattedCount !== undefined && (\n <span className={cn(ratingDisplayClassNames.count, 'ms-1 text-muted-foreground', textSize)}>\n ({formattedCount})\n </span>\n )}\n </div>\n );\n};\nRatingDisplayRoot.displayName = 'RatingDisplay';\n\n/**\n * A star rating input (`role=\"radiogroup\"` of `role=\"radio\"` stars).\n *\n * - One tab stop (the radio of the chosen value, else the first). Keys choose relative to the\n * current rating and move focus to the chosen radio, as in 0.4: Right/Up one `step` more (a\n * star, or half a star), Left/Down one fewer (Left/Right mirrored under `dir=\"rtl\"`), Home the\n * smallest value (`step`) and End `max`. From an empty rating, Right/Up/Home choose `step`.\n * Keys at the ends (and Left/Down while empty) emit nothing.\n * - The keyboard cannot clear a rating: Left/Down stop at `step` (APG radio group; 0.4 went down\n * to 0). Only a controlled `value={0}` (or a form reset while `defaultValue` is 0) clears it.\n * - `step={0.5}` offers half stars. Each star stays one pointer target, which chooses by the\n * pointer's position (its half from the inline start, else its full value) and then focuses\n * the radio it chose; it holds two transparent radios (\"2.5 stars\", \"3 stars\") for the\n * keyboard and screen readers, and draws the focus ring of either. A controlled value between\n * two steps checks no radio and is drawn as the step below it; the keys move it to the next or\n * previous step.\n * - `onValueChange` (and the deprecated `onChange` alias) fire only when the rating changes, so\n * choosing the current star again calls neither.\n * - Hovering previews a value (half stars preview by the pointer's position); the preview never\n * outlives the hover or a disabled state.\n * - `color` colors the filled stars (`marigold`, the default, `brand` or `neutral`; the root\n * carries `data-color`); `iconFilled` and `iconOutline` replace the star glyphs, as a pair.\n * - Inside a `Field` it is named by the Field label (instead of the default \"Rating\") and\n * described by its hint and error. The stars are named \"1 star\", \"2 stars\", … (and a half value\n * \"2.5 stars\"); `labels` localizes these names.\n * - With `name` (or `required`) it takes part in native forms; a form reset restores\n * `defaultValue`.\n * - The stars are generated from `max`. Children that render content replace them: one\n * `Rating.Item` per value from 1 to `max`, chosen, previewed, roved and named as the generated\n * stars are (`max` still sets the key range and the star names).\n *\n * Sub-component: `Rating.Item` (the same component as `RatingDisplay.Item`). React Server\n * Components import its flat name `RatingItem` (dotted access needs a client file).\n */\nexport const Rating = /* @__PURE__ */ Object.assign(RatingRoot, { Item: RatingItem });\n\n/**\n * A read-only star rating (`role=\"img\"` named \"Rating: <value> out of <max>\"). A fractional value\n * is drawn with a partly filled star, so the stars and the name show the same value.\n *\n * - `showValue` adds the value as text after the stars, `count` the number of ratings (\"(1,160)\",\n * also added to the name), and `compact` shows one filled star with the value instead of `max`\n * stars (the root carries `data-compact`). Without them only the stars show.\n * - The value (up to one decimal) and the count are formatted with `locale`, in the text and in\n * the name; `labels` localizes the name. Pass `locale` when rendering on the server.\n * - `color` colors the filled stars (`marigold`, the default, `brand` or `neutral`; the root\n * carries `data-color`); `iconFilled` and `iconOutline` replace the star glyphs, as a pair.\n * - The stars are generated from `max`. Children that render content replace them: one\n * `RatingDisplay.Item` per value from 1 to `max`. A `compact` display ignores them.\n *\n * Sub-component: `RatingDisplay.Item` (the same component as `Rating.Item`). React Server\n * Components import its flat name `RatingDisplayItem`, or `RatingItem` (dotted access needs a\n * client file).\n */\nexport const RatingDisplay = /* @__PURE__ */ Object.assign(RatingDisplayRoot, {\n Item: RatingItem,\n});\n\n/**\n * Flat name of `RatingDisplay.Item` for React Server Components (the same component as\n * `RatingItem`).\n */\nexport const RatingDisplayItem = RatingItem;\n\nexport { RatingItem, type RatingItemProps, type RatingColor } from './Rating.item';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA2CA,IAAMC,KAAoB,MAAkB,GAAGC,EAAM,OAAOA,MAAU,IAAU,KAAN,OAiMpEC,KAAc,EAClB,OAAOC,GACP,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O;EACL,MAAK;EACL,cAAYwB;EACZ,gBAAcG,IAAU,KAAK,KAAA;EAC7B,cAAY7C;EACZ,WAAWmB,EAAG6B,EAAwB,MAAM,oCAAoC3B,CAAS;EACzF,GAAIjE;EAPN,UAAA;GASGyF,IACC,kBAACI,GAAD;IACE,eAAeD,EAAwB;IACvC,eAAeA,EAAwB;IACvC,UAAU;IACJ;IACN,OAAOhD;IACC;GACT,CAAA,IAED,kBAAC0B,EAAc,UAAf;IAAwB,OAAOZ;IAC5B,UAAAa,EAAYf,GAAUlC,CAAG;GACJ,CAAA;GAEzBiE,KACC,kBAAC,QAAD;IACE,WAAWxB,EACT6B,EAAwB,OACxB,sCACAF,CACF;IAEC,UAAAf;GACG,CAAA;GAEPG,MAAmB,KAAA,KAClB,kBAAC,QAAD;IAAM,WAAWf,EAAG6B,EAAwB,OAAO,8BAA8BF,CAAQ;IAAzF,UAAA;KAA4F;KACxFZ;KAAe;IACb;;EAEL;;AAET;AACA,EAAkB,cAAc;AAoChC,IAAagB,IAAyB,uBAAO,OAAOtG,GAAY,EAAE,MAAMuG,EAAW,CAAC,GAoBvEC,IAAgC,uBAAO,OAAOf,GAAmB,EAC5E,MAAMc,EACR,CAAC,GAMYE,IAAoBF"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/slot.cjs"),a=require("../../lib/composeEventHandlers.cjs"),o=require("../../hooks/useControllable.cjs"),s=require("../../hooks/useMergedRefs.cjs"),c=require("../../hooks/useFieldControl.cjs"),l=require("../../lib/styles.cjs"),u=require("../button/Button.cjs"),d=require("../../lib/icons.cjs"),f=require("../../lib/mergeProps.cjs"),p=require("../button/Button.slots.cjs"),m=require("./Input.cjs"),h=require("../../hooks/useFormReset.cjs"),g=require("../../lib/labelInName.cjs");let _=require("react");_=e.__toESM(_,1);let v=require("react/jsx-runtime");var y=new Set([`type`,`disabled`,`form`,`formAction`,`formEncType`,`formMethod`,`formNoValidate`,`formTarget`,`name`,`value`,`popoverTarget`,`popoverTargetAction`]),b=/^on[A-Z]/,x=new Set([`aria-label`,`aria-labelledby`,`title`]),ee=`Clear search`,te=()=>{},ne=`a[href], button, input, select, textarea, [tabindex], [contenteditable]:not([contenteditable="false"])`,S={kind:`default`,buttonProps:{},content:null,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!1};function C(e){return e===`button`||e===u.Button}function w(e,t,n){let r=i.slotRendersContent(n),a=i.materialiseSlotContent(n),o=g.hasTextLabel(a);if(e===u.Button){let e={};for(let[n,r]of Object.entries(t))n!==`children`&&!p.BUTTON_OWN_PROP_KEYS.has(n)&&(e[n]=r);let n=i.renderSlot(t.icon,`span`,`inline-flex`,{"aria-hidden":!0});return{buttonProps:e,content:n||r?p.placeButtonIcon(n,a,t.iconPosition):null,contentMayName:!0,literalTextLabel:o,disabledFocusable:!!t.disabledFocusable}}let{as:s,children:c,...l}=t;return{buttonProps:l,content:r?a:null,contentMayName:!0,literalTextLabel:o,disabledFocusable:!1}}function T(e){let t=e;if(n.isElementOfType(t,`button`,u.Button)){let e=t.props.children;return{kind:`element`,...w(n.getElementType(t),t.props,e)}}let r=i.resolveSlot(e,`span`);if(!r)return S;let{Component:a,props:o,children:s}=r;if(C(a))return{kind:`button-object`,...w(a,o,s)};let c={},l={},f=!1;for(let[e,t]of Object.entries(o))t!==void 0&&(y.has(e)||b.test(e)?(c[e]=t,f=!0):x.has(e)?c[e]=t:l[e]=t);let p=i.slotRendersContent(s),m=i.slotWrapsDefaultContent(a,{...l,children:s});if(m&&Object.keys(c).length===0&&Object.keys(l).length===0)return S;let h=m?(0,v.jsx)(d.DismissIcon,{}):p?s:void 0,g=h===void 0?_.createElement(a,{"aria-hidden":!0,...l}):_.createElement(a,{"aria-hidden":!0,...l},h);return{kind:f?`button-object`:`content`,buttonProps:c,content:g,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!1}}var E=({value:e,defaultValue:n=``,onValueChange:u,onChange:y,onClear:b,placeholder:S=`Search`,disabled:C,contentBefore:w,contentAfter:E,dismiss:D,className:re,ref:ie,controlRef:ae,id:oe,"aria-label":se,"aria-labelledby":ce,"aria-describedby":le,"aria-invalid":ue,"aria-required":de,"aria-errormessage":fe,"aria-details":pe,required:O,name:k,form:A,readOnly:j,autoComplete:M,autoFocus:N,autoCapitalize:P,autoCorrect:F,inputMode:I,enterKeyHint:L,spellCheck:R,maxLength:z,minLength:B,pattern:me,tabIndex:he,onFocus:ge,onBlur:_e,onKeyDown:ve,onKeyUp:ye,onMouseDown:be,hidden:xe,...Se})=>{y!==void 0&&r.warnDeprecated(`SearchBox`,`onChange`,`onValueChange`);let[V,H]=o.useControllable(e,n,e=>{u?.(e),y?.(e)}),U=_.useRef(null),Ce=s.useMergedRefs(U,ae);h.useFormReset(U,()=>H(n),A);let W=c.useFieldControl({id:oe,"aria-label":se,"aria-labelledby":ce,"aria-describedby":le,"aria-invalid":ue,"aria-required":de,required:O},{nativeRequired:!0}),we=m.isInvalidLook(!1,W[`aria-invalid`]),G=T(D),K=G.kind;_.useEffect(()=>{K===`element`?r.warnOnce(`SearchBox:dismiss-button-element`,"SearchBox: `dismiss` received a button element; its props were merged into the built-in clear button (buttons cannot be nested). Pass icon content instead, e.g. `dismiss={<MyIcon />}`."):K===`button-object`&&r.warnOnce(`SearchBox:dismiss-button-object`,'SearchBox: `dismiss` with button props (`as: "button"`, `onClick`, `type`, …) is deprecated and will be removed in 1.0; the props were merged into the built-in clear button. Pass icon content instead, e.g. `dismiss={<MyIcon />}`.')},[K]);let Te=()=>{H(``),b?.(),U.current?.focus()},Ee=e=>{e.key!==`Escape`||e.nativeEvent.isComposing||!V||j||C||(e.preventDefault(),H(``),b?.())},De=e=>{let t=U.current,n=e.currentTarget,r=e.target;if(!t||C||e.button!==0||r===t||!(r instanceof Element)||!n.contains(r))return;let i=r.closest(ne);i&&n.contains(i)||(e.preventDefault(),t.focus())},{onClick:Oe,ref:ke,...q}=G.buttonProps,J=Object.keys(q).some(e=>x.has(e)&&q[e]!=null),Y=G.contentMayName&&!J,X=G.literalTextLabel,[Z,Ae]=_.useState(null),je=_.useCallback(e=>Z?g.observeTextLabel(Z,e):te,[Z]),Me=_.useSyncExternalStore(je,()=>Z?g.hasRenderedTextLabel(Z):X,()=>X),Q=Y&&Me,Ne=s.useMergedRefs(ke,Y?Ae:void 0),$=f.mergeProps({type:`button`,disabled:C,"aria-label":J||Q?void 0:ee,className:t.cn(`me-1 flex h-6 w-6 shrink-0 items-center justify-center rounded bg-transparent p-0 text-muted-foreground`,`not-disabled:not-aria-disabled:hover:text-foreground`,l.focusRing,`disabled:cursor-not-allowed`,p.mergedAriaDisabledClasses)},q),Pe=$.dangerouslySetInnerHTML==null?K===`content`?G.content:G.content??(0,v.jsx)(d.DismissIcon,{}):void 0,Fe=i.slotRendersContent(w),Ie=i.slotRendersContent(E);return(0,v.jsxs)(`div`,{ref:ie,className:t.cn(`relative inline-flex h-8 w-full items-center rounded border border-input border-b-stroke-accessible bg-background text-body-1 text-foreground`,l.inputFocusWithin,we&&`border-destructive focus-within:border-b-destructive`,C&&`cursor-not-allowed opacity-50 has-focus-visible:opacity-100`,re),hidden:xe,...Se,onMouseDown:e=>a.composeEventHandlers(be,De)(e),children:[(0,v.jsx)(`span`,{className:`flex shrink-0 items-center ps-2`,children:Fe?i.renderSlot(w,`span`,`shrink-0`):(0,v.jsx)(d.SearchIcon,{className:`text-muted-foreground`})}),(0,v.jsx)(`input`,{ref:Ce,type:`search`,value:V,onChange:e=>H(e.target.value),placeholder:S,disabled:C,className:t.cn(`h-full min-w-0 flex-1 appearance-none border-none bg-transparent px-2 text-body-1 text-foreground`,`placeholder:text-muted-foreground`,`focus:outline-hidden`,`disabled:cursor-not-allowed`,`[&::-webkit-search-cancel-button]:hidden`),"aria-errormessage":fe,"aria-details":pe,name:k,form:A,readOnly:j,autoComplete:M,autoFocus:N,autoCapitalize:P,autoCorrect:F,inputMode:I,enterKeyHint:L,spellCheck:R,maxLength:z,minLength:B,pattern:me,tabIndex:he,onFocus:ge,onBlur:_e,onKeyDown:a.composeEventHandlers(ve,Ee),onKeyUp:ye,...W}),Ie&&(0,v.jsx)(`span`,{className:`flex shrink-0 items-center pe-2`,children:i.renderSlot(E,`span`,`shrink-0`)}),V&&!j?(0,v.jsx)(`button`,{...$,ref:Ne,type:$.type??`button`,disabled:C||$.disabled,onClick:e=>a.composeEventHandlers(Oe,Te)(e),...G.disabledFocusable?p.MERGED_DISABLED_FOCUSABLE_PROPS:void 0,children:Pe}):null]})};E.displayName=`SearchBox`,exports.SearchBox=E;
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/slot.cjs"),a=require("../../lib/composeEventHandlers.cjs"),o=require("../../lib/classNames.cjs"),s=require("../../hooks/useControllable.cjs"),c=require("../../hooks/useMergedRefs.cjs"),l=require("../../hooks/useFieldControl.cjs"),u=require("../../lib/styles.cjs"),d=require("../button/Button.cjs"),f=require("../button/Button.slots.cjs"),p=require("../../lib/icons.cjs"),m=require("../../lib/mergeProps.cjs"),h=require("./inputLook.cjs"),g=require("./Input.cjs"),_=require("../../hooks/useFormReset.cjs"),v=require("../../lib/labelInName.cjs");let y=require("react");y=e.__toESM(y,1);let b=require("react/jsx-runtime");var x={small:{before:`ps-1.5`,after:`pe-1.5`,input:`px-1.5`,clear:`size-5`,glyph:12},medium:{before:`ps-2`,after:`pe-2`,input:`px-2`,clear:`h-6 w-6`,glyph:16},large:{before:`ps-3`,after:`pe-3`,input:`px-3`,clear:`size-8`,glyph:20}},S=new Set([`type`,`disabled`,`form`,`formAction`,`formEncType`,`formMethod`,`formNoValidate`,`formTarget`,`name`,`value`,`popoverTarget`,`popoverTargetAction`]),C=/^on[A-Z]/,w=new Set([`aria-label`,`aria-labelledby`,`title`]),T=`Clear search`,E=()=>{},ee=`a[href], button, input, select, textarea, [tabindex], [contenteditable]:not([contenteditable="false"])`,D={kind:`default`,buttonProps:{},content:null,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!1};function O(e){return e===`button`||e===d.Button}function k(e,n,r){let a=i.slotRendersContent(r),s=i.materialiseSlotContent(r),c=v.hasTextLabel(s);if(e===d.Button){let e={};for(let[t,r]of Object.entries(n))t!==`children`&&!f.BUTTON_OWN_PROP_KEYS.has(t)&&(e[t]=r);let r=i.renderSlot(n.icon,`span`,t.cn(o.searchBoxClassNames.dismissIcon,`inline-flex`),{"aria-hidden":!0});return{buttonProps:e,content:r||a?f.placeButtonIcon(r,s,n.iconPosition):null,contentMayName:!0,literalTextLabel:c,disabledFocusable:!!n.disabledFocusable}}let{as:l,children:u,...p}=n;return{buttonProps:p,content:a?s:null,contentMayName:!0,literalTextLabel:c,disabledFocusable:!1}}function te(e,r){let a=e;if(n.isElementOfType(a,`button`,d.Button)){let e=a.props.children;return{kind:`element`,...k(n.getElementType(a),a.props,e)}}let s=i.resolveSlot(e,`span`);if(!s)return D;let{Component:c,props:l,children:u}=s;if(O(c))return{kind:`button-object`,...k(c,l,u)};let f={},m={},h=!1;for(let[e,t]of Object.entries(l))t!==void 0&&(S.has(e)||C.test(e)?(f[e]=t,h=!0):w.has(e)?f[e]=t:m[e]=t);let g=i.slotRendersContent(u),_=i.slotWrapsDefaultContent(c,{...m,children:u});if(_&&Object.keys(f).length===0&&Object.keys(m).length===0)return D;let v=_?(0,b.jsx)(p.DismissIcon,{size:x[r].glyph}):g?u:void 0,T={"aria-hidden":!0,...m,className:t.cn(o.searchBoxClassNames.dismissIcon,m.className)},E=v===void 0?y.createElement(c,T):y.createElement(c,T,v);return{kind:h?`button-object`:`content`,buttonProps:f,content:E,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!1}}var A=({value:e,defaultValue:n=``,onValueChange:d,onChange:S,onClear:C,placeholder:D=`Search`,disabled:O,size:k,appearance:A,contentBefore:j,contentAfter:M,dismiss:ne,className:re,ref:ie,controlRef:ae,id:oe,"aria-label":se,"aria-labelledby":ce,"aria-describedby":le,"aria-invalid":ue,"aria-required":de,"aria-errormessage":fe,"aria-details":pe,required:me,name:he,form:N,readOnly:P,autoComplete:F,autoFocus:I,autoCapitalize:L,autoCorrect:R,inputMode:ge,enterKeyHint:_e,spellCheck:ve,maxLength:ye,minLength:be,pattern:xe,tabIndex:Se,onFocus:Ce,onBlur:z,onKeyDown:we,onKeyUp:Te,onMouseDown:Ee,hidden:De,...Oe})=>{S!==void 0&&r.warnDeprecated(`SearchBox`,`onChange`,`onValueChange`);let[B,V]=s.useControllable(e,n,e=>{d?.(e),S?.(e)}),H=y.useRef(null),ke=c.useMergedRefs(H,ae);_.useFormReset(H,()=>V(n),N);let U=l.useFieldControl({id:oe,"aria-label":se,"aria-labelledby":ce,"aria-describedby":le,"aria-invalid":ue,"aria-required":de,required:me},{nativeRequired:!0}),Ae=g.isInvalidLook(!1,U[`aria-invalid`]),{size:W,appearance:G}=h.useInputLook(k,A),K=te(ne,W),q=K.kind;y.useEffect(()=>{q===`element`?r.warnOnce(`SearchBox:dismiss-button-element`,"SearchBox: `dismiss` received a button element; its props were merged into the built-in clear button (buttons cannot be nested). Pass icon content instead, e.g. `dismiss={<MyIcon />}`."):q===`button-object`&&r.warnOnce(`SearchBox:dismiss-button-object`,'SearchBox: `dismiss` with button props (`as: "button"`, `onClick`, `type`, …) is deprecated and will be removed in 1.0; the props were merged into the built-in clear button. Pass icon content instead, e.g. `dismiss={<MyIcon />}`.')},[q]);let je=()=>{V(``),C?.(),H.current?.focus()},Me=e=>{e.key!==`Escape`||e.nativeEvent.isComposing||!B||P||O||(e.preventDefault(),V(``),C?.())},Ne=e=>{let t=H.current,n=e.currentTarget,r=e.target;if(!t||O||e.button!==0||r===t||!(r instanceof Element)||!n.contains(r))return;let i=r.closest(ee);i&&n.contains(i)||(e.preventDefault(),t.focus())},{onClick:Pe,ref:Fe,...J}=K.buttonProps,Y=Object.keys(J).some(e=>w.has(e)&&J[e]!=null),X=K.contentMayName&&!Y,Z=K.literalTextLabel,[Q,Ie]=y.useState(null),Le=y.useCallback(e=>Q?v.observeTextLabel(Q,e):E,[Q]),Re=y.useSyncExternalStore(Le,()=>Q?v.hasRenderedTextLabel(Q):Z,()=>Z),ze=X&&Re,Be=c.useMergedRefs(Fe,X?Ie:void 0),$=m.mergeProps({type:`button`,disabled:O,"aria-label":Y||ze?void 0:T,className:t.cn(o.searchBoxClassNames.dismissButton,`me-1 flex shrink-0 items-center justify-center rounded bg-transparent p-0 text-muted-foreground`,x[W].clear,W===`small`&&t.cn(`relative`,`before:absolute before:-inset-0.5`),`not-disabled:not-aria-disabled:hover:text-foreground`,u.focusRing,`disabled:cursor-not-allowed`,f.mergedAriaDisabledClasses)},J),Ve=$.dangerouslySetInnerHTML==null?q===`content`?K.content:K.content??(0,b.jsx)(p.DismissIcon,{size:x[W].glyph,className:o.searchBoxClassNames.dismissIcon}):void 0,He=i.slotRendersContent(j),Ue=i.slotRendersContent(M);return(0,b.jsxs)(`div`,{ref:ie,"data-size":W,"data-appearance":G,className:t.cn(o.searchBoxClassNames.root,`relative inline-flex w-full items-center`,u.inputHeightClasses[W],u.inputTextClasses[W],u.inputAppearanceClasses[G],`text-foreground`,u.inputFocusWithin,Ae&&`border-destructive`,O&&`cursor-not-allowed opacity-50 has-focus-visible:opacity-100`,re),hidden:De,...Oe,onMouseDown:e=>a.composeEventHandlers(Ee,Ne)(e),children:[(0,b.jsx)(`span`,{className:t.cn(o.searchBoxClassNames.contentBefore,`flex shrink-0 items-center`,x[W].before),children:He?i.renderSlot(j,`span`,`shrink-0`):(0,b.jsx)(p.SearchIcon,{size:x[W].glyph,className:`text-muted-foreground`})}),(0,b.jsx)(`input`,{ref:ke,type:`search`,value:B,onChange:e=>V(e.target.value),placeholder:D,disabled:O,className:t.cn(o.searchBoxClassNames.input,`h-full min-w-0 flex-1 appearance-none border-none bg-transparent text-foreground`,x[W].input,u.inputTextClasses[W],`placeholder:text-muted-foreground`,`focus:outline-hidden`,`disabled:cursor-not-allowed`,`[&::-webkit-search-cancel-button]:hidden`),"aria-errormessage":fe,"aria-details":pe,name:he,form:N,readOnly:P,autoComplete:F,autoFocus:I,autoCapitalize:L,autoCorrect:R,inputMode:ge,enterKeyHint:_e,spellCheck:ve,maxLength:ye,minLength:be,pattern:xe,tabIndex:Se,onFocus:Ce,onBlur:z,onKeyDown:a.composeEventHandlers(we,Me),onKeyUp:Te,...U}),Ue&&(0,b.jsx)(`span`,{className:t.cn(o.searchBoxClassNames.contentAfter,`flex shrink-0 items-center`,x[W].after),children:i.renderSlot(M,`span`,`shrink-0`)}),B&&!P?(0,b.jsx)(`button`,{...$,ref:Be,type:$.type??`button`,disabled:O||$.disabled,onClick:e=>a.composeEventHandlers(Pe,je)(e),...K.disabledFocusable?f.MERGED_DISABLED_FOCUSABLE_PROPS:void 0,children:Ve}):null]})};A.displayName=`SearchBox`,exports.SearchBox=A;
2
2
  //# sourceMappingURL=SearchBox.cjs.map