@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.
- 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,286 @@
|
|
|
1
|
+
import { t as useElement } from "./use-element-tpFZ-kuA.js";
|
|
2
|
+
import { t as useRequiredContext } from "./use-required-context-Cjd_CYnv.js";
|
|
3
|
+
import { t as renderElement } from "./render-element-DXbUbfgN.js";
|
|
4
|
+
import { t as stateAttributes } from "./state-attributes-DhboDeMS.js";
|
|
5
|
+
import { t as DirectionContext } from "./direction-context-CiRdNJmu.js";
|
|
6
|
+
import { t as useColorPickerBinding } from "./use-color-picker-binding-D0R-FsfF.js";
|
|
7
|
+
import { t as useControllableState } from "./use-controllable-state-Dm8eNkgP.js";
|
|
8
|
+
import { t as useFieldControl } from "./use-field-control-CL_nOU7T.js";
|
|
9
|
+
import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { getDirection } from "@fragiola/primitives/direction";
|
|
12
|
+
import { bridgeForm } from "@fragiola/primitives/form";
|
|
13
|
+
import { formatColor, parseColor } from "@fragiola/primitives/color";
|
|
14
|
+
import { createListModel, listKeyTarget, rowTarget } from "@fragiola/primitives/selection";
|
|
15
|
+
// src/components/color-swatch-picker/color-swatch-picker-context.ts
|
|
16
|
+
const ColorSwatchPickerContext = createContext(null);
|
|
17
|
+
// src/components/color-swatch-picker/color-swatch-picker-item.tsx
|
|
18
|
+
const BLACK = {
|
|
19
|
+
space: "rgb",
|
|
20
|
+
red: 0,
|
|
21
|
+
green: 0,
|
|
22
|
+
blue: 0,
|
|
23
|
+
alpha: 1
|
|
24
|
+
};
|
|
25
|
+
/** An `option` of the palette, focusable with a roving `tabindex` (spec/color-swatch-picker.md). */
|
|
26
|
+
function ColorSwatchPickerItem({ value, disabled: disabledProp = false, ...props }) {
|
|
27
|
+
const context = useRequiredContext(ColorSwatchPickerContext, "ColorSwatchPicker.Item");
|
|
28
|
+
const color = useMemo(() => parseColor(value) ?? BLACK, [value]);
|
|
29
|
+
const key = formatColor(color, "hexa");
|
|
30
|
+
const [element, ref] = useElement();
|
|
31
|
+
const id = useId();
|
|
32
|
+
const { register } = context;
|
|
33
|
+
useLayoutEffect(() => element === null ? void 0 : register({
|
|
34
|
+
element,
|
|
35
|
+
key,
|
|
36
|
+
color,
|
|
37
|
+
disabled: disabledProp
|
|
38
|
+
}), [
|
|
39
|
+
element,
|
|
40
|
+
key,
|
|
41
|
+
color,
|
|
42
|
+
disabledProp,
|
|
43
|
+
register
|
|
44
|
+
]);
|
|
45
|
+
const disabled = disabledProp || context.disabled;
|
|
46
|
+
const selected = context.selected === key;
|
|
47
|
+
const highlighted = element !== null && context.highlighted === element;
|
|
48
|
+
return renderElement("div", props, {
|
|
49
|
+
color,
|
|
50
|
+
selected,
|
|
51
|
+
highlighted,
|
|
52
|
+
disabled
|
|
53
|
+
}, {
|
|
54
|
+
role: "option",
|
|
55
|
+
id,
|
|
56
|
+
tabIndex: context.disabled ? void 0 : element !== null && context.tabStop === element ? 0 : -1,
|
|
57
|
+
"aria-selected": selected ? "true" : "false",
|
|
58
|
+
"aria-disabled": disabled ? "true" : void 0,
|
|
59
|
+
style: { "--color-swatch-picker-item-color": formatColor(color, "css") },
|
|
60
|
+
"data-primitives-part": "color-swatch-picker-item",
|
|
61
|
+
...stateAttributes({
|
|
62
|
+
selected,
|
|
63
|
+
highlighted,
|
|
64
|
+
disabled
|
|
65
|
+
}),
|
|
66
|
+
onFocus: () => {
|
|
67
|
+
if (element !== null) context.focused(element);
|
|
68
|
+
},
|
|
69
|
+
onClick: (event) => {
|
|
70
|
+
if (element !== null) context.press(element, event.nativeEvent);
|
|
71
|
+
}
|
|
72
|
+
}, ref);
|
|
73
|
+
}
|
|
74
|
+
// src/components/color-swatch-picker/color-swatch-picker-root.tsx
|
|
75
|
+
/** A `Color`, a string `parseColor` reads (`null` when it reads none), or `null`. */
|
|
76
|
+
function toColor(value) {
|
|
77
|
+
if (value === void 0 || value === null) return value;
|
|
78
|
+
return parseColor(value);
|
|
79
|
+
}
|
|
80
|
+
/** The items in document order. */
|
|
81
|
+
function inOrder(entries) {
|
|
82
|
+
return [...entries].sort((a, b) => a.element.compareDocumentPosition(b.element) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
|
|
83
|
+
}
|
|
84
|
+
/** The list model of the rendered items (`@fragiola/primitives/selection`). */
|
|
85
|
+
function modelOf(entries) {
|
|
86
|
+
return createListModel(entries.map((entry) => ({
|
|
87
|
+
key: entry.key,
|
|
88
|
+
textValue: "",
|
|
89
|
+
disabled: entry.disabled
|
|
90
|
+
})));
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A palette of swatches for choosing one color (spec/color-swatch-picker.md, the APG listbox in
|
|
94
|
+
* single selection): its roving focus, the arrows along and between its rows, its hidden input.
|
|
95
|
+
*/
|
|
96
|
+
function ColorSwatchPickerRoot({ value: valueProp, defaultValue: defaultValueProp, onValueChange, disabled: disabledProp = false, name, children, ...props }) {
|
|
97
|
+
const defaultValue = defaultValueProp ?? null;
|
|
98
|
+
const { picker, bound } = useColorPickerBinding(valueProp !== void 0 || defaultValueProp !== void 0);
|
|
99
|
+
const [own, setOwn] = useControllableState(toColor(valueProp), toColor(defaultValue) ?? null, onValueChange);
|
|
100
|
+
const value = bound === null ? own : bound.value;
|
|
101
|
+
const selected = value === null ? null : formatColor(value, "hexa");
|
|
102
|
+
const [element, ref] = useElement();
|
|
103
|
+
const direction = useContext(DirectionContext);
|
|
104
|
+
const [entries, setEntries] = useState([]);
|
|
105
|
+
const ordered = inOrder(entries);
|
|
106
|
+
const [active, setActive] = useState(null);
|
|
107
|
+
const [within, setWithin] = useState(false);
|
|
108
|
+
const hidden = useRef(null);
|
|
109
|
+
const tabStopOf = useCallback((items, current) => {
|
|
110
|
+
if (items.length === 0) return null;
|
|
111
|
+
if (within && active !== null) {
|
|
112
|
+
const focused = items.find((entry) => entry.element === active);
|
|
113
|
+
if (focused !== void 0) return focused.element;
|
|
114
|
+
}
|
|
115
|
+
return items.find((entry) => entry.key === current)?.element ?? items[0]?.element ?? null;
|
|
116
|
+
}, [within, active]);
|
|
117
|
+
const latest = useRef({
|
|
118
|
+
entries,
|
|
119
|
+
selected,
|
|
120
|
+
tabStopOf,
|
|
121
|
+
bound,
|
|
122
|
+
setOwn
|
|
123
|
+
});
|
|
124
|
+
latest.current = {
|
|
125
|
+
entries,
|
|
126
|
+
selected,
|
|
127
|
+
tabStopOf,
|
|
128
|
+
bound,
|
|
129
|
+
setOwn
|
|
130
|
+
};
|
|
131
|
+
const tabStopElement = useCallback(() => {
|
|
132
|
+
const current = latest.current;
|
|
133
|
+
return current.tabStopOf(inOrder(current.entries), current.selected);
|
|
134
|
+
}, []);
|
|
135
|
+
const field = useFieldControl({
|
|
136
|
+
id: void 0,
|
|
137
|
+
labelable: false,
|
|
138
|
+
value,
|
|
139
|
+
filled: value !== null,
|
|
140
|
+
input: () => hidden.current,
|
|
141
|
+
element: () => element,
|
|
142
|
+
focusTarget: tabStopElement,
|
|
143
|
+
skip: picker !== null
|
|
144
|
+
});
|
|
145
|
+
const disabled = disabledProp || field.disabled || (picker?.disabled ?? false);
|
|
146
|
+
const onValueChangeRef = useRef(onValueChange);
|
|
147
|
+
onValueChangeRef.current = onValueChange;
|
|
148
|
+
const choose = useCallback((key, reason, event) => {
|
|
149
|
+
const current = latest.current;
|
|
150
|
+
const entry = current.entries.find((candidate) => candidate.key === key);
|
|
151
|
+
if (entry === void 0 || entry.disabled || key === current.selected) return;
|
|
152
|
+
const details = {
|
|
153
|
+
reason,
|
|
154
|
+
event
|
|
155
|
+
};
|
|
156
|
+
if (current.bound === null) {
|
|
157
|
+
current.setOwn(entry.color, details);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
onValueChangeRef.current?.(entry.color, details);
|
|
161
|
+
current.bound.setValue(entry.color, details);
|
|
162
|
+
current.bound.commit(entry.color, details);
|
|
163
|
+
}, []);
|
|
164
|
+
const onKeyDown = (event) => {
|
|
165
|
+
if (disabled || event.defaultPrevented) return;
|
|
166
|
+
const items = inOrder(latest.current.entries);
|
|
167
|
+
const index = items.findIndex((entry) => entry.element === event.target);
|
|
168
|
+
if (index === -1) return;
|
|
169
|
+
const elements = items.map((entry) => entry.element);
|
|
170
|
+
if ((event.key === "ArrowDown" || event.key === "ArrowUp") && !event.altKey) {
|
|
171
|
+
event.preventDefault();
|
|
172
|
+
elements[rowTarget(elements, index, event.key === "ArrowDown" ? 1 : -1)]?.focus();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const model = modelOf(items);
|
|
176
|
+
const result = listKeyTarget(event, model, index, {
|
|
177
|
+
orientation: "horizontal",
|
|
178
|
+
rtl: getDirection(event.currentTarget, direction) === "rtl",
|
|
179
|
+
loop: true,
|
|
180
|
+
mode: "single",
|
|
181
|
+
behavior: "toggle"
|
|
182
|
+
});
|
|
183
|
+
if (result === null) return;
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
elements[result.index]?.focus();
|
|
186
|
+
if (result.selection?.type === "replace") choose(result.selection.key, "keyboard", event.nativeEvent);
|
|
187
|
+
};
|
|
188
|
+
const register = useCallback((entry) => {
|
|
189
|
+
setEntries((current) => [...current, entry]);
|
|
190
|
+
return () => setEntries((current) => current.filter((item) => item !== entry));
|
|
191
|
+
}, []);
|
|
192
|
+
const focused = useCallback((item) => {
|
|
193
|
+
setActive(item);
|
|
194
|
+
setWithin(true);
|
|
195
|
+
}, []);
|
|
196
|
+
const press = useCallback((item, event) => {
|
|
197
|
+
const entry = latest.current.entries.find((candidate) => candidate.element === item);
|
|
198
|
+
if (entry === void 0 || disabled) return;
|
|
199
|
+
item.focus();
|
|
200
|
+
choose(entry.key, "item-press", event);
|
|
201
|
+
}, [disabled, choose]);
|
|
202
|
+
const reset = useRef({
|
|
203
|
+
defaultValue,
|
|
204
|
+
markReset: field.reset
|
|
205
|
+
});
|
|
206
|
+
reset.current = {
|
|
207
|
+
defaultValue,
|
|
208
|
+
markReset: field.reset
|
|
209
|
+
};
|
|
210
|
+
useEffect(() => {
|
|
211
|
+
const input = hidden.current;
|
|
212
|
+
if (input === null) return;
|
|
213
|
+
return bridgeForm(input, {
|
|
214
|
+
reset: () => {
|
|
215
|
+
if (latest.current.bound !== null) return;
|
|
216
|
+
const current = reset.current;
|
|
217
|
+
current.markReset();
|
|
218
|
+
latest.current.setOwn(toColor(current.defaultValue) ?? null, { reason: "none" });
|
|
219
|
+
},
|
|
220
|
+
invalid: tabStopElement
|
|
221
|
+
});
|
|
222
|
+
}, [tabStopElement]);
|
|
223
|
+
const tabStop = disabled ? null : tabStopOf(ordered, selected);
|
|
224
|
+
const highlighted = within && !disabled ? active : null;
|
|
225
|
+
const context = useMemo(() => ({
|
|
226
|
+
disabled,
|
|
227
|
+
selected,
|
|
228
|
+
tabStop,
|
|
229
|
+
highlighted,
|
|
230
|
+
register,
|
|
231
|
+
focused,
|
|
232
|
+
press
|
|
233
|
+
}), [
|
|
234
|
+
disabled,
|
|
235
|
+
selected,
|
|
236
|
+
tabStop,
|
|
237
|
+
highlighted,
|
|
238
|
+
register,
|
|
239
|
+
focused,
|
|
240
|
+
press
|
|
241
|
+
]);
|
|
242
|
+
const formName = bound === null ? field.name ?? name : void 0;
|
|
243
|
+
return /* @__PURE__ */ jsx(ColorSwatchPickerContext.Provider, {
|
|
244
|
+
value: context,
|
|
245
|
+
children: renderElement("div", {
|
|
246
|
+
...props,
|
|
247
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [children, /* @__PURE__ */ jsx("input", {
|
|
248
|
+
ref: hidden,
|
|
249
|
+
type: "hidden",
|
|
250
|
+
name: formName,
|
|
251
|
+
value: value === null ? "" : formatColor(value, "hex"),
|
|
252
|
+
disabled,
|
|
253
|
+
"data-primitives-part": "color-swatch-picker-input"
|
|
254
|
+
})] })
|
|
255
|
+
}, {
|
|
256
|
+
value,
|
|
257
|
+
disabled
|
|
258
|
+
}, {
|
|
259
|
+
role: "listbox",
|
|
260
|
+
"aria-orientation": "horizontal",
|
|
261
|
+
"aria-disabled": disabled ? "true" : void 0,
|
|
262
|
+
...field.aria,
|
|
263
|
+
"data-primitives-part": "color-swatch-picker-root",
|
|
264
|
+
...field.attributes,
|
|
265
|
+
...stateAttributes({ disabled }),
|
|
266
|
+
onKeyDown,
|
|
267
|
+
onFocus: field.onFocus,
|
|
268
|
+
onBlur: (event) => {
|
|
269
|
+
const next = event.relatedTarget;
|
|
270
|
+
if (!(next instanceof Node) || !event.currentTarget.contains(next)) {
|
|
271
|
+
setWithin(false);
|
|
272
|
+
field.onBlur();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}, ref)
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
// src/components/color-swatch-picker/parts.ts
|
|
279
|
+
/** spec/color-swatch-picker.md */
|
|
280
|
+
const ColorSwatchPicker = {
|
|
281
|
+
Root: ColorSwatchPickerRoot,
|
|
282
|
+
Item: ColorSwatchPickerItem
|
|
283
|
+
};
|
|
284
|
+
export { ColorSwatchPicker as t };
|
|
285
|
+
|
|
286
|
+
//# sourceMappingURL=color-swatch-picker-CnmTr1SY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-swatch-picker-CnmTr1SY.js","names":[],"sources":["../src/components/color-swatch-picker/color-swatch-picker-context.ts","../src/components/color-swatch-picker/color-swatch-picker-item.tsx","../src/components/color-swatch-picker/color-swatch-picker-root.tsx","../src/components/color-swatch-picker/parts.ts"],"sourcesContent":["import type { Color } from \"@fragiola/primitives/color\";\nimport { createContext } from \"react\";\n\n/** A rendered Item, as the Root knows it. */\nexport interface ColorSwatchPickerItemEntry {\n element: HTMLElement;\n /** Its color's key: `formatColor(color, \"hexa\")`. */\n key: string;\n color: Color;\n disabled: boolean;\n}\n\nexport interface ColorSwatchPickerContextValue {\n disabled: boolean;\n /** The selected color's key, or `null`. */\n selected: string | null;\n /** The Item holding the tab stop (`tabindex=\"0\"`); `null` before the items are known. */\n tabStop: HTMLElement | null;\n /** The focused Item while the focus is in the list (`data-highlighted`). */\n highlighted: HTMLElement | null;\n register: (entry: ColorSwatchPickerItemEntry) => () => void;\n /** An Item took focus. */\n focused: (element: HTMLElement) => void;\n /** A press on an Item. */\n press: (element: HTMLElement, event: MouseEvent) => void;\n}\n\nexport const ColorSwatchPickerContext =\n createContext<ColorSwatchPickerContextValue | null>(null);\n","import {\n type Color,\n formatColor,\n parseColor,\n} from \"@fragiola/primitives/color\";\nimport { type MouseEvent, useId, useLayoutEffect, useMemo } 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 { ColorSwatchPickerContext } from \"./color-swatch-picker-context.ts\";\n\nexport interface ColorSwatchPickerItemState {\n color: Color;\n selected: boolean;\n highlighted: boolean;\n disabled: boolean;\n}\n\nexport interface ColorSwatchPickerItemProps\n extends PartProps<ColorSwatchPickerItemState> {\n /** The color it selects. */\n value: Color | string;\n /** Takes focus, never the selection. */\n disabled?: boolean;\n}\n\nconst BLACK: Color = { space: \"rgb\", red: 0, green: 0, blue: 0, alpha: 1 };\n\n/** An `option` of the palette, focusable with a roving `tabindex` (spec/color-swatch-picker.md). */\nexport function ColorSwatchPickerItem({\n value,\n disabled: disabledProp = false,\n ...props\n}: ColorSwatchPickerItemProps) {\n const context = useRequiredContext(\n ColorSwatchPickerContext,\n \"ColorSwatchPicker.Item\",\n );\n const color = useMemo(() => parseColor(value) ?? BLACK, [value]);\n const key = formatColor(color, \"hexa\");\n const [element, ref] = useElement<HTMLElement>();\n const id = useId();\n const { register } = context;\n useLayoutEffect(\n () =>\n element === null\n ? undefined\n : register({ element, key, color, disabled: disabledProp }),\n [element, key, color, disabledProp, register],\n );\n const disabled = disabledProp || context.disabled;\n const selected = context.selected === key;\n const highlighted = element !== null && context.highlighted === element;\n return renderElement(\n \"div\",\n props,\n { color, selected, highlighted, disabled },\n {\n role: \"option\",\n id,\n // a disabled list's options take no focus at all\n tabIndex: context.disabled\n ? undefined\n : element !== null && context.tabStop === element\n ? 0\n : -1,\n \"aria-selected\": selected ? \"true\" : \"false\",\n \"aria-disabled\": disabled ? \"true\" : undefined,\n style: {\n \"--color-swatch-picker-item-color\": formatColor(color, \"css\"),\n },\n \"data-primitives-part\": \"color-swatch-picker-item\",\n ...stateAttributes({ selected, highlighted, disabled }),\n onFocus: () => {\n if (element !== null) {\n context.focused(element);\n }\n },\n onClick: (event: MouseEvent) => {\n if (element !== null) {\n context.press(element, event.nativeEvent);\n }\n },\n },\n ref,\n );\n}\n","import {\n type Color,\n formatColor,\n parseColor,\n} from \"@fragiola/primitives/color\";\nimport { getDirection } from \"@fragiola/primitives/direction\";\nimport { bridgeForm } from \"@fragiola/primitives/form\";\nimport {\n createListModel,\n type ListModel,\n listKeyTarget,\n rowTarget,\n} from \"@fragiola/primitives/selection\";\nimport {\n type FocusEvent,\n type KeyboardEvent,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { DirectionContext } from \"../../direction/direction-context.ts\";\nimport { useColorPickerBinding } from \"../../hooks/use-color-picker-binding.ts\";\nimport { useControllableState } from \"../../hooks/use-controllable-state.ts\";\nimport { useElement } from \"../../hooks/use-element.ts\";\nimport { useFieldControl } from \"../../hooks/use-field-control.ts\";\nimport type {\n ChangeDetails,\n ChangeReason,\n} from \"../../utils/change-details.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { stateAttributes } from \"../../utils/state-attributes.ts\";\nimport {\n ColorSwatchPickerContext,\n type ColorSwatchPickerItemEntry,\n} from \"./color-swatch-picker-context.ts\";\n\nexport interface ColorSwatchPickerRootState {\n /** The selected color, or `null`. */\n value: Color | null;\n disabled: boolean;\n}\n\nexport interface ColorSwatchPickerRootProps\n extends PartProps<ColorSwatchPickerRootState> {\n value?: Color | string | null;\n defaultValue?: Color | string | null;\n onValueChange?: (value: Color | null, details: ChangeDetails) => void;\n /** Every option is disabled and none takes focus. */\n disabled?: boolean;\n name?: string;\n}\n\n/** A `Color`, a string `parseColor` reads (`null` when it reads none), or `null`. */\nfunction toColor(\n value: Color | string | null | undefined,\n): Color | null | undefined {\n if (value === undefined || value === null) {\n return value;\n }\n return parseColor(value);\n}\n\n/** The items in document order. */\nfunction inOrder(\n entries: readonly ColorSwatchPickerItemEntry[],\n): ColorSwatchPickerItemEntry[] {\n return [...entries].sort((a, b) =>\n a.element.compareDocumentPosition(b.element) &\n Node.DOCUMENT_POSITION_FOLLOWING\n ? -1\n : 1,\n );\n}\n\n/** The list model of the rendered items (`@fragiola/primitives/selection`). */\nfunction modelOf(entries: readonly ColorSwatchPickerItemEntry[]): ListModel {\n return createListModel(\n entries.map((entry) => ({\n key: entry.key,\n textValue: \"\",\n disabled: entry.disabled,\n })),\n );\n}\n\n/**\n * A palette of swatches for choosing one color (spec/color-swatch-picker.md, the APG listbox in\n * single selection): its roving focus, the arrows along and between its rows, its hidden input.\n */\nexport function ColorSwatchPickerRoot({\n value: valueProp,\n defaultValue: defaultValueProp,\n onValueChange,\n disabled: disabledProp = false,\n name,\n children,\n ...props\n}: ColorSwatchPickerRootProps) {\n const defaultValue = defaultValueProp ?? null;\n // inside a ColorPicker, bound to its color unless given its own (spec/color-picker.md)\n const { picker, bound } = useColorPickerBinding(\n valueProp !== undefined || defaultValueProp !== undefined,\n );\n const [own, setOwn] = useControllableState<Color | null, ChangeDetails>(\n toColor(valueProp),\n toColor(defaultValue) ?? null,\n onValueChange,\n );\n const value = bound === null ? own : bound.value;\n const selected = value === null ? null : formatColor(value, \"hexa\");\n const [element, ref] = useElement<HTMLElement>();\n const direction = useContext(DirectionContext);\n const [entries, setEntries] = useState<\n readonly ColorSwatchPickerItemEntry[]\n >([]);\n const ordered = inOrder(entries);\n const [active, setActive] = useState<HTMLElement | null>(null);\n const [within, setWithin] = useState(false);\n const hidden = useRef<HTMLInputElement>(null);\n\n const tabStopOf = useCallback(\n (\n items: readonly ColorSwatchPickerItemEntry[],\n current: string | null,\n ) => {\n if (items.length === 0) {\n return null;\n }\n if (within && active !== null) {\n const focused = items.find((entry) => entry.element === active);\n if (focused !== undefined) {\n return focused.element;\n }\n }\n return (\n items.find((entry) => entry.key === current)?.element ??\n items[0]?.element ??\n null\n );\n },\n [within, active],\n );\n const latest = useRef({ entries, selected, tabStopOf, bound, setOwn });\n latest.current = { entries, selected, tabStopOf, bound, setOwn };\n const tabStopElement = useCallback(() => {\n const current = latest.current;\n return current.tabStopOf(inOrder(current.entries), current.selected);\n }, []);\n\n // in a Field, the list is the field's control (spec/color-swatch-picker.md, \"Forms and Field\")\n const field = useFieldControl({\n id: undefined,\n labelable: false,\n value,\n filled: value !== null,\n input: () => hidden.current,\n element: () => element,\n focusTarget: tabStopElement,\n // inside a ColorPicker, the picker is the field's control\n skip: picker !== null,\n });\n const disabled =\n disabledProp || field.disabled || (picker?.disabled ?? false);\n\n const onValueChangeRef = useRef(onValueChange);\n onValueChangeRef.current = onValueChange;\n const choose = useCallback(\n (key: string, reason: ChangeReason, event?: Event) => {\n const current = latest.current;\n const entry = current.entries.find(\n (candidate) => candidate.key === key,\n );\n if (\n entry === undefined ||\n entry.disabled ||\n key === current.selected\n ) {\n return;\n }\n const details = { reason, event };\n if (current.bound === null) {\n current.setOwn(entry.color, details);\n return;\n }\n onValueChangeRef.current?.(entry.color, details);\n current.bound.setValue(entry.color, details);\n current.bound.commit(entry.color, details);\n },\n [],\n );\n const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n if (disabled || event.defaultPrevented) {\n return;\n }\n const items = inOrder(latest.current.entries);\n const index = items.findIndex(\n (entry) => entry.element === event.target,\n );\n if (index === -1) {\n return;\n }\n const elements = items.map((entry) => entry.element);\n if (\n (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") &&\n !event.altKey\n ) {\n event.preventDefault();\n const target = rowTarget(\n elements,\n index,\n event.key === \"ArrowDown\" ? 1 : -1,\n );\n elements[target]?.focus();\n return;\n }\n const model = modelOf(items);\n const result = listKeyTarget(event, model, index, {\n orientation: \"horizontal\",\n rtl: getDirection(event.currentTarget, direction) === \"rtl\",\n loop: true,\n mode: \"single\",\n behavior: \"toggle\",\n });\n if (result === null) {\n return;\n }\n event.preventDefault();\n elements[result.index]?.focus();\n if (result.selection?.type === \"replace\") {\n choose(result.selection.key, \"keyboard\", event.nativeEvent);\n }\n };\n\n const register = useCallback((entry: ColorSwatchPickerItemEntry) => {\n setEntries((current) => [...current, entry]);\n return () =>\n setEntries((current) => current.filter((item) => item !== entry));\n }, []);\n const focused = useCallback((item: HTMLElement) => {\n setActive(item);\n setWithin(true);\n }, []);\n const press = useCallback(\n (item: HTMLElement, event: MouseEvent) => {\n const entry = latest.current.entries.find(\n (candidate) => candidate.element === item,\n );\n if (entry === undefined || disabled) {\n return;\n }\n item.focus();\n choose(entry.key, \"item-press\", event);\n },\n [disabled, choose],\n );\n\n // a form reset returns an uncontrolled picker to its default\n const reset = useRef({ defaultValue, markReset: field.reset });\n reset.current = { defaultValue, markReset: field.reset };\n useEffect(() => {\n const input = hidden.current;\n if (input === null) {\n return undefined;\n }\n return bridgeForm(input, {\n reset: () => {\n // a bound picker is reset by its ColorPicker\n if (latest.current.bound !== null) {\n return;\n }\n const current = reset.current;\n current.markReset();\n latest.current.setOwn(toColor(current.defaultValue) ?? null, {\n reason: \"none\",\n });\n },\n invalid: tabStopElement,\n });\n }, [tabStopElement]);\n\n const tabStop = disabled ? null : tabStopOf(ordered, selected);\n const highlighted = within && !disabled ? active : null;\n const context = useMemo(\n () => ({\n disabled,\n selected,\n tabStop,\n highlighted,\n register,\n focused,\n press,\n }),\n [disabled, selected, tabStop, highlighted, register, focused, press],\n );\n const formName = bound === null ? (field.name ?? name) : undefined;\n return (\n <ColorSwatchPickerContext.Provider value={context}>\n {renderElement(\n \"div\",\n {\n ...props,\n children: (\n <>\n {children}\n <input\n ref={hidden}\n type=\"hidden\"\n name={formName}\n value={\n value === null\n ? \"\"\n : formatColor(value, \"hex\")\n }\n disabled={disabled}\n data-primitives-part=\"color-swatch-picker-input\"\n />\n </>\n ),\n },\n { value, disabled },\n {\n role: \"listbox\",\n \"aria-orientation\": \"horizontal\",\n \"aria-disabled\": disabled ? \"true\" : undefined,\n ...field.aria,\n \"data-primitives-part\": \"color-swatch-picker-root\",\n ...field.attributes,\n ...stateAttributes({ disabled }),\n onKeyDown,\n onFocus: field.onFocus,\n // the focus left the list: the next Tab in lands on the selection (APG)\n onBlur: (event: FocusEvent<HTMLElement>) => {\n const next = event.relatedTarget;\n if (\n !(next instanceof Node) ||\n !event.currentTarget.contains(next)\n ) {\n setWithin(false);\n field.onBlur();\n }\n },\n },\n ref,\n )}\n </ColorSwatchPickerContext.Provider>\n );\n}\n","import { ColorSwatchPickerItem } from \"./color-swatch-picker-item.tsx\";\nimport { ColorSwatchPickerRoot } from \"./color-swatch-picker-root.tsx\";\n\n/** spec/color-swatch-picker.md */\nexport const ColorSwatchPicker = {\n Root: ColorSwatchPickerRoot,\n Item: ColorSwatchPickerItem,\n};\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,MAAa,2BACT,cAAoD,IAAI;;ACD5D,MAAM,QAAe;CAAE,OAAO;CAAO,KAAK;CAAG,OAAO;CAAG,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
|
2
|
+
import { n as RenderProp } from "./render-element-Pwuv2wsL.js";
|
|
3
|
+
import { a as RgbColor, c as ColorSwatchPickerRootState, i as HslColor, l as ColorSwatchPickerItemProps, n as ColorSpace, o as ColorSwatchPicker, r as HsbColor, s as ColorSwatchPickerRootProps, t as Color, u as ColorSwatchPickerItemState } from "./index-CsXJJ0G8.js";
|
|
4
|
+
export { type ChangeDetails, type ChangeReason, type Color, type ColorSpace, ColorSwatchPicker, type ColorSwatchPickerItemProps, type ColorSwatchPickerItemState, type ColorSwatchPickerRootProps, type ColorSwatchPickerRootState, type HsbColor, type HslColor, type RenderProp, type RgbColor };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as ColorSwatchPicker } from "./color-swatch-picker-CnmTr1SY.js";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { n as RenderProp } from "./render-element-Pwuv2wsL.js";
|
|
2
|
+
import { a as RgbColor, c as ColorSwatchState, i as HslColor, n as ColorSpace, o as ColorSwatch, r as HsbColor, s as ColorSwatchProps, t as Color } from "./index-Cjl7RT2o.js";
|
|
3
|
+
export { type Color, type ColorSpace, ColorSwatch, type ColorSwatchProps, type ColorSwatchState, type HsbColor, type HslColor, type RenderProp, type RgbColor };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as ColorSwatch } from "./color-swatch-C9ws0xF4.js";
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { t as useColorPickerBinding } from "./use-color-picker-binding-D0R-FsfF.js";
|
|
2
|
+
import { t as useControllableState } from "./use-controllable-state-Dm8eNkgP.js";
|
|
3
|
+
import { t as renderElement } from "./render-element-DXbUbfgN.js";
|
|
4
|
+
import { t as stateAttributes } from "./state-attributes-DhboDeMS.js";
|
|
5
|
+
import { t as useElement } from "./use-element-tpFZ-kuA.js";
|
|
6
|
+
import { t as useRequiredContext } from "./use-required-context-Cjd_CYnv.js";
|
|
7
|
+
import { createContext, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { bridgeForm } from "@fragiola/primitives/form";
|
|
10
|
+
import { startDrag } from "@fragiola/primitives/pointer";
|
|
11
|
+
import { colorSpaceFor, colorWheelGradient, colorWheelKeyTarget, colorWheelThumbOffset, convertColor, formatColor, formatColorChannel, getColorChannel, hueAtPoint, isOnColorWheel, isSameColor, parseColor, setColorChannel, wrapHue } from "@fragiola/primitives/color";
|
|
12
|
+
// src/components/color-wheel/color-wheel-context.ts
|
|
13
|
+
const ColorWheelContext = createContext(null);
|
|
14
|
+
function colorWheelState(context) {
|
|
15
|
+
return {
|
|
16
|
+
color: context.color,
|
|
17
|
+
hue: context.hue,
|
|
18
|
+
disabled: context.disabled,
|
|
19
|
+
dragging: context.dragging
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
// src/components/color-wheel/color-wheel-root.tsx
|
|
23
|
+
const RED = {
|
|
24
|
+
space: "hsl",
|
|
25
|
+
hue: 0,
|
|
26
|
+
saturation: 100,
|
|
27
|
+
lightness: 50,
|
|
28
|
+
alpha: 1
|
|
29
|
+
};
|
|
30
|
+
/** A `Color`, or a string `parseColor` reads (the default when it reads none). */
|
|
31
|
+
function toColor(value) {
|
|
32
|
+
return value === void 0 ? void 0 : parseColor(value) ?? RED;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Holds a color wheel's value: the interactive square around the ring, and the hidden input with
|
|
36
|
+
* the color as hex (spec/color-wheel.md, the APG slider on a ring).
|
|
37
|
+
*/
|
|
38
|
+
function ColorWheelRoot({ value: valueProp, defaultValue: defaultValueProp, onValueChange, onValueCommit, colorSpace, outerRadius = 100, innerRadius = 75, disabled: disabledProp = false, name, locale, children, ...props }) {
|
|
39
|
+
const defaultValue = defaultValueProp ?? RED;
|
|
40
|
+
const { picker, bound } = useColorPickerBinding(valueProp !== void 0 || defaultValueProp !== void 0);
|
|
41
|
+
const disabled = disabledProp || (picker?.disabled ?? false);
|
|
42
|
+
const [own, setOwn] = useControllableState(toColor(valueProp), toColor(defaultValue), onValueChange);
|
|
43
|
+
const current = bound === null ? own : bound.value;
|
|
44
|
+
const setCurrent = bound === null ? setOwn : (next, details) => {
|
|
45
|
+
onValueChange?.(next, details);
|
|
46
|
+
bound.setValue(next, details);
|
|
47
|
+
};
|
|
48
|
+
const color = convertColor(current, colorSpaceFor("hue", current, colorSpace));
|
|
49
|
+
const hue = getColorChannel(color, "hue");
|
|
50
|
+
const hex = formatColor(color, "hex");
|
|
51
|
+
const input = useRef(null);
|
|
52
|
+
const [thumb, setThumb] = useState(null);
|
|
53
|
+
const [dragging, setDragging] = useState(false);
|
|
54
|
+
const endDrag = useRef(null);
|
|
55
|
+
useEffect(() => () => endDrag.current?.(), []);
|
|
56
|
+
const latest = useRef({
|
|
57
|
+
current,
|
|
58
|
+
color,
|
|
59
|
+
innerRadius,
|
|
60
|
+
outerRadius,
|
|
61
|
+
onValueCommit,
|
|
62
|
+
setCurrent,
|
|
63
|
+
bound
|
|
64
|
+
});
|
|
65
|
+
latest.current = {
|
|
66
|
+
current,
|
|
67
|
+
color,
|
|
68
|
+
innerRadius,
|
|
69
|
+
outerRadius,
|
|
70
|
+
onValueCommit,
|
|
71
|
+
setCurrent,
|
|
72
|
+
bound
|
|
73
|
+
};
|
|
74
|
+
const initial = useRef(defaultValue);
|
|
75
|
+
initial.current = defaultValue;
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
const element = input.current;
|
|
78
|
+
if (element === null) return;
|
|
79
|
+
return bridgeForm(element, { reset: () => {
|
|
80
|
+
if (latest.current.bound !== null) return;
|
|
81
|
+
const next = toColor(initial.current);
|
|
82
|
+
if (!isSameColor(next, latest.current.current)) latest.current.setCurrent(next, { reason: "none" });
|
|
83
|
+
} });
|
|
84
|
+
}, []);
|
|
85
|
+
const setHue = useCallback((next, reason) => {
|
|
86
|
+
const before = latest.current.color;
|
|
87
|
+
const wrapped = wrapHue(next);
|
|
88
|
+
if (wrapped === getColorChannel(before, "hue")) return before;
|
|
89
|
+
const changed = setColorChannel(before, "hue", wrapped);
|
|
90
|
+
latest.current.setCurrent(changed, { reason });
|
|
91
|
+
return changed;
|
|
92
|
+
}, []);
|
|
93
|
+
const commit = useCallback((committed) => {
|
|
94
|
+
const { color: now, onValueCommit: onCommit, bound: to } = latest.current;
|
|
95
|
+
onCommit?.(committed ?? now, { reason: "none" });
|
|
96
|
+
to?.commit(committed ?? now, { reason: "none" });
|
|
97
|
+
}, []);
|
|
98
|
+
const onPointerDown = (event) => {
|
|
99
|
+
if (disabled || event.pointerType === "mouse" && event.button !== 0) return;
|
|
100
|
+
const target = event.currentTarget;
|
|
101
|
+
const point = {
|
|
102
|
+
x: event.clientX,
|
|
103
|
+
y: event.clientY
|
|
104
|
+
};
|
|
105
|
+
const box = target.getBoundingClientRect();
|
|
106
|
+
if (!isOnColorWheel(box, point, latest.current.innerRadius, latest.current.outerRadius)) return;
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
setHue(hueAtPoint(box, point), "track-press");
|
|
109
|
+
thumb?.focus();
|
|
110
|
+
setDragging(true);
|
|
111
|
+
endDrag.current?.();
|
|
112
|
+
endDrag.current = startDrag(target, event.nativeEvent, {
|
|
113
|
+
onMove: (move) => setHue(hueAtPoint(target.getBoundingClientRect(), {
|
|
114
|
+
x: move.clientX,
|
|
115
|
+
y: move.clientY
|
|
116
|
+
}), "drag"),
|
|
117
|
+
onEnd: () => {
|
|
118
|
+
endDrag.current = null;
|
|
119
|
+
setDragging(false);
|
|
120
|
+
commit();
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
const valueText = formatColorChannel(color, "hue", locale, hue);
|
|
125
|
+
const context = useMemo(() => ({
|
|
126
|
+
color,
|
|
127
|
+
hue,
|
|
128
|
+
outerRadius,
|
|
129
|
+
innerRadius,
|
|
130
|
+
disabled,
|
|
131
|
+
dragging,
|
|
132
|
+
valueText,
|
|
133
|
+
setHue,
|
|
134
|
+
commit,
|
|
135
|
+
thumb,
|
|
136
|
+
setThumb
|
|
137
|
+
}), [
|
|
138
|
+
color,
|
|
139
|
+
hue,
|
|
140
|
+
outerRadius,
|
|
141
|
+
innerRadius,
|
|
142
|
+
disabled,
|
|
143
|
+
dragging,
|
|
144
|
+
valueText,
|
|
145
|
+
setHue,
|
|
146
|
+
commit,
|
|
147
|
+
thumb
|
|
148
|
+
]);
|
|
149
|
+
const size = `${outerRadius * 2}px`;
|
|
150
|
+
return /* @__PURE__ */ jsx(ColorWheelContext.Provider, {
|
|
151
|
+
value: context,
|
|
152
|
+
children: renderElement("div", {
|
|
153
|
+
...props,
|
|
154
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [children, /* @__PURE__ */ jsx("input", {
|
|
155
|
+
ref: input,
|
|
156
|
+
type: "hidden",
|
|
157
|
+
name: bound === null ? name : void 0,
|
|
158
|
+
value: hex,
|
|
159
|
+
"data-primitives-part": "color-wheel-input"
|
|
160
|
+
})] })
|
|
161
|
+
}, colorWheelState(context), {
|
|
162
|
+
"data-primitives-part": "color-wheel-root",
|
|
163
|
+
...stateAttributes({
|
|
164
|
+
disabled,
|
|
165
|
+
dragging
|
|
166
|
+
}),
|
|
167
|
+
style: {
|
|
168
|
+
position: "relative",
|
|
169
|
+
inlineSize: size,
|
|
170
|
+
blockSize: size,
|
|
171
|
+
touchAction: "none",
|
|
172
|
+
"--color-wheel-outer-radius": `${outerRadius}px`,
|
|
173
|
+
"--color-wheel-inner-radius": `${innerRadius}px`
|
|
174
|
+
},
|
|
175
|
+
onPointerDown
|
|
176
|
+
})
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
// src/components/color-wheel/color-wheel-thumb.tsx
|
|
180
|
+
/** The `slider`: the hue, on the ring's middle circle (spec/color-wheel.md). */
|
|
181
|
+
function ColorWheelThumb(props) {
|
|
182
|
+
const context = useRequiredContext(ColorWheelContext, "ColorWheel.Thumb");
|
|
183
|
+
const [element, ref] = useElement();
|
|
184
|
+
const { setThumb } = context;
|
|
185
|
+
useLayoutEffect(() => {
|
|
186
|
+
setThumb(element);
|
|
187
|
+
return () => setThumb(null);
|
|
188
|
+
}, [element, setThumb]);
|
|
189
|
+
const { hue, disabled } = context;
|
|
190
|
+
const offset = colorWheelThumbOffset(hue, (context.innerRadius + context.outerRadius) / 2);
|
|
191
|
+
const onKeyDown = (event) => {
|
|
192
|
+
if (disabled) return;
|
|
193
|
+
const target = colorWheelKeyTarget(event.key, event.shiftKey, hue);
|
|
194
|
+
if (target === null) return;
|
|
195
|
+
event.preventDefault();
|
|
196
|
+
context.commit(context.setHue(target, "keyboard"));
|
|
197
|
+
};
|
|
198
|
+
return renderElement("div", props, colorWheelState(context), {
|
|
199
|
+
role: "slider",
|
|
200
|
+
tabIndex: disabled ? void 0 : 0,
|
|
201
|
+
"aria-valuenow": hue,
|
|
202
|
+
"aria-valuemin": 0,
|
|
203
|
+
"aria-valuemax": 360,
|
|
204
|
+
"aria-valuetext": context.valueText,
|
|
205
|
+
"aria-disabled": disabled ? "true" : void 0,
|
|
206
|
+
"data-primitives-part": "color-wheel-thumb",
|
|
207
|
+
...stateAttributes({
|
|
208
|
+
disabled,
|
|
209
|
+
dragging: context.dragging
|
|
210
|
+
}),
|
|
211
|
+
style: {
|
|
212
|
+
position: "absolute",
|
|
213
|
+
left: `calc(50% + ${offset.x}px)`,
|
|
214
|
+
top: `calc(50% + ${offset.y}px)`,
|
|
215
|
+
translate: "-50% -50%",
|
|
216
|
+
"--color-wheel-thumb-color": formatColor(setColorChannel(context.color, "alpha", 1))
|
|
217
|
+
},
|
|
218
|
+
onKeyDown
|
|
219
|
+
}, ref);
|
|
220
|
+
}
|
|
221
|
+
// src/components/color-wheel/color-wheel-track.tsx
|
|
222
|
+
/** The ring: its conic gradient, for the recipe to draw (spec/color-wheel.md). */
|
|
223
|
+
function ColorWheelTrack(props) {
|
|
224
|
+
const context = useRequiredContext(ColorWheelContext, "ColorWheel.Track");
|
|
225
|
+
return renderElement("div", props, colorWheelState(context), {
|
|
226
|
+
"data-primitives-part": "color-wheel-track",
|
|
227
|
+
...stateAttributes({
|
|
228
|
+
disabled: context.disabled,
|
|
229
|
+
dragging: context.dragging
|
|
230
|
+
}),
|
|
231
|
+
style: {
|
|
232
|
+
position: "absolute",
|
|
233
|
+
inset: 0,
|
|
234
|
+
"--color-wheel-track-background": colorWheelGradient()
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
// src/components/color-wheel/parts.ts
|
|
239
|
+
/** spec/color-wheel.md */
|
|
240
|
+
const ColorWheel = {
|
|
241
|
+
Root: ColorWheelRoot,
|
|
242
|
+
Track: ColorWheelTrack,
|
|
243
|
+
Thumb: ColorWheelThumb
|
|
244
|
+
};
|
|
245
|
+
export { ColorWheel as t };
|
|
246
|
+
|
|
247
|
+
//# sourceMappingURL=color-wheel--n8w5fIJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-wheel--n8w5fIJ.js","names":[],"sources":["../src/components/color-wheel/color-wheel-context.ts","../src/components/color-wheel/color-wheel-root.tsx","../src/components/color-wheel/color-wheel-thumb.tsx","../src/components/color-wheel/color-wheel-track.tsx","../src/components/color-wheel/parts.ts"],"sourcesContent":["import type { Color } from \"@fragiola/primitives/color\";\nimport { createContext } from \"react\";\nimport type { ChangeReason } from \"../../utils/change-details.ts\";\n\nexport interface ColorWheelContextValue {\n /** The value, in the wheel's space (hsl or hsb). */\n color: Color;\n hue: number;\n outerRadius: number;\n innerRadius: number;\n disabled: boolean;\n dragging: boolean;\n /** The hue's text (`Intl`, spec/color.md). */\n valueText: string;\n /** Sets the hue (wrapped into [0, 360), snapped), reports it, returns the color. */\n setHue: (hue: number, reason: ChangeReason) => Color;\n /** Reports the color (default: the current one) as committed. */\n commit: (color?: Color) => void;\n thumb: HTMLElement | null;\n setThumb: (element: HTMLElement | null) => void;\n}\n\nexport const ColorWheelContext = createContext<ColorWheelContextValue | null>(\n null,\n);\n\n/** The state every color wheel part shares. */\nexport interface ColorWheelState {\n /** The value, in the wheel's space. */\n color: Color;\n hue: number;\n disabled: boolean;\n dragging: boolean;\n}\n\nexport function colorWheelState(\n context: ColorWheelContextValue,\n): ColorWheelState {\n return {\n color: context.color,\n hue: context.hue,\n disabled: context.disabled,\n dragging: context.dragging,\n };\n}\n","import {\n type Color,\n colorSpaceFor,\n convertColor,\n formatColor,\n formatColorChannel,\n getColorChannel,\n hueAtPoint,\n isOnColorWheel,\n isSameColor,\n parseColor,\n setColorChannel,\n wrapHue,\n} from \"@fragiola/primitives/color\";\nimport { bridgeForm } from \"@fragiola/primitives/form\";\nimport { startDrag } from \"@fragiola/primitives/pointer\";\nimport {\n type PointerEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useColorPickerBinding } from \"../../hooks/use-color-picker-binding.ts\";\nimport { useControllableState } from \"../../hooks/use-controllable-state.ts\";\nimport type {\n ChangeDetails,\n ChangeReason,\n} from \"../../utils/change-details.ts\";\nimport { type PartProps, renderElement } from \"../../utils/render-element.tsx\";\nimport { stateAttributes } from \"../../utils/state-attributes.ts\";\nimport {\n ColorWheelContext,\n type ColorWheelState,\n colorWheelState,\n} from \"./color-wheel-context.ts\";\n\nconst RED: Color = {\n space: \"hsl\",\n hue: 0,\n saturation: 100,\n lightness: 50,\n alpha: 1,\n};\n\n/** A `Color`, or a string `parseColor` reads (the default when it reads none). */\nfunction toColor(value: Color | string | undefined): Color | undefined {\n return value === undefined ? undefined : (parseColor(value) ?? RED);\n}\n\nexport interface ColorWheelRootProps extends PartProps<ColorWheelState> {\n value?: Color | string;\n defaultValue?: Color | string;\n onValueChange?: (value: Color, details: ChangeDetails) => void;\n /** When a drag ends, or after a key changed the value. */\n onValueCommit?: (value: Color, details: ChangeDetails) => void;\n /** The space of the hue (default: the value's, else hsb). */\n colorSpace?: \"hsl\" | \"hsb\";\n /** The ring's outer radius, in px (default 100). */\n outerRadius?: number;\n /** The ring's inner radius, in px (default 75). */\n innerRadius?: number;\n disabled?: boolean;\n name?: string;\n /** The locale of the hue's text (BCP 47; default: the runtime's). */\n locale?: string;\n}\n\n/**\n * Holds a color wheel's value: the interactive square around the ring, and the hidden input with\n * the color as hex (spec/color-wheel.md, the APG slider on a ring).\n */\nexport function ColorWheelRoot({\n value: valueProp,\n defaultValue: defaultValueProp,\n onValueChange,\n onValueCommit,\n colorSpace,\n outerRadius = 100,\n innerRadius = 75,\n disabled: disabledProp = false,\n name,\n locale,\n children,\n ...props\n}: ColorWheelRootProps) {\n const defaultValue = defaultValueProp ?? RED;\n // inside a ColorPicker, bound to its color unless given its own (spec/color-picker.md)\n const { picker, bound } = useColorPickerBinding(\n valueProp !== undefined || defaultValueProp !== undefined,\n );\n const disabled = disabledProp || (picker?.disabled ?? false);\n const [own, setOwn] = useControllableState<Color, ChangeDetails>(\n toColor(valueProp),\n toColor(defaultValue) as Color,\n onValueChange,\n );\n const current = bound === null ? own : bound.value;\n const setCurrent =\n bound === null\n ? setOwn\n : (next: Color, details: ChangeDetails) => {\n onValueChange?.(next, details);\n bound.setValue(next, details);\n };\n const color = convertColor(\n current,\n colorSpaceFor(\"hue\", current, colorSpace),\n );\n const hue = getColorChannel(color, \"hue\");\n const hex = formatColor(color, \"hex\");\n const input = useRef<HTMLInputElement>(null);\n const [thumb, setThumb] = useState<HTMLElement | null>(null);\n const [dragging, setDragging] = useState(false);\n const endDrag = useRef<(() => void) | null>(null);\n useEffect(() => () => endDrag.current?.(), []);\n\n const latest = useRef({\n current,\n color,\n innerRadius,\n outerRadius,\n onValueCommit,\n setCurrent,\n bound,\n });\n latest.current = {\n current,\n color,\n innerRadius,\n outerRadius,\n onValueCommit,\n setCurrent,\n bound,\n };\n\n // a form reset returns the wheel to its default (spec/color-wheel.md, \"Forms\")\n const initial = useRef(defaultValue);\n initial.current = defaultValue;\n useEffect(() => {\n const element = input.current;\n if (element === null) {\n return undefined;\n }\n return bridgeForm(element, {\n reset: () => {\n // a bound control is reset by its picker\n if (latest.current.bound !== null) {\n return;\n }\n const next = toColor(initial.current) as Color;\n if (!isSameColor(next, latest.current.current)) {\n latest.current.setCurrent(next, { reason: \"none\" });\n }\n },\n });\n }, []);\n\n const setHue = useCallback((next: number, reason: ChangeReason) => {\n const before = latest.current.color;\n const wrapped = wrapHue(next);\n if (wrapped === getColorChannel(before, \"hue\")) {\n return before;\n }\n const changed = setColorChannel(before, \"hue\", wrapped);\n latest.current.setCurrent(changed, { reason });\n return changed;\n }, []);\n const commit = useCallback((committed?: Color) => {\n const {\n color: now,\n onValueCommit: onCommit,\n bound: to,\n } = latest.current;\n onCommit?.(committed ?? now, { reason: \"none\" });\n to?.commit(committed ?? now, { reason: \"none\" });\n }, []);\n\n const onPointerDown = (event: PointerEvent<HTMLElement>) => {\n if (disabled || (event.pointerType === \"mouse\" && event.button !== 0)) {\n return;\n }\n const target = event.currentTarget;\n const point = { x: event.clientX, y: event.clientY };\n const box = target.getBoundingClientRect();\n // a press off the ring does nothing (spec/color-wheel.md, \"Pointer\")\n if (\n !isOnColorWheel(\n box,\n point,\n latest.current.innerRadius,\n latest.current.outerRadius,\n )\n ) {\n return;\n }\n event.preventDefault();\n setHue(hueAtPoint(box, point), \"track-press\");\n thumb?.focus();\n setDragging(true);\n endDrag.current?.();\n endDrag.current = startDrag(target, event.nativeEvent, {\n onMove: (move) =>\n setHue(\n hueAtPoint(target.getBoundingClientRect(), {\n x: move.clientX,\n y: move.clientY,\n }),\n \"drag\",\n ),\n onEnd: () => {\n endDrag.current = null;\n setDragging(false);\n commit();\n },\n });\n };\n\n const valueText = formatColorChannel(color, \"hue\", locale, hue);\n const context = useMemo(\n () => ({\n color,\n hue,\n outerRadius,\n innerRadius,\n disabled,\n dragging,\n valueText,\n setHue,\n commit,\n thumb,\n setThumb,\n }),\n [\n color,\n hue,\n outerRadius,\n innerRadius,\n disabled,\n dragging,\n valueText,\n setHue,\n commit,\n thumb,\n ],\n );\n const size = `${outerRadius * 2}px`;\n return (\n <ColorWheelContext.Provider value={context}>\n {renderElement(\n \"div\",\n {\n ...props,\n children: (\n <>\n {children}\n <input\n ref={input}\n type=\"hidden\"\n name={bound === null ? name : undefined}\n value={hex}\n data-primitives-part=\"color-wheel-input\"\n />\n </>\n ),\n },\n colorWheelState(context),\n {\n \"data-primitives-part\": \"color-wheel-root\",\n ...stateAttributes({ disabled, dragging }),\n // structural: the square around the ring, no page scroll under a touch drag,\n // the radii a recipe's ring mask reads\n style: {\n position: \"relative\",\n inlineSize: size,\n blockSize: size,\n touchAction: \"none\",\n \"--color-wheel-outer-radius\": `${outerRadius}px`,\n \"--color-wheel-inner-radius\": `${innerRadius}px`,\n },\n onPointerDown,\n },\n )}\n </ColorWheelContext.Provider>\n );\n}\n","import {\n colorWheelKeyTarget,\n colorWheelThumbOffset,\n formatColor,\n setColorChannel,\n} from \"@fragiola/primitives/color\";\nimport { type KeyboardEvent, useLayoutEffect } 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 {\n ColorWheelContext,\n type ColorWheelState,\n colorWheelState,\n} from \"./color-wheel-context.ts\";\n\n/** The `slider`: the hue, on the ring's middle circle (spec/color-wheel.md). */\nexport function ColorWheelThumb(props: PartProps<ColorWheelState>) {\n const context = useRequiredContext(ColorWheelContext, \"ColorWheel.Thumb\");\n const [element, ref] = useElement<HTMLElement>();\n const { setThumb } = context;\n useLayoutEffect(() => {\n setThumb(element);\n return () => setThumb(null);\n }, [element, setThumb]);\n\n const { hue, disabled } = context;\n const offset = colorWheelThumbOffset(\n hue,\n (context.innerRadius + context.outerRadius) / 2,\n );\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (disabled) {\n return;\n }\n const target = colorWheelKeyTarget(event.key, event.shiftKey, hue);\n if (target === null) {\n return;\n }\n event.preventDefault();\n context.commit(context.setHue(target, \"keyboard\"));\n };\n\n return renderElement(\n \"div\",\n props,\n colorWheelState(context),\n {\n role: \"slider\",\n tabIndex: disabled ? undefined : 0,\n \"aria-valuenow\": hue,\n \"aria-valuemin\": 0,\n \"aria-valuemax\": 360,\n \"aria-valuetext\": context.valueText,\n \"aria-disabled\": disabled ? \"true\" : undefined,\n \"data-primitives-part\": \"color-wheel-thumb\",\n ...stateAttributes({ disabled, dragging: context.dragging }),\n // structural: its centre on the hue's point of the ring, and its color for the recipe\n style: {\n position: \"absolute\",\n left: `calc(50% + ${offset.x}px)`,\n top: `calc(50% + ${offset.y}px)`,\n translate: \"-50% -50%\",\n \"--color-wheel-thumb-color\": formatColor(\n setColorChannel(context.color, \"alpha\", 1),\n ),\n },\n onKeyDown,\n },\n ref,\n );\n}\n","import { colorWheelGradient } from \"@fragiola/primitives/color\";\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 ColorWheelContext,\n type ColorWheelState,\n colorWheelState,\n} from \"./color-wheel-context.ts\";\n\n/** The ring: its conic gradient, for the recipe to draw (spec/color-wheel.md). */\nexport function ColorWheelTrack(props: PartProps<ColorWheelState>) {\n const context = useRequiredContext(ColorWheelContext, \"ColorWheel.Track\");\n return renderElement(\"div\", props, colorWheelState(context), {\n \"data-primitives-part\": \"color-wheel-track\",\n ...stateAttributes({\n disabled: context.disabled,\n dragging: context.dragging,\n }),\n // structural: the Root's box, and the gradient a recipe draws\n style: {\n position: \"absolute\",\n inset: 0,\n \"--color-wheel-track-background\": colorWheelGradient(),\n },\n });\n}\n","import { ColorWheelRoot } from \"./color-wheel-root.tsx\";\nimport { ColorWheelThumb } from \"./color-wheel-thumb.tsx\";\nimport { ColorWheelTrack } from \"./color-wheel-track.tsx\";\n\n/** spec/color-wheel.md */\nexport const ColorWheel = {\n Root: ColorWheelRoot,\n Track: ColorWheelTrack,\n Thum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@
|
|
|
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 { a as RgbColor, c as ColorWheelState, i as HslColor, n as ColorSpace, o as ColorWheel, r as HsbColor, s as ColorWheelRootProps, t as Color } from "./index-D1-zqp2Q.js";
|
|
4
|
+
export { type ChangeDetails, type ChangeReason, type Color, type ColorSpace, ColorWheel, type ColorWheelRootProps, type ColorWheelState, type HsbColor, type HslColor, type RenderProp, type RgbColor };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as ColorWheel } from "./color-wheel--n8w5fIJ.js";
|