@mortenbrudvik/waveui 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (408) hide show
  1. package/README.md +395 -132
  2. package/dist/components/button/Button.cjs +1 -1
  3. package/dist/components/button/Button.cjs.map +1 -1
  4. package/dist/components/button/Button.mjs +36 -35
  5. package/dist/components/button/Button.mjs.map +1 -1
  6. package/dist/components/button/Button.slots.cjs +1 -1
  7. package/dist/components/button/Button.slots.cjs.map +1 -1
  8. package/dist/components/button/Button.slots.mjs +31 -21
  9. package/dist/components/button/Button.slots.mjs.map +1 -1
  10. package/dist/components/button/CompoundButton.cjs +1 -1
  11. package/dist/components/button/CompoundButton.cjs.map +1 -1
  12. package/dist/components/button/CompoundButton.mjs +31 -29
  13. package/dist/components/button/CompoundButton.mjs.map +1 -1
  14. package/dist/components/button/Link.cjs +1 -1
  15. package/dist/components/button/Link.cjs.map +1 -1
  16. package/dist/components/button/Link.mjs +24 -23
  17. package/dist/components/button/Link.mjs.map +1 -1
  18. package/dist/components/button/MenuButton.cjs +1 -1
  19. package/dist/components/button/MenuButton.cjs.map +1 -1
  20. package/dist/components/button/MenuButton.mjs +29 -28
  21. package/dist/components/button/MenuButton.mjs.map +1 -1
  22. package/dist/components/button/SplitButton.cjs +1 -1
  23. package/dist/components/button/SplitButton.cjs.map +1 -1
  24. package/dist/components/button/SplitButton.mjs +46 -45
  25. package/dist/components/button/SplitButton.mjs.map +1 -1
  26. package/dist/components/button/ToggleButton.cjs +1 -1
  27. package/dist/components/button/ToggleButton.cjs.map +1 -1
  28. package/dist/components/button/ToggleButton.mjs +38 -35
  29. package/dist/components/button/ToggleButton.mjs.map +1 -1
  30. package/dist/components/button/Toolbar.cjs +1 -1
  31. package/dist/components/button/Toolbar.cjs.map +1 -1
  32. package/dist/components/button/Toolbar.mjs +43 -42
  33. package/dist/components/button/Toolbar.mjs.map +1 -1
  34. package/dist/components/button/Toolbar.parts.cjs +1 -1
  35. package/dist/components/button/Toolbar.parts.cjs.map +1 -1
  36. package/dist/components/button/Toolbar.parts.mjs +76 -81
  37. package/dist/components/button/Toolbar.parts.mjs.map +1 -1
  38. package/dist/components/data-display/Avatar.cjs +1 -1
  39. package/dist/components/data-display/Avatar.cjs.map +1 -1
  40. package/dist/components/data-display/Avatar.mjs +72 -67
  41. package/dist/components/data-display/Avatar.mjs.map +1 -1
  42. package/dist/components/data-display/AvatarGroup.cjs +1 -1
  43. package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
  44. package/dist/components/data-display/AvatarGroup.mjs +89 -88
  45. package/dist/components/data-display/AvatarGroup.mjs.map +1 -1
  46. package/dist/components/data-display/Badge.cjs +1 -1
  47. package/dist/components/data-display/Badge.cjs.map +1 -1
  48. package/dist/components/data-display/Badge.mjs +17 -16
  49. package/dist/components/data-display/Badge.mjs.map +1 -1
  50. package/dist/components/data-display/CounterBadge.cjs +1 -1
  51. package/dist/components/data-display/CounterBadge.cjs.map +1 -1
  52. package/dist/components/data-display/CounterBadge.mjs +18 -17
  53. package/dist/components/data-display/CounterBadge.mjs.map +1 -1
  54. package/dist/components/data-display/Divider.cjs +1 -1
  55. package/dist/components/data-display/Divider.cjs.map +1 -1
  56. package/dist/components/data-display/Divider.mjs +31 -30
  57. package/dist/components/data-display/Divider.mjs.map +1 -1
  58. package/dist/components/data-display/Image.cjs +1 -1
  59. package/dist/components/data-display/Image.cjs.map +1 -1
  60. package/dist/components/data-display/Image.mjs +16 -15
  61. package/dist/components/data-display/Image.mjs.map +1 -1
  62. package/dist/components/data-display/InfoLabel.cjs +1 -1
  63. package/dist/components/data-display/InfoLabel.cjs.map +1 -1
  64. package/dist/components/data-display/InfoLabel.mjs +74 -73
  65. package/dist/components/data-display/InfoLabel.mjs.map +1 -1
  66. package/dist/components/data-display/List.cjs +1 -1
  67. package/dist/components/data-display/List.cjs.map +1 -1
  68. package/dist/components/data-display/List.mjs +175 -174
  69. package/dist/components/data-display/List.mjs.map +1 -1
  70. package/dist/components/data-display/Persona.cjs +1 -1
  71. package/dist/components/data-display/Persona.cjs.map +1 -1
  72. package/dist/components/data-display/Persona.mjs +31 -29
  73. package/dist/components/data-display/Persona.mjs.map +1 -1
  74. package/dist/components/data-display/PresenceBadge.cjs +1 -1
  75. package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
  76. package/dist/components/data-display/PresenceBadge.mjs +25 -24
  77. package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
  78. package/dist/components/data-display/Tag.cjs +1 -1
  79. package/dist/components/data-display/Tag.cjs.map +1 -1
  80. package/dist/components/data-display/Tag.mjs +87 -82
  81. package/dist/components/data-display/Tag.mjs.map +1 -1
  82. package/dist/components/feedback/MessageBar.cjs +1 -1
  83. package/dist/components/feedback/MessageBar.cjs.map +1 -1
  84. package/dist/components/feedback/MessageBar.mjs +129 -71
  85. package/dist/components/feedback/MessageBar.mjs.map +1 -1
  86. package/dist/components/feedback/MessageBar.parts.cjs +2 -0
  87. package/dist/components/feedback/MessageBar.parts.cjs.map +1 -0
  88. package/dist/components/feedback/MessageBar.parts.mjs +84 -0
  89. package/dist/components/feedback/MessageBar.parts.mjs.map +1 -0
  90. package/dist/components/feedback/MessageBar.reflow.cjs +2 -0
  91. package/dist/components/feedback/MessageBar.reflow.cjs.map +1 -0
  92. package/dist/components/feedback/MessageBar.reflow.mjs +74 -0
  93. package/dist/components/feedback/MessageBar.reflow.mjs.map +1 -0
  94. package/dist/components/feedback/MessageBar.status.cjs +1 -1
  95. package/dist/components/feedback/MessageBar.status.cjs.map +1 -1
  96. package/dist/components/feedback/MessageBar.status.mjs +2 -1
  97. package/dist/components/feedback/MessageBar.status.mjs.map +1 -1
  98. package/dist/components/feedback/ProgressBar.cjs +1 -1
  99. package/dist/components/feedback/ProgressBar.cjs.map +1 -1
  100. package/dist/components/feedback/ProgressBar.mjs +44 -43
  101. package/dist/components/feedback/ProgressBar.mjs.map +1 -1
  102. package/dist/components/feedback/Skeleton.cjs +1 -1
  103. package/dist/components/feedback/Skeleton.cjs.map +1 -1
  104. package/dist/components/feedback/Skeleton.mjs +26 -24
  105. package/dist/components/feedback/Skeleton.mjs.map +1 -1
  106. package/dist/components/feedback/Spinner.cjs +1 -1
  107. package/dist/components/feedback/Spinner.cjs.map +1 -1
  108. package/dist/components/feedback/Spinner.mjs +32 -31
  109. package/dist/components/feedback/Spinner.mjs.map +1 -1
  110. package/dist/components/feedback/Toast.cjs +1 -1
  111. package/dist/components/feedback/Toast.cjs.map +1 -1
  112. package/dist/components/feedback/Toast.context.cjs +2 -0
  113. package/dist/components/feedback/Toast.context.cjs.map +1 -0
  114. package/dist/components/feedback/Toast.context.mjs +23 -0
  115. package/dist/components/feedback/Toast.context.mjs.map +1 -0
  116. package/dist/components/feedback/Toast.mjs +10 -342
  117. package/dist/components/feedback/Toast.mjs.map +1 -1
  118. package/dist/components/feedback/Toast.parts.cjs +2 -0
  119. package/dist/components/feedback/Toast.parts.cjs.map +1 -0
  120. package/dist/components/feedback/Toast.parts.mjs +98 -0
  121. package/dist/components/feedback/Toast.parts.mjs.map +1 -0
  122. package/dist/components/feedback/Toast.root.cjs +2 -0
  123. package/dist/components/feedback/Toast.root.cjs.map +1 -0
  124. package/dist/components/feedback/Toast.root.mjs +109 -0
  125. package/dist/components/feedback/Toast.root.mjs.map +1 -0
  126. package/dist/components/feedback/Toaster.cjs +2 -0
  127. package/dist/components/feedback/Toaster.cjs.map +1 -0
  128. package/dist/components/feedback/Toaster.mjs +564 -0
  129. package/dist/components/feedback/Toaster.mjs.map +1 -0
  130. package/dist/components/input/AlphaSlider.cjs +2 -0
  131. package/dist/components/input/AlphaSlider.cjs.map +1 -0
  132. package/dist/components/input/AlphaSlider.mjs +115 -0
  133. package/dist/components/input/AlphaSlider.mjs.map +1 -0
  134. package/dist/components/input/Checkbox.cjs +1 -1
  135. package/dist/components/input/Checkbox.cjs.map +1 -1
  136. package/dist/components/input/Checkbox.mjs +47 -46
  137. package/dist/components/input/Checkbox.mjs.map +1 -1
  138. package/dist/components/input/ColorArea.cjs +2 -0
  139. package/dist/components/input/ColorArea.cjs.map +1 -0
  140. package/dist/components/input/ColorArea.mjs +204 -0
  141. package/dist/components/input/ColorArea.mjs.map +1 -0
  142. package/dist/components/input/ColorPicker.cjs +5 -5
  143. package/dist/components/input/ColorPicker.cjs.map +1 -1
  144. package/dist/components/input/ColorPicker.mjs +142 -165
  145. package/dist/components/input/ColorPicker.mjs.map +1 -1
  146. package/dist/components/input/ColorPicker.parts.cjs +2 -0
  147. package/dist/components/input/ColorPicker.parts.cjs.map +1 -0
  148. package/dist/components/input/ColorPicker.parts.mjs +192 -0
  149. package/dist/components/input/ColorPicker.parts.mjs.map +1 -0
  150. package/dist/components/input/ColorSlider.cjs +2 -0
  151. package/dist/components/input/ColorSlider.cjs.map +1 -0
  152. package/dist/components/input/ColorSlider.mjs +138 -0
  153. package/dist/components/input/ColorSlider.mjs.map +1 -0
  154. package/dist/components/input/Combobox.cjs +1 -1
  155. package/dist/components/input/Combobox.cjs.map +1 -1
  156. package/dist/components/input/Combobox.expand.cjs +1 -1
  157. package/dist/components/input/Combobox.expand.cjs.map +1 -1
  158. package/dist/components/input/Combobox.expand.mjs +9 -9
  159. package/dist/components/input/Combobox.expand.mjs.map +1 -1
  160. package/dist/components/input/Combobox.mjs +90 -85
  161. package/dist/components/input/Combobox.mjs.map +1 -1
  162. package/dist/components/input/DatePicker.cjs +1 -1
  163. package/dist/components/input/DatePicker.cjs.map +1 -1
  164. package/dist/components/input/DatePicker.mjs +186 -185
  165. package/dist/components/input/DatePicker.mjs.map +1 -1
  166. package/dist/components/input/Dropdown.cjs +1 -1
  167. package/dist/components/input/Dropdown.cjs.map +1 -1
  168. package/dist/components/input/Dropdown.mjs +71 -68
  169. package/dist/components/input/Dropdown.mjs.map +1 -1
  170. package/dist/components/input/Field.cjs +1 -1
  171. package/dist/components/input/Field.cjs.map +1 -1
  172. package/dist/components/input/Field.mjs +113 -112
  173. package/dist/components/input/Field.mjs.map +1 -1
  174. package/dist/components/input/Input.cjs +1 -1
  175. package/dist/components/input/Input.cjs.map +1 -1
  176. package/dist/components/input/Input.mjs +55 -54
  177. package/dist/components/input/Input.mjs.map +1 -1
  178. package/dist/components/input/Label.cjs +1 -1
  179. package/dist/components/input/Label.cjs.map +1 -1
  180. package/dist/components/input/Label.mjs +12 -11
  181. package/dist/components/input/Label.mjs.map +1 -1
  182. package/dist/components/input/Option.cjs +1 -1
  183. package/dist/components/input/Option.cjs.map +1 -1
  184. package/dist/components/input/Option.mjs +100 -98
  185. package/dist/components/input/Option.mjs.map +1 -1
  186. package/dist/components/input/RadioGroup.cjs +1 -1
  187. package/dist/components/input/RadioGroup.cjs.map +1 -1
  188. package/dist/components/input/RadioGroup.mjs +89 -88
  189. package/dist/components/input/RadioGroup.mjs.map +1 -1
  190. package/dist/components/input/Rating.cjs +1 -1
  191. package/dist/components/input/Rating.cjs.map +1 -1
  192. package/dist/components/input/Rating.mjs +110 -109
  193. package/dist/components/input/Rating.mjs.map +1 -1
  194. package/dist/components/input/SearchBox.cjs +1 -1
  195. package/dist/components/input/SearchBox.cjs.map +1 -1
  196. package/dist/components/input/SearchBox.mjs +118 -119
  197. package/dist/components/input/SearchBox.mjs.map +1 -1
  198. package/dist/components/input/Select.cjs +1 -1
  199. package/dist/components/input/Select.cjs.map +1 -1
  200. package/dist/components/input/Select.mjs +25 -24
  201. package/dist/components/input/Select.mjs.map +1 -1
  202. package/dist/components/input/Slider.cjs +1 -1
  203. package/dist/components/input/Slider.cjs.map +1 -1
  204. package/dist/components/input/Slider.mjs +47 -46
  205. package/dist/components/input/Slider.mjs.map +1 -1
  206. package/dist/components/input/SpinButton.cjs +1 -1
  207. package/dist/components/input/SpinButton.cjs.map +1 -1
  208. package/dist/components/input/SpinButton.mjs +76 -75
  209. package/dist/components/input/SpinButton.mjs.map +1 -1
  210. package/dist/components/input/SwatchPicker.cjs +1 -1
  211. package/dist/components/input/SwatchPicker.cjs.map +1 -1
  212. package/dist/components/input/SwatchPicker.mjs +38 -37
  213. package/dist/components/input/SwatchPicker.mjs.map +1 -1
  214. package/dist/components/input/Switch.cjs +1 -1
  215. package/dist/components/input/Switch.cjs.map +1 -1
  216. package/dist/components/input/Switch.mjs +65 -64
  217. package/dist/components/input/Switch.mjs.map +1 -1
  218. package/dist/components/input/TagPicker.cjs +1 -1
  219. package/dist/components/input/TagPicker.cjs.map +1 -1
  220. package/dist/components/input/TagPicker.mjs +161 -157
  221. package/dist/components/input/TagPicker.mjs.map +1 -1
  222. package/dist/components/input/Textarea.cjs +1 -1
  223. package/dist/components/input/Textarea.cjs.map +1 -1
  224. package/dist/components/input/Textarea.mjs +24 -23
  225. package/dist/components/input/Textarea.mjs.map +1 -1
  226. package/dist/components/input/TimePicker.cjs +1 -1
  227. package/dist/components/input/TimePicker.cjs.map +1 -1
  228. package/dist/components/input/TimePicker.mjs +202 -199
  229. package/dist/components/input/TimePicker.mjs.map +1 -1
  230. package/dist/components/input/colorName.cjs +2 -0
  231. package/dist/components/input/colorName.cjs.map +1 -0
  232. package/dist/components/input/colorName.mjs +30 -0
  233. package/dist/components/input/colorName.mjs.map +1 -0
  234. package/dist/components/input/colorUtils.cjs +1 -1
  235. package/dist/components/input/colorUtils.cjs.map +1 -1
  236. package/dist/components/input/colorUtils.mjs +154 -56
  237. package/dist/components/input/colorUtils.mjs.map +1 -1
  238. package/dist/components/layout/Accordion.cjs +1 -1
  239. package/dist/components/layout/Accordion.cjs.map +1 -1
  240. package/dist/components/layout/Accordion.mjs +130 -129
  241. package/dist/components/layout/Accordion.mjs.map +1 -1
  242. package/dist/components/layout/Card.cjs +1 -1
  243. package/dist/components/layout/Card.cjs.map +1 -1
  244. package/dist/components/layout/Card.mjs +78 -77
  245. package/dist/components/layout/Card.mjs.map +1 -1
  246. package/dist/components/layout/Carousel.cjs +1 -1
  247. package/dist/components/layout/Carousel.cjs.map +1 -1
  248. package/dist/components/layout/Carousel.mjs +111 -110
  249. package/dist/components/layout/Carousel.mjs.map +1 -1
  250. package/dist/components/layout/Flex.cjs +1 -1
  251. package/dist/components/layout/Flex.cjs.map +1 -1
  252. package/dist/components/layout/Flex.mjs +22 -21
  253. package/dist/components/layout/Flex.mjs.map +1 -1
  254. package/dist/components/layout/Grid.cjs +1 -1
  255. package/dist/components/layout/Grid.cjs.map +1 -1
  256. package/dist/components/layout/Grid.mjs +19 -18
  257. package/dist/components/layout/Grid.mjs.map +1 -1
  258. package/dist/components/layout/Overflow.cjs +1 -1
  259. package/dist/components/layout/Overflow.cjs.map +1 -1
  260. package/dist/components/layout/Overflow.mjs +92 -91
  261. package/dist/components/layout/Overflow.mjs.map +1 -1
  262. package/dist/components/layout/Stack.cjs +1 -1
  263. package/dist/components/layout/Stack.cjs.map +1 -1
  264. package/dist/components/layout/Stack.mjs +14 -13
  265. package/dist/components/layout/Stack.mjs.map +1 -1
  266. package/dist/components/layout/TabList.cjs +1 -1
  267. package/dist/components/layout/TabList.cjs.map +1 -1
  268. package/dist/components/layout/TabList.mjs +118 -117
  269. package/dist/components/layout/TabList.mjs.map +1 -1
  270. package/dist/components/layout/Tree.cjs +1 -1
  271. package/dist/components/layout/Tree.cjs.map +1 -1
  272. package/dist/components/layout/Tree.context.cjs +2 -0
  273. package/dist/components/layout/Tree.context.cjs.map +1 -0
  274. package/dist/components/layout/Tree.context.mjs +33 -0
  275. package/dist/components/layout/Tree.context.mjs.map +1 -0
  276. package/dist/components/layout/Tree.core.cjs +2 -0
  277. package/dist/components/layout/Tree.core.cjs.map +1 -0
  278. package/dist/components/layout/Tree.core.mjs +416 -0
  279. package/dist/components/layout/Tree.core.mjs.map +1 -0
  280. package/dist/components/layout/Tree.itemPersonaLayout.cjs +2 -0
  281. package/dist/components/layout/Tree.itemPersonaLayout.cjs.map +1 -0
  282. package/dist/components/layout/Tree.itemPersonaLayout.mjs +46 -0
  283. package/dist/components/layout/Tree.itemPersonaLayout.mjs.map +1 -0
  284. package/dist/components/layout/Tree.mjs +7 -215
  285. package/dist/components/layout/Tree.mjs.map +1 -1
  286. package/dist/components/layout/Tree.selection.cjs +2 -0
  287. package/dist/components/layout/Tree.selection.cjs.map +1 -0
  288. package/dist/components/layout/Tree.selection.mjs +73 -0
  289. package/dist/components/layout/Tree.selection.mjs.map +1 -0
  290. package/dist/components/navigation/Breadcrumb.cjs +1 -1
  291. package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
  292. package/dist/components/navigation/Breadcrumb.mjs +76 -75
  293. package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
  294. package/dist/components/navigation/Menu.group.cjs +1 -1
  295. package/dist/components/navigation/Menu.group.cjs.map +1 -1
  296. package/dist/components/navigation/Menu.group.mjs +39 -37
  297. package/dist/components/navigation/Menu.group.mjs.map +1 -1
  298. package/dist/components/navigation/Menu.items.cjs +1 -1
  299. package/dist/components/navigation/Menu.items.cjs.map +1 -1
  300. package/dist/components/navigation/Menu.items.mjs +67 -61
  301. package/dist/components/navigation/Menu.items.mjs.map +1 -1
  302. package/dist/components/navigation/Menu.link.cjs +1 -1
  303. package/dist/components/navigation/Menu.link.cjs.map +1 -1
  304. package/dist/components/navigation/Menu.link.mjs +34 -28
  305. package/dist/components/navigation/Menu.link.mjs.map +1 -1
  306. package/dist/components/navigation/Menu.popover.cjs +1 -1
  307. package/dist/components/navigation/Menu.popover.cjs.map +1 -1
  308. package/dist/components/navigation/Menu.popover.mjs +110 -109
  309. package/dist/components/navigation/Menu.popover.mjs.map +1 -1
  310. package/dist/components/navigation/Menu.root.cjs +1 -1
  311. package/dist/components/navigation/Menu.root.cjs.map +1 -1
  312. package/dist/components/navigation/Menu.root.mjs +171 -170
  313. package/dist/components/navigation/Menu.root.mjs.map +1 -1
  314. package/dist/components/navigation/Menu.selectable.cjs +1 -1
  315. package/dist/components/navigation/Menu.selectable.cjs.map +1 -1
  316. package/dist/components/navigation/Menu.selectable.mjs +85 -63
  317. package/dist/components/navigation/Menu.selectable.mjs.map +1 -1
  318. package/dist/components/navigation/Menu.splitGroup.cjs +1 -1
  319. package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -1
  320. package/dist/components/navigation/Menu.splitGroup.mjs +27 -26
  321. package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -1
  322. package/dist/components/navigation/Menu.trigger.cjs +1 -1
  323. package/dist/components/navigation/Menu.trigger.cjs.map +1 -1
  324. package/dist/components/navigation/Menu.trigger.mjs +6 -6
  325. package/dist/components/navigation/Nav.cjs +1 -1
  326. package/dist/components/navigation/Nav.cjs.map +1 -1
  327. package/dist/components/navigation/Nav.mjs +170 -155
  328. package/dist/components/navigation/Nav.mjs.map +1 -1
  329. package/dist/components/navigation/Pagination.cjs +1 -1
  330. package/dist/components/navigation/Pagination.cjs.map +1 -1
  331. package/dist/components/navigation/Pagination.mjs +73 -65
  332. package/dist/components/navigation/Pagination.mjs.map +1 -1
  333. package/dist/components/navigation/Stepper.cjs +1 -1
  334. package/dist/components/navigation/Stepper.cjs.map +1 -1
  335. package/dist/components/navigation/Stepper.mjs +110 -109
  336. package/dist/components/navigation/Stepper.mjs.map +1 -1
  337. package/dist/components/overlays/Dialog.cjs +1 -1
  338. package/dist/components/overlays/Dialog.cjs.map +1 -1
  339. package/dist/components/overlays/Dialog.mjs +109 -108
  340. package/dist/components/overlays/Dialog.mjs.map +1 -1
  341. package/dist/components/overlays/Drawer.cjs +1 -1
  342. package/dist/components/overlays/Drawer.cjs.map +1 -1
  343. package/dist/components/overlays/Drawer.mjs +110 -109
  344. package/dist/components/overlays/Drawer.mjs.map +1 -1
  345. package/dist/components/overlays/Popover.cjs +1 -1
  346. package/dist/components/overlays/Popover.cjs.map +1 -1
  347. package/dist/components/overlays/Popover.mjs +229 -227
  348. package/dist/components/overlays/Popover.mjs.map +1 -1
  349. package/dist/components/overlays/TeachingPopover.cjs +1 -1
  350. package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
  351. package/dist/components/overlays/TeachingPopover.mjs +41 -37
  352. package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
  353. package/dist/components/overlays/Tooltip.cjs +1 -1
  354. package/dist/components/overlays/Tooltip.cjs.map +1 -1
  355. package/dist/components/overlays/Tooltip.mjs +87 -86
  356. package/dist/components/overlays/Tooltip.mjs.map +1 -1
  357. package/dist/components/portal/Portal.cjs +1 -1
  358. package/dist/components/portal/Portal.cjs.map +1 -1
  359. package/dist/components/portal/Portal.mjs +33 -32
  360. package/dist/components/portal/Portal.mjs.map +1 -1
  361. package/dist/components/provider/WaveProvider.cjs +1 -1
  362. package/dist/components/provider/WaveProvider.cjs.map +1 -1
  363. package/dist/components/provider/WaveProvider.mjs +31 -30
  364. package/dist/components/provider/WaveProvider.mjs.map +1 -1
  365. package/dist/components/table/DataGrid.cjs +1 -1
  366. package/dist/components/table/DataGrid.cjs.map +1 -1
  367. package/dist/components/table/DataGrid.mjs +228 -227
  368. package/dist/components/table/DataGrid.mjs.map +1 -1
  369. package/dist/components/table/Table.cjs +1 -1
  370. package/dist/components/table/Table.cjs.map +1 -1
  371. package/dist/components/table/Table.mjs +60 -59
  372. package/dist/components/table/Table.mjs.map +1 -1
  373. package/dist/components/typography/Text.cjs +1 -1
  374. package/dist/components/typography/Text.cjs.map +1 -1
  375. package/dist/components/typography/Text.mjs +12 -11
  376. package/dist/components/typography/Text.mjs.map +1 -1
  377. package/dist/hooks/useMediaQuery.cjs +2 -0
  378. package/dist/hooks/useMediaQuery.cjs.map +1 -0
  379. package/dist/hooks/useMediaQuery.mjs +20 -0
  380. package/dist/hooks/useMediaQuery.mjs.map +1 -0
  381. package/dist/hooks/usePrefersReducedMotion.cjs +1 -1
  382. package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -1
  383. package/dist/hooks/usePrefersReducedMotion.mjs +4 -18
  384. package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -1
  385. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  386. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  387. package/dist/hooks/useRovingTabIndex.mjs +3 -3
  388. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  389. package/dist/index.cjs +1 -1
  390. package/dist/index.d.cts +2089 -102
  391. package/dist/index.d.ts +2089 -102
  392. package/dist/index.mjs +99 -87
  393. package/dist/lib/classNames.cjs +2 -0
  394. package/dist/lib/classNames.cjs.map +1 -0
  395. package/dist/lib/classNames.mjs +415 -0
  396. package/dist/lib/classNames.mjs.map +1 -0
  397. package/dist/lib/color.cjs +2 -0
  398. package/dist/lib/color.cjs.map +1 -0
  399. package/dist/lib/color.mjs +86 -0
  400. package/dist/lib/color.mjs.map +1 -0
  401. package/dist/lib/globalRegistry.cjs.map +1 -1
  402. package/dist/lib/globalRegistry.mjs.map +1 -1
  403. package/dist/lib/toaster.cjs +2 -0
  404. package/dist/lib/toaster.cjs.map +1 -0
  405. package/dist/lib/toaster.mjs +77 -0
  406. package/dist/lib/toaster.mjs.map +1 -0
  407. package/dist/styles.css +1 -1
  408. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Card.cjs","names":["React","useId","useMergedRefs","isDev","hasWarned","getTabbableElements","useEventCallback","composeEventHandlers","cn","forcedColors","CheckIcon","slotRendersContent","materialiseSlotContent","require_runtime","require_cn","require_dev","require_slot","require_composeEventHandlers","require_useEventCallback","require_useId","require_focus","require_useMergedRefs","require_styles","require_icons","react","react_jsx_runtime","INTERACTIVE_SELECTOR","ELEMENT_NODE","isForeignEvent","target","event","root","control","NESTED_INTERACTIVE_WARNING","CardTitleIdContext","CardRoot","rest","props","Component","as","selectable","onSelect","checkboxMode","selectionControl","cardMode","nativeButton","titleId","rootRef","mergedRef","ref","selectLabel","spaceArmedRef","setSpaceArmed","armed","takeSpaceArmed","handleClick","onClick","keyboardActivation","handleKeyDown","onKeyDown","handleKeyUp","onKeyUp","handleBlur","onBlur","defaults","selected","className","children","CardHeader","hasTitle","title","hasSubtitle","subtitle","CardBody","CardFooter","Card"],"sources":["../../../src/components/layout/Card.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { hasWarned, isDev, warnOnce } from '../../lib/dev';\nimport { getTabbableElements } from '../../lib/focus';\nimport { CheckIcon } from '../../lib/icons';\nimport { materialiseSlotContent, slotRendersContent } from '../../lib/slot';\nimport { focusRing, forcedColors } from '../../lib/styles';\nimport type { PolymorphicComponent, PolymorphicProps } from '../../lib/polymorphic';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\n\n/**\n * Elements whose own events a selectable card ignores: a click or key press that starts inside a\n * nested control belongs to that control, never to the card (layout#35). A `<label>` counts too:\n * its click already activates the control it labels.\n */\nconst INTERACTIVE_SELECTOR =\n 'button, a[href], input, select, textarea, label, summary, [role=\"button\"], [tabindex]';\n\n/** `Node.ELEMENT_NODE`, spelled out so no realm's `Node` global is read. */\nconst ELEMENT_NODE = 1;\n\n/**\n * Whether the card must ignore `event`: it started outside the card's DOM, or inside an\n * interactive element nested in `root` (the card itself, which carries `role=\"button\"`/`tabindex`\n * in the default mode, does not count).\n *\n * React events bubble through portals along the component tree, so a menu, popover or dialog\n * opened from inside the card (e.g. a footer overflow menu) reaches the card's handlers although\n * its DOM lives elsewhere. Such a target is not a DOM descendant of the card and never selects it.\n *\n * The target is duck typed (`nodeType`) rather than checked with `instanceof`, so a card rendered\n * into another realm's document (an iframe, or a popout window reached through `createPortal`)\n * still selects: its nodes are not instances of the main realm's `Node`/`Element`.\n */\nfunction isForeignEvent(event: React.SyntheticEvent, root: Element): boolean {\n const target = event.target as Partial<Node> | null;\n if (!target || typeof target.nodeType !== 'number' || !root.contains(target as Node)) {\n return true;\n }\n if (target.nodeType !== ELEMENT_NODE) return false;\n const control = (target as Element).closest(INTERACTIVE_SELECTOR);\n return control !== null && control !== root && root.contains(control);\n}\n\n/** Warn-once key of the \"selectable card contains tabbable elements\" diagnostic. */\nconst NESTED_INTERACTIVE_WARNING = 'Card:nested-interactive';\n\n/**\n * The id of the header title that names the built-in checkbox of a `selectionControl=\"checkbox\"`\n * card; `null` everywhere else (other cards, and a `Card.Header` rendered on its own, which does\n * not require a Card). A string, never an object, so the provider value needs no memoisation.\n */\nconst CardTitleIdContext = React.createContext<string | null>(null);\n\n/**\n * The Card's own props (the XOwnProps rule of `PolymorphicProps`: component-specific props only).\n * Every other prop comes from the rendered element (`as`).\n */\nexport interface CardOwnProps {\n /**\n * Whether the card is selected. Shown with the selected colors plus non-color cues: a 2px primary\n * border (a 1px border plus an inset 1px ring), a Highlight outline in forced-colors mode, and a\n * check glyph (with `selectionControl=\"checkbox\"` the checked checkbox instead).\n *\n * The state reaches assistive technology only on a selectable card (`onSelect`): as\n * `aria-pressed` (default mode) or as the built-in checkbox's checked state. Without `onSelect`,\n * `selected` is a visual state only (the glyph is decorative); state it in the content if it\n * matters to screen-reader users, or make the card selectable.\n */\n selected?: boolean;\n /**\n * Makes the card selectable: called when the card is activated by a click, Enter (on key down)\n * or Space (on key up, like a native button) in the default mode, or when its built-in checkbox\n * changes (`selectionControl=\"checkbox\"`). Clicks and key presses that start inside a nested\n * interactive element (a button, link, input or any element with `tabindex`), or in content\n * portaled out of the card (a menu, popover or dialog opened from it), are ignored, so a footer\n * action never selects the card.\n */\n onSelect?: () => void;\n /**\n * How a selectable card (`onSelect`) exposes its selection:\n * - `'card'` (default): the card itself is the control — `role=\"button\"`, a tab stop, Enter and\n * Space activation and `aria-pressed={selected}` when `selected` is defined. Use it only for\n * cards **without** interactive content: a button inside a `role=\"button\"` card is invalid\n * (axe `nested-interactive`), and a development warning points here. A button's children are\n * presentational, so the card's content is flattened into its name: a heading (e.g.\n * `<Card.Header as=\"h3\">`), list or other structure inside it is not exposed and cannot be\n * reached by heading navigation (no warning covers this). Keep such cards short.\n * - `'checkbox'`: the card is not a widget; a built-in native checkbox (top end corner) carries\n * `selected` and is named by the `Card.Header` title (or `selectLabel`). Pointer clicks on\n * non-interactive card areas still toggle it. Use it for cards with actions, and for cards\n * whose headings or other structure must stay navigable.\n * @default 'card'\n */\n selectionControl?: 'card' | 'checkbox';\n /**\n * Accessible name of the built-in checkbox (`selectionControl=\"checkbox\"`). Defaults to the\n * `Card.Header` title, which the checkbox references with `aria-labelledby`.\n */\n selectLabel?: string;\n}\n\n/**\n * Props of {@link Card} rendered as `C` (default `'div'`). `CardProps` without a type argument is\n * the 0.4 name: the props of a Card rendered as a `<div>`, including `ref`.\n */\nexport type CardProps<C extends React.ElementType = 'div'> = PolymorphicProps<C, CardOwnProps>;\n\n/** The props the implementation reads, for any `as` (the public typing is `PolymorphicComponent`). */\ntype CardImplProps = CardOwnProps &\n Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n type?: string;\n };\n\n// The Card root, documented on the exported `Card` const.\nconst CardRoot: PolymorphicComponent<'div', CardOwnProps> = (props) => {\n const {\n as,\n selected,\n onSelect,\n selectionControl = 'card',\n selectLabel,\n className,\n children,\n ref,\n onClick,\n onKeyDown,\n onKeyUp,\n onBlur,\n ...rest\n } = props as CardImplProps;\n\n const Component: React.ElementType = as ?? 'div';\n const selectable = onSelect !== undefined;\n const checkboxMode = selectable && selectionControl === 'checkbox';\n const cardMode = selectable && !checkboxMode;\n /** A native `<button>` already has the role, tab stop and keyboard activation. */\n const nativeButton = Component === 'button';\n\n const titleId = useId('card-title');\n const rootRef = React.useRef<HTMLElement | null>(null);\n const mergedRef = useMergedRefs<HTMLElement>(ref, rootRef);\n\n // Development diagnostics (C-DEV): read the mounted DOM after every commit (content can change\n // without prop changes), warn once. Once a key has warned, its DOM scan is skipped.\n React.useEffect(() => {\n const root = rootRef.current;\n if (!isDev || !root || !selectable) return;\n if (\n cardMode &&\n !hasWarned(NESTED_INTERACTIVE_WARNING) &&\n getTabbableElements(root).length > 0\n ) {\n warnOnce(\n NESTED_INTERACTIVE_WARNING,\n 'Card: a selectable card (`onSelect`) is a button and must not contain focusable elements (buttons, links, inputs). Use `selectionControl=\"checkbox\"` for cards with interactive content.',\n );\n }\n if (checkboxMode && !selectLabel && !root.ownerDocument.getElementById(titleId)) {\n warnOnce(\n 'Card:checkbox-name',\n 'Card: the selection checkbox has no accessible name. Render a `Card.Header` with a `title`, or pass `selectLabel`.',\n );\n }\n });\n\n /**\n * Set by an unprevented Space keydown on the card; Space selects on the following keyup only\n * while it is set (like a native button and P01's Button: a keyup alone never selects, and\n * moving focus away in between cancels). The ref is only touched from event handlers, through\n * these two stable callbacks (C-HOOKS).\n */\n const spaceArmedRef = React.useRef(false);\n /** Arms (or disarms) Space activation. */\n const setSpaceArmed = useEventCallback((armed: boolean) => {\n spaceArmedRef.current = armed;\n });\n /** Reads and clears the Space arm. */\n const takeSpaceArmed = useEventCallback(() => {\n const armed = spaceArmedRef.current;\n spaceArmedRef.current = false;\n return armed;\n });\n\n const handleClick = composeEventHandlers<React.MouseEvent<HTMLElement>>(onClick, (event) => {\n if (!selectable || isForeignEvent(event, event.currentTarget)) return;\n onSelect();\n });\n\n /** Keyboard activation applies to a `role=\"button\"` card (a native `<button>` has its own). */\n const keyboardActivation = cardMode && !nativeButton;\n\n const handleKeyDown = composeEventHandlers<React.KeyboardEvent<HTMLElement>>(\n onKeyDown,\n (event) => {\n if (!keyboardActivation) return;\n if (event.key !== 'Enter' && event.key !== ' ') return;\n if (isForeignEvent(event, event.currentTarget)) return;\n // Space would scroll the page: prevent it now, select on keyup. Enter selects on keydown; a\n // held Enter does not toggle repeatedly.\n event.preventDefault();\n if (event.key === ' ') setSpaceArmed(true);\n else if (!event.repeat) onSelect?.();\n },\n );\n\n const handleKeyUp = composeEventHandlers<React.KeyboardEvent<HTMLElement>>(\n onKeyUp,\n (event) => {\n if (!keyboardActivation || event.key !== ' ') return;\n // Always consume the arm, also when the consumer prevented this keyup.\n const armed = takeSpaceArmed();\n if (!armed || event.defaultPrevented || isForeignEvent(event, event.currentTarget)) return;\n event.preventDefault();\n onSelect?.();\n },\n { checkDefaultPrevented: false },\n );\n\n // Moving focus away between Space keydown and keyup cancels the activation (native behavior).\n const handleBlur = composeEventHandlers<React.FocusEvent<HTMLElement>>(\n onBlur,\n () => {\n if (keyboardActivation) setSpaceArmed(false);\n },\n { checkDefaultPrevented: false },\n );\n\n /** Defaults the consumer may override (C-COMPOSE: before `{...rest}`). */\n const defaults: Record<string, unknown> = {};\n if (cardMode) {\n if (nativeButton) {\n defaults.type = 'button';\n } else {\n defaults.role = 'button';\n defaults.tabIndex = 0;\n }\n if (selected !== undefined) defaults['aria-pressed'] = selected;\n }\n\n return (\n <CardTitleIdContext.Provider value={checkboxMode ? titleId : null}>\n <Component\n {...defaults}\n {...rest}\n ref={mergedRef}\n data-selected={selected ? '' : undefined}\n className={cn(\n 'overflow-hidden rounded-md border border-border bg-card shadow-4',\n // Positions the check glyph / checkbox; plain cards keep their 0.4 positioning.\n (selectable || selected !== undefined) && 'relative',\n selected &&\n cn(\n 'border-primary bg-selected text-selected-foreground ring-1 ring-inset ring-primary',\n forcedColors.selectedContainer,\n ),\n selectable && 'cursor-pointer',\n cardMode && focusRing,\n className,\n )}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n onBlur={handleBlur}\n >\n {checkboxMode && (\n <input\n type=\"checkbox\"\n checked={selected ?? false}\n onChange={() => onSelect()}\n aria-label={selectLabel}\n aria-labelledby={selectLabel ? undefined : titleId}\n className={cn(\n 'absolute end-3 top-3 m-0 size-4 cursor-pointer accent-primary',\n focusRing,\n )}\n />\n )}\n {selected && !checkboxMode && (\n <CheckIcon size={12} className=\"absolute end-2 top-2 text-primary\" />\n )}\n {children}\n </Component>\n </CardTitleIdContext.Provider>\n );\n};\nCardRoot.displayName = 'Card';\n\n/** The Card.Header's own props (component-specific props only). */\nexport interface CardHeaderOwnProps {\n /**\n * Title content displayed in the card header. It also names a selectable card's built-in\n * checkbox (`selectionControl=\"checkbox\"`). Content that renders nothing (`''`, `[]`, a list of\n * nothing) renders no title element; `0` is content.\n */\n title?: React.ReactNode;\n /** Subtitle content displayed below the title (none when it renders nothing, as `title`). */\n subtitle?: React.ReactNode;\n}\n\n/** Props of {@link CardHeader} rendered as `C` (default `'div'`), including `ref`. */\nexport type CardHeaderProps<C extends React.ElementType = 'div'> = PolymorphicProps<\n C,\n CardHeaderOwnProps\n>;\n\ntype CardHeaderImplProps = CardHeaderOwnProps &\n Omit<React.HTMLAttributes<HTMLElement>, 'title'> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n };\n\n/**\n * The header of a {@link Card}: a title and an optional subtitle, followed by any children.\n * Flat export for React Server Components (`Card.Header` in client files).\n */\nexport const CardHeader: PolymorphicComponent<'div', CardHeaderOwnProps> = (props) => {\n const { as, title, subtitle, className, children, ref, ...rest } = props as CardHeaderImplProps;\n const Component: React.ElementType = as ?? 'div';\n /** Set only inside a `selectionControl=\"checkbox\"` card: the title names its checkbox. */\n const titleId = React.useContext(CardTitleIdContext);\n // A title or subtitle that renders nothing (`''`, `[]`, a list of nothing) gets no element, so a\n // checkbox card with such a title warns about its missing name; `0` is content.\n const hasTitle = slotRendersContent(title);\n const hasSubtitle = slotRendersContent(subtitle);\n return (\n // In a checkbox card the header keeps clear of the checkbox in the top end corner.\n <Component ref={ref} className={cn('p-4', titleId && 'pe-10', className)} {...rest}>\n {hasTitle && (\n <div id={titleId ?? undefined} className=\"text-subtitle-1\">\n {materialiseSlotContent(title)}\n </div>\n )}\n {hasSubtitle && (\n <div className=\"text-caption-1 text-muted-foreground\">\n {materialiseSlotContent(subtitle)}\n </div>\n )}\n {children}\n </Component>\n );\n};\nCardHeader.displayName = 'CardHeader';\n\n/** The Card.Body's own props: none besides the element's (component-specific props only). */\nexport type CardBodyOwnProps = Record<never, never>;\n\n/** Props of {@link CardBody} rendered as `C` (default `'div'`), including `ref`. */\nexport type CardBodyProps<C extends React.ElementType = 'div'> = PolymorphicProps<\n C,\n CardBodyOwnProps\n>;\n\ntype CardSectionImplProps = React.HTMLAttributes<HTMLElement> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n};\n\n/**\n * The main content of a {@link Card}. Flat export for React Server Components (`Card.Body` in\n * client files).\n */\nexport const CardBody: PolymorphicComponent<'div', CardBodyOwnProps> = (props) => {\n const { as, className, ref, ...rest } = props as CardSectionImplProps;\n const Component: React.ElementType = as ?? 'div';\n return <Component ref={ref} className={cn('p-4 pt-0', className)} {...rest} />;\n};\nCardBody.displayName = 'CardBody';\n\n/** The Card.Footer's own props: none besides the element's (component-specific props only). */\nexport type CardFooterOwnProps = Record<never, never>;\n\n/** Props of {@link CardFooter} rendered as `C` (default `'div'`), including `ref`. */\nexport type CardFooterProps<C extends React.ElementType = 'div'> = PolymorphicProps<\n C,\n CardFooterOwnProps\n>;\n\n/**\n * The action row of a {@link Card} (end-aligned). A selectable card with actions here needs\n * `selectionControl=\"checkbox\"`. Flat export for React Server Components (`Card.Footer` in client\n * files).\n */\nexport const CardFooter: PolymorphicComponent<'div', CardFooterOwnProps> = (props) => {\n const { as, className, ref, ...rest } = props as CardSectionImplProps;\n const Component: React.ElementType = as ?? 'div';\n return (\n <Component ref={ref} className={cn('flex justify-end gap-2 p-4 pt-0', className)} {...rest} />\n );\n};\nCardFooter.displayName = 'CardFooter';\n\n/**\n * A surface that groups related content, with `Card.Header`, `Card.Body` and `Card.Footer`.\n *\n * **Selectable cards** (`onSelect`) come in two patterns:\n * - A card without interactive content is itself the control (`selectionControl=\"card\"`, the\n * default): it is a `role=\"button\"` tab stop activated by click, Enter (key down) or Space (key\n * up, cancelled by moving focus away first), with `aria-pressed` reflecting `selected`. Its\n * content becomes the button's name, so headings and other structure inside it are flattened.\n * - A card that contains buttons or links, or headings that must stay navigable, uses\n * `selectionControl=\"checkbox\"`: a built-in checkbox named by the header title carries the\n * selection, and the card's actions and structure stay separate from it.\n *\n * In both modes events that start inside a nested interactive element, or in content portaled out\n * of the card, are ignored. `onClick`, `onKeyDown` and `onKeyUp` are composed with the built-in\n * selection (call `event.preventDefault()` to skip it). A `selected` card without `onSelect` shows\n * the selected look only; its state is not exposed to assistive technology.\n *\n * React Server Components cannot dot into a client module: import the flat names `CardHeader`,\n * `CardBody` and `CardFooter` there; `Card.Header` etc. work in client files.\n *\n * @example\n * <Card onSelect={toggle} selected={selected}>\n * <Card.Header title=\"Pro plan\" subtitle=\"Billed monthly\" />\n * </Card>\n *\n * <Card onSelect={toggle} selected={selected} selectionControl=\"checkbox\">\n * <Card.Header title=\"Pro plan\" />\n * <Card.Footer><Button>Details</Button></Card.Footer>\n * </Card>\n */\nexport const Card = /* @__PURE__ */ Object.assign(CardRoot, {\n Header: CardHeader,\n Body: CardBody,\n Footer: CardFooter,\n});\n"],"mappings":"6fAkBA,IAAM0B,EACJ,wFAGIC,EAAe,EAerB,SAASC,EAAe,EAA6B,EAAwB,CAC3E,IAAMC,EAASC,EAAM,OACrB,GAAI,CAACD,GAAU,OAAOA,EAAO,UAAa,UAAY,CAACE,EAAK,SAASF,CAAc,EACjF,MAAO,GAET,GAAIA,EAAO,WAAaF,EAAc,MAAO,GAC7C,IAAMK,EAAWH,EAAmB,QAAQH,CAAoB,EAChE,OAAOM,IAAY,MAAQA,IAAYD,GAAQA,EAAK,SAASC,CAAO,CACtE,CAGA,IAAMC,EAA6B,0BAO7BC,EAAqBlC,EAAM,cAA6B,IAAI,EAiE5DmC,EAAuD,GAAU,CACrE,GAAM,CACJ,KACA,WACA,WACA,mBAAmB,OACnB,cACA,YACA,WACA,MACA,UACA,YACA,UACA,SACA,GAAGC,GACDC,EAEEC,EAA+BC,GAAM,MACrCC,EAAaC,IAAa,IAAA,GAC1BC,EAAeF,GAAcG,IAAqB,WAClDC,EAAWJ,GAAc,CAACE,EAE1BG,EAAeP,IAAc,SAE7BQ,EAAU7C,EAAAA,MAAM,YAAY,EAC5B8C,EAAU/C,EAAM,OAA2B,IAAI,EAC/CgD,EAAY9C,EAAAA,cAA2B+C,EAAKF,CAAO,EAIzDvB,EAAM,cAAgB,CACpB,IAAMO,EAAOgB,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C,EAAA,IAAA,CAAC,MAAD,CAAK,GAAIqB,GAAW,IAAA,GAAW,UAAU,kBACtC,SAAAlC,EAAAA,uBAAuB0D,CAAK,CAC1B,CAAA,EAENC,IACC,EAAA9C,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,uCACZ,SAAAb,EAAAA,uBAAuB4D,CAAQ,CAC7B,CAAA,EAENL,CACQ,GAEf,EACA,EAAW,YAAc,aAoBzB,IAAaM,EAA2D,GAAU,CAChF,GAAM,CAAE,KAAI,YAAW,MAAK,GAAGrC,GAASC,EAExC,OAAO,EAAAZ,EAAA,IAAA,CAD8Bc,GAAM,MACpC,CAAgB,MAAK,UAAW/B,EAAAA,GAAG,WAAY0D,CAAS,EAAG,GAAI9B,CAAO,CAAA,CAC/E,EACA,EAAS,YAAc,WAgBvB,IAAasC,EAA+D,GAAU,CACpF,GAAM,CAAE,KAAI,YAAW,MAAK,GAAGtC,GAASC,EAExC,OACE,EAAAZ,EAAA,IAAA,CAFmCc,GAAM,MAEzC,CAAgB,MAAK,UAAW/B,EAAAA,GAAG,kCAAmC0D,CAAS,EAAG,GAAI9B,CAAO,CAAA,CAEjG,EACA,EAAW,YAAc,aAgCzB,IAAauC,EAAuB,OAAO,OAAOxC,EAAU,CAC1D,OAAQiC,EACR,KAAMK,EACN,OAAQC,CACV,CAAC"}
