@postenbring/hedwig-react 0.0.76 → 0.0.77

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 (429) hide show
  1. package/dist/_tsup-dts-rollup.d.mts +498 -492
  2. package/dist/_tsup-dts-rollup.d.ts +498 -492
  3. package/dist/accordion/accordion-content.js +20 -18
  4. package/dist/accordion/accordion-content.js.map +1 -1
  5. package/dist/accordion/accordion-content.mjs +1 -1
  6. package/dist/accordion/accordion-header.js +24 -22
  7. package/dist/accordion/accordion-header.js.map +1 -1
  8. package/dist/accordion/accordion-header.mjs +1 -1
  9. package/dist/accordion/accordion-item.js +2 -16
  10. package/dist/accordion/accordion-item.js.map +1 -1
  11. package/dist/accordion/accordion-item.mjs +1 -1
  12. package/dist/accordion/accordion.js +2 -2
  13. package/dist/accordion/accordion.js.map +1 -1
  14. package/dist/accordion/accordion.mjs +1 -1
  15. package/dist/accordion/index.js +48 -58
  16. package/dist/accordion/index.js.map +1 -1
  17. package/dist/accordion/index.mjs +7 -7
  18. package/dist/badge/badge.d.mts +2 -2
  19. package/dist/badge/badge.d.ts +2 -2
  20. package/dist/badge/badge.js +23 -30
  21. package/dist/badge/badge.js.map +1 -1
  22. package/dist/badge/badge.mjs +3 -3
  23. package/dist/badge/index.d.mts +2 -1
  24. package/dist/badge/index.d.ts +2 -1
  25. package/dist/badge/index.js +22 -29
  26. package/dist/badge/index.js.map +1 -1
  27. package/dist/badge/index.mjs +3 -3
  28. package/dist/box/box.js +5 -3
  29. package/dist/box/box.js.map +1 -1
  30. package/dist/box/box.mjs +1 -1
  31. package/dist/box/index.js +5 -3
  32. package/dist/box/index.js.map +1 -1
  33. package/dist/box/index.mjs +2 -2
  34. package/dist/breadcrumbs/breadcrumbs.js.map +1 -1
  35. package/dist/breadcrumbs/breadcrumbs.mjs +1 -1
  36. package/dist/breadcrumbs/index.js.map +1 -1
  37. package/dist/breadcrumbs/index.mjs +1 -1
  38. package/dist/button/button.d.mts +0 -1
  39. package/dist/button/button.d.ts +0 -1
  40. package/dist/button/button.js +15 -22
  41. package/dist/button/button.js.map +1 -1
  42. package/dist/button/button.mjs +1 -3
  43. package/dist/button/index.d.mts +0 -1
  44. package/dist/button/index.d.ts +0 -1
  45. package/dist/button/index.js +15 -20
  46. package/dist/button/index.js.map +1 -1
  47. package/dist/button/index.mjs +1 -1
  48. package/dist/card/card.d.mts +1 -1
  49. package/dist/card/card.d.ts +1 -1
  50. package/dist/card/card.js +63 -46
  51. package/dist/card/card.js.map +1 -1
  52. package/dist/card/card.mjs +1 -1
  53. package/dist/card/index.d.mts +3 -3
  54. package/dist/card/index.d.ts +3 -3
  55. package/dist/card/index.js +80 -59
  56. package/dist/card/index.js.map +1 -1
  57. package/dist/card/index.mjs +10 -2
  58. package/dist/chunk-2UWPZNXC.mjs +40 -0
  59. package/dist/chunk-2UWPZNXC.mjs.map +1 -0
  60. package/dist/chunk-3EFAPJ3H.mjs +44 -0
  61. package/dist/chunk-3EFAPJ3H.mjs.map +1 -0
  62. package/dist/{chunk-XVFQWVHO.mjs → chunk-3MQKXNZ6.mjs} +4 -2
  63. package/dist/chunk-3MQKXNZ6.mjs.map +1 -0
  64. package/dist/{chunk-NMMFIRLZ.mjs → chunk-3NL3TOZF.mjs} +2 -2
  65. package/dist/{chunk-DM4PJFLG.mjs → chunk-6N4TGRZB.mjs} +2 -2
  66. package/dist/{chunk-JDXYRFLJ.mjs → chunk-722MZPXO.mjs} +2 -2
  67. package/dist/chunk-7JDEN3T6.mjs +109 -0
  68. package/dist/chunk-7JDEN3T6.mjs.map +1 -0
  69. package/dist/{chunk-HMB4TY2F.mjs → chunk-7W4HONVO.mjs} +3 -3
  70. package/dist/{chunk-62F4I3MQ.mjs → chunk-A2H2LAII.mjs} +3 -17
  71. package/dist/chunk-A2H2LAII.mjs.map +1 -0
  72. package/dist/{chunk-YC7MT6SO.mjs → chunk-A4ME3VXV.mjs} +2 -2
  73. package/dist/chunk-ACEYO4LN.mjs +33 -0
  74. package/dist/chunk-ACEYO4LN.mjs.map +1 -0
  75. package/dist/{chunk-VVPJOVFP.mjs → chunk-AXKJB47E.mjs} +1 -1
  76. package/dist/chunk-AXKJB47E.mjs.map +1 -0
  77. package/dist/{chunk-UWTGHSWT.mjs → chunk-CCVZAHYA.mjs} +11 -6
  78. package/dist/chunk-CCVZAHYA.mjs.map +1 -0
  79. package/dist/chunk-CIHZDFSQ.mjs +148 -0
  80. package/dist/chunk-CIHZDFSQ.mjs.map +1 -0
  81. package/dist/chunk-COEZA7WA.mjs +30 -0
  82. package/dist/chunk-COEZA7WA.mjs.map +1 -0
  83. package/dist/chunk-CSXSUQ2M.mjs +1 -0
  84. package/dist/chunk-CSXSUQ2M.mjs.map +1 -0
  85. package/dist/{chunk-4GSNPCNT.mjs → chunk-CYEYGPRH.mjs} +2 -2
  86. package/dist/{chunk-E2AG5TUR.mjs → chunk-DCCQXWD6.mjs} +4 -4
  87. package/dist/{chunk-JXA3B33M.mjs → chunk-DEX36MFK.mjs} +1 -1
  88. package/dist/chunk-DEX36MFK.mjs.map +1 -0
  89. package/dist/chunk-DFU2THGC.mjs +31 -0
  90. package/dist/chunk-DFU2THGC.mjs.map +1 -0
  91. package/dist/{chunk-EGXM575K.mjs → chunk-ENKVTAJB.mjs} +6 -4
  92. package/dist/chunk-ENKVTAJB.mjs.map +1 -0
  93. package/dist/{chunk-25R7DBK6.mjs → chunk-ES6ISHOV.mjs} +1 -1
  94. package/dist/chunk-ES6ISHOV.mjs.map +1 -0
  95. package/dist/{chunk-PYR6QEIS.mjs → chunk-FCPQXZQV.mjs} +12 -12
  96. package/dist/chunk-FCPQXZQV.mjs.map +1 -0
  97. package/dist/{chunk-57SSGJ4X.mjs → chunk-GGQB2WWD.mjs} +6 -3
  98. package/dist/chunk-GGQB2WWD.mjs.map +1 -0
  99. package/dist/chunk-GSJPTZT3.mjs +121 -0
  100. package/dist/chunk-GSJPTZT3.mjs.map +1 -0
  101. package/dist/{chunk-S3BGPCLK.mjs → chunk-HFXVRPBA.mjs} +13 -26
  102. package/dist/chunk-HFXVRPBA.mjs.map +1 -0
  103. package/dist/{chunk-Z753E3XF.mjs → chunk-HMATZX4A.mjs} +1 -1
  104. package/dist/chunk-HMATZX4A.mjs.map +1 -0
  105. package/dist/{chunk-S5RB7KLJ.mjs → chunk-I3ZIMS72.mjs} +4 -2
  106. package/dist/chunk-I3ZIMS72.mjs.map +1 -0
  107. package/dist/{chunk-EJ7ANN7M.mjs → chunk-IKJJWKXM.mjs} +2 -2
  108. package/dist/{chunk-A47QULAK.mjs → chunk-JF3HBGAA.mjs} +10 -6
  109. package/dist/chunk-JF3HBGAA.mjs.map +1 -0
  110. package/dist/{chunk-KTRIVJM3.mjs → chunk-JL4PLDXN.mjs} +2 -2
  111. package/dist/{chunk-UXJIK76H.mjs → chunk-K3CBNVXC.mjs} +3 -5
  112. package/dist/chunk-K3CBNVXC.mjs.map +1 -0
  113. package/dist/{chunk-BWFFP6BB.mjs → chunk-KEKPEN2C.mjs} +17 -23
  114. package/dist/chunk-KEKPEN2C.mjs.map +1 -0
  115. package/dist/{chunk-VRIY65P5.mjs → chunk-KPGSRU4I.mjs} +3 -3
  116. package/dist/chunk-KPGSRU4I.mjs.map +1 -0
  117. package/dist/{chunk-CSAEHQ4R.mjs → chunk-LTTJWLS7.mjs} +2 -2
  118. package/dist/{chunk-5QL53TR2.mjs → chunk-MJ2DZH3N.mjs} +4 -2
  119. package/dist/chunk-MJ2DZH3N.mjs.map +1 -0
  120. package/dist/{chunk-DFH4YKQA.mjs → chunk-NAIBK23T.mjs} +2 -2
  121. package/dist/chunk-P6KBFRF4.mjs +54 -0
  122. package/dist/chunk-P6KBFRF4.mjs.map +1 -0
  123. package/dist/{chunk-TNU64NUN.mjs → chunk-P6WIBHQH.mjs} +2 -2
  124. package/dist/{chunk-E2RTLHMZ.mjs → chunk-PLXB3TNA.mjs} +2 -2
  125. package/dist/chunk-PLXB3TNA.mjs.map +1 -0
  126. package/dist/chunk-PT5H3QV6.mjs +29 -0
  127. package/dist/chunk-PT5H3QV6.mjs.map +1 -0
  128. package/dist/{chunk-5YMUST7H.mjs → chunk-QY2K3GWU.mjs} +3 -3
  129. package/dist/{chunk-6NGF7FFY.mjs → chunk-RYM3LM7K.mjs} +2 -2
  130. package/dist/{chunk-ME66RUR6.mjs → chunk-TQDUBRCZ.mjs} +7 -4
  131. package/dist/chunk-TQDUBRCZ.mjs.map +1 -0
  132. package/dist/{chunk-ZDPU3N54.mjs → chunk-UB2R7TCG.mjs} +1 -1
  133. package/dist/chunk-UB2R7TCG.mjs.map +1 -0
  134. package/dist/{chunk-RHCMBJOT.mjs → chunk-UMYOYHUI.mjs} +3 -3
  135. package/dist/{chunk-I6GDRDYD.mjs → chunk-USXU6ULZ.mjs} +4 -2
  136. package/dist/chunk-USXU6ULZ.mjs.map +1 -0
  137. package/dist/{chunk-MGUYIOP2.mjs → chunk-W2MRIP5P.mjs} +1 -1
  138. package/dist/chunk-W2MRIP5P.mjs.map +1 -0
  139. package/dist/chunk-WHMIHTPC.mjs +41 -0
  140. package/dist/chunk-WHMIHTPC.mjs.map +1 -0
  141. package/dist/{chunk-PUESATBQ.mjs → chunk-XC3UHH2U.mjs} +31 -45
  142. package/dist/chunk-XC3UHH2U.mjs.map +1 -0
  143. package/dist/{chunk-MKC7HZCM.mjs → chunk-XUWZ4HGD.mjs} +16 -15
  144. package/dist/chunk-XUWZ4HGD.mjs.map +1 -0
  145. package/dist/{chunk-GGEQEVZ4.mjs → chunk-YSFZCRWS.mjs} +1 -1
  146. package/dist/chunk-YSFZCRWS.mjs.map +1 -0
  147. package/dist/{chunk-XYIY6FHW.mjs → chunk-ZMLHJZQK.mjs} +9 -9
  148. package/dist/description-list/description-list.js.map +1 -1
  149. package/dist/description-list/description-list.mjs +1 -1
  150. package/dist/description-list/index.js.map +1 -1
  151. package/dist/description-list/index.mjs +1 -1
  152. package/dist/footer/footer.d.mts +1 -1
  153. package/dist/footer/footer.d.ts +1 -1
  154. package/dist/footer/footer.js +117 -134
  155. package/dist/footer/footer.js.map +1 -1
  156. package/dist/footer/footer.mjs +9 -9
  157. package/dist/footer/index.js +117 -134
  158. package/dist/footer/index.js.map +1 -1
  159. package/dist/footer/index.mjs +10 -10
  160. package/dist/form/checkbox/checkbox.js +25 -19
  161. package/dist/form/checkbox/checkbox.js.map +1 -1
  162. package/dist/form/checkbox/checkbox.mjs +3 -3
  163. package/dist/form/checkbox/index.js +25 -19
  164. package/dist/form/checkbox/index.js.map +1 -1
  165. package/dist/form/checkbox/index.mjs +3 -3
  166. package/dist/form/date-picker/date-picker.js +28 -22
  167. package/dist/form/date-picker/date-picker.js.map +1 -1
  168. package/dist/form/date-picker/date-picker.mjs +4 -4
  169. package/dist/form/date-picker/index.js +28 -22
  170. package/dist/form/date-picker/index.js.map +1 -1
  171. package/dist/form/date-picker/index.mjs +4 -4
  172. package/dist/form/error-message/error-message.d.mts +1 -1
  173. package/dist/form/error-message/error-message.d.ts +1 -1
  174. package/dist/form/error-message/error-message.js +46 -11
  175. package/dist/form/error-message/error-message.js.map +1 -1
  176. package/dist/form/error-message/error-message.mjs +1 -1
  177. package/dist/form/error-message/index.js +46 -11
  178. package/dist/form/error-message/index.js.map +1 -1
  179. package/dist/form/error-message/index.mjs +1 -1
  180. package/dist/form/fieldset/fieldset.js +22 -16
  181. package/dist/form/fieldset/fieldset.js.map +1 -1
  182. package/dist/form/fieldset/fieldset.mjs +2 -2
  183. package/dist/form/fieldset/index.js +22 -16
  184. package/dist/form/fieldset/index.js.map +1 -1
  185. package/dist/form/fieldset/index.mjs +2 -2
  186. package/dist/form/index.js +48 -42
  187. package/dist/form/index.js.map +1 -1
  188. package/dist/form/index.mjs +11 -11
  189. package/dist/form/input/index.js +26 -20
  190. package/dist/form/input/index.js.map +1 -1
  191. package/dist/form/input/index.mjs +3 -3
  192. package/dist/form/input/input.js +26 -20
  193. package/dist/form/input/input.js.map +1 -1
  194. package/dist/form/input/input.mjs +3 -3
  195. package/dist/form/input-group/index.js +24 -18
  196. package/dist/form/input-group/index.js.map +1 -1
  197. package/dist/form/input-group/index.mjs +2 -2
  198. package/dist/form/input-group/input-group.js +24 -18
  199. package/dist/form/input-group/input-group.js.map +1 -1
  200. package/dist/form/input-group/input-group.mjs +2 -2
  201. package/dist/form/radiobutton/index.js +28 -22
  202. package/dist/form/radiobutton/index.js.map +1 -1
  203. package/dist/form/radiobutton/index.mjs +4 -4
  204. package/dist/form/radiobutton/radiobutton.js +28 -22
  205. package/dist/form/radiobutton/radiobutton.js.map +1 -1
  206. package/dist/form/radiobutton/radiobutton.mjs +4 -4
  207. package/dist/form/radiobutton/radiogroup.js +25 -19
  208. package/dist/form/radiobutton/radiogroup.js.map +1 -1
  209. package/dist/form/radiobutton/radiogroup.mjs +3 -3
  210. package/dist/form/select/index.js +26 -20
  211. package/dist/form/select/index.js.map +1 -1
  212. package/dist/form/select/index.mjs +3 -3
  213. package/dist/form/select/select.js +26 -20
  214. package/dist/form/select/select.js.map +1 -1
  215. package/dist/form/select/select.mjs +3 -3
  216. package/dist/form/textarea/index.js +26 -20
  217. package/dist/form/textarea/index.js.map +1 -1
  218. package/dist/form/textarea/index.mjs +3 -3
  219. package/dist/form/textarea/textarea.js +26 -20
  220. package/dist/form/textarea/textarea.js.map +1 -1
  221. package/dist/form/textarea/textarea.mjs +3 -3
  222. package/dist/help-text/help-text.js +5 -3
  223. package/dist/help-text/help-text.js.map +1 -1
  224. package/dist/help-text/help-text.mjs +3 -3
  225. package/dist/help-text/index.js +5 -3
  226. package/dist/help-text/index.js.map +1 -1
  227. package/dist/help-text/index.mjs +3 -3
  228. package/dist/index-no-css.d.mts +12 -20
  229. package/dist/index-no-css.d.ts +12 -20
  230. package/dist/index-no-css.js +615 -614
  231. package/dist/index-no-css.js.map +1 -1
  232. package/dist/index-no-css.mjs +85 -92
  233. package/dist/index.d.mts +12 -20
  234. package/dist/index.d.ts +12 -20
  235. package/dist/index.js +615 -614
  236. package/dist/index.js.map +1 -1
  237. package/dist/index.mjs +85 -92
  238. package/dist/index.mjs.map +1 -1
  239. package/dist/layout/container/container.js +3 -1
  240. package/dist/layout/container/container.js.map +1 -1
  241. package/dist/layout/container/container.mjs +1 -1
  242. package/dist/layout/grid/grid.js.map +1 -1
  243. package/dist/layout/grid/grid.mjs +1 -1
  244. package/dist/layout/grid/index.js.map +1 -1
  245. package/dist/layout/grid/index.mjs +2 -2
  246. package/dist/layout/index.js +8 -6
  247. package/dist/layout/index.js.map +1 -1
  248. package/dist/layout/index.mjs +4 -4
  249. package/dist/layout/stack/index.js.map +1 -1
  250. package/dist/layout/stack/index.mjs +1 -1
  251. package/dist/layout/stack/stack.js.map +1 -1
  252. package/dist/layout/stack/stack.mjs +1 -1
  253. package/dist/link/index.js +3 -1
  254. package/dist/link/index.js.map +1 -1
  255. package/dist/link/index.mjs +1 -1
  256. package/dist/link/link.js +3 -1
  257. package/dist/link/link.js.map +1 -1
  258. package/dist/link/link.mjs +1 -1
  259. package/dist/list/index.js +39 -31
  260. package/dist/list/index.js.map +1 -1
  261. package/dist/list/index.mjs +2 -2
  262. package/dist/list/link-list.d.mts +1 -1
  263. package/dist/list/link-list.d.ts +1 -1
  264. package/dist/list/link-list.js +39 -31
  265. package/dist/list/link-list.js.map +1 -1
  266. package/dist/list/link-list.mjs +2 -2
  267. package/dist/list/list.d.mts +1 -1
  268. package/dist/list/list.d.ts +1 -1
  269. package/dist/list/list.js +26 -26
  270. package/dist/list/list.js.map +1 -1
  271. package/dist/list/list.mjs +1 -1
  272. package/dist/message/index.js +10 -5
  273. package/dist/message/index.js.map +1 -1
  274. package/dist/message/index.mjs +3 -3
  275. package/dist/message/message.js +10 -5
  276. package/dist/message/message.js.map +1 -1
  277. package/dist/message/message.mjs +2 -2
  278. package/dist/modal/index.d.mts +0 -1
  279. package/dist/modal/index.d.ts +0 -1
  280. package/dist/modal/index.js +17 -13
  281. package/dist/modal/index.js.map +1 -1
  282. package/dist/modal/index.mjs +4 -4
  283. package/dist/modal/modal.d.mts +0 -1
  284. package/dist/modal/modal.d.ts +0 -1
  285. package/dist/modal/modal.js +19 -17
  286. package/dist/modal/modal.js.map +1 -1
  287. package/dist/modal/modal.mjs +5 -7
  288. package/dist/navbar/icons.js.map +1 -1
  289. package/dist/navbar/icons.mjs +1 -1
  290. package/dist/navbar/index.d.mts +7 -1
  291. package/dist/navbar/index.d.ts +7 -1
  292. package/dist/navbar/index.js +87 -39
  293. package/dist/navbar/index.js.map +1 -1
  294. package/dist/navbar/index.mjs +19 -7
  295. package/dist/navbar/navbar-expandable-menu.d.mts +3 -3
  296. package/dist/navbar/navbar-expandable-menu.d.ts +3 -3
  297. package/dist/navbar/navbar-expandable-menu.js +9 -9
  298. package/dist/navbar/navbar-expandable-menu.js.map +1 -1
  299. package/dist/navbar/navbar-expandable-menu.mjs +3 -3
  300. package/dist/navbar/navbar.d.mts +4 -1
  301. package/dist/navbar/navbar.d.ts +4 -1
  302. package/dist/navbar/navbar.js +64 -24
  303. package/dist/navbar/navbar.js.map +1 -1
  304. package/dist/navbar/navbar.mjs +9 -3
  305. package/dist/show-more/index.js +1 -3
  306. package/dist/show-more/index.js.map +1 -1
  307. package/dist/show-more/index.mjs +3 -3
  308. package/dist/show-more/show-more.js.map +1 -1
  309. package/dist/show-more/show-more.mjs +1 -1
  310. package/dist/skeleton/index.js +9 -5
  311. package/dist/skeleton/index.js.map +1 -1
  312. package/dist/skeleton/index.mjs +1 -1
  313. package/dist/skeleton/skeleton.js +9 -5
  314. package/dist/skeleton/skeleton.js.map +1 -1
  315. package/dist/skeleton/skeleton.mjs +1 -1
  316. package/dist/styled-html/index.js +3 -1
  317. package/dist/styled-html/index.js.map +1 -1
  318. package/dist/styled-html/index.mjs +1 -1
  319. package/dist/styled-html/styled-html.js +3 -1
  320. package/dist/styled-html/styled-html.js.map +1 -1
  321. package/dist/styled-html/styled-html.mjs +1 -1
  322. package/dist/tabs/index.d.mts +2 -2
  323. package/dist/tabs/index.d.ts +2 -2
  324. package/dist/tabs/index.js +73 -63
  325. package/dist/tabs/index.js.map +1 -1
  326. package/dist/tabs/index.mjs +5 -5
  327. package/dist/tabs/tabs-content.d.mts +1 -1
  328. package/dist/tabs/tabs-content.d.ts +1 -1
  329. package/dist/tabs/tabs-content.js +10 -5
  330. package/dist/tabs/tabs-content.js.map +1 -1
  331. package/dist/tabs/tabs-content.mjs +1 -1
  332. package/dist/tabs/tabs-list.d.mts +1 -1
  333. package/dist/tabs/tabs-list.d.ts +1 -1
  334. package/dist/tabs/tabs-list.js +60 -57
  335. package/dist/tabs/tabs-list.js.map +1 -1
  336. package/dist/tabs/tabs-list.mjs +2 -2
  337. package/dist/tabs/tabs.js +3 -1
  338. package/dist/tabs/tabs.js.map +1 -1
  339. package/dist/tabs/tabs.mjs +1 -1
  340. package/dist/text/index.d.mts +0 -13
  341. package/dist/text/index.d.ts +0 -13
  342. package/dist/text/index.js +7 -68
  343. package/dist/text/index.js.map +1 -1
  344. package/dist/text/index.mjs +3 -30
  345. package/dist/text/text.js +5 -2
  346. package/dist/text/text.js.map +1 -1
  347. package/dist/text/text.mjs +1 -1
  348. package/dist/utilities/auto-animate-height.js +1 -3
  349. package/dist/utilities/auto-animate-height.js.map +1 -1
  350. package/dist/utilities/auto-animate-height.mjs +2 -2
  351. package/dist/utilities/index.js +1 -3
  352. package/dist/utilities/index.js.map +1 -1
  353. package/dist/utilities/index.mjs +2 -2
  354. package/dist/utils.d.mts +0 -1
  355. package/dist/utils.d.ts +0 -1
  356. package/dist/utils.js.map +1 -1
  357. package/dist/utils.mjs +1 -1
  358. package/dist/warning-banner/index.js +34 -46
  359. package/dist/warning-banner/index.js.map +1 -1
  360. package/dist/warning-banner/index.mjs +3 -3
  361. package/dist/warning-banner/warning-banner.js +34 -46
  362. package/dist/warning-banner/warning-banner.js.map +1 -1
  363. package/dist/warning-banner/warning-banner.mjs +3 -3
  364. package/package.json +5 -5
  365. package/dist/chunk-25R7DBK6.mjs.map +0 -1
  366. package/dist/chunk-57SSGJ4X.mjs.map +0 -1
  367. package/dist/chunk-5QL53TR2.mjs.map +0 -1
  368. package/dist/chunk-625SVQEP.mjs +0 -84
  369. package/dist/chunk-625SVQEP.mjs.map +0 -1
  370. package/dist/chunk-62F4I3MQ.mjs.map +0 -1
  371. package/dist/chunk-A47QULAK.mjs.map +0 -1
  372. package/dist/chunk-BWFFP6BB.mjs.map +0 -1
  373. package/dist/chunk-E2RTLHMZ.mjs.map +0 -1
  374. package/dist/chunk-EGXM575K.mjs.map +0 -1
  375. package/dist/chunk-FYNTNGIY.mjs +0 -61
  376. package/dist/chunk-FYNTNGIY.mjs.map +0 -1
  377. package/dist/chunk-GGEQEVZ4.mjs.map +0 -1
  378. package/dist/chunk-GJDRW6PA.mjs +0 -22
  379. package/dist/chunk-GJDRW6PA.mjs.map +0 -1
  380. package/dist/chunk-GUB3UCXO.mjs +0 -38
  381. package/dist/chunk-GUB3UCXO.mjs.map +0 -1
  382. package/dist/chunk-I6GDRDYD.mjs.map +0 -1
  383. package/dist/chunk-IL7576PP.mjs +0 -19
  384. package/dist/chunk-IL7576PP.mjs.map +0 -1
  385. package/dist/chunk-JXA3B33M.mjs.map +0 -1
  386. package/dist/chunk-ME66RUR6.mjs.map +0 -1
  387. package/dist/chunk-MF2AREPQ.mjs +0 -28
  388. package/dist/chunk-MF2AREPQ.mjs.map +0 -1
  389. package/dist/chunk-MGUYIOP2.mjs.map +0 -1
  390. package/dist/chunk-MKC7HZCM.mjs.map +0 -1
  391. package/dist/chunk-PMLDK3VC.mjs +0 -39
  392. package/dist/chunk-PMLDK3VC.mjs.map +0 -1
  393. package/dist/chunk-PUESATBQ.mjs.map +0 -1
  394. package/dist/chunk-PYR6QEIS.mjs.map +0 -1
  395. package/dist/chunk-S3BGPCLK.mjs.map +0 -1
  396. package/dist/chunk-S5RB7KLJ.mjs.map +0 -1
  397. package/dist/chunk-SRLRTLHS.mjs +0 -106
  398. package/dist/chunk-SRLRTLHS.mjs.map +0 -1
  399. package/dist/chunk-UWTGHSWT.mjs.map +0 -1
  400. package/dist/chunk-UXJIK76H.mjs.map +0 -1
  401. package/dist/chunk-VRIY65P5.mjs.map +0 -1
  402. package/dist/chunk-VVPJOVFP.mjs.map +0 -1
  403. package/dist/chunk-W3D4VR4Y.mjs +0 -61
  404. package/dist/chunk-W3D4VR4Y.mjs.map +0 -1
  405. package/dist/chunk-X5JERDDU.mjs +0 -131
  406. package/dist/chunk-X5JERDDU.mjs.map +0 -1
  407. package/dist/chunk-XE4UZBL2.mjs +0 -33
  408. package/dist/chunk-XE4UZBL2.mjs.map +0 -1
  409. package/dist/chunk-XVFQWVHO.mjs.map +0 -1
  410. package/dist/chunk-YXHXRUFX.mjs +0 -42
  411. package/dist/chunk-YXHXRUFX.mjs.map +0 -1
  412. package/dist/chunk-Z753E3XF.mjs.map +0 -1
  413. package/dist/chunk-ZDPU3N54.mjs.map +0 -1
  414. /package/dist/{chunk-NMMFIRLZ.mjs.map → chunk-3NL3TOZF.mjs.map} +0 -0
  415. /package/dist/{chunk-DM4PJFLG.mjs.map → chunk-6N4TGRZB.mjs.map} +0 -0
  416. /package/dist/{chunk-JDXYRFLJ.mjs.map → chunk-722MZPXO.mjs.map} +0 -0
  417. /package/dist/{chunk-HMB4TY2F.mjs.map → chunk-7W4HONVO.mjs.map} +0 -0
  418. /package/dist/{chunk-YC7MT6SO.mjs.map → chunk-A4ME3VXV.mjs.map} +0 -0
  419. /package/dist/{chunk-4GSNPCNT.mjs.map → chunk-CYEYGPRH.mjs.map} +0 -0
  420. /package/dist/{chunk-E2AG5TUR.mjs.map → chunk-DCCQXWD6.mjs.map} +0 -0
  421. /package/dist/{chunk-EJ7ANN7M.mjs.map → chunk-IKJJWKXM.mjs.map} +0 -0
  422. /package/dist/{chunk-KTRIVJM3.mjs.map → chunk-JL4PLDXN.mjs.map} +0 -0
  423. /package/dist/{chunk-CSAEHQ4R.mjs.map → chunk-LTTJWLS7.mjs.map} +0 -0
  424. /package/dist/{chunk-DFH4YKQA.mjs.map → chunk-NAIBK23T.mjs.map} +0 -0
  425. /package/dist/{chunk-TNU64NUN.mjs.map → chunk-P6WIBHQH.mjs.map} +0 -0
  426. /package/dist/{chunk-5YMUST7H.mjs.map → chunk-QY2K3GWU.mjs.map} +0 -0
  427. /package/dist/{chunk-6NGF7FFY.mjs.map → chunk-RYM3LM7K.mjs.map} +0 -0
  428. /package/dist/{chunk-RHCMBJOT.mjs.map → chunk-UMYOYHUI.mjs.map} +0 -0
  429. /package/dist/{chunk-XYIY6FHW.mjs.map → chunk-ZMLHJZQK.mjs.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/auto-animate-height.tsx","../../src/utils.ts"],"sourcesContent":["import { cloneElement, forwardRef, useEffect, useRef, useState } from \"react\";\nimport { useMergeRefs, type OverridableComponent } from \"../utils\";\n\nexport interface AutoAnimateHeightProps {\n /**\n * Time of the animation, using the hedwig animation tokens\n * quick: 0.1s\n * normal: 0.3s\n * slow: 0.7s\n *\n * default is \"quick\"\n */\n animationDuration?: \"quick\" | \"normal\" | \"slow\";\n\n /**\n * Callback fired when animiation transition ends\n * Use this to do effects after resizing is done, e.g. scrolling to the element\n * using `element.scrollIntoView()`\n */\n onTransitionEnd?: () => void;\n\n /**\n * Which hedwig easing function to use, default is \"normal\"\n */\n animationEasing?: \"in\" | \"out\" | \"normal\";\n children: React.ReactNode;\n style?: React.CSSProperties;\n}\n\n/**\n * Helper component to animate the height of the children when they change\n * It's done by rendering two versions of the passed children,\n * one hidden to measure the height and one visible to only changes after the height is measured.\n *\n * **IMPORTANT** Do not pass any components with effects (like data fetching), as they will trigger twice.\n */\nexport const AutoAnimateHeight: OverridableComponent<AutoAnimateHeightProps, HTMLDivElement> =\n forwardRef(\n (\n {\n as: Component = \"div\",\n children,\n style,\n animationDuration = \"quick\",\n animationEasing = \"normal\",\n onTransitionEnd,\n ...rest\n },\n ref,\n ) => {\n const rootRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([rootRef, ref]);\n const measurementRef = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState<{ height: number; shouldAnimate: boolean } | undefined>(\n undefined,\n );\n const [clonedChildren, setClonedChildren] = useState<React.ReactNode>(() =>\n cloneElement(<>{children}</>, {}),\n );\n\n useEffect(() => {\n if (!rootRef.current) return;\n if (!measurementRef.current) return;\n if (document.body.scrollHeight === 0) return;\n const currentMeasurement = measurementRef.current;\n const { height: newHeight } = currentMeasurement.getBoundingClientRect();\n\n // Listen for resize events on the measurement element\n // Keep the children in sync with the height\n // But don't animate it.\n let previouslyObservedHeight = newHeight;\n const resizeObserver = new ResizeObserver(() => {\n const { height: resizedHeight } = currentMeasurement.getBoundingClientRect();\n if (resizedHeight === previouslyObservedHeight) return;\n previouslyObservedHeight = resizedHeight;\n setHeight({ height: resizedHeight, shouldAnimate: false });\n });\n resizeObserver.observe(currentMeasurement); // This is cleaned up down below in the return functions\n\n // Set the new height when children changes\n setHeight({ height: newHeight, shouldAnimate: true });\n\n // Update children\n const nextClonedChildren = cloneElement(<>{children}</>, {});\n\n // When increasing in height update immediately so the new content is shown during the animation\n if (newHeight >= (height?.height ?? 0)) {\n setClonedChildren(nextClonedChildren);\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n // When decreasing in height, wait until the animation is done so that we don't get a sudden flash of empty content\n const currentRoot = rootRef.current;\n function onTransitionEndHandler(e: TransitionEvent) {\n if (e.propertyName !== \"height\") return;\n setClonedChildren(nextClonedChildren);\n }\n currentRoot.addEventListener(\"transitionend\", onTransitionEndHandler);\n return () => {\n resizeObserver.disconnect();\n currentRoot.removeEventListener(\"transitionend\", onTransitionEndHandler);\n };\n\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, [children]);\n\n return (\n <Component\n ref={mergedRef}\n onTransitionEnd={onTransitionEnd}\n style={{\n position: \"relative\",\n overflow: \"hidden\",\n height: height?.height ?? measurementRef.current?.getBoundingClientRect().height,\n transitionProperty: height?.shouldAnimate ? \"height\" : \"none\",\n transitionDuration: `var(--hds-micro-animation-duration-${animationDuration})`,\n transitionTimingFunction: `var(--hds-micro-animation-easing-${animationEasing})`,\n willChange: \"height\",\n ...style,\n }}\n {...rest}\n >\n <div\n aria-hidden\n ref={measurementRef}\n style={{\n position: \"absolute\",\n visibility: \"hidden\",\n }}\n >\n {children}\n </div>\n {clonedChildren}\n </Component>\n );\n },\n );\nAutoAnimateHeight.displayName = \"AutoAnimateHeight\";\n","import type { ComponentPropsWithRef, ElementType, FC, RefAttributes } from \"react\";\nimport * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * OverridableComponent makes the `as` prop available,\n * to be used to override the html element being used for a component\n *\n * Taken from digdir design system: https://github.com/digdir/designsystem/blob/main/packages/react/src/types/OverridableComponent.ts\n */\nexport type OverridableComponent<ComponentProps, Element extends HTMLElement> = {\n (props: ComponentProps & RefAttributes<Element>): ReturnType<FC>;\n\n <As extends ElementType>(\n props: {\n /** Override html element */\n as?: As;\n } & ComponentProps &\n Omit<ComponentPropsWithRef<As>, keyof ComponentProps>,\n ): ReturnType<FC>;\n} & Pick<FC, \"displayName\">;\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nexport function releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;A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cACX,KAAK;AAAA,cACL,OAAO;AAAA,gBACL,UAAU;AAAA,gBACV,YAAY;AAAA,cACd;AAAA,cAEC;AAAA;AAAA,UACH;AAAA,UACC;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACF,kBAAkB,cAAc;","names":["import_react","_a","_b"]}
