@42-central/ui-react 0.17.1 → 0.18.1

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 (345) hide show
  1. package/biome/no-gray-color.grit +18 -0
  2. package/dist/{chunk-FD6P6PLQ.js → chunk-5JHDSVEZ.js} +3 -3
  3. package/dist/{chunk-FD6P6PLQ.js.map → chunk-5JHDSVEZ.js.map} +1 -1
  4. package/dist/{chunk-QMW7D5GU.js → chunk-5OQLFX47.js} +4 -3
  5. package/dist/chunk-5OQLFX47.js.map +1 -0
  6. package/dist/{chunk-VZ2TPU4B.js → chunk-6GDMSENK.js} +3 -2
  7. package/dist/chunk-6GDMSENK.js.map +1 -0
  8. package/dist/{chunk-TNNH3FVQ.js → chunk-6OLTJYSX.js} +24 -8
  9. package/dist/chunk-6OLTJYSX.js.map +1 -0
  10. package/dist/{chunk-POKDSVQT.js → chunk-AE7QTLJ5.js} +5 -4
  11. package/dist/chunk-AE7QTLJ5.js.map +1 -0
  12. package/dist/{chunk-44OV3PNH.js → chunk-B2YJKRNQ.js} +3 -3
  13. package/dist/{chunk-44OV3PNH.js.map → chunk-B2YJKRNQ.js.map} +1 -1
  14. package/dist/{chunk-YIQI2CF3.js → chunk-CTSO6V72.js} +3 -2
  15. package/dist/chunk-CTSO6V72.js.map +1 -0
  16. package/dist/{chunk-EVVMHTCL.js → chunk-EBREIC3L.js} +4 -3
  17. package/dist/chunk-EBREIC3L.js.map +1 -0
  18. package/dist/{chunk-UNSAA7YG.js → chunk-FHG54IT5.js} +3 -2
  19. package/dist/chunk-FHG54IT5.js.map +1 -0
  20. package/dist/{chunk-3GYOIQW7.js → chunk-FZIHZT5R.js} +5 -5
  21. package/dist/{chunk-3GYOIQW7.js.map → chunk-FZIHZT5R.js.map} +1 -1
  22. package/dist/{chunk-2H46IXW4.js → chunk-HAQJQFE6.js} +28 -8
  23. package/dist/chunk-HAQJQFE6.js.map +1 -0
  24. package/dist/{chunk-IHYFYMHJ.js → chunk-HT5JAHR3.js} +6 -6
  25. package/dist/{chunk-IHYFYMHJ.js.map → chunk-HT5JAHR3.js.map} +1 -1
  26. package/dist/chunk-I4SQQIP5.js +12 -0
  27. package/dist/chunk-I4SQQIP5.js.map +1 -0
  28. package/dist/{chunk-J3PELDH3.js → chunk-JITF6I7N.js} +22 -6
  29. package/dist/chunk-JITF6I7N.js.map +1 -0
  30. package/dist/{chunk-IFWCCAQV.js → chunk-KHMFNH3X.js} +3 -2
  31. package/dist/chunk-KHMFNH3X.js.map +1 -0
  32. package/dist/{chunk-SIG4DMNZ.js → chunk-MI2WZRK3.js} +4 -4
  33. package/dist/{chunk-SIG4DMNZ.js.map → chunk-MI2WZRK3.js.map} +1 -1
  34. package/dist/{chunk-YON5Y336.js → chunk-O23Y5ML4.js} +8 -8
  35. package/dist/{chunk-YON5Y336.js.map → chunk-O23Y5ML4.js.map} +1 -1
  36. package/dist/{chunk-P7A3BCAC.js → chunk-OWG4BCQR.js} +3 -3
  37. package/dist/{chunk-P7A3BCAC.js.map → chunk-OWG4BCQR.js.map} +1 -1
  38. package/dist/{chunk-FUWSTUDM.js → chunk-PH354ECN.js} +4 -4
  39. package/dist/{chunk-FUWSTUDM.js.map → chunk-PH354ECN.js.map} +1 -1
  40. package/dist/{chunk-U5GW5EBR.js → chunk-RAUOFTUH.js} +12 -20
  41. package/dist/chunk-RAUOFTUH.js.map +1 -0
  42. package/dist/{chunk-6I4R3HR6.js → chunk-RQL7FVCS.js} +3 -3
  43. package/dist/{chunk-6I4R3HR6.js.map → chunk-RQL7FVCS.js.map} +1 -1
  44. package/dist/{chunk-2762HZYX.js → chunk-S2HWWR2H.js} +47 -25
  45. package/dist/chunk-S2HWWR2H.js.map +1 -0
  46. package/dist/{chunk-VLUKI3HL.js → chunk-S7N4LGLZ.js} +6 -13
  47. package/dist/chunk-S7N4LGLZ.js.map +1 -0
  48. package/dist/{chunk-NSOA3GMZ.js → chunk-UHNRAI6V.js} +3 -3
  49. package/dist/{chunk-NSOA3GMZ.js.map → chunk-UHNRAI6V.js.map} +1 -1
  50. package/dist/{chunk-JBVFWSRQ.js → chunk-VIYVN4WF.js} +6 -4
  51. package/dist/chunk-VIYVN4WF.js.map +1 -0
  52. package/dist/{chunk-3NZXWCGF.js → chunk-WHKKN3ZK.js} +6 -6
  53. package/dist/{chunk-3NZXWCGF.js.map → chunk-WHKKN3ZK.js.map} +1 -1
  54. package/dist/{chunk-MOI7B3KH.js → chunk-WQN64ZHG.js} +5 -5
  55. package/dist/{chunk-MOI7B3KH.js.map → chunk-WQN64ZHG.js.map} +1 -1
  56. package/dist/chunk-WSIVRDRB.js +34 -0
  57. package/dist/chunk-WSIVRDRB.js.map +1 -0
  58. package/dist/{chunk-S53FHWNG.js → chunk-YWRBG23W.js} +3 -3
  59. package/dist/chunk-YWRBG23W.js.map +1 -0
  60. package/dist/{chunk-6SWK4XG5.js → chunk-YXE4B6X3.js} +2 -2
  61. package/dist/chunk-YXE4B6X3.js.map +1 -0
  62. package/dist/{chunk-NGAQITWP.js → chunk-Z2Z5EXVT.js} +10 -7
  63. package/dist/chunk-Z2Z5EXVT.js.map +1 -0
  64. package/dist/{chunk-IXKELBJA.js → chunk-ZDXQ64A7.js} +63 -44
  65. package/dist/chunk-ZDXQ64A7.js.map +1 -0
  66. package/dist/colors.css +12 -26
  67. package/dist/components/accordion/accordion-data.d.ts +3 -2
  68. package/dist/components/accordion/accordion-data.d.ts.map +1 -1
  69. package/dist/components/accordion/accordion.d.ts +2 -2
  70. package/dist/components/accordion/accordion.d.ts.map +1 -1
  71. package/dist/components/accordion/index.js +20 -8
  72. package/dist/components/accordion/index.js.map +1 -1
  73. package/dist/components/action-icon/action-icon.d.ts +3 -4
  74. package/dist/components/action-icon/action-icon.d.ts.map +1 -1
  75. package/dist/components/action-icon/index.js +2 -1
  76. package/dist/components/alert/alert.d.ts +1 -1
  77. package/dist/components/alert/alert.d.ts.map +1 -1
  78. package/dist/components/alert/index.js +16 -4
  79. package/dist/components/alert/index.js.map +1 -1
  80. package/dist/components/app-shell/app-shell.d.ts +3 -2
  81. package/dist/components/app-shell/app-shell.d.ts.map +1 -1
  82. package/dist/components/app-shell/index.js +4 -2
  83. package/dist/components/app-shell/index.js.map +1 -1
  84. package/dist/components/autocomplete/index.js +5 -4
  85. package/dist/components/autocomplete/index.js.map +1 -1
  86. package/dist/components/avatar/avatar.d.ts +3 -3
  87. package/dist/components/avatar/index.js.map +1 -1
  88. package/dist/components/breadcrumb/breadcrumb.d.ts +3 -2
  89. package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -1
  90. package/dist/components/breadcrumb/index.js +11 -5
  91. package/dist/components/breadcrumb/index.js.map +1 -1
  92. package/dist/components/button/button.d.ts +4 -4
  93. package/dist/components/button/button.d.ts.map +1 -1
  94. package/dist/components/button/index.js +2 -1
  95. package/dist/components/button-multi-select/index.js +4 -3
  96. package/dist/components/button-multi-select/index.js.map +1 -1
  97. package/dist/components/button-select/index.js +4 -3
  98. package/dist/components/button-select/index.js.map +1 -1
  99. package/dist/components/calendar/index.js +3 -2
  100. package/dist/components/chart/chart.d.ts +1 -1
  101. package/dist/components/chart/index.js +1 -1
  102. package/dist/components/chart/index.js.map +1 -1
  103. package/dist/components/checkbox/index.js +2 -2
  104. package/dist/components/choice-card-group/index.js +1 -1
  105. package/dist/components/circular-progress/circular-progress.d.ts +3 -2
  106. package/dist/components/circular-progress/circular-progress.d.ts.map +1 -1
  107. package/dist/components/circular-progress/index.js +1 -0
  108. package/dist/components/circular-progress/index.js.map +1 -1
  109. package/dist/components/clipboard/clipboard.d.ts +1 -1
  110. package/dist/components/clipboard/clipboard.d.ts.map +1 -1
  111. package/dist/components/clipboard/index.js +9 -5
  112. package/dist/components/clipboard/index.js.map +1 -1
  113. package/dist/components/code/index.js +1 -1
  114. package/dist/components/code-block/chrome.d.ts +4 -1
  115. package/dist/components/code-block/chrome.d.ts.map +1 -1
  116. package/dist/components/code-block/chrome.js +5 -4
  117. package/dist/components/code-block/code-block.d.ts +7 -1
  118. package/dist/components/code-block/code-block.d.ts.map +1 -1
  119. package/dist/components/code-block/index.d.ts +1 -1
  120. package/dist/components/code-block/index.js +12 -10
  121. package/dist/components/code-block/index.js.map +1 -1
  122. package/dist/components/code-block/notation.d.ts +5 -2
  123. package/dist/components/code-block/notation.d.ts.map +1 -1
  124. package/dist/components/code-block/static.d.ts +4 -1
  125. package/dist/components/code-block/static.d.ts.map +1 -1
  126. package/dist/components/code-block/static.js +5 -4
  127. package/dist/components/code-block/static.js.map +1 -1
  128. package/dist/components/collapse/collapse.d.ts +7 -3
  129. package/dist/components/collapse/collapse.d.ts.map +1 -1
  130. package/dist/components/collapse/index.js +2 -1
  131. package/dist/components/combobox/combobox.d.ts +11 -10
  132. package/dist/components/combobox/combobox.d.ts.map +1 -1
  133. package/dist/components/combobox/index.js +5 -4
  134. package/dist/components/combobox-list/index.js +6 -5
  135. package/dist/components/data-table/index.js +21 -20
  136. package/dist/components/data-table/index.js.map +1 -1
  137. package/dist/components/date-picker/index.js +12 -11
  138. package/dist/components/date-picker/index.js.map +1 -1
  139. package/dist/components/divider/divider.d.ts +3 -2
  140. package/dist/components/divider/divider.d.ts.map +1 -1
  141. package/dist/components/divider/index.js +1 -1
  142. package/dist/components/drawer/drawer.d.ts +6 -5
  143. package/dist/components/drawer/drawer.d.ts.map +1 -1
  144. package/dist/components/drawer/index.js +3 -2
  145. package/dist/components/field/field.d.ts +7 -4
  146. package/dist/components/field/field.d.ts.map +1 -1
  147. package/dist/components/field/index.js +1 -1
  148. package/dist/components/file-upload/index.js +3 -2
  149. package/dist/components/file-upload/index.js.map +1 -1
  150. package/dist/components/hover-card/index.js +1 -1
  151. package/dist/components/input/index.js +2 -2
  152. package/dist/components/input/input.d.ts +3 -2
  153. package/dist/components/input/input.d.ts.map +1 -1
  154. package/dist/components/mark/index.js +1 -1
  155. package/dist/components/mark/mark.d.ts +2 -2
  156. package/dist/components/menu/index.js +3 -2
  157. package/dist/components/menu/index.js.map +1 -1
  158. package/dist/components/menu/menu-data.d.ts +6 -1
  159. package/dist/components/menu/menu-data.d.ts.map +1 -1
  160. package/dist/components/menu/menu.d.ts +5 -5
  161. package/dist/components/menu/menu.d.ts.map +1 -1
  162. package/dist/components/modal/index.js +3 -2
  163. package/dist/components/modal/modal.d.ts +4 -3
  164. package/dist/components/modal/modal.d.ts.map +1 -1
  165. package/dist/components/multi-combobox-list/index.js +6 -5
  166. package/dist/components/multi-select/index.js +7 -6
  167. package/dist/components/multi-select/index.js.map +1 -1
  168. package/dist/components/nav-link/index.js +3 -2
  169. package/dist/components/nav-link/tanstack.js +3 -2
  170. package/dist/components/nav-link/tanstack.js.map +1 -1
  171. package/dist/components/notification/index.js +4 -3
  172. package/dist/components/notification/index.js.map +1 -1
  173. package/dist/components/notification/notification.d.ts +3 -2
  174. package/dist/components/notification/notification.d.ts.map +1 -1
  175. package/dist/components/number-input/index.js +4 -4
  176. package/dist/components/overlays/index.js +5 -4
  177. package/dist/components/overlays/index.js.map +1 -1
  178. package/dist/components/password-input/index.js +2 -2
  179. package/dist/components/pill/index.js +2 -1
  180. package/dist/components/pill/pill.d.ts +4 -2
  181. package/dist/components/pill/pill.d.ts.map +1 -1
  182. package/dist/components/pills-input/index.js +5 -4
  183. package/dist/components/pills-input/pills-input.d.ts +3 -2
  184. package/dist/components/pills-input/pills-input.d.ts.map +1 -1
  185. package/dist/components/pin-input/index.js +2 -2
  186. package/dist/components/popover/index.js +1 -1
  187. package/dist/components/popover/popover.d.ts +3 -2
  188. package/dist/components/popover/popover.d.ts.map +1 -1
  189. package/dist/components/progress/index.js +1 -0
  190. package/dist/components/progress/index.js.map +1 -1
  191. package/dist/components/progress/progress.d.ts +3 -2
  192. package/dist/components/progress/progress.d.ts.map +1 -1
  193. package/dist/components/radio-group/index.js +1 -1
  194. package/dist/components/rating/index.js +2 -1
  195. package/dist/components/rating/index.js.map +1 -1
  196. package/dist/components/rating/rating.d.ts +3 -2
  197. package/dist/components/rating/rating.d.ts.map +1 -1
  198. package/dist/components/schedule/index.d.ts +2 -2
  199. package/dist/components/schedule/index.js +50 -23
  200. package/dist/components/schedule/index.js.map +1 -1
  201. package/dist/components/schedule/schedule-agenda-list.d.ts +6 -7
  202. package/dist/components/schedule/schedule-agenda-list.d.ts.map +1 -1
  203. package/dist/components/schedule/schedule-agenda-view.d.ts +19 -16
  204. package/dist/components/schedule/schedule-agenda-view.d.ts.map +1 -1
  205. package/dist/components/schedule/schedule-dates.d.ts.map +1 -1
  206. package/dist/components/schedule/schedule-days-view.d.ts +3 -2
  207. package/dist/components/schedule/schedule-days-view.d.ts.map +1 -1
  208. package/dist/components/schedule/schedule-month-view.d.ts +3 -2
  209. package/dist/components/schedule/schedule-month-view.d.ts.map +1 -1
  210. package/dist/components/schedule/schedule-next-up.d.ts +4 -3
  211. package/dist/components/schedule/schedule-next-up.d.ts.map +1 -1
  212. package/dist/components/schedule/schedule-toolbar.d.ts +1 -1
  213. package/dist/components/schedule/schedule-toolbar.d.ts.map +1 -1
  214. package/dist/components/schedule/schedule-types.d.ts +6 -4
  215. package/dist/components/schedule/schedule-types.d.ts.map +1 -1
  216. package/dist/components/schedule/schedule-views.d.ts +2 -2
  217. package/dist/components/schedule/schedule-views.d.ts.map +1 -1
  218. package/dist/components/schedule/schedule-year-view.d.ts +3 -2
  219. package/dist/components/schedule/schedule-year-view.d.ts.map +1 -1
  220. package/dist/components/schedule/schedule.d.ts +9 -6
  221. package/dist/components/schedule/schedule.d.ts.map +1 -1
  222. package/dist/components/segment-group/index.js +2 -2
  223. package/dist/components/select/index.js +4 -4
  224. package/dist/components/slider/index.js +2 -1
  225. package/dist/components/slider/index.js.map +1 -1
  226. package/dist/components/slider/slider.d.ts +3 -2
  227. package/dist/components/slider/slider.d.ts.map +1 -1
  228. package/dist/components/switch/index.js +1 -1
  229. package/dist/components/tabs/index.js +1 -1
  230. package/dist/components/tabs/tabs-data.d.ts +3 -2
  231. package/dist/components/tabs/tabs-data.d.ts.map +1 -1
  232. package/dist/components/tags-input/index.js +6 -5
  233. package/dist/components/tags-input/index.js.map +1 -1
  234. package/dist/components/text-input/index.js +2 -2
  235. package/dist/components/textarea/index.js +2 -2
  236. package/dist/components/theme-icon/index.js +1 -1
  237. package/dist/components/time-input/index.js +6 -6
  238. package/dist/components/timeline/index.js +8 -5
  239. package/dist/components/timeline/index.js.map +1 -1
  240. package/dist/components/timeline/timeline.d.ts +1 -1
  241. package/dist/components/timeline/timeline.d.ts.map +1 -1
  242. package/dist/components/tooltip/index.js +1 -1
  243. package/dist/components/tooltip/tooltip.d.ts +2 -1
  244. package/dist/components/tooltip/tooltip.d.ts.map +1 -1
  245. package/dist/components/tree-multi-select/index.js +6 -5
  246. package/dist/components/tree-multi-select/index.js.map +1 -1
  247. package/dist/components/tree-select/index.js +3 -3
  248. package/dist/index.js +1 -1
  249. package/dist/lib/as-child.d.ts +104 -0
  250. package/dist/lib/as-child.d.ts.map +1 -0
  251. package/dist/lib/colors.d.ts +1 -1
  252. package/dist/lib/colors.d.ts.map +1 -1
  253. package/dist/theme.css +0 -33
  254. package/package.json +2 -1
  255. package/src/as-child.contract.test.tsx +809 -0
  256. package/src/biome-plugins.test.ts +61 -0
  257. package/src/colors.css +12 -26
  258. package/src/components/accordion/accordion-data.tsx +8 -5
  259. package/src/components/accordion/accordion.test.tsx +40 -0
  260. package/src/components/accordion/accordion.tsx +23 -6
  261. package/src/components/action-icon/action-icon.tsx +9 -24
  262. package/src/components/alert/alert.test.tsx +17 -0
  263. package/src/components/alert/alert.tsx +21 -2
  264. package/src/components/app-shell/app-shell.tsx +3 -1
  265. package/src/components/avatar/avatar.tsx +3 -3
  266. package/src/components/breadcrumb/breadcrumb.test.tsx +30 -0
  267. package/src/components/breadcrumb/breadcrumb.tsx +21 -12
  268. package/src/components/button/button.tsx +21 -50
  269. package/src/components/chart/chart.test.tsx +1 -2
  270. package/src/components/chart/chart.tsx +1 -1
  271. package/src/components/circular-progress/circular-progress.tsx +4 -1
  272. package/src/components/clipboard/clipboard.test.tsx +18 -0
  273. package/src/components/clipboard/clipboard.tsx +8 -2
  274. package/src/components/code-block/chrome.tsx +60 -36
  275. package/src/components/code-block/code-block.test.tsx +27 -0
  276. package/src/components/code-block/code-block.tsx +13 -3
  277. package/src/components/code-block/gutters.test.ts +2 -2
  278. package/src/components/code-block/notation.test.ts +8 -0
  279. package/src/components/code-block/notation.ts +6 -3
  280. package/src/components/code-block/static.tsx +8 -2
  281. package/src/components/collapse/collapse.tsx +33 -15
  282. package/src/components/combobox/combobox.test.tsx +38 -0
  283. package/src/components/combobox/combobox.tsx +24 -10
  284. package/src/components/divider/divider.tsx +3 -1
  285. package/src/components/drawer/drawer.tsx +37 -16
  286. package/src/components/field/field.tsx +7 -3
  287. package/src/components/input/input.tsx +3 -1
  288. package/src/components/mark/mark.test.tsx +4 -4
  289. package/src/components/mark/mark.tsx +3 -3
  290. package/src/components/menu/menu-data.tsx +8 -1
  291. package/src/components/menu/menu.test.tsx +52 -0
  292. package/src/components/menu/menu.tsx +83 -35
  293. package/src/components/modal/close-trigger.test.tsx +38 -0
  294. package/src/components/modal/modal.tsx +29 -13
  295. package/src/components/notification/notification.tsx +4 -1
  296. package/src/components/pill/pill.tsx +29 -20
  297. package/src/components/pills-input/pills-input.tsx +3 -1
  298. package/src/components/popover/popover.tsx +3 -1
  299. package/src/components/progress/progress.tsx +4 -1
  300. package/src/components/rating/rating.tsx +27 -23
  301. package/src/components/schedule/index.ts +1 -1
  302. package/src/components/schedule/schedule-agenda-list.tsx +6 -7
  303. package/src/components/schedule/schedule-agenda-view.test.tsx +105 -28
  304. package/src/components/schedule/schedule-agenda-view.tsx +41 -28
  305. package/src/components/schedule/schedule-dates.test.ts +37 -52
  306. package/src/components/schedule/schedule-dates.ts +22 -25
  307. package/src/components/schedule/schedule-days-view.tsx +3 -1
  308. package/src/components/schedule/schedule-month-view.tsx +3 -1
  309. package/src/components/schedule/schedule-next-up.tsx +6 -2
  310. package/src/components/schedule/schedule-toolbar.test.tsx +26 -0
  311. package/src/components/schedule/schedule-toolbar.tsx +13 -1
  312. package/src/components/schedule/schedule-types.ts +6 -4
  313. package/src/components/schedule/schedule-views.ts +4 -5
  314. package/src/components/schedule/schedule-year-view.tsx +3 -1
  315. package/src/components/schedule/schedule.test.tsx +66 -22
  316. package/src/components/schedule/schedule.tsx +22 -13
  317. package/src/components/slider/slider.tsx +4 -0
  318. package/src/components/tabs/tabs-data.tsx +17 -14
  319. package/src/components/theme-icon/theme-icon.tsx +1 -1
  320. package/src/components/timeline/timeline.tsx +102 -95
  321. package/src/components/tooltip/tooltip.tsx +2 -1
  322. package/src/lib/as-child.test.tsx +70 -0
  323. package/src/lib/as-child.ts +119 -0
  324. package/src/lib/colors.ts +4 -2
  325. package/src/theme.css +0 -33
  326. package/dist/chunk-2762HZYX.js.map +0 -1
  327. package/dist/chunk-2H46IXW4.js.map +0 -1
  328. package/dist/chunk-6SWK4XG5.js.map +0 -1
  329. package/dist/chunk-EVVMHTCL.js.map +0 -1
  330. package/dist/chunk-HWNPXAEN.js +0 -31
  331. package/dist/chunk-HWNPXAEN.js.map +0 -1
  332. package/dist/chunk-IFWCCAQV.js.map +0 -1
  333. package/dist/chunk-IXKELBJA.js.map +0 -1
  334. package/dist/chunk-J3PELDH3.js.map +0 -1
  335. package/dist/chunk-JBVFWSRQ.js.map +0 -1
  336. package/dist/chunk-NGAQITWP.js.map +0 -1
  337. package/dist/chunk-POKDSVQT.js.map +0 -1
  338. package/dist/chunk-QMW7D5GU.js.map +0 -1
  339. package/dist/chunk-S53FHWNG.js.map +0 -1
  340. package/dist/chunk-TNNH3FVQ.js.map +0 -1
  341. package/dist/chunk-U5GW5EBR.js.map +0 -1
  342. package/dist/chunk-UNSAA7YG.js.map +0 -1
  343. package/dist/chunk-VLUKI3HL.js.map +0 -1
  344. package/dist/chunk-VZ2TPU4B.js.map +0 -1
  345. package/dist/chunk-YIQI2CF3.js.map +0 -1
