mood-ui 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.mjs +6 -6
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/Calendar.vue_vue_type_script_setup_true_lang.mjs +4 -4
- package/dist/components/data-display/calendar/Calendar.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.mjs +7 -7
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.mjs +7 -7
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.mjs +7 -7
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.mjs +3 -3
- package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/table/Table.cjs +1 -1
- package/dist/components/data-display/table/Table.cjs.map +1 -1
- package/dist/components/data-display/table/Table.mjs +1 -1
- package/dist/components/data-display/table/Table.mjs.map +1 -1
- package/dist/components/data-display/table/Table.vue_vue_type_script_setup_true_lang.cjs +37 -1
- package/dist/components/data-display/table/Table.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/table/Table.vue_vue_type_script_setup_true_lang.mjs +38 -2
- package/dist/components/data-display/table/Table.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/table/TablePagination.cjs.map +1 -1
- package/dist/components/data-display/table/TablePagination.mjs.map +1 -1
- package/dist/components/data-display/table/TablePagination.vue_vue_type_script_setup_true_lang.cjs +24 -16
- package/dist/components/data-display/table/TablePagination.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/table/TablePagination.vue_vue_type_script_setup_true_lang.mjs +24 -16
- package/dist/components/data-display/table/TablePagination.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Banner.vue_vue_type_script_setup_true_lang.mjs +4 -4
- package/dist/components/feedback/Banner.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.mjs +5 -5
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/EmptyState.cjs.map +1 -1
- package/dist/components/feedback/EmptyState.mjs.map +1 -1
- package/dist/components/feedback/EmptyState.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/feedback/EmptyState.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/feedback/EmptyState.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/feedback/EmptyState.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.mjs +5 -5
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/tour/Tour.vue_vue_type_script_setup_true_lang.cjs +369 -0
- package/dist/components/feedback/tour/Tour.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/components/feedback/tour/Tour.vue_vue_type_script_setup_true_lang.mjs +368 -0
- package/dist/components/feedback/tour/Tour.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
- package/dist/components/feedback/tour/Tour2.cjs +6 -0
- package/dist/components/feedback/tour/Tour2.cjs.map +1 -0
- package/dist/components/feedback/tour/Tour2.mjs +7 -0
- package/dist/components/feedback/tour/Tour2.mjs.map +1 -0
- package/dist/components/feedback/tour/TourCard.cjs +6 -0
- package/dist/components/feedback/tour/TourCard.cjs.map +1 -0
- package/dist/components/feedback/tour/TourCard.mjs +7 -0
- package/dist/components/feedback/tour/TourCard.mjs.map +1 -0
- package/dist/components/feedback/tour/TourCard.vue_vue_type_script_setup_true_lang.cjs +102 -0
- package/dist/components/feedback/tour/TourCard.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/components/feedback/tour/TourCard.vue_vue_type_script_setup_true_lang.mjs +101 -0
- package/dist/components/feedback/tour/TourCard.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
- package/dist/components/feedback/tour/tourAnchor.cjs +75 -0
- package/dist/components/feedback/tour/tourAnchor.cjs.map +1 -0
- package/dist/components/feedback/tour/tourAnchor.mjs +72 -0
- package/dist/components/feedback/tour/tourAnchor.mjs.map +1 -0
- package/dist/components/feedback/tour/tourPlace.cjs +108 -0
- package/dist/components/feedback/tour/tourPlace.cjs.map +1 -0
- package/dist/components/feedback/tour/tourPlace.mjs +107 -0
- package/dist/components/feedback/tour/tourPlace.mjs.map +1 -0
- package/dist/components/feedback/tour/tourShape.cjs +121 -0
- package/dist/components/feedback/tour/tourShape.cjs.map +1 -0
- package/dist/components/feedback/tour/tourShape.mjs +118 -0
- package/dist/components/feedback/tour/tourShape.mjs.map +1 -0
- package/dist/components/feedback/tour/useTourSpotlight.cjs +60 -0
- package/dist/components/feedback/tour/useTourSpotlight.cjs.map +1 -0
- package/dist/components/feedback/tour/useTourSpotlight.mjs +59 -0
- package/dist/components/feedback/tour/useTourSpotlight.mjs.map +1 -0
- package/dist/components/feedback/tour/useTourSteps.cjs +108 -0
- package/dist/components/feedback/tour/useTourSteps.cjs.map +1 -0
- package/dist/components/feedback/tour/useTourSteps.mjs +107 -0
- package/dist/components/feedback/tour/useTourSteps.mjs.map +1 -0
- package/dist/components/forms/Button.cjs +1 -1
- package/dist/components/forms/Button.cjs.map +1 -1
- package/dist/components/forms/Button.mjs +1 -1
- package/dist/components/forms/Button.mjs.map +1 -1
- package/dist/components/forms/Button.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/forms/Button.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/Button.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/forms/Button.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/FileInput.cjs +1 -1
- package/dist/components/forms/FileInput.cjs.map +1 -1
- package/dist/components/forms/FileInput.mjs +1 -1
- package/dist/components/forms/FileInput.mjs.map +1 -1
- package/dist/components/forms/FileInput.vue_vue_type_script_setup_true_lang.cjs +34 -17
- package/dist/components/forms/FileInput.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/FileInput.vue_vue_type_script_setup_true_lang.mjs +34 -17
- package/dist/components/forms/FileInput.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/MultiSelect.cjs +1 -1
- package/dist/components/forms/MultiSelect.cjs.map +1 -1
- package/dist/components/forms/MultiSelect.mjs +1 -1
- package/dist/components/forms/MultiSelect.mjs.map +1 -1
- package/dist/components/forms/MultiSelect.vue_vue_type_script_setup_true_lang.cjs +2 -1
- package/dist/components/forms/MultiSelect.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/MultiSelect.vue_vue_type_script_setup_true_lang.mjs +2 -1
- package/dist/components/forms/MultiSelect.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/TagInput.cjs.map +1 -1
- package/dist/components/forms/TagInput.mjs.map +1 -1
- package/dist/components/forms/TagInput.vue_vue_type_script_setup_true_lang.cjs +1 -0
- package/dist/components/forms/TagInput.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/TagInput.vue_vue_type_script_setup_true_lang.mjs +1 -0
- package/dist/components/forms/TagInput.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/Textarea.cjs.map +1 -1
- package/dist/components/forms/Textarea.mjs.map +1 -1
- package/dist/components/forms/Textarea.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/forms/Textarea.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/Textarea.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/forms/Textarea.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/morph-select/MorphSelectTrigger.cjs.map +1 -1
- package/dist/components/forms/morph-select/MorphSelectTrigger.mjs.map +1 -1
- package/dist/components/forms/morph-select/MorphSelectTrigger.vue_vue_type_script_setup_true_lang.cjs +2 -2
- package/dist/components/forms/morph-select/MorphSelectTrigger.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/morph-select/MorphSelectTrigger.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/forms/morph-select/MorphSelectTrigger.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/layout/Canvas.cjs +1 -1
- package/dist/components/layout/Canvas.cjs.map +1 -1
- package/dist/components/layout/Canvas.mjs +1 -1
- package/dist/components/layout/Canvas.mjs.map +1 -1
- package/dist/components/layout/Canvas.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/layout/Canvas.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/layout/Canvas.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/layout/Canvas.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/layout/PopoverPanel.cjs +1 -1
- package/dist/components/layout/PopoverPanel.cjs.map +1 -1
- package/dist/components/layout/PopoverPanel.mjs +1 -1
- package/dist/components/layout/PopoverPanel.mjs.map +1 -1
- package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/layout/popover/PopoverTrigger.cjs.map +1 -1
- package/dist/components/layout/popover/PopoverTrigger.mjs.map +1 -1
- package/dist/components/layout/popover/PopoverTrigger.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/layout/popover/PopoverTrigger.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/layout/popover/PopoverTrigger.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/layout/popover/PopoverTrigger.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/navigation/DropdownMenu.cjs +1 -1
- package/dist/components/navigation/DropdownMenu.cjs.map +1 -1
- package/dist/components/navigation/DropdownMenu.mjs +1 -1
- package/dist/components/navigation/DropdownMenu.mjs.map +1 -1
- package/dist/components/navigation/DropdownMenu.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/navigation/DropdownMenu.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/navigation/DropdownMenu.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/navigation/DropdownMenu.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/navigation/Switcher.cjs.map +1 -1
- package/dist/components/navigation/Switcher.mjs.map +1 -1
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.cjs +77 -45
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.mjs +77 -45
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/navigation/menu/MenuTrigger.cjs.map +1 -1
- package/dist/components/navigation/menu/MenuTrigger.mjs.map +1 -1
- package/dist/components/navigation/menu/MenuTrigger.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/navigation/menu/MenuTrigger.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/navigation/menu/MenuTrigger.vue_vue_type_script_setup_true_lang.mjs +1 -1
- package/dist/components/navigation/menu/MenuTrigger.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/composables/useField.cjs +28 -8
- package/dist/composables/useField.cjs.map +1 -1
- package/dist/composables/useField.mjs +28 -8
- package/dist/composables/useField.mjs.map +1 -1
- package/dist/config/ModoLocale.cjs +10 -1
- package/dist/config/ModoLocale.cjs.map +1 -1
- package/dist/config/ModoLocale.mjs +10 -1
- package/dist/config/ModoLocale.mjs.map +1 -1
- package/dist/config/locales/es.cjs +10 -1
- package/dist/config/locales/es.cjs.map +1 -1
- package/dist/config/locales/es.mjs +10 -1
- package/dist/config/locales/es.mjs.map +1 -1
- package/dist/index.cjs +4 -0
- package/dist/index.mjs +3 -1
- package/dist/mood-ui.css +293 -117
- package/dist/types/components/data-display/surface-card/SurfaceCardBody.vue.d.ts +1 -1
- package/dist/types/components/data-display/surface-card/SurfaceCardFooter.vue.d.ts +1 -1
- package/dist/types/components/data-display/surface-card/SurfaceCardHeader.vue.d.ts +1 -1
- package/dist/types/components/feedback/dialog/DialogContent.vue.d.ts +1 -1
- package/dist/types/components/feedback/tour/Tour.vue.d.ts +31 -0
- package/dist/types/components/feedback/tour/TourCard.vue.d.ts +25 -0
- package/dist/types/components/feedback/tour/index.d.ts +2 -0
- package/dist/types/components/feedback/tour/tourAnchor.d.ts +12 -0
- package/dist/types/components/feedback/tour/tourPlace.d.ts +60 -0
- package/dist/types/components/feedback/tour/tourShape.d.ts +36 -0
- package/dist/types/components/feedback/tour/useTourSpotlight.d.ts +14 -0
- package/dist/types/components/feedback/tour/useTourSteps.d.ts +31 -0
- package/dist/types/components/layout/Canvas.vue.d.ts +1 -1
- package/dist/types/components/layout/popover/PopoverContent.vue.d.ts +1 -1
- package/dist/types/components/navigation/menu/MenuContent.vue.d.ts +1 -1
- package/dist/types/composables/useField.d.ts +23 -0
- package/dist/types/config/ModoLocale.d.ts +14 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/interfaces/feedback/Tour.interface.d.ts +73 -0
- package/dist/types/interfaces/navigation/Switcher.interface.d.ts +5 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.vue_vue_type_script_setup_true_lang.mjs","names":[],"sources":["../../../src/components/forms/FileInput.vue"],"sourcesContent":["<template> \n <div :class=\"['flex flex-col gap-1.5', fullWidth ? 'w-full' : 'inline-flex']\"> \n <label \n v-if=\"label\" \n :for=\"fieldId\" \n class=\"text-caption font-medium text-foreground\" \n > \n {{ label }} \n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span> \n </label> \n \n <div \n :class=\"[ \n 'modo-field-wrapper transition-colors', \n dashed ? dashedWrapperClasses : wrapperVariantClasses, \n isAreaVariant ? '' : wrapperSizeClasses, \n radiusClasses, \n colorBorderClass, \n fullWidth ? 'w-full' : '', \n isDisabled ? 'opacity-60 cursor-not-allowed' : '', \n isDragOver ? dragOverRingClass : '', \n isAreaVariant && clickToSelect && !isDisabled && !readonly ? 'cursor-pointer' : '', \n ]\" \n :role=\"isAreaVariant ? 'button' : undefined\" \n :tabindex=\"isAreaVariant && !isDisabled && !readonly ? 0 : undefined\" \n :aria-label=\"isAreaVariant ? (ariaLabel ?? label ?? dropzoneLabel ?? loc.fileInput.uploadFiles) : undefined\" \n @dragover.prevent=\"onDragOver\" \n @dragleave.prevent=\"onDragLeave\" \n @drop.prevent=\"onDrop\" \n @click=\"onWrapperClick\" \n @keydown=\"onWrapperKeydown\" \n > \n <!-- Area variant --> \n <div \n v-if=\"isAreaVariant\" \n :class=\"[ \n 'flex flex-col items-center justify-center text-center gap-2 px-4', \n areaHeightClasses, \n ]\" \n > \n <component \n :is=\"iconLeft ?? ArrowUpTrayIcon\" \n aria-hidden=\"true\" \n :class=\"[ \n 'shrink-0 transition-colors duration-base ease-standard', \n isDragOver ? accentTextClass : accentTextIdleClass, \n areaIconSizeClasses, \n ]\" \n /> \n <Typography variant=\"body\" :size=\"size\" weight=\"medium\"> \n {{ areaPrimaryText }} \n </Typography> \n <Typography v-if=\"areaSecondaryText\" variant=\"caption\" size=\"medium\" color=\"muted\" as=\"p\"> \n {{ areaSecondaryText }} \n </Typography> \n <div @click.stop> \n <Button \n :disabled=\"isDisabled || readonly\" \n :color=\"color\" \n :size=\"size\" \n :radius=\"radius\" \n :icon=\"ArrowUpTrayIcon\" \n variant=\"outline\" \n :label=\"browseLabel\" \n class=\"mt-1\" \n @click=\"openFilePicker\" \n /> \n </div> \n </div> \n \n <!-- Inline variant (default) --> \n <div v-else class=\"flex items-center gap-3\"> \n <component \n :is=\"iconLeft ?? ArrowUpTrayIcon\" \n aria-hidden=\"true\" \n :class=\"['shrink-0', accentTextIdleClass, iconSizeClasses]\" \n /> \n <div class=\"flex-1 min-w-0\"> \n <Typography variant=\"body\" :size=\"size\" weight=\"medium\" :truncate=\"true\"> \n {{ files.length === 0 ? (placeholder ?? loc.fileInput.placeholder) : headlineText }} \n </Typography> \n <Typography v-if=\"helperInlineText\" variant=\"caption\" size=\"medium\" color=\"muted\" :truncate=\"true\" as=\"p\"> \n {{ helperInlineText }} \n </Typography> \n </div> \n <div @click.stop> \n <Button \n :disabled=\"isDisabled || readonly\" \n :color=\"color\" \n :size=\"size\" \n :radius=\"radius\" \n :icon=\"ArrowUpTrayIcon\" \n variant=\"outline\" \n :label=\"browseLabel\" \n @click=\"openFilePicker\" \n /> \n </div> \n </div> \n \n <!-- Hidden native input --> \n <input \n :id=\"fieldId\" \n ref=\"inputEl\" \n type=\"file\" \n class=\"sr-only\" \n :name=\"name\" \n :accept=\"accept\" \n :multiple=\"multiple\" \n :disabled=\"isDisabled\" \n :required=\"required\" \n :aria-label=\"!label ? ariaLabel : undefined\" \n :aria-invalid=\"hasError || undefined\" \n :aria-describedby=\"describedBy\" \n @change=\"onPickerChange\" \n /> \n </div> \n \n <!-- File list / previews (fuera del dropzone para no romper su forma) --> \n <TransitionGroup \n v-show=\"files.length\" \n appear \n name=\"modo-file\" \n tag=\"ul\" \n :class=\"[ \n 'flex flex-col mt-1', \n previews ? 'md:grid md:grid-cols-2 lg:grid-cols-3 md:gap-2' : '', \n ]\" \n > \n <li \n v-for=\"entry in files\" \n :key=\"entry.id\" \n :class=\"[ \n 'modo-file-item relative flex items-center gap-2 p-2 border border-border bg-background', \n // Vertical spacing via margin-bottom (not parent gap) so \n // it can animate to 0 on leave without causing a sibling \n // snap. Using mb (not mt) means when an item is removed \n // the newly-exposed sibling keeps its position. \n '[&:not(:last-child)]:mb-1.5 md:[&:not(:last-child)]:mb-0', \n itemRadiusClass, \n ]\" \n > \n <div \n v-if=\"previews && entry.previewUrl\" \n :class=\"[ \n 'shrink-0 w-10 h-10 overflow-hidden bg-muted', \n itemThumbRadiusClass, \n ]\" \n > \n <img :src=\"entry.previewUrl\" :alt=\"entry.name\" class=\"w-full h-full object-cover\" /> \n </div> \n <component \n v-else \n :is=\"isImage(entry) ? PhotoIcon : DocumentIcon\" \n aria-hidden=\"true\" \n :class=\"[ \n 'shrink-0 w-8 h-8 text-muted-foreground p-1.5 bg-muted', \n itemThumbRadiusClass, \n ]\" \n /> \n \n <div class=\"flex-1 min-w-0\"> \n <Typography variant=\"caption\" size=\"medium\" weight=\"medium\" :truncate=\"true\" as=\"p\">{{ entry.name }}</Typography> \n <p class=\"text-[11px] text-muted-foreground\"> \n {{ formatBytes(entry.size) }} \n <span v-if=\"entry.error\" class=\"text-destructive\">· {{ entry.error }}</span> \n </p> \n <!-- Progress bar --> \n <div \n v-if=\"typeof entry.progress === 'number' && entry.progress >= 0 && entry.progress < 100\" \n :class=\"['mt-1 h-1 overflow-hidden', progressRadiusClass, 'bg-muted']\" \n > \n <div \n :class=\"['h-full transition-all duration-base ease-standard', progressFillClass]\" \n :style=\"{ width: `${entry.progress}%` }\" \n /> \n </div> \n </div> \n \n <div v-if=\"!isDisabled && !readonly\" @click.stop> \n <Button \n variant=\"text\" \n :color=\"color\" \n size=\"small\" \n :icon=\"XMarkIcon\" \n :ariaLabel=\"`Remove ${entry.name}`\" \n @click=\"removeFile(entry.id)\" \n /> \n </div> \n </li> \n </TransitionGroup> \n \n <div v-if=\"errorText || helperText\" class=\"flex items-start gap-2\"> \n <Typography v-if=\"errorText\" :id=\"errorId\" variant=\"caption\" size=\"medium\" color=\"danger\" as=\"p\">{{ errorText }}</Typography> \n <Typography v-else-if=\"helperText\" :id=\"helperId\" variant=\"caption\" size=\"medium\" color=\"muted\" as=\"p\">{{ helperText }}</Typography> \n </div> \n </div> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, onBeforeUnmount, ref, useId, watch } from 'vue'; \nimport type { \n FileInput, \n FileInputFile, \n FileInputRejectCode, \n FileInputRejectContext, \n FileInputRejection, \n} from '../../interfaces/forms/FileInput.interface'; \nimport { useFieldState, useFieldClasses } from '../../composables/useField'; \nimport { useModoLocale, useResolvedSize, useSizeTokens } from '../../composables/useModoConfig';\nimport { interpolate } from '../../config/ModoLocale'; \nimport { ArrowUpTrayIcon, XMarkIcon, PhotoIcon, DocumentIcon } from '@heroicons/vue/24/outline'; \nimport Button from './Button.vue'; \nimport Typography from '../data-display/Typography.vue'; \n \nconst props = withDefaults(defineProps<FileInput>(), { \n modelValue: null, \n multiple: false, \n previews: true, \n dropzone: true, \n dropzoneVariant: 'inline', \n dropzoneHeight: 'medium', \n dashed: false, \n clickToSelect: true, \n variant: 'outline', \n color: 'default', \n disabled: false, \n readonly: false, \n required: false, \n loading: false, \n fullWidth: false, \n // `placeholder` is resolved at render time against the locale fallback. \n // Leaving the default undefined so `props.placeholder ?? loc...` works. \n autofocus: false, \n}); \n \nconst resolvedSize = useResolvedSize(() => props.size);\nconst sz = useSizeTokens(() => props.size);\n\nconst emit = defineEmits<{ \n 'update:modelValue': [files: File[] | null]; \n change: [files: File[] | null]; \n add: [files: File[]]; \n remove: [file: File]; \n reject: [rejections: FileInputRejection[]]; \n}>(); \n \nconst loc = useModoLocale(); \n \nconst { \n fieldId, hasError, isDisabled, errorId, helperId, describedBy, \n stateColor, radius, \n} = useFieldState(props, { componentName: 'FileInput', idPrefix: 'modo-file' }); \n \nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({ \n variant: () => props.variant, \n stateColor, hasError, radius, \n forceFocus: () => isDragOver.value, \n halo: () => props.halo, \n}); \n \nconst inputEl = ref<HTMLInputElement | null>(null); \nconst isDragOver = ref(false); \nconst internalFiles = ref<FileInputFile[]>([]); \nconst autoId = useId(); \nlet counter = 0; \nconst makeId = () => `modo-file-${autoId}-${++counter}`; \n \nfunction isImage(entry: FileInputFile) { \n return entry.type.startsWith('image/'); \n} \n \nfunction formatBytes(n: number) { \n if (n < 1024) return `${n} B`; \n if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`; \n if (n < 1024 * 1024 * 1024) return `${(n / (1024 * 1024)).toFixed(1)} MB`; \n return `${(n / (1024 * 1024 * 1024)).toFixed(2)} GB`; \n} \n \nfunction openFilePicker() { \n if (isDisabled.value || props.readonly) return; \n inputEl.value?.click(); \n} \n \nfunction validate(file: File): { code: FileInputRejectCode; limit?: number | string } | null { \n if (props.maxSize && file.size > props.maxSize) { \n return { code: 'size', limit: props.maxSize }; \n } \n // Accept check (simple prefix + ext match) \n if (props.accept) { \n const tokens = props.accept.split(',').map((t) => t.trim().toLowerCase()); \n const name = file.name.toLowerCase(); \n const type = file.type.toLowerCase(); \n const ok = tokens.some((t) => { \n if (t.startsWith('.')) return name.endsWith(t); \n if (t.endsWith('/*')) return type.startsWith(t.slice(0, -1)); \n return type === t; \n }); \n if (!ok) return { code: 'type', limit: props.accept }; \n } \n return null; \n} \n \n/** \n * Reject message resolver with three-tier precedence: \n * 1. Per-component prop `rejectMessages` (fn > string with `{limit}`). \n * 2. `ModoProvider`-level `locale.fileInput.reject`. \n * 3. Built-in English defaults in `defaultLocale`. \n */ \nfunction resolveRejectMessage(ctx: FileInputRejectContext): string { \n const override = props.rejectMessages?.[ctx.code]; \n if (typeof override === 'function') return override(ctx); \n if (typeof override === 'string') { \n return applyLimit(override, ctx); \n } \n // Fall back to locale (which itself falls back to defaultLocale EN). \n const reject = loc.value.fileInput.reject; \n let template: string; \n if (ctx.code === 'size') { \n template = typeof ctx.limit === 'number' ? reject.size : reject.sizeNoLimit; \n } else if (ctx.code === 'count') { \n template = typeof ctx.limit === 'number' ? reject.count : reject.countNoLimit; \n } else { \n template = reject.type; \n } \n return applyLimit(template, ctx); \n} \n \nfunction applyLimit(template: string, ctx: FileInputRejectContext): string { \n if (!template.includes('{limit}')) return template; \n const value = \n typeof ctx.limit === 'number' && ctx.code === 'size' \n ? ctx.formatBytes(ctx.limit) \n : String(ctx.limit ?? ''); \n return template.split('{limit}').join(value); \n} \n \nfunction buildRejection( \n file: File, \n code: FileInputRejectCode, \n limit?: number | string, \n): FileInputRejection { \n const ctx: FileInputRejectContext = { file, code, limit, formatBytes }; \n return { file, code, limit, message: resolveRejectMessage(ctx) }; \n} \n \nfunction addFiles(list: FileList | File[]) { \n const incoming = Array.from(list); \n const accepted: FileInputFile[] = []; \n const rejected: FileInputRejection[] = []; \n \n for (const file of incoming) { \n const err = validate(file); \n if (err) { \n rejected.push(buildRejection(file, err.code, err.limit)); \n continue; \n } \n const entry: FileInputFile = { \n id: makeId(), \n file, \n name: file.name, \n size: file.size, \n type: file.type, \n }; \n if (props.previews && file.type.startsWith('image/')) { \n entry.previewUrl = URL.createObjectURL(file); \n } \n accepted.push(entry); \n } \n \n // Respect multiple + maxFiles \n if (!props.multiple) { \n // Replace with first \n revokeAll(); \n internalFiles.value = accepted.slice(0, 1); \n } else { \n const next = [...internalFiles.value, ...accepted]; \n if (props.maxFiles && next.length > props.maxFiles) { \n const overflow = next.slice(props.maxFiles); \n overflow.forEach((e) => { \n if (e.previewUrl) URL.revokeObjectURL(e.previewUrl); \n }); \n internalFiles.value = next.slice(0, props.maxFiles); \n overflow.forEach((e) => \n rejected.push(buildRejection(e.file, 'count', props.maxFiles)), \n ); \n } else { \n internalFiles.value = next; \n } \n } \n \n if (accepted.length) emit('add', accepted.map((e) => e.file)); \n if (rejected.length) emit('reject', rejected); \n emitUpdate(); \n} \n \nfunction removeFile(id: string) { \n const idx = internalFiles.value.findIndex((e) => e.id === id); \n if (idx === -1) return; \n const [removed] = internalFiles.value.splice(idx, 1); \n if (removed.previewUrl) URL.revokeObjectURL(removed.previewUrl); \n emit('remove', removed.file); \n emitUpdate(); \n} \n \nfunction emitUpdate() { \n const out = internalFiles.value.map((e) => e.file); \n emit('update:modelValue', out.length ? out : null); \n emit('change', out.length ? out : null); \n} \n \nfunction revokeAll() { \n internalFiles.value.forEach((e) => { \n if (e.previewUrl) URL.revokeObjectURL(e.previewUrl); \n }); \n internalFiles.value = []; \n} \n \nonBeforeUnmount(() => revokeAll()); \n \n/* ---------- Events ---------- */ \n \nfunction onPickerChange(e: Event) { \n const input = e.target as HTMLInputElement; \n if (input.files && input.files.length) { \n addFiles(input.files); \n } \n // Reset para permitir re-seleccionar el mismo archivo \n input.value = ''; \n} \n \nfunction onDragOver(e: DragEvent) { \n if (!props.dropzone || isDisabled.value || props.readonly) return; \n if (e.dataTransfer) e.dataTransfer.dropEffect = 'copy'; \n isDragOver.value = true; \n} \nfunction onDragLeave() { \n isDragOver.value = false; \n} \nfunction onDrop(e: DragEvent) { \n isDragOver.value = false; \n if (!props.dropzone || isDisabled.value || props.readonly) return; \n if (e.dataTransfer?.files?.length) { \n addFiles(e.dataTransfer.files); \n } \n} \n \nfunction onWrapperClick(e: MouseEvent) { \n if (!isAreaVariant.value) return; \n if (!props.clickToSelect) return; \n if (isDisabled.value || props.readonly) return; \n // Ignora clicks provenientes de elementos interactivos (botones, remove) \n const target = e.target as HTMLElement | null; \n if (target?.closest('button, a, input, [role=\"button\"][data-modo-item]')) return; \n openFilePicker(); \n} \nfunction onWrapperKeydown(e: KeyboardEvent) { \n if (!isAreaVariant.value) return; \n if (!props.clickToSelect) return; \n if (isDisabled.value || props.readonly) return; \n if (e.key === 'Enter' || e.key === ' ') { \n e.preventDefault(); \n openFilePicker(); \n } \n} \n \n/* ---------- Merge external progress / errors ---------- */ \nconst files = computed<FileInputFile[]>(() => \n internalFiles.value.map((e) => ({ \n ...e, \n progress: props.progress?.[e.id] ?? e.progress, \n error: props.errors?.[e.id] ?? e.error, \n })), \n); \n \n/* ---------- v-model sync from outside ---------- */ \nwatch(() => props.modelValue, (v) => { \n if (!v) { \n if (internalFiles.value.length) revokeAll(); \n return; \n } \n // Solo sincroniza si el caller reemplazó la lista entera con otras refs. \n const current = internalFiles.value.map((e) => e.file); \n if (v.length === current.length && v.every((f, i) => f === current[i])) return; \n revokeAll(); \n const wrapped: FileInputFile[] = v.map((file) => { \n const entry: FileInputFile = { \n id: makeId(), \n file, \n name: file.name, \n size: file.size, \n type: file.type, \n }; \n if (props.previews && file.type.startsWith('image/')) { \n entry.previewUrl = URL.createObjectURL(file); \n } \n return entry; \n }); \n internalFiles.value = wrapped; \n}, { immediate: true }); \n \n/* ---------- Display ---------- */ \n \nconst headlineText = computed(() => { \n if (files.value.length === 1) return files.value[0].name; \n return interpolate(loc.value.fileInput.filesSelected, { count: files.value.length }); \n}); \n \nconst helperInlineText = computed(() => { \n const bits: string[] = []; \n if (props.accept) bits.push(props.accept); \n if (props.maxSize) bits.push(interpolate(loc.value.fileInput.hintUpTo, { limit: formatBytes(props.maxSize) })); \n if (props.multiple && props.maxFiles) bits.push(interpolate(loc.value.fileInput.hintMax, { limit: props.maxFiles })); \n return bits.join(' · '); \n}); \n \nconst browseLabel = computed(() => \n props.multiple \n ? (files.value.length ? loc.value.fileInput.addMore : loc.value.fileInput.browse) \n : (files.value.length ? loc.value.fileInput.replace : loc.value.fileInput.browse), \n); \n \n/* ---------- Size maps ---------- */\nconst wrapperSizeClasses = computed(() => `${sz.value.control} ${sz.value.padX}`);\nconst iconSizeClasses = computed(() => sz.value.icon); \n \n/* ---------- Area variant ---------- */ \nconst isAreaVariant = computed(() => props.dropzoneVariant === 'area'); \n \nconst areaHeightClasses = computed(() => { \n switch (props.dropzoneHeight) { \n case 'small': return 'min-h-[120px] py-4'; \n case 'large': return 'min-h-[240px] py-10'; \n default: return 'min-h-[180px] py-8'; \n } \n}); \n \nconst areaIconSizeClasses = computed(() => { \n switch (props.dropzoneHeight) { \n case 'small': return 'w-8 h-8'; \n case 'large': return 'w-14 h-14'; \n default: return 'w-10 h-10'; \n } \n}); \n \nconst areaPrimaryText = computed(() => { \n if (props.dropzoneLabel) return props.dropzoneLabel; \n if (files.value.length === 0) { \n return props.multiple \n ? loc.value.fileInput.dropzoneLabelMultiple \n : loc.value.fileInput.dropzoneLabel; \n } \n return headlineText.value; \n}); \n \nconst areaSecondaryText = computed<string | undefined>(() => { \n if (props.dropzoneHint) return props.dropzoneHint; \n return helperInlineText.value || undefined; \n}); \n \n/* ---------- Color / dashed accents ---------- */ \nconst ACCENT_TEXT_BY_COLOR: 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 ACCENT_TEXT_IDLE_BY_COLOR: Record<string, string> = { \n default: 'text-muted-foreground', \n primary: 'text-primary/70', \n danger: 'text-destructive/70', \n success: 'text-success/70', \n warning: 'text-warning/70', \n}; \n// Dashed variant keeps a transparent surface — colored fills felt heavy \n// against form backgrounds. Color only surfaces via icon/button accents. \nconst DRAG_OVER_RING_BY_COLOR: Record<string, string> = { \n default: 'ring-4 ring-foreground/25 border-foreground', \n primary: 'ring-4 ring-primary/40 border-primary', \n danger: 'ring-4 ring-destructive/40 border-destructive', \n success: 'ring-4 ring-success/40 border-success', \n warning: 'ring-4 ring-warning/40 border-warning', \n}; \nconst PROGRESS_FILL_BY_COLOR: Record<string, string> = { \n default: 'bg-foreground', \n primary: 'bg-primary', \n danger: 'bg-destructive', \n success: 'bg-success', \n warning: 'bg-warning', \n}; \n \nconst accentTextClass = computed(() => ACCENT_TEXT_BY_COLOR[stateColor.value] ?? ACCENT_TEXT_BY_COLOR.default); \nconst accentTextIdleClass = computed(() => ACCENT_TEXT_IDLE_BY_COLOR[stateColor.value] ?? ACCENT_TEXT_IDLE_BY_COLOR.default); \n// Idle border is always neutral — the color only surfaces as accent on \n// drag-over, focus, or in the upload Button. Matches Modal/Card surface pattern. \nconst colorBorderClass = computed(() => ''); \nconst dragOverRingClass = computed(() => \n DRAG_OVER_RING_BY_COLOR[stateColor.value] ?? DRAG_OVER_RING_BY_COLOR.default, \n); \nconst progressFillClass = computed(() => \n PROGRESS_FILL_BY_COLOR[stateColor.value] ?? PROGRESS_FILL_BY_COLOR.default, \n); \n \n/** Wrapper classes when `dashed=true` (overrides the field variant entirely). */ \nconst dashedWrapperClasses = computed(() => { \n // Border stays neutral; only error state gets a colored border. \n const borderTint = hasError.value ? 'border-destructive/50' : 'border-border'; \n return [ \n 'border-2 border-dashed', \n borderTint, \n ].join(' '); \n}); \n \n/* ---------- Radius helpers ---------- */ \nconst itemRadiusClass = computed(() => { \n switch (radius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-lg'; \n case 'full': return 'rounded-xl'; \n default: return 'rounded-md'; \n } \n}); \nconst itemThumbRadiusClass = computed(() => { \n switch (radius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-md'; \n case 'full': return 'rounded-lg'; \n default: return 'rounded-md'; \n } \n}); \nconst progressRadiusClass = computed(() => { \n switch (radius.value) { \n case 'none': return 'rounded-none'; \n default: return 'rounded-full'; \n } \n}); \n</script> \n \n<style scoped> \n/* File item enter/leave + move. Mirrors the MultiSelect chip pattern but \n * collapses vertical space (max-height + margin-bottom + padding) so siblings \n * slide cleanly when files are added or removed. \n * \n * NOTE: spacing between items uses margin-bottom (see template), NOT the \n * parent's `gap`. `gap` cannot animate per-item so removing the first \n * file would leave a 6px gap that snaps closed when the node unmounts. \n */ \n.modo-file-enter-active, \n.modo-file-leave-active { \n transition: \n opacity 220ms cubic-bezier(0.2, 0, 0, 1), \n transform 260ms cubic-bezier(0.2, 0, 0, 1), \n max-height 260ms cubic-bezier(0.2, 0, 0, 1), \n margin-bottom 260ms cubic-bezier(0.2, 0, 0, 1), \n padding-top 260ms cubic-bezier(0.2, 0, 0, 1), \n padding-bottom 260ms cubic-bezier(0.2, 0, 0, 1), \n border-width 260ms cubic-bezier(0.2, 0, 0, 1); \n overflow: hidden; \n} \n.modo-file-move { \n transition: transform 260ms cubic-bezier(0.2, 0, 0, 1); \n} \n.modo-file-enter-from, \n.modo-file-leave-to { \n opacity: 0; \n transform: translateY(-4px) scale(0.98); \n max-height: 0; \n margin-bottom: 0 !important; \n padding-top: 0; \n padding-bottom: 0; \n border-width: 0; \n} \n.modo-file-enter-to, \n.modo-file-leave-from { \n /* 5rem comfortably fits the tallest file row (40px thumb + padding). */ \n max-height: 5rem; \n} \n \n@media (prefers-reduced-motion: reduce) { \n .modo-file-enter-active, \n .modo-file-leave-active, \n .modo-file-move { \n transition: none; \n } \n .modo-file-enter-from, \n .modo-file-leave-to { \n opacity: 1; \n transform: none; \n max-height: none; \n margin-bottom: initial !important; \n padding: initial; \n border-width: initial; \n } \n} \n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsNA,MAAM,QAAQ;EAqBO,sBAAsB,MAAM,KAAK;EACtD,MAAM,KAAK,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OAAA;;SAND,OAAK,eAAA;UAAA;UAA+B,oBAAA;UAAmB;UAAA,CAAA;YAExD,mBAGE,OAAA;SAFG,OAAK,eAAA,CAAA,qDAAwD,kBAAA,MAAiB,CAAA;SAC9E,OAAK,eAAA,EAAA,OAAA,GAAc,MAAM,SAAQ,IAAA,CAAA;;;QAKlC,MAAA,WAAU,IAAA,CAAK,QAAA,YAAA,WAAA,EAA3B,mBASM,OAAA;;QATgC,SAAK,OAAA,OAAA,OAAA,KAAA,oBAAN,IAAW,CAAA,OAAA,CAAA;WAC5C,YAOE,gBAAA;QANE,SAAQ;QACP,OAAO,QAAA;QACR,MAAK;QACJ,MAAM,MAAA,UAAS;QACf,WAAS,UAAY,MAAM;QAC3B,UAAK,WAAE,WAAW,MAAM,GAAE;;;;;;;;;;+BAlE/B,MAAA,MAAM,OAAM,CAAA,CAAA;IAwEb,QAAA,aAAa,QAAA,cAAA,WAAA,EAAxB,mBAGM,OAHN,aAGM,CAFgB,QAAA,aAAA,WAAA,EAAlB,YAA6H,oBAAA;;KAA/F,IAAI,MAAA,QAAO;KAAE,SAAQ;KAAU,MAAK;KAAS,OAAM;KAAS,IAAG;;4BAAmB,CAAA,gBAAA,gBAAZ,QAAA,UAAS,EAAA,EAAA,CAAA,CAAA;;qBACtF,QAAA,cAAA,WAAA,EAAvB,YAAoI,oBAAA;;KAAhG,IAAI,MAAA,SAAQ;KAAE,SAAQ;KAAU,MAAK;KAAS,OAAM;KAAQ,IAAG;;4BAAoB,CAAA,gBAAA,gBAAb,QAAA,WAAU,EAAA,EAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"FileInput.vue_vue_type_script_setup_true_lang.mjs","names":[],"sources":["../../../src/components/forms/FileInput.vue"],"sourcesContent":["<template> \n <div :class=\"['flex flex-col gap-1.5', fullWidth ? 'w-full' : 'inline-flex']\"> \n <label \n v-if=\"label\" \n :for=\"fieldId\" \n class=\"text-caption font-medium text-foreground\" \n > \n {{ label }} \n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span> \n </label> \n \n <div \n :class=\"[ \n 'modo-field-wrapper transition-colors', \n dashed ? dashedWrapperClasses : wrapperVariantClasses, \n isAreaVariant ? '' : `flex items-center ${wrapperSizeClasses}`, \n radiusClasses, \n colorBorderClass, \n fullWidth ? 'w-full' : '', \n isDisabled ? 'opacity-60 cursor-not-allowed' : '', \n isDragOver ? dragOverRingClass : '', \n isAreaVariant && clickToSelect && !isDisabled && !readonly ? 'cursor-pointer' : '', \n ]\" \n :role=\"isAreaVariant ? 'button' : undefined\" \n :tabindex=\"isAreaVariant && !isDisabled && !readonly ? 0 : undefined\" \n :aria-label=\"isAreaVariant ? (ariaLabel ?? label ?? dropzoneLabel ?? loc.fileInput.uploadFiles) : undefined\" \n @dragover.prevent=\"onDragOver\" \n @dragleave.prevent=\"onDragLeave\" \n @drop.prevent=\"onDrop\" \n @click=\"onWrapperClick\" \n @keydown=\"onWrapperKeydown\" \n > \n <!-- Area variant --> \n <div \n v-if=\"isAreaVariant\" \n :class=\"[ \n 'flex flex-col items-center justify-center text-center gap-2 px-4', \n areaHeightClasses, \n ]\" \n > \n <component \n :is=\"iconLeft ?? ArrowUpTrayIcon\" \n aria-hidden=\"true\" \n :class=\"[ \n 'shrink-0 transition-colors duration-base ease-standard', \n isDragOver ? accentTextClass : accentTextIdleClass, \n areaIconSizeClasses, \n ]\" \n /> \n <Typography variant=\"body\" :size=\"size\" weight=\"medium\"> \n {{ areaPrimaryText }} \n </Typography> \n <Typography v-if=\"areaSecondaryText\" variant=\"caption\" size=\"medium\" color=\"muted\" as=\"p\"> \n {{ areaSecondaryText }} \n </Typography> \n <div @click.stop> \n <Button \n :disabled=\"isDisabled || readonly\" \n :color=\"color\" \n :size=\"size\" \n :radius=\"radius\" \n :icon=\"ArrowUpTrayIcon\" \n variant=\"outline\" \n :label=\"browseLabel\" \n class=\"mt-1\" \n @click=\"openFilePicker\" \n /> \n </div> \n </div> \n \n <!-- Inline variant (default) --> \n <div v-else class=\"flex items-center gap-3 w-full min-w-0\"> \n <component \n :is=\"iconLeft ?? ArrowUpTrayIcon\" \n aria-hidden=\"true\" \n :class=\"['shrink-0', accentTextIdleClass, iconSizeClasses]\" \n /> \n <div class=\"flex-1 min-w-0\"> \n <p :class=\"['truncate', inputTextClasses, files.length === 0 ? 'text-muted-foreground' : 'text-foreground']\"> \n {{ files.length === 0 ? (placeholder ?? loc.fileInput.placeholder) : headlineText }} \n </p> \n <Typography v-if=\"helperInlineText\" variant=\"caption\" size=\"medium\" color=\"muted\" :truncate=\"true\" as=\"p\"> \n {{ helperInlineText }} \n </Typography> \n </div> \n <div class=\"flex shrink-0 items-center\" @click.stop> \n <Button \n :disabled=\"isDisabled || readonly\" \n :color=\"color\" \n :size=\"inlineButtonSize\" \n :class=\"['shrink-0', inlineButtonHeight]\" \n :radius=\"radius\" \n :icon=\"ArrowUpTrayIcon\" \n variant=\"outline\" \n :label=\"browseLabel\" \n @click=\"openFilePicker\" \n /> \n </div> \n </div> \n \n <!-- Hidden native input --> \n <input \n :id=\"fieldId\" \n ref=\"inputEl\" \n type=\"file\" \n class=\"sr-only\" \n :name=\"name\" \n :accept=\"accept\" \n :multiple=\"multiple\" \n :disabled=\"isDisabled\" \n :required=\"required\" \n :aria-label=\"!label ? ariaLabel : undefined\" \n :aria-invalid=\"hasError || undefined\" \n :aria-describedby=\"describedBy\" \n @change=\"onPickerChange\" \n /> \n </div> \n \n <!-- File list / previews (fuera del dropzone para no romper su forma) --> \n <TransitionGroup \n v-show=\"files.length\" \n appear \n name=\"modo-file\" \n tag=\"ul\" \n :class=\"[ \n 'flex flex-col mt-1', \n previews ? 'md:grid md:grid-cols-2 lg:grid-cols-3 md:gap-2' : '', \n ]\" \n > \n <li \n v-for=\"entry in files\" \n :key=\"entry.id\" \n :class=\"[ \n 'modo-file-item relative flex items-center gap-2 p-2 border border-border bg-background', \n // Vertical spacing via margin-bottom (not parent gap) so \n // it can animate to 0 on leave without causing a sibling \n // snap. Using mb (not mt) means when an item is removed \n // the newly-exposed sibling keeps its position. \n '[&:not(:last-child)]:mb-1.5 md:[&:not(:last-child)]:mb-0', \n itemRadiusClass, \n ]\" \n > \n <div \n v-if=\"previews && entry.previewUrl\" \n :class=\"[ \n 'shrink-0 w-10 h-10 overflow-hidden bg-muted', \n itemThumbRadiusClass, \n ]\" \n > \n <img :src=\"entry.previewUrl\" :alt=\"entry.name\" class=\"w-full h-full object-cover\" /> \n </div> \n <component \n v-else \n :is=\"isImage(entry) ? PhotoIcon : DocumentIcon\" \n aria-hidden=\"true\" \n :class=\"[ \n 'shrink-0 w-8 h-8 text-muted-foreground p-1.5 bg-muted', \n itemThumbRadiusClass, \n ]\" \n /> \n \n <div class=\"flex-1 min-w-0\"> \n <Typography variant=\"caption\" size=\"medium\" weight=\"medium\" :truncate=\"true\" as=\"p\">{{ entry.name }}</Typography> \n <p class=\"text-[11px] text-muted-foreground\"> \n {{ formatBytes(entry.size) }} \n <span v-if=\"entry.error\" class=\"text-destructive\">· {{ entry.error }}</span> \n </p> \n <!-- Progress bar --> \n <div \n v-if=\"typeof entry.progress === 'number' && entry.progress >= 0 && entry.progress < 100\" \n :class=\"['mt-1 h-1 overflow-hidden', progressRadiusClass, 'bg-muted']\" \n > \n <div \n :class=\"['h-full transition-all duration-base ease-standard', progressFillClass]\" \n :style=\"{ width: `${entry.progress}%` }\" \n /> \n </div> \n </div> \n \n <div v-if=\"!isDisabled && !readonly\" @click.stop> \n <Button \n variant=\"text\" \n :color=\"color\" \n size=\"small\" \n :icon=\"XMarkIcon\" \n :ariaLabel=\"`Remove ${entry.name}`\" \n @click=\"removeFile(entry.id)\" \n /> \n </div> \n </li> \n </TransitionGroup> \n \n <div v-if=\"errorText || helperText\" class=\"flex items-start gap-2\"> \n <Typography v-if=\"errorText\" :id=\"errorId\" variant=\"caption\" size=\"medium\" color=\"danger\" as=\"p\">{{ errorText }}</Typography> \n <Typography v-else-if=\"helperText\" :id=\"helperId\" variant=\"caption\" size=\"medium\" color=\"muted\" as=\"p\">{{ helperText }}</Typography> \n </div> \n </div> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, onBeforeUnmount, ref, useId, watch } from 'vue'; \nimport type { \n FileInput, \n FileInputFile, \n FileInputRejectCode, \n FileInputRejectContext, \n FileInputRejection, \n} from '../../interfaces/forms/FileInput.interface'; \nimport { useFieldState, useFieldClasses } from '../../composables/useField'; \nimport { useModoLocale, useResolvedSize, useSizeTokens } from '../../composables/useModoConfig';\nimport { interpolate } from '../../config/ModoLocale'; \nimport { ArrowUpTrayIcon, XMarkIcon, PhotoIcon, DocumentIcon } from '@heroicons/vue/24/outline'; \nimport Button from './Button.vue'; \nimport Typography from '../data-display/Typography.vue'; \n \nconst props = withDefaults(defineProps<FileInput>(), { \n modelValue: null, \n multiple: false, \n previews: true, \n dropzone: true, \n dropzoneVariant: 'inline', \n dropzoneHeight: 'medium', \n dashed: false, \n clickToSelect: true, \n variant: 'outline', \n color: 'default', \n disabled: false, \n readonly: false, \n required: false, \n loading: false, \n fullWidth: false, \n // `placeholder` is resolved at render time against the locale fallback. \n // Leaving the default undefined so `props.placeholder ?? loc...` works. \n autofocus: false, \n}); \n \nconst resolvedSize = useResolvedSize(() => props.size);\nconst sz = useSizeTokens(() => props.size);\n\nconst emit = defineEmits<{ \n 'update:modelValue': [files: File[] | null]; \n change: [files: File[] | null]; \n add: [files: File[]]; \n remove: [file: File]; \n reject: [rejections: FileInputRejection[]]; \n}>(); \n \nconst loc = useModoLocale(); \n \nconst { \n fieldId, hasError, isDisabled, errorId, helperId, describedBy, \n stateColor, radius, \n} = useFieldState(props, { componentName: 'FileInput', idPrefix: 'modo-file' }); \n \nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({ \n variant: () => props.variant, \n stateColor, hasError, radius, \n // The drop zone is a big box: `radius=\"full\"` caps at a card-like radius.\n radiusKind: () => (props.dropzoneVariant === 'area' ? 'surface' : 'control'), \n forceFocus: () => isDragOver.value, \n halo: () => props.halo, \n}); \n \nconst inputEl = ref<HTMLInputElement | null>(null); \nconst isDragOver = ref(false); \nconst internalFiles = ref<FileInputFile[]>([]); \nconst autoId = useId(); \nlet counter = 0; \nconst makeId = () => `modo-file-${autoId}-${++counter}`; \n \nfunction isImage(entry: FileInputFile) { \n return entry.type.startsWith('image/'); \n} \n \nfunction formatBytes(n: number) { \n if (n < 1024) return `${n} B`; \n if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`; \n if (n < 1024 * 1024 * 1024) return `${(n / (1024 * 1024)).toFixed(1)} MB`; \n return `${(n / (1024 * 1024 * 1024)).toFixed(2)} GB`; \n} \n \nfunction openFilePicker() { \n if (isDisabled.value || props.readonly) return; \n inputEl.value?.click(); \n} \n \nfunction validate(file: File): { code: FileInputRejectCode; limit?: number | string } | null { \n if (props.maxSize && file.size > props.maxSize) { \n return { code: 'size', limit: props.maxSize }; \n } \n // Accept check (simple prefix + ext match) \n if (props.accept) { \n const tokens = props.accept.split(',').map((t) => t.trim().toLowerCase()); \n const name = file.name.toLowerCase(); \n const type = file.type.toLowerCase(); \n const ok = tokens.some((t) => { \n if (t.startsWith('.')) return name.endsWith(t); \n if (t.endsWith('/*')) return type.startsWith(t.slice(0, -1)); \n return type === t; \n }); \n if (!ok) return { code: 'type', limit: props.accept }; \n } \n return null; \n} \n \n/** \n * Reject message resolver with three-tier precedence: \n * 1. Per-component prop `rejectMessages` (fn > string with `{limit}`). \n * 2. `ModoProvider`-level `locale.fileInput.reject`. \n * 3. Built-in English defaults in `defaultLocale`. \n */ \nfunction resolveRejectMessage(ctx: FileInputRejectContext): string { \n const override = props.rejectMessages?.[ctx.code]; \n if (typeof override === 'function') return override(ctx); \n if (typeof override === 'string') { \n return applyLimit(override, ctx); \n } \n // Fall back to locale (which itself falls back to defaultLocale EN). \n const reject = loc.value.fileInput.reject; \n let template: string; \n if (ctx.code === 'size') { \n template = typeof ctx.limit === 'number' ? reject.size : reject.sizeNoLimit; \n } else if (ctx.code === 'count') { \n template = typeof ctx.limit === 'number' ? reject.count : reject.countNoLimit; \n } else { \n template = reject.type; \n } \n return applyLimit(template, ctx); \n} \n \nfunction applyLimit(template: string, ctx: FileInputRejectContext): string { \n if (!template.includes('{limit}')) return template; \n const value = \n typeof ctx.limit === 'number' && ctx.code === 'size' \n ? ctx.formatBytes(ctx.limit) \n : String(ctx.limit ?? ''); \n return template.split('{limit}').join(value); \n} \n \nfunction buildRejection( \n file: File, \n code: FileInputRejectCode, \n limit?: number | string, \n): FileInputRejection { \n const ctx: FileInputRejectContext = { file, code, limit, formatBytes }; \n return { file, code, limit, message: resolveRejectMessage(ctx) }; \n} \n \nfunction addFiles(list: FileList | File[]) { \n const incoming = Array.from(list); \n const accepted: FileInputFile[] = []; \n const rejected: FileInputRejection[] = []; \n \n for (const file of incoming) { \n const err = validate(file); \n if (err) { \n rejected.push(buildRejection(file, err.code, err.limit)); \n continue; \n } \n const entry: FileInputFile = { \n id: makeId(), \n file, \n name: file.name, \n size: file.size, \n type: file.type, \n }; \n if (props.previews && file.type.startsWith('image/')) { \n entry.previewUrl = URL.createObjectURL(file); \n } \n accepted.push(entry); \n } \n \n // Respect multiple + maxFiles \n if (!props.multiple) { \n // Replace with first \n revokeAll(); \n internalFiles.value = accepted.slice(0, 1); \n } else { \n const next = [...internalFiles.value, ...accepted]; \n if (props.maxFiles && next.length > props.maxFiles) { \n const overflow = next.slice(props.maxFiles); \n overflow.forEach((e) => { \n if (e.previewUrl) URL.revokeObjectURL(e.previewUrl); \n }); \n internalFiles.value = next.slice(0, props.maxFiles); \n overflow.forEach((e) => \n rejected.push(buildRejection(e.file, 'count', props.maxFiles)), \n ); \n } else { \n internalFiles.value = next; \n } \n } \n \n if (accepted.length) emit('add', accepted.map((e) => e.file)); \n if (rejected.length) emit('reject', rejected); \n emitUpdate(); \n} \n \nfunction removeFile(id: string) { \n const idx = internalFiles.value.findIndex((e) => e.id === id); \n if (idx === -1) return; \n const [removed] = internalFiles.value.splice(idx, 1); \n if (removed.previewUrl) URL.revokeObjectURL(removed.previewUrl); \n emit('remove', removed.file); \n emitUpdate(); \n} \n \nfunction emitUpdate() { \n const out = internalFiles.value.map((e) => e.file); \n emit('update:modelValue', out.length ? out : null); \n emit('change', out.length ? out : null); \n} \n \nfunction revokeAll() { \n internalFiles.value.forEach((e) => { \n if (e.previewUrl) URL.revokeObjectURL(e.previewUrl); \n }); \n internalFiles.value = []; \n} \n \nonBeforeUnmount(() => revokeAll()); \n \n/* ---------- Events ---------- */ \n \nfunction onPickerChange(e: Event) { \n const input = e.target as HTMLInputElement; \n if (input.files && input.files.length) { \n addFiles(input.files); \n } \n // Reset para permitir re-seleccionar el mismo archivo \n input.value = ''; \n} \n \nfunction onDragOver(e: DragEvent) { \n if (!props.dropzone || isDisabled.value || props.readonly) return; \n if (e.dataTransfer) e.dataTransfer.dropEffect = 'copy'; \n isDragOver.value = true; \n} \nfunction onDragLeave() { \n isDragOver.value = false; \n} \nfunction onDrop(e: DragEvent) { \n isDragOver.value = false; \n if (!props.dropzone || isDisabled.value || props.readonly) return; \n if (e.dataTransfer?.files?.length) { \n addFiles(e.dataTransfer.files); \n } \n} \n \nfunction onWrapperClick(e: MouseEvent) { \n if (!isAreaVariant.value) return; \n if (!props.clickToSelect) return; \n if (isDisabled.value || props.readonly) return; \n // Ignora clicks provenientes de elementos interactivos (botones, remove) \n const target = e.target as HTMLElement | null; \n if (target?.closest('button, a, input, [role=\"button\"][data-modo-item]')) return; \n openFilePicker(); \n} \nfunction onWrapperKeydown(e: KeyboardEvent) { \n if (!isAreaVariant.value) return; \n if (!props.clickToSelect) return; \n if (isDisabled.value || props.readonly) return; \n if (e.key === 'Enter' || e.key === ' ') { \n e.preventDefault(); \n openFilePicker(); \n } \n} \n \n/* ---------- Merge external progress / errors ---------- */ \nconst files = computed<FileInputFile[]>(() => \n internalFiles.value.map((e) => ({ \n ...e, \n progress: props.progress?.[e.id] ?? e.progress, \n error: props.errors?.[e.id] ?? e.error, \n })), \n); \n \n/* ---------- v-model sync from outside ---------- */ \nwatch(() => props.modelValue, (v) => { \n if (!v) { \n if (internalFiles.value.length) revokeAll(); \n return; \n } \n // Solo sincroniza si el caller reemplazó la lista entera con otras refs. \n const current = internalFiles.value.map((e) => e.file); \n if (v.length === current.length && v.every((f, i) => f === current[i])) return; \n revokeAll(); \n const wrapped: FileInputFile[] = v.map((file) => { \n const entry: FileInputFile = { \n id: makeId(), \n file, \n name: file.name, \n size: file.size, \n type: file.type, \n }; \n if (props.previews && file.type.startsWith('image/')) { \n entry.previewUrl = URL.createObjectURL(file); \n } \n return entry; \n }); \n internalFiles.value = wrapped; \n}, { immediate: true }); \n \n/* ---------- Display ---------- */ \n \nconst headlineText = computed(() => { \n if (files.value.length === 1) return files.value[0].name; \n return interpolate(loc.value.fileInput.filesSelected, { count: files.value.length }); \n}); \n \nconst helperInlineText = computed(() => { \n const bits: string[] = []; \n if (props.accept) bits.push(props.accept); \n if (props.maxSize) bits.push(interpolate(loc.value.fileInput.hintUpTo, { limit: formatBytes(props.maxSize) })); \n if (props.multiple && props.maxFiles) bits.push(interpolate(loc.value.fileInput.hintMax, { limit: props.maxFiles })); \n return bits.join(' · '); \n}); \n \nconst browseLabel = computed(() => \n props.multiple \n ? (files.value.length ? loc.value.fileInput.addMore : loc.value.fileInput.browse) \n : (files.value.length ? loc.value.fileInput.replace : loc.value.fileInput.browse), \n); \n \n/* ---------- Size maps ---------- */\nconst wrapperSizeClasses = computed(() => `${sz.value.control} ${sz.value.padX}`);\nconst iconSizeClasses = computed(() => sz.value.icon);\nconst inputTextClasses = computed(() => sz.value.text);\n// The inline Browse button is a trailing control: it sits inside the field with\n// 4px of air above and below (control height - 8px), so it never touches the\n// border at any radius. Same idea as the clear / eye buttons of other fields.\nconst INLINE_BUTTON_SIZE: Record<string, 'xsmall' | 'small' | 'medium'> = { xsmall: 'xsmall', small: 'xsmall', medium: 'small', large: 'medium' };\nconst inlineButtonSize = computed(() => INLINE_BUTTON_SIZE[resolvedSize.value] ?? 'small');\nconst INLINE_BUTTON_HEIGHT: Record<string, string> = { xsmall: '!h-6', small: '!h-7', medium: '!h-8', large: '!h-10' };\nconst inlineButtonHeight = computed(() => INLINE_BUTTON_HEIGHT[resolvedSize.value] ?? '!h-8'); \n \n/* ---------- Area variant ---------- */ \nconst isAreaVariant = computed(() => props.dropzoneVariant === 'area'); \n \nconst areaHeightClasses = computed(() => { \n switch (props.dropzoneHeight) { \n case 'small': return 'min-h-[120px] py-4'; \n case 'large': return 'min-h-[240px] py-10'; \n default: return 'min-h-[180px] py-8'; \n } \n}); \n \nconst areaIconSizeClasses = computed(() => { \n switch (props.dropzoneHeight) { \n case 'small': return 'w-8 h-8'; \n case 'large': return 'w-14 h-14'; \n default: return 'w-10 h-10'; \n } \n}); \n \nconst areaPrimaryText = computed(() => { \n if (props.dropzoneLabel) return props.dropzoneLabel; \n if (files.value.length === 0) { \n return props.multiple \n ? loc.value.fileInput.dropzoneLabelMultiple \n : loc.value.fileInput.dropzoneLabel; \n } \n return headlineText.value; \n}); \n \nconst areaSecondaryText = computed<string | undefined>(() => { \n if (props.dropzoneHint) return props.dropzoneHint; \n return helperInlineText.value || undefined; \n}); \n \n/* ---------- Color / dashed accents ---------- */ \nconst ACCENT_TEXT_BY_COLOR: 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 ACCENT_TEXT_IDLE_BY_COLOR: Record<string, string> = { \n default: 'text-muted-foreground', \n primary: 'text-primary/70', \n danger: 'text-destructive/70', \n success: 'text-success/70', \n warning: 'text-warning/70', \n}; \n// Dashed variant keeps a transparent surface — colored fills felt heavy \n// against form backgrounds. Color only surfaces via icon/button accents. \nconst DRAG_OVER_RING_BY_COLOR: Record<string, string> = { \n default: 'ring-4 ring-foreground/25 border-foreground', \n primary: 'ring-4 ring-primary/40 border-primary', \n danger: 'ring-4 ring-destructive/40 border-destructive', \n success: 'ring-4 ring-success/40 border-success', \n warning: 'ring-4 ring-warning/40 border-warning', \n}; \nconst PROGRESS_FILL_BY_COLOR: Record<string, string> = { \n default: 'bg-foreground', \n primary: 'bg-primary', \n danger: 'bg-destructive', \n success: 'bg-success', \n warning: 'bg-warning', \n}; \n \nconst accentTextClass = computed(() => ACCENT_TEXT_BY_COLOR[stateColor.value] ?? ACCENT_TEXT_BY_COLOR.default); \nconst accentTextIdleClass = computed(() => ACCENT_TEXT_IDLE_BY_COLOR[stateColor.value] ?? ACCENT_TEXT_IDLE_BY_COLOR.default); \n// Idle border is always neutral — the color only surfaces as accent on \n// drag-over, focus, or in the upload Button. Matches Modal/Card surface pattern. \nconst colorBorderClass = computed(() => ''); \nconst dragOverRingClass = computed(() => \n DRAG_OVER_RING_BY_COLOR[stateColor.value] ?? DRAG_OVER_RING_BY_COLOR.default, \n); \nconst progressFillClass = computed(() => \n PROGRESS_FILL_BY_COLOR[stateColor.value] ?? PROGRESS_FILL_BY_COLOR.default, \n); \n \n/** Wrapper classes when `dashed=true` (overrides the field variant entirely). */ \nconst dashedWrapperClasses = computed(() => { \n // Border stays neutral; only error state gets a colored border. \n const borderTint = hasError.value ? 'border-destructive/50' : 'border-input not-[.cursor-not-allowed]:not-focus-within:hover:border-input-hover'; \n return [ \n 'border-2 border-dashed', \n borderTint, \n ].join(' '); \n}); \n \n/* ---------- Radius helpers ---------- */ \nconst itemRadiusClass = computed(() => { \n switch (radius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-lg'; \n // File chips are inner controls: they take the full pill.\n case 'full': return 'rounded-full pl-3'; \n default: return 'rounded-md'; \n } \n}); \nconst itemThumbRadiusClass = computed(() => { \n switch (radius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-md'; \n case 'full': return 'rounded-full'; \n default: return 'rounded-md'; \n } \n}); \nconst progressRadiusClass = computed(() => { \n switch (radius.value) { \n case 'none': return 'rounded-none'; \n default: return 'rounded-full'; \n } \n}); \n</script> \n \n<style scoped> \n/* File item enter/leave + move. Mirrors the MultiSelect chip pattern but \n * collapses vertical space (max-height + margin-bottom + padding) so siblings \n * slide cleanly when files are added or removed. \n * \n * NOTE: spacing between items uses margin-bottom (see template), NOT the \n * parent's `gap`. `gap` cannot animate per-item so removing the first \n * file would leave a 6px gap that snaps closed when the node unmounts. \n */ \n.modo-file-enter-active, \n.modo-file-leave-active { \n transition: \n opacity 220ms cubic-bezier(0.2, 0, 0, 1), \n transform 260ms cubic-bezier(0.2, 0, 0, 1), \n max-height 260ms cubic-bezier(0.2, 0, 0, 1), \n margin-bottom 260ms cubic-bezier(0.2, 0, 0, 1), \n padding-top 260ms cubic-bezier(0.2, 0, 0, 1), \n padding-bottom 260ms cubic-bezier(0.2, 0, 0, 1), \n border-width 260ms cubic-bezier(0.2, 0, 0, 1); \n overflow: hidden; \n} \n.modo-file-move { \n transition: transform 260ms cubic-bezier(0.2, 0, 0, 1); \n} \n.modo-file-enter-from, \n.modo-file-leave-to { \n opacity: 0; \n transform: translateY(-4px) scale(0.98); \n max-height: 0; \n margin-bottom: 0 !important; \n padding-top: 0; \n padding-bottom: 0; \n border-width: 0; \n} \n.modo-file-enter-to, \n.modo-file-leave-from { \n /* 5rem comfortably fits the tallest file row (40px thumb + padding). */ \n max-height: 5rem; \n} \n \n@media (prefers-reduced-motion: reduce) { \n .modo-file-enter-active, \n .modo-file-leave-active, \n .modo-file-move { \n transition: none; \n } \n .modo-file-enter-from, \n .modo-file-leave-to { \n opacity: 1; \n transform: none; \n max-height: none; \n margin-bottom: initial !important; \n padding: initial; \n border-width: initial; \n } \n} \n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuNA,MAAM,QAAQ;EAqBd,MAAM,eAAe,sBAAsB,MAAM,KAAK;E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BACtF,QAAA,cAAA,WAAA,EAAvB,YAAoI,oBAAA;;KAAhG,IAAI,MAAA,SAAQ;KAAE,SAAQ;KAAU,MAAK;KAAS,OAAM;KAAQ,IAAG;;4BAAoB,CAAA,gBAAA,gBAAb,QAAA,WAAU,EAAA,EAAA,CAAA,CAAA"}
|
|
@@ -2,7 +2,7 @@ const require__plugin_vue_export_helper = require("../../_virtual/_plugin-vue_ex
|
|
|
2
2
|
const require_MultiSelect_vue_vue_type_script_setup_true_lang = require("./MultiSelect.vue_vue_type_script_setup_true_lang.cjs");
|
|
3
3
|
;/* empty css */
|
|
4
4
|
//#region src/components/forms/MultiSelect.vue
|
|
5
|
-
var MultiSelect_default = /* @__PURE__ */ require__plugin_vue_export_helper.default(require_MultiSelect_vue_vue_type_script_setup_true_lang.default, [["__scopeId", "data-v-
|
|
5
|
+
var MultiSelect_default = /* @__PURE__ */ require__plugin_vue_export_helper.default(require_MultiSelect_vue_vue_type_script_setup_true_lang.default, [["__scopeId", "data-v-c2686e7f"]]);
|
|
6
6
|
//#endregion
|
|
7
7
|
exports.default = MultiSelect_default;
|
|
8
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelect.cjs","names":[],"sources":["../../../src/components/forms/MultiSelect.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 @click=\"openAndFocus\" \n > \n {{ label }} \n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span> \n </label> \n \n <!-- Trigger --> \n <button \n :id=\"fieldId\" \n ref=\"triggerEl\" \n type=\"button\" \n :disabled=\"isDisabled\" \n :aria-label=\"!label ? ariaLabel : undefined\" \n :aria-invalid=\"hasError || undefined\" \n :aria-describedby=\"describedBy\" \n :aria-required=\"required || undefined\" \n :aria-haspopup=\"'listbox'\" \n :aria-expanded=\"isOpen\" \n :aria-controls=\"listboxId\" \n :aria-activedescendant=\"isOpen && activeId ? activeId : undefined\" \n role=\"combobox\" \n :class=\"[ \n 'modo-field-wrapper flex items-center gap-2 text-left',\n wrapperVariantClasses, \n wrapperSizeClasses, \n radiusClasses, \n fullWidth ? 'w-full' : '', \n isDisabled ? 'opacity-60 cursor-not-allowed' : 'cursor-pointer', \n ]\" \n @click=\"onTriggerClick\" \n @keydown=\"onTriggerKeydown\" \n > \n <component \n :is=\"iconLeft\" \n v-if=\"iconLeft\" \n aria-hidden=\"true\" \n :class=\"['shrink-0', affordanceIconClass, iconSizeClasses]\" \n /> \n \n <!-- Chips --> \n <!-- \n NOTE: the TransitionGroup stays always mounted; if we toggle it \n with `v-if`, removing the last chip unmounts the group before \n Vue can play the leave transition on that chip. A sibling \n placeholder handles the empty state visually. \n --> \n <TransitionGroup \n name=\"modo-chip\" \n tag=\"div\" \n class=\"min-w-0 flex flex-wrap items-center gap-1 py-1\" \n :class=\"[selectedOptions.length ? 'flex-1' : '']\" \n @after-leave=\"onChipAfterLeave\" \n > \n <Badge \n v-for=\"opt in visibleChips\" \n :key=\"`chip-${opt.value}`\" \n variant=\"subtle\" \n :color=\"badgeColor\" \n size=\"medium\" \n :radius=\"radius\" \n :removable=\"!isDisabled && !readonly\" \n :removeAriaLabel=\"`Remove ${opt.label}`\" \n :label=\"opt.label\" \n class=\"modo-chip max-w-50\" \n @remove=\"removeValue(opt.value)\" \n /> \n <Badge \n v-if=\"hiddenChipCount > 0\" \n :key=\"'chip-overflow'\" \n variant=\"subtle\" \n :color=\"badgeColor\" \n size=\"medium\" \n :radius=\"radius\" \n :label=\"`+${hiddenChipCount}`\" \n class=\"modo-chip\" \n /> \n </TransitionGroup> \n <span \n v-if=\"showPlaceholder\" \n :class=\"['flex-1 min-w-0 truncate text-muted-foreground', inputTextClasses]\" \n > \n {{ placeholder }} \n </span> \n \n <Loader \n v-if=\"loading\" \n :size=\"size === 'large' ? 'medium' : 'small'\" \n :class=\"['shrink-0', affordanceIconClass]\" \n /> \n \n <Button \n v-else-if=\"clearable && selectedOptions.length && !isDisabled && !readonly\" \n variant=\"text\" \n size=\"xs\" \n radius=\"full\" \n :icon=\"XMarkIcon\" \n :ariaLabel=\"loc.multiSelect.clear\" \n tabindex=\"-1\" \n :class=\"['shrink-0', affordanceActionClass]\" \n @click.stop=\"clear\" \n /> \n \n <ChevronDownIcon \n v-if=\"!loading\" \n aria-hidden=\"true\" \n :class=\"[ \n 'shrink-0 transition-transform duration-base ease-standard', \n affordanceIconClass,\n iconSizeClasses, \n isOpen ? 'rotate-180' : '', \n ]\" \n /> \n </button> \n \n <!-- Hidden inputs for form integration --> \n <template v-if=\"name\"> \n <input \n v-for=\"val in modelValue\" \n :key=\"`hidden-${val}`\" \n type=\"hidden\" \n :name=\"`${name}[]`\" \n :value=\"val\" \n /> \n </template> \n \n <!-- Dropdown --> \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 <div v-if=\"searchable\" class=\"px-3 py-2 border-b border-border shrink-0\"> \n <div class=\"flex items-center gap-2 h-7\"> \n <MagnifyingGlassIcon \n v-if=\"!isSearching\" \n :class=\"['w-4 h-4 shrink-0', affordanceIconClass]\" \n aria-hidden=\"true\" \n /> \n <Loader \n v-else \n size=\"small\" \n class=\"shrink-0 text-primary\" \n /> \n <input \n ref=\"searchEl\" \n v-model=\"searchQuery\" \n type=\"text\" \n autocomplete=\"off\" \n spellcheck=\"false\" \n :placeholder=\"searchPlaceholder\" \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.multiSelect.clearSearch\" \n tabindex=\"-1\" \n :class=\"['shrink-0', affordanceActionClass]\" \n @click=\"searchQuery = ''\" \n /> \n </div> \n </div> \n \n <!-- Select all --> \n <button \n v-if=\"showSelectAll && selectableOptions.length > 0\" \n type=\"button\" \n :class=\"['flex items-center justify-between gap-2 px-3 py-2 border-b border-border text-caption font-medium text-foreground transition-colors duration-fast ease-standard', optionHover]\"\n @click=\"toggleAll\" \n > \n <span>{{ allSelected ? deselectAllLabel : selectAllLabel }}</span> \n <span class=\"text-muted-foreground\"> \n {{ selectedCountOfFiltered }} / {{ selectableOptions.length }} \n </span> \n </button> \n \n <ul \n :id=\"listboxId\" \n role=\"listbox\" \n aria-multiselectable=\"true\" \n class=\"modo-stagger flex-1 overflow-y-auto\" \n tabindex=\"-1\" \n > \n <template v-if=\"groupedOptions.length === 0\"> \n <li class=\"px-3 py-4 text-caption text-muted-foreground text-center\"> \n {{ emptyText }} \n </li> \n </template> \n \n <template v-for=\"(group, gi) in groupedOptions\" :key=\"group.name ?? gi\"> \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(opt.value)\" \n :key=\"String(opt.value)\" \n role=\"option\" \n :aria-selected=\"isSelected(opt.value)\" \n :aria-disabled=\"isOptionDisabled(opt) || 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 isOptionDisabled(opt)\n ? 'text-muted-foreground/60 cursor-not-allowed'\n : ['text-foreground', optionHover],\n activeValue === opt.value && !isOptionDisabled(opt) ? optionSurface : '', \n isSelected(opt.value) ? 'font-medium' : '', \n ]\" \n @pointerenter=\"setActive(opt.value)\" \n @click=\"toggleOption(opt)\" \n > \n <!-- Checkbox marker --> \n <span \n :class=\"[ \n 'shrink-0 inline-flex items-center justify-center w-4 h-4 rounded border transition-colors duration-fast ease-standard', \n isSelected(opt.value) \n ? [checkFillClass, 'border-transparent'] \n : 'border-border bg-transparent', \n ]\" \n aria-hidden=\"true\" \n > \n <CheckIcon \n v-if=\"isSelected(opt.value)\" \n :class=\"['w-3 h-3', checkIconClass]\" \n /> \n </span> \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\">{{ opt.label }}</div> \n <div v-if=\"opt.description\" class=\"text-caption text-muted-foreground truncate\"> \n {{ opt.description }} \n </div> \n </div> \n </li> \n </template> \n </ul> \n \n <slot name=\"footer\" /> \n </div> \n </PopoverPanel> \n \n <div v-if=\"errorText || helperText || maxSelected\" 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 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=\"maxSelected\" \n class=\"text-caption text-muted-foreground ml-auto\" \n > \n {{ modelValue?.length ?? 0 }} / {{ maxSelected }} \n </p> \n </div> \n </div> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, nextTick, ref, useId, watch } from 'vue'; \nimport type { MultiSelect, SelectOption, SelectValue } from '../../interfaces/forms/Select.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 Badge from '../feedback/Badge.vue'; \nimport { ChevronDownIcon, XMarkIcon, CheckIcon, MagnifyingGlassIcon } from '@heroicons/vue/24/outline'; \nimport Button from './Button.vue'; \nimport { useModoLocale, useSizeTokens } from '../../composables/useModoConfig';\n \nconst loc = useModoLocale(); \n \nconst emit = defineEmits<{ \n 'update:modelValue': [value: SelectValue[]]; \n change: [value: SelectValue[]]; \n open: []; \n close: []; \n clear: []; \n}>(); \n \nconst props = withDefaults(defineProps<MultiSelect>(), { \n modelValue: () => [], \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 searchable: false, \n showSelectAll: false, \n selectAllLabel: 'Select all', \n deselectAllLabel: 'Deselect all', \n searchPlaceholder: 'Search…', \n emptyText: 'No results.', \n placeholder: 'Select…', \n autofocus: false, \n maxVisibleChips: 3, \n}); \n \nconst sz = useSizeTokens(() => props.size);\n \nconst { \n fieldId, \n radius, \n stateColor, \n hasError, \n isDisabled, \n errorId, \n helperId, \n describedBy, \n} = useFieldState(props, { componentName: 'MultiSelect', idPrefix: 'modo-multiselect' }); \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/* ---------- Color / radius maps (chip + check) ---------- */ \n \nconst CHECK_FILL_BY_STATE: Record<string, string> = { \n default: 'bg-foreground', \n primary: 'bg-primary', \n danger: 'bg-destructive', \n success: 'bg-success', \n warning: 'bg-warning', \n}; \nconst CHECK_ICON_BY_STATE: Record<string, string> = { \n default: 'text-background', \n primary: 'text-primary-foreground', \n danger: 'text-destructive-foreground', \n success: 'text-success-foreground', \n warning: 'text-warning-foreground', \n}; \nconst checkFillClass = computed(() => CHECK_FILL_BY_STATE[stateColor.value] ?? 'bg-foreground'); \nconst checkIconClass = computed(() => CHECK_ICON_BY_STATE[stateColor.value] ?? 'text-background'); \nconst affordanceIconClass = computed(() => FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? 'text-muted-foreground');\nconst affordanceActionClass = computed(() => FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ?? 'text-muted-foreground hover:text-foreground');\n \n/** Map field's stateColor to Badge color (identical union). */ \nconst badgeColor = computed<'default' | 'primary' | 'danger' | 'success' | 'warning'>(\n () => (stateColor.value as 'default' | 'primary' | 'danger' | 'success' | 'warning'),\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(() => OPTION_SURFACE[stateColor.value] ?? 'bg-muted');\nconst optionHover = computed(() => OPTION_HOVER[stateColor.value] ?? 'hover:bg-muted');\n\nconst autoListboxId = useId(); \nconst listboxId = computed(() => `modo-multiselect-listbox-${autoListboxId}`); \nconst optionDomId = (v: SelectValue) => `${listboxId.value}-opt-${String(v)}`; \n \nconst searchQuery = ref(''); \nconst isSearching = ref(false); \nlet searchingTimer: number | null = null; \nwatch(searchQuery, () => { \n isSearching.value = true; \n if (searchingTimer !== null) clearTimeout(searchingTimer); \n searchingTimer = window.setTimeout(() => { \n isSearching.value = false; \n searchingTimer = null; \n }, 220); \n}); \nconst searchEl = ref<HTMLInputElement | null>(null); \n \nconst selectedSet = computed(() => new Set<SelectValue>(props.modelValue ?? [])); \n \nconst selectedOptions = computed<SelectOption[]>(() => \n props.options.filter((o) => selectedSet.value.has(o.value)), \n); \n \n/* Placeholder visibility: stays hidden while the last chip is still \n * playing its leave transition, so removing the last selection does not \n * cause the placeholder text to appear to animate in alongside the chip. */ \nconst showPlaceholder = ref(selectedOptions.value.length === 0); \nwatch( \n () => selectedOptions.value.length, \n (n, prev) => { \n if (n > 0) { \n showPlaceholder.value = false; \n } else if (prev === 0) { \n // No chip is leaving (e.g. initial state, options swap): show now. \n showPlaceholder.value = true; \n } \n // n === 0 && prev > 0 → wait for @after-leave from TransitionGroup. \n }, \n); \nfunction onChipAfterLeave() { \n if (selectedOptions.value.length === 0) { \n showPlaceholder.value = true; \n } \n} \n \nconst visibleChips = computed(() => \n selectedOptions.value.slice(0, props.maxVisibleChips), \n); \nconst hiddenChipCount = computed(() => \n Math.max(0, selectedOptions.value.length - props.maxVisibleChips), \n); \n \nfunction isSelected(v: SelectValue) { \n return selectedSet.value.has(v); \n} \n \nconst atMax = computed( \n () => typeof props.maxSelected === 'number' && (props.modelValue?.length ?? 0) >= props.maxSelected, \n); \n \nfunction isOptionDisabled(opt: SelectOption) { \n if (opt.disabled) return true; \n return atMax.value && !isSelected(opt.value); \n} \n \nconst filteredOptions = computed(() => { \n if (!props.searchable || !searchQuery.value.trim()) return props.options; \n const q = searchQuery.value.trim().toLowerCase(); \n return props.options.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 = filteredOptions.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/* Opciones activables para \"select all\" (las filtradas + no deshabilitadas). */ \nconst selectableOptions = computed(() => \n flatOptions.value.filter((o) => !o.disabled), \n); \nconst selectedCountOfFiltered = computed( \n () => selectableOptions.value.filter((o) => isSelected(o.value)).length, \n); \nconst allSelected = computed( \n () => \n selectableOptions.value.length > 0 && \n selectedCountOfFiltered.value === selectableOptions.value.length, \n); \n \nfunction toggleAll() { \n if (isDisabled.value || props.readonly) return; \n const current = new Set<SelectValue>(props.modelValue ?? []); \n if (allSelected.value) { \n // Deselect sólo las visibles/filtradas. \n for (const opt of selectableOptions.value) current.delete(opt.value); \n } else { \n // Select todas las filtradas, respetando maxSelected. \n for (const opt of selectableOptions.value) { \n if ( \n typeof props.maxSelected === 'number' && \n current.size >= props.maxSelected \n ) break; \n current.add(opt.value); \n } \n } \n const next = Array.from(current); \n emit('update:modelValue', next); \n emit('change', next); \n} \n \n/* ---------- Popover ---------- */ \n \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 matchTriggerWidth: true, \n onOpen: () => { \n emit('open'); \n const initial = \n selectedOptions.value[0] ?? flatOptions.value.find((o) => !isOptionDisabled(o)); \n activeValue.value = initial ? initial.value : null; \n nextTick(() => { \n if (props.searchable) searchEl.value?.focus(); \n scrollActiveIntoView(); \n }); \n }, \n onClose: () => { \n emit('close'); \n searchQuery.value = ''; \n }, \n}); \n \nconst triggerEl = ref<HTMLButtonElement | null>(null); \nwatch(triggerEl, (el) => (triggerRef.value = el)); \n \nconst activeValue = ref<SelectValue | null>(null); \nconst activeId = computed(() => \n activeValue.value !== null ? optionDomId(activeValue.value) : '', \n); \n \nfunction setActive(v: SelectValue) { \n activeValue.value = v; \n} \n \nfunction scrollActiveIntoView() { \n if (activeValue.value === null) return; \n const el = document.getElementById(optionDomId(activeValue.value)); \n el?.scrollIntoView({ block: 'nearest' }); \n} \n \n/* ---------- Actions ---------- */ \n \nfunction openAndFocus() { \n if (isDisabled.value || props.readonly) return; \n if (!isOpen.value) openPopover(); \n triggerEl.value?.focus(); \n} \n \nfunction onTriggerClick() { \n if (isDisabled.value || props.readonly) return; \n togglePopover(); \n} \n \nfunction toggleOption(opt: SelectOption) { \n console.log('toggleOption', opt);\n if (isOptionDisabled(opt)) return; \n const current = [...(props.modelValue ?? [])]; \n const idx = current.indexOf(opt.value); \n if (idx >= 0) { \n current.splice(idx, 1); \n } else { \n current.push(opt.value); \n } \n emit('update:modelValue', current); \n emit('change', current); \n} \n \nfunction removeValue(v: SelectValue) { \n isOpen.value = false;\n event?.stopPropagation();\n const current = (props.modelValue ?? []).filter((x) => x !== v); \n emit('update:modelValue', current); \n emit('change', current); \n} \n \nfunction clear() { \n emit('update:modelValue', []); \n emit('change', []); \n emit('clear'); \n triggerEl.value?.focus(); \n} \n \n/* ---------- Keyboard ---------- */ \n \nfunction moveActive(direction: 1 | -1) { \n const list = flatOptions.value.filter((o) => !isOptionDisabled(o)); \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 jumpTo(pos: 'first' | 'last') { \n const list = flatOptions.value.filter((o) => !isOptionDisabled(o)); \n if (list.length === 0) return; \n activeValue.value = pos === 'first' ? list[0].value : list[list.length - 1].value; \n scrollActiveIntoView(); \n} \n \nlet typeaheadBuffer = ''; \nlet typeaheadTimer: number | null = null; \nfunction typeaheadJump(key: string) { \n if (typeaheadTimer !== null) clearTimeout(typeaheadTimer); \n typeaheadBuffer += key.toLowerCase(); \n typeaheadTimer = window.setTimeout(() => { \n typeaheadBuffer = ''; \n typeaheadTimer = null; \n }, 500); \n \n const match = flatOptions.value.find( \n (o) => !isOptionDisabled(o) && o.label.toLowerCase().startsWith(typeaheadBuffer), \n ); \n if (match) { \n activeValue.value = match.value; \n scrollActiveIntoView(); \n } \n} \n \nfunction onTriggerKeydown(e: KeyboardEvent) { \n if (isDisabled.value || props.readonly) return; \n \n // Backspace en trigger vacío: elimina la última selección. \n if (!isOpen.value && e.key === 'Backspace' && selectedOptions.value.length > 0) { \n e.preventDefault(); \n const current = [...(props.modelValue ?? [])]; \n current.pop(); \n emit('update:modelValue', current); \n emit('change', current); \n return; \n } \n \n if (!isOpen.value) { \n if (['Enter', ' ', 'ArrowDown', 'ArrowUp'].includes(e.key)) { \n e.preventDefault(); \n openPopover(); \n } \n return; \n } \n \n switch (e.key) { \n case 'ArrowDown': \n e.preventDefault(); \n moveActive(1); \n break; \n case 'ArrowUp': \n e.preventDefault(); \n moveActive(-1); \n break; \n case 'Home': \n e.preventDefault(); \n jumpTo('first'); \n break; \n case 'End': \n e.preventDefault(); \n jumpTo('last'); \n break; \n case 'Enter': \n case ' ': { \n e.preventDefault(); \n const opt = flatOptions.value.find((o) => o.value === activeValue.value); \n if (opt) toggleOption(opt); \n break; \n } \n case 'Tab': \n closePopover(); \n break; \n default: \n if (!props.searchable && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) { \n typeaheadJump(e.key); \n } \n break; \n } \n} \n \nfunction onSearchKeydown(e: KeyboardEvent) { \n switch (e.key) { \n case 'ArrowDown': \n e.preventDefault(); \n moveActive(1); \n break; \n case 'ArrowUp': \n e.preventDefault(); \n moveActive(-1); \n break; \n case 'Enter': { \n e.preventDefault(); \n const opt = flatOptions.value.find((o) => o.value === activeValue.value); \n if (opt) toggleOption(opt); \n break; \n } \n case 'Backspace': \n if (!searchQuery.value && selectedOptions.value.length > 0) { \n e.preventDefault(); \n const current = [...(props.modelValue ?? [])]; \n current.pop(); \n emit('update:modelValue', current); \n emit('change', current); \n } \n break; \n case 'Escape': \n break; \n } \n} \n \nwatch(filteredOptions, (list) => { \n if (!list.find((o) => o.value === activeValue.value)) { \n activeValue.value = list.find((o) => !isOptionDisabled(o))?.value ?? null; \n } \n}); \n \n/* ---------- Classes ---------- */\n\nconst wrapperSizeClasses = computed(() => {\n const minH = sz.value.control.replace('h-', 'min-h-');\n return `${minH} ${sz.value.padX} py-1`;\n});\nconst inputTextClasses = computed(() => sz.value.text);\nconst iconSizeClasses = computed(() => sz.value.icon); \n \ndefineExpose({ \n open: openPopover, \n close: closePopover, \n toggle: togglePopover, \n focus: () => triggerEl.value?.focus(), \n triggerEl, \n}); \n</script> \n \n<style scoped> \n/* Chip transitions for enter/leave + move. */ \n.modo-chip-enter-active, \n.modo-chip-leave-active { \n transition: \n transform 280ms cubic-bezier(0.2, 0, 0, 1), \n opacity 240ms cubic-bezier(0.2, 0, 0, 1), \n margin 280ms cubic-bezier(0.2, 0, 0, 1), \n max-width 280ms cubic-bezier(0.2, 0, 0, 1); \n} \n.modo-chip-move { \n transition: transform 320ms cubic-bezier(0.2, 0, 0, 1); \n} \n.modo-chip-enter-from, \n.modo-chip-leave-to { \n opacity: 0; \n transform: scale(0.7) translateY(-2px); \n /* Collapse the space smoothly so siblings can slide in. */ \n max-width: 0; \n margin-left: -0.125rem; \n margin-right: -0.125rem; \n} \n \n@media (prefers-reduced-motion: reduce) { \n .modo-chip-enter-active, \n .modo-chip-leave-active, \n .modo-chip-move { \n transition: none; \n } \n .modo-chip-enter-from, \n .modo-chip-leave-to { \n opacity: 1; \n transform: none; \n max-width: none; \n margin: 0; \n } \n} \n</style>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"MultiSelect.cjs","names":[],"sources":["../../../src/components/forms/MultiSelect.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 @click=\"openAndFocus\" \n > \n {{ label }} \n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span> \n </label> \n \n <!-- Trigger --> \n <button \n :id=\"fieldId\" \n ref=\"triggerEl\" \n type=\"button\" \n :disabled=\"isDisabled\" \n :aria-label=\"!label ? ariaLabel : undefined\" \n :aria-invalid=\"hasError || undefined\" \n :aria-describedby=\"describedBy\" \n :aria-required=\"required || undefined\" \n :aria-haspopup=\"'listbox'\" \n :aria-expanded=\"isOpen\" \n :aria-controls=\"listboxId\" \n :aria-activedescendant=\"isOpen && activeId ? activeId : undefined\" \n role=\"combobox\" \n :class=\"[ \n 'modo-field-wrapper flex items-center gap-2 text-left',\n wrapperVariantClasses, \n wrapperSizeClasses, \n radiusClasses, \n fullWidth ? 'w-full' : '', \n isDisabled ? 'opacity-60 cursor-not-allowed' : 'cursor-pointer', \n ]\" \n @click=\"onTriggerClick\" \n @keydown=\"onTriggerKeydown\" \n > \n <component \n :is=\"iconLeft\" \n v-if=\"iconLeft\" \n aria-hidden=\"true\" \n :class=\"['shrink-0', affordanceIconClass, iconSizeClasses]\" \n /> \n \n <!-- Chips --> \n <!-- \n NOTE: the TransitionGroup stays always mounted; if we toggle it \n with `v-if`, removing the last chip unmounts the group before \n Vue can play the leave transition on that chip. A sibling \n placeholder handles the empty state visually. \n --> \n <TransitionGroup \n name=\"modo-chip\" \n tag=\"div\" \n class=\"min-w-0 flex flex-wrap items-center gap-1 py-1\" \n :class=\"[selectedOptions.length ? 'flex-1' : '']\" \n @after-leave=\"onChipAfterLeave\" \n > \n <Badge \n v-for=\"opt in visibleChips\" \n :key=\"`chip-${opt.value}`\" \n variant=\"subtle\" \n :color=\"badgeColor\" \n size=\"medium\" \n :radius=\"radius\" \n :removable=\"!isDisabled && !readonly\" \n :removeAriaLabel=\"`Remove ${opt.label}`\" \n :label=\"opt.label\" \n class=\"modo-chip max-w-50\" \n @remove=\"removeValue(opt.value)\" \n /> \n <Badge \n v-if=\"hiddenChipCount > 0\" \n :key=\"'chip-overflow'\" \n variant=\"subtle\" \n :color=\"badgeColor\" \n size=\"medium\" \n :radius=\"radius\" \n :label=\"`+${hiddenChipCount}`\" \n class=\"modo-chip\" \n /> \n </TransitionGroup> \n <span \n v-if=\"showPlaceholder\" \n :class=\"['flex-1 min-w-0 truncate text-muted-foreground', inputTextClasses]\" \n > \n {{ placeholder }} \n </span> \n \n <Loader \n v-if=\"loading\" \n :size=\"size === 'large' ? 'medium' : 'small'\" \n :class=\"['shrink-0', affordanceIconClass]\" \n /> \n \n <Button \n v-else-if=\"clearable && selectedOptions.length && !isDisabled && !readonly\" \n variant=\"text\" \n size=\"xs\" \n radius=\"full\" \n :icon=\"XMarkIcon\" \n :ariaLabel=\"loc.multiSelect.clear\" \n tabindex=\"-1\" \n :class=\"['shrink-0', affordanceActionClass]\" \n @click.stop=\"clear\" \n /> \n \n <ChevronDownIcon \n v-if=\"!loading\" \n aria-hidden=\"true\" \n :class=\"[ \n 'shrink-0 transition-transform duration-base ease-standard', \n affordanceIconClass,\n iconSizeClasses, \n isOpen ? 'rotate-180' : '', \n ]\" \n /> \n </button> \n \n <!-- Hidden inputs for form integration --> \n <template v-if=\"name\"> \n <input \n v-for=\"val in modelValue\" \n :key=\"`hidden-${val}`\" \n type=\"hidden\" \n :name=\"`${name}[]`\" \n :value=\"val\" \n /> \n </template> \n \n <!-- Dropdown --> \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 <div v-if=\"searchable\" class=\"px-3 py-2 border-b border-border shrink-0\"> \n <div class=\"flex items-center gap-2 h-7\"> \n <MagnifyingGlassIcon \n v-if=\"!isSearching\" \n :class=\"['w-4 h-4 shrink-0', affordanceIconClass]\" \n aria-hidden=\"true\" \n /> \n <Loader \n v-else \n size=\"small\" \n class=\"shrink-0 text-primary\" \n /> \n <input \n ref=\"searchEl\" \n v-model=\"searchQuery\" \n type=\"text\" \n autocomplete=\"off\" \n spellcheck=\"false\" \n :placeholder=\"searchPlaceholder\" \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.multiSelect.clearSearch\" \n tabindex=\"-1\" \n :class=\"['shrink-0', affordanceActionClass]\" \n @click=\"searchQuery = ''\" \n /> \n </div> \n </div> \n \n <!-- Select all --> \n <button \n v-if=\"showSelectAll && selectableOptions.length > 0\" \n type=\"button\" \n :class=\"['flex items-center justify-between gap-2 px-3 py-2 border-b border-border text-caption font-medium text-foreground transition-colors duration-fast ease-standard', optionHover]\"\n @click=\"toggleAll\" \n > \n <span>{{ allSelected ? deselectAllLabel : selectAllLabel }}</span> \n <span class=\"text-muted-foreground\"> \n {{ selectedCountOfFiltered }} / {{ selectableOptions.length }} \n </span> \n </button> \n \n <ul \n :id=\"listboxId\" \n role=\"listbox\" \n aria-multiselectable=\"true\" \n class=\"modo-stagger flex-1 overflow-y-auto\" \n tabindex=\"-1\" \n > \n <template v-if=\"groupedOptions.length === 0\"> \n <li class=\"px-3 py-4 text-caption text-muted-foreground text-center\"> \n {{ emptyText }} \n </li> \n </template> \n \n <template v-for=\"(group, gi) in groupedOptions\" :key=\"group.name ?? gi\"> \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(opt.value)\" \n :key=\"String(opt.value)\" \n role=\"option\" \n :aria-selected=\"isSelected(opt.value)\" \n :aria-disabled=\"isOptionDisabled(opt) || 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 isOptionDisabled(opt)\n ? 'text-muted-foreground/60 cursor-not-allowed'\n : ['text-foreground', optionHover],\n activeValue === opt.value && !isOptionDisabled(opt) ? optionSurface : '', \n isSelected(opt.value) ? 'font-medium' : '', \n ]\" \n @pointerenter=\"setActive(opt.value)\" \n @click=\"toggleOption(opt)\" \n > \n <!-- Checkbox marker --> \n <span \n :class=\"[ \n 'shrink-0 inline-flex items-center justify-center w-4 h-4 rounded border transition-colors duration-fast ease-standard', \n isSelected(opt.value) \n ? [checkFillClass, 'border-transparent'] \n : 'border-input bg-transparent', \n ]\" \n aria-hidden=\"true\" \n > \n <CheckIcon \n v-if=\"isSelected(opt.value)\" \n :class=\"['w-3 h-3', checkIconClass]\" \n /> \n </span> \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\">{{ opt.label }}</div> \n <div v-if=\"opt.description\" class=\"text-caption text-muted-foreground truncate\"> \n {{ opt.description }} \n </div> \n </div> \n </li> \n </template> \n </ul> \n \n <slot name=\"footer\" /> \n </div> \n </PopoverPanel> \n \n <div v-if=\"errorText || helperText || maxSelected\" 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 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=\"maxSelected\" \n class=\"text-caption text-muted-foreground ml-auto\" \n > \n {{ modelValue?.length ?? 0 }} / {{ maxSelected }} \n </p> \n </div> \n </div> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, nextTick, ref, useId, watch } from 'vue'; \nimport type { MultiSelect, SelectOption, SelectValue } from '../../interfaces/forms/Select.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 Badge from '../feedback/Badge.vue'; \nimport { ChevronDownIcon, XMarkIcon, CheckIcon, MagnifyingGlassIcon } from '@heroicons/vue/24/outline'; \nimport Button from './Button.vue'; \nimport { useModoLocale, useSizeTokens } from '../../composables/useModoConfig';\n \nconst loc = useModoLocale(); \n \nconst emit = defineEmits<{ \n 'update:modelValue': [value: SelectValue[]]; \n change: [value: SelectValue[]]; \n open: []; \n close: []; \n clear: []; \n}>(); \n \nconst props = withDefaults(defineProps<MultiSelect>(), { \n modelValue: () => [], \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 searchable: false, \n showSelectAll: false, \n selectAllLabel: 'Select all', \n deselectAllLabel: 'Deselect all', \n searchPlaceholder: 'Search…', \n emptyText: 'No results.', \n placeholder: 'Select…', \n autofocus: false, \n maxVisibleChips: 3, \n}); \n \nconst sz = useSizeTokens(() => props.size);\n \nconst { \n fieldId, \n radius, \n stateColor, \n hasError, \n isDisabled, \n errorId, \n helperId, \n describedBy, \n} = useFieldState(props, { componentName: 'MultiSelect', idPrefix: 'modo-multiselect' }); \n \nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({ \n variant: () => props.variant, \n stateColor, \n hasError, \n radius, \n radiusKind: 'grow', \n forceFocus: () => isOpen.value, \n halo: () => props.halo, \n}); \n \n/* ---------- Color / radius maps (chip + check) ---------- */ \n \nconst CHECK_FILL_BY_STATE: Record<string, string> = { \n default: 'bg-foreground', \n primary: 'bg-primary', \n danger: 'bg-destructive', \n success: 'bg-success', \n warning: 'bg-warning', \n}; \nconst CHECK_ICON_BY_STATE: Record<string, string> = { \n default: 'text-background', \n primary: 'text-primary-foreground', \n danger: 'text-destructive-foreground', \n success: 'text-success-foreground', \n warning: 'text-warning-foreground', \n}; \nconst checkFillClass = computed(() => CHECK_FILL_BY_STATE[stateColor.value] ?? 'bg-foreground'); \nconst checkIconClass = computed(() => CHECK_ICON_BY_STATE[stateColor.value] ?? 'text-background'); \nconst affordanceIconClass = computed(() => FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? 'text-muted-foreground');\nconst affordanceActionClass = computed(() => FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ?? 'text-muted-foreground hover:text-foreground');\n \n/** Map field's stateColor to Badge color (identical union). */ \nconst badgeColor = computed<'default' | 'primary' | 'danger' | 'success' | 'warning'>(\n () => (stateColor.value as 'default' | 'primary' | 'danger' | 'success' | 'warning'),\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(() => OPTION_SURFACE[stateColor.value] ?? 'bg-muted');\nconst optionHover = computed(() => OPTION_HOVER[stateColor.value] ?? 'hover:bg-muted');\n\nconst autoListboxId = useId(); \nconst listboxId = computed(() => `modo-multiselect-listbox-${autoListboxId}`); \nconst optionDomId = (v: SelectValue) => `${listboxId.value}-opt-${String(v)}`; \n \nconst searchQuery = ref(''); \nconst isSearching = ref(false); \nlet searchingTimer: number | null = null; \nwatch(searchQuery, () => { \n isSearching.value = true; \n if (searchingTimer !== null) clearTimeout(searchingTimer); \n searchingTimer = window.setTimeout(() => { \n isSearching.value = false; \n searchingTimer = null; \n }, 220); \n}); \nconst searchEl = ref<HTMLInputElement | null>(null); \n \nconst selectedSet = computed(() => new Set<SelectValue>(props.modelValue ?? [])); \n \nconst selectedOptions = computed<SelectOption[]>(() => \n props.options.filter((o) => selectedSet.value.has(o.value)), \n); \n \n/* Placeholder visibility: stays hidden while the last chip is still \n * playing its leave transition, so removing the last selection does not \n * cause the placeholder text to appear to animate in alongside the chip. */ \nconst showPlaceholder = ref(selectedOptions.value.length === 0); \nwatch( \n () => selectedOptions.value.length, \n (n, prev) => { \n if (n > 0) { \n showPlaceholder.value = false; \n } else if (prev === 0) { \n // No chip is leaving (e.g. initial state, options swap): show now. \n showPlaceholder.value = true; \n } \n // n === 0 && prev > 0 → wait for @after-leave from TransitionGroup. \n }, \n); \nfunction onChipAfterLeave() { \n if (selectedOptions.value.length === 0) { \n showPlaceholder.value = true; \n } \n} \n \nconst visibleChips = computed(() => \n selectedOptions.value.slice(0, props.maxVisibleChips), \n); \nconst hiddenChipCount = computed(() => \n Math.max(0, selectedOptions.value.length - props.maxVisibleChips), \n); \n \nfunction isSelected(v: SelectValue) { \n return selectedSet.value.has(v); \n} \n \nconst atMax = computed( \n () => typeof props.maxSelected === 'number' && (props.modelValue?.length ?? 0) >= props.maxSelected, \n); \n \nfunction isOptionDisabled(opt: SelectOption) { \n if (opt.disabled) return true; \n return atMax.value && !isSelected(opt.value); \n} \n \nconst filteredOptions = computed(() => { \n if (!props.searchable || !searchQuery.value.trim()) return props.options; \n const q = searchQuery.value.trim().toLowerCase(); \n return props.options.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 = filteredOptions.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/* Opciones activables para \"select all\" (las filtradas + no deshabilitadas). */ \nconst selectableOptions = computed(() => \n flatOptions.value.filter((o) => !o.disabled), \n); \nconst selectedCountOfFiltered = computed( \n () => selectableOptions.value.filter((o) => isSelected(o.value)).length, \n); \nconst allSelected = computed( \n () => \n selectableOptions.value.length > 0 && \n selectedCountOfFiltered.value === selectableOptions.value.length, \n); \n \nfunction toggleAll() { \n if (isDisabled.value || props.readonly) return; \n const current = new Set<SelectValue>(props.modelValue ?? []); \n if (allSelected.value) { \n // Deselect sólo las visibles/filtradas. \n for (const opt of selectableOptions.value) current.delete(opt.value); \n } else { \n // Select todas las filtradas, respetando maxSelected. \n for (const opt of selectableOptions.value) { \n if ( \n typeof props.maxSelected === 'number' && \n current.size >= props.maxSelected \n ) break; \n current.add(opt.value); \n } \n } \n const next = Array.from(current); \n emit('update:modelValue', next); \n emit('change', next); \n} \n \n/* ---------- Popover ---------- */ \n \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 matchTriggerWidth: true, \n onOpen: () => { \n emit('open'); \n const initial = \n selectedOptions.value[0] ?? flatOptions.value.find((o) => !isOptionDisabled(o)); \n activeValue.value = initial ? initial.value : null; \n nextTick(() => { \n if (props.searchable) searchEl.value?.focus(); \n scrollActiveIntoView(); \n }); \n }, \n onClose: () => { \n emit('close'); \n searchQuery.value = ''; \n }, \n}); \n \nconst triggerEl = ref<HTMLButtonElement | null>(null); \nwatch(triggerEl, (el) => (triggerRef.value = el)); \n \nconst activeValue = ref<SelectValue | null>(null); \nconst activeId = computed(() => \n activeValue.value !== null ? optionDomId(activeValue.value) : '', \n); \n \nfunction setActive(v: SelectValue) { \n activeValue.value = v; \n} \n \nfunction scrollActiveIntoView() { \n if (activeValue.value === null) return; \n const el = document.getElementById(optionDomId(activeValue.value)); \n el?.scrollIntoView({ block: 'nearest' }); \n} \n \n/* ---------- Actions ---------- */ \n \nfunction openAndFocus() { \n if (isDisabled.value || props.readonly) return; \n if (!isOpen.value) openPopover(); \n triggerEl.value?.focus(); \n} \n \nfunction onTriggerClick() { \n if (isDisabled.value || props.readonly) return; \n togglePopover(); \n} \n \nfunction toggleOption(opt: SelectOption) { \n console.log('toggleOption', opt);\n if (isOptionDisabled(opt)) return; \n const current = [...(props.modelValue ?? [])]; \n const idx = current.indexOf(opt.value); \n if (idx >= 0) { \n current.splice(idx, 1); \n } else { \n current.push(opt.value); \n } \n emit('update:modelValue', current); \n emit('change', current); \n} \n \nfunction removeValue(v: SelectValue) { \n isOpen.value = false;\n event?.stopPropagation();\n const current = (props.modelValue ?? []).filter((x) => x !== v); \n emit('update:modelValue', current); \n emit('change', current); \n} \n \nfunction clear() { \n emit('update:modelValue', []); \n emit('change', []); \n emit('clear'); \n triggerEl.value?.focus(); \n} \n \n/* ---------- Keyboard ---------- */ \n \nfunction moveActive(direction: 1 | -1) { \n const list = flatOptions.value.filter((o) => !isOptionDisabled(o)); \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 jumpTo(pos: 'first' | 'last') { \n const list = flatOptions.value.filter((o) => !isOptionDisabled(o)); \n if (list.length === 0) return; \n activeValue.value = pos === 'first' ? list[0].value : list[list.length - 1].value; \n scrollActiveIntoView(); \n} \n \nlet typeaheadBuffer = ''; \nlet typeaheadTimer: number | null = null; \nfunction typeaheadJump(key: string) { \n if (typeaheadTimer !== null) clearTimeout(typeaheadTimer); \n typeaheadBuffer += key.toLowerCase(); \n typeaheadTimer = window.setTimeout(() => { \n typeaheadBuffer = ''; \n typeaheadTimer = null; \n }, 500); \n \n const match = flatOptions.value.find( \n (o) => !isOptionDisabled(o) && o.label.toLowerCase().startsWith(typeaheadBuffer), \n ); \n if (match) { \n activeValue.value = match.value; \n scrollActiveIntoView(); \n } \n} \n \nfunction onTriggerKeydown(e: KeyboardEvent) { \n if (isDisabled.value || props.readonly) return; \n \n // Backspace en trigger vacío: elimina la última selección. \n if (!isOpen.value && e.key === 'Backspace' && selectedOptions.value.length > 0) { \n e.preventDefault(); \n const current = [...(props.modelValue ?? [])]; \n current.pop(); \n emit('update:modelValue', current); \n emit('change', current); \n return; \n } \n \n if (!isOpen.value) { \n if (['Enter', ' ', 'ArrowDown', 'ArrowUp'].includes(e.key)) { \n e.preventDefault(); \n openPopover(); \n } \n return; \n } \n \n switch (e.key) { \n case 'ArrowDown': \n e.preventDefault(); \n moveActive(1); \n break; \n case 'ArrowUp': \n e.preventDefault(); \n moveActive(-1); \n break; \n case 'Home': \n e.preventDefault(); \n jumpTo('first'); \n break; \n case 'End': \n e.preventDefault(); \n jumpTo('last'); \n break; \n case 'Enter': \n case ' ': { \n e.preventDefault(); \n const opt = flatOptions.value.find((o) => o.value === activeValue.value); \n if (opt) toggleOption(opt); \n break; \n } \n case 'Tab': \n closePopover(); \n break; \n default: \n if (!props.searchable && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) { \n typeaheadJump(e.key); \n } \n break; \n } \n} \n \nfunction onSearchKeydown(e: KeyboardEvent) { \n switch (e.key) { \n case 'ArrowDown': \n e.preventDefault(); \n moveActive(1); \n break; \n case 'ArrowUp': \n e.preventDefault(); \n moveActive(-1); \n break; \n case 'Enter': { \n e.preventDefault(); \n const opt = flatOptions.value.find((o) => o.value === activeValue.value); \n if (opt) toggleOption(opt); \n break; \n } \n case 'Backspace': \n if (!searchQuery.value && selectedOptions.value.length > 0) { \n e.preventDefault(); \n const current = [...(props.modelValue ?? [])]; \n current.pop(); \n emit('update:modelValue', current); \n emit('change', current); \n } \n break; \n case 'Escape': \n break; \n } \n} \n \nwatch(filteredOptions, (list) => { \n if (!list.find((o) => o.value === activeValue.value)) { \n activeValue.value = list.find((o) => !isOptionDisabled(o))?.value ?? null; \n } \n}); \n \n/* ---------- Classes ---------- */\n\nconst wrapperSizeClasses = computed(() => {\n const minH = sz.value.control.replace('h-', 'min-h-');\n return `${minH} ${sz.value.padX} py-1`;\n});\nconst inputTextClasses = computed(() => sz.value.text);\nconst iconSizeClasses = computed(() => sz.value.icon); \n \ndefineExpose({ \n open: openPopover, \n close: closePopover, \n toggle: togglePopover, \n focus: () => triggerEl.value?.focus(), \n triggerEl, \n}); \n</script> \n \n<style scoped> \n/* Chip transitions for enter/leave + move. */ \n.modo-chip-enter-active, \n.modo-chip-leave-active { \n transition: \n transform 280ms cubic-bezier(0.2, 0, 0, 1), \n opacity 240ms cubic-bezier(0.2, 0, 0, 1), \n margin 280ms cubic-bezier(0.2, 0, 0, 1), \n max-width 280ms cubic-bezier(0.2, 0, 0, 1); \n} \n.modo-chip-move { \n transition: transform 320ms cubic-bezier(0.2, 0, 0, 1); \n} \n.modo-chip-enter-from, \n.modo-chip-leave-to { \n opacity: 0; \n transform: scale(0.7) translateY(-2px); \n /* Collapse the space smoothly so siblings can slide in. */ \n max-width: 0; \n margin-left: -0.125rem; \n margin-right: -0.125rem; \n} \n \n@media (prefers-reduced-motion: reduce) { \n .modo-chip-enter-active, \n .modo-chip-leave-active, \n .modo-chip-move { \n transition: none; \n } \n .modo-chip-enter-from, \n .modo-chip-leave-to { \n opacity: 1; \n transform: none; \n max-width: none; \n margin: 0; \n } \n} \n</style>\n"],"mappings":""}
|
|
@@ -2,7 +2,7 @@ import _plugin_vue_export_helper_default from "../../_virtual/_plugin-vue_export
|
|
|
2
2
|
import MultiSelect_vue_vue_type_script_setup_true_lang_default from "./MultiSelect.vue_vue_type_script_setup_true_lang.mjs";
|
|
3
3
|
/* empty css */
|
|
4
4
|
//#region src/components/forms/MultiSelect.vue
|
|
5
|
-
var MultiSelect_default = /* @__PURE__ */ _plugin_vue_export_helper_default(MultiSelect_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-
|
|
5
|
+
var MultiSelect_default = /* @__PURE__ */ _plugin_vue_export_helper_default(MultiSelect_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-c2686e7f"]]);
|
|
6
6
|
//#endregion
|
|
7
7
|
export { MultiSelect_default as default };
|
|
8
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelect.mjs","names":[],"sources":["../../../src/components/forms/MultiSelect.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 @click=\"openAndFocus\" \n > \n {{ label }} \n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span> \n </label> \n \n <!-- Trigger --> \n <button \n :id=\"fieldId\" \n ref=\"triggerEl\" \n type=\"button\" \n :disabled=\"isDisabled\" \n :aria-label=\"!label ? ariaLabel : undefined\" \n :aria-invalid=\"hasError || undefined\" \n :aria-describedby=\"describedBy\" \n :aria-required=\"required || undefined\" \n :aria-haspopup=\"'listbox'\" \n :aria-expanded=\"isOpen\" \n :aria-controls=\"listboxId\" \n :aria-activedescendant=\"isOpen && activeId ? activeId : undefined\" \n role=\"combobox\" \n :class=\"[ \n 'modo-field-wrapper flex items-center gap-2 text-left',\n wrapperVariantClasses, \n wrapperSizeClasses, \n radiusClasses, \n fullWidth ? 'w-full' : '', \n isDisabled ? 'opacity-60 cursor-not-allowed' : 'cursor-pointer', \n ]\" \n @click=\"onTriggerClick\" \n @keydown=\"onTriggerKeydown\" \n > \n <component \n :is=\"iconLeft\" \n v-if=\"iconLeft\" \n aria-hidden=\"true\" \n :class=\"['shrink-0', affordanceIconClass, iconSizeClasses]\" \n /> \n \n <!-- Chips --> \n <!-- \n NOTE: the TransitionGroup stays always mounted; if we toggle it \n with `v-if`, removing the last chip unmounts the group before \n Vue can play the leave transition on that chip. A sibling \n placeholder handles the empty state visually. \n --> \n <TransitionGroup \n name=\"modo-chip\" \n tag=\"div\" \n class=\"min-w-0 flex flex-wrap items-center gap-1 py-1\" \n :class=\"[selectedOptions.length ? 'flex-1' : '']\" \n @after-leave=\"onChipAfterLeave\" \n > \n <Badge \n v-for=\"opt in visibleChips\" \n :key=\"`chip-${opt.value}`\" \n variant=\"subtle\" \n :color=\"badgeColor\" \n size=\"medium\" \n :radius=\"radius\" \n :removable=\"!isDisabled && !readonly\" \n :removeAriaLabel=\"`Remove ${opt.label}`\" \n :label=\"opt.label\" \n class=\"modo-chip max-w-50\" \n @remove=\"removeValue(opt.value)\" \n /> \n <Badge \n v-if=\"hiddenChipCount > 0\" \n :key=\"'chip-overflow'\" \n variant=\"subtle\" \n :color=\"badgeColor\" \n size=\"medium\" \n :radius=\"radius\" \n :label=\"`+${hiddenChipCount}`\" \n class=\"modo-chip\" \n /> \n </TransitionGroup> \n <span \n v-if=\"showPlaceholder\" \n :class=\"['flex-1 min-w-0 truncate text-muted-foreground', inputTextClasses]\" \n > \n {{ placeholder }} \n </span> \n \n <Loader \n v-if=\"loading\" \n :size=\"size === 'large' ? 'medium' : 'small'\" \n :class=\"['shrink-0', affordanceIconClass]\" \n /> \n \n <Button \n v-else-if=\"clearable && selectedOptions.length && !isDisabled && !readonly\" \n variant=\"text\" \n size=\"xs\" \n radius=\"full\" \n :icon=\"XMarkIcon\" \n :ariaLabel=\"loc.multiSelect.clear\" \n tabindex=\"-1\" \n :class=\"['shrink-0', affordanceActionClass]\" \n @click.stop=\"clear\" \n /> \n \n <ChevronDownIcon \n v-if=\"!loading\" \n aria-hidden=\"true\" \n :class=\"[ \n 'shrink-0 transition-transform duration-base ease-standard', \n affordanceIconClass,\n iconSizeClasses, \n isOpen ? 'rotate-180' : '', \n ]\" \n /> \n </button> \n \n <!-- Hidden inputs for form integration --> \n <template v-if=\"name\"> \n <input \n v-for=\"val in modelValue\" \n :key=\"`hidden-${val}`\" \n type=\"hidden\" \n :name=\"`${name}[]`\" \n :value=\"val\" \n /> \n </template> \n \n <!-- Dropdown --> \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 <div v-if=\"searchable\" class=\"px-3 py-2 border-b border-border shrink-0\"> \n <div class=\"flex items-center gap-2 h-7\"> \n <MagnifyingGlassIcon \n v-if=\"!isSearching\" \n :class=\"['w-4 h-4 shrink-0', affordanceIconClass]\" \n aria-hidden=\"true\" \n /> \n <Loader \n v-else \n size=\"small\" \n class=\"shrink-0 text-primary\" \n /> \n <input \n ref=\"searchEl\" \n v-model=\"searchQuery\" \n type=\"text\" \n autocomplete=\"off\" \n spellcheck=\"false\" \n :placeholder=\"searchPlaceholder\" \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.multiSelect.clearSearch\" \n tabindex=\"-1\" \n :class=\"['shrink-0', affordanceActionClass]\" \n @click=\"searchQuery = ''\" \n /> \n </div> \n </div> \n \n <!-- Select all --> \n <button \n v-if=\"showSelectAll && selectableOptions.length > 0\" \n type=\"button\" \n :class=\"['flex items-center justify-between gap-2 px-3 py-2 border-b border-border text-caption font-medium text-foreground transition-colors duration-fast ease-standard', optionHover]\"\n @click=\"toggleAll\" \n > \n <span>{{ allSelected ? deselectAllLabel : selectAllLabel }}</span> \n <span class=\"text-muted-foreground\"> \n {{ selectedCountOfFiltered }} / {{ selectableOptions.length }} \n </span> \n </button> \n \n <ul \n :id=\"listboxId\" \n role=\"listbox\" \n aria-multiselectable=\"true\" \n class=\"modo-stagger flex-1 overflow-y-auto\" \n tabindex=\"-1\" \n > \n <template v-if=\"groupedOptions.length === 0\"> \n <li class=\"px-3 py-4 text-caption text-muted-foreground text-center\"> \n {{ emptyText }} \n </li> \n </template> \n \n <template v-for=\"(group, gi) in groupedOptions\" :key=\"group.name ?? gi\"> \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(opt.value)\" \n :key=\"String(opt.value)\" \n role=\"option\" \n :aria-selected=\"isSelected(opt.value)\" \n :aria-disabled=\"isOptionDisabled(opt) || 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 isOptionDisabled(opt)\n ? 'text-muted-foreground/60 cursor-not-allowed'\n : ['text-foreground', optionHover],\n activeValue === opt.value && !isOptionDisabled(opt) ? optionSurface : '', \n isSelected(opt.value) ? 'font-medium' : '', \n ]\" \n @pointerenter=\"setActive(opt.value)\" \n @click=\"toggleOption(opt)\" \n > \n <!-- Checkbox marker --> \n <span \n :class=\"[ \n 'shrink-0 inline-flex items-center justify-center w-4 h-4 rounded border transition-colors duration-fast ease-standard', \n isSelected(opt.value) \n ? [checkFillClass, 'border-transparent'] \n : 'border-border bg-transparent', \n ]\" \n aria-hidden=\"true\" \n > \n <CheckIcon \n v-if=\"isSelected(opt.value)\" \n :class=\"['w-3 h-3', checkIconClass]\" \n /> \n </span> \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\">{{ opt.label }}</div> \n <div v-if=\"opt.description\" class=\"text-caption text-muted-foreground truncate\"> \n {{ opt.description }} \n </div> \n </div> \n </li> \n </template> \n </ul> \n \n <slot name=\"footer\" /> \n </div> \n </PopoverPanel> \n \n <div v-if=\"errorText || helperText || maxSelected\" 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 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=\"maxSelected\" \n class=\"text-caption text-muted-foreground ml-auto\" \n > \n {{ modelValue?.length ?? 0 }} / {{ maxSelected }} \n </p> \n </div> \n </div> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, nextTick, ref, useId, watch } from 'vue'; \nimport type { MultiSelect, SelectOption, SelectValue } from '../../interfaces/forms/Select.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 Badge from '../feedback/Badge.vue'; \nimport { ChevronDownIcon, XMarkIcon, CheckIcon, MagnifyingGlassIcon } from '@heroicons/vue/24/outline'; \nimport Button from './Button.vue'; \nimport { useModoLocale, useSizeTokens } from '../../composables/useModoConfig';\n \nconst loc = useModoLocale(); \n \nconst emit = defineEmits<{ \n 'update:modelValue': [value: SelectValue[]]; \n change: [value: SelectValue[]]; \n open: []; \n close: []; \n clear: []; \n}>(); \n \nconst props = withDefaults(defineProps<MultiSelect>(), { \n modelValue: () => [], \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 searchable: false, \n showSelectAll: false, \n selectAllLabel: 'Select all', \n deselectAllLabel: 'Deselect all', \n searchPlaceholder: 'Search…', \n emptyText: 'No results.', \n placeholder: 'Select…', \n autofocus: false, \n maxVisibleChips: 3, \n}); \n \nconst sz = useSizeTokens(() => props.size);\n \nconst { \n fieldId, \n radius, \n stateColor, \n hasError, \n isDisabled, \n errorId, \n helperId, \n describedBy, \n} = useFieldState(props, { componentName: 'MultiSelect', idPrefix: 'modo-multiselect' }); \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/* ---------- Color / radius maps (chip + check) ---------- */ \n \nconst CHECK_FILL_BY_STATE: Record<string, string> = { \n default: 'bg-foreground', \n primary: 'bg-primary', \n danger: 'bg-destructive', \n success: 'bg-success', \n warning: 'bg-warning', \n}; \nconst CHECK_ICON_BY_STATE: Record<string, string> = { \n default: 'text-background', \n primary: 'text-primary-foreground', \n danger: 'text-destructive-foreground', \n success: 'text-success-foreground', \n warning: 'text-warning-foreground', \n}; \nconst checkFillClass = computed(() => CHECK_FILL_BY_STATE[stateColor.value] ?? 'bg-foreground'); \nconst checkIconClass = computed(() => CHECK_ICON_BY_STATE[stateColor.value] ?? 'text-background'); \nconst affordanceIconClass = computed(() => FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? 'text-muted-foreground');\nconst affordanceActionClass = computed(() => FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ?? 'text-muted-foreground hover:text-foreground');\n \n/** Map field's stateColor to Badge color (identical union). */ \nconst badgeColor = computed<'default' | 'primary' | 'danger' | 'success' | 'warning'>(\n () => (stateColor.value as 'default' | 'primary' | 'danger' | 'success' | 'warning'),\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(() => OPTION_SURFACE[stateColor.value] ?? 'bg-muted');\nconst optionHover = computed(() => OPTION_HOVER[stateColor.value] ?? 'hover:bg-muted');\n\nconst autoListboxId = useId(); \nconst listboxId = computed(() => `modo-multiselect-listbox-${autoListboxId}`); \nconst optionDomId = (v: SelectValue) => `${listboxId.value}-opt-${String(v)}`; \n \nconst searchQuery = ref(''); \nconst isSearching = ref(false); \nlet searchingTimer: number | null = null; \nwatch(searchQuery, () => { \n isSearching.value = true; \n if (searchingTimer !== null) clearTimeout(searchingTimer); \n searchingTimer = window.setTimeout(() => { \n isSearching.value = false; \n searchingTimer = null; \n }, 220); \n}); \nconst searchEl = ref<HTMLInputElement | null>(null); \n \nconst selectedSet = computed(() => new Set<SelectValue>(props.modelValue ?? [])); \n \nconst selectedOptions = computed<SelectOption[]>(() => \n props.options.filter((o) => selectedSet.value.has(o.value)), \n); \n \n/* Placeholder visibility: stays hidden while the last chip is still \n * playing its leave transition, so removing the last selection does not \n * cause the placeholder text to appear to animate in alongside the chip. */ \nconst showPlaceholder = ref(selectedOptions.value.length === 0); \nwatch( \n () => selectedOptions.value.length, \n (n, prev) => { \n if (n > 0) { \n showPlaceholder.value = false; \n } else if (prev === 0) { \n // No chip is leaving (e.g. initial state, options swap): show now. \n showPlaceholder.value = true; \n } \n // n === 0 && prev > 0 → wait for @after-leave from TransitionGroup. \n }, \n); \nfunction onChipAfterLeave() { \n if (selectedOptions.value.length === 0) { \n showPlaceholder.value = true; \n } \n} \n \nconst visibleChips = computed(() => \n selectedOptions.value.slice(0, props.maxVisibleChips), \n); \nconst hiddenChipCount = computed(() => \n Math.max(0, selectedOptions.value.length - props.maxVisibleChips), \n); \n \nfunction isSelected(v: SelectValue) { \n return selectedSet.value.has(v); \n} \n \nconst atMax = computed( \n () => typeof props.maxSelected === 'number' && (props.modelValue?.length ?? 0) >= props.maxSelected, \n); \n \nfunction isOptionDisabled(opt: SelectOption) { \n if (opt.disabled) return true; \n return atMax.value && !isSelected(opt.value); \n} \n \nconst filteredOptions = computed(() => { \n if (!props.searchable || !searchQuery.value.trim()) return props.options; \n const q = searchQuery.value.trim().toLowerCase(); \n return props.options.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 = filteredOptions.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/* Opciones activables para \"select all\" (las filtradas + no deshabilitadas). */ \nconst selectableOptions = computed(() => \n flatOptions.value.filter((o) => !o.disabled), \n); \nconst selectedCountOfFiltered = computed( \n () => selectableOptions.value.filter((o) => isSelected(o.value)).length, \n); \nconst allSelected = computed( \n () => \n selectableOptions.value.length > 0 && \n selectedCountOfFiltered.value === selectableOptions.value.length, \n); \n \nfunction toggleAll() { \n if (isDisabled.value || props.readonly) return; \n const current = new Set<SelectValue>(props.modelValue ?? []); \n if (allSelected.value) { \n // Deselect sólo las visibles/filtradas. \n for (const opt of selectableOptions.value) current.delete(opt.value); \n } else { \n // Select todas las filtradas, respetando maxSelected. \n for (const opt of selectableOptions.value) { \n if ( \n typeof props.maxSelected === 'number' && \n current.size >= props.maxSelected \n ) break; \n current.add(opt.value); \n } \n } \n const next = Array.from(current); \n emit('update:modelValue', next); \n emit('change', next); \n} \n \n/* ---------- Popover ---------- */ \n \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 matchTriggerWidth: true, \n onOpen: () => { \n emit('open'); \n const initial = \n selectedOptions.value[0] ?? flatOptions.value.find((o) => !isOptionDisabled(o)); \n activeValue.value = initial ? initial.value : null; \n nextTick(() => { \n if (props.searchable) searchEl.value?.focus(); \n scrollActiveIntoView(); \n }); \n }, \n onClose: () => { \n emit('close'); \n searchQuery.value = ''; \n }, \n}); \n \nconst triggerEl = ref<HTMLButtonElement | null>(null); \nwatch(triggerEl, (el) => (triggerRef.value = el)); \n \nconst activeValue = ref<SelectValue | null>(null); \nconst activeId = computed(() => \n activeValue.value !== null ? optionDomId(activeValue.value) : '', \n); \n \nfunction setActive(v: SelectValue) { \n activeValue.value = v; \n} \n \nfunction scrollActiveIntoView() { \n if (activeValue.value === null) return; \n const el = document.getElementById(optionDomId(activeValue.value)); \n el?.scrollIntoView({ block: 'nearest' }); \n} \n \n/* ---------- Actions ---------- */ \n \nfunction openAndFocus() { \n if (isDisabled.value || props.readonly) return; \n if (!isOpen.value) openPopover(); \n triggerEl.value?.focus(); \n} \n \nfunction onTriggerClick() { \n if (isDisabled.value || props.readonly) return; \n togglePopover(); \n} \n \nfunction toggleOption(opt: SelectOption) { \n console.log('toggleOption', opt);\n if (isOptionDisabled(opt)) return; \n const current = [...(props.modelValue ?? [])]; \n const idx = current.indexOf(opt.value); \n if (idx >= 0) { \n current.splice(idx, 1); \n } else { \n current.push(opt.value); \n } \n emit('update:modelValue', current); \n emit('change', current); \n} \n \nfunction removeValue(v: SelectValue) { \n isOpen.value = false;\n event?.stopPropagation();\n const current = (props.modelValue ?? []).filter((x) => x !== v); \n emit('update:modelValue', current); \n emit('change', current); \n} \n \nfunction clear() { \n emit('update:modelValue', []); \n emit('change', []); \n emit('clear'); \n triggerEl.value?.focus(); \n} \n \n/* ---------- Keyboard ---------- */ \n \nfunction moveActive(direction: 1 | -1) { \n const list = flatOptions.value.filter((o) => !isOptionDisabled(o)); \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 jumpTo(pos: 'first' | 'last') { \n const list = flatOptions.value.filter((o) => !isOptionDisabled(o)); \n if (list.length === 0) return; \n activeValue.value = pos === 'first' ? list[0].value : list[list.length - 1].value; \n scrollActiveIntoView(); \n} \n \nlet typeaheadBuffer = ''; \nlet typeaheadTimer: number | null = null; \nfunction typeaheadJump(key: string) { \n if (typeaheadTimer !== null) clearTimeout(typeaheadTimer); \n typeaheadBuffer += key.toLowerCase(); \n typeaheadTimer = window.setTimeout(() => { \n typeaheadBuffer = ''; \n typeaheadTimer = null; \n }, 500); \n \n const match = flatOptions.value.find( \n (o) => !isOptionDisabled(o) && o.label.toLowerCase().startsWith(typeaheadBuffer), \n ); \n if (match) { \n activeValue.value = match.value; \n scrollActiveIntoView(); \n } \n} \n \nfunction onTriggerKeydown(e: KeyboardEvent) { \n if (isDisabled.value || props.readonly) return; \n \n // Backspace en trigger vacío: elimina la última selección. \n if (!isOpen.value && e.key === 'Backspace' && selectedOptions.value.length > 0) { \n e.preventDefault(); \n const current = [...(props.modelValue ?? [])]; \n current.pop(); \n emit('update:modelValue', current); \n emit('change', current); \n return; \n } \n \n if (!isOpen.value) { \n if (['Enter', ' ', 'ArrowDown', 'ArrowUp'].includes(e.key)) { \n e.preventDefault(); \n openPopover(); \n } \n return; \n } \n \n switch (e.key) { \n case 'ArrowDown': \n e.preventDefault(); \n moveActive(1); \n break; \n case 'ArrowUp': \n e.preventDefault(); \n moveActive(-1); \n break; \n case 'Home': \n e.preventDefault(); \n jumpTo('first'); \n break; \n case 'End': \n e.preventDefault(); \n jumpTo('last'); \n break; \n case 'Enter': \n case ' ': { \n e.preventDefault(); \n const opt = flatOptions.value.find((o) => o.value === activeValue.value); \n if (opt) toggleOption(opt); \n break; \n } \n case 'Tab': \n closePopover(); \n break; \n default: \n if (!props.searchable && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) { \n typeaheadJump(e.key); \n } \n break; \n } \n} \n \nfunction onSearchKeydown(e: KeyboardEvent) { \n switch (e.key) { \n case 'ArrowDown': \n e.preventDefault(); \n moveActive(1); \n break; \n case 'ArrowUp': \n e.preventDefault(); \n moveActive(-1); \n break; \n case 'Enter': { \n e.preventDefault(); \n const opt = flatOptions.value.find((o) => o.value === activeValue.value); \n if (opt) toggleOption(opt); \n break; \n } \n case 'Backspace': \n if (!searchQuery.value && selectedOptions.value.length > 0) { \n e.preventDefault(); \n const current = [...(props.modelValue ?? [])]; \n current.pop(); \n emit('update:modelValue', current); \n emit('change', current); \n } \n break; \n case 'Escape': \n break; \n } \n} \n \nwatch(filteredOptions, (list) => { \n if (!list.find((o) => o.value === activeValue.value)) { \n activeValue.value = list.find((o) => !isOptionDisabled(o))?.value ?? null; \n } \n}); \n \n/* ---------- Classes ---------- */\n\nconst wrapperSizeClasses = computed(() => {\n const minH = sz.value.control.replace('h-', 'min-h-');\n return `${minH} ${sz.value.padX} py-1`;\n});\nconst inputTextClasses = computed(() => sz.value.text);\nconst iconSizeClasses = computed(() => sz.value.icon); \n \ndefineExpose({ \n open: openPopover, \n close: closePopover, \n toggle: togglePopover, \n focus: () => triggerEl.value?.focus(), \n triggerEl, \n}); \n</script> \n \n<style scoped> \n/* Chip transitions for enter/leave + move. */ \n.modo-chip-enter-active, \n.modo-chip-leave-active { \n transition: \n transform 280ms cubic-bezier(0.2, 0, 0, 1), \n opacity 240ms cubic-bezier(0.2, 0, 0, 1), \n margin 280ms cubic-bezier(0.2, 0, 0, 1), \n max-width 280ms cubic-bezier(0.2, 0, 0, 1); \n} \n.modo-chip-move { \n transition: transform 320ms cubic-bezier(0.2, 0, 0, 1); \n} \n.modo-chip-enter-from, \n.modo-chip-leave-to { \n opacity: 0; \n transform: scale(0.7) translateY(-2px); \n /* Collapse the space smoothly so siblings can slide in. */ \n max-width: 0; \n margin-left: -0.125rem; \n margin-right: -0.125rem; \n} \n \n@media (prefers-reduced-motion: reduce) { \n .modo-chip-enter-active, \n .modo-chip-leave-active, \n .modo-chip-move { \n transition: none; \n } \n .modo-chip-enter-from, \n .modo-chip-leave-to { \n opacity: 1; \n transform: none; \n max-width: none; \n margin: 0; \n } \n} \n</style>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"MultiSelect.mjs","names":[],"sources":["../../../src/components/forms/MultiSelect.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 @click=\"openAndFocus\" \n > \n {{ label }} \n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span> \n </label> \n \n <!-- Trigger --> \n <button \n :id=\"fieldId\" \n ref=\"triggerEl\" \n type=\"button\" \n :disabled=\"isDisabled\" \n :aria-label=\"!label ? ariaLabel : undefined\" \n :aria-invalid=\"hasError || undefined\" \n :aria-describedby=\"describedBy\" \n :aria-required=\"required || undefined\" \n :aria-haspopup=\"'listbox'\" \n :aria-expanded=\"isOpen\" \n :aria-controls=\"listboxId\" \n :aria-activedescendant=\"isOpen && activeId ? activeId : undefined\" \n role=\"combobox\" \n :class=\"[ \n 'modo-field-wrapper flex items-center gap-2 text-left',\n wrapperVariantClasses, \n wrapperSizeClasses, \n radiusClasses, \n fullWidth ? 'w-full' : '', \n isDisabled ? 'opacity-60 cursor-not-allowed' : 'cursor-pointer', \n ]\" \n @click=\"onTriggerClick\" \n @keydown=\"onTriggerKeydown\" \n > \n <component \n :is=\"iconLeft\" \n v-if=\"iconLeft\" \n aria-hidden=\"true\" \n :class=\"['shrink-0', affordanceIconClass, iconSizeClasses]\" \n /> \n \n <!-- Chips --> \n <!-- \n NOTE: the TransitionGroup stays always mounted; if we toggle it \n with `v-if`, removing the last chip unmounts the group before \n Vue can play the leave transition on that chip. A sibling \n placeholder handles the empty state visually. \n --> \n <TransitionGroup \n name=\"modo-chip\" \n tag=\"div\" \n class=\"min-w-0 flex flex-wrap items-center gap-1 py-1\" \n :class=\"[selectedOptions.length ? 'flex-1' : '']\" \n @after-leave=\"onChipAfterLeave\" \n > \n <Badge \n v-for=\"opt in visibleChips\" \n :key=\"`chip-${opt.value}`\" \n variant=\"subtle\" \n :color=\"badgeColor\" \n size=\"medium\" \n :radius=\"radius\" \n :removable=\"!isDisabled && !readonly\" \n :removeAriaLabel=\"`Remove ${opt.label}`\" \n :label=\"opt.label\" \n class=\"modo-chip max-w-50\" \n @remove=\"removeValue(opt.value)\" \n /> \n <Badge \n v-if=\"hiddenChipCount > 0\" \n :key=\"'chip-overflow'\" \n variant=\"subtle\" \n :color=\"badgeColor\" \n size=\"medium\" \n :radius=\"radius\" \n :label=\"`+${hiddenChipCount}`\" \n class=\"modo-chip\" \n /> \n </TransitionGroup> \n <span \n v-if=\"showPlaceholder\" \n :class=\"['flex-1 min-w-0 truncate text-muted-foreground', inputTextClasses]\" \n > \n {{ placeholder }} \n </span> \n \n <Loader \n v-if=\"loading\" \n :size=\"size === 'large' ? 'medium' : 'small'\" \n :class=\"['shrink-0', affordanceIconClass]\" \n /> \n \n <Button \n v-else-if=\"clearable && selectedOptions.length && !isDisabled && !readonly\" \n variant=\"text\" \n size=\"xs\" \n radius=\"full\" \n :icon=\"XMarkIcon\" \n :ariaLabel=\"loc.multiSelect.clear\" \n tabindex=\"-1\" \n :class=\"['shrink-0', affordanceActionClass]\" \n @click.stop=\"clear\" \n /> \n \n <ChevronDownIcon \n v-if=\"!loading\" \n aria-hidden=\"true\" \n :class=\"[ \n 'shrink-0 transition-transform duration-base ease-standard', \n affordanceIconClass,\n iconSizeClasses, \n isOpen ? 'rotate-180' : '', \n ]\" \n /> \n </button> \n \n <!-- Hidden inputs for form integration --> \n <template v-if=\"name\"> \n <input \n v-for=\"val in modelValue\" \n :key=\"`hidden-${val}`\" \n type=\"hidden\" \n :name=\"`${name}[]`\" \n :value=\"val\" \n /> \n </template> \n \n <!-- Dropdown --> \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 <div v-if=\"searchable\" class=\"px-3 py-2 border-b border-border shrink-0\"> \n <div class=\"flex items-center gap-2 h-7\"> \n <MagnifyingGlassIcon \n v-if=\"!isSearching\" \n :class=\"['w-4 h-4 shrink-0', affordanceIconClass]\" \n aria-hidden=\"true\" \n /> \n <Loader \n v-else \n size=\"small\" \n class=\"shrink-0 text-primary\" \n /> \n <input \n ref=\"searchEl\" \n v-model=\"searchQuery\" \n type=\"text\" \n autocomplete=\"off\" \n spellcheck=\"false\" \n :placeholder=\"searchPlaceholder\" \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.multiSelect.clearSearch\" \n tabindex=\"-1\" \n :class=\"['shrink-0', affordanceActionClass]\" \n @click=\"searchQuery = ''\" \n /> \n </div> \n </div> \n \n <!-- Select all --> \n <button \n v-if=\"showSelectAll && selectableOptions.length > 0\" \n type=\"button\" \n :class=\"['flex items-center justify-between gap-2 px-3 py-2 border-b border-border text-caption font-medium text-foreground transition-colors duration-fast ease-standard', optionHover]\"\n @click=\"toggleAll\" \n > \n <span>{{ allSelected ? deselectAllLabel : selectAllLabel }}</span> \n <span class=\"text-muted-foreground\"> \n {{ selectedCountOfFiltered }} / {{ selectableOptions.length }} \n </span> \n </button> \n \n <ul \n :id=\"listboxId\" \n role=\"listbox\" \n aria-multiselectable=\"true\" \n class=\"modo-stagger flex-1 overflow-y-auto\" \n tabindex=\"-1\" \n > \n <template v-if=\"groupedOptions.length === 0\"> \n <li class=\"px-3 py-4 text-caption text-muted-foreground text-center\"> \n {{ emptyText }} \n </li> \n </template> \n \n <template v-for=\"(group, gi) in groupedOptions\" :key=\"group.name ?? gi\"> \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(opt.value)\" \n :key=\"String(opt.value)\" \n role=\"option\" \n :aria-selected=\"isSelected(opt.value)\" \n :aria-disabled=\"isOptionDisabled(opt) || 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 isOptionDisabled(opt)\n ? 'text-muted-foreground/60 cursor-not-allowed'\n : ['text-foreground', optionHover],\n activeValue === opt.value && !isOptionDisabled(opt) ? optionSurface : '', \n isSelected(opt.value) ? 'font-medium' : '', \n ]\" \n @pointerenter=\"setActive(opt.value)\" \n @click=\"toggleOption(opt)\" \n > \n <!-- Checkbox marker --> \n <span \n :class=\"[ \n 'shrink-0 inline-flex items-center justify-center w-4 h-4 rounded border transition-colors duration-fast ease-standard', \n isSelected(opt.value) \n ? [checkFillClass, 'border-transparent'] \n : 'border-input bg-transparent', \n ]\" \n aria-hidden=\"true\" \n > \n <CheckIcon \n v-if=\"isSelected(opt.value)\" \n :class=\"['w-3 h-3', checkIconClass]\" \n /> \n </span> \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\">{{ opt.label }}</div> \n <div v-if=\"opt.description\" class=\"text-caption text-muted-foreground truncate\"> \n {{ opt.description }} \n </div> \n </div> \n </li> \n </template> \n </ul> \n \n <slot name=\"footer\" /> \n </div> \n </PopoverPanel> \n \n <div v-if=\"errorText || helperText || maxSelected\" 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 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=\"maxSelected\" \n class=\"text-caption text-muted-foreground ml-auto\" \n > \n {{ modelValue?.length ?? 0 }} / {{ maxSelected }} \n </p> \n </div> \n </div> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, nextTick, ref, useId, watch } from 'vue'; \nimport type { MultiSelect, SelectOption, SelectValue } from '../../interfaces/forms/Select.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 Badge from '../feedback/Badge.vue'; \nimport { ChevronDownIcon, XMarkIcon, CheckIcon, MagnifyingGlassIcon } from '@heroicons/vue/24/outline'; \nimport Button from './Button.vue'; \nimport { useModoLocale, useSizeTokens } from '../../composables/useModoConfig';\n \nconst loc = useModoLocale(); \n \nconst emit = defineEmits<{ \n 'update:modelValue': [value: SelectValue[]]; \n change: [value: SelectValue[]]; \n open: []; \n close: []; \n clear: []; \n}>(); \n \nconst props = withDefaults(defineProps<MultiSelect>(), { \n modelValue: () => [], \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 searchable: false, \n showSelectAll: false, \n selectAllLabel: 'Select all', \n deselectAllLabel: 'Deselect all', \n searchPlaceholder: 'Search…', \n emptyText: 'No results.', \n placeholder: 'Select…', \n autofocus: false, \n maxVisibleChips: 3, \n}); \n \nconst sz = useSizeTokens(() => props.size);\n \nconst { \n fieldId, \n radius, \n stateColor, \n hasError, \n isDisabled, \n errorId, \n helperId, \n describedBy, \n} = useFieldState(props, { componentName: 'MultiSelect', idPrefix: 'modo-multiselect' }); \n \nconst { wrapperVariantClasses, radiusClasses } = useFieldClasses({ \n variant: () => props.variant, \n stateColor, \n hasError, \n radius, \n radiusKind: 'grow', \n forceFocus: () => isOpen.value, \n halo: () => props.halo, \n}); \n \n/* ---------- Color / radius maps (chip + check) ---------- */ \n \nconst CHECK_FILL_BY_STATE: Record<string, string> = { \n default: 'bg-foreground', \n primary: 'bg-primary', \n danger: 'bg-destructive', \n success: 'bg-success', \n warning: 'bg-warning', \n}; \nconst CHECK_ICON_BY_STATE: Record<string, string> = { \n default: 'text-background', \n primary: 'text-primary-foreground', \n danger: 'text-destructive-foreground', \n success: 'text-success-foreground', \n warning: 'text-warning-foreground', \n}; \nconst checkFillClass = computed(() => CHECK_FILL_BY_STATE[stateColor.value] ?? 'bg-foreground'); \nconst checkIconClass = computed(() => CHECK_ICON_BY_STATE[stateColor.value] ?? 'text-background'); \nconst affordanceIconClass = computed(() => FIELD_AFFORDANCE_ICON_BY_COLOR[stateColor.value] ?? 'text-muted-foreground');\nconst affordanceActionClass = computed(() => FIELD_AFFORDANCE_ACTION_BY_COLOR[stateColor.value] ?? 'text-muted-foreground hover:text-foreground');\n \n/** Map field's stateColor to Badge color (identical union). */ \nconst badgeColor = computed<'default' | 'primary' | 'danger' | 'success' | 'warning'>(\n () => (stateColor.value as 'default' | 'primary' | 'danger' | 'success' | 'warning'),\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(() => OPTION_SURFACE[stateColor.value] ?? 'bg-muted');\nconst optionHover = computed(() => OPTION_HOVER[stateColor.value] ?? 'hover:bg-muted');\n\nconst autoListboxId = useId(); \nconst listboxId = computed(() => `modo-multiselect-listbox-${autoListboxId}`); \nconst optionDomId = (v: SelectValue) => `${listboxId.value}-opt-${String(v)}`; \n \nconst searchQuery = ref(''); \nconst isSearching = ref(false); \nlet searchingTimer: number | null = null; \nwatch(searchQuery, () => { \n isSearching.value = true; \n if (searchingTimer !== null) clearTimeout(searchingTimer); \n searchingTimer = window.setTimeout(() => { \n isSearching.value = false; \n searchingTimer = null; \n }, 220); \n}); \nconst searchEl = ref<HTMLInputElement | null>(null); \n \nconst selectedSet = computed(() => new Set<SelectValue>(props.modelValue ?? [])); \n \nconst selectedOptions = computed<SelectOption[]>(() => \n props.options.filter((o) => selectedSet.value.has(o.value)), \n); \n \n/* Placeholder visibility: stays hidden while the last chip is still \n * playing its leave transition, so removing the last selection does not \n * cause the placeholder text to appear to animate in alongside the chip. */ \nconst showPlaceholder = ref(selectedOptions.value.length === 0); \nwatch( \n () => selectedOptions.value.length, \n (n, prev) => { \n if (n > 0) { \n showPlaceholder.value = false; \n } else if (prev === 0) { \n // No chip is leaving (e.g. initial state, options swap): show now. \n showPlaceholder.value = true; \n } \n // n === 0 && prev > 0 → wait for @after-leave from TransitionGroup. \n }, \n); \nfunction onChipAfterLeave() { \n if (selectedOptions.value.length === 0) { \n showPlaceholder.value = true; \n } \n} \n \nconst visibleChips = computed(() => \n selectedOptions.value.slice(0, props.maxVisibleChips), \n); \nconst hiddenChipCount = computed(() => \n Math.max(0, selectedOptions.value.length - props.maxVisibleChips), \n); \n \nfunction isSelected(v: SelectValue) { \n return selectedSet.value.has(v); \n} \n \nconst atMax = computed( \n () => typeof props.maxSelected === 'number' && (props.modelValue?.length ?? 0) >= props.maxSelected, \n); \n \nfunction isOptionDisabled(opt: SelectOption) { \n if (opt.disabled) return true; \n return atMax.value && !isSelected(opt.value); \n} \n \nconst filteredOptions = computed(() => { \n if (!props.searchable || !searchQuery.value.trim()) return props.options; \n const q = searchQuery.value.trim().toLowerCase(); \n return props.options.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 = filteredOptions.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/* Opciones activables para \"select all\" (las filtradas + no deshabilitadas). */ \nconst selectableOptions = computed(() => \n flatOptions.value.filter((o) => !o.disabled), \n); \nconst selectedCountOfFiltered = computed( \n () => selectableOptions.value.filter((o) => isSelected(o.value)).length, \n); \nconst allSelected = computed( \n () => \n selectableOptions.value.length > 0 && \n selectedCountOfFiltered.value === selectableOptions.value.length, \n); \n \nfunction toggleAll() { \n if (isDisabled.value || props.readonly) return; \n const current = new Set<SelectValue>(props.modelValue ?? []); \n if (allSelected.value) { \n // Deselect sólo las visibles/filtradas. \n for (const opt of selectableOptions.value) current.delete(opt.value); \n } else { \n // Select todas las filtradas, respetando maxSelected. \n for (const opt of selectableOptions.value) { \n if ( \n typeof props.maxSelected === 'number' && \n current.size >= props.maxSelected \n ) break; \n current.add(opt.value); \n } \n } \n const next = Array.from(current); \n emit('update:modelValue', next); \n emit('change', next); \n} \n \n/* ---------- Popover ---------- */ \n \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 matchTriggerWidth: true, \n onOpen: () => { \n emit('open'); \n const initial = \n selectedOptions.value[0] ?? flatOptions.value.find((o) => !isOptionDisabled(o)); \n activeValue.value = initial ? initial.value : null; \n nextTick(() => { \n if (props.searchable) searchEl.value?.focus(); \n scrollActiveIntoView(); \n }); \n }, \n onClose: () => { \n emit('close'); \n searchQuery.value = ''; \n }, \n}); \n \nconst triggerEl = ref<HTMLButtonElement | null>(null); \nwatch(triggerEl, (el) => (triggerRef.value = el)); \n \nconst activeValue = ref<SelectValue | null>(null); \nconst activeId = computed(() => \n activeValue.value !== null ? optionDomId(activeValue.value) : '', \n); \n \nfunction setActive(v: SelectValue) { \n activeValue.value = v; \n} \n \nfunction scrollActiveIntoView() { \n if (activeValue.value === null) return; \n const el = document.getElementById(optionDomId(activeValue.value)); \n el?.scrollIntoView({ block: 'nearest' }); \n} \n \n/* ---------- Actions ---------- */ \n \nfunction openAndFocus() { \n if (isDisabled.value || props.readonly) return; \n if (!isOpen.value) openPopover(); \n triggerEl.value?.focus(); \n} \n \nfunction onTriggerClick() { \n if (isDisabled.value || props.readonly) return; \n togglePopover(); \n} \n \nfunction toggleOption(opt: SelectOption) { \n console.log('toggleOption', opt);\n if (isOptionDisabled(opt)) return; \n const current = [...(props.modelValue ?? [])]; \n const idx = current.indexOf(opt.value); \n if (idx >= 0) { \n current.splice(idx, 1); \n } else { \n current.push(opt.value); \n } \n emit('update:modelValue', current); \n emit('change', current); \n} \n \nfunction removeValue(v: SelectValue) { \n isOpen.value = false;\n event?.stopPropagation();\n const current = (props.modelValue ?? []).filter((x) => x !== v); \n emit('update:modelValue', current); \n emit('change', current); \n} \n \nfunction clear() { \n emit('update:modelValue', []); \n emit('change', []); \n emit('clear'); \n triggerEl.value?.focus(); \n} \n \n/* ---------- Keyboard ---------- */ \n \nfunction moveActive(direction: 1 | -1) { \n const list = flatOptions.value.filter((o) => !isOptionDisabled(o)); \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 jumpTo(pos: 'first' | 'last') { \n const list = flatOptions.value.filter((o) => !isOptionDisabled(o)); \n if (list.length === 0) return; \n activeValue.value = pos === 'first' ? list[0].value : list[list.length - 1].value; \n scrollActiveIntoView(); \n} \n \nlet typeaheadBuffer = ''; \nlet typeaheadTimer: number | null = null; \nfunction typeaheadJump(key: string) { \n if (typeaheadTimer !== null) clearTimeout(typeaheadTimer); \n typeaheadBuffer += key.toLowerCase(); \n typeaheadTimer = window.setTimeout(() => { \n typeaheadBuffer = ''; \n typeaheadTimer = null; \n }, 500); \n \n const match = flatOptions.value.find( \n (o) => !isOptionDisabled(o) && o.label.toLowerCase().startsWith(typeaheadBuffer), \n ); \n if (match) { \n activeValue.value = match.value; \n scrollActiveIntoView(); \n } \n} \n \nfunction onTriggerKeydown(e: KeyboardEvent) { \n if (isDisabled.value || props.readonly) return; \n \n // Backspace en trigger vacío: elimina la última selección. \n if (!isOpen.value && e.key === 'Backspace' && selectedOptions.value.length > 0) { \n e.preventDefault(); \n const current = [...(props.modelValue ?? [])]; \n current.pop(); \n emit('update:modelValue', current); \n emit('change', current); \n return; \n } \n \n if (!isOpen.value) { \n if (['Enter', ' ', 'ArrowDown', 'ArrowUp'].includes(e.key)) { \n e.preventDefault(); \n openPopover(); \n } \n return; \n } \n \n switch (e.key) { \n case 'ArrowDown': \n e.preventDefault(); \n moveActive(1); \n break; \n case 'ArrowUp': \n e.preventDefault(); \n moveActive(-1); \n break; \n case 'Home': \n e.preventDefault(); \n jumpTo('first'); \n break; \n case 'End': \n e.preventDefault(); \n jumpTo('last'); \n break; \n case 'Enter': \n case ' ': { \n e.preventDefault(); \n const opt = flatOptions.value.find((o) => o.value === activeValue.value); \n if (opt) toggleOption(opt); \n break; \n } \n case 'Tab': \n closePopover(); \n break; \n default: \n if (!props.searchable && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) { \n typeaheadJump(e.key); \n } \n break; \n } \n} \n \nfunction onSearchKeydown(e: KeyboardEvent) { \n switch (e.key) { \n case 'ArrowDown': \n e.preventDefault(); \n moveActive(1); \n break; \n case 'ArrowUp': \n e.preventDefault(); \n moveActive(-1); \n break; \n case 'Enter': { \n e.preventDefault(); \n const opt = flatOptions.value.find((o) => o.value === activeValue.value); \n if (opt) toggleOption(opt); \n break; \n } \n case 'Backspace': \n if (!searchQuery.value && selectedOptions.value.length > 0) { \n e.preventDefault(); \n const current = [...(props.modelValue ?? [])]; \n current.pop(); \n emit('update:modelValue', current); \n emit('change', current); \n } \n break; \n case 'Escape': \n break; \n } \n} \n \nwatch(filteredOptions, (list) => { \n if (!list.find((o) => o.value === activeValue.value)) { \n activeValue.value = list.find((o) => !isOptionDisabled(o))?.value ?? null; \n } \n}); \n \n/* ---------- Classes ---------- */\n\nconst wrapperSizeClasses = computed(() => {\n const minH = sz.value.control.replace('h-', 'min-h-');\n return `${minH} ${sz.value.padX} py-1`;\n});\nconst inputTextClasses = computed(() => sz.value.text);\nconst iconSizeClasses = computed(() => sz.value.icon); \n \ndefineExpose({ \n open: openPopover, \n close: closePopover, \n toggle: togglePopover, \n focus: () => triggerEl.value?.focus(), \n triggerEl, \n}); \n</script> \n \n<style scoped> \n/* Chip transitions for enter/leave + move. */ \n.modo-chip-enter-active, \n.modo-chip-leave-active { \n transition: \n transform 280ms cubic-bezier(0.2, 0, 0, 1), \n opacity 240ms cubic-bezier(0.2, 0, 0, 1), \n margin 280ms cubic-bezier(0.2, 0, 0, 1), \n max-width 280ms cubic-bezier(0.2, 0, 0, 1); \n} \n.modo-chip-move { \n transition: transform 320ms cubic-bezier(0.2, 0, 0, 1); \n} \n.modo-chip-enter-from, \n.modo-chip-leave-to { \n opacity: 0; \n transform: scale(0.7) translateY(-2px); \n /* Collapse the space smoothly so siblings can slide in. */ \n max-width: 0; \n margin-left: -0.125rem; \n margin-right: -0.125rem; \n} \n \n@media (prefers-reduced-motion: reduce) { \n .modo-chip-enter-active, \n .modo-chip-leave-active, \n .modo-chip-move { \n transition: none; \n } \n .modo-chip-enter-from, \n .modo-chip-leave-to { \n opacity: 1; \n transform: none; \n max-width: none; \n margin: 0; \n } \n} \n</style>\n"],"mappings":""}
|
|
@@ -151,6 +151,7 @@ var MultiSelect_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0
|
|
|
151
151
|
stateColor,
|
|
152
152
|
hasError,
|
|
153
153
|
radius,
|
|
154
|
+
radiusKind: "grow",
|
|
154
155
|
forceFocus: () => isOpen.value,
|
|
155
156
|
halo: () => props.halo
|
|
156
157
|
});
|
|
@@ -653,7 +654,7 @@ var MultiSelect_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0
|
|
|
653
654
|
onClick: ($event) => toggleOption(opt)
|
|
654
655
|
}, [
|
|
655
656
|
(0, vue.createElementVNode)("span", {
|
|
656
|
-
class: (0, vue.normalizeClass)(["shrink-0 inline-flex items-center justify-center w-4 h-4 rounded border transition-colors duration-fast ease-standard", isSelected(opt.value) ? [checkFillClass.value, "border-transparent"] : "border-
|
|
657
|
+
class: (0, vue.normalizeClass)(["shrink-0 inline-flex items-center justify-center w-4 h-4 rounded border transition-colors duration-fast ease-standard", isSelected(opt.value) ? [checkFillClass.value, "border-transparent"] : "border-input bg-transparent"]),
|
|
657
658
|
"aria-hidden": "true"
|
|
658
659
|
}, [isSelected(opt.value) ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_heroicons_vue_24_outline.CheckIcon), {
|
|
659
660
|
key: 0,
|