@42-central/ui-react 0.29.1 → 0.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-X6DESK37.js → chunk-2RRTT4AF.js} +17 -5
- package/dist/chunk-2RRTT4AF.js.map +1 -0
- package/dist/{chunk-TUP7WXQE.js → chunk-322I2RSV.js} +9 -6
- package/dist/chunk-322I2RSV.js.map +1 -0
- package/dist/{chunk-ISX3AM32.js → chunk-37SRSNLJ.js} +4 -4
- package/dist/{chunk-ISX3AM32.js.map → chunk-37SRSNLJ.js.map} +1 -1
- package/dist/{chunk-L5GH7LLD.js → chunk-3MFWUG5O.js} +4 -4
- package/dist/{chunk-L5GH7LLD.js.map → chunk-3MFWUG5O.js.map} +1 -1
- package/dist/{chunk-FQJNQW3G.js → chunk-3XQEOJCE.js} +8 -5
- package/dist/chunk-3XQEOJCE.js.map +1 -0
- package/dist/{chunk-JKFPRQB2.js → chunk-4LSZ5JWF.js} +3 -3
- package/dist/{chunk-JKFPRQB2.js.map → chunk-4LSZ5JWF.js.map} +1 -1
- package/dist/{chunk-V2QZG4IT.js → chunk-5HWFYYHW.js} +27 -9
- package/dist/chunk-5HWFYYHW.js.map +1 -0
- package/dist/{chunk-GEZYGBXY.js → chunk-6MVFCS46.js} +99 -42
- package/dist/chunk-6MVFCS46.js.map +1 -0
- package/dist/{chunk-NNPSBC7O.js → chunk-6WZSUS3U.js} +10 -9
- package/dist/chunk-6WZSUS3U.js.map +1 -0
- package/dist/chunk-6YRGP6PS.js +138 -0
- package/dist/chunk-6YRGP6PS.js.map +1 -0
- package/dist/{chunk-B5YHYI7E.js → chunk-ALANKV5Y.js} +23 -6
- package/dist/chunk-ALANKV5Y.js.map +1 -0
- package/dist/{chunk-IA6DCC3N.js → chunk-AUQPNDE5.js} +23 -13
- package/dist/chunk-AUQPNDE5.js.map +1 -0
- package/dist/{chunk-AKXALCUN.js → chunk-D7SW2E24.js} +4 -4
- package/dist/chunk-D7SW2E24.js.map +1 -0
- package/dist/{chunk-OXR7BXZA.js → chunk-DQIYYDFD.js} +4 -3
- package/dist/chunk-DQIYYDFD.js.map +1 -0
- package/dist/{chunk-HMNXNKDA.js → chunk-FCBYUN6F.js} +4 -4
- package/dist/{chunk-HMNXNKDA.js.map → chunk-FCBYUN6F.js.map} +1 -1
- package/dist/{chunk-2W7H43WL.js → chunk-FED6SJWM.js} +23 -14
- package/dist/chunk-FED6SJWM.js.map +1 -0
- package/dist/{chunk-7E7JNWOC.js → chunk-FEPIHXVI.js} +6 -5
- package/dist/chunk-FEPIHXVI.js.map +1 -0
- package/dist/{chunk-Y57NW6G7.js → chunk-G3YOSG3U.js} +4 -4
- package/dist/{chunk-Y57NW6G7.js.map → chunk-G3YOSG3U.js.map} +1 -1
- package/dist/chunk-GZN5CXMR.js +100 -0
- package/dist/chunk-GZN5CXMR.js.map +1 -0
- package/dist/{chunk-HCHGERDB.js → chunk-HCSZPBWV.js} +17 -115
- package/dist/chunk-HCSZPBWV.js.map +1 -0
- package/dist/{chunk-I4B3N3UX.js → chunk-HTVICHT4.js} +12 -7
- package/dist/chunk-HTVICHT4.js.map +1 -0
- package/dist/chunk-I7TC2C3I.js +163 -0
- package/dist/chunk-I7TC2C3I.js.map +1 -0
- package/dist/{chunk-7FPSQBWB.js → chunk-IBXYLO2J.js} +14 -13
- package/dist/chunk-IBXYLO2J.js.map +1 -0
- package/dist/{chunk-7KFUFAVP.js → chunk-IRYG6B5A.js} +9 -8
- package/dist/chunk-IRYG6B5A.js.map +1 -0
- package/dist/{chunk-2RQLPN4U.js → chunk-JCNEW4WJ.js} +8 -8
- package/dist/{chunk-2RQLPN4U.js.map → chunk-JCNEW4WJ.js.map} +1 -1
- package/dist/{chunk-SP6LCCTZ.js → chunk-KZDMVOL6.js} +35 -8
- package/dist/chunk-KZDMVOL6.js.map +1 -0
- package/dist/chunk-LR5U6TZZ.js +169 -0
- package/dist/chunk-LR5U6TZZ.js.map +1 -0
- package/dist/{chunk-MQHD3EJE.js → chunk-LZHZJWVM.js} +6 -4
- package/dist/chunk-LZHZJWVM.js.map +1 -0
- package/dist/{chunk-5EOMSWNO.js → chunk-MAM2X3MW.js} +5 -5
- package/dist/{chunk-5EOMSWNO.js.map → chunk-MAM2X3MW.js.map} +1 -1
- package/dist/{chunk-FSPS7TVD.js → chunk-MCMS4NMO.js} +5 -5
- package/dist/{chunk-FSPS7TVD.js.map → chunk-MCMS4NMO.js.map} +1 -1
- package/dist/{chunk-ZB5VMGKB.js → chunk-MV5DIE2T.js} +15 -4
- package/dist/chunk-MV5DIE2T.js.map +1 -0
- package/dist/chunk-NDI4HLQE.js +41 -0
- package/dist/chunk-NDI4HLQE.js.map +1 -0
- package/dist/{chunk-B4GNSSHU.js → chunk-NLJEQZQQ.js} +3 -3
- package/dist/{chunk-B4GNSSHU.js.map → chunk-NLJEQZQQ.js.map} +1 -1
- package/dist/{chunk-SBZJGFZ6.js → chunk-QHT4DCXE.js} +8 -7
- package/dist/chunk-QHT4DCXE.js.map +1 -0
- package/dist/{chunk-I4IJOLNA.js → chunk-RMUBCTEF.js} +5 -5
- package/dist/{chunk-I4IJOLNA.js.map → chunk-RMUBCTEF.js.map} +1 -1
- package/dist/{chunk-G3AD3NJG.js → chunk-RNTDM3RP.js} +9 -5
- package/dist/chunk-RNTDM3RP.js.map +1 -0
- package/dist/chunk-RPFN6ETQ.js +509 -0
- package/dist/chunk-RPFN6ETQ.js.map +1 -0
- package/dist/{chunk-HWBFRDX7.js → chunk-SI7C3W5M.js} +28 -9
- package/dist/chunk-SI7C3W5M.js.map +1 -0
- package/dist/chunk-TPOV3OCC.js +234 -0
- package/dist/chunk-TPOV3OCC.js.map +1 -0
- package/dist/{chunk-IANYMDKH.js → chunk-UBQ54W46.js} +4 -4
- package/dist/chunk-UBQ54W46.js.map +1 -0
- package/dist/{chunk-QVOBLRCM.js → chunk-UIKQ4X6W.js} +3 -3
- package/dist/{chunk-QVOBLRCM.js.map → chunk-UIKQ4X6W.js.map} +1 -1
- package/dist/chunk-UOWQH53N.js +70 -0
- package/dist/chunk-UOWQH53N.js.map +1 -0
- package/dist/{chunk-QRNQQIQM.js → chunk-WJUY6YWF.js} +52 -20
- package/dist/chunk-WJUY6YWF.js.map +1 -0
- package/dist/{chunk-3KARNPW4.js → chunk-WKIUMLRT.js} +3 -3
- package/dist/{chunk-3KARNPW4.js.map → chunk-WKIUMLRT.js.map} +1 -1
- package/dist/chunk-X6RB74JN.js +37 -0
- package/dist/chunk-X6RB74JN.js.map +1 -0
- package/dist/chunk-XQ6L2CM5.js +83 -0
- package/dist/chunk-XQ6L2CM5.js.map +1 -0
- package/dist/{chunk-RKCUXOU2.js → chunk-YUVKROMA.js} +44 -7
- package/dist/chunk-YUVKROMA.js.map +1 -0
- package/dist/components/action-icon/action-icon.d.ts +9 -2
- package/dist/components/action-icon/action-icon.d.ts.map +1 -1
- package/dist/components/action-icon/index.js +5 -1
- package/dist/components/alert/index.js +4 -4
- package/dist/components/anchor/anchor.d.ts +45 -0
- package/dist/components/anchor/anchor.d.ts.map +1 -0
- package/dist/components/anchor/index.d.ts +2 -0
- package/dist/components/anchor/index.d.ts.map +1 -0
- package/dist/components/anchor/index.js +11 -0
- package/dist/components/anchor/index.js.map +1 -0
- package/dist/components/app-shell/app-shell.d.ts +10 -6
- package/dist/components/app-shell/app-shell.d.ts.map +1 -1
- package/dist/components/app-shell/index.js +23 -24
- package/dist/components/app-shell/index.js.map +1 -1
- package/dist/components/autocomplete/autocomplete.d.ts +1 -1
- package/dist/components/autocomplete/autocomplete.d.ts.map +1 -1
- package/dist/components/autocomplete/index.js +15 -9
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/avatar/index.js +1 -1
- package/dist/components/breadcrumb/breadcrumb.d.ts +5 -1
- package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -1
- package/dist/components/breadcrumb/index.js +12 -0
- package/dist/components/breadcrumb/index.js.map +1 -1
- package/dist/components/button/button.d.ts +15 -2
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/index.js +5 -1
- package/dist/components/button-multi-select/index.js +6 -4
- package/dist/components/button-multi-select/index.js.map +1 -1
- package/dist/components/button-select/button-select-control.d.ts.map +1 -1
- package/dist/components/button-select/button-select.d.ts +2 -2
- package/dist/components/button-select/button-select.d.ts.map +1 -1
- package/dist/components/button-select/index.js +6 -4
- package/dist/components/button-select/index.js.map +1 -1
- package/dist/components/calendar/aliases.d.ts +16 -0
- package/dist/components/calendar/aliases.d.ts.map +1 -0
- package/dist/components/calendar/calendar-body.d.ts +11 -1
- package/dist/components/calendar/calendar-body.d.ts.map +1 -1
- package/dist/components/calendar/calendar.d.ts +8 -4
- package/dist/components/calendar/calendar.d.ts.map +1 -1
- package/dist/components/calendar/index.d.ts +2 -1
- package/dist/components/calendar/index.d.ts.map +1 -1
- package/dist/components/calendar/index.js +15 -5
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/calendar-heatmap/calendar-heatmap.d.ts.map +1 -1
- package/dist/components/calendar-heatmap/index.js +85 -73
- package/dist/components/calendar-heatmap/index.js.map +1 -1
- package/dist/components/camera/index.js +16 -14
- package/dist/components/carousel/index.js +3 -3
- package/dist/components/checkbox/checkbox.d.ts.map +1 -1
- package/dist/components/checkbox/index.js +2 -2
- package/dist/components/choice-card-group/index.js +2 -2
- package/dist/components/choice-card-group/index.js.map +1 -1
- package/dist/components/circular-progress/circular-progress.d.ts +22 -11
- package/dist/components/circular-progress/circular-progress.d.ts.map +1 -1
- package/dist/components/circular-progress/index.d.ts +1 -1
- package/dist/components/circular-progress/index.d.ts.map +1 -1
- package/dist/components/circular-progress/index.js +68 -49
- package/dist/components/circular-progress/index.js.map +1 -1
- package/dist/components/clipboard/index.js +7 -3
- package/dist/components/clipboard/index.js.map +1 -1
- package/dist/components/code/code.d.ts +10 -0
- package/dist/components/code/code.d.ts.map +1 -1
- package/dist/components/code/index.js +1 -0
- package/dist/components/code/index.js.map +1 -1
- package/dist/components/code-block/chrome.js +10 -6
- package/dist/components/code-block/index.js +10 -7
- package/dist/components/code-block/index.js.map +1 -1
- package/dist/components/combobox/combobox.d.ts +5 -3
- package/dist/components/combobox/combobox.d.ts.map +1 -1
- package/dist/components/combobox/index.js +12 -7
- package/dist/components/combobox-list/combobox-list.d.ts +1 -1
- package/dist/components/combobox-list/combobox-list.d.ts.map +1 -1
- package/dist/components/combobox-list/index.js +14 -9
- package/dist/components/compare/index.js +1 -1
- package/dist/components/data-list/data-list.d.ts +96 -0
- package/dist/components/data-list/data-list.d.ts.map +1 -0
- package/dist/components/data-list/index.d.ts +2 -0
- package/dist/components/data-list/index.d.ts.map +1 -0
- package/dist/components/data-list/index.js +147 -0
- package/dist/components/data-list/index.js.map +1 -0
- package/dist/components/data-table/data-table-group.d.ts.map +1 -1
- package/dist/components/data-table/data-table-placeholder.d.ts +12 -1
- package/dist/components/data-table/data-table-placeholder.d.ts.map +1 -1
- package/dist/components/data-table/data-table-stack.d.ts.map +1 -1
- package/dist/components/data-table/data-table.d.ts +5 -2
- package/dist/components/data-table/data-table.d.ts.map +1 -1
- package/dist/components/data-table/index.js +163 -168
- package/dist/components/data-table/index.js.map +1 -1
- package/dist/components/date-picker/aliases.d.ts +16 -0
- package/dist/components/date-picker/aliases.d.ts.map +1 -1
- package/dist/components/date-picker/date-picker.d.ts +22 -8
- package/dist/components/date-picker/date-picker.d.ts.map +1 -1
- package/dist/components/date-picker/index.d.ts +2 -2
- package/dist/components/date-picker/index.d.ts.map +1 -1
- package/dist/components/date-picker/index.js +34 -28
- package/dist/components/date-picker/index.js.map +1 -1
- package/dist/components/download-button/index.js +6 -2
- package/dist/components/drawer/drawer.d.ts +7 -4
- package/dist/components/drawer/drawer.d.ts.map +1 -1
- package/dist/components/drawer/index.js +11 -6
- package/dist/components/empty-state/empty-state.d.ts +57 -0
- package/dist/components/empty-state/empty-state.d.ts.map +1 -0
- package/dist/components/empty-state/index.d.ts +2 -0
- package/dist/components/empty-state/index.d.ts.map +1 -0
- package/dist/components/empty-state/index.js +8 -0
- package/dist/components/empty-state/index.js.map +1 -0
- package/dist/components/field/field.d.ts +20 -0
- package/dist/components/field/field.d.ts.map +1 -1
- package/dist/components/field/index.js +1 -1
- package/dist/components/fieldset/fieldset.d.ts +103 -0
- package/dist/components/fieldset/fieldset.d.ts.map +1 -0
- package/dist/components/fieldset/index.d.ts +2 -0
- package/dist/components/fieldset/index.d.ts.map +1 -0
- package/dist/components/fieldset/index.js +150 -0
- package/dist/components/fieldset/index.js.map +1 -0
- package/dist/components/file-item/index.js +10 -7
- package/dist/components/file-preview/file-preview.d.ts.map +1 -1
- package/dist/components/file-preview/index.js +10 -18
- package/dist/components/file-preview/index.js.map +1 -1
- package/dist/components/file-trigger/index.js +6 -2
- package/dist/components/file-upload/file-upload.d.ts.map +1 -1
- package/dist/components/file-upload/index.js +18 -14
- package/dist/components/file-upload/index.js.map +1 -1
- package/dist/components/gallery/index.js +3 -3
- package/dist/components/geodesic/a11y.d.ts +3 -3
- package/dist/components/geodesic/a11y.d.ts.map +1 -1
- package/dist/components/hover-card/hover-card.d.ts.map +1 -1
- package/dist/components/hover-card/index.js +10 -3
- package/dist/components/hover-card/index.js.map +1 -1
- package/dist/components/image/index.js +3 -3
- package/dist/components/image-cropper/index.js +9 -6
- package/dist/components/input/index.js +2 -2
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/kbd/index.js +3 -3
- package/dist/components/kbd/kbd.d.ts +4 -0
- package/dist/components/kbd/kbd.d.ts.map +1 -1
- package/dist/components/lightbox/index.js +13 -11
- package/dist/components/lightbox/index.js.map +1 -1
- package/dist/components/menu/index.js +9 -5
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/menu/menu.d.ts.map +1 -1
- package/dist/components/modal/index.js +11 -6
- package/dist/components/modal/modal.d.ts +10 -4
- package/dist/components/modal/modal.d.ts.map +1 -1
- package/dist/components/multi-combobox-list/index.js +13 -9
- package/dist/components/multi-combobox-list/multi-combobox-list.d.ts +1 -1
- package/dist/components/multi-combobox-list/multi-combobox-list.d.ts.map +1 -1
- package/dist/components/multi-select/index.js +13 -10
- package/dist/components/multi-select/index.js.map +1 -1
- package/dist/components/multi-select/multi-select.d.ts +1 -1
- package/dist/components/multi-select/multi-select.d.ts.map +1 -1
- package/dist/components/nav-link/index.js +4 -4
- package/dist/components/nav-link/tanstack.js +4 -4
- package/dist/components/notification/index.js +6 -6
- package/dist/components/notification/index.js.map +1 -1
- package/dist/components/number-input/index.js +11 -7
- package/dist/components/number-input/number-input.d.ts +1 -1
- package/dist/components/number-input/number-input.d.ts.map +1 -1
- package/dist/components/overlays/dialog-parts.d.ts +10 -1
- package/dist/components/overlays/dialog-parts.d.ts.map +1 -1
- package/dist/components/overlays/index.js +13 -8
- package/dist/components/overlays/index.js.map +1 -1
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/index.d.ts.map +1 -0
- package/dist/components/pagination/index.js +362 -0
- package/dist/components/pagination/index.js.map +1 -0
- package/dist/components/pagination/pagination.d.ts +147 -0
- package/dist/components/pagination/pagination.d.ts.map +1 -0
- package/dist/components/password-input/index.js +6 -5
- package/dist/components/password-input/index.js.map +1 -1
- package/dist/components/password-input/password-input.d.ts +1 -1
- package/dist/components/password-input/password-input.d.ts.map +1 -1
- package/dist/components/phone-input/index.js +14 -11
- package/dist/components/phone-input/index.js.map +1 -1
- package/dist/components/phone-input/phone-input.d.ts +1 -1
- package/dist/components/phone-input/phone-input.d.ts.map +1 -1
- package/dist/components/photo-capture/index.js +19 -17
- package/dist/components/photo-capture/index.js.map +1 -1
- package/dist/components/pills-input/index.js +4 -4
- package/dist/components/pills-input/pills-input.d.ts +1 -1
- package/dist/components/pills-input/pills-input.d.ts.map +1 -1
- package/dist/components/pin-input/index.js +6 -5
- package/dist/components/pin-input/index.js.map +1 -1
- package/dist/components/pin-input/pin-input.d.ts.map +1 -1
- package/dist/components/popover/index.js +7 -2
- package/dist/components/popover/popover.d.ts +41 -16
- package/dist/components/popover/popover.d.ts.map +1 -1
- package/dist/components/progress/index.d.ts +1 -1
- package/dist/components/progress/index.d.ts.map +1 -1
- package/dist/components/progress/index.js +4 -1
- package/dist/components/progress/progress.d.ts +22 -14
- package/dist/components/progress/progress.d.ts.map +1 -1
- package/dist/components/prose/index.d.ts +2 -0
- package/dist/components/prose/index.d.ts.map +1 -0
- package/dist/components/prose/index.js +17 -0
- package/dist/components/prose/index.js.map +1 -0
- package/dist/components/prose/prose.d.ts +49 -0
- package/dist/components/prose/prose.d.ts.map +1 -0
- package/dist/components/prose/styles.css +593 -0
- package/dist/components/radio-group/index.js +9 -3
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/radio-group/radio-group.d.ts.map +1 -1
- package/dist/components/rating/index.js +3 -2
- package/dist/components/rating/index.js.map +1 -1
- package/dist/components/rating/rating.d.ts.map +1 -1
- package/dist/components/schedule/index.js +10 -8
- package/dist/components/schedule/index.js.map +1 -1
- package/dist/components/scroll-area/index.d.ts +2 -0
- package/dist/components/scroll-area/index.d.ts.map +1 -0
- package/dist/components/scroll-area/index.js +10 -0
- package/dist/components/scroll-area/index.js.map +1 -0
- package/dist/components/scroll-area/scroll-area.d.ts +150 -0
- package/dist/components/scroll-area/scroll-area.d.ts.map +1 -0
- package/dist/components/segment-group/index.js +2 -2
- package/dist/components/segment-group/segment-group.d.ts.map +1 -1
- package/dist/components/select/index.js +12 -8
- package/dist/components/select/select.d.ts +1 -1
- package/dist/components/select/select.d.ts.map +1 -1
- package/dist/components/slider/index.js +2 -2
- package/dist/components/slider/slider.d.ts.map +1 -1
- package/dist/components/splitter/index.d.ts +2 -0
- package/dist/components/splitter/index.d.ts.map +1 -0
- package/dist/components/splitter/index.js +373 -0
- package/dist/components/splitter/index.js.map +1 -0
- package/dist/components/splitter/splitter.d.ts +159 -0
- package/dist/components/splitter/splitter.d.ts.map +1 -0
- package/dist/components/spotlight/index.js +23 -22
- package/dist/components/spotlight/index.js.map +1 -1
- package/dist/components/spotlight/spotlight.d.ts.map +1 -1
- package/dist/components/steps/index.d.ts +4 -0
- package/dist/components/steps/index.d.ts.map +1 -0
- package/dist/components/steps/index.js +478 -0
- package/dist/components/steps/index.js.map +1 -0
- package/dist/components/steps/steps-data.d.ts +78 -0
- package/dist/components/steps/steps-data.d.ts.map +1 -0
- package/dist/components/steps/steps.d.ts +183 -0
- package/dist/components/steps/steps.d.ts.map +1 -0
- package/dist/components/switch/index.js +4 -3
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/switch/switch.d.ts.map +1 -1
- package/dist/components/table-of-contents/index.d.ts +2 -0
- package/dist/components/table-of-contents/index.d.ts.map +1 -0
- package/dist/components/table-of-contents/index.js +471 -0
- package/dist/components/table-of-contents/index.js.map +1 -0
- package/dist/components/table-of-contents/table-of-contents.d.ts +173 -0
- package/dist/components/table-of-contents/table-of-contents.d.ts.map +1 -0
- package/dist/components/tags-input/index.js +12 -9
- package/dist/components/tags-input/index.js.map +1 -1
- package/dist/components/tags-input/tags-input.d.ts +1 -1
- package/dist/components/tags-input/tags-input.d.ts.map +1 -1
- package/dist/components/text-input/index.js +2 -2
- package/dist/components/textarea/index.js +8 -6
- package/dist/components/textarea/index.js.map +1 -1
- package/dist/components/textarea/textarea.d.ts.map +1 -1
- package/dist/components/time-input/index.js +11 -9
- package/dist/components/time-input/index.js.map +1 -1
- package/dist/components/tooltip/index.js +1 -1
- package/dist/components/tooltip/tooltip.d.ts +3 -8
- package/dist/components/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/tour/conditions.d.ts +83 -0
- package/dist/components/tour/conditions.d.ts.map +1 -0
- package/dist/components/tour/create-tours.d.ts +49 -0
- package/dist/components/tour/create-tours.d.ts.map +1 -0
- package/dist/components/tour/index.d.ts +6 -0
- package/dist/components/tour/index.d.ts.map +1 -0
- package/dist/components/tour/index.js +1449 -0
- package/dist/components/tour/index.js.map +1 -0
- package/dist/components/tour/runtime.d.ts +57 -0
- package/dist/components/tour/runtime.d.ts.map +1 -0
- package/dist/components/tour/storage.d.ts +14 -0
- package/dist/components/tour/storage.d.ts.map +1 -0
- package/dist/components/tour/store.d.ts +62 -0
- package/dist/components/tour/store.d.ts.map +1 -0
- package/dist/components/tour/tour.d.ts +77 -0
- package/dist/components/tour/tour.d.ts.map +1 -0
- package/dist/components/tour/types.d.ts +680 -0
- package/dist/components/tour/types.d.ts.map +1 -0
- package/dist/components/tree/index.d.ts +3 -0
- package/dist/components/tree/index.d.ts.map +1 -0
- package/dist/components/tree/index.js +457 -0
- package/dist/components/tree/index.js.map +1 -0
- package/dist/components/tree/tree-row.d.ts +72 -0
- package/dist/components/tree/tree-row.d.ts.map +1 -0
- package/dist/components/tree/tree.d.ts +193 -0
- package/dist/components/tree/tree.d.ts.map +1 -0
- package/dist/components/tree-multi-select/index.js +31 -54
- package/dist/components/tree-multi-select/index.js.map +1 -1
- package/dist/components/tree-multi-select/tree-multi-select.d.ts +16 -1
- package/dist/components/tree-multi-select/tree-multi-select.d.ts.map +1 -1
- package/dist/components/tree-select/index.js +30 -24
- package/dist/components/tree-select/index.js.map +1 -1
- package/dist/components/tree-select/tree-popover.d.ts +20 -31
- package/dist/components/tree-select/tree-popover.d.ts.map +1 -1
- package/dist/components/tree-select/tree-select.d.ts +1 -1
- package/dist/components/tree-select/tree-select.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/lib/date-predicates.d.ts +7 -5
- package/dist/lib/date-predicates.d.ts.map +1 -1
- package/dist/lib/date-value.d.ts +20 -0
- package/dist/lib/date-value.d.ts.map +1 -1
- package/dist/lib/floating-arrow.d.ts +53 -0
- package/dist/lib/floating-arrow.d.ts.map +1 -0
- package/dist/lib/focus-return.d.ts +53 -0
- package/dist/lib/focus-return.d.ts.map +1 -0
- package/dist/lib/meter.d.ts +104 -0
- package/dist/lib/meter.d.ts.map +1 -0
- package/dist/lib/overlay-layer.d.ts +26 -8
- package/dist/lib/overlay-layer.d.ts.map +1 -1
- package/dist/lib/pressed.d.ts +92 -0
- package/dist/lib/pressed.d.ts.map +1 -0
- package/dist/lib/tree-data.d.ts +18 -2
- package/dist/lib/tree-data.d.ts.map +1 -1
- package/dist/lib/use-pagination.d.ts +102 -0
- package/dist/lib/use-pagination.d.ts.map +1 -0
- package/dist/lib/use-scroll-spy.d.ts +126 -0
- package/dist/lib/use-scroll-spy.d.ts.map +1 -0
- package/dist/theme.css +39 -3
- package/package.json +1 -1
- package/src/as-child.contract.test.tsx +283 -1
- package/src/components/action-icon/action-icon.tsx +34 -4
- package/src/components/anchor/anchor.test.tsx +232 -0
- package/src/components/anchor/anchor.tsx +187 -0
- package/src/components/anchor/index.ts +12 -0
- package/src/components/app-shell/app-shell.test.tsx +15 -7
- package/src/components/app-shell/app-shell.tsx +27 -20
- package/src/components/autocomplete/autocomplete.tsx +11 -3
- package/src/components/breadcrumb/breadcrumb.test.tsx +24 -0
- package/src/components/breadcrumb/breadcrumb.tsx +20 -1
- package/src/components/button/button-pressed.test.tsx +202 -0
- package/src/components/button/button.tsx +48 -6
- package/src/components/button-select/button-select-control.tsx +2 -2
- package/src/components/button-select/button-select.tsx +22 -2
- package/src/components/calendar/aliases.tsx +28 -0
- package/src/components/calendar/calendar-body.tsx +310 -210
- package/src/components/calendar/calendar.tsx +43 -12
- package/src/components/calendar/index.ts +7 -1
- package/src/components/calendar/month-year-calendar.test.tsx +106 -0
- package/src/components/calendar-heatmap/calendar-heatmap.tsx +88 -73
- package/src/components/checkbox/checkbox.tsx +7 -2
- package/src/components/choice-card-group/choice-card-group.tsx +2 -2
- package/src/components/circular-progress/circular-progress.test.tsx +35 -0
- package/src/components/circular-progress/circular-progress.tsx +116 -59
- package/src/components/circular-progress/index.ts +1 -0
- package/src/components/code/code.test.tsx +16 -0
- package/src/components/code/code.tsx +11 -0
- package/src/components/combobox/combobox.tsx +63 -28
- package/src/components/combobox-list/combobox-list.tsx +11 -3
- package/src/components/data-list/data-list.test.tsx +149 -0
- package/src/components/data-list/data-list.tsx +268 -0
- package/src/components/data-list/index.ts +9 -0
- package/src/components/data-table/data-table-group.test.tsx +16 -0
- package/src/components/data-table/data-table-group.tsx +15 -2
- package/src/components/data-table/data-table-placeholder.tsx +28 -36
- package/src/components/data-table/data-table-stack.tsx +33 -39
- package/src/components/data-table/data-table.test.tsx +31 -0
- package/src/components/data-table/data-table.tsx +41 -42
- package/src/components/date-picker/aliases.tsx +28 -0
- package/src/components/date-picker/date-picker.test.tsx +29 -0
- package/src/components/date-picker/date-picker.tsx +164 -45
- package/src/components/date-picker/index.ts +5 -1
- package/src/components/date-picker/month-year-picker.test.tsx +362 -0
- package/src/components/drawer/drawer.test.tsx +41 -0
- package/src/components/drawer/drawer.tsx +7 -1
- package/src/components/empty-state/empty-state.test.tsx +109 -0
- package/src/components/empty-state/empty-state.tsx +180 -0
- package/src/components/empty-state/index.ts +9 -0
- package/src/components/field/field.tsx +35 -1
- package/src/components/fieldset/fieldset.test.tsx +352 -0
- package/src/components/fieldset/fieldset.tsx +268 -0
- package/src/components/fieldset/index.ts +11 -0
- package/src/components/file-preview/file-preview.test.tsx +2 -1
- package/src/components/file-preview/file-preview.tsx +7 -13
- package/src/components/file-upload/file-upload.tsx +14 -5
- package/src/components/hover-card/hover-card.tsx +5 -1
- package/src/components/input/input.tsx +12 -5
- package/src/components/kbd/kbd.test.tsx +13 -0
- package/src/components/kbd/kbd.tsx +6 -0
- package/src/components/menu/menu.tsx +6 -2
- package/src/components/modal/modal.test.tsx +41 -0
- package/src/components/modal/modal.tsx +17 -9
- package/src/components/multi-combobox-list/multi-combobox-list.tsx +11 -3
- package/src/components/multi-select/multi-select.tsx +11 -3
- package/src/components/notification/create-notifier.tsx +1 -1
- package/src/components/number-input/number-input.tsx +12 -3
- package/src/components/overlays/dialog-parts.tsx +42 -5
- package/src/components/pagination/index.ts +19 -0
- package/src/components/pagination/pagination.test.tsx +187 -0
- package/src/components/pagination/pagination.tsx +563 -0
- package/src/components/password-input/password-input.tsx +12 -3
- package/src/components/phone-input/phone-input.tsx +12 -3
- package/src/components/pills-input/pills-input.tsx +7 -2
- package/src/components/pin-input/pin-input.tsx +13 -4
- package/src/components/popover/popover.tsx +87 -17
- package/src/components/progress/index.ts +1 -0
- package/src/components/progress/progress.test.tsx +102 -0
- package/src/components/progress/progress.tsx +116 -62
- package/src/components/prose/index.ts +1 -0
- package/src/components/prose/prose.test.tsx +90 -0
- package/src/components/prose/prose.tsx +60 -0
- package/src/components/prose/styles.css +593 -0
- package/src/components/radio-group/radio-group.tsx +8 -3
- package/src/components/rating/rating.tsx +5 -2
- package/src/components/scroll-area/index.ts +18 -0
- package/src/components/scroll-area/scroll-area.test.tsx +184 -0
- package/src/components/scroll-area/scroll-area.tsx +448 -0
- package/src/components/segment-group/segment-group.tsx +2 -2
- package/src/components/select/select.tsx +37 -18
- package/src/components/slider/slider.tsx +2 -2
- package/src/components/splitter/index.ts +15 -0
- package/src/components/splitter/splitter.test.tsx +244 -0
- package/src/components/splitter/splitter.tsx +625 -0
- package/src/components/spotlight/spotlight.test.tsx +34 -26
- package/src/components/spotlight/spotlight.tsx +7 -9
- package/src/components/steps/index.ts +21 -0
- package/src/components/steps/steps-data.tsx +179 -0
- package/src/components/steps/steps.test.tsx +235 -0
- package/src/components/steps/steps.tsx +686 -0
- package/src/components/switch/switch.tsx +7 -2
- package/src/components/table-of-contents/index.ts +17 -0
- package/src/components/table-of-contents/table-of-contents.test.tsx +289 -0
- package/src/components/table-of-contents/table-of-contents.tsx +708 -0
- package/src/components/tags-input/tags-input.tsx +12 -3
- package/src/components/textarea/textarea.tsx +15 -5
- package/src/components/tooltip/tooltip.tsx +8 -17
- package/src/components/tour/conditions.test.ts +527 -0
- package/src/components/tour/conditions.ts +445 -0
- package/src/components/tour/create-tours.tsx +150 -0
- package/src/components/tour/index.ts +86 -0
- package/src/components/tour/runtime.ts +187 -0
- package/src/components/tour/storage.test.ts +68 -0
- package/src/components/tour/storage.ts +44 -0
- package/src/components/tour/store.test.tsx +784 -0
- package/src/components/tour/store.ts +661 -0
- package/src/components/tour/tour.test.tsx +318 -0
- package/src/components/tour/tour.tsx +773 -0
- package/src/components/tour/tour.types.test.ts +185 -0
- package/src/components/tour/types.ts +904 -0
- package/src/components/tree/index.ts +24 -0
- package/src/components/tree/tree-row.tsx +179 -0
- package/src/components/tree/tree.test.tsx +296 -0
- package/src/components/tree/tree.tsx +796 -0
- package/src/components/tree-multi-select/tree-multi-select.tsx +29 -58
- package/src/components/tree-select/tree-popover.tsx +26 -107
- package/src/components/tree-select/tree-select.tsx +24 -16
- package/src/icon-stroke.test.tsx +2 -0
- package/src/index.ts +16 -0
- package/src/lib/date-predicates.test.ts +46 -0
- package/src/lib/date-predicates.ts +44 -24
- package/src/lib/date-value.test.ts +24 -1
- package/src/lib/date-value.ts +42 -1
- package/src/lib/floating-arrow.tsx +73 -0
- package/src/lib/focus-return.test.tsx +143 -0
- package/src/lib/focus-return.ts +106 -0
- package/src/lib/meter.test.ts +40 -0
- package/src/lib/meter.ts +159 -0
- package/src/lib/overlay-layer.test.tsx +47 -1
- package/src/lib/overlay-layer.tsx +65 -8
- package/src/lib/pressed.ts +130 -0
- package/src/lib/tree-data.ts +42 -2
- package/src/lib/use-pagination.test.ts +105 -0
- package/src/lib/use-pagination.ts +179 -0
- package/src/lib/use-scroll-spy.test.tsx +238 -0
- package/src/lib/use-scroll-spy.ts +336 -0
- package/src/theme.css +39 -3
- package/src/theme.test.ts +29 -1
- package/src/visually-hidden-containment.test.tsx +9 -0
- package/dist/chunk-2W7H43WL.js.map +0 -1
- package/dist/chunk-7E7JNWOC.js.map +0 -1
- package/dist/chunk-7FPSQBWB.js.map +0 -1
- package/dist/chunk-7KFUFAVP.js.map +0 -1
- package/dist/chunk-AKXALCUN.js.map +0 -1
- package/dist/chunk-B5YHYI7E.js.map +0 -1
- package/dist/chunk-FQJNQW3G.js.map +0 -1
- package/dist/chunk-G3AD3NJG.js.map +0 -1
- package/dist/chunk-GEZYGBXY.js.map +0 -1
- package/dist/chunk-HCHGERDB.js.map +0 -1
- package/dist/chunk-HWBFRDX7.js.map +0 -1
- package/dist/chunk-I4B3N3UX.js.map +0 -1
- package/dist/chunk-IA6DCC3N.js.map +0 -1
- package/dist/chunk-IANYMDKH.js.map +0 -1
- package/dist/chunk-MQHD3EJE.js.map +0 -1
- package/dist/chunk-NNPSBC7O.js.map +0 -1
- package/dist/chunk-OXR7BXZA.js.map +0 -1
- package/dist/chunk-QKSLDQM2.js +0 -120
- package/dist/chunk-QKSLDQM2.js.map +0 -1
- package/dist/chunk-QRNQQIQM.js.map +0 -1
- package/dist/chunk-RKCUXOU2.js.map +0 -1
- package/dist/chunk-S5CQRCTF.js +0 -426
- package/dist/chunk-S5CQRCTF.js.map +0 -1
- package/dist/chunk-SBZJGFZ6.js.map +0 -1
- package/dist/chunk-SP6LCCTZ.js.map +0 -1
- package/dist/chunk-TUP7WXQE.js.map +0 -1
- package/dist/chunk-V2QZG4IT.js.map +0 -1
- package/dist/chunk-X6DESK37.js.map +0 -1
- package/dist/chunk-ZB5VMGKB.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Progress } from './chunk-
|
|
1
|
+
import { Progress } from './chunk-6YRGP6PS.js';
|
|
2
2
|
import { FILE_KIND_ICONS } from './chunk-SDVZFXQ2.js';
|
|
3
|
-
import { Image } from './chunk-
|
|
4
|
-
import { Button } from './chunk-
|
|
3
|
+
import { Image } from './chunk-G3YOSG3U.js';
|
|
4
|
+
import { Button } from './chunk-KZDMVOL6.js';
|
|
5
5
|
import { formatFileSize, useObjectUrl, fileKind } from './chunk-DTFSCR3U.js';
|
|
6
6
|
import { useLocale, useTimeZone } from './chunk-OBSZ4NE2.js';
|
|
7
7
|
import { CloseIcon } from './chunk-6YNLRQ25.js';
|
|
@@ -336,5 +336,5 @@ var FileItem = Object.assign(FileItemComponent, {
|
|
|
336
336
|
});
|
|
337
337
|
|
|
338
338
|
export { FileItem, isInFlight };
|
|
339
|
-
//# sourceMappingURL=chunk-
|
|
340
|
-
//# sourceMappingURL=chunk-
|
|
339
|
+
//# sourceMappingURL=chunk-MCMS4NMO.js.map
|
|
340
|
+
//# sourceMappingURL=chunk-MCMS4NMO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/file-item/file-item.tsx"],"names":["Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;AAmGA,IAAM,oBAAA,GAAuD;AAAA,EAC3D,MAAA,EAAQ,CAAC,IAAA,KAAS,CAAA,OAAA,EAAU,IAAI,CAAA,CAAA;AAAA,EAChC,MAAA,EAAQ,CAAC,IAAA,KAAS,CAAA,iBAAA,EAAoB,IAAI,CAAA,CAAA;AAAA,EAC1C,KAAA,EAAO,OAAA;AAAA,EACP,MAAA,EAAQ,QAAA;AAAA,EACR,UAAA,EAAY,kBAAA;AAAA,EACZ,IAAA,EAAM,UAAA;AAAA,EACN,MAAA,EAAQ,eAAA;AAAA,EACR,YAAA,EAAc,CAAC,MAAA,EAAQ,IAAA,KACrB,KAAA,CAAM,MAAM,CAAA,CACT,IAAA,CAAK,WAAA,EAAa,MAAM,CAAA,UAAA,EAAa,IAAI,CAAA,CAAE,CAAA,CAC3C,IAAA,CAAK,MAAA,EAAQ,MAAM,CAAA,EAAG,IAAI,CAAA,SAAA,CAAW,CAAA,CACrC,IAAA,CAAK,OAAA,EAAS,MAAM,CAAA,EAAG,IAAI,CAAA,iBAAA,CAAmB,CAAA,CAC9C,UAAA;AACP,CAAA;AAGA,IAAM,aAAA,GAAqD;AAAA,EACzD,GAAG,eAAA;AAAA,EACH,MAAA,sBAAS,SAAA,EAAA,EAAU,CAAA;AAAA,EACnB,uBAAO,GAAA,CAAC,QAAA,EAAA,EAAS,aAAA,EAAW,IAAA,EAAC,WAAW,UAAA,EAAY,CAAA;AAAA,EACpD,sBAAM,GAAA,CAAC,WAAA,EAAA,EAAY,aAAA,EAAW,IAAA,EAAC,WAAW,UAAA,EAAY;AACxD,CAAA;AAEA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,QAAA,EAAU;AAAA,KAAA,EAChD,CAAA;AAAA,IACC,WAAW,IAAA,oBAAQ,GAAA,CAAC,WAAQ,SAAA,EAAW,UAAA,EAAY,SAAU,QAAA,EAAA,OAAA,EAAQ,CAAA;AAAA,IACrE,OAAA,IAAW,IAAA,CAAK,MAAA,KAAW,OAAA,oBAC1B,GAAA,CAAC,SAAM,OAAA,EAAS,OAAA,EAAS,SAAA,EAAW,UAAA,EAAY,KAAA,EAAO,CAAA;AAAA,IAExD,2BAAW,GAAA,CAAC,MAAA,EAAA,EAAO,SAAS,OAAA,EAAS,SAAA,EAAW,YAAY,MAAA,EAAQ;AAAA,GAAA,EACvE,CAAA;AAEF,EAAA;AAAA;AAAA;AAAA,wBAGG,IAAA,EAAA,EAAM,GAAG,MAAM,OAAA,EAAkB,SAAA,EAAW,GAAG,SAAA,EAAW,UAAA,EAAY,IAAI,CAAA,EACxE,oBACC,kBAAA,CAAmB,QAAA,EAAU,CAAC,GAAA,qBAC5B,IAAA,CAAAA,UAAA,EACG,QAAA,EAAA;AAAA,MAAA,GAAA;AAAA,MACA;AAAA,KAAA,EACH,CACD,CAAA,mBAED,IAAA,CAAAA,QAAAA,EAAA,EACG,QAAA,EAAA;AAAA,MAAA,GAAA;AAAA,MACA;AAAA,KAAA,EACH,CAAA,EAEJ;AAAA;AAEJ;AAOO,IAAM,QAAA,GAAW,MAAA,CAAO,MAAA,CAAO,iBAAA,EAAmB;AAAA,EACvD,IAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,QAAA,EAAU,WAAA;AAAA,EACV,OAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAC","file":"chunk-FSPS7TVD.js","sourcesContent":["\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { CircleCheck, RotateCw } from \"lucide-react\"\nimport {\n createContext,\n Fragment,\n type ReactNode,\n type Ref,\n useContext,\n useId,\n useState,\n} from \"react\"\nimport { match } from \"ts-pattern\"\nimport { composeChildren, type NoAsChild, withAsChildContent } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { FILE_KIND_ICONS } from \"../../lib/file-kind-icons\"\nimport { type FileKind, fileKind, formatFileSize } from \"../../lib/files\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { useLocale, useTimeZone } from \"../../lib/intl\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES, TYPOGRAPHY_SHADE_CLASSES } from \"../../lib/typography-size\"\nimport { useObjectUrl } from \"../../lib/use-object-url\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport { Image } from \"../image/image\"\nimport { CloseIcon } from \"../popover/icons\"\nimport { Progress, type ProgressProps } from \"../progress/progress\"\n\n/**\n * FileItem — one file as a row: its icon or thumbnail, its name, a meta line\n * (size, date, upload status) and its actions.\n *\n * <FileItem file={pickedFile} onRemove={() => remove(pickedFile)} />\n * <FileItem file={{ name: \"contract.pdf\", size: 248_213, date: doc.signedAt }} actions={…} />\n *\n * The same row serves a `File` the visitor just picked and a document stored\n * on a server, described by `{ name, size?, type?, date?, src? }` (`src` is a\n * thumbnail or preview URL). `FileUpload` renders its list with it.\n *\n * Upload state comes in through `status` (`queued → uploading → processing →\n * done | error`) and `progress` (0–1), so a queue only has to feed them:\n * uploading shows a determinate bar named after the file, processing an\n * indeterminate one, an error its message and a Retry button. Screen readers\n * hear the start, the end and a failure through a polite status region,\n * never each progress tick. A row a queue drives (`itemProps`) stays quiet\n * instead (`announce={false}`), and `FileQueueSummary` speaks for the run.\n *\n * Sizes and dates follow the `IntlProvider` locale and time zone; every\n * string goes through `translations`, every icon through `icons`.\n */\n\nexport type FileItemStatus = \"idle\" | \"queued\" | \"uploading\" | \"processing\" | \"done\" | \"error\"\n\n/** A file that lives on a server: a stored document rather than a picked `File`. */\nexport type FileDescriptor = {\n name: string\n /** In bytes. */\n size?: number\n /** MIME type. Picks the icon, with the name's extension as the fallback. */\n type?: string\n /** When it was uploaded, signed, last changed: whatever the app's meta line means. A date-only\n * ISO string (`\"2026-10-01\"`) is UTC midnight, so it can read as the day before west of UTC;\n * pass a full timestamp or a `Date`. */\n date?: Date | string | number\n /** A thumbnail or preview URL, shown in place of the kind icon. */\n src?: string\n}\n\nexport type FileItemFile = File | FileDescriptor\n\nexport type FileItemIconSlot = FileKind | \"remove\" | \"retry\" | \"done\"\nexport type FileItemIcons = IconMap<FileItemIconSlot>\n\n/** The statuses the status region speaks up for. The others are steps in between. */\nexport type FileItemAnnouncedStatus = \"uploading\" | \"done\" | \"error\"\n\nexport type FileItemTranslations = {\n /** The remove button's accessible name. @default (name) => `Remove ${name}` */\n remove?: (name: string) => string\n /** The same button's name while the file is queued or in flight.\n * @default (name) => `Cancel upload of ${name}` */\n cancel?: (name: string) => string\n /** The retry button's text (it is described by the file name). @default \"Retry\" */\n retry?: string\n /** @default \"Queued\" */\n queued?: string\n /** The meta line and the indeterminate bar's value text. @default \"Processing…\" */\n processing?: string\n /** @default \"Uploaded\" */\n done?: string\n /** Shown for an error without an `error` message. @default \"Upload failed\" */\n failed?: string\n /** What the status region says on each announced transition. The `error` message, when\n * there is one, follows it. */\n announcement?: (status: FileItemAnnouncedStatus, name: string) => string\n}\n\nconst DEFAULT_TRANSLATIONS: Required<FileItemTranslations> = {\n remove: (name) => `Remove ${name}`,\n cancel: (name) => `Cancel upload of ${name}`,\n retry: \"Retry\",\n queued: \"Queued\",\n processing: \"Processing…\",\n done: \"Uploaded\",\n failed: \"Upload failed\",\n announcement: (status, name) =>\n match(status)\n .with(\"uploading\", () => `Uploading ${name}`)\n .with(\"done\", () => `${name} uploaded`)\n .with(\"error\", () => `${name} failed to upload`)\n .exhaustive(),\n}\n\n/** The default icons, one per kind plus the row's own buttons. */\nconst DEFAULT_ICONS: Record<FileItemIconSlot, ReactNode> = {\n ...FILE_KIND_ICONS,\n remove: <CloseIcon />,\n retry: <RotateCw aria-hidden className={iconStroke} />,\n done: <CircleCheck aria-hidden className={iconStroke} />,\n}\n\nconst ANNOUNCED = new Set<FileItemStatus>([\"uploading\", \"done\", \"error\"])\nconst isAnnounced = (status: FileItemStatus | undefined): status is FileItemAnnouncedStatus =>\n status !== undefined && ANNOUNCED.has(status)\n\n/** Statuses where the remove button stops the upload rather than dropping a finished file. */\nconst IN_FLIGHT = new Set<FileItemStatus>([\"queued\", \"uploading\", \"processing\"])\n\n/** Whether the × stops an upload (and calls `onCancel`) rather than dropping the file. For a\n * layout composed from the parts, which wires `Remove` itself. */\nexport const isInFlight = (status: FileItemStatus | undefined): boolean =>\n status !== undefined && IN_FLIGHT.has(status)\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\ntype Shared = {\n name: string\n kind: FileKind\n size?: number\n date?: Date\n src?: string\n /** The picked file itself, for an object-URL thumbnail. */\n blob?: File\n status?: FileItemStatus\n progress?: number\n error?: ReactNode\n disabled: boolean\n thumbnails: boolean\n nameId: string\n locale: string\n timeZone: string\n t: Required<FileItemTranslations>\n icons: Record<FileItemIconSlot, ReactNode>\n}\n\nconst SharedContext = createContext<Shared | null>(null)\n\nconst useShared = () => {\n const shared = useContext(SharedContext)\n if (!shared) throw new Error(\"FileItem parts must be rendered within <FileItem.Root>.\")\n return shared\n}\n\n/** A `File` and a descriptor, read the same way. */\ntype FileFacts = Omit<FileDescriptor, \"date\"> & { date?: Date; blob?: File }\n\n/** An unparseable `date` is dropped rather than shown as \"Invalid Date\". */\nconst toDate = (value: FileDescriptor[\"date\"]): Date | undefined => {\n const date = value === undefined ? undefined : new Date(value)\n return date && !Number.isNaN(date.getTime()) ? date : undefined\n}\n\nconst readFile = (file: FileItemFile): FileFacts =>\n file instanceof File\n ? { name: file.name, size: file.size, type: file.type, blob: file }\n : { name: file.name, size: file.size, type: file.type, src: file.src, date: toDate(file.date) }\n\n// ---------------------------------------------------------------------------\n// Parts\n// ---------------------------------------------------------------------------\n\nexport type FileItemRootProps = HTMLArkProps<\"div\"> &\n WithTestId & {\n /** A picked `File`, or a stored document's `{ name, size?, type?, date?, src? }`. */\n file: FileItemFile\n /** Upload state. Pass it from the first render (`\"idle\"` or `\"queued\"`): the status\n * region exists only with a status, and announces changes, not its first value. */\n status?: FileItemStatus\n /** Upload progress from 0 to 1, read while `status` is `\"uploading\"`. Without it the bar\n * is indeterminate. */\n progress?: number\n /** Why the upload failed, shown and announced while `status` is `\"error\"`. */\n error?: ReactNode\n /** Keep a status region that announces this row's upload. Off for a row a queue drives:\n * `useFileQueue`'s `itemProps` pass `false`, and one `FileQueueSummary` speaks for every\n * row, so 400 rows don't announce 800 times. @default true */\n announce?: boolean\n /** Disables the row's own buttons (remove, retry). */\n disabled?: boolean\n /** Show image files and `src` as thumbnails. Off, every file shows its kind icon, and no\n * object URL is created. @default true */\n thumbnails?: boolean\n /** Replaces the default icons: one per `FileKind`, plus `remove`, `retry` and `done`. */\n icons?: FileItemIcons\n /** Overrides the row's strings. A partial override keeps the other defaults. */\n translations?: FileItemTranslations\n ref?: Ref<HTMLDivElement>\n }\n\nconst Root = ({\n file,\n status,\n progress,\n error,\n announce = true,\n disabled = false,\n thumbnails = true,\n icons,\n translations,\n asChild,\n children,\n className,\n testId,\n ...rest\n}: FileItemRootProps) => {\n const locale = useLocale()\n const timeZone = useTimeZone()\n const nameId = useId()\n const t = { ...DEFAULT_TRANSLATIONS, ...translations }\n const { type, ...facts } = readFile(file)\n const kind = fileKind(type, facts.name)\n\n // Only a change of status is announced, never the first one (a stored document mounting as\n // \"done\" is not news) and never a progress tick. State adjusted during render, React's own\n // pattern for \"remember the previous prop\", so the region's text lands in the same commit.\n const [seen, setSeen] = useState(status)\n const [announced, setAnnounced] = useState<FileItemAnnouncedStatus | null>(null)\n if (seen !== status) {\n setSeen(status)\n setAnnounced(isAnnounced(status) ? status : null)\n }\n\n const shared: Shared = {\n ...facts,\n kind,\n status,\n progress,\n error,\n disabled,\n thumbnails,\n nameId,\n locale,\n timeZone,\n t,\n icons: mergeIcons(DEFAULT_ICONS, icons),\n }\n\n const region = announce && status !== undefined && (\n // A sibling of the busy Body rather than inside it: assistive tech may hold back a live\n // region's changes while it sits in an `aria-busy` subtree.\n <span role=\"status\" className=\"sr-only\">\n {announced && t.announcement(announced, facts.name)}\n {announced === \"error\" && error != null && <> {error}</>}\n </span>\n )\n\n return (\n <SharedContext.Provider value={shared}>\n <ark.div\n data-kind={kind}\n {...props({ \"data-status\": status, \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\n // `relative` contains the status region's sr-only box.\n \"relative flex items-center gap-1 rounded-input border p-2\",\n // The kit's hairline, the same as FileUpload's dropzone above its list.\n \"border-brand-900/20 dark:border-white/15\",\n // Figma's file-upload item: `Border/border-error-secondary`, Error/500 at 30%.\n \"data-[status=error]:border-red-500/30\",\n className,\n )}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n {own}\n {region}\n </>\n ))}\n </ark.div>\n </SharedContext.Provider>\n )\n}\n\nexport type FileItemPreviewProps = NoAsChild<HTMLArkProps<\"div\">> & WithTestId\n\n/** The kind icon, or the thumbnail: `src`, or an image `File` through an object URL. Lazy, and\n * decorative (the name sits next to it), so it is hidden from assistive tech. */\nconst Preview = ({ className, testId, asChild: _asChild, ...rest }: FileItemPreviewProps) => {\n const { kind, src, blob, thumbnails, icons } = useShared()\n const pictured = thumbnails && (src !== undefined || (blob !== undefined && kind === \"image\"))\n // `null` when no thumbnail is wanted, so a list with thumbnails off makes no object URLs.\n const objectUrl = useObjectUrl(pictured && src === undefined ? blob : null)\n return (\n <ark.div\n aria-hidden\n data-part=\"preview\"\n {...props({ \"data-testid\": testId })}\n className={cn(\"flex size-9 shrink-0 items-center justify-center [&>svg]:size-6\", className)}\n {...rest}\n >\n {pictured ? (\n <Image src={src ?? objectUrl} alt=\"\" fallback={icons[kind]} className=\"size-9\" />\n ) : (\n icons[kind]\n )}\n </ark.div>\n )\n}\n\nexport type FileItemBodyProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** The name, meta and progress column. Busy while the file uploads or is processed. */\nconst Body = ({ className, testId, ...rest }: FileItemBodyProps) => {\n const { status } = useShared()\n return (\n <ark.div\n {...props({\n \"aria-busy\": status === \"uploading\" || status === \"processing\",\n \"data-testid\": testId,\n })}\n // `relative` anchors the progress bar, which sits in the row's bottom padding.\n className={cn(\"relative min-w-0 flex-1\", className)}\n {...rest}\n />\n )\n}\n\nexport type FileItemNameProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** The file name, on one line. The full name stays in the text (truncation is CSS only) and in\n * a `title`. `asChild` turns it into your link: `<FileItem.Name asChild><a href={url}>{name}</a></…>`\n * (an empty link would fall back to the name, but linters rightly flag one). */\nconst Name = ({ asChild, children, className, testId, ...rest }: FileItemNameProps) => {\n const { name, nameId } = useShared()\n return (\n <ark.div\n title={name}\n {...props({ \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\"block truncate text-sm\", className)}\n {...rest}\n // Last, so a composing part's own id (Ark's item name) can't detach the bar and buttons\n // that are named and described by it.\n id={nameId}\n >\n {composeChildren(asChild, children, (own) => own ?? name)}\n </ark.div>\n )\n}\n\nexport type FileItemMetaProps = NoAsChild<HTMLArkProps<\"div\">> & WithTestId\n\n/** The dot is hidden, the spaces aren't: screen readers get \"248 kB Queued\", not \"248 kBQueued\". */\nconst Separator = () => (\n <>\n {\" \"}\n <span aria-hidden>·</span>{\" \"}\n </>\n)\n\n/**\n * The size and date, then the status. `children` replace the size and date and keep the\n * status; an error replaces the whole line with its message.\n */\nconst Meta = ({ children, className, testId, asChild: _asChild, ...rest }: FileItemMetaProps) => {\n const { size, date, status, progress, error, locale, timeZone, t, icons } = useShared()\n const details =\n children === undefined\n ? [\n size === undefined ? null : formatFileSize(size, locale),\n date === undefined\n ? null\n : new Intl.DateTimeFormat(locale, { dateStyle: \"medium\", timeZone }).format(date),\n ]\n : [children]\n const state = match(status)\n .with(\"queued\", () => t.queued)\n .with(\"uploading\", () =>\n progress === undefined\n ? null\n : new Intl.NumberFormat(locale, { style: \"percent\", maximumFractionDigits: 0 }).format(\n Math.min(Math.max(progress, 0), 1),\n ),\n )\n .with(\"processing\", () => t.processing)\n .with(\"done\", () => (\n <span\n data-color=\"green\"\n className=\"inline-flex items-center gap-1 align-bottom text-(--c-text) [&_svg]:size-3.5\"\n >\n {icons.done}\n {t.done}\n </span>\n ))\n .otherwise(() => null)\n const segments = [...details, state].filter((segment) => segment != null && segment !== \"\")\n\n return (\n <ark.div\n data-part=\"meta\"\n {...props({ \"data-testid\": testId })}\n className={cn(\"truncate text-xs\", TYPOGRAPHY_SHADE_CLASSES.muted, className)}\n {...rest}\n >\n {status === \"error\" ? (\n <span className={TEXT_COLOR_CLASSES.error}>{error ?? t.failed}</span>\n ) : (\n segments.map((segment, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: a fixed sequence, rebuilt per render\n <Fragment key={index}>\n {index > 0 && <Separator />}\n <span>{segment}</span>\n </Fragment>\n ))\n )}\n </ark.div>\n )\n}\n\nexport type FileItemProgressProps = Omit<ProgressProps, \"value\" | \"defaultValue\" | \"onChange\">\n\n/** The upload bar: determinate while uploading with a `progress`, indeterminate otherwise and\n * while processing, absent in every other status. Named after the file. It sits under the\n * name and meta, out of flow, so the row doesn't change height. */\nconst ProgressBar = ({ className, ...rest }: FileItemProgressProps) => {\n const { status, progress, nameId, t } = useShared()\n if (status !== \"uploading\" && status !== \"processing\") return null\n const determinate = status === \"uploading\" && progress !== undefined\n return (\n <Progress\n size=\"xs\"\n value={determinate ? Math.min(Math.max(progress, 0), 1) * 100 : null}\n aria-labelledby={nameId}\n aria-valuetext={status === \"processing\" ? t.processing : undefined}\n // Out of flow, in the row's bottom padding under the text: a row keeps its height as its\n // upload starts and ends, so a list of uploads doesn't jump.\n className={cn(\"absolute inset-x-0 -bottom-1\", className)}\n {...rest}\n />\n )\n}\n\nexport type FileItemActionsProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** Your buttons for the file: download, view, open in a tab. */\nconst Actions = ({ className, testId, ...rest }: FileItemActionsProps) => (\n <ark.div\n {...props({ \"data-testid\": testId })}\n className={cn(\"ms-1 flex shrink-0 items-center gap-2\", className)}\n {...rest}\n />\n)\n\nexport type FileItemRemoveProps = HTMLArkProps<\"button\"> & WithTestId\n\n/** The × button, named \"Remove {name}\", or \"Cancel upload of {name}\" while the file is queued\n * or in flight. Wire `onClick`; a composing trigger's own name (Ark's) wins over the default. */\nconst Remove = ({\n asChild,\n children,\n className,\n testId,\n disabled,\n ...rest\n}: FileItemRemoveProps) => {\n const { name, status, disabled: rowDisabled, t, icons } = useShared()\n const label = isInFlight(status) ? t.cancel(name) : t.remove(name)\n return (\n <ark.button\n type=\"button\"\n aria-label={label}\n disabled={disabled ?? rowDisabled}\n {...props({ \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\n \"inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-sm me-1\",\n // The neutral washes rows and options use for hover (`popoverOption`, Table):\n // translucent, so the button reads on whatever the row sits on.\n TYPOGRAPHY_SHADE_CLASSES.muted,\n \"transition-colors hover:bg-black/5 hover:text-black dark:hover:bg-white/8 dark:hover:text-white\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n focusStyles(),\n \"[&_svg]:size-3.5\",\n className,\n )}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => own ?? icons.remove)}\n </ark.button>\n )\n}\n\nexport type FileItemRetryProps = ButtonProps\n\n/** A small \"Retry\" button, described by the file name (\"Retry, cv.pdf\"). Wire `onClick`. */\nconst Retry = ({ children, disabled, ...rest }: FileItemRetryProps) => {\n const { nameId, disabled: rowDisabled, t, icons } = useShared()\n return (\n <Button\n type=\"button\"\n size=\"xs\"\n variant=\"subtle\"\n color=\"neutral\"\n startSlot={icons.retry}\n aria-describedby={nameId}\n disabled={disabled ?? rowDisabled}\n {...rest}\n >\n {children ?? t.retry}\n </Button>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Convenience\n// ---------------------------------------------------------------------------\n\ntype FileItemClassNames = {\n root?: string\n preview?: string\n body?: string\n name?: string\n meta?: string\n progress?: string\n actions?: string\n retry?: string\n remove?: string\n}\n\nexport type FileItemProps = FileItemRootProps & {\n /** Replaces the size and date on the meta line; the status still follows. */\n meta?: ReactNode\n /** Your buttons (download, view…), before the retry and remove buttons. */\n actions?: ReactNode\n /** Renders the × button. While the file is queued or in flight it is named as a cancel, and\n * calls `onCancel` when there is one. */\n onRemove?: () => void\n /** What the × does while the file is queued or in flight: stop the upload. Falls back to\n * `onRemove`; on its own, the × shows only while there is an upload to stop. */\n onCancel?: () => void\n /** Renders a Retry button while `status` is `\"error\"`. */\n onRetry?: () => void\n classNames?: FileItemClassNames\n}\n\nfunction FileItemComponent({\n meta,\n actions,\n onRemove,\n onCancel,\n onRetry,\n classNames,\n className,\n asChild,\n children,\n ...root\n}: FileItemProps) {\n const dismiss = isInFlight(root.status) ? (onCancel ?? onRemove) : onRemove\n const row = (\n <>\n <Preview className={classNames?.preview} />\n <Body className={classNames?.body}>\n <Name className={classNames?.name} />\n <Meta className={classNames?.meta}>{meta}</Meta>\n <ProgressBar className={classNames?.progress} />\n </Body>\n {actions != null && <Actions className={classNames?.actions}>{actions}</Actions>}\n {onRetry && root.status === \"error\" && (\n <Retry onClick={onRetry} className={classNames?.retry} />\n )}\n {dismiss && <Remove onClick={dismiss} className={classNames?.remove} />}\n </>\n )\n return (\n // Under `asChild` the row becomes your element (an `<li>` in your list), with the row\n // folded in ahead of that element's own content.\n <Root {...root} asChild={asChild} className={cn(className, classNames?.root)}>\n {asChild ? (\n withAsChildContent(children, (own) => (\n <>\n {row}\n {own}\n </>\n ))\n ) : (\n <>\n {row}\n {children}\n </>\n )}\n </Root>\n )\n}\n\n/**\n * `FileItem` — the ready-made row, with the parts attached for your own layout:\n * `Root` (the file, status and context), `Preview`, `Body`, `Name`, `Meta`, `Progress`,\n * `Actions`, `Retry` and `Remove`.\n */\nexport const FileItem = Object.assign(FileItemComponent, {\n Root,\n Preview,\n Body,\n Name,\n Meta,\n Progress: ProgressBar,\n Actions,\n Retry,\n Remove,\n})\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/file-item/file-item.tsx"],"names":["Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;AAmGA,IAAM,oBAAA,GAAuD;AAAA,EAC3D,MAAA,EAAQ,CAAC,IAAA,KAAS,CAAA,OAAA,EAAU,IAAI,CAAA,CAAA;AAAA,EAChC,MAAA,EAAQ,CAAC,IAAA,KAAS,CAAA,iBAAA,EAAoB,IAAI,CAAA,CAAA;AAAA,EAC1C,KAAA,EAAO,OAAA;AAAA,EACP,MAAA,EAAQ,QAAA;AAAA,EACR,UAAA,EAAY,kBAAA;AAAA,EACZ,IAAA,EAAM,UAAA;AAAA,EACN,MAAA,EAAQ,eAAA;AAAA,EACR,YAAA,EAAc,CAAC,MAAA,EAAQ,IAAA,KACrB,KAAA,CAAM,MAAM,CAAA,CACT,IAAA,CAAK,WAAA,EAAa,MAAM,CAAA,UAAA,EAAa,IAAI,CAAA,CAAE,CAAA,CAC3C,IAAA,CAAK,MAAA,EAAQ,MAAM,CAAA,EAAG,IAAI,CAAA,SAAA,CAAW,CAAA,CACrC,IAAA,CAAK,OAAA,EAAS,MAAM,CAAA,EAAG,IAAI,CAAA,iBAAA,CAAmB,CAAA,CAC9C,UAAA;AACP,CAAA;AAGA,IAAM,aAAA,GAAqD;AAAA,EACzD,GAAG,eAAA;AAAA,EACH,MAAA,sBAAS,SAAA,EAAA,EAAU,CAAA;AAAA,EACnB,uBAAO,GAAA,CAAC,QAAA,EAAA,EAAS,aAAA,EAAW,IAAA,EAAC,WAAW,UAAA,EAAY,CAAA;AAAA,EACpD,sBAAM,GAAA,CAAC,WAAA,EAAA,EAAY,aAAA,EAAW,IAAA,EAAC,WAAW,UAAA,EAAY;AACxD,CAAA;AAEA,IAAM,4BAAY,IAAI,GAAA,CAAoB,CAAC,WAAA,EA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WAAW,IAAA,oBAAQ,GAAA,CAAC,WAAQ,SAAA,EAAW,UAAA,EAAY,SAAU,QAAA,EAAA,OAAA,EAAQ,CAAA;AAAA,IACrE,OAAA,IAAW,IAAA,CAAK,MAAA,KAAW,OAAA,oBAC1B,GAAA,CAAC,SAAM,OAAA,EAAS,OAAA,EAAS,SAAA,EAAW,UAAA,EAAY,KAAA,EAAO,CAAA;AAAA,IAExD,2BAAW,GAAA,CAAC,MAAA,EAAA,EAAO,SAAS,OAAA,EAAS,SAAA,EAAW,YAAY,MAAA,EAAQ;AAAA,GAAA,EACvE,CAAA;AAEF,EAAA;AAAA;AAAA;AAAA,wBAGG,IAAA,EAAA,EAAM,GAAG,MAAM,OAAA,EAAkB,SAAA,EAAW,GAAG,SAAA,EAAW,UAAA,EAAY,IAAI,CAAA,EACxE,oBACC,kBAAA,CAAmB,QAAA,EAAU,CAAC,GAAA,qBAC5B,IAAA,CAAAA,UAAA,EACG,QAAA,EAAA;AAAA,MAAA,GAAA;AAAA,MACA;AAAA,KAAA,EACH,CACD,CAAA,mBAED,IAAA,CAAAA,QAAAA,EAAA,EACG,QAAA,EAAA;AAAA,MAAA,GAAA;AAAA,MACA;AAAA,KAAA,EACH,CAAA,EAEJ;AAAA;AAEJ;AAOO,IAAM,QAAA,GAAW,MAAA,CAAO,MAAA,CAAO,iBAAA,EAAmB;AAAA,EACvD,IAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,QAAA,EAAU,WAAA;AAAA,EACV,OAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAC","file":"chunk-MCMS4NMO.js","sourcesContent":["\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { CircleCheck, RotateCw } from \"lucide-react\"\nimport {\n createContext,\n Fragment,\n type ReactNode,\n type Ref,\n useContext,\n useId,\n useState,\n} from \"react\"\nimport { match } from \"ts-pattern\"\nimport { composeChildren, type NoAsChild, withAsChildContent } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { FILE_KIND_ICONS } from \"../../lib/file-kind-icons\"\nimport { type FileKind, fileKind, formatFileSize } from \"../../lib/files\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { useLocale, useTimeZone } from \"../../lib/intl\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES, TYPOGRAPHY_SHADE_CLASSES } from \"../../lib/typography-size\"\nimport { useObjectUrl } from \"../../lib/use-object-url\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport { Image } from \"../image/image\"\nimport { CloseIcon } from \"../popover/icons\"\nimport { Progress, type ProgressProps } from \"../progress/progress\"\n\n/**\n * FileItem — one file as a row: its icon or thumbnail, its name, a meta line\n * (size, date, upload status) and its actions.\n *\n * <FileItem file={pickedFile} onRemove={() => remove(pickedFile)} />\n * <FileItem file={{ name: \"contract.pdf\", size: 248_213, date: doc.signedAt }} actions={…} />\n *\n * The same row serves a `File` the visitor just picked and a document stored\n * on a server, described by `{ name, size?, type?, date?, src? }` (`src` is a\n * thumbnail or preview URL). `FileUpload` renders its list with it.\n *\n * Upload state comes in through `status` (`queued → uploading → processing →\n * done | error`) and `progress` (0–1), so a queue only has to feed them:\n * uploading shows a determinate bar named after the file, processing an\n * indeterminate one, an error its message and a Retry button. Screen readers\n * hear the start, the end and a failure through a polite status region,\n * never each progress tick. A row a queue drives (`itemProps`) stays quiet\n * instead (`announce={false}`), and `FileQueueSummary` speaks for the run.\n *\n * Sizes and dates follow the `IntlProvider` locale and time zone; every\n * string goes through `translations`, every icon through `icons`.\n */\n\nexport type FileItemStatus = \"idle\" | \"queued\" | \"uploading\" | \"processing\" | \"done\" | \"error\"\n\n/** A file that lives on a server: a stored document rather than a picked `File`. */\nexport type FileDescriptor = {\n name: string\n /** In bytes. */\n size?: number\n /** MIME type. Picks the icon, with the name's extension as the fallback. */\n type?: string\n /** When it was uploaded, signed, last changed: whatever the app's meta line means. A date-only\n * ISO string (`\"2026-10-01\"`) is UTC midnight, so it can read as the day before west of UTC;\n * pass a full timestamp or a `Date`. */\n date?: Date | string | number\n /** A thumbnail or preview URL, shown in place of the kind icon. */\n src?: string\n}\n\nexport type FileItemFile = File | FileDescriptor\n\nexport type FileItemIconSlot = FileKind | \"remove\" | \"retry\" | \"done\"\nexport type FileItemIcons = IconMap<FileItemIconSlot>\n\n/** The statuses the status region speaks up for. The others are steps in between. */\nexport type FileItemAnnouncedStatus = \"uploading\" | \"done\" | \"error\"\n\nexport type FileItemTranslations = {\n /** The remove button's accessible name. @default (name) => `Remove ${name}` */\n remove?: (name: string) => string\n /** The same button's name while the file is queued or in flight.\n * @default (name) => `Cancel upload of ${name}` */\n cancel?: (name: string) => string\n /** The retry button's text (it is described by the file name). @default \"Retry\" */\n retry?: string\n /** @default \"Queued\" */\n queued?: string\n /** The meta line and the indeterminate bar's value text. @default \"Processing…\" */\n processing?: string\n /** @default \"Uploaded\" */\n done?: string\n /** Shown for an error without an `error` message. @default \"Upload failed\" */\n failed?: string\n /** What the status region says on each announced transition. The `error` message, when\n * there is one, follows it. */\n announcement?: (status: FileItemAnnouncedStatus, name: string) => string\n}\n\nconst DEFAULT_TRANSLATIONS: Required<FileItemTranslations> = {\n remove: (name) => `Remove ${name}`,\n cancel: (name) => `Cancel upload of ${name}`,\n retry: \"Retry\",\n queued: \"Queued\",\n processing: \"Processing…\",\n done: \"Uploaded\",\n failed: \"Upload failed\",\n announcement: (status, name) =>\n match(status)\n .with(\"uploading\", () => `Uploading ${name}`)\n .with(\"done\", () => `${name} uploaded`)\n .with(\"error\", () => `${name} failed to upload`)\n .exhaustive(),\n}\n\n/** The default icons, one per kind plus the row's own buttons. */\nconst DEFAULT_ICONS: Record<FileItemIconSlot, ReactNode> = {\n ...FILE_KIND_ICONS,\n remove: <CloseIcon />,\n retry: <RotateCw aria-hidden className={iconStroke} />,\n done: <CircleCheck aria-hidden className={iconStroke} />,\n}\n\nconst ANNOUNCED = new Set<FileItemStatus>([\"uploading\", \"done\", \"error\"])\nconst isAnnounced = (status: FileItemStatus | undefined): status is FileItemAnnouncedStatus =>\n status !== undefined && ANNOUNCED.has(status)\n\n/** Statuses where the remove button stops the upload rather than dropping a finished file. */\nconst IN_FLIGHT = new Set<FileItemStatus>([\"queued\", \"uploading\", \"processing\"])\n\n/** Whether the × stops an upload (and calls `onCancel`) rather than dropping the file. For a\n * layout composed from the parts, which wires `Remove` itself. */\nexport const isInFlight = (status: FileItemStatus | undefined): boolean =>\n status !== undefined && IN_FLIGHT.has(status)\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\ntype Shared = {\n name: string\n kind: FileKind\n size?: number\n date?: Date\n src?: string\n /** The picked file itself, for an object-URL thumbnail. */\n blob?: File\n status?: FileItemStatus\n progress?: number\n error?: ReactNode\n disabled: boolean\n thumbnails: boolean\n nameId: string\n locale: string\n timeZone: string\n t: Required<FileItemTranslations>\n icons: Record<FileItemIconSlot, ReactNode>\n}\n\nconst SharedContext = createContext<Shared | null>(null)\n\nconst useShared = () => {\n const shared = useContext(SharedContext)\n if (!shared) throw new Error(\"FileItem parts must be rendered within <FileItem.Root>.\")\n return shared\n}\n\n/** A `File` and a descriptor, read the same way. */\ntype FileFacts = Omit<FileDescriptor, \"date\"> & { date?: Date; blob?: File }\n\n/** An unparseable `date` is dropped rather than shown as \"Invalid Date\". */\nconst toDate = (value: FileDescriptor[\"date\"]): Date | undefined => {\n const date = value === undefined ? undefined : new Date(value)\n return date && !Number.isNaN(date.getTime()) ? date : undefined\n}\n\nconst readFile = (file: FileItemFile): FileFacts =>\n file instanceof File\n ? { name: file.name, size: file.size, type: file.type, blob: file }\n : { name: file.name, size: file.size, type: file.type, src: file.src, date: toDate(file.date) }\n\n// ---------------------------------------------------------------------------\n// Parts\n// ---------------------------------------------------------------------------\n\nexport type FileItemRootProps = HTMLArkProps<\"div\"> &\n WithTestId & {\n /** A picked `File`, or a stored document's `{ name, size?, type?, date?, src? }`. */\n file: FileItemFile\n /** Upload state. Pass it from the first render (`\"idle\"` or `\"queued\"`): the status\n * region exists only with a status, and announces changes, not its first value. */\n status?: FileItemStatus\n /** Upload progress from 0 to 1, read while `status` is `\"uploading\"`. Without it the bar\n * is indeterminate. */\n progress?: number\n /** Why the upload failed, shown and announced while `status` is `\"error\"`. */\n error?: ReactNode\n /** Keep a status region that announces this row's upload. Off for a row a queue drives:\n * `useFileQueue`'s `itemProps` pass `false`, and one `FileQueueSummary` speaks for every\n * row, so 400 rows don't announce 800 times. @default true */\n announce?: boolean\n /** Disables the row's own buttons (remove, retry). */\n disabled?: boolean\n /** Show image files and `src` as thumbnails. Off, every file shows its kind icon, and no\n * object URL is created. @default true */\n thumbnails?: boolean\n /** Replaces the default icons: one per `FileKind`, plus `remove`, `retry` and `done`. */\n icons?: FileItemIcons\n /** Overrides the row's strings. A partial override keeps the other defaults. */\n translations?: FileItemTranslations\n ref?: Ref<HTMLDivElement>\n }\n\nconst Root = ({\n file,\n status,\n progress,\n error,\n announce = true,\n disabled = false,\n thumbnails = true,\n icons,\n translations,\n asChild,\n children,\n className,\n testId,\n ...rest\n}: FileItemRootProps) => {\n const locale = useLocale()\n const timeZone = useTimeZone()\n const nameId = useId()\n const t = { ...DEFAULT_TRANSLATIONS, ...translations }\n const { type, ...facts } = readFile(file)\n const kind = fileKind(type, facts.name)\n\n // Only a change of status is announced, never the first one (a stored document mounting as\n // \"done\" is not news) and never a progress tick. State adjusted during render, React's own\n // pattern for \"remember the previous prop\", so the region's text lands in the same commit.\n const [seen, setSeen] = useState(status)\n const [announced, setAnnounced] = useState<FileItemAnnouncedStatus | null>(null)\n if (seen !== status) {\n setSeen(status)\n setAnnounced(isAnnounced(status) ? status : null)\n }\n\n const shared: Shared = {\n ...facts,\n kind,\n status,\n progress,\n error,\n disabled,\n thumbnails,\n nameId,\n locale,\n timeZone,\n t,\n icons: mergeIcons(DEFAULT_ICONS, icons),\n }\n\n const region = announce && status !== undefined && (\n // A sibling of the busy Body rather than inside it: assistive tech may hold back a live\n // region's changes while it sits in an `aria-busy` subtree.\n <span role=\"status\" className=\"sr-only\">\n {announced && t.announcement(announced, facts.name)}\n {announced === \"error\" && error != null && <> {error}</>}\n </span>\n )\n\n return (\n <SharedContext.Provider value={shared}>\n <ark.div\n data-kind={kind}\n {...props({ \"data-status\": status, \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\n // `relative` contains the status region's sr-only box.\n \"relative flex items-center gap-1 rounded-input border p-2\",\n // The kit's hairline, the same as FileUpload's dropzone above its list.\n \"border-brand-900/20 dark:border-white/15\",\n // Figma's file-upload item: `Border/border-error-secondary`, Error/500 at 30%.\n \"data-[status=error]:border-red-500/30\",\n className,\n )}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n {own}\n {region}\n </>\n ))}\n </ark.div>\n </SharedContext.Provider>\n )\n}\n\nexport type FileItemPreviewProps = NoAsChild<HTMLArkProps<\"div\">> & WithTestId\n\n/** The kind icon, or the thumbnail: `src`, or an image `File` through an object URL. Lazy, and\n * decorative (the name sits next to it), so it is hidden from assistive tech. */\nconst Preview = ({ className, testId, asChild: _asChild, ...rest }: FileItemPreviewProps) => {\n const { kind, src, blob, thumbnails, icons } = useShared()\n const pictured = thumbnails && (src !== undefined || (blob !== undefined && kind === \"image\"))\n // `null` when no thumbnail is wanted, so a list with thumbnails off makes no object URLs.\n const objectUrl = useObjectUrl(pictured && src === undefined ? blob : null)\n return (\n <ark.div\n aria-hidden\n data-part=\"preview\"\n {...props({ \"data-testid\": testId })}\n className={cn(\"flex size-9 shrink-0 items-center justify-center [&>svg]:size-6\", className)}\n {...rest}\n >\n {pictured ? (\n <Image src={src ?? objectUrl} alt=\"\" fallback={icons[kind]} className=\"size-9\" />\n ) : (\n icons[kind]\n )}\n </ark.div>\n )\n}\n\nexport type FileItemBodyProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** The name, meta and progress column. Busy while the file uploads or is processed. */\nconst Body = ({ className, testId, ...rest }: FileItemBodyProps) => {\n const { status } = useShared()\n return (\n <ark.div\n {...props({\n \"aria-busy\": status === \"uploading\" || status === \"processing\",\n \"data-testid\": testId,\n })}\n // `relative` anchors the progress bar, which sits in the row's bottom padding.\n className={cn(\"relative min-w-0 flex-1\", className)}\n {...rest}\n />\n )\n}\n\nexport type FileItemNameProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** The file name, on one line. The full name stays in the text (truncation is CSS only) and in\n * a `title`. `asChild` turns it into your link: `<FileItem.Name asChild><a href={url}>{name}</a></…>`\n * (an empty link would fall back to the name, but linters rightly flag one). */\nconst Name = ({ asChild, children, className, testId, ...rest }: FileItemNameProps) => {\n const { name, nameId } = useShared()\n return (\n <ark.div\n title={name}\n {...props({ \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\"block truncate text-sm\", className)}\n {...rest}\n // Last, so a composing part's own id (Ark's item name) can't detach the bar and buttons\n // that are named and described by it.\n id={nameId}\n >\n {composeChildren(asChild, children, (own) => own ?? name)}\n </ark.div>\n )\n}\n\nexport type FileItemMetaProps = NoAsChild<HTMLArkProps<\"div\">> & WithTestId\n\n/** The dot is hidden, the spaces aren't: screen readers get \"248 kB Queued\", not \"248 kBQueued\". */\nconst Separator = () => (\n <>\n {\" \"}\n <span aria-hidden>·</span>{\" \"}\n </>\n)\n\n/**\n * The size and date, then the status. `children` replace the size and date and keep the\n * status; an error replaces the whole line with its message.\n */\nconst Meta = ({ children, className, testId, asChild: _asChild, ...rest }: FileItemMetaProps) => {\n const { size, date, status, progress, error, locale, timeZone, t, icons } = useShared()\n const details =\n children === undefined\n ? [\n size === undefined ? null : formatFileSize(size, locale),\n date === undefined\n ? null\n : new Intl.DateTimeFormat(locale, { dateStyle: \"medium\", timeZone }).format(date),\n ]\n : [children]\n const state = match(status)\n .with(\"queued\", () => t.queued)\n .with(\"uploading\", () =>\n progress === undefined\n ? null\n : new Intl.NumberFormat(locale, { style: \"percent\", maximumFractionDigits: 0 }).format(\n Math.min(Math.max(progress, 0), 1),\n ),\n )\n .with(\"processing\", () => t.processing)\n .with(\"done\", () => (\n <span\n data-color=\"green\"\n className=\"inline-flex items-center gap-1 align-bottom text-(--c-text) [&_svg]:size-3.5\"\n >\n {icons.done}\n {t.done}\n </span>\n ))\n .otherwise(() => null)\n const segments = [...details, state].filter((segment) => segment != null && segment !== \"\")\n\n return (\n <ark.div\n data-part=\"meta\"\n {...props({ \"data-testid\": testId })}\n className={cn(\"truncate text-xs\", TYPOGRAPHY_SHADE_CLASSES.muted, className)}\n {...rest}\n >\n {status === \"error\" ? (\n <span className={TEXT_COLOR_CLASSES.error}>{error ?? t.failed}</span>\n ) : (\n segments.map((segment, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: a fixed sequence, rebuilt per render\n <Fragment key={index}>\n {index > 0 && <Separator />}\n <span>{segment}</span>\n </Fragment>\n ))\n )}\n </ark.div>\n )\n}\n\nexport type FileItemProgressProps = Omit<ProgressProps, \"value\" | \"defaultValue\" | \"onChange\">\n\n/** The upload bar: determinate while uploading with a `progress`, indeterminate otherwise and\n * while processing, absent in every other status. Named after the file. It sits under the\n * name and meta, out of flow, so the row doesn't change height. */\nconst ProgressBar = ({ className, ...rest }: FileItemProgressProps) => {\n const { status, progress, nameId, t } = useShared()\n if (status !== \"uploading\" && status !== \"processing\") return null\n const determinate = status === \"uploading\" && progress !== undefined\n return (\n <Progress\n size=\"xs\"\n value={determinate ? Math.min(Math.max(progress, 0), 1) * 100 : null}\n aria-labelledby={nameId}\n aria-valuetext={status === \"processing\" ? t.processing : undefined}\n // Out of flow, in the row's bottom padding under the text: a row keeps its height as its\n // upload starts and ends, so a list of uploads doesn't jump.\n className={cn(\"absolute inset-x-0 -bottom-1\", className)}\n {...rest}\n />\n )\n}\n\nexport type FileItemActionsProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** Your buttons for the file: download, view, open in a tab. */\nconst Actions = ({ className, testId, ...rest }: FileItemActionsProps) => (\n <ark.div\n {...props({ \"data-testid\": testId })}\n className={cn(\"ms-1 flex shrink-0 items-center gap-2\", className)}\n {...rest}\n />\n)\n\nexport type FileItemRemoveProps = HTMLArkProps<\"button\"> & WithTestId\n\n/** The × button, named \"Remove {name}\", or \"Cancel upload of {name}\" while the file is queued\n * or in flight. Wire `onClick`; a composing trigger's own name (Ark's) wins over the default. */\nconst Remove = ({\n asChild,\n children,\n className,\n testId,\n disabled,\n ...rest\n}: FileItemRemoveProps) => {\n const { name, status, disabled: rowDisabled, t, icons } = useShared()\n const label = isInFlight(status) ? t.cancel(name) : t.remove(name)\n return (\n <ark.button\n type=\"button\"\n aria-label={label}\n disabled={disabled ?? rowDisabled}\n {...props({ \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\n \"inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-sm me-1\",\n // The neutral washes rows and options use for hover (`popoverOption`, Table):\n // translucent, so the button reads on whatever the row sits on.\n TYPOGRAPHY_SHADE_CLASSES.muted,\n \"transition-colors hover:bg-black/5 hover:text-black dark:hover:bg-white/8 dark:hover:text-white\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n focusStyles(),\n \"[&_svg]:size-3.5\",\n className,\n )}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => own ?? icons.remove)}\n </ark.button>\n )\n}\n\nexport type FileItemRetryProps = ButtonProps\n\n/** A small \"Retry\" button, described by the file name (\"Retry, cv.pdf\"). Wire `onClick`. */\nconst Retry = ({ children, disabled, ...rest }: FileItemRetryProps) => {\n const { nameId, disabled: rowDisabled, t, icons } = useShared()\n return (\n <Button\n type=\"button\"\n size=\"xs\"\n variant=\"subtle\"\n color=\"neutral\"\n startSlot={icons.retry}\n aria-describedby={nameId}\n disabled={disabled ?? rowDisabled}\n {...rest}\n >\n {children ?? t.retry}\n </Button>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Convenience\n// ---------------------------------------------------------------------------\n\ntype FileItemClassNames = {\n root?: string\n preview?: string\n body?: string\n name?: string\n meta?: string\n progress?: string\n actions?: string\n retry?: string\n remove?: string\n}\n\nexport type FileItemProps = FileItemRootProps & {\n /** Replaces the size and date on the meta line; the status still follows. */\n meta?: ReactNode\n /** Your buttons (download, view…), before the retry and remove buttons. */\n actions?: ReactNode\n /** Renders the × button. While the file is queued or in flight it is named as a cancel, and\n * calls `onCancel` when there is one. */\n onRemove?: () => void\n /** What the × does while the file is queued or in flight: stop the upload. Falls back to\n * `onRemove`; on its own, the × shows only while there is an upload to stop. */\n onCancel?: () => void\n /** Renders a Retry button while `status` is `\"error\"`. */\n onRetry?: () => void\n classNames?: FileItemClassNames\n}\n\nfunction FileItemComponent({\n meta,\n actions,\n onRemove,\n onCancel,\n onRetry,\n classNames,\n className,\n asChild,\n children,\n ...root\n}: FileItemProps) {\n const dismiss = isInFlight(root.status) ? (onCancel ?? onRemove) : onRemove\n const row = (\n <>\n <Preview className={classNames?.preview} />\n <Body className={classNames?.body}>\n <Name className={classNames?.name} />\n <Meta className={classNames?.meta}>{meta}</Meta>\n <ProgressBar className={classNames?.progress} />\n </Body>\n {actions != null && <Actions className={classNames?.actions}>{actions}</Actions>}\n {onRetry && root.status === \"error\" && (\n <Retry onClick={onRetry} className={classNames?.retry} />\n )}\n {dismiss && <Remove onClick={dismiss} className={classNames?.remove} />}\n </>\n )\n return (\n // Under `asChild` the row becomes your element (an `<li>` in your list), with the row\n // folded in ahead of that element's own content.\n <Root {...root} asChild={asChild} className={cn(className, classNames?.root)}>\n {asChild ? (\n withAsChildContent(children, (own) => (\n <>\n {row}\n {own}\n </>\n ))\n ) : (\n <>\n {row}\n {children}\n </>\n )}\n </Root>\n )\n}\n\n/**\n * `FileItem` — the ready-made row, with the parts attached for your own layout:\n * `Root` (the file, status and context), `Preview`, `Body`, `Name`, `Meta`, `Progress`,\n * `Actions`, `Retry` and `Remove`.\n */\nexport const FileItem = Object.assign(FileItemComponent, {\n Root,\n Preview,\n Body,\n Name,\n Meta,\n Progress: ProgressBar,\n Actions,\n Retry,\n Remove,\n})\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fromDate, toCalendarDateTime } from '@internationalized/date';
|
|
1
|
+
import { fromDate, toCalendarDateTime, toCalendarDate, startOfMonth, startOfYear, endOfMonth, endOfYear } from '@internationalized/date';
|
|
2
2
|
|
|
3
3
|
// src/lib/date-value.ts
|
|
4
4
|
function dateToCalendarValue(date, timeZone) {
|
|
@@ -30,7 +30,18 @@ function fromArkValues(values, range, timeZone) {
|
|
|
30
30
|
end: end ? calendarValueToDate(end, timeZone) : null
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
+
function snapToUnit(value, unit) {
|
|
34
|
+
if (unit === "day") return value;
|
|
35
|
+
const date = toCalendarDate(value);
|
|
36
|
+
return unit === "month" ? startOfMonth(date) : startOfYear(date);
|
|
37
|
+
}
|
|
38
|
+
function snapBound(value, unit, edge) {
|
|
39
|
+
if (unit === "day") return value;
|
|
40
|
+
const date = toCalendarDate(value);
|
|
41
|
+
if (unit === "month") return edge === "start" ? startOfMonth(date) : endOfMonth(date);
|
|
42
|
+
return edge === "start" ? startOfYear(date) : endOfYear(date);
|
|
43
|
+
}
|
|
33
44
|
|
|
34
|
-
export { calendarValueToDate, dateToArkValue, dateToCalendarValue, fromArkValues, toArkValues };
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
36
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
export { calendarValueToDate, dateToArkValue, dateToCalendarValue, fromArkValues, snapBound, snapToUnit, toArkValues };
|
|
46
|
+
//# sourceMappingURL=chunk-MV5DIE2T.js.map
|
|
47
|
+
//# sourceMappingURL=chunk-MV5DIE2T.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/date-value.ts"],"names":[],"mappings":";;;AA8BO,SAAS,mBAAA,CAAoB,MAAY,QAAA,EAA6B;AAC3E,EAAA,OAAO,QAAA,CAAS,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I,IAAA;AAAA,IACtD,GAAA,EAAK,GAAA,GAAM,mBAAA,CAAoB,GAAA,EAAK,QAAQ,CAAA,GAAI;AAAA,GAClD;AACF;AAeO,SAAS,UAAA,CAAW,OAAkB,IAAA,EAA2B;AACtE,EAAA,IAAI,IAAA,KAAS,OAAO,OAAO,KAAA;AAC3B,EAAA,MAAM,IAAA,GAAO,eAAe,KAAK,CAAA;AACjC,EAAA,OAAO,SAAS,OAAA,GAAU,YAAA,CAAa,IAAI,CAAA,GAAI,YAAY,IAAI,CAAA;AACjE;AAQO,SAAS,SAAA,CAAU,KAAA,EAAkB,IAAA,EAAgB,IAAA,EAAkC;AAC5F,EAAA,IAAI,IAAA,KAAS,OAAO,OAAO,KAAA;AAC3B,EAAA,MAAM,IAAA,GAAO,eAAe,KAAK,CAAA;AACjC,EAAA,IAAI,IAAA,KAAS,SAAS,OAAO,IAAA,KAAS,UAAU,YAAA,CAAa,IAAI,CAAA,GAAI,UAAA,CAAW,IAAI,CAAA;AACpF,EAAA,OAAO,SAAS,OAAA,GAAU,WAAA,CAAY,IAAI,CAAA,GAAI,UAAU,IAAI,CAAA;AAC9D","file":"chunk-MV5DIE2T.js","sourcesContent":["import {\n type DateValue,\n endOfMonth,\n endOfYear,\n fromDate,\n startOfMonth,\n startOfYear,\n toCalendarDate,\n toCalendarDateTime,\n} from \"@internationalized/date\"\n\n/**\n * The `Date ↔ DateValue` boundary (RFC §4/§13, `docs/rfcs/date-picker.md`) — the one place a\n * native `Date` *instant* converts to/from Ark's wall-calendar `DateValue`\n * (`CalendarDate | CalendarDateTime | ZonedDateTime`). `Calendar` and (later) `DatePicker` both\n * funnel every conversion through here, so there is exactly one audited crossing point instead\n * of one per component.\n *\n * `@internationalized/date` internals are deliberately NOT re-exported from this module — keep\n * the public surface to the boundary functions below (PR3's `date-picker/index.ts` re-exports\n * exactly one unrelated helper, `getLocalTimeZone`, directly from the library itself).\n */\n\n/**\n * A range value: `{ start, end }`, each independently nullable (a real \"unset\" endpoint, never\n * `undefined`). Mirrors `Calendar`/`DatePicker`'s `range` value shape.\n */\nexport type DateRangeValue = { start: Date | null; end: Date | null }\n\n/** Convert a native `Date` instant to Ark's `DateValue`, interpreted in `timeZone`. */\nexport function dateToCalendarValue(date: Date, timeZone: string): DateValue {\n return fromDate(date, timeZone)\n}\n\n/**\n * Convert a native `Date` instant to the value handed to Ark's machine: the wall-clock date and\n * time it reads as in `timeZone`, as a zone-free `CalendarDateTime`.\n *\n * Not a `ZonedDateTime`, although that is what `dateToCalendarValue` returns, because Ark copies\n * the zone of whatever it is handed into everything it derives from it: the focused day, the\n * visible month, and through those every grid cell, and a pick keeps the zone of the cell it came\n * from. So when the component's zone changes (`timeZone=\"auto\"` after hydration, or the app's\n * `IntlProvider`), the grid would go on producing picks in the *old* zone. Kept zone-free, the\n * machine only ever holds wall-clock values, and the one zone that turns them back into instants\n * is the component's current one, passed to `calendarValueToDate`.\n */\nexport function dateToArkValue(date: Date, timeZone: string): DateValue {\n return toCalendarDateTime(fromDate(date, timeZone))\n}\n\n/**\n * Convert Ark's `DateValue` back to a native `Date`. A `ZonedDateTime` (what `dateToCalendarValue`\n * produces) already carries its own zone/offset — its `toDate()` takes no argument and would\n * silently ignore a mismatched `timeZone` here — while a plain `CalendarDate`/`CalendarDateTime`\n * (what the day-grid's own calendar arithmetic produces) needs one to resolve to an instant, so\n * branch on which shape we actually got rather than assuming the caller's `dateToCalendarValue`\n * origin.\n */\nexport function calendarValueToDate(value: DateValue, timeZone: string): Date {\n return \"timeZone\" in value ? value.toDate() : value.toDate(timeZone)\n}\n\n/**\n * Wrap a public value into Ark's array contract, each `Date` through `dateToArkValue`. `undefined` stays uncontrolled (Ark's own\n * default takes over); `null` — or an all-null range — clears to `[]`; a single `Date` becomes a\n * one-element array; a range pushes only its defined ends, so a mid-selection range\n * (`{ start, end: null }`) naturally comes out length 1.\n */\nexport function toArkValues(\n value: Date | DateRangeValue | null | undefined,\n timeZone: string,\n): DateValue[] | undefined {\n if (value === undefined) return undefined\n if (value === null) return []\n if (value instanceof Date) return [dateToArkValue(value, timeZone)]\n const values: DateValue[] = []\n if (value.start !== null) values.push(dateToArkValue(value.start, timeZone))\n if (value.end !== null) values.push(dateToArkValue(value.end, timeZone))\n return values\n}\n\n/**\n * The inverse of `toArkValues` — Ark's `value` array back to the public shape. `range` picks\n * which shape to produce; a length-1 array under `range` is a mid-selection (`start` set,\n * `end` still `null`), not an error.\n */\nexport function fromArkValues(\n values: DateValue[],\n range: boolean,\n timeZone: string,\n): Date | DateRangeValue | null {\n if (!range) {\n const [only] = values\n return only ? calendarValueToDate(only, timeZone) : null\n }\n const [start, end] = values\n return {\n start: start ? calendarValueToDate(start, timeZone) : null,\n end: end ? calendarValueToDate(end, timeZone) : null,\n }\n}\n\n/**\n * The unit a picker's value is made of: a day (`DatePicker`, `Calendar`), a month\n * (`MonthPicker`, `MonthCalendar`) or a year (`YearPicker`, `YearCalendar`). It is the machine's\n * own `minView`: the lowest view the grid can reach is the one whose cell commits the value.\n */\nexport type DateUnit = \"day\" | \"month\" | \"year\"\n\n/**\n * The value a `unit`-level picker holds for `value`: the first day of its month or year, as a\n * time-less `CalendarDate`. A `\"day\"` value passes through untouched. Ark's machine already\n * snaps a *picked* cell this way (`normalizeValue`); this is the same rule for the values the\n * app hands in (`value`, `defaultValue`, a preset), so they come back out on the first day too.\n */\nexport function snapToUnit(value: DateValue, unit: DateUnit): DateValue {\n if (unit === \"day\") return value\n const date = toCalendarDate(value)\n return unit === \"month\" ? startOfMonth(date) : startOfYear(date)\n}\n\n/**\n * A `min` (`edge: \"start\"`) or `max` (`edge: \"end\"`) bound widened to the whole `unit` it falls\n * in. Ark compares a month cell as one of its days, so a `min` of March 15th would disable March\n * itself, and clamp a picked March 1st up to the 15th. Widened, a bound reads as \"the month\n * holding this day\", which is what a month picker means by it.\n */\nexport function snapBound(value: DateValue, unit: DateUnit, edge: \"start\" | \"end\"): DateValue {\n if (unit === \"day\") return value\n const date = toCalendarDate(value)\n if (unit === \"month\") return edge === \"start\" ? startOfMonth(date) : endOfMonth(date)\n return edge === \"start\" ? startOfYear(date) : endOfYear(date)\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { devWarnOnce } from './chunk-PQZSTI3R.js';
|
|
2
|
+
import { useUncontrolled } from './chunk-PMUCGFY5.js';
|
|
3
|
+
import { isValidElement } from 'react';
|
|
4
|
+
|
|
5
|
+
var reason = "aria-pressed has no meaning on a link: a toggle must render a <button>, not an <a>";
|
|
6
|
+
var isLinkElement = (child) => isValidElement(child) && (child.type === "a" || child.props.href != null || child.props.to != null);
|
|
7
|
+
var usePressed = ({
|
|
8
|
+
pressed: pressedProp,
|
|
9
|
+
defaultPressed,
|
|
10
|
+
onPressedChange,
|
|
11
|
+
disabled,
|
|
12
|
+
onClick,
|
|
13
|
+
link,
|
|
14
|
+
component
|
|
15
|
+
}) => {
|
|
16
|
+
const [pressed, setPressed] = useUncontrolled({
|
|
17
|
+
value: pressedProp,
|
|
18
|
+
defaultValue: defaultPressed,
|
|
19
|
+
finalValue: false,
|
|
20
|
+
onChange: onPressedChange
|
|
21
|
+
});
|
|
22
|
+
const requested = pressedProp !== void 0 || defaultPressed !== void 0 || onPressedChange !== void 0;
|
|
23
|
+
if (requested && link) {
|
|
24
|
+
devWarnOnce(`${component}: ignoring \`pressed\` on an \`asChild\` link. ${reason}.`);
|
|
25
|
+
}
|
|
26
|
+
const toggle = requested && !link;
|
|
27
|
+
if (!toggle) return { toggle, pressed: false, onClick };
|
|
28
|
+
return {
|
|
29
|
+
toggle,
|
|
30
|
+
pressed,
|
|
31
|
+
onClick: (event) => {
|
|
32
|
+
onClick?.(event);
|
|
33
|
+
if (event.defaultPrevented || disabled) return;
|
|
34
|
+
setPressed((previous) => !previous);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { isLinkElement, usePressed };
|
|
40
|
+
//# sourceMappingURL=chunk-NDI4HLQE.js.map
|
|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,IAAI,KAAA,CAAM,oBAAoB,QAAA,EAAU;AACxC,MAAA,UAAA,CAAW,CAAC,QAAA,KAAa,CAAC,QAAQ,CAAA;AAAA,IACpC;AAAA,GACF;AACF","file":"chunk-NDI4HLQE.js","sourcesContent":["import { isValidElement, type MouseEvent, type MouseEventHandler, type ReactNode } from \"react\"\nimport type { Unavailable } from \"./available-if\"\nimport { devWarnOnce } from \"./dev-warn\"\nimport { useUncontrolled } from \"./use-uncontrolled\"\n\n/**\n * The toggle (pressed) state shared by `Button` and `ActionIcon`.\n *\n * Passing `pressed`, `defaultPressed` or `onPressedChange` turns the control\n * into a toggle button: it renders `aria-pressed`, a click flips the state,\n * and its look swaps from `variant` to `pressedVariant`, the same swap\n * `ButtonSelect` makes with `selectedVariant`. Without any of the three the\n * control renders exactly as before: no `aria-pressed`, no extra click work.\n *\n * Built on `useUncontrolled` rather than Ark's `toggle` machine. The machine\n * holds one boolean and flips it on click, but its root props bring their own\n * `type=\"button\"`, `disabled` and an `onClick` that knows nothing of\n * `loading`, all of which `Button` already owns (and gets right under\n * `asChild`, where `disabled` does nothing). Every Button would also start a\n * zag service it mostly never uses, since a hook can't be called\n * conditionally. The state is the only part worth sharing, and this is it.\n */\nexport type PressedProps<Variant extends string> = {\n /**\n * Controlled pressed state. Passing it (or `defaultPressed`, or\n * `onPressedChange`) makes the control a toggle: it renders `aria-pressed`\n * and a click flips the state.\n */\n pressed?: boolean\n /** Uncontrolled initial pressed state. */\n defaultPressed?: boolean\n /** Fires with the next pressed state when a click flips it. */\n onPressedChange?: (pressed: boolean) => void\n /**\n * Treatment while pressed, the toggle's counterpart of `ButtonSelect`'s\n * `selectedVariant`. A toggle's `variant` (its unpressed look) defaults to\n * `light` and this to `filled`, the same pair as `ButtonSelect`, so a lone\n * toggle and one in a group look alike.\n */\n pressedVariant?: Variant\n}\n\n/**\n * Why a toggle can't be a link, printed verbatim in the compile error and\n * the dev warning.\n */\nexport type PressedLinkReason =\n \"aria-pressed has no meaning on a link: a toggle must render a <button>, not an <a>\"\n\nconst reason: PressedLinkReason =\n \"aria-pressed has no meaning on a link: a toggle must render a <button>, not an <a>\"\n\n/**\n * `href` forbidden on `Button` and `ActionIcon`, carrying the reason.\n *\n * Both render a `<button>`, which has no `href`, and the only way to make one\n * a link is `asChild` around an `<a>` or a router `Link`. TypeScript can't see\n * through that (every JSX child is a plain `JSX.Element`), so the runtime\n * guard in `usePressed` covers it. What the type *can* catch is an `href`\n * forwarded in a prop bag — `<Button pressed {...linkProps} />` — which would\n * otherwise land silently on the `<button>`. Omitting the key wouldn't: excess\n * property checks skip JSX spreads. See `available-if.ts` for the brand.\n */\nexport type ForbidHref = {\n /** Unavailable: a Button renders a `<button>`. For a link, use `asChild`\n * around an `<a>`, without the pressed props. */\n href?: Unavailable<PressedLinkReason> | undefined\n}\n\n/**\n * A link child under `asChild`: an `<a>`, or any element carrying an `href`\n * (Next's `Link`) or a `to` (TanStack Router's and React Router's `Link`).\n */\nexport const isLinkElement = (child: ReactNode): boolean =>\n isValidElement<{ href?: unknown; to?: unknown }>(child) &&\n (child.type === \"a\" || child.props.href != null || child.props.to != null)\n\ntype UsePressedOptions = Pick<\n PressedProps<string>,\n \"pressed\" | \"defaultPressed\" | \"onPressedChange\"\n> & {\n /** Native `disabled` or `loading`: a click never flips the state. Needed\n * for an `asChild` element, where native `disabled` doesn't stop clicks. */\n disabled: boolean\n /** The consumer's own `onClick`, run first. Calling `preventDefault` in it\n * keeps the state as it is. */\n onClick: MouseEventHandler<HTMLButtonElement> | undefined\n /** Whether the `asChild` child is a link (`isLinkElement`). */\n link: boolean\n /** Component name, for the dev warning. */\n component: string\n}\n\n/**\n * Resolves a control's toggle state. `toggle` is false unless one of the\n * pressed props is passed (and the control isn't a link), and then `onClick`\n * is the consumer's own, untouched.\n */\nexport const usePressed = ({\n pressed: pressedProp,\n defaultPressed,\n onPressedChange,\n disabled,\n onClick,\n link,\n component,\n}: UsePressedOptions) => {\n const [pressed, setPressed] = useUncontrolled<boolean>({\n value: pressedProp,\n defaultValue: defaultPressed,\n finalValue: false,\n onChange: onPressedChange,\n })\n const requested =\n pressedProp !== undefined || defaultPressed !== undefined || onPressedChange !== undefined\n if (requested && link) {\n devWarnOnce(`${component}: ignoring \\`pressed\\` on an \\`asChild\\` link. ${reason}.`)\n }\n const toggle = requested && !link\n if (!toggle) return { toggle, pressed: false, onClick }\n return {\n toggle,\n pressed,\n onClick: (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (event.defaultPrevented || disabled) return\n setPressed((previous) => !previous)\n },\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button } from './chunk-
|
|
1
|
+
import { Button } from './chunk-KZDMVOL6.js';
|
|
2
2
|
import { saveFile } from './chunk-EIBDLRAR.js';
|
|
3
3
|
import { mergeIcons, iconStroke } from './chunk-XXOR34T4.js';
|
|
4
4
|
import { Spinner } from './chunk-W3XX7BYT.js';
|
|
@@ -136,5 +136,5 @@ var DownloadButton = ({
|
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
export { DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS, DownloadButton };
|
|
139
|
-
//# sourceMappingURL=chunk-
|
|
140
|
-
//# sourceMappingURL=chunk-
|
|
139
|
+
//# sourceMappingURL=chunk-NLJEQZQQ.js.map
|
|
140
|
+
//# sourceMappingURL=chunk-NLJEQZQQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/download-button/download-button.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAkEO,IAAM,oCAAA,GAA6E;AAAA,EACxF,KAAA,EAAO,UAAA;AAAA,EACP,OAAA,EAAS,0BAAA;AAAA,EACT,OAAO,CAAC,IAAA,KAAU,IAAA,GAAO,CAAA,EAAG,IAAI,CAAA,uBAAA,CAAA,GAA4B;AAC9D;AAIA,IAAM,aAAA,GAA2D;AAAA,EAC/D,QAAA,kBAAU,GAAA,CAAC,QAAA,EAAA,EAA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AA,CAAE,KAAA;AAAA,UACd,wBAAQ,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,SAAA,EAAW,YAAE,OAAA,EAAQ;AAAA;AAAA;AAAA,KAChD;AAAA,oBAEF,GAAA,CAAC,MAAA,EAAA,EAAK,IAAA,EAAK,QAAA,EAAS,SAAA,EAAW,cAAc,YAAA,EAAW,iBAAA,EAAkB,WAAA,EAAU,QAAA,EACjF,QAAA,EAAA,OAAA,EACH;AAAA,GAAA,EACF,CAAA;AAEJ","file":"chunk-B4GNSSHU.js","sourcesContent":["\"use client\"\n\nimport { ark } from \"@ark-ui/react\"\nimport { Download } from \"lucide-react\"\nimport { type MouseEvent, type ReactNode, useEffect, useRef, useState } from \"react\"\nimport { withAsChildContent } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { props } from \"../../lib/props\"\nimport { saveFile } from \"../../lib/save-file\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport { Spinner } from \"../spinner/spinner\"\n\n/**\n * DownloadButton — a button that saves a file: a Blob you already have, a\n * URL, or whatever a function of yours resolves to (an authenticated fetch,\n * a presign call, a generated CSV). The kit makes no request itself.\n *\n * - **While a function's promise is pending** the button is busy: a\n * spinner, `aria-busy`, and re-clicks are ignored, so a double click\n * saves one file. It stays enabled and focused, unlike Button's\n * `loading`, which sets `disabled` and drops keyboard focus.\n * - **On failure**, a polite status region says so (`translations.error`)\n * and `onError` gets the error. Nothing is announced on success: the\n * browser's own download UI is the feedback.\n * - **Unmounting mid-fetch** aborts: the function's `signal` fires and\n * nothing is saved afterwards.\n * - Renders a kit `Button` by default. With `asChild`, only the behaviour\n * goes onto your element (an `ActionIcon` in a row's actions), and its\n * content is swapped for the spinner while busy.\n *\n * Built on `saveFile` (`lib/save-file.ts`) rather than Ark's\n * `DownloadTrigger`: Ark's trigger has no pending state, drops a rejected\n * promise, can't be aborted, and reads a string as the file's *contents*\n * rather than a URL.\n *\n * ```tsx\n * <DownloadButton\n * name=\"transcript.pdf\"\n * data={({ signal }) => api.get(`/transcripts/${id}`, { signal }).then((r) => r.blob())}\n * onError={() => notify.error(\"Couldn't download the transcript\")}\n * />\n * ```\n */\n\n/** What can be saved: a Blob (or File), or a URL. */\nexport type DownloadData = Blob | string\n\n/** Resolves the file on click. `signal` aborts when the button unmounts first. */\nexport type DownloadLoader = (context: {\n signal: AbortSignal\n}) => DownloadData | Promise<DownloadData>\n\n/** What `data` takes: the value itself, or a function that resolves it on click. */\nexport type DownloadSource = DownloadData | DownloadLoader\n\nexport type DownloadButtonTranslations = {\n /** The default label, when there are no `children`. @default \"Download\" */\n label?: string\n /** Added to the button's name while `data` is resolving. @default \"Preparing download…\" */\n loading?: string\n /** What the status region says when the download fails.\n * @default (name) => name ? `${name} couldn't be downloaded` : \"The download failed\" */\n error?: (name: string | undefined) => string\n}\n\nexport const DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS: Required<DownloadButtonTranslations> = {\n label: \"Download\",\n loading: \"Preparing download…\",\n error: (name) => (name ? `${name} couldn't be downloaded` : \"The download failed\"),\n}\n\nexport type DownloadButtonIconSlot = \"download\"\n\nconst DEFAULT_ICONS: Record<DownloadButtonIconSlot, ReactNode> = {\n download: <Download className={iconStroke} />,\n}\n\nexport type DownloadButtonProps = Omit<\n ButtonProps,\n \"type\" | \"name\" | \"loading\" | \"startSlot\" | \"onError\"\n> & {\n /** The file: a Blob, a URL, or a function resolving one on click (passed an abort `signal`). */\n data: DownloadSource\n /** The file name. Ignored by browsers for a cross-origin URL; see `saveFile`. */\n name?: string\n /** The MIME type, for a Blob without one. */\n type?: string\n /** Fires when `data` rejects or the save throws. */\n onError?: (error: unknown) => void\n /** Fires once the file has been handed to the browser. */\n onDone?: () => void\n translations?: DownloadButtonTranslations\n /** `download`, the leading icon. `null` renders none. Not shown under `asChild`. */\n icons?: IconMap<DownloadButtonIconSlot>\n}\n\n/** Tailwind's `sr-only`, fixed rather than absolute: it is rendered beside the\n * button, outside any box of ours, and a fixed box can't stretch a scroller. */\nconst statusRegion =\n \"fixed size-px -m-px p-0 overflow-hidden whitespace-nowrap border-0 [clip-path:inset(50%)]\"\n\n/** Calls the loader now, inside the click, and treats a synchronous throw as a rejection. */\nconst started = (load: DownloadLoader, signal: AbortSignal): Promise<DownloadData> => {\n try {\n return Promise.resolve(load({ signal }))\n } catch (error) {\n return Promise.reject(error)\n }\n}\n\nexport const DownloadButton = ({\n data,\n name,\n type,\n onError,\n onDone,\n translations,\n icons,\n asChild,\n children,\n testId,\n onClick,\n variant,\n size,\n color,\n endSlot,\n disabled,\n className,\n ...rest\n}: DownloadButtonProps) => {\n const t = { ...DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS, ...translations }\n const icon = mergeIcons(DEFAULT_ICONS, icons)\n const [busy, setBusy] = useState(false)\n const [failure, setFailure] = useState(\"\")\n // The run in flight, if any: the re-click guard and the unmount abort. A\n // ref, so two clicks in one frame can't both read a stale `busy`.\n const running = useRef<AbortController | null>(null)\n\n useEffect(() => () => running.current?.abort(), [])\n\n const fail = (error: unknown) => {\n setFailure(t.error(name))\n onError?.(error)\n }\n\n // `onDone` sits outside the try, so a throw in the caller's own callback\n // isn't announced as a failed download.\n const save = (value: DownloadData) => {\n try {\n saveFile(value, name, { type })\n } catch (error) {\n return fail(error)\n }\n onDone?.()\n }\n\n const resolve = async (load: DownloadLoader) => {\n const controller = new AbortController()\n running.current = controller\n setBusy(true)\n const outcome = await started(load, controller.signal).then(\n (value) => ({ value }),\n (error: unknown) => ({ error }),\n )\n running.current = null\n // Unmounted meanwhile: nothing to save, and no state left to update.\n if (controller.signal.aborted) return\n setBusy(false)\n if (\"error\" in outcome) fail(outcome.error)\n else save(outcome.value)\n }\n\n // `onClick` runs first, so a caller can `preventDefault()` to stop the save\n // (a confirm step). A value is saved inside the click itself; a function's\n // promise is awaited, and the save follows when it settles.\n const download = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (event.defaultPrevented || disabled || running.current) return\n // An `asChild` link would also follow its own href.\n event.preventDefault()\n setFailure(\"\")\n if (typeof data === \"function\") void resolve(data)\n else save(data)\n }\n\n const trigger = {\n \"data-scope\": \"download-button\",\n \"data-part\": \"trigger\",\n onClick: download,\n ...props({\n \"aria-busy\": busy,\n \"data-loading\": busy,\n \"data-testid\": testId,\n \"data-disabled\": disabled,\n }),\n ...rest,\n }\n\n return (\n <>\n {asChild ? (\n // Only behaviour is merged onto the child: Button's styling would\n // fight an ActionIcon's own. While busy the spinner stands in for the\n // child's content (its icon); its name stays the child's own label.\n <ark.button\n asChild\n disabled={disabled}\n {...props({ \"aria-disabled\": disabled })}\n className={className}\n {...trigger}\n >\n {withAsChildContent(children, (own) => (busy ? <Spinner label={t.loading} /> : own))}\n </ark.button>\n ) : (\n <Button\n variant={variant}\n size={size}\n color={color}\n startSlot={busy ? <Spinner label={null} /> : icon.download}\n endSlot={endSlot}\n disabled={disabled}\n // `relative` holds the sr-only loading text inside the button.\n className={cn(\"relative\", className)}\n {...trigger}\n >\n {children ?? t.label}\n {busy && <span className=\"sr-only\">{t.loading}</span>}\n </Button>\n )}\n <span role=\"status\" className={statusRegion} data-scope=\"download-button\" data-part=\"status\">\n {failure}\n </span>\n </>\n )\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/download-button/download-button.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAkEO,IAAM,oCAAA,GAA6E;AAAA,EACxF,KAAA,EAAO,UAAA;AAAA,EACP,OAAA,EAAS,0BAAA;AAAA,EACT,OAAO,CAAC,IAAA,KAAU,IAAA,GAAO,CAAA,EAAG,IAAI,CAAA,uBAAA,CAAA,GAA4B;AAC9D;AAIA,IAAM,aAAA,GAA2D;AAAA,EAC/D,QAAA,kBAAU,GAAA,CAAC,QAAA,EAAA,EAAS,SAAA,EAAW,UAAA,EAAY;AAC7C,CAAA;AAuBA,IAAM,YAAA,GACJ,2FAAA;AAGF,IAAM,OAAA,GAAU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OAAA,EAAQ;AAAA;AAAA;AAAA,KAChD;AAAA,oBAEF,GAAA,CAAC,MAAA,EAAA,EAAK,IAAA,EAAK,QAAA,EAAS,SAAA,EAAW,cAAc,YAAA,EAAW,iBAAA,EAAkB,WAAA,EAAU,QAAA,EACjF,QAAA,EAAA,OAAA,EACH;AAAA,GAAA,EACF,CAAA;AAEJ","file":"chunk-NLJEQZQQ.js","sourcesContent":["\"use client\"\n\nimport { ark } from \"@ark-ui/react\"\nimport { Download } from \"lucide-react\"\nimport { type MouseEvent, type ReactNode, useEffect, useRef, useState } from \"react\"\nimport { withAsChildContent } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { props } from \"../../lib/props\"\nimport { saveFile } from \"../../lib/save-file\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport { Spinner } from \"../spinner/spinner\"\n\n/**\n * DownloadButton — a button that saves a file: a Blob you already have, a\n * URL, or whatever a function of yours resolves to (an authenticated fetch,\n * a presign call, a generated CSV). The kit makes no request itself.\n *\n * - **While a function's promise is pending** the button is busy: a\n * spinner, `aria-busy`, and re-clicks are ignored, so a double click\n * saves one file. It stays enabled and focused, unlike Button's\n * `loading`, which sets `disabled` and drops keyboard focus.\n * - **On failure**, a polite status region says so (`translations.error`)\n * and `onError` gets the error. Nothing is announced on success: the\n * browser's own download UI is the feedback.\n * - **Unmounting mid-fetch** aborts: the function's `signal` fires and\n * nothing is saved afterwards.\n * - Renders a kit `Button` by default. With `asChild`, only the behaviour\n * goes onto your element (an `ActionIcon` in a row's actions), and its\n * content is swapped for the spinner while busy.\n *\n * Built on `saveFile` (`lib/save-file.ts`) rather than Ark's\n * `DownloadTrigger`: Ark's trigger has no pending state, drops a rejected\n * promise, can't be aborted, and reads a string as the file's *contents*\n * rather than a URL.\n *\n * ```tsx\n * <DownloadButton\n * name=\"transcript.pdf\"\n * data={({ signal }) => api.get(`/transcripts/${id}`, { signal }).then((r) => r.blob())}\n * onError={() => notify.error(\"Couldn't download the transcript\")}\n * />\n * ```\n */\n\n/** What can be saved: a Blob (or File), or a URL. */\nexport type DownloadData = Blob | string\n\n/** Resolves the file on click. `signal` aborts when the button unmounts first. */\nexport type DownloadLoader = (context: {\n signal: AbortSignal\n}) => DownloadData | Promise<DownloadData>\n\n/** What `data` takes: the value itself, or a function that resolves it on click. */\nexport type DownloadSource = DownloadData | DownloadLoader\n\nexport type DownloadButtonTranslations = {\n /** The default label, when there are no `children`. @default \"Download\" */\n label?: string\n /** Added to the button's name while `data` is resolving. @default \"Preparing download…\" */\n loading?: string\n /** What the status region says when the download fails.\n * @default (name) => name ? `${name} couldn't be downloaded` : \"The download failed\" */\n error?: (name: string | undefined) => string\n}\n\nexport const DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS: Required<DownloadButtonTranslations> = {\n label: \"Download\",\n loading: \"Preparing download…\",\n error: (name) => (name ? `${name} couldn't be downloaded` : \"The download failed\"),\n}\n\nexport type DownloadButtonIconSlot = \"download\"\n\nconst DEFAULT_ICONS: Record<DownloadButtonIconSlot, ReactNode> = {\n download: <Download className={iconStroke} />,\n}\n\nexport type DownloadButtonProps = Omit<\n ButtonProps,\n \"type\" | \"name\" | \"loading\" | \"startSlot\" | \"onError\"\n> & {\n /** The file: a Blob, a URL, or a function resolving one on click (passed an abort `signal`). */\n data: DownloadSource\n /** The file name. Ignored by browsers for a cross-origin URL; see `saveFile`. */\n name?: string\n /** The MIME type, for a Blob without one. */\n type?: string\n /** Fires when `data` rejects or the save throws. */\n onError?: (error: unknown) => void\n /** Fires once the file has been handed to the browser. */\n onDone?: () => void\n translations?: DownloadButtonTranslations\n /** `download`, the leading icon. `null` renders none. Not shown under `asChild`. */\n icons?: IconMap<DownloadButtonIconSlot>\n}\n\n/** Tailwind's `sr-only`, fixed rather than absolute: it is rendered beside the\n * button, outside any box of ours, and a fixed box can't stretch a scroller. */\nconst statusRegion =\n \"fixed size-px -m-px p-0 overflow-hidden whitespace-nowrap border-0 [clip-path:inset(50%)]\"\n\n/** Calls the loader now, inside the click, and treats a synchronous throw as a rejection. */\nconst started = (load: DownloadLoader, signal: AbortSignal): Promise<DownloadData> => {\n try {\n return Promise.resolve(load({ signal }))\n } catch (error) {\n return Promise.reject(error)\n }\n}\n\nexport const DownloadButton = ({\n data,\n name,\n type,\n onError,\n onDone,\n translations,\n icons,\n asChild,\n children,\n testId,\n onClick,\n variant,\n size,\n color,\n endSlot,\n disabled,\n className,\n ...rest\n}: DownloadButtonProps) => {\n const t = { ...DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS, ...translations }\n const icon = mergeIcons(DEFAULT_ICONS, icons)\n const [busy, setBusy] = useState(false)\n const [failure, setFailure] = useState(\"\")\n // The run in flight, if any: the re-click guard and the unmount abort. A\n // ref, so two clicks in one frame can't both read a stale `busy`.\n const running = useRef<AbortController | null>(null)\n\n useEffect(() => () => running.current?.abort(), [])\n\n const fail = (error: unknown) => {\n setFailure(t.error(name))\n onError?.(error)\n }\n\n // `onDone` sits outside the try, so a throw in the caller's own callback\n // isn't announced as a failed download.\n const save = (value: DownloadData) => {\n try {\n saveFile(value, name, { type })\n } catch (error) {\n return fail(error)\n }\n onDone?.()\n }\n\n const resolve = async (load: DownloadLoader) => {\n const controller = new AbortController()\n running.current = controller\n setBusy(true)\n const outcome = await started(load, controller.signal).then(\n (value) => ({ value }),\n (error: unknown) => ({ error }),\n )\n running.current = null\n // Unmounted meanwhile: nothing to save, and no state left to update.\n if (controller.signal.aborted) return\n setBusy(false)\n if (\"error\" in outcome) fail(outcome.error)\n else save(outcome.value)\n }\n\n // `onClick` runs first, so a caller can `preventDefault()` to stop the save\n // (a confirm step). A value is saved inside the click itself; a function's\n // promise is awaited, and the save follows when it settles.\n const download = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (event.defaultPrevented || disabled || running.current) return\n // An `asChild` link would also follow its own href.\n event.preventDefault()\n setFailure(\"\")\n if (typeof data === \"function\") void resolve(data)\n else save(data)\n }\n\n const trigger = {\n \"data-scope\": \"download-button\",\n \"data-part\": \"trigger\",\n onClick: download,\n ...props({\n \"aria-busy\": busy,\n \"data-loading\": busy,\n \"data-testid\": testId,\n \"data-disabled\": disabled,\n }),\n ...rest,\n }\n\n return (\n <>\n {asChild ? (\n // Only behaviour is merged onto the child: Button's styling would\n // fight an ActionIcon's own. While busy the spinner stands in for the\n // child's content (its icon); its name stays the child's own label.\n <ark.button\n asChild\n disabled={disabled}\n {...props({ \"aria-disabled\": disabled })}\n className={className}\n {...trigger}\n >\n {withAsChildContent(children, (own) => (busy ? <Spinner label={t.loading} /> : own))}\n </ark.button>\n ) : (\n <Button\n variant={variant}\n size={size}\n color={color}\n startSlot={busy ? <Spinner label={null} /> : icon.download}\n endSlot={endSlot}\n disabled={disabled}\n // `relative` holds the sr-only loading text inside the button.\n className={cn(\"relative\", className)}\n {...trigger}\n >\n {children ?? t.label}\n {busy && <span className=\"sr-only\">{t.loading}</span>}\n </Button>\n )}\n <span role=\"status\" className={statusRegion} data-scope=\"download-button\" data-part=\"status\">\n {failure}\n </span>\n </>\n )\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { InputBase, inputControlClasses, inputSlot } from './chunk-
|
|
2
|
-
import { FieldShell, fieldA11yProps } from './chunk-
|
|
1
|
+
import { InputBase, inputControlClasses, inputSlot } from './chunk-HTVICHT4.js';
|
|
2
|
+
import { useInheritedDisabled, useInheritedInvalid, FieldShell, fieldA11yProps } from './chunk-2RRTT4AF.js';
|
|
3
|
+
import { popoverClearTrigger } from './chunk-YUVKROMA.js';
|
|
3
4
|
import { useMergedRefs } from './chunk-HBWV5EPU.js';
|
|
4
|
-
import { popoverClearTrigger } from './chunk-RKCUXOU2.js';
|
|
5
5
|
import { CloseIcon } from './chunk-6YNLRQ25.js';
|
|
6
6
|
import { mergeIcons, iconStroke } from './chunk-XXOR34T4.js';
|
|
7
7
|
import { props } from './chunk-WYCMIIRR.js';
|
|
@@ -108,7 +108,7 @@ var NumberInput = ({
|
|
|
108
108
|
clearable,
|
|
109
109
|
name,
|
|
110
110
|
invalid,
|
|
111
|
-
disabled,
|
|
111
|
+
disabled: disabledProp,
|
|
112
112
|
readOnly,
|
|
113
113
|
required,
|
|
114
114
|
label,
|
|
@@ -127,9 +127,10 @@ var NumberInput = ({
|
|
|
127
127
|
translations,
|
|
128
128
|
icons: iconsProp
|
|
129
129
|
}) => {
|
|
130
|
+
const disabled = useInheritedDisabled(disabledProp);
|
|
130
131
|
const resolvedTranslations = { ...NUMBER_INPUT_DEFAULT_TRANSLATIONS, ...translations };
|
|
131
132
|
const icons = mergeIcons(DEFAULT_ICONS, iconsProp);
|
|
132
|
-
const isInvalid = invalid || error != null;
|
|
133
|
+
const isInvalid = useInheritedInvalid(invalid || error != null);
|
|
133
134
|
const inputRef = useRef(null);
|
|
134
135
|
const cycle = wrap && min !== void 0 && max !== void 0 ? { min, max } : void 0;
|
|
135
136
|
const fieldRef = useMergedRefs(inputRef, ref);
|
|
@@ -230,5 +231,5 @@ var NumberInput = ({
|
|
|
230
231
|
};
|
|
231
232
|
|
|
232
233
|
export { NUMBER_INPUT_DEFAULT_TRANSLATIONS, NumberInput };
|
|
233
|
-
//# sourceMappingURL=chunk-
|
|
234
|
-
//# sourceMappingURL=chunk-
|
|
234
|
+
//# sourceMappingURL=chunk-QHT4DCXE.js.map
|
|
235
|
+
//# sourceMappingURL=chunk-QHT4DCXE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/number-input/number-input.tsx"],"names":["Ark"],"mappings":";;;;;;;;;;;;;;AA6CO,IAAM,iCAAA,GAAoC;AAAA,EAC/C,cAAA,EAAgB,WAAA;AAAA,EAChB,cAAA,EAAgB,WAAA;AAAA,EAChB,iBAAA,EAAmB;AACrB;AAMO,IAAM,aAAA,GAAwD;AAAA,EACnE,SAAA,kBAAW,GAAA,CAAC,SAAA,EAAA,EAAU,SAAA,EAAW,UAAA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Y,SAAA,EAAW,EAAA,CAAG,qBAAA,EAAuB,UAAA,EAAY,OAAO,CAAA,EAGnE,QAAA,EAAA;AAAA,oCAAA,GAAA,CAACA,cAAI,gBAAA,EAAJ,EAAqB,SAAA,EAAW,cAAA,EAC9B,gBAAM,SAAA,EACT,CAAA;AAAA,wCACCA,aAAA,CAAI,gBAAA,EAAJ,EAAqB,SAAA,EAAW,cAAA,EAC9B,gBAAM,SAAA,EACT;AAAA,mBAAA,EACF;AAAA;AAAA;AAAA,aAEJ;AAAA,UAEJ,CAAA,EACF;AAAA;AAAA;AACF;AAAA,GACF;AAEJ","file":"chunk-QHT4DCXE.js","sourcesContent":["\"use client\"\n\nimport { useFieldContext } from \"@ark-ui/react/field\"\nimport { NumberInput as Ark, useNumberInputContext } from \"@ark-ui/react/number-input\"\nimport { ChevronDown, ChevronUp } from \"lucide-react\"\nimport {\n type ComponentProps,\n type FocusEvent,\n type KeyboardEvent,\n type ReactNode,\n type Ref,\n useRef,\n} from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { useMergedRefs } from \"../../lib/merge-refs\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport {\n type FieldProps,\n FieldShell,\n fieldA11yProps,\n useInheritedDisabled,\n useInheritedInvalid,\n} from \"../field/field\"\nimport {\n InputBase,\n type InputSize,\n type InputVariant,\n inputControlClasses,\n inputSlot,\n} from \"../input/input\"\nimport { CloseIcon } from \"../popover/icons\"\nimport { popoverClearTrigger } from \"../popover/popover\"\n\n/** Ark's own NumberInput `translations` type (`incrementLabel`, `decrementLabel`, and\n * `valueText` for `aria-valuetext`), derived structurally rather than imported from\n * `@zag-js/number-input`, plus the combobox family's `clearTriggerLabel` for the kit's own\n * clear button. */\nexport type NumberInputTranslations = NonNullable<\n ComponentProps<typeof Ark.Root>[\"translations\"]\n> & {\n clearTriggerLabel?: string\n}\n\nexport const NUMBER_INPUT_DEFAULT_TRANSLATIONS = {\n incrementLabel: \"Increment\",\n decrementLabel: \"Decrement\",\n clearTriggerLabel: \"Clear value\",\n} as const satisfies NumberInputTranslations\n\nexport type NumberInputIconSlot = \"increment\" | \"decrement\" | \"clear\"\nexport type NumberInputIcons = IconMap<NumberInputIconSlot>\n\n/** The default icons: the steppers' chevrons and the clear button's ×. */\nexport const DEFAULT_ICONS: Record<NumberInputIconSlot, ReactNode> = {\n increment: <ChevronUp className={iconStroke} />,\n decrement: <ChevronDown className={iconStroke} />,\n clear: <CloseIcon />,\n}\n\n/**\n * NumberInput — a numeric `<input>` with increment / decrement steppers on Ark\n * UI's NumberInput machine. It lives on the same shell as [`Input`](/docs/input)\n * (border, focus ring, slots, invalid / disabled states) and adds spin buttons,\n * clamping, locale-aware formatting, and the full keyboard / wheel model.\n *\n * - Value is a real `number` here (or `null` for empty): the machine speaks\n * strings internally, but `value` / `defaultValue` take a `number | null`\n * and `onChange` hands one back — `null` whenever the field has no valid\n * number (empty, or mid-edit on a partial token).\n * - Like the rest of the family it carries its own `label` / `description` /\n * `error` / `required` via [`Field`](/docs/field); `error` flips the red\n * state, or set `invalid` directly.\n * - `hideControls` drops the steppers for a plain numeric field.\n * - `clearable` adds a clear (×) button once there's a value, resetting to\n * `null` — the numeric analogue of `Select`'s `clearable`.\n *\n * Palette rides on `data-color`, matching the family — but the shell's focus\n * halo is a fixed `brand-500`, so nothing here actually tints today.\n */\n\ntype NumberInputClassNames = {\n /** The field wrapper (label / description / error). */\n field?: string\n /** The label element itself — e.g. `\"sr-only\"` to keep the accessible name\n * without showing it (pair with `suffix` for a unit hint in its place). */\n label?: string\n /** The shell `<div>` (also targeted by `className`). */\n root?: string\n /** The inner `<input>` element. */\n input?: string\n /** The stepper column wrapping the increment / decrement triggers. */\n control?: string\n}\n\nexport type NumberInputProps = Pick<FieldProps, \"label\" | \"description\" | \"error\" | \"required\"> &\n WithTestId & {\n /** Controlled value; `null` for empty. */\n value?: number | null\n /** Uncontrolled initial value; `null` for empty. */\n defaultValue?: number | null\n /** Fires with the next numeric value, or `null` when the field has no valid number. */\n onChange?: (value: number | null) => void\n /** Minimum value. */\n min?: number\n /** Maximum value. */\n max?: number\n /** Increment / decrement step. */\n step?: number\n /** Placeholder shown while the field is empty. */\n placeholder?: string\n /** Options forwarded to `Intl.NumberFormat` for display (currency, percent, …). */\n formatOptions?: Intl.NumberFormatOptions\n /** Allow the mouse wheel to change the value while focused. */\n allowMouseWheel?: boolean\n /** Clamp the value into `[min, max]` when the input blurs. */\n clampValueOnBlur?: boolean\n /** Wrap past `min` / `max` instead of clamping (23 → 0, 0 → 59, …) — for\n * cyclical fields like hours/minutes. Requires both `min` and `max`, and\n * the field to be used controlled: the wrapped value round-trips back in\n * as `value` on the next render to correct the display.\n *\n * Only *stepping* wraps (arrow keys, steppers, wheel). Typing behaves like\n * a clock segment instead: a digit that would overflow `max` (or its digit\n * count) replaces the whole field rather than being inserted, so `10` + a\n * `2` typed at the start reads `2`, not `210`. A typed value still out of\n * range (a partial `0` in a 1–12 field, a paste) isn't reported until it\n * is either completed or clamped into range on blur. */\n wrap?: boolean\n /** Hide the increment / decrement steppers for a plain numeric field. */\n hideControls?: boolean\n /** Show a clear button once there's a value, resetting to `null`. */\n clearable?: boolean\n /** Field name for native form submission. */\n name?: string\n /** Red invalid state; OR'd with `error`. */\n invalid?: boolean\n /** Dims the shell and disables the input. */\n disabled?: boolean\n /** Keeps full contrast but blocks edits. */\n readOnly?: boolean\n variant?: InputVariant\n size?: InputSize\n /** Inline-start adornment (icon, prefix). */\n startSlot?: ReactNode\n /** Non-interactive unit hint (e.g. `\"h\"`, `\"%\"`) rendered right after the\n * value, before the clear button / steppers — `aria-hidden` and\n * non-selectable, never part of the editable value. Distinct from a\n * generic end adornment: `InputBase`'s `endSlot` renders after *all*\n * content (i.e. after the steppers here), which would sit away from the\n * digits instead of glued to them. */\n suffix?: ReactNode\n /** Explicit id for label association. */\n id?: string\n /** Lands on the `<input>` for focus-on-error. */\n ref?: Ref<HTMLInputElement>\n /** Forwarded to the `<input>`; drives touched/blurred validation. */\n onBlur?: (event: FocusEvent<HTMLInputElement>) => void\n className?: string\n classNames?: NumberInputClassNames\n /** Overrides the steppers' (`incrementLabel`, `decrementLabel`, default `\"Increment\"` /\n * `\"Decrement\"`) and the clear button's (`clearTriggerLabel`, default `\"Clear value\"`)\n * accessible names, and sets `valueText` (the input's `aria-valuetext`). A partial override\n * keeps the other defaults. */\n translations?: NumberInputTranslations\n /** Replaces the default icons: `increment`, `decrement`, `clear`. A missing key keeps its\n * default. */\n icons?: NumberInputIcons\n }\n\n/** The increment / decrement steppers — one class list for both, so they share one disabled\n * treatment. */\nconst stepperTrigger = cn(\n \"inline-flex h-1/2 w-6 shrink-0 cursor-pointer items-center justify-center rounded-xxs transition-colors\",\n \"[&:hover:not([data-disabled])]:bg-brand-900/6 dark:[&:hover:not([data-disabled])]:bg-white/8\",\n \"data-disabled:cursor-not-allowed data-disabled:text-brand-900/40 dark:data-disabled:text-white/35\",\n)\n\n/** Bridge the kit's `number | null` value to the machine's string contract:\n * `undefined` stays uncontrolled, `null` is a controlled empty field. */\nconst toArkValue = (value: number | null | undefined): string | undefined =>\n value === undefined ? undefined : value === null ? \"\" : String(value)\n\n/** Wrap `raw` into `[min, max]` (inclusive), e.g. `wrapValue(24, 0, 23) === 0`. */\nconst wrapValue = (raw: number, min: number, max: number): number => {\n const span = max - min + 1\n return ((((raw - min) % span) + span) % span) + min\n}\n\n/** `wrap`'s bounds. */\ntype WrapCycle = { min: number; max: number }\n\n/** Under `wrap`, select the whole field before a digit lands if inserting it at\n * the caret would overflow `max` (by value or digit count) — the browser's own\n * insertion then replaces the field with that digit, like a clock segment. */\nconst selectOnOverflow = (event: KeyboardEvent<HTMLInputElement>, max: number) => {\n if (!/^\\d$/.test(event.key) || event.ctrlKey || event.metaKey || event.altKey) return\n const input = event.currentTarget\n const { value } = input\n const start = input.selectionStart ?? value.length\n const end = input.selectionEnd ?? value.length\n const next = value.slice(0, start) + event.key + value.slice(end)\n if (next.length > String(max).length || Number(next) > max) input.select()\n}\n\n/**\n * The real `<input>`, split out so it reads the `Field` context from *inside*\n * the wrapping `FieldShell` — `NumberInput` itself renders that shell, so\n * calling `useFieldContext()` at its own top level would run too early.\n */\nconst NumberInputField = ({\n ref,\n placeholder,\n onBlur,\n testId,\n className,\n cycle,\n}: {\n ref?: Ref<HTMLInputElement>\n placeholder?: string\n onBlur?: (event: FocusEvent<HTMLInputElement>) => void\n testId?: string\n className?: string\n cycle?: WrapCycle\n}) => {\n const field = useFieldContext()\n const api = useNumberInputContext()\n if (!cycle) {\n return (\n <Ark.Input\n ref={ref}\n placeholder={placeholder}\n onBlur={onBlur}\n data-testid={testId}\n {...fieldA11yProps(field)}\n className={className}\n />\n )\n }\n return (\n <Ark.Input\n ref={ref}\n placeholder={placeholder}\n onKeyDown={(event) => selectOnOverflow(event, cycle.max)}\n // Home/End jump to Ark's own `min`/`max`, which it never sees under `wrap` — it would land\n // on ±`MAX_SAFE_INTEGER` and wrap to an arbitrary value. Capture runs before Ark's own\n // handler; stopping propagation is what skips it (Ark's `defaultPrevented` bail-out reads\n // the synthetic event's creation-time snapshot, so `preventDefault` alone doesn't).\n onKeyDownCapture={(event) => {\n if (event.key !== \"Home\" && event.key !== \"End\") return\n if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return\n event.preventDefault()\n event.stopPropagation()\n api.setValue(event.key === \"Home\" ? cycle.min : cycle.max)\n }}\n onBlur={(event) => {\n // A typed value never wraps, so one left out of range is clamped here instead —\n // Ark's own clamp-on-blur is off under `wrap` (it never sees `min`/`max`).\n const raw = api.valueAsNumber\n if (!Number.isNaN(raw) && (raw < cycle.min || raw > cycle.max)) {\n api.setValue(Math.min(Math.max(raw, cycle.min), cycle.max))\n }\n onBlur?.(event)\n }}\n // Ark only sees `min`/`max` outside `wrap`, so restore the real range here.\n aria-valuemin={cycle.min}\n aria-valuemax={cycle.max}\n data-testid={testId}\n {...fieldA11yProps(field)}\n className={className}\n />\n )\n}\n\nexport const NumberInput = ({\n value,\n defaultValue,\n onChange,\n min,\n max,\n step,\n placeholder,\n formatOptions,\n allowMouseWheel,\n clampValueOnBlur,\n wrap,\n hideControls,\n clearable,\n name,\n invalid,\n disabled: disabledProp,\n readOnly,\n required,\n label,\n description,\n error,\n variant = \"default\",\n size = \"md\",\n startSlot,\n suffix,\n id,\n ref,\n onBlur,\n className,\n classNames,\n testId,\n translations,\n icons: iconsProp,\n}: NumberInputProps) => {\n // An enclosing `Field` or `Fieldset` disables it too: the shell only dims on\n // the `disabled` handed to it here.\n const disabled = useInheritedDisabled(disabledProp)\n const resolvedTranslations = { ...NUMBER_INPUT_DEFAULT_TRANSLATIONS, ...translations }\n const icons = mergeIcons(DEFAULT_ICONS, iconsProp)\n // Drive the red state independently of the `Field` error slot so a form\n // library can flip it from `fieldState.invalid` (see FormControlProps).\n const isInvalid = useInheritedInvalid(invalid || error != null)\n const inputRef = useRef<HTMLInputElement>(null)\n const cycle: WrapCycle | undefined =\n wrap && min !== undefined && max !== undefined ? { min, max } : undefined\n\n const fieldRef = useMergedRefs(inputRef, ref)\n return (\n <FieldShell\n label={label}\n description={description}\n error={error}\n required={required}\n disabled={disabled}\n size={size}\n className={classNames?.field}\n classNames={{ label: classNames?.label }}\n >\n <Ark.Root\n value={toArkValue(value)}\n defaultValue={toArkValue(defaultValue)}\n onValueChange={\n onChange\n ? (details) => {\n const raw = details.valueAsNumber\n if (Number.isNaN(raw)) {\n onChange(null)\n } else if (cycle) {\n // Only stepping wraps. A typed change is already in the `<input>` when it is\n // reported, while a stepped one (arrows, steppers, wheel) is only written to\n // the DOM on Ark's next frame — so a match means the user typed it. Typed\n // values are reported as-is when in range; an out-of-range one is held until\n // it is completed or clamped on blur (see `NumberInputField`).\n const typed = details.value === inputRef.current?.value\n if (!typed) onChange(wrapValue(raw, cycle.min, cycle.max))\n else if (raw >= cycle.min && raw <= cycle.max) onChange(raw)\n } else {\n onChange(raw)\n }\n }\n : undefined\n }\n // Wrapping fields disable Ark's own clamp so it always reports the true\n // out-of-range stepped value — `wrapValue` above normalizes it instead.\n min={wrap ? undefined : min}\n max={wrap ? undefined : max}\n step={step}\n formatOptions={formatOptions}\n allowMouseWheel={allowMouseWheel}\n clampValueOnBlur={clampValueOnBlur}\n name={name}\n {...props({ invalid: isInvalid, disabled, readOnly, required })}\n ids={id ? { input: id } : undefined}\n translations={resolvedTranslations}\n className={cn(\"w-full\", className)}\n >\n <Ark.Context>\n {(api) => {\n // `canClear` reserves the clear button's layout box (and the\n // shell's end-slot padding) for the whole time the field is\n // clearable, not just while it has a value — otherwise the\n // button mounting/unmounting shifts the input's width. `showClear`\n // only toggles its visibility/interactivity via `invisible`.\n const canClear = Boolean(clearable) && !disabled && !readOnly\n const showClear = canClear && !api.empty\n return (\n <InputBase\n variant={variant}\n size={size}\n invalid={isInvalid}\n disabled={disabled}\n readOnly={readOnly}\n startSlot={startSlot}\n // The steppers (and the clear button) are interactive — they must\n // not sit inside the `aria-hidden` end-slot span. Render them as\n // direct children instead, and flag the shell's end padding\n // manually so the layout matches an `endSlot`.\n classNames={{ root: classNames?.root }}\n className=\"pe-0! overflow-clip\"\n {...props({ \"data-with-end-slot\": !hideControls || canClear || suffix != null })}\n >\n {/* The shell's own `gap-*` (`shellGap`) is meant for *slots* — spacing the\n * control away from icons/steppers/clear button — not for the suffix, which is\n * documented (and used, e.g. `TimeRow`'s \"23h\") to sit glued right against the\n * value. Wrapping the two together in their own `gap`-less flex row keeps that\n * glued pairing regardless of `size`, while the shell's real gap still applies\n * between this pair and the next sibling (clear button / steppers). */}\n <div className=\"flex min-w-0 flex-1 items-center\">\n <NumberInputField\n ref={fieldRef}\n placeholder={placeholder}\n onBlur={onBlur}\n testId={testId}\n cycle={cycle}\n className={cn(inputControlClasses, classNames?.input)}\n />\n {suffix != null && (\n <span aria-hidden className={cn(inputSlot, \"select-none\")}>\n {suffix}\n </span>\n )}\n </div>\n {canClear && (\n <button\n type=\"button\"\n aria-label={resolvedTranslations.clearTriggerLabel}\n aria-hidden={!showClear}\n tabIndex={showClear ? 0 : -1}\n onPointerDown={(event) => event.preventDefault()}\n onClick={() => api.clearValue()}\n className={cn(popoverClearTrigger, !showClear && \"invisible\")}\n >\n {icons.clear}\n </button>\n )}\n {!hideControls && (\n <Ark.Control className={cn(\"-my-1 flex flex-col\", classNames?.control)}>\n {/* Ark disables each stepper at its own bound (it only sees `min`/`max`\n * outside `wrap`, so wrapping fields keep both enabled) — controlled or not. */}\n <Ark.IncrementTrigger className={stepperTrigger}>\n {icons.increment}\n </Ark.IncrementTrigger>\n <Ark.DecrementTrigger className={stepperTrigger}>\n {icons.decrement}\n </Ark.DecrementTrigger>\n </Ark.Control>\n )}\n </InputBase>\n )\n }}\n </Ark.Context>\n </Ark.Root>\n </FieldShell>\n )\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { popoverChrome } from './chunk-
|
|
2
|
-
import { Tooltip } from './chunk-
|
|
3
|
-
import { useUncontrolled } from './chunk-PMUCGFY5.js';
|
|
1
|
+
import { popoverChrome } from './chunk-YUVKROMA.js';
|
|
2
|
+
import { Tooltip } from './chunk-FED6SJWM.js';
|
|
4
3
|
import { Collapse } from './chunk-NKOTA5TM.js';
|
|
5
4
|
import { iconStroke, mergeIcons } from './chunk-XXOR34T4.js';
|
|
5
|
+
import { useUncontrolled } from './chunk-PMUCGFY5.js';
|
|
6
6
|
import { props } from './chunk-WYCMIIRR.js';
|
|
7
7
|
import { focusStyles } from './chunk-C6NVU4F7.js';
|
|
8
8
|
import { TEXT_COLOR_CLASSES } from './chunk-GIPQUKCN.js';
|
|
@@ -226,5 +226,5 @@ function CodeBlockChrome({
|
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
export { CodeBlockButton, CodeBlockChrome, DEFAULT_ICONS };
|
|
229
|
-
//# sourceMappingURL=chunk-
|
|
230
|
-
//# sourceMappingURL=chunk-
|
|
229
|
+
//# sourceMappingURL=chunk-RMUBCTEF.js.map
|
|
230
|
+
//# sourceMappingURL=chunk-RMUBCTEF.js.map
|