@@ -0,0 +1,61 @@
1
+ import { execFileSync } from "node:child_process"
2
+ import { mkdtempSync, rmSync, writeFileSync } from "node:fs"
3
+ import { tmpdir } from "node:os"
4
+ import { join, resolve } from "node:path"
5
+ import { afterAll, describe, expect, it } from "vitest"
6
+
7
+ /**
8
+ * Runs the shipped Biome plugins (`biome/*.grit`) against a throwaway file
9
+ * with the repo's own Biome. A Grit rule that stops matching fails silently,
10
+ * with no lint error, so this pins what each one flags and what it leaves alone.
11
+ */
12
+ const pkg = resolve(__dirname, "..")
13
+ const biome = resolve(pkg, "../../node_modules/.bin/biome")
14
+ // Outside the repo: Biome never lints anything under `node_modules`, and the
15
+ // fixture must not pick up the repo's own biome.json either.
16
+ const dir = mkdtempSync(join(tmpdir(), "biome-plugins-"))
17
+
18
+ const lint = (plugin: string, source: string) => {
19
+ writeFileSync(
20
+ join(dir, "biome.json"),
21
+ JSON.stringify({
22
+ root: true,
23
+ plugins: [resolve(pkg, "biome", plugin)],
24
+ linter: { rules: { recommended: false } },
25
+ formatter: { enabled: false },
26
+ }),
27
+ )
28
+ writeFileSync(join(dir, "sample.tsx"), source)
29
+ const out = execFileSync(biome, ["lint", "--reporter=json", "sample.tsx"], {
30
+ cwd: dir,
31
+ encoding: "utf8",
32
+ })
33
+ const { diagnostics } = JSON.parse(out) as {
34
+ diagnostics: { location: { start: { line: number } } }[]
35
+ }
36
+ return diagnostics.map((d) => d.location.start.line)
37
+ }
38
+
39
+ afterAll(() => rmSync(dir, { recursive: true, force: true }))
40
+
41
+ describe("no-gray-color.grit", () => {
42
+ it("warns on gray literals and nothing else", () => {
43
+ const lines = lint(
44
+ "no-gray-color.grit",
45
+ [
46
+ `export const A = () => (`,
47
+ ` <>`,
48
+ ` <Badge color="gray" variant="light">a</Badge>`,
49
+ ` <Button color={"gray"} />`,
50
+ ` <Button color={'gray'}>b</Button>`,
51
+ ` <Button color="neutral" />`,
52
+ ` <Text c="gray" />`,
53
+ ` <Badge background="gray" />`,
54
+ ` </>`,
55
+ `)`,
56
+ `export const data = { color: "gray" }`,
57
+ ].join("\n"),
58
+ )
59
+ expect(lines).toEqual([3, 4, 5])
60
+ })
61
+ })
package/src/colors.css CHANGED
@@ -21,12 +21,10 @@
21
21
  * --c-solid-hover : filled hover state (600 light / 400 dark)
