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.
Files changed (135) hide show
  1. package/dist/components/data-display/calendar/AgendaView.cjs.map +1 -1
  2. package/dist/components/data-display/calendar/AgendaView.mjs.map +1 -1
  3. package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.cjs +11 -6
  4. package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  5. package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.mjs +18 -13
  6. package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  7. package/dist/components/data-display/calendar/Calendar.vue_vue_type_script_setup_true_lang.mjs +4 -4
  8. package/dist/components/data-display/calendar/Calendar.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  9. package/dist/components/data-display/calendar/DayView.cjs.map +1 -1
  10. package/dist/components/data-display/calendar/DayView.mjs.map +1 -1
  11. package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.cjs +14 -9
  12. package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  13. package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.mjs +22 -17
  14. package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  15. package/dist/components/data-display/calendar/MonthView.cjs +1 -1
  16. package/dist/components/data-display/calendar/MonthView.cjs.map +1 -1
  17. package/dist/components/data-display/calendar/MonthView.mjs +1 -1
  18. package/dist/components/data-display/calendar/MonthView.mjs.map +1 -1
  19. package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.cjs +15 -17
  20. package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  21. package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.mjs +18 -20
  22. package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  23. package/dist/components/data-display/calendar/Scheduler.cjs.map +1 -1
  24. package/dist/components/data-display/calendar/Scheduler.mjs.map +1 -1
  25. package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.cjs +14 -9
  26. package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  27. package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.mjs +22 -17
  28. package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  29. package/dist/components/data-display/calendar/WeekView.cjs.map +1 -1
  30. package/dist/components/data-display/calendar/WeekView.mjs.map +1 -1
  31. package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.cjs +14 -9
  32. package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  33. package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.mjs +22 -17
  34. package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  35. package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.mjs +3 -3
  36. package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  37. package/dist/components/data-display/date-picker/DateTimePicker.cjs.map +1 -1
  38. package/dist/components/data-display/date-picker/DateTimePicker.mjs.map +1 -1
  39. package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.cjs +1 -1
  40. package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  41. package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.mjs +3 -3
  42. package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  43. package/dist/components/feedback/Banner.vue_vue_type_script_setup_true_lang.mjs +4 -4
  44. package/dist/components/feedback/Banner.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  45. package/dist/components/feedback/Drawer.cjs.map +1 -1
  46. package/dist/components/feedback/Drawer.mjs.map +1 -1
  47. package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.cjs +4 -9
  48. package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  49. package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.mjs +9 -14
  50. package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  51. package/dist/components/feedback/Modal.cjs.map +1 -1
  52. package/dist/components/feedback/Modal.mjs.map +1 -1
  53. package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.cjs +4 -9
  54. package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  55. package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.mjs +9 -14
  56. package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  57. package/dist/components/feedback/Tooltip.cjs.map +1 -1
  58. package/dist/components/feedback/Tooltip.mjs.map +1 -1
  59. package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.cjs +44 -17
  60. package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  61. package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.mjs +44 -17
  62. package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  63. package/dist/components/forms/Combobox.cjs.map +1 -1
  64. package/dist/components/forms/Combobox.mjs.map +1 -1
  65. package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.cjs +2 -2
  66. package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  67. package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.mjs +2 -2
  68. package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  69. package/dist/components/forms/PhoneInput.cjs.map +1 -1
  70. package/dist/components/forms/PhoneInput.mjs.map +1 -1
  71. package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.cjs +6 -1
  72. package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  73. package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.mjs +6 -1
  74. package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  75. package/dist/components/forms/SearchInput.cjs.map +1 -1
  76. package/dist/components/forms/SearchInput.mjs.map +1 -1
  77. package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.cjs +8 -6
  78. package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  79. package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.mjs +8 -6
  80. package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  81. package/dist/components/layout/PopoverPanel.cjs +1 -1
  82. package/dist/components/layout/PopoverPanel.cjs.map +1 -1
  83. package/dist/components/layout/PopoverPanel.mjs +1 -1
  84. package/dist/components/layout/PopoverPanel.mjs.map +1 -1
  85. package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.cjs +2 -2
  86. package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  87. package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.mjs +2 -2
  88. package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  89. package/dist/components/navigation/Switcher.cjs.map +1 -1
  90. package/dist/components/navigation/Switcher.mjs.map +1 -1
  91. package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.cjs +38 -40
  92. package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  93. package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.mjs +38 -40
  94. package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  95. package/dist/composables/eventColors.cjs +51 -27
  96. package/dist/composables/eventColors.cjs.map +1 -1
  97. package/dist/composables/eventColors.mjs +51 -27
  98. package/dist/composables/eventColors.mjs.map +1 -1
  99. package/dist/composables/useBodyScrollLock.cjs +44 -0
  100. package/dist/composables/useBodyScrollLock.cjs.map +1 -0
  101. package/dist/composables/useBodyScrollLock.mjs +43 -0
  102. package/dist/composables/useBodyScrollLock.mjs.map +1 -0
  103. package/dist/composables/useCalendarTheme.cjs +29 -8
  104. package/dist/composables/useCalendarTheme.cjs.map +1 -1
  105. package/dist/composables/useCalendarTheme.mjs +29 -8
  106. package/dist/composables/useCalendarTheme.mjs.map +1 -1
  107. package/dist/composables/usePopover.cjs +44 -12
  108. package/dist/composables/usePopover.cjs.map +1 -1
  109. package/dist/composables/usePopover.mjs +44 -12
  110. package/dist/composables/usePopover.mjs.map +1 -1
  111. package/dist/mood-ui.css +9 -9
  112. package/dist/types/composables/eventColors.d.ts +2 -2
  113. package/dist/types/composables/useBodyScrollLock.d.ts +19 -0
  114. package/dist/types/composables/useCalendarTheme.d.ts +2 -0
  115. package/dist/types/interfaces/data-display/calendar/AgendaView.interface.d.ts +5 -0
  116. package/dist/types/interfaces/data-display/calendar/DayView.interface.d.ts +5 -0
  117. package/dist/types/interfaces/data-display/calendar/MonthView.interface.d.ts +5 -0
  118. package/dist/types/interfaces/data-display/calendar/Scheduler.interface.d.ts +5 -0
  119. package/dist/types/interfaces/data-display/calendar/WeekView.interface.d.ts +5 -0
  120. package/dist/types/utils/calendarTooltip.d.ts +13 -0
  121. package/dist/types/utils/cssLength.d.ts +5 -0
  122. package/dist/types/utils/tooltipArrow.d.ts +34 -0
  123. package/dist/utils/calendarTooltip.cjs +18 -0
  124. package/dist/utils/calendarTooltip.cjs.map +1 -0
  125. package/dist/utils/calendarTooltip.mjs +18 -0
  126. package/dist/utils/calendarTooltip.mjs.map +1 -0
  127. package/dist/utils/cssLength.cjs +13 -0
  128. package/dist/utils/cssLength.cjs.map +1 -0
  129. package/dist/utils/cssLength.mjs +13 -0
  130. package/dist/utils/cssLength.mjs.map +1 -0
  131. package/dist/utils/tooltipArrow.cjs +37 -0
  132. package/dist/utils/tooltipArrow.cjs.map +1 -0
  133. package/dist/utils/tooltipArrow.mjs +36 -0
  134. package/dist/utils/tooltipArrow.mjs.map +1 -0
  135. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Combobox.mjs","names":[],"sources":["../../../src/components/forms/Combobox.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\"\n >*</span\n >\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 role=\"combobox\"\n :aria-haspopup=\"'listbox'\"\n :aria-expanded=\"isOpen\"\n :aria-controls=\"listboxId\"\n :aria-owns=\"listboxId\"\n >\n <component\n :is=\"iconLeft\"\n v-if=\"iconLeft\"\n aria-hidden=\"true\"\n :class=\"['shrink-0', affordanceIconClass, iconSizeClasses]\"\n />\n\n <input\n :id=\"fieldId\"\n ref=\"inputEl\"\n type=\"text\"\n role=\"combobox\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n :value=\"modelValue ?? ''\"\n :placeholder=\"placeholder\"\n :disabled=\"isDisabled\"\n :readonly=\"readonly\"\n :required=\"required\"\n :name=\"name\"\n :autofocus=\"autofocus\"\n :maxlength=\"maxLength\"\n :aria-label=\"!label ? ariaLabel : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-describedby=\"describedBy\"\n :aria-required=\"required || undefined\"\n :aria-autocomplete=\"'list'\"\n :aria-controls=\"listboxId\"\n :aria-expanded=\"isOpen\"\n :aria-activedescendant=\"isOpen && activeId ? activeId : 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 @focus=\"onFocus\"\n @blur=\"onBlur\"\n @keydown=\"onKeydown\"\n />\n\n <Loader\n v-if=\"loading || isLoadingAsync\"\n :size=\"size === 'large' ? 'medium' : 'small'\"\n :class=\"['shrink-0', affordanceIconClass]\"\n />\n\n <Button\n v-else-if=\"clearable && hasValue && !isDisabled && !readonly\"\n variant=\"text\"\n size=\"xs\"\n radius=\"full\"\n :icon=\"XMarkIcon\"\n :ariaLabel=\"loc.combobox.clear\"\n tabindex=\"-1\"\n :class=\"['shrink-0', affordanceActionClass]\"\n @click=\"clear\"\n />\n\n <Button\n variant=\"text\"\n size=\"xs\"\n radius=\"full\"\n :icon=\"ChevronDownIcon\"\n :ariaLabel=\"loc.combobox.toggleOptions\"\n tabindex=\"-1\"\n :class=\"[\n 'shrink-0',\n affordanceActionClass,\n 'transition-transform duration-base ease-standard',\n isOpen ? 'rotate-180' : '',\n ]\"\n @mousedown.prevent\n @click=\"onToggleClick\"\n />\n </div>\n\n <PopoverPanel\n :open=\"isOpen\"\n :style=\"panelStyle\"\n :radius=\"radius\"\n role=\"listbox\"\n :labelledBy=\"label ? fieldId : undefined\"\n @update:panelRef=\"panelRef = $event\"\n >\n <div class=\"flex flex-col max-h-72\">\n <ul\n :id=\"listboxId\"\n role=\"listbox\"\n class=\"modo-stagger flex-1 overflow-y-auto\"\n tabindex=\"-1\"\n >\n <li\n v-if=\"isLoadingAsync && displayedOptions.length === 0\"\n class=\"px-3 py-4 text-caption text-muted-foreground text-center\"\n >\n {{ loadingText }}\n </li>\n <li\n v-else-if=\"displayedOptions.length === 0\"\n class=\"px-3 py-4 text-caption text-muted-foreground text-center\"\n >\n {{ emptyText }}\n </li>\n\n <template\n v-for=\"(group, gi) in groupedOptions\"\n :key=\"group.name ?? gi\"\n >\n <li\n v-if=\"group.name\"\n class=\"px-3 pt-2 pb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground\"\n role=\"presentation\"\n >\n {{ group.name }}\n </li>\n <li\n v-for=\"opt in group.items\"\n :id=\"optionDomId(String(opt.value))\"\n :key=\"String(opt.value)\"\n role=\"option\"\n :aria-selected=\"matchedOption?.value === opt.value\"\n :aria-disabled=\"opt.disabled || undefined\"\n :class=\"[\n 'flex items-center gap-2 px-3 py-2 text-body cursor-pointer select-none',\n 'transition-colors duration-fast ease-standard',\n opt.disabled\n ? 'text-muted-foreground/60 cursor-not-allowed'\n : ['text-foreground', optionHover],\n activeValue === opt.value && !opt.disabled ? optionSurface : '',\n matchedOption?.value === opt.value ? 'font-medium' : '',\n ]\"\n @pointerenter=\"setActive(opt.value)\"\n @mousedown.prevent\n @touchstart.prevent\n @click=\"selectOption(opt)\"\n >\n <component\n :is=\"opt.icon\"\n v-if=\"opt.icon\"\n aria-hidden=\"true\"\n :class=\"['w-4 h-4 shrink-0', affordanceIconClass]\"\n />\n <div class=\"flex-1 min-w-0\">\n <div class=\"truncate\">\n <Highlight :text=\"opt.label\" :query=\"modelValue ?? ''\" />\n </div>\n <div\n v-if=\"opt.description\"\n class=\"text-caption text-muted-foreground truncate\"\n >\n {{ opt.description }}\n </div>\n </div>\n <CheckIcon\n v-if=\"matchedOption?.value === opt.value\"\n :class=\"['w-4 h-4 shrink-0', checkColorClass]\"\n aria-hidden=\"true\"\n />\n </li>\n </template>\n </ul>\n <slot name=\"footer\" />\n </div>\n </PopoverPanel>\n\n <div\n v-if=\"errorText || helperText || showCounterEffective\"\n class=\"flex items-start 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 class=\"flex-1\"\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 class=\"flex-1\"\n >\n {{ helperText }}\n </Typography>\n <p\n v-if=\"showCounterEffective\"\n :id=\"counterId\"\n :class=\"[\n 'text-caption ml-auto tabular-nums',\n counterOverflow ? 'text-destructive' : 'text-muted-foreground',\n ]\"\n >\n {{ currentLength }}/{{ maxLength }}\n </p>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, defineComponent, h, nextTick, ref, useId, watch } from \"vue\";\nimport type {\n Combobox as ComboboxProps,\n SelectOption,\n} from \"../../interfaces/forms/Combobox.interface\";\nimport {\n useFieldState,\n useFieldClasses,\n FIELD_AFFORDANCE_ACTION_BY_COLOR,\n FIELD_AFFORDANCE_ICON_BY_COLOR,\n} from \"../../composables/useField\";\nimport { usePopover } from \"../../composables/usePopover\";\nimport PopoverPanel from \"../layout/PopoverPanel.vue\";\nimport Typography from \"../data-display/Typography.vue\";\nimport Loader from \"../feedback/Loader.vue\";\nimport {\n ChevronDownIcon,\n XMarkIcon,\n CheckIcon,\n} from \"@heroicons/vue/24/outline\";\nimport Button from \"./Button.vue\";\nimport {\n useModoLocale,\n useSizeTokens,\n} from \"../../composables/useModoConfig\";\n\nconst loc = useModoLocale();\n\nconst props = withDefaults(defineProps<ComboboxProps>(), {\n modelValue: \"\",\n options: () => [],\n debounce: 250,\n minChars: 0,\n freeSolo: false,\n variant: \"outline\",\n color: \"default\",\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n clearable: false,\n placeholder: \"Type to search…\",\n emptyText: \"No results.\",\n loadingText: \"Loading…\",\n autofocus: false,\n});\n\nconst sz = useSizeTokens(() => props.size);\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: string];\n change: [value: string, option: SelectOption | null];\n select: [option: SelectOption];\n open: [];\n close: [];\n clear: [];\n search: [query: string];\n}>();\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, {\n componentName: \"Combobox\",\n idPrefix: \"modo-combobox\",\n});\n\nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({\n variant: () => props.variant,\n stateColor,\n hasError,\n radius,\n forceFocus: () => isOpen.value,\n halo: () => props.halo,\n});\n\n/* ---------- IDs ---------- */\nconst autoListboxId = useId();\nconst listboxId = computed(() => `modo-combobox-listbox-${autoListboxId}`);\nconst optionDomId = (v: string) => `${listboxId.value}-opt-${v}`;\n\n/* ---------- Options source (sync or async) ---------- */\n\nconst asyncOptions = ref<SelectOption[]>([]);\nconst isLoadingAsync = ref(false);\nlet loadTimer: number | null = null;\nlet loadRequestId = 0;\n\nwatch(\n () => props.modelValue,\n (q) => {\n if (!props.loadOptions) return;\n if (!isOpen.value) return;\n if ((q ?? \"\").length < props.minChars) {\n asyncOptions.value = [];\n return;\n }\n if (loadTimer !== null) clearTimeout(loadTimer);\n isLoadingAsync.value = true;\n const reqId = ++loadRequestId;\n loadTimer = window.setTimeout(async () => {\n try {\n const result = await props.loadOptions!(q ?? \"\");\n if (reqId === loadRequestId) asyncOptions.value = result;\n } finally {\n if (reqId === loadRequestId) isLoadingAsync.value = false;\n }\n emit(\"search\", q ?? \"\");\n }, props.debounce);\n },\n);\n\nconst sourceOptions = computed(() =>\n props.loadOptions ? asyncOptions.value : props.options,\n);\n\nconst displayedOptions = computed(() => {\n const q = (props.modelValue ?? \"\").trim().toLowerCase();\n // Si hay loadOptions, no filtramos localmente (confiamos en el backend).\n if (props.loadOptions) return sourceOptions.value;\n if (!q) return sourceOptions.value;\n return sourceOptions.value.filter(\n (o) =>\n o.label.toLowerCase().includes(q) ||\n (o.description ? o.description.toLowerCase().includes(q) : false),\n );\n});\n\ninterface OptionGroup {\n name?: string;\n items: SelectOption[];\n}\n\nconst groupedOptions = computed<OptionGroup[]>(() => {\n const list = displayedOptions.value;\n if (!list.some((o) => o.group)) {\n return list.length ? [{ items: list }] : [];\n }\n const map = new Map<string | undefined, SelectOption[]>();\n for (const opt of list) {\n const key = opt.group;\n if (!map.has(key)) map.set(key, []);\n map.get(key)!.push(opt);\n }\n const groups: OptionGroup[] = [];\n for (const [name, items] of map) groups.push({ name, items });\n return groups;\n});\n\nconst flatOptions = computed<SelectOption[]>(() =>\n groupedOptions.value.flatMap((g) => g.items),\n);\n\n/** Si el texto actual coincide exactamente (case-insensitive) con alguna opción, la devuelve. */\nconst matchedOption = computed<SelectOption | null>(() => {\n const v = (props.modelValue ?? \"\").trim().toLowerCase();\n if (!v) return null;\n return sourceOptions.value.find((o) => o.label.toLowerCase() === v) ?? null;\n});\n\n/* ---------- Color ---------- */\nconst CHECK_COLOR_BY_STATE: Record<string, string> = {\n default: \"text-foreground\",\n primary: \"text-primary\",\n danger: \"text-destructive\",\n success: \"text-success\",\n warning: \"text-warning\",\n};\nconst checkColorClass = computed(\n () => CHECK_COLOR_BY_STATE[stateColor.value] ?? \"text-foreground\",\n);\nconst affordanceIconClass = computed(\n () =>\n FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? \"text-muted-foreground\",\n);\nconst affordanceActionClass = computed(\n () =>\n FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ??\n \"text-muted-foreground hover:text-foreground\",\n);\n\nconst OPTION_SURFACE: Record<string, string> = {\n default: \"bg-muted\",\n primary: \"bg-primary/10\",\n danger: \"bg-destructive/10\",\n success: \"bg-success/10\",\n warning: \"bg-warning/10\",\n};\nconst OPTION_HOVER: Record<string, string> = {\n default: \"hover:bg-muted\",\n primary: \"hover:bg-primary/10\",\n danger: \"hover:bg-destructive/10\",\n success: \"hover:bg-success/10\",\n warning: \"hover:bg-warning/10\",\n};\nconst optionSurface = computed(\n () => OPTION_SURFACE[stateColor.value] ?? \"bg-muted\",\n);\nconst optionHover = computed(\n () => OPTION_HOVER[stateColor.value] ?? \"hover:bg-muted\",\n);\n\n/* ---------- Popover ---------- */\n\nconst inputEl = ref<HTMLInputElement | null>(null);\nconst wrapperEl = ref<HTMLElement | null>(null);\nconst activeValue = ref<string | number | null>(null);\nconst activeId = computed(() =>\n activeValue.value !== null ? optionDomId(String(activeValue.value)) : \"\",\n);\n\nconst {\n triggerRef,\n panelRef,\n isOpen,\n panelStyle,\n open: openPopover,\n close: closePopover,\n} = usePopover({\n placement: \"bottom-start\",\n matchTriggerWidth: true,\n onOpen: () => {\n emit(\"open\");\n const initial =\n matchedOption.value ?? flatOptions.value.find((o) => !o.disabled);\n activeValue.value = initial ? initial.value : null;\n nextTick(scrollActiveIntoView);\n },\n onClose: () => {\n emit(\"close\");\n },\n});\n\nwatch(wrapperEl, (el) => (triggerRef.value = el));\n\nfunction setActive(v: string | number) {\n activeValue.value = v;\n}\n\nfunction scrollActiveIntoView() {\n if (activeValue.value === null) return;\n const el = document.getElementById(optionDomId(String(activeValue.value)));\n el?.scrollIntoView({ block: \"nearest\" });\n}\n\n/* ---------- Actions ---------- */\n\nfunction onInput(e: Event) {\n const next = (e.target as HTMLInputElement).value;\n emit(\"update:modelValue\", next);\n if (!isOpen.value) openPopover();\n // Activar la primera opción tras filtrar\n nextTick(() => {\n const first = flatOptions.value.find((o) => !o.disabled);\n activeValue.value = first ? first.value : null;\n });\n}\n\nfunction onFocus() {\n if (isDisabled.value || props.readonly) return;\n if (!isOpen.value) openPopover();\n}\n\nfunction onBlur() {\n // Delay para permitir el click en la opción (mousedown.prevent también ayuda).\n setTimeout(() => {\n // Si no es freeSolo y no hay match, resetea al último match válido (o vacío)\n if (!props.freeSolo) {\n const current = (props.modelValue ?? \"\").trim();\n if (current && !matchedOption.value) {\n // Revertir al label de la opción previa si había una\n emit(\"update:modelValue\", lastCommittedValue.value);\n }\n }\n closePopover();\n }, 120);\n}\n\nfunction onToggleClick() {\n if (isDisabled.value || props.readonly) return;\n if (isOpen.value) {\n closePopover();\n inputEl.value?.blur();\n } else {\n inputEl.value?.focus();\n }\n}\n\nconst lastCommittedValue = ref<string>(props.modelValue ?? \"\");\n\nfunction commit(value: string, opt: SelectOption | null) {\n lastCommittedValue.value = value;\n emit(\"update:modelValue\", value);\n emit(\"change\", value, opt);\n}\n\nfunction selectOption(opt: SelectOption) {\n if (opt.disabled) return;\n commit(opt.label, opt);\n emit(\"select\", opt);\n closePopover();\n inputEl.value?.blur();\n}\n\nfunction clear() {\n commit(\"\", null);\n emit(\"clear\");\n inputEl.value?.focus();\n}\n\n/* ---------- Keyboard ---------- */\n\nfunction moveActive(direction: 1 | -1) {\n const list = flatOptions.value.filter((o) => !o.disabled);\n if (list.length === 0) return;\n const currentIdx = list.findIndex((o) => o.value === activeValue.value);\n let nextIdx: number;\n if (currentIdx === -1) {\n nextIdx = direction > 0 ? 0 : list.length - 1;\n } else {\n nextIdx = (currentIdx + direction + list.length) % list.length;\n }\n activeValue.value = list[nextIdx].value;\n scrollActiveIntoView();\n}\n\nfunction onKeydown(e: KeyboardEvent) {\n if (isDisabled.value || props.readonly) return;\n switch (e.key) {\n case \"ArrowDown\":\n e.preventDefault();\n if (!isOpen.value) openPopover();\n moveActive(1);\n break;\n case \"ArrowUp\":\n e.preventDefault();\n if (!isOpen.value) openPopover();\n moveActive(-1);\n break;\n case \"Enter\": {\n if (!isOpen.value) return;\n const opt = flatOptions.value.find((o) => o.value === activeValue.value);\n if (opt && !opt.disabled) {\n e.preventDefault();\n selectOption(opt);\n } else if (props.freeSolo) {\n e.preventDefault();\n commit(props.modelValue ?? \"\", null);\n // Keep panel open so the user sees the new value added to the list.\n // closePopover();\n }\n break;\n }\n case \"Escape\":\n if (isOpen.value) {\n e.preventDefault();\n closePopover();\n }\n break;\n case \"Tab\":\n // Dejar que Tab cierre naturalmente vía blur.\n break;\n }\n}\n\n/* ---------- Size maps ---------- */\n\nconst wrapperSizeClasses = computed(() => `${sz.value.control} ${sz.value.padX}`);\nconst inputTextClasses = computed(() => sz.value.text);\nconst iconSizeClasses = computed(() => sz.value.icon);\n\n/* ---------- Inline highlight helper ---------- */\nconst Highlight = defineComponent({\n name: \"ComboboxHighlight\",\n props: {\n text: { type: String, required: true },\n query: { type: String, required: true },\n },\n setup(p) {\n return () => {\n const q = (p.query ?? \"\").trim();\n if (!q) return h(\"span\", p.text);\n const idx = p.text.toLowerCase().indexOf(q.toLowerCase());\n if (idx === -1) return h(\"span\", p.text);\n const before = p.text.slice(0, idx);\n const match = p.text.slice(idx, idx + q.length);\n const after = p.text.slice(idx + q.length);\n return h(\"span\", [\n before,\n h(\n \"span\",\n {\n class:\n \"font-semibold text-foreground bg-primary/10 rounded-sm px-0.5\",\n },\n match,\n ),\n after,\n ]);\n };\n },\n});\n\n/* ---------- Sync committed value when controlling v-model externally ---------- */\nwatch(\n () => props.modelValue,\n (v) => {\n if (matchedOption.value) lastCommittedValue.value = v ?? \"\";\n },\n);\n</script>\n"],"mappings":""}
