@42-central/ui-react 0.29.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/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/timeline/index.js +8 -1
- package/dist/components/timeline/index.js.map +1 -1
- package/dist/components/timeline/timeline.d.ts.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/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/timeline/timeline.test.tsx +22 -0
- package/src/components/timeline/timeline.tsx +10 -1
- 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
|
@@ -0,0 +1,796 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { ark, type HTMLArkProps } from "@ark-ui/react"
|
|
4
|
+
import { createTreeCollection, type UseTreeViewReturn, useTreeView } from "@ark-ui/react/tree-view"
|
|
5
|
+
import { mergeProps } from "@ark-ui/react/utils"
|
|
6
|
+
import { FileIcon, FolderIcon, FolderOpenIcon } from "lucide-react"
|
|
7
|
+
import {
|
|
8
|
+
createContext,
|
|
9
|
+
type KeyboardEvent,
|
|
10
|
+
type MouseEvent,
|
|
11
|
+
type ReactNode,
|
|
12
|
+
type Ref,
|
|
13
|
+
useContext,
|
|
14
|
+
useMemo,
|
|
15
|
+
useState,
|
|
16
|
+
} from "react"
|
|
17
|
+
import { composeChildren, type NoAsChild } from "../../lib/as-child"
|
|
18
|
+
import { cn } from "../../lib/cn"
|
|
19
|
+
import type { Color } from "../../lib/colors"
|
|
20
|
+
import { type IconMap, iconStroke, mergeIcons } from "../../lib/icons"
|
|
21
|
+
import { useDirectionCheck } from "../../lib/intl"
|
|
22
|
+
import { useMergedRefs } from "../../lib/merge-refs"
|
|
23
|
+
import { props } from "../../lib/props"
|
|
24
|
+
import type { Size } from "../../lib/sizes"
|
|
25
|
+
import type { WithTestId } from "../../lib/test-id"
|
|
26
|
+
import {
|
|
27
|
+
getCheckState,
|
|
28
|
+
getLeafValues,
|
|
29
|
+
type TreeNodeData,
|
|
30
|
+
type TreePayload,
|
|
31
|
+
type TreeSelectData,
|
|
32
|
+
type TreeValue,
|
|
33
|
+
toggleChecked,
|
|
34
|
+
} from "../../lib/tree-data"
|
|
35
|
+
import { TEXT_COLOR_CLASSES } from "../../lib/typography-size"
|
|
36
|
+
import { useUncontrolled } from "../../lib/use-uncontrolled"
|
|
37
|
+
import { Collapse } from "../collapse/collapse"
|
|
38
|
+
import { CheckIcon, ChevronIcon, MinusIcon } from "../popover/icons"
|
|
39
|
+
import { Spinner } from "../spinner/spinner"
|
|
40
|
+
import {
|
|
41
|
+
TreeCheckMark,
|
|
42
|
+
type TreePosition,
|
|
43
|
+
TreeRow,
|
|
44
|
+
treeLine,
|
|
45
|
+
treePositions,
|
|
46
|
+
treeText,
|
|
47
|
+
} from "./tree-row"
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Tree — a standalone, always-visible tree view on Ark UI's `tree-view` machine: a repo's
|
|
51
|
+
* file tree, a curriculum's modules, any hierarchy people browse rather than pick from a
|
|
52
|
+
* dropdown (for that, use `TreeSelect` / `TreeMultiSelect`, which take the same `data`).
|
|
53
|
+
*
|
|
54
|
+
* // 1. Data-driven — the common case
|
|
55
|
+
* <Tree data={files} defaultExpanded={["src"]} onNodeClick={(node) => open(node.value)} />
|
|
56
|
+
*
|
|
57
|
+
* // 2. Compound — your own row content, built from the parts
|
|
58
|
+
* <Tree.Root data={files}>
|
|
59
|
+
* <Tree.List>
|
|
60
|
+
* {(node, state) => (
|
|
61
|
+
* <>
|
|
62
|
+
* <Tree.Indicator />
|
|
63
|
+
* <Tree.Icon />
|
|
64
|
+
* <Tree.Text />
|
|
65
|
+
* {state.leaf && <Badge size="xs">{node.payload.size}</Badge>}
|
|
66
|
+
* </>
|
|
67
|
+
* )}
|
|
68
|
+
* </Tree.List>
|
|
69
|
+
* </Tree.Root>
|
|
70
|
+
*
|
|
71
|
+
* Ark owns selection, expansion, focus, typeahead, the keyboard model and lazy loading. The
|
|
72
|
+
* kit renders the rows itself so a branch's children animate through `Collapse` (the CSS
|
|
73
|
+
* `0fr` → `1fr` row track), never Ark's JS height measurement, and owns the checkbox state so
|
|
74
|
+
* it cascades exactly as `TreeMultiSelect`'s does: `checked` holds leaf values, a branch is
|
|
75
|
+
* derived, disabled leaves keep their state.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
/** Indent per level: the rails' column, the chevron's, and the gap the elbow spans. */
|
|
79
|
+
const iconSize: Record<Size, string> = {
|
|
80
|
+
xs: "[&_svg]:size-3.5",
|
|
81
|
+
sm: "[&_svg]:size-4",
|
|
82
|
+
md: "[&_svg]:size-4",
|
|
83
|
+
lg: "[&_svg]:size-5",
|
|
84
|
+
xl: "[&_svg]:size-5",
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** A selected row: Figma's `Background/bg-active`, a step above the hover wash. */
|
|
88
|
+
const selectedRow = "data-selected:bg-brand-900/10 dark:data-selected:bg-white/16"
|
|
89
|
+
|
|
90
|
+
/** Live node state handed to a row renderer and read by the parts. */
|
|
91
|
+
export type TreeItemState = {
|
|
92
|
+
/** 0-based; the row's `aria-level` is `depth + 1`. */
|
|
93
|
+
depth: number
|
|
94
|
+
/** No children and nothing left to load. */
|
|
95
|
+
leaf: boolean
|
|
96
|
+
selected: boolean
|
|
97
|
+
expanded: boolean
|
|
98
|
+
/** Its children are loading through `loadChildren`. */
|
|
99
|
+
loading: boolean
|
|
100
|
+
/** Its checkbox is checked (a branch: every enabled leaf below it is). */
|
|
101
|
+
checked: boolean
|
|
102
|
+
/** A branch with some, not all, of its enabled leaves checked. */
|
|
103
|
+
indeterminate: boolean
|
|
104
|
+
/** Disabled itself, through an ancestor, or through the tree's `disabled`. */
|
|
105
|
+
disabled: boolean
|
|
106
|
+
/** The tree's one tab stop: the row focus returns to. */
|
|
107
|
+
focused: boolean
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Fill a row yourself. The tree keeps the row (its `treeitem` role, indent rails, roving
|
|
112
|
+
* focus, click and keys); the callback fills what comes after the rails, usually from the
|
|
113
|
+
* parts: `Tree.Indicator`, `Tree.Checkbox`, `Tree.Icon`, `Tree.Text`, `Tree.Actions`.
|
|
114
|
+
*/
|
|
115
|
+
export type RenderTreeItem<P = unknown> = (node: TreeNodeData<P>, state: TreeItemState) => ReactNode
|
|
116
|
+
|
|
117
|
+
export type TreeIconSlot =
|
|
118
|
+
| "chevron"
|
|
119
|
+
| "folder"
|
|
120
|
+
| "folderOpen"
|
|
121
|
+
| "file"
|
|
122
|
+
| "check"
|
|
123
|
+
| "indeterminate"
|
|
124
|
+
| "loading"
|
|
125
|
+
/** `folder`, `folderOpen`, `file`: `null` draws no icon. */
|
|
126
|
+
export type TreeIcons = IconMap<TreeIconSlot>
|
|
127
|
+
|
|
128
|
+
/** The default icons. The chevron points down and turns a quarter towards the inline end
|
|
129
|
+
* while closed, so it follows `dir` without a mirrored glyph. */
|
|
130
|
+
const DEFAULT_ICONS: Record<TreeIconSlot, ReactNode> = {
|
|
131
|
+
chevron: <ChevronIcon />,
|
|
132
|
+
folder: <FolderIcon className={iconStroke} />,
|
|
133
|
+
folderOpen: <FolderOpenIcon className={iconStroke} />,
|
|
134
|
+
file: <FileIcon className={iconStroke} />,
|
|
135
|
+
check: <CheckIcon />,
|
|
136
|
+
indeterminate: <MinusIcon />,
|
|
137
|
+
loading: <Spinner label={null} />,
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export type TreeTranslations = {
|
|
141
|
+
/** The tree's accessible name, when no `Tree.Label` names it. Default `"Tree"`. */
|
|
142
|
+
treeLabel?: string
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export const TREE_DEFAULT_TRANSLATIONS = {
|
|
146
|
+
treeLabel: "Tree",
|
|
147
|
+
} as const satisfies Required<TreeTranslations>
|
|
148
|
+
|
|
149
|
+
export type TreeClassNames = {
|
|
150
|
+
/** The `role="tree"` list. */
|
|
151
|
+
tree?: string
|
|
152
|
+
/** Every row. */
|
|
153
|
+
node?: string
|
|
154
|
+
/** A branch's children group (the `Collapse`). */
|
|
155
|
+
group?: string
|
|
156
|
+
indicator?: string
|
|
157
|
+
checkbox?: string
|
|
158
|
+
icon?: string
|
|
159
|
+
/** A row's text. */
|
|
160
|
+
label?: string
|
|
161
|
+
actions?: string
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
type TreeContextValue = {
|
|
165
|
+
api: UseTreeViewReturn<TreeNodeData>
|
|
166
|
+
size: Size
|
|
167
|
+
withLines: boolean
|
|
168
|
+
withCheckbox: boolean
|
|
169
|
+
icons: Record<TreeIconSlot, ReactNode>
|
|
170
|
+
classNames?: TreeClassNames
|
|
171
|
+
checked: ReadonlySet<string>
|
|
172
|
+
toggle: (node: TreeNodeData) => void
|
|
173
|
+
onNodeClick?: (node: TreeNodeData, event: MouseEvent<HTMLElement>) => void
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const TreeContext = createContext<TreeContextValue | null>(null)
|
|
177
|
+
|
|
178
|
+
const useTreeContext = (part: string) => {
|
|
179
|
+
const context = useContext(TreeContext)
|
|
180
|
+
if (!context) throw new Error(`[@42/ui-react] <Tree.${part}> must be inside <Tree.Root>.`)
|
|
181
|
+
return context
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
type NodeContextValue = {
|
|
185
|
+
node: TreeNodeData
|
|
186
|
+
indexPath: number[]
|
|
187
|
+
state: TreeItemState
|
|
188
|
+
testId: string
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const NodeContext = createContext<NodeContextValue | null>(null)
|
|
192
|
+
|
|
193
|
+
const useNodeContext = (part: string) => {
|
|
194
|
+
const context = useContext(NodeContext)
|
|
195
|
+
if (!context)
|
|
196
|
+
throw new Error(`[@42/ui-react] <Tree.${part}> must be inside a row, in <Tree.List>.`)
|
|
197
|
+
return context
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** The live tree: Ark's API and the kit's checkbox state, for a part of your own. */
|
|
201
|
+
export const useTree = () => useTreeContext("useTree")
|
|
202
|
+
/** The row being rendered: its node, index path, state and `testId`. */
|
|
203
|
+
export const useTreeNode = () => useNodeContext("useTreeNode")
|
|
204
|
+
|
|
205
|
+
/** The tree's own root node value, never a `data` value. */
|
|
206
|
+
const ROOT = "\u0000tree-root"
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* `data` as the machine sees it: each loaded branch's children spliced in, and `disabled`
|
|
210
|
+
* pushed down to every descendant (Ark reads a node's own flag only).
|
|
211
|
+
*/
|
|
212
|
+
const resolveNodes = <P,>(
|
|
213
|
+
nodes: ReadonlyArray<TreeNodeData<P>>,
|
|
214
|
+
loaded: ReadonlyMap<string, TreeNodeData<P>[]>,
|
|
215
|
+
inheritedDisabled: boolean,
|
|
216
|
+
): TreeNodeData<P>[] =>
|
|
217
|
+
nodes.map((node) => {
|
|
218
|
+
const disabled = inheritedDisabled || !!node.disabled
|
|
219
|
+
const children = node.children ?? loaded.get(node.value)
|
|
220
|
+
if (!children && disabled === !!node.disabled) return node
|
|
221
|
+
return {
|
|
222
|
+
...node,
|
|
223
|
+
disabled,
|
|
224
|
+
...(children && { children: resolveNodes(children, loaded, disabled) }),
|
|
225
|
+
}
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
export type TreeRootProps<Data extends TreeSelectData = TreeNodeData[]> = Omit<
|
|
229
|
+
HTMLArkProps<"div">,
|
|
230
|
+
"defaultChecked" | "color" | "children"
|
|
231
|
+
> &
|
|
232
|
+
WithTestId & {
|
|
233
|
+
/** The hierarchy: `{ value, label, disabled?, children?, hasChildren?, icon?, payload? }`,
|
|
234
|
+
* the same nodes `TreeSelect` and `TreeMultiSelect` take. */
|
|
235
|
+
data: Data
|
|
236
|
+
/** Let several nodes be selected: ⌘/Ctrl-click toggles, Shift extends, ⌘A takes all. */
|
|
237
|
+
multiple?: boolean
|
|
238
|
+
/** Controlled selected values. */
|
|
239
|
+
selected?: TreeValue<Data>[]
|
|
240
|
+
/** Uncontrolled initial selected values. */
|
|
241
|
+
defaultSelected?: TreeValue<Data>[]
|
|
242
|
+
/** Fires with the next selected values. */
|
|
243
|
+
onSelectedChange?: (selected: TreeValue<Data>[]) => void
|
|
244
|
+
/** Controlled expanded branch values. */
|
|
245
|
+
expanded?: TreeValue<Data>[]
|
|
246
|
+
/** Uncontrolled initial expanded branch values. */
|
|
247
|
+
defaultExpanded?: TreeValue<Data>[]
|
|
248
|
+
/** Fires with the next expanded branch values. */
|
|
249
|
+
onExpandedChange?: (expanded: TreeValue<Data>[]) => void
|
|
250
|
+
/** Draw a checkbox on every row. Checking a branch cascades to its enabled leaves. */
|
|
251
|
+
withCheckbox?: boolean
|
|
252
|
+
/** Controlled checked **leaf** values; a branch's state is derived. */
|
|
253
|
+
checked?: TreeValue<Data>[]
|
|
254
|
+
/** Uncontrolled initial checked leaf values. */
|
|
255
|
+
defaultChecked?: TreeValue<Data>[]
|
|
256
|
+
/** Fires with the next checked leaf values. */
|
|
257
|
+
onCheckedChange?: (checked: TreeValue<Data>[]) => void
|
|
258
|
+
/** Load a `hasChildren` branch's children on its first expand. The row shows a spinner
|
|
259
|
+
* until it resolves; a rejection leaves the branch closed, so expanding it again retries. */
|
|
260
|
+
loadChildren?: (
|
|
261
|
+
node: TreeNodeData<TreePayload<Data>>,
|
|
262
|
+
details: { signal: AbortSignal },
|
|
263
|
+
) => Promise<TreeNodeData[]>
|
|
264
|
+
/** Fires when `loadChildren` rejects. */
|
|
265
|
+
onLoadError?: (node: TreeNodeData<TreePayload<Data>>, error: unknown) => void
|
|
266
|
+
/** Fires on a row click (not on its chevron, checkbox or actions). */
|
|
267
|
+
onNodeClick?: (node: TreeNodeData<TreePayload<Data>>, event: MouseEvent<HTMLElement>) => void
|
|
268
|
+
/** Clicking a branch row toggles it. With `false`, only its chevron and the arrow keys do.
|
|
269
|
+
* Default `true`. */
|
|
270
|
+
expandOnClick?: boolean
|
|
271
|
+
/** Typing a node's first letters focuses it. Default `true`. */
|
|
272
|
+
typeahead?: boolean
|
|
273
|
+
/** Disables every node. */
|
|
274
|
+
disabled?: boolean
|
|
275
|
+
/** Draw the indentation guides. Default `true`. */
|
|
276
|
+
withLines?: boolean
|
|
277
|
+
/** Row height, text and icon size. Default `"md"`. */
|
|
278
|
+
size?: Size
|
|
279
|
+
/** The palette of the checkboxes and the focus ring. */
|
|
280
|
+
color?: Color
|
|
281
|
+
/** Replaces the default icons: `chevron`, `folder`, `folderOpen`, `file` (`null` draws
|
|
282
|
+
* none), `check`, `indeterminate`, `loading`. A node's own `icon` wins over these. */
|
|
283
|
+
icons?: TreeIcons
|
|
284
|
+
/** Overrides the built-in strings — see `TreeTranslations`. */
|
|
285
|
+
translations?: TreeTranslations
|
|
286
|
+
classNames?: TreeClassNames
|
|
287
|
+
ref?: Ref<HTMLDivElement>
|
|
288
|
+
children?: ReactNode
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** Owns the state (Ark's machine, the loaded children, the checkboxes) and the root element. */
|
|
292
|
+
const Root = <const Data extends TreeSelectData = TreeNodeData[]>({
|
|
293
|
+
data,
|
|
294
|
+
multiple,
|
|
295
|
+
selected,
|
|
296
|
+
defaultSelected,
|
|
297
|
+
onSelectedChange,
|
|
298
|
+
expanded,
|
|
299
|
+
defaultExpanded,
|
|
300
|
+
onExpandedChange,
|
|
301
|
+
withCheckbox = false,
|
|
302
|
+
checked: checkedProp,
|
|
303
|
+
defaultChecked,
|
|
304
|
+
onCheckedChange,
|
|
305
|
+
loadChildren,
|
|
306
|
+
onLoadError,
|
|
307
|
+
onNodeClick,
|
|
308
|
+
expandOnClick = true,
|
|
309
|
+
typeahead = true,
|
|
310
|
+
disabled,
|
|
311
|
+
withLines = true,
|
|
312
|
+
size = "md",
|
|
313
|
+
color,
|
|
314
|
+
icons,
|
|
315
|
+
translations,
|
|
316
|
+
classNames,
|
|
317
|
+
className,
|
|
318
|
+
testId,
|
|
319
|
+
ref,
|
|
320
|
+
children,
|
|
321
|
+
...rest
|
|
322
|
+
}: TreeRootProps<Data>) => {
|
|
323
|
+
type Node = TreeNodeData<TreePayload<Data>>
|
|
324
|
+
type Value = TreeValue<Data>
|
|
325
|
+
|
|
326
|
+
const [loaded, setLoaded] = useState<ReadonlyMap<string, Node[]>>(() => new Map())
|
|
327
|
+
const nodes = useMemo(
|
|
328
|
+
() => resolveNodes(data as ReadonlyArray<Node>, loaded, !!disabled),
|
|
329
|
+
[data, loaded, disabled],
|
|
330
|
+
)
|
|
331
|
+
const collection = useMemo(
|
|
332
|
+
() =>
|
|
333
|
+
createTreeCollection<TreeNodeData>({
|
|
334
|
+
rootNode: { value: ROOT, label: "", children: nodes },
|
|
335
|
+
nodeToValue: (node) => node.value,
|
|
336
|
+
nodeToString: (node) => node.label,
|
|
337
|
+
nodeToChildren: (node) => node.children ?? [],
|
|
338
|
+
// A `hasChildren` branch stays a branch before its children load, and after they
|
|
339
|
+
// load empty.
|
|
340
|
+
nodeToChildrenCount: (node) =>
|
|
341
|
+
node.hasChildren ? (node.children?.length ?? 1) : undefined,
|
|
342
|
+
isNodeDisabled: (node) => !!node.disabled,
|
|
343
|
+
}),
|
|
344
|
+
[nodes],
|
|
345
|
+
)
|
|
346
|
+
|
|
347
|
+
const [checked, setChecked] = useUncontrolled<Value[]>({
|
|
348
|
+
value: checkedProp,
|
|
349
|
+
defaultValue: defaultChecked,
|
|
350
|
+
finalValue: [],
|
|
351
|
+
onChange: onCheckedChange,
|
|
352
|
+
})
|
|
353
|
+
const checkedSet = useMemo(() => new Set<string>(checked), [checked])
|
|
354
|
+
|
|
355
|
+
const api = useTreeView<TreeNodeData>({
|
|
356
|
+
collection,
|
|
357
|
+
selectionMode: multiple ? "multiple" : "single",
|
|
358
|
+
selectedValue: selected,
|
|
359
|
+
defaultSelectedValue: defaultSelected ?? [],
|
|
360
|
+
onSelectionChange: (details) => onSelectedChange?.(details.selectedValue as Value[]),
|
|
361
|
+
expandedValue: expanded,
|
|
362
|
+
defaultExpandedValue: defaultExpanded ?? [],
|
|
363
|
+
onExpandedChange: (details) => onExpandedChange?.(details.expandedValue as Value[]),
|
|
364
|
+
expandOnClick,
|
|
365
|
+
typeahead,
|
|
366
|
+
translations: { treeLabel: translations?.treeLabel ?? TREE_DEFAULT_TRANSLATIONS.treeLabel },
|
|
367
|
+
loadChildren: loadChildren
|
|
368
|
+
? async ({ node, signal }) => {
|
|
369
|
+
const children = await loadChildren(node as Node, { signal })
|
|
370
|
+
setLoaded((prev) => new Map(prev).set(node.value, children as Node[]))
|
|
371
|
+
// A branch checked before it loaded stood for itself; it now stands for its leaves.
|
|
372
|
+
setChecked((prev) =>
|
|
373
|
+
prev.includes(node.value as Value)
|
|
374
|
+
? ([
|
|
375
|
+
...prev.filter((v) => v !== node.value),
|
|
376
|
+
...children.flatMap((child) => getLeafValues(child)),
|
|
377
|
+
] as Value[])
|
|
378
|
+
: prev,
|
|
379
|
+
)
|
|
380
|
+
return children
|
|
381
|
+
}
|
|
382
|
+
: undefined,
|
|
383
|
+
onLoadChildrenError: (details) => {
|
|
384
|
+
for (const { node, error } of details.nodes) onLoadError?.(node as Node, error)
|
|
385
|
+
},
|
|
386
|
+
})
|
|
387
|
+
|
|
388
|
+
const checkDirection = useDirectionCheck()
|
|
389
|
+
const rootRef = useMergedRefs(ref, checkDirection)
|
|
390
|
+
|
|
391
|
+
return (
|
|
392
|
+
<TreeContext.Provider
|
|
393
|
+
value={{
|
|
394
|
+
api,
|
|
395
|
+
size,
|
|
396
|
+
withLines,
|
|
397
|
+
withCheckbox,
|
|
398
|
+
icons: mergeIcons(DEFAULT_ICONS, icons),
|
|
399
|
+
classNames,
|
|
400
|
+
checked: checkedSet,
|
|
401
|
+
toggle: (node) => setChecked((prev) => toggleChecked(node, prev) as Value[]),
|
|
402
|
+
onNodeClick: onNodeClick as TreeContextValue["onNodeClick"],
|
|
403
|
+
}}
|
|
404
|
+
>
|
|
405
|
+
<ark.div
|
|
406
|
+
ref={rootRef}
|
|
407
|
+
{...mergeProps(api.getRootProps(), rest)}
|
|
408
|
+
data-color={color}
|
|
409
|
+
className={cn("flex min-w-0 flex-col gap-1", className)}
|
|
410
|
+
{...props({ "data-testid": testId })}
|
|
411
|
+
>
|
|
412
|
+
{children}
|
|
413
|
+
</ark.div>
|
|
414
|
+
</TreeContext.Provider>
|
|
415
|
+
)
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
export type TreeLabelProps = HTMLArkProps<"div"> & WithTestId
|
|
419
|
+
|
|
420
|
+
/** A visible name for the tree; the list is labelled by it. */
|
|
421
|
+
const Label = ({ className, testId, ...rest }: TreeLabelProps) => {
|
|
422
|
+
const { api } = useTreeContext("Label")
|
|
423
|
+
return (
|
|
424
|
+
<ark.div
|
|
425
|
+
{...mergeProps(api.getLabelProps(), rest)}
|
|
426
|
+
className={cn("text-sm font-medium", TEXT_COLOR_CLASSES.primary, className)}
|
|
427
|
+
{...props({ "data-testid": testId })}
|
|
428
|
+
/>
|
|
429
|
+
)
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
type NodesProps = {
|
|
433
|
+
nodes: ReadonlyArray<TreeNodeData>
|
|
434
|
+
parentPath: number[]
|
|
435
|
+
/** The parent's position; none at the top level. */
|
|
436
|
+
parent?: TreePosition
|
|
437
|
+
render: RenderTreeItem
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
const Nodes = ({ nodes, parentPath, parent, render }: NodesProps) => {
|
|
441
|
+
const positions = treePositions(nodes.length, parent)
|
|
442
|
+
return nodes.map((node, i) => (
|
|
443
|
+
<TreeNode
|
|
444
|
+
key={node.value}
|
|
445
|
+
node={node}
|
|
446
|
+
indexPath={[...parentPath, i]}
|
|
447
|
+
position={positions[i] as TreePosition}
|
|
448
|
+
render={render}
|
|
449
|
+
/>
|
|
450
|
+
))
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/** One node: its row, and for a branch the collapsing group of its children. */
|
|
454
|
+
const TreeNode = ({
|
|
455
|
+
node,
|
|
456
|
+
indexPath,
|
|
457
|
+
position,
|
|
458
|
+
render,
|
|
459
|
+
}: {
|
|
460
|
+
node: TreeNodeData
|
|
461
|
+
indexPath: number[]
|
|
462
|
+
position: TreePosition
|
|
463
|
+
render: RenderTreeItem
|
|
464
|
+
}) => {
|
|
465
|
+
const { api, size, checked, withCheckbox, withLines, onNodeClick, classNames, toggle } =
|
|
466
|
+
useTreeContext("List")
|
|
467
|
+
const nodeProps = { node, indexPath }
|
|
468
|
+
const nodeState = api.getNodeState(nodeProps)
|
|
469
|
+
const check = getCheckState(node, checked)
|
|
470
|
+
const state: TreeItemState = {
|
|
471
|
+
depth: position.depth,
|
|
472
|
+
leaf: !nodeState.isBranch,
|
|
473
|
+
selected: nodeState.selected,
|
|
474
|
+
expanded: nodeState.expanded,
|
|
475
|
+
loading: nodeState.loading,
|
|
476
|
+
checked: check === "checked",
|
|
477
|
+
indeterminate: check === "indeterminate",
|
|
478
|
+
disabled: nodeState.disabled,
|
|
479
|
+
focused: nodeState.focused,
|
|
480
|
+
}
|
|
481
|
+
const testId = node.testId ?? `item-${node.value}`
|
|
482
|
+
|
|
483
|
+
// On the `treeitem`: the row for a leaf, the wrapper around row and group for a branch.
|
|
484
|
+
const treeitem = {
|
|
485
|
+
"aria-setsize": position.setsize,
|
|
486
|
+
"aria-posinset": position.posinset,
|
|
487
|
+
...(withCheckbox && {
|
|
488
|
+
"aria-checked": state.indeterminate ? ("mixed" as const) : state.checked,
|
|
489
|
+
}),
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// Ark's own props first: the kit's handlers run after.
|
|
493
|
+
const control = nodeState.isBranch
|
|
494
|
+
? api.getBranchControlProps(nodeProps)
|
|
495
|
+
: mergeProps(api.getItemProps(nodeProps), treeitem)
|
|
496
|
+
const row = mergeProps(control, {
|
|
497
|
+
className: cn(selectedRow, classNames?.node),
|
|
498
|
+
onClick: (event: MouseEvent<HTMLElement>) => {
|
|
499
|
+
if (!state.disabled) onNodeClick?.(node, event)
|
|
500
|
+
},
|
|
501
|
+
// With checkboxes, Space checks (Enter still selects), like a checkbox list.
|
|
502
|
+
onKeyDown: (event: KeyboardEvent<HTMLElement>) => {
|
|
503
|
+
if (!withCheckbox || event.key !== " " || state.disabled) return
|
|
504
|
+
event.preventDefault()
|
|
505
|
+
toggle(node)
|
|
506
|
+
},
|
|
507
|
+
})
|
|
508
|
+
|
|
509
|
+
const rowElement = (
|
|
510
|
+
<TreeRow {...row} position={position} size={size} withLines={withLines} data-testid={testId}>
|
|
511
|
+
<NodeContext.Provider value={{ node, indexPath, state, testId }}>
|
|
512
|
+
{render(node, state)}
|
|
513
|
+
</NodeContext.Provider>
|
|
514
|
+
</TreeRow>
|
|
515
|
+
)
|
|
516
|
+
|
|
517
|
+
if (!nodeState.isBranch) return rowElement
|
|
518
|
+
|
|
519
|
+
// Ark's `hidden` would cut the close animation short; the closed `Collapse` is `inert`
|
|
520
|
+
// and clipped instead.
|
|
521
|
+
const { hidden: _hidden, ...group } = api.getBranchContentProps(nodeProps)
|
|
522
|
+
return (
|
|
523
|
+
<ark.div {...mergeProps(api.getBranchProps(nodeProps), treeitem)}>
|
|
524
|
+
{rowElement}
|
|
525
|
+
<Collapse
|
|
526
|
+
open={nodeState.expanded}
|
|
527
|
+
{...group}
|
|
528
|
+
className={classNames?.group}
|
|
529
|
+
{...props({ "data-testid": `${testId}-group` })}
|
|
530
|
+
>
|
|
531
|
+
<Nodes
|
|
532
|
+
nodes={node.children ?? []}
|
|
533
|
+
parentPath={indexPath}
|
|
534
|
+
parent={position}
|
|
535
|
+
render={render}
|
|
536
|
+
/>
|
|
537
|
+
</Collapse>
|
|
538
|
+
</ark.div>
|
|
539
|
+
)
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/** The default row: chevron, checkbox (with `withCheckbox`), icon, text. */
|
|
543
|
+
const DefaultContent = () => {
|
|
544
|
+
const { withCheckbox } = useTreeContext("List")
|
|
545
|
+
return (
|
|
546
|
+
<>
|
|
547
|
+
<Indicator />
|
|
548
|
+
{withCheckbox && <Checkbox />}
|
|
549
|
+
<Icon />
|
|
550
|
+
<Text />
|
|
551
|
+
</>
|
|
552
|
+
)
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
const renderDefault: RenderTreeItem = () => <DefaultContent />
|
|
556
|
+
|
|
557
|
+
export type TreeListProps = NoAsChild<Omit<HTMLArkProps<"div">, "children">> &
|
|
558
|
+
WithTestId & {
|
|
559
|
+
/** Fill each row: what follows the rails. Defaults to chevron, checkbox, icon and text. */
|
|
560
|
+
children?: RenderTreeItem
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/** The `role="tree"` element, rendering every node of `data`. */
|
|
564
|
+
const List = ({ children, className, testId, asChild: _asChild, ...rest }: TreeListProps) => {
|
|
565
|
+
const { api, classNames } = useTreeContext("List")
|
|
566
|
+
return (
|
|
567
|
+
<ark.div
|
|
568
|
+
{...mergeProps(api.getTreeProps(), rest)}
|
|
569
|
+
className={cn("flex flex-col outline-none", classNames?.tree, className)}
|
|
570
|
+
{...props({ "data-testid": testId })}
|
|
571
|
+
>
|
|
572
|
+
<Nodes
|
|
573
|
+
nodes={api.collection.getNodeChildren(api.collection.rootNode)}
|
|
574
|
+
parentPath={[]}
|
|
575
|
+
render={children ?? renderDefault}
|
|
576
|
+
/>
|
|
577
|
+
</ark.div>
|
|
578
|
+
)
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
export type TreeIndicatorProps = NoAsChild<HTMLArkProps<"span">> & WithTestId
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* A branch's chevron, or its spinner while loading; an empty column on a leaf, so labels
|
|
585
|
+
* line up. Clicking it toggles the branch without selecting it.
|
|
586
|
+
*/
|
|
587
|
+
const Indicator = ({
|
|
588
|
+
className,
|
|
589
|
+
testId,
|
|
590
|
+
children,
|
|
591
|
+
asChild: _asChild,
|
|
592
|
+
...rest
|
|
593
|
+
}: TreeIndicatorProps) => {
|
|
594
|
+
const { api, icons, size, withLines, classNames } = useTreeContext("Indicator")
|
|
595
|
+
const { node, indexPath, state, testId: rowTestId } = useNodeContext("Indicator")
|
|
596
|
+
const base = cn(
|
|
597
|
+
"flex w-4 shrink-0 items-center justify-center self-stretch",
|
|
598
|
+
TEXT_COLOR_CLASSES.muted,
|
|
599
|
+
iconSize[size],
|
|
600
|
+
classNames?.indicator,
|
|
601
|
+
className,
|
|
602
|
+
)
|
|
603
|
+
// A nested leaf carries its elbow on through the empty column, up to its icon.
|
|
604
|
+
if (state.leaf)
|
|
605
|
+
return (
|
|
606
|
+
<span aria-hidden className={cn(base, "relative")}>
|
|
607
|
+
{withLines && state.depth > 0 && (
|
|
608
|
+
<span className={cn("absolute inset-s-0 top-1/2 h-px w-full", treeLine)} />
|
|
609
|
+
)}
|
|
610
|
+
</span>
|
|
611
|
+
)
|
|
612
|
+
return (
|
|
613
|
+
<ark.span
|
|
614
|
+
{...mergeProps(api.getBranchIndicatorProps({ node, indexPath }), rest)}
|
|
615
|
+
onClick={(event) => {
|
|
616
|
+
rest.onClick?.(event)
|
|
617
|
+
event.stopPropagation()
|
|
618
|
+
if (state.disabled || state.loading) return
|
|
619
|
+
if (state.expanded) api.collapse([node.value])
|
|
620
|
+
else api.expand([node.value])
|
|
621
|
+
}}
|
|
622
|
+
className={cn(
|
|
623
|
+
base,
|
|
624
|
+
"cursor-pointer [&>svg]:transition-transform motion-reduce:[&>svg]:transition-none",
|
|
625
|
+
// Closed: a quarter turn towards the inline end.
|
|
626
|
+
"data-[state=closed]:[&>svg]:-rotate-90 rtl:data-[state=closed]:[&>svg]:rotate-90",
|
|
627
|
+
)}
|
|
628
|
+
{...props({ "data-testid": testId ?? `${rowTestId}-indicator` })}
|
|
629
|
+
>
|
|
630
|
+
{state.loading ? icons.loading : (children ?? icons.chevron)}
|
|
631
|
+
</ark.span>
|
|
632
|
+
)
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
export type TreeCheckboxProps = NoAsChild<HTMLArkProps<"span">> & WithTestId
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* The row's checkbox. Presentational: the state is the row's `aria-checked`. Clicking it
|
|
639
|
+
* toggles the node (a branch cascades) without selecting the row.
|
|
640
|
+
*/
|
|
641
|
+
const Checkbox = ({
|
|
642
|
+
className,
|
|
643
|
+
testId,
|
|
644
|
+
children: _children,
|
|
645
|
+
asChild: _asChild,
|
|
646
|
+
...rest
|
|
647
|
+
}: TreeCheckboxProps) => {
|
|
648
|
+
const { api, icons, size, toggle, classNames } = useTreeContext("Checkbox")
|
|
649
|
+
const { node, state, testId: rowTestId } = useNodeContext("Checkbox")
|
|
650
|
+
return (
|
|
651
|
+
<TreeCheckMark
|
|
652
|
+
checked={state.checked}
|
|
653
|
+
indeterminate={state.indeterminate}
|
|
654
|
+
size={size}
|
|
655
|
+
icons={icons}
|
|
656
|
+
{...props({ "data-disabled": state.disabled })}
|
|
657
|
+
{...rest}
|
|
658
|
+
onClick={(event) => {
|
|
659
|
+
rest.onClick?.(event)
|
|
660
|
+
event.stopPropagation()
|
|
661
|
+
if (state.disabled) return
|
|
662
|
+
toggle(node)
|
|
663
|
+
api.focus(node.value)
|
|
664
|
+
}}
|
|
665
|
+
className={cn("ms-1", classNames?.checkbox, className)}
|
|
666
|
+
{...props({ "data-testid": testId ?? `${rowTestId}-checkbox` })}
|
|
667
|
+
/>
|
|
668
|
+
)
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
export type TreeIconProps = NoAsChild<HTMLArkProps<"span">> & WithTestId
|
|
672
|
+
|
|
673
|
+
/** The node's icon: its own `icon`, else an open or closed folder for a branch, a file for a
|
|
674
|
+
* leaf. Renders nothing when that resolves to `null`. */
|
|
675
|
+
const Icon = ({ className, testId, children, asChild: _asChild, ...rest }: TreeIconProps) => {
|
|
676
|
+
const { icons, size, classNames } = useTreeContext("Icon")
|
|
677
|
+
const { node, state, testId: rowTestId } = useNodeContext("Icon")
|
|
678
|
+
const icon =
|
|
679
|
+
children ??
|
|
680
|
+
(node.icon !== undefined
|
|
681
|
+
? node.icon
|
|
682
|
+
: state.leaf
|
|
683
|
+
? icons.file
|
|
684
|
+
: state.expanded
|
|
685
|
+
? icons.folderOpen
|
|
686
|
+
: icons.folder)
|
|
687
|
+
if (icon == null) return null
|
|
688
|
+
return (
|
|
689
|
+
<ark.span
|
|
690
|
+
aria-hidden
|
|
691
|
+
{...rest}
|
|
692
|
+
className={cn(
|
|
693
|
+
"ms-1.5 flex shrink-0 items-center",
|
|
694
|
+
TEXT_COLOR_CLASSES.secondary,
|
|
695
|
+
iconSize[size],
|
|
696
|
+
classNames?.icon,
|
|
697
|
+
className,
|
|
698
|
+
)}
|
|
699
|
+
{...props({ "data-testid": testId ?? `${rowTestId}-icon` })}
|
|
700
|
+
>
|
|
701
|
+
{icon}
|
|
702
|
+
</ark.span>
|
|
703
|
+
)
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
export type TreeTextProps = HTMLArkProps<"span"> & WithTestId
|
|
707
|
+
|
|
708
|
+
/** The node's label, truncated to the row. `children` replace it. */
|
|
709
|
+
const Text = ({ className, testId, children, asChild, ...rest }: TreeTextProps) => {
|
|
710
|
+
const { classNames } = useTreeContext("Text")
|
|
711
|
+
const { node, testId: rowTestId } = useNodeContext("Text")
|
|
712
|
+
return (
|
|
713
|
+
<ark.span
|
|
714
|
+
asChild={asChild}
|
|
715
|
+
{...rest}
|
|
716
|
+
className={cn(treeText, classNames?.label, className)}
|
|
717
|
+
{...props({ "data-testid": testId ?? `${rowTestId}-text` })}
|
|
718
|
+
>
|
|
719
|
+
{composeChildren(asChild, children, (own) => own ?? node.label)}
|
|
720
|
+
</ark.span>
|
|
721
|
+
)
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
export type TreeActionsProps = HTMLArkProps<"div"> & WithTestId
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Buttons at the row's end, shown while the row is hovered or holds focus. Hidden ones are
|
|
728
|
+
* `visibility: hidden`, so they're out of the tab order: Tab from the focused row reaches its
|
|
729
|
+
* actions, then leaves the tree. Clicks and keys inside never select or move the row.
|
|
730
|
+
*/
|
|
731
|
+
const Actions = ({ className, testId, ...rest }: TreeActionsProps) => {
|
|
732
|
+
const { classNames } = useTreeContext("Actions")
|
|
733
|
+
const { testId: rowTestId } = useNodeContext("Actions")
|
|
734
|
+
return (
|
|
735
|
+
<ark.div
|
|
736
|
+
{...rest}
|
|
737
|
+
onClick={(event) => {
|
|
738
|
+
event.stopPropagation()
|
|
739
|
+
rest.onClick?.(event)
|
|
740
|
+
}}
|
|
741
|
+
onKeyDown={(event) => {
|
|
742
|
+
event.stopPropagation()
|
|
743
|
+
rest.onKeyDown?.(event)
|
|
744
|
+
}}
|
|
745
|
+
className={cn(
|
|
746
|
+
"ms-auto flex shrink-0 items-center gap-0.5 ps-2",
|
|
747
|
+
"invisible group-hover/row:visible group-focus-within/row:visible",
|
|
748
|
+
classNames?.actions,
|
|
749
|
+
className,
|
|
750
|
+
)}
|
|
751
|
+
{...props({ "data-testid": testId ?? `${rowTestId}-actions` })}
|
|
752
|
+
/>
|
|
753
|
+
)
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/** The data form renders its own list inside the root, so it can't become your element. */
|
|
757
|
+
export type TreeProps<Data extends TreeSelectData = TreeNodeData[]> = NoAsChild<
|
|
758
|
+
Omit<TreeRootProps<Data>, "children">
|
|
759
|
+
> & {
|
|
760
|
+
/** Fill each row yourself, from the parts. Replaces the default content and `actions`. */
|
|
761
|
+
renderItem?: RenderTreeItem<TreePayload<Data>>
|
|
762
|
+
/** Buttons at a row's end, shown on hover or focus. */
|
|
763
|
+
actions?: RenderTreeItem<TreePayload<Data>>
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
const TreeComponent = <const Data extends TreeSelectData = TreeNodeData[]>({
|
|
767
|
+
renderItem,
|
|
768
|
+
actions,
|
|
769
|
+
asChild: _asChild,
|
|
770
|
+
...rest
|
|
771
|
+
}: TreeProps<Data>) => (
|
|
772
|
+
<Root {...(rest as TreeRootProps<Data>)}>
|
|
773
|
+
<List>
|
|
774
|
+
{(renderItem as RenderTreeItem | undefined) ??
|
|
775
|
+
(actions
|
|
776
|
+
? (node, state) => (
|
|
777
|
+
<>
|
|
778
|
+
<DefaultContent />
|
|
779
|
+
<Actions>{(actions as RenderTreeItem)(node, state)}</Actions>
|
|
780
|
+
</>
|
|
781
|
+
)
|
|
782
|
+
: undefined)}
|
|
783
|
+
</List>
|
|
784
|
+
</Root>
|
|
785
|
+
)
|
|
786
|
+
|
|
787
|
+
export const Tree = Object.assign(TreeComponent, {
|
|
788
|
+
Root,
|
|
789
|
+
Label,
|
|
790
|
+
List,
|
|
791
|
+
Indicator,
|
|
792
|
+
Checkbox,
|
|
793
|
+
Icon,
|
|
794
|
+
Text,
|
|
795
|
+
Actions,
|
|
796
|
+
})
|