1
+ {"version":3,"sources":["../../src/utilities/auto-animate-height.tsx","../../src/utils.ts"],"sourcesContent":["import { cloneElement, forwardRef, useEffect, useRef, useState } from \"react\";\nimport { useMergeRefs } from \"../utils\";\n\nexport interface AutoAnimateHeightProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Time of the animation, using the hedwig animation tokens\n * quick: 0.1s\n * normal: 0.3s\n * slow: 0.7s\n *\n * default is \"quick\"\n */\n animationDuration?: \"quick\" | \"normal\" | \"slow\";\n\n /**\n * Callback fired when animiation transition ends\n * Use this to do effects after resizing is done, e.g. scrolling to the element\n * using `element.scrollIntoView()`\n */\n onTransitionEnd?: () => void;\n\n /**\n * Which hedwig easing function to use, default is \"normal\"\n */\n animationEasing?: \"in\" | \"out\" | \"normal\";\n children: React.ReactNode;\n style?: React.CSSProperties;\n}\n\n/**\n * Helper component to animate the height of the children when they change\n * It's done by rendering two versions of the passed children,\n * one hidden to measure the height and one visible to only changes after the height is measured.\n *\n * **IMPORTANT** Do not pass any components with effects (like data fetching), as they will trigger twice.\n */\nexport const AutoAnimateHeight = forwardRef<HTMLDivElement, AutoAnimateHeightProps>(\n (\n {\n children,\n style,\n animationDuration = \"quick\",\n animationEasing = \"normal\",\n onTransitionEnd,\n ...rest\n },\n ref,\n ) => {\n const rootRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([rootRef, ref]);\n const measurementRef = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState<{ height: number; shouldAnimate: boolean } | undefined>(\n undefined,\n );\n const [clonedChildren, setClonedChildren] = useState<React.ReactNode>(() =>\n cloneElement(<>{children}</>, {}),\n );\n\n useEffect(() => {\n if (!rootRef.current) return;\n if (!measurementRef.current) return;\n if (document.body.scrollHeight === 0) return;\n const currentMeasurement = measurementRef.current;\n const { height: newHeight } = currentMeasurement.getBoundingClientRect();\n\n // Listen for resize events on the measurement element\n // Keep the children in sync with the height\n // But don't animate it.\n let previouslyObservedHeight = newHeight;\n const resizeObserver = new ResizeObserver(() => {\n const { height: resizedHeight } = currentMeasurement.getBoundingClientRect();\n if (resizedHeight === previouslyObservedHeight) return;\n previouslyObservedHeight = resizedHeight;\n setHeight({ height: resizedHeight, shouldAnimate: false });\n });\n resizeObserver.observe(currentMeasurement); // This is cleaned up down below in the return functions\n\n // Set the new height when children changes\n setHeight({ height: newHeight, shouldAnimate: true });\n\n // Update children\n const nextClonedChildren = cloneElement(<>{children}</>, {});\n\n // When increasing in height update immediately so the new content is shown during the animation\n if (newHeight >= (height?.height ?? 0)) {\n setClonedChildren(nextClonedChildren);\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n // When decreasing in height, wait until the animation is done so that we don't get a sudden flash of empty content\n const currentRoot = rootRef.current;\n function onTransitionEndHandler(e: TransitionEvent) {\n if (e.propertyName !== \"height\") return;\n setClonedChildren(nextClonedChildren);\n }\n currentRoot.addEventListener(\"transitionend\", onTransitionEndHandler);\n return () => {\n resizeObserver.disconnect();\n currentRoot.removeEventListener(\"transitionend\", onTransitionEndHandler);\n };\n\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, [children]);\n\n return (\n <div\n ref={mergedRef}\n onTransitionEnd={onTransitionEnd}\n style={{\n position: \"relative\",\n overflow: \"hidden\",\n height: height?.height ?? measurementRef.current?.getBoundingClientRect().height,\n transitionProperty: height?.shouldAnimate ? \"height\" : \"none\",\n transitionDuration: `var(--hds-micro-animation-duration-${animationDuration})`,\n transitionTimingFunction: `var(--hds-micro-animation-easing-${animationEasing})`,\n willChange: \"height\",\n ...style,\n }}\n {...rest}\n >\n <div\n aria-hidden\n ref={measurementRef}\n style={{\n position: \"absolute\",\n visibility: \"hidden\",\n }}\n >\n {children}\n </div>\n {clonedChildren}\n </div>\n );\n },\n);\nAutoAnimateHeight.displayName = \"AutoAnimateHeight\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nexport function releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAAsE;;;ACAtE,YAAuB;AACvB,mBAAiD;AAM1C,SAAS,aACd,MACoC;AACpC,SAAa,cAAQ,MAAM;AACzB,QAAI,KAAK,MAAM,CAAC,QAAQ,QAAQ,IAAI,GAAG;AACrC,aAAO;AAAA,IACT;AAEA,WAAO,CAAC,UAAU;AAChB,WAAK,QAAQ,CAAC,QAAQ;AACpB,YAAI,OAAO,QAAQ,YAAY;AAC7B,cAAI,KAAK;AAAA,QACX,WAAW,QAAQ,MAAM;AACvB,UAAC,IAAgD,UAAU;AAAA,QAC7D;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EAEF,GAAG,IAAI;AACT;;;AD6BmB;AAnBZ,IAAM,wBAAoB;AAAA,EAC/B,CACE,IAQA,QACG;AATH,iBACE;AAAA;AAAA,MACA;AAAA,MACA,oBAAoB;AAAA,MACpB,kB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E,iBAAiB;AAAU;AACjC,0BAAkB,kBAAkB;AAAA,MACtC;AACA,kBAAY,iBAAiB,iBAAiB,sBAAsB;AACpE,aAAO,MAAM;AACX,uBAAe,WAAW;AAC1B,oBAAY,oBAAoB,iBAAiB,sBAAsB;AAAA,MACzE;AAAA,IAGF,GAAG,CAAC,QAAQ,CAAC;AAEb,WACE;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL;AAAA,QACA,OAAO;AAAA,UACL,UAAU;AAAA,UACV,UAAU;AAAA,UACV,SAAQC,MAAA,iCAAQ,WAAR,OAAAA,OAAkBD,MAAA,eAAe,YAAf,gBAAAA,IAAwB,wBAAwB;AAAA,UAC1E,qBAAoB,iCAAQ,iBAAgB,WAAW;AAAA,UACvD,oBAAoB,sCAAsC,iBAAiB;AAAA,UAC3E,0BAA0B,oCAAoC,eAAe;AAAA,UAC7E,YAAY;AAAA,WACT;AAAA,SAED,OAbL;AAAA,QAeC;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,eAAW;AAAA,cACX,KAAK;AAAA,cACL,OAAO;AAAA,gBACL,UAAU;AAAA,gBACV,YAAY;AAAA,cACd;AAAA,cAEC;AAAA;AAAA,UACH;AAAA,UACC;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,kBAAkB,cAAc;","names":["import_react","_a","_b"]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  AutoAnimateHeight
3
- } from "../chunk-UXJIK76H.mjs";
4
- import "../chunk-JXA3B33M.mjs";
3
+ } from "../chunk-K3CBNVXC.mjs";
4
+ import "../chunk-DEX36MFK.mjs";
5
5
  import "../chunk-R4SQKVDQ.mjs";