1
+ {"version":3,"file":"Card.cjs","names":["React","useId","useMergedRefs","isDev","hasWarned","getTabbableElements","useEventCallback","composeEventHandlers","cn","cardClassNames","forcedColors","CheckIcon","slotRendersContent","cardHeaderClassNames","materialiseSlotContent","cardBodyClassNames","cardFooterClassNames","require_runtime","require_cn","require_dev","require_slot","require_composeEventHandlers","require_classNames","require_useEventCallback","require_useId","require_focus","require_useMergedRefs","require_styles","require_icons","react","react_jsx_runtime","INTERACTIVE_SELECTOR","ELEMENT_NODE","isForeignEvent","target","event","root","control","NESTED_INTERACTIVE_WARNING","CardTitleIdContext","CardRoot","rest","props","Component","as","selectable","onSelect","checkboxMode","selectionControl","cardMode","nativeButton","titleId","rootRef","mergedRef","ref","selectLabel","spaceArmedRef","setSpaceArmed","armed","takeSpaceArmed","handleClick","onClick","keyboardActivation","handleKeyDown","onKeyDown","handleKeyUp","onKeyUp","handleBlur","onBlur","defaults","selected","className","children","CardHeader","hasTitle","title","hasSubtitle","subtitle","CardBody","CardFooter","Card"],"sources":["../../../src/components/layout/Card.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n cardBodyClassNames,\n cardClassNames,\n cardFooterClassNames,\n cardHeaderClassNames,\n} from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { hasWarned, isDev, warnOnce } from '../../lib/dev';\nimport { getTabbableElements } from '../../lib/focus';\nimport { CheckIcon } from '../../lib/icons';\nimport { materialiseSlotContent, slotRendersContent } from '../../lib/slot';\nimport { focusRing, forcedColors } from '../../lib/styles';\nimport type { PolymorphicComponent, PolymorphicProps } from '../../lib/polymorphic';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\n\n/**\n * Elements whose own events a selectable card ignores: a click or key press that starts inside a\n * nested control belongs to that control, never to the card (layout#35). A `<label>` counts too:\n * its click already activates the control it labels.\n */\nconst INTERACTIVE_SELECTOR =\n 'button, a[href], input, select, textarea, label, summary, [role=\"button\"], [tabindex]';\n\n/** `Node.ELEMENT_NODE`, spelled out so no realm's `Node` global is read. */\nconst ELEMENT_NODE = 1;\n\n/**\n * Whether the card must ignore `event`: it started outside the card's DOM, or inside an\n * interactive element nested in `root` (the card itself, which carries `role=\"button\"`/`tabindex`\n * in the default mode, does not count).\n *\n * React events bubble through portals along the component tree, so a menu, popover or dialog\n * opened from inside the card (e.g. a footer overflow menu) reaches the card's handlers although\n * its DOM lives elsewhere. Such a target is not a DOM descendant of the card and never selects it.\n *\n * The target is duck typed (`nodeType`) rather than checked with `instanceof`, so a card rendered\n * into another realm's document (an iframe, or a popout window reached through `createPortal`)\n * still selects: its nodes are not instances of the main realm's `Node`/`Element`.\n */\nfunction isForeignEvent(event: React.SyntheticEvent, root: Element): boolean {\n const target = event.target as Partial<Node> | null;\n if (!target || typeof target.nodeType !== 'number' || !root.contains(target as Node)) {\n return true;\n }\n if (target.nodeType !== ELEMENT_NODE) return false;\n const control = (target as Element).closest(INTERACTIVE_SELECTOR);\n return control !== null && control !== root && root.contains(control);\n}\n\n/** Warn-once key of the \"selectable card contains tabbable elements\" diagnostic. */\nconst NESTED_INTERACTIVE_WARNING = 'Card:nested-interactive';\n\n/**\n * The id of the header title that names the built-in checkbox of a `selectionControl=\"checkbox\"`\n * card; `null` everywhere else (other cards, and a `Card.Header` rendered on its own, which does\n * not require a Card). A string, never an object, so the provider value needs no memoisation.\n */\nconst CardTitleIdContext = React.createContext<string | null>(null);\n\n/**\n * The Card's own props (the XOwnProps rule of `PolymorphicProps`: component-specific props only).\n * Every other prop comes from the rendered element (`as`).\n */\nexport interface CardOwnProps {\n /**\n * Whether the card is selected. Shown with the selected colors plus non-color cues: a 2px primary\n * border (a 1px border plus an inset 1px ring), a Highlight outline in forced-colors mode, and a\n * check glyph (with `selectionControl=\"checkbox\"` the checked checkbox instead).\n *\n * The state reaches assistive technology only on a selectable card (`onSelect`): as\n * `aria-pressed` (default mode) or as the built-in checkbox's checked state. Without `onSelect`,\n * `selected` is a visual state only (the glyph is decorative); state it in the content if it\n * matters to screen-reader users, or make the card selectable.\n */\n selected?: boolean;\n /**\n * Makes the card selectable: called when the card is activated by a click, Enter (on key down)\n * or Space (on key up, like a native button) in the default mode, or when its built-in checkbox\n * changes (`selectionControl=\"checkbox\"`). Clicks and key presses that start inside a nested\n * interactive element (a button, link, input or any element with `tabindex`), or in content\n * portaled out of the card (a menu, popover or dialog opened from it), are ignored, so a footer\n * action never selects the card.\n */\n onSelect?: () => void;\n /**\n * How a selectable card (`onSelect`) exposes its selection:\n * - `'card'` (default): the card itself is the control — `role=\"button\"`, a tab stop, Enter and\n * Space activation and `aria-pressed={selected}` when `selected` is defined. Use it only for\n * cards **without** interactive content: a button inside a `role=\"button\"` card is invalid\n * (axe `nested-interactive`), and a development warning points here. A button's children are\n * presentational, so the card's content is flattened into its name: a heading (e.g.\n * `<Card.Header as=\"h3\">`), list or other structure inside it is not exposed and cannot be\n * reached by heading navigation (no warning covers this). Keep such cards short.\n * - `'checkbox'`: the card is not a widget; a built-in native checkbox (top end corner) carries\n * `selected` and is named by the `Card.Header` title (or `selectLabel`). Pointer clicks on\n * non-interactive card areas still toggle it. Use it for cards with actions, and for cards\n * whose headings or other structure must stay navigable.\n * @default 'card'\n */\n selectionControl?: 'card' | 'checkbox';\n /**\n * Accessible name of the built-in checkbox (`selectionControl=\"checkbox\"`). Defaults to the\n * `Card.Header` title, which the checkbox references with `aria-labelledby`.\n */\n selectLabel?: string;\n}\n\n/**\n * Props of {@link Card} rendered as `C` (default `'div'`). `CardProps` without a type argument is\n * the 0.4 name: the props of a Card rendered as a `<div>`, including `ref`.\n */\nexport type CardProps<C extends React.ElementType = 'div'> = PolymorphicProps<C, CardOwnProps>;\n\n/** The props the implementation reads, for any `as` (the public typing is `PolymorphicComponent`). */\ntype CardImplProps = CardOwnProps &\n Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n type?: string;\n };\n\n// The Card root, documented on the exported `Card` const.\nconst CardRoot: PolymorphicComponent<'div', CardOwnProps> = (props) => {\n const {\n as,\n selected,\n onSelect,\n selectionControl = 'card',\n selectLabel,\n className,\n children,\n ref,\n onClick,\n onKeyDown,\n onKeyUp,\n onBlur,\n ...rest\n } = props as CardImplProps;\n\n const Component: React.ElementType = as ?? 'div';\n const selectable = onSelect !== undefined;\n const checkboxMode = selectable && selectionControl === 'checkbox';\n const cardMode = selectable && !checkboxMode;\n /** A native `<button>` already has the role, tab stop and keyboard activation. */\n const nativeButton = Component === 'button';\n\n const titleId = useId('card-title');\n const rootRef = React.useRef<HTMLElement | null>(null);\n const mergedRef = useMergedRefs<HTMLElement>(ref, rootRef);\n\n // Development diagnostics (C-DEV): read the mounted DOM after every commit (content can change\n // without prop changes), warn once. Once a key has warned, its DOM scan is skipped.\n React.useEffect(() => {\n const root = rootRef.current;\n if (!isDev || !root || !selectable) return;\n if (\n cardMode &&\n !hasWarned(NESTED_INTERACTIVE_WARNING) &&\n getTabbableElements(root).length > 0\n ) {\n warnOnce(\n NESTED_INTERACTIVE_WARNING,\n 'Card: a selectable card (`onSelect`) is a button and must not contain focusable elements (buttons, links, inputs). Use `selectionControl=\"checkbox\"` for cards with interactive content.',\n );\n }\n if (checkboxMode && !selectLabel && !root.ownerDocument.getElementById(titleId)) {\n warnOnce(\n 'Card:checkbox-name',\n 'Card: the selection checkbox has no accessible name. Render a `Card.Header` with a `title`, or pass `selectLabel`.',\n );\n }\n });\n\n /**\n * Set by an unprevented Space keydown on the card; Space selects on the following keyup only\n * while it is set (like a native button and P01's Button: a keyup alone never selects, and\n * moving focus away in between cancels). The ref is only touched from event handlers, through\n * these two stable callbacks (C-HOOKS).\n */\n const spaceArmedRef = React.useRef(false);\n /** Arms (or disarms) Space activation. */\n const setSpaceArmed = useEventCallback((armed: boolean) => {\n spaceArmedRef.current = armed;\n });\n /** Reads and clears the Space arm. */\n const takeSpaceArmed = useEventCallback(() => {\n const armed = spaceArmedRef.current;\n spaceArmedRef.current = false;\n return armed;\n });\n\n const handleClick = composeEventHandlers<React.MouseEvent<HTMLElement>>(onClick, (event) => {\n if (!selectable || isForeignEvent(event, event.currentTarget)) return;\n onSelect();\n });\n\n /** Keyboard activation applies to a `role=\"button\"` card (a native `<button>` has its own). */\n const keyboardActivation = cardMode && !nativeButton;\n\n const handleKeyDown = composeEventHandlers<React.KeyboardEvent<HTMLElement>>(\n onKeyDown,\n (event) => {\n if (!keyboardActivation) return;\n if (event.key !== 'Enter' && event.key !== ' ') return;\n if (isForeignEvent(event, event.currentTarget)) return;\n // Space would scroll the page: prevent it now, select on keyup. Enter selects on keydown; a\n // held Enter does not toggle repeatedly.\n event.preventDefault();\n if (event.key === ' ') setSpaceArmed(true);\n else if (!event.repeat) onSelect?.();\n },\n );\n\n const handleKeyUp = composeEventHandlers<React.KeyboardEvent<HTMLElement>>(\n onKeyUp,\n (event) => {\n if (!keyboardActivation || event.key !== ' ') return;\n // Always consume the arm, also when the consumer prevented this keyup.\n const armed = takeSpaceArmed();\n if (!armed || event.defaultPrevented || isForeignEvent(event, event.currentTarget)) return;\n event.preventDefault();\n onSelect?.();\n },\n { checkDefaultPrevented: false },\n );\n\n // Moving focus away between Space keydown and keyup cancels the activation (native behavior).\n const handleBlur = composeEventHandlers<React.FocusEvent<HTMLElement>>(\n onBlur,\n () => {\n if (keyboardActivation) setSpaceArmed(false);\n },\n { checkDefaultPrevented: false },\n );\n\n /** Defaults the consumer may override (C-COMPOSE: before `{...rest}`). */\n const defaults: Record<string, unknown> = {};\n if (cardMode) {\n if (nativeButton) {\n defaults.type = 'button';\n } else {\n defaults.role = 'button';\n defaults.tabIndex = 0;\n }\n if (selected !== undefined) defaults['aria-pressed'] = selected;\n }\n\n return (\n <CardTitleIdContext.Provider value={checkboxMode ? titleId : null}>\n <Component\n {...defaults}\n {...rest}\n ref={mergedRef}\n data-selected={selected ? '' : undefined}\n className={cn(\n cardClassNames.root,\n 'overflow-hidden rounded-md border border-border bg-card shadow-4',\n // Positions the check glyph / checkbox; plain cards keep their 0.4 positioning.\n (selectable || selected !== undefined) && 'relative',\n selected &&\n cn(\n 'border-primary bg-selected text-selected-foreground ring-1 ring-inset ring-primary',\n forcedColors.selectedContainer,\n ),\n selectable && 'cursor-pointer',\n cardMode && focusRing,\n className,\n )}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n onBlur={handleBlur}\n >\n {checkboxMode && (\n <input\n type=\"checkbox\"\n checked={selected ?? false}\n onChange={() => onSelect()}\n aria-label={selectLabel}\n aria-labelledby={selectLabel ? undefined : titleId}\n className={cn(\n cardClassNames.checkbox,\n 'absolute end-3 top-3 m-0 size-4 cursor-pointer accent-primary',\n focusRing,\n )}\n />\n )}\n {selected && !checkboxMode && (\n <CheckIcon\n size={12}\n className={cn(cardClassNames.checkmark, 'absolute end-2 top-2 text-primary')}\n />\n )}\n {children}\n </Component>\n </CardTitleIdContext.Provider>\n );\n};\nCardRoot.displayName = 'Card';\n\n/** The Card.Header's own props (component-specific props only). */\nexport interface CardHeaderOwnProps {\n /**\n * Title content displayed in the card header. It also names a selectable card's built-in\n * checkbox (`selectionControl=\"checkbox\"`). Content that renders nothing (`''`, `[]`, a list of\n * nothing) renders no title element; `0` is content.\n */\n title?: React.ReactNode;\n /** Subtitle content displayed below the title (none when it renders nothing, as `title`). */\n subtitle?: React.ReactNode;\n}\n\n/** Props of {@link CardHeader} rendered as `C` (default `'div'`), including `ref`. */\nexport type CardHeaderProps<C extends React.ElementType = 'div'> = PolymorphicProps<\n C,\n CardHeaderOwnProps\n>;\n\ntype CardHeaderImplProps = CardHeaderOwnProps &\n Omit<React.HTMLAttributes<HTMLElement>, 'title'> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n };\n\n/**\n * The header of a {@link Card}: a title and an optional subtitle, followed by any children.\n * Flat export for React Server Components (`Card.Header` in client files).\n */\nexport const CardHeader: PolymorphicComponent<'div', CardHeaderOwnProps> = (props) => {\n const { as, title, subtitle, className, children, ref, ...rest } = props as CardHeaderImplProps;\n const Component: React.ElementType = as ?? 'div';\n /** Set only inside a `selectionControl=\"checkbox\"` card: the title names its checkbox. */\n const titleId = React.useContext(CardTitleIdContext);\n // A title or subtitle that renders nothing (`''`, `[]`, a list of nothing) gets no element, so a\n // checkbox card with such a title warns about its missing name; `0` is content.\n const hasTitle = slotRendersContent(title);\n const hasSubtitle = slotRendersContent(subtitle);\n return (\n // In a checkbox card the header keeps clear of the checkbox in the top end corner.\n <Component\n ref={ref}\n className={cn(cardHeaderClassNames.root, 'p-4', titleId && 'pe-10', className)}\n {...rest}\n >\n {hasTitle && (\n <div\n id={titleId ?? undefined}\n className={cn(cardHeaderClassNames.title, 'text-subtitle-1')}\n >\n {materialiseSlotContent(title)}\n </div>\n )}\n {hasSubtitle && (\n <div className={cn(cardHeaderClassNames.subtitle, 'text-caption-1 text-muted-foreground')}>\n {materialiseSlotContent(subtitle)}\n </div>\n )}\n {children}\n </Component>\n );\n};\nCardHeader.displayName = 'CardHeader';\n\n/** The Card.Body's own props: none besides the element's (component-specific props only). */\nexport type CardBodyOwnProps = Record<never, never>;\n\n/** Props of {@link CardBody} rendered as `C` (default `'div'`), including `ref`. */\nexport type CardBodyProps<C extends React.ElementType = 'div'> = PolymorphicProps<\n C,\n CardBodyOwnProps\n>;\n\ntype CardSectionImplProps = React.HTMLAttributes<HTMLElement> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n};\n\n/**\n * The main content of a {@link Card}. Flat export for React Server Components (`Card.Body` in\n * client files).\n */\nexport const CardBody: PolymorphicComponent<'div', CardBodyOwnProps> = (props) => {\n const { as, className, ref, ...rest } = props as CardSectionImplProps;\n const Component: React.ElementType = as ?? 'div';\n return (\n <Component ref={ref} className={cn(cardBodyClassNames.root, 'p-4 pt-0', className)} {...rest} />\n );\n};\nCardBody.displayName = 'CardBody';\n\n/** The Card.Footer's own props: none besides the element's (component-specific props only). */\nexport type CardFooterOwnProps = Record<never, never>;\n\n/** Props of {@link CardFooter} rendered as `C` (default `'div'`), including `ref`. */\nexport type CardFooterProps<C extends React.ElementType = 'div'> = PolymorphicProps<\n C,\n CardFooterOwnProps\n>;\n\n/**\n * The action row of a {@link Card} (end-aligned). A selectable card with actions here needs\n * `selectionControl=\"checkbox\"`. Flat export for React Server Components (`Card.Footer` in client\n * files).\n */\nexport const CardFooter: PolymorphicComponent<'div', CardFooterOwnProps> = (props) => {\n const { as, className, ref, ...rest } = props as CardSectionImplProps;\n const Component: React.ElementType = as ?? 'div';\n return (\n <Component\n ref={ref}\n className={cn(cardFooterClassNames.root, 'flex justify-end gap-2 p-4 pt-0', className)}\n {...rest}\n />\n );\n};\nCardFooter.displayName = 'CardFooter';\n\n/**\n * A surface that groups related content, with `Card.Header`, `Card.Body` and `Card.Footer`.\n *\n * **Selectable cards** (`onSelect`) come in two patterns:\n * - A card without interactive content is itself the control (`selectionControl=\"card\"`, the\n * default): it is a `role=\"button\"` tab stop activated by click, Enter (key down) or Space (key\n * up, cancelled by moving focus away first), with `aria-pressed` reflecting `selected`. Its\n * content becomes the button's name, so headings and other structure inside it are flattened.\n * - A card that contains buttons or links, or headings that must stay navigable, uses\n * `selectionControl=\"checkbox\"`: a built-in checkbox named by the header title carries the\n * selection, and the card's actions and structure stay separate from it.\n *\n * In both modes events that start inside a nested interactive element, or in content portaled out\n * of the card, are ignored. `onClick`, `onKeyDown` and `onKeyUp` are composed with the built-in\n * selection (call `event.preventDefault()` to skip it). A `selected` card without `onSelect` shows\n * the selected look only; its state is not exposed to assistive technology.\n *\n * React Server Components cannot dot into a client module: import the flat names `CardHeader`,\n * `CardBody` and `CardFooter` there; `Card.Header` etc. work in client files.\n *\n * @example\n * <Card onSelect={toggle} selected={selected}>\n * <Card.Header title=\"Pro plan\" subtitle=\"Billed monthly\" />\n * </Card>\n *\n * <Card onSelect={toggle} selected={selected} selectionControl=\"checkbox\">\n * <Card.Header title=\"Pro plan\" />\n * <Card.Footer><Button>Details</Button></Card.Footer>\n * </Card>\n */\nexport const Card = /* @__PURE__ */ Object.assign(CardRoot, {\n Header: CardHeader,\n Body: CardBody,\n Footer: CardFooter,\n});\n"],"mappings":"miBAwBA,IAAM+B,EACJ,wFAGIC,EAAe,EAerB,SAASC,EAAe,EAA6B,EAAwB,CAC3E,IAAMC,EAASC,EAAM,OACrB,GAAI,CAACD,GAAU,OAAOA,EAAO,UAAa,UAAY,CAACE,EAAK,SAASF,CAAc,EACjF,MAAO,GAET,GAAIA,EAAO,WAAaF,EAAc,MAAO,GAC7C,IAAMK,EAAWH,EAAmB,QAAQH,CA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AEnG,EACA,EAAS,YAAc,WAgBvB,IAAasC,EAA+D,GAAU,CACpF,GAAM,CAAE,KAAI,YAAW,MAAK,GAAGtC,GAASC,EAExC,OACE,EAAAZ,EAAA,IAAA,CAFmCc,GAAM,MAEzC,CACO,MACL,UAAWpC,EAAAA,GAAGQ,EAAAA,qBAAqB,KAAM,kCAAmCuD,CAAS,EACrF,GAAI9B,CACL,CAAA,CAEL,EACA,EAAW,YAAc,aAgCzB,IAAauC,EAAuB,OAAO,OAAOxC,EAAU,CAC1D,OAAQiC,EACR,KAAMK,EACN,OAAQC,CACV,CAAC"}
@@ -3,119 +3,120 @@ import { cn as e } from "../../lib/cn.mjs";
3
3
  import { hasWarned as t, isDev as n, warnOnce as r } from "../../lib/dev.mjs";
