@mortenbrudvik/waveui 0.4.0 → 0.7.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 (574) hide show
  1. package/README.md +1221 -173
  2. package/dist/_virtual/_rolldown/runtime.cjs +1 -0
  3. package/dist/components/button/Button.cjs +2 -0
  4. package/dist/components/button/Button.cjs.map +1 -0
  5. package/dist/components/button/Button.mjs +50 -0
  6. package/dist/components/button/Button.mjs.map +1 -0
  7. package/dist/components/button/Button.semantics.cjs +2 -0
  8. package/dist/components/button/Button.semantics.cjs.map +1 -0
  9. package/dist/components/button/Button.semantics.mjs +61 -0
  10. package/dist/components/button/Button.semantics.mjs.map +1 -0
  11. package/dist/components/button/Button.slots.cjs +2 -0
  12. package/dist/components/button/Button.slots.cjs.map +1 -0
  13. package/dist/components/button/Button.slots.mjs +47 -0
  14. package/dist/components/button/Button.slots.mjs.map +1 -0
  15. package/dist/components/button/CompoundButton.cjs +2 -0
  16. package/dist/components/button/CompoundButton.cjs.map +1 -0
  17. package/dist/components/button/CompoundButton.mjs +53 -0
  18. package/dist/components/button/CompoundButton.mjs.map +1 -0
  19. package/dist/components/button/Link.cjs +2 -0
  20. package/dist/components/button/Link.cjs.map +1 -0
  21. package/dist/components/button/Link.mjs +37 -0
  22. package/dist/components/button/Link.mjs.map +1 -0
  23. package/dist/components/button/MenuButton.cjs +2 -0
  24. package/dist/components/button/MenuButton.cjs.map +1 -0
  25. package/dist/components/button/MenuButton.mjs +45 -0
  26. package/dist/components/button/MenuButton.mjs.map +1 -0
  27. package/dist/components/button/SplitButton.cjs +2 -0
  28. package/dist/components/button/SplitButton.cjs.map +1 -0
  29. package/dist/components/button/SplitButton.mjs +66 -0
  30. package/dist/components/button/SplitButton.mjs.map +1 -0
  31. package/dist/components/button/ToggleButton.cjs +2 -0
  32. package/dist/components/button/ToggleButton.cjs.map +1 -0
  33. package/dist/components/button/ToggleButton.mjs +65 -0
  34. package/dist/components/button/ToggleButton.mjs.map +1 -0
  35. package/dist/components/button/Toolbar.cjs +2 -0
  36. package/dist/components/button/Toolbar.cjs.map +1 -0
  37. package/dist/components/button/Toolbar.context.cjs +2 -0
  38. package/dist/components/button/Toolbar.context.cjs.map +1 -0
  39. package/dist/components/button/Toolbar.context.mjs +31 -0
  40. package/dist/components/button/Toolbar.context.mjs.map +1 -0
  41. package/dist/components/button/Toolbar.mjs +63 -0
  42. package/dist/components/button/Toolbar.mjs.map +1 -0
  43. package/dist/components/button/Toolbar.parts.cjs +2 -0
  44. package/dist/components/button/Toolbar.parts.cjs.map +1 -0
  45. package/dist/components/button/Toolbar.parts.mjs +131 -0
  46. package/dist/components/button/Toolbar.parts.mjs.map +1 -0
  47. package/dist/components/button/buttonStyles.cjs +2 -0
  48. package/dist/components/button/buttonStyles.cjs.map +1 -0
  49. package/dist/components/button/buttonStyles.mjs +39 -0
  50. package/dist/components/button/buttonStyles.mjs.map +1 -0
  51. package/dist/components/data-display/Avatar.cjs +2 -0
  52. package/dist/components/data-display/Avatar.cjs.map +1 -0
  53. package/dist/components/data-display/Avatar.mjs +157 -0
  54. package/dist/components/data-display/Avatar.mjs.map +1 -0
  55. package/dist/components/data-display/AvatarGroup.cjs +2 -0
  56. package/dist/components/data-display/AvatarGroup.cjs.map +1 -0
  57. package/dist/components/data-display/AvatarGroup.mjs +134 -0
  58. package/dist/components/data-display/AvatarGroup.mjs.map +1 -0
  59. package/dist/components/data-display/Badge.cjs +2 -0
  60. package/dist/components/data-display/Badge.cjs.map +1 -0
  61. package/dist/components/data-display/Badge.colors.cjs +2 -0
  62. package/dist/components/data-display/Badge.colors.cjs.map +1 -0
  63. package/dist/components/data-display/Badge.colors.mjs +58 -0
  64. package/dist/components/data-display/Badge.colors.mjs.map +1 -0
  65. package/dist/components/data-display/Badge.mjs +32 -0
  66. package/dist/components/data-display/Badge.mjs.map +1 -0
  67. package/dist/components/data-display/CounterBadge.cjs +2 -0
  68. package/dist/components/data-display/CounterBadge.cjs.map +1 -0
  69. package/dist/components/data-display/CounterBadge.mjs +28 -0
  70. package/dist/components/data-display/CounterBadge.mjs.map +1 -0
  71. package/dist/components/data-display/Divider.cjs +2 -0
  72. package/dist/components/data-display/Divider.cjs.map +1 -0
  73. package/dist/components/data-display/Divider.mjs +52 -0
  74. package/dist/components/data-display/Divider.mjs.map +1 -0
  75. package/dist/components/data-display/Image.cjs +2 -0
  76. package/dist/components/data-display/Image.cjs.map +1 -0
  77. package/dist/components/data-display/Image.mjs +32 -0
  78. package/dist/components/data-display/Image.mjs.map +1 -0
  79. package/dist/components/data-display/InfoLabel.cjs +2 -0
  80. package/dist/components/data-display/InfoLabel.cjs.map +1 -0
  81. package/dist/components/data-display/InfoLabel.mjs +104 -0
  82. package/dist/components/data-display/InfoLabel.mjs.map +1 -0
  83. package/dist/components/data-display/List.cjs +2 -0
  84. package/dist/components/data-display/List.cjs.map +1 -0
  85. package/dist/components/data-display/List.mjs +381 -0
  86. package/dist/components/data-display/List.mjs.map +1 -0
  87. package/dist/components/data-display/List.registry.cjs +2 -0
  88. package/dist/components/data-display/List.registry.cjs.map +1 -0
  89. package/dist/components/data-display/List.registry.mjs +101 -0
  90. package/dist/components/data-display/List.registry.mjs.map +1 -0
  91. package/dist/components/data-display/Persona.cjs +2 -0
  92. package/dist/components/data-display/Persona.cjs.map +1 -0
  93. package/dist/components/data-display/Persona.mjs +48 -0
  94. package/dist/components/data-display/Persona.mjs.map +1 -0
  95. package/dist/components/data-display/PresenceBadge.cjs +2 -0
  96. package/dist/components/data-display/PresenceBadge.cjs.map +1 -0
  97. package/dist/components/data-display/PresenceBadge.mjs +71 -0
  98. package/dist/components/data-display/PresenceBadge.mjs.map +1 -0
  99. package/dist/components/data-display/Tag.cjs +2 -0
  100. package/dist/components/data-display/Tag.cjs.map +1 -0
  101. package/dist/components/data-display/Tag.mjs +147 -0
  102. package/dist/components/data-display/Tag.mjs.map +1 -0
  103. package/dist/components/feedback/MessageBar.cjs +2 -0
  104. package/dist/components/feedback/MessageBar.cjs.map +1 -0
  105. package/dist/components/feedback/MessageBar.mjs +144 -0
  106. package/dist/components/feedback/MessageBar.mjs.map +1 -0
  107. package/dist/components/feedback/MessageBar.status.cjs +2 -0
  108. package/dist/components/feedback/MessageBar.status.cjs.map +1 -0
  109. package/dist/components/feedback/MessageBar.status.mjs +45 -0
  110. package/dist/components/feedback/MessageBar.status.mjs.map +1 -0
  111. package/dist/components/feedback/ProgressBar.cjs +2 -0
  112. package/dist/components/feedback/ProgressBar.cjs.map +1 -0
  113. package/dist/components/feedback/ProgressBar.mjs +72 -0
  114. package/dist/components/feedback/ProgressBar.mjs.map +1 -0
  115. package/dist/components/feedback/Skeleton.cjs +2 -0
  116. package/dist/components/feedback/Skeleton.cjs.map +1 -0
  117. package/dist/components/feedback/Skeleton.mjs +47 -0
  118. package/dist/components/feedback/Skeleton.mjs.map +1 -0
  119. package/dist/components/feedback/Spinner.cjs +2 -0
  120. package/dist/components/feedback/Spinner.cjs.map +1 -0
  121. package/dist/components/feedback/Spinner.mjs +60 -0
  122. package/dist/components/feedback/Spinner.mjs.map +1 -0
  123. package/dist/components/feedback/Toast.cjs +2 -0
  124. package/dist/components/feedback/Toast.cjs.map +1 -0
  125. package/dist/components/feedback/Toast.mjs +347 -0
  126. package/dist/components/feedback/Toast.mjs.map +1 -0
  127. package/dist/components/input/Checkbox.cjs +2 -0
  128. package/dist/components/input/Checkbox.cjs.map +1 -0
  129. package/dist/components/input/Checkbox.mjs +96 -0
  130. package/dist/components/input/Checkbox.mjs.map +1 -0
  131. package/dist/components/input/ColorPicker.cjs +6 -0
  132. package/dist/components/input/ColorPicker.cjs.map +1 -0
  133. package/dist/components/input/ColorPicker.mjs +236 -0
  134. package/dist/components/input/ColorPicker.mjs.map +1 -0
  135. package/dist/components/input/Combobox.cjs +2 -0
  136. package/dist/components/input/Combobox.cjs.map +1 -0
  137. package/dist/components/input/Combobox.expand.cjs +2 -0
  138. package/dist/components/input/Combobox.expand.cjs.map +1 -0
  139. package/dist/components/input/Combobox.expand.mjs +38 -0
  140. package/dist/components/input/Combobox.expand.mjs.map +1 -0
  141. package/dist/components/input/Combobox.mjs +187 -0
  142. package/dist/components/input/Combobox.mjs.map +1 -0
  143. package/dist/components/input/DatePicker.cjs +2 -0
  144. package/dist/components/input/DatePicker.cjs.map +1 -0
  145. package/dist/components/input/DatePicker.mjs +340 -0
  146. package/dist/components/input/DatePicker.mjs.map +1 -0
  147. package/dist/components/input/Dropdown.cjs +2 -0
  148. package/dist/components/input/Dropdown.cjs.map +1 -0
  149. package/dist/components/input/Dropdown.mjs +128 -0
  150. package/dist/components/input/Dropdown.mjs.map +1 -0
  151. package/dist/components/input/Field.cjs +2 -0
  152. package/dist/components/input/Field.cjs.map +1 -0
  153. package/dist/components/input/Field.mjs +200 -0
  154. package/dist/components/input/Field.mjs.map +1 -0
  155. package/dist/components/input/Input.cjs +2 -0
  156. package/dist/components/input/Input.cjs.map +1 -0
  157. package/dist/components/input/Input.mjs +81 -0
  158. package/dist/components/input/Input.mjs.map +1 -0
  159. package/dist/components/input/Label.cjs +2 -0
  160. package/dist/components/input/Label.cjs.map +1 -0
  161. package/dist/components/input/Label.mjs +28 -0
  162. package/dist/components/input/Label.mjs.map +1 -0
  163. package/dist/components/input/Option.cjs +2 -0
  164. package/dist/components/input/Option.cjs.map +1 -0
  165. package/dist/components/input/Option.mjs +169 -0
  166. package/dist/components/input/Option.mjs.map +1 -0
  167. package/dist/components/input/RadioGroup.cjs +2 -0
  168. package/dist/components/input/RadioGroup.cjs.map +1 -0
  169. package/dist/components/input/RadioGroup.mjs +139 -0
  170. package/dist/components/input/RadioGroup.mjs.map +1 -0
  171. package/dist/components/input/Rating.cjs +2 -0
  172. package/dist/components/input/Rating.cjs.map +1 -0
  173. package/dist/components/input/Rating.mjs +196 -0
  174. package/dist/components/input/Rating.mjs.map +1 -0
  175. package/dist/components/input/SearchBox.cjs +2 -0
  176. package/dist/components/input/SearchBox.cjs.map +1 -0
  177. package/dist/components/input/SearchBox.mjs +205 -0
  178. package/dist/components/input/SearchBox.mjs.map +1 -0
  179. package/dist/components/input/Select.cjs +2 -0
  180. package/dist/components/input/Select.cjs.map +1 -0
  181. package/dist/components/input/Select.mjs +33 -0
  182. package/dist/components/input/Select.mjs.map +1 -0
  183. package/dist/components/input/Slider.cjs +2 -0
  184. package/dist/components/input/Slider.cjs.map +1 -0
  185. package/dist/components/input/Slider.mjs +79 -0
  186. package/dist/components/input/Slider.mjs.map +1 -0
  187. package/dist/components/input/SpinButton.cjs +2 -0
  188. package/dist/components/input/SpinButton.cjs.map +1 -0
  189. package/dist/components/input/SpinButton.mjs +157 -0
  190. package/dist/components/input/SpinButton.mjs.map +1 -0
  191. package/dist/components/input/SwatchPicker.cjs +2 -0
  192. package/dist/components/input/SwatchPicker.cjs.map +1 -0
  193. package/dist/components/input/SwatchPicker.mjs +113 -0
  194. package/dist/components/input/SwatchPicker.mjs.map +1 -0
  195. package/dist/components/input/Switch.cjs +2 -0
  196. package/dist/components/input/Switch.cjs.map +1 -0
  197. package/dist/components/input/Switch.mjs +92 -0
  198. package/dist/components/input/Switch.mjs.map +1 -0
  199. package/dist/components/input/TagPicker.cjs +2 -0
  200. package/dist/components/input/TagPicker.cjs.map +1 -0
  201. package/dist/components/input/TagPicker.mjs +249 -0
  202. package/dist/components/input/TagPicker.mjs.map +1 -0
  203. package/dist/components/input/Textarea.cjs +2 -0
  204. package/dist/components/input/Textarea.cjs.map +1 -0
  205. package/dist/components/input/Textarea.mjs +32 -0
  206. package/dist/components/input/Textarea.mjs.map +1 -0
  207. package/dist/components/input/TimePicker.cjs +2 -0
  208. package/dist/components/input/TimePicker.cjs.map +1 -0
  209. package/dist/components/input/TimePicker.mjs +292 -0
  210. package/dist/components/input/TimePicker.mjs.map +1 -0
  211. package/dist/components/input/colorUtils.cjs +2 -0
  212. package/dist/components/input/colorUtils.cjs.map +1 -0
  213. package/dist/components/input/colorUtils.mjs +96 -0
  214. package/dist/components/input/colorUtils.mjs.map +1 -0
  215. package/dist/components/input/dateUtils.cjs +2 -0
  216. package/dist/components/input/dateUtils.cjs.map +1 -0
  217. package/dist/components/input/dateUtils.mjs +250 -0
  218. package/dist/components/input/dateUtils.mjs.map +1 -0
  219. package/dist/components/input/pickerStyles.cjs +2 -0
  220. package/dist/components/input/pickerStyles.cjs.map +1 -0
  221. package/dist/components/input/pickerStyles.mjs +10 -0
  222. package/dist/components/input/pickerStyles.mjs.map +1 -0
  223. package/dist/components/internal/HiddenInput.cjs +2 -0
  224. package/dist/components/internal/HiddenInput.cjs.map +1 -0
  225. package/dist/components/internal/HiddenInput.mjs +88 -0
  226. package/dist/components/internal/HiddenInput.mjs.map +1 -0
  227. package/dist/components/layout/Accordion.cjs +2 -0
  228. package/dist/components/layout/Accordion.cjs.map +1 -0
  229. package/dist/components/layout/Accordion.mjs +236 -0
  230. package/dist/components/layout/Accordion.mjs.map +1 -0
  231. package/dist/components/layout/Card.cjs +2 -0
  232. package/dist/components/layout/Card.cjs.map +1 -0
  233. package/dist/components/layout/Card.mjs +121 -0
  234. package/dist/components/layout/Card.mjs.map +1 -0
  235. package/dist/components/layout/Carousel.cjs +2 -0
  236. package/dist/components/layout/Carousel.cjs.map +1 -0
  237. package/dist/components/layout/Carousel.mjs +205 -0
  238. package/dist/components/layout/Carousel.mjs.map +1 -0
  239. package/dist/components/layout/Flex.cjs +2 -0
  240. package/dist/components/layout/Flex.cjs.map +1 -0
  241. package/dist/components/layout/Flex.mjs +54 -0
  242. package/dist/components/layout/Flex.mjs.map +1 -0
  243. package/dist/components/layout/Grid.cjs +2 -0
  244. package/dist/components/layout/Grid.cjs.map +1 -0
  245. package/dist/components/layout/Grid.mjs +62 -0
  246. package/dist/components/layout/Grid.mjs.map +1 -0
  247. package/dist/components/layout/Overflow.cjs +2 -0
  248. package/dist/components/layout/Overflow.cjs.map +1 -0
  249. package/dist/components/layout/Overflow.mjs +269 -0
  250. package/dist/components/layout/Overflow.mjs.map +1 -0
  251. package/dist/components/layout/Stack.cjs +2 -0
  252. package/dist/components/layout/Stack.cjs.map +1 -0
  253. package/dist/components/layout/Stack.mjs +39 -0
  254. package/dist/components/layout/Stack.mjs.map +1 -0
  255. package/dist/components/layout/TabList.cjs +2 -0
  256. package/dist/components/layout/TabList.cjs.map +1 -0
  257. package/dist/components/layout/TabList.mjs +238 -0
  258. package/dist/components/layout/TabList.mjs.map +1 -0
  259. package/dist/components/layout/Tree.cjs +2 -0
  260. package/dist/components/layout/Tree.cjs.map +1 -0
  261. package/dist/components/layout/Tree.mjs +220 -0
  262. package/dist/components/layout/Tree.mjs.map +1 -0
  263. package/dist/components/layout/disclosureIds.cjs +2 -0
  264. package/dist/components/layout/disclosureIds.cjs.map +1 -0
  265. package/dist/components/layout/disclosureIds.mjs +12 -0
  266. package/dist/components/layout/disclosureIds.mjs.map +1 -0
  267. package/dist/components/motion/Presence.cjs +2 -0
  268. package/dist/components/motion/Presence.cjs.map +1 -0
  269. package/dist/components/motion/Presence.mjs +35 -0
  270. package/dist/components/motion/Presence.mjs.map +1 -0
  271. package/dist/components/navigation/Breadcrumb.cjs +2 -0
  272. package/dist/components/navigation/Breadcrumb.cjs.map +1 -0
  273. package/dist/components/navigation/Breadcrumb.mjs +144 -0
  274. package/dist/components/navigation/Breadcrumb.mjs.map +1 -0
  275. package/dist/components/navigation/Menu.cjs +2 -0
  276. package/dist/components/navigation/Menu.cjs.map +1 -0
  277. package/dist/components/navigation/Menu.context.cjs +2 -0
  278. package/dist/components/navigation/Menu.context.cjs.map +1 -0
  279. package/dist/components/navigation/Menu.context.mjs +82 -0
  280. package/dist/components/navigation/Menu.context.mjs.map +1 -0
  281. package/dist/components/navigation/Menu.group.cjs +2 -0
  282. package/dist/components/navigation/Menu.group.cjs.map +1 -0
  283. package/dist/components/navigation/Menu.group.mjs +58 -0
  284. package/dist/components/navigation/Menu.group.mjs.map +1 -0
  285. package/dist/components/navigation/Menu.items.cjs +2 -0
  286. package/dist/components/navigation/Menu.items.cjs.map +1 -0
  287. package/dist/components/navigation/Menu.items.mjs +127 -0
  288. package/dist/components/navigation/Menu.items.mjs.map +1 -0
  289. package/dist/components/navigation/Menu.link.cjs +2 -0
  290. package/dist/components/navigation/Menu.link.cjs.map +1 -0
  291. package/dist/components/navigation/Menu.link.mjs +41 -0
  292. package/dist/components/navigation/Menu.link.mjs.map +1 -0
  293. package/dist/components/navigation/Menu.mjs +27 -0
  294. package/dist/components/navigation/Menu.mjs.map +1 -0
  295. package/dist/components/navigation/Menu.popover.cjs +2 -0
  296. package/dist/components/navigation/Menu.popover.cjs.map +1 -0
  297. package/dist/components/navigation/Menu.popover.mjs +231 -0
  298. package/dist/components/navigation/Menu.popover.mjs.map +1 -0
  299. package/dist/components/navigation/Menu.root.cjs +2 -0
  300. package/dist/components/navigation/Menu.root.cjs.map +1 -0
  301. package/dist/components/navigation/Menu.root.mjs +308 -0
  302. package/dist/components/navigation/Menu.root.mjs.map +1 -0
  303. package/dist/components/navigation/Menu.selectable.cjs +2 -0
  304. package/dist/components/navigation/Menu.selectable.cjs.map +1 -0
  305. package/dist/components/navigation/Menu.selectable.mjs +89 -0
  306. package/dist/components/navigation/Menu.selectable.mjs.map +1 -0
  307. package/dist/components/navigation/Menu.shared.cjs +2 -0
  308. package/dist/components/navigation/Menu.shared.cjs.map +1 -0
  309. package/dist/components/navigation/Menu.shared.mjs +23 -0
  310. package/dist/components/navigation/Menu.shared.mjs.map +1 -0
  311. package/dist/components/navigation/Menu.splitGroup.cjs +2 -0
  312. package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -0
  313. package/dist/components/navigation/Menu.splitGroup.mjs +51 -0
  314. package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -0
  315. package/dist/components/navigation/Menu.trigger.cjs +2 -0
  316. package/dist/components/navigation/Menu.trigger.cjs.map +1 -0
  317. package/dist/components/navigation/Menu.trigger.mjs +79 -0
  318. package/dist/components/navigation/Menu.trigger.mjs.map +1 -0
  319. package/dist/components/navigation/Nav.cjs +2 -0
  320. package/dist/components/navigation/Nav.cjs.map +1 -0
  321. package/dist/components/navigation/Nav.mjs +276 -0
  322. package/dist/components/navigation/Nav.mjs.map +1 -0
  323. package/dist/components/navigation/Pagination.cjs +2 -0
  324. package/dist/components/navigation/Pagination.cjs.map +1 -0
  325. package/dist/components/navigation/Pagination.mjs +110 -0
  326. package/dist/components/navigation/Pagination.mjs.map +1 -0
  327. package/dist/components/navigation/Stepper.cjs +2 -0
  328. package/dist/components/navigation/Stepper.cjs.map +1 -0
  329. package/dist/components/navigation/Stepper.mjs +204 -0
  330. package/dist/components/navigation/Stepper.mjs.map +1 -0
  331. package/dist/components/overlays/Dialog.cjs +2 -0
  332. package/dist/components/overlays/Dialog.cjs.map +1 -0
  333. package/dist/components/overlays/Dialog.mjs +180 -0
  334. package/dist/components/overlays/Dialog.mjs.map +1 -0
  335. package/dist/components/overlays/Dialog.shared.cjs +2 -0
  336. package/dist/components/overlays/Dialog.shared.cjs.map +1 -0
  337. package/dist/components/overlays/Dialog.shared.mjs +227 -0
  338. package/dist/components/overlays/Dialog.shared.mjs.map +1 -0
  339. package/dist/components/overlays/Drawer.cjs +2 -0
  340. package/dist/components/overlays/Drawer.cjs.map +1 -0
  341. package/dist/components/overlays/Drawer.mjs +192 -0
  342. package/dist/components/overlays/Drawer.mjs.map +1 -0
  343. package/dist/components/overlays/Popover.cjs +2 -0
  344. package/dist/components/overlays/Popover.cjs.map +1 -0
  345. package/dist/components/overlays/Popover.mjs +365 -0
  346. package/dist/components/overlays/Popover.mjs.map +1 -0
  347. package/dist/components/overlays/Popover.shared.cjs +2 -0
  348. package/dist/components/overlays/Popover.shared.cjs.map +1 -0
  349. package/dist/components/overlays/Popover.shared.mjs +182 -0
  350. package/dist/components/overlays/Popover.shared.mjs.map +1 -0
  351. package/dist/components/overlays/TeachingPopover.cjs +2 -0
  352. package/dist/components/overlays/TeachingPopover.cjs.map +1 -0
  353. package/dist/components/overlays/TeachingPopover.mjs +181 -0
  354. package/dist/components/overlays/TeachingPopover.mjs.map +1 -0
  355. package/dist/components/overlays/Tooltip.cjs +2 -0
  356. package/dist/components/overlays/Tooltip.cjs.map +1 -0
  357. package/dist/components/overlays/Tooltip.mjs +160 -0
  358. package/dist/components/overlays/Tooltip.mjs.map +1 -0
  359. package/dist/components/portal/Portal.cjs +2 -0
  360. package/dist/components/portal/Portal.cjs.map +1 -0
  361. package/dist/components/portal/Portal.mjs +45 -0
  362. package/dist/components/portal/Portal.mjs.map +1 -0
  363. package/dist/components/provider/WaveProvider.cjs +2 -0
  364. package/dist/components/provider/WaveProvider.cjs.map +1 -0
  365. package/dist/components/provider/WaveProvider.mjs +51 -0
  366. package/dist/components/provider/WaveProvider.mjs.map +1 -0
  367. package/dist/components/table/DataGrid.cjs +2 -0
  368. package/dist/components/table/DataGrid.cjs.map +1 -0
  369. package/dist/components/table/DataGrid.mjs +489 -0
  370. package/dist/components/table/DataGrid.mjs.map +1 -0
  371. package/dist/components/table/Table.cjs +2 -0
  372. package/dist/components/table/Table.cjs.map +1 -0
  373. package/dist/components/table/Table.mjs +99 -0
  374. package/dist/components/table/Table.mjs.map +1 -0
  375. package/dist/components/table/useGridNavigation.cjs +2 -0
  376. package/dist/components/table/useGridNavigation.cjs.map +1 -0
  377. package/dist/components/table/useGridNavigation.mjs +336 -0
  378. package/dist/components/table/useGridNavigation.mjs.map +1 -0
  379. package/dist/components/typography/Text.cjs +2 -0
  380. package/dist/components/typography/Text.cjs.map +1 -0
  381. package/dist/components/typography/Text.mjs +38 -0
  382. package/dist/components/typography/Text.mjs.map +1 -0
  383. package/dist/hooks/useAnnounce.cjs +2 -0
  384. package/dist/hooks/useAnnounce.cjs.map +1 -0
  385. package/dist/hooks/useAnnounce.mjs +88 -0
  386. package/dist/hooks/useAnnounce.mjs.map +1 -0
  387. package/dist/hooks/useCheckedValues.cjs +2 -0
  388. package/dist/hooks/useCheckedValues.cjs.map +1 -0
  389. package/dist/hooks/useCheckedValues.mjs +102 -0
  390. package/dist/hooks/useCheckedValues.mjs.map +1 -0
  391. package/dist/hooks/useContextMenuAnchor.cjs +2 -0
  392. package/dist/hooks/useContextMenuAnchor.cjs.map +1 -0
  393. package/dist/hooks/useContextMenuAnchor.mjs +132 -0
  394. package/dist/hooks/useContextMenuAnchor.mjs.map +1 -0
  395. package/dist/hooks/useControllable.cjs +2 -0
  396. package/dist/hooks/useControllable.cjs.map +1 -0
  397. package/dist/hooks/useControllable.mjs +37 -0
  398. package/dist/hooks/useControllable.mjs.map +1 -0
  399. package/dist/hooks/useDirection.cjs +2 -0
  400. package/dist/hooks/useDirection.cjs.map +1 -0
  401. package/dist/hooks/useDirection.mjs +57 -0
  402. package/dist/hooks/useDirection.mjs.map +1 -0
  403. package/dist/hooks/useDismiss.cjs +2 -0
  404. package/dist/hooks/useDismiss.cjs.map +1 -0
  405. package/dist/hooks/useDismiss.mjs +57 -0
  406. package/dist/hooks/useDismiss.mjs.map +1 -0
  407. package/dist/hooks/useEventCallback.cjs +2 -0
  408. package/dist/hooks/useEventCallback.cjs.map +1 -0
  409. package/dist/hooks/useEventCallback.mjs +16 -0
  410. package/dist/hooks/useEventCallback.mjs.map +1 -0
  411. package/dist/hooks/useFieldControl.cjs +2 -0
  412. package/dist/hooks/useFieldControl.cjs.map +1 -0
  413. package/dist/hooks/useFieldControl.mjs +62 -0
  414. package/dist/hooks/useFieldControl.mjs.map +1 -0
  415. package/dist/hooks/useFocusTrap.cjs +2 -0
  416. package/dist/hooks/useFocusTrap.cjs.map +1 -0
  417. package/dist/hooks/useFocusTrap.mjs +266 -0
  418. package/dist/hooks/useFocusTrap.mjs.map +1 -0
  419. package/dist/hooks/useFormReset.cjs +2 -0
  420. package/dist/hooks/useFormReset.cjs.map +1 -0
  421. package/dist/hooks/useFormReset.mjs +33 -0
  422. package/dist/hooks/useFormReset.mjs.map +1 -0
  423. package/dist/hooks/useHoverIntent.cjs +2 -0
  424. package/dist/hooks/useHoverIntent.cjs.map +1 -0
  425. package/dist/hooks/useHoverIntent.mjs +201 -0
  426. package/dist/hooks/useHoverIntent.mjs.map +1 -0
  427. package/dist/hooks/useId.cjs +2 -0
  428. package/dist/hooks/useId.cjs.map +1 -0
  429. package/dist/hooks/useId.mjs +11 -0
  430. package/dist/hooks/useId.mjs.map +1 -0
  431. package/dist/hooks/useIsClient.cjs +2 -0
  432. package/dist/hooks/useIsClient.cjs.map +1 -0
  433. package/dist/hooks/useIsClient.mjs +19 -0
  434. package/dist/hooks/useIsClient.mjs.map +1 -0
  435. package/dist/hooks/useListbox.cjs +2 -0
  436. package/dist/hooks/useListbox.cjs.map +1 -0
  437. package/dist/hooks/useListbox.mjs +492 -0
  438. package/dist/hooks/useListbox.mjs.map +1 -0
  439. package/dist/hooks/useMergedRefs.cjs +2 -0
  440. package/dist/hooks/useMergedRefs.cjs.map +1 -0
  441. package/dist/hooks/useMergedRefs.mjs +57 -0
  442. package/dist/hooks/useMergedRefs.mjs.map +1 -0
  443. package/dist/hooks/useModalIsolation.cjs +2 -0
  444. package/dist/hooks/useModalIsolation.cjs.map +1 -0
  445. package/dist/hooks/useModalIsolation.mjs +87 -0
  446. package/dist/hooks/useModalIsolation.mjs.map +1 -0
  447. package/dist/hooks/useModalLayer.cjs +2 -0
  448. package/dist/hooks/useModalLayer.cjs.map +1 -0
  449. package/dist/hooks/useModalLayer.mjs +30 -0
  450. package/dist/hooks/useModalLayer.mjs.map +1 -0
  451. package/dist/hooks/usePopupPosition.cjs +2 -0
  452. package/dist/hooks/usePopupPosition.cjs.map +1 -0
  453. package/dist/hooks/usePopupPosition.mjs +117 -0
  454. package/dist/hooks/usePopupPosition.mjs.map +1 -0
  455. package/dist/hooks/usePrefersReducedMotion.cjs +2 -0
  456. package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -0
  457. package/dist/hooks/usePrefersReducedMotion.mjs +24 -0
  458. package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -0
  459. package/dist/hooks/usePresence.cjs +2 -0
  460. package/dist/hooks/usePresence.cjs.map +1 -0
  461. package/dist/hooks/usePresence.mjs +136 -0
  462. package/dist/hooks/usePresence.mjs.map +1 -0
  463. package/dist/hooks/usePreserveFocus.cjs +2 -0
  464. package/dist/hooks/usePreserveFocus.cjs.map +1 -0
  465. package/dist/hooks/usePreserveFocus.mjs +50 -0
  466. package/dist/hooks/usePreserveFocus.mjs.map +1 -0
  467. package/dist/hooks/useRestoreFocus.cjs +2 -0
  468. package/dist/hooks/useRestoreFocus.cjs.map +1 -0
  469. package/dist/hooks/useRestoreFocus.mjs +271 -0
  470. package/dist/hooks/useRestoreFocus.mjs.map +1 -0
  471. package/dist/hooks/useRovingTabIndex.cjs +2 -0
  472. package/dist/hooks/useRovingTabIndex.cjs.map +1 -0
  473. package/dist/hooks/useRovingTabIndex.mjs +389 -0
  474. package/dist/hooks/useRovingTabIndex.mjs.map +1 -0
  475. package/dist/hooks/useScrollLock.cjs +2 -0
  476. package/dist/hooks/useScrollLock.cjs.map +1 -0
  477. package/dist/hooks/useScrollLock.mjs +71 -0
  478. package/dist/hooks/useScrollLock.mjs.map +1 -0
  479. package/dist/hooks/useTriggerElement.cjs +2 -0
  480. package/dist/hooks/useTriggerElement.cjs.map +1 -0
  481. package/dist/hooks/useTriggerElement.mjs +126 -0
  482. package/dist/hooks/useTriggerElement.mjs.map +1 -0
  483. package/dist/hooks/useTypeahead.cjs +2 -0
  484. package/dist/hooks/useTypeahead.cjs.map +1 -0
  485. package/dist/hooks/useTypeahead.mjs +38 -0
  486. package/dist/hooks/useTypeahead.mjs.map +1 -0
  487. package/dist/index.cjs +1 -1
  488. package/dist/index.d.cts +9099 -0
  489. package/dist/index.d.ts +7688 -1027
  490. package/dist/index.mjs +91 -5695
  491. package/dist/lib/aria.cjs +2 -0
  492. package/dist/lib/aria.cjs.map +1 -0
  493. package/dist/lib/aria.mjs +29 -0
  494. package/dist/lib/aria.mjs.map +1 -0
  495. package/dist/lib/children.cjs +2 -0
  496. package/dist/lib/children.cjs.map +1 -0
  497. package/dist/lib/children.mjs +37 -0
  498. package/dist/lib/children.mjs.map +1 -0
  499. package/dist/lib/cn.cjs +2 -0
  500. package/dist/lib/cn.cjs.map +1 -0
  501. package/dist/lib/cn.mjs +64 -0
  502. package/dist/lib/cn.mjs.map +1 -0
  503. package/dist/lib/composeEventHandlers.cjs +2 -0
  504. package/dist/lib/composeEventHandlers.cjs.map +1 -0
  505. package/dist/lib/composeEventHandlers.mjs +11 -0
  506. package/dist/lib/composeEventHandlers.mjs.map +1 -0
  507. package/dist/lib/dev.cjs +2 -0
  508. package/dist/lib/dev.cjs.map +1 -0
  509. package/dist/lib/dev.mjs +42 -0
  510. package/dist/lib/dev.mjs.map +1 -0
  511. package/dist/lib/direction.cjs +2 -0
  512. package/dist/lib/direction.cjs.map +1 -0
  513. package/dist/lib/direction.mjs +35 -0
  514. package/dist/lib/direction.mjs.map +1 -0
  515. package/dist/lib/events.cjs +2 -0
  516. package/dist/lib/events.cjs.map +1 -0
  517. package/dist/lib/events.mjs +31 -0
  518. package/dist/lib/events.mjs.map +1 -0
  519. package/dist/lib/focus.cjs +2 -0
  520. package/dist/lib/focus.cjs.map +1 -0
  521. package/dist/lib/focus.mjs +119 -0
  522. package/dist/lib/focus.mjs.map +1 -0
  523. package/dist/lib/globalRegistry.cjs +2 -0
  524. package/dist/lib/globalRegistry.cjs.map +1 -0
  525. package/dist/lib/globalRegistry.mjs +13 -0
  526. package/dist/lib/globalRegistry.mjs.map +1 -0
  527. package/dist/lib/icons.cjs +2 -0
  528. package/dist/lib/icons.cjs.map +1 -0
  529. package/dist/lib/icons.mjs +254 -0
  530. package/dist/lib/icons.mjs.map +1 -0
  531. package/dist/lib/labelInName.cjs +2 -0
  532. package/dist/lib/labelInName.cjs.map +1 -0
  533. package/dist/lib/labelInName.mjs +54 -0
  534. package/dist/lib/labelInName.mjs.map +1 -0
  535. package/dist/lib/layers.cjs +2 -0
  536. package/dist/lib/layers.cjs.map +1 -0
  537. package/dist/lib/layers.mjs +224 -0
  538. package/dist/lib/layers.mjs.map +1 -0
  539. package/dist/lib/mergeProps.cjs +2 -0
  540. package/dist/lib/mergeProps.cjs.map +1 -0
  541. package/dist/lib/mergeProps.mjs +21 -0
  542. package/dist/lib/mergeProps.mjs.map +1 -0
  543. package/dist/lib/mergeRefs.cjs +2 -0
  544. package/dist/lib/mergeRefs.cjs.map +1 -0
  545. package/dist/lib/mergeRefs.mjs +29 -0
  546. package/dist/lib/mergeRefs.mjs.map +1 -0
  547. package/dist/lib/renderTrigger.cjs +2 -0
  548. package/dist/lib/renderTrigger.cjs.map +1 -0
  549. package/dist/lib/renderTrigger.mjs +29 -0
  550. package/dist/lib/renderTrigger.mjs.map +1 -0
  551. package/dist/lib/slot.cjs +2 -0
  552. package/dist/lib/slot.cjs.map +1 -0
  553. package/dist/lib/slot.mjs +122 -0
  554. package/dist/lib/slot.mjs.map +1 -0
  555. package/dist/lib/styles.cjs +2 -0
  556. package/dist/lib/styles.cjs.map +1 -0
  557. package/dist/lib/styles.mjs +16 -0
  558. package/dist/lib/styles.mjs.map +1 -0
  559. package/dist/lib/theme.cjs +2 -0
  560. package/dist/lib/theme.cjs.map +1 -0
  561. package/dist/lib/theme.mjs +16 -0
  562. package/dist/lib/theme.mjs.map +1 -0
  563. package/dist/preflight.css +2 -0
  564. package/dist/styles.css +2 -0
  565. package/package.json +149 -100
  566. package/src/styles/animations.css +7 -39
  567. package/src/styles/base.css +103 -0
  568. package/src/styles/globals.css +10 -22
  569. package/src/styles/legacy-tokens.css +184 -0
  570. package/src/styles/preflight.css +7 -0
  571. package/src/styles/styles.css +32 -0
  572. package/src/styles/tailwind.css +17 -0
  573. package/src/styles/tokens.css +561 -221
  574. package/src/styles/variants.css +29 -0
