@42-central/ui-react 0.17.1 → 0.18.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 (311) hide show
  1. package/dist/{chunk-FD6P6PLQ.js → chunk-5JHDSVEZ.js} +3 -3
  2. package/dist/{chunk-FD6P6PLQ.js.map → chunk-5JHDSVEZ.js.map} +1 -1
  3. package/dist/{chunk-QMW7D5GU.js → chunk-5OQLFX47.js} +4 -3
  4. package/dist/chunk-5OQLFX47.js.map +1 -0
  5. package/dist/{chunk-VZ2TPU4B.js → chunk-6GDMSENK.js} +3 -2
  6. package/dist/chunk-6GDMSENK.js.map +1 -0
  7. package/dist/{chunk-TNNH3FVQ.js → chunk-6OLTJYSX.js} +24 -8
  8. package/dist/chunk-6OLTJYSX.js.map +1 -0
  9. package/dist/{chunk-POKDSVQT.js → chunk-AE7QTLJ5.js} +5 -4
  10. package/dist/chunk-AE7QTLJ5.js.map +1 -0
  11. package/dist/{chunk-44OV3PNH.js → chunk-B2YJKRNQ.js} +3 -3
  12. package/dist/{chunk-44OV3PNH.js.map → chunk-B2YJKRNQ.js.map} +1 -1
  13. package/dist/{chunk-YIQI2CF3.js → chunk-CTSO6V72.js} +3 -2
  14. package/dist/chunk-CTSO6V72.js.map +1 -0
  15. package/dist/{chunk-EVVMHTCL.js → chunk-EBREIC3L.js} +4 -3
  16. package/dist/chunk-EBREIC3L.js.map +1 -0
  17. package/dist/{chunk-UNSAA7YG.js → chunk-FHG54IT5.js} +3 -2
  18. package/dist/chunk-FHG54IT5.js.map +1 -0
  19. package/dist/{chunk-3GYOIQW7.js → chunk-FZIHZT5R.js} +5 -5
  20. package/dist/{chunk-3GYOIQW7.js.map → chunk-FZIHZT5R.js.map} +1 -1
  21. package/dist/{chunk-2H46IXW4.js → chunk-HAQJQFE6.js} +28 -8
  22. package/dist/chunk-HAQJQFE6.js.map +1 -0
  23. package/dist/{chunk-IHYFYMHJ.js → chunk-HT5JAHR3.js} +6 -6
  24. package/dist/{chunk-IHYFYMHJ.js.map → chunk-HT5JAHR3.js.map} +1 -1
  25. package/dist/chunk-I4SQQIP5.js +12 -0
  26. package/dist/chunk-I4SQQIP5.js.map +1 -0
  27. package/dist/{chunk-J3PELDH3.js → chunk-JITF6I7N.js} +22 -6
  28. package/dist/chunk-JITF6I7N.js.map +1 -0
  29. package/dist/{chunk-IFWCCAQV.js → chunk-KHMFNH3X.js} +3 -2
  30. package/dist/chunk-KHMFNH3X.js.map +1 -0
  31. package/dist/{chunk-SIG4DMNZ.js → chunk-MI2WZRK3.js} +4 -4
  32. package/dist/{chunk-SIG4DMNZ.js.map → chunk-MI2WZRK3.js.map} +1 -1
  33. package/dist/{chunk-YON5Y336.js → chunk-O23Y5ML4.js} +8 -8
  34. package/dist/{chunk-YON5Y336.js.map → chunk-O23Y5ML4.js.map} +1 -1
  35. package/dist/{chunk-P7A3BCAC.js → chunk-OWG4BCQR.js} +3 -3
  36. package/dist/{chunk-P7A3BCAC.js.map → chunk-OWG4BCQR.js.map} +1 -1
  37. package/dist/{chunk-FUWSTUDM.js → chunk-PH354ECN.js} +4 -4
  38. package/dist/{chunk-FUWSTUDM.js.map → chunk-PH354ECN.js.map} +1 -1
  39. package/dist/{chunk-U5GW5EBR.js → chunk-RAUOFTUH.js} +12 -20
  40. package/dist/chunk-RAUOFTUH.js.map +1 -0
  41. package/dist/{chunk-2762HZYX.js → chunk-S2HWWR2H.js} +47 -25
  42. package/dist/chunk-S2HWWR2H.js.map +1 -0
  43. package/dist/{chunk-VLUKI3HL.js → chunk-S7N4LGLZ.js} +6 -13
  44. package/dist/chunk-S7N4LGLZ.js.map +1 -0
  45. package/dist/{chunk-NSOA3GMZ.js → chunk-UHNRAI6V.js} +3 -3
  46. package/dist/{chunk-NSOA3GMZ.js.map → chunk-UHNRAI6V.js.map} +1 -1
  47. package/dist/{chunk-3NZXWCGF.js → chunk-WHKKN3ZK.js} +6 -6
  48. package/dist/{chunk-3NZXWCGF.js.map → chunk-WHKKN3ZK.js.map} +1 -1
  49. package/dist/{chunk-MOI7B3KH.js → chunk-WQN64ZHG.js} +5 -5
  50. package/dist/{chunk-MOI7B3KH.js.map → chunk-WQN64ZHG.js.map} +1 -1
  51. package/dist/chunk-WSIVRDRB.js +34 -0
  52. package/dist/chunk-WSIVRDRB.js.map +1 -0
  53. package/dist/{chunk-6SWK4XG5.js → chunk-YXE4B6X3.js} +2 -2
  54. package/dist/chunk-YXE4B6X3.js.map +1 -0
  55. package/dist/{chunk-NGAQITWP.js → chunk-Z2Z5EXVT.js} +10 -7
  56. package/dist/chunk-Z2Z5EXVT.js.map +1 -0
  57. package/dist/{chunk-IXKELBJA.js → chunk-ZDXQ64A7.js} +63 -44
  58. package/dist/chunk-ZDXQ64A7.js.map +1 -0
  59. package/dist/components/accordion/accordion-data.d.ts +3 -2
  60. package/dist/components/accordion/accordion-data.d.ts.map +1 -1
  61. package/dist/components/accordion/accordion.d.ts +2 -2
  62. package/dist/components/accordion/accordion.d.ts.map +1 -1
  63. package/dist/components/accordion/index.js +20 -8
  64. package/dist/components/accordion/index.js.map +1 -1
  65. package/dist/components/action-icon/action-icon.d.ts +3 -4
  66. package/dist/components/action-icon/action-icon.d.ts.map +1 -1
  67. package/dist/components/action-icon/index.js +2 -1
  68. package/dist/components/alert/alert.d.ts +1 -1
  69. package/dist/components/alert/alert.d.ts.map +1 -1
  70. package/dist/components/alert/index.js +16 -4
  71. package/dist/components/alert/index.js.map +1 -1
  72. package/dist/components/app-shell/app-shell.d.ts +3 -2
  73. package/dist/components/app-shell/app-shell.d.ts.map +1 -1
  74. package/dist/components/app-shell/index.js +4 -2
  75. package/dist/components/app-shell/index.js.map +1 -1
  76. package/dist/components/autocomplete/index.js +5 -4
  77. package/dist/components/autocomplete/index.js.map +1 -1
  78. package/dist/components/breadcrumb/breadcrumb.d.ts +3 -2
  79. package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -1
  80. package/dist/components/breadcrumb/index.js +11 -5
  81. package/dist/components/breadcrumb/index.js.map +1 -1
  82. package/dist/components/button/button.d.ts +4 -4
  83. package/dist/components/button/button.d.ts.map +1 -1
  84. package/dist/components/button/index.js +2 -1
  85. package/dist/components/button-multi-select/index.js +4 -3
  86. package/dist/components/button-multi-select/index.js.map +1 -1
  87. package/dist/components/button-select/index.js +4 -3
  88. package/dist/components/button-select/index.js.map +1 -1
  89. package/dist/components/calendar/index.js +3 -2
  90. package/dist/components/checkbox/index.js +2 -2
  91. package/dist/components/choice-card-group/index.js +1 -1
  92. package/dist/components/circular-progress/circular-progress.d.ts +3 -2
  93. package/dist/components/circular-progress/circular-progress.d.ts.map +1 -1
  94. package/dist/components/circular-progress/index.js +1 -0
  95. package/dist/components/circular-progress/index.js.map +1 -1
  96. package/dist/components/clipboard/clipboard.d.ts +1 -1
  97. package/dist/components/clipboard/clipboard.d.ts.map +1 -1
  98. package/dist/components/clipboard/index.js +9 -5
  99. package/dist/components/clipboard/index.js.map +1 -1
  100. package/dist/components/code-block/chrome.d.ts +4 -1
  101. package/dist/components/code-block/chrome.d.ts.map +1 -1
  102. package/dist/components/code-block/chrome.js +5 -4
  103. package/dist/components/code-block/code-block.d.ts +7 -1
  104. package/dist/components/code-block/code-block.d.ts.map +1 -1
  105. package/dist/components/code-block/index.d.ts +1 -1
  106. package/dist/components/code-block/index.js +12 -10
  107. package/dist/components/code-block/index.js.map +1 -1
  108. package/dist/components/code-block/notation.d.ts +5 -2
  109. package/dist/components/code-block/notation.d.ts.map +1 -1
  110. package/dist/components/code-block/static.d.ts +4 -1
  111. package/dist/components/code-block/static.d.ts.map +1 -1
  112. package/dist/components/code-block/static.js +5 -4
  113. package/dist/components/code-block/static.js.map +1 -1
  114. package/dist/components/collapse/collapse.d.ts +7 -3
  115. package/dist/components/collapse/collapse.d.ts.map +1 -1
  116. package/dist/components/collapse/index.js +2 -1
  117. package/dist/components/combobox/combobox.d.ts +11 -10
  118. package/dist/components/combobox/combobox.d.ts.map +1 -1
  119. package/dist/components/combobox/index.js +5 -4
  120. package/dist/components/combobox-list/index.js +6 -5
  121. package/dist/components/data-table/index.js +20 -19
  122. package/dist/components/data-table/index.js.map +1 -1
  123. package/dist/components/date-picker/index.js +12 -11
  124. package/dist/components/date-picker/index.js.map +1 -1
  125. package/dist/components/divider/divider.d.ts +3 -2
  126. package/dist/components/divider/divider.d.ts.map +1 -1
  127. package/dist/components/divider/index.js +1 -1
  128. package/dist/components/drawer/drawer.d.ts +6 -5
  129. package/dist/components/drawer/drawer.d.ts.map +1 -1
  130. package/dist/components/drawer/index.js +3 -2
  131. package/dist/components/field/field.d.ts +7 -4
  132. package/dist/components/field/field.d.ts.map +1 -1
  133. package/dist/components/field/index.js +1 -1
  134. package/dist/components/file-upload/index.js +3 -2
  135. package/dist/components/file-upload/index.js.map +1 -1
  136. package/dist/components/hover-card/index.js +1 -1
  137. package/dist/components/input/index.js +2 -2
  138. package/dist/components/input/input.d.ts +3 -2
  139. package/dist/components/input/input.d.ts.map +1 -1
  140. package/dist/components/menu/index.js +3 -2
  141. package/dist/components/menu/index.js.map +1 -1
  142. package/dist/components/menu/menu-data.d.ts +6 -1
  143. package/dist/components/menu/menu-data.d.ts.map +1 -1
  144. package/dist/components/menu/menu.d.ts +5 -5
  145. package/dist/components/menu/menu.d.ts.map +1 -1
  146. package/dist/components/modal/index.js +3 -2
  147. package/dist/components/modal/modal.d.ts +4 -3
  148. package/dist/components/modal/modal.d.ts.map +1 -1
  149. package/dist/components/multi-combobox-list/index.js +6 -5
  150. package/dist/components/multi-select/index.js +7 -6
  151. package/dist/components/multi-select/index.js.map +1 -1
  152. package/dist/components/nav-link/index.js +3 -2
  153. package/dist/components/nav-link/tanstack.js +3 -2
  154. package/dist/components/nav-link/tanstack.js.map +1 -1
  155. package/dist/components/notification/index.js +4 -3
  156. package/dist/components/notification/index.js.map +1 -1
  157. package/dist/components/notification/notification.d.ts +3 -2
  158. package/dist/components/notification/notification.d.ts.map +1 -1
  159. package/dist/components/number-input/index.js +4 -4
  160. package/dist/components/overlays/index.js +5 -4
  161. package/dist/components/overlays/index.js.map +1 -1
  162. package/dist/components/password-input/index.js +2 -2
  163. package/dist/components/pill/index.js +2 -1
  164. package/dist/components/pill/pill.d.ts +4 -2
  165. package/dist/components/pill/pill.d.ts.map +1 -1
  166. package/dist/components/pills-input/index.js +5 -4
  167. package/dist/components/pills-input/pills-input.d.ts +3 -2
  168. package/dist/components/pills-input/pills-input.d.ts.map +1 -1
  169. package/dist/components/pin-input/index.js +2 -2
  170. package/dist/components/popover/index.js +1 -1
  171. package/dist/components/popover/popover.d.ts +3 -2
  172. package/dist/components/popover/popover.d.ts.map +1 -1
  173. package/dist/components/progress/index.js +1 -0
  174. package/dist/components/progress/index.js.map +1 -1
  175. package/dist/components/progress/progress.d.ts +3 -2
  176. package/dist/components/progress/progress.d.ts.map +1 -1
  177. package/dist/components/radio-group/index.js +1 -1
  178. package/dist/components/rating/index.js +2 -1
  179. package/dist/components/rating/index.js.map +1 -1
  180. package/dist/components/rating/rating.d.ts +3 -2
  181. package/dist/components/rating/rating.d.ts.map +1 -1
  182. package/dist/components/schedule/index.d.ts +2 -2
  183. package/dist/components/schedule/index.js +50 -23
  184. package/dist/components/schedule/index.js.map +1 -1
  185. package/dist/components/schedule/schedule-agenda-list.d.ts +6 -7
  186. package/dist/components/schedule/schedule-agenda-list.d.ts.map +1 -1
  187. package/dist/components/schedule/schedule-agenda-view.d.ts +19 -16
  188. package/dist/components/schedule/schedule-agenda-view.d.ts.map +1 -1
  189. package/dist/components/schedule/schedule-dates.d.ts.map +1 -1
  190. package/dist/components/schedule/schedule-days-view.d.ts +3 -2
  191. package/dist/components/schedule/schedule-days-view.d.ts.map +1 -1
  192. package/dist/components/schedule/schedule-month-view.d.ts +3 -2
  193. package/dist/components/schedule/schedule-month-view.d.ts.map +1 -1
  194. package/dist/components/schedule/schedule-next-up.d.ts +4 -3
  195. package/dist/components/schedule/schedule-next-up.d.ts.map +1 -1
  196. package/dist/components/schedule/schedule-toolbar.d.ts +1 -1
  197. package/dist/components/schedule/schedule-toolbar.d.ts.map +1 -1
  198. package/dist/components/schedule/schedule-types.d.ts +5 -3
  199. package/dist/components/schedule/schedule-types.d.ts.map +1 -1
  200. package/dist/components/schedule/schedule-views.d.ts +2 -2
  201. package/dist/components/schedule/schedule-views.d.ts.map +1 -1
  202. package/dist/components/schedule/schedule-year-view.d.ts +3 -2
  203. package/dist/components/schedule/schedule-year-view.d.ts.map +1 -1
  204. package/dist/components/schedule/schedule.d.ts +9 -6
  205. package/dist/components/schedule/schedule.d.ts.map +1 -1
  206. package/dist/components/segment-group/index.js +2 -2
  207. package/dist/components/select/index.js +4 -4
  208. package/dist/components/slider/index.js +2 -1
  209. package/dist/components/slider/index.js.map +1 -1
  210. package/dist/components/slider/slider.d.ts +3 -2
  211. package/dist/components/slider/slider.d.ts.map +1 -1
  212. package/dist/components/switch/index.js +1 -1
  213. package/dist/components/tabs/index.js +1 -1
  214. package/dist/components/tabs/tabs-data.d.ts +3 -2
  215. package/dist/components/tabs/tabs-data.d.ts.map +1 -1
  216. package/dist/components/tags-input/index.js +6 -5
  217. package/dist/components/tags-input/index.js.map +1 -1
  218. package/dist/components/text-input/index.js +2 -2
  219. package/dist/components/textarea/index.js +2 -2
  220. package/dist/components/time-input/index.js +6 -6
  221. package/dist/components/timeline/index.js +8 -5
  222. package/dist/components/timeline/index.js.map +1 -1
  223. package/dist/components/timeline/timeline.d.ts +1 -1
  224. package/dist/components/timeline/timeline.d.ts.map +1 -1
  225. package/dist/components/tooltip/index.js +1 -1
  226. package/dist/components/tooltip/tooltip.d.ts +2 -1
  227. package/dist/components/tooltip/tooltip.d.ts.map +1 -1
  228. package/dist/components/tree-multi-select/index.js +6 -5
  229. package/dist/components/tree-multi-select/index.js.map +1 -1
  230. package/dist/components/tree-select/index.js +3 -3
  231. package/dist/lib/as-child.d.ts +104 -0
  232. package/dist/lib/as-child.d.ts.map +1 -0
  233. package/package.json +1 -1
  234. package/src/as-child.contract.test.tsx +809 -0
  235. package/src/components/accordion/accordion-data.tsx +8 -5
  236. package/src/components/accordion/accordion.test.tsx +40 -0
  237. package/src/components/accordion/accordion.tsx +23 -6
  238. package/src/components/action-icon/action-icon.tsx +9 -24
  239. package/src/components/alert/alert.test.tsx +17 -0
  240. package/src/components/alert/alert.tsx +21 -2
  241. package/src/components/app-shell/app-shell.tsx +3 -1
  242. package/src/components/breadcrumb/breadcrumb.test.tsx +30 -0
  243. package/src/components/breadcrumb/breadcrumb.tsx +21 -12
  244. package/src/components/button/button.tsx +21 -50
  245. package/src/components/circular-progress/circular-progress.tsx +4 -1
  246. package/src/components/clipboard/clipboard.test.tsx +18 -0
  247. package/src/components/clipboard/clipboard.tsx +8 -2
  248. package/src/components/code-block/chrome.tsx +60 -36
  249. package/src/components/code-block/code-block.test.tsx +27 -0
  250. package/src/components/code-block/code-block.tsx +13 -3
  251. package/src/components/code-block/notation.test.ts +8 -0
  252. package/src/components/code-block/notation.ts +6 -3
  253. package/src/components/code-block/static.tsx +8 -2
  254. package/src/components/collapse/collapse.tsx +33 -15
  255. package/src/components/combobox/combobox.test.tsx +38 -0
  256. package/src/components/combobox/combobox.tsx +24 -10
  257. package/src/components/divider/divider.tsx +3 -1
  258. package/src/components/drawer/drawer.tsx +37 -16
  259. package/src/components/field/field.tsx +7 -3
  260. package/src/components/input/input.tsx +3 -1
  261. package/src/components/menu/menu-data.tsx +8 -1
  262. package/src/components/menu/menu.test.tsx +52 -0
  263. package/src/components/menu/menu.tsx +83 -35
  264. package/src/components/modal/close-trigger.test.tsx +38 -0
  265. package/src/components/modal/modal.tsx +29 -13
  266. package/src/components/notification/notification.tsx +4 -1
  267. package/src/components/pill/pill.tsx +29 -20
  268. package/src/components/pills-input/pills-input.tsx +3 -1
  269. package/src/components/popover/popover.tsx +3 -1
  270. package/src/components/progress/progress.tsx +4 -1
  271. package/src/components/rating/rating.tsx +27 -23
  272. package/src/components/schedule/index.ts +1 -1
  273. package/src/components/schedule/schedule-agenda-list.tsx +6 -7
  274. package/src/components/schedule/schedule-agenda-view.test.tsx +105 -28
  275. package/src/components/schedule/schedule-agenda-view.tsx +41 -28
  276. package/src/components/schedule/schedule-dates.test.ts +37 -52
  277. package/src/components/schedule/schedule-dates.ts +22 -25
  278. package/src/components/schedule/schedule-days-view.tsx +3 -1
  279. package/src/components/schedule/schedule-month-view.tsx +3 -1
  280. package/src/components/schedule/schedule-next-up.tsx +6 -2
  281. package/src/components/schedule/schedule-toolbar.test.tsx +26 -0
  282. package/src/components/schedule/schedule-toolbar.tsx +13 -1
  283. package/src/components/schedule/schedule-types.ts +5 -3
  284. package/src/components/schedule/schedule-views.ts +4 -5
  285. package/src/components/schedule/schedule-year-view.tsx +3 -1
  286. package/src/components/schedule/schedule.test.tsx +66 -22
  287. package/src/components/schedule/schedule.tsx +22 -13
  288. package/src/components/slider/slider.tsx +4 -0
  289. package/src/components/tabs/tabs-data.tsx +17 -14
  290. package/src/components/timeline/timeline.tsx +102 -95
  291. package/src/components/tooltip/tooltip.tsx +2 -1
  292. package/src/lib/as-child.test.tsx +70 -0
  293. package/src/lib/as-child.ts +119 -0
  294. package/dist/chunk-2762HZYX.js.map +0 -1
  295. package/dist/chunk-2H46IXW4.js.map +0 -1
  296. package/dist/chunk-6SWK4XG5.js.map +0 -1
  297. package/dist/chunk-EVVMHTCL.js.map +0 -1
  298. package/dist/chunk-HWNPXAEN.js +0 -31
  299. package/dist/chunk-HWNPXAEN.js.map +0 -1
  300. package/dist/chunk-IFWCCAQV.js.map +0 -1
  301. package/dist/chunk-IXKELBJA.js.map +0 -1
  302. package/dist/chunk-J3PELDH3.js.map +0 -1
  303. package/dist/chunk-NGAQITWP.js.map +0 -1
  304. package/dist/chunk-POKDSVQT.js.map +0 -1
  305. package/dist/chunk-QMW7D5GU.js.map +0 -1
  306. package/dist/chunk-TNNH3FVQ.js.map +0 -1
  307. package/dist/chunk-U5GW5EBR.js.map +0 -1
  308. package/dist/chunk-UNSAA7YG.js.map +0 -1
  309. package/dist/chunk-VLUKI3HL.js.map +0 -1
  310. package/dist/chunk-VZ2TPU4B.js.map +0 -1
  311. package/dist/chunk-YIQI2CF3.js.map +0 -1