6
6
  export {
7
7
  AutoAnimateHeight
@@ -91,14 +91,12 @@ var import_jsx_runtime = require("react/jsx-runtime");
91
91
  var AutoAnimateHeight = (0, import_react2.forwardRef)(
92
92
  (_a, ref) => {
93
93
  var _b = _a, {
94
- as: Component = "div",
95
94
  children,
96
95
  style,
97
96
  animationDuration = "quick",
98
97
  animationEasing = "normal",
99
98
  onTransitionEnd
100
99
  } = _b, rest = __objRest(_b, [
101
- "as",
102
100
  "children",
103
101
  "style",
104
102
  "animationDuration",
@@ -155,7 +153,7 @@ var AutoAnimateHeight = (0, import_react2.forwardRef)(
155
153
  };
156
154
  }, [children]);
157
155
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
158
- Component,
156
+ "div",
159
157
  __spreadProps(__spreadValues({
160
158
  ref: mergedRef,
161
159
  onTransitionEnd,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/index.ts","../../src/utilities/auto-animate-height.tsx","../../src/utils.ts"],"sourcesContent":["export { AutoAnimateHeight } from \"./auto-animate-height\";\nexport type * from \"./auto-animate-height\";\n","import { cloneElement, forwardRef, useEffect, useRef, useState } from \"react\";\nimport { useMergeRefs, type OverridableComponent } from \"../utils\";\n\nexport interface AutoAnimateHeightProps {\n /**\n * Time of the animation, using the hedwig animation tokens\n * quick: 0.1s\n * normal: 0.3s\n * slow: 0.7s\n *\n * default is \"quick\"\n */\n animationDuration?: \"quick\" | \"normal\" | \"slow\";\n\n /**\n * Callback fired when animiation transition ends\n * Use this to do effects after resizing is done, e.g. scrolling to the element\n * using `element.scrollIntoView()`\n */\n onTransitionEnd?: () => void;\n\n /**\n * Which hedwig easing function to use, default is \"normal\"\n */\n animationEasing?: \"in\" | \"out\" | \"normal\";\n children: React.ReactNode;\n style?: React.CSSProperties;\n}\n\n/**\n * Helper component to animate the height of the children when they change\n * It's done by rendering two versions of the passed children,\n * one hidden to measure the height and one visible to only changes after the height is measured.\n *\n * **IMPORTANT** Do not pass any components with effects (like data fetching), as they will trigger twice.\n */\nexport const AutoAnimateHeight: OverridableComponent<AutoAnimateHeightProps, HTMLDivElement> =\n forwardRef(\n (\n {\n as: Component = \"div\",\n children,\n style,\n animationDuration = \"quick\",\n animationEasing = \"normal\",\n onTransitionEnd,\n ...rest\n },\n ref,\n ) => {\n const rootRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([rootRef, ref]);\n const measurementRef = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState<{ height: number; shouldAnimate: boolean } | undefined>(\n undefined,\n );\n const [clonedChildren, setClonedChildren] = useState<React.ReactNode>(() =>\n cloneElement(<>{children}</>, {}),\n );\n\n useEffect(() => {\n if (!rootRef.current) return;\n if (!measurementRef.current) return;\n if (document.body.scrollHeight === 0) return;\n const currentMeasurement = measurementRef.current;\n const { height: newHeight } = currentMeasurement.getBoundingClientRect();\n\n // Listen for resize events on the measurement element\n // Keep the children in sync with the height\n // But don't animate it.\n let previouslyObservedHeight = newHeight;\n const resizeObserver = new ResizeObserver(() => {\n const { height: resizedHeight } = currentMeasurement.getBoundingClientRect();\n if (resizedHeight === previouslyObservedHeight) return;\n previouslyObservedHeight = resizedHeight;\n setHeight({ height: resizedHeight, shouldAnimate: false });\n });\n resizeObserver.observe(currentMeasurement); // This is cleaned up down below in the return functions\n\n // Set the new height when children changes\n setHeight({ height: newHeight, shouldAnimate: true });\n\n // Update children\n const nextClonedChildren = cloneElement(<>{children}</>, {});\n\n // When increasing in height update immediately so the new content is shown during the animation\n if (newHeight >= (height?.height ?? 0)) {\n setClonedChildren(nextClonedChildren);\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n // When decreasing in height, wait until the animation is done so that we don't get a sudden flash of empty content\n const currentRoot = rootRef.current;\n function onTransitionEndHandler(e: TransitionEvent) {\n if (e.propertyName !== \"height\") return;\n setClonedChildren(nextClonedChildren);\n }\n currentRoot.addEventListener(\"transitionend\", onTransitionEndHandler);\n return () => {\n resizeObserver.disconnect();\n currentRoot.removeEventListener(\"transitionend\", onTransitionEndHandler);\n };\n\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, [children]);\n\n return (\n <Component\n ref={mergedRef}\n onTransitionEnd={onTransitionEnd}\n style={{\n position: \"relative\",\n overflow: \"hidden\",\n height: height?.height ?? measurementRef.current?.getBoundingClientRect().height,\n transitionProperty: height?.shouldAnimate ? \"height\" : \"none\",\n transitionDuration: `var(--hds-micro-animation-duration-${animationDuration})`,\n transitionTimingFunction: `var(--hds-micro-animation-easing-${animationEasing})`,\n willChange: \"height\",\n ...style,\n }}\n {...rest}\n >\n <div\n aria-hidden\n ref={measurementRef}\n style={{\n position: \"absolute\",\n visibility: \"hidden\",\n }}\n >\n {children}\n </div>\n {clonedChildren}\n </Component>\n );\n },\n );\nAutoAnimateHeight.displayName = \"AutoAnimateHeight\";\n","import type { ComponentPropsWithRef, ElementType, FC, RefAttributes } from \"react\";\nimport * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * OverridableComponent makes the `as` prop available,\n * to be used to override the html element being used for a component\n *\n * Taken from digdir design system: https://github.com/digdir/designsystem/blob/main/packages/react/src/types/OverridableComponent.ts\n */\nexport type OverridableComponent<ComponentProps, Element extends HTMLElement> = {\n (props: ComponentProps & RefAttributes<Element>): ReturnType<FC>;\n\n <As extends ElementType>(\n props: {\n /** Override html element */\n as?: As;\n } & ComponentProps &\n Omit<ComponentPropsWithRef<As>, keyof ComponentProps>,\n ): ReturnType<FC>;\n} & Pick<FC, \"displayName\">;\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nexport function releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAAA,YAAC;AAAA;AAAA,cACC,eAAW;AAAA,cACX,KAAK;AAAA,cACL,OAAO;AAAA,gBACL,UAAU;AAAA,gBACV,YAAY;AAAA,cACd;AAAA,cAEC;AAAA;AAAA,UACH;AAAA,UACC;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACF,kBAAkB,cAAc;","names":["import_react","_a","_b"]}
1
+ {"version":3,"sources":["../../src/utilities/index.ts","../../src/utilities/auto-animate-height.tsx","../../src/utils.ts"],"sourcesContent":["export { AutoAnimateHeight } from \"./auto-animate-height\";\nexport type * from \"./auto-animate-height\";\n","import { cloneElement, forwardRef, useEffect, useRef, useState } from \"react\";\nimport { useMergeRefs } from \"../utils\";\n\nexport interface AutoAnimateHeightProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Time of the animation, using the hedwig animation tokens\n * quick: 0.1s\n * normal: 0.3s\n * slow: 0.7s\n *\n * default is \"quick\"\n */\n animationDuration?: \"quick\" | \"normal\" | \"slow\";\n\n /**\n * Callback fired when animiation transition ends\n * Use this to do effects after resizing is done, e.g. scrolling to the element\n * using `element.scrollIntoView()`\n */\n onTransitionEnd?: () => void;\n\n /**\n * Which hedwig easing function to use, default is \"normal\"\n */\n animationEasing?: \"in\" | \"out\" | \"normal\";\n children: React.ReactNode;\n style?: React.CSSProperties;\n}\n\n/**\n * Helper component to animate the height of the children when they change\n * It's done by rendering two versions of the passed children,\n * one hidden to measure the height and one visible to only changes after the height is measured.\n *\n * **IMPORTANT** Do not pass any components with effects (like data fetching), as they will trigger twice.\n */\nexport const AutoAnimateHeight = forwardRef<HTMLDivElement, AutoAnimateHeightProps>(\n (\n {\n children,\n style,\n animationDuration = \"quick\",\n animationEasing = \"normal\",\n onTransitionEnd,\n ...rest\n },\n ref,\n ) => {\n const rootRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([rootRef, ref]);\n const measurementRef = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState<{ height: number; shouldAnimate: boolean } | undefined>(\n undefined,\n );\n const [clonedChildren, setClonedChildren] = useState<React.ReactNode>(() =>\n cloneElement(<>{children}</>, {}),\n );\n\n useEffect(() => {\n if (!rootRef.current) return;\n if (!measurementRef.current) return;\n if (document.body.scrollHeight === 0) return;\n const currentMeasurement = measurementRef.current;\n const { height: newHeight } = currentMeasurement.getBoundingClientRect();\n\n // Listen for resize events on the measurement element\n // Keep the children in sync with the height\n // But don't animate it.\n let previouslyObservedHeight = newHeight;\n const resizeObserver = new ResizeObserver(() => {\n const { height: resizedHeight } = currentMeasurement.getBoundingClientRect();\n if (resizedHeight === previouslyObservedHeight) return;\n previouslyObservedHeight = resizedHeight;\n setHeight({ height: resizedHeight, shouldAnimate: false });\n });\n resizeObserver.observe(currentMeasurement); // This is cleaned up down below in the return functions\n\n // Set the new height when children changes\n setHeight({ height: newHeight, shouldAnimate: true });\n\n // Update children\n const nextClonedChildren = cloneElement(<>{children}</>, {});\n\n // When increasing in height update immediately so the new content is shown during the animation\n if (newHeight >= (height?.height ?? 0)) {\n setClonedChildren(nextClonedChildren);\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n // When decreasing in height, wait until the animation is done so that we don't get a sudden flash of empty content\n const currentRoot = rootRef.current;\n function onTransitionEndHandler(e: TransitionEvent) {\n if (e.propertyName !== \"height\") return;\n setClonedChildren(nextClonedChildren);\n }\n currentRoot.addEventListener(\"transitionend\", onTransitionEndHandler);\n return () => {\n resizeObserver.disconnect();\n currentRoot.removeEventListener(\"transitionend\", onTransitionEndHandler);\n };\n\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, [children]);\n\n return (\n <div\n ref={mergedRef}\n onTransitionEnd={onTransitionEnd}\n style={{\n position: \"relative\",\n overflow: \"hidden\",\n height: height?.height ?? measurementRef.current?.getBoundingClientRect().height,\n transitionProperty: height?.shouldAnimate ? \"height\" : \"none\",\n transitionDuration: `var(--hds-micro-animation-duration-${animationDuration})`,\n transitionTimingFunction: `var(--hds-micro-animation-easing-${animationEasing})`,\n willChange: \"height\",\n ...style,\n }}\n {...rest}\n >\n <div\n aria-hidden\n ref={measurementRef}\n style={{\n position: \"absolute\",\n visibility: \"hidden\",\n }}\n >\n {children}\n </div>\n {clonedChildren}\n </div>\n );\n },\n);\nAutoAnimateHeight.displayName = \"AutoAnimateHeight\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nexport function releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAAsE;;;ACAtE,YAAuB;AACvB,mBAAiD;AAM1C,SAAS,aACd,MACoC;AACpC,SAAa,cAAQ,MAAM;AACzB,QAAI,KAAK,MAAM,CAAC,QAAQ,QAAQ,IAAI,GAAG;AACrC,aAAO;AAAA,IACT;AAEA,WAAO,CAAC,UAAU;AAChB,WAAK,QAAQ,CAAC,QAAQ;AACpB,YAAI,OAAO,QAAQ,YAAY;AAC7B,cAAI,KAAK;AAAA,QACX,WAAW,QAAQ,MAAM;AACvB,UAAC,IAAgD,UAAU;AAAA,QAC7D;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EAEF,GAAG,IAAI;AACT;;;AD6B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AAM;AACX,yBAAe,WAAW;AAAA,QAC5B;AAAA,MACF;AAGA,YAAM,cAAc,QAAQ;AAC5B,eAAS,uBAAuB,GAAoB;AAClD,YAAI,EAAE,iBAAiB;AAAU;AACjC,0BAAkB,kBAAkB;AAAA,MACtC;AACA,kBAAY,iBAAiB,iBAAiB,sBAAsB;AACpE,aAAO,MAAM;AACX,uBAAe,WAAW;AAC1B,oBAAY,oBAAoB,iBAAiB,sBAAsB;AAAA,MACzE;AAAA,IAGF,GAAG,CAAC,QAAQ,CAAC;AAEb,WACE;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL;AAAA,QACA,OAAO;AAAA,UACL,UAAU;AAAA,UACV,UAAU;AAAA,UACV,SAAQC,MAAA,iCAAQ,WAAR,OAAAA,OAAkBD,MAAA,eAAe,YAAf,gBAAAA,IAAwB,wBAAwB;AAAA,UAC1E,qBAAoB,iCAAQ,iBAAgB,WAAW;AAAA,UACvD,oBAAoB,sCAAsC,iBAAiB;AAAA,UAC3E,0BAA0B,oCAAoC,eAAe;AAAA,UAC7E,YAAY;AAAA,WACT;AAAA,SAED,OAbL;AAAA,QAeC;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,eAAW;AAAA,cACX,KAAK;AAAA,cACL,OAAO;AAAA,gBACL,UAAU;AAAA,gBACV,YAAY;AAAA,cACd;AAAA,cAEC;AAAA;AAAA,UACH;AAAA,UACC;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,kBAAkB,cAAc;","names":["import_react","_a","_b"]}
@@ -1,8 +1,8 @@
1
1
  import "../chunk-DZNH5JHY.mjs";
2
2
  import {
3
3
  AutoAnimateHeight
4
- } from "../chunk-UXJIK76H.mjs";
5
- import "../chunk-JXA3B33M.mjs";
4
+ } from "../chunk-K3CBNVXC.mjs";
5
+ import "../chunk-DEX36MFK.mjs";
6
6
  import "../chunk-R4SQKVDQ.mjs";
7
7
  export {
8
8
  AutoAnimateHeight
package/dist/utils.d.mts CHANGED
@@ -3,4 +3,3 @@ export { useResize } from './_tsup-dts-rollup';
3
3
  export { useHydrated } from './_tsup-dts-rollup';
4
4
  export { focusTrap } from './_tsup-dts-rollup';
5
5
  export { releaseFocusTrap } from './_tsup-dts-rollup';
6
- export { OverridableComponent } from './_tsup-dts-rollup';
package/dist/utils.d.ts CHANGED
@@ -3,4 +3,3 @@ export { useResize } from './_tsup-dts-rollup';
3
3
  export { useHydrated } from './_tsup-dts-rollup';
4
4
  export { focusTrap } from './_tsup-dts-rollup';
5
5
  export { releaseFocusTrap } from './_tsup-dts-rollup';
6
- export { OverridableComponent } from './_tsup-dts-rollup';
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils.ts"],"sourcesContent":["import type { ComponentPropsWithRef, ElementType, FC, RefAttributes } from \"react\";\nimport * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * OverridableComponent makes the `as` prop available,\n * to be used to override the html element being used for a component\n *\n * Taken from digdir design system: https://github.com/digdir/designsystem/blob/main/packages/react/src/types/OverridableComponent.ts\n */\nexport type OverridableComponent<ComponentProps, Element extends HTMLElement> = {\n (props: ComponentProps & RefAttributes<Element>): ReturnType<FC>;\n\n <As extends ElementType>(\n props: {\n /** Override html element */\n as?: As;\n } & ComponentProps &\n Omit<ComponentPropsWithRef<As>, keyof ComponentProps>,\n ): ReturnType<FC>;\n} & Pick<FC, \"displayName\">;\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nexport function releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,YAAuB;AACvB,mBAAiD;AAwB1C,SAAS,aACd,MACoC;AACpC,SAAa,cAAQ,MAAM;AACzB,QAAI,KAAK,MAAM,CAAC,QAAQ,QAAQ,IAAI,GAAG;AACrC,aAAO;AAAA,IACT;AAEA,WAAO,CAAC,UAAU;AAChB,WAAK,QAAQ,CAAC,QAAQ;AACpB,YAAI,OAAO,QAAQ,YAAY;AAC7B,cAAI,KAAK;AAAA,QACX,WAAW,QAAQ,MAAM;AACvB,UAAC,IAAgD,UAAU;AAAA,QAC7D;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EAEF,GAAG,IAAI;AACT;AAEO,SAAS,UACd,KACmC;AACnC,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAiB,CAAC;AAC5C,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAAiB,CAAC;AAC9C,QAAM,mBAAe,0BAAY,MAAM;AApDzC;AAqDI,SAAI,2BAAK,aAAY,MAAM;AACzB,gBAAS,sCAAK,YAAL,mBAAc,gBAAd,YAA6B,CAAC;AACvC,iBAAU,sCAAK,YAAL,mBAAc,iBAAd,YAA8B,CAAC;AAAA,IAC3C;AAAA,EACF,GAAG,CAAC,GAAG,CAAC;AACR,8BAAU,MAAM;AACd,WAAO,iBAAiB,QAAQ,YAAY;AAC5C,WAAO,iBAAiB,UAAU,YAAY;AAC9C,WAAO,MAAM;AACX,aAAO,oBAAoB,QAAQ,YAAY;AAC/C,aAAO,oBAAoB,UAAU,YAAY;AAAA,IACnD;AAAA,EACF,GAAG,CAAC,KAAK,YAAY,CAAC;AACtB,8BAAU,MAAM;AACd,iBAAa;AAAA,EAEf,GAAG,CAAC,CAAC;AACL,SAAO,EAAE,OAAO,OAAO;AACzB;AAEA,SAAS,YAAY;AAEnB,SAAO,MAAM;AAAA,EAAC;AAChB;AAEO,SAAS,cAAc;AAC5B,SAAa;AAAA,IACX;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AACF;AAaO,SAAS,UAAU,SAAsB;AAjGhD;AAmGE,MAAI,YAAY,SAAS;AAAM,WAAO,MAAM;AAAA,IAAC;AAE7C,MAAI,gBAA+B,CAAC;AACpC,WAAS,KAAyB,SAAS,IAAI,KAAK,GAAG,eAAe;AACpE,QAAI,OAAO,SAAS;AAAM;AAE1B,eAAW,YAAW,cAAG,kBAAH,mBAAkB,aAAlB,YAA8B,CAAC,GAAG;AACtD,UAAI,YAAY;AAAI;AACpB,UAAI,EAAE,mBAAmB;AAAc;AACvC,UAAI,QAAQ,aAAa,OAAO;AAAG;AAEnC,cAAQ,aAAa,SAAS,MAAM;AACpC,oBAAc,KAAK,OAAO;AAAA,IAC5B;AAAA,EACF;AAEA,SAAO,MAAM;AACX,qBAAiB,aAAa;AAC9B,oBAAgB,CAAC;AAAA,EACnB;AACF;AAKO,SAAS,iBAAiB,eAAsC;AACrE,aAAW,MAAM,eAAe;AAC9B,OAAG,gBAAgB,OAAO;AAAA,EAC5B;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/utils.ts"],"sourcesContent":["import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nexport function releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,mBAAiD;AAM1C,SAAS,aACd,MACoC;AACpC,SAAa,cAAQ,MAAM;AACzB,QAAI,KAAK,MAAM,CAAC,QAAQ,QAAQ,IAAI,GAAG;AACrC,aAAO;AAAA,IACT;AAEA,WAAO,CAAC,UAAU;AAChB,WAAK,QAAQ,CAAC,QAAQ;AACpB,YAAI,OAAO,QAAQ,YAAY;AAC7B,cAAI,KAAK;AAAA,QACX,WAAW,QAAQ,MAAM;AACvB,UAAC,IAAgD,UAAU;AAAA,QAC7D;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EAEF,GAAG,IAAI;AACT;AAEO,SAAS,UACd,KACmC;AACnC,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAiB,CAAC;AAC5C,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAAiB,CAAC;AAC9C,QAAM,mBAAe,0BAAY,MAAM;AAjCzC;AAkCI,SAAI,2BAAK,aAAY,MAAM;AACzB,gBAAS,sCAAK,YAAL,mBAAc,gBAAd,YAA6B,CAAC;AACvC,iBAAU,sCAAK,YAAL,mBAAc,iBAAd,YAA8B,CAAC;AAAA,IAC3C;AAAA,EACF,GAAG,CAAC,GAAG,CAAC;AACR,8BAAU,MAAM;AACd,WAAO,iBAAiB,QAAQ,YAAY;AAC5C,WAAO,iBAAiB,UAAU,YAAY;AAC9C,WAAO,MAAM;AACX,aAAO,oBAAoB,QAAQ,YAAY;AAC/C,aAAO,oBAAoB,UAAU,YAAY;AAAA,IACnD;AAAA,EACF,GAAG,CAAC,KAAK,YAAY,CAAC;AACtB,8BAAU,MAAM;AACd,iBAAa;AAAA,EAEf,GAAG,CAAC,CAAC;AACL,SAAO,EAAE,OAAO,OAAO;AACzB;AAEA,SAAS,YAAY;AAEnB,SAAO,MAAM;AAAA,EAAC;AAChB;AAEO,SAAS,cAAc;AAC5B,SAAa;AAAA,IACX;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AACF;AAaO,SAAS,UAAU,SAAsB;AA9EhD;AAgFE,MAAI,YAAY,SAAS;AAAM,WAAO,MAAM;AAAA,IAAC;AAE7C,MAAI,gBAA+B,CAAC;AACpC,WAAS,KAAyB,SAAS,IAAI,KAAK,GAAG,eAAe;AACpE,QAAI,OAAO,SAAS;AAAM;AAE1B,eAAW,YAAW,cAAG,kBAAH,mBAAkB,aAAlB,YAA8B,CAAC,GAAG;AACtD,UAAI,YAAY;AAAI;AACpB,UAAI,EAAE,mBAAmB;AAAc;AACvC,UAAI,QAAQ,aAAa,OAAO;AAAG;AAEnC,cAAQ,aAAa,SAAS,MAAM;AACpC,oBAAc,KAAK,OAAO;AAAA,IAC5B;AAAA,EACF;AAEA,SAAO,MAAM;AACX,qBAAiB,aAAa;AAC9B,oBAAgB,CAAC;AAAA,EACnB;AACF;AAKO,SAAS,iBAAiB,eAAsC;AACrE,aAAW,MAAM,eAAe;AAC9B,OAAG,gBAAgB,OAAO;AAAA,EAC5B;AACF;","names":[]}
package/dist/utils.mjs CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  useHydrated,
5
5
  useMergeRefs,
6
6
  useResize
7
- } from "./chunk-JXA3B33M.mjs";
7
+ } from "./chunk-DEX36MFK.mjs";
8
8
  import "./chunk-R4SQKVDQ.mjs";
9
9
  export {
10
10
  focusTrap,
@@ -60,11 +60,12 @@ var import_typed_classname2 = require("@postenbring/hedwig-css/typed-classname")
60
60
  // src/box/box.tsx
61
61
  var import_react = require("react");
62
62
  var import_typed_classname = require("@postenbring/hedwig-css/typed-classname");
63
+ var import_react_slot = require("@radix-ui/react-slot");
63
64
  var import_jsx_runtime = require("react/jsx-runtime");
64
65
  var Box = (0, import_react.forwardRef)(
65
66
  (_a, ref) => {
66
67
  var _b = _a, {
67
- as: Component = "div",
68
+ asChild,
68
69
  variant,
69
70
  closeable = false,
70
71
  onClose: onCloseProp,
@@ -73,7 +74,7 @@ var Box = (0, import_react.forwardRef)(
73
74
  children,
74
75
  className
75
76
  } = _b, rest = __objRest(_b, [
76
- "as",
77
+ "asChild",
77
78
  "variant",
78
79
  "closeable",
79
80
  "onClose",
@@ -94,6 +95,7 @@ var Box = (0, import_react.forwardRef)(
94
95
  }
95
96
  }, []);
96
97
  const closed = closedProp != null ? closedProp : closedState;
98
+ const Component = asChild ? import_react_slot.Slot : "div";
97
99
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
98
100
  Component,
99
101
  __spreadProps(__spreadValues({
@@ -107,7 +109,7 @@ var Box = (0, import_react.forwardRef)(
107
109
  }, rest), {
108
110
  children: [
109
111
  closeable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BoxCloseButton, __spreadValues({ onClick: onClose }, closeButtonProps)) : null,
110
- children
112
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_slot.Slottable, { children })
111
113
  ]
112
114
  })
113
115
  );
@@ -146,57 +148,43 @@ var WarningBanner = (0, import_react2.forwardRef)(
146
148
  }
147
149
  );
148
150
  WarningBanner.displayName = "WarningBanner";
149
- var WarningBannerTitle = (0, import_react2.forwardRef)(
150
- (_a, ref) => {
151
- var _b = _a, {
152
- variant,
153
- as: Component = variant === "expandable" ? "button" : "p",
154
- children,
155
- className
156
- } = _b, rest = __objRest(_b, [
157
- "variant",
158
- "as",
159
- "children",
160
- "className"
161
- ]);
162
- const [open, setOpen] = (0, import_react2.useState)(false);
163
- if (variant === "expandable") {
164
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
165
- Component,
166
- __spreadProps(__spreadValues({
167
- className: (0, import_typed_classname2.clsx)(
168
- "hds-warning-banner__title",
169
- "hds-warning-banner__title-trigger",
170
- { "hds-warning-banner--closed": !open },
171
- className
172
- ),
173
- onClick: () => {
174
- setOpen(!open);
175
- },
176
- ref,
177
- type: "button"
178
- }, rest), {
179
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children })
180
- })
181
- );
182
- }
151
+ var WarningBannerTitle = (0, import_react2.forwardRef)((_a, ref) => {
152
+ var _b = _a, { variant, children, className } = _b, rest = __objRest(_b, ["variant", "children", "className"]);
153
+ const [open, setOpen] = (0, import_react2.useState)(false);
154
+ if (variant === "expandable") {
183
155
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
184
- Component,
185
- __spreadProps(__spreadValues({
186
- className: (0, import_typed_classname2.clsx)("hds-warning-banner__title", className),
187
- ref
188
- }, rest), {
189
- children
156
+ "button",
157
+ __spreadProps(__spreadValues({}, rest), {
158
+ className: (0, import_typed_classname2.clsx)(
159
+ "hds-warning-banner__title",
160
+ "hds-warning-banner__title-trigger",
161
+ { "hds-warning-banner--closed": !open },
162
+ className
163
+ ),
164
+ onClick: () => {
165
+ setOpen((prev) => !prev);
166
+ },
167
+ ref,
168
+ type: "button",
169
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children })
190
170
  })
191
171
  );
192
172
  }
193
- );
173
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
174
+ "p",
175
+ __spreadProps(__spreadValues({}, rest), {
176
+ className: (0, import_typed_classname2.clsx)("hds-warning-banner__title", className),
177
+ ref,
178
+ children
179
+ })
180
+ );
181
+ });
194
182
  WarningBannerTitle.displayName = "WarningBannerTitle";
