@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,784 @@
|
|
|
1
|
+
import { act, fireEvent, render } from "@testing-library/react"
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
|
|
3
|
+
import { useNestedLayer } from "../../lib/overlay-layer"
|
|
4
|
+
import { useHotkey } from "../../lib/use-hotkey"
|
|
5
|
+
import { click, gate, signal, value } from "./conditions"
|
|
6
|
+
import { createTours, defineTour } from "./create-tours"
|
|
7
|
+
import { TICK, WAIT_TIMEOUT } from "./store"
|
|
8
|
+
import type { TourEvent, TourRecord, TourStorage } from "./types"
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The engine behind `createTours`, driven through the public controller with
|
|
12
|
+
* real conditions and a real DOM. No zag and no card: the store owns the
|
|
13
|
+
* flow, `<Tours />` only renders it.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
vi.useFakeTimers()
|
|
18
|
+
// zag's tour reads the bare `visualViewport` global, which jsdom lacks.
|
|
19
|
+
vi.stubGlobal("visualViewport", undefined)
|
|
20
|
+
})
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
vi.useRealTimers()
|
|
23
|
+
vi.unstubAllGlobals()
|
|
24
|
+
document.body.innerHTML = ""
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const html = (markup: string) => {
|
|
28
|
+
document.body.innerHTML = markup
|
|
29
|
+
}
|
|
30
|
+
const $ = (selector: string) => document.querySelector(selector) as HTMLElement
|
|
31
|
+
|
|
32
|
+
/** A tour of three dialog steps: nothing to wait for. */
|
|
33
|
+
const plain = defineTour({
|
|
34
|
+
steps: [
|
|
35
|
+
{ id: "one", type: "dialog", title: "One" },
|
|
36
|
+
{ id: "two", type: "dialog", title: "Two" },
|
|
37
|
+
{ id: "three", type: "dialog", title: "Three" },
|
|
38
|
+
],
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
/** Records every event and gives back their `type`s, or `type@stepId`s. */
|
|
42
|
+
const recorder = () => {
|
|
43
|
+
const events: TourEvent[] = []
|
|
44
|
+
return {
|
|
45
|
+
onEvent: (event: TourEvent) => {
|
|
46
|
+
events.push(event)
|
|
47
|
+
},
|
|
48
|
+
events,
|
|
49
|
+
types: () => events.map((event) => `${event.type}@${event.stepId}`),
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** A storage that keeps records in a map, synchronously. */
|
|
54
|
+
const memoryStorage = (initial: Record<string, TourRecord> = {}) => {
|
|
55
|
+
const records = new Map(Object.entries(initial))
|
|
56
|
+
const storage: TourStorage = {
|
|
57
|
+
get: (key) => records.get(key) ?? null,
|
|
58
|
+
set: (key, record) => {
|
|
59
|
+
records.set(key, record)
|
|
60
|
+
},
|
|
61
|
+
remove: (key) => {
|
|
62
|
+
records.delete(key)
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
return { storage, records }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
describe("start and the result", () => {
|
|
69
|
+
it("walks the steps and resolves completed on the last next()", async () => {
|
|
70
|
+
const { tours } = createTours({ registry: { plain } })
|
|
71
|
+
const result = tours.start("plain")
|
|
72
|
+
expect(tours.active?.stepId).toBe("one")
|
|
73
|
+
expect(tours.active).toMatchObject({ index: 0, total: 3, state: "shown", gate: null })
|
|
74
|
+
tours.next()
|
|
75
|
+
expect(tours.active?.stepId).toBe("two")
|
|
76
|
+
tours.next()
|
|
77
|
+
tours.next()
|
|
78
|
+
expect(tours.active).toBeNull()
|
|
79
|
+
await expect(result).resolves.toEqual({ status: "completed", stepId: "three", answers: {} })
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
it.each([
|
|
83
|
+
["skip", "skipped"],
|
|
84
|
+
["dismiss", "dismissed"],
|
|
85
|
+
] as const)("%s() ends the tour as %s, on the step it was on", async (method, status) => {
|
|
86
|
+
const { tours } = createTours({ registry: { plain } })
|
|
87
|
+
const result = tours.start("plain")
|
|
88
|
+
tours.next()
|
|
89
|
+
tours[method]()
|
|
90
|
+
await expect(result).resolves.toEqual({ status, stepId: "two", answers: {} })
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it("resolves not-found when the tour's when is false", async () => {
|
|
94
|
+
const gated = defineTour({ when: () => false, steps: [{ id: "a", type: "dialog" }] })
|
|
95
|
+
const { tours } = createTours({ registry: { gated } })
|
|
96
|
+
await expect(tours.start("gated")).resolves.toEqual({
|
|
97
|
+
status: "not-found",
|
|
98
|
+
stepId: null,
|
|
99
|
+
answers: {},
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it("resolves not-found when every step is filtered out", async () => {
|
|
104
|
+
const empty = defineTour({ steps: [{ id: "a", type: "dialog", when: () => false }] })
|
|
105
|
+
const { tours } = createTours({ registry: { empty } })
|
|
106
|
+
await expect(tours.start("empty")).resolves.toMatchObject({ status: "not-found" })
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it("starts at `from`", () => {
|
|
110
|
+
const { tours } = createTours({ registry: { plain } })
|
|
111
|
+
tours.start("plain", { from: "two" })
|
|
112
|
+
expect(tours.active?.stepId).toBe("two")
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it("hands params to when", () => {
|
|
116
|
+
const withParams = defineTour<{ campus?: string }>()({
|
|
117
|
+
steps: [
|
|
118
|
+
{ id: "campus", type: "dialog", when: (ctx) => ctx.params.campus === undefined },
|
|
119
|
+
{ id: "end", type: "dialog" },
|
|
120
|
+
],
|
|
121
|
+
})
|
|
122
|
+
const { tours } = createTours({ registry: { withParams } })
|
|
123
|
+
tours.start("withParams", { params: { campus: "paris" } })
|
|
124
|
+
expect(tours.active?.stepId).toBe("end")
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
it("defaults version to 1", () => {
|
|
128
|
+
expect(plain.version).toBe(1)
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
describe("the queue (D7)", () => {
|
|
133
|
+
it("runs a second start after the first tour ends", async () => {
|
|
134
|
+
const other = defineTour({ steps: [{ id: "x", type: "dialog" }] })
|
|
135
|
+
const { tours } = createTours({ registry: { plain, other } })
|
|
136
|
+
const first = tours.start("plain")
|
|
137
|
+
const second = tours.start("other")
|
|
138
|
+
expect(tours.active?.key).toBe("plain")
|
|
139
|
+
tours.dismiss()
|
|
140
|
+
await first
|
|
141
|
+
expect(tours.active?.key).toBe("other")
|
|
142
|
+
tours.next()
|
|
143
|
+
await expect(second).resolves.toMatchObject({ status: "completed", stepId: "x" })
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
it("never starts over an open modal, and starts once it closes", () => {
|
|
147
|
+
/** Stands in for a Modal: registers as a modal layer while open. */
|
|
148
|
+
const ModalLayer = ({ open }: { open: boolean }) => {
|
|
149
|
+
useNestedLayer(open, { modal: true })
|
|
150
|
+
return null
|
|
151
|
+
}
|
|
152
|
+
const modal = render(<ModalLayer open />)
|
|
153
|
+
const { tours } = createTours({ registry: { plain } })
|
|
154
|
+
tours.start("plain")
|
|
155
|
+
expect(tours.active).toBeNull()
|
|
156
|
+
modal.rerender(<ModalLayer open={false} />)
|
|
157
|
+
expect(tours.active?.stepId).toBe("one")
|
|
158
|
+
modal.unmount()
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
describe("navigation", () => {
|
|
163
|
+
it("goes back through the steps actually shown", () => {
|
|
164
|
+
const { tours } = createTours({ registry: { plain } })
|
|
165
|
+
tours.start("plain")
|
|
166
|
+
tours.goto("three")
|
|
167
|
+
tours.back()
|
|
168
|
+
expect(tours.active?.stepId).toBe("one")
|
|
169
|
+
tours.back()
|
|
170
|
+
expect(tours.active?.stepId).toBe("one")
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
it("checks when again before each step", () => {
|
|
174
|
+
let showTwo = true
|
|
175
|
+
const flaky = defineTour({
|
|
176
|
+
steps: [
|
|
177
|
+
{ id: "one", type: "dialog" },
|
|
178
|
+
{ id: "two", type: "dialog", when: () => showTwo },
|
|
179
|
+
{ id: "three", type: "dialog" },
|
|
180
|
+
],
|
|
181
|
+
})
|
|
182
|
+
const { tours } = createTours({ registry: { flaky } })
|
|
183
|
+
tours.start("flaky")
|
|
184
|
+
expect(tours.active?.total).toBe(3)
|
|
185
|
+
showTwo = false
|
|
186
|
+
tours.next()
|
|
187
|
+
expect(tours.active).toMatchObject({ stepId: "three", index: 1, total: 2 })
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
it("warns and stays put on goto to an unknown step", () => {
|
|
191
|
+
const warn = vi.spyOn(console, "warn").mockImplementation(() => {})
|
|
192
|
+
const { tours } = createTours({ registry: { plain } })
|
|
193
|
+
tours.start("plain")
|
|
194
|
+
;(tours.goto as (id: string) => void)("nope")
|
|
195
|
+
expect(tours.active?.stepId).toBe("one")
|
|
196
|
+
expect(warn).toHaveBeenCalledWith(expect.stringContaining('no step "nope"'))
|
|
197
|
+
warn.mockRestore()
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
it("patches the step that shows with update, until the step changes", () => {
|
|
201
|
+
const { tours } = createTours({ registry: { plain } })
|
|
202
|
+
tours.start("plain")
|
|
203
|
+
tours.update({ title: "Patched" })
|
|
204
|
+
expect(tours.active?.step).toMatchObject({ title: "Patched" })
|
|
205
|
+
tours.next()
|
|
206
|
+
expect(tours.active?.step).toMatchObject({ title: "Two" })
|
|
207
|
+
})
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
describe("choices", () => {
|
|
211
|
+
const role = defineTour({
|
|
212
|
+
steps: [
|
|
213
|
+
{
|
|
214
|
+
id: "role",
|
|
215
|
+
type: "dialog",
|
|
216
|
+
choices: [
|
|
217
|
+
{ label: "Student", value: "student" },
|
|
218
|
+
{ label: "Staff", value: "staff", goto: "staff" },
|
|
219
|
+
],
|
|
220
|
+
},
|
|
221
|
+
{ id: "student", type: "dialog" },
|
|
222
|
+
{ id: "staff", type: "dialog" },
|
|
223
|
+
],
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
it("records the answer and follows the choice's goto", async () => {
|
|
227
|
+
const { tours } = createTours({ registry: { role } })
|
|
228
|
+
const result = tours.start("role")
|
|
229
|
+
tours.choose("staff")
|
|
230
|
+
expect(tours.active).toMatchObject({ stepId: "staff", answers: { role: "staff" } })
|
|
231
|
+
tours.next()
|
|
232
|
+
await expect(result).resolves.toEqual({
|
|
233
|
+
status: "completed",
|
|
234
|
+
stepId: "staff",
|
|
235
|
+
answers: { role: "staff" },
|
|
236
|
+
})
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
it("goes to the next step for a choice without goto", () => {
|
|
240
|
+
const { tours } = createTours({ registry: { role } })
|
|
241
|
+
tours.start("role")
|
|
242
|
+
tours.choose("student")
|
|
243
|
+
expect(tours.active?.stepId).toBe("student")
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
it("hands the answers to later steps' when", () => {
|
|
247
|
+
const branch = defineTour({
|
|
248
|
+
steps: [
|
|
249
|
+
{ id: "role", type: "dialog", choices: [{ label: "Staff", value: "staff" }] },
|
|
250
|
+
{ id: "students-only", type: "dialog", when: (ctx) => ctx.answers.role !== "staff" },
|
|
251
|
+
{ id: "end", type: "dialog" },
|
|
252
|
+
],
|
|
253
|
+
})
|
|
254
|
+
const { tours } = createTours({ registry: { branch } })
|
|
255
|
+
tours.start("branch")
|
|
256
|
+
tours.choose("staff")
|
|
257
|
+
expect(tours.active?.stepId).toBe("end")
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
it("ends the tour skipped when the last step is skipped", async () => {
|
|
261
|
+
const tour = defineTour({
|
|
262
|
+
steps: [
|
|
263
|
+
{ id: "a", type: "dialog" },
|
|
264
|
+
{ id: "last", type: "dialog", until: gate("never") },
|
|
265
|
+
],
|
|
266
|
+
})
|
|
267
|
+
const events = recorder()
|
|
268
|
+
const { tours } = createTours({ registry: { tour }, onEvent: events.onEvent })
|
|
269
|
+
const result = tours.start("tour")
|
|
270
|
+
tours.next()
|
|
271
|
+
tours.next()
|
|
272
|
+
await expect(result).resolves.toMatchObject({ status: "skipped", stepId: "last" })
|
|
273
|
+
expect(events.types().slice(-2)).toEqual(["step:skip@last", "tour:end@last"])
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
it("counts next() without an answer as skipping the step", () => {
|
|
277
|
+
const events = recorder()
|
|
278
|
+
const { tours } = createTours({ registry: { role }, onEvent: events.onEvent })
|
|
279
|
+
tours.start("role")
|
|
280
|
+
tours.next()
|
|
281
|
+
expect(events.types()).toContain("step:skip@role")
|
|
282
|
+
})
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
describe("gated steps", () => {
|
|
286
|
+
it("advances by itself after the tick when an action gate passes (D5)", async () => {
|
|
287
|
+
html(`<button id="create">Create</button>`)
|
|
288
|
+
const tour = defineTour({
|
|
289
|
+
steps: [
|
|
290
|
+
{ id: "create", target: "#create", until: click() },
|
|
291
|
+
{ id: "end", type: "dialog" },
|
|
292
|
+
],
|
|
293
|
+
})
|
|
294
|
+
const { tours } = createTours({ registry: { tour } })
|
|
295
|
+
tours.start("tour")
|
|
296
|
+
expect(tours.active?.gate).toBe("pending")
|
|
297
|
+
fireEvent.click($("#create"))
|
|
298
|
+
expect(tours.active).toMatchObject({ stepId: "create", gate: "valid" })
|
|
299
|
+
vi.advanceTimersByTime(TICK)
|
|
300
|
+
expect(tours.active?.stepId).toBe("end")
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
it("shows the tick and waits for Next on a typed value (D5)", () => {
|
|
304
|
+
html(`<input id="name" />`)
|
|
305
|
+
const tour = defineTour({
|
|
306
|
+
steps: [
|
|
307
|
+
{ id: "name", target: "#name", until: value((v) => v.length >= 3) },
|
|
308
|
+
{ id: "end", type: "dialog" },
|
|
309
|
+
],
|
|
310
|
+
})
|
|
311
|
+
const { tours } = createTours({ registry: { tour } })
|
|
312
|
+
tours.start("tour")
|
|
313
|
+
fireEvent.input($("#name"), { target: { value: "Norm" } })
|
|
314
|
+
vi.advanceTimersByTime(TICK * 10)
|
|
315
|
+
expect(tours.active).toMatchObject({ stepId: "name", gate: "valid" })
|
|
316
|
+
tours.next()
|
|
317
|
+
expect(tours.active?.stepId).toBe("end")
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
it("lets the step's advance override the condition's", () => {
|
|
321
|
+
html(`<button id="create">Create</button>`)
|
|
322
|
+
const tour = defineTour({
|
|
323
|
+
steps: [
|
|
324
|
+
{ id: "create", target: "#create", until: click(), advance: "manual" },
|
|
325
|
+
{ id: "end", type: "dialog" },
|
|
326
|
+
],
|
|
327
|
+
})
|
|
328
|
+
const { tours } = createTours({ registry: { tour } })
|
|
329
|
+
tours.start("tour")
|
|
330
|
+
fireEvent.click($("#create"))
|
|
331
|
+
vi.advanceTimersByTime(TICK * 10)
|
|
332
|
+
expect(tours.active?.stepId).toBe("create")
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
it("cancels the advance when the gate falls back before the tick ends", () => {
|
|
336
|
+
const tour = defineTour({
|
|
337
|
+
steps: [
|
|
338
|
+
{ id: "avatar", type: "dialog", until: gate("avatar") },
|
|
339
|
+
{ id: "end", type: "dialog" },
|
|
340
|
+
],
|
|
341
|
+
})
|
|
342
|
+
const { tours, useTourGate } = createTours({ registry: { tour } })
|
|
343
|
+
const Field = ({ state }: { state: "valid" | "pending" }) => {
|
|
344
|
+
useTourGate("avatar", state)
|
|
345
|
+
return null
|
|
346
|
+
}
|
|
347
|
+
tours.start("tour")
|
|
348
|
+
const view = render(<Field state="valid" />)
|
|
349
|
+
vi.advanceTimersByTime(TICK / 2)
|
|
350
|
+
view.rerender(<Field state="pending" />)
|
|
351
|
+
vi.advanceTimersByTime(TICK)
|
|
352
|
+
expect(tours.active).toMatchObject({ stepId: "avatar", gate: "pending" })
|
|
353
|
+
view.unmount()
|
|
354
|
+
})
|
|
355
|
+
|
|
356
|
+
it("ends the tour completed when the last step's gate passes", async () => {
|
|
357
|
+
const tour = defineTour({ steps: [{ id: "done", type: "wait", until: signal("saved") }] })
|
|
358
|
+
const { tours } = createTours({ registry: { tour } })
|
|
359
|
+
const result = tours.start("tour")
|
|
360
|
+
tours.signal("saved")
|
|
361
|
+
vi.advanceTimersByTime(TICK)
|
|
362
|
+
await expect(result).resolves.toMatchObject({ status: "completed", stepId: "done" })
|
|
363
|
+
})
|
|
364
|
+
|
|
365
|
+
describe("signals fired before a step waits on them", () => {
|
|
366
|
+
const later = defineTour({
|
|
367
|
+
steps: [
|
|
368
|
+
{ id: "a", type: "dialog" },
|
|
369
|
+
{ id: "b", type: "dialog", until: signal("saved", (p) => (p as { ok: boolean }).ok) },
|
|
370
|
+
{ id: "c", type: "dialog", until: signal("saved") },
|
|
371
|
+
{ id: "end", type: "dialog" },
|
|
372
|
+
],
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
it("remembers one for the run: a later step waiting on it passes at once", () => {
|
|
376
|
+
const { tours } = createTours({ registry: { later } })
|
|
377
|
+
tours.start("later")
|
|
378
|
+
tours.signal("saved", { ok: true })
|
|
379
|
+
tours.next()
|
|
380
|
+
expect(tours.active).toMatchObject({ stepId: "b", gate: "valid" })
|
|
381
|
+
vi.advanceTimersByTime(TICK)
|
|
382
|
+
expect(tours.active?.stepId).toBe("c")
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
it("applies match to the remembered payload, and a step takes it only once", () => {
|
|
386
|
+
const { tours } = createTours({ registry: { later } })
|
|
387
|
+
tours.start("later")
|
|
388
|
+
tours.signal("saved", { ok: false })
|
|
389
|
+
tours.next()
|
|
390
|
+
expect(tours.active).toMatchObject({ stepId: "b", gate: "pending" })
|
|
391
|
+
tours.signal("saved", { ok: true })
|
|
392
|
+
vi.advanceTimersByTime(TICK)
|
|
393
|
+
// c takes the { ok: false } that b's match turned down.
|
|
394
|
+
expect(tours.active).toMatchObject({ stepId: "c", gate: "valid" })
|
|
395
|
+
vi.advanceTimersByTime(TICK)
|
|
396
|
+
expect(tours.active?.stepId).toBe("end")
|
|
397
|
+
})
|
|
398
|
+
|
|
399
|
+
it("forgets them when the run ends", async () => {
|
|
400
|
+
const { tours } = createTours({ registry: { later } })
|
|
401
|
+
const first = tours.start("later")
|
|
402
|
+
tours.signal("saved", { ok: true })
|
|
403
|
+
tours.dismiss()
|
|
404
|
+
await first
|
|
405
|
+
tours.start("later")
|
|
406
|
+
tours.next()
|
|
407
|
+
expect(tours.active).toMatchObject({ stepId: "b", gate: "pending" })
|
|
408
|
+
})
|
|
409
|
+
|
|
410
|
+
it("drops one fired while no tour runs", () => {
|
|
411
|
+
const { tours } = createTours({ registry: { later } })
|
|
412
|
+
tours.signal("saved", { ok: true })
|
|
413
|
+
tours.start("later")
|
|
414
|
+
tours.next()
|
|
415
|
+
expect(tours.active).toMatchObject({ stepId: "b", gate: "pending" })
|
|
416
|
+
})
|
|
417
|
+
})
|
|
418
|
+
|
|
419
|
+
it("keeps required steps skippable from code: required only hides Skip", () => {
|
|
420
|
+
const tour = defineTour({
|
|
421
|
+
steps: [
|
|
422
|
+
{ id: "code", type: "dialog", required: true, until: gate("honour") },
|
|
423
|
+
{ id: "end", type: "dialog" },
|
|
424
|
+
],
|
|
425
|
+
})
|
|
426
|
+
const { tours } = createTours({ registry: { tour } })
|
|
427
|
+
tours.start("tour")
|
|
428
|
+
expect(tours.active?.step).toMatchObject({ required: true })
|
|
429
|
+
tours.dismiss()
|
|
430
|
+
expect(tours.active).toBeNull()
|
|
431
|
+
})
|
|
432
|
+
})
|
|
433
|
+
|
|
434
|
+
describe("help", () => {
|
|
435
|
+
const stuck = defineTour({
|
|
436
|
+
steps: [
|
|
437
|
+
{
|
|
438
|
+
id: "avatar",
|
|
439
|
+
type: "dialog",
|
|
440
|
+
until: gate("avatar"),
|
|
441
|
+
help: { after: 15_000, hint: "Click the avatar", pulse: true },
|
|
442
|
+
},
|
|
443
|
+
],
|
|
444
|
+
})
|
|
445
|
+
|
|
446
|
+
it("shows the hint and pulses after `after` ms without progress", () => {
|
|
447
|
+
const events = recorder()
|
|
448
|
+
const { tours } = createTours({ registry: { stuck }, onEvent: events.onEvent })
|
|
449
|
+
tours.start("stuck")
|
|
450
|
+
vi.advanceTimersByTime(14_999)
|
|
451
|
+
expect(tours.active?.help).toBeNull()
|
|
452
|
+
vi.advanceTimersByTime(1)
|
|
453
|
+
expect(tours.active?.help).toEqual({ hint: "Click the avatar", pulse: true })
|
|
454
|
+
expect(events.events.at(-1)).toMatchObject({ type: "step:hint", hint: "Click the avatar" })
|
|
455
|
+
})
|
|
456
|
+
|
|
457
|
+
it("restarts the wait when the gate changes, and never shows once valid", () => {
|
|
458
|
+
const { tours, useTourGate } = createTours({ registry: { stuck } })
|
|
459
|
+
const Field = ({ state }: { state: "valid" | { invalid: string } }) => {
|
|
460
|
+
useTourGate("avatar", state)
|
|
461
|
+
return null
|
|
462
|
+
}
|
|
463
|
+
tours.start("stuck")
|
|
464
|
+
vi.advanceTimersByTime(10_000)
|
|
465
|
+
const view = render(<Field state={{ invalid: "Wrong file" }} />)
|
|
466
|
+
vi.advanceTimersByTime(10_000)
|
|
467
|
+
expect(tours.active?.help).toBeNull()
|
|
468
|
+
view.rerender(<Field state="valid" />)
|
|
469
|
+
vi.advanceTimersByTime(30_000)
|
|
470
|
+
view.unmount()
|
|
471
|
+
})
|
|
472
|
+
})
|
|
473
|
+
|
|
474
|
+
describe("a missing target (D3)", () => {
|
|
475
|
+
const late = defineTour({
|
|
476
|
+
steps: [
|
|
477
|
+
{ id: "create", target: "#create", title: "Create", wait: { timeout: 2000 } },
|
|
478
|
+
{ id: "end", type: "dialog" },
|
|
479
|
+
],
|
|
480
|
+
})
|
|
481
|
+
|
|
482
|
+
it("waits with a loading state, then times out, and carries on when the target shows up", async () => {
|
|
483
|
+
const events = recorder()
|
|
484
|
+
const warn = vi.spyOn(console, "warn").mockImplementation(() => {})
|
|
485
|
+
const { tours } = createTours({ registry: { late }, onEvent: events.onEvent })
|
|
486
|
+
tours.start("late")
|
|
487
|
+
expect(tours.active?.state).toBe("loading")
|
|
488
|
+
vi.advanceTimersByTime(2000)
|
|
489
|
+
expect(tours.active?.state).toBe("timeout")
|
|
490
|
+
expect(warn).toHaveBeenCalledWith(expect.stringContaining("still missing after 2000ms"))
|
|
491
|
+
html(`<button id="create">Create</button>`)
|
|
492
|
+
await act(() => Promise.resolve())
|
|
493
|
+
expect(tours.active?.state).toBe("shown")
|
|
494
|
+
expect(events.types()).toEqual([
|
|
495
|
+
"tour:start@create",
|
|
496
|
+
"step:waiting@create",
|
|
497
|
+
"step:timeout@create",
|
|
498
|
+
"step:show@create",
|
|
499
|
+
])
|
|
500
|
+
expect(events.events.find((e) => e.type === "step:timeout")).toMatchObject({ timeout: 2000 })
|
|
501
|
+
warn.mockRestore()
|
|
502
|
+
})
|
|
503
|
+
|
|
504
|
+
it("defaults the timeout to 5 seconds", () => {
|
|
505
|
+
const noTimeout = defineTour({ steps: [{ id: "a", target: "#missing" }] })
|
|
506
|
+
const warn = vi.spyOn(console, "warn").mockImplementation(() => {})
|
|
507
|
+
const { tours } = createTours({ registry: { noTimeout } })
|
|
508
|
+
tours.start("noTimeout")
|
|
509
|
+
vi.advanceTimersByTime(WAIT_TIMEOUT - 1)
|
|
510
|
+
expect(tours.active?.state).toBe("loading")
|
|
511
|
+
vi.advanceTimersByTime(1)
|
|
512
|
+
expect(tours.active?.state).toBe("timeout")
|
|
513
|
+
warn.mockRestore()
|
|
514
|
+
})
|
|
515
|
+
|
|
516
|
+
it("Skip step moves on, as a skip", () => {
|
|
517
|
+
const events = recorder()
|
|
518
|
+
const warn = vi.spyOn(console, "warn").mockImplementation(() => {})
|
|
519
|
+
const { tours } = createTours({ registry: { late }, onEvent: events.onEvent })
|
|
520
|
+
tours.start("late")
|
|
521
|
+
vi.advanceTimersByTime(2000)
|
|
522
|
+
tours.next()
|
|
523
|
+
expect(tours.active?.stepId).toBe("end")
|
|
524
|
+
expect(events.types()).toContain("step:skip@create")
|
|
525
|
+
warn.mockRestore()
|
|
526
|
+
})
|
|
527
|
+
|
|
528
|
+
it("goes back to waiting when the target leaves the page", async () => {
|
|
529
|
+
html(`<button id="create">Create</button>`)
|
|
530
|
+
const { tours } = createTours({ registry: { late } })
|
|
531
|
+
tours.start("late")
|
|
532
|
+
expect(tours.active?.state).toBe("shown")
|
|
533
|
+
$("#create").remove()
|
|
534
|
+
await act(() => Promise.resolve())
|
|
535
|
+
expect(tours.active?.state).toBe("loading")
|
|
536
|
+
})
|
|
537
|
+
})
|
|
538
|
+
|
|
539
|
+
describe("the event stream", () => {
|
|
540
|
+
it("sends each event in order, with key, version, run, step and index", () => {
|
|
541
|
+
html(`<button id="create">Create</button>`)
|
|
542
|
+
const tour = defineTour({
|
|
543
|
+
version: 3,
|
|
544
|
+
steps: [
|
|
545
|
+
{ id: "welcome", type: "dialog" },
|
|
546
|
+
{ id: "create", target: "#create", until: click() },
|
|
547
|
+
],
|
|
548
|
+
})
|
|
549
|
+
const events = recorder()
|
|
550
|
+
const { tours } = createTours({ registry: { tour }, onEvent: events.onEvent })
|
|
551
|
+
tours.start("tour")
|
|
552
|
+
vi.advanceTimersByTime(1500)
|
|
553
|
+
tours.next()
|
|
554
|
+
vi.advanceTimersByTime(2500)
|
|
555
|
+
fireEvent.click($("#create"))
|
|
556
|
+
vi.advanceTimersByTime(TICK)
|
|
557
|
+
expect(events.types()).toEqual([
|
|
558
|
+
"tour:start@welcome",
|
|
559
|
+
"step:show@welcome",
|
|
560
|
+
"step:complete@welcome",
|
|
561
|
+
"step:show@create",
|
|
562
|
+
"step:complete@create",
|
|
563
|
+
"tour:end@create",
|
|
564
|
+
])
|
|
565
|
+
const [start, , welcome, , create, end] = events.events
|
|
566
|
+
expect(start).toMatchObject({ key: "tour", version: 3, index: 0, resumed: false })
|
|
567
|
+
expect(welcome).toMatchObject({ duration: 1500, attempts: 0, index: 0 })
|
|
568
|
+
expect(create).toMatchObject({ duration: 2500 + TICK, index: 1 })
|
|
569
|
+
expect(end).toMatchObject({ status: "completed", index: 1 })
|
|
570
|
+
expect(new Set(events.events.map((e) => e.run)).size).toBe(1)
|
|
571
|
+
})
|
|
572
|
+
|
|
573
|
+
it("counts invalid attempts and reports them on complete", () => {
|
|
574
|
+
const tour = defineTour({ steps: [{ id: "avatar", type: "dialog", until: gate("avatar") }] })
|
|
575
|
+
const events = recorder()
|
|
576
|
+
const { tours, useTourGate } = createTours({ registry: { tour }, onEvent: events.onEvent })
|
|
577
|
+
const Field = ({ state }: { state: "valid" | { invalid: string } }) => {
|
|
578
|
+
useTourGate("avatar", state)
|
|
579
|
+
return null
|
|
580
|
+
}
|
|
581
|
+
tours.start("tour")
|
|
582
|
+
const view = render(<Field state={{ invalid: "Too small" }} />)
|
|
583
|
+
view.rerender(<Field state={{ invalid: "Wrong format" }} />)
|
|
584
|
+
view.rerender(<Field state="valid" />)
|
|
585
|
+
vi.advanceTimersByTime(TICK)
|
|
586
|
+
const invalid = events.events.filter((e) => e.type === "step:invalid")
|
|
587
|
+
expect(invalid).toMatchObject([
|
|
588
|
+
{ message: "Too small", attempts: 1 },
|
|
589
|
+
{ message: "Wrong format", attempts: 2 },
|
|
590
|
+
])
|
|
591
|
+
expect(events.events.find((e) => e.type === "step:complete")).toMatchObject({ attempts: 2 })
|
|
592
|
+
view.unmount()
|
|
593
|
+
})
|
|
594
|
+
|
|
595
|
+
it("sends tour:start with no step, then tour:end, for a tour with nothing to show", () => {
|
|
596
|
+
const empty = defineTour({ when: () => false, steps: [{ id: "a", type: "dialog" }] })
|
|
597
|
+
const events = recorder()
|
|
598
|
+
const { tours } = createTours({ registry: { empty }, onEvent: events.onEvent })
|
|
599
|
+
tours.start("empty")
|
|
600
|
+
expect(events.events).toMatchObject([
|
|
601
|
+
{ type: "tour:start", stepId: null },
|
|
602
|
+
{ type: "tour:end", stepId: null, status: "not-found" },
|
|
603
|
+
])
|
|
604
|
+
})
|
|
605
|
+
})
|
|
606
|
+
|
|
607
|
+
describe("storage", () => {
|
|
608
|
+
it("startOnce skips a tour this version already completed, skipped or dismissed", async () => {
|
|
609
|
+
for (const status of ["completed", "skipped", "dismissed"] as const) {
|
|
610
|
+
const { storage } = memoryStorage({
|
|
611
|
+
plain: { version: 1, status, stepId: "one", answers: {}, updatedAt: 0 },
|
|
612
|
+
})
|
|
613
|
+
const { tours } = createTours({ registry: { plain }, storage })
|
|
614
|
+
await expect(tours.startOnce("plain")).resolves.toBeNull()
|
|
615
|
+
}
|
|
616
|
+
})
|
|
617
|
+
|
|
618
|
+
it("startOnce shows the tour again after a version bump", async () => {
|
|
619
|
+
const { storage } = memoryStorage({
|
|
620
|
+
plain: { version: 0, status: "completed", stepId: "three", answers: {}, updatedAt: 0 },
|
|
621
|
+
})
|
|
622
|
+
const { tours } = createTours({ registry: { plain }, storage })
|
|
623
|
+
const result = tours.startOnce("plain")
|
|
624
|
+
await vi.advanceTimersByTimeAsync(0)
|
|
625
|
+
expect(tours.active?.stepId).toBe("one")
|
|
626
|
+
tours.dismiss()
|
|
627
|
+
await expect(result).resolves.toMatchObject({ status: "dismissed" })
|
|
628
|
+
})
|
|
629
|
+
|
|
630
|
+
it("records progress as the tour runs, and how it ended", async () => {
|
|
631
|
+
const { storage, records } = memoryStorage()
|
|
632
|
+
const { tours } = createTours({ registry: { plain }, storage })
|
|
633
|
+
const result = tours.start("plain")
|
|
634
|
+
tours.next()
|
|
635
|
+
expect(records.get("plain")).toMatchObject({ version: 1, status: "active", stepId: "two" })
|
|
636
|
+
tours.skip()
|
|
637
|
+
await result
|
|
638
|
+
expect(records.get("plain")).toMatchObject({ status: "skipped", stepId: "two" })
|
|
639
|
+
await expect(tours.startOnce("plain")).resolves.toBeNull()
|
|
640
|
+
})
|
|
641
|
+
|
|
642
|
+
it("resume continues from the saved step, with the saved answers", async () => {
|
|
643
|
+
const { storage } = memoryStorage({
|
|
644
|
+
plain: { version: 1, status: "active", stepId: "two", answers: { one: "x" }, updatedAt: 0 },
|
|
645
|
+
})
|
|
646
|
+
const events = recorder()
|
|
647
|
+
const { tours } = createTours({ registry: { plain }, storage, onEvent: events.onEvent })
|
|
648
|
+
tours.resume("plain")
|
|
649
|
+
await vi.advanceTimersByTimeAsync(0)
|
|
650
|
+
expect(tours.active).toMatchObject({ stepId: "two", answers: { one: "x" } })
|
|
651
|
+
expect(events.events[0]).toMatchObject({ type: "tour:start", resumed: true })
|
|
652
|
+
})
|
|
653
|
+
|
|
654
|
+
it("resume starts from the first step when nothing is saved, or the tour ended", async () => {
|
|
655
|
+
const { storage } = memoryStorage({
|
|
656
|
+
plain: { version: 1, status: "completed", stepId: "three", answers: {}, updatedAt: 0 },
|
|
657
|
+
})
|
|
658
|
+
const { tours } = createTours({ registry: { plain }, storage })
|
|
659
|
+
tours.resume("plain")
|
|
660
|
+
await vi.advanceTimersByTimeAsync(0)
|
|
661
|
+
expect(tours.active?.stepId).toBe("one")
|
|
662
|
+
})
|
|
663
|
+
|
|
664
|
+
it("reset forgets the record, so startOnce shows the tour again", async () => {
|
|
665
|
+
const { storage, records } = memoryStorage({
|
|
666
|
+
plain: { version: 1, status: "completed", stepId: "three", answers: {}, updatedAt: 0 },
|
|
667
|
+
})
|
|
668
|
+
const { tours } = createTours({ registry: { plain }, storage })
|
|
669
|
+
await tours.reset("plain")
|
|
670
|
+
expect(records.has("plain")).toBe(false)
|
|
671
|
+
tours.startOnce("plain")
|
|
672
|
+
await vi.advanceTimersByTimeAsync(0)
|
|
673
|
+
expect(tours.active?.stepId).toBe("one")
|
|
674
|
+
})
|
|
675
|
+
|
|
676
|
+
it("works with an async storage", async () => {
|
|
677
|
+
const { storage, records } = memoryStorage({
|
|
678
|
+
plain: { version: 1, status: "dismissed", stepId: "one", answers: {}, updatedAt: 0 },
|
|
679
|
+
})
|
|
680
|
+
const asyncStorage: TourStorage = {
|
|
681
|
+
get: async (key) => storage.get(key),
|
|
682
|
+
set: async (key, record) => storage.set(key, record),
|
|
683
|
+
remove: async (key) => storage.remove(key),
|
|
684
|
+
}
|
|
685
|
+
const { tours } = createTours({ registry: { plain }, storage: asyncStorage })
|
|
686
|
+
await expect(tours.startOnce("plain")).resolves.toBeNull()
|
|
687
|
+
expect(records.size).toBe(1)
|
|
688
|
+
})
|
|
689
|
+
|
|
690
|
+
it("treats a storage that throws as empty", async () => {
|
|
691
|
+
const broken: TourStorage = {
|
|
692
|
+
get: () => {
|
|
693
|
+
throw new Error("blocked")
|
|
694
|
+
},
|
|
695
|
+
set: () => {
|
|
696
|
+
throw new Error("blocked")
|
|
697
|
+
},
|
|
698
|
+
remove: () => {
|
|
699
|
+
throw new Error("blocked")
|
|
700
|
+
},
|
|
701
|
+
}
|
|
702
|
+
const { tours } = createTours({ registry: { plain }, storage: broken })
|
|
703
|
+
tours.startOnce("plain")
|
|
704
|
+
await vi.advanceTimersByTimeAsync(0)
|
|
705
|
+
expect(tours.active?.stepId).toBe("one")
|
|
706
|
+
tours.next()
|
|
707
|
+
await expect(tours.reset("plain")).resolves.toBeUndefined()
|
|
708
|
+
})
|
|
709
|
+
})
|
|
710
|
+
|
|
711
|
+
describe("focus return", () => {
|
|
712
|
+
it("gives focus back to where it was when the tour started", async () => {
|
|
713
|
+
html(`<button id="opener">Start the tour</button>`)
|
|
714
|
+
$("#opener").focus()
|
|
715
|
+
const { tours } = createTours({ registry: { plain } })
|
|
716
|
+
const result = tours.start("plain")
|
|
717
|
+
$("#opener").blur()
|
|
718
|
+
tours.dismiss()
|
|
719
|
+
await result
|
|
720
|
+
expect(document.activeElement).toBe($("#opener"))
|
|
721
|
+
})
|
|
722
|
+
|
|
723
|
+
it("leaves focus where the user put it outside the tour", async () => {
|
|
724
|
+
html(`<button id="opener">Start</button><input id="search" />`)
|
|
725
|
+
$("#opener").focus()
|
|
726
|
+
const { tours } = createTours({ registry: { plain } })
|
|
727
|
+
tours.start("plain")
|
|
728
|
+
$("#search").focus()
|
|
729
|
+
tours.dismiss()
|
|
730
|
+
expect(document.activeElement).toBe($("#search"))
|
|
731
|
+
})
|
|
732
|
+
})
|
|
733
|
+
|
|
734
|
+
describe("useTours", () => {
|
|
735
|
+
it("returns [active, tours] and re-renders as the tour moves", () => {
|
|
736
|
+
const { tours, useTours } = createTours({ registry: { plain } })
|
|
737
|
+
const seen: (string | null)[] = []
|
|
738
|
+
const Probe = () => {
|
|
739
|
+
const [active] = useTours()
|
|
740
|
+
seen.push(active?.stepId ?? null)
|
|
741
|
+
return null
|
|
742
|
+
}
|
|
743
|
+
render(<Probe />)
|
|
744
|
+
act(() => {
|
|
745
|
+
tours.start("plain")
|
|
746
|
+
})
|
|
747
|
+
act(() => tours.next())
|
|
748
|
+
act(() => tours.dismiss())
|
|
749
|
+
expect(seen).toEqual([null, "one", "two", null])
|
|
750
|
+
})
|
|
751
|
+
})
|
|
752
|
+
|
|
753
|
+
describe("<Tours />", () => {
|
|
754
|
+
it("registers a running tour as a layer, so page hotkeys yield to it", async () => {
|
|
755
|
+
const { isTourOpen } = await import("../../lib/overlay-layer")
|
|
756
|
+
const { tours, Tours } = createTours({ registry: { plain } })
|
|
757
|
+
render(<Tours />)
|
|
758
|
+
expect(isTourOpen()).toBe(false)
|
|
759
|
+
act(() => {
|
|
760
|
+
tours.start("plain")
|
|
761
|
+
})
|
|
762
|
+
expect(isTourOpen()).toBe(true)
|
|
763
|
+
act(() => tours.dismiss())
|
|
764
|
+
expect(isTourOpen()).toBe(false)
|
|
765
|
+
})
|
|
766
|
+
|
|
767
|
+
it("makes a page-level useHotkey yield while a tour shows, like a modal", () => {
|
|
768
|
+
const handler = vi.fn()
|
|
769
|
+
const { tours, Tours } = createTours({ registry: { plain } })
|
|
770
|
+
const Page = () => {
|
|
771
|
+
useHotkey("j", handler)
|
|
772
|
+
return <Tours />
|
|
773
|
+
}
|
|
774
|
+
render(<Page />)
|
|
775
|
+
act(() => {
|
|
776
|
+
tours.start("plain")
|
|
777
|
+
})
|
|
778
|
+
fireEvent.keyDown(document.body, { key: "j" })
|
|
779
|
+
expect(handler).not.toHaveBeenCalled()
|
|
780
|
+
act(() => tours.dismiss())
|
|
781
|
+
fireEvent.keyDown(document.body, { key: "j" })
|
|
782
|
+
expect(handler).toHaveBeenCalledOnce()
|
|
783
|
+
})
|
|
784
|
+
})
|