@bevelo/vue 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.cjs +89 -0
- package/dist/accordion.d.cts +145 -0
- package/dist/accordion.d.ts +145 -0
- package/dist/accordion.js +88 -0
- package/dist/agent.cjs +74 -0
- package/dist/agent.d.cts +2 -0
- package/dist/agent.d.ts +2 -0
- package/dist/agent.js +1 -0
- package/dist/alert-dialog.cjs +48 -0
- package/dist/alert-dialog.d.cts +142 -0
- package/dist/alert-dialog.d.ts +142 -0
- package/dist/alert-dialog.js +47 -0
- package/dist/alert.cjs +77 -0
- package/dist/alert.d.cts +64 -0
- package/dist/alert.d.ts +64 -0
- package/dist/alert.js +76 -0
- package/dist/aspect-ratio.cjs +21 -0
- package/dist/aspect-ratio.d.cts +13 -0
- package/dist/aspect-ratio.d.ts +13 -0
- package/dist/aspect-ratio.js +21 -0
- package/dist/async-options.cjs +76 -0
- package/dist/async-options.d.cts +49 -0
- package/dist/async-options.d.ts +49 -0
- package/dist/async-options.js +75 -0
- package/dist/autocomplete.cjs +274 -0
- package/dist/autocomplete.d.cts +309 -0
- package/dist/autocomplete.d.ts +309 -0
- package/dist/autocomplete.js +273 -0
- package/dist/avatar.cjs +51 -0
- package/dist/avatar.d.cts +69 -0
- package/dist/avatar.d.ts +69 -0
- package/dist/avatar.js +50 -0
- package/dist/badge.cjs +41 -0
- package/dist/badge.d.cts +39 -0
- package/dist/badge.d.ts +39 -0
- package/dist/badge.js +40 -0
- package/dist/breadcrumb.cjs +59 -0
- package/dist/breadcrumb.d.cts +40 -0
- package/dist/breadcrumb.d.ts +40 -0
- package/dist/breadcrumb.js +58 -0
- package/dist/button.cjs +56 -0
- package/dist/button.d.cts +79 -0
- package/dist/button.d.ts +79 -0
- package/dist/button.js +55 -0
- package/dist/calendar-Bcc6HKc9.js +643 -0
- package/dist/calendar-vHGhj3RI.cjs +720 -0
- package/dist/calendar.cjs +4 -0
- package/dist/calendar.d.cts +316 -0
- package/dist/calendar.d.ts +316 -0
- package/dist/calendar.js +1 -0
- package/dist/card-B_ZoLCvt.d.cts +61 -0
- package/dist/card-B_ZoLCvt.d.ts +61 -0
- package/dist/card-CZHRix0r.js +99 -0
- package/dist/card-CvGfpsiU.cjs +140 -0
- package/dist/card.cjs +9 -0
- package/dist/card.d.cts +2 -0
- package/dist/card.d.ts +2 -0
- package/dist/card.js +1 -0
- package/dist/carousel.cjs +225 -0
- package/dist/carousel.d.cts +214 -0
- package/dist/carousel.d.ts +214 -0
- package/dist/carousel.js +224 -0
- package/dist/checkbox-group.cjs +93 -0
- package/dist/checkbox-group.d.cts +108 -0
- package/dist/checkbox-group.d.ts +108 -0
- package/dist/checkbox-group.js +91 -0
- package/dist/checkbox.cjs +117 -0
- package/dist/checkbox.d.cts +153 -0
- package/dist/checkbox.d.ts +153 -0
- package/dist/checkbox.js +116 -0
- package/dist/collapsible.cjs +70 -0
- package/dist/collapsible.d.cts +141 -0
- package/dist/collapsible.d.ts +141 -0
- package/dist/collapsible.js +69 -0
- package/dist/color-picker.cjs +225 -0
- package/dist/color-picker.d.cts +180 -0
- package/dist/color-picker.d.ts +180 -0
- package/dist/color-picker.js +212 -0
- package/dist/combobox-CDHIXr6J.d.ts +735 -0
- package/dist/combobox-D39Waj6L.d.cts +735 -0
- package/dist/combobox-DlCU0vS1.cjs +945 -0
- package/dist/combobox-wLdV6VA_.js +802 -0
- package/dist/combobox.cjs +26 -0
- package/dist/combobox.d.cts +3 -0
- package/dist/combobox.d.ts +3 -0
- package/dist/combobox.js +1 -0
- package/dist/command-CEJACYpR.d.ts +404 -0
- package/dist/command-CqHZVivR.js +693 -0
- package/dist/command-D54bj6RJ.cjs +836 -0
- package/dist/command-rAVp-wbf.d.cts +404 -0
- package/dist/command.cjs +15 -0
- package/dist/command.d.cts +2 -0
- package/dist/command.d.ts +2 -0
- package/dist/command.js +1 -0
- package/dist/context-menu-BPsgeLQm.cjs +170 -0
- package/dist/context-menu-ByhKzWTm.d.ts +129 -0
- package/dist/context-menu-Co3ABcdp.js +153 -0
- package/dist/context-menu-USbhMQuc.d.cts +129 -0
- package/dist/context-menu.cjs +6 -0
- package/dist/context-menu.d.cts +2 -0
- package/dist/context-menu.d.ts +2 -0
- package/dist/context-menu.js +2 -0
- package/dist/date-input.cjs +374 -0
- package/dist/date-input.d.cts +234 -0
- package/dist/date-input.d.ts +234 -0
- package/dist/date-input.js +371 -0
- package/dist/date-picker-D1mygz_Y.js +891 -0
- package/dist/date-picker-D_hqHHAV.cjs +938 -0
- package/dist/date-picker.cjs +4 -0
- package/dist/date-picker.d.cts +447 -0
- package/dist/date-picker.d.ts +447 -0
- package/dist/date-picker.js +1 -0
- package/dist/describe-BlNg9SbK.js +25 -0
- package/dist/describe-D_dLtwde.cjs +42 -0
- package/dist/dialog-view-CKtpbGq_.js +26 -0
- package/dist/dialog-view-swgEQvlZ.cjs +31 -0
- package/dist/dialog.cjs +66 -0
- package/dist/dialog.d.cts +158 -0
- package/dist/dialog.d.ts +158 -0
- package/dist/dialog.js +63 -0
- package/dist/direction.cjs +21 -0
- package/dist/direction.d.cts +13 -0
- package/dist/direction.d.ts +13 -0
- package/dist/direction.js +21 -0
- package/dist/dnd.cjs +103 -0
- package/dist/dnd.d.cts +54 -0
- package/dist/dnd.d.ts +54 -0
- package/dist/dnd.js +98 -0
- package/dist/drawer.cjs +137 -0
- package/dist/drawer.d.cts +190 -0
- package/dist/drawer.d.ts +190 -0
- package/dist/drawer.js +134 -0
- package/dist/empty-state.cjs +75 -0
- package/dist/empty-state.d.cts +46 -0
- package/dist/empty-state.d.ts +46 -0
- package/dist/empty-state.js +74 -0
- package/dist/engine-refs-8O6mHfYd.d.cts +4 -0
- package/dist/engine-refs-8O6mHfYd.d.ts +4 -0
- package/dist/engine-refs-CPWFFTfA.cjs +32 -0
- package/dist/engine-refs-sojZQs1R.js +21 -0
- package/dist/error-state.cjs +86 -0
- package/dist/error-state.d.cts +54 -0
- package/dist/error-state.d.ts +54 -0
- package/dist/error-state.js +85 -0
- package/dist/field.cjs +123 -0
- package/dist/field.d.cts +100 -0
- package/dist/field.d.ts +100 -0
- package/dist/field.js +122 -0
- package/dist/file-input.cjs +117 -0
- package/dist/file-input.d.cts +168 -0
- package/dist/file-input.d.ts +168 -0
- package/dist/file-input.js +116 -0
- package/dist/form-CKus_NQE.cjs +23 -0
- package/dist/form-y7b0fcqL.js +18 -0
- package/dist/gauge-parts-BVmw61GR.js +64 -0
- package/dist/gauge-parts-DjqBK9pL.d.cts +15 -0
- package/dist/gauge-parts-V31Fma77.cjs +75 -0
- package/dist/gauge-parts-mAgseDD4.d.ts +15 -0
- package/dist/headless-B3zQWaJm.js +225 -0
- package/dist/headless-BQe1X1Vf.d.ts +2 -0
- package/dist/headless-CbQgxdK1.d.cts +2 -0
- package/dist/headless-D88yFw8W.cjs +248 -0
- package/dist/hover-card.cjs +139 -0
- package/dist/hover-card.d.cts +200 -0
- package/dist/hover-card.d.ts +200 -0
- package/dist/hover-card.js +137 -0
- package/dist/icon-button.cjs +75 -0
- package/dist/icon-button.d.cts +104 -0
- package/dist/icon-button.d.ts +104 -0
- package/dist/icon-button.js +74 -0
- package/dist/image-cropper.cjs +106 -0
- package/dist/image-cropper.d.cts +7 -0
- package/dist/image-cropper.d.ts +7 -0
- package/dist/image-cropper.js +105 -0
- package/dist/image.cjs +87 -0
- package/dist/image.d.cts +92 -0
- package/dist/image.d.ts +92 -0
- package/dist/image.js +86 -0
- package/dist/index.cjs +1685 -0
- package/dist/index.d.cts +1195 -0
- package/dist/index.d.ts +1195 -0
- package/dist/index.js +1042 -0
- package/dist/input-group.cjs +91 -0
- package/dist/input-group.d.cts +84 -0
- package/dist/input-group.d.ts +84 -0
- package/dist/input-group.js +90 -0
- package/dist/input.cjs +114 -0
- package/dist/input.d.cts +186 -0
- package/dist/input.d.ts +186 -0
- package/dist/input.js +113 -0
- package/dist/item-B-QdNtAl.cjs +264 -0
- package/dist/item-D6GSb0WD.d.ts +144 -0
- package/dist/item-DPJnk7ED.js +199 -0
- package/dist/item-DyrvCrsL.d.cts +144 -0
- package/dist/item.cjs +10 -0
- package/dist/item.d.cts +2 -0
- package/dist/item.d.ts +2 -0
- package/dist/item.js +1 -0
- package/dist/kbd.cjs +55 -0
- package/dist/kbd.d.cts +38 -0
- package/dist/kbd.d.ts +38 -0
- package/dist/kbd.js +54 -0
- package/dist/label.cjs +41 -0
- package/dist/label.d.cts +40 -0
- package/dist/label.d.ts +40 -0
- package/dist/label.js +40 -0
- package/dist/listbox.cjs +85 -0
- package/dist/listbox.d.cts +200 -0
- package/dist/listbox.d.ts +200 -0
- package/dist/listbox.js +84 -0
- package/dist/loader.cjs +66 -0
- package/dist/loader.d.cts +68 -0
- package/dist/loader.d.ts +68 -0
- package/dist/loader.js +65 -0
- package/dist/mention-menu.cjs +126 -0
- package/dist/mention-menu.d.cts +144 -0
- package/dist/mention-menu.d.ts +144 -0
- package/dist/mention-menu.js +125 -0
- package/dist/menu.cjs +182 -0
- package/dist/menu.d.cts +240 -0
- package/dist/menu.d.ts +240 -0
- package/dist/menu.js +181 -0
- package/dist/menubar.cjs +38 -0
- package/dist/menubar.d.cts +43 -0
- package/dist/menubar.d.ts +43 -0
- package/dist/menubar.js +37 -0
- package/dist/meter.cjs +113 -0
- package/dist/meter.d.cts +124 -0
- package/dist/meter.d.ts +124 -0
- package/dist/meter.js +108 -0
- package/dist/native-select-52jYpA3c.d.cts +136 -0
- package/dist/native-select-BdJojSQt.d.ts +136 -0
- package/dist/native-select-BwptULNE.js +129 -0
- package/dist/native-select-DjBGWFoh.cjs +146 -0
- package/dist/native-select.cjs +5 -0
- package/dist/native-select.d.cts +2 -0
- package/dist/native-select.d.ts +2 -0
- package/dist/native-select.js +1 -0
- package/dist/navigation-menu.cjs +108 -0
- package/dist/navigation-menu.d.cts +245 -0
- package/dist/navigation-menu.d.ts +245 -0
- package/dist/navigation-menu.js +107 -0
- package/dist/number-input.cjs +189 -0
- package/dist/number-input.d.cts +232 -0
- package/dist/number-input.d.ts +232 -0
- package/dist/number-input.js +187 -0
- package/dist/option-row-DFCj-NoL.js +64 -0
- package/dist/option-row-Dlc6brXH.d.cts +30 -0
- package/dist/option-row-hLg6Ye86.cjs +105 -0
- package/dist/option-row-yJqjEx0G.d.ts +30 -0
- package/dist/options-BDn36q6n.cjs +111 -0
- package/dist/options-BlkyK-uO.js +106 -0
- package/dist/options-CGl5jBEY.d.ts +19 -0
- package/dist/options-DUGLoksA.d.cts +19 -0
- package/dist/otp-input.cjs +85 -0
- package/dist/otp-input.d.cts +113 -0
- package/dist/otp-input.d.ts +113 -0
- package/dist/otp-input.js +84 -0
- package/dist/overlay-controller-78GSJGbM.js +76 -0
- package/dist/overlay-controller-BDeITPoR.d.cts +16 -0
- package/dist/overlay-controller-DmaZ8FLl.cjs +93 -0
- package/dist/overlay-controller-HrMdTomI.d.ts +16 -0
- package/dist/pagination.cjs +87 -0
- package/dist/pagination.d.cts +112 -0
- package/dist/pagination.d.ts +112 -0
- package/dist/pagination.js +86 -0
- package/dist/parts-9zrUGbuI.js +84 -0
- package/dist/parts-DcYZV8ug.cjs +95 -0
- package/dist/password-input.cjs +144 -0
- package/dist/password-input.d.cts +151 -0
- package/dist/password-input.d.ts +151 -0
- package/dist/password-input.js +143 -0
- package/dist/placement-C_WRqvZk.js +49 -0
- package/dist/placement-ChEh6uxa.cjs +60 -0
- package/dist/popover.cjs +159 -0
- package/dist/popover.d.cts +185 -0
- package/dist/popover.d.ts +185 -0
- package/dist/popover.js +157 -0
- package/dist/preferences.cjs +96 -0
- package/dist/preferences.d.cts +36 -0
- package/dist/preferences.d.ts +36 -0
- package/dist/preferences.js +94 -0
- package/dist/presence.cjs +85 -0
- package/dist/presence.d.cts +25 -0
- package/dist/presence.d.ts +25 -0
- package/dist/presence.js +83 -0
- package/dist/progress.cjs +111 -0
- package/dist/progress.d.cts +109 -0
- package/dist/progress.d.ts +109 -0
- package/dist/progress.js +106 -0
- package/dist/query.cjs +152 -0
- package/dist/query.d.cts +68 -0
- package/dist/query.d.ts +68 -0
- package/dist/query.js +142 -0
- package/dist/radio.cjs +102 -0
- package/dist/radio.d.cts +136 -0
- package/dist/radio.d.ts +136 -0
- package/dist/radio.js +101 -0
- package/dist/rating.cjs +88 -0
- package/dist/rating.d.cts +100 -0
- package/dist/rating.d.ts +100 -0
- package/dist/rating.js +87 -0
- package/dist/resizable.cjs +57 -0
- package/dist/resizable.d.cts +119 -0
- package/dist/resizable.d.ts +119 -0
- package/dist/resizable.js +56 -0
- package/dist/scroll-area.cjs +59 -0
- package/dist/scroll-area.d.cts +72 -0
- package/dist/scroll-area.d.ts +72 -0
- package/dist/scroll-area.js +58 -0
- package/dist/segmented-control.cjs +88 -0
- package/dist/segmented-control.d.cts +121 -0
- package/dist/segmented-control.d.ts +121 -0
- package/dist/segmented-control.js +86 -0
- package/dist/select.cjs +160 -0
- package/dist/select.d.cts +385 -0
- package/dist/select.d.ts +385 -0
- package/dist/select.js +159 -0
- package/dist/separator.cjs +32 -0
- package/dist/separator.d.cts +31 -0
- package/dist/separator.d.ts +31 -0
- package/dist/separator.js +31 -0
- package/dist/sheet.cjs +294 -0
- package/dist/sheet.d.cts +456 -0
- package/dist/sheet.d.ts +456 -0
- package/dist/sheet.js +292 -0
- package/dist/sidebar-C-OdvGzD.d.cts +96 -0
- package/dist/sidebar-CZ1-p0-V.d.ts +96 -0
- package/dist/sidebar-DC-mpzMR.js +87 -0
- package/dist/sidebar-gSAgHdkn.cjs +110 -0
- package/dist/sidebar.cjs +6 -0
- package/dist/sidebar.d.cts +2 -0
- package/dist/sidebar.d.ts +2 -0
- package/dist/sidebar.js +1 -0
- package/dist/skeleton.cjs +46 -0
- package/dist/skeleton.d.cts +47 -0
- package/dist/skeleton.d.ts +47 -0
- package/dist/skeleton.js +45 -0
- package/dist/slider.cjs +118 -0
- package/dist/slider.d.cts +181 -0
- package/dist/slider.d.ts +181 -0
- package/dist/slider.js +117 -0
- package/dist/sortable-board-strict.cjs +149 -0
- package/dist/sortable-board-strict.d.cts +181 -0
- package/dist/sortable-board-strict.d.ts +181 -0
- package/dist/sortable-board-strict.js +148 -0
- package/dist/sortable-engine.cjs +136 -0
- package/dist/sortable-engine.d.cts +237 -0
- package/dist/sortable-engine.d.ts +237 -0
- package/dist/sortable-engine.js +135 -0
- package/dist/sortable.cjs +67 -0
- package/dist/sortable.d.cts +217 -0
- package/dist/sortable.d.ts +217 -0
- package/dist/sortable.js +66 -0
- package/dist/spinner.cjs +32 -0
- package/dist/spinner.d.cts +31 -0
- package/dist/spinner.d.ts +31 -0
- package/dist/spinner.js +31 -0
- package/dist/steps-C9Jmrt8G.cjs +122 -0
- package/dist/steps-Cs8AfxV7.js +81 -0
- package/dist/steps-DW5NkzVj.d.ts +71 -0
- package/dist/steps-ymRMdju5.d.cts +71 -0
- package/dist/steps.cjs +8 -0
- package/dist/steps.d.cts +2 -0
- package/dist/steps.d.ts +2 -0
- package/dist/steps.js +1 -0
- package/dist/switch.cjs +100 -0
- package/dist/switch.d.cts +144 -0
- package/dist/switch.d.ts +144 -0
- package/dist/switch.js +99 -0
- package/dist/table.cjs +124 -0
- package/dist/table.d.cts +124 -0
- package/dist/table.d.ts +124 -0
- package/dist/table.js +123 -0
- package/dist/tabs.cjs +89 -0
- package/dist/tabs.d.cts +160 -0
- package/dist/tabs.d.ts +160 -0
- package/dist/tabs.js +88 -0
- package/dist/textarea.cjs +140 -0
- package/dist/textarea.d.cts +231 -0
- package/dist/textarea.d.ts +231 -0
- package/dist/textarea.js +139 -0
- package/dist/time-input.cjs +117 -0
- package/dist/time-input.d.cts +140 -0
- package/dist/time-input.d.ts +140 -0
- package/dist/time-input.js +116 -0
- package/dist/timeline.cjs +82 -0
- package/dist/timeline.d.cts +62 -0
- package/dist/timeline.d.ts +62 -0
- package/dist/timeline.js +81 -0
- package/dist/toast-CfkRzdNd.js +354 -0
- package/dist/toast-DyezF7lm.cjs +401 -0
- package/dist/toast.cjs +16 -0
- package/dist/toast.d.cts +275 -0
- package/dist/toast.d.ts +275 -0
- package/dist/toast.js +1 -0
- package/dist/toggle-group.cjs +65 -0
- package/dist/toggle-group.d.cts +128 -0
- package/dist/toggle-group.d.ts +128 -0
- package/dist/toggle-group.js +64 -0
- package/dist/toggle.cjs +64 -0
- package/dist/toggle.d.cts +97 -0
- package/dist/toggle.d.ts +97 -0
- package/dist/toggle.js +63 -0
- package/dist/token-input-BIC9VLMG.d.cts +170 -0
- package/dist/token-input-BTReOHIv.cjs +336 -0
- package/dist/token-input-CQnZ6-pO.d.ts +170 -0
- package/dist/token-input-DtcCZrcC.js +295 -0
- package/dist/token-input.cjs +9 -0
- package/dist/token-input.d.cts +2 -0
- package/dist/token-input.d.ts +2 -0
- package/dist/token-input.js +1 -0
- package/dist/toolbar.cjs +62 -0
- package/dist/toolbar.d.cts +58 -0
- package/dist/toolbar.d.ts +58 -0
- package/dist/toolbar.js +61 -0
- package/dist/tooltip.cjs +149 -0
- package/dist/tooltip.d.cts +208 -0
- package/dist/tooltip.d.ts +208 -0
- package/dist/tooltip.js +147 -0
- package/dist/tree-grid.cjs +127 -0
- package/dist/tree-grid.d.cts +130 -0
- package/dist/tree-grid.d.ts +130 -0
- package/dist/tree-grid.js +126 -0
- package/dist/tree.cjs +227 -0
- package/dist/tree.d.cts +223 -0
- package/dist/tree.d.ts +223 -0
- package/dist/tree.js +226 -0
- package/dist/trigger-menu-8FAwypbs.d.cts +347 -0
- package/dist/trigger-menu-B898rWkz.cjs +502 -0
- package/dist/trigger-menu-C2YHe7es.d.ts +347 -0
- package/dist/trigger-menu-CxzocSWO.js +431 -0
- package/dist/trigger-menu.cjs +22 -0
- package/dist/trigger-menu.d.cts +2 -0
- package/dist/trigger-menu.d.ts +2 -0
- package/dist/trigger-menu.js +2 -0
- package/dist/virtual-list-strict.cjs +126 -0
- package/dist/virtual-list-strict.d.cts +69 -0
- package/dist/virtual-list-strict.d.ts +69 -0
- package/dist/virtual-list-strict.js +125 -0
- package/dist/virtual-list.cjs +65 -0
- package/dist/virtual-list.d.cts +82 -0
- package/dist/virtual-list.d.ts +82 -0
- package/dist/virtual-list.js +64 -0
- package/dist/virtual.cjs +27 -0
- package/dist/virtual.d.cts +30 -0
- package/dist/virtual.d.ts +30 -0
- package/dist/virtual.js +26 -0
- package/dist/vue-helpers-Bh_YF48i.cjs +102 -0
- package/dist/vue-helpers-Z3oOAHYB.js +55 -0
- package/dist/waterfall-chart.cjs +114 -0
- package/dist/waterfall-chart.d.cts +117 -0
- package/dist/waterfall-chart.d.ts +117 -0
- package/dist/waterfall-chart.js +113 -0
- package/dist/waterfall.cjs +296 -0
- package/dist/waterfall.d.cts +219 -0
- package/dist/waterfall.d.ts +219 -0
- package/dist/waterfall.js +284 -0
- package/package.json +518 -3
- package/README.md +0 -3
|
@@ -0,0 +1,802 @@
|
|
|
1
|
+
import { i as providePortalTarget, n as usePrimitive, t as renderPart } from "./headless-B3zQWaJm.js";
|
|
2
|
+
import { n as descriptionNodes } from "./describe-BlNg9SbK.js";
|
|
3
|
+
import { t as vueOptions } from "./options-BlkyK-uO.js";
|
|
4
|
+
import { n as usePlacement, t as placementProps } from "./placement-C_WRqvZk.js";
|
|
5
|
+
import { a as optionMapOf, i as noop, n as EMPTY_LIST_ITEMS, r as PANEL_STYLE, s as renderOptionSections, t as EMPTY_LISTBOX_OPTIONS } from "./option-row-DFCj-NoL.js";
|
|
6
|
+
import { comboboxMatchSegments, comboboxPrimitive, comboboxValueText, createComboboxCompound, createDetails } from "@bevelo/core";
|
|
7
|
+
import { Fragment, computed, defineComponent, h, inject, onBeforeUnmount, onMounted, provide, ref, shallowRef, useId, watch } from "vue";
|
|
8
|
+
// src/combobox-compound.ts
|
|
9
|
+
/** The list a part outside a root receives: one identity, not a new array. */
|
|
10
|
+
const NO_ITEMS = EMPTY_LIST_ITEMS;
|
|
11
|
+
const SCOPE = Symbol("bevelo.combobox");
|
|
12
|
+
const ITEM = Symbol("bevelo.combobox.item");
|
|
13
|
+
const CHIP = Symbol("bevelo.combobox.chip");
|
|
14
|
+
const GROUP = Symbol("bevelo.combobox.group");
|
|
15
|
+
function useScope() {
|
|
16
|
+
const scope = inject(SCOPE, void 0);
|
|
17
|
+
scope?.version.value;
|
|
18
|
+
return scope;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The composed root's setup: creates the shared object, provides it, exposes
|
|
22
|
+
* its api and returns the render function for the root element.
|
|
23
|
+
*/
|
|
24
|
+
function setupComboboxCompound(props, emit, attrs, slots, expose) {
|
|
25
|
+
const id = `bevelo-combobox-${useId().replace(/[^a-zA-Z0-9_-]/gu, "")}`;
|
|
26
|
+
const version = ref(0);
|
|
27
|
+
const multiple = () => props.multiple === true;
|
|
28
|
+
const controlledValue = () => {
|
|
29
|
+
return props.modelValue !== void 0 ? props.modelValue : props.value;
|
|
30
|
+
};
|
|
31
|
+
const onReport = (report) => {
|
|
32
|
+
switch (report.kind) {
|
|
33
|
+
case "value": {
|
|
34
|
+
const value = multiple() ? [...report.values] : report.values[0];
|
|
35
|
+
emit("change", value, createDetails({
|
|
36
|
+
reason: report.reason,
|
|
37
|
+
source: "programmatic"
|
|
38
|
+
}));
|
|
39
|
+
emit("update:modelValue", value);
|
|
40
|
+
emit("update:value", value);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case "open":
|
|
44
|
+
emit("openChange", report.open, createDetails({
|
|
45
|
+
reason: report.reason,
|
|
46
|
+
source: "programmatic"
|
|
47
|
+
}));
|
|
48
|
+
emit("update:open", report.open);
|
|
49
|
+
break;
|
|
50
|
+
case "query":
|
|
51
|
+
emit("input", report.query);
|
|
52
|
+
emit("update:inputValue", report.query);
|
|
53
|
+
break;
|
|
54
|
+
case "highlight": emit("highlight", report.value, { index: report.index });
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const compound = createComboboxCompound({
|
|
58
|
+
id,
|
|
59
|
+
init: {
|
|
60
|
+
defaultValue: props.defaultValue,
|
|
61
|
+
defaultOpen: props.defaultOpen,
|
|
62
|
+
defaultQuery: props.defaultQuery,
|
|
63
|
+
multiple: props.multiple,
|
|
64
|
+
itemToLabel: props.itemToLabel
|
|
65
|
+
},
|
|
66
|
+
read: () => ({
|
|
67
|
+
value: controlledValue(),
|
|
68
|
+
open: props.open,
|
|
69
|
+
inputValue: props.inputValue,
|
|
70
|
+
multiple: props.multiple,
|
|
71
|
+
maxSelected: props.maxSelected,
|
|
72
|
+
allowCustomValue: props.allowCustomValue,
|
|
73
|
+
disabled: props.disabled,
|
|
74
|
+
readOnly: props.readOnly,
|
|
75
|
+
loop: props.loop,
|
|
76
|
+
itemToLabel: props.itemToLabel,
|
|
77
|
+
filter: props.filter
|
|
78
|
+
}),
|
|
79
|
+
onReport
|
|
80
|
+
});
|
|
81
|
+
const unsubscribe = compound.subscribe(() => {
|
|
82
|
+
version.value++;
|
|
83
|
+
});
|
|
84
|
+
onBeforeUnmount(unsubscribe);
|
|
85
|
+
const root = shallowRef(null);
|
|
86
|
+
expose({ api: compound.api(() => root.value?.ownerDocument.getElementById(compound.inputId)?.focus()) });
|
|
87
|
+
provide(SCOPE, {
|
|
88
|
+
compound,
|
|
89
|
+
version,
|
|
90
|
+
status: () => props.status ?? "idle",
|
|
91
|
+
items: () => compound.query().trim() === "" && props.emptyItems !== void 0 ? props.emptyItems : props.items ?? []
|
|
92
|
+
});
|
|
93
|
+
const onKeydown = (event) => {
|
|
94
|
+
if (compound.key(event.key)) event.preventDefault();
|
|
95
|
+
};
|
|
96
|
+
return () => {
|
|
97
|
+
version.value;
|
|
98
|
+
return h("div", {
|
|
99
|
+
...attrs,
|
|
100
|
+
ref: root,
|
|
101
|
+
"data-slot": "combobox",
|
|
102
|
+
"aria-label": props.label || void 0,
|
|
103
|
+
...props.disabled ? { "data-disabled": "" } : {},
|
|
104
|
+
...props.readOnly ? { "data-readonly": "" } : {},
|
|
105
|
+
onKeydown
|
|
106
|
+
}, [slots.default?.()]);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/** The text field: typing filters the rows and opens the panel. */
|
|
110
|
+
const ComboboxInput = defineComponent({
|
|
111
|
+
name: "ComboboxInput",
|
|
112
|
+
setup() {
|
|
113
|
+
const scope = inject(SCOPE, void 0);
|
|
114
|
+
return () => {
|
|
115
|
+
scope?.version.value;
|
|
116
|
+
if (scope === void 0) return h("input", {
|
|
117
|
+
type: "text",
|
|
118
|
+
"data-part": "input"
|
|
119
|
+
});
|
|
120
|
+
const { compound } = scope;
|
|
121
|
+
return h("input", {
|
|
122
|
+
type: "text",
|
|
123
|
+
role: "combobox",
|
|
124
|
+
id: compound.inputId,
|
|
125
|
+
"data-part": "input",
|
|
126
|
+
"aria-expanded": compound.isOpen() ? "true" : "false",
|
|
127
|
+
"aria-controls": compound.listId,
|
|
128
|
+
"aria-autocomplete": "list",
|
|
129
|
+
"aria-activedescendant": compound.activeId(),
|
|
130
|
+
disabled: compound.disabled(),
|
|
131
|
+
readonly: compound.readOnly(),
|
|
132
|
+
value: compound.query(),
|
|
133
|
+
onInput: (event) => {
|
|
134
|
+
compound.dispatch({
|
|
135
|
+
type: "type",
|
|
136
|
+
text: event.target.value
|
|
137
|
+
});
|
|
138
|
+
const input = event.target;
|
|
139
|
+
if (input.value !== compound.query()) input.value = compound.query();
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
/** A button that opens and closes the panel. The slot receives `{ open, disabled }`. */
|
|
146
|
+
const ComboboxTrigger = defineComponent({
|
|
147
|
+
name: "ComboboxTrigger",
|
|
148
|
+
slots: Object,
|
|
149
|
+
setup(_props, { slots }) {
|
|
150
|
+
const scope = inject(SCOPE, void 0);
|
|
151
|
+
return () => {
|
|
152
|
+
scope?.version.value;
|
|
153
|
+
const open = scope?.compound.isOpen() ?? false;
|
|
154
|
+
const disabled = scope?.compound.disabled() ?? false;
|
|
155
|
+
return h("button", {
|
|
156
|
+
type: "button",
|
|
157
|
+
"data-part": "trigger",
|
|
158
|
+
tabindex: -1,
|
|
159
|
+
"aria-expanded": open ? "true" : "false",
|
|
160
|
+
"aria-controls": scope?.compound.listId,
|
|
161
|
+
disabled,
|
|
162
|
+
onClick: () => scope?.compound.dispatch({
|
|
163
|
+
type: "open",
|
|
164
|
+
open: !open,
|
|
165
|
+
reason: "imperative"
|
|
166
|
+
})
|
|
167
|
+
}, [slots.default?.({
|
|
168
|
+
open,
|
|
169
|
+
disabled
|
|
170
|
+
})]);
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
/** A button that clears the selection and the typed text. */
|
|
175
|
+
const ComboboxClear = defineComponent({
|
|
176
|
+
name: "ComboboxClear",
|
|
177
|
+
setup(_props, { slots }) {
|
|
178
|
+
const scope = inject(SCOPE, void 0);
|
|
179
|
+
return () => {
|
|
180
|
+
scope?.version.value;
|
|
181
|
+
return h("button", {
|
|
182
|
+
type: "button",
|
|
183
|
+
"data-part": "clear",
|
|
184
|
+
disabled: (scope?.compound.disabled() ?? false) || (scope?.compound.readOnly() ?? false),
|
|
185
|
+
onClick: () => scope?.compound.dispatch({ type: "clear" })
|
|
186
|
+
}, [slots.default?.() ?? "×"]);
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
/** The field's visible label, tied to the input. */
|
|
191
|
+
const ComboboxLabel = defineComponent({
|
|
192
|
+
name: "ComboboxLabel",
|
|
193
|
+
setup(_props, { slots }) {
|
|
194
|
+
const scope = inject(SCOPE, void 0);
|
|
195
|
+
return () => h("label", {
|
|
196
|
+
"data-part": "label",
|
|
197
|
+
for: scope?.compound.inputId
|
|
198
|
+
}, slots.default?.());
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
function statusState(scope) {
|
|
202
|
+
const count = scope?.compound.matchingCount() ?? 0;
|
|
203
|
+
const status = scope?.status() ?? "idle";
|
|
204
|
+
return {
|
|
205
|
+
status,
|
|
206
|
+
loading: status === "loading",
|
|
207
|
+
count,
|
|
208
|
+
query: scope?.compound.query() ?? "",
|
|
209
|
+
empty: count === 0
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/** A polite live region; the slot receives the match count and the loading state. */
|
|
213
|
+
const ComboboxStatus = defineComponent({
|
|
214
|
+
name: "ComboboxStatus",
|
|
215
|
+
slots: Object,
|
|
216
|
+
setup(_props, { slots }) {
|
|
217
|
+
return () => {
|
|
218
|
+
const scope = useScope();
|
|
219
|
+
return h("div", {
|
|
220
|
+
role: "status",
|
|
221
|
+
"aria-live": "polite",
|
|
222
|
+
"data-part": "status"
|
|
223
|
+
}, [slots.default?.(statusState(scope))]);
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
/**
|
|
228
|
+
* A row offering the typed text. `@create` (or `onCreate`) receives the trimmed
|
|
229
|
+
* text; a returned promise marks the row pending until it settles.
|
|
230
|
+
*/
|
|
231
|
+
const ComboboxCreate = defineComponent({
|
|
232
|
+
name: "ComboboxCreate",
|
|
233
|
+
props: {
|
|
234
|
+
minLength: {
|
|
235
|
+
type: Number,
|
|
236
|
+
default: 1
|
|
237
|
+
},
|
|
238
|
+
onCreate: {
|
|
239
|
+
type: Function,
|
|
240
|
+
required: false
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
slots: Object,
|
|
244
|
+
setup(props, { slots }) {
|
|
245
|
+
const pending = ref(false);
|
|
246
|
+
const error = shallowRef(void 0);
|
|
247
|
+
return () => {
|
|
248
|
+
const scope = useScope();
|
|
249
|
+
const query = scope?.compound.query().trim() ?? "";
|
|
250
|
+
if (scope !== void 0 && query.length < props.minLength) return null;
|
|
251
|
+
const create = () => {
|
|
252
|
+
try {
|
|
253
|
+
const result = props.onCreate?.(query);
|
|
254
|
+
if (result !== null && typeof result === "object" && typeof result.then === "function") {
|
|
255
|
+
pending.value = true;
|
|
256
|
+
error.value = void 0;
|
|
257
|
+
result.then(() => {
|
|
258
|
+
pending.value = false;
|
|
259
|
+
}, (reason) => {
|
|
260
|
+
pending.value = false;
|
|
261
|
+
error.value = reason;
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
} catch (reason) {
|
|
265
|
+
error.value = reason;
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
return h("div", {
|
|
269
|
+
role: "option",
|
|
270
|
+
"aria-selected": "false",
|
|
271
|
+
"data-part": "create",
|
|
272
|
+
...pending.value ? { "aria-busy": "true" } : {},
|
|
273
|
+
onClick: create
|
|
274
|
+
}, [slots.default?.({
|
|
275
|
+
query,
|
|
276
|
+
pending: pending.value,
|
|
277
|
+
error: error.value
|
|
278
|
+
})]);
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
/** The panel: rendered while the combobox is open, or always with `keepMounted`. */
|
|
283
|
+
const ComboboxContent = defineComponent({
|
|
284
|
+
name: "ComboboxContent",
|
|
285
|
+
props: { keepMounted: {
|
|
286
|
+
type: Boolean,
|
|
287
|
+
default: false
|
|
288
|
+
} },
|
|
289
|
+
setup(props, { slots }) {
|
|
290
|
+
return () => {
|
|
291
|
+
const open = useScope()?.compound.isOpen() ?? true;
|
|
292
|
+
if (!open && !props.keepMounted) return null;
|
|
293
|
+
return h("div", {
|
|
294
|
+
"data-part": "content",
|
|
295
|
+
...open ? { "data-open": "" } : { hidden: true }
|
|
296
|
+
}, slots.default?.());
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
/** The listbox. The slot receives `items` (or `emptyItems` while the query is empty). */
|
|
301
|
+
const ComboboxList = defineComponent({
|
|
302
|
+
name: "ComboboxList",
|
|
303
|
+
slots: Object,
|
|
304
|
+
setup(_props, { slots }) {
|
|
305
|
+
return () => {
|
|
306
|
+
const scope = useScope();
|
|
307
|
+
return h("div", {
|
|
308
|
+
role: "listbox",
|
|
309
|
+
id: scope?.compound.listId,
|
|
310
|
+
"data-part": "list",
|
|
311
|
+
...scope?.compound.multiple() ? { "aria-multiselectable": "true" } : {}
|
|
312
|
+
}, [slots.default?.({
|
|
313
|
+
items: scope?.items() ?? NO_ITEMS,
|
|
314
|
+
highlightedValue: scope?.compound.activeValue()
|
|
315
|
+
})]);
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
/** Shown while no row matches the query. The slot receives the status state. */
|
|
320
|
+
const ComboboxEmpty = defineComponent({
|
|
321
|
+
name: "ComboboxEmpty",
|
|
322
|
+
slots: Object,
|
|
323
|
+
setup(_props, { slots }) {
|
|
324
|
+
return () => {
|
|
325
|
+
const scope = useScope();
|
|
326
|
+
const state = statusState(scope);
|
|
327
|
+
if (scope !== void 0 && !state.empty) return null;
|
|
328
|
+
return h("div", { "data-part": "empty" }, [slots.default?.(state)]);
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
/** The selected labels as text, or the slot's own rendering of them. */
|
|
333
|
+
const ComboboxValue = defineComponent({
|
|
334
|
+
name: "ComboboxValue",
|
|
335
|
+
props: {
|
|
336
|
+
placeholder: {
|
|
337
|
+
type: String,
|
|
338
|
+
required: false
|
|
339
|
+
},
|
|
340
|
+
maxLabels: {
|
|
341
|
+
type: Number,
|
|
342
|
+
required: false
|
|
343
|
+
},
|
|
344
|
+
getMoreLabel: {
|
|
345
|
+
type: Function,
|
|
346
|
+
required: false
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
slots: Object,
|
|
350
|
+
setup(props, { slots }) {
|
|
351
|
+
return () => {
|
|
352
|
+
const scope = useScope();
|
|
353
|
+
const values = scope?.compound.values() ?? [];
|
|
354
|
+
const labels = scope?.compound.labels() ?? [];
|
|
355
|
+
const label = comboboxValueText(labels, props.maxLabels, props.getMoreLabel);
|
|
356
|
+
const state = {
|
|
357
|
+
value: scope?.compound.multiple() ? values : values[0],
|
|
358
|
+
values,
|
|
359
|
+
label,
|
|
360
|
+
labels,
|
|
361
|
+
placeholder: values.length === 0
|
|
362
|
+
};
|
|
363
|
+
return h("span", { "data-part": "value" }, [slots.default?.(state) ?? (values.length > 0 ? label : props.placeholder)]);
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
/** The chips' container. */
|
|
368
|
+
const ComboboxChips = defineComponent({
|
|
369
|
+
name: "ComboboxChips",
|
|
370
|
+
setup(_props, { slots }) {
|
|
371
|
+
return () => h("div", { "data-part": "chips" }, slots.default?.());
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
/** One selected value as a chip; a `ComboboxChipRemove` inside removes it. */
|
|
375
|
+
const ComboboxChip = defineComponent({
|
|
376
|
+
name: "ComboboxChip",
|
|
377
|
+
props: { value: {
|
|
378
|
+
type: String,
|
|
379
|
+
required: false
|
|
380
|
+
} },
|
|
381
|
+
setup(props, { slots }) {
|
|
382
|
+
provide(CHIP, { value: () => props.value });
|
|
383
|
+
return () => h("span", { "data-part": "chip" }, slots.default?.());
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
/** Removes the surrounding chip's value. */
|
|
387
|
+
const ComboboxChipRemove = defineComponent({
|
|
388
|
+
name: "ComboboxChipRemove",
|
|
389
|
+
setup(_props, { slots }) {
|
|
390
|
+
const scope = inject(SCOPE, void 0);
|
|
391
|
+
const chip = inject(CHIP, void 0);
|
|
392
|
+
return () => h("button", {
|
|
393
|
+
type: "button",
|
|
394
|
+
tabindex: -1,
|
|
395
|
+
"data-part": "chip-remove",
|
|
396
|
+
onClick: () => {
|
|
397
|
+
const value = chip?.value();
|
|
398
|
+
if (value !== void 0) scope?.compound.dispatch({
|
|
399
|
+
type: "remove",
|
|
400
|
+
value
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
}, [slots.default?.() ?? "×"]);
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
/** A count of chips the host chose not to draw. The slot receives `{ count, labels }`. */
|
|
407
|
+
const ComboboxChipsOverflow = defineComponent({
|
|
408
|
+
name: "ComboboxChipsOverflow",
|
|
409
|
+
props: { count: {
|
|
410
|
+
type: Number,
|
|
411
|
+
required: false
|
|
412
|
+
} },
|
|
413
|
+
slots: Object,
|
|
414
|
+
setup(props, { slots }) {
|
|
415
|
+
return () => {
|
|
416
|
+
const labels = useScope()?.compound.labels() ?? [];
|
|
417
|
+
return h("span", { "data-part": "chips-overflow" }, [slots.default?.({
|
|
418
|
+
count: props.count ?? labels.length,
|
|
419
|
+
labels
|
|
420
|
+
})]);
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
/** A row's state as its slot receives it. */
|
|
425
|
+
/**
|
|
426
|
+
* One choosable row. It registers its value and label with the root, hides
|
|
427
|
+
* while the query filters it out, and selects on press. The slot receives
|
|
428
|
+
* `{ selected, highlighted, disabled, maxReached }`.
|
|
429
|
+
*/
|
|
430
|
+
const ComboboxItem = defineComponent({
|
|
431
|
+
name: "ComboboxItem",
|
|
432
|
+
props: {
|
|
433
|
+
value: {
|
|
434
|
+
type: String,
|
|
435
|
+
required: true
|
|
436
|
+
},
|
|
437
|
+
label: {
|
|
438
|
+
type: String,
|
|
439
|
+
required: false
|
|
440
|
+
},
|
|
441
|
+
keywords: {
|
|
442
|
+
type: Array,
|
|
443
|
+
required: false
|
|
444
|
+
},
|
|
445
|
+
disabled: {
|
|
446
|
+
type: Boolean,
|
|
447
|
+
default: false
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
emits: { select: (_value) => true },
|
|
451
|
+
slots: Object,
|
|
452
|
+
setup(props, { slots, emit }) {
|
|
453
|
+
const scope = inject(SCOPE, void 0);
|
|
454
|
+
const element = shallowRef(null);
|
|
455
|
+
const text = ref(props.label ?? props.value);
|
|
456
|
+
const label = () => props.label ?? text.value;
|
|
457
|
+
const entry = () => ({
|
|
458
|
+
value: props.value,
|
|
459
|
+
label: label(),
|
|
460
|
+
...props.keywords === void 0 ? {} : { keywords: props.keywords },
|
|
461
|
+
...props.disabled ? { disabled: true } : {}
|
|
462
|
+
});
|
|
463
|
+
let registration;
|
|
464
|
+
onMounted(() => {
|
|
465
|
+
if (props.label === void 0) text.value = element.value?.textContent?.trim() || props.value;
|
|
466
|
+
registration = scope?.compound.register(entry(), () => element.value);
|
|
467
|
+
});
|
|
468
|
+
watch(() => [
|
|
469
|
+
props.value,
|
|
470
|
+
props.label,
|
|
471
|
+
props.keywords,
|
|
472
|
+
props.disabled,
|
|
473
|
+
text.value
|
|
474
|
+
], () => registration?.update(entry()));
|
|
475
|
+
onBeforeUnmount(() => registration?.dispose());
|
|
476
|
+
const selected = computed(() => {
|
|
477
|
+
scope?.version.value;
|
|
478
|
+
return scope?.compound.values().includes(props.value) ?? false;
|
|
479
|
+
});
|
|
480
|
+
provide(ITEM, {
|
|
481
|
+
value: props.value,
|
|
482
|
+
label,
|
|
483
|
+
selected: () => selected.value
|
|
484
|
+
});
|
|
485
|
+
return () => {
|
|
486
|
+
scope?.version.value;
|
|
487
|
+
if (scope !== void 0 && scope.compound.query() !== "" && !scope.compound.matches(entry())) return null;
|
|
488
|
+
const state = scope?.compound.itemState(props.value, props.disabled) ?? {
|
|
489
|
+
selected: false,
|
|
490
|
+
highlighted: false,
|
|
491
|
+
disabled: props.disabled,
|
|
492
|
+
maxReached: false
|
|
493
|
+
};
|
|
494
|
+
return h("div", {
|
|
495
|
+
ref: element,
|
|
496
|
+
role: "option",
|
|
497
|
+
id: registration?.id,
|
|
498
|
+
"data-part": "option",
|
|
499
|
+
"data-value": props.value,
|
|
500
|
+
"aria-selected": state.selected ? "true" : "false",
|
|
501
|
+
...state.selected ? { "data-selected": "" } : {},
|
|
502
|
+
...state.highlighted ? { "data-highlighted": "" } : {},
|
|
503
|
+
...state.disabled ? {
|
|
504
|
+
"aria-disabled": "true",
|
|
505
|
+
"data-disabled": ""
|
|
506
|
+
} : {},
|
|
507
|
+
onPointermove: () => {
|
|
508
|
+
if (scope === void 0 || state.disabled) return;
|
|
509
|
+
const index = scope.compound.visible().findIndex((row) => row.value === props.value);
|
|
510
|
+
scope.compound.dispatch({
|
|
511
|
+
type: "highlight",
|
|
512
|
+
value: props.value,
|
|
513
|
+
index
|
|
514
|
+
});
|
|
515
|
+
},
|
|
516
|
+
onMousedown: (event) => event.preventDefault(),
|
|
517
|
+
onClick: () => {
|
|
518
|
+
if (state.disabled) return;
|
|
519
|
+
scope?.compound.dispatch({
|
|
520
|
+
type: "toggle",
|
|
521
|
+
value: props.value
|
|
522
|
+
});
|
|
523
|
+
emit("select", props.value);
|
|
524
|
+
}
|
|
525
|
+
}, [slots.default?.(state)]);
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
/** The row's label; the slot receives the label split around the typed query. */
|
|
530
|
+
const ComboboxItemText = defineComponent({
|
|
531
|
+
name: "ComboboxItemText",
|
|
532
|
+
slots: Object,
|
|
533
|
+
setup(_props, { slots }) {
|
|
534
|
+
const item = inject(ITEM, void 0);
|
|
535
|
+
return () => {
|
|
536
|
+
const scope = useScope();
|
|
537
|
+
const label = item?.label() ?? "";
|
|
538
|
+
const content = slots.default?.({ segments: comboboxMatchSegments(label, scope?.compound.query() ?? "") });
|
|
539
|
+
return h("span", { "data-part": "label" }, content ?? label);
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
/** The selected row's mark; renders only while its row is selected unless `keepMounted`. */
|
|
544
|
+
const ComboboxItemIndicator = defineComponent({
|
|
545
|
+
name: "ComboboxItemIndicator",
|
|
546
|
+
props: { keepMounted: {
|
|
547
|
+
type: Boolean,
|
|
548
|
+
default: false
|
|
549
|
+
} },
|
|
550
|
+
setup(props, { slots }) {
|
|
551
|
+
const item = inject(ITEM, void 0);
|
|
552
|
+
return () => {
|
|
553
|
+
useScope();
|
|
554
|
+
const selected = item?.selected() ?? false;
|
|
555
|
+
if (!selected && !props.keepMounted) return null;
|
|
556
|
+
return h("span", {
|
|
557
|
+
"data-part": "indicator",
|
|
558
|
+
"aria-hidden": "true",
|
|
559
|
+
...selected ? { "data-selected": "" } : { hidden: true }
|
|
560
|
+
}, slots.default?.());
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
/** A decorative icon inside a row; `mirror` flips it in right-to-left text. */
|
|
565
|
+
const ComboboxItemIcon = defineComponent({
|
|
566
|
+
name: "ComboboxItemIcon",
|
|
567
|
+
props: { mirror: {
|
|
568
|
+
type: Boolean,
|
|
569
|
+
default: false
|
|
570
|
+
} },
|
|
571
|
+
setup(props, { slots }) {
|
|
572
|
+
return () => h("span", {
|
|
573
|
+
"data-part": "icon",
|
|
574
|
+
"aria-hidden": "true",
|
|
575
|
+
...props.mirror ? { "data-mirror": "" } : {}
|
|
576
|
+
}, slots.default?.());
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
/** A decorative icon for the selected value beside the field. */
|
|
580
|
+
const ComboboxValueIcon = defineComponent({
|
|
581
|
+
name: "ComboboxValueIcon",
|
|
582
|
+
setup(_props, { slots }) {
|
|
583
|
+
return () => h("span", {
|
|
584
|
+
"data-part": "value-icon",
|
|
585
|
+
"aria-hidden": "true"
|
|
586
|
+
}, slots.default?.());
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
/** A labelled run of rows; a `ComboboxGroupLabel` inside names it. */
|
|
590
|
+
const ComboboxGroup = defineComponent({
|
|
591
|
+
name: "ComboboxGroup",
|
|
592
|
+
setup(_props, { slots }) {
|
|
593
|
+
const labelId = `bevelo-combobox-group-${useId().replace(/[^a-zA-Z0-9_-]/gu, "")}`;
|
|
594
|
+
provide(GROUP, labelId);
|
|
595
|
+
return () => h("div", {
|
|
596
|
+
role: "group",
|
|
597
|
+
"data-part": "group",
|
|
598
|
+
"aria-labelledby": labelId
|
|
599
|
+
}, slots.default?.());
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
/** The heading of the surrounding group. */
|
|
603
|
+
const ComboboxGroupLabel = defineComponent({
|
|
604
|
+
name: "ComboboxGroupLabel",
|
|
605
|
+
setup(_props, { slots }) {
|
|
606
|
+
const id = inject(GROUP, void 0);
|
|
607
|
+
return () => h("div", {
|
|
608
|
+
id,
|
|
609
|
+
"data-part": "label",
|
|
610
|
+
"data-scope": "group"
|
|
611
|
+
}, slots.default?.());
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
/** A rule between groups. */
|
|
615
|
+
const ComboboxSeparator = defineComponent({
|
|
616
|
+
name: "ComboboxSeparator",
|
|
617
|
+
setup() {
|
|
618
|
+
return () => h("div", {
|
|
619
|
+
role: "separator",
|
|
620
|
+
"data-part": "separator"
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
/**
|
|
625
|
+
* Selects every enabled row, or clears them once all are chosen. The slot
|
|
626
|
+
* receives `{ checked, indeterminate }`.
|
|
627
|
+
*/
|
|
628
|
+
const ComboboxSelectAll = defineComponent({
|
|
629
|
+
name: "ComboboxSelectAll",
|
|
630
|
+
slots: Object,
|
|
631
|
+
setup(_props, { slots }) {
|
|
632
|
+
return () => {
|
|
633
|
+
const scope = useScope();
|
|
634
|
+
const state = scope?.compound.selectAllState() ?? {
|
|
635
|
+
checked: false,
|
|
636
|
+
indeterminate: false
|
|
637
|
+
};
|
|
638
|
+
return h("div", {
|
|
639
|
+
role: "option",
|
|
640
|
+
"data-part": "select-all",
|
|
641
|
+
"aria-selected": state.checked ? "true" : "false",
|
|
642
|
+
...state.indeterminate ? { "data-indeterminate": "" } : {},
|
|
643
|
+
onMousedown: (event) => event.preventDefault(),
|
|
644
|
+
onClick: () => scope?.compound.selectAll()
|
|
645
|
+
}, [slots.default?.(state) ?? "Select all"]);
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
// src/combobox.ts
|
|
650
|
+
const schema = vueOptions(comboboxPrimitive, {
|
|
651
|
+
modelValue: ["value", "onChange"],
|
|
652
|
+
value: ["value", "onChange"],
|
|
653
|
+
open: ["open", "onOpenChange"],
|
|
654
|
+
inputValue: ["inputValue", "onInput"]
|
|
655
|
+
});
|
|
656
|
+
const Combobox = defineComponent({
|
|
657
|
+
name: "Combobox",
|
|
658
|
+
inheritAttrs: false,
|
|
659
|
+
props: {
|
|
660
|
+
...schema.props,
|
|
661
|
+
...placementProps,
|
|
662
|
+
options: {
|
|
663
|
+
type: Array,
|
|
664
|
+
required: false
|
|
665
|
+
},
|
|
666
|
+
label: {
|
|
667
|
+
type: String,
|
|
668
|
+
default: ""
|
|
669
|
+
},
|
|
670
|
+
container: {
|
|
671
|
+
type: [Object, Function],
|
|
672
|
+
required: false
|
|
673
|
+
},
|
|
674
|
+
/** Shown when no option matches the typed text. */
|
|
675
|
+
emptyText: {
|
|
676
|
+
type: String,
|
|
677
|
+
default: "No results"
|
|
678
|
+
},
|
|
679
|
+
/** The create row's text for the typed value. */
|
|
680
|
+
createText: {
|
|
681
|
+
type: Function,
|
|
682
|
+
default: (text) => `Create “${text}”`
|
|
683
|
+
},
|
|
684
|
+
/** Composed form: the selection holds many values and `v-model` is an array. */
|
|
685
|
+
multiple: {
|
|
686
|
+
type: Boolean,
|
|
687
|
+
default: false
|
|
688
|
+
},
|
|
689
|
+
/** Composed form: the most values a multiple selection takes. */
|
|
690
|
+
maxSelected: {
|
|
691
|
+
type: Number,
|
|
692
|
+
required: false
|
|
693
|
+
},
|
|
694
|
+
/** Composed form: Enter with no highlighted row chooses the typed text. */
|
|
695
|
+
allowCustomValue: {
|
|
696
|
+
type: Boolean,
|
|
697
|
+
default: false
|
|
698
|
+
},
|
|
699
|
+
/** Composed form: the text the field starts with. */
|
|
700
|
+
defaultQuery: {
|
|
701
|
+
type: String,
|
|
702
|
+
required: false
|
|
703
|
+
},
|
|
704
|
+
/** Composed form: shows the value but refuses changes and never opens. */
|
|
705
|
+
readOnly: {
|
|
706
|
+
type: Boolean,
|
|
707
|
+
default: false
|
|
708
|
+
},
|
|
709
|
+
/** Composed form: the arrows wrap from the last row to the first. */
|
|
710
|
+
loop: {
|
|
711
|
+
type: Boolean,
|
|
712
|
+
default: true
|
|
713
|
+
},
|
|
714
|
+
/** Composed form: the data the `ComboboxList` slot receives. */
|
|
715
|
+
items: {
|
|
716
|
+
type: Array,
|
|
717
|
+
required: false
|
|
718
|
+
},
|
|
719
|
+
/** Composed form: the data the list receives while the query is empty. */
|
|
720
|
+
emptyItems: {
|
|
721
|
+
type: Array,
|
|
722
|
+
required: false
|
|
723
|
+
},
|
|
724
|
+
/** Composed form: the label a value shows in the field and in `ComboboxValue`. */
|
|
725
|
+
itemToLabel: {
|
|
726
|
+
type: Function,
|
|
727
|
+
required: false
|
|
728
|
+
}
|
|
729
|
+
},
|
|
730
|
+
emits: {
|
|
731
|
+
...schema.emits,
|
|
732
|
+
highlight: (_value, _details) => true
|
|
733
|
+
},
|
|
734
|
+
slots: Object,
|
|
735
|
+
setup(props, { attrs, slots, emit, expose }) {
|
|
736
|
+
if (slots.default !== void 0 || props.items !== void 0) return setupComboboxCompound(props, emit, attrs, slots, expose);
|
|
737
|
+
const resolved = usePlacement(props, "bottom", 8);
|
|
738
|
+
const handle = usePrimitive(comboboxPrimitive, schema.bind(props, () => ({
|
|
739
|
+
options: props.options ?? EMPTY_LISTBOX_OPTIONS,
|
|
740
|
+
placement: resolved.value.placement,
|
|
741
|
+
offset: resolved.value.offset ?? 8,
|
|
742
|
+
padding: resolved.value.padding,
|
|
743
|
+
boundary: resolved.value.boundary
|
|
744
|
+
})));
|
|
745
|
+
const api = handle.api;
|
|
746
|
+
let inputElement = null;
|
|
747
|
+
expose({ api: {
|
|
748
|
+
...api,
|
|
749
|
+
focus: () => inputElement?.focus(),
|
|
750
|
+
setValue: (next) => {
|
|
751
|
+
if (typeof next === "string") api.choose(next);
|
|
752
|
+
else if (next === null) api.clear();
|
|
753
|
+
},
|
|
754
|
+
getValue: () => api.value(),
|
|
755
|
+
setQuery: (query) => api.typeText(query)
|
|
756
|
+
} });
|
|
757
|
+
const container = typeof props.container === "function" ? props.container() : props.container;
|
|
758
|
+
if (container !== void 0) providePortalTarget(container);
|
|
759
|
+
return () => {
|
|
760
|
+
handle.revision.value;
|
|
761
|
+
const value = handle.state.value;
|
|
762
|
+
const options = props.options ?? EMPTY_LISTBOX_OPTIONS;
|
|
763
|
+
const selectedOption = value === void 0 ? void 0 : optionMapOf(options).get(value);
|
|
764
|
+
const valueIconPart = renderPart(handle, "icon", { key: "value-icon" }, selectedOption?.icon === void 0 ? void 0 : descriptionNodes([selectedOption.icon]), { scope: "value" });
|
|
765
|
+
const labelPart = renderPart(handle, "label", { key: "label" }, props.label);
|
|
766
|
+
const input = renderPart(handle, "input", {
|
|
767
|
+
key: "input",
|
|
768
|
+
onChange: noop,
|
|
769
|
+
ref: (node) => {
|
|
770
|
+
inputElement = node instanceof HTMLInputElement ? node : null;
|
|
771
|
+
}
|
|
772
|
+
});
|
|
773
|
+
const triggerPart = renderPart(handle, "trigger", { key: "trigger" }, [h("span", { "aria-hidden": "true" }, slots.triggerIcon?.() ?? "▾")]);
|
|
774
|
+
const clearPart = renderPart(handle, "clear", { key: "clear" }, slots.clearIcon?.() ?? "×");
|
|
775
|
+
const rows = renderOptionSections(handle, api.sections(), slots);
|
|
776
|
+
const typed = api.createText();
|
|
777
|
+
const createRow = renderPart(handle, "create", { key: "create" }, slots.create?.({ text: typed }) ?? props.createText(typed));
|
|
778
|
+
const empty = renderPart(handle, "empty", { key: "empty" }, slots.empty?.() ?? props.emptyText);
|
|
779
|
+
const statusRegion = renderPart(handle, "status", { key: "status" }, props.status);
|
|
780
|
+
const list = renderPart(handle, "list", { key: "list" }, [h(Fragment, null, [...rows, createRow])]);
|
|
781
|
+
const content = renderPart(handle, "content", {
|
|
782
|
+
key: "content",
|
|
783
|
+
style: { ...PANEL_STYLE }
|
|
784
|
+
}, [h(Fragment, null, [
|
|
785
|
+
list,
|
|
786
|
+
empty,
|
|
787
|
+
statusRegion
|
|
788
|
+
])], { portal: true });
|
|
789
|
+
const carrier = renderPart(handle, "carrier", { key: "carrier" });
|
|
790
|
+
return renderPart(handle, "root", { ...attrs }, [h(Fragment, null, [
|
|
791
|
+
valueIconPart,
|
|
792
|
+
labelPart,
|
|
793
|
+
input,
|
|
794
|
+
triggerPart,
|
|
795
|
+
clearPart,
|
|
796
|
+
content,
|
|
797
|
+
carrier
|
|
798
|
+
])]);
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
export { ComboboxValue as C, ComboboxTrigger as S, ComboboxLabel as _, ComboboxChipsOverflow as a, ComboboxSeparator as b, ComboboxCreate as c, ComboboxGroupLabel as d, ComboboxInput as f, ComboboxItemText as g, ComboboxItemIndicator as h, ComboboxChips as i, ComboboxEmpty as l, ComboboxItemIcon as m, ComboboxChip as n, ComboboxClear as o, ComboboxItem as p, ComboboxChipRemove as r, ComboboxContent as s, Combobox as t, ComboboxGroup as u, ComboboxList as v, ComboboxValueIcon as w, ComboboxStatus as x, ComboboxSelectAll as y };
|