195
183
  var WarningBannerDescription = (0, import_react2.forwardRef)(
196
184
  (_a, ref) => {
197
- var _b = _a, { as: Component = "p", className } = _b, rest = __objRest(_b, ["as", "className"]);
185
+ var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
198
186
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
199
- Component,
187
+ "p",
200
188
  __spreadValues({
201
189
  className: (0, import_typed_classname2.clsx)("hds-warning-banner__description", className),
202
190
  ref
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/warning-banner/index.tsx","../../src/warning-banner/warning-banner.tsx","../../src/box/box.tsx","../../src/box/index.tsx"],"sourcesContent":["export { WarningBanner } from \"./warning-banner\";\nexport type * from \"./warning-banner\";\n","import type { ReactNode } from \"react\";\nimport { forwardRef, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport type { OverridableComponent } from \"../utils\";\nimport { Box } from \"../box\";\n\nexport interface WarningBannerProps {\n title: ReactNode;\n description?: ReactNode;\n}\n\nexport const WarningBanner: OverridableComponent<WarningBannerProps, HTMLDivElement> = forwardRef(\n ({ title, description, className, ...rest }, ref) => {\n const expandable = !!description;\n return (\n <Box {...rest} className={clsx(\"hds-warning-banner\", className as undefined)} ref={ref}>\n <WarningBannerTitle variant={expandable ? \"expandable\" : \"default\"}>\n {title}\n </WarningBannerTitle>\n {expandable ? <WarningBannerDescription>{description}</WarningBannerDescription> : null}\n </Box>\n );\n },\n);\nWarningBanner.displayName = \"WarningBanner\";\n\ninterface WarningBannerTitleProps {\n variant: \"expandable\" | \"default\";\n children: ReactNode;\n}\n\nconst WarningBannerTitle: OverridableComponent<WarningBannerTitleProps, HTMLDivElement> =\n forwardRef(\n (\n {\n variant,\n as: Component = variant === \"expandable\" ? \"button\" : \"p\",\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [open, setOpen] = useState<boolean>(false);\n if (variant === \"expandable\") {\n return (\n <Component\n className={clsx(\n \"hds-warning-banner__title\",\n \"hds-warning-banner__title-trigger\",\n { \"hds-warning-banner--closed\": !open },\n className as undefined,\n )}\n onClick={() => {\n setOpen(!open);\n }}\n ref={ref}\n type=\"button\"\n {...rest}\n >\n <span>{children}</span>\n </Component>\n );\n }\n return (\n <Component\n className={clsx(\"hds-warning-banner__title\", className as undefined)}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n );\nWarningBannerTitle.displayName = \"WarningBannerTitle\";\n\nconst WarningBannerDescription: OverridableComponent<object, HTMLParagraphElement> = forwardRef(\n ({ as: Component = \"p\", className, ...rest }, ref) => {\n return (\n <Component\n className={clsx(\"hds-warning-banner__description\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nWarningBannerDescription.displayName = \"WarningBannerDescription\";\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport type { OverridableComponent } from \"../utils\";\n\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n variant?: \"light-grey\" | \"lighter\" | \"white\" | \"warning\";\n children?: React.ReactNode;\n\n /**\n * If `true`, a close button will be shown.\n * Use when you want to control the close button using the BoxCloseButton component.\n */\n closeable?: boolean;\n\n /**\n * Callback fired when the component requests to be closed.\n * If not set, the component will be closed without any user interaction.\n *\n * If set, and the handler returns non-true value, the component will not be closed.\n * Use this if you want to control the closing of the component, using the `closed` prop\n *\n * If set, and the handler returns the true, the component will be closed.\n * Use this with `window.confirm()` to ask the user to confirm closing the component.\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents -- It's fine, I want to have the boolean in the type\n onClose?: () => boolean | unknown;\n\n /**\n * If `true`, the box will be closed and hidden from view\n */\n closed?: boolean;\n\n /**\n * Props applied to the close button element.\n */\n closeButtonProps?: BoxCloseButtonProps;\n}\n\nexport const Box: OverridableComponent<BoxProps, HTMLDivElement> = forwardRef(\n (\n {\n as: Component = \"div\",\n variant,\n closeable = false,\n onClose: onCloseProp,\n closed: closedProp,\n closeButtonProps,\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [closedState, setClosedState] = useState(false);\n const onClose = useCallback(() => {\n if (onCloseProp) {\n const result = onCloseProp();\n if (result === true) {\n setClosedState(true);\n }\n } else {\n setClosedState(true);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, []);\n const closed = closedProp ?? closedState;\n\n return (\n <Component\n className={clsx(\n \"hds-box\",\n variant && `hds-box--${variant}`,\n { \"hds-box--closed\": closed },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {closeable ? <BoxCloseButton onClick={onClose} {...closeButtonProps} /> : null}\n {children}\n </Component>\n );\n },\n);\nBox.displayName = \"Box\";\n\nexport type BoxCloseButtonProps = Omit<React.HTMLAttributes<HTMLButtonElement>, \"children\">;\nexport const BoxCloseButton = forwardRef<HTMLButtonElement, BoxCloseButtonProps>(\n ({ className, ...rest }, ref) => {\n return (\n <button\n className={clsx(\"hds-box__close-button\", className as undefined)}\n ref={ref}\n type=\"button\"\n {...rest}\n />\n );\n },\n);\nBoxCloseButton.displayName = \"Box.CloseButton\";\n","import { Box, BoxCloseButton } from \"./box\";\n\nconst BoxComponent = Box as typeof Box & {\n CloseButton: typeof BoxCloseButton;\n};\nBoxComponent.CloseButton = BoxCloseButton;\n\nexport { BoxComponent as Box, BoxCloseButton };\n\nexport type * from \"./box\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAAA,gBAAqC;AACrC,IAAAC,0BAAqB;;;ACFrB,mBAAkD;AAClD,6BAAqB;AAmEf;AA9BC,IAAM,UAAsD;AAAA,EACjE,CACE,IAWA,QACG;AAZH,iBACE;AAAA,UAAI,YAAY;AAAA,MAChB;AAAA,MACA,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IAhDN,IAwCI,IASK,iBATL,IASK;AAAA,MARH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF,UAAM,CAAC,aAAa,cAAc,QAAI,uBAAS,KAAK;AACpD,UAAM,cAAU,0BAAY,MAAM;AAChC,UAAI,aAAa;AACf,cAAM,SAAS,YAAY;AAC3B,YAAI,WAAW,MAAM;AACnB,yBAAe,IAAI;AA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AAe,WAAW;AAAA,MACtD;AAAA,MACA;AAAA,IAtCR,IAkCM,IAKK,iBALL,IAKK;AAAA,MAJH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF,UAAM,CAAC,MAAM,OAAO,QAAI,wBAAkB,KAAK;AAC/C,QAAI,YAAY,cAAc;AAC5B,aACE;AAAA,QAAC;AAAA;AAAA,UACC,eAAW;AAAA,YACT;AAAA,YACA;AAAA,YACA,EAAE,8BAA8B,CAAC,KAAK;AAAA,YACtC;AAAA,UACF;AAAA,UACA,SAAS,MAAM;AACb,oBAAQ,CAAC,IAAI;AAAA,UACf;AAAA,UACA;AAAA,UACA,MAAK;AAAA,WACD,OAZL;AAAA,UAcC,uDAAC,UAAM,UAAS;AAAA;AAAA,MAClB;AAAA,IAEJ;AACA,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,8BAAK,6BAA6B,SAAsB;AAAA,QACnE;AAAA,SACI,OAHL;AAAA,QAKE;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACF,mBAAmB,cAAc;AAEjC,IAAM,+BAA+E;AAAA,EACnF,CAAC,IAA6C,QAAQ;AAArD,iBAAE,MAAI,YAAY,KAAK,UA9E1B,IA8EG,IAAqC,iBAArC,IAAqC,CAAnC,MAAqB;AACtB,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,8BAAK,mCAAmC,SAAsB;AAAA,QACzE;AAAA,SACI;AAAA,IACN;AAAA,EAEJ;AACF;AACA,yBAAyB,cAAc;","names":["import_react","import_typed_classname","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../../src/warning-banner/index.tsx","../../src/warning-banner/warning-banner.tsx","../../src/box/box.tsx","../../src/box/index.tsx"],"sourcesContent":["export { WarningBanner } from \"./warning-banner\";\nexport type * from \"./warning-banner\";\n","import type { ReactNode } from \"react\";\nimport React, { forwardRef, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Box } from \"../box\";\n\nexport interface WarningBannerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n title: ReactNode;\n description?: ReactNode;\n}\n\nexport const WarningBanner = forwardRef<HTMLDivElement, WarningBannerProps>(\n ({ title, description, className, ...rest }, ref) => {\n const expandable = !!description;\n return (\n <Box {...rest} className={clsx(\"hds-warning-banner\", className as undefined)} ref={ref}>\n <WarningBannerTitle variant={expandable ? \"expandable\" : \"default\"}>\n {title}\n </WarningBannerTitle>\n {expandable ? <WarningBannerDescription>{description}</WarningBannerDescription> : null}\n </Box>\n );\n },\n);\nWarningBanner.displayName = \"WarningBanner\";\n\ntype WarningBannerTitleProps =\n | ({ variant: \"expandable\" } & React.ButtonHTMLAttributes<HTMLButtonElement>)\n | ({ variant: \"default\" } & React.HTMLAttributes<HTMLParagraphElement>);\n\nconst WarningBannerTitle = forwardRef<\n HTMLButtonElement | HTMLParagraphElement,\n WarningBannerTitleProps\n>(({ variant, children, className, ...rest }, ref) => {\n const [open, setOpen] = useState<boolean>(false);\n if (variant === \"expandable\") {\n return (\n <button\n {...(rest as React.ButtonHTMLAttributes<HTMLButtonElement>)}\n className={clsx(\n \"hds-warning-banner__title\",\n \"hds-warning-banner__title-trigger\",\n { \"hds-warning-banner--closed\": !open },\n className as undefined,\n )}\n onClick={() => {\n setOpen((prev) => !prev);\n }}\n ref={ref as React.Ref<HTMLButtonElement>}\n type=\"button\"\n >\n <span>{children}</span>\n </button>\n );\n }\n return (\n <p\n {...(rest as React.HTMLAttributes<HTMLParagraphElement>)}\n className={clsx(\"hds-warning-banner__title\", className as undefined)}\n ref={ref as React.Ref<HTMLParagraphElement>}\n >\n {children}\n </p>\n );\n});\nWarningBannerTitle.displayName = \"WarningBannerTitle\";\n\ntype WarningBannerDescriptionProps = React.HTMLAttributes<HTMLParagraphElement>;\nconst WarningBannerDescription = forwardRef<HTMLParagraphElement, WarningBannerDescriptionProps>(\n ({ className, ...rest }, ref) => {\n return (\n <p\n className={clsx(\"hds-warning-banner__description\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nWarningBannerDescription.displayName = \"WarningBannerDescription\";\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\n\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n children?: React.ReactNode;\n\n /**\n * Color variant of the box\n *\n * @default \"light-grey\"\n */\n variant?: \"light-grey\" | \"lighter\" | \"white\" | \"warning\";\n\n /**\n * If `true`, a close button will be shown.\n * Use when you want to control the close button using the BoxCloseButton component.\n *\n * @default false\n */\n closeable?: boolean;\n\n /**\n * Callback fired when the component requests to be closed.\n * If not set, the component will be closed without any user interaction.\n *\n * If set, and the handler returns non-true value, the component will not be closed.\n * Use this if you want to control the closing of the component, using the `closed` prop\n *\n * If set, and the handler returns the true, the component will be closed.\n * Use this with `window.confirm()` to ask the user to confirm closing the component.\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents -- It's fine, I want to have the boolean in the type\n onClose?: () => boolean | unknown;\n\n /**\n * If `true`, the box will be closed and hidden from view\n */\n closed?: boolean;\n\n /**\n * Props applied to the close button element.\n */\n closeButtonProps?: BoxCloseButtonProps;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n (\n {\n asChild,\n variant,\n closeable = false,\n onClose: onCloseProp,\n closed: closedProp,\n closeButtonProps,\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [closedState, setClosedState] = useState(false);\n const onClose = useCallback(() => {\n if (onCloseProp) {\n const result = onCloseProp();\n if (result === true) {\n setClosedState(true);\n }\n } else {\n setClosedState(true);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, []);\n const closed = closedProp ?? closedState;\n const Component = asChild ? Slot : \"div\";\n\n return (\n <Component\n className={clsx(\n \"hds-box\",\n variant && `hds-box--${variant}`,\n { \"hds-box--closed\": closed },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {closeable ? <BoxCloseButton onClick={onClose} {...closeButtonProps} /> : null}\n <Slottable>{children}</Slottable>\n </Component>\n );\n },\n);\nBox.displayName = \"Box\";\n\nexport type BoxCloseButtonProps = Omit<React.HTMLAttributes<HTMLButtonElement>, \"children\">;\nexport const BoxCloseButton = forwardRef<HTMLButtonElement, BoxCloseButtonProps>(\n ({ className, ...rest }, ref) => {\n return (\n <button\n className={clsx(\"hds-box__close-button\", className as undefined)}\n ref={ref}\n type=\"button\"\n {...rest}\n />\n );\n },\n);\nBoxCloseButton.displayName = \"Box.CloseButton\";\n","import { Box, BoxCloseButton } from \"./box\";\n\nconst BoxComponent = Box as typeof Box & {\n CloseButton: typeof BoxCloseButton;\n};\nBoxComponent.CloseButton = BoxCloseButton;\n\nexport { BoxComponent as Box, BoxCloseButton };\n\nexport type * from \"./box\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAAA,gBAA4C;AAC5C,IAAAC,0BAAqB;;;ACFrB,mBAAkD;AAClD,6BAAqB;AACrB,wBAAgC;AAkF1B;AA/BC,IAAM,UAAM;AAAA,EACjB,CACE,IAWA,QACG;AAZH,iBACE;AAAA;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IA/DN,IAuDI,IASK,iBATL,IASK;AAAA,MARH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF,UAAM,CAAC,aAAa,cAAc,QAAI,uBAAS,KAAK;AACpD,UAAM,cAAU,0BAAY,MAAM;AAChC,UAAI,aAAa;AACf,cAAM,SAAS,YAAY;AAC3B,YAAI,WAAW,MAAM;AAC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qB,0BAGzB,CAAC,IAA2C,QAAQ;AAAnD,eAAE,WAAS,UAAU,UAhCxB,IAgCG,IAAmC,iBAAnC,IAAmC,CAAjC,WAAS,YAAU;AACtB,QAAM,CAAC,MAAM,OAAO,QAAI,wBAAkB,KAAK;AAC/C,MAAI,YAAY,cAAc;AAC5B,WACE;AAAA,MAAC;AAAA,uCACM,OADN;AAAA,QAEC,eAAW;AAAA,UACT;AAAA,UACA;AAAA,UACA,EAAE,8BAA8B,CAAC,KAAK;AAAA,UACtC;AAAA,QACF;AAAA,QACA,SAAS,MAAM;AACb,kBAAQ,CAAC,SAAS,CAAC,IAAI;AAAA,QACzB;AAAA,QACA;AAAA,QACA,MAAK;AAAA,QAEL,uDAAC,UAAM,UAAS;AAAA;AAAA,IAClB;AAAA,EAEJ;AACA,SACE;AAAA,IAAC;AAAA,qCACM,OADN;AAAA,MAEC,eAAW,8BAAK,6BAA6B,SAAsB;AAAA,MACnE;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ,CAAC;AACD,mBAAmB,cAAc;AAGjC,IAAM,+BAA2B;AAAA,EAC/B,CAAC,IAAwB,QAAQ;AAAhC,iBAAE,YApEL,IAoEG,IAAgB,iBAAhB,IAAgB,CAAd;AACD,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,8BAAK,mCAAmC,SAAsB;AAAA,QACzE;AAAA,SACI;AAAA,IACN;AAAA,EAEJ;AACF;AACA,yBAAyB,cAAc;","names":["import_react","import_typed_classname","import_jsx_runtime"]}
@@ -1,9 +1,9 @@
1
1
  import "../chunk-3D2MWIEX.mjs";
2
2
  import {
3
3
  WarningBanner
4
- } from "../chunk-PUESATBQ.mjs";
5
- import "../chunk-NMMFIRLZ.mjs";
6
- import "../chunk-EGXM575K.mjs";
4
+ } from "../chunk-XC3UHH2U.mjs";
5
+ import "../chunk-3NL3TOZF.mjs";
6
+ import "../chunk-ENKVTAJB.mjs";
7
7
  import "../chunk-R4SQKVDQ.mjs";
8
8
  export {
9
9
  WarningBanner
@@ -58,11 +58,12 @@ var import_typed_classname2 = require("@postenbring/hedwig-css/typed-classname")
58
58
  // src/box/box.tsx
59
59
  var import_react = require("react");
60
60
  var import_typed_classname = require("@postenbring/hedwig-css/typed-classname");
61
+ var import_react_slot = require("@radix-ui/react-slot");
61
62
  var import_jsx_runtime = require("react/jsx-runtime");
62
63
  var Box = (0, import_react.forwardRef)(
63
64
  (_a, ref) => {
64
65
  var _b = _a, {
65
- as: Component = "div",
66
+ asChild,
66
67
  variant,
67
68
  closeable = false,
68
69
  onClose: onCloseProp,
@@ -71,7 +72,7 @@ var Box = (0, import_react.forwardRef)(
71
72
  children,
72
73
  className
73
74
  } = _b, rest = __objRest(_b, [
74
- "as",
75
+ "asChild",
75
76
  "variant",
76
77
  "closeable",
77
78
  "onClose",
@@ -92,6 +93,7 @@ var Box = (0, import_react.forwardRef)(
92
93
  }
93
94
  }, []);
94
95
  const closed = closedProp != null ? closedProp : closedState;
96
+ const Component = asChild ? import_react_slot.Slot : "div";
95
97
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
96
98
  Component,
97
99
  __spreadProps(__spreadValues({
@@ -105,7 +107,7 @@ var Box = (0, import_react.forwardRef)(
105
107
  }, rest), {
106
108
  children: [
107
109
  closeable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BoxCloseButton, __spreadValues({ onClick: onClose }, closeButtonProps)) : null,
108
- children
110
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_slot.Slottable, { children })
109
111
  ]
110
112
  })
111
113
  );
@@ -144,57 +146,43 @@ var WarningBanner = (0, import_react2.forwardRef)(
144
146
  }
145
147
  );
146
148
  WarningBanner.displayName = "WarningBanner";
147
- var WarningBannerTitle = (0, import_react2.forwardRef)(
148
- (_a, ref) => {
149
- var _b = _a, {
150
- variant,
151
- as: Component = variant === "expandable" ? "button" : "p",
152
- children,
153
- className
154
- } = _b, rest = __objRest(_b, [
155
- "variant",
156
- "as",
157
- "children",
158
- "className"
159
- ]);
160
- const [open, setOpen] = (0, import_react2.useState)(false);
161
- if (variant === "expandable") {
162
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
163
- Component,
164
- __spreadProps(__spreadValues({
165
- className: (0, import_typed_classname2.clsx)(
166
- "hds-warning-banner__title",
167
- "hds-warning-banner__title-trigger",
168
- { "hds-warning-banner--closed": !open },
169
- className
170
- ),
171
- onClick: () => {
172
- setOpen(!open);
173
- },
174
- ref,
175
- type: "button"
176
- }, rest), {
177
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children })
178
- })
179
- );
180
- }
149
+ var WarningBannerTitle = (0, import_react2.forwardRef)((_a, ref) => {
150
+ var _b = _a, { variant, children, className } = _b, rest = __objRest(_b, ["variant", "children", "className"]);
151
+ const [open, setOpen] = (0, import_react2.useState)(false);
152
+ if (variant === "expandable") {
181
153
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
182
- Component,
183
- __spreadProps(__spreadValues({
184
- className: (0, import_typed_classname2.clsx)("hds-warning-banner__title", className),
185
- ref
186
- }, rest), {
187
- children
154
+ "button",
155
+ __spreadProps(__spreadValues({}, rest), {
156
+ className: (0, import_typed_classname2.clsx)(
157
+ "hds-warning-banner__title",
158
+ "hds-warning-banner__title-trigger",
159
+ { "hds-warning-banner--closed": !open },
160
+ className
161
+ ),
162
+ onClick: () => {
163
+ setOpen((prev) => !prev);
164
+ },
165
+ ref,
166
+ type: "button",
167
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children })
188
168
  })
189
169
  );
190
170
  }
191
- );
171
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
172
+ "p",
173
+ __spreadProps(__spreadValues({}, rest), {
174
+ className: (0, import_typed_classname2.clsx)("hds-warning-banner__title", className),
175
+ ref,
176
+ children
177
+ })
178
+ );
179
+ });
192
180
  WarningBannerTitle.displayName = "WarningBannerTitle";
