@fragiola/primitives-react 0.0.0-stage → 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (578) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -2
  3. package/dist/accordion--E-5hjWo.js +210 -0
  4. package/dist/accordion--E-5hjWo.js.map +1 -0
  5. package/dist/accordion.d.ts +4 -0
  6. package/dist/accordion.js +1 -0
  7. package/dist/alert-dialog-7FIAj98B.js +37 -0
  8. package/dist/alert-dialog-7FIAj98B.js.map +1 -0
  9. package/dist/alert-dialog.d.ts +9 -0
  10. package/dist/alert-dialog.js +1 -0
  11. package/dist/aspect-ratio-CUADsevg.js +19 -0
  12. package/dist/aspect-ratio-CUADsevg.js.map +1 -0
  13. package/dist/aspect-ratio.d.ts +3 -0
  14. package/dist/aspect-ratio.js +1 -0
  15. package/dist/async-list-7ljWFMgA.js +35 -0
  16. package/dist/async-list-7ljWFMgA.js.map +1 -0
  17. package/dist/async-list.d.ts +2 -0
  18. package/dist/async-list.js +1 -0
  19. package/dist/autocomplete-virtual-BE8dDDgU.js +56 -0
  20. package/dist/autocomplete-virtual-BE8dDDgU.js.map +1 -0
  21. package/dist/autocomplete-virtual.d.ts +4 -0
  22. package/dist/autocomplete-virtual.js +3 -0
  23. package/dist/autocomplete.d.ts +9 -0
  24. package/dist/autocomplete.js +1 -0
  25. package/dist/avatar-CABjoLs9.js +101 -0
  26. package/dist/avatar-CABjoLs9.js.map +1 -0
  27. package/dist/avatar.d.ts +3 -0
  28. package/dist/avatar.js +1 -0
  29. package/dist/breadcrumbs-nG0Rq3kX.js +69 -0
  30. package/dist/breadcrumbs-nG0Rq3kX.js.map +1 -0
  31. package/dist/breadcrumbs.d.ts +3 -0
  32. package/dist/breadcrumbs.js +1 -0
  33. package/dist/button-B6h8UkhR.js +30 -0
  34. package/dist/button-B6h8UkhR.js.map +1 -0
  35. package/dist/button-props-DWfy1ZSo.js +69 -0
  36. package/dist/button-props-DWfy1ZSo.js.map +1 -0
  37. package/dist/button.d.ts +3 -0
  38. package/dist/button.js +1 -0
  39. package/dist/calendar-preset-Cs-hy-_0.js +70 -0
  40. package/dist/calendar-preset-Cs-hy-_0.js.map +1 -0
  41. package/dist/calendar-preset.d.ts +4 -0
  42. package/dist/calendar-preset.js +3 -0
  43. package/dist/calendar-root-base-CIkiSebb.js +515 -0
  44. package/dist/calendar-root-base-CIkiSebb.js.map +1 -0
  45. package/dist/calendar-row-BO5kyOgq.d.ts +84 -0
  46. package/dist/calendar-value-DCOjO7og.d.ts +23 -0
  47. package/dist/calendar-view-DT9i5Xg_.js +157 -0
  48. package/dist/calendar-view-DT9i5Xg_.js.map +1 -0
  49. package/dist/calendar-view.d.ts +6 -0
  50. package/dist/calendar-view.js +4 -0
  51. package/dist/calendar.d.ts +7 -0
  52. package/dist/calendar.js +1 -0
  53. package/dist/carousel-ClQsQ135.js +436 -0
  54. package/dist/carousel-ClQsQ135.js.map +1 -0
  55. package/dist/carousel.d.ts +4 -0
  56. package/dist/carousel.js +1 -0
  57. package/dist/cascade-select-DZlpKUok.js +582 -0
  58. package/dist/cascade-select-DZlpKUok.js.map +1 -0
  59. package/dist/cascade-select.d.ts +7 -0
  60. package/dist/cascade-select.js +1 -0
  61. package/dist/change-details-CPSkPCNw.d.ts +32 -0
  62. package/dist/checkbox-CbmkKNfv.js +165 -0
  63. package/dist/checkbox-CbmkKNfv.js.map +1 -0
  64. package/dist/checkbox-group-_UrFCUgQ.js +99 -0
  65. package/dist/checkbox-group-_UrFCUgQ.js.map +1 -0
  66. package/dist/checkbox-group-context-CoGqgxBM.js +6 -0
  67. package/dist/checkbox-group-context-CoGqgxBM.js.map +1 -0
  68. package/dist/checkbox-group.d.ts +4 -0
  69. package/dist/checkbox-group.js +1 -0
  70. package/dist/checkbox.d.ts +4 -0
  71. package/dist/checkbox.js +1 -0
  72. package/dist/clipboard-CvgO1qhh.js +189 -0
  73. package/dist/clipboard-CvgO1qhh.js.map +1 -0
  74. package/dist/clipboard.d.ts +4 -0
  75. package/dist/clipboard.js +1 -0
  76. package/dist/collapsible-Dh0TUP6l.js +112 -0
  77. package/dist/collapsible-Dh0TUP6l.js.map +1 -0
  78. package/dist/collapsible.d.ts +4 -0
  79. package/dist/collapsible.js +1 -0
  80. package/dist/color-area-BGo6tZxX.js +311 -0
  81. package/dist/color-area-BGo6tZxX.js.map +1 -0
  82. package/dist/color-area.d.ts +4 -0
  83. package/dist/color-area.js +1 -0
  84. package/dist/color-field-B9QEKyQ1.js +334 -0
  85. package/dist/color-field-B9QEKyQ1.js.map +1 -0
  86. package/dist/color-field.d.ts +4 -0
  87. package/dist/color-field.js +1 -0
  88. package/dist/color-picker-BNOtqWUK.js +276 -0
  89. package/dist/color-picker-BNOtqWUK.js.map +1 -0
  90. package/dist/color-picker-binding-D9xBS_my.js +6 -0
  91. package/dist/color-picker-binding-D9xBS_my.js.map +1 -0
  92. package/dist/color-picker-popover-CV_wP6KG.js +195 -0
  93. package/dist/color-picker-popover-CV_wP6KG.js.map +1 -0
  94. package/dist/color-picker-popover.d.ts +7 -0
  95. package/dist/color-picker-popover.js +1 -0
  96. package/dist/color-picker.d.ts +4 -0
  97. package/dist/color-picker.js +1 -0
  98. package/dist/color-slider-Bw940FJr.js +357 -0
  99. package/dist/color-slider-Bw940FJr.js.map +1 -0
  100. package/dist/color-slider.d.ts +4 -0
  101. package/dist/color-slider.js +1 -0
  102. package/dist/color-swatch-C9ws0xF4.js +37 -0
  103. package/dist/color-swatch-C9ws0xF4.js.map +1 -0
  104. package/dist/color-swatch-picker-CnmTr1SY.js +286 -0
  105. package/dist/color-swatch-picker-CnmTr1SY.js.map +1 -0
  106. package/dist/color-swatch-picker.d.ts +4 -0
  107. package/dist/color-swatch-picker.js +1 -0
  108. package/dist/color-swatch.d.ts +3 -0
  109. package/dist/color-swatch.js +1 -0
  110. package/dist/color-wheel--n8w5fIJ.js +247 -0
  111. package/dist/color-wheel--n8w5fIJ.js.map +1 -0
  112. package/dist/color-wheel.d.ts +4 -0
  113. package/dist/color-wheel.js +1 -0
  114. package/dist/combobox-virtual-BI-l10BE.js +61 -0
  115. package/dist/combobox-virtual-BI-l10BE.js.map +1 -0
  116. package/dist/combobox-virtual.d.ts +4 -0
  117. package/dist/combobox-virtual.js +3 -0
  118. package/dist/combobox.d.ts +9 -0
  119. package/dist/combobox.js +1 -0
  120. package/dist/command-virtual-CxNLxsih.js +56 -0
  121. package/dist/command-virtual-CxNLxsih.js.map +1 -0
  122. package/dist/command-virtual.d.ts +4 -0
  123. package/dist/command-virtual.js +3 -0
  124. package/dist/command.d.ts +5 -0
  125. package/dist/command.js +1 -0
  126. package/dist/context-menu-DGj2L-Sv.js +131 -0
  127. package/dist/context-menu-DGj2L-Sv.js.map +1 -0
  128. package/dist/context-menu.d.ts +8 -0
  129. package/dist/context-menu.js +1 -0
  130. package/dist/date-field-C1nhThPd.js +33 -0
  131. package/dist/date-field-C1nhThPd.js.map +1 -0
  132. package/dist/date-field-root-CzSo5iKL.d.ts +26 -0
  133. package/dist/date-field-root-base-B-050SUC.js +185 -0
  134. package/dist/date-field-root-base-B-050SUC.js.map +1 -0
  135. package/dist/date-field-segment-BoS-ohDh.d.ts +67 -0
  136. package/dist/date-field.d.ts +6 -0
  137. package/dist/date-field.js +1 -0
  138. package/dist/date-picker-input-BCaKff7A.js +29 -0
  139. package/dist/date-picker-input-BCaKff7A.js.map +1 -0
  140. package/dist/date-picker-input-root-base-Cc3mE-NR.d.ts +17 -0
  141. package/dist/date-picker-input-root-base-D4VaBnpf.js +361 -0
  142. package/dist/date-picker-input-root-base-D4VaBnpf.js.map +1 -0
  143. package/dist/date-picker-input.d.ts +7 -0
  144. package/dist/date-picker-input.js +3 -0
  145. package/dist/date-picker-trigger-BKPvZbRg.js +304 -0
  146. package/dist/date-picker-trigger-BKPvZbRg.js.map +1 -0
  147. package/dist/date-picker-trigger-DHsAhBf2.d.ts +51 -0
  148. package/dist/date-picker.d.ts +11 -0
  149. package/dist/date-picker.js +1 -0
  150. package/dist/date-range-field-C-ID01oa.js +34 -0
  151. package/dist/date-range-field-C-ID01oa.js.map +1 -0
  152. package/dist/date-range-field-input-BkLpldTx.js +33 -0
  153. package/dist/date-range-field-input-BkLpldTx.js.map +1 -0
  154. package/dist/date-range-field-input-BwCNo15l.d.ts +13 -0
  155. package/dist/date-range-field-root-CmZ3c7xn.d.ts +31 -0
  156. package/dist/date-range-field-root-base-DWH3nqmz.d.ts +23 -0
  157. package/dist/date-range-field-root-base-z8S5aSCs.js +261 -0
  158. package/dist/date-range-field-root-base-z8S5aSCs.js.map +1 -0
  159. package/dist/date-range-field.d.ts +9 -0
  160. package/dist/date-range-field.js +1 -0
  161. package/dist/date-range-picker-input-DlIdTD-J.js +30 -0
  162. package/dist/date-range-picker-input-DlIdTD-J.js.map +1 -0
  163. package/dist/date-range-picker-input.d.ts +10 -0
  164. package/dist/date-range-picker-input.js +3 -0
  165. package/dist/date-range-picker.d.ts +11 -0
  166. package/dist/date-range-picker.js +1 -0
  167. package/dist/dialog-DDE15qBB.js +33 -0
  168. package/dist/dialog-DDE15qBB.js.map +1 -0
  169. package/dist/dialog-root-base-DDMrqDC9.js +328 -0
  170. package/dist/dialog-root-base-DDMrqDC9.js.map +1 -0
  171. package/dist/dialog-title-BitK2i0A.d.ts +78 -0
  172. package/dist/dialog.d.ts +9 -0
  173. package/dist/dialog.js +1 -0
  174. package/dist/direction-BfW1BOg1.js +22 -0
  175. package/dist/direction-BfW1BOg1.js.map +1 -0
  176. package/dist/direction-context-CiRdNJmu.js +11 -0
  177. package/dist/direction-context-CiRdNJmu.js.map +1 -0
  178. package/dist/direction.d.ts +2 -0
  179. package/dist/direction.js +1 -0
  180. package/dist/drawer-CaPOhMl-.js +302 -0
  181. package/dist/drawer-CaPOhMl-.js.map +1 -0
  182. package/dist/drawer.d.ts +9 -0
  183. package/dist/drawer.js +1 -0
  184. package/dist/drop-zone-q0-5u2cs.js +86 -0
  185. package/dist/drop-zone-q0-5u2cs.js.map +1 -0
  186. package/dist/drop-zone.d.ts +4 -0
  187. package/dist/drop-zone.js +1 -0
  188. package/dist/editable-vU6vYZOD.js +403 -0
  189. package/dist/editable-vU6vYZOD.js.map +1 -0
  190. package/dist/editable.d.ts +4 -0
  191. package/dist/editable.js +1 -0
  192. package/dist/field-DibhXWF6.js +308 -0
  193. package/dist/field-DibhXWF6.js.map +1 -0
  194. package/dist/field.d.ts +4 -0
  195. package/dist/field.js +1 -0
  196. package/dist/fieldset-Cz80P2jc.js +53 -0
  197. package/dist/fieldset-Cz80P2jc.js.map +1 -0
  198. package/dist/fieldset-context-CeaxEBvi.js +6 -0
  199. package/dist/fieldset-context-CeaxEBvi.js.map +1 -0
  200. package/dist/fieldset.d.ts +3 -0
  201. package/dist/fieldset.js +1 -0
  202. package/dist/file-upload-BIRibICU.js +513 -0
  203. package/dist/file-upload-BIRibICU.js.map +1 -0
  204. package/dist/file-upload.d.ts +4 -0
  205. package/dist/file-upload.js +1 -0
  206. package/dist/form-DNAaFPpL.js +87 -0
  207. package/dist/form-DNAaFPpL.js.map +1 -0
  208. package/dist/form-context-BW-nK6kl.js +6 -0
  209. package/dist/form-context-BW-nK6kl.js.map +1 -0
  210. package/dist/form.d.ts +3 -0
  211. package/dist/form.js +1 -0
  212. package/dist/hover-card-CRDpA_zU.js +317 -0
  213. package/dist/hover-card-CRDpA_zU.js.map +1 -0
  214. package/dist/hover-card.d.ts +9 -0
  215. package/dist/hover-card.js +1 -0
  216. package/dist/index-0bXL0iXX.d.ts +25 -0
  217. package/dist/index-6f2s5HfF.d.ts +30 -0
  218. package/dist/index-9WYWziGt.d.ts +42 -0
  219. package/dist/index-B57uQVXT.d.ts +100 -0
  220. package/dist/index-BA629roy.d.ts +52 -0
  221. package/dist/index-BC5bS-vC.d.ts +30 -0
  222. package/dist/index-BDbTYsJR.d.ts +77 -0
  223. package/dist/index-BEaxabvv.d.ts +80 -0
  224. package/dist/index-BLRo_PJD.d.ts +58 -0
  225. package/dist/index-BMt816ZL.d.ts +51 -0
  226. package/dist/index-BQJrDd_G.d.ts +108 -0
  227. package/dist/index-BUJIeLCT.d.ts +37 -0
  228. package/dist/index-BZxd4oqB.d.ts +111 -0
  229. package/dist/index-B_JVgpGe.d.ts +13 -0
  230. package/dist/index-BdxleDV0.d.ts +104 -0
  231. package/dist/index-Be4w9GAc.d.ts +13 -0
  232. package/dist/index-Bht8ohW3.d.ts +31 -0
  233. package/dist/index-Bk1NBvxD.d.ts +75 -0
  234. package/dist/index-BmtcAsQr.d.ts +44 -0
  235. package/dist/index-BmuEv-h3.d.ts +35 -0
  236. package/dist/index-BnPLIkKG.d.ts +31 -0
  237. package/dist/index-BoJU86K5.d.ts +52 -0
  238. package/dist/index-Bq6yByLv.d.ts +50 -0
  239. package/dist/index-Bqt2th2p.d.ts +41 -0
  240. package/dist/index-BrXfSGo2.d.ts +51 -0
  241. package/dist/index-BsvcTJ_x.d.ts +17 -0
  242. package/dist/index-BxcCz-NS.d.ts +36 -0
  243. package/dist/index-C3y4g2fs.d.ts +21 -0
  244. package/dist/index-C8-b81Jh.d.ts +20 -0
  245. package/dist/index-C8KLM25T.d.ts +31 -0
  246. package/dist/index-C9TSddnB.d.ts +140 -0
  247. package/dist/index-CCnaczzE.d.ts +32 -0
  248. package/dist/index-CD6hgnl1.d.ts +86 -0
  249. package/dist/index-CEN3o4Pw.d.ts +35 -0
  250. package/dist/index-CFlhfs3y.d.ts +30 -0
  251. package/dist/index-CIQU06ga.d.ts +36 -0
  252. package/dist/index-CNUEsZ_M.d.ts +51 -0
  253. package/dist/index-CNYBtgVC.d.ts +53 -0
  254. package/dist/index-CQJHcuzo.d.ts +76 -0
  255. package/dist/index-CTw9ONha.d.ts +69 -0
  256. package/dist/index-CU9QnAha.d.ts +32 -0
  257. package/dist/index-CcwKZWPY.d.ts +92 -0
  258. package/dist/index-Cjl7RT2o.d.ts +17 -0
  259. package/dist/index-ClfKp-sZ.d.ts +21 -0
  260. package/dist/index-CqGIxPDB.d.ts +82 -0
  261. package/dist/index-CsXJJ0G8.d.ts +41 -0
  262. package/dist/index-Cyjcq7lp.d.ts +28 -0
  263. package/dist/index-CzB9dDcM.d.ts +22 -0
  264. package/dist/index-D1-zqp2Q.d.ts +44 -0
  265. package/dist/index-D59OFWyx.d.ts +53 -0
  266. package/dist/index-D9lx4wAU.d.ts +21 -0
  267. package/dist/index-DHrnPQEE.d.ts +128 -0
  268. package/dist/index-DHwyHITu.d.ts +131 -0
  269. package/dist/index-DQ68aV2P.d.ts +21 -0
  270. package/dist/index-DQAkgf9_.d.ts +14 -0
  271. package/dist/index-DRow1231.d.ts +31 -0
  272. package/dist/index-DTGZeJU7.d.ts +29 -0
  273. package/dist/index-DU7jtvI8.d.ts +24 -0
  274. package/dist/index-DVjhOpXu.d.ts +42 -0
  275. package/dist/index-DZoqbcd6.d.ts +26 -0
  276. package/dist/index-Da0eVQHO.d.ts +62 -0
  277. package/dist/index-DhNPJa6U.d.ts +31 -0
  278. package/dist/index-DnQAamhU.d.ts +27 -0
  279. package/dist/index-DoFrs7Az.d.ts +16 -0
  280. package/dist/index-DorcIjVk.d.ts +20 -0
  281. package/dist/index-Dx-yMTdt.d.ts +81 -0
  282. package/dist/index-J4LbimqY.d.ts +79 -0
  283. package/dist/index-L6Mp2njJ.d.ts +81 -0
  284. package/dist/index-OmXQjsNi.d.ts +37 -0
  285. package/dist/index-PpCPWRbt.d.ts +30 -0
  286. package/dist/index-Pq-ztBxR.d.ts +34 -0
  287. package/dist/index-Qgz-Dnsj.d.ts +73 -0
  288. package/dist/index-R3h8-VcD.d.ts +32 -0
  289. package/dist/index-WtAHbmtb.d.ts +88 -0
  290. package/dist/index-dKoYaA3K.d.ts +38 -0
  291. package/dist/index-fgqEotIa.d.ts +16 -0
  292. package/dist/index-gvpnQy8T.d.ts +87 -0
  293. package/dist/index-kY3Yo50q.d.ts +68 -0
  294. package/dist/index-ndFpL4W9.d.ts +15 -0
  295. package/dist/index-oLgwTyCz.d.ts +45 -0
  296. package/dist/index-pSrGVYre.d.ts +40 -0
  297. package/dist/index-t4CBZJDG.d.ts +65 -0
  298. package/dist/index-wC8PY0fW.d.ts +16 -0
  299. package/dist/index-wv0Lafz4.d.ts +46 -0
  300. package/dist/index-zEeZUMLc.d.ts +29 -0
  301. package/dist/index.d.ts +125 -0
  302. package/dist/index.js +104 -0
  303. package/dist/label-DN9tJMXl.js +24 -0
  304. package/dist/label-DN9tJMXl.js.map +1 -0
  305. package/dist/label.d.ts +3 -0
  306. package/dist/label.js +1 -0
  307. package/dist/link-D3xYrfPK.js +22 -0
  308. package/dist/link-D3xYrfPK.js.map +1 -0
  309. package/dist/link-props-Shu8RU_5.js +27 -0
  310. package/dist/link-props-Shu8RU_5.js.map +1 -0
  311. package/dist/link.d.ts +3 -0
  312. package/dist/link.js +1 -0
  313. package/dist/listbox-virtual-C4wz3TOa.js +281 -0
  314. package/dist/listbox-virtual-C4wz3TOa.js.map +1 -0
  315. package/dist/listbox-virtual.d.ts +6 -0
  316. package/dist/listbox-virtual.js +3 -0
  317. package/dist/listbox.d.ts +5 -0
  318. package/dist/listbox.js +1 -0
  319. package/dist/live-region-style-Xgiu9ttw.js +48 -0
  320. package/dist/live-region-style-Xgiu9ttw.js.map +1 -0
  321. package/dist/menu-bar-context-1duNlOWo.js +14 -0
  322. package/dist/menu-bar-context-1duNlOWo.js.map +1 -0
  323. package/dist/menu-oZj27rvf.js +123 -0
  324. package/dist/menu-oZj27rvf.js.map +1 -0
  325. package/dist/menu-separator-CzAc4jM8.d.ts +143 -0
  326. package/dist/menu-submenu-trigger-BykOQORL.js +672 -0
  327. package/dist/menu-submenu-trigger-BykOQORL.js.map +1 -0
  328. package/dist/menu.d.ts +10 -0
  329. package/dist/menu.js +1 -0
  330. package/dist/menubar-wjJF54GJ.js +213 -0
  331. package/dist/menubar-wjJF54GJ.js.map +1 -0
  332. package/dist/menubar.d.ts +3 -0
  333. package/dist/menubar.js +1 -0
  334. package/dist/meter-11PgO99t.js +120 -0
  335. package/dist/meter-11PgO99t.js.map +1 -0
  336. package/dist/meter.d.ts +3 -0
  337. package/dist/meter.js +1 -0
  338. package/dist/month-calendar-value-CNJcsqcv.d.ts +5 -0
  339. package/dist/month-calendar-value-D_au-Kbz.js +35 -0
  340. package/dist/month-calendar-value-D_au-Kbz.js.map +1 -0
  341. package/dist/month-calendar.d.ts +6 -0
  342. package/dist/month-calendar.js +1 -0
  343. package/dist/month-picker-DFjFvjo9.js +26 -0
  344. package/dist/month-picker-DFjFvjo9.js.map +1 -0
  345. package/dist/month-picker-root-base-CI7jcllI.js +162 -0
  346. package/dist/month-picker-root-base-CI7jcllI.js.map +1 -0
  347. package/dist/month-picker-root-base-SELhczoy.d.ts +28 -0
  348. package/dist/month-picker.d.ts +10 -0
  349. package/dist/month-picker.js +3 -0
  350. package/dist/month-range-calendar-BmnWB6OD.js +28 -0
  351. package/dist/month-range-calendar-BmnWB6OD.js.map +1 -0
  352. package/dist/month-range-calendar.d.ts +6 -0
  353. package/dist/month-range-calendar.js +3 -0
  354. package/dist/month-range-picker-TfMtxi2X.js +26 -0
  355. package/dist/month-range-picker-TfMtxi2X.js.map +1 -0
  356. package/dist/month-range-picker.d.ts +10 -0
  357. package/dist/month-range-picker.js +3 -0
  358. package/dist/multiple-calendar-EBsuTzYQ.js +133 -0
  359. package/dist/multiple-calendar-EBsuTzYQ.js.map +1 -0
  360. package/dist/multiple-calendar.d.ts +7 -0
  361. package/dist/multiple-calendar.js +3 -0
  362. package/dist/navigation-menu-82shSjXS.js +660 -0
  363. package/dist/navigation-menu-82shSjXS.js.map +1 -0
  364. package/dist/navigation-menu.d.ts +5 -0
  365. package/dist/navigation-menu.js +1 -0
  366. package/dist/number-field-BUNkL15K.js +491 -0
  367. package/dist/number-field-BUNkL15K.js.map +1 -0
  368. package/dist/number-field.d.ts +4 -0
  369. package/dist/number-field.js +1 -0
  370. package/dist/otp-field-BMKBhv0O.js +363 -0
  371. package/dist/otp-field-BMKBhv0O.js.map +1 -0
  372. package/dist/otp-field.d.ts +4 -0
  373. package/dist/otp-field.js +1 -0
  374. package/dist/overlay-handle-DOyqO4oY.js +62 -0
  375. package/dist/overlay-handle-DOyqO4oY.js.map +1 -0
  376. package/dist/overlay-handle-DzzlzKqP.d.ts +16 -0
  377. package/dist/pagination-CMWaQSpr.js +173 -0
  378. package/dist/pagination-CMWaQSpr.js.map +1 -0
  379. package/dist/pagination.d.ts +4 -0
  380. package/dist/pagination.js +1 -0
  381. package/dist/parts-B2E7RN77.d.ts +170 -0
  382. package/dist/parts-BHkvkEgf.js +485 -0
  383. package/dist/parts-BHkvkEgf.js.map +1 -0
  384. package/dist/parts-BJ94V7Kv.d.ts +24 -0
  385. package/dist/parts-BL0sXepP.d.ts +101 -0
  386. package/dist/parts-BjC20sfl.d.ts +19 -0
  387. package/dist/parts-BnbJ2FWv.d.ts +81 -0
  388. package/dist/parts-C688_OLH.js +24 -0
  389. package/dist/parts-C688_OLH.js.map +1 -0
  390. package/dist/parts-C81p8gpg.d.ts +147 -0
  391. package/dist/parts-CDVlldST.js +721 -0
  392. package/dist/parts-CDVlldST.js.map +1 -0
  393. package/dist/parts-CNp1lOIU.js +24 -0
  394. package/dist/parts-CNp1lOIU.js.map +1 -0
  395. package/dist/parts-CXjEfLf7.d.ts +125 -0
  396. package/dist/parts-CrriPiIL.js +29 -0
  397. package/dist/parts-CrriPiIL.js.map +1 -0
  398. package/dist/parts-DVNSEjIO.d.ts +19 -0
  399. package/dist/parts-DmQ9WqOP.js +512 -0
  400. package/dist/parts-DmQ9WqOP.js.map +1 -0
  401. package/dist/parts-DoQQN1Io.d.ts +96 -0
  402. package/dist/parts-VT0Ohb06.js +806 -0
  403. package/dist/parts-VT0Ohb06.js.map +1 -0
  404. package/dist/parts-XRa0gd47.js +350 -0
  405. package/dist/parts-XRa0gd47.js.map +1 -0
  406. package/dist/parts-_ZriSS4p.js +376 -0
  407. package/dist/parts-_ZriSS4p.js.map +1 -0
  408. package/dist/password-input-BQAySlmc.js +212 -0
  409. package/dist/password-input-BQAySlmc.js.map +1 -0
  410. package/dist/password-input.d.ts +4 -0
  411. package/dist/password-input.js +1 -0
  412. package/dist/picker-binding-context-7ci59zS0.js +22 -0
  413. package/dist/picker-binding-context-7ci59zS0.js.map +1 -0
  414. package/dist/popover-C5UaRJpT.js +295 -0
  415. package/dist/popover-C5UaRJpT.js.map +1 -0
  416. package/dist/popover.d.ts +9 -0
  417. package/dist/popover.js +1 -0
  418. package/dist/progress-2d64jFqb.js +141 -0
  419. package/dist/progress-2d64jFqb.js.map +1 -0
  420. package/dist/progress.d.ts +3 -0
  421. package/dist/progress.js +1 -0
  422. package/dist/radio-Mvw36nnF.js +128 -0
  423. package/dist/radio-Mvw36nnF.js.map +1 -0
  424. package/dist/radio-group-D7DchtVK.js +149 -0
  425. package/dist/radio-group-D7DchtVK.js.map +1 -0
  426. package/dist/radio-group-context-DRe2PyiF.js +6 -0
  427. package/dist/radio-group-context-DRe2PyiF.js.map +1 -0
  428. package/dist/radio-group.d.ts +4 -0
  429. package/dist/radio-group.js +1 -0
  430. package/dist/radio.d.ts +3 -0
  431. package/dist/radio.js +1 -0
  432. package/dist/range-calendar-BMxPzzAr.js +32 -0
  433. package/dist/range-calendar-BMxPzzAr.js.map +1 -0
  434. package/dist/range-calendar.d.ts +6 -0
  435. package/dist/range-calendar.js +1 -0
  436. package/dist/rating-DQdIL_nz.js +303 -0
  437. package/dist/rating-DQdIL_nz.js.map +1 -0
  438. package/dist/rating.d.ts +4 -0
  439. package/dist/rating.js +1 -0
  440. package/dist/render-C7XnxB7f.js +40 -0
  441. package/dist/render-C7XnxB7f.js.map +1 -0
  442. package/dist/render-element-DXbUbfgN.js +66 -0
  443. package/dist/render-element-DXbUbfgN.js.map +1 -0
  444. package/dist/render-element-Pwuv2wsL.d.ts +13 -0
  445. package/dist/render.d.ts +3 -0
  446. package/dist/render.js +1 -0
  447. package/dist/roving-context-BVp0I9UN.js +16 -0
  448. package/dist/roving-context-BVp0I9UN.js.map +1 -0
  449. package/dist/scroll-area-CGaVLKik.js +274 -0
  450. package/dist/scroll-area-CGaVLKik.js.map +1 -0
  451. package/dist/scroll-area.d.ts +3 -0
  452. package/dist/scroll-area.js +1 -0
  453. package/dist/search-field-DqGQt6pC.js +207 -0
  454. package/dist/search-field-DqGQt6pC.js.map +1 -0
  455. package/dist/search-field.d.ts +4 -0
  456. package/dist/search-field.js +1 -0
  457. package/dist/segmented-control-BYrnLASo.js +316 -0
  458. package/dist/segmented-control-BYrnLASo.js.map +1 -0
  459. package/dist/segmented-control.d.ts +4 -0
  460. package/dist/segmented-control.js +1 -0
  461. package/dist/select-virtual-9vDaEiye.js +55 -0
  462. package/dist/select-virtual-9vDaEiye.js.map +1 -0
  463. package/dist/select-virtual.d.ts +4 -0
  464. package/dist/select-virtual.js +3 -0
  465. package/dist/select.d.ts +8 -0
  466. package/dist/select.js +1 -0
  467. package/dist/separator-ChAJks2Q.js +18 -0
  468. package/dist/separator-ChAJks2Q.js.map +1 -0
  469. package/dist/separator.d.ts +3 -0
  470. package/dist/separator.js +1 -0
  471. package/dist/slider-DZiqQ18C.js +437 -0
  472. package/dist/slider-DZiqQ18C.js.map +1 -0
  473. package/dist/slider.d.ts +4 -0
  474. package/dist/slider.js +1 -0
  475. package/dist/state-attributes-DhboDeMS.js +14 -0
  476. package/dist/state-attributes-DhboDeMS.js.map +1 -0
  477. package/dist/steps-t_FxFH9P.js +251 -0
  478. package/dist/steps-t_FxFH9P.js.map +1 -0
  479. package/dist/steps.d.ts +4 -0
  480. package/dist/steps.js +1 -0
  481. package/dist/switch-D3zj8gtg.js +137 -0
  482. package/dist/switch-D3zj8gtg.js.map +1 -0
  483. package/dist/switch.d.ts +4 -0
  484. package/dist/switch.js +1 -0
  485. package/dist/tabs-o83wz1hF.js +285 -0
  486. package/dist/tabs-o83wz1hF.js.map +1 -0
  487. package/dist/tabs.d.ts +4 -0
  488. package/dist/tabs.js +1 -0
  489. package/dist/tag-group-gmBdCkE4.js +354 -0
  490. package/dist/tag-group-gmBdCkE4.js.map +1 -0
  491. package/dist/tag-group.d.ts +4 -0
  492. package/dist/tag-group.js +1 -0
  493. package/dist/tags-input-Co9pI732.js +555 -0
  494. package/dist/tags-input-Co9pI732.js.map +1 -0
  495. package/dist/tags-input.d.ts +4 -0
  496. package/dist/tags-input.js +1 -0
  497. package/dist/time-field-qqgemJB1.js +35 -0
  498. package/dist/time-field-qqgemJB1.js.map +1 -0
  499. package/dist/time-field.d.ts +5 -0
  500. package/dist/time-field.js +1 -0
  501. package/dist/time-range-field-BurnJee0.js +36 -0
  502. package/dist/time-range-field-BurnJee0.js.map +1 -0
  503. package/dist/time-range-field.d.ts +7 -0
  504. package/dist/time-range-field.js +1 -0
  505. package/dist/toast-ChdTo_Md.js +341 -0
  506. package/dist/toast-ChdTo_Md.js.map +1 -0
  507. package/dist/toast.d.ts +4 -0
  508. package/dist/toast.js +1 -0
  509. package/dist/toggle-W5tihPuD.js +65 -0
  510. package/dist/toggle-W5tihPuD.js.map +1 -0
  511. package/dist/toggle-group-DpJ794rw.js +73 -0
  512. package/dist/toggle-group-DpJ794rw.js.map +1 -0
  513. package/dist/toggle-group-context-Bp44l1NR.js +6 -0
  514. package/dist/toggle-group-context-Bp44l1NR.js.map +1 -0
  515. package/dist/toggle-group.d.ts +4 -0
  516. package/dist/toggle-group.js +1 -0
  517. package/dist/toggle.d.ts +4 -0
  518. package/dist/toggle.js +1 -0
  519. package/dist/toolbar-DfjePeEZ.js +178 -0
  520. package/dist/toolbar-DfjePeEZ.js.map +1 -0
  521. package/dist/toolbar.d.ts +3 -0
  522. package/dist/toolbar.js +1 -0
  523. package/dist/tooltip-CqZtSspz.js +320 -0
  524. package/dist/tooltip-CqZtSspz.js.map +1 -0
  525. package/dist/tooltip.d.ts +9 -0
  526. package/dist/tooltip.js +1 -0
  527. package/dist/use-color-picker-binding-D0R-FsfF.js +17 -0
  528. package/dist/use-color-picker-binding-D0R-FsfF.js.map +1 -0
  529. package/dist/use-controllable-state-Dm8eNkgP.js +36 -0
  530. package/dist/use-controllable-state-Dm8eNkgP.js.map +1 -0
  531. package/dist/use-element-tpFZ-kuA.js +10 -0
  532. package/dist/use-element-tpFZ-kuA.js.map +1 -0
  533. package/dist/use-field-control-CL_nOU7T.js +131 -0
  534. package/dist/use-field-control-CL_nOU7T.js.map +1 -0
  535. package/dist/use-overlay-portal-Cfv6qtTO.js +18 -0
  536. package/dist/use-overlay-portal-Cfv6qtTO.js.map +1 -0
  537. package/dist/use-overlay-portal-D8GjZ-m7.d.ts +13 -0
  538. package/dist/use-overlay-root-BDO5E_0S.d.ts +23 -0
  539. package/dist/use-overlay-root-eXuUlCpV.js +225 -0
  540. package/dist/use-overlay-root-eXuUlCpV.js.map +1 -0
  541. package/dist/use-overlay-trigger-CxW1Z6Q6.js +74 -0
  542. package/dist/use-overlay-trigger-CxW1Z6Q6.js.map +1 -0
  543. package/dist/use-overlay-trigger-PP99t2ZF.d.ts +11 -0
  544. package/dist/use-panel-transition-CKMdsqPR.js +145 -0
  545. package/dist/use-panel-transition-CKMdsqPR.js.map +1 -0
  546. package/dist/use-positioner-BpxM4U5Y.d.ts +11 -0
  547. package/dist/use-positioner-DtJR980s.js +56 -0
  548. package/dist/use-positioner-DtJR980s.js.map +1 -0
  549. package/dist/use-presence-Cwi_UTLe.js +97 -0
  550. package/dist/use-presence-Cwi_UTLe.js.map +1 -0
  551. package/dist/use-required-context-Cjd_CYnv.js +11 -0
  552. package/dist/use-required-context-Cjd_CYnv.js.map +1 -0
  553. package/dist/use-roving-composite-D0vtGxm8.js +82 -0
  554. package/dist/use-roving-composite-D0vtGxm8.js.map +1 -0
  555. package/dist/use-roving-item-Dxe3phsZ.js +42 -0
  556. package/dist/use-roving-item-Dxe3phsZ.js.map +1 -0
  557. package/dist/use-segment-group--unFuh-Z.js +307 -0
  558. package/dist/use-segment-group--unFuh-Z.js.map +1 -0
  559. package/dist/use-virtual-rows-B5N0qgmT.js +99 -0
  560. package/dist/use-virtual-rows-B5N0qgmT.js.map +1 -0
  561. package/dist/use-virtual-rows-BQFqR0_e.d.ts +16 -0
  562. package/dist/year-calendar-CroBMFMN.js +28 -0
  563. package/dist/year-calendar-CroBMFMN.js.map +1 -0
  564. package/dist/year-calendar.d.ts +6 -0
  565. package/dist/year-calendar.js +3 -0
  566. package/dist/year-picker-DJVxXtPh.js +26 -0
  567. package/dist/year-picker-DJVxXtPh.js.map +1 -0
  568. package/dist/year-picker.d.ts +10 -0
  569. package/dist/year-picker.js +3 -0
  570. package/dist/year-range-calendar-Cz2WYDV2.js +28 -0
  571. package/dist/year-range-calendar-Cz2WYDV2.js.map +1 -0
  572. package/dist/year-range-calendar.d.ts +6 -0
  573. package/dist/year-range-calendar.js +3 -0
  574. package/dist/year-range-picker-9f7L5Hgx.js +26 -0
  575. package/dist/year-range-picker-9f7L5Hgx.js.map +1 -0
  576. package/dist/year-range-picker.d.ts +10 -0
  577. package/dist/year-range-picker.js +3 -0
  578. package/package.json +553 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu-submenu-trigger-BykOQORL.js","names":[],"sources":["../src/components/menu/menu-context.ts","../src/components/menu/use-checkable-item.ts","../src/components/menu/use-menu-item.ts","../src/components/menu/menu-checkbox-item.tsx","../src/components/menu/menu-checkbox-item-indicator.tsx","../src/components/menu/menu-group.tsx","../src/components/menu/menu-group-label.tsx","../src/components/menu/menu-item.tsx","../src/components/menu/menu-popup.tsx","../src/components/menu/menu-portal.tsx","../src/components/menu/menu-positioner.tsx","../src/components/menu/menu-radio-group.tsx","../src/components/menu/menu-radio-item.tsx","../src/components/menu/menu-radio-item-indicator.tsx","../src/components/menu/use-menu-root.ts","../src/components/menu/menu-root.tsx","../src/components/menu/menu-separator.tsx","../src/components/menu/menu-submenu-trigger.tsx"],"sourcesContent":["import type { createTypeahead } from \"@fragiola/primitives/collection\";\nimport type {\n Align,\n Side,\n VirtualAnchor,\n} from \"@fragiola/primitives/positioning\";\nimport { createContext, type MutableRefObject } from \"react\";\nimport type { OverlayRoot } from \"../../hooks/use-overlay-root.ts\";\nimport type { MenuBarContextValue } from \"./menu-bar-context.ts\";\n\n/** Where the pointer left an open submenu's trigger, for the safe hover area (spec/menu.md). */\nexport interface SafeArea {\n x: number;\n y: number;\n submenu: HTMLElement;\n}\n\n/** The component a menu's parts belong to: their part attribute's prefix (spec/context-menu.md). */\nexport type MenuComponent = \"menu\" | \"context-menu\";\n\nexport interface MenuContextValue extends OverlayRoot {\n component: MenuComponent;\n /** What the positioner anchors to instead of the trigger (a context menu's point), or `null`. */\n anchor: Element | VirtualAnchor | null;\n /** Where focus returns on close, and where Tab moves on from: the trigger, for a Menu. */\n returnTarget: () => HTMLElement | null;\n /** The menu this one is a submenu of. */\n parent: MenuContextValue | null;\n loopFocus: boolean;\n /** The root menu's `modal` (a submenu follows it; a menu of a bar follows the bar's). */\n modal: boolean;\n /** The bar the root menu belongs to (spec/menu.md, \"In a Menubar\"), at every level; or `null`. */\n bar: MenuBarContextValue | null;\n /**\n * The item to highlight when the popup opens: from the keyboard, the first or the last;\n * `keep` leaves the focus where it is (a bar moving to this menu); `null` focuses the popup.\n */\n pendingHighlight: MutableRefObject<PendingHighlight>;\n typeahead: ReturnType<typeof createTypeahead>;\n /** Labels given with the `label` prop, by item element. */\n labels: Map<Element, string>;\n placed: { side: Side; align: Align };\n setPlaced: (placed: { side: Side; align: Align }) => void;\n /** Closes this level and every level above it. */\n closeAll: (\n reason: \"item-press\" | \"focus-out\" | \"outside-press\",\n event?: Event,\n ) => void;\n /** The open submenu of this level, so hovering a sibling item can close it. */\n openSubmenu: MutableRefObject<MenuContextValue | null>;\n safeArea: MutableRefObject<SafeArea | null>;\n}\n\n/** What the popup focuses when it opens (spec/menu.md, \"Focus\" and \"In a Menubar\"). */\nexport type PendingHighlight = \"first\" | \"last\" | \"keep\" | null;\n\nexport const MenuContext = createContext<MenuContextValue | null>(null);\n\n/** The state a CheckboxItem or a RadioItem gives its indicator. */\nexport interface MenuCheckableItemState {\n checked: boolean;\n highlighted: boolean;\n disabled: boolean;\n}\n\nexport const MenuCheckboxItemContext =\n createContext<MenuCheckableItemState | null>(null);\n\nexport const MenuRadioItemContext =\n createContext<MenuCheckableItemState | null>(null);\n\n/** What a RadioGroup gives its items. */\nexport interface MenuRadioGroupContextValue {\n value: string | null;\n setValue: (value: string, event: Event) => void;\n disabled: boolean;\n}\n\nexport const MenuRadioGroupContext =\n createContext<MenuRadioGroupContextValue | null>(null);\n\n/** The `data-checked` / `data-unchecked` pair of a checkable item and its indicator. */\nexport function checkedAttributes(state: MenuCheckableItemState) {\n return {\n checked: state.checked,\n unchecked: !state.checked,\n highlighted: state.highlighted,\n disabled: state.disabled,\n };\n}\n","import type { KeyboardEvent, MouseEvent } from \"react\";\nimport { useRef } from \"react\";\nimport type { MenuContextValue } from \"./menu-context.ts\";\n\n/**\n * The activation of a CheckboxItem or a RadioItem (spec/menu.md, \"Activating a checkable item\"):\n * Space and Enter fire its `click`; the click changes the state, then Enter closes every level,\n * Space keeps them open, and a pointer click closes them only with `closeOnClick`.\n */\nexport function useCheckableItem(\n context: MenuContextValue,\n {\n disabled,\n closeOnClick,\n change,\n }: {\n disabled: boolean;\n closeOnClick: boolean;\n change: (event: Event) => void;\n },\n) {\n const key = useRef<\"Enter\" | \" \" | null>(null);\n return {\n onKeyDown: (event: KeyboardEvent<HTMLElement>) => {\n if (event.key !== \"Enter\" && event.key !== \" \") {\n return;\n }\n // the popup's own activation stays out of it\n event.preventDefault();\n key.current = event.key;\n event.currentTarget.click();\n key.current = null;\n },\n onClick: (event: MouseEvent) => {\n if (disabled) {\n return;\n }\n change(event.nativeEvent);\n const pressed = key.current;\n if (pressed === \"Enter\" || (pressed === null && closeOnClick)) {\n context.closeAll(\"item-press\", event.nativeEvent);\n }\n },\n };\n}\n","import { isInSafeArea } from \"@fragiola/primitives/pointer\";\nimport { type PointerEvent, useLayoutEffect, useState } from \"react\";\nimport type { MenuContextValue } from \"./menu-context.ts\";\nimport { menuItems } from \"./menu-items.ts\";\n\n/**\n * What every item of a menu level shares: highlight follows focus, the pointer highlights, the\n * typeahead label, and the safe area that protects an open submenu while the pointer travels to it.\n */\nexport function useMenuItem(\n context: MenuContextValue,\n element: HTMLElement | null,\n label: string | undefined,\n isSubmenuTrigger: boolean,\n) {\n const [highlighted, setHighlighted] = useState(false);\n const { labels } = context;\n useLayoutEffect(() => {\n if (element === null || label === undefined) {\n return undefined;\n }\n labels.set(element, label);\n return () => {\n labels.delete(element);\n };\n }, [element, label, labels]);\n\n const onPointerMove = (event: PointerEvent) => {\n if (element === null) {\n return;\n }\n const submenu = context.openSubmenu.current;\n const area = context.safeArea.current;\n if (!isSubmenuTrigger || submenu?.trigger !== element) {\n if (\n submenu &&\n area &&\n isInSafeArea(\n { x: event.clientX, y: event.clientY },\n area,\n area.submenu,\n )\n ) {\n return;\n }\n if (submenu && submenu.trigger !== element) {\n submenu.setOpen(false, \"none\");\n }\n }\n if (element.ownerDocument.activeElement !== element) {\n element.focus({ preventScroll: true });\n }\n };\n const onPointerLeave = () => {\n const popup = context.popup;\n if (\n element &&\n popup &&\n element.ownerDocument.activeElement === element &&\n !isSubmenuTrigger\n ) {\n popup.focus({ preventScroll: true });\n }\n };\n return {\n highlighted,\n handlers: {\n onFocus: () => setHighlighted(true),\n onBlur: () => setHighlighted(false),\n onPointerMove,\n onPointerLeave,\n },\n isItem: (node: HTMLElement) =>\n context.popup !== null && menuItems(context.popup).includes(node),\n };\n}\n","import { useControllableState } from \"../../hooks/use-controllable-state.ts\";\nimport { useElement } from \"../../hooks/use-element.ts\";\nimport { useRequiredContext } from \"../../hooks/use-required-context.ts\";\nimport type { ChangeDetails } from \"../../utils/change-details.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { stateAttributes } from \"../../utils/state-attributes.ts\";\nimport {\n checkedAttributes,\n type MenuCheckableItemState,\n MenuCheckboxItemContext,\n MenuContext,\n} from \"./menu-context.ts\";\nimport { useCheckableItem } from \"./use-checkable-item.ts\";\nimport { useMenuItem } from \"./use-menu-item.ts\";\n\nexport type MenuCheckboxItemState = MenuCheckableItemState;\n\nexport interface MenuCheckboxItemProps\n extends PartProps<MenuCheckboxItemState> {\n checked?: boolean;\n defaultChecked?: boolean;\n onCheckedChange?: (checked: boolean, details: ChangeDetails) => void;\n disabled?: boolean;\n /** The text typeahead matches (default: the item's text). */\n label?: string;\n /** A click closes every menu level (default `false`; Enter always closes, Space never). */\n closeOnClick?: boolean;\n}\n\n/** A `menuitemcheckbox` (spec/menu.md): toggles its checked state. */\nexport function MenuCheckboxItem({\n checked: checkedProp,\n defaultChecked = false,\n onCheckedChange,\n disabled = false,\n label,\n closeOnClick = false,\n onClick,\n children,\n ...props\n}: MenuCheckboxItemProps) {\n const context = useRequiredContext(MenuContext, \"Menu.CheckboxItem\");\n const [element, ref] = useElement<HTMLElement>();\n const item = useMenuItem(context, element, label, false);\n const [checked, setChecked] = useControllableState(\n checkedProp,\n defaultChecked,\n onCheckedChange,\n );\n const activation = useCheckableItem(context, {\n disabled,\n closeOnClick,\n change: (event) =>\n setChecked(!checked, { reason: \"item-press\", event }),\n });\n const state = { checked, highlighted: item.highlighted, disabled };\n const consumer = disabled ? props : { ...props, onClick };\n return (\n <MenuCheckboxItemContext.Provider value={state}>\n {renderElement(\n \"div\",\n { ...consumer, children },\n state,\n {\n role: \"menuitemcheckbox\",\n tabIndex: -1,\n \"aria-checked\": checked ? \"true\" : \"false\",\n \"aria-disabled\": disabled ? \"true\" : undefined,\n \"data-primitives-part\": `${context.component}-checkbox-item`,\n ...stateAttributes(checkedAttributes(state)),\n ...item.handlers,\n ...activation,\n },\n ref,\n )}\n </MenuCheckboxItemContext.Provider>\n );\n}\n","import { useContext } from \"react\";\nimport { useRequiredContext } from \"../../hooks/use-required-context.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { stateAttributes } from \"../../utils/state-attributes.ts\";\nimport {\n checkedAttributes,\n type MenuCheckableItemState,\n MenuCheckboxItemContext,\n MenuContext,\n} from \"./menu-context.ts\";\n\nexport interface MenuCheckboxItemIndicatorProps\n extends PartProps<MenuCheckableItemState> {\n /** Rendered while the item is unchecked too (default `false`). */\n keepMounted?: boolean;\n}\n\n/** Marks a checked CheckboxItem; hidden from assistive technologies (spec/menu.md). */\nexport function MenuCheckboxItemIndicator({\n keepMounted = false,\n ...props\n}: MenuCheckboxItemIndicatorProps) {\n const state = useRequiredContext(\n MenuCheckboxItemContext,\n \"Menu.CheckboxItemIndicator\",\n );\n const component = useContext(MenuContext)?.component ?? \"menu\";\n if (!state.checked && !keepMounted) {\n return null;\n }\n const { highlighted: _highlighted, ...attributes } =\n checkedAttributes(state);\n return renderElement(\"span\", props, state, {\n \"aria-hidden\": \"true\",\n \"data-primitives-part\": `${component}-checkbox-item-indicator`,\n ...stateAttributes(attributes),\n });\n}\n","import { createContext, useContext, useMemo, useState } from \"react\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { MenuContext } from \"./menu-context.ts\";\n\nexport const MenuGroupContext = createContext<\n ((id: string | undefined) => void) | null\n>(null);\n\n/** Groups items under its GroupLabel. */\nexport function MenuGroup(props: PartProps<Record<string, never>>) {\n const component = useContext(MenuContext)?.component ?? \"menu\";\n const [labelId, setLabelId] = useState<string>();\n const register = useMemo(() => setLabelId, []);\n return (\n <MenuGroupContext.Provider value={register}>\n {renderElement(\n \"div\",\n props,\n {},\n {\n role: \"group\",\n \"aria-labelledby\": labelId,\n \"data-primitives-part\": `${component}-group`,\n },\n )}\n </MenuGroupContext.Provider>\n );\n}\n","import { useContext, useId, useLayoutEffect } from \"react\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { MenuContext } from \"./menu-context.ts\";\nimport { MenuGroupContext } from \"./menu-group.tsx\";\n\n/** Names its Group. */\nexport function MenuGroupLabel(props: PartProps<Record<string, never>>) {\n const register = useContext(MenuGroupContext);\n const component = useContext(MenuContext)?.component ?? \"menu\";\n const generated = useId();\n const id = (props.id as string | undefined) ?? generated;\n useLayoutEffect(() => {\n register?.(id);\n return () => register?.(undefined);\n }, [id, register]);\n return renderElement(\n \"div\",\n props,\n {},\n { id, \"data-primitives-part\": `${component}-group-label` },\n );\n}\n","import type { MouseEvent } from \"react\";\nimport { useElement } from \"../../hooks/use-element.ts\";\nimport { useRequiredContext } from \"../../hooks/use-required-context.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { stateAttributes } from \"../../utils/state-attributes.ts\";\nimport { MenuContext } from \"./menu-context.ts\";\nimport { useMenuItem } from \"./use-menu-item.ts\";\n\nexport interface MenuItemState {\n highlighted: boolean;\n disabled: boolean;\n}\n\nexport interface MenuItemProps extends PartProps<MenuItemState> {\n disabled?: boolean;\n /** The text typeahead matches (default: the item's text). */\n label?: string;\n /** Activating the item closes every menu level (default `true`). */\n closeOnClick?: boolean;\n}\n\n/**\n * An action. Enter, Space and clicks fire its `click`, then close every level (spec/menu.md).\n * A disabled item stays focusable but is never activated.\n */\nexport function MenuItem({\n disabled = false,\n label,\n closeOnClick = true,\n onClick,\n ...props\n}: MenuItemProps) {\n const context = useRequiredContext(MenuContext, \"Menu.Item\");\n const [element, ref] = useElement<HTMLElement>();\n const item = useMenuItem(context, element, label, false);\n const state = { highlighted: item.highlighted, disabled };\n const consumer = disabled ? props : { ...props, onClick };\n return renderElement(\n \"div\",\n consumer,\n state,\n {\n role: \"menuitem\",\n tabIndex: -1,\n \"aria-disabled\": disabled ? \"true\" : undefined,\n \"data-primitives-part\": `${context.component}-item`,\n ...stateAttributes({ highlighted: item.highlighted, disabled }),\n ...item.handlers,\n onClick: (event: MouseEvent) => {\n if (!disabled && closeOnClick) {\n context.closeAll(\"item-press\", event.nativeEvent);\n }\n },\n },\n ref,\n );\n}\n","import { menuKeyTarget, submenuKeys } from \"@fragiola/primitives/collection\";\nimport { getDirection } from \"@fragiola/primitives/direction\";\nimport {\n nextTabbableAfter,\n previousTabbableBefore,\n} from \"@fragiola/primitives/focus\";\nimport { blockOutsidePointer } from \"@fragiola/primitives/inert\";\nimport { openOverlaySession } from \"@fragiola/primitives/overlay\";\nimport { lockScroll } from \"@fragiola/primitives/scroll-lock\";\nimport { type KeyboardEvent, useContext, useEffect, useRef } from \"react\";\nimport { DirectionContext } from \"../../direction/direction-context.ts\";\nimport { useRequiredContext } from \"../../hooks/use-required-context.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { stateAttributes } from \"../../utils/state-attributes.ts\";\nimport { MenuContext, type MenuContextValue } from \"./menu-context.ts\";\nimport { menuItems } from \"./menu-items.ts\";\n\nconst ROOT_RETURNS_FOCUS = new Set([\n \"escape-key\",\n \"item-press\",\n \"trigger-press\",\n]);\nconst SUBMENU_RETURNS_FOCUS = new Set([\"escape-key\", \"list-navigation\"]);\n// a modal menu's outside press reaches nothing, so focus goes back to the trigger\nconst MODAL_RETURNS_FOCUS_UNFOCUSED = new Set([\"outside-press\", \"none\"]);\n// a root menu closed through the controlled `open` (reason `none`) returns focus left inside it,\n// as Popover does; so does a handle's or the actions' close (`imperative-action`)\nconst RETURNS_FOCUS_UNFOCUSED = new Set([\"none\", \"imperative-action\"]);\n\nfunction rootOf(context: MenuContextValue): MenuContextValue {\n return context.parent ? rootOf(context.parent) : context;\n}\n\n/** Every positioner of the chain of open levels, for Tab to skip. */\nfunction positioners(context: MenuContextValue): (HTMLElement | null)[] {\n const own = [context.positioner];\n return context.parent ? [...positioners(context.parent), ...own] : own;\n}\n\n/** One menu level: roving focus, typeahead, Escape per level (spec/menu.md). */\nexport function MenuPopup(\n props: PartProps<{ open: boolean; side: string; align: string }>,\n) {\n const context = useRequiredContext(MenuContext, \"Menu.Popup\");\n const direction = useContext(DirectionContext);\n const {\n open,\n popup,\n positioner,\n trigger,\n setOpen,\n lastReason,\n pendingHighlight,\n } = context;\n const nested = context.parent !== null;\n const modal = context.modal && !nested;\n const modalNow = useRef(modal);\n modalNow.current = modal;\n // read when the session needs them: the active trigger may move while it is open\n const triggers = useRef(context);\n triggers.current = context;\n\n useEffect(() => {\n if (!open || popup === null) {\n return undefined;\n }\n // Escape, an item and the trigger give focus back to this level's trigger; the closing\n // arrow of a submenu gives it back to its submenu trigger\n const doc = popup.ownerDocument;\n // a context menu's area is no trigger that toggles it: a press on it is outside the menu,\n // but it is still what the menu was opened from (spec/context-menu.md)\n const area = !nested && triggers.current.component === \"context-menu\";\n const session = openOverlaySession(doc, {\n elements: () => [positioner ?? popup],\n ignore: () => (area ? [] : triggers.current.triggers),\n owner: () => triggers.current.triggers,\n dismiss: (reason, event) => setOpen(false, reason, event),\n returnFocus: {\n when: nested ? SUBMENU_RETURNS_FOCUS : ROOT_RETURNS_FOCUS,\n whenUnfocused: () =>\n modalNow.current\n ? MODAL_RETURNS_FOCUS_UNFOCUSED\n : RETURNS_FOCUS_UNFOCUSED,\n reason: () => lastReason.current ?? (nested ? null : \"none\"),\n to: () =>\n nested\n ? triggers.current.trigger\n : triggers.current.returnTarget(),\n },\n });\n return session.end;\n }, [open, popup, positioner, setOpen, lastReason, nested]);\n\n // on open, and when it moves to another trigger: the keyboard's item, else the popup with no\n // highlight (spec/menu.md, \"Focus\")\n // biome-ignore lint/correctness/useExhaustiveDependencies: a new active trigger focuses again\n useEffect(() => {\n if (!open || popup === null) {\n return;\n }\n const items = menuItems(popup);\n const highlight = pendingHighlight.current;\n pendingHighlight.current = null;\n // a bar moving to this menu keeps the focus on its item (spec/menu.md, \"In a Menubar\")\n if (highlight === \"keep\") {\n return;\n }\n const target =\n highlight === \"first\"\n ? items[0]\n : highlight === \"last\"\n ? items.at(-1)\n : undefined;\n (target ?? popup).focus({ preventScroll: true });\n }, [open, popup, trigger, pendingHighlight]);\n\n // spec/menu.md, \"Modal\": the root level locks the scroll and blocks the outside pointer while\n // open; on its own, so toggling `modal` while open keeps the session (and the focus) as it is\n useEffect(() => {\n if (!open || popup === null || !modal) {\n return undefined;\n }\n const doc = popup.ownerDocument;\n const unlock = lockScroll(doc);\n const unblock = blockOutsidePointer(doc);\n return () => {\n unblock();\n unlock();\n };\n }, [open, popup, modal]);\n\n const onKeyDown = (event: KeyboardEvent) => {\n // a submenu's keys bubble through its portal in React's tree: each level handles its own\n if (\n popup === null ||\n event.defaultPrevented ||\n !popup.contains(event.target as Node)\n ) {\n return;\n }\n const items = menuItems(popup);\n const active = popup.ownerDocument.activeElement as HTMLElement | null;\n const current = active ? items.indexOf(active) : -1;\n const focusAt = (index: number) =>\n items[index]?.focus({ preventScroll: true });\n const { close: closeKey } = submenuKeys(\n getDirection(popup, direction) === \"rtl\",\n );\n switch (event.key) {\n case \"ArrowDown\":\n case \"ArrowUp\":\n case \"Home\":\n case \"End\": {\n event.preventDefault();\n const target = menuKeyTarget(event.key, current, items.length, {\n loop: context.loopFocus,\n });\n if (target !== null) {\n focusAt(target);\n }\n return;\n }\n case \"Enter\":\n case \" \":\n if (active && current !== -1) {\n event.preventDefault();\n active.click();\n }\n return;\n case \"Tab\": {\n event.preventDefault();\n const root = rootOf(context);\n const skip = positioners(context);\n // after the trigger (a context menu: the element focused when it opened)\n const from = root.returnTarget() ?? root.trigger;\n const target = from\n ? event.shiftKey\n ? previousTabbableBefore(from, skip)\n : nextTabbableAfter(from, skip)\n : null;\n context.closeAll(\"focus-out\", event.nativeEvent);\n target?.focus();\n return;\n }\n default:\n if (nested && event.key === closeKey) {\n event.preventDefault();\n setOpen(false, \"list-navigation\", event.nativeEvent);\n return;\n }\n // the keys a level leaves go to its bar first (spec/menu.md, \"In a Menubar\")\n if (context.bar?.menuKeyDown(event, context)) {\n event.preventDefault();\n return;\n }\n if (\n event.key.length === 1 &&\n !event.ctrlKey &&\n !event.metaKey &&\n !event.altKey\n ) {\n const labels = items.map(\n (item) =>\n context.labels.get(item) ?? item.textContent ?? \"\",\n );\n const index = context.typeahead.match(\n event.key,\n labels,\n current,\n );\n if (index !== -1) {\n event.preventDefault();\n focusAt(index);\n }\n }\n }\n };\n\n const status = context.presence.status;\n const contextMenu = context.component === \"context-menu\";\n return renderElement(\n \"div\",\n props,\n { open, ...context.placed },\n {\n id: context.popupId,\n role: \"menu\",\n // the active trigger names the menu (a submenu's: its SubmenuTrigger); no button names\n // a context menu (spec/context-menu.md)\n \"aria-labelledby\":\n contextMenu && !nested\n ? undefined\n : (context.activeTriggerId ?? context.triggerId),\n \"aria-orientation\": \"vertical\",\n tabIndex: -1,\n \"data-primitives-part\": `${context.component}-popup`,\n ...stateAttributes({\n open,\n closed: !open,\n side: context.placed.side,\n align: context.placed.align,\n nested,\n \"starting-style\": status === \"starting\",\n \"ending-style\": status === \"ending\",\n }),\n onKeyDown,\n // no browser menu over a context menu (spec/context-menu.md, \"Pointer\")\n onContextMenu: contextMenu\n ? (event: { preventDefault: () => void }) =>\n event.preventDefault()\n : undefined,\n },\n context.setPopup,\n );\n}\n","import {\n type OverlayPortalProps,\n useOverlayPortal,\n} from \"../../hooks/use-overlay-portal.ts\";\nimport { useRequiredContext } from \"../../hooks/use-required-context.ts\";\nimport { MenuContext } from \"./menu-context.ts\";\n\nexport interface MenuPortalProps extends OverlayPortalProps {}\n\nexport function MenuPortal(props: MenuPortalProps) {\n const context = useRequiredContext(MenuContext, \"Menu.Portal\");\n return useOverlayPortal(context.presence.mounted, props);\n}\n","import { useLayoutEffect } from \"react\";\nimport {\n type PositionerProps,\n usePositioner,\n} from \"../../hooks/use-positioner.ts\";\nimport { useRequiredContext } from \"../../hooks/use-required-context.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { stateAttributes } from \"../../utils/state-attributes.ts\";\nimport { MenuContext } from \"./menu-context.ts\";\n\nexport interface MenuPositionerState {\n open: boolean;\n side: string;\n align: string;\n}\n\nexport interface MenuPositionerProps\n extends PartProps<MenuPositionerState>,\n PositionerProps {}\n\n/** Places a menu level: below its trigger, or at the end side of its submenu trigger. */\nexport function MenuPositioner({\n side,\n align,\n sideOffset,\n alignOffset,\n collisionPadding,\n anchor,\n ...props\n}: MenuPositionerProps) {\n const context = useRequiredContext(MenuContext, \"Menu.Positioner\");\n const nested = context.parent !== null;\n const placed = usePositioner(\n { side, align, sideOffset, alignOffset, collisionPadding, anchor },\n // a vertical bar's menus open at its end side, as submenus (spec/menubar.md)\n nested || context.bar?.orientation === \"vertical\"\n ? { side: \"inline-end\", align: \"start\" }\n : { side: \"bottom\", align: \"start\" },\n context.anchor ?? context.trigger,\n context.positioner,\n null,\n context.presence.mounted,\n );\n const { setPlaced } = context;\n useLayoutEffect(() => setPlaced(placed), [placed, setPlaced]);\n return renderElement(\n \"div\",\n props,\n { open: context.open, ...placed },\n {\n role: \"presentation\",\n hidden: context.presence.mounted ? undefined : true,\n // a modal menu blocks the pointer outside; its levels take it back (spec/menu.md)\n style: context.modal ? { pointerEvents: \"auto\" } : undefined,\n \"data-primitives-part\": `${context.component}-positioner`,\n ...stateAttributes({\n open: context.open,\n closed: !context.open,\n side: placed.side,\n align: placed.align,\n nested,\n }),\n },\n context.setPositioner,\n );\n}\n","import { useContext, useMemo } from \"react\";\nimport { useControllableState } from \"../../hooks/use-controllable-state.ts\";\nimport type { ChangeDetails } from \"../../utils/change-details.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { stateAttributes } from \"../../utils/state-attributes.ts\";\nimport { MenuContext, MenuRadioGroupContext } from \"./menu-context.ts\";\n\nexport interface MenuRadioGroupProps extends PartProps<{ disabled: boolean }> {\n /** The checked RadioItem's value; `null` for none (controlled). */\n value?: string | null;\n defaultValue?: string | null;\n onValueChange?: (value: string | null, details: ChangeDetails) => void;\n /** Disables every RadioItem of the group. */\n disabled?: boolean;\n}\n\n/** A `group` of RadioItems holding their value (spec/menu.md). */\nexport function MenuRadioGroup({\n value: valueProp,\n defaultValue = null,\n onValueChange,\n disabled = false,\n children,\n ...props\n}: MenuRadioGroupProps) {\n const component = useContext(MenuContext)?.component ?? \"menu\";\n const [value, setValue] = useControllableState<\n string | null,\n ChangeDetails\n >(valueProp, defaultValue, onValueChange);\n const group = useMemo(\n () => ({\n value,\n disabled,\n setValue: (next: string, event: Event) =>\n setValue(next, { reason: \"item-press\", event }),\n }),\n [value, disabled, setValue],\n );\n return (\n <MenuRadioGroupContext.Provider value={group}>\n {renderElement(\n \"div\",\n { ...props, children },\n { disabled },\n {\n role: \"group\",\n \"data-primitives-part\": `${component}-radio-group`,\n ...stateAttributes({ disabled }),\n },\n )}\n </MenuRadioGroupContext.Provider>\n );\n}\n","import { useElement } from \"../../hooks/use-element.ts\";\nimport { useRequiredContext } from \"../../hooks/use-required-context.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { stateAttributes } from \"../../utils/state-attributes.ts\";\nimport {\n checkedAttributes,\n type MenuCheckableItemState,\n MenuContext,\n MenuRadioGroupContext,\n MenuRadioItemContext,\n} from \"./menu-context.ts\";\nimport { useCheckableItem } from \"./use-checkable-item.ts\";\nimport { useMenuItem } from \"./use-menu-item.ts\";\n\nexport type MenuRadioItemState = MenuCheckableItemState;\n\nexport interface MenuRadioItemProps extends PartProps<MenuRadioItemState> {\n value: string;\n disabled?: boolean;\n /** The text typeahead matches (default: the item's text). */\n label?: string;\n /** A click closes every menu level (default `false`; Enter always closes, Space never). */\n closeOnClick?: boolean;\n}\n\n/** A `menuitemradio` of its RadioGroup (spec/menu.md): checks its value. */\nexport function MenuRadioItem({\n value,\n disabled: disabledProp = false,\n label,\n closeOnClick = false,\n onClick,\n children,\n ...props\n}: MenuRadioItemProps) {\n const context = useRequiredContext(MenuContext, \"Menu.RadioItem\");\n const group = useRequiredContext(MenuRadioGroupContext, \"Menu.RadioItem\");\n const [element, ref] = useElement<HTMLElement>();\n const item = useMenuItem(context, element, label, false);\n const disabled = disabledProp || group.disabled;\n const checked = group.value === value;\n const activation = useCheckableItem(context, {\n disabled,\n closeOnClick,\n change: (event) => group.setValue(value, event),\n });\n const state = { checked, highlighted: item.highlighted, disabled };\n const consumer = disabled ? props : { ...props, onClick };\n return (\n <MenuRadioItemContext.Provider value={state}>\n {renderElement(\n \"div\",\n { ...consumer, children },\n state,\n {\n role: \"menuitemradio\",\n tabIndex: -1,\n \"aria-checked\": checked ? \"true\" : \"false\",\n \"aria-disabled\": disabled ? \"true\" : undefined,\n \"data-primitives-part\": `${context.component}-radio-item`,\n ...stateAttributes(checkedAttributes(state)),\n ...item.handlers,\n ...activation,\n },\n ref,\n )}\n </MenuRadioItemContext.Provider>\n );\n}\n","import { useContext } from \"react\";\nimport { useRequiredContext } from \"../../hooks/use-required-context.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { stateAttributes } from \"../../utils/state-attributes.ts\";\nimport {\n checkedAttributes,\n type MenuCheckableItemState,\n MenuContext,\n MenuRadioItemContext,\n} from \"./menu-context.ts\";\n\nexport interface MenuRadioItemIndicatorProps\n extends PartProps<MenuCheckableItemState> {\n /** Rendered while the item is unchecked too (default `false`). */\n keepMounted?: boolean;\n}\n\n/** Marks a checked RadioItem; hidden from assistive technologies (spec/menu.md). */\nexport function MenuRadioItemIndicator({\n keepMounted = false,\n ...props\n}: MenuRadioItemIndicatorProps) {\n const state = useRequiredContext(\n MenuRadioItemContext,\n \"Menu.RadioItemIndicator\",\n );\n const component = useContext(MenuContext)?.component ?? \"menu\";\n if (!state.checked && !keepMounted) {\n return null;\n }\n const { highlighted: _highlighted, ...attributes } =\n checkedAttributes(state);\n return renderElement(\"span\", props, state, {\n \"aria-hidden\": \"true\",\n \"data-primitives-part\": `${component}-radio-item-indicator`,\n ...stateAttributes(attributes),\n });\n}\n","import { createTypeahead } from \"@fragiola/primitives/collection\";\nimport type {\n Align,\n Side,\n VirtualAnchor,\n} from \"@fragiola/primitives/positioning\";\nimport {\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n type OverlayRootProps,\n type OverlayTriggerRootProps,\n useOverlayRoot,\n} from \"../../hooks/use-overlay-root.ts\";\nimport { MenuBarContext } from \"./menu-bar-context.ts\";\nimport {\n type MenuComponent,\n MenuContext,\n type MenuContextValue,\n type PendingHighlight,\n type SafeArea,\n} from \"./menu-context.ts\";\n\n/** What a root menu level gets from the component it belongs to (a Menu or a ContextMenu). */\nexport interface MenuRootOptions {\n /** The part attributes' prefix (default: the parent level's, else `menu`). */\n component?: MenuComponent;\n /** What the positioner anchors to instead of the trigger (a context menu's point). */\n anchor?: Element | VirtualAnchor | null;\n /** Where focus returns, and where Tab moves on from (default: the trigger). */\n returnTarget?: () => HTMLElement | null;\n}\n\n/** The state of one menu level, a root or a submenu (spec/menu.md). */\nexport function useMenuRoot(\n {\n loopFocus = true,\n modal: modalProp = false,\n ...props\n }: OverlayRootProps &\n OverlayTriggerRootProps & { loopFocus?: boolean; modal?: boolean },\n nested: boolean,\n options: MenuRootOptions = {},\n): MenuContextValue {\n const parent = useContext(MenuContext);\n const enclosingBar = useContext(MenuBarContext);\n const root = useOverlayRoot(props);\n const pendingHighlight = useRef<PendingHighlight>(null);\n const typeahead = useMemo(() => createTypeahead(), []);\n const labels = useMemo(() => new Map<Element, string>(), []);\n const openSubmenu = useRef<MenuContextValue | null>(null);\n const safeArea = useRef<SafeArea | null>(null);\n const owner = nested ? parent : null;\n const component = options.component ?? owner?.component ?? \"menu\";\n // a root Menu inside a bar is one of its menus (spec/menu.md, \"In a Menubar\"); its levels\n // share the bar\n const bar = owner ? owner.bar : component === \"menu\" ? enclosingBar : null;\n const [placed, setPlaced] = useState<{ side: Side; align: Align }>(\n nested || bar?.orientation === \"vertical\"\n ? { side: \"inline-end\", align: \"start\" }\n : { side: \"bottom\", align: \"start\" },\n );\n // a submenu follows its root menu, a menu of a bar the bar\n const modal = owner ? owner.modal : bar ? bar.modal : modalProp;\n const anchor = options.anchor ?? null;\n const returnTarget = useRef(options.returnTarget);\n returnTarget.current = options.returnTarget;\n const { setOpen } = root;\n const closeAll = useCallback(\n (\n reason: \"item-press\" | \"focus-out\" | \"outside-press\",\n event?: Event,\n ) => {\n setOpen(false, reason, event);\n owner?.closeAll(reason, event);\n },\n [setOpen, owner],\n );\n const value: MenuContextValue = useMemo(\n () => ({\n ...root,\n component,\n anchor,\n returnTarget: () =>\n returnTarget.current ? returnTarget.current() : root.trigger,\n parent: owner,\n loopFocus,\n modal,\n bar,\n pendingHighlight,\n typeahead,\n labels,\n placed,\n setPlaced,\n closeAll,\n openSubmenu,\n safeArea,\n }),\n [\n root,\n component,\n anchor,\n owner,\n loopFocus,\n modal,\n bar,\n typeahead,\n labels,\n placed,\n closeAll,\n ],\n );\n // a parent level knows its open submenu, so a hovered sibling can close it\n useEffect(() => {\n if (owner === null || !value.open) {\n return undefined;\n }\n owner.openSubmenu.current = value;\n return () => {\n if (owner.openSubmenu.current === value) {\n owner.openSubmenu.current = null;\n }\n };\n }, [owner, value]);\n return value;\n}\n","import type { ReactNode } from \"react\";\nimport type {\n OverlayRootProps,\n OverlayTriggerRootProps,\n} from \"../../hooks/use-overlay-root.ts\";\nimport { useAttachHandle } from \"../../hooks/use-overlay-trigger.ts\";\nimport { MenuBarContext } from \"./menu-bar-context.ts\";\nimport { MenuContext } from \"./menu-context.ts\";\nimport type { MenuHandle } from \"./menu-handle.ts\";\nimport { useMenuRoot } from \"./use-menu-root.ts\";\n\nexport interface MenuSubmenuRootProps extends OverlayRootProps {\n /** Arrow keys wrap at the ends (default `true`). */\n loopFocus?: boolean;\n children?: ReactNode;\n}\n\nexport interface MenuRootProps<Payload = unknown>\n extends Omit<MenuSubmenuRootProps, \"children\">,\n OverlayTriggerRootProps {\n /**\n * Locks the page's scroll and blocks the pointer outside the menu while it is open (default\n * `false`: the APG menu button is non-modal; spec/menu.md, \"Modal\").\n */\n modal?: boolean;\n /** Connects Triggers rendered outside the Root (spec/menu.md, \"Detached triggers\"). */\n handle?: MenuHandle<Payload>;\n /** The content, or a function of the active trigger's payload. */\n children?:\n | ReactNode\n | ((state: { payload: Payload | undefined }) => ReactNode);\n}\n\n/** Holds the state of one menu level; renders no element (spec/menu.md). */\nexport function MenuRoot<Payload = unknown>({\n children,\n handle,\n ...props\n}: MenuRootProps<Payload>) {\n const value = useMenuRoot(props, false);\n useAttachHandle(handle, value);\n // a Menu opened from inside this one's content is no menu of the bar (spec/menu.md)\n return (\n <MenuContext.Provider value={value}>\n <MenuBarContext.Provider value={null}>\n {typeof children === \"function\"\n ? children({\n payload: value.payload as Payload | undefined,\n })\n : children}\n </MenuBarContext.Provider>\n </MenuContext.Provider>\n );\n}\n\n/** A nested menu level; its trigger is a `SubmenuTrigger` item of the parent menu. */\nexport function MenuSubmenuRoot({ children, ...props }: MenuSubmenuRootProps) {\n const value = useMenuRoot(props, true);\n return (\n <MenuContext.Provider value={value}>{children}</MenuContext.Provider>\n );\n}\n","import { useContext } from \"react\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { MenuContext } from \"./menu-context.ts\";\n\nexport function MenuSeparator(props: PartProps<Record<string, never>>) {\n const component = useContext(MenuContext)?.component ?? \"menu\";\n return renderElement(\n \"div\",\n props,\n {},\n {\n role: \"separator\",\n \"aria-orientation\": \"horizontal\",\n \"data-primitives-part\": `${component}-separator`,\n },\n );\n}\n","import { submenuKeys } from \"@fragiola/primitives/collection\";\nimport { getDirection } from \"@fragiola/primitives/direction\";\nimport {\n type KeyboardEvent,\n type MouseEvent,\n type PointerEvent,\n useContext,\n useEffect,\n useRef,\n} from \"react\";\nimport { DirectionContext } from \"../../direction/direction-context.ts\";\nimport { useElement } from \"../../hooks/use-element.ts\";\nimport { useRequiredContext } from \"../../hooks/use-required-context.ts\";\nimport { mergeRefs } from \"../../utils/merge-refs.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { stateAttributes } from \"../../utils/state-attributes.ts\";\nimport { MenuContext } from \"./menu-context.ts\";\nimport { useMenuItem } from \"./use-menu-item.ts\";\n\nexport interface MenuSubmenuTriggerState {\n open: boolean;\n highlighted: boolean;\n disabled: boolean;\n}\n\nexport interface MenuSubmenuTriggerProps\n extends PartProps<MenuSubmenuTriggerState> {\n disabled?: boolean;\n label?: string;\n /** Hovering opens the submenu (default `true`), after `delay` ms (default 100). */\n openOnHover?: boolean;\n delay?: number;\n}\n\n/** An item of the parent menu that opens its submenu (spec/menu.md). */\nexport function MenuSubmenuTrigger({\n disabled = false,\n label,\n openOnHover = true,\n delay = 100,\n ...props\n}: MenuSubmenuTriggerProps) {\n const submenu = useRequiredContext(MenuContext, \"Menu.SubmenuTrigger\");\n const direction = useContext(DirectionContext);\n const parent = submenu.parent;\n if (parent === null) {\n throw new Error(\n \"<Menu.SubmenuTrigger> must be inside <Menu.SubmenuRoot>.\",\n );\n }\n const [element, ref] = useElement<HTMLElement>();\n const item = useMenuItem(parent, element, label, true);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n useEffect(() => () => clearTimeout(timer.current), []);\n const context = useContext(MenuContext);\n\n const open = (\n highlight: \"first\" | null,\n reason: \"trigger-press\" | \"list-navigation\",\n event?: Event,\n ) => {\n if (disabled) {\n return;\n }\n submenu.pendingHighlight.current = highlight;\n submenu.setOpen(true, reason, event);\n };\n const state = {\n open: submenu.open,\n highlighted: item.highlighted,\n disabled,\n };\n return renderElement(\n \"div\",\n props,\n state,\n {\n id: submenu.triggerId,\n role: \"menuitem\",\n tabIndex: -1,\n \"aria-haspopup\": \"menu\",\n \"aria-expanded\": submenu.open,\n \"aria-controls\": submenu.open ? submenu.popupId : undefined,\n \"aria-disabled\": disabled ? \"true\" : undefined,\n \"data-primitives-part\": `${parent.component}-submenu-trigger`,\n ...stateAttributes({\n \"popup-open\": submenu.open,\n highlighted: item.highlighted,\n disabled,\n }),\n ...item.handlers,\n onClick: (event: MouseEvent) =>\n open(null, \"trigger-press\", event.nativeEvent),\n onKeyDown: (event: KeyboardEvent) => {\n const { open: openKey } = submenuKeys(\n element !== null &&\n getDirection(element, direction) === \"rtl\",\n );\n if (\n event.key === openKey ||\n event.key === \"Enter\" ||\n event.key === \" \"\n ) {\n event.preventDefault();\n event.stopPropagation();\n open(\n \"first\",\n event.key === openKey\n ? \"list-navigation\"\n : \"trigger-press\",\n event.nativeEvent,\n );\n }\n },\n onPointerMove: (event: PointerEvent) => {\n item.handlers.onPointerMove(event);\n if (\n openOnHover &&\n !submenu.open &&\n timer.current === undefined\n ) {\n timer.current = setTimeout(() => {\n timer.current = undefined;\n open(null, \"trigger-press\");\n }, delay);\n }\n },\n onPointerLeave: (event: PointerEvent) => {\n clearTimeout(timer.current);\n timer.current = undefined;\n if (submenu.open && submenu.popup) {\n parent.safeArea.current = {\n x: event.clientX,\n y: event.clientY,\n submenu: submenu.popup,\n };\n }\n },\n },\n mergeRefs(ref, context === submenu ? submenu.setTrigger : undefined),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwDA,MAAa,cAAc,cAAuC,IAAI;AAStE,MAAa,0BACT,cAA6C,IAAI;AAErD,MAAa,uBACT,cAA6C,IAAI;AASrD,MAAa,wBACT,cAAiD,IAAI;;AAGzD,SAAgB,kBAAkB,OAA+B;CAC7D,OAAO;EACH,SAAS,MAAM;EACf,WAAW,CAAC,MAAM;EAClB,aAAa,MAAM;EACnB,UAAU,MAAM;CACpB;AACJ;;;;;;;AChFA,SAAgB,iBACZ,SACA,EACI,UACA,cACA,UAMN;CACE,MAAM,MAAM,OAA6B,IAAI;CAC7C,OAAO;EACH,YAAY,UAAsC;GAC9C,IAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,KACvC;GAGJ,MAAM,eAAe;GACrB,IAAI,UAAU,MAAM;GACpB,MAAM,cAAc,MAAM;GAC1B,IAAI,UAAU;EAClB;EACA,UAAU,UAAsB;GAC5B,IAAI,UACA;GAEJ,OAAO,MAAM,WAAW;GACxB,MAAM,UAAU,IAAI;GACpB,IAAI,YAAY,WAAY,YAAY,QAAQ,cAC5C,QAAQ,SAAS,cAAc,MAAM,WAAW;EAExD;CACJ;AACJ;;;;;;ACnCA,SAAgB,YACZ,SACA,SACA,OACA,kBACF;CACE,MAAM,CAAC,aAAa,kBAAkB,SAAS,KAAK;CACpD,MAAM,EAAE,WAAW;CACnB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MAAM,eAAe;GAC9B,GAAG,KAAK;EAEhB;EACA,iBAAiB,UAAwB;GACrC,aAAa,MAAM,OAAO;GAC1B,MAAM,UAAU,KAAA;GAChB,IAAI,QAAQ,QAAQ,QAAQ,OACxB,OAAO,SAAS,UAAU;IACtB,GAAG,MAAM;IACT,GAAG,MAAM;IACT,SAAS,QAAQ;GACrB;EAER;CACJ,GACA,UAAU,KAAK,YAAY,UAAU,QAAQ,aAAa,KAAA,CAAS,CACvE;AACJ"}
