@mortenbrudvik/waveui 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (408) hide show
  1. package/README.md +395 -132
  2. package/dist/components/button/Button.cjs +1 -1
  3. package/dist/components/button/Button.cjs.map +1 -1
  4. package/dist/components/button/Button.mjs +36 -35
  5. package/dist/components/button/Button.mjs.map +1 -1
  6. package/dist/components/button/Button.slots.cjs +1 -1
  7. package/dist/components/button/Button.slots.cjs.map +1 -1
  8. package/dist/components/button/Button.slots.mjs +31 -21
  9. package/dist/components/button/Button.slots.mjs.map +1 -1
  10. package/dist/components/button/CompoundButton.cjs +1 -1
  11. package/dist/components/button/CompoundButton.cjs.map +1 -1
  12. package/dist/components/button/CompoundButton.mjs +31 -29
  13. package/dist/components/button/CompoundButton.mjs.map +1 -1
  14. package/dist/components/button/Link.cjs +1 -1
  15. package/dist/components/button/Link.cjs.map +1 -1
  16. package/dist/components/button/Link.mjs +24 -23
  17. package/dist/components/button/Link.mjs.map +1 -1
  18. package/dist/components/button/MenuButton.cjs +1 -1
  19. package/dist/components/button/MenuButton.cjs.map +1 -1
  20. package/dist/components/button/MenuButton.mjs +29 -28
  21. package/dist/components/button/MenuButton.mjs.map +1 -1
  22. package/dist/components/button/SplitButton.cjs +1 -1
  23. package/dist/components/button/SplitButton.cjs.map +1 -1
  24. package/dist/components/button/SplitButton.mjs +46 -45
  25. package/dist/components/button/SplitButton.mjs.map +1 -1
  26. package/dist/components/button/ToggleButton.cjs +1 -1
  27. package/dist/components/button/ToggleButton.cjs.map +1 -1
  28. package/dist/components/button/ToggleButton.mjs +38 -35
  29. package/dist/components/button/ToggleButton.mjs.map +1 -1
  30. package/dist/components/button/Toolbar.cjs +1 -1
  31. package/dist/components/button/Toolbar.cjs.map +1 -1
  32. package/dist/components/button/Toolbar.mjs +43 -42
  33. package/dist/components/button/Toolbar.mjs.map +1 -1
  34. package/dist/components/button/Toolbar.parts.cjs +1 -1
  35. package/dist/components/button/Toolbar.parts.cjs.map +1 -1
  36. package/dist/components/button/Toolbar.parts.mjs +76 -81
  37. package/dist/components/button/Toolbar.parts.mjs.map +1 -1
  38. package/dist/components/data-display/Avatar.cjs +1 -1
  39. package/dist/components/data-display/Avatar.cjs.map +1 -1
  40. package/dist/components/data-display/Avatar.mjs +72 -67
  41. package/dist/components/data-display/Avatar.mjs.map +1 -1
  42. package/dist/components/data-display/AvatarGroup.cjs +1 -1
  43. package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
  44. package/dist/components/data-display/AvatarGroup.mjs +89 -88
  45. package/dist/components/data-display/AvatarGroup.mjs.map +1 -1
  46. package/dist/components/data-display/Badge.cjs +1 -1
  47. package/dist/components/data-display/Badge.cjs.map +1 -1
  48. package/dist/components/data-display/Badge.mjs +17 -16
  49. package/dist/components/data-display/Badge.mjs.map +1 -1
  50. package/dist/components/data-display/CounterBadge.cjs +1 -1
  51. package/dist/components/data-display/CounterBadge.cjs.map +1 -1
  52. package/dist/components/data-display/CounterBadge.mjs +18 -17
  53. package/dist/components/data-display/CounterBadge.mjs.map +1 -1
  54. package/dist/components/data-display/Divider.cjs +1 -1
  55. package/dist/components/data-display/Divider.cjs.map +1 -1
  56. package/dist/components/data-display/Divider.mjs +31 -30
  57. package/dist/components/data-display/Divider.mjs.map +1 -1
  58. package/dist/components/data-display/Image.cjs +1 -1
  59. package/dist/components/data-display/Image.cjs.map +1 -1
  60. package/dist/components/data-display/Image.mjs +16 -15
  61. package/dist/components/data-display/Image.mjs.map +1 -1
  62. package/dist/components/data-display/InfoLabel.cjs +1 -1
  63. package/dist/components/data-display/InfoLabel.cjs.map +1 -1
  64. package/dist/components/data-display/InfoLabel.mjs +74 -73
  65. package/dist/components/data-display/InfoLabel.mjs.map +1 -1
  66. package/dist/components/data-display/List.cjs +1 -1
  67. package/dist/components/data-display/List.cjs.map +1 -1
  68. package/dist/components/data-display/List.mjs +175 -174
  69. package/dist/components/data-display/List.mjs.map +1 -1
  70. package/dist/components/data-display/Persona.cjs +1 -1
  71. package/dist/components/data-display/Persona.cjs.map +1 -1
  72. package/dist/components/data-display/Persona.mjs +31 -29
  73. package/dist/components/data-display/Persona.mjs.map +1 -1
  74. package/dist/components/data-display/PresenceBadge.cjs +1 -1
  75. package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
  76. package/dist/components/data-display/PresenceBadge.mjs +25 -24
  77. package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
  78. package/dist/components/data-display/Tag.cjs +1 -1
  79. package/dist/components/data-display/Tag.cjs.map +1 -1
  80. package/dist/components/data-display/Tag.mjs +87 -82
  81. package/dist/components/data-display/Tag.mjs.map +1 -1
  82. package/dist/components/feedback/MessageBar.cjs +1 -1
  83. package/dist/components/feedback/MessageBar.cjs.map +1 -1
  84. package/dist/components/feedback/MessageBar.mjs +129 -71
  85. package/dist/components/feedback/MessageBar.mjs.map +1 -1
  86. package/dist/components/feedback/MessageBar.parts.cjs +2 -0
  87. package/dist/components/feedback/MessageBar.parts.cjs.map +1 -0
  88. package/dist/components/feedback/MessageBar.parts.mjs +84 -0
  89. package/dist/components/feedback/MessageBar.parts.mjs.map +1 -0
  90. package/dist/components/feedback/MessageBar.reflow.cjs +2 -0
  91. package/dist/components/feedback/MessageBar.reflow.cjs.map +1 -0
  92. package/dist/components/feedback/MessageBar.reflow.mjs +74 -0
  93. package/dist/components/feedback/MessageBar.reflow.mjs.map +1 -0
  94. package/dist/components/feedback/MessageBar.status.cjs +1 -1
  95. package/dist/components/feedback/MessageBar.status.cjs.map +1 -1
  96. package/dist/components/feedback/MessageBar.status.mjs +2 -1
  97. package/dist/components/feedback/MessageBar.status.mjs.map +1 -1
  98. package/dist/components/feedback/ProgressBar.cjs +1 -1
  99. package/dist/components/feedback/ProgressBar.cjs.map +1 -1
  100. package/dist/components/feedback/ProgressBar.mjs +44 -43
  101. package/dist/components/feedback/ProgressBar.mjs.map +1 -1
  102. package/dist/components/feedback/Skeleton.cjs +1 -1
  103. package/dist/components/feedback/Skeleton.cjs.map +1 -1
  104. package/dist/components/feedback/Skeleton.mjs +26 -24
  105. package/dist/components/feedback/Skeleton.mjs.map +1 -1
  106. package/dist/components/feedback/Spinner.cjs +1 -1
  107. package/dist/components/feedback/Spinner.cjs.map +1 -1
  108. package/dist/components/feedback/Spinner.mjs +32 -31
  109. package/dist/components/feedback/Spinner.mjs.map +1 -1
  110. package/dist/components/feedback/Toast.cjs +1 -1
  111. package/dist/components/feedback/Toast.cjs.map +1 -1
  112. package/dist/components/feedback/Toast.context.cjs +2 -0
  113. package/dist/components/feedback/Toast.context.cjs.map +1 -0
  114. package/dist/components/feedback/Toast.context.mjs +23 -0
  115. package/dist/components/feedback/Toast.context.mjs.map +1 -0
  116. package/dist/components/feedback/Toast.mjs +10 -342
  117. package/dist/components/feedback/Toast.mjs.map +1 -1
  118. package/dist/components/feedback/Toast.parts.cjs +2 -0
  119. package/dist/components/feedback/Toast.parts.cjs.map +1 -0
  120. package/dist/components/feedback/Toast.parts.mjs +98 -0
  121. package/dist/components/feedback/Toast.parts.mjs.map +1 -0
  122. package/dist/components/feedback/Toast.root.cjs +2 -0
  123. package/dist/components/feedback/Toast.root.cjs.map +1 -0
  124. package/dist/components/feedback/Toast.root.mjs +109 -0
  125. package/dist/components/feedback/Toast.root.mjs.map +1 -0
  126. package/dist/components/feedback/Toaster.cjs +2 -0
  127. package/dist/components/feedback/Toaster.cjs.map +1 -0
  128. package/dist/components/feedback/Toaster.mjs +564 -0
  129. package/dist/components/feedback/Toaster.mjs.map +1 -0
  130. package/dist/components/input/AlphaSlider.cjs +2 -0
  131. package/dist/components/input/AlphaSlider.cjs.map +1 -0
  132. package/dist/components/input/AlphaSlider.mjs +115 -0
  133. package/dist/components/input/AlphaSlider.mjs.map +1 -0
  134. package/dist/components/input/Checkbox.cjs +1 -1
  135. package/dist/components/input/Checkbox.cjs.map +1 -1
  136. package/dist/components/input/Checkbox.mjs +47 -46
  137. package/dist/components/input/Checkbox.mjs.map +1 -1
  138. package/dist/components/input/ColorArea.cjs +2 -0
  139. package/dist/components/input/ColorArea.cjs.map +1 -0
  140. package/dist/components/input/ColorArea.mjs +204 -0
  141. package/dist/components/input/ColorArea.mjs.map +1 -0
  142. package/dist/components/input/ColorPicker.cjs +5 -5
  143. package/dist/components/input/ColorPicker.cjs.map +1 -1
  144. package/dist/components/input/ColorPicker.mjs +142 -165
  145. package/dist/components/input/ColorPicker.mjs.map +1 -1
  146. package/dist/components/input/ColorPicker.parts.cjs +2 -0
  147. package/dist/components/input/ColorPicker.parts.cjs.map +1 -0
  148. package/dist/components/input/ColorPicker.parts.mjs +192 -0
  149. package/dist/components/input/ColorPicker.parts.mjs.map +1 -0
  150. package/dist/components/input/ColorSlider.cjs +2 -0
  151. package/dist/components/input/ColorSlider.cjs.map +1 -0
  152. package/dist/components/input/ColorSlider.mjs +138 -0
  153. package/dist/components/input/ColorSlider.mjs.map +1 -0
  154. package/dist/components/input/Combobox.cjs +1 -1
  155. package/dist/components/input/Combobox.cjs.map +1 -1
  156. package/dist/components/input/Combobox.expand.cjs +1 -1
  157. package/dist/components/input/Combobox.expand.cjs.map +1 -1
  158. package/dist/components/input/Combobox.expand.mjs +9 -9
  159. package/dist/components/input/Combobox.expand.mjs.map +1 -1
  160. package/dist/components/input/Combobox.mjs +90 -85
  161. package/dist/components/input/Combobox.mjs.map +1 -1
  162. package/dist/components/input/DatePicker.cjs +1 -1
  163. package/dist/components/input/DatePicker.cjs.map +1 -1
  164. package/dist/components/input/DatePicker.mjs +186 -185
  165. package/dist/components/input/DatePicker.mjs.map +1 -1
  166. package/dist/components/input/Dropdown.cjs +1 -1
  167. package/dist/components/input/Dropdown.cjs.map +1 -1
  168. package/dist/components/input/Dropdown.mjs +71 -68
  169. package/dist/components/input/Dropdown.mjs.map +1 -1
  170. package/dist/components/input/Field.cjs +1 -1
  171. package/dist/components/input/Field.cjs.map +1 -1
  172. package/dist/components/input/Field.mjs +113 -112
  173. package/dist/components/input/Field.mjs.map +1 -1
  174. package/dist/components/input/Input.cjs +1 -1
  175. package/dist/components/input/Input.cjs.map +1 -1
  176. package/dist/components/input/Input.mjs +55 -54
  177. package/dist/components/input/Input.mjs.map +1 -1
  178. package/dist/components/input/Label.cjs +1 -1
  179. package/dist/components/input/Label.cjs.map +1 -1
  180. package/dist/components/input/Label.mjs +12 -11
  181. package/dist/components/input/Label.mjs.map +1 -1
  182. package/dist/components/input/Option.cjs +1 -1
  183. package/dist/components/input/Option.cjs.map +1 -1
  184. package/dist/components/input/Option.mjs +100 -98
  185. package/dist/components/input/Option.mjs.map +1 -1
  186. package/dist/components/input/RadioGroup.cjs +1 -1
  187. package/dist/components/input/RadioGroup.cjs.map +1 -1
  188. package/dist/components/input/RadioGroup.mjs +89 -88
  189. package/dist/components/input/RadioGroup.mjs.map +1 -1
  190. package/dist/components/input/Rating.cjs +1 -1
  191. package/dist/components/input/Rating.cjs.map +1 -1
  192. package/dist/components/input/Rating.mjs +110 -109
  193. package/dist/components/input/Rating.mjs.map +1 -1
  194. package/dist/components/input/SearchBox.cjs +1 -1
  195. package/dist/components/input/SearchBox.cjs.map +1 -1
  196. package/dist/components/input/SearchBox.mjs +118 -119
  197. package/dist/components/input/SearchBox.mjs.map +1 -1
  198. package/dist/components/input/Select.cjs +1 -1
  199. package/dist/components/input/Select.cjs.map +1 -1
  200. package/dist/components/input/Select.mjs +25 -24
  201. package/dist/components/input/Select.mjs.map +1 -1
  202. package/dist/components/input/Slider.cjs +1 -1
  203. package/dist/components/input/Slider.cjs.map +1 -1
  204. package/dist/components/input/Slider.mjs +47 -46
  205. package/dist/components/input/Slider.mjs.map +1 -1
  206. package/dist/components/input/SpinButton.cjs +1 -1
  207. package/dist/components/input/SpinButton.cjs.map +1 -1
  208. package/dist/components/input/SpinButton.mjs +76 -75
  209. package/dist/components/input/SpinButton.mjs.map +1 -1
  210. package/dist/components/input/SwatchPicker.cjs +1 -1
  211. package/dist/components/input/SwatchPicker.cjs.map +1 -1
  212. package/dist/components/input/SwatchPicker.mjs +38 -37
  213. package/dist/components/input/SwatchPicker.mjs.map +1 -1
  214. package/dist/components/input/Switch.cjs +1 -1
  215. package/dist/components/input/Switch.cjs.map +1 -1
  216. package/dist/components/input/Switch.mjs +65 -64
  217. package/dist/components/input/Switch.mjs.map +1 -1
  218. package/dist/components/input/TagPicker.cjs +1 -1
  219. package/dist/components/input/TagPicker.cjs.map +1 -1
  220. package/dist/components/input/TagPicker.mjs +161 -157
  221. package/dist/components/input/TagPicker.mjs.map +1 -1
  222. package/dist/components/input/Textarea.cjs +1 -1
  223. package/dist/components/input/Textarea.cjs.map +1 -1
  224. package/dist/components/input/Textarea.mjs +24 -23
  225. package/dist/components/input/Textarea.mjs.map +1 -1
  226. package/dist/components/input/TimePicker.cjs +1 -1
  227. package/dist/components/input/TimePicker.cjs.map +1 -1
  228. package/dist/components/input/TimePicker.mjs +202 -199
  229. package/dist/components/input/TimePicker.mjs.map +1 -1
  230. package/dist/components/input/colorName.cjs +2 -0
  231. package/dist/components/input/colorName.cjs.map +1 -0
  232. package/dist/components/input/colorName.mjs +30 -0
  233. package/dist/components/input/colorName.mjs.map +1 -0
  234. package/dist/components/input/colorUtils.cjs +1 -1
  235. package/dist/components/input/colorUtils.cjs.map +1 -1
  236. package/dist/components/input/colorUtils.mjs +154 -56
  237. package/dist/components/input/colorUtils.mjs.map +1 -1
  238. package/dist/components/layout/Accordion.cjs +1 -1
  239. package/dist/components/layout/Accordion.cjs.map +1 -1
  240. package/dist/components/layout/Accordion.mjs +130 -129
  241. package/dist/components/layout/Accordion.mjs.map +1 -1
  242. package/dist/components/layout/Card.cjs +1 -1
  243. package/dist/components/layout/Card.cjs.map +1 -1
  244. package/dist/components/layout/Card.mjs +78 -77
  245. package/dist/components/layout/Card.mjs.map +1 -1
  246. package/dist/components/layout/Carousel.cjs +1 -1
  247. package/dist/components/layout/Carousel.cjs.map +1 -1
  248. package/dist/components/layout/Carousel.mjs +111 -110
  249. package/dist/components/layout/Carousel.mjs.map +1 -1
  250. package/dist/components/layout/Flex.cjs +1 -1
  251. package/dist/components/layout/Flex.cjs.map +1 -1
  252. package/dist/components/layout/Flex.mjs +22 -21
  253. package/dist/components/layout/Flex.mjs.map +1 -1
  254. package/dist/components/layout/Grid.cjs +1 -1
  255. package/dist/components/layout/Grid.cjs.map +1 -1
  256. package/dist/components/layout/Grid.mjs +19 -18
  257. package/dist/components/layout/Grid.mjs.map +1 -1
  258. package/dist/components/layout/Overflow.cjs +1 -1
  259. package/dist/components/layout/Overflow.cjs.map +1 -1
  260. package/dist/components/layout/Overflow.mjs +92 -91
  261. package/dist/components/layout/Overflow.mjs.map +1 -1
  262. package/dist/components/layout/Stack.cjs +1 -1
  263. package/dist/components/layout/Stack.cjs.map +1 -1
  264. package/dist/components/layout/Stack.mjs +14 -13
  265. package/dist/components/layout/Stack.mjs.map +1 -1
  266. package/dist/components/layout/TabList.cjs +1 -1
  267. package/dist/components/layout/TabList.cjs.map +1 -1
  268. package/dist/components/layout/TabList.mjs +118 -117
  269. package/dist/components/layout/TabList.mjs.map +1 -1
  270. package/dist/components/layout/Tree.cjs +1 -1
  271. package/dist/components/layout/Tree.cjs.map +1 -1
  272. package/dist/components/layout/Tree.context.cjs +2 -0
  273. package/dist/components/layout/Tree.context.cjs.map +1 -0
  274. package/dist/components/layout/Tree.context.mjs +33 -0
  275. package/dist/components/layout/Tree.context.mjs.map +1 -0
  276. package/dist/components/layout/Tree.core.cjs +2 -0
  277. package/dist/components/layout/Tree.core.cjs.map +1 -0
  278. package/dist/components/layout/Tree.core.mjs +416 -0
  279. package/dist/components/layout/Tree.core.mjs.map +1 -0
  280. package/dist/components/layout/Tree.itemPersonaLayout.cjs +2 -0
  281. package/dist/components/layout/Tree.itemPersonaLayout.cjs.map +1 -0
  282. package/dist/components/layout/Tree.itemPersonaLayout.mjs +46 -0
  283. package/dist/components/layout/Tree.itemPersonaLayout.mjs.map +1 -0
  284. package/dist/components/layout/Tree.mjs +7 -215
  285. package/dist/components/layout/Tree.mjs.map +1 -1
  286. package/dist/components/layout/Tree.selection.cjs +2 -0
  287. package/dist/components/layout/Tree.selection.cjs.map +1 -0
  288. package/dist/components/layout/Tree.selection.mjs +73 -0
  289. package/dist/components/layout/Tree.selection.mjs.map +1 -0
  290. package/dist/components/navigation/Breadcrumb.cjs +1 -1
  291. package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
  292. package/dist/components/navigation/Breadcrumb.mjs +76 -75
  293. package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
  294. package/dist/components/navigation/Menu.group.cjs +1 -1
  295. package/dist/components/navigation/Menu.group.cjs.map +1 -1
  296. package/dist/components/navigation/Menu.group.mjs +39 -37
  297. package/dist/components/navigation/Menu.group.mjs.map +1 -1
  298. package/dist/components/navigation/Menu.items.cjs +1 -1
  299. package/dist/components/navigation/Menu.items.cjs.map +1 -1
  300. package/dist/components/navigation/Menu.items.mjs +67 -61
  301. package/dist/components/navigation/Menu.items.mjs.map +1 -1
  302. package/dist/components/navigation/Menu.link.cjs +1 -1
  303. package/dist/components/navigation/Menu.link.cjs.map +1 -1
  304. package/dist/components/navigation/Menu.link.mjs +34 -28
  305. package/dist/components/navigation/Menu.link.mjs.map +1 -1
  306. package/dist/components/navigation/Menu.popover.cjs +1 -1
  307. package/dist/components/navigation/Menu.popover.cjs.map +1 -1
  308. package/dist/components/navigation/Menu.popover.mjs +110 -109
  309. package/dist/components/navigation/Menu.popover.mjs.map +1 -1
  310. package/dist/components/navigation/Menu.root.cjs +1 -1
  311. package/dist/components/navigation/Menu.root.cjs.map +1 -1
  312. package/dist/components/navigation/Menu.root.mjs +171 -170
  313. package/dist/components/navigation/Menu.root.mjs.map +1 -1
  314. package/dist/components/navigation/Menu.selectable.cjs +1 -1
  315. package/dist/components/navigation/Menu.selectable.cjs.map +1 -1
  316. package/dist/components/navigation/Menu.selectable.mjs +85 -63
  317. package/dist/components/navigation/Menu.selectable.mjs.map +1 -1
  318. package/dist/components/navigation/Menu.splitGroup.cjs +1 -1
  319. package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -1
  320. package/dist/components/navigation/Menu.splitGroup.mjs +27 -26
  321. package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -1
  322. package/dist/components/navigation/Menu.trigger.cjs +1 -1
  323. package/dist/components/navigation/Menu.trigger.cjs.map +1 -1
  324. package/dist/components/navigation/Menu.trigger.mjs +6 -6
  325. package/dist/components/navigation/Nav.cjs +1 -1
  326. package/dist/components/navigation/Nav.cjs.map +1 -1
  327. package/dist/components/navigation/Nav.mjs +170 -155
  328. package/dist/components/navigation/Nav.mjs.map +1 -1
  329. package/dist/components/navigation/Pagination.cjs +1 -1
  330. package/dist/components/navigation/Pagination.cjs.map +1 -1
  331. package/dist/components/navigation/Pagination.mjs +73 -65
  332. package/dist/components/navigation/Pagination.mjs.map +1 -1
  333. package/dist/components/navigation/Stepper.cjs +1 -1
  334. package/dist/components/navigation/Stepper.cjs.map +1 -1
  335. package/dist/components/navigation/Stepper.mjs +110 -109
  336. package/dist/components/navigation/Stepper.mjs.map +1 -1
  337. package/dist/components/overlays/Dialog.cjs +1 -1
  338. package/dist/components/overlays/Dialog.cjs.map +1 -1
  339. package/dist/components/overlays/Dialog.mjs +109 -108
  340. package/dist/components/overlays/Dialog.mjs.map +1 -1
  341. package/dist/components/overlays/Drawer.cjs +1 -1
  342. package/dist/components/overlays/Drawer.cjs.map +1 -1
  343. package/dist/components/overlays/Drawer.mjs +110 -109
  344. package/dist/components/overlays/Drawer.mjs.map +1 -1
  345. package/dist/components/overlays/Popover.cjs +1 -1
  346. package/dist/components/overlays/Popover.cjs.map +1 -1
  347. package/dist/components/overlays/Popover.mjs +229 -227
  348. package/dist/components/overlays/Popover.mjs.map +1 -1
  349. package/dist/components/overlays/TeachingPopover.cjs +1 -1
  350. package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
  351. package/dist/components/overlays/TeachingPopover.mjs +41 -37
  352. package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
  353. package/dist/components/overlays/Tooltip.cjs +1 -1
  354. package/dist/components/overlays/Tooltip.cjs.map +1 -1
  355. package/dist/components/overlays/Tooltip.mjs +87 -86
  356. package/dist/components/overlays/Tooltip.mjs.map +1 -1
  357. package/dist/components/portal/Portal.cjs +1 -1
  358. package/dist/components/portal/Portal.cjs.map +1 -1
  359. package/dist/components/portal/Portal.mjs +33 -32
  360. package/dist/components/portal/Portal.mjs.map +1 -1
  361. package/dist/components/provider/WaveProvider.cjs +1 -1
  362. package/dist/components/provider/WaveProvider.cjs.map +1 -1
  363. package/dist/components/provider/WaveProvider.mjs +31 -30
  364. package/dist/components/provider/WaveProvider.mjs.map +1 -1
  365. package/dist/components/table/DataGrid.cjs +1 -1
  366. package/dist/components/table/DataGrid.cjs.map +1 -1
  367. package/dist/components/table/DataGrid.mjs +228 -227
  368. package/dist/components/table/DataGrid.mjs.map +1 -1
  369. package/dist/components/table/Table.cjs +1 -1
  370. package/dist/components/table/Table.cjs.map +1 -1
  371. package/dist/components/table/Table.mjs +60 -59
  372. package/dist/components/table/Table.mjs.map +1 -1
  373. package/dist/components/typography/Text.cjs +1 -1
  374. package/dist/components/typography/Text.cjs.map +1 -1
  375. package/dist/components/typography/Text.mjs +12 -11
  376. package/dist/components/typography/Text.mjs.map +1 -1
  377. package/dist/hooks/useMediaQuery.cjs +2 -0
  378. package/dist/hooks/useMediaQuery.cjs.map +1 -0
  379. package/dist/hooks/useMediaQuery.mjs +20 -0
  380. package/dist/hooks/useMediaQuery.mjs.map +1 -0
  381. package/dist/hooks/usePrefersReducedMotion.cjs +1 -1
  382. package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -1
  383. package/dist/hooks/usePrefersReducedMotion.mjs +4 -18
  384. package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -1
  385. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  386. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  387. package/dist/hooks/useRovingTabIndex.mjs +3 -3
  388. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  389. package/dist/index.cjs +1 -1
  390. package/dist/index.d.cts +2089 -102
  391. package/dist/index.d.ts +2089 -102
  392. package/dist/index.mjs +99 -87
  393. package/dist/lib/classNames.cjs +2 -0
  394. package/dist/lib/classNames.cjs.map +1 -0
  395. package/dist/lib/classNames.mjs +415 -0
  396. package/dist/lib/classNames.mjs.map +1 -0
  397. package/dist/lib/color.cjs +2 -0
  398. package/dist/lib/color.cjs.map +1 -0
  399. package/dist/lib/color.mjs +86 -0
  400. package/dist/lib/color.mjs.map +1 -0
  401. package/dist/lib/globalRegistry.cjs.map +1 -1
  402. package/dist/lib/globalRegistry.mjs.map +1 -1
  403. package/dist/lib/toaster.cjs +2 -0
  404. package/dist/lib/toaster.cjs.map +1 -0
  405. package/dist/lib/toaster.mjs +77 -0
  406. package/dist/lib/toaster.mjs.map +1 -0
  407. package/dist/styles.css +1 -1
  408. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/slot.cjs"),a=require("../../hooks/useId.cjs"),o=require("../../lib/styles.cjs"),s=require("../button/Button.cjs"),c=require("../../lib/icons.cjs"),l=require("../../lib/mergeProps.cjs"),u=require("../button/Button.slots.cjs"),d=require("../../lib/labelInName.cjs");let f=require("react");f=e.__toESM(f,1);let p=require("react/jsx-runtime");var m=new Set([`type`,`disabled`,`autoFocus`,`form`,`formAction`,`formEncType`,`formMethod`,`formNoValidate`,`formTarget`,`name`,`value`]),h=/^on[A-Z]/,g=new Set([`aria-label`,`aria-labelledby`]),_=()=>{};function v(e){let t={},n=!1;for(let[r,i]of Object.entries(e))g.has(r)?i!==void 0&&(n=!0):t[r]=i;return{props:t,ignoredName:n}}var y=`inline-flex items-center justify-center`;function b(e){if(typeof e!=`object`||!e||f.isValidElement(e)||Symbol.iterator in e)return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function x(){return(0,p.jsx)(c.DismissIcon,{size:12})}function S(e){if(!i.slotRendersContent(e))return{buttonProps:null,content:x(),warning:null,ignoredName:!1,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!1};let t=n.getElementType(e);if(f.isValidElement(e)&&(t===`button`||t===s.Button)){let{children:n,dangerouslySetInnerHTML:r,...a}=e.props,o=t===s.Button,c=a;if(o){c={};for(let[e,t]of Object.entries(a))u.BUTTON_OWN_PROP_KEYS.has(e)||(c[e]=t)}let l=o?a.icon:void 0,{props:f,ignoredName:m}=v(c),h=i.slotRendersContent(l)?i.renderSlot(l,`span`,y,{"aria-hidden":!0}):null,g=r==null?i.materialiseSlotContent(n):(0,p.jsx)(`span`,{className:y,dangerouslySetInnerHTML:r});return{buttonProps:f,content:h||i.slotRendersContent(g)?u.placeButtonIcon(h,g,o&&a.iconPosition):x(),warning:`button-element`,ignoredName:m,contentMayName:!0,literalTextLabel:d.hasTextLabel(g),disabledFocusable:o&&!!a.disabledFocusable}}if(b(e)){let t=e.as===s.Button,n=e.as===`button`||t||Object.keys(e).some(e=>m.has(e)||h.test(e)),r={},a={},o={},c=!1;for(let[i,s]of Object.entries(e))i===`as`?s!==`button`&&!t&&(a.as=s):t&&u.BUTTON_OWN_PROP_KEYS.has(i)?o[i]=s:g.has(i)?s!==void 0&&(c=!0):i===`children`||i===`dangerouslySetInnerHTML`?a[i]=s:n||i.startsWith(`aria-`)&&i!==`aria-hidden`?r[i]=s:a[i]=s;return i.slotRendersContent(o.icon)?a.children=u.placeButtonIcon(i.renderSlot(o.icon,`span`,y),i.materialiseSlotContent(a.children),o.iconPosition):i.slotWrapsDefaultContent(a.as??`span`,a)&&(a.children=x()),{buttonProps:n||Object.keys(r).length>0?r:null,content:i.renderSlot(a,`span`,y,{"aria-hidden":!0}),warning:n?`button-object`:null,ignoredName:c,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!!o.disabledFocusable}}return{buttonProps:null,content:i.renderSlot(e,`span`,y,{"aria-hidden":!0}),warning:null,ignoredName:!1,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!1}}var C=e=>{let{as:n,dismissible:i,onDismiss:s,dismissIcon:c,dismissLabel:m=`Dismiss`,className:h,children:g,ref:v,...y}=e,b=n??`span`,x=a.useId(`tag-content`),C=a.useId(`tag-dismiss`),w=a.useId(`tag-dismiss-text`),{buttonProps:T,content:E,warning:D,ignoredName:O,contentMayName:k,literalTextLabel:A,disabledFocusable:j}=S(i?c:void 0),[M,N]=f.useState(null),P=f.useCallback(e=>M?d.observeTextLabel(M,e):_,[M]),F=f.useSyncExternalStore(P,()=>M?d.hasRenderedTextLabel(M):A,()=>A),I=k&&F;f.useEffect(()=>{D===`button-element`?r.warnOnce(`Tag:dismissIcon-button`,"Tag: `dismissIcon` received a button. Its props were merged into the built-in dismiss button (a button cannot contain another button), which is named by its text label (or `dismissLabel`) and the tag content. Pass icon content instead, e.g. `dismissIcon={<CloseIcon />}`, and handle the dismissal in `onDismiss`."):D===`button-object`&&r.warnDeprecated(`Tag`,`dismissIcon={{ onClick, type, disabled, … }} (button props on the slot object)`,`onDismiss and icon content in dismissIcon`,"Its props are merged onto the built-in dismiss button, which is named by `dismissLabel` and the tag content.")},[D]);let L=i===void 0&&(s!==void 0||c!==void 0);f.useEffect(()=>{L&&r.warnOnce(`Tag:dismiss-without-dismissible`,"Tag: `onDismiss` and `dismissIcon` take effect only with `dismissible`; no dismiss button was rendered. Add `dismissible` to render it.")},[L]),f.useEffect(()=>{O&&r.warnOnce(`Tag:dismissIcon-name`,'Tag: `aria-label`/`aria-labelledby` on `dismissIcon` are ignored. The dismiss button is named by `dismissLabel` (default "Dismiss") and the tag content, e.g. "Dismiss Cherry"; set `dismissLabel` to change or localise it.')},[O]);let R={type:`button`,className:t.cn(`inline-flex size-5 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 text-foreground`,`not-disabled:not-aria-disabled:hover:bg-subtle-pressed`,`disabled:cursor-not-allowed disabled:opacity-50`,u.mergedAriaDisabledClasses,o.focusRing),"aria-labelledby":`${I?w:C} ${x}`};s&&(R.onClick=s);let z=T?l.mergeProps(R,T):R;return(0,p.jsxs)(b,{ref:v,className:t.cn(`inline-flex items-center gap-1 rounded-full bg-muted py-1 ps-3 text-body-1 text-foreground`,i?`pe-1.5`:`pe-3`,h),...y,children:[(0,p.jsx)(`span`,{id:x,className:`inline-flex items-center gap-1`,children:g}),i&&(0,p.jsxs)(`button`,{...z,type:z.type??`button`,...j?u.MERGED_DISABLED_FOCUSABLE_PROPS:void 0,children:[(0,p.jsx)(`span`,{id:C,className:`sr-only`,children:m}),k?(0,p.jsx)(`span`,{id:w,ref:N,className:`inline-flex items-center justify-center gap-[inherit]`,children:E}):E]})]})};C.displayName=`Tag`,exports.Tag=C;
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/classNames.cjs"),o=require("../../hooks/useId.cjs"),s=require("../../lib/styles.cjs"),c=require("../button/Button.cjs"),l=require("../button/Button.slots.cjs"),u=require("../../lib/icons.cjs"),d=require("../../lib/mergeProps.cjs"),f=require("../../lib/labelInName.cjs");let p=require("react");p=e.__toESM(p,1);let m=require("react/jsx-runtime");var h=new Set([`type`,`disabled`,`autoFocus`,`form`,`formAction`,`formEncType`,`formMethod`,`formNoValidate`,`formTarget`,`name`,`value`]),g=/^on[A-Z]/,_=new Set([`aria-label`,`aria-labelledby`]),v=()=>{};function y(e){let t={},n=!1;for(let[r,i]of Object.entries(e))_.has(r)?i!==void 0&&(n=!0):t[r]=i;return{props:t,ignoredName:n}}var b=`inline-flex items-center justify-center`;function x(e){if(typeof e!=`object`||!e||p.isValidElement(e)||Symbol.iterator in e)return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function S(e){return(0,m.jsx)(u.DismissIcon,{size:12,className:e})}function C(e){if(!i.slotRendersContent(e))return{buttonProps:null,content:S(a.tagClassNames.dismissIcon),warning:null,ignoredName:!1,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!1};let r=n.getElementType(e);if(p.isValidElement(e)&&(r===`button`||r===c.Button)){let{children:n,dangerouslySetInnerHTML:o,...s}=e.props,u=r===c.Button,d=s;if(u){d={};for(let[e,t]of Object.entries(s))l.BUTTON_OWN_PROP_KEYS.has(e)||(d[e]=t)}let p=u?s.icon:void 0,{props:h,ignoredName:g}=y(d),_=i.slotRendersContent(p)?i.renderSlot(p,`span`,t.cn(a.tagClassNames.dismissIcon,b),{"aria-hidden":!0}):null,v=o==null?i.materialiseSlotContent(n):(0,m.jsx)(`span`,{className:b,dangerouslySetInnerHTML:o});return{buttonProps:h,content:_||i.slotRendersContent(v)?l.placeButtonIcon(_,v,u&&s.iconPosition):S(a.tagClassNames.dismissIcon),warning:`button-element`,ignoredName:g,contentMayName:!0,literalTextLabel:f.hasTextLabel(v),disabledFocusable:u&&!!s.disabledFocusable}}if(x(e)){let n=e.as===c.Button,r=e.as===`button`||n||Object.keys(e).some(e=>h.has(e)||g.test(e)),o={},s={},u={},d=!1;for(let[t,i]of Object.entries(e))t===`as`?i!==`button`&&!n&&(s.as=i):n&&l.BUTTON_OWN_PROP_KEYS.has(t)?u[t]=i:_.has(t)?i!==void 0&&(d=!0):t===`children`||t===`dangerouslySetInnerHTML`?s[t]=i:r||t.startsWith(`aria-`)&&t!==`aria-hidden`?o[t]=i:s[t]=i;let f=i.slotRendersContent(u.icon);return f?s.children=l.placeButtonIcon(i.renderSlot(u.icon,`span`,t.cn(a.tagClassNames.dismissIcon,b)),i.materialiseSlotContent(s.children),u.iconPosition):i.slotWrapsDefaultContent(s.as??`span`,s)&&(s.children=S()),{buttonProps:r||Object.keys(o).length>0?o:null,content:i.renderSlot(s,`span`,t.cn(!f&&a.tagClassNames.dismissIcon,b),{"aria-hidden":!0}),warning:r?`button-object`:null,ignoredName:d,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!!u.disabledFocusable}}return{buttonProps:null,content:i.renderSlot(e,`span`,t.cn(a.tagClassNames.dismissIcon,b),{"aria-hidden":!0}),warning:null,ignoredName:!1,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!1}}var w=e=>{let{as:n,dismissible:i,onDismiss:c,dismissIcon:u,dismissLabel:h=`Dismiss`,className:g,children:_,ref:y,...b}=e,x=n??`span`,S=o.useId(`tag-content`),w=o.useId(`tag-dismiss`),T=o.useId(`tag-dismiss-text`),{buttonProps:E,content:D,warning:O,ignoredName:k,contentMayName:A,literalTextLabel:j,disabledFocusable:M}=C(i?u:void 0),[N,P]=p.useState(null),F=p.useCallback(e=>N?f.observeTextLabel(N,e):v,[N]),I=p.useSyncExternalStore(F,()=>N?f.hasRenderedTextLabel(N):j,()=>j),L=A&&I;p.useEffect(()=>{O===`button-element`?r.warnOnce(`Tag:dismissIcon-button`,"Tag: `dismissIcon` received a button. Its props were merged into the built-in dismiss button (a button cannot contain another button), which is named by its text label (or `dismissLabel`) and the tag content. Pass icon content instead, e.g. `dismissIcon={<CloseIcon />}`, and handle the dismissal in `onDismiss`."):O===`button-object`&&r.warnDeprecated(`Tag`,`dismissIcon={{ onClick, type, disabled, … }} (button props on the slot object)`,`onDismiss and icon content in dismissIcon`,"Its props are merged onto the built-in dismiss button, which is named by `dismissLabel` and the tag content.")},[O]);let R=i===void 0&&(c!==void 0||u!==void 0);p.useEffect(()=>{R&&r.warnOnce(`Tag:dismiss-without-dismissible`,"Tag: `onDismiss` and `dismissIcon` take effect only with `dismissible`; no dismiss button was rendered. Add `dismissible` to render it.")},[R]),p.useEffect(()=>{k&&r.warnOnce(`Tag:dismissIcon-name`,'Tag: `aria-label`/`aria-labelledby` on `dismissIcon` are ignored. The dismiss button is named by `dismissLabel` (default "Dismiss") and the tag content, e.g. "Dismiss Cherry"; set `dismissLabel` to change or localise it.')},[k]);let z={type:`button`,className:t.cn(a.tagClassNames.dismissButton,`inline-flex size-5 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 text-foreground`,`not-disabled:not-aria-disabled:hover:bg-subtle-pressed`,`disabled:cursor-not-allowed disabled:opacity-50`,l.mergedAriaDisabledClasses,s.focusRing),"aria-labelledby":`${L?T:w} ${S}`};c&&(z.onClick=c);let B=E?d.mergeProps(z,E):z;return(0,m.jsxs)(x,{ref:y,className:t.cn(a.tagClassNames.root,`inline-flex items-center gap-1 rounded-full bg-muted py-1 ps-3 text-body-1 text-foreground`,i?`pe-1.5`:`pe-3`,g),...b,children:[(0,m.jsx)(`span`,{id:S,className:t.cn(a.tagClassNames.primaryText,`inline-flex items-center gap-1`),children:_}),i&&(0,m.jsxs)(`button`,{...B,type:B.type??`button`,...M?l.MERGED_DISABLED_FOCUSABLE_PROPS:void 0,children:[(0,m.jsx)(`span`,{id:w,className:`sr-only`,children:h}),A?(0,m.jsx)(`span`,{id:T,ref:P,className:`inline-flex items-center justify-center gap-[inherit]`,children:D}):D]})]})};w.displayName=`Tag`,exports.Tag=w;
2
2
  //# sourceMappingURL=Tag.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tag.cjs","names":["React","DismissIcon","slotRendersContent","getElementType","Button","BUTTON_OWN_PROP_KEYS","renderSlot","materialiseSlotContent","placeButtonIcon","hasTextLabel","slotWrapsDefaultContent","useId","observeTextLabel","hasRenderedTextLabel","cn","mergedAriaDisabledClasses","focusRing","mergeProps","MERGED_DISABLED_FOCUSABLE_PROPS","require_runtime","require_cn","require_children","require_dev","require_slot","require_useId","require_styles","require_Button","require_icons","require_mergeProps","require_Button_slots","require_labelInName","react","react_jsx_runtime","BUTTON_ONLY_KEYS","HANDLER_KEY","NAME_KEYS","noop","withoutName","result","ignoredName","key","value","props","iconClassName","isPlainObject","proto","defaultDismissContent","resolveDismissSlot","slot","elementType","markup","elementProps","isWaveButton","slotProps","icon","buttonProps","iconNode","ownContent","children","asWaveButton","isButtonObject","contentProps","ownProps","Tag","rest","Component","as","contentId","dismissLabelId","dismissTextId","slotButtonProps","dismissible","dismissIcon","labelTarget","setLabelTarget","subscribeToContent","onChange","contentHasTextLabel","literalTextLabel","namedByContent","contentMayName","warning","dismissPropsIgnored","onDismiss","ownButtonProps","dismissButtonProps","className","disabledFocusable","dismissLabel","content"],"sources":["../../../src/components/data-display/Tag.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { mergeProps } from '../../lib/mergeProps';\nimport { getElementType } from '../../lib/children';\nimport {\n materialiseSlotContent,\n renderSlot,\n slotRendersContent,\n slotWrapsDefaultContent,\n} from '../../lib/slot';\nimport { focusRing } from '../../lib/styles';\nimport { DismissIcon } from '../../lib/icons';\nimport { hasRenderedTextLabel, hasTextLabel, observeTextLabel } from '../../lib/labelInName';\nimport type { Slot, SlotObject } from '../../lib/slot';\nimport type { PolymorphicComponent, PolymorphicProps } from '../../lib/polymorphic';\nimport { useId } from '../../hooks/useId';\nimport { Button } from '../button/Button';\nimport {\n BUTTON_OWN_PROP_KEYS,\n MERGED_DISABLED_FOCUSABLE_PROPS,\n mergedAriaDisabledClasses,\n placeButtonIcon,\n} from '../button/Button.slots';\n\n/**\n * The Tag's own props (the XOwnProps rule of `PolymorphicProps`: component-specific props only).\n * Every other prop comes from the rendered element (`as`, default `span`).\n */\nexport interface TagOwnProps {\n /**\n * Whether the tag renders a dismiss button. `onDismiss` and `dismissIcon` take effect only with\n * it (a development warning says so when they are passed without it).\n */\n dismissible?: boolean;\n /**\n * Called when the dismiss button is activated (click, Enter or Space). Passing it does not render\n * the dismiss button: set `dismissible` too. When it removes the tag, move focus yourself (see\n * \"Focus after dismissal\" on {@link Tag}).\n */\n onDismiss?: () => void;\n /**\n * Content of the dismiss button (an icon). The Tag always renders its own dismiss\n * `<button type=\"button\">`, wired to `onDismiss` and named by `dismissLabel` plus the tag\n * content; this slot only replaces the icon inside it.\n *\n * A `<button>` element or a Wave `Button` passed here is not nested (a button cannot contain a\n * button): its props are merged into the dismiss button (its `onClick` runs first and can call\n * `preventDefault()` to skip `onDismiss`) and a development warning recommends icon content.\n * A Wave `Button`'s own props are not attributes: its `icon` becomes decorative content before\n * its children (after them with `iconPosition=\"after\"`), `disabledFocusable` makes the dismiss\n * button unavailable but focusable as on the Button (`onDismiss` is not called), and\n * `appearance` and `size` are ignored.\n * A slot object with button props (`type`, `disabled`, event handlers, `as: 'button'` or\n * `as: Button`) is the deprecated 0.4 button-object form: its props (`className`, `id`,\n * `aria-*`, handlers, …) are merged onto the dismiss button, except its content (`children`,\n * `dangerouslySetInnerHTML`, rendered inside the button) and the naming attributes (see below);\n * for `as: Button`, the Button's own props apply as for a `Button` element — pass icon content\n * and use `onDismiss` instead.\n * The `aria-*` attributes of an icon slot object also go to the dismiss button, because the icon\n * is `aria-hidden`.\n *\n * The dismiss button's name is `dismissLabel` plus the tag content (\"Dismiss Cherry\"):\n * `aria-label` and `aria-labelledby` on the slot are ignored (development warning). Icon\n * content is decorative (`aria-hidden`). The children of a merged `<button>`/`Button` (or its\n * `dangerouslySetInnerHTML` markup) are rendered as is inside the dismiss button, next to the\n * decorative `icon` of a Wave `Button`: when they render a text label (at least two letters or\n * digits outside `aria-hidden`/`hidden` content, text from components such as translations\n * included), that text replaces `dismissLabel` in the name, so the name contains the visible\n * label (WCAG 2.5.3): `<button>Remove</button>` or\n * `<Button icon={<CloseIcon />}>Remove</Button>` on \"Cherry\" is named \"Remove Cherry\". An icon or\n * a lone character (`x`, `×`) keeps \"Dismiss Cherry\". Text hidden only with CSS still counts as\n * the label.\n *\n * When the slot renders no content (`[]`, `<></>`, a childless merged button, a slot object\n * without `children`), the default dismiss icon is shown; a slot object then styles it, e.g.\n * `{ className: 'text-error' }`. A slot object that renders a component or a void element\n * (`{ as: CloseIcon }`, `{ as: 'img', src, alt: '' }`) or sets `dangerouslySetInnerHTML` is the\n * icon itself: no default icon is added. Only takes effect with `dismissible`.\n */\n dismissIcon?: Slot<'span'> | SlotObject<'button'>;\n /**\n * Visually hidden text that names the dismiss button together with the tag content\n * (`aria-labelledby`), e.g. \"Dismiss Cherry\". Localise it here. A text label rendered by a\n * merged `<button>` slot replaces it (see `dismissIcon`).\n * @default 'Dismiss'\n */\n dismissLabel?: string;\n}\n\n/**\n * Props of {@link Tag} rendered as `C` (default `'span'`). `TagProps` without a type argument is\n * the 0.4 name.\n */\nexport type TagProps<C extends React.ElementType = 'span'> = PolymorphicProps<C, TagOwnProps>;\n\n/** The props the implementation reads, for any `as` (the public typing is `PolymorphicComponent`). */\ntype TagImplProps = TagOwnProps &\n React.HTMLAttributes<HTMLElement> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n };\n\ntype UnknownProps = Record<string, unknown>;\n\n/** Attributes that only make sense on the dismiss `<button>` itself. */\nconst BUTTON_ONLY_KEYS: ReadonlySet<string> = new Set([\n 'type',\n 'disabled',\n 'autoFocus',\n 'form',\n 'formAction',\n 'formEncType',\n 'formMethod',\n 'formNoValidate',\n 'formTarget',\n 'name',\n 'value',\n]);\n\nconst HANDLER_KEY = /^on[A-Z]/;\n\n/**\n * Naming attributes a slot cannot set: the Tag names its dismiss button itself\n * (`aria-labelledby` = `dismissLabel` + tag content, data-display#10), so these are dropped.\n */\nconst NAME_KEYS: ReadonlySet<string> = new Set(['aria-label', 'aria-labelledby']);\n\n/** The props of a merged `<button>` or Wave `Button` that the Tag reads itself. */\ninterface WaveButtonSlotProps extends UnknownProps {\n icon?: Slot<'span'>;\n iconPosition?: unknown;\n disabledFocusable?: unknown;\n children?: React.ReactNode;\n dangerouslySetInnerHTML?: React.HTMLAttributes<HTMLElement>['dangerouslySetInnerHTML'];\n}\n\ninterface ResolvedDismissSlot {\n /** Props merged onto the wired dismiss button (`null`: none). */\n buttonProps: UnknownProps | null;\n /** What renders inside the dismiss button. */\n content: React.ReactNode;\n /** Which development warning the slot needs. */\n warning: 'button-element' | 'button-object' | null;\n /** Whether the slot passed `aria-label`/`aria-labelledby`, which the Tag ignores. */\n ignoredName: boolean;\n /**\n * `true` when the content is rendered as is (a merged `<button>`/`Button`), so a text label in it\n * replaces `dismissLabel` in the name (C-SLOTS naming, WCAG 2.5.3); `false` when the content is\n * decorative (`aria-hidden`).\n */\n contentMayName: boolean;\n /**\n * Whether the literal content contains a text label: the name for the server render and the\n * first client render. After mount the rendered content decides.\n */\n literalTextLabel: boolean;\n /**\n * Whether a merged Wave `Button` set `disabledFocusable`: the dismiss button is then unavailable\n * but focusable, as the Button would be.\n */\n disabledFocusable: boolean;\n}\n\nconst noop = () => {};\n\n/** `props` without the naming attributes, and whether any was set. */\nfunction withoutName(props: UnknownProps): { props: UnknownProps; ignoredName: boolean } {\n const result: UnknownProps = {};\n let ignoredName = false;\n for (const [key, value] of Object.entries(props)) {\n if (NAME_KEYS.has(key)) {\n if (value !== undefined) ignoredName = true;\n } else {\n result[key] = value;\n }\n }\n return { props: result, ignoredName };\n}\n\nconst iconClassName = 'inline-flex items-center justify-center';\n\nfunction isPlainObject(value: unknown): value is UnknownProps {\n if (typeof value !== 'object' || value === null) return false;\n if (React.isValidElement(value) || Symbol.iterator in value) return false;\n const proto: unknown = Object.getPrototypeOf(value);\n return proto === null || proto === Object.prototype;\n}\n\n/** The decorative default dismiss glyph. */\nfunction defaultDismissContent(): React.ReactNode {\n return <DismissIcon size={12} />;\n}\n\n/**\n * Splits the dismissIcon slot into dismiss-button props and icon content (C-SLOTS). The icon\n * content is `aria-hidden`, so no attribute that means something to assistive technology stays on\n * it: button-form props go to the dismiss button, and so do the `aria-*` attributes of an icon slot\n * object; the naming attributes are dropped (see {@link NAME_KEYS}).\n *\n * Content that renders nothing (`[]`, `<></>`, a childless merged button, a slot object without\n * `children`) shows the default icon, so the dismiss button is never an empty, invisible Tab stop.\n */\nfunction resolveDismissSlot(slot: TagOwnProps['dismissIcon']): ResolvedDismissSlot {\n if (!slotRendersContent(slot)) {\n return {\n buttonProps: null,\n content: defaultDismissContent(),\n warning: null,\n ignoredName: false,\n contentMayName: false,\n literalTextLabel: false,\n disabledFocusable: false,\n };\n }\n\n // A `<button>` or a Wave `Button` (also one written in a Server Component, whose type arrives as\n // a lazy reference) is merged into the dismiss button. Its content is rendered as is, after the\n // Button's icon, which is decorative (as in MessageBar and SearchBox); its text label names it.\n const elementType = getElementType(slot as React.ReactNode);\n if (\n React.isValidElement<WaveButtonSlotProps>(slot) &&\n (elementType === 'button' || elementType === Button)\n ) {\n const { children, dangerouslySetInnerHTML: markup, ...elementProps } = slot.props;\n const isWaveButton = elementType === Button;\n let slotProps: UnknownProps = elementProps;\n if (isWaveButton) {\n // Wave Button's own props are not attributes: `icon`, `iconPosition` and\n // `disabledFocusable` are applied here, the others (`appearance`, `size`) are dropped.\n slotProps = {};\n for (const [key, value] of Object.entries(elementProps)) {\n if (!BUTTON_OWN_PROP_KEYS.has(key)) slotProps[key] = value;\n }\n }\n const icon = isWaveButton ? elementProps.icon : undefined;\n const { props: buttonProps, ignoredName } = withoutName(slotProps);\n const iconNode = slotRendersContent(icon)\n ? renderSlot(icon, 'span', iconClassName, { 'aria-hidden': true })\n : null;\n // A generator is read once by the check; its items are what renders (and names the button).\n // Markup of the merged button (`dangerouslySetInnerHTML`) is its content as well: the dismiss\n // button holds its own name text, so the markup renders in a span inside it.\n const ownContent =\n markup != null ? (\n <span className={iconClassName} dangerouslySetInnerHTML={markup} />\n ) : (\n materialiseSlotContent(children)\n );\n return {\n buttonProps,\n content:\n iconNode || slotRendersContent(ownContent)\n ? placeButtonIcon(iconNode, ownContent, isWaveButton && elementProps.iconPosition)\n : defaultDismissContent(),\n warning: 'button-element',\n ignoredName,\n contentMayName: true,\n literalTextLabel: hasTextLabel(ownContent),\n disabledFocusable: isWaveButton && Boolean(elementProps.disabledFocusable),\n };\n }\n\n if (isPlainObject(slot)) {\n // 0.4 rendered the whole object as the dismiss element, so an object with button props\n // describes the button: everything but its content goes to the dismiss button. `as: Button`\n // is that form too (a button cannot contain a button); its icon becomes decorative content.\n const asWaveButton = slot.as === Button;\n const isButtonObject =\n slot.as === 'button' ||\n asWaveButton ||\n Object.keys(slot).some((key) => BUTTON_ONLY_KEYS.has(key) || HANDLER_KEY.test(key));\n const buttonProps: UnknownProps = {};\n const contentProps: UnknownProps = {};\n // Wave Button's own props are not attributes: `icon`, `iconPosition` and `disabledFocusable`\n // are applied below, the others (`appearance`, `size`) are dropped.\n const ownProps: UnknownProps = {};\n let ignoredName = false;\n for (const [key, value] of Object.entries(slot)) {\n if (key === 'as') {\n if (value !== 'button' && !asWaveButton) contentProps.as = value;\n } else if (asWaveButton && BUTTON_OWN_PROP_KEYS.has(key)) {\n ownProps[key] = value;\n } else if (NAME_KEYS.has(key)) {\n if (value !== undefined) ignoredName = true;\n } else if (key === 'children' || key === 'dangerouslySetInnerHTML') {\n // Content, also in the button-object form: the dismiss button holds its own name text.\n contentProps[key] = value;\n } else if (isButtonObject || (key.startsWith('aria-') && key !== 'aria-hidden')) {\n buttonProps[key] = value;\n } else {\n contentProps[key] = value;\n }\n }\n // An object without content styles the default icon, e.g. `{ className: 'text-error' }` (as in\n // MessageBar and SearchBox); a Wave Button's icon comes before the content (after it with\n // `iconPosition=\"after\"`).\n if (slotRendersContent(ownProps.icon)) {\n contentProps.children = placeButtonIcon(\n renderSlot(ownProps.icon as Slot<'span'>, 'span', iconClassName),\n materialiseSlotContent(contentProps.children),\n ownProps.iconPosition,\n );\n } else if (slotWrapsDefaultContent(contentProps.as ?? 'span', contentProps)) {\n contentProps.children = defaultDismissContent();\n }\n return {\n buttonProps: isButtonObject || Object.keys(buttonProps).length > 0 ? buttonProps : null,\n content: renderSlot(contentProps as SlotObject<'span'>, 'span', iconClassName, {\n 'aria-hidden': true,\n }),\n warning: isButtonObject ? 'button-object' : null,\n ignoredName,\n contentMayName: false,\n literalTextLabel: false,\n disabledFocusable: Boolean(ownProps.disabledFocusable),\n };\n }\n\n return {\n buttonProps: null,\n content: renderSlot(slot as Slot<'span'>, 'span', iconClassName, { 'aria-hidden': true }),\n warning: null,\n ignoredName: false,\n contentMayName: false,\n literalTextLabel: false,\n disabledFocusable: false,\n };\n}\n\n/**\n * A compact label (a \"chip\") for a keyword, category or filter, optionally dismissible.\n *\n * - The dismiss button is a real `<button type=\"button\">` wired to `onDismiss`. Its accessible\n * name is `dismissLabel` plus the tag content (\"Dismiss Cherry\"), so a row of tags has\n * distinguishable dismiss buttons.\n * - `dismissIcon` replaces only the icon inside that button (see {@link TagOwnProps.dismissIcon}).\n * - Polymorphic: `as=\"a\"` renders a link chip with anchor props type-checked.\n *\n * **Focus after dismissal.** A tag cannot keep focus once you remove it. When `onDismiss` removes\n * the tag, move focus to the next tag's dismiss button (else the previous one, else a sensible\n * element nearby); TagGroup (planned) will do this for you. The neighbour stays mounted, so you\n * can focus it in `onDismiss` before removing the tag.\n *\n * @example\n * <Tag>React</Tag>\n * <Tag dismissible onDismiss={() => remove('cherry')}>Cherry</Tag>\n * <Tag dismissible dismissLabel=\"Remove\" dismissIcon={<CloseIcon />}>Cherry</Tag>\n */\nexport const Tag: PolymorphicComponent<'span', TagOwnProps> = (props) => {\n const {\n as,\n dismissible,\n onDismiss,\n dismissIcon,\n dismissLabel = 'Dismiss',\n className,\n children,\n ref,\n ...rest\n } = props as TagImplProps;\n const Component: React.ElementType = as ?? 'span';\n const contentId = useId('tag-content');\n const dismissLabelId = useId('tag-dismiss');\n const dismissTextId = useId('tag-dismiss-text');\n\n const {\n buttonProps: slotButtonProps,\n content,\n warning,\n ignoredName,\n contentMayName,\n literalTextLabel,\n disabledFocusable,\n } = resolveDismissSlot(dismissible ? dismissIcon : undefined);\n\n // C-SLOTS naming (WCAG 2.5.3 Label in Name): the rendered text label of a merged button replaces\n // `dismissLabel` in the name (\"Remove Cherry\"). The literal content decides on the server and on\n // the first render; after mount, the rendered content does (text from components, later changes).\n const [labelTarget, setLabelTarget] = React.useState<HTMLSpanElement | null>(null);\n const subscribeToContent = React.useCallback(\n (onChange: () => void) => (labelTarget ? observeTextLabel(labelTarget, onChange) : noop),\n [labelTarget],\n );\n const contentHasTextLabel = React.useSyncExternalStore(\n subscribeToContent,\n () => (labelTarget ? hasRenderedTextLabel(labelTarget) : literalTextLabel),\n () => literalTextLabel,\n );\n const namedByContent = contentMayName && contentHasTextLabel;\n\n React.useEffect(() => {\n if (warning === 'button-element') {\n warnOnce(\n 'Tag:dismissIcon-button',\n 'Tag: `dismissIcon` received a button. Its props were merged into the built-in dismiss button (a button cannot contain another button), which is named by its text label (or `dismissLabel`) and the tag content. Pass icon content instead, e.g. `dismissIcon={<CloseIcon />}`, and handle the dismissal in `onDismiss`.',\n );\n } else if (warning === 'button-object') {\n warnDeprecated(\n 'Tag',\n 'dismissIcon={{ onClick, type, disabled, … }} (button props on the slot object)',\n 'onDismiss and icon content in dismissIcon',\n 'Its props are merged onto the built-in dismiss button, which is named by `dismissLabel` and the tag content.',\n );\n }\n }, [warning]);\n\n // `onDismiss`/`dismissIcon` alone render no dismiss button (unlike MessageBar's `onDismiss`).\n // An explicit `dismissible={false}` is a deliberate state, so only a missing flag warns.\n const dismissPropsIgnored =\n dismissible === undefined && (onDismiss !== undefined || dismissIcon !== undefined);\n React.useEffect(() => {\n if (dismissPropsIgnored) {\n warnOnce(\n 'Tag:dismiss-without-dismissible',\n 'Tag: `onDismiss` and `dismissIcon` take effect only with `dismissible`; no dismiss button was rendered. Add `dismissible` to render it.',\n );\n }\n }, [dismissPropsIgnored]);\n\n React.useEffect(() => {\n if (ignoredName) {\n warnOnce(\n 'Tag:dismissIcon-name',\n 'Tag: `aria-label`/`aria-labelledby` on `dismissIcon` are ignored. The dismiss button is named by `dismissLabel` (default \"Dismiss\") and the tag content, e.g. \"Dismiss Cherry\"; set `dismissLabel` to change or localise it.',\n );\n }\n }, [ignoredName]);\n\n const ownButtonProps: UnknownProps = {\n type: 'button',\n className: cn(\n 'inline-flex size-5 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 text-foreground',\n 'not-disabled:not-aria-disabled:hover:bg-subtle-pressed',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n mergedAriaDisabledClasses,\n focusRing,\n ),\n 'aria-labelledby': `${namedByContent ? dismissTextId : dismissLabelId} ${contentId}`,\n };\n if (onDismiss) ownButtonProps.onClick = onDismiss;\n const dismissButtonProps = slotButtonProps\n ? mergeProps(ownButtonProps, slotButtonProps)\n : ownButtonProps;\n\n return (\n <Component\n ref={ref}\n className={cn(\n 'inline-flex items-center gap-1 rounded-full bg-muted py-1 ps-3 text-body-1 text-foreground',\n dismissible ? 'pe-1.5' : 'pe-3',\n className,\n )}\n {...rest}\n >\n <span id={contentId} className=\"inline-flex items-center gap-1\">\n {children}\n </span>\n {dismissible && (\n <button\n {...dismissButtonProps}\n type={(dismissButtonProps.type as 'button' | 'submit' | 'reset' | undefined) ?? 'button'}\n // A merged `disabledFocusable` Button makes the dismiss button unavailable but focusable\n // (spread last: it wins over `disabled` and `onDismiss`).\n {...(disabledFocusable ? MERGED_DISABLED_FOCUSABLE_PROPS : undefined)}\n >\n <span id={dismissLabelId} className=\"sr-only\">\n {dismissLabel}\n </span>\n {contentMayName ? (\n // The merged button's own content, rendered as is: its text label can name the button.\n // `gap-[inherit]` keeps a gap set on the button between the content items.\n <span\n id={dismissTextId}\n ref={setLabelTarget}\n className=\"inline-flex items-center justify-center gap-[inherit]\"\n >\n {content}\n </span>\n ) : (\n content\n )}\n </button>\n )}\n </Component>\n );\n};\n\nTag.displayName = 'Tag';\n"],"mappings":"8gBA0GA,IAAMiC,EAAwC,IAAI,IAAI,CACpD,OACA,WACA,YACA,OACA,aACA,cACA,aACA,iBACA,aACA,OACA,OACF,CAAC,EAEKC,EAAc,WAMdC,EAAiC,IAAI,IAAI,CAAC,aAAc,iBAAiB,CAAC,EAsC1EC,MAAa,CAAC,EAGpB,SAASC,EAAY,EAAoE,CACvF,IAAMC,EAAuB,CAAC,EAC1BC,EAAc,GAClB,IAAK,GAAM,CAACC,EAAKC,KAAU,OAAO,QAAQC,CAAK,EACzCP,EAAU,IAAIK,CAAG,EACfC,IAAU,IAAA,KAAW,E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AAG,CAAC2D,CAAO,CAAC,EAIZ,IAAMC,EACJX,IAAgB,IAAA,KAAcY,IAAc,IAAA,IAAaX,IAAgB,IAAA,IAC3EzC,EAAM,cAAgB,CAChBmD,GACF5D,EAAA,SACE,kCACA,yIACF,CAEJ,EAAG,CAAC4D,CAAmB,CAAC,EAExBnD,EAAM,cAAgB,CAChBQ,GACFjB,EAAA,SACE,uBACA,8NACF,CAEJ,EAAG,CAACiB,CAAW,CAAC,EAEhB,IAAM6C,EAA+B,CACnC,KAAM,SACN,UAAWtE,EAAAA,GACT,mHACA,yDACA,kDACAC,EAAAA,0BACAC,EAAAA,SACF,EACA,kBAAmB,GAAG+D,EAAiBV,EAAgBD,EAAe,GAAGD,GAC3E,EACIgB,IAAW,EAAe,QAAUA,GACxC,IAAME,EAAqBf,EACvBrD,EAAAA,WAAWmE,EAAgBd,CAAe,EAC1Cc,EAEJ,OACE,EAAApD,EAAA,KAAA,CAACiC,EAAD,CACO,MACL,UAAWnD,EAAAA,GACT,6FACAyD,EAAc,SAAW,OACzBe,CACF,EACA,GAAItB,EAPN,SAAA,EASE,EAAAhC,EAAA,IAAA,CAAC,OAAD,CAAM,GAAImC,EAAW,UAAU,iCAC5B,UACG,CAAA,EACLI,IACC,EAAAvC,EAAA,KAAA,CAAC,SAAD,CACE,GAAIqD,EACJ,KAAOA,EAAmB,MAAsD,SAGhF,GAAKE,EAAoBrE,EAAAA,gCAAkC,IAAA,GAL7D,SAAA,EAOE,EAAAc,EAAA,IAAA,CAAC,OAAD,CAAM,GAAIoC,EAAgB,UAAU,UACjC,SAAAoB,CACG,CAAA,EACLR,GAGC,EAAAhD,EAAA,IAAA,CAAC,OAAD,CACE,GAAIqC,EACJ,IAAKK,EACL,UAAU,wDAET,SAAAe,CACG,CAAA,EAENA,CAEI,CAED,CAAA,CAAA,GAEf,EAEA,EAAI,YAAc"}