1
+ {"version":3,"file":"Combobox.mjs","names":[],"sources":["../../../src/components/forms/Combobox.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\"\n >*</span\n >\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 role=\"combobox\"\n :aria-haspopup=\"'listbox'\"\n :aria-expanded=\"isOpen\"\n :aria-controls=\"listboxId\"\n :aria-owns=\"listboxId\"\n >\n <component\n :is=\"iconLeft\"\n v-if=\"iconLeft\"\n aria-hidden=\"true\"\n :class=\"['shrink-0', affordanceIconClass, iconSizeClasses]\"\n />\n\n <input\n :id=\"fieldId\"\n ref=\"inputEl\"\n type=\"text\"\n role=\"combobox\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n :value=\"modelValue ?? ''\"\n :placeholder=\"placeholder\"\n :disabled=\"isDisabled\"\n :readonly=\"readonly\"\n :required=\"required\"\n :name=\"name\"\n :autofocus=\"autofocus\"\n :maxlength=\"maxLength\"\n :aria-label=\"!label ? ariaLabel : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-describedby=\"describedBy\"\n :aria-required=\"required || undefined\"\n :aria-autocomplete=\"'list'\"\n :aria-controls=\"listboxId\"\n :aria-expanded=\"isOpen\"\n :aria-activedescendant=\"isOpen && activeId ? activeId : 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 @focus=\"onFocus\"\n @blur=\"onBlur\"\n @keydown=\"onKeydown\"\n />\n\n <Loader\n v-if=\"loading || isLoadingAsync\"\n :size=\"size === 'large' ? 'medium' : 'small'\"\n :class=\"['shrink-0', affordanceIconClass]\"\n />\n\n <Button\n v-else-if=\"clearable && hasValue && !isDisabled && !readonly\"\n variant=\"text\"\n size=\"xs\"\n radius=\"full\"\n :icon=\"XMarkIcon\"\n :ariaLabel=\"loc.combobox.clear\"\n tabindex=\"-1\"\n :class=\"['shrink-0', affordanceActionClass]\"\n @click=\"clear\"\n />\n\n <Button\n variant=\"text\"\n size=\"xs\"\n radius=\"full\"\n :icon=\"ChevronDownIcon\"\n :ariaLabel=\"loc.combobox.toggleOptions\"\n tabindex=\"-1\"\n :class=\"[\n 'shrink-0',\n affordanceActionClass,\n 'transition-transform duration-base ease-standard',\n isOpen ? 'rotate-180' : '',\n ]\"\n @mousedown.prevent\n @click=\"onToggleClick\"\n />\n </div>\n\n <PopoverPanel\n :open=\"isOpen\"\n :style=\"panelStyle\"\n :radius=\"radius\"\n role=\"listbox\"\n :labelledBy=\"label ? fieldId : undefined\"\n @update:panelRef=\"panelRef = $event\"\n >\n <div class=\"flex flex-col max-h-72\">\n <ul\n :id=\"listboxId\"\n role=\"listbox\"\n class=\"modo-stagger flex-1 overflow-y-auto\"\n tabindex=\"-1\"\n >\n <li\n v-if=\"isLoadingAsync && displayedOptions.length === 0\"\n class=\"px-3 py-4 text-caption text-muted-foreground text-center\"\n >\n {{ loadingText }}\n </li>\n <li\n v-else-if=\"displayedOptions.length === 0\"\n class=\"px-3 py-4 text-caption text-muted-foreground text-center\"\n >\n {{ emptyText }}\n </li>\n\n <template\n v-for=\"(group, gi) in groupedOptions\"\n :key=\"group.name ?? gi\"\n >\n <li\n v-if=\"group.name\"\n class=\"px-3 pt-2 pb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground\"\n role=\"presentation\"\n >\n {{ group.name }}\n </li>\n <!--\n `mousedown.prevent` keeps focus in the input while an option is\n picked. There is deliberately no `touchstart.prevent` alongside\n it: cancelling touchstart tells the browser to suppress the\n compatibility mouse events *and* the click for that tap, so on a\n touch device the option became impossible to select at all.\n -->\n <li\n v-for=\"opt in group.items\"\n :id=\"optionDomId(String(opt.value))\"\n :key=\"String(opt.value)\"\n role=\"option\"\n :aria-selected=\"matchedOption?.value === opt.value\"\n :aria-disabled=\"opt.disabled || undefined\"\n :class=\"[\n 'flex items-center gap-2 px-3 py-2 text-body cursor-pointer select-none',\n 'transition-colors duration-fast ease-standard',\n opt.disabled\n ? 'text-muted-foreground/60 cursor-not-allowed'\n : ['text-foreground', optionHover],\n activeValue === opt.value && !opt.disabled ? optionSurface : '',\n matchedOption?.value === opt.value ? 'font-medium' : '',\n ]\"\n @pointerenter=\"setActive(opt.value)\"\n @mousedown.prevent\n @click=\"selectOption(opt)\"\n >\n <component\n :is=\"opt.icon\"\n v-if=\"opt.icon\"\n aria-hidden=\"true\"\n :class=\"['w-4 h-4 shrink-0', affordanceIconClass]\"\n />\n <div class=\"flex-1 min-w-0\">\n <div class=\"truncate\">\n <Highlight :text=\"opt.label\" :query=\"modelValue ?? ''\" />\n </div>\n <div\n v-if=\"opt.description\"\n class=\"text-caption text-muted-foreground truncate\"\n >\n {{ opt.description }}\n </div>\n </div>\n <CheckIcon\n v-if=\"matchedOption?.value === opt.value\"\n :class=\"['w-4 h-4 shrink-0', checkColorClass]\"\n aria-hidden=\"true\"\n />\n </li>\n </template>\n </ul>\n <slot name=\"footer\" />\n </div>\n </PopoverPanel>\n\n <div\n v-if=\"errorText || helperText || showCounterEffective\"\n class=\"flex items-start 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 class=\"flex-1\"\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 class=\"flex-1\"\n >\n {{ helperText }}\n </Typography>\n <p\n v-if=\"showCounterEffective\"\n :id=\"counterId\"\n :class=\"[\n 'text-caption ml-auto tabular-nums',\n counterOverflow ? 'text-destructive' : 'text-muted-foreground',\n ]\"\n >\n {{ currentLength }}/{{ maxLength }}\n </p>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, defineComponent, h, nextTick, ref, useId, watch } from \"vue\";\nimport type {\n Combobox as ComboboxProps,\n SelectOption,\n} from \"../../interfaces/forms/Combobox.interface\";\nimport {\n useFieldState,\n useFieldClasses,\n FIELD_AFFORDANCE_ACTION_BY_COLOR,\n FIELD_AFFORDANCE_ICON_BY_COLOR,\n} from \"../../composables/useField\";\nimport { usePopover } from \"../../composables/usePopover\";\nimport PopoverPanel from \"../layout/PopoverPanel.vue\";\nimport Typography from \"../data-display/Typography.vue\";\nimport Loader from \"../feedback/Loader.vue\";\nimport {\n ChevronDownIcon,\n XMarkIcon,\n CheckIcon,\n} from \"@heroicons/vue/24/outline\";\nimport Button from \"./Button.vue\";\nimport {\n useModoLocale,\n useSizeTokens,\n} from \"../../composables/useModoConfig\";\n\nconst loc = useModoLocale();\n\nconst props = withDefaults(defineProps<ComboboxProps>(), {\n modelValue: \"\",\n options: () => [],\n debounce: 250,\n minChars: 0,\n freeSolo: false,\n variant: \"outline\",\n color: \"default\",\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n clearable: false,\n placeholder: \"Type to search…\",\n emptyText: \"No results.\",\n loadingText: \"Loading…\",\n autofocus: false,\n});\n\nconst sz = useSizeTokens(() => props.size);\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: string];\n change: [value: string, option: SelectOption | null];\n select: [option: SelectOption];\n open: [];\n close: [];\n clear: [];\n search: [query: string];\n}>();\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, {\n componentName: \"Combobox\",\n idPrefix: \"modo-combobox\",\n});\n\nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({\n variant: () => props.variant,\n stateColor,\n hasError,\n radius,\n forceFocus: () => isOpen.value,\n halo: () => props.halo,\n});\n\n/* ---------- IDs ---------- */\nconst autoListboxId = useId();\nconst listboxId = computed(() => `modo-combobox-listbox-${autoListboxId}`);\nconst optionDomId = (v: string) => `${listboxId.value}-opt-${v}`;\n\n/* ---------- Options source (sync or async) ---------- */\n\nconst asyncOptions = ref<SelectOption[]>([]);\nconst isLoadingAsync = ref(false);\nlet loadTimer: number | null = null;\nlet loadRequestId = 0;\n\nwatch(\n () => props.modelValue,\n (q) => {\n if (!props.loadOptions) return;\n if (!isOpen.value) return;\n if ((q ?? \"\").length < props.minChars) {\n asyncOptions.value = [];\n return;\n }\n if (loadTimer !== null) clearTimeout(loadTimer);\n isLoadingAsync.value = true;\n const reqId = ++loadRequestId;\n loadTimer = window.setTimeout(async () => {\n try {\n const result = await props.loadOptions!(q ?? \"\");\n if (reqId === loadRequestId) asyncOptions.value = result;\n } finally {\n if (reqId === loadRequestId) isLoadingAsync.value = false;\n }\n emit(\"search\", q ?? \"\");\n }, props.debounce);\n },\n);\n\nconst sourceOptions = computed(() =>\n props.loadOptions ? asyncOptions.value : props.options,\n);\n\nconst displayedOptions = computed(() => {\n const q = (props.modelValue ?? \"\").trim().toLowerCase();\n // Si hay loadOptions, no filtramos localmente (confiamos en el backend).\n if (props.loadOptions) return sourceOptions.value;\n if (!q) return sourceOptions.value;\n return sourceOptions.value.filter(\n (o) =>\n o.label.toLowerCase().includes(q) ||\n (o.description ? o.description.toLowerCase().includes(q) : false),\n );\n});\n\ninterface OptionGroup {\n name?: string;\n items: SelectOption[];\n}\n\nconst groupedOptions = computed<OptionGroup[]>(() => {\n const list = displayedOptions.value;\n if (!list.some((o) => o.group)) {\n return list.length ? [{ items: list }] : [];\n }\n const map = new Map<string | undefined, SelectOption[]>();\n for (const opt of list) {\n const key = opt.group;\n if (!map.has(key)) map.set(key, []);\n map.get(key)!.push(opt);\n }\n const groups: OptionGroup[] = [];\n for (const [name, items] of map) groups.push({ name, items });\n return groups;\n});\n\nconst flatOptions = computed<SelectOption[]>(() =>\n groupedOptions.value.flatMap((g) => g.items),\n);\n\n/** Si el texto actual coincide exactamente (case-insensitive) con alguna opción, la devuelve. */\nconst matchedOption = computed<SelectOption | null>(() => {\n const v = (props.modelValue ?? \"\").trim().toLowerCase();\n if (!v) return null;\n return sourceOptions.value.find((o) => o.label.toLowerCase() === v) ?? null;\n});\n\n/* ---------- Color ---------- */\nconst CHECK_COLOR_BY_STATE: Record<string, string> = {\n default: \"text-foreground\",\n primary: \"text-primary\",\n danger: \"text-destructive\",\n success: \"text-success\",\n warning: \"text-warning\",\n};\nconst checkColorClass = computed(\n () => CHECK_COLOR_BY_STATE[stateColor.value] ?? \"text-foreground\",\n);\nconst affordanceIconClass = computed(\n () =>\n FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? \"text-muted-foreground\",\n);\nconst affordanceActionClass = computed(\n () =>\n FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ??\n \"text-muted-foreground hover:text-foreground\",\n);\n\nconst OPTION_SURFACE: Record<string, string> = {\n default: \"bg-muted\",\n primary: \"bg-primary/10\",\n danger: \"bg-destructive/10\",\n success: \"bg-success/10\",\n warning: \"bg-warning/10\",\n};\nconst OPTION_HOVER: Record<string, string> = {\n default: \"hover:bg-muted\",\n primary: \"hover:bg-primary/10\",\n danger: \"hover:bg-destructive/10\",\n success: \"hover:bg-success/10\",\n warning: \"hover:bg-warning/10\",\n};\nconst optionSurface = computed(\n () => OPTION_SURFACE[stateColor.value] ?? \"bg-muted\",\n);\nconst optionHover = computed(\n () => OPTION_HOVER[stateColor.value] ?? \"hover:bg-muted\",\n);\n\n/* ---------- Popover ---------- */\n\nconst inputEl = ref<HTMLInputElement | null>(null);\nconst wrapperEl = ref<HTMLElement | null>(null);\nconst activeValue = ref<string | number | null>(null);\nconst activeId = computed(() =>\n activeValue.value !== null ? optionDomId(String(activeValue.value)) : \"\",\n);\n\nconst {\n triggerRef,\n panelRef,\n isOpen,\n panelStyle,\n open: openPopover,\n close: closePopover,\n} = usePopover({\n placement: \"bottom-start\",\n matchTriggerWidth: true,\n // Reposition on scroll instead of closing. Focus is what opens this panel,\n // and focusing a text field is itself a scroll trigger: on mobile the virtual\n // keyboard appears and the browser scrolls the field into view a few frames\n // after the panel opened, which closed the dropdown before the user could\n // ever see it. Typing reopened it — by then the keyboard was already up and\n // no further scroll followed — which is why the list only appeared after the\n // first keystroke. Same reasoning as SearchInput.\n closeOnScroll: false,\n onOpen: () => {\n emit(\"open\");\n const initial =\n matchedOption.value ?? flatOptions.value.find((o) => !o.disabled);\n activeValue.value = initial ? initial.value : null;\n nextTick(scrollActiveIntoView);\n },\n onClose: () => {\n emit(\"close\");\n },\n});\n\nwatch(wrapperEl, (el) => (triggerRef.value = el));\n\nfunction setActive(v: string | number) {\n activeValue.value = v;\n}\n\nfunction scrollActiveIntoView() {\n if (activeValue.value === null) return;\n const el = document.getElementById(optionDomId(String(activeValue.value)));\n el?.scrollIntoView({ block: \"nearest\" });\n}\n\n/* ---------- Actions ---------- */\n\nfunction onInput(e: Event) {\n const next = (e.target as HTMLInputElement).value;\n emit(\"update:modelValue\", next);\n if (!isOpen.value) openPopover();\n // Activar la primera opción tras filtrar\n nextTick(() => {\n const first = flatOptions.value.find((o) => !o.disabled);\n activeValue.value = first ? first.value : null;\n });\n}\n\nfunction onFocus() {\n if (isDisabled.value || props.readonly) return;\n if (!isOpen.value) openPopover();\n}\n\nfunction onBlur() {\n // Delay para permitir el click en la opción (mousedown.prevent también ayuda).\n setTimeout(() => {\n // Si no es freeSolo y no hay match, resetea al último match válido (o vacío)\n if (!props.freeSolo) {\n const current = (props.modelValue ?? \"\").trim();\n if (current && !matchedOption.value) {\n // Revertir al label de la opción previa si había una\n emit(\"update:modelValue\", lastCommittedValue.value);\n }\n }\n closePopover();\n }, 120);\n}\n\nfunction onToggleClick() {\n if (isDisabled.value || props.readonly) return;\n if (isOpen.value) {\n closePopover();\n inputEl.value?.blur();\n } else {\n inputEl.value?.focus();\n }\n}\n\nconst lastCommittedValue = ref<string>(props.modelValue ?? \"\");\n\nfunction commit(value: string, opt: SelectOption | null) {\n lastCommittedValue.value = value;\n emit(\"update:modelValue\", value);\n emit(\"change\", value, opt);\n}\n\nfunction selectOption(opt: SelectOption) {\n if (opt.disabled) return;\n commit(opt.label, opt);\n emit(\"select\", opt);\n closePopover();\n inputEl.value?.blur();\n}\n\nfunction clear() {\n commit(\"\", null);\n emit(\"clear\");\n inputEl.value?.focus();\n}\n\n/* ---------- Keyboard ---------- */\n\nfunction moveActive(direction: 1 | -1) {\n const list = flatOptions.value.filter((o) => !o.disabled);\n if (list.length === 0) return;\n const currentIdx = list.findIndex((o) => o.value === activeValue.value);\n let nextIdx: number;\n if (currentIdx === -1) {\n nextIdx = direction > 0 ? 0 : list.length - 1;\n } else {\n nextIdx = (currentIdx + direction + list.length) % list.length;\n }\n activeValue.value = list[nextIdx].value;\n scrollActiveIntoView();\n}\n\nfunction onKeydown(e: KeyboardEvent) {\n if (isDisabled.value || props.readonly) return;\n switch (e.key) {\n case \"ArrowDown\":\n e.preventDefault();\n if (!isOpen.value) openPopover();\n moveActive(1);\n break;\n case \"ArrowUp\":\n e.preventDefault();\n if (!isOpen.value) openPopover();\n moveActive(-1);\n break;\n case \"Enter\": {\n if (!isOpen.value) return;\n const opt = flatOptions.value.find((o) => o.value === activeValue.value);\n if (opt && !opt.disabled) {\n e.preventDefault();\n selectOption(opt);\n } else if (props.freeSolo) {\n e.preventDefault();\n commit(props.modelValue ?? \"\", null);\n // Keep panel open so the user sees the new value added to the list.\n // closePopover();\n }\n break;\n }\n case \"Escape\":\n if (isOpen.value) {\n e.preventDefault();\n closePopover();\n }\n break;\n case \"Tab\":\n // Dejar que Tab cierre naturalmente vía blur.\n break;\n }\n}\n\n/* ---------- Size maps ---------- */\n\nconst wrapperSizeClasses = computed(() => `${sz.value.control} ${sz.value.padX}`);\nconst inputTextClasses = computed(() => sz.value.text);\nconst iconSizeClasses = computed(() => sz.value.icon);\n\n/* ---------- Inline highlight helper ---------- */\nconst Highlight = defineComponent({\n name: \"ComboboxHighlight\",\n props: {\n text: { type: String, required: true },\n query: { type: String, required: true },\n },\n setup(p) {\n return () => {\n const q = (p.query ?? \"\").trim();\n if (!q) return h(\"span\", p.text);\n const idx = p.text.toLowerCase().indexOf(q.toLowerCase());\n if (idx === -1) return h(\"span\", p.text);\n const before = p.text.slice(0, idx);\n const match = p.text.slice(idx, idx + q.length);\n const after = p.text.slice(idx + q.length);\n return h(\"span\", [\n before,\n h(\n \"span\",\n {\n class:\n \"font-semibold text-foreground bg-primary/10 rounded-sm px-0.5\",\n },\n match,\n ),\n after,\n ]);\n };\n },\n});\n\n/* ---------- Sync committed value when controlling v-model externally ---------- */\nwatch(\n () => props.modelValue,\n (v) => {\n if (matchedOption.value) lastCommittedValue.value = v ?? \"\";\n },\n);\n</script>\n"],"mappings":""}
@@ -246,6 +246,7 @@ var Combobox_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, v
246
246
  const { triggerRef, panelRef, isOpen, panelStyle, open: openPopover, close: closePopover } = require_usePopover.usePopover({
247
247
  placement: "bottom-start",
248
248
  matchTriggerWidth: true,
249
+ closeOnScroll: false,
249
250
  onOpen: () => {
250
251
  emit("open");
251
252
  const initial = matchedOption.value ?? flatOptions.value.find((o) => !o.disabled);
@@ -503,7 +504,7 @@ var Combobox_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, v
503
504
  radius: (0, vue.unref)(radius),
504
505
  role: "listbox",
505
506
  labelledBy: __props.label ? (0, vue.unref)(fieldId) : void 0,
506
- "onUpdate:panelRef": _cache[3] || (_cache[3] = ($event) => panelRef.value = $event)
507
+ "onUpdate:panelRef": _cache[2] || (_cache[2] = ($event) => panelRef.value = $event)
507
508
  }, {
508
509
  default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", _hoisted_5, [(0, vue.createElementVNode)("ul", {
509
510
  id: listboxId.value,
@@ -527,7 +528,6 @@ var Combobox_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, v
527
528
  ]),
528
529
  onPointerenter: ($event) => setActive(opt.value),
529
530
  onMousedown: _cache[1] || (_cache[1] = (0, vue.withModifiers)(() => {}, ["prevent"])),
530
- onTouchstart: _cache[2] || (_cache[2] = (0, vue.withModifiers)(() => {}, ["prevent"])),
531
531
  onClick: ($event) => selectOption(opt)
532
532
  }, [
533
533
  opt.icon ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(opt.icon), {
@@ -1 +1 @@
1
- {"version":3,"file":"Combobox.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../../src/components/forms/Combobox.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\"\n >*</span\n >\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 role=\"combobox\"\n :aria-haspopup=\"'listbox'\"\n :aria-expanded=\"isOpen\"\n :aria-controls=\"listboxId\"\n :aria-owns=\"listboxId\"\n >\n <component\n :is=\"iconLeft\"\n v-if=\"iconLeft\"\n aria-hidden=\"true\"\n :class=\"['shrink-0', affordanceIconClass, iconSizeClasses]\"\n />\n\n <input\n :id=\"fieldId\"\n ref=\"inputEl\"\n type=\"text\"\n role=\"combobox\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n :value=\"modelValue ?? ''\"\n :placeholder=\"placeholder\"\n :disabled=\"isDisabled\"\n :readonly=\"readonly\"\n :required=\"required\"\n :name=\"name\"\n :autofocus=\"autofocus\"\n :maxlength=\"maxLength\"\n :aria-label=\"!label ? ariaLabel : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-describedby=\"describedBy\"\n :aria-required=\"required || undefined\"\n :aria-autocomplete=\"'list'\"\n :aria-controls=\"listboxId\"\n :aria-expanded=\"isOpen\"\n :aria-activedescendant=\"isOpen && activeId ? activeId : 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 @focus=\"onFocus\"\n @blur=\"onBlur\"\n @keydown=\"onKeydown\"\n />\n\n <Loader\n v-if=\"loading || isLoadingAsync\"\n :size=\"size === 'large' ? 'medium' : 'small'\"\n :class=\"['shrink-0', affordanceIconClass]\"\n />\n\n <Button\n v-else-if=\"clearable && hasValue && !isDisabled && !readonly\"\n variant=\"text\"\n size=\"xs\"\n radius=\"full\"\n :icon=\"XMarkIcon\"\n :ariaLabel=\"loc.combobox.clear\"\n tabindex=\"-1\"\n :class=\"['shrink-0', affordanceActionClass]\"\n @click=\"clear\"\n />\n\n <Button\n variant=\"text\"\n size=\"xs\"\n radius=\"full\"\n :icon=\"ChevronDownIcon\"\n :ariaLabel=\"loc.combobox.toggleOptions\"\n tabindex=\"-1\"\n :class=\"[\n 'shrink-0',\n affordanceActionClass,\n 'transition-transform duration-base ease-standard',\n isOpen ? 'rotate-180' : '',\n ]\"\n @mousedown.prevent\n @click=\"onToggleClick\"\n />\n </div>\n\n <PopoverPanel\n :open=\"isOpen\"\n :style=\"panelStyle\"\n :radius=\"radius\"\n role=\"listbox\"\n :labelledBy=\"label ? fieldId : undefined\"\n @update:panelRef=\"panelRef = $event\"\n >\n <div class=\"flex flex-col max-h-72\">\n <ul\n :id=\"listboxId\"\n role=\"listbox\"\n class=\"modo-stagger flex-1 overflow-y-auto\"\n tabindex=\"-1\"\n >\n <li\n v-if=\"isLoadingAsync && displayedOptions.length === 0\"\n class=\"px-3 py-4 text-caption text-muted-foreground text-center\"\n >\n {{ loadingText }}\n </li>\n <li\n v-else-if=\"displayedOptions.length === 0\"\n class=\"px-3 py-4 text-caption text-muted-foreground text-center\"\n >\n {{ emptyText }}\n </li>\n\n <template\n v-for=\"(group, gi) in groupedOptions\"\n :key=\"group.name ?? gi\"\n >\n <li\n v-if=\"group.name\"\n class=\"px-3 pt-2 pb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground\"\n role=\"presentation\"\n >\n {{ group.name }}\n </li>\n <li\n v-for=\"opt in group.items\"\n :id=\"optionDomId(String(opt.value))\"\n :key=\"String(opt.value)\"\n role=\"option\"\n :aria-selected=\"matchedOption?.value === opt.value\"\n :aria-disabled=\"opt.disabled || undefined\"\n :class=\"[\n 'flex items-center gap-2 px-3 py-2 text-body cursor-pointer select-none',\n 'transition-colors duration-fast ease-standard',\n opt.disabled\n ? 'text-muted-foreground/60 cursor-not-allowed'\n : ['text-foreground', optionHover],\n activeValue === opt.value && !opt.disabled ? optionSurface : '',\n matchedOption?.value === opt.value ? 'font-medium' : '',\n ]\"\n @pointerenter=\"setActive(opt.value)\"\n @mousedown.prevent\n @touchstart.prevent\n @click=\"selectOption(opt)\"\n >\n <component\n :is=\"opt.icon\"\n v-if=\"opt.icon\"\n aria-hidden=\"true\"\n :class=\"['w-4 h-4 shrink-0', affordanceIconClass]\"\n />\n <div class=\"flex-1 min-w-0\">\n <div class=\"truncate\">\n <Highlight :text=\"opt.label\" :query=\"modelValue ?? ''\" />\n </div>\n <div\n v-if=\"opt.description\"\n class=\"text-caption text-muted-foreground truncate\"\n >\n {{ opt.description }}\n </div>\n </div>\n <CheckIcon\n v-if=\"matchedOption?.value === opt.value\"\n :class=\"['w-4 h-4 shrink-0', checkColorClass]\"\n aria-hidden=\"true\"\n />\n </li>\n </template>\n </ul>\n <slot name=\"footer\" />\n </div>\n </PopoverPanel>\n\n <div\n v-if=\"errorText || helperText || showCounterEffective\"\n class=\"flex items-start 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 class=\"flex-1\"\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 class=\"flex-1\"\n >\n {{ helperText }}\n </Typography>\n <p\n v-if=\"showCounterEffective\"\n :id=\"counterId\"\n :class=\"[\n 'text-caption ml-auto tabular-nums',\n counterOverflow ? 'text-destructive' : 'text-muted-foreground',\n ]\"\n >\n {{ currentLength }}/{{ maxLength }}\n </p>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, defineComponent, h, nextTick, ref, useId, watch } from \"vue\";\nimport type {\n Combobox as ComboboxProps,\n SelectOption,\n} from \"../../interfaces/forms/Combobox.interface\";\nimport {\n useFieldState,\n useFieldClasses,\n FIELD_AFFORDANCE_ACTION_BY_COLOR,\n FIELD_AFFORDANCE_ICON_BY_COLOR,\n} from \"../../composables/useField\";\nimport { usePopover } from \"../../composables/usePopover\";\nimport PopoverPanel from \"../layout/PopoverPanel.vue\";\nimport Typography from \"../data-display/Typography.vue\";\nimport Loader from \"../feedback/Loader.vue\";\nimport {\n ChevronDownIcon,\n XMarkIcon,\n CheckIcon,\n} from \"@heroicons/vue/24/outline\";\nimport Button from \"./Button.vue\";\nimport {\n useModoLocale,\n useSizeTokens,\n} from \"../../composables/useModoConfig\";\n\nconst loc = useModoLocale();\n\nconst props = withDefaults(defineProps<ComboboxProps>(), {\n modelValue: \"\",\n options: () => [],\n debounce: 250,\n minChars: 0,\n freeSolo: false,\n variant: \"outline\",\n color: \"default\",\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n clearable: false,\n placeholder: \"Type to search…\",\n emptyText: \"No results.\",\n loadingText: \"Loading…\",\n autofocus: false,\n});\n\nconst sz = useSizeTokens(() => props.size);\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: string];\n change: [value: string, option: SelectOption | null];\n select: [option: SelectOption];\n open: [];\n close: [];\n clear: [];\n search: [query: string];\n}>();\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, {\n componentName: \"Combobox\",\n idPrefix: \"modo-combobox\",\n});\n\nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({\n variant: () => props.variant,\n stateColor,\n hasError,\n radius,\n forceFocus: () => isOpen.value,\n halo: () => props.halo,\n});\n\n/* ---------- IDs ---------- */\nconst autoListboxId = useId();\nconst listboxId = computed(() => `modo-combobox-listbox-${autoListboxId}`);\nconst optionDomId = (v: string) => `${listboxId.value}-opt-${v}`;\n\n/* ---------- Options source (sync or async) ---------- */\n\nconst asyncOptions = ref<SelectOption[]>([]);\nconst isLoadingAsync = ref(false);\nlet loadTimer: number | null = null;\nlet loadRequestId = 0;\n\nwatch(\n () => props.modelValue,\n (q) => {\n if (!props.loadOptions) return;\n if (!isOpen.value) return;\n if ((q ?? \"\").length < props.minChars) {\n asyncOptions.value = [];\n return;\n }\n if (loadTimer !== null) clearTimeout(loadTimer);\n isLoadingAsync.value = true;\n const reqId = ++loadRequestId;\n loadTimer = window.setTimeout(async () => {\n try {\n const result = await props.loadOptions!(q ?? \"\");\n if (reqId === loadRequestId) asyncOptions.value = result;\n } finally {\n if (reqId === loadRequestId) isLoadingAsync.value = false;\n }\n emit(\"search\", q ?? \"\");\n }, props.debounce);\n },\n);\n\nconst sourceOptions = computed(() =>\n props.loadOptions ? asyncOptions.value : props.options,\n);\n\nconst displayedOptions = computed(() => {\n const q = (props.modelValue ?? \"\").trim().toLowerCase();\n // Si hay loadOptions, no filtramos localmente (confiamos en el backend).\n if (props.loadOptions) return sourceOptions.value;\n if (!q) return sourceOptions.value;\n return sourceOptions.value.filter(\n (o) =>\n o.label.toLowerCase().includes(q) ||\n (o.description ? o.description.toLowerCase().includes(q) : false),\n );\n});\n\ninterface OptionGroup {\n name?: string;\n items: SelectOption[];\n}\n\nconst groupedOptions = computed<OptionGroup[]>(() => {\n const list = displayedOptions.value;\n if (!list.some((o) => o.group)) {\n return list.length ? [{ items: list }] : [];\n }\n const map = new Map<string | undefined, SelectOption[]>();\n for (const opt of list) {\n const key = opt.group;\n if (!map.has(key)) map.set(key, []);\n map.get(key)!.push(opt);\n }\n const groups: OptionGroup[] = [];\n for (const [name, items] of map) groups.push({ name, items });\n return groups;\n});\n\nconst flatOptions = computed<SelectOption[]>(() =>\n groupedOptions.value.flatMap((g) => g.items),\n);\n\n/** Si el texto actual coincide exactamente (case-insensitive) con alguna opción, la devuelve. */\nconst matchedOption = computed<SelectOption | null>(() => {\n const v = (props.modelValue ?? \"\").trim().toLowerCase();\n if (!v) return null;\n return sourceOptions.value.find((o) => o.label.toLowerCase() === v) ?? null;\n});\n\n/* ---------- Color ---------- */\nconst CHECK_COLOR_BY_STATE: Record<string, string> = {\n default: \"text-foreground\",\n primary: \"text-primary\",\n danger: \"text-destructive\",\n success: \"text-success\",\n warning: \"text-warning\",\n};\nconst checkColorClass = computed(\n () => CHECK_COLOR_BY_STATE[stateColor.value] ?? \"text-foreground\",\n);\nconst affordanceIconClass = computed(\n () =>\n FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? \"text-muted-foreground\",\n);\nconst affordanceActionClass = computed(\n () =>\n FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ??\n \"text-muted-foreground hover:text-foreground\",\n);\n\nconst OPTION_SURFACE: Record<string, string> = {\n default: \"bg-muted\",\n primary: \"bg-primary/10\",\n danger: \"bg-destructive/10\",\n success: \"bg-success/10\",\n warning: \"bg-warning/10\",\n};\nconst OPTION_HOVER: Record<string, string> = {\n default: \"hover:bg-muted\",\n primary: \"hover:bg-primary/10\",\n danger: \"hover:bg-destructive/10\",\n success: \"hover:bg-success/10\",\n warning: \"hover:bg-warning/10\",\n};\nconst optionSurface = computed(\n () => OPTION_SURFACE[stateColor.value] ?? \"bg-muted\",\n);\nconst optionHover = computed(\n () => OPTION_HOVER[stateColor.value] ?? \"hover:bg-muted\",\n);\n\n/* ---------- Popover ---------- */\n\nconst inputEl = ref<HTMLInputElement | null>(null);\nconst wrapperEl = ref<HTMLElement | null>(null);\nconst activeValue = ref<string | number | null>(null);\nconst activeId = computed(() =>\n activeValue.value !== null ? optionDomId(String(activeValue.value)) : \"\",\n);\n\nconst {\n triggerRef,\n panelRef,\n isOpen,\n panelStyle,\n open: openPopover,\n close: closePopover,\n} = usePopover({\n placement: \"bottom-start\",\n matchTriggerWidth: true,\n onOpen: () => {\n emit(\"open\");\n const initial =\n matchedOption.value ?? flatOptions.value.find((o) => !o.disabled);\n activeValue.value = initial ? initial.value : null;\n nextTick(scrollActiveIntoView);\n },\n onClose: () => {\n emit(\"close\");\n },\n});\n\nwatch(wrapperEl, (el) => (triggerRef.value = el));\n\nfunction setActive(v: string | number) {\n activeValue.value = v;\n}\n\nfunction scrollActiveIntoView() {\n if (activeValue.value === null) return;\n const el = document.getElementById(optionDomId(String(activeValue.value)));\n el?.scrollIntoView({ block: \"nearest\" });\n}\n\n/* ---------- Actions ---------- */\n\nfunction onInput(e: Event) {\n const next = (e.target as HTMLInputElement).value;\n emit(\"update:modelValue\", next);\n if (!isOpen.value) openPopover();\n // Activar la primera opción tras filtrar\n nextTick(() => {\n const first = flatOptions.value.find((o) => !o.disabled);\n activeValue.value = first ? first.value : null;\n });\n}\n\nfunction onFocus() {\n if (isDisabled.value || props.readonly) return;\n if (!isOpen.value) openPopover();\n}\n\nfunction onBlur() {\n // Delay para permitir el click en la opción (mousedown.prevent también ayuda).\n setTimeout(() => {\n // Si no es freeSolo y no hay match, resetea al último match válido (o vacío)\n if (!props.freeSolo) {\n const current = (props.modelValue ?? \"\").trim();\n if (current && !matchedOption.value) {\n // Revertir al label de la opción previa si había una\n emit(\"update:modelValue\", lastCommittedValue.value);\n }\n }\n closePopover();\n }, 120);\n}\n\nfunction onToggleClick() {\n if (isDisabled.value || props.readonly) return;\n if (isOpen.value) {\n closePopover();\n inputEl.value?.blur();\n } else {\n inputEl.value?.focus();\n }\n}\n\nconst lastCommittedValue = ref<string>(props.modelValue ?? \"\");\n\nfunction commit(value: string, opt: SelectOption | null) {\n lastCommittedValue.value = value;\n emit(\"update:modelValue\", value);\n emit(\"change\", value, opt);\n}\n\nfunction selectOption(opt: SelectOption) {\n if (opt.disabled) return;\n commit(opt.label, opt);\n emit(\"select\", opt);\n closePopover();\n inputEl.value?.blur();\n}\n\nfunction clear() {\n commit(\"\", null);\n emit(\"clear\");\n inputEl.value?.focus();\n}\n\n/* ---------- Keyboard ---------- */\n\nfunction moveActive(direction: 1 | -1) {\n const list = flatOptions.value.filter((o) => !o.disabled);\n if (list.length === 0) return;\n const currentIdx = list.findIndex((o) => o.value === activeValue.value);\n let nextIdx: number;\n if (currentIdx === -1) {\n nextIdx = direction > 0 ? 0 : list.length - 1;\n } else {\n nextIdx = (currentIdx + direction + list.length) % list.length;\n }\n activeValue.value = list[nextIdx].value;\n scrollActiveIntoView();\n}\n\nfunction onKeydown(e: KeyboardEvent) {\n if (isDisabled.value || props.readonly) return;\n switch (e.key) {\n case \"ArrowDown\":\n e.preventDefault();\n if (!isOpen.value) openPopover();\n moveActive(1);\n break;\n case \"ArrowUp\":\n e.preventDefault();\n if (!isOpen.value) openPopover();\n moveActive(-1);\n break;\n case \"Enter\": {\n if (!isOpen.value) return;\n const opt = flatOptions.value.find((o) => o.value === activeValue.value);\n if (opt && !opt.disabled) {\n e.preventDefault();\n selectOption(opt);\n } else if (props.freeSolo) {\n e.preventDefault();\n commit(props.modelValue ?? \"\", null);\n // Keep panel open so the user sees the new value added to the list.\n // closePopover();\n }\n break;\n }\n case \"Escape\":\n if (isOpen.value) {\n e.preventDefault();\n closePopover();\n }\n break;\n case \"Tab\":\n // Dejar que Tab cierre naturalmente vía blur.\n break;\n }\n}\n\n/* ---------- Size maps ---------- */\n\nconst wrapperSizeClasses = computed(() => `${sz.value.control} ${sz.value.padX}`);\nconst inputTextClasses = computed(() => sz.value.text);\nconst iconSizeClasses = computed(() => sz.value.icon);\n\n/* ---------- Inline highlight helper ---------- */\nconst Highlight = defineComponent({\n name: \"ComboboxHighlight\",\n props: {\n text: { type: String, required: true },\n query: { type: String, required: true },\n },\n setup(p) {\n return () => {\n const q = (p.query ?? \"\").trim();\n if (!q) return h(\"span\", p.text);\n const idx = p.text.toLowerCase().indexOf(q.toLowerCase());\n if (idx === -1) return h(\"span\", p.text);\n const before = p.text.slice(0, idx);\n const match = p.text.slice(idx, idx + q.length);\n const after = p.text.slice(idx + q.length);\n return h(\"span\", [\n before,\n h(\n \"span\",\n {\n class:\n \"font-semibold text-foreground bg-primary/10 rounded-sm px-0.5\",\n },\n match,\n ),\n after,\n ]);\n };\n },\n});\n\n/* ---------- Sync committed value when controlling v-model externally ---------- */\nwatch(\n () => props.modelValue,\n (v) => {\n if (matchedOption.value) lastCommittedValue.value = v ?? \"\";\n },\n);\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuQA,MAAM,MAAM,sBAAA,eAAe;EAE3B,MAAM,QAAQ;EAoBd,MAAM,KAAK,sBAAA,oBAAoB,MAAM,KAAK;EAE1C,MAAM,OAAO;EAUb,MAAM,EACJ,SACA,QACA,YACA,UACA,UACA,YACA,eACA,sBACA,iBACA,SACA,UACA,WACA,gBACE,iBAAA,cAAc,OAAO;GACvB,eAAe;GACf,UAAU;GACX,CAAC;EAEF,MAAM,EAAE,uBAAuB,kBAAkB,iBAAA,gBAAgB;GAC/D,eAAe,MAAM;GACrB;GACA;GACA;GACA,kBAAkB,OAAO;GACzB,YAAY,MAAM;GACnB,CAAC;EAGF,MAAM,iBAAA,GAAA,IAAA,QAAuB;EAC7B,MAAM,aAAA,GAAA,IAAA,gBAA2B,yBAAyB,gBAAgB;EAC1E,MAAM,eAAe,MAAc,GAAG,UAAU,MAAM,OAAO;EAI7D,MAAM,gBAAA,GAAA,IAAA,KAAmC,EAAE,CAAC;EAC5C,MAAM,kBAAA,GAAA,IAAA,KAAqB,MAAM;EACjC,IAAI,YAA2B;EAC/B,IAAI,gBAAgB;EAEpB,CAAA,GAAA,IAAA,aACQ,MAAM,aACX,MAAM;GACL,IAAI,CAAC,MAAM,aAAa;GACxB,IAAI,CAAC,OAAO,OAAO;GACnB,KAAK,KAAK,IAAI,SAAS,MAAM,UAAU;IACrC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mBAAA,SAAA;;KARV,KAAA,GAAA,IAAA,OAAI,QAAO;KACZ,SAAQ;KACR,MAAK;KACL,OAAM;KACN,IAAG;KACH,OAAM;;qCAES,EAAA,GAAA,IAAA,kBAAA,GAAA,IAAA,iBAAZ,QAAA,UAAS,EAAA,EAAA,CAAA,CAAA;;qBAGD,QAAA,eAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,aASA,mBAAA,SAAA;;KARV,KAAA,GAAA,IAAA,OAAI,SAAQ;KACb,SAAQ;KACR,MAAK;KACL,OAAM;KACN,IAAG;KACH,OAAM;;qCAEU,EAAA,GAAA,IAAA,kBAAA,GAAA,IAAA,iBAAb,QAAA,WAAU,EAAA,EAAA,CAAA,CAAA;;2EAGP,qBAAoB,KAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAQxB,KAAA;;KAPD,KAAA,GAAA,IAAA,OAAI,UAAS;KACb,QAAA,GAAA,IAAA,gBAAK,CAAA,sCAAA,GAAA,IAAA,OAA6D,gBAAe,GAAA,qBAAA,wBAAA,CAAA;+CAK/E,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":"Combobox.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../../src/components/forms/Combobox.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\"\n >*</span\n >\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 role=\"combobox\"\n :aria-haspopup=\"'listbox'\"\n :aria-expanded=\"isOpen\"\n :aria-controls=\"listboxId\"\n :aria-owns=\"listboxId\"\n >\n <component\n :is=\"iconLeft\"\n v-if=\"iconLeft\"\n aria-hidden=\"true\"\n :class=\"['shrink-0', affordanceIconClass, iconSizeClasses]\"\n />\n\n <input\n :id=\"fieldId\"\n ref=\"inputEl\"\n type=\"text\"\n role=\"combobox\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n :value=\"modelValue ?? ''\"\n :placeholder=\"placeholder\"\n :disabled=\"isDisabled\"\n :readonly=\"readonly\"\n :required=\"required\"\n :name=\"name\"\n :autofocus=\"autofocus\"\n :maxlength=\"maxLength\"\n :aria-label=\"!label ? ariaLabel : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-describedby=\"describedBy\"\n :aria-required=\"required || undefined\"\n :aria-autocomplete=\"'list'\"\n :aria-controls=\"listboxId\"\n :aria-expanded=\"isOpen\"\n :aria-activedescendant=\"isOpen && activeId ? activeId : 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 @focus=\"onFocus\"\n @blur=\"onBlur\"\n @keydown=\"onKeydown\"\n />\n\n <Loader\n v-if=\"loading || isLoadingAsync\"\n :size=\"size === 'large' ? 'medium' : 'small'\"\n :class=\"['shrink-0', affordanceIconClass]\"\n />\n\n <Button\n v-else-if=\"clearable && hasValue && !isDisabled && !readonly\"\n variant=\"text\"\n size=\"xs\"\n radius=\"full\"\n :icon=\"XMarkIcon\"\n :ariaLabel=\"loc.combobox.clear\"\n tabindex=\"-1\"\n :class=\"['shrink-0', affordanceActionClass]\"\n @click=\"clear\"\n />\n\n <Button\n variant=\"text\"\n size=\"xs\"\n radius=\"full\"\n :icon=\"ChevronDownIcon\"\n :ariaLabel=\"loc.combobox.toggleOptions\"\n tabindex=\"-1\"\n :class=\"[\n 'shrink-0',\n affordanceActionClass,\n 'transition-transform duration-base ease-standard',\n isOpen ? 'rotate-180' : '',\n ]\"\n @mousedown.prevent\n @click=\"onToggleClick\"\n />\n </div>\n\n <PopoverPanel\n :open=\"isOpen\"\n :style=\"panelStyle\"\n :radius=\"radius\"\n role=\"listbox\"\n :labelledBy=\"label ? fieldId : undefined\"\n @update:panelRef=\"panelRef = $event\"\n >\n <div class=\"flex flex-col max-h-72\">\n <ul\n :id=\"listboxId\"\n role=\"listbox\"\n class=\"modo-stagger flex-1 overflow-y-auto\"\n tabindex=\"-1\"\n >\n <li\n v-if=\"isLoadingAsync && displayedOptions.length === 0\"\n class=\"px-3 py-4 text-caption text-muted-foreground text-center\"\n >\n {{ loadingText }}\n </li>\n <li\n v-else-if=\"displayedOptions.length === 0\"\n class=\"px-3 py-4 text-caption text-muted-foreground text-center\"\n >\n {{ emptyText }}\n </li>\n\n <template\n v-for=\"(group, gi) in groupedOptions\"\n :key=\"group.name ?? gi\"\n >\n <li\n v-if=\"group.name\"\n class=\"px-3 pt-2 pb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground\"\n role=\"presentation\"\n >\n {{ group.name }}\n </li>\n <!--\n `mousedown.prevent` keeps focus in the input while an option is\n picked. There is deliberately no `touchstart.prevent` alongside\n it: cancelling touchstart tells the browser to suppress the\n compatibility mouse events *and* the click for that tap, so on a\n touch device the option became impossible to select at all.\n -->\n <li\n v-for=\"opt in group.items\"\n :id=\"optionDomId(String(opt.value))\"\n :key=\"String(opt.value)\"\n role=\"option\"\n :aria-selected=\"matchedOption?.value === opt.value\"\n :aria-disabled=\"opt.disabled || undefined\"\n :class=\"[\n 'flex items-center gap-2 px-3 py-2 text-body cursor-pointer select-none',\n 'transition-colors duration-fast ease-standard',\n opt.disabled\n ? 'text-muted-foreground/60 cursor-not-allowed'\n : ['text-foreground', optionHover],\n activeValue === opt.value && !opt.disabled ? optionSurface : '',\n matchedOption?.value === opt.value ? 'font-medium' : '',\n ]\"\n @pointerenter=\"setActive(opt.value)\"\n @mousedown.prevent\n @click=\"selectOption(opt)\"\n >\n <component\n :is=\"opt.icon\"\n v-if=\"opt.icon\"\n aria-hidden=\"true\"\n :class=\"['w-4 h-4 shrink-0', affordanceIconClass]\"\n />\n <div class=\"flex-1 min-w-0\">\n <div class=\"truncate\">\n <Highlight :text=\"opt.label\" :query=\"modelValue ?? ''\" />\n </div>\n <div\n v-if=\"opt.description\"\n class=\"text-caption text-muted-foreground truncate\"\n >\n {{ opt.description }}\n </div>\n </div>\n <CheckIcon\n v-if=\"matchedOption?.value === opt.value\"\n :class=\"['w-4 h-4 shrink-0', checkColorClass]\"\n aria-hidden=\"true\"\n />\n </li>\n </template>\n </ul>\n <slot name=\"footer\" />\n </div>\n </PopoverPanel>\n\n <div\n v-if=\"errorText || helperText || showCounterEffective\"\n class=\"flex items-start 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 class=\"flex-1\"\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 class=\"flex-1\"\n >\n {{ helperText }}\n </Typography>\n <p\n v-if=\"showCounterEffective\"\n :id=\"counterId\"\n :class=\"[\n 'text-caption ml-auto tabular-nums',\n counterOverflow ? 'text-destructive' : 'text-muted-foreground',\n ]\"\n >\n {{ currentLength }}/{{ maxLength }}\n </p>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, defineComponent, h, nextTick, ref, useId, watch } from \"vue\";\nimport type {\n Combobox as ComboboxProps,\n SelectOption,\n} from \"../../interfaces/forms/Combobox.interface\";\nimport {\n useFieldState,\n useFieldClasses,\n FIELD_AFFORDANCE_ACTION_BY_COLOR,\n FIELD_AFFORDANCE_ICON_BY_COLOR,\n} from \"../../composables/useField\";\nimport { usePopover } from \"../../composables/usePopover\";\nimport PopoverPanel from \"../layout/PopoverPanel.vue\";\nimport Typography from \"../data-display/Typography.vue\";\nimport Loader from \"../feedback/Loader.vue\";\nimport {\n ChevronDownIcon,\n XMarkIcon,\n CheckIcon,\n} from \"@heroicons/vue/24/outline\";\nimport Button from \"./Button.vue\";\nimport {\n useModoLocale,\n useSizeTokens,\n} from \"../../composables/useModoConfig\";\n\nconst loc = useModoLocale();\n\nconst props = withDefaults(defineProps<ComboboxProps>(), {\n modelValue: \"\",\n options: () => [],\n debounce: 250,\n minChars: 0,\n freeSolo: false,\n variant: \"outline\",\n color: \"default\",\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n clearable: false,\n placeholder: \"Type to search…\",\n emptyText: \"No results.\",\n loadingText: \"Loading…\",\n autofocus: false,\n});\n\nconst sz = useSizeTokens(() => props.size);\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: string];\n change: [value: string, option: SelectOption | null];\n select: [option: SelectOption];\n open: [];\n close: [];\n clear: [];\n search: [query: string];\n}>();\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, {\n componentName: \"Combobox\",\n idPrefix: \"modo-combobox\",\n});\n\nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({\n variant: () => props.variant,\n stateColor,\n hasError,\n radius,\n forceFocus: () => isOpen.value,\n halo: () => props.halo,\n});\n\n/* ---------- IDs ---------- */\nconst autoListboxId = useId();\nconst listboxId = computed(() => `modo-combobox-listbox-${autoListboxId}`);\nconst optionDomId = (v: string) => `${listboxId.value}-opt-${v}`;\n\n/* ---------- Options source (sync or async) ---------- */\n\nconst asyncOptions = ref<SelectOption[]>([]);\nconst isLoadingAsync = ref(false);\nlet loadTimer: number | null = null;\nlet loadRequestId = 0;\n\nwatch(\n () => props.modelValue,\n (q) => {\n if (!props.loadOptions) return;\n if (!isOpen.value) return;\n if ((q ?? \"\").length < props.minChars) {\n asyncOptions.value = [];\n return;\n }\n if (loadTimer !== null) clearTimeout(loadTimer);\n isLoadingAsync.value = true;\n const reqId = ++loadRequestId;\n loadTimer = window.setTimeout(async () => {\n try {\n const result = await props.loadOptions!(q ?? \"\");\n if (reqId === loadRequestId) asyncOptions.value = result;\n } finally {\n if (reqId === loadRequestId) isLoadingAsync.value = false;\n }\n emit(\"search\", q ?? \"\");\n }, props.debounce);\n },\n);\n\nconst sourceOptions = computed(() =>\n props.loadOptions ? asyncOptions.value : props.options,\n);\n\nconst displayedOptions = computed(() => {\n const q = (props.modelValue ?? \"\").trim().toLowerCase();\n // Si hay loadOptions, no filtramos localmente (confiamos en el backend).\n if (props.loadOptions) return sourceOptions.value;\n if (!q) return sourceOptions.value;\n return sourceOptions.value.filter(\n (o) =>\n o.label.toLowerCase().includes(q) ||\n (o.description ? o.description.toLowerCase().includes(q) : false),\n );\n});\n\ninterface OptionGroup {\n name?: string;\n items: SelectOption[];\n}\n\nconst groupedOptions = computed<OptionGroup[]>(() => {\n const list = displayedOptions.value;\n if (!list.some((o) => o.group)) {\n return list.length ? [{ items: list }] : [];\n }\n const map = new Map<string | undefined, SelectOption[]>();\n for (const opt of list) {\n const key = opt.group;\n if (!map.has(key)) map.set(key, []);\n map.get(key)!.push(opt);\n }\n const groups: OptionGroup[] = [];\n for (const [name, items] of map) groups.push({ name, items });\n return groups;\n});\n\nconst flatOptions = computed<SelectOption[]>(() =>\n groupedOptions.value.flatMap((g) => g.items),\n);\n\n/** Si el texto actual coincide exactamente (case-insensitive) con alguna opción, la devuelve. */\nconst matchedOption = computed<SelectOption | null>(() => {\n const v = (props.modelValue ?? \"\").trim().toLowerCase();\n if (!v) return null;\n return sourceOptions.value.find((o) => o.label.toLowerCase() === v) ?? null;\n});\n\n/* ---------- Color ---------- */\nconst CHECK_COLOR_BY_STATE: Record<string, string> = {\n default: \"text-foreground\",\n primary: \"text-primary\",\n danger: \"text-destructive\",\n success: \"text-success\",\n warning: \"text-warning\",\n};\nconst checkColorClass = computed(\n () => CHECK_COLOR_BY_STATE[stateColor.value] ?? \"text-foreground\",\n);\nconst affordanceIconClass = computed(\n () =>\n FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? \"text-muted-foreground\",\n);\nconst affordanceActionClass = computed(\n () =>\n FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ??\n \"text-muted-foreground hover:text-foreground\",\n);\n\nconst OPTION_SURFACE: Record<string, string> = {\n default: \"bg-muted\",\n primary: \"bg-primary/10\",\n danger: \"bg-destructive/10\",\n success: \"bg-success/10\",\n warning: \"bg-warning/10\",\n};\nconst OPTION_HOVER: Record<string, string> = {\n default: \"hover:bg-muted\",\n primary: \"hover:bg-primary/10\",\n danger: \"hover:bg-destructive/10\",\n success: \"hover:bg-success/10\",\n warning: \"hover:bg-warning/10\",\n};\nconst optionSurface = computed(\n () => OPTION_SURFACE[stateColor.value] ?? \"bg-muted\",\n);\nconst optionHover = computed(\n () => OPTION_HOVER[stateColor.value] ?? \"hover:bg-muted\",\n);\n\n/* ---------- Popover ---------- */\n\nconst inputEl = ref<HTMLInputElement | null>(null);\nconst wrapperEl = ref<HTMLElement | null>(null);\nconst activeValue = ref<string | number | null>(null);\nconst activeId = computed(() =>\n activeValue.value !== null ? optionDomId(String(activeValue.value)) : \"\",\n);\n\nconst {\n triggerRef,\n panelRef,\n isOpen,\n panelStyle,\n open: openPopover,\n close: closePopover,\n} = usePopover({\n placement: \"bottom-start\",\n matchTriggerWidth: true,\n // Reposition on scroll instead of closing. Focus is what opens this panel,\n // and focusing a text field is itself a scroll trigger: on mobile the virtual\n // keyboard appears and the browser scrolls the field into view a few frames\n // after the panel opened, which closed the dropdown before the user could\n // ever see it. Typing reopened it — by then the keyboard was already up and\n // no further scroll followed — which is why the list only appeared after the\n // first keystroke. Same reasoning as SearchInput.\n closeOnScroll: false,\n onOpen: () => {\n emit(\"open\");\n const initial =\n matchedOption.value ?? flatOptions.value.find((o) => !o.disabled);\n activeValue.value = initial ? initial.value : null;\n nextTick(scrollActiveIntoView);\n },\n onClose: () => {\n emit(\"close\");\n },\n});\n\nwatch(wrapperEl, (el) => (triggerRef.value = el));\n\nfunction setActive(v: string | number) {\n activeValue.value = v;\n}\n\nfunction scrollActiveIntoView() {\n if (activeValue.value === null) return;\n const el = document.getElementById(optionDomId(String(activeValue.value)));\n el?.scrollIntoView({ block: \"nearest\" });\n}\n\n/* ---------- Actions ---------- */\n\nfunction onInput(e: Event) {\n const next = (e.target as HTMLInputElement).value;\n emit(\"update:modelValue\", next);\n if (!isOpen.value) openPopover();\n // Activar la primera opción tras filtrar\n nextTick(() => {\n const first = flatOptions.value.find((o) => !o.disabled);\n activeValue.value = first ? first.value : null;\n });\n}\n\nfunction onFocus() {\n if (isDisabled.value || props.readonly) return;\n if (!isOpen.value) openPopover();\n}\n\nfunction onBlur() {\n // Delay para permitir el click en la opción (mousedown.prevent también ayuda).\n setTimeout(() => {\n // Si no es freeSolo y no hay match, resetea al último match válido (o vacío)\n if (!props.freeSolo) {\n const current = (props.modelValue ?? \"\").trim();\n if (current && !matchedOption.value) {\n // Revertir al label de la opción previa si había una\n emit(\"update:modelValue\", lastCommittedValue.value);\n }\n }\n closePopover();\n }, 120);\n}\n\nfunction onToggleClick() {\n if (isDisabled.value || props.readonly) return;\n if (isOpen.value) {\n closePopover();\n inputEl.value?.blur();\n } else {\n inputEl.value?.focus();\n }\n}\n\nconst lastCommittedValue = ref<string>(props.modelValue ?? \"\");\n\nfunction commit(value: string, opt: SelectOption | null) {\n lastCommittedValue.value = value;\n emit(\"update:modelValue\", value);\n emit(\"change\", value, opt);\n}\n\nfunction selectOption(opt: SelectOption) {\n if (opt.disabled) return;\n commit(opt.label, opt);\n emit(\"select\", opt);\n closePopover();\n inputEl.value?.blur();\n}\n\nfunction clear() {\n commit(\"\", null);\n emit(\"clear\");\n inputEl.value?.focus();\n}\n\n/* ---------- Keyboard ---------- */\n\nfunction moveActive(direction: 1 | -1) {\n const list = flatOptions.value.filter((o) => !o.disabled);\n if (list.length === 0) return;\n const currentIdx = list.findIndex((o) => o.value === activeValue.value);\n let nextIdx: number;\n if (currentIdx === -1) {\n nextIdx = direction > 0 ? 0 : list.length - 1;\n } else {\n nextIdx = (currentIdx + direction + list.length) % list.length;\n }\n activeValue.value = list[nextIdx].value;\n scrollActiveIntoView();\n}\n\nfunction onKeydown(e: KeyboardEvent) {\n if (isDisabled.value || props.readonly) return;\n switch (e.key) {\n case \"ArrowDown\":\n e.preventDefault();\n if (!isOpen.value) openPopover();\n moveActive(1);\n break;\n case \"ArrowUp\":\n e.preventDefault();\n if (!isOpen.value) openPopover();\n moveActive(-1);\n break;\n case \"Enter\": {\n if (!isOpen.value) return;\n const opt = flatOptions.value.find((o) => o.value === activeValue.value);\n if (opt && !opt.disabled) {\n e.preventDefault();\n selectOption(opt);\n } else if (props.freeSolo) {\n e.preventDefault();\n commit(props.modelValue ?? \"\", null);\n // Keep panel open so the user sees the new value added to the list.\n // closePopover();\n }\n break;\n }\n case \"Escape\":\n if (isOpen.value) {\n e.preventDefault();\n closePopover();\n }\n break;\n case \"Tab\":\n // Dejar que Tab cierre naturalmente vía blur.\n break;\n }\n}\n\n/* ---------- Size maps ---------- */\n\nconst wrapperSizeClasses = computed(() => `${sz.value.control} ${sz.value.padX}`);\nconst inputTextClasses = computed(() => sz.value.text);\nconst iconSizeClasses = computed(() => sz.value.icon);\n\n/* ---------- Inline highlight helper ---------- */\nconst Highlight = defineComponent({\n name: \"ComboboxHighlight\",\n props: {\n text: { type: String, required: true },\n query: { type: String, required: true },\n },\n setup(p) {\n return () => {\n const q = (p.query ?? \"\").trim();\n if (!q) return h(\"span\", p.text);\n const idx = p.text.toLowerCase().indexOf(q.toLowerCase());\n if (idx === -1) return h(\"span\", p.text);\n const before = p.text.slice(0, idx);\n const match = p.text.slice(idx, idx + q.length);\n const after = p.text.slice(idx + q.length);\n return h(\"span\", [\n before,\n h(\n \"span\",\n {\n class:\n \"font-semibold text-foreground bg-primary/10 rounded-sm px-0.5\",\n },\n match,\n ),\n after,\n ]);\n };\n },\n});\n\n/* ---------- Sync committed value when controlling v-model externally ---------- */\nwatch(\n () => props.modelValue,\n (v) => {\n if (matchedOption.value) lastCommittedValue.value = v ?? \"\";\n },\n);\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6QA,MAAM,MAAM,sBAAA,eAAe;EAE3B,MAAM,QAAQ;EAoBd,MAAM,KAAK,sBAAA,oBAAoB,MAAM,KAAK;EAE1C,MAAM,OAAO;EAUb,MAAM,EACJ,SACA,QACA,YACA,UACA,UACA,YACA,eACA,sBACA,iBACA,SACA,UACA,WACA,gBACE,iBAAA,cAAc,OAAO;GACvB,eAAe;GACf,UAAU;GACX,CAAC;EAEF,MAAM,EAAE,uBAAuB,kBAAkB,iBAAA,gBAAgB;GAC/D,eAAe,MAAM;GACrB;GACA;GACA;GACA,kBAAkB,OAAO;GACzB,YAAY,MAAM;GACnB,CAAC;EAGF,MAAM,iBAAA,GAAA,IAAA,QAAuB;EAC7B,MAAM,aAAA,GAAA,IAAA,gBAA2B,yBAAyB,gBAAgB;EAC1E,MAAM,eAAe,MAAc,GAAG,UAAU,MAAM,OAAO;EAI7D,MAAM,gBAAA,GAAA,IAAA,KAAmC,EAAE,CAAC;EAC5C,MAAM,kBAAA,GAAA,IAAA,KAAqB,MAAM;EACjC,IAAI,YAA2B;EAC/B,IAAI,gBAAgB;EAEpB,CAAA,GAAA,IAAA,aACQ,MAAM,aACX,MAAM;GACL,IAAI,CAAC,MAAM,aAAa;GACxB,IAAI,CAAC,OAA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KARV,KAAA,GAAA,IAAA,OAAI,QAAO;KACZ,SAAQ;KACR,MAAK;KACL,OAAM;KACN,IAAG;KACH,OAAM;;qCAES,EAAA,GAAA,IAAA,kBAAA,GAAA,IAAA,iBAAZ,QAAA,UAAS,EAAA,EAAA,CAAA,CAAA;;qBAGD,QAAA,eAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,aASA,mBAAA,SAAA;;KARV,KAAA,GAAA,IAAA,OAAI,SAAQ;KACb,SAAQ;KACR,MAAK;KACL,OAAM;KACN,IAAG;KACH,OAAM;;qCAEU,EAAA,GAAA,IAAA,kBAAA,GAAA,IAAA,iBAAb,QAAA,WAAU,EAAA,EAAA,CAAA,CAAA;;2EAGP,qBAAoB,KAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAQxB,KAAA;;KAPD,KAAA,GAAA,IAAA,OAAI,UAAS;KACb,QAAA,GAAA,IAAA,gBAAK,CAAA,sCAAA,GAAA,IAAA,OAA6D,gBAAe,GAAA,qBAAA,wBAAA,CAAA;+CAK/E,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"}
@@ -245,6 +245,7 @@ var Combobox_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defin
245
245
  const { triggerRef, panelRef, isOpen, panelStyle, open: openPopover, close: closePopover } = usePopover({
246
246
  placement: "bottom-start",
247
247
  matchTriggerWidth: true,
248
+ closeOnScroll: false,
248
249
  onOpen: () => {
249
250
  emit("open");
250
251
  const initial = matchedOption.value ?? flatOptions.value.find((o) => !o.disabled);
@@ -502,7 +503,7 @@ var Combobox_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defin
502
503
  radius: unref(radius),
503
504
  role: "listbox",
504
505
  labelledBy: __props.label ? unref(fieldId) : void 0,
505
- "onUpdate:panelRef": _cache[3] || (_cache[3] = ($event) => panelRef.value = $event)
506
+ "onUpdate:panelRef": _cache[2] || (_cache[2] = ($event) => panelRef.value = $event)
506
507
  }, {
507
508
  default: withCtx(() => [createElementVNode("div", _hoisted_5, [createElementVNode("ul", {
508
509
  id: listboxId.value,
@@ -526,7 +527,6 @@ var Combobox_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defin
526
527
  ]),
527
528
  onPointerenter: ($event) => setActive(opt.value),
528
529
  onMousedown: _cache[1] || (_cache[1] = withModifiers(() => {}, ["prevent"])),
529
- onTouchstart: _cache[2] || (_cache[2] = withModifiers(() => {}, ["prevent"])),
530
530
  onClick: ($event) => selectOption(opt)
531
531
  }, [
532
532
  opt.icon ? (openBlock(), createBlock(resolveDynamicComponent(opt.icon), {
@@ -1 +1 @@
1
- {"version":3,"file":"Combobox.vue_vue_type_script_setup_true_lang.mjs","names":[],"sources":["../../../src/components/forms/Combobox.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\"\n >*</span\n >\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 role=\"combobox\"\n :aria-haspopup=\"'listbox'\"\n :aria-expanded=\"isOpen\"\n :aria-controls=\"listboxId\"\n :aria-owns=\"listboxId\"\n >\n <component\n :is=\"iconLeft\"\n v-if=\"iconLeft\"\n aria-hidden=\"true\"\n :class=\"['shrink-0', affordanceIconClass, iconSizeClasses]\"\n />\n\n <input\n :id=\"fieldId\"\n ref=\"inputEl\"\n type=\"text\"\n role=\"combobox\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n :value=\"modelValue ?? ''\"\n :placeholder=\"placeholder\"\n :disabled=\"isDisabled\"\n :readonly=\"readonly\"\n :required=\"required\"\n :name=\"name\"\n :autofocus=\"autofocus\"\n :maxlength=\"maxLength\"\n :aria-label=\"!label ? ariaLabel : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-describedby=\"describedBy\"\n :aria-required=\"required || undefined\"\n :aria-autocomplete=\"'list'\"\n :aria-controls=\"listboxId\"\n :aria-expanded=\"isOpen\"\n :aria-activedescendant=\"isOpen && activeId ? activeId : 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 @focus=\"onFocus\"\n @blur=\"onBlur\"\n @keydown=\"onKeydown\"\n />\n\n <Loader\n v-if=\"loading || isLoadingAsync\"\n :size=\"size === 'large' ? 'medium' : 'small'\"\n :class=\"['shrink-0', affordanceIconClass]\"\n />\n\n <Button\n v-else-if=\"clearable && hasValue && !isDisabled && !readonly\"\n variant=\"text\"\n size=\"xs\"\n radius=\"full\"\n :icon=\"XMarkIcon\"\n :ariaLabel=\"loc.combobox.clear\"\n tabindex=\"-1\"\n :class=\"['shrink-0', affordanceActionClass]\"\n @click=\"clear\"\n />\n\n <Button\n variant=\"text\"\n size=\"xs\"\n radius=\"full\"\n :icon=\"ChevronDownIcon\"\n :ariaLabel=\"loc.combobox.toggleOptions\"\n tabindex=\"-1\"\n :class=\"[\n 'shrink-0',\n affordanceActionClass,\n 'transition-transform duration-base ease-standard',\n isOpen ? 'rotate-180' : '',\n ]\"\n @mousedown.prevent\n @click=\"onToggleClick\"\n />\n </div>\n\n <PopoverPanel\n :open=\"isOpen\"\n :style=\"panelStyle\"\n :radius=\"radius\"\n role=\"listbox\"\n :labelledBy=\"label ? fieldId : undefined\"\n @update:panelRef=\"panelRef = $event\"\n >\n <div class=\"flex flex-col max-h-72\">\n <ul\n :id=\"listboxId\"\n role=\"listbox\"\n class=\"modo-stagger flex-1 overflow-y-auto\"\n tabindex=\"-1\"\n >\n <li\n v-if=\"isLoadingAsync && displayedOptions.length === 0\"\n class=\"px-3 py-4 text-caption text-muted-foreground text-center\"\n >\n {{ loadingText }}\n </li>\n <li\n v-else-if=\"displayedOptions.length === 0\"\n class=\"px-3 py-4 text-caption text-muted-foreground text-center\"\n >\n {{ emptyText }}\n </li>\n\n <template\n v-for=\"(group, gi) in groupedOptions\"\n :key=\"group.name ?? gi\"\n >\n <li\n v-if=\"group.name\"\n class=\"px-3 pt-2 pb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground\"\n role=\"presentation\"\n >\n {{ group.name }}\n </li>\n <li\n v-for=\"opt in group.items\"\n :id=\"optionDomId(String(opt.value))\"\n :key=\"String(opt.value)\"\n role=\"option\"\n :aria-selected=\"matchedOption?.value === opt.value\"\n :aria-disabled=\"opt.disabled || undefined\"\n :class=\"[\n 'flex items-center gap-2 px-3 py-2 text-body cursor-pointer select-none',\n 'transition-colors duration-fast ease-standard',\n opt.disabled\n ? 'text-muted-foreground/60 cursor-not-allowed'\n : ['text-foreground', optionHover],\n activeValue === opt.value && !opt.disabled ? optionSurface : '',\n matchedOption?.value === opt.value ? 'font-medium' : '',\n ]\"\n @pointerenter=\"setActive(opt.value)\"\n @mousedown.prevent\n @touchstart.prevent\n @click=\"selectOption(opt)\"\n >\n <component\n :is=\"opt.icon\"\n v-if=\"opt.icon\"\n aria-hidden=\"true\"\n :class=\"['w-4 h-4 shrink-0', affordanceIconClass]\"\n />\n <div class=\"flex-1 min-w-0\">\n <div class=\"truncate\">\n <Highlight :text=\"opt.label\" :query=\"modelValue ?? ''\" />\n </div>\n <div\n v-if=\"opt.description\"\n class=\"text-caption text-muted-foreground truncate\"\n >\n {{ opt.description }}\n </div>\n </div>\n <CheckIcon\n v-if=\"matchedOption?.value === opt.value\"\n :class=\"['w-4 h-4 shrink-0', checkColorClass]\"\n aria-hidden=\"true\"\n />\n </li>\n </template>\n </ul>\n <slot name=\"footer\" />\n </div>\n </PopoverPanel>\n\n <div\n v-if=\"errorText || helperText || showCounterEffective\"\n class=\"flex items-start 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 class=\"flex-1\"\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 class=\"flex-1\"\n >\n {{ helperText }}\n </Typography>\n <p\n v-if=\"showCounterEffective\"\n :id=\"counterId\"\n :class=\"[\n 'text-caption ml-auto tabular-nums',\n counterOverflow ? 'text-destructive' : 'text-muted-foreground',\n ]\"\n >\n {{ currentLength }}/{{ maxLength }}\n </p>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, defineComponent, h, nextTick, ref, useId, watch } from \"vue\";\nimport type {\n Combobox as ComboboxProps,\n SelectOption,\n} from \"../../interfaces/forms/Combobox.interface\";\nimport {\n useFieldState,\n useFieldClasses,\n FIELD_AFFORDANCE_ACTION_BY_COLOR,\n FIELD_AFFORDANCE_ICON_BY_COLOR,\n} from \"../../composables/useField\";\nimport { usePopover } from \"../../composables/usePopover\";\nimport PopoverPanel from \"../layout/PopoverPanel.vue\";\nimport Typography from \"../data-display/Typography.vue\";\nimport Loader from \"../feedback/Loader.vue\";\nimport {\n ChevronDownIcon,\n XMarkIcon,\n CheckIcon,\n} from \"@heroicons/vue/24/outline\";\nimport Button from \"./Button.vue\";\nimport {\n useModoLocale,\n useSizeTokens,\n} from \"../../composables/useModoConfig\";\n\nconst loc = useModoLocale();\n\nconst props = withDefaults(defineProps<ComboboxProps>(), {\n modelValue: \"\",\n options: () => [],\n debounce: 250,\n minChars: 0,\n freeSolo: false,\n variant: \"outline\",\n color: \"default\",\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n clearable: false,\n placeholder: \"Type to search…\",\n emptyText: \"No results.\",\n loadingText: \"Loading…\",\n autofocus: false,\n});\n\nconst sz = useSizeTokens(() => props.size);\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: string];\n change: [value: string, option: SelectOption | null];\n select: [option: SelectOption];\n open: [];\n close: [];\n clear: [];\n search: [query: string];\n}>();\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, {\n componentName: \"Combobox\",\n idPrefix: \"modo-combobox\",\n});\n\nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({\n variant: () => props.variant,\n stateColor,\n hasError,\n radius,\n forceFocus: () => isOpen.value,\n halo: () => props.halo,\n});\n\n/* ---------- IDs ---------- */\nconst autoListboxId = useId();\nconst listboxId = computed(() => `modo-combobox-listbox-${autoListboxId}`);\nconst optionDomId = (v: string) => `${listboxId.value}-opt-${v}`;\n\n/* ---------- Options source (sync or async) ---------- */\n\nconst asyncOptions = ref<SelectOption[]>([]);\nconst isLoadingAsync = ref(false);\nlet loadTimer: number | null = null;\nlet loadRequestId = 0;\n\nwatch(\n () => props.modelValue,\n (q) => {\n if (!props.loadOptions) return;\n if (!isOpen.value) return;\n if ((q ?? \"\").length < props.minChars) {\n asyncOptions.value = [];\n return;\n }\n if (loadTimer !== null) clearTimeout(loadTimer);\n isLoadingAsync.value = true;\n const reqId = ++loadRequestId;\n loadTimer = window.setTimeout(async () => {\n try {\n const result = await props.loadOptions!(q ?? \"\");\n if (reqId === loadRequestId) asyncOptions.value = result;\n } finally {\n if (reqId === loadRequestId) isLoadingAsync.value = false;\n }\n emit(\"search\", q ?? \"\");\n }, props.debounce);\n },\n);\n\nconst sourceOptions = computed(() =>\n props.loadOptions ? asyncOptions.value : props.options,\n);\n\nconst displayedOptions = computed(() => {\n const q = (props.modelValue ?? \"\").trim().toLowerCase();\n // Si hay loadOptions, no filtramos localmente (confiamos en el backend).\n if (props.loadOptions) return sourceOptions.value;\n if (!q) return sourceOptions.value;\n return sourceOptions.value.filter(\n (o) =>\n o.label.toLowerCase().includes(q) ||\n (o.description ? o.description.toLowerCase().includes(q) : false),\n );\n});\n\ninterface OptionGroup {\n name?: string;\n items: SelectOption[];\n}\n\nconst groupedOptions = computed<OptionGroup[]>(() => {\n const list = displayedOptions.value;\n if (!list.some((o) => o.group)) {\n return list.length ? [{ items: list }] : [];\n }\n const map = new Map<string | undefined, SelectOption[]>();\n for (const opt of list) {\n const key = opt.group;\n if (!map.has(key)) map.set(key, []);\n map.get(key)!.push(opt);\n }\n const groups: OptionGroup[] = [];\n for (const [name, items] of map) groups.push({ name, items });\n return groups;\n});\n\nconst flatOptions = computed<SelectOption[]>(() =>\n groupedOptions.value.flatMap((g) => g.items),\n);\n\n/** Si el texto actual coincide exactamente (case-insensitive) con alguna opción, la devuelve. */\nconst matchedOption = computed<SelectOption | null>(() => {\n const v = (props.modelValue ?? \"\").trim().toLowerCase();\n if (!v) return null;\n return sourceOptions.value.find((o) => o.label.toLowerCase() === v) ?? null;\n});\n\n/* ---------- Color ---------- */\nconst CHECK_COLOR_BY_STATE: Record<string, string> = {\n default: \"text-foreground\",\n primary: \"text-primary\",\n danger: \"text-destructive\",\n success: \"text-success\",\n warning: \"text-warning\",\n};\nconst checkColorClass = computed(\n () => CHECK_COLOR_BY_STATE[stateColor.value] ?? \"text-foreground\",\n);\nconst affordanceIconClass = computed(\n () =>\n FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? \"text-muted-foreground\",\n);\nconst affordanceActionClass = computed(\n () =>\n FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ??\n \"text-muted-foreground hover:text-foreground\",\n);\n\nconst OPTION_SURFACE: Record<string, string> = {\n default: \"bg-muted\",\n primary: \"bg-primary/10\",\n danger: \"bg-destructive/10\",\n success: \"bg-success/10\",\n warning: \"bg-warning/10\",\n};\nconst OPTION_HOVER: Record<string, string> = {\n default: \"hover:bg-muted\",\n primary: \"hover:bg-primary/10\",\n danger: \"hover:bg-destructive/10\",\n success: \"hover:bg-success/10\",\n warning: \"hover:bg-warning/10\",\n};\nconst optionSurface = computed(\n () => OPTION_SURFACE[stateColor.value] ?? \"bg-muted\",\n);\nconst optionHover = computed(\n () => OPTION_HOVER[stateColor.value] ?? \"hover:bg-muted\",\n);\n\n/* ---------- Popover ---------- */\n\nconst inputEl = ref<HTMLInputElement | null>(null);\nconst wrapperEl = ref<HTMLElement | null>(null);\nconst activeValue = ref<string | number | null>(null);\nconst activeId = computed(() =>\n activeValue.value !== null ? optionDomId(String(activeValue.value)) : \"\",\n);\n\nconst {\n triggerRef,\n panelRef,\n isOpen,\n panelStyle,\n open: openPopover,\n close: closePopover,\n} = usePopover({\n placement: \"bottom-start\",\n matchTriggerWidth: true,\n onOpen: () => {\n emit(\"open\");\n const initial =\n matchedOption.value ?? flatOptions.value.find((o) => !o.disabled);\n activeValue.value = initial ? initial.value : null;\n nextTick(scrollActiveIntoView);\n },\n onClose: () => {\n emit(\"close\");\n },\n});\n\nwatch(wrapperEl, (el) => (triggerRef.value = el));\n\nfunction setActive(v: string | number) {\n activeValue.value = v;\n}\n\nfunction scrollActiveIntoView() {\n if (activeValue.value === null) return;\n const el = document.getElementById(optionDomId(String(activeValue.value)));\n el?.scrollIntoView({ block: \"nearest\" });\n}\n\n/* ---------- Actions ---------- */\n\nfunction onInput(e: Event) {\n const next = (e.target as HTMLInputElement).value;\n emit(\"update:modelValue\", next);\n if (!isOpen.value) openPopover();\n // Activar la primera opción tras filtrar\n nextTick(() => {\n const first = flatOptions.value.find((o) => !o.disabled);\n activeValue.value = first ? first.value : null;\n });\n}\n\nfunction onFocus() {\n if (isDisabled.value || props.readonly) return;\n if (!isOpen.value) openPopover();\n}\n\nfunction onBlur() {\n // Delay para permitir el click en la opción (mousedown.prevent también ayuda).\n setTimeout(() => {\n // Si no es freeSolo y no hay match, resetea al último match válido (o vacío)\n if (!props.freeSolo) {\n const current = (props.modelValue ?? \"\").trim();\n if (current && !matchedOption.value) {\n // Revertir al label de la opción previa si había una\n emit(\"update:modelValue\", lastCommittedValue.value);\n }\n }\n closePopover();\n }, 120);\n}\n\nfunction onToggleClick() {\n if (isDisabled.value || props.readonly) return;\n if (isOpen.value) {\n closePopover();\n inputEl.value?.blur();\n } else {\n inputEl.value?.focus();\n }\n}\n\nconst lastCommittedValue = ref<string>(props.modelValue ?? \"\");\n\nfunction commit(value: string, opt: SelectOption | null) {\n lastCommittedValue.value = value;\n emit(\"update:modelValue\", value);\n emit(\"change\", value, opt);\n}\n\nfunction selectOption(opt: SelectOption) {\n if (opt.disabled) return;\n commit(opt.label, opt);\n emit(\"select\", opt);\n closePopover();\n inputEl.value?.blur();\n}\n\nfunction clear() {\n commit(\"\", null);\n emit(\"clear\");\n inputEl.value?.focus();\n}\n\n/* ---------- Keyboard ---------- */\n\nfunction moveActive(direction: 1 | -1) {\n const list = flatOptions.value.filter((o) => !o.disabled);\n if (list.length === 0) return;\n const currentIdx = list.findIndex((o) => o.value === activeValue.value);\n let nextIdx: number;\n if (currentIdx === -1) {\n nextIdx = direction > 0 ? 0 : list.length - 1;\n } else {\n nextIdx = (currentIdx + direction + list.length) % list.length;\n }\n activeValue.value = list[nextIdx].value;\n scrollActiveIntoView();\n}\n\nfunction onKeydown(e: KeyboardEvent) {\n if (isDisabled.value || props.readonly) return;\n switch (e.key) {\n case \"ArrowDown\":\n e.preventDefault();\n if (!isOpen.value) openPopover();\n moveActive(1);\n break;\n case \"ArrowUp\":\n e.preventDefault();\n if (!isOpen.value) openPopover();\n moveActive(-1);\n break;\n case \"Enter\": {\n if (!isOpen.value) return;\n const opt = flatOptions.value.find((o) => o.value === activeValue.value);\n if (opt && !opt.disabled) {\n e.preventDefault();\n selectOption(opt);\n } else if (props.freeSolo) {\n e.preventDefault();\n commit(props.modelValue ?? \"\", null);\n // Keep panel open so the user sees the new value added to the list.\n // closePopover();\n }\n break;\n }\n case \"Escape\":\n if (isOpen.value) {\n e.preventDefault();\n closePopover();\n }\n break;\n case \"Tab\":\n // Dejar que Tab cierre naturalmente vía blur.\n break;\n }\n}\n\n/* ---------- Size maps ---------- */\n\nconst wrapperSizeClasses = computed(() => `${sz.value.control} ${sz.value.padX}`);\nconst inputTextClasses = computed(() => sz.value.text);\nconst iconSizeClasses = computed(() => sz.value.icon);\n\n/* ---------- Inline highlight helper ---------- */\nconst Highlight = defineComponent({\n name: \"ComboboxHighlight\",\n props: {\n text: { type: String, required: true },\n query: { type: String, required: true },\n },\n setup(p) {\n return () => {\n const q = (p.query ?? \"\").trim();\n if (!q) return h(\"span\", p.text);\n const idx = p.text.toLowerCase().indexOf(q.toLowerCase());\n if (idx === -1) return h(\"span\", p.text);\n const before = p.text.slice(0, idx);\n const match = p.text.slice(idx, idx + q.length);\n const after = p.text.slice(idx + q.length);\n return h(\"span\", [\n before,\n h(\n \"span\",\n {\n class:\n \"font-semibold text-foreground bg-primary/10 rounded-sm px-0.5\",\n },\n match,\n ),\n after,\n ]);\n };\n },\n});\n\n/* ---------- Sync committed value when controlling v-model externally ---------- */\nwatch(\n () => props.modelValue,\n (v) => {\n if (matchedOption.value) lastCommittedValue.value = v ?? \"\";\n },\n);\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuQA,MAAM,MAAM,eAAe;EAE3B,MAAM,QAAQ;EAoBd,MAAM,KAAK,oBAAoB,MAAM,KAAK;EAE1C,MAAM,OAAO;EAUb,MAAM,EACJ,SACA,QACA,YACA,UACA,UACA,YACA,eACA,sBACA,iBACA,SACA,UACA,WACA,gBACE,cAAc,OAAO;GACvB,eAAe;GACf,UAA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,IAAI,YAAW,EAAA,EAAA,IAAA,mBAAA,IAAA,KAAA,CAAA,CAAA;QAId,cAAA,OAAe,UAAU,IAAI,SAAA,WAAA,EADrC,YAIE,MAAA,UAAA,EAAA;;SAFC,OAAK,eAAA,CAAA,oBAAuB,gBAAA,MAAe,CAAA;SAC5C,eAAY;;;;iCAKpB,WAAsB,KAAA,QAAA,SAAA,CAAA,CAAA,CAAA,CAAA;;;;;;;;IAKlB,QAAA,aAAa,QAAA,cAAc,MAAA,qBAAoB,IAAA,WAAA,EADvD,mBAoCM,OApCN,aAoCM,CA/BI,QAAA,aAAA,WAAA,EADR,YAUa,oBAAA;;KARV,IAAI,MAAA,QAAO;KACZ,SAAQ;KACR,MAAK;KACL,OAAM;KACN,IAAG;KACH,OAAM;;4BAES,CAAA,gBAAA,gBAAZ,QAAA,UAAS,EAAA,EAAA,CAAA,CAAA;;qBAGD,QAAA,cAAA,WAAA,EADb,YAUa,oBAAA;;KARV,IAAI,MAAA,SAAQ;KACb,SAAQ;KACR,MAAK;KACL,OAAM;KACN,IAAG;KACH,OAAM;;4BAEU,CAAA,gBAAA,gBAAb,QAAA,WAAU,EAAA,EAAA,CAAA,CAAA;;mDAGP,MAAA,qBAAoB,IAAA,WAAA,EAD5B,mBASI,KAAA;;KAPD,IAAI,MAAA,UAAS;KACb,OAAK,eAAA,CAAA,qCAA6D,MAAA,gBAAe,GAAA,qBAAA,wBAAA,CAAA;uBAK/E,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":"Combobox.vue_vue_type_script_setup_true_lang.mjs","names":[],"sources":["../../../src/components/forms/Combobox.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\"\n >*</span\n >\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 role=\"combobox\"\n :aria-haspopup=\"'listbox'\"\n :aria-expanded=\"isOpen\"\n :aria-controls=\"listboxId\"\n :aria-owns=\"listboxId\"\n >\n <component\n :is=\"iconLeft\"\n v-if=\"iconLeft\"\n aria-hidden=\"true\"\n :class=\"['shrink-0', affordanceIconClass, iconSizeClasses]\"\n />\n\n <input\n :id=\"fieldId\"\n ref=\"inputEl\"\n type=\"text\"\n role=\"combobox\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n :value=\"modelValue ?? ''\"\n :placeholder=\"placeholder\"\n :disabled=\"isDisabled\"\n :readonly=\"readonly\"\n :required=\"required\"\n :name=\"name\"\n :autofocus=\"autofocus\"\n :maxlength=\"maxLength\"\n :aria-label=\"!label ? ariaLabel : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-describedby=\"describedBy\"\n :aria-required=\"required || undefined\"\n :aria-autocomplete=\"'list'\"\n :aria-controls=\"listboxId\"\n :aria-expanded=\"isOpen\"\n :aria-activedescendant=\"isOpen && activeId ? activeId : 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 @focus=\"onFocus\"\n @blur=\"onBlur\"\n @keydown=\"onKeydown\"\n />\n\n <Loader\n v-if=\"loading || isLoadingAsync\"\n :size=\"size === 'large' ? 'medium' : 'small'\"\n :class=\"['shrink-0', affordanceIconClass]\"\n />\n\n <Button\n v-else-if=\"clearable && hasValue && !isDisabled && !readonly\"\n variant=\"text\"\n size=\"xs\"\n radius=\"full\"\n :icon=\"XMarkIcon\"\n :ariaLabel=\"loc.combobox.clear\"\n tabindex=\"-1\"\n :class=\"['shrink-0', affordanceActionClass]\"\n @click=\"clear\"\n />\n\n <Button\n variant=\"text\"\n size=\"xs\"\n radius=\"full\"\n :icon=\"ChevronDownIcon\"\n :ariaLabel=\"loc.combobox.toggleOptions\"\n tabindex=\"-1\"\n :class=\"[\n 'shrink-0',\n affordanceActionClass,\n 'transition-transform duration-base ease-standard',\n isOpen ? 'rotate-180' : '',\n ]\"\n @mousedown.prevent\n @click=\"onToggleClick\"\n />\n </div>\n\n <PopoverPanel\n :open=\"isOpen\"\n :style=\"panelStyle\"\n :radius=\"radius\"\n role=\"listbox\"\n :labelledBy=\"label ? fieldId : undefined\"\n @update:panelRef=\"panelRef = $event\"\n >\n <div class=\"flex flex-col max-h-72\">\n <ul\n :id=\"listboxId\"\n role=\"listbox\"\n class=\"modo-stagger flex-1 overflow-y-auto\"\n tabindex=\"-1\"\n >\n <li\n v-if=\"isLoadingAsync && displayedOptions.length === 0\"\n class=\"px-3 py-4 text-caption text-muted-foreground text-center\"\n >\n {{ loadingText }}\n </li>\n <li\n v-else-if=\"displayedOptions.length === 0\"\n class=\"px-3 py-4 text-caption text-muted-foreground text-center\"\n >\n {{ emptyText }}\n </li>\n\n <template\n v-for=\"(group, gi) in groupedOptions\"\n :key=\"group.name ?? gi\"\n >\n <li\n v-if=\"group.name\"\n class=\"px-3 pt-2 pb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground\"\n role=\"presentation\"\n >\n {{ group.name }}\n </li>\n <!--\n `mousedown.prevent` keeps focus in the input while an option is\n picked. There is deliberately no `touchstart.prevent` alongside\n it: cancelling touchstart tells the browser to suppress the\n compatibility mouse events *and* the click for that tap, so on a\n touch device the option became impossible to select at all.\n -->\n <li\n v-for=\"opt in group.items\"\n :id=\"optionDomId(String(opt.value))\"\n :key=\"String(opt.value)\"\n role=\"option\"\n :aria-selected=\"matchedOption?.value === opt.value\"\n :aria-disabled=\"opt.disabled || undefined\"\n :class=\"[\n 'flex items-center gap-2 px-3 py-2 text-body cursor-pointer select-none',\n 'transition-colors duration-fast ease-standard',\n opt.disabled\n ? 'text-muted-foreground/60 cursor-not-allowed'\n : ['text-foreground', optionHover],\n activeValue === opt.value && !opt.disabled ? optionSurface : '',\n matchedOption?.value === opt.value ? 'font-medium' : '',\n ]\"\n @pointerenter=\"setActive(opt.value)\"\n @mousedown.prevent\n @click=\"selectOption(opt)\"\n >\n <component\n :is=\"opt.icon\"\n v-if=\"opt.icon\"\n aria-hidden=\"true\"\n :class=\"['w-4 h-4 shrink-0', affordanceIconClass]\"\n />\n <div class=\"flex-1 min-w-0\">\n <div class=\"truncate\">\n <Highlight :text=\"opt.label\" :query=\"modelValue ?? ''\" />\n </div>\n <div\n v-if=\"opt.description\"\n class=\"text-caption text-muted-foreground truncate\"\n >\n {{ opt.description }}\n </div>\n </div>\n <CheckIcon\n v-if=\"matchedOption?.value === opt.value\"\n :class=\"['w-4 h-4 shrink-0', checkColorClass]\"\n aria-hidden=\"true\"\n />\n </li>\n </template>\n </ul>\n <slot name=\"footer\" />\n </div>\n </PopoverPanel>\n\n <div\n v-if=\"errorText || helperText || showCounterEffective\"\n class=\"flex items-start 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 class=\"flex-1\"\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 class=\"flex-1\"\n >\n {{ helperText }}\n </Typography>\n <p\n v-if=\"showCounterEffective\"\n :id=\"counterId\"\n :class=\"[\n 'text-caption ml-auto tabular-nums',\n counterOverflow ? 'text-destructive' : 'text-muted-foreground',\n ]\"\n >\n {{ currentLength }}/{{ maxLength }}\n </p>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, defineComponent, h, nextTick, ref, useId, watch } from \"vue\";\nimport type {\n Combobox as ComboboxProps,\n SelectOption,\n} from \"../../interfaces/forms/Combobox.interface\";\nimport {\n useFieldState,\n useFieldClasses,\n FIELD_AFFORDANCE_ACTION_BY_COLOR,\n FIELD_AFFORDANCE_ICON_BY_COLOR,\n} from \"../../composables/useField\";\nimport { usePopover } from \"../../composables/usePopover\";\nimport PopoverPanel from \"../layout/PopoverPanel.vue\";\nimport Typography from \"../data-display/Typography.vue\";\nimport Loader from \"../feedback/Loader.vue\";\nimport {\n ChevronDownIcon,\n XMarkIcon,\n CheckIcon,\n} from \"@heroicons/vue/24/outline\";\nimport Button from \"./Button.vue\";\nimport {\n useModoLocale,\n useSizeTokens,\n} from \"../../composables/useModoConfig\";\n\nconst loc = useModoLocale();\n\nconst props = withDefaults(defineProps<ComboboxProps>(), {\n modelValue: \"\",\n options: () => [],\n debounce: 250,\n minChars: 0,\n freeSolo: false,\n variant: \"outline\",\n color: \"default\",\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n clearable: false,\n placeholder: \"Type to search…\",\n emptyText: \"No results.\",\n loadingText: \"Loading…\",\n autofocus: false,\n});\n\nconst sz = useSizeTokens(() => props.size);\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: string];\n change: [value: string, option: SelectOption | null];\n select: [option: SelectOption];\n open: [];\n close: [];\n clear: [];\n search: [query: string];\n}>();\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, {\n componentName: \"Combobox\",\n idPrefix: \"modo-combobox\",\n});\n\nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({\n variant: () => props.variant,\n stateColor,\n hasError,\n radius,\n forceFocus: () => isOpen.value,\n halo: () => props.halo,\n});\n\n/* ---------- IDs ---------- */\nconst autoListboxId = useId();\nconst listboxId = computed(() => `modo-combobox-listbox-${autoListboxId}`);\nconst optionDomId = (v: string) => `${listboxId.value}-opt-${v}`;\n\n/* ---------- Options source (sync or async) ---------- */\n\nconst asyncOptions = ref<SelectOption[]>([]);\nconst isLoadingAsync = ref(false);\nlet loadTimer: number | null = null;\nlet loadRequestId = 0;\n\nwatch(\n () => props.modelValue,\n (q) => {\n if (!props.loadOptions) return;\n if (!isOpen.value) return;\n if ((q ?? \"\").length < props.minChars) {\n asyncOptions.value = [];\n return;\n }\n if (loadTimer !== null) clearTimeout(loadTimer);\n isLoadingAsync.value = true;\n const reqId = ++loadRequestId;\n loadTimer = window.setTimeout(async () => {\n try {\n const result = await props.loadOptions!(q ?? \"\");\n if (reqId === loadRequestId) asyncOptions.value = result;\n } finally {\n if (reqId === loadRequestId) isLoadingAsync.value = false;\n }\n emit(\"search\", q ?? \"\");\n }, props.debounce);\n },\n);\n\nconst sourceOptions = computed(() =>\n props.loadOptions ? asyncOptions.value : props.options,\n);\n\nconst displayedOptions = computed(() => {\n const q = (props.modelValue ?? \"\").trim().toLowerCase();\n // Si hay loadOptions, no filtramos localmente (confiamos en el backend).\n if (props.loadOptions) return sourceOptions.value;\n if (!q) return sourceOptions.value;\n return sourceOptions.value.filter(\n (o) =>\n o.label.toLowerCase().includes(q) ||\n (o.description ? o.description.toLowerCase().includes(q) : false),\n );\n});\n\ninterface OptionGroup {\n name?: string;\n items: SelectOption[];\n}\n\nconst groupedOptions = computed<OptionGroup[]>(() => {\n const list = displayedOptions.value;\n if (!list.some((o) => o.group)) {\n return list.length ? [{ items: list }] : [];\n }\n const map = new Map<string | undefined, SelectOption[]>();\n for (const opt of list) {\n const key = opt.group;\n if (!map.has(key)) map.set(key, []);\n map.get(key)!.push(opt);\n }\n const groups: OptionGroup[] = [];\n for (const [name, items] of map) groups.push({ name, items });\n return groups;\n});\n\nconst flatOptions = computed<SelectOption[]>(() =>\n groupedOptions.value.flatMap((g) => g.items),\n);\n\n/** Si el texto actual coincide exactamente (case-insensitive) con alguna opción, la devuelve. */\nconst matchedOption = computed<SelectOption | null>(() => {\n const v = (props.modelValue ?? \"\").trim().toLowerCase();\n if (!v) return null;\n return sourceOptions.value.find((o) => o.label.toLowerCase() === v) ?? null;\n});\n\n/* ---------- Color ---------- */\nconst CHECK_COLOR_BY_STATE: Record<string, string> = {\n default: \"text-foreground\",\n primary: \"text-primary\",\n danger: \"text-destructive\",\n success: \"text-success\",\n warning: \"text-warning\",\n};\nconst checkColorClass = computed(\n () => CHECK_COLOR_BY_STATE[stateColor.value] ?? \"text-foreground\",\n);\nconst affordanceIconClass = computed(\n () =>\n FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? \"text-muted-foreground\",\n);\nconst affordanceActionClass = computed(\n () =>\n FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ??\n \"text-muted-foreground hover:text-foreground\",\n);\n\nconst OPTION_SURFACE: Record<string, string> = {\n default: \"bg-muted\",\n primary: \"bg-primary/10\",\n danger: \"bg-destructive/10\",\n success: \"bg-success/10\",\n warning: \"bg-warning/10\",\n};\nconst OPTION_HOVER: Record<string, string> = {\n default: \"hover:bg-muted\",\n primary: \"hover:bg-primary/10\",\n danger: \"hover:bg-destructive/10\",\n success: \"hover:bg-success/10\",\n warning: \"hover:bg-warning/10\",\n};\nconst optionSurface = computed(\n () => OPTION_SURFACE[stateColor.value] ?? \"bg-muted\",\n);\nconst optionHover = computed(\n () => OPTION_HOVER[stateColor.value] ?? \"hover:bg-muted\",\n);\n\n/* ---------- Popover ---------- */\n\nconst inputEl = ref<HTMLInputElement | null>(null);\nconst wrapperEl = ref<HTMLElement | null>(null);\nconst activeValue = ref<string | number | null>(null);\nconst activeId = computed(() =>\n activeValue.value !== null ? optionDomId(String(activeValue.value)) : \"\",\n);\n\nconst {\n triggerRef,\n panelRef,\n isOpen,\n panelStyle,\n open: openPopover,\n close: closePopover,\n} = usePopover({\n placement: \"bottom-start\",\n matchTriggerWidth: true,\n // Reposition on scroll instead of closing. Focus is what opens this panel,\n // and focusing a text field is itself a scroll trigger: on mobile the virtual\n // keyboard appears and the browser scrolls the field into view a few frames\n // after the panel opened, which closed the dropdown before the user could\n // ever see it. Typing reopened it — by then the keyboard was already up and\n // no further scroll followed — which is why the list only appeared after the\n // first keystroke. Same reasoning as SearchInput.\n closeOnScroll: false,\n onOpen: () => {\n emit(\"open\");\n const initial =\n matchedOption.value ?? flatOptions.value.find((o) => !o.disabled);\n activeValue.value = initial ? initial.value : null;\n nextTick(scrollActiveIntoView);\n },\n onClose: () => {\n emit(\"close\");\n },\n});\n\nwatch(wrapperEl, (el) => (triggerRef.value = el));\n\nfunction setActive(v: string | number) {\n activeValue.value = v;\n}\n\nfunction scrollActiveIntoView() {\n if (activeValue.value === null) return;\n const el = document.getElementById(optionDomId(String(activeValue.value)));\n el?.scrollIntoView({ block: \"nearest\" });\n}\n\n/* ---------- Actions ---------- */\n\nfunction onInput(e: Event) {\n const next = (e.target as HTMLInputElement).value;\n emit(\"update:modelValue\", next);\n if (!isOpen.value) openPopover();\n // Activar la primera opción tras filtrar\n nextTick(() => {\n const first = flatOptions.value.find((o) => !o.disabled);\n activeValue.value = first ? first.value : null;\n });\n}\n\nfunction onFocus() {\n if (isDisabled.value || props.readonly) return;\n if (!isOpen.value) openPopover();\n}\n\nfunction onBlur() {\n // Delay para permitir el click en la opción (mousedown.prevent también ayuda).\n setTimeout(() => {\n // Si no es freeSolo y no hay match, resetea al último match válido (o vacío)\n if (!props.freeSolo) {\n const current = (props.modelValue ?? \"\").trim();\n if (current && !matchedOption.value) {\n // Revertir al label de la opción previa si había una\n emit(\"update:modelValue\", lastCommittedValue.value);\n }\n }\n closePopover();\n }, 120);\n}\n\nfunction onToggleClick() {\n if (isDisabled.value || props.readonly) return;\n if (isOpen.value) {\n closePopover();\n inputEl.value?.blur();\n } else {\n inputEl.value?.focus();\n }\n}\n\nconst lastCommittedValue = ref<string>(props.modelValue ?? \"\");\n\nfunction commit(value: string, opt: SelectOption | null) {\n lastCommittedValue.value = value;\n emit(\"update:modelValue\", value);\n emit(\"change\", value, opt);\n}\n\nfunction selectOption(opt: SelectOption) {\n if (opt.disabled) return;\n commit(opt.label, opt);\n emit(\"select\", opt);\n closePopover();\n inputEl.value?.blur();\n}\n\nfunction clear() {\n commit(\"\", null);\n emit(\"clear\");\n inputEl.value?.focus();\n}\n\n/* ---------- Keyboard ---------- */\n\nfunction moveActive(direction: 1 | -1) {\n const list = flatOptions.value.filter((o) => !o.disabled);\n if (list.length === 0) return;\n const currentIdx = list.findIndex((o) => o.value === activeValue.value);\n let nextIdx: number;\n if (currentIdx === -1) {\n nextIdx = direction > 0 ? 0 : list.length - 1;\n } else {\n nextIdx = (currentIdx + direction + list.length) % list.length;\n }\n activeValue.value = list[nextIdx].value;\n scrollActiveIntoView();\n}\n\nfunction onKeydown(e: KeyboardEvent) {\n if (isDisabled.value || props.readonly) return;\n switch (e.key) {\n case \"ArrowDown\":\n e.preventDefault();\n if (!isOpen.value) openPopover();\n moveActive(1);\n break;\n case \"ArrowUp\":\n e.preventDefault();\n if (!isOpen.value) openPopover();\n moveActive(-1);\n break;\n case \"Enter\": {\n if (!isOpen.value) return;\n const opt = flatOptions.value.find((o) => o.value === activeValue.value);\n if (opt && !opt.disabled) {\n e.preventDefault();\n selectOption(opt);\n } else if (props.freeSolo) {\n e.preventDefault();\n commit(props.modelValue ?? \"\", null);\n // Keep panel open so the user sees the new value added to the list.\n // closePopover();\n }\n break;\n }\n case \"Escape\":\n if (isOpen.value) {\n e.preventDefault();\n closePopover();\n }\n break;\n case \"Tab\":\n // Dejar que Tab cierre naturalmente vía blur.\n break;\n }\n}\n\n/* ---------- Size maps ---------- */\n\nconst wrapperSizeClasses = computed(() => `${sz.value.control} ${sz.value.padX}`);\nconst inputTextClasses = computed(() => sz.value.text);\nconst iconSizeClasses = computed(() => sz.value.icon);\n\n/* ---------- Inline highlight helper ---------- */\nconst Highlight = defineComponent({\n name: \"ComboboxHighlight\",\n props: {\n text: { type: String, required: true },\n query: { type: String, required: true },\n },\n setup(p) {\n return () => {\n const q = (p.query ?? \"\").trim();\n if (!q) return h(\"span\", p.text);\n const idx = p.text.toLowerCase().indexOf(q.toLowerCase());\n if (idx === -1) return h(\"span\", p.text);\n const before = p.text.slice(0, idx);\n const match = p.text.slice(idx, idx + q.length);\n const after = p.text.slice(idx + q.length);\n return h(\"span\", [\n before,\n h(\n \"span\",\n {\n class:\n \"font-semibold text-foreground bg-primary/10 rounded-sm px-0.5\",\n },\n match,\n ),\n after,\n ]);\n };\n },\n});\n\n/* ---------- Sync committed value when controlling v-model externally ---------- */\nwatch(\n () => props.modelValue,\n (v) => {\n if (matchedOption.value) lastCommittedValue.value = v ?? \"\";\n },\n);\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6QA,MAAM,MAAM,eAAe;EAE3B,MAAM,QAAQ;EAoBd,MAAM,KAAK,oBAAoB,MAAM,KAAK;EAE1C,MAAM,OAAO;EAUb,MAAM,EACJ,SACA,QACA,YACA,UACA,UACA,YACA,eACA,sBACA,iBACA,SACA,UACA,WACA,gBACE,cAAc,OAAO;GACvB,eAAe;GACf,UAAU;GACX,CAAC;EAEF,MAAM,EAAE,uBAAuB,kBAAkB,gBAAgB;GAC/D,eAAe,MAAM;GACrB;GACA;GACA;GACA,kBAAkB,OAAO;GACzB,YAAY,MAAM;GACnB,CAAC;EAGF,MAAM,gBAAgB,OAAO;EAC7B,MAAM,YAAY,eAAe,yBAAyB,gBAAgB;EAC1E,MAAM,eAAe,MAAc,GAAG,UAAU,MAAM,OAAO;EAI7D,MAAM,eAAe,IAAoB,EAAE,CAAC;EAC5C,MAAM,iBAAiB,IAAI,MAAM;EACjC,IAAI,YAA2B;EAC/B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,QAAO;KACZ,SAAQ;KACR,MAAK;KACL,OAAM;KACN,IAAG;KACH,OAAM;;4BAES,CAAA,gBAAA,gBAAZ,QAAA,UAAS,EAAA,EAAA,CAAA,CAAA;;qBAGD,QAAA,cAAA,WAAA,EADb,YAUa,oBAAA;;KARV,IAAI,MAAA,SAAQ;KACb,SAAQ;KACR,MAAK;KACL,OAAM;KACN,IAAG;KACH,OAAM;;4BAEU,CAAA,gBAAA,gBAAb,QAAA,WAAU,EAAA,EAAA,CAAA,CAAA;;mDAGP,MAAA,qBAAoB,IAAA,WAAA,EAD5B,mBASI,KAAA;;KAPD,IAAI,MAAA,UAAS;KACb,OAAK,eAAA,CAAA,qCAA6D,MAAA,gBAAe,GAAA,qBAAA,wBAAA,CAAA;uBAK/E,MAAA,cAAa,CAAA,GAAG,MAAC,gBAAG,QAAA,UAAS,EAAA,IAAA,YAAA,IAAA,mBAAA,IAAA,KAAA,CAAA,CAAA,IAAA,mBAAA,IAAA,KAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneInput.cjs","names":[],"sources":["../../../src/components/forms/PhoneInput.vue"],"sourcesContent":["<template>\n <div :class=\"['flex flex-col gap-1.5', fullWidth ? 'w-full' : 'inline-flex']\">\n <!-- Label -->\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\"\n >*</span\n >\n </label>\n\n <!-- Unified field wrapper -->\n <div\n ref=\"wrapperEl\"\n :class=\"[\n 'modo-field-wrapper flex items-center overflow-hidden',\n wrapperVariantClasses,\n wrapperHeightClass,\n radiusClasses,\n fullWidth ? 'w-full' : '',\n isDisabled ? 'opacity-60 cursor-not-allowed' : '',\n ]\"\n >\n <!-- Country selector trigger -->\n <button\n ref=\"triggerRef\"\n type=\"button\"\n :disabled=\"isDisabled || readonly\"\n :aria-label=\"loc.phoneInput.selectCountry\"\n :aria-expanded=\"isOpen\"\n :aria-haspopup=\"'listbox'\"\n :class=\"[\n 'flex items-center self-stretch shrink-0 select-none',\n 'transition-colors duration-fast ease-standard',\n triggerPaddingClass,\n isDisabled || readonly ? 'cursor-not-allowed' : 'cursor-pointer',\n ]\"\n @click=\"onTriggerClick\"\n @keydown=\"onTriggerKeydown\"\n >\n <span\n aria-hidden=\"true\"\n :class=\"['leading-none shrink-0', flagSizeClass]\"\n >\n {{ selectedCountry ? countryFlag(selectedCountry.iso) : \"🌐\" }}\n </span>\n <span\n :class=\"[\n 'tabular-nums text-muted-foreground font-medium shrink-0',\n triggerTextClass,\n ]\"\n >\n +{{ selectedCountry?.dial ?? \"?\" }}\n </span>\n <ChevronDownIcon\n aria-hidden=\"true\"\n :class=\"[\n 'shrink-0 transition-transform duration-base ease-standard',\n affordanceIconClass,\n chevronSizeClass,\n isOpen ? 'rotate-180' : '',\n ]\"\n />\n </button>\n\n <!-- Vertical divider -->\n <div aria-hidden=\"true\" class=\"w-px self-stretch bg-border shrink-0\" />\n\n <!-- Phone number input -->\n <input\n :id=\"fieldId\"\n ref=\"inputRef\"\n type=\"tel\"\n inputmode=\"tel\"\n :value=\"localNumber\"\n :placeholder=\"placeholder ?? ''\"\n :disabled=\"isDisabled\"\n :readonly=\"readonly\"\n :required=\"required\"\n :name=\"name ? `${name}-local` : undefined\"\n :autocomplete=\"autocomplete ?? 'tel-national'\"\n :autofocus=\"autofocus\"\n :aria-label=\"!label ? (ariaLabel ?? undefined) : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-describedby=\"describedBy\"\n :aria-required=\"required || undefined\"\n :class=\"[\n 'modo-field-native flex-1 min-w-0 bg-transparent',\n 'text-foreground placeholder:text-muted-foreground',\n 'disabled:cursor-not-allowed',\n inputTextClass,\n inputPaddingClass,\n ]\"\n @input=\"onInput\"\n @change=\"onChange\"\n @focus=\"$emit('focus', $event)\"\n @blur=\"$emit('blur', $event)\"\n />\n\n <!-- Loading spinner -->\n <Loader\n v-if=\"loading\"\n :size=\"resolvedSize === 'large' ? 'medium' : 'small'\"\n :class=\"['shrink-0', affordanceIconClass]\"\n />\n </div>\n\n <!-- Hidden input carrying the full formatted value for form submission -->\n <input v-if=\"name\" type=\"hidden\" :name=\"name\" :value=\"currentFormValue\" />\n\n <!-- Error / helper text -->\n <div v-if=\"errorText || helperText\" class=\"flex items-start gap-2\">\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 </div>\n\n <!-- Country dropdown -->\n <PopoverPanel\n :open=\"isOpen\"\n :style=\"mergedPanelStyle\"\n :radius=\"radius\"\n role=\"listbox\"\n :labelledBy=\"fieldId\"\n @update:panelRef=\"panelRef = $event\"\n >\n <div style=\"max-height: 296px\" class=\"flex flex-col\">\n <!-- Search input -->\n <div class=\"px-3 border-b border-border shrink-0\">\n <div class=\"flex items-center gap-2 h-7\">\n <MagnifyingGlassIcon\n class=\"w-4 h-4 shrink-0 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n <input\n ref=\"searchEl\"\n v-model=\"searchQuery\"\n type=\"text\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n :placeholder=\"loc.phoneInput.searchCountry\"\n class=\"modo-field-native flex-1 min-w-0 bg-transparent p-0 text-caption text-foreground placeholder:text-muted-foreground\"\n @keydown=\"onSearchKeydown\"\n />\n <Button\n v-if=\"searchQuery\"\n variant=\"text\"\n size=\"xs\"\n radius=\"full\"\n :icon=\"XMarkIcon\"\n :ariaLabel=\"loc.common.clear\"\n tabindex=\"-1\"\n :class=\"['shrink-0', affordanceActionClass]\"\n @click=\"searchQuery = ''\"\n />\n </div>\n </div>\n\n <!-- Countries list -->\n <ul\n ref=\"listEl\"\n role=\"listbox\"\n class=\"modo-stagger flex-1 overflow-y-auto w-full\"\n style=\"min-height: 2.5rem\"\n tabindex=\"-1\"\n >\n <li\n v-if=\"filteredCountries.length === 0\"\n class=\"px-3 py-4 text-caption text-muted-foreground text-center\"\n >\n {{ loc.phoneInput.noResults }}\n </li>\n <li\n v-for=\"(c, i) in filteredCountries\"\n :key=\"c.iso\"\n :id=\"optionId(c.iso)\"\n role=\"option\"\n :aria-selected=\"c.iso === activeIso\"\n :class=\"[\n 'flex items-center gap-2.5 px-3 py-2 text-body cursor-pointer select-none',\n 'transition-colors duration-fast ease-standard',\n ['text-foreground', optionHover],\n i === activeIndex ? optionSurface : '',\n c.iso === activeIso ? 'font-medium' : '',\n ]\"\n @pointerenter=\"activeIndex = i\"\n @click=\"selectCountry(c)\"\n >\n <span aria-hidden=\"true\" class=\"text-base leading-none shrink-0\">\n {{ countryFlag(c.iso) }}\n </span>\n <span class=\"flex-1 min-w-0 truncate text-foreground\">{{\n c.name\n }}</span>\n <span\n class=\"shrink-0 tabular-nums text-muted-foreground text-[11px]\"\n >\n +{{ c.dial }}\n </span>\n <CheckIcon\n v-if=\"c.iso === activeIso\"\n :class=\"['w-4 h-4 shrink-0', checkColorClass]\"\n aria-hidden=\"true\"\n />\n </li>\n </ul>\n </div>\n </PopoverPanel>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, nextTick, ref, useId, watch } from \"vue\";\nimport type { PhoneInput } from \"../../interfaces/forms/PhoneInput.interface\";\nimport {\n PHONE_COUNTRIES,\n countryFlag,\n findCountryByIso,\n type PhoneCountry,\n} from \"../../data/phoneCountries\";\nimport {\n useFieldState,\n useFieldClasses,\n FIELD_AFFORDANCE_ICON_BY_COLOR,\n FIELD_AFFORDANCE_ACTION_BY_COLOR,\n} from \"../../composables/useField\";\nimport { usePopover } from \"../../composables/usePopover\";\nimport {\n useResolvedSize,\n useSizeTokens,\n useModoLocale,\n} from \"../../composables/useModoConfig\";\nimport PopoverPanel from \"../layout/PopoverPanel.vue\";\nimport Typography from \"../data-display/Typography.vue\";\nimport Loader from \"../feedback/Loader.vue\";\nimport Button from \"./Button.vue\";\nimport {\n ChevronDownIcon,\n MagnifyingGlassIcon,\n XMarkIcon,\n CheckIcon,\n} from \"@heroicons/vue/24/outline\";\n\nconst loc = useModoLocale();\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: string];\n \"update:country\": [iso: string];\n change: [value: string];\n focus: [event: FocusEvent];\n blur: [event: FocusEvent];\n}>();\n\nconst props = withDefaults(defineProps<PhoneInput>(), {\n defaultCountry: \"US\",\n format: \"national\",\n variant: \"outline\",\n color: \"default\",\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n autofocus: false,\n});\n\nconst resolvedSize = useResolvedSize(() => props.size);\nconst sz = useSizeTokens(() => props.size);\n\n// ── Refs ──────────────────────────────────────────────────────────────────────\nconst inputRef = ref<HTMLInputElement | null>(null);\nconst searchEl = ref<HTMLInputElement | null>(null);\nconst listEl = ref<HTMLElement | null>(null);\nconst wrapperEl = ref<HTMLElement | null>(null);\nconst dropdownWidth = ref(\"\");\n\n// ── Internal state ────────────────────────────────────────────────────────────\nconst localNumber = ref(\"\");\nconst internalCountry = ref((props.defaultCountry ?? \"US\").toUpperCase());\n\n// ── Field state ───────────────────────────────────────────────────────────────\nconst {\n fieldId,\n radius,\n stateColor,\n hasError,\n isDisabled,\n errorId,\n helperId,\n describedBy,\n} = useFieldState(props, {\n componentName: \"PhoneInput\",\n idPrefix: \"modo-phone\",\n});\n\nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({\n variant: () => props.variant,\n stateColor,\n hasError,\n radius,\n forceFocus: () => isOpen.value,\n halo: () => props.halo,\n});\n\n// ── Country resolution ────────────────────────────────────────────────────────\nconst activeIso = computed(() =>\n (props.country !== undefined\n ? props.country\n : internalCountry.value\n ).toUpperCase(),\n);\nconst selectedCountry = computed(() => findCountryByIso(activeIso.value));\n\n// ── Format helpers ────────────────────────────────────────────────────────────\nfunction buildValue(local: string, dialCode: string): string {\n const fmt = props.format ?? \"national\";\n if (fmt === \"e164\") return `+${dialCode}${local.replace(/\\D/g, \"\")}`;\n if (fmt === \"international\") return `+${dialCode}${local}`;\n return local;\n}\n\nfunction extractNational(v: string | undefined, dialCode: string): string {\n if (!v) return \"\";\n const prefix = `+${dialCode}`;\n if (v.startsWith(prefix)) return v.slice(prefix.length);\n return v;\n}\n\nconst currentFormValue = computed(() =>\n selectedCountry.value\n ? buildValue(localNumber.value, selectedCountry.value.dial)\n : localNumber.value,\n);\n\n// Sync external modelValue → localNumber\nwatch(\n () => props.modelValue,\n (v) => {\n const dial = selectedCountry.value?.dial ?? \"\";\n const national = extractNational(v, dial);\n if (national !== localNumber.value) localNumber.value = national;\n },\n { immediate: true },\n);\n\n// ── Popover ───────────────────────────────────────────────────────────────────\nconst {\n triggerRef,\n panelRef,\n isOpen,\n panelStyle,\n open: openPopover,\n close: closePopover,\n toggle: togglePopover,\n} = usePopover({\n placement: \"bottom-start\",\n onOpen: () => {\n dropdownWidth.value = wrapperEl.value\n ? `${wrapperEl.value.getBoundingClientRect().width}px`\n : \"260px\";\n searchQuery.value = \"\";\n activeIndex.value = Math.max(\n 0,\n filteredCountries.value.findIndex((c) => c.iso === activeIso.value),\n );\n nextTick(() => {\n searchEl.value?.focus();\n scrollActiveIntoView();\n });\n },\n onClose: () => {\n searchQuery.value = \"\";\n activeIndex.value = -1;\n },\n});\n\nconst mergedPanelStyle = computed(() => ({\n ...panelStyle.value,\n ...(dropdownWidth.value ? { width: dropdownWidth.value } : {}),\n}));\n\n// ── Search + filtered list ────────────────────────────────────────────────────\nconst searchQuery = ref(\"\");\nconst activeIndex = ref(-1);\nconst autoListboxId = useId();\n\nconst optionId = (iso: string) =>\n `modo-phone-listbox-${autoListboxId}-opt-${iso}`;\n\nconst filteredCountries = computed<PhoneCountry[]>(() => {\n const q = searchQuery.value.trim().toLowerCase();\n if (!q) return PHONE_COUNTRIES as unknown as PhoneCountry[];\n return (PHONE_COUNTRIES as unknown as PhoneCountry[]).filter(\n (c) =>\n c.name.toLowerCase().includes(q) ||\n c.iso.toLowerCase().includes(q) ||\n c.dial.startsWith(q.replace(/^\\+/, \"\")),\n );\n});\n\nwatch(filteredCountries, (list) => {\n const idx = list.findIndex((c) => c.iso === activeIso.value);\n activeIndex.value = idx >= 0 ? idx : 0;\n});\n\n// ── Option styles ─────────────────────────────────────────────────────────────\nconst OPTION_SURFACE: Record<string, string> = {\n default: \"bg-muted\",\n primary: \"bg-primary/10\",\n danger: \"bg-destructive/10\",\n success: \"bg-success/10\",\n warning: \"bg-warning/10\",\n};\nconst OPTION_HOVER: Record<string, string> = {\n default: \"hover:bg-muted\",\n primary: \"hover:bg-primary/10\",\n danger: \"hover:bg-destructive/10\",\n success: \"hover:bg-success/10\",\n warning: \"hover:bg-warning/10\",\n};\nconst optionSurface = computed(\n () => OPTION_SURFACE[stateColor.value] ?? \"bg-muted\",\n);\nconst optionHover = computed(\n () => OPTION_HOVER[stateColor.value] ?? \"hover:bg-muted\",\n);\nconst CHECK_COLOR_BY_STATE: Record<string, string> = {\n default: \"text-foreground\",\n primary: \"text-primary\",\n danger: \"text-destructive\",\n success: \"text-success\",\n warning: \"text-warning\",\n};\nconst checkColorClass = computed(\n () => CHECK_COLOR_BY_STATE[stateColor.value] ?? \"text-foreground\",\n);\nconst affordanceIconClass = computed(\n () =>\n FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? \"text-muted-foreground\",\n);\nconst affordanceActionClass = computed(\n () =>\n FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ??\n \"text-muted-foreground hover:text-foreground\",\n);\n\n// ── Size classes ──────────────────────────────────────────────────────────────\nconst wrapperHeightClass = computed(() => {\n // sz.value.padX is e.g. \"px-2.5\" — convert to pr-* for the wrapper right edge\n const pr = sz.value.padX.replace(\"px-\", \"pr-\");\n return `${sz.value.control} ${pr}`;\n});\n\nconst triggerPaddingClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"pl-2.5 pr-1.5 gap-1\";\n case \"large\":\n return \"pl-4 pr-2 gap-1.5\";\n default:\n return \"pl-3 pr-2 gap-1\";\n }\n});\n\nconst flagSizeClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"text-sm\";\n case \"large\":\n return \"text-xl\";\n default:\n return \"text-base\";\n }\n});\n\nconst triggerTextClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"text-[11px]\";\n case \"large\":\n return \"text-body\";\n default:\n return \"text-caption\";\n }\n});\n\nconst chevronSizeClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"w-3 h-3\";\n case \"large\":\n return \"w-4 h-4\";\n default:\n return \"w-3.5 h-3.5\";\n }\n});\n\nconst inputTextClass = computed(() => sz.value.text);\n\nconst inputPaddingClass = computed(() => {\n // pr-3 leaves a comfortable gap on the right edge as well; the\n // legacy showroom relied on the field-native default padding which\n // we override here. Without pl-3 numbers visually butt up against\n // the country trigger divider.\n return \"pl-3 pr-3\";\n});\n\n// ── Event handlers ────────────────────────────────────────────────────────────\nfunction onInput(e: Event) {\n const val = (e.target as HTMLInputElement).value;\n localNumber.value = val;\n emit(\"update:modelValue\", buildValue(val, selectedCountry.value?.dial ?? \"\"));\n}\n\nfunction onChange(e: Event) {\n const val = (e.target as HTMLInputElement).value;\n emit(\"change\", buildValue(val, selectedCountry.value?.dial ?? \"\"));\n}\n\nfunction selectCountry(c: PhoneCountry) {\n if (props.country === undefined) internalCountry.value = c.iso;\n emit(\"update:country\", c.iso);\n emit(\"update:modelValue\", buildValue(localNumber.value, c.dial));\n closePopover();\n nextTick(() => inputRef.value?.focus());\n}\n\nfunction onTriggerClick() {\n if (isDisabled.value || props.readonly) return;\n togglePopover();\n}\n\nfunction onTriggerKeydown(e: KeyboardEvent) {\n if (isDisabled.value || props.readonly) return;\n if (e.key === \"ArrowDown\" || e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n if (!isOpen.value) openPopover();\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n closePopover();\n }\n}\n\nfunction onSearchKeydown(e: KeyboardEvent) {\n const list = filteredCountries.value;\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n activeIndex.value = Math.min(activeIndex.value + 1, list.length - 1);\n scrollActiveIntoView();\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n activeIndex.value = Math.max(activeIndex.value - 1, 0);\n scrollActiveIntoView();\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n const c = list[activeIndex.value];\n if (c) selectCountry(c);\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n closePopover();\n triggerRef.value?.focus?.();\n } else if (e.key === \"Tab\") {\n closePopover();\n }\n}\n\nfunction scrollActiveIntoView() {\n nextTick(() => {\n const c = filteredCountries.value[activeIndex.value];\n if (!c || !listEl.value) return;\n const el = document.getElementById(optionId(c.iso));\n el?.scrollIntoView({ block: \"nearest\" });\n });\n}\n\n// ── Expose ────────────────────────────────────────────────────────────────────\ndefineExpose({\n focus: () => inputRef.value?.focus(),\n blur: () => inputRef.value?.blur(),\n inputRef,\n});\n</script>\n"],"mappings":""}
1
+ {"version":3,"file":"PhoneInput.cjs","names":[],"sources":["../../../src/components/forms/PhoneInput.vue"],"sourcesContent":["<template>\n <div :class=\"['flex flex-col gap-1.5', fullWidth ? 'w-full' : 'inline-flex']\">\n <!-- Label -->\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\"\n >*</span\n >\n </label>\n\n <!-- Unified field wrapper -->\n <div\n ref=\"wrapperEl\"\n :class=\"[\n 'modo-field-wrapper flex items-center overflow-hidden',\n wrapperVariantClasses,\n wrapperHeightClass,\n radiusClasses,\n fullWidth ? 'w-full' : '',\n isDisabled ? 'opacity-60 cursor-not-allowed' : '',\n ]\"\n >\n <!-- Country selector trigger -->\n <button\n ref=\"triggerRef\"\n type=\"button\"\n :disabled=\"isDisabled || readonly\"\n :aria-label=\"loc.phoneInput.selectCountry\"\n :aria-expanded=\"isOpen\"\n :aria-haspopup=\"'listbox'\"\n :class=\"[\n 'flex items-center self-stretch shrink-0 select-none',\n 'transition-colors duration-fast ease-standard',\n triggerPaddingClass,\n isDisabled || readonly ? 'cursor-not-allowed' : 'cursor-pointer',\n ]\"\n @click=\"onTriggerClick\"\n @keydown=\"onTriggerKeydown\"\n >\n <span\n aria-hidden=\"true\"\n :class=\"['leading-none shrink-0', flagSizeClass]\"\n >\n {{ selectedCountry ? countryFlag(selectedCountry.iso) : \"🌐\" }}\n </span>\n <span\n :class=\"[\n 'tabular-nums text-muted-foreground font-medium shrink-0',\n triggerTextClass,\n ]\"\n >\n +{{ selectedCountry?.dial ?? \"?\" }}\n </span>\n <ChevronDownIcon\n aria-hidden=\"true\"\n :class=\"[\n 'shrink-0 transition-transform duration-base ease-standard',\n affordanceIconClass,\n chevronSizeClass,\n isOpen ? 'rotate-180' : '',\n ]\"\n />\n </button>\n\n <!-- Vertical divider -->\n <div aria-hidden=\"true\" class=\"w-px self-stretch bg-border shrink-0\" />\n\n <!-- Phone number input -->\n <input\n :id=\"fieldId\"\n ref=\"inputRef\"\n type=\"tel\"\n inputmode=\"tel\"\n :value=\"localNumber\"\n :placeholder=\"placeholder ?? ''\"\n :disabled=\"isDisabled\"\n :readonly=\"readonly\"\n :required=\"required\"\n :name=\"name ? `${name}-local` : undefined\"\n :autocomplete=\"autocomplete ?? 'tel-national'\"\n :autofocus=\"autofocus\"\n :aria-label=\"!label ? (ariaLabel ?? undefined) : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-describedby=\"describedBy\"\n :aria-required=\"required || undefined\"\n :class=\"[\n 'modo-field-native flex-1 min-w-0 bg-transparent',\n 'text-foreground placeholder:text-muted-foreground',\n 'disabled:cursor-not-allowed',\n inputTextClass,\n inputPaddingClass,\n ]\"\n @input=\"onInput\"\n @change=\"onChange\"\n @focus=\"$emit('focus', $event)\"\n @blur=\"$emit('blur', $event)\"\n />\n\n <!-- Loading spinner -->\n <Loader\n v-if=\"loading\"\n :size=\"resolvedSize === 'large' ? 'medium' : 'small'\"\n :class=\"['shrink-0', affordanceIconClass]\"\n />\n </div>\n\n <!-- Hidden input carrying the full formatted value for form submission -->\n <input v-if=\"name\" type=\"hidden\" :name=\"name\" :value=\"currentFormValue\" />\n\n <!-- Error / helper text -->\n <div v-if=\"errorText || helperText\" class=\"flex items-start gap-2\">\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 </div>\n\n <!-- Country dropdown -->\n <PopoverPanel\n :open=\"isOpen\"\n :style=\"mergedPanelStyle\"\n :radius=\"radius\"\n role=\"listbox\"\n :labelledBy=\"fieldId\"\n @update:panelRef=\"panelRef = $event\"\n >\n <div style=\"max-height: 296px\" class=\"flex flex-col\">\n <!-- Search input -->\n <div class=\"px-3 border-b border-border shrink-0\">\n <div class=\"flex items-center gap-2 h-7\">\n <MagnifyingGlassIcon\n class=\"w-4 h-4 shrink-0 text-muted-foreground\"\n aria-hidden=\"true\"\n />\n <input\n ref=\"searchEl\"\n v-model=\"searchQuery\"\n type=\"text\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n :placeholder=\"loc.phoneInput.searchCountry\"\n class=\"modo-field-native flex-1 min-w-0 bg-transparent p-0 text-caption text-foreground placeholder:text-muted-foreground\"\n @keydown=\"onSearchKeydown\"\n />\n <Button\n v-if=\"searchQuery\"\n variant=\"text\"\n size=\"xs\"\n radius=\"full\"\n :icon=\"XMarkIcon\"\n :ariaLabel=\"loc.common.clear\"\n tabindex=\"-1\"\n :class=\"['shrink-0', affordanceActionClass]\"\n @click=\"searchQuery = ''\"\n />\n </div>\n </div>\n\n <!-- Countries list -->\n <ul\n ref=\"listEl\"\n role=\"listbox\"\n class=\"modo-stagger flex-1 overflow-y-auto w-full\"\n style=\"min-height: 2.5rem\"\n tabindex=\"-1\"\n >\n <li\n v-if=\"filteredCountries.length === 0\"\n class=\"px-3 py-4 text-caption text-muted-foreground text-center\"\n >\n {{ loc.phoneInput.noResults }}\n </li>\n <li\n v-for=\"(c, i) in filteredCountries\"\n :key=\"c.iso\"\n :id=\"optionId(c.iso)\"\n role=\"option\"\n :aria-selected=\"c.iso === activeIso\"\n :class=\"[\n 'flex items-center gap-2.5 px-3 py-2 text-body cursor-pointer select-none',\n 'transition-colors duration-fast ease-standard',\n ['text-foreground', optionHover],\n i === activeIndex ? optionSurface : '',\n c.iso === activeIso ? 'font-medium' : '',\n ]\"\n @pointerenter=\"activeIndex = i\"\n @click=\"selectCountry(c)\"\n >\n <span aria-hidden=\"true\" class=\"text-base leading-none shrink-0\">\n {{ countryFlag(c.iso) }}\n </span>\n <span class=\"flex-1 min-w-0 truncate text-foreground\">{{\n c.name\n }}</span>\n <span\n class=\"shrink-0 tabular-nums text-muted-foreground text-[11px]\"\n >\n +{{ c.dial }}\n </span>\n <CheckIcon\n v-if=\"c.iso === activeIso\"\n :class=\"['w-4 h-4 shrink-0', checkColorClass]\"\n aria-hidden=\"true\"\n />\n </li>\n </ul>\n </div>\n </PopoverPanel>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, nextTick, ref, useId, watch } from \"vue\";\nimport type { PhoneInput } from \"../../interfaces/forms/PhoneInput.interface\";\nimport {\n PHONE_COUNTRIES,\n countryFlag,\n findCountryByIso,\n type PhoneCountry,\n} from \"../../data/phoneCountries\";\nimport {\n useFieldState,\n useFieldClasses,\n FIELD_AFFORDANCE_ICON_BY_COLOR,\n FIELD_AFFORDANCE_ACTION_BY_COLOR,\n} from \"../../composables/useField\";\nimport { usePopover } from \"../../composables/usePopover\";\nimport {\n useResolvedSize,\n useSizeTokens,\n useModoLocale,\n} from \"../../composables/useModoConfig\";\nimport PopoverPanel from \"../layout/PopoverPanel.vue\";\nimport Typography from \"../data-display/Typography.vue\";\nimport Loader from \"../feedback/Loader.vue\";\nimport Button from \"./Button.vue\";\nimport {\n ChevronDownIcon,\n MagnifyingGlassIcon,\n XMarkIcon,\n CheckIcon,\n} from \"@heroicons/vue/24/outline\";\n\nconst loc = useModoLocale();\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: string];\n \"update:country\": [iso: string];\n change: [value: string];\n focus: [event: FocusEvent];\n blur: [event: FocusEvent];\n}>();\n\nconst props = withDefaults(defineProps<PhoneInput>(), {\n defaultCountry: \"US\",\n format: \"national\",\n variant: \"outline\",\n color: \"default\",\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n autofocus: false,\n});\n\nconst resolvedSize = useResolvedSize(() => props.size);\nconst sz = useSizeTokens(() => props.size);\n\n// ── Refs ──────────────────────────────────────────────────────────────────────\nconst inputRef = ref<HTMLInputElement | null>(null);\nconst searchEl = ref<HTMLInputElement | null>(null);\nconst listEl = ref<HTMLElement | null>(null);\nconst wrapperEl = ref<HTMLElement | null>(null);\nconst dropdownWidth = ref(\"\");\n\n// ── Internal state ────────────────────────────────────────────────────────────\nconst localNumber = ref(\"\");\nconst internalCountry = ref((props.defaultCountry ?? \"US\").toUpperCase());\n\n// ── Field state ───────────────────────────────────────────────────────────────\nconst {\n fieldId,\n radius,\n stateColor,\n hasError,\n isDisabled,\n errorId,\n helperId,\n describedBy,\n} = useFieldState(props, {\n componentName: \"PhoneInput\",\n idPrefix: \"modo-phone\",\n});\n\nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({\n variant: () => props.variant,\n stateColor,\n hasError,\n radius,\n forceFocus: () => isOpen.value,\n halo: () => props.halo,\n});\n\n// ── Country resolution ────────────────────────────────────────────────────────\nconst activeIso = computed(() =>\n (props.country !== undefined\n ? props.country\n : internalCountry.value\n ).toUpperCase(),\n);\nconst selectedCountry = computed(() => findCountryByIso(activeIso.value));\n\n// ── Format helpers ────────────────────────────────────────────────────────────\nfunction buildValue(local: string, dialCode: string): string {\n const fmt = props.format ?? \"national\";\n if (fmt === \"e164\") return `+${dialCode}${local.replace(/\\D/g, \"\")}`;\n if (fmt === \"international\") return `+${dialCode}${local}`;\n return local;\n}\n\nfunction extractNational(v: string | undefined, dialCode: string): string {\n if (!v) return \"\";\n const prefix = `+${dialCode}`;\n if (v.startsWith(prefix)) return v.slice(prefix.length);\n return v;\n}\n\nconst currentFormValue = computed(() =>\n selectedCountry.value\n ? buildValue(localNumber.value, selectedCountry.value.dial)\n : localNumber.value,\n);\n\n// Sync external modelValue → localNumber\nwatch(\n () => props.modelValue,\n (v) => {\n const dial = selectedCountry.value?.dial ?? \"\";\n const national = extractNational(v, dial);\n if (national !== localNumber.value) localNumber.value = national;\n },\n { immediate: true },\n);\n\n// ── Popover ───────────────────────────────────────────────────────────────────\nconst {\n triggerRef,\n panelRef,\n isOpen,\n panelStyle,\n open: openPopover,\n close: closePopover,\n toggle: togglePopover,\n} = usePopover({\n placement: \"bottom-start\",\n onOpen: () => {\n dropdownWidth.value = wrapperEl.value\n ? `${wrapperEl.value.getBoundingClientRect().width}px`\n : \"260px\";\n searchQuery.value = \"\";\n activeIndex.value = Math.max(\n 0,\n filteredCountries.value.findIndex((c) => c.iso === activeIso.value),\n );\n nextTick(() => {\n searchEl.value?.focus();\n scrollActiveIntoView();\n });\n },\n onClose: () => {\n searchQuery.value = \"\";\n activeIndex.value = -1;\n },\n});\n\nconst mergedPanelStyle = computed(() => ({\n ...panelStyle.value,\n ...(dropdownWidth.value ? { width: dropdownWidth.value } : {}),\n}));\n\n// ── Search + filtered list ────────────────────────────────────────────────────\nconst searchQuery = ref(\"\");\nconst activeIndex = ref(-1);\nconst autoListboxId = useId();\n\nconst optionId = (iso: string) =>\n `modo-phone-listbox-${autoListboxId}-opt-${iso}`;\n\nconst filteredCountries = computed<PhoneCountry[]>(() => {\n const q = searchQuery.value.trim().toLowerCase();\n if (!q) return PHONE_COUNTRIES as unknown as PhoneCountry[];\n return (PHONE_COUNTRIES as unknown as PhoneCountry[]).filter(\n (c) =>\n c.name.toLowerCase().includes(q) ||\n c.iso.toLowerCase().includes(q) ||\n c.dial.startsWith(q.replace(/^\\+/, \"\")),\n );\n});\n\nwatch(filteredCountries, (list) => {\n const idx = list.findIndex((c) => c.iso === activeIso.value);\n activeIndex.value = idx >= 0 ? idx : 0;\n});\n\n// ── Option styles ─────────────────────────────────────────────────────────────\nconst OPTION_SURFACE: Record<string, string> = {\n default: \"bg-muted\",\n primary: \"bg-primary/10\",\n danger: \"bg-destructive/10\",\n success: \"bg-success/10\",\n warning: \"bg-warning/10\",\n};\nconst OPTION_HOVER: Record<string, string> = {\n default: \"hover:bg-muted\",\n primary: \"hover:bg-primary/10\",\n danger: \"hover:bg-destructive/10\",\n success: \"hover:bg-success/10\",\n warning: \"hover:bg-warning/10\",\n};\nconst optionSurface = computed(\n () => OPTION_SURFACE[stateColor.value] ?? \"bg-muted\",\n);\nconst optionHover = computed(\n () => OPTION_HOVER[stateColor.value] ?? \"hover:bg-muted\",\n);\nconst CHECK_COLOR_BY_STATE: Record<string, string> = {\n default: \"text-foreground\",\n primary: \"text-primary\",\n danger: \"text-destructive\",\n success: \"text-success\",\n warning: \"text-warning\",\n};\nconst checkColorClass = computed(\n () => CHECK_COLOR_BY_STATE[stateColor.value] ?? \"text-foreground\",\n);\nconst affordanceIconClass = computed(\n () =>\n FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? \"text-muted-foreground\",\n);\nconst affordanceActionClass = computed(\n () =>\n FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ??\n \"text-muted-foreground hover:text-foreground\",\n);\n\n// ── Size classes ──────────────────────────────────────────────────────────────\nconst wrapperHeightClass = computed(() => {\n // sz.value.padX is e.g. \"px-2.5\" — convert to pr-* for the wrapper right edge\n const pr = sz.value.padX.replace(\"px-\", \"pr-\");\n return `${sz.value.control} ${pr}`;\n});\n\nconst triggerPaddingClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"pl-2.5 pr-1.5 gap-1\";\n case \"large\":\n return \"pl-4 pr-2 gap-1.5\";\n default:\n return \"pl-3 pr-2 gap-1\";\n }\n});\n\nconst flagSizeClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"text-sm\";\n case \"large\":\n return \"text-xl\";\n default:\n return \"text-base\";\n }\n});\n\nconst triggerTextClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"text-[11px]\";\n case \"large\":\n return \"text-body\";\n default:\n return \"text-caption\";\n }\n});\n\nconst chevronSizeClass = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"w-3 h-3\";\n case \"large\":\n return \"w-4 h-4\";\n default:\n return \"w-3.5 h-3.5\";\n }\n});\n\nconst inputTextClass = computed(() => sz.value.text);\n\nconst inputPaddingClass = computed(() => {\n // pr-3 leaves a comfortable gap on the right edge as well; the\n // legacy showroom relied on the field-native default padding which\n // we override here. Without pl-3 numbers visually butt up against\n // the country trigger divider.\n return \"pl-3 pr-3\";\n});\n\n// ── Event handlers ────────────────────────────────────────────────────────────\nfunction onInput(e: Event) {\n const val = (e.target as HTMLInputElement).value;\n localNumber.value = val;\n emit(\"update:modelValue\", buildValue(val, selectedCountry.value?.dial ?? \"\"));\n}\n\nfunction onChange(e: Event) {\n const val = (e.target as HTMLInputElement).value;\n emit(\"change\", buildValue(val, selectedCountry.value?.dial ?? \"\"));\n}\n\nfunction selectCountry(c: PhoneCountry) {\n if (props.country === undefined) internalCountry.value = c.iso;\n emit(\"update:country\", c.iso);\n emit(\"update:modelValue\", buildValue(localNumber.value, c.dial));\n closePopover();\n nextTick(() => inputRef.value?.focus());\n}\n\nfunction onTriggerClick() {\n if (isDisabled.value || props.readonly) return;\n togglePopover();\n}\n\nfunction onTriggerKeydown(e: KeyboardEvent) {\n if (isDisabled.value || props.readonly) return;\n if (e.key === \"ArrowDown\" || e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n if (!isOpen.value) openPopover();\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n closePopover();\n }\n}\n\nfunction onSearchKeydown(e: KeyboardEvent) {\n const list = filteredCountries.value;\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n activeIndex.value = Math.min(activeIndex.value + 1, list.length - 1);\n scrollActiveIntoView();\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n activeIndex.value = Math.max(activeIndex.value - 1, 0);\n scrollActiveIntoView();\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n const c = list[activeIndex.value];\n if (c) selectCountry(c);\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n closePopover();\n triggerRef.value?.focus?.();\n } else if (e.key === \"Tab\") {\n // The search field lives inside a panel teleported to <body>, i.e. at the\n // very end of the document. Letting the browser resolve Tab from there\n // walks *past* the whole field — the number input sits earlier in the DOM\n // and is never reached — so focus landed on whatever followed the panel\n // while the panel was unmounting. Drive the destination explicitly:\n // forwards continues into the number input, backwards returns to the flag\n // trigger, which is the order the field reads in.\n e.preventDefault();\n closePopover();\n if (e.shiftKey) triggerRef.value?.focus?.();\n else inputRef.value?.focus();\n }\n}\n\nfunction scrollActiveIntoView() {\n nextTick(() => {\n const c = filteredCountries.value[activeIndex.value];\n if (!c || !listEl.value) return;\n const el = document.getElementById(optionId(c.iso));\n el?.scrollIntoView({ block: \"nearest\" });\n });\n}\n\n// ── Expose ────────────────────────────────────────────────────────────────────\ndefineExpose({\n focus: () => inputRef.value?.focus(),\n blur: () => inputRef.value?.blur(),\n inputRef,\n});\n</script>\n"],"mappings":""}