@slotted/react 0.1.0-beta.39 → 0.1.0-beta.40
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/alert-CV8wKS-N.js +179 -0
- package/dist/alert.js +1 -1
- package/dist/{avatar-DLWElrgg.js → avatar-fHRva5zn.js} +1 -1
- package/dist/{avatar-group-DshHqe8B.js → avatar-group-bJaZE1_C.js} +1 -1
- package/dist/avatar-group.js +1 -1
- package/dist/avatar.js +1 -1
- package/dist/calendar-D3QZDlm0.js +598 -0
- package/dist/calendar.js +1 -1
- package/dist/clock-DzkQa57Q.js +290 -0
- package/dist/clock.js +2 -0
- package/dist/{dashboard-grid-B6jxBz4j.js → dashboard-grid-DAY_CjCW.js} +1 -1
- package/dist/dashboard-grid.js +1 -1
- package/dist/{data-grid-Cx0ZOf_e.js → data-grid-B7UuUvBH.js} +42 -37
- package/dist/data-grid.js +1 -1
- package/dist/{data-list-Cb2sNA6I.js → data-list-CyEq7M2D.js} +1 -1
- package/dist/data-list.js +1 -1
- package/dist/date-picker-DMcMFW_N.js +344 -0
- package/dist/date-picker.js +3 -2
- package/dist/date-range-picker-D9zo93NE.js +543 -0
- package/dist/date-range-picker.js +2 -2
- package/dist/datetime-picker-lOXZbAx_.js +462 -0
- package/dist/datetime-picker.js +2 -2
- package/dist/datetime-range-picker-DU5ctZbm.js +641 -0
- package/dist/datetime-range-picker.js +2 -2
- package/dist/divider-DUUPCIh4.js +35 -0
- package/dist/divider.js +1 -1
- package/dist/docs/alert.examples.md +500 -0
- package/dist/docs/alert.json +85 -37
- package/dist/docs/alert.md +37 -189
- package/dist/docs/aspect-ratio.json +40 -16
- package/dist/docs/aspect-ratio.md +204 -29
- package/dist/docs/avatar.json +125 -29
- package/dist/docs/avatar.md +374 -31
- package/dist/docs/badge.json +119 -23
- package/dist/docs/badge.md +436 -27
- package/dist/docs/calendar.json +53 -5
- package/dist/docs/calendar.md +7 -2
- package/dist/docs/card.json +98 -10
- package/dist/docs/card.md +468 -26
- package/dist/docs/clock.json +405 -0
- package/dist/docs/clock.md +189 -0
- package/dist/docs/container.json +54 -6
- package/dist/docs/container.md +247 -17
- package/dist/docs/date-picker.examples.md +143 -169
- package/dist/docs/date-picker.json +178 -223
- package/dist/docs/date-picker.md +44 -50
- package/dist/docs/date-range-picker.examples.md +169 -187
- package/dist/docs/date-range-picker.json +206 -337
- package/dist/docs/date-range-picker.md +52 -67
- package/dist/docs/datetime-picker.examples.md +75 -210
- package/dist/docs/datetime-picker.json +183 -410
- package/dist/docs/datetime-picker.md +50 -72
- package/dist/docs/datetime-range-picker.json +225 -502
- package/dist/docs/datetime-range-picker.md +250 -101
- package/dist/docs/divider.json +71 -7
- package/dist/docs/divider.md +281 -13
- package/dist/docs/grid.json +76 -12
- package/dist/docs/grid.md +376 -18
- package/dist/docs/index.md +1 -0
- package/dist/docs/inline-message.json +87 -40
- package/dist/docs/inline-message.md +314 -71
- package/dist/docs/inline.json +65 -9
- package/dist/docs/inline.md +276 -13
- package/dist/docs/kbd.json +76 -36
- package/dist/docs/kbd.md +346 -63
- package/dist/docs/link.json +65 -25
- package/dist/docs/link.md +317 -60
- package/dist/docs/progress-indicator.examples.md +522 -0
- package/dist/docs/progress-indicator.json +51 -27
- package/dist/docs/progress-indicator.md +13 -238
- package/dist/docs/result-state.examples.md +752 -0
- package/dist/docs/result-state.json +95 -47
- package/dist/docs/result-state.md +45 -228
- package/dist/docs/skeleton.json +70 -38
- package/dist/docs/skeleton.md +393 -71
- package/dist/docs/stack.json +57 -9
- package/dist/docs/stack.md +225 -12
- package/dist/docs/table.examples.md +6 -10
- package/dist/docs/table.json +5 -5
- package/dist/docs/table.md +1 -1
- package/dist/docs/tag.examples.md +503 -0
- package/dist/docs/tag.json +128 -32
- package/dist/docs/tag.md +27 -138
- package/dist/docs/time-picker.json +162 -300
- package/dist/docs/time-picker.md +100 -154
- package/dist/docs/time-range-picker.json +203 -465
- package/dist/docs/time-range-picker.md +125 -173
- package/dist/docs/toast.examples.md +690 -0
- package/dist/docs/toast.json +119 -71
- package/dist/docs/toast.md +44 -212
- package/dist/docs/tree.examples.md +2008 -0
- package/dist/docs/tree.json +283 -106
- package/dist/docs/tree.md +96 -328
- package/dist/docs/visually-hidden.json +38 -6
- package/dist/docs/visually-hidden.md +148 -11
- package/dist/{entity-picker-CwfA1wr_.js → entity-picker-BwJX0gNJ.js} +1 -1
- package/dist/entity-picker.js +1 -1
- package/dist/{filter-bar-b8bRNPs9.js → filter-bar-BQZFgV0A.js} +5 -3
- package/dist/filter-bar.js +1 -1
- package/dist/{import-export-center-C_oNc-RM.js → import-export-center-DWSEOV5Z.js} +3 -3
- package/dist/import-export-center.js +1 -1
- package/dist/index.js +101 -99
- package/dist/{markdown-x59MHBAa.js → markdown-7wOBMXTl.js} +1 -1
- package/dist/markdown.js +1 -1
- package/dist/picker-frame-_9ZqQOjf.js +43 -0
- package/dist/picker-group-CrNRKUxz.js +33 -0
- package/dist/picker-head-C_Z0tQGq.js +69 -0
- package/dist/picker-jump-BcTRIJs6.js +70 -0
- package/dist/picker-range-head-B4tsDOc5.js +100 -0
- package/dist/picker-step-MgBwF9g1.js +26 -0
- package/dist/read-title-id-DQZVWlMt.js +14 -0
- package/dist/result-state-Ct9AB01a.js +123 -0
- package/dist/result-state.js +1 -1
- package/dist/styles/app-shell.css +1 -1
- package/dist/styles/aspect-ratio.css +1 -1
- package/dist/styles/attachment.css +1 -1
- package/dist/styles/badge.css +1 -1
- package/dist/styles/calendar.css +1 -1
- package/dist/styles/cascader.css +1 -1
- package/dist/styles/chart.css +1 -1
- package/dist/styles/clock.css +2 -0
- package/dist/styles/code-block.css +1 -1
- package/dist/styles/command-palette.css +1 -1
- package/dist/styles/dashboard-grid.css +1 -1
- package/dist/styles/data-grid.css +14 -10
- package/dist/styles/data-list.css +1 -1
- package/dist/styles/date-picker.css +4 -2
- package/dist/styles/date-range-picker.css +4 -2
- package/dist/styles/datetime-picker.css +8 -2
- package/dist/styles/datetime-range-picker.css +6 -2
- package/dist/styles/detail-panel.css +3 -3
- package/dist/styles/entity-picker.css +1 -1
- package/dist/styles/event-calendar.css +1 -1
- package/dist/styles/filter-bar.css +11 -7
- package/dist/styles/grid.css +1 -1
- package/dist/styles/image.css +1 -1
- package/dist/styles/import-export-center.css +15 -11
- package/dist/styles/index.css +21 -17
- package/dist/styles/inline.css +1 -1
- package/dist/styles/loading-overlay.css +1 -1
- package/dist/styles/markdown.css +1 -1
- package/dist/styles/multi-select.css +1 -1
- package/dist/styles/notification-center.css +1 -1
- package/dist/styles/page-header.css +2 -2
- package/dist/styles/progress-indicator.css +1 -1
- package/dist/styles/side-navigation.css +2 -2
- package/dist/styles/skeleton.css +1 -1
- package/dist/styles/stack.css +1 -1
- package/dist/styles/stat-card.css +1 -1
- package/dist/styles/table-of-contents.css +1 -1
- package/dist/styles/table.css +14 -10
- package/dist/styles/time-picker.css +5 -1
- package/dist/styles/time-range-picker.css +5 -1
- package/dist/styles/toast.css +1 -1
- package/dist/styles/top-navigation.css +1 -1
- package/dist/styles/tree.css +1 -1
- package/dist/styles/upload.css +1 -1
- package/dist/styles/wizard.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/{table-DqwYPHGS.js → table-MGb3iZY_.js} +11 -6
- package/dist/table.js +1 -1
- package/dist/time-picker-z4GSRuha.js +313 -0
- package/dist/time-picker.js +2 -2
- package/dist/time-range-picker-ar40oPcf.js +563 -0
- package/dist/time-range-picker.js +2 -2
- package/dist/{toast-DHDVXIew.js → toast-Cg28GkqX.js} +121 -117
- package/dist/toast.js +1 -1
- package/dist/tree-CytfCFT-.js +874 -0
- package/dist/tree.js +1 -1
- package/dist/types/alert/alert-parts.d.ts +1 -1
- package/dist/types/alert/alert-parts.d.ts.map +1 -1
- package/dist/types/alert/alert.d.ts.map +1 -1
- package/dist/types/alert/alert.types.d.ts +1 -1
- package/dist/types/alert/alert.types.d.ts.map +1 -1
- package/dist/types/avatar/avatar.d.ts.map +1 -1
- package/dist/types/badge/badge.types.d.ts +1 -1
- package/dist/types/badge/badge.types.d.ts.map +1 -1
- package/dist/types/calendar/calendar-day-cell.d.ts +3 -1
- package/dist/types/calendar/calendar-day-cell.d.ts.map +1 -1
- package/dist/types/calendar/calendar-header.d.ts +9 -5
- package/dist/types/calendar/calendar-header.d.ts.map +1 -1
- package/dist/types/calendar/calendar-month-table.d.ts +8 -3
- package/dist/types/calendar/calendar-month-table.d.ts.map +1 -1
- package/dist/types/calendar/calendar.d.ts +1 -1
- package/dist/types/calendar/calendar.d.ts.map +1 -1
- package/dist/types/calendar/calendar.types.d.ts +12 -1
- package/dist/types/calendar/calendar.types.d.ts.map +1 -1
- package/dist/types/clock/clock-body.d.ts +16 -0
- package/dist/types/clock/clock-body.d.ts.map +1 -0
- package/dist/types/clock/clock-demo.d.ts +15 -0
- package/dist/types/clock/clock-demo.d.ts.map +1 -0
- package/dist/types/clock/clock-groups.d.ts +15 -0
- package/dist/types/clock/clock-groups.d.ts.map +1 -0
- package/dist/types/clock/clock-option.d.ts +14 -0
- package/dist/types/clock/clock-option.d.ts.map +1 -0
- package/dist/types/clock/clock-units.d.ts +13 -0
- package/dist/types/clock/clock-units.d.ts.map +1 -0
- package/dist/types/clock/clock.d.ts +11 -0
- package/dist/types/clock/clock.d.ts.map +1 -0
- package/dist/types/clock/clock.types.d.ts +66 -0
- package/dist/types/clock/clock.types.d.ts.map +1 -0
- package/dist/types/clock/index.d.ts +3 -0
- package/dist/types/clock/index.d.ts.map +1 -0
- package/dist/types/clock/use-clock-grid.d.ts +28 -0
- package/dist/types/clock/use-clock-grid.d.ts.map +1 -0
- package/dist/types/clock/use-clock-view.d.ts +16 -0
- package/dist/types/clock/use-clock-view.d.ts.map +1 -0
- package/dist/types/data-grid/data-grid-filter.d.ts.map +1 -1
- package/dist/types/date-picker/date-panel.d.ts +32 -0
- package/dist/types/date-picker/date-panel.d.ts.map +1 -0
- package/dist/types/date-picker/date-picker-demo.d.ts +8 -15
- package/dist/types/date-picker/date-picker-demo.d.ts.map +1 -1
- package/dist/types/date-picker/date-picker-panel.d.ts +18 -0
- package/dist/types/date-picker/date-picker-panel.d.ts.map +1 -0
- package/dist/types/date-picker/date-picker.d.ts +7 -13
- package/dist/types/date-picker/date-picker.d.ts.map +1 -1
- package/dist/types/date-picker/date-picker.types.d.ts +15 -16
- package/dist/types/date-picker/date-picker.types.d.ts.map +1 -1
- package/dist/types/date-picker/index.d.ts +1 -1
- package/dist/types/date-picker/index.d.ts.map +1 -1
- package/dist/types/date-picker/month-picker.d.ts +12 -0
- package/dist/types/date-picker/month-picker.d.ts.map +1 -0
- package/dist/types/date-picker/use-date-panel.d.ts +50 -0
- package/dist/types/date-picker/use-date-panel.d.ts.map +1 -0
- package/dist/types/date-picker/use-date-picker.d.ts +24 -0
- package/dist/types/date-picker/use-date-picker.d.ts.map +1 -0
- package/dist/types/date-range-picker/date-range-control.d.ts +34 -0
- package/dist/types/date-range-picker/date-range-control.d.ts.map +1 -0
- package/dist/types/date-range-picker/date-range-panel.d.ts +24 -0
- package/dist/types/date-range-picker/date-range-panel.d.ts.map +1 -0
- package/dist/types/date-range-picker/date-range-picker-demo.d.ts +8 -15
- package/dist/types/date-range-picker/date-range-picker-demo.d.ts.map +1 -1
- package/dist/types/date-range-picker/date-range-picker.d.ts +11 -21
- package/dist/types/date-range-picker/date-range-picker.d.ts.map +1 -1
- package/dist/types/date-range-picker/date-range-picker.types.d.ts +12 -26
- package/dist/types/date-range-picker/date-range-picker.types.d.ts.map +1 -1
- package/dist/types/date-range-picker/index.d.ts +2 -2
- package/dist/types/date-range-picker/index.d.ts.map +1 -1
- package/dist/types/date-range-picker/range-words.d.ts +30 -0
- package/dist/types/date-range-picker/range-words.d.ts.map +1 -0
- package/dist/types/date-range-picker/use-date-range-picker.d.ts +32 -0
- package/dist/types/date-range-picker/use-date-range-picker.d.ts.map +1 -0
- package/dist/types/date-range-picker/use-range-draft.d.ts +39 -0
- package/dist/types/date-range-picker/use-range-draft.d.ts.map +1 -0
- package/dist/types/date-range-picker/use-range-panel.d.ts +71 -0
- package/dist/types/date-range-picker/use-range-panel.d.ts.map +1 -0
- package/dist/types/datetime-picker/datetime-picker-defaults.d.ts +3 -9
- package/dist/types/datetime-picker/datetime-picker-defaults.d.ts.map +1 -1
- package/dist/types/datetime-picker/datetime-picker-demo.d.ts +8 -31
- package/dist/types/datetime-picker/datetime-picker-demo.d.ts.map +1 -1
- package/dist/types/datetime-picker/datetime-picker-panel.d.ts +23 -0
- package/dist/types/datetime-picker/datetime-picker-panel.d.ts.map +1 -0
- package/dist/types/datetime-picker/datetime-picker.d.ts +8 -19
- package/dist/types/datetime-picker/datetime-picker.d.ts.map +1 -1
- package/dist/types/datetime-picker/datetime-picker.types.d.ts +25 -66
- package/dist/types/datetime-picker/datetime-picker.types.d.ts.map +1 -1
- package/dist/types/datetime-picker/index.d.ts +2 -2
- package/dist/types/datetime-picker/index.d.ts.map +1 -1
- package/dist/types/datetime-picker/use-datetime-panel.d.ts +69 -0
- package/dist/types/datetime-picker/use-datetime-panel.d.ts.map +1 -0
- package/dist/types/datetime-picker/use-datetime-picker.d.ts +22 -0
- package/dist/types/datetime-picker/use-datetime-picker.d.ts.map +1 -0
- package/dist/types/datetime-range-picker/datetime-range-half.d.ts +20 -0
- package/dist/types/datetime-range-picker/datetime-range-half.d.ts.map +1 -0
- package/dist/types/datetime-range-picker/datetime-range-panel.d.ts +30 -0
- package/dist/types/datetime-range-picker/datetime-range-panel.d.ts.map +1 -0
- package/dist/types/datetime-range-picker/datetime-range-picker-defaults.d.ts +5 -7
- package/dist/types/datetime-range-picker/datetime-range-picker-defaults.d.ts.map +1 -1
- package/dist/types/datetime-range-picker/datetime-range-picker-demo.d.ts +8 -24
- package/dist/types/datetime-range-picker/datetime-range-picker-demo.d.ts.map +1 -1
- package/dist/types/datetime-range-picker/datetime-range-picker.d.ts +12 -24
- package/dist/types/datetime-range-picker/datetime-range-picker.d.ts.map +1 -1
- package/dist/types/datetime-range-picker/datetime-range-picker.types.d.ts +31 -66
- package/dist/types/datetime-range-picker/datetime-range-picker.types.d.ts.map +1 -1
- package/dist/types/datetime-range-picker/datetime-range-words.d.ts +40 -0
- package/dist/types/datetime-range-picker/datetime-range-words.d.ts.map +1 -0
- package/dist/types/datetime-range-picker/index.d.ts +4 -3
- package/dist/types/datetime-range-picker/index.d.ts.map +1 -1
- package/dist/types/datetime-range-picker/use-datetime-range-draft.d.ts +43 -0
- package/dist/types/datetime-range-picker/use-datetime-range-draft.d.ts.map +1 -0
- package/dist/types/datetime-range-picker/use-datetime-range-panel.d.ts +82 -0
- package/dist/types/datetime-range-picker/use-datetime-range-panel.d.ts.map +1 -0
- package/dist/types/datetime-range-picker/use-datetime-range-picker.d.ts +28 -0
- package/dist/types/datetime-range-picker/use-datetime-range-picker.d.ts.map +1 -0
- package/dist/types/divider/divider.d.ts +1 -1
- package/dist/types/divider/divider.d.ts.map +1 -1
- package/dist/types/filter-bar/filter-bar-rules.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/picker-panel/picker-footer.d.ts +17 -0
- package/dist/types/picker-panel/picker-footer.d.ts.map +1 -0
- package/dist/types/picker-panel/picker-frame.d.ts +21 -0
- package/dist/types/picker-panel/picker-frame.d.ts.map +1 -0
- package/dist/types/picker-panel/picker-group.d.ts +18 -0
- package/dist/types/picker-panel/picker-group.d.ts.map +1 -0
- package/dist/types/picker-panel/picker-head.d.ts +27 -0
- package/dist/types/picker-panel/picker-head.d.ts.map +1 -0
- package/dist/types/picker-panel/picker-jump.d.ts +18 -0
- package/dist/types/picker-panel/picker-jump.d.ts.map +1 -0
- package/dist/types/picker-panel/picker-layer.d.ts +14 -0
- package/dist/types/picker-panel/picker-layer.d.ts.map +1 -0
- package/dist/types/picker-panel/picker-panel.d.ts +17 -0
- package/dist/types/picker-panel/picker-panel.d.ts.map +1 -0
- package/dist/types/picker-panel/picker-rail.d.ts +17 -0
- package/dist/types/picker-panel/picker-rail.d.ts.map +1 -0
- package/dist/types/picker-panel/picker-range-head.d.ts +37 -0
- package/dist/types/picker-panel/picker-range-head.d.ts.map +1 -0
- package/dist/types/picker-panel/picker-ruler.d.ts +14 -0
- package/dist/types/picker-panel/picker-ruler.d.ts.map +1 -0
- package/dist/types/picker-panel/picker-step.d.ts +11 -0
- package/dist/types/picker-panel/picker-step.d.ts.map +1 -0
- package/dist/types/picker-panel/picker-trigger.d.ts +16 -0
- package/dist/types/picker-panel/picker-trigger.d.ts.map +1 -0
- package/dist/types/picker-panel/use-media-query.d.ts +3 -0
- package/dist/types/picker-panel/use-media-query.d.ts.map +1 -0
- package/dist/types/picker-panel/use-picker-draft.d.ts +18 -0
- package/dist/types/picker-panel/use-picker-draft.d.ts.map +1 -0
- package/dist/types/picker-panel/use-picker-layer.d.ts +31 -0
- package/dist/types/picker-panel/use-picker-layer.d.ts.map +1 -0
- package/dist/types/picker-panel/use-picker-open.d.ts +14 -0
- package/dist/types/picker-panel/use-picker-open.d.ts.map +1 -0
- package/dist/types/picker-panel/use-picker-position.d.ts +12 -0
- package/dist/types/picker-panel/use-picker-position.d.ts.map +1 -0
- package/dist/types/picker-panel/use-picker-value.d.ts +20 -0
- package/dist/types/picker-panel/use-picker-value.d.ts.map +1 -0
- package/dist/types/result-state/result-state.d.ts +32 -2
- package/dist/types/result-state/result-state.d.ts.map +1 -1
- package/dist/types/table/table-filter.d.ts.map +1 -1
- package/dist/types/table/table.types.d.ts +16 -14
- package/dist/types/table/table.types.d.ts.map +1 -1
- package/dist/types/tag/tag.types.d.ts +1 -1
- package/dist/types/tag/tag.types.d.ts.map +1 -1
- package/dist/types/time-picker/index.d.ts +2 -2
- package/dist/types/time-picker/index.d.ts.map +1 -1
- package/dist/types/time-picker/time-picker-defaults.d.ts +0 -7
- package/dist/types/time-picker/time-picker-defaults.d.ts.map +1 -1
- package/dist/types/time-picker/time-picker-demo.d.ts +15 -0
- package/dist/types/time-picker/time-picker-demo.d.ts.map +1 -0
- package/dist/types/time-picker/time-picker-panel.d.ts +17 -0
- package/dist/types/time-picker/time-picker-panel.d.ts.map +1 -0
- package/dist/types/time-picker/time-picker.d.ts +6 -14
- package/dist/types/time-picker/time-picker.d.ts.map +1 -1
- package/dist/types/time-picker/time-picker.types.d.ts +21 -45
- package/dist/types/time-picker/time-picker.types.d.ts.map +1 -1
- package/dist/types/time-picker/use-time-panel.d.ts +42 -0
- package/dist/types/time-picker/use-time-panel.d.ts.map +1 -0
- package/dist/types/time-picker/use-time-picker.d.ts +27 -0
- package/dist/types/time-picker/use-time-picker.d.ts.map +1 -0
- package/dist/types/time-range-picker/index.d.ts +4 -3
- package/dist/types/time-range-picker/index.d.ts.map +1 -1
- package/dist/types/time-range-picker/time-range-panel.d.ts +23 -0
- package/dist/types/time-range-picker/time-range-panel.d.ts.map +1 -0
- package/dist/types/time-range-picker/time-range-picker-defaults.d.ts +2 -4
- package/dist/types/time-range-picker/time-range-picker-defaults.d.ts.map +1 -1
- package/dist/types/time-range-picker/time-range-picker-demo.d.ts +8 -24
- package/dist/types/time-range-picker/time-range-picker-demo.d.ts.map +1 -1
- package/dist/types/time-range-picker/time-range-picker.d.ts +12 -28
- package/dist/types/time-range-picker/time-range-picker.d.ts.map +1 -1
- package/dist/types/time-range-picker/time-range-picker.types.d.ts +24 -64
- package/dist/types/time-range-picker/time-range-picker.types.d.ts.map +1 -1
- package/dist/types/time-range-picker/time-range-words.d.ts +37 -0
- package/dist/types/time-range-picker/time-range-words.d.ts.map +1 -0
- package/dist/types/time-range-picker/use-time-range-panel.d.ts +68 -0
- package/dist/types/time-range-picker/use-time-range-panel.d.ts.map +1 -0
- package/dist/types/time-range-picker/use-time-range-picker.d.ts +25 -0
- package/dist/types/time-range-picker/use-time-range-picker.d.ts.map +1 -0
- package/dist/types/title-id/read-title-id.d.ts +15 -0
- package/dist/types/title-id/read-title-id.d.ts.map +1 -0
- package/dist/types/toast/toast.d.ts.map +1 -1
- package/dist/types/tree/index.d.ts +1 -1
- package/dist/types/tree/index.d.ts.map +1 -1
- package/dist/types/tree/tree-parts.d.ts +2 -0
- package/dist/types/tree/tree-parts.d.ts.map +1 -1
- package/dist/types/tree/tree.d.ts +1 -1
- package/dist/types/tree/tree.d.ts.map +1 -1
- package/dist/types/tree/tree.types.d.ts +15 -5
- package/dist/types/tree/tree.types.d.ts.map +1 -1
- package/dist/use-date-picker-DL8tRXji.js +63 -0
- package/dist/use-picker-draft-Bw8VFaj0.js +377 -0
- package/dist/{wizard-CL6u1aJb.js → wizard-BokOrtwq.js} +1 -1
- package/dist/wizard.js +1 -1
- package/package.json +10 -6
- package/dist/alert-Bi9s1cjV.js +0 -174
- package/dist/calendar-CX0wN5Bh.js +0 -564
- package/dist/date-picker-CLXTtQGe.js +0 -337
- package/dist/date-range-picker-Br0neGyT.js +0 -522
- package/dist/datetime-picker-CR-H_BLu.js +0 -683
- package/dist/datetime-range-picker-BLo58OIk.js +0 -1050
- package/dist/divider-ryFeK0Pi.js +0 -35
- package/dist/docs/datetime-range-picker.examples.md +0 -219
- package/dist/result-state-BMYhelu1.js +0 -128
- package/dist/time-picker-B4-GsO24.js +0 -436
- package/dist/time-range-picker-DVOWN8PF.js +0 -800
- package/dist/tree-D-y-0TrL.js +0 -794
|
@@ -0,0 +1,2008 @@
|
|
|
1
|
+
<!-- index: ./index.md -->
|
|
2
|
+
# tree
|
|
3
|
+
|
|
4
|
+
`data-ui="tree"` · Hierarchy of items that expand and select.
|
|
5
|
+
|
|
6
|
+
## Examples
|
|
7
|
+
|
|
8
|
+
### Playground
|
|
9
|
+
|
|
10
|
+
One tree with every axis on it, driven by the controls under the canvas. Arrow through it, press the arrows sideways, and watch the chevron and the band say two different things.
|
|
11
|
+
|
|
12
|
+
Excerpt — not a complete module
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
<Tree aria-label="Project files" defaultExpandedKeys={['src']}>
|
|
16
|
+
<TreeNode value="src" label="src" meta="12">
|
|
17
|
+
<TreeNode value="index.ts" label="index.ts" />
|
|
18
|
+
<TreeNode value="lib" label="lib">
|
|
19
|
+
<TreeNode value="tree.ts" label="tree.ts" />
|
|
20
|
+
</TreeNode>
|
|
21
|
+
</TreeNode>
|
|
22
|
+
<TreeNode value="readme" label="README.md" />
|
|
23
|
+
</Tree>;
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Opening and closing a branch
|
|
27
|
+
|
|
28
|
+
The row opens the branch by default; the second tree gives that job to the chevron alone. Press each of them, then use the sideways arrows on both.
|
|
29
|
+
|
|
30
|
+
Example
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { Grid } from '@slotted/react/grid';
|
|
34
|
+
import { Stack } from '@slotted/react/stack';
|
|
35
|
+
import { Tree } from '@slotted/react/tree';
|
|
36
|
+
import { Text } from '@slotted/react/typography';
|
|
37
|
+
|
|
38
|
+
interface Category {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
children?: Category[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const CATEGORIES: Category[] = [
|
|
45
|
+
{
|
|
46
|
+
id: 'beverages',
|
|
47
|
+
name: 'Beverages',
|
|
48
|
+
children: [
|
|
49
|
+
{ id: 'coffee', name: 'Coffee' },
|
|
50
|
+
{ id: 'tea', name: 'Tea' },
|
|
51
|
+
{ id: 'soft-drinks', name: 'Soft drinks' },
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'pantry',
|
|
56
|
+
name: 'Pantry',
|
|
57
|
+
children: [
|
|
58
|
+
{ id: 'oils', name: 'Oils and vinegars' },
|
|
59
|
+
{
|
|
60
|
+
id: 'spices',
|
|
61
|
+
name: 'Spices',
|
|
62
|
+
children: [
|
|
63
|
+
{ id: 'ground-spices', name: 'Ground spices' },
|
|
64
|
+
{ id: 'whole-spices', name: 'Whole spices' },
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
{ id: 'household', name: 'Household' },
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
export default function TreeExpansion() {
|
|
73
|
+
return (
|
|
74
|
+
<Grid columns={2} gap={6} minItemWidth="xs">
|
|
75
|
+
<Stack gap={2}>
|
|
76
|
+
<Text size="sm" tone="muted">
|
|
77
|
+
The whole row
|
|
78
|
+
</Text>
|
|
79
|
+
<Tree
|
|
80
|
+
aria-label="Categories, opened by the row"
|
|
81
|
+
defaultExpandedKeys={['beverages']}
|
|
82
|
+
nodes={CATEGORIES}
|
|
83
|
+
getKey={(category) => category.id}
|
|
84
|
+
getLabel={(category) => category.name}
|
|
85
|
+
getChildren={(category) => category.children}
|
|
86
|
+
/>
|
|
87
|
+
</Stack>
|
|
88
|
+
<Stack gap={2}>
|
|
89
|
+
<Text size="sm" tone="muted">
|
|
90
|
+
The chevron alone
|
|
91
|
+
</Text>
|
|
92
|
+
<Tree
|
|
93
|
+
aria-label="Categories, opened by the chevron"
|
|
94
|
+
expandOn="expander"
|
|
95
|
+
defaultExpandedKeys={['beverages']}
|
|
96
|
+
nodes={CATEGORIES}
|
|
97
|
+
getKey={(category) => category.id}
|
|
98
|
+
getLabel={(category) => category.name}
|
|
99
|
+
getChildren={(category) => category.children}
|
|
100
|
+
/>
|
|
101
|
+
</Stack>
|
|
102
|
+
</Grid>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### One choice, several, or none
|
|
108
|
+
|
|
109
|
+
Three trees side by side. The multi-select one writes aria-checked and draws a box; the single one writes aria-selected and says it with the band; the third writes neither.
|
|
110
|
+
|
|
111
|
+
Excerpt — not a complete module
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
<Tree
|
|
115
|
+
aria-label="Permissions"
|
|
116
|
+
selectionMode="multiple"
|
|
117
|
+
defaultValue={['revenue']}
|
|
118
|
+
defaultExpandedKeys={['reports']}
|
|
119
|
+
>
|
|
120
|
+
{nodes}
|
|
121
|
+
</Tree>;
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### A branch that takes its descendants with it
|
|
125
|
+
|
|
126
|
+
Press the folder and watch every enabled file under it follow, including the ones inside a branch that is closed. The locked file is left exactly where it was.
|
|
127
|
+
|
|
128
|
+
Example
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
import { Tree } from '@slotted/react/tree';
|
|
132
|
+
|
|
133
|
+
interface Scope {
|
|
134
|
+
id: string;
|
|
135
|
+
name: string;
|
|
136
|
+
locked?: boolean;
|
|
137
|
+
children?: Scope[];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const SCOPES: Scope[] = [
|
|
141
|
+
{
|
|
142
|
+
id: 'orders',
|
|
143
|
+
name: 'Orders',
|
|
144
|
+
children: [
|
|
145
|
+
{ id: 'orders.view', name: 'View orders' },
|
|
146
|
+
{ id: 'orders.edit', name: 'Edit orders' },
|
|
147
|
+
{ id: 'orders.refund', name: 'Issue refunds' },
|
|
148
|
+
],
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
id: 'finance',
|
|
152
|
+
name: 'Finance',
|
|
153
|
+
children: [
|
|
154
|
+
{ id: 'finance.invoices', name: 'View invoices' },
|
|
155
|
+
{ id: 'finance.payouts', name: 'Approve payouts', locked: true },
|
|
156
|
+
],
|
|
157
|
+
},
|
|
158
|
+
{ id: 'reports', name: 'Reports' },
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
export default function TreeCascade() {
|
|
162
|
+
return (
|
|
163
|
+
<Tree
|
|
164
|
+
aria-label="Role permissions"
|
|
165
|
+
selectionCascade="descendants"
|
|
166
|
+
selectionMode="multiple"
|
|
167
|
+
expandOn="expander"
|
|
168
|
+
defaultExpandedKeys={['orders', 'finance']}
|
|
169
|
+
defaultValue={['orders.view']}
|
|
170
|
+
isNodeDisabled={(scope) => scope.locked === true}
|
|
171
|
+
nodes={SCOPES}
|
|
172
|
+
getKey={(scope) => scope.id}
|
|
173
|
+
getLabel={(scope) => scope.name}
|
|
174
|
+
getChildren={(scope) => scope.children}
|
|
175
|
+
/>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### How the selection is said
|
|
181
|
+
|
|
182
|
+
The same value under the two indicators. The box states aria-checked and is the box the checkbox family draws; the highlight states aria-selected and spends no cell at all.
|
|
183
|
+
|
|
184
|
+
Example
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
import { Tree } from '@slotted/react/tree';
|
|
188
|
+
|
|
189
|
+
interface Category {
|
|
190
|
+
id: string;
|
|
191
|
+
name: string;
|
|
192
|
+
children?: Category[];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const CATEGORIES: Category[] = [
|
|
196
|
+
{
|
|
197
|
+
id: 'beverages',
|
|
198
|
+
name: 'Beverages',
|
|
199
|
+
children: [
|
|
200
|
+
{ id: 'coffee', name: 'Coffee' },
|
|
201
|
+
{ id: 'tea', name: 'Tea' },
|
|
202
|
+
{ id: 'soft-drinks', name: 'Soft drinks' },
|
|
203
|
+
],
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
id: 'pantry',
|
|
207
|
+
name: 'Pantry',
|
|
208
|
+
children: [
|
|
209
|
+
{ id: 'oils', name: 'Oils and vinegars' },
|
|
210
|
+
{
|
|
211
|
+
id: 'spices',
|
|
212
|
+
name: 'Spices',
|
|
213
|
+
children: [
|
|
214
|
+
{ id: 'ground-spices', name: 'Ground spices' },
|
|
215
|
+
{ id: 'whole-spices', name: 'Whole spices' },
|
|
216
|
+
],
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
},
|
|
220
|
+
{ id: 'household', name: 'Household' },
|
|
221
|
+
];
|
|
222
|
+
|
|
223
|
+
export default function TreeIndicator() {
|
|
224
|
+
return (
|
|
225
|
+
<Tree
|
|
226
|
+
aria-label="Default category"
|
|
227
|
+
selectionIndicator="checkbox"
|
|
228
|
+
defaultExpandedKeys={['beverages']}
|
|
229
|
+
defaultValue="tea"
|
|
230
|
+
nodes={CATEGORIES}
|
|
231
|
+
getKey={(category) => category.id}
|
|
232
|
+
getLabel={(category) => category.name}
|
|
233
|
+
getChildren={(category) => category.children}
|
|
234
|
+
/>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### The lines that say which parent a row belongs to
|
|
240
|
+
|
|
241
|
+
Depth four with the guides on and off. Each line sits under the chevron of the level above it, at one distance from the row it belongs to, at every size.
|
|
242
|
+
|
|
243
|
+
Example
|
|
244
|
+
|
|
245
|
+
```tsx
|
|
246
|
+
import { Grid } from '@slotted/react/grid';
|
|
247
|
+
import { Tree } from '@slotted/react/tree';
|
|
248
|
+
|
|
249
|
+
interface Category {
|
|
250
|
+
id: string;
|
|
251
|
+
name: string;
|
|
252
|
+
children?: Category[];
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const CATEGORIES: Category[] = [
|
|
256
|
+
{
|
|
257
|
+
id: 'beverages',
|
|
258
|
+
name: 'Beverages',
|
|
259
|
+
children: [
|
|
260
|
+
{ id: 'coffee', name: 'Coffee' },
|
|
261
|
+
{ id: 'tea', name: 'Tea' },
|
|
262
|
+
{ id: 'soft-drinks', name: 'Soft drinks' },
|
|
263
|
+
],
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
id: 'pantry',
|
|
267
|
+
name: 'Pantry',
|
|
268
|
+
children: [
|
|
269
|
+
{ id: 'oils', name: 'Oils and vinegars' },
|
|
270
|
+
{
|
|
271
|
+
id: 'spices',
|
|
272
|
+
name: 'Spices',
|
|
273
|
+
children: [
|
|
274
|
+
{ id: 'ground-spices', name: 'Ground spices' },
|
|
275
|
+
{ id: 'whole-spices', name: 'Whole spices' },
|
|
276
|
+
],
|
|
277
|
+
},
|
|
278
|
+
],
|
|
279
|
+
},
|
|
280
|
+
{ id: 'household', name: 'Household' },
|
|
281
|
+
];
|
|
282
|
+
|
|
283
|
+
export default function TreeGuides() {
|
|
284
|
+
return (
|
|
285
|
+
<Grid columns={2} gap={6} minItemWidth="xs">
|
|
286
|
+
<Tree
|
|
287
|
+
aria-label="Categories with guides"
|
|
288
|
+
defaultExpandedKeys={['pantry', 'spices']}
|
|
289
|
+
nodes={CATEGORIES}
|
|
290
|
+
getKey={(category) => category.id}
|
|
291
|
+
getLabel={(category) => category.name}
|
|
292
|
+
getChildren={(category) => category.children}
|
|
293
|
+
/>
|
|
294
|
+
<Tree
|
|
295
|
+
aria-label="Categories without guides"
|
|
296
|
+
guides={false}
|
|
297
|
+
defaultExpandedKeys={['pantry', 'spices']}
|
|
298
|
+
nodes={CATEGORIES}
|
|
299
|
+
getKey={(category) => category.id}
|
|
300
|
+
getLabel={(category) => category.name}
|
|
301
|
+
getChildren={(category) => category.children}
|
|
302
|
+
/>
|
|
303
|
+
</Grid>
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### The three type steps
|
|
309
|
+
|
|
310
|
+
Small, medium and large in a column. The row height, the type, the glyph and the indent all move together, and the distance from a guide to its chevron does not.
|
|
311
|
+
|
|
312
|
+
Excerpt — not a complete module
|
|
313
|
+
|
|
314
|
+
```tsx
|
|
315
|
+
<Tree aria-label="Files" size="sm" defaultExpandedKeys={['src']}>
|
|
316
|
+
{nodes}
|
|
317
|
+
</Tree>;
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Framed, and inside something that already has an edge
|
|
321
|
+
|
|
322
|
+
The framed tree draws its own box; the plain one draws none, for a panel or a drawer that has drawn one already. Both keep the same row.
|
|
323
|
+
|
|
324
|
+
Excerpt — not a complete module
|
|
325
|
+
|
|
326
|
+
```tsx
|
|
327
|
+
<Tree aria-label="Navigation" variant="plain" defaultExpandedKeys={['reports']}>
|
|
328
|
+
{nodes}
|
|
329
|
+
</Tree>;
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Every state a row can be in
|
|
333
|
+
|
|
334
|
+
At rest, hovered, where the keyboard is, chosen, both at once, out of reach, and fetching. Chosen outranks the keyboard, and disabled outranks everything.
|
|
335
|
+
|
|
336
|
+
Example
|
|
337
|
+
|
|
338
|
+
```tsx
|
|
339
|
+
import { Grid } from '@slotted/react/grid';
|
|
340
|
+
import { Stack } from '@slotted/react/stack';
|
|
341
|
+
import { Tree } from '@slotted/react/tree';
|
|
342
|
+
import { Text } from '@slotted/react/typography';
|
|
343
|
+
|
|
344
|
+
interface Scope {
|
|
345
|
+
id: string;
|
|
346
|
+
name: string;
|
|
347
|
+
locked?: boolean;
|
|
348
|
+
children?: Scope[];
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const SCOPES: Scope[] = [
|
|
352
|
+
{
|
|
353
|
+
id: 'orders',
|
|
354
|
+
name: 'Orders',
|
|
355
|
+
children: [
|
|
356
|
+
{ id: 'orders.view', name: 'View orders' },
|
|
357
|
+
{ id: 'orders.edit', name: 'Edit orders' },
|
|
358
|
+
{ id: 'orders.refund', name: 'Issue refunds' },
|
|
359
|
+
],
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
id: 'finance',
|
|
363
|
+
name: 'Finance',
|
|
364
|
+
children: [
|
|
365
|
+
{ id: 'finance.invoices', name: 'View invoices' },
|
|
366
|
+
{ id: 'finance.payouts', name: 'Approve payouts', locked: true },
|
|
367
|
+
],
|
|
368
|
+
},
|
|
369
|
+
{ id: 'reports', name: 'Reports' },
|
|
370
|
+
];
|
|
371
|
+
|
|
372
|
+
export default function TreeStates() {
|
|
373
|
+
return (
|
|
374
|
+
<Grid columns={2} gap={6} minItemWidth="xs">
|
|
375
|
+
<Stack gap={2}>
|
|
376
|
+
<Text size="sm" tone="muted">
|
|
377
|
+
One node disabled
|
|
378
|
+
</Text>
|
|
379
|
+
<Tree
|
|
380
|
+
aria-label="Permissions, one node disabled"
|
|
381
|
+
isNodeDisabled={(scope) => scope.locked === true}
|
|
382
|
+
selectionMode="multiple"
|
|
383
|
+
defaultExpandedKeys={['finance']}
|
|
384
|
+
defaultValue={['finance.invoices']}
|
|
385
|
+
nodes={SCOPES}
|
|
386
|
+
getKey={(scope) => scope.id}
|
|
387
|
+
getLabel={(scope) => scope.name}
|
|
388
|
+
getChildren={(scope) => scope.children}
|
|
389
|
+
/>
|
|
390
|
+
</Stack>
|
|
391
|
+
<Stack gap={2}>
|
|
392
|
+
<Text size="sm" tone="muted">
|
|
393
|
+
Read only
|
|
394
|
+
</Text>
|
|
395
|
+
<Tree
|
|
396
|
+
aria-label="Permissions, read only"
|
|
397
|
+
readOnly
|
|
398
|
+
selectionMode="multiple"
|
|
399
|
+
defaultExpandedKeys={['finance']}
|
|
400
|
+
defaultValue={['finance.invoices']}
|
|
401
|
+
nodes={SCOPES}
|
|
402
|
+
getKey={(scope) => scope.id}
|
|
403
|
+
getLabel={(scope) => scope.name}
|
|
404
|
+
getChildren={(scope) => scope.children}
|
|
405
|
+
/>
|
|
406
|
+
</Stack>
|
|
407
|
+
<Stack gap={2}>
|
|
408
|
+
<Text size="sm" tone="muted">
|
|
409
|
+
Disabled
|
|
410
|
+
</Text>
|
|
411
|
+
<Tree
|
|
412
|
+
aria-label="Permissions, disabled"
|
|
413
|
+
disabled
|
|
414
|
+
selectionMode="multiple"
|
|
415
|
+
defaultExpandedKeys={['finance']}
|
|
416
|
+
defaultValue={['finance.invoices']}
|
|
417
|
+
nodes={SCOPES}
|
|
418
|
+
getKey={(scope) => scope.id}
|
|
419
|
+
getLabel={(scope) => scope.name}
|
|
420
|
+
getChildren={(scope) => scope.children}
|
|
421
|
+
/>
|
|
422
|
+
</Stack>
|
|
423
|
+
<Stack gap={2}>
|
|
424
|
+
<Text size="sm" tone="muted">
|
|
425
|
+
Invalid
|
|
426
|
+
</Text>
|
|
427
|
+
<Tree
|
|
428
|
+
aria-label="Permissions, invalid"
|
|
429
|
+
invalid
|
|
430
|
+
variant="framed"
|
|
431
|
+
selectionMode="multiple"
|
|
432
|
+
defaultExpandedKeys={['finance']}
|
|
433
|
+
defaultValue={['finance.invoices']}
|
|
434
|
+
nodes={SCOPES}
|
|
435
|
+
getKey={(scope) => scope.id}
|
|
436
|
+
getLabel={(scope) => scope.name}
|
|
437
|
+
getChildren={(scope) => scope.children}
|
|
438
|
+
/>
|
|
439
|
+
</Stack>
|
|
440
|
+
</Grid>
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
### Nothing yet, and nothing at all
|
|
446
|
+
|
|
447
|
+
A tree still loading its roots, and one whose query matched nothing. The empty part replaces no row: the tree keeps its name and its role either way.
|
|
448
|
+
|
|
449
|
+
Excerpt — not a complete module
|
|
450
|
+
|
|
451
|
+
```tsx
|
|
452
|
+
<Tree aria-label="Files" nodes={[]} getKey={(node) => node.id} emptyContent="No files here" />;
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
### Children that arrive after the branch opens
|
|
456
|
+
|
|
457
|
+
Press the folder. The request goes out, the ring stands where the chevron stood, the group says aria-busy, and the placeholder rows are the width names would have been.
|
|
458
|
+
|
|
459
|
+
Excerpt — not a complete module
|
|
460
|
+
|
|
461
|
+
```tsx
|
|
462
|
+
<Tree
|
|
463
|
+
aria-label="Files"
|
|
464
|
+
nodes={roots}
|
|
465
|
+
getKey={(node) => node.id}
|
|
466
|
+
hasChildren={(node) => node.type === 'folder'}
|
|
467
|
+
getChildrenCount={(node) => node.count}
|
|
468
|
+
isNodeLoading={(node) => pending.has(node.id)}
|
|
469
|
+
onExpandedKeysChange={(keys, request) => {
|
|
470
|
+
if (request.reason !== 'programmatic') fetchChildren(keys);
|
|
471
|
+
setExpanded(keys);
|
|
472
|
+
}}
|
|
473
|
+
/>;
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
### Searching a tree without losing where things are
|
|
477
|
+
|
|
478
|
+
Type in the field. Every hit keeps its ancestors, the matched span is marked, and the path is held open for as long as the query lasts without moving the set the reader opened.
|
|
479
|
+
|
|
480
|
+
Example
|
|
481
|
+
|
|
482
|
+
```tsx
|
|
483
|
+
import { useState } from 'react';
|
|
484
|
+
import { Glyph, Icon } from '@slotted/react/icon';
|
|
485
|
+
import { Stack } from '@slotted/react/stack';
|
|
486
|
+
import { TextField } from '@slotted/react/text-field';
|
|
487
|
+
import { Tree } from '@slotted/react/tree';
|
|
488
|
+
|
|
489
|
+
interface Category {
|
|
490
|
+
id: string;
|
|
491
|
+
name: string;
|
|
492
|
+
children?: Category[];
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
const CATEGORIES: Category[] = [
|
|
496
|
+
{
|
|
497
|
+
id: 'beverages',
|
|
498
|
+
name: 'Beverages',
|
|
499
|
+
children: [
|
|
500
|
+
{ id: 'coffee', name: 'Coffee' },
|
|
501
|
+
{ id: 'tea', name: 'Tea' },
|
|
502
|
+
{ id: 'soft-drinks', name: 'Soft drinks' },
|
|
503
|
+
],
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
id: 'pantry',
|
|
507
|
+
name: 'Pantry',
|
|
508
|
+
children: [
|
|
509
|
+
{ id: 'oils', name: 'Oils and vinegars' },
|
|
510
|
+
{
|
|
511
|
+
id: 'spices',
|
|
512
|
+
name: 'Spices',
|
|
513
|
+
children: [
|
|
514
|
+
{ id: 'ground-spices', name: 'Ground spices' },
|
|
515
|
+
{ id: 'whole-spices', name: 'Whole spices' },
|
|
516
|
+
],
|
|
517
|
+
},
|
|
518
|
+
],
|
|
519
|
+
},
|
|
520
|
+
{ id: 'household', name: 'Household' },
|
|
521
|
+
];
|
|
522
|
+
|
|
523
|
+
export default function TreeFiltering() {
|
|
524
|
+
const [query, setQuery] = useState('spice');
|
|
525
|
+
|
|
526
|
+
return (
|
|
527
|
+
<Stack gap={3}>
|
|
528
|
+
<TextField
|
|
529
|
+
aria-label="Find a category"
|
|
530
|
+
clearable
|
|
531
|
+
onValueChange={(next) => setQuery(next)}
|
|
532
|
+
start={
|
|
533
|
+
<Icon>
|
|
534
|
+
<Glyph name="search" />
|
|
535
|
+
</Icon>
|
|
536
|
+
}
|
|
537
|
+
type="search"
|
|
538
|
+
value={query}
|
|
539
|
+
/>
|
|
540
|
+
<Tree
|
|
541
|
+
aria-label="Product categories"
|
|
542
|
+
emptyContent="No category matches"
|
|
543
|
+
query={query}
|
|
544
|
+
nodes={CATEGORIES}
|
|
545
|
+
getKey={(category) => category.id}
|
|
546
|
+
getLabel={(category) => category.name}
|
|
547
|
+
getChildren={(category) => category.children}
|
|
548
|
+
/>
|
|
549
|
+
</Stack>
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
### Four thousand rows, and the ones on screen
|
|
555
|
+
|
|
556
|
+
Scroll it. Only the covered slice is rendered, the rows are laid flat with their level stated, and the node the keyboard is on stays in the document however far it is scrolled away.
|
|
557
|
+
|
|
558
|
+
Example
|
|
559
|
+
|
|
560
|
+
```tsx
|
|
561
|
+
import { Tree } from '@slotted/react/tree';
|
|
562
|
+
|
|
563
|
+
interface OrderNode {
|
|
564
|
+
id: string;
|
|
565
|
+
name: string;
|
|
566
|
+
children?: OrderNode[];
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
const MONTHS: OrderNode[] = Array.from({ length: 24 }, (_, month) => {
|
|
570
|
+
const id = `${2025 + Math.floor(month / 12)}-${String((month % 12) + 1).padStart(2, '0')}`;
|
|
571
|
+
return {
|
|
572
|
+
id,
|
|
573
|
+
name: id,
|
|
574
|
+
children: Array.from({ length: 150 }, (_entry, index) => ({
|
|
575
|
+
id: `${id}-${index}`,
|
|
576
|
+
name: `SO-${10000 + month * 150 + index}`,
|
|
577
|
+
})),
|
|
578
|
+
};
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
export default function TreeVirtualization() {
|
|
582
|
+
return (
|
|
583
|
+
<Tree
|
|
584
|
+
aria-label="Orders by month"
|
|
585
|
+
variant="framed"
|
|
586
|
+
virtual
|
|
587
|
+
itemSize={34}
|
|
588
|
+
defaultExpandedKeys={MONTHS.map((month) => month.id)}
|
|
589
|
+
nodes={MONTHS}
|
|
590
|
+
getKey={(node) => node.id}
|
|
591
|
+
getLabel={(node) => node.name}
|
|
592
|
+
getChildren={(node) => node.children}
|
|
593
|
+
/>
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
### Content the tree did not choose
|
|
599
|
+
|
|
600
|
+
A name that is one unbroken token, a translated name twice the length, and a right-to-left name in a left-to-right tree. Each takes its own direction and truncates rather than pushing the count out.
|
|
601
|
+
|
|
602
|
+
Excerpt — not a complete module
|
|
603
|
+
|
|
604
|
+
```tsx
|
|
605
|
+
<TreeNode
|
|
606
|
+
value="report"
|
|
607
|
+
label="quarterly-report-2026.pdf"
|
|
608
|
+
description="edited"
|
|
609
|
+
icon={<FileIcon />}
|
|
610
|
+
meta="18 kB"
|
|
611
|
+
/>;
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
### A tree that submits
|
|
615
|
+
|
|
616
|
+
One hidden input per chosen key, under the name the form reads. The tree is the control, and a bare form carries the set without a controlled value anywhere.
|
|
617
|
+
|
|
618
|
+
Excerpt — not a complete module
|
|
619
|
+
|
|
620
|
+
```tsx
|
|
621
|
+
<form action="/permissions" method="post">
|
|
622
|
+
<Tree aria-label="Permissions" name="scopes" selectionMode="multiple">
|
|
623
|
+
{nodes}
|
|
624
|
+
</Tree>
|
|
625
|
+
<Button type="submit">Save</Button>
|
|
626
|
+
</form>;
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
### What a consumer can put in a row, and set once
|
|
630
|
+
|
|
631
|
+
A row with an icon, a count and a trailing control, beside a provider that gives every tree under it the same size and the same expansion target.
|
|
632
|
+
|
|
633
|
+
Excerpt — not a complete module
|
|
634
|
+
|
|
635
|
+
```tsx
|
|
636
|
+
<TreeDefaultsProvider size="sm" expandOn="expander" guides={false}>
|
|
637
|
+
<Tree aria-label="Files">{nodes}</Tree>
|
|
638
|
+
</TreeDefaultsProvider>;
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
### Every key the pattern gives a tree
|
|
642
|
+
|
|
643
|
+
Tab in and try them: the sideways arrows open, enter and leave a branch; Home and End cross the whole list; the asterisk opens every sibling at the level.
|
|
644
|
+
|
|
645
|
+
Excerpt — not a complete module
|
|
646
|
+
|
|
647
|
+
```tsx
|
|
648
|
+
<Tree
|
|
649
|
+
aria-label="Files"
|
|
650
|
+
activeKey={active}
|
|
651
|
+
onActiveKeyChange={(key, request) => {
|
|
652
|
+
if (request.reason === 'keyboard') announce(key);
|
|
653
|
+
setActive(key);
|
|
654
|
+
}}
|
|
655
|
+
>
|
|
656
|
+
{nodes}
|
|
657
|
+
</Tree>;
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
### What a reader hears
|
|
661
|
+
|
|
662
|
+
The tree carries its own name, each node is named by its own label rather than by the subtree under it, and a branch that is fetching says so through a live region once.
|
|
663
|
+
|
|
664
|
+
Excerpt — not a complete module
|
|
665
|
+
|
|
666
|
+
```tsx
|
|
667
|
+
<Tree aria-labelledby="files-heading">{nodes}</Tree>;
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
### access-editor.tsx
|
|
671
|
+
|
|
672
|
+
Example
|
|
673
|
+
|
|
674
|
+
```tsx
|
|
675
|
+
import { useState } from 'react';
|
|
676
|
+
import { Button } from '@slotted/react/button';
|
|
677
|
+
import { Glyph, Icon } from '@slotted/react/icon';
|
|
678
|
+
import { Inline } from '@slotted/react/inline';
|
|
679
|
+
import { Stack } from '@slotted/react/stack';
|
|
680
|
+
import { TextField } from '@slotted/react/text-field';
|
|
681
|
+
import { Tree } from '@slotted/react/tree';
|
|
682
|
+
import { Text } from '@slotted/react/typography';
|
|
683
|
+
|
|
684
|
+
interface Scope {
|
|
685
|
+
id: string;
|
|
686
|
+
name: string;
|
|
687
|
+
locked?: boolean;
|
|
688
|
+
children?: Scope[];
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
const SCOPES: Scope[] = [
|
|
692
|
+
{
|
|
693
|
+
id: 'orders',
|
|
694
|
+
name: 'Orders',
|
|
695
|
+
children: [
|
|
696
|
+
{ id: 'orders.view', name: 'View orders' },
|
|
697
|
+
{ id: 'orders.edit', name: 'Edit orders' },
|
|
698
|
+
{ id: 'orders.refund', name: 'Issue refunds' },
|
|
699
|
+
],
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
id: 'finance',
|
|
703
|
+
name: 'Finance',
|
|
704
|
+
children: [
|
|
705
|
+
{ id: 'finance.invoices', name: 'View invoices' },
|
|
706
|
+
{ id: 'finance.payouts', name: 'Approve payouts', locked: true },
|
|
707
|
+
],
|
|
708
|
+
},
|
|
709
|
+
{ id: 'reports', name: 'Reports' },
|
|
710
|
+
];
|
|
711
|
+
|
|
712
|
+
export default function TreeAccessEditor() {
|
|
713
|
+
const [query, setQuery] = useState('');
|
|
714
|
+
const [granted, setGranted] = useState<readonly string[]>(['orders.view', 'finance.invoices']);
|
|
715
|
+
const [saved, setSaved] = useState(granted);
|
|
716
|
+
const permissions = granted.filter((key) => key.includes('.') || key === 'reports').length;
|
|
717
|
+
|
|
718
|
+
return (
|
|
719
|
+
<Stack gap={3}>
|
|
720
|
+
<TextField
|
|
721
|
+
aria-label="Find a permission"
|
|
722
|
+
clearable
|
|
723
|
+
onValueChange={(next) => setQuery(next)}
|
|
724
|
+
start={
|
|
725
|
+
<Icon>
|
|
726
|
+
<Glyph name="search" />
|
|
727
|
+
</Icon>
|
|
728
|
+
}
|
|
729
|
+
type="search"
|
|
730
|
+
value={query}
|
|
731
|
+
/>
|
|
732
|
+
<Tree
|
|
733
|
+
aria-label="Permissions of the support role"
|
|
734
|
+
emptyContent="No permission matches"
|
|
735
|
+
expandOn="expander"
|
|
736
|
+
variant="framed"
|
|
737
|
+
selectionCascade="descendants"
|
|
738
|
+
selectionMode="multiple"
|
|
739
|
+
defaultExpandedKeys={['orders', 'finance']}
|
|
740
|
+
isNodeDisabled={(scope) => scope.locked === true}
|
|
741
|
+
onValueChange={(next) => setGranted(next as readonly string[])}
|
|
742
|
+
query={query}
|
|
743
|
+
value={granted}
|
|
744
|
+
renderCells={(scope) => ({ description: scope.locked ? 'Owners only' : undefined })}
|
|
745
|
+
nodes={SCOPES}
|
|
746
|
+
getKey={(scope) => scope.id}
|
|
747
|
+
getLabel={(scope) => scope.name}
|
|
748
|
+
getChildren={(scope) => scope.children}
|
|
749
|
+
/>
|
|
750
|
+
<Inline align="center" gap={3}>
|
|
751
|
+
<Button disabled={saved === granted} onClick={() => setSaved(granted)}>
|
|
752
|
+
Save role
|
|
753
|
+
</Button>
|
|
754
|
+
<Text role="status" size="sm" tone="muted">
|
|
755
|
+
{permissions} permissions granted
|
|
756
|
+
</Text>
|
|
757
|
+
</Inline>
|
|
758
|
+
</Stack>
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
### actions.tsx
|
|
764
|
+
|
|
765
|
+
Example
|
|
766
|
+
|
|
767
|
+
```tsx
|
|
768
|
+
import { useState } from 'react';
|
|
769
|
+
import { IconButton } from '@slotted/react/button';
|
|
770
|
+
import { Glyph } from '@slotted/react/icon';
|
|
771
|
+
import { Menu, MenuContent, MenuItem, MenuTrigger } from '@slotted/react/menu';
|
|
772
|
+
import { Stack } from '@slotted/react/stack';
|
|
773
|
+
import { Tree } from '@slotted/react/tree';
|
|
774
|
+
import { Text } from '@slotted/react/typography';
|
|
775
|
+
|
|
776
|
+
interface Category {
|
|
777
|
+
id: string;
|
|
778
|
+
name: string;
|
|
779
|
+
children?: Category[];
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
const CATEGORIES: Category[] = [
|
|
783
|
+
{
|
|
784
|
+
id: 'beverages',
|
|
785
|
+
name: 'Beverages',
|
|
786
|
+
children: [
|
|
787
|
+
{ id: 'coffee', name: 'Coffee' },
|
|
788
|
+
{ id: 'tea', name: 'Tea' },
|
|
789
|
+
{ id: 'soft-drinks', name: 'Soft drinks' },
|
|
790
|
+
],
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
id: 'pantry',
|
|
794
|
+
name: 'Pantry',
|
|
795
|
+
children: [
|
|
796
|
+
{ id: 'oils', name: 'Oils and vinegars' },
|
|
797
|
+
{
|
|
798
|
+
id: 'spices',
|
|
799
|
+
name: 'Spices',
|
|
800
|
+
children: [
|
|
801
|
+
{ id: 'ground-spices', name: 'Ground spices' },
|
|
802
|
+
{ id: 'whole-spices', name: 'Whole spices' },
|
|
803
|
+
],
|
|
804
|
+
},
|
|
805
|
+
],
|
|
806
|
+
},
|
|
807
|
+
{ id: 'household', name: 'Household' },
|
|
808
|
+
];
|
|
809
|
+
|
|
810
|
+
export default function TreeActionsExample() {
|
|
811
|
+
const [last, setLast] = useState('No action yet.');
|
|
812
|
+
|
|
813
|
+
return (
|
|
814
|
+
<Stack gap={3}>
|
|
815
|
+
<Tree
|
|
816
|
+
aria-label="Product categories"
|
|
817
|
+
defaultExpandedKeys={['beverages']}
|
|
818
|
+
renderCells={(category) => ({
|
|
819
|
+
actions: (
|
|
820
|
+
<Menu align="end">
|
|
821
|
+
<MenuTrigger
|
|
822
|
+
render={(props) => (
|
|
823
|
+
<IconButton
|
|
824
|
+
{...props}
|
|
825
|
+
aria-label={`Actions for ${category.name}`}
|
|
826
|
+
size="sm"
|
|
827
|
+
variant="ghost"
|
|
828
|
+
>
|
|
829
|
+
<Glyph name="ellipsis" />
|
|
830
|
+
</IconButton>
|
|
831
|
+
)}
|
|
832
|
+
/>
|
|
833
|
+
<MenuContent>
|
|
834
|
+
<MenuItem onSelect={() => setLast(`Rename ${category.name}.`)}>Rename…</MenuItem>
|
|
835
|
+
<MenuItem onSelect={() => setLast(`Add a category under ${category.name}.`)}>
|
|
836
|
+
Add a category
|
|
837
|
+
</MenuItem>
|
|
838
|
+
</MenuContent>
|
|
839
|
+
</Menu>
|
|
840
|
+
),
|
|
841
|
+
})}
|
|
842
|
+
nodes={CATEGORIES}
|
|
843
|
+
getKey={(category) => category.id}
|
|
844
|
+
getLabel={(category) => category.name}
|
|
845
|
+
getChildren={(category) => category.children}
|
|
846
|
+
/>
|
|
847
|
+
<Text role="status" size="sm" tone="muted">
|
|
848
|
+
{last}
|
|
849
|
+
</Text>
|
|
850
|
+
</Stack>
|
|
851
|
+
);
|
|
852
|
+
}
|
|
853
|
+
```
|
|
854
|
+
|
|
855
|
+
### catalog.tsx
|
|
856
|
+
|
|
857
|
+
Example
|
|
858
|
+
|
|
859
|
+
```tsx
|
|
860
|
+
import { useState } from 'react';
|
|
861
|
+
import { Grid } from '@slotted/react/grid';
|
|
862
|
+
import { List, ListEmpty } from '@slotted/react/list';
|
|
863
|
+
import {
|
|
864
|
+
ListItem,
|
|
865
|
+
ListItemBody,
|
|
866
|
+
ListItemContent,
|
|
867
|
+
ListItemEnd,
|
|
868
|
+
ListItemLabel,
|
|
869
|
+
} from '@slotted/react/list-item';
|
|
870
|
+
import { Tree } from '@slotted/react/tree';
|
|
871
|
+
|
|
872
|
+
interface Category {
|
|
873
|
+
id: string;
|
|
874
|
+
name: string;
|
|
875
|
+
children?: Category[];
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
const CATEGORIES: Category[] = [
|
|
879
|
+
{
|
|
880
|
+
id: 'beverages',
|
|
881
|
+
name: 'Beverages',
|
|
882
|
+
children: [
|
|
883
|
+
{ id: 'coffee', name: 'Coffee' },
|
|
884
|
+
{ id: 'tea', name: 'Tea' },
|
|
885
|
+
{ id: 'soft-drinks', name: 'Soft drinks' },
|
|
886
|
+
],
|
|
887
|
+
},
|
|
888
|
+
{
|
|
889
|
+
id: 'pantry',
|
|
890
|
+
name: 'Pantry',
|
|
891
|
+
children: [
|
|
892
|
+
{ id: 'oils', name: 'Oils and vinegars' },
|
|
893
|
+
{
|
|
894
|
+
id: 'spices',
|
|
895
|
+
name: 'Spices',
|
|
896
|
+
children: [
|
|
897
|
+
{ id: 'ground-spices', name: 'Ground spices' },
|
|
898
|
+
{ id: 'whole-spices', name: 'Whole spices' },
|
|
899
|
+
],
|
|
900
|
+
},
|
|
901
|
+
],
|
|
902
|
+
},
|
|
903
|
+
{ id: 'household', name: 'Household' },
|
|
904
|
+
];
|
|
905
|
+
|
|
906
|
+
const PRODUCTS = [
|
|
907
|
+
{ sku: 'BEV-104', name: 'House blend, 1 kg', category: 'coffee' },
|
|
908
|
+
{ sku: 'BEV-131', name: 'Decaf espresso, 500 g', category: 'coffee' },
|
|
909
|
+
{ sku: 'BEV-220', name: 'Earl grey, 50 bags', category: 'tea' },
|
|
910
|
+
{ sku: 'BEV-305', name: 'Ginger ale, 24 cans', category: 'soft-drinks' },
|
|
911
|
+
{ sku: 'PAN-012', name: 'Olive oil, 5 L', category: 'oils' },
|
|
912
|
+
{ sku: 'PAN-118', name: 'Smoked paprika, 250 g', category: 'ground-spices' },
|
|
913
|
+
];
|
|
914
|
+
|
|
915
|
+
function keysUnder(categories: Category[], key: string, inside = false): string[] {
|
|
916
|
+
return categories.flatMap((category) => {
|
|
917
|
+
const here = inside || category.id === key;
|
|
918
|
+
return [...(here ? [category.id] : []), ...keysUnder(category.children ?? [], key, here)];
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
export default function TreeCatalog() {
|
|
923
|
+
const [category, setCategory] = useState('beverages');
|
|
924
|
+
const keys = keysUnder(CATEGORIES, category);
|
|
925
|
+
const products = PRODUCTS.filter((product) => keys.includes(product.category));
|
|
926
|
+
|
|
927
|
+
return (
|
|
928
|
+
<Grid columns={2} gap={6} minItemWidth="xs">
|
|
929
|
+
<Tree
|
|
930
|
+
aria-label="Product categories"
|
|
931
|
+
disallowEmptySelection
|
|
932
|
+
expandOn="expander"
|
|
933
|
+
defaultExpandedKeys={['beverages', 'pantry']}
|
|
934
|
+
onValueChange={(next) => setCategory(String(next))}
|
|
935
|
+
value={category}
|
|
936
|
+
nodes={CATEGORIES}
|
|
937
|
+
getKey={(category) => category.id}
|
|
938
|
+
getLabel={(category) => category.name}
|
|
939
|
+
getChildren={(category) => category.children}
|
|
940
|
+
/>
|
|
941
|
+
<List aria-label="Products" variant="framed">
|
|
942
|
+
{products.length === 0 && <ListEmpty>No products in this category</ListEmpty>}
|
|
943
|
+
{products.map((product) => (
|
|
944
|
+
<ListItem key={product.sku}>
|
|
945
|
+
<ListItemContent>
|
|
946
|
+
<ListItemBody>
|
|
947
|
+
<ListItemLabel>{product.name}</ListItemLabel>
|
|
948
|
+
</ListItemBody>
|
|
949
|
+
<ListItemEnd>{product.sku}</ListItemEnd>
|
|
950
|
+
</ListItemContent>
|
|
951
|
+
</ListItem>
|
|
952
|
+
))}
|
|
953
|
+
</List>
|
|
954
|
+
</Grid>
|
|
955
|
+
);
|
|
956
|
+
}
|
|
957
|
+
```
|
|
958
|
+
|
|
959
|
+
### cells.tsx
|
|
960
|
+
|
|
961
|
+
Example
|
|
962
|
+
|
|
963
|
+
```tsx
|
|
964
|
+
import { Tree } from '@slotted/react/tree';
|
|
965
|
+
|
|
966
|
+
interface Location {
|
|
967
|
+
id: string;
|
|
968
|
+
name: string;
|
|
969
|
+
units?: number;
|
|
970
|
+
status?: string;
|
|
971
|
+
children?: Location[];
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
const LOCATIONS: Location[] = [
|
|
975
|
+
{
|
|
976
|
+
id: 'cmh',
|
|
977
|
+
name: 'Columbus, OH',
|
|
978
|
+
children: [
|
|
979
|
+
{ id: 'cmh-a', name: 'Zone A', units: 1840 },
|
|
980
|
+
{ id: 'cmh-b', name: 'Zone B', units: 920, status: 'Counting' },
|
|
981
|
+
],
|
|
982
|
+
},
|
|
983
|
+
{
|
|
984
|
+
id: 'rno',
|
|
985
|
+
name: 'Reno, NV',
|
|
986
|
+
children: [
|
|
987
|
+
{ id: 'rno-a', name: 'Zone A', units: 2310 },
|
|
988
|
+
{ id: 'rno-cold', name: 'Cold storage', units: 415 },
|
|
989
|
+
],
|
|
990
|
+
},
|
|
991
|
+
];
|
|
992
|
+
|
|
993
|
+
export default function TreeCells() {
|
|
994
|
+
return (
|
|
995
|
+
<Tree
|
|
996
|
+
aria-label="Stock locations"
|
|
997
|
+
defaultExpandedKeys={['cmh']}
|
|
998
|
+
renderCells={(location) => ({
|
|
999
|
+
description: location.status,
|
|
1000
|
+
meta: location.units?.toLocaleString('en-US') ?? `${location.children?.length ?? 0} zones`,
|
|
1001
|
+
})}
|
|
1002
|
+
nodes={LOCATIONS}
|
|
1003
|
+
getKey={(location) => location.id}
|
|
1004
|
+
getLabel={(location) => location.name}
|
|
1005
|
+
getChildren={(location) => location.children}
|
|
1006
|
+
/>
|
|
1007
|
+
);
|
|
1008
|
+
}
|
|
1009
|
+
```
|
|
1010
|
+
|
|
1011
|
+
### controlled.tsx
|
|
1012
|
+
|
|
1013
|
+
Example
|
|
1014
|
+
|
|
1015
|
+
```tsx
|
|
1016
|
+
import { useState } from 'react';
|
|
1017
|
+
import { Stack } from '@slotted/react/stack';
|
|
1018
|
+
import { Tree, type TreeValue } from '@slotted/react/tree';
|
|
1019
|
+
import { Text } from '@slotted/react/typography';
|
|
1020
|
+
|
|
1021
|
+
interface Category {
|
|
1022
|
+
id: string;
|
|
1023
|
+
name: string;
|
|
1024
|
+
children?: Category[];
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
const CATEGORIES: Category[] = [
|
|
1028
|
+
{
|
|
1029
|
+
id: 'beverages',
|
|
1030
|
+
name: 'Beverages',
|
|
1031
|
+
children: [
|
|
1032
|
+
{ id: 'coffee', name: 'Coffee' },
|
|
1033
|
+
{ id: 'tea', name: 'Tea' },
|
|
1034
|
+
{ id: 'soft-drinks', name: 'Soft drinks' },
|
|
1035
|
+
],
|
|
1036
|
+
},
|
|
1037
|
+
{
|
|
1038
|
+
id: 'pantry',
|
|
1039
|
+
name: 'Pantry',
|
|
1040
|
+
children: [
|
|
1041
|
+
{ id: 'oils', name: 'Oils and vinegars' },
|
|
1042
|
+
{
|
|
1043
|
+
id: 'spices',
|
|
1044
|
+
name: 'Spices',
|
|
1045
|
+
children: [
|
|
1046
|
+
{ id: 'ground-spices', name: 'Ground spices' },
|
|
1047
|
+
{ id: 'whole-spices', name: 'Whole spices' },
|
|
1048
|
+
],
|
|
1049
|
+
},
|
|
1050
|
+
],
|
|
1051
|
+
},
|
|
1052
|
+
{ id: 'household', name: 'Household' },
|
|
1053
|
+
];
|
|
1054
|
+
|
|
1055
|
+
export default function TreeControlled() {
|
|
1056
|
+
const [value, setValue] = useState<TreeValue>('tea');
|
|
1057
|
+
const [open, setOpen] = useState<readonly string[]>(['beverages']);
|
|
1058
|
+
|
|
1059
|
+
return (
|
|
1060
|
+
<Stack gap={3}>
|
|
1061
|
+
<Tree
|
|
1062
|
+
aria-label="Product categories"
|
|
1063
|
+
expandedKeys={open}
|
|
1064
|
+
onExpandedKeysChange={(keys) => setOpen(keys)}
|
|
1065
|
+
onValueChange={(next) => setValue(next)}
|
|
1066
|
+
value={value}
|
|
1067
|
+
nodes={CATEGORIES}
|
|
1068
|
+
getKey={(category) => category.id}
|
|
1069
|
+
getLabel={(category) => category.name}
|
|
1070
|
+
getChildren={(category) => category.children}
|
|
1071
|
+
/>
|
|
1072
|
+
<Text size="sm" tone="muted">
|
|
1073
|
+
Chosen: {value ?? 'none'}. Open: {open.join(', ') || 'none'}.
|
|
1074
|
+
</Text>
|
|
1075
|
+
</Stack>
|
|
1076
|
+
);
|
|
1077
|
+
}
|
|
1078
|
+
```
|
|
1079
|
+
|
|
1080
|
+
### defaults.tsx
|
|
1081
|
+
|
|
1082
|
+
Example
|
|
1083
|
+
|
|
1084
|
+
```tsx
|
|
1085
|
+
import { Grid } from '@slotted/react/grid';
|
|
1086
|
+
import { Tree, TreeDefaultsProvider } from '@slotted/react/tree';
|
|
1087
|
+
|
|
1088
|
+
interface Category {
|
|
1089
|
+
id: string;
|
|
1090
|
+
name: string;
|
|
1091
|
+
children?: Category[];
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
const CATEGORIES: Category[] = [
|
|
1095
|
+
{
|
|
1096
|
+
id: 'beverages',
|
|
1097
|
+
name: 'Beverages',
|
|
1098
|
+
children: [
|
|
1099
|
+
{ id: 'coffee', name: 'Coffee' },
|
|
1100
|
+
{ id: 'tea', name: 'Tea' },
|
|
1101
|
+
{ id: 'soft-drinks', name: 'Soft drinks' },
|
|
1102
|
+
],
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
id: 'pantry',
|
|
1106
|
+
name: 'Pantry',
|
|
1107
|
+
children: [
|
|
1108
|
+
{ id: 'oils', name: 'Oils and vinegars' },
|
|
1109
|
+
{
|
|
1110
|
+
id: 'spices',
|
|
1111
|
+
name: 'Spices',
|
|
1112
|
+
children: [
|
|
1113
|
+
{ id: 'ground-spices', name: 'Ground spices' },
|
|
1114
|
+
{ id: 'whole-spices', name: 'Whole spices' },
|
|
1115
|
+
],
|
|
1116
|
+
},
|
|
1117
|
+
],
|
|
1118
|
+
},
|
|
1119
|
+
{ id: 'household', name: 'Household' },
|
|
1120
|
+
];
|
|
1121
|
+
|
|
1122
|
+
export default function TreeDefaultsExample() {
|
|
1123
|
+
return (
|
|
1124
|
+
<TreeDefaultsProvider expandOn="expander" guides={false} size="sm">
|
|
1125
|
+
<Grid columns={2} gap={6} minItemWidth="xs">
|
|
1126
|
+
<Tree
|
|
1127
|
+
aria-label="Categories"
|
|
1128
|
+
defaultExpandedKeys={['beverages']}
|
|
1129
|
+
nodes={CATEGORIES}
|
|
1130
|
+
getKey={(category) => category.id}
|
|
1131
|
+
getLabel={(category) => category.name}
|
|
1132
|
+
getChildren={(category) => category.children}
|
|
1133
|
+
/>
|
|
1134
|
+
<Tree
|
|
1135
|
+
aria-label="Categories with guides"
|
|
1136
|
+
guides
|
|
1137
|
+
defaultExpandedKeys={['beverages']}
|
|
1138
|
+
nodes={CATEGORIES}
|
|
1139
|
+
getKey={(category) => category.id}
|
|
1140
|
+
getLabel={(category) => category.name}
|
|
1141
|
+
getChildren={(category) => category.children}
|
|
1142
|
+
/>
|
|
1143
|
+
</Grid>
|
|
1144
|
+
</TreeDefaultsProvider>
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1147
|
+
```
|
|
1148
|
+
|
|
1149
|
+
### empty.tsx
|
|
1150
|
+
|
|
1151
|
+
Example
|
|
1152
|
+
|
|
1153
|
+
```tsx
|
|
1154
|
+
import { Tree } from '@slotted/react/tree';
|
|
1155
|
+
|
|
1156
|
+
export default function TreeEmpty() {
|
|
1157
|
+
return (
|
|
1158
|
+
<Tree
|
|
1159
|
+
aria-label="Archived categories"
|
|
1160
|
+
variant="framed"
|
|
1161
|
+
emptyContent="No archived categories"
|
|
1162
|
+
nodes={[] as { id: string }[]}
|
|
1163
|
+
getKey={(category) => category.id}
|
|
1164
|
+
/>
|
|
1165
|
+
);
|
|
1166
|
+
}
|
|
1167
|
+
```
|
|
1168
|
+
|
|
1169
|
+
### flat-rows.tsx
|
|
1170
|
+
|
|
1171
|
+
Example
|
|
1172
|
+
|
|
1173
|
+
```tsx
|
|
1174
|
+
import { Tree } from '@slotted/react/tree';
|
|
1175
|
+
|
|
1176
|
+
interface AccountRow {
|
|
1177
|
+
code: string;
|
|
1178
|
+
name: string;
|
|
1179
|
+
level: number;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
const CHART: AccountRow[] = [
|
|
1183
|
+
{ code: '1000', name: 'Assets', level: 0 },
|
|
1184
|
+
{ code: '1100', name: 'Cash and equivalents', level: 1 },
|
|
1185
|
+
{ code: '1110', name: 'Operating account', level: 2 },
|
|
1186
|
+
{ code: '1120', name: 'Payroll account', level: 2 },
|
|
1187
|
+
{ code: '1200', name: 'Receivables', level: 1 },
|
|
1188
|
+
{ code: '2000', name: 'Liabilities', level: 0 },
|
|
1189
|
+
{ code: '2100', name: 'Payables', level: 1 },
|
|
1190
|
+
];
|
|
1191
|
+
|
|
1192
|
+
export default function TreeFlatRows() {
|
|
1193
|
+
return (
|
|
1194
|
+
<Tree
|
|
1195
|
+
aria-label="Chart of accounts"
|
|
1196
|
+
defaultExpandedKeys={['1000', '1100']}
|
|
1197
|
+
nodes={CHART}
|
|
1198
|
+
getKey={(row) => row.code}
|
|
1199
|
+
getLabel={(row) => row.name}
|
|
1200
|
+
getLevel={(row) => row.level}
|
|
1201
|
+
renderCells={(row) => ({ meta: row.code })}
|
|
1202
|
+
/>
|
|
1203
|
+
);
|
|
1204
|
+
}
|
|
1205
|
+
```
|
|
1206
|
+
|
|
1207
|
+
### form.tsx
|
|
1208
|
+
|
|
1209
|
+
Example
|
|
1210
|
+
|
|
1211
|
+
```tsx
|
|
1212
|
+
import { useState } from 'react';
|
|
1213
|
+
import type { SubmitEvent } from 'react';
|
|
1214
|
+
import { Button } from '@slotted/react/button';
|
|
1215
|
+
import { Inline } from '@slotted/react/inline';
|
|
1216
|
+
import { Stack } from '@slotted/react/stack';
|
|
1217
|
+
import { Tree } from '@slotted/react/tree';
|
|
1218
|
+
import { Text } from '@slotted/react/typography';
|
|
1219
|
+
|
|
1220
|
+
interface Category {
|
|
1221
|
+
id: string;
|
|
1222
|
+
name: string;
|
|
1223
|
+
children?: Category[];
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
const CATEGORIES: Category[] = [
|
|
1227
|
+
{
|
|
1228
|
+
id: 'beverages',
|
|
1229
|
+
name: 'Beverages',
|
|
1230
|
+
children: [
|
|
1231
|
+
{ id: 'coffee', name: 'Coffee' },
|
|
1232
|
+
{ id: 'tea', name: 'Tea' },
|
|
1233
|
+
{ id: 'soft-drinks', name: 'Soft drinks' },
|
|
1234
|
+
],
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
id: 'pantry',
|
|
1238
|
+
name: 'Pantry',
|
|
1239
|
+
children: [
|
|
1240
|
+
{ id: 'oils', name: 'Oils and vinegars' },
|
|
1241
|
+
{
|
|
1242
|
+
id: 'spices',
|
|
1243
|
+
name: 'Spices',
|
|
1244
|
+
children: [
|
|
1245
|
+
{ id: 'ground-spices', name: 'Ground spices' },
|
|
1246
|
+
{ id: 'whole-spices', name: 'Whole spices' },
|
|
1247
|
+
],
|
|
1248
|
+
},
|
|
1249
|
+
],
|
|
1250
|
+
},
|
|
1251
|
+
{ id: 'household', name: 'Household' },
|
|
1252
|
+
];
|
|
1253
|
+
|
|
1254
|
+
export default function TreeForm() {
|
|
1255
|
+
const [saved, setSaved] = useState<string | null>(null);
|
|
1256
|
+
|
|
1257
|
+
function handleSubmit(event: SubmitEvent<HTMLFormElement>) {
|
|
1258
|
+
event.preventDefault();
|
|
1259
|
+
const chosen = new FormData(event.currentTarget).getAll('categories');
|
|
1260
|
+
setSaved(`Submitted ${chosen.length} categories.`);
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
return (
|
|
1264
|
+
<form onSubmit={handleSubmit}>
|
|
1265
|
+
<Stack gap={4}>
|
|
1266
|
+
<Tree
|
|
1267
|
+
aria-label="Categories in this feed"
|
|
1268
|
+
name="categories"
|
|
1269
|
+
selectionMode="multiple"
|
|
1270
|
+
defaultExpandedKeys={['beverages']}
|
|
1271
|
+
defaultValue={['coffee', 'tea']}
|
|
1272
|
+
nodes={CATEGORIES}
|
|
1273
|
+
getKey={(category) => category.id}
|
|
1274
|
+
getLabel={(category) => category.name}
|
|
1275
|
+
getChildren={(category) => category.children}
|
|
1276
|
+
/>
|
|
1277
|
+
<Inline align="center" gap={3}>
|
|
1278
|
+
<Button type="submit">Save feed</Button>
|
|
1279
|
+
{saved && (
|
|
1280
|
+
<Text size="sm" tone="muted">
|
|
1281
|
+
{saved}
|
|
1282
|
+
</Text>
|
|
1283
|
+
)}
|
|
1284
|
+
</Inline>
|
|
1285
|
+
</Stack>
|
|
1286
|
+
</form>
|
|
1287
|
+
);
|
|
1288
|
+
}
|
|
1289
|
+
```
|
|
1290
|
+
|
|
1291
|
+
### icon-by-state.tsx
|
|
1292
|
+
|
|
1293
|
+
Example
|
|
1294
|
+
|
|
1295
|
+
```tsx
|
|
1296
|
+
import { useState } from 'react';
|
|
1297
|
+
import { Glyph, Icon } from '@slotted/react/icon';
|
|
1298
|
+
import { Tree } from '@slotted/react/tree';
|
|
1299
|
+
|
|
1300
|
+
interface Entry {
|
|
1301
|
+
id: string;
|
|
1302
|
+
name: string;
|
|
1303
|
+
children?: Entry[];
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
const FOLDERS: Entry[] = [
|
|
1307
|
+
{
|
|
1308
|
+
id: 'contracts',
|
|
1309
|
+
name: 'Contracts',
|
|
1310
|
+
children: [
|
|
1311
|
+
{ id: 'contoso', name: 'Contoso Foods 2026.pdf' },
|
|
1312
|
+
{ id: 'fabrikam', name: 'Fabrikam Supply 2026.pdf' },
|
|
1313
|
+
{ id: 'atlas', name: 'Atlas Freight renewal.pdf' },
|
|
1314
|
+
],
|
|
1315
|
+
},
|
|
1316
|
+
{
|
|
1317
|
+
id: 'forecasts',
|
|
1318
|
+
name: 'Forecasts',
|
|
1319
|
+
children: [
|
|
1320
|
+
{ id: 'q3', name: 'Q3 demand.xlsx' },
|
|
1321
|
+
{ id: 'q4', name: 'Q4 demand.xlsx' },
|
|
1322
|
+
],
|
|
1323
|
+
},
|
|
1324
|
+
];
|
|
1325
|
+
|
|
1326
|
+
const FOLDER =
|
|
1327
|
+
'M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z';
|
|
1328
|
+
const FOLDER_OPEN =
|
|
1329
|
+
'm6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2';
|
|
1330
|
+
|
|
1331
|
+
function FolderIcon({ open }: { open: boolean }) {
|
|
1332
|
+
return (
|
|
1333
|
+
<Icon>
|
|
1334
|
+
<svg
|
|
1335
|
+
fill="none"
|
|
1336
|
+
stroke="currentColor"
|
|
1337
|
+
strokeLinejoin="round"
|
|
1338
|
+
strokeWidth="2"
|
|
1339
|
+
viewBox="0 0 24 24"
|
|
1340
|
+
>
|
|
1341
|
+
<path d={open ? FOLDER_OPEN : FOLDER} />
|
|
1342
|
+
</svg>
|
|
1343
|
+
</Icon>
|
|
1344
|
+
);
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
export default function TreeIconByState() {
|
|
1348
|
+
const [open, setOpen] = useState<readonly string[]>(['contracts']);
|
|
1349
|
+
|
|
1350
|
+
return (
|
|
1351
|
+
<Tree
|
|
1352
|
+
aria-label="Documents"
|
|
1353
|
+
expandedKeys={open}
|
|
1354
|
+
onExpandedKeysChange={(keys) => setOpen(keys)}
|
|
1355
|
+
renderCells={(entry) => ({
|
|
1356
|
+
icon: entry.children ? (
|
|
1357
|
+
<FolderIcon open={open.includes(entry.id)} />
|
|
1358
|
+
) : (
|
|
1359
|
+
<Icon>
|
|
1360
|
+
<Glyph name="file-text" />
|
|
1361
|
+
</Icon>
|
|
1362
|
+
),
|
|
1363
|
+
})}
|
|
1364
|
+
nodes={FOLDERS}
|
|
1365
|
+
getKey={(entry) => entry.id}
|
|
1366
|
+
getLabel={(entry) => entry.name}
|
|
1367
|
+
getChildren={(entry) => entry.children}
|
|
1368
|
+
/>
|
|
1369
|
+
);
|
|
1370
|
+
}
|
|
1371
|
+
```
|
|
1372
|
+
|
|
1373
|
+
### lazy.tsx
|
|
1374
|
+
|
|
1375
|
+
Example
|
|
1376
|
+
|
|
1377
|
+
```tsx
|
|
1378
|
+
import { useState } from 'react';
|
|
1379
|
+
import { Tree } from '@slotted/react/tree';
|
|
1380
|
+
|
|
1381
|
+
interface Account {
|
|
1382
|
+
id: string;
|
|
1383
|
+
name: string;
|
|
1384
|
+
orders?: number;
|
|
1385
|
+
children?: Account[];
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
const ACCOUNTS: Account[] = [
|
|
1389
|
+
{ id: 'contoso', name: 'Contoso Foods', orders: 3 },
|
|
1390
|
+
{ id: 'fabrikam', name: 'Fabrikam Supply', orders: 2 },
|
|
1391
|
+
{ id: 'atlas', name: 'Atlas Freight' },
|
|
1392
|
+
];
|
|
1393
|
+
|
|
1394
|
+
const ORDERS: Record<string, Account[]> = {
|
|
1395
|
+
contoso: [
|
|
1396
|
+
{ id: 'SO-10482', name: 'SO-10482' },
|
|
1397
|
+
{ id: 'SO-10496', name: 'SO-10496' },
|
|
1398
|
+
{ id: 'SO-10511', name: 'SO-10511' },
|
|
1399
|
+
],
|
|
1400
|
+
fabrikam: [
|
|
1401
|
+
{ id: 'SO-10484', name: 'SO-10484' },
|
|
1402
|
+
{ id: 'SO-10502', name: 'SO-10502' },
|
|
1403
|
+
],
|
|
1404
|
+
};
|
|
1405
|
+
|
|
1406
|
+
export default function TreeLazy() {
|
|
1407
|
+
const [accounts, setAccounts] = useState(ACCOUNTS);
|
|
1408
|
+
const [open, setOpen] = useState<readonly string[]>([]);
|
|
1409
|
+
const [pending, setPending] = useState<readonly string[]>([]);
|
|
1410
|
+
|
|
1411
|
+
function handleOpen(keys: readonly string[]) {
|
|
1412
|
+
setOpen(keys);
|
|
1413
|
+
for (const key of keys.filter((candidate) => !open.includes(candidate))) fetchOrders(key);
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
function fetchOrders(key: string) {
|
|
1417
|
+
const account = accounts.find((candidate) => candidate.id === key);
|
|
1418
|
+
if (account === undefined || account.children !== undefined || pending.includes(key)) return;
|
|
1419
|
+
|
|
1420
|
+
setPending((current) => [...current, key]);
|
|
1421
|
+
setTimeout(() => {
|
|
1422
|
+
setAccounts((current) =>
|
|
1423
|
+
current.map((entry) =>
|
|
1424
|
+
entry.id === key ? { ...entry, children: ORDERS[key] ?? [] } : entry,
|
|
1425
|
+
),
|
|
1426
|
+
);
|
|
1427
|
+
setPending((current) => current.filter((candidate) => candidate !== key));
|
|
1428
|
+
}, 1200);
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
return (
|
|
1432
|
+
<Tree
|
|
1433
|
+
aria-label="Orders by account"
|
|
1434
|
+
expandedKeys={open}
|
|
1435
|
+
onExpandedKeysChange={(keys) => handleOpen(keys)}
|
|
1436
|
+
getChildrenCount={(account) => account.orders}
|
|
1437
|
+
hasChildren={(account) => account.orders !== undefined}
|
|
1438
|
+
isNodeLoading={(account) => pending.includes(account.id)}
|
|
1439
|
+
nodes={accounts}
|
|
1440
|
+
getKey={(account) => account.id}
|
|
1441
|
+
getLabel={(account) => account.name}
|
|
1442
|
+
getChildren={(account) => account.children}
|
|
1443
|
+
/>
|
|
1444
|
+
);
|
|
1445
|
+
}
|
|
1446
|
+
```
|
|
1447
|
+
|
|
1448
|
+
### loading.tsx
|
|
1449
|
+
|
|
1450
|
+
Example
|
|
1451
|
+
|
|
1452
|
+
```tsx
|
|
1453
|
+
import { useEffect, useState } from 'react';
|
|
1454
|
+
import { Button } from '@slotted/react/button';
|
|
1455
|
+
import { Skeleton, SkeletonRegion } from '@slotted/react/skeleton';
|
|
1456
|
+
import { Stack } from '@slotted/react/stack';
|
|
1457
|
+
import { Tree, TreeNode } from '@slotted/react/tree';
|
|
1458
|
+
|
|
1459
|
+
const ROWS = [
|
|
1460
|
+
{ id: 'cmh', name: 'Columbus, OH' },
|
|
1461
|
+
{ id: 'rno', name: 'Reno, NV' },
|
|
1462
|
+
{ id: 'sav', name: 'Savannah, GA' },
|
|
1463
|
+
{ id: 'dfw', name: 'Dallas, TX' },
|
|
1464
|
+
];
|
|
1465
|
+
|
|
1466
|
+
export default function TreeLoading() {
|
|
1467
|
+
const [loading, setLoading] = useState(true);
|
|
1468
|
+
|
|
1469
|
+
useEffect(() => {
|
|
1470
|
+
if (!loading) return;
|
|
1471
|
+
const timer = setTimeout(() => setLoading(false), 1500);
|
|
1472
|
+
return () => clearTimeout(timer);
|
|
1473
|
+
}, [loading]);
|
|
1474
|
+
|
|
1475
|
+
return (
|
|
1476
|
+
<Stack align="start" gap={3}>
|
|
1477
|
+
<Button size="sm" variant="outline" onClick={() => setLoading(true)}>
|
|
1478
|
+
Refresh locations
|
|
1479
|
+
</Button>
|
|
1480
|
+
<SkeletonRegion
|
|
1481
|
+
delay={200}
|
|
1482
|
+
loading={loading}
|
|
1483
|
+
messages={{ label: 'Loading locations' }}
|
|
1484
|
+
minDuration={400}
|
|
1485
|
+
>
|
|
1486
|
+
<Tree aria-label="Stock locations" loading={loading}>
|
|
1487
|
+
{ROWS.map((row) => (
|
|
1488
|
+
<TreeNode
|
|
1489
|
+
hasChildren
|
|
1490
|
+
key={row.id}
|
|
1491
|
+
label={loading ? <Skeleton /> : row.name}
|
|
1492
|
+
textValue={row.name}
|
|
1493
|
+
value={row.id}
|
|
1494
|
+
/>
|
|
1495
|
+
))}
|
|
1496
|
+
</Tree>
|
|
1497
|
+
</SkeletonRegion>
|
|
1498
|
+
</Stack>
|
|
1499
|
+
);
|
|
1500
|
+
}
|
|
1501
|
+
```
|
|
1502
|
+
|
|
1503
|
+
### multiple.tsx
|
|
1504
|
+
|
|
1505
|
+
Example
|
|
1506
|
+
|
|
1507
|
+
```tsx
|
|
1508
|
+
import { Tree } from '@slotted/react/tree';
|
|
1509
|
+
|
|
1510
|
+
interface Category {
|
|
1511
|
+
id: string;
|
|
1512
|
+
name: string;
|
|
1513
|
+
children?: Category[];
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
const CATEGORIES: Category[] = [
|
|
1517
|
+
{
|
|
1518
|
+
id: 'beverages',
|
|
1519
|
+
name: 'Beverages',
|
|
1520
|
+
children: [
|
|
1521
|
+
{ id: 'coffee', name: 'Coffee' },
|
|
1522
|
+
{ id: 'tea', name: 'Tea' },
|
|
1523
|
+
{ id: 'soft-drinks', name: 'Soft drinks' },
|
|
1524
|
+
],
|
|
1525
|
+
},
|
|
1526
|
+
{
|
|
1527
|
+
id: 'pantry',
|
|
1528
|
+
name: 'Pantry',
|
|
1529
|
+
children: [
|
|
1530
|
+
{ id: 'oils', name: 'Oils and vinegars' },
|
|
1531
|
+
{
|
|
1532
|
+
id: 'spices',
|
|
1533
|
+
name: 'Spices',
|
|
1534
|
+
children: [
|
|
1535
|
+
{ id: 'ground-spices', name: 'Ground spices' },
|
|
1536
|
+
{ id: 'whole-spices', name: 'Whole spices' },
|
|
1537
|
+
],
|
|
1538
|
+
},
|
|
1539
|
+
],
|
|
1540
|
+
},
|
|
1541
|
+
{ id: 'household', name: 'Household' },
|
|
1542
|
+
];
|
|
1543
|
+
|
|
1544
|
+
export default function TreeMultiple() {
|
|
1545
|
+
return (
|
|
1546
|
+
<Tree
|
|
1547
|
+
aria-label="Categories on promotion"
|
|
1548
|
+
selectionMode="multiple"
|
|
1549
|
+
defaultExpandedKeys={['beverages', 'pantry']}
|
|
1550
|
+
defaultValue={['coffee', 'oils']}
|
|
1551
|
+
nodes={CATEGORIES}
|
|
1552
|
+
getKey={(category) => category.id}
|
|
1553
|
+
getLabel={(category) => category.name}
|
|
1554
|
+
getChildren={(category) => category.children}
|
|
1555
|
+
/>
|
|
1556
|
+
);
|
|
1557
|
+
}
|
|
1558
|
+
```
|
|
1559
|
+
|
|
1560
|
+
### navigation.tsx
|
|
1561
|
+
|
|
1562
|
+
Example
|
|
1563
|
+
|
|
1564
|
+
```tsx
|
|
1565
|
+
import { useState } from 'react';
|
|
1566
|
+
import { Stack } from '@slotted/react/stack';
|
|
1567
|
+
import { Tree } from '@slotted/react/tree';
|
|
1568
|
+
import { Text } from '@slotted/react/typography';
|
|
1569
|
+
|
|
1570
|
+
interface Page {
|
|
1571
|
+
id: string;
|
|
1572
|
+
name: string;
|
|
1573
|
+
children?: Page[];
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
const PAGES: Page[] = [
|
|
1577
|
+
{
|
|
1578
|
+
id: 'inventory',
|
|
1579
|
+
name: 'Inventory',
|
|
1580
|
+
children: [
|
|
1581
|
+
{ id: 'stock', name: 'Stock levels' },
|
|
1582
|
+
{ id: 'transfers', name: 'Transfers' },
|
|
1583
|
+
{ id: 'counts', name: 'Cycle counts' },
|
|
1584
|
+
],
|
|
1585
|
+
},
|
|
1586
|
+
{
|
|
1587
|
+
id: 'purchasing',
|
|
1588
|
+
name: 'Purchasing',
|
|
1589
|
+
children: [
|
|
1590
|
+
{ id: 'orders', name: 'Purchase orders' },
|
|
1591
|
+
{ id: 'suppliers', name: 'Suppliers' },
|
|
1592
|
+
],
|
|
1593
|
+
},
|
|
1594
|
+
];
|
|
1595
|
+
|
|
1596
|
+
const NAMES = new Map(
|
|
1597
|
+
PAGES.flatMap((page) => [page, ...(page.children ?? [])]).map((page) => [page.id, page.name]),
|
|
1598
|
+
);
|
|
1599
|
+
|
|
1600
|
+
export default function TreeNavigation() {
|
|
1601
|
+
const [page, setPage] = useState('stock');
|
|
1602
|
+
|
|
1603
|
+
return (
|
|
1604
|
+
<Stack gap={3}>
|
|
1605
|
+
<Tree
|
|
1606
|
+
aria-label="Help center"
|
|
1607
|
+
expandOn="expander"
|
|
1608
|
+
selectionMode="none"
|
|
1609
|
+
defaultActiveKey="stock"
|
|
1610
|
+
defaultExpandedKeys={['inventory']}
|
|
1611
|
+
onNodeActivate={setPage}
|
|
1612
|
+
nodes={PAGES}
|
|
1613
|
+
getKey={(entry) => entry.id}
|
|
1614
|
+
getLabel={(entry) => entry.name}
|
|
1615
|
+
getChildren={(entry) => entry.children}
|
|
1616
|
+
/>
|
|
1617
|
+
<Text role="status" size="sm" tone="muted">
|
|
1618
|
+
Open page: {NAMES.get(page)}
|
|
1619
|
+
</Text>
|
|
1620
|
+
</Stack>
|
|
1621
|
+
);
|
|
1622
|
+
}
|
|
1623
|
+
```
|
|
1624
|
+
|
|
1625
|
+
### nodes.tsx
|
|
1626
|
+
|
|
1627
|
+
Example
|
|
1628
|
+
|
|
1629
|
+
```tsx
|
|
1630
|
+
import { useRef } from 'react';
|
|
1631
|
+
import { Button } from '@slotted/react/button';
|
|
1632
|
+
import { Inline } from '@slotted/react/inline';
|
|
1633
|
+
import { Stack } from '@slotted/react/stack';
|
|
1634
|
+
import { Tree, type TreeHandle } from '@slotted/react/tree';
|
|
1635
|
+
|
|
1636
|
+
interface Category {
|
|
1637
|
+
id: string;
|
|
1638
|
+
name: string;
|
|
1639
|
+
children?: Category[];
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
const CATEGORIES: Category[] = [
|
|
1643
|
+
{
|
|
1644
|
+
id: 'beverages',
|
|
1645
|
+
name: 'Beverages',
|
|
1646
|
+
children: [
|
|
1647
|
+
{ id: 'coffee', name: 'Coffee' },
|
|
1648
|
+
{ id: 'tea', name: 'Tea' },
|
|
1649
|
+
{ id: 'soft-drinks', name: 'Soft drinks' },
|
|
1650
|
+
],
|
|
1651
|
+
},
|
|
1652
|
+
{
|
|
1653
|
+
id: 'pantry',
|
|
1654
|
+
name: 'Pantry',
|
|
1655
|
+
children: [
|
|
1656
|
+
{ id: 'oils', name: 'Oils and vinegars' },
|
|
1657
|
+
{
|
|
1658
|
+
id: 'spices',
|
|
1659
|
+
name: 'Spices',
|
|
1660
|
+
children: [
|
|
1661
|
+
{ id: 'ground-spices', name: 'Ground spices' },
|
|
1662
|
+
{ id: 'whole-spices', name: 'Whole spices' },
|
|
1663
|
+
],
|
|
1664
|
+
},
|
|
1665
|
+
],
|
|
1666
|
+
},
|
|
1667
|
+
{ id: 'household', name: 'Household' },
|
|
1668
|
+
];
|
|
1669
|
+
|
|
1670
|
+
export default function TreeNodes() {
|
|
1671
|
+
const tree = useRef<TreeHandle>(null);
|
|
1672
|
+
|
|
1673
|
+
return (
|
|
1674
|
+
<Stack gap={3}>
|
|
1675
|
+
<Inline gap={2}>
|
|
1676
|
+
<Button size="sm" variant="outline" onClick={() => tree.current?.expandAll()}>
|
|
1677
|
+
Expand all
|
|
1678
|
+
</Button>
|
|
1679
|
+
<Button size="sm" variant="outline" onClick={() => tree.current?.collapseAll()}>
|
|
1680
|
+
Collapse all
|
|
1681
|
+
</Button>
|
|
1682
|
+
</Inline>
|
|
1683
|
+
<Tree
|
|
1684
|
+
aria-label="Product categories"
|
|
1685
|
+
handleRef={tree}
|
|
1686
|
+
nodes={CATEGORIES}
|
|
1687
|
+
getKey={(category) => category.id}
|
|
1688
|
+
getLabel={(category) => category.name}
|
|
1689
|
+
getChildren={(category) => category.children}
|
|
1690
|
+
/>
|
|
1691
|
+
</Stack>
|
|
1692
|
+
);
|
|
1693
|
+
}
|
|
1694
|
+
```
|
|
1695
|
+
|
|
1696
|
+
### replace.tsx
|
|
1697
|
+
|
|
1698
|
+
Example
|
|
1699
|
+
|
|
1700
|
+
```tsx
|
|
1701
|
+
import { Tree } from '@slotted/react/tree';
|
|
1702
|
+
|
|
1703
|
+
interface Entry {
|
|
1704
|
+
id: string;
|
|
1705
|
+
name: string;
|
|
1706
|
+
children?: Entry[];
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
const FOLDERS: Entry[] = [
|
|
1710
|
+
{
|
|
1711
|
+
id: 'contracts',
|
|
1712
|
+
name: 'Contracts',
|
|
1713
|
+
children: [
|
|
1714
|
+
{ id: 'contoso', name: 'Contoso Foods 2026.pdf' },
|
|
1715
|
+
{ id: 'fabrikam', name: 'Fabrikam Supply 2026.pdf' },
|
|
1716
|
+
{ id: 'atlas', name: 'Atlas Freight renewal.pdf' },
|
|
1717
|
+
],
|
|
1718
|
+
},
|
|
1719
|
+
{
|
|
1720
|
+
id: 'forecasts',
|
|
1721
|
+
name: 'Forecasts',
|
|
1722
|
+
children: [
|
|
1723
|
+
{ id: 'q3', name: 'Q3 demand.xlsx' },
|
|
1724
|
+
{ id: 'q4', name: 'Q4 demand.xlsx' },
|
|
1725
|
+
],
|
|
1726
|
+
},
|
|
1727
|
+
];
|
|
1728
|
+
|
|
1729
|
+
export default function TreeReplace() {
|
|
1730
|
+
return (
|
|
1731
|
+
<Tree
|
|
1732
|
+
aria-label="Documents"
|
|
1733
|
+
expandOn="expander"
|
|
1734
|
+
selectionBehavior="replace"
|
|
1735
|
+
selectionIndicator="highlight"
|
|
1736
|
+
selectionMode="multiple"
|
|
1737
|
+
defaultExpandedKeys={['contracts', 'forecasts']}
|
|
1738
|
+
defaultValue={['contoso', 'fabrikam']}
|
|
1739
|
+
nodes={FOLDERS}
|
|
1740
|
+
getKey={(entry) => entry.id}
|
|
1741
|
+
getLabel={(entry) => entry.name}
|
|
1742
|
+
getChildren={(entry) => entry.children}
|
|
1743
|
+
/>
|
|
1744
|
+
);
|
|
1745
|
+
}
|
|
1746
|
+
```
|
|
1747
|
+
|
|
1748
|
+
### reveal.tsx
|
|
1749
|
+
|
|
1750
|
+
Example
|
|
1751
|
+
|
|
1752
|
+
```tsx
|
|
1753
|
+
import { useRef, useState } from 'react';
|
|
1754
|
+
import { Button } from '@slotted/react/button';
|
|
1755
|
+
import { Stack } from '@slotted/react/stack';
|
|
1756
|
+
import { Tree, type TreeHandle, type TreeValue } from '@slotted/react/tree';
|
|
1757
|
+
|
|
1758
|
+
interface Place {
|
|
1759
|
+
id: string;
|
|
1760
|
+
name: string;
|
|
1761
|
+
children?: Place[];
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
const PLACES: Place[] = ['CMH', 'RNO', 'SAV'].map((site) => ({
|
|
1765
|
+
id: site,
|
|
1766
|
+
name: `Warehouse ${site}`,
|
|
1767
|
+
children: ['A', 'B', 'C'].map((aisle) => ({
|
|
1768
|
+
id: `${site}-${aisle}`,
|
|
1769
|
+
name: `Aisle ${aisle}`,
|
|
1770
|
+
children: Array.from({ length: 8 }, (_, index) => ({
|
|
1771
|
+
id: `${site}-${aisle}-0${index + 1}`,
|
|
1772
|
+
name: `Bin ${site}-${aisle}-0${index + 1}`,
|
|
1773
|
+
})),
|
|
1774
|
+
})),
|
|
1775
|
+
}));
|
|
1776
|
+
|
|
1777
|
+
export default function TreeReveal() {
|
|
1778
|
+
const tree = useRef<TreeHandle>(null);
|
|
1779
|
+
const [value, setValue] = useState<TreeValue>(null);
|
|
1780
|
+
|
|
1781
|
+
function handleFind() {
|
|
1782
|
+
setValue('SAV-B-06');
|
|
1783
|
+
tree.current?.scrollToKey('SAV-B-06', 'center');
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
return (
|
|
1787
|
+
<Stack align="start" gap={3}>
|
|
1788
|
+
<Button size="sm" variant="outline" onClick={handleFind}>
|
|
1789
|
+
Find bin SAV-B-06
|
|
1790
|
+
</Button>
|
|
1791
|
+
<Tree
|
|
1792
|
+
aria-label="Bins"
|
|
1793
|
+
handleRef={tree}
|
|
1794
|
+
onValueChange={(next) => setValue(next)}
|
|
1795
|
+
value={value}
|
|
1796
|
+
defaultExpandedKeys={['CMH', 'CMH-A']}
|
|
1797
|
+
nodes={PLACES}
|
|
1798
|
+
getKey={(place) => place.id}
|
|
1799
|
+
getLabel={(place) => place.name}
|
|
1800
|
+
getChildren={(place) => place.children}
|
|
1801
|
+
/>
|
|
1802
|
+
</Stack>
|
|
1803
|
+
);
|
|
1804
|
+
}
|
|
1805
|
+
```
|
|
1806
|
+
|
|
1807
|
+
### row-content.tsx
|
|
1808
|
+
|
|
1809
|
+
Example
|
|
1810
|
+
|
|
1811
|
+
```tsx
|
|
1812
|
+
import { Glyph, Icon } from '@slotted/react/icon';
|
|
1813
|
+
import { Tree, TreeNode } from '@slotted/react/tree';
|
|
1814
|
+
|
|
1815
|
+
export default function TreeRowContent() {
|
|
1816
|
+
return (
|
|
1817
|
+
<Tree aria-label="Documents" defaultExpandedKeys={['contracts', 'forecasts']}>
|
|
1818
|
+
<TreeNode value="contracts" label="Contracts" meta="2">
|
|
1819
|
+
<TreeNode
|
|
1820
|
+
value="contoso"
|
|
1821
|
+
label="Contoso Foods 2026.pdf"
|
|
1822
|
+
description="Signed"
|
|
1823
|
+
meta="1.2 MB"
|
|
1824
|
+
icon={
|
|
1825
|
+
<Icon>
|
|
1826
|
+
<Glyph name="file-text" />
|
|
1827
|
+
</Icon>
|
|
1828
|
+
}
|
|
1829
|
+
/>
|
|
1830
|
+
<TreeNode
|
|
1831
|
+
value="fabrikam"
|
|
1832
|
+
label="Fabrikam Supply master services agreement, amended.pdf"
|
|
1833
|
+
description="Draft"
|
|
1834
|
+
meta="840 kB"
|
|
1835
|
+
icon={
|
|
1836
|
+
<Icon>
|
|
1837
|
+
<Glyph name="file-text" />
|
|
1838
|
+
</Icon>
|
|
1839
|
+
}
|
|
1840
|
+
/>
|
|
1841
|
+
</TreeNode>
|
|
1842
|
+
<TreeNode value="forecasts" label="Forecasts" meta="1">
|
|
1843
|
+
<TreeNode
|
|
1844
|
+
value="q4"
|
|
1845
|
+
label="Q4 demand.xlsx"
|
|
1846
|
+
description="Edited today"
|
|
1847
|
+
meta="96 kB"
|
|
1848
|
+
icon={
|
|
1849
|
+
<Icon>
|
|
1850
|
+
<Glyph name="file-spreadsheet" />
|
|
1851
|
+
</Icon>
|
|
1852
|
+
}
|
|
1853
|
+
/>
|
|
1854
|
+
</TreeNode>
|
|
1855
|
+
</Tree>
|
|
1856
|
+
);
|
|
1857
|
+
}
|
|
1858
|
+
```
|
|
1859
|
+
|
|
1860
|
+
### sizes.tsx
|
|
1861
|
+
|
|
1862
|
+
Example
|
|
1863
|
+
|
|
1864
|
+
```tsx
|
|
1865
|
+
import { Grid } from '@slotted/react/grid';
|
|
1866
|
+
import { Tree } from '@slotted/react/tree';
|
|
1867
|
+
|
|
1868
|
+
interface Category {
|
|
1869
|
+
id: string;
|
|
1870
|
+
name: string;
|
|
1871
|
+
children?: Category[];
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
const CATEGORIES: Category[] = [
|
|
1875
|
+
{
|
|
1876
|
+
id: 'beverages',
|
|
1877
|
+
name: 'Beverages',
|
|
1878
|
+
children: [
|
|
1879
|
+
{ id: 'coffee', name: 'Coffee' },
|
|
1880
|
+
{ id: 'tea', name: 'Tea' },
|
|
1881
|
+
{ id: 'soft-drinks', name: 'Soft drinks' },
|
|
1882
|
+
],
|
|
1883
|
+
},
|
|
1884
|
+
{
|
|
1885
|
+
id: 'pantry',
|
|
1886
|
+
name: 'Pantry',
|
|
1887
|
+
children: [
|
|
1888
|
+
{ id: 'oils', name: 'Oils and vinegars' },
|
|
1889
|
+
{
|
|
1890
|
+
id: 'spices',
|
|
1891
|
+
name: 'Spices',
|
|
1892
|
+
children: [
|
|
1893
|
+
{ id: 'ground-spices', name: 'Ground spices' },
|
|
1894
|
+
{ id: 'whole-spices', name: 'Whole spices' },
|
|
1895
|
+
],
|
|
1896
|
+
},
|
|
1897
|
+
],
|
|
1898
|
+
},
|
|
1899
|
+
{ id: 'household', name: 'Household' },
|
|
1900
|
+
];
|
|
1901
|
+
|
|
1902
|
+
export default function TreeSizes() {
|
|
1903
|
+
return (
|
|
1904
|
+
<Grid columns={3} gap={6} minItemWidth="xs">
|
|
1905
|
+
<Tree
|
|
1906
|
+
aria-label="Categories, small"
|
|
1907
|
+
size="sm"
|
|
1908
|
+
defaultExpandedKeys={['beverages']}
|
|
1909
|
+
defaultValue="coffee"
|
|
1910
|
+
nodes={CATEGORIES}
|
|
1911
|
+
getKey={(category) => category.id}
|
|
1912
|
+
getLabel={(category) => category.name}
|
|
1913
|
+
getChildren={(category) => category.children}
|
|
1914
|
+
/>
|
|
1915
|
+
<Tree
|
|
1916
|
+
aria-label="Categories, medium"
|
|
1917
|
+
size="md"
|
|
1918
|
+
defaultExpandedKeys={['beverages']}
|
|
1919
|
+
defaultValue="coffee"
|
|
1920
|
+
nodes={CATEGORIES}
|
|
1921
|
+
getKey={(category) => category.id}
|
|
1922
|
+
getLabel={(category) => category.name}
|
|
1923
|
+
getChildren={(category) => category.children}
|
|
1924
|
+
/>
|
|
1925
|
+
<Tree
|
|
1926
|
+
aria-label="Categories, large"
|
|
1927
|
+
size="lg"
|
|
1928
|
+
defaultExpandedKeys={['beverages']}
|
|
1929
|
+
defaultValue="coffee"
|
|
1930
|
+
nodes={CATEGORIES}
|
|
1931
|
+
getKey={(category) => category.id}
|
|
1932
|
+
getLabel={(category) => category.name}
|
|
1933
|
+
getChildren={(category) => category.children}
|
|
1934
|
+
/>
|
|
1935
|
+
</Grid>
|
|
1936
|
+
);
|
|
1937
|
+
}
|
|
1938
|
+
```
|
|
1939
|
+
|
|
1940
|
+
### variants.tsx
|
|
1941
|
+
|
|
1942
|
+
Example
|
|
1943
|
+
|
|
1944
|
+
```tsx
|
|
1945
|
+
import { Grid } from '@slotted/react/grid';
|
|
1946
|
+
import { Tree } from '@slotted/react/tree';
|
|
1947
|
+
|
|
1948
|
+
interface Category {
|
|
1949
|
+
id: string;
|
|
1950
|
+
name: string;
|
|
1951
|
+
children?: Category[];
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
const CATEGORIES: Category[] = [
|
|
1955
|
+
{
|
|
1956
|
+
id: 'beverages',
|
|
1957
|
+
name: 'Beverages',
|
|
1958
|
+
children: [
|
|
1959
|
+
{ id: 'coffee', name: 'Coffee' },
|
|
1960
|
+
{ id: 'tea', name: 'Tea' },
|
|
1961
|
+
{ id: 'soft-drinks', name: 'Soft drinks' },
|
|
1962
|
+
],
|
|
1963
|
+
},
|
|
1964
|
+
{
|
|
1965
|
+
id: 'pantry',
|
|
1966
|
+
name: 'Pantry',
|
|
1967
|
+
children: [
|
|
1968
|
+
{ id: 'oils', name: 'Oils and vinegars' },
|
|
1969
|
+
{
|
|
1970
|
+
id: 'spices',
|
|
1971
|
+
name: 'Spices',
|
|
1972
|
+
children: [
|
|
1973
|
+
{ id: 'ground-spices', name: 'Ground spices' },
|
|
1974
|
+
{ id: 'whole-spices', name: 'Whole spices' },
|
|
1975
|
+
],
|
|
1976
|
+
},
|
|
1977
|
+
],
|
|
1978
|
+
},
|
|
1979
|
+
{ id: 'household', name: 'Household' },
|
|
1980
|
+
];
|
|
1981
|
+
|
|
1982
|
+
export default function TreeVariants() {
|
|
1983
|
+
return (
|
|
1984
|
+
<Grid columns={2} gap={6} minItemWidth="xs">
|
|
1985
|
+
<Tree
|
|
1986
|
+
aria-label="Categories, plain"
|
|
1987
|
+
variant="plain"
|
|
1988
|
+
defaultExpandedKeys={['beverages']}
|
|
1989
|
+
defaultValue="coffee"
|
|
1990
|
+
nodes={CATEGORIES}
|
|
1991
|
+
getKey={(category) => category.id}
|
|
1992
|
+
getLabel={(category) => category.name}
|
|
1993
|
+
getChildren={(category) => category.children}
|
|
1994
|
+
/>
|
|
1995
|
+
<Tree
|
|
1996
|
+
aria-label="Categories, framed"
|
|
1997
|
+
variant="framed"
|
|
1998
|
+
defaultExpandedKeys={['beverages']}
|
|
1999
|
+
defaultValue="coffee"
|
|
2000
|
+
nodes={CATEGORIES}
|
|
2001
|
+
getKey={(category) => category.id}
|
|
2002
|
+
getLabel={(category) => category.name}
|
|
2003
|
+
getChildren={(category) => category.children}
|
|
2004
|
+
/>
|
|
2005
|
+
</Grid>
|
|
2006
|
+
);
|
|
2007
|
+
}
|
|
2008
|
+
```
|