@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,773 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { useLocaleContext } from "@ark-ui/react/locale"
|
|
4
|
+
import { Portal } from "@ark-ui/react/portal"
|
|
5
|
+
import { Tour as ArkTour, useTour } from "@ark-ui/react/tour"
|
|
6
|
+
import { CheckIcon, CircleIcon, XIcon } from "lucide-react"
|
|
7
|
+
import { type KeyboardEvent, type ReactNode, useEffect, useMemo, useRef, useState } from "react"
|
|
8
|
+
import type { NoAsChild } from "../../lib/as-child"
|
|
9
|
+
import { cn } from "../../lib/cn"
|
|
10
|
+
import { createFloatingArrow, type FloatingArrowProps } from "../../lib/floating-arrow"
|
|
11
|
+
import { iconStroke, mergeIcons } from "../../lib/icons"
|
|
12
|
+
import { useNestedLayer } from "../../lib/overlay-layer"
|
|
13
|
+
import { resolveLogicalPlacement } from "../../lib/placement"
|
|
14
|
+
import { props } from "../../lib/props"
|
|
15
|
+
import type { WithTestId } from "../../lib/test-id"
|
|
16
|
+
import { useIsomorphicLayoutEffect } from "../../lib/use-isomorphic-layout-effect"
|
|
17
|
+
import { ActionIcon } from "../action-icon/action-icon"
|
|
18
|
+
import { Button } from "../button/button"
|
|
19
|
+
import { modalSurface } from "../modal/modal"
|
|
20
|
+
import { popoverChrome } from "../popover/popover"
|
|
21
|
+
import { Spinner } from "../spinner/spinner"
|
|
22
|
+
import { Tooltip } from "../tooltip/tooltip"
|
|
23
|
+
import { resolveTarget, spotlightTarget } from "./runtime"
|
|
24
|
+
import type {
|
|
25
|
+
ConditionState,
|
|
26
|
+
TourChecklistItem,
|
|
27
|
+
TourController,
|
|
28
|
+
TourIconSlot,
|
|
29
|
+
TourRenderProps,
|
|
30
|
+
TourSlot,
|
|
31
|
+
TourSnapshot,
|
|
32
|
+
TourStep,
|
|
33
|
+
ToursProps,
|
|
34
|
+
TourTranslations,
|
|
35
|
+
} from "./types"
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Tour's parts and default card, a styled layer over Ark's Tour.
|
|
39
|
+
*
|
|
40
|
+
* The tours engine (`store.ts`) owns the flow; zag only renders. One machine
|
|
41
|
+
* lives per run, fed exactly one step: the one the engine shows. Each time
|
|
42
|
+
* that step changes, the machine gets the new step and is moved to it
|
|
43
|
+
* imperatively (`setSteps` + `setStep`). zag's `stepId` prop only seeds the
|
|
44
|
+
* machine, so there is no prop to control it with. A step waiting for its
|
|
45
|
+
* target (D3) is handed to zag as a centred dialog under a different id, so
|
|
46
|
+
* zag never runs its own target timeout (3 s, then "not-found").
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/* -------------------------------------------------------------------------- */
|
|
50
|
+
/* Defaults */
|
|
51
|
+
/* -------------------------------------------------------------------------- */
|
|
52
|
+
|
|
53
|
+
export const DEFAULT_TRANSLATIONS: Required<TourTranslations> = {
|
|
54
|
+
progressText: ({ current, total }) => `${current} of ${total}`,
|
|
55
|
+
next: "Next",
|
|
56
|
+
back: "Back",
|
|
57
|
+
done: "Done",
|
|
58
|
+
skip: "Skip tour",
|
|
59
|
+
skipStep: "Skip step",
|
|
60
|
+
close: "Close tour",
|
|
61
|
+
loading: "Loading…",
|
|
62
|
+
valid: "Done",
|
|
63
|
+
blocked: "Finish this step to continue",
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const DEFAULT_ICONS: Record<TourIconSlot, ReactNode> = {
|
|
67
|
+
close: <XIcon className={iconStroke} />,
|
|
68
|
+
check: <CheckIcon className={iconStroke} />,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* -------------------------------------------------------------------------- */
|
|
72
|
+
/* Styles */
|
|
73
|
+
/* -------------------------------------------------------------------------- */
|
|
74
|
+
|
|
75
|
+
/** The cut-out, its ring and the card glide from one step to the next with a
|
|
76
|
+
* plain ease, never the expo curve (it front-loads a move into a snap). Only
|
|
77
|
+
* between two anchored steps: the renderer sets `data-glide` then. A run's
|
|
78
|
+
* first step, and a step after a dialog, have no previous place to glide
|
|
79
|
+
* from: the cut-out would sweep in from a stale box, and the card (a dialog
|
|
80
|
+
* step has no transform) from the page's corner. Each layer names its own
|
|
81
|
+
* properties, and the timing is scoped to `data-glide` whole, because a bare
|
|
82
|
+
* duration animates everything (`transition-property` defaults to `all`).
|
|
83
|
+
* Off under reduced motion. */
|
|
84
|
+
const motion = cn(
|
|
85
|
+
"in-data-glide:duration-300 in-data-glide:ease-in-out",
|
|
86
|
+
"motion-reduce:transition-none",
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
/** Black at 50% barely moves a dark page, which is already near black, so the
|
|
90
|
+
* cut-out hardly stood out there. Dark mode dims harder, and its ring is
|
|
91
|
+
* brighter, so the target still reads as the one lit thing on the page. */
|
|
92
|
+
const backdropClass = cn(
|
|
93
|
+
"bg-black/50 dark:bg-black/75 in-data-glide:transition-[clip-path]",
|
|
94
|
+
motion,
|
|
95
|
+
"data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out",
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
/** The hairline ring around the cut-out, on the spotlight part that sits
|
|
99
|
+
* exactly over the target. */
|
|
100
|
+
const spotlightClass = cn(
|
|
101
|
+
"ring-1 ring-brand-900/20 dark:ring-white/35",
|
|
102
|
+
"in-data-glide:transition-[left,top,width,height]",
|
|
103
|
+
motion,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
/** A dialog step is centred on the viewport; the positioner lets clicks
|
|
107
|
+
* through around the card. An anchored card glides with the spotlight: zag
|
|
108
|
+
* moves it through `transform`, on the same positioner across steps. */
|
|
109
|
+
const positionerClass = cn(
|
|
110
|
+
"in-data-glide:transition-transform",
|
|
111
|
+
motion,
|
|
112
|
+
"data-[type=dialog]:pointer-events-none data-[type=dialog]:fixed data-[type=dialog]:inset-0",
|
|
113
|
+
"data-[type=dialog]:flex data-[type=dialog]:items-center data-[type=dialog]:justify-center data-[type=dialog]:p-4",
|
|
114
|
+
"data-[type=floating]:fixed data-[type=floating]:end-4 data-[type=floating]:bottom-4",
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
const cardBase = "pointer-events-auto relative flex flex-col gap-3 text-sm"
|
|
118
|
+
|
|
119
|
+
const contentClass = {
|
|
120
|
+
/** Tooltip and floating steps: the popover surface, made opaque. A
|
|
121
|
+
* popover's translucent fill reads well over a live page; a tour card sits
|
|
122
|
+
* over its own dimmed backdrop and often right over the page it explains,
|
|
123
|
+
* so whatever it covers would show through it as stray outlines. Opaque,
|
|
124
|
+
* it also matches the arrow's solid tip. */
|
|
125
|
+
anchored: cn(
|
|
126
|
+
popoverChrome,
|
|
127
|
+
"bg-brand-50 backdrop-blur-none dark:bg-brand-950",
|
|
128
|
+
cardBase,
|
|
129
|
+
"w-80 max-w-[calc(100vw-2rem)] p-4",
|
|
130
|
+
),
|
|
131
|
+
/** Dialog steps: Modal's surface. */
|
|
132
|
+
dialog: cn(modalSurface, cardBase, "w-full max-w-(--width-sm) rounded-sm p-6"),
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** The arrow's tip matches the popover surface, with its hairline on the two
|
|
136
|
+
* edges that poke out: zag rotates the tip so its top-left corner always
|
|
137
|
+
* points at the target, whatever the side. */
|
|
138
|
+
const arrowSurface = cn(
|
|
139
|
+
"bg-brand-50! dark:bg-brand-950!",
|
|
140
|
+
"border-t border-l border-brand-900/20 dark:border-white/15",
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
/* -------------------------------------------------------------------------- */
|
|
144
|
+
/* Parts */
|
|
145
|
+
/* -------------------------------------------------------------------------- */
|
|
146
|
+
|
|
147
|
+
/** The parts render inside a running tour's machine, so `asChild` isn't
|
|
148
|
+
* offered: there is no element of the caller's to merge onto. */
|
|
149
|
+
type PartProps<P> = NoAsChild<P> & WithTestId
|
|
150
|
+
|
|
151
|
+
/** The dimmed page, with the target cut out (zag's clip-path, D4). */
|
|
152
|
+
const Backdrop = ({
|
|
153
|
+
className,
|
|
154
|
+
testId,
|
|
155
|
+
asChild: _asChild,
|
|
156
|
+
...rest
|
|
157
|
+
}: PartProps<ArkTour.BackdropProps>) => (
|
|
158
|
+
<ArkTour.Backdrop
|
|
159
|
+
className={cn(backdropClass, className)}
|
|
160
|
+
{...props({ "data-testid": testId })}
|
|
161
|
+
{...rest}
|
|
162
|
+
/>
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
/** The box over the target: its hairline ring, and the help pulse. */
|
|
166
|
+
const Spotlight = ({
|
|
167
|
+
className,
|
|
168
|
+
testId,
|
|
169
|
+
asChild: _asChild,
|
|
170
|
+
...rest
|
|
171
|
+
}: PartProps<ArkTour.SpotlightProps>) => (
|
|
172
|
+
<ArkTour.Spotlight
|
|
173
|
+
className={cn(spotlightClass, className)}
|
|
174
|
+
{...props({ "data-testid": testId })}
|
|
175
|
+
{...rest}
|
|
176
|
+
/>
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
const Positioner = ({
|
|
180
|
+
className,
|
|
181
|
+
asChild: _asChild,
|
|
182
|
+
...rest
|
|
183
|
+
}: NoAsChild<ArkTour.PositionerProps>) => (
|
|
184
|
+
<ArkTour.Positioner className={cn(positionerClass, className)} {...rest} />
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
/** The card. Pass `surface="dialog"` for Modal's surface. */
|
|
188
|
+
const Content = ({
|
|
189
|
+
className,
|
|
190
|
+
surface = "anchored",
|
|
191
|
+
testId,
|
|
192
|
+
asChild: _asChild,
|
|
193
|
+
...rest
|
|
194
|
+
}: PartProps<ArkTour.ContentProps> & {
|
|
195
|
+
/** Which surface the card wears. @default "anchored" */
|
|
196
|
+
surface?: keyof typeof contentClass
|
|
197
|
+
}) => (
|
|
198
|
+
<ArkTour.Content
|
|
199
|
+
className={cn(contentClass[surface], className)}
|
|
200
|
+
{...props({ "data-testid": testId })}
|
|
201
|
+
{...rest}
|
|
202
|
+
/>
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
export type TourArrowProps = FloatingArrowProps<ArkTour.ArrowProps>
|
|
206
|
+
|
|
207
|
+
/** The arrow from the card to the target, the kit's shared floating arrow. */
|
|
208
|
+
const Arrow = createFloatingArrow(ArkTour.Arrow, ArkTour.ArrowTip, arrowSurface)
|
|
209
|
+
|
|
210
|
+
const Title = ({
|
|
211
|
+
className,
|
|
212
|
+
testId,
|
|
213
|
+
asChild: _asChild,
|
|
214
|
+
...rest
|
|
215
|
+
}: PartProps<ArkTour.TitleProps>) => (
|
|
216
|
+
<ArkTour.Title
|
|
217
|
+
className={cn("pe-8 font-semibold text-base leading-snug", className)}
|
|
218
|
+
{...props({ "data-testid": testId })}
|
|
219
|
+
{...rest}
|
|
220
|
+
/>
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
const Description = ({
|
|
224
|
+
className,
|
|
225
|
+
testId,
|
|
226
|
+
asChild: _asChild,
|
|
227
|
+
...rest
|
|
228
|
+
}: PartProps<ArkTour.DescriptionProps>) => (
|
|
229
|
+
<ArkTour.Description
|
|
230
|
+
className={cn("text-brand-900/80 dark:text-white/75", className)}
|
|
231
|
+
{...props({ "data-testid": testId })}
|
|
232
|
+
{...rest}
|
|
233
|
+
/>
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
/** The compound parts, for a custom card through `createTours({ render })`. */
|
|
237
|
+
export const Tour = {
|
|
238
|
+
Backdrop,
|
|
239
|
+
Spotlight,
|
|
240
|
+
Positioner,
|
|
241
|
+
Content,
|
|
242
|
+
Arrow,
|
|
243
|
+
Title,
|
|
244
|
+
Description,
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/* -------------------------------------------------------------------------- */
|
|
248
|
+
/* zag step */
|
|
249
|
+
/* -------------------------------------------------------------------------- */
|
|
250
|
+
|
|
251
|
+
type ZagStep = NonNullable<ArkTour.RootProps["tour"]["step"]>
|
|
252
|
+
|
|
253
|
+
const needsTarget = (step: TourStep) =>
|
|
254
|
+
step.target !== undefined &&
|
|
255
|
+
(step.type === undefined || step.type === "tooltip" || step.type === "floating")
|
|
256
|
+
|
|
257
|
+
type ZagDefaults = { withArrow: boolean; withBackdrop: boolean }
|
|
258
|
+
|
|
259
|
+
/** The id zag shows a step under: its own, or a variant's. */
|
|
260
|
+
const zagIdOf = (active: TourSnapshot) => {
|
|
261
|
+
const step = active.step
|
|
262
|
+
if (needsTarget(step) && active.state !== "shown") return `${step.id}~loading`
|
|
263
|
+
if (step.type === "wait" && active.help) return `${step.id}~help`
|
|
264
|
+
return step.id
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Every step zag may be asked to show during a run, variants included, so
|
|
269
|
+
* moving it is only ever a `setStep`. (zag reads its steps from state that
|
|
270
|
+
* updates on the next render, so a `setSteps` + `setStep` pair in one go
|
|
271
|
+
* looks the new id up in the old list and lands on nothing.)
|
|
272
|
+
*
|
|
273
|
+
* - A step waiting for its target (D3) is a centred dialog, `~loading`.
|
|
274
|
+
* - A wait step has no card, but shows its help as a small floating one,
|
|
275
|
+
* `~help`.
|
|
276
|
+
*/
|
|
277
|
+
const toZagSteps = (
|
|
278
|
+
steps: readonly TourStep[],
|
|
279
|
+
dir: "ltr" | "rtl",
|
|
280
|
+
defaults: ZagDefaults,
|
|
281
|
+
): ZagStep[] =>
|
|
282
|
+
steps.flatMap((step): ZagStep[] => {
|
|
283
|
+
const base = { title: null, description: null }
|
|
284
|
+
const backdrop =
|
|
285
|
+
"withBackdrop" in step ? (step.withBackdrop ?? defaults.withBackdrop) : defaults.withBackdrop
|
|
286
|
+
if (step.type === "wait") {
|
|
287
|
+
return [
|
|
288
|
+
{ ...base, id: step.id, type: "wait", backdrop: false },
|
|
289
|
+
{
|
|
290
|
+
...base,
|
|
291
|
+
id: `${step.id}~help`,
|
|
292
|
+
type: "floating",
|
|
293
|
+
placement: "bottom-end",
|
|
294
|
+
backdrop: false,
|
|
295
|
+
},
|
|
296
|
+
]
|
|
297
|
+
}
|
|
298
|
+
if (step.type === "dialog") return [{ ...base, id: step.id, type: "dialog", backdrop }]
|
|
299
|
+
const anchored = step as Extract<TourStep, { type?: "tooltip" }>
|
|
300
|
+
const shown: ZagStep = {
|
|
301
|
+
...base,
|
|
302
|
+
id: step.id,
|
|
303
|
+
type: step.type === "floating" && !step.target ? "floating" : "tooltip",
|
|
304
|
+
target: step.target ? () => spotlightTarget(resolveTarget(step.target)) : undefined,
|
|
305
|
+
placement: resolveLogicalPlacement(anchored.position ?? "bottom", dir),
|
|
306
|
+
backdrop,
|
|
307
|
+
arrow: anchored.withArrow ?? defaults.withArrow,
|
|
308
|
+
}
|
|
309
|
+
if (!needsTarget(step)) return [shown]
|
|
310
|
+
return [shown, { ...base, id: `${step.id}~loading`, type: "dialog", backdrop }]
|
|
311
|
+
})
|
|
312
|
+
|
|
313
|
+
/* -------------------------------------------------------------------------- */
|
|
314
|
+
/* Default card */
|
|
315
|
+
/* -------------------------------------------------------------------------- */
|
|
316
|
+
|
|
317
|
+
const isMet = (gate: ConditionState | null) => gate === null || gate === "valid"
|
|
318
|
+
|
|
319
|
+
const Checklist = ({
|
|
320
|
+
items,
|
|
321
|
+
className,
|
|
322
|
+
}: {
|
|
323
|
+
items: readonly TourChecklistItem[]
|
|
324
|
+
className?: string
|
|
325
|
+
}) => (
|
|
326
|
+
<ul className={cn("flex flex-col gap-1.5", className)}>
|
|
327
|
+
{items.map((item) => {
|
|
328
|
+
const valid = item.state === "valid"
|
|
329
|
+
return (
|
|
330
|
+
<li
|
|
331
|
+
key={item.key}
|
|
332
|
+
data-state={valid ? "valid" : "pending"}
|
|
333
|
+
className="flex items-center gap-2"
|
|
334
|
+
>
|
|
335
|
+
<span
|
|
336
|
+
aria-hidden
|
|
337
|
+
className={cn(
|
|
338
|
+
"flex size-4 shrink-0 items-center justify-center rounded-full [&_svg]:size-3",
|
|
339
|
+
valid ? "bg-green-600 text-white" : "text-brand-900/40 dark:text-white/40",
|
|
340
|
+
)}
|
|
341
|
+
>
|
|
342
|
+
{valid ? <CheckIcon className={iconStroke} /> : <CircleIcon className={iconStroke} />}
|
|
343
|
+
</span>
|
|
344
|
+
<span className={cn(valid && "text-brand-900/60 line-through dark:text-white/60")}>
|
|
345
|
+
{item.label}
|
|
346
|
+
</span>
|
|
347
|
+
</li>
|
|
348
|
+
)
|
|
349
|
+
})}
|
|
350
|
+
</ul>
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
type CardProps = {
|
|
354
|
+
active: TourSnapshot
|
|
355
|
+
tours: TourController
|
|
356
|
+
translations: Required<TourTranslations>
|
|
357
|
+
icons: Record<TourIconSlot, ReactNode>
|
|
358
|
+
classNames: Partial<Record<TourSlot, string>>
|
|
359
|
+
withCloseButton: boolean
|
|
360
|
+
testId?: string
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const part = (testId: string | undefined, name: string) =>
|
|
364
|
+
testId ? `${testId}-${name}` : undefined
|
|
365
|
+
|
|
366
|
+
/** The default card's body: everything inside `Tour.Content`. */
|
|
367
|
+
const CardBody = ({
|
|
368
|
+
active,
|
|
369
|
+
tours,
|
|
370
|
+
translations: t,
|
|
371
|
+
icons,
|
|
372
|
+
classNames,
|
|
373
|
+
withCloseButton,
|
|
374
|
+
testId,
|
|
375
|
+
}: CardProps) => {
|
|
376
|
+
const step = active.step
|
|
377
|
+
const loading = needsTarget(step) && active.state !== "shown"
|
|
378
|
+
const card = "title" in step ? step : null
|
|
379
|
+
const choices = card?.choices
|
|
380
|
+
const last = active.index === active.total - 1
|
|
381
|
+
const met = isMet(active.gate)
|
|
382
|
+
const invalid =
|
|
383
|
+
typeof active.gate === "object" && active.gate !== null ? active.gate.invalid : undefined
|
|
384
|
+
const hint = invalid ?? active.help?.hint
|
|
385
|
+
const required = card?.required ?? false
|
|
386
|
+
|
|
387
|
+
const close = withCloseButton && (
|
|
388
|
+
<ActionIcon
|
|
389
|
+
variant="subtle"
|
|
390
|
+
color="neutral"
|
|
391
|
+
size="sm"
|
|
392
|
+
aria-label={t.close}
|
|
393
|
+
className={cn("absolute end-2 top-2", classNames.close)}
|
|
394
|
+
onClick={() => tours.dismiss()}
|
|
395
|
+
testId={part(testId, "close")}
|
|
396
|
+
>
|
|
397
|
+
{icons.close}
|
|
398
|
+
</ActionIcon>
|
|
399
|
+
)
|
|
400
|
+
|
|
401
|
+
if (loading) {
|
|
402
|
+
const stuck = active.state === "timeout"
|
|
403
|
+
return (
|
|
404
|
+
<>
|
|
405
|
+
{close}
|
|
406
|
+
<div role="status" className="flex items-center gap-3 pe-8" data-state={active.state}>
|
|
407
|
+
<Spinner size="sm" />
|
|
408
|
+
<span>{t.loading}</span>
|
|
409
|
+
</div>
|
|
410
|
+
{stuck && (
|
|
411
|
+
<div className={cn("flex justify-end gap-2", classNames.actions)}>
|
|
412
|
+
<Button variant="subtle" color="neutral" size="sm" onClick={() => tours.dismiss()}>
|
|
413
|
+
{t.close}
|
|
414
|
+
</Button>
|
|
415
|
+
<Button
|
|
416
|
+
variant="light"
|
|
417
|
+
size="sm"
|
|
418
|
+
onClick={() => tours.next()}
|
|
419
|
+
testId={part(testId, "skip-step")}
|
|
420
|
+
>
|
|
421
|
+
{t.skipStep}
|
|
422
|
+
</Button>
|
|
423
|
+
</div>
|
|
424
|
+
)}
|
|
425
|
+
</>
|
|
426
|
+
)
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
const next = (
|
|
430
|
+
<Button
|
|
431
|
+
size="sm"
|
|
432
|
+
// Focusable while blocked, so its tooltip can say why (aria-disabled,
|
|
433
|
+
// not disabled: a disabled button takes no hover or focus).
|
|
434
|
+
aria-disabled={met ? undefined : true}
|
|
435
|
+
data-disabled={met ? undefined : ""}
|
|
436
|
+
onClick={() => {
|
|
437
|
+
if (met) tours.next()
|
|
438
|
+
}}
|
|
439
|
+
testId={part(testId, "next")}
|
|
440
|
+
>
|
|
441
|
+
{last ? t.done : t.next}
|
|
442
|
+
</Button>
|
|
443
|
+
)
|
|
444
|
+
|
|
445
|
+
return (
|
|
446
|
+
<>
|
|
447
|
+
{close}
|
|
448
|
+
{card?.title !== undefined && (
|
|
449
|
+
<Title className={classNames.title} testId={part(testId, "title")}>
|
|
450
|
+
{card.title}
|
|
451
|
+
</Title>
|
|
452
|
+
)}
|
|
453
|
+
{card?.description !== undefined && (
|
|
454
|
+
<Description className={classNames.description} testId={part(testId, "description")}>
|
|
455
|
+
{card.description}
|
|
456
|
+
</Description>
|
|
457
|
+
)}
|
|
458
|
+
{active.checklist && <Checklist items={active.checklist} className={classNames.checklist} />}
|
|
459
|
+
{choices && (
|
|
460
|
+
<div className="flex flex-wrap gap-2">
|
|
461
|
+
{choices.map((choice) => (
|
|
462
|
+
<Button
|
|
463
|
+
key={choice.value}
|
|
464
|
+
variant="light"
|
|
465
|
+
size="sm"
|
|
466
|
+
onClick={() => tours.choose(choice.value)}
|
|
467
|
+
>
|
|
468
|
+
{choice.label}
|
|
469
|
+
</Button>
|
|
470
|
+
))}
|
|
471
|
+
</div>
|
|
472
|
+
)}
|
|
473
|
+
{/* Polite, and only once the hint is due: value() holds it back while
|
|
474
|
+
the user types, so it isn't read out on every keystroke. */}
|
|
475
|
+
<p
|
|
476
|
+
role="status"
|
|
477
|
+
className={cn(
|
|
478
|
+
// Takes no room when there's nothing to show; the tick's word is
|
|
479
|
+
// for screen readers only.
|
|
480
|
+
"empty:hidden",
|
|
481
|
+
active.gate === "valid" && "sr-only",
|
|
482
|
+
invalid ? "text-red-700 dark:text-red-400" : "text-brand-900/80 dark:text-white/75",
|
|
483
|
+
classNames.hint,
|
|
484
|
+
)}
|
|
485
|
+
{...props({ "data-testid": part(testId, "hint") })}
|
|
486
|
+
>
|
|
487
|
+
{active.gate === "valid" ? t.valid : hint}
|
|
488
|
+
</p>
|
|
489
|
+
<div className={cn("flex items-center gap-2", classNames.actions)}>
|
|
490
|
+
<span
|
|
491
|
+
// Its own direction, from its text: "2 of 4" stays in order on a
|
|
492
|
+
// right-to-left page, and a translated string follows its script.
|
|
493
|
+
dir="auto"
|
|
494
|
+
className={cn(
|
|
495
|
+
"me-auto text-brand-900/60 text-xs tabular-nums dark:text-white/60",
|
|
496
|
+
classNames.progress,
|
|
497
|
+
)}
|
|
498
|
+
{...props({ "data-testid": part(testId, "progress") })}
|
|
499
|
+
>
|
|
500
|
+
{active.total > 1 && t.progressText({ current: active.index + 1, total: active.total })}
|
|
501
|
+
</span>
|
|
502
|
+
{active.gate === "valid" && (
|
|
503
|
+
<span
|
|
504
|
+
aria-hidden
|
|
505
|
+
data-part="tick"
|
|
506
|
+
className="flex size-6 items-center justify-center rounded-full bg-green-600 text-white motion-safe:animate-fade-in [&_svg]:size-3.5"
|
|
507
|
+
>
|
|
508
|
+
{icons.check}
|
|
509
|
+
</span>
|
|
510
|
+
)}
|
|
511
|
+
{!required && !last && (
|
|
512
|
+
<Button
|
|
513
|
+
variant="subtle"
|
|
514
|
+
color="neutral"
|
|
515
|
+
size="sm"
|
|
516
|
+
onClick={() => tours.skip()}
|
|
517
|
+
testId={part(testId, "skip")}
|
|
518
|
+
>
|
|
519
|
+
{t.skip}
|
|
520
|
+
</Button>
|
|
521
|
+
)}
|
|
522
|
+
{active.index > 0 && (
|
|
523
|
+
<Button
|
|
524
|
+
variant="light"
|
|
525
|
+
size="sm"
|
|
526
|
+
onClick={() => tours.back()}
|
|
527
|
+
testId={part(testId, "back")}
|
|
528
|
+
>
|
|
529
|
+
{t.back}
|
|
530
|
+
</Button>
|
|
531
|
+
)}
|
|
532
|
+
{!choices &&
|
|
533
|
+
(met ? (
|
|
534
|
+
next
|
|
535
|
+
) : (
|
|
536
|
+
// The trigger is a wrapper: Button's disabled look also turns off
|
|
537
|
+
// its pointer events, so the button itself would never be hovered.
|
|
538
|
+
// Focus on the (aria-disabled, still focusable) button bubbles up.
|
|
539
|
+
<Tooltip label={invalid ?? t.blocked} asChild>
|
|
540
|
+
<span className="inline-flex">{next}</span>
|
|
541
|
+
</Tooltip>
|
|
542
|
+
))}
|
|
543
|
+
</div>
|
|
544
|
+
</>
|
|
545
|
+
)
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/* -------------------------------------------------------------------------- */
|
|
549
|
+
/* Renderer */
|
|
550
|
+
/* -------------------------------------------------------------------------- */
|
|
551
|
+
|
|
552
|
+
export type TourRendererProps = ToursProps & {
|
|
553
|
+
/** The running tour, or `null`. */
|
|
554
|
+
active: TourSnapshot | null
|
|
555
|
+
/** The controller the buttons drive. */
|
|
556
|
+
tours: TourController
|
|
557
|
+
/** The registered tours, for the running one's steps. */
|
|
558
|
+
registry: Record<string, { steps: readonly TourStep[] }>
|
|
559
|
+
/** The card's strings, merged over the defaults. */
|
|
560
|
+
translations?: TourTranslations
|
|
561
|
+
/** Replaces the default card. */
|
|
562
|
+
render?: (props: TourRenderProps) => ReactNode
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/** Whether a floating panel lifted above the tour is open: Escape is its. */
|
|
566
|
+
const raisedPanelOpen = () =>
|
|
567
|
+
document.querySelector('[data-part="content"][data-raised][data-state="open"]') !== null
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* The document's scroll height. zag draws the cut-out in document
|
|
571
|
+
* coordinates, sized to `documentElement.scrollHeight`, on a backdrop that is
|
|
572
|
+
* `position: absolute; inset: 0`, which only covers the first viewport: the
|
|
573
|
+
* initial containing block is viewport-sized, and nothing CSS can reach
|
|
574
|
+
* sizes an absolute box to the whole document. So the backdrop takes zag's
|
|
575
|
+
* own measure.
|
|
576
|
+
*/
|
|
577
|
+
const useDocumentHeight = (active: boolean) => {
|
|
578
|
+
const [height, setHeight] = useState<number>()
|
|
579
|
+
useIsomorphicLayoutEffect(() => {
|
|
580
|
+
if (!active || typeof ResizeObserver === "undefined") return
|
|
581
|
+
const root = document.documentElement
|
|
582
|
+
const measure = () => setHeight(root.scrollHeight)
|
|
583
|
+
measure()
|
|
584
|
+
const observer = new ResizeObserver(measure)
|
|
585
|
+
observer.observe(document.body)
|
|
586
|
+
return () => observer.disconnect()
|
|
587
|
+
}, [active])
|
|
588
|
+
return height
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/** One run: one zag machine, fed the step the engine shows. */
|
|
592
|
+
const TourRun = ({
|
|
593
|
+
active,
|
|
594
|
+
tours,
|
|
595
|
+
translations,
|
|
596
|
+
render,
|
|
597
|
+
color,
|
|
598
|
+
classNames = {},
|
|
599
|
+
icons,
|
|
600
|
+
withArrow = true,
|
|
601
|
+
withBackdrop = true,
|
|
602
|
+
withCloseButton = true,
|
|
603
|
+
testId,
|
|
604
|
+
tour,
|
|
605
|
+
}: TourRendererProps & {
|
|
606
|
+
active: TourSnapshot
|
|
607
|
+
translations: Required<TourTranslations>
|
|
608
|
+
/** The running tour's definition: every step zag may show. */
|
|
609
|
+
tour: { steps: readonly TourStep[] }
|
|
610
|
+
}) => {
|
|
611
|
+
const { dir } = useLocaleContext()
|
|
612
|
+
const steps = useMemo(
|
|
613
|
+
() => toZagSteps(tour.steps, dir, { withArrow, withBackdrop }),
|
|
614
|
+
[tour, dir, withArrow, withBackdrop],
|
|
615
|
+
)
|
|
616
|
+
const zagId = zagIdOf(active)
|
|
617
|
+
const api = useTour({
|
|
618
|
+
steps,
|
|
619
|
+
keyboardNavigation: false,
|
|
620
|
+
// zag pads the cut-out 10px all round, which reads as a loose frame around
|
|
621
|
+
// a field or a button; 4px clears the element's own focus ring and border.
|
|
622
|
+
spotlightOffset: { x: 4, y: 4 },
|
|
623
|
+
closeOnEscape: false,
|
|
624
|
+
closeOnInteractOutside: false,
|
|
625
|
+
translations: {
|
|
626
|
+
close: translations.close,
|
|
627
|
+
nextStep: translations.next,
|
|
628
|
+
prevStep: translations.back,
|
|
629
|
+
},
|
|
630
|
+
})
|
|
631
|
+
|
|
632
|
+
// A new direction or arrow/backdrop default: hand zag the rebuilt list.
|
|
633
|
+
const first = useRef(true)
|
|
634
|
+
useIsomorphicLayoutEffect(() => {
|
|
635
|
+
if (first.current) {
|
|
636
|
+
first.current = false
|
|
637
|
+
return
|
|
638
|
+
}
|
|
639
|
+
api.setSteps(steps)
|
|
640
|
+
}, [steps])
|
|
641
|
+
|
|
642
|
+
// Move zag to the engine's step. The first one starts the machine.
|
|
643
|
+
const started = useRef(false)
|
|
644
|
+
useIsomorphicLayoutEffect(() => {
|
|
645
|
+
if (!started.current) {
|
|
646
|
+
started.current = true
|
|
647
|
+
api.start(zagId)
|
|
648
|
+
return
|
|
649
|
+
}
|
|
650
|
+
api.setStep(zagId)
|
|
651
|
+
}, [zagId])
|
|
652
|
+
|
|
653
|
+
// Escape ends the tour, unless a panel raised above it is open: that one
|
|
654
|
+
// closes first. zag's own Escape listener can't tell, so it's off.
|
|
655
|
+
useEffect(() => {
|
|
656
|
+
const onKeyDown = (event: globalThis.KeyboardEvent) => {
|
|
657
|
+
if (event.key !== "Escape" || event.defaultPrevented || raisedPanelOpen()) return
|
|
658
|
+
tours.dismiss()
|
|
659
|
+
}
|
|
660
|
+
document.addEventListener("keydown", onKeyDown)
|
|
661
|
+
return () => document.removeEventListener("keydown", onKeyDown)
|
|
662
|
+
}, [tours])
|
|
663
|
+
|
|
664
|
+
// Arrow keys move between steps from inside the card, mirrored under RTL,
|
|
665
|
+
// and never past an unmet gate.
|
|
666
|
+
const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
|
|
667
|
+
if (event.key !== "ArrowRight" && event.key !== "ArrowLeft") return
|
|
668
|
+
if (event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement)
|
|
669
|
+
return
|
|
670
|
+
const forward = (event.key === "ArrowRight") === (dir === "ltr")
|
|
671
|
+
if (forward && isMet(active.gate) && !("choices" in active.step && active.step.choices))
|
|
672
|
+
tours.next()
|
|
673
|
+
if (!forward && active.index > 0) tours.back()
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
const step = active.step
|
|
677
|
+
const loading = needsTarget(step) && active.state !== "shown"
|
|
678
|
+
const surface = loading || step.type === "dialog" ? "dialog" : "anchored"
|
|
679
|
+
// Whether the card glides from the previous step: both must be anchored.
|
|
680
|
+
// Updated once per step change, so a re-render within a step keeps it.
|
|
681
|
+
const last = useRef<{ id: string; surface: string; from: string | null }>({
|
|
682
|
+
id: zagId,
|
|
683
|
+
surface,
|
|
684
|
+
from: null,
|
|
685
|
+
})
|
|
686
|
+
if (last.current.id !== zagId) last.current = { id: zagId, surface, from: last.current.surface }
|
|
687
|
+
const glide = surface === "anchored" && last.current.from === "anchored"
|
|
688
|
+
const blocking = "interactive" in step && step.interactive === false && active.gate === null
|
|
689
|
+
const resolvedIcons = mergeIcons(DEFAULT_ICONS, icons)
|
|
690
|
+
const height = useDocumentHeight(api.open)
|
|
691
|
+
|
|
692
|
+
return (
|
|
693
|
+
<ArkTour.Root tour={api}>
|
|
694
|
+
<Portal>
|
|
695
|
+
{render ? (
|
|
696
|
+
render({ active, step, tours, translations, loading })
|
|
697
|
+
) : (
|
|
698
|
+
<div data-glide={glide ? "" : undefined} data-color={color} className="contents">
|
|
699
|
+
<Backdrop
|
|
700
|
+
className={classNames.backdrop}
|
|
701
|
+
style={surface === "anchored" && height ? { height } : undefined}
|
|
702
|
+
testId={part(testId, "backdrop")}
|
|
703
|
+
/>
|
|
704
|
+
<Spotlight
|
|
705
|
+
data-pulse={active.help?.pulse ? "" : undefined}
|
|
706
|
+
className={cn(
|
|
707
|
+
// D2's opt-out: the box over the target takes the clicks.
|
|
708
|
+
blocking && "pointer-events-auto!",
|
|
709
|
+
classNames.spotlight,
|
|
710
|
+
)}
|
|
711
|
+
testId={part(testId, "spotlight")}
|
|
712
|
+
>
|
|
713
|
+
{active.help?.pulse && (
|
|
714
|
+
<span
|
|
715
|
+
aria-hidden
|
|
716
|
+
className="absolute inset-0 animate-ping rounded-[inherit] ring-2 ring-white motion-reduce:animate-none"
|
|
717
|
+
/>
|
|
718
|
+
)}
|
|
719
|
+
</Spotlight>
|
|
720
|
+
<Positioner className={classNames.positioner}>
|
|
721
|
+
<Content
|
|
722
|
+
surface={surface}
|
|
723
|
+
className={classNames.content}
|
|
724
|
+
data-step={step.id}
|
|
725
|
+
data-gate={
|
|
726
|
+
typeof active.gate === "object" && active.gate
|
|
727
|
+
? "invalid"
|
|
728
|
+
: (active.gate ?? undefined)
|
|
729
|
+
}
|
|
730
|
+
onKeyDown={onKeyDown}
|
|
731
|
+
testId={testId}
|
|
732
|
+
>
|
|
733
|
+
{surface === "anchored" && withArrow && <Arrow className={classNames.arrow} />}
|
|
734
|
+
<CardBody
|
|
735
|
+
active={active}
|
|
736
|
+
tours={tours}
|
|
737
|
+
translations={translations}
|
|
738
|
+
icons={resolvedIcons}
|
|
739
|
+
classNames={classNames}
|
|
740
|
+
withCloseButton={withCloseButton}
|
|
741
|
+
testId={testId}
|
|
742
|
+
/>
|
|
743
|
+
</Content>
|
|
744
|
+
</Positioner>
|
|
745
|
+
</div>
|
|
746
|
+
)}
|
|
747
|
+
</Portal>
|
|
748
|
+
</ArkTour.Root>
|
|
749
|
+
)
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Renders the running tour: one zag machine per run, keyed by the run, so a
|
|
754
|
+
* new tour starts from a clean machine. Registers the run as a tour layer,
|
|
755
|
+
* so page hotkeys yield to it and floating panels opened during it rise above
|
|
756
|
+
* it (`lib/overlay-layer.tsx`).
|
|
757
|
+
*/
|
|
758
|
+
export const TourRenderer = ({ active, translations, registry, ...rest }: TourRendererProps) => {
|
|
759
|
+
useNestedLayer(active !== null, { tour: true })
|
|
760
|
+
const merged = useMemo(() => ({ ...DEFAULT_TRANSLATIONS, ...translations }), [translations])
|
|
761
|
+
const tour = active ? registry[active.key] : undefined
|
|
762
|
+
if (!active || !tour) return null
|
|
763
|
+
return (
|
|
764
|
+
<TourRun
|
|
765
|
+
key={active.run}
|
|
766
|
+
active={active}
|
|
767
|
+
translations={merged}
|
|
768
|
+
tour={tour}
|
|
769
|
+
registry={registry}
|
|
770
|
+
{...rest}
|
|
771
|
+
/>
|
|
772
|
+
)
|
|
773
|
+
}
|