@fragiola/primitives-react 0.0.0-stage → 0.1.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.
- package/CHANGELOG.md +67 -0
- package/LICENSE +21 -0
- package/README.md +38 -2
- package/dist/accordion--E-5hjWo.js +210 -0
- package/dist/accordion--E-5hjWo.js.map +1 -0
- package/dist/accordion.d.ts +4 -0
- package/dist/accordion.js +1 -0
- package/dist/alert-dialog-7FIAj98B.js +37 -0
- package/dist/alert-dialog-7FIAj98B.js.map +1 -0
- package/dist/alert-dialog.d.ts +9 -0
- package/dist/alert-dialog.js +1 -0
- package/dist/aspect-ratio-CUADsevg.js +19 -0
- package/dist/aspect-ratio-CUADsevg.js.map +1 -0
- package/dist/aspect-ratio.d.ts +3 -0
- package/dist/aspect-ratio.js +1 -0
- package/dist/async-list-7ljWFMgA.js +35 -0
- package/dist/async-list-7ljWFMgA.js.map +1 -0
- package/dist/async-list.d.ts +2 -0
- package/dist/async-list.js +1 -0
- package/dist/autocomplete-virtual-BE8dDDgU.js +56 -0
- package/dist/autocomplete-virtual-BE8dDDgU.js.map +1 -0
- package/dist/autocomplete-virtual.d.ts +4 -0
- package/dist/autocomplete-virtual.js +3 -0
- package/dist/autocomplete.d.ts +9 -0
- package/dist/autocomplete.js +1 -0
- package/dist/avatar-CABjoLs9.js +101 -0
- package/dist/avatar-CABjoLs9.js.map +1 -0
- package/dist/avatar.d.ts +3 -0
- package/dist/avatar.js +1 -0
- package/dist/breadcrumbs-nG0Rq3kX.js +69 -0
- package/dist/breadcrumbs-nG0Rq3kX.js.map +1 -0
- package/dist/breadcrumbs.d.ts +3 -0
- package/dist/breadcrumbs.js +1 -0
- package/dist/button-B6h8UkhR.js +30 -0
- package/dist/button-B6h8UkhR.js.map +1 -0
- package/dist/button-props-DWfy1ZSo.js +69 -0
- package/dist/button-props-DWfy1ZSo.js.map +1 -0
- package/dist/button.d.ts +3 -0
- package/dist/button.js +1 -0
- package/dist/calendar-preset-Cs-hy-_0.js +70 -0
- package/dist/calendar-preset-Cs-hy-_0.js.map +1 -0
- package/dist/calendar-preset.d.ts +4 -0
- package/dist/calendar-preset.js +3 -0
- package/dist/calendar-root-base-CIkiSebb.js +515 -0
- package/dist/calendar-root-base-CIkiSebb.js.map +1 -0
- package/dist/calendar-row-BO5kyOgq.d.ts +84 -0
- package/dist/calendar-value-DCOjO7og.d.ts +23 -0
- package/dist/calendar-view-DT9i5Xg_.js +157 -0
- package/dist/calendar-view-DT9i5Xg_.js.map +1 -0
- package/dist/calendar-view.d.ts +6 -0
- package/dist/calendar-view.js +4 -0
- package/dist/calendar.d.ts +7 -0
- package/dist/calendar.js +1 -0
- package/dist/carousel-ClQsQ135.js +436 -0
- package/dist/carousel-ClQsQ135.js.map +1 -0
- package/dist/carousel.d.ts +4 -0
- package/dist/carousel.js +1 -0
- package/dist/cascade-select-DZlpKUok.js +582 -0
- package/dist/cascade-select-DZlpKUok.js.map +1 -0
- package/dist/cascade-select.d.ts +7 -0
- package/dist/cascade-select.js +1 -0
- package/dist/change-details-CPSkPCNw.d.ts +32 -0
- package/dist/checkbox-CbmkKNfv.js +165 -0
- package/dist/checkbox-CbmkKNfv.js.map +1 -0
- package/dist/checkbox-group-_UrFCUgQ.js +99 -0
- package/dist/checkbox-group-_UrFCUgQ.js.map +1 -0
- package/dist/checkbox-group-context-CoGqgxBM.js +6 -0
- package/dist/checkbox-group-context-CoGqgxBM.js.map +1 -0
- package/dist/checkbox-group.d.ts +4 -0
- package/dist/checkbox-group.js +1 -0
- package/dist/checkbox.d.ts +4 -0
- package/dist/checkbox.js +1 -0
- package/dist/clipboard-CvgO1qhh.js +189 -0
- package/dist/clipboard-CvgO1qhh.js.map +1 -0
- package/dist/clipboard.d.ts +4 -0
- package/dist/clipboard.js +1 -0
- package/dist/collapsible-Dh0TUP6l.js +112 -0
- package/dist/collapsible-Dh0TUP6l.js.map +1 -0
- package/dist/collapsible.d.ts +4 -0
- package/dist/collapsible.js +1 -0
- package/dist/color-area-BGo6tZxX.js +311 -0
- package/dist/color-area-BGo6tZxX.js.map +1 -0
- package/dist/color-area.d.ts +4 -0
- package/dist/color-area.js +1 -0
- package/dist/color-field-B9QEKyQ1.js +334 -0
- package/dist/color-field-B9QEKyQ1.js.map +1 -0
- package/dist/color-field.d.ts +4 -0
- package/dist/color-field.js +1 -0
- package/dist/color-picker-BNOtqWUK.js +276 -0
- package/dist/color-picker-BNOtqWUK.js.map +1 -0
- package/dist/color-picker-binding-D9xBS_my.js +6 -0
- package/dist/color-picker-binding-D9xBS_my.js.map +1 -0
- package/dist/color-picker-popover-CV_wP6KG.js +195 -0
- package/dist/color-picker-popover-CV_wP6KG.js.map +1 -0
- package/dist/color-picker-popover.d.ts +7 -0
- package/dist/color-picker-popover.js +1 -0
- package/dist/color-picker.d.ts +4 -0
- package/dist/color-picker.js +1 -0
- package/dist/color-slider-Bw940FJr.js +357 -0
- package/dist/color-slider-Bw940FJr.js.map +1 -0
- package/dist/color-slider.d.ts +4 -0
- package/dist/color-slider.js +1 -0
- package/dist/color-swatch-C9ws0xF4.js +37 -0
- package/dist/color-swatch-C9ws0xF4.js.map +1 -0
- package/dist/color-swatch-picker-CnmTr1SY.js +286 -0
- package/dist/color-swatch-picker-CnmTr1SY.js.map +1 -0
- package/dist/color-swatch-picker.d.ts +4 -0
- package/dist/color-swatch-picker.js +1 -0
- package/dist/color-swatch.d.ts +3 -0
- package/dist/color-swatch.js +1 -0
- package/dist/color-wheel--n8w5fIJ.js +247 -0
- package/dist/color-wheel--n8w5fIJ.js.map +1 -0
- package/dist/color-wheel.d.ts +4 -0
- package/dist/color-wheel.js +1 -0
- package/dist/combobox-virtual-BI-l10BE.js +61 -0
- package/dist/combobox-virtual-BI-l10BE.js.map +1 -0
- package/dist/combobox-virtual.d.ts +4 -0
- package/dist/combobox-virtual.js +3 -0
- package/dist/combobox.d.ts +9 -0
- package/dist/combobox.js +1 -0
- package/dist/command-virtual-CxNLxsih.js +56 -0
- package/dist/command-virtual-CxNLxsih.js.map +1 -0
- package/dist/command-virtual.d.ts +4 -0
- package/dist/command-virtual.js +3 -0
- package/dist/command.d.ts +5 -0
- package/dist/command.js +1 -0
- package/dist/context-menu-DGj2L-Sv.js +131 -0
- package/dist/context-menu-DGj2L-Sv.js.map +1 -0
- package/dist/context-menu.d.ts +8 -0
- package/dist/context-menu.js +1 -0
- package/dist/date-field-C1nhThPd.js +33 -0
- package/dist/date-field-C1nhThPd.js.map +1 -0
- package/dist/date-field-root-CzSo5iKL.d.ts +26 -0
- package/dist/date-field-root-base-B-050SUC.js +185 -0
- package/dist/date-field-root-base-B-050SUC.js.map +1 -0
- package/dist/date-field-segment-BoS-ohDh.d.ts +67 -0
- package/dist/date-field.d.ts +6 -0
- package/dist/date-field.js +1 -0
- package/dist/date-picker-input-BCaKff7A.js +29 -0
- package/dist/date-picker-input-BCaKff7A.js.map +1 -0
- package/dist/date-picker-input-root-base-Cc3mE-NR.d.ts +17 -0
- package/dist/date-picker-input-root-base-D4VaBnpf.js +361 -0
- package/dist/date-picker-input-root-base-D4VaBnpf.js.map +1 -0
- package/dist/date-picker-input.d.ts +7 -0
- package/dist/date-picker-input.js +3 -0
- package/dist/date-picker-trigger-BKPvZbRg.js +304 -0
- package/dist/date-picker-trigger-BKPvZbRg.js.map +1 -0
- package/dist/date-picker-trigger-DHsAhBf2.d.ts +51 -0
- package/dist/date-picker.d.ts +11 -0
- package/dist/date-picker.js +1 -0
- package/dist/date-range-field-C-ID01oa.js +34 -0
- package/dist/date-range-field-C-ID01oa.js.map +1 -0
- package/dist/date-range-field-input-BkLpldTx.js +33 -0
- package/dist/date-range-field-input-BkLpldTx.js.map +1 -0
- package/dist/date-range-field-input-BwCNo15l.d.ts +13 -0
- package/dist/date-range-field-root-CmZ3c7xn.d.ts +31 -0
- package/dist/date-range-field-root-base-DWH3nqmz.d.ts +23 -0
- package/dist/date-range-field-root-base-z8S5aSCs.js +261 -0
- package/dist/date-range-field-root-base-z8S5aSCs.js.map +1 -0
- package/dist/date-range-field.d.ts +9 -0
- package/dist/date-range-field.js +1 -0
- package/dist/date-range-picker-input-DlIdTD-J.js +30 -0
- package/dist/date-range-picker-input-DlIdTD-J.js.map +1 -0
- package/dist/date-range-picker-input.d.ts +10 -0
- package/dist/date-range-picker-input.js +3 -0
- package/dist/date-range-picker.d.ts +11 -0
- package/dist/date-range-picker.js +1 -0
- package/dist/dialog-DDE15qBB.js +33 -0
- package/dist/dialog-DDE15qBB.js.map +1 -0
- package/dist/dialog-root-base-DDMrqDC9.js +328 -0
- package/dist/dialog-root-base-DDMrqDC9.js.map +1 -0
- package/dist/dialog-title-BitK2i0A.d.ts +78 -0
- package/dist/dialog.d.ts +9 -0
- package/dist/dialog.js +1 -0
- package/dist/direction-BfW1BOg1.js +22 -0
- package/dist/direction-BfW1BOg1.js.map +1 -0
- package/dist/direction-context-CiRdNJmu.js +11 -0
- package/dist/direction-context-CiRdNJmu.js.map +1 -0
- package/dist/direction.d.ts +2 -0
- package/dist/direction.js +1 -0
- package/dist/drawer-CaPOhMl-.js +302 -0
- package/dist/drawer-CaPOhMl-.js.map +1 -0
- package/dist/drawer.d.ts +9 -0
- package/dist/drawer.js +1 -0
- package/dist/drop-zone-q0-5u2cs.js +86 -0
- package/dist/drop-zone-q0-5u2cs.js.map +1 -0
- package/dist/drop-zone.d.ts +4 -0
- package/dist/drop-zone.js +1 -0
- package/dist/editable-vU6vYZOD.js +403 -0
- package/dist/editable-vU6vYZOD.js.map +1 -0
- package/dist/editable.d.ts +4 -0
- package/dist/editable.js +1 -0
- package/dist/field-DibhXWF6.js +308 -0
- package/dist/field-DibhXWF6.js.map +1 -0
- package/dist/field.d.ts +4 -0
- package/dist/field.js +1 -0
- package/dist/fieldset-Cz80P2jc.js +53 -0
- package/dist/fieldset-Cz80P2jc.js.map +1 -0
- package/dist/fieldset-context-CeaxEBvi.js +6 -0
- package/dist/fieldset-context-CeaxEBvi.js.map +1 -0
- package/dist/fieldset.d.ts +3 -0
- package/dist/fieldset.js +1 -0
- package/dist/file-upload-BIRibICU.js +513 -0
- package/dist/file-upload-BIRibICU.js.map +1 -0
- package/dist/file-upload.d.ts +4 -0
- package/dist/file-upload.js +1 -0
- package/dist/form-DNAaFPpL.js +87 -0
- package/dist/form-DNAaFPpL.js.map +1 -0
- package/dist/form-context-BW-nK6kl.js +6 -0
- package/dist/form-context-BW-nK6kl.js.map +1 -0
- package/dist/form.d.ts +3 -0
- package/dist/form.js +1 -0
- package/dist/hover-card-CRDpA_zU.js +317 -0
- package/dist/hover-card-CRDpA_zU.js.map +1 -0
- package/dist/hover-card.d.ts +9 -0
- package/dist/hover-card.js +1 -0
- package/dist/index-0bXL0iXX.d.ts +25 -0
- package/dist/index-6f2s5HfF.d.ts +30 -0
- package/dist/index-9WYWziGt.d.ts +42 -0
- package/dist/index-B57uQVXT.d.ts +100 -0
- package/dist/index-BA629roy.d.ts +52 -0
- package/dist/index-BC5bS-vC.d.ts +30 -0
- package/dist/index-BDbTYsJR.d.ts +77 -0
- package/dist/index-BEaxabvv.d.ts +80 -0
- package/dist/index-BLRo_PJD.d.ts +58 -0
- package/dist/index-BMt816ZL.d.ts +51 -0
- package/dist/index-BQJrDd_G.d.ts +108 -0
- package/dist/index-BUJIeLCT.d.ts +37 -0
- package/dist/index-BZxd4oqB.d.ts +111 -0
- package/dist/index-B_JVgpGe.d.ts +13 -0
- package/dist/index-BdxleDV0.d.ts +104 -0
- package/dist/index-Be4w9GAc.d.ts +13 -0
- package/dist/index-Bht8ohW3.d.ts +31 -0
- package/dist/index-Bk1NBvxD.d.ts +75 -0
- package/dist/index-BmtcAsQr.d.ts +44 -0
- package/dist/index-BmuEv-h3.d.ts +35 -0
- package/dist/index-BnPLIkKG.d.ts +31 -0
- package/dist/index-BoJU86K5.d.ts +52 -0
- package/dist/index-Bq6yByLv.d.ts +50 -0
- package/dist/index-Bqt2th2p.d.ts +41 -0
- package/dist/index-BrXfSGo2.d.ts +51 -0
- package/dist/index-BsvcTJ_x.d.ts +17 -0
- package/dist/index-BxcCz-NS.d.ts +36 -0
- package/dist/index-C3y4g2fs.d.ts +21 -0
- package/dist/index-C8-b81Jh.d.ts +20 -0
- package/dist/index-C8KLM25T.d.ts +31 -0
- package/dist/index-C9TSddnB.d.ts +140 -0
- package/dist/index-CCnaczzE.d.ts +32 -0
- package/dist/index-CD6hgnl1.d.ts +86 -0
- package/dist/index-CEN3o4Pw.d.ts +35 -0
- package/dist/index-CFlhfs3y.d.ts +30 -0
- package/dist/index-CIQU06ga.d.ts +36 -0
- package/dist/index-CNUEsZ_M.d.ts +51 -0
- package/dist/index-CNYBtgVC.d.ts +53 -0
- package/dist/index-CQJHcuzo.d.ts +76 -0
- package/dist/index-CTw9ONha.d.ts +69 -0
- package/dist/index-CU9QnAha.d.ts +32 -0
- package/dist/index-CcwKZWPY.d.ts +92 -0
- package/dist/index-Cjl7RT2o.d.ts +17 -0
- package/dist/index-ClfKp-sZ.d.ts +21 -0
- package/dist/index-CqGIxPDB.d.ts +82 -0
- package/dist/index-CsXJJ0G8.d.ts +41 -0
- package/dist/index-Cyjcq7lp.d.ts +28 -0
- package/dist/index-CzB9dDcM.d.ts +22 -0
- package/dist/index-D1-zqp2Q.d.ts +44 -0
- package/dist/index-D59OFWyx.d.ts +53 -0
- package/dist/index-D9lx4wAU.d.ts +21 -0
- package/dist/index-DHrnPQEE.d.ts +128 -0
- package/dist/index-DHwyHITu.d.ts +131 -0
- package/dist/index-DQ68aV2P.d.ts +21 -0
- package/dist/index-DQAkgf9_.d.ts +14 -0
- package/dist/index-DRow1231.d.ts +31 -0
- package/dist/index-DTGZeJU7.d.ts +29 -0
- package/dist/index-DU7jtvI8.d.ts +24 -0
- package/dist/index-DVjhOpXu.d.ts +42 -0
- package/dist/index-DZoqbcd6.d.ts +26 -0
- package/dist/index-Da0eVQHO.d.ts +62 -0
- package/dist/index-DhNPJa6U.d.ts +31 -0
- package/dist/index-DnQAamhU.d.ts +27 -0
- package/dist/index-DoFrs7Az.d.ts +16 -0
- package/dist/index-DorcIjVk.d.ts +20 -0
- package/dist/index-Dx-yMTdt.d.ts +81 -0
- package/dist/index-J4LbimqY.d.ts +79 -0
- package/dist/index-L6Mp2njJ.d.ts +81 -0
- package/dist/index-OmXQjsNi.d.ts +37 -0
- package/dist/index-PpCPWRbt.d.ts +30 -0
- package/dist/index-Pq-ztBxR.d.ts +34 -0
- package/dist/index-Qgz-Dnsj.d.ts +73 -0
- package/dist/index-R3h8-VcD.d.ts +32 -0
- package/dist/index-WtAHbmtb.d.ts +88 -0
- package/dist/index-dKoYaA3K.d.ts +38 -0
- package/dist/index-fgqEotIa.d.ts +16 -0
- package/dist/index-gvpnQy8T.d.ts +87 -0
- package/dist/index-kY3Yo50q.d.ts +68 -0
- package/dist/index-ndFpL4W9.d.ts +15 -0
- package/dist/index-oLgwTyCz.d.ts +45 -0
- package/dist/index-pSrGVYre.d.ts +40 -0
- package/dist/index-t4CBZJDG.d.ts +65 -0
- package/dist/index-wC8PY0fW.d.ts +16 -0
- package/dist/index-wv0Lafz4.d.ts +46 -0
- package/dist/index-zEeZUMLc.d.ts +29 -0
- package/dist/index.d.ts +125 -0
- package/dist/index.js +104 -0
- package/dist/label-DN9tJMXl.js +24 -0
- package/dist/label-DN9tJMXl.js.map +1 -0
- package/dist/label.d.ts +3 -0
- package/dist/label.js +1 -0
- package/dist/link-D3xYrfPK.js +22 -0
- package/dist/link-D3xYrfPK.js.map +1 -0
- package/dist/link-props-Shu8RU_5.js +27 -0
- package/dist/link-props-Shu8RU_5.js.map +1 -0
- package/dist/link.d.ts +3 -0
- package/dist/link.js +1 -0
- package/dist/listbox-virtual-C4wz3TOa.js +281 -0
- package/dist/listbox-virtual-C4wz3TOa.js.map +1 -0
- package/dist/listbox-virtual.d.ts +6 -0
- package/dist/listbox-virtual.js +3 -0
- package/dist/listbox.d.ts +5 -0
- package/dist/listbox.js +1 -0
- package/dist/live-region-style-Xgiu9ttw.js +48 -0
- package/dist/live-region-style-Xgiu9ttw.js.map +1 -0
- package/dist/menu-bar-context-1duNlOWo.js +14 -0
- package/dist/menu-bar-context-1duNlOWo.js.map +1 -0
- package/dist/menu-oZj27rvf.js +123 -0
- package/dist/menu-oZj27rvf.js.map +1 -0
- package/dist/menu-separator-CzAc4jM8.d.ts +143 -0
- package/dist/menu-submenu-trigger-BykOQORL.js +672 -0
- package/dist/menu-submenu-trigger-BykOQORL.js.map +1 -0
- package/dist/menu.d.ts +10 -0
- package/dist/menu.js +1 -0
- package/dist/menubar-wjJF54GJ.js +213 -0
- package/dist/menubar-wjJF54GJ.js.map +1 -0
- package/dist/menubar.d.ts +3 -0
- package/dist/menubar.js +1 -0
- package/dist/meter-11PgO99t.js +120 -0
- package/dist/meter-11PgO99t.js.map +1 -0
- package/dist/meter.d.ts +3 -0
- package/dist/meter.js +1 -0
- package/dist/month-calendar-value-CNJcsqcv.d.ts +5 -0
- package/dist/month-calendar-value-D_au-Kbz.js +35 -0
- package/dist/month-calendar-value-D_au-Kbz.js.map +1 -0
- package/dist/month-calendar.d.ts +6 -0
- package/dist/month-calendar.js +1 -0
- package/dist/month-picker-DFjFvjo9.js +26 -0
- package/dist/month-picker-DFjFvjo9.js.map +1 -0
- package/dist/month-picker-root-base-CI7jcllI.js +162 -0
- package/dist/month-picker-root-base-CI7jcllI.js.map +1 -0
- package/dist/month-picker-root-base-SELhczoy.d.ts +28 -0
- package/dist/month-picker.d.ts +10 -0
- package/dist/month-picker.js +3 -0
- package/dist/month-range-calendar-BmnWB6OD.js +28 -0
- package/dist/month-range-calendar-BmnWB6OD.js.map +1 -0
- package/dist/month-range-calendar.d.ts +6 -0
- package/dist/month-range-calendar.js +3 -0
- package/dist/month-range-picker-TfMtxi2X.js +26 -0
- package/dist/month-range-picker-TfMtxi2X.js.map +1 -0
- package/dist/month-range-picker.d.ts +10 -0
- package/dist/month-range-picker.js +3 -0
- package/dist/multiple-calendar-EBsuTzYQ.js +133 -0
- package/dist/multiple-calendar-EBsuTzYQ.js.map +1 -0
- package/dist/multiple-calendar.d.ts +7 -0
- package/dist/multiple-calendar.js +3 -0
- package/dist/navigation-menu-82shSjXS.js +660 -0
- package/dist/navigation-menu-82shSjXS.js.map +1 -0
- package/dist/navigation-menu.d.ts +5 -0
- package/dist/navigation-menu.js +1 -0
- package/dist/number-field-BUNkL15K.js +491 -0
- package/dist/number-field-BUNkL15K.js.map +1 -0
- package/dist/number-field.d.ts +4 -0
- package/dist/number-field.js +1 -0
- package/dist/otp-field-BMKBhv0O.js +363 -0
- package/dist/otp-field-BMKBhv0O.js.map +1 -0
- package/dist/otp-field.d.ts +4 -0
- package/dist/otp-field.js +1 -0
- package/dist/overlay-handle-DOyqO4oY.js +62 -0
- package/dist/overlay-handle-DOyqO4oY.js.map +1 -0
- package/dist/overlay-handle-DzzlzKqP.d.ts +16 -0
- package/dist/pagination-CMWaQSpr.js +173 -0
- package/dist/pagination-CMWaQSpr.js.map +1 -0
- package/dist/pagination.d.ts +4 -0
- package/dist/pagination.js +1 -0
- package/dist/parts-B2E7RN77.d.ts +170 -0
- package/dist/parts-BHkvkEgf.js +485 -0
- package/dist/parts-BHkvkEgf.js.map +1 -0
- package/dist/parts-BJ94V7Kv.d.ts +24 -0
- package/dist/parts-BL0sXepP.d.ts +101 -0
- package/dist/parts-BjC20sfl.d.ts +19 -0
- package/dist/parts-BnbJ2FWv.d.ts +81 -0
- package/dist/parts-C688_OLH.js +24 -0
- package/dist/parts-C688_OLH.js.map +1 -0
- package/dist/parts-C81p8gpg.d.ts +147 -0
- package/dist/parts-CDVlldST.js +721 -0
- package/dist/parts-CDVlldST.js.map +1 -0
- package/dist/parts-CNp1lOIU.js +24 -0
- package/dist/parts-CNp1lOIU.js.map +1 -0
- package/dist/parts-CXjEfLf7.d.ts +125 -0
- package/dist/parts-CrriPiIL.js +29 -0
- package/dist/parts-CrriPiIL.js.map +1 -0
- package/dist/parts-DVNSEjIO.d.ts +19 -0
- package/dist/parts-DmQ9WqOP.js +512 -0
- package/dist/parts-DmQ9WqOP.js.map +1 -0
- package/dist/parts-DoQQN1Io.d.ts +96 -0
- package/dist/parts-VT0Ohb06.js +806 -0
- package/dist/parts-VT0Ohb06.js.map +1 -0
- package/dist/parts-XRa0gd47.js +350 -0
- package/dist/parts-XRa0gd47.js.map +1 -0
- package/dist/parts-_ZriSS4p.js +376 -0
- package/dist/parts-_ZriSS4p.js.map +1 -0
- package/dist/password-input-BQAySlmc.js +212 -0
- package/dist/password-input-BQAySlmc.js.map +1 -0
- package/dist/password-input.d.ts +4 -0
- package/dist/password-input.js +1 -0
- package/dist/picker-binding-context-7ci59zS0.js +22 -0
- package/dist/picker-binding-context-7ci59zS0.js.map +1 -0
- package/dist/popover-C5UaRJpT.js +295 -0
- package/dist/popover-C5UaRJpT.js.map +1 -0
- package/dist/popover.d.ts +9 -0
- package/dist/popover.js +1 -0
- package/dist/progress-2d64jFqb.js +141 -0
- package/dist/progress-2d64jFqb.js.map +1 -0
- package/dist/progress.d.ts +3 -0
- package/dist/progress.js +1 -0
- package/dist/radio-Mvw36nnF.js +128 -0
- package/dist/radio-Mvw36nnF.js.map +1 -0
- package/dist/radio-group-D7DchtVK.js +149 -0
- package/dist/radio-group-D7DchtVK.js.map +1 -0
- package/dist/radio-group-context-DRe2PyiF.js +6 -0
- package/dist/radio-group-context-DRe2PyiF.js.map +1 -0
- package/dist/radio-group.d.ts +4 -0
- package/dist/radio-group.js +1 -0
- package/dist/radio.d.ts +3 -0
- package/dist/radio.js +1 -0
- package/dist/range-calendar-BMxPzzAr.js +32 -0
- package/dist/range-calendar-BMxPzzAr.js.map +1 -0
- package/dist/range-calendar.d.ts +6 -0
- package/dist/range-calendar.js +1 -0
- package/dist/rating-DQdIL_nz.js +303 -0
- package/dist/rating-DQdIL_nz.js.map +1 -0
- package/dist/rating.d.ts +4 -0
- package/dist/rating.js +1 -0
- package/dist/render-C7XnxB7f.js +40 -0
- package/dist/render-C7XnxB7f.js.map +1 -0
- package/dist/render-element-DXbUbfgN.js +66 -0
- package/dist/render-element-DXbUbfgN.js.map +1 -0
- package/dist/render-element-Pwuv2wsL.d.ts +13 -0
- package/dist/render.d.ts +3 -0
- package/dist/render.js +1 -0
- package/dist/roving-context-BVp0I9UN.js +16 -0
- package/dist/roving-context-BVp0I9UN.js.map +1 -0
- package/dist/scroll-area-CGaVLKik.js +274 -0
- package/dist/scroll-area-CGaVLKik.js.map +1 -0
- package/dist/scroll-area.d.ts +3 -0
- package/dist/scroll-area.js +1 -0
- package/dist/search-field-DqGQt6pC.js +207 -0
- package/dist/search-field-DqGQt6pC.js.map +1 -0
- package/dist/search-field.d.ts +4 -0
- package/dist/search-field.js +1 -0
- package/dist/segmented-control-BYrnLASo.js +316 -0
- package/dist/segmented-control-BYrnLASo.js.map +1 -0
- package/dist/segmented-control.d.ts +4 -0
- package/dist/segmented-control.js +1 -0
- package/dist/select-virtual-9vDaEiye.js +55 -0
- package/dist/select-virtual-9vDaEiye.js.map +1 -0
- package/dist/select-virtual.d.ts +4 -0
- package/dist/select-virtual.js +3 -0
- package/dist/select.d.ts +8 -0
- package/dist/select.js +1 -0
- package/dist/separator-ChAJks2Q.js +18 -0
- package/dist/separator-ChAJks2Q.js.map +1 -0
- package/dist/separator.d.ts +3 -0
- package/dist/separator.js +1 -0
- package/dist/slider-DZiqQ18C.js +437 -0
- package/dist/slider-DZiqQ18C.js.map +1 -0
- package/dist/slider.d.ts +4 -0
- package/dist/slider.js +1 -0
- package/dist/state-attributes-DhboDeMS.js +14 -0
- package/dist/state-attributes-DhboDeMS.js.map +1 -0
- package/dist/steps-t_FxFH9P.js +251 -0
- package/dist/steps-t_FxFH9P.js.map +1 -0
- package/dist/steps.d.ts +4 -0
- package/dist/steps.js +1 -0
- package/dist/switch-D3zj8gtg.js +137 -0
- package/dist/switch-D3zj8gtg.js.map +1 -0
- package/dist/switch.d.ts +4 -0
- package/dist/switch.js +1 -0
- package/dist/tabs-o83wz1hF.js +285 -0
- package/dist/tabs-o83wz1hF.js.map +1 -0
- package/dist/tabs.d.ts +4 -0
- package/dist/tabs.js +1 -0
- package/dist/tag-group-gmBdCkE4.js +354 -0
- package/dist/tag-group-gmBdCkE4.js.map +1 -0
- package/dist/tag-group.d.ts +4 -0
- package/dist/tag-group.js +1 -0
- package/dist/tags-input-Co9pI732.js +555 -0
- package/dist/tags-input-Co9pI732.js.map +1 -0
- package/dist/tags-input.d.ts +4 -0
- package/dist/tags-input.js +1 -0
- package/dist/time-field-qqgemJB1.js +35 -0
- package/dist/time-field-qqgemJB1.js.map +1 -0
- package/dist/time-field.d.ts +5 -0
- package/dist/time-field.js +1 -0
- package/dist/time-range-field-BurnJee0.js +36 -0
- package/dist/time-range-field-BurnJee0.js.map +1 -0
- package/dist/time-range-field.d.ts +7 -0
- package/dist/time-range-field.js +1 -0
- package/dist/toast-ChdTo_Md.js +341 -0
- package/dist/toast-ChdTo_Md.js.map +1 -0
- package/dist/toast.d.ts +4 -0
- package/dist/toast.js +1 -0
- package/dist/toggle-W5tihPuD.js +65 -0
- package/dist/toggle-W5tihPuD.js.map +1 -0
- package/dist/toggle-group-DpJ794rw.js +73 -0
- package/dist/toggle-group-DpJ794rw.js.map +1 -0
- package/dist/toggle-group-context-Bp44l1NR.js +6 -0
- package/dist/toggle-group-context-Bp44l1NR.js.map +1 -0
- package/dist/toggle-group.d.ts +4 -0
- package/dist/toggle-group.js +1 -0
- package/dist/toggle.d.ts +4 -0
- package/dist/toggle.js +1 -0
- package/dist/toolbar-DfjePeEZ.js +178 -0
- package/dist/toolbar-DfjePeEZ.js.map +1 -0
- package/dist/toolbar.d.ts +3 -0
- package/dist/toolbar.js +1 -0
- package/dist/tooltip-CqZtSspz.js +320 -0
- package/dist/tooltip-CqZtSspz.js.map +1 -0
- package/dist/tooltip.d.ts +9 -0
- package/dist/tooltip.js +1 -0
- package/dist/use-color-picker-binding-D0R-FsfF.js +17 -0
- package/dist/use-color-picker-binding-D0R-FsfF.js.map +1 -0
- package/dist/use-controllable-state-Dm8eNkgP.js +36 -0
- package/dist/use-controllable-state-Dm8eNkgP.js.map +1 -0
- package/dist/use-element-tpFZ-kuA.js +10 -0
- package/dist/use-element-tpFZ-kuA.js.map +1 -0
- package/dist/use-field-control-CL_nOU7T.js +131 -0
- package/dist/use-field-control-CL_nOU7T.js.map +1 -0
- package/dist/use-overlay-portal-Cfv6qtTO.js +18 -0
- package/dist/use-overlay-portal-Cfv6qtTO.js.map +1 -0
- package/dist/use-overlay-portal-D8GjZ-m7.d.ts +13 -0
- package/dist/use-overlay-root-BDO5E_0S.d.ts +23 -0
- package/dist/use-overlay-root-eXuUlCpV.js +225 -0
- package/dist/use-overlay-root-eXuUlCpV.js.map +1 -0
- package/dist/use-overlay-trigger-CxW1Z6Q6.js +74 -0
- package/dist/use-overlay-trigger-CxW1Z6Q6.js.map +1 -0
- package/dist/use-overlay-trigger-PP99t2ZF.d.ts +11 -0
- package/dist/use-panel-transition-CKMdsqPR.js +145 -0
- package/dist/use-panel-transition-CKMdsqPR.js.map +1 -0
- package/dist/use-positioner-BpxM4U5Y.d.ts +11 -0
- package/dist/use-positioner-DtJR980s.js +56 -0
- package/dist/use-positioner-DtJR980s.js.map +1 -0
- package/dist/use-presence-Cwi_UTLe.js +97 -0
- package/dist/use-presence-Cwi_UTLe.js.map +1 -0
- package/dist/use-required-context-Cjd_CYnv.js +11 -0
- package/dist/use-required-context-Cjd_CYnv.js.map +1 -0
- package/dist/use-roving-composite-D0vtGxm8.js +82 -0
- package/dist/use-roving-composite-D0vtGxm8.js.map +1 -0
- package/dist/use-roving-item-Dxe3phsZ.js +42 -0
- package/dist/use-roving-item-Dxe3phsZ.js.map +1 -0
- package/dist/use-segment-group--unFuh-Z.js +307 -0
- package/dist/use-segment-group--unFuh-Z.js.map +1 -0
- package/dist/use-virtual-rows-B5N0qgmT.js +99 -0
- package/dist/use-virtual-rows-B5N0qgmT.js.map +1 -0
- package/dist/use-virtual-rows-BQFqR0_e.d.ts +16 -0
- package/dist/year-calendar-CroBMFMN.js +28 -0
- package/dist/year-calendar-CroBMFMN.js.map +1 -0
- package/dist/year-calendar.d.ts +6 -0
- package/dist/year-calendar.js +3 -0
- package/dist/year-picker-DJVxXtPh.js +26 -0
- package/dist/year-picker-DJVxXtPh.js.map +1 -0
- package/dist/year-picker.d.ts +10 -0
- package/dist/year-picker.js +3 -0
- package/dist/year-range-calendar-Cz2WYDV2.js +28 -0
- package/dist/year-range-calendar-Cz2WYDV2.js.map +1 -0
- package/dist/year-range-calendar.d.ts +6 -0
- package/dist/year-range-calendar.js +3 -0
- package/dist/year-range-picker-9f7L5Hgx.js +26 -0
- package/dist/year-range-picker-9f7L5Hgx.js.map +1 -0
- package/dist/year-range-picker.d.ts +10 -0
- package/dist/year-range-picker.js +3 -0
- package/package.json +553 -3
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { n as scopeOfElement, t as RovingContext } from "./roving-context-BVp0I9UN.js";
|
|
2
|
+
import { t as useElement } from "./use-element-tpFZ-kuA.js";
|
|
3
|
+
import { useContext, useLayoutEffect } from "react";
|
|
4
|
+
// src/hooks/use-roving-item.ts
|
|
5
|
+
/**
|
|
6
|
+
* An item of the nearest roving-focus scope (spec/toolbar.md, "Nested composites"): it registers
|
|
7
|
+
* its element, takes the roving `tabIndex` (`0` on the scope's tab stop, `-1` on every other item
|
|
8
|
+
* and before the items are known) and tells the scope when it takes focus. An element outside the
|
|
9
|
+
* scope's root (rendered through a portal) is in no scope ("Nested composites", 6). `focusable`
|
|
10
|
+
* reads the scope's `disabled`; `explicit` names the scope instead of the nearest one (a
|
|
11
|
+
* Menubar's, which its Triggers read from the bar's contract; `null`: none).
|
|
12
|
+
*/
|
|
13
|
+
function useRovingItem(focusable, explicit) {
|
|
14
|
+
const nearest = useContext(RovingContext);
|
|
15
|
+
const [element, ref] = useElement();
|
|
16
|
+
const around = explicit === void 0 ? nearest : explicit;
|
|
17
|
+
const scope = scopeOfElement(around, element);
|
|
18
|
+
const register = scope?.register;
|
|
19
|
+
const canFocus = scope === null ? false : focusable(scope.disabled);
|
|
20
|
+
useLayoutEffect(() => register === void 0 || element === null ? void 0 : register(element, canFocus), [
|
|
21
|
+
register,
|
|
22
|
+
element,
|
|
23
|
+
canFocus
|
|
24
|
+
]);
|
|
25
|
+
if (scope === null) return {
|
|
26
|
+
scope,
|
|
27
|
+
tabIndex: void 0,
|
|
28
|
+
ref: around === null ? void 0 : ref,
|
|
29
|
+
onFocus: () => {}
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
scope,
|
|
33
|
+
tabIndex: element !== null && scope.tabStop === element ? 0 : -1,
|
|
34
|
+
ref,
|
|
35
|
+
onFocus: () => {
|
|
36
|
+
if (element !== null) scope.focused(element);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export { useRovingItem as t };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=use-roving-item-Dxe3phsZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-roving-item-Dxe3phsZ.js","names":[],"sources":["../src/hooks/use-roving-item.ts"],"sourcesContent":["import { useContext, useLayoutEffect } from \"react\";\nimport {\n RovingContext,\n type RovingScope,\n scopeOfElement,\n} from \"../utils/roving-context.ts\";\nimport { useElement } from \"./use-element.ts\";\n\nexport interface RovingItem {\n /**\n * The scope it is an item of: the nearest one (or `explicit`), unless its element is outside\n * that scope's root (a popup rendered through a portal); `null` outside any.\n */\n scope: RovingScope | null;\n /** The roving `tabIndex`; `undefined` outside any scope. */\n tabIndex: number | undefined;\n /**\n * The item's element, attached whenever a scope is around it (also while it is outside the\n * scope's root, so the item keeps knowing where it is); `undefined` with no scope around it.\n */\n ref: ((node: HTMLElement | null) => void) | undefined;\n onFocus: () => void;\n}\n\n/**\n * An item of the nearest roving-focus scope (spec/toolbar.md, \"Nested composites\"): it registers\n * its element, takes the roving `tabIndex` (`0` on the scope's tab stop, `-1` on every other item\n * and before the items are known) and tells the scope when it takes focus. An element outside the\n * scope's root (rendered through a portal) is in no scope (\"Nested composites\", 6). `focusable`\n * reads the scope's `disabled`; `explicit` names the scope instead of the nearest one (a\n * Menubar's, which its Triggers read from the bar's contract; `null`: none).\n */\nexport function useRovingItem(\n focusable: (scopeDisabled: boolean) => boolean,\n explicit?: RovingScope | null,\n): RovingItem {\n const nearest = useContext(RovingContext);\n const [element, ref] = useElement<HTMLElement>();\n const around = explicit === undefined ? nearest : explicit;\n const scope = scopeOfElement(around, element);\n const register = scope?.register;\n const canFocus = scope === null ? false : focusable(scope.disabled);\n useLayoutEffect(\n () =>\n register === undefined || element === null\n ? undefined\n : register(element, canFocus),\n [register, element, canFocus],\n );\n if (scope === null) {\n return {\n scope,\n tabIndex: undefined,\n ref: around === null ? undefined : ref,\n onFocus: () => {},\n };\n }\n return {\n scope,\n tabIndex: element !== null && scope.tabStop === element ? 0 : -1,\n ref,\n onFocus: () => {\n if (element !== null) {\n scope.focused(element);\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,SAAgB,cACZ,WACA,UACU;CACV,MAAM,UAAU,WAAW,aAAa;CACxC,MAAM,CAAC,SAAS,OAAO,WAAwB;CAC/C,MAAM,SAAS,aAAa,KAAA,IAAY,UAAU;CAClD,MAAM,QAAQ,eAAe,QAAQ,OAAO;CAC5C,MAAM,WAAW,OAAO;CACxB,MAAM,WAAW,UAAU,OAAO,QAAQ,UAAU,MAAM,QAAQ;CAClE,sBAEQ,aAAa,KAAA,KAAa,YAAY,OAChC,KAAA,IACA,SAAS,SAAS,QAAQ,GACpC;EAAC;EAAU;EAAS;CAAQ,CAChC;CACA,IAAI,UAAU,MACV,OAAO;EACH;EACA,UAAU,KAAA;EACV,KAAK,WAAW,OAAO,KAAA,IAAY;EACnC,eAAe,CAAC;CACpB;CAEJ,OAAO;EACH;EACA,UAAU,YAAY,QAAQ,MAAM,YAAY,UAAU,IAAI;EAC9D;EACA,eAAe;GACX,IAAI,YAAY,MACZ,MAAM,QAAQ,OAAO;EAE7B;CACJ;AACJ"}
|
|
@@ -0,0 +1,307 @@
|
|
|
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, useCallback, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { toIsoDate, watchDocumentLanguage } from "@fragiola/primitives/date";
|
|
6
|
+
import { dateSegments, isSegmentsComplete, segmentKeyDown, segmentTarget, segmentValuesOf, segmentsToDate, segmentsToDateTime, segmentsToTime, typeSegment } from "@fragiola/primitives/segments";
|
|
7
|
+
import { compareDateTimes, compareTimes, toIsoDateTime, toIsoTime } from "@fragiola/primitives/time";
|
|
8
|
+
// src/components/date-field/date-field-context.ts
|
|
9
|
+
const DateFieldContext = createContext(null);
|
|
10
|
+
// src/components/date-field/date-field-segment.tsx
|
|
11
|
+
const NUMERIC_STYLE = {
|
|
12
|
+
unicodeBidi: "embed",
|
|
13
|
+
direction: "ltr"
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* One segment: a `spinbutton` the user types into or steps (the APG), or a literal hidden from
|
|
17
|
+
* assistive technology (spec/date-field.md, "State attributes and ARIA").
|
|
18
|
+
*/
|
|
19
|
+
function DateFieldSegment({ segment, children, ...props }) {
|
|
20
|
+
const context = useRequiredContext(DateFieldContext, "DateField.Segment");
|
|
21
|
+
const id = useId();
|
|
22
|
+
const element = useRef(null);
|
|
23
|
+
const latest = useRef({
|
|
24
|
+
context,
|
|
25
|
+
segment
|
|
26
|
+
});
|
|
27
|
+
latest.current = {
|
|
28
|
+
context,
|
|
29
|
+
segment
|
|
30
|
+
};
|
|
31
|
+
const { disabled, readOnly, required, invalid, field, labelId } = context;
|
|
32
|
+
const editable = segment.editable;
|
|
33
|
+
const writable = editable && !disabled && !readOnly;
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const node = element.current;
|
|
36
|
+
if (node === null || !writable) return;
|
|
37
|
+
const onBeforeInput = (event) => {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
const { context: current, segment: shown } = latest.current;
|
|
40
|
+
if (event.inputType === "deleteContentBackward") {
|
|
41
|
+
current.onSegmentKey(shown, new KeyboardEvent("keydown", { key: "Backspace" }), node);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (event.data !== null && event.data !== "") current.onSegmentText(shown, event.data, event, node);
|
|
45
|
+
};
|
|
46
|
+
node.addEventListener("beforeinput", onBeforeInput);
|
|
47
|
+
return () => node.removeEventListener("beforeinput", onBeforeInput);
|
|
48
|
+
}, [writable]);
|
|
49
|
+
const state = {
|
|
50
|
+
disabled,
|
|
51
|
+
readOnly,
|
|
52
|
+
required,
|
|
53
|
+
invalid,
|
|
54
|
+
type: segment.type,
|
|
55
|
+
placeholder: segment.placeholder
|
|
56
|
+
};
|
|
57
|
+
const content = children ?? segment.text;
|
|
58
|
+
const textual = segment.type === "dayPeriod" || segment.type === "era";
|
|
59
|
+
if (!editable) return renderElement("span", {
|
|
60
|
+
...props,
|
|
61
|
+
children: content
|
|
62
|
+
}, state, {
|
|
63
|
+
"aria-hidden": segment.type === "literal" ? "true" : void 0,
|
|
64
|
+
"data-primitives-part": `${context.component}-segment`,
|
|
65
|
+
"data-type": segment.type,
|
|
66
|
+
...context.attributes
|
|
67
|
+
});
|
|
68
|
+
return renderElement("span", {
|
|
69
|
+
...props,
|
|
70
|
+
children: content
|
|
71
|
+
}, state, {
|
|
72
|
+
id,
|
|
73
|
+
role: "spinbutton",
|
|
74
|
+
tabIndex: disabled ? void 0 : 0,
|
|
75
|
+
"aria-label": segment.label ?? void 0,
|
|
76
|
+
"aria-labelledby": labelId === void 0 ? void 0 : `${labelId} ${id}`,
|
|
77
|
+
"aria-valuenow": segment.value ?? void 0,
|
|
78
|
+
"aria-valuetext": segment.valueText ?? void 0,
|
|
79
|
+
"aria-valuemin": segment.min ?? void 0,
|
|
80
|
+
"aria-valuemax": segment.max ?? void 0,
|
|
81
|
+
"aria-invalid": invalid ? "true" : void 0,
|
|
82
|
+
"aria-required": required ? "true" : void 0,
|
|
83
|
+
"aria-readonly": readOnly ? "true" : void 0,
|
|
84
|
+
"aria-disabled": disabled ? "true" : void 0,
|
|
85
|
+
contentEditable: writable ? true : void 0,
|
|
86
|
+
suppressContentEditableWarning: true,
|
|
87
|
+
inputMode: textual ? "text" : "numeric",
|
|
88
|
+
spellCheck: "false",
|
|
89
|
+
autoCorrect: "off",
|
|
90
|
+
autoCapitalize: "off",
|
|
91
|
+
enterKeyHint: "next",
|
|
92
|
+
style: textual ? void 0 : NUMERIC_STYLE,
|
|
93
|
+
"data-primitives-part": `${context.component}-segment`,
|
|
94
|
+
"data-type": segment.type,
|
|
95
|
+
"data-placeholder": segment.placeholder ? "" : void 0,
|
|
96
|
+
...context.attributes,
|
|
97
|
+
onKeyDown: (event) => {
|
|
98
|
+
const { context: current, segment: shown } = latest.current;
|
|
99
|
+
if (current.onSegmentKey(shown, event.nativeEvent, event.currentTarget)) event.preventDefault();
|
|
100
|
+
},
|
|
101
|
+
onFocus: () => field.onFocus(),
|
|
102
|
+
onBlur: (event) => {
|
|
103
|
+
const { context: current, segment: shown } = latest.current;
|
|
104
|
+
current.onSegmentBlur(shown, event.nativeEvent, event.currentTarget);
|
|
105
|
+
}
|
|
106
|
+
}, (node) => {
|
|
107
|
+
element.current = node;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
// src/components/date-field/date-field-input.tsx
|
|
111
|
+
/** The `group` of the segments (spec/date-field.md, "Anatomy"). */
|
|
112
|
+
function DateFieldInput({ children, ...props }) {
|
|
113
|
+
const context = useRequiredContext(DateFieldContext, "DateField.Input");
|
|
114
|
+
const { field } = context;
|
|
115
|
+
const state = {
|
|
116
|
+
disabled: context.disabled,
|
|
117
|
+
readOnly: context.readOnly,
|
|
118
|
+
required: context.required,
|
|
119
|
+
invalid: context.invalid
|
|
120
|
+
};
|
|
121
|
+
return renderElement("div", {
|
|
122
|
+
...props,
|
|
123
|
+
children: context.segments.map((segment) => children ? children(segment) : /* @__PURE__ */ jsx(DateFieldSegment, { segment }, segment.index))
|
|
124
|
+
}, state, {
|
|
125
|
+
role: "group",
|
|
126
|
+
"aria-labelledby": field.aria["aria-labelledby"],
|
|
127
|
+
"aria-describedby": field.aria["aria-describedby"],
|
|
128
|
+
"data-primitives-part": context.inputPart ?? `${context.component}-input`,
|
|
129
|
+
...context.attributes
|
|
130
|
+
}, context.setInputElement);
|
|
131
|
+
}
|
|
132
|
+
// src/components/date-field/field-value.ts
|
|
133
|
+
/**
|
|
134
|
+
* A value's ISO text at the field's granularity (spec/date-field.md, "Forms"); a zoned value's with
|
|
135
|
+
* its offset and zone (spec/time-zones.md).
|
|
136
|
+
*/
|
|
137
|
+
function isoOf(kind, granularity, value, timeZone) {
|
|
138
|
+
if (value == null) return "";
|
|
139
|
+
const precision = granularity === "second" ? "second" : "minute";
|
|
140
|
+
if (timeZone && "offset" in value) return timeZone.toIso(value, precision);
|
|
141
|
+
if (kind === "time") return toIsoTime(value, precision);
|
|
142
|
+
if (granularity === "day") return toIsoDate(value);
|
|
143
|
+
const { hour = 0, minute = 0, second = 0, millisecond = 0 } = value;
|
|
144
|
+
return toIsoDateTime({
|
|
145
|
+
...value,
|
|
146
|
+
hour,
|
|
147
|
+
minute,
|
|
148
|
+
second,
|
|
149
|
+
millisecond
|
|
150
|
+
}, precision);
|
|
151
|
+
}
|
|
152
|
+
/** Orders two values of a field (a `PlainDate` counts as its midnight). */
|
|
153
|
+
function compareValues(kind, a, b) {
|
|
154
|
+
return kind === "time" ? compareTimes(a, b) : compareDateTimes(a, b);
|
|
155
|
+
}
|
|
156
|
+
/** Whether a value is out of `min` / `max`, or (a date) unavailable (spec/date-field.md). */
|
|
157
|
+
function isOutOfRange(kind, value, min, max, isDateUnavailable) {
|
|
158
|
+
return min !== void 0 && compareValues(kind, value, min) < 0 || max !== void 0 && compareValues(kind, value, max) > 0 || kind === "date" && isDateUnavailable?.(value) === true;
|
|
159
|
+
}
|
|
160
|
+
/** The value complete segment values make (`null` while one is a placeholder). */
|
|
161
|
+
function composeSegments(format, kind, granularity, values) {
|
|
162
|
+
return !isSegmentsComplete(format, values) ? null : kind === "time" ? segmentsToTime(values) : granularity === "day" ? segmentsToDate(values, format) : segmentsToDateTime(values, format);
|
|
163
|
+
}
|
|
164
|
+
/** A bound's ISO text for a hidden input's `min` / `max` (`undefined` with none). */
|
|
165
|
+
function boundIso(kind, granularity, edge) {
|
|
166
|
+
return edge === void 0 ? void 0 : isoOf(kind, granularity, edge);
|
|
167
|
+
}
|
|
168
|
+
// src/components/date-field/use-document-locale.ts
|
|
169
|
+
/** The locale of the first render with no `locale`: a server knows neither of the others. */
|
|
170
|
+
const FIRST_RENDER_LOCALE = "en-US";
|
|
171
|
+
const serverLocale = () => FIRST_RENDER_LOCALE;
|
|
172
|
+
const subscribeLanguage = (change) => watchDocumentLanguage(document, change);
|
|
173
|
+
function documentLocale() {
|
|
174
|
+
if (typeof document !== "undefined" && document.documentElement.lang) return document.documentElement.lang;
|
|
175
|
+
return typeof navigator !== "undefined" ? navigator.language : FIRST_RENDER_LOCALE;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* A date or time field's locale (spec/date-field.md, "API"): its own, else the document's `lang`,
|
|
179
|
+
* else the browser's language; a server render and its hydration use `en-US`, and React renders
|
|
180
|
+
* again with the document's right after (the calendars' rule, spec/calendar.md "API"). The
|
|
181
|
+
* calendars keep their own copy, so their entries are unchanged.
|
|
182
|
+
*/
|
|
183
|
+
function useDocumentLocale(locale) {
|
|
184
|
+
const fallback = useSyncExternalStore(subscribeLanguage, documentLocale, serverLocale);
|
|
185
|
+
return locale ?? fallback;
|
|
186
|
+
}
|
|
187
|
+
// src/components/date-field/use-segment-group.ts
|
|
188
|
+
/** The change reason of an edit (spec/date-field.md, "API"): `null` after an erase clears. */
|
|
189
|
+
function editReason(edit, value) {
|
|
190
|
+
return edit === "step" ? "keyboard" : edit === "erase" && value === null ? "input-clear" : "input-change";
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* One group of segments (spec/date-field.md): the values the user set, the digits being typed,
|
|
194
|
+
* the segments to render and what their keys and text do. A DateField has one; a range field and
|
|
195
|
+
* a range picker's typed input two, one per end (spec/date-range-field.md). The value and its
|
|
196
|
+
* reports are the root's: the group says what its segments make after each edit.
|
|
197
|
+
*/
|
|
198
|
+
function useSegmentGroup(options) {
|
|
199
|
+
const { format } = options;
|
|
200
|
+
const [values, setValues] = useState(() => segmentValuesOf(format, options.initial));
|
|
201
|
+
const [edit, setEdit] = useState(null);
|
|
202
|
+
const [element, setElement] = useState(null);
|
|
203
|
+
const current = useRef({
|
|
204
|
+
values,
|
|
205
|
+
edit
|
|
206
|
+
});
|
|
207
|
+
const latest = useRef(options);
|
|
208
|
+
latest.current = options;
|
|
209
|
+
const actions = useMemo(() => {
|
|
210
|
+
/** Applies new segment values, and reports what they make. */
|
|
211
|
+
const apply = (next, nextEdit, kind, event) => {
|
|
212
|
+
const state = latest.current;
|
|
213
|
+
current.current = {
|
|
214
|
+
values: next,
|
|
215
|
+
edit: nextEdit
|
|
216
|
+
};
|
|
217
|
+
setValues(next);
|
|
218
|
+
setEdit(nextEdit);
|
|
219
|
+
state.onEdit(composeSegments(state.format, state.kind, state.granularity, next), kind, event);
|
|
220
|
+
};
|
|
221
|
+
const editable = () => {
|
|
222
|
+
const state = latest.current;
|
|
223
|
+
return !state.disabled && !state.readOnly;
|
|
224
|
+
};
|
|
225
|
+
const move = (from, to) => segmentTarget(from, to, latest.current.groups?.())?.focus();
|
|
226
|
+
return {
|
|
227
|
+
/** A key on a segment: whether the group took it (its default is then prevented). */
|
|
228
|
+
onSegmentKey: (segment, event, target) => {
|
|
229
|
+
const state = latest.current;
|
|
230
|
+
if (!segment.editable || state.disabled || event.altKey || event.ctrlKey || event.metaKey) return false;
|
|
231
|
+
const { values: before, edit: typing } = current.current;
|
|
232
|
+
const result = segmentKeyDown(state.format, before, segment.type, event.key, typing, {
|
|
233
|
+
seed: state.seed,
|
|
234
|
+
readOnly: !editable()
|
|
235
|
+
});
|
|
236
|
+
if (result === null) return false;
|
|
237
|
+
if (result.kind !== "move") apply(result.values, result.edit, result.kind === "step" ? "step" : "erase", event);
|
|
238
|
+
if (result.move !== null) move(target, result.move);
|
|
239
|
+
return true;
|
|
240
|
+
},
|
|
241
|
+
/** Text typed into a segment (`beforeinput`'s data). */
|
|
242
|
+
onSegmentText: (segment, text, event, target) => {
|
|
243
|
+
if (!segment.editable || !editable()) return;
|
|
244
|
+
const state = latest.current;
|
|
245
|
+
let { values: next, edit: typing } = current.current;
|
|
246
|
+
let advance = false;
|
|
247
|
+
for (const character of text) {
|
|
248
|
+
const result = typeSegment(state.format, next, segment.type, character, typing, state.seed);
|
|
249
|
+
if (result === null) continue;
|
|
250
|
+
next = result.values;
|
|
251
|
+
typing = result.edit;
|
|
252
|
+
advance = result.advance;
|
|
253
|
+
}
|
|
254
|
+
if (next === current.current.values && typing === current.current.edit) return;
|
|
255
|
+
apply(next, typing, "type", event);
|
|
256
|
+
if (advance) move(target, "next");
|
|
257
|
+
},
|
|
258
|
+
/** A segment lost the focus: its typed digits are dropped; leaving the groups blurs. */
|
|
259
|
+
onSegmentBlur: (segment, event, target) => {
|
|
260
|
+
const { edit: typing } = current.current;
|
|
261
|
+
if (typing !== null && typing.type === segment.type) {
|
|
262
|
+
current.current = {
|
|
263
|
+
...current.current,
|
|
264
|
+
edit: null
|
|
265
|
+
};
|
|
266
|
+
setEdit(null);
|
|
267
|
+
}
|
|
268
|
+
const own = target.closest("[role=\"group\"]");
|
|
269
|
+
const groups = latest.current.groups?.() ?? (own === null ? [] : [own]);
|
|
270
|
+
const to = event.relatedTarget;
|
|
271
|
+
if (to === null || !groups.some((group) => group.contains(to))) latest.current.onBlur();
|
|
272
|
+
},
|
|
273
|
+
/** Replaces the segments with a value's (`null`: every one a placeholder). */
|
|
274
|
+
replace: (value) => {
|
|
275
|
+
const next = segmentValuesOf(latest.current.format, value);
|
|
276
|
+
current.current = {
|
|
277
|
+
values: next,
|
|
278
|
+
edit: null
|
|
279
|
+
};
|
|
280
|
+
setValues(next);
|
|
281
|
+
setEdit(null);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
}, []);
|
|
285
|
+
const firstSegment = useCallback(() => element?.querySelector("[role=\"spinbutton\"][tabindex]") ?? null, [element]);
|
|
286
|
+
return {
|
|
287
|
+
segments: useMemo(() => dateSegments(format, values, edit), [
|
|
288
|
+
format,
|
|
289
|
+
values,
|
|
290
|
+
edit
|
|
291
|
+
]),
|
|
292
|
+
/** The segment values this render shows. */
|
|
293
|
+
rendered: values,
|
|
294
|
+
/** Whether every segment is set (the state as of the last change). */
|
|
295
|
+
complete: () => isSegmentsComplete(format, current.current.values),
|
|
296
|
+
/** The segment values as of the last change. */
|
|
297
|
+
values: () => current.current.values,
|
|
298
|
+
element,
|
|
299
|
+
setElement,
|
|
300
|
+
/** The first editable segment: the focus target, where a label press and a failed validation go. */
|
|
301
|
+
firstSegment,
|
|
302
|
+
...actions
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
export { compareValues as a, isoOf as c, DateFieldContext as d, boundIso as i, DateFieldInput as l, useSegmentGroup as n, composeSegments as o, useDocumentLocale as r, isOutOfRange as s, editReason as t, DateFieldSegment as u };
|
|
306
|
+
|
|
307
|
+
//# sourceMappingURL=use-segment-group--unFuh-Z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-segment-group--unFuh-Z.js","names":[],"sources":["../src/components/date-field/date-field-context.ts","../src/components/date-field/date-field-segment.tsx","../src/components/date-field/date-field-input.tsx","../src/components/date-field/field-value.ts","../src/components/date-field/use-document-locale.ts","../src/components/date-field/use-segment-group.ts"],"sourcesContent":["import type { DateSegment, SegmentFormat } from \"@fragiola/primitives/segments\";\nimport { createContext } from \"react\";\nimport type { FieldControlBinding } from \"../../hooks/use-field-control.ts\";\n\n/**\n * Which root the shared parts sit in: their part attribute names it (spec/date-field.md; the\n * range fields' and the pickers' typed input, spec/date-range-field.md and spec/calendar.md).\n */\nexport type DateFieldComponent =\n | \"date-field\"\n | \"time-field\"\n | \"date-range-field\"\n | \"time-range-field\"\n | \"date-picker\"\n | \"date-range-picker\";\n\n/** The state every part renders with (spec/date-field.md, \"State attributes and ARIA\"). */\nexport interface DateFieldState {\n disabled: boolean;\n readOnly: boolean;\n required: boolean;\n /** Out of range or unavailable, or the Field shows an error. */\n invalid: boolean;\n}\n\n/** A Segment's state: the field's, with its own type and placeholder state. */\nexport interface DateFieldSegmentState extends DateFieldState {\n type: DateSegment[\"type\"];\n placeholder: boolean;\n}\n\nexport interface DateFieldContextValue extends DateFieldState {\n component: DateFieldComponent;\n /** The Input's part attribute, when not `<component>-input` (a picker's `-segments`). */\n inputPart?: string;\n format: SegmentFormat;\n segments: DateSegment[];\n /** The Field's label id (the segments' `aria-labelledby` starts with it). */\n labelId: string | undefined;\n field: FieldControlBinding;\n /** The state attributes and the field's, for every part. */\n attributes: Record<`data-${string}`, string>;\n setInputElement: (element: HTMLElement | null) => void;\n /** A key on a segment: whether the field took it (its default is then prevented). */\n onSegmentKey: (\n segment: DateSegment,\n event: KeyboardEvent,\n element: HTMLElement,\n ) => boolean;\n /** Text typed into a segment (`beforeinput`'s data). */\n onSegmentText: (\n segment: DateSegment,\n text: string,\n event: Event,\n element: HTMLElement,\n ) => void;\n /** A segment lost the focus. */\n onSegmentBlur: (\n segment: DateSegment,\n event: FocusEvent,\n element: HTMLElement,\n ) => void;\n}\n\nexport const DateFieldContext = createContext<DateFieldContextValue | null>(\n null,\n);\n","import type { DateSegment } from \"@fragiola/primitives/segments\";\nimport {\n type FocusEvent,\n type KeyboardEvent as ReactKeyboardEvent,\n useEffect,\n useId,\n useRef,\n} from \"react\";\nimport { useRequiredContext } from \"../../hooks/use-required-context.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport {\n DateFieldContext,\n type DateFieldSegmentState,\n} from \"./date-field-context.ts\";\n\nexport interface DateFieldSegmentProps\n extends PartProps<DateFieldSegmentState> {\n /** One of the Input's segments. */\n segment: DateSegment;\n}\n\n// numeric segments are one left-to-right run, so they keep the locale's order in any direction\n// (spec/date-field.md, \"Bidirectional text\": structural, React Aria's fix)\nconst NUMERIC_STYLE = { unicodeBidi: \"embed\", direction: \"ltr\" } as const;\n\n/**\n * One segment: a `spinbutton` the user types into or steps (the APG), or a literal hidden from\n * assistive technology (spec/date-field.md, \"State attributes and ARIA\").\n */\nexport function DateFieldSegment({\n segment,\n children,\n ...props\n}: DateFieldSegmentProps) {\n const context = useRequiredContext(DateFieldContext, \"DateField.Segment\");\n const id = useId();\n const element = useRef<HTMLElement | null>(null);\n const latest = useRef({ context, segment });\n latest.current = { context, segment };\n const { disabled, readOnly, required, invalid, field, labelId } = context;\n const editable = segment.editable;\n const writable = editable && !disabled && !readOnly;\n\n // every edit the browser would make is cancelled: the field writes the text from its state\n // (a native listener: React's `onBeforeInput` is not the native event)\n useEffect(() => {\n const node = element.current;\n if (node === null || !writable) {\n return undefined;\n }\n const onBeforeInput = (event: InputEvent) => {\n event.preventDefault();\n const { context: current, segment: shown } = latest.current;\n if (event.inputType === \"deleteContentBackward\") {\n current.onSegmentKey(\n shown,\n new KeyboardEvent(\"keydown\", { key: \"Backspace\" }),\n node,\n );\n return;\n }\n if (event.data !== null && event.data !== \"\") {\n current.onSegmentText(shown, event.data, event, node);\n }\n };\n node.addEventListener(\"beforeinput\", onBeforeInput);\n return () => node.removeEventListener(\"beforeinput\", onBeforeInput);\n }, [writable]);\n\n const state: DateFieldSegmentState = {\n disabled,\n readOnly,\n required,\n invalid,\n type: segment.type,\n placeholder: segment.placeholder,\n };\n const content = children ?? segment.text;\n const textual = segment.type === \"dayPeriod\" || segment.type === \"era\";\n if (!editable) {\n return renderElement(\"span\", { ...props, children: content }, state, {\n \"aria-hidden\": segment.type === \"literal\" ? \"true\" : undefined,\n \"data-primitives-part\": `${context.component}-segment`,\n \"data-type\": segment.type,\n ...context.attributes,\n });\n }\n return renderElement(\n \"span\",\n { ...props, children: content },\n state,\n {\n id,\n role: \"spinbutton\",\n tabIndex: disabled ? undefined : 0,\n \"aria-label\": segment.label ?? undefined,\n \"aria-labelledby\":\n labelId === undefined ? undefined : `${labelId} ${id}`,\n \"aria-valuenow\": segment.value ?? undefined,\n \"aria-valuetext\": segment.valueText ?? undefined,\n \"aria-valuemin\": segment.min ?? undefined,\n \"aria-valuemax\": segment.max ?? undefined,\n \"aria-invalid\": invalid ? \"true\" : undefined,\n \"aria-required\": required ? \"true\" : undefined,\n \"aria-readonly\": readOnly ? \"true\" : undefined,\n \"aria-disabled\": disabled ? \"true\" : undefined,\n contentEditable: writable ? true : undefined,\n suppressContentEditableWarning: true,\n // a day period and an era take letters\n inputMode: textual ? \"text\" : \"numeric\",\n spellCheck: \"false\",\n autoCorrect: \"off\",\n autoCapitalize: \"off\",\n enterKeyHint: \"next\",\n style: textual ? undefined : NUMERIC_STYLE,\n \"data-primitives-part\": `${context.component}-segment`,\n \"data-type\": segment.type,\n \"data-placeholder\": segment.placeholder ? \"\" : undefined,\n ...context.attributes,\n onKeyDown: (event: ReactKeyboardEvent<HTMLElement>) => {\n const { context: current, segment: shown } = latest.current;\n if (\n current.onSegmentKey(\n shown,\n event.nativeEvent,\n event.currentTarget,\n )\n ) {\n event.preventDefault();\n }\n },\n onFocus: () => field.onFocus(),\n onBlur: (event: FocusEvent<HTMLElement>) => {\n const { context: current, segment: shown } = latest.current;\n current.onSegmentBlur(\n shown,\n event.nativeEvent,\n event.currentTarget,\n );\n },\n },\n (node: HTMLElement | null) => {\n element.current = node;\n },\n );\n}\n","import type { DateSegment } from \"@fragiola/primitives/segments\";\nimport type { ReactNode } from \"react\";\nimport { useRequiredContext } from \"../../hooks/use-required-context.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { DateFieldContext, type DateFieldState } from \"./date-field-context.ts\";\nimport { DateFieldSegment } from \"./date-field-segment.tsx\";\n\nexport interface DateFieldInputProps\n extends Omit<PartProps<DateFieldState>, \"children\"> {\n /** A function of each segment; default: every segment with its own text. */\n children?: (segment: DateSegment) => ReactNode;\n}\n\n/** The `group` of the segments (spec/date-field.md, \"Anatomy\"). */\nexport function DateFieldInput({ children, ...props }: DateFieldInputProps) {\n const context = useRequiredContext(DateFieldContext, \"DateField.Input\");\n const { field } = context;\n const state: DateFieldState = {\n disabled: context.disabled,\n readOnly: context.readOnly,\n required: context.required,\n invalid: context.invalid,\n };\n return renderElement(\n \"div\",\n {\n ...props,\n children: context.segments.map((segment) =>\n children ? (\n children(segment)\n ) : (\n <DateFieldSegment key={segment.index} segment={segment} />\n ),\n ),\n },\n state,\n {\n role: \"group\",\n \"aria-labelledby\": field.aria[\"aria-labelledby\"],\n \"aria-describedby\": field.aria[\"aria-describedby\"],\n \"data-primitives-part\":\n context.inputPart ?? `${context.component}-input`,\n ...context.attributes,\n },\n context.setInputElement,\n );\n}\n","import { type PlainDate, toIsoDate } from \"@fragiola/primitives/date\";\nimport {\n isSegmentsComplete,\n type SegmentFormat,\n type SegmentGranularity,\n type SegmentKind,\n type SegmentValues,\n segmentsToDate,\n segmentsToDateTime,\n segmentsToTime,\n} from \"@fragiola/primitives/segments\";\nimport {\n compareDateTimes,\n compareTimes,\n type PlainDateTime,\n type PlainTime,\n toIsoDateTime,\n toIsoTime,\n} from \"@fragiola/primitives/time\";\nimport type { TimeZone, ZonedDateTime } from \"@fragiola/primitives/time-zone\";\n\n/** What a date or time field holds: a date, a date and time, or a time. */\nexport type FieldValue = PlainDate | PlainDateTime | PlainTime;\n\n/**\n * A value's ISO text at the field's granularity (spec/date-field.md, \"Forms\"); a zoned value's with\n * its offset and zone (spec/time-zones.md).\n */\nexport function isoOf(\n kind: SegmentKind,\n granularity: SegmentGranularity,\n value: FieldValue | null | undefined,\n timeZone?: TimeZone,\n): string {\n if (value == null) {\n return \"\";\n }\n const precision = granularity === \"second\" ? \"second\" : \"minute\";\n if (timeZone && \"offset\" in value) {\n return timeZone.toIso(value as ZonedDateTime, precision);\n }\n if (kind === \"time\") {\n return toIsoTime(value as PlainTime, precision);\n }\n if (granularity === \"day\") {\n return toIsoDate(value as PlainDate);\n }\n // a `PlainDate` bound counts as its midnight\n const {\n hour = 0,\n minute = 0,\n second = 0,\n millisecond = 0,\n } = value as Partial<PlainDateTime>;\n return toIsoDateTime(\n { ...(value as PlainDate), hour, minute, second, millisecond },\n precision,\n );\n}\n\n/** Orders two values of a field (a `PlainDate` counts as its midnight). */\nexport function compareValues(\n kind: SegmentKind,\n a: FieldValue,\n b: FieldValue,\n): number {\n return kind === \"time\"\n ? compareTimes(a as PlainTime, b as PlainTime)\n : compareDateTimes(a as PlainDate, b as PlainDate);\n}\n\n/** Whether a value is out of `min` / `max`, or (a date) unavailable (spec/date-field.md). */\nexport function isOutOfRange(\n kind: SegmentKind,\n value: FieldValue,\n min: FieldValue | undefined,\n max: FieldValue | undefined,\n isDateUnavailable: ((date: PlainDate) => boolean) | undefined,\n): boolean {\n return (\n (min !== undefined && compareValues(kind, value, min) < 0) ||\n (max !== undefined && compareValues(kind, value, max) > 0) ||\n (kind === \"date\" && isDateUnavailable?.(value as PlainDate) === true)\n );\n}\n\n/** The value complete segment values make (`null` while one is a placeholder). */\nexport function composeSegments(\n format: SegmentFormat,\n kind: SegmentKind,\n granularity: SegmentGranularity,\n values: SegmentValues,\n): FieldValue | null {\n return !isSegmentsComplete(format, values)\n ? null\n : kind === \"time\"\n ? segmentsToTime(values)\n : granularity === \"day\"\n ? segmentsToDate(values, format)\n : segmentsToDateTime(values, format);\n}\n\n/** A bound's ISO text for a hidden input's `min` / `max` (`undefined` with none). */\nexport function boundIso(\n kind: SegmentKind,\n granularity: SegmentGranularity,\n edge: FieldValue | undefined,\n): string | undefined {\n return edge === undefined ? undefined : isoOf(kind, granularity, edge);\n}\n","import { watchDocumentLanguage } from \"@fragiola/primitives/date\";\nimport { useSyncExternalStore } from \"react\";\n\n/** The locale of the first render with no `locale`: a server knows neither of the others. */\nconst FIRST_RENDER_LOCALE = \"en-US\";\nconst serverLocale = () => FIRST_RENDER_LOCALE;\n// a change of the document's `lang` renders again (followed after mount, as the calendars)\nconst subscribeLanguage = (change: () => void) =>\n watchDocumentLanguage(document, change);\n\nfunction documentLocale(): string {\n if (typeof document !== \"undefined\" && document.documentElement.lang) {\n return document.documentElement.lang;\n }\n return typeof navigator !== \"undefined\"\n ? navigator.language\n : FIRST_RENDER_LOCALE;\n}\n\n/**\n * A date or time field's locale (spec/date-field.md, \"API\"): its own, else the document's `lang`,\n * else the browser's language; a server render and its hydration use `en-US`, and React renders\n * again with the document's right after (the calendars' rule, spec/calendar.md \"API\"). The\n * calendars keep their own copy, so their entries are unchanged.\n */\nexport function useDocumentLocale(locale: string | undefined): string {\n const fallback = useSyncExternalStore(\n subscribeLanguage,\n documentLocale,\n serverLocale,\n );\n return locale ?? fallback;\n}\n","import {\n type DateSegment,\n dateSegments,\n type EditableSegmentType,\n isSegmentsComplete,\n type SegmentEdit,\n type SegmentFormat,\n type SegmentGranularity,\n type SegmentKind,\n type SegmentValues,\n segmentKeyDown,\n segmentTarget,\n segmentValuesOf,\n typeSegment,\n} from \"@fragiola/primitives/segments\";\nimport type { PlainDateTime } from \"@fragiola/primitives/time\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\nimport type { ChangeReason } from \"../../utils/change-details.ts\";\nimport { composeSegments, type FieldValue } from \"./field-value.ts\";\n\n/** What an edit did: typed a character, erased one (Backspace, Delete), or stepped a segment. */\nexport type SegmentEditKind = \"type\" | \"erase\" | \"step\";\n\n/** The change reason of an edit (spec/date-field.md, \"API\"): `null` after an erase clears. */\nexport function editReason(\n edit: SegmentEditKind,\n value: unknown,\n): ChangeReason {\n return edit === \"step\"\n ? \"keyboard\"\n : edit === \"erase\" && value === null\n ? \"input-clear\"\n : \"input-change\";\n}\n\nexport interface SegmentGroupOptions {\n format: SegmentFormat;\n kind: SegmentKind;\n granularity: SegmentGranularity;\n /** The segment values a placeholder's first step starts from (the `placeholderValue`'s). */\n seed: SegmentValues;\n /** The value the segments start from. */\n initial: Partial<PlainDateTime> | null;\n disabled: boolean;\n readOnly: boolean;\n /**\n * The groups the focus moves among, in order (a range's two ends: spec/date-range-field.md);\n * default: this group alone.\n */\n groups?: () => readonly Element[];\n /** An edit changed the segments: the value they make now (`null` while incomplete). */\n onEdit: (\n composed: FieldValue | null,\n edit: SegmentEditKind,\n event: Event,\n ) => void;\n /** The focus left every group (the field's blur). */\n onBlur: () => void;\n}\n\n/**\n * One group of segments (spec/date-field.md): the values the user set, the digits being typed,\n * the segments to render and what their keys and text do. A DateField has one; a range field and\n * a range picker's typed input two, one per end (spec/date-range-field.md). The value and its\n * reports are the root's: the group says what its segments make after each edit.\n */\nexport function useSegmentGroup(options: SegmentGroupOptions) {\n const { format } = options;\n const [values, setValues] = useState<SegmentValues>(() =>\n segmentValuesOf(format, options.initial),\n );\n const [edit, setEdit] = useState<SegmentEdit | null>(null);\n const [element, setElement] = useState<HTMLElement | null>(null);\n // the state as of the last change, so a quick next key never reads a stale render\n const current = useRef({ values, edit });\n const latest = useRef(options);\n latest.current = options;\n\n const actions = useMemo(() => {\n /** Applies new segment values, and reports what they make. */\n const apply = (\n next: SegmentValues,\n nextEdit: SegmentEdit | null,\n kind: SegmentEditKind,\n event: Event,\n ) => {\n const state = latest.current;\n current.current = { values: next, edit: nextEdit };\n setValues(next);\n setEdit(nextEdit);\n state.onEdit(\n composeSegments(\n state.format,\n state.kind,\n state.granularity,\n next,\n ),\n kind,\n event,\n );\n };\n const editable = () => {\n const state = latest.current;\n return !state.disabled && !state.readOnly;\n };\n const move = (\n from: HTMLElement,\n to: Parameters<typeof segmentTarget>[1],\n ) => segmentTarget(from, to, latest.current.groups?.())?.focus();\n return {\n /** A key on a segment: whether the group took it (its default is then prevented). */\n onSegmentKey: (\n segment: DateSegment,\n event: KeyboardEvent,\n target: HTMLElement,\n ) => {\n const state = latest.current;\n if (\n !segment.editable ||\n state.disabled ||\n event.altKey ||\n event.ctrlKey ||\n event.metaKey\n ) {\n return false;\n }\n const { values: before, edit: typing } = current.current;\n const result = segmentKeyDown(\n state.format,\n before,\n segment.type as EditableSegmentType,\n event.key,\n typing,\n { seed: state.seed, readOnly: !editable() },\n );\n if (result === null) {\n return false;\n }\n if (result.kind !== \"move\") {\n apply(\n result.values,\n result.edit,\n result.kind === \"step\" ? \"step\" : \"erase\",\n event,\n );\n }\n if (result.move !== null) {\n move(target, result.move);\n }\n return true;\n },\n /** Text typed into a segment (`beforeinput`'s data). */\n onSegmentText: (\n segment: DateSegment,\n text: string,\n event: Event,\n target: HTMLElement,\n ) => {\n if (!segment.editable || !editable()) {\n return;\n }\n const state = latest.current;\n let { values: next, edit: typing } = current.current;\n let advance = false;\n for (const character of text) {\n const result = typeSegment(\n state.format,\n next,\n segment.type as EditableSegmentType,\n character,\n typing,\n state.seed,\n );\n if (result === null) {\n continue;\n }\n next = result.values;\n typing = result.edit;\n advance = result.advance;\n }\n if (\n next === current.current.values &&\n typing === current.current.edit\n ) {\n return;\n }\n apply(next, typing, \"type\", event);\n if (advance) {\n move(target, \"next\");\n }\n },\n /** A segment lost the focus: its typed digits are dropped; leaving the groups blurs. */\n onSegmentBlur: (\n segment: DateSegment,\n event: FocusEvent,\n target: HTMLElement,\n ) => {\n const { edit: typing } = current.current;\n if (typing !== null && typing.type === segment.type) {\n current.current = { ...current.current, edit: null };\n setEdit(null);\n }\n // the segment itself: a native event's `currentTarget` is React's root\n const own = target.closest('[role=\"group\"]');\n const groups =\n latest.current.groups?.() ?? (own === null ? [] : [own]);\n const to = event.relatedTarget as Node | null;\n if (\n to === null ||\n !groups.some((group) => group.contains(to))\n ) {\n latest.current.onBlur();\n }\n },\n /** Replaces the segments with a value's (`null`: every one a placeholder). */\n replace: (value: Partial<PlainDateTime> | null) => {\n const next = segmentValuesOf(latest.current.format, value);\n current.current = { values: next, edit: null };\n setValues(next);\n setEdit(null);\n },\n };\n }, []);\n\n const firstSegment = useCallback(\n () =>\n element?.querySelector<HTMLElement>(\n '[role=\"spinbutton\"][tabindex]',\n ) ?? null,\n [element],\n );\n const segments = useMemo(\n () => dateSegments(format, values, edit),\n [format, values, edit],\n );\n return {\n segments,\n /** The segment values this render shows. */\n rendered: values,\n /** Whether every segment is set (the state as of the last change). */\n complete: () => isSegmentsComplete(format, current.current.values),\n /** The segment values as of the last change. */\n values: () => current.current.values,\n element,\n setElement,\n /** The first editable segment: the focus target, where a label press and a failed validation go. */\n firstSegment,\n ...actions,\n };\n}\n\nexport type SegmentGroup = ReturnType<typeof useSegmentGroup>;\n"],"mappings":";;;;;;;;AAgEA,MAAa,mBAAmB,cAC5B,IACJ;;AC3CA,MAAM,gBAAgB;CAAE,aAAa;CAAS,WAAW;AAAM;;;;;AAM/D,SAAgB,iBAAiB,EAC7B,SACA,UACA,GAAG,SACmB;CACtB,MAAM,UAAU,mBAAmB,kBAAkB,mBAAmB;CACxE,MAAM,KAAK,MAAM;CACjB,MAAM,UAAU,OAA2B,IAAI;CAC/C,MAAM,SAAS,OAAO;EAAE;EAAS;CAAQ,CAAC;CAC1C,OAAO,UAAU;EAAE;EAAS;CAAQ;CACpC,MAAM,EAAE,UAAU,UAAU,UAAU,SAAS,OAAO,YAAY;CAClE,MAAM,WAAW,QAAQ;CACzB,MAAM,WAAW,YAAY,CAAC,YAAY,CAAC;CAI3C,gBAAgB;EACZ,MAAM,OAAO,QAAQ;EACrB,IAAI,SAAS,QAAQ,CAAC,UAClB;EAEJ,MAAM,iBAAiB,UAAsB;GACzC,MAAM,eAAe;GACrB,MAAM,EAAE,SAAS,SAAS,SAAS,UAAU,OAAO;GACpD,IAAI,MAAM,cAAc,yBAAyB;IAC7C,QAAQ,aACJ,OACA,IAAI,cAAc,WAAW,EAAE,KAAK,YAAY,CAAC,GACjD,IACJ;IACA;GACJ;GACA,IAAI,MAAM,SAAS,QAAQ,MAAM,SAAS,IACtC,QAAQ,cAAc,OAAO,MA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AI,CAGd;;EAEP,UAAU;;EAEV,gBAAgB,mBAAmB,QAAQ,QAAQ,QAAQ,MAAM;;EAEjE,cAAc,QAAQ,QAAQ;EAC9B;EACA;;EAEA;EACA,GAAG;CACP;AACJ"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { n as mergeRefs } from "./render-element-DXbUbfgN.js";
|
|
2
|
+
import { cloneElement, isValidElement, useEffect, useLayoutEffect, useReducer, useRef, useState } from "react";
|
|
3
|
+
import { createVirtualizer } from "@fragiola/primitives/virtual";
|
|
4
|
+
// src/hooks/use-virtual-rows.ts
|
|
5
|
+
/**
|
|
6
|
+
* The rows a combobox's keys reach from the DOM (Combobox, Autocomplete): the ends, the
|
|
7
|
+
* highlighted row and its neighbours, and the selected row (the list opens on it).
|
|
8
|
+
*/
|
|
9
|
+
function reachableRows(count, highlighted, selected) {
|
|
10
|
+
const rows = [0, count - 1];
|
|
11
|
+
if (highlighted !== void 0) rows.push(highlighted - 1, highlighted, highlighted + 1);
|
|
12
|
+
if (selected >= 0) rows.push(selected);
|
|
13
|
+
return rows;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The row's structural style merged into the Item's own (an object or a function): it never
|
|
17
|
+
* shrinks (a flex column that scrolls would squeeze its rows), takes no part in the browser's
|
|
18
|
+
* scroll anchoring (the virtualizer anchors the view itself), and its room as margins.
|
|
19
|
+
*/
|
|
20
|
+
function withRoom(style, room) {
|
|
21
|
+
if (typeof style === "function") return (state) => ({
|
|
22
|
+
...style(state),
|
|
23
|
+
...room
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
...style,
|
|
27
|
+
...room
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The rows of a virtual list (spec/virtual-lists.md): the toolkit's virtualizer over the items,
|
|
32
|
+
* attached to the list's scroll container, each rendered row the consumer's Item with
|
|
33
|
+
* `aria-setsize`, `aria-posinset`, `data-index`, its room as margins, `flex-shrink: 0`, `overflow-anchor: none` and, unless `measure` is
|
|
34
|
+
* `false`, measured. Calls `onLoadMore` when the last row comes into view.
|
|
35
|
+
*/
|
|
36
|
+
function useVirtualRows({ items, render, pinned, list, itemSize = 36, measure = true, overscan = 4, loading = false, onLoadMore }) {
|
|
37
|
+
const [, rerender] = useReducer((count) => count + 1, 0);
|
|
38
|
+
const [virtualizer] = useState(() => createVirtualizer({
|
|
39
|
+
count: items.length,
|
|
40
|
+
onChange: rerender
|
|
41
|
+
}));
|
|
42
|
+
virtualizer.update({
|
|
43
|
+
count: items.length,
|
|
44
|
+
estimateSize: itemSize,
|
|
45
|
+
overscan,
|
|
46
|
+
pinned
|
|
47
|
+
});
|
|
48
|
+
const range = virtualizer.range();
|
|
49
|
+
const elements = useRef(/* @__PURE__ */ new Map()).current;
|
|
50
|
+
useLayoutEffect(() => list === null ? void 0 : virtualizer.attach(list), [list, virtualizer]);
|
|
51
|
+
const count = items.length;
|
|
52
|
+
const end = range.visibleEnd;
|
|
53
|
+
const loadMore = useRef(onLoadMore);
|
|
54
|
+
loadMore.current = onLoadMore;
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (!loading && count > 0 && end >= count - 1) loadMore.current?.();
|
|
57
|
+
}, [
|
|
58
|
+
loading,
|
|
59
|
+
count,
|
|
60
|
+
end
|
|
61
|
+
]);
|
|
62
|
+
const last = range.rows.length - 1;
|
|
63
|
+
return {
|
|
64
|
+
rows: range.rows.map((row, position) => {
|
|
65
|
+
const element = render(items[row.index], row.index);
|
|
66
|
+
if (!isValidElement(element)) return element;
|
|
67
|
+
const index = row.index;
|
|
68
|
+
const own = element.props;
|
|
69
|
+
const ref = (node) => {
|
|
70
|
+
if (node === null) return;
|
|
71
|
+
elements.set(index, node);
|
|
72
|
+
const stop = measure ? virtualizer.measure(index, node) : void 0;
|
|
73
|
+
return () => {
|
|
74
|
+
if (elements.get(index) === node) elements.delete(index);
|
|
75
|
+
stop?.();
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
return cloneElement(element, {
|
|
79
|
+
key: element.key ?? index,
|
|
80
|
+
ref: mergeRefs(own.ref, ref),
|
|
81
|
+
style: withRoom(own.style, {
|
|
82
|
+
flexShrink: 0,
|
|
83
|
+
overflowAnchor: "none",
|
|
84
|
+
marginBlockStart: row.spaceBefore > 0 ? row.spaceBefore : void 0,
|
|
85
|
+
marginBlockEnd: position === last && range.spaceAfter > 0 ? range.spaceAfter : void 0
|
|
86
|
+
}),
|
|
87
|
+
"aria-setsize": count,
|
|
88
|
+
"aria-posinset": index + 1,
|
|
89
|
+
"data-index": index
|
|
90
|
+
});
|
|
91
|
+
}),
|
|
92
|
+
range,
|
|
93
|
+
virtualizer,
|
|
94
|
+
elements
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export { useVirtualRows as n, reachableRows as t };
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=use-virtual-rows-B5N0qgmT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-virtual-rows-B5N0qgmT.js","names":[],"sources":["../src/hooks/use-virtual-rows.ts"],"sourcesContent":["import {\n createVirtualizer,\n type Virtualizer,\n type VirtualRange,\n} from \"@fragiola/primitives/virtual\";\nimport {\n type CSSProperties,\n cloneElement,\n isValidElement,\n type ReactNode,\n type Ref,\n useEffect,\n useLayoutEffect,\n useReducer,\n useRef,\n useState,\n} from \"react\";\nimport { mergeRefs } from \"../utils/merge-refs.ts\";\n\n/** The props every virtual part takes (spec/virtual-lists.md, \"API\"). */\nexport interface VirtualListProps {\n /** A row's size in pixels before it is measured, or every row's with `measure={false}`. */\n itemSize?: number | ((index: number) => number);\n /** Measure the rendered rows (default `true`); `false`: fixed sizes. */\n measure?: boolean;\n /** The rows rendered beyond each end of the view (default 4). */\n overscan?: number;\n /** The list is loading (`data-loading`, `aria-busy`). */\n loading?: boolean;\n /** The last row came into view while not `loading`: load the next page. */\n onLoadMore?: () => void;\n}\n\nexport interface VirtualRowsOptions<Item> extends VirtualListProps {\n items: readonly Item[];\n /** The consumer's render function: an Item element for an item. */\n render: (item: Item, index: number) => ReactNode;\n /** Rows always rendered (the focused, highlighted or selected one; the ends). */\n pinned: readonly number[];\n /** The list element: its scroll container is watched once it mounts. */\n list: HTMLElement | null;\n}\n\nexport interface VirtualRows {\n /** The rendered rows: the consumer's Items, with their place in the set and their room. */\n rows: ReactNode[];\n range: VirtualRange;\n virtualizer: Virtualizer;\n /** The rendered rows' elements, by index. */\n elements: ReadonlyMap<number, HTMLElement>;\n}\n\n/**\n * The rows a combobox's keys reach from the DOM (Combobox, Autocomplete): the ends, the\n * highlighted row and its neighbours, and the selected row (the list opens on it).\n */\nexport function reachableRows(\n count: number,\n highlighted: number | undefined,\n selected: number,\n): number[] {\n const rows = [0, count - 1];\n if (highlighted !== undefined) {\n rows.push(highlighted - 1, highlighted, highlighted + 1);\n }\n if (selected >= 0) {\n rows.push(selected);\n }\n return rows;\n}\n\ntype StyleProp =\n | CSSProperties\n | ((state: never) => CSSProperties | undefined)\n | undefined;\n\n/**\n * The row's structural style merged into the Item's own (an object or a function): it never\n * shrinks (a flex column that scrolls would squeeze its rows), takes no part in the browser's\n * scroll anchoring (the virtualizer anchors the view itself), and its room as margins.\n */\nfunction withRoom(style: StyleProp, room: CSSProperties): StyleProp {\n if (typeof style === \"function\") {\n return (state: never) => ({ ...style(state), ...room });\n }\n return { ...style, ...room };\n}\n\n/**\n * The rows of a virtual list (spec/virtual-lists.md): the toolkit's virtualizer over the items,\n * attached to the list's scroll container, each rendered row the consumer's Item with\n * `aria-setsize`, `aria-posinset`, `data-index`, its room as margins, `flex-shrink: 0`, `overflow-anchor: none` and, unless `measure` is\n * `false`, measured. Calls `onLoadMore` when the last row comes into view.\n */\nexport function useVirtualRows<Item>({\n items,\n render,\n pinned,\n list,\n itemSize = 36,\n measure = true,\n overscan = 4,\n loading = false,\n onLoadMore,\n}: VirtualRowsOptions<Item>): VirtualRows {\n const [, rerender] = useReducer((count: number) => count + 1, 0);\n const [virtualizer] = useState(() =>\n createVirtualizer({ count: items.length, onChange: rerender }),\n );\n virtualizer.update({\n count: items.length,\n estimateSize: itemSize,\n overscan,\n pinned,\n });\n const range = virtualizer.range();\n const elements = useRef(new Map<number, HTMLElement>()).current;\n\n useLayoutEffect(\n () => (list === null ? undefined : virtualizer.attach(list)),\n [list, virtualizer],\n );\n\n const count = items.length;\n const end = range.visibleEnd;\n const loadMore = useRef(onLoadMore);\n loadMore.current = onLoadMore;\n useEffect(() => {\n if (!loading && count > 0 && end >= count - 1) {\n loadMore.current?.();\n }\n }, [loading, count, end]);\n\n const last = range.rows.length - 1;\n const rows = range.rows.map((row, position) => {\n const element = render(items[row.index] as Item, row.index);\n if (!isValidElement<Record<string, unknown>>(element)) {\n return element;\n }\n const index = row.index;\n const own = element.props;\n const ref = (node: HTMLElement | null) => {\n if (node === null) {\n return undefined;\n }\n elements.set(index, node);\n const stop = measure ? virtualizer.measure(index, node) : undefined;\n return () => {\n if (elements.get(index) === node) {\n elements.delete(index);\n }\n stop?.();\n };\n };\n return cloneElement(element, {\n key: element.key ?? index,\n ref: mergeRefs(own.ref as Ref<HTMLElement> | undefined, ref),\n style: withRoom(own.style as StyleProp, {\n flexShrink: 0,\n overflowAnchor: \"none\",\n marginBlockStart:\n row.spaceBefore > 0 ? row.spaceBefore : undefined,\n marginBlockEnd:\n position === last && range.spaceAfter > 0\n ? range.spaceAfter\n : undefined,\n }),\n \"aria-setsize\": count,\n \"aria-posinset\": index + 1,\n \"data-index\": index,\n });\n });\n return { rows, range, virtualizer, elements };\n}\n"],"mappings":";;;;;;;;AAwDA,SAAgB,cACZ,OACA,aACA,UACQ;CACR,MAAM,OAAO,CAAC,GAAG,QAAQ,CAAC;CAC1B,IAAI,gBAAgB,KAAA,GAChB,KAAK,KAAK,cAAc,GAAG,aAAa,cAAc,CAAC;CAE3D,IAAI,YAAY,GACZ,KAAK,KAAK,QAAQ;CAEtB,OAAO;AACX;;;;;;AAYA,SAAS,SAAS,OAAkB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AI,KAAA;IAC1D,aAAa;KACT,IAAI,SAAS,IAAI,KAAK,MAAM,MACxB,SAAS,OAAO,KAAK;KAEzB,OAAO;IACX;GACJ;GACA,OAAO,aAAa,SAAS;IACzB,KAAK,QAAQ,OAAO;IACpB,KAAK,UAAU,IAAI,KAAqC,GAAG;IAC3D,OAAO,SAAS,IAAI,OAAoB;KACpC,YAAY;KACZ,gBAAgB;KAChB,kBACI,IAAI,cAAc,IAAI,IAAI,cAAc,KAAA;KAC5C,gBACI,aAAa,QAAQ,MAAM,aAAa,IAClC,MAAM,aACN,KAAA;IACd,CAAC;IACD,gBAAgB;IAChB,iBAAiB,QAAQ;IACzB,cAAc;GAClB,CAAC;EACL,CACY;EAAG;EAAO;EAAa;CAAS;AAChD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
import "@fragiola/primitives/virtual";
|
|
3
|
+
/** The props every virtual part takes (spec/virtual-lists.md, "API"). */
|
|
4
|
+
interface VirtualListProps {
|
|
5
|
+
/** A row's size in pixels before it is measured, or every row's with `measure={false}`. */
|
|
6
|
+
itemSize?: number | ((index: number) => number);
|
|
7
|
+
/** Measure the rendered rows (default `true`); `false`: fixed sizes. */
|
|
8
|
+
measure?: boolean;
|
|
9
|
+
/** The rows rendered beyond each end of the view (default 4). */
|
|
10
|
+
overscan?: number;
|
|
11
|
+
/** The list is loading (`data-loading`, `aria-busy`). */
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
/** The last row came into view while not `loading`: load the next page. */
|
|
14
|
+
onLoadMore?: () => void;
|
|
15
|
+
}
|
|
16
|
+
export { VirtualListProps as t };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { a as MonthCalendarHeading, c as MonthCalendarGrid, i as MonthCalendarNextButton, l as MonthCalendarCell, n as MonthCalendarRootBase, o as MonthCalendarGridBody, r as MonthCalendarPrevButton, s as MonthCalendarRow } from "./parts-BHkvkEgf.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
// src/components/year-calendar/year-calendar-root.tsx
|
|
4
|
+
/** One year, in a grid of a page of 12 years (spec/month-calendar.md), on the MonthCalendar's state and parts. */
|
|
5
|
+
function YearCalendarRoot(props) {
|
|
6
|
+
return /* @__PURE__ */ jsx(MonthCalendarRootBase, {
|
|
7
|
+
component: "year-calendar",
|
|
8
|
+
kind: "year",
|
|
9
|
+
mode: "single",
|
|
10
|
+
...props,
|
|
11
|
+
onValueChange: props.onValueChange
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
// src/components/year-calendar/parts.ts
|
|
15
|
+
/** spec/month-calendar.md: one year, in a grid of a page of 12 years, with the MonthCalendar's parts (named `year-calendar-*`) */
|
|
16
|
+
const YearCalendar = {
|
|
17
|
+
Root: YearCalendarRoot,
|
|
18
|
+
Heading: MonthCalendarHeading,
|
|
19
|
+
PrevButton: MonthCalendarPrevButton,
|
|
20
|
+
NextButton: MonthCalendarNextButton,
|
|
21
|
+
Grid: MonthCalendarGrid,
|
|
22
|
+
GridBody: MonthCalendarGridBody,
|
|
23
|
+
Row: MonthCalendarRow,
|
|
24
|
+
Cell: MonthCalendarCell
|
|
25
|
+
};
|
|
26
|
+
export { YearCalendar as t };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=year-calendar-CroBMFMN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"year-calendar-CroBMFMN.js","names":[],"sources":["../src/components/year-calendar/year-calendar-root.tsx","../src/components/year-calendar/parts.ts"],"sourcesContent":["import type { PlainYear } from \"@fragiola/primitives/month-year\";\nimport type { ChangeDetails } from \"../../utils/change-details.ts\";\nimport {\n MonthCalendarRootBase,\n type MonthCalendarRootSharedProps,\n} from \"../month-calendar/month-calendar-root-base.tsx\";\nimport type { MonthCalendarValue } from \"../month-calendar/month-calendar-value.ts\";\n\nexport interface YearCalendarRootProps extends MonthCalendarRootSharedProps {\n value?: PlainYear | null;\n defaultValue?: PlainYear | null;\n onValueChange?: (value: PlainYear | null, details: ChangeDetails) => void;\n /** Years before it are disabled. */\n min?: PlainYear | null;\n /** Years after it are disabled. */\n max?: PlainYear | null;\n /** Unavailable years can be focused but not chosen. */\n isUnavailable?: (year: PlainYear) => boolean;\n}\n\n/** One year, in a grid of a page of 12 years (spec/month-calendar.md), on the MonthCalendar's state and parts. */\nexport function YearCalendarRoot(props: YearCalendarRootProps) {\n return (\n <MonthCalendarRootBase\n component=\"year-calendar\"\n kind=\"year\"\n mode=\"single\"\n {...props}\n onValueChange={\n props.onValueChange as\n | ((\n value: MonthCalendarValue,\n details: ChangeDetails,\n ) => void)\n | undefined\n }\n />\n );\n}\n","import { MonthCalendarCell } from \"../month-calendar/month-calendar-cell.tsx\";\nimport { MonthCalendarGrid } from \"../month-calendar/month-calendar-grid.tsx\";\nimport { MonthCalendarGridBody } from \"../month-calendar/month-calendar-grid-body.tsx\";\nimport { MonthCalendarHeading } from \"../month-calendar/month-calendar-heading.tsx\";\nimport { MonthCalendarNextButton } from \"../month-calendar/month-calendar-next-button.tsx\";\nimport { MonthCalendarPrevButton } from \"../month-calendar/month-calendar-prev-button.tsx\";\nimport { MonthCalendarRow } from \"../month-calendar/month-calendar-row.tsx\";\nimport { YearCalendarRoot } from \"./year-calendar-root.tsx\";\n\n/** spec/month-calendar.md: one year, in a grid of a page of 12 years, with the MonthCalendar's parts (named `year-calendar-*`) */\nexport const YearCalendar = {\n Root: YearCalendarRoot,\n Heading: MonthCalendarHeading,\n PrevButton: MonthCalendarPrevButton,\n NextButton: MonthCalendarNextButton,\n Grid: MonthCalendarGrid,\n GridBody: MonthCalendarGridBody,\n Row: MonthCalendarRow,\n Cell: MonthCalendarCell,\n};\n"],"mappings":";;;;AAqBA,SAAgB,iBAAiB,OAA8B;CAC3D,OACI,oBAAC,uBAAD;EACI,WAAU;EACV,MAAK;EACL,MAAK;EACL,GAAI;EACJ,eACI,MAAM;CAOb,CAAA;AAET;;;AC5BA,MAAa,eAAe;CACxB,MAAM;CACN,SAAS;CACT,YAAY;CACZ,YAAY;CACZ,MAAM;CACN,UAAU;CACV,KAAK;CACL,MAAM;AACV"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { 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 MonthCalendarItem } from "./month-calendar-value-CNJcsqcv.js";
|
|
4
|
+
import { a as MonthCalendarRootSharedProps, b as MonthCalendarCellProps, c as MonthCalendarPrevButtonProps, d as MonthCalendarPageButtonState, g as MonthCalendarGridBodyProps, m as MonthCalendarHeadingState, o as MonthCalendarRootState, p as MonthCalendarHeadingProps, r as MonthCalendarRowProps, t as MonthCalendar, u as MonthCalendarNextButtonProps, v as MonthCalendarGridProps, x as MonthCalendarCellState } from "./parts-BL0sXepP.js";
|
|
5
|
+
import { a as YearCalendar, i as YearRange, n as PlainYearMonth, o as YearCalendarRootProps, r as YearMonthRange, t as PlainYear } from "./index-PpCPWRbt.js";
|
|
6
|
+
export { type ChangeDetails, type ChangeReason, MonthCalendar, type MonthCalendarCellProps, type MonthCalendarCellState, type MonthCalendarGridBodyProps, type MonthCalendarGridProps, type MonthCalendarHeadingProps, type MonthCalendarHeadingState, type MonthCalendarItem, type MonthCalendarNextButtonProps, type MonthCalendarPageButtonState, type MonthCalendarPrevButtonProps, type MonthCalendarRootSharedProps, type MonthCalendarRootState, type MonthCalendarRowProps, type PlainYear, type PlainYearMonth, type RenderProp, YearCalendar, type YearCalendarRootProps, type YearMonthRange, type YearRange };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { a as DatePickerPopup, i as DatePickerPortal, r as DatePickerPositioner, t as DatePickerTrigger } from "./date-picker-trigger-BKPvZbRg.js";
|
|
2
|
+
import { t as MonthPickerRootBase } from "./month-picker-root-base-CI7jcllI.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/year-picker/year-picker-root.tsx
|
|
5
|
+
/** A trigger and a popup holding a bound `YearCalendar.Root`: one year (spec/month-calendar.md). */
|
|
6
|
+
function YearPickerRoot(props) {
|
|
7
|
+
return /* @__PURE__ */ jsx(MonthPickerRootBase, {
|
|
8
|
+
component: "year-picker",
|
|
9
|
+
kind: "year",
|
|
10
|
+
mode: "single",
|
|
11
|
+
...props,
|
|
12
|
+
onValueChange: props.onValueChange
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
// src/components/year-picker/parts.ts
|
|
16
|
+
/** spec/month-calendar.md: one year, with the DatePicker's parts (named `year-picker-*`) */
|
|
17
|
+
const YearPicker = {
|
|
18
|
+
Root: YearPickerRoot,
|
|
19
|
+
Trigger: DatePickerTrigger,
|
|
20
|
+
Portal: DatePickerPortal,
|
|
21
|
+
Positioner: DatePickerPositioner,
|
|
22
|
+
Popup: DatePickerPopup
|
|
23
|
+
};
|
|
24
|
+
export { YearPicker as t };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=year-picker-DJVxXtPh.js.map
|