193
181
  var WarningBannerDescription = (0, import_react2.forwardRef)(
194
182
  (_a, ref) => {
195
- var _b = _a, { as: Component = "p", className } = _b, rest = __objRest(_b, ["as", "className"]);
183
+ var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
196
184
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
197
- Component,
185
+ "p",
198
186
  __spreadValues({
199
187
  className: (0, import_typed_classname2.clsx)("hds-warning-banner__description", className),
200
188
  ref
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/warning-banner/warning-banner.tsx","../../src/box/box.tsx","../../src/box/index.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { forwardRef, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport type { OverridableComponent } from \"../utils\";\nimport { Box } from \"../box\";\n\nexport interface WarningBannerProps {\n title: ReactNode;\n description?: ReactNode;\n}\n\nexport const WarningBanner: OverridableComponent<WarningBannerProps, HTMLDivElement> = forwardRef(\n ({ title, description, className, ...rest }, ref) => {\n const expandable = !!description;\n return (\n <Box {...rest} className={clsx(\"hds-warning-banner\", className as undefined)} ref={ref}>\n <WarningBannerTitle variant={expandable ? \"expandable\" : \"default\"}>\n {title}\n </WarningBannerTitle>\n {expandable ? <WarningBannerDescription>{description}</WarningBannerDescription> : null}\n </Box>\n );\n },\n);\nWarningBanner.displayName = \"WarningBanner\";\n\ninterface WarningBannerTitleProps {\n variant: \"expandable\" | \"default\";\n children: ReactNode;\n}\n\nconst WarningBannerTitle: OverridableComponent<WarningBannerTitleProps, HTMLDivElement> =\n forwardRef(\n (\n {\n variant,\n as: Component = variant === \"expandable\" ? \"button\" : \"p\",\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [open, setOpen] = useState<boolean>(false);\n if (variant === \"expandable\") {\n return (\n <Component\n className={clsx(\n \"hds-warning-banner__title\",\n \"hds-warning-banner__title-trigger\",\n { \"hds-warning-banner--closed\": !open },\n className as undefined,\n )}\n onClick={() => {\n setOpen(!open);\n }}\n ref={ref}\n type=\"button\"\n {...rest}\n >\n <span>{children}</span>\n </Component>\n );\n }\n return (\n <Component\n className={clsx(\"hds-warning-banner__title\", className as undefined)}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n );\nWarningBannerTitle.displayName = \"WarningBannerTitle\";\n\nconst WarningBannerDescription: OverridableComponent<object, HTMLParagraphElement> = forwardRef(\n ({ as: Component = \"p\", className, ...rest }, ref) => {\n return (\n <Component\n className={clsx(\"hds-warning-banner__description\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nWarningBannerDescription.displayName = \"WarningBannerDescription\";\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport type { OverridableComponent } from \"../utils\";\n\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n variant?: \"light-grey\" | \"lighter\" | \"white\" | \"warning\";\n children?: React.ReactNode;\n\n /**\n * If `true`, a close button will be shown.\n * Use when you want to control the close button using the BoxCloseButton component.\n */\n closeable?: boolean;\n\n /**\n * Callback fired when the component requests to be closed.\n * If not set, the component will be closed without any user interaction.\n *\n * If set, and the handler returns non-true value, the component will not be closed.\n * Use this if you want to control the closing of the component, using the `closed` prop\n *\n * If set, and the handler returns the true, the component will be closed.\n * Use this with `window.confirm()` to ask the user to confirm closing the component.\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents -- It's fine, I want to have the boolean in the type\n onClose?: () => boolean | unknown;\n\n /**\n * If `true`, the box will be closed and hidden from view\n */\n closed?: boolean;\n\n /**\n * Props applied to the close button element.\n */\n closeButtonProps?: BoxCloseButtonProps;\n}\n\nexport const Box: OverridableComponent<BoxProps, HTMLDivElement> = forwardRef(\n (\n {\n as: Component = \"div\",\n variant,\n closeable = false,\n onClose: onCloseProp,\n closed: closedProp,\n closeButtonProps,\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [closedState, setClosedState] = useState(false);\n const onClose = useCallback(() => {\n if (onCloseProp) {\n const result = onCloseProp();\n if (result === true) {\n setClosedState(true);\n }\n } else {\n setClosedState(true);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, []);\n const closed = closedProp ?? closedState;\n\n return (\n <Component\n className={clsx(\n \"hds-box\",\n variant && `hds-box--${variant}`,\n { \"hds-box--closed\": closed },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {closeable ? <BoxCloseButton onClick={onClose} {...closeButtonProps} /> : null}\n {children}\n </Component>\n );\n },\n);\nBox.displayName = \"Box\";\n\nexport type BoxCloseButtonProps = Omit<React.HTMLAttributes<HTMLButtonElement>, \"children\">;\nexport const BoxCloseButton = forwardRef<HTMLButtonElement, BoxCloseButtonProps>(\n ({ className, ...rest }, ref) => {\n return (\n <button\n className={clsx(\"hds-box__close-button\", className as undefined)}\n ref={ref}\n type=\"button\"\n {...rest}\n />\n );\n },\n);\nBoxCloseButton.displayName = \"Box.CloseButton\";\n","import { Box, BoxCloseButton } from \"./box\";\n\nconst BoxComponent = Box as typeof Box & {\n CloseButton: typeof BoxCloseButton;\n};\nBoxComponent.CloseButton = BoxCloseButton;\n\nexport { BoxComponent as Box, BoxCloseButton };\n\nexport type * from \"./box\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,gBAAqC;AACrC,IAAAC,0BAAqB;;;ACFrB,mBAAkD;AAClD,6BAAqB;AAmEf;AA9BC,IAAM,UAAsD;AAAA,EACjE,CACE,IAWA,QACG;AAZH,iBACE;AAAA,UAAI,YAAY;AAAA,MAChB;AAAA,MACA,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IAhDN,IAwCI,IASK,iBATL,IASK;AAAA,MARH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF,UAAM,CAAC,aAA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AA8B;AAAA,QACrF;AAAA,EAEJ;AACF;AACA,cAAc,cAAc;AAO5B,IAAM,yBACJ;AAAA,EACE,CACE,IAOA,QACG;AARH,iBACE;AAAA;AAAA,MACA,IAAI,YAAY,YAAY,eAAe,WAAW;AAAA,MACtD;AAAA,MACA;AAAA,IAtCR,IAkCM,IAKK,iBALL,IAKK;AAAA,MAJH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF,UAAM,CAAC,MAAM,OAAO,QAAI,wBAAkB,KAAK;AAC/C,QAAI,YAAY,cAAc;AAC5B,aACE;AAAA,QAAC;AAAA;AAAA,UACC,eAAW;AAAA,YACT;AAAA,YACA;AAAA,YACA,EAAE,8BAA8B,CAAC,KAAK;AAAA,YACtC;AAAA,UACF;AAAA,UACA,SAAS,MAAM;AACb,oBAAQ,CAAC,IAAI;AAAA,UACf;AAAA,UACA;AAAA,UACA,MAAK;AAAA,WACD,OAZL;AAAA,UAcC,uDAAC,UAAM,UAAS;AAAA;AAAA,MAClB;AAAA,IAEJ;AACA,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,8BAAK,6BAA6B,SAAsB;AAAA,QACnE;AAAA,SACI,OAHL;AAAA,QAKE;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACF,mBAAmB,cAAc;AAEjC,IAAM,+BAA+E;AAAA,EACnF,CAAC,IAA6C,QAAQ;AAArD,iBAAE,MAAI,YAAY,KAAK,UA9E1B,IA8EG,IAAqC,iBAArC,IAAqC,CAAnC,MAAqB;AACtB,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,8BAAK,mCAAmC,SAAsB;AAAA,QACzE;AAAA,SACI;AAAA,IACN;AAAA,EAEJ;AACF;AACA,yBAAyB,cAAc;","names":["import_react","import_typed_classname","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../../src/warning-banner/warning-banner.tsx","../../src/box/box.tsx","../../src/box/index.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport React, { forwardRef, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Box } from \"../box\";\n\nexport interface WarningBannerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n title: ReactNode;\n description?: ReactNode;\n}\n\nexport const WarningBanner = forwardRef<HTMLDivElement, WarningBannerProps>(\n ({ title, description, className, ...rest }, ref) => {\n const expandable = !!description;\n return (\n <Box {...rest} className={clsx(\"hds-warning-banner\", className as undefined)} ref={ref}>\n <WarningBannerTitle variant={expandable ? \"expandable\" : \"default\"}>\n {title}\n </WarningBannerTitle>\n {expandable ? <WarningBannerDescription>{description}</WarningBannerDescription> : null}\n </Box>\n );\n },\n);\nWarningBanner.displayName = \"WarningBanner\";\n\ntype WarningBannerTitleProps =\n | ({ variant: \"expandable\" } & React.ButtonHTMLAttributes<HTMLButtonElement>)\n | ({ variant: \"default\" } & React.HTMLAttributes<HTMLParagraphElement>);\n\nconst WarningBannerTitle = forwardRef<\n HTMLButtonElement | HTMLParagraphElement,\n WarningBannerTitleProps\n>(({ variant, children, className, ...rest }, ref) => {\n const [open, setOpen] = useState<boolean>(false);\n if (variant === \"expandable\") {\n return (\n <button\n {...(rest as React.ButtonHTMLAttributes<HTMLButtonElement>)}\n className={clsx(\n \"hds-warning-banner__title\",\n \"hds-warning-banner__title-trigger\",\n { \"hds-warning-banner--closed\": !open },\n className as undefined,\n )}\n onClick={() => {\n setOpen((prev) => !prev);\n }}\n ref={ref as React.Ref<HTMLButtonElement>}\n type=\"button\"\n >\n <span>{children}</span>\n </button>\n );\n }\n return (\n <p\n {...(rest as React.HTMLAttributes<HTMLParagraphElement>)}\n className={clsx(\"hds-warning-banner__title\", className as undefined)}\n ref={ref as React.Ref<HTMLParagraphElement>}\n >\n {children}\n </p>\n );\n});\nWarningBannerTitle.displayName = \"WarningBannerTitle\";\n\ntype WarningBannerDescriptionProps = React.HTMLAttributes<HTMLParagraphElement>;\nconst WarningBannerDescription = forwardRef<HTMLParagraphElement, WarningBannerDescriptionProps>(\n ({ className, ...rest }, ref) => {\n return (\n <p\n className={clsx(\"hds-warning-banner__description\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nWarningBannerDescription.displayName = \"WarningBannerDescription\";\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\n\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n children?: React.ReactNode;\n\n /**\n * Color variant of the box\n *\n * @default \"light-grey\"\n */\n variant?: \"light-grey\" | \"lighter\" | \"white\" | \"warning\";\n\n /**\n * If `true`, a close button will be shown.\n * Use when you want to control the close button using the BoxCloseButton component.\n *\n * @default false\n */\n closeable?: boolean;\n\n /**\n * Callback fired when the component requests to be closed.\n * If not set, the component will be closed without any user interaction.\n *\n * If set, and the handler returns non-true value, the component will not be closed.\n * Use this if you want to control the closing of the component, using the `closed` prop\n *\n * If set, and the handler returns the true, the component will be closed.\n * Use this with `window.confirm()` to ask the user to confirm closing the component.\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents -- It's fine, I want to have the boolean in the type\n onClose?: () => boolean | unknown;\n\n /**\n * If `true`, the box will be closed and hidden from view\n */\n closed?: boolean;\n\n /**\n * Props applied to the close button element.\n */\n closeButtonProps?: BoxCloseButtonProps;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n (\n {\n asChild,\n variant,\n closeable = false,\n onClose: onCloseProp,\n closed: closedProp,\n closeButtonProps,\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [closedState, setClosedState] = useState(false);\n const onClose = useCallback(() => {\n if (onCloseProp) {\n const result = onCloseProp();\n if (result === true) {\n setClosedState(true);\n }\n } else {\n setClosedState(true);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, []);\n const closed = closedProp ?? closedState;\n const Component = asChild ? Slot : \"div\";\n\n return (\n <Component\n className={clsx(\n \"hds-box\",\n variant && `hds-box--${variant}`,\n { \"hds-box--closed\": closed },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {closeable ? <BoxCloseButton onClick={onClose} {...closeButtonProps} /> : null}\n <Slottable>{children}</Slottable>\n </Component>\n );\n },\n);\nBox.displayName = \"Box\";\n\nexport type BoxCloseButtonProps = Omit<React.HTMLAttributes<HTMLButtonElement>, \"children\">;\nexport const BoxCloseButton = forwardRef<HTMLButtonElement, BoxCloseButtonProps>(\n ({ className, ...rest }, ref) => {\n return (\n <button\n className={clsx(\"hds-box__close-button\", className as undefined)}\n ref={ref}\n type=\"button\"\n {...rest}\n />\n );\n },\n);\nBoxCloseButton.displayName = \"Box.CloseButton\";\n","import { Box, BoxCloseButton } from \"./box\";\n\nconst BoxComponent = Box as typeof Box & {\n CloseButton: typeof BoxCloseButton;\n};\nBoxComponent.CloseButton = BoxCloseButton;\n\nexport { BoxComponent as Box, BoxCloseButton };\n\nexport type * from \"./box\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,gBAA4C;AAC5C,IAAAC,0BAAqB;;;ACFrB,mBAAkD;AAClD,6BAAqB;AACrB,wBAAgC;AAkF1B;AA/BC,IAAM,UAAM;AAAA,EACjB,CACE,IAWA,QACG;AAZH,iBACE;AAAA;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IA/DN,IAuDI,IASK,iBATL,IASK;AAAA,MARH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF,UAAM,CAAC,aAAa,cAAc,QAAI,uBAAS,KAAK;AACpD,UAAM,cAAU,0BAAY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AY,IAA8B;AAAA,QACrF;AAAA,EAEJ;AACF;AACA,cAAc,cAAc;AAM5B,IAAM,yBAAqB,0BAGzB,CAAC,IAA2C,QAAQ;AAAnD,eAAE,WAAS,UAAU,UAhCxB,IAgCG,IAAmC,iBAAnC,IAAmC,CAAjC,WAAS,YAAU;AACtB,QAAM,CAAC,MAAM,OAAO,QAAI,wBAAkB,KAAK;AAC/C,MAAI,YAAY,cAAc;AAC5B,WACE;AAAA,MAAC;AAAA,uCACM,OADN;AAAA,QAEC,eAAW;AAAA,UACT;AAAA,UACA;AAAA,UACA,EAAE,8BAA8B,CAAC,KAAK;AAAA,UACtC;AAAA,QACF;AAAA,QACA,SAAS,MAAM;AACb,kBAAQ,CAAC,SAAS,CAAC,IAAI;AAAA,QACzB;AAAA,QACA;AAAA,QACA,MAAK;AAAA,QAEL,uDAAC,UAAM,UAAS;AAAA;AAAA,IAClB;AAAA,EAEJ;AACA,SACE;AAAA,IAAC;AAAA,qCACM,OADN;AAAA,MAEC,eAAW,8BAAK,6BAA6B,SAAsB;AAAA,MACnE;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ,CAAC;AACD,mBAAmB,cAAc;AAGjC,IAAM,+BAA2B;AAAA,EAC/B,CAAC,IAAwB,QAAQ;AAAhC,iBAAE,YApEL,IAoEG,IAAgB,iBAAhB,IAAgB,CAAd;AACD,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,8BAAK,mCAAmC,SAAsB;AAAA,QACzE;AAAA,SACI;AAAA,IACN;AAAA,EAEJ;AACF;AACA,yBAAyB,cAAc;","names":["import_react","import_typed_classname","import_jsx_runtime"]}
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  WarningBanner
3
- } from "../chunk-PUESATBQ.mjs";
4
- import "../chunk-NMMFIRLZ.mjs";
5
- import "../chunk-EGXM575K.mjs";
3
+ } from "../chunk-XC3UHH2U.mjs";
4
+ import "../chunk-3NL3TOZF.mjs";
5
+ import "../chunk-ENKVTAJB.mjs";
6
6
  import "../chunk-R4SQKVDQ.mjs";
7
7
  export {
8
8
  WarningBanner