@@ -1,6 +1,7 @@
1
1
  "use client"
2
2
 
3
3
  import type { ReactNode } from "react"
4
+ import type { ForbidAsChild } from "../../lib/as-child"
4
5
  import {
5
6
  type AccordionRootProps,
6
7
  Item,
@@ -46,14 +47,16 @@ export type AccordionData = ReadonlyArray<AccordionItem>
46
47
 
47
48
  export type AccordionProps<Data extends AccordionData = AccordionData> = Omit<
48
49
  AccordionRootProps,
49
- "children"
50
- > & {
51
- /** Sections, in order. Each needs its own `content`. */
52
- data: Data
53
- }
50
+ "children" | "asChild"
51
+ > &
52
+ ForbidAsChild & {
53
+ /** Sections, in order. Each needs its own `content`. */
54
+ data: Data
55
+ }
54
56
 
55
57
  const AccordionComponent = <const Data extends AccordionData>({
56
58
  data,
59
+ asChild: _asChild,
57
60
  ...root
58
61
  }: AccordionProps<Data>) => (
59
62
  <Root {...root}>
@@ -232,3 +232,43 @@ describe("Accordion", () => {
232
232
  expect(html).toContain("Section B")
233
233
  })
234
234
  })
235
+
236
+ describe("Accordion parts under asChild", () => {
237
+ it("ItemTrigger folds the chevron and label into the consumer's element", () => {
238
+ render(
239
+ <Accordion.Root>
240
+ <Accordion.Item value="a">
241
+ <Accordion.ItemTrigger asChild icon={<svg data-testid="icon" aria-hidden="true" />}>
242
+ <button type="button" data-testid="custom">
243
+ Section A
244
+ </button>
245
+ </Accordion.ItemTrigger>
246
+ </Accordion.Item>
247
+ </Accordion.Root>,
248
+ )
249
+ const trigger = screen.getByTestId("custom")
250
+ expect(trigger.getAttribute("aria-controls")).toBeTruthy()
251
+ expect(trigger.contains(screen.getByTestId("icon"))).toBe(true)
252
+ expect(trigger.querySelector('[data-part="item-indicator"]')).toBeTruthy()
253
+ expect(trigger.textContent).toContain("Section A")
254
+ })
255
+
256
+ it("ItemContent makes the consumer's element the panel, the clipped cell inside it", () => {
257
+ render(
258
+ <Accordion.Root defaultValue={["a"]}>
259
+ <Accordion.Item value="a">
260
+ <Accordion.ItemContent asChild>
261
+ <section data-testid="panel">A panel</section>
262
+ </Accordion.ItemContent>
263
+ </Accordion.Item>
264
+ </Accordion.Root>,
265
+ )
266
+ const panel = screen.getByTestId("panel")
267
+ expect(panel.getAttribute("role")).toBe("region")
268
+ expect(panel.getAttribute("data-state")).toBe("open")
269
+ expect(panel.className).toContain("grid-rows-[1fr]")
270
+ const cell = panel.firstElementChild
271
+ expect(cell?.className).toContain("overflow-clip")
272
+ expect(cell?.textContent).toBe("A panel")
273
+ })
274
+ })
@@ -3,6 +3,7 @@
3
3
  import { Accordion as Ark } from "@ark-ui/react/accordion"
