@getcortexlabs/mavis-core 0.1.0-alpha.1 → 0.1.0-alpha.11
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/README.md +2 -2
- package/dist/accordion.d.ts +17 -0
- package/dist/accordion.d.ts.map +1 -0
- package/dist/accordion.js +42 -0
- package/dist/accordion.js.map +1 -0
- package/dist/alert.d.ts +21 -0
- package/dist/alert.d.ts.map +1 -0
- package/dist/alert.js +13 -0
- package/dist/alert.js.map +1 -0
- package/dist/app-icons.d.ts +27 -0
- package/dist/app-icons.d.ts.map +1 -0
- package/dist/app-icons.js +42 -0
- package/dist/app-icons.js.map +1 -0
- package/dist/avatar.d.ts +10 -0
- package/dist/avatar.d.ts.map +1 -0
- package/dist/avatar.js +11 -0
- package/dist/avatar.js.map +1 -0
- package/dist/badge.d.ts +7 -0
- package/dist/badge.d.ts.map +1 -0
- package/dist/badge.js +11 -0
- package/dist/badge.js.map +1 -0
- package/dist/capabilities.d.ts +132 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +180 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/chart.d.ts +40 -0
- package/dist/chart.d.ts.map +1 -0
- package/dist/chart.js +73 -0
- package/dist/chart.js.map +1 -0
- package/dist/chip.d.ts +9 -0
- package/dist/chip.d.ts.map +1 -0
- package/dist/chip.js +16 -0
- package/dist/chip.js.map +1 -0
- package/dist/choice-motion.d.ts +14 -0
- package/dist/choice-motion.d.ts.map +1 -0
- package/dist/choice-motion.js +5 -0
- package/dist/choice-motion.js.map +1 -0
- package/dist/choice.d.ts +15 -0
- package/dist/choice.d.ts.map +1 -0
- package/dist/choice.js +27 -0
- package/dist/choice.js.map +1 -0
- package/dist/collections.d.ts +46 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +48 -0
- package/dist/collections.js.map +1 -0
- package/dist/combobox.d.ts +42 -0
- package/dist/combobox.d.ts.map +1 -0
- package/dist/combobox.js +159 -0
- package/dist/combobox.js.map +1 -0
- package/dist/contracts.d.ts +1321 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +268 -0
- package/dist/contracts.js.map +1 -0
- package/dist/date-input.d.ts +10 -0
- package/dist/date-input.d.ts.map +1 -0
- package/dist/date-input.js +58 -0
- package/dist/date-input.js.map +1 -0
- package/dist/date-time.d.ts +19 -0
- package/dist/date-time.d.ts.map +1 -0
- package/dist/date-time.js +27 -0
- package/dist/date-time.js.map +1 -0
- package/dist/date.d.ts +96 -0
- package/dist/date.d.ts.map +1 -0
- package/dist/date.js +235 -0
- package/dist/date.js.map +1 -0
- package/dist/dialog.d.ts +4 -0
- package/dist/dialog.d.ts.map +1 -0
- package/dist/dialog.js +21 -0
- package/dist/dialog.js.map +1 -0
- package/dist/discovery.d.ts +49 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +80 -0
- package/dist/discovery.js.map +1 -0
- package/dist/empty-state.d.ts +2 -0
- package/dist/empty-state.d.ts.map +1 -0
- package/dist/empty-state.js +5 -0
- package/dist/empty-state.js.map +1 -0
- package/dist/experimental-collections.d.ts +82 -0
- package/dist/experimental-collections.d.ts.map +1 -0
- package/dist/experimental-collections.js +8 -0
- package/dist/experimental-collections.js.map +1 -0
- package/dist/experimental-effects.d.ts +107 -0
- package/dist/experimental-effects.d.ts.map +1 -0
- package/dist/experimental-effects.js +24 -0
- package/dist/experimental-effects.js.map +1 -0
- package/dist/experimental-platforms.d.ts +94 -0
- package/dist/experimental-platforms.d.ts.map +1 -0
- package/dist/experimental-platforms.js +2 -0
- package/dist/experimental-platforms.js.map +1 -0
- package/dist/experimental-playback.d.ts +63 -0
- package/dist/experimental-playback.d.ts.map +1 -0
- package/dist/experimental-playback.js +46 -0
- package/dist/experimental-playback.js.map +1 -0
- package/dist/experimental-regions.d.ts +179 -0
- package/dist/experimental-regions.d.ts.map +1 -0
- package/dist/experimental-regions.js +554 -0
- package/dist/experimental-regions.js.map +1 -0
- package/dist/experimental-sensors.d.ts +42 -0
- package/dist/experimental-sensors.d.ts.map +1 -0
- package/dist/experimental-sensors.js +2 -0
- package/dist/experimental-sensors.js.map +1 -0
- package/dist/experimental-surfaces.d.ts +127 -0
- package/dist/experimental-surfaces.d.ts.map +1 -0
- package/dist/experimental-surfaces.js +2 -0
- package/dist/experimental-surfaces.js.map +1 -0
- package/dist/experimental.d.ts +197 -0
- package/dist/experimental.d.ts.map +1 -0
- package/dist/experimental.js +855 -0
- package/dist/experimental.js.map +1 -0
- package/dist/files.d.ts +87 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +328 -0
- package/dist/files.js.map +1 -0
- package/dist/form.d.ts +39 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +170 -0
- package/dist/form.js.map +1 -0
- package/dist/grid.d.ts +3 -0
- package/dist/grid.d.ts.map +1 -0
- package/dist/grid.js +16 -0
- package/dist/grid.js.map +1 -0
- package/dist/icon.d.ts +15 -0
- package/dist/icon.d.ts.map +1 -0
- package/dist/icon.js +28 -0
- package/dist/icon.js.map +1 -0
- package/dist/icons.d.ts +2002 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +2003 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +59 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -1
- package/dist/index.js.map +1 -1
- package/dist/input.d.ts +14 -0
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +12 -0
- package/dist/input.js.map +1 -1
- package/dist/link.d.ts +36 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +60 -0
- package/dist/link.js.map +1 -0
- package/dist/list-item.d.ts +3 -0
- package/dist/list-item.d.ts.map +1 -0
- package/dist/list-item.js +7 -0
- package/dist/list-item.js.map +1 -0
- package/dist/motion.d.ts +58 -0
- package/dist/motion.d.ts.map +1 -0
- package/dist/motion.js +73 -0
- package/dist/motion.js.map +1 -0
- package/dist/multi-select.d.ts +4 -0
- package/dist/multi-select.d.ts.map +1 -0
- package/dist/multi-select.js +23 -0
- package/dist/multi-select.js.map +1 -0
- package/dist/navigation-transition.d.ts +10 -0
- package/dist/navigation-transition.d.ts.map +1 -0
- package/dist/navigation-transition.js +10 -0
- package/dist/navigation-transition.js.map +1 -0
- package/dist/navigation.d.ts +22 -0
- package/dist/navigation.d.ts.map +1 -0
- package/dist/navigation.js +54 -0
- package/dist/navigation.js.map +1 -0
- package/dist/number-input.d.ts +21 -0
- package/dist/number-input.d.ts.map +1 -0
- package/dist/number-input.js +63 -0
- package/dist/number-input.js.map +1 -0
- package/dist/popover.d.ts +17 -0
- package/dist/popover.d.ts.map +1 -0
- package/dist/popover.js +19 -0
- package/dist/popover.js.map +1 -0
- package/dist/progress.d.ts +19 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +19 -0
- package/dist/progress.js.map +1 -0
- package/dist/responsive.d.ts +18 -0
- package/dist/responsive.d.ts.map +1 -0
- package/dist/responsive.js +35 -0
- package/dist/responsive.js.map +1 -0
- package/dist/section-scroll.d.ts +14 -0
- package/dist/section-scroll.d.ts.map +1 -0
- package/dist/section-scroll.js +28 -0
- package/dist/section-scroll.js.map +1 -0
- package/dist/segmented.d.ts +11 -0
- package/dist/segmented.d.ts.map +1 -0
- package/dist/segmented.js +30 -0
- package/dist/segmented.js.map +1 -0
- package/dist/sheet.d.ts +19 -0
- package/dist/sheet.d.ts.map +1 -0
- package/dist/sheet.js +15 -0
- package/dist/sheet.js.map +1 -0
- package/dist/tabs.d.ts +11 -0
- package/dist/tabs.d.ts.map +1 -0
- package/dist/tabs.js +28 -0
- package/dist/tabs.js.map +1 -0
- package/dist/theme/themes.d.ts.map +1 -1
- package/dist/theme/themes.js +85 -12
- package/dist/theme/themes.js.map +1 -1
- package/dist/theme/types.d.ts +64 -4
- package/dist/theme/types.d.ts.map +1 -1
- package/dist/theme/typography.d.ts +10 -0
- package/dist/theme/typography.d.ts.map +1 -0
- package/dist/theme/typography.js +90 -0
- package/dist/theme/typography.js.map +1 -0
- package/dist/time.d.ts +34 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +78 -0
- package/dist/time.js.map +1 -0
- package/dist/toast.d.ts +43 -0
- package/dist/toast.d.ts.map +1 -0
- package/dist/toast.js +228 -0
- package/dist/toast.js.map +1 -0
- package/dist/vue/button-content.d.ts +10 -0
- package/dist/vue/button-content.d.ts.map +1 -0
- package/dist/vue/button-content.js +54 -0
- package/dist/vue/button-content.js.map +1 -0
- package/dist/vue/cached-activity.d.ts +3 -0
- package/dist/vue/cached-activity.d.ts.map +1 -0
- package/dist/vue/cached-activity.js +13 -0
- package/dist/vue/cached-activity.js.map +1 -0
- package/dist/vue/carousel.d.ts +11 -0
- package/dist/vue/carousel.d.ts.map +1 -0
- package/dist/vue/carousel.js +115 -0
- package/dist/vue/carousel.js.map +1 -0
- package/dist/vue/chart.d.ts +194 -0
- package/dist/vue/chart.d.ts.map +1 -0
- package/dist/vue/chart.js +246 -0
- package/dist/vue/chart.js.map +1 -0
- package/dist/vue/combobox.d.ts +155 -0
- package/dist/vue/combobox.d.ts.map +1 -0
- package/dist/vue/combobox.js +195 -0
- package/dist/vue/combobox.js.map +1 -0
- package/dist/vue/command-palette.d.ts +129 -0
- package/dist/vue/command-palette.d.ts.map +1 -0
- package/dist/vue/command-palette.js +187 -0
- package/dist/vue/command-palette.js.map +1 -0
- package/dist/vue/component-props.d.ts +3310 -0
- package/dist/vue/component-props.d.ts.map +1 -0
- package/dist/vue/component-props.js +43 -0
- package/dist/vue/component-props.js.map +1 -0
- package/dist/vue/configurator-props.d.ts +277 -0
- package/dist/vue/configurator-props.d.ts.map +1 -0
- package/dist/vue/configurator-props.js +63 -0
- package/dist/vue/configurator-props.js.map +1 -0
- package/dist/vue/configurator.d.ts +403 -0
- package/dist/vue/configurator.d.ts.map +1 -0
- package/dist/vue/configurator.js +287 -0
- package/dist/vue/configurator.js.map +1 -0
- package/dist/vue/contracts.d.ts +18 -0
- package/dist/vue/contracts.d.ts.map +1 -0
- package/dist/vue/contracts.js +24 -0
- package/dist/vue/contracts.js.map +1 -0
- package/dist/vue/data-table.d.ts +17 -0
- package/dist/vue/data-table.d.ts.map +1 -0
- package/dist/vue/data-table.js +133 -0
- package/dist/vue/data-table.js.map +1 -0
- package/dist/vue/date-calendar.d.ts +64 -0
- package/dist/vue/date-calendar.d.ts.map +1 -0
- package/dist/vue/date-calendar.js +65 -0
- package/dist/vue/date-calendar.js.map +1 -0
- package/dist/vue/date-picker.d.ts +1000 -0
- package/dist/vue/date-picker.d.ts.map +1 -0
- package/dist/vue/date-picker.js +334 -0
- package/dist/vue/date-picker.js.map +1 -0
- package/dist/vue/date-props.d.ts +278 -0
- package/dist/vue/date-props.d.ts.map +1 -0
- package/dist/vue/date-props.js +81 -0
- package/dist/vue/date-props.js.map +1 -0
- package/dist/vue/dialog.d.ts +21 -0
- package/dist/vue/dialog.d.ts.map +1 -0
- package/dist/vue/dialog.js +58 -0
- package/dist/vue/dialog.js.map +1 -0
- package/dist/vue/discovery-components.d.ts +50 -0
- package/dist/vue/discovery-components.d.ts.map +1 -0
- package/dist/vue/discovery-components.js +2 -0
- package/dist/vue/discovery-components.js.map +1 -0
- package/dist/vue/discovery-controls.d.ts +197 -0
- package/dist/vue/discovery-controls.d.ts.map +1 -0
- package/dist/vue/discovery-controls.js +166 -0
- package/dist/vue/discovery-controls.js.map +1 -0
- package/dist/vue/discovery-props.d.ts +249 -0
- package/dist/vue/discovery-props.d.ts.map +1 -0
- package/dist/vue/discovery-props.js +87 -0
- package/dist/vue/discovery-props.js.map +1 -0
- package/dist/vue/files.d.ts +53 -0
- package/dist/vue/files.d.ts.map +1 -0
- package/dist/vue/files.js +40 -0
- package/dist/vue/files.js.map +1 -0
- package/dist/vue/forms.d.ts +4 -0
- package/dist/vue/forms.d.ts.map +1 -0
- package/dist/vue/forms.js +15 -0
- package/dist/vue/forms.js.map +1 -0
- package/dist/vue/global-components.d.ts +259 -3
- package/dist/vue/global-components.d.ts.map +1 -1
- package/dist/vue/index.d.ts +54 -4
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +45 -2
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/inline-content.d.ts +54 -0
- package/dist/vue/inline-content.d.ts.map +1 -0
- package/dist/vue/inline-content.js +64 -0
- package/dist/vue/inline-content.js.map +1 -0
- package/dist/vue/layout-context.d.ts +4 -2
- package/dist/vue/layout-context.d.ts.map +1 -1
- package/dist/vue/layout-context.js +7 -2
- package/dist/vue/layout-context.js.map +1 -1
- package/dist/vue/list-motion.d.ts +7 -0
- package/dist/vue/list-motion.d.ts.map +1 -0
- package/dist/vue/list-motion.js +28 -0
- package/dist/vue/list-motion.js.map +1 -0
- package/dist/vue/loading-effect.d.ts +7 -0
- package/dist/vue/loading-effect.d.ts.map +1 -0
- package/dist/vue/loading-effect.js +32 -0
- package/dist/vue/loading-effect.js.map +1 -0
- package/dist/vue/menu.d.ts +122 -0
- package/dist/vue/menu.d.ts.map +1 -0
- package/dist/vue/menu.js +79 -0
- package/dist/vue/menu.js.map +1 -0
- package/dist/vue/navigation-controls.d.ts +124 -0
- package/dist/vue/navigation-controls.d.ts.map +1 -0
- package/dist/vue/navigation-controls.js +117 -0
- package/dist/vue/navigation-controls.js.map +1 -0
- package/dist/vue/navigation-props.d.ts +283 -0
- package/dist/vue/navigation-props.d.ts.map +1 -0
- package/dist/vue/navigation-props.js +82 -0
- package/dist/vue/navigation-props.js.map +1 -0
- package/dist/vue/navigation.d.ts +7 -0
- package/dist/vue/navigation.d.ts.map +1 -0
- package/dist/vue/navigation.js +15 -0
- package/dist/vue/navigation.js.map +1 -0
- package/dist/vue/platform.d.ts +37 -0
- package/dist/vue/platform.d.ts.map +1 -0
- package/dist/vue/platform.js +46 -0
- package/dist/vue/platform.js.map +1 -0
- package/dist/vue/props.d.ts +3326 -510
- package/dist/vue/props.d.ts.map +1 -1
- package/dist/vue/props.js +314 -83
- package/dist/vue/props.js.map +1 -1
- package/dist/vue/reveal-state.d.ts +18 -0
- package/dist/vue/reveal-state.d.ts.map +1 -0
- package/dist/vue/reveal-state.js +76 -0
- package/dist/vue/reveal-state.js.map +1 -0
- package/dist/vue/theme-provider.d.ts +58 -0
- package/dist/vue/theme-provider.d.ts.map +1 -0
- package/dist/vue/theme-provider.js +69 -0
- package/dist/vue/theme-provider.js.map +1 -0
- package/dist/vue/theme.d.ts +1029 -19
- package/dist/vue/theme.d.ts.map +1 -1
- package/dist/vue/theme.js +47 -2
- package/dist/vue/theme.js.map +1 -1
- package/dist/vue/time-picker.d.ts +488 -0
- package/dist/vue/time-picker.d.ts.map +1 -0
- package/dist/vue/time-picker.js +190 -0
- package/dist/vue/time-picker.js.map +1 -0
- package/dist/vue/toast.d.ts +29 -0
- package/dist/vue/toast.d.ts.map +1 -0
- package/dist/vue/toast.js +79 -0
- package/dist/vue/toast.js.map +1 -0
- package/dist/vue/tree-view.d.ts +111 -0
- package/dist/vue/tree-view.d.ts.map +1 -0
- package/dist/vue/tree-view.js +180 -0
- package/dist/vue/tree-view.js.map +1 -0
- package/dist/vue/virtual-list.d.ts +26 -0
- package/dist/vue/virtual-list.d.ts.map +1 -0
- package/dist/vue/virtual-list.js +2 -0
- package/dist/vue/virtual-list.js.map +1 -0
- package/dist/vue/wayfinding-controls.d.ts +198 -0
- package/dist/vue/wayfinding-controls.d.ts.map +1 -0
- package/dist/vue/wayfinding-controls.js +310 -0
- package/dist/vue/wayfinding-controls.js.map +1 -0
- package/dist/vue/wayfinding-props.d.ts +221 -0
- package/dist/vue/wayfinding-props.d.ts.map +1 -0
- package/dist/vue/wayfinding-props.js +86 -0
- package/dist/vue/wayfinding-props.js.map +1 -0
- package/dist/vue/workflow-props.d.ts +110 -0
- package/dist/vue/workflow-props.d.ts.map +1 -0
- package/dist/vue/workflow-props.js +37 -0
- package/dist/vue/workflow-props.js.map +1 -0
- package/dist/vue/workflows.d.ts +267 -0
- package/dist/vue/workflows.d.ts.map +1 -0
- package/dist/vue/workflows.js +200 -0
- package/dist/vue/workflows.js.map +1 -0
- package/dist/wayfinding.d.ts +50 -0
- package/dist/wayfinding.d.ts.map +1 -0
- package/dist/wayfinding.js +54 -0
- package/dist/wayfinding.js.map +1 -0
- package/package.json +5 -1
- package/src/accordion.ts +66 -0
- package/src/alert.ts +16 -0
- package/src/app-icons.ts +57 -0
- package/src/avatar.ts +11 -0
- package/src/badge.ts +11 -0
- package/src/capabilities.ts +183 -0
- package/src/chart.ts +112 -0
- package/src/chip.ts +20 -0
- package/src/choice-motion.ts +12 -0
- package/src/choice.ts +41 -0
- package/src/collections.ts +87 -0
- package/src/combobox.ts +198 -0
- package/src/contracts.ts +324 -0
- package/src/date-input.ts +87 -0
- package/src/date-time.ts +37 -0
- package/src/date.ts +280 -0
- package/src/dialog.ts +22 -0
- package/src/discovery.ts +139 -0
- package/src/empty-state.ts +4 -0
- package/src/experimental-collections.ts +87 -0
- package/src/experimental-effects.ts +146 -0
- package/src/experimental-platforms.ts +96 -0
- package/src/experimental-playback.ts +115 -0
- package/src/experimental-regions.ts +777 -0
- package/src/experimental-sensors.ts +50 -0
- package/src/experimental-surfaces.ts +124 -0
- package/src/experimental.ts +1102 -0
- package/src/files.ts +408 -0
- package/src/form.ts +190 -0
- package/src/grid.ts +19 -0
- package/src/icon.ts +30 -0
- package/src/icons.ts +2002 -0
- package/src/index.ts +93 -2
- package/src/input.ts +27 -0
- package/src/link.ts +91 -0
- package/src/list-item.ts +5 -0
- package/src/motion.ts +80 -0
- package/src/multi-select.ts +30 -0
- package/src/navigation-transition.ts +14 -0
- package/src/navigation.ts +61 -0
- package/src/number-input.ts +80 -0
- package/src/popover.ts +38 -0
- package/src/progress.ts +22 -0
- package/src/responsive.ts +61 -0
- package/src/section-scroll.ts +46 -0
- package/src/segmented.ts +39 -0
- package/src/sheet.ts +31 -0
- package/src/tabs.ts +35 -0
- package/src/theme/themes.ts +89 -12
- package/src/theme/types.ts +55 -2
- package/src/theme/typography.ts +84 -0
- package/src/time.ts +83 -0
- package/src/toast.ts +249 -0
- package/src/vue/button-content.ts +60 -0
- package/src/vue/cached-activity.ts +13 -0
- package/src/vue/carousel.ts +173 -0
- package/src/vue/chart.ts +338 -0
- package/src/vue/combobox.ts +238 -0
- package/src/vue/command-palette.ts +232 -0
- package/src/vue/component-props.ts +70 -0
- package/src/vue/configurator-props.ts +67 -0
- package/src/vue/configurator.ts +350 -0
- package/src/vue/contracts.ts +39 -0
- package/src/vue/data-table.ts +190 -0
- package/src/vue/date-calendar.ts +76 -0
- package/src/vue/date-picker.ts +410 -0
- package/src/vue/date-props.ts +89 -0
- package/src/vue/dialog.ts +63 -0
- package/src/vue/discovery-components.ts +60 -0
- package/src/vue/discovery-controls.ts +218 -0
- package/src/vue/discovery-props.ts +92 -0
- package/src/vue/files.ts +53 -0
- package/src/vue/forms.ts +20 -0
- package/src/vue/global-components.ts +248 -4
- package/src/vue/index.ts +97 -4
- package/src/vue/inline-content.ts +71 -0
- package/src/vue/layout-context.ts +10 -3
- package/src/vue/list-motion.ts +31 -0
- package/src/vue/loading-effect.ts +44 -0
- package/src/vue/menu.ts +100 -0
- package/src/vue/navigation-controls.ts +138 -0
- package/src/vue/navigation-props.ts +87 -0
- package/src/vue/navigation.ts +16 -0
- package/src/vue/platform.ts +73 -0
- package/src/vue/props.ts +348 -96
- package/src/vue/reveal-state.ts +83 -0
- package/src/vue/theme-provider.ts +74 -0
- package/src/vue/theme.ts +65 -3
- package/src/vue/time-picker.ts +227 -0
- package/src/vue/toast.ts +99 -0
- package/src/vue/tree-view.ts +220 -0
- package/src/vue/virtual-list.ts +28 -0
- package/src/vue/wayfinding-controls.ts +412 -0
- package/src/vue/wayfinding-props.ts +97 -0
- package/src/vue/workflow-props.ts +41 -0
- package/src/vue/workflows.ts +257 -0
- package/src/wayfinding.ts +85 -0
package/src/vue/chart.ts
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
defineComponent,
|
|
4
|
+
h,
|
|
5
|
+
markRaw,
|
|
6
|
+
mergeProps,
|
|
7
|
+
onScopeDispose,
|
|
8
|
+
ref,
|
|
9
|
+
watch,
|
|
10
|
+
type Component,
|
|
11
|
+
type PropType,
|
|
12
|
+
} from '@vue/runtime-core'
|
|
13
|
+
import { chartGeometry, type ChartGeometry, type ChartSelection } from '../chart.js'
|
|
14
|
+
import { choiceKey, type ChoiceValue } from '../choice.js'
|
|
15
|
+
import { createMotionSurface } from '../experimental.js'
|
|
16
|
+
import { chartProps } from './wayfinding-props.js'
|
|
17
|
+
import { useMavisTheme } from './theme.js'
|
|
18
|
+
|
|
19
|
+
export const chartPlotProps = {
|
|
20
|
+
geometry: { type: Object as PropType<ChartGeometry>, required: true as const },
|
|
21
|
+
colors: { type: Array as PropType<readonly string[]>, required: true as const },
|
|
22
|
+
type: { type: String as PropType<'line' | 'bar'>, required: true as const },
|
|
23
|
+
height: { type: Number, required: true as const },
|
|
24
|
+
selected: {
|
|
25
|
+
type: Object as PropType<{ category: number; series: number } | null>,
|
|
26
|
+
default: null,
|
|
27
|
+
},
|
|
28
|
+
disabled: Boolean,
|
|
29
|
+
}
|
|
30
|
+
export function createChart(
|
|
31
|
+
ui: {
|
|
32
|
+
Row: Component
|
|
33
|
+
Column: Component
|
|
34
|
+
Box: Component
|
|
35
|
+
Text: Component
|
|
36
|
+
Button: Component
|
|
37
|
+
Reveal: Component
|
|
38
|
+
Select: Component
|
|
39
|
+
Plot: Component
|
|
40
|
+
},
|
|
41
|
+
platform: 'web' | 'native',
|
|
42
|
+
) {
|
|
43
|
+
return defineComponent({
|
|
44
|
+
name: 'MChart',
|
|
45
|
+
inheritAttrs: false,
|
|
46
|
+
props: chartProps,
|
|
47
|
+
emits: {
|
|
48
|
+
'update:modelValue': (_selection: ChartSelection | null) => true,
|
|
49
|
+
'update:hiddenSeries': (_keys: ChoiceValue[]) => true,
|
|
50
|
+
},
|
|
51
|
+
setup(props, { attrs, emit }) {
|
|
52
|
+
const web = platform === 'web'
|
|
53
|
+
const { theme } = useMavisTheme()
|
|
54
|
+
const dataOpen = ref(props.showData)
|
|
55
|
+
watch(
|
|
56
|
+
() => props.showData,
|
|
57
|
+
(value) => {
|
|
58
|
+
dataOpen.value = value
|
|
59
|
+
},
|
|
60
|
+
)
|
|
61
|
+
const allGeometry = computed(() =>
|
|
62
|
+
chartGeometry(props.categories, props.series, props.domain),
|
|
63
|
+
)
|
|
64
|
+
const visible = computed(() =>
|
|
65
|
+
props.series.filter((series) => !props.hiddenSeries.includes(series.key)),
|
|
66
|
+
)
|
|
67
|
+
const geometry = computed(() => ({
|
|
68
|
+
...allGeometry.value,
|
|
69
|
+
series: allGeometry.value.series.filter(
|
|
70
|
+
(series) => !props.hiddenSeries.includes(series.key),
|
|
71
|
+
),
|
|
72
|
+
}))
|
|
73
|
+
const selected = computed(() => {
|
|
74
|
+
if (!props.modelValue) return null
|
|
75
|
+
const category = props.categories.findIndex(
|
|
76
|
+
(item) => item.key === props.modelValue!.category,
|
|
77
|
+
)
|
|
78
|
+
const series = visible.value.findIndex((item) => item.key === props.modelValue!.series)
|
|
79
|
+
return category < 0 || series < 0 ? null : { category, series }
|
|
80
|
+
})
|
|
81
|
+
const format = (value: number | null | undefined) =>
|
|
82
|
+
value == null ? props.missingLabel : (props.formatValue?.(value) ?? String(value))
|
|
83
|
+
const colors = computed(() => {
|
|
84
|
+
const palette = [
|
|
85
|
+
theme.value.colors.primary,
|
|
86
|
+
theme.value.colors.accent,
|
|
87
|
+
theme.value.colors.success,
|
|
88
|
+
theme.value.colors.warning,
|
|
89
|
+
theme.value.colors.danger,
|
|
90
|
+
theme.value.colors.muted,
|
|
91
|
+
theme.value.colors.text,
|
|
92
|
+
theme.value.colors.border,
|
|
93
|
+
]
|
|
94
|
+
return visible.value.map(
|
|
95
|
+
(series) => series.color ?? palette[props.series.indexOf(series) % palette.length]!,
|
|
96
|
+
)
|
|
97
|
+
})
|
|
98
|
+
const summary = computed(() => {
|
|
99
|
+
const point = selected.value
|
|
100
|
+
if (!point) return props.description ?? props.label
|
|
101
|
+
const series = visible.value[point.series]!
|
|
102
|
+
return `${props.categories[point.category]!.label} · ${series.label}: ${format(series.values[point.category])}`
|
|
103
|
+
})
|
|
104
|
+
function choose(category: number, series: number) {
|
|
105
|
+
if (props.disabled || !props.categories[category] || !visible.value[series]) return
|
|
106
|
+
emit('update:modelValue', {
|
|
107
|
+
category: props.categories[category]!.key,
|
|
108
|
+
series: visible.value[series]!.key,
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
const surface = markRaw(createMotionSurface())
|
|
112
|
+
function animate() {
|
|
113
|
+
if (surface.available)
|
|
114
|
+
surface.animate(
|
|
115
|
+
{ opacity: [0.35, 1], y: [6, 0] },
|
|
116
|
+
{ duration: theme.value.motion.enterDuration, ease: 'easeOut' },
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
onScopeDispose(surface.use(animate))
|
|
120
|
+
watch(() => [geometry.value, props.type], animate, { flush: 'post' })
|
|
121
|
+
return () => {
|
|
122
|
+
if (!props.label.trim()) throw new TypeError('Chart requires a label.')
|
|
123
|
+
if (!Number.isFinite(props.height) || props.height < 120 || props.height > 800)
|
|
124
|
+
throw new RangeError('Chart height must be between 120 and 800.')
|
|
125
|
+
if (!['line', 'bar'].includes(props.type))
|
|
126
|
+
throw new TypeError('Chart type must be line or bar.')
|
|
127
|
+
// Validate hidden series too; toggling a legend must never reveal invalid data.
|
|
128
|
+
const domain = allGeometry.value
|
|
129
|
+
const hasData = geometry.value.series.some((series) => series.points.some(Boolean))
|
|
130
|
+
return h(
|
|
131
|
+
ui.Column,
|
|
132
|
+
mergeProps({ id: props.id, gap: 'md' }, attrs, {
|
|
133
|
+
class: 'm-chart',
|
|
134
|
+
...(web ? { role: 'group', 'aria-label': props.label } : {}),
|
|
135
|
+
}),
|
|
136
|
+
() => [
|
|
137
|
+
h(ui.Column, { gap: 'xs' }, () => [
|
|
138
|
+
h(ui.Text, { text: props.label, as: 'h2', variant: 'heading' }),
|
|
139
|
+
props.description
|
|
140
|
+
? h(ui.Text, { text: props.description, tone: 'muted', variant: 'caption' })
|
|
141
|
+
: null,
|
|
142
|
+
]),
|
|
143
|
+
h(ui.Row, { gap: 'xs', wrap: true }, () =>
|
|
144
|
+
props.series.map((series) => {
|
|
145
|
+
const shown = !props.hiddenSeries.includes(series.key)
|
|
146
|
+
return h(
|
|
147
|
+
ui.Button,
|
|
148
|
+
{
|
|
149
|
+
key: choiceKey(series.key),
|
|
150
|
+
text: series.label,
|
|
151
|
+
variant: shown ? 'secondary' : 'ghost',
|
|
152
|
+
size: 'sm',
|
|
153
|
+
disabled: props.disabled,
|
|
154
|
+
...(web
|
|
155
|
+
? { 'aria-pressed': shown }
|
|
156
|
+
: { accessibilityState: shown ? 'selected' : '' }),
|
|
157
|
+
onClick: () => {
|
|
158
|
+
if (!props.disabled)
|
|
159
|
+
emit(
|
|
160
|
+
'update:hiddenSeries',
|
|
161
|
+
shown
|
|
162
|
+
? [...props.hiddenSeries, series.key]
|
|
163
|
+
: props.hiddenSeries.filter((key) => key !== series.key),
|
|
164
|
+
)
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
leading: () =>
|
|
169
|
+
h(ui.Box, {
|
|
170
|
+
width: 8,
|
|
171
|
+
height: 8,
|
|
172
|
+
radius: 'full',
|
|
173
|
+
backgroundColor: shown
|
|
174
|
+
? colors.value[visible.value.indexOf(series)]
|
|
175
|
+
: theme.value.colors.border,
|
|
176
|
+
accessibilityHidden: true,
|
|
177
|
+
}),
|
|
178
|
+
},
|
|
179
|
+
)
|
|
180
|
+
}),
|
|
181
|
+
),
|
|
182
|
+
// An exact native column prevents measured plot shapes from expanding their own viewport.
|
|
183
|
+
h(
|
|
184
|
+
web ? ui.Row : 'GridLayout',
|
|
185
|
+
web ? { gap: 'xs', align: 'stretch' } : { columns: '56, *', height: props.height },
|
|
186
|
+
() => [
|
|
187
|
+
h(
|
|
188
|
+
ui.Column,
|
|
189
|
+
{ col: 0, justify: 'between', width: 56, shrink: 0, height: props.height },
|
|
190
|
+
() =>
|
|
191
|
+
[...domain.ticks].reverse().map((value, index) =>
|
|
192
|
+
h(ui.Text, {
|
|
193
|
+
key: index,
|
|
194
|
+
text: format(value),
|
|
195
|
+
variant: 'caption',
|
|
196
|
+
tone: 'muted',
|
|
197
|
+
align: 'right',
|
|
198
|
+
}),
|
|
199
|
+
),
|
|
200
|
+
),
|
|
201
|
+
h(
|
|
202
|
+
ui.Box,
|
|
203
|
+
{ col: 1, grow: 1, shrink: 1, height: props.height, motionSurface: surface },
|
|
204
|
+
() =>
|
|
205
|
+
hasData
|
|
206
|
+
? h(ui.Plot, {
|
|
207
|
+
geometry: geometry.value,
|
|
208
|
+
colors: colors.value,
|
|
209
|
+
type: props.type,
|
|
210
|
+
height: props.height,
|
|
211
|
+
selected: selected.value,
|
|
212
|
+
disabled: props.disabled,
|
|
213
|
+
onSelect: choose,
|
|
214
|
+
})
|
|
215
|
+
: h(
|
|
216
|
+
ui.Column,
|
|
217
|
+
{ height: props.height, justify: 'center', align: 'center' },
|
|
218
|
+
() => h(ui.Text, { text: props.emptyLabel, tone: 'muted' }),
|
|
219
|
+
),
|
|
220
|
+
),
|
|
221
|
+
],
|
|
222
|
+
),
|
|
223
|
+
props.categories.length
|
|
224
|
+
? h(ui.Row, { justify: 'between', gap: 'sm' }, () => [
|
|
225
|
+
h(ui.Text, {
|
|
226
|
+
text: props.categories[0]!.label,
|
|
227
|
+
variant: 'caption',
|
|
228
|
+
tone: 'muted',
|
|
229
|
+
}),
|
|
230
|
+
props.categories.length > 1
|
|
231
|
+
? h(ui.Text, {
|
|
232
|
+
text: props.categories[props.categories.length - 1]!.label,
|
|
233
|
+
variant: 'caption',
|
|
234
|
+
tone: 'muted',
|
|
235
|
+
align: 'right',
|
|
236
|
+
})
|
|
237
|
+
: null,
|
|
238
|
+
])
|
|
239
|
+
: null,
|
|
240
|
+
h(ui.Text, {
|
|
241
|
+
text: summary.value,
|
|
242
|
+
weight: '600',
|
|
243
|
+
...(web
|
|
244
|
+
? { role: 'status', 'aria-live': 'polite', 'aria-atomic': 'true' }
|
|
245
|
+
: { accessibilityLiveRegion: 'polite' }),
|
|
246
|
+
}),
|
|
247
|
+
props.categories.length && visible.value.length
|
|
248
|
+
? h(ui.Row, { gap: 'sm', wrap: true }, () => [
|
|
249
|
+
h(ui.Select, {
|
|
250
|
+
label: props.categoryLabel,
|
|
251
|
+
placeholder: props.categoryLabel,
|
|
252
|
+
grow: 1,
|
|
253
|
+
shrink: 1,
|
|
254
|
+
options: props.categories.map((item) => ({
|
|
255
|
+
value: item.key,
|
|
256
|
+
label: item.label,
|
|
257
|
+
})),
|
|
258
|
+
modelValue: props.modelValue?.category ?? null,
|
|
259
|
+
disabled: props.disabled,
|
|
260
|
+
'onUpdate:modelValue': (key: ChoiceValue) =>
|
|
261
|
+
choose(
|
|
262
|
+
props.categories.findIndex((item) => item.key === key),
|
|
263
|
+
selected.value?.series ?? 0,
|
|
264
|
+
),
|
|
265
|
+
}),
|
|
266
|
+
h(ui.Select, {
|
|
267
|
+
label: props.seriesLabel,
|
|
268
|
+
grow: 1,
|
|
269
|
+
shrink: 1,
|
|
270
|
+
options: visible.value.map((item) => ({ value: item.key, label: item.label })),
|
|
271
|
+
modelValue: visible.value[selected.value?.series ?? 0]!.key,
|
|
272
|
+
disabled: props.disabled,
|
|
273
|
+
'onUpdate:modelValue': (key: ChoiceValue) =>
|
|
274
|
+
choose(
|
|
275
|
+
selected.value?.category ?? 0,
|
|
276
|
+
visible.value.findIndex((item) => item.key === key),
|
|
277
|
+
),
|
|
278
|
+
}),
|
|
279
|
+
])
|
|
280
|
+
: null,
|
|
281
|
+
h(ui.Row, { gap: 'sm', wrap: true }, () => [
|
|
282
|
+
h(ui.Button, {
|
|
283
|
+
text: dataOpen.value ? props.hideDataLabel : props.showDataLabel,
|
|
284
|
+
icon: 'table-2',
|
|
285
|
+
variant: 'ghost',
|
|
286
|
+
...(web ? { 'aria-expanded': dataOpen.value } : {}),
|
|
287
|
+
onClick: () => {
|
|
288
|
+
dataOpen.value = !dataOpen.value
|
|
289
|
+
},
|
|
290
|
+
}),
|
|
291
|
+
selected.value
|
|
292
|
+
? h(ui.Button, {
|
|
293
|
+
text: props.clearLabel,
|
|
294
|
+
variant: 'ghost',
|
|
295
|
+
disabled: props.disabled,
|
|
296
|
+
onClick: () => {
|
|
297
|
+
if (!props.disabled) emit('update:modelValue', null)
|
|
298
|
+
},
|
|
299
|
+
})
|
|
300
|
+
: null,
|
|
301
|
+
]),
|
|
302
|
+
h(ui.Reveal, { show: dataOpen.value, gap: 'sm' }, () =>
|
|
303
|
+
h(
|
|
304
|
+
ui.Column,
|
|
305
|
+
{ gap: 'sm', ...(web ? { role: 'list', 'aria-label': props.showDataLabel } : {}) },
|
|
306
|
+
() =>
|
|
307
|
+
props.categories.map((category, index) =>
|
|
308
|
+
h(
|
|
309
|
+
ui.Column,
|
|
310
|
+
{
|
|
311
|
+
key: choiceKey(category.key),
|
|
312
|
+
gap: 'xs',
|
|
313
|
+
padding: 'sm',
|
|
314
|
+
radius: 'md',
|
|
315
|
+
backgroundColor: theme.value.colors.surface,
|
|
316
|
+
...(web ? { role: 'listitem' } : {}),
|
|
317
|
+
},
|
|
318
|
+
() => [
|
|
319
|
+
h(ui.Text, { text: category.label, weight: '600' }),
|
|
320
|
+
...props.series.map((series) =>
|
|
321
|
+
h(ui.Text, {
|
|
322
|
+
key: choiceKey(series.key),
|
|
323
|
+
text: `${series.label}: ${format(series.values[index])}`,
|
|
324
|
+
variant: 'caption',
|
|
325
|
+
tone: 'muted',
|
|
326
|
+
}),
|
|
327
|
+
),
|
|
328
|
+
],
|
|
329
|
+
),
|
|
330
|
+
),
|
|
331
|
+
),
|
|
332
|
+
),
|
|
333
|
+
],
|
|
334
|
+
)
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
})
|
|
338
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
onBeforeUnmount,
|
|
4
|
+
ref,
|
|
5
|
+
shallowRef,
|
|
6
|
+
watch,
|
|
7
|
+
type ExtractPropTypes,
|
|
8
|
+
type PropType,
|
|
9
|
+
} from '@vue/runtime-core'
|
|
10
|
+
import { dimensionProperty, flexContract, viewContract } from '../contracts.js'
|
|
11
|
+
import { vueProperty, vueProps } from './contracts.js'
|
|
12
|
+
import { useCachedActivity } from './cached-activity.js'
|
|
13
|
+
import {
|
|
14
|
+
choiceKey,
|
|
15
|
+
isChoiceValue,
|
|
16
|
+
validateChoices,
|
|
17
|
+
type ChoiceOption,
|
|
18
|
+
type ChoiceValue,
|
|
19
|
+
} from '../choice.js'
|
|
20
|
+
import {
|
|
21
|
+
comboboxHighlight,
|
|
22
|
+
comboboxMove,
|
|
23
|
+
comboboxSelected,
|
|
24
|
+
createComboboxSearch,
|
|
25
|
+
type ComboboxSearch,
|
|
26
|
+
type ComboboxSnapshot,
|
|
27
|
+
} from '../combobox.js'
|
|
28
|
+
|
|
29
|
+
export const comboboxProps = {
|
|
30
|
+
...vueProps(viewContract),
|
|
31
|
+
...vueProps(flexContract),
|
|
32
|
+
width: vueProperty(dimensionProperty),
|
|
33
|
+
modelValue: { type: [String, Number] as PropType<ChoiceValue | null>, default: null },
|
|
34
|
+
query: { type: String, required: true as const },
|
|
35
|
+
selectedOption: { type: Object as PropType<ChoiceOption | null>, default: null },
|
|
36
|
+
search: { type: Function as PropType<ComboboxSearch>, required: true as const },
|
|
37
|
+
initialResults: { type: Object as PropType<ComboboxSnapshot>, default: undefined },
|
|
38
|
+
debounce: { type: Number, default: 200 },
|
|
39
|
+
minQueryLength: { type: Number, default: 1 },
|
|
40
|
+
maxResults: { type: Number, default: 50 },
|
|
41
|
+
label: { type: String, required: true as const },
|
|
42
|
+
placeholder: { type: String, default: 'Search options' },
|
|
43
|
+
helperText: { type: String, default: '' },
|
|
44
|
+
error: { type: String, default: '' },
|
|
45
|
+
disabled: Boolean,
|
|
46
|
+
clearable: { type: Boolean, default: true },
|
|
47
|
+
clearLabel: { type: String, default: 'Clear selection' },
|
|
48
|
+
closeLabel: { type: String, default: 'Close results' },
|
|
49
|
+
loadingText: { type: String, default: 'Searching…' },
|
|
50
|
+
emptyText: { type: String, default: 'No results' },
|
|
51
|
+
searchErrorText: { type: String, default: 'Could not load results.' },
|
|
52
|
+
retryLabel: { type: String, default: 'Try again' },
|
|
53
|
+
idleText: { type: String, default: 'Type to search.' },
|
|
54
|
+
limitedText: { type: String, default: 'Refine your search to see more results.' },
|
|
55
|
+
}
|
|
56
|
+
export const comboboxEmits = {
|
|
57
|
+
'update:modelValue': (value: ChoiceValue | null) => value === null || isChoiceValue(value),
|
|
58
|
+
'update:query': (value: string) => typeof value === 'string',
|
|
59
|
+
select: (option: ChoiceOption | null) => option === null || isChoiceValue(option.value),
|
|
60
|
+
focus: () => true,
|
|
61
|
+
blur: () => true,
|
|
62
|
+
}
|
|
63
|
+
type Props = Readonly<ExtractPropTypes<typeof comboboxProps>>
|
|
64
|
+
type Emit = {
|
|
65
|
+
(event: 'update:modelValue', value: ChoiceValue | null): void
|
|
66
|
+
(event: 'update:query', value: string): void
|
|
67
|
+
(event: 'select', value: ChoiceOption | null): void
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** @internal Shared request ownership and controlled selection for the two Vue renderers. */
|
|
71
|
+
export function useCombobox(props: Props, emit: Emit) {
|
|
72
|
+
watch(
|
|
73
|
+
() => props.label,
|
|
74
|
+
(label) => {
|
|
75
|
+
if (!label.trim()) throw new RangeError('Combobox needs a nonempty label.')
|
|
76
|
+
},
|
|
77
|
+
{ immediate: true },
|
|
78
|
+
)
|
|
79
|
+
const open = ref(false)
|
|
80
|
+
const revision = ref(0)
|
|
81
|
+
const composing = ref(false)
|
|
82
|
+
const active = ref<string>()
|
|
83
|
+
const retained = shallowRef<ChoiceOption | null>(props.selectedOption)
|
|
84
|
+
const pendingSelection = shallowRef<ChoiceOption>()
|
|
85
|
+
const activity = useCachedActivity()
|
|
86
|
+
const makeSearch = () =>
|
|
87
|
+
createComboboxSearch({
|
|
88
|
+
search: (query, context) => props.search(query, context),
|
|
89
|
+
debounce: props.debounce,
|
|
90
|
+
minQueryLength: props.minQueryLength,
|
|
91
|
+
maxResults: props.maxResults,
|
|
92
|
+
initialResults: props.initialResults,
|
|
93
|
+
onChange(value) {
|
|
94
|
+
state.value = value
|
|
95
|
+
active.value = comboboxHighlight(value.options, active.value)
|
|
96
|
+
},
|
|
97
|
+
})
|
|
98
|
+
let search = makeSearch()
|
|
99
|
+
const state = shallowRef(search.state)
|
|
100
|
+
const selected = computed(() =>
|
|
101
|
+
comboboxSelected(
|
|
102
|
+
props.modelValue,
|
|
103
|
+
state.value.options,
|
|
104
|
+
props.selectedOption?.value === props.modelValue
|
|
105
|
+
? props.selectedOption
|
|
106
|
+
: pendingSelection.value?.value === props.modelValue
|
|
107
|
+
? pendingSelection.value
|
|
108
|
+
: retained.value,
|
|
109
|
+
),
|
|
110
|
+
)
|
|
111
|
+
watch(
|
|
112
|
+
selected,
|
|
113
|
+
(option) => {
|
|
114
|
+
if (option) retained.value = option
|
|
115
|
+
},
|
|
116
|
+
{ immediate: true },
|
|
117
|
+
)
|
|
118
|
+
watch(
|
|
119
|
+
() => [props.modelValue, props.selectedOption] as const,
|
|
120
|
+
() => {
|
|
121
|
+
validateChoices(props.selectedOption ? [props.selectedOption] : [], props.modelValue)
|
|
122
|
+
if (props.modelValue === null) {
|
|
123
|
+
retained.value = null
|
|
124
|
+
pendingSelection.value = undefined
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
{ immediate: true, deep: true },
|
|
128
|
+
)
|
|
129
|
+
watch(
|
|
130
|
+
() => props.query,
|
|
131
|
+
() => {
|
|
132
|
+
if (open.value && !composing.value) search.request(props.query)
|
|
133
|
+
else search.cancel()
|
|
134
|
+
},
|
|
135
|
+
{ flush: 'sync' },
|
|
136
|
+
)
|
|
137
|
+
watch(
|
|
138
|
+
() => [props.search, props.debounce, props.minQueryLength, props.maxResults],
|
|
139
|
+
() => {
|
|
140
|
+
search.dispose()
|
|
141
|
+
search = makeSearch()
|
|
142
|
+
state.value = search.state
|
|
143
|
+
if (open.value && !composing.value) search.request(props.query)
|
|
144
|
+
},
|
|
145
|
+
)
|
|
146
|
+
watch(
|
|
147
|
+
() => props.disabled || !activity.value,
|
|
148
|
+
(blocked) => {
|
|
149
|
+
if (blocked) close()
|
|
150
|
+
},
|
|
151
|
+
)
|
|
152
|
+
onBeforeUnmount(() => search.dispose())
|
|
153
|
+
function show() {
|
|
154
|
+
if (props.disabled || !activity.value) return
|
|
155
|
+
open.value = true
|
|
156
|
+
if (!composing.value) search.request(props.query)
|
|
157
|
+
}
|
|
158
|
+
function close() {
|
|
159
|
+
open.value = false
|
|
160
|
+
active.value = undefined
|
|
161
|
+
composing.value = false
|
|
162
|
+
search.cancel()
|
|
163
|
+
}
|
|
164
|
+
function edit(query: string) {
|
|
165
|
+
if (props.disabled) return
|
|
166
|
+
revision.value++
|
|
167
|
+
// Browsers may send a final input event after compositionend. It is the same
|
|
168
|
+
// accepted query, not a second request (including when debounce is zero).
|
|
169
|
+
if (
|
|
170
|
+
query === props.query &&
|
|
171
|
+
!composing.value &&
|
|
172
|
+
open.value &&
|
|
173
|
+
state.value.query === query &&
|
|
174
|
+
state.value.status !== 'idle'
|
|
175
|
+
)
|
|
176
|
+
return
|
|
177
|
+
search.cancel()
|
|
178
|
+
active.value = undefined
|
|
179
|
+
open.value = true
|
|
180
|
+
emit('update:query', query)
|
|
181
|
+
if (props.query === query && !composing.value) search.request(query)
|
|
182
|
+
// Only the accepted controlled query starts a request (the synchronous watch owns it).
|
|
183
|
+
}
|
|
184
|
+
function choose(option: ChoiceOption) {
|
|
185
|
+
const current = state.value.options.find((item) => item.value === option.value)
|
|
186
|
+
if (!open.value || props.disabled || composing.value || !current || current.disabled) return
|
|
187
|
+
pendingSelection.value = current
|
|
188
|
+
if (props.modelValue !== current.value) emit('update:modelValue', current.value)
|
|
189
|
+
emit('update:query', current.label)
|
|
190
|
+
emit('select', current)
|
|
191
|
+
close()
|
|
192
|
+
}
|
|
193
|
+
function clear() {
|
|
194
|
+
if (props.disabled) return
|
|
195
|
+
close()
|
|
196
|
+
emit('update:modelValue', null)
|
|
197
|
+
emit('update:query', '')
|
|
198
|
+
emit('select', null)
|
|
199
|
+
}
|
|
200
|
+
function cancel() {
|
|
201
|
+
close()
|
|
202
|
+
emit('update:query', selected.value?.label ?? '')
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
open,
|
|
206
|
+
composing,
|
|
207
|
+
active,
|
|
208
|
+
state,
|
|
209
|
+
selected,
|
|
210
|
+
revision,
|
|
211
|
+
show,
|
|
212
|
+
close,
|
|
213
|
+
edit,
|
|
214
|
+
choose,
|
|
215
|
+
clear,
|
|
216
|
+
cancel,
|
|
217
|
+
startComposition() {
|
|
218
|
+
composing.value = true
|
|
219
|
+
search.cancel()
|
|
220
|
+
active.value = undefined
|
|
221
|
+
},
|
|
222
|
+
endComposition(query: string) {
|
|
223
|
+
composing.value = false
|
|
224
|
+
edit(query)
|
|
225
|
+
},
|
|
226
|
+
move(direction: 1 | -1) {
|
|
227
|
+
if (!open.value) show()
|
|
228
|
+
active.value = comboboxMove(state.value.options, active.value, direction)
|
|
229
|
+
},
|
|
230
|
+
commit() {
|
|
231
|
+
const option = state.value.options.find((item) => choiceKey(item.value) === active.value)
|
|
232
|
+
if (option) choose(option)
|
|
233
|
+
},
|
|
234
|
+
retry() {
|
|
235
|
+
if (!props.disabled && open.value && !composing.value) search.request(props.query, true)
|
|
236
|
+
},
|
|
237
|
+
}
|
|
238
|
+
}
|