22
22
  * --c-on-solid : foreground sitting on a solid background. brand-950 (dark navy)
23
23
  * for every color, light or dark theme — matches the 42 UI Kit
24
- * Figma, which uses dark navy text on solid fills. `gray` (light
25
- * theme) is the one exception, kept white — its solid shade is
26
- * too dark for brand-950 text to clear WCAG AA (2.05:1; see the
27
- * inline comment there). `purple` is a marginal fail (4.29:1 vs
28
- * the 4.5 AA threshold) but keeps brand-950 anyway for
29
- * consistency with the other nine colors.
24
+ * Figma, which uses dark navy text on solid fills. `neutral`
25
+ * (light theme) is the one exception, white on its black fill.
26
+ * `purple` is a marginal fail (4.29:1 vs the 4.5 AA threshold)
27
+ * but keeps brand-950 anyway for consistency with the others.
30
28
  * --c-soft : tinted surface for `light` / hover tints (50 light / 950 dark)
31
29
  * --c-soft-hover : a step darker than --c-soft
32
30
  * --c-text : text + icon on non-filled surfaces (700 light / 300 dark)
@@ -94,24 +92,6 @@
94
92
  --c-text: var(--color-brand-300);
95
93
  }
96
94
 
97
- [data-color="gray"] {
98
- /* gray-700 is too dark for brand-950 text (2.05:1, fails WCAG AA) — kept white. */
99
- --c-solid: var(--color-gray-light-700);
100
- --c-solid-hover: var(--color-gray-light-800);
101
- --c-on-solid: var(--color-white);
102
- --c-soft: var(--color-gray-light-100);
103
- --c-soft-hover: var(--color-gray-light-200);
104
- --c-text: var(--color-gray-light-700);
105
- }
106
- [data-theme="dark"] [data-color="gray"] {
107
- --c-solid: var(--color-gray-dark-300);
108
- --c-solid-hover: var(--color-gray-dark-200);
109
- --c-on-solid: var(--color-brand-950);
110
- --c-soft: var(--color-gray-dark-800);
111
- --c-soft-hover: var(--color-gray-dark-700);
112
- --c-text: var(--color-gray-dark-300);
113
- }
114
-
115
95
  [data-color="red"] {
116
96
  --c-solid: var(--color-red-500);
117
97
  --c-solid-hover: var(--color-red-600);
@@ -268,7 +248,12 @@
268
248
  --c-text: var(--color-pink-300);
269
249
  }
