@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,238 @@
|
|
|
1
|
+
import { act, render, renderHook } from "@testing-library/react"
|
|
2
|
+
import { renderToString } from "react-dom/server"
|
|
3
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
|
|
4
|
+
import { pickActiveHeading, pickVisibleRange, useScrollSpy } from "./use-scroll-spy"
|
|
5
|
+
|
|
6
|
+
/** Gives `el` a fixed viewport rect, as layout would. */
|
|
7
|
+
const placeAt = (el: Element, top: number, height = 20) => {
|
|
8
|
+
el.getBoundingClientRect = () => ({ top, bottom: top + height, height }) as DOMRect
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** An article of headings, appended to the body; `tops` are their viewport tops. */
|
|
12
|
+
const mountArticle = (tops: number[]) => {
|
|
13
|
+
const article = document.createElement("article")
|
|
14
|
+
article.id = "article"
|
|
15
|
+
article.innerHTML = `
|
|
16
|
+
<h2 id="intro">Intro</h2>
|
|
17
|
+
<h3 id="setup">Setup <code>pnpm</code></h3>
|
|
18
|
+
<h2>No id</h2>
|
|
19
|
+
<h2 id="usage">Usage</h2>
|
|
20
|
+
<h4 id="deep">Deep</h4>
|
|
21
|
+
`
|
|
22
|
+
document.body.append(article)
|
|
23
|
+
const headings = [...article.querySelectorAll<HTMLElement>("h2[id], h3, h4")]
|
|
24
|
+
headings.forEach((h, i) => {
|
|
25
|
+
placeAt(h, tops[i] ?? 0)
|
|
26
|
+
})
|
|
27
|
+
return { article, headings }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const scroll = (target: EventTarget = window) =>
|
|
31
|
+
act(() => {
|
|
32
|
+
target.dispatchEvent(new Event("scroll"))
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
vi.spyOn(window, "requestAnimationFrame").mockImplementation((cb) => {
|
|
37
|
+
cb(0)
|
|
38
|
+
return 0
|
|
39
|
+
})
|
|
40
|
+
vi.spyOn(window, "scrollBy").mockImplementation(() => {})
|
|
41
|
+
Object.defineProperty(window, "innerHeight", { configurable: true, value: 800 })
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
vi.restoreAllMocks()
|
|
46
|
+
document.body.innerHTML = ""
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
describe("pickActiveHeading", () => {
|
|
50
|
+
const at = (line: number, end = false) => ({ line, bottom: 800, end })
|
|
51
|
+
|
|
52
|
+
it("picks the last heading that reached the line", () => {
|
|
53
|
+
expect(pickActiveHeading([-300, -10, 200], at(0))).toBe(1)
|
|
54
|
+
expect(pickActiveHeading([-300, 0, 200], at(0))).toBe(1)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it("falls back to the first heading before any reached the line", () => {
|
|
58
|
+
expect(pickActiveHeading([100, 400], at(0))).toBe(0)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it("at the end of the scroll, picks the last heading still in view", () => {
|
|
62
|
+
expect(pickActiveHeading([-300, 300, 600, 900], at(0, true))).toBe(2)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it("is -1 with no headings", () => {
|
|
66
|
+
expect(pickActiveHeading([], at(0))).toBe(-1)
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
describe("pickVisibleRange", () => {
|
|
71
|
+
const at = (line: number) => ({ line, bottom: 800 })
|
|
72
|
+
|
|
73
|
+
it("runs from the section holding the line to the last heading above the bottom", () => {
|
|
74
|
+
expect(pickVisibleRange([-300, -10, 200, 900], at(0))).toEqual([1, 2])
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it("is the one section being read when no other heading is in view", () => {
|
|
78
|
+
expect(pickVisibleRange([-900, 1000], at(0))).toEqual([0, 0])
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it("starts at the first section before any heading reached the line", () => {
|
|
82
|
+
expect(pickVisibleRange([100, 400], at(0))).toEqual([0, 1])
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it("is [-1, -1] with no headings", () => {
|
|
86
|
+
expect(pickVisibleRange([], at(0))).toEqual([-1, -1])
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
describe("useScrollSpy", () => {
|
|
91
|
+
it("collects the headings with an id, with their level and text", () => {
|
|
92
|
+
mountArticle([0, 100, 200, 300])
|
|
93
|
+
const { result } = renderHook(() => useScrollSpy({ container: "#article" }))
|
|
94
|
+
expect(result.current.initialized).toBe(true)
|
|
95
|
+
expect(result.current.data.map(({ id, label, depth }) => ({ id, label, depth }))).toEqual([
|
|
96
|
+
{ id: "intro", label: "Intro", depth: 2 },
|
|
97
|
+
{ id: "setup", label: "Setup pnpm", depth: 3 },
|
|
98
|
+
{ id: "usage", label: "Usage", depth: 2 },
|
|
99
|
+
{ id: "deep", label: "Deep", depth: 4 },
|
|
100
|
+
])
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it("limits collection to the selector and the container ref", () => {
|
|
104
|
+
const { article } = mountArticle([0, 100, 200, 300])
|
|
105
|
+
const outside = document.createElement("h2")
|
|
106
|
+
outside.id = "outside"
|
|
107
|
+
document.body.append(outside)
|
|
108
|
+
const container = { current: article }
|
|
109
|
+
const { result } = renderHook(() => useScrollSpy({ container, selector: "h2" }))
|
|
110
|
+
expect(result.current.data.map((h) => h.id)).toEqual(["intro", "usage"])
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
it("returns `data` before mount, so a server render has the entries", () => {
|
|
114
|
+
const Probe = () => {
|
|
115
|
+
const spy = useScrollSpy({ data: [{ id: "a", label: "A", depth: 2 }, { id: "b" }] })
|
|
116
|
+
return <p>{spy.data.map((h) => `${h.id}:${h.label}:${h.depth}`).join(",")}</p>
|
|
117
|
+
}
|
|
118
|
+
expect(renderToString(<Probe />)).toContain("a:A:2,b::1")
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
it("fills a `data` entry's missing label and level from its heading", () => {
|
|
122
|
+
mountArticle([0, 100, 200, 300])
|
|
123
|
+
const { result } = renderHook(() => useScrollSpy({ data: [{ id: "setup" }, { id: "gone" }] }))
|
|
124
|
+
expect(result.current.data.map(({ id, label, depth }) => ({ id, label, depth }))).toEqual([
|
|
125
|
+
{ id: "setup", label: "Setup pnpm", depth: 3 },
|
|
126
|
+
{ id: "gone", label: "", depth: 1 },
|
|
127
|
+
])
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
it("tracks the heading that scrolled past the offset line", () => {
|
|
131
|
+
const { headings } = mountArticle([0, 300, 600, 900])
|
|
132
|
+
const { result } = renderHook(() => useScrollSpy({ container: "#article", offset: 64 }))
|
|
133
|
+
expect(result.current.active).toBe("intro")
|
|
134
|
+
|
|
135
|
+
headings.forEach((h, i) => {
|
|
136
|
+
placeAt(h, [-400, 64, 300, 600][i] as number)
|
|
137
|
+
})
|
|
138
|
+
scroll()
|
|
139
|
+
expect(result.current.active).toBe("setup")
|
|
140
|
+
// `setup` holds the line; `usage` and `deep` start above the bottom (800).
|
|
141
|
+
expect(result.current.visible).toEqual(["setup", "usage", "deep"])
|
|
142
|
+
|
|
143
|
+
headings.forEach((h, i) => {
|
|
144
|
+
placeAt(h, [-400, 100, 300, 600][i] as number)
|
|
145
|
+
})
|
|
146
|
+
scroll()
|
|
147
|
+
expect(result.current.active).toBe("intro")
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
it("measures against a nested scroller's top, and listens to its scroll", () => {
|
|
151
|
+
const { article, headings } = mountArticle([0, 0, 0, 0])
|
|
152
|
+
const scroller = document.createElement("div")
|
|
153
|
+
scroller.append(article)
|
|
154
|
+
document.body.append(scroller)
|
|
155
|
+
placeAt(scroller, 200, 400)
|
|
156
|
+
Object.defineProperty(scroller, "clientHeight", { configurable: true, value: 400 })
|
|
157
|
+
headings.forEach((h, i) => {
|
|
158
|
+
placeAt(h, [150, 260, 400, 700][i] as number)
|
|
159
|
+
})
|
|
160
|
+
const root = { current: scroller }
|
|
161
|
+
const { result } = renderHook(() => useScrollSpy({ container: "#article", root, offset: 50 }))
|
|
162
|
+
// The line is 200 (scroller top) + 50: only `intro` is above it.
|
|
163
|
+
expect(result.current.active).toBe("intro")
|
|
164
|
+
|
|
165
|
+
headings.forEach((h, i) => {
|
|
166
|
+
placeAt(h, [-100, 0, 240, 500][i] as number)
|
|
167
|
+
})
|
|
168
|
+
scroll(scroller)
|
|
169
|
+
expect(result.current.active).toBe("usage")
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
it("scrolls by the distance to the line, in the scroller, and pins the target", () => {
|
|
173
|
+
const { article, headings } = mountArticle([0, 0, 0, 0])
|
|
174
|
+
const scroller = document.createElement("div")
|
|
175
|
+
scroller.append(article)
|
|
176
|
+
document.body.append(scroller)
|
|
177
|
+
scroller.scrollBy = vi.fn()
|
|
178
|
+
placeAt(scroller, 100, 400)
|
|
179
|
+
headings.forEach((h, i) => {
|
|
180
|
+
placeAt(h, [100, 500, 900, 1300][i] as number)
|
|
181
|
+
})
|
|
182
|
+
const root = { current: scroller }
|
|
183
|
+
const { result } = renderHook(() => useScrollSpy({ container: "#article", root, offset: 40 }))
|
|
184
|
+
|
|
185
|
+
let found = false
|
|
186
|
+
act(() => {
|
|
187
|
+
found = result.current.scrollTo("usage")
|
|
188
|
+
})
|
|
189
|
+
expect(found).toBe(true)
|
|
190
|
+
// 900 - (100 + 40): a delta, never an absolute scrollTop.
|
|
191
|
+
expect(scroller.scrollBy).toHaveBeenCalledWith({ top: 760, behavior: "smooth" })
|
|
192
|
+
expect(window.scrollBy).not.toHaveBeenCalled()
|
|
193
|
+
expect(result.current.active).toBe("usage")
|
|
194
|
+
|
|
195
|
+
// Headings passing the line during the smooth scroll don't take over
|
|
196
|
+
// `active`, but the range follows the scroll.
|
|
197
|
+
headings.forEach((h, i) => {
|
|
198
|
+
placeAt(h, [-300, 140, 500, 900][i] as number)
|
|
199
|
+
})
|
|
200
|
+
scroll(scroller)
|
|
201
|
+
expect(result.current.active).toBe("usage")
|
|
202
|
+
expect(result.current.visible).toEqual(["setup"])
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
it("scrolls the window instantly when the reader prefers reduced motion", () => {
|
|
206
|
+
mountArticle([0, 500, 900, 1300])
|
|
207
|
+
vi.spyOn(window, "matchMedia").mockReturnValue({ matches: true } as MediaQueryList)
|
|
208
|
+
const { result } = renderHook(() => useScrollSpy({ container: "#article", offset: 10 }))
|
|
209
|
+
act(() => {
|
|
210
|
+
result.current.scrollTo("setup")
|
|
211
|
+
})
|
|
212
|
+
expect(window.scrollBy).toHaveBeenCalledWith({ top: 490, behavior: "instant" })
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
it("returns false for a heading that isn't on the page", () => {
|
|
216
|
+
const { result } = renderHook(() => useScrollSpy({ data: [{ id: "nowhere" }] }))
|
|
217
|
+
expect(result.current.scrollTo("nowhere")).toBe(false)
|
|
218
|
+
expect(window.scrollBy).not.toHaveBeenCalled()
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
it("reads the headings again on reinitialize", () => {
|
|
222
|
+
const { article } = mountArticle([0, 100, 200, 300])
|
|
223
|
+
const { result } = renderHook(() => useScrollSpy({ container: "#article" }))
|
|
224
|
+
const added = document.createElement("h2")
|
|
225
|
+
added.id = "added"
|
|
226
|
+
article.append(added)
|
|
227
|
+
expect(result.current.data).toHaveLength(4)
|
|
228
|
+
act(() => result.current.reinitialize())
|
|
229
|
+
expect(result.current.data.map((h) => h.id)).toContain("added")
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
it("is inactive with no headings", () => {
|
|
233
|
+
render(<div />)
|
|
234
|
+
const { result } = renderHook(() => useScrollSpy({ container: "#missing" }))
|
|
235
|
+
expect(result.current.data).toEqual([])
|
|
236
|
+
expect(result.current.active).toBeNull()
|
|
237
|
+
})
|
|
238
|
+
})
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { type RefObject, useCallback, useEffect, useRef, useState } from "react"
|
|
4
|
+
import { devWarnOnce } from "./dev-warn"
|
|
5
|
+
import { prefersReducedMotion } from "./motion/reduced-motion"
|
|
6
|
+
|
|
7
|
+
/** One heading the spy watches. */
|
|
8
|
+
export type ScrollSpyHeading = {
|
|
9
|
+
/** The heading element's `id`: its `#hash`, and the spy's `active` value. */
|
|
10
|
+
id: string
|
|
11
|
+
/** Its text, from `getLabel` (by default the element's text). */
|
|
12
|
+
label: string
|
|
13
|
+
/** Its level: `2` for an `<h2>`, from `getDepth`. */
|
|
14
|
+
depth: number
|
|
15
|
+
/** The element. `null` on the server, before mount, and for a `data` entry whose id isn't on the page. */
|
|
16
|
+
node: HTMLElement | null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** A heading you already know, passed as `data` instead of collected from the page. */
|
|
20
|
+
export type ScrollSpyEntry = {
|
|
21
|
+
/** The heading element's `id`. */
|
|
22
|
+
id: string
|
|
23
|
+
/** Its text. Defaults to the element's text once mounted, `""` before. */
|
|
24
|
+
label?: string
|
|
25
|
+
/** Its level. Defaults to the element's own (`2` for an `<h2>`) once mounted, `1` before. */
|
|
26
|
+
depth?: number
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type UseScrollSpyOptions = {
|
|
30
|
+
/**
|
|
31
|
+
* Where to collect headings from: a ref, or a CSS selector for one
|
|
32
|
+
* element. The whole document without it. Ignored when `data` is set.
|
|
33
|
+
*/
|
|
34
|
+
container?: RefObject<Element | null> | string
|
|
35
|
+
/** Which elements count as headings. @default "h1, h2, h3, h4, h5, h6" */
|
|
36
|
+
selector?: string
|
|
37
|
+
/**
|
|
38
|
+
* The headings to watch, in order, instead of collecting them. They are
|
|
39
|
+
* returned as `data` straight away, so a server render already has them.
|
|
40
|
+
*/
|
|
41
|
+
data?: readonly ScrollSpyEntry[]
|
|
42
|
+
/** A heading's level. By default its tag's (`h3` is `3`), else its `aria-level`, else `1`. */
|
|
43
|
+
getDepth?: (element: HTMLElement) => number
|
|
44
|
+
/** A heading's label. By default its trimmed text. */
|
|
45
|
+
getLabel?: (element: HTMLElement) => string
|
|
46
|
+
/** The scrolling ancestor the headings move in. The window without it. */
|
|
47
|
+
root?: RefObject<HTMLElement | null>
|
|
48
|
+
/**
|
|
49
|
+
* The height, in px, of whatever covers the top of `root` (a sticky
|
|
50
|
+
* header). A heading becomes active when it reaches this line, and
|
|
51
|
+
* `scrollTo` stops it just below it. @default 0
|
|
52
|
+
*/
|
|
53
|
+
offset?: number
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** How `scrollTo` moves. */
|
|
57
|
+
export type ScrollSpyScrollOptions = {
|
|
58
|
+
/** `"smooth"` by default, or `"instant"` when the reader prefers reduced motion. */
|
|
59
|
+
behavior?: ScrollBehavior
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type UseScrollSpyReturnValue = {
|
|
63
|
+
/** The `id` of the heading being read, `null` before the first measure or with no headings. */
|
|
64
|
+
active: string | null
|
|
65
|
+
/**
|
|
66
|
+
* The `id`s of every section in view, in order: from the one being read
|
|
67
|
+
* (whose heading is at or above the line) to the last heading above the
|
|
68
|
+
* bottom of `root`. Never empty once `active` is set. A table of contents
|
|
69
|
+
* highlights this range; `active` is the one entry that gets
|
|
70
|
+
* `aria-current`.
|
|
71
|
+
*/
|
|
72
|
+
visible: string[]
|
|
73
|
+
/** The headings, in document order. Empty until mount unless `data` was passed. */
|
|
74
|
+
data: ScrollSpyHeading[]
|
|
75
|
+
/** `true` once the headings have been read from the page. */
|
|
76
|
+
initialized: boolean
|
|
77
|
+
/** Reads the headings again, for content that changed after mount. */
|
|
78
|
+
reinitialize: () => void
|
|
79
|
+
/**
|
|
80
|
+
* Scrolls `root` so the heading sits just under `offset`, and makes it
|
|
81
|
+
* active until the scroll settles. Returns `false` when the heading isn't
|
|
82
|
+
* on the page.
|
|
83
|
+
*/
|
|
84
|
+
scrollTo: (id: string, options?: ScrollSpyScrollOptions) => boolean
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export const DEFAULT_SCROLL_SPY_SELECTOR = "h1, h2, h3, h4, h5, h6"
|
|
88
|
+
|
|
89
|
+
const HEADING_TAG = /^H([1-6])$/
|
|
90
|
+
|
|
91
|
+
const defaultDepth = (el: HTMLElement) => {
|
|
92
|
+
const tag = HEADING_TAG.exec(el.tagName)?.[1]
|
|
93
|
+
return Number(tag ?? el.getAttribute("aria-level") ?? 1) || 1
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const defaultLabel = (el: HTMLElement) => el.textContent?.trim() ?? ""
|
|
97
|
+
|
|
98
|
+
/** A ref read is the only `container` that needs no lookup; a string is a selector. */
|
|
99
|
+
const resolveContainer = (container: UseScrollSpyOptions["container"]): ParentNode | null =>
|
|
100
|
+
typeof container === "string"
|
|
101
|
+
? document.querySelector(container)
|
|
102
|
+
: container
|
|
103
|
+
? container.current
|
|
104
|
+
: document
|
|
105
|
+
|
|
106
|
+
/** The top and bottom of what `root` shows, in viewport coordinates. */
|
|
107
|
+
const viewportOf = (root: HTMLElement | null) => {
|
|
108
|
+
if (!root) return { top: 0, bottom: window.innerHeight }
|
|
109
|
+
const top = root.getBoundingClientRect().top + root.clientTop
|
|
110
|
+
return { top, bottom: top + root.clientHeight }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Whether `root` (or the page) is scrolled to its very end, and can scroll at all. */
|
|
114
|
+
const scrolledToEnd = (root: HTMLElement | null) => {
|
|
115
|
+
const el = root ?? document.scrollingElement ?? document.documentElement
|
|
116
|
+
return el.scrollTop > 0 && Math.ceil(el.scrollTop + el.clientHeight) >= el.scrollHeight
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** The index of the last value passing `test`, `-1` for none (`findLastIndex` is ES2023, past the kit's target). */
|
|
120
|
+
const lastIndex = (values: readonly number[], test: (value: number) => boolean) =>
|
|
121
|
+
values.reduce((found, value, i) => (test(value) ? i : found), -1)
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The sections in view, as `[first, last]` indices: from the section the
|
|
125
|
+
* line sits in (the last heading at or above it, else the first) to the
|
|
126
|
+
* last heading above `bottom`. `[-1, -1]` with no headings.
|
|
127
|
+
*/
|
|
128
|
+
export function pickVisibleRange(
|
|
129
|
+
tops: readonly number[],
|
|
130
|
+
{ line, bottom }: { line: number; bottom: number },
|
|
131
|
+
): [number, number] {
|
|
132
|
+
if (tops.length === 0) return [-1, -1]
|
|
133
|
+
const first = Math.max(
|
|
134
|
+
lastIndex(tops, (top) => top <= line),
|
|
135
|
+
0,
|
|
136
|
+
)
|
|
137
|
+
return [
|
|
138
|
+
first,
|
|
139
|
+
Math.max(
|
|
140
|
+
lastIndex(tops, (top) => top < bottom),
|
|
141
|
+
first,
|
|
142
|
+
),
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Picks the heading being read from each heading's top edge (viewport
|
|
148
|
+
* coordinates): the last one that has reached `line`, or the first one
|
|
149
|
+
* before any has. At the end of the scroll the last headings can never
|
|
150
|
+
* reach the line, so there the last one still in view (`top < bottom`) wins
|
|
151
|
+
* instead. `-1` only with no headings.
|
|
152
|
+
*/
|
|
153
|
+
export function pickActiveHeading(
|
|
154
|
+
tops: readonly number[],
|
|
155
|
+
{ line, bottom, end }: { line: number; bottom: number; end: boolean },
|
|
156
|
+
): number {
|
|
157
|
+
if (tops.length === 0) return -1
|
|
158
|
+
const reached = lastIndex(tops, (top) => top <= line)
|
|
159
|
+
if (!end) return Math.max(reached, 0)
|
|
160
|
+
return Math.max(
|
|
161
|
+
lastIndex(tops, (top) => top < bottom),
|
|
162
|
+
reached,
|
|
163
|
+
0,
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* How long the scroll must be quiet before a `scrollTo` hands `active` back
|
|
169
|
+
* to the reader's position. Debounced on `scroll` events rather than waiting
|
|
170
|
+
* for `scrollend`, which Safari lacks.
|
|
171
|
+
*/
|
|
172
|
+
const SETTLE_MS = 150
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Scroll-spy: collects the headings on a page (or takes the ones you pass)
|
|
176
|
+
* and tracks which one is being read (`active`) and which sections are in
|
|
177
|
+
* view (`visible`), for a table of contents.
|
|
178
|
+
*
|
|
179
|
+
* A heading is active once its top has scrolled up to `offset` (the height
|
|
180
|
+
* of a sticky header), and stays active until the next one gets there. At
|
|
181
|
+
* the bottom of the page, where the last sections are too short to reach
|
|
182
|
+
* the line, the last heading in view wins, so the last entry can light up.
|
|
183
|
+
*
|
|
184
|
+
* `scrollTo` scrolls by the distance between the heading and that line
|
|
185
|
+
* (`scrollBy`), never to an absolute position, so it works in any scroller
|
|
186
|
+
* and any writing direction. While the scroll it started is running, the
|
|
187
|
+
* clicked heading stays active instead of every heading it passes.
|
|
188
|
+
*
|
|
189
|
+
* Headings are read on mount. Call `reinitialize` when the content changes.
|
|
190
|
+
* A collected heading without an `id` is skipped (it couldn't be linked to),
|
|
191
|
+
* with a warning in development.
|
|
192
|
+
*
|
|
193
|
+
* const spy = useScrollSpy({ container: "#article", selector: "h2, h3", offset: 64 })
|
|
194
|
+
* spy.data.map((h) => (
|
|
195
|
+
* <a key={h.id} href={`#${h.id}`} aria-current={h.id === spy.active ? "location" : undefined}>
|
|
196
|
+
* {h.label}
|
|
197
|
+
* </a>
|
|
198
|
+
* ))
|
|
199
|
+
*/
|
|
200
|
+
export function useScrollSpy({
|
|
201
|
+
container,
|
|
202
|
+
selector = DEFAULT_SCROLL_SPY_SELECTOR,
|
|
203
|
+
data: entries,
|
|
204
|
+
getDepth = defaultDepth,
|
|
205
|
+
getLabel = defaultLabel,
|
|
206
|
+
root,
|
|
207
|
+
offset = 0,
|
|
208
|
+
}: UseScrollSpyOptions = {}): UseScrollSpyReturnValue {
|
|
209
|
+
const fromEntries = (nodes?: (HTMLElement | null)[]): ScrollSpyHeading[] =>
|
|
210
|
+
(entries ?? []).map((entry, i) => {
|
|
211
|
+
const node = nodes?.[i] ?? null
|
|
212
|
+
return {
|
|
213
|
+
id: entry.id,
|
|
214
|
+
label: entry.label ?? (node ? getLabel(node) : ""),
|
|
215
|
+
depth: entry.depth ?? (node ? getDepth(node) : 1),
|
|
216
|
+
node,
|
|
217
|
+
}
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
const [data, setData] = useState<ScrollSpyHeading[]>(() => fromEntries())
|
|
221
|
+
const [active, setActive] = useState<string | null>(null)
|
|
222
|
+
const [visible, setVisible] = useState<string[]>([])
|
|
223
|
+
const [initialized, setInitialized] = useState(false)
|
|
224
|
+
const [generation, setGeneration] = useState(0)
|
|
225
|
+
const reinitialize = useCallback(() => setGeneration((n) => n + 1), [])
|
|
226
|
+
|
|
227
|
+
// The id a `scrollTo` pinned, while its scroll runs.
|
|
228
|
+
const pinned = useRef<string | null>(null)
|
|
229
|
+
const settle = useRef<ReturnType<typeof setTimeout>>(undefined)
|
|
230
|
+
|
|
231
|
+
// Latest values for the listeners, so they don't re-subscribe each render.
|
|
232
|
+
const latest = useRef({ data, offset, root, getDepth, getLabel })
|
|
233
|
+
latest.current = { data, offset, root, getDepth, getLabel }
|
|
234
|
+
|
|
235
|
+
// A stable key for `data`, so an inline array doesn't re-collect every render.
|
|
236
|
+
const entriesKey = entries
|
|
237
|
+
?.map((e) => `${e.id}\u0000${e.depth ?? ""}\u0000${e.label ?? ""}`)
|
|
238
|
+
.join("\u0001")
|
|
239
|
+
|
|
240
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: `entriesKey` stands in for `entries`; `generation` re-runs on demand.
|
|
241
|
+
useEffect(() => {
|
|
242
|
+
if (entries) {
|
|
243
|
+
setData(fromEntries(entries.map((e) => document.getElementById(e.id))))
|
|
244
|
+
} else {
|
|
245
|
+
const scope = resolveContainer(container)
|
|
246
|
+
const nodes = scope ? [...scope.querySelectorAll<HTMLElement>(selector)] : []
|
|
247
|
+
const unnamed = nodes.filter((n) => !n.id)
|
|
248
|
+
if (unnamed.length > 0) {
|
|
249
|
+
devWarnOnce(
|
|
250
|
+
`useScrollSpy: skipped ${unnamed.length} heading(s) without an id, which a link can't reach. Give each heading an id (rehype-slug does it for MDX).`,
|
|
251
|
+
)
|
|
252
|
+
}
|
|
253
|
+
setData(
|
|
254
|
+
nodes
|
|
255
|
+
.filter((n) => n.id)
|
|
256
|
+
.map((node) => ({ id: node.id, label: getLabel(node), depth: getDepth(node), node })),
|
|
257
|
+
)
|
|
258
|
+
}
|
|
259
|
+
setInitialized(true)
|
|
260
|
+
}, [entriesKey, container, selector, generation])
|
|
261
|
+
|
|
262
|
+
const measure = useCallback(() => {
|
|
263
|
+
const { data: headings, offset: line, root: rootRef } = latest.current
|
|
264
|
+
const scroller = rootRef?.current ?? null
|
|
265
|
+
const view = viewportOf(scroller)
|
|
266
|
+
const present = headings.filter((h) => h.node)
|
|
267
|
+
const tops = present.map((h) => (h.node as HTMLElement).getBoundingClientRect().top)
|
|
268
|
+
const at = {
|
|
269
|
+
// One pixel of slack: `scrollTo` lands the heading on the line, and
|
|
270
|
+
// sub-pixel layout can leave it a fraction below.
|
|
271
|
+
line: view.top + line + 1,
|
|
272
|
+
bottom: view.bottom,
|
|
273
|
+
end: scrolledToEnd(scroller),
|
|
274
|
+
}
|
|
275
|
+
const [first, last] = pickVisibleRange(tops, at)
|
|
276
|
+
const ids = present.slice(first, last + 1).map((h) => h.id)
|
|
277
|
+
// A new array only when the range changed, so consumers don't re-render per frame.
|
|
278
|
+
setVisible((prev) => (prev.join("\u0000") === ids.join("\u0000") ? prev : ids))
|
|
279
|
+
// The range follows a `scrollTo`'s scroll; `active` stays on its target.
|
|
280
|
+
if (pinned.current) return
|
|
281
|
+
setActive(present[pickActiveHeading(tops, at)]?.id ?? null)
|
|
282
|
+
}, [])
|
|
283
|
+
|
|
284
|
+
useEffect(() => {
|
|
285
|
+
if (data.length === 0) {
|
|
286
|
+
setActive(null)
|
|
287
|
+
setVisible([])
|
|
288
|
+
return
|
|
289
|
+
}
|
|
290
|
+
const target: HTMLElement | Window = root?.current ?? window
|
|
291
|
+
let frame = 0
|
|
292
|
+
const onScroll = () => {
|
|
293
|
+
if (pinned.current) {
|
|
294
|
+
// Release the pin once the scroll `scrollTo` started goes quiet.
|
|
295
|
+
clearTimeout(settle.current)
|
|
296
|
+
settle.current = setTimeout(() => {
|
|
297
|
+
pinned.current = null
|
|
298
|
+
}, SETTLE_MS)
|
|
299
|
+
}
|
|
300
|
+
cancelAnimationFrame(frame)
|
|
301
|
+
frame = requestAnimationFrame(measure)
|
|
302
|
+
}
|
|
303
|
+
measure()
|
|
304
|
+
target.addEventListener("scroll", onScroll, { passive: true })
|
|
305
|
+
window.addEventListener("resize", onScroll, { passive: true })
|
|
306
|
+
return () => {
|
|
307
|
+
cancelAnimationFrame(frame)
|
|
308
|
+
target.removeEventListener("scroll", onScroll)
|
|
309
|
+
window.removeEventListener("resize", onScroll)
|
|
310
|
+
}
|
|
311
|
+
}, [data, root, measure])
|
|
312
|
+
|
|
313
|
+
useEffect(() => () => clearTimeout(settle.current), [])
|
|
314
|
+
|
|
315
|
+
const scrollTo = useCallback((id: string, options?: ScrollSpyScrollOptions) => {
|
|
316
|
+
const { data: headings, offset: line, root: rootRef } = latest.current
|
|
317
|
+
const node = headings.find((h) => h.id === id)?.node ?? document.getElementById(id)
|
|
318
|
+
if (!node) return false
|
|
319
|
+
const scroller = rootRef?.current ?? null
|
|
320
|
+
// By the distance to the line, not to an absolute `scrollTop`: the same
|
|
321
|
+
// code serves the window and any nested scroller, in either direction.
|
|
322
|
+
const delta = node.getBoundingClientRect().top - (viewportOf(scroller).top + line)
|
|
323
|
+
const behavior = options?.behavior ?? (prefersReducedMotion() ? "instant" : "smooth")
|
|
324
|
+
pinned.current = id
|
|
325
|
+
setActive(id)
|
|
326
|
+
// If nothing scrolls (already in place), no `scroll` event comes to release the pin.
|
|
327
|
+
clearTimeout(settle.current)
|
|
328
|
+
settle.current = setTimeout(() => {
|
|
329
|
+
pinned.current = null
|
|
330
|
+
}, SETTLE_MS * 2)
|
|
331
|
+
;(scroller ?? window).scrollBy({ top: delta, behavior })
|
|
332
|
+
return true
|
|
333
|
+
}, [])
|
|
334
|
+
|
|
335
|
+
return { active, visible, data, initialized, reinitialize, scrollTo }
|
|
336
|
+
}
|
package/src/theme.css
CHANGED
|
@@ -1298,6 +1298,8 @@ body {
|
|
|
1298
1298
|
--overlay-z popover, menu, hover-card, select, combobox, date-picker
|
|
1299
1299
|
--toast-z the notifier region
|
|
1300
1300
|
--modal-z modal + drawer + lightbox (backdrop and positioner)
|
|
1301
|
+
--tour-z tour (backdrop, spotlight, card); a floating panel
|
|
1302
|
+
opened while a tour runs is raised into this band
|
|
1301
1303
|
--toast-raised-z the notifier region, while it holds a toast created
|
|
1302
1304
|
with a modal open (feedback on what was done in it)
|
|
1303
1305
|
--tooltip-z tooltip
|
|
@@ -1346,8 +1348,9 @@ body {
|
|
|
1346
1348
|
--overlay-z: 50;
|
|
1347
1349
|
--toast-z: 100;
|
|
1348
1350
|
--modal-z: 150;
|
|
1349
|
-
--
|
|
1350
|
-
--
|
|
1351
|
+
--tour-z: 200;
|
|
1352
|
+
--toast-raised-z: 250;
|
|
1353
|
+
--tooltip-z: 300;
|
|
1351
1354
|
}
|
|
1352
1355
|
|
|
1353
1356
|
[data-scope="popover"][data-part="content"],
|
|
@@ -1359,10 +1362,43 @@ body {
|
|
|
1359
1362
|
z-index: calc(var(--overlay-z, 50) + var(--layer-index, 0));
|
|
1360
1363
|
}
|
|
1361
1364
|
|
|
1365
|
+
/* A tour sits above modals: a step may highlight something inside one. zag
|
|
1366
|
+
tags its three layers with `--tour-layer` (0 backdrop, 1 spotlight, 2 the
|
|
1367
|
+
card's positioner) and expects `--tour-z-index` as their base, which it
|
|
1368
|
+
never defines. All three take theirs here, the positioner included: zag's
|
|
1369
|
+
`syncZIndex` hoists the content's z-index onto the positioner only once,
|
|
1370
|
+
when the tour opens, and the card's positioner is a new element on later
|
|
1371
|
+
steps, so it was left at `auto` and its isolated card painted under the
|
|
1372
|
+
backdrop. */
|
|
1373
|
+
[data-scope="tour"] {
|
|
1374
|
+
--tour-z-index: var(--tour-z, 200);
|
|
1375
|
+
}
|
|
1376
|
+
[data-scope="tour"][data-part="backdrop"],
|
|
1377
|
+
[data-scope="tour"][data-part="spotlight"],
|
|
1378
|
+
[data-scope="tour"][data-part="positioner"] {
|
|
1379
|
+
z-index: calc(var(--tour-z, 200) + var(--tour-layer, 0));
|
|
1380
|
+
}
|
|
1381
|
+
[data-scope="tour"][data-part="content"] {
|
|
1382
|
+
z-index: calc(var(--tour-z, 200) + 2);
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
/* A floating panel opened while a tour runs (a Select or Menu on the
|
|
1386
|
+
highlighted element) would paint under the tour's backdrop. Such a panel
|
|
1387
|
+
carries `data-raised` (`useTourRaised` in `lib/overlay-layer.tsx`) and is
|
|
1388
|
+
lifted into the tour band, above the card's three layers. */
|
|
1389
|
+
[data-scope="popover"][data-part="content"][data-raised],
|
|
1390
|
+
[data-scope="menu"][data-part="content"][data-raised],
|
|
1391
|
+
[data-scope="hover-card"][data-part="content"][data-raised],
|
|
1392
|
+
[data-scope="select"][data-part="content"][data-raised],
|
|
1393
|
+
[data-scope="combobox"][data-part="content"][data-raised],
|
|
1394
|
+
[data-scope="date-picker"][data-part="content"][data-raised] {
|
|
1395
|
+
z-index: calc(var(--tour-z, 200) + 10 + var(--layer-index, 0));
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1362
1398
|
/* A tooltip can show up over anything hoverable, an open picker included. It
|
|
1363
1399
|
isn't a dismissable layer, so there's no `--layer-index` to add. */
|
|
1364
1400
|
[data-scope="tooltip"][data-part="content"] {
|
|
1365
|
-
z-index: var(--tooltip-z,
|
|
1401
|
+
z-index: var(--tooltip-z, 300);
|
|
1366
1402
|
}
|
|
1367
1403
|
|
|
1368
1404
|
/* ==========================================
|
package/src/theme.test.ts
CHANGED
|
@@ -150,7 +150,14 @@ describe("theme.css overlay stacking", () => {
|
|
|
150
150
|
const rootBlock = themeCss.match(/:root \{[\s\S]*?\n\}/g)?.join("\n") ?? ""
|
|
151
151
|
|
|
152
152
|
/** The scale, bottom to top. */
|
|
153
|
-
const BANDS = [
|
|
153
|
+
const BANDS = [
|
|
154
|
+
"--overlay-z",
|
|
155
|
+
"--toast-z",
|
|
156
|
+
"--modal-z",
|
|
157
|
+
"--tour-z",
|
|
158
|
+
"--toast-raised-z",
|
|
159
|
+
"--tooltip-z",
|
|
160
|
+
]
|
|
154
161
|
|
|
155
162
|
it.each(BANDS)("declares %s on :root so consumers can retune the band", (token) => {
|
|
156
163
|
expect(rootBlock).toMatch(new RegExp(`${token}:\\s*\\d+;`))
|
|
@@ -167,6 +174,7 @@ describe("theme.css overlay stacking", () => {
|
|
|
167
174
|
"combobox",
|
|
168
175
|
"date-picker",
|
|
169
176
|
"tooltip",
|
|
177
|
+
"tour",
|
|
170
178
|
]
|
|
171
179
|
|
|
172
180
|
it.each(BANDED_SCOPES)("gives %s's content part a z-index", (scope) => {
|
|
@@ -179,6 +187,26 @@ describe("theme.css overlay stacking", () => {
|
|
|
179
187
|
)
|
|
180
188
|
})
|
|
181
189
|
|
|
190
|
+
/** zag's tour layers add `--tour-layer` (0 backdrop, 1 spotlight, 2 card) to a
|
|
191
|
+
* base it never defines; the kit points it at the tour band. */
|
|
192
|
+
/** The card's positioner included: zag hoists the content's z-index onto it
|
|
193
|
+
* only when the tour opens, and later steps mount a new positioner, which
|
|
194
|
+
* was left at `auto` and painted the card under the backdrop. */
|
|
195
|
+
it("gives every tour layer the tour band, the card's positioner included", () => {
|
|
196
|
+
expect(themeCss).toMatch(/--tour-z-index:\s*var\(--tour-z,\s*200\)/)
|
|
197
|
+
expect(themeCss).toMatch(
|
|
198
|
+
/\[data-scope="tour"\]\[data-part="spotlight"\],\s*\[data-scope="tour"\]\[data-part="positioner"\]\s*\{\s*z-index:\s*calc\(var\(--tour-z,\s*200\)\s*\+\s*var\(--tour-layer,\s*0\)\)/,
|
|
199
|
+
)
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
/** A panel opened while a tour runs is lifted above the tour's card. */
|
|
203
|
+
it.each(BANDED_SCOPES.filter((scope) => scope !== "tooltip" && scope !== "tour"))(
|
|
204
|
+
"raises %s into the tour band while a tour runs",
|
|
205
|
+
(scope) => {
|
|
206
|
+
expect(themeCss).toContain(`[data-scope="${scope}"][data-part="content"][data-raised]`)
|
|
207
|
+
},
|
|
208
|
+
)
|
|
209
|
+
|
|
182
210
|
/**
|
|
183
211
|
* The bug this whole scale replaces: `data-scope` and `data-part` are emitted
|
|
184
212
|
* on the *same* element by zag's `createAnatomy`, so a descendant combinator
|