mood-ui 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/data-display/calendar/AgendaView.cjs.map +1 -1
- package/dist/components/data-display/calendar/AgendaView.mjs.map +1 -1
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.cjs +4 -1
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.mjs +4 -1
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/DayView.cjs.map +1 -1
- package/dist/components/data-display/calendar/DayView.mjs.map +1 -1
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.cjs +7 -4
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.mjs +7 -4
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/MonthView.cjs +1 -1
- package/dist/components/data-display/calendar/MonthView.cjs.map +1 -1
- package/dist/components/data-display/calendar/MonthView.mjs +1 -1
- package/dist/components/data-display/calendar/MonthView.mjs.map +1 -1
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.cjs +8 -12
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.mjs +8 -12
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/Scheduler.cjs.map +1 -1
- package/dist/components/data-display/calendar/Scheduler.mjs.map +1 -1
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.cjs +7 -4
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.mjs +7 -4
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/WeekView.cjs.map +1 -1
- package/dist/components/data-display/calendar/WeekView.mjs.map +1 -1
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.cjs +7 -4
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.mjs +7 -4
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.cjs.map +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.mjs.map +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Drawer.cjs.map +1 -1
- package/dist/components/feedback/Drawer.mjs.map +1 -1
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.cjs +4 -9
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.mjs +4 -9
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Modal.cjs.map +1 -1
- package/dist/components/feedback/Modal.mjs.map +1 -1
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.cjs +4 -9
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.mjs +4 -9
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Tooltip.cjs.map +1 -1
- package/dist/components/feedback/Tooltip.mjs.map +1 -1
- package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.cjs +44 -17
- package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.mjs +44 -17
- package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/Combobox.cjs.map +1 -1
- package/dist/components/forms/Combobox.mjs.map +1 -1
- package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.cjs +2 -2
- package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/PhoneInput.cjs.map +1 -1
- package/dist/components/forms/PhoneInput.mjs.map +1 -1
- package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.cjs +6 -1
- package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.mjs +6 -1
- package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/SearchInput.cjs.map +1 -1
- package/dist/components/forms/SearchInput.mjs.map +1 -1
- package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.cjs +8 -6
- package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.mjs +8 -6
- package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/layout/PopoverPanel.cjs +1 -1
- package/dist/components/layout/PopoverPanel.cjs.map +1 -1
- package/dist/components/layout/PopoverPanel.mjs +1 -1
- package/dist/components/layout/PopoverPanel.mjs.map +1 -1
- package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.cjs +2 -2
- package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/navigation/Switcher.cjs.map +1 -1
- package/dist/components/navigation/Switcher.mjs.map +1 -1
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.cjs +38 -40
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.mjs +38 -40
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/composables/eventColors.cjs +51 -27
- package/dist/composables/eventColors.cjs.map +1 -1
- package/dist/composables/eventColors.mjs +51 -27
- package/dist/composables/eventColors.mjs.map +1 -1
- package/dist/composables/useBodyScrollLock.cjs +44 -0
- package/dist/composables/useBodyScrollLock.cjs.map +1 -0
- package/dist/composables/useBodyScrollLock.mjs +43 -0
- package/dist/composables/useBodyScrollLock.mjs.map +1 -0
- package/dist/composables/useCalendarTheme.cjs +29 -8
- package/dist/composables/useCalendarTheme.cjs.map +1 -1
- package/dist/composables/useCalendarTheme.mjs +29 -8
- package/dist/composables/useCalendarTheme.mjs.map +1 -1
- package/dist/composables/usePopover.cjs +44 -12
- package/dist/composables/usePopover.cjs.map +1 -1
- package/dist/composables/usePopover.mjs +44 -12
- package/dist/composables/usePopover.mjs.map +1 -1
- package/dist/mood-ui.css +9 -9
- package/dist/types/composables/eventColors.d.ts +2 -2
- package/dist/types/composables/useBodyScrollLock.d.ts +19 -0
- package/dist/types/composables/useCalendarTheme.d.ts +2 -0
- package/dist/types/interfaces/data-display/calendar/AgendaView.interface.d.ts +5 -0
- package/dist/types/interfaces/data-display/calendar/DayView.interface.d.ts +5 -0
- package/dist/types/interfaces/data-display/calendar/MonthView.interface.d.ts +5 -0
- package/dist/types/interfaces/data-display/calendar/Scheduler.interface.d.ts +5 -0
- package/dist/types/interfaces/data-display/calendar/WeekView.interface.d.ts +5 -0
- package/dist/types/utils/cssLength.d.ts +5 -0
- package/dist/types/utils/tooltipArrow.d.ts +34 -0
- package/dist/utils/cssLength.cjs +13 -0
- package/dist/utils/cssLength.cjs.map +1 -0
- package/dist/utils/cssLength.mjs +13 -0
- package/dist/utils/cssLength.mjs.map +1 -0
- package/dist/utils/tooltipArrow.cjs +37 -0
- package/dist/utils/tooltipArrow.cjs.map +1 -0
- package/dist/utils/tooltipArrow.mjs +36 -0
- package/dist/utils/tooltipArrow.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.vue_vue_type_script_setup_true_lang.mjs","names":[],"sources":["../../../src/components/forms/SearchInput.vue"],"sourcesContent":["<template> \n <div :class=\"['flex flex-col gap-1.5', fullWidth ? 'w-full' : 'inline-flex']\"> \n <label \n v-if=\"label\" \n :for=\"fieldId\" \n class=\"text-caption font-medium text-foreground\" \n > \n {{ label }} \n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span> \n </label> \n \n <div\n ref=\"wrapperEl\"\n :class=\"[\n 'modo-field-wrapper flex items-center gap-2',\n wrapperVariantClasses,\n wrapperSizeClasses,\n radiusClasses,\n fullWidth ? 'w-full' : '',\n isDisabled ? 'opacity-60 cursor-not-allowed' : '',\n ]\"\n >\n <MagnifyingGlassIcon \n aria-hidden=\"true\" \n :class=\"['shrink-0', affordanceIconClass, iconSizeClasses]\" \n /> \n \n <input \n :id=\"fieldId\" \n ref=\"inputRef\" \n type=\"search\" \n :value=\"modelValue ?? ''\" \n :placeholder=\"placeholder\" \n :disabled=\"isDisabled\" \n :readonly=\"readonly\" \n :required=\"required\" \n :name=\"name\" \n :maxlength=\"maxLength\" \n :autofocus=\"autofocus\" \n autocomplete=\"off\" \n spellcheck=\"false\" \n role=\"searchbox\"\n :aria-label=\"!label ? ariaLabel : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-describedby=\"describedBy\"\n :aria-required=\"required || undefined\"\n :aria-expanded=\"hasDropdown ? isOpen : undefined\"\n :aria-controls=\"hasDropdown && isOpen ? `${fieldId}-results` : undefined\"\n :aria-activedescendant=\"isOpen && highlightedIdx >= 0 ? `${fieldId}-opt-${highlightedIdx}` : undefined\"\n :class=\"[ \n 'modo-field-native flex-1 min-w-0 bg-transparent p-0', \n 'text-foreground placeholder:text-muted-foreground', \n 'disabled:cursor-not-allowed', \n inputTextClasses, \n ]\" \n @input=\"onInput\" \n @keydown=\"onKeydown\" \n @focus=\"onFocus\" \n @blur=\"onBlur\" \n /> \n \n <Loader \n v-if=\"loading\" \n :size=\"size === 'large' ? 'medium' : 'small'\" \n :class=\"['shrink-0', affordanceIconClass]\" \n /> \n \n <Button \n v-else-if=\"hasValue && !isDisabled && !readonly\" \n variant=\"text\" \n size=\"xs\" \n radius=\"full\" \n :icon=\"XMarkIcon\" \n :ariaLabel=\"loc.searchInput.clear\" \n tabindex=\"-1\" \n :class=\"['shrink-0', affordanceActionClass]\" \n @click=\"onClear\" \n /> \n \n <!-- The shortcut hint stays while the field is empty (focused or not)\n so focusing never removes it and reflows the width. It yields to\n the clear button as soon as there is a value. -->\n <kbd\n v-else-if=\"shortcut\"\n aria-hidden=\"true\"\n :class=\"[ \n 'shrink-0 select-none rounded-md px-1.5 py-0.5', \n 'text-[11px] leading-none font-sans font-medium tabular-nums', \n 'bg-muted text-muted-foreground border border-border', \n ]\" \n > \n {{ shortcutLabel }}\n </kbd>\n </div>\n\n <!-- RESULTS DROPDOWN -->\n <PopoverPanel\n v-if=\"hasDropdown\"\n :open=\"isOpen\"\n :style=\"panelStyle\"\n :radius=\"resolvedRadius\"\n role=\"presentation\"\n @update:panelRef=\"panelRef = $event\"\n >\n <!-- mousedown.prevent keeps focus in the input while clicking a row -->\n <div class=\"modo-search-results\" @mousedown.prevent>\n <slot\n name=\"results\"\n :items=\"resultItems\"\n :query=\"String(modelValue ?? '')\"\n :highlighted=\"highlightedIdx\"\n :select=\"selectResult\"\n :close=\"closePopover\"\n >\n <div v-if=\"loading\" class=\"px-3 py-6 flex items-center justify-center\">\n <slot name=\"loading\"><Loader size=\"small\" /></slot>\n </div>\n <div\n v-else-if=\"!resultItems.length\"\n class=\"px-3 py-6 text-center text-muted-foreground text-body\"\n >\n <slot name=\"empty\">{{ emptyText }}</slot>\n </div>\n <ul v-else :id=\"`${fieldId}-results`\" role=\"listbox\" class=\"flex flex-col\">\n <template v-for=\"row in renderRows\" :key=\"row.key\">\n <li\n v-if=\"row.kind === 'header'\"\n role=\"presentation\"\n class=\"px-3 pt-2 pb-1 text-caption font-medium text-muted-foreground select-none\"\n >\n {{ row.label }}\n </li>\n <li\n v-else\n :id=\"`${fieldId}-opt-${row.index}`\"\n role=\"option\"\n :aria-selected=\"row.index === highlightedIdx\"\n :aria-disabled=\"row.item.disabled || undefined\"\n >\n <component\n :is=\"row.item.href && !row.item.disabled ? 'a' : 'div'\"\n :href=\"row.item.href && !row.item.disabled ? row.item.href : undefined\"\n :target=\"row.item.external ? '_blank' : undefined\"\n :rel=\"row.item.external ? 'noopener noreferrer' : undefined\"\n class=\"flex items-center gap-2.5 px-3 py-2 text-body transition-colors duration-fast ease-standard\"\n :class=\"[\n row.item.disabled\n ? 'opacity-50 cursor-not-allowed'\n : 'cursor-pointer',\n row.index === highlightedIdx && !row.item.disabled ? 'bg-accent' : '',\n ]\"\n @mouseenter=\"row.item.disabled ? null : (highlightedIdx = row.index)\"\n @click=\"selectResult(row.item)\"\n >\n <slot name=\"item\" :item=\"row.item\" :active=\"row.index === highlightedIdx\">\n <component\n :is=\"row.item.icon\"\n v-if=\"row.item.icon\"\n class=\"size-4 shrink-0 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n <span class=\"flex flex-col min-w-0 flex-1\">\n <span class=\"truncate\">{{ row.item.label }}</span>\n <span\n v-if=\"row.item.description\"\n class=\"text-caption text-muted-foreground truncate\"\n >{{ row.item.description }}</span>\n </span>\n <span\n v-if=\"row.item.shortcut\"\n class=\"ml-2 text-caption text-muted-foreground tabular-nums shrink-0\"\n aria-hidden=\"true\"\n >{{ row.item.shortcut }}</span>\n </slot>\n </component>\n </li>\n </template>\n </ul>\n </slot>\n </div>\n </PopoverPanel>\n\n <div\n v-if=\"errorText || helperText || showCounterEffective\" \n class=\"flex items-start justify-between gap-2\" \n > \n <Typography \n v-if=\"errorText\" \n :id=\"errorId\" \n variant=\"caption\" \n size=\"medium\" \n color=\"danger\" \n as=\"p\" \n > \n {{ errorText }} \n </Typography> \n <Typography \n v-else-if=\"helperText\" \n :id=\"helperId\" \n variant=\"caption\" \n size=\"medium\" \n color=\"muted\" \n as=\"p\" \n > \n {{ helperText }} \n </Typography> \n <span v-else class=\"flex-1\" /> \n \n <span \n v-if=\"showCounterEffective\" \n :id=\"counterId\" \n :class=\"[ \n 'text-caption shrink-0 tabular-nums', \n counterOverflow ? 'text-destructive' : 'text-muted-foreground', \n ]\" \n > \n {{ currentLength }}/{{ maxLength }} \n </span> \n </div> \n </div> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, onBeforeUnmount, onMounted, ref, useSlots, watch, nextTick } from 'vue';\nimport type { SearchInput, SearchResultItem } from '../../interfaces/forms/SearchInput.interface';\nimport {\n useFieldState,\n useFieldClasses,\n FIELD_AFFORDANCE_ACTION_BY_COLOR,\n FIELD_AFFORDANCE_ICON_BY_COLOR,\n} from '../../composables/useField';\nimport Loader from '../feedback/Loader.vue';\nimport Button from './Button.vue';\nimport PopoverPanel from '../layout/PopoverPanel.vue';\nimport { usePopover } from '../../composables/usePopover';\nimport { MagnifyingGlassIcon, XMarkIcon } from '@heroicons/vue/24/outline';\nimport Typography from '../data-display/Typography.vue';\nimport { useModoLocale, useResolvedRadius, useResolvedSize, useSizeTokens } from '../../composables/useModoConfig';\n\nconst loc = useModoLocale();\nconst slots = useSlots();\n\nconst emit = defineEmits<{\n 'update:modelValue': [value: string];\n change: [value: string];\n focus: [event: FocusEvent];\n blur: [event: FocusEvent];\n clear: [];\n /** Se emite al presionar Enter o tras el debounce. */\n search: [value: string];\n /** A result row was chosen (click / Enter on the highlighted row). */\n select: [item: SearchResultItem];\n /** Results popover open state (for `v-model:open`). */\n 'update:open': [value: boolean];\n}>();\n\nconst props = withDefaults(defineProps<SearchInput>(), {\n variant: 'outline',\n color: 'default',\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n showCounter: false,\n autofocus: false,\n debounce: 0,\n placeholder: 'Search…',\n resultsPlacement: 'bottom-start',\n});\n \nconst resolvedSize = useResolvedSize(() => props.size);\nconst sz = useSizeTokens(() => props.size);\n\nconst inputRef = ref<HTMLInputElement | null>(null); \nconst focused = ref(false); \n \nconst { \n fieldId, \n radius, \n stateColor, \n hasError, \n hasValue, \n isDisabled, \n currentLength, \n showCounterEffective, \n counterOverflow, \n errorId, \n helperId, \n counterId, \n describedBy, \n} = useFieldState(props, { componentName: 'SearchInput', idPrefix: 'modo-search' }); \n \nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({ \n variant: () => props.variant, \n stateColor, \n hasError, \n radius, \n halo: () => props.halo, \n}); \n\nconst affordanceIconClass = computed(() => FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? 'text-muted-foreground');\nconst affordanceActionClass = computed(() => FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ?? 'text-muted-foreground hover:text-foreground');\n\n/* ---------- Results dropdown ---------- */\nconst resolvedRadius = useResolvedRadius(() => props.radius);\n\n// The dropdown is active when the host passes `items` (even empty) or a custom\n// `#results` slot. Filtering/async stays with the host — this only renders.\nconst hasDropdown = computed(() => props.items !== undefined || !!slots.results);\nconst resultItems = computed<SearchResultItem[]>(() => props.items ?? []);\n\nconst highlightedIdx = ref(-1);\nconst {\n triggerRef: popoverTrigger,\n panelRef,\n isOpen,\n panelStyle,\n open: openPopover,\n close: closePopover,\n} = usePopover({\n placement: () => props.resultsPlacement,\n matchTriggerWidth: true,\n closeOnEscape: false, // handled on the input so focus stays in the field\n closeOnScroll: false, // reposition on scroll; focusing the input can auto-scroll it into view\n onOpen: () => emit('update:open', true),\n onClose: () => { emit('update:open', false); highlightedIdx.value = -1; },\n});\n\nconst wrapperEl = ref<HTMLElement | null>(null);\nwatch(wrapperEl, (el) => { popoverTrigger.value = el; });\n\n// Flat render list with a group header inserted whenever `group` changes.\ntype RenderRow =\n | { kind: 'header'; label: string; key: string }\n | { kind: 'option'; item: SearchResultItem; index: number; key: string };\nconst renderRows = computed<RenderRow[]>(() => {\n const rows: RenderRow[] = [];\n let prevGroup: string | undefined;\n resultItems.value.forEach((item, index) => {\n if (item.group && item.group !== prevGroup) {\n rows.push({ kind: 'header', label: item.group, key: `h-${index}` });\n prevGroup = item.group;\n }\n rows.push({ kind: 'option', item, index, key: `o-${item.id ?? index}` });\n });\n return rows;\n});\n\nconst enabledIndices = computed(() =>\n resultItems.value.map((it, i) => (it.disabled ? -1 : i)).filter((i) => i !== -1),\n);\n\n// Show the popover only while focused and there is something to render.\nconst shouldShowResults = computed(() =>\n hasDropdown.value && focused.value &&\n (resultItems.value.length > 0 || props.loading || !!props.emptyText || !!slots.empty),\n);\n\nfunction syncOpen() {\n if (shouldShowResults.value) { if (!isOpen.value) openPopover(); }\n else if (isOpen.value) closePopover();\n}\nwatch(shouldShowResults, syncOpen);\nwatch(() => resultItems.value.length, () => { if (isOpen.value || shouldShowResults.value) nextTick(syncOpen); });\n\n// Optional external control via `v-model:open`.\nwatch(() => props.open, (v) => {\n if (v === undefined) return;\n if (v && shouldShowResults.value) openPopover();\n else if (!v) closePopover();\n});\n\nfunction moveHighlight(delta: 1 | -1) {\n const order = enabledIndices.value;\n if (!order.length) return;\n const cur = order.indexOf(highlightedIdx.value);\n highlightedIdx.value = cur === -1\n ? (delta > 0 ? order[0] : order[order.length - 1])\n : order[(cur + delta + order.length) % order.length];\n}\n\nfunction selectResult(item: SearchResultItem) {\n if (item.disabled) return;\n emit('select', item);\n closePopover();\n}\n\n/* ---------- Debounce ---------- */\nlet debounceTimer: number | null = null; \nfunction scheduleSearch(value: string) { \n if (!props.debounce || props.debounce <= 0) return; \n if (debounceTimer !== null) clearTimeout(debounceTimer); \n debounceTimer = window.setTimeout(() => { \n emit('search', value); \n debounceTimer = null; \n }, props.debounce); \n} \nfunction cancelDebounce() { \n if (debounceTimer !== null) { \n clearTimeout(debounceTimer); \n debounceTimer = null; \n } \n} \n \n/* ---------- Events ---------- */ \nfunction onInput(e: Event) { \n const target = e.target as HTMLInputElement; \n emit('update:modelValue', target.value); \n scheduleSearch(target.value); \n} \n \nfunction onKeydown(e: KeyboardEvent) {\n // Arrow keys drive the results dropdown when it is available.\n if (hasDropdown.value && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) {\n e.preventDefault();\n if (!isOpen.value && shouldShowResults.value) openPopover();\n moveHighlight(e.key === 'ArrowDown' ? 1 : -1);\n return;\n }\n if (e.key === 'Enter') {\n // Enter picks the highlighted result if the dropdown is open; otherwise\n // it keeps the existing \"submit search\" behaviour.\n if (isOpen.value && highlightedIdx.value >= 0) {\n const item = resultItems.value[highlightedIdx.value];\n if (item && !item.disabled) {\n e.preventDefault();\n selectResult(item);\n return;\n }\n }\n e.preventDefault();\n cancelDebounce();\n emit('search', String(props.modelValue ?? ''));\n return;\n }\n if (e.key === 'Escape') {\n // First Escape closes the dropdown; a second (or when closed) clears.\n if (isOpen.value) {\n e.preventDefault();\n closePopover();\n return;\n }\n if (hasValue.value) {\n e.preventDefault();\n onClear();\n }\n }\n}\n \nfunction onFocus(e: FocusEvent) {\n focused.value = true;\n emit('focus', e);\n // Open the results popover on focus if there is anything to show. Done\n // explicitly (not only via the watcher) so it fires on the very first focus.\n if (hasDropdown.value) nextTick(syncOpen);\n}\n \nfunction onBlur(e: FocusEvent) { \n focused.value = false; \n emit('blur', e); \n} \n \nfunction onClear() { \n cancelDebounce(); \n emit('update:modelValue', ''); \n emit('clear'); \n emit('search', ''); \n inputRef.value?.focus(); \n} \n \n/* ---------- Shortcut ---------- */\n// Stays `false` on SSR and on the first client paint to keep them\n// identical, then flips to the real platform value in onMounted. Without\n// this guard the server would render `Ctrl+K` and the client would\n// immediately replace it with `⌘K`, triggering a hydration warning.\nconst isMac = ref(false);\nonMounted(() => {\n isMac.value = /Mac|iPod|iPhone|iPad/.test(navigator.platform);\n});\n \ninterface ParsedShortcut { \n key: string; \n ctrl: boolean; \n meta: boolean; \n shift: boolean; \n alt: boolean; \n} \n \nconst parsedShortcut = computed<ParsedShortcut | null>(() => { \n if (!props.shortcut) return null; \n const parts = props.shortcut.toLowerCase().split('+').map((p) => p.trim()); \n const result: ParsedShortcut = { key: '', ctrl: false, meta: false, shift: false, alt: false }; \n for (const part of parts) { \n if (part === 'cmd' || part === 'meta' || part === 'command') { \n if (isMac.value) result.meta = true; \n else result.ctrl = true; \n } else if (part === 'ctrl' || part === 'control') { \n result.ctrl = true; \n } else if (part === 'shift') { \n result.shift = true; \n } else if (part === 'alt' || part === 'option') { \n result.alt = true; \n } else { \n result.key = part; \n } \n } \n return result.key ? result : null; \n}); \n \nconst shortcutLabel = computed(() => { \n const s = parsedShortcut.value; \n if (!s) return ''; \n const segs: string[] = []; \n if (s.meta) segs.push(isMac.value ? '⌘' : 'Ctrl');\n else if (s.ctrl) segs.push(isMac.value ? '⌃' : 'Ctrl');\n if (s.alt) segs.push(isMac.value ? '⌥' : 'Alt');\n if (s.shift) segs.push(isMac.value ? '⇧' : 'Shift');\n segs.push(s.key.length === 1 ? s.key.toUpperCase() : s.key); \n return segs.join(isMac.value ? '' : '+'); \n}); \n \nfunction onGlobalKeydown(e: KeyboardEvent) { \n const s = parsedShortcut.value; \n if (!s) return; \n \n // No robar atajos mientras el usuario escribe en otro campo (a menos que sea una combinación con modificador). \n const target = e.target as HTMLElement | null; \n const typingElsewhere = !!target && (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable); \n const hasModifier = s.meta || s.ctrl || s.alt; \n if (typingElsewhere && !hasModifier && target !== inputRef.value) return; \n \n if ( \n e.key.toLowerCase() === s.key && \n e.metaKey === s.meta && \n e.ctrlKey === s.ctrl && \n e.shiftKey === s.shift && \n e.altKey === s.alt \n ) { \n e.preventDefault(); \n inputRef.value?.focus(); \n inputRef.value?.select(); \n } \n} \n \nonMounted(() => { \n if (parsedShortcut.value) { \n window.addEventListener('keydown', onGlobalKeydown); \n } \n}); \n \nonBeforeUnmount(() => { \n cancelDebounce(); \n window.removeEventListener('keydown', onGlobalKeydown); \n}); \n \n/* ---------- Classes ---------- */ \n \nconst wrapperSizeClasses = computed(() => `${sz.value.control} ${sz.value.padX}`);\n\nconst inputTextClasses = computed(() => sz.value.text);\n\nconst iconSizeClasses = computed(() => sz.value.icon); \n \ndefineExpose({ \n focus: () => inputRef.value?.focus(), \n blur: () => inputRef.value?.blur(), \n select: () => inputRef.value?.select(), \n clear: onClear, \n inputRef, \n}); \n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+OA,MAAM,MAAM,eAAe;EAC3B,MAAM,QAAQ,UAAU;EAExB,MAAM,OAAO;EAcb,MAAM,QAAQ;EAeO,sBAAsB,MAAM,KAAK;EACtD,MAAM,KAAK,oBAAoB,MAAM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aAAa,QAAA,cAAc,MAAA,qBAAoB,IAAA,WAAA,EADzD,mBAoCM,OApCN,aAoCM,CA/BQ,QAAA,aAAA,WAAA,EADV,YASa,oBAAA;;KAPR,IAAI,MAAA,QAAO;KACZ,SAAQ;KACR,MAAK;KACL,OAAM;KACN,IAAG;;4BAEY,CAAA,gBAAA,gBAAZ,QAAA,UAAS,EAAA,EAAA,CAAA,CAAA;;qBAGD,QAAA,cAAA,WAAA,EADf,YASa,oBAAA;;KAPR,IAAI,MAAA,SAAQ;KACb,SAAQ;KACR,MAAK;KACL,OAAM;KACN,IAAG;;4BAEa,CAAA,gBAAA,gBAAb,QAAA,WAAU,EAAA,EAAA,CAAA,CAAA;;mCAEjB,mBAA8B,QAA9B,YAA8B,GAGpB,MAAA,qBAAoB,IAAA,WAAA,EAD9B,mBASO,QAAA;;KAPF,IAAI,MAAA,UAAS;KACb,OAAK,eAAA,CAAA,sCAAoF,MAAA,gBAAe,GAAA,qBAAA,wBAAA,CAAA;uBAKtG,MAAA,cAAa,CAAA,GAAG,MAAC,gBAAG,QAAA,UAAS,EAAA,IAAA,YAAA,IAAA,mBAAA,IAAA,KAAA,CAAA,CAAA,IAAA,mBAAA,IAAA,KAAA"}
|
|
1
|
+
{"version":3,"file":"SearchInput.vue_vue_type_script_setup_true_lang.mjs","names":[],"sources":["../../../src/components/forms/SearchInput.vue"],"sourcesContent":["<template> \n <div :class=\"['flex flex-col gap-1.5', fullWidth ? 'w-full' : 'inline-flex']\"> \n <label \n v-if=\"label\" \n :for=\"fieldId\" \n class=\"text-caption font-medium text-foreground\" \n > \n {{ label }} \n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span> \n </label> \n \n <div\n ref=\"wrapperEl\"\n :class=\"[\n 'modo-field-wrapper flex items-center gap-2',\n wrapperVariantClasses,\n wrapperSizeClasses,\n radiusClasses,\n fullWidth ? 'w-full' : '',\n isDisabled ? 'opacity-60 cursor-not-allowed' : '',\n ]\"\n >\n <MagnifyingGlassIcon \n aria-hidden=\"true\" \n :class=\"['shrink-0', affordanceIconClass, iconSizeClasses]\" \n /> \n \n <input \n :id=\"fieldId\" \n ref=\"inputRef\" \n type=\"search\" \n :value=\"modelValue ?? ''\" \n :placeholder=\"placeholder\" \n :disabled=\"isDisabled\" \n :readonly=\"readonly\" \n :required=\"required\" \n :name=\"name\" \n :maxlength=\"maxLength\" \n :autofocus=\"autofocus\" \n autocomplete=\"off\" \n spellcheck=\"false\" \n role=\"searchbox\"\n :aria-label=\"!label ? ariaLabel : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-describedby=\"describedBy\"\n :aria-required=\"required || undefined\"\n :aria-expanded=\"hasDropdown ? isOpen : undefined\"\n :aria-controls=\"hasDropdown && isOpen ? `${fieldId}-results` : undefined\"\n :aria-activedescendant=\"isOpen && highlightedIdx >= 0 ? `${fieldId}-opt-${highlightedIdx}` : undefined\"\n :class=\"[ \n 'modo-field-native flex-1 min-w-0 bg-transparent p-0', \n 'text-foreground placeholder:text-muted-foreground', \n 'disabled:cursor-not-allowed', \n inputTextClasses, \n ]\" \n @input=\"onInput\" \n @keydown=\"onKeydown\" \n @focus=\"onFocus\" \n @blur=\"onBlur\" \n /> \n \n <Loader \n v-if=\"loading\" \n :size=\"size === 'large' ? 'medium' : 'small'\" \n :class=\"['shrink-0', affordanceIconClass]\" \n /> \n \n <Button \n v-else-if=\"hasValue && !isDisabled && !readonly\" \n variant=\"text\" \n size=\"xs\" \n radius=\"full\" \n :icon=\"XMarkIcon\" \n :ariaLabel=\"loc.searchInput.clear\" \n tabindex=\"-1\" \n :class=\"['shrink-0', affordanceActionClass]\" \n @click=\"onClear\" \n /> \n \n <!-- The shortcut hint stays while the field is empty (focused or not)\n so focusing never removes it and reflows the width. It yields to\n the clear button as soon as there is a value. -->\n <kbd\n v-else-if=\"shortcut\"\n aria-hidden=\"true\"\n :class=\"[ \n 'shrink-0 select-none rounded-md px-1.5 py-0.5', \n 'text-[11px] leading-none font-sans font-medium tabular-nums', \n 'bg-muted text-muted-foreground border border-border', \n ]\" \n > \n {{ shortcutLabel }}\n </kbd>\n </div>\n\n <!-- RESULTS DROPDOWN -->\n <PopoverPanel\n v-if=\"hasDropdown\"\n :open=\"isOpen\"\n :style=\"panelStyle\"\n :radius=\"resolvedRadius\"\n role=\"presentation\"\n @update:panelRef=\"panelRef = $event\"\n >\n <!-- mousedown.prevent keeps focus in the input while clicking a row -->\n <div class=\"modo-search-results\" @mousedown.prevent>\n <slot\n name=\"results\"\n :items=\"resultItems\"\n :query=\"String(modelValue ?? '')\"\n :highlighted=\"highlightedIdx\"\n :select=\"selectResult\"\n :close=\"closePopover\"\n >\n <!--\n The panel loader only takes over when there is nothing\n to show yet. Swapping a populated list for a spinner on\n every keystroke makes the dropdown collapse and reopen\n as the user types; the affordance spinner in the field\n already signals the in-flight request.\n -->\n <div v-if=\"loading && !resultItems.length\" class=\"px-3 py-6 flex items-center justify-center\">\n <slot name=\"loading\"><Loader size=\"small\" /></slot>\n </div>\n <div\n v-else-if=\"!resultItems.length\"\n class=\"px-3 py-6 text-center text-muted-foreground text-body\"\n >\n <slot name=\"empty\">{{ emptyText }}</slot>\n </div>\n <ul\n v-else\n :id=\"`${fieldId}-results`\"\n role=\"listbox\"\n :aria-busy=\"loading || undefined\"\n class=\"flex flex-col\"\n >\n <template v-for=\"row in renderRows\" :key=\"row.key\">\n <li\n v-if=\"row.kind === 'header'\"\n role=\"presentation\"\n class=\"px-3 pt-2 pb-1 text-caption font-medium text-muted-foreground select-none\"\n >\n {{ row.label }}\n </li>\n <li\n v-else\n :id=\"`${fieldId}-opt-${row.index}`\"\n role=\"option\"\n :aria-selected=\"row.index === highlightedIdx\"\n :aria-disabled=\"row.item.disabled || undefined\"\n >\n <component\n :is=\"row.item.href && !row.item.disabled ? 'a' : 'div'\"\n :href=\"row.item.href && !row.item.disabled ? row.item.href : undefined\"\n :target=\"row.item.external ? '_blank' : undefined\"\n :rel=\"row.item.external ? 'noopener noreferrer' : undefined\"\n class=\"flex items-center gap-2.5 px-3 py-2 text-body transition-colors duration-fast ease-standard\"\n :class=\"[\n row.item.disabled\n ? 'opacity-50 cursor-not-allowed'\n : 'cursor-pointer',\n row.index === highlightedIdx && !row.item.disabled ? 'bg-accent' : '',\n ]\"\n @mouseenter=\"row.item.disabled ? null : (highlightedIdx = row.index)\"\n @click=\"selectResult(row.item)\"\n >\n <slot name=\"item\" :item=\"row.item\" :active=\"row.index === highlightedIdx\">\n <component\n :is=\"row.item.icon\"\n v-if=\"row.item.icon\"\n class=\"size-4 shrink-0 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n <span class=\"flex flex-col min-w-0 flex-1\">\n <span class=\"truncate\">{{ row.item.label }}</span>\n <span\n v-if=\"row.item.description\"\n class=\"text-caption text-muted-foreground truncate\"\n >{{ row.item.description }}</span>\n </span>\n <span\n v-if=\"row.item.shortcut\"\n class=\"ml-2 text-caption text-muted-foreground tabular-nums shrink-0\"\n aria-hidden=\"true\"\n >{{ row.item.shortcut }}</span>\n </slot>\n </component>\n </li>\n </template>\n </ul>\n </slot>\n </div>\n </PopoverPanel>\n\n <div\n v-if=\"errorText || helperText || showCounterEffective\" \n class=\"flex items-start justify-between gap-2\" \n > \n <Typography \n v-if=\"errorText\" \n :id=\"errorId\" \n variant=\"caption\" \n size=\"medium\" \n color=\"danger\" \n as=\"p\" \n > \n {{ errorText }} \n </Typography> \n <Typography \n v-else-if=\"helperText\" \n :id=\"helperId\" \n variant=\"caption\" \n size=\"medium\" \n color=\"muted\" \n as=\"p\" \n > \n {{ helperText }} \n </Typography> \n <span v-else class=\"flex-1\" /> \n \n <span \n v-if=\"showCounterEffective\" \n :id=\"counterId\" \n :class=\"[ \n 'text-caption shrink-0 tabular-nums', \n counterOverflow ? 'text-destructive' : 'text-muted-foreground', \n ]\" \n > \n {{ currentLength }}/{{ maxLength }} \n </span> \n </div> \n </div> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, onBeforeUnmount, onMounted, ref, useSlots, watch, nextTick } from 'vue';\nimport type { SearchInput, SearchResultItem } from '../../interfaces/forms/SearchInput.interface';\nimport {\n useFieldState,\n useFieldClasses,\n FIELD_AFFORDANCE_ACTION_BY_COLOR,\n FIELD_AFFORDANCE_ICON_BY_COLOR,\n} from '../../composables/useField';\nimport Loader from '../feedback/Loader.vue';\nimport Button from './Button.vue';\nimport PopoverPanel from '../layout/PopoverPanel.vue';\nimport { usePopover } from '../../composables/usePopover';\nimport { MagnifyingGlassIcon, XMarkIcon } from '@heroicons/vue/24/outline';\nimport Typography from '../data-display/Typography.vue';\nimport { useModoLocale, useResolvedRadius, useResolvedSize, useSizeTokens } from '../../composables/useModoConfig';\n\nconst loc = useModoLocale();\nconst slots = useSlots();\n\nconst emit = defineEmits<{\n 'update:modelValue': [value: string];\n change: [value: string];\n focus: [event: FocusEvent];\n blur: [event: FocusEvent];\n clear: [];\n /** Se emite al presionar Enter o tras el debounce. */\n search: [value: string];\n /** A result row was chosen (click / Enter on the highlighted row). */\n select: [item: SearchResultItem];\n /** Results popover open state (for `v-model:open`). */\n 'update:open': [value: boolean];\n}>();\n\nconst props = withDefaults(defineProps<SearchInput>(), {\n variant: 'outline',\n color: 'default',\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n showCounter: false,\n autofocus: false,\n debounce: 0,\n placeholder: 'Search…',\n resultsPlacement: 'bottom-start',\n});\n \nconst resolvedSize = useResolvedSize(() => props.size);\nconst sz = useSizeTokens(() => props.size);\n\nconst inputRef = ref<HTMLInputElement | null>(null); \nconst focused = ref(false); \n \nconst { \n fieldId, \n radius, \n stateColor, \n hasError, \n hasValue, \n currentLength,\n showCounterEffective, \n counterOverflow, \n errorId, \n helperId, \n counterId, \n describedBy, \n} = useFieldState(props, { componentName: 'SearchInput', idPrefix: 'modo-search' }); \n \nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({ \n variant: () => props.variant, \n stateColor, \n hasError, \n radius, \n halo: () => props.halo, \n}); \n\n// Deliberately NOT `useFieldState`'s `isDisabled`, which also reports true\n// while `loading`. That is right for a field being submitted, but fatal for a\n// search box: the results are what load, not the input. Disabling it mid-query\n// makes the browser blur the element the user is typing in — focus is lost, the\n// results popover closes, and the next keystroke is dropped. For SearchInput,\n// only an explicit `disabled` disables.\nconst isDisabled = computed(() => !!props.disabled);\n\nconst affordanceIconClass = computed(() => FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? 'text-muted-foreground');\nconst affordanceActionClass = computed(() => FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ?? 'text-muted-foreground hover:text-foreground');\n\n/* ---------- Results dropdown ---------- */\nconst resolvedRadius = useResolvedRadius(() => props.radius);\n\n// The dropdown is active when the host passes `items` (even empty) or a custom\n// `#results` slot. Filtering/async stays with the host — this only renders.\nconst hasDropdown = computed(() => props.items !== undefined || !!slots.results);\nconst resultItems = computed<SearchResultItem[]>(() => props.items ?? []);\n\nconst highlightedIdx = ref(-1);\nconst {\n triggerRef: popoverTrigger,\n panelRef,\n isOpen,\n panelStyle,\n open: openPopover,\n close: closePopover,\n} = usePopover({\n placement: () => props.resultsPlacement,\n matchTriggerWidth: true,\n closeOnEscape: false, // handled on the input so focus stays in the field\n closeOnScroll: false, // reposition on scroll; focusing the input can auto-scroll it into view\n onOpen: () => emit('update:open', true),\n onClose: () => { emit('update:open', false); highlightedIdx.value = -1; },\n});\n\nconst wrapperEl = ref<HTMLElement | null>(null);\nwatch(wrapperEl, (el) => { popoverTrigger.value = el; });\n\n// Flat render list with a group header inserted whenever `group` changes.\ntype RenderRow =\n | { kind: 'header'; label: string; key: string }\n | { kind: 'option'; item: SearchResultItem; index: number; key: string };\nconst renderRows = computed<RenderRow[]>(() => {\n const rows: RenderRow[] = [];\n let prevGroup: string | undefined;\n resultItems.value.forEach((item, index) => {\n if (item.group && item.group !== prevGroup) {\n rows.push({ kind: 'header', label: item.group, key: `h-${index}` });\n prevGroup = item.group;\n }\n rows.push({ kind: 'option', item, index, key: `o-${item.id ?? index}` });\n });\n return rows;\n});\n\nconst enabledIndices = computed(() =>\n resultItems.value.map((it, i) => (it.disabled ? -1 : i)).filter((i) => i !== -1),\n);\n\n// Show the popover only while focused and there is something to render.\nconst shouldShowResults = computed(() =>\n hasDropdown.value && focused.value &&\n (resultItems.value.length > 0 || props.loading || !!props.emptyText || !!slots.empty),\n);\n\nfunction syncOpen() {\n if (shouldShowResults.value) { if (!isOpen.value) openPopover(); }\n else if (isOpen.value) closePopover();\n}\nwatch(shouldShowResults, syncOpen);\nwatch(() => resultItems.value.length, () => { if (isOpen.value || shouldShowResults.value) nextTick(syncOpen); });\n\n// Optional external control via `v-model:open`.\nwatch(() => props.open, (v) => {\n if (v === undefined) return;\n if (v && shouldShowResults.value) openPopover();\n else if (!v) closePopover();\n});\n\nfunction moveHighlight(delta: 1 | -1) {\n const order = enabledIndices.value;\n if (!order.length) return;\n const cur = order.indexOf(highlightedIdx.value);\n highlightedIdx.value = cur === -1\n ? (delta > 0 ? order[0] : order[order.length - 1])\n : order[(cur + delta + order.length) % order.length];\n}\n\nfunction selectResult(item: SearchResultItem) {\n if (item.disabled) return;\n emit('select', item);\n closePopover();\n}\n\n/* ---------- Debounce ---------- */\nlet debounceTimer: number | null = null; \nfunction scheduleSearch(value: string) { \n if (!props.debounce || props.debounce <= 0) return; \n if (debounceTimer !== null) clearTimeout(debounceTimer); \n debounceTimer = window.setTimeout(() => { \n emit('search', value); \n debounceTimer = null; \n }, props.debounce); \n} \nfunction cancelDebounce() { \n if (debounceTimer !== null) { \n clearTimeout(debounceTimer); \n debounceTimer = null; \n } \n} \n \n/* ---------- Events ---------- */ \nfunction onInput(e: Event) { \n const target = e.target as HTMLInputElement; \n emit('update:modelValue', target.value); \n scheduleSearch(target.value); \n} \n \nfunction onKeydown(e: KeyboardEvent) {\n // Arrow keys drive the results dropdown when it is available.\n if (hasDropdown.value && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) {\n e.preventDefault();\n if (!isOpen.value && shouldShowResults.value) openPopover();\n moveHighlight(e.key === 'ArrowDown' ? 1 : -1);\n return;\n }\n if (e.key === 'Enter') {\n // Enter picks the highlighted result if the dropdown is open; otherwise\n // it keeps the existing \"submit search\" behaviour.\n if (isOpen.value && highlightedIdx.value >= 0) {\n const item = resultItems.value[highlightedIdx.value];\n if (item && !item.disabled) {\n e.preventDefault();\n selectResult(item);\n return;\n }\n }\n e.preventDefault();\n cancelDebounce();\n emit('search', String(props.modelValue ?? ''));\n return;\n }\n if (e.key === 'Escape') {\n // First Escape closes the dropdown; a second (or when closed) clears.\n if (isOpen.value) {\n e.preventDefault();\n closePopover();\n return;\n }\n if (hasValue.value) {\n e.preventDefault();\n onClear();\n }\n }\n}\n \nfunction onFocus(e: FocusEvent) {\n focused.value = true;\n emit('focus', e);\n // Open the results popover on focus if there is anything to show. Done\n // explicitly (not only via the watcher) so it fires on the very first focus.\n if (hasDropdown.value) nextTick(syncOpen);\n}\n \nfunction onBlur(e: FocusEvent) {\n focused.value = false;\n emit('blur', e);\n}\n \nfunction onClear() { \n cancelDebounce(); \n emit('update:modelValue', ''); \n emit('clear'); \n emit('search', ''); \n inputRef.value?.focus(); \n} \n \n/* ---------- Shortcut ---------- */\n// Stays `false` on SSR and on the first client paint to keep them\n// identical, then flips to the real platform value in onMounted. Without\n// this guard the server would render `Ctrl+K` and the client would\n// immediately replace it with `⌘K`, triggering a hydration warning.\nconst isMac = ref(false);\nonMounted(() => {\n isMac.value = /Mac|iPod|iPhone|iPad/.test(navigator.platform);\n});\n \ninterface ParsedShortcut { \n key: string; \n ctrl: boolean; \n meta: boolean; \n shift: boolean; \n alt: boolean; \n} \n \nconst parsedShortcut = computed<ParsedShortcut | null>(() => { \n if (!props.shortcut) return null; \n const parts = props.shortcut.toLowerCase().split('+').map((p) => p.trim()); \n const result: ParsedShortcut = { key: '', ctrl: false, meta: false, shift: false, alt: false }; \n for (const part of parts) { \n if (part === 'cmd' || part === 'meta' || part === 'command') { \n if (isMac.value) result.meta = true; \n else result.ctrl = true; \n } else if (part === 'ctrl' || part === 'control') { \n result.ctrl = true; \n } else if (part === 'shift') { \n result.shift = true; \n } else if (part === 'alt' || part === 'option') { \n result.alt = true; \n } else { \n result.key = part; \n } \n } \n return result.key ? result : null; \n}); \n \nconst shortcutLabel = computed(() => { \n const s = parsedShortcut.value; \n if (!s) return ''; \n const segs: string[] = []; \n if (s.meta) segs.push(isMac.value ? '⌘' : 'Ctrl');\n else if (s.ctrl) segs.push(isMac.value ? '⌃' : 'Ctrl');\n if (s.alt) segs.push(isMac.value ? '⌥' : 'Alt');\n if (s.shift) segs.push(isMac.value ? '⇧' : 'Shift');\n segs.push(s.key.length === 1 ? s.key.toUpperCase() : s.key); \n return segs.join(isMac.value ? '' : '+'); \n}); \n \nfunction onGlobalKeydown(e: KeyboardEvent) { \n const s = parsedShortcut.value; \n if (!s) return; \n \n // No robar atajos mientras el usuario escribe en otro campo (a menos que sea una combinación con modificador). \n const target = e.target as HTMLElement | null; \n const typingElsewhere = !!target && (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable); \n const hasModifier = s.meta || s.ctrl || s.alt; \n if (typingElsewhere && !hasModifier && target !== inputRef.value) return; \n \n if ( \n e.key.toLowerCase() === s.key && \n e.metaKey === s.meta && \n e.ctrlKey === s.ctrl && \n e.shiftKey === s.shift && \n e.altKey === s.alt \n ) { \n e.preventDefault(); \n inputRef.value?.focus(); \n inputRef.value?.select(); \n } \n} \n \nonMounted(() => { \n if (parsedShortcut.value) { \n window.addEventListener('keydown', onGlobalKeydown); \n } \n}); \n \nonBeforeUnmount(() => { \n cancelDebounce(); \n window.removeEventListener('keydown', onGlobalKeydown); \n}); \n \n/* ---------- Classes ---------- */ \n \nconst wrapperSizeClasses = computed(() => `${sz.value.control} ${sz.value.padX}`);\n\nconst inputTextClasses = computed(() => sz.value.text);\n\nconst iconSizeClasses = computed(() => sz.value.icon); \n \ndefineExpose({ \n focus: () => inputRef.value?.focus(), \n blur: () => inputRef.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 -2,7 +2,7 @@ const require__plugin_vue_export_helper = require("../../_virtual/_plugin-vue_ex
|
|
|
2
2
|
const require_PopoverPanel_vue_vue_type_script_setup_true_lang = require("./PopoverPanel.vue_vue_type_script_setup_true_lang.cjs");
|
|
3
3
|
;/* empty css */
|
|
4
4
|
//#region src/components/layout/PopoverPanel.vue
|
|
5
|
-
var PopoverPanel_default = /* @__PURE__ */ require__plugin_vue_export_helper.default(require_PopoverPanel_vue_vue_type_script_setup_true_lang.default, [["__scopeId", "data-v-
|
|
5
|
+
var PopoverPanel_default = /* @__PURE__ */ require__plugin_vue_export_helper.default(require_PopoverPanel_vue_vue_type_script_setup_true_lang.default, [["__scopeId", "data-v-8bb79aba"]]);
|
|
6
6
|
//#endregion
|
|
7
7
|
exports.default = PopoverPanel_default;
|
|
8
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverPanel.cjs","names":[],"sources":["../../../src/components/layout/PopoverPanel.vue"],"sourcesContent":["<template> \n <Teleport to=\"body\"> \n <Transition \n enter-active-class=\"modo-popover-enter\" \n leave-active-class=\"modo-popover-leave\" \n > \n <div \n v-if=\"open\" \n ref=\"panelEl\" \n :role=\"role\" \n :aria-labelledby=\"labelledBy\" \n :style=\"mergedStyle\" \n :class=\"[\n 'modo-popover bg-popover text-popover-foreground border border-border shadow-lg',\n radiusClass,\n $attrs.class,\n ]\"
|
|
1
|
+
{"version":3,"file":"PopoverPanel.cjs","names":[],"sources":["../../../src/components/layout/PopoverPanel.vue"],"sourcesContent":["<template> \n <Teleport to=\"body\"> \n <Transition \n enter-active-class=\"modo-popover-enter\" \n leave-active-class=\"modo-popover-leave\" \n > \n <div \n v-if=\"open\" \n ref=\"panelEl\" \n :role=\"role\" \n :aria-labelledby=\"labelledBy\" \n :style=\"mergedStyle\" \n :class=\"[\n 'modo-popover flex flex-col overflow-hidden bg-popover text-popover-foreground border border-border shadow-lg',\n radiusClass,\n $attrs.class,\n ]\"\n :data-modo-theme=\"scopedTheme || undefined\"\n >\n <!--\n `min-h-0` is what makes the panel's max-height actually bite:\n as a flex child this wrapper defaults to min-height:auto and\n refuses to shrink below its content, so it would render past\n the capped panel instead of scrolling inside it.\n -->\n <div :class=\"['modo-popover-inner min-h-0 flex-1 overflow-x-hidden overflow-y-auto', radiusClass]\">\n <slot />\n </div>\n </div> \n </Transition> \n </Teleport> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, ref, watch } from 'vue'; \nimport { useResolvedRadius, useResolvedTheme, useModoConfig } from '../../composables/useModoConfig'; \nimport { resolveColorMode } from '../../composables/useColorMode'; \nimport { palettesToCssVars, semanticTokensFromPalettes } from '../../config/palettes'; \nimport { hexToOklchString, pickForegroundOklch } from '../../config/colorPrimitives'; \nimport { surfacesToCssVars } from '../../config/surfaces'; \n \ndefineOptions({ inheritAttrs: false }); \n \nconst props = defineProps<{ \n /** Controla la visibilidad. */ \n open: boolean; \n /** Estilo (top/left/width/zIndex) calculado por `usePopover`. */ \n style?: Record<string, string>; \n /** Radio de esquinas. Si no se pasa, toma el del provider. */ \n radius?: 'none' | 'small' | 'medium' | 'large' | 'full'; \n /** ARIA role. @default 'dialog' */ \n role?: string; \n /** Id del elemento que nombra al panel. */ \n labelledBy?: string; \n}>(); \n \nconst emit = defineEmits<{ 'update:panelRef': [el: HTMLElement | null] }>(); \n \nconst panelEl = ref<HTMLElement | null>(null); \nwatch(panelEl, (el) => emit('update:panelRef', el)); \n \nconst radius = useResolvedRadius(() => props.radius); \nconst theme = useResolvedTheme(); \nconst cfg = useModoConfig(); \n// When the popover is portal'd to <body>, the data-modo-theme attribute on \n// the parent provider is out of scope. Forward it so dark mode works. \nconst scopedTheme = computed(() => resolveColorMode(theme.value)); \n \n// Forward the provider's palette CSS vars (`--primary`, `--primary-foreground`, \n// etc.) to the teleported panel so `bg-primary` / `text-primary` stay in sync \n// with whatever palette the provider set. Also forward surface vars so tinted \n// surfaces (base intensity) are visible inside the popover. \nconst mergedStyle = computed(() => { \n const providerVars = cfg?.value.palettes \n ? { \n ...palettesToCssVars(cfg.value.palettes), \n ...semanticTokensFromPalettes(cfg.value.palettes, hexToOklchString, pickForegroundOklch), \n } \n : {};\n const surfaceVars = cfg?.value.surfaces\n ? surfacesToCssVars(cfg.value.surfaces)\n : {};\n const darkSurfaceVars = (scopedTheme.value === 'dark' && cfg?.value.darkSurfaces)\n ? surfacesToCssVars(cfg.value.darkSurfaces)\n : {};\n return { ...providerVars, ...surfaceVars, ...darkSurfaceVars, ...(props.style ?? {}) }; \n}); \n \nconst radiusClass = computed(() => { \n switch (radius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-xl'; \n case 'full': return 'rounded-2xl'; \n case 'medium': \n default: return 'rounded-md'; \n } \n}); \n</script> \n \n<style scoped> \n.modo-popover { \n transform-origin: top center; \n will-change: transform, opacity; \n} \n.modo-popover-enter { \n animation: modo-popover-in 140ms cubic-bezier(0.2, 0, 0, 1); \n} \n.modo-popover-leave { \n animation: modo-popover-out 80ms cubic-bezier(0.3, 0, 1, 1); \n} \n@keyframes modo-popover-in { \n from { opacity: 0; transform: translateY(-4px) scale(0.98); } \n to { opacity: 1; transform: translateY(0) scale(1); } \n} \n@keyframes modo-popover-out { \n from { opacity: 1; transform: translateY(0); } \n to { opacity: 0; transform: translateY(-2px); } \n} \n@media (prefers-reduced-motion: reduce) { \n .modo-popover-enter, .modo-popover-leave { animation: none; } \n} \n</style>\n"],"mappings":""}
|
|
@@ -2,7 +2,7 @@ import _plugin_vue_export_helper_default from "../../_virtual/_plugin-vue_export
|
|
|
2
2
|
import PopoverPanel_vue_vue_type_script_setup_true_lang_default from "./PopoverPanel.vue_vue_type_script_setup_true_lang.mjs";
|
|
3
3
|
/* empty css */
|
|
4
4
|
//#region src/components/layout/PopoverPanel.vue
|
|
5
|
-
var PopoverPanel_default = /* @__PURE__ */ _plugin_vue_export_helper_default(PopoverPanel_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-
|
|
5
|
+
var PopoverPanel_default = /* @__PURE__ */ _plugin_vue_export_helper_default(PopoverPanel_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-8bb79aba"]]);
|
|
6
6
|
//#endregion
|
|
7
7
|
export { PopoverPanel_default as default };
|
|
8
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverPanel.mjs","names":[],"sources":["../../../src/components/layout/PopoverPanel.vue"],"sourcesContent":["<template> \n <Teleport to=\"body\"> \n <Transition \n enter-active-class=\"modo-popover-enter\" \n leave-active-class=\"modo-popover-leave\" \n > \n <div \n v-if=\"open\" \n ref=\"panelEl\" \n :role=\"role\" \n :aria-labelledby=\"labelledBy\" \n :style=\"mergedStyle\" \n :class=\"[\n 'modo-popover bg-popover text-popover-foreground border border-border shadow-lg',\n radiusClass,\n $attrs.class,\n ]\"
|
|
1
|
+
{"version":3,"file":"PopoverPanel.mjs","names":[],"sources":["../../../src/components/layout/PopoverPanel.vue"],"sourcesContent":["<template> \n <Teleport to=\"body\"> \n <Transition \n enter-active-class=\"modo-popover-enter\" \n leave-active-class=\"modo-popover-leave\" \n > \n <div \n v-if=\"open\" \n ref=\"panelEl\" \n :role=\"role\" \n :aria-labelledby=\"labelledBy\" \n :style=\"mergedStyle\" \n :class=\"[\n 'modo-popover flex flex-col overflow-hidden bg-popover text-popover-foreground border border-border shadow-lg',\n radiusClass,\n $attrs.class,\n ]\"\n :data-modo-theme=\"scopedTheme || undefined\"\n >\n <!--\n `min-h-0` is what makes the panel's max-height actually bite:\n as a flex child this wrapper defaults to min-height:auto and\n refuses to shrink below its content, so it would render past\n the capped panel instead of scrolling inside it.\n -->\n <div :class=\"['modo-popover-inner min-h-0 flex-1 overflow-x-hidden overflow-y-auto', radiusClass]\">\n <slot />\n </div>\n </div> \n </Transition> \n </Teleport> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, ref, watch } from 'vue'; \nimport { useResolvedRadius, useResolvedTheme, useModoConfig } from '../../composables/useModoConfig'; \nimport { resolveColorMode } from '../../composables/useColorMode'; \nimport { palettesToCssVars, semanticTokensFromPalettes } from '../../config/palettes'; \nimport { hexToOklchString, pickForegroundOklch } from '../../config/colorPrimitives'; \nimport { surfacesToCssVars } from '../../config/surfaces'; \n \ndefineOptions({ inheritAttrs: false }); \n \nconst props = defineProps<{ \n /** Controla la visibilidad. */ \n open: boolean; \n /** Estilo (top/left/width/zIndex) calculado por `usePopover`. */ \n style?: Record<string, string>; \n /** Radio de esquinas. Si no se pasa, toma el del provider. */ \n radius?: 'none' | 'small' | 'medium' | 'large' | 'full'; \n /** ARIA role. @default 'dialog' */ \n role?: string; \n /** Id del elemento que nombra al panel. */ \n labelledBy?: string; \n}>(); \n \nconst emit = defineEmits<{ 'update:panelRef': [el: HTMLElement | null] }>(); \n \nconst panelEl = ref<HTMLElement | null>(null); \nwatch(panelEl, (el) => emit('update:panelRef', el)); \n \nconst radius = useResolvedRadius(() => props.radius); \nconst theme = useResolvedTheme(); \nconst cfg = useModoConfig(); \n// When the popover is portal'd to <body>, the data-modo-theme attribute on \n// the parent provider is out of scope. Forward it so dark mode works. \nconst scopedTheme = computed(() => resolveColorMode(theme.value)); \n \n// Forward the provider's palette CSS vars (`--primary`, `--primary-foreground`, \n// etc.) to the teleported panel so `bg-primary` / `text-primary` stay in sync \n// with whatever palette the provider set. Also forward surface vars so tinted \n// surfaces (base intensity) are visible inside the popover. \nconst mergedStyle = computed(() => { \n const providerVars = cfg?.value.palettes \n ? { \n ...palettesToCssVars(cfg.value.palettes), \n ...semanticTokensFromPalettes(cfg.value.palettes, hexToOklchString, pickForegroundOklch), \n } \n : {};\n const surfaceVars = cfg?.value.surfaces\n ? surfacesToCssVars(cfg.value.surfaces)\n : {};\n const darkSurfaceVars = (scopedTheme.value === 'dark' && cfg?.value.darkSurfaces)\n ? surfacesToCssVars(cfg.value.darkSurfaces)\n : {};\n return { ...providerVars, ...surfaceVars, ...darkSurfaceVars, ...(props.style ?? {}) }; \n}); \n \nconst radiusClass = computed(() => { \n switch (radius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-xl'; \n case 'full': return 'rounded-2xl'; \n case 'medium': \n default: return 'rounded-md'; \n } \n}); \n</script> \n \n<style scoped> \n.modo-popover { \n transform-origin: top center; \n will-change: transform, opacity; \n} \n.modo-popover-enter { \n animation: modo-popover-in 140ms cubic-bezier(0.2, 0, 0, 1); \n} \n.modo-popover-leave { \n animation: modo-popover-out 80ms cubic-bezier(0.3, 0, 1, 1); \n} \n@keyframes modo-popover-in { \n from { opacity: 0; transform: translateY(-4px) scale(0.98); } \n to { opacity: 1; transform: translateY(0) scale(1); } \n} \n@keyframes modo-popover-out { \n from { opacity: 1; transform: translateY(0); } \n to { opacity: 0; transform: translateY(-2px); } \n} \n@media (prefers-reduced-motion: reduce) { \n .modo-popover-enter, .modo-popover-leave { animation: none; } \n} \n</style>\n"],"mappings":""}
|
|
@@ -67,12 +67,12 @@ var PopoverPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (
|
|
|
67
67
|
"aria-labelledby": __props.labelledBy,
|
|
68
68
|
style: (0, vue.normalizeStyle)(mergedStyle.value),
|
|
69
69
|
class: (0, vue.normalizeClass)([
|
|
70
|
-
"modo-popover bg-popover text-popover-foreground border border-border shadow-lg",
|
|
70
|
+
"modo-popover flex flex-col overflow-hidden bg-popover text-popover-foreground border border-border shadow-lg",
|
|
71
71
|
radiusClass.value,
|
|
72
72
|
_ctx.$attrs.class
|
|
73
73
|
]),
|
|
74
74
|
"data-modo-theme": scopedTheme.value || void 0
|
|
75
|
-
}, [(0, vue.createElementVNode)("div", { class: (0, vue.normalizeClass)(["modo-popover-inner overflow-x-hidden overflow-y-auto", radiusClass.value]) }, [(0, vue.renderSlot)(_ctx.$slots, "default", {}, void 0, true)], 2)], 14, _hoisted_1)) : (0, vue.createCommentVNode)("", true)]),
|
|
75
|
+
}, [(0, vue.createElementVNode)("div", { class: (0, vue.normalizeClass)(["modo-popover-inner min-h-0 flex-1 overflow-x-hidden overflow-y-auto", radiusClass.value]) }, [(0, vue.renderSlot)(_ctx.$slots, "default", {}, void 0, true)], 2)], 14, _hoisted_1)) : (0, vue.createCommentVNode)("", true)]),
|
|
76
76
|
_: 3
|
|
77
77
|
})]);
|
|
78
78
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverPanel.vue_vue_type_script_setup_true_lang.cjs","names":["$attrs"],"sources":["../../../src/components/layout/PopoverPanel.vue"],"sourcesContent":["<template> \n <Teleport to=\"body\"> \n <Transition \n enter-active-class=\"modo-popover-enter\" \n leave-active-class=\"modo-popover-leave\" \n > \n <div \n v-if=\"open\" \n ref=\"panelEl\" \n :role=\"role\" \n :aria-labelledby=\"labelledBy\" \n :style=\"mergedStyle\" \n :class=\"[\n 'modo-popover bg-popover text-popover-foreground border border-border shadow-lg',\n radiusClass,\n $attrs.class,\n ]\"
|
|
1
|
+
{"version":3,"file":"PopoverPanel.vue_vue_type_script_setup_true_lang.cjs","names":["$attrs"],"sources":["../../../src/components/layout/PopoverPanel.vue"],"sourcesContent":["<template> \n <Teleport to=\"body\"> \n <Transition \n enter-active-class=\"modo-popover-enter\" \n leave-active-class=\"modo-popover-leave\" \n > \n <div \n v-if=\"open\" \n ref=\"panelEl\" \n :role=\"role\" \n :aria-labelledby=\"labelledBy\" \n :style=\"mergedStyle\" \n :class=\"[\n 'modo-popover flex flex-col overflow-hidden bg-popover text-popover-foreground border border-border shadow-lg',\n radiusClass,\n $attrs.class,\n ]\"\n :data-modo-theme=\"scopedTheme || undefined\"\n >\n <!--\n `min-h-0` is what makes the panel's max-height actually bite:\n as a flex child this wrapper defaults to min-height:auto and\n refuses to shrink below its content, so it would render past\n the capped panel instead of scrolling inside it.\n -->\n <div :class=\"['modo-popover-inner min-h-0 flex-1 overflow-x-hidden overflow-y-auto', radiusClass]\">\n <slot />\n </div>\n </div> \n </Transition> \n </Teleport> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, ref, watch } from 'vue'; \nimport { useResolvedRadius, useResolvedTheme, useModoConfig } from '../../composables/useModoConfig'; \nimport { resolveColorMode } from '../../composables/useColorMode'; \nimport { palettesToCssVars, semanticTokensFromPalettes } from '../../config/palettes'; \nimport { hexToOklchString, pickForegroundOklch } from '../../config/colorPrimitives'; \nimport { surfacesToCssVars } from '../../config/surfaces'; \n \ndefineOptions({ inheritAttrs: false }); \n \nconst props = defineProps<{ \n /** Controla la visibilidad. */ \n open: boolean; \n /** Estilo (top/left/width/zIndex) calculado por `usePopover`. */ \n style?: Record<string, string>; \n /** Radio de esquinas. Si no se pasa, toma el del provider. */ \n radius?: 'none' | 'small' | 'medium' | 'large' | 'full'; \n /** ARIA role. @default 'dialog' */ \n role?: string; \n /** Id del elemento que nombra al panel. */ \n labelledBy?: string; \n}>(); \n \nconst emit = defineEmits<{ 'update:panelRef': [el: HTMLElement | null] }>(); \n \nconst panelEl = ref<HTMLElement | null>(null); \nwatch(panelEl, (el) => emit('update:panelRef', el)); \n \nconst radius = useResolvedRadius(() => props.radius); \nconst theme = useResolvedTheme(); \nconst cfg = useModoConfig(); \n// When the popover is portal'd to <body>, the data-modo-theme attribute on \n// the parent provider is out of scope. Forward it so dark mode works. \nconst scopedTheme = computed(() => resolveColorMode(theme.value)); \n \n// Forward the provider's palette CSS vars (`--primary`, `--primary-foreground`, \n// etc.) to the teleported panel so `bg-primary` / `text-primary` stay in sync \n// with whatever palette the provider set. Also forward surface vars so tinted \n// surfaces (base intensity) are visible inside the popover. \nconst mergedStyle = computed(() => { \n const providerVars = cfg?.value.palettes \n ? { \n ...palettesToCssVars(cfg.value.palettes), \n ...semanticTokensFromPalettes(cfg.value.palettes, hexToOklchString, pickForegroundOklch), \n } \n : {};\n const surfaceVars = cfg?.value.surfaces\n ? surfacesToCssVars(cfg.value.surfaces)\n : {};\n const darkSurfaceVars = (scopedTheme.value === 'dark' && cfg?.value.darkSurfaces)\n ? surfacesToCssVars(cfg.value.darkSurfaces)\n : {};\n return { ...providerVars, ...surfaceVars, ...darkSurfaceVars, ...(props.style ?? {}) }; \n}); \n \nconst radiusClass = computed(() => { \n switch (radius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-xl'; \n case 'full': return 'rounded-2xl'; \n case 'medium': \n default: return 'rounded-md'; \n } \n}); \n</script> \n \n<style scoped> \n.modo-popover { \n transform-origin: top center; \n will-change: transform, opacity; \n} \n.modo-popover-enter { \n animation: modo-popover-in 140ms cubic-bezier(0.2, 0, 0, 1); \n} \n.modo-popover-leave { \n animation: modo-popover-out 80ms cubic-bezier(0.3, 0, 1, 1); \n} \n@keyframes modo-popover-in { \n from { opacity: 0; transform: translateY(-4px) scale(0.98); } \n to { opacity: 1; transform: translateY(0) scale(1); } \n} \n@keyframes modo-popover-out { \n from { opacity: 1; transform: translateY(0); } \n to { opacity: 0; transform: translateY(-2px); } \n} \n@media (prefers-reduced-motion: reduce) { \n .modo-popover-enter, .modo-popover-leave { animation: none; } \n} \n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EA2CA,MAAM,QAAQ;EAad,MAAM,OAAO;EAEb,MAAM,WAAA,GAAA,IAAA,KAAkC,KAAK;EAC7C,CAAA,GAAA,IAAA,OAAM,UAAU,OAAO,KAAK,mBAAmB,GAAG,CAAC;EAEnD,MAAM,SAAS,sBAAA,wBAAwB,MAAM,OAAO;EACpD,MAAM,QAAQ,sBAAA,kBAAkB;EAChC,MAAM,MAAM,sBAAA,eAAe;EAG3B,MAAM,eAAA,GAAA,IAAA,gBAA6B,qBAAA,iBAAiB,MAAM,MAAM,CAAC;EAMjE,MAAM,eAAA,GAAA,IAAA,gBAA6B;GAC/B,MAAM,eAAe,KAAK,MAAM,WAC1B;IACI,GAAG,iBAAA,kBAAkB,IAAI,MAAM,SAAS;IACxC,GAAG,iBAAA,2BAA2B,IAAI,MAAM,UAAU,wBAAA,kBAAkB,wBAAA,oBAAo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elledby": __props.labelledBy,
|
|
67
67
|
style: normalizeStyle(mergedStyle.value),
|
|
68
68
|
class: normalizeClass([
|
|
69
|
-
"modo-popover bg-popover text-popover-foreground border border-border shadow-lg",
|
|
69
|
+
"modo-popover flex flex-col overflow-hidden bg-popover text-popover-foreground border border-border shadow-lg",
|
|
70
70
|
radiusClass.value,
|
|
71
71
|
_ctx.$attrs.class
|
|
72
72
|
]),
|
|
73
73
|
"data-modo-theme": scopedTheme.value || void 0
|
|
74
|
-
}, [createElementVNode("div", { class: normalizeClass(["modo-popover-inner overflow-x-hidden overflow-y-auto", radiusClass.value]) }, [renderSlot(_ctx.$slots, "default", {}, void 0, true)], 2)], 14, _hoisted_1)) : createCommentVNode("", true)]),
|
|
74
|
+
}, [createElementVNode("div", { class: normalizeClass(["modo-popover-inner min-h-0 flex-1 overflow-x-hidden overflow-y-auto", radiusClass.value]) }, [renderSlot(_ctx.$slots, "default", {}, void 0, true)], 2)], 14, _hoisted_1)) : createCommentVNode("", true)]),
|
|
75
75
|
_: 3
|
|
76
76
|
})]);
|
|
77
77
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverPanel.vue_vue_type_script_setup_true_lang.mjs","names":["$attrs"],"sources":["../../../src/components/layout/PopoverPanel.vue"],"sourcesContent":["<template> \n <Teleport to=\"body\"> \n <Transition \n enter-active-class=\"modo-popover-enter\" \n leave-active-class=\"modo-popover-leave\" \n > \n <div \n v-if=\"open\" \n ref=\"panelEl\" \n :role=\"role\" \n :aria-labelledby=\"labelledBy\" \n :style=\"mergedStyle\" \n :class=\"[\n 'modo-popover bg-popover text-popover-foreground border border-border shadow-lg',\n radiusClass,\n $attrs.class,\n ]\"
|
|
1
|
+
{"version":3,"file":"PopoverPanel.vue_vue_type_script_setup_true_lang.mjs","names":["$attrs"],"sources":["../../../src/components/layout/PopoverPanel.vue"],"sourcesContent":["<template> \n <Teleport to=\"body\"> \n <Transition \n enter-active-class=\"modo-popover-enter\" \n leave-active-class=\"modo-popover-leave\" \n > \n <div \n v-if=\"open\" \n ref=\"panelEl\" \n :role=\"role\" \n :aria-labelledby=\"labelledBy\" \n :style=\"mergedStyle\" \n :class=\"[\n 'modo-popover flex flex-col overflow-hidden bg-popover text-popover-foreground border border-border shadow-lg',\n radiusClass,\n $attrs.class,\n ]\"\n :data-modo-theme=\"scopedTheme || undefined\"\n >\n <!--\n `min-h-0` is what makes the panel's max-height actually bite:\n as a flex child this wrapper defaults to min-height:auto and\n refuses to shrink below its content, so it would render past\n the capped panel instead of scrolling inside it.\n -->\n <div :class=\"['modo-popover-inner min-h-0 flex-1 overflow-x-hidden overflow-y-auto', radiusClass]\">\n <slot />\n </div>\n </div> \n </Transition> \n </Teleport> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, ref, watch } from 'vue'; \nimport { useResolvedRadius, useResolvedTheme, useModoConfig } from '../../composables/useModoConfig'; \nimport { resolveColorMode } from '../../composables/useColorMode'; \nimport { palettesToCssVars, semanticTokensFromPalettes } from '../../config/palettes'; \nimport { hexToOklchString, pickForegroundOklch } from '../../config/colorPrimitives'; \nimport { surfacesToCssVars } from '../../config/surfaces'; \n \ndefineOptions({ inheritAttrs: false }); \n \nconst props = defineProps<{ \n /** Controla la visibilidad. */ \n open: boolean; \n /** Estilo (top/left/width/zIndex) calculado por `usePopover`. */ \n style?: Record<string, string>; \n /** Radio de esquinas. Si no se pasa, toma el del provider. */ \n radius?: 'none' | 'small' | 'medium' | 'large' | 'full'; \n /** ARIA role. @default 'dialog' */ \n role?: string; \n /** Id del elemento que nombra al panel. */ \n labelledBy?: string; \n}>(); \n \nconst emit = defineEmits<{ 'update:panelRef': [el: HTMLElement | null] }>(); \n \nconst panelEl = ref<HTMLElement | null>(null); \nwatch(panelEl, (el) => emit('update:panelRef', el)); \n \nconst radius = useResolvedRadius(() => props.radius); \nconst theme = useResolvedTheme(); \nconst cfg = useModoConfig(); \n// When the popover is portal'd to <body>, the data-modo-theme attribute on \n// the parent provider is out of scope. Forward it so dark mode works. \nconst scopedTheme = computed(() => resolveColorMode(theme.value)); \n \n// Forward the provider's palette CSS vars (`--primary`, `--primary-foreground`, \n// etc.) to the teleported panel so `bg-primary` / `text-primary` stay in sync \n// with whatever palette the provider set. Also forward surface vars so tinted \n// surfaces (base intensity) are visible inside the popover. \nconst mergedStyle = computed(() => { \n const providerVars = cfg?.value.palettes \n ? { \n ...palettesToCssVars(cfg.value.palettes), \n ...semanticTokensFromPalettes(cfg.value.palettes, hexToOklchString, pickForegroundOklch), \n } \n : {};\n const surfaceVars = cfg?.value.surfaces\n ? surfacesToCssVars(cfg.value.surfaces)\n : {};\n const darkSurfaceVars = (scopedTheme.value === 'dark' && cfg?.value.darkSurfaces)\n ? surfacesToCssVars(cfg.value.darkSurfaces)\n : {};\n return { ...providerVars, ...surfaceVars, ...darkSurfaceVars, ...(props.style ?? {}) }; \n}); \n \nconst radiusClass = computed(() => { \n switch (radius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-xl'; \n case 'full': return 'rounded-2xl'; \n case 'medium': \n default: return 'rounded-md'; \n } \n}); \n</script> \n \n<style scoped> \n.modo-popover { \n transform-origin: top center; \n will-change: transform, opacity; \n} \n.modo-popover-enter { \n animation: modo-popover-in 140ms cubic-bezier(0.2, 0, 0, 1); \n} \n.modo-popover-leave { \n animation: modo-popover-out 80ms cubic-bezier(0.3, 0, 1, 1); \n} \n@keyframes modo-popover-in { \n from { opacity: 0; transform: translateY(-4px) scale(0.98); } \n to { opacity: 1; transform: translateY(0) scale(1); } \n} \n@keyframes modo-popover-out { \n from { opacity: 1; transform: translateY(0); } \n to { opacity: 0; transform: translateY(-2px); } \n} \n@media (prefers-reduced-motion: reduce) { \n .modo-popover-enter, .modo-popover-leave { animation: none; } \n} \n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EA2CA,MAAM,QAAQ;EAad,MAAM,OAAO;EAEb,MAAM,UAAU,IAAwB,KAAK;EAC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AAA,WAAA,EAAA,EAAA,KAAA,GAAA,KAAA,CAAA,EAAA,EAAA,CAAA,EAAA,IAAA,WAAA,IAAA,mBAAA,IAAA,KAAA,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switcher.cjs","names":[],"sources":["../../../src/components/navigation/Switcher.vue"],"sourcesContent":["<template>\n <div class=\"modo-switcher inline-flex\" :class=\"{ 'w-full': fullWidth }\">\n <span ref=\"triggerWrapEl\" class=\"inline-flex\" :class=\"{ 'w-full': fullWidth }\">\n <slot\n name=\"trigger\"\n :activeItem=\"activeItem\"\n :isOpen=\"isOpen\"\n :toggle=\"onTriggerClick\"\n >\n <button\n ref=\"triggerEl\"\n type=\"button\"\n data-modo-switcher-trigger\n aria-haspopup=\"listbox\"\n :aria-expanded=\"isOpen\"\n :aria-label=\"resolvedAriaLabel\"\n :disabled=\"disabled\"\n :class=\"[\n 'inline-flex items-center gap-3 px-3 py-2 text-left transition-colors',\n 'border bg-card text-card-foreground border-border',\n 'hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60',\n radiusClass,\n fullWidth ? 'w-full' : '',\n disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer',\n ]\"\n @click=\"onTriggerClick\"\n @keydown=\"onTriggerKeydown\"\n >\n <span v-if=\"activeItem?.avatar\" class=\"shrink-0\">\n <Avatar\n :src=\"activeItem.avatar.src\"\n :initials=\"activeItem.avatar.initials\"\n :name=\"activeItem.title\"\n size=\"small\"\n />\n </span>\n <span\n v-else-if=\"activeItem?.icon\"\n class=\"shrink-0 inline-flex items-center justify-center w-9 h-9 rounded-md bg-accent/60 text-foreground\"\n >\n <component :is=\"activeItem.icon\" class=\"w-5 h-5\" aria-hidden=\"true\" />\n </span>\n <span class=\"flex flex-col min-w-0 flex-1\">\n <span class=\"truncate text-body font-medium\">\n {{ activeItem ? activeItem.title : resolvedPlaceholder }}\n </span>\n <span\n v-if=\"!compactTrigger && activeItem?.subtitle\"\n class=\"truncate text-caption text-muted-foreground\"\n >\n {{ activeItem.subtitle }}\n </span>\n </span>\n <ChevronUpDownIcon\n v-if=\"chevron === 'updown'\"\n class=\"w-4 h-4 shrink-0 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n <ChevronDownIcon\n v-else-if=\"chevron === 'down'\"\n class=\"w-4 h-4 shrink-0 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n </button>\n </slot>\n </span>\n\n <PopoverPanel\n :open=\"isOpen\"\n :style=\"mergedPanelStyle\"\n :radius=\"resolvedRadius\"\n role=\"dialog\"\n :aria-label=\"resolvedAriaLabel\"\n @update:panelRef=\"panelRef = $event\"\n >\n <div\n data-modo-switcher-panel\n class=\"modo-switcher-panel overflow-y-auto\"\n :style=\"{ maxHeight: panelMaxHeightStyle }\"\n >\n <div\n v-if=\"panelTitle\"\n class=\"px-3 pt-3 pb-2 text-caption text-muted-foreground uppercase tracking-wider\"\n >\n {{ panelTitle }}\n </div>\n\n <div v-if=\"searchable\" class=\"px-2 pt-2 pb-1\">\n <input\n ref=\"searchInputEl\"\n v-model=\"searchQuery\"\n role=\"searchbox\"\n type=\"text\"\n :placeholder=\"resolvedSearchPlaceholder\"\n :aria-controls=\"listboxId\"\n :aria-activedescendant=\"activeDescendantId\"\n class=\"w-full px-2 py-1.5 text-body bg-background border border-border rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60\"\n @keydown=\"onSearchKeydown\"\n />\n </div>\n\n <template v-if=\"loading\">\n <slot name=\"loading\">\n <div class=\"p-2 flex flex-col gap-1\">\n <div\n v-for=\"i in 3\"\n :key=\"i\"\n data-modo-switcher-skeleton\n >\n <Skeleton height=\"44px\" />\n </div>\n </div>\n </slot>\n </template>\n\n <template v-else-if=\"items.length === 0\">\n <slot name=\"empty\">\n <div class=\"px-3 py-6 text-center text-muted-foreground text-body\">\n {{ resolvedEmptyText }}\n </div>\n </slot>\n </template>\n\n <template v-else-if=\"displayedItems.length === 0\">\n <div class=\"px-3 py-6 text-center text-muted-foreground text-body\">\n {{ resolvedNoResults }}\n </div>\n </template>\n\n <ul\n v-else\n role=\"listbox\"\n :id=\"listboxId\"\n class=\"flex flex-col\"\n @keydown=\"onListKeydown\"\n >\n <li\n v-for=\"(item, idx) in displayedItems\"\n :key=\"item.value\"\n :ref=\"(el) => setOptionRef(el as HTMLElement | null, idx)\"\n role=\"option\"\n :id=\"`${listboxId}-opt-${idx}`\"\n :aria-selected=\"item.value === modelValue\"\n :aria-current=\"item.value === modelValue ? 'true' : undefined\"\n :aria-disabled=\"item.disabled || undefined\"\n :data-active=\"item.value === modelValue || undefined\"\n :tabindex=\"-1\"\n class=\"modo-switcher-item flex items-center gap-3 px-3 py-2 cursor-pointer\"\n :class=\"[\n item.value === modelValue ? 'bg-accent/40' : '',\n searchable && idx === highlightedIdx ? 'bg-accent' : 'hover:bg-accent',\n item.disabled ? 'opacity-50 cursor-not-allowed' : '',\n ]\"\n @click=\"selectItem(item)\"\n @mouseenter=\"searchable ? (highlightedIdx = idx) : null\"\n >\n <span v-if=\"item.avatar\" class=\"shrink-0\">\n <Avatar\n :src=\"item.avatar.src\"\n :initials=\"item.avatar.initials\"\n :name=\"item.title\"\n size=\"small\"\n />\n </span>\n <span\n v-else-if=\"item.icon\"\n data-modo-switcher-iconwrap\n class=\"shrink-0 inline-flex items-center justify-center w-9 h-9 rounded-md bg-accent/60 text-foreground\"\n >\n <component :is=\"item.icon\" class=\"w-5 h-5\" aria-hidden=\"true\" />\n </span>\n <span class=\"flex flex-col min-w-0 flex-1\">\n <span class=\"truncate text-body font-medium\">{{ item.title }}</span>\n <span\n v-if=\"item.subtitle\"\n class=\"truncate text-caption text-muted-foreground\"\n >{{ item.subtitle }}</span>\n </span>\n <slot\n name=\"item-trailing\"\n :item=\"item\"\n :active=\"item.value === modelValue\"\n :close=\"close\"\n >\n <CheckIcon\n v-if=\"item.value === modelValue\"\n class=\"w-4 h-4 shrink-0\"\n aria-hidden=\"true\"\n />\n </slot>\n </li>\n </ul>\n\n <template v-if=\"$slots.footer\">\n <hr\n data-modo-switcher-footer-sep\n role=\"separator\"\n class=\"my-1 border-t border-border\"\n />\n <div class=\"p-1\">\n <slot name=\"footer\" :close=\"close\" />\n </div>\n </template>\n </div>\n </PopoverPanel>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, nextTick, ref, useId, watch, watchEffect } from \"vue\";\nimport { ChevronUpDownIcon, ChevronDownIcon, CheckIcon } from \"@heroicons/vue/24/outline\";\nimport PopoverPanel from \"../layout/PopoverPanel.vue\";\nimport Avatar from \"../data-display/avatar/Avatar.vue\";\nimport Skeleton from \"../feedback/Skeleton.vue\";\nimport { usePopover } from \"../../composables/usePopover\";\nimport {\n useResolvedRadius,\n useModoLocale,\n} from \"../../composables/useModoConfig\";\nimport type {\n Switcher as SwitcherProps,\n SwitcherEmits,\n SwitcherItem,\n SwitcherValue,\n} from \"../../interfaces/navigation/Switcher.interface\";\n\nconst props = withDefaults(defineProps<SwitcherProps>(), {\n modelValue: null,\n chevron: \"updown\",\n triggerVariant: \"outline\",\n compactTrigger: false,\n fullWidth: false,\n panelWidth: \"trigger\",\n panelMinWidth: \"15rem\",\n panelMaxHeight: 320,\n placement: \"bottom-start\",\n searchable: false,\n loading: false,\n disabled: false,\n});\n\nconst emit = defineEmits<SwitcherEmits>();\n\nconst locale = useModoLocale();\nconst resolvedRadius = useResolvedRadius(() => props.radius);\nconst listboxId = useId();\n\nconst resolvedPlaceholder = computed(\n () => props.placeholder ?? locale.value.switcher.placeholder,\n);\nconst resolvedAriaLabel = computed(\n () => props.ariaLabel ?? locale.value.switcher.ariaLabel,\n);\nconst resolvedEmptyText = computed(\n () => props.emptyText ?? locale.value.switcher.empty,\n);\nconst resolvedSearchPlaceholder = computed(\n () => props.searchPlaceholder ?? locale.value.switcher.searchPlaceholder,\n);\nconst resolvedNoResults = computed(\n () => props.noResultsText ?? locale.value.switcher.noResults,\n);\n\nconst searchQuery = ref(\"\");\nconst searchInputEl = ref<HTMLInputElement | null>(null);\n\nconst displayedItems = computed<SwitcherItem[]>(() => {\n if (!props.searchable) return props.items;\n const q = searchQuery.value.trim().toLowerCase();\n if (!q) return props.items;\n const fields = props.searchFields ?? [\"title\", \"subtitle\"];\n return props.items.filter((it) =>\n fields.some((f) => {\n const v = it[f];\n return typeof v === \"string\" && v.toLowerCase().includes(q);\n }),\n );\n});\n\nwatch(searchQuery, (q) => {\n emit(\"search\", q);\n});\n\nconst radiusClass = computed(() => {\n switch (resolvedRadius.value) {\n case \"none\": return \"rounded-none\";\n case \"small\": return \"rounded-sm\";\n case \"large\": return \"rounded-lg\";\n case \"full\": return \"rounded-[999px]\";\n default: return \"rounded-md\";\n }\n});\n\nconst panelMaxHeightStyle = computed(() => {\n const v = props.panelMaxHeight;\n return typeof v === \"number\" ? `${v}px` : v;\n});\n\nconst panelMinWidthStyle = computed(() => {\n const v = props.panelMinWidth;\n if (v == null) return undefined;\n return typeof v === \"number\" ? `${v}px` : v;\n});\n\n// The popover composable sizes the panel to the trigger width when\n// `panelWidth='trigger'`. A narrow trigger (e.g. an avatar-only custom\n// trigger) would otherwise crush the panel — `minWidth` floors it.\nconst mergedPanelStyle = computed(() => ({\n ...panelStyle.value,\n ...(panelMinWidthStyle.value ? { minWidth: panelMinWidthStyle.value } : {}),\n}));\n\nconst activeItem = computed<SwitcherItem | null>(() => {\n if (props.modelValue == null) return null;\n return props.items.find((i) => i.value === props.modelValue) ?? null;\n});\n\nconst {\n triggerRef,\n panelRef,\n isOpen,\n panelStyle,\n open,\n close,\n toggle,\n} = usePopover({\n placement: () => props.placement,\n matchTriggerWidth: () => props.panelWidth === \"trigger\",\n closeOnEscape: false,\n onOpen: () => emit(\"open\"),\n onClose: () => {\n searchQuery.value = \"\";\n emit(\"close\");\n },\n});\n\nconst triggerEl = ref<HTMLElement | null>(null);\nconst triggerWrapEl = ref<HTMLElement | null>(null);\nwatch([triggerEl, triggerWrapEl], ([btn, wrap]) => {\n triggerRef.value = (btn as HTMLElement | null) ?? (wrap as HTMLElement | null);\n});\n\nfunction focusTrigger() {\n const el = triggerEl.value ?? triggerWrapEl.value;\n el?.focus?.();\n}\n\nfunction onTriggerClick() {\n if (props.disabled) return;\n toggle();\n}\n\nfunction selectItem(item: SwitcherItem) {\n if (item.disabled || props.disabled) return;\n emit(\"update:modelValue\", item.value);\n emit(\"change\", item.value, item);\n close();\n}\n\nfunction focusableIndices(): number[] {\n return displayedItems.value\n .map((it, i) => (it.disabled ? -1 : i))\n .filter((i) => i !== -1);\n}\n\nconst optionRefs = new Map<number, HTMLElement>();\nfunction setOptionRef(el: HTMLElement | null, idx: number) {\n if (el) optionRefs.set(idx, el);\n else optionRefs.delete(idx);\n}\n\nfunction focusOptionByIdx(idx: number) {\n optionRefs.get(idx)?.focus();\n}\n\nasync function openAndFocusActive() {\n if (props.disabled) return;\n if (!isOpen.value) open();\n await nextTick();\n if (props.searchable) {\n searchInputEl.value?.focus();\n return;\n }\n const order = focusableIndices();\n if (!order.length) return;\n const activeIdx = displayedItems.value.findIndex(\n (it) => it.value === props.modelValue,\n );\n const usable =\n activeIdx >= 0 && !displayedItems.value[activeIdx].disabled\n ? activeIdx\n : order[0];\n focusOptionByIdx(usable);\n}\n\nfunction onTriggerKeydown(e: KeyboardEvent) {\n if ([\"ArrowDown\", \"ArrowUp\", \"Enter\", \" \"].includes(e.key)) {\n e.preventDefault();\n openAndFocusActive();\n } else if (e.key === \"Escape\" && isOpen.value) {\n e.preventDefault();\n close();\n }\n}\n\nfunction currentFocusedIdx(): number {\n const el = document.activeElement as HTMLElement | null;\n if (!el) return -1;\n for (const [idx, node] of optionRefs.entries()) {\n if (node === el) return idx;\n }\n return -1;\n}\n\nfunction moveFocus(delta: 1 | -1) {\n const order = focusableIndices();\n if (!order.length) return;\n const cur = currentFocusedIdx();\n let pos = order.indexOf(cur);\n if (pos === -1) {\n focusOptionByIdx(delta > 0 ? order[0] : order[order.length - 1]);\n return;\n }\n pos = (pos + delta + order.length) % order.length;\n focusOptionByIdx(order[pos]);\n}\n\nfunction onListKeydown(e: KeyboardEvent) {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n moveFocus(1);\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n moveFocus(-1);\n } else if (e.key === \"Home\") {\n e.preventDefault();\n const order = focusableIndices();\n if (order.length) focusOptionByIdx(order[0]);\n } else if (e.key === \"End\") {\n e.preventDefault();\n const order = focusableIndices();\n if (order.length) focusOptionByIdx(order[order.length - 1]);\n } else if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n const idx = currentFocusedIdx();\n if (idx >= 0) selectItem(displayedItems.value[idx]);\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n close();\n focusTrigger();\n } else if (\n !props.searchable &&\n e.key.length === 1 &&\n /^[a-zA-Z0-9]$/.test(e.key)\n ) {\n const order = focusableIndices();\n const letter = e.key.toLowerCase();\n const match = order.find((i) =>\n displayedItems.value[i].title.toLowerCase().startsWith(letter),\n );\n if (match !== undefined) focusOptionByIdx(match);\n }\n}\n\nwatch(isOpen, (open) => {\n if (!open) focusTrigger();\n});\n\nconst highlightedIdx = ref<number>(-1);\n\nconst activeDescendantId = computed(() =>\n highlightedIdx.value >= 0\n ? `${listboxId}-opt-${highlightedIdx.value}`\n : undefined,\n);\n\nwatch(displayedItems, () => {\n if (!props.searchable) return;\n const order = focusableIndices();\n highlightedIdx.value = order[0] ?? -1;\n});\n\nwatch(isOpen, (open) => {\n if (!open) {\n highlightedIdx.value = -1;\n return;\n }\n if (!props.searchable) return;\n const idx = displayedItems.value.findIndex(\n (it) => it.value === props.modelValue && !it.disabled,\n );\n const order = focusableIndices();\n highlightedIdx.value = idx >= 0 ? idx : order[0] ?? -1;\n});\n\nfunction moveHighlight(delta: 1 | -1) {\n const order = focusableIndices();\n if (!order.length) return;\n const cur = order.indexOf(highlightedIdx.value);\n if (cur === -1) {\n highlightedIdx.value = delta > 0 ? order[0] : order[order.length - 1];\n return;\n }\n const next = (cur + delta + order.length) % order.length;\n highlightedIdx.value = order[next];\n}\n\nfunction onSearchKeydown(e: KeyboardEvent) {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n moveHighlight(1);\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n moveHighlight(-1);\n } else if (e.key === \"Home\") {\n e.preventDefault();\n const order = focusableIndices();\n if (order.length) highlightedIdx.value = order[0];\n } else if (e.key === \"End\") {\n e.preventDefault();\n const order = focusableIndices();\n if (order.length) highlightedIdx.value = order[order.length - 1];\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n if (highlightedIdx.value >= 0) {\n selectItem(displayedItems.value[highlightedIdx.value]);\n }\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n close();\n focusTrigger();\n }\n}\n\n// Dev-only: warn once per offending item when both icon and avatar are set.\nif (import.meta.env?.DEV ?? true) {\n const warned = new Set<SwitcherValue>();\n watchEffect(() => {\n for (const item of props.items) {\n if (item.icon && item.avatar && !warned.has(item.value)) {\n warned.add(item.value);\n console.warn(\n `[Switcher] item \"${item.value}\" declares both \\`icon\\` and \\`avatar\\`; \\`avatar\\` wins. Pick one.`,\n );\n }\n }\n });\n}\n\ndefineExpose({ open, close, toggle });\n</script>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Switcher.cjs","names":[],"sources":["../../../src/components/navigation/Switcher.vue"],"sourcesContent":["<template>\n <div class=\"modo-switcher inline-flex\" :class=\"{ 'w-full': fullWidth }\">\n <span ref=\"triggerWrapEl\" class=\"inline-flex\" :class=\"{ 'w-full': fullWidth }\">\n <slot\n name=\"trigger\"\n :activeItem=\"activeItem\"\n :isOpen=\"isOpen\"\n :toggle=\"onTriggerClick\"\n >\n <button\n ref=\"triggerEl\"\n type=\"button\"\n data-modo-switcher-trigger\n aria-haspopup=\"listbox\"\n :aria-expanded=\"isOpen\"\n :aria-label=\"resolvedAriaLabel\"\n :disabled=\"disabled\"\n :class=\"[\n 'inline-flex items-center gap-3 px-3 py-2 text-left transition-colors',\n 'border bg-card text-card-foreground border-border',\n 'hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60',\n radiusClass,\n fullWidth ? 'w-full' : '',\n disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer',\n ]\"\n @click=\"onTriggerClick\"\n @keydown=\"onTriggerKeydown\"\n >\n <span v-if=\"activeItem?.avatar\" class=\"shrink-0\">\n <Avatar\n :src=\"activeItem.avatar.src\"\n :initials=\"activeItem.avatar.initials\"\n :name=\"activeItem.title\"\n size=\"small\"\n />\n </span>\n <span\n v-else-if=\"activeItem?.icon\"\n :class=\"[\n 'shrink-0 inline-flex items-center justify-center w-9 h-9 bg-accent/60 text-foreground',\n radiusClass,\n ]\"\n >\n <component :is=\"activeItem.icon\" class=\"w-5 h-5\" aria-hidden=\"true\" />\n </span>\n <span class=\"flex flex-col min-w-0 flex-1\">\n <span class=\"truncate text-body font-medium\">\n {{ activeItem ? activeItem.title : resolvedPlaceholder }}\n </span>\n <span\n v-if=\"!compactTrigger && activeItem?.subtitle\"\n class=\"truncate text-caption text-muted-foreground\"\n >\n {{ activeItem.subtitle }}\n </span>\n </span>\n <ChevronUpDownIcon\n v-if=\"chevron === 'updown'\"\n class=\"w-4 h-4 shrink-0 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n <ChevronDownIcon\n v-else-if=\"chevron === 'down'\"\n class=\"w-4 h-4 shrink-0 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n </button>\n </slot>\n </span>\n\n <PopoverPanel\n :open=\"isOpen\"\n :style=\"mergedPanelStyle\"\n :radius=\"resolvedRadius\"\n role=\"dialog\"\n :aria-label=\"resolvedAriaLabel\"\n @update:panelRef=\"panelRef = $event\"\n >\n <div\n data-modo-switcher-panel\n class=\"modo-switcher-panel overflow-y-auto\"\n :style=\"{ maxHeight: panelMaxHeightStyle }\"\n >\n <div\n v-if=\"panelTitle\"\n class=\"px-3 pt-3 pb-2 text-caption text-muted-foreground uppercase tracking-wider\"\n >\n {{ panelTitle }}\n </div>\n\n <div v-if=\"searchable\" class=\"px-2 pt-2 pb-1\">\n <input\n ref=\"searchInputEl\"\n v-model=\"searchQuery\"\n role=\"searchbox\"\n type=\"text\"\n :placeholder=\"resolvedSearchPlaceholder\"\n :aria-controls=\"listboxId\"\n :aria-activedescendant=\"activeDescendantId\"\n class=\"w-full px-2 py-1.5 text-body bg-background border border-border rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60\"\n @keydown=\"onSearchKeydown\"\n />\n </div>\n\n <template v-if=\"loading\">\n <slot name=\"loading\">\n <div class=\"p-2 flex flex-col gap-1\">\n <div\n v-for=\"i in 3\"\n :key=\"i\"\n data-modo-switcher-skeleton\n >\n <Skeleton height=\"44px\" />\n </div>\n </div>\n </slot>\n </template>\n\n <template v-else-if=\"items.length === 0\">\n <slot name=\"empty\">\n <div class=\"px-3 py-6 text-center text-muted-foreground text-body\">\n {{ resolvedEmptyText }}\n </div>\n </slot>\n </template>\n\n <template v-else-if=\"displayedItems.length === 0\">\n <div class=\"px-3 py-6 text-center text-muted-foreground text-body\">\n {{ resolvedNoResults }}\n </div>\n </template>\n\n <ul\n v-else\n role=\"listbox\"\n :id=\"listboxId\"\n class=\"flex flex-col\"\n @keydown=\"onListKeydown\"\n >\n <li\n v-for=\"(item, idx) in displayedItems\"\n :key=\"item.value\"\n :ref=\"(el) => setOptionRef(el as HTMLElement | null, idx)\"\n role=\"option\"\n :id=\"`${listboxId}-opt-${idx}`\"\n :aria-selected=\"item.value === modelValue\"\n :aria-current=\"item.value === modelValue ? 'true' : undefined\"\n :aria-disabled=\"item.disabled || undefined\"\n :data-active=\"item.value === modelValue || undefined\"\n :tabindex=\"-1\"\n class=\"modo-switcher-item flex items-center gap-3 px-3 py-2 cursor-pointer\"\n :class=\"[\n item.value === modelValue ? 'bg-accent/40' : '',\n searchable && idx === highlightedIdx ? 'bg-accent' : 'hover:bg-accent',\n item.disabled ? 'opacity-50 cursor-not-allowed' : '',\n ]\"\n @click=\"selectItem(item)\"\n @mouseenter=\"searchable ? (highlightedIdx = idx) : null\"\n >\n <span v-if=\"item.avatar\" class=\"shrink-0\">\n <Avatar\n :src=\"item.avatar.src\"\n :initials=\"item.avatar.initials\"\n :name=\"item.title\"\n size=\"small\"\n />\n </span>\n <span\n v-else-if=\"item.icon\"\n data-modo-switcher-iconwrap\n :class=\"[\n 'shrink-0 inline-flex items-center justify-center w-9 h-9 bg-accent/60 text-foreground',\n radiusClass,\n ]\"\n >\n <component :is=\"item.icon\" class=\"w-5 h-5\" aria-hidden=\"true\" />\n </span>\n <span class=\"flex flex-col min-w-0 flex-1\">\n <span class=\"truncate text-body font-medium\">{{ item.title }}</span>\n <span\n v-if=\"item.subtitle\"\n class=\"truncate text-caption text-muted-foreground\"\n >{{ item.subtitle }}</span>\n </span>\n <slot\n name=\"item-trailing\"\n :item=\"item\"\n :active=\"item.value === modelValue\"\n :close=\"close\"\n >\n <CheckIcon\n v-if=\"item.value === modelValue\"\n class=\"w-4 h-4 shrink-0\"\n aria-hidden=\"true\"\n />\n </slot>\n </li>\n </ul>\n\n <template v-if=\"$slots.footer\">\n <hr\n data-modo-switcher-footer-sep\n role=\"separator\"\n class=\"my-1 border-t border-border\"\n />\n <div class=\"p-1\">\n <slot name=\"footer\" :close=\"close\" />\n </div>\n </template>\n </div>\n </PopoverPanel>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, nextTick, ref, useId, watch, watchEffect } from \"vue\";\nimport { ChevronUpDownIcon, ChevronDownIcon, CheckIcon } from \"@heroicons/vue/24/outline\";\nimport PopoverPanel from \"../layout/PopoverPanel.vue\";\nimport Avatar from \"../data-display/avatar/Avatar.vue\";\nimport Skeleton from \"../feedback/Skeleton.vue\";\nimport { usePopover } from \"../../composables/usePopover\";\nimport {\n useResolvedRadius,\n useModoLocale,\n} from \"../../composables/useModoConfig\";\nimport type {\n Switcher as SwitcherProps,\n SwitcherEmits,\n SwitcherItem,\n SwitcherValue,\n} from \"../../interfaces/navigation/Switcher.interface\";\n\nconst props = withDefaults(defineProps<SwitcherProps>(), {\n modelValue: null,\n chevron: \"updown\",\n triggerVariant: \"outline\",\n compactTrigger: false,\n fullWidth: false,\n panelWidth: \"trigger\",\n panelMinWidth: \"15rem\",\n panelMaxHeight: 320,\n placement: \"bottom-start\",\n searchable: false,\n loading: false,\n disabled: false,\n});\n\nconst emit = defineEmits<SwitcherEmits>();\n\nconst locale = useModoLocale();\nconst resolvedRadius = useResolvedRadius(() => props.radius);\nconst listboxId = useId();\n\nconst resolvedPlaceholder = computed(\n () => props.placeholder ?? locale.value.switcher.placeholder,\n);\nconst resolvedAriaLabel = computed(\n () => props.ariaLabel ?? locale.value.switcher.ariaLabel,\n);\nconst resolvedEmptyText = computed(\n () => props.emptyText ?? locale.value.switcher.empty,\n);\nconst resolvedSearchPlaceholder = computed(\n () => props.searchPlaceholder ?? locale.value.switcher.searchPlaceholder,\n);\nconst resolvedNoResults = computed(\n () => props.noResultsText ?? locale.value.switcher.noResults,\n);\n\nconst searchQuery = ref(\"\");\nconst searchInputEl = ref<HTMLInputElement | null>(null);\n\nconst displayedItems = computed<SwitcherItem[]>(() => {\n if (!props.searchable) return props.items;\n const q = searchQuery.value.trim().toLowerCase();\n if (!q) return props.items;\n const fields = props.searchFields ?? [\"title\", \"subtitle\"];\n return props.items.filter((it) =>\n fields.some((f) => {\n const v = it[f];\n return typeof v === \"string\" && v.toLowerCase().includes(q);\n }),\n );\n});\n\nwatch(searchQuery, (q) => {\n emit(\"search\", q);\n});\n\nconst radiusClass = computed(() => {\n switch (resolvedRadius.value) {\n case \"none\": return \"rounded-none\";\n case \"small\": return \"rounded-sm\";\n case \"large\": return \"rounded-lg\";\n case \"full\": return \"rounded-[999px]\";\n default: return \"rounded-md\";\n }\n});\n\nconst panelMaxHeightStyle = computed(() => {\n const v = props.panelMaxHeight;\n return typeof v === \"number\" ? `${v}px` : v;\n});\n\nconst panelMinWidthStyle = computed(() => {\n const v = props.panelMinWidth;\n if (v == null) return undefined;\n return typeof v === \"number\" ? `${v}px` : v;\n});\n\n// The popover composable sizes the panel to the trigger width when\n// `panelWidth='trigger'`. A narrow trigger (e.g. an avatar-only custom\n// trigger) would otherwise crush the panel — `minWidth` floors it.\nconst mergedPanelStyle = computed(() => ({\n ...panelStyle.value,\n ...(panelMinWidthStyle.value ? { minWidth: panelMinWidthStyle.value } : {}),\n}));\n\nconst activeItem = computed<SwitcherItem | null>(() => {\n if (props.modelValue == null) return null;\n return props.items.find((i) => i.value === props.modelValue) ?? null;\n});\n\nconst {\n triggerRef,\n panelRef,\n isOpen,\n panelStyle,\n open,\n close,\n toggle,\n} = usePopover({\n placement: () => props.placement,\n matchTriggerWidth: () => props.panelWidth === \"trigger\",\n closeOnEscape: false,\n onOpen: () => emit(\"open\"),\n onClose: () => {\n searchQuery.value = \"\";\n emit(\"close\");\n },\n});\n\nconst triggerEl = ref<HTMLElement | null>(null);\nconst triggerWrapEl = ref<HTMLElement | null>(null);\nwatch([triggerEl, triggerWrapEl], ([btn, wrap]) => {\n triggerRef.value = (btn as HTMLElement | null) ?? (wrap as HTMLElement | null);\n});\n\nfunction focusTrigger() {\n const el = triggerEl.value ?? triggerWrapEl.value;\n el?.focus?.();\n}\n\nfunction onTriggerClick() {\n if (props.disabled) return;\n toggle();\n}\n\nfunction selectItem(item: SwitcherItem) {\n if (item.disabled || props.disabled) return;\n emit(\"update:modelValue\", item.value);\n emit(\"change\", item.value, item);\n close();\n}\n\nfunction focusableIndices(): number[] {\n return displayedItems.value\n .map((it, i) => (it.disabled ? -1 : i))\n .filter((i) => i !== -1);\n}\n\nconst optionRefs = new Map<number, HTMLElement>();\nfunction setOptionRef(el: HTMLElement | null, idx: number) {\n if (el) optionRefs.set(idx, el);\n else optionRefs.delete(idx);\n}\n\nfunction focusOptionByIdx(idx: number) {\n optionRefs.get(idx)?.focus();\n}\n\nasync function openAndFocusActive() {\n if (props.disabled) return;\n if (!isOpen.value) open();\n await nextTick();\n if (props.searchable) {\n searchInputEl.value?.focus();\n return;\n }\n const order = focusableIndices();\n if (!order.length) return;\n const activeIdx = displayedItems.value.findIndex(\n (it) => it.value === props.modelValue,\n );\n const usable =\n activeIdx >= 0 && !displayedItems.value[activeIdx].disabled\n ? activeIdx\n : order[0];\n focusOptionByIdx(usable);\n}\n\nfunction onTriggerKeydown(e: KeyboardEvent) {\n if ([\"ArrowDown\", \"ArrowUp\", \"Enter\", \" \"].includes(e.key)) {\n e.preventDefault();\n openAndFocusActive();\n } else if (e.key === \"Escape\" && isOpen.value) {\n e.preventDefault();\n close();\n }\n}\n\nfunction currentFocusedIdx(): number {\n const el = document.activeElement as HTMLElement | null;\n if (!el) return -1;\n for (const [idx, node] of optionRefs.entries()) {\n if (node === el) return idx;\n }\n return -1;\n}\n\nfunction moveFocus(delta: 1 | -1) {\n const order = focusableIndices();\n if (!order.length) return;\n const cur = currentFocusedIdx();\n let pos = order.indexOf(cur);\n if (pos === -1) {\n focusOptionByIdx(delta > 0 ? order[0] : order[order.length - 1]);\n return;\n }\n pos = (pos + delta + order.length) % order.length;\n focusOptionByIdx(order[pos]);\n}\n\nfunction onListKeydown(e: KeyboardEvent) {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n moveFocus(1);\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n moveFocus(-1);\n } else if (e.key === \"Home\") {\n e.preventDefault();\n const order = focusableIndices();\n if (order.length) focusOptionByIdx(order[0]);\n } else if (e.key === \"End\") {\n e.preventDefault();\n const order = focusableIndices();\n if (order.length) focusOptionByIdx(order[order.length - 1]);\n } else if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n const idx = currentFocusedIdx();\n if (idx >= 0) selectItem(displayedItems.value[idx]);\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n close();\n focusTrigger();\n } else if (\n !props.searchable &&\n e.key.length === 1 &&\n /^[a-zA-Z0-9]$/.test(e.key)\n ) {\n const order = focusableIndices();\n const letter = e.key.toLowerCase();\n const match = order.find((i) =>\n displayedItems.value[i].title.toLowerCase().startsWith(letter),\n );\n if (match !== undefined) focusOptionByIdx(match);\n }\n}\n\nwatch(isOpen, (open) => {\n if (!open) focusTrigger();\n});\n\nconst highlightedIdx = ref<number>(-1);\n\nconst activeDescendantId = computed(() =>\n highlightedIdx.value >= 0\n ? `${listboxId}-opt-${highlightedIdx.value}`\n : undefined,\n);\n\nwatch(displayedItems, () => {\n if (!props.searchable) return;\n const order = focusableIndices();\n highlightedIdx.value = order[0] ?? -1;\n});\n\nwatch(isOpen, (open) => {\n if (!open) {\n highlightedIdx.value = -1;\n return;\n }\n if (!props.searchable) return;\n const idx = displayedItems.value.findIndex(\n (it) => it.value === props.modelValue && !it.disabled,\n );\n const order = focusableIndices();\n highlightedIdx.value = idx >= 0 ? idx : order[0] ?? -1;\n});\n\nfunction moveHighlight(delta: 1 | -1) {\n const order = focusableIndices();\n if (!order.length) return;\n const cur = order.indexOf(highlightedIdx.value);\n if (cur === -1) {\n highlightedIdx.value = delta > 0 ? order[0] : order[order.length - 1];\n return;\n }\n const next = (cur + delta + order.length) % order.length;\n highlightedIdx.value = order[next];\n}\n\nfunction onSearchKeydown(e: KeyboardEvent) {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n moveHighlight(1);\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n moveHighlight(-1);\n } else if (e.key === \"Home\") {\n e.preventDefault();\n const order = focusableIndices();\n if (order.length) highlightedIdx.value = order[0];\n } else if (e.key === \"End\") {\n e.preventDefault();\n const order = focusableIndices();\n if (order.length) highlightedIdx.value = order[order.length - 1];\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n if (highlightedIdx.value >= 0) {\n selectItem(displayedItems.value[highlightedIdx.value]);\n }\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n close();\n focusTrigger();\n }\n}\n\n// Dev-only: warn once per offending item when both icon and avatar are set.\nif (import.meta.env?.DEV ?? true) {\n const warned = new Set<SwitcherValue>();\n watchEffect(() => {\n for (const item of props.items) {\n if (item.icon && item.avatar && !warned.has(item.value)) {\n warned.add(item.value);\n console.warn(\n `[Switcher] item \"${item.value}\" declares both \\`icon\\` and \\`avatar\\`; \\`avatar\\` wins. Pick one.`,\n );\n }\n }\n });\n}\n\ndefineExpose({ open, close, toggle });\n</script>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switcher.mjs","names":[],"sources":["../../../src/components/navigation/Switcher.vue"],"sourcesContent":["<template>\n <div class=\"modo-switcher inline-flex\" :class=\"{ 'w-full': fullWidth }\">\n <span ref=\"triggerWrapEl\" class=\"inline-flex\" :class=\"{ 'w-full': fullWidth }\">\n <slot\n name=\"trigger\"\n :activeItem=\"activeItem\"\n :isOpen=\"isOpen\"\n :toggle=\"onTriggerClick\"\n >\n <button\n ref=\"triggerEl\"\n type=\"button\"\n data-modo-switcher-trigger\n aria-haspopup=\"listbox\"\n :aria-expanded=\"isOpen\"\n :aria-label=\"resolvedAriaLabel\"\n :disabled=\"disabled\"\n :class=\"[\n 'inline-flex items-center gap-3 px-3 py-2 text-left transition-colors',\n 'border bg-card text-card-foreground border-border',\n 'hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60',\n radiusClass,\n fullWidth ? 'w-full' : '',\n disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer',\n ]\"\n @click=\"onTriggerClick\"\n @keydown=\"onTriggerKeydown\"\n >\n <span v-if=\"activeItem?.avatar\" class=\"shrink-0\">\n <Avatar\n :src=\"activeItem.avatar.src\"\n :initials=\"activeItem.avatar.initials\"\n :name=\"activeItem.title\"\n size=\"small\"\n />\n </span>\n <span\n v-else-if=\"activeItem?.icon\"\n class=\"shrink-0 inline-flex items-center justify-center w-9 h-9 rounded-md bg-accent/60 text-foreground\"\n >\n <component :is=\"activeItem.icon\" class=\"w-5 h-5\" aria-hidden=\"true\" />\n </span>\n <span class=\"flex flex-col min-w-0 flex-1\">\n <span class=\"truncate text-body font-medium\">\n {{ activeItem ? activeItem.title : resolvedPlaceholder }}\n </span>\n <span\n v-if=\"!compactTrigger && activeItem?.subtitle\"\n class=\"truncate text-caption text-muted-foreground\"\n >\n {{ activeItem.subtitle }}\n </span>\n </span>\n <ChevronUpDownIcon\n v-if=\"chevron === 'updown'\"\n class=\"w-4 h-4 shrink-0 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n <ChevronDownIcon\n v-else-if=\"chevron === 'down'\"\n class=\"w-4 h-4 shrink-0 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n </button>\n </slot>\n </span>\n\n <PopoverPanel\n :open=\"isOpen\"\n :style=\"mergedPanelStyle\"\n :radius=\"resolvedRadius\"\n role=\"dialog\"\n :aria-label=\"resolvedAriaLabel\"\n @update:panelRef=\"panelRef = $event\"\n >\n <div\n data-modo-switcher-panel\n class=\"modo-switcher-panel overflow-y-auto\"\n :style=\"{ maxHeight: panelMaxHeightStyle }\"\n >\n <div\n v-if=\"panelTitle\"\n class=\"px-3 pt-3 pb-2 text-caption text-muted-foreground uppercase tracking-wider\"\n >\n {{ panelTitle }}\n </div>\n\n <div v-if=\"searchable\" class=\"px-2 pt-2 pb-1\">\n <input\n ref=\"searchInputEl\"\n v-model=\"searchQuery\"\n role=\"searchbox\"\n type=\"text\"\n :placeholder=\"resolvedSearchPlaceholder\"\n :aria-controls=\"listboxId\"\n :aria-activedescendant=\"activeDescendantId\"\n class=\"w-full px-2 py-1.5 text-body bg-background border border-border rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60\"\n @keydown=\"onSearchKeydown\"\n />\n </div>\n\n <template v-if=\"loading\">\n <slot name=\"loading\">\n <div class=\"p-2 flex flex-col gap-1\">\n <div\n v-for=\"i in 3\"\n :key=\"i\"\n data-modo-switcher-skeleton\n >\n <Skeleton height=\"44px\" />\n </div>\n </div>\n </slot>\n </template>\n\n <template v-else-if=\"items.length === 0\">\n <slot name=\"empty\">\n <div class=\"px-3 py-6 text-center text-muted-foreground text-body\">\n {{ resolvedEmptyText }}\n </div>\n </slot>\n </template>\n\n <template v-else-if=\"displayedItems.length === 0\">\n <div class=\"px-3 py-6 text-center text-muted-foreground text-body\">\n {{ resolvedNoResults }}\n </div>\n </template>\n\n <ul\n v-else\n role=\"listbox\"\n :id=\"listboxId\"\n class=\"flex flex-col\"\n @keydown=\"onListKeydown\"\n >\n <li\n v-for=\"(item, idx) in displayedItems\"\n :key=\"item.value\"\n :ref=\"(el) => setOptionRef(el as HTMLElement | null, idx)\"\n role=\"option\"\n :id=\"`${listboxId}-opt-${idx}`\"\n :aria-selected=\"item.value === modelValue\"\n :aria-current=\"item.value === modelValue ? 'true' : undefined\"\n :aria-disabled=\"item.disabled || undefined\"\n :data-active=\"item.value === modelValue || undefined\"\n :tabindex=\"-1\"\n class=\"modo-switcher-item flex items-center gap-3 px-3 py-2 cursor-pointer\"\n :class=\"[\n item.value === modelValue ? 'bg-accent/40' : '',\n searchable && idx === highlightedIdx ? 'bg-accent' : 'hover:bg-accent',\n item.disabled ? 'opacity-50 cursor-not-allowed' : '',\n ]\"\n @click=\"selectItem(item)\"\n @mouseenter=\"searchable ? (highlightedIdx = idx) : null\"\n >\n <span v-if=\"item.avatar\" class=\"shrink-0\">\n <Avatar\n :src=\"item.avatar.src\"\n :initials=\"item.avatar.initials\"\n :name=\"item.title\"\n size=\"small\"\n />\n </span>\n <span\n v-else-if=\"item.icon\"\n data-modo-switcher-iconwrap\n class=\"shrink-0 inline-flex items-center justify-center w-9 h-9 rounded-md bg-accent/60 text-foreground\"\n >\n <component :is=\"item.icon\" class=\"w-5 h-5\" aria-hidden=\"true\" />\n </span>\n <span class=\"flex flex-col min-w-0 flex-1\">\n <span class=\"truncate text-body font-medium\">{{ item.title }}</span>\n <span\n v-if=\"item.subtitle\"\n class=\"truncate text-caption text-muted-foreground\"\n >{{ item.subtitle }}</span>\n </span>\n <slot\n name=\"item-trailing\"\n :item=\"item\"\n :active=\"item.value === modelValue\"\n :close=\"close\"\n >\n <CheckIcon\n v-if=\"item.value === modelValue\"\n class=\"w-4 h-4 shrink-0\"\n aria-hidden=\"true\"\n />\n </slot>\n </li>\n </ul>\n\n <template v-if=\"$slots.footer\">\n <hr\n data-modo-switcher-footer-sep\n role=\"separator\"\n class=\"my-1 border-t border-border\"\n />\n <div class=\"p-1\">\n <slot name=\"footer\" :close=\"close\" />\n </div>\n </template>\n </div>\n </PopoverPanel>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, nextTick, ref, useId, watch, watchEffect } from \"vue\";\nimport { ChevronUpDownIcon, ChevronDownIcon, CheckIcon } from \"@heroicons/vue/24/outline\";\nimport PopoverPanel from \"../layout/PopoverPanel.vue\";\nimport Avatar from \"../data-display/avatar/Avatar.vue\";\nimport Skeleton from \"../feedback/Skeleton.vue\";\nimport { usePopover } from \"../../composables/usePopover\";\nimport {\n useResolvedRadius,\n useModoLocale,\n} from \"../../composables/useModoConfig\";\nimport type {\n Switcher as SwitcherProps,\n SwitcherEmits,\n SwitcherItem,\n SwitcherValue,\n} from \"../../interfaces/navigation/Switcher.interface\";\n\nconst props = withDefaults(defineProps<SwitcherProps>(), {\n modelValue: null,\n chevron: \"updown\",\n triggerVariant: \"outline\",\n compactTrigger: false,\n fullWidth: false,\n panelWidth: \"trigger\",\n panelMinWidth: \"15rem\",\n panelMaxHeight: 320,\n placement: \"bottom-start\",\n searchable: false,\n loading: false,\n disabled: false,\n});\n\nconst emit = defineEmits<SwitcherEmits>();\n\nconst locale = useModoLocale();\nconst resolvedRadius = useResolvedRadius(() => props.radius);\nconst listboxId = useId();\n\nconst resolvedPlaceholder = computed(\n () => props.placeholder ?? locale.value.switcher.placeholder,\n);\nconst resolvedAriaLabel = computed(\n () => props.ariaLabel ?? locale.value.switcher.ariaLabel,\n);\nconst resolvedEmptyText = computed(\n () => props.emptyText ?? locale.value.switcher.empty,\n);\nconst resolvedSearchPlaceholder = computed(\n () => props.searchPlaceholder ?? locale.value.switcher.searchPlaceholder,\n);\nconst resolvedNoResults = computed(\n () => props.noResultsText ?? locale.value.switcher.noResults,\n);\n\nconst searchQuery = ref(\"\");\nconst searchInputEl = ref<HTMLInputElement | null>(null);\n\nconst displayedItems = computed<SwitcherItem[]>(() => {\n if (!props.searchable) return props.items;\n const q = searchQuery.value.trim().toLowerCase();\n if (!q) return props.items;\n const fields = props.searchFields ?? [\"title\", \"subtitle\"];\n return props.items.filter((it) =>\n fields.some((f) => {\n const v = it[f];\n return typeof v === \"string\" && v.toLowerCase().includes(q);\n }),\n );\n});\n\nwatch(searchQuery, (q) => {\n emit(\"search\", q);\n});\n\nconst radiusClass = computed(() => {\n switch (resolvedRadius.value) {\n case \"none\": return \"rounded-none\";\n case \"small\": return \"rounded-sm\";\n case \"large\": return \"rounded-lg\";\n case \"full\": return \"rounded-[999px]\";\n default: return \"rounded-md\";\n }\n});\n\nconst panelMaxHeightStyle = computed(() => {\n const v = props.panelMaxHeight;\n return typeof v === \"number\" ? `${v}px` : v;\n});\n\nconst panelMinWidthStyle = computed(() => {\n const v = props.panelMinWidth;\n if (v == null) return undefined;\n return typeof v === \"number\" ? `${v}px` : v;\n});\n\n// The popover composable sizes the panel to the trigger width when\n// `panelWidth='trigger'`. A narrow trigger (e.g. an avatar-only custom\n// trigger) would otherwise crush the panel — `minWidth` floors it.\nconst mergedPanelStyle = computed(() => ({\n ...panelStyle.value,\n ...(panelMinWidthStyle.value ? { minWidth: panelMinWidthStyle.value } : {}),\n}));\n\nconst activeItem = computed<SwitcherItem | null>(() => {\n if (props.modelValue == null) return null;\n return props.items.find((i) => i.value === props.modelValue) ?? null;\n});\n\nconst {\n triggerRef,\n panelRef,\n isOpen,\n panelStyle,\n open,\n close,\n toggle,\n} = usePopover({\n placement: () => props.placement,\n matchTriggerWidth: () => props.panelWidth === \"trigger\",\n closeOnEscape: false,\n onOpen: () => emit(\"open\"),\n onClose: () => {\n searchQuery.value = \"\";\n emit(\"close\");\n },\n});\n\nconst triggerEl = ref<HTMLElement | null>(null);\nconst triggerWrapEl = ref<HTMLElement | null>(null);\nwatch([triggerEl, triggerWrapEl], ([btn, wrap]) => {\n triggerRef.value = (btn as HTMLElement | null) ?? (wrap as HTMLElement | null);\n});\n\nfunction focusTrigger() {\n const el = triggerEl.value ?? triggerWrapEl.value;\n el?.focus?.();\n}\n\nfunction onTriggerClick() {\n if (props.disabled) return;\n toggle();\n}\n\nfunction selectItem(item: SwitcherItem) {\n if (item.disabled || props.disabled) return;\n emit(\"update:modelValue\", item.value);\n emit(\"change\", item.value, item);\n close();\n}\n\nfunction focusableIndices(): number[] {\n return displayedItems.value\n .map((it, i) => (it.disabled ? -1 : i))\n .filter((i) => i !== -1);\n}\n\nconst optionRefs = new Map<number, HTMLElement>();\nfunction setOptionRef(el: HTMLElement | null, idx: number) {\n if (el) optionRefs.set(idx, el);\n else optionRefs.delete(idx);\n}\n\nfunction focusOptionByIdx(idx: number) {\n optionRefs.get(idx)?.focus();\n}\n\nasync function openAndFocusActive() {\n if (props.disabled) return;\n if (!isOpen.value) open();\n await nextTick();\n if (props.searchable) {\n searchInputEl.value?.focus();\n return;\n }\n const order = focusableIndices();\n if (!order.length) return;\n const activeIdx = displayedItems.value.findIndex(\n (it) => it.value === props.modelValue,\n );\n const usable =\n activeIdx >= 0 && !displayedItems.value[activeIdx].disabled\n ? activeIdx\n : order[0];\n focusOptionByIdx(usable);\n}\n\nfunction onTriggerKeydown(e: KeyboardEvent) {\n if ([\"ArrowDown\", \"ArrowUp\", \"Enter\", \" \"].includes(e.key)) {\n e.preventDefault();\n openAndFocusActive();\n } else if (e.key === \"Escape\" && isOpen.value) {\n e.preventDefault();\n close();\n }\n}\n\nfunction currentFocusedIdx(): number {\n const el = document.activeElement as HTMLElement | null;\n if (!el) return -1;\n for (const [idx, node] of optionRefs.entries()) {\n if (node === el) return idx;\n }\n return -1;\n}\n\nfunction moveFocus(delta: 1 | -1) {\n const order = focusableIndices();\n if (!order.length) return;\n const cur = currentFocusedIdx();\n let pos = order.indexOf(cur);\n if (pos === -1) {\n focusOptionByIdx(delta > 0 ? order[0] : order[order.length - 1]);\n return;\n }\n pos = (pos + delta + order.length) % order.length;\n focusOptionByIdx(order[pos]);\n}\n\nfunction onListKeydown(e: KeyboardEvent) {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n moveFocus(1);\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n moveFocus(-1);\n } else if (e.key === \"Home\") {\n e.preventDefault();\n const order = focusableIndices();\n if (order.length) focusOptionByIdx(order[0]);\n } else if (e.key === \"End\") {\n e.preventDefault();\n const order = focusableIndices();\n if (order.length) focusOptionByIdx(order[order.length - 1]);\n } else if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n const idx = currentFocusedIdx();\n if (idx >= 0) selectItem(displayedItems.value[idx]);\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n close();\n focusTrigger();\n } else if (\n !props.searchable &&\n e.key.length === 1 &&\n /^[a-zA-Z0-9]$/.test(e.key)\n ) {\n const order = focusableIndices();\n const letter = e.key.toLowerCase();\n const match = order.find((i) =>\n displayedItems.value[i].title.toLowerCase().startsWith(letter),\n );\n if (match !== undefined) focusOptionByIdx(match);\n }\n}\n\nwatch(isOpen, (open) => {\n if (!open) focusTrigger();\n});\n\nconst highlightedIdx = ref<number>(-1);\n\nconst activeDescendantId = computed(() =>\n highlightedIdx.value >= 0\n ? `${listboxId}-opt-${highlightedIdx.value}`\n : undefined,\n);\n\nwatch(displayedItems, () => {\n if (!props.searchable) return;\n const order = focusableIndices();\n highlightedIdx.value = order[0] ?? -1;\n});\n\nwatch(isOpen, (open) => {\n if (!open) {\n highlightedIdx.value = -1;\n return;\n }\n if (!props.searchable) return;\n const idx = displayedItems.value.findIndex(\n (it) => it.value === props.modelValue && !it.disabled,\n );\n const order = focusableIndices();\n highlightedIdx.value = idx >= 0 ? idx : order[0] ?? -1;\n});\n\nfunction moveHighlight(delta: 1 | -1) {\n const order = focusableIndices();\n if (!order.length) return;\n const cur = order.indexOf(highlightedIdx.value);\n if (cur === -1) {\n highlightedIdx.value = delta > 0 ? order[0] : order[order.length - 1];\n return;\n }\n const next = (cur + delta + order.length) % order.length;\n highlightedIdx.value = order[next];\n}\n\nfunction onSearchKeydown(e: KeyboardEvent) {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n moveHighlight(1);\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n moveHighlight(-1);\n } else if (e.key === \"Home\") {\n e.preventDefault();\n const order = focusableIndices();\n if (order.length) highlightedIdx.value = order[0];\n } else if (e.key === \"End\") {\n e.preventDefault();\n const order = focusableIndices();\n if (order.length) highlightedIdx.value = order[order.length - 1];\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n if (highlightedIdx.value >= 0) {\n selectItem(displayedItems.value[highlightedIdx.value]);\n }\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n close();\n focusTrigger();\n }\n}\n\n// Dev-only: warn once per offending item when both icon and avatar are set.\nif (import.meta.env?.DEV ?? true) {\n const warned = new Set<SwitcherValue>();\n watchEffect(() => {\n for (const item of props.items) {\n if (item.icon && item.avatar && !warned.has(item.value)) {\n warned.add(item.value);\n console.warn(\n `[Switcher] item \"${item.value}\" declares both \\`icon\\` and \\`avatar\\`; \\`avatar\\` wins. Pick one.`,\n );\n }\n }\n });\n}\n\ndefineExpose({ open, close, toggle });\n</script>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Switcher.mjs","names":[],"sources":["../../../src/components/navigation/Switcher.vue"],"sourcesContent":["<template>\n <div class=\"modo-switcher inline-flex\" :class=\"{ 'w-full': fullWidth }\">\n <span ref=\"triggerWrapEl\" class=\"inline-flex\" :class=\"{ 'w-full': fullWidth }\">\n <slot\n name=\"trigger\"\n :activeItem=\"activeItem\"\n :isOpen=\"isOpen\"\n :toggle=\"onTriggerClick\"\n >\n <button\n ref=\"triggerEl\"\n type=\"button\"\n data-modo-switcher-trigger\n aria-haspopup=\"listbox\"\n :aria-expanded=\"isOpen\"\n :aria-label=\"resolvedAriaLabel\"\n :disabled=\"disabled\"\n :class=\"[\n 'inline-flex items-center gap-3 px-3 py-2 text-left transition-colors',\n 'border bg-card text-card-foreground border-border',\n 'hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60',\n radiusClass,\n fullWidth ? 'w-full' : '',\n disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer',\n ]\"\n @click=\"onTriggerClick\"\n @keydown=\"onTriggerKeydown\"\n >\n <span v-if=\"activeItem?.avatar\" class=\"shrink-0\">\n <Avatar\n :src=\"activeItem.avatar.src\"\n :initials=\"activeItem.avatar.initials\"\n :name=\"activeItem.title\"\n size=\"small\"\n />\n </span>\n <span\n v-else-if=\"activeItem?.icon\"\n :class=\"[\n 'shrink-0 inline-flex items-center justify-center w-9 h-9 bg-accent/60 text-foreground',\n radiusClass,\n ]\"\n >\n <component :is=\"activeItem.icon\" class=\"w-5 h-5\" aria-hidden=\"true\" />\n </span>\n <span class=\"flex flex-col min-w-0 flex-1\">\n <span class=\"truncate text-body font-medium\">\n {{ activeItem ? activeItem.title : resolvedPlaceholder }}\n </span>\n <span\n v-if=\"!compactTrigger && activeItem?.subtitle\"\n class=\"truncate text-caption text-muted-foreground\"\n >\n {{ activeItem.subtitle }}\n </span>\n </span>\n <ChevronUpDownIcon\n v-if=\"chevron === 'updown'\"\n class=\"w-4 h-4 shrink-0 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n <ChevronDownIcon\n v-else-if=\"chevron === 'down'\"\n class=\"w-4 h-4 shrink-0 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n </button>\n </slot>\n </span>\n\n <PopoverPanel\n :open=\"isOpen\"\n :style=\"mergedPanelStyle\"\n :radius=\"resolvedRadius\"\n role=\"dialog\"\n :aria-label=\"resolvedAriaLabel\"\n @update:panelRef=\"panelRef = $event\"\n >\n <div\n data-modo-switcher-panel\n class=\"modo-switcher-panel overflow-y-auto\"\n :style=\"{ maxHeight: panelMaxHeightStyle }\"\n >\n <div\n v-if=\"panelTitle\"\n class=\"px-3 pt-3 pb-2 text-caption text-muted-foreground uppercase tracking-wider\"\n >\n {{ panelTitle }}\n </div>\n\n <div v-if=\"searchable\" class=\"px-2 pt-2 pb-1\">\n <input\n ref=\"searchInputEl\"\n v-model=\"searchQuery\"\n role=\"searchbox\"\n type=\"text\"\n :placeholder=\"resolvedSearchPlaceholder\"\n :aria-controls=\"listboxId\"\n :aria-activedescendant=\"activeDescendantId\"\n class=\"w-full px-2 py-1.5 text-body bg-background border border-border rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60\"\n @keydown=\"onSearchKeydown\"\n />\n </div>\n\n <template v-if=\"loading\">\n <slot name=\"loading\">\n <div class=\"p-2 flex flex-col gap-1\">\n <div\n v-for=\"i in 3\"\n :key=\"i\"\n data-modo-switcher-skeleton\n >\n <Skeleton height=\"44px\" />\n </div>\n </div>\n </slot>\n </template>\n\n <template v-else-if=\"items.length === 0\">\n <slot name=\"empty\">\n <div class=\"px-3 py-6 text-center text-muted-foreground text-body\">\n {{ resolvedEmptyText }}\n </div>\n </slot>\n </template>\n\n <template v-else-if=\"displayedItems.length === 0\">\n <div class=\"px-3 py-6 text-center text-muted-foreground text-body\">\n {{ resolvedNoResults }}\n </div>\n </template>\n\n <ul\n v-else\n role=\"listbox\"\n :id=\"listboxId\"\n class=\"flex flex-col\"\n @keydown=\"onListKeydown\"\n >\n <li\n v-for=\"(item, idx) in displayedItems\"\n :key=\"item.value\"\n :ref=\"(el) => setOptionRef(el as HTMLElement | null, idx)\"\n role=\"option\"\n :id=\"`${listboxId}-opt-${idx}`\"\n :aria-selected=\"item.value === modelValue\"\n :aria-current=\"item.value === modelValue ? 'true' : undefined\"\n :aria-disabled=\"item.disabled || undefined\"\n :data-active=\"item.value === modelValue || undefined\"\n :tabindex=\"-1\"\n class=\"modo-switcher-item flex items-center gap-3 px-3 py-2 cursor-pointer\"\n :class=\"[\n item.value === modelValue ? 'bg-accent/40' : '',\n searchable && idx === highlightedIdx ? 'bg-accent' : 'hover:bg-accent',\n item.disabled ? 'opacity-50 cursor-not-allowed' : '',\n ]\"\n @click=\"selectItem(item)\"\n @mouseenter=\"searchable ? (highlightedIdx = idx) : null\"\n >\n <span v-if=\"item.avatar\" class=\"shrink-0\">\n <Avatar\n :src=\"item.avatar.src\"\n :initials=\"item.avatar.initials\"\n :name=\"item.title\"\n size=\"small\"\n />\n </span>\n <span\n v-else-if=\"item.icon\"\n data-modo-switcher-iconwrap\n :class=\"[\n 'shrink-0 inline-flex items-center justify-center w-9 h-9 bg-accent/60 text-foreground',\n radiusClass,\n ]\"\n >\n <component :is=\"item.icon\" class=\"w-5 h-5\" aria-hidden=\"true\" />\n </span>\n <span class=\"flex flex-col min-w-0 flex-1\">\n <span class=\"truncate text-body font-medium\">{{ item.title }}</span>\n <span\n v-if=\"item.subtitle\"\n class=\"truncate text-caption text-muted-foreground\"\n >{{ item.subtitle }}</span>\n </span>\n <slot\n name=\"item-trailing\"\n :item=\"item\"\n :active=\"item.value === modelValue\"\n :close=\"close\"\n >\n <CheckIcon\n v-if=\"item.value === modelValue\"\n class=\"w-4 h-4 shrink-0\"\n aria-hidden=\"true\"\n />\n </slot>\n </li>\n </ul>\n\n <template v-if=\"$slots.footer\">\n <hr\n data-modo-switcher-footer-sep\n role=\"separator\"\n class=\"my-1 border-t border-border\"\n />\n <div class=\"p-1\">\n <slot name=\"footer\" :close=\"close\" />\n </div>\n </template>\n </div>\n </PopoverPanel>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, nextTick, ref, useId, watch, watchEffect } from \"vue\";\nimport { ChevronUpDownIcon, ChevronDownIcon, CheckIcon } from \"@heroicons/vue/24/outline\";\nimport PopoverPanel from \"../layout/PopoverPanel.vue\";\nimport Avatar from \"../data-display/avatar/Avatar.vue\";\nimport Skeleton from \"../feedback/Skeleton.vue\";\nimport { usePopover } from \"../../composables/usePopover\";\nimport {\n useResolvedRadius,\n useModoLocale,\n} from \"../../composables/useModoConfig\";\nimport type {\n Switcher as SwitcherProps,\n SwitcherEmits,\n SwitcherItem,\n SwitcherValue,\n} from \"../../interfaces/navigation/Switcher.interface\";\n\nconst props = withDefaults(defineProps<SwitcherProps>(), {\n modelValue: null,\n chevron: \"updown\",\n triggerVariant: \"outline\",\n compactTrigger: false,\n fullWidth: false,\n panelWidth: \"trigger\",\n panelMinWidth: \"15rem\",\n panelMaxHeight: 320,\n placement: \"bottom-start\",\n searchable: false,\n loading: false,\n disabled: false,\n});\n\nconst emit = defineEmits<SwitcherEmits>();\n\nconst locale = useModoLocale();\nconst resolvedRadius = useResolvedRadius(() => props.radius);\nconst listboxId = useId();\n\nconst resolvedPlaceholder = computed(\n () => props.placeholder ?? locale.value.switcher.placeholder,\n);\nconst resolvedAriaLabel = computed(\n () => props.ariaLabel ?? locale.value.switcher.ariaLabel,\n);\nconst resolvedEmptyText = computed(\n () => props.emptyText ?? locale.value.switcher.empty,\n);\nconst resolvedSearchPlaceholder = computed(\n () => props.searchPlaceholder ?? locale.value.switcher.searchPlaceholder,\n);\nconst resolvedNoResults = computed(\n () => props.noResultsText ?? locale.value.switcher.noResults,\n);\n\nconst searchQuery = ref(\"\");\nconst searchInputEl = ref<HTMLInputElement | null>(null);\n\nconst displayedItems = computed<SwitcherItem[]>(() => {\n if (!props.searchable) return props.items;\n const q = searchQuery.value.trim().toLowerCase();\n if (!q) return props.items;\n const fields = props.searchFields ?? [\"title\", \"subtitle\"];\n return props.items.filter((it) =>\n fields.some((f) => {\n const v = it[f];\n return typeof v === \"string\" && v.toLowerCase().includes(q);\n }),\n );\n});\n\nwatch(searchQuery, (q) => {\n emit(\"search\", q);\n});\n\nconst radiusClass = computed(() => {\n switch (resolvedRadius.value) {\n case \"none\": return \"rounded-none\";\n case \"small\": return \"rounded-sm\";\n case \"large\": return \"rounded-lg\";\n case \"full\": return \"rounded-[999px]\";\n default: return \"rounded-md\";\n }\n});\n\nconst panelMaxHeightStyle = computed(() => {\n const v = props.panelMaxHeight;\n return typeof v === \"number\" ? `${v}px` : v;\n});\n\nconst panelMinWidthStyle = computed(() => {\n const v = props.panelMinWidth;\n if (v == null) return undefined;\n return typeof v === \"number\" ? `${v}px` : v;\n});\n\n// The popover composable sizes the panel to the trigger width when\n// `panelWidth='trigger'`. A narrow trigger (e.g. an avatar-only custom\n// trigger) would otherwise crush the panel — `minWidth` floors it.\nconst mergedPanelStyle = computed(() => ({\n ...panelStyle.value,\n ...(panelMinWidthStyle.value ? { minWidth: panelMinWidthStyle.value } : {}),\n}));\n\nconst activeItem = computed<SwitcherItem | null>(() => {\n if (props.modelValue == null) return null;\n return props.items.find((i) => i.value === props.modelValue) ?? null;\n});\n\nconst {\n triggerRef,\n panelRef,\n isOpen,\n panelStyle,\n open,\n close,\n toggle,\n} = usePopover({\n placement: () => props.placement,\n matchTriggerWidth: () => props.panelWidth === \"trigger\",\n closeOnEscape: false,\n onOpen: () => emit(\"open\"),\n onClose: () => {\n searchQuery.value = \"\";\n emit(\"close\");\n },\n});\n\nconst triggerEl = ref<HTMLElement | null>(null);\nconst triggerWrapEl = ref<HTMLElement | null>(null);\nwatch([triggerEl, triggerWrapEl], ([btn, wrap]) => {\n triggerRef.value = (btn as HTMLElement | null) ?? (wrap as HTMLElement | null);\n});\n\nfunction focusTrigger() {\n const el = triggerEl.value ?? triggerWrapEl.value;\n el?.focus?.();\n}\n\nfunction onTriggerClick() {\n if (props.disabled) return;\n toggle();\n}\n\nfunction selectItem(item: SwitcherItem) {\n if (item.disabled || props.disabled) return;\n emit(\"update:modelValue\", item.value);\n emit(\"change\", item.value, item);\n close();\n}\n\nfunction focusableIndices(): number[] {\n return displayedItems.value\n .map((it, i) => (it.disabled ? -1 : i))\n .filter((i) => i !== -1);\n}\n\nconst optionRefs = new Map<number, HTMLElement>();\nfunction setOptionRef(el: HTMLElement | null, idx: number) {\n if (el) optionRefs.set(idx, el);\n else optionRefs.delete(idx);\n}\n\nfunction focusOptionByIdx(idx: number) {\n optionRefs.get(idx)?.focus();\n}\n\nasync function openAndFocusActive() {\n if (props.disabled) return;\n if (!isOpen.value) open();\n await nextTick();\n if (props.searchable) {\n searchInputEl.value?.focus();\n return;\n }\n const order = focusableIndices();\n if (!order.length) return;\n const activeIdx = displayedItems.value.findIndex(\n (it) => it.value === props.modelValue,\n );\n const usable =\n activeIdx >= 0 && !displayedItems.value[activeIdx].disabled\n ? activeIdx\n : order[0];\n focusOptionByIdx(usable);\n}\n\nfunction onTriggerKeydown(e: KeyboardEvent) {\n if ([\"ArrowDown\", \"ArrowUp\", \"Enter\", \" \"].includes(e.key)) {\n e.preventDefault();\n openAndFocusActive();\n } else if (e.key === \"Escape\" && isOpen.value) {\n e.preventDefault();\n close();\n }\n}\n\nfunction currentFocusedIdx(): number {\n const el = document.activeElement as HTMLElement | null;\n if (!el) return -1;\n for (const [idx, node] of optionRefs.entries()) {\n if (node === el) return idx;\n }\n return -1;\n}\n\nfunction moveFocus(delta: 1 | -1) {\n const order = focusableIndices();\n if (!order.length) return;\n const cur = currentFocusedIdx();\n let pos = order.indexOf(cur);\n if (pos === -1) {\n focusOptionByIdx(delta > 0 ? order[0] : order[order.length - 1]);\n return;\n }\n pos = (pos + delta + order.length) % order.length;\n focusOptionByIdx(order[pos]);\n}\n\nfunction onListKeydown(e: KeyboardEvent) {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n moveFocus(1);\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n moveFocus(-1);\n } else if (e.key === \"Home\") {\n e.preventDefault();\n const order = focusableIndices();\n if (order.length) focusOptionByIdx(order[0]);\n } else if (e.key === \"End\") {\n e.preventDefault();\n const order = focusableIndices();\n if (order.length) focusOptionByIdx(order[order.length - 1]);\n } else if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n const idx = currentFocusedIdx();\n if (idx >= 0) selectItem(displayedItems.value[idx]);\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n close();\n focusTrigger();\n } else if (\n !props.searchable &&\n e.key.length === 1 &&\n /^[a-zA-Z0-9]$/.test(e.key)\n ) {\n const order = focusableIndices();\n const letter = e.key.toLowerCase();\n const match = order.find((i) =>\n displayedItems.value[i].title.toLowerCase().startsWith(letter),\n );\n if (match !== undefined) focusOptionByIdx(match);\n }\n}\n\nwatch(isOpen, (open) => {\n if (!open) focusTrigger();\n});\n\nconst highlightedIdx = ref<number>(-1);\n\nconst activeDescendantId = computed(() =>\n highlightedIdx.value >= 0\n ? `${listboxId}-opt-${highlightedIdx.value}`\n : undefined,\n);\n\nwatch(displayedItems, () => {\n if (!props.searchable) return;\n const order = focusableIndices();\n highlightedIdx.value = order[0] ?? -1;\n});\n\nwatch(isOpen, (open) => {\n if (!open) {\n highlightedIdx.value = -1;\n return;\n }\n if (!props.searchable) return;\n const idx = displayedItems.value.findIndex(\n (it) => it.value === props.modelValue && !it.disabled,\n );\n const order = focusableIndices();\n highlightedIdx.value = idx >= 0 ? idx : order[0] ?? -1;\n});\n\nfunction moveHighlight(delta: 1 | -1) {\n const order = focusableIndices();\n if (!order.length) return;\n const cur = order.indexOf(highlightedIdx.value);\n if (cur === -1) {\n highlightedIdx.value = delta > 0 ? order[0] : order[order.length - 1];\n return;\n }\n const next = (cur + delta + order.length) % order.length;\n highlightedIdx.value = order[next];\n}\n\nfunction onSearchKeydown(e: KeyboardEvent) {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n moveHighlight(1);\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n moveHighlight(-1);\n } else if (e.key === \"Home\") {\n e.preventDefault();\n const order = focusableIndices();\n if (order.length) highlightedIdx.value = order[0];\n } else if (e.key === \"End\") {\n e.preventDefault();\n const order = focusableIndices();\n if (order.length) highlightedIdx.value = order[order.length - 1];\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n if (highlightedIdx.value >= 0) {\n selectItem(displayedItems.value[highlightedIdx.value]);\n }\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n close();\n focusTrigger();\n }\n}\n\n// Dev-only: warn once per offending item when both icon and avatar are set.\nif (import.meta.env?.DEV ?? true) {\n const warned = new Set<SwitcherValue>();\n watchEffect(() => {\n for (const item of props.items) {\n if (item.icon && item.avatar && !warned.has(item.value)) {\n warned.add(item.value);\n console.warn(\n `[Switcher] item \"${item.value}\" declares both \\`icon\\` and \\`avatar\\`; \\`avatar\\` wins. Pick one.`,\n );\n }\n }\n });\n}\n\ndefineExpose({ open, close, toggle });\n</script>\n"],"mappings":""}
|