vectis-ui 0.1.0 → 0.8.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 +40 -6
- package/dist/components/VAccordion/VAccordion.css +1 -1
- package/dist/components/VAccordion/VAccordion.d.ts +9 -16
- package/dist/components/VAccordion/VAccordion.js.map +1 -1
- package/dist/components/VAccordion/VAccordion.vue_vue_type_script_setup_true_lang.js +3 -3
- package/dist/components/VAccordion/VAccordion.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VAccordion/VAccordionItem.css +1 -1
- package/dist/components/VAccordion/VAccordionItem.d.ts +33 -19
- package/dist/components/VAccordion/VAccordionItem.js.map +1 -1
- package/dist/components/VAccordion/VAccordionItem.vue_vue_type_script_setup_true_lang.js +50 -38
- package/dist/components/VAccordion/VAccordionItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VAccordion/context.d.ts +1 -8
- package/dist/components/VAccordion/context.js.map +1 -1
- package/dist/components/VAvatar/VAvatar.css +1 -1
- package/dist/components/VAvatar/VAvatar.d.ts +44 -29
- package/dist/components/VAvatar/VAvatar.js.map +1 -1
- package/dist/components/VAvatar/VAvatar.vue_vue_type_script_setup_true_lang.js +38 -35
- package/dist/components/VAvatar/VAvatar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VAvatar/VAvatarGroup.d.ts +5 -16
- package/dist/components/VAvatar/VAvatarGroup.js.map +1 -1
- package/dist/components/VAvatar/VAvatarGroup.vue_vue_type_script_setup_true_lang.js +7 -7
- package/dist/components/VAvatar/VAvatarGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VAvatar/context.d.ts +6 -10
- package/dist/components/VAvatar/context.js.map +1 -1
- package/dist/components/VBadge/VBadge.css +1 -1
- package/dist/components/VBadge/VBadge.d.ts +31 -10
- package/dist/components/VBadge/VBadge.js.map +1 -1
- package/dist/components/VBadge/VBadge.vue_vue_type_script_setup_true_lang.js +39 -24
- package/dist/components/VBadge/VBadge.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VBreadcrumb/VBreadcrumb.css +1 -1
- package/dist/components/VBreadcrumb/VBreadcrumb.d.ts +4 -17
- package/dist/components/VBreadcrumb/VBreadcrumb.js.map +1 -1
- package/dist/components/VBreadcrumb/VBreadcrumb.vue_vue_type_script_setup_true_lang.js +23 -25
- 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 +30 -10
- package/dist/components/VButton/VButton.js.map +1 -1
- package/dist/components/VButton/VButton.vue_vue_type_script_setup_true_lang.js +39 -30
- package/dist/components/VButton/VButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VButton/VButtonGroup.css +1 -1
- package/dist/components/VButton/VButtonGroup.d.ts +76 -13
- package/dist/components/VButton/VButtonGroup.js.map +1 -1
- package/dist/components/VButton/VButtonGroup.vue_vue_type_script_setup_true_lang.js +74 -8
- package/dist/components/VButton/VButtonGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VButton/context.d.ts +30 -0
- package/dist/components/VButton/context.js +6 -0
- package/dist/components/VButton/context.js.map +1 -0
- package/dist/components/VCalendar/VCalendar.css +1 -1
- package/dist/components/VCalendar/VCalendar.d.ts +50 -36
- package/dist/components/VCalendar/VCalendar.js.map +1 -1
- package/dist/components/VCalendar/VCalendar.vue_vue_type_script_setup_true_lang.js +99 -85
- 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 +5 -11
- package/dist/components/VCalendar/VCalendarEvent.js.map +1 -1
- package/dist/components/VCalendar/VCalendarEvent.vue_vue_type_script_setup_true_lang.js +7 -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 +10 -13
- package/dist/components/VCalendar/VCalendarMonth.js.map +1 -1
- package/dist/components/VCalendar/VCalendarMonth.vue_vue_type_script_setup_true_lang.js +183 -244
- 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 +15 -20
- package/dist/components/VCalendar/VCalendarTimeGrid.js.map +1 -1
- package/dist/components/VCalendar/VCalendarTimeGrid.vue_vue_type_script_setup_true_lang.js +385 -448
- 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.js.map +1 -1
- package/dist/components/VCalendar/VCalendarYear.vue_vue_type_script_setup_true_lang.js +53 -49
- package/dist/components/VCalendar/VCalendarYear.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCalendar/gesture.d.ts +158 -0
- package/dist/components/VCalendar/gesture.js +170 -0
- package/dist/components/VCalendar/gesture.js.map +1 -0
- package/dist/components/VCalendar/keyboard.d.ts +9 -3
- package/dist/components/VCalendar/keyboard.js +2 -6
- package/dist/components/VCalendar/keyboard.js.map +1 -1
- package/dist/components/VCalendar/layout.d.ts +67 -54
- package/dist/components/VCalendar/layout.js +77 -69
- package/dist/components/VCalendar/layout.js.map +1 -1
- package/dist/components/VCalendar/timeGrid.d.ts +55 -0
- package/dist/components/VCalendar/timeGrid.js +71 -0
- package/dist/components/VCalendar/timeGrid.js.map +1 -0
- package/dist/components/VCalendar/types.d.ts +41 -16
- package/dist/components/VCarousel/VCarousel.css +1 -1
- package/dist/components/VCarousel/VCarousel.d.ts +21 -41
- package/dist/components/VCarousel/VCarousel.js.map +1 -1
- package/dist/components/VCarousel/VCarousel.vue_vue_type_script_setup_true_lang.js +157 -129
- package/dist/components/VCarousel/VCarousel.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCarousel/VCarouselItem.d.ts +0 -17
- 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 +0 -12
- package/dist/components/VCarousel/context.js.map +1 -1
- package/dist/components/VCheckbox/VCheckbox.css +1 -1
- package/dist/components/VCheckbox/VCheckbox.d.ts +31 -16
- package/dist/components/VCheckbox/VCheckbox.js.map +1 -1
- package/dist/components/VCheckbox/VCheckbox.vue_vue_type_script_setup_true_lang.js +62 -29
- 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 +36 -26
- package/dist/components/VChip/VChip.js.map +1 -1
- package/dist/components/VChip/VChip.vue_vue_type_script_setup_true_lang.js +57 -48
- 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 +127 -31
- package/dist/components/VCombobox/VCombobox.js.map +1 -1
- package/dist/components/VCombobox/VCombobox.vue_vue_type_script_setup_true_lang.js +336 -247
- 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.d.ts +0 -9
- 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/VComboboxOption.css +1 -1
- package/dist/components/VCombobox/VComboboxOption.d.ts +0 -15
- package/dist/components/VCombobox/VComboboxOption.js.map +1 -1
- package/dist/components/VCombobox/VComboboxOption.vue_vue_type_script_setup_true_lang.js +4 -4
- package/dist/components/VCombobox/VComboboxOption.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCombobox/VComboboxSeparator.js.map +1 -1
- package/dist/components/VCombobox/VComboboxSeparator.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCombobox/infiniteScroll.js.map +1 -1
- package/dist/components/VDataTable/VDataTable.css +1 -1
- package/dist/components/VDataTable/VDataTable.d.ts +50 -28
- package/dist/components/VDataTable/VDataTable.js.map +1 -1
- package/dist/components/VDataTable/VDataTable.vue_vue_type_script_setup_true_lang.js +183 -194
- 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 +90 -42
- package/dist/components/VDateInput/VDateInput.js.map +1 -1
- package/dist/components/VDateInput/VDateInput.vue_vue_type_script_setup_true_lang.js +159 -191
- package/dist/components/VDateInput/VDateInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VDatePicker/VDatePicker.css +1 -1
- package/dist/components/VDatePicker/VDatePicker.d.ts +61 -30
- package/dist/components/VDatePicker/VDatePicker.js.map +1 -1
- package/dist/components/VDatePicker/VDatePicker.vue_vue_type_script_setup_true_lang.js +243 -221
- package/dist/components/VDatePicker/VDatePicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VDialog/VDialog.css +1 -1
- package/dist/components/VDialog/VDialog.d.ts +45 -33
- package/dist/components/VDialog/VDialog.js.map +1 -1
- package/dist/components/VDialog/VDialog.vue_vue_type_script_setup_true_lang.js +65 -64
- package/dist/components/VDialog/VDialog.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VDialog/VDialogAlert.d.ts +24 -20
- package/dist/components/VDialog/VDialogAlert.js.map +1 -1
- package/dist/components/VDialog/VDialogAlert.vue_vue_type_script_setup_true_lang.js +36 -25
- package/dist/components/VDialog/VDialogAlert.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VFileInput/VFileInput.css +1 -1
- package/dist/components/VFileInput/VFileInput.d.ts +78 -26
- package/dist/components/VFileInput/VFileInput.js.map +1 -1
- package/dist/components/VFileInput/VFileInput.vue_vue_type_script_setup_true_lang.js +144 -132
- package/dist/components/VFileInput/VFileInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VFilePicker/VFilePicker.css +1 -1
- package/dist/components/VFilePicker/VFilePicker.d.ts +47 -30
- package/dist/components/VFilePicker/VFilePicker.js.map +1 -1
- package/dist/components/VFilePicker/VFilePicker.vue_vue_type_script_setup_true_lang.js +166 -163
- package/dist/components/VFilePicker/VFilePicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VFilePicker/fileKind.d.ts +2 -27
- package/dist/components/VFilePicker/fileKind.js +9 -8
- package/dist/components/VFilePicker/fileKind.js.map +1 -1
- package/dist/components/VHotkeys/VHotkeys.css +1 -1
- package/dist/components/VHotkeys/VHotkeys.d.ts +8 -30
- package/dist/components/VHotkeys/VHotkeys.js.map +1 -1
- package/dist/components/VHotkeys/VHotkeys.vue_vue_type_script_setup_true_lang.js +4 -4
- package/dist/components/VHotkeys/VHotkeys.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VHotkeys/platform.js.map +1 -1
- package/dist/components/VIcon/VIcon.css +1 -1
- package/dist/components/VIcon/VIcon.d.ts +15 -6
- package/dist/components/VIcon/VIcon.js.map +1 -1
- package/dist/components/VIcon/VIcon.vue_vue_type_script_setup_true_lang.js +45 -37
- package/dist/components/VIcon/VIcon.vue_vue_type_script_setup_true_lang.js.map +1 -1
- 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.map +1 -1
- package/dist/components/VIcon/types.d.ts +12 -12
- package/dist/components/VIconButton/VIconButton.css +1 -1
- package/dist/components/VIconButton/VIconButton.d.ts +28 -11
- package/dist/components/VIconButton/VIconButton.js.map +1 -1
- package/dist/components/VIconButton/VIconButton.vue_vue_type_script_setup_true_lang.js +26 -20
- package/dist/components/VIconButton/VIconButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VInput/VInput.css +1 -1
- package/dist/components/VInput/VInput.d.ts +26 -7
- package/dist/components/VInput/VInput.js.map +1 -1
- package/dist/components/VInput/VInput.vue_vue_type_script_setup_true_lang.js +86 -75
- package/dist/components/VInput/VInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VInput/VInputGroup.css +2 -0
- package/dist/components/VInput/VInputGroup.d.ts +47 -0
- package/dist/components/VInput/VInputGroup.js +9 -0
- package/dist/components/VInput/VInputGroup.js.map +1 -0
- package/dist/components/VInput/VInputGroup.vue_vue_type_script_setup_true_lang.js +80 -0
- package/dist/components/VInput/VInputGroup.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/VInput/context.d.ts +11 -0
- package/dist/components/VInput/context.js +6 -0
- package/dist/components/VInput/context.js.map +1 -0
- package/dist/components/VInputOTP/VInputOTP.css +1 -1
- package/dist/components/VInputOTP/VInputOTP.d.ts +37 -22
- package/dist/components/VInputOTP/VInputOTP.js.map +1 -1
- package/dist/components/VInputOTP/VInputOTP.vue_vue_type_script_setup_true_lang.js +98 -61
- package/dist/components/VInputOTP/VInputOTP.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VMenu/VMenu.d.ts +23 -30
- package/dist/components/VMenu/VMenu.js.map +1 -1
- package/dist/components/VMenu/VMenu.vue_vue_type_script_setup_true_lang.js +31 -27
- 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.d.ts +12 -8
- package/dist/components/VMenu/VMenuGroup.js.map +1 -1
- package/dist/components/VMenu/VMenuGroup.vue_vue_type_script_setup_true_lang.js +11 -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 +11 -19
- package/dist/components/VMenu/VMenuItem.js.map +1 -1
- package/dist/components/VMenu/VMenuItem.vue_vue_type_script_setup_true_lang.js +65 -57
- package/dist/components/VMenu/VMenuItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VMenu/VMenuPanel.d.ts +14 -30
- package/dist/components/VMenu/VMenuPanel.js.map +1 -1
- package/dist/components/VMenu/VMenuPanel.vue_vue_type_script_setup_true_lang.js +43 -44
- package/dist/components/VMenu/VMenuPanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VMenu/context.d.ts +2 -6
- package/dist/components/VMenu/context.js.map +1 -1
- package/dist/components/VPagination/VPagination.css +1 -1
- package/dist/components/VPagination/VPagination.d.ts +60 -22
- package/dist/components/VPagination/VPagination.js.map +1 -1
- package/dist/components/VPagination/VPagination.vue_vue_type_script_setup_true_lang.js +113 -161
- 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 +26 -7
- package/dist/components/VPopover/VPopover.js.map +1 -1
- package/dist/components/VPopover/VPopover.vue_vue_type_script_setup_true_lang.js +43 -37
- 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 +15 -4
- package/dist/components/VProgressCircular/VProgressCircular.js.map +1 -1
- package/dist/components/VProgressCircular/VProgressCircular.vue_vue_type_script_setup_true_lang.js +32 -30
- 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 +23 -8
- package/dist/components/VProgressLinear/VProgressLinear.js.map +1 -1
- package/dist/components/VProgressLinear/VProgressLinear.vue_vue_type_script_setup_true_lang.js +34 -32
- 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.d.ts +36 -18
- package/dist/components/VRadio/VRadio.js.map +1 -1
- package/dist/components/VRadio/VRadio.vue_vue_type_script_setup_true_lang.js +55 -26
- package/dist/components/VRadio/VRadio.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSeparator/VSeparator.d.ts +4 -2
- 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.css +1 -1
- package/dist/components/VSideNavigation/VSideNavigation.d.ts +5 -19
- package/dist/components/VSideNavigation/VSideNavigation.js.map +1 -1
- package/dist/components/VSideNavigation/VSideNavigation.vue_vue_type_script_setup_true_lang.js +5 -5
- 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.d.ts +9 -17
- package/dist/components/VSideNavigation/VSideNavigationGroup.js.map +1 -1
- package/dist/components/VSideNavigation/VSideNavigationGroup.vue_vue_type_script_setup_true_lang.js +2 -2
- 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 +22 -30
- package/dist/components/VSideNavigation/VSideNavigationItem.js.map +1 -1
- package/dist/components/VSideNavigation/VSideNavigationItem.vue_vue_type_script_setup_true_lang.js +77 -87
- package/dist/components/VSideNavigation/VSideNavigationItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSideNavigation/context.d.ts +0 -14
- package/dist/components/VSideNavigation/context.js.map +1 -1
- package/dist/components/VSkeletonLoader/VSkeletonLoader.css +1 -1
- package/dist/components/VSkeletonLoader/VSkeletonLoader.d.ts +9 -9
- package/dist/components/VSkeletonLoader/VSkeletonLoader.js.map +1 -1
- 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 +52 -27
- package/dist/components/VSlider/VSlider.js.map +1 -1
- package/dist/components/VSlider/VSlider.vue_vue_type_script_setup_true_lang.js +202 -118
- 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 +0 -23
- package/dist/components/VSnackbar/VSnackbar.js.map +1 -1
- package/dist/components/VSnackbar/VSnackbar.vue_vue_type_script_setup_true_lang.js +38 -38
- package/dist/components/VSnackbar/VSnackbar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSnackbar/state.d.ts +0 -27
- package/dist/components/VSnackbar/state.js.map +1 -1
- package/dist/components/VSpinner/VSpinner.css +1 -1
- package/dist/components/VSpinner/VSpinner.d.ts +6 -6
- package/dist/components/VSpinner/VSpinner.js.map +1 -1
- package/dist/components/VSpinner/VSpinner.vue_vue_type_script_setup_true_lang.js +10 -9
- 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 +35 -13
- package/dist/components/VSwitch/VSwitch.js.map +1 -1
- package/dist/components/VSwitch/VSwitch.vue_vue_type_script_setup_true_lang.js +62 -21
- 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 +12 -12
- package/dist/components/VTabs/VTab.js.map +1 -1
- package/dist/components/VTabs/VTab.vue_vue_type_script_setup_true_lang.js +36 -24
- package/dist/components/VTabs/VTab.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTabs/VTabPanel.d.ts +2 -10
- package/dist/components/VTabs/VTabPanel.js.map +1 -1
- package/dist/components/VTabs/VTabPanel.vue_vue_type_script_setup_true_lang.js +4 -4
- package/dist/components/VTabs/VTabPanel.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 +27 -18
- package/dist/components/VTabs/VTabs.js.map +1 -1
- package/dist/components/VTabs/VTabs.vue_vue_type_script_setup_true_lang.js +92 -81
- package/dist/components/VTabs/VTabs.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTabs/context.d.ts +9 -19
- package/dist/components/VTabs/context.js +1 -1
- package/dist/components/VTabs/context.js.map +1 -1
- package/dist/components/VTextarea/VTextarea.css +1 -1
- package/dist/components/VTextarea/VTextarea.d.ts +34 -6
- package/dist/components/VTextarea/VTextarea.js.map +1 -1
- package/dist/components/VTextarea/VTextarea.vue_vue_type_script_setup_true_lang.js +91 -74
- 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 +123 -33
- package/dist/components/VTimeInput/VTimeInput.js.map +1 -1
- package/dist/components/VTimeInput/VTimeInput.vue_vue_type_script_setup_true_lang.js +294 -291
- package/dist/components/VTimeInput/VTimeInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTimeInput/search.d.ts +24 -0
- package/dist/components/VTimeInput/search.js +22 -0
- package/dist/components/VTimeInput/search.js.map +1 -0
- package/dist/components/VTimePicker/VTimePicker.css +1 -1
- package/dist/components/VTimePicker/VTimePicker.d.ts +51 -30
- package/dist/components/VTimePicker/VTimePicker.js.map +1 -1
- package/dist/components/VTimePicker/VTimePicker.vue_vue_type_script_setup_true_lang.js +216 -151
- package/dist/components/VTimePicker/VTimePicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTimePicker/limits.d.ts +88 -0
- package/dist/components/VTimePicker/limits.js +70 -0
- package/dist/components/VTimePicker/limits.js.map +1 -0
- package/dist/components/VToast/VToast.css +1 -1
- package/dist/components/VToast/VToast.d.ts +0 -10
- package/dist/components/VToast/VToast.js.map +1 -1
- package/dist/components/VToast/VToast.vue_vue_type_script_setup_true_lang.js +10 -10
- package/dist/components/VToast/VToast.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VToast/VToaster.css +1 -1
- package/dist/components/VToast/VToaster.d.ts +0 -17
- package/dist/components/VToast/VToaster.js.map +1 -1
- package/dist/components/VToast/VToaster.vue_vue_type_script_setup_true_lang.js +29 -28
- package/dist/components/VToast/VToaster.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VToast/state.d.ts +10 -19
- package/dist/components/VToast/state.js +1 -1
- package/dist/components/VToast/state.js.map +1 -1
- package/dist/components/VToggle/VToggle.css +1 -1
- package/dist/components/VToggle/VToggle.d.ts +56 -11
- package/dist/components/VToggle/VToggle.js.map +1 -1
- package/dist/components/VToggle/VToggle.vue_vue_type_script_setup_true_lang.js +80 -46
- package/dist/components/VToggle/VToggle.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VToggle/VToggleItem.d.ts +16 -2
- package/dist/components/VToggle/VToggleItem.js +0 -2
- package/dist/components/VToggle/VToggleItem.js.map +1 -1
- package/dist/components/VToggle/VToggleItem.vue_vue_type_script_setup_true_lang.js +23 -15
- package/dist/components/VToggle/VToggleItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VToggle/context.d.ts +4 -24
- package/dist/components/VToggle/context.js.map +1 -1
- package/dist/components/VTooltip/VTooltip.css +1 -1
- package/dist/components/VTooltip/VTooltip.d.ts +9 -33
- package/dist/components/VTooltip/VTooltip.js.map +1 -1
- package/dist/components/VTooltip/VTooltip.vue_vue_type_script_setup_true_lang.js +28 -24
- package/dist/components/VTooltip/VTooltip.vue_vue_type_script_setup_true_lang.js.map +1 -1
- 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.d.ts +0 -17
- package/dist/composables/useAriaLabel.js.map +1 -1
- package/dist/composables/useClearable.d.ts +42 -0
- package/dist/composables/useClearable.js +19 -0
- package/dist/composables/useClearable.js.map +1 -0
- package/dist/composables/useControlShape.d.ts +22 -0
- package/dist/composables/useControlShape.js +13 -0
- package/dist/composables/useControlShape.js.map +1 -0
- package/dist/composables/useDetailsOpen.d.ts +22 -0
- package/dist/composables/useDetailsOpen.js +21 -0
- package/dist/composables/useDetailsOpen.js.map +1 -0
- package/dist/composables/useFieldIds.d.ts +0 -15
- package/dist/composables/useFieldIds.js +8 -7
- package/dist/composables/useFieldIds.js.map +1 -1
- package/dist/composables/useFieldPanel.d.ts +21 -18
- package/dist/composables/useFieldPanel.js +43 -23
- package/dist/composables/useFieldPanel.js.map +1 -1
- package/dist/composables/useFileDrop.d.ts +0 -22
- package/dist/composables/useFileDrop.js.map +1 -1
- package/dist/composables/useFileField.d.ts +45 -17
- package/dist/composables/useFileField.js +40 -20
- package/dist/composables/useFileField.js.map +1 -1
- package/dist/composables/useFocusoutDismiss.d.ts +0 -15
- package/dist/composables/useFocusoutDismiss.js.map +1 -1
- package/dist/composables/useIconClickHandlers.d.ts +29 -14
- package/dist/composables/useIconClickHandlers.js +15 -5
- package/dist/composables/useIconClickHandlers.js.map +1 -1
- package/dist/composables/useInertLink.d.ts +20 -0
- package/dist/composables/useInertLink.js +23 -0
- package/dist/composables/useInertLink.js.map +1 -0
- package/dist/composables/useMaskedField.d.ts +33 -10
- package/dist/composables/useMaskedField.js +45 -1
- package/dist/composables/useMaskedField.js.map +1 -1
- package/dist/composables/usePopover.d.ts +15 -1
- package/dist/composables/usePopover.js +23 -8
- package/dist/composables/usePopover.js.map +1 -1
- package/dist/composables/useProgressValue.d.ts +5 -8
- package/dist/composables/useProgressValue.js +6 -3
- package/dist/composables/useProgressValue.js.map +1 -1
- package/dist/composables/useRootAttrs.d.ts +12 -19
- package/dist/composables/useRootAttrs.js.map +1 -1
- package/dist/composables/useTimer.d.ts +8 -10
- package/dist/composables/useTimer.js.map +1 -1
- package/dist/i18n/en.d.ts +2 -10
- package/dist/i18n/en.js +18 -19
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/fr.d.ts +2 -18
- package/dist/i18n/fr.js +18 -19
- package/dist/i18n/fr.js.map +1 -1
- package/dist/i18n/state.d.ts +44 -47
- package/dist/i18n/state.js +20 -17
- package/dist/i18n/state.js.map +1 -1
- package/dist/i18n/types.d.ts +53 -44
- package/dist/icons.d.ts +3 -3
- package/dist/index.d.ts +43 -17
- package/dist/index.js +45 -44
- package/dist/styles.css +1 -1
- package/dist/tokens/css.js.map +1 -1
- package/dist/tokens/index.d.ts +5 -1
- package/dist/tokens/primitives.js.map +1 -1
- package/dist/tokens/semantic.d.ts +5 -1
- package/dist/tokens/semantic.js +6 -2
- package/dist/tokens/semantic.js.map +1 -1
- package/dist/tokens/themes/dark.js.map +1 -1
- package/dist/tokens/types.d.ts +7 -15
- package/dist/tokens/types.js.map +1 -1
- package/dist/tokens.json +25 -5
- package/dist/types.d.ts +24 -0
- package/dist/utils/array.d.ts +3 -6
- package/dist/utils/array.js.map +1 -1
- package/dist/utils/arrowNav.d.ts +17 -17
- package/dist/utils/arrowNav.js +5 -3
- package/dist/utils/arrowNav.js.map +1 -1
- package/dist/utils/chip.d.ts +11 -15
- package/dist/utils/chip.js.map +1 -1
- package/dist/utils/css.d.ts +22 -11
- package/dist/utils/css.js +5 -2
- package/dist/utils/css.js.map +1 -1
- package/dist/utils/date.d.ts +42 -19
- package/dist/utils/date.js +97 -98
- package/dist/utils/date.js.map +1 -1
- package/dist/utils/direction.d.ts +6 -12
- package/dist/utils/direction.js.map +1 -1
- package/dist/utils/env.d.ts +5 -6
- package/dist/utils/file.d.ts +46 -58
- package/dist/utils/file.js +43 -36
- package/dist/utils/file.js.map +1 -1
- package/dist/utils/focus.d.ts +8 -17
- package/dist/utils/focus.js.map +1 -1
- package/dist/utils/hostWarns.d.ts +12 -0
- package/dist/utils/hostWarns.js +6 -0
- package/dist/utils/hostWarns.js.map +1 -0
- package/dist/utils/ids.d.ts +10 -0
- package/dist/utils/ids.js +8 -0
- package/dist/utils/ids.js.map +1 -0
- package/dist/utils/matcher.d.ts +5 -9
- package/dist/utils/matcher.js.map +1 -1
- package/dist/utils/memo.d.ts +12 -0
- package/dist/utils/memo.js +9 -0
- package/dist/utils/memo.js.map +1 -0
- package/dist/utils/number.d.ts +3 -4
- package/dist/utils/number.js.map +1 -1
- package/dist/utils/text.d.ts +20 -9
- package/dist/utils/text.js +17 -3
- package/dist/utils/text.js.map +1 -1
- package/dist/utils/time.d.ts +53 -61
- package/dist/utils/time.js +49 -45
- package/dist/utils/time.js.map +1 -1
- package/dist/utils/vnode.d.ts +8 -15
- package/dist/utils/vnode.js.map +1 -1
- package/package.json +6 -6
- package/dist/components/VToggle/VToggleItem.css +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VChip.vue_vue_type_script_setup_true_lang.js","names":["$attrs","$emit"],"sources":["../../../src/components/VChip/VChip.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, useAttrs, useSlots } from 'vue'\nimport type { StyleValue } from 'vue'\n\nimport VIcon from '../VIcon/VIcon.vue'\nimport { iconProps } from '../VIcon/iconProps'\nimport { check as checkIcon } from '../VIcon/icons/check'\nimport { close as closeIcon } from '../VIcon/icons/close'\nimport type { IconSource } from '../VIcon/types'\nimport { useMessages } from '../../i18n/state'\n\n// @core\n/**\n * A chip: a small labelled pill standing for a value — a filter in force, a tag, a\n * file chosen, a person picked in a field.\n *\n * What it renders follows what it is asked to DO, and each shape is the native element\n * for it, so focus, keyboard and disabling come free: a chip that can be selected is a\n * button reporting whether it is pressed, one that leads somewhere is a link, one that\n * merely reacts to clicks is a button, and one that does none of those is plain text\n * with no hover at all.\n *\n * A chip that can be removed carries a SECOND button, beside the first and never\n * inside it: a button within a button is invalid HTML and unreachable by keyboard.\n *\n * The only JavaScript makes a disabled link inert — the platform having no `disabled`\n * for links — and splits the attributes the consumer passes between the pill and the\n * element that actually acts.\n */\ninterface ChipProps {\n /**\n * How strongly the chip is painted: a tinted background, the full colour, or a\n * border alone.\n */\n variant?: 'soft' | 'solid' | 'outline'\n /** What the chip means, expressed as a colour. */\n tone?: 'neutral' | 'accent' | 'danger' | 'success' | 'warning'\n /**\n * A colour of your own (hex, CSS name or `oklch()`), which REPLACES the tone. Every\n * shade it needs — the tinted background, the text, the hover — is derived from that\n * one colour, so it follows the light and the dark theme with nothing to rebuild.\n * Only the contrast of the text on a fully coloured chip is yours to check.\n */\n color?: string\n /** The silhouette: softly rounded corners, or a full pill. */\n shape?: 'chip' | 'pill'\n /** The height of the chip. */\n size?: 'xs' | 'sm'\n /** Takes 4px off the height, leaving the padding, the text and the icons as they are. */\n compact?: boolean\n /** Makes the chip a button that reacts to clicks, without holding a state. */\n clickable?: boolean\n /**\n * Where the chip leads, which makes it a link. A disabled link is made inert by\n * hand.\n */\n href?: string\n /**\n * Makes the chip something that stays chosen, bound to `v-model:selected`. It wins\n * over `href` and `clickable`.\n */\n selectable?: boolean\n /**\n * Shows a tick before the label while the chip is selected. It REPLACES whatever\n * start icon was given, so the two are never shown together.\n */\n check?: boolean\n /** An icon before the label. The `#start` slot replaces it. */\n iconStart?: IconSource\n /** An icon after the label. The `#end` slot replaces it. */\n iconEnd?: IconSource\n /**\n * Adds a button that asks for the chip to be removed. It only EMITS that request:\n * actually taking the chip away is the consumer's decision.\n */\n dismissible?: boolean\n /** The icon of that removal button. */\n dismissIcon?: IconSource\n /**\n * What the removal button does, in words. It falls back to the design system\n * dictionary.\n */\n dismissLabel?: string\n /** Makes the chip unusable, greyed out through the colour tokens. */\n disabled?: boolean\n}\n\nconst props = withDefaults(defineProps<ChipProps>(), {\n variant: 'soft',\n tone: 'neutral',\n color: undefined,\n shape: 'chip',\n size: 'xs',\n compact: false,\n clickable: false,\n href: undefined,\n selectable: false,\n check: false,\n iconStart: undefined,\n iconEnd: undefined,\n dismissible: false,\n dismissIcon: () => closeIcon,\n dismissLabel: undefined,\n disabled: false,\n})\n\nconst m = useMessages()\nconst resolvedDismissLabel = computed(() => props.dismissLabel ?? m.value.common.dismiss)\n\nconst selected = defineModel<boolean>('selected', { default: false })\n\ndefineEmits<{\n /** The removal button was pressed. The chip is still there: removing it is up to you. */\n dismiss: []\n}>()\n\ndefineSlots<{\n /** The label. It may be left out entirely, which gives a chip made of icons alone. */\n default?(): unknown\n /** Content before the label, which takes the place of `iconStart`. */\n start?(): unknown\n /** Content after the label, which takes the place of `iconEnd`. */\n end?(): unknown\n}>()\n\ndefineOptions({ inheritAttrs: false })\n\nconst attrs = useAttrs()\n\n/* What the chip does, in order of precedence: staying selected wins over leading\n somewhere, which wins over merely reacting to clicks; asked for none of them, it is\n plain text. */\nconst isLink = computed(() => !props.selectable && props.href !== undefined)\nconst actionTag = computed(() =>\n props.selectable ? 'button' : isLink.value ? 'a' : props.clickable ? 'button' : 'span',\n)\nconst isInertLink = computed(() => isLink.value && props.disabled)\n\nconst rootStyle = computed<StyleValue>(() => [\n props.color !== undefined ? { '--custom-color': props.color } : undefined,\n attrs.style as StyleValue,\n])\nconst actionAttrs = computed(() => {\n const rest = Object.fromEntries(\n Object.entries(attrs).filter(([key]) => key !== 'class' && key !== 'style'),\n )\n if (isInertLink.value) delete rest.onClick\n return rest\n})\n\nconst showCheck = computed(() => props.check && props.selectable && selected.value)\n\n/* An icon and no label at all: the chip becomes a square, as wide as it is tall. */\nconst slots = useSlots()\nconst iconOnly = computed(\n () => !slots.default && !!(slots.start || slots.end || props.iconStart || props.iconEnd),\n)\n</script>\n\n<template>\n <span\n class=\"v-chip v-control v-tone\"\n :class=\"$attrs.class\"\n :style=\"rootStyle\"\n :data-variant=\"variant\"\n :data-tone=\"tone\"\n :data-custom=\"color !== undefined ? '' : undefined\"\n :data-shape=\"shape\"\n :data-size=\"size\"\n :data-compact=\"compact ? '' : undefined\"\n :data-selected=\"selectable && selected ? '' : undefined\"\n :data-disabled=\"disabled ? '' : undefined\"\n :data-icon-only=\"iconOnly ? '' : undefined\"\n >\n <component\n :is=\"actionTag\"\n v-bind=\"actionAttrs\"\n class=\"v-chip-action\"\n :type=\"actionTag === 'button' ? 'button' : undefined\"\n :href=\"isLink && !disabled ? href : undefined\"\n :disabled=\"actionTag === 'button' ? disabled : undefined\"\n :aria-disabled=\"isInertLink ? 'true' : undefined\"\n :aria-pressed=\"selectable ? selected : undefined\"\n @click=\"selectable && !disabled && (selected = !selected)\"\n >\n <VIcon v-if=\"showCheck\" :name=\"checkIcon\" />\n <slot v-else name=\"start\">\n <VIcon v-if=\"iconStart\" v-bind=\"iconProps(iconStart)\" />\n </slot>\n <slot />\n <slot name=\"end\">\n <VIcon v-if=\"iconEnd\" v-bind=\"iconProps(iconEnd)\" />\n </slot>\n </component>\n <button\n v-if=\"dismissible\"\n type=\"button\"\n class=\"v-chip-remove\"\n :aria-label=\"resolvedDismissLabel\"\n :disabled=\"disabled\"\n @click=\"$emit('dismiss')\"\n >\n <VIcon v-bind=\"iconProps(dismissIcon)\" />\n </button>\n </span>\n</template>\n\n<style>\n@layer vectis.components {\n /* The height comes from the shared size class set on this element. The scale itself\n holds five steps; the component's type restricts it to the two smallest, a chip\n larger than that being a button. */\n .v-chip {\n display: inline-flex;\n align-items: center;\n height: var(--control-height);\n border: 1px solid transparent;\n border-radius: var(--vectis-radius-interactive);\n font-family: var(--vectis-text-family);\n font-size: var(--control-font-size);\n font-weight: var(--vectis-text-control-weight);\n line-height: var(--vectis-text-control-leading);\n transition:\n background-color var(--vectis-duration-fast) var(--vectis-ease-default),\n border-color var(--vectis-duration-fast) var(--vectis-ease-default),\n color var(--vectis-duration-fast) var(--vectis-ease-default);\n }\n\n .v-chip[data-shape='pill'] {\n border-radius: var(--vectis-radius-pill);\n }\n\n /* The tone table itself lives in styles/tones.css, in a layer below the components.\n All five tones are taken exactly as they come; the only values redefined here are\n those of a custom colour, and they win over the shared table by LAYER rather than\n by order, so no bundling can change the outcome. */\n\n /* A custom colour replaces the tone entirely. Every shade it needs is derived from\n that one colour mixed with the theme's own surface and text, so the same value\n produces a legible chip in the light theme and in the dark one, with nothing to\n rebuild. */\n .v-chip[data-custom] {\n --tone-bg-solid: var(--custom-color);\n --tone-bg-solid-hover: color-mix(in oklab, var(--custom-color), var(--vectis-color-text) 8%);\n --tone-bg-solid-active: color-mix(in oklab, var(--custom-color), var(--vectis-color-text) 14%);\n /* Fixed white, whatever the colour: on a fully coloured chip the contrast of the\n text is the consumer's to check, as it is in VBadge. */\n --tone-text-solid: var(--vectis-color-text-on-accent);\n --tone-text-tinted: color-mix(in oklab, var(--custom-color), var(--vectis-color-text) 30%);\n --tone-bg-soft: color-mix(in oklab, var(--custom-color), var(--vectis-color-surface) 85%);\n --tone-border-soft: color-mix(in oklab, var(--custom-color), var(--vectis-color-surface) 60%);\n }\n\n .v-chip[data-variant='soft'] {\n background: var(--tone-bg-soft);\n color: var(--tone-text-tinted);\n }\n\n .v-chip[data-variant='solid'] {\n background: var(--tone-bg-solid);\n color: var(--tone-text-solid);\n }\n\n .v-chip[data-variant='outline'] {\n background: transparent;\n color: var(--tone-text-tinted);\n border-color: var(--tone-border-soft);\n }\n\n /* A selected chip is painted in the full colour of its CURRENT tone, whichever\n variant it was given. The block sits after the variants at equal specificity, so\n it is the order that lets it win. */\n .v-chip[data-selected] {\n background: var(--tone-bg-solid);\n color: var(--tone-text-solid);\n border-color: transparent;\n }\n\n /* Hovering and pressing are conditioned on the ACTION being a real control, which\n buys two things at once: a chip that merely displays a value never lights up, and\n hovering the removal button does not repaint the whole chip as though it were\n about to be activated. */\n .v-chip[data-variant='soft']:not([data-disabled], [data-selected]):has(\n :is(button, a).v-chip-action:hover\n ) {\n background: color-mix(in oklab, var(--tone-bg-soft), var(--tone-text-tinted) 8%);\n }\n\n .v-chip[data-variant='soft']:not([data-disabled], [data-selected]):has(\n :is(button, a).v-chip-action:active\n ) {\n background: color-mix(in oklab, var(--tone-bg-soft), var(--tone-text-tinted) 14%);\n }\n\n .v-chip[data-variant='outline']:not([data-disabled], [data-selected]):has(\n :is(button, a).v-chip-action:hover\n ) {\n background: var(--tone-bg-soft);\n }\n\n .v-chip[data-variant='outline']:not([data-disabled], [data-selected]):has(\n :is(button, a).v-chip-action:active\n ) {\n background: color-mix(in oklab, var(--tone-bg-soft), var(--tone-text-tinted) 8%);\n }\n\n .v-chip[data-variant='solid']:not([data-disabled]):has(:is(button, a).v-chip-action:hover),\n .v-chip[data-selected]:not([data-disabled]):has(:is(button, a).v-chip-action:hover) {\n background: var(--tone-bg-solid-hover);\n }\n\n .v-chip[data-variant='solid']:not([data-disabled]):has(:is(button, a).v-chip-action:active),\n .v-chip[data-selected]:not([data-disabled]):has(:is(button, a).v-chip-action:active) {\n background: var(--tone-bg-solid-active);\n }\n\n .v-chip-action {\n display: inline-flex;\n align-items: center;\n gap: var(--control-gap);\n height: 100%;\n padding-block: 0;\n padding-inline: var(--control-padding-inline);\n border: none;\n background: transparent;\n color: inherit;\n font: inherit;\n border-radius: inherit;\n text-decoration: none;\n cursor: default;\n }\n\n /* With an icon and no label the action becomes square, its width taken from its own\n height through the ratio rather than from a new measurement to keep in step. */\n .v-chip[data-icon-only] .v-chip-action {\n aspect-ratio: 1;\n justify-content: center;\n padding-inline: 0;\n }\n\n :is(button, a).v-chip-action {\n cursor: pointer;\n }\n\n :is(button, a).v-chip-action:focus-visible {\n outline: var(--vectis-focus-ring-width) solid var(--vectis-focus-ring-color);\n outline-offset: var(--vectis-focus-ring-offset);\n }\n\n /* The removal button carries no background of its own, not even on hover — the same\n treatment as a field's inner buttons — and the cursor is what signals it can be\n used.\n\n Its icon takes the chip's colour AT FULL strength. Dimming it, as one would\n instinctively do for a secondary control, took the cross down to 3.9:1 on a tinted\n chip and 2.8:1 on a solid one. That matters because the cross is drawn from the\n icon font here, and a glyph from a font is real text, to which the contrast rule\n applies. */\n .v-chip-remove {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--control-action-size);\n height: var(--control-action-size);\n margin-inline: calc(var(--vectis-space-1) * -1) var(--vectis-space-1);\n padding: 0;\n border: none;\n background: transparent;\n color: inherit;\n border-radius: var(--vectis-radius-full);\n cursor: pointer;\n flex: none;\n }\n\n .v-chip-remove:focus-visible {\n outline: var(--vectis-focus-ring-width) solid var(--vectis-focus-ring-color);\n outline-offset: calc(var(--vectis-focus-ring-offset) * -1);\n }\n\n /* A disabled chip greys out through the colour tokens, which is what makes it follow\n the dark theme without a rule of its own. */\n .v-chip[data-disabled] {\n background: var(--vectis-color-surface-muted);\n color: var(--vectis-color-text-subtle);\n border-color: transparent;\n }\n\n .v-chip[data-disabled][data-variant='outline'] {\n background: transparent;\n border-color: var(--vectis-color-border);\n }\n\n .v-chip[data-disabled] :is(:is(button, a).v-chip-action, .v-chip-remove) {\n cursor: not-allowed;\n }\n\n .v-chip[data-disabled] .v-chip-remove {\n color: inherit;\n }\n\n @media (prefers-reduced-motion: reduce) {\n .v-chip,\n .v-chip-remove {\n transition: none;\n }\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuFA,IAAM,IAAQ,GAmBR,IAAI,EAAY,GAChB,IAAuB,QAAe,EAAM,gBAAgB,EAAE,MAAM,OAAO,OAAO,GAElF,IAAW,EAAoB,GAAC,UAA8B,GAkB9D,IAAQ,EAAS,GAKjB,IAAS,QAAe,CAAC,EAAM,cAAc,EAAM,SAAS,KAAA,CAAS,GACrE,IAAY,QAChB,EAAM,aAAa,WAAW,EAAO,QAAQ,MAAM,EAAM,YAAY,WAAW,MAClF,GACM,IAAc,QAAe,EAAO,SAAS,EAAM,QAAQ,GAE3D,IAAY,QAA2B,CAC3C,EAAM,UAAU,KAAA,IAAgD,KAAA,IAApC,EAAE,kBAAkB,EAAM,MAAM,GAC5D,EAAM,KACR,CAAC,GACK,IAAc,QAAe;GACjC,IAAM,IAAO,OAAO,YAClB,OAAO,QAAQ,CAAK,CAAC,CAAC,QAAQ,CAAC,OAAS,MAAQ,WAAW,MAAQ,OAAO,CAC5E;GAEA,OADI,EAAY,SAAO,OAAO,EAAK,SAC5B;EACT,CAAC,GAEK,IAAY,QAAe,EAAM,SAAS,EAAM,cAAc,EAAS,KAAK,GAG5E,IAAQ,EAAS,GACjB,IAAW,QACT,CAAC,EAAM,WAAW,CAAC,EAAE,EAAM,SAAS,EAAM,OAAO,EAAM,aAAa,EAAM,QAClF;yBAIE,EA4CO,QAAA;GA3CL,OAAK,EAAA,CAAC,2BACEA,EAAAA,OAAO,KAAK,CAAA;GACnB,OAAK,EAAE,EAAA,KAAS;GAChB,gBAAc,EAAA;GACd,aAAW,EAAA;GACX,eAAa,EAAA,UAAU,KAAA,IAAiB,KAAA,IAAR;GAChC,cAAY,EAAA;GACZ,aAAW,EAAA;GACX,gBAAc,EAAA,UAAO,KAAQ,KAAA;GAC7B,iBAAe,EAAA,cAAc,EAAA,QAAQ,KAAQ,KAAA;GAC7C,iBAAe,EAAA,WAAQ,KAAQ,KAAA;GAC/B,kBAAgB,EAAA,QAAQ,KAAQ,KAAA;YAEjC,EAmBY,EAlBL,EAAA,KAAS,GADhB,EAEU,EAiBE,OAjBS;GACnB,OAAM;GACL,MAAM,EAAA,UAAS,WAAA,WAA2B,KAAA;GAC1C,MAAM,EAAA,SAAM,CAAK,EAAA,WAAW,EAAA,OAAO,KAAA;GACnC,UAAU,EAAA,UAAS,WAAgB,EAAA,WAAW,KAAA;GAC9C,iBAAe,EAAA,QAAW,SAAY,KAAA;GACtC,gBAAc,EAAA,aAAa,EAAA,QAAW,KAAA;GACtC,SAAK,AAAA,EAAA,QAAA,MAAE,EAAA,cAAU,CAAK,EAAA,aAAa,EAAA,QAAQ,CAAI,EAAA;;oBAEJ;IAA/B,EAAA,SAAA,EAAA,GAAb,EAA4C,GAAA;;KAAnB,MAAM,EAAA,CAAA;6BAC/B,EAEO,EAAA,QAAA,SAAA,CAAA,SAAA,CADQ,EAAA,aAAA,EAAA,GAAb,EAAwD,GAAA,EAAA,EAAA,EAAA,KAAA,EAAA,GAAxB,EAAA,CAAA,CAAS,CAAC,EAAA,SAAS,CAAA,CAAA,GAAA,MAAA,EAAA,KAAA,EAAA,IAAA,EAAA,CAAA,GAAA,KAAA,GAAA,CAAA;IAErD,EAAQ,EAAA,QAAA,SAAA;IACR,EAEO,EAAA,QAAA,OAAA,CAAA,SAAA,CADQ,EAAA,WAAA,EAAA,GAAb,EAAoD,GAAA,EAAA,EAAA,EAAA,KAAA,EAAA,GAAtB,EAAA,CAAA,CAAS,CAAC,EAAA,OAAO,CAAA,CAAA,GAAA,MAAA,EAAA,KAAA,EAAA,IAAA,EAAA,CAAA,CAAA;;;;;;;;;OAI3C,EAAA,eAAA,EAAA,GADR,EASS,UAAA;;GAPP,MAAK;GACL,OAAM;GACL,cAAY,EAAA;GACZ,UAAU,EAAA;GACV,SAAK,AAAA,EAAA,QAAA,MAAEC,EAAAA,MAAK,SAAA;MAEb,EAAyC,GAAA,EAAA,EAA1B,EAAA,CAAA,CAAS,CAAC,EAAA,WAAW,CAAA,CAAA,GAAA,MAAA,EAAA,CAAA,GAAA,GAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,GAAA,IAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"VChip.vue_vue_type_script_setup_true_lang.js","names":["$emit"],"sources":["../../../src/components/VChip/VChip.vue"],"sourcesContent":["<script setup lang=\"ts\">\n// @core\n/**\n * A small labelled pill standing for a value: a filter in force, a tag, a chosen file, a\n * person picked in a field.\n *\n * What it renders follows what it is asked to DO, each shape being the native element for\n * it, so focus, keyboard and disabling come free: selectable is a button with `aria-pressed`,\n * `href` is a link, `clickable` is a button, and none of those is plain text with no hover.\n *\n * A dismissible chip carries a SECOND button BESIDE the first, never inside it — a button\n * within a button is invalid HTML and unreachable by keyboard.\n *\n * The only JS makes a disabled link inert, the platform having no `disabled` for links, and\n * splits the consumer's attributes between the pill and the element that acts.\n */\n\nimport { computed } from 'vue'\nimport type { StyleValue } from 'vue'\n\nimport VIcon from '../VIcon/VIcon.vue'\nimport { iconProps } from '../VIcon/iconProps'\n// TRAP — neither import may be named after a prop (`check`, `checkIcon`): every top-level\n// binding of a `<script setup>` reaches the template, where it shadows the prop of that name.\nimport { check as checkMark } from '../VIcon/icons/check'\nimport { close as closeIcon } from '../VIcon/icons/close'\nimport type { IconSource } from '../VIcon/types'\nimport { useMessages } from '../../i18n/state'\n\nimport { useInertLink } from '../../composables/useInertLink'\nimport { useRootAttrs } from '../../composables/useRootAttrs'\nimport { customColorStyle } from '../../utils/css'\n\n/** How much visual weight the chip carries. */\nexport type ChipVariant = 'soft' | 'solid' | 'outline'\n\n/** What the chip means, in colour. */\nexport type ChipTone = 'neutral' | 'accent' | 'danger' | 'success' | 'warning'\n\n/** The silhouette: softly rounded, or a full pill. */\nexport type ChipShape = 'chip' | 'pill'\n\n/** The height of the chip: 24 or 32 pixels. */\nexport type ChipSize = 'xs' | 'sm'\n\ninterface ChipProps {\n /**\n * How strongly the chip is painted: a tinted background, the full colour, or a\n * border alone.\n */\n variant?: ChipVariant\n /**\n * What the chip means, expressed as a colour: `neutral` by default, then `accent` for\n * something singled out and `danger`/`success`/`warning` for a state being reported. A\n * chip may report a state where a button may not, which is why it offers five.\n */\n tone?: ChipTone\n /**\n * A colour of your own (hex, CSS name or `oklch()`), which REPLACES the tone. Every\n * shade it needs — the tinted background, the text, the hover — is derived from that\n * one colour, so it follows the light and the dark theme with nothing to rebuild.\n * Only the contrast of the text on a fully coloured chip is yours to check.\n */\n color?: string\n /** The silhouette: softly rounded corners, or a full pill. */\n shape?: ChipShape\n /** The height of the chip. */\n size?: ChipSize\n /** Takes 4px off the height, leaving the padding, the text and the icons as they are. */\n compact?: boolean\n /** Makes the chip a button that reacts to clicks, without holding a state. */\n clickable?: boolean\n /**\n * Where the chip leads, which makes it a link. A disabled link is made inert by\n * hand.\n */\n href?: string\n /**\n * Makes the chip something that stays chosen, bound to `v-model:selected`. It wins\n * over `href` and `clickable`.\n */\n selectable?: boolean\n /**\n * Shows a tick before the label while the chip is selected. It REPLACES whatever\n * start icon was given, so the two are never shown together.\n */\n check?: boolean\n /** The icon of that tick, a built-in check mark by default. `iconFilled` does not reach it. */\n checkIcon?: IconSource\n /** An icon before the label. The `#start` slot replaces it. */\n iconStart?: IconSource\n /** An icon after the label. The `#end` slot replaces it. */\n iconEnd?: IconSource\n /**\n * Renders `iconStart` and `iconEnd` in their filled form (the font's `FILL` axis). It has\n * no effect on the `#start`/`#end` slots, whose icons the consumer builds, nor on the tick\n * or the removal cross.\n */\n iconFilled?: boolean\n /**\n * Adds a button that asks for the chip to be removed. It only EMITS that request:\n * actually taking the chip away is the consumer's decision.\n */\n dismissible?: boolean\n /** The icon of that removal button. */\n dismissIcon?: IconSource\n /**\n * What the removal button does, in words. It falls back to the design system\n * dictionary.\n */\n dismissLabel?: string\n /** Makes the chip unusable, greyed out through the colour tokens. */\n disabled?: boolean\n}\n\nconst props = withDefaults(defineProps<ChipProps>(), {\n variant: 'soft',\n tone: 'neutral',\n color: undefined,\n shape: 'chip',\n size: 'xs',\n compact: false,\n clickable: false,\n href: undefined,\n selectable: false,\n check: false,\n checkIcon: () => checkMark,\n iconStart: undefined,\n iconEnd: undefined,\n iconFilled: false,\n dismissible: false,\n dismissIcon: () => closeIcon,\n dismissLabel: undefined,\n disabled: false,\n})\n\nconst m = useMessages()\nconst resolvedDismissLabel = computed(() => props.dismissLabel ?? m.value.common.dismiss)\n\n/**\n * Whether the chip is selected, which is also what makes it selectable at all: binding this\n * turns it into a toggle button and takes precedence over `href` and `clickable`. It starts\n * unselected.\n */\nconst selected = defineModel<boolean>('selected', { default: false })\n\ndefineEmits<{\n /** The removal button was pressed. The chip is still there: removing it is up to you. */\n dismiss: []\n}>()\n\nconst slots = defineSlots<{\n /** The label. It may be left out entirely, which gives a chip made of icons alone. */\n default?(): unknown\n /** Content before the label, which takes the place of `iconStart`. */\n start?(): unknown\n /** Content after the label, which takes the place of `iconEnd`. */\n end?(): unknown\n}>()\n\ndefineOptions({ inheritAttrs: false })\n\n// The wrapper-root split: the pill is the box a consumer positions, and the ACTION is the\n// element that is focused, named and clicked, so everything else goes there.\nconst { rootClass, rootStyle: consumerStyle, forwardedAttrs } = useRootAttrs()\n\n/* What the chip does, in order of precedence: staying selected wins over leading\n somewhere, which wins over merely reacting to clicks; asked for none of them, it is\n plain text. A selectable chip is therefore never a link, whatever `href` says. */\nconst {\n isLink,\n isInertLink,\n linkHref,\n attrs: actionAttrs,\n} = useInertLink({\n href: () => (props.selectable ? undefined : props.href),\n inert: () => props.disabled,\n attrs: () => forwardedAttrs.value,\n})\nconst actionTag = computed(() =>\n props.selectable ? 'button' : isLink.value ? 'a' : props.clickable ? 'button' : 'span',\n)\n\nconst rootStyle = computed<StyleValue>(() => [customColorStyle(props.color), consumerStyle.value])\n\nconst showCheck = computed(() => props.check && props.selectable && selected.value)\n\n// TRAP — a function read by the template, never a `computed`: `slots` is not reactive, so a\n// computed would keep its first answer while a slot behind a `v-if` comes and goes.\n/** An icon and no label at all: the chip becomes a square, as wide as it is tall. */\nfunction iconOnly() {\n return !slots.default && !!(slots.start || slots.end || props.iconStart || props.iconEnd)\n}\n</script>\n\n<template>\n <span\n :class=\"['v-chip v-control v-tone v-variant', rootClass]\"\n :style=\"rootStyle\"\n :data-variant=\"variant\"\n :data-tone=\"tone\"\n :data-custom=\"color !== undefined ? '' : undefined\"\n :data-shape=\"shape\"\n :data-size=\"size\"\n :data-compact=\"compact ? '' : undefined\"\n :data-selected=\"selectable && selected ? '' : undefined\"\n :data-disabled=\"disabled ? '' : undefined\"\n :data-icon-only=\"iconOnly() ? '' : undefined\"\n >\n <component\n :is=\"actionTag\"\n v-bind=\"actionAttrs\"\n class=\"v-chip-action\"\n :type=\"actionTag === 'button' ? 'button' : undefined\"\n :href=\"linkHref\"\n :disabled=\"actionTag === 'button' ? disabled : undefined\"\n :aria-disabled=\"isInertLink ? 'true' : undefined\"\n :aria-pressed=\"selectable ? selected : undefined\"\n @click=\"selectable && !disabled && (selected = !selected)\"\n >\n <VIcon v-if=\"showCheck\" v-bind=\"iconProps(checkIcon)\" />\n <slot v-else name=\"start\">\n <VIcon v-if=\"iconStart\" v-bind=\"iconProps(iconStart)\" :filled=\"iconFilled\" />\n </slot>\n <slot />\n <slot name=\"end\">\n <VIcon v-if=\"iconEnd\" v-bind=\"iconProps(iconEnd)\" :filled=\"iconFilled\" />\n </slot>\n </component>\n <button\n v-if=\"dismissible\"\n type=\"button\"\n class=\"v-chip-dismiss\"\n :aria-label=\"resolvedDismissLabel\"\n :disabled=\"disabled\"\n @click=\"$emit('dismiss')\"\n >\n <VIcon v-bind=\"iconProps(dismissIcon)\" />\n </button>\n </span>\n</template>\n\n<style>\n@layer vectis.components {\n /* The height comes from the shared size class set on this element. The scale itself\n holds five steps; the component's type restricts it to the two smallest, a chip\n larger than that being a button. */\n .v-chip {\n display: inline-flex;\n align-items: center;\n height: var(--control-height);\n border: 1px solid transparent;\n border-radius: var(--vectis-radius-chip);\n font-family: var(--vectis-text-family);\n font-size: var(--control-font-size);\n font-weight: var(--vectis-text-control-weight);\n line-height: var(--vectis-text-control-leading);\n transition:\n background-color var(--vectis-duration-fast) var(--vectis-ease-default),\n border-color var(--vectis-duration-fast) var(--vectis-ease-default),\n color var(--vectis-duration-fast) var(--vectis-ease-default);\n }\n\n .v-chip[data-shape='pill'] {\n border-radius: var(--vectis-radius-pill);\n }\n\n /* The tone table itself lives in styles/tones.css, in a layer below the components.\n All five tones are taken exactly as they come; the only values redefined here are\n those of a custom colour, and they win over the shared table by LAYER rather than\n by order, so no bundling can change the outcome. */\n\n /* A custom colour replaces the tone entirely. Every shade it needs is derived from\n that one colour mixed with the theme's own surface and text, so the same value\n produces a legible chip in the light theme and in the dark one, with nothing to\n rebuild. */\n .v-chip[data-custom] {\n --tone-bg-solid: var(--custom-color);\n --tone-bg-solid-hover: color-mix(in oklab, var(--custom-color), var(--vectis-color-text) 8%);\n --tone-bg-solid-active: color-mix(in oklab, var(--custom-color), var(--vectis-color-text) 14%);\n /* Fixed white, whatever the colour: on a fully coloured chip the contrast of the\n text is the consumer's to check, as it is in VBadge. */\n --tone-text-solid: var(--vectis-color-text-on-accent);\n --tone-text-tinted: color-mix(in oklab, var(--custom-color), var(--vectis-color-text) 30%);\n --tone-bg-soft: color-mix(in oklab, var(--custom-color), var(--vectis-color-surface) 85%);\n --tone-border-soft: color-mix(in oklab, var(--custom-color), var(--vectis-color-surface) 60%);\n }\n\n /* A selected chip is painted in the full colour of its CURRENT tone, whichever variant it\n was given. It COMPOUNDS `.v-variant`: the variant table weighs (0,2,0) like this rule and\n lives in another sheet, so at equal specificity the winner would be whichever one the\n consumer's bundler put last. At (0,3,0) it wins by construction. */\n .v-variant.v-chip[data-selected] {\n background: var(--tone-bg-solid);\n color: var(--tone-text-solid);\n border-color: transparent;\n }\n\n /* Hovering and pressing are conditioned on the ACTION being a real control, which\n buys two things at once: a chip that merely displays a value never lights up, and\n hovering the removal button does not repaint the whole chip as though it were\n about to be activated. */\n /* The same steps as VButton's, rule for rule: an outline sits on the soft surface while\n hovered and one tint further when pressed, and that tint is where a soft chip starts\n on hover. Held in each sheet rather than in `variants.css`, which every consumer\n downloads whether or not it renders a single button or chip. */\n .v-chip[data-variant='outline']:not([data-disabled], [data-selected]):has(\n :is(button, a).v-chip-action:hover\n ) {\n background: var(--tone-bg-soft);\n }\n\n .v-chip[data-variant='outline']:not([data-disabled], [data-selected]):has(\n :is(button, a).v-chip-action:active\n ),\n .v-chip[data-variant='soft']:not([data-disabled], [data-selected]):has(\n :is(button, a).v-chip-action:hover\n ) {\n background: color-mix(in oklab, var(--tone-bg-soft), var(--tone-text-tinted) 8%);\n }\n\n .v-chip[data-variant='soft']:not([data-disabled], [data-selected]):has(\n :is(button, a).v-chip-action:active\n ) {\n background: color-mix(in oklab, var(--tone-bg-soft), var(--tone-text-tinted) 14%);\n }\n\n .v-chip[data-variant='solid']:not([data-disabled]):has(:is(button, a).v-chip-action:hover),\n .v-chip[data-selected]:not([data-disabled]):has(:is(button, a).v-chip-action:hover) {\n background: var(--tone-bg-solid-hover);\n }\n\n .v-chip[data-variant='solid']:not([data-disabled]):has(:is(button, a).v-chip-action:active),\n .v-chip[data-selected]:not([data-disabled]):has(:is(button, a).v-chip-action:active) {\n background: var(--tone-bg-solid-active);\n }\n\n .v-chip-action {\n display: inline-flex;\n align-items: center;\n gap: var(--control-gap);\n height: 100%;\n padding-block: 0;\n padding-inline: var(--control-padding-inline);\n border: none;\n background: transparent;\n color: inherit;\n font: inherit;\n border-radius: inherit;\n text-decoration: none;\n cursor: default;\n }\n\n /* With an icon and no label the action becomes square, its width taken from its own\n height through the ratio rather than from a new measurement to keep in step. */\n .v-chip[data-icon-only] .v-chip-action {\n aspect-ratio: 1;\n justify-content: center;\n padding-inline: 0;\n }\n\n :is(button, a).v-chip-action {\n cursor: pointer;\n }\n\n :is(button, a).v-chip-action:focus-visible {\n outline: var(--vectis-focus-ring-width) solid var(--vectis-focus-ring-color);\n outline-offset: var(--vectis-focus-ring-offset);\n }\n\n /* The removal button carries no background of its own, not even on hover — the same\n treatment as a field's inner buttons — and the cursor is what signals it can be\n used.\n\n Its icon takes the chip's colour AT FULL strength. Dimming it, as one would\n instinctively do for a secondary control, took the cross down to 3.9:1 on a tinted\n chip and 2.8:1 on a solid one. That matters because the cross is drawn from the\n icon font here, and a glyph from a font is real text, to which the contrast rule\n applies. */\n .v-chip-dismiss {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--control-action-size);\n height: var(--control-action-size);\n margin-inline: calc(var(--vectis-space-1) * -1) var(--vectis-space-1);\n padding: 0;\n border: none;\n background: transparent;\n color: inherit;\n border-radius: var(--vectis-radius-pill);\n cursor: pointer;\n flex: none;\n }\n\n .v-chip-dismiss:focus-visible {\n outline: var(--vectis-focus-ring-width) solid var(--vectis-focus-ring-color);\n outline-offset: calc(-1 * var(--vectis-focus-ring-width));\n }\n\n /* A disabled chip greys out through the colour tokens, which is what makes it follow\n the dark theme without a rule of its own. */\n .v-variant.v-chip[data-disabled] {\n background: var(--vectis-color-surface-muted);\n color: var(--vectis-color-text-subtle);\n border-color: transparent;\n }\n\n .v-variant.v-chip[data-disabled][data-variant='outline'] {\n background: transparent;\n border-color: var(--vectis-color-border);\n }\n\n .v-chip[data-disabled] :is(:is(button, a).v-chip-action, .v-chip-dismiss) {\n cursor: not-allowed;\n }\n\n @media (prefers-reduced-motion: reduce) {\n .v-chip {\n transition: none;\n }\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmHA,IAAM,IAAQ,GAqBR,IAAI,EAAY,GAChB,IAAuB,QAAe,EAAM,gBAAgB,EAAE,MAAM,OAAO,OAAO,GAOlF,IAAW,EAAoB,GAAC,UAA8B,GAO9D,IAAQ,EAAA,GAaR,EAAE,cAAW,WAAW,GAAe,sBAAmB,EAAa,GAKvE,EACJ,WACA,gBACA,aACA,OAAO,MACL,EAAa;GACf,YAAa,EAAM,aAAa,KAAA,IAAY,EAAM;GAClD,aAAa,EAAM;GACnB,aAAa,EAAe;EAC9B,CAAC,GACK,IAAY,QAChB,EAAM,aAAa,WAAW,EAAO,QAAQ,MAAM,EAAM,YAAY,WAAW,MAClF,GAEM,IAAY,QAA2B,CAAC,EAAiB,EAAM,KAAK,GAAG,EAAc,KAAK,CAAC,GAE3F,IAAY,QAAe,EAAM,SAAS,EAAM,cAAc,EAAS,KAAK;EAKlF,SAAS,IAAW;GAClB,OAAO,CAAC,EAAM,WAAW,CAAC,EAAE,EAAM,SAAS,EAAM,OAAO,EAAM,aAAa,EAAM;EACnF;yBAIE,EA2CO,QAAA;GA1CJ,OAAK,EAAA,CAAA,qCAAwC,EAAA,CAAA,CAAS,CAAA;GACtD,OAAK,EAAE,EAAA,KAAS;GAChB,gBAAc,EAAA;GACd,aAAW,EAAA;GACX,eAAa,EAAA,UAAU,KAAA,IAAiB,KAAA,IAAR;GAChC,cAAY,EAAA;GACZ,aAAW,EAAA;GACX,gBAAc,EAAA,UAAO,KAAQ,KAAA;GAC7B,iBAAe,EAAA,cAAc,EAAA,QAAQ,KAAQ,KAAA;GAC7C,iBAAe,EAAA,WAAQ,KAAQ,KAAA;GAC/B,kBAAgB,EAAQ,IAAA,KAAU,KAAA;YAEnC,EAmBY,EAlBL,EAAA,KAAS,GADhB,EAEU,EAiBE,CAAA,GAjBS;GACnB,OAAM;GACL,MAAM,EAAA,UAAS,WAAA,WAA2B,KAAA;GAC1C,MAAM,EAAA,CAAA;GACN,UAAU,EAAA,UAAS,WAAgB,EAAA,WAAW,KAAA;GAC9C,iBAAe,EAAA,CAAA,IAAW,SAAY,KAAA;GACtC,gBAAc,EAAA,aAAa,EAAA,QAAW,KAAA;GACtC,SAAK,AAAA,EAAA,QAAA,MAAE,EAAA,cAAU,CAAK,EAAA,aAAa,EAAA,QAAQ,CAAI,EAAA;;oBAEQ;IAA3C,EAAA,SAAA,EAAA,GAAb,EAAwD,GAAA,EAAA,EAAA,EAAA,KAAA,EAAA,GAAxB,EAAA,CAAA,CAAS,CAAC,EAAA,SAAS,CAAA,CAAA,GAAA,MAAA,EAAA,KACnD,EAEO,EAAA,QAAA,SAAA,CAAA,SAAA,CADQ,EAAA,aAAA,EAAA,GAAb,EAA6E,GAA7E,EAA6E,EAAA,KAAA,EAAA,GAA7C,EAAA,CAAA,CAAS,CAAC,EAAA,SAAS,GAAA,EAAI,QAAQ,EAAA,WAAU,CAAA,GAAA,MAAA,IAAA,CAAA,QAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,GAAA,KAAA,GAAA,CAAA;IAE3E,EAAQ,EAAA,QAAA,SAAA;IACR,EAEO,EAAA,QAAA,OAAA,CAAA,SAAA,CADQ,EAAA,WAAA,EAAA,GAAb,EAAyE,GAAzE,EAAyE,EAAA,KAAA,EAAA,GAA3C,EAAA,CAAA,CAAS,CAAC,EAAA,OAAO,GAAA,EAAI,QAAQ,EAAA,WAAU,CAAA,GAAA,MAAA,IAAA,CAAA,QAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,CAAA;;;;;;;;;OAIjE,EAAA,eAAA,EAAA,GADR,EASS,UAAA;;GAPP,MAAK;GACL,OAAM;GACL,cAAY,EAAA;GACZ,UAAU,EAAA;GACV,SAAK,AAAA,EAAA,QAAA,MAAEA,EAAAA,MAAK,SAAA;MAEb,EAAyC,GAAA,EAAA,EAA1B,EAAA,CAAA,CAAS,CAAC,EAAA,WAAW,CAAA,CAAA,GAAA,MAAA,EAAA,CAAA,GAAA,GAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,GAAA,IAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
@layer vectis.reset, vectis.tokens, vectis.components, vectis.utilities;
|
|
2
|
-
@layer vectis.components{.v-combobox{anchor-scope:--combobox-anchor;width:100%;font-family:var(--vectis-text-family)}.v-combobox-control{anchor-name:--combobox-anchor
|
|
2
|
+
@layer vectis.components{.v-combobox{anchor-scope:--combobox-anchor;width:100%;font-family:var(--vectis-text-family)}.v-combobox-control{display:block}.v-combobox-control .v-input-field{anchor-name:--combobox-anchor}.v-combobox-panel{max-block-size:var(--vectis-control-size-combobox-list-max-block);overflow:auto}.v-combobox-chevron,.v-combobox-spinner{color:var(--vectis-color-text-muted)}.v-combobox-chevron{transition:rotate var(--vectis-duration-fast) var(--vectis-ease-default)}.v-combobox[data-open] .v-combobox-chevron{rotate:180deg}.v-combobox[data-collapsed] .v-input-control{width:0;height:0;padding:0;position:absolute}.v-combobox-text{text-overflow:ellipsis;white-space:nowrap;flex:0 auto;min-width:0;overflow:hidden}.v-combobox:not([data-collapsed]) .v-combobox-text{max-inline-size:50%}.v-combobox-overflow{white-space:nowrap;color:var(--vectis-color-text-muted);flex:none}.v-combobox:has(.v-combobox-text){min-inline-size:0}.v-combobox-state{align-items:center;gap:var(--control-gap);min-height:var(--control-height);padding:var(--vectis-space-1) var(--control-padding-inline);font-size:var(--control-font-size);color:var(--vectis-color-text-muted);flex:none;display:flex}.v-combobox-more{min-height:var(--vectis-space-6);color:var(--vectis-color-text-muted);flex:none;justify-content:center;align-items:center;display:flex}@media (prefers-reduced-motion:reduce){.v-combobox-chevron{transition:none}}}
|
|
@@ -1,27 +1,13 @@
|
|
|
1
|
+
import { ChipSize } from '../VChip/VChip.js';
|
|
1
2
|
import { IconSource } from '../VIcon/types.js';
|
|
2
|
-
|
|
3
|
-
* A field one types into to search a list, and picks one or several values from. It is
|
|
4
|
-
* built out of a text field, a floating panel holding the list, and chips for the values
|
|
5
|
-
* already chosen.
|
|
6
|
-
*
|
|
7
|
-
* The platform offers nothing to build this on: its own suggestion list can be neither
|
|
8
|
-
* styled nor made to accept several values. So the JavaScript here implements the whole
|
|
9
|
-
* pattern assistive technology expects of a combobox — the filtering, the moving of the
|
|
10
|
-
* highlight, and the selection.
|
|
11
|
-
*
|
|
12
|
-
* One decision shapes all the rest: the DOM focus NEVER leaves the text field. What
|
|
13
|
-
* moves as the reader presses the arrows is a pointer naming the current option, which
|
|
14
|
-
* is why the panel has no keyboard of its own and why this component owns the entire
|
|
15
|
-
* accessibility contract of the field.
|
|
16
|
-
*
|
|
17
|
-
* The panel is opened in the mode where nothing dismisses it by itself, and closing is
|
|
18
|
-
* decided by the focus leaving the component — which the field being OUTSIDE the panel
|
|
19
|
-
* makes possible.
|
|
20
|
-
*/
|
|
3
|
+
import { ItemValue } from '../../types.js';
|
|
21
4
|
/** One thing that can be chosen. */
|
|
22
5
|
export interface ComboboxOption {
|
|
23
|
-
/**
|
|
24
|
-
|
|
6
|
+
/**
|
|
7
|
+
* What choosing it means: this is what the value holds. A number is admitted because a
|
|
8
|
+
* list of options almost always comes from somewhere that keys its rows by one.
|
|
9
|
+
*/
|
|
10
|
+
value: ItemValue;
|
|
25
11
|
/** What it is called on screen, and what the search matches against. */
|
|
26
12
|
label: string;
|
|
27
13
|
/** An icon before the label: an icon name, or an explicit render. */
|
|
@@ -55,6 +41,15 @@ export type ComboboxItem = ComboboxOption | ComboboxGroup | ComboboxSeparator;
|
|
|
55
41
|
* options already arrive filtered by a server — or by a rule of your own.
|
|
56
42
|
*/
|
|
57
43
|
export type ComboboxFilter = boolean | ((option: ComboboxOption, query: string) => boolean);
|
|
44
|
+
/** Where the list opens relative to the field. */
|
|
45
|
+
export type ComboboxPlacement = 'bottom' | 'bottom-start' | 'bottom-end' | 'top' | 'top-start' | 'top-end';
|
|
46
|
+
/** The height of the field: 32, 40 or 48 pixels. */
|
|
47
|
+
export type ComboboxSize = 'sm' | 'md' | 'lg';
|
|
48
|
+
/**
|
|
49
|
+
* How the chosen values are shown in a multiple field: one chip each, or their labels
|
|
50
|
+
* joined by commas.
|
|
51
|
+
*/
|
|
52
|
+
export type ComboboxDisplay = 'chip' | 'text';
|
|
58
53
|
interface ComboboxProps {
|
|
59
54
|
/**
|
|
60
55
|
* What the list offers. An entry may be an option, a named block of options, or a
|
|
@@ -63,21 +58,72 @@ interface ComboboxProps {
|
|
|
63
58
|
options: ComboboxItem[];
|
|
64
59
|
/**
|
|
65
60
|
* Allows several values to be chosen, which makes the value a list and shows what has
|
|
66
|
-
* been chosen as chips
|
|
61
|
+
* been chosen inside the field, as chips or as text depending on `display`.
|
|
67
62
|
*/
|
|
68
63
|
multiple?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* How the chosen values are shown when several can be chosen: one dismissible chip
|
|
66
|
+
* each, or their labels joined by commas on a single line, cut short with an ellipsis
|
|
67
|
+
* when they run out of room. It changes nothing for a single value, which is always
|
|
68
|
+
* text.
|
|
69
|
+
*/
|
|
70
|
+
display?: ComboboxDisplay;
|
|
71
|
+
/**
|
|
72
|
+
* How many chosen values to show before the rest are summed up as "+X", as chips or as
|
|
73
|
+
* text alike. It applies while the search input is folded away, which is to say out of
|
|
74
|
+
* focus: focused, every value comes back so it can be seen and taken back. Left out, or
|
|
75
|
+
* set to 0, every value is shown. It changes nothing without `multiple`.
|
|
76
|
+
*/
|
|
77
|
+
max?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Rephrases the "+X" standing for the values beyond `max`, "+5 products" for instance.
|
|
80
|
+
* It receives the number of values being hidden.
|
|
81
|
+
*/
|
|
82
|
+
overflowText?: (count: number) => string;
|
|
83
|
+
/** The label above the field, tied to it so that clicking it focuses the field. */
|
|
84
|
+
label?: string;
|
|
85
|
+
/**
|
|
86
|
+
* A line of help under the field. It is tied to the field for assistive technology,
|
|
87
|
+
* so it is read out along with the label.
|
|
88
|
+
*/
|
|
89
|
+
hint?: string;
|
|
69
90
|
/** The height of the field: 32, 40 or 48 pixels. */
|
|
70
|
-
size?:
|
|
91
|
+
size?: ComboboxSize;
|
|
71
92
|
/** Takes 4px off the height, as everywhere else in the design system. */
|
|
72
93
|
compact?: boolean;
|
|
73
94
|
/** What the field says while nothing is chosen and nothing has been typed. */
|
|
74
95
|
placeholder?: string;
|
|
75
96
|
/** Makes the field unusable, greyed out through the colour tokens. */
|
|
76
97
|
disabled?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Shows what has been chosen without letting it be changed: nothing can be typed,
|
|
100
|
+
* the list never opens, the chips lose their crosses and no clear cross is offered.
|
|
101
|
+
* The field stays focusable and can be copied from, which is what separates it from
|
|
102
|
+
* `disabled`.
|
|
103
|
+
*/
|
|
104
|
+
readonly?: boolean;
|
|
77
105
|
/** Marks the field as invalid — for a rule of your own. */
|
|
78
106
|
invalid?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* An icon inside the field, at the start — before the chips when several values can
|
|
109
|
+
* be chosen. It is decorative by default and becomes a real button as soon as a
|
|
110
|
+
* `@click:icon-start` listener is attached, in which case it needs `iconStartLabel`.
|
|
111
|
+
*/
|
|
112
|
+
iconStart?: IconSource;
|
|
113
|
+
/** What the start icon does, in words, once it is clickable. */
|
|
114
|
+
iconStartLabel?: string;
|
|
115
|
+
/**
|
|
116
|
+
* The chevron at the end of the field, which turns as the list opens: an icon name,
|
|
117
|
+
* or an explicit render. Clicking it while the list is open closes the list. It is
|
|
118
|
+
* decoration all the same — the field itself is what opens the list, and Escape what
|
|
119
|
+
* closes it from the keyboard — so the chevron is hidden from screen readers and takes
|
|
120
|
+
* no label.
|
|
121
|
+
*/
|
|
122
|
+
expandIcon?: IconSource;
|
|
79
123
|
/** Offers a cross that empties both the selection and the search. */
|
|
80
124
|
clearable?: boolean;
|
|
125
|
+
/** What that cross does, in words. It falls back to the design system dictionary. */
|
|
126
|
+
clearLabel?: string;
|
|
81
127
|
/** What the panel says when the search matches nothing. */
|
|
82
128
|
emptyText?: string;
|
|
83
129
|
/**
|
|
@@ -108,9 +154,22 @@ interface ComboboxProps {
|
|
|
108
154
|
* the next one as the end of the list comes into view.
|
|
109
155
|
*/
|
|
110
156
|
hasMore?: boolean;
|
|
157
|
+
/** Where the list opens relative to the field. */
|
|
158
|
+
placement?: ComboboxPlacement;
|
|
111
159
|
}
|
|
112
160
|
type __VLS_Props = ComboboxProps;
|
|
113
161
|
type __VLS_Slots = {
|
|
162
|
+
/**
|
|
163
|
+
* Content at the start of the field, rendered after the chips standing for the chosen
|
|
164
|
+
* values rather than in their place.
|
|
165
|
+
*/
|
|
166
|
+
start?(): unknown;
|
|
167
|
+
/**
|
|
168
|
+
* Controls of your own inside the field, placed before the ones the field owns — the
|
|
169
|
+
* clear cross and the chevron. Those two are this component's own affordance, which is
|
|
170
|
+
* why there is no `#end` here: it would replace them.
|
|
171
|
+
*/
|
|
172
|
+
'value-end'?(): unknown;
|
|
114
173
|
/**
|
|
115
174
|
* What a row of the list shows, in place of the plain label — a subtitle, an avatar,
|
|
116
175
|
* a badge. It is told whether the row is the highlighted one and whether it is
|
|
@@ -132,11 +191,21 @@ type __VLS_Slots = {
|
|
|
132
191
|
* options.
|
|
133
192
|
*/
|
|
134
193
|
chip?(props: {
|
|
135
|
-
value:
|
|
194
|
+
value: ItemValue;
|
|
136
195
|
option: ComboboxOption | undefined;
|
|
137
196
|
label: string;
|
|
138
197
|
remove: () => void;
|
|
139
|
-
size:
|
|
198
|
+
size: ChipSize;
|
|
199
|
+
compact: boolean;
|
|
200
|
+
}): unknown;
|
|
201
|
+
/**
|
|
202
|
+
* Replaces the "+X" standing for the values beyond `max`. It receives `count`, the number
|
|
203
|
+
* of values being hidden, and the size and density of the chips inside the field, so that a
|
|
204
|
+
* chip of your own lines up with the others.
|
|
205
|
+
*/
|
|
206
|
+
overflow?(props: {
|
|
207
|
+
count: number;
|
|
208
|
+
size: ChipSize;
|
|
140
209
|
compact: boolean;
|
|
141
210
|
}): unknown;
|
|
142
211
|
/** What the panel shows when nothing matches. It receives the term that was searched. */
|
|
@@ -147,27 +216,54 @@ type __VLS_Slots = {
|
|
|
147
216
|
loading?(): unknown;
|
|
148
217
|
};
|
|
149
218
|
type __VLS_ModelProps = {
|
|
150
|
-
|
|
219
|
+
/**
|
|
220
|
+
* The chosen option's `value`, or the list of them when `multiple` is set. It is an empty
|
|
221
|
+
* string to begin with, and the array is never mutated in place: each change is a new one,
|
|
222
|
+
* which is what wakes the consumer's binding.
|
|
223
|
+
*/
|
|
224
|
+
modelValue?: ItemValue | ItemValue[];
|
|
151
225
|
};
|
|
152
226
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
153
|
-
declare const __VLS_base: import('vue').DefineComponent<__VLS_PublicProps, {
|
|
227
|
+
declare const __VLS_base: import('vue').DefineComponent<__VLS_PublicProps, {
|
|
228
|
+
/** Moves the focus to the search field. */
|
|
229
|
+
focus: (options?: FocusOptions) => void | undefined;
|
|
230
|
+
/** Selects what has been typed in the search field. */
|
|
231
|
+
select: () => void | undefined;
|
|
232
|
+
/** The real `<input>` behind the field, for what neither of the two above covers. */
|
|
233
|
+
el: import('vue').ComputedRef<HTMLInputElement | null>;
|
|
234
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
235
|
+
clear: () => any;
|
|
154
236
|
search: (query: string) => any;
|
|
155
|
-
"update:modelValue": (value:
|
|
237
|
+
"update:modelValue": (value: ItemValue | ItemValue[]) => any;
|
|
238
|
+
"click:icon-start": (event: MouseEvent) => any;
|
|
156
239
|
"load-more": () => any;
|
|
157
240
|
}, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
241
|
+
onClear?: (() => any) | undefined;
|
|
158
242
|
onSearch?: ((query: string) => any) | undefined;
|
|
159
|
-
"onUpdate:modelValue"?: ((value:
|
|
243
|
+
"onUpdate:modelValue"?: ((value: ItemValue | ItemValue[]) => any) | undefined;
|
|
244
|
+
"onClick:icon-start"?: ((event: MouseEvent) => any) | undefined;
|
|
160
245
|
"onLoad-more"?: (() => any) | undefined;
|
|
161
246
|
}>, {
|
|
162
247
|
loading: boolean;
|
|
248
|
+
label: string;
|
|
163
249
|
placeholder: string;
|
|
164
|
-
size:
|
|
250
|
+
size: ComboboxSize;
|
|
165
251
|
filter: ComboboxFilter;
|
|
252
|
+
display: ComboboxDisplay;
|
|
253
|
+
placement: ComboboxPlacement;
|
|
166
254
|
compact: boolean;
|
|
167
255
|
disabled: boolean;
|
|
168
|
-
|
|
256
|
+
iconStart: IconSource;
|
|
169
257
|
invalid: boolean;
|
|
258
|
+
multiple: boolean;
|
|
259
|
+
hint: string;
|
|
260
|
+
readonly: boolean;
|
|
261
|
+
iconStartLabel: string;
|
|
170
262
|
clearable: boolean;
|
|
263
|
+
clearLabel: string;
|
|
264
|
+
expandIcon: IconSource;
|
|
265
|
+
max: number;
|
|
266
|
+
overflowText: (count: number) => string;
|
|
171
267
|
emptyText: string;
|
|
172
268
|
searchDebounce: number;
|
|
173
269
|
loadingText: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VCombobox.js","names":[],"sources":["../../../src/components/VCombobox/VCombobox.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, nextTick, reactive, ref, useId, watch, watchEffect } from 'vue'\n\nimport VChip from '../VChip/VChip.vue'\nimport VIcon from '../VIcon/VIcon.vue'\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 { chipScaleFor } from '../../utils/chip'\nimport { normalizeText } from '../../utils/text'\n\nimport { useRootAttrs } from '../../composables/useRootAttrs'\n\nimport { useFocusoutDismiss } from '../../composables/useFocusoutDismiss'\n\nimport { useTimer } from '../../composables/useTimer'\nimport { useMessages } from '../../i18n/state'\n\n// @a11y @keyboard @core\n/**\n * A field one types into to search a list, and picks one or several values from. It is\n * built out of a text field, a floating panel holding the list, and chips for the values\n * already chosen.\n *\n * The platform offers nothing to build this on: its own suggestion list can be neither\n * styled nor made to accept several values. So the JavaScript here implements the whole\n * pattern assistive technology expects of a combobox — the filtering, the moving of the\n * highlight, and the selection.\n *\n * One decision shapes all the rest: the DOM focus NEVER leaves the text field. What\n * moves as the reader presses the arrows is a pointer naming the current option, which\n * is why the panel has no keyboard of its own and why this component owns the entire\n * accessibility contract of the field.\n *\n * The panel is opened in the mode where nothing dismisses it by itself, and closing is\n * decided by the focus leaving the component — which the field being OUTSIDE the panel\n * makes possible.\n */\n/** One thing that can be chosen. */\nexport interface ComboboxOption {\n /** What choosing it means: this is what the value holds. */\n value: string\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\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 as chips inside the field.\n */\n multiple?: boolean\n /** The height of the field: 32, 40 or 48 pixels. */\n size?: 'sm' | 'md' | 'lg'\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 /** Marks the field as invalid — for a rule of your own. */\n invalid?: boolean\n /** Offers a cross that empties both the selection and the search. */\n clearable?: boolean\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}\n\nconst props = withDefaults(defineProps<ComboboxProps>(), {\n multiple: false,\n size: 'md',\n compact: false,\n placeholder: undefined,\n disabled: false,\n invalid: false,\n clearable: true,\n emptyText: undefined,\n filter: true,\n searchDebounce: 250,\n loading: false,\n loadingText: undefined,\n hasMore: false,\n})\n\nconst m = useMessages()\nconst resolvedEmptyText = computed(() => props.emptyText ?? m.value.combobox.empty)\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}>()\n\ndefineSlots<{\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: string\n option: ComboboxOption | undefined\n label: string\n remove: () => void\n size: 'xs' | 'sm'\n compact: boolean\n }): 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// 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(props.size, props.compact))\n\nconst model = defineModel<string | string[]>({ 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\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<string[]>(() => {\n if (props.multiple) return Array.isArray(model.value) ? model.value : []\n return typeof model.value === 'string' && 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<string, 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<string, 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: string) {\n return optionsByValue.value.get(value) ?? optionCache.get(value)\n}\n\nfunction labelOf(value: string) {\n return optionOf(value)?.label ?? value\n}\n\n/*\n * The labels in their accent-insensitive form, remembered per option and re-checked\n * against the label itself.\n *\n * Normalizing a string means decomposing it, stripping what it decomposed into, and\n * lowercasing it — and the filter below runs on every keystroke. Without this memory the\n * entire list would be normalized again for each character typed.\n *\n * Reading the label on every call, rather than deriving the whole table once, is what\n * keeps the filter reactive: a derived value keyed on the list alone would not notice a\n * label changed in place, since flattening the options only ever touches the containers.\n */\nconst normalizedLabels = new WeakMap<ComboboxOption, { label: string; normalized: string }>()\nfunction normalizedLabelOf(option: ComboboxOption): string {\n const hit = normalizedLabels.get(option)\n if (hit && hit.label === option.label) return hit.normalized\n const normalized = normalizeText(option.label)\n normalizedLabels.set(option, { label: option.label, normalized })\n return normalized\n}\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\nconst rendered = computed<RenderedNode[]>(() => {\n const indexOf = new Map<string, number>()\n filtered.value.forEach((option, index) => indexOf.set(option.value, index))\n\n const entryOf = (option: ComboboxOption): RenderedOption | null => {\n const index = indexOf.get(option.value)\n if (index === undefined) return null\n return { kind: 'option', key: `option:${option.value}`, option, index }\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(entryOf)\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)\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.\nif (!props.multiple && typeof model.value === 'string' && model.value) {\n query.value = labelOf(model.value)\n}\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 (typeof model.value === 'string' && model.value) query.value = labelOf(model.value)\n },\n { flush: 'post' },\n)\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.\nconst collapsed = computed(\n () => props.multiple && !focused.value && selectedValues.value.length > 0,\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 canClear = computed(\n () =>\n props.clearable &&\n !props.disabled &&\n (selectedValues.value.length > 0 || query.value.length > 0),\n)\n\nconst optionId = (index: number) => `${optionsId}-option-${index}`\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. These\n// two builders are what reduce that duplication to a single line on each side.\nfunction rowProps(entry: RenderedOption) {\n return {\n id: optionId(entry.index),\n icon: entry.option.icon,\n active: entry.index === activeIndex.value,\n selected: selectedSet.value.has(entry.option.value),\n disabled: entry.option.disabled,\n }\n}\n\nfunction optionSlotProps(entry: RenderedOption) {\n return {\n option: entry.option,\n index: entry.index,\n active: entry.index === activeIndex.value,\n selected: selectedSet.value.has(entry.option.value),\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\nfunction openPanel() {\n if (props.disabled || 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 =\n !props.multiple && typeof model.value === 'string' && model.value ? labelOf(model.value) : ''\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/** A click anywhere on the field focuses it and opens the panel. */\nfunction onControlClick() {\n if (props.disabled) return\n inputRef.value?.focus()\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: string) {\n if (!props.multiple) 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}\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) removeValue(last)\n }\n break\n }\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=\"size\"\n :data-compact=\"compact ? '' : undefined\"\n :data-multiple=\"multiple ? '' : undefined\"\n :data-collapsed=\"collapsed ? '' : undefined\"\n :data-open=\"open ? '' : undefined\"\n :data-can-clear=\"canClear ? '' : undefined\"\n @focusout=\"onFocusout\"\n >\n <div class=\"v-combobox-control\" @click=\"onControlClick\">\n <VInput\n ref=\"inputRef\"\n v-model=\"query\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-autocomplete=\"list\"\n :aria-expanded=\"open\"\n :aria-controls=\"optionsId\"\n v-bind=\"forwardedAttrs\"\n :size=\"size\"\n :compact=\"compact\"\n :invalid=\"invalid\"\n :disabled=\"disabled\"\n :clearable=\"clearable\"\n :clear-visible=\"canClear\"\n :clear-label=\"m.combobox.clear\"\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\" #start>\n <template v-for=\"value in selectedValues\" :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\n :dismiss-label=\"m.combobox.remove(labelOf(value))\"\n :disabled=\"disabled\"\n @dismiss=\"removeValue(value)\"\n >{{ labelOf(value) }}</VChip\n >\n </slot>\n </template>\n </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\" aria-hidden=\"true\" />\n <VIcon v-else :name=\"expandMoreIcon\" class=\"v-combobox-chevron\" aria-hidden=\"true\" />\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 placement=\"bottom-start\"\n role=\"listbox\"\n class=\"v-combobox-panel v-control\"\n :data-size=\"size\"\n :data-compact=\"compact ? '' : 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 rendered\" :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=\"rowProps(entry)\"\n @select=\"select(entry.option)\"\n @pointermove=\"hover(entry)\"\n >\n <slot name=\"option\" v-bind=\"optionSlotProps(entry)\">{{ entry.option.label }}</slot>\n </VComboboxOption>\n </VComboboxGroup>\n\n <VComboboxOption\n v-else\n v-bind=\"rowProps(node)\"\n @select=\"select(node.option)\"\n @pointermove=\"hover(node)\"\n >\n <slot name=\"option\" v-bind=\"optionSlotProps(node)\">{{ 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 anchor-name: --combobox-anchor;\n display: block;\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. What stays are the two things specific to a list: a width tied to the field\n below it, and the scrolling. */\n .v-combobox-panel {\n min-inline-size: anchor-size(width);\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 lifted out of the field's flow, so that they stay\n pinned to its end and vertically centred whatever the chips do and whether or not the\n input has folded away.\n\n The room they occupy is then reserved with padding, or the text and the chips would\n run underneath them. That reservation is written as exactly what the flow would have\n produced with them left in place — one glyph's width each from the field's padding,\n one gap between two of them — which is what keeps this field's spacing identical to\n every other field in the design system. It reads from the same two variables as the\n insets below, so the room reserved and the glyphs it protects cannot drift apart.\n\n Vertically they are centred with a translation kept SEPARATE from the rotation, since\n the chevron turns when the panel opens. */\n .v-combobox .v-input-field {\n position: relative;\n padding-inline-end: calc(\n var(--control-padding-inline-field) + var(--vectis-icon-size) + var(--control-gap)\n );\n }\n\n .v-combobox[data-can-clear] .v-input-field {\n padding-inline-end: calc(\n var(--control-padding-inline-field) + 2 * var(--vectis-icon-size) + 2 * var(--control-gap)\n );\n }\n\n /* The chevron and the spinner take turns in the same place and occupy the same box —\n the field gives a spinner among its direct children the size of an icon — so the\n padding reserved above serves both, and swapping one for the other shifts\n nothing. */\n .v-combobox-chevron,\n .v-combobox-spinner {\n position: absolute;\n inset-inline-end: var(--control-padding-inline-field);\n top: 50%;\n translate: 0 -50%;\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 /* The clear cross goes just before the chevron, centred the same way.\n\n TRAP — both insets are measured to the GLYPH's edge, and they get there by different\n routes: the chevron is a bare icon, whose box IS its glyph, while the cross is one of\n the field's buttons, whose negative margin — half the difference between icon and\n button — cancels its own overhang. Because of that the arithmetic reads directly: one\n glyph's width from the field's padding, then one gap between the two.\n\n That gap is the field's own, which is the entire point: a number written here instead\n would drift from every other field in the design system, with nothing to signal\n it. */\n .v-combobox .v-input-clear {\n position: absolute;\n inset-inline-end: calc(\n var(--control-padding-inline-field) + var(--vectis-icon-size) + var(--control-gap)\n );\n top: 50%;\n translate: 0 -50%;\n }\n\n /* With several values allowed, the field holds the chips and lets them WRAP onto\n several rows, growing instead of scrolling — but never shrinking below the height of\n an ordinary control.\n\n The chips' height is written inline by the same helper that gives them their size,\n because it belongs to their own subtree and the field cannot read it. The input is\n then forced to that SAME height rather than the full height it inherits: its natural\n height is greater than a chip's, and the field would grow the moment it was focused.\n\n The result is a field that stays exactly one control tall, an input never taller than\n the chips beside it, and no jump when the focus arrives. */\n .v-combobox[data-multiple] .v-input-field {\n flex-wrap: wrap;\n height: auto;\n min-height: var(--control-height);\n padding-block: var(--vectis-space-1);\n }\n\n .v-combobox[data-multiple] .v-input-control {\n height: var(--chip-height);\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 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\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":""}
|