vectis-ui 0.8.1 → 0.9.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/README.md +3 -3
- package/dist/components/VAccordion/VAccordionItem.d.ts +4 -6
- package/dist/components/VAccordion/VAccordionItem.js.map +1 -1
- package/dist/components/VAccordion/VAccordionItem.vue_vue_type_script_setup_true_lang.js +21 -19
- package/dist/components/VAccordion/VAccordionItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VAccordion/context.d.ts +6 -1
- package/dist/components/VAccordion/context.js.map +1 -1
- package/dist/components/VAvatar/VAvatar.css +1 -1
- package/dist/components/VAvatar/VAvatar.d.ts +5 -3
- package/dist/components/VAvatar/VAvatar.js.map +1 -1
- package/dist/components/VAvatar/VAvatar.vue_vue_type_script_setup_true_lang.js +53 -39
- package/dist/components/VAvatar/VAvatar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VAvatar/VAvatarGroup.d.ts +12 -3
- package/dist/components/VAvatar/VAvatarGroup.js.map +1 -1
- package/dist/components/VAvatar/VAvatarGroup.vue_vue_type_script_setup_true_lang.js +27 -20
- package/dist/components/VAvatar/VAvatarGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VAvatar/context.d.ts +2 -2
- package/dist/components/VAvatar/context.js.map +1 -1
- package/dist/components/VBadge/VBadge.css +1 -1
- package/dist/components/VBadge/VBadge.d.ts +8 -4
- package/dist/components/VBadge/VBadge.js.map +1 -1
- package/dist/components/VBadge/VBadge.vue_vue_type_script_setup_true_lang.js +6 -3
- package/dist/components/VBadge/VBadge.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VBreadcrumb/VBreadcrumb.d.ts +5 -4
- package/dist/components/VBreadcrumb/VBreadcrumb.js.map +1 -1
- package/dist/components/VBreadcrumb/VBreadcrumb.vue_vue_type_script_setup_true_lang.js +8 -3
- package/dist/components/VBreadcrumb/VBreadcrumb.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VButton/VButton.css +1 -1
- package/dist/components/VButton/VButton.d.ts +4 -1
- package/dist/components/VButton/VButton.js.map +1 -1
- package/dist/components/VButton/VButton.vue_vue_type_script_setup_true_lang.js +8 -7
- package/dist/components/VButton/VButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VButton/VButtonGroup.js.map +1 -1
- package/dist/components/VButton/VButtonGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCalendar/VCalendar.css +1 -1
- package/dist/components/VCalendar/VCalendar.d.ts +15 -6
- package/dist/components/VCalendar/VCalendar.js.map +1 -1
- package/dist/components/VCalendar/VCalendar.vue_vue_type_script_setup_true_lang.js +144 -126
- package/dist/components/VCalendar/VCalendar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCalendar/VCalendarEvent.css +1 -1
- package/dist/components/VCalendar/VCalendarEvent.d.ts +1 -1
- package/dist/components/VCalendar/VCalendarEvent.js.map +1 -1
- package/dist/components/VCalendar/VCalendarEvent.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCalendar/VCalendarMonth.css +1 -1
- package/dist/components/VCalendar/VCalendarMonth.d.ts +1 -1
- package/dist/components/VCalendar/VCalendarMonth.js.map +1 -1
- package/dist/components/VCalendar/VCalendarMonth.vue_vue_type_script_setup_true_lang.js +99 -90
- package/dist/components/VCalendar/VCalendarMonth.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCalendar/VCalendarTimeGrid.css +1 -1
- package/dist/components/VCalendar/VCalendarTimeGrid.d.ts +3 -3
- package/dist/components/VCalendar/VCalendarTimeGrid.js.map +1 -1
- package/dist/components/VCalendar/VCalendarTimeGrid.vue_vue_type_script_setup_true_lang.js +256 -246
- package/dist/components/VCalendar/VCalendarTimeGrid.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCalendar/VCalendarYear.css +1 -1
- package/dist/components/VCalendar/VCalendarYear.d.ts +8 -1
- package/dist/components/VCalendar/VCalendarYear.js.map +1 -1
- package/dist/components/VCalendar/VCalendarYear.vue_vue_type_script_setup_true_lang.js +39 -32
- package/dist/components/VCalendar/VCalendarYear.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCalendar/color.d.ts +1 -1
- package/dist/components/VCalendar/color.js.map +1 -1
- package/dist/components/VCalendar/edgeStep.d.ts +3 -3
- package/dist/components/VCalendar/edgeStep.js +5 -0
- package/dist/components/VCalendar/edgeStep.js.map +1 -1
- package/dist/components/VCalendar/gesture.d.ts +10 -9
- package/dist/components/VCalendar/gesture.js +60 -45
- package/dist/components/VCalendar/gesture.js.map +1 -1
- package/dist/components/VCalendar/keyboard.d.ts +22 -5
- package/dist/components/VCalendar/keyboard.js +17 -16
- package/dist/components/VCalendar/keyboard.js.map +1 -1
- package/dist/components/VCalendar/layout.d.ts +47 -37
- package/dist/components/VCalendar/layout.js +47 -37
- package/dist/components/VCalendar/layout.js.map +1 -1
- package/dist/components/VCalendar/timeGrid.d.ts +4 -4
- package/dist/components/VCalendar/timeGrid.js +6 -6
- package/dist/components/VCalendar/timeGrid.js.map +1 -1
- package/dist/components/VCalendar/types.d.ts +5 -5
- package/dist/components/VCarousel/VCarousel.css +1 -1
- package/dist/components/VCarousel/VCarousel.d.ts +59 -38
- package/dist/components/VCarousel/VCarousel.js.map +1 -1
- package/dist/components/VCarousel/VCarousel.vue_vue_type_script_setup_true_lang.js +161 -132
- package/dist/components/VCarousel/VCarousel.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCarousel/VCarouselItem.d.ts +1 -1
- package/dist/components/VCarousel/VCarouselItem.js.map +1 -1
- package/dist/components/VCarousel/VCarouselItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCarousel/context.d.ts +1 -1
- package/dist/components/VCarousel/context.js.map +1 -1
- package/dist/components/VCheckbox/VCheckbox.css +1 -1
- package/dist/components/VCheckbox/VCheckbox.d.ts +2 -2
- package/dist/components/VCheckbox/VCheckbox.js.map +1 -1
- package/dist/components/VCheckbox/VCheckbox.vue_vue_type_script_setup_true_lang.js +10 -8
- package/dist/components/VCheckbox/VCheckbox.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VChip/VChip.css +1 -1
- package/dist/components/VChip/VChip.d.ts +7 -2
- package/dist/components/VChip/VChip.js.map +1 -1
- package/dist/components/VChip/VChip.vue_vue_type_script_setup_true_lang.js +69 -55
- package/dist/components/VChip/VChip.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCombobox/VCombobox.css +1 -1
- package/dist/components/VCombobox/VCombobox.d.ts +50 -36
- package/dist/components/VCombobox/VCombobox.js.map +1 -1
- package/dist/components/VCombobox/VCombobox.vue_vue_type_script_setup_true_lang.js +167 -161
- package/dist/components/VCombobox/VCombobox.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCombobox/VComboboxGroup.css +1 -1
- package/dist/components/VCombobox/VComboboxGroup.js.map +1 -1
- package/dist/components/VCombobox/VComboboxGroup.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/VCombobox/VComboboxGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCombobox/infiniteScroll.d.ts +12 -3
- package/dist/components/VCombobox/infiniteScroll.js +18 -12
- package/dist/components/VCombobox/infiniteScroll.js.map +1 -1
- package/dist/components/VDataTable/VDataTable.css +1 -1
- package/dist/components/VDataTable/VDataTable.d.ts +55 -24
- package/dist/components/VDataTable/VDataTable.js.map +1 -1
- package/dist/components/VDataTable/VDataTable.vue_vue_type_script_setup_true_lang.js +192 -155
- package/dist/components/VDataTable/VDataTable.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VDateInput/VDateInput.css +1 -1
- package/dist/components/VDateInput/VDateInput.d.ts +15 -12
- package/dist/components/VDateInput/VDateInput.js.map +1 -1
- package/dist/components/VDateInput/VDateInput.vue_vue_type_script_setup_true_lang.js +180 -160
- package/dist/components/VDateInput/VDateInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VDateInput/mask.d.ts +95 -0
- package/dist/components/VDateInput/mask.js +118 -0
- package/dist/components/VDateInput/mask.js.map +1 -0
- package/dist/components/VDatePicker/VDatePicker.css +1 -1
- package/dist/components/VDatePicker/VDatePicker.d.ts +6 -5
- package/dist/components/VDatePicker/VDatePicker.js.map +1 -1
- package/dist/components/VDatePicker/VDatePicker.vue_vue_type_script_setup_true_lang.js +204 -173
- package/dist/components/VDatePicker/VDatePicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VDatePicker/keyboard.d.ts +3 -3
- package/dist/components/VDatePicker/keyboard.js.map +1 -1
- package/dist/components/VDatePicker/names.d.ts +34 -0
- package/dist/components/VDatePicker/names.js +42 -0
- package/dist/components/VDatePicker/names.js.map +1 -0
- package/dist/components/VDialog/VDialog.css +1 -1
- package/dist/components/VDialog/VDialog.d.ts +2 -2
- package/dist/components/VDialog/VDialog.js.map +1 -1
- package/dist/components/VDialog/VDialog.vue_vue_type_script_setup_true_lang.js +63 -41
- package/dist/components/VDialog/VDialog.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VFileInput/VFileInput.d.ts +38 -25
- package/dist/components/VFileInput/VFileInput.js.map +1 -1
- package/dist/components/VFileInput/VFileInput.vue_vue_type_script_setup_true_lang.js +74 -71
- package/dist/components/VFileInput/VFileInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VFileInput/truncate.d.ts +4 -4
- package/dist/components/VFileInput/truncate.js.map +1 -1
- package/dist/components/VFilePicker/VFilePicker.css +1 -1
- package/dist/components/VFilePicker/VFilePicker.d.ts +54 -37
- package/dist/components/VFilePicker/VFilePicker.js.map +1 -1
- package/dist/components/VFilePicker/VFilePicker.vue_vue_type_script_setup_true_lang.js +152 -135
- package/dist/components/VFilePicker/VFilePicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VFilePicker/fileKind.d.ts +2 -2
- package/dist/components/VFilePicker/fileKind.js.map +1 -1
- package/dist/components/VHotkeys/VHotkeys.css +1 -1
- package/dist/components/VHotkeys/VHotkeys.d.ts +10 -8
- package/dist/components/VHotkeys/VHotkeys.js.map +1 -1
- package/dist/components/VHotkeys/VHotkeys.vue_vue_type_script_setup_true_lang.js +22 -20
- package/dist/components/VHotkeys/VHotkeys.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VHotkeys/platform.d.ts +9 -7
- package/dist/components/VHotkeys/platform.js +41 -30
- package/dist/components/VHotkeys/platform.js.map +1 -1
- package/dist/components/VIcon/VIcon.css +1 -1
- package/dist/components/VIcon/VIcon.d.ts +6 -6
- package/dist/components/VIcon/VIcon.js.map +1 -1
- package/dist/components/VIcon/VIcon.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VIcon/iconProps.d.ts +4 -4
- package/dist/components/VIcon/iconProps.js.map +1 -1
- package/dist/components/VIcon/icons/index.d.ts +1 -1
- package/dist/components/VIcon/icons/index.js.map +1 -1
- package/dist/components/VIcon/icons/names.d.ts +1 -1
- package/dist/components/VIcon/icons/names.js.map +1 -1
- package/dist/components/VIcon/resolver.d.ts +3 -3
- package/dist/components/VIcon/resolver.js +23 -20
- package/dist/components/VIcon/resolver.js.map +1 -1
- package/dist/components/VIcon/types.d.ts +4 -4
- package/dist/components/VIconButton/VIconButton.d.ts +4 -4
- package/dist/components/VIconButton/VIconButton.js.map +1 -1
- package/dist/components/VIconButton/VIconButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VInput/VInput.d.ts +16 -8
- package/dist/components/VInput/VInput.js.map +1 -1
- package/dist/components/VInput/VInput.vue_vue_type_script_setup_true_lang.js +22 -16
- package/dist/components/VInput/VInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VInput/VInputGroup.css +1 -1
- package/dist/components/VInput/VInputGroup.js.map +1 -1
- package/dist/components/VInput/VInputGroup.vue_vue_type_script_setup_true_lang.js +43 -28
- package/dist/components/VInput/VInputGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VInputOTP/VInputOTP.css +1 -1
- package/dist/components/VInputOTP/VInputOTP.d.ts +3 -3
- package/dist/components/VInputOTP/VInputOTP.js.map +1 -1
- package/dist/components/VInputOTP/VInputOTP.vue_vue_type_script_setup_true_lang.js +152 -85
- package/dist/components/VInputOTP/VInputOTP.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VMenu/VMenu.d.ts +4 -4
- package/dist/components/VMenu/VMenu.js.map +1 -1
- package/dist/components/VMenu/VMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VMenu/VMenuGroup.css +1 -1
- package/dist/components/VMenu/VMenuGroup.js.map +1 -1
- package/dist/components/VMenu/VMenuGroup.vue_vue_type_script_setup_true_lang.js +18 -11
- package/dist/components/VMenu/VMenuGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VMenu/VMenuItem.css +1 -1
- package/dist/components/VMenu/VMenuItem.d.ts +6 -6
- package/dist/components/VMenu/VMenuItem.js.map +1 -1
- package/dist/components/VMenu/VMenuItem.vue_vue_type_script_setup_true_lang.js +83 -69
- package/dist/components/VMenu/VMenuItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VMenu/VMenuPanel.css +1 -1
- package/dist/components/VMenu/VMenuPanel.d.ts +2 -2
- package/dist/components/VMenu/VMenuPanel.js.map +1 -1
- package/dist/components/VMenu/VMenuPanel.vue_vue_type_script_setup_true_lang.js +56 -55
- package/dist/components/VMenu/VMenuPanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VMenu/context.d.ts +2 -2
- package/dist/components/VMenu/context.js.map +1 -1
- package/dist/components/VPagination/VPagination.css +1 -1
- package/dist/components/VPagination/VPagination.d.ts +22 -9
- package/dist/components/VPagination/VPagination.js.map +1 -1
- package/dist/components/VPagination/VPagination.vue_vue_type_script_setup_true_lang.js +67 -57
- package/dist/components/VPagination/VPagination.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VPopover/VPopover.css +1 -1
- package/dist/components/VPopover/VPopover.d.ts +1 -1
- package/dist/components/VPopover/VPopover.js.map +1 -1
- package/dist/components/VPopover/VPopover.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VProgressCircular/VProgressCircular.css +1 -1
- package/dist/components/VProgressCircular/VProgressCircular.d.ts +12 -7
- package/dist/components/VProgressCircular/VProgressCircular.js.map +1 -1
- package/dist/components/VProgressCircular/VProgressCircular.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VProgressLinear/VProgressLinear.css +1 -1
- package/dist/components/VProgressLinear/VProgressLinear.d.ts +15 -10
- package/dist/components/VProgressLinear/VProgressLinear.js.map +1 -1
- package/dist/components/VProgressLinear/VProgressLinear.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VRadio/VRadio.css +1 -1
- package/dist/components/VRadio/VRadio.js.map +1 -1
- package/dist/components/VRadio/VRadio.vue_vue_type_script_setup_true_lang.js +3 -3
- package/dist/components/VRadio/VRadio.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSeparator/VSeparator.d.ts +1 -1
- package/dist/components/VSeparator/VSeparator.js.map +1 -1
- package/dist/components/VSeparator/VSeparator.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSideNavigation/VSideNavigation.d.ts +2 -2
- package/dist/components/VSideNavigation/VSideNavigation.js.map +1 -1
- package/dist/components/VSideNavigation/VSideNavigation.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/VSideNavigation/VSideNavigation.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSideNavigation/VSideNavigationGroup.css +1 -1
- package/dist/components/VSideNavigation/VSideNavigationGroup.js.map +1 -1
- package/dist/components/VSideNavigation/VSideNavigationGroup.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/VSideNavigation/VSideNavigationGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSideNavigation/VSideNavigationItem.css +1 -1
- package/dist/components/VSideNavigation/VSideNavigationItem.d.ts +12 -13
- package/dist/components/VSideNavigation/VSideNavigationItem.js.map +1 -1
- package/dist/components/VSideNavigation/VSideNavigationItem.vue_vue_type_script_setup_true_lang.js +87 -68
- package/dist/components/VSideNavigation/VSideNavigationItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSkeletonLoader/VSkeletonLoader.css +1 -1
- package/dist/components/VSkeletonLoader/VSkeletonLoader.d.ts +10 -7
- package/dist/components/VSkeletonLoader/VSkeletonLoader.js.map +1 -1
- package/dist/components/VSkeletonLoader/VSkeletonLoader.vue_vue_type_script_setup_true_lang.js +5 -5
- package/dist/components/VSkeletonLoader/VSkeletonLoader.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSlider/VSlider.css +1 -1
- package/dist/components/VSlider/VSlider.d.ts +21 -7
- package/dist/components/VSlider/VSlider.js.map +1 -1
- package/dist/components/VSlider/VSlider.vue_vue_type_script_setup_true_lang.js +159 -140
- package/dist/components/VSlider/VSlider.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSnackbar/VSnackbar.css +1 -1
- package/dist/components/VSnackbar/VSnackbar.d.ts +4 -4
- package/dist/components/VSnackbar/VSnackbar.js.map +1 -1
- package/dist/components/VSnackbar/VSnackbar.vue_vue_type_script_setup_true_lang.js +85 -59
- package/dist/components/VSnackbar/VSnackbar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSnackbar/state.d.ts +7 -7
- package/dist/components/VSnackbar/state.js +13 -11
- package/dist/components/VSnackbar/state.js.map +1 -1
- package/dist/components/VSpinner/VSpinner.css +1 -1
- package/dist/components/VSpinner/VSpinner.js.map +1 -1
- package/dist/components/VSpinner/VSpinner.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSwitch/VSwitch.css +1 -1
- package/dist/components/VSwitch/VSwitch.d.ts +1 -1
- package/dist/components/VSwitch/VSwitch.js.map +1 -1
- package/dist/components/VSwitch/VSwitch.vue_vue_type_script_setup_true_lang.js +4 -4
- package/dist/components/VSwitch/VSwitch.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTabs/VTab.css +1 -1
- package/dist/components/VTabs/VTab.d.ts +4 -0
- package/dist/components/VTabs/VTab.js.map +1 -1
- package/dist/components/VTabs/VTab.vue_vue_type_script_setup_true_lang.js +9 -8
- package/dist/components/VTabs/VTab.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTabs/VTabs.css +1 -1
- package/dist/components/VTabs/VTabs.d.ts +17 -7
- package/dist/components/VTabs/VTabs.js.map +1 -1
- package/dist/components/VTabs/VTabs.vue_vue_type_script_setup_true_lang.js +84 -77
- package/dist/components/VTabs/VTabs.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTextarea/VTextarea.d.ts +8 -8
- package/dist/components/VTextarea/VTextarea.js.map +1 -1
- package/dist/components/VTextarea/VTextarea.vue_vue_type_script_setup_true_lang.js +71 -69
- package/dist/components/VTextarea/VTextarea.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTimeInput/VTimeInput.css +1 -1
- package/dist/components/VTimeInput/VTimeInput.d.ts +21 -12
- package/dist/components/VTimeInput/VTimeInput.js.map +1 -1
- package/dist/components/VTimeInput/VTimeInput.vue_vue_type_script_setup_true_lang.js +230 -206
- package/dist/components/VTimeInput/VTimeInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTimeInput/search.d.ts +17 -2
- package/dist/components/VTimeInput/search.js +19 -9
- package/dist/components/VTimeInput/search.js.map +1 -1
- package/dist/components/VTimePicker/VTimePicker.css +1 -1
- package/dist/components/VTimePicker/VTimePicker.d.ts +8 -7
- package/dist/components/VTimePicker/VTimePicker.js.map +1 -1
- package/dist/components/VTimePicker/VTimePicker.vue_vue_type_script_setup_true_lang.js +128 -106
- package/dist/components/VTimePicker/VTimePicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTimePicker/limits.d.ts +11 -4
- package/dist/components/VTimePicker/limits.js +3 -2
- package/dist/components/VTimePicker/limits.js.map +1 -1
- package/dist/components/VToast/VToast.css +1 -1
- package/dist/components/VToast/VToast.js.map +1 -1
- package/dist/components/VToast/VToast.vue_vue_type_script_setup_true_lang.js +33 -37
- package/dist/components/VToast/VToast.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VToast/VToaster.js.map +1 -1
- package/dist/components/VToast/VToaster.vue_vue_type_script_setup_true_lang.js +91 -61
- package/dist/components/VToast/VToaster.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VToast/state.d.ts +8 -6
- package/dist/components/VToast/state.js +15 -13
- package/dist/components/VToast/state.js.map +1 -1
- package/dist/components/VToggle/VToggle.css +1 -1
- package/dist/components/VToggle/VToggle.d.ts +9 -4
- package/dist/components/VToggle/VToggle.js.map +1 -1
- package/dist/components/VToggle/VToggle.vue_vue_type_script_setup_true_lang.js +2 -1
- package/dist/components/VToggle/VToggle.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VToggle/VToggleItem.d.ts +4 -0
- package/dist/components/VToggle/VToggleItem.js.map +1 -1
- package/dist/components/VToggle/VToggleItem.vue_vue_type_script_setup_true_lang.js +5 -5
- package/dist/components/VToggle/VToggleItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTooltip/VTooltip.css +1 -1
- package/dist/components/VTooltip/VTooltip.d.ts +17 -10
- package/dist/components/VTooltip/VTooltip.js.map +1 -1
- package/dist/components/VTooltip/VTooltip.vue_vue_type_script_setup_true_lang.js +46 -26
- package/dist/components/VTooltip/VTooltip.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTypography/VTypography.css +1 -1
- package/dist/components/VTypography/VTypography.d.ts +6 -4
- package/dist/components/VTypography/VTypography.js.map +1 -1
- package/dist/components/VTypography/VTypography.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/composables/useAriaLabel.js +1 -1
- package/dist/composables/useAriaLabel.js.map +1 -1
- package/dist/composables/useClearable.d.ts +2 -2
- package/dist/composables/useClearable.js.map +1 -1
- package/dist/composables/useDetailsOpen.d.ts +3 -3
- package/dist/composables/useDetailsOpen.js +14 -12
- package/dist/composables/useDetailsOpen.js.map +1 -1
- package/dist/composables/useFieldIds.d.ts +2 -1
- package/dist/composables/useFieldIds.js +6 -5
- package/dist/composables/useFieldIds.js.map +1 -1
- package/dist/composables/useFieldPanel.d.ts +2 -2
- package/dist/composables/useFieldPanel.js +47 -37
- package/dist/composables/useFieldPanel.js.map +1 -1
- package/dist/composables/useFileDrop.js +3 -3
- package/dist/composables/useFileDrop.js.map +1 -1
- package/dist/composables/useFileField.d.ts +1 -1
- package/dist/composables/useFileField.js +62 -41
- package/dist/composables/useFileField.js.map +1 -1
- package/dist/composables/useIconClickHandlers.d.ts +3 -3
- package/dist/composables/useIconClickHandlers.js +14 -13
- package/dist/composables/useIconClickHandlers.js.map +1 -1
- package/dist/composables/useInertLink.js +12 -10
- package/dist/composables/useInertLink.js.map +1 -1
- package/dist/composables/useLiveAnnouncer.d.ts +5 -0
- package/dist/composables/useLiveAnnouncer.js +23 -0
- package/dist/composables/useLiveAnnouncer.js.map +1 -0
- package/dist/composables/useMaskedField.d.ts +5 -5
- package/dist/composables/useMaskedField.js.map +1 -1
- package/dist/composables/usePopover.d.ts +3 -3
- package/dist/composables/usePopover.js +6 -4
- package/dist/composables/usePopover.js.map +1 -1
- package/dist/composables/useProgressValue.js +11 -2
- package/dist/composables/useProgressValue.js.map +1 -1
- package/dist/composables/useRootAttrs.d.ts +1 -1
- package/dist/composables/useRootAttrs.js.map +1 -1
- package/dist/composables/useSlotNodes.d.ts +18 -0
- package/dist/composables/useSlotNodes.js +13 -0
- package/dist/composables/useSlotNodes.js.map +1 -0
- package/dist/composables/useTextLimit.d.ts +2 -1
- package/dist/composables/useTextLimit.js +2 -2
- package/dist/composables/useTextLimit.js.map +1 -1
- package/dist/composables/useTimer.d.ts +5 -0
- package/dist/composables/useTimer.js +22 -11
- package/dist/composables/useTimer.js.map +1 -1
- package/dist/i18n/en.js +1 -1
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/fr.js +14 -14
- package/dist/i18n/fr.js.map +1 -1
- package/dist/i18n/state.d.ts +7 -7
- package/dist/i18n/state.js +37 -28
- package/dist/i18n/state.js.map +1 -1
- package/dist/i18n/types.d.ts +12 -12
- package/dist/icons.d.ts +2 -2
- package/dist/index.d.ts +12 -11
- package/dist/styles.css +1 -1
- package/dist/tokens/css.d.ts +1 -1
- package/dist/tokens/css.js.map +1 -1
- package/dist/tokens/index.d.ts +6 -0
- package/dist/tokens/semantic.d.ts +6 -0
- package/dist/tokens/semantic.js +66 -60
- package/dist/tokens/semantic.js.map +1 -1
- package/dist/tokens/themes/dark.js +3 -3
- package/dist/tokens/themes/dark.js.map +1 -1
- package/dist/tokens.json +130 -66
- package/dist/types.d.ts +1 -1
- package/dist/utils/arrowNav.d.ts +4 -1
- package/dist/utils/arrowNav.js +7 -7
- package/dist/utils/arrowNav.js.map +1 -1
- package/dist/utils/chip.d.ts +1 -1
- package/dist/utils/chip.js.map +1 -1
- package/dist/utils/clock.d.ts +113 -0
- package/dist/utils/clock.js +84 -0
- package/dist/utils/clock.js.map +1 -0
- package/dist/utils/css.d.ts +6 -4
- package/dist/utils/css.js +2 -2
- package/dist/utils/css.js.map +1 -1
- package/dist/utils/date.d.ts +7 -102
- package/dist/utils/date.js +33 -160
- package/dist/utils/date.js.map +1 -1
- package/dist/utils/direction.d.ts +1 -1
- package/dist/utils/direction.js.map +1 -1
- package/dist/utils/env.d.ts +12 -3
- package/dist/utils/env.js +6 -0
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/file.d.ts +3 -3
- package/dist/utils/file.js +1 -1
- package/dist/utils/file.js.map +1 -1
- package/dist/utils/focus.d.ts +1 -1
- package/dist/utils/focus.js.map +1 -1
- package/dist/utils/hostWarns.d.ts +1 -1
- package/dist/utils/hostWarns.js.map +1 -1
- package/dist/utils/ids.d.ts +1 -1
- package/dist/utils/ids.js.map +1 -1
- package/dist/utils/matcher.d.ts +2 -2
- package/dist/utils/matcher.js.map +1 -1
- package/dist/utils/memo.d.ts +1 -1
- package/dist/utils/memo.js.map +1 -1
- package/dist/utils/text.d.ts +3 -3
- package/dist/utils/text.js.map +1 -1
- package/dist/utils/time.d.ts +2 -101
- package/dist/utils/time.js +22 -98
- package/dist/utils/time.js.map +1 -1
- package/dist/utils/vnode.d.ts +5 -3
- package/dist/utils/vnode.js.map +1 -1
- package/package.json +2 -2
|
@@ -16,7 +16,7 @@ export interface ComboboxOption {
|
|
|
16
16
|
disabled?: boolean;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* A named block of options
|
|
19
|
+
* A named block of options, the equivalent of the grouping a native list offers. A
|
|
20
20
|
* group none of whose options survive the search disappears entirely, its name
|
|
21
21
|
* included.
|
|
22
22
|
*/
|
|
@@ -28,7 +28,7 @@ export interface ComboboxGroup {
|
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* A rule drawn between two blocks of options. It is purely decorative, and a separator
|
|
31
|
-
* the search leaves stranded
|
|
31
|
+
* the search leaves stranded (at the top, at the bottom, or against another one) is
|
|
32
32
|
* simply not drawn.
|
|
33
33
|
*/
|
|
34
34
|
export interface ComboboxSeparator {
|
|
@@ -37,8 +37,8 @@ export interface ComboboxSeparator {
|
|
|
37
37
|
/** Anything the list may hold: an option, a named block, or a separator. */
|
|
38
38
|
export type ComboboxItem = ComboboxOption | ComboboxGroup | ComboboxSeparator;
|
|
39
39
|
/**
|
|
40
|
-
* How the list is narrowed as one types: by the component itself, not at all
|
|
41
|
-
* options already arrive filtered by a server
|
|
40
|
+
* How the list is narrowed as one types: by the component itself, not at all (when the
|
|
41
|
+
* options already arrive filtered by a server), or by a rule of your own.
|
|
42
42
|
*/
|
|
43
43
|
export type ComboboxFilter = boolean | ((option: ComboboxOption, query: string) => boolean);
|
|
44
44
|
/** Where the list opens relative to the field. */
|
|
@@ -50,6 +50,32 @@ export type ComboboxSize = 'sm' | 'md' | 'lg';
|
|
|
50
50
|
* joined by commas.
|
|
51
51
|
*/
|
|
52
52
|
export type ComboboxDisplay = 'chip' | 'text';
|
|
53
|
+
/** What the `#option` slot receives. */
|
|
54
|
+
export interface ComboboxOptionSlotProps {
|
|
55
|
+
option: ComboboxOption;
|
|
56
|
+
index: number;
|
|
57
|
+
active: boolean;
|
|
58
|
+
selected: boolean;
|
|
59
|
+
}
|
|
60
|
+
/** What the `#chip` slot receives. */
|
|
61
|
+
export interface ComboboxChipSlotProps {
|
|
62
|
+
value: ItemValue;
|
|
63
|
+
option: ComboboxOption | undefined;
|
|
64
|
+
label: string;
|
|
65
|
+
remove: () => void;
|
|
66
|
+
size: ChipSize;
|
|
67
|
+
compact: boolean;
|
|
68
|
+
}
|
|
69
|
+
/** What the `#overflow` slot receives. */
|
|
70
|
+
export interface ComboboxOverflowSlotProps {
|
|
71
|
+
count: number;
|
|
72
|
+
size: ChipSize;
|
|
73
|
+
compact: boolean;
|
|
74
|
+
}
|
|
75
|
+
/** What the `#empty` slot receives. */
|
|
76
|
+
export interface ComboboxEmptySlotProps {
|
|
77
|
+
query: string;
|
|
78
|
+
}
|
|
53
79
|
interface ComboboxProps {
|
|
54
80
|
/**
|
|
55
81
|
* What the list offers. An entry may be an option, a named block of options, or a
|
|
@@ -102,10 +128,10 @@ interface ComboboxProps {
|
|
|
102
128
|
* `disabled`.
|
|
103
129
|
*/
|
|
104
130
|
readonly?: boolean;
|
|
105
|
-
/** Marks the field as invalid
|
|
131
|
+
/** Marks the field as invalid, for a rule of your own. */
|
|
106
132
|
invalid?: boolean;
|
|
107
133
|
/**
|
|
108
|
-
* An icon inside the field, at the start
|
|
134
|
+
* An icon inside the field, at the start, before the chips when several values can
|
|
109
135
|
* be chosen. It is decorative by default and becomes a real button as soon as a
|
|
110
136
|
* `@click:icon-start` listener is attached, in which case it needs `iconStartLabel`.
|
|
111
137
|
*/
|
|
@@ -115,8 +141,8 @@ interface ComboboxProps {
|
|
|
115
141
|
/**
|
|
116
142
|
* The chevron at the end of the field, which turns as the list opens: an icon name,
|
|
117
143
|
* or an explicit render. Clicking it while the list is open closes the list. It is
|
|
118
|
-
* decoration all the same
|
|
119
|
-
* closes it from the keyboard
|
|
144
|
+
* decoration all the same (the field itself is what opens the list, and Escape what
|
|
145
|
+
* closes it from the keyboard), so the chevron is hidden from screen readers and takes
|
|
120
146
|
* no label.
|
|
121
147
|
*/
|
|
122
148
|
expandIcon?: IconSource;
|
|
@@ -124,13 +150,16 @@ interface ComboboxProps {
|
|
|
124
150
|
clearable?: boolean;
|
|
125
151
|
/** What that cross does, in words. It falls back to the design system dictionary. */
|
|
126
152
|
clearLabel?: string;
|
|
127
|
-
/**
|
|
153
|
+
/**
|
|
154
|
+
* What the panel says when the search matches nothing. It is also what a screen reader
|
|
155
|
+
* hears, even when the `#empty` slot draws something else: set both together.
|
|
156
|
+
*/
|
|
128
157
|
emptyText?: string;
|
|
129
158
|
/**
|
|
130
159
|
* How the list is narrowed as one types. Turning it off means the options already
|
|
131
160
|
* arrive filtered by their source and are shown exactly as they come.
|
|
132
161
|
*
|
|
133
|
-
* A rule of your own receives the query as it was TYPED, merely trimmed
|
|
162
|
+
* A rule of your own receives the query as it was TYPED, merely trimmed, rather than the
|
|
134
163
|
* accent-insensitive form used internally.
|
|
135
164
|
*/
|
|
136
165
|
filter?: ComboboxFilter;
|
|
@@ -147,7 +176,10 @@ interface ComboboxProps {
|
|
|
147
176
|
* spinner.
|
|
148
177
|
*/
|
|
149
178
|
loading?: boolean;
|
|
150
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* What is said while loading, and what the spinner is announced as. A screen reader hears
|
|
181
|
+
* it even when the `#loading` slot draws something else: set both together.
|
|
182
|
+
*/
|
|
151
183
|
loadingText?: string;
|
|
152
184
|
/**
|
|
153
185
|
* Says that there are more pages to come, which is what makes the component ask for
|
|
@@ -165,22 +197,17 @@ type __VLS_Slots = {
|
|
|
165
197
|
*/
|
|
166
198
|
start?(): unknown;
|
|
167
199
|
/**
|
|
168
|
-
* Controls of your own inside the field, placed before the ones the field owns
|
|
200
|
+
* Controls of your own inside the field, placed before the ones the field owns: the
|
|
169
201
|
* clear cross and the chevron. Those two are this component's own affordance, which is
|
|
170
202
|
* why there is no `#end` here: it would replace them.
|
|
171
203
|
*/
|
|
172
204
|
'value-end'?(): unknown;
|
|
173
205
|
/**
|
|
174
|
-
* What a row of the list shows, in place of the plain label
|
|
206
|
+
* What a row of the list shows, in place of the plain label: a subtitle, an avatar,
|
|
175
207
|
* a badge. It is told whether the row is the highlighted one and whether it is
|
|
176
208
|
* already chosen, so the rendering can react to both.
|
|
177
209
|
*/
|
|
178
|
-
option?(props:
|
|
179
|
-
option: ComboboxOption;
|
|
180
|
-
index: number;
|
|
181
|
-
active: boolean;
|
|
182
|
-
selected: boolean;
|
|
183
|
-
}): unknown;
|
|
210
|
+
option?(props: ComboboxOptionSlotProps): unknown;
|
|
184
211
|
/**
|
|
185
212
|
* Replaces the chip standing for one chosen value.
|
|
186
213
|
*
|
|
@@ -190,28 +217,15 @@ type __VLS_Slots = {
|
|
|
190
217
|
* The option itself may be missing, if that value has never appeared among the
|
|
191
218
|
* options.
|
|
192
219
|
*/
|
|
193
|
-
chip?(props:
|
|
194
|
-
value: ItemValue;
|
|
195
|
-
option: ComboboxOption | undefined;
|
|
196
|
-
label: string;
|
|
197
|
-
remove: () => void;
|
|
198
|
-
size: ChipSize;
|
|
199
|
-
compact: boolean;
|
|
200
|
-
}): unknown;
|
|
220
|
+
chip?(props: ComboboxChipSlotProps): unknown;
|
|
201
221
|
/**
|
|
202
222
|
* Replaces the "+X" standing for the values beyond `max`. It receives `count`, the number
|
|
203
223
|
* of values being hidden, and the size and density of the chips inside the field, so that a
|
|
204
224
|
* chip of your own lines up with the others.
|
|
205
225
|
*/
|
|
206
|
-
overflow?(props:
|
|
207
|
-
count: number;
|
|
208
|
-
size: ChipSize;
|
|
209
|
-
compact: boolean;
|
|
210
|
-
}): unknown;
|
|
226
|
+
overflow?(props: ComboboxOverflowSlotProps): unknown;
|
|
211
227
|
/** What the panel shows when nothing matches. It receives the term that was searched. */
|
|
212
|
-
empty?(props:
|
|
213
|
-
query: string;
|
|
214
|
-
}): unknown;
|
|
228
|
+
empty?(props: ComboboxEmptySlotProps): unknown;
|
|
215
229
|
/** What the panel shows while loading its first options. */
|
|
216
230
|
loading?(): unknown;
|
|
217
231
|
};
|
|
@@ -259,6 +273,7 @@ declare const __VLS_base: import('vue').DefineComponent<__VLS_PublicProps, {
|
|
|
259
273
|
hint: string;
|
|
260
274
|
readonly: boolean;
|
|
261
275
|
iconStartLabel: string;
|
|
276
|
+
loadingText: string;
|
|
262
277
|
clearable: boolean;
|
|
263
278
|
clearLabel: string;
|
|
264
279
|
expandIcon: IconSource;
|
|
@@ -266,7 +281,6 @@ declare const __VLS_base: import('vue').DefineComponent<__VLS_PublicProps, {
|
|
|
266
281
|
overflowText: (count: number) => string;
|
|
267
282
|
emptyText: string;
|
|
268
283
|
searchDebounce: number;
|
|
269
|
-
loadingText: string;
|
|
270
284
|
hasMore: boolean;
|
|
271
285
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
272
286
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VCombobox.js","names":[],"sources":["../../../src/components/VCombobox/VCombobox.vue"],"sourcesContent":["<script setup lang=\"ts\">\n// @a11y @keyboard @core\n/**\n * A field typed into to search a list, and to pick one or several values from. Composed of a\n * VInput, a VPopover holding the `role=\"listbox\"` panel, and VChips for the chosen values.\n *\n * The platform offers nothing to build on — `<datalist>` can be neither styled nor made\n * multi-select — so the JS here implements the whole ARIA combobox pattern: the filtering,\n * the highlight and the selection.\n *\n * ONE decision shapes the rest: DOM focus NEVER leaves the text field. What moves under the\n * arrows is `aria-activedescendant`, which is why the panel has no keyboard of its own and\n * why this component owns the field's entire accessibility contract.\n *\n * The panel is `mode=\"manual\"` (no light dismiss) and closes on `focusout` — which works\n * only because the field is OUTSIDE the panel.\n */\n\nimport { computed, inject, nextTick, reactive, ref, useId, watch, watchEffect } from 'vue'\n\nimport VChip from '../VChip/VChip.vue'\nimport type { ChipSize } from '../VChip/VChip.vue'\nimport VIcon from '../VIcon/VIcon.vue'\nimport { iconProps } from '../VIcon/iconProps'\nimport { expand_more as expandMoreIcon } from '../VIcon/icons/expand_more'\nimport type { IconSource } from '../VIcon/types'\nimport VInput from '../VInput/VInput.vue'\nimport VPopover from '../VPopover/VPopover.vue'\nimport VComboboxOption from './VComboboxOption.vue'\nimport VComboboxGroup from './VComboboxGroup.vue'\nimport VComboboxSeparator from './VComboboxSeparator.vue'\nimport { useInfiniteScroll } from './infiniteScroll'\nimport VSpinner from '../VSpinner/VSpinner.vue'\n\nimport { toggleValue } from '../../utils/array'\nimport type { ItemValue } from '../../types'\nimport { inputGroupKey } from '../VInput/context'\n\nimport { chipScaleFor } from '../../utils/chip'\nimport { createNormalizedCache, normalizeText } from '../../utils/text'\n\nimport { useControlShape } from '../../composables/useControlShape'\nimport { useRootAttrs } from '../../composables/useRootAttrs'\n\nimport { useFocusoutDismiss } from '../../composables/useFocusoutDismiss'\n\nimport { canClear } from '../../composables/useClearable'\nimport { iconStartListener } from '../../composables/useIconClickHandlers'\n\nimport { useTimer } from '../../composables/useTimer'\nimport { useMessages } from '../../i18n/state'\n\n/** One thing that can be chosen. */\nexport interface ComboboxOption {\n /**\n * What choosing it means: this is what the value holds. A number is admitted because a\n * list of options almost always comes from somewhere that keys its rows by one.\n */\n value: ItemValue\n /** What it is called on screen, and what the search matches against. */\n label: string\n /** An icon before the label: an icon name, or an explicit render. */\n icon?: IconSource\n /** Shows the option without allowing it to be chosen. */\n disabled?: boolean\n}\n\n/**\n * A named block of options — the equivalent of the grouping a native list offers. A\n * group none of whose options survive the search disappears entirely, its name\n * included.\n */\nexport interface ComboboxGroup {\n /** The name of the block. */\n label: string\n /** The options it holds. */\n options: ComboboxOption[]\n}\n\n/**\n * A rule drawn between two blocks of options. It is purely decorative, and a separator\n * the search leaves stranded — at the top, at the bottom, or against another one — is\n * simply not drawn.\n */\nexport interface ComboboxSeparator {\n separator: true\n}\n\n/** Anything the list may hold: an option, a named block, or a separator. */\nexport type ComboboxItem = ComboboxOption | ComboboxGroup | ComboboxSeparator\n\nconst isGroup = (item: ComboboxItem): item is ComboboxGroup => 'options' in item\nconst isSeparator = (item: ComboboxItem): item is ComboboxSeparator => 'separator' in item\n\n/**\n * How the list is narrowed as one types: by the component itself, not at all — when the\n * options already arrive filtered by a server — or by a rule of your own.\n */\nexport type ComboboxFilter = boolean | ((option: ComboboxOption, query: string) => boolean)\n\n/** Where the list opens relative to the field. */\nexport type ComboboxPlacement =\n 'bottom' | 'bottom-start' | 'bottom-end' | 'top' | 'top-start' | 'top-end'\n\n/** The height of the field: 32, 40 or 48 pixels. */\nexport type ComboboxSize = 'sm' | 'md' | 'lg'\n\n/**\n * How the chosen values are shown in a multiple field: one chip each, or their labels\n * joined by commas.\n */\nexport type ComboboxDisplay = 'chip' | 'text'\n\ninterface ComboboxProps {\n /**\n * What the list offers. An entry may be an option, a named block of options, or a\n * separator; a plain list of options remains perfectly valid.\n */\n options: ComboboxItem[]\n /**\n * Allows several values to be chosen, which makes the value a list and shows what has\n * been chosen inside the field, as chips or as text depending on `display`.\n */\n multiple?: boolean\n /**\n * How the chosen values are shown when several can be chosen: one dismissible chip\n * each, or their labels joined by commas on a single line, cut short with an ellipsis\n * when they run out of room. It changes nothing for a single value, which is always\n * text.\n */\n display?: ComboboxDisplay\n /**\n * How many chosen values to show before the rest are summed up as \"+X\", as chips or as\n * text alike. It applies while the search input is folded away, which is to say out of\n * focus: focused, every value comes back so it can be seen and taken back. Left out, or\n * set to 0, every value is shown. It changes nothing without `multiple`.\n */\n max?: number\n /**\n * Rephrases the \"+X\" standing for the values beyond `max`, \"+5 products\" for instance.\n * It receives the number of values being hidden.\n */\n overflowText?: (count: number) => string\n /** The label above the field, tied to it so that clicking it focuses the field. */\n label?: string\n /**\n * A line of help under the field. It is tied to the field for assistive technology,\n * so it is read out along with the label.\n */\n hint?: string\n /** The height of the field: 32, 40 or 48 pixels. */\n size?: ComboboxSize\n /** Takes 4px off the height, as everywhere else in the design system. */\n compact?: boolean\n /** What the field says while nothing is chosen and nothing has been typed. */\n placeholder?: string\n /** Makes the field unusable, greyed out through the colour tokens. */\n disabled?: boolean\n /**\n * Shows what has been chosen without letting it be changed: nothing can be typed,\n * the list never opens, the chips lose their crosses and no clear cross is offered.\n * The field stays focusable and can be copied from, which is what separates it from\n * `disabled`.\n */\n readonly?: boolean\n /** Marks the field as invalid — for a rule of your own. */\n invalid?: boolean\n /**\n * An icon inside the field, at the start — before the chips when several values can\n * be chosen. It is decorative by default and becomes a real button as soon as a\n * `@click:icon-start` listener is attached, in which case it needs `iconStartLabel`.\n */\n iconStart?: IconSource\n /** What the start icon does, in words, once it is clickable. */\n iconStartLabel?: string\n /**\n * The chevron at the end of the field, which turns as the list opens: an icon name,\n * or an explicit render. Clicking it while the list is open closes the list. It is\n * decoration all the same — the field itself is what opens the list, and Escape what\n * closes it from the keyboard — so the chevron is hidden from screen readers and takes\n * no label.\n */\n expandIcon?: IconSource\n /** Offers a cross that empties both the selection and the search. */\n clearable?: boolean\n /** What that cross does, in words. It falls back to the design system dictionary. */\n clearLabel?: string\n /** What the panel says when the search matches nothing. */\n emptyText?: string\n /**\n * How the list is narrowed as one types. Turning it off means the options already\n * arrive filtered by their source and are shown exactly as they come.\n *\n * A rule of your own receives the query as it was TYPED, merely trimmed — not the\n * accent-insensitive form used internally.\n */\n filter?: ComboboxFilter\n /**\n * How long to wait before telling the source what is being searched for, in\n * milliseconds. Zero tells it at once, which suits a source that is not a network\n * request.\n */\n searchDebounce?: number\n /**\n * Says that something is being loaded. With no option yet, the whole panel says so;\n * with options already listed, a spinner appears at the foot of the list, since what\n * is loading is then the next page. Either way the field replaces its chevron with a\n * spinner.\n */\n loading?: boolean\n /** What is said while loading, and what the spinner is announced as. */\n loadingText?: string\n /**\n * Says that there are more pages to come, which is what makes the component ask for\n * the next one as the end of the list comes into view.\n */\n hasMore?: boolean\n /** Where the list opens relative to the field. */\n placement?: ComboboxPlacement\n}\n\nconst props = withDefaults(defineProps<ComboboxProps>(), {\n multiple: false,\n display: 'chip',\n max: undefined,\n overflowText: undefined,\n label: undefined,\n hint: undefined,\n size: 'md',\n compact: false,\n placeholder: undefined,\n disabled: false,\n readonly: false,\n invalid: false,\n iconStart: undefined,\n iconStartLabel: undefined,\n expandIcon: () => expandMoreIcon,\n clearable: false,\n clearLabel: undefined,\n emptyText: undefined,\n filter: true,\n searchDebounce: 250,\n loading: false,\n loadingText: undefined,\n hasMore: false,\n placement: 'bottom-start',\n})\n\nconst m = useMessages()\nconst resolvedEmptyText = computed(() => props.emptyText ?? m.value.combobox.empty)\nconst resolvedClearLabel = computed(() => props.clearLabel ?? m.value.combobox.clear)\nconst resolvedLoadingText = computed(() => props.loadingText ?? m.value.common.loading)\n\nconst emit = defineEmits<{\n /**\n * What is being searched for, to be sent to the source. It is delayed by\n * `searchDebounce` while typing, and emitted at once when the panel opens so that a\n * first page can be loaded.\n *\n * The same term is never emitted twice in a row, so reopening the panel does not\n * repeat a request that has already been answered.\n */\n search: [query: string]\n /** The end of the list has come into view: send the next page. */\n 'load-more': []\n /** The clear cross emptied the selection and the search. */\n clear: []\n /** The start icon was clicked. Attaching this listener is what makes it a button. */\n 'click:icon-start': [event: MouseEvent]\n}>()\n\ndefineSlots<{\n /**\n * Content at the start of the field, rendered after the chips standing for the chosen\n * values rather than in their place.\n */\n start?(): unknown\n /**\n * Controls of your own inside the field, placed before the ones the field owns — the\n * clear cross and the chevron. Those two are this component's own affordance, which is\n * why there is no `#end` here: it would replace them.\n */\n 'value-end'?(): unknown\n /**\n * What a row of the list shows, in place of the plain label — a subtitle, an avatar,\n * a badge. It is told whether the row is the highlighted one and whether it is\n * already chosen, so the rendering can react to both.\n */\n option?(props: {\n option: ComboboxOption\n index: number\n active: boolean\n selected: boolean\n }): unknown\n /**\n * Replaces the chip standing for one chosen value.\n *\n * Three of the values it receives are what make it usable without regressions:\n * `remove`, without which the value could no longer be taken back, and the size and\n * density worked out to sit inside the field, which cannot be guessed from outside.\n * The option itself may be missing, if that value has never appeared among the\n * options.\n */\n chip?(props: {\n value: ItemValue\n option: ComboboxOption | undefined\n label: string\n remove: () => void\n size: ChipSize\n compact: boolean\n }): unknown\n /**\n * Replaces the \"+X\" standing for the values beyond `max`. It receives `count`, the number\n * of values being hidden, and the size and density of the chips inside the field, so that a\n * chip of your own lines up with the others.\n */\n overflow?(props: { count: number; size: ChipSize; compact: boolean }): unknown\n /** What the panel shows when nothing matches. It receives the term that was searched. */\n empty?(props: { query: string }): unknown\n /** What the panel shows while loading its first options. */\n loading?(): unknown\n}>()\n\n// A VInputGroup joins several controls into one object, so the shape of this field is the\n// row's decision rather than its own (VInput/context.ts). Everything below reads the\n// RESOLVED values and never the props: the chips, the panel and the field would otherwise\n// come out at three different scales inside the same row.\nconst group = inject(inputGroupKey, null)\nconst {\n size: resolvedSize,\n compact: resolvedCompact,\n disabled: resolvedDisabled,\n} = useControlShape(props, group)\n\n// The size, the density and the HEIGHT of the chips sitting inside the field, worked out\n// once in `utils/chip.ts` and shared with VFileInput. The height is set inline below\n// rather than restated as a table of CSS rules: it is the height the field forces on its\n// input, and deriving both from the same pair is what stops them drifting apart.\nconst chipScale = computed(() => chipScaleFor(resolvedSize.value, resolvedCompact.value))\n\n/**\n * The chosen option's `value`, or the list of them when `multiple` is set. It is an empty\n * string to begin with, and the array is never mutated in place: each change is a new one,\n * which is what wakes the consumer's binding.\n */\nconst model = defineModel<ItemValue | ItemValue[]>({ default: '' })\n\n// `class` and `style` stay on the wrapper, where a consumer expects to style the\n// component; everything else — a name above all — goes down to the text field, which is\n// the element assistive technology treats as the combobox.\ndefineOptions({ inheritAttrs: false })\nconst { rootClass, rootStyle, forwardedAttrs } = useRootAttrs()\n\n// Declared as this component's own event, `click:icon-start` is out of `$attrs`, so the\n// listener is relayed to the field by hand — and only when the consumer wrote one.\nconst iconStartClick = iconStartListener((event) => emit('click:icon-start', event))\n\n/** What reaches the field: the consumer's own attributes, plus that listener. */\nconst fieldAttrs = computed(() => ({ ...forwardedAttrs.value, ...iconStartClick }))\n\nconst rootEl = ref<HTMLElement | null>(null)\nconst inputRef = ref<InstanceType<typeof VInput> | null>(null)\n// One generated identifier serves twice: as the panel's own id, which the field points\n// at, and as the prefix of every option's id. The two strings can never collide, one\n// being a prefix of longer ones.\nconst optionsId = useId()\n\nconst open = ref(false)\nconst query = ref('')\nconst activeIndex = ref(-1)\nconst focused = ref(false)\n// The text in the field serves two purposes at once: it SHOWS the chosen label when a\n// single value is picked, and it is what one searches with. This flag tells the two\n// apart — while it is false the text is merely a label and narrows nothing, so reopening\n// the panel offers the whole list again. It only becomes true once the reader types.\nconst typed = ref(false)\n\nconst selectedValues = computed<ItemValue[]>(() => {\n if (props.multiple) return Array.isArray(model.value) ? model.value : []\n // An empty string is what an emptied combobox says, and it is not a value. A NUMBER, on\n // the other hand, is a value even at zero — hence the test on the empty string alone\n // rather than on falsiness, which would drop the option keyed `0`.\n return !Array.isArray(model.value) && model.value !== '' ? [model.value] : []\n})\n\n// Every option, flattened: the blocks unwrapped, the separators dropped, in the order\n// they were given. This is the ONE reading of the options the rest of the component\n// does — the filtering, the memory of what was chosen, the labels and the paging all\n// ignore the hierarchy entirely. Only the rendering below knows about it.\nconst allOptions = computed<ComboboxOption[]>(() =>\n props.options.flatMap((item) => {\n if (isSeparator(item)) return []\n return isGroup(item) ? item.options : [item]\n }),\n)\n\n// A memory of the options that were CHOSEN. With a source that answers over the network,\n// the options only ever hold the latest results, and something already chosen is usually\n// absent from them — without this, a chip would show a raw identifier instead of a name,\n// and a custom chip would lose the option's icon.\n//\n// It is kept up to date by an effect rather than by watching the options, because the\n// effect tracks the ITERATION and therefore also notices a page appended in place. And\n// it is bounded to what is currently chosen: everything else is read from the options\n// themselves.\nconst optionCache = reactive(new Map<ItemValue, ComboboxOption>())\nwatchEffect(() => {\n const wanted = new Set(selectedValues.value)\n for (const option of allOptions.value) {\n if (wanted.has(option.value)) optionCache.set(option.value, option)\n }\n // What is no longer chosen is forgotten. Without this the memory would grow with every\n // value chosen during the session rather than with the current selection — a slow leak\n // in a long-lived multiple field fed by a paginated source.\n for (const value of optionCache.keys()) if (!wanted.has(value)) optionCache.delete(value)\n})\n\n/*\n * A lookup from value to option, built once per list of options rather than searched\n * each time. Finding an option is done several times per chip and per render — for the\n * chip itself, its label and the name of its remove button — so a linear search here\n * would cost the number of chips times the number of options, on every keystroke.\n *\n * The FIRST match wins, exactly as a search would have done, so a duplicated value keeps\n * the option that came first.\n */\nconst optionsByValue = computed(() => {\n const map = new Map<ItemValue, ComboboxOption>()\n for (const option of allOptions.value) if (!map.has(option.value)) map.set(option.value, option)\n return map\n})\n\n/**\n * The selection as a set, so that asking \"is this one chosen?\" costs nothing however\n * many are — the same device VDataTable uses for its selected rows.\n */\nconst selectedSet = computed(() => new Set(selectedValues.value))\n\n/**\n * The option a value stands for: from the current options first, and from the memory of\n * chosen ones failing that.\n *\n * TRAP — an option coming from that memory is a reactive PROXY, since making the map\n * reactive converts the objects inside it. Compare options by their value and never by\n * identity, or the two forms of the same option will not match.\n */\nfunction optionOf(value: ItemValue) {\n return optionsByValue.value.get(value) ?? optionCache.get(value)\n}\n\nfunction labelOf(value: ItemValue) {\n return optionOf(value)?.label ?? String(value)\n}\n\n/*\n * The labels in their accent-insensitive form, remembered per option. Reading the label on\n * every call is what keeps the filter reactive: flattening the options only ever touches the\n * containers, so a label changed in place would go unnoticed by anything keyed on the list.\n */\nconst normalizedOf = createNormalizedCache<ComboboxOption>()\nconst normalizedLabelOf = (option: ComboboxOption) => normalizedOf(option, option.label)\n\n// ONE search term, read both by the local filter and by what is sent to the source: the\n// list on screen and the request in flight therefore cannot describe different searches.\n// With nothing typed the term is empty, so a label merely being displayed never narrows\n// the list.\nconst searchTerm = computed(() => (typed.value ? query.value.trim() : ''))\n\n// The options that survive the search, flat and in the order they are shown. This is\n// what the keyboard counts through: blocks and separators do not appear in it, which is\n// exactly why the arrows never stop on one.\nconst filtered = computed(() => {\n const matcher = props.filter\n const list = allOptions.value\n if (matcher === false) return list\n const q = searchTerm.value\n if (!q) return list\n if (typeof matcher === 'function') return list.filter((o) => matcher(o, q))\n const needle = normalizeText(q)\n return list.filter((o) => normalizedLabelOf(o).includes(needle))\n})\n\n// @a11y\n/**\n * What is announced about the state of the panel — that nothing matches, or that\n * something is loading. It is emptied as soon as there are options to show: a region\n * that announces its changes must only ever hold what is new, or the same sentence is\n * read out again at every keystroke.\n */\nconst stateAnnouncement = computed(() => {\n if (!open.value || filtered.value.length > 0) return ''\n return props.loading ? resolvedLoadingText.value : resolvedEmptyText.value\n})\n\n// The render tree: the only place that knows about the hierarchy. Each option there\n// carries its index IN `filtered` (and not its position in the tree): ids, highlight\n// and the #option slot stay aligned on the keyboard navigation.\ntype RenderedOption = { kind: 'option'; key: string; option: ComboboxOption; index: number }\ntype RenderedNode =\n | RenderedOption\n | { kind: 'group'; key: string; label: string; options: RenderedOption[] }\n | { kind: 'separator'; key: string }\n\n//\n// TRAP — nothing here is keyed by VALUE. Two options may share one (a consumer's\n// duplicate, or `1` beside `'1'`, which a template literal spells the same), and a\n// value-keyed index hands both the same position, so both light up as active and Vue\n// patches two rows under one key. The index is COUNTED instead, walking the tree in the\n// order `allOptions` flattens it, which `filtered` keeps; the key is the position in the\n// tree, which filtering does not move.\nconst rendered = computed<RenderedNode[]>(() => {\n const kept = new Set(filtered.value)\n let next = 0\n\n const entryOf = (option: ComboboxOption, key: string): RenderedOption | null => {\n if (!kept.has(option)) return null\n return { kind: 'option', key: `option:${key}`, option, index: next++ }\n }\n\n const nodes: RenderedNode[] = []\n // A separator is held back and only drawn once something has come BEFORE it and\n // something comes AFTER it. That single rule covers all three ways the filtering can\n // strand one: at the top of the list, at the bottom, and two in a row.\n let pendingSeparator: string | null = null\n\n for (const [i, item] of props.options.entries()) {\n if (isSeparator(item)) {\n if (nodes.length > 0) pendingSeparator = `sep:${i}`\n continue\n }\n\n let node: RenderedNode | null\n if (isGroup(item)) {\n const options = item.options\n .map((option, j) => entryOf(option, `${i}.${j}`))\n .filter((entry): entry is RenderedOption => entry !== null)\n // A block none of whose options survived is dropped entirely, its name included:\n // a heading over nothing is worse than no heading.\n node =\n options.length > 0 ? { kind: 'group', key: `group:${i}`, label: item.label, options } : null\n } else {\n node = entryOf(item, String(i))\n }\n if (!node) continue\n\n if (pendingSeparator !== null) {\n nodes.push({ kind: 'separator', key: pendingSeparator })\n pendingSeparator = null\n }\n nodes.push(node)\n }\n\n return nodes\n})\n\n// Telling an outside source what is being searched for. Nothing native waits before\n// sending a request, or refrains from sending the same one twice, so both have to be\n// written. The waiting itself is delegated to `useTimer` — re-arming, a delay of zero\n// running at once, cancellation when the component goes away — and what stays here is\n// specific to this component: not repeating a term, and giving up when the panel closes.\nconst searchTimer = useTimer()\n// The last term actually sent, or nothing if none ever was. It is what stops reopening\n// the panel on an unchanged term from firing the request again — a consumer with a cache\n// of their own is of course free to answer instantly.\nlet lastEmitted: string | undefined\n\nconst cancelSearch = searchTimer.cancel\n\nfunction emitSearch(term: string, immediate = false) {\n cancelSearch()\n if (term === lastEmitted) return\n searchTimer.start(\n () => {\n // The panel may have closed while we were waiting: there is then nothing left to\n // load, and the check has to happen HERE rather than before arming the timer.\n if (!open.value) return\n lastEmitted = term\n emit('search', term)\n },\n immediate ? 0 : props.searchDebounce,\n )\n}\n\nwatch(searchTerm, (term) => {\n if (!open.value) return\n // A new search means a new list, so the highlight cannot survive it: with an outside\n // source the options are replaced wholesale, and the old position would name a\n // completely unrelated option.\n //\n // It is moved to the first available option rather than dropped altogether, and that\n // matters when the filtering is left to the source: the visible list keeps the very\n // same reference until the answer arrives, so the watcher below would never fire and\n // Enter would do nothing in the meantime. When the new list does arrive, the position\n // is still within it and simply names its first option.\n activeIndex.value = filtered.value.findIndex((o) => !o.disabled)\n emitSearch(term)\n})\n\nwatch(filtered, (list) => {\n // While the panel is open there must always be a valid option highlighted. It is moved\n // back to the first result whenever the highlighted one has fallen out of the list OR\n // there was none at all — without that second case, a search that passed through \"no\n // result\" would leave nothing highlighted, and Enter would not choose the single\n // result that came back.\n if (!open.value) return\n if (activeIndex.value < 0 || activeIndex.value >= list.length) {\n activeIndex.value = list.findIndex((o) => !o.disabled)\n }\n})\n\n// With a single value, the field shows its label as ordinary text whenever it is not\n// being edited. Read through `selectedValues`, which is what knows that a number is a\n// value even at zero: a test on the string type would leave a numeric value unlabelled.\nfunction singleLabel() {\n const value = props.multiple ? undefined : selectedValues.value[0]\n return value === undefined ? '' : labelOf(value)\n}\n\nquery.value = singleLabel()\n\n// That label is a COPY and not something derived, so it has to be refreshed when the\n// options arrive later — otherwise a field mounted with a value but no options yet would\n// show a raw identifier for ever.\n//\n// ONLY the options are watched. Watching the value as well would bring back the\n// premature read that selecting deliberately avoids, and the two guards below are what\n// keep the refresh from ever overwriting something being typed.\nwatch(\n allOptions,\n () => {\n if (props.multiple || open.value || typed.value) return\n if (selectedValues.value.length) query.value = singleLabel()\n },\n { flush: 'post' },\n)\n\n/** The chosen values are spelled out as one line of text rather than drawn as chips. */\nconst textDisplay = computed(() => props.multiple && props.display === 'text')\n\n// With several values chosen and the field unfocused, the search input folds away so the\n// chips are not followed by an empty gap. It stays in the page and stays focusable —\n// only its width goes.\n//\n// A read-only TEXT display keeps it folded under the focus too: nothing can be typed, and\n// the input's share of the row would only cut the line of values short for nothing.\nconst collapsed = computed(\n () =>\n props.multiple &&\n selectedValues.value.length > 0 &&\n (!focused.value || (textDisplay.value && props.readonly)),\n)\n\n// `max` holds only while the field is folded. Unfolded, the reader is working on the\n// selection, and every value must be there to be seen and taken back — Backspace included,\n// which would otherwise remove a value hidden behind the \"+X\". `max: 0` means no limit, as\n// on VAvatarGroup: a truthiness test, never `!= null`, which would hide every value.\nconst visibleValues = computed(() =>\n collapsed.value && props.max ? selectedValues.value.slice(0, props.max) : selectedValues.value,\n)\nconst overflowCount = computed(() => selectedValues.value.length - visibleValues.value.length)\n\n// Digits and a plus sign stay out of the dictionary, as VAvatarGroup's \"+N\" does: rephrasing\n// goes through `overflowText` or the `#overflow` slot.\nconst resolvedOverflowText = computed(() =>\n props.overflowText ? props.overflowText(overflowCount.value) : `+${overflowCount.value}`,\n)\n\n// The comma is universal punctuation rather than a word, so it stays out of the dictionary,\n// as in VFileInput's own text display.\nconst displayText = computed(() =>\n textDisplay.value ? visibleValues.value.map(labelOf).join(', ') : '',\n)\n\n// The clear cross has to appear as soon as there is SOMETHING to clear — chosen values,\n// or a search in progress — and not merely when the text field holds text. The field\n// cannot work that out for itself, since the chips live outside its value, so the answer\n// is given to it explicitly, and the room for the cross is reserved accordingly.\nconst clearVisible = computed(() =>\n canClear(\n props,\n resolvedDisabled.value,\n selectedValues.value.length > 0 || query.value.length > 0,\n ),\n)\n\nconst optionId = (index: number) => `${optionsId}-option-${index}`\n\n/**\n * A rendered option with its state worked out, ONCE per row: `row` is what the option\n * element takes, `slot` what the `#option` slot receives, and both read the same two answers.\n */\ntype OptionRow = RenderedOption & {\n row: { id: string; icon?: IconSource; active: boolean; selected: boolean; disabled?: boolean }\n slot: { option: ComboboxOption; index: number; active: boolean; selected: boolean }\n}\ntype RowNode =\n | OptionRow\n | { kind: 'group'; key: string; label: string; options: OptionRow[] }\n | { kind: 'separator'; key: string }\n\nfunction withState(entry: RenderedOption): OptionRow {\n const active = entry.index === activeIndex.value\n const selected = selectedSet.value.has(entry.option.value)\n return {\n ...entry,\n row: {\n id: optionId(entry.index),\n icon: entry.option.icon,\n active,\n selected,\n disabled: entry.option.disabled,\n },\n slot: { option: entry.option, index: entry.index, active, selected },\n }\n}\n\n// A row has to be written twice in the template, once inside a block and once at the top\n// level of the panel, a Vue template having no way to declare a reusable fragment. Kept\n// apart from `rendered` on purpose: the highlight moves on every arrow key, and only this\n// cheap pass over the tree follows it — the filtering and the grouping stay where they are.\nconst rows = computed<RowNode[]>(() =>\n rendered.value.map((node) => {\n if (node.kind === 'option') return withState(node)\n if (node.kind === 'group') return { ...node, options: node.options.map(withState) }\n return node\n }),\n)\n\nfunction hover(entry: RenderedOption) {\n if (!entry.option.disabled) activeIndex.value = entry.index\n}\n\n// @a11y\n// Since the focus never leaves the field, the browser has no reason to scroll the\n// highlighted option into view — nothing was focused. It is brought into view by hand\n// instead, and asked for the SMALLEST movement that reveals it, so an option already\n// visible does not make the panel jump.\nwatch(activeIndex, (index) => {\n if (index < 0) return\n nextTick(() => {\n // Called optionally: the unit-test environment implements no scrolling at all.\n document.getElementById(optionId(index))?.scrollIntoView?.({ block: 'nearest' })\n })\n})\n\n// The single cut-off point of a frozen field: every route into the list — a click on the\n// control, the focus, a keystroke, typing — ends up here, so `readonly` is refused once\n// rather than guarded in each handler.\nfunction openPanel() {\n if (resolvedDisabled.value || props.readonly || open.value) return\n open.value = true\n const list = filtered.value\n const selectedIdx = list.findIndex((o) => !o.disabled && selectedSet.value.has(o.value))\n activeIndex.value = selectedIdx >= 0 ? selectedIdx : list.findIndex((o) => !o.disabled)\n // Told to the source AFTER the panel is marked open — the delayed emission checks that\n // flag before firing — which is what lets an outside source load its first page as the\n // panel appears.\n emitSearch(searchTerm.value, true)\n}\n\n// Asking for the next page as the end of the list is reached. The observer itself, its\n// re-arming after each page and the lock that stops it firing twice all live in\n// `./infiniteScroll`; it is declared here so that closing the panel can reset it.\nconst sentinelEl = ref<HTMLElement | null>(null)\n\nconst infiniteScroll = useInfiniteScroll({\n sentinelEl,\n canLoad: () => open.value && props.hasMore && !props.loading,\n loadedCount: () => allOptions.value.length,\n onLoadMore: () => emit('load-more'),\n})\n\nfunction closePanel() {\n if (!open.value) return\n cancelSearch()\n // A page that never arrived — a request that failed — must not leave the paging\n // frozen for good, so the lock is released here.\n infiniteScroll.reset()\n open.value = false\n activeIndex.value = -1\n typed.value = false\n query.value = singleLabel()\n}\n\n/**\n * Closes as soon as the focus leaves the component — the panel included, which is a\n * descendant of it even while floating above the page.\n */\nconst onFocusout = useFocusoutDismiss(rootEl, closePanel)\n\n// @a11y\n/*\n * TRAP — the focus must never leave the field, and this is what prevents it. Without\n * cancelling the press, clicking an option takes the focus off the field, the handler\n * above closes the panel BEFORE the click is turned into a selection, and choosing with\n * the mouse stops working entirely.\n *\n * It is invisible in the unit tests, where clicking moves no focus; a browser test\n * covers it.\n */\nfunction onPanelMousedown(event: MouseEvent) {\n event.preventDefault()\n}\n\n/** The reader is typing: the text becomes a search, and the panel opens. */\nfunction onInput() {\n typed.value = true\n openPanel()\n}\n\n/**\n * With a single value chosen, the label shown in the field is selected on focus, so that\n * typing replaces it rather than appending to it — and until something IS typed, the\n * whole list stays on offer.\n */\nfunction selectQuery() {\n if (!props.multiple && query.value) inputRef.value?.select()\n}\n\nfunction onFocus() {\n focused.value = true\n selectQuery()\n}\n\n/** Whether a pointer event landed on the chevron, or on the spinner standing in its place. */\nconst onChevron = (event: Event) =>\n event.target instanceof Element &&\n event.target.closest('.v-combobox-chevron, .v-combobox-spinner') !== null\n\n// @core\n/*\n * TRAP — the chevron is not focusable, so pressing it would hand the focus to the page:\n * the root's `focusout` then closes the panel, and the click that follows reopens it. A\n * click meant to close would flash the list instead. Keeping the focus in the field is\n * what lets the click below decide.\n */\nfunction onControlMousedown(event: MouseEvent) {\n if (onChevron(event)) event.preventDefault()\n}\n\n/**\n * A click anywhere on the field focuses it and opens the panel — except on the chevron of\n * an open panel, which closes it.\n */\nfunction onControlClick(event: MouseEvent) {\n if (resolvedDisabled.value) return\n inputRef.value?.focus()\n if (open.value && onChevron(event)) {\n closePanel()\n return\n }\n openPanel()\n // Selected again AFTER the click, which has just placed the caret somewhere in the\n // middle of the label.\n selectQuery()\n}\n\nfunction select(option: ComboboxOption) {\n if (option.disabled) return\n // Remembered immediately: the option may vanish from the list — on the next search —\n // before the parent has even passed the new value back down.\n optionCache.set(option.value, option)\n typed.value = false\n if (props.multiple) {\n model.value = toggleValue(selectedValues.value, option.value)\n query.value = ''\n inputRef.value?.focus()\n } else {\n model.value = option.value\n // This path does not go through the closing function, so the pending search has to\n // be cancelled here as well — otherwise the last keystroke would fire its request\n // after the panel had closed.\n cancelSearch()\n // TRAP — the label is taken from the option just chosen and NOT by reading the value\n // back. With a value bound by the parent, reading it immediately after writing still\n // returns the OLD one, and the field would show the previously selected label.\n query.value = option.label\n open.value = false\n activeIndex.value = -1\n }\n}\n\nfunction removeValue(value: ItemValue) {\n if (!props.multiple || props.readonly) return\n model.value = selectedValues.value.filter((v) => v !== value)\n inputRef.value?.focus()\n}\n\n/**\n * The clear cross was pressed. The field has already emptied the text it holds; what is\n * left to empty is the selection itself — the single value, or all the chips.\n */\nfunction onClear() {\n model.value = props.multiple ? [] : ''\n typed.value = false\n activeIndex.value = -1\n emit('clear')\n}\n\n// @keyboard — moves the highlight, skipping over the options that cannot be chosen and\n// wrapping round from one end of the list to the other.\nfunction move(delta: number) {\n const list = filtered.value\n if (list.length === 0) return\n let i = activeIndex.value\n for (let step = 0; step < list.length; step++) {\n i = (i + delta + list.length) % list.length\n if (!list[i]?.disabled) break\n }\n activeIndex.value = i\n}\n\n// @keyboard @a11y — the whole keyboard of the pattern. The arrows move the POINTER\n// naming the current option and never the focus itself, which stays in the field\n// throughout; Backspace on an empty field takes back the last chip, the usual gesture in\n// a field holding several values.\nfunction onKeydown(event: KeyboardEvent) {\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault()\n if (open.value) move(1)\n else openPanel()\n break\n case 'ArrowUp':\n event.preventDefault()\n if (open.value) move(-1)\n else openPanel()\n break\n case 'Enter':\n if (open.value && activeIndex.value >= 0) {\n event.preventDefault()\n const option = filtered.value[activeIndex.value]\n if (option) select(option)\n }\n break\n case 'Escape':\n closePanel()\n break\n case 'Tab':\n closePanel()\n break\n case 'Backspace':\n if (props.multiple && !query.value) {\n const last = selectedValues.value.at(-1)\n if (last !== undefined) removeValue(last)\n }\n break\n }\n}\n\ndefineExpose({\n /** Moves the focus to the search field. */\n focus: (options?: FocusOptions) => inputRef.value?.focus(options),\n /** Selects what has been typed in the search field. */\n select: () => inputRef.value?.select(),\n /** The real `<input>` behind the field, for what neither of the two above covers. */\n el: computed(() => inputRef.value?.el ?? null),\n})\n</script>\n\n<template>\n <div\n ref=\"rootEl\"\n class=\"v-combobox\"\n :class=\"rootClass\"\n :style=\"[{ '--chip-height': chipScale.height }, rootStyle]\"\n :data-size=\"resolvedSize\"\n :data-compact=\"resolvedCompact ? '' : undefined\"\n :data-multiple=\"multiple ? '' : undefined\"\n :data-collapsed=\"collapsed ? '' : undefined\"\n :data-open=\"open ? '' : undefined\"\n @focusout=\"onFocusout\"\n >\n <div class=\"v-combobox-control\" @mousedown=\"onControlMousedown\" @click=\"onControlClick\">\n <!-- The two arrangements VInput offers a field holding chips: its end controls lifted\n out of the flow, always — the chevron and the cross stay put whether or not the\n input has folded away — and the chips wrapping, when there are chips at all. A\n text display keeps the field on one line and needs only the first. -->\n <VInput\n ref=\"inputRef\"\n v-model=\"query\"\n class=\"v-input-end-pinned\"\n :class=\"{ 'v-input-chips': multiple && !textDisplay }\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-autocomplete=\"list\"\n :aria-expanded=\"open\"\n :aria-controls=\"optionsId\"\n v-bind=\"fieldAttrs\"\n :label=\"label\"\n :hint=\"hint\"\n :size=\"resolvedSize\"\n :compact=\"resolvedCompact\"\n :invalid=\"invalid\"\n :disabled=\"resolvedDisabled\"\n :readonly=\"readonly\"\n :icon-start=\"iconStart\"\n :icon-start-label=\"iconStartLabel\"\n :clearable=\"clearable\"\n :clear-visible=\"clearVisible\"\n :clear-label=\"resolvedClearLabel\"\n :placeholder=\"selectedValues.length === 0 ? placeholder : undefined\"\n :aria-activedescendant=\"open && activeIndex >= 0 ? optionId(activeIndex) : undefined\"\n @input=\"onInput\"\n @keydown=\"onKeydown\"\n @focus=\"onFocus\"\n @blur=\"focused = false\"\n @clear=\"onClear\"\n >\n <template v-if=\"multiple || $slots.start\" #start>\n <span v-if=\"displayText\" class=\"v-combobox-text\">{{ displayText }}</span>\n <!-- A box of its own beside the line rather than the end of it: the labels are what\n the ellipsis cuts, and the count of what they do not show must survive it. -->\n <span v-if=\"textDisplay && overflowCount > 0\" class=\"v-combobox-overflow\">\n <slot\n name=\"overflow\"\n :count=\"overflowCount\"\n :size=\"chipScale.size\"\n :compact=\"chipScale.compact\"\n >{{ resolvedOverflowText }}</slot\n >\n </span>\n <template v-for=\"value in multiple && !textDisplay ? visibleValues : []\" :key=\"value\">\n <slot\n name=\"chip\"\n :value=\"value\"\n :option=\"optionOf(value)\"\n :label=\"labelOf(value)\"\n :remove=\"() => removeValue(value)\"\n :size=\"chipScale.size\"\n :compact=\"chipScale.compact\"\n >\n <VChip\n tone=\"accent\"\n :size=\"chipScale.size\"\n :compact=\"chipScale.compact\"\n :dismissible=\"!readonly && !resolvedDisabled\"\n :dismiss-label=\"m.common.remove(labelOf(value))\"\n :disabled=\"resolvedDisabled\"\n @dismiss=\"removeValue(value)\"\n >{{ labelOf(value) }}</VChip\n >\n </slot>\n </template>\n <!-- Not wrapped, unlike the text display's counter: a box around an inline-flex chip\n opens a line box, whose strut makes the field taller than its chips. Neutral\n and not dismissible, so it reads as a summary rather than one more value. -->\n <slot\n v-if=\"multiple && !textDisplay && overflowCount > 0\"\n name=\"overflow\"\n :count=\"overflowCount\"\n :size=\"chipScale.size\"\n :compact=\"chipScale.compact\"\n >\n <VChip\n class=\"v-combobox-overflow-chip\"\n tone=\"neutral\"\n :size=\"chipScale.size\"\n :compact=\"chipScale.compact\"\n :disabled=\"resolvedDisabled\"\n >{{ resolvedOverflowText }}</VChip\n >\n </slot>\n <slot name=\"start\" />\n </template>\n\n <template v-if=\"$slots['value-end']\" #value-end><slot name=\"value-end\" /></template>\n\n <!-- The chevron sits at the end of the field and turns as the panel opens; the\n clear cross is rendered by the field itself, to its left.\n\n While loading, the spinner takes EXACTLY the chevron's place — the field\n gives a spinner among its direct children the size of an icon — so nothing\n shifts. The field's own loading option is deliberately not used: it would\n overwrite this slot, chevron and all.\n\n The spinner is hidden from screen readers, which neutralizes the status role\n it carries: what announces the loading is the panel, and once is enough. -->\n <template #end>\n <VSpinner v-if=\"loading\" class=\"v-combobox-spinner v-input-icon-end\" aria-hidden=\"true\" />\n <VIcon\n v-else\n v-bind=\"iconProps(expandIcon)\"\n class=\"v-combobox-chevron v-input-icon-end\"\n aria-hidden=\"true\"\n />\n </template>\n </VInput>\n </div>\n\n <!-- TRAP — the panel itself carries BOTH the listbox role and the scrolling. That\n single fact is what the observer watching for the end of the list and the\n scrolling of the highlighted option both rely on: inserting any wrapper between\n them breaks the two at once. -->\n <VPopover\n :id=\"optionsId\"\n v-model:open=\"open\"\n mode=\"manual\"\n anchor=\"--combobox-anchor\"\n match-trigger\n :placement=\"placement\"\n role=\"listbox\"\n class=\"v-combobox-panel v-control\"\n :data-size=\"resolvedSize\"\n :data-compact=\"resolvedCompact ? '' : undefined\"\n :aria-multiselectable=\"multiple ? 'true' : undefined\"\n @mousedown=\"onPanelMousedown\"\n >\n <!-- Blocks and separators exist for the eye alone: the keyboard counts through the\n flat list of surviving options and therefore never encounters one. -->\n <template v-for=\"node in rows\" :key=\"node.key\">\n <VComboboxSeparator v-if=\"node.kind === 'separator'\" />\n\n <VComboboxGroup v-else-if=\"node.kind === 'group'\" :label=\"node.label\">\n <VComboboxOption\n v-for=\"entry in node.options\"\n :key=\"entry.key\"\n v-bind=\"entry.row\"\n @select=\"select(entry.option)\"\n @pointermove=\"hover(entry)\"\n >\n <slot name=\"option\" v-bind=\"entry.slot\">{{ entry.option.label }}</slot>\n </VComboboxOption>\n </VComboboxGroup>\n\n <VComboboxOption\n v-else\n v-bind=\"node.row\"\n @select=\"select(node.option)\"\n @pointermove=\"hover(node)\"\n >\n <slot name=\"option\" v-bind=\"node.slot\">{{ node.option.label }}</slot>\n </VComboboxOption>\n </template>\n\n <!-- The order matters: loading is checked BEFORE emptiness, so that a panel\n waiting for an answer never claims there is no result.\n\n Both are hidden from screen readers, and that is not an oversight. A listbox\n may contain nothing but options and blocks of options, so any other visible\n child would make the panel invalid — where an EMPTY listbox is perfectly\n acceptable. What they say is announced instead by the live region outside the\n panel, which is also the only way a screen reader would ever hear it: plain\n text sitting inside a combobox's popup is not part of what the field walks\n through. -->\n <div v-if=\"loading && filtered.length === 0\" class=\"v-combobox-state\" aria-hidden=\"true\">\n <slot name=\"loading\">\n <VSpinner :label=\"resolvedLoadingText\" />\n <span>{{ resolvedLoadingText }}</span>\n </slot>\n </div>\n <div v-else-if=\"filtered.length === 0\" class=\"v-combobox-state\" aria-hidden=\"true\">\n <slot name=\"empty\" :query=\"searchTerm\">{{ resolvedEmptyText }}</slot>\n </div>\n\n <!-- One element serves as both the marker watched for the end of the list and the\n place the next-page spinner appears. TRAP — it has to stay a SINGLE element:\n rendering the spinner conditionally in its place would destroy the marker and\n silently cancel the observation, and no further page would ever be asked\n for. -->\n <div v-if=\"hasMore\" ref=\"sentinelEl\" class=\"v-combobox-more\" aria-hidden=\"true\">\n <VSpinner v-if=\"loading\" :label=\"resolvedLoadingText\" />\n </div>\n </VPopover>\n\n <!-- The spoken counterpart of the two panel states above. It sits OUTSIDE the\n listbox, being exactly the kind of content a listbox may not contain. -->\n <span class=\"v-visually-hidden\" role=\"status\">{{ stateAnnouncement }}</span>\n </div>\n</template>\n\n<style>\n@layer vectis.components {\n .v-combobox {\n /* Confines the anchor name to this instance. It is declared on the root because that\n is the common ancestor of the field and the panel — a panel drawn above the page\n remains a descendant of it in the document. */\n anchor-scope: --combobox-anchor;\n width: 100%;\n font-family: var(--vectis-text-family);\n }\n\n .v-combobox-control {\n display: block;\n }\n\n /* The anchor is the FIELD's box and not this wrapper's, which also holds the label and\n the hint: anchored to the wrapper, the panel opens a hint's height below the field, and\n a label's height above it once there is no room below and `flip-block` turns it over.\n Against the field it covers whichever of the two it lands on, which is what a panel\n belonging to a control is supposed to do. */\n .v-combobox-control .v-input-field {\n anchor-name: --combobox-anchor;\n }\n\n /* The panel comes from VPopover, which brings the floating element, its open state, its\n anchoring, its placement and its surface. It also carries the shared size class, so\n the options and the state rows read their dimensions from it with no size table\n here. The width tied to the field is VPopover's `matchTrigger`, so what stays here\n is the one thing specific to a list: the scrolling. */\n .v-combobox-panel {\n max-block-size: var(--vectis-control-size-combobox-list-max-block);\n overflow: auto;\n }\n\n /* The chevron and the clear cross are pinned to the end of the field by VInput's\n `.v-input-end-pinned`, which also reserves their room. The chevron and the spinner take\n turns in the same place and occupy the same box — the field gives a spinner among its\n direct children the size of an icon — so swapping one for the other shifts nothing. */\n .v-combobox-chevron,\n .v-combobox-spinner {\n color: var(--vectis-color-text-muted);\n }\n\n .v-combobox-chevron {\n transition: rotate var(--vectis-duration-fast) var(--vectis-ease-default);\n }\n\n .v-combobox[data-open] .v-combobox-chevron {\n rotate: 180deg;\n }\n\n /* Folded away, the input is taken out of the flow entirely rather than merely narrowed:\n even at zero width it would still occupy a line of its own under the chips and leave\n a visible gap.\n\n It remains in the page and remains focusable — clicking the field or tabbing into it\n brings it straight back, the folded state ending as soon as it has the focus. */\n .v-combobox[data-collapsed] .v-input-control {\n position: absolute;\n width: 0;\n height: 0;\n padding: 0;\n }\n\n /* The chosen values as one line of text, cut short with an ellipsis. It shrinks before the\n search input does, the input being `flex: 1` with no floor of its own.\n\n Under the focus the two share the row, and the line is capped at half of it so that a\n long selection cannot squeeze what is being typed down to nothing. Folded, the input is\n out of the flow and the line takes the whole field. */\n .v-combobox-text {\n flex: 0 1 auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .v-combobox:not([data-collapsed]) .v-combobox-text {\n max-inline-size: 50%;\n }\n\n /* The \"+X\" after a line of text never shrinks: the line gives way instead. */\n .v-combobox-overflow {\n flex: none;\n white-space: nowrap;\n color: var(--vectis-color-text-muted);\n }\n\n /* TRAP — an unbroken line has the whole of its text as its min-content width, and that\n width travels up through the field to the root. In a grid track or a flex row sized\n `auto`, the component then widens its container to fit every label instead of cutting\n them short, and the ellipsis never shows. Chips wrap, so they carry no such minimum. */\n .v-combobox:has(.v-combobox-text) {\n min-inline-size: 0;\n }\n\n /* The rows saying \"nothing matches\" or \"loading\" are built like an option: they read\n the same inherited dimensions from the panel, and the spinner follows through the\n same block's icon context. They refuse to shrink, the panel being a bounded column\n that would otherwise squash them. */\n .v-combobox-state {\n display: flex;\n flex: none;\n align-items: center;\n gap: var(--control-gap);\n min-height: var(--control-height);\n padding: var(--vectis-space-1) var(--control-padding-inline);\n font-size: var(--control-font-size);\n color: var(--vectis-color-text-muted);\n }\n\n /* The foot of the list: the marker watched for the end, and the place the next-page\n spinner appears. It is given a real height on purpose — a box of no height at all\n makes the crossing it is watched for unreliable. */\n .v-combobox-more {\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n min-height: var(--vectis-space-6);\n color: var(--vectis-color-text-muted);\n }\n\n @media (prefers-reduced-motion: reduce) {\n .v-combobox-chevron {\n transition: none;\n }\n }\n}\n</style>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"VCombobox.js","names":[],"sources":["../../../src/components/VCombobox/VCombobox.vue"],"sourcesContent":["<script setup lang=\"ts\">\n// @a11y @keyboard @core\n/**\n * A field typed into to search a list, and to pick one or several values from. Composed of a\n * VInput, a VPopover holding the `role=\"listbox\"` panel, and VChips for the chosen values.\n *\n * The platform offers nothing to build on — `<datalist>` can be neither styled nor made\n * multi-select — so the JS here implements the whole ARIA combobox pattern: the filtering,\n * the highlight and the selection.\n *\n * ONE decision shapes the rest: DOM focus NEVER leaves the text field. What moves under the\n * arrows is `aria-activedescendant`, which is why the panel has no keyboard of its own and\n * why this component owns the field's entire accessibility contract.\n *\n * The panel is `mode=\"manual\"` (no light dismiss) and closes on `focusout` — which works\n * only because the field is OUTSIDE the panel.\n */\n\nimport { computed, inject, nextTick, reactive, ref, useId, watch, watchEffect } from 'vue'\n\nimport VChip from '../VChip/VChip.vue'\nimport type { ChipSize } from '../VChip/VChip.vue'\nimport VIcon from '../VIcon/VIcon.vue'\nimport { iconProps } from '../VIcon/iconProps'\nimport { expand_more as expandMoreIcon } from '../VIcon/icons/expand_more'\nimport type { IconSource } from '../VIcon/types'\nimport VInput from '../VInput/VInput.vue'\nimport VPopover from '../VPopover/VPopover.vue'\nimport VComboboxOption from './VComboboxOption.vue'\nimport VComboboxGroup from './VComboboxGroup.vue'\nimport VComboboxSeparator from './VComboboxSeparator.vue'\nimport { useInfiniteScroll } from './infiniteScroll'\nimport VSpinner from '../VSpinner/VSpinner.vue'\n\nimport { toggleValue } from '../../utils/array'\nimport type { ItemValue } from '../../types'\nimport { inputGroupKey } from '../VInput/context'\n\nimport { chipScaleFor } from '../../utils/chip'\nimport { createNormalizedCache, normalizeText } from '../../utils/text'\n\nimport { useControlShape } from '../../composables/useControlShape'\nimport { useRootAttrs } from '../../composables/useRootAttrs'\n\nimport { useFocusoutDismiss } from '../../composables/useFocusoutDismiss'\n\nimport { canClear } from '../../composables/useClearable'\nimport { iconStartListener } from '../../composables/useIconClickHandlers'\n\nimport { useTimer } from '../../composables/useTimer'\nimport { useMessages } from '../../i18n/state'\n\n/** One thing that can be chosen. */\nexport interface ComboboxOption {\n /**\n * What choosing it means: this is what the value holds. A number is admitted because a\n * list of options almost always comes from somewhere that keys its rows by one.\n */\n value: ItemValue\n /** What it is called on screen, and what the search matches against. */\n label: string\n /** An icon before the label: an icon name, or an explicit render. */\n icon?: IconSource\n /** Shows the option without allowing it to be chosen. */\n disabled?: boolean\n}\n\n/**\n * A named block of options, the equivalent of the grouping a native list offers. A\n * group none of whose options survive the search disappears entirely, its name\n * included.\n */\nexport interface ComboboxGroup {\n /** The name of the block. */\n label: string\n /** The options it holds. */\n options: ComboboxOption[]\n}\n\n/**\n * A rule drawn between two blocks of options. It is purely decorative, and a separator\n * the search leaves stranded (at the top, at the bottom, or against another one) is\n * simply not drawn.\n */\nexport interface ComboboxSeparator {\n separator: true\n}\n\n/** Anything the list may hold: an option, a named block, or a separator. */\nexport type ComboboxItem = ComboboxOption | ComboboxGroup | ComboboxSeparator\n\nconst isGroup = (item: ComboboxItem): item is ComboboxGroup => 'options' in item\nconst isSeparator = (item: ComboboxItem): item is ComboboxSeparator => 'separator' in item\n\n/**\n * How the list is narrowed as one types: by the component itself, not at all (when the\n * options already arrive filtered by a server), or by a rule of your own.\n */\nexport type ComboboxFilter = boolean | ((option: ComboboxOption, query: string) => boolean)\n\n/** Where the list opens relative to the field. */\nexport type ComboboxPlacement =\n 'bottom' | 'bottom-start' | 'bottom-end' | 'top' | 'top-start' | 'top-end'\n\n/** The height of the field: 32, 40 or 48 pixels. */\nexport type ComboboxSize = 'sm' | 'md' | 'lg'\n\n/**\n * How the chosen values are shown in a multiple field: one chip each, or their labels\n * joined by commas.\n */\nexport type ComboboxDisplay = 'chip' | 'text'\n\n/** What the `#option` slot receives. */\nexport interface ComboboxOptionSlotProps {\n option: ComboboxOption\n index: number\n active: boolean\n selected: boolean\n}\n\n/** What the `#chip` slot receives. */\nexport interface ComboboxChipSlotProps {\n value: ItemValue\n option: ComboboxOption | undefined\n label: string\n remove: () => void\n size: ChipSize\n compact: boolean\n}\n\n/** What the `#overflow` slot receives. */\nexport interface ComboboxOverflowSlotProps {\n count: number\n size: ChipSize\n compact: boolean\n}\n\n/** What the `#empty` slot receives. */\nexport interface ComboboxEmptySlotProps {\n query: string\n}\n\ninterface ComboboxProps {\n /**\n * What the list offers. An entry may be an option, a named block of options, or a\n * separator; a plain list of options remains perfectly valid.\n */\n options: ComboboxItem[]\n /**\n * Allows several values to be chosen, which makes the value a list and shows what has\n * been chosen inside the field, as chips or as text depending on `display`.\n */\n multiple?: boolean\n /**\n * How the chosen values are shown when several can be chosen: one dismissible chip\n * each, or their labels joined by commas on a single line, cut short with an ellipsis\n * when they run out of room. It changes nothing for a single value, which is always\n * text.\n */\n display?: ComboboxDisplay\n /**\n * How many chosen values to show before the rest are summed up as \"+X\", as chips or as\n * text alike. It applies while the search input is folded away, which is to say out of\n * focus: focused, every value comes back so it can be seen and taken back. Left out, or\n * set to 0, every value is shown. It changes nothing without `multiple`.\n */\n max?: number\n /**\n * Rephrases the \"+X\" standing for the values beyond `max`, \"+5 products\" for instance.\n * It receives the number of values being hidden.\n */\n overflowText?: (count: number) => string\n /** The label above the field, tied to it so that clicking it focuses the field. */\n label?: string\n /**\n * A line of help under the field. It is tied to the field for assistive technology,\n * so it is read out along with the label.\n */\n hint?: string\n /** The height of the field: 32, 40 or 48 pixels. */\n size?: ComboboxSize\n /** Takes 4px off the height, as everywhere else in the design system. */\n compact?: boolean\n /** What the field says while nothing is chosen and nothing has been typed. */\n placeholder?: string\n /** Makes the field unusable, greyed out through the colour tokens. */\n disabled?: boolean\n /**\n * Shows what has been chosen without letting it be changed: nothing can be typed,\n * the list never opens, the chips lose their crosses and no clear cross is offered.\n * The field stays focusable and can be copied from, which is what separates it from\n * `disabled`.\n */\n readonly?: boolean\n /** Marks the field as invalid, for a rule of your own. */\n invalid?: boolean\n /**\n * An icon inside the field, at the start, before the chips when several values can\n * be chosen. It is decorative by default and becomes a real button as soon as a\n * `@click:icon-start` listener is attached, in which case it needs `iconStartLabel`.\n */\n iconStart?: IconSource\n /** What the start icon does, in words, once it is clickable. */\n iconStartLabel?: string\n /**\n * The chevron at the end of the field, which turns as the list opens: an icon name,\n * or an explicit render. Clicking it while the list is open closes the list. It is\n * decoration all the same (the field itself is what opens the list, and Escape what\n * closes it from the keyboard), so the chevron is hidden from screen readers and takes\n * no label.\n */\n expandIcon?: IconSource\n /** Offers a cross that empties both the selection and the search. */\n clearable?: boolean\n /** What that cross does, in words. It falls back to the design system dictionary. */\n clearLabel?: string\n /**\n * What the panel says when the search matches nothing. It is also what a screen reader\n * hears, even when the `#empty` slot draws something else: set both together.\n */\n emptyText?: string\n /**\n * How the list is narrowed as one types. Turning it off means the options already\n * arrive filtered by their source and are shown exactly as they come.\n *\n * A rule of your own receives the query as it was TYPED, merely trimmed, rather than the\n * accent-insensitive form used internally.\n */\n filter?: ComboboxFilter\n /**\n * How long to wait before telling the source what is being searched for, in\n * milliseconds. Zero tells it at once, which suits a source that is not a network\n * request.\n */\n searchDebounce?: number\n /**\n * Says that something is being loaded. With no option yet, the whole panel says so;\n * with options already listed, a spinner appears at the foot of the list, since what\n * is loading is then the next page. Either way the field replaces its chevron with a\n * spinner.\n */\n loading?: boolean\n /**\n * What is said while loading, and what the spinner is announced as. A screen reader hears\n * it even when the `#loading` slot draws something else: set both together.\n */\n loadingText?: string\n /**\n * Says that there are more pages to come, which is what makes the component ask for\n * the next one as the end of the list comes into view.\n */\n hasMore?: boolean\n /** Where the list opens relative to the field. */\n placement?: ComboboxPlacement\n}\n\nconst props = withDefaults(defineProps<ComboboxProps>(), {\n multiple: false,\n display: 'chip',\n max: undefined,\n overflowText: undefined,\n label: undefined,\n hint: undefined,\n size: 'md',\n compact: false,\n placeholder: undefined,\n disabled: false,\n readonly: false,\n invalid: false,\n iconStart: undefined,\n iconStartLabel: undefined,\n expandIcon: () => expandMoreIcon,\n clearable: false,\n clearLabel: undefined,\n emptyText: undefined,\n filter: true,\n searchDebounce: 250,\n loading: false,\n loadingText: undefined,\n hasMore: false,\n placement: 'bottom-start',\n})\n\nconst m = useMessages()\nconst resolvedEmptyText = computed(() => props.emptyText ?? m.value.combobox.empty)\nconst resolvedClearLabel = computed(() => props.clearLabel ?? m.value.combobox.clear)\nconst resolvedLoadingText = computed(() => props.loadingText ?? m.value.common.loading)\n\nconst emit = defineEmits<{\n /**\n * What is being searched for, to be sent to the source. It is delayed by\n * `searchDebounce` while typing, and emitted at once when the panel opens so that a\n * first page can be loaded.\n *\n * The same term is never emitted twice in a row, so reopening the panel does not\n * repeat a request that has already been answered.\n */\n search: [query: string]\n /** The end of the list has come into view: send the next page. */\n 'load-more': []\n /** The clear cross emptied the selection and the search. */\n clear: []\n /** The start icon was clicked. Attaching this listener is what makes it a button. */\n 'click:icon-start': [event: MouseEvent]\n}>()\n\ndefineSlots<{\n /**\n * Content at the start of the field, rendered after the chips standing for the chosen\n * values rather than in their place.\n */\n start?(): unknown\n /**\n * Controls of your own inside the field, placed before the ones the field owns: the\n * clear cross and the chevron. Those two are this component's own affordance, which is\n * why there is no `#end` here: it would replace them.\n */\n 'value-end'?(): unknown\n /**\n * What a row of the list shows, in place of the plain label: a subtitle, an avatar,\n * a badge. It is told whether the row is the highlighted one and whether it is\n * already chosen, so the rendering can react to both.\n */\n option?(props: ComboboxOptionSlotProps): unknown\n /**\n * Replaces the chip standing for one chosen value.\n *\n * Three of the values it receives are what make it usable without regressions:\n * `remove`, without which the value could no longer be taken back, and the size and\n * density worked out to sit inside the field, which cannot be guessed from outside.\n * The option itself may be missing, if that value has never appeared among the\n * options.\n */\n chip?(props: ComboboxChipSlotProps): unknown\n /**\n * Replaces the \"+X\" standing for the values beyond `max`. It receives `count`, the number\n * of values being hidden, and the size and density of the chips inside the field, so that a\n * chip of your own lines up with the others.\n */\n overflow?(props: ComboboxOverflowSlotProps): unknown\n /** What the panel shows when nothing matches. It receives the term that was searched. */\n empty?(props: ComboboxEmptySlotProps): unknown\n /** What the panel shows while loading its first options. */\n loading?(): unknown\n}>()\n\n// A VInputGroup joins several controls into one object, so the shape of this field is the\n// row's decision rather than its own (VInput/context.ts). Everything below reads the\n// RESOLVED values and never the props: the chips, the panel and the field would otherwise\n// come out at three different scales inside the same row.\nconst group = inject(inputGroupKey, null)\nconst {\n size: resolvedSize,\n compact: resolvedCompact,\n disabled: resolvedDisabled,\n} = useControlShape(props, group)\n\n// The size, the density and the HEIGHT of the chips sitting inside the field, worked out\n// once in `utils/chip.ts` and shared with VFileInput. The height is set inline below\n// rather than restated as a table of CSS rules: it is the height the field forces on its\n// input, and deriving both from the same pair is what stops them drifting apart.\nconst chipScale = computed(() => chipScaleFor(resolvedSize.value, resolvedCompact.value))\n\n/**\n * The chosen option's `value`, or the list of them when `multiple` is set. It is an empty\n * string to begin with, and the array is never mutated in place: each change is a new one,\n * which is what wakes the consumer's binding.\n */\nconst model = defineModel<ItemValue | ItemValue[]>({ default: '' })\n\n// `class` and `style` stay on the wrapper, where a consumer expects to style the\n// component; everything else — a name above all — goes down to the text field, which is\n// the element assistive technology treats as the combobox.\ndefineOptions({ inheritAttrs: false })\nconst { rootClass, rootStyle, forwardedAttrs } = useRootAttrs()\n\n// Declared as this component's own event, `click:icon-start` is out of `$attrs`, so the\n// listener is relayed to the field by hand — and only when the consumer wrote one.\nconst iconStartClick = iconStartListener((event) => emit('click:icon-start', event))\n\n/** What reaches the field: the consumer's own attributes, plus that listener. */\nconst fieldAttrs = computed(() => ({ ...forwardedAttrs.value, ...iconStartClick }))\n\nconst rootEl = ref<HTMLElement | null>(null)\nconst inputRef = ref<InstanceType<typeof VInput> | null>(null)\n// One generated identifier serves twice: as the panel's own id, which the field points\n// at, and as the prefix of every option's id. The two strings can never collide, one\n// being a prefix of longer ones.\nconst optionsId = useId()\n\nconst open = ref(false)\nconst query = ref('')\nconst activeIndex = ref(-1)\nconst focused = ref(false)\n// The text in the field serves two purposes at once: it SHOWS the chosen label when a\n// single value is picked, and it is what one searches with. This flag tells the two\n// apart — while it is false the text is merely a label and narrows nothing, so reopening\n// the panel offers the whole list again. It only becomes true once the reader types.\nconst typed = ref(false)\n\nconst selectedValues = computed<ItemValue[]>(() => {\n if (props.multiple) return Array.isArray(model.value) ? model.value : []\n // An empty string is what an emptied combobox says, and it is not a value. A NUMBER, on\n // the other hand, is a value even at zero — hence the test on the empty string alone\n // rather than on falsiness, which would drop the option keyed `0`.\n return !Array.isArray(model.value) && model.value !== '' ? [model.value] : []\n})\n\n// Every option, flattened: the blocks unwrapped, the separators dropped, in the order\n// they were given. This is the ONE reading of the options the rest of the component\n// does — the filtering, the memory of what was chosen, the labels and the paging all\n// ignore the hierarchy entirely. Only the rendering below knows about it.\nconst allOptions = computed<ComboboxOption[]>(() =>\n props.options.flatMap((item) => {\n if (isSeparator(item)) return []\n return isGroup(item) ? item.options : [item]\n }),\n)\n\n// A memory of the options that were CHOSEN. With a source that answers over the network,\n// the options only ever hold the latest results, and something already chosen is usually\n// absent from them — without this, a chip would show a raw identifier instead of a name,\n// and a custom chip would lose the option's icon.\n//\n// It is kept up to date by an effect rather than by watching the options, because the\n// effect tracks the ITERATION and therefore also notices a page appended in place. And\n// it is bounded to what is currently chosen: everything else is read from the options\n// themselves.\nconst optionCache = reactive(new Map<ItemValue, ComboboxOption>())\nwatchEffect(() => {\n const wanted = new Set(selectedValues.value)\n for (const option of allOptions.value) {\n if (wanted.has(option.value)) optionCache.set(option.value, option)\n }\n // What is no longer chosen is forgotten. Without this the memory would grow with every\n // value chosen during the session rather than with the current selection — a slow leak\n // in a long-lived multiple field fed by a paginated source.\n for (const value of optionCache.keys()) if (!wanted.has(value)) optionCache.delete(value)\n})\n\n/*\n * A lookup from value to option, built once per list of options rather than searched\n * each time. Finding an option is done several times per chip and per render — for the\n * chip itself, its label and the name of its remove button — so a linear search here\n * would cost the number of chips times the number of options, on every keystroke.\n *\n * The FIRST match wins, exactly as a search would have done, so a duplicated value keeps\n * the option that came first.\n */\nconst optionsByValue = computed(() => {\n const map = new Map<ItemValue, ComboboxOption>()\n for (const option of allOptions.value) if (!map.has(option.value)) map.set(option.value, option)\n return map\n})\n\n/**\n * The selection as a set, so that asking \"is this one chosen?\" costs nothing however\n * many are — the same device VDataTable uses for its selected rows.\n */\nconst selectedSet = computed(() => new Set(selectedValues.value))\n\n/**\n * The option a value stands for: from the current options first, and from the memory of\n * chosen ones failing that.\n *\n * TRAP — an option coming from that memory is a reactive PROXY, since making the map\n * reactive converts the objects inside it. Compare options by their value and never by\n * identity, or the two forms of the same option will not match.\n */\nfunction optionOf(value: ItemValue) {\n return optionsByValue.value.get(value) ?? optionCache.get(value)\n}\n\nfunction labelOf(value: ItemValue) {\n return optionOf(value)?.label ?? String(value)\n}\n\n/*\n * The labels in their accent-insensitive form, remembered per option. Reading the label on\n * every call is what keeps the filter reactive: flattening the options only ever touches the\n * containers, so a label changed in place would go unnoticed by anything keyed on the list.\n */\nconst normalizedOf = createNormalizedCache<ComboboxOption>()\nconst normalizedLabelOf = (option: ComboboxOption) => normalizedOf(option, option.label)\n\n// ONE search term, read both by the local filter and by what is sent to the source: the\n// list on screen and the request in flight therefore cannot describe different searches.\n// With nothing typed the term is empty, so a label merely being displayed never narrows\n// the list.\nconst searchTerm = computed(() => (typed.value ? query.value.trim() : ''))\n\n// TRAP — closing empties `searchTerm` (the typing flag drops) in the same tick as it hides\n// the panel, but the panel fades out rather than vanishing. Filtered on the live term, the\n// list would spring back to every option during that fade, and the panel grow under the\n// pointer that just chose. The term in force is therefore frozen here on every close and\n// released on the next opening; `null` means the panel is live and follows the search.\nconst closedTerm = ref<string | null>(null)\n\n// The options that survive the search, flat and in the order they are shown. This is\n// what the keyboard counts through: blocks and separators do not appear in it, which is\n// exactly why the arrows never stop on one.\nconst filtered = computed(() => {\n const matcher = props.filter\n const list = allOptions.value\n if (matcher === false) return list\n const q = closedTerm.value ?? searchTerm.value\n if (!q) return list\n if (typeof matcher === 'function') return list.filter((o) => matcher(o, q))\n const needle = normalizeText(q)\n return list.filter((o) => normalizedLabelOf(o).includes(needle))\n})\n\n// @a11y\n/**\n * What is announced about the state of the panel — that nothing matches, or that\n * something is loading. It is emptied as soon as there are options to show: a region\n * that announces its changes must only ever hold what is new, or the same sentence is\n * read out again at every keystroke.\n */\nconst stateAnnouncement = computed(() => {\n if (!open.value || filtered.value.length > 0) return ''\n return props.loading ? resolvedLoadingText.value : resolvedEmptyText.value\n})\n\n// The render tree: the only place that knows about the hierarchy. Each option there\n// carries its index IN `filtered` (and not its position in the tree): ids, highlight\n// and the #option slot stay aligned on the keyboard navigation.\ntype RenderedOption = { kind: 'option'; key: string; option: ComboboxOption; index: number }\ntype RenderedNode =\n | RenderedOption\n | { kind: 'group'; key: string; label: string; options: RenderedOption[] }\n | { kind: 'separator'; key: string }\n\n//\n// TRAP — nothing here is keyed by VALUE. Two options may share one (a consumer's\n// duplicate, or `1` beside `'1'`, which a template literal spells the same), and a\n// value-keyed index hands both the same position, so both light up as active and Vue\n// patches two rows under one key. The index is COUNTED instead, walking the tree in the\n// order `allOptions` flattens it, which `filtered` keeps; the key is the position in the\n// tree, which filtering does not move.\nconst rendered = computed<RenderedNode[]>(() => {\n const kept = new Set(filtered.value)\n let next = 0\n\n const entryOf = (option: ComboboxOption, key: string): RenderedOption | null => {\n if (!kept.has(option)) return null\n return { kind: 'option', key: `option:${key}`, option, index: next++ }\n }\n\n const nodes: RenderedNode[] = []\n // A separator is held back and only drawn once something has come BEFORE it and\n // something comes AFTER it. That single rule covers all three ways the filtering can\n // strand one: at the top of the list, at the bottom, and two in a row.\n let pendingSeparator: string | null = null\n\n for (const [i, item] of props.options.entries()) {\n if (isSeparator(item)) {\n if (nodes.length > 0) pendingSeparator = `sep:${i}`\n continue\n }\n\n let node: RenderedNode | null\n if (isGroup(item)) {\n const options = item.options\n .map((option, j) => entryOf(option, `${i}.${j}`))\n .filter((entry): entry is RenderedOption => entry !== null)\n // A block none of whose options survived is dropped entirely, its name included:\n // a heading over nothing is worse than no heading.\n node =\n options.length > 0 ? { kind: 'group', key: `group:${i}`, label: item.label, options } : null\n } else {\n node = entryOf(item, String(i))\n }\n if (!node) continue\n\n if (pendingSeparator !== null) {\n nodes.push({ kind: 'separator', key: pendingSeparator })\n pendingSeparator = null\n }\n nodes.push(node)\n }\n\n return nodes\n})\n\n// Telling an outside source what is being searched for. Nothing native waits before\n// sending a request, or refrains from sending the same one twice, so both have to be\n// written. The waiting itself is delegated to `useTimer` — re-arming, a delay of zero\n// running at once, cancellation when the component goes away — and what stays here is\n// specific to this component: not repeating a term, and giving up when the panel closes.\nconst searchTimer = useTimer()\n// The last term actually sent, or nothing if none ever was. It is what stops reopening\n// the panel on an unchanged term from firing the request again — a consumer with a cache\n// of their own is of course free to answer instantly.\nlet lastEmitted: string | undefined\n\nconst cancelSearch = searchTimer.cancel\n\nfunction emitSearch(term: string, immediate = false) {\n cancelSearch()\n if (term === lastEmitted) return\n searchTimer.start(\n () => {\n // The panel may have closed while we were waiting: there is then nothing left to\n // load, and the check has to happen HERE rather than before arming the timer.\n if (!open.value) return\n lastEmitted = term\n emit('search', term)\n },\n immediate ? 0 : props.searchDebounce,\n )\n}\n\nwatch(searchTerm, (term) => {\n if (!open.value) return\n // A new search means a new list, so the highlight cannot survive it: with an outside\n // source the options are replaced wholesale, and the old position would name a\n // completely unrelated option.\n //\n // It is moved to the first available option rather than dropped altogether, and that\n // matters when the filtering is left to the source: the visible list keeps the very\n // same reference until the answer arrives, so the watcher below would never fire and\n // Enter would do nothing in the meantime. When the new list does arrive, the position\n // is still within it and simply names its first option.\n activeIndex.value = filtered.value.findIndex((o) => !o.disabled)\n // The page asked for under the previous term will never arrive, and the first page of\n // the new one may be exactly as long as the list it replaces — which the paging would\n // not recognise as an arrival.\n infiniteScroll.restart()\n emitSearch(term)\n})\n\nwatch(filtered, (list) => {\n // While the panel is open there must always be a valid option highlighted. It is moved\n // back to the first result whenever the highlighted one has fallen out of the list OR\n // there was none at all — without that second case, a search that passed through \"no\n // result\" would leave nothing highlighted, and Enter would not choose the single\n // result that came back.\n if (!open.value) return\n if (activeIndex.value < 0 || activeIndex.value >= list.length) {\n activeIndex.value = list.findIndex((o) => !o.disabled)\n }\n})\n\n// With a single value, the field shows its label as ordinary text whenever it is not\n// being edited. Read through `selectedValues`, which is what knows that a number is a\n// value even at zero: a test on the string type would leave a numeric value unlabelled.\nfunction singleLabel() {\n const value = props.multiple ? undefined : selectedValues.value[0]\n return value === undefined ? '' : labelOf(value)\n}\n\nquery.value = singleLabel()\n\n// That label is a COPY and not something derived, so it has to be refreshed when the\n// options arrive later — otherwise a field mounted with a value but no options yet would\n// show a raw identifier for ever — AND when the parent changes the value: an edit form\n// loading its record after mount, or a reset, would otherwise leave the old label on show.\n//\n// Watching the value does not bring back the premature read `select` avoids: this watcher\n// only runs once the value has CHANGED, i.e. once the parent has passed it back down, and\n// its `post` timing reads it after that render. The two guards below keep the refresh from\n// ever overwriting something being typed.\nwatch(\n [allOptions, selectedValues],\n () => {\n if (props.multiple || open.value || typed.value) return\n query.value = singleLabel()\n },\n { flush: 'post' },\n)\n\n/** The chosen values are spelled out as one line of text rather than drawn as chips. */\nconst textDisplay = computed(() => props.multiple && props.display === 'text')\n\n// With several values chosen and the field unfocused, the search input folds away so the\n// chips are not followed by an empty gap. It stays in the page and stays focusable —\n// only its width goes.\n//\n// A read-only TEXT display keeps it folded under the focus too: nothing can be typed, and\n// the input's share of the row would only cut the line of values short for nothing.\nconst collapsed = computed(\n () =>\n props.multiple &&\n selectedValues.value.length > 0 &&\n (!focused.value || (textDisplay.value && props.readonly)),\n)\n\n// `max` holds only while the field is folded. Unfolded, the reader is working on the\n// selection, and every value must be there to be seen and taken back — Backspace included,\n// which would otherwise remove a value hidden behind the \"+X\". `max: 0` means no limit, as\n// on VAvatarGroup: a truthiness test, never `!= null`, which would hide every value.\nconst visibleValues = computed(() =>\n collapsed.value && props.max ? selectedValues.value.slice(0, props.max) : selectedValues.value,\n)\nconst overflowCount = computed(() => selectedValues.value.length - visibleValues.value.length)\n\n// Digits and a plus sign stay out of the dictionary, as VAvatarGroup's \"+N\" does: rephrasing\n// goes through `overflowText` or the `#overflow` slot.\nconst resolvedOverflowText = computed(() =>\n props.overflowText ? props.overflowText(overflowCount.value) : `+${overflowCount.value}`,\n)\n\n// The comma is universal punctuation rather than a word, so it stays out of the dictionary,\n// as in VFileInput's own text display.\nconst displayText = computed(() =>\n textDisplay.value ? visibleValues.value.map(labelOf).join(', ') : '',\n)\n\n// The clear cross has to appear as soon as there is SOMETHING to clear — chosen values,\n// or a search in progress — and not merely when the text field holds text. The field\n// cannot work that out for itself, since the chips live outside its value, so the answer\n// is given to it explicitly, and the room for the cross is reserved accordingly.\nconst clearVisible = computed(() =>\n canClear(\n props,\n resolvedDisabled.value,\n selectedValues.value.length > 0 || query.value.length > 0,\n ),\n)\n\n// @a11y\n// An option's id follows the OPTION, from its place among all the options, and never its\n// place in the filtered list: a screen reader announces the current option when\n// `aria-activedescendant` changes, and a positional id would keep the same value while the\n// filter slides another option under the highlight, which then goes unannounced. Still\n// indexed by the filtered position, which is what the keyboard counts through.\nconst sourceIndex = computed(() => new Map(allOptions.value.map((option, i) => [option, i])))\nconst optionId = (index: number) => {\n const option = filtered.value[index]\n return `${optionsId}-option-${option ? sourceIndex.value.get(option) : index}`\n}\n\n/**\n * A rendered option with its state worked out, ONCE per row: `row` is what the option\n * element takes, `slot` what the `#option` slot receives, and both read the same two answers.\n */\ntype OptionRow = RenderedOption & {\n row: { id: string; icon?: IconSource; active: boolean; selected: boolean; disabled?: boolean }\n slot: { option: ComboboxOption; index: number; active: boolean; selected: boolean }\n}\ntype RowNode =\n | OptionRow\n | { kind: 'group'; key: string; label: string; options: OptionRow[] }\n | { kind: 'separator'; key: string }\n\nfunction withState(entry: RenderedOption): OptionRow {\n const active = entry.index === activeIndex.value\n const selected = selectedSet.value.has(entry.option.value)\n return {\n ...entry,\n row: {\n id: optionId(entry.index),\n icon: entry.option.icon,\n active,\n selected,\n disabled: entry.option.disabled,\n },\n slot: { option: entry.option, index: entry.index, active, selected },\n }\n}\n\n// A row has to be written twice in the template, once inside a block and once at the top\n// level of the panel, a Vue template having no way to declare a reusable fragment. Kept\n// apart from `rendered` on purpose: the highlight moves on every arrow key, and only this\n// cheap pass over the tree follows it — the filtering and the grouping stay where they are.\n// That saves the COMPUTED work only: every option component still re-renders on each move,\n// since a `v-for` row whose slot reads loop variables is always patched. Keep long lists\n// server-paged (`hasMore`) rather than relying on this pass to make them cheap.\nconst rows = computed<RowNode[]>(() =>\n rendered.value.map((node) => {\n if (node.kind === 'option') return withState(node)\n if (node.kind === 'group') return { ...node, options: node.options.map(withState) }\n return node\n }),\n)\n\nfunction hover(entry: RenderedOption) {\n if (!entry.option.disabled) activeIndex.value = entry.index\n}\n\n// @a11y\n// Since the focus never leaves the field, the browser has no reason to scroll the\n// highlighted option into view — nothing was focused. It is brought into view by hand\n// instead, and asked for the SMALLEST movement that reveals it, so an option already\n// visible does not make the panel jump.\nwatch(activeIndex, (index) => {\n if (index < 0) return\n nextTick(() => {\n // Called optionally: the unit-test environment implements no scrolling at all.\n document.getElementById(optionId(index))?.scrollIntoView?.({ block: 'nearest' })\n })\n})\n\n// The single cut-off point of a frozen field: every route into the list — a click on the\n// control, the focus, a keystroke, typing — ends up here, so `readonly` is refused once\n// rather than guarded in each handler.\nfunction openPanel() {\n if (resolvedDisabled.value || props.readonly || open.value) return\n closedTerm.value = null\n open.value = true\n const list = filtered.value\n const selectedIdx = list.findIndex((o) => !o.disabled && selectedSet.value.has(o.value))\n activeIndex.value = selectedIdx >= 0 ? selectedIdx : list.findIndex((o) => !o.disabled)\n // Told to the source AFTER the panel is marked open — the delayed emission checks that\n // flag before firing — which is what lets an outside source load its first page as the\n // panel appears.\n emitSearch(searchTerm.value, true)\n}\n\n// Asking for the next page as the end of the list is reached. The observer itself, its\n// re-arming after each page and the lock that stops it firing twice all live in\n// `./infiniteScroll`; it is declared here so that closing the panel can reset it.\nconst sentinelEl = ref<HTMLElement | null>(null)\n\nconst infiniteScroll = useInfiniteScroll({\n sentinelEl,\n canLoad: () => open.value && props.hasMore && !props.loading,\n loaded: () => allOptions.value,\n onLoadMore: () => emit('load-more'),\n})\n\nfunction closePanel() {\n if (!open.value) return\n cancelSearch()\n // A page that never arrived — a request that failed — must not leave the paging\n // frozen for good, so the lock is released here.\n infiniteScroll.reset()\n closedTerm.value = searchTerm.value\n open.value = false\n activeIndex.value = -1\n typed.value = false\n query.value = singleLabel()\n}\n\n// A field made read-only or disabled while its list is open can no longer be written, so\n// the list goes with it; `select` refuses as well, for the keystroke already on its way.\nwatch(\n () => props.readonly || resolvedDisabled.value,\n (frozen) => {\n if (frozen) closePanel()\n },\n)\n\n/**\n * Closes as soon as the focus leaves the component — the panel included, which is a\n * descendant of it even while floating above the page.\n */\nconst onFocusout = useFocusoutDismiss(rootEl, closePanel)\n\n// @a11y\n/*\n * TRAP — the focus must never leave the field, and this is what prevents it. Without\n * cancelling the press, clicking an option takes the focus off the field, the handler\n * above closes the panel BEFORE the click is turned into a selection, and choosing with\n * the mouse stops working entirely.\n *\n * It is invisible in the unit tests, where clicking moves no focus; a browser test\n * covers it.\n */\nfunction onPanelMousedown(event: MouseEvent) {\n event.preventDefault()\n}\n\n/** The reader is typing: the text becomes a search, and the panel opens. */\nfunction onInput() {\n typed.value = true\n openPanel()\n}\n\n/**\n * With a single value chosen, the label shown in the field is selected on focus, so that\n * typing replaces it rather than appending to it — and until something IS typed, the\n * whole list stays on offer.\n */\nfunction selectQuery() {\n if (!props.multiple && query.value) inputRef.value?.select()\n}\n\nfunction onFocus() {\n focused.value = true\n selectQuery()\n}\n\n/** Whether a pointer event landed on the chevron, or on the spinner standing in its place. */\nconst onChevron = (event: Event) =>\n event.target instanceof Element &&\n event.target.closest('.v-combobox-chevron, .v-combobox-spinner') !== null\n\n// @core\n/*\n * TRAP — the chevron is not focusable, so pressing it would hand the focus to the page:\n * the root's `focusout` then closes the panel, and the click that follows reopens it. A\n * click meant to close would flash the list instead. Keeping the focus in the field is\n * what lets the click below decide.\n */\nfunction onControlMousedown(event: MouseEvent) {\n if (onChevron(event)) event.preventDefault()\n}\n\n/**\n * A click anywhere on the field focuses it and opens the panel — except on the chevron of\n * an open panel, which closes it.\n */\nfunction onControlClick(event: MouseEvent) {\n if (resolvedDisabled.value) return\n inputRef.value?.focus()\n if (open.value && onChevron(event)) {\n closePanel()\n return\n }\n openPanel()\n // Selected again AFTER the click, which has just placed the caret somewhere in the\n // middle of the label.\n selectQuery()\n}\n\nfunction select(option: ComboboxOption) {\n if (option.disabled || props.readonly || resolvedDisabled.value) return\n // Remembered immediately: the option may vanish from the list — on the next search —\n // before the parent has even passed the new value back down.\n optionCache.set(option.value, option)\n // Read before the typing flag drops, which empties the term (see `closedTerm`).\n if (!props.multiple) closedTerm.value = searchTerm.value\n typed.value = false\n if (props.multiple) {\n model.value = toggleValue(selectedValues.value, option.value)\n query.value = ''\n inputRef.value?.focus()\n } else {\n model.value = option.value\n // This path does not go through the closing function, so the pending search has to\n // be cancelled here as well — otherwise the last keystroke would fire its request\n // after the panel had closed. The paging lock goes for the same reason: a page still\n // on its way when the panel shut would otherwise freeze it on the next opening.\n cancelSearch()\n infiniteScroll.reset()\n // TRAP — the label is taken from the option just chosen and NOT by reading the value\n // back. With a value bound by the parent, reading it immediately after writing still\n // returns the OLD one, and the field would show the previously selected label.\n query.value = option.label\n open.value = false\n activeIndex.value = -1\n }\n}\n\nfunction removeValue(value: ItemValue) {\n if (!props.multiple || props.readonly) return\n model.value = selectedValues.value.filter((v) => v !== value)\n inputRef.value?.focus()\n}\n\n/**\n * The clear cross was pressed. The field has already emptied the text it holds; what is\n * left to empty is the selection itself — the single value, or all the chips.\n */\nfunction onClear() {\n model.value = props.multiple ? [] : ''\n typed.value = false\n // The list may still be open (a pointer press on the cross does not close it): the\n // highlight is moved to the first option rather than dropped, or Enter would do nothing.\n activeIndex.value = open.value ? filtered.value.findIndex((o) => !o.disabled) : -1\n emit('clear')\n}\n\n// @keyboard — moves the highlight, skipping over the options that cannot be chosen and\n// wrapping round from one end of the list to the other.\nfunction move(delta: number) {\n const list = filtered.value\n if (list.length === 0) return\n // From \"nothing highlighted\" the first step lands on an END of the list: starting at -1,\n // a step back would stop on the second-to-last option.\n let i = activeIndex.value < 0 && delta < 0 ? 0 : activeIndex.value\n for (let step = 0; step < list.length; step++) {\n i = (i + delta + list.length) % list.length\n if (!list[i]?.disabled) break\n }\n activeIndex.value = i\n}\n\n// @keyboard @a11y — the whole keyboard of the pattern. The arrows move the POINTER\n// naming the current option and never the focus itself, which stays in the field\n// throughout; Backspace on an empty field takes back the last chip, the usual gesture in\n// a field holding several values.\nfunction onKeydown(event: KeyboardEvent) {\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault()\n if (open.value) move(1)\n else openPanel()\n break\n case 'ArrowUp':\n event.preventDefault()\n if (open.value) move(-1)\n else openPanel()\n break\n case 'Enter':\n if (open.value && activeIndex.value >= 0) {\n event.preventDefault()\n const option = filtered.value[activeIndex.value]\n if (option) select(option)\n }\n break\n case 'Escape':\n // Consumed only when it closes the list, so a surrounding VDialog stays open; on a\n // closed list it is left to go on and close the dialog.\n if (open.value) {\n event.preventDefault()\n closePanel()\n }\n break\n case 'Tab':\n closePanel()\n break\n case 'Backspace':\n if (props.multiple && !query.value) {\n const last = selectedValues.value.at(-1)\n if (last !== undefined) removeValue(last)\n }\n break\n }\n}\n\ndefineExpose({\n /** Moves the focus to the search field. */\n focus: (options?: FocusOptions) => inputRef.value?.focus(options),\n /** Selects what has been typed in the search field. */\n select: () => inputRef.value?.select(),\n /** The real `<input>` behind the field, for what neither of the two above covers. */\n el: computed(() => inputRef.value?.el ?? null),\n})\n</script>\n\n<template>\n <div\n ref=\"rootEl\"\n class=\"v-combobox\"\n :class=\"rootClass\"\n :style=\"[{ '--chip-height': chipScale.height }, rootStyle]\"\n :data-size=\"resolvedSize\"\n :data-compact=\"resolvedCompact ? '' : undefined\"\n :data-multiple=\"multiple ? '' : undefined\"\n :data-collapsed=\"collapsed ? '' : undefined\"\n :data-open=\"open ? '' : undefined\"\n @focusout=\"onFocusout\"\n >\n <div class=\"v-combobox-control\" @mousedown=\"onControlMousedown\" @click=\"onControlClick\">\n <!-- The two arrangements VInput offers a field holding chips: its end controls lifted\n out of the flow, always — the chevron and the cross stay put whether or not the\n input has folded away — and the chips wrapping, when there are chips at all. A\n text display keeps the field on one line and needs only the first. -->\n <VInput\n ref=\"inputRef\"\n v-model=\"query\"\n class=\"v-input-end-pinned\"\n :class=\"{ 'v-input-chips': multiple && !textDisplay }\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-autocomplete=\"list\"\n :aria-expanded=\"open\"\n :aria-controls=\"optionsId\"\n v-bind=\"fieldAttrs\"\n :label=\"label\"\n :hint=\"hint\"\n :size=\"resolvedSize\"\n :compact=\"resolvedCompact\"\n :invalid=\"invalid\"\n :disabled=\"resolvedDisabled\"\n :readonly=\"readonly\"\n :icon-start=\"iconStart\"\n :icon-start-label=\"iconStartLabel\"\n :clearable=\"clearable\"\n :clear-visible=\"clearVisible\"\n :clear-label=\"resolvedClearLabel\"\n :placeholder=\"selectedValues.length === 0 ? placeholder : undefined\"\n :aria-activedescendant=\"open && activeIndex >= 0 ? optionId(activeIndex) : undefined\"\n @input=\"onInput\"\n @keydown=\"onKeydown\"\n @focus=\"onFocus\"\n @blur=\"focused = false\"\n @clear=\"onClear\"\n >\n <template v-if=\"multiple || $slots.start\" #start>\n <span v-if=\"displayText\" class=\"v-combobox-text\">{{ displayText }}</span>\n <!-- A box of its own beside the line rather than the end of it: the labels are what\n the ellipsis cuts, and the count of what they do not show must survive it. -->\n <span v-if=\"textDisplay && overflowCount > 0\" class=\"v-combobox-overflow\">\n <slot\n name=\"overflow\"\n :count=\"overflowCount\"\n :size=\"chipScale.size\"\n :compact=\"chipScale.compact\"\n >{{ resolvedOverflowText }}</slot\n >\n </span>\n <template v-for=\"value in multiple && !textDisplay ? visibleValues : []\" :key=\"value\">\n <slot\n name=\"chip\"\n :value=\"value\"\n :option=\"optionOf(value)\"\n :label=\"labelOf(value)\"\n :remove=\"() => removeValue(value)\"\n :size=\"chipScale.size\"\n :compact=\"chipScale.compact\"\n >\n <VChip\n tone=\"accent\"\n :size=\"chipScale.size\"\n :compact=\"chipScale.compact\"\n :dismissible=\"!readonly && !resolvedDisabled\"\n :dismiss-label=\"m.common.remove(labelOf(value))\"\n :disabled=\"resolvedDisabled\"\n @dismiss=\"removeValue(value)\"\n >{{ labelOf(value) }}</VChip\n >\n </slot>\n </template>\n <!-- Not wrapped, unlike the text display's counter: a box around an inline-flex chip\n opens a line box, whose strut makes the field taller than its chips. Neutral\n and not dismissible, so it reads as a summary rather than one more value. -->\n <slot\n v-if=\"multiple && !textDisplay && overflowCount > 0\"\n name=\"overflow\"\n :count=\"overflowCount\"\n :size=\"chipScale.size\"\n :compact=\"chipScale.compact\"\n >\n <VChip\n class=\"v-combobox-overflow-chip\"\n tone=\"neutral\"\n :size=\"chipScale.size\"\n :compact=\"chipScale.compact\"\n :disabled=\"resolvedDisabled\"\n >{{ resolvedOverflowText }}</VChip\n >\n </slot>\n <slot name=\"start\" />\n </template>\n\n <template v-if=\"$slots['value-end']\" #value-end><slot name=\"value-end\" /></template>\n\n <!-- The chevron sits at the end of the field and turns as the panel opens; the\n clear cross is rendered by the field itself, to its left.\n\n While loading, the spinner takes EXACTLY the chevron's place — the field\n gives a spinner among its direct children the size of an icon — so nothing\n shifts. The field's own loading option is deliberately not used: it would\n overwrite this slot, chevron and all.\n\n The spinner is hidden from screen readers, which neutralizes the status role\n it carries: what announces the loading is the panel, and once is enough. -->\n <template #end>\n <VSpinner v-if=\"loading\" class=\"v-combobox-spinner v-input-icon-end\" aria-hidden=\"true\" />\n <VIcon\n v-else\n v-bind=\"iconProps(expandIcon)\"\n class=\"v-combobox-chevron v-input-icon-end\"\n aria-hidden=\"true\"\n />\n </template>\n </VInput>\n </div>\n\n <!-- TRAP — the panel itself carries BOTH the listbox role and the scrolling. That\n single fact is what the observer watching for the end of the list and the\n scrolling of the highlighted option both rely on: inserting any wrapper between\n them breaks the two at once. -->\n <VPopover\n :id=\"optionsId\"\n v-model:open=\"open\"\n mode=\"manual\"\n anchor=\"--combobox-anchor\"\n match-trigger\n :placement=\"placement\"\n role=\"listbox\"\n class=\"v-combobox-panel v-control\"\n :data-size=\"resolvedSize\"\n :data-compact=\"resolvedCompact ? '' : undefined\"\n :aria-multiselectable=\"multiple ? 'true' : undefined\"\n @mousedown=\"onPanelMousedown\"\n >\n <!-- Blocks and separators exist for the eye alone: the keyboard counts through the\n flat list of surviving options and therefore never encounters one. -->\n <template v-for=\"node in rows\" :key=\"node.key\">\n <VComboboxSeparator v-if=\"node.kind === 'separator'\" />\n\n <VComboboxGroup v-else-if=\"node.kind === 'group'\" :label=\"node.label\">\n <VComboboxOption\n v-for=\"entry in node.options\"\n :key=\"entry.key\"\n v-bind=\"entry.row\"\n @select=\"select(entry.option)\"\n @pointermove=\"hover(entry)\"\n >\n <slot name=\"option\" v-bind=\"entry.slot\">{{ entry.option.label }}</slot>\n </VComboboxOption>\n </VComboboxGroup>\n\n <VComboboxOption\n v-else\n v-bind=\"node.row\"\n @select=\"select(node.option)\"\n @pointermove=\"hover(node)\"\n >\n <slot name=\"option\" v-bind=\"node.slot\">{{ node.option.label }}</slot>\n </VComboboxOption>\n </template>\n\n <!-- The order matters: loading is checked BEFORE emptiness, so that a panel\n waiting for an answer never claims there is no result.\n\n Both are hidden from screen readers, and that is not an oversight. A listbox\n may contain nothing but options and blocks of options, so any other visible\n child would make the panel invalid — where an EMPTY listbox is perfectly\n acceptable. What they say is announced instead by the live region outside the\n panel, which is also the only way a screen reader would ever hear it: plain\n text sitting inside a combobox's popup is not part of what the field walks\n through. -->\n <div v-if=\"loading && filtered.length === 0\" class=\"v-combobox-state\" aria-hidden=\"true\">\n <slot name=\"loading\">\n <VSpinner :label=\"resolvedLoadingText\" />\n <span>{{ resolvedLoadingText }}</span>\n </slot>\n </div>\n <div v-else-if=\"filtered.length === 0\" class=\"v-combobox-state\" aria-hidden=\"true\">\n <slot name=\"empty\" :query=\"searchTerm\">{{ resolvedEmptyText }}</slot>\n </div>\n\n <!-- One element serves as both the marker watched for the end of the list and the\n place the next-page spinner appears. TRAP — it has to stay a SINGLE element:\n rendering the spinner conditionally in its place would destroy the marker and\n silently cancel the observation, and no further page would ever be asked\n for. -->\n <div v-if=\"hasMore\" ref=\"sentinelEl\" class=\"v-combobox-more\" aria-hidden=\"true\">\n <VSpinner v-if=\"loading\" :label=\"resolvedLoadingText\" />\n </div>\n </VPopover>\n\n <!-- The spoken counterpart of the two panel states above. It sits OUTSIDE the\n listbox, being exactly the kind of content a listbox may not contain. -->\n <span class=\"v-visually-hidden\" role=\"status\">{{ stateAnnouncement }}</span>\n </div>\n</template>\n\n<style>\n@layer vectis.components {\n .v-combobox {\n /* Confines the anchor name to this instance. It is declared on the root because that\n is the common ancestor of the field and the panel — a panel drawn above the page\n remains a descendant of it in the document. */\n anchor-scope: --combobox-anchor;\n width: 100%;\n font-family: var(--vectis-text-family);\n }\n\n .v-combobox-control {\n display: block;\n }\n\n /* The anchor is the FIELD's box and not this wrapper's, which also holds the label and\n the hint: anchored to the wrapper, the panel opens a hint's height below the field, and\n a label's height above it once there is no room below and `flip-block` turns it over.\n Against the field it covers whichever of the two it lands on, which is what a panel\n belonging to a control is supposed to do. */\n .v-combobox-control .v-input-field {\n anchor-name: --combobox-anchor;\n }\n\n /* The panel comes from VPopover, which brings the floating element, its open state, its\n anchoring, its placement and its surface. It also carries the shared size class, so\n the options and the state rows read their dimensions from it with no size table\n here. The width tied to the field is VPopover's `matchTrigger`, so what stays here\n is the one thing specific to a list: the scrolling. */\n .v-combobox-panel {\n max-block-size: var(--vectis-control-size-combobox-list-max-block);\n overflow: auto;\n }\n\n /* The chevron and the clear cross are pinned to the end of the field by VInput's\n `.v-input-end-pinned`, which also reserves their room. The chevron and the spinner take\n turns in the same place and occupy the same box — the field gives a spinner among its\n direct children the size of an icon — so swapping one for the other shifts nothing. */\n .v-combobox-chevron,\n .v-combobox-spinner {\n color: var(--vectis-color-text-muted);\n }\n\n .v-combobox-chevron {\n transition: rotate var(--vectis-duration-fast) var(--vectis-ease-default);\n }\n\n .v-combobox[data-open] .v-combobox-chevron {\n rotate: 180deg;\n }\n\n /* Folded away, the input is taken out of the flow entirely rather than merely narrowed:\n even at zero width it would still occupy a line of its own under the chips and leave\n a visible gap.\n\n It remains in the page and remains focusable — clicking the field or tabbing into it\n brings it straight back, the folded state ending as soon as it has the focus. */\n .v-combobox[data-collapsed] .v-input-control {\n position: absolute;\n width: 0;\n height: 0;\n padding: 0;\n }\n\n /* The chosen values as one line of text, cut short with an ellipsis. It shrinks before the\n search input does, the input being `flex: 1` with no floor of its own.\n\n Under the focus the two share the row, and the line is capped at half of it so that a\n long selection cannot squeeze what is being typed down to nothing. Folded, the input is\n out of the flow and the line takes the whole field. */\n .v-combobox-text {\n flex: 0 1 auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .v-combobox:not([data-collapsed]) .v-combobox-text {\n max-inline-size: 50%;\n }\n\n /* The \"+X\" after a line of text never shrinks: the line gives way instead. */\n .v-combobox-overflow {\n flex: none;\n white-space: nowrap;\n color: var(--vectis-color-text-muted);\n }\n\n /* TRAP — an unbroken line has the whole of its text as its min-content width, and that\n width travels up through the field to the root. In a grid track or a flex row sized\n `auto`, the component then widens its container to fit every label instead of cutting\n them short, and the ellipsis never shows. Chips wrap, so they carry no such minimum. */\n .v-combobox:has(.v-combobox-text) {\n min-inline-size: 0;\n }\n\n /* The rows saying \"nothing matches\" or \"loading\" are built like an option: they read\n the same inherited dimensions from the panel, and the spinner follows through the\n same block's icon context. They refuse to shrink, the panel being a bounded column\n that would otherwise squash them. */\n .v-combobox-state {\n display: flex;\n flex: none;\n align-items: center;\n gap: var(--control-gap);\n min-height: var(--control-height);\n padding: var(--vectis-space-1) var(--control-padding-inline);\n font-size: var(--control-font-size);\n color: var(--vectis-color-text-muted);\n }\n\n /* The foot of the list: the marker watched for the end, and the place the next-page\n spinner appears. It is given a real height on purpose — a box of no height at all\n makes the crossing it is watched for unreliable. */\n .v-combobox-more {\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n min-height: var(--vectis-control-height-xs);\n color: var(--vectis-color-text-muted);\n }\n\n @media (prefers-reduced-motion: reduce) {\n .v-combobox-chevron {\n transition: none;\n }\n }\n}\n</style>\n"],"mappings":""}
|