@42-central/ui-react 0.29.1 → 0.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-X6DESK37.js → chunk-2RRTT4AF.js} +17 -5
- package/dist/chunk-2RRTT4AF.js.map +1 -0
- package/dist/{chunk-TUP7WXQE.js → chunk-322I2RSV.js} +9 -6
- package/dist/chunk-322I2RSV.js.map +1 -0
- package/dist/{chunk-ISX3AM32.js → chunk-37SRSNLJ.js} +4 -4
- package/dist/{chunk-ISX3AM32.js.map → chunk-37SRSNLJ.js.map} +1 -1
- package/dist/{chunk-L5GH7LLD.js → chunk-3MFWUG5O.js} +4 -4
- package/dist/{chunk-L5GH7LLD.js.map → chunk-3MFWUG5O.js.map} +1 -1
- package/dist/{chunk-FQJNQW3G.js → chunk-3XQEOJCE.js} +8 -5
- package/dist/chunk-3XQEOJCE.js.map +1 -0
- package/dist/{chunk-JKFPRQB2.js → chunk-4LSZ5JWF.js} +3 -3
- package/dist/{chunk-JKFPRQB2.js.map → chunk-4LSZ5JWF.js.map} +1 -1
- package/dist/{chunk-V2QZG4IT.js → chunk-5HWFYYHW.js} +27 -9
- package/dist/chunk-5HWFYYHW.js.map +1 -0
- package/dist/{chunk-GEZYGBXY.js → chunk-6MVFCS46.js} +99 -42
- package/dist/chunk-6MVFCS46.js.map +1 -0
- package/dist/{chunk-NNPSBC7O.js → chunk-6WZSUS3U.js} +10 -9
- package/dist/chunk-6WZSUS3U.js.map +1 -0
- package/dist/chunk-6YRGP6PS.js +138 -0
- package/dist/chunk-6YRGP6PS.js.map +1 -0
- package/dist/{chunk-B5YHYI7E.js → chunk-ALANKV5Y.js} +23 -6
- package/dist/chunk-ALANKV5Y.js.map +1 -0
- package/dist/{chunk-IA6DCC3N.js → chunk-AUQPNDE5.js} +23 -13
- package/dist/chunk-AUQPNDE5.js.map +1 -0
- package/dist/{chunk-AKXALCUN.js → chunk-D7SW2E24.js} +4 -4
- package/dist/chunk-D7SW2E24.js.map +1 -0
- package/dist/{chunk-OXR7BXZA.js → chunk-DQIYYDFD.js} +4 -3
- package/dist/chunk-DQIYYDFD.js.map +1 -0
- package/dist/{chunk-HMNXNKDA.js → chunk-FCBYUN6F.js} +4 -4
- package/dist/{chunk-HMNXNKDA.js.map → chunk-FCBYUN6F.js.map} +1 -1
- package/dist/{chunk-2W7H43WL.js → chunk-FED6SJWM.js} +23 -14
- package/dist/chunk-FED6SJWM.js.map +1 -0
- package/dist/{chunk-7E7JNWOC.js → chunk-FEPIHXVI.js} +6 -5
- package/dist/chunk-FEPIHXVI.js.map +1 -0
- package/dist/{chunk-Y57NW6G7.js → chunk-G3YOSG3U.js} +4 -4
- package/dist/{chunk-Y57NW6G7.js.map → chunk-G3YOSG3U.js.map} +1 -1
- package/dist/chunk-GZN5CXMR.js +100 -0
- package/dist/chunk-GZN5CXMR.js.map +1 -0
- package/dist/{chunk-HCHGERDB.js → chunk-HCSZPBWV.js} +17 -115
- package/dist/chunk-HCSZPBWV.js.map +1 -0
- package/dist/{chunk-I4B3N3UX.js → chunk-HTVICHT4.js} +12 -7
- package/dist/chunk-HTVICHT4.js.map +1 -0
- package/dist/chunk-I7TC2C3I.js +163 -0
- package/dist/chunk-I7TC2C3I.js.map +1 -0
- package/dist/{chunk-7FPSQBWB.js → chunk-IBXYLO2J.js} +14 -13
- package/dist/chunk-IBXYLO2J.js.map +1 -0
- package/dist/{chunk-7KFUFAVP.js → chunk-IRYG6B5A.js} +9 -8
- package/dist/chunk-IRYG6B5A.js.map +1 -0
- package/dist/{chunk-2RQLPN4U.js → chunk-JCNEW4WJ.js} +8 -8
- package/dist/{chunk-2RQLPN4U.js.map → chunk-JCNEW4WJ.js.map} +1 -1
- package/dist/{chunk-SP6LCCTZ.js → chunk-KZDMVOL6.js} +35 -8
- package/dist/chunk-KZDMVOL6.js.map +1 -0
- package/dist/chunk-LR5U6TZZ.js +169 -0
- package/dist/chunk-LR5U6TZZ.js.map +1 -0
- package/dist/{chunk-MQHD3EJE.js → chunk-LZHZJWVM.js} +6 -4
- package/dist/chunk-LZHZJWVM.js.map +1 -0
- package/dist/{chunk-5EOMSWNO.js → chunk-MAM2X3MW.js} +5 -5
- package/dist/{chunk-5EOMSWNO.js.map → chunk-MAM2X3MW.js.map} +1 -1
- package/dist/{chunk-FSPS7TVD.js → chunk-MCMS4NMO.js} +5 -5
- package/dist/{chunk-FSPS7TVD.js.map → chunk-MCMS4NMO.js.map} +1 -1
- package/dist/{chunk-ZB5VMGKB.js → chunk-MV5DIE2T.js} +15 -4
- package/dist/chunk-MV5DIE2T.js.map +1 -0
- package/dist/chunk-NDI4HLQE.js +41 -0
- package/dist/chunk-NDI4HLQE.js.map +1 -0
- package/dist/{chunk-B4GNSSHU.js → chunk-NLJEQZQQ.js} +3 -3
- package/dist/{chunk-B4GNSSHU.js.map → chunk-NLJEQZQQ.js.map} +1 -1
- package/dist/{chunk-SBZJGFZ6.js → chunk-QHT4DCXE.js} +8 -7
- package/dist/chunk-QHT4DCXE.js.map +1 -0
- package/dist/{chunk-I4IJOLNA.js → chunk-RMUBCTEF.js} +5 -5
- package/dist/{chunk-I4IJOLNA.js.map → chunk-RMUBCTEF.js.map} +1 -1
- package/dist/{chunk-G3AD3NJG.js → chunk-RNTDM3RP.js} +9 -5
- package/dist/chunk-RNTDM3RP.js.map +1 -0
- package/dist/chunk-RPFN6ETQ.js +509 -0
- package/dist/chunk-RPFN6ETQ.js.map +1 -0
- package/dist/{chunk-HWBFRDX7.js → chunk-SI7C3W5M.js} +28 -9
- package/dist/chunk-SI7C3W5M.js.map +1 -0
- package/dist/chunk-TPOV3OCC.js +234 -0
- package/dist/chunk-TPOV3OCC.js.map +1 -0
- package/dist/{chunk-IANYMDKH.js → chunk-UBQ54W46.js} +4 -4
- package/dist/chunk-UBQ54W46.js.map +1 -0
- package/dist/{chunk-QVOBLRCM.js → chunk-UIKQ4X6W.js} +3 -3
- package/dist/{chunk-QVOBLRCM.js.map → chunk-UIKQ4X6W.js.map} +1 -1
- package/dist/chunk-UOWQH53N.js +70 -0
- package/dist/chunk-UOWQH53N.js.map +1 -0
- package/dist/{chunk-QRNQQIQM.js → chunk-WJUY6YWF.js} +52 -20
- package/dist/chunk-WJUY6YWF.js.map +1 -0
- package/dist/{chunk-3KARNPW4.js → chunk-WKIUMLRT.js} +3 -3
- package/dist/{chunk-3KARNPW4.js.map → chunk-WKIUMLRT.js.map} +1 -1
- package/dist/chunk-X6RB74JN.js +37 -0
- package/dist/chunk-X6RB74JN.js.map +1 -0
- package/dist/chunk-XQ6L2CM5.js +83 -0
- package/dist/chunk-XQ6L2CM5.js.map +1 -0
- package/dist/{chunk-RKCUXOU2.js → chunk-YUVKROMA.js} +44 -7
- package/dist/chunk-YUVKROMA.js.map +1 -0
- package/dist/components/action-icon/action-icon.d.ts +9 -2
- package/dist/components/action-icon/action-icon.d.ts.map +1 -1
- package/dist/components/action-icon/index.js +5 -1
- package/dist/components/alert/index.js +4 -4
- package/dist/components/anchor/anchor.d.ts +45 -0
- package/dist/components/anchor/anchor.d.ts.map +1 -0
- package/dist/components/anchor/index.d.ts +2 -0
- package/dist/components/anchor/index.d.ts.map +1 -0
- package/dist/components/anchor/index.js +11 -0
- package/dist/components/anchor/index.js.map +1 -0
- package/dist/components/app-shell/app-shell.d.ts +10 -6
- package/dist/components/app-shell/app-shell.d.ts.map +1 -1
- package/dist/components/app-shell/index.js +23 -24
- package/dist/components/app-shell/index.js.map +1 -1
- package/dist/components/autocomplete/autocomplete.d.ts +1 -1
- package/dist/components/autocomplete/autocomplete.d.ts.map +1 -1
- package/dist/components/autocomplete/index.js +15 -9
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/avatar/index.js +1 -1
- package/dist/components/breadcrumb/breadcrumb.d.ts +5 -1
- package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -1
- package/dist/components/breadcrumb/index.js +12 -0
- package/dist/components/breadcrumb/index.js.map +1 -1
- package/dist/components/button/button.d.ts +15 -2
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/index.js +5 -1
- package/dist/components/button-multi-select/index.js +6 -4
- package/dist/components/button-multi-select/index.js.map +1 -1
- package/dist/components/button-select/button-select-control.d.ts.map +1 -1
- package/dist/components/button-select/button-select.d.ts +2 -2
- package/dist/components/button-select/button-select.d.ts.map +1 -1
- package/dist/components/button-select/index.js +6 -4
- package/dist/components/button-select/index.js.map +1 -1
- package/dist/components/calendar/aliases.d.ts +16 -0
- package/dist/components/calendar/aliases.d.ts.map +1 -0
- package/dist/components/calendar/calendar-body.d.ts +11 -1
- package/dist/components/calendar/calendar-body.d.ts.map +1 -1
- package/dist/components/calendar/calendar.d.ts +8 -4
- package/dist/components/calendar/calendar.d.ts.map +1 -1
- package/dist/components/calendar/index.d.ts +2 -1
- package/dist/components/calendar/index.d.ts.map +1 -1
- package/dist/components/calendar/index.js +15 -5
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/calendar-heatmap/calendar-heatmap.d.ts.map +1 -1
- package/dist/components/calendar-heatmap/index.js +85 -73
- package/dist/components/calendar-heatmap/index.js.map +1 -1
- package/dist/components/camera/index.js +16 -14
- package/dist/components/carousel/index.js +3 -3
- package/dist/components/checkbox/checkbox.d.ts.map +1 -1
- package/dist/components/checkbox/index.js +2 -2
- package/dist/components/choice-card-group/index.js +2 -2
- package/dist/components/choice-card-group/index.js.map +1 -1
- package/dist/components/circular-progress/circular-progress.d.ts +22 -11
- package/dist/components/circular-progress/circular-progress.d.ts.map +1 -1
- package/dist/components/circular-progress/index.d.ts +1 -1
- package/dist/components/circular-progress/index.d.ts.map +1 -1
- package/dist/components/circular-progress/index.js +68 -49
- package/dist/components/circular-progress/index.js.map +1 -1
- package/dist/components/clipboard/index.js +7 -3
- package/dist/components/clipboard/index.js.map +1 -1
- package/dist/components/code/code.d.ts +10 -0
- package/dist/components/code/code.d.ts.map +1 -1
- package/dist/components/code/index.js +1 -0
- package/dist/components/code/index.js.map +1 -1
- package/dist/components/code-block/chrome.js +10 -6
- package/dist/components/code-block/index.js +10 -7
- package/dist/components/code-block/index.js.map +1 -1
- package/dist/components/combobox/combobox.d.ts +5 -3
- package/dist/components/combobox/combobox.d.ts.map +1 -1
- package/dist/components/combobox/index.js +12 -7
- package/dist/components/combobox-list/combobox-list.d.ts +1 -1
- package/dist/components/combobox-list/combobox-list.d.ts.map +1 -1
- package/dist/components/combobox-list/index.js +14 -9
- package/dist/components/compare/index.js +1 -1
- package/dist/components/data-list/data-list.d.ts +96 -0
- package/dist/components/data-list/data-list.d.ts.map +1 -0
- package/dist/components/data-list/index.d.ts +2 -0
- package/dist/components/data-list/index.d.ts.map +1 -0
- package/dist/components/data-list/index.js +147 -0
- package/dist/components/data-list/index.js.map +1 -0
- package/dist/components/data-table/data-table-group.d.ts.map +1 -1
- package/dist/components/data-table/data-table-placeholder.d.ts +12 -1
- package/dist/components/data-table/data-table-placeholder.d.ts.map +1 -1
- package/dist/components/data-table/data-table-stack.d.ts.map +1 -1
- package/dist/components/data-table/data-table.d.ts +5 -2
- package/dist/components/data-table/data-table.d.ts.map +1 -1
- package/dist/components/data-table/index.js +163 -168
- package/dist/components/data-table/index.js.map +1 -1
- package/dist/components/date-picker/aliases.d.ts +16 -0
- package/dist/components/date-picker/aliases.d.ts.map +1 -1
- package/dist/components/date-picker/date-picker.d.ts +22 -8
- package/dist/components/date-picker/date-picker.d.ts.map +1 -1
- package/dist/components/date-picker/index.d.ts +2 -2
- package/dist/components/date-picker/index.d.ts.map +1 -1
- package/dist/components/date-picker/index.js +34 -28
- package/dist/components/date-picker/index.js.map +1 -1
- package/dist/components/download-button/index.js +6 -2
- package/dist/components/drawer/drawer.d.ts +7 -4
- package/dist/components/drawer/drawer.d.ts.map +1 -1
- package/dist/components/drawer/index.js +11 -6
- package/dist/components/empty-state/empty-state.d.ts +57 -0
- package/dist/components/empty-state/empty-state.d.ts.map +1 -0
- package/dist/components/empty-state/index.d.ts +2 -0
- package/dist/components/empty-state/index.d.ts.map +1 -0
- package/dist/components/empty-state/index.js +8 -0
- package/dist/components/empty-state/index.js.map +1 -0
- package/dist/components/field/field.d.ts +20 -0
- package/dist/components/field/field.d.ts.map +1 -1
- package/dist/components/field/index.js +1 -1
- package/dist/components/fieldset/fieldset.d.ts +103 -0
- package/dist/components/fieldset/fieldset.d.ts.map +1 -0
- package/dist/components/fieldset/index.d.ts +2 -0
- package/dist/components/fieldset/index.d.ts.map +1 -0
- package/dist/components/fieldset/index.js +150 -0
- package/dist/components/fieldset/index.js.map +1 -0
- package/dist/components/file-item/index.js +10 -7
- package/dist/components/file-preview/file-preview.d.ts.map +1 -1
- package/dist/components/file-preview/index.js +10 -18
- package/dist/components/file-preview/index.js.map +1 -1
- package/dist/components/file-trigger/index.js +6 -2
- package/dist/components/file-upload/file-upload.d.ts.map +1 -1
- package/dist/components/file-upload/index.js +18 -14
- package/dist/components/file-upload/index.js.map +1 -1
- package/dist/components/gallery/index.js +3 -3
- package/dist/components/geodesic/a11y.d.ts +3 -3
- package/dist/components/geodesic/a11y.d.ts.map +1 -1
- package/dist/components/hover-card/hover-card.d.ts.map +1 -1
- package/dist/components/hover-card/index.js +10 -3
- package/dist/components/hover-card/index.js.map +1 -1
- package/dist/components/image/index.js +3 -3
- package/dist/components/image-cropper/index.js +9 -6
- package/dist/components/input/index.js +2 -2
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/kbd/index.js +3 -3
- package/dist/components/kbd/kbd.d.ts +4 -0
- package/dist/components/kbd/kbd.d.ts.map +1 -1
- package/dist/components/lightbox/index.js +13 -11
- package/dist/components/lightbox/index.js.map +1 -1
- package/dist/components/menu/index.js +9 -5
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/menu/menu.d.ts.map +1 -1
- package/dist/components/modal/index.js +11 -6
- package/dist/components/modal/modal.d.ts +10 -4
- package/dist/components/modal/modal.d.ts.map +1 -1
- package/dist/components/multi-combobox-list/index.js +13 -9
- package/dist/components/multi-combobox-list/multi-combobox-list.d.ts +1 -1
- package/dist/components/multi-combobox-list/multi-combobox-list.d.ts.map +1 -1
- package/dist/components/multi-select/index.js +13 -10
- package/dist/components/multi-select/index.js.map +1 -1
- package/dist/components/multi-select/multi-select.d.ts +1 -1
- package/dist/components/multi-select/multi-select.d.ts.map +1 -1
- package/dist/components/nav-link/index.js +4 -4
- package/dist/components/nav-link/tanstack.js +4 -4
- package/dist/components/notification/index.js +6 -6
- package/dist/components/notification/index.js.map +1 -1
- package/dist/components/number-input/index.js +11 -7
- package/dist/components/number-input/number-input.d.ts +1 -1
- package/dist/components/number-input/number-input.d.ts.map +1 -1
- package/dist/components/overlays/dialog-parts.d.ts +10 -1
- package/dist/components/overlays/dialog-parts.d.ts.map +1 -1
- package/dist/components/overlays/index.js +13 -8
- package/dist/components/overlays/index.js.map +1 -1
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/index.d.ts.map +1 -0
- package/dist/components/pagination/index.js +362 -0
- package/dist/components/pagination/index.js.map +1 -0
- package/dist/components/pagination/pagination.d.ts +147 -0
- package/dist/components/pagination/pagination.d.ts.map +1 -0
- package/dist/components/password-input/index.js +6 -5
- package/dist/components/password-input/index.js.map +1 -1
- package/dist/components/password-input/password-input.d.ts +1 -1
- package/dist/components/password-input/password-input.d.ts.map +1 -1
- package/dist/components/phone-input/index.js +14 -11
- package/dist/components/phone-input/index.js.map +1 -1
- package/dist/components/phone-input/phone-input.d.ts +1 -1
- package/dist/components/phone-input/phone-input.d.ts.map +1 -1
- package/dist/components/photo-capture/index.js +19 -17
- package/dist/components/photo-capture/index.js.map +1 -1
- package/dist/components/pills-input/index.js +4 -4
- package/dist/components/pills-input/pills-input.d.ts +1 -1
- package/dist/components/pills-input/pills-input.d.ts.map +1 -1
- package/dist/components/pin-input/index.js +6 -5
- package/dist/components/pin-input/index.js.map +1 -1
- package/dist/components/pin-input/pin-input.d.ts.map +1 -1
- package/dist/components/popover/index.js +7 -2
- package/dist/components/popover/popover.d.ts +41 -16
- package/dist/components/popover/popover.d.ts.map +1 -1
- package/dist/components/progress/index.d.ts +1 -1
- package/dist/components/progress/index.d.ts.map +1 -1
- package/dist/components/progress/index.js +4 -1
- package/dist/components/progress/progress.d.ts +22 -14
- package/dist/components/progress/progress.d.ts.map +1 -1
- package/dist/components/prose/index.d.ts +2 -0
- package/dist/components/prose/index.d.ts.map +1 -0
- package/dist/components/prose/index.js +17 -0
- package/dist/components/prose/index.js.map +1 -0
- package/dist/components/prose/prose.d.ts +49 -0
- package/dist/components/prose/prose.d.ts.map +1 -0
- package/dist/components/prose/styles.css +593 -0
- package/dist/components/radio-group/index.js +9 -3
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/radio-group/radio-group.d.ts.map +1 -1
- package/dist/components/rating/index.js +3 -2
- package/dist/components/rating/index.js.map +1 -1
- package/dist/components/rating/rating.d.ts.map +1 -1
- package/dist/components/schedule/index.js +10 -8
- package/dist/components/schedule/index.js.map +1 -1
- package/dist/components/scroll-area/index.d.ts +2 -0
- package/dist/components/scroll-area/index.d.ts.map +1 -0
- package/dist/components/scroll-area/index.js +10 -0
- package/dist/components/scroll-area/index.js.map +1 -0
- package/dist/components/scroll-area/scroll-area.d.ts +150 -0
- package/dist/components/scroll-area/scroll-area.d.ts.map +1 -0
- package/dist/components/segment-group/index.js +2 -2
- package/dist/components/segment-group/segment-group.d.ts.map +1 -1
- package/dist/components/select/index.js +12 -8
- package/dist/components/select/select.d.ts +1 -1
- package/dist/components/select/select.d.ts.map +1 -1
- package/dist/components/slider/index.js +2 -2
- package/dist/components/slider/slider.d.ts.map +1 -1
- package/dist/components/splitter/index.d.ts +2 -0
- package/dist/components/splitter/index.d.ts.map +1 -0
- package/dist/components/splitter/index.js +373 -0
- package/dist/components/splitter/index.js.map +1 -0
- package/dist/components/splitter/splitter.d.ts +159 -0
- package/dist/components/splitter/splitter.d.ts.map +1 -0
- package/dist/components/spotlight/index.js +23 -22
- package/dist/components/spotlight/index.js.map +1 -1
- package/dist/components/spotlight/spotlight.d.ts.map +1 -1
- package/dist/components/steps/index.d.ts +4 -0
- package/dist/components/steps/index.d.ts.map +1 -0
- package/dist/components/steps/index.js +478 -0
- package/dist/components/steps/index.js.map +1 -0
- package/dist/components/steps/steps-data.d.ts +78 -0
- package/dist/components/steps/steps-data.d.ts.map +1 -0
- package/dist/components/steps/steps.d.ts +183 -0
- package/dist/components/steps/steps.d.ts.map +1 -0
- package/dist/components/switch/index.js +4 -3
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/switch/switch.d.ts.map +1 -1
- package/dist/components/table-of-contents/index.d.ts +2 -0
- package/dist/components/table-of-contents/index.d.ts.map +1 -0
- package/dist/components/table-of-contents/index.js +471 -0
- package/dist/components/table-of-contents/index.js.map +1 -0
- package/dist/components/table-of-contents/table-of-contents.d.ts +173 -0
- package/dist/components/table-of-contents/table-of-contents.d.ts.map +1 -0
- package/dist/components/tags-input/index.js +12 -9
- package/dist/components/tags-input/index.js.map +1 -1
- package/dist/components/tags-input/tags-input.d.ts +1 -1
- package/dist/components/tags-input/tags-input.d.ts.map +1 -1
- package/dist/components/text-input/index.js +2 -2
- package/dist/components/textarea/index.js +8 -6
- package/dist/components/textarea/index.js.map +1 -1
- package/dist/components/textarea/textarea.d.ts.map +1 -1
- package/dist/components/time-input/index.js +11 -9
- package/dist/components/time-input/index.js.map +1 -1
- package/dist/components/tooltip/index.js +1 -1
- package/dist/components/tooltip/tooltip.d.ts +3 -8
- package/dist/components/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/tour/conditions.d.ts +83 -0
- package/dist/components/tour/conditions.d.ts.map +1 -0
- package/dist/components/tour/create-tours.d.ts +49 -0
- package/dist/components/tour/create-tours.d.ts.map +1 -0
- package/dist/components/tour/index.d.ts +6 -0
- package/dist/components/tour/index.d.ts.map +1 -0
- package/dist/components/tour/index.js +1449 -0
- package/dist/components/tour/index.js.map +1 -0
- package/dist/components/tour/runtime.d.ts +57 -0
- package/dist/components/tour/runtime.d.ts.map +1 -0
- package/dist/components/tour/storage.d.ts +14 -0
- package/dist/components/tour/storage.d.ts.map +1 -0
- package/dist/components/tour/store.d.ts +62 -0
- package/dist/components/tour/store.d.ts.map +1 -0
- package/dist/components/tour/tour.d.ts +77 -0
- package/dist/components/tour/tour.d.ts.map +1 -0
- package/dist/components/tour/types.d.ts +680 -0
- package/dist/components/tour/types.d.ts.map +1 -0
- package/dist/components/tree/index.d.ts +3 -0
- package/dist/components/tree/index.d.ts.map +1 -0
- package/dist/components/tree/index.js +457 -0
- package/dist/components/tree/index.js.map +1 -0
- package/dist/components/tree/tree-row.d.ts +72 -0
- package/dist/components/tree/tree-row.d.ts.map +1 -0
- package/dist/components/tree/tree.d.ts +193 -0
- package/dist/components/tree/tree.d.ts.map +1 -0
- package/dist/components/tree-multi-select/index.js +31 -54
- package/dist/components/tree-multi-select/index.js.map +1 -1
- package/dist/components/tree-multi-select/tree-multi-select.d.ts +16 -1
- package/dist/components/tree-multi-select/tree-multi-select.d.ts.map +1 -1
- package/dist/components/tree-select/index.js +30 -24
- package/dist/components/tree-select/index.js.map +1 -1
- package/dist/components/tree-select/tree-popover.d.ts +20 -31
- package/dist/components/tree-select/tree-popover.d.ts.map +1 -1
- package/dist/components/tree-select/tree-select.d.ts +1 -1
- package/dist/components/tree-select/tree-select.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/lib/date-predicates.d.ts +7 -5
- package/dist/lib/date-predicates.d.ts.map +1 -1
- package/dist/lib/date-value.d.ts +20 -0
- package/dist/lib/date-value.d.ts.map +1 -1
- package/dist/lib/floating-arrow.d.ts +53 -0
- package/dist/lib/floating-arrow.d.ts.map +1 -0
- package/dist/lib/focus-return.d.ts +53 -0
- package/dist/lib/focus-return.d.ts.map +1 -0
- package/dist/lib/meter.d.ts +104 -0
- package/dist/lib/meter.d.ts.map +1 -0
- package/dist/lib/overlay-layer.d.ts +26 -8
- package/dist/lib/overlay-layer.d.ts.map +1 -1
- package/dist/lib/pressed.d.ts +92 -0
- package/dist/lib/pressed.d.ts.map +1 -0
- package/dist/lib/tree-data.d.ts +18 -2
- package/dist/lib/tree-data.d.ts.map +1 -1
- package/dist/lib/use-pagination.d.ts +102 -0
- package/dist/lib/use-pagination.d.ts.map +1 -0
- package/dist/lib/use-scroll-spy.d.ts +126 -0
- package/dist/lib/use-scroll-spy.d.ts.map +1 -0
- package/dist/theme.css +39 -3
- package/package.json +1 -1
- package/src/as-child.contract.test.tsx +283 -1
- package/src/components/action-icon/action-icon.tsx +34 -4
- package/src/components/anchor/anchor.test.tsx +232 -0
- package/src/components/anchor/anchor.tsx +187 -0
- package/src/components/anchor/index.ts +12 -0
- package/src/components/app-shell/app-shell.test.tsx +15 -7
- package/src/components/app-shell/app-shell.tsx +27 -20
- package/src/components/autocomplete/autocomplete.tsx +11 -3
- package/src/components/breadcrumb/breadcrumb.test.tsx +24 -0
- package/src/components/breadcrumb/breadcrumb.tsx +20 -1
- package/src/components/button/button-pressed.test.tsx +202 -0
- package/src/components/button/button.tsx +48 -6
- package/src/components/button-select/button-select-control.tsx +2 -2
- package/src/components/button-select/button-select.tsx +22 -2
- package/src/components/calendar/aliases.tsx +28 -0
- package/src/components/calendar/calendar-body.tsx +310 -210
- package/src/components/calendar/calendar.tsx +43 -12
- package/src/components/calendar/index.ts +7 -1
- package/src/components/calendar/month-year-calendar.test.tsx +106 -0
- package/src/components/calendar-heatmap/calendar-heatmap.tsx +88 -73
- package/src/components/checkbox/checkbox.tsx +7 -2
- package/src/components/choice-card-group/choice-card-group.tsx +2 -2
- package/src/components/circular-progress/circular-progress.test.tsx +35 -0
- package/src/components/circular-progress/circular-progress.tsx +116 -59
- package/src/components/circular-progress/index.ts +1 -0
- package/src/components/code/code.test.tsx +16 -0
- package/src/components/code/code.tsx +11 -0
- package/src/components/combobox/combobox.tsx +63 -28
- package/src/components/combobox-list/combobox-list.tsx +11 -3
- package/src/components/data-list/data-list.test.tsx +149 -0
- package/src/components/data-list/data-list.tsx +268 -0
- package/src/components/data-list/index.ts +9 -0
- package/src/components/data-table/data-table-group.test.tsx +16 -0
- package/src/components/data-table/data-table-group.tsx +15 -2
- package/src/components/data-table/data-table-placeholder.tsx +28 -36
- package/src/components/data-table/data-table-stack.tsx +33 -39
- package/src/components/data-table/data-table.test.tsx +31 -0
- package/src/components/data-table/data-table.tsx +41 -42
- package/src/components/date-picker/aliases.tsx +28 -0
- package/src/components/date-picker/date-picker.test.tsx +29 -0
- package/src/components/date-picker/date-picker.tsx +164 -45
- package/src/components/date-picker/index.ts +5 -1
- package/src/components/date-picker/month-year-picker.test.tsx +362 -0
- package/src/components/drawer/drawer.test.tsx +41 -0
- package/src/components/drawer/drawer.tsx +7 -1
- package/src/components/empty-state/empty-state.test.tsx +109 -0
- package/src/components/empty-state/empty-state.tsx +180 -0
- package/src/components/empty-state/index.ts +9 -0
- package/src/components/field/field.tsx +35 -1
- package/src/components/fieldset/fieldset.test.tsx +352 -0
- package/src/components/fieldset/fieldset.tsx +268 -0
- package/src/components/fieldset/index.ts +11 -0
- package/src/components/file-preview/file-preview.test.tsx +2 -1
- package/src/components/file-preview/file-preview.tsx +7 -13
- package/src/components/file-upload/file-upload.tsx +14 -5
- package/src/components/hover-card/hover-card.tsx +5 -1
- package/src/components/input/input.tsx +12 -5
- package/src/components/kbd/kbd.test.tsx +13 -0
- package/src/components/kbd/kbd.tsx +6 -0
- package/src/components/menu/menu.tsx +6 -2
- package/src/components/modal/modal.test.tsx +41 -0
- package/src/components/modal/modal.tsx +17 -9
- package/src/components/multi-combobox-list/multi-combobox-list.tsx +11 -3
- package/src/components/multi-select/multi-select.tsx +11 -3
- package/src/components/notification/create-notifier.tsx +1 -1
- package/src/components/number-input/number-input.tsx +12 -3
- package/src/components/overlays/dialog-parts.tsx +42 -5
- package/src/components/pagination/index.ts +19 -0
- package/src/components/pagination/pagination.test.tsx +187 -0
- package/src/components/pagination/pagination.tsx +563 -0
- package/src/components/password-input/password-input.tsx +12 -3
- package/src/components/phone-input/phone-input.tsx +12 -3
- package/src/components/pills-input/pills-input.tsx +7 -2
- package/src/components/pin-input/pin-input.tsx +13 -4
- package/src/components/popover/popover.tsx +87 -17
- package/src/components/progress/index.ts +1 -0
- package/src/components/progress/progress.test.tsx +102 -0
- package/src/components/progress/progress.tsx +116 -62
- package/src/components/prose/index.ts +1 -0
- package/src/components/prose/prose.test.tsx +90 -0
- package/src/components/prose/prose.tsx +60 -0
- package/src/components/prose/styles.css +593 -0
- package/src/components/radio-group/radio-group.tsx +8 -3
- package/src/components/rating/rating.tsx +5 -2
- package/src/components/scroll-area/index.ts +18 -0
- package/src/components/scroll-area/scroll-area.test.tsx +184 -0
- package/src/components/scroll-area/scroll-area.tsx +448 -0
- package/src/components/segment-group/segment-group.tsx +2 -2
- package/src/components/select/select.tsx +37 -18
- package/src/components/slider/slider.tsx +2 -2
- package/src/components/splitter/index.ts +15 -0
- package/src/components/splitter/splitter.test.tsx +244 -0
- package/src/components/splitter/splitter.tsx +625 -0
- package/src/components/spotlight/spotlight.test.tsx +34 -26
- package/src/components/spotlight/spotlight.tsx +7 -9
- package/src/components/steps/index.ts +21 -0
- package/src/components/steps/steps-data.tsx +179 -0
- package/src/components/steps/steps.test.tsx +235 -0
- package/src/components/steps/steps.tsx +686 -0
- package/src/components/switch/switch.tsx +7 -2
- package/src/components/table-of-contents/index.ts +17 -0
- package/src/components/table-of-contents/table-of-contents.test.tsx +289 -0
- package/src/components/table-of-contents/table-of-contents.tsx +708 -0
- package/src/components/tags-input/tags-input.tsx +12 -3
- package/src/components/textarea/textarea.tsx +15 -5
- package/src/components/tooltip/tooltip.tsx +8 -17
- package/src/components/tour/conditions.test.ts +527 -0
- package/src/components/tour/conditions.ts +445 -0
- package/src/components/tour/create-tours.tsx +150 -0
- package/src/components/tour/index.ts +86 -0
- package/src/components/tour/runtime.ts +187 -0
- package/src/components/tour/storage.test.ts +68 -0
- package/src/components/tour/storage.ts +44 -0
- package/src/components/tour/store.test.tsx +784 -0
- package/src/components/tour/store.ts +661 -0
- package/src/components/tour/tour.test.tsx +318 -0
- package/src/components/tour/tour.tsx +773 -0
- package/src/components/tour/tour.types.test.ts +185 -0
- package/src/components/tour/types.ts +904 -0
- package/src/components/tree/index.ts +24 -0
- package/src/components/tree/tree-row.tsx +179 -0
- package/src/components/tree/tree.test.tsx +296 -0
- package/src/components/tree/tree.tsx +796 -0
- package/src/components/tree-multi-select/tree-multi-select.tsx +29 -58
- package/src/components/tree-select/tree-popover.tsx +26 -107
- package/src/components/tree-select/tree-select.tsx +24 -16
- package/src/icon-stroke.test.tsx +2 -0
- package/src/index.ts +16 -0
- package/src/lib/date-predicates.test.ts +46 -0
- package/src/lib/date-predicates.ts +44 -24
- package/src/lib/date-value.test.ts +24 -1
- package/src/lib/date-value.ts +42 -1
- package/src/lib/floating-arrow.tsx +73 -0
- package/src/lib/focus-return.test.tsx +143 -0
- package/src/lib/focus-return.ts +106 -0
- package/src/lib/meter.test.ts +40 -0
- package/src/lib/meter.ts +159 -0
- package/src/lib/overlay-layer.test.tsx +47 -1
- package/src/lib/overlay-layer.tsx +65 -8
- package/src/lib/pressed.ts +130 -0
- package/src/lib/tree-data.ts +42 -2
- package/src/lib/use-pagination.test.ts +105 -0
- package/src/lib/use-pagination.ts +179 -0
- package/src/lib/use-scroll-spy.test.tsx +238 -0
- package/src/lib/use-scroll-spy.ts +336 -0
- package/src/theme.css +39 -3
- package/src/theme.test.ts +29 -1
- package/src/visually-hidden-containment.test.tsx +9 -0
- package/dist/chunk-2W7H43WL.js.map +0 -1
- package/dist/chunk-7E7JNWOC.js.map +0 -1
- package/dist/chunk-7FPSQBWB.js.map +0 -1
- package/dist/chunk-7KFUFAVP.js.map +0 -1
- package/dist/chunk-AKXALCUN.js.map +0 -1
- package/dist/chunk-B5YHYI7E.js.map +0 -1
- package/dist/chunk-FQJNQW3G.js.map +0 -1
- package/dist/chunk-G3AD3NJG.js.map +0 -1
- package/dist/chunk-GEZYGBXY.js.map +0 -1
- package/dist/chunk-HCHGERDB.js.map +0 -1
- package/dist/chunk-HWBFRDX7.js.map +0 -1
- package/dist/chunk-I4B3N3UX.js.map +0 -1
- package/dist/chunk-IA6DCC3N.js.map +0 -1
- package/dist/chunk-IANYMDKH.js.map +0 -1
- package/dist/chunk-MQHD3EJE.js.map +0 -1
- package/dist/chunk-NNPSBC7O.js.map +0 -1
- package/dist/chunk-OXR7BXZA.js.map +0 -1
- package/dist/chunk-QKSLDQM2.js +0 -120
- package/dist/chunk-QKSLDQM2.js.map +0 -1
- package/dist/chunk-QRNQQIQM.js.map +0 -1
- package/dist/chunk-RKCUXOU2.js.map +0 -1
- package/dist/chunk-S5CQRCTF.js +0 -426
- package/dist/chunk-S5CQRCTF.js.map +0 -1
- package/dist/chunk-SBZJGFZ6.js.map +0 -1
- package/dist/chunk-SP6LCCTZ.js.map +0 -1
- package/dist/chunk-TUP7WXQE.js.map +0 -1
- package/dist/chunk-V2QZG4IT.js.map +0 -1
- package/dist/chunk-X6DESK37.js.map +0 -1
- package/dist/chunk-ZB5VMGKB.js.map +0 -1
|
@@ -0,0 +1,708 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { ark, type HTMLArkProps } from "@ark-ui/react"
|
|
4
|
+
import { cva } from "class-variance-authority"
|
|
5
|
+
import { TextAlignStart } from "lucide-react"
|
|
6
|
+
import {
|
|
7
|
+
type CSSProperties,
|
|
8
|
+
createContext,
|
|
9
|
+
type MouseEvent,
|
|
10
|
+
type ReactNode,
|
|
11
|
+
type Ref,
|
|
12
|
+
useContext,
|
|
13
|
+
useId,
|
|
14
|
+
useRef,
|
|
15
|
+
useState,
|
|
16
|
+
} from "react"
|
|
17
|
+
import { composeChildren, type NoAsChild } from "../../lib/as-child"
|
|
18
|
+
import { cn } from "../../lib/cn"
|
|
19
|
+
import type { Color } from "../../lib/colors"
|
|
20
|
+
import { type IconMap, iconStroke, mergeIcons } from "../../lib/icons"
|
|
21
|
+
import { useMergedRefs } from "../../lib/merge-refs"
|
|
22
|
+
import { props } from "../../lib/props"
|
|
23
|
+
import type { Size } from "../../lib/sizes"
|
|
24
|
+
import type { WithTestId } from "../../lib/test-id"
|
|
25
|
+
import { TEXT_COLOR_CLASSES, TYPOGRAPHY_SIZE_CLASSES } from "../../lib/typography-size"
|
|
26
|
+
import { useIsomorphicLayoutEffect } from "../../lib/use-isomorphic-layout-effect"
|
|
27
|
+
import {
|
|
28
|
+
type UseScrollSpyOptions,
|
|
29
|
+
type UseScrollSpyReturnValue,
|
|
30
|
+
useScrollSpy,
|
|
31
|
+
} from "../../lib/use-scroll-spy"
|
|
32
|
+
import { Anchor, type AnchorProps } from "../anchor/anchor"
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* TableOfContents — an on-page table of contents that highlights the
|
|
36
|
+
* sections being read.
|
|
37
|
+
*
|
|
38
|
+
* Built on `useScrollSpy`: it collects the headings inside `container`
|
|
39
|
+
* (those matching `selector`, `h2, h3` by default) or takes them from
|
|
40
|
+
* `data`, and indents each by its level. Each entry is an `Anchor` to the
|
|
41
|
+
* heading's `#id`; a click scrolls there (leaving `offset` px for a sticky
|
|
42
|
+
* header) and puts the hash in the URL. The entry being read is
|
|
43
|
+
* `aria-current="location"`.
|
|
44
|
+
*
|
|
45
|
+
* Variants:
|
|
46
|
+
* - `track` (default): a hairline that follows the nesting, bending in and
|
|
47
|
+
* out with an S-curve at each level change. The sections in view are the
|
|
48
|
+
* same path drawn in the accent, ending in a dot, and their labels light
|
|
49
|
+
* up. The path is measured from the links, so wrapped labels and inline
|
|
50
|
+
* code stay lined up.
|
|
51
|
+
* - `light` / `filled`: a tinted or solid pill behind the entry being read.
|
|
52
|
+
*
|
|
53
|
+
* The highlight jumps instead of sliding under `prefers-reduced-motion`.
|
|
54
|
+
*
|
|
55
|
+
* Ark ships a `toc` machine, but it has no sticky-header offset and only
|
|
56
|
+
* takes over link clicks inside a custom scroller, so this is built on the
|
|
57
|
+
* kit's own hook instead.
|
|
58
|
+
*
|
|
59
|
+
* <TableOfContents container="#article" offset={64} />
|
|
60
|
+
* <TableOfContents data={[{ value: "install", label: "Install" }, …]} />
|
|
61
|
+
*
|
|
62
|
+
* For your own markup, call `useScrollSpy` and pass its result to
|
|
63
|
+
* `TableOfContents.Root` as `spy`.
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
export type TableOfContentsVariant = "track" | "light" | "filled"
|
|
67
|
+
|
|
68
|
+
/** The nav's built-in strings. */
|
|
69
|
+
export type TableOfContentsTranslations = {
|
|
70
|
+
/** The nav's name, and the title's text. Default `"On this page"`. */
|
|
71
|
+
label?: string
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const TABLE_OF_CONTENTS_DEFAULT_TRANSLATIONS: Required<TableOfContentsTranslations> = {
|
|
75
|
+
label: "On this page",
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type TableOfContentsIconSlot = "title"
|
|
79
|
+
export type TableOfContentsIcons = IconMap<TableOfContentsIconSlot>
|
|
80
|
+
|
|
81
|
+
/** The default icons: `title`, before the title's text. */
|
|
82
|
+
export const DEFAULT_ICONS: Record<TableOfContentsIconSlot, ReactNode> = {
|
|
83
|
+
title: <TextAlignStart aria-hidden className={cn(iconStroke, "rtl:-scale-x-100")} />,
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type Context = {
|
|
87
|
+
spy: UseScrollSpyReturnValue
|
|
88
|
+
variant: TableOfContentsVariant
|
|
89
|
+
size: Size
|
|
90
|
+
/** The shallowest heading level, which sits flush. */
|
|
91
|
+
base: number
|
|
92
|
+
label: string
|
|
93
|
+
icons: Record<TableOfContentsIconSlot, ReactNode>
|
|
94
|
+
titleId: string
|
|
95
|
+
/** A mounted `Title` names the nav (`aria-labelledby`) instead of `aria-label`. */
|
|
96
|
+
setTitled: (titled: boolean) => void
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const TocContext = createContext<Context | null>(null)
|
|
100
|
+
|
|
101
|
+
const useTocContext = (part: string) => {
|
|
102
|
+
const ctx = useContext(TocContext)
|
|
103
|
+
if (!ctx) throw new Error(`TableOfContents.${part} must be rendered inside TableOfContents.Root`)
|
|
104
|
+
return ctx
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const SCOPE = "table-of-contents"
|
|
108
|
+
const LINK = `[data-scope="${SCOPE}"][data-part="link"]`
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Each entry's link. The indent is `--toc-pad` plus one `--toc-indent` per
|
|
112
|
+
* level below the shallowest, so nesting needs no nested lists. The `track`
|
|
113
|
+
* measures that padding to place its line, so the two can't drift apart.
|
|
114
|
+
*/
|
|
115
|
+
const tocLink = cva(
|
|
116
|
+
[
|
|
117
|
+
"block rounded-sm py-(--toc-py) pe-2 leading-snug wrap-anywhere",
|
|
118
|
+
"ps-[calc(var(--toc-pad)+var(--toc-depth,0)*var(--toc-indent))]",
|
|
119
|
+
],
|
|
120
|
+
{
|
|
121
|
+
variants: {
|
|
122
|
+
size: {
|
|
123
|
+
xs: "[--toc-py:0.25rem] [--toc-pad:0.625rem] [--toc-indent:0.625rem]",
|
|
124
|
+
sm: "[--toc-py:0.375rem] [--toc-pad:0.75rem] [--toc-indent:0.75rem]",
|
|
125
|
+
md: "[--toc-py:0.5rem] [--toc-pad:0.875rem] [--toc-indent:0.875rem]",
|
|
126
|
+
lg: "[--toc-py:0.625rem] [--toc-pad:1rem] [--toc-indent:1rem]",
|
|
127
|
+
xl: "[--toc-py:0.75rem] [--toc-pad:1.125rem] [--toc-indent:1.125rem]",
|
|
128
|
+
},
|
|
129
|
+
variant: { track: "", light: "", filled: "" },
|
|
130
|
+
lit: { true: "", false: "" },
|
|
131
|
+
},
|
|
132
|
+
compoundVariants: [
|
|
133
|
+
// Hover keeps the lit colour; Anchor's own subtle hover would win otherwise.
|
|
134
|
+
{
|
|
135
|
+
variant: ["track", "light"],
|
|
136
|
+
lit: true,
|
|
137
|
+
className: "text-(--btn-link-text) hover:text-(--btn-link-text)",
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
variant: "filled",
|
|
141
|
+
lit: true,
|
|
142
|
+
className: "text-(--c-on-solid) hover:text-(--c-on-solid)",
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* The `light` / `filled` pill: the active link's box, measured into
|
|
150
|
+
* `--toc-*` properties, behind the text (`-z-10`, inside the root's
|
|
151
|
+
* `isolate`). A physical `left`, so it needs no RTL flip.
|
|
152
|
+
*/
|
|
153
|
+
const tocPill = cva(
|
|
154
|
+
[
|
|
155
|
+
"pointer-events-none absolute -z-10 top-(--toc-top) left-(--toc-left) h-(--toc-height) w-(--toc-width) rounded-sm",
|
|
156
|
+
"transition-[top,left,width,height] duration-(--duration-normal) ease-(--ease-emphasized)",
|
|
157
|
+
"motion-reduce:transition-none",
|
|
158
|
+
],
|
|
159
|
+
{
|
|
160
|
+
variants: {
|
|
161
|
+
variant: {
|
|
162
|
+
// The solid at 15%, not `--c-soft`: a palette's dark-mode soft step is
|
|
163
|
+
// its 950, which is the page colour for `brand`.
|
|
164
|
+
light: "bg-(--c-solid)/15",
|
|
165
|
+
filled: "bg-(--c-solid)",
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
export type TableOfContentsRootProps = Omit<HTMLArkProps<"nav">, "color"> &
|
|
172
|
+
WithTestId & {
|
|
173
|
+
/** The spy, from `useScrollSpy()`: which headings there are, and which are in view. */
|
|
174
|
+
spy: UseScrollSpyReturnValue
|
|
175
|
+
/**
|
|
176
|
+
* `track` draws a line that follows the nesting and lights up the
|
|
177
|
+
* sections in view; `light` and `filled` put a pill behind the entry
|
|
178
|
+
* being read. @default "track"
|
|
179
|
+
*/
|
|
180
|
+
variant?: TableOfContentsVariant
|
|
181
|
+
/** The highlight's palette. Neutral (the text colour) without it. */
|
|
182
|
+
color?: Color
|
|
183
|
+
/** Text size, padding and indent. @default "sm" */
|
|
184
|
+
size?: Size
|
|
185
|
+
/** Replaces the default icons: `title`, before the title. `null` draws none. */
|
|
186
|
+
icons?: TableOfContentsIcons
|
|
187
|
+
/** Overrides the built-in strings. */
|
|
188
|
+
translations?: TableOfContentsTranslations
|
|
189
|
+
ref?: Ref<HTMLElement>
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** The `<nav>` landmark, and the box the indicator is positioned in. */
|
|
193
|
+
const TableOfContentsRoot = ({
|
|
194
|
+
spy,
|
|
195
|
+
variant = "track",
|
|
196
|
+
color,
|
|
197
|
+
size = "sm",
|
|
198
|
+
icons,
|
|
199
|
+
translations,
|
|
200
|
+
className,
|
|
201
|
+
testId,
|
|
202
|
+
children,
|
|
203
|
+
...rest
|
|
204
|
+
}: TableOfContentsRootProps) => {
|
|
205
|
+
const { label } = { ...TABLE_OF_CONTENTS_DEFAULT_TRANSLATIONS, ...translations }
|
|
206
|
+
const base = spy.data.length > 0 ? Math.min(...spy.data.map((h) => h.depth)) : 1
|
|
207
|
+
const titleId = useId()
|
|
208
|
+
const [titled, setTitled] = useState(false)
|
|
209
|
+
const ctx: Context = {
|
|
210
|
+
spy,
|
|
211
|
+
variant,
|
|
212
|
+
size,
|
|
213
|
+
base,
|
|
214
|
+
label,
|
|
215
|
+
icons: mergeIcons(DEFAULT_ICONS, icons),
|
|
216
|
+
titleId,
|
|
217
|
+
setTitled,
|
|
218
|
+
}
|
|
219
|
+
return (
|
|
220
|
+
<TocContext.Provider value={ctx}>
|
|
221
|
+
<ark.nav
|
|
222
|
+
aria-label={titled ? undefined : label}
|
|
223
|
+
aria-labelledby={titled ? titleId : undefined}
|
|
224
|
+
data-scope={SCOPE}
|
|
225
|
+
data-part="root"
|
|
226
|
+
data-variant={variant}
|
|
227
|
+
data-size={size}
|
|
228
|
+
data-color={color}
|
|
229
|
+
className={cn(
|
|
230
|
+
"relative isolate",
|
|
231
|
+
TYPOGRAPHY_SIZE_CLASSES[size],
|
|
232
|
+
variant === "track" ? TEXT_COLOR_CLASSES.muted : TEXT_COLOR_CLASSES.secondary,
|
|
233
|
+
className,
|
|
234
|
+
)}
|
|
235
|
+
{...props({ "data-testid": testId })}
|
|
236
|
+
{...rest}
|
|
237
|
+
>
|
|
238
|
+
{children}
|
|
239
|
+
</ark.nav>
|
|
240
|
+
</TocContext.Provider>
|
|
241
|
+
)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export type TableOfContentsTitleProps = HTMLArkProps<"p"> &
|
|
245
|
+
WithTestId & {
|
|
246
|
+
ref?: Ref<HTMLParagraphElement>
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* The visible title, "On this page" (`translations.label`) after the
|
|
251
|
+
* `title` icon. While it's mounted, it names the nav (`aria-labelledby`).
|
|
252
|
+
*/
|
|
253
|
+
const TableOfContentsTitle = ({
|
|
254
|
+
asChild,
|
|
255
|
+
className,
|
|
256
|
+
children,
|
|
257
|
+
testId,
|
|
258
|
+
...rest
|
|
259
|
+
}: TableOfContentsTitleProps) => {
|
|
260
|
+
const { label, icons, titleId, setTitled } = useTocContext("Title")
|
|
261
|
+
useIsomorphicLayoutEffect(() => {
|
|
262
|
+
setTitled(true)
|
|
263
|
+
return () => setTitled(false)
|
|
264
|
+
}, [setTitled])
|
|
265
|
+
return (
|
|
266
|
+
<ark.p
|
|
267
|
+
asChild={asChild}
|
|
268
|
+
id={titleId}
|
|
269
|
+
data-scope={SCOPE}
|
|
270
|
+
data-part="title"
|
|
271
|
+
className={cn(
|
|
272
|
+
"mb-2 flex items-center gap-2 font-medium",
|
|
273
|
+
TEXT_COLOR_CLASSES.secondary,
|
|
274
|
+
className,
|
|
275
|
+
)}
|
|
276
|
+
{...props({ "data-testid": testId })}
|
|
277
|
+
{...rest}
|
|
278
|
+
>
|
|
279
|
+
{composeChildren(asChild, asChild ? children : (children ?? label), (own) => (
|
|
280
|
+
<>
|
|
281
|
+
{icons.title != null && (
|
|
282
|
+
<span aria-hidden="true" className="inline-flex shrink-0 [&_svg]:size-[1.15em]">
|
|
283
|
+
{icons.title}
|
|
284
|
+
</span>
|
|
285
|
+
)}
|
|
286
|
+
{own}
|
|
287
|
+
</>
|
|
288
|
+
))}
|
|
289
|
+
</ark.p>
|
|
290
|
+
)
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export type TableOfContentsListProps = HTMLArkProps<"ul"> &
|
|
294
|
+
WithTestId & {
|
|
295
|
+
ref?: Ref<HTMLUListElement>
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** The `<ul>` of entries. */
|
|
299
|
+
const TableOfContentsList = ({ className, testId, ...rest }: TableOfContentsListProps) => {
|
|
300
|
+
useTocContext("List")
|
|
301
|
+
return (
|
|
302
|
+
<ark.ul
|
|
303
|
+
data-scope={SCOPE}
|
|
304
|
+
data-part="list"
|
|
305
|
+
className={cn("flex flex-col", className)}
|
|
306
|
+
{...props({ "data-testid": testId })}
|
|
307
|
+
{...rest}
|
|
308
|
+
/>
|
|
309
|
+
)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export type TableOfContentsItemProps = Omit<
|
|
313
|
+
AnchorProps,
|
|
314
|
+
"href" | "variant" | "color" | "underline" | "size" | "external"
|
|
315
|
+
> & {
|
|
316
|
+
/** The heading's `id`. The link goes to `#value`. */
|
|
317
|
+
value: string
|
|
318
|
+
/** The heading's level (`2` for an `<h2>`). Taken from the spy when unset. */
|
|
319
|
+
depth?: number
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** Whether a click should be left to the browser: a new tab, a download, another button. */
|
|
323
|
+
const isModified = (event: MouseEvent) =>
|
|
324
|
+
event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* One entry: an `<li>` around an `Anchor` to `#value`. A plain click
|
|
328
|
+
* scrolls to the heading with the spy (sticky offset included) and pushes
|
|
329
|
+
* the hash; a modified click (new tab, download) is the browser's. `testId`,
|
|
330
|
+
* `ref`, `asChild` and every other prop go to the link.
|
|
331
|
+
*/
|
|
332
|
+
const TableOfContentsItem = ({
|
|
333
|
+
value,
|
|
334
|
+
depth,
|
|
335
|
+
onClick,
|
|
336
|
+
className,
|
|
337
|
+
style,
|
|
338
|
+
children,
|
|
339
|
+
...rest
|
|
340
|
+
}: TableOfContentsItemProps) => {
|
|
341
|
+
const { spy, variant, size, base } = useTocContext("Item")
|
|
342
|
+
const active = spy.active === value
|
|
343
|
+
const visible = spy.visible.includes(value)
|
|
344
|
+
const level = Math.max((depth ?? spy.data.find((h) => h.id === value)?.depth ?? base) - base, 0)
|
|
345
|
+
|
|
346
|
+
const handleClick = (event: MouseEvent<HTMLAnchorElement>) => {
|
|
347
|
+
onClick?.(event)
|
|
348
|
+
if (event.defaultPrevented || isModified(event)) return
|
|
349
|
+
if (!spy.scrollTo(value)) return
|
|
350
|
+
event.preventDefault()
|
|
351
|
+
window.history.pushState(null, "", `#${value}`)
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
return (
|
|
355
|
+
<ark.li
|
|
356
|
+
data-scope={SCOPE}
|
|
357
|
+
data-part="item"
|
|
358
|
+
data-depth={level}
|
|
359
|
+
{...props({ "data-active": active, "data-visible": visible })}
|
|
360
|
+
>
|
|
361
|
+
<Anchor
|
|
362
|
+
href={`#${value}`}
|
|
363
|
+
variant="subtle"
|
|
364
|
+
underline="never"
|
|
365
|
+
aria-current={active ? "location" : undefined}
|
|
366
|
+
data-scope={SCOPE}
|
|
367
|
+
data-part="link"
|
|
368
|
+
data-value={value}
|
|
369
|
+
{...props({ "data-active": active, "data-visible": visible })}
|
|
370
|
+
onClick={handleClick}
|
|
371
|
+
style={{ "--toc-depth": level, ...style } as CSSProperties}
|
|
372
|
+
className={cn(
|
|
373
|
+
tocLink({ size, variant, lit: variant === "track" ? visible : active }),
|
|
374
|
+
className,
|
|
375
|
+
)}
|
|
376
|
+
{...rest}
|
|
377
|
+
>
|
|
378
|
+
{children}
|
|
379
|
+
</Anchor>
|
|
380
|
+
</ark.li>
|
|
381
|
+
)
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** One link's line, in px from the root's padding box (inline offsets logical). */
|
|
385
|
+
type Row = {
|
|
386
|
+
id: string
|
|
387
|
+
x: number
|
|
388
|
+
top: number
|
|
389
|
+
bottom: number
|
|
390
|
+
textTop: number
|
|
391
|
+
textBottom: number
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
type Track = { rows: Row[]; d: string; width: number; height: number }
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Measures every link against `host` and draws the track through them: a
|
|
398
|
+
* vertical run beside each label's text, and between two labels at
|
|
399
|
+
* different levels a cubic S-curve with vertical tangents, so the line
|
|
400
|
+
* bends rather than kinks. Inline offsets are measured from the inline
|
|
401
|
+
* start, so the same numbers serve LTR and RTL (the SVG is mirrored).
|
|
402
|
+
*/
|
|
403
|
+
export function measureTrack(host: HTMLElement): Track | null {
|
|
404
|
+
const links = [...host.querySelectorAll<HTMLElement>(LINK)]
|
|
405
|
+
if (links.length === 0) return null
|
|
406
|
+
const rtl = getComputedStyle(host).direction === "rtl"
|
|
407
|
+
const h = host.getBoundingClientRect()
|
|
408
|
+
const measured = links.map((link) => {
|
|
409
|
+
const r = link.getBoundingClientRect()
|
|
410
|
+
const cs = getComputedStyle(link)
|
|
411
|
+
const top = r.top - h.top - host.clientTop + host.scrollTop
|
|
412
|
+
return {
|
|
413
|
+
id: link.dataset["value"] ?? "",
|
|
414
|
+
start: rtl ? h.right - host.clientLeft - r.right : r.left - h.left - host.clientLeft,
|
|
415
|
+
pad: Number.parseFloat(cs.paddingInlineStart) || 0,
|
|
416
|
+
top,
|
|
417
|
+
bottom: top + r.height,
|
|
418
|
+
pt: Number.parseFloat(cs.paddingTop) || 0,
|
|
419
|
+
pb: Number.parseFloat(cs.paddingBottom) || 0,
|
|
420
|
+
}
|
|
421
|
+
})
|
|
422
|
+
const flush = Math.min(...measured.map((m) => m.pad))
|
|
423
|
+
// Half a pixel in, so a 1px stroke covers whole pixels.
|
|
424
|
+
const rows: Row[] = measured.map((m) => ({
|
|
425
|
+
id: m.id,
|
|
426
|
+
x: m.start + m.pad - flush + 0.5,
|
|
427
|
+
top: m.top,
|
|
428
|
+
bottom: m.bottom,
|
|
429
|
+
textTop: m.top + m.pt,
|
|
430
|
+
textBottom: m.bottom - m.pb,
|
|
431
|
+
}))
|
|
432
|
+
const first = rows[0] as Row
|
|
433
|
+
const last = rows[rows.length - 1] as Row
|
|
434
|
+
const d = [
|
|
435
|
+
`M${first.x} ${first.top}`,
|
|
436
|
+
...rows.map((row, i) => {
|
|
437
|
+
const prev = rows[i - 1]
|
|
438
|
+
if (!prev) return `L${row.x} ${row.textBottom}`
|
|
439
|
+
const mid = (prev.textBottom + row.textTop) / 2
|
|
440
|
+
return `C${prev.x} ${mid} ${row.x} ${mid} ${row.x} ${row.textTop} L${row.x} ${row.textBottom}`
|
|
441
|
+
}),
|
|
442
|
+
`L${last.x} ${last.bottom}`,
|
|
443
|
+
].join(" ")
|
|
444
|
+
return {
|
|
445
|
+
rows,
|
|
446
|
+
d,
|
|
447
|
+
width: Math.ceil(Math.max(...rows.map((r) => r.x)) + 4),
|
|
448
|
+
height: Math.ceil(last.bottom),
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
const sameTrack = (a: Track | null, b: Track | null) =>
|
|
453
|
+
a === b || (a != null && b != null && a.d === b.d && a.width === b.width)
|
|
454
|
+
|
|
455
|
+
type Box = { top: number; left: number; width: number; height: number }
|
|
456
|
+
|
|
457
|
+
const sameBox = (a: Box | null, b: Box | null) =>
|
|
458
|
+
a === b ||
|
|
459
|
+
(a != null &&
|
|
460
|
+
b != null &&
|
|
461
|
+
a.top === b.top &&
|
|
462
|
+
a.left === b.left &&
|
|
463
|
+
a.width === b.width &&
|
|
464
|
+
a.height === b.height)
|
|
465
|
+
|
|
466
|
+
const motion = "duration-(--duration-normal) ease-(--ease-emphasized) motion-reduce:transition-none"
|
|
467
|
+
|
|
468
|
+
export type TableOfContentsIndicatorProps = NoAsChild<HTMLArkProps<"div">> &
|
|
469
|
+
WithTestId & {
|
|
470
|
+
ref?: Ref<HTMLDivElement>
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* The highlight. With `track`, the line and the lit range over it; with
|
|
475
|
+
* `light` / `filled`, the pill behind the active entry. It re-measures
|
|
476
|
+
* through a `ResizeObserver` on the root and every link, so a resize or a
|
|
477
|
+
* label that re-wraps keeps it lined up. Purely visual (`aria-hidden`):
|
|
478
|
+
* `aria-current` on the link is what assistive tech reads.
|
|
479
|
+
*/
|
|
480
|
+
const TableOfContentsIndicator = ({
|
|
481
|
+
asChild: _asChild,
|
|
482
|
+
className,
|
|
483
|
+
style,
|
|
484
|
+
testId,
|
|
485
|
+
ref,
|
|
486
|
+
...rest
|
|
487
|
+
}: TableOfContentsIndicatorProps) => {
|
|
488
|
+
const { spy, variant, size } = useTocContext("Indicator")
|
|
489
|
+
const own = useRef<HTMLDivElement>(null)
|
|
490
|
+
const setRef = useMergedRefs(own, ref)
|
|
491
|
+
const [track, setTrack] = useState<Track | null>(null)
|
|
492
|
+
const [box, setBox] = useState<Box | null>(null)
|
|
493
|
+
|
|
494
|
+
useIsomorphicLayoutEffect(() => {
|
|
495
|
+
const host = own.current?.closest<HTMLElement>(`[data-scope="${SCOPE}"][data-part="root"]`)
|
|
496
|
+
if (!host) return
|
|
497
|
+
const measure = () => {
|
|
498
|
+
if (variant === "track") {
|
|
499
|
+
const next = measureTrack(host)
|
|
500
|
+
setTrack((prev) => (sameTrack(prev, next) ? prev : next))
|
|
501
|
+
return
|
|
502
|
+
}
|
|
503
|
+
const link = host.querySelector<HTMLElement>(`${LINK}[aria-current]`)
|
|
504
|
+
if (!link) {
|
|
505
|
+
setBox(null)
|
|
506
|
+
return
|
|
507
|
+
}
|
|
508
|
+
const h = host.getBoundingClientRect()
|
|
509
|
+
const l = link.getBoundingClientRect()
|
|
510
|
+
const next = {
|
|
511
|
+
top: l.top - h.top - host.clientTop + host.scrollTop,
|
|
512
|
+
left: l.left - h.left - host.clientLeft + host.scrollLeft,
|
|
513
|
+
width: l.width,
|
|
514
|
+
height: l.height,
|
|
515
|
+
}
|
|
516
|
+
setBox((prev) => (sameBox(prev, next) ? prev : next))
|
|
517
|
+
}
|
|
518
|
+
measure()
|
|
519
|
+
if (typeof ResizeObserver === "undefined") return
|
|
520
|
+
const observer = new ResizeObserver(measure)
|
|
521
|
+
observer.observe(host)
|
|
522
|
+
for (const link of host.querySelectorAll(LINK)) observer.observe(link)
|
|
523
|
+
return () => observer.disconnect()
|
|
524
|
+
}, [spy.active, spy.data, variant, size])
|
|
525
|
+
|
|
526
|
+
const shared = {
|
|
527
|
+
ref: setRef,
|
|
528
|
+
"aria-hidden": true as const,
|
|
529
|
+
"data-scope": SCOPE,
|
|
530
|
+
"data-part": "indicator",
|
|
531
|
+
"data-variant": variant,
|
|
532
|
+
...props({ "data-testid": testId }),
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
if (variant !== "track") {
|
|
536
|
+
return (
|
|
537
|
+
<ark.div
|
|
538
|
+
{...shared}
|
|
539
|
+
hidden={box == null}
|
|
540
|
+
className={cn(tocPill({ variant }), className)}
|
|
541
|
+
style={
|
|
542
|
+
{
|
|
543
|
+
"--toc-top": `${box?.top ?? 0}px`,
|
|
544
|
+
"--toc-left": `${box?.left ?? 0}px`,
|
|
545
|
+
"--toc-width": `${box?.width ?? 0}px`,
|
|
546
|
+
"--toc-height": `${box?.height ?? 0}px`,
|
|
547
|
+
...style,
|
|
548
|
+
} as CSSProperties
|
|
549
|
+
}
|
|
550
|
+
{...rest}
|
|
551
|
+
/>
|
|
552
|
+
)
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// The lit range: from the first section in view's text top to the last's
|
|
556
|
+
// text bottom, where the dot sits.
|
|
557
|
+
const lit = track?.rows.filter((row) => spy.visible.includes(row.id)) ?? []
|
|
558
|
+
const head = lit[0]
|
|
559
|
+
const tail = lit[lit.length - 1]
|
|
560
|
+
|
|
561
|
+
return (
|
|
562
|
+
<ark.div
|
|
563
|
+
{...shared}
|
|
564
|
+
hidden={track == null}
|
|
565
|
+
className={cn(
|
|
566
|
+
"pointer-events-none absolute start-0 top-0 h-(--toc-h) w-(--toc-w) rtl:-scale-x-100",
|
|
567
|
+
className,
|
|
568
|
+
)}
|
|
569
|
+
style={
|
|
570
|
+
{
|
|
571
|
+
"--toc-w": `${track?.width ?? 0}px`,
|
|
572
|
+
"--toc-h": `${track?.height ?? 0}px`,
|
|
573
|
+
"--toc-range-top": `${head?.textTop ?? 0}px`,
|
|
574
|
+
"--toc-range-bottom": `${tail?.textBottom ?? 0}px`,
|
|
575
|
+
"--toc-dot-x": `${tail?.x ?? 0}px`,
|
|
576
|
+
...style,
|
|
577
|
+
} as CSSProperties
|
|
578
|
+
}
|
|
579
|
+
{...rest}
|
|
580
|
+
>
|
|
581
|
+
{track && (
|
|
582
|
+
<>
|
|
583
|
+
<svg
|
|
584
|
+
aria-hidden="true"
|
|
585
|
+
className="absolute inset-0 size-full overflow-visible"
|
|
586
|
+
viewBox={`0 0 ${track.width} ${track.height}`}
|
|
587
|
+
>
|
|
588
|
+
<path
|
|
589
|
+
d={track.d}
|
|
590
|
+
fill="none"
|
|
591
|
+
strokeWidth={1}
|
|
592
|
+
className="stroke-brand-900/20 dark:stroke-white/15"
|
|
593
|
+
/>
|
|
594
|
+
</svg>
|
|
595
|
+
{/* The same path in the accent, clipped to the range. The clip's
|
|
596
|
+
custom properties are set on this element's own ancestor, so
|
|
597
|
+
they resolve where they're read (unlike a `var()` inside an SVG
|
|
598
|
+
<mask>, which resolves from the mask's own DOM position). */}
|
|
599
|
+
<svg
|
|
600
|
+
aria-hidden="true"
|
|
601
|
+
// SVG ignores the HTML `hidden` attribute.
|
|
602
|
+
className={cn(
|
|
603
|
+
"absolute inset-0 size-full overflow-visible transition-[clip-path]",
|
|
604
|
+
!head && "invisible",
|
|
605
|
+
"[clip-path:polygon(-4px_var(--toc-range-top),calc(100%+4px)_var(--toc-range-top),calc(100%+4px)_var(--toc-range-bottom),-4px_var(--toc-range-bottom))]",
|
|
606
|
+
motion,
|
|
607
|
+
)}
|
|
608
|
+
viewBox={`0 0 ${track.width} ${track.height}`}
|
|
609
|
+
>
|
|
610
|
+
<path d={track.d} fill="none" strokeWidth={1.5} className="stroke-(--c-solid)" />
|
|
611
|
+
</svg>
|
|
612
|
+
<span
|
|
613
|
+
hidden={!tail}
|
|
614
|
+
className={cn(
|
|
615
|
+
"absolute size-[5px] rounded-full bg-(--c-solid)",
|
|
616
|
+
"top-[calc(var(--toc-range-bottom)-2.5px)] left-[calc(var(--toc-dot-x)-2.5px)]",
|
|
617
|
+
"transition-[top,left]",
|
|
618
|
+
motion,
|
|
619
|
+
)}
|
|
620
|
+
/>
|
|
621
|
+
</>
|
|
622
|
+
)}
|
|
623
|
+
</ark.div>
|
|
624
|
+
)
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/** One entry of `data`. */
|
|
628
|
+
export type TableOfContentsEntry = {
|
|
629
|
+
/** The heading's `id`. */
|
|
630
|
+
value: string
|
|
631
|
+
/** What the entry says. Inline code and wrapping labels are fine. */
|
|
632
|
+
label: ReactNode
|
|
633
|
+
/** The heading's level (`2` for an `<h2>`). Read from the heading when unset. */
|
|
634
|
+
depth?: number
|
|
635
|
+
/** Renders as `data-testid` on the entry's link. */
|
|
636
|
+
testId?: string
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export type TableOfContentsProps = NoAsChild<Omit<TableOfContentsRootProps, "spy" | "children">> &
|
|
640
|
+
Pick<UseScrollSpyOptions, "container" | "root" | "offset" | "getDepth"> & {
|
|
641
|
+
/** The entries, instead of collecting headings from the page. Rendered on the server too. */
|
|
642
|
+
data?: readonly TableOfContentsEntry[]
|
|
643
|
+
/** Which headings to collect, when there's no `data`. @default "h2, h3" */
|
|
644
|
+
selector?: string
|
|
645
|
+
/** Shows the "On this page" title above the list. @default true */
|
|
646
|
+
withTitle?: boolean
|
|
647
|
+
/** Classes for each part: `title`, `list`, `link` (every entry's), `indicator`. */
|
|
648
|
+
classNames?: { title?: string; list?: string; link?: string; indicator?: string }
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* The ready-made table of contents: a spy, the nav, its title, the list
|
|
653
|
+
* and the indicator, from a few props. Renders nothing when there are no
|
|
654
|
+
* headings.
|
|
655
|
+
*/
|
|
656
|
+
const TableOfContentsComponent = ({
|
|
657
|
+
data,
|
|
658
|
+
container,
|
|
659
|
+
selector = "h2, h3",
|
|
660
|
+
root,
|
|
661
|
+
offset,
|
|
662
|
+
getDepth,
|
|
663
|
+
withTitle = true,
|
|
664
|
+
classNames,
|
|
665
|
+
asChild: _asChild,
|
|
666
|
+
...rest
|
|
667
|
+
}: TableOfContentsProps) => {
|
|
668
|
+
const spy = useScrollSpy({
|
|
669
|
+
container,
|
|
670
|
+
selector,
|
|
671
|
+
root,
|
|
672
|
+
offset,
|
|
673
|
+
getDepth,
|
|
674
|
+
data: data?.map((entry) => ({
|
|
675
|
+
id: entry.value,
|
|
676
|
+
depth: entry.depth,
|
|
677
|
+
label: typeof entry.label === "string" ? entry.label : undefined,
|
|
678
|
+
})),
|
|
679
|
+
})
|
|
680
|
+
if (spy.data.length === 0) return null
|
|
681
|
+
return (
|
|
682
|
+
<TableOfContentsRoot spy={spy} {...rest}>
|
|
683
|
+
{withTitle && <TableOfContentsTitle className={classNames?.title} />}
|
|
684
|
+
<TableOfContentsIndicator className={classNames?.indicator} />
|
|
685
|
+
<TableOfContentsList className={classNames?.list}>
|
|
686
|
+
{spy.data.map((heading, i) => (
|
|
687
|
+
<TableOfContentsItem
|
|
688
|
+
key={heading.id}
|
|
689
|
+
value={heading.id}
|
|
690
|
+
depth={heading.depth}
|
|
691
|
+
testId={data?.[i]?.testId}
|
|
692
|
+
className={classNames?.link}
|
|
693
|
+
>
|
|
694
|
+
{data?.[i]?.label ?? heading.label}
|
|
695
|
+
</TableOfContentsItem>
|
|
696
|
+
))}
|
|
697
|
+
</TableOfContentsList>
|
|
698
|
+
</TableOfContentsRoot>
|
|
699
|
+
)
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
export const TableOfContents = Object.assign(TableOfContentsComponent, {
|
|
703
|
+
Root: TableOfContentsRoot,
|
|
704
|
+
Title: TableOfContentsTitle,
|
|
705
|
+
List: TableOfContentsList,
|
|
706
|
+
Item: TableOfContentsItem,
|
|
707
|
+
Indicator: TableOfContentsIndicator,
|
|
708
|
+
})
|