4
4
  import { cva, type VariantProps } from "class-variance-authority"
5
5
  import { createContext, type ReactNode, useContext } from "react"
6
+ import { composeChildren } from "../../lib/as-child"
6
7
  import { cn } from "../../lib/cn"
7
8
  import { focusStyles } from "../../lib/focus-styles"
8
9
  import { props } from "../../lib/props"
@@ -257,7 +258,14 @@ export type AccordionItemTriggerProps = Ark.ItemTriggerProps &
257
258
  icon?: ReactNode
258
259
  }
259
260
 
260
- const ItemTrigger = ({ icon, children, className, testId, ...rest }: AccordionItemTriggerProps) => {
261
+ const ItemTrigger = ({
262
+ icon,
263
+ children,
264
+ className,
265
+ testId,
266
+ asChild,
267
+ ...rest
268
+ }: AccordionItemTriggerProps) => {
261
269
  const { size, chevronPosition, chevron, order } = useContext(AccordionStyleContext)
262
270
  const indicator =
263
271
  chevron === null ? null : <ItemIndicator>{chevron ?? <ChevronIcon />}</ItemIndicator>
@@ -265,14 +273,19 @@ const ItemTrigger = ({ icon, children, className, testId, ...rest }: AccordionIt
265
273
  return (
266
274
  <Title order={order} className="contents">
267
275
  <Ark.ItemTrigger
276
+ asChild={asChild}
268
277
  className={cn(accordionTrigger({ size }), className)}
269
278
  {...props({ "data-testid": testId })}
270
279
  {...rest}
271
280
  >
272
- {chevronPosition === "start" && indicator}
273
- {icon && <span className={accordionIcon}>{icon}</span>}
274
- <span className={accordionLabel}>{children}</span>
275
- {chevronPosition === "end" && indicator}
281
+ {composeChildren(asChild, children, (own) => (
282
+ <>
283
+ {chevronPosition === "start" && indicator}
284
+ {icon && <span className={accordionIcon}>{icon}</span>}
285
+ <span className={accordionLabel}>{own}</span>
286
+ {chevronPosition === "end" && indicator}
287
+ </>
288
+ ))}
276
289
  </Ark.ItemTrigger>
277
290
  </Title>
278
291
  )
@@ -308,6 +321,7 @@ const ItemContent = ({
308
321
  className,
309
322
  classNames,
310
323
  testId,
324
+ asChild,
311
325
  ...rest
312
326
  }: AccordionItemContentProps) => {
313
327
  const { size } = useContext(AccordionStyleContext)
@@ -322,8 +336,11 @@ const ItemContent = ({
322
336
  classNames={classNames}
323
337
  {...props({ "data-testid": testId })}
324
338
  {...rest}
339
+ asChild={asChild}
325
340
  >
326
- <div className={accordionContent({ size })}>{children}</div>
341
+ {composeChildren(asChild, children, (own) => (
342
+ <div className={accordionContent({ size })}>{own}</div>
343
+ ))}
327
344
  </Collapse>
328
345
  </Ark.ItemContent>
329
346
  )}
@@ -2,7 +2,8 @@
2
2
 
3
3
  import { ark, type HTMLArkProps } from "@ark-ui/react"
4
4
  import { cva, type VariantProps } from "class-variance-authority"
5
- import { cloneElement, isValidElement, type MouseEvent, type ReactNode } from "react"
5
+ import type { MouseEvent } from "react"
6
+ import { withAsChildContent } from "../../lib/as-child"
6
7
  import { cn } from "../../lib/cn"
7
8
  import type { Color } from "../../lib/colors"
8
9
  import { focusStyles } from "../../lib/focus-styles"
@@ -28,10 +29,9 @@ import { Spinner } from "../spinner/spinner"
28
29
  * icon children are decoration.
29
30
  *
30
31
  * `asChild` renders the single child with ActionIcon's styling. Ark's
31
- * factory uses `Children.only`, so only one element can survive the swap —
32
- * `loading`'s spinner replaces *that* element's own children (see
33
- * `withAsChildLoading` below) rather than the element itself, same trick as
34
- * `Button`'s `withAsChildContent`. The `onClick` guard (`preventWhileLoading`)
32
+ * factory clones exactly one element, so `loading`'s spinner replaces
33
+ * *that* element's own children (`withAsChildContent`, `lib/as-child.ts`)
34
+ * rather than the element itself. The `onClick` guard (`preventWhileLoading`)
35
35
  * goes on the same clone, since `disabled` doesn't do anything on an
36
36
  * arbitrary `asChild` element (e.g. an `<a>`) — same reason the `opacity-50`
37
37
  * dimming and `pointer-events-none` blocking are keyed off `data-loading`
@@ -118,23 +118,6 @@ const preventWhileLoading = (event: MouseEvent) => {
118
118
  event.stopPropagation()
119
119
  }
120
120
 
121
- /**
122
- * Replaces the single `asChild` child's own children with the spinner and
123
- * guards its `onClick`, mirroring `Button`'s `withAsChildContent`. Falls
124
- * through unchanged when not loading or the child isn't a single element,
125
- * letting Ark's own `Children.only` handle the misuse case as it already
126
- * does.
127
- */
128
- const withAsChildLoading = (child: ReactNode, loading: boolean) => {
129
- if (!loading) return child
130
- if (!isValidElement<{ children?: ReactNode; onClick?: (event: MouseEvent) => void }>(child))
131
- return child
132
- return cloneElement(child, {
133
- onClick: preventWhileLoading,
134
- children: <Spinner label={null} />,
135
- })
136
- }
137
-
138
121
  export const ActionIcon = ({
139
122
  className,
140
123
  variant,
@@ -168,8 +151,10 @@ export const ActionIcon = ({
168
151
  {...props({ "data-testid": testId })}
169
152
  {...rest}
170
153
  >
171
- {asChild ? (
172
- withAsChildLoading(children, loading)
154
+ {asChild && loading ? (
155
+ withAsChildContent(children, () => <Spinner label={null} />, {
156
+ onClick: preventWhileLoading,
157
+ })
173
158
  ) : loading ? (
174
159
  <Spinner label={null} />
175
160
  ) : (
@@ -129,3 +129,20 @@ describe("Alert", () => {
129
129
  expect(classes).toContain("focus:outline-none")
130
130
  })
131
131
  })
132
+
133
+ describe("Alert as a link", () => {
134
+ it("renders the card inside the consumer's link under asChild", () => {
135
+ const html = renderToStaticMarkup(
136
+ <Alert asChild type="info" title="New version available" description="See what changed">
137
+ {/* biome-ignore lint/a11y/useAnchorContent: the card is what fills the empty link */}
138
+ <a href="/changelog" />
139
+ </Alert>,
140
+ )
141
+ // The link is the root: it opens the markup and carries the card's palette.
142
+ expect(html).toMatch(/^<a href="\/changelog"[^>]* data-color="/)
143
+ expect(html).toContain("New version available")
144
+ expect(html).toContain("See what changed")
145
+ expect(html).toContain("<svg")
146
+ expect(html.endsWith("</a>")).toBe(true)
147
+ })
148
+ })
@@ -3,6 +3,7 @@
3
3
  import { ark, type HTMLArkProps } from "@ark-ui/react"
4
4
  import { cva } from "class-variance-authority"
5
5
  import type { ReactNode, Ref } from "react"
6
+ import { withAsChildContent } from "../../lib/as-child"
6
7
  import { cn } from "../../lib/cn"
7
8
  import type { Color } from "../../lib/colors"
8
9
  import { focusStyles } from "../../lib/focus-styles"
@@ -120,6 +121,8 @@ function AlertComponent({
120
121
  icon: _icon,
121
122
  withCloseButton = false,
122
123
  onClose,
124
+ asChild,
125
+ children,
123
126
  ...rest
124
127
  }: AlertProps) {
125
128
  const preset = type ? TOAST_STATUS[type] : undefined
@@ -130,8 +133,8 @@ function AlertComponent({
130
133
  // through to the preset the way an omitted (`undefined`) icon does.
131
134
  const icon = _icon === undefined ? preset?.icon : _icon
132
135
 
133
- return (
134
- <Root color={color} {...rest}>
136
+ const card = (
137
+ <>
135
138
  <div className="flex flex-row gap-3">
136
139
  {icon != null && <Icon>{icon}</Icon>}
137
140
  {title != null ? (
@@ -146,6 +149,22 @@ function AlertComponent({
146
149
  </div>
147
150
  {title != null && description != null && <Description>{description}</Description>}
148
151
  {action != null && <div className="mt-2 flex flex-wrap items-center gap-2">{action}</div>}
152
+ </>
153
+ )
154
+
155
+ return (
156
+ // Under `asChild` the card becomes the consumer's element (a link to the
157
+ // details, say), with the card's rows folded in ahead of that element's
158
+ // own content.
159
+ <Root color={color} asChild={asChild} {...rest}>
160
+ {asChild
161
+ ? withAsChildContent(children, (own) => (
162
+ <>
163
+ {card}
164
+ {own}
165
+ </>
166
+ ))
167
+ : card}
149
168
  </Root>
150
169
  )
151
170
  }
@@ -11,6 +11,7 @@ import {
11
11
  useRef,
12
12
  useState,
13
13
  } from "react"
14
+ import type { NoAsChild } from "../../lib/as-child"
14
15
  import { cn } from "../../lib/cn"
15
16
  import { mergeRefs } from "../../lib/merge-refs"
16
17
  import { props } from "../../lib/props"
@@ -124,7 +125,7 @@ const SIDEBAR_WIDTH: Record<Size, string> = {
124
125
  xl: "w-96",
125
126
  }
126
127
 
127
- export type AppShellSidebarProps = HTMLArkProps<"aside"> &
128
+ export type AppShellSidebarProps = NoAsChild<HTMLArkProps<"aside">> &
128
129
  WithTestId & {
129
130
  /** Width when expanded, from the kit's Size scale. @default "md" */
130
131
  size?: Size
@@ -163,6 +164,7 @@ const AppShellSidebar = ({
163
164
  className,
164
165
  children,
165
166
  testId,
167
+ asChild: _asChild,
166
168
  ...rest
167
169
  }: AppShellSidebarProps) => {
168
170
  const { isMobile, mobileOpen, setMobileOpen } = useAppShell()
@@ -80,6 +80,36 @@ describe("Breadcrumb", () => {
80
80
  expect(container.querySelector("svg")).toBeTruthy()
81
81
  })
82
82
 
83
+ // #280 — a router link with no children of its own rendered empty.
84
+ it("puts the house icon inside an empty asChild link", () => {
85
+ render(
86
+ <Breadcrumb.Root>
87
+ <Breadcrumb.Home asChild>
88
+ {/* biome-ignore lint/a11y/useAnchorContent: the house icon is what fills the empty link */}
89
+ <a href="/" data-router-link="" />
90
+ </Breadcrumb.Home>
91
+ </Breadcrumb.Root>,
92
+ )
93
+ const home = screen.getByRole("link", { name: "Home" })
94
+ expect(home.hasAttribute("data-router-link")).toBe(true)
95
+ expect(home.querySelector("svg")).toBeTruthy()
96
+ })
97
+
98
+ it("keeps an asChild link's own content instead of the house icon", () => {
99
+ render(
100
+ <Breadcrumb.Root>
101
+ <Breadcrumb.Home asChild>
102
+ <a href="/">
103
+ <span data-testid="logo" />
104
+ </a>
105
+ </Breadcrumb.Home>
106
+ </Breadcrumb.Root>,
107
+ )
108
+ const home = screen.getByRole("link", { name: "Home" })
109
+ expect(home.contains(screen.getByTestId("logo"))).toBe(true)
110
+ expect(home.querySelector("svg")).toBeNull()
111
+ })
112
+
83
113
  it("forwards asChild on Breadcrumb.Item onto a custom child instead of rendering its own <a>", () => {
84
114
  render(
85
115
  <Breadcrumb.Root>
@@ -2,6 +2,7 @@ import { ark, type HTMLArkProps } from "@ark-ui/react"
2
2
  import { House } from "lucide-react"
3
3
  import type { ElementType, ReactElement, ReactNode } from "react"
4
4
  import { Children, cloneElement, isValidElement } from "react"
5
+ import { type ForbidAsChild, withAsChildContent } from "../../lib/as-child"
5
6
  import { cn } from "../../lib/cn"
6
7
  import { props } from "../../lib/props"
7
8
  import type { WithTestId } from "../../lib/test-id"
@@ -244,7 +245,9 @@ const BreadcrumbHome = ({
244
245
  testId,
245
246
  ...rest
246
247
  }: BreadcrumbHomeProps) => {
247
- const icon = children ?? <House aria-hidden size={16} />
248
+ // Under `asChild`, `children` is the consumer's link, so the house goes
249
+ // inside it whenever that link brings no content of its own.
250
+ const icon = (own: ReactNode) => own ?? <House aria-hidden size={16} />
248
251
  if (asChild) {
249
252
  return (
250
253
  <li className="shrink-0">
@@ -255,7 +258,7 @@ const BreadcrumbHome = ({
255
258
  {...props({ "data-testid": testId })}
256
259
  {...rest}
257
260
  >
258
- {icon}
261
+ {withAsChildContent(children, icon)}
259
262
  </ark.a>
260
263
  </li>
261
264
  )
@@ -270,7 +273,7 @@ const BreadcrumbHome = ({
270
273
  {...props({ "data-testid": testId })}
271
274
  {...rest}
272
275
  >
273
- {icon}
276
+ {icon(children)}
274
277
  </LinkComponent>
275
278
  </li>
276
279
  )
@@ -284,7 +287,7 @@ const BreadcrumbHome = ({
284
287
  {...props({ "data-testid": testId })}
285
288
  {...rest}
286
289
  >
287
- {icon}
290
+ {icon(children)}
288
291
  </ark.a>
289
292
  </li>
290
293
  )
@@ -301,13 +304,14 @@ export type BreadcrumbDataItem = {
301
304
  testId?: string
302
305
  }
303
306
 
304
- export type BreadcrumbProps = Omit<BreadcrumbRootProps, "children"> & {
305
- /** The crumbs to render, in order. */
306
- data: readonly BreadcrumbDataItem[]
307
- /** Renders a leading icon-only `Breadcrumb.Home`. `true` uses the default
308
- * house icon with no link; pass an object (with `href`) to link it. */
309
- withHome?: boolean | (BreadcrumbHomeProps & { href: string })
310
- }
307
+ export type BreadcrumbProps = Omit<BreadcrumbRootProps, "children" | "asChild"> &
308
+ ForbidAsChild & {
309
+ /** The crumbs to render, in order. */
310
+ data: readonly BreadcrumbDataItem[]
311
+ /** Renders a leading icon-only `Breadcrumb.Home`. `true` uses the default
312
+ * house icon with no link; pass an object (with `href`) to link it. */
313
+ withHome?: boolean | (BreadcrumbHomeProps & { href: string })
314
+ }
311
315
 
312
316
  /** Renders one `data` entry to a `Breadcrumb.Item` — factored out so its
313
317
  * `key` (built from position) isn't a bare index inline in a `.map` JSX
@@ -324,7 +328,12 @@ const renderDataItem = (item: BreadcrumbDataItem, key: string, current: boolean)
324
328
  </BreadcrumbItem>
325
329
  )
326
330
 
327
- const BreadcrumbComponent = ({ data, withHome, ...rootProps }: BreadcrumbProps) => {
331
+ const BreadcrumbComponent = ({
332
+ data,
333
+ withHome,
334
+ asChild: _asChild,
335
+ ...rootProps
336
+ }: BreadcrumbProps) => {
328
337
  const explicitCurrent = data.some((item) => item.current !== undefined)
329
338
 
330
339
  return (
@@ -2,7 +2,8 @@
2
2
 
3
3
  import { ark, type HTMLArkProps } from "@ark-ui/react"
4
4
  import { cva, type VariantProps } from "class-variance-authority"
5
- import { cloneElement, isValidElement, type MouseEvent, type ReactNode } from "react"
5
+ import type { MouseEvent, ReactNode } from "react"
6
+ import { withAsChildContent } from "../../lib/as-child"
6
7
  import { cn } from "../../lib/cn"
7
8
  import type { Color } from "../../lib/colors"
8
9
  import { focusStyles } from "../../lib/focus-styles"
@@ -28,10 +29,10 @@ import { Spinner } from "../spinner/spinner"
28
29
  * required.
29
30
  *
30
31
  * `asChild` (inherited from `HTMLArkProps`) renders the single child element
31
- * with Button's styling merged in. Ark's factory uses `Children.only`, so
32
- * only one element can survive the swap — `startSlot`/`endSlot` (and the
32
+ * with Button's styling merged in. Ark's factory clones exactly one element,
33
+ * so only one element can survive the swap — `startSlot`/`endSlot` (and the
33
34
  * `loading` spinner, which replaces `startSlot`) are folded into *that*
34
- * element's own children (see `withAsChildContent` below) rather than
35
+ * element's own children (`withAsChildContent`, `lib/as-child.ts`) rather than
35
36
  * rendered as siblings, so they keep showing up even when the child is a
36
37
  * link. Common case: `<Button asChild startSlot={<Icon />}><a ...>Go</a></Button>`.
37
38
  *
@@ -165,39 +166,6 @@ const preventWhileLoading = (event: MouseEvent) => {
165
166
  event.stopPropagation()
166
167
  }
167
168
 
168
- /**
169
- * Ark's `asChild` clones the single child element in place of `ark.button`,
170
- * so the start/end content (icon or spinner) can't be rendered as siblings
171
- * of `children` (that would hand `Children.only` a `Fragment` and lose
172
- * Button's own props in the clone). Instead, fold them into the child's own
173
- * children — same trick as `Breadcrumb.Home`. Falls through unchanged when
174
- * there's nothing to add or the child isn't a single element, letting Ark's
175
- * own `Children.only` handle the misuse case as it already does.
176
- */
177
- const withAsChildContent = (
178
- child: ReactNode,
179
- startContent: ReactNode,
180
- endContent: ReactNode,
181
- size: VariantProps<typeof buttonVariants>["size"],
182
- loading: boolean,
183
- ) => {
184
- if (!startContent && !endContent && !loading) return child
185
- if (!isValidElement<{ children?: ReactNode; onClick?: (event: MouseEvent) => void }>(child))
186
- return child
187
- return cloneElement(child, {
188
- onClick: loading ? preventWhileLoading : child.props.onClick,
189
- children: (
190
- <>
191
- {startContent && (
192
- <HiddenSlot className={startSlotVariants({ size })}>{startContent}</HiddenSlot>
193
- )}
194
- {child.props.children}
195
- {endContent && <HiddenSlot className={endSlotVariants({ size })}>{endContent}</HiddenSlot>}
196
- </>
197
- ),
198
- })
199
- }
200
-
201
169
  export const Button = ({
202
170
  className,
203
171
  variant,
@@ -218,6 +186,15 @@ export const Button = ({
218
186
  const startContent = loading ? <Spinner label={null} /> : startSlot
219
187
  const endContent = loading ? null : endSlot
220
188
  const resolvedOnClick = loading ? preventWhileLoading : onClick
189
+ const content = (own: ReactNode) => (
190
+ <>
191
+ {startContent && (
192
+ <HiddenSlot className={startSlotVariants({ size })}>{startContent}</HiddenSlot>
193
+ )}
194
+ {own}
195
+ {endContent && <HiddenSlot className={endSlotVariants({ size })}>{endContent}</HiddenSlot>}
196
+ </>
197
+ )
221
198
 
222
199
  return (
223
200
  <ark.button
@@ -235,19 +212,13 @@ export const Button = ({
235
212
  {...props({ "data-testid": testId })}
236
213
  {...rest}
237
214
  >
238
- {asChild ? (
239
- withAsChildContent(children, startContent, endContent, size, loading)
240
- ) : (
241
- <>
242
- {startContent && (
243
- <HiddenSlot className={startSlotVariants({ size })}>{startContent}</HiddenSlot>
244
- )}
245
- {children}
246
- {endContent && (
247
- <HiddenSlot className={endSlotVariants({ size })}>{endContent}</HiddenSlot>
248
- )}
249
- </>
250
- )}
215
+ {asChild
216
+ ? withAsChildContent(
217
+ children,
218
+ content,
219
+ loading ? { onClick: preventWhileLoading } : undefined,
220
+ )
221
+ : content(children)}
251
222
  </ark.button>
252
223
  )
253
224
  }
@@ -7,6 +7,7 @@ import {
7
7
  type Ref,
8
8
  useId,
9
9
  } from "react"
10
+ import type { ForbidAsChild } from "../../lib/as-child"
10
11
  import { cn } from "../../lib/cn"
11
12
  import type { Color } from "../../lib/colors"
12
13
  import type { GradientDir, GradientProps } from "../../lib/gradient"
@@ -93,8 +94,9 @@ type ArkRootProps = ComponentPropsWithoutRef<typeof Ark.Root>
93
94
 
94
95
  export type CircularProgressProps = Omit<
95
96
  ArkRootProps,
96
- "value" | "defaultValue" | "onValueChange" | "ref" | "className" | "children"
97
+ "value" | "defaultValue" | "onValueChange" | "ref" | "className" | "children" | "asChild"
97
98
  > &
99
+ ForbidAsChild &
98
100
  VariantProps<typeof circularRange> &
99
101
  WithTestId & {
100
102
  /** Controlled value (0..max). Pass `null` for the indeterminate state. */
@@ -140,6 +142,7 @@ export const CircularProgress = ({
140
142
  classNames,
141
143
  style,
142
144
  testId,
145
+ asChild: _asChild,
143
146
  ...rest
144
147
  }: CircularProgressProps) => {
145
148
  const isGradient = variant === "gradient"
@@ -227,3 +227,21 @@ describe("Clipboard", () => {
227
227
  })
228
228
  })
229
229
  })
230
+
231
+ describe("Clipboard.Input under asChild", () => {
232
+ // `children` doubled as the trailing slot, so the consumer's input landed
233
+ // beside an Ark input that had nothing to clone, and rendered unwired.
234
+ it("wires the consumer's own input as the read-only value field", () => {
235
+ render(
236
+ <Clipboard.Root value="https://example.com/s/abc">
237
+ <Clipboard.Input asChild>
238
+ <input data-testid="custom" />
239
+ </Clipboard.Input>
240
+ </Clipboard.Root>,
241
+ )
242
+ const input = screen.getByTestId("custom") as HTMLInputElement
243
+ expect(screen.getAllByRole("textbox")).toHaveLength(1)
244
+ expect(input.value).toBe("https://example.com/s/abc")
245
+ expect(input.readOnly).toBe(true)
246
+ })
247
+ })
@@ -95,15 +95,21 @@ const Input = ({
95
95
  classNames,
96
96
  children,
97
97
  testId,
98
+ asChild,
98
99
  ...rest
99
100
  }: ClipboardInputProps) => (
100
101
  <InputBase variant={variant} size={size} readOnly className={cn(className, classNames?.root)}>
102
+ {/* `children` is the trailing slot (usually the copy trigger), except under
103
+ `asChild`, where the single child is the input element itself. */}
101
104
  <Ark.Input
105
+ asChild={asChild}
102
106
  className={cn(inputControlClasses, classNames?.input)}
103
107
  {...props({ "data-testid": testId })}
104
108
  {...rest}
105
- />
106
- {children}
109
+ >
110
+ {asChild ? children : undefined}
111
+ </Ark.Input>
112
+ {!asChild && children}
107
113
  </InputBase>
108
114
  )
109
115