4
4
  import { materialiseSlotContent as i, slotRendersContent as a } from "../../lib/slot.mjs";
5
5
  import { composeEventHandlers as o } from "../../lib/composeEventHandlers.mjs";
6
- import { useEventCallback as s } from "../../hooks/useEventCallback.mjs";
7
- import { useId as c } from "../../hooks/useId.mjs";
8
- import { getTabbableElements as l } from "../../lib/focus.mjs";
9
- import { useMergedRefs as u } from "../../hooks/useMergedRefs.mjs";
10
- import { forcedColors as d } from "../../lib/styles.mjs";
11
- import { CheckIcon as f } from "../../lib/icons.mjs";
12
- import * as p from "react";
13
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
6
+ import { cardBodyClassNames as s, cardClassNames as c, cardFooterClassNames as l, cardHeaderClassNames as u } from "../../lib/classNames.mjs";
7
+ import { useEventCallback as d } from "../../hooks/useEventCallback.mjs";
8
+ import { useId as f } from "../../hooks/useId.mjs";
9
+ import { getTabbableElements as p } from "../../lib/focus.mjs";
10
+ import { useMergedRefs as m } from "../../hooks/useMergedRefs.mjs";
11
+ import { forcedColors as h } from "../../lib/styles.mjs";
12
+ import { CheckIcon as g } from "../../lib/icons.mjs";
13
+ import * as _ from "react";
14
+ import { jsx as v, jsxs as y } from "react/jsx-runtime";
14
15
  //#region src/components/layout/Card.tsx
