vectis-ui 0.10.0 → 0.10.2
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/dist/components/VAccordion/VAccordion.js.map +1 -1
- package/dist/components/VAccordion/VAccordion.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VAccordion/VAccordionItem.d.ts +6 -21
- package/dist/components/VAccordion/VAccordionItem.js.map +1 -1
- package/dist/components/VAccordion/VAccordionItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VAccordion/context.js.map +1 -1
- package/dist/components/VAvatar/VAvatar.d.ts +2 -12
- package/dist/components/VAvatar/VAvatar.js.map +1 -1
- package/dist/components/VAvatar/VAvatar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VAvatar/VAvatarGroup.d.ts +2 -2
- package/dist/components/VAvatar/VAvatarGroup.js.map +1 -1
- package/dist/components/VAvatar/VAvatarGroup.vue_vue_type_script_setup_true_lang.js +6 -6
- package/dist/components/VAvatar/VAvatarGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VAvatar/context.d.ts +1 -5
- package/dist/components/VAvatar/context.js.map +1 -1
- package/dist/components/VBadge/VBadge.d.ts +13 -27
- package/dist/components/VBadge/VBadge.js.map +1 -1
- package/dist/components/VBadge/VBadge.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VBreadcrumb/VBreadcrumb.d.ts +3 -9
- package/dist/components/VBreadcrumb/VBreadcrumb.js.map +1 -1
- package/dist/components/VBreadcrumb/VBreadcrumb.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VButton/VButton.d.ts +10 -17
- package/dist/components/VButton/VButton.js.map +1 -1
- package/dist/components/VButton/VButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VButton/VButtonGroup.d.ts +6 -15
- package/dist/components/VButton/VButtonGroup.js.map +1 -1
- package/dist/components/VButton/VButtonGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VButton/context.d.ts +1 -9
- package/dist/components/VButton/context.js.map +1 -1
- package/dist/components/VCalendar/VCalendar.d.ts +9 -24
- package/dist/components/VCalendar/VCalendar.js.map +1 -1
- package/dist/components/VCalendar/VCalendar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCalendar/VCalendarEvent.d.ts +4 -13
- package/dist/components/VCalendar/VCalendarEvent.js.map +1 -1
- package/dist/components/VCalendar/VCalendarEvent.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCalendar/VCalendarMonth.js.map +1 -1
- package/dist/components/VCalendar/VCalendarMonth.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCalendar/VCalendarTimeGrid.d.ts +1 -5
- package/dist/components/VCalendar/VCalendarTimeGrid.js.map +1 -1
- package/dist/components/VCalendar/VCalendarTimeGrid.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCalendar/VCalendarYear.js.map +1 -1
- package/dist/components/VCalendar/VCalendarYear.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCalendar/color.d.ts +1 -7
- package/dist/components/VCalendar/color.js.map +1 -1
- package/dist/components/VCalendar/edgeStep.d.ts +5 -15
- package/dist/components/VCalendar/edgeStep.js.map +1 -1
- package/dist/components/VCalendar/gesture.d.ts +12 -36
- package/dist/components/VCalendar/gesture.js.map +1 -1
- package/dist/components/VCalendar/keyboard.d.ts +5 -42
- package/dist/components/VCalendar/keyboard.js.map +1 -1
- package/dist/components/VCalendar/layout.d.ts +38 -199
- package/dist/components/VCalendar/layout.js.map +1 -1
- package/dist/components/VCalendar/timeGrid.d.ts +3 -25
- package/dist/components/VCalendar/timeGrid.js.map +1 -1
- package/dist/components/VCalendar/types.d.ts +6 -23
- package/dist/components/VCarousel/VCarousel.d.ts +25 -96
- package/dist/components/VCarousel/VCarousel.js.map +1 -1
- package/dist/components/VCarousel/VCarousel.vue_vue_type_script_setup_true_lang.js +6 -6
- package/dist/components/VCarousel/VCarousel.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCarousel/VCarouselItem.d.ts +1 -6
- 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.js.map +1 -1
- package/dist/components/VCheckbox/VCheckbox.d.ts +1 -5
- package/dist/components/VCheckbox/VCheckbox.js.map +1 -1
- package/dist/components/VCheckbox/VCheckbox.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VChip/VChip.d.ts +2 -8
- package/dist/components/VChip/VChip.js.map +1 -1
- package/dist/components/VChip/VChip.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCombobox/VCombobox.d.ts +21 -59
- package/dist/components/VCombobox/VCombobox.js.map +1 -1
- package/dist/components/VCombobox/VCombobox.vue_vue_type_script_setup_true_lang.js +117 -119
- package/dist/components/VCombobox/VCombobox.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCombobox/VComboboxGroup.js.map +1 -1
- package/dist/components/VCombobox/VComboboxGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VCombobox/VComboboxOption.js.map +1 -1
- 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.d.ts +4 -10
- package/dist/components/VCombobox/infiniteScroll.js.map +1 -1
- package/dist/components/VDataTable/VDataTable.d.ts +11 -36
- package/dist/components/VDataTable/VDataTable.js.map +1 -1
- package/dist/components/VDataTable/VDataTable.vue_vue_type_script_setup_true_lang.js +23 -20
- package/dist/components/VDataTable/VDataTable.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VDateInput/VDateInput.d.ts +12 -21
- package/dist/components/VDateInput/VDateInput.js.map +1 -1
- package/dist/components/VDateInput/VDateInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VDateInput/mask.d.ts +14 -59
- package/dist/components/VDateInput/mask.js.map +1 -1
- package/dist/components/VDatePicker/VDatePicker.d.ts +6 -12
- package/dist/components/VDatePicker/VDatePicker.js.map +1 -1
- package/dist/components/VDatePicker/VDatePicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VDatePicker/keyboard.d.ts +10 -42
- package/dist/components/VDatePicker/keyboard.js.map +1 -1
- package/dist/components/VDatePicker/names.d.ts +8 -22
- package/dist/components/VDatePicker/names.js.map +1 -1
- package/dist/components/VDialog/VDialog.d.ts +5 -10
- package/dist/components/VDialog/VDialog.js.map +1 -1
- package/dist/components/VDialog/VDialog.vue_vue_type_script_setup_true_lang.js +51 -53
- package/dist/components/VDialog/VDialog.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VDialog/VDialogAlert.d.ts +2 -3
- package/dist/components/VDialog/VDialogAlert.js.map +1 -1
- package/dist/components/VDialog/VDialogAlert.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VFileInput/VFileInput.d.ts +11 -37
- package/dist/components/VFileInput/VFileInput.js.map +1 -1
- package/dist/components/VFileInput/VFileInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VFileInput/truncate.d.ts +3 -23
- package/dist/components/VFileInput/truncate.js.map +1 -1
- package/dist/components/VFilePicker/VFilePicker.d.ts +15 -65
- package/dist/components/VFilePicker/VFilePicker.js.map +1 -1
- package/dist/components/VFilePicker/VFilePicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VFilePicker/fileKind.js.map +1 -1
- package/dist/components/VHotkeys/VHotkeys.d.ts +6 -15
- package/dist/components/VHotkeys/VHotkeys.js.map +1 -1
- package/dist/components/VHotkeys/VHotkeys.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VHotkeys/platform.d.ts +10 -49
- package/dist/components/VHotkeys/platform.js.map +1 -1
- package/dist/components/VIcon/VIcon.d.ts +7 -19
- package/dist/components/VIcon/VIcon.js.map +1 -1
- package/dist/components/VIcon/VIcon.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VIcon/iconProps.d.ts +5 -19
- package/dist/components/VIcon/iconProps.js.map +1 -1
- package/dist/components/VIcon/resolver.d.ts +15 -43
- package/dist/components/VIcon/resolver.js.map +1 -1
- package/dist/components/VIcon/types.d.ts +7 -34
- package/dist/components/VIconButton/VIconButton.d.ts +2 -3
- package/dist/components/VIconButton/VIconButton.js.map +1 -1
- package/dist/components/VIconButton/VIconButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VInput/VInput.d.ts +14 -29
- package/dist/components/VInput/VInput.js.map +1 -1
- package/dist/components/VInput/VInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VInput/VInputGroup.js.map +1 -1
- package/dist/components/VInput/VInputGroup.vue_vue_type_script_setup_true_lang.js +34 -50
- package/dist/components/VInput/VInputGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VInput/context.js.map +1 -1
- package/dist/components/VInputOTP/VInputOTP.d.ts +8 -16
- package/dist/components/VInputOTP/VInputOTP.js.map +1 -1
- package/dist/components/VInputOTP/VInputOTP.vue_vue_type_script_setup_true_lang.js +55 -63
- package/dist/components/VInputOTP/VInputOTP.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VMenu/VMenu.js.map +1 -1
- package/dist/components/VMenu/VMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VMenu/VMenuGroup.d.ts +1 -6
- package/dist/components/VMenu/VMenuGroup.js.map +1 -1
- package/dist/components/VMenu/VMenuGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VMenu/VMenuItem.d.ts +0 -5
- package/dist/components/VMenu/VMenuItem.js.map +1 -1
- package/dist/components/VMenu/VMenuItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VMenu/VMenuPanel.d.ts +1 -6
- package/dist/components/VMenu/VMenuPanel.js.map +1 -1
- package/dist/components/VMenu/VMenuPanel.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/components/VMenu/VMenuPanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VMenu/VMenuSeparator.js.map +1 -1
- package/dist/components/VMenu/VMenuSeparator.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VMenu/context.d.ts +3 -11
- package/dist/components/VMenu/context.js.map +1 -1
- package/dist/components/VPagination/VPagination.d.ts +9 -20
- package/dist/components/VPagination/VPagination.js.map +1 -1
- package/dist/components/VPagination/VPagination.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VPopover/VPopover.d.ts +7 -18
- package/dist/components/VPopover/VPopover.js.map +1 -1
- package/dist/components/VPopover/VPopover.vue_vue_type_script_setup_true_lang.js +23 -27
- package/dist/components/VPopover/VPopover.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VProgressCircular/VProgressCircular.d.ts +2 -6
- package/dist/components/VProgressCircular/VProgressCircular.js.map +1 -1
- package/dist/components/VProgressCircular/VProgressCircular.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VProgressLinear/VProgressLinear.d.ts +4 -15
- package/dist/components/VProgressLinear/VProgressLinear.js.map +1 -1
- package/dist/components/VProgressLinear/VProgressLinear.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VRadio/VRadio.d.ts +1 -5
- package/dist/components/VRadio/VRadio.js.map +1 -1
- package/dist/components/VRadio/VRadio.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSeparator/VSeparator.d.ts +2 -15
- package/dist/components/VSeparator/VSeparator.js.map +1 -1
- package/dist/components/VSeparator/VSeparator.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSideNavigation/VSideNavigation.d.ts +1 -1
- package/dist/components/VSideNavigation/VSideNavigation.js.map +1 -1
- package/dist/components/VSideNavigation/VSideNavigation.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSideNavigation/VSideNavigationGroup.d.ts +1 -5
- package/dist/components/VSideNavigation/VSideNavigationGroup.js.map +1 -1
- package/dist/components/VSideNavigation/VSideNavigationGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSideNavigation/VSideNavigationItem.d.ts +1 -5
- package/dist/components/VSideNavigation/VSideNavigationItem.js.map +1 -1
- package/dist/components/VSideNavigation/VSideNavigationItem.vue_vue_type_script_setup_true_lang.js +80 -75
- package/dist/components/VSideNavigation/VSideNavigationItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSideNavigation/VSideNavigationSeparator.js.map +1 -1
- package/dist/components/VSideNavigation/context.js.map +1 -1
- package/dist/components/VSkeletonLoader/VSkeletonLoader.d.ts +6 -19
- 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.d.ts +5 -13
- package/dist/components/VSlider/VSlider.js.map +1 -1
- package/dist/components/VSlider/VSlider.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSnackbar/VSnackbar.js.map +1 -1
- package/dist/components/VSnackbar/VSnackbar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSnackbar/state.d.ts +4 -17
- package/dist/components/VSnackbar/state.js.map +1 -1
- package/dist/components/VSpinner/VSpinner.d.ts +3 -5
- package/dist/components/VSpinner/VSpinner.js.map +1 -1
- package/dist/components/VSpinner/VSpinner.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VSwitch/VSwitch.js.map +1 -1
- package/dist/components/VSwitch/VSwitch.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTabs/VTab.d.ts +1 -5
- package/dist/components/VTabs/VTab.js.map +1 -1
- package/dist/components/VTabs/VTab.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTabs/VTabPanel.js.map +1 -1
- package/dist/components/VTabs/VTabPanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTabs/VTabs.d.ts +5 -17
- package/dist/components/VTabs/VTabs.js.map +1 -1
- package/dist/components/VTabs/VTabs.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTabs/context.js.map +1 -1
- package/dist/components/VTextarea/VTextarea.d.ts +13 -20
- package/dist/components/VTextarea/VTextarea.js.map +1 -1
- package/dist/components/VTextarea/VTextarea.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTimeInput/VTimeInput.d.ts +8 -21
- package/dist/components/VTimeInput/VTimeInput.js.map +1 -1
- package/dist/components/VTimeInput/VTimeInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTimeInput/search.d.ts +3 -34
- package/dist/components/VTimeInput/search.js.map +1 -1
- package/dist/components/VTimePicker/VTimePicker.d.ts +9 -31
- package/dist/components/VTimePicker/VTimePicker.js.map +1 -1
- package/dist/components/VTimePicker/VTimePicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTimePicker/limits.d.ts +18 -45
- package/dist/components/VTimePicker/limits.js.map +1 -1
- package/dist/components/VToast/VToast.js.map +1 -1
- package/dist/components/VToast/VToast.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VToast/VToaster.js.map +1 -1
- package/dist/components/VToast/VToaster.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VToast/state.d.ts +2 -7
- package/dist/components/VToast/state.js.map +1 -1
- package/dist/components/VToggle/VToggle.d.ts +5 -9
- package/dist/components/VToggle/VToggle.js.map +1 -1
- package/dist/components/VToggle/VToggle.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VToggle/VToggleItem.d.ts +1 -9
- package/dist/components/VToggle/VToggleItem.js.map +1 -1
- package/dist/components/VToggle/VToggleItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VToggle/context.js.map +1 -1
- package/dist/components/VTooltip/VTooltip.d.ts +3 -16
- package/dist/components/VTooltip/VTooltip.js.map +1 -1
- package/dist/components/VTooltip/VTooltip.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/components/VTooltip/VTooltip.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/VTypography/VTypography.d.ts +4 -8
- package/dist/components/VTypography/VTypography.js.map +1 -1
- package/dist/components/VTypography/VTypography.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/composables/useAriaLabel.js.map +1 -1
- package/dist/composables/useClearable.d.ts +2 -8
- package/dist/composables/useClearable.js.map +1 -1
- package/dist/composables/useControlShape.js.map +1 -1
- package/dist/composables/useDetailsOpen.d.ts +2 -10
- package/dist/composables/useDetailsOpen.js.map +1 -1
- package/dist/composables/useFieldIds.js.map +1 -1
- package/dist/composables/useFieldPanel.d.ts +4 -17
- package/dist/composables/useFieldPanel.js.map +1 -1
- package/dist/composables/useFileDrop.js.map +1 -1
- package/dist/composables/useFileField.d.ts +1 -5
- package/dist/composables/useFileField.js.map +1 -1
- package/dist/composables/useFocusoutDismiss.js.map +1 -1
- package/dist/composables/useIconClickHandlers.d.ts +4 -19
- package/dist/composables/useIconClickHandlers.js.map +1 -1
- package/dist/composables/useInertLink.d.ts +1 -1
- package/dist/composables/useInertLink.js.map +1 -1
- package/dist/composables/useLiveAnnouncer.js.map +1 -1
- package/dist/composables/useMaskedField.d.ts +12 -27
- package/dist/composables/useMaskedField.js.map +1 -1
- package/dist/composables/usePopover.d.ts +3 -11
- package/dist/composables/usePopover.js.map +1 -1
- package/dist/composables/useProgressValue.js.map +1 -1
- package/dist/composables/useRootAttrs.d.ts +0 -9
- package/dist/composables/useRootAttrs.js +11 -4
- package/dist/composables/useRootAttrs.js.map +1 -1
- package/dist/composables/useSlotNodes.d.ts +3 -14
- package/dist/composables/useSlotNodes.js.map +1 -1
- package/dist/composables/useTextLimit.d.ts +4 -16
- package/dist/composables/useTextLimit.js.map +1 -1
- package/dist/composables/useTimer.d.ts +2 -15
- package/dist/composables/useTimer.js.map +1 -1
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/fr.js.map +1 -1
- package/dist/i18n/state.d.ts +9 -38
- package/dist/i18n/state.js.map +1 -1
- package/dist/i18n/types.d.ts +19 -81
- package/dist/icons.d.ts +2 -12
- package/dist/styles.css +1 -1
- package/dist/tokens/css.d.ts +3 -16
- package/dist/tokens/css.js.map +1 -1
- package/dist/tokens/index.d.ts +5 -0
- package/dist/tokens/index.js.map +1 -1
- package/dist/tokens/primitives.js.map +1 -1
- package/dist/tokens/semantic.d.ts +6 -23
- package/dist/tokens/semantic.js +5 -0
- package/dist/tokens/semantic.js.map +1 -1
- package/dist/tokens/themes/dark.js.map +1 -1
- package/dist/tokens/types.d.ts +2 -12
- package/dist/tokens/types.js.map +1 -1
- package/dist/tokens.json +14 -0
- package/dist/types.d.ts +3 -21
- package/dist/utils/array.d.ts +2 -4
- package/dist/utils/array.js.map +1 -1
- package/dist/utils/arrowNav.d.ts +2 -26
- package/dist/utils/arrowNav.js.map +1 -1
- package/dist/utils/chip.d.ts +1 -8
- package/dist/utils/chip.js.map +1 -1
- package/dist/utils/clock.d.ts +16 -39
- package/dist/utils/clock.js.map +1 -1
- package/dist/utils/css.d.ts +5 -16
- package/dist/utils/css.js.map +1 -1
- package/dist/utils/date.d.ts +17 -60
- package/dist/utils/date.js.map +1 -1
- package/dist/utils/direction.d.ts +2 -9
- package/dist/utils/direction.js.map +1 -1
- package/dist/utils/env.d.ts +2 -15
- package/dist/utils/env.js.map +1 -1
- package/dist/utils/file.d.ts +8 -46
- package/dist/utils/file.js.map +1 -1
- package/dist/utils/focus.d.ts +1 -14
- package/dist/utils/focus.js +1 -6
- package/dist/utils/focus.js.map +1 -1
- package/dist/utils/hostWarns.d.ts +3 -8
- package/dist/utils/hostWarns.js.map +1 -1
- package/dist/utils/ids.d.ts +2 -7
- package/dist/utils/ids.js.map +1 -1
- package/dist/utils/matcher.d.ts +1 -8
- package/dist/utils/matcher.js.map +1 -1
- package/dist/utils/memo.d.ts +1 -11
- package/dist/utils/memo.js.map +1 -1
- package/dist/utils/number.d.ts +1 -7
- package/dist/utils/number.js.map +1 -1
- package/dist/utils/text.d.ts +4 -23
- package/dist/utils/text.js.map +1 -1
- package/dist/utils/time.d.ts +4 -12
- package/dist/utils/time.js.map +1 -1
- package/dist/utils/vnode.d.ts +0 -10
- package/dist/utils/vnode.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VAccordion.js","names":[],"sources":["../../../src/components/VAccordion/VAccordion.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n *
|
|
1
|
+
{"version":3,"file":"VAccordion.js","names":[],"sources":["../../../src/components/VAccordion/VAccordion.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * Native details elements own disclosure and exclusive groups; multiple removes the shared\n * group name.\n */\n\nimport { provide, useId } from 'vue'\n\nimport { expand_more as expandMoreIcon } from '../VIcon/icons/expand_more'\nimport type { IconSource } from '../VIcon/types'\n\nimport { accordionKey } from './context'\n\n/** How much decoration the block carries. */\nexport type AccordionVariant = 'flat' | 'outlined'\n\ninterface AccordionProps {\n /**\n * Lets the reader keep several sections open at once. Left out, only one may stay\n * open and opening one closes the previous one, which the browser does on its own\n * once every item shares the same `<details>` name.\n */\n multiple?: boolean\n /**\n * How the group is decorated. `flat`, the default, draws nothing and lets the\n * accordion sit directly on the surface behind it; `outlined` gives it a raised\n * background, a border and rounded corners, so it reads as a card.\n */\n variant?: AccordionVariant\n /**\n * The icon shown on a closed item: an icon name, or an explicit `{ src }` /\n * `{ component }`. It is a chevron by default, which rotates by 180° when the\n * item opens.\n */\n expandIcon?: IconSource\n /**\n * The icon shown on an open item. Leave it out and the `expandIcon` is simply\n * rotated 180°; provide one and the two icons are swapped instead.\n */\n collapseIcon?: IconSource\n /**\n * Reduced density: every padding loses 4px, while the text and the icons keep\n * their size.\n */\n compact?: boolean\n}\n\nconst props = withDefaults(defineProps<AccordionProps>(), {\n multiple: false,\n variant: 'flat',\n expandIcon: () => expandMoreIcon,\n collapseIcon: undefined,\n compact: false,\n})\n\ndefineSlots<{\n /** The `<VAccordionItem>`s that make up the group. */\n default(): unknown\n}>()\n\nconst groupName = useId()\nprovide(accordionKey, {\n get name() {\n return props.multiple ? undefined : groupName\n },\n get expandIcon() {\n return props.expandIcon\n },\n get collapseIcon() {\n return props.collapseIcon\n },\n})\n</script>\n\n<template>\n <div class=\"v-accordion\" :data-variant=\"variant\" :data-compact=\"compact ? '' : undefined\">\n <slot />\n </div>\n</template>\n\n<style>\n@layer vectis.components {\n .v-accordion {\n --accordion-pad-delta: 0px;\n --accordion-pad-block: calc(var(--vectis-space-4) - var(--accordion-pad-delta));\n --accordion-pad-inline: calc(var(--vectis-space-5) - var(--accordion-pad-delta));\n --accordion-content-pad-start: calc(var(--vectis-space-2) - var(--accordion-pad-delta));\n\n font-family: var(--vectis-text-family);\n }\n\n .v-accordion[data-compact] {\n --accordion-pad-delta: var(--vectis-space-1);\n }\n\n .v-accordion[data-variant='outlined'] {\n --accordion-corner-radius: calc(var(--vectis-radius-surface) - 1px);\n\n background: var(--vectis-color-surface-raised);\n border: 1px solid var(--vectis-color-border);\n border-radius: var(--vectis-radius-surface);\n /* The clip is what keeps the first and last rows' hover inside the rounded corners, so\n it belongs to the variant that HAS corners. `clip` and not `hidden`: `hidden` makes\n the box a scroll container, which captures every `position: sticky` in the content\n and pins it to the accordion instead of the page. */\n overflow: clip;\n }\n}\n</style>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VAccordion.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../../src/components/VAccordion/VAccordion.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n *
|
|
1
|
+
{"version":3,"file":"VAccordion.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../../src/components/VAccordion/VAccordion.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * Native details elements own disclosure and exclusive groups; multiple removes the shared\n * group name.\n */\n\nimport { provide, useId } from 'vue'\n\nimport { expand_more as expandMoreIcon } from '../VIcon/icons/expand_more'\nimport type { IconSource } from '../VIcon/types'\n\nimport { accordionKey } from './context'\n\n/** How much decoration the block carries. */\nexport type AccordionVariant = 'flat' | 'outlined'\n\ninterface AccordionProps {\n /**\n * Lets the reader keep several sections open at once. Left out, only one may stay\n * open and opening one closes the previous one, which the browser does on its own\n * once every item shares the same `<details>` name.\n */\n multiple?: boolean\n /**\n * How the group is decorated. `flat`, the default, draws nothing and lets the\n * accordion sit directly on the surface behind it; `outlined` gives it a raised\n * background, a border and rounded corners, so it reads as a card.\n */\n variant?: AccordionVariant\n /**\n * The icon shown on a closed item: an icon name, or an explicit `{ src }` /\n * `{ component }`. It is a chevron by default, which rotates by 180° when the\n * item opens.\n */\n expandIcon?: IconSource\n /**\n * The icon shown on an open item. Leave it out and the `expandIcon` is simply\n * rotated 180°; provide one and the two icons are swapped instead.\n */\n collapseIcon?: IconSource\n /**\n * Reduced density: every padding loses 4px, while the text and the icons keep\n * their size.\n */\n compact?: boolean\n}\n\nconst props = withDefaults(defineProps<AccordionProps>(), {\n multiple: false,\n variant: 'flat',\n expandIcon: () => expandMoreIcon,\n collapseIcon: undefined,\n compact: false,\n})\n\ndefineSlots<{\n /** The `<VAccordionItem>`s that make up the group. */\n default(): unknown\n}>()\n\nconst groupName = useId()\nprovide(accordionKey, {\n get name() {\n return props.multiple ? undefined : groupName\n },\n get expandIcon() {\n return props.expandIcon\n },\n get collapseIcon() {\n return props.collapseIcon\n },\n})\n</script>\n\n<template>\n <div class=\"v-accordion\" :data-variant=\"variant\" :data-compact=\"compact ? '' : undefined\">\n <slot />\n </div>\n</template>\n\n<style>\n@layer vectis.components {\n .v-accordion {\n --accordion-pad-delta: 0px;\n --accordion-pad-block: calc(var(--vectis-space-4) - var(--accordion-pad-delta));\n --accordion-pad-inline: calc(var(--vectis-space-5) - var(--accordion-pad-delta));\n --accordion-content-pad-start: calc(var(--vectis-space-2) - var(--accordion-pad-delta));\n\n font-family: var(--vectis-text-family);\n }\n\n .v-accordion[data-compact] {\n --accordion-pad-delta: var(--vectis-space-1);\n }\n\n .v-accordion[data-variant='outlined'] {\n --accordion-corner-radius: calc(var(--vectis-radius-surface) - 1px);\n\n background: var(--vectis-color-surface-raised);\n border: 1px solid var(--vectis-color-border);\n border-radius: var(--vectis-radius-surface);\n /* The clip is what keeps the first and last rows' hover inside the rounded corners, so\n it belongs to the variant that HAS corners. `clip` and not `hidden`: `hidden` makes\n the box a scroll container, which captures every `position: sticky` in the content\n and pins it to the accordion instead of the page. */\n overflow: clip;\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EA+CA,IAAM,IAAQ,GAaR,IAAY,EAAM;SACxB,EAAQ,GAAc;GACpB,IAAI,OAAO;IACT,OAAO,EAAM,WAAW,KAAA,IAAY;GACtC;GACA,IAAI,aAAa;IACf,OAAO,EAAM;GACf;GACA,IAAI,eAAe;IACjB,OAAO,EAAM;GACf;EACF,CAAC,mBAIC,EAEM,OAAA;GAFD,OAAM;GAAe,gBAAc,EAAA;GAAU,gBAAc,EAAA,UAAO,KAAQ,KAAA;MAC7E,EAAQ,EAAA,QAAA,SAAA,CAAA,GAAA,GAAA,CAAA"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { IconSource } from '../VIcon/types.js';
|
|
2
2
|
interface AccordionItemProps {
|
|
3
3
|
/**
|
|
4
|
-
* The heading of the section, the line that stays visible when it is closed. Use
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Note that this prop shadows the HTML attribute of the same name on the component,
|
|
8
|
-
* so no tooltip can be set through it.
|
|
4
|
+
* The heading of the section, the line that stays visible when it is closed. Use the `#title`
|
|
5
|
+
* slot instead when the heading needs markup rather than plain text.
|
|
9
6
|
*/
|
|
10
7
|
title?: string;
|
|
11
8
|
/**
|
|
@@ -14,25 +11,13 @@ interface AccordionItemProps {
|
|
|
14
11
|
*/
|
|
15
12
|
subtitle?: string;
|
|
16
13
|
/**
|
|
17
|
-
* An icon placed before the title: an icon name, or an explicit render
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* It carries no side in its name because there is only one: the end of the row belongs
|
|
21
|
-
* to the chevron, so there is nothing for a start to be told apart from. That is the
|
|
22
|
-
* rule every single-icon component of the design system follows, and its slot is named
|
|
23
|
-
* `#icon` for the same reason.
|
|
14
|
+
* An icon placed before the title: an icon name, or an explicit render (`{ src }`,
|
|
15
|
+
* `{ component }`…). The `#icon` slot replaces it.
|
|
24
16
|
*/
|
|
25
17
|
icon?: IconSource;
|
|
26
|
-
/**
|
|
27
|
-
* Renders the section already open. Only its initial value is read: the browser
|
|
28
|
-
* owns the state afterwards, so changing this prop later will not close a section
|
|
29
|
-
* the reader has opened. Bind `v-model:open` to drive it instead.
|
|
30
|
-
*/
|
|
18
|
+
/** Renders the section already open. Bind `v-model:open` to drive it instead. */
|
|
31
19
|
defaultOpen?: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Makes the section inert. It can no longer be opened, the keyboard skips over
|
|
34
|
-
* it, and it is greyed out through the colour tokens.
|
|
35
|
-
*/
|
|
20
|
+
/** Makes the section inert. */
|
|
36
21
|
disabled?: boolean;
|
|
37
22
|
}
|
|
38
23
|
type __VLS_Props = AccordionItemProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VAccordionItem.js","names":[],"sources":["../../../src/components/VAccordion/VAccordionItem.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n *
|
|
1
|
+
{"version":3,"file":"VAccordionItem.js","names":[],"sources":["../../../src/components/VAccordion/VAccordionItem.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * Native details owns disclosure. useDetailsOpen bridges v-model and cancels activation of\n * disabled summaries.\n */\n\nimport { computed, inject, provide } from 'vue'\n\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 VTypography from '../VTypography/VTypography.vue'\nimport { accordionKey } from './context'\n\nimport { useDetailsOpen } from '../../composables/useDetailsOpen'\n\ninterface AccordionItemProps {\n /**\n * The heading of the section, the line that stays visible when it is closed. Use the `#title`\n * slot instead when the heading needs markup rather than plain text.\n */\n title?: string\n /**\n * A secondary line under the title, for a short explanation or a status. The\n * `#subtitle` slot replaces it when markup is needed.\n */\n subtitle?: string\n /**\n * An icon placed before the title: an icon name, or an explicit render (`{ src }`,\n * `{ component }`…). The `#icon` slot replaces it.\n */\n icon?: IconSource\n /** Renders the section already open. Bind `v-model:open` to drive it instead. */\n defaultOpen?: boolean\n /** Makes the section inert. */\n disabled?: boolean\n}\n\nconst props = withDefaults(defineProps<AccordionItemProps>(), {\n title: undefined,\n subtitle: undefined,\n icon: undefined,\n defaultOpen: false,\n disabled: false,\n})\n\n// \"not bound\" is written as `null` and not `undefined`. A model typed as a plain boolean is\n// declared as such at runtime, and Vue casts an ABSENT boolean prop to `false`, which would\n// silently overwrite `defaultOpen`.\n/**\n * Whether the section is open, when the consumer wants to drive or observe it. Left\n * unbound, the browser keeps that state to itself, `defaultOpen` giving only the initial\n * value. `null` means unbound.\n */\nconst open = defineModel<boolean | null>('open', { default: null })\n\ndefineSlots<{\n /** The content revealed when the section is open. */\n default(): unknown\n /** A title made of markup, which replaces the `title` prop. */\n title?(): unknown\n /** A subtitle made of markup, which replaces the `subtitle` prop. */\n subtitle?(): unknown\n /** Free content before the title, which takes the place of `icon`. */\n icon?(): unknown\n}>()\n\nconst accordion = inject(accordionKey, null)\n// The group stops here: an item nested in this one's content without a VAccordion of its\n// own would otherwise share this group's name, and the browser closes every other member\n// of a name group when one opens, the section holding it included.\nprovide(accordionKey, null)\n\n/**\n * Both icons are chosen on the enclosing group. The chevron fallback is what keeps\n * an item rendering correctly when it is used outside a VAccordion.\n */\nconst expandIcon = computed(() => accordion?.expandIcon ?? expandMoreIcon)\nconst collapseIcon = computed(() => accordion?.collapseIcon)\n\nconst { openAttr, onToggle, onSummaryClick } = useDetailsOpen(open, {\n defaultOpen: () => props.defaultOpen,\n disabled: () => props.disabled,\n})\n</script>\n\n<template>\n <details\n class=\"v-accordion-item v-disclosure\"\n :name=\"accordion?.name\"\n :open=\"openAttr\"\n :data-swap=\"collapseIcon ? '' : undefined\"\n @toggle=\"onToggle\"\n >\n <summary\n class=\"v-accordion-summary\"\n :data-disabled=\"disabled ? '' : undefined\"\n :aria-disabled=\"disabled || undefined\"\n :tabindex=\"disabled ? -1 : undefined\"\n @click=\"onSummaryClick\"\n >\n <slot name=\"icon\">\n <VIcon v-if=\"icon\" class=\"v-accordion-icon\" v-bind=\"iconProps(icon)\" />\n </slot>\n <span class=\"v-accordion-heading\">\n <span class=\"v-accordion-title\"\n ><slot name=\"title\">{{ title }}</slot></span\n >\n <VTypography\n v-if=\"subtitle !== undefined || $slots.subtitle\"\n as=\"span\"\n variant=\"caption\"\n tone=\"muted\"\n class=\"v-accordion-subtitle\"\n ><slot name=\"subtitle\">{{ subtitle }}</slot></VTypography\n >\n </span>\n <VIcon class=\"v-accordion-chevron v-disclosure-chevron\" v-bind=\"iconProps(expandIcon)\" />\n <VIcon\n v-if=\"collapseIcon\"\n class=\"v-accordion-chevron v-accordion-chevron-open v-disclosure-chevron v-disclosure-chevron-open\"\n v-bind=\"iconProps(collapseIcon)\"\n />\n </summary>\n <div class=\"v-accordion-content\">\n <slot />\n </div>\n </details>\n</template>\n\n<style>\n@layer vectis.components {\n .v-accordion-item + .v-accordion-item {\n border-block-start: 1px solid var(--vectis-color-border);\n }\n\n .v-accordion-summary {\n --vectis-icon-size: var(--vectis-icon-size-md);\n --vectis-icon-opsz: 20;\n\n display: flex;\n align-items: center;\n gap: var(--vectis-space-3);\n padding: var(--accordion-pad-block, var(--vectis-space-4))\n var(--accordion-pad-inline, var(--vectis-space-5));\n cursor: pointer;\n font-size: var(--vectis-text-label-size);\n font-weight: var(--vectis-text-label-weight);\n color: var(--vectis-color-text);\n }\n\n .v-accordion-summary:hover:not([data-disabled]) {\n background: var(--vectis-color-surface-muted);\n }\n\n .v-accordion-summary: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 .v-accordion-item:first-child > .v-accordion-summary {\n border-start-start-radius: var(--accordion-corner-radius, 0);\n border-start-end-radius: var(--accordion-corner-radius, 0);\n }\n\n .v-accordion-item:last-child:not([open]) > .v-accordion-summary {\n border-end-start-radius: var(--accordion-corner-radius, 0);\n border-end-end-radius: var(--accordion-corner-radius, 0);\n }\n\n .v-accordion-heading {\n flex: 1;\n display: flex;\n flex-direction: column;\n line-height: var(--vectis-text-label-leading);\n }\n\n .v-accordion-icon {\n flex: none;\n color: var(--vectis-color-text-muted);\n }\n\n /* A disabled item greys out through the colour tokens and never through\n `opacity`, the rule every control in the DS follows. */\n .v-accordion-summary[data-disabled] {\n color: var(--vectis-color-text-subtle);\n cursor: not-allowed;\n }\n\n /* The icon and the subtitle default to text-muted, which is DARKER than the\n text-subtle a disabled title takes: left to themselves they would come out\n stronger than the label they belong to, so they inherit it instead. The chevron\n gets the same treatment from `styles/disclosure.css`. */\n .v-accordion-summary[data-disabled] .v-accordion-icon,\n .v-accordion-summary[data-disabled] .v-accordion-subtitle {\n color: inherit;\n }\n\n .v-accordion-content {\n padding: var(--accordion-content-pad-start, var(--vectis-space-2))\n var(--accordion-pad-inline, var(--vectis-space-5))\n var(--accordion-pad-block, var(--vectis-space-4));\n font-size: var(--vectis-text-body-md-size);\n line-height: var(--vectis-text-body-md-leading);\n color: var(--vectis-color-text-muted);\n }\n\n /* The disclosure animation, the chevron's rotation or swap and the WebKit marker come\n from `styles/disclosure.css`, reduced-motion block included. */\n}\n</style>\n"],"mappings":""}
|
package/dist/components/VAccordion/VAccordionItem.vue_vue_type_script_setup_true_lang.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VAccordionItem.vue_vue_type_script_setup_true_lang.js","names":["$slots"],"sources":["../../../src/components/VAccordion/VAccordionItem.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * One section of an accordion: a heading the reader can click, and the content it\n * reveals. It is a native `<details>`/`<summary>` pair, so the browser owns the\n * open and closed state, the keyboard and the accessibility semantics. The only JS\n * is the `v-model:open` bridge, fed by the element, and the click a disabled summary\n * has to cancel, both shared with VSideNavigationItem through `useDetailsOpen`.\n *\n * The opening is animated entirely in CSS, with `::details-content` and\n * `interpolate-size` (`styles/disclosure.css`). Both are recent additions to the\n * language: where they are missing the section simply appears at once, which is the\n * intended fallback.\n */\n\nimport { computed, inject, provide } from 'vue'\n\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 VTypography from '../VTypography/VTypography.vue'\nimport { accordionKey } from './context'\n\nimport { useDetailsOpen } from '../../composables/useDetailsOpen'\n\ninterface AccordionItemProps {\n /**\n * The heading of the section, the line that stays visible when it is closed. Use\n * the `#title` slot instead when the heading needs markup rather than plain text.\n *\n * Note that this prop shadows the HTML attribute of the same name on the component,\n * so no tooltip can be set through it.\n */\n title?: string\n /**\n * A secondary line under the title, for a short explanation or a status. The\n * `#subtitle` slot replaces it when markup is needed.\n */\n subtitle?: string\n /**\n * An icon placed before the title: an icon name, or an explicit render\n * (`{ src }`, `{ component }`…). The `#icon` slot replaces it.\n *\n * It carries no side in its name because there is only one: the end of the row belongs\n * to the chevron, so there is nothing for a start to be told apart from. That is the\n * rule every single-icon component of the design system follows, and its slot is named\n * `#icon` for the same reason.\n */\n icon?: IconSource\n /**\n * Renders the section already open. Only its initial value is read: the browser\n * owns the state afterwards, so changing this prop later will not close a section\n * the reader has opened. Bind `v-model:open` to drive it instead.\n */\n defaultOpen?: boolean\n /**\n * Makes the section inert. It can no longer be opened, the keyboard skips over\n * it, and it is greyed out through the colour tokens.\n */\n disabled?: boolean\n}\n\nconst props = withDefaults(defineProps<AccordionItemProps>(), {\n title: undefined,\n subtitle: undefined,\n icon: undefined,\n defaultOpen: false,\n disabled: false,\n})\n\n// TRAP — \"not bound\" is written as `null` and not `undefined`. A model typed as a plain\n// boolean is declared as such at runtime, and Vue casts an ABSENT boolean prop to `false`,\n// which would silently overwrite `defaultOpen`. The explicit default disarms that cast.\n/**\n * Whether the section is open, when the consumer wants to drive or observe it. Left\n * unbound, the browser keeps that state to itself, `defaultOpen` giving only the initial\n * value. `null` means unbound.\n */\nconst open = defineModel<boolean | null>('open', { default: null })\n\ndefineSlots<{\n /** The content revealed when the section is open. */\n default(): unknown\n /** A title made of markup, which replaces the `title` prop. */\n title?(): unknown\n /** A subtitle made of markup, which replaces the `subtitle` prop. */\n subtitle?(): unknown\n /** Free content before the title, which takes the place of `icon`. */\n icon?(): unknown\n}>()\n\nconst accordion = inject(accordionKey, null)\n// The group stops here: an item nested in this one's content without a VAccordion of its\n// own would otherwise share this group's name, and the browser closes every other member\n// of a name group when one opens, the section holding it included.\nprovide(accordionKey, null)\n\n/**\n * Both icons are chosen on the enclosing group. The chevron fallback is what keeps\n * an item rendering correctly when it is used outside a VAccordion.\n */\nconst expandIcon = computed(() => accordion?.expandIcon ?? expandMoreIcon)\nconst collapseIcon = computed(() => accordion?.collapseIcon)\n\nconst { openAttr, onToggle, onSummaryClick } = useDetailsOpen(open, {\n defaultOpen: () => props.defaultOpen,\n disabled: () => props.disabled,\n})\n</script>\n\n<template>\n <details\n class=\"v-accordion-item v-disclosure\"\n :name=\"accordion?.name\"\n :open=\"openAttr\"\n :data-swap=\"collapseIcon ? '' : undefined\"\n @toggle=\"onToggle\"\n >\n <summary\n class=\"v-accordion-summary\"\n :data-disabled=\"disabled ? '' : undefined\"\n :aria-disabled=\"disabled || undefined\"\n :tabindex=\"disabled ? -1 : undefined\"\n @click=\"onSummaryClick\"\n >\n <slot name=\"icon\">\n <VIcon v-if=\"icon\" class=\"v-accordion-icon\" v-bind=\"iconProps(icon)\" />\n </slot>\n <span class=\"v-accordion-heading\">\n <span class=\"v-accordion-title\"\n ><slot name=\"title\">{{ title }}</slot></span\n >\n <VTypography\n v-if=\"subtitle !== undefined || $slots.subtitle\"\n as=\"span\"\n variant=\"caption\"\n tone=\"muted\"\n class=\"v-accordion-subtitle\"\n ><slot name=\"subtitle\">{{ subtitle }}</slot></VTypography\n >\n </span>\n <VIcon class=\"v-accordion-chevron v-disclosure-chevron\" v-bind=\"iconProps(expandIcon)\" />\n <!-- Both icons are always in the DOM; [open] decides which one shows, in CSS alone -->\n <VIcon\n v-if=\"collapseIcon\"\n class=\"v-accordion-chevron v-accordion-chevron-open v-disclosure-chevron v-disclosure-chevron-open\"\n v-bind=\"iconProps(collapseIcon)\"\n />\n </summary>\n <div class=\"v-accordion-content\">\n <slot />\n </div>\n </details>\n</template>\n\n<style>\n@layer vectis.components {\n .v-accordion-item + .v-accordion-item {\n border-block-start: 1px solid var(--vectis-color-border);\n }\n\n .v-accordion-summary {\n --vectis-icon-size: var(--vectis-icon-size-md);\n --vectis-icon-opsz: 20;\n\n display: flex;\n align-items: center;\n gap: var(--vectis-space-3);\n padding: var(--accordion-pad-block, var(--vectis-space-4))\n var(--accordion-pad-inline, var(--vectis-space-5));\n cursor: pointer;\n font-size: var(--vectis-text-label-size);\n font-weight: var(--vectis-text-label-weight);\n color: var(--vectis-color-text);\n }\n\n .v-accordion-summary:hover:not([data-disabled]) {\n background: var(--vectis-color-surface-muted);\n }\n\n .v-accordion-summary: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 .v-accordion-item:first-child > .v-accordion-summary {\n border-start-start-radius: var(--accordion-corner-radius, 0);\n border-start-end-radius: var(--accordion-corner-radius, 0);\n }\n\n .v-accordion-item:last-child:not([open]) > .v-accordion-summary {\n border-end-start-radius: var(--accordion-corner-radius, 0);\n border-end-end-radius: var(--accordion-corner-radius, 0);\n }\n\n .v-accordion-heading {\n flex: 1;\n display: flex;\n flex-direction: column;\n line-height: var(--vectis-text-label-leading);\n }\n\n .v-accordion-icon {\n flex: none;\n color: var(--vectis-color-text-muted);\n }\n\n /* A disabled item greys out through the colour tokens and never through\n `opacity`, the rule every control in the DS follows. */\n .v-accordion-summary[data-disabled] {\n color: var(--vectis-color-text-subtle);\n cursor: not-allowed;\n }\n\n /* The icon and the subtitle default to text-muted, which is DARKER than the\n text-subtle a disabled title takes: left to themselves they would come out\n stronger than the label they belong to, so they inherit it instead. The chevron\n gets the same treatment from `styles/disclosure.css`. */\n .v-accordion-summary[data-disabled] .v-accordion-icon,\n .v-accordion-summary[data-disabled] .v-accordion-subtitle {\n color: inherit;\n }\n\n .v-accordion-content {\n padding: var(--accordion-content-pad-start, var(--vectis-space-2))\n var(--accordion-pad-inline, var(--vectis-space-5))\n var(--accordion-pad-block, var(--vectis-space-4));\n font-size: var(--vectis-text-body-md-size);\n line-height: var(--vectis-text-body-md-leading);\n color: var(--vectis-color-text-muted);\n }\n\n /* The disclosure animation, the chevron's rotation or swap and the WebKit marker come\n from `styles/disclosure.css`, reduced-motion block included. */\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8DA,IAAM,IAAQ,GAgBR,IAAO,EAA2B,GAAC,MAAyB,GAa5D,IAAY,EAAO,GAAc,IAAI;EAI3C,EAAQ,GAAc,IAAI;EAM1B,IAAM,IAAa,QAAe,GAAW,cAAc,CAAc,GACnE,IAAe,QAAe,GAAW,YAAY,GAErD,EAAE,aAAU,aAAU,sBAAmB,EAAe,GAAM;GAClE,mBAAmB,EAAM;GACzB,gBAAgB,EAAM;EACxB,CAAC;yBAIC,EAyCU,WAAA;GAxCR,OAAM;GACL,MAAM,EAAA,CAAA,CAAS,EAAE;GACjB,MAAM,EAAA,CAAA;GACN,aAAW,EAAA,QAAY,KAAQ,KAAA;GAC/B,UAAM,AAAA,EAAA,QAAA,GAAA,MAAE,EAAA,CAAA,KAAA,EAAA,CAAA,CAAA,CAAA,GAAA,CAAA;MAET,EA8BU,WAAA;GA7BR,OAAM;GACL,iBAAe,EAAA,WAAQ,KAAQ,KAAA;GAC/B,iBAAe,EAAA,YAAY,KAAA;GAC3B,UAAU,EAAA,WAAQ,KAAQ,KAAA;GAC1B,SAAK,AAAA,EAAA,QAAA,GAAA,MAAE,EAAA,CAAA,KAAA,EAAA,CAAA,CAAA,CAAA,GAAA,CAAA;;GAER,EAEO,EAAA,QAAA,QAAA,CAAA,SAAA,CADQ,EAAA,QAAA,EAAA,GAAb,EAAuE,GAAvE,EAAuE;;IAApD,OAAM;MAA2B,EAAA,CAAA,CAAS,CAAC,EAAA,IAAI,CAAA,GAAA,MAAA,EAAA,KAAA,EAAA,IAAA,EAAA,CAAA,CAAA;GAEpE,EAYO,QAZP,GAYO,CAXL,EAEC,QAFD,GAEC,CADE,EAAqC,EAAA,QAAA,SAAA,CAAA,SAAA,CAAA,EAAA,EAAf,EAAA,KAAK,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAGtB,EAAA,aAAa,KAAA,KAAaA,EAAAA,OAAO,YAAA,EAAA,GADzC,EAOC,GAAA;;IALC,IAAG;IACH,SAAQ;IACR,MAAK;IACL,OAAM;;qBACsC,CAA3C,EAA2C,EAAA,QAAA,YAAA,CAAA,SAAA,CAAA,EAAA,EAAlB,EAAA,QAAQ,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;;GAGtC,EAAyF,GAAzF,EAAyF,EAAlF,OAAM,2CAA0C,GAAS,EAAA,CAAA,CAAS,CAAC,EAAA,KAAU,CAAA,GAAA,MAAA,EAAA;GAG5E,EAAA,SAAA,EAAA,GADR,EAIE,GAJF,EAIE;;IAFA,OAAM;MACE,EAAA,CAAA,CAAS,CAAC,EAAA,KAAY,CAAA,GAAA,MAAA,EAAA,KAAA,EAAA,IAAA,EAAA;YAGlC,EAEM,OAFN,GAEM,CADJ,EAAQ,EAAA,QAAA,SAAA,CAAA,CAAA,CAAA,GAAA,IAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"VAccordionItem.vue_vue_type_script_setup_true_lang.js","names":["$slots"],"sources":["../../../src/components/VAccordion/VAccordionItem.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * Native details owns disclosure. useDetailsOpen bridges v-model and cancels activation of\n * disabled summaries.\n */\n\nimport { computed, inject, provide } from 'vue'\n\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 VTypography from '../VTypography/VTypography.vue'\nimport { accordionKey } from './context'\n\nimport { useDetailsOpen } from '../../composables/useDetailsOpen'\n\ninterface AccordionItemProps {\n /**\n * The heading of the section, the line that stays visible when it is closed. Use the `#title`\n * slot instead when the heading needs markup rather than plain text.\n */\n title?: string\n /**\n * A secondary line under the title, for a short explanation or a status. The\n * `#subtitle` slot replaces it when markup is needed.\n */\n subtitle?: string\n /**\n * An icon placed before the title: an icon name, or an explicit render (`{ src }`,\n * `{ component }`…). The `#icon` slot replaces it.\n */\n icon?: IconSource\n /** Renders the section already open. Bind `v-model:open` to drive it instead. */\n defaultOpen?: boolean\n /** Makes the section inert. */\n disabled?: boolean\n}\n\nconst props = withDefaults(defineProps<AccordionItemProps>(), {\n title: undefined,\n subtitle: undefined,\n icon: undefined,\n defaultOpen: false,\n disabled: false,\n})\n\n// \"not bound\" is written as `null` and not `undefined`. A model typed as a plain boolean is\n// declared as such at runtime, and Vue casts an ABSENT boolean prop to `false`, which would\n// silently overwrite `defaultOpen`.\n/**\n * Whether the section is open, when the consumer wants to drive or observe it. Left\n * unbound, the browser keeps that state to itself, `defaultOpen` giving only the initial\n * value. `null` means unbound.\n */\nconst open = defineModel<boolean | null>('open', { default: null })\n\ndefineSlots<{\n /** The content revealed when the section is open. */\n default(): unknown\n /** A title made of markup, which replaces the `title` prop. */\n title?(): unknown\n /** A subtitle made of markup, which replaces the `subtitle` prop. */\n subtitle?(): unknown\n /** Free content before the title, which takes the place of `icon`. */\n icon?(): unknown\n}>()\n\nconst accordion = inject(accordionKey, null)\n// The group stops here: an item nested in this one's content without a VAccordion of its\n// own would otherwise share this group's name, and the browser closes every other member\n// of a name group when one opens, the section holding it included.\nprovide(accordionKey, null)\n\n/**\n * Both icons are chosen on the enclosing group. The chevron fallback is what keeps\n * an item rendering correctly when it is used outside a VAccordion.\n */\nconst expandIcon = computed(() => accordion?.expandIcon ?? expandMoreIcon)\nconst collapseIcon = computed(() => accordion?.collapseIcon)\n\nconst { openAttr, onToggle, onSummaryClick } = useDetailsOpen(open, {\n defaultOpen: () => props.defaultOpen,\n disabled: () => props.disabled,\n})\n</script>\n\n<template>\n <details\n class=\"v-accordion-item v-disclosure\"\n :name=\"accordion?.name\"\n :open=\"openAttr\"\n :data-swap=\"collapseIcon ? '' : undefined\"\n @toggle=\"onToggle\"\n >\n <summary\n class=\"v-accordion-summary\"\n :data-disabled=\"disabled ? '' : undefined\"\n :aria-disabled=\"disabled || undefined\"\n :tabindex=\"disabled ? -1 : undefined\"\n @click=\"onSummaryClick\"\n >\n <slot name=\"icon\">\n <VIcon v-if=\"icon\" class=\"v-accordion-icon\" v-bind=\"iconProps(icon)\" />\n </slot>\n <span class=\"v-accordion-heading\">\n <span class=\"v-accordion-title\"\n ><slot name=\"title\">{{ title }}</slot></span\n >\n <VTypography\n v-if=\"subtitle !== undefined || $slots.subtitle\"\n as=\"span\"\n variant=\"caption\"\n tone=\"muted\"\n class=\"v-accordion-subtitle\"\n ><slot name=\"subtitle\">{{ subtitle }}</slot></VTypography\n >\n </span>\n <VIcon class=\"v-accordion-chevron v-disclosure-chevron\" v-bind=\"iconProps(expandIcon)\" />\n <VIcon\n v-if=\"collapseIcon\"\n class=\"v-accordion-chevron v-accordion-chevron-open v-disclosure-chevron v-disclosure-chevron-open\"\n v-bind=\"iconProps(collapseIcon)\"\n />\n </summary>\n <div class=\"v-accordion-content\">\n <slot />\n </div>\n </details>\n</template>\n\n<style>\n@layer vectis.components {\n .v-accordion-item + .v-accordion-item {\n border-block-start: 1px solid var(--vectis-color-border);\n }\n\n .v-accordion-summary {\n --vectis-icon-size: var(--vectis-icon-size-md);\n --vectis-icon-opsz: 20;\n\n display: flex;\n align-items: center;\n gap: var(--vectis-space-3);\n padding: var(--accordion-pad-block, var(--vectis-space-4))\n var(--accordion-pad-inline, var(--vectis-space-5));\n cursor: pointer;\n font-size: var(--vectis-text-label-size);\n font-weight: var(--vectis-text-label-weight);\n color: var(--vectis-color-text);\n }\n\n .v-accordion-summary:hover:not([data-disabled]) {\n background: var(--vectis-color-surface-muted);\n }\n\n .v-accordion-summary: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 .v-accordion-item:first-child > .v-accordion-summary {\n border-start-start-radius: var(--accordion-corner-radius, 0);\n border-start-end-radius: var(--accordion-corner-radius, 0);\n }\n\n .v-accordion-item:last-child:not([open]) > .v-accordion-summary {\n border-end-start-radius: var(--accordion-corner-radius, 0);\n border-end-end-radius: var(--accordion-corner-radius, 0);\n }\n\n .v-accordion-heading {\n flex: 1;\n display: flex;\n flex-direction: column;\n line-height: var(--vectis-text-label-leading);\n }\n\n .v-accordion-icon {\n flex: none;\n color: var(--vectis-color-text-muted);\n }\n\n /* A disabled item greys out through the colour tokens and never through\n `opacity`, the rule every control in the DS follows. */\n .v-accordion-summary[data-disabled] {\n color: var(--vectis-color-text-subtle);\n cursor: not-allowed;\n }\n\n /* The icon and the subtitle default to text-muted, which is DARKER than the\n text-subtle a disabled title takes: left to themselves they would come out\n stronger than the label they belong to, so they inherit it instead. The chevron\n gets the same treatment from `styles/disclosure.css`. */\n .v-accordion-summary[data-disabled] .v-accordion-icon,\n .v-accordion-summary[data-disabled] .v-accordion-subtitle {\n color: inherit;\n }\n\n .v-accordion-content {\n padding: var(--accordion-content-pad-start, var(--vectis-space-2))\n var(--accordion-pad-inline, var(--vectis-space-5))\n var(--accordion-pad-block, var(--vectis-space-4));\n font-size: var(--vectis-text-body-md-size);\n line-height: var(--vectis-text-body-md-leading);\n color: var(--vectis-color-text-muted);\n }\n\n /* The disclosure animation, the chevron's rotation or swap and the WebKit marker come\n from `styles/disclosure.css`, reduced-motion block included. */\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuCA,IAAM,IAAQ,GAgBR,IAAO,EAA2B,GAAC,MAAyB,GAa5D,IAAY,EAAO,GAAc,IAAI;EAI3C,EAAQ,GAAc,IAAI;EAM1B,IAAM,IAAa,QAAe,GAAW,cAAc,CAAc,GACnE,IAAe,QAAe,GAAW,YAAY,GAErD,EAAE,aAAU,aAAU,sBAAmB,EAAe,GAAM;GAClE,mBAAmB,EAAM;GACzB,gBAAgB,EAAM;EACxB,CAAC;yBAIC,EAwCU,WAAA;GAvCR,OAAM;GACL,MAAM,EAAA,CAAA,CAAS,EAAE;GACjB,MAAM,EAAA,CAAA;GACN,aAAW,EAAA,QAAY,KAAQ,KAAA;GAC/B,UAAM,AAAA,EAAA,QAAA,GAAA,MAAE,EAAA,CAAA,KAAA,EAAA,CAAA,CAAA,CAAA,GAAA,CAAA;MAET,EA6BU,WAAA;GA5BR,OAAM;GACL,iBAAe,EAAA,WAAQ,KAAQ,KAAA;GAC/B,iBAAe,EAAA,YAAY,KAAA;GAC3B,UAAU,EAAA,WAAQ,KAAQ,KAAA;GAC1B,SAAK,AAAA,EAAA,QAAA,GAAA,MAAE,EAAA,CAAA,KAAA,EAAA,CAAA,CAAA,CAAA,GAAA,CAAA;;GAER,EAEO,EAAA,QAAA,QAAA,CAAA,SAAA,CADQ,EAAA,QAAA,EAAA,GAAb,EAAuE,GAAvE,EAAuE;;IAApD,OAAM;MAA2B,EAAA,CAAA,CAAS,CAAC,EAAA,IAAI,CAAA,GAAA,MAAA,EAAA,KAAA,EAAA,IAAA,EAAA,CAAA,CAAA;GAEpE,EAYO,QAZP,GAYO,CAXL,EAEC,QAFD,GAEC,CADE,EAAqC,EAAA,QAAA,SAAA,CAAA,SAAA,CAAA,EAAA,EAAf,EAAA,KAAK,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAGtB,EAAA,aAAa,KAAA,KAAaA,EAAAA,OAAO,YAAA,EAAA,GADzC,EAOC,GAAA;;IALC,IAAG;IACH,SAAQ;IACR,MAAK;IACL,OAAM;;qBACsC,CAA3C,EAA2C,EAAA,QAAA,YAAA,CAAA,SAAA,CAAA,EAAA,EAAlB,EAAA,QAAQ,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;;GAGtC,EAAyF,GAAzF,EAAyF,EAAlF,OAAM,2CAA0C,GAAS,EAAA,CAAA,CAAS,CAAC,EAAA,KAAU,CAAA,GAAA,MAAA,EAAA;GAE5E,EAAA,SAAA,EAAA,GADR,EAIE,GAJF,EAIE;;IAFA,OAAM;MACE,EAAA,CAAA,CAAS,CAAC,EAAA,KAAY,CAAA,GAAA,MAAA,EAAA,KAAA,EAAA,IAAA,EAAA;YAGlC,EAEM,OAFN,GAEM,CADJ,EAAQ,EAAA,QAAA,SAAA,CAAA,CAAA,CAAA,GAAA,IAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":[],"sources":["../../../src/components/VAccordion/context.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["../../../src/components/VAccordion/context.ts"],"sourcesContent":["/** Share group icons through context; compact spacing inherits through CSS variables. */\n\nimport type { InjectionKey } from 'vue'\n\nimport type { IconSource } from '../VIcon/types'\n\nexport interface AccordionContext {\n /** Group name for <details name>; undefined = several items may stay open at once. */\n name: string | undefined\n /** Icon in the closed state: an icon name, or an explicit render. */\n expandIcon: IconSource\n /** Icon in the open state; undefined = a rotation of `expandIcon`. */\n collapseIcon: IconSource | undefined\n}\n\n/**\n * `null` is what an item provides to its own content: an item placed straight inside\n * another one must not join the outer group, since opening it would then close the section\n * that holds it.\n */\nexport const accordionKey: InjectionKey<AccordionContext | null> = Symbol('v-accordion')\n"],"mappings":";AAoBA,IAAa,IAAsD,OAAO,aAAa"}
|
|
@@ -12,17 +12,11 @@ interface AvatarProps {
|
|
|
12
12
|
* given both an icon and a name shows the icon.
|
|
13
13
|
*/
|
|
14
14
|
icon?: IconSource;
|
|
15
|
-
/**
|
|
16
|
-
* The person's full name. It does three things at once: it names the avatar for assistive
|
|
17
|
-
* technology, its initials are what shows when there is no picture and no icon, and it is
|
|
18
|
-
* the seed the automatic colour is derived from, so the same person keeps the same colour
|
|
19
|
-
* everywhere.
|
|
20
|
-
*/
|
|
15
|
+
/** The person's full name. */
|
|
21
16
|
name?: string;
|
|
22
17
|
/**
|
|
23
18
|
* The accessible name, when it should not simply be `name`: an avatar standing for a team
|
|
24
19
|
* rather than a person, say. It wins over `name`, and a consumer `aria-label` wins over it.
|
|
25
|
-
* On a picture it is the image's `alt` text.
|
|
26
20
|
*/
|
|
27
21
|
alt?: string;
|
|
28
22
|
/**
|
|
@@ -37,11 +31,7 @@ interface AvatarProps {
|
|
|
37
31
|
* here; on its own it is `md`.
|
|
38
32
|
*/
|
|
39
33
|
size?: AvatarSize;
|
|
40
|
-
/**
|
|
41
|
-
* Takes 4px off the diameter, as it does on every other control. Unlike `size` it is
|
|
42
|
-
* cumulative: inside a compact VAvatarGroup the avatar is compact whatever this says, and
|
|
43
|
-
* setting it on one avatar of a regular group makes that one compact alone.
|
|
44
|
-
*/
|
|
34
|
+
/** Takes 4px off the diameter, as it does on every other control. */
|
|
45
35
|
compact?: boolean;
|
|
46
36
|
/**
|
|
47
37
|
* Turns the avatar into an `<a>` pointing at this address. A disabled link becomes inert:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VAvatar.js","names":[],"sources":["../../../src/components/VAvatar/VAvatar.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * A round avatar standing for a person or an entity. It shows the best of what it\n * was given, in that order: the picture, failing that an icon, failing that the\n * initials taken from the name, and failing that whatever the default slot holds —\n * the escape hatch VAvatarGroup uses to render its \"+X\" overflow badge.\n *\n * Four things here genuinely need JavaScript. A picture that fails to download\n * reports it as a DOM event and nothing else, so the script listens for it and\n * hands over to the initials rather than leaving an empty circle. The initials and\n * the automatic colour are both computed from the name, which is arithmetic no\n * stylesheet can do. A disabled link has no native equivalent of a disabled\n * button, so it is turned inert by hand (composables/useInertLink). Finally the attributes\n * the consumer passes are split so that `style` never reaches the element\n * directly: the component has to merge its own `--avatar-hue`/`--custom-color`\n * into it first, and a plain fallthrough would overwrite them.\n */\n\nimport { computed, inject, onMounted, ref, useAttrs, useSlots, useTemplateRef, watch } from 'vue'\nimport type { StyleValue } from 'vue'\n\nimport VIcon from '../VIcon/VIcon.vue'\nimport { iconProps } from '../VIcon/iconProps'\nimport type { IconSource } from '../VIcon/types'\nimport { AVATAR_DEFAULT_SIZE, avatarGroupKey } from './context'\n\nimport { useAriaLabel } from '../../composables/useAriaLabel'\nimport { useInertLink } from '../../composables/useInertLink'\nimport { customColorStyle } from '../../utils/css'\nimport { isDev } from '../../utils/env'\n\n/** The diameter of the disc, from the control size scale. */\nexport type AvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n\ninterface AvatarProps {\n /**\n * The picture to show. It is what the avatar prefers above everything else, and an image\n * that fails to load hands over to the icon or the initials rather than leaving a gap.\n */\n src?: string\n /**\n * The icon to show when there is no picture. It comes before the initials, so an avatar\n * given both an icon and a name shows the icon.\n */\n icon?: IconSource\n /**\n * The person's full name. It does three things at once: it names the avatar for assistive\n * technology, its initials are what shows when there is no picture and no icon, and it is\n * the seed the automatic colour is derived from, so the same person keeps the same colour\n * everywhere.\n */\n name?: string\n /**\n * The accessible name, when it should not simply be `name`: an avatar standing for a team\n * rather than a person, say. It wins over `name`, and a consumer `aria-label` wins over it.\n * On a picture it is the image's `alt` text.\n */\n alt?: string\n /**\n * A colour of your own, as a hex value, a CSS colour name or an `oklch()`. It REPLACES the\n * hue otherwise derived from `name`, and the text on it is always white, so a light colour\n * is the consumer's own risk.\n */\n color?: string\n /**\n * The diameter of the disc, from the size scale shared by every control. Leaving it out\n * inside a VAvatarGroup takes the group's size, which is the point of not defaulting it\n * here; on its own it is `md`.\n */\n size?: AvatarSize\n /**\n * Takes 4px off the diameter, as it does on every other control. Unlike `size` it is\n * cumulative: inside a compact VAvatarGroup the avatar is compact whatever this says, and\n * setting it on one avatar of a regular group makes that one compact alone.\n */\n compact?: boolean\n /**\n * Turns the avatar into an `<a>` pointing at this address. A disabled link becomes inert:\n * the address is dropped, so it can be neither focused nor followed.\n */\n href?: string\n /**\n * Turns the avatar into a `<button>`. It is ignored as soon as `href` makes it a link.\n * A VTooltip wrapping the avatar reaches this button through fallthrough.\n */\n clickable?: boolean\n /**\n * Makes an interactive avatar unusable: it stops responding, leaves the tab order and greys\n * out. It says nothing on a plain avatar, which was never interactive to begin with.\n */\n disabled?: boolean\n}\n\nconst props = withDefaults(defineProps<AvatarProps>(), {\n src: undefined,\n icon: undefined,\n name: undefined,\n alt: undefined,\n color: undefined,\n size: undefined,\n compact: false,\n href: undefined,\n clickable: false,\n disabled: false,\n})\n\ndefineSlots<{\n /** Fallback content (replaces the initials), e.g. VAvatarGroup's \"+X\". */\n default?(): unknown\n}>()\n\ndefineOptions({ inheritAttrs: false })\n\nconst attrs = useAttrs()\nconst group = inject(avatarGroupKey, null)\n\n// The size is the avatar's own answer first, then the group's; the density is cumulative,\n// the two terms written out in context.ts.\nconst resolvedSize = computed<AvatarSize>(() => props.size ?? group?.size ?? AVATAR_DEFAULT_SIZE)\nconst resolvedCompact = computed(() => props.compact || Boolean(group?.compact))\n\n// Fallthrough without `style`, which rootStyle merges with the component's own; the click\n// handler is also dropped on an inert link.\nconst {\n isLink,\n isInertLink,\n linkHref,\n attrs: passedAttrs,\n} = useInertLink({\n href: () => props.href,\n inert: () => props.disabled,\n attrs: () => Object.fromEntries(Object.entries(attrs).filter(([key]) => key !== 'style')),\n})\n\n/* Interactivity priority: href > clickable > static. */\nconst isInteractive = computed(() => isLink.value || props.clickable)\nconst tag = computed(() => (isLink.value ? 'a' : props.clickable ? 'button' : 'span'))\n\n// @core\n// The image failed to load: the initials take over, so an avatar is never an empty box.\nconst failed = ref(false)\nwatch(\n () => props.src,\n () => {\n failed.value = false\n },\n)\nconst showImage = computed(() => Boolean(props.src) && !failed.value)\n\n/* TRAP — on a server-rendered page the browser may give up on the picture BEFORE hydration\n attaches `@error`, and that event is never sent again: the disc would stay an empty\n circle. A picture already settled with no pixels at mount is one that failed. */\nconst imageEl = useTemplateRef<HTMLImageElement>('image')\nonMounted(() => {\n const img = imageEl.value\n if (img?.complete && img.naturalWidth === 0) failed.value = true\n})\n\n// @a11y\n/*\n * The name bound on the root: a consumer `aria-labelledby` removes it, a consumer `aria-label`\n * replaces it, and otherwise it is `alt`, then `name`. A picture on show carries that name as\n * its own `alt`, so the root then names itself only with what the consumer wrote.\n */\nconst ariaLabel = useAriaLabel(() => (showImage.value ? undefined : (props.alt ?? props.name)))\nconst named = computed(() => ariaLabel.value !== undefined || attrs['aria-labelledby'] != null)\n\n// @core\nconst initials = computed(() => {\n if (!props.name) return ''\n /* Whole characters, not UTF-16 halves: `part[0]` of \"😀\" is a lone surrogate, drawn as a\n replacement box. And `toUpperCase` rather than its locale-aware sibling, whose answer\n depends on the runtime's locale, which the server and the browser need not share. */\n return props.name\n .split(/\\s+/)\n .filter(Boolean)\n .slice(0, 2)\n .map((part) => [...part][0]?.toUpperCase() ?? '')\n .join('')\n})\n\n// @core\n/*\n * Auto hue: a pure JS hash of the name → an OKLCH hue (0–359). Only the hue is\n * inline (a unitless scalar); the CSS composes background/text with L/C fixed per\n * theme (light/dark adaptation without depending on contrast-color). A colour\n * computed outside the tokens, a deliberate exception. SSR-safe: no browser API.\n *\n * VCalendar derives an event's hue the same way (`VCalendar/color.ts`, `hueOf`) with a hash\n * of its own, and the two stay apart ON PURPOSE: changing this one would give every person\n * already shown in an application a new colour. Nothing ties an avatar's hue to an event's,\n * so a person and an event sharing a string do not share a colour.\n */\nconst hue = computed(() => {\n if (!props.name) return null\n let hash = 0\n for (let i = 0; i < props.name.length; i++) {\n hash = (hash * 31 + props.name.charCodeAt(i)) | 0\n }\n return Math.abs(hash) % 360\n})\nconst isAuto = computed(() => props.color === undefined && hue.value !== null)\n\n// @a11y\n// A static avatar with no picture is an image named by `alt`/`name`. Anything else keeps the\n// role that arrived in the attributes — `link` on an inert link, a consumer's own otherwise.\nconst role = computed(() =>\n !isInteractive.value && !showImage.value && named.value\n ? 'img'\n : (passedAttrs.value.role as string | undefined),\n)\n\n// @devwarn\n// A button or a link named by nothing: no `name`, no `alt`, no `aria-*` and no slot text. A\n// picture alone does not count, its `alt` coming from the same two props.\nif (isDev) {\n const slots = useSlots()\n onMounted(() => {\n if (isInteractive.value && !named.value && !props.alt && !props.name && !slots.default) {\n console.warn(\n '[VAvatar] a clickable or linked avatar needs an accessible name: set `name`, `alt` or `aria-label`.',\n )\n }\n })\n}\n\nconst rootStyle = computed<StyleValue>(() => [\n customColorStyle(props.color) ??\n (isAuto.value ? { '--avatar-hue': String(hue.value) } : undefined),\n attrs.style as StyleValue,\n])\n</script>\n\n<template>\n <component\n :is=\"tag\"\n :aria-disabled=\"isInertLink ? 'true' : undefined\"\n v-bind=\"passedAttrs\"\n class=\"v-avatar v-control\"\n :style=\"rootStyle\"\n :data-size=\"resolvedSize\"\n :data-compact=\"resolvedCompact ? '' : undefined\"\n :data-custom=\"color !== undefined ? '' : undefined\"\n :data-auto=\"isAuto ? '' : undefined\"\n :href=\"linkHref\"\n :type=\"tag === 'button' ? 'button' : undefined\"\n :disabled=\"tag === 'button' ? disabled : undefined\"\n :role=\"role\"\n :aria-label=\"ariaLabel\"\n >\n <img\n v-if=\"showImage\"\n ref=\"image\"\n class=\"v-avatar-image\"\n :src=\"src\"\n :alt=\"alt ?? name ?? ''\"\n @error=\"failed = true\"\n />\n <VIcon v-else-if=\"icon\" v-bind=\"iconProps(icon)\" class=\"v-avatar-icon\" />\n <slot v-else>\n <span class=\"v-avatar-initials\" aria-hidden=\"true\">{{ initials }}</span>\n </slot>\n </component>\n</template>\n\n<style>\n@layer vectis.components {\n .v-avatar {\n --avatar-bg: var(--vectis-color-surface-muted);\n --avatar-text: var(--vectis-color-text-muted);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n inline-size: var(--control-height);\n block-size: var(--control-height);\n flex: none;\n overflow: hidden;\n padding: 0;\n border: none;\n background: var(--avatar-bg);\n color: var(--avatar-text);\n border-radius: var(--vectis-radius-pill);\n font-family: var(--vectis-text-family);\n font-size: var(--control-font-size);\n font-weight: var(--vectis-font-weight-semibold);\n line-height: var(--vectis-text-control-leading);\n text-decoration: none;\n user-select: none;\n /* `--avatar-ring-color` is a contract with VAvatarGroup, which is the only thing that\n ever sets it — a private name shared across two sheets, like the `anchor-name`\n idents. The `transparent` fallback is what lets a lone avatar render ringless, and\n it is also what makes a divergence silent: rename it on one side and the discs in a\n group simply stop being separated, with no error and nothing missing from the box. */\n box-shadow: 0 0 0 var(--vectis-control-size-avatar-ring) var(--avatar-ring-color, transparent);\n transition:\n background-color var(--vectis-duration-fast) var(--vectis-ease-default),\n box-shadow var(--vectis-duration-fast) var(--vectis-ease-default);\n }\n\n /* `--avatar-hue` is set inline by the script, which derives it from the name — so these\n pairs cannot be tokens: only the hue varies, and it is not known until render. The two\n themes are written out separately for the same reason relative colours are not used\n elsewhere in the library: OKLCH's lightness is perceptual, so the dark pair is a\n design decision rather than a delta off the light one.\n\n TRAP — the lightness/chroma pairs are set on the THEME scopes and INHERITED, rather\n than written in a `[data-theme='dark'] .v-avatar` rule: a descendant selector matches\n ANY dark ancestor, so a light subtree nested in a dark page kept the dark discs. An\n inherited value is resolved by the NEAREST scope, which is exactly how the semantic\n tokens behave. The selectors and their order are `tokens.css`'s own: all three are\n (0,1,0), so on a dark root the later block wins. */\n :root,\n [data-theme='light'] {\n --avatar-auto-bg-lc: 0.9 0.06;\n --avatar-auto-text-lc: 0.42 0.13;\n }\n\n [data-theme='dark'] {\n --avatar-auto-bg-lc: 0.42 0.09;\n --avatar-auto-text-lc: 0.92 0.05;\n }\n\n .v-avatar[data-auto] {\n --avatar-bg: oklch(var(--avatar-auto-bg-lc) var(--avatar-hue));\n --avatar-text: oklch(var(--avatar-auto-text-lc) var(--avatar-hue));\n }\n\n /* Custom colour (--custom-color inline): wins, with a fixed white text (contrast\n is the consumer's responsibility). */\n .v-avatar[data-custom] {\n --avatar-bg: var(--custom-color);\n --avatar-text: var(--vectis-color-text-on-accent);\n }\n\n .v-avatar-image {\n inline-size: 100%;\n block-size: 100%;\n object-fit: cover;\n }\n\n /* The icon occupies ~55% of the disc (a unitless ratio, like the font-size). */\n .v-avatar-icon {\n --vectis-icon-size: calc(var(--control-height) * 0.55);\n }\n\n :is(a, button).v-avatar {\n cursor: pointer;\n }\n\n :is(a, button).v-avatar:hover:not([aria-disabled='true'], :disabled) {\n background: color-mix(in oklab, var(--avatar-bg), var(--vectis-color-text) 10%);\n }\n\n :is(a, button).v-avatar: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 .v-avatar:is(:disabled, [aria-disabled='true']) {\n cursor: not-allowed;\n background: var(--vectis-color-surface-muted);\n color: var(--vectis-color-text-subtle);\n }\n\n @media (prefers-reduced-motion: reduce) {\n .v-avatar {\n transition: none;\n }\n }\n\n /* Forced colours repaint the disc as Canvas and drop the separation ring, a shadow, so\n an avatar has no edge and the discs of a group run into one another. The outline gives\n each disc its circle back; the focus ring, at (0,2,0), still wins over it. */\n @media (forced-colors: active) {\n .v-avatar {\n outline: var(--vectis-control-border-width) solid CanvasText;\n outline-offset: calc(-1 * var(--vectis-control-border-width));\n }\n }\n}\n</style>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"VAvatar.js","names":[],"sources":["../../../src/components/VAvatar/VAvatar.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * Resolve image, icon and initials in priority order. JavaScript handles failed images, inert\n * links and merging private colour variables with consumer styles.\n */\n\nimport { computed, inject, onMounted, ref, useAttrs, useSlots, useTemplateRef, watch } from 'vue'\nimport type { StyleValue } from 'vue'\n\nimport VIcon from '../VIcon/VIcon.vue'\nimport { iconProps } from '../VIcon/iconProps'\nimport type { IconSource } from '../VIcon/types'\nimport { AVATAR_DEFAULT_SIZE, avatarGroupKey } from './context'\n\nimport { useAriaLabel } from '../../composables/useAriaLabel'\nimport { useInertLink } from '../../composables/useInertLink'\nimport { customColorStyle } from '../../utils/css'\nimport { isDev } from '../../utils/env'\n\n/** The diameter of the disc, from the control size scale. */\nexport type AvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n\ninterface AvatarProps {\n /**\n * The picture to show. It is what the avatar prefers above everything else, and an image\n * that fails to load hands over to the icon or the initials rather than leaving a gap.\n */\n src?: string\n /**\n * The icon to show when there is no picture. It comes before the initials, so an avatar\n * given both an icon and a name shows the icon.\n */\n icon?: IconSource\n /** The person's full name. */\n name?: string\n /**\n * The accessible name, when it should not simply be `name`: an avatar standing for a team\n * rather than a person, say. It wins over `name`, and a consumer `aria-label` wins over it.\n */\n alt?: string\n /**\n * A colour of your own, as a hex value, a CSS colour name or an `oklch()`. It REPLACES the\n * hue otherwise derived from `name`, and the text on it is always white, so a light colour\n * is the consumer's own risk.\n */\n color?: string\n /**\n * The diameter of the disc, from the size scale shared by every control. Leaving it out\n * inside a VAvatarGroup takes the group's size, which is the point of not defaulting it\n * here; on its own it is `md`.\n */\n size?: AvatarSize\n /** Takes 4px off the diameter, as it does on every other control. */\n compact?: boolean\n /**\n * Turns the avatar into an `<a>` pointing at this address. A disabled link becomes inert:\n * the address is dropped, so it can be neither focused nor followed.\n */\n href?: string\n /**\n * Turns the avatar into a `<button>`. It is ignored as soon as `href` makes it a link.\n * A VTooltip wrapping the avatar reaches this button through fallthrough.\n */\n clickable?: boolean\n /**\n * Makes an interactive avatar unusable: it stops responding, leaves the tab order and greys\n * out. It says nothing on a plain avatar, which was never interactive to begin with.\n */\n disabled?: boolean\n}\n\nconst props = withDefaults(defineProps<AvatarProps>(), {\n src: undefined,\n icon: undefined,\n name: undefined,\n alt: undefined,\n color: undefined,\n size: undefined,\n compact: false,\n href: undefined,\n clickable: false,\n disabled: false,\n})\n\ndefineSlots<{\n /** Fallback content (replaces the initials), e.g. VAvatarGroup's \"+X\". */\n default?(): unknown\n}>()\n\ndefineOptions({ inheritAttrs: false })\n\nconst attrs = useAttrs()\nconst group = inject(avatarGroupKey, null)\n\n// The size is the avatar's own answer first, then the group's; the density is cumulative,\n// the two terms written out in context.ts.\nconst resolvedSize = computed<AvatarSize>(() => props.size ?? group?.size ?? AVATAR_DEFAULT_SIZE)\nconst resolvedCompact = computed(() => props.compact || Boolean(group?.compact))\n\n// Fallthrough without `style`, which rootStyle merges with the component's own; the click\n// handler is also dropped on an inert link.\nconst {\n isLink,\n isInertLink,\n linkHref,\n attrs: passedAttrs,\n} = useInertLink({\n href: () => props.href,\n inert: () => props.disabled,\n attrs: () => Object.fromEntries(Object.entries(attrs).filter(([key]) => key !== 'style')),\n})\n\nconst isInteractive = computed(() => isLink.value || props.clickable)\nconst tag = computed(() => (isLink.value ? 'a' : props.clickable ? 'button' : 'span'))\n\n// @core\n// The image failed to load: the initials take over, so an avatar is never an empty box.\nconst failed = ref(false)\nwatch(\n () => props.src,\n () => {\n failed.value = false\n },\n)\nconst showImage = computed(() => Boolean(props.src) && !failed.value)\n\n/*\n * On a server-rendered page the browser may give up on the picture before hydration attaches\n * `@error`, and that event is never sent again: the disc would stay an empty circle. A picture\n * already settled with no pixels at mount is one that failed.\n */\nconst imageEl = useTemplateRef<HTMLImageElement>('image')\nonMounted(() => {\n const img = imageEl.value\n if (img?.complete && img.naturalWidth === 0) failed.value = true\n})\n\n// @a11y\n/*\n * The name bound on the root: a consumer `aria-labelledby` removes it, a consumer `aria-label`\n * replaces it, and otherwise it is `alt`, then `name`. A picture on show carries that name as\n * its own `alt`, so the root then names itself only with what the consumer wrote.\n */\nconst ariaLabel = useAriaLabel(() => (showImage.value ? undefined : (props.alt ?? props.name)))\nconst named = computed(() => ariaLabel.value !== undefined || attrs['aria-labelledby'] != null)\n\n// @core\nconst initials = computed(() => {\n if (!props.name) return ''\n /* Whole characters, not UTF-16 halves: `part[0]` of \"😀\" is a lone surrogate, drawn as a\n replacement box. And `toUpperCase` rather than its locale-aware sibling, whose answer\n depends on the runtime's locale, which the server and the browser need not share. */\n return props.name\n .split(/\\s+/)\n .filter(Boolean)\n .slice(0, 2)\n .map((part) => [...part][0]?.toUpperCase() ?? '')\n .join('')\n})\n\n// @core\n/*\n * Only the hue is inline (a unitless scalar); the CSS composes background/text with L/C fixed\n * per theme (light/dark adaptation without depending on contrast-color). A colour computed\n * outside the tokens, a deliberate exception.\n */\nconst hue = computed(() => {\n if (!props.name) return null\n let hash = 0\n for (let i = 0; i < props.name.length; i++) {\n hash = (hash * 31 + props.name.charCodeAt(i)) | 0\n }\n return Math.abs(hash) % 360\n})\nconst isAuto = computed(() => props.color === undefined && hue.value !== null)\n\n// @a11y\n// A static avatar with no picture is an image named by `alt`/ `name`. Anything else keeps the\n// role that arrived in the attributes; `link` on an inert link, a consumer's own otherwise.\nconst role = computed(() =>\n !isInteractive.value && !showImage.value && named.value\n ? 'img'\n : (passedAttrs.value.role as string | undefined),\n)\n\n// @devwarn\n// A button or a link named by nothing: no `name`, no `alt`, no `aria-*` and no slot text. A\n// picture alone does not count, its `alt` coming from the same two props.\nif (isDev) {\n const slots = useSlots()\n onMounted(() => {\n if (isInteractive.value && !named.value && !props.alt && !props.name && !slots.default) {\n console.warn(\n '[VAvatar] a clickable or linked avatar needs an accessible name: set `name`, `alt` or `aria-label`.',\n )\n }\n })\n}\n\nconst rootStyle = computed<StyleValue>(() => [\n customColorStyle(props.color) ??\n (isAuto.value ? { '--avatar-hue': String(hue.value) } : undefined),\n attrs.style as StyleValue,\n])\n</script>\n\n<template>\n <component\n :is=\"tag\"\n :aria-disabled=\"isInertLink ? 'true' : undefined\"\n v-bind=\"passedAttrs\"\n class=\"v-avatar v-control\"\n :style=\"rootStyle\"\n :data-size=\"resolvedSize\"\n :data-compact=\"resolvedCompact ? '' : undefined\"\n :data-custom=\"color !== undefined ? '' : undefined\"\n :data-auto=\"isAuto ? '' : undefined\"\n :href=\"linkHref\"\n :type=\"tag === 'button' ? 'button' : undefined\"\n :disabled=\"tag === 'button' ? disabled : undefined\"\n :role=\"role\"\n :aria-label=\"ariaLabel\"\n >\n <img\n v-if=\"showImage\"\n ref=\"image\"\n class=\"v-avatar-image\"\n :src=\"src\"\n :alt=\"alt ?? name ?? ''\"\n @error=\"failed = true\"\n />\n <VIcon v-else-if=\"icon\" v-bind=\"iconProps(icon)\" class=\"v-avatar-icon\" />\n <slot v-else>\n <span class=\"v-avatar-initials\" aria-hidden=\"true\">{{ initials }}</span>\n </slot>\n </component>\n</template>\n\n<style>\n@layer vectis.components {\n .v-avatar {\n --avatar-bg: var(--vectis-color-surface-muted);\n --avatar-text: var(--vectis-color-text-muted);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n inline-size: var(--control-height);\n block-size: var(--control-height);\n flex: none;\n overflow: hidden;\n padding: 0;\n border: none;\n background: var(--avatar-bg);\n color: var(--avatar-text);\n border-radius: var(--vectis-radius-pill);\n font-family: var(--vectis-text-family);\n font-size: var(--control-font-size);\n font-weight: var(--vectis-font-weight-semibold);\n line-height: var(--vectis-text-control-leading);\n text-decoration: none;\n user-select: none;\n /*\n * The `transparent` fallback is what lets a lone avatar render ringless, and it is also\n * what makes a divergence silent: rename it on one side and the discs in a group simply\n * stop being separated, with no error and nothing missing from the box.\n */\n box-shadow: 0 0 0 var(--vectis-control-size-avatar-ring) var(--avatar-ring-color, transparent);\n transition:\n background-color var(--vectis-duration-fast) var(--vectis-ease-default),\n box-shadow var(--vectis-duration-fast) var(--vectis-ease-default);\n }\n\n /*\n * The lightness/chroma pairs are set on the THEME scopes and inherited, rather than written\n * in a `[data-theme='dark'] .v-avatar` rule: a descendant selector matches ANY dark ancestor,\n * so a light subtree nested in a dark page kept the dark discs. An inherited value is\n * resolved by the NEAREST scope, which is exactly how the semantic tokens behave.\n */\n :root,\n [data-theme='light'] {\n --avatar-auto-bg-lc: 0.9 0.06;\n --avatar-auto-text-lc: 0.42 0.13;\n }\n\n [data-theme='dark'] {\n --avatar-auto-bg-lc: 0.42 0.09;\n --avatar-auto-text-lc: 0.92 0.05;\n }\n\n .v-avatar[data-auto] {\n --avatar-bg: oklch(var(--avatar-auto-bg-lc) var(--avatar-hue));\n --avatar-text: oklch(var(--avatar-auto-text-lc) var(--avatar-hue));\n }\n\n /* Custom colour (--custom-color inline): wins, with a fixed white text (contrast\n is the consumer's responsibility). */\n .v-avatar[data-custom] {\n --avatar-bg: var(--custom-color);\n --avatar-text: var(--vectis-color-text-on-accent);\n }\n\n .v-avatar-image {\n inline-size: 100%;\n block-size: 100%;\n object-fit: cover;\n }\n\n .v-avatar-icon {\n --vectis-icon-size: calc(var(--control-height) * 0.55);\n }\n\n :is(a, button).v-avatar {\n cursor: pointer;\n }\n\n :is(a, button).v-avatar:hover:not([aria-disabled='true'], :disabled) {\n background: color-mix(in oklab, var(--avatar-bg), var(--vectis-color-text) 10%);\n }\n\n :is(a, button).v-avatar: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 .v-avatar:is(:disabled, [aria-disabled='true']) {\n cursor: not-allowed;\n background: var(--vectis-color-surface-muted);\n color: var(--vectis-color-text-subtle);\n }\n\n @media (prefers-reduced-motion: reduce) {\n .v-avatar {\n transition: none;\n }\n }\n\n /* The outline gives each disc its circle back; the focus ring, at (0,2,0), still wins over it. */\n @media (forced-colors: active) {\n .v-avatar {\n outline: var(--vectis-control-border-width) solid CanvasText;\n outline-offset: calc(-1 * var(--vectis-control-border-width));\n }\n }\n}\n</style>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VAvatar.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../../src/components/VAvatar/VAvatar.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * A round avatar standing for a person or an entity. It shows the best of what it\n * was given, in that order: the picture, failing that an icon, failing that the\n * initials taken from the name, and failing that whatever the default slot holds —\n * the escape hatch VAvatarGroup uses to render its \"+X\" overflow badge.\n *\n * Four things here genuinely need JavaScript. A picture that fails to download\n * reports it as a DOM event and nothing else, so the script listens for it and\n * hands over to the initials rather than leaving an empty circle. The initials and\n * the automatic colour are both computed from the name, which is arithmetic no\n * stylesheet can do. A disabled link has no native equivalent of a disabled\n * button, so it is turned inert by hand (composables/useInertLink). Finally the attributes\n * the consumer passes are split so that `style` never reaches the element\n * directly: the component has to merge its own `--avatar-hue`/`--custom-color`\n * into it first, and a plain fallthrough would overwrite them.\n */\n\nimport { computed, inject, onMounted, ref, useAttrs, useSlots, useTemplateRef, watch } from 'vue'\nimport type { StyleValue } from 'vue'\n\nimport VIcon from '../VIcon/VIcon.vue'\nimport { iconProps } from '../VIcon/iconProps'\nimport type { IconSource } from '../VIcon/types'\nimport { AVATAR_DEFAULT_SIZE, avatarGroupKey } from './context'\n\nimport { useAriaLabel } from '../../composables/useAriaLabel'\nimport { useInertLink } from '../../composables/useInertLink'\nimport { customColorStyle } from '../../utils/css'\nimport { isDev } from '../../utils/env'\n\n/** The diameter of the disc, from the control size scale. */\nexport type AvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n\ninterface AvatarProps {\n /**\n * The picture to show. It is what the avatar prefers above everything else, and an image\n * that fails to load hands over to the icon or the initials rather than leaving a gap.\n */\n src?: string\n /**\n * The icon to show when there is no picture. It comes before the initials, so an avatar\n * given both an icon and a name shows the icon.\n */\n icon?: IconSource\n /**\n * The person's full name. It does three things at once: it names the avatar for assistive\n * technology, its initials are what shows when there is no picture and no icon, and it is\n * the seed the automatic colour is derived from, so the same person keeps the same colour\n * everywhere.\n */\n name?: string\n /**\n * The accessible name, when it should not simply be `name`: an avatar standing for a team\n * rather than a person, say. It wins over `name`, and a consumer `aria-label` wins over it.\n * On a picture it is the image's `alt` text.\n */\n alt?: string\n /**\n * A colour of your own, as a hex value, a CSS colour name or an `oklch()`. It REPLACES the\n * hue otherwise derived from `name`, and the text on it is always white, so a light colour\n * is the consumer's own risk.\n */\n color?: string\n /**\n * The diameter of the disc, from the size scale shared by every control. Leaving it out\n * inside a VAvatarGroup takes the group's size, which is the point of not defaulting it\n * here; on its own it is `md`.\n */\n size?: AvatarSize\n /**\n * Takes 4px off the diameter, as it does on every other control. Unlike `size` it is\n * cumulative: inside a compact VAvatarGroup the avatar is compact whatever this says, and\n * setting it on one avatar of a regular group makes that one compact alone.\n */\n compact?: boolean\n /**\n * Turns the avatar into an `<a>` pointing at this address. A disabled link becomes inert:\n * the address is dropped, so it can be neither focused nor followed.\n */\n href?: string\n /**\n * Turns the avatar into a `<button>`. It is ignored as soon as `href` makes it a link.\n * A VTooltip wrapping the avatar reaches this button through fallthrough.\n */\n clickable?: boolean\n /**\n * Makes an interactive avatar unusable: it stops responding, leaves the tab order and greys\n * out. It says nothing on a plain avatar, which was never interactive to begin with.\n */\n disabled?: boolean\n}\n\nconst props = withDefaults(defineProps<AvatarProps>(), {\n src: undefined,\n icon: undefined,\n name: undefined,\n alt: undefined,\n color: undefined,\n size: undefined,\n compact: false,\n href: undefined,\n clickable: false,\n disabled: false,\n})\n\ndefineSlots<{\n /** Fallback content (replaces the initials), e.g. VAvatarGroup's \"+X\". */\n default?(): unknown\n}>()\n\ndefineOptions({ inheritAttrs: false })\n\nconst attrs = useAttrs()\nconst group = inject(avatarGroupKey, null)\n\n// The size is the avatar's own answer first, then the group's; the density is cumulative,\n// the two terms written out in context.ts.\nconst resolvedSize = computed<AvatarSize>(() => props.size ?? group?.size ?? AVATAR_DEFAULT_SIZE)\nconst resolvedCompact = computed(() => props.compact || Boolean(group?.compact))\n\n// Fallthrough without `style`, which rootStyle merges with the component's own; the click\n// handler is also dropped on an inert link.\nconst {\n isLink,\n isInertLink,\n linkHref,\n attrs: passedAttrs,\n} = useInertLink({\n href: () => props.href,\n inert: () => props.disabled,\n attrs: () => Object.fromEntries(Object.entries(attrs).filter(([key]) => key !== 'style')),\n})\n\n/* Interactivity priority: href > clickable > static. */\nconst isInteractive = computed(() => isLink.value || props.clickable)\nconst tag = computed(() => (isLink.value ? 'a' : props.clickable ? 'button' : 'span'))\n\n// @core\n// The image failed to load: the initials take over, so an avatar is never an empty box.\nconst failed = ref(false)\nwatch(\n () => props.src,\n () => {\n failed.value = false\n },\n)\nconst showImage = computed(() => Boolean(props.src) && !failed.value)\n\n/* TRAP — on a server-rendered page the browser may give up on the picture BEFORE hydration\n attaches `@error`, and that event is never sent again: the disc would stay an empty\n circle. A picture already settled with no pixels at mount is one that failed. */\nconst imageEl = useTemplateRef<HTMLImageElement>('image')\nonMounted(() => {\n const img = imageEl.value\n if (img?.complete && img.naturalWidth === 0) failed.value = true\n})\n\n// @a11y\n/*\n * The name bound on the root: a consumer `aria-labelledby` removes it, a consumer `aria-label`\n * replaces it, and otherwise it is `alt`, then `name`. A picture on show carries that name as\n * its own `alt`, so the root then names itself only with what the consumer wrote.\n */\nconst ariaLabel = useAriaLabel(() => (showImage.value ? undefined : (props.alt ?? props.name)))\nconst named = computed(() => ariaLabel.value !== undefined || attrs['aria-labelledby'] != null)\n\n// @core\nconst initials = computed(() => {\n if (!props.name) return ''\n /* Whole characters, not UTF-16 halves: `part[0]` of \"😀\" is a lone surrogate, drawn as a\n replacement box. And `toUpperCase` rather than its locale-aware sibling, whose answer\n depends on the runtime's locale, which the server and the browser need not share. */\n return props.name\n .split(/\\s+/)\n .filter(Boolean)\n .slice(0, 2)\n .map((part) => [...part][0]?.toUpperCase() ?? '')\n .join('')\n})\n\n// @core\n/*\n * Auto hue: a pure JS hash of the name → an OKLCH hue (0–359). Only the hue is\n * inline (a unitless scalar); the CSS composes background/text with L/C fixed per\n * theme (light/dark adaptation without depending on contrast-color). A colour\n * computed outside the tokens, a deliberate exception. SSR-safe: no browser API.\n *\n * VCalendar derives an event's hue the same way (`VCalendar/color.ts`, `hueOf`) with a hash\n * of its own, and the two stay apart ON PURPOSE: changing this one would give every person\n * already shown in an application a new colour. Nothing ties an avatar's hue to an event's,\n * so a person and an event sharing a string do not share a colour.\n */\nconst hue = computed(() => {\n if (!props.name) return null\n let hash = 0\n for (let i = 0; i < props.name.length; i++) {\n hash = (hash * 31 + props.name.charCodeAt(i)) | 0\n }\n return Math.abs(hash) % 360\n})\nconst isAuto = computed(() => props.color === undefined && hue.value !== null)\n\n// @a11y\n// A static avatar with no picture is an image named by `alt`/`name`. Anything else keeps the\n// role that arrived in the attributes — `link` on an inert link, a consumer's own otherwise.\nconst role = computed(() =>\n !isInteractive.value && !showImage.value && named.value\n ? 'img'\n : (passedAttrs.value.role as string | undefined),\n)\n\n// @devwarn\n// A button or a link named by nothing: no `name`, no `alt`, no `aria-*` and no slot text. A\n// picture alone does not count, its `alt` coming from the same two props.\nif (isDev) {\n const slots = useSlots()\n onMounted(() => {\n if (isInteractive.value && !named.value && !props.alt && !props.name && !slots.default) {\n console.warn(\n '[VAvatar] a clickable or linked avatar needs an accessible name: set `name`, `alt` or `aria-label`.',\n )\n }\n })\n}\n\nconst rootStyle = computed<StyleValue>(() => [\n customColorStyle(props.color) ??\n (isAuto.value ? { '--avatar-hue': String(hue.value) } : undefined),\n attrs.style as StyleValue,\n])\n</script>\n\n<template>\n <component\n :is=\"tag\"\n :aria-disabled=\"isInertLink ? 'true' : undefined\"\n v-bind=\"passedAttrs\"\n class=\"v-avatar v-control\"\n :style=\"rootStyle\"\n :data-size=\"resolvedSize\"\n :data-compact=\"resolvedCompact ? '' : undefined\"\n :data-custom=\"color !== undefined ? '' : undefined\"\n :data-auto=\"isAuto ? '' : undefined\"\n :href=\"linkHref\"\n :type=\"tag === 'button' ? 'button' : undefined\"\n :disabled=\"tag === 'button' ? disabled : undefined\"\n :role=\"role\"\n :aria-label=\"ariaLabel\"\n >\n <img\n v-if=\"showImage\"\n ref=\"image\"\n class=\"v-avatar-image\"\n :src=\"src\"\n :alt=\"alt ?? name ?? ''\"\n @error=\"failed = true\"\n />\n <VIcon v-else-if=\"icon\" v-bind=\"iconProps(icon)\" class=\"v-avatar-icon\" />\n <slot v-else>\n <span class=\"v-avatar-initials\" aria-hidden=\"true\">{{ initials }}</span>\n </slot>\n </component>\n</template>\n\n<style>\n@layer vectis.components {\n .v-avatar {\n --avatar-bg: var(--vectis-color-surface-muted);\n --avatar-text: var(--vectis-color-text-muted);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n inline-size: var(--control-height);\n block-size: var(--control-height);\n flex: none;\n overflow: hidden;\n padding: 0;\n border: none;\n background: var(--avatar-bg);\n color: var(--avatar-text);\n border-radius: var(--vectis-radius-pill);\n font-family: var(--vectis-text-family);\n font-size: var(--control-font-size);\n font-weight: var(--vectis-font-weight-semibold);\n line-height: var(--vectis-text-control-leading);\n text-decoration: none;\n user-select: none;\n /* `--avatar-ring-color` is a contract with VAvatarGroup, which is the only thing that\n ever sets it — a private name shared across two sheets, like the `anchor-name`\n idents. The `transparent` fallback is what lets a lone avatar render ringless, and\n it is also what makes a divergence silent: rename it on one side and the discs in a\n group simply stop being separated, with no error and nothing missing from the box. */\n box-shadow: 0 0 0 var(--vectis-control-size-avatar-ring) var(--avatar-ring-color, transparent);\n transition:\n background-color var(--vectis-duration-fast) var(--vectis-ease-default),\n box-shadow var(--vectis-duration-fast) var(--vectis-ease-default);\n }\n\n /* `--avatar-hue` is set inline by the script, which derives it from the name — so these\n pairs cannot be tokens: only the hue varies, and it is not known until render. The two\n themes are written out separately for the same reason relative colours are not used\n elsewhere in the library: OKLCH's lightness is perceptual, so the dark pair is a\n design decision rather than a delta off the light one.\n\n TRAP — the lightness/chroma pairs are set on the THEME scopes and INHERITED, rather\n than written in a `[data-theme='dark'] .v-avatar` rule: a descendant selector matches\n ANY dark ancestor, so a light subtree nested in a dark page kept the dark discs. An\n inherited value is resolved by the NEAREST scope, which is exactly how the semantic\n tokens behave. The selectors and their order are `tokens.css`'s own: all three are\n (0,1,0), so on a dark root the later block wins. */\n :root,\n [data-theme='light'] {\n --avatar-auto-bg-lc: 0.9 0.06;\n --avatar-auto-text-lc: 0.42 0.13;\n }\n\n [data-theme='dark'] {\n --avatar-auto-bg-lc: 0.42 0.09;\n --avatar-auto-text-lc: 0.92 0.05;\n }\n\n .v-avatar[data-auto] {\n --avatar-bg: oklch(var(--avatar-auto-bg-lc) var(--avatar-hue));\n --avatar-text: oklch(var(--avatar-auto-text-lc) var(--avatar-hue));\n }\n\n /* Custom colour (--custom-color inline): wins, with a fixed white text (contrast\n is the consumer's responsibility). */\n .v-avatar[data-custom] {\n --avatar-bg: var(--custom-color);\n --avatar-text: var(--vectis-color-text-on-accent);\n }\n\n .v-avatar-image {\n inline-size: 100%;\n block-size: 100%;\n object-fit: cover;\n }\n\n /* The icon occupies ~55% of the disc (a unitless ratio, like the font-size). */\n .v-avatar-icon {\n --vectis-icon-size: calc(var(--control-height) * 0.55);\n }\n\n :is(a, button).v-avatar {\n cursor: pointer;\n }\n\n :is(a, button).v-avatar:hover:not([aria-disabled='true'], :disabled) {\n background: color-mix(in oklab, var(--avatar-bg), var(--vectis-color-text) 10%);\n }\n\n :is(a, button).v-avatar: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 .v-avatar:is(:disabled, [aria-disabled='true']) {\n cursor: not-allowed;\n background: var(--vectis-color-surface-muted);\n color: var(--vectis-color-text-subtle);\n }\n\n @media (prefers-reduced-motion: reduce) {\n .v-avatar {\n transition: none;\n }\n }\n\n /* Forced colours repaint the disc as Canvas and drop the separation ring, a shadow, so\n an avatar has no edge and the discs of a group run into one another. The outline gives\n each disc its circle back; the focus ring, at (0,2,0), still wins over it. */\n @media (forced-colors: active) {\n .v-avatar {\n outline: var(--vectis-control-border-width) solid CanvasText;\n outline-offset: calc(-1 * var(--vectis-control-border-width));\n }\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6FA,IAAM,IAAQ,GAoBR,IAAQ,EAAS,GACjB,IAAQ,EAAO,GAAgB,IAAI,GAInC,IAAe,QAA2B,EAAM,QAAQ,GAAO,QAAA,IAA2B,GAC1F,IAAkB,QAAe,EAAM,WAAW,EAAQ,GAAO,OAAQ,GAIzE,EACJ,WACA,gBACA,aACA,OAAO,MACL,EAAa;GACf,YAAY,EAAM;GAClB,aAAa,EAAM;GACnB,aAAa,OAAO,YAAY,OAAO,QAAQ,CAAK,CAAC,CAAC,QAAQ,CAAC,OAAS,MAAQ,OAAO,CAAC;EAC1F,CAAC,GAGK,IAAgB,QAAe,EAAO,SAAS,EAAM,SAAS,GAC9D,IAAM,QAAgB,EAAO,QAAQ,MAAM,EAAM,YAAY,WAAW,MAAO,GAI/E,IAAS,EAAI,EAAK;EACxB,QACQ,EAAM,WACN;GACJ,EAAO,QAAQ;EACjB,CACF;EACA,IAAM,IAAY,QAAe,EAAQ,EAAM,OAAQ,CAAC,EAAO,KAAK,GAK9D,IAAU,EAAiC,OAAO;EACxD,QAAgB;GACd,IAAM,IAAM,EAAQ;GACpB,AAAI,GAAK,YAAY,EAAI,iBAAiB,MAAG,EAAO,QAAQ;EAC9D,CAAC;EAQD,IAAM,IAAY,QAAoB,EAAU,QAAQ,KAAA,IAAa,EAAM,OAAO,EAAM,IAAM,GACxF,IAAQ,QAAe,EAAU,UAAU,KAAA,KAAa,EAAM,sBAAsB,IAAI,GAGxF,IAAW,QACV,EAAM,OAIJ,EAAM,KACV,MAAM,KAAK,CAAA,CACX,OAAO,OAAO,CAAA,CACd,MAAM,GAAG,CAAC,CAAA,CACV,KAAK,MAAS,CAAC,GAAG,CAAI,CAAC,CAAC,EAAE,EAAE,YAAY,KAAK,EAAE,CAAA,CAC/C,KAAK,EAAE,IATc,EAUzB,GAcK,IAAM,QAAe;GACzB,IAAI,CAAC,EAAM,MAAM,OAAO;GACxB,IAAI,IAAO;GACX,KAAK,IAAI,IAAI,GAAG,IAAI,EAAM,KAAK,QAAQ,KACrC,IAAQ,IAAO,KAAK,EAAM,KAAK,WAAW,CAAC,IAAK;GAElD,OAAO,KAAK,IAAI,CAAI,IAAI;EAC1B,CAAC,GACK,IAAS,QAAe,EAAM,UAAU,KAAA,KAAa,EAAI,UAAU,IAAI,GAKvE,IAAO,QACX,CAAC,EAAc,SAAS,CAAC,EAAU,SAAS,EAAM,QAC9C,QACC,EAAY,MAAM,IACzB;EAKA,IAAI,GAAO;GACT,IAAM,IAAQ,EAAS;GACvB,QAAgB;IACd,AAAI,EAAc,SAAS,CAAC,EAAM,SAAS,CAAC,EAAM,OAAO,CAAC,EAAM,QAAQ,CAAC,EAAM,WAC7E,QAAQ,KACN,qGACF;GAEJ,CAAC;EACH;EAEA,IAAM,IAAY,QAA2B,CAC3C,EAAiB,EAAM,KAAK,MACzB,EAAO,QAAQ,EAAE,gBAAgB,OAAO,EAAI,KAAK,EAAE,IAAI,KAAA,IAC1D,EAAM,KACR,CAAC;yBAIC,EA4BY,EA3BL,EAAA,KAAG,GADV,EA4BY,EA1BT,iBAAe,EAAA,CAAA,IAAW,SAAY,KAAA,EAAA,GAC/B,EAAA,CAAA,GAAW;GACnB,OAAM;GACL,OAAO,EAAA;GACP,aAAW,EAAA;GACX,gBAAc,EAAA,QAAe,KAAQ,KAAA;GACrC,eAAa,EAAA,UAAU,KAAA,IAAiB,KAAA,IAAR;GAChC,aAAW,EAAA,QAAM,KAAQ,KAAA;GACzB,MAAM,EAAA,CAAA;GACN,MAAM,EAAA,UAAG,WAAA,WAA2B,KAAA;GACpC,UAAU,EAAA,UAAG,WAAgB,EAAA,WAAW,KAAA;GACxC,MAAM,EAAA;GACN,cAAY,EAAA,CAAA;;oBASX,CANM,EAAA,SAAA,EAAA,GADR,EAOE,OAAA;;IALA,KAAI;IACJ,OAAM;IACL,KAAK,EAAA;IACL,KAAK,EAAA,OAAO,EAAA,QAAI;IAChB,SAAK,AAAA,EAAA,QAAA,MAAE,EAAA,QAAM;sBAEE,EAAA,QAAA,EAAA,GAAlB,EAAyE,GAAzE,EAAyE,EAAA,KAAA,EAAA,GAAzC,EAAA,CAAA,CAAS,CAAC,EAAA,IAAI,GAAA,EAAG,OAAM,gBAAe,CAAA,GAAA,MAAA,EAAA,KACtE,EAEO,EAAA,QAAA,WAAA,CAAA,SAAA,CADL,EAAwE,QAAxE,GAAwE,EAAlB,EAAA,KAAQ,GAAA,CAAA,CAAA,GAAA,KAAA,GAAA,CAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"VAvatar.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../../src/components/VAvatar/VAvatar.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * Resolve image, icon and initials in priority order. JavaScript handles failed images, inert\n * links and merging private colour variables with consumer styles.\n */\n\nimport { computed, inject, onMounted, ref, useAttrs, useSlots, useTemplateRef, watch } from 'vue'\nimport type { StyleValue } from 'vue'\n\nimport VIcon from '../VIcon/VIcon.vue'\nimport { iconProps } from '../VIcon/iconProps'\nimport type { IconSource } from '../VIcon/types'\nimport { AVATAR_DEFAULT_SIZE, avatarGroupKey } from './context'\n\nimport { useAriaLabel } from '../../composables/useAriaLabel'\nimport { useInertLink } from '../../composables/useInertLink'\nimport { customColorStyle } from '../../utils/css'\nimport { isDev } from '../../utils/env'\n\n/** The diameter of the disc, from the control size scale. */\nexport type AvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n\ninterface AvatarProps {\n /**\n * The picture to show. It is what the avatar prefers above everything else, and an image\n * that fails to load hands over to the icon or the initials rather than leaving a gap.\n */\n src?: string\n /**\n * The icon to show when there is no picture. It comes before the initials, so an avatar\n * given both an icon and a name shows the icon.\n */\n icon?: IconSource\n /** The person's full name. */\n name?: string\n /**\n * The accessible name, when it should not simply be `name`: an avatar standing for a team\n * rather than a person, say. It wins over `name`, and a consumer `aria-label` wins over it.\n */\n alt?: string\n /**\n * A colour of your own, as a hex value, a CSS colour name or an `oklch()`. It REPLACES the\n * hue otherwise derived from `name`, and the text on it is always white, so a light colour\n * is the consumer's own risk.\n */\n color?: string\n /**\n * The diameter of the disc, from the size scale shared by every control. Leaving it out\n * inside a VAvatarGroup takes the group's size, which is the point of not defaulting it\n * here; on its own it is `md`.\n */\n size?: AvatarSize\n /** Takes 4px off the diameter, as it does on every other control. */\n compact?: boolean\n /**\n * Turns the avatar into an `<a>` pointing at this address. A disabled link becomes inert:\n * the address is dropped, so it can be neither focused nor followed.\n */\n href?: string\n /**\n * Turns the avatar into a `<button>`. It is ignored as soon as `href` makes it a link.\n * A VTooltip wrapping the avatar reaches this button through fallthrough.\n */\n clickable?: boolean\n /**\n * Makes an interactive avatar unusable: it stops responding, leaves the tab order and greys\n * out. It says nothing on a plain avatar, which was never interactive to begin with.\n */\n disabled?: boolean\n}\n\nconst props = withDefaults(defineProps<AvatarProps>(), {\n src: undefined,\n icon: undefined,\n name: undefined,\n alt: undefined,\n color: undefined,\n size: undefined,\n compact: false,\n href: undefined,\n clickable: false,\n disabled: false,\n})\n\ndefineSlots<{\n /** Fallback content (replaces the initials), e.g. VAvatarGroup's \"+X\". */\n default?(): unknown\n}>()\n\ndefineOptions({ inheritAttrs: false })\n\nconst attrs = useAttrs()\nconst group = inject(avatarGroupKey, null)\n\n// The size is the avatar's own answer first, then the group's; the density is cumulative,\n// the two terms written out in context.ts.\nconst resolvedSize = computed<AvatarSize>(() => props.size ?? group?.size ?? AVATAR_DEFAULT_SIZE)\nconst resolvedCompact = computed(() => props.compact || Boolean(group?.compact))\n\n// Fallthrough without `style`, which rootStyle merges with the component's own; the click\n// handler is also dropped on an inert link.\nconst {\n isLink,\n isInertLink,\n linkHref,\n attrs: passedAttrs,\n} = useInertLink({\n href: () => props.href,\n inert: () => props.disabled,\n attrs: () => Object.fromEntries(Object.entries(attrs).filter(([key]) => key !== 'style')),\n})\n\nconst isInteractive = computed(() => isLink.value || props.clickable)\nconst tag = computed(() => (isLink.value ? 'a' : props.clickable ? 'button' : 'span'))\n\n// @core\n// The image failed to load: the initials take over, so an avatar is never an empty box.\nconst failed = ref(false)\nwatch(\n () => props.src,\n () => {\n failed.value = false\n },\n)\nconst showImage = computed(() => Boolean(props.src) && !failed.value)\n\n/*\n * On a server-rendered page the browser may give up on the picture before hydration attaches\n * `@error`, and that event is never sent again: the disc would stay an empty circle. A picture\n * already settled with no pixels at mount is one that failed.\n */\nconst imageEl = useTemplateRef<HTMLImageElement>('image')\nonMounted(() => {\n const img = imageEl.value\n if (img?.complete && img.naturalWidth === 0) failed.value = true\n})\n\n// @a11y\n/*\n * The name bound on the root: a consumer `aria-labelledby` removes it, a consumer `aria-label`\n * replaces it, and otherwise it is `alt`, then `name`. A picture on show carries that name as\n * its own `alt`, so the root then names itself only with what the consumer wrote.\n */\nconst ariaLabel = useAriaLabel(() => (showImage.value ? undefined : (props.alt ?? props.name)))\nconst named = computed(() => ariaLabel.value !== undefined || attrs['aria-labelledby'] != null)\n\n// @core\nconst initials = computed(() => {\n if (!props.name) return ''\n /* Whole characters, not UTF-16 halves: `part[0]` of \"😀\" is a lone surrogate, drawn as a\n replacement box. And `toUpperCase` rather than its locale-aware sibling, whose answer\n depends on the runtime's locale, which the server and the browser need not share. */\n return props.name\n .split(/\\s+/)\n .filter(Boolean)\n .slice(0, 2)\n .map((part) => [...part][0]?.toUpperCase() ?? '')\n .join('')\n})\n\n// @core\n/*\n * Only the hue is inline (a unitless scalar); the CSS composes background/text with L/C fixed\n * per theme (light/dark adaptation without depending on contrast-color). A colour computed\n * outside the tokens, a deliberate exception.\n */\nconst hue = computed(() => {\n if (!props.name) return null\n let hash = 0\n for (let i = 0; i < props.name.length; i++) {\n hash = (hash * 31 + props.name.charCodeAt(i)) | 0\n }\n return Math.abs(hash) % 360\n})\nconst isAuto = computed(() => props.color === undefined && hue.value !== null)\n\n// @a11y\n// A static avatar with no picture is an image named by `alt`/ `name`. Anything else keeps the\n// role that arrived in the attributes; `link` on an inert link, a consumer's own otherwise.\nconst role = computed(() =>\n !isInteractive.value && !showImage.value && named.value\n ? 'img'\n : (passedAttrs.value.role as string | undefined),\n)\n\n// @devwarn\n// A button or a link named by nothing: no `name`, no `alt`, no `aria-*` and no slot text. A\n// picture alone does not count, its `alt` coming from the same two props.\nif (isDev) {\n const slots = useSlots()\n onMounted(() => {\n if (isInteractive.value && !named.value && !props.alt && !props.name && !slots.default) {\n console.warn(\n '[VAvatar] a clickable or linked avatar needs an accessible name: set `name`, `alt` or `aria-label`.',\n )\n }\n })\n}\n\nconst rootStyle = computed<StyleValue>(() => [\n customColorStyle(props.color) ??\n (isAuto.value ? { '--avatar-hue': String(hue.value) } : undefined),\n attrs.style as StyleValue,\n])\n</script>\n\n<template>\n <component\n :is=\"tag\"\n :aria-disabled=\"isInertLink ? 'true' : undefined\"\n v-bind=\"passedAttrs\"\n class=\"v-avatar v-control\"\n :style=\"rootStyle\"\n :data-size=\"resolvedSize\"\n :data-compact=\"resolvedCompact ? '' : undefined\"\n :data-custom=\"color !== undefined ? '' : undefined\"\n :data-auto=\"isAuto ? '' : undefined\"\n :href=\"linkHref\"\n :type=\"tag === 'button' ? 'button' : undefined\"\n :disabled=\"tag === 'button' ? disabled : undefined\"\n :role=\"role\"\n :aria-label=\"ariaLabel\"\n >\n <img\n v-if=\"showImage\"\n ref=\"image\"\n class=\"v-avatar-image\"\n :src=\"src\"\n :alt=\"alt ?? name ?? ''\"\n @error=\"failed = true\"\n />\n <VIcon v-else-if=\"icon\" v-bind=\"iconProps(icon)\" class=\"v-avatar-icon\" />\n <slot v-else>\n <span class=\"v-avatar-initials\" aria-hidden=\"true\">{{ initials }}</span>\n </slot>\n </component>\n</template>\n\n<style>\n@layer vectis.components {\n .v-avatar {\n --avatar-bg: var(--vectis-color-surface-muted);\n --avatar-text: var(--vectis-color-text-muted);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n inline-size: var(--control-height);\n block-size: var(--control-height);\n flex: none;\n overflow: hidden;\n padding: 0;\n border: none;\n background: var(--avatar-bg);\n color: var(--avatar-text);\n border-radius: var(--vectis-radius-pill);\n font-family: var(--vectis-text-family);\n font-size: var(--control-font-size);\n font-weight: var(--vectis-font-weight-semibold);\n line-height: var(--vectis-text-control-leading);\n text-decoration: none;\n user-select: none;\n /*\n * The `transparent` fallback is what lets a lone avatar render ringless, and it is also\n * what makes a divergence silent: rename it on one side and the discs in a group simply\n * stop being separated, with no error and nothing missing from the box.\n */\n box-shadow: 0 0 0 var(--vectis-control-size-avatar-ring) var(--avatar-ring-color, transparent);\n transition:\n background-color var(--vectis-duration-fast) var(--vectis-ease-default),\n box-shadow var(--vectis-duration-fast) var(--vectis-ease-default);\n }\n\n /*\n * The lightness/chroma pairs are set on the THEME scopes and inherited, rather than written\n * in a `[data-theme='dark'] .v-avatar` rule: a descendant selector matches ANY dark ancestor,\n * so a light subtree nested in a dark page kept the dark discs. An inherited value is\n * resolved by the NEAREST scope, which is exactly how the semantic tokens behave.\n */\n :root,\n [data-theme='light'] {\n --avatar-auto-bg-lc: 0.9 0.06;\n --avatar-auto-text-lc: 0.42 0.13;\n }\n\n [data-theme='dark'] {\n --avatar-auto-bg-lc: 0.42 0.09;\n --avatar-auto-text-lc: 0.92 0.05;\n }\n\n .v-avatar[data-auto] {\n --avatar-bg: oklch(var(--avatar-auto-bg-lc) var(--avatar-hue));\n --avatar-text: oklch(var(--avatar-auto-text-lc) var(--avatar-hue));\n }\n\n /* Custom colour (--custom-color inline): wins, with a fixed white text (contrast\n is the consumer's responsibility). */\n .v-avatar[data-custom] {\n --avatar-bg: var(--custom-color);\n --avatar-text: var(--vectis-color-text-on-accent);\n }\n\n .v-avatar-image {\n inline-size: 100%;\n block-size: 100%;\n object-fit: cover;\n }\n\n .v-avatar-icon {\n --vectis-icon-size: calc(var(--control-height) * 0.55);\n }\n\n :is(a, button).v-avatar {\n cursor: pointer;\n }\n\n :is(a, button).v-avatar:hover:not([aria-disabled='true'], :disabled) {\n background: color-mix(in oklab, var(--avatar-bg), var(--vectis-color-text) 10%);\n }\n\n :is(a, button).v-avatar: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 .v-avatar:is(:disabled, [aria-disabled='true']) {\n cursor: not-allowed;\n background: var(--vectis-color-surface-muted);\n color: var(--vectis-color-text-subtle);\n }\n\n @media (prefers-reduced-motion: reduce) {\n .v-avatar {\n transition: none;\n }\n }\n\n /* The outline gives each disc its circle back; the focus ring, at (0,2,0), still wins over it. */\n @media (forced-colors: active) {\n .v-avatar {\n outline: var(--vectis-control-border-width) solid CanvasText;\n outline-offset: calc(-1 * var(--vectis-control-border-width));\n }\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuEA,IAAM,IAAQ,GAoBR,IAAQ,EAAS,GACjB,IAAQ,EAAO,GAAgB,IAAI,GAInC,IAAe,QAA2B,EAAM,QAAQ,GAAO,QAAA,IAA2B,GAC1F,IAAkB,QAAe,EAAM,WAAW,EAAQ,GAAO,OAAQ,GAIzE,EACJ,WACA,gBACA,aACA,OAAO,MACL,EAAa;GACf,YAAY,EAAM;GAClB,aAAa,EAAM;GACnB,aAAa,OAAO,YAAY,OAAO,QAAQ,CAAK,CAAC,CAAC,QAAQ,CAAC,OAAS,MAAQ,OAAO,CAAC;EAC1F,CAAC,GAEK,IAAgB,QAAe,EAAO,SAAS,EAAM,SAAS,GAC9D,IAAM,QAAgB,EAAO,QAAQ,MAAM,EAAM,YAAY,WAAW,MAAO,GAI/E,IAAS,EAAI,EAAK;EACxB,QACQ,EAAM,WACN;GACJ,EAAO,QAAQ;EACjB,CACF;EACA,IAAM,IAAY,QAAe,EAAQ,EAAM,OAAQ,CAAC,EAAO,KAAK,GAO9D,IAAU,EAAiC,OAAO;EACxD,QAAgB;GACd,IAAM,IAAM,EAAQ;GACpB,AAAI,GAAK,YAAY,EAAI,iBAAiB,MAAG,EAAO,QAAQ;EAC9D,CAAC;EAQD,IAAM,IAAY,QAAoB,EAAU,QAAQ,KAAA,IAAa,EAAM,OAAO,EAAM,IAAM,GACxF,IAAQ,QAAe,EAAU,UAAU,KAAA,KAAa,EAAM,sBAAsB,IAAI,GAGxF,IAAW,QACV,EAAM,OAIJ,EAAM,KACV,MAAM,KAAK,CAAA,CACX,OAAO,OAAO,CAAA,CACd,MAAM,GAAG,CAAC,CAAA,CACV,KAAK,MAAS,CAAC,GAAG,CAAI,CAAC,CAAC,EAAE,EAAE,YAAY,KAAK,EAAE,CAAA,CAC/C,KAAK,EAAE,IATc,EAUzB,GAQK,IAAM,QAAe;GACzB,IAAI,CAAC,EAAM,MAAM,OAAO;GACxB,IAAI,IAAO;GACX,KAAK,IAAI,IAAI,GAAG,IAAI,EAAM,KAAK,QAAQ,KACrC,IAAQ,IAAO,KAAK,EAAM,KAAK,WAAW,CAAC,IAAK;GAElD,OAAO,KAAK,IAAI,CAAI,IAAI;EAC1B,CAAC,GACK,IAAS,QAAe,EAAM,UAAU,KAAA,KAAa,EAAI,UAAU,IAAI,GAKvE,IAAO,QACX,CAAC,EAAc,SAAS,CAAC,EAAU,SAAS,EAAM,QAC9C,QACC,EAAY,MAAM,IACzB;EAKA,IAAI,GAAO;GACT,IAAM,IAAQ,EAAS;GACvB,QAAgB;IACd,AAAI,EAAc,SAAS,CAAC,EAAM,SAAS,CAAC,EAAM,OAAO,CAAC,EAAM,QAAQ,CAAC,EAAM,WAC7E,QAAQ,KACN,qGACF;GAEJ,CAAC;EACH;EAEA,IAAM,IAAY,QAA2B,CAC3C,EAAiB,EAAM,KAAK,MACzB,EAAO,QAAQ,EAAE,gBAAgB,OAAO,EAAI,KAAK,EAAE,IAAI,KAAA,IAC1D,EAAM,KACR,CAAC;yBAIC,EA4BY,EA3BL,EAAA,KAAG,GADV,EA4BY,EA1BT,iBAAe,EAAA,CAAA,IAAW,SAAY,KAAA,EAAA,GAC/B,EAAA,CAAA,GAAW;GACnB,OAAM;GACL,OAAO,EAAA;GACP,aAAW,EAAA;GACX,gBAAc,EAAA,QAAe,KAAQ,KAAA;GACrC,eAAa,EAAA,UAAU,KAAA,IAAiB,KAAA,IAAR;GAChC,aAAW,EAAA,QAAM,KAAQ,KAAA;GACzB,MAAM,EAAA,CAAA;GACN,MAAM,EAAA,UAAG,WAAA,WAA2B,KAAA;GACpC,UAAU,EAAA,UAAG,WAAgB,EAAA,WAAW,KAAA;GACxC,MAAM,EAAA;GACN,cAAY,EAAA,CAAA;;oBASX,CANM,EAAA,SAAA,EAAA,GADR,EAOE,OAAA;;IALA,KAAI;IACJ,OAAM;IACL,KAAK,EAAA;IACL,KAAK,EAAA,OAAO,EAAA,QAAI;IAChB,SAAK,AAAA,EAAA,QAAA,MAAE,EAAA,QAAM;sBAEE,EAAA,QAAA,EAAA,GAAlB,EAAyE,GAAzE,EAAyE,EAAA,KAAA,EAAA,GAAzC,EAAA,CAAA,CAAS,CAAC,EAAA,IAAI,GAAA,EAAG,OAAM,gBAAe,CAAA,GAAA,MAAA,EAAA,KACtE,EAEO,EAAA,QAAA,WAAA,CAAA,SAAA,CADL,EAAwE,QAAxE,GAAwE,EAAlB,EAAA,KAAQ,GAAA,CAAA,CAAA,GAAA,KAAA,GAAA,CAAA,CAAA,CAAA"}
|
|
@@ -21,8 +21,8 @@ interface AvatarGroupProps {
|
|
|
21
21
|
*/
|
|
22
22
|
compact?: boolean;
|
|
23
23
|
/**
|
|
24
|
-
* The colour of the ring drawn around each disc. It defaults to the page
|
|
25
|
-
*
|
|
24
|
+
* The colour of the ring drawn around each disc. It defaults to the page background, which
|
|
25
|
+
* makes the ring read as a gap between two avatars.
|
|
26
26
|
*/
|
|
27
27
|
ringColor?: string;
|
|
28
28
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VAvatarGroup.js","names":[],"sources":["../../../src/components/VAvatar/VAvatarGroup.vue"],"sourcesContent":["<script setup lang=\"ts\">\n// @ssr @core
|
|
1
|
+
{"version":3,"file":"VAvatarGroup.js","names":[],"sources":["../../../src/components/VAvatar/VAvatarGroup.vue"],"sourcesContent":["<script setup lang=\"ts\">\n// @ssr @core\n/**\n * Count avatars through slot VNodes for SSR-consistent overflow; useSlotNodes keeps that count\n * reactive when the parent replaces its slot.\n */\n\nimport { computed, provide } from 'vue'\nimport type { StyleValue } from 'vue'\n\nimport VAvatar from './VAvatar.vue'\nimport type { AvatarSize } from './VAvatar.vue'\nimport { AVATAR_DEFAULT_SIZE, avatarGroupKey } from './context'\n\nimport { useAriaLabel } from '../../composables/useAriaLabel'\nimport { useSlotNodes } from '../../composables/useSlotNodes'\n\n/** What the `#overflow` slot receives. */\nexport interface AvatarGroupOverflowSlotProps {\n /** How many avatars are hidden beyond `max`. */\n count: number\n}\n\ninterface AvatarGroupProps {\n /**\n * How many avatars to show before the remaining ones are summed up as a single\n * \"+X\" disc. Left out, or set to 0, every avatar is shown.\n */\n max?: number\n /**\n * The size given to the avatars inside the group. An avatar that sets a `size`\n * of its own keeps it.\n */\n size?: AvatarSize\n /**\n * Applies the reduced density to every avatar inside. Unlike `size` it is cumulative: an\n * avatar cannot opt back out of a compact group.\n */\n compact?: boolean\n /**\n * The colour of the ring drawn around each disc. It defaults to the page background, which\n * makes the ring read as a gap between two avatars.\n */\n ringColor?: string\n /**\n * The accessible name of the group, e.g. \"Project members\". A row of faces does not say on\n * its own who these people are. A consumer `aria-label` or `aria-labelledby` wins over it.\n */\n label?: string\n}\n\nconst props = withDefaults(defineProps<AvatarGroupProps>(), {\n max: undefined,\n size: undefined,\n compact: false,\n ringColor: undefined,\n label: undefined,\n})\n\nconst ariaLabel = useAriaLabel(() => props.label)\n\ndefineSlots<{\n /** The VAvatars to stack. */\n default?(): unknown\n /**\n * Replaces the \"+X\" disc that stands for the avatars beyond `max`. It receives\n * `count`, the number of avatars being hidden.\n */\n overflow?(props: AvatarGroupOverflowSlotProps): unknown\n}>()\n\nprovide(avatarGroupKey, {\n get size() {\n return props.size\n },\n get compact() {\n return props.compact\n },\n})\n\nconst items = useSlotNodes()\n// `max: 0` means \"no limit\", as documented, and so does a negative one: `slice(0, -1)` would\n// drop the last avatar and sum it into a \"+1\" disc.\nconst visibleItems = computed(() =>\n props.max !== undefined && props.max > 0 ? items.value.slice(0, props.max) : items.value,\n)\nconst overflowCount = computed(() => items.value.length - visibleItems.value.length)\n\n// A functional component is the only way to render VNodes that have already been\n// captured: <component :is> expects a component definition, not a vnode.\nconst VisibleAvatars = () => visibleItems.value\n\nconst rootStyle = computed<StyleValue>(() =>\n props.ringColor !== undefined ? { '--avatar-ring-color': props.ringColor } : undefined,\n)\n\n// The group carries v-control so that --control-height is defined at ITS level, which keeps the\n// overlap computable even when a child is wrapped; a VTooltip, for instance, inserts a <span>\n// between the group and the VAvatar. An avatar given a size of its own redefines\n// --control-height on itself, so its own overlap follows that size rather than the group's.\nconst resolvedGroupSize = computed<AvatarSize>(() => props.size ?? AVATAR_DEFAULT_SIZE)\n</script>\n\n<template>\n <div\n class=\"v-avatar-group v-control\"\n role=\"group\"\n :aria-label=\"ariaLabel\"\n :style=\"rootStyle\"\n :data-size=\"resolvedGroupSize\"\n :data-compact=\"compact ? '' : undefined\"\n >\n <component :is=\"VisibleAvatars\" />\n <slot v-if=\"overflowCount > 0\" name=\"overflow\" :count=\"overflowCount\">\n <VAvatar>+{{ overflowCount }}</VAvatar>\n </slot>\n </div>\n</template>\n\n<style>\n@layer vectis.components {\n .v-avatar-group {\n /* The separation ring, declared here so that every child .v-avatar inherits it. */\n --avatar-ring-color: var(--vectis-color-surface);\n display: inline-flex;\n align-items: center;\n }\n\n /*\n * Take overlap height from the group so wrappers and differently sized avatars share one row\n * contract.\n */\n .v-avatar-group > * + * {\n margin-inline-start: calc(var(--control-height) * -0.3);\n }\n\n /* On hover, or as soon as something inside it takes focus, a disc rises above its\n neighbours so it is seen whole rather than clipped by the next one. */\n .v-avatar-group > *:hover,\n .v-avatar-group > *:focus-within {\n z-index: 1;\n }\n}\n</style>\n"],"mappings":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useAriaLabel as e } from "../../composables/useAriaLabel.js";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import r from "
|
|
2
|
+
import { avatarGroupKey as t } from "./context.js";
|
|
3
|
+
import n from "./VAvatar.js";
|
|
4
|
+
import { useSlotNodes as r } from "../../composables/useSlotNodes.js";
|
|
5
5
|
import { computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createTextVNode as c, createVNode as l, defineComponent as u, normalizeStyle as d, openBlock as f, provide as p, renderSlot as m, resolveDynamicComponent as h, toDisplayString as g, unref as _, withCtx as v } from "vue";
|
|
6
6
|
//#region src/components/VAvatar/VAvatarGroup.vue?vue&type=script&setup=true&lang.ts
|
|
7
7
|
var y = [
|
|
@@ -22,7 +22,7 @@ var y = [
|
|
|
22
22
|
},
|
|
23
23
|
setup(u) {
|
|
24
24
|
let b = u, x = e(() => b.label);
|
|
25
|
-
p(
|
|
25
|
+
p(t, {
|
|
26
26
|
get size() {
|
|
27
27
|
return b.size;
|
|
28
28
|
},
|
|
@@ -30,7 +30,7 @@ var y = [
|
|
|
30
30
|
return b.compact;
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
|
-
let S =
|
|
33
|
+
let S = r(), C = i(() => b.max !== void 0 && b.max > 0 ? S.value.slice(0, b.max) : S.value), w = i(() => S.value.length - C.value.length), T = () => C.value, E = i(() => b.ringColor === void 0 ? void 0 : { "--avatar-ring-color": b.ringColor }), D = i(() => b.size ?? "md");
|
|
34
34
|
return (e, t) => (f(), s("div", {
|
|
35
35
|
class: "v-avatar-group v-control",
|
|
36
36
|
role: "group",
|
|
@@ -38,7 +38,7 @@ var y = [
|
|
|
38
38
|
style: d(E.value),
|
|
39
39
|
"data-size": D.value,
|
|
40
40
|
"data-compact": u.compact ? "" : void 0
|
|
41
|
-
}, [(f(), a(h(T))), w.value > 0 ? m(e.$slots, "overflow", { count: w.value }, () => [l(
|
|
41
|
+
}, [(f(), a(h(T))), w.value > 0 ? m(e.$slots, "overflow", { count: w.value }, () => [l(n, null, {
|
|
42
42
|
default: v(() => [c("+" + g(w.value), 1)]),
|
|
43
43
|
_: 1
|
|
44
44
|
})], void 0, 0) : o("", !0)], 12, y));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VAvatarGroup.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../../src/components/VAvatar/VAvatarGroup.vue"],"sourcesContent":["<script setup lang=\"ts\">\n// @ssr @core
|
|
1
|
+
{"version":3,"file":"VAvatarGroup.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../../src/components/VAvatar/VAvatarGroup.vue"],"sourcesContent":["<script setup lang=\"ts\">\n// @ssr @core\n/**\n * Count avatars through slot VNodes for SSR-consistent overflow; useSlotNodes keeps that count\n * reactive when the parent replaces its slot.\n */\n\nimport { computed, provide } from 'vue'\nimport type { StyleValue } from 'vue'\n\nimport VAvatar from './VAvatar.vue'\nimport type { AvatarSize } from './VAvatar.vue'\nimport { AVATAR_DEFAULT_SIZE, avatarGroupKey } from './context'\n\nimport { useAriaLabel } from '../../composables/useAriaLabel'\nimport { useSlotNodes } from '../../composables/useSlotNodes'\n\n/** What the `#overflow` slot receives. */\nexport interface AvatarGroupOverflowSlotProps {\n /** How many avatars are hidden beyond `max`. */\n count: number\n}\n\ninterface AvatarGroupProps {\n /**\n * How many avatars to show before the remaining ones are summed up as a single\n * \"+X\" disc. Left out, or set to 0, every avatar is shown.\n */\n max?: number\n /**\n * The size given to the avatars inside the group. An avatar that sets a `size`\n * of its own keeps it.\n */\n size?: AvatarSize\n /**\n * Applies the reduced density to every avatar inside. Unlike `size` it is cumulative: an\n * avatar cannot opt back out of a compact group.\n */\n compact?: boolean\n /**\n * The colour of the ring drawn around each disc. It defaults to the page background, which\n * makes the ring read as a gap between two avatars.\n */\n ringColor?: string\n /**\n * The accessible name of the group, e.g. \"Project members\". A row of faces does not say on\n * its own who these people are. A consumer `aria-label` or `aria-labelledby` wins over it.\n */\n label?: string\n}\n\nconst props = withDefaults(defineProps<AvatarGroupProps>(), {\n max: undefined,\n size: undefined,\n compact: false,\n ringColor: undefined,\n label: undefined,\n})\n\nconst ariaLabel = useAriaLabel(() => props.label)\n\ndefineSlots<{\n /** The VAvatars to stack. */\n default?(): unknown\n /**\n * Replaces the \"+X\" disc that stands for the avatars beyond `max`. It receives\n * `count`, the number of avatars being hidden.\n */\n overflow?(props: AvatarGroupOverflowSlotProps): unknown\n}>()\n\nprovide(avatarGroupKey, {\n get size() {\n return props.size\n },\n get compact() {\n return props.compact\n },\n})\n\nconst items = useSlotNodes()\n// `max: 0` means \"no limit\", as documented, and so does a negative one: `slice(0, -1)` would\n// drop the last avatar and sum it into a \"+1\" disc.\nconst visibleItems = computed(() =>\n props.max !== undefined && props.max > 0 ? items.value.slice(0, props.max) : items.value,\n)\nconst overflowCount = computed(() => items.value.length - visibleItems.value.length)\n\n// A functional component is the only way to render VNodes that have already been\n// captured: <component :is> expects a component definition, not a vnode.\nconst VisibleAvatars = () => visibleItems.value\n\nconst rootStyle = computed<StyleValue>(() =>\n props.ringColor !== undefined ? { '--avatar-ring-color': props.ringColor } : undefined,\n)\n\n// The group carries v-control so that --control-height is defined at ITS level, which keeps the\n// overlap computable even when a child is wrapped; a VTooltip, for instance, inserts a <span>\n// between the group and the VAvatar. An avatar given a size of its own redefines\n// --control-height on itself, so its own overlap follows that size rather than the group's.\nconst resolvedGroupSize = computed<AvatarSize>(() => props.size ?? AVATAR_DEFAULT_SIZE)\n</script>\n\n<template>\n <div\n class=\"v-avatar-group v-control\"\n role=\"group\"\n :aria-label=\"ariaLabel\"\n :style=\"rootStyle\"\n :data-size=\"resolvedGroupSize\"\n :data-compact=\"compact ? '' : undefined\"\n >\n <component :is=\"VisibleAvatars\" />\n <slot v-if=\"overflowCount > 0\" name=\"overflow\" :count=\"overflowCount\">\n <VAvatar>+{{ overflowCount }}</VAvatar>\n </slot>\n </div>\n</template>\n\n<style>\n@layer vectis.components {\n .v-avatar-group {\n /* The separation ring, declared here so that every child .v-avatar inherits it. */\n --avatar-ring-color: var(--vectis-color-surface);\n display: inline-flex;\n align-items: center;\n }\n\n /*\n * Take overlap height from the group so wrappers and differently sized avatars share one row\n * contract.\n */\n .v-avatar-group > * + * {\n margin-inline-start: calc(var(--control-height) * -0.3);\n }\n\n /* On hover, or as soon as something inside it takes focus, a disc rises above its\n neighbours so it is seen whole rather than clipped by the next one. */\n .v-avatar-group > *:hover,\n .v-avatar-group > *:focus-within {\n z-index: 1;\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;EAmDA,IAAM,IAAQ,GAQR,IAAY,QAAmB,EAAM,KAAK;EAYhD,EAAQ,GAAgB;GACtB,IAAI,OAAO;IACT,OAAO,EAAM;GACf;GACA,IAAI,UAAU;IACZ,OAAO,EAAM;GACf;EACF,CAAC;EAED,IAAM,IAAQ,EAAa,GAGrB,IAAe,QACnB,EAAM,QAAQ,KAAA,KAAa,EAAM,MAAM,IAAI,EAAM,MAAM,MAAM,GAAG,EAAM,GAAG,IAAI,EAAM,KACrF,GACM,IAAgB,QAAe,EAAM,MAAM,SAAS,EAAa,MAAM,MAAM,GAI7E,UAAuB,EAAa,OAEpC,IAAY,QAChB,EAAM,cAAc,KAAA,IAAyD,KAAA,IAA7C,EAAE,uBAAuB,EAAM,UAAU,CAC3E,GAMM,IAAoB,QAA2B,EAAM,QAAA,IAA2B;yBAIpF,EAYM,OAAA;GAXJ,OAAM;GACN,MAAK;GACJ,cAAY,EAAA,CAAA;GACZ,OAAK,EAAE,EAAA,KAAS;GAChB,aAAW,EAAA;GACX,gBAAc,EAAA,UAAO,KAAQ,KAAA;YAE9B,EAAkC,EAAlB,CAAc,CAAA,IAClB,EAAA,QAAa,IAAzB,EAEO,EAAA,QAAA,YAAA,EAFyC,OAAO,EAAA,MAAa,SAE7D,CADL,EAAuC,GAAA,MAAA;oBAA7B,CAAA,EAAD,MAAC,EAAG,EAAA,KAAa,GAAA,CAAA,CAAA,CAAA"}
|
|
@@ -4,10 +4,6 @@ export interface AvatarGroupContext {
|
|
|
4
4
|
size?: AvatarSize;
|
|
5
5
|
compact?: boolean;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
* The size of an avatar that neither names one nor sits in a group that does. VAvatar and
|
|
9
|
-
* VAvatarGroup both read it: the group sets `--control-height` at its own level, for the
|
|
10
|
-
* overlap, so the two cannot disagree on what an unsized avatar measures.
|
|
11
|
-
*/
|
|
7
|
+
/** The size of an avatar that neither names one nor sits in a group that does. */
|
|
12
8
|
export declare const AVATAR_DEFAULT_SIZE: AvatarSize;
|
|
13
9
|
export declare const avatarGroupKey: InjectionKey<AvatarGroupContext>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":[],"sources":["../../../src/components/VAvatar/context.ts"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["../../../src/components/VAvatar/context.ts"],"sourcesContent":["/**\n * Explicit avatar size overrides the group fallback. Compact is cumulative, so a compact group\n * cannot have an expanded child.\n */\n\nimport type { InjectionKey } from 'vue'\n\nimport type { AvatarSize } from './VAvatar.vue'\n\nexport interface AvatarGroupContext {\n size?: AvatarSize\n compact?: boolean\n}\n\n/** The size of an avatar that neither names one nor sits in a group that does. */\nexport const AVATAR_DEFAULT_SIZE: AvatarSize = 'md'\n\nexport const avatarGroupKey: InjectionKey<AvatarGroupContext> = Symbol('v-avatar-group')\n"],"mappings":";AAiBA,IAAa,IAAmD,OAAO,gBAAgB"}
|