1
+ {"version":3,"file":"Tag.cjs","names":["React","DismissIcon","slotRendersContent","tagClassNames","getElementType","Button","BUTTON_OWN_PROP_KEYS","renderSlot","cn","materialiseSlotContent","placeButtonIcon","hasTextLabel","slotWrapsDefaultContent","useId","observeTextLabel","hasRenderedTextLabel","mergedAriaDisabledClasses","focusRing","mergeProps","MERGED_DISABLED_FOCUSABLE_PROPS","require_runtime","require_cn","require_children","require_dev","require_slot","require_classNames","require_useId","require_styles","require_Button","require_Button_slots","require_icons","require_mergeProps","require_labelInName","react","react_jsx_runtime","BUTTON_ONLY_KEYS","HANDLER_KEY","NAME_KEYS","noop","withoutName","result","ignoredName","key","value","props","iconClassName","isPlainObject","proto","defaultDismissContent","resolveDismissSlot","slot","elementType","markup","elementProps","isWaveButton","slotProps","icon","buttonProps","iconNode","ownContent","children","asWaveButton","isButtonObject","contentProps","ownProps","hasButtonIcon","Tag","rest","Component","as","contentId","dismissLabelId","dismissTextId","slotButtonProps","dismissible","dismissIcon","labelTarget","setLabelTarget","subscribeToContent","onChange","contentHasTextLabel","literalTextLabel","namedByContent","contentMayName","warning","dismissPropsIgnored","onDismiss","ownButtonProps","dismissButtonProps","className","disabledFocusable","dismissLabel","content"],"sources":["../../../src/components/data-display/Tag.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { tagClassNames } from '../../lib/classNames';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { mergeProps } from '../../lib/mergeProps';\nimport { getElementType } from '../../lib/children';\nimport {\n materialiseSlotContent,\n renderSlot,\n slotRendersContent,\n slotWrapsDefaultContent,\n} from '../../lib/slot';\nimport { focusRing } from '../../lib/styles';\nimport { DismissIcon } from '../../lib/icons';\nimport { hasRenderedTextLabel, hasTextLabel, observeTextLabel } from '../../lib/labelInName';\nimport type { Slot, SlotObject } from '../../lib/slot';\nimport type { PolymorphicComponent, PolymorphicProps } from '../../lib/polymorphic';\nimport { useId } from '../../hooks/useId';\nimport { Button } from '../button/Button';\nimport {\n BUTTON_OWN_PROP_KEYS,\n MERGED_DISABLED_FOCUSABLE_PROPS,\n mergedAriaDisabledClasses,\n placeButtonIcon,\n} from '../button/Button.slots';\n\n/**\n * The Tag's own props (the XOwnProps rule of `PolymorphicProps`: component-specific props only).\n * Every other prop comes from the rendered element (`as`, default `span`).\n */\nexport interface TagOwnProps {\n /**\n * Whether the tag renders a dismiss button. `onDismiss` and `dismissIcon` take effect only with\n * it (a development warning says so when they are passed without it).\n */\n dismissible?: boolean;\n /**\n * Called when the dismiss button is activated (click, Enter or Space). Passing it does not render\n * the dismiss button: set `dismissible` too. When it removes the tag, move focus yourself (see\n * \"Focus after dismissal\" on {@link Tag}).\n */\n onDismiss?: () => void;\n /**\n * Content of the dismiss button (an icon). The Tag always renders its own dismiss\n * `<button type=\"button\">`, wired to `onDismiss` and named by `dismissLabel` plus the tag\n * content; this slot only replaces the icon inside it.\n *\n * A `<button>` element or a Wave `Button` passed here is not nested (a button cannot contain a\n * button): its props are merged into the dismiss button (its `onClick` runs first and can call\n * `preventDefault()` to skip `onDismiss`) and a development warning recommends icon content.\n * A Wave `Button`'s own props are not attributes: its `icon` becomes decorative content before\n * its children (after them with `iconPosition=\"after\"`), `disabledFocusable` makes the dismiss\n * button unavailable but focusable as on the Button (`onDismiss` is not called), and\n * `appearance` and `size` are ignored.\n * A slot object with button props (`type`, `disabled`, event handlers, `as: 'button'` or\n * `as: Button`) is the deprecated 0.4 button-object form: its props (`className`, `id`,\n * `aria-*`, handlers, …) are merged onto the dismiss button, except its content (`children`,\n * `dangerouslySetInnerHTML`, rendered inside the button) and the naming attributes (see below);\n * for `as: Button`, the Button's own props apply as for a `Button` element — pass icon content\n * and use `onDismiss` instead.\n * The `aria-*` attributes of an icon slot object also go to the dismiss button, because the icon\n * is `aria-hidden`.\n *\n * The dismiss button's name is `dismissLabel` plus the tag content (\"Dismiss Cherry\"):\n * `aria-label` and `aria-labelledby` on the slot are ignored (development warning). Icon\n * content is decorative (`aria-hidden`). The children of a merged `<button>`/`Button` (or its\n * `dangerouslySetInnerHTML` markup) are rendered as is inside the dismiss button, next to the\n * decorative `icon` of a Wave `Button`: when they render a text label (at least two letters or\n * digits outside `aria-hidden`/`hidden` content, text from components such as translations\n * included), that text replaces `dismissLabel` in the name, so the name contains the visible\n * label (WCAG 2.5.3): `<button>Remove</button>` or\n * `<Button icon={<CloseIcon />}>Remove</Button>` on \"Cherry\" is named \"Remove Cherry\". An icon or\n * a lone character (`x`, `×`) keeps \"Dismiss Cherry\". Text hidden only with CSS still counts as\n * the label.\n *\n * When the slot renders no content (`[]`, `<></>`, a childless merged button, a slot object\n * without `children`), the default dismiss icon is shown; a slot object then styles it, e.g.\n * `{ className: 'text-error' }`. A slot object that renders a component or a void element\n * (`{ as: CloseIcon }`, `{ as: 'img', src, alt: '' }`) or sets `dangerouslySetInnerHTML` is the\n * icon itself: no default icon is added. Only takes effect with `dismissible`.\n */\n dismissIcon?: Slot<'span'> | SlotObject<'button'>;\n /**\n * Visually hidden text that names the dismiss button together with the tag content\n * (`aria-labelledby`), e.g. \"Dismiss Cherry\". Localise it here. A text label rendered by a\n * merged `<button>` slot replaces it (see `dismissIcon`).\n * @default 'Dismiss'\n */\n dismissLabel?: string;\n}\n\n/**\n * Props of {@link Tag} rendered as `C` (default `'span'`). `TagProps` without a type argument is\n * the 0.4 name.\n */\nexport type TagProps<C extends React.ElementType = 'span'> = PolymorphicProps<C, TagOwnProps>;\n\n/** The props the implementation reads, for any `as` (the public typing is `PolymorphicComponent`). */\ntype TagImplProps = TagOwnProps &\n React.HTMLAttributes<HTMLElement> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n };\n\ntype UnknownProps = Record<string, unknown>;\n\n/** Attributes that only make sense on the dismiss `<button>` itself. */\nconst BUTTON_ONLY_KEYS: ReadonlySet<string> = new Set([\n 'type',\n 'disabled',\n 'autoFocus',\n 'form',\n 'formAction',\n 'formEncType',\n 'formMethod',\n 'formNoValidate',\n 'formTarget',\n 'name',\n 'value',\n]);\n\nconst HANDLER_KEY = /^on[A-Z]/;\n\n/**\n * Naming attributes a slot cannot set: the Tag names its dismiss button itself\n * (`aria-labelledby` = `dismissLabel` + tag content, data-display#10), so these are dropped.\n */\nconst NAME_KEYS: ReadonlySet<string> = new Set(['aria-label', 'aria-labelledby']);\n\n/** The props of a merged `<button>` or Wave `Button` that the Tag reads itself. */\ninterface WaveButtonSlotProps extends UnknownProps {\n icon?: Slot<'span'>;\n iconPosition?: unknown;\n disabledFocusable?: unknown;\n children?: React.ReactNode;\n dangerouslySetInnerHTML?: React.HTMLAttributes<HTMLElement>['dangerouslySetInnerHTML'];\n}\n\ninterface ResolvedDismissSlot {\n /** Props merged onto the wired dismiss button (`null`: none). */\n buttonProps: UnknownProps | null;\n /** What renders inside the dismiss button. */\n content: React.ReactNode;\n /** Which development warning the slot needs. */\n warning: 'button-element' | 'button-object' | null;\n /** Whether the slot passed `aria-label`/`aria-labelledby`, which the Tag ignores. */\n ignoredName: boolean;\n /**\n * `true` when the content is rendered as is (a merged `<button>`/`Button`), so a text label in it\n * replaces `dismissLabel` in the name (C-SLOTS naming, WCAG 2.5.3); `false` when the content is\n * decorative (`aria-hidden`).\n */\n contentMayName: boolean;\n /**\n * Whether the literal content contains a text label: the name for the server render and the\n * first client render. After mount the rendered content decides.\n */\n literalTextLabel: boolean;\n /**\n * Whether a merged Wave `Button` set `disabledFocusable`: the dismiss button is then unavailable\n * but focusable, as the Button would be.\n */\n disabledFocusable: boolean;\n}\n\nconst noop = () => {};\n\n/** `props` without the naming attributes, and whether any was set. */\nfunction withoutName(props: UnknownProps): { props: UnknownProps; ignoredName: boolean } {\n const result: UnknownProps = {};\n let ignoredName = false;\n for (const [key, value] of Object.entries(props)) {\n if (NAME_KEYS.has(key)) {\n if (value !== undefined) ignoredName = true;\n } else {\n result[key] = value;\n }\n }\n return { props: result, ignoredName };\n}\n\nconst iconClassName = 'inline-flex items-center justify-center';\n\nfunction isPlainObject(value: unknown): value is UnknownProps {\n if (typeof value !== 'object' || value === null) return false;\n if (React.isValidElement(value) || Symbol.iterator in value) return false;\n const proto: unknown = Object.getPrototypeOf(value);\n return proto === null || proto === Object.prototype;\n}\n\n/**\n * The decorative default dismiss glyph. It carries the dismiss icon part class when it is the\n * dismiss button's own content, not when the element of a slot object wraps it.\n */\nfunction defaultDismissContent(className?: string): React.ReactNode {\n return <DismissIcon size={12} className={className} />;\n}\n\n/**\n * Splits the dismissIcon slot into dismiss-button props and icon content (C-SLOTS). The icon\n * content is `aria-hidden`, so no attribute that means something to assistive technology stays on\n * it: button-form props go to the dismiss button, and so do the `aria-*` attributes of an icon slot\n * object; the naming attributes are dropped (see {@link NAME_KEYS}).\n *\n * Content that renders nothing (`[]`, `<></>`, a childless merged button, a slot object without\n * `children`) shows the default icon, so the dismiss button is never an empty, invisible Tab stop.\n */\nfunction resolveDismissSlot(slot: TagOwnProps['dismissIcon']): ResolvedDismissSlot {\n if (!slotRendersContent(slot)) {\n return {\n buttonProps: null,\n content: defaultDismissContent(tagClassNames.dismissIcon),\n warning: null,\n ignoredName: false,\n contentMayName: false,\n literalTextLabel: false,\n disabledFocusable: false,\n };\n }\n\n // A `<button>` or a Wave `Button` (also one written in a Server Component, whose type arrives as\n // a lazy reference) is merged into the dismiss button. Its content is rendered as is, after the\n // Button's icon, which is decorative (as in MessageBar and SearchBox); its text label names it.\n const elementType = getElementType(slot as React.ReactNode);\n if (\n React.isValidElement<WaveButtonSlotProps>(slot) &&\n (elementType === 'button' || elementType === Button)\n ) {\n const { children, dangerouslySetInnerHTML: markup, ...elementProps } = slot.props;\n const isWaveButton = elementType === Button;\n let slotProps: UnknownProps = elementProps;\n if (isWaveButton) {\n // Wave Button's own props are not attributes: `icon`, `iconPosition` and\n // `disabledFocusable` are applied here, the others (`appearance`, `size`) are dropped.\n slotProps = {};\n for (const [key, value] of Object.entries(elementProps)) {\n if (!BUTTON_OWN_PROP_KEYS.has(key)) slotProps[key] = value;\n }\n }\n const icon = isWaveButton ? elementProps.icon : undefined;\n const { props: buttonProps, ignoredName } = withoutName(slotProps);\n const iconNode = slotRendersContent(icon)\n ? renderSlot(icon, 'span', cn(tagClassNames.dismissIcon, iconClassName), {\n 'aria-hidden': true,\n })\n : null;\n // A generator is read once by the check; its items are what renders (and names the button).\n // Markup of the merged button (`dangerouslySetInnerHTML`) is its content as well: the dismiss\n // button holds its own name text, so the markup renders in a span inside it.\n const ownContent =\n markup != null ? (\n <span className={iconClassName} dangerouslySetInnerHTML={markup} />\n ) : (\n materialiseSlotContent(children)\n );\n return {\n buttonProps,\n content:\n iconNode || slotRendersContent(ownContent)\n ? placeButtonIcon(iconNode, ownContent, isWaveButton && elementProps.iconPosition)\n : defaultDismissContent(tagClassNames.dismissIcon),\n warning: 'button-element',\n ignoredName,\n contentMayName: true,\n literalTextLabel: hasTextLabel(ownContent),\n disabledFocusable: isWaveButton && Boolean(elementProps.disabledFocusable),\n };\n }\n\n if (isPlainObject(slot)) {\n // 0.4 rendered the whole object as the dismiss element, so an object with button props\n // describes the button: everything but its content goes to the dismiss button. `as: Button`\n // is that form too (a button cannot contain a button); its icon becomes decorative content.\n const asWaveButton = slot.as === Button;\n const isButtonObject =\n slot.as === 'button' ||\n asWaveButton ||\n Object.keys(slot).some((key) => BUTTON_ONLY_KEYS.has(key) || HANDLER_KEY.test(key));\n const buttonProps: UnknownProps = {};\n const contentProps: UnknownProps = {};\n // Wave Button's own props are not attributes: `icon`, `iconPosition` and `disabledFocusable`\n // are applied below, the others (`appearance`, `size`) are dropped.\n const ownProps: UnknownProps = {};\n let ignoredName = false;\n for (const [key, value] of Object.entries(slot)) {\n if (key === 'as') {\n if (value !== 'button' && !asWaveButton) contentProps.as = value;\n } else if (asWaveButton && BUTTON_OWN_PROP_KEYS.has(key)) {\n ownProps[key] = value;\n } else if (NAME_KEYS.has(key)) {\n if (value !== undefined) ignoredName = true;\n } else if (key === 'children' || key === 'dangerouslySetInnerHTML') {\n // Content, also in the button-object form: the dismiss button holds its own name text.\n contentProps[key] = value;\n } else if (isButtonObject || (key.startsWith('aria-') && key !== 'aria-hidden')) {\n buttonProps[key] = value;\n } else {\n contentProps[key] = value;\n }\n }\n // An object without content styles the default icon, e.g. `{ className: 'text-error' }` (as in\n // MessageBar and SearchBox); a Wave Button's icon comes before the content (after it with\n // `iconPosition=\"after\"`).\n // The dismiss icon part is the merged Button's icon element when there is one, else the\n // element this slot object renders (a default glyph inside it stays without the part class).\n const hasButtonIcon = slotRendersContent(ownProps.icon);\n if (hasButtonIcon) {\n contentProps.children = placeButtonIcon(\n renderSlot(\n ownProps.icon as Slot<'span'>,\n 'span',\n cn(tagClassNames.dismissIcon, iconClassName),\n ),\n materialiseSlotContent(contentProps.children),\n ownProps.iconPosition,\n );\n } else if (slotWrapsDefaultContent(contentProps.as ?? 'span', contentProps)) {\n contentProps.children = defaultDismissContent();\n }\n return {\n buttonProps: isButtonObject || Object.keys(buttonProps).length > 0 ? buttonProps : null,\n content: renderSlot(\n contentProps as SlotObject<'span'>,\n 'span',\n cn(!hasButtonIcon && tagClassNames.dismissIcon, iconClassName),\n { 'aria-hidden': true },\n ),\n warning: isButtonObject ? 'button-object' : null,\n ignoredName,\n contentMayName: false,\n literalTextLabel: false,\n disabledFocusable: Boolean(ownProps.disabledFocusable),\n };\n }\n\n return {\n buttonProps: null,\n content: renderSlot(\n slot as Slot<'span'>,\n 'span',\n cn(tagClassNames.dismissIcon, iconClassName),\n {\n 'aria-hidden': true,\n },\n ),\n warning: null,\n ignoredName: false,\n contentMayName: false,\n literalTextLabel: false,\n disabledFocusable: false,\n };\n}\n\n/**\n * A compact label (a \"chip\") for a keyword, category or filter, optionally dismissible.\n *\n * - The dismiss button is a real `<button type=\"button\">` wired to `onDismiss`. Its accessible\n * name is `dismissLabel` plus the tag content (\"Dismiss Cherry\"), so a row of tags has\n * distinguishable dismiss buttons.\n * - `dismissIcon` replaces only the icon inside that button (see {@link TagOwnProps.dismissIcon}).\n * - Polymorphic: `as=\"a\"` renders a link chip with anchor props type-checked.\n *\n * **Focus after dismissal.** A tag cannot keep focus once you remove it. When `onDismiss` removes\n * the tag, move focus to the next tag's dismiss button (else the previous one, else a sensible\n * element nearby); TagGroup (planned) will do this for you. The neighbour stays mounted, so you\n * can focus it in `onDismiss` before removing the tag.\n *\n * @example\n * <Tag>React</Tag>\n * <Tag dismissible onDismiss={() => remove('cherry')}>Cherry</Tag>\n * <Tag dismissible dismissLabel=\"Remove\" dismissIcon={<CloseIcon />}>Cherry</Tag>\n */\nexport const Tag: PolymorphicComponent<'span', TagOwnProps> = (props) => {\n const {\n as,\n dismissible,\n onDismiss,\n dismissIcon,\n dismissLabel = 'Dismiss',\n className,\n children,\n ref,\n ...rest\n } = props as TagImplProps;\n const Component: React.ElementType = as ?? 'span';\n const contentId = useId('tag-content');\n const dismissLabelId = useId('tag-dismiss');\n const dismissTextId = useId('tag-dismiss-text');\n\n const {\n buttonProps: slotButtonProps,\n content,\n warning,\n ignoredName,\n contentMayName,\n literalTextLabel,\n disabledFocusable,\n } = resolveDismissSlot(dismissible ? dismissIcon : undefined);\n\n // C-SLOTS naming (WCAG 2.5.3 Label in Name): the rendered text label of a merged button replaces\n // `dismissLabel` in the name (\"Remove Cherry\"). The literal content decides on the server and on\n // the first render; after mount, the rendered content does (text from components, later changes).\n const [labelTarget, setLabelTarget] = React.useState<HTMLSpanElement | null>(null);\n const subscribeToContent = React.useCallback(\n (onChange: () => void) => (labelTarget ? observeTextLabel(labelTarget, onChange) : noop),\n [labelTarget],\n );\n const contentHasTextLabel = React.useSyncExternalStore(\n subscribeToContent,\n () => (labelTarget ? hasRenderedTextLabel(labelTarget) : literalTextLabel),\n () => literalTextLabel,\n );\n const namedByContent = contentMayName && contentHasTextLabel;\n\n React.useEffect(() => {\n if (warning === 'button-element') {\n warnOnce(\n 'Tag:dismissIcon-button',\n 'Tag: `dismissIcon` received a button. Its props were merged into the built-in dismiss button (a button cannot contain another button), which is named by its text label (or `dismissLabel`) and the tag content. Pass icon content instead, e.g. `dismissIcon={<CloseIcon />}`, and handle the dismissal in `onDismiss`.',\n );\n } else if (warning === 'button-object') {\n warnDeprecated(\n 'Tag',\n 'dismissIcon={{ onClick, type, disabled, … }} (button props on the slot object)',\n 'onDismiss and icon content in dismissIcon',\n 'Its props are merged onto the built-in dismiss button, which is named by `dismissLabel` and the tag content.',\n );\n }\n }, [warning]);\n\n // `onDismiss`/`dismissIcon` alone render no dismiss button (unlike MessageBar's `onDismiss`).\n // An explicit `dismissible={false}` is a deliberate state, so only a missing flag warns.\n const dismissPropsIgnored =\n dismissible === undefined && (onDismiss !== undefined || dismissIcon !== undefined);\n React.useEffect(() => {\n if (dismissPropsIgnored) {\n warnOnce(\n 'Tag:dismiss-without-dismissible',\n 'Tag: `onDismiss` and `dismissIcon` take effect only with `dismissible`; no dismiss button was rendered. Add `dismissible` to render it.',\n );\n }\n }, [dismissPropsIgnored]);\n\n React.useEffect(() => {\n if (ignoredName) {\n warnOnce(\n 'Tag:dismissIcon-name',\n 'Tag: `aria-label`/`aria-labelledby` on `dismissIcon` are ignored. The dismiss button is named by `dismissLabel` (default \"Dismiss\") and the tag content, e.g. \"Dismiss Cherry\"; set `dismissLabel` to change or localise it.',\n );\n }\n }, [ignoredName]);\n\n const ownButtonProps: UnknownProps = {\n type: 'button',\n className: cn(\n tagClassNames.dismissButton,\n 'inline-flex size-5 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 text-foreground',\n 'not-disabled:not-aria-disabled:hover:bg-subtle-pressed',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n mergedAriaDisabledClasses,\n focusRing,\n ),\n 'aria-labelledby': `${namedByContent ? dismissTextId : dismissLabelId} ${contentId}`,\n };\n if (onDismiss) ownButtonProps.onClick = onDismiss;\n const dismissButtonProps = slotButtonProps\n ? mergeProps(ownButtonProps, slotButtonProps)\n : ownButtonProps;\n\n return (\n <Component\n ref={ref}\n className={cn(\n tagClassNames.root,\n 'inline-flex items-center gap-1 rounded-full bg-muted py-1 ps-3 text-body-1 text-foreground',\n dismissible ? 'pe-1.5' : 'pe-3',\n className,\n )}\n {...rest}\n >\n <span\n id={contentId}\n className={cn(tagClassNames.primaryText, 'inline-flex items-center gap-1')}\n >\n {children}\n </span>\n {dismissible && (\n <button\n {...dismissButtonProps}\n type={(dismissButtonProps.type as 'button' | 'submit' | 'reset' | undefined) ?? 'button'}\n // A merged `disabledFocusable` Button makes the dismiss button unavailable but focusable\n // (spread last: it wins over `disabled` and `onDismiss`).\n {...(disabledFocusable ? MERGED_DISABLED_FOCUSABLE_PROPS : undefined)}\n >\n <span id={dismissLabelId} className=\"sr-only\">\n {dismissLabel}\n </span>\n {contentMayName ? (\n // The merged button's own content, rendered as is: its text label can name the button.\n // `gap-[inherit]` keeps a gap set on the button between the content items.\n <span\n id={dismissTextId}\n ref={setLabelTarget}\n className=\"inline-flex items-center justify-center gap-[inherit]\"\n >\n {content}\n </span>\n ) : (\n content\n )}\n </button>\n )}\n </Component>\n );\n};\n\nTag.displayName = 'Tag';\n"],"mappings":"ojBA2GA,IAAMmC,EAAwC,IAAI,IAAI,CACpD,OACA,WACA,YACA,OACA,aACA,cACA,aACA,iBACA,aACA,OACA,OACF,CAAC,EAEKC,EAAc,WAMdC,EAAiC,IAAI,IAAI,CAAC,aAAc,iBAAiB,CAAC,EAsC1EC,MAAa,CAAC,EAGpB,SAASC,EAAY,EAAoE,CACvF,IAAMC,EAAuB,CAAC,EAC1BC,EAAc,GAClB,IAAK,GAAM,CAACC,EAAKC,KAAU,OAAO,QAAQC,CAAK,EACzCP,EAAU,IAAIK,CAAG,EACfC,IAAU,IAAA,KAAW,EAAc,IAEvC,EAAOD,GAAOC,EAGlB,MAAO,CAAE,MAAOH,EAAQ,aAAY,CACtC,CAEA,IAAMK,EAAgB,0CAEtB,SAASC,EAAc,EAAuC,CAE5D,GADI,OAAOH,GAAU,WAAYA,GAC7B3C,EAAM,eAAe2C,CAAK,GAAK,OAAO,YAAYA,EAAO,MAAO,GACpE,IAAMI,EAAiB,OAAO,eAAeJ,CAAK,EAClD,OAAOI,IAAU,MAAQA,IAAU,OAAO,SAC5C,CAMA,SA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../../lib/children.mjs";
4
4
  import { warnDeprecated as n, warnOnce as r } from "../../lib/dev.mjs";
5
5
  import { materialiseSlotContent as i, renderSlot as a, slotRendersContent as o, slotWrapsDefaultContent as s } from "../../lib/slot.mjs";
6
- import { useId as c } from "../../hooks/useId.mjs";
7
- import { focusRing as l } from "../../lib/styles.mjs";
8
- import { Button as u } from "../button/Button.mjs";
9
- import { DismissIcon as d } from "../../lib/icons.mjs";
10
- import { mergeProps as f } from "../../lib/mergeProps.mjs";
11
- import { BUTTON_OWN_PROP_KEYS as p, MERGED_DISABLED_FOCUSABLE_PROPS as m, mergedAriaDisabledClasses as h, placeButtonIcon as g } from "../button/Button.slots.mjs";
12
- import { hasRenderedTextLabel as _, hasTextLabel as v, observeTextLabel as y } from "../../lib/labelInName.mjs";
13
- import * as b from "react";
14
- import { jsx as x, jsxs as S } from "react/jsx-runtime";
6
+ import { tagClassNames as c } from "../../lib/classNames.mjs";
7
+ import { useId as l } from "../../hooks/useId.mjs";
8
+ import { focusRing as u } from "../../lib/styles.mjs";
9
+ import { Button as d } from "../button/Button.mjs";
10
+ import { BUTTON_OWN_PROP_KEYS as f, MERGED_DISABLED_FOCUSABLE_PROPS as p, mergedAriaDisabledClasses as m, placeButtonIcon as h } from "../button/Button.slots.mjs";
11
+ import { DismissIcon as g } from "../../lib/icons.mjs";
12
+ import { mergeProps as _ } from "../../lib/mergeProps.mjs";
13
+ import { hasRenderedTextLabel as v, hasTextLabel as y, observeTextLabel as b } from "../../lib/labelInName.mjs";
14
+ import * as x from "react";
15
+ import { jsx as S, jsxs as C } from "react/jsx-runtime";
15
16
  //#region src/components/data-display/Tag.tsx
16
- var C = /* @__PURE__ */ new Set([
17
+ var w = /* @__PURE__ */ new Set([
17
18
  "type",
18
19
  "disabled",
19
20
  "autoFocus",
@@ -25,71 +26,75 @@ var C = /* @__PURE__ */ new Set([
25
26
  "formTarget",
26
27
  "name",
27
28
  "value"
28
- ]), w = /^on[A-Z]/, T = /* @__PURE__ */ new Set(["aria-label", "aria-labelledby"]), E = () => {};
29
- function D(e) {
29
+ ]), T = /^on[A-Z]/, E = /* @__PURE__ */ new Set(["aria-label", "aria-labelledby"]), D = () => {};
30
+ function O(e) {
30
31
  let t = {}, n = !1;
31
- for (let [r, i] of Object.entries(e)) T.has(r) ? i !== void 0 && (n = !0) : t[r] = i;
32
+ for (let [r, i] of Object.entries(e)) E.has(r) ? i !== void 0 && (n = !0) : t[r] = i;
32
33
  return {
33
34
  props: t,
34
35
  ignoredName: n
35
36
  };
36
37
  }
37
- var O = "inline-flex items-center justify-center";
38
- function k(e) {
39
- if (typeof e != "object" || !e || b.isValidElement(e) || Symbol.iterator in e) return !1;
38
+ var k = "inline-flex items-center justify-center";
39
+ function A(e) {
40
+ if (typeof e != "object" || !e || x.isValidElement(e) || Symbol.iterator in e) return !1;
40
41
  let t = Object.getPrototypeOf(e);
41
42
  return t === null || t === Object.prototype;
42
43
  }
43
- function A() {
44
- return /* @__PURE__ */ x(d, { size: 12 });
45
- }
46
44
  function j(e) {
47
- if (!o(e)) return {
45
+ return /* @__PURE__ */ S(g, {
46
+ size: 12,
47
+ className: e
48
+ });
49
+ }
50
+ function M(n) {
51
+ if (!o(n)) return {
48
52
  buttonProps: null,
49
- content: A(),
53
+ content: j(c.dismissIcon),
50
54
  warning: null,
51
55
  ignoredName: !1,
52
56
  contentMayName: !1,
53
57
  literalTextLabel: !1,
54
58
  disabledFocusable: !1
55
59
  };
56
- let n = t(e);
57
- if (b.isValidElement(e) && (n === "button" || n === u)) {
58
- let { children: t, dangerouslySetInnerHTML: r, ...s } = e.props, c = n === u, l = s;
59
- if (c) {
60
- l = {};
61
- for (let [e, t] of Object.entries(s)) p.has(e) || (l[e] = t);
60
+ let r = t(n);
61
+ if (x.isValidElement(n) && (r === "button" || r === d)) {
62
+ let { children: t, dangerouslySetInnerHTML: s, ...l } = n.props, u = r === d, p = l;
63
+ if (u) {
64
+ p = {};
65
+ for (let [e, t] of Object.entries(l)) f.has(e) || (p[e] = t);
62
66
  }
63
- let d = c ? s.icon : void 0, { props: f, ignoredName: m } = D(l), h = o(d) ? a(d, "span", O, { "aria-hidden": !0 }) : null, _ = r == null ? i(t) : /* @__PURE__ */ x("span", {
64
- className: O,
65
- dangerouslySetInnerHTML: r
67
+ let m = u ? l.icon : void 0, { props: g, ignoredName: _ } = O(p), v = o(m) ? a(m, "span", e(c.dismissIcon, k), { "aria-hidden": !0 }) : null, b = s == null ? i(t) : /* @__PURE__ */ S("span", {
68
+ className: k,
69
+ dangerouslySetInnerHTML: s
66
70
  });
67
71
  return {
68
- buttonProps: f,
69
- content: h || o(_) ? g(h, _, c && s.iconPosition) : A(),
72
+ buttonProps: g,
73
+ content: v || o(b) ? h(v, b, u && l.iconPosition) : j(c.dismissIcon),
70
74
  warning: "button-element",
71
- ignoredName: m,
75
+ ignoredName: _,
72
76
  contentMayName: !0,
73
- literalTextLabel: v(_),
74
- disabledFocusable: c && !!s.disabledFocusable
77
+ literalTextLabel: y(b),
78
+ disabledFocusable: u && !!l.disabledFocusable
75
79
  };
76
80
  }
77
- if (k(e)) {
78
- let t = e.as === u, n = e.as === "button" || t || Object.keys(e).some((e) => C.has(e) || w.test(e)), r = {}, c = {}, l = {}, d = !1;
79
- for (let [i, a] of Object.entries(e)) i === "as" ? a !== "button" && !t && (c.as = a) : t && p.has(i) ? l[i] = a : T.has(i) ? a !== void 0 && (d = !0) : i === "children" || i === "dangerouslySetInnerHTML" ? c[i] = a : n || i.startsWith("aria-") && i !== "aria-hidden" ? r[i] = a : c[i] = a;
80
- return o(l.icon) ? c.children = g(a(l.icon, "span", O), i(c.children), l.iconPosition) : s(c.as ?? "span", c) && (c.children = A()), {
81
- buttonProps: n || Object.keys(r).length > 0 ? r : null,
82
- content: a(c, "span", O, { "aria-hidden": !0 }),
83
- warning: n ? "button-object" : null,
84
- ignoredName: d,
81
+ if (A(n)) {
82
+ let t = n.as === d, r = n.as === "button" || t || Object.keys(n).some((e) => w.has(e) || T.test(e)), l = {}, u = {}, p = {}, m = !1;
83
+ for (let [e, i] of Object.entries(n)) e === "as" ? i !== "button" && !t && (u.as = i) : t && f.has(e) ? p[e] = i : E.has(e) ? i !== void 0 && (m = !0) : e === "children" || e === "dangerouslySetInnerHTML" ? u[e] = i : r || e.startsWith("aria-") && e !== "aria-hidden" ? l[e] = i : u[e] = i;
84
+ let g = o(p.icon);
85
+ return g ? u.children = h(a(p.icon, "span", e(c.dismissIcon, k)), i(u.children), p.iconPosition) : s(u.as ?? "span", u) && (u.children = j()), {
86
+ buttonProps: r || Object.keys(l).length > 0 ? l : null,
87
+ content: a(u, "span", e(!g && c.dismissIcon, k), { "aria-hidden": !0 }),
88
+ warning: r ? "button-object" : null,
89
+ ignoredName: m,
85
90
  contentMayName: !1,
86
91
  literalTextLabel: !1,
87
- disabledFocusable: !!l.disabledFocusable
92
+ disabledFocusable: !!p.disabledFocusable
88
93
  };
89
94
  }
90
95
  return {
91
96
  buttonProps: null,
92
- content: a(e, "span", O, { "aria-hidden": !0 }),
97
+ content: a(n, "span", e(c.dismissIcon, k), { "aria-hidden": !0 }),
93
98
  warning: null,
94
99
  ignoredName: !1,
95
100
  contentMayName: !1,
@@ -97,51 +102,51 @@ function j(e) {
97
102
  disabledFocusable: !1
98
103
  };
99
104
  }
100
- var M = (t) => {
101
- let { as: i, dismissible: a, onDismiss: o, dismissIcon: s, dismissLabel: u = "Dismiss", className: d, children: p, ref: g, ...v } = t, C = i ?? "span", w = c("tag-content"), T = c("tag-dismiss"), D = c("tag-dismiss-text"), { buttonProps: O, content: k, warning: A, ignoredName: M, contentMayName: N, literalTextLabel: P, disabledFocusable: F } = j(a ? s : void 0), [I, L] = b.useState(null), R = b.useCallback((e) => I ? y(I, e) : E, [I]), z = b.useSyncExternalStore(R, () => I ? _(I) : P, () => P), B = N && z;
102
- b.useEffect(() => {
103
- A === "button-element" ? r("Tag:dismissIcon-button", "Tag: `dismissIcon` received a button. Its props were merged into the built-in dismiss button (a button cannot contain another button), which is named by its text label (or `dismissLabel`) and the tag content. Pass icon content instead, e.g. `dismissIcon={<CloseIcon />}`, and handle the dismissal in `onDismiss`.") : A === "button-object" && n("Tag", "dismissIcon={{ onClick, type, disabled, … }} (button props on the slot object)", "onDismiss and icon content in dismissIcon", "Its props are merged onto the built-in dismiss button, which is named by `dismissLabel` and the tag content.");
104
- }, [A]);
105
- let V = a === void 0 && (o !== void 0 || s !== void 0);
106
- b.useEffect(() => {
107
- V && r("Tag:dismiss-without-dismissible", "Tag: `onDismiss` and `dismissIcon` take effect only with `dismissible`; no dismiss button was rendered. Add `dismissible` to render it.");
108
- }, [V]), b.useEffect(() => {
109
- M && r("Tag:dismissIcon-name", "Tag: `aria-label`/`aria-labelledby` on `dismissIcon` are ignored. The dismiss button is named by `dismissLabel` (default \"Dismiss\") and the tag content, e.g. \"Dismiss Cherry\"; set `dismissLabel` to change or localise it.");
110
- }, [M]);
111
- let H = {
105
+ var N = (t) => {
106
+ let { as: i, dismissible: a, onDismiss: o, dismissIcon: s, dismissLabel: d = "Dismiss", className: f, children: h, ref: g, ...y } = t, w = i ?? "span", T = l("tag-content"), E = l("tag-dismiss"), O = l("tag-dismiss-text"), { buttonProps: k, content: A, warning: j, ignoredName: N, contentMayName: P, literalTextLabel: F, disabledFocusable: I } = M(a ? s : void 0), [L, R] = x.useState(null), z = x.useCallback((e) => L ? b(L, e) : D, [L]), B = x.useSyncExternalStore(z, () => L ? v(L) : F, () => F), V = P && B;
107
+ x.useEffect(() => {
108
+ j === "button-element" ? r("Tag:dismissIcon-button", "Tag: `dismissIcon` received a button. Its props were merged into the built-in dismiss button (a button cannot contain another button), which is named by its text label (or `dismissLabel`) and the tag content. Pass icon content instead, e.g. `dismissIcon={<CloseIcon />}`, and handle the dismissal in `onDismiss`.") : j === "button-object" && n("Tag", "dismissIcon={{ onClick, type, disabled, … }} (button props on the slot object)", "onDismiss and icon content in dismissIcon", "Its props are merged onto the built-in dismiss button, which is named by `dismissLabel` and the tag content.");
109
+ }, [j]);
110
+ let H = a === void 0 && (o !== void 0 || s !== void 0);
111
+ x.useEffect(() => {
112
+ H && r("Tag:dismiss-without-dismissible", "Tag: `onDismiss` and `dismissIcon` take effect only with `dismissible`; no dismiss button was rendered. Add `dismissible` to render it.");
113
+ }, [H]), x.useEffect(() => {
114
+ N && r("Tag:dismissIcon-name", "Tag: `aria-label`/`aria-labelledby` on `dismissIcon` are ignored. The dismiss button is named by `dismissLabel` (default \"Dismiss\") and the tag content, e.g. \"Dismiss Cherry\"; set `dismissLabel` to change or localise it.");
115
+ }, [N]);
116
+ let U = {
112
117
  type: "button",
113
- className: e("inline-flex size-5 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 text-foreground", "not-disabled:not-aria-disabled:hover:bg-subtle-pressed", "disabled:cursor-not-allowed disabled:opacity-50", h, l),
114
- "aria-labelledby": `${B ? D : T} ${w}`
118
+ className: e(c.dismissButton, "inline-flex size-5 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 text-foreground", "not-disabled:not-aria-disabled:hover:bg-subtle-pressed", "disabled:cursor-not-allowed disabled:opacity-50", m, u),
119
+ "aria-labelledby": `${V ? O : E} ${T}`
115
120
  };
116
- o && (H.onClick = o);
117
- let U = O ? f(H, O) : H;
118
- return /* @__PURE__ */ S(C, {
121
+ o && (U.onClick = o);
122
+ let W = k ? _(U, k) : U;
123
+ return /* @__PURE__ */ C(w, {
119
124
  ref: g,
120
- className: e("inline-flex items-center gap-1 rounded-full bg-muted py-1 ps-3 text-body-1 text-foreground", a ? "pe-1.5" : "pe-3", d),
121
- ...v,
122
- children: [/* @__PURE__ */ x("span", {
123
- id: w,
124
- className: "inline-flex items-center gap-1",
125
- children: p
126
- }), a && /* @__PURE__ */ S("button", {
127
- ...U,
128
- type: U.type ?? "button",
129
- ...F ? m : void 0,
130
- children: [/* @__PURE__ */ x("span", {
131
- id: T,
125
+ className: e(c.root, "inline-flex items-center gap-1 rounded-full bg-muted py-1 ps-3 text-body-1 text-foreground", a ? "pe-1.5" : "pe-3", f),
126
+ ...y,
127
+ children: [/* @__PURE__ */ S("span", {
128
+ id: T,
129
+ className: e(c.primaryText, "inline-flex items-center gap-1"),
130
+ children: h
131
+ }), a && /* @__PURE__ */ C("button", {
132
+ ...W,
133
+ type: W.type ?? "button",
134
+ ...I ? p : void 0,
135
+ children: [/* @__PURE__ */ S("span", {
136
+ id: E,
132
137
  className: "sr-only",
133
- children: u
134
- }), N ? /* @__PURE__ */ x("span", {
135
- id: D,
136
- ref: L,
138
+ children: d
139
+ }), P ? /* @__PURE__ */ S("span", {
140
+ id: O,
141
+ ref: R,
137
142
  className: "inline-flex items-center justify-center gap-[inherit]",
138
- children: k
139
- }) : k]
143
+ children: A
144
+ }) : A]
140
145
  })]
141
146
  });
142
147
  };
143
- M.displayName = "Tag";
148
+ N.displayName = "Tag";
144
149
  //#endregion
145
- export { M as Tag };
150
+ export { N as Tag };
146
151
 
147
152
  //# sourceMappingURL=Tag.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tag.mjs","names":["useId","useId$1","React","BUTTON_ONLY_KEYS","HANDLER_KEY","NAME_KEYS","noop","withoutName","result","ignoredName","key","value","props","iconClassName","isPlainObject","proto","defaultDismissContent","DismissIcon","resolveDismissSlot","slotRendersContent","slot","elementType","getElementType","Button","markup","elementProps","isWaveButton","slotProps","BUTTON_OWN_PROP_KEYS","icon","buttonProps","iconNode","renderSlot","ownContent","materialiseSlotContent","children","placeButtonIcon","hasTextLabel","asWaveButton","isButtonObject","contentProps","ownProps","slotWrapsDefaultContent","Tag","rest","Component","as","contentId","dismissLabelId","dismissTextId","slotButtonProps","dismissible","dismissIcon","labelTarget","setLabelTarget","subscribeToContent","observeTextLabel","onChange","contentHasTextLabel","hasRenderedTextLabel","literalTextLabel","namedByContent","contentMayName","warning","warnOnce","warnDeprecated","dismissPropsIgnored","onDismiss","ownButtonProps","cn","mergedAriaDisabledClasses","focusRing","dismissButtonProps","mergeProps","className","disabledFocusable","MERGED_DISABLED_FOCUSABLE_PROPS","dismissLabel","content"],"sources":["../../../src/components/data-display/Tag.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { mergeProps } from '../../lib/mergeProps';\nimport { getElementType } from '../../lib/children';\nimport {\n materialiseSlotContent,\n renderSlot,\n slotRendersContent,\n slotWrapsDefaultContent,\n} from '../../lib/slot';\nimport { focusRing } from '../../lib/styles';\nimport { DismissIcon } from '../../lib/icons';\nimport { hasRenderedTextLabel, hasTextLabel, observeTextLabel } from '../../lib/labelInName';\nimport type { Slot, SlotObject } from '../../lib/slot';\nimport type { PolymorphicComponent, PolymorphicProps } from '../../lib/polymorphic';\nimport { useId } from '../../hooks/useId';\nimport { Button } from '../button/Button';\nimport {\n BUTTON_OWN_PROP_KEYS,\n MERGED_DISABLED_FOCUSABLE_PROPS,\n mergedAriaDisabledClasses,\n placeButtonIcon,\n} from '../button/Button.slots';\n\n/**\n * The Tag's own props (the XOwnProps rule of `PolymorphicProps`: component-specific props only).\n * Every other prop comes from the rendered element (`as`, default `span`).\n */\nexport interface TagOwnProps {\n /**\n * Whether the tag renders a dismiss button. `onDismiss` and `dismissIcon` take effect only with\n * it (a development warning says so when they are passed without it).\n */\n dismissible?: boolean;\n /**\n * Called when the dismiss button is activated (click, Enter or Space). Passing it does not render\n * the dismiss button: set `dismissible` too. When it removes the tag, move focus yourself (see\n * \"Focus after dismissal\" on {@link Tag}).\n */\n onDismiss?: () => void;\n /**\n * Content of the dismiss button (an icon). The Tag always renders its own dismiss\n * `<button type=\"button\">`, wired to `onDismiss` and named by `dismissLabel` plus the tag\n * content; this slot only replaces the icon inside it.\n *\n * A `<button>` element or a Wave `Button` passed here is not nested (a button cannot contain a\n * button): its props are merged into the dismiss button (its `onClick` runs first and can call\n * `preventDefault()` to skip `onDismiss`) and a development warning recommends icon content.\n * A Wave `Button`'s own props are not attributes: its `icon` becomes decorative content before\n * its children (after them with `iconPosition=\"after\"`), `disabledFocusable` makes the dismiss\n * button unavailable but focusable as on the Button (`onDismiss` is not called), and\n * `appearance` and `size` are ignored.\n * A slot object with button props (`type`, `disabled`, event handlers, `as: 'button'` or\n * `as: Button`) is the deprecated 0.4 button-object form: its props (`className`, `id`,\n * `aria-*`, handlers, …) are merged onto the dismiss button, except its content (`children`,\n * `dangerouslySetInnerHTML`, rendered inside the button) and the naming attributes (see below);\n * for `as: Button`, the Button's own props apply as for a `Button` element — pass icon content\n * and use `onDismiss` instead.\n * The `aria-*` attributes of an icon slot object also go to the dismiss button, because the icon\n * is `aria-hidden`.\n *\n * The dismiss button's name is `dismissLabel` plus the tag content (\"Dismiss Cherry\"):\n * `aria-label` and `aria-labelledby` on the slot are ignored (development warning). Icon\n * content is decorative (`aria-hidden`). The children of a merged `<button>`/`Button` (or its\n * `dangerouslySetInnerHTML` markup) are rendered as is inside the dismiss button, next to the\n * decorative `icon` of a Wave `Button`: when they render a text label (at least two letters or\n * digits outside `aria-hidden`/`hidden` content, text from components such as translations\n * included), that text replaces `dismissLabel` in the name, so the name contains the visible\n * label (WCAG 2.5.3): `<button>Remove</button>` or\n * `<Button icon={<CloseIcon />}>Remove</Button>` on \"Cherry\" is named \"Remove Cherry\". An icon or\n * a lone character (`x`, `×`) keeps \"Dismiss Cherry\". Text hidden only with CSS still counts as\n * the label.\n *\n * When the slot renders no content (`[]`, `<></>`, a childless merged button, a slot object\n * without `children`), the default dismiss icon is shown; a slot object then styles it, e.g.\n * `{ className: 'text-error' }`. A slot object that renders a component or a void element\n * (`{ as: CloseIcon }`, `{ as: 'img', src, alt: '' }`) or sets `dangerouslySetInnerHTML` is the\n * icon itself: no default icon is added. Only takes effect with `dismissible`.\n */\n dismissIcon?: Slot<'span'> | SlotObject<'button'>;\n /**\n * Visually hidden text that names the dismiss button together with the tag content\n * (`aria-labelledby`), e.g. \"Dismiss Cherry\". Localise it here. A text label rendered by a\n * merged `<button>` slot replaces it (see `dismissIcon`).\n * @default 'Dismiss'\n */\n dismissLabel?: string;\n}\n\n/**\n * Props of {@link Tag} rendered as `C` (default `'span'`). `TagProps` without a type argument is\n * the 0.4 name.\n */\nexport type TagProps<C extends React.ElementType = 'span'> = PolymorphicProps<C, TagOwnProps>;\n\n/** The props the implementation reads, for any `as` (the public typing is `PolymorphicComponent`). */\ntype TagImplProps = TagOwnProps &\n React.HTMLAttributes<HTMLElement> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n };\n\ntype UnknownProps = Record<string, unknown>;\n\n/** Attributes that only make sense on the dismiss `<button>` itself. */\nconst BUTTON_ONLY_KEYS: ReadonlySet<string> = new Set([\n 'type',\n 'disabled',\n 'autoFocus',\n 'form',\n 'formAction',\n 'formEncType',\n 'formMethod',\n 'formNoValidate',\n 'formTarget',\n 'name',\n 'value',\n]);\n\nconst HANDLER_KEY = /^on[A-Z]/;\n\n/**\n * Naming attributes a slot cannot set: the Tag names its dismiss button itself\n * (`aria-labelledby` = `dismissLabel` + tag content, data-display#10), so these are dropped.\n */\nconst NAME_KEYS: ReadonlySet<string> = new Set(['aria-label', 'aria-labelledby']);\n\n/** The props of a merged `<button>` or Wave `Button` that the Tag reads itself. */\ninterface WaveButtonSlotProps extends UnknownProps {\n icon?: Slot<'span'>;\n iconPosition?: unknown;\n disabledFocusable?: unknown;\n children?: React.ReactNode;\n dangerouslySetInnerHTML?: React.HTMLAttributes<HTMLElement>['dangerouslySetInnerHTML'];\n}\n\ninterface ResolvedDismissSlot {\n /** Props merged onto the wired dismiss button (`null`: none). */\n buttonProps: UnknownProps | null;\n /** What renders inside the dismiss button. */\n content: React.ReactNode;\n /** Which development warning the slot needs. */\n warning: 'button-element' | 'button-object' | null;\n /** Whether the slot passed `aria-label`/`aria-labelledby`, which the Tag ignores. */\n ignoredName: boolean;\n /**\n * `true` when the content is rendered as is (a merged `<button>`/`Button`), so a text label in it\n * replaces `dismissLabel` in the name (C-SLOTS naming, WCAG 2.5.3); `false` when the content is\n * decorative (`aria-hidden`).\n */\n contentMayName: boolean;\n /**\n * Whether the literal content contains a text label: the name for the server render and the\n * first client render. After mount the rendered content decides.\n */\n literalTextLabel: boolean;\n /**\n * Whether a merged Wave `Button` set `disabledFocusable`: the dismiss button is then unavailable\n * but focusable, as the Button would be.\n */\n disabledFocusable: boolean;\n}\n\nconst noop = () => {};\n\n/** `props` without the naming attributes, and whether any was set. */\nfunction withoutName(props: UnknownProps): { props: UnknownProps; ignoredName: boolean } {\n const result: UnknownProps = {};\n let ignoredName = false;\n for (const [key, value] of Object.entries(props)) {\n if (NAME_KEYS.has(key)) {\n if (value !== undefined) ignoredName = true;\n } else {\n result[key] = value;\n }\n }\n return { props: result, ignoredName };\n}\n\nconst iconClassName = 'inline-flex items-center justify-center';\n\nfunction isPlainObject(value: unknown): value is UnknownProps {\n if (typeof value !== 'object' || value === null) return false;\n if (React.isValidElement(value) || Symbol.iterator in value) return false;\n const proto: unknown = Object.getPrototypeOf(value);\n return proto === null || proto === Object.prototype;\n}\n\n/** The decorative default dismiss glyph. */\nfunction defaultDismissContent(): React.ReactNode {\n return <DismissIcon size={12} />;\n}\n\n/**\n * Splits the dismissIcon slot into dismiss-button props and icon content (C-SLOTS). The icon\n * content is `aria-hidden`, so no attribute that means something to assistive technology stays on\n * it: button-form props go to the dismiss button, and so do the `aria-*` attributes of an icon slot\n * object; the naming attributes are dropped (see {@link NAME_KEYS}).\n *\n * Content that renders nothing (`[]`, `<></>`, a childless merged button, a slot object without\n * `children`) shows the default icon, so the dismiss button is never an empty, invisible Tab stop.\n */\nfunction resolveDismissSlot(slot: TagOwnProps['dismissIcon']): ResolvedDismissSlot {\n if (!slotRendersContent(slot)) {\n return {\n buttonProps: null,\n content: defaultDismissContent(),\n warning: null,\n ignoredName: false,\n contentMayName: false,\n literalTextLabel: false,\n disabledFocusable: false,\n };\n }\n\n // A `<button>` or a Wave `Button` (also one written in a Server Component, whose type arrives as\n // a lazy reference) is merged into the dismiss button. Its content is rendered as is, after the\n // Button's icon, which is decorative (as in MessageBar and SearchBox); its text label names it.\n const elementType = getElementType(slot as React.ReactNode);\n if (\n React.isValidElement<WaveButtonSlotProps>(slot) &&\n (elementType === 'button' || elementType === Button)\n ) {\n const { children, dangerouslySetInnerHTML: markup, ...elementProps } = slot.props;\n const isWaveButton = elementType === Button;\n let slotProps: UnknownProps = elementProps;\n if (isWaveButton) {\n // Wave Button's own props are not attributes: `icon`, `iconPosition` and\n // `disabledFocusable` are applied here, the others (`appearance`, `size`) are dropped.\n slotProps = {};\n for (const [key, value] of Object.entries(elementProps)) {\n if (!BUTTON_OWN_PROP_KEYS.has(key)) slotProps[key] = value;\n }\n }\n const icon = isWaveButton ? elementProps.icon : undefined;\n const { props: buttonProps, ignoredName } = withoutName(slotProps);\n const iconNode = slotRendersContent(icon)\n ? renderSlot(icon, 'span', iconClassName, { 'aria-hidden': true })\n : null;\n // A generator is read once by the check; its items are what renders (and names the button).\n // Markup of the merged button (`dangerouslySetInnerHTML`) is its content as well: the dismiss\n // button holds its own name text, so the markup renders in a span inside it.\n const ownContent =\n markup != null ? (\n <span className={iconClassName} dangerouslySetInnerHTML={markup} />\n ) : (\n materialiseSlotContent(children)\n );\n return {\n buttonProps,\n content:\n iconNode || slotRendersContent(ownContent)\n ? placeButtonIcon(iconNode, ownContent, isWaveButton && elementProps.iconPosition)\n : defaultDismissContent(),\n warning: 'button-element',\n ignoredName,\n contentMayName: true,\n literalTextLabel: hasTextLabel(ownContent),\n disabledFocusable: isWaveButton && Boolean(elementProps.disabledFocusable),\n };\n }\n\n if (isPlainObject(slot)) {\n // 0.4 rendered the whole object as the dismiss element, so an object with button props\n // describes the button: everything but its content goes to the dismiss button. `as: Button`\n // is that form too (a button cannot contain a button); its icon becomes decorative content.\n const asWaveButton = slot.as === Button;\n const isButtonObject =\n slot.as === 'button' ||\n asWaveButton ||\n Object.keys(slot).some((key) => BUTTON_ONLY_KEYS.has(key) || HANDLER_KEY.test(key));\n const buttonProps: UnknownProps = {};\n const contentProps: UnknownProps = {};\n // Wave Button's own props are not attributes: `icon`, `iconPosition` and `disabledFocusable`\n // are applied below, the others (`appearance`, `size`) are dropped.\n const ownProps: UnknownProps = {};\n let ignoredName = false;\n for (const [key, value] of Object.entries(slot)) {\n if (key === 'as') {\n if (value !== 'button' && !asWaveButton) contentProps.as = value;\n } else if (asWaveButton && BUTTON_OWN_PROP_KEYS.has(key)) {\n ownProps[key] = value;\n } else if (NAME_KEYS.has(key)) {\n if (value !== undefined) ignoredName = true;\n } else if (key === 'children' || key === 'dangerouslySetInnerHTML') {\n // Content, also in the button-object form: the dismiss button holds its own name text.\n contentProps[key] = value;\n } else if (isButtonObject || (key.startsWith('aria-') && key !== 'aria-hidden')) {\n buttonProps[key] = value;\n } else {\n contentProps[key] = value;\n }\n }\n // An object without content styles the default icon, e.g. `{ className: 'text-error' }` (as in\n // MessageBar and SearchBox); a Wave Button's icon comes before the content (after it with\n // `iconPosition=\"after\"`).\n if (slotRendersContent(ownProps.icon)) {\n contentProps.children = placeButtonIcon(\n renderSlot(ownProps.icon as Slot<'span'>, 'span', iconClassName),\n materialiseSlotContent(contentProps.children),\n ownProps.iconPosition,\n );\n } else if (slotWrapsDefaultContent(contentProps.as ?? 'span', contentProps)) {\n contentProps.children = defaultDismissContent();\n }\n return {\n buttonProps: isButtonObject || Object.keys(buttonProps).length > 0 ? buttonProps : null,\n content: renderSlot(contentProps as SlotObject<'span'>, 'span', iconClassName, {\n 'aria-hidden': true,\n }),\n warning: isButtonObject ? 'button-object' : null,\n ignoredName,\n contentMayName: false,\n literalTextLabel: false,\n disabledFocusable: Boolean(ownProps.disabledFocusable),\n };\n }\n\n return {\n buttonProps: null,\n content: renderSlot(slot as Slot<'span'>, 'span', iconClassName, { 'aria-hidden': true }),\n warning: null,\n ignoredName: false,\n contentMayName: false,\n literalTextLabel: false,\n disabledFocusable: false,\n };\n}\n\n/**\n * A compact label (a \"chip\") for a keyword, category or filter, optionally dismissible.\n *\n * - The dismiss button is a real `<button type=\"button\">` wired to `onDismiss`. Its accessible\n * name is `dismissLabel` plus the tag content (\"Dismiss Cherry\"), so a row of tags has\n * distinguishable dismiss buttons.\n * - `dismissIcon` replaces only the icon inside that button (see {@link TagOwnProps.dismissIcon}).\n * - Polymorphic: `as=\"a\"` renders a link chip with anchor props type-checked.\n *\n * **Focus after dismissal.** A tag cannot keep focus once you remove it. When `onDismiss` removes\n * the tag, move focus to the next tag's dismiss button (else the previous one, else a sensible\n * element nearby); TagGroup (planned) will do this for you. The neighbour stays mounted, so you\n * can focus it in `onDismiss` before removing the tag.\n *\n * @example\n * <Tag>React</Tag>\n * <Tag dismissible onDismiss={() => remove('cherry')}>Cherry</Tag>\n * <Tag dismissible dismissLabel=\"Remove\" dismissIcon={<CloseIcon />}>Cherry</Tag>\n */\nexport const Tag: PolymorphicComponent<'span', TagOwnProps> = (props) => {\n const {\n as,\n dismissible,\n onDismiss,\n dismissIcon,\n dismissLabel = 'Dismiss',\n className,\n children,\n ref,\n ...rest\n } = props as TagImplProps;\n const Component: React.ElementType = as ?? 'span';\n const contentId = useId('tag-content');\n const dismissLabelId = useId('tag-dismiss');\n const dismissTextId = useId('tag-dismiss-text');\n\n const {\n buttonProps: slotButtonProps,\n content,\n warning,\n ignoredName,\n contentMayName,\n literalTextLabel,\n disabledFocusable,\n } = resolveDismissSlot(dismissible ? dismissIcon : undefined);\n\n // C-SLOTS naming (WCAG 2.5.3 Label in Name): the rendered text label of a merged button replaces\n // `dismissLabel` in the name (\"Remove Cherry\"). The literal content decides on the server and on\n // the first render; after mount, the rendered content does (text from components, later changes).\n const [labelTarget, setLabelTarget] = React.useState<HTMLSpanElement | null>(null);\n const subscribeToContent = React.useCallback(\n (onChange: () => void) => (labelTarget ? observeTextLabel(labelTarget, onChange) : noop),\n [labelTarget],\n );\n const contentHasTextLabel = React.useSyncExternalStore(\n subscribeToContent,\n () => (labelTarget ? hasRenderedTextLabel(labelTarget) : literalTextLabel),\n () => literalTextLabel,\n );\n const namedByContent = contentMayName && contentHasTextLabel;\n\n React.useEffect(() => {\n if (warning === 'button-element') {\n warnOnce(\n 'Tag:dismissIcon-button',\n 'Tag: `dismissIcon` received a button. Its props were merged into the built-in dismiss button (a button cannot contain another button), which is named by its text label (or `dismissLabel`) and the tag content. Pass icon content instead, e.g. `dismissIcon={<CloseIcon />}`, and handle the dismissal in `onDismiss`.',\n );\n } else if (warning === 'button-object') {\n warnDeprecated(\n 'Tag',\n 'dismissIcon={{ onClick, type, disabled, … }} (button props on the slot object)',\n 'onDismiss and icon content in dismissIcon',\n 'Its props are merged onto the built-in dismiss button, which is named by `dismissLabel` and the tag content.',\n );\n }\n }, [warning]);\n\n // `onDismiss`/`dismissIcon` alone render no dismiss button (unlike MessageBar's `onDismiss`).\n // An explicit `dismissible={false}` is a deliberate state, so only a missing flag warns.\n const dismissPropsIgnored =\n dismissible === undefined && (onDismiss !== undefined || dismissIcon !== undefined);\n React.useEffect(() => {\n if (dismissPropsIgnored) {\n warnOnce(\n 'Tag:dismiss-without-dismissible',\n 'Tag: `onDismiss` and `dismissIcon` take effect only with `dismissible`; no dismiss button was rendered. Add `dismissible` to render it.',\n );\n }\n }, [dismissPropsIgnored]);\n\n React.useEffect(() => {\n if (ignoredName) {\n warnOnce(\n 'Tag:dismissIcon-name',\n 'Tag: `aria-label`/`aria-labelledby` on `dismissIcon` are ignored. The dismiss button is named by `dismissLabel` (default \"Dismiss\") and the tag content, e.g. \"Dismiss Cherry\"; set `dismissLabel` to change or localise it.',\n );\n }\n }, [ignoredName]);\n\n const ownButtonProps: UnknownProps = {\n type: 'button',\n className: cn(\n 'inline-flex size-5 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 text-foreground',\n 'not-disabled:not-aria-disabled:hover:bg-subtle-pressed',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n mergedAriaDisabledClasses,\n focusRing,\n ),\n 'aria-labelledby': `${namedByContent ? dismissTextId : dismissLabelId} ${contentId}`,\n };\n if (onDismiss) ownButtonProps.onClick = onDismiss;\n const dismissButtonProps = slotButtonProps\n ? mergeProps(ownButtonProps, slotButtonProps)\n : ownButtonProps;\n\n return (\n <Component\n ref={ref}\n className={cn(\n 'inline-flex items-center gap-1 rounded-full bg-muted py-1 ps-3 text-body-1 text-foreground',\n dismissible ? 'pe-1.5' : 'pe-3',\n className,\n )}\n {...rest}\n >\n <span id={contentId} className=\"inline-flex items-center gap-1\">\n {children}\n </span>\n {dismissible && (\n <button\n {...dismissButtonProps}\n type={(dismissButtonProps.type as 'button' | 'submit' | 'reset' | undefined) ?? 'button'}\n // A merged `disabledFocusable` Button makes the dismiss button unavailable but focusable\n // (spread last: it wins over `disabled` and `onDismiss`).\n {...(disabledFocusable ? MERGED_DISABLED_FOCUSABLE_PROPS : undefined)}\n >\n <span id={dismissLabelId} className=\"sr-only\">\n {dismissLabel}\n </span>\n {contentMayName ? (\n // The merged button's own content, rendered as is: its text label can name the button.\n // `gap-[inherit]` keeps a gap set on the button between the content items.\n <span\n id={dismissTextId}\n ref={setLabelTarget}\n className=\"inline-flex items-center justify-center gap-[inherit]\"\n >\n {content}\n </span>\n ) : (\n content\n )}\n </button>\n )}\n </Component>\n );\n};\n\nTag.displayName = 'Tag';\n"],"mappings":";;;;;;;;;;;;;;;AA0GA,IAAMG,oBAAwC,IAAI,IAAI;CACpD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,GAEKC,IAAc,YAMdC,oBAAiC,IAAI,IAAI,CAAC,cAAc,iBAAiB,CAAC,GAsC1EC,UAAa,CAAC;AAGpB,SAASC,EAAY,GAAoE;CACvF,IAAMC,IAAuB,CAAC,GAC1BC,IAAc;CAClB,KAAK,IAAM,CAACC,GAAKC,MAAU,OAAO,QAAQC,CAAK,GAC7C,AAAIP,EAAU,IAAIK,CAAG,IACfC,MAAU,KAAA,MAAW,IAAc,MAEvC,EAAOD,KAAOC;CAGlB,OAAO;EAAE,OAAOH;EAAQ;CAAY;AACtC;AAEA,IAAMK,IAAgB;AAEtB,SAASC,EAAc,GAAuC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A,mBAAmB,GAAGV,IAAiBZ,IAAgBD,EAAe,GAAGD;CAC3E;CACA,AAAIoB,MAAW,EAAe,UAAUA;CACxC,IAAMK,IAAqBtB,IACvBuB,EAAWL,GAAgBlB,CAAe,IAC1CkB;CAEJ,OACE,kBAACvB,GAAD;EACO;EACL,WAAWwB,EACT,8FACAlB,IAAc,WAAW,QACzBuB,CACF;EACA,GAAI9B;EAPN,UAAA,CASE,kBAAC,QAAD;GAAM,IAAIG;GAAW,WAAU;GAC5B;EACG,CAAA,GACLI,KACC,kBAAC,UAAD;GACE,GAAIqB;GACJ,MAAOA,EAAmB,QAAsD;GAGhF,GAAKG,IAAoBC,IAAkC,KAAA;GAL7D,UAAA,CAOE,kBAAC,QAAD;IAAM,IAAI5B;IAAgB,WAAU;IACjC,UAAA6B;GACG,CAAA,GACLf,IAGC,kBAAC,QAAD;IACE,IAAIb;IACJ,KAAKK;IACL,WAAU;IAET,UAAAwB;GACG,CAAA,IAENA,CAEI;EAED,CAAA,CAAA;;AAEf;AAEA,EAAI,cAAc"}
1
+ {"version":3,"file":"Tag.mjs","names":["useId","useId$1","React","BUTTON_ONLY_KEYS","HANDLER_KEY","NAME_KEYS","noop","withoutName","result","ignoredName","key","value","props","iconClassName","isPlainObject","proto","defaultDismissContent","DismissIcon","resolveDismissSlot","slotRendersContent","slot","tagClassNames","elementType","getElementType","Button","markup","elementProps","isWaveButton","slotProps","BUTTON_OWN_PROP_KEYS","icon","buttonProps","iconNode","renderSlot","cn","ownContent","materialiseSlotContent","children","placeButtonIcon","hasTextLabel","asWaveButton","isButtonObject","contentProps","ownProps","hasButtonIcon","slotWrapsDefaultContent","Tag","rest","Component","as","contentId","dismissLabelId","dismissTextId","slotButtonProps","dismissible","dismissIcon","labelTarget","setLabelTarget","subscribeToContent","observeTextLabel","onChange","contentHasTextLabel","hasRenderedTextLabel","literalTextLabel","namedByContent","contentMayName","warning","warnOnce","warnDeprecated","dismissPropsIgnored","onDismiss","ownButtonProps","mergedAriaDisabledClasses","focusRing","dismissButtonProps","mergeProps","className","disabledFocusable","MERGED_DISABLED_FOCUSABLE_PROPS","dismissLabel","content"],"sources":["../../../src/components/data-display/Tag.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { tagClassNames } from '../../lib/classNames';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { mergeProps } from '../../lib/mergeProps';\nimport { getElementType } from '../../lib/children';\nimport {\n materialiseSlotContent,\n renderSlot,\n slotRendersContent,\n slotWrapsDefaultContent,\n} from '../../lib/slot';\nimport { focusRing } from '../../lib/styles';\nimport { DismissIcon } from '../../lib/icons';\nimport { hasRenderedTextLabel, hasTextLabel, observeTextLabel } from '../../lib/labelInName';\nimport type { Slot, SlotObject } from '../../lib/slot';\nimport type { PolymorphicComponent, PolymorphicProps } from '../../lib/polymorphic';\nimport { useId } from '../../hooks/useId';\nimport { Button } from '../button/Button';\nimport {\n BUTTON_OWN_PROP_KEYS,\n MERGED_DISABLED_FOCUSABLE_PROPS,\n mergedAriaDisabledClasses,\n placeButtonIcon,\n} from '../button/Button.slots';\n\n/**\n * The Tag's own props (the XOwnProps rule of `PolymorphicProps`: component-specific props only).\n * Every other prop comes from the rendered element (`as`, default `span`).\n */\nexport interface TagOwnProps {\n /**\n * Whether the tag renders a dismiss button. `onDismiss` and `dismissIcon` take effect only with\n * it (a development warning says so when they are passed without it).\n */\n dismissible?: boolean;\n /**\n * Called when the dismiss button is activated (click, Enter or Space). Passing it does not render\n * the dismiss button: set `dismissible` too. When it removes the tag, move focus yourself (see\n * \"Focus after dismissal\" on {@link Tag}).\n */\n onDismiss?: () => void;\n /**\n * Content of the dismiss button (an icon). The Tag always renders its own dismiss\n * `<button type=\"button\">`, wired to `onDismiss` and named by `dismissLabel` plus the tag\n * content; this slot only replaces the icon inside it.\n *\n * A `<button>` element or a Wave `Button` passed here is not nested (a button cannot contain a\n * button): its props are merged into the dismiss button (its `onClick` runs first and can call\n * `preventDefault()` to skip `onDismiss`) and a development warning recommends icon content.\n * A Wave `Button`'s own props are not attributes: its `icon` becomes decorative content before\n * its children (after them with `iconPosition=\"after\"`), `disabledFocusable` makes the dismiss\n * button unavailable but focusable as on the Button (`onDismiss` is not called), and\n * `appearance` and `size` are ignored.\n * A slot object with button props (`type`, `disabled`, event handlers, `as: 'button'` or\n * `as: Button`) is the deprecated 0.4 button-object form: its props (`className`, `id`,\n * `aria-*`, handlers, …) are merged onto the dismiss button, except its content (`children`,\n * `dangerouslySetInnerHTML`, rendered inside the button) and the naming attributes (see below);\n * for `as: Button`, the Button's own props apply as for a `Button` element — pass icon content\n * and use `onDismiss` instead.\n * The `aria-*` attributes of an icon slot object also go to the dismiss button, because the icon\n * is `aria-hidden`.\n *\n * The dismiss button's name is `dismissLabel` plus the tag content (\"Dismiss Cherry\"):\n * `aria-label` and `aria-labelledby` on the slot are ignored (development warning). Icon\n * content is decorative (`aria-hidden`). The children of a merged `<button>`/`Button` (or its\n * `dangerouslySetInnerHTML` markup) are rendered as is inside the dismiss button, next to the\n * decorative `icon` of a Wave `Button`: when they render a text label (at least two letters or\n * digits outside `aria-hidden`/`hidden` content, text from components such as translations\n * included), that text replaces `dismissLabel` in the name, so the name contains the visible\n * label (WCAG 2.5.3): `<button>Remove</button>` or\n * `<Button icon={<CloseIcon />}>Remove</Button>` on \"Cherry\" is named \"Remove Cherry\". An icon or\n * a lone character (`x`, `×`) keeps \"Dismiss Cherry\". Text hidden only with CSS still counts as\n * the label.\n *\n * When the slot renders no content (`[]`, `<></>`, a childless merged button, a slot object\n * without `children`), the default dismiss icon is shown; a slot object then styles it, e.g.\n * `{ className: 'text-error' }`. A slot object that renders a component or a void element\n * (`{ as: CloseIcon }`, `{ as: 'img', src, alt: '' }`) or sets `dangerouslySetInnerHTML` is the\n * icon itself: no default icon is added. Only takes effect with `dismissible`.\n */\n dismissIcon?: Slot<'span'> | SlotObject<'button'>;\n /**\n * Visually hidden text that names the dismiss button together with the tag content\n * (`aria-labelledby`), e.g. \"Dismiss Cherry\". Localise it here. A text label rendered by a\n * merged `<button>` slot replaces it (see `dismissIcon`).\n * @default 'Dismiss'\n */\n dismissLabel?: string;\n}\n\n/**\n * Props of {@link Tag} rendered as `C` (default `'span'`). `TagProps` without a type argument is\n * the 0.4 name.\n */\nexport type TagProps<C extends React.ElementType = 'span'> = PolymorphicProps<C, TagOwnProps>;\n\n/** The props the implementation reads, for any `as` (the public typing is `PolymorphicComponent`). */\ntype TagImplProps = TagOwnProps &\n React.HTMLAttributes<HTMLElement> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n };\n\ntype UnknownProps = Record<string, unknown>;\n\n/** Attributes that only make sense on the dismiss `<button>` itself. */\nconst BUTTON_ONLY_KEYS: ReadonlySet<string> = new Set([\n 'type',\n 'disabled',\n 'autoFocus',\n 'form',\n 'formAction',\n 'formEncType',\n 'formMethod',\n 'formNoValidate',\n 'formTarget',\n 'name',\n 'value',\n]);\n\nconst HANDLER_KEY = /^on[A-Z]/;\n\n/**\n * Naming attributes a slot cannot set: the Tag names its dismiss button itself\n * (`aria-labelledby` = `dismissLabel` + tag content, data-display#10), so these are dropped.\n */\nconst NAME_KEYS: ReadonlySet<string> = new Set(['aria-label', 'aria-labelledby']);\n\n/** The props of a merged `<button>` or Wave `Button` that the Tag reads itself. */\ninterface WaveButtonSlotProps extends UnknownProps {\n icon?: Slot<'span'>;\n iconPosition?: unknown;\n disabledFocusable?: unknown;\n children?: React.ReactNode;\n dangerouslySetInnerHTML?: React.HTMLAttributes<HTMLElement>['dangerouslySetInnerHTML'];\n}\n\ninterface ResolvedDismissSlot {\n /** Props merged onto the wired dismiss button (`null`: none). */\n buttonProps: UnknownProps | null;\n /** What renders inside the dismiss button. */\n content: React.ReactNode;\n /** Which development warning the slot needs. */\n warning: 'button-element' | 'button-object' | null;\n /** Whether the slot passed `aria-label`/`aria-labelledby`, which the Tag ignores. */\n ignoredName: boolean;\n /**\n * `true` when the content is rendered as is (a merged `<button>`/`Button`), so a text label in it\n * replaces `dismissLabel` in the name (C-SLOTS naming, WCAG 2.5.3); `false` when the content is\n * decorative (`aria-hidden`).\n */\n contentMayName: boolean;\n /**\n * Whether the literal content contains a text label: the name for the server render and the\n * first client render. After mount the rendered content decides.\n */\n literalTextLabel: boolean;\n /**\n * Whether a merged Wave `Button` set `disabledFocusable`: the dismiss button is then unavailable\n * but focusable, as the Button would be.\n */\n disabledFocusable: boolean;\n}\n\nconst noop = () => {};\n\n/** `props` without the naming attributes, and whether any was set. */\nfunction withoutName(props: UnknownProps): { props: UnknownProps; ignoredName: boolean } {\n const result: UnknownProps = {};\n let ignoredName = false;\n for (const [key, value] of Object.entries(props)) {\n if (NAME_KEYS.has(key)) {\n if (value !== undefined) ignoredName = true;\n } else {\n result[key] = value;\n }\n }\n return { props: result, ignoredName };\n}\n\nconst iconClassName = 'inline-flex items-center justify-center';\n\nfunction isPlainObject(value: unknown): value is UnknownProps {\n if (typeof value !== 'object' || value === null) return false;\n if (React.isValidElement(value) || Symbol.iterator in value) return false;\n const proto: unknown = Object.getPrototypeOf(value);\n return proto === null || proto === Object.prototype;\n}\n\n/**\n * The decorative default dismiss glyph. It carries the dismiss icon part class when it is the\n * dismiss button's own content, not when the element of a slot object wraps it.\n */\nfunction defaultDismissContent(className?: string): React.ReactNode {\n return <DismissIcon size={12} className={className} />;\n}\n\n/**\n * Splits the dismissIcon slot into dismiss-button props and icon content (C-SLOTS). The icon\n * content is `aria-hidden`, so no attribute that means something to assistive technology stays on\n * it: button-form props go to the dismiss button, and so do the `aria-*` attributes of an icon slot\n * object; the naming attributes are dropped (see {@link NAME_KEYS}).\n *\n * Content that renders nothing (`[]`, `<></>`, a childless merged button, a slot object without\n * `children`) shows the default icon, so the dismiss button is never an empty, invisible Tab stop.\n */\nfunction resolveDismissSlot(slot: TagOwnProps['dismissIcon']): ResolvedDismissSlot {\n if (!slotRendersContent(slot)) {\n return {\n buttonProps: null,\n content: defaultDismissContent(tagClassNames.dismissIcon),\n warning: null,\n ignoredName: false,\n contentMayName: false,\n literalTextLabel: false,\n disabledFocusable: false,\n };\n }\n\n // A `<button>` or a Wave `Button` (also one written in a Server Component, whose type arrives as\n // a lazy reference) is merged into the dismiss button. Its content is rendered as is, after the\n // Button's icon, which is decorative (as in MessageBar and SearchBox); its text label names it.\n const elementType = getElementType(slot as React.ReactNode);\n if (\n React.isValidElement<WaveButtonSlotProps>(slot) &&\n (elementType === 'button' || elementType === Button)\n ) {\n const { children, dangerouslySetInnerHTML: markup, ...elementProps } = slot.props;\n const isWaveButton = elementType === Button;\n let slotProps: UnknownProps = elementProps;\n if (isWaveButton) {\n // Wave Button's own props are not attributes: `icon`, `iconPosition` and\n // `disabledFocusable` are applied here, the others (`appearance`, `size`) are dropped.\n slotProps = {};\n for (const [key, value] of Object.entries(elementProps)) {\n if (!BUTTON_OWN_PROP_KEYS.has(key)) slotProps[key] = value;\n }\n }\n const icon = isWaveButton ? elementProps.icon : undefined;\n const { props: buttonProps, ignoredName } = withoutName(slotProps);\n const iconNode = slotRendersContent(icon)\n ? renderSlot(icon, 'span', cn(tagClassNames.dismissIcon, iconClassName), {\n 'aria-hidden': true,\n })\n : null;\n // A generator is read once by the check; its items are what renders (and names the button).\n // Markup of the merged button (`dangerouslySetInnerHTML`) is its content as well: the dismiss\n // button holds its own name text, so the markup renders in a span inside it.\n const ownContent =\n markup != null ? (\n <span className={iconClassName} dangerouslySetInnerHTML={markup} />\n ) : (\n materialiseSlotContent(children)\n );\n return {\n buttonProps,\n content:\n iconNode || slotRendersContent(ownContent)\n ? placeButtonIcon(iconNode, ownContent, isWaveButton && elementProps.iconPosition)\n : defaultDismissContent(tagClassNames.dismissIcon),\n warning: 'button-element',\n ignoredName,\n contentMayName: true,\n literalTextLabel: hasTextLabel(ownContent),\n disabledFocusable: isWaveButton && Boolean(elementProps.disabledFocusable),\n };\n }\n\n if (isPlainObject(slot)) {\n // 0.4 rendered the whole object as the dismiss element, so an object with button props\n // describes the button: everything but its content goes to the dismiss button. `as: Button`\n // is that form too (a button cannot contain a button); its icon becomes decorative content.\n const asWaveButton = slot.as === Button;\n const isButtonObject =\n slot.as === 'button' ||\n asWaveButton ||\n Object.keys(slot).some((key) => BUTTON_ONLY_KEYS.has(key) || HANDLER_KEY.test(key));\n const buttonProps: UnknownProps = {};\n const contentProps: UnknownProps = {};\n // Wave Button's own props are not attributes: `icon`, `iconPosition` and `disabledFocusable`\n // are applied below, the others (`appearance`, `size`) are dropped.\n const ownProps: UnknownProps = {};\n let ignoredName = false;\n for (const [key, value] of Object.entries(slot)) {\n if (key === 'as') {\n if (value !== 'button' && !asWaveButton) contentProps.as = value;\n } else if (asWaveButton && BUTTON_OWN_PROP_KEYS.has(key)) {\n ownProps[key] = value;\n } else if (NAME_KEYS.has(key)) {\n if (value !== undefined) ignoredName = true;\n } else if (key === 'children' || key === 'dangerouslySetInnerHTML') {\n // Content, also in the button-object form: the dismiss button holds its own name text.\n contentProps[key] = value;\n } else if (isButtonObject || (key.startsWith('aria-') && key !== 'aria-hidden')) {\n buttonProps[key] = value;\n } else {\n contentProps[key] = value;\n }\n }\n // An object without content styles the default icon, e.g. `{ className: 'text-error' }` (as in\n // MessageBar and SearchBox); a Wave Button's icon comes before the content (after it with\n // `iconPosition=\"after\"`).\n // The dismiss icon part is the merged Button's icon element when there is one, else the\n // element this slot object renders (a default glyph inside it stays without the part class).\n const hasButtonIcon = slotRendersContent(ownProps.icon);\n if (hasButtonIcon) {\n contentProps.children = placeButtonIcon(\n renderSlot(\n ownProps.icon as Slot<'span'>,\n 'span',\n cn(tagClassNames.dismissIcon, iconClassName),\n ),\n materialiseSlotContent(contentProps.children),\n ownProps.iconPosition,\n );\n } else if (slotWrapsDefaultContent(contentProps.as ?? 'span', contentProps)) {\n contentProps.children = defaultDismissContent();\n }\n return {\n buttonProps: isButtonObject || Object.keys(buttonProps).length > 0 ? buttonProps : null,\n content: renderSlot(\n contentProps as SlotObject<'span'>,\n 'span',\n cn(!hasButtonIcon && tagClassNames.dismissIcon, iconClassName),\n { 'aria-hidden': true },\n ),\n warning: isButtonObject ? 'button-object' : null,\n ignoredName,\n contentMayName: false,\n literalTextLabel: false,\n disabledFocusable: Boolean(ownProps.disabledFocusable),\n };\n }\n\n return {\n buttonProps: null,\n content: renderSlot(\n slot as Slot<'span'>,\n 'span',\n cn(tagClassNames.dismissIcon, iconClassName),\n {\n 'aria-hidden': true,\n },\n ),\n warning: null,\n ignoredName: false,\n contentMayName: false,\n literalTextLabel: false,\n disabledFocusable: false,\n };\n}\n\n/**\n * A compact label (a \"chip\") for a keyword, category or filter, optionally dismissible.\n *\n * - The dismiss button is a real `<button type=\"button\">` wired to `onDismiss`. Its accessible\n * name is `dismissLabel` plus the tag content (\"Dismiss Cherry\"), so a row of tags has\n * distinguishable dismiss buttons.\n * - `dismissIcon` replaces only the icon inside that button (see {@link TagOwnProps.dismissIcon}).\n * - Polymorphic: `as=\"a\"` renders a link chip with anchor props type-checked.\n *\n * **Focus after dismissal.** A tag cannot keep focus once you remove it. When `onDismiss` removes\n * the tag, move focus to the next tag's dismiss button (else the previous one, else a sensible\n * element nearby); TagGroup (planned) will do this for you. The neighbour stays mounted, so you\n * can focus it in `onDismiss` before removing the tag.\n *\n * @example\n * <Tag>React</Tag>\n * <Tag dismissible onDismiss={() => remove('cherry')}>Cherry</Tag>\n * <Tag dismissible dismissLabel=\"Remove\" dismissIcon={<CloseIcon />}>Cherry</Tag>\n */\nexport const Tag: PolymorphicComponent<'span', TagOwnProps> = (props) => {\n const {\n as,\n dismissible,\n onDismiss,\n dismissIcon,\n dismissLabel = 'Dismiss',\n className,\n children,\n ref,\n ...rest\n } = props as TagImplProps;\n const Component: React.ElementType = as ?? 'span';\n const contentId = useId('tag-content');\n const dismissLabelId = useId('tag-dismiss');\n const dismissTextId = useId('tag-dismiss-text');\n\n const {\n buttonProps: slotButtonProps,\n content,\n warning,\n ignoredName,\n contentMayName,\n literalTextLabel,\n disabledFocusable,\n } = resolveDismissSlot(dismissible ? dismissIcon : undefined);\n\n // C-SLOTS naming (WCAG 2.5.3 Label in Name): the rendered text label of a merged button replaces\n // `dismissLabel` in the name (\"Remove Cherry\"). The literal content decides on the server and on\n // the first render; after mount, the rendered content does (text from components, later changes).\n const [labelTarget, setLabelTarget] = React.useState<HTMLSpanElement | null>(null);\n const subscribeToContent = React.useCallback(\n (onChange: () => void) => (labelTarget ? observeTextLabel(labelTarget, onChange) : noop),\n [labelTarget],\n );\n const contentHasTextLabel = React.useSyncExternalStore(\n subscribeToContent,\n () => (labelTarget ? hasRenderedTextLabel(labelTarget) : literalTextLabel),\n () => literalTextLabel,\n );\n const namedByContent = contentMayName && contentHasTextLabel;\n\n React.useEffect(() => {\n if (warning === 'button-element') {\n warnOnce(\n 'Tag:dismissIcon-button',\n 'Tag: `dismissIcon` received a button. Its props were merged into the built-in dismiss button (a button cannot contain another button), which is named by its text label (or `dismissLabel`) and the tag content. Pass icon content instead, e.g. `dismissIcon={<CloseIcon />}`, and handle the dismissal in `onDismiss`.',\n );\n } else if (warning === 'button-object') {\n warnDeprecated(\n 'Tag',\n 'dismissIcon={{ onClick, type, disabled, … }} (button props on the slot object)',\n 'onDismiss and icon content in dismissIcon',\n 'Its props are merged onto the built-in dismiss button, which is named by `dismissLabel` and the tag content.',\n );\n }\n }, [warning]);\n\n // `onDismiss`/`dismissIcon` alone render no dismiss button (unlike MessageBar's `onDismiss`).\n // An explicit `dismissible={false}` is a deliberate state, so only a missing flag warns.\n const dismissPropsIgnored =\n dismissible === undefined && (onDismiss !== undefined || dismissIcon !== undefined);\n React.useEffect(() => {\n if (dismissPropsIgnored) {\n warnOnce(\n 'Tag:dismiss-without-dismissible',\n 'Tag: `onDismiss` and `dismissIcon` take effect only with `dismissible`; no dismiss button was rendered. Add `dismissible` to render it.',\n );\n }\n }, [dismissPropsIgnored]);\n\n React.useEffect(() => {\n if (ignoredName) {\n warnOnce(\n 'Tag:dismissIcon-name',\n 'Tag: `aria-label`/`aria-labelledby` on `dismissIcon` are ignored. The dismiss button is named by `dismissLabel` (default \"Dismiss\") and the tag content, e.g. \"Dismiss Cherry\"; set `dismissLabel` to change or localise it.',\n );\n }\n }, [ignoredName]);\n\n const ownButtonProps: UnknownProps = {\n type: 'button',\n className: cn(\n tagClassNames.dismissButton,\n 'inline-flex size-5 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 text-foreground',\n 'not-disabled:not-aria-disabled:hover:bg-subtle-pressed',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n mergedAriaDisabledClasses,\n focusRing,\n ),\n 'aria-labelledby': `${namedByContent ? dismissTextId : dismissLabelId} ${contentId}`,\n };\n if (onDismiss) ownButtonProps.onClick = onDismiss;\n const dismissButtonProps = slotButtonProps\n ? mergeProps(ownButtonProps, slotButtonProps)\n : ownButtonProps;\n\n return (\n <Component\n ref={ref}\n className={cn(\n tagClassNames.root,\n 'inline-flex items-center gap-1 rounded-full bg-muted py-1 ps-3 text-body-1 text-foreground',\n dismissible ? 'pe-1.5' : 'pe-3',\n className,\n )}\n {...rest}\n >\n <span\n id={contentId}\n className={cn(tagClassNames.primaryText, 'inline-flex items-center gap-1')}\n >\n {children}\n </span>\n {dismissible && (\n <button\n {...dismissButtonProps}\n type={(dismissButtonProps.type as 'button' | 'submit' | 'reset' | undefined) ?? 'button'}\n // A merged `disabledFocusable` Button makes the dismiss button unavailable but focusable\n // (spread last: it wins over `disabled` and `onDismiss`).\n {...(disabledFocusable ? MERGED_DISABLED_FOCUSABLE_PROPS : undefined)}\n >\n <span id={dismissLabelId} className=\"sr-only\">\n {dismissLabel}\n </span>\n {contentMayName ? (\n // The merged button's own content, rendered as is: its text label can name the button.\n // `gap-[inherit]` keeps a gap set on the button between the content items.\n <span\n id={dismissTextId}\n ref={setLabelTarget}\n className=\"inline-flex items-center justify-center gap-[inherit]\"\n >\n {content}\n </span>\n ) : (\n content\n )}\n </button>\n )}\n </Component>\n );\n};\n\nTag.displayName = 'Tag';\n"],"mappings":";;;;;;;;;;;;;;;;AA2GA,IAA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