@@ -0,0 +1,139 @@
1
+ "use client";
2
+ import { cn as e } from "../../lib/cn.mjs";
3
+ import { isDev as t, reportMissingContext as n, warnDeprecated as r, warnOnce as i } from "../../lib/dev.mjs";
4
+ import { materialiseSlotContent as a, slotRendersContent as o } from "../../lib/slot.mjs";
5
+ import { composeEventHandlers as s } from "../../lib/composeEventHandlers.mjs";
6
+ import { useControllable as c } from "../../hooks/useControllable.mjs";
7
+ import { useId as l } from "../../hooks/useId.mjs";
8
+ import { useRovingTabIndex as u } from "../../hooks/useRovingTabIndex.mjs";
9
+ import { useMergedRefs as d } from "../../hooks/useMergedRefs.mjs";
10
+ import { joinIds as f } from "../../lib/aria.mjs";
11
+ import { useFieldContext as p, useFieldControl as m } from "../../hooks/useFieldControl.mjs";
12
+ import { focusRing as h, forcedColors as g } from "../../lib/styles.mjs";
13
+ import { useFormReset as _ } from "../../hooks/useFormReset.mjs";
14
+ import { HiddenInput as v } from "../internal/HiddenInput.mjs";
15
+ import * as y from "react";
16
+ import { jsx as b, jsxs as x } from "react/jsx-runtime";
17
+ //#region src/components/input/RadioGroup.tsx
18
+ var S = y.createContext(null);
19
+ S.displayName = "RadioGroupContext";
20
+ var C = {
21
+ value: "",
22
+ disabled: !1,
23
+ select: () => {},
24
+ getTabIndex: () => -1
25
+ };
26
+ function w(e) {
27
+ return y.useContext(S) || (n(e, "a RadioGroup"), C);
28
+ }
29
+ function T(e) {
30
+ i(`RadioGroup:duplicate:${e}`, `RadioGroup: several items share the value "${e}". Item values must be unique within a RadioGroup; items that share a value are checked together.`);
31
+ }
32
+ var E = ({ value: n, defaultValue: i, onValueChange: a, onChange: o, orientation: l = "vertical", disabled: f = !1, name: h, required: g, form: C, children: w, className: E, id: D, "aria-label": O, "aria-labelledby": k, "aria-describedby": A, "aria-invalid": j, "aria-required": M, onKeyDown: N, onFocus: P, ref: F, ...I }) => {
33
+ o !== void 0 && r("RadioGroup", "onChange", "onValueChange");
34
+ let L = i ?? "", [R, z] = c(n, L, (e) => {
35
+ a?.(e), o?.(e);
36
+ }), { containerProps: B, getTabIndex: V } = u({
37
+ activeValue: R,
38
+ orientation: "both",
39
+ loop: !0,
40
+ onFocusMove: (e) => z(e)
41
+ }), H = y.useRef(null), U = d(F, B.ref, H), W = p(), G = m({
42
+ id: D,
43
+ "aria-label": O,
44
+ "aria-labelledby": k,
45
+ "aria-describedby": A,
46
+ "aria-invalid": j,
47
+ "aria-required": M ?? g
48
+ }, { labelable: !1 }), K = g ?? W?.required ?? !1;
49
+ _(H, () => z(L), C), y.useEffect(() => {
50
+ let e = H.current;
51
+ if (!t || !e) return;
52
+ let n = /* @__PURE__ */ new Set();
53
+ for (let t of e.querySelectorAll("[role=\"radio\"][data-roving-value]")) {
54
+ if (t.closest("[data-roving-container]") !== e) continue;
55
+ let r = t.getAttribute("data-roving-value") ?? "";
56
+ n.has(r) && T(r), n.add(r);
57
+ }
58
+ });
59
+ let q = () => {
60
+ H.current?.querySelector("[data-roving-value][tabindex=\"0\"]")?.focus();
61
+ }, J = (e) => {
62
+ let t = e.target, n = t.closest("[data-roving-value]"), r = n !== null && n.closest("[data-roving-container]") === e.currentTarget;
63
+ (t === e.currentTarget || r) && B.onKeyDown(e);
64
+ }, Y = y.useMemo(() => ({
65
+ value: R,
66
+ disabled: f,
67
+ select: z,
68
+ getTabIndex: V
69
+ }), [
70
+ R,
71
+ f,
72
+ z,
73
+ V
74
+ ]);
75
+ return /* @__PURE__ */ b(S.Provider, {
76
+ value: Y,
77
+ children: /* @__PURE__ */ x("div", {
78
+ role: "radiogroup",
79
+ ...G,
80
+ "aria-orientation": l,
81
+ "aria-disabled": f || void 0,
82
+ className: e("relative flex", l === "vertical" ? "flex-col gap-2" : "flex-row gap-4", E),
83
+ ...I,
84
+ ref: U,
85
+ "data-roving-container": "",
86
+ onKeyDown: s(N, J),
87
+ onFocus: s(P, B.onFocus, { checkDefaultPrevented: !1 }),
88
+ children: [w, /* @__PURE__ */ b(v, {
89
+ type: "radio",
90
+ name: h,
91
+ form: C,
92
+ disabled: f,
93
+ value: R,
94
+ required: K,
95
+ onInvalid: q
96
+ })]
97
+ })
98
+ });
99
+ };
100
+ E.displayName = "RadioGroup";
101
+ var D = "forced-colors:bg-[GrayText] forced-colors:forced-color-adjust-none";
102
+ function O({ value: t, label: n, disabled: r, className: c, labelClassName: u, onClick: d, "aria-labelledby": p, children: m, ref: _, ...v }) {
103
+ let S = w("RadioItem"), C = o(m);
104
+ y.useEffect(() => {
105
+ C && i("RadioItem:children", "RadioItem: children are not rendered. Pass the label in `label`.");
106
+ }, [C]);
107
+ let T = l("radio-item"), E = l("radio-item-label"), O = !!(r || S.disabled), k = S.value === t, A = o(n), j = A && v["aria-label"] === void 0 ? f(p, E) : p;
108
+ return /* @__PURE__ */ x("label", {
109
+ className: e("inline-flex items-start gap-2 select-none", O ? "cursor-not-allowed opacity-50 has-focus-visible:opacity-100" : "cursor-pointer", c),
110
+ children: [/* @__PURE__ */ b("button", {
111
+ id: T,
112
+ type: "button",
113
+ role: "radio",
114
+ ...v,
115
+ ref: _,
116
+ "aria-labelledby": j,
117
+ "aria-checked": k,
118
+ disabled: O,
119
+ tabIndex: O ? -1 : S.getTabIndex(t),
120
+ "data-roving-value": t,
121
+ onClick: s(d, () => S.select(t)),
122
+ className: e("flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full border bg-transparent p-0 transition-colors motion-reduce:transition-none", A && "mt-px", h, k ? "border-2 border-primary" : "border-stroke-accessible", O ? g.disabled : k ? "forced-colors:border-[Highlight]" : g.control),
123
+ children: k && /* @__PURE__ */ b("span", {
124
+ "aria-hidden": "true",
125
+ className: e("block h-2 w-2 rounded-full bg-primary", O ? D : g.selectedLeaf)
126
+ })
127
+ }), A && /* @__PURE__ */ b("span", {
128
+ id: E,
129
+ className: e("text-body-1 text-foreground", u),
130
+ children: a(n)
131
+ })]
132
+ });
133
+ }
134
+ O.displayName = "RadioItem";
135
+ var k = O, A = /* @__PURE__ */ Object.assign(E, { Item: O });
136
+ //#endregion
137
+ export { A as RadioGroup, k as RadioGroupItem, O as RadioItem };
138
+
139
+ //# sourceMappingURL=RadioGroup.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioGroup.mjs","names":["useId","useId$1","React","RadioGroupContext","INERT_CONTEXT","useRadioGroupContext","reportMissingContext","componentName","warnDuplicateValue","value","RadioGroupRoot","valueProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","rest","onChange","warnDeprecated","initialValue","defaultValue","setValue","useControllable","onValueChange","next","useRovingTabIndex","rootRef","mergedRef","useMergedRefs","ref","containerProps","field","useFieldContext","fieldProps","useFieldControl","required","isRequired","useFormReset","form","root","isDev","seen","item","itemValue","focusTabStop","handleKeyDown","target","event","fromOwnItem","contextValue","disabled","getTabIndex","orientation","cn","className","composeEventHandlers","onKeyDown","onFocus","children","HiddenInput","disabledDot","RadioItem","ctx","hasChildren","slotRendersContent","warnOnce","generatedId","labelTextId","isDisabled","selected","hasLabel","label","labelledBy","joinIds","onClick","focusRing","forcedColors","labelClassName","materialiseSlotContent","RadioGroupItem","RadioGroup"],"sources":["../../../src/components/input/RadioGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport { joinIds } from '../../lib/aria';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { isDev, reportMissingContext, warnDeprecated, warnOnce } from '../../lib/dev';\nimport { materialiseSlotContent, slotRendersContent } from '../../lib/slot';\nimport { focusRing, forcedColors } from '../../lib/styles';\nimport type { Orientation } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useRovingTabIndex } from '../../hooks/useRovingTabIndex';\nimport { HiddenInput } from '../internal/HiddenInput';\n\n/* ---- Context ---- */\ninterface RadioGroupContextValue {\n /** The selected value (`''` when nothing is selected). */\n value: string;\n /** Group-level disabled state. */\n disabled: boolean;\n /**\n * Selects a value when an item is activated (click, Space, Enter). Arrow keys select through\n * the roving hook's `onFocusMove` instead. Both paths use the same `setValue`, so\n * `onValueChange` and the deprecated `onChange` alias fire only when the value changes\n * (C-NAMING).\n */\n select: (value: string) => void;\n /** Roving tab index of an item. */\n getTabIndex: (value: string) => 0 | -1;\n}\n\nconst RadioGroupContext = React.createContext<RadioGroupContextValue | null>(null);\nRadioGroupContext.displayName = 'RadioGroupContext';\n\nconst INERT_CONTEXT: RadioGroupContextValue = {\n value: '',\n disabled: false,\n select: () => {},\n getTabIndex: () => -1,\n};\n\n/**\n * The surrounding RadioGroup's context; throws in development outside one, logs once and returns\n * an inert value in production (C-CONTEXT).\n */\nfunction useRadioGroupContext(componentName: string): RadioGroupContextValue {\n const context = React.useContext(RadioGroupContext);\n if (context) return context;\n reportMissingContext(componentName, 'a RadioGroup');\n return INERT_CONTEXT;\n}\n\nfunction warnDuplicateValue(value: string): void {\n warnOnce(\n `RadioGroup:duplicate:${value}`,\n `RadioGroup: several items share the value \"${value}\". Item values must be unique within a ` +\n 'RadioGroup; items that share a value are checked together.',\n );\n}\n\n/* ---- RadioGroup ---- */\n/** Properties for the RadioGroup component. */\nexport interface RadioGroupProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue'\n> {\n /** Controlled selected value (`''` for no selection). */\n value?: string;\n /** Initial selected value for uncontrolled usage (also the value a form reset restores).\n * @default ''\n */\n defaultValue?: string;\n /** Called with the newly selected value when the selection changes (not when re-selecting). */\n onValueChange?: (value: string) => void;\n /**\n * Called with the newly selected value, exactly like `onValueChange`: only when the selection\n * changes (0.4 also called it when the selected item was chosen again).\n * @deprecated Use `onValueChange`.\n */\n onChange?: (value: string) => void;\n /**\n * Layout of the radio items (also `aria-orientation`). Arrow keys follow the APG radio pattern\n * in both layouts: Down/Right select the next item, Up/Left the previous one (Left/Right\n * mirrored under `dir=\"rtl\"`).\n * @default 'vertical'\n */\n orientation?: Orientation;\n /** Disables every item of the group. */\n disabled?: boolean;\n /**\n * Form field name. With a name, the selected value is submitted with the form. No name is\n * generated: without one the group adds nothing to `FormData`.\n */\n name?: string;\n /** A value must be selected before the form can be submitted (native validation). */\n required?: boolean;\n /** Id of the form the group belongs to, when it is rendered outside that form. */\n form?: string;\n /** Ref to the `role=\"radiogroup\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// The `role=\"radiogroup\"` root, documented on the exported `RadioGroup` const.\nconst RadioGroupRoot = ({\n value: valueProp,\n defaultValue,\n onValueChange,\n onChange,\n orientation = 'vertical',\n disabled = false,\n name,\n required,\n form,\n children,\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 ref,\n ...rest\n}: RadioGroupProps) => {\n if (onChange !== undefined) warnDeprecated('RadioGroup', 'onChange', 'onValueChange');\n const initialValue = defaultValue ?? '';\n const [value, setValue] = useControllable(valueProp, initialValue, (next: string) => {\n onValueChange?.(next);\n onChange?.(next);\n });\n\n const { containerProps, getTabIndex } = useRovingTabIndex({\n activeValue: value,\n orientation: 'both',\n loop: true,\n // APG radio group: moving focus also selects the item.\n onFocusMove: (next) => 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\n useFormReset(rootRef, () => setValue(initialValue), form);\n\n // Development diagnostic (C-DEV): the items may sit anywhere inside the group (Fragments, wrapper\n // elements), so they are read from the DOM after each commit.\n React.useEffect(() => {\n const root = rootRef.current;\n if (!isDev || !root) return;\n const seen = new Set<string>();\n for (const item of root.querySelectorAll<HTMLElement>('[role=\"radio\"][data-roving-value]')) {\n // Its own items only: the roving marker cannot be overridden by the consumer (`role` can).\n if (item.closest('[data-roving-container]') !== root) continue;\n const itemValue = item.getAttribute('data-roving-value') ?? '';\n if (seen.has(itemValue)) warnDuplicateValue(itemValue);\n seen.add(itemValue);\n }\n });\n\n const focusTabStop = () => {\n rootRef.current?.querySelector<HTMLElement>('[data-roving-value][tabindex=\"0\"]')?.focus();\n };\n\n // Arrow keys, Home and End move between the radios (and select) only when they are pressed on a\n // radio or on the group itself. A key pressed on other focusable content inside the group (a\n // link in an item's label) keeps its own meaning, such as scrolling the page.\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const target = event.target as Element;\n const item = target.closest('[data-roving-value]');\n const fromOwnItem =\n item !== null && item.closest('[data-roving-container]') === event.currentTarget;\n if (target === event.currentTarget || fromOwnItem) containerProps.onKeyDown(event);\n };\n\n const contextValue = React.useMemo<RadioGroupContextValue>(\n () => ({ value, disabled, select: setValue, getTabIndex }),\n [value, disabled, setValue, getTabIndex],\n );\n\n return (\n <RadioGroupContext.Provider value={contextValue}>\n <div\n role=\"radiogroup\"\n {...fieldProps}\n aria-orientation={orientation}\n aria-disabled={disabled || undefined}\n className={cn(\n 'relative flex',\n orientation === 'vertical' ? 'flex-col gap-2' : 'flex-row gap-4',\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 >\n {children}\n <HiddenInput\n type=\"radio\"\n name={name}\n form={form}\n disabled={disabled}\n value={value}\n required={isRequired}\n onInvalid={focusTabStop}\n />\n </div>\n </RadioGroupContext.Provider>\n );\n};\n\nRadioGroupRoot.displayName = 'RadioGroup';\n\n/* ---- RadioItem ---- */\n/** Forced-colors look of the dot of a disabled selected radio: GrayText, no Highlight fill. */\nconst disabledDot = 'forced-colors:bg-[GrayText] forced-colors:forced-color-adjust-none';\n\n/** Properties for the RadioItem component. */\nexport interface RadioItemProps extends Omit<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n 'value' | 'onChange'\n> {\n /** Value associated with this radio option. */\n value: string;\n /**\n * Label next to the radio indicator (any phrasing content, links included, but no other form\n * controls). It names the radio through `aria-labelledby`, after a consumer `aria-labelledby`;\n * a consumer `aria-label` names it instead. Clicking its text selects the radio; clicking a link\n * inside it follows the link, and arrow keys on that link do not move between the radios. The\n * radio lines up with the first line of the label. `children` are not rendered: pass the label\n * here.\n */\n label?: React.ReactNode;\n /** Whether the radio item is disabled and non-interactive (also when the group is disabled). */\n disabled?: boolean;\n /** Class name of the item's root `<label>` element. */\n className?: string;\n /** Class name of the element that renders the `label` text. */\n labelClassName?: string;\n /** Ref to the `role=\"radio\"` button. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * One option of a {@link RadioGroup}: a `role=\"radio\"` button inside a `<label>`.\n *\n * Native button props (`id`, `aria-*`, `data-*`, handlers, `style`) and `ref` go to the radio\n * button; `className` stays on the root `<label>` and `labelClassName` styles the label text. A\n * consumer `onClick` runs before the selection; `preventDefault()` in it cancels the selection.\n * Must be rendered inside a RadioGroup (also inside Fragments or wrapper elements). `label` takes\n * rich content (a second line of subtext, a link); `children` are not rendered (a development\n * warning says so).\n */\nexport function RadioItem({\n value,\n label,\n disabled,\n className,\n labelClassName,\n onClick,\n 'aria-labelledby': ariaLabelledBy,\n children,\n ref,\n ...rest\n}: RadioItemProps) {\n const ctx = useRadioGroupContext('RadioItem');\n const hasChildren = slotRendersContent(children);\n React.useEffect(() => {\n if (hasChildren) {\n warnOnce(\n 'RadioItem:children',\n 'RadioItem: children are not rendered. Pass the label in `label`.',\n );\n }\n }, [hasChildren]);\n const generatedId = useId('radio-item');\n const labelTextId = useId('radio-item-label');\n\n const isDisabled = Boolean(disabled || ctx.disabled);\n const selected = ctx.value === value;\n // `0` is a label; `null`, `false`, `''` and empty collections are not (C-SLOTS).\n const hasLabel = slotRendersContent(label);\n // The label text names the radio through aria-labelledby, disabled or not: axe exempts the dimmed\n // text of a disabled radio only when the radio references it this way (its <label> exemption\n // covers native inputs only). A consumer aria-label still names the radio alone; a consumer\n // aria-labelledby comes first.\n const labelledBy =\n hasLabel && rest['aria-label'] === undefined\n ? joinIds(ariaLabelledBy, labelTextId)\n : ariaLabelledBy;\n\n return (\n <label\n className={cn(\n // items-start: the radio lines up with the first line of a label that wraps or has a\n // second line, not with its middle.\n 'inline-flex items-start gap-2 select-none',\n // The dimmed look lifts while a focus ring shows inside the root (a link's in the label; a\n // disabled radio never takes focus): opacity would dim the ring below 3:1.\n isDisabled\n ? 'cursor-not-allowed opacity-50 has-focus-visible:opacity-100'\n : 'cursor-pointer',\n className,\n )}\n >\n <button\n id={generatedId}\n type=\"button\"\n role=\"radio\"\n {...rest}\n ref={ref}\n aria-labelledby={labelledBy}\n aria-checked={selected}\n disabled={isDisabled}\n tabIndex={isDisabled ? -1 : ctx.getTabIndex(value)}\n data-roving-value={value}\n onClick={composeEventHandlers(onClick, () => ctx.select(value))}\n className={cn(\n // p-0 and bg-transparent are set here, not left to the native reset, which any app button\n // style overrides (C-NATIVE).\n 'flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full border bg-transparent p-0 transition-colors motion-reduce:transition-none',\n // Centred on the 20px first line of the label text.\n hasLabel && 'mt-px',\n focusRing,\n selected ? 'border-2 border-primary' : 'border-stroke-accessible',\n // Forced colors: the focusable circle keeps system colors (its focus outline stays\n // forced); only the dot opts out. A disabled radio draws GrayText, never Highlight.\n isDisabled\n ? forcedColors.disabled\n : selected\n ? 'forced-colors:border-[Highlight]'\n : forcedColors.control,\n )}\n >\n {selected && (\n <span\n aria-hidden=\"true\"\n className={cn(\n 'block h-2 w-2 rounded-full bg-primary',\n isDisabled ? disabledDot : forcedColors.selectedLeaf,\n )}\n />\n )}\n </button>\n {hasLabel && (\n <span id={labelTextId} className={cn('text-body-1 text-foreground', labelClassName)}>\n {materialiseSlotContent(label)}\n </span>\n )}\n </label>\n );\n}\n\nRadioItem.displayName = 'RadioItem';\n\n/**\n * Flat name of `RadioGroup.Item` (C-COMPOUND), for React Server Components, which cannot access\n * the dotted form. Same component as {@link RadioItem}.\n */\nexport const RadioGroupItem = RadioItem;\n\n/** Props of {@link RadioGroupItem} (same as {@link RadioItemProps}). */\nexport type RadioGroupItemProps = RadioItemProps;\n\n/**\n * A single-choice group of {@link RadioItem}s (`role=\"radiogroup\"`).\n *\n * - One tab stop (the selected item, else the first enabled one); arrow keys move focus and select\n * (APG radio group), Home/End jump to the ends, disabled items are skipped. A key pressed on a\n * link inside an item's label stays the link's: it neither moves focus nor selects. Items may\n * sit inside Fragments or wrapper elements. Every item needs its own `value` (a development\n * warning names a value that several items share).\n * - Inside a `Field` it is named by the Field label (`aria-labelledby`) and described by its hint\n * and error.\n * - With `name` (or `required`) it takes part in native forms; a form reset restores\n * `defaultValue`.\n *\n * Use `RadioGroup.Item` (or the flat `RadioGroupItem`/`RadioItem` names) for the items. React\n * Server Components cannot access the dotted form, so they import the flat names; dotted access\n * needs a client file.\n */\nexport const RadioGroup = /* @__PURE__ */ Object.assign(RadioGroupRoot, { Item: RadioItem });\n"],"mappings":";;;;;;;;;;;;;;;;;AAiCA,IAAMG,IAAoBD,EAAM,cAA6C,IAAI;AACjF,EAAkB,cAAc;AAEhC,IAAME,IAAwC;CAC5C,OAAO;CACP,UAAU;CACV,cAAc,CAAC;CACf,mBAAmB;AACrB;AAMA,SAASC,EAAqB,GAA+C;CAI3E,OAHgBH,EAAM,WAAWC,CAC7B,MACJG,EAAqBC,GAAe,cAAc,GAC3CH;AACT;AAEA,SAASI,EAAmB,GAAqB;CAC/C,EACE,wBAAwBC,KACxB,8CAA8CA,EAAM,kGAEtD;AACF;AA6CA,IAAMC,KAAkB,EACtB,OAAOC,GACP,iBACA,kBACA,aACA,iBAAc,YACd,cAAW,IACX,SACA,aACA,SACA,aACA,cACA,OACA,cAAcC,GACd,mBAAmBC,GACnB,oBAAoBC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D,EAAK,kBAAkB,KAAA,IAC/ByD,EAAQ7D,GAAgBuD,CAAW,IACnCvD;CAEN,OACE,kBAAC,SAAD;EACE,WAAWyC,EAGT,6CAGAe,IACI,gEACA,kBACJd,CACF;EAXF,UAAA,CAaE,kBAAC,UAAD;GACE,IAAIY;GACJ,MAAK;GACL,MAAK;GACL,GAAIlD;GACC;GACL,mBAAiBwD;GACjB,gBAAcH;GACd,UAAUD;GACV,UAAUA,IAAa,KAAKN,EAAI,YAAYtD,CAAK;GACjD,qBAAmBA;GACnB,SAAS+C,EAAqBmB,SAAeZ,EAAI,OAAOtD,CAAK,CAAC;GAC9D,WAAW6C,EAGT,sJAEAiB,KAAY,SACZK,GACAN,IAAW,4BAA4B,4BAGvCD,IACIQ,EAAa,WACbP,IACE,qCACAO,EAAa,OACrB;GAEC,UAAAP,KACC,kBAAC,QAAD;IACE,eAAY;IACZ,WAAWhB,EACT,yCACAe,IAAaR,IAAcgB,EAAa,YAC1C;GACD,CAAA;EAEG,CAAA,GACPN,KACC,kBAAC,QAAD;GAAM,IAAIH;GAAa,WAAWd,EAAG,+BAA+BwB,CAAc;GAC/E,UAAAC,EAAuBP,CAAK;EACzB,CAAA,CAEH;;AAEX;AAEA,EAAU,cAAc;AAMxB,IAAaQ,IAAiBlB,GAsBjBmB,IAA6B,uBAAO,OAAOvE,GAAgB,EAAE,MAAMoD,EAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/composeEventHandlers.cjs"),i=require("../../hooks/useControllable.cjs"),a=require("../../lib/direction.cjs"),o=require("../../hooks/useRovingTabIndex.cjs"),s=require("../../hooks/useMergedRefs.cjs"),c=require("../../hooks/useFieldControl.cjs"),l=require("../../lib/styles.cjs"),u=require("../../lib/icons.cjs"),d=require("../../hooks/useFormReset.cjs"),f=require("../internal/HiddenInput.cjs");let p=require("react");p=e.__toESM(p,1);let m=require("react/jsx-runtime");var h=e=>`${e} star${e===1?``:`s`}`,g={"extra-small":`h-3 w-3`,small:`h-4 w-4`,medium:`h-5 w-5`,large:`h-6 w-6`,"extra-large":`h-8 w-8`},_={"extra-small":`p-1.5`,small:`p-1`,medium:`p-0.5`,large:`p-0.5`,"extra-large":`p-0.5`};function v({filled:e,className:t}){return e?(0,m.jsx)(u.StarIcon,{className:t}):(0,m.jsx)(u.StarIcon,{className:t,fill:`none`,stroke:`currentColor`,strokeWidth:1.5})}var y=({value:e,defaultValue:u,onValueChange:y,onChange:b,max:x=5,size:S=`medium`,disabled:C=!1,name:w,required:T,form:E,labels:D,className:O,id:k,"aria-label":ee,"aria-labelledby":A,"aria-describedby":j,"aria-invalid":M,"aria-required":N,onKeyDown:P,onFocus:F,onMouseLeave:I,ref:L,...R})=>{b!==void 0&&n.warnDeprecated(`Rating`,`onChange`,`onValueChange`);let z=u??0,[B,V]=i.useControllable(e,z,e=>{y?.(e),b?.(e)}),[H,U]=p.useState(0),[W,G]=p.useState(C);W!==C&&(G(C),C&&U(0));let K=C?B:H||B,{containerProps:q,getTabIndex:J,focusValue:Y}=o.useRovingTabIndex({activeValue:B>0?String(B):null}),X=e=>{if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey)return;let t;if(e.key===`Home`)t=1;else if(e.key===`End`)t=x;else if(e.key===`ArrowUp`)t=B+1;else if(e.key===`ArrowDown`)t=B-1;else{let n=a.getArrowIntent(e.key,{orientation:`horizontal`,dir:a.getDirection(e.currentTarget)});if(!n)return;t=n===`next`?B+1:B-1}e.preventDefault(),t=Math.min(t,x),!(C||t<1||t===B)&&(Y(String(t)),V(t))},Z=p.useRef(null),Q=s.useMergedRefs(L,q.ref,Z),te=c.useFieldContext(),$=c.useFieldControl({id:k,"aria-label":ee,"aria-labelledby":A,"aria-describedby":j,"aria-invalid":M,"aria-required":N??T},{labelable:!1}),ne=T??te?.required??!1,re=$[`aria-label`]===void 0&&$[`aria-labelledby`]===void 0?`Rating`:void 0;d.useFormReset(Z,()=>V(z),E);let ie=()=>{Z.current?.querySelector(`[data-roving-value][tabindex="0"]`)?.focus()},ae=g[S],oe=D?.star??h;return(0,m.jsxs)(`div`,{role:`radiogroup`,"aria-label":re,...$,"aria-disabled":C||void 0,className:t.cn(`relative inline-flex items-center gap-0.5`,C&&`pointer-events-none opacity-50`,O),...R,ref:Q,"data-roving-container":``,onKeyDown:r.composeEventHandlers(P,X),onFocus:r.composeEventHandlers(F,q.onFocus,{checkDefaultPrevented:!1}),onMouseLeave:r.composeEventHandlers(I,()=>U(0),{checkDefaultPrevented:!1}),children:[Array.from({length:x},(e,n)=>{let r=n+1,i=String(r),a=K>=r;return(0,m.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":B===r,"aria-label":oe(r,x),"data-roving-value":i,tabIndex:C?-1:J(i),disabled:C,className:t.cn(`inline-flex cursor-pointer rounded border-0 bg-transparent transition-colors motion-reduce:transition-none disabled:cursor-not-allowed`,_[S],l.focusRing,a?`text-rating`:`text-stroke-accessible`),onClick:()=>{C||V(r)},onMouseEnter:()=>{C||U(r)},children:(0,m.jsx)(v,{filled:a,className:ae})},i)}),(0,m.jsx)(f.HiddenInput,{type:`radio`,name:w,form:E,disabled:C,value:B>0?String(B):``,required:ne,onInvalid:ie})]})};y.displayName=`Rating`;var b={"extra-small":`text-caption-1`,small:`text-caption-1`,medium:`text-body-1`,large:`text-body-2`,"extra-large":`text-body-2`},x=(e,t,n)=>`Rating: ${n} out of ${t}`,S=(e,t)=>e===1?`1 rating`:`${t} ratings`;function C(e){if(e!==void 0)try{return Intl.getCanonicalLocales(e),e}catch{return}}var w=({value:e,max:r=5,size:i=`medium`,showValue:a=!1,count:o,compact:s=!1,locale:c,labels:l,className:u,ref:d,...f})=>{let h=g[i],_=C(c),y=c!==void 0&&_===void 0;p.useEffect(()=>{y&&n.warnOnce(`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.`)},[y,c]);let w=new Intl.NumberFormat(_,{maximumFractionDigits:1}).format(e),T=o===void 0?void 0:new Intl.NumberFormat(_).format(o),E=(l?.rating??x)(e,r,w),D=o===void 0||T===void 0?E:`${E}, ${(l?.count??S)(o,T)}`,O=a||s||o!==void 0,k=b[i];return(0,m.jsxs)(`div`,{ref:d,role:`img`,"aria-label":D,"data-compact":s?``:void 0,className:t.cn(`inline-flex items-center gap-0.5`,u),...f,children:[s?(0,m.jsx)(`span`,{className:`inline-flex text-rating`,children:(0,m.jsx)(v,{filled:!0,className:h})}):Array.from({length:r},(n,r)=>{let i=Math.round(Math.min(1,Math.max(0,e-r))*100);if(i>0&&i<100)return(0,m.jsxs)(`span`,{className:`relative inline-flex text-stroke-accessible`,children:[(0,m.jsx)(v,{filled:!1,className:h}),(0,m.jsx)(`span`,{className:`absolute inset-y-0 start-0 flex overflow-hidden text-rating`,style:{width:`${i}%`},children:(0,m.jsx)(v,{filled:!0,className:t.cn(h,`shrink-0`)})})]},r);let a=i===100;return(0,m.jsx)(`span`,{className:t.cn(`inline-flex`,a?`text-rating`:`text-stroke-accessible`),children:(0,m.jsx)(v,{filled:a,className:h})},r)}),O&&(0,m.jsx)(`span`,{className:t.cn(`ms-1 font-semibold text-foreground`,k),children:w}),T!==void 0&&(0,m.jsxs)(`span`,{className:t.cn(`ms-1 text-muted-foreground`,k),children:[`(`,T,`)`]})]})};w.displayName=`RatingDisplay`,exports.Rating=y,exports.RatingDisplay=w;
2
+ //# sourceMappingURL=Rating.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Rating.cjs","names":["StarIcon","useControllable","React","useRovingTabIndex","getArrowIntent","getDirection","useMergedRefs","useFieldContext","useFieldControl","cn","composeEventHandlers","focusRing","HiddenInput","require_runtime","require_cn","require_dev","require_composeEventHandlers","require_useControllable","require_direction","require_useRovingTabIndex","require_useMergedRefs","require_useFieldControl","require_styles","require_icons","require_useFormReset","require_HiddenInput","react","react_jsx_runtime","defaultStarLabel","value","sizeMap","targetPaddingMap","Star","filled","Rating","valueProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","rest","onChange","initialValue","defaultValue","setValue","onValueChange","next","hovered","setHovered","prevDisabled","setPrevDisabled","disabled","displayValue","handleKeyDown","max","intent","focusValue","rootRef","mergedRef","ref","containerProps","field","fieldProps","required","isRequired","defaultName","form","focusTabStop","starSize","size","starLabel","labels","className","onKeyDown","onFocus","onMouseLeave","starValue","i","key","getTabIndex","textSizeMap","defaultRatingLabel","formattedValue","defaultCountLabel","count","formattedCount","supportedLocale","locale","RatingDisplay","formatLocale","invalidLocale","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":"4mBA2BA,IAAM4B,EAAoB,GAAkB,GAAGC,EAAM,OAAOA,IAAU,EAAU,GAAN,MA4GpEC,EAAgC,CACpC,cAAe,UACf,MAAO,UACP,OAAQ,UACR,MAAO,UACP,cAAe,SACjB,EAGMC,EAAyC,CAC7C,cAAe,QACf,MAAO,MACP,OAAQ,QACR,MAAO,QACP,cAAe,OACjB,EAGA,SAASC,EAAK,CAAE,SAAQ,aAAqD,CAC3E,OAAOC,GACL,EAAAN,EAAA,IAAA,CAAC3B,EAAAA,SAAD,CAAqB,WAAY,CAAA,GAEjC,EAAA2B,EAAA,IAAA,CAAC3B,EAAAA,SAAD,CAAqB,YAAW,KAAK,OAAO,OAAO,eAAe,YAAa,GAAM,CAAA,CAEzF,CAoBA,IAAakC,GAAU,CACrB,MAAOC,EACP,eACA,gBACA,WACA,MAAM,EACN,OAAO,SACP,WAAW,GACX,OACA,WACA,OACA,SACA,YACA,KACA,aAAcC,GACd,kBAAmBC,EACnB,mBAAoBC,EACpB,eAAgBC,EAChB,gBAAiBC,EACjB,YACA,UACA,eACA,MACA,GAAGC,KACc,CACbC,IAAa,IAAA,IAAW3B,EAAA,eAAe,SAAU,WAAY,eAAe,EAChF,IAAM4B,EAAeC,GAAgB,EA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,EAASiE,IAAY,IAC3B,OACE,EAAAvE,EAAA,IAAA,CAAC,OAAD,CAEE,UAAWlB,EAAAA,GAAG,cAAewB,EAAS,cAAgB,wBAAwB,EAE9E,UAAA,EAAAN,EAAA,IAAA,CAACK,EAAD,CAAc,SAAQ,UAAWqC,CAAW,CAAA,CACxC,EAJCS,CAID,CAEV,CAAC,EAEFgB,IACC,EAAAnE,EAAA,IAAA,CAAC,OAAD,CAAM,UAAWlB,EAAAA,GAAG,qCAAsCwF,CAAQ,EAAI,SAAAd,CAAqB,CAAA,EAE5FG,IAAmB,IAAA,KAClB,EAAA3D,EAAA,KAAA,CAAC,OAAD,CAAM,UAAWlB,EAAAA,GAAG,6BAA8BwF,CAAQ,EAA1D,SAAA,CAA6D,IAAEX,EAAe,GAAO,GAEpF,GAET,EACA,EAAc,YAAc"}
@@ -0,0 +1,196 @@
1
+ "use client";
2
+ import { cn as e } from "../../lib/cn.mjs";
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";
16
+ //#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;
46
+ 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;
51
+ else {
52
+ let n = a(e.key, {
53
+ orientation: "horizontal",
54
+ dir: o(e.currentTarget)
55
+ });
56
+ if (!n) return;
57
+ t = n === "next" ? V + 1 : V - 1;
58
+ }
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 = () => {
70
+ Z.current?.querySelector("[data-roving-value][tabindex=\"0\"]")?.focus();
71
+ }, ce = y[T], le = A?.star ?? v;
72
+ return /* @__PURE__ */ _("div", {
73
+ role: "radiogroup",
74
+ "aria-label": $,
75
+ ...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,
80
+ "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, {
107
+ type: "radio",
108
+ name: D,
109
+ form: k,
110
+ disabled: E,
111
+ value: V > 0 ? String(V) : "",
112
+ required: oe,
113
+ onInvalid: se
114
+ })]
115
+ });
116
+ };
117
+ S.displayName = "Rating";
118
+ var C = {
119
+ "extra-small": "text-caption-1",
120
+ small: "text-caption-1",
121
+ medium: "text-body-1",
122
+ large: "text-body-2",
123
+ "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) {
126
+ if (e !== void 0) try {
127
+ return Intl.getCanonicalLocales(e), e;
128
+ } catch {
129
+ return;
130
+ }
131
+ }
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,
140
+ 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,
145
+ 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);
176
+ }),
177
+ k && /* @__PURE__ */ g("span", {
178
+ className: e("ms-1 font-semibold text-foreground", A),
179
+ children: b
180
+ }),
181
+ S !== void 0 && /* @__PURE__ */ _("span", {
182
+ className: e("ms-1 text-muted-foreground", A),
183
+ children: [
184
+ "(",
185
+ S,
186
+ ")"
187
+ ]
188
+ })
189
+ ]
190
+ });
191
+ };
192
+ D.displayName = "RatingDisplay";
193
+ //#endregion
194
+ export { S as Rating, D as RatingDisplay };
195
+
196
+ //# sourceMappingURL=Rating.mjs.map
@@ -0,0 +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":";;;;;;;;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I,GAAG,KAAK,IAAI,GAAGnF,IAAQ4D,CAAC,CAAC,IAAI,GAAG;IACpE,IAAIuB,IAAU,KAAKA,IAAU,KAG3B,OACE,kBAAC,QAAD;KAAc,WAAU;KAAxB,UAAA,CACE,kBAAChF,GAAD;MAAM,QAAQ;MAAO,WAAW8C;KAAW,CAAA,GAC3C,kBAAC,QAAD;MACE,WAAU;MACV,OAAO,EAAE,OAAO,GAAGkC,EAAQ,GAAG;MAE9B,UAAA,kBAAChF,GAAD;OAAM,QAAA;OAAO,WAAWkD,EAAGJ,GAAU,UAAU;MAAI,CAAA;KAC/C,CAAA,CACF;IARK,GAAAW,CAQL;IAGV,IAAMxD,IAAS+E,MAAY;IAC3B,OACE,kBAAC,QAAD;KAEE,WAAW9B,EAAG,eAAejD,IAAS,gBAAgB,wBAAwB;KAE9E,UAAA,kBAACD,GAAD;MAAc;MAAQ,WAAW8C;KAAW,CAAA;IACxC,GAJCW,CAID;GAEV,CAAC;GAEFmB,KACC,kBAAC,QAAD;IAAM,WAAW1B,EAAG,sCAAsC6B,CAAQ;IAAI,UAAAf;GAAqB,CAAA;GAE5FG,MAAmB,KAAA,KAClB,kBAAC,QAAD;IAAM,WAAWjB,EAAG,8BAA8B6B,CAAQ;IAA1D,UAAA;KAA6D;KAAEZ;KAAe;IAAO;;EAEpF;;AAET;AACA,EAAc,cAAc"}
@@ -0,0 +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;
2
+ //# sourceMappingURL=SearchBox.cjs.map