15
- var g = "button, a[href], input, select, textarea, label, summary, [role=\"button\"], [tabindex]", _ = 1;
16
- function v(e, t) {
16
+ var b = "button, a[href], input, select, textarea, label, summary, [role=\"button\"], [tabindex]", x = 1;
17
+ function S(e, t) {
17
18
  let n = e.target;
18
19
  if (!n || typeof n.nodeType != "number" || !t.contains(n)) return !0;
19
- if (n.nodeType !== _) return !1;
20
- let r = n.closest(g);
20
+ if (n.nodeType !== x) return !1;
21
+ let r = n.closest(b);
21
22
  return r !== null && r !== t && t.contains(r);
22
23
  }
23
- var y = "Card:nested-interactive", b = p.createContext(null), x = (i) => {
24
- let { as: a, selected: g, onSelect: _, selectionControl: x = "card", selectLabel: S, className: C, children: w, ref: T, onClick: E, onKeyDown: D, onKeyUp: O, onBlur: k, ...A } = i, j = a ?? "div", M = _ !== void 0, N = M && x === "checkbox", P = M && !N, F = j === "button", I = c("card-title"), L = p.useRef(null), R = u(T, L);
25
- p.useEffect(() => {
26
- let e = L.current;
27
- n && e && M && (P && !t(y) && l(e).length > 0 && r(y, "Card: a selectable card (`onSelect`) is a button and must not contain focusable elements (buttons, links, inputs). Use `selectionControl=\"checkbox\"` for cards with interactive content."), N && !S && !e.ownerDocument.getElementById(I) && r("Card:checkbox-name", "Card: the selection checkbox has no accessible name. Render a `Card.Header` with a `title`, or pass `selectLabel`."));
24
+ var C = "Card:nested-interactive", w = _.createContext(null), T = (i) => {
25
+ let { as: a, selected: s, onSelect: l, selectionControl: u = "card", selectLabel: b, className: x, children: T, ref: E, onClick: D, onKeyDown: O, onKeyUp: k, onBlur: A, ...j } = i, M = a ?? "div", N = l !== void 0, P = N && u === "checkbox", F = N && !P, I = M === "button", L = f("card-title"), R = _.useRef(null), z = m(E, R);
26
+ _.useEffect(() => {
27
+ let e = R.current;
28
+ n && e && N && (F && !t(C) && p(e).length > 0 && r(C, "Card: a selectable card (`onSelect`) is a button and must not contain focusable elements (buttons, links, inputs). Use `selectionControl=\"checkbox\"` for cards with interactive content."), P && !b && !e.ownerDocument.getElementById(L) && r("Card:checkbox-name", "Card: the selection checkbox has no accessible name. Render a `Card.Header` with a `title`, or pass `selectLabel`."));
28
29
  });
29
- let z = p.useRef(!1), B = s((e) => {
30
- z.current = e;
31
- }), V = s(() => {
32
- let e = z.current;
33
- return z.current = !1, e;
34
- }), H = o(E, (e) => {
35
- M && !v(e, e.currentTarget) && _();
36
- }), U = P && !F, W = o(D, (e) => {
37
- U && (e.key === "Enter" || e.key === " ") && (v(e, e.currentTarget) || (e.preventDefault(), e.key === " " ? B(!0) : e.repeat || _?.()));
38
- }), G = o(O, (e) => {
39
- U && e.key === " " && (!V() || e.defaultPrevented || v(e, e.currentTarget) || (e.preventDefault(), _?.()));
40
- }, { checkDefaultPrevented: !1 }), K = o(k, () => {
41
- U && B(!1);
42
- }, { checkDefaultPrevented: !1 }), q = {};
43
- return P && (F ? q.type = "button" : (q.role = "button", q.tabIndex = 0), g !== void 0 && (q["aria-pressed"] = g)), /* @__PURE__ */ m(b.Provider, {
44
- value: N ? I : null,
45
- children: /* @__PURE__ */ h(j, {
46
- ...q,
47
- ...A,
48
- ref: R,
49
- "data-selected": g ? "" : void 0,
50
- className: e("overflow-hidden rounded-md border border-border bg-card shadow-4", (M || g !== void 0) && "relative", g && e("border-primary bg-selected text-selected-foreground ring-1 ring-inset ring-primary", d.selectedContainer), M && "cursor-pointer", P && "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring", C),
51
- onClick: H,
52
- onKeyDown: W,
53
- onKeyUp: G,
54
- onBlur: K,
30
+ let B = _.useRef(!1), V = d((e) => {
31
+ B.current = e;
32
+ }), H = d(() => {
33
+ let e = B.current;
34
+ return B.current = !1, e;
35
+ }), U = o(D, (e) => {
36
+ N && !S(e, e.currentTarget) && l();
37
+ }), W = F && !I, G = o(O, (e) => {
38
+ W && (e.key === "Enter" || e.key === " ") && (S(e, e.currentTarget) || (e.preventDefault(), e.key === " " ? V(!0) : e.repeat || l?.()));
39
+ }), K = o(k, (e) => {
40
+ W && e.key === " " && (!H() || e.defaultPrevented || S(e, e.currentTarget) || (e.preventDefault(), l?.()));
41
+ }, { checkDefaultPrevented: !1 }), q = o(A, () => {
42
+ W && V(!1);
43
+ }, { checkDefaultPrevented: !1 }), J = {};
44
+ return F && (I ? J.type = "button" : (J.role = "button", J.tabIndex = 0), s !== void 0 && (J["aria-pressed"] = s)), /* @__PURE__ */ v(w.Provider, {
45
+ value: P ? L : null,
46
+ children: /* @__PURE__ */ y(M, {
47
+ ...J,
48
+ ...j,
49
+ ref: z,
50
+ "data-selected": s ? "" : void 0,
51
+ className: e(c.root, "overflow-hidden rounded-md border border-border bg-card shadow-4", (N || s !== void 0) && "relative", s && e("border-primary bg-selected text-selected-foreground ring-1 ring-inset ring-primary", h.selectedContainer), N && "cursor-pointer", F && "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring", x),
52
+ onClick: U,
53
+ onKeyDown: G,
54
+ onKeyUp: K,
55
+ onBlur: q,
55
56
  children: [
56
- N && /* @__PURE__ */ m("input", {
57
+ P && /* @__PURE__ */ v("input", {
57
58
  type: "checkbox",
58
- checked: g ?? !1,
59
- onChange: () => _(),
60
- "aria-label": S,
61
- "aria-labelledby": S ? void 0 : I,
62
- className: e("absolute end-3 top-3 m-0 size-4 cursor-pointer accent-primary", "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring")
59
+ checked: s ?? !1,
60
+ onChange: () => l(),
61
+ "aria-label": b,
62
+ "aria-labelledby": b ? void 0 : L,
63
+ className: e(c.checkbox, "absolute end-3 top-3 m-0 size-4 cursor-pointer accent-primary", "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring")
63
64
  }),
64
- g && !N && /* @__PURE__ */ m(f, {
65
+ s && !P && /* @__PURE__ */ v(g, {
65
66
  size: 12,
66
- className: "absolute end-2 top-2 text-primary"
67
+ className: e(c.checkmark, "absolute end-2 top-2 text-primary")
67
68
  }),
68
- w
69
+ T
69
70
  ]
70
71
  })
71
72
  });
72
73
  };
73
- x.displayName = "Card";
74
- var S = (t) => {
75
- let { as: n, title: r, subtitle: o, className: s, children: c, ref: l, ...u } = t, d = n ?? "div", f = p.useContext(b), g = a(r), _ = a(o);
76
- return /* @__PURE__ */ h(d, {
74
+ T.displayName = "Card";
75
+ var E = (t) => {
76
+ let { as: n, title: r, subtitle: o, className: s, children: c, ref: l, ...d } = t, f = n ?? "div", p = _.useContext(w), m = a(r), h = a(o);
77
+ return /* @__PURE__ */ y(f, {
77
78
  ref: l,
78
- className: e("p-4", f && "pe-10", s),
79
- ...u,
79
+ className: e(u.root, "p-4", p && "pe-10", s),
80
+ ...d,
80
81
  children: [
81
- g && /* @__PURE__ */ m("div", {
82
- id: f ?? void 0,
83
- className: "text-subtitle-1",
82
+ m && /* @__PURE__ */ v("div", {
83
+ id: p ?? void 0,
84
+ className: e(u.title, "text-subtitle-1"),
84
85
  children: i(r)
85
86
  }),
86
- _ && /* @__PURE__ */ m("div", {
87
- className: "text-caption-1 text-muted-foreground",
87
+ h && /* @__PURE__ */ v("div", {
88
+ className: e(u.subtitle, "text-caption-1 text-muted-foreground"),
88
89
  children: i(o)
89
90
  }),
90
91
  c
91
92
  ]
92
93
  });
93
94
  };
94
- S.displayName = "CardHeader";
95
- var C = (t) => {
95
+ E.displayName = "CardHeader";
96
+ var D = (t) => {
96
97
  let { as: n, className: r, ref: i, ...a } = t;
97
- return /* @__PURE__ */ m(n ?? "div", {
98
+ return /* @__PURE__ */ v(n ?? "div", {
98
99
  ref: i,
99
- className: e("p-4 pt-0", r),
100
+ className: e(s.root, "p-4 pt-0", r),
100
101
  ...a
101
102
  });
102
103
  };
103
- C.displayName = "CardBody";
104
- var w = (t) => {
104
+ D.displayName = "CardBody";
105
+ var O = (t) => {
105
106
  let { as: n, className: r, ref: i, ...a } = t;
106
- return /* @__PURE__ */ m(n ?? "div", {
107
+ return /* @__PURE__ */ v(n ?? "div", {
107
108
  ref: i,
108
- className: e("flex justify-end gap-2 p-4 pt-0", r),
109
+ className: e(l.root, "flex justify-end gap-2 p-4 pt-0", r),
109
110
  ...a
110
111
  });
111
112
  };
112
- w.displayName = "CardFooter";
113
- var T = /* @__PURE__ */ Object.assign(x, {
114
- Header: S,
115
- Body: C,
116
- Footer: w
113
+ O.displayName = "CardFooter";
114
+ var k = /* @__PURE__ */ Object.assign(T, {
115
+ Header: E,
116
+ Body: D,
117
+ Footer: O
117
118
  });
118
119
  //#endregion
119
- export { T as Card, C as CardBody, w as CardFooter, S as CardHeader };
120
+ export { k as Card, D as CardBody, O as CardFooter, E as CardHeader };
120
121
 
121
122
  //# sourceMappingURL=Card.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Card.mjs","names":["useId","useId$1","React","INTERACTIVE_SELECTOR","ELEMENT_NODE","isForeignEvent","target","event","root","control","NESTED_INTERACTIVE_WARNING","CardTitleIdContext","CardRoot","rest","props","Component","as","selectable","onSelect","checkboxMode","selectionControl","cardMode","nativeButton","titleId","rootRef","mergedRef","useMergedRefs","ref","isDev","hasWarned","getTabbableElements","warnOnce","selectLabel","spaceArmedRef","setSpaceArmed","useEventCallback","armed","takeSpaceArmed","handleClick","composeEventHandlers","onClick","keyboardActivation","handleKeyDown","onKeyDown","handleKeyUp","onKeyUp","handleBlur","onBlur","defaults","selected","cn","forcedColors","className","CheckIcon","children","CardHeader","hasTitle","slotRendersContent","title","hasSubtitle","subtitle","materialiseSlotContent","CardBody","CardFooter","Card"],"sources":["../../../src/components/layout/Card.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { hasWarned, isDev, warnOnce } from '../../lib/dev';\nimport { getTabbableElements } from '../../lib/focus';\nimport { CheckIcon } from '../../lib/icons';\nimport { materialiseSlotContent, slotRendersContent } from '../../lib/slot';\nimport { focusRing, forcedColors } from '../../lib/styles';\nimport type { PolymorphicComponent, PolymorphicProps } from '../../lib/polymorphic';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\n\n/**\n * Elements whose own events a selectable card ignores: a click or key press that starts inside a\n * nested control belongs to that control, never to the card (layout#35). A `<label>` counts too:\n * its click already activates the control it labels.\n */\nconst INTERACTIVE_SELECTOR =\n 'button, a[href], input, select, textarea, label, summary, [role=\"button\"], [tabindex]';\n\n/** `Node.ELEMENT_NODE`, spelled out so no realm's `Node` global is read. */\nconst ELEMENT_NODE = 1;\n\n/**\n * Whether the card must ignore `event`: it started outside the card's DOM, or inside an\n * interactive element nested in `root` (the card itself, which carries `role=\"button\"`/`tabindex`\n * in the default mode, does not count).\n *\n * React events bubble through portals along the component tree, so a menu, popover or dialog\n * opened from inside the card (e.g. a footer overflow menu) reaches the card's handlers although\n * its DOM lives elsewhere. Such a target is not a DOM descendant of the card and never selects it.\n *\n * The target is duck typed (`nodeType`) rather than checked with `instanceof`, so a card rendered\n * into another realm's document (an iframe, or a popout window reached through `createPortal`)\n * still selects: its nodes are not instances of the main realm's `Node`/`Element`.\n */\nfunction isForeignEvent(event: React.SyntheticEvent, root: Element): boolean {\n const target = event.target as Partial<Node> | null;\n if (!target || typeof target.nodeType !== 'number' || !root.contains(target as Node)) {\n return true;\n }\n if (target.nodeType !== ELEMENT_NODE) return false;\n const control = (target as Element).closest(INTERACTIVE_SELECTOR);\n return control !== null && control !== root && root.contains(control);\n}\n\n/** Warn-once key of the \"selectable card contains tabbable elements\" diagnostic. */\nconst NESTED_INTERACTIVE_WARNING = 'Card:nested-interactive';\n\n/**\n * The id of the header title that names the built-in checkbox of a `selectionControl=\"checkbox\"`\n * card; `null` everywhere else (other cards, and a `Card.Header` rendered on its own, which does\n * not require a Card). A string, never an object, so the provider value needs no memoisation.\n */\nconst CardTitleIdContext = React.createContext<string | null>(null);\n\n/**\n * The Card's own props (the XOwnProps rule of `PolymorphicProps`: component-specific props only).\n * Every other prop comes from the rendered element (`as`).\n */\nexport interface CardOwnProps {\n /**\n * Whether the card is selected. Shown with the selected colors plus non-color cues: a 2px primary\n * border (a 1px border plus an inset 1px ring), a Highlight outline in forced-colors mode, and a\n * check glyph (with `selectionControl=\"checkbox\"` the checked checkbox instead).\n *\n * The state reaches assistive technology only on a selectable card (`onSelect`): as\n * `aria-pressed` (default mode) or as the built-in checkbox's checked state. Without `onSelect`,\n * `selected` is a visual state only (the glyph is decorative); state it in the content if it\n * matters to screen-reader users, or make the card selectable.\n */\n selected?: boolean;\n /**\n * Makes the card selectable: called when the card is activated by a click, Enter (on key down)\n * or Space (on key up, like a native button) in the default mode, or when its built-in checkbox\n * changes (`selectionControl=\"checkbox\"`). Clicks and key presses that start inside a nested\n * interactive element (a button, link, input or any element with `tabindex`), or in content\n * portaled out of the card (a menu, popover or dialog opened from it), are ignored, so a footer\n * action never selects the card.\n */\n onSelect?: () => void;\n /**\n * How a selectable card (`onSelect`) exposes its selection:\n * - `'card'` (default): the card itself is the control — `role=\"button\"`, a tab stop, Enter and\n * Space activation and `aria-pressed={selected}` when `selected` is defined. Use it only for\n * cards **without** interactive content: a button inside a `role=\"button\"` card is invalid\n * (axe `nested-interactive`), and a development warning points here. A button's children are\n * presentational, so the card's content is flattened into its name: a heading (e.g.\n * `<Card.Header as=\"h3\">`), list or other structure inside it is not exposed and cannot be\n * reached by heading navigation (no warning covers this). Keep such cards short.\n * - `'checkbox'`: the card is not a widget; a built-in native checkbox (top end corner) carries\n * `selected` and is named by the `Card.Header` title (or `selectLabel`). Pointer clicks on\n * non-interactive card areas still toggle it. Use it for cards with actions, and for cards\n * whose headings or other structure must stay navigable.\n * @default 'card'\n */\n selectionControl?: 'card' | 'checkbox';\n /**\n * Accessible name of the built-in checkbox (`selectionControl=\"checkbox\"`). Defaults to the\n * `Card.Header` title, which the checkbox references with `aria-labelledby`.\n */\n selectLabel?: string;\n}\n\n/**\n * Props of {@link Card} rendered as `C` (default `'div'`). `CardProps` without a type argument is\n * the 0.4 name: the props of a Card rendered as a `<div>`, including `ref`.\n */\nexport type CardProps<C extends React.ElementType = 'div'> = PolymorphicProps<C, CardOwnProps>;\n\n/** The props the implementation reads, for any `as` (the public typing is `PolymorphicComponent`). */\ntype CardImplProps = CardOwnProps &\n Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n type?: string;\n };\n\n// The Card root, documented on the exported `Card` const.\nconst CardRoot: PolymorphicComponent<'div', CardOwnProps> = (props) => {\n const {\n as,\n selected,\n onSelect,\n selectionControl = 'card',\n selectLabel,\n className,\n children,\n ref,\n onClick,\n onKeyDown,\n onKeyUp,\n onBlur,\n ...rest\n } = props as CardImplProps;\n\n const Component: React.ElementType = as ?? 'div';\n const selectable = onSelect !== undefined;\n const checkboxMode = selectable && selectionControl === 'checkbox';\n const cardMode = selectable && !checkboxMode;\n /** A native `<button>` already has the role, tab stop and keyboard activation. */\n const nativeButton = Component === 'button';\n\n const titleId = useId('card-title');\n const rootRef = React.useRef<HTMLElement | null>(null);\n const mergedRef = useMergedRefs<HTMLElement>(ref, rootRef);\n\n // Development diagnostics (C-DEV): read the mounted DOM after every commit (content can change\n // without prop changes), warn once. Once a key has warned, its DOM scan is skipped.\n React.useEffect(() => {\n const root = rootRef.current;\n if (!isDev || !root || !selectable) return;\n if (\n cardMode &&\n !hasWarned(NESTED_INTERACTIVE_WARNING) &&\n getTabbableElements(root).length > 0\n ) {\n warnOnce(\n NESTED_INTERACTIVE_WARNING,\n 'Card: a selectable card (`onSelect`) is a button and must not contain focusable elements (buttons, links, inputs). Use `selectionControl=\"checkbox\"` for cards with interactive content.',\n );\n }\n if (checkboxMode && !selectLabel && !root.ownerDocument.getElementById(titleId)) {\n warnOnce(\n 'Card:checkbox-name',\n 'Card: the selection checkbox has no accessible name. Render a `Card.Header` with a `title`, or pass `selectLabel`.',\n );\n }\n });\n\n /**\n * Set by an unprevented Space keydown on the card; Space selects on the following keyup only\n * while it is set (like a native button and P01's Button: a keyup alone never selects, and\n * moving focus away in between cancels). The ref is only touched from event handlers, through\n * these two stable callbacks (C-HOOKS).\n */\n const spaceArmedRef = React.useRef(false);\n /** Arms (or disarms) Space activation. */\n const setSpaceArmed = useEventCallback((armed: boolean) => {\n spaceArmedRef.current = armed;\n });\n /** Reads and clears the Space arm. */\n const takeSpaceArmed = useEventCallback(() => {\n const armed = spaceArmedRef.current;\n spaceArmedRef.current = false;\n return armed;\n });\n\n const handleClick = composeEventHandlers<React.MouseEvent<HTMLElement>>(onClick, (event) => {\n if (!selectable || isForeignEvent(event, event.currentTarget)) return;\n onSelect();\n });\n\n /** Keyboard activation applies to a `role=\"button\"` card (a native `<button>` has its own). */\n const keyboardActivation = cardMode && !nativeButton;\n\n const handleKeyDown = composeEventHandlers<React.KeyboardEvent<HTMLElement>>(\n onKeyDown,\n (event) => {\n if (!keyboardActivation) return;\n if (event.key !== 'Enter' && event.key !== ' ') return;\n if (isForeignEvent(event, event.currentTarget)) return;\n // Space would scroll the page: prevent it now, select on keyup. Enter selects on keydown; a\n // held Enter does not toggle repeatedly.\n event.preventDefault();\n if (event.key === ' ') setSpaceArmed(true);\n else if (!event.repeat) onSelect?.();\n },\n );\n\n const handleKeyUp = composeEventHandlers<React.KeyboardEvent<HTMLElement>>(\n onKeyUp,\n (event) => {\n if (!keyboardActivation || event.key !== ' ') return;\n // Always consume the arm, also when the consumer prevented this keyup.\n const armed = takeSpaceArmed();\n if (!armed || event.defaultPrevented || isForeignEvent(event, event.currentTarget)) return;\n event.preventDefault();\n onSelect?.();\n },\n { checkDefaultPrevented: false },\n );\n\n // Moving focus away between Space keydown and keyup cancels the activation (native behavior).\n const handleBlur = composeEventHandlers<React.FocusEvent<HTMLElement>>(\n onBlur,\n () => {\n if (keyboardActivation) setSpaceArmed(false);\n },\n { checkDefaultPrevented: false },\n );\n\n /** Defaults the consumer may override (C-COMPOSE: before `{...rest}`). */\n const defaults: Record<string, unknown> = {};\n if (cardMode) {\n if (nativeButton) {\n defaults.type = 'button';\n } else {\n defaults.role = 'button';\n defaults.tabIndex = 0;\n }\n if (selected !== undefined) defaults['aria-pressed'] = selected;\n }\n\n return (\n <CardTitleIdContext.Provider value={checkboxMode ? titleId : null}>\n <Component\n {...defaults}\n {...rest}\n ref={mergedRef}\n data-selected={selected ? '' : undefined}\n className={cn(\n 'overflow-hidden rounded-md border border-border bg-card shadow-4',\n // Positions the check glyph / checkbox; plain cards keep their 0.4 positioning.\n (selectable || selected !== undefined) && 'relative',\n selected &&\n cn(\n 'border-primary bg-selected text-selected-foreground ring-1 ring-inset ring-primary',\n forcedColors.selectedContainer,\n ),\n selectable && 'cursor-pointer',\n cardMode && focusRing,\n className,\n )}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n onBlur={handleBlur}\n >\n {checkboxMode && (\n <input\n type=\"checkbox\"\n checked={selected ?? false}\n onChange={() => onSelect()}\n aria-label={selectLabel}\n aria-labelledby={selectLabel ? undefined : titleId}\n className={cn(\n 'absolute end-3 top-3 m-0 size-4 cursor-pointer accent-primary',\n focusRing,\n )}\n />\n )}\n {selected && !checkboxMode && (\n <CheckIcon size={12} className=\"absolute end-2 top-2 text-primary\" />\n )}\n {children}\n </Component>\n </CardTitleIdContext.Provider>\n );\n};\nCardRoot.displayName = 'Card';\n\n/** The Card.Header's own props (component-specific props only). */\nexport interface CardHeaderOwnProps {\n /**\n * Title content displayed in the card header. It also names a selectable card's built-in\n * checkbox (`selectionControl=\"checkbox\"`). Content that renders nothing (`''`, `[]`, a list of\n * nothing) renders no title element; `0` is content.\n */\n title?: React.ReactNode;\n /** Subtitle content displayed below the title (none when it renders nothing, as `title`). */\n subtitle?: React.ReactNode;\n}\n\n/** Props of {@link CardHeader} rendered as `C` (default `'div'`), including `ref`. */\nexport type CardHeaderProps<C extends React.ElementType = 'div'> = PolymorphicProps<\n C,\n CardHeaderOwnProps\n>;\n\ntype CardHeaderImplProps = CardHeaderOwnProps &\n Omit<React.HTMLAttributes<HTMLElement>, 'title'> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n };\n\n/**\n * The header of a {@link Card}: a title and an optional subtitle, followed by any children.\n * Flat export for React Server Components (`Card.Header` in client files).\n */\nexport const CardHeader: PolymorphicComponent<'div', CardHeaderOwnProps> = (props) => {\n const { as, title, subtitle, className, children, ref, ...rest } = props as CardHeaderImplProps;\n const Component: React.ElementType = as ?? 'div';\n /** Set only inside a `selectionControl=\"checkbox\"` card: the title names its checkbox. */\n const titleId = React.useContext(CardTitleIdContext);\n // A title or subtitle that renders nothing (`''`, `[]`, a list of nothing) gets no element, so a\n // checkbox card with such a title warns about its missing name; `0` is content.\n const hasTitle = slotRendersContent(title);\n const hasSubtitle = slotRendersContent(subtitle);\n return (\n // In a checkbox card the header keeps clear of the checkbox in the top end corner.\n <Component ref={ref} className={cn('p-4', titleId && 'pe-10', className)} {...rest}>\n {hasTitle && (\n <div id={titleId ?? undefined} className=\"text-subtitle-1\">\n {materialiseSlotContent(title)}\n </div>\n )}\n {hasSubtitle && (\n <div className=\"text-caption-1 text-muted-foreground\">\n {materialiseSlotContent(subtitle)}\n </div>\n )}\n {children}\n </Component>\n );\n};\nCardHeader.displayName = 'CardHeader';\n\n/** The Card.Body's own props: none besides the element's (component-specific props only). */\nexport type CardBodyOwnProps = Record<never, never>;\n\n/** Props of {@link CardBody} rendered as `C` (default `'div'`), including `ref`. */\nexport type CardBodyProps<C extends React.ElementType = 'div'> = PolymorphicProps<\n C,\n CardBodyOwnProps\n>;\n\ntype CardSectionImplProps = React.HTMLAttributes<HTMLElement> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n};\n\n/**\n * The main content of a {@link Card}. Flat export for React Server Components (`Card.Body` in\n * client files).\n */\nexport const CardBody: PolymorphicComponent<'div', CardBodyOwnProps> = (props) => {\n const { as, className, ref, ...rest } = props as CardSectionImplProps;\n const Component: React.ElementType = as ?? 'div';\n return <Component ref={ref} className={cn('p-4 pt-0', className)} {...rest} />;\n};\nCardBody.displayName = 'CardBody';\n\n/** The Card.Footer's own props: none besides the element's (component-specific props only). */\nexport type CardFooterOwnProps = Record<never, never>;\n\n/** Props of {@link CardFooter} rendered as `C` (default `'div'`), including `ref`. */\nexport type CardFooterProps<C extends React.ElementType = 'div'> = PolymorphicProps<\n C,\n CardFooterOwnProps\n>;\n\n/**\n * The action row of a {@link Card} (end-aligned). A selectable card with actions here needs\n * `selectionControl=\"checkbox\"`. Flat export for React Server Components (`Card.Footer` in client\n * files).\n */\nexport const CardFooter: PolymorphicComponent<'div', CardFooterOwnProps> = (props) => {\n const { as, className, ref, ...rest } = props as CardSectionImplProps;\n const Component: React.ElementType = as ?? 'div';\n return (\n <Component ref={ref} className={cn('flex justify-end gap-2 p-4 pt-0', className)} {...rest} />\n );\n};\nCardFooter.displayName = 'CardFooter';\n\n/**\n * A surface that groups related content, with `Card.Header`, `Card.Body` and `Card.Footer`.\n *\n * **Selectable cards** (`onSelect`) come in two patterns:\n * - A card without interactive content is itself the control (`selectionControl=\"card\"`, the\n * default): it is a `role=\"button\"` tab stop activated by click, Enter (key down) or Space (key\n * up, cancelled by moving focus away first), with `aria-pressed` reflecting `selected`. Its\n * content becomes the button's name, so headings and other structure inside it are flattened.\n * - A card that contains buttons or links, or headings that must stay navigable, uses\n * `selectionControl=\"checkbox\"`: a built-in checkbox named by the header title carries the\n * selection, and the card's actions and structure stay separate from it.\n *\n * In both modes events that start inside a nested interactive element, or in content portaled out\n * of the card, are ignored. `onClick`, `onKeyDown` and `onKeyUp` are composed with the built-in\n * selection (call `event.preventDefault()` to skip it). A `selected` card without `onSelect` shows\n * the selected look only; its state is not exposed to assistive technology.\n *\n * React Server Components cannot dot into a client module: import the flat names `CardHeader`,\n * `CardBody` and `CardFooter` there; `Card.Header` etc. work in client files.\n *\n * @example\n * <Card onSelect={toggle} selected={selected}>\n * <Card.Header title=\"Pro plan\" subtitle=\"Billed monthly\" />\n * </Card>\n *\n * <Card onSelect={toggle} selected={selected} selectionControl=\"checkbox\">\n * <Card.Header title=\"Pro plan\" />\n * <Card.Footer><Button>Details</Button></Card.Footer>\n * </Card>\n */\nexport const Card = /* @__PURE__ */ Object.assign(CardRoot, {\n Header: CardHeader,\n Body: CardBody,\n Footer: CardFooter,\n});\n"],"mappings":";;;;;;;;;;;;;;AAkBA,IAAMG,IACJ,2FAGIC,IAAe;AAerB,SAASC,EAAe,GAA6B,GAAwB;CAC3E,IAAMC,IAASC,EAAM;CACrB,IAAI,CAACD,KAAU,OAAOA,EAAO,YAAa,YAAY,CAACE,EAAK,SAASF,CAAc,GACjF,OAAO;CAET,IAAIA,EAAO,aAAaF,GAAc,OAAO;CAC7C,IAAMK,IAAWH,EAAmB,QAAQH,CAAoB;CAChE,OAAOM,MAAY,QAAQA,MAAYD,KAAQA,EAAK,SAASC,CAAO;AACtE;AAGA,IAAMC,IAA6B,2BAO7BC,IAAqBT,EAAM,cAA6B,IAAI,GAiE5DU,KAAuD,MAAU;CACrE,IAAM,EACJ,OACA,aACA,aACA,sBAAmB,QACnB,gBACA,cACA,aACA,QACA,YACA,cACA,YACA,WACA,GAAGC,MACDC,GAEEC,IAA+BC,KAAM,OACrCC,IAAaC,MAAa,KAAA,GAC1BC,IAAeF,KAAcG,MAAqB,YAClDC,IAAWJ,KAAc,CAACE,GAE1BG,IAAeP,MAAc,UAE7BQ,IAAUvB,EAAM,YAAY,GAC5BwB,IAAUtB,EAAM,OAA2B,IAAI,GAC/CuB,IAAYC,EAA2BC,GAAKH,CAAO;CAIzD,EAAM,gBAAgB;EACpB,IAAMhB,IAAOgB,EAAQ;EACrB,AAAKI,KAAUpB,KAASS,MAEtBI,KACA,CAACQ,EAAUnB,CAA0B,KACrCoB,EAAoBtB,CAAI,CAAC,CAAC,SAAS,KAEnCuB,EACErB,GACA,4LACF,GAEES,KAAgB,CAACa,KAAe,CAACxB,EAAK,cAAc,eAAee,CAAO,KAC5EQ,EACE,sBACA,oHACF;CAEJ,CAAC;CAQD,IAAME,IAAgB/B,EAAM,OAAO,EAAK,GAElC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E,KAAM,OAEzC;EAAgB;EAAK,WAAWkC,EAAG,mCAAmCE,CAAS;EAAG,GAAIvC;CAAO,CAAA;AAEjG;AACA,EAAW,cAAc;AAgCzB,IAAamD,IAAuB,uBAAO,OAAOpD,GAAU;CAC1D,QAAQ2C;CACR,MAAMO;CACN,QAAQC;AACV,CAAC"}
1
+ {"version":3,"file":"Card.mjs","names":["useId","useId$1","React","INTERACTIVE_SELECTOR","ELEMENT_NODE","isForeignEvent","target","event","root","control","NESTED_INTERACTIVE_WARNING","CardTitleIdContext","CardRoot","rest","props","Component","as","selectable","onSelect","checkboxMode","selectionControl","cardMode","nativeButton","titleId","rootRef","mergedRef","useMergedRefs","ref","isDev","hasWarned","getTabbableElements","warnOnce","selectLabel","spaceArmedRef","setSpaceArmed","useEventCallback","armed","takeSpaceArmed","handleClick","composeEventHandlers","onClick","keyboardActivation","handleKeyDown","onKeyDown","handleKeyUp","onKeyUp","handleBlur","onBlur","defaults","selected","cn","cardClassNames","forcedColors","className","CheckIcon","children","CardHeader","hasTitle","slotRendersContent","title","hasSubtitle","subtitle","cardHeaderClassNames","materialiseSlotContent","CardBody","cardBodyClassNames","CardFooter","cardFooterClassNames","Card"],"sources":["../../../src/components/layout/Card.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n cardBodyClassNames,\n cardClassNames,\n cardFooterClassNames,\n cardHeaderClassNames,\n} from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { hasWarned, isDev, warnOnce } from '../../lib/dev';\nimport { getTabbableElements } from '../../lib/focus';\nimport { CheckIcon } from '../../lib/icons';\nimport { materialiseSlotContent, slotRendersContent } from '../../lib/slot';\nimport { focusRing, forcedColors } from '../../lib/styles';\nimport type { PolymorphicComponent, PolymorphicProps } from '../../lib/polymorphic';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\n\n/**\n * Elements whose own events a selectable card ignores: a click or key press that starts inside a\n * nested control belongs to that control, never to the card (layout#35). A `<label>` counts too:\n * its click already activates the control it labels.\n */\nconst INTERACTIVE_SELECTOR =\n 'button, a[href], input, select, textarea, label, summary, [role=\"button\"], [tabindex]';\n\n/** `Node.ELEMENT_NODE`, spelled out so no realm's `Node` global is read. */\nconst ELEMENT_NODE = 1;\n\n/**\n * Whether the card must ignore `event`: it started outside the card's DOM, or inside an\n * interactive element nested in `root` (the card itself, which carries `role=\"button\"`/`tabindex`\n * in the default mode, does not count).\n *\n * React events bubble through portals along the component tree, so a menu, popover or dialog\n * opened from inside the card (e.g. a footer overflow menu) reaches the card's handlers although\n * its DOM lives elsewhere. Such a target is not a DOM descendant of the card and never selects it.\n *\n * The target is duck typed (`nodeType`) rather than checked with `instanceof`, so a card rendered\n * into another realm's document (an iframe, or a popout window reached through `createPortal`)\n * still selects: its nodes are not instances of the main realm's `Node`/`Element`.\n */\nfunction isForeignEvent(event: React.SyntheticEvent, root: Element): boolean {\n const target = event.target as Partial<Node> | null;\n if (!target || typeof target.nodeType !== 'number' || !root.contains(target as Node)) {\n return true;\n }\n if (target.nodeType !== ELEMENT_NODE) return false;\n const control = (target as Element).closest(INTERACTIVE_SELECTOR);\n return control !== null && control !== root && root.contains(control);\n}\n\n/** Warn-once key of the \"selectable card contains tabbable elements\" diagnostic. */\nconst NESTED_INTERACTIVE_WARNING = 'Card:nested-interactive';\n\n/**\n * The id of the header title that names the built-in checkbox of a `selectionControl=\"checkbox\"`\n * card; `null` everywhere else (other cards, and a `Card.Header` rendered on its own, which does\n * not require a Card). A string, never an object, so the provider value needs no memoisation.\n */\nconst CardTitleIdContext = React.createContext<string | null>(null);\n\n/**\n * The Card's own props (the XOwnProps rule of `PolymorphicProps`: component-specific props only).\n * Every other prop comes from the rendered element (`as`).\n */\nexport interface CardOwnProps {\n /**\n * Whether the card is selected. Shown with the selected colors plus non-color cues: a 2px primary\n * border (a 1px border plus an inset 1px ring), a Highlight outline in forced-colors mode, and a\n * check glyph (with `selectionControl=\"checkbox\"` the checked checkbox instead).\n *\n * The state reaches assistive technology only on a selectable card (`onSelect`): as\n * `aria-pressed` (default mode) or as the built-in checkbox's checked state. Without `onSelect`,\n * `selected` is a visual state only (the glyph is decorative); state it in the content if it\n * matters to screen-reader users, or make the card selectable.\n */\n selected?: boolean;\n /**\n * Makes the card selectable: called when the card is activated by a click, Enter (on key down)\n * or Space (on key up, like a native button) in the default mode, or when its built-in checkbox\n * changes (`selectionControl=\"checkbox\"`). Clicks and key presses that start inside a nested\n * interactive element (a button, link, input or any element with `tabindex`), or in content\n * portaled out of the card (a menu, popover or dialog opened from it), are ignored, so a footer\n * action never selects the card.\n */\n onSelect?: () => void;\n /**\n * How a selectable card (`onSelect`) exposes its selection:\n * - `'card'` (default): the card itself is the control — `role=\"button\"`, a tab stop, Enter and\n * Space activation and `aria-pressed={selected}` when `selected` is defined. Use it only for\n * cards **without** interactive content: a button inside a `role=\"button\"` card is invalid\n * (axe `nested-interactive`), and a development warning points here. A button's children are\n * presentational, so the card's content is flattened into its name: a heading (e.g.\n * `<Card.Header as=\"h3\">`), list or other structure inside it is not exposed and cannot be\n * reached by heading navigation (no warning covers this). Keep such cards short.\n * - `'checkbox'`: the card is not a widget; a built-in native checkbox (top end corner) carries\n * `selected` and is named by the `Card.Header` title (or `selectLabel`). Pointer clicks on\n * non-interactive card areas still toggle it. Use it for cards with actions, and for cards\n * whose headings or other structure must stay navigable.\n * @default 'card'\n */\n selectionControl?: 'card' | 'checkbox';\n /**\n * Accessible name of the built-in checkbox (`selectionControl=\"checkbox\"`). Defaults to the\n * `Card.Header` title, which the checkbox references with `aria-labelledby`.\n */\n selectLabel?: string;\n}\n\n/**\n * Props of {@link Card} rendered as `C` (default `'div'`). `CardProps` without a type argument is\n * the 0.4 name: the props of a Card rendered as a `<div>`, including `ref`.\n */\nexport type CardProps<C extends React.ElementType = 'div'> = PolymorphicProps<C, CardOwnProps>;\n\n/** The props the implementation reads, for any `as` (the public typing is `PolymorphicComponent`). */\ntype CardImplProps = CardOwnProps &\n Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n type?: string;\n };\n\n// The Card root, documented on the exported `Card` const.\nconst CardRoot: PolymorphicComponent<'div', CardOwnProps> = (props) => {\n const {\n as,\n selected,\n onSelect,\n selectionControl = 'card',\n selectLabel,\n className,\n children,\n ref,\n onClick,\n onKeyDown,\n onKeyUp,\n onBlur,\n ...rest\n } = props as CardImplProps;\n\n const Component: React.ElementType = as ?? 'div';\n const selectable = onSelect !== undefined;\n const checkboxMode = selectable && selectionControl === 'checkbox';\n const cardMode = selectable && !checkboxMode;\n /** A native `<button>` already has the role, tab stop and keyboard activation. */\n const nativeButton = Component === 'button';\n\n const titleId = useId('card-title');\n const rootRef = React.useRef<HTMLElement | null>(null);\n const mergedRef = useMergedRefs<HTMLElement>(ref, rootRef);\n\n // Development diagnostics (C-DEV): read the mounted DOM after every commit (content can change\n // without prop changes), warn once. Once a key has warned, its DOM scan is skipped.\n React.useEffect(() => {\n const root = rootRef.current;\n if (!isDev || !root || !selectable) return;\n if (\n cardMode &&\n !hasWarned(NESTED_INTERACTIVE_WARNING) &&\n getTabbableElements(root).length > 0\n ) {\n warnOnce(\n NESTED_INTERACTIVE_WARNING,\n 'Card: a selectable card (`onSelect`) is a button and must not contain focusable elements (buttons, links, inputs). Use `selectionControl=\"checkbox\"` for cards with interactive content.',\n );\n }\n if (checkboxMode && !selectLabel && !root.ownerDocument.getElementById(titleId)) {\n warnOnce(\n 'Card:checkbox-name',\n 'Card: the selection checkbox has no accessible name. Render a `Card.Header` with a `title`, or pass `selectLabel`.',\n );\n }\n });\n\n /**\n * Set by an unprevented Space keydown on the card; Space selects on the following keyup only\n * while it is set (like a native button and P01's Button: a keyup alone never selects, and\n * moving focus away in between cancels). The ref is only touched from event handlers, through\n * these two stable callbacks (C-HOOKS).\n */\n const spaceArmedRef = React.useRef(false);\n /** Arms (or disarms) Space activation. */\n const setSpaceArmed = useEventCallback((armed: boolean) => {\n spaceArmedRef.current = armed;\n });\n /** Reads and clears the Space arm. */\n const takeSpaceArmed = useEventCallback(() => {\n const armed = spaceArmedRef.current;\n spaceArmedRef.current = false;\n return armed;\n });\n\n const handleClick = composeEventHandlers<React.MouseEvent<HTMLElement>>(onClick, (event) => {\n if (!selectable || isForeignEvent(event, event.currentTarget)) return;\n onSelect();\n });\n\n /** Keyboard activation applies to a `role=\"button\"` card (a native `<button>` has its own). */\n const keyboardActivation = cardMode && !nativeButton;\n\n const handleKeyDown = composeEventHandlers<React.KeyboardEvent<HTMLElement>>(\n onKeyDown,\n (event) => {\n if (!keyboardActivation) return;\n if (event.key !== 'Enter' && event.key !== ' ') return;\n if (isForeignEvent(event, event.currentTarget)) return;\n // Space would scroll the page: prevent it now, select on keyup. Enter selects on keydown; a\n // held Enter does not toggle repeatedly.\n event.preventDefault();\n if (event.key === ' ') setSpaceArmed(true);\n else if (!event.repeat) onSelect?.();\n },\n );\n\n const handleKeyUp = composeEventHandlers<React.KeyboardEvent<HTMLElement>>(\n onKeyUp,\n (event) => {\n if (!keyboardActivation || event.key !== ' ') return;\n // Always consume the arm, also when the consumer prevented this keyup.\n const armed = takeSpaceArmed();\n if (!armed || event.defaultPrevented || isForeignEvent(event, event.currentTarget)) return;\n event.preventDefault();\n onSelect?.();\n },\n { checkDefaultPrevented: false },\n );\n\n // Moving focus away between Space keydown and keyup cancels the activation (native behavior).\n const handleBlur = composeEventHandlers<React.FocusEvent<HTMLElement>>(\n onBlur,\n () => {\n if (keyboardActivation) setSpaceArmed(false);\n },\n { checkDefaultPrevented: false },\n );\n\n /** Defaults the consumer may override (C-COMPOSE: before `{...rest}`). */\n const defaults: Record<string, unknown> = {};\n if (cardMode) {\n if (nativeButton) {\n defaults.type = 'button';\n } else {\n defaults.role = 'button';\n defaults.tabIndex = 0;\n }\n if (selected !== undefined) defaults['aria-pressed'] = selected;\n }\n\n return (\n <CardTitleIdContext.Provider value={checkboxMode ? titleId : null}>\n <Component\n {...defaults}\n {...rest}\n ref={mergedRef}\n data-selected={selected ? '' : undefined}\n className={cn(\n cardClassNames.root,\n 'overflow-hidden rounded-md border border-border bg-card shadow-4',\n // Positions the check glyph / checkbox; plain cards keep their 0.4 positioning.\n (selectable || selected !== undefined) && 'relative',\n selected &&\n cn(\n 'border-primary bg-selected text-selected-foreground ring-1 ring-inset ring-primary',\n forcedColors.selectedContainer,\n ),\n selectable && 'cursor-pointer',\n cardMode && focusRing,\n className,\n )}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n onBlur={handleBlur}\n >\n {checkboxMode && (\n <input\n type=\"checkbox\"\n checked={selected ?? false}\n onChange={() => onSelect()}\n aria-label={selectLabel}\n aria-labelledby={selectLabel ? undefined : titleId}\n className={cn(\n cardClassNames.checkbox,\n 'absolute end-3 top-3 m-0 size-4 cursor-pointer accent-primary',\n focusRing,\n )}\n />\n )}\n {selected && !checkboxMode && (\n <CheckIcon\n size={12}\n className={cn(cardClassNames.checkmark, 'absolute end-2 top-2 text-primary')}\n />\n )}\n {children}\n </Component>\n </CardTitleIdContext.Provider>\n );\n};\nCardRoot.displayName = 'Card';\n\n/** The Card.Header's own props (component-specific props only). */\nexport interface CardHeaderOwnProps {\n /**\n * Title content displayed in the card header. It also names a selectable card's built-in\n * checkbox (`selectionControl=\"checkbox\"`). Content that renders nothing (`''`, `[]`, a list of\n * nothing) renders no title element; `0` is content.\n */\n title?: React.ReactNode;\n /** Subtitle content displayed below the title (none when it renders nothing, as `title`). */\n subtitle?: React.ReactNode;\n}\n\n/** Props of {@link CardHeader} rendered as `C` (default `'div'`), including `ref`. */\nexport type CardHeaderProps<C extends React.ElementType = 'div'> = PolymorphicProps<\n C,\n CardHeaderOwnProps\n>;\n\ntype CardHeaderImplProps = CardHeaderOwnProps &\n Omit<React.HTMLAttributes<HTMLElement>, 'title'> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n };\n\n/**\n * The header of a {@link Card}: a title and an optional subtitle, followed by any children.\n * Flat export for React Server Components (`Card.Header` in client files).\n */\nexport const CardHeader: PolymorphicComponent<'div', CardHeaderOwnProps> = (props) => {\n const { as, title, subtitle, className, children, ref, ...rest } = props as CardHeaderImplProps;\n const Component: React.ElementType = as ?? 'div';\n /** Set only inside a `selectionControl=\"checkbox\"` card: the title names its checkbox. */\n const titleId = React.useContext(CardTitleIdContext);\n // A title or subtitle that renders nothing (`''`, `[]`, a list of nothing) gets no element, so a\n // checkbox card with such a title warns about its missing name; `0` is content.\n const hasTitle = slotRendersContent(title);\n const hasSubtitle = slotRendersContent(subtitle);\n return (\n // In a checkbox card the header keeps clear of the checkbox in the top end corner.\n <Component\n ref={ref}\n className={cn(cardHeaderClassNames.root, 'p-4', titleId && 'pe-10', className)}\n {...rest}\n >\n {hasTitle && (\n <div\n id={titleId ?? undefined}\n className={cn(cardHeaderClassNames.title, 'text-subtitle-1')}\n >\n {materialiseSlotContent(title)}\n </div>\n )}\n {hasSubtitle && (\n <div className={cn(cardHeaderClassNames.subtitle, 'text-caption-1 text-muted-foreground')}>\n {materialiseSlotContent(subtitle)}\n </div>\n )}\n {children}\n </Component>\n );\n};\nCardHeader.displayName = 'CardHeader';\n\n/** The Card.Body's own props: none besides the element's (component-specific props only). */\nexport type CardBodyOwnProps = Record<never, never>;\n\n/** Props of {@link CardBody} rendered as `C` (default `'div'`), including `ref`. */\nexport type CardBodyProps<C extends React.ElementType = 'div'> = PolymorphicProps<\n C,\n CardBodyOwnProps\n>;\n\ntype CardSectionImplProps = React.HTMLAttributes<HTMLElement> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n};\n\n/**\n * The main content of a {@link Card}. Flat export for React Server Components (`Card.Body` in\n * client files).\n */\nexport const CardBody: PolymorphicComponent<'div', CardBodyOwnProps> = (props) => {\n const { as, className, ref, ...rest } = props as CardSectionImplProps;\n const Component: React.ElementType = as ?? 'div';\n return (\n <Component ref={ref} className={cn(cardBodyClassNames.root, 'p-4 pt-0', className)} {...rest} />\n );\n};\nCardBody.displayName = 'CardBody';\n\n/** The Card.Footer's own props: none besides the element's (component-specific props only). */\nexport type CardFooterOwnProps = Record<never, never>;\n\n/** Props of {@link CardFooter} rendered as `C` (default `'div'`), including `ref`. */\nexport type CardFooterProps<C extends React.ElementType = 'div'> = PolymorphicProps<\n C,\n CardFooterOwnProps\n>;\n\n/**\n * The action row of a {@link Card} (end-aligned). A selectable card with actions here needs\n * `selectionControl=\"checkbox\"`. Flat export for React Server Components (`Card.Footer` in client\n * files).\n */\nexport const CardFooter: PolymorphicComponent<'div', CardFooterOwnProps> = (props) => {\n const { as, className, ref, ...rest } = props as CardSectionImplProps;\n const Component: React.ElementType = as ?? 'div';\n return (\n <Component\n ref={ref}\n className={cn(cardFooterClassNames.root, 'flex justify-end gap-2 p-4 pt-0', className)}\n {...rest}\n />\n );\n};\nCardFooter.displayName = 'CardFooter';\n\n/**\n * A surface that groups related content, with `Card.Header`, `Card.Body` and `Card.Footer`.\n *\n * **Selectable cards** (`onSelect`) come in two patterns:\n * - A card without interactive content is itself the control (`selectionControl=\"card\"`, the\n * default): it is a `role=\"button\"` tab stop activated by click, Enter (key down) or Space (key\n * up, cancelled by moving focus away first), with `aria-pressed` reflecting `selected`. Its\n * content becomes the button's name, so headings and other structure inside it are flattened.\n * - A card that contains buttons or links, or headings that must stay navigable, uses\n * `selectionControl=\"checkbox\"`: a built-in checkbox named by the header title carries the\n * selection, and the card's actions and structure stay separate from it.\n *\n * In both modes events that start inside a nested interactive element, or in content portaled out\n * of the card, are ignored. `onClick`, `onKeyDown` and `onKeyUp` are composed with the built-in\n * selection (call `event.preventDefault()` to skip it). A `selected` card without `onSelect` shows\n * the selected look only; its state is not exposed to assistive technology.\n *\n * React Server Components cannot dot into a client module: import the flat names `CardHeader`,\n * `CardBody` and `CardFooter` there; `Card.Header` etc. work in client files.\n *\n * @example\n * <Card onSelect={toggle} selected={selected}>\n * <Card.Header title=\"Pro plan\" subtitle=\"Billed monthly\" />\n * </Card>\n *\n * <Card onSelect={toggle} selected={selected} selectionControl=\"checkbox\">\n * <Card.Header title=\"Pro plan\" />\n * <Card.Footer><Button>Details</Button></Card.Footer>\n * </Card>\n */\nexport const Card = /* @__PURE__ */ Object.assign(CardRoot, {\n Header: CardHeader,\n Body: CardBody,\n Footer: CardFooter,\n});\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,IAAMG,IACJ,2FAGIC,IAAe;AAerB,SAASC,EAAe,GAA6B,GAAwB;CAC3E,IAAMC,IAASC,EAAM;CACrB,IAAI,CAACD,KAAU,OAAOA,EAAO,YAAa,YAAY,CAACE,EAAK,SAASF,CAAc,GACjF,OAAO;CAET,IAAIA,EAAO,aAAaF,GAAc,OAAO;CAC7C,IAAMK,IAAWH,EAAmB,QAAQH,CAAoB;CAChE,OAAOM,MAAY,QAAQA,MAAYD,KAAQA,EAAK,SAASC,CAAO;AACtE;AAGA,IAAMC,IAA6B,2BAO7BC,IAAqBT,EAAM,cAA6B,IAAI,GAiE5DU,KAAuD,MAAU;CACrE,IAAM,EACJ,OACA,aACA,aACA,sBAAmB,QACnB,gBACA,cACA,aACA,QACA,YACA,cACA,YACA,WACA,GAAGC,MACDC,GAEEC,IAA+BC,KAAM,OACrCC,IAAaC,MAAa,KAAA,GAC1BC,IAAeF,KAAcG,MAAqB,YAClDC,IAAWJ,KAAc,CAACE,GAE1BG,IAAeP,MAAc,UAE7BQ,IAAUvB,EAAM,YAAY,GAC5BwB,IAAUtB,EAAM,OAA2B,IAAI,GAC/CuB,IAAYC,EAA2BC,GAAKH,CAAO;CAIzD,EAAM,gBAAgB;EACpB,IAAMhB,IAAOgB,EAAQ;EACrB,AAAKI,KAAUpB,KAASS,MAEtBI,KACA,CAACQ,EAAUnB,CAA0B,KACrCoB,EAAoBtB,CAAI,CAAC,CAAC,SAAS,KAEnCuB,EACErB,GACA,4LACF,GAEES,KAAgB,CAACa,KAAe,CAAC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AAGnD,MAASC;CAExC,OACE,kBAFmCE,KAAM,OAEzC;EAAgB;EAAK,WAAWkC,EAAGe,EAAmB,MAAM,YAAYZ,CAAS;EAAG,GAAIxC;CAAO,CAAA;AAEnG;AACA,EAAS,cAAc;AAgBvB,IAAaqD,KAA+D,MAAU;CACpF,IAAM,EAAE,OAAI,cAAW,QAAK,GAAGrD,MAASC;CAExC,OACE,kBAFmCE,KAAM,OAEzC;EACO;EACL,WAAWkC,EAAGiB,EAAqB,MAAM,mCAAmCd,CAAS;EACrF,GAAIxC;CACL,CAAA;AAEL;AACA,EAAW,cAAc;AAgCzB,IAAauD,IAAuB,uBAAO,OAAOxD,GAAU;CAC1D,QAAQ4C;CACR,MAAMQ;CACN,QAAQE;AACV,CAAC"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/slot.cjs"),a=require("../../lib/composeEventHandlers.cjs"),o=require("../../hooks/useEventCallback.cjs"),ee=require("../../hooks/useControllable.cjs"),te=require("../../hooks/useId.cjs"),ne=require("../../hooks/useMergedRefs.cjs"),s=require("../../lib/aria.cjs"),re=require("../../hooks/usePrefersReducedMotion.cjs"),ie=require("../../hooks/useDirection.cjs"),c=require("../../lib/styles.cjs"),l=require("../../lib/icons.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("react/jsx-runtime");var ae=`Pause slide rotation`,oe=`Start slide rotation`,se=`Previous slide`,ce=`Next slide`,le=`Choose slide`,ue=(e,t)=>`Slide ${e+1} of ${t}`,de=`carousel`,fe=`slide`;function f(e,t){return t<=0||!Number.isFinite(e)?0:Math.min(Math.max(Math.trunc(e),0),t-1)}function pe(e){return e instanceof Element&&e.closest(`[data-carousel-rotation]`)!==null}var p=[`absolute z-10 inline-flex h-8 w-8 items-center justify-center rounded-full border border-border bg-background text-foreground shadow-2`,`not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:active:bg-subtle-pressed`,c.focusRing,c.disabledStyles].join(` `),me=()=>(0,d.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,children:[(0,d.jsx)(`rect`,{x:`4`,y:`3`,width:`3`,height:`10`,rx:`1`}),(0,d.jsx)(`rect`,{x:`9`,y:`3`,width:`3`,height:`10`,rx:`1`})]}),he=()=>(0,d.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,children:(0,d.jsx)(`path`,{d:`M5 3.5v9a.5.5 0 0 0 .77.42l7-4.5a.5.5 0 0 0 0-.84l-7-4.5A.5.5 0 0 0 5 3.5Z`})}),m=({value:e,defaultValue:m=0,onValueChange:g,autoPlay:ge=!1,autoPlayInterval:_=5e3,autoPlayLabels:v,labels:y,loop:b=!1,className:x,children:_e,onMouseEnter:ve,onMouseLeave:ye,onFocus:be,onBlur:xe,ref:Se,...S})=>{let[Ce,C]=ee.useControllable(e,m,g),w=te.useId(`carousel-slides`),[we,Te]=u.useState(null),T=ne.useMergedRefs(Se,Te),E=ie.useDirection(we),D=S.dir===`rtl`||S.dir===`ltr`?S.dir:E,O=re.usePrefersReducedMotion(),[Ee,k]=u.useState(null),[A,j]=u.useState(null),[De,M]=u.useState(!1),[Oe,N]=u.useState(!1),[ke,P]=u.useState(!1),[F,I]=u.useState(!1),L=[],R=!1;for(let e of n.flattenChildren(_e))n.isElementOfType(e.node,h)?L.push(e):i.slotRendersContent(e.node)&&(R=!0);let z=L.length;u.useEffect(()=>{R&&r.warnOnce(`Carousel:non-item-children`,"Carousel: only `Carousel.Item` (`CarouselItem`) children are slides, directly or in Fragments; other children are not rendered. A component that renders `Carousel.Item` itself is not recognised: render the `Carousel.Item` in the Carousel and put the component inside it.")},[R]);let B=f(Ce,z),V=B<=0,H=B>=z-1,U=z<=1||!b&&V,W=z<=1||!b&&H,G=A===z&&!b,K=(Ee??O)||G,q=ge&&z>1;q&&!b&&H&&!K?j(z):A!==null&&!G&&j(null);let J=q&&!K&&!(De&&!Oe)&&!(ke&&!F),Y=e=>{e>=0&&e<z&&e!==B&&C(e)},Ae=()=>Y(V?z-1:B-1),je=()=>Y(H?0:B+1),X=o.useEventCallback(()=>{C(e=>{let t=f(e,z);return t<z-1?t+1:b?0:e})});u.useEffect(()=>{if(!J)return;let e=setInterval(X,_);return()=>clearInterval(e)},[J,_,X]);let Me=()=>{K?(!b&&H&&Y(0),j(null),k(!1),I(!0)):(k(!0),I(!1))},Z={onMouseEnter:a.composeEventHandlers(ve,()=>M(!0)),onMouseLeave:a.composeEventHandlers(ye,()=>M(!1)),onFocus:a.composeEventHandlers(be,e=>{let t=e.relatedTarget,n=!(t instanceof Node&&e.currentTarget.contains(t));P(!0),(n||!pe(e.target))&&I(!1)}),onBlur:a.composeEventHandlers(xe,e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||(P(!1),I(!1))})};if(z===0)return(0,d.jsx)(`div`,{ref:T,className:t.cn(`relative`,x),...Z,...S});let Ne=(D===`rtl`?1:-1)*B*100,Q=D===`rtl`?`-scale-x-100`:void 0,Pe=v?.pause??ae,Fe=v?.play??oe,Ie=y?.previous??se,Le=y?.next??ce,Re=y?.picker??le,$=y?.slide??ue,ze=y?.carouselRoleDescription??de,Be=y?.slideRoleDescription??fe;return(0,d.jsxs)(`div`,{ref:T,role:`region`,"aria-roledescription":ze,"aria-label":`Carousel`,className:t.cn(`relative isolate overflow-hidden`,x),...Z,...S,children:[q&&(0,d.jsx)(`button`,{type:`button`,"data-carousel-rotation":``,"aria-label":K?Fe:Pe,"aria-controls":w,onClick:Me,onMouseEnter:()=>N(!0),onMouseLeave:()=>N(!1),className:t.cn(p,`top-2 start-2`),children:K?(0,d.jsx)(he,{}):(0,d.jsx)(me,{})}),(0,d.jsx)(`div`,{id:w,className:`flex transition-transform duration-300 ease-in-out motion-reduce:transition-none`,style:{transform:`translateX(${Ne}%)`},children:L.map(({key:e,node:t},n)=>{let r=n===B;return(0,d.jsx)(`div`,{role:`group`,"aria-roledescription":Be,"aria-label":$(n,z),"aria-hidden":!r||void 0,inert:!r,className:`w-full shrink-0`,children:t},e)})}),(0,d.jsx)(`div`,{"aria-live":J?`off`:`polite`,"aria-atomic":`true`,className:`sr-only`,children:$(B,z)}),(0,d.jsx)(`button`,{type:`button`,"aria-label":Ie,"aria-controls":w,...s.focusableDisabledProps(U),onClick:s.preventIfDisabled(U,Ae),className:t.cn(p,`top-1/2 start-2 -translate-y-1/2`),children:(0,d.jsx)(l.ChevronLeftIcon,{size:16,className:Q})}),(0,d.jsx)(`button`,{type:`button`,"aria-label":Le,"aria-controls":w,...s.focusableDisabledProps(W),onClick:s.preventIfDisabled(W,je),className:t.cn(p,`top-1/2 end-2 -translate-y-1/2`),children:(0,d.jsx)(l.ChevronRightIcon,{size:16,className:Q})}),(0,d.jsx)(`div`,{role:`group`,"aria-label":Re,className:`absolute inset-x-0 bottom-1 z-10 mx-auto flex w-fit`,children:L.map(({key:e},n)=>{let r=n===B;return(0,d.jsx)(`button`,{type:`button`,"aria-label":$(n,z),"aria-current":r?`true`:void 0,onClick:()=>Y(n),className:t.cn(`group inline-flex h-6 min-w-6 items-center justify-center`,c.focusRing),children:(0,d.jsx)(`span`,{"aria-hidden":`true`,className:t.cn(`block h-2 rounded-full transition-[width,background-color] duration-200 motion-reduce:transition-none`,r?t.cn(`w-5 bg-primary`,c.forcedColors.selectedLeaf):`w-2 bg-stroke-accessible group-hover:bg-foreground forced-colors:bg-[ButtonText] forced-colors:forced-color-adjust-none`)})},e)})})]})};m.displayName=`Carousel`;var h=({className:e,children:n,ref:r,...i})=>(0,d.jsx)(`div`,{ref:r,className:t.cn(`p-4`,e),...i,children:n});h.displayName=`CarouselItem`;var g=Object.assign(m,{Item:h});exports.Carousel=g,exports.CarouselItem=h;
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/slot.cjs"),a=require("../../lib/composeEventHandlers.cjs"),o=require("../../lib/classNames.cjs"),ee=require("../../hooks/useEventCallback.cjs"),s=require("../../hooks/useControllable.cjs"),te=require("../../hooks/useId.cjs"),ne=require("../../hooks/useMergedRefs.cjs"),c=require("../../lib/aria.cjs"),re=require("../../hooks/usePrefersReducedMotion.cjs"),ie=require("../../hooks/useDirection.cjs"),l=require("../../lib/styles.cjs"),u=require("../../lib/icons.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("react/jsx-runtime");var ae=`Pause slide rotation`,oe=`Start slide rotation`,se=`Previous slide`,ce=`Next slide`,le=`Choose slide`,ue=(e,t)=>`Slide ${e+1} of ${t}`,de=`carousel`,fe=`slide`;function p(e,t){return t<=0||!Number.isFinite(e)?0:Math.min(Math.max(Math.trunc(e),0),t-1)}function pe(e){return e instanceof Element&&e.closest(`[data-carousel-rotation]`)!==null}var m=[`absolute z-10 inline-flex h-8 w-8 items-center justify-center rounded-full border border-border bg-background text-foreground shadow-2`,`not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:active:bg-subtle-pressed`,l.focusRing,l.disabledStyles].join(` `),me=()=>(0,f.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,children:[(0,f.jsx)(`rect`,{x:`4`,y:`3`,width:`3`,height:`10`,rx:`1`}),(0,f.jsx)(`rect`,{x:`9`,y:`3`,width:`3`,height:`10`,rx:`1`})]}),he=()=>(0,f.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,children:(0,f.jsx)(`path`,{d:`M5 3.5v9a.5.5 0 0 0 .77.42l7-4.5a.5.5 0 0 0 0-.84l-7-4.5A.5.5 0 0 0 5 3.5Z`})}),h=({value:e,defaultValue:h=0,onValueChange:_,autoPlay:ge=!1,autoPlayInterval:v=5e3,autoPlayLabels:y,labels:b,loop:x=!1,className:S,children:_e,onMouseEnter:ve,onMouseLeave:ye,onFocus:be,onBlur:xe,ref:Se,...C})=>{let[Ce,w]=s.useControllable(e,h,_),T=te.useId(`carousel-slides`),[we,Te]=d.useState(null),E=ne.useMergedRefs(Se,Te),D=ie.useDirection(we),O=C.dir===`rtl`||C.dir===`ltr`?C.dir:D,Ee=re.usePrefersReducedMotion(),[De,k]=d.useState(null),[A,j]=d.useState(null),[Oe,M]=d.useState(!1),[ke,N]=d.useState(!1),[Ae,P]=d.useState(!1),[je,F]=d.useState(!1),I=[],L=!1;for(let e of n.flattenChildren(_e))n.isElementOfType(e.node,g)?I.push(e):i.slotRendersContent(e.node)&&(L=!0);let R=I.length;d.useEffect(()=>{L&&r.warnOnce(`Carousel:non-item-children`,"Carousel: only `Carousel.Item` (`CarouselItem`) children are slides, directly or in Fragments; other children are not rendered. A component that renders `Carousel.Item` itself is not recognised: render the `Carousel.Item` in the Carousel and put the component inside it.")},[L]);let z=p(Ce,R),B=z<=0,V=z>=R-1,H=R<=1||!x&&B,U=R<=1||!x&&V,W=A===R&&!x,G=(De??Ee)||W,K=ge&&R>1;K&&!x&&V&&!G?j(R):A!==null&&!W&&j(null);let q=K&&!G&&!(Oe&&!ke)&&!(Ae&&!je),J=e=>{e>=0&&e<R&&e!==z&&w(e)},Me=()=>J(B?R-1:z-1),Ne=()=>J(V?0:z+1),Y=ee.useEventCallback(()=>{w(e=>{let t=p(e,R);return t<R-1?t+1:x?0:e})});d.useEffect(()=>{if(!q)return;let e=setInterval(Y,v);return()=>clearInterval(e)},[q,v,Y]);let Pe=()=>{G?(!x&&V&&J(0),j(null),k(!1),F(!0)):(k(!0),F(!1))},X={onMouseEnter:a.composeEventHandlers(ve,()=>M(!0)),onMouseLeave:a.composeEventHandlers(ye,()=>M(!1)),onFocus:a.composeEventHandlers(be,e=>{let t=e.relatedTarget,n=!(t instanceof Node&&e.currentTarget.contains(t));P(!0),(n||!pe(e.target))&&F(!1)}),onBlur:a.composeEventHandlers(xe,e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||(P(!1),F(!1))})};if(R===0)return(0,f.jsx)(`div`,{ref:E,className:t.cn(o.carouselClassNames.root,`relative`,S),...X,...C});let Fe=(O===`rtl`?1:-1)*z*100,Z=O===`rtl`?`-scale-x-100`:void 0,Ie=y?.pause??ae,Le=y?.play??oe,Re=b?.previous??se,ze=b?.next??ce,Be=b?.picker??le,Q=b?.slide??ue,$=b?.carouselRoleDescription??de,Ve=b?.slideRoleDescription??fe;return(0,f.jsxs)(`div`,{ref:E,role:`region`,"aria-roledescription":$,"aria-label":`Carousel`,className:t.cn(o.carouselClassNames.root,`relative isolate overflow-hidden`,S),...X,...C,children:[K&&(0,f.jsx)(`button`,{type:`button`,"data-carousel-rotation":``,"aria-label":G?Le:Ie,"aria-controls":T,onClick:Pe,onMouseEnter:()=>N(!0),onMouseLeave:()=>N(!1),className:t.cn(o.carouselClassNames.autoPlayButton,m,`top-2 start-2`),children:G?(0,f.jsx)(he,{}):(0,f.jsx)(me,{})}),(0,f.jsx)(`div`,{id:T,className:t.cn(o.carouselClassNames.track,`flex transition-transform duration-300 ease-in-out motion-reduce:transition-none`),style:{transform:`translateX(${Fe}%)`},children:I.map(({key:e,node:n},r)=>{let i=r===z;return(0,f.jsx)(`div`,{role:`group`,"aria-roledescription":Ve,"aria-label":Q(r,R),"aria-hidden":!i||void 0,inert:!i,className:t.cn(o.carouselClassNames.slide,`w-full shrink-0`),children:n},e)})}),(0,f.jsx)(`div`,{"aria-live":q?`off`:`polite`,"aria-atomic":`true`,className:`sr-only`,children:Q(z,R)}),(0,f.jsx)(`button`,{type:`button`,"aria-label":Re,"aria-controls":T,...c.focusableDisabledProps(H),onClick:c.preventIfDisabled(H,Me),className:t.cn(o.carouselClassNames.previousButton,m,`top-1/2 start-2 -translate-y-1/2`),children:(0,f.jsx)(u.ChevronLeftIcon,{size:16,className:Z})}),(0,f.jsx)(`button`,{type:`button`,"aria-label":ze,"aria-controls":T,...c.focusableDisabledProps(U),onClick:c.preventIfDisabled(U,Ne),className:t.cn(o.carouselClassNames.nextButton,m,`top-1/2 end-2 -translate-y-1/2`),children:(0,f.jsx)(u.ChevronRightIcon,{size:16,className:Z})}),(0,f.jsx)(`div`,{role:`group`,"aria-label":Be,className:t.cn(o.carouselClassNames.picker,`absolute inset-x-0 bottom-1 z-10 mx-auto flex w-fit`),children:I.map(({key:e},n)=>{let r=n===z;return(0,f.jsx)(`button`,{type:`button`,"aria-label":Q(n,R),"aria-current":r?`true`:void 0,onClick:()=>J(n),className:t.cn(o.carouselClassNames.pickerButton,`group inline-flex h-6 min-w-6 items-center justify-center`,l.focusRing),children:(0,f.jsx)(`span`,{"aria-hidden":`true`,className:t.cn(o.carouselClassNames.pickerIndicator,`block h-2 rounded-full transition-[width,background-color] duration-200 motion-reduce:transition-none`,r?t.cn(`w-5 bg-primary`,l.forcedColors.selectedLeaf):`w-2 bg-stroke-accessible group-hover:bg-foreground forced-colors:bg-[ButtonText] forced-colors:forced-color-adjust-none`)})},e)})})]})};h.displayName=`Carousel`;var g=({className:e,children:n,ref:r,...i})=>(0,f.jsx)(`div`,{ref:r,className:t.cn(o.carouselItemClassNames.root,`p-4`,e),...i,children:n});g.displayName=`CarouselItem`;var _=Object.assign(h,{Item:g});exports.Carousel=_,exports.CarouselItem=g;
2
2
  //# sourceMappingURL=Carousel.cjs.map