mood-ui 0.11.0 → 0.12.1
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 +11 -6
- 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 +18 -13
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/Calendar.vue_vue_type_script_setup_true_lang.mjs +4 -4
- package/dist/components/data-display/calendar/Calendar.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 +14 -9
- 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 +22 -17
- 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 +15 -17
- 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 +18 -20
- 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 +14 -9
- 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 +22 -17
- 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 +14 -9
- 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 +22 -17
- 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/DateRangePicker.vue_vue_type_script_setup_true_lang.mjs +3 -3
- package/dist/components/data-display/date-picker/DateRangePicker.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 +3 -3
- package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Banner.vue_vue_type_script_setup_true_lang.mjs +4 -4
- package/dist/components/feedback/Banner.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 +9 -14
- 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 +9 -14
- 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/calendarTooltip.d.ts +13 -0
- package/dist/types/utils/cssLength.d.ts +5 -0
- package/dist/types/utils/tooltipArrow.d.ts +34 -0
- package/dist/utils/calendarTooltip.cjs +18 -0
- package/dist/utils/calendarTooltip.cjs.map +1 -0
- package/dist/utils/calendarTooltip.mjs +18 -0
- package/dist/utils/calendarTooltip.mjs.map +1 -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.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":""}
|
|
1
|
+
{"version":3,"file":"SearchInput.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.value?.blur(), \n select: () => inputRef.value?.select(), \n clear: onClear, \n inputRef, \n}); \n</script>\n"],"mappings":""}
|
|
@@ -50,7 +50,7 @@ var _hoisted_6 = {
|
|
|
50
50
|
key: 1,
|
|
51
51
|
class: "px-3 py-6 text-center text-muted-foreground text-body"
|
|
52
52
|
};
|
|
53
|
-
var _hoisted_7 = ["id"];
|
|
53
|
+
var _hoisted_7 = ["id", "aria-busy"];
|
|
54
54
|
var _hoisted_8 = {
|
|
55
55
|
key: 0,
|
|
56
56
|
role: "presentation",
|
|
@@ -152,7 +152,7 @@ var SearchInput_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0
|
|
|
152
152
|
const sz = require_useModoConfig.useSizeTokens(() => props.size);
|
|
153
153
|
const inputRef = (0, vue.ref)(null);
|
|
154
154
|
const focused = (0, vue.ref)(false);
|
|
155
|
-
const { fieldId, radius, stateColor, hasError, hasValue,
|
|
155
|
+
const { fieldId, radius, stateColor, hasError, hasValue, currentLength, showCounterEffective, counterOverflow, errorId, helperId, counterId, describedBy } = require_useField.useFieldState(props, {
|
|
156
156
|
componentName: "SearchInput",
|
|
157
157
|
idPrefix: "modo-search"
|
|
158
158
|
});
|
|
@@ -163,6 +163,7 @@ var SearchInput_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0
|
|
|
163
163
|
radius,
|
|
164
164
|
halo: () => props.halo
|
|
165
165
|
});
|
|
166
|
+
const isDisabled = (0, vue.computed)(() => !!props.disabled);
|
|
166
167
|
const affordanceIconClass = (0, vue.computed)(() => require_useField.FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? "text-muted-foreground");
|
|
167
168
|
const affordanceActionClass = (0, vue.computed)(() => require_useField.FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ?? "text-muted-foreground hover:text-foreground");
|
|
168
169
|
const resolvedRadius = require_useModoConfig.useResolvedRadius(() => props.radius);
|
|
@@ -380,7 +381,7 @@ var SearchInput_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0
|
|
|
380
381
|
wrapperSizeClasses.value,
|
|
381
382
|
(0, vue.unref)(radiusClasses),
|
|
382
383
|
__props.fullWidth ? "w-full" : "",
|
|
383
|
-
|
|
384
|
+
isDisabled.value ? "opacity-60 cursor-not-allowed" : ""
|
|
384
385
|
])
|
|
385
386
|
}, [
|
|
386
387
|
(0, vue.createVNode)((0, vue.unref)(_heroicons_vue_24_outline.MagnifyingGlassIcon), {
|
|
@@ -398,7 +399,7 @@ var SearchInput_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0
|
|
|
398
399
|
type: "search",
|
|
399
400
|
value: __props.modelValue ?? "",
|
|
400
401
|
placeholder: __props.placeholder,
|
|
401
|
-
disabled:
|
|
402
|
+
disabled: isDisabled.value,
|
|
402
403
|
readonly: __props.readonly,
|
|
403
404
|
required: __props.required,
|
|
404
405
|
name: __props.name,
|
|
@@ -429,7 +430,7 @@ var SearchInput_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0
|
|
|
429
430
|
key: 0,
|
|
430
431
|
size: __props.size === "large" ? "medium" : "small",
|
|
431
432
|
class: (0, vue.normalizeClass)(["shrink-0", affordanceIconClass.value])
|
|
432
|
-
}, null, 8, ["size", "class"])) : (0, vue.unref)(hasValue) && !
|
|
433
|
+
}, null, 8, ["size", "class"])) : (0, vue.unref)(hasValue) && !isDisabled.value && !__props.readonly ? ((0, vue.openBlock)(), (0, vue.createBlock)(require_Button.default, {
|
|
433
434
|
key: 1,
|
|
434
435
|
variant: "text",
|
|
435
436
|
size: "xs",
|
|
@@ -462,10 +463,11 @@ var SearchInput_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0
|
|
|
462
463
|
highlighted: highlightedIdx.value,
|
|
463
464
|
select: selectResult,
|
|
464
465
|
close: (0, vue.unref)(closePopover)
|
|
465
|
-
}, () => [__props.loading ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_5, [(0, vue.renderSlot)(_ctx.$slots, "loading", {}, () => [(0, vue.createVNode)(require_Loader.default, { size: "small" })])])) : !resultItems.value.length ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_6, [(0, vue.renderSlot)(_ctx.$slots, "empty", {}, () => [(0, vue.createTextVNode)((0, vue.toDisplayString)(__props.emptyText), 1)])])) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("ul", {
|
|
466
|
+
}, () => [__props.loading && !resultItems.value.length ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_5, [(0, vue.renderSlot)(_ctx.$slots, "loading", {}, () => [(0, vue.createVNode)(require_Loader.default, { size: "small" })])])) : !resultItems.value.length ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_6, [(0, vue.renderSlot)(_ctx.$slots, "empty", {}, () => [(0, vue.createTextVNode)((0, vue.toDisplayString)(__props.emptyText), 1)])])) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("ul", {
|
|
466
467
|
key: 2,
|
|
467
468
|
id: `${(0, vue.unref)(fieldId)}-results`,
|
|
468
469
|
role: "listbox",
|
|
470
|
+
"aria-busy": __props.loading || void 0,
|
|
469
471
|
class: "flex flex-col"
|
|
470
472
|
}, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(renderRows.value, (row) => {
|
|
471
473
|
return (0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: row.key }, [row.kind === "header" ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("li", _hoisted_8, (0, vue.toDisplayString)(row.label), 1)) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("li", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.vue_vue_type_script_setup_true_lang.cjs","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,sBAAA,eAAe;EAC3B,MAAM,SAAA,GAAA,IAAA,WAAkB;EAExB,MAAM,OAAO;EAcb,MAAM,QAAQ;EAeO,sBAAA,sBAAsB,MAAM,KAAK;EACtD,MAAM,KAAK,sBAAA,oBAAoB,MAAM,KAAK;EAE1C,MAAM,YAAA,GAAA,IAAA,KAAwC,KAAK;EACnD,MAAM,WAAA,GAAA,IAAA,KAAc,MAAM;EAE1B,MAAM,EACF,SACA,QACA,YACA,UACA,UACA,YACA,eACA,sBACA,iBACA,SACA,UACA,WACA,gBACA,iBAAA,cAAc,OAAO;GAAE,eAAe;GAAe,UAAU;GAAe,CAAC;EAEnF,MAAM,EAAE,uBAAuB,kB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I,QAAO;KACZ,SAAQ;KACR,MAAK;KACL,OAAM;KACN,IAAG;;qCAEY,EAAA,GAAA,IAAA,kBAAA,GAAA,IAAA,iBAAZ,QAAA,UAAS,EAAA,EAAA,CAAA,CAAA;;qBAGD,QAAA,eAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,aAQF,mBAAA,SAAA;;KAPR,KAAA,GAAA,IAAA,OAAI,SAAQ;KACb,SAAQ;KACR,MAAK;KACL,OAAM;KACN,IAAG;;qCAEa,EAAA,GAAA,IAAA,kBAAA,GAAA,IAAA,iBAAb,QAAA,WAAU,EAAA,EAAA,CAAA,CAAA;;wEAEa,QAA9B,YAA8B,IAAA,GAAA,IAAA,OAGpB,qBAAoB,KAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAQvB,QAAA;;KAPF,KAAA,GAAA,IAAA,OAAI,UAAS;KACb,QAAA,GAAA,IAAA,gBAAK,CAAA,uCAAA,GAAA,IAAA,OAAoF,gBAAe,GAAA,qBAAA,wBAAA,CAAA;+CAKtG,cAAa,CAAA,GAAG,OAAA,GAAA,IAAA,iBAAI,QAAA,UAAS,EAAA,IAAA,YAAA,KAAA,GAAA,IAAA,oBAAA,IAAA,KAAA,CAAA,CAAA,KAAA,GAAA,IAAA,oBAAA,IAAA,KAAA"}
|
|
1
|
+
{"version":3,"file":"SearchInput.vue_vue_type_script_setup_true_lang.cjs","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.value?.blur(), \n select: () => inputRef.value?.select(), \n clear: onClear, \n inputRef, \n}); \n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4PA,MAAM,MAAM,sBAAA,eAAe;EAC3B,MAAM,SAAA,GAAA,IAAA,WAAkB;EAExB,MAAM,OAAO;EAcb,MAAM,QAAQ;EAeO,sBAAA,sBAAsB,MAAM,KAAK;EACtD,MAAM,KAAK,sBAAA,oBAAoB,MAAM,KAAK;EAE1C,MAAM,YAAA,GAAA,IAAA,KAAwC,KAAK;EACnD,MAAM,WAAA,GAAA,IAAA,KAAc,MAAM;EAE1B,MAAM,EACF,SACA,QACA,YACA,UACA,UACA,eACA,sBACA,iBACA,SACA,UACA,WACA,gBACA,iBAAA,cAAc,OAAO;GAAE,eAAe;GAAe,UAAU;GAAe,CAAC;EAEnF,MAAM,EAAE,uBAAuB,kBAAkB,iBAAA,gBAAgB;GAC7D,eAAe,MAAM;GACrB;GACA;GACA;GACA,YAAY,MAAM;GACrB,CAAC;EAQF,MAAM,cAAA,GAAA,IAAA,gBAA4B,CAAC,CAAC,MAAM,SAAS;EAEnD,MAAM,uBAAA,GAAA,IAAA,gBAAqC,iBAAA,+BAA+B,WAAW,UAAU,wBAAwB;EACvH,MAAM,yBAAA,GAAA,IAAA,gBAAuC,iBAAA,iCAAiC,WAAW,UAAU,8CAA8C;EAGjJ,MAAM,iBAAiB,sBAAA,wBAAwB,MAAM,OAAO;EAI5D,MAAM,eAAA,GAAA,IAAA,gBAA6B,MAAM,UAAU,KAAA,KAAa,CAAC,CAAC,MAAM,QAAQ;EAChF,MAAM,eAAA,GAAA,IAAA,gBAAiD,MAAM,SAAS,E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B,IAAA,GAAA,IAAA,OAGpB,qBAAoB,KAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAQvB,QAAA;;KAPF,KAAA,GAAA,IAAA,OAAI,UAAS;KACb,QAAA,GAAA,IAAA,gBAAK,CAAA,uCAAA,GAAA,IAAA,OAAoF,gBAAe,GAAA,qBAAA,wBAAA,CAAA;+CAKtG,cAAa,CAAA,GAAG,OAAA,GAAA,IAAA,iBAAI,QAAA,UAAS,EAAA,IAAA,YAAA,KAAA,GAAA,IAAA,oBAAA,IAAA,KAAA,CAAA,CAAA,KAAA,GAAA,IAAA,oBAAA,IAAA,KAAA"}
|
|
@@ -49,7 +49,7 @@ var _hoisted_6 = {
|
|
|
49
49
|
key: 1,
|
|
50
50
|
class: "px-3 py-6 text-center text-muted-foreground text-body"
|
|
51
51
|
};
|
|
52
|
-
var _hoisted_7 = ["id"];
|
|
52
|
+
var _hoisted_7 = ["id", "aria-busy"];
|
|
53
53
|
var _hoisted_8 = {
|
|
54
54
|
key: 0,
|
|
55
55
|
role: "presentation",
|
|
@@ -151,7 +151,7 @@ var SearchInput_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
151
151
|
const sz = useSizeTokens(() => props.size);
|
|
152
152
|
const inputRef = ref(null);
|
|
153
153
|
const focused = ref(false);
|
|
154
|
-
const { fieldId, radius, stateColor, hasError, hasValue,
|
|
154
|
+
const { fieldId, radius, stateColor, hasError, hasValue, currentLength, showCounterEffective, counterOverflow, errorId, helperId, counterId, describedBy } = useFieldState(props, {
|
|
155
155
|
componentName: "SearchInput",
|
|
156
156
|
idPrefix: "modo-search"
|
|
157
157
|
});
|
|
@@ -162,6 +162,7 @@ var SearchInput_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
162
162
|
radius,
|
|
163
163
|
halo: () => props.halo
|
|
164
164
|
});
|
|
165
|
+
const isDisabled = computed(() => !!props.disabled);
|
|
165
166
|
const affordanceIconClass = computed(() => FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? "text-muted-foreground");
|
|
166
167
|
const affordanceActionClass = computed(() => FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ?? "text-muted-foreground hover:text-foreground");
|
|
167
168
|
const resolvedRadius = useResolvedRadius(() => props.radius);
|
|
@@ -379,7 +380,7 @@ var SearchInput_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
379
380
|
wrapperSizeClasses.value,
|
|
380
381
|
unref(radiusClasses),
|
|
381
382
|
__props.fullWidth ? "w-full" : "",
|
|
382
|
-
|
|
383
|
+
isDisabled.value ? "opacity-60 cursor-not-allowed" : ""
|
|
383
384
|
])
|
|
384
385
|
}, [
|
|
385
386
|
createVNode(unref(MagnifyingGlassIcon), {
|
|
@@ -397,7 +398,7 @@ var SearchInput_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
397
398
|
type: "search",
|
|
398
399
|
value: __props.modelValue ?? "",
|
|
399
400
|
placeholder: __props.placeholder,
|
|
400
|
-
disabled:
|
|
401
|
+
disabled: isDisabled.value,
|
|
401
402
|
readonly: __props.readonly,
|
|
402
403
|
required: __props.required,
|
|
403
404
|
name: __props.name,
|
|
@@ -428,7 +429,7 @@ var SearchInput_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
428
429
|
key: 0,
|
|
429
430
|
size: __props.size === "large" ? "medium" : "small",
|
|
430
431
|
class: normalizeClass(["shrink-0", affordanceIconClass.value])
|
|
431
|
-
}, null, 8, ["size", "class"])) : unref(hasValue) && !
|
|
432
|
+
}, null, 8, ["size", "class"])) : unref(hasValue) && !isDisabled.value && !__props.readonly ? (openBlock(), createBlock(Button_default, {
|
|
432
433
|
key: 1,
|
|
433
434
|
variant: "text",
|
|
434
435
|
size: "xs",
|
|
@@ -461,10 +462,11 @@ var SearchInput_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
461
462
|
highlighted: highlightedIdx.value,
|
|
462
463
|
select: selectResult,
|
|
463
464
|
close: unref(closePopover)
|
|
464
|
-
}, () => [__props.loading ? (openBlock(), createElementBlock("div", _hoisted_5, [renderSlot(_ctx.$slots, "loading", {}, () => [createVNode(Loader_default, { size: "small" })])])) : !resultItems.value.length ? (openBlock(), createElementBlock("div", _hoisted_6, [renderSlot(_ctx.$slots, "empty", {}, () => [createTextVNode(toDisplayString(__props.emptyText), 1)])])) : (openBlock(), createElementBlock("ul", {
|
|
465
|
+
}, () => [__props.loading && !resultItems.value.length ? (openBlock(), createElementBlock("div", _hoisted_5, [renderSlot(_ctx.$slots, "loading", {}, () => [createVNode(Loader_default, { size: "small" })])])) : !resultItems.value.length ? (openBlock(), createElementBlock("div", _hoisted_6, [renderSlot(_ctx.$slots, "empty", {}, () => [createTextVNode(toDisplayString(__props.emptyText), 1)])])) : (openBlock(), createElementBlock("ul", {
|
|
465
466
|
key: 2,
|
|
466
467
|
id: `${unref(fieldId)}-results`,
|
|
467
468
|
role: "listbox",
|
|
469
|
+
"aria-busy": __props.loading || void 0,
|
|
468
470
|
class: "flex flex-col"
|
|
469
471
|
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(renderRows.value, (row) => {
|
|
470
472
|
return openBlock(), createElementBlock(Fragment, { key: row.key }, [row.kind === "header" ? (openBlock(), createElementBlock("li", _hoisted_8, toDisplayString(row.label), 1)) : (openBlock(), createElementBlock("li", {
|
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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B,IAAI,KAAK,YAAA,WAAA,EADnB,mBAI+B,QAJ/B,aAI+B,gBAA3B,IAAI,KAAK,SAAQ,EAAA,EAAA,IAAA,mBAAA,IAAA,KAAA;;;;;;;;;;;;;;;;;;IAW3C,QAAA,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.value?.blur(), \n select: () => inputRef.value?.select(), \n clear: onClear, \n inputRef, \n}); \n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4PA,MAAM,MAAM,eAAe;EAC3B,MAAM,QAAQ,UAAU;EAExB,MAAM,OAAO;EAcb,MAAM,QAAQ;EAeO,sBAAsB,MAAM,KAAK;EACtD,MAAM,KAAK,oBAAoB,MAAM,KAAK;EAE1C,MAAM,WAAW,IAA6B,KAAK;EACnD,MAAM,UAAU,IAAI,MAAM;EAE1B,MAAM,EACF,SACA,QACA,YACA,UACA,UACA,eACA,sBACA,iBACA,SACA,UACA,WACA,gBACA,cAAc,OAAO;GAAE,eAAe;GAAe,UAAU;GAAe,CAAC;EAEnF,MAAM,EAAE,uBAAuB,kBAAkB,gBAAgB;GAC7D,eAAe,MAAM;GACrB;GACA;GACA;GACA,YAAY,MAAM;GACrB,CAAC;EAQF,MAAM,aAAa,eAAe,CAAC,CAAC,MAAM,SAAS;EAEnD,MAAM,sBAAsB,eAAe,+BAA+B,WAAW,UAAU,wBAAwB;EACvH,MAAM,wBAAwB,eAAe,iCAAiC,WAAW,UAAU,8CAA8C;EAGjJ,MAAM,iBAAiB,wBAAwB,MAAM,OAAO;EAI5D,MAAM,cAAc,eAAe,MAAM,UAAU,KAAA,KAAa,CAAC,CAAC,MAAM,QAAQ;EAChF,MAAM,cAAc,eAAmC,MAAM,SAAS,EAAE,CAAC;EAEzE,MAAM,iBAAiB,IAAI,GAAG;EAC9B,MAAM,EACF,Y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