270
250
 
271
- [data-color="neutral"] {
251
+ /* `gray` is a deprecated alias of `neutral`: the former mid-gray palette was
252
+ cut (Figma's "gray" Button already draws these exact values). The selector
253
+ stays one minor so `data-color="gray"` doesn't silently inherit its
254
+ ancestor's palette instead. Remove in the next minor. */
255
+ [data-color="neutral"],
256
+ [data-color="gray"] {
272
257
  /* Figma "White" hierarchy — the literal white/dark-navy button most of the
273
258
  kit defaults to. --c-soft mirrors Figma's own translucent-white overlay
274
259
  intent, but a single value shared across themes would go invisible (or
@@ -286,7 +271,8 @@
286
271
  --c-soft-hover: color-mix(in oklab, var(--color-black) 35%, transparent);
287
272
  --c-text: var(--color-gray-light-700);
288
273
  }
289
- [data-theme="dark"] [data-color="neutral"] {
274
+ [data-theme="dark"] [data-color="neutral"],
275
+ [data-theme="dark"] [data-color="gray"] {
290
276
  --c-solid: var(--color-white);
291
277
  --c-solid-hover: var(--color-gray-light-300);
292
278
  --c-on-solid: var(--color-brand-950);
@@ -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()
@@ -114,9 +114,9 @@ export type AvatarNameMode = "name" | "initials"
114
114
  /**
115
115
  * Default hash pool for `color="name"` / `color="initials"`. Excludes
116
116
  * `brand` (the kit's own primary/CTA identity color — auto-tinting a user
117
- * avatar with it would read as "official") and `gray`/`neutral` (muted, and
118
- * `neutral` is a composed-not-scaled tone per `lib/colors.ts`, so it would
119
- * just look washed-out for some names). Exported so a consumer can extend it,
117
+ * avatar with it would read as "official") and `neutral` (muted, and a
118
+ * composed-not-scaled tone per `lib/colors.ts`, so it would just look
119
+ * washed-out for some names). Exported so a consumer can extend it,
120
120
  * e.g. `palette={[...AVATAR_PALETTE, "brand"]}`.
121
121
  */
122
122
  export const AVATAR_PALETTE: Color[] = [
@@ -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
  }