@bevelo/react 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/accordion-parts.cjs +33 -0
- package/dist/accordion-parts.d.cts +21 -0
- package/dist/accordion-parts.d.ts +21 -0
- package/dist/accordion-parts.js +28 -0
- package/dist/accordion.cjs +182 -0
- package/dist/accordion.d.cts +79 -0
- package/dist/accordion.d.ts +79 -0
- package/dist/accordion.js +176 -0
- package/dist/agent.cjs +56 -0
- package/dist/agent.d.cts +16 -0
- package/dist/agent.d.ts +16 -0
- package/dist/agent.js +1 -0
- package/dist/alert-dialog-CXU7gjLv.js +466 -0
- package/dist/alert-dialog-DrZoqcTb.cjs +543 -0
- package/dist/alert-dialog-Dxcfl30r.d.cts +145 -0
- package/dist/alert-dialog-parts.cjs +50 -0
- package/dist/alert-dialog-parts.d.cts +38 -0
- package/dist/alert-dialog-parts.d.ts +38 -0
- package/dist/alert-dialog-parts.js +44 -0
- package/dist/alert-dialog-rH0B74ee.d.ts +145 -0
- package/dist/alert-dialog.cjs +12 -0
- package/dist/alert-dialog.d.cts +2 -0
- package/dist/alert-dialog.d.ts +2 -0
- package/dist/alert-dialog.js +1 -0
- package/dist/alert-parts.cjs +22 -0
- package/dist/alert-parts.d.cts +14 -0
- package/dist/alert-parts.d.ts +14 -0
- package/dist/alert-parts.js +17 -0
- package/dist/alert.cjs +36 -0
- package/dist/alert.d.cts +25 -0
- package/dist/alert.d.ts +25 -0
- package/dist/alert.js +35 -0
- package/dist/aspect-ratio-parts.cjs +11 -0
- package/dist/aspect-ratio-parts.d.cts +11 -0
- package/dist/aspect-ratio-parts.d.ts +11 -0
- package/dist/aspect-ratio-parts.js +9 -0
- package/dist/aspect-ratio.cjs +15 -0
- package/dist/aspect-ratio.d.cts +13 -0
- package/dist/aspect-ratio.d.ts +13 -0
- package/dist/aspect-ratio.js +14 -0
- package/dist/async-options.cjs +127 -0
- package/dist/async-options.d.cts +34 -0
- package/dist/async-options.d.ts +34 -0
- package/dist/async-options.js +90 -0
- package/dist/autocomplete-parts.cjs +37 -0
- package/dist/autocomplete-parts.d.cts +15 -0
- package/dist/autocomplete-parts.d.ts +15 -0
- package/dist/autocomplete-parts.js +27 -0
- package/dist/autocomplete.cjs +383 -0
- package/dist/autocomplete.d.cts +158 -0
- package/dist/autocomplete.d.ts +158 -0
- package/dist/autocomplete.js +367 -0
- package/dist/avatar.cjs +172 -0
- package/dist/avatar.d.cts +77 -0
- package/dist/avatar.d.ts +77 -0
- package/dist/avatar.js +169 -0
- package/dist/badge.cjs +49 -0
- package/dist/badge.d.cts +48 -0
- package/dist/badge.d.ts +48 -0
- package/dist/badge.js +47 -0
- package/dist/breadcrumb-parts.cjs +47 -0
- package/dist/breadcrumb-parts.d.cts +29 -0
- package/dist/breadcrumb-parts.d.ts +29 -0
- package/dist/breadcrumb-parts.js +40 -0
- package/dist/breadcrumb.cjs +63 -0
- package/dist/breadcrumb.d.cts +28 -0
- package/dist/breadcrumb.d.ts +28 -0
- package/dist/breadcrumb.js +62 -0
- package/dist/button-group.cjs +25 -0
- package/dist/button-group.d.cts +54 -0
- package/dist/button-group.d.ts +54 -0
- package/dist/button-group.js +24 -0
- package/dist/button.cjs +98 -0
- package/dist/button.d.cts +69 -0
- package/dist/button.d.ts +69 -0
- package/dist/button.js +96 -0
- package/dist/calendar-BkpTwyKZ.cjs +1059 -0
- package/dist/calendar-D7gRz8P-.js +964 -0
- package/dist/calendar-DSGMQvRe.d.cts +167 -0
- package/dist/calendar-kEC-wyey.d.ts +167 -0
- package/dist/calendar-parts.cjs +31 -0
- package/dist/calendar-parts.d.cts +13 -0
- package/dist/calendar-parts.d.ts +13 -0
- package/dist/calendar-parts.js +23 -0
- package/dist/calendar.cjs +15 -0
- package/dist/calendar.d.cts +2 -0
- package/dist/calendar.d.ts +2 -0
- package/dist/calendar.js +1 -0
- package/dist/card-Ct7BZgwB.cjs +90 -0
- package/dist/card-Dbqbi_C2.js +85 -0
- package/dist/card-parts.cjs +32 -0
- package/dist/card-parts.d.cts +21 -0
- package/dist/card-parts.d.ts +21 -0
- package/dist/card-parts.js +26 -0
- package/dist/card.cjs +3 -0
- package/dist/card.d.cts +31 -0
- package/dist/card.d.ts +31 -0
- package/dist/card.js +1 -0
- package/dist/carousel-parts.cjs +52 -0
- package/dist/carousel-parts.d.cts +31 -0
- package/dist/carousel-parts.d.ts +31 -0
- package/dist/carousel-parts.js +40 -0
- package/dist/carousel.cjs +288 -0
- package/dist/carousel.d.cts +160 -0
- package/dist/carousel.d.ts +160 -0
- package/dist/carousel.js +277 -0
- package/dist/checkbox-group-C_H-SE-v.cjs +105 -0
- package/dist/checkbox-group-lW8QoRfJ.js +94 -0
- package/dist/checkbox-group-parts.cjs +19 -0
- package/dist/checkbox-group-parts.d.cts +9 -0
- package/dist/checkbox-group-parts.d.ts +9 -0
- package/dist/checkbox-group-parts.js +15 -0
- package/dist/checkbox-group.cjs +3 -0
- package/dist/checkbox-group.d.cts +32 -0
- package/dist/checkbox-group.d.ts +32 -0
- package/dist/checkbox-group.js +1 -0
- package/dist/checkbox-parts.cjs +13 -0
- package/dist/checkbox-parts.d.cts +7 -0
- package/dist/checkbox-parts.d.ts +7 -0
- package/dist/checkbox-parts.js +11 -0
- package/dist/checkbox.cjs +104 -0
- package/dist/checkbox.d.cts +58 -0
- package/dist/checkbox.d.ts +58 -0
- package/dist/checkbox.js +101 -0
- package/dist/children.cjs +177 -0
- package/dist/children.d.cts +18 -0
- package/dist/children.d.ts +18 -0
- package/dist/children.js +175 -0
- package/dist/collapsible-parts.cjs +29 -0
- package/dist/collapsible-parts.d.cts +19 -0
- package/dist/collapsible-parts.d.ts +19 -0
- package/dist/collapsible-parts.js +25 -0
- package/dist/collapsible.cjs +128 -0
- package/dist/collapsible.d.cts +65 -0
- package/dist/collapsible.d.ts +65 -0
- package/dist/collapsible.js +124 -0
- package/dist/color-picker.cjs +305 -0
- package/dist/color-picker.d.cts +164 -0
- package/dist/color-picker.d.ts +164 -0
- package/dist/color-picker.js +290 -0
- package/dist/color.cjs +62 -0
- package/dist/color.d.cts +2 -0
- package/dist/color.d.ts +2 -0
- package/dist/color.js +1 -0
- package/dist/combobox-parts.cjs +31 -0
- package/dist/combobox-parts.d.cts +15 -0
- package/dist/combobox-parts.d.ts +15 -0
- package/dist/combobox-parts.js +23 -0
- package/dist/combobox.cjs +533 -0
- package/dist/combobox.d.cts +211 -0
- package/dist/combobox.d.ts +211 -0
- package/dist/combobox.js +508 -0
- package/dist/command-parts.cjs +40 -0
- package/dist/command-parts.d.cts +16 -0
- package/dist/command-parts.d.ts +16 -0
- package/dist/command-parts.js +29 -0
- package/dist/command.cjs +837 -0
- package/dist/command.d.cts +201 -0
- package/dist/command.d.ts +201 -0
- package/dist/command.js +823 -0
- package/dist/compound-helpers-C--V3vAy.d.ts +75 -0
- package/dist/compound-helpers-C0Sx_vxV.js +490 -0
- package/dist/compound-helpers-Dhm54_n4.cjs +699 -0
- package/dist/compound-helpers-g8EZGzme.d.cts +75 -0
- package/dist/compound-registry-BDVOjXHa.js +118 -0
- package/dist/compound-registry-jhlDoTDR.cjs +141 -0
- package/dist/context-menu-parts.cjs +16 -0
- package/dist/context-menu-parts.d.cts +7 -0
- package/dist/context-menu-parts.d.ts +7 -0
- package/dist/context-menu-parts.js +14 -0
- package/dist/context-menu.cjs +85 -0
- package/dist/context-menu.d.cts +45 -0
- package/dist/context-menu.d.ts +45 -0
- package/dist/context-menu.js +83 -0
- package/dist/controller-C8Z-wsos.d.cts +5 -0
- package/dist/controller-C8Z-wsos.d.ts +5 -0
- package/dist/controller-DEAYKbYU.js +52 -0
- package/dist/controller-DvBz7LNG.cjs +63 -0
- package/dist/date-input-parts.cjs +13 -0
- package/dist/date-input-parts.d.cts +7 -0
- package/dist/date-input-parts.d.ts +7 -0
- package/dist/date-input-parts.js +11 -0
- package/dist/date-input.cjs +156 -0
- package/dist/date-input.d.cts +91 -0
- package/dist/date-input.d.ts +91 -0
- package/dist/date-input.js +153 -0
- package/dist/date-picker-parts.cjs +22 -0
- package/dist/date-picker-parts.d.cts +10 -0
- package/dist/date-picker-parts.d.ts +10 -0
- package/dist/date-picker-parts.js +17 -0
- package/dist/date-picker.cjs +1040 -0
- package/dist/date-picker.d.cts +99 -0
- package/dist/date-picker.d.ts +99 -0
- package/dist/date-picker.js +1024 -0
- package/dist/date.cjs +56 -0
- package/dist/date.d.cts +2 -0
- package/dist/date.d.ts +2 -0
- package/dist/date.js +1 -0
- package/dist/dialog-CUgRlS5R.js +474 -0
- package/dist/dialog-DQ0OOOSi.cjs +533 -0
- package/dist/dialog-parts.cjs +33 -0
- package/dist/dialog-parts.d.cts +27 -0
- package/dist/dialog-parts.d.ts +27 -0
- package/dist/dialog-parts.js +30 -0
- package/dist/dialog-view-DwlJaE43.cjs +157 -0
- package/dist/dialog-view-XeUVTMHa.js +140 -0
- package/dist/dialog.cjs +12 -0
- package/dist/dialog.d.cts +147 -0
- package/dist/dialog.d.ts +147 -0
- package/dist/dialog.js +1 -0
- package/dist/direction-parts.cjs +11 -0
- package/dist/direction-parts.d.cts +11 -0
- package/dist/direction-parts.d.ts +11 -0
- package/dist/direction-parts.js +9 -0
- package/dist/direction.cjs +15 -0
- package/dist/direction.d.cts +13 -0
- package/dist/direction.d.ts +13 -0
- package/dist/direction.js +14 -0
- package/dist/dnd.cjs +148 -0
- package/dist/dnd.d.cts +68 -0
- package/dist/dnd.d.ts +68 -0
- package/dist/dnd.js +143 -0
- package/dist/drawer-parts.cjs +17 -0
- package/dist/drawer-parts.d.cts +12 -0
- package/dist/drawer-parts.d.ts +12 -0
- package/dist/drawer-parts.js +14 -0
- package/dist/drawer.cjs +313 -0
- package/dist/drawer.d.cts +156 -0
- package/dist/drawer.d.ts +156 -0
- package/dist/drawer.js +302 -0
- package/dist/empty-state-parts.cjs +25 -0
- package/dist/empty-state-parts.d.cts +15 -0
- package/dist/empty-state-parts.d.ts +15 -0
- package/dist/empty-state-parts.js +19 -0
- package/dist/empty-state.cjs +35 -0
- package/dist/empty-state.d.cts +20 -0
- package/dist/empty-state.d.ts +20 -0
- package/dist/empty-state.js +34 -0
- package/dist/engine-C1L7buUc.cjs +55 -0
- package/dist/engine-DC0U0oW4.js +44 -0
- package/dist/error-state-parts.cjs +16 -0
- package/dist/error-state-parts.d.cts +12 -0
- package/dist/error-state-parts.d.ts +12 -0
- package/dist/error-state-parts.js +13 -0
- package/dist/error-state.cjs +40 -0
- package/dist/error-state.d.cts +23 -0
- package/dist/error-state.d.ts +23 -0
- package/dist/error-state.js +39 -0
- package/dist/field-6rggafk5.js +490 -0
- package/dist/field-DYx_FkJo.d.cts +117 -0
- package/dist/field-K5Ih8hd4.cjs +543 -0
- package/dist/field-a4QJ2c-m.d.ts +117 -0
- package/dist/field.cjs +11 -0
- package/dist/field.d.cts +2 -0
- package/dist/field.d.ts +2 -0
- package/dist/field.js +1 -0
- package/dist/file-input-parts.cjs +31 -0
- package/dist/file-input-parts.d.cts +13 -0
- package/dist/file-input-parts.d.ts +13 -0
- package/dist/file-input-parts.js +23 -0
- package/dist/file-input.cjs +305 -0
- package/dist/file-input.d.cts +121 -0
- package/dist/file-input.d.ts +121 -0
- package/dist/file-input.js +292 -0
- package/dist/gauge-helpers-B5LtX6LH.js +112 -0
- package/dist/gauge-helpers-CH1_d6Gu.cjs +165 -0
- package/dist/gesture.cjs +14 -0
- package/dist/gesture.d.cts +2 -0
- package/dist/gesture.d.ts +2 -0
- package/dist/gesture.js +1 -0
- package/dist/headless-B-TKPycd.d.ts +126 -0
- package/dist/headless-BlJkiUjO.cjs +716 -0
- package/dist/headless-CljY7Ctc.d.cts +126 -0
- package/dist/headless-CrvR466Z.js +645 -0
- package/dist/headless.cjs +7 -0
- package/dist/headless.d.cts +3 -0
- package/dist/headless.d.ts +3 -0
- package/dist/headless.js +3 -0
- package/dist/history.cjs +88 -0
- package/dist/history.d.cts +43 -0
- package/dist/history.d.ts +43 -0
- package/dist/history.js +85 -0
- package/dist/host-channels-2qF0Zogd.js +40 -0
- package/dist/host-channels-CGGNArN9.d.ts +34 -0
- package/dist/host-channels-D_BJumjy.d.cts +34 -0
- package/dist/host-channels-_jRfb-gI.cjs +57 -0
- package/dist/hover-card-BLDhTCGz.d.ts +93 -0
- package/dist/hover-card-D1bBICJL.d.cts +93 -0
- package/dist/hover-card.cjs +353 -0
- package/dist/hover-card.d.cts +2 -0
- package/dist/hover-card.d.ts +2 -0
- package/dist/hover-card.js +348 -0
- package/dist/icon-button.cjs +59 -0
- package/dist/icon-button.d.cts +40 -0
- package/dist/icon-button.d.ts +40 -0
- package/dist/icon-button.js +58 -0
- package/dist/image-cropper-parts.cjs +21 -0
- package/dist/image-cropper-parts.d.cts +15 -0
- package/dist/image-cropper-parts.d.ts +15 -0
- package/dist/image-cropper-parts.js +17 -0
- package/dist/image-cropper.cjs +126 -0
- package/dist/image-cropper.d.cts +78 -0
- package/dist/image-cropper.d.ts +78 -0
- package/dist/image-cropper.js +116 -0
- package/dist/image-parts.cjs +19 -0
- package/dist/image-parts.d.cts +13 -0
- package/dist/image-parts.d.ts +13 -0
- package/dist/image-parts.js +15 -0
- package/dist/image.cjs +120 -0
- package/dist/image.d.cts +56 -0
- package/dist/image.d.ts +56 -0
- package/dist/image.js +70 -0
- package/dist/index.cjs +2091 -0
- package/dist/index.d.cts +425 -0
- package/dist/index.d.ts +425 -0
- package/dist/index.js +745 -0
- package/dist/input-group-BGBOYB4n.d.cts +39 -0
- package/dist/input-group-BGOv7JzR.js +59 -0
- package/dist/input-group-CfU-Io-O.d.ts +39 -0
- package/dist/input-group-IrBJ7FhC.cjs +70 -0
- package/dist/input-group-parts.cjs +22 -0
- package/dist/input-group-parts.d.cts +10 -0
- package/dist/input-group-parts.d.ts +10 -0
- package/dist/input-group-parts.js +17 -0
- package/dist/input-group.cjs +3 -0
- package/dist/input-group.d.cts +2 -0
- package/dist/input-group.d.ts +2 -0
- package/dist/input-group.js +1 -0
- package/dist/input-parts.cjs +13 -0
- package/dist/input-parts.d.cts +7 -0
- package/dist/input-parts.d.ts +7 -0
- package/dist/input-parts.js +11 -0
- package/dist/input.cjs +122 -0
- package/dist/input.d.cts +61 -0
- package/dist/input.d.ts +61 -0
- package/dist/input.js +118 -0
- package/dist/intl-cache-BnmpE1aq.cjs +50 -0
- package/dist/intl-cache-CDLsfK96.js +33 -0
- package/dist/item-parts.cjs +48 -0
- package/dist/item-parts.d.cts +29 -0
- package/dist/item-parts.d.ts +29 -0
- package/dist/item-parts.js +38 -0
- package/dist/item.cjs +90 -0
- package/dist/item.d.cts +46 -0
- package/dist/item.d.ts +46 -0
- package/dist/item.js +88 -0
- package/dist/kbd-parts.cjs +13 -0
- package/dist/kbd-parts.d.cts +7 -0
- package/dist/kbd-parts.d.ts +7 -0
- package/dist/kbd-parts.js +11 -0
- package/dist/kbd.cjs +53 -0
- package/dist/kbd.d.cts +21 -0
- package/dist/kbd.d.ts +21 -0
- package/dist/kbd.js +52 -0
- package/dist/label.cjs +51 -0
- package/dist/label.d.cts +20 -0
- package/dist/label.d.ts +20 -0
- package/dist/label.js +50 -0
- package/dist/list-field-BOenMv1V.d.cts +33 -0
- package/dist/list-field-CAglN-Lq.d.ts +33 -0
- package/dist/list-field-Du4-URtf.cjs +1347 -0
- package/dist/list-field-j21SJ5eb.js +1216 -0
- package/dist/listbox-parts.cjs +18 -0
- package/dist/listbox-parts.d.cts +12 -0
- package/dist/listbox-parts.d.ts +12 -0
- package/dist/listbox-parts.js +15 -0
- package/dist/listbox.cjs +288 -0
- package/dist/listbox.d.cts +102 -0
- package/dist/listbox.d.ts +102 -0
- package/dist/listbox.js +280 -0
- package/dist/loader-parts.cjs +16 -0
- package/dist/loader-parts.d.cts +8 -0
- package/dist/loader-parts.d.ts +8 -0
- package/dist/loader-parts.js +13 -0
- package/dist/loader.cjs +31 -0
- package/dist/loader.d.cts +31 -0
- package/dist/loader.d.ts +31 -0
- package/dist/loader.js +30 -0
- package/dist/mark-presence-BBxPeAWU.js +40 -0
- package/dist/mark-presence-CA2qIL-U.cjs +45 -0
- package/dist/mention-menu-parts.cjs +46 -0
- package/dist/mention-menu-parts.d.cts +18 -0
- package/dist/mention-menu-parts.d.ts +18 -0
- package/dist/mention-menu-parts.js +33 -0
- package/dist/mention-menu.cjs +98 -0
- package/dist/mention-menu.d.cts +67 -0
- package/dist/mention-menu.d.ts +67 -0
- package/dist/mention-menu.js +96 -0
- package/dist/menu-parts.cjs +28 -0
- package/dist/menu-parts.d.cts +11 -0
- package/dist/menu-parts.d.ts +11 -0
- package/dist/menu-parts.js +22 -0
- package/dist/menu-surface-65w5dvFt.js +198 -0
- package/dist/menu-surface-CdCMDe9e.cjs +215 -0
- package/dist/menu.cjs +796 -0
- package/dist/menu.d.cts +249 -0
- package/dist/menu.d.ts +249 -0
- package/dist/menu.js +778 -0
- package/dist/menubar-DbOuiq7c.d.ts +45 -0
- package/dist/menubar-bar-DEAk5SJ_.js +419 -0
- package/dist/menubar-bar-Jl_AAP52.cjs +436 -0
- package/dist/menubar-parts.cjs +16 -0
- package/dist/menubar-parts.d.cts +8 -0
- package/dist/menubar-parts.d.ts +8 -0
- package/dist/menubar-parts.js +13 -0
- package/dist/menubar-wL-MNWma.d.cts +45 -0
- package/dist/menubar.cjs +86 -0
- package/dist/menubar.d.cts +2 -0
- package/dist/menubar.d.ts +2 -0
- package/dist/menubar.js +84 -0
- package/dist/meter-parts.cjs +19 -0
- package/dist/meter-parts.d.cts +9 -0
- package/dist/meter-parts.d.ts +9 -0
- package/dist/meter-parts.js +15 -0
- package/dist/meter.cjs +91 -0
- package/dist/meter.d.cts +61 -0
- package/dist/meter.d.ts +61 -0
- package/dist/meter.js +86 -0
- package/dist/native-select-parts.cjs +13 -0
- package/dist/native-select-parts.d.cts +7 -0
- package/dist/native-select-parts.d.ts +7 -0
- package/dist/native-select-parts.js +11 -0
- package/dist/native-select.cjs +53 -0
- package/dist/native-select.d.cts +43 -0
- package/dist/native-select.d.ts +43 -0
- package/dist/native-select.js +52 -0
- package/dist/navigation-menu-parts.cjs +19 -0
- package/dist/navigation-menu-parts.d.cts +9 -0
- package/dist/navigation-menu-parts.d.ts +9 -0
- package/dist/navigation-menu-parts.js +15 -0
- package/dist/navigation-menu.cjs +632 -0
- package/dist/navigation-menu.d.cts +129 -0
- package/dist/navigation-menu.d.ts +129 -0
- package/dist/navigation-menu.js +622 -0
- package/dist/number-input-parts.cjs +25 -0
- package/dist/number-input-parts.d.cts +11 -0
- package/dist/number-input-parts.d.ts +11 -0
- package/dist/number-input-parts.js +19 -0
- package/dist/number-input.cjs +210 -0
- package/dist/number-input.d.cts +96 -0
- package/dist/number-input.d.ts +96 -0
- package/dist/number-input.js +202 -0
- package/dist/number.cjs +44 -0
- package/dist/number.d.cts +2 -0
- package/dist/number.d.ts +2 -0
- package/dist/number.js +1 -0
- package/dist/observe.cjs +30 -0
- package/dist/observe.d.cts +5 -0
- package/dist/observe.d.ts +5 -0
- package/dist/observe.js +11 -0
- package/dist/option-rows-CC2bEewo.cjs +50 -0
- package/dist/option-rows-XSPajLnJ.js +45 -0
- package/dist/otp-input-parts.cjs +19 -0
- package/dist/otp-input-parts.d.cts +9 -0
- package/dist/otp-input-parts.d.ts +9 -0
- package/dist/otp-input-parts.js +15 -0
- package/dist/otp-input.cjs +117 -0
- package/dist/otp-input.d.cts +99 -0
- package/dist/otp-input.d.ts +99 -0
- package/dist/otp-input.js +111 -0
- package/dist/overlays-BA9yrPGi.d.cts +162 -0
- package/dist/overlays-BjCNK-1Y.d.ts +162 -0
- package/dist/overlays.cjs +46 -0
- package/dist/overlays.d.cts +5 -0
- package/dist/overlays.d.ts +5 -0
- package/dist/overlays.js +5 -0
- package/dist/pagination-parts.cjs +22 -0
- package/dist/pagination-parts.d.cts +10 -0
- package/dist/pagination-parts.d.ts +10 -0
- package/dist/pagination-parts.js +17 -0
- package/dist/pagination.cjs +318 -0
- package/dist/pagination.d.cts +92 -0
- package/dist/pagination.d.ts +92 -0
- package/dist/pagination.js +302 -0
- package/dist/password-input-parts.cjs +16 -0
- package/dist/password-input-parts.d.cts +8 -0
- package/dist/password-input-parts.d.ts +8 -0
- package/dist/password-input-parts.js +13 -0
- package/dist/password-input.cjs +233 -0
- package/dist/password-input.d.cts +89 -0
- package/dist/password-input.d.ts +89 -0
- package/dist/password-input.js +229 -0
- package/dist/popover-B3GoPvi2.d.cts +124 -0
- package/dist/popover-BZl6Dt-0.d.ts +124 -0
- package/dist/popover-Ck8WMrE1.cjs +558 -0
- package/dist/popover-CypGE1n4.js +505 -0
- package/dist/popover.cjs +11 -0
- package/dist/popover.d.cts +2 -0
- package/dist/popover.d.ts +2 -0
- package/dist/popover.js +1 -0
- package/dist/preferences.cjs +132 -0
- package/dist/preferences.d.cts +33 -0
- package/dist/preferences.d.ts +33 -0
- package/dist/preferences.js +78 -0
- package/dist/presence.cjs +60 -0
- package/dist/presence.d.cts +27 -0
- package/dist/presence.d.ts +27 -0
- package/dist/presence.js +58 -0
- package/dist/primitive-6ogzHDuC.cjs +155 -0
- package/dist/primitive-BZcvjGFR.js +126 -0
- package/dist/primitive-Cqz6wKSr.d.cts +97 -0
- package/dist/primitive-Cqz6wKSr.d.ts +97 -0
- package/dist/primitive-entry.cjs +10 -0
- package/dist/primitive-entry.d.cts +3 -0
- package/dist/primitive-entry.d.ts +3 -0
- package/dist/primitive-entry.js +3 -0
- package/dist/progress-DBt5j1bZ.d.cts +60 -0
- package/dist/progress-DDMC5ANu.d.ts +60 -0
- package/dist/progress-parts.cjs +22 -0
- package/dist/progress-parts.d.cts +10 -0
- package/dist/progress-parts.d.ts +10 -0
- package/dist/progress-parts.js +17 -0
- package/dist/progress.cjs +118 -0
- package/dist/progress.d.cts +2 -0
- package/dist/progress.d.ts +2 -0
- package/dist/progress.js +113 -0
- package/dist/query.cjs +251 -0
- package/dist/query.d.cts +69 -0
- package/dist/query.d.ts +69 -0
- package/dist/query.js +230 -0
- package/dist/radio-parts.cjs +25 -0
- package/dist/radio-parts.d.cts +11 -0
- package/dist/radio-parts.d.ts +11 -0
- package/dist/radio-parts.js +19 -0
- package/dist/radio.cjs +273 -0
- package/dist/radio.d.cts +67 -0
- package/dist/radio.d.ts +67 -0
- package/dist/radio.js +269 -0
- package/dist/rating-parts.cjs +19 -0
- package/dist/rating-parts.d.cts +9 -0
- package/dist/rating-parts.d.ts +9 -0
- package/dist/rating-parts.js +15 -0
- package/dist/rating.cjs +99 -0
- package/dist/rating.d.cts +87 -0
- package/dist/rating.d.ts +87 -0
- package/dist/rating.js +96 -0
- package/dist/resizable-parts.cjs +20 -0
- package/dist/resizable-parts.d.cts +15 -0
- package/dist/resizable-parts.d.ts +15 -0
- package/dist/resizable-parts.js +16 -0
- package/dist/resizable.cjs +386 -0
- package/dist/resizable.d.cts +105 -0
- package/dist/resizable.d.ts +105 -0
- package/dist/resizable.js +376 -0
- package/dist/scroll-area-parts.cjs +20 -0
- package/dist/scroll-area-parts.d.cts +15 -0
- package/dist/scroll-area-parts.d.ts +15 -0
- package/dist/scroll-area-parts.js +17 -0
- package/dist/scroll-area.cjs +121 -0
- package/dist/scroll-area.d.cts +81 -0
- package/dist/scroll-area.d.ts +81 -0
- package/dist/scroll-area.js +113 -0
- package/dist/segmented-control-parts.cjs +18 -0
- package/dist/segmented-control-parts.d.cts +8 -0
- package/dist/segmented-control-parts.d.ts +8 -0
- package/dist/segmented-control-parts.js +14 -0
- package/dist/segmented-control.cjs +166 -0
- package/dist/segmented-control.d.cts +58 -0
- package/dist/segmented-control.d.ts +58 -0
- package/dist/segmented-control.js +162 -0
- package/dist/segmented-input-BEvH60gW.js +871 -0
- package/dist/segmented-input-B_LrxViw.d.cts +25 -0
- package/dist/segmented-input-B_LrxViw.d.ts +25 -0
- package/dist/segmented-input-CLyC59Tw.cjs +882 -0
- package/dist/select-parts.cjs +59 -0
- package/dist/select-parts.d.cts +20 -0
- package/dist/select-parts.d.ts +20 -0
- package/dist/select-parts.js +45 -0
- package/dist/select.cjs +878 -0
- package/dist/select.d.cts +210 -0
- package/dist/select.d.ts +210 -0
- package/dist/select.js +858 -0
- package/dist/separator-parts.cjs +13 -0
- package/dist/separator-parts.d.cts +7 -0
- package/dist/separator-parts.d.ts +7 -0
- package/dist/separator-parts.js +11 -0
- package/dist/separator.cjs +15 -0
- package/dist/separator.d.cts +16 -0
- package/dist/separator.d.ts +16 -0
- package/dist/separator.js +14 -0
- package/dist/sheet-parts.cjs +20 -0
- package/dist/sheet-parts.d.cts +13 -0
- package/dist/sheet-parts.d.ts +13 -0
- package/dist/sheet-parts.js +16 -0
- package/dist/sheet.cjs +51 -0
- package/dist/sheet.d.cts +72 -0
- package/dist/sheet.d.ts +72 -0
- package/dist/sheet.js +50 -0
- package/dist/shortcuts.cjs +96 -0
- package/dist/shortcuts.d.cts +21 -0
- package/dist/shortcuts.d.ts +21 -0
- package/dist/shortcuts.js +75 -0
- package/dist/sidebar-parts.cjs +20 -0
- package/dist/sidebar-parts.d.cts +15 -0
- package/dist/sidebar-parts.d.ts +15 -0
- package/dist/sidebar-parts.js +17 -0
- package/dist/sidebar.cjs +47 -0
- package/dist/sidebar.d.cts +38 -0
- package/dist/sidebar.d.ts +38 -0
- package/dist/sidebar.js +45 -0
- package/dist/skeleton-parts.cjs +16 -0
- package/dist/skeleton-parts.d.cts +8 -0
- package/dist/skeleton-parts.d.ts +8 -0
- package/dist/skeleton-parts.js +13 -0
- package/dist/skeleton.cjs +33 -0
- package/dist/skeleton.d.cts +20 -0
- package/dist/skeleton.d.ts +20 -0
- package/dist/skeleton.js +32 -0
- package/dist/slider.cjs +153 -0
- package/dist/slider.d.cts +89 -0
- package/dist/slider.d.ts +89 -0
- package/dist/slider.js +145 -0
- package/dist/slot-content-B2QEzvsJ.js +28 -0
- package/dist/slot-content-TPoO9_3v.cjs +39 -0
- package/dist/sortable-8vB7oWM-.js +141 -0
- package/dist/sortable-BItLUSjX.cjs +188 -0
- package/dist/sortable-CzHsBo4d.d.cts +126 -0
- package/dist/sortable-DsQVJ7Nj.d.ts +126 -0
- package/dist/sortable-parts.cjs +4 -0
- package/dist/sortable-parts.d.cts +2 -0
- package/dist/sortable-parts.d.ts +2 -0
- package/dist/sortable-parts.js +1 -0
- package/dist/sortable-root-BO3Jsvjq.js +84 -0
- package/dist/sortable-root-CR-Mj60O.d.cts +40 -0
- package/dist/sortable-root-CrnWoHtt.d.ts +40 -0
- package/dist/sortable-root-Dr_yMiUu.cjs +119 -0
- package/dist/sortable.cjs +17 -0
- package/dist/sortable.d.cts +3 -0
- package/dist/sortable.d.ts +3 -0
- package/dist/sortable.js +3 -0
- package/dist/spinner-parts.cjs +18 -0
- package/dist/spinner-parts.d.cts +12 -0
- package/dist/spinner-parts.d.ts +12 -0
- package/dist/spinner-parts.js +16 -0
- package/dist/spinner.cjs +31 -0
- package/dist/spinner.d.cts +24 -0
- package/dist/spinner.d.ts +24 -0
- package/dist/spinner.js +30 -0
- package/dist/steps-parts.cjs +37 -0
- package/dist/steps-parts.d.cts +26 -0
- package/dist/steps-parts.d.ts +26 -0
- package/dist/steps-parts.js +31 -0
- package/dist/steps.cjs +58 -0
- package/dist/steps.d.cts +27 -0
- package/dist/steps.d.ts +27 -0
- package/dist/steps.js +57 -0
- package/dist/switch-DOfO8P-X.js +111 -0
- package/dist/switch-DWgAvCo-.cjs +128 -0
- package/dist/switch-parts.cjs +13 -0
- package/dist/switch-parts.d.cts +7 -0
- package/dist/switch-parts.d.ts +7 -0
- package/dist/switch-parts.js +11 -0
- package/dist/switch.cjs +6 -0
- package/dist/switch.d.cts +67 -0
- package/dist/switch.d.ts +67 -0
- package/dist/switch.js +2 -0
- package/dist/table-parts.cjs +22 -0
- package/dist/table-parts.d.cts +13 -0
- package/dist/table-parts.d.ts +13 -0
- package/dist/table-parts.js +18 -0
- package/dist/table.cjs +149 -0
- package/dist/table.d.cts +53 -0
- package/dist/table.d.ts +53 -0
- package/dist/table.js +148 -0
- package/dist/tabs.cjs +307 -0
- package/dist/tabs.d.cts +121 -0
- package/dist/tabs.d.ts +121 -0
- package/dist/tabs.js +300 -0
- package/dist/text-match.cjs +44 -0
- package/dist/text-match.d.cts +2 -0
- package/dist/text-match.d.ts +2 -0
- package/dist/text-match.js +1 -0
- package/dist/textarea-parts.cjs +13 -0
- package/dist/textarea-parts.d.cts +7 -0
- package/dist/textarea-parts.d.ts +7 -0
- package/dist/textarea-parts.js +11 -0
- package/dist/textarea.cjs +101 -0
- package/dist/textarea.d.cts +61 -0
- package/dist/textarea.d.ts +61 -0
- package/dist/textarea.js +98 -0
- package/dist/time-input-parts.cjs +19 -0
- package/dist/time-input-parts.d.cts +9 -0
- package/dist/time-input-parts.d.ts +9 -0
- package/dist/time-input-parts.js +15 -0
- package/dist/time-input.cjs +123 -0
- package/dist/time-input.d.cts +58 -0
- package/dist/time-input.d.ts +58 -0
- package/dist/time-input.js +122 -0
- package/dist/timeline-parts.cjs +44 -0
- package/dist/timeline-parts.d.cts +27 -0
- package/dist/timeline-parts.d.ts +27 -0
- package/dist/timeline-parts.js +35 -0
- package/dist/timeline.cjs +286 -0
- package/dist/timeline.d.cts +44 -0
- package/dist/timeline.d.ts +44 -0
- package/dist/timeline.js +277 -0
- package/dist/toast-parts.cjs +64 -0
- package/dist/toast-parts.d.cts +37 -0
- package/dist/toast-parts.d.ts +37 -0
- package/dist/toast-parts.js +52 -0
- package/dist/toast.cjs +288 -0
- package/dist/toast.d.cts +2 -0
- package/dist/toast.d.ts +2 -0
- package/dist/toast.js +280 -0
- package/dist/toggle-group-parts.cjs +18 -0
- package/dist/toggle-group-parts.d.cts +8 -0
- package/dist/toggle-group-parts.d.ts +8 -0
- package/dist/toggle-group-parts.js +14 -0
- package/dist/toggle-group.cjs +91 -0
- package/dist/toggle-group.d.cts +42 -0
- package/dist/toggle-group.d.ts +42 -0
- package/dist/toggle-group.js +90 -0
- package/dist/toggle-parts.cjs +52 -0
- package/dist/toggle-parts.d.cts +23 -0
- package/dist/toggle-parts.d.ts +23 -0
- package/dist/toggle-parts.js +49 -0
- package/dist/toggle.cjs +140 -0
- package/dist/toggle.d.cts +56 -0
- package/dist/toggle.d.ts +56 -0
- package/dist/toggle.js +137 -0
- package/dist/token-input-parts.cjs +30 -0
- package/dist/token-input-parts.d.cts +12 -0
- package/dist/token-input-parts.d.ts +12 -0
- package/dist/token-input-parts.js +22 -0
- package/dist/token-input.cjs +292 -0
- package/dist/token-input.d.cts +100 -0
- package/dist/token-input.d.ts +100 -0
- package/dist/token-input.js +284 -0
- package/dist/toolbar-BIAPDqB1.d.cts +125 -0
- package/dist/toolbar-DmD0BTK8.d.ts +125 -0
- package/dist/toolbar-context-AdI8_pQK.js +23 -0
- package/dist/toolbar-context-B2oM2qUt.cjs +46 -0
- package/dist/toolbar-parts.cjs +25 -0
- package/dist/toolbar-parts.d.cts +11 -0
- package/dist/toolbar-parts.d.ts +11 -0
- package/dist/toolbar-parts.js +19 -0
- package/dist/toolbar.cjs +398 -0
- package/dist/toolbar.d.cts +2 -0
- package/dist/toolbar.d.ts +2 -0
- package/dist/toolbar.js +391 -0
- package/dist/tooltip-BBd4ttIN.d.ts +95 -0
- package/dist/tooltip-BfeH1U_K.d.cts +95 -0
- package/dist/tooltip-C0lNNlBr.js +594 -0
- package/dist/tooltip-RaXnPVvX.cjs +629 -0
- package/dist/tooltip.cjs +8 -0
- package/dist/tooltip.d.cts +2 -0
- package/dist/tooltip.d.ts +2 -0
- package/dist/tooltip.js +1 -0
- package/dist/tree-grid-parts.cjs +22 -0
- package/dist/tree-grid-parts.d.cts +13 -0
- package/dist/tree-grid-parts.d.ts +13 -0
- package/dist/tree-grid-parts.js +18 -0
- package/dist/tree-grid.cjs +102 -0
- package/dist/tree-grid.d.cts +52 -0
- package/dist/tree-grid.d.ts +52 -0
- package/dist/tree-grid.js +101 -0
- package/dist/tree-parts.cjs +19 -0
- package/dist/tree-parts.d.cts +11 -0
- package/dist/tree-parts.d.ts +11 -0
- package/dist/tree-parts.js +16 -0
- package/dist/tree.cjs +1199 -0
- package/dist/tree.d.cts +146 -0
- package/dist/tree.d.ts +146 -0
- package/dist/tree.js +1190 -0
- package/dist/trigger-menu-BAptgs-8.d.cts +152 -0
- package/dist/trigger-menu-Bik8DeBO.cjs +1473 -0
- package/dist/trigger-menu-e_WojzA8.js +1390 -0
- package/dist/trigger-menu-g9hS4Cvv.d.ts +152 -0
- package/dist/trigger-menu.cjs +16 -0
- package/dist/trigger-menu.d.cts +2 -0
- package/dist/trigger-menu.d.ts +2 -0
- package/dist/trigger-menu.js +1 -0
- package/dist/virtual-list-parts.cjs +36 -0
- package/dist/virtual-list-parts.d.cts +18 -0
- package/dist/virtual-list-parts.d.ts +18 -0
- package/dist/virtual-list-parts.js +33 -0
- package/dist/virtual-list.cjs +68 -0
- package/dist/virtual-list.d.cts +49 -0
- package/dist/virtual-list.d.ts +49 -0
- package/dist/virtual-list.js +66 -0
- package/dist/virtual.cjs +32 -0
- package/dist/virtual.d.cts +9 -0
- package/dist/virtual.d.ts +9 -0
- package/dist/virtual.js +31 -0
- package/dist/waterfall-chart-parts.cjs +65 -0
- package/dist/waterfall-chart-parts.d.cts +36 -0
- package/dist/waterfall-chart-parts.d.ts +36 -0
- package/dist/waterfall-chart-parts.js +51 -0
- package/dist/waterfall-chart.cjs +80 -0
- package/dist/waterfall-chart.d.cts +44 -0
- package/dist/waterfall-chart.d.ts +44 -0
- package/dist/waterfall-chart.js +78 -0
- package/dist/waterfall-parts.cjs +25 -0
- package/dist/waterfall-parts.d.cts +16 -0
- package/dist/waterfall-parts.d.ts +16 -0
- package/dist/waterfall-parts.js +21 -0
- package/dist/waterfall.cjs +582 -0
- package/dist/waterfall.d.cts +113 -0
- package/dist/waterfall.d.ts +113 -0
- package/dist/waterfall.js +569 -0
- package/package.json +923 -3
- package/README.md +0 -3
package/dist/tree.cjs
ADDED
|
@@ -0,0 +1,1199 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_controller = require("./controller-DvBz7LNG.cjs");
|
|
3
|
+
const require_headless = require("./headless-BlJkiUjO.cjs");
|
|
4
|
+
const require_primitive = require("./primitive-6ogzHDuC.cjs");
|
|
5
|
+
const require_compound_helpers = require("./compound-helpers-Dhm54_n4.cjs");
|
|
6
|
+
const require_compound_registry = require("./compound-registry-jhlDoTDR.cjs");
|
|
7
|
+
let react = require("react");
|
|
8
|
+
let _bevelo_core = require("@bevelo/core");
|
|
9
|
+
let _bevelo_dom = require("@bevelo/dom");
|
|
10
|
+
let _bevelo_core_primitives_tree = require("@bevelo/core/primitives/tree");
|
|
11
|
+
// src/tree.tsx
|
|
12
|
+
/**
|
|
13
|
+
* @stable
|
|
14
|
+
*/
|
|
15
|
+
/** Builds a hierarchical tree of `TreeItemData` from file/folder path strings. */
|
|
16
|
+
function treeFromPaths(paths) {
|
|
17
|
+
const roots = [];
|
|
18
|
+
const rootMap = /* @__PURE__ */ new Map();
|
|
19
|
+
for (const raw of paths) {
|
|
20
|
+
const clean = raw.replace(/\/+$/, "");
|
|
21
|
+
if (!clean) continue;
|
|
22
|
+
const parts = clean.split("/");
|
|
23
|
+
let curMap = rootMap;
|
|
24
|
+
let curList = roots;
|
|
25
|
+
let acc = "";
|
|
26
|
+
for (let i = 0; i < parts.length; i += 1) {
|
|
27
|
+
const seg = parts[i] ?? "";
|
|
28
|
+
acc = acc ? `${acc}/${seg}` : seg;
|
|
29
|
+
let node = curMap.get(seg);
|
|
30
|
+
if (!node) {
|
|
31
|
+
node = {
|
|
32
|
+
value: acc,
|
|
33
|
+
label: seg,
|
|
34
|
+
children: [],
|
|
35
|
+
map: /* @__PURE__ */ new Map()
|
|
36
|
+
};
|
|
37
|
+
curMap.set(seg, node);
|
|
38
|
+
curList.push(node);
|
|
39
|
+
}
|
|
40
|
+
curMap = node.map;
|
|
41
|
+
curList = node.children;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const finalize = (d) => ({
|
|
45
|
+
id: d.value,
|
|
46
|
+
value: d.value,
|
|
47
|
+
label: d.label,
|
|
48
|
+
...d.children.length > 0 ? { children: d.children.map(finalize) } : {}
|
|
49
|
+
});
|
|
50
|
+
return roots.map(finalize);
|
|
51
|
+
}
|
|
52
|
+
/** Flattens visible tree nodes according to the expanded id list/set. */
|
|
53
|
+
function visibleTreeRows(items, expanded = []) {
|
|
54
|
+
const exp = expanded instanceof Set ? expanded : new Set(expanded);
|
|
55
|
+
const out = [];
|
|
56
|
+
const walk = (list) => {
|
|
57
|
+
for (const item of list) {
|
|
58
|
+
out.push(item);
|
|
59
|
+
const id = item.id ?? item.value ?? "";
|
|
60
|
+
if (item.children && item.children.length > 0 && exp.has(id)) walk(item.children);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
walk(items);
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
/** Creates an imperative controller for a `Tree`. */
|
|
67
|
+
function createTreeController() {
|
|
68
|
+
return require_controller.createController();
|
|
69
|
+
}
|
|
70
|
+
const INDICATOR = "▸";
|
|
71
|
+
const EMPTY_ITEMS = [];
|
|
72
|
+
const EMPTY_IDS = [];
|
|
73
|
+
const NO_WALK = {
|
|
74
|
+
tree: [],
|
|
75
|
+
entries: []
|
|
76
|
+
};
|
|
77
|
+
const COUNT_EVERY_LEAF = () => true;
|
|
78
|
+
function hasTreeGroupChild(node) {
|
|
79
|
+
if (Array.isArray(node)) return node.some((c) => hasTreeGroupChild(c));
|
|
80
|
+
if (!(0, react.isValidElement)(node)) return false;
|
|
81
|
+
if (node.type === TreeGroup) return true;
|
|
82
|
+
if (node.type === react.Fragment) return hasTreeGroupChild(node.props.children);
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
/** The host's item shape, as the primitive takes it. */
|
|
86
|
+
function toCoreItems(list) {
|
|
87
|
+
return list.map((it) => ({
|
|
88
|
+
...it,
|
|
89
|
+
id: it.id ?? it.value ?? it.label,
|
|
90
|
+
label: it.label,
|
|
91
|
+
...it.disabled ? { disabled: true } : {},
|
|
92
|
+
...it.expanded !== void 0 ? { expanded: it.expanded } : {},
|
|
93
|
+
...it.children ? { children: toCoreItems(it.children) } : {}
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
/** The data path's items, or undefined when the tree is composed from parts. */
|
|
97
|
+
function dataSource(items, paths) {
|
|
98
|
+
if (items !== void 0) return items;
|
|
99
|
+
return paths === void 0 ? void 0 : treeFromPaths(paths);
|
|
100
|
+
}
|
|
101
|
+
/** A row's label: its TreeItemLabel's text, else all of its text. */
|
|
102
|
+
function treeLabel(children) {
|
|
103
|
+
const labelEl = Array.isArray(children) ? children.find((c) => (0, react.isValidElement)(c) && c.type === TreeItemLabel) : (0, react.isValidElement)(children) && children.type === TreeItemLabel ? children : void 0;
|
|
104
|
+
return (0, react.isValidElement)(labelEl) ? require_compound_helpers.nodeText(labelEl.props.children) : require_compound_helpers.nodeText(children);
|
|
105
|
+
}
|
|
106
|
+
function treeEntry(id, props, parent) {
|
|
107
|
+
const branch = typeof props.branch === "boolean" ? props.branch : hasTreeGroupChild(props.children);
|
|
108
|
+
return {
|
|
109
|
+
value: id,
|
|
110
|
+
label: treeLabel(props.children) || id,
|
|
111
|
+
...parent === void 0 ? {} : { parent },
|
|
112
|
+
...branch ? { branch: true } : {},
|
|
113
|
+
...props.disabled === true ? { disabled: true } : {}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/** The rows a tree's own children name, nested, with each row's entry in document order. */
|
|
117
|
+
function extractTreeItems(node) {
|
|
118
|
+
const entries = [];
|
|
119
|
+
const walkLevel = (n, parent, out) => {
|
|
120
|
+
if (Array.isArray(n)) {
|
|
121
|
+
for (const c of n) walkLevel(c, parent, out);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (!(0, react.isValidElement)(n)) return;
|
|
125
|
+
const el = n;
|
|
126
|
+
if (el.type === react.Fragment) {
|
|
127
|
+
walkLevel(el.props["children"], parent, out);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (el.type === TreeItem) {
|
|
131
|
+
const id = typeof el.props["id"] === "string" ? el.props["id"] : typeof el.props["value"] === "string" ? el.props["value"] : `node-${entries.length}`;
|
|
132
|
+
const entry = treeEntry(id, el.props, parent);
|
|
133
|
+
entries.push(entry);
|
|
134
|
+
const groupEl = Array.isArray(el.props["children"]) ? el.props["children"].find((c) => (0, react.isValidElement)(c) && c.type === TreeGroup) : void 0;
|
|
135
|
+
const nested = [];
|
|
136
|
+
if ((0, react.isValidElement)(groupEl)) walkLevel(groupEl.props.children, id, nested);
|
|
137
|
+
out.push({
|
|
138
|
+
id,
|
|
139
|
+
label: entry.label,
|
|
140
|
+
...entry.disabled ? { disabled: true } : {},
|
|
141
|
+
...nested.length > 0 ? { children: nested } : {}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const tree = [];
|
|
146
|
+
walkLevel(node, void 0, tree);
|
|
147
|
+
return {
|
|
148
|
+
tree,
|
|
149
|
+
entries
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/** The walked rows that are mounted: a row under a collapsed branch is not. */
|
|
153
|
+
function visibleEntries(entries, expanded) {
|
|
154
|
+
const shown = /* @__PURE__ */ new Set();
|
|
155
|
+
const out = [];
|
|
156
|
+
for (const entry of entries) {
|
|
157
|
+
if (entry.parent !== void 0 && !(shown.has(entry.parent) && expanded.has(entry.parent))) continue;
|
|
158
|
+
shown.add(entry.value);
|
|
159
|
+
out.push(entry);
|
|
160
|
+
}
|
|
161
|
+
return out;
|
|
162
|
+
}
|
|
163
|
+
/** The rows of `items` data, in document order, as composed rows would register them. */
|
|
164
|
+
function dataEntries(list, parent, out = []) {
|
|
165
|
+
for (const item of list) {
|
|
166
|
+
const value = item.value ?? item.id ?? item.label;
|
|
167
|
+
out.push({
|
|
168
|
+
value,
|
|
169
|
+
label: item.label,
|
|
170
|
+
...parent === void 0 ? {} : { parent },
|
|
171
|
+
...item.children === void 0 ? {} : { branch: true },
|
|
172
|
+
...item.disabled ? { disabled: true } : {}
|
|
173
|
+
});
|
|
174
|
+
if (item.children) dataEntries(item.children, value, out);
|
|
175
|
+
}
|
|
176
|
+
return out;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The shape from the registered rows, with the walk's rows grafted under a
|
|
180
|
+
* branch none of whose rows registered (a collapsed branch).
|
|
181
|
+
*/
|
|
182
|
+
function shapeOf(registered, walked) {
|
|
183
|
+
const entry = /* @__PURE__ */ new Map();
|
|
184
|
+
const children = /* @__PURE__ */ new Map();
|
|
185
|
+
const add = (row) => {
|
|
186
|
+
if (entry.has(row.value)) return;
|
|
187
|
+
entry.set(row.value, row);
|
|
188
|
+
const key = row.parent ?? null;
|
|
189
|
+
const siblings = children.get(key);
|
|
190
|
+
if (siblings) siblings.push(row.value);
|
|
191
|
+
else children.set(key, [row.value]);
|
|
192
|
+
};
|
|
193
|
+
for (const row of registered) add(row);
|
|
194
|
+
const registeredParents = new Set(registered.map((row) => row.parent ?? null));
|
|
195
|
+
for (const row of walked) if (!registeredParents.has(row.parent ?? null)) add(row);
|
|
196
|
+
const order = [];
|
|
197
|
+
const parent = /* @__PURE__ */ new Map();
|
|
198
|
+
const visit = (key) => (children.get(key) ?? []).map((id) => {
|
|
199
|
+
order.push(id);
|
|
200
|
+
parent.set(id, key);
|
|
201
|
+
const row = entry.get(id);
|
|
202
|
+
const below = visit(id);
|
|
203
|
+
return {
|
|
204
|
+
id,
|
|
205
|
+
...row.disabled ? { disabled: true } : {},
|
|
206
|
+
...below.length > 0 || row.branch ? { children: below } : {}
|
|
207
|
+
};
|
|
208
|
+
});
|
|
209
|
+
return {
|
|
210
|
+
order,
|
|
211
|
+
entry,
|
|
212
|
+
parent,
|
|
213
|
+
children,
|
|
214
|
+
nodes: visit(null)
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function ancestorsIn(shape, id) {
|
|
218
|
+
const out = [];
|
|
219
|
+
const seen = /* @__PURE__ */ new Set([id]);
|
|
220
|
+
for (let up = shape.parent.get(id) ?? null; up !== null && !seen.has(up); up = shape.parent.get(up) ?? null) {
|
|
221
|
+
seen.add(up);
|
|
222
|
+
out.unshift(up);
|
|
223
|
+
}
|
|
224
|
+
return out;
|
|
225
|
+
}
|
|
226
|
+
function descendantsIn(shape, id, out = []) {
|
|
227
|
+
for (const child of shape.children.get(id) ?? []) {
|
|
228
|
+
out.push(child);
|
|
229
|
+
descendantsIn(shape, child, out);
|
|
230
|
+
}
|
|
231
|
+
return out;
|
|
232
|
+
}
|
|
233
|
+
function isBranchIn(shape, id) {
|
|
234
|
+
return shape.entry.get(id)?.branch === true || (shape.children.get(id)?.length ?? 0) > 0;
|
|
235
|
+
}
|
|
236
|
+
function toKeys(value) {
|
|
237
|
+
if (value === null || value === void 0) return [];
|
|
238
|
+
return typeof value === "string" ? [value] : value;
|
|
239
|
+
}
|
|
240
|
+
function sameKeys(a, b) {
|
|
241
|
+
return a.length === b.length && a.every((key, index) => key === b[index]);
|
|
242
|
+
}
|
|
243
|
+
function sameSet(a, b) {
|
|
244
|
+
return a.length === b.length && a.every((key) => b.includes(key));
|
|
245
|
+
}
|
|
246
|
+
function isApple() {
|
|
247
|
+
return typeof navigator !== "undefined" && /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent);
|
|
248
|
+
}
|
|
249
|
+
function idPart(value) {
|
|
250
|
+
return value.replace(/[^\w-]/g, (char) => `_${char.charCodeAt(0).toString(16)}`);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Typeahead as the WAI-ARIA practices describe it for trees: typed characters
|
|
254
|
+
* build a query that clears after half a second, and the next row whose label
|
|
255
|
+
* starts with it takes focus. The same character again steps through the rows
|
|
256
|
+
* that start with it.
|
|
257
|
+
*/
|
|
258
|
+
function createTypeahead(timeout = 500) {
|
|
259
|
+
let query = "";
|
|
260
|
+
let lastKey = "";
|
|
261
|
+
let stepping = false;
|
|
262
|
+
let timer;
|
|
263
|
+
const reset = () => {
|
|
264
|
+
query = "";
|
|
265
|
+
lastKey = "";
|
|
266
|
+
stepping = false;
|
|
267
|
+
clearTimeout(timer);
|
|
268
|
+
};
|
|
269
|
+
const scan = (labels, prefix, start) => {
|
|
270
|
+
for (let step = 0; step < labels.length; step += 1) {
|
|
271
|
+
const index = ((start + step) % labels.length + labels.length) % labels.length;
|
|
272
|
+
if ((0, _bevelo_core.foldSearchText)(labels[index] ?? "").startsWith(prefix)) return index;
|
|
273
|
+
}
|
|
274
|
+
return -1;
|
|
275
|
+
};
|
|
276
|
+
const search = (key, labels, current) => {
|
|
277
|
+
if ([...key].length !== 1 || key === " " && query === "") return -1;
|
|
278
|
+
clearTimeout(timer);
|
|
279
|
+
timer = setTimeout(reset, timeout);
|
|
280
|
+
const char = (0, _bevelo_core.foldSearchText)(key) || key;
|
|
281
|
+
stepping = char === lastKey && (stepping || query.length === 1);
|
|
282
|
+
lastKey = char;
|
|
283
|
+
query += char;
|
|
284
|
+
if (stepping) {
|
|
285
|
+
const whole = scan(labels, query, Math.max(current, 0));
|
|
286
|
+
return whole !== -1 ? whole : scan(labels, char, current + 1);
|
|
287
|
+
}
|
|
288
|
+
return scan(labels, query, query.length === 1 ? current + 1 : Math.max(current, 0));
|
|
289
|
+
};
|
|
290
|
+
return {
|
|
291
|
+
search,
|
|
292
|
+
reset,
|
|
293
|
+
active: () => query !== ""
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/** One visible row: the twisty (a branch only) and the label span. */
|
|
297
|
+
function TreeRowView(props) {
|
|
298
|
+
const { extras } = props;
|
|
299
|
+
const address = { index: props.index };
|
|
300
|
+
const disabled = (props.handle.part("row", address)?.state)?.disabled === true;
|
|
301
|
+
const indicator = require_headless.usePart(props.handle, "indicator", {
|
|
302
|
+
children: INDICATOR,
|
|
303
|
+
"data-loading": extras.loading ? "" : void 0,
|
|
304
|
+
"data-failed": extras.failed ? "" : void 0
|
|
305
|
+
}, void 0, address);
|
|
306
|
+
const checkbox = extras.checkbox ? (0, react.createElement)("input", {
|
|
307
|
+
type: "checkbox",
|
|
308
|
+
"data-slot": "tree-checkbox",
|
|
309
|
+
"data-part": "checkbox",
|
|
310
|
+
...extras.checked ? { "data-checked": "" } : {},
|
|
311
|
+
...disabled ? {
|
|
312
|
+
"data-disabled": "",
|
|
313
|
+
disabled: true
|
|
314
|
+
} : {},
|
|
315
|
+
checked: extras.checked,
|
|
316
|
+
style: {
|
|
317
|
+
appearance: "none",
|
|
318
|
+
margin: 0
|
|
319
|
+
},
|
|
320
|
+
onClick: (e) => e.stopPropagation(),
|
|
321
|
+
onChange: () => {
|
|
322
|
+
if (!disabled) extras.toggleChecked(props.id);
|
|
323
|
+
}
|
|
324
|
+
}) : null;
|
|
325
|
+
const label = require_headless.usePart(props.handle, "label", { children: (partState) => partState.label }, void 0, address);
|
|
326
|
+
return require_headless.usePart(props.handle, "row", {
|
|
327
|
+
"aria-selected": extras.selected ? "true" : "false",
|
|
328
|
+
"data-selected": extras.selected ? "" : void 0,
|
|
329
|
+
"aria-busy": extras.loading ? "true" : void 0,
|
|
330
|
+
children: (0, react.createElement)(react.Fragment, null, indicator, checkbox, label)
|
|
331
|
+
}, void 0, address);
|
|
332
|
+
}
|
|
333
|
+
function branchIds(list, out = []) {
|
|
334
|
+
for (const item of list) {
|
|
335
|
+
if (item.children && item.children.length > 0) out.push(item.id);
|
|
336
|
+
if (item.children) branchIds(item.children, out);
|
|
337
|
+
}
|
|
338
|
+
return out;
|
|
339
|
+
}
|
|
340
|
+
function ancestorsOf(list, target, trail = []) {
|
|
341
|
+
for (const item of list) {
|
|
342
|
+
if (item.id === target) return trail;
|
|
343
|
+
if (item.children) {
|
|
344
|
+
const found = ancestorsOf(item.children, target, [...trail, item.id]);
|
|
345
|
+
if (found) return found;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
function useTreeLoader(loadChildren) {
|
|
351
|
+
const [loadingIds, setLoadingIds] = (0, react.useState)(EMPTY_IDS);
|
|
352
|
+
const [failedIds, setFailedIds] = (0, react.useState)(EMPTY_IDS);
|
|
353
|
+
const loads = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
354
|
+
(0, react.useEffect)(() => {
|
|
355
|
+
const running = loads.current;
|
|
356
|
+
return () => {
|
|
357
|
+
for (const ac of running) ac.abort();
|
|
358
|
+
};
|
|
359
|
+
}, []);
|
|
360
|
+
return {
|
|
361
|
+
loadingIds,
|
|
362
|
+
failedIds,
|
|
363
|
+
loadBranch: (0, react.useCallback)((id, fn = loadChildren) => {
|
|
364
|
+
if (!fn) return;
|
|
365
|
+
setLoadingIds((prev) => prev.includes(id) ? prev : [...prev, id]);
|
|
366
|
+
setFailedIds((prev) => prev.filter((x) => x !== id));
|
|
367
|
+
const ac = new AbortController();
|
|
368
|
+
loads.current.add(ac);
|
|
369
|
+
const settle = (ok) => {
|
|
370
|
+
loads.current.delete(ac);
|
|
371
|
+
setLoadingIds((prev) => prev.filter((x) => x !== id));
|
|
372
|
+
if (!ok) setFailedIds((prev) => prev.includes(id) ? prev : [...prev, id]);
|
|
373
|
+
};
|
|
374
|
+
new Promise((resolve) => resolve(fn(id, { signal: ac.signal }))).then(() => settle(true), () => settle(false));
|
|
375
|
+
}, [loadChildren])
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
function Tree(props) {
|
|
379
|
+
return props.children !== void 0 ? (0, react.createElement)(CompoundTree, props) : (0, react.createElement)(DataTree, props);
|
|
380
|
+
}
|
|
381
|
+
Tree.displayName = "tree";
|
|
382
|
+
/** The data path: the primitive renders the visible rows of `items` or `paths`. */
|
|
383
|
+
function DataTree(props) {
|
|
384
|
+
const { items: itemsProp, paths, children: _children, expanded, defaultExpanded = EMPTY_IDS, selected, defaultValue, mode = "single", activation: _activation, expandOnPress: _expandOnPress, loadChildren, onAction, checkboxes = false, checked: checkedProp, defaultChecked = EMPTY_IDS, onCheckedChange, current: _current, keepMounted: _keepMounted, disabled = false, label = "", indent = 16, onChange, onValueChange, onSelect, controller, className, style, render, ref: hostRef, ...element } = props;
|
|
385
|
+
const [uncontrolledExpanded, setUncontrolledExpanded] = (0, react.useState)(() => {
|
|
386
|
+
const source = dataSource(itemsProp, paths);
|
|
387
|
+
return source === void 0 ? defaultExpanded : (0, _bevelo_core_primitives_tree.initialTreeExpanded)(toCoreItems(source), defaultExpanded);
|
|
388
|
+
});
|
|
389
|
+
const [uncontrolledSelected, setUncontrolledSelected] = (0, react.useState)(defaultValue ?? void 0);
|
|
390
|
+
const [uncontrolledChecked, setUncontrolledChecked] = (0, react.useState)(defaultChecked);
|
|
391
|
+
const { loadingIds, failedIds, loadBranch } = useTreeLoader(loadChildren);
|
|
392
|
+
const currentExpanded = expanded ?? uncontrolledExpanded;
|
|
393
|
+
const currentSelected = selected ?? uncontrolledSelected;
|
|
394
|
+
const selectedSet = (0, react.useMemo)(() => new Set(Array.isArray(currentSelected) ? currentSelected : currentSelected !== void 0 ? [currentSelected] : []), [currentSelected]);
|
|
395
|
+
const firstSelected = Array.isArray(currentSelected) ? currentSelected[0] : currentSelected;
|
|
396
|
+
const currentChecked = checkedProp ?? uncontrolledChecked;
|
|
397
|
+
const toggleChecked = (id) => {
|
|
398
|
+
const next = currentChecked.includes(id) ? currentChecked.filter((x) => x !== id) : [...currentChecked, id];
|
|
399
|
+
const details = (0, _bevelo_core.createDetails)({ reason: "item-press" });
|
|
400
|
+
onCheckedChange?.(next, details);
|
|
401
|
+
if (details.canceled) return;
|
|
402
|
+
if (checkedProp === void 0) setUncontrolledChecked(next);
|
|
403
|
+
};
|
|
404
|
+
const selectItem = (id) => {
|
|
405
|
+
if (disabled) return;
|
|
406
|
+
if (mode === "none") {
|
|
407
|
+
onAction?.(id, {});
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
const next = mode === "multiple" ? selectedSet.has(id) ? [...selectedSet].filter((x) => x !== id) : [...selectedSet, id] : id;
|
|
411
|
+
const details = (0, _bevelo_core.createDetails)({ reason: "item-press" });
|
|
412
|
+
onValueChange?.(next, details);
|
|
413
|
+
if (details.canceled) return;
|
|
414
|
+
if (selected === void 0) setUncontrolledSelected(next);
|
|
415
|
+
onSelect?.(id);
|
|
416
|
+
if (mode !== "multiple") onAction?.(id, {});
|
|
417
|
+
};
|
|
418
|
+
const treeRef = (0, react.useRef)(null);
|
|
419
|
+
const mergedTreeRef = (0, react.useMemo)(() => hostRef ? require_primitive.mergeRefs(treeRef, hostRef) : treeRef, [hostRef]);
|
|
420
|
+
const items = (0, react.useMemo)(() => {
|
|
421
|
+
const src = dataSource(itemsProp, paths);
|
|
422
|
+
return src === void 0 ? EMPTY_ITEMS : toCoreItems(src);
|
|
423
|
+
}, [itemsProp, paths]);
|
|
424
|
+
const commitExpanded = (next, reason) => {
|
|
425
|
+
const details = (0, _bevelo_core.createDetails)({ reason });
|
|
426
|
+
onChange?.([...next], details);
|
|
427
|
+
if (details.canceled) return;
|
|
428
|
+
if (expanded === void 0) setUncontrolledExpanded(next);
|
|
429
|
+
for (const id of next) if (!currentExpanded.includes(id)) loadBranch(id);
|
|
430
|
+
};
|
|
431
|
+
const latest = (0, react.useRef)({
|
|
432
|
+
commitExpanded,
|
|
433
|
+
selectItem
|
|
434
|
+
});
|
|
435
|
+
latest.current = {
|
|
436
|
+
commitExpanded,
|
|
437
|
+
selectItem
|
|
438
|
+
};
|
|
439
|
+
const onDataChange = (0, react.useCallback)((next) => {
|
|
440
|
+
latest.current.commitExpanded(next, "item-press");
|
|
441
|
+
}, []);
|
|
442
|
+
const onDataSelect = (0, react.useCallback)((id) => {
|
|
443
|
+
latest.current.selectItem(id);
|
|
444
|
+
}, []);
|
|
445
|
+
const handle = require_headless.usePrimitive(_bevelo_core_primitives_tree.treePrimitive, {
|
|
446
|
+
items,
|
|
447
|
+
expanded: currentExpanded,
|
|
448
|
+
...firstSelected === void 0 ? {} : { selected: firstSelected },
|
|
449
|
+
disabled,
|
|
450
|
+
label,
|
|
451
|
+
indent,
|
|
452
|
+
onChange: onDataChange,
|
|
453
|
+
onSelect: onDataSelect
|
|
454
|
+
});
|
|
455
|
+
const pendingFocus = (0, react.useRef)(null);
|
|
456
|
+
require_primitive.useIsomorphicLayoutEffect(() => {
|
|
457
|
+
const id = pendingFocus.current;
|
|
458
|
+
if (id === null) return;
|
|
459
|
+
const rowEl = [...treeRef.current?.querySelectorAll("[data-id]") ?? []].find((el) => el.dataset["id"] === id);
|
|
460
|
+
if (rowEl) {
|
|
461
|
+
pendingFocus.current = null;
|
|
462
|
+
rowEl.focus();
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
const controllerApi = {
|
|
466
|
+
...handle.api,
|
|
467
|
+
expandAll: () => latest.current.commitExpanded(branchIds(items), "imperative"),
|
|
468
|
+
collapseAll: () => latest.current.commitExpanded([], "imperative"),
|
|
469
|
+
setValue: (next) => {
|
|
470
|
+
if (selected === void 0) setUncontrolledSelected(next === null ? void 0 : next);
|
|
471
|
+
if (typeof next === "string") onSelect?.(next);
|
|
472
|
+
},
|
|
473
|
+
reveal: (targetId) => {
|
|
474
|
+
const ancestors = ancestorsOf(items, targetId);
|
|
475
|
+
if (ancestors !== null && ancestors.length > 0) latest.current.commitExpanded(Array.from(/* @__PURE__ */ new Set([...currentExpanded, ...ancestors])), "imperative");
|
|
476
|
+
handle.api.focus(targetId);
|
|
477
|
+
pendingFocus.current = targetId;
|
|
478
|
+
},
|
|
479
|
+
isExpanded: (value) => currentExpanded.includes(value)
|
|
480
|
+
};
|
|
481
|
+
const apiRef = (0, react.useRef)(controllerApi);
|
|
482
|
+
apiRef.current = controllerApi;
|
|
483
|
+
const stableApi = (0, react.useMemo)(() => ({
|
|
484
|
+
expandedIds: () => apiRef.current.expandedIds(),
|
|
485
|
+
visibleIds: () => apiRef.current.visibleIds(),
|
|
486
|
+
toggle: (id) => apiRef.current.toggle(id),
|
|
487
|
+
focus: (id) => apiRef.current.focus(id),
|
|
488
|
+
rovingId: () => apiRef.current.rovingId(),
|
|
489
|
+
expandAll: () => apiRef.current.expandAll(),
|
|
490
|
+
collapseAll: () => apiRef.current.collapseAll(),
|
|
491
|
+
setValue: (next) => apiRef.current.setValue(next),
|
|
492
|
+
reveal: (id) => apiRef.current.reveal(id),
|
|
493
|
+
isExpanded: (value) => apiRef.current.isExpanded(value)
|
|
494
|
+
}), []);
|
|
495
|
+
require_controller.useControllerAttach(controller, stableApi);
|
|
496
|
+
const checkedSet = new Set(currentChecked);
|
|
497
|
+
const rows = handle.api.visibleIds().map((id, index) => (0, react.createElement)(TreeRowView, {
|
|
498
|
+
key: id,
|
|
499
|
+
handle,
|
|
500
|
+
index,
|
|
501
|
+
id,
|
|
502
|
+
extras: {
|
|
503
|
+
selected: selectedSet.has(id),
|
|
504
|
+
checkbox: checkboxes,
|
|
505
|
+
checked: checkedSet.has(id),
|
|
506
|
+
loading: loadingIds.includes(id),
|
|
507
|
+
failed: failedIds.includes(id),
|
|
508
|
+
toggleChecked
|
|
509
|
+
}
|
|
510
|
+
}));
|
|
511
|
+
return require_headless.usePart(handle, "root", {
|
|
512
|
+
...element,
|
|
513
|
+
className,
|
|
514
|
+
style,
|
|
515
|
+
ref: mergedTreeRef,
|
|
516
|
+
children: rows
|
|
517
|
+
}, render);
|
|
518
|
+
}
|
|
519
|
+
const TreeCompoundContext = (0, react.createContext)(null);
|
|
520
|
+
const TreeLevelContext = (0, react.createContext)(1);
|
|
521
|
+
/** Events a part already acted on, which the row's own press then leaves alone. */
|
|
522
|
+
const partPresses = /* @__PURE__ */ new WeakSet();
|
|
523
|
+
/** The compound path: the host composes TreeItem, TreeGroup and the item parts. */
|
|
524
|
+
function CompoundTree(props) {
|
|
525
|
+
const { items: itemsProp, paths, children, expanded, defaultExpanded = EMPTY_IDS, selected, defaultValue, mode: modeProp = "single", activation = "manual", expandOnPress = true, loadChildren, onAction, checkboxes = false, checked: checkedProp, defaultChecked = EMPTY_IDS, onCheckedChange, current = null, keepMounted = false, disabled = false, label = "", indent: _indent, onChange, onValueChange, onSelect, controller, className, style, render: _render, ref: hostRef, ...element } = props;
|
|
526
|
+
const mode = modeProp === "multiple" || modeProp === "none" ? modeProp : "single";
|
|
527
|
+
const id = (0, react.useId)();
|
|
528
|
+
const dataShape = (0, react.useMemo)(() => {
|
|
529
|
+
const source = dataSource(itemsProp, paths);
|
|
530
|
+
return source === void 0 ? void 0 : shapeOf(dataEntries(source), []);
|
|
531
|
+
}, [itemsProp, paths]);
|
|
532
|
+
const walk = (0, react.useMemo)(() => dataShape === void 0 ? extractTreeItems(children) : NO_WALK, [dataShape, children]);
|
|
533
|
+
const [ownExpanded, setOwnExpanded] = (0, react.useState)(() => {
|
|
534
|
+
const shape = dataShape ?? shapeOf(walk.entries, []);
|
|
535
|
+
const seeded = new Set(defaultExpanded);
|
|
536
|
+
if (current !== null) for (const ancestor of ancestorsIn(shape, current)) seeded.add(ancestor);
|
|
537
|
+
return [...seeded];
|
|
538
|
+
});
|
|
539
|
+
const [ownValue, setOwnValue] = (0, react.useState)(() => {
|
|
540
|
+
const keys = toKeys(defaultValue);
|
|
541
|
+
return mode === "multiple" ? keys : keys[0] ?? null;
|
|
542
|
+
});
|
|
543
|
+
const [ownChecked, setOwnChecked] = (0, react.useState)(defaultChecked);
|
|
544
|
+
const { loadingIds, failedIds, loadBranch: loadBranchWith } = useTreeLoader(props.loadChildren);
|
|
545
|
+
const [focusedId, setFocusedId] = (0, react.useState)(void 0);
|
|
546
|
+
const [probeOpen, setProbeOpen] = (0, react.useState)(null);
|
|
547
|
+
const probe = (0, react.useRef)(null);
|
|
548
|
+
const currentExpanded = expanded ?? ownExpanded;
|
|
549
|
+
const value = selected === void 0 ? ownValue : mode === "multiple" ? toKeys(selected) : toKeys(selected)[0] ?? null;
|
|
550
|
+
const selectedKeys = (0, react.useMemo)(() => toKeys(value), [value]);
|
|
551
|
+
const selectedSet = (0, react.useMemo)(() => new Set(selectedKeys), [selectedKeys]);
|
|
552
|
+
const shown = (0, react.useMemo)(() => new Set(probeOpen === null ? currentExpanded : [...currentExpanded, ...probeOpen]), [probeOpen, currentExpanded]);
|
|
553
|
+
const checkedValue = checkedProp ?? ownChecked;
|
|
554
|
+
const mountedWalk = (0, react.useMemo)(() => keepMounted ? walk.entries : visibleEntries(walk.entries, shown), [
|
|
555
|
+
keepMounted,
|
|
556
|
+
walk,
|
|
557
|
+
shown
|
|
558
|
+
]);
|
|
559
|
+
const collection = require_compound_registry.useCollection(mountedWalk);
|
|
560
|
+
const shape = (0, react.useMemo)(() => dataShape ?? shapeOf(collection.items, walk.entries), [
|
|
561
|
+
dataShape,
|
|
562
|
+
collection.items,
|
|
563
|
+
walk
|
|
564
|
+
]);
|
|
565
|
+
const shows = (key) => ancestorsIn(shape, key).every((ancestor) => shown.has(ancestor));
|
|
566
|
+
const isDisabled = (key) => disabled || shape.entry.get(key)?.disabled === true;
|
|
567
|
+
const checkStates = (0, react.useMemo)(() => {
|
|
568
|
+
const tree = (0, _bevelo_core.treeCollection)(shape.nodes);
|
|
569
|
+
return (0, _bevelo_core.treeChecked)(tree, checkedValue, { counted: COUNT_EVERY_LEAF });
|
|
570
|
+
}, [shape, checkedValue]);
|
|
571
|
+
const checks = (0, react.useCallback)((key) => checkStates.get(key) ?? checkedValue.includes(key), [checkStates, checkedValue]);
|
|
572
|
+
let tabStop;
|
|
573
|
+
if (!disabled) {
|
|
574
|
+
for (let key = focusedId; key !== void 0 && tabStop === void 0; key = shape.parent.get(key) ?? void 0) if (shape.entry.has(key) && shows(key)) tabStop = key;
|
|
575
|
+
tabStop ??= [current, ...selectedKeys].find((key) => key !== null && shape.entry.has(key) && shows(key) && !isDisabled(key)) ?? shape.order.find((key) => shows(key) && !isDisabled(key));
|
|
576
|
+
}
|
|
577
|
+
const treeRef = (0, react.useRef)(null);
|
|
578
|
+
const mergedTreeRef = (0, react.useMemo)(() => hostRef ? require_primitive.mergeRefs(treeRef, hostRef) : treeRef, [hostRef]);
|
|
579
|
+
const deep = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
580
|
+
const anchor = (0, react.useRef)(null);
|
|
581
|
+
const typeahead = (0, react.useRef)(null);
|
|
582
|
+
typeahead.current ??= createTypeahead();
|
|
583
|
+
(0, react.useEffect)(() => () => typeahead.current?.reset(), []);
|
|
584
|
+
const pendingFocus = (0, react.useRef)(null);
|
|
585
|
+
const latest = (0, react.useRef)({
|
|
586
|
+
shape,
|
|
587
|
+
expanded: currentExpanded,
|
|
588
|
+
value,
|
|
589
|
+
checked: checkedValue,
|
|
590
|
+
focusedId,
|
|
591
|
+
props,
|
|
592
|
+
mode
|
|
593
|
+
});
|
|
594
|
+
latest.current = {
|
|
595
|
+
shape,
|
|
596
|
+
expanded: currentExpanded,
|
|
597
|
+
value,
|
|
598
|
+
checked: checkedValue,
|
|
599
|
+
focusedId,
|
|
600
|
+
props,
|
|
601
|
+
mode
|
|
602
|
+
};
|
|
603
|
+
const actions = (0, react.useMemo)(() => {
|
|
604
|
+
const s = () => latest.current;
|
|
605
|
+
const disabledKey = (key) => s().props.disabled === true || s().shape.entry.get(key)?.disabled === true;
|
|
606
|
+
const itemElement = (key) => [...treeRef.current?.querySelectorAll("[role=\"treeitem\"]") ?? []].find((el) => el.dataset["value"] === key);
|
|
607
|
+
const visibleItems = () => [...treeRef.current?.querySelectorAll("[role=\"treeitem\"]") ?? []].filter((el) => el.closest("[role=\"group\"][hidden]") === null);
|
|
608
|
+
const keyOf = (el) => el?.dataset["value"];
|
|
609
|
+
const details = (reason, event) => (0, _bevelo_core.createDetails)({
|
|
610
|
+
reason,
|
|
611
|
+
event
|
|
612
|
+
});
|
|
613
|
+
const loadBranch = (key) => loadBranchWith(key, s().props.loadChildren);
|
|
614
|
+
const setExpanded = (next, why) => {
|
|
615
|
+
const before = s().expanded;
|
|
616
|
+
const unique = [...new Set(next)];
|
|
617
|
+
if (sameSet(unique, before)) return false;
|
|
618
|
+
s().props.onChange?.(unique, why);
|
|
619
|
+
if (why.canceled) return false;
|
|
620
|
+
if (s().props.expanded === void 0) setOwnExpanded(unique);
|
|
621
|
+
latest.current = {
|
|
622
|
+
...latest.current,
|
|
623
|
+
expanded: unique
|
|
624
|
+
};
|
|
625
|
+
for (const key of unique) if (!before.includes(key)) loadBranch(key);
|
|
626
|
+
return true;
|
|
627
|
+
};
|
|
628
|
+
const setOpen = (key, opening, why) => {
|
|
629
|
+
if (!opening) deep.current.delete(key);
|
|
630
|
+
const before = s().expanded;
|
|
631
|
+
if (before.includes(key) === opening) return false;
|
|
632
|
+
if (opening && s().shape.entry.has(key) && !isBranchIn(s().shape, key)) return false;
|
|
633
|
+
const changed = setExpanded(opening ? [...before, key] : before.filter((other) => other !== key), why);
|
|
634
|
+
if (!changed || typeof document === "undefined") return changed;
|
|
635
|
+
const el = itemElement(key);
|
|
636
|
+
const active = document.activeElement;
|
|
637
|
+
if (el !== void 0 && el === active && isApple()) (0, _bevelo_dom.announce)(opening ? "Expanded" : "Collapsed");
|
|
638
|
+
if (!opening && el !== void 0 && active !== el && el.contains(active)) el.focus();
|
|
639
|
+
return changed;
|
|
640
|
+
};
|
|
641
|
+
const expandDeep = (key, why) => {
|
|
642
|
+
deep.current.add(key);
|
|
643
|
+
const below = descendantsIn(s().shape, key).filter((child) => isBranchIn(s().shape, child));
|
|
644
|
+
setExpanded([
|
|
645
|
+
...s().expanded,
|
|
646
|
+
key,
|
|
647
|
+
...below
|
|
648
|
+
], why);
|
|
649
|
+
};
|
|
650
|
+
const collapseDeep = (key, why) => {
|
|
651
|
+
const below = /* @__PURE__ */ new Set([key, ...descendantsIn(s().shape, key)]);
|
|
652
|
+
for (const branch of below) deep.current.delete(branch);
|
|
653
|
+
setExpanded(s().expanded.filter((other) => !below.has(other)), why);
|
|
654
|
+
};
|
|
655
|
+
const setValue = (next, why) => {
|
|
656
|
+
if (sameKeys(toKeys(next), toKeys(s().value))) return false;
|
|
657
|
+
s().props.onValueChange?.(next, why);
|
|
658
|
+
if (why.canceled) return false;
|
|
659
|
+
if (s().props.selected === void 0) setOwnValue(next);
|
|
660
|
+
latest.current = {
|
|
661
|
+
...latest.current,
|
|
662
|
+
value: next
|
|
663
|
+
};
|
|
664
|
+
return true;
|
|
665
|
+
};
|
|
666
|
+
const selectable = (key) => s().mode !== "none" && !disabledKey(key);
|
|
667
|
+
const choose = (key, why) => {
|
|
668
|
+
if (!selectable(key)) return;
|
|
669
|
+
anchor.current = key;
|
|
670
|
+
if (setValue(s().mode === "multiple" ? [key] : key, why)) s().props.onSelect?.(key);
|
|
671
|
+
};
|
|
672
|
+
const toggle = (key, why) => {
|
|
673
|
+
if (!selectable(key)) return;
|
|
674
|
+
anchor.current = key;
|
|
675
|
+
const keys = toKeys(s().value);
|
|
676
|
+
const has = keys.includes(key);
|
|
677
|
+
const next = s().mode === "multiple" ? has ? keys.filter((other) => other !== key) : [...keys, key] : has ? null : key;
|
|
678
|
+
if (setValue(next, why)) s().props.onSelect?.(key);
|
|
679
|
+
};
|
|
680
|
+
const extend = (target, from, why) => {
|
|
681
|
+
const keys = visibleItems().map((el) => keyOf(el) ?? "");
|
|
682
|
+
const start = keys.indexOf(anchor.current ?? from);
|
|
683
|
+
const end = keys.indexOf(target);
|
|
684
|
+
if (start === -1 || end === -1) return;
|
|
685
|
+
const range = keys.slice(Math.min(start, end), Math.max(start, end) + 1).filter(selectable);
|
|
686
|
+
setValue(range, why);
|
|
687
|
+
};
|
|
688
|
+
const toggleAll = (why) => {
|
|
689
|
+
const keys = visibleItems().map((el) => keyOf(el) ?? "").filter(selectable);
|
|
690
|
+
const selectedNow = toKeys(s().value);
|
|
691
|
+
setValue(keys.every((key) => selectedNow.includes(key)) ? [] : keys, why);
|
|
692
|
+
};
|
|
693
|
+
const follow = (key, event) => {
|
|
694
|
+
if (s().mode === "single" && s().props.activation === "automatic") choose(key, details("list-navigation", event));
|
|
695
|
+
};
|
|
696
|
+
const toggleChecked = (key, why) => {
|
|
697
|
+
if (disabledKey(key) || !s().shape.entry.has(key)) return false;
|
|
698
|
+
const tree = (0, _bevelo_core.treeCollection)(s().shape.nodes);
|
|
699
|
+
const before = s().checked;
|
|
700
|
+
const next = [...(0, _bevelo_core.treeToggleChecked)(tree, before, key, { counted: COUNT_EVERY_LEAF })];
|
|
701
|
+
if (sameKeys(next, before)) return false;
|
|
702
|
+
s().props.onCheckedChange?.(next, why);
|
|
703
|
+
if (why.canceled) return false;
|
|
704
|
+
if (s().props.checked === void 0) setOwnChecked(next);
|
|
705
|
+
latest.current = {
|
|
706
|
+
...latest.current,
|
|
707
|
+
checked: next
|
|
708
|
+
};
|
|
709
|
+
return true;
|
|
710
|
+
};
|
|
711
|
+
const focusRow = (el) => {
|
|
712
|
+
if (el === void 0) return;
|
|
713
|
+
const key = keyOf(el);
|
|
714
|
+
if (key !== void 0) setFocusedId(key);
|
|
715
|
+
el.focus();
|
|
716
|
+
};
|
|
717
|
+
const press = (key, el, event) => {
|
|
718
|
+
if (s().props.disabled === true) return;
|
|
719
|
+
const active = typeof document === "undefined" ? null : document.activeElement;
|
|
720
|
+
const editing = active instanceof HTMLElement && active !== el && (active.isContentEditable || active.matches("input, textarea, select"));
|
|
721
|
+
const from = s().focusedId ?? key;
|
|
722
|
+
if (active !== el && !editing) el.focus({ preventScroll: true });
|
|
723
|
+
setFocusedId(key);
|
|
724
|
+
if (disabledKey(key)) return;
|
|
725
|
+
const mouse = event;
|
|
726
|
+
if (s().mode === "multiple" && mouse.shiftKey) extend(key, from, details("item-press", event));
|
|
727
|
+
else if (s().mode === "multiple" || mouse.ctrlKey || mouse.metaKey) toggle(key, details("item-press", event));
|
|
728
|
+
else choose(key, details("item-press", event));
|
|
729
|
+
if (isBranchIn(s().shape, key) && s().props.expandOnPress !== false) setOpen(key, !s().expanded.includes(key), details("item-press", event));
|
|
730
|
+
s().props.onAction?.(key, { event });
|
|
731
|
+
};
|
|
732
|
+
const pressIndicator = (key, el, event) => {
|
|
733
|
+
partPresses.add(event);
|
|
734
|
+
if (s().props.disabled === true) return;
|
|
735
|
+
if (el) focusRow(el);
|
|
736
|
+
if (disabledKey(key)) return;
|
|
737
|
+
const why = details("trigger-press", event);
|
|
738
|
+
if (event.altKey) {
|
|
739
|
+
if (s().expanded.includes(key)) collapseDeep(key, why);
|
|
740
|
+
else expandDeep(key, why);
|
|
741
|
+
} else setOpen(key, !s().expanded.includes(key), why);
|
|
742
|
+
};
|
|
743
|
+
const pressCheckbox = (key, el, event) => {
|
|
744
|
+
partPresses.add(event);
|
|
745
|
+
if (s().props.disabled === true) return;
|
|
746
|
+
if (el) focusRow(el);
|
|
747
|
+
toggleChecked(key, details("item-press", event));
|
|
748
|
+
};
|
|
749
|
+
const keydown = (event) => {
|
|
750
|
+
if (event.defaultPrevented || s().props.disabled === true) return;
|
|
751
|
+
const target = event.target;
|
|
752
|
+
const el = target.closest("[role=\"treeitem\"]") ?? document.activeElement?.closest("[role=\"treeitem\"]") ?? null;
|
|
753
|
+
if (el === null || !treeRef.current?.contains(el)) return;
|
|
754
|
+
if (target !== el && target.matches("input, textarea, select, [contenteditable]:not([contenteditable='false'])")) return;
|
|
755
|
+
const key = keyOf(el);
|
|
756
|
+
if (key === void 0) return;
|
|
757
|
+
const native = event.nativeEvent;
|
|
758
|
+
const shape = s().shape;
|
|
759
|
+
const mod = event.ctrlKey || event.metaKey;
|
|
760
|
+
const visible = visibleItems();
|
|
761
|
+
const index = visible.indexOf(el);
|
|
762
|
+
const nav = () => details("list-navigation", native);
|
|
763
|
+
const parentItem = () => el.parentElement?.closest("[role=\"treeitem\"]") ?? void 0;
|
|
764
|
+
const moves = {
|
|
765
|
+
ArrowDown: visible[index + 1],
|
|
766
|
+
ArrowUp: index > 0 ? visible[index - 1] : void 0,
|
|
767
|
+
Home: visible[0],
|
|
768
|
+
End: visible[visible.length - 1]
|
|
769
|
+
};
|
|
770
|
+
if (event.key in moves && !event.altKey) {
|
|
771
|
+
event.preventDefault();
|
|
772
|
+
const to = moves[event.key];
|
|
773
|
+
const toKey = keyOf(to);
|
|
774
|
+
if (to === void 0 || toKey === void 0 || to === el) return;
|
|
775
|
+
focusRow(to);
|
|
776
|
+
const homeOrEnd = event.key === "Home" || event.key === "End";
|
|
777
|
+
if (s().mode === "multiple" && event.shiftKey && (!homeOrEnd || mod)) extend(toKey, key, nav());
|
|
778
|
+
else if (!event.shiftKey) follow(toKey, native);
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
const rtl = getComputedStyle(el).direction === "rtl";
|
|
782
|
+
const forward = rtl ? "ArrowLeft" : "ArrowRight";
|
|
783
|
+
const backward = rtl ? "ArrowRight" : "ArrowLeft";
|
|
784
|
+
const branch = isBranchIn(shape, key);
|
|
785
|
+
const open = branch && s().expanded.includes(key);
|
|
786
|
+
const off = disabledKey(key);
|
|
787
|
+
if (event.key === forward && !mod) {
|
|
788
|
+
if (!branch) return;
|
|
789
|
+
if (event.altKey) {
|
|
790
|
+
if (!off) expandDeep(key, nav());
|
|
791
|
+
} else if (!open) {
|
|
792
|
+
if (off) return;
|
|
793
|
+
setOpen(key, true, nav());
|
|
794
|
+
} else {
|
|
795
|
+
const next = visible[index + 1];
|
|
796
|
+
if (next !== void 0 && next.parentElement?.closest("[role=\"treeitem\"]") === el) {
|
|
797
|
+
focusRow(next);
|
|
798
|
+
const nextKey = keyOf(next);
|
|
799
|
+
if (nextKey !== void 0) follow(nextKey, native);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
} else if (event.key === backward && !mod) {
|
|
803
|
+
if (branch && event.altKey && !off) collapseDeep(key, nav());
|
|
804
|
+
else if (open && !off) setOpen(key, false, nav());
|
|
805
|
+
else {
|
|
806
|
+
const up = parentItem();
|
|
807
|
+
if (up === void 0 || !treeRef.current?.contains(up)) return;
|
|
808
|
+
focusRow(up);
|
|
809
|
+
const upKey = keyOf(up);
|
|
810
|
+
if (upKey !== void 0) follow(upKey, native);
|
|
811
|
+
}
|
|
812
|
+
} else if (event.key === "*") {
|
|
813
|
+
const siblings = (shape.children.get(shape.parent.get(key) ?? null) ?? []).filter((sibling) => isBranchIn(shape, sibling) && !disabledKey(sibling));
|
|
814
|
+
setExpanded([...s().expanded, ...siblings], nav());
|
|
815
|
+
} else if (mod && !event.shiftKey && !event.altKey && event.key.toLowerCase() === "a") {
|
|
816
|
+
if (s().mode !== "multiple") return;
|
|
817
|
+
toggleAll(nav());
|
|
818
|
+
} else if (event.key === "Enter" && !mod && !event.altKey) {
|
|
819
|
+
const link = [...el.querySelectorAll("[data-slot=\"tree-label\"]")].find((labelEl) => labelEl.closest("[role=\"treeitem\"]") === el);
|
|
820
|
+
if (link?.matches("a[href]")) link.click();
|
|
821
|
+
else press(key, el, native);
|
|
822
|
+
} else if (event.key === " " && !typeahead.current?.active()) {
|
|
823
|
+
const why = details("item-press", native);
|
|
824
|
+
if (s().props.checkboxes === true) toggleChecked(key, why);
|
|
825
|
+
else if (s().mode === "multiple" && event.shiftKey) extend(key, key, why);
|
|
826
|
+
else if (s().mode !== "none") toggle(key, why);
|
|
827
|
+
else return;
|
|
828
|
+
} else if ([...event.key].length === 1 && !mod && !event.altKey) {
|
|
829
|
+
const labels = visible.map((item) => {
|
|
830
|
+
const itemKey = keyOf(item) ?? "";
|
|
831
|
+
return shape.entry.get(itemKey)?.label ?? item.textContent ?? "";
|
|
832
|
+
});
|
|
833
|
+
const found = typeahead.current?.search(event.key, labels, index) ?? -1;
|
|
834
|
+
if (found === -1) return;
|
|
835
|
+
const to = visible[found];
|
|
836
|
+
focusRow(to);
|
|
837
|
+
const toKey = keyOf(to);
|
|
838
|
+
if (toKey !== void 0) follow(toKey, native);
|
|
839
|
+
} else return;
|
|
840
|
+
event.preventDefault();
|
|
841
|
+
};
|
|
842
|
+
const startProbe = (next) => {
|
|
843
|
+
probe.current = next;
|
|
844
|
+
setProbeOpen((running) => running ?? []);
|
|
845
|
+
};
|
|
846
|
+
return {
|
|
847
|
+
press,
|
|
848
|
+
pressIndicator,
|
|
849
|
+
pressCheckbox,
|
|
850
|
+
focused: setFocusedId,
|
|
851
|
+
keydown,
|
|
852
|
+
setExpanded,
|
|
853
|
+
api: {
|
|
854
|
+
expandedIds: () => [...s().expanded],
|
|
855
|
+
visibleIds: () => s().shape.order.filter((key) => ancestorsIn(s().shape, key).every((up) => s().expanded.includes(up))),
|
|
856
|
+
toggle: (key) => {
|
|
857
|
+
setOpen(key, !s().expanded.includes(key), details("imperative"));
|
|
858
|
+
},
|
|
859
|
+
focus: (key) => {
|
|
860
|
+
setFocusedId(key);
|
|
861
|
+
pendingFocus.current = key;
|
|
862
|
+
},
|
|
863
|
+
rovingId: () => s().focusedId,
|
|
864
|
+
expandAll: () => {
|
|
865
|
+
if (s().props.items !== void 0 || s().props.paths !== void 0) {
|
|
866
|
+
setExpanded(s().shape.order.filter((key) => isBranchIn(s().shape, key)), details("imperative"));
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
startProbe({ kind: "expandAll" });
|
|
870
|
+
},
|
|
871
|
+
collapseAll: () => {
|
|
872
|
+
probe.current = null;
|
|
873
|
+
setProbeOpen(null);
|
|
874
|
+
deep.current.clear();
|
|
875
|
+
setExpanded([], details("imperative"));
|
|
876
|
+
},
|
|
877
|
+
setValue: (next) => {
|
|
878
|
+
const normalized = next === null ? null : typeof next === "string" ? next : [...next];
|
|
879
|
+
if (setValue(normalized, details("imperative")) && typeof next === "string") s().props.onSelect?.(next);
|
|
880
|
+
},
|
|
881
|
+
reveal: (target) => {
|
|
882
|
+
const shape = s().shape;
|
|
883
|
+
if (!shape.entry.has(target)) {
|
|
884
|
+
startProbe({
|
|
885
|
+
kind: "reveal",
|
|
886
|
+
target,
|
|
887
|
+
base: s().expanded
|
|
888
|
+
});
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
const hidden = ancestorsIn(shape, target).filter((up) => !s().expanded.includes(up));
|
|
892
|
+
if (hidden.length > 0 && !setExpanded([...s().expanded, ...hidden], details("imperative"))) return;
|
|
893
|
+
setFocusedId(target);
|
|
894
|
+
pendingFocus.current = target;
|
|
895
|
+
},
|
|
896
|
+
isExpanded: (key) => s().expanded.includes(key)
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
}, []);
|
|
900
|
+
require_controller.useControllerAttach(controller, actions.api);
|
|
901
|
+
require_primitive.useIsomorphicLayoutEffect(() => {
|
|
902
|
+
if (deep.current.size === 0) return;
|
|
903
|
+
const add = shape.order.filter((key) => isBranchIn(shape, key) && !currentExpanded.includes(key) && !isDisabled(key) && ancestorsIn(shape, key).some((up) => deep.current.has(up)));
|
|
904
|
+
if (add.length > 0) actions.setExpanded([...currentExpanded, ...add], (0, _bevelo_core.createDetails)({ reason: "list-navigation" }));
|
|
905
|
+
});
|
|
906
|
+
const seenCurrent = (0, react.useRef)(current);
|
|
907
|
+
(0, react.useEffect)(() => {
|
|
908
|
+
if (current === seenCurrent.current) return;
|
|
909
|
+
seenCurrent.current = current;
|
|
910
|
+
if (current === null) return;
|
|
911
|
+
const hidden = ancestorsIn(latest.current.shape, current).filter((up) => !latest.current.expanded.includes(up));
|
|
912
|
+
if (hidden.length > 0) actions.setExpanded([...latest.current.expanded, ...hidden], (0, _bevelo_core.createDetails)({ reason: "imperative" }));
|
|
913
|
+
}, [current, actions]);
|
|
914
|
+
require_primitive.useIsomorphicLayoutEffect(() => {
|
|
915
|
+
const key = pendingFocus.current;
|
|
916
|
+
if (key === null) return;
|
|
917
|
+
const rowEl = [...treeRef.current?.querySelectorAll("[role=\"treeitem\"]") ?? []].find((el) => el.dataset["value"] === key && el.closest("[role=\"group\"][hidden]") === null);
|
|
918
|
+
if (rowEl) {
|
|
919
|
+
pendingFocus.current = null;
|
|
920
|
+
rowEl.focus();
|
|
921
|
+
}
|
|
922
|
+
});
|
|
923
|
+
require_primitive.useIsomorphicLayoutEffect(() => {
|
|
924
|
+
const running = probe.current;
|
|
925
|
+
if (running === null) return;
|
|
926
|
+
const known = dataShape ?? shapeOf(collection.current(), walk.entries);
|
|
927
|
+
if (running.kind === "reveal" && known.entry.has(running.target)) {
|
|
928
|
+
probe.current = null;
|
|
929
|
+
setProbeOpen(null);
|
|
930
|
+
const ancestors = ancestorsIn(known, running.target);
|
|
931
|
+
if (ancestors.length > 0) actions.setExpanded([.../* @__PURE__ */ new Set([...running.base, ...ancestors])], (0, _bevelo_core.createDetails)({ reason: "imperative" }));
|
|
932
|
+
setFocusedId(running.target);
|
|
933
|
+
pendingFocus.current = running.target;
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
const branches = known.order.filter((key) => isBranchIn(known, key));
|
|
937
|
+
const opened = new Set(probeOpen ?? []);
|
|
938
|
+
if (branches.some((key) => !opened.has(key))) {
|
|
939
|
+
setProbeOpen(branches);
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
probe.current = null;
|
|
943
|
+
setProbeOpen(null);
|
|
944
|
+
if (running.kind === "expandAll") actions.setExpanded(branches, (0, _bevelo_core.createDetails)({ reason: "imperative" }));
|
|
945
|
+
});
|
|
946
|
+
const position = (0, react.useCallback)((key) => {
|
|
947
|
+
const siblings = shape.children.get(shape.parent.get(key) ?? null) ?? [];
|
|
948
|
+
const index = siblings.indexOf(key);
|
|
949
|
+
return index === -1 ? void 0 : {
|
|
950
|
+
index: index + 1,
|
|
951
|
+
size: siblings.length
|
|
952
|
+
};
|
|
953
|
+
}, [shape]);
|
|
954
|
+
const scope = {
|
|
955
|
+
id,
|
|
956
|
+
mode,
|
|
957
|
+
checkable: checkboxes,
|
|
958
|
+
disabled,
|
|
959
|
+
keepMounted,
|
|
960
|
+
shown,
|
|
961
|
+
selected: selectedSet,
|
|
962
|
+
checks,
|
|
963
|
+
current,
|
|
964
|
+
tabStop,
|
|
965
|
+
loading: (0, react.useMemo)(() => new Set(loadingIds), [loadingIds]),
|
|
966
|
+
failed: (0, react.useMemo)(() => new Set(failedIds), [failedIds]),
|
|
967
|
+
position,
|
|
968
|
+
register: collection.register,
|
|
969
|
+
actions
|
|
970
|
+
};
|
|
971
|
+
return (0, react.createElement)(TreeCompoundContext.Provider, { value: scope }, (0, react.createElement)("ul", {
|
|
972
|
+
role: "tree",
|
|
973
|
+
"data-slot": "tree",
|
|
974
|
+
...label ? { "aria-label": label } : {},
|
|
975
|
+
"aria-multiselectable": mode === "multiple" ? "true" : void 0,
|
|
976
|
+
"aria-disabled": disabled ? "true" : void 0,
|
|
977
|
+
"data-disabled": disabled ? "" : void 0,
|
|
978
|
+
className,
|
|
979
|
+
style: {
|
|
980
|
+
listStyle: "none",
|
|
981
|
+
margin: 0,
|
|
982
|
+
...style
|
|
983
|
+
},
|
|
984
|
+
ref: mergedTreeRef,
|
|
985
|
+
onKeyDown: actions.keydown,
|
|
986
|
+
...element
|
|
987
|
+
}, children));
|
|
988
|
+
}
|
|
989
|
+
const TreeRowItemContext = (0, react.createContext)(null);
|
|
990
|
+
function TreeGroup({ style, keepMounted, ...props }) {
|
|
991
|
+
const item = (0, react.useContext)(TreeRowItemContext);
|
|
992
|
+
const tree = (0, react.useContext)(TreeCompoundContext);
|
|
993
|
+
const collapsed = item !== null && item.branch && !item.expanded;
|
|
994
|
+
if (collapsed && !(keepMounted ?? tree?.keepMounted ?? false)) return null;
|
|
995
|
+
const nextLevel = (item?.level ?? 1) + 1;
|
|
996
|
+
return (0, react.createElement)(TreeLevelContext.Provider, { value: nextLevel }, (0, react.createElement)("ul", {
|
|
997
|
+
role: "group",
|
|
998
|
+
"data-part": "group",
|
|
999
|
+
"data-slot": "tree-group",
|
|
1000
|
+
...item?.expanded ? { "data-expanded": "" } : {},
|
|
1001
|
+
...collapsed ? { hidden: true } : {},
|
|
1002
|
+
...props,
|
|
1003
|
+
style: {
|
|
1004
|
+
listStyle: "none",
|
|
1005
|
+
margin: 0,
|
|
1006
|
+
padding: 0,
|
|
1007
|
+
...style
|
|
1008
|
+
}
|
|
1009
|
+
}));
|
|
1010
|
+
}
|
|
1011
|
+
function TreeItem({ children, id, value, branch, disabled: itemDisabled = false, style, onClick, onFocus, ...rest }) {
|
|
1012
|
+
const ctx = (0, react.useContext)(TreeCompoundContext);
|
|
1013
|
+
const level = (0, react.useContext)(TreeLevelContext);
|
|
1014
|
+
const parentRow = (0, react.useContext)(TreeRowItemContext);
|
|
1015
|
+
const itemId = id ?? value ?? "";
|
|
1016
|
+
const hasChildren = branch ?? hasTreeGroupChild(children);
|
|
1017
|
+
const rowRef = require_compound_registry.useCollectionItem(itemId === "" ? void 0 : ctx?.register, treeEntry(itemId, {
|
|
1018
|
+
children,
|
|
1019
|
+
branch,
|
|
1020
|
+
disabled: itemDisabled
|
|
1021
|
+
}, parentRow?.id));
|
|
1022
|
+
const [labelled, setLabelled] = (0, react.useState)(() => (Array.isArray(children) ? children : [children]).some((c) => (0, react.isValidElement)(c) && c.type === TreeItemLabel));
|
|
1023
|
+
const isExpanded = hasChildren && Boolean(itemId && ctx?.shown.has(itemId));
|
|
1024
|
+
const mode = ctx?.mode ?? "single";
|
|
1025
|
+
const isSelected = Boolean(itemId && ctx?.selected.has(itemId));
|
|
1026
|
+
const isDisabled = Boolean(ctx?.disabled || itemDisabled);
|
|
1027
|
+
const isTabStop = Boolean(itemId && ctx?.tabStop === itemId);
|
|
1028
|
+
const isCurrent = Boolean(itemId && ctx?.current === itemId);
|
|
1029
|
+
const checked = itemId && ctx ? ctx.checks(itemId) : false;
|
|
1030
|
+
const position = itemId && ctx ? ctx.position(itemId) : void 0;
|
|
1031
|
+
const loading = Boolean(itemId && ctx?.loading.has(itemId));
|
|
1032
|
+
const labelId = `${ctx?.id ?? ""}-label-${idPart(itemId)}`;
|
|
1033
|
+
const row = (0, react.useMemo)(() => ({
|
|
1034
|
+
id: itemId,
|
|
1035
|
+
level,
|
|
1036
|
+
branch: hasChildren,
|
|
1037
|
+
expanded: isExpanded,
|
|
1038
|
+
selected: isSelected,
|
|
1039
|
+
disabled: isDisabled,
|
|
1040
|
+
checked,
|
|
1041
|
+
labelId,
|
|
1042
|
+
row: () => rowRef.current,
|
|
1043
|
+
setLabelled
|
|
1044
|
+
}), [
|
|
1045
|
+
itemId,
|
|
1046
|
+
level,
|
|
1047
|
+
hasChildren,
|
|
1048
|
+
isExpanded,
|
|
1049
|
+
isSelected,
|
|
1050
|
+
isDisabled,
|
|
1051
|
+
checked,
|
|
1052
|
+
labelId,
|
|
1053
|
+
rowRef
|
|
1054
|
+
]);
|
|
1055
|
+
return (0, react.createElement)(TreeRowItemContext.Provider, { value: row }, (0, react.createElement)("li", {
|
|
1056
|
+
role: "treeitem",
|
|
1057
|
+
"data-slot": "tree-item",
|
|
1058
|
+
"data-part": "row",
|
|
1059
|
+
"data-id": itemId,
|
|
1060
|
+
"data-value": itemId,
|
|
1061
|
+
"data-level": level,
|
|
1062
|
+
"aria-level": level,
|
|
1063
|
+
...labelled ? { "aria-labelledby": labelId } : {},
|
|
1064
|
+
...position ? {
|
|
1065
|
+
"aria-posinset": position.index,
|
|
1066
|
+
"aria-setsize": position.size
|
|
1067
|
+
} : {},
|
|
1068
|
+
...hasChildren ? {
|
|
1069
|
+
"data-branch": "",
|
|
1070
|
+
"aria-expanded": isExpanded ? "true" : "false"
|
|
1071
|
+
} : {},
|
|
1072
|
+
...mode === "none" ? {} : { "aria-selected": isSelected ? "true" : "false" },
|
|
1073
|
+
...ctx?.checkable ? { "aria-checked": checked === "mixed" ? "mixed" : checked ? "true" : "false" } : {},
|
|
1074
|
+
...isDisabled ? {
|
|
1075
|
+
"aria-disabled": "true",
|
|
1076
|
+
"data-disabled": ""
|
|
1077
|
+
} : {},
|
|
1078
|
+
...isCurrent ? { "aria-current": "page" } : {},
|
|
1079
|
+
...loading ? {
|
|
1080
|
+
"aria-busy": "true",
|
|
1081
|
+
"data-loading": ""
|
|
1082
|
+
} : {},
|
|
1083
|
+
...hasChildren ? { "data-expanded": isExpanded ? "true" : "false" } : {},
|
|
1084
|
+
...isSelected ? { "data-selected": "" } : {},
|
|
1085
|
+
...isTabStop ? { "data-current": "" } : {},
|
|
1086
|
+
...checked === true ? { "data-checked": "" } : checked === "mixed" ? { "data-indeterminate": "" } : {},
|
|
1087
|
+
tabIndex: isTabStop ? 0 : -1,
|
|
1088
|
+
...rest,
|
|
1089
|
+
onClick: (event) => {
|
|
1090
|
+
onClick?.(event);
|
|
1091
|
+
const el = event.currentTarget;
|
|
1092
|
+
if (!(event.target.closest("[role=\"treeitem\"]") === el) || event.defaultPrevented || partPresses.has(event.nativeEvent) || !ctx || itemId === "") return;
|
|
1093
|
+
ctx.actions.press(itemId, el, event.nativeEvent);
|
|
1094
|
+
},
|
|
1095
|
+
onFocus: (event) => {
|
|
1096
|
+
onFocus?.(event);
|
|
1097
|
+
if (event.target === event.currentTarget && itemId !== "") ctx?.actions.focused(itemId);
|
|
1098
|
+
},
|
|
1099
|
+
ref: rowRef,
|
|
1100
|
+
style: {
|
|
1101
|
+
"--tree-level": level,
|
|
1102
|
+
...style
|
|
1103
|
+
}
|
|
1104
|
+
}, children));
|
|
1105
|
+
}
|
|
1106
|
+
function TreeItemIndicator({ children, onClick, ...props }) {
|
|
1107
|
+
const item = (0, react.useContext)(TreeRowItemContext);
|
|
1108
|
+
const tree = (0, react.useContext)(TreeCompoundContext);
|
|
1109
|
+
const state = {
|
|
1110
|
+
expanded: Boolean(item?.branch && item.expanded),
|
|
1111
|
+
disabled: Boolean(item?.disabled),
|
|
1112
|
+
loading: Boolean(item?.id && tree?.loading.has(item.id)),
|
|
1113
|
+
failed: Boolean(item?.id && tree?.failed.has(item.id))
|
|
1114
|
+
};
|
|
1115
|
+
const content = typeof children === "function" ? children(state) : children;
|
|
1116
|
+
return (0, react.createElement)("span", {
|
|
1117
|
+
"data-slot": "tree-indicator",
|
|
1118
|
+
"data-part": "indicator",
|
|
1119
|
+
"aria-hidden": "true",
|
|
1120
|
+
...state.expanded ? { "data-expanded": "" } : {},
|
|
1121
|
+
...state.disabled ? { "data-disabled": "" } : {},
|
|
1122
|
+
...state.loading ? { "data-loading": "" } : {},
|
|
1123
|
+
...state.failed ? { "data-failed": "" } : {},
|
|
1124
|
+
...props,
|
|
1125
|
+
onClick: (event) => {
|
|
1126
|
+
onClick?.(event);
|
|
1127
|
+
if (event.defaultPrevented || !item?.branch || !tree || !item.id) return;
|
|
1128
|
+
tree.actions.pressIndicator(item.id, item.row(), event.nativeEvent);
|
|
1129
|
+
}
|
|
1130
|
+
}, content);
|
|
1131
|
+
}
|
|
1132
|
+
/** The row's checkbox. Hidden from screen readers, which hear the row's `aria-checked`. */
|
|
1133
|
+
function TreeItemCheckbox({ onClick, ...props }) {
|
|
1134
|
+
const tree = (0, react.useContext)(TreeCompoundContext);
|
|
1135
|
+
const item = (0, react.useContext)(TreeRowItemContext);
|
|
1136
|
+
const checked = item?.checked ?? false;
|
|
1137
|
+
return (0, react.createElement)("span", {
|
|
1138
|
+
"data-slot": "tree-checkbox",
|
|
1139
|
+
"data-part": "checkbox",
|
|
1140
|
+
"aria-hidden": "true",
|
|
1141
|
+
...checked === true ? { "data-checked": "" } : checked === "mixed" ? { "data-indeterminate": "" } : {},
|
|
1142
|
+
...item?.disabled ? { "data-disabled": "" } : {},
|
|
1143
|
+
...props,
|
|
1144
|
+
onClick: (event) => {
|
|
1145
|
+
onClick?.(event);
|
|
1146
|
+
if (event.defaultPrevented || !tree || !item?.id) return;
|
|
1147
|
+
tree.actions.pressCheckbox(item.id, item.row(), event.nativeEvent);
|
|
1148
|
+
}
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
/** The row's text, which names it. Render it as a link to make the row one. */
|
|
1152
|
+
function TreeItemLabel({ children, render, ref, ...rest }) {
|
|
1153
|
+
const ctx = (0, react.useContext)(TreeCompoundContext);
|
|
1154
|
+
const item = (0, react.useContext)(TreeRowItemContext);
|
|
1155
|
+
const selected = item?.selected ?? false;
|
|
1156
|
+
const expanded = item?.expanded ?? false;
|
|
1157
|
+
const branch = item?.branch ?? false;
|
|
1158
|
+
const disabled = item?.disabled ?? false;
|
|
1159
|
+
const current = Boolean(item && ctx?.tabStop === item.id);
|
|
1160
|
+
const state = {
|
|
1161
|
+
pending: Boolean(item?.id && ctx?.loading.has(item.id)),
|
|
1162
|
+
selected,
|
|
1163
|
+
expanded
|
|
1164
|
+
};
|
|
1165
|
+
const setLabelled = item?.setLabelled;
|
|
1166
|
+
require_primitive.useIsomorphicLayoutEffect(() => {
|
|
1167
|
+
setLabelled?.(true);
|
|
1168
|
+
return () => setLabelled?.(false);
|
|
1169
|
+
}, [setLabelled]);
|
|
1170
|
+
const own = (0, react.useRef)(null);
|
|
1171
|
+
require_primitive.useIsomorphicLayoutEffect(() => {
|
|
1172
|
+
const el = own.current;
|
|
1173
|
+
if (el?.matches("a[href]") && !el.hasAttribute("tabindex")) el.tabIndex = -1;
|
|
1174
|
+
});
|
|
1175
|
+
const mergedRef = (0, react.useMemo)(() => ref ? require_primitive.mergeRefs(own, ref) : own, [ref]);
|
|
1176
|
+
const resolvedChildren = typeof children === "function" ? children(state) : children;
|
|
1177
|
+
return require_primitive.renderElement("span", {
|
|
1178
|
+
"data-slot": "tree-label",
|
|
1179
|
+
"data-part": "label",
|
|
1180
|
+
...item ? { id: item.labelId } : {},
|
|
1181
|
+
...branch ? { "data-branch": "" } : {},
|
|
1182
|
+
...selected ? { "data-selected": "" } : {},
|
|
1183
|
+
...branch && expanded ? { "data-expanded": "" } : {},
|
|
1184
|
+
...current ? { "data-current": "" } : {},
|
|
1185
|
+
...disabled ? { "data-disabled": "" } : {},
|
|
1186
|
+
...rest,
|
|
1187
|
+
ref: mergedRef,
|
|
1188
|
+
children: resolvedChildren
|
|
1189
|
+
}, render, state);
|
|
1190
|
+
}
|
|
1191
|
+
exports.Tree = Tree;
|
|
1192
|
+
exports.TreeGroup = TreeGroup;
|
|
1193
|
+
exports.TreeItem = TreeItem;
|
|
1194
|
+
exports.TreeItemCheckbox = TreeItemCheckbox;
|
|
1195
|
+
exports.TreeItemIndicator = TreeItemIndicator;
|
|
1196
|
+
exports.TreeItemLabel = TreeItemLabel;
|
|
1197
|
+
exports.createTreeController = createTreeController;
|
|
1198
|
+
exports.treeFromPaths = treeFromPaths;
|
|
1199
|
+
exports.visibleTreeRows = visibleTreeRows;
|