package/dist/menu.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { a as OverlayActions, i as OpenChangeDetails, n as ChangeReason, t as ChangeDetails } from "./change-details-CPSkPCNw.js";
2
+ import { n as RenderProp } from "./render-element-Pwuv2wsL.js";
3
+ import { t as OverlayPortalProps } from "./use-overlay-portal-D8GjZ-m7.js";
4
+ import { n as OverlayTriggerRootProps, t as OverlayRootProps } from "./use-overlay-root-BDO5E_0S.js";
5
+ import { t as OverlayHandle } from "./overlay-handle-DzzlzKqP.js";
6
+ import { t as OverlayTriggerProps } from "./use-overlay-trigger-PP99t2ZF.js";
7
+ import { t as PositionerProps } from "./use-positioner-BpxM4U5Y.js";
8
+ import { A as MenuCheckboxItemIndicatorProps, C as MenuPositionerState, D as MenuItemProps, M as MenuCheckboxItemProps, N as MenuCheckboxItemState, O as MenuItemState, P as MenuCheckableItemState, S as MenuPositionerProps, T as MenuPortalProps, _ as MenuRadioItemProps, b as MenuRadioGroupProps, d as MenuSubmenuRootProps, f as MenuHandle, h as MenuRadioItemIndicatorProps, l as MenuRootProps, o as MenuSubmenuTriggerProps, p as createMenuHandle, s as MenuSubmenuTriggerState, v as MenuRadioItemState } from "./menu-separator-CzAc4jM8.js";
9
+ import { a as MenuTriggerState, i as MenuTriggerProps, n as Side, r as Menu, t as Align } from "./index-pSrGVYre.js";
10
+ export { type Align, type ChangeDetails, type ChangeReason, Menu, type MenuCheckableItemState, type MenuCheckboxItemIndicatorProps, type MenuCheckboxItemProps, type MenuCheckboxItemState, type MenuHandle, type MenuItemProps, type MenuItemState, type MenuPortalProps, type MenuPositionerProps, type MenuPositionerState, type MenuRadioGroupProps, type MenuRadioItemIndicatorProps, type MenuRadioItemProps, type MenuRadioItemState, type MenuRootProps, type MenuSubmenuRootProps, type MenuSubmenuTriggerProps, type MenuSubmenuTriggerState, type MenuTriggerProps, type MenuTriggerState, type OpenChangeDetails, type OverlayActions, type OverlayHandle, type OverlayPortalProps, type OverlayRootProps, type OverlayTriggerProps, type OverlayTriggerRootProps, type PositionerProps, type RenderProp, type Side, createMenuHandle };
package/dist/menu.js ADDED
@@ -0,0 +1 @@
1
+ export { t as Menu, n as createMenuHandle } from "./menu-oZj27rvf.js";
@@ -0,0 +1,213 @@
1
+ import { t as DirectionContext } from "./direction-context-CiRdNJmu.js";
2
+ import { t as useElement } from "./use-element-tpFZ-kuA.js";
3
+ import { t as useRovingComposite } from "./use-roving-composite-D0vtGxm8.js";
4
+ import { t as renderElement } from "./render-element-DXbUbfgN.js";
5
+ import { t as stateAttributes } from "./state-attributes-DhboDeMS.js";
6
+ import { n as menuItems, t as MenuBarContext } from "./menu-bar-context-1duNlOWo.js";
7
+ import { useCallback, useContext, useMemo, useRef } from "react";
8
+ import { jsx } from "react/jsx-runtime";
9
+ import { inDocumentOrder, rovingKeyTarget, rovingKeys, submenuKeys } from "@fragiola/primitives/collection";
10
+ import { getDirection } from "@fragiola/primitives/direction";
11
+ // src/components/menubar/menubar.tsx
12
+ /** A press within this time after a hover opened a menu keeps it open (Base UI's patient click). */
13
+ const PATIENT_PRESS_MS = 500;
14
+ /** The open keys of an item: the item of its menu they focus (spec/menubar.md, "Keyboard"). */
15
+ function openKeyTarget(key, orientation, rtl) {
16
+ if (key === "Enter" || key === " ") return "first";
17
+ if (orientation === "vertical") return key === submenuKeys(rtl).open ? "first" : null;
18
+ return key === "ArrowDown" ? "first" : key === "ArrowUp" ? "last" : null;
19
+ }
20
+ function rootLevel(level) {
21
+ return level.parent ? rootLevel(level.parent) : level;
22
+ }
23
+ /**
24
+ * A bar of menus with one tab stop (spec/menubar.md, the APG menubar): the `Menu.Trigger`s of the
25
+ * `Menu.Root`s inside it are its items; it moves the focus between them and, while a menu is
26
+ * open, from that menu to the next, by the keys and by hovering.
27
+ */
28
+ function Menubar({ orientation = "horizontal", loopFocus = true, modal = false, disabled = false, ...props }) {
29
+ const direction = useContext(DirectionContext);
30
+ const [element, ref] = useElement();
31
+ const { scope, onKeyDown: rovingKeyDown } = useRovingComposite({
32
+ orientation,
33
+ loopFocus,
34
+ disabled,
35
+ root: element
36
+ });
37
+ const entries = useRef(/* @__PURE__ */ new Map()).current;
38
+ const hoverOpened = useRef(null);
39
+ const latest = useRef({
40
+ orientation,
41
+ loopFocus,
42
+ direction,
43
+ scope
44
+ });
45
+ latest.current = {
46
+ orientation,
47
+ loopFocus,
48
+ direction,
49
+ scope
50
+ };
51
+ const register = useCallback((trigger, entry) => {
52
+ entries.set(trigger, entry);
53
+ return () => {
54
+ if (entries.get(trigger) === entry) entries.delete(trigger);
55
+ };
56
+ }, [entries]);
57
+ /** The open menu of the bar and its Trigger, if any. */
58
+ const openOne = useCallback(() => {
59
+ for (const [trigger, entry] of entries) if (entry.current.menu.open) return {
60
+ trigger,
61
+ menu: entry.current.menu
62
+ };
63
+ return null;
64
+ }, [entries]);
65
+ /** Opens a Trigger's menu, unless it is disabled. */
66
+ const openMenu = useCallback((trigger, reason, event, highlight) => {
67
+ const entry = entries.get(trigger)?.current;
68
+ if (entry === void 0 || entry.disabled) return;
69
+ entry.menu.pendingHighlight.current = highlight;
70
+ if (!entry.menu.setOpen(true, reason, event, trigger)) entry.menu.pendingHighlight.current = null;
71
+ }, [entries]);
72
+ /**
73
+ * Moves from the open menu to another item (the keys): the focus first, then the open menu
74
+ * closes and the item's menu opens with the focus kept on it (APG).
75
+ */
76
+ const moveTo = useCallback((target, from, event) => {
77
+ target.focus();
78
+ from?.setOpen(false, "list-navigation", event);
79
+ openMenu(target, "list-navigation", event, "keep");
80
+ }, [openMenu]);
81
+ const menuKeyDown = useCallback((event, level) => {
82
+ if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return false;
83
+ const root = rootLevel(level);
84
+ const trigger = root.trigger;
85
+ if (trigger === null || !entries.has(trigger)) return false;
86
+ const current = latest.current;
87
+ const rtl = getDirection(level.popup ?? trigger, current.direction) === "rtl";
88
+ const nested = level.parent !== null;
89
+ if (current.orientation === "vertical") {
90
+ if (!nested && event.key === submenuKeys(rtl).close) {
91
+ trigger.focus();
92
+ root.setOpen(false, "list-navigation", event.nativeEvent);
93
+ return true;
94
+ }
95
+ return false;
96
+ }
97
+ const { next, previous } = rovingKeys("horizontal", rtl);
98
+ if (event.key !== next && !(event.key === previous && !nested)) return false;
99
+ const triggers = inDocumentOrder([...entries.keys()], (t) => t);
100
+ const index = rovingKeyTarget(event.key, triggers.indexOf(trigger), triggers.length, {
101
+ orientation: "horizontal",
102
+ rtl,
103
+ loop: current.loopFocus
104
+ });
105
+ const target = index === null ? void 0 : triggers[index];
106
+ if (target !== void 0 && target !== trigger) moveTo(target, root, event.nativeEvent);
107
+ return true;
108
+ }, [entries, moveTo]);
109
+ const press = useCallback((trigger, event) => {
110
+ const entry = entries.get(trigger)?.current;
111
+ if (entry === void 0 || entry.disabled) return;
112
+ const { menu } = entry;
113
+ if (!menu.open) {
114
+ openMenu(trigger, "trigger-press", event.nativeEvent, null);
115
+ return;
116
+ }
117
+ const hovered = hoverOpened.current;
118
+ hoverOpened.current = null;
119
+ if (hovered?.trigger === trigger && event.timeStamp - hovered.time < PATIENT_PRESS_MS) return;
120
+ menu.pendingHighlight.current = null;
121
+ menu.setOpen(false, "trigger-press", event.nativeEvent, trigger);
122
+ }, [entries, openMenu]);
123
+ const hover = useCallback((trigger, event) => {
124
+ const entry = entries.get(trigger)?.current;
125
+ if (event.pointerType === "touch" || entry === void 0 || entry.disabled || entry.menu.open) return;
126
+ const open = openOne();
127
+ if (open === null) return;
128
+ open.menu.setOpen(false, "trigger-hover", event.nativeEvent);
129
+ openMenu(trigger, "trigger-hover", event.nativeEvent, null);
130
+ hoverOpened.current = {
131
+ trigger,
132
+ time: event.timeStamp
133
+ };
134
+ latest.current.scope.focused(trigger);
135
+ }, [
136
+ entries,
137
+ openOne,
138
+ openMenu
139
+ ]);
140
+ const onKeyDown = (event) => {
141
+ const trigger = event.target;
142
+ const entry = entries.get(trigger)?.current;
143
+ if (entry === void 0 || event.defaultPrevented) return;
144
+ const open = openOne();
145
+ if (event.key === "Tab") {
146
+ open?.menu.setOpen(false, "focus-out", event.nativeEvent);
147
+ return;
148
+ }
149
+ rovingKeyDown(event);
150
+ if (event.defaultPrevented) {
151
+ const target = trigger.ownerDocument.activeElement;
152
+ if (open !== null && target instanceof HTMLElement && target !== trigger && entries.has(target)) {
153
+ open.menu.setOpen(false, "list-navigation", event.nativeEvent);
154
+ openMenu(target, "list-navigation", event.nativeEvent, "keep");
155
+ }
156
+ return;
157
+ }
158
+ if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
159
+ const rtl = getDirection(event.currentTarget, direction) === "rtl";
160
+ const highlight = openKeyTarget(event.key, orientation, rtl);
161
+ if (highlight === null) return;
162
+ event.preventDefault();
163
+ if (entry.disabled) return;
164
+ const { menu } = entry;
165
+ if (menu.open) {
166
+ const items = menu.popup ? menuItems(menu.popup) : [];
167
+ (highlight === "first" ? items[0] : items.at(-1))?.focus({ preventScroll: true });
168
+ return;
169
+ }
170
+ openMenu(trigger, event.key === "Enter" || event.key === " " ? "trigger-press" : "list-navigation", event.nativeEvent, highlight);
171
+ };
172
+ const context = useMemo(() => ({
173
+ scope,
174
+ orientation,
175
+ disabled,
176
+ modal,
177
+ register,
178
+ press,
179
+ hover,
180
+ menuKeyDown
181
+ }), [
182
+ scope,
183
+ orientation,
184
+ disabled,
185
+ modal,
186
+ register,
187
+ press,
188
+ hover,
189
+ menuKeyDown
190
+ ]);
191
+ const state = {
192
+ orientation,
193
+ disabled,
194
+ modal
195
+ };
196
+ return /* @__PURE__ */ jsx(MenuBarContext.Provider, {
197
+ value: context,
198
+ children: renderElement("div", props, state, {
199
+ role: "menubar",
200
+ "aria-orientation": orientation,
201
+ style: modal ? { pointerEvents: "auto" } : void 0,
202
+ "data-primitives-part": "menubar-root",
203
+ ...stateAttributes({
204
+ orientation,
205
+ disabled
206
+ }),
207
+ onKeyDown
208
+ }, ref)
209
+ });
210
+ }
211
+ export { Menubar as t };
212
+
213
+ //# sourceMappingURL=menubar-wjJF54GJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menubar-wjJF54GJ.js","names":[],"sources":["../src/components/menubar/menubar.tsx"],"sourcesContent":["import {\n inDocumentOrder,\n type RovingOrientation,\n rovingKeys,\n rovingKeyTarget,\n submenuKeys,\n} from \"@fragiola/primitives/collection\";\nimport { getDirection } from \"@fragiola/primitives/direction\";\nimport {\n type KeyboardEvent,\n type MouseEvent,\n type PointerEvent,\n useCallback,\n useContext,\n useMemo,\n useRef,\n} from \"react\";\nimport { DirectionContext } from \"../../direction/direction-context.ts\";\nimport { useElement } from \"../../hooks/use-element.ts\";\nimport { useRovingComposite } from \"../../hooks/use-roving-composite.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { stateAttributes } from \"../../utils/state-attributes.ts\";\nimport {\n MenuBarContext,\n type MenuBarContextValue,\n type MenuBarEntry,\n} from \"../menu/menu-bar-context.ts\";\nimport type {\n MenuContextValue,\n PendingHighlight,\n} from \"../menu/menu-context.ts\";\nimport { menuItems } from \"../menu/menu-items.ts\";\n\nexport interface MenubarState {\n orientation: RovingOrientation;\n disabled: boolean;\n modal: boolean;\n}\n\nexport interface MenubarProps extends PartProps<MenubarState> {\n /** The arrow keys' axis, and where the menus open (default `\"horizontal\"`). */\n orientation?: RovingOrientation;\n /** The arrows wrap from the last item to the first and back (default `true`). */\n loopFocus?: boolean;\n /**\n * The menus lock the page's scroll and block the pointer outside while open (default `false`:\n * the APG menubar is non-modal; spec/menubar.md, \"Modal\").\n */\n modal?: boolean;\n /** Every item is disabled: focusable, opening nothing. */\n disabled?: boolean;\n}\n\n/** A press within this time after a hover opened a menu keeps it open (Base UI's patient click). */\nconst PATIENT_PRESS_MS = 500;\n\n/** The open keys of an item: the item of its menu they focus (spec/menubar.md, \"Keyboard\"). */\nfunction openKeyTarget(\n key: string,\n orientation: RovingOrientation,\n rtl: boolean,\n): \"first\" | \"last\" | null {\n if (key === \"Enter\" || key === \" \") {\n return \"first\";\n }\n if (orientation === \"vertical\") {\n return key === submenuKeys(rtl).open ? \"first\" : null;\n }\n return key === \"ArrowDown\" ? \"first\" : key === \"ArrowUp\" ? \"last\" : null;\n}\n\nfunction rootLevel(level: MenuContextValue): MenuContextValue {\n return level.parent ? rootLevel(level.parent) : level;\n}\n\n/**\n * A bar of menus with one tab stop (spec/menubar.md, the APG menubar): the `Menu.Trigger`s of the\n * `Menu.Root`s inside it are its items; it moves the focus between them and, while a menu is\n * open, from that menu to the next, by the keys and by hovering.\n */\nexport function Menubar({\n orientation = \"horizontal\",\n loopFocus = true,\n modal = false,\n disabled = false,\n ...props\n}: MenubarProps) {\n const direction = useContext(DirectionContext);\n const [element, ref] = useElement<HTMLElement>();\n const { scope, onKeyDown: rovingKeyDown } = useRovingComposite({\n orientation,\n loopFocus,\n disabled,\n root: element,\n });\n const entries = useRef(\n new Map<HTMLElement, { readonly current: MenuBarEntry }>(),\n ).current;\n const hoverOpened = useRef<{ trigger: HTMLElement; time: number } | null>(\n null,\n );\n const latest = useRef({ orientation, loopFocus, direction, scope });\n latest.current = { orientation, loopFocus, direction, scope };\n\n const register = useCallback(\n (trigger: HTMLElement, entry: { readonly current: MenuBarEntry }) => {\n entries.set(trigger, entry);\n return () => {\n if (entries.get(trigger) === entry) {\n entries.delete(trigger);\n }\n };\n },\n [entries],\n );\n /** The open menu of the bar and its Trigger, if any. */\n const openOne = useCallback(() => {\n for (const [trigger, entry] of entries) {\n if (entry.current.menu.open) {\n return { trigger, menu: entry.current.menu };\n }\n }\n return null;\n }, [entries]);\n /** Opens a Trigger's menu, unless it is disabled. */\n const openMenu = useCallback(\n (\n trigger: HTMLElement,\n reason: \"list-navigation\" | \"trigger-press\" | \"trigger-hover\",\n event: Event,\n highlight: PendingHighlight,\n ) => {\n const entry = entries.get(trigger)?.current;\n if (entry === undefined || entry.disabled) {\n return;\n }\n entry.menu.pendingHighlight.current = highlight;\n if (!entry.menu.setOpen(true, reason, event, trigger)) {\n entry.menu.pendingHighlight.current = null;\n }\n },\n [entries],\n );\n /**\n * Moves from the open menu to another item (the keys): the focus first, then the open menu\n * closes and the item's menu opens with the focus kept on it (APG).\n */\n const moveTo = useCallback(\n (target: HTMLElement, from: MenuContextValue | null, event: Event) => {\n target.focus();\n from?.setOpen(false, \"list-navigation\", event);\n openMenu(target, \"list-navigation\", event, \"keep\");\n },\n [openMenu],\n );\n\n const menuKeyDown = useCallback(\n (event: KeyboardEvent, level: MenuContextValue) => {\n if (\n event.altKey ||\n event.ctrlKey ||\n event.metaKey ||\n event.shiftKey\n ) {\n return false;\n }\n const root = rootLevel(level);\n const trigger = root.trigger;\n if (trigger === null || !entries.has(trigger)) {\n return false;\n }\n const current = latest.current;\n const rtl =\n getDirection(level.popup ?? trigger, current.direction) ===\n \"rtl\";\n const nested = level.parent !== null;\n if (current.orientation === \"vertical\") {\n // the menu sits at the item's end side, as a submenu: its close key goes back\n if (!nested && event.key === submenuKeys(rtl).close) {\n trigger.focus();\n root.setOpen(false, \"list-navigation\", event.nativeEvent);\n return true;\n }\n return false;\n }\n const { next, previous } = rovingKeys(\"horizontal\", rtl);\n if (event.key !== next && !(event.key === previous && !nested)) {\n return false;\n }\n const triggers = inDocumentOrder([...entries.keys()], (t) => t);\n const index = rovingKeyTarget(\n event.key,\n triggers.indexOf(trigger),\n triggers.length,\n {\n orientation: \"horizontal\",\n rtl,\n loop: current.loopFocus,\n },\n );\n const target = index === null ? undefined : triggers[index];\n if (target !== undefined && target !== trigger) {\n moveTo(target, root, event.nativeEvent);\n }\n return true;\n },\n [entries, moveTo],\n );\n\n const press = useCallback(\n (trigger: HTMLElement, event: MouseEvent<HTMLElement>) => {\n const entry = entries.get(trigger)?.current;\n if (entry === undefined || entry.disabled) {\n return;\n }\n const { menu } = entry;\n if (!menu.open) {\n openMenu(trigger, \"trigger-press\", event.nativeEvent, null);\n return;\n }\n const hovered = hoverOpened.current;\n hoverOpened.current = null;\n if (\n hovered?.trigger === trigger &&\n event.timeStamp - hovered.time < PATIENT_PRESS_MS\n ) {\n return;\n }\n menu.pendingHighlight.current = null;\n menu.setOpen(false, \"trigger-press\", event.nativeEvent, trigger);\n },\n [entries, openMenu],\n );\n\n const hover = useCallback(\n (trigger: HTMLElement, event: PointerEvent<HTMLElement>) => {\n const entry = entries.get(trigger)?.current;\n // a tap's pointer entering an item is no hover (spec/menubar.md, \"Pointer\")\n if (\n event.pointerType === \"touch\" ||\n entry === undefined ||\n entry.disabled ||\n entry.menu.open\n ) {\n return;\n }\n const open = openOne();\n if (open === null) {\n return;\n }\n open.menu.setOpen(false, \"trigger-hover\", event.nativeEvent);\n openMenu(trigger, \"trigger-hover\", event.nativeEvent, null);\n hoverOpened.current = { trigger, time: event.timeStamp };\n latest.current.scope.focused(trigger);\n },\n [entries, openOne, openMenu],\n );\n\n // the keys of the bar's items (the Triggers hand theirs to it)\n const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n const trigger = event.target as HTMLElement;\n const entry = entries.get(trigger)?.current;\n if (entry === undefined || event.defaultPrevented) {\n return;\n }\n const open = openOne();\n if (event.key === \"Tab\") {\n open?.menu.setOpen(false, \"focus-out\", event.nativeEvent);\n return;\n }\n rovingKeyDown(event);\n if (event.defaultPrevented) {\n const target = trigger.ownerDocument.activeElement;\n if (\n open !== null &&\n target instanceof HTMLElement &&\n target !== trigger &&\n entries.has(target)\n ) {\n open.menu.setOpen(false, \"list-navigation\", event.nativeEvent);\n openMenu(target, \"list-navigation\", event.nativeEvent, \"keep\");\n }\n return;\n }\n if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {\n return;\n }\n const rtl = getDirection(event.currentTarget, direction) === \"rtl\";\n const highlight = openKeyTarget(event.key, orientation, rtl);\n if (highlight === null) {\n return;\n }\n event.preventDefault();\n if (entry.disabled) {\n return;\n }\n const { menu } = entry;\n if (menu.open) {\n // the focus is on the item of an open menu: the open keys go into it\n const items = menu.popup ? menuItems(menu.popup) : [];\n (highlight === \"first\" ? items[0] : items.at(-1))?.focus({\n preventScroll: true,\n });\n return;\n }\n openMenu(\n trigger,\n event.key === \"Enter\" || event.key === \" \"\n ? \"trigger-press\"\n : \"list-navigation\",\n event.nativeEvent,\n highlight,\n );\n };\n\n const context: MenuBarContextValue = useMemo(\n () => ({\n scope,\n orientation,\n disabled,\n modal,\n register,\n press,\n hover,\n menuKeyDown,\n }),\n [\n scope,\n orientation,\n disabled,\n modal,\n register,\n press,\n hover,\n menuKeyDown,\n ],\n );\n const state = { orientation, disabled, modal };\n return (\n <MenuBarContext.Provider value={context}>\n {renderElement(\n \"div\",\n props,\n state,\n {\n role: \"menubar\",\n \"aria-orientation\": orientation,\n // a modal menu blocks the pointer outside; the bar takes it back (spec/menubar.md)\n style: modal ? { pointerEvents: \"auto\" } : undefined,\n \"data-primitives-part\": \"menubar-root\",\n ...stateAttributes({ orientation, disabled }),\n onKeyDown,\n },\n ref,\n )}\n </MenuBarContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAsDA,MAAM,mBAAmB;;AAGzB,SAAS,cACL,KACA,aACA,KACuB;CACvB,IAAI,QAAQ,WAAW,QAAQ,KAC3B,OAAO;CAEX,IAAI,gBAAgB,YAChB,OAAO,QAAQ,YAAY,GAAG,CAAC,CAAC,OAAO,UAAU;CAErD,OAAO,QAAQ,cAAc,UAAU,QAAQ,YAAY,SAAS;AACxE;AAEA,SAAS,UAAU,OAA2C;CAC1D,OAAO,MAAM,SAAS,UAAU,MAAM,MAAM,IAAI;AACpD;;;;;;AAOA,SAAgB,QAAQ,EACpB,cAA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EACA,IAAI,MAAM,UAAU,MAAM,WAAW,MAAM,WAAW,MAAM,UACxD;EAEJ,MAAM,MAAM,aAAa,MAAM,eAAe,SAAS,MAAM;EAC7D,MAAM,YAAY,cAAc,MAAM,KAAK,aAAa,GAAG;EAC3D,IAAI,cAAc,MACd;EAEJ,MAAM,eAAe;EACrB,IAAI,MAAM,UACN;EAEJ,MAAM,EAAE,SAAS;EACjB,IAAI,KAAK,MAAM;GAEX,MAAM,QAAQ,KAAK,QAAQ,UAAU,KAAK,KAAK,IAAI,CAAC;GACpD,CAAC,cAAc,UAAU,MAAM,KAAK,MAAM,GAAG,EAAE,EAAA,EAAI,MAAM,EACrD,eAAe,KACnB,CAAC;GACD;EACJ;EACA,SACI,SACA,MAAM,QAAQ,WAAW,MAAM,QAAQ,MACjC,kBACA,mBACN,MAAM,aACN,SACJ;CACJ;CAEA,MAAM,UAA+B,eAC1B;EACH;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,IACA;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,CACJ;CACA,MAAM,QAAQ;EAAE;EAAa;EAAU;CAAM;CAC7C,OACI,oBAAC,eAAe,UAAhB;EAAyB,OAAO;EAC3B,UAAA,cACG,OACA,OACA,OACA;GACI,MAAM;GACN,oBAAoB;GAEpB,OAAO,QAAQ,EAAE,eAAe,OAAO,IAAI,KAAA;GAC3C,wBAAwB;GACxB,GAAG,gBAAgB;IAAE;IAAa;GAAS,CAAC;GAC5C;EACJ,GACA,GACJ;CACqB,CAAA;AAEjC"}
@@ -0,0 +1,3 @@
1
+ import { n as RenderProp } from "./render-element-Pwuv2wsL.js";
2
+ import { i as MenubarState, n as Menubar, r as MenubarProps, t as RovingOrientation } from "./index-DnQAamhU.js";
3
+ export { Menubar, type MenubarProps, type MenubarState, type RenderProp, type RovingOrientation };
@@ -0,0 +1 @@
1
+ export { t as Menubar } from "./menubar-wjJF54GJ.js";
@@ -0,0 +1,120 @@
1
+ import { t as useRequiredContext } from "./use-required-context-Cjd_CYnv.js";
2
+ import { t as renderElement } from "./render-element-DXbUbfgN.js";
3
+ import { createContext, useId, useLayoutEffect, useMemo, useState } from "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { progressValue } from "@fragiola/primitives/range";
6
+ // src/components/meter/meter-context.ts
7
+ const MeterContext = createContext(null);
8
+ /** The state the parts render with. */
9
+ function meterState(context) {
10
+ return {
11
+ value: context.value,
12
+ min: context.min,
13
+ max: context.max
14
+ };
15
+ }
16
+ // src/components/meter/meter-indicator.tsx
17
+ /**
18
+ * The filled part, from the inline start (spec/meter.md): its structural style sets its inline
19
+ * size, and `--meter-indicator-size`.
20
+ */
21
+ function MeterIndicator(props) {
22
+ const context = useRequiredContext(MeterContext, "Meter.Indicator");
23
+ const style = {
24
+ insetInlineStart: 0,
25
+ inlineSize: `${context.percent}%`,
26
+ "--meter-indicator-size": `${context.percent}%`
27
+ };
28
+ return renderElement("div", props, meterState(context), {
29
+ style,
30
+ "data-primitives-part": "meter-indicator"
31
+ });
32
+ }
33
+ // src/components/meter/meter-label.tsx
34
+ /** Names the meter (`aria-labelledby`, spec/meter.md). */
35
+ function MeterLabel({ id: idProp, ...props }) {
36
+ const context = useRequiredContext(MeterContext, "Meter.Label");
37
+ const generated = useId();
38
+ const id = idProp ?? generated;
39
+ const { setLabelId } = context;
40
+ useLayoutEffect(() => {
41
+ setLabelId(id);
42
+ return () => setLabelId(void 0);
43
+ }, [id, setLabelId]);
44
+ return renderElement("span", props, meterState(context), {
45
+ id,
46
+ "data-primitives-part": "meter-label"
47
+ });
48
+ }
49
+ // src/components/meter/meter-root.tsx
50
+ /** The `meter`: holds the value and its formatted text (spec/meter.md). */
51
+ function MeterRoot({ value: valueProp, min = 0, max = 100, format, locale, getAriaValueText, ...props }) {
52
+ const [labelId, setLabelId] = useState();
53
+ const computed = progressValue(valueProp, {
54
+ min,
55
+ max,
56
+ format,
57
+ locale
58
+ });
59
+ const value = computed.value ?? min;
60
+ const percent = computed.percent ?? 0;
61
+ const { formattedValue } = computed;
62
+ const context = useMemo(() => ({
63
+ value,
64
+ min,
65
+ max,
66
+ percent,
67
+ formattedValue,
68
+ setLabelId
69
+ }), [
70
+ value,
71
+ min,
72
+ max,
73
+ percent,
74
+ formattedValue
75
+ ]);
76
+ return /* @__PURE__ */ jsx(MeterContext.Provider, {
77
+ value: context,
78
+ children: renderElement("div", props, {
79
+ value,
80
+ min,
81
+ max
82
+ }, {
83
+ role: "meter",
84
+ "aria-valuemin": min,
85
+ "aria-valuemax": max,
86
+ "aria-valuenow": value,
87
+ "aria-valuetext": getAriaValueText !== void 0 ? getAriaValueText(formattedValue, value) : formattedValue,
88
+ "aria-labelledby": labelId,
89
+ "data-primitives-part": "meter-root"
90
+ })
91
+ });
92
+ }
93
+ // src/components/meter/meter-track.tsx
94
+ /** The rail the Indicator fills (spec/meter.md). */
95
+ function MeterTrack(props) {
96
+ const context = useRequiredContext(MeterContext, "Meter.Track");
97
+ return renderElement("div", props, meterState(context), { "data-primitives-part": "meter-track" });
98
+ }
99
+ // src/components/meter/meter-value.tsx
100
+ /** Shows the formatted value (spec/meter.md). */
101
+ function MeterValue({ children, ...props }) {
102
+ const context = useRequiredContext(MeterContext, "Meter.Value");
103
+ const content = typeof children === "function" ? children(context.formattedValue, context.value) : children ?? context.formattedValue;
104
+ return renderElement("span", {
105
+ ...props,
106
+ children: content
107
+ }, meterState(context), { "data-primitives-part": "meter-value" });
108
+ }
109
+ // src/components/meter/parts.ts
110
+ /** spec/meter.md */
111
+ const Meter = {
112
+ Root: MeterRoot,
113
+ Label: MeterLabel,
114
+ Value: MeterValue,
115
+ Track: MeterTrack,
116
+ Indicator: MeterIndicator
117
+ };
118
+ export { Meter as t };
119
+
120
+ //# sourceMappingURL=meter-11PgO99t.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meter-11PgO99t.js","names":[],"sources":["../src/components/meter/meter-context.ts","../src/components/meter/meter-indicator.tsx","../src/components/meter/meter-label.tsx","../src/components/meter/meter-root.tsx","../src/components/meter/meter-track.tsx","../src/components/meter/meter-value.tsx","../src/components/meter/parts.ts"],"sourcesContent":["import { createContext } from \"react\";\n\nexport interface MeterState {\n /** The value, clamped to `[min, max]`. */\n value: number;\n min: number;\n max: number;\n}\n\nexport interface MeterContextValue extends MeterState {\n /** From 0 to 100. */\n percent: number;\n /** The value as `format` writes it. */\n formattedValue: string;\n setLabelId: (id: string | undefined) => void;\n}\n\nexport const MeterContext = createContext<MeterContextValue | null>(null);\n\n/** The state the parts render with. */\nexport function meterState(context: MeterContextValue): MeterState {\n return { value: context.value, min: context.min, max: context.max };\n}\n","import type { CSSProperties } from \"react\";\nimport { useRequiredContext } from \"../../hooks/use-required-context.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { MeterContext, type MeterState, meterState } from \"./meter-context.ts\";\n\nexport type MeterIndicatorProps = PartProps<MeterState>;\n\n/**\n * The filled part, from the inline start (spec/meter.md): its structural style sets its inline\n * size, and `--meter-indicator-size`.\n */\nexport function MeterIndicator(props: MeterIndicatorProps) {\n const context = useRequiredContext(MeterContext, \"Meter.Indicator\");\n const style = {\n insetInlineStart: 0,\n inlineSize: `${context.percent}%`,\n \"--meter-indicator-size\": `${context.percent}%`,\n } as CSSProperties;\n return renderElement(\"div\", props, meterState(context), {\n style,\n \"data-primitives-part\": \"meter-indicator\",\n });\n}\n","import { useId, useLayoutEffect } from \"react\";\nimport { useRequiredContext } from \"../../hooks/use-required-context.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { MeterContext, type MeterState, meterState } from \"./meter-context.ts\";\n\nexport interface MeterLabelProps extends PartProps<MeterState> {\n id?: string;\n}\n\n/** Names the meter (`aria-labelledby`, spec/meter.md). */\nexport function MeterLabel({ id: idProp, ...props }: MeterLabelProps) {\n const context = useRequiredContext(MeterContext, \"Meter.Label\");\n const generated = useId();\n const id = idProp ?? generated;\n const { setLabelId } = context;\n useLayoutEffect(() => {\n setLabelId(id);\n return () => setLabelId(undefined);\n }, [id, setLabelId]);\n return renderElement(\"span\", props, meterState(context), {\n id,\n \"data-primitives-part\": \"meter-label\",\n });\n}\n","import { progressValue } from \"@fragiola/primitives/range\";\nimport { useMemo, useState } from \"react\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { MeterContext, type MeterState } from \"./meter-context.ts\";\n\nexport interface MeterRootProps extends PartProps<MeterState> {\n /** The measurement; clamped to `[min, max]`. */\n value: number;\n min?: number;\n max?: number;\n /** How the value is written; default: a percentage of the range. */\n format?: Intl.NumberFormatOptions;\n /** The locale of `format` (BCP 47; default: the runtime's). */\n locale?: string;\n /** The Root's `aria-valuetext` instead of the formatted value. */\n getAriaValueText?: (formattedValue: string, value: number) => string;\n}\n\n/** The `meter`: holds the value and its formatted text (spec/meter.md). */\nexport function MeterRoot({\n value: valueProp,\n min = 0,\n max = 100,\n format,\n locale,\n getAriaValueText,\n ...props\n}: MeterRootProps) {\n const [labelId, setLabelId] = useState<string>();\n // a meter's value is never indeterminate: the progress math with a number always\n const computed = progressValue(valueProp, { min, max, format, locale });\n const value = computed.value ?? min;\n const percent = computed.percent ?? 0;\n const { formattedValue } = computed;\n const context = useMemo(\n () => ({ value, min, max, percent, formattedValue, setLabelId }),\n [value, min, max, percent, formattedValue],\n );\n return (\n <MeterContext.Provider value={context}>\n {renderElement(\n \"div\",\n props,\n { value, min, max },\n {\n role: \"meter\",\n \"aria-valuemin\": min,\n \"aria-valuemax\": max,\n \"aria-valuenow\": value,\n \"aria-valuetext\":\n getAriaValueText !== undefined\n ? getAriaValueText(formattedValue, value)\n : formattedValue,\n \"aria-labelledby\": labelId,\n \"data-primitives-part\": \"meter-root\",\n },\n )}\n </MeterContext.Provider>\n );\n}\n","import { useRequiredContext } from \"../../hooks/use-required-context.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { MeterContext, type MeterState, meterState } from \"./meter-context.ts\";\n\nexport type MeterTrackProps = PartProps<MeterState>;\n\n/** The rail the Indicator fills (spec/meter.md). */\nexport function MeterTrack(props: MeterTrackProps) {\n const context = useRequiredContext(MeterContext, \"Meter.Track\");\n return renderElement(\"div\", props, meterState(context), {\n \"data-primitives-part\": \"meter-track\",\n });\n}\n","import type { ReactNode } from \"react\";\nimport { useRequiredContext } from \"../../hooks/use-required-context.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { MeterContext, type MeterState, meterState } from \"./meter-context.ts\";\n\nexport interface MeterValueProps\n extends Omit<PartProps<MeterState>, \"children\"> {\n /** Its content: a node, or a function of the formatted value and the value. */\n children?:\n | ReactNode\n | ((formattedValue: string, value: number) => ReactNode);\n}\n\n/** Shows the formatted value (spec/meter.md). */\nexport function MeterValue({ children, ...props }: MeterValueProps) {\n const context = useRequiredContext(MeterContext, \"Meter.Value\");\n const content =\n typeof children === \"function\"\n ? children(context.formattedValue, context.value)\n : (children ?? context.formattedValue);\n return renderElement(\n \"span\",\n { ...props, children: content },\n meterState(context),\n { \"data-primitives-part\": \"meter-value\" },\n );\n}\n","import { MeterIndicator } from \"./meter-indicator.tsx\";\nimport { MeterLabel } from \"./meter-label.tsx\";\nimport { MeterRoot } from \"./meter-root.tsx\";\nimport { MeterTrack } from \"./meter-track.tsx\";\nimport { MeterValue } from \"./meter-value.tsx\";\n\n/** spec/meter.md */\nexport const Meter = {\n Root: MeterRoot,\n Label: MeterLabel,\n Value: MeterValue,\n Track: MeterTrack,\n Indicator: MeterIndicator,\n};\n"],"mappings":";;;;;;AAiBA,MAAa,eAAe,cAAwC,IAAI;;AAGxE,SAAgB,WAAW,SAAwC;CAC/D,OAAO;EAAE,OAAO,QAAQ;EAAO,KAAK,QAAQ;EAAK,KAAK,QAAQ;CAAI;AACtE;;;;;;ACXA,SAAgB,eAAe,OAA4B;CACvD,MAAM,UAAU,mBAAmB,cAAc,iBAAiB;CAClE,MAAM,QAAQ;EACV,kBAAkB;EAClB,YAAY,GAAG,QAAQ,QAAQ;EAC/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AO,OAAO,WAAW,OAAO,GAAG,EACpD,wBAAwB,cAC5B,CAAC;AACL;;;ACEA,SAAgB,WAAW,EAAE,UAAU,GAAG,SAA0B;CAChE,MAAM,UAAU,mBAAmB,cAAc,aAAa;CAC9D,MAAM,UACF,OAAO,aAAa,aACd,SAAS,QAAQ,gBAAgB,QAAQ,KAAK,IAC7C,YAAY,QAAQ;CAC/B,OAAO,cACH,QACA;EAAE,GAAG;EAAO,UAAU;CAAQ,GAC9B,WAAW,OAAO,GAClB,EAAE,wBAAwB,cAAc,CAC5C;AACJ;;;ACnBA,MAAa,QAAQ;CACjB,MAAM;CACN,OAAO;CACP,OAAO;CACP,OAAO;CACP,WAAW;AACf"}
@@ -0,0 +1,3 @@
1
+ import { n as RenderProp } from "./render-element-Pwuv2wsL.js";
2
+ import { a as MeterLabelProps, i as MeterRootProps, n as MeterValueProps, o as MeterIndicatorProps, r as MeterTrackProps, s as MeterState, t as Meter } from "./index-BrXfSGo2.js";
3
+ export { Meter, type MeterIndicatorProps, type MeterLabelProps, type MeterRootProps, type MeterState, type MeterTrackProps, type MeterValueProps, type RenderProp };
package/dist/meter.js ADDED
@@ -0,0 +1 @@
1
+ export { t as Meter } from "./meter-11PgO99t.js";
@@ -0,0 +1,5 @@
1
+ import { PlainYear, PlainYearMonth } from "@fragiola/primitives/month-year";
2
+ import "@fragiola/primitives/calendar-systems";
3
+ /** One month or year. */
4
+ type MonthCalendarItem = PlainYearMonth | PlainYear;
5
+ export { MonthCalendarItem as t };
@@ -0,0 +1,35 @@
1
+ import { createContext } from "react";
2
+ import { UNIT_PAGE_SIZE, currentYearMonth, formatMonthName, formatYear, formatYearMonth, formatYearSpan, fromMonthIndex, monthIndex, unitKeyTarget, unitPageStart, unitRows } from "@fragiola/primitives/month-year";
3
+ // src/components/month-calendar/month-calendar-binding-context.ts
4
+ const MonthCalendarBindingContext = createContext(null);
5
+ // src/components/month-calendar/month-calendar-value.ts
6
+ /**
7
+ * The units of a kind: the calendar system's (its hook), else the ISO calendar's months or years
8
+ * (`/month-year`, pages of 12).
9
+ */
10
+ function unitsOf(kind, calendar) {
11
+ if (calendar) return calendar.units(kind);
12
+ const month = kind === "month";
13
+ return {
14
+ index: (item) => month ? monthIndex(item) : item.year,
15
+ item: (index) => month ? fromMonthIndex(index) : { year: index },
16
+ pageStart: unitPageStart,
17
+ pageSize: () => UNIT_PAGE_SIZE,
18
+ page: (start, delta) => start + delta * UNIT_PAGE_SIZE,
19
+ rows: unitRows,
20
+ keyTarget: unitKeyTarget,
21
+ text: (locale, index) => month ? formatMonthName(locale, fromMonthIndex(index), "long") : formatYear(locale, index),
22
+ name: (locale, index) => month ? formatYearMonth(locale, fromMonthIndex(index)) : formatYear(locale, index),
23
+ heading: (locale, start) => month ? formatYear(locale, start / UNIT_PAGE_SIZE) : formatYearSpan(locale, start, start + UNIT_PAGE_SIZE - 1),
24
+ today: () => {
25
+ const now = currentYearMonth();
26
+ return month ? monthIndex(now) : now.year;
27
+ }
28
+ };
29
+ }
30
+ function isItemRange(value) {
31
+ return value !== null && "start" in value;
32
+ }
33
+ export { unitsOf as n, MonthCalendarBindingContext as r, isItemRange as t };
34
+
35
+ //# sourceMappingURL=month-calendar-value-D_au-Kbz.js.map