mood-ui 0.13.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/data-display/calendar/AgendaView.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/feedback/Banner.vue_vue_type_script_setup_true_lang.mjs +4 -4
- package/dist/components/feedback/Banner.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Drawer.cjs.map +1 -1
- package/dist/components/feedback/Drawer.mjs.map +1 -1
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.cjs +11 -7
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.mjs +17 -13
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Modal.cjs.map +1 -1
- package/dist/components/feedback/Modal.mjs.map +1 -1
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.cjs +10 -3
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.mjs +16 -9
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Toast.cjs +1 -1
- package/dist/components/feedback/Toast.cjs.map +1 -1
- package/dist/components/feedback/Toast.mjs +1 -1
- package/dist/components/feedback/Toast.mjs.map +1 -1
- package/dist/components/feedback/Toast.vue_vue_type_script_setup_true_lang.cjs +4 -2
- package/dist/components/feedback/Toast.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/feedback/Toast.vue_vue_type_script_setup_true_lang.mjs +5 -3
- package/dist/components/feedback/Toast.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/ToastContainer.cjs +1 -1
- package/dist/components/feedback/ToastContainer.cjs.map +1 -1
- package/dist/components/feedback/ToastContainer.mjs +1 -1
- package/dist/components/feedback/ToastContainer.mjs.map +1 -1
- package/dist/components/feedback/ToastContainer.vue_vue_type_script_setup_true_lang.cjs +4 -2
- package/dist/components/feedback/ToastContainer.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/feedback/ToastContainer.vue_vue_type_script_setup_true_lang.mjs +6 -4
- package/dist/components/feedback/ToastContainer.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/dialog/DialogTrigger.cjs.map +1 -1
- package/dist/components/feedback/dialog/DialogTrigger.mjs.map +1 -1
- package/dist/components/feedback/dialog/DialogTrigger.vue_vue_type_script_setup_true_lang.cjs +10 -2
- package/dist/components/feedback/dialog/DialogTrigger.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/feedback/dialog/DialogTrigger.vue_vue_type_script_setup_true_lang.mjs +10 -2
- package/dist/components/feedback/dialog/DialogTrigger.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/sheet/SheetTrigger.cjs.map +1 -1
- package/dist/components/feedback/sheet/SheetTrigger.mjs.map +1 -1
- package/dist/components/feedback/sheet/SheetTrigger.vue_vue_type_script_setup_true_lang.cjs +10 -2
- package/dist/components/feedback/sheet/SheetTrigger.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/feedback/sheet/SheetTrigger.vue_vue_type_script_setup_true_lang.mjs +10 -2
- package/dist/components/feedback/sheet/SheetTrigger.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/morph-select/MorphSelect.cjs.map +1 -1
- package/dist/components/forms/morph-select/MorphSelect.mjs.map +1 -1
- package/dist/components/forms/morph-select/MorphSelect.vue_vue_type_script_setup_true_lang.cjs +53 -6
- package/dist/components/forms/morph-select/MorphSelect.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/morph-select/MorphSelect.vue_vue_type_script_setup_true_lang.mjs +54 -7
- package/dist/components/forms/morph-select/MorphSelect.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/morph-select/MorphSelectContent.cjs.map +1 -1
- package/dist/components/forms/morph-select/MorphSelectContent.mjs.map +1 -1
- package/dist/components/forms/morph-select/MorphSelectContent.vue_vue_type_script_setup_true_lang.cjs +33 -8
- package/dist/components/forms/morph-select/MorphSelectContent.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/morph-select/MorphSelectContent.vue_vue_type_script_setup_true_lang.mjs +34 -9
- package/dist/components/forms/morph-select/MorphSelectContent.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/morph-select/MorphSelectContext.cjs.map +1 -1
- package/dist/components/forms/morph-select/MorphSelectContext.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 +31 -14
- 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 +32 -15
- package/dist/components/forms/morph-select/MorphSelectTrigger.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 +10 -2
- 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 +10 -2
- package/dist/components/layout/popover/PopoverTrigger.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 +7 -0
- 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 +7 -0
- package/dist/components/navigation/menu/MenuTrigger.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/config/ModoLocale.cjs +4 -0
- package/dist/config/ModoLocale.cjs.map +1 -1
- package/dist/config/ModoLocale.mjs +4 -0
- package/dist/config/ModoLocale.mjs.map +1 -1
- package/dist/config/locales/es.cjs +4 -0
- package/dist/config/locales/es.cjs.map +1 -1
- package/dist/config/locales/es.mjs +4 -0
- package/dist/config/locales/es.mjs.map +1 -1
- package/dist/mood-ui.css +35 -27
- package/dist/types/components/forms/morph-select/MorphSelect.vue.d.ts +8 -7
- package/dist/types/components/forms/morph-select/MorphSelectContext.d.ts +6 -1
- package/dist/types/components/forms/morph-select/MorphSelectTrigger.vue.d.ts +6 -3
- package/dist/types/components/forms/morph-select/index.d.ts +24 -18
- package/dist/types/config/ModoLocale.d.ts +6 -0
- package/dist/types/interfaces/feedback/Drawer.interface.d.ts +2 -0
- package/dist/types/interfaces/feedback/Modal.interface.d.ts +2 -0
- package/dist/types/interfaces/forms/ModeOrb.interface.d.ts +3 -3
- package/dist/types/interfaces/forms/MorphSelect.interface.d.ts +13 -5
- package/dist/types/utils/morph/morphHelpers.d.ts +6 -0
- package/dist/utils/morph/morphHelpers.cjs +16 -0
- package/dist/utils/morph/morphHelpers.cjs.map +1 -1
- package/dist/utils/morph/morphHelpers.mjs +16 -1
- package/dist/utils/morph/morphHelpers.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.cjs","names":[],"sources":["../../../src/components/feedback/Modal.vue"],"sourcesContent":["<template> \n <Teleport to=\"body\"> \n <Transition :css=\"false\" @enter=\"onOverlayEnter\" @leave=\"onOverlayLeave\" appear> \n <div \n v-if=\"modelValue\" \n ref=\"overlayRef\" \n :class=\"[ \n 'modo-modal-overlay fixed inset-0 z-1200 flex opacity-0', \n positionClasses, \n ]\" \n :style=\"overlayStyle\" \n :data-modo-theme=\"scopedTheme || undefined\" \n @mousedown=\"onOverlayMouseDown\" \n @click=\"onOverlayClick\" \n > \n <!-- Scrim (shared Valux material, dark veil in both modes) -->\n <div\n aria-hidden=\"true\"\n class=\"modo-scrim pointer-events-none absolute inset-0\"\n :data-modo-scrim=\"scrimVariant\"\n />\n <div \n ref=\"panelRef\" \n data-modo-modal-panel \n role=\"dialog\" \n aria-modal=\"true\" \n :aria-labelledby=\"title ? titleId : undefined\" \n :aria-describedby=\"description ? descriptionId : undefined\" \n :aria-label=\"!title ? ariaLabel : undefined\" \n :class=\"[ \n 'modo-modal relative flex flex-col w-full bg-card text-foreground overflow-hidden', \n 'dark:bg-card/85 dark:backdrop-blur-xl', \n 'border border-border shadow-xl outline-none focus:outline-none focus-visible:outline-none', \n sizeClasses, \n radiusClasses, \n ]\" \n tabindex=\"-1\" \n @click.stop \n @keydown=\"onPanelKeydown\" \n > \n <!-- Inner border layer --> \n <span \n v-if=\"innerBorder\" \n aria-hidden=\"true\" \n :class=\"[ \n 'pointer-events-none absolute inset-1 border border-border/40', \n innerBorderRadiusClass, \n ]\" \n /> \n \n <!-- Close button (usa nuestro Button en modo icono) --> \n <div v-if=\"showClose\" class=\"absolute top-3 right-3 z-10\"> \n <Button \n variant=\"text\" \n size=\"small\" \n :color=\"resolvedColor\" \n :icon=\"XMarkIcon\" \n ariaLabel=\"Close\" \n @click=\"close\" \n /> \n </div> \n \n <!-- Content wrapper --> \n <div ref=\"contentRef\" data-modo-modal-content class=\"flex flex-col min-h-0 flex-1\"> \n <!-- Header --> \n <header \n v-if=\"$slots.header || title || description\" \n :class=\"[ \n 'relative flex flex-col gap-1 px-6 pt-6', \n showClose ? 'pr-12' : '', \n $slots.default || $slots.body || $slots.footer ? 'pb-4' : 'pb-6', \n ]\" \n > \n <slot name=\"header\"> \n <Typography \n v-if=\"title\" \n :id=\"titleId\" \n variant=\"title\" \n size=\"medium\" \n as=\"h2\" \n weight=\"semibold\" \n > \n {{ title }} \n </Typography> \n <Typography \n v-if=\"description\" \n :id=\"descriptionId\" \n variant=\"body\" \n size=\"small\" \n color=\"muted\" \n > \n {{ description }} \n </Typography> \n </slot> \n </header> \n \n <!-- Body --> \n <div \n v-if=\"$slots.default || $slots.body\" \n :class=\"[ \n 'relative flex-1 overflow-auto px-6', \n ($slots.header || title || description) ? '' : 'pt-6', \n $slots.footer ? 'pb-4' : 'pb-6', \n ]\" \n > \n <slot name=\"body\"> \n <slot /> \n </slot> \n </div> \n \n <!-- Footer (divider respeta inner border con inset) --> \n <footer \n v-if=\"$slots.footer\" \n class=\"relative flex items-center justify-end gap-2 px-6 py-4\" \n > \n <span \n v-if=\"innerBorder\" \n aria-hidden=\"true\" \n class=\"pointer-events-none absolute top-0 left-1 right-1 h-px bg-border/40\" \n /> \n <span \n v-else \n aria-hidden=\"true\" \n class=\"pointer-events-none absolute top-0 left-0 right-0 h-px bg-border\" \n /> \n <slot name=\"footer\" :close=\"close\" /> \n </footer> \n </div> \n </div> \n </div> \n </Transition> \n </Teleport> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, nextTick, onBeforeUnmount, onMounted, ref, useId, watch } from 'vue'; \nimport { gsap } from 'gsap'; \nimport { XMarkIcon } from '@heroicons/vue/24/outline'; \nimport Button from '../forms/Button.vue'; \nimport Typography from '../data-display/Typography.vue'; \nimport type { Modal } from '../../interfaces/feedback/Modal.interface'; \nimport { \n useResolvedColor, \n useResolvedRadius, \n useResolvedTheme, \n useModoConfig, \n} from '../../composables/useModoConfig'; \nimport { resolveColorMode } from '../../composables/useColorMode';\nimport { lockBodyScroll, unlockBodyScroll } from '../../composables/useBodyScrollLock';\nimport { palettesToCssVars, semanticTokensFromPalettes } from '../../config/palettes';\nimport { hexToOklchString, pickForegroundOklch } from '../../config/colorPrimitives';\nimport { surfacesToCssVars } from '../../config/surfaces'; \nimport type { ModoColor, ModoRadius } from '../../config/ModoConfig'; \n \nconst props = withDefaults(defineProps<Modal>(), { \n modelValue: false, \n size: 'medium', \n position: 'center', \n closeOnOverlay: true, \n closeOnEscape: true, \n showClose: true, \n lockScroll: true, \n color: 'default', \n overlay: 'blur', \n innerBorder: true, \n disableOriginAnimation: false, \n}); \n \nconst emit = defineEmits<{ \n 'update:modelValue': [value: boolean]; \n open: []; \n close: []; \n afterLeave: []; \n}>(); \n \nconst autoId = useId(); \nconst titleId = computed(() => `modo-modal-${autoId}-title`); \nconst descriptionId = computed(() => `modo-modal-${autoId}-desc`); \n \nconst overlayRef = ref<HTMLElement | null>(null); \nconst panelRef = ref<HTMLElement | null>(null); \nconst contentRef = ref<HTMLElement | null>(null); \n \nconst resolvedColor = useResolvedColor(() => props.color as ModoColor | undefined); \nconst resolvedRadius = useResolvedRadius(() => props.radius as ModoRadius | undefined); \n \nconst cfg = useModoConfig(); \nconst theme = useResolvedTheme(); \nconst scopedTheme = computed(() => resolveColorMode(theme.value)); \n \nconst overlayStyle = computed(() => { \n const providerVars = cfg?.value.palettes \n ? { \n ...palettesToCssVars(cfg.value.palettes), \n ...semanticTokensFromPalettes(cfg.value.palettes, hexToOklchString, pickForegroundOklch), \n } \n : {};\n const surfaceVars = cfg?.value.surfaces\n ? surfacesToCssVars(cfg.value.surfaces)\n : {};\n const darkSurfaceVars = (scopedTheme.value === 'dark' && cfg?.value.darkSurfaces)\n ? surfacesToCssVars(cfg.value.darkSurfaces)\n : {};\n return { ...providerVars, ...surfaceVars, ...darkSurfaceVars };\n}); \n \nfunction close() { \n if (!props.modelValue) return; \n emit('update:modelValue', false); \n emit('close'); \n} \n \n/* ---------- Click outside ---------- */ \nlet mouseDownOnOverlay = false; \nfunction onOverlayMouseDown(e: MouseEvent) { \n mouseDownOnOverlay = e.target === overlayRef.value; \n} \nfunction onOverlayClick(e: MouseEvent) { \n if (!props.closeOnOverlay) return; \n if (e.target !== overlayRef.value) return; \n if (!mouseDownOnOverlay) return; \n close(); \n} \n \n/* ---------- Keydown (Escape + focus trap) ---------- */ \nfunction onPanelKeydown(e: KeyboardEvent) { \n if (props.closeOnEscape && e.key === 'Escape') { \n e.preventDefault(); \n close(); \n return; \n } \n if (e.key === 'Tab' && panelRef.value) { \n const focusables = getFocusable(panelRef.value); \n if (focusables.length === 0) { \n e.preventDefault(); \n return; \n } \n const first = focusables[0]; \n const last = focusables[focusables.length - 1]; \n const active = document.activeElement as HTMLElement | null; \n if (e.shiftKey && active === first) { \n e.preventDefault(); \n last.focus(); \n } else if (!e.shiftKey && active === last) { \n e.preventDefault(); \n first.focus(); \n } \n } \n} \n \nconst FOCUSABLE_SELECTOR = \n 'a[href], area[href], input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, [tabindex]:not([tabindex=\"-1\"]), [contenteditable=\"true\"]'; \n \nfunction getFocusable(container: HTMLElement): HTMLElement[] { \n return Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)) \n .filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null); \n} \n \n/* ---------- Animations (staged open/close) ---------- */ \n \nfunction prefersReducedMotion() { \n return typeof window !== 'undefined' \n && window.matchMedia('(prefers-reduced-motion: reduce)').matches; \n} \n \nlet capturedOrigin: HTMLElement | null = null; \nlet lastPointerTrigger: { el: HTMLElement; time: number } | null = null;\n\nfunction onWindowPointerDown(e: PointerEvent) {\n const target = e.target as Element | null;\n const trigger = target?.closest?.('button, a, [role=\"button\"], [tabindex]') as HTMLElement | null;\n if (trigger) {\n lastPointerTrigger = { el: trigger, time: Date.now() };\n }\n}\n\nfunction getOriginEl(): HTMLElement | null { \n if (props.origin) return props.origin; \n return capturedOrigin; \n} \n \nlet activeTimeline: gsap.core.Timeline | null = null; \n \nfunction onOverlayEnter(el: Element, done: () => void) { \n const overlay = (el as HTMLElement) ?? overlayRef.value; \n const panel = \n overlay?.querySelector<HTMLElement>('[data-modo-modal-panel]') \n ?? panelRef.value; \n if (!overlay || !panel) { done(); return; } \n \n activeTimeline?.kill(); \n \n if (prefersReducedMotion()) { \n gsap.set([overlay, panel], { opacity: 1, clearProps: 'transform' }); \n done(); \n return; \n } \n \n const origin = !props.disableOriginAnimation ? getOriginEl() : null; \n const pRect = panel.getBoundingClientRect(); \n \n const tl = gsap.timeline({ onComplete: () => { activeTimeline = null; done(); } }); \n activeTimeline = tl; \n \n // 1. Overlay fade in \n tl.fromTo(overlay, { opacity: 0 }, { opacity: 1, duration: 0.25, ease: 'power2.out' }, 0); \n \n // 2. Panel + contenido emergen juntos desde el trigger hasta su tamaño real\n if (origin && document.body.contains(origin)) { \n const oRect = origin.getBoundingClientRect(); \n const dx = oRect.left + oRect.width / 2 - (pRect.left + pRect.width / 2); \n const dy = oRect.top + oRect.height / 2 - (pRect.top + pRect.height / 2); \n const scaleX = Math.max(oRect.width / pRect.width, 0.05); \n const scaleY = Math.max(oRect.height / pRect.height, 0.05); \n tl.fromTo( \n panel, \n { x: dx, y: dy, scaleX, scaleY, opacity: 0.85, transformOrigin: 'center center' }, \n { x: 0, y: 0, scaleX: 1, scaleY: 1, opacity: 1, duration: 0.5, ease: 'power3.out' }, \n 0.05, \n ); \n } else { \n tl.fromTo( \n panel, \n { y: 16, scale: 0.95, opacity: 0 }, \n { y: 0, scale: 1, opacity: 1, duration: 0.35, ease: 'power2.out' }, \n 0, \n ); \n } \n} \n \nfunction onOverlayLeave(el: Element, done: () => void) { \n // Durante el leave, los template refs de Vue ya fueron desvinculados, \n // así que resolvemos los nodos desde el elemento que Transition nos entrega. \n const overlay = el as HTMLElement; \n const panel = \n overlay.querySelector<HTMLElement>('[data-modo-modal-panel]') \n ?? panelRef.value; \n // Bail out without animating, but never without releasing the lock — this\n // path is the one that used to strand `overflow: hidden` on <body>.\n if (!overlay || !panel) { releaseScrollLock(); done(); return; }\n\n activeTimeline?.kill();\n\n if (prefersReducedMotion()) {\n gsap.to(overlay, {\n opacity: 0,\n duration: 0.12,\n onComplete: () => { releaseScrollLock(); done(); },\n });\n return;\n }\n\n const origin = !props.disableOriginAnimation ? getOriginEl() : null; \n const pRect = panel.getBoundingClientRect(); \n \n const tl = gsap.timeline({ \n onComplete: () => { \n activeTimeline = null; \n releaseScrollLock(); \n done(); \n }, \n }); \n activeTimeline = tl; \n \n // El panel regresa con todo su contenido visible hacia su lugar de origen;\n // el overlay (padre del panel) solo cae en opacidad al final del recorrido\n // para no ocultar el vuelo de regreso antes de llegar al trigger.\n if (origin && document.body.contains(origin)) { \n const oRect = origin.getBoundingClientRect(); \n const dx = oRect.left + oRect.width / 2 - (pRect.left + pRect.width / 2); \n const dy = oRect.top + oRect.height / 2 - (pRect.top + pRect.height / 2); \n const scaleX = Math.max(oRect.width / pRect.width, 0.05); \n const scaleY = Math.max(oRect.height / pRect.height, 0.05); \n tl.to( \n panel, \n { x: dx, y: dy, scaleX, scaleY, transformOrigin: 'center center', duration: 0.38, ease: 'power3.in' }, \n 0, \n ); \n tl.to(overlay, { opacity: 0, duration: 0.28, ease: 'power3.in' }, 0.1); \n } else { \n tl.to( \n panel, \n { y: 10, scale: 0.95, opacity: 0, duration: 0.24, ease: 'power2.in' }, \n 0, \n ); \n tl.to(overlay, { opacity: 0, duration: 0.24, ease: 'power2.in' }, 0.04); \n } \n} \n \n/* ---------- Scroll lock + focus management ---------- */\nlet previouslyFocused: HTMLElement | null = null;\nlet scrollLocked = false;\n\nfunction releaseScrollLock() {\n if (!scrollLocked) return;\n scrollLocked = false;\n unlockBodyScroll();\n}\n\nonMounted(() => {\n if (typeof window !== 'undefined') {\n window.addEventListener('pointerdown', onWindowPointerDown, { capture: true, passive: true });\n }\n});\n\nwatch( \n () => props.modelValue, \n (open) => { \n if (open) { \n const active = document.activeElement as HTMLElement | null; \n const recentPointer =\n lastPointerTrigger\n && Date.now() - lastPointerTrigger.time < 600\n && document.body.contains(lastPointerTrigger.el)\n ? lastPointerTrigger.el\n : null;\n const triggerEl =\n active && active !== document.body && active !== document.documentElement\n ? active\n : recentPointer;\n previouslyFocused = triggerEl; \n capturedOrigin = triggerEl; \n \n if (props.lockScroll && !scrollLocked) {\n scrollLocked = true;\n lockBodyScroll();\n }\n emit('open'); \n nextTick(() => { \n if (!panelRef.value) return; \n const focusables = getFocusable(panelRef.value); \n (focusables[0] ?? panelRef.value).focus(); \n }); \n } else { \n // El scroll lock se libera en onOverlayLeave cuando termina la \n // animación, para evitar que aparezca el scrollbar y empuje el \n // modal antes de que desaparezca. \n if (previouslyFocused && typeof previouslyFocused.focus === 'function') { \n previouslyFocused.focus(); \n } \n previouslyFocused = null; \n emit('afterLeave'); \n } \n }, \n); \n \nonBeforeUnmount(() => { \n if (typeof window !== 'undefined') {\n window.removeEventListener('pointerdown', onWindowPointerDown, { capture: true });\n }\n activeTimeline?.kill(); \n releaseScrollLock(); \n}); \n \n/* ---------- Style maps ---------- */ \nconst sizeClasses = computed(() => { \n switch (props.size) { \n case 'xsmall': return 'max-w-xs';\n case 'small': return 'max-w-sm'; \n case 'large': return 'max-w-2xl'; \n case 'xlarge': return 'max-w-4xl'; \n case 'full': return 'max-w-none w-[calc(100vw-2rem)] h-[calc(100vh-2rem)]'; \n default: return 'max-w-md'; \n } \n}); \n \nconst radiusClasses = computed(() => { \n if (props.size === 'full') return 'rounded-xl'; \n switch (resolvedRadius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-md'; \n case 'large': return 'rounded-2xl'; \n case 'full': return 'rounded-3xl'; \n default: return 'rounded-xl'; \n } \n}); \n \nconst innerBorderRadiusClass = computed(() => { \n if (props.size === 'full') return 'rounded-lg'; \n switch (resolvedRadius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-xl'; \n case 'full': return 'rounded-[calc(1.5rem-4px)]'; \n default: return 'rounded-lg'; \n } \n}); \n \nconst positionClasses = computed(() => { \n if (props.position === 'top') return 'items-start justify-center p-4 sm:p-6 pt-[10vh]'; \n return 'items-center justify-center p-4 sm:p-6'; \n}); \n \nconst scrimVariant = computed(() => props.overlay ?? 'blur'); \n</script>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Modal.cjs","names":[],"sources":["../../../src/components/feedback/Modal.vue"],"sourcesContent":["<template> \n <Teleport to=\"body\"> \n <Transition :css=\"false\" @enter=\"onOverlayEnter\" @leave=\"onOverlayLeave\" appear> \n <div \n v-if=\"modelValue\" \n ref=\"overlayRef\" \n :class=\"[ \n 'modo-modal-overlay fixed inset-0 z-1200 flex opacity-0', \n positionClasses, \n ]\" \n :style=\"overlayStyle\" \n :data-modo-theme=\"scopedTheme || undefined\" \n @mousedown=\"onOverlayMouseDown\" \n @click=\"onOverlayClick\" \n > \n <!-- Scrim (shared Valux material, dark veil in both modes) -->\n <div\n aria-hidden=\"true\"\n class=\"modo-scrim pointer-events-none absolute inset-0\"\n :data-modo-scrim=\"scrimVariant\"\n />\n <div \n ref=\"panelRef\" \n data-modo-modal-panel \n role=\"dialog\" \n aria-modal=\"true\" \n :aria-labelledby=\"title ? titleId : undefined\" \n :aria-describedby=\"description ? descriptionId : undefined\" \n :aria-label=\"!title ? ariaLabel : undefined\" \n :class=\"[ \n 'modo-modal relative flex flex-col w-full bg-card text-foreground overflow-hidden', \n 'dark:bg-card/85 dark:backdrop-blur-xl', \n 'border border-border shadow-xl outline-none focus:outline-none focus-visible:outline-none', \n sizeClasses, \n radiusClasses, \n ]\" \n tabindex=\"-1\" \n @click.stop \n @keydown=\"onPanelKeydown\" \n > \n <!-- Inner border layer --> \n <span \n v-if=\"innerBorder\" \n aria-hidden=\"true\" \n :class=\"[ \n 'pointer-events-none absolute inset-1 border border-border/40', \n innerBorderRadiusClass, \n ]\" \n /> \n \n <!-- Close button (usa nuestro Button en modo icono) --> \n <div v-if=\"showClose\" class=\"absolute top-3 right-3 z-10\"> \n <Button \n variant=\"text\" \n size=\"small\" \n :color=\"resolvedColor\" \n :icon=\"XMarkIcon\" \n :ariaLabel=\"closeLabelText\" \n @click=\"close\" \n /> \n </div> \n \n <!-- Content wrapper --> \n <div ref=\"contentRef\" data-modo-modal-content class=\"flex flex-col min-h-0 flex-1\"> \n <!-- Header --> \n <header \n v-if=\"$slots.header || title || description\" \n :class=\"[ \n 'relative flex flex-col gap-1 px-6 pt-6', \n showClose ? 'pr-12' : '', \n $slots.default || $slots.body || $slots.footer ? 'pb-4' : 'pb-6', \n ]\" \n > \n <slot name=\"header\"> \n <Typography \n v-if=\"title\" \n :id=\"titleId\" \n variant=\"title\" \n size=\"medium\" \n as=\"h2\" \n weight=\"semibold\" \n > \n {{ title }} \n </Typography> \n <Typography \n v-if=\"description\" \n :id=\"descriptionId\" \n variant=\"body\" \n size=\"small\" \n color=\"muted\" \n > \n {{ description }} \n </Typography> \n </slot> \n </header> \n \n <!-- Body --> \n <div \n v-if=\"$slots.default || $slots.body\" \n :class=\"[ \n 'relative flex-1 overflow-auto px-6', \n ($slots.header || title || description) ? '' : 'pt-6', \n $slots.footer ? 'pb-4' : 'pb-6', \n ]\" \n > \n <slot name=\"body\"> \n <slot /> \n </slot> \n </div> \n \n <!-- Footer (divider respeta inner border con inset) --> \n <footer \n v-if=\"$slots.footer\" \n class=\"relative flex items-center justify-end gap-2 px-6 py-4\" \n > \n <span \n v-if=\"innerBorder\" \n aria-hidden=\"true\" \n class=\"pointer-events-none absolute top-0 left-1 right-1 h-px bg-border/40\" \n /> \n <span \n v-else \n aria-hidden=\"true\" \n class=\"pointer-events-none absolute top-0 left-0 right-0 h-px bg-border\" \n /> \n <slot name=\"footer\" :close=\"close\" /> \n </footer> \n </div> \n </div> \n </div> \n </Transition> \n </Teleport> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, nextTick, onBeforeUnmount, onMounted, ref, useId, watch } from 'vue'; \nimport { gsap } from 'gsap'; \nimport { XMarkIcon } from '@heroicons/vue/24/outline'; \nimport Button from '../forms/Button.vue'; \nimport Typography from '../data-display/Typography.vue'; \nimport type { Modal } from '../../interfaces/feedback/Modal.interface'; \nimport { \n useResolvedColor, \n useResolvedRadius, \n useResolvedTheme, \n useModoConfig, \n useModoLocale,\n} from '../../composables/useModoConfig'; \nimport { resolveColorMode } from '../../composables/useColorMode';\nimport { lockBodyScroll, unlockBodyScroll } from '../../composables/useBodyScrollLock';\nimport { palettesToCssVars, semanticTokensFromPalettes } from '../../config/palettes';\nimport { hexToOklchString, pickForegroundOklch } from '../../config/colorPrimitives';\nimport { surfacesToCssVars } from '../../config/surfaces'; \nimport type { ModoColor, ModoRadius } from '../../config/ModoConfig'; \n \nconst props = withDefaults(defineProps<Modal>(), { \n modelValue: false, \n size: 'medium', \n position: 'center', \n closeOnOverlay: true, \n closeOnEscape: true, \n showClose: true, \n lockScroll: true, \n color: 'default', \n overlay: 'blur', \n innerBorder: true, \n disableOriginAnimation: false, \n});\n// Close button label: prop wins, then the provider locale (`common.close`).\nconst loc = useModoLocale();\nconst closeLabelText = computed(() => props.closeLabel ?? loc.value.common.close);\n \n \nconst emit = defineEmits<{ \n 'update:modelValue': [value: boolean]; \n open: []; \n close: []; \n afterLeave: []; \n}>(); \n \nconst autoId = useId(); \nconst titleId = computed(() => `modo-modal-${autoId}-title`); \nconst descriptionId = computed(() => `modo-modal-${autoId}-desc`); \n \nconst overlayRef = ref<HTMLElement | null>(null); \nconst panelRef = ref<HTMLElement | null>(null); \nconst contentRef = ref<HTMLElement | null>(null); \n \nconst resolvedColor = useResolvedColor(() => props.color as ModoColor | undefined); \nconst resolvedRadius = useResolvedRadius(() => props.radius as ModoRadius | undefined); \n \nconst cfg = useModoConfig(); \nconst theme = useResolvedTheme(); \nconst scopedTheme = computed(() => resolveColorMode(theme.value)); \n \nconst overlayStyle = computed(() => { \n const providerVars = cfg?.value.palettes \n ? { \n ...palettesToCssVars(cfg.value.palettes), \n ...semanticTokensFromPalettes(cfg.value.palettes, hexToOklchString, pickForegroundOklch), \n } \n : {};\n const surfaceVars = cfg?.value.surfaces\n ? surfacesToCssVars(cfg.value.surfaces)\n : {};\n const darkSurfaceVars = (scopedTheme.value === 'dark' && cfg?.value.darkSurfaces)\n ? surfacesToCssVars(cfg.value.darkSurfaces)\n : {};\n return { ...providerVars, ...surfaceVars, ...darkSurfaceVars };\n}); \n \nfunction close() { \n if (!props.modelValue) return; \n emit('update:modelValue', false); \n emit('close'); \n} \n \n/* ---------- Click outside ---------- */ \nlet mouseDownOnOverlay = false; \nfunction onOverlayMouseDown(e: MouseEvent) { \n mouseDownOnOverlay = e.target === overlayRef.value; \n} \nfunction onOverlayClick(e: MouseEvent) { \n if (!props.closeOnOverlay) return; \n if (e.target !== overlayRef.value) return; \n if (!mouseDownOnOverlay) return; \n close(); \n} \n \n/* ---------- Keydown (Escape + focus trap) ---------- */ \nfunction onPanelKeydown(e: KeyboardEvent) { \n if (props.closeOnEscape && e.key === 'Escape') { \n e.preventDefault(); \n close(); \n return; \n } \n if (e.key === 'Tab' && panelRef.value) { \n const focusables = getFocusable(panelRef.value); \n if (focusables.length === 0) { \n e.preventDefault(); \n return; \n } \n const first = focusables[0]; \n const last = focusables[focusables.length - 1]; \n const active = document.activeElement as HTMLElement | null; \n if (e.shiftKey && active === first) { \n e.preventDefault(); \n last.focus(); \n } else if (!e.shiftKey && active === last) { \n e.preventDefault(); \n first.focus(); \n } \n } \n} \n \nconst FOCUSABLE_SELECTOR = \n 'a[href], area[href], input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, [tabindex]:not([tabindex=\"-1\"]), [contenteditable=\"true\"]'; \n \nfunction getFocusable(container: HTMLElement): HTMLElement[] { \n return Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)) \n .filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null); \n} \n \n/* ---------- Animations (staged open/close) ---------- */ \n \nfunction prefersReducedMotion() { \n return typeof window !== 'undefined' \n && window.matchMedia('(prefers-reduced-motion: reduce)').matches; \n} \n \nlet capturedOrigin: HTMLElement | null = null; \nlet lastPointerTrigger: { el: HTMLElement; time: number } | null = null;\n\nfunction onWindowPointerDown(e: PointerEvent) {\n const target = e.target as Element | null;\n const trigger = target?.closest?.('button, a, [role=\"button\"], [tabindex]') as HTMLElement | null;\n if (trigger) {\n lastPointerTrigger = { el: trigger, time: Date.now() };\n }\n}\n\nfunction getOriginEl(): HTMLElement | null { \n if (props.origin) return props.origin; \n return capturedOrigin; \n} \n \nlet activeTimeline: gsap.core.Timeline | null = null; \n \nfunction onOverlayEnter(el: Element, done: () => void) { \n const overlay = (el as HTMLElement) ?? overlayRef.value; \n const panel = \n overlay?.querySelector<HTMLElement>('[data-modo-modal-panel]') \n ?? panelRef.value; \n if (!overlay || !panel) { done(); return; } \n \n activeTimeline?.kill(); \n \n if (prefersReducedMotion()) { \n gsap.set([overlay, panel], { opacity: 1, clearProps: 'transform' }); \n done(); \n return; \n } \n \n const origin = !props.disableOriginAnimation ? getOriginEl() : null; \n const pRect = panel.getBoundingClientRect(); \n \n const tl = gsap.timeline({ onComplete: () => { activeTimeline = null; done(); } }); \n activeTimeline = tl; \n \n // 1. Overlay fade in \n tl.fromTo(overlay, { opacity: 0 }, { opacity: 1, duration: 0.25, ease: 'power2.out' }, 0); \n \n // 2. Panel + contenido emergen juntos desde el trigger hasta su tamaño real\n if (origin && document.body.contains(origin)) { \n const oRect = origin.getBoundingClientRect(); \n const dx = oRect.left + oRect.width / 2 - (pRect.left + pRect.width / 2); \n const dy = oRect.top + oRect.height / 2 - (pRect.top + pRect.height / 2); \n const scaleX = Math.max(oRect.width / pRect.width, 0.05); \n const scaleY = Math.max(oRect.height / pRect.height, 0.05); \n tl.fromTo( \n panel, \n { x: dx, y: dy, scaleX, scaleY, opacity: 0.85, transformOrigin: 'center center' }, \n { x: 0, y: 0, scaleX: 1, scaleY: 1, opacity: 1, duration: 0.5, ease: 'power3.out' }, \n 0.05, \n ); \n } else { \n tl.fromTo( \n panel, \n { y: 16, scale: 0.95, opacity: 0 }, \n { y: 0, scale: 1, opacity: 1, duration: 0.35, ease: 'power2.out' }, \n 0, \n ); \n } \n} \n \nfunction onOverlayLeave(el: Element, done: () => void) { \n // Durante el leave, los template refs de Vue ya fueron desvinculados, \n // así que resolvemos los nodos desde el elemento que Transition nos entrega. \n const overlay = el as HTMLElement; \n const panel = \n overlay.querySelector<HTMLElement>('[data-modo-modal-panel]') \n ?? panelRef.value; \n // Bail out without animating, but never without releasing the lock — this\n // path is the one that used to strand `overflow: hidden` on <body>.\n if (!overlay || !panel) { releaseScrollLock(); done(); return; }\n\n activeTimeline?.kill();\n\n if (prefersReducedMotion()) {\n gsap.to(overlay, {\n opacity: 0,\n duration: 0.12,\n onComplete: () => { releaseScrollLock(); done(); },\n });\n return;\n }\n\n const origin = !props.disableOriginAnimation ? getOriginEl() : null; \n const pRect = panel.getBoundingClientRect(); \n \n const tl = gsap.timeline({ \n onComplete: () => { \n activeTimeline = null; \n releaseScrollLock(); \n done(); \n }, \n }); \n activeTimeline = tl; \n \n // El panel regresa con todo su contenido visible hacia su lugar de origen;\n // el overlay (padre del panel) solo cae en opacidad al final del recorrido\n // para no ocultar el vuelo de regreso antes de llegar al trigger.\n if (origin && document.body.contains(origin)) { \n const oRect = origin.getBoundingClientRect(); \n const dx = oRect.left + oRect.width / 2 - (pRect.left + pRect.width / 2); \n const dy = oRect.top + oRect.height / 2 - (pRect.top + pRect.height / 2); \n const scaleX = Math.max(oRect.width / pRect.width, 0.05); \n const scaleY = Math.max(oRect.height / pRect.height, 0.05); \n tl.to( \n panel, \n { x: dx, y: dy, scaleX, scaleY, transformOrigin: 'center center', duration: 0.38, ease: 'power3.in' }, \n 0, \n ); \n tl.to(overlay, { opacity: 0, duration: 0.28, ease: 'power3.in' }, 0.1); \n } else { \n tl.to( \n panel, \n { y: 10, scale: 0.95, opacity: 0, duration: 0.24, ease: 'power2.in' }, \n 0, \n ); \n tl.to(overlay, { opacity: 0, duration: 0.24, ease: 'power2.in' }, 0.04); \n } \n} \n \n/* ---------- Scroll lock + focus management ---------- */\nlet previouslyFocused: HTMLElement | null = null;\nlet scrollLocked = false;\n\nfunction releaseScrollLock() {\n if (!scrollLocked) return;\n scrollLocked = false;\n unlockBodyScroll();\n}\n\nonMounted(() => {\n if (typeof window !== 'undefined') {\n window.addEventListener('pointerdown', onWindowPointerDown, { capture: true, passive: true });\n }\n});\n\nwatch( \n () => props.modelValue, \n (open) => { \n if (open) { \n const active = document.activeElement as HTMLElement | null; \n const recentPointer =\n lastPointerTrigger\n && Date.now() - lastPointerTrigger.time < 600\n && document.body.contains(lastPointerTrigger.el)\n ? lastPointerTrigger.el\n : null;\n const triggerEl =\n active && active !== document.body && active !== document.documentElement\n ? active\n : recentPointer;\n previouslyFocused = triggerEl; \n capturedOrigin = triggerEl; \n \n if (props.lockScroll && !scrollLocked) {\n scrollLocked = true;\n lockBodyScroll();\n }\n emit('open'); \n nextTick(() => { \n if (!panelRef.value) return; \n const focusables = getFocusable(panelRef.value); \n (focusables[0] ?? panelRef.value).focus(); \n }); \n } else { \n // El scroll lock se libera en onOverlayLeave cuando termina la \n // animación, para evitar que aparezca el scrollbar y empuje el \n // modal antes de que desaparezca. \n if (previouslyFocused && typeof previouslyFocused.focus === 'function') { \n previouslyFocused.focus(); \n } \n previouslyFocused = null; \n emit('afterLeave'); \n } \n }, \n); \n \nonBeforeUnmount(() => { \n if (typeof window !== 'undefined') {\n window.removeEventListener('pointerdown', onWindowPointerDown, { capture: true });\n }\n activeTimeline?.kill(); \n releaseScrollLock(); \n}); \n \n/* ---------- Style maps ---------- */ \nconst sizeClasses = computed(() => { \n switch (props.size) { \n case 'xsmall': return 'max-w-xs';\n case 'small': return 'max-w-sm'; \n case 'large': return 'max-w-2xl'; \n case 'xlarge': return 'max-w-4xl'; \n case 'full': return 'max-w-none w-[calc(100vw-2rem)] h-[calc(100vh-2rem)]'; \n default: return 'max-w-md'; \n } \n}); \n \nconst radiusClasses = computed(() => { \n if (props.size === 'full') return 'rounded-xl'; \n switch (resolvedRadius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-md'; \n case 'large': return 'rounded-2xl'; \n case 'full': return 'rounded-3xl'; \n default: return 'rounded-xl'; \n } \n}); \n \nconst innerBorderRadiusClass = computed(() => { \n if (props.size === 'full') return 'rounded-lg'; \n switch (resolvedRadius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-xl'; \n case 'full': return 'rounded-[calc(1.5rem-4px)]'; \n default: return 'rounded-lg'; \n } \n}); \n \nconst positionClasses = computed(() => { \n if (props.position === 'top') return 'items-start justify-center p-4 sm:p-6 pt-[10vh]'; \n return 'items-center justify-center p-4 sm:p-6'; \n}); \n \nconst scrimVariant = computed(() => props.overlay ?? 'blur'); \n</script>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.mjs","names":[],"sources":["../../../src/components/feedback/Modal.vue"],"sourcesContent":["<template> \n <Teleport to=\"body\"> \n <Transition :css=\"false\" @enter=\"onOverlayEnter\" @leave=\"onOverlayLeave\" appear> \n <div \n v-if=\"modelValue\" \n ref=\"overlayRef\" \n :class=\"[ \n 'modo-modal-overlay fixed inset-0 z-1200 flex opacity-0', \n positionClasses, \n ]\" \n :style=\"overlayStyle\" \n :data-modo-theme=\"scopedTheme || undefined\" \n @mousedown=\"onOverlayMouseDown\" \n @click=\"onOverlayClick\" \n > \n <!-- Scrim (shared Valux material, dark veil in both modes) -->\n <div\n aria-hidden=\"true\"\n class=\"modo-scrim pointer-events-none absolute inset-0\"\n :data-modo-scrim=\"scrimVariant\"\n />\n <div \n ref=\"panelRef\" \n data-modo-modal-panel \n role=\"dialog\" \n aria-modal=\"true\" \n :aria-labelledby=\"title ? titleId : undefined\" \n :aria-describedby=\"description ? descriptionId : undefined\" \n :aria-label=\"!title ? ariaLabel : undefined\" \n :class=\"[ \n 'modo-modal relative flex flex-col w-full bg-card text-foreground overflow-hidden', \n 'dark:bg-card/85 dark:backdrop-blur-xl', \n 'border border-border shadow-xl outline-none focus:outline-none focus-visible:outline-none', \n sizeClasses, \n radiusClasses, \n ]\" \n tabindex=\"-1\" \n @click.stop \n @keydown=\"onPanelKeydown\" \n > \n <!-- Inner border layer --> \n <span \n v-if=\"innerBorder\" \n aria-hidden=\"true\" \n :class=\"[ \n 'pointer-events-none absolute inset-1 border border-border/40', \n innerBorderRadiusClass, \n ]\" \n /> \n \n <!-- Close button (usa nuestro Button en modo icono) --> \n <div v-if=\"showClose\" class=\"absolute top-3 right-3 z-10\"> \n <Button \n variant=\"text\" \n size=\"small\" \n :color=\"resolvedColor\" \n :icon=\"XMarkIcon\" \n ariaLabel=\"Close\" \n @click=\"close\" \n /> \n </div> \n \n <!-- Content wrapper --> \n <div ref=\"contentRef\" data-modo-modal-content class=\"flex flex-col min-h-0 flex-1\"> \n <!-- Header --> \n <header \n v-if=\"$slots.header || title || description\" \n :class=\"[ \n 'relative flex flex-col gap-1 px-6 pt-6', \n showClose ? 'pr-12' : '', \n $slots.default || $slots.body || $slots.footer ? 'pb-4' : 'pb-6', \n ]\" \n > \n <slot name=\"header\"> \n <Typography \n v-if=\"title\" \n :id=\"titleId\" \n variant=\"title\" \n size=\"medium\" \n as=\"h2\" \n weight=\"semibold\" \n > \n {{ title }} \n </Typography> \n <Typography \n v-if=\"description\" \n :id=\"descriptionId\" \n variant=\"body\" \n size=\"small\" \n color=\"muted\" \n > \n {{ description }} \n </Typography> \n </slot> \n </header> \n \n <!-- Body --> \n <div \n v-if=\"$slots.default || $slots.body\" \n :class=\"[ \n 'relative flex-1 overflow-auto px-6', \n ($slots.header || title || description) ? '' : 'pt-6', \n $slots.footer ? 'pb-4' : 'pb-6', \n ]\" \n > \n <slot name=\"body\"> \n <slot /> \n </slot> \n </div> \n \n <!-- Footer (divider respeta inner border con inset) --> \n <footer \n v-if=\"$slots.footer\" \n class=\"relative flex items-center justify-end gap-2 px-6 py-4\" \n > \n <span \n v-if=\"innerBorder\" \n aria-hidden=\"true\" \n class=\"pointer-events-none absolute top-0 left-1 right-1 h-px bg-border/40\" \n /> \n <span \n v-else \n aria-hidden=\"true\" \n class=\"pointer-events-none absolute top-0 left-0 right-0 h-px bg-border\" \n /> \n <slot name=\"footer\" :close=\"close\" /> \n </footer> \n </div> \n </div> \n </div> \n </Transition> \n </Teleport> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, nextTick, onBeforeUnmount, onMounted, ref, useId, watch } from 'vue'; \nimport { gsap } from 'gsap'; \nimport { XMarkIcon } from '@heroicons/vue/24/outline'; \nimport Button from '../forms/Button.vue'; \nimport Typography from '../data-display/Typography.vue'; \nimport type { Modal } from '../../interfaces/feedback/Modal.interface'; \nimport { \n useResolvedColor, \n useResolvedRadius, \n useResolvedTheme, \n useModoConfig, \n} from '../../composables/useModoConfig'; \nimport { resolveColorMode } from '../../composables/useColorMode';\nimport { lockBodyScroll, unlockBodyScroll } from '../../composables/useBodyScrollLock';\nimport { palettesToCssVars, semanticTokensFromPalettes } from '../../config/palettes';\nimport { hexToOklchString, pickForegroundOklch } from '../../config/colorPrimitives';\nimport { surfacesToCssVars } from '../../config/surfaces'; \nimport type { ModoColor, ModoRadius } from '../../config/ModoConfig'; \n \nconst props = withDefaults(defineProps<Modal>(), { \n modelValue: false, \n size: 'medium', \n position: 'center', \n closeOnOverlay: true, \n closeOnEscape: true, \n showClose: true, \n lockScroll: true, \n color: 'default', \n overlay: 'blur', \n innerBorder: true, \n disableOriginAnimation: false, \n}); \n \nconst emit = defineEmits<{ \n 'update:modelValue': [value: boolean]; \n open: []; \n close: []; \n afterLeave: []; \n}>(); \n \nconst autoId = useId(); \nconst titleId = computed(() => `modo-modal-${autoId}-title`); \nconst descriptionId = computed(() => `modo-modal-${autoId}-desc`); \n \nconst overlayRef = ref<HTMLElement | null>(null); \nconst panelRef = ref<HTMLElement | null>(null); \nconst contentRef = ref<HTMLElement | null>(null); \n \nconst resolvedColor = useResolvedColor(() => props.color as ModoColor | undefined); \nconst resolvedRadius = useResolvedRadius(() => props.radius as ModoRadius | undefined); \n \nconst cfg = useModoConfig(); \nconst theme = useResolvedTheme(); \nconst scopedTheme = computed(() => resolveColorMode(theme.value)); \n \nconst overlayStyle = computed(() => { \n const providerVars = cfg?.value.palettes \n ? { \n ...palettesToCssVars(cfg.value.palettes), \n ...semanticTokensFromPalettes(cfg.value.palettes, hexToOklchString, pickForegroundOklch), \n } \n : {};\n const surfaceVars = cfg?.value.surfaces\n ? surfacesToCssVars(cfg.value.surfaces)\n : {};\n const darkSurfaceVars = (scopedTheme.value === 'dark' && cfg?.value.darkSurfaces)\n ? surfacesToCssVars(cfg.value.darkSurfaces)\n : {};\n return { ...providerVars, ...surfaceVars, ...darkSurfaceVars };\n}); \n \nfunction close() { \n if (!props.modelValue) return; \n emit('update:modelValue', false); \n emit('close'); \n} \n \n/* ---------- Click outside ---------- */ \nlet mouseDownOnOverlay = false; \nfunction onOverlayMouseDown(e: MouseEvent) { \n mouseDownOnOverlay = e.target === overlayRef.value; \n} \nfunction onOverlayClick(e: MouseEvent) { \n if (!props.closeOnOverlay) return; \n if (e.target !== overlayRef.value) return; \n if (!mouseDownOnOverlay) return; \n close(); \n} \n \n/* ---------- Keydown (Escape + focus trap) ---------- */ \nfunction onPanelKeydown(e: KeyboardEvent) { \n if (props.closeOnEscape && e.key === 'Escape') { \n e.preventDefault(); \n close(); \n return; \n } \n if (e.key === 'Tab' && panelRef.value) { \n const focusables = getFocusable(panelRef.value); \n if (focusables.length === 0) { \n e.preventDefault(); \n return; \n } \n const first = focusables[0]; \n const last = focusables[focusables.length - 1]; \n const active = document.activeElement as HTMLElement | null; \n if (e.shiftKey && active === first) { \n e.preventDefault(); \n last.focus(); \n } else if (!e.shiftKey && active === last) { \n e.preventDefault(); \n first.focus(); \n } \n } \n} \n \nconst FOCUSABLE_SELECTOR = \n 'a[href], area[href], input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, [tabindex]:not([tabindex=\"-1\"]), [contenteditable=\"true\"]'; \n \nfunction getFocusable(container: HTMLElement): HTMLElement[] { \n return Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)) \n .filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null); \n} \n \n/* ---------- Animations (staged open/close) ---------- */ \n \nfunction prefersReducedMotion() { \n return typeof window !== 'undefined' \n && window.matchMedia('(prefers-reduced-motion: reduce)').matches; \n} \n \nlet capturedOrigin: HTMLElement | null = null; \nlet lastPointerTrigger: { el: HTMLElement; time: number } | null = null;\n\nfunction onWindowPointerDown(e: PointerEvent) {\n const target = e.target as Element | null;\n const trigger = target?.closest?.('button, a, [role=\"button\"], [tabindex]') as HTMLElement | null;\n if (trigger) {\n lastPointerTrigger = { el: trigger, time: Date.now() };\n }\n}\n\nfunction getOriginEl(): HTMLElement | null { \n if (props.origin) return props.origin; \n return capturedOrigin; \n} \n \nlet activeTimeline: gsap.core.Timeline | null = null; \n \nfunction onOverlayEnter(el: Element, done: () => void) { \n const overlay = (el as HTMLElement) ?? overlayRef.value; \n const panel = \n overlay?.querySelector<HTMLElement>('[data-modo-modal-panel]') \n ?? panelRef.value; \n if (!overlay || !panel) { done(); return; } \n \n activeTimeline?.kill(); \n \n if (prefersReducedMotion()) { \n gsap.set([overlay, panel], { opacity: 1, clearProps: 'transform' }); \n done(); \n return; \n } \n \n const origin = !props.disableOriginAnimation ? getOriginEl() : null; \n const pRect = panel.getBoundingClientRect(); \n \n const tl = gsap.timeline({ onComplete: () => { activeTimeline = null; done(); } }); \n activeTimeline = tl; \n \n // 1. Overlay fade in \n tl.fromTo(overlay, { opacity: 0 }, { opacity: 1, duration: 0.25, ease: 'power2.out' }, 0); \n \n // 2. Panel + contenido emergen juntos desde el trigger hasta su tamaño real\n if (origin && document.body.contains(origin)) { \n const oRect = origin.getBoundingClientRect(); \n const dx = oRect.left + oRect.width / 2 - (pRect.left + pRect.width / 2); \n const dy = oRect.top + oRect.height / 2 - (pRect.top + pRect.height / 2); \n const scaleX = Math.max(oRect.width / pRect.width, 0.05); \n const scaleY = Math.max(oRect.height / pRect.height, 0.05); \n tl.fromTo( \n panel, \n { x: dx, y: dy, scaleX, scaleY, opacity: 0.85, transformOrigin: 'center center' }, \n { x: 0, y: 0, scaleX: 1, scaleY: 1, opacity: 1, duration: 0.5, ease: 'power3.out' }, \n 0.05, \n ); \n } else { \n tl.fromTo( \n panel, \n { y: 16, scale: 0.95, opacity: 0 }, \n { y: 0, scale: 1, opacity: 1, duration: 0.35, ease: 'power2.out' }, \n 0, \n ); \n } \n} \n \nfunction onOverlayLeave(el: Element, done: () => void) { \n // Durante el leave, los template refs de Vue ya fueron desvinculados, \n // así que resolvemos los nodos desde el elemento que Transition nos entrega. \n const overlay = el as HTMLElement; \n const panel = \n overlay.querySelector<HTMLElement>('[data-modo-modal-panel]') \n ?? panelRef.value; \n // Bail out without animating, but never without releasing the lock — this\n // path is the one that used to strand `overflow: hidden` on <body>.\n if (!overlay || !panel) { releaseScrollLock(); done(); return; }\n\n activeTimeline?.kill();\n\n if (prefersReducedMotion()) {\n gsap.to(overlay, {\n opacity: 0,\n duration: 0.12,\n onComplete: () => { releaseScrollLock(); done(); },\n });\n return;\n }\n\n const origin = !props.disableOriginAnimation ? getOriginEl() : null; \n const pRect = panel.getBoundingClientRect(); \n \n const tl = gsap.timeline({ \n onComplete: () => { \n activeTimeline = null; \n releaseScrollLock(); \n done(); \n }, \n }); \n activeTimeline = tl; \n \n // El panel regresa con todo su contenido visible hacia su lugar de origen;\n // el overlay (padre del panel) solo cae en opacidad al final del recorrido\n // para no ocultar el vuelo de regreso antes de llegar al trigger.\n if (origin && document.body.contains(origin)) { \n const oRect = origin.getBoundingClientRect(); \n const dx = oRect.left + oRect.width / 2 - (pRect.left + pRect.width / 2); \n const dy = oRect.top + oRect.height / 2 - (pRect.top + pRect.height / 2); \n const scaleX = Math.max(oRect.width / pRect.width, 0.05); \n const scaleY = Math.max(oRect.height / pRect.height, 0.05); \n tl.to( \n panel, \n { x: dx, y: dy, scaleX, scaleY, transformOrigin: 'center center', duration: 0.38, ease: 'power3.in' }, \n 0, \n ); \n tl.to(overlay, { opacity: 0, duration: 0.28, ease: 'power3.in' }, 0.1); \n } else { \n tl.to( \n panel, \n { y: 10, scale: 0.95, opacity: 0, duration: 0.24, ease: 'power2.in' }, \n 0, \n ); \n tl.to(overlay, { opacity: 0, duration: 0.24, ease: 'power2.in' }, 0.04); \n } \n} \n \n/* ---------- Scroll lock + focus management ---------- */\nlet previouslyFocused: HTMLElement | null = null;\nlet scrollLocked = false;\n\nfunction releaseScrollLock() {\n if (!scrollLocked) return;\n scrollLocked = false;\n unlockBodyScroll();\n}\n\nonMounted(() => {\n if (typeof window !== 'undefined') {\n window.addEventListener('pointerdown', onWindowPointerDown, { capture: true, passive: true });\n }\n});\n\nwatch( \n () => props.modelValue, \n (open) => { \n if (open) { \n const active = document.activeElement as HTMLElement | null; \n const recentPointer =\n lastPointerTrigger\n && Date.now() - lastPointerTrigger.time < 600\n && document.body.contains(lastPointerTrigger.el)\n ? lastPointerTrigger.el\n : null;\n const triggerEl =\n active && active !== document.body && active !== document.documentElement\n ? active\n : recentPointer;\n previouslyFocused = triggerEl; \n capturedOrigin = triggerEl; \n \n if (props.lockScroll && !scrollLocked) {\n scrollLocked = true;\n lockBodyScroll();\n }\n emit('open'); \n nextTick(() => { \n if (!panelRef.value) return; \n const focusables = getFocusable(panelRef.value); \n (focusables[0] ?? panelRef.value).focus(); \n }); \n } else { \n // El scroll lock se libera en onOverlayLeave cuando termina la \n // animación, para evitar que aparezca el scrollbar y empuje el \n // modal antes de que desaparezca. \n if (previouslyFocused && typeof previouslyFocused.focus === 'function') { \n previouslyFocused.focus(); \n } \n previouslyFocused = null; \n emit('afterLeave'); \n } \n }, \n); \n \nonBeforeUnmount(() => { \n if (typeof window !== 'undefined') {\n window.removeEventListener('pointerdown', onWindowPointerDown, { capture: true });\n }\n activeTimeline?.kill(); \n releaseScrollLock(); \n}); \n \n/* ---------- Style maps ---------- */ \nconst sizeClasses = computed(() => { \n switch (props.size) { \n case 'xsmall': return 'max-w-xs';\n case 'small': return 'max-w-sm'; \n case 'large': return 'max-w-2xl'; \n case 'xlarge': return 'max-w-4xl'; \n case 'full': return 'max-w-none w-[calc(100vw-2rem)] h-[calc(100vh-2rem)]'; \n default: return 'max-w-md'; \n } \n}); \n \nconst radiusClasses = computed(() => { \n if (props.size === 'full') return 'rounded-xl'; \n switch (resolvedRadius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-md'; \n case 'large': return 'rounded-2xl'; \n case 'full': return 'rounded-3xl'; \n default: return 'rounded-xl'; \n } \n}); \n \nconst innerBorderRadiusClass = computed(() => { \n if (props.size === 'full') return 'rounded-lg'; \n switch (resolvedRadius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-xl'; \n case 'full': return 'rounded-[calc(1.5rem-4px)]'; \n default: return 'rounded-lg'; \n } \n}); \n \nconst positionClasses = computed(() => { \n if (props.position === 'top') return 'items-start justify-center p-4 sm:p-6 pt-[10vh]'; \n return 'items-center justify-center p-4 sm:p-6'; \n}); \n \nconst scrimVariant = computed(() => props.overlay ?? 'blur'); \n</script>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Modal.mjs","names":[],"sources":["../../../src/components/feedback/Modal.vue"],"sourcesContent":["<template> \n <Teleport to=\"body\"> \n <Transition :css=\"false\" @enter=\"onOverlayEnter\" @leave=\"onOverlayLeave\" appear> \n <div \n v-if=\"modelValue\" \n ref=\"overlayRef\" \n :class=\"[ \n 'modo-modal-overlay fixed inset-0 z-1200 flex opacity-0', \n positionClasses, \n ]\" \n :style=\"overlayStyle\" \n :data-modo-theme=\"scopedTheme || undefined\" \n @mousedown=\"onOverlayMouseDown\" \n @click=\"onOverlayClick\" \n > \n <!-- Scrim (shared Valux material, dark veil in both modes) -->\n <div\n aria-hidden=\"true\"\n class=\"modo-scrim pointer-events-none absolute inset-0\"\n :data-modo-scrim=\"scrimVariant\"\n />\n <div \n ref=\"panelRef\" \n data-modo-modal-panel \n role=\"dialog\" \n aria-modal=\"true\" \n :aria-labelledby=\"title ? titleId : undefined\" \n :aria-describedby=\"description ? descriptionId : undefined\" \n :aria-label=\"!title ? ariaLabel : undefined\" \n :class=\"[ \n 'modo-modal relative flex flex-col w-full bg-card text-foreground overflow-hidden', \n 'dark:bg-card/85 dark:backdrop-blur-xl', \n 'border border-border shadow-xl outline-none focus:outline-none focus-visible:outline-none', \n sizeClasses, \n radiusClasses, \n ]\" \n tabindex=\"-1\" \n @click.stop \n @keydown=\"onPanelKeydown\" \n > \n <!-- Inner border layer --> \n <span \n v-if=\"innerBorder\" \n aria-hidden=\"true\" \n :class=\"[ \n 'pointer-events-none absolute inset-1 border border-border/40', \n innerBorderRadiusClass, \n ]\" \n /> \n \n <!-- Close button (usa nuestro Button en modo icono) --> \n <div v-if=\"showClose\" class=\"absolute top-3 right-3 z-10\"> \n <Button \n variant=\"text\" \n size=\"small\" \n :color=\"resolvedColor\" \n :icon=\"XMarkIcon\" \n :ariaLabel=\"closeLabelText\" \n @click=\"close\" \n /> \n </div> \n \n <!-- Content wrapper --> \n <div ref=\"contentRef\" data-modo-modal-content class=\"flex flex-col min-h-0 flex-1\"> \n <!-- Header --> \n <header \n v-if=\"$slots.header || title || description\" \n :class=\"[ \n 'relative flex flex-col gap-1 px-6 pt-6', \n showClose ? 'pr-12' : '', \n $slots.default || $slots.body || $slots.footer ? 'pb-4' : 'pb-6', \n ]\" \n > \n <slot name=\"header\"> \n <Typography \n v-if=\"title\" \n :id=\"titleId\" \n variant=\"title\" \n size=\"medium\" \n as=\"h2\" \n weight=\"semibold\" \n > \n {{ title }} \n </Typography> \n <Typography \n v-if=\"description\" \n :id=\"descriptionId\" \n variant=\"body\" \n size=\"small\" \n color=\"muted\" \n > \n {{ description }} \n </Typography> \n </slot> \n </header> \n \n <!-- Body --> \n <div \n v-if=\"$slots.default || $slots.body\" \n :class=\"[ \n 'relative flex-1 overflow-auto px-6', \n ($slots.header || title || description) ? '' : 'pt-6', \n $slots.footer ? 'pb-4' : 'pb-6', \n ]\" \n > \n <slot name=\"body\"> \n <slot /> \n </slot> \n </div> \n \n <!-- Footer (divider respeta inner border con inset) --> \n <footer \n v-if=\"$slots.footer\" \n class=\"relative flex items-center justify-end gap-2 px-6 py-4\" \n > \n <span \n v-if=\"innerBorder\" \n aria-hidden=\"true\" \n class=\"pointer-events-none absolute top-0 left-1 right-1 h-px bg-border/40\" \n /> \n <span \n v-else \n aria-hidden=\"true\" \n class=\"pointer-events-none absolute top-0 left-0 right-0 h-px bg-border\" \n /> \n <slot name=\"footer\" :close=\"close\" /> \n </footer> \n </div> \n </div> \n </div> \n </Transition> \n </Teleport> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, nextTick, onBeforeUnmount, onMounted, ref, useId, watch } from 'vue'; \nimport { gsap } from 'gsap'; \nimport { XMarkIcon } from '@heroicons/vue/24/outline'; \nimport Button from '../forms/Button.vue'; \nimport Typography from '../data-display/Typography.vue'; \nimport type { Modal } from '../../interfaces/feedback/Modal.interface'; \nimport { \n useResolvedColor, \n useResolvedRadius, \n useResolvedTheme, \n useModoConfig, \n useModoLocale,\n} from '../../composables/useModoConfig'; \nimport { resolveColorMode } from '../../composables/useColorMode';\nimport { lockBodyScroll, unlockBodyScroll } from '../../composables/useBodyScrollLock';\nimport { palettesToCssVars, semanticTokensFromPalettes } from '../../config/palettes';\nimport { hexToOklchString, pickForegroundOklch } from '../../config/colorPrimitives';\nimport { surfacesToCssVars } from '../../config/surfaces'; \nimport type { ModoColor, ModoRadius } from '../../config/ModoConfig'; \n \nconst props = withDefaults(defineProps<Modal>(), { \n modelValue: false, \n size: 'medium', \n position: 'center', \n closeOnOverlay: true, \n closeOnEscape: true, \n showClose: true, \n lockScroll: true, \n color: 'default', \n overlay: 'blur', \n innerBorder: true, \n disableOriginAnimation: false, \n});\n// Close button label: prop wins, then the provider locale (`common.close`).\nconst loc = useModoLocale();\nconst closeLabelText = computed(() => props.closeLabel ?? loc.value.common.close);\n \n \nconst emit = defineEmits<{ \n 'update:modelValue': [value: boolean]; \n open: []; \n close: []; \n afterLeave: []; \n}>(); \n \nconst autoId = useId(); \nconst titleId = computed(() => `modo-modal-${autoId}-title`); \nconst descriptionId = computed(() => `modo-modal-${autoId}-desc`); \n \nconst overlayRef = ref<HTMLElement | null>(null); \nconst panelRef = ref<HTMLElement | null>(null); \nconst contentRef = ref<HTMLElement | null>(null); \n \nconst resolvedColor = useResolvedColor(() => props.color as ModoColor | undefined); \nconst resolvedRadius = useResolvedRadius(() => props.radius as ModoRadius | undefined); \n \nconst cfg = useModoConfig(); \nconst theme = useResolvedTheme(); \nconst scopedTheme = computed(() => resolveColorMode(theme.value)); \n \nconst overlayStyle = computed(() => { \n const providerVars = cfg?.value.palettes \n ? { \n ...palettesToCssVars(cfg.value.palettes), \n ...semanticTokensFromPalettes(cfg.value.palettes, hexToOklchString, pickForegroundOklch), \n } \n : {};\n const surfaceVars = cfg?.value.surfaces\n ? surfacesToCssVars(cfg.value.surfaces)\n : {};\n const darkSurfaceVars = (scopedTheme.value === 'dark' && cfg?.value.darkSurfaces)\n ? surfacesToCssVars(cfg.value.darkSurfaces)\n : {};\n return { ...providerVars, ...surfaceVars, ...darkSurfaceVars };\n}); \n \nfunction close() { \n if (!props.modelValue) return; \n emit('update:modelValue', false); \n emit('close'); \n} \n \n/* ---------- Click outside ---------- */ \nlet mouseDownOnOverlay = false; \nfunction onOverlayMouseDown(e: MouseEvent) { \n mouseDownOnOverlay = e.target === overlayRef.value; \n} \nfunction onOverlayClick(e: MouseEvent) { \n if (!props.closeOnOverlay) return; \n if (e.target !== overlayRef.value) return; \n if (!mouseDownOnOverlay) return; \n close(); \n} \n \n/* ---------- Keydown (Escape + focus trap) ---------- */ \nfunction onPanelKeydown(e: KeyboardEvent) { \n if (props.closeOnEscape && e.key === 'Escape') { \n e.preventDefault(); \n close(); \n return; \n } \n if (e.key === 'Tab' && panelRef.value) { \n const focusables = getFocusable(panelRef.value); \n if (focusables.length === 0) { \n e.preventDefault(); \n return; \n } \n const first = focusables[0]; \n const last = focusables[focusables.length - 1]; \n const active = document.activeElement as HTMLElement | null; \n if (e.shiftKey && active === first) { \n e.preventDefault(); \n last.focus(); \n } else if (!e.shiftKey && active === last) { \n e.preventDefault(); \n first.focus(); \n } \n } \n} \n \nconst FOCUSABLE_SELECTOR = \n 'a[href], area[href], input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, [tabindex]:not([tabindex=\"-1\"]), [contenteditable=\"true\"]'; \n \nfunction getFocusable(container: HTMLElement): HTMLElement[] { \n return Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)) \n .filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null); \n} \n \n/* ---------- Animations (staged open/close) ---------- */ \n \nfunction prefersReducedMotion() { \n return typeof window !== 'undefined' \n && window.matchMedia('(prefers-reduced-motion: reduce)').matches; \n} \n \nlet capturedOrigin: HTMLElement | null = null; \nlet lastPointerTrigger: { el: HTMLElement; time: number } | null = null;\n\nfunction onWindowPointerDown(e: PointerEvent) {\n const target = e.target as Element | null;\n const trigger = target?.closest?.('button, a, [role=\"button\"], [tabindex]') as HTMLElement | null;\n if (trigger) {\n lastPointerTrigger = { el: trigger, time: Date.now() };\n }\n}\n\nfunction getOriginEl(): HTMLElement | null { \n if (props.origin) return props.origin; \n return capturedOrigin; \n} \n \nlet activeTimeline: gsap.core.Timeline | null = null; \n \nfunction onOverlayEnter(el: Element, done: () => void) { \n const overlay = (el as HTMLElement) ?? overlayRef.value; \n const panel = \n overlay?.querySelector<HTMLElement>('[data-modo-modal-panel]') \n ?? panelRef.value; \n if (!overlay || !panel) { done(); return; } \n \n activeTimeline?.kill(); \n \n if (prefersReducedMotion()) { \n gsap.set([overlay, panel], { opacity: 1, clearProps: 'transform' }); \n done(); \n return; \n } \n \n const origin = !props.disableOriginAnimation ? getOriginEl() : null; \n const pRect = panel.getBoundingClientRect(); \n \n const tl = gsap.timeline({ onComplete: () => { activeTimeline = null; done(); } }); \n activeTimeline = tl; \n \n // 1. Overlay fade in \n tl.fromTo(overlay, { opacity: 0 }, { opacity: 1, duration: 0.25, ease: 'power2.out' }, 0); \n \n // 2. Panel + contenido emergen juntos desde el trigger hasta su tamaño real\n if (origin && document.body.contains(origin)) { \n const oRect = origin.getBoundingClientRect(); \n const dx = oRect.left + oRect.width / 2 - (pRect.left + pRect.width / 2); \n const dy = oRect.top + oRect.height / 2 - (pRect.top + pRect.height / 2); \n const scaleX = Math.max(oRect.width / pRect.width, 0.05); \n const scaleY = Math.max(oRect.height / pRect.height, 0.05); \n tl.fromTo( \n panel, \n { x: dx, y: dy, scaleX, scaleY, opacity: 0.85, transformOrigin: 'center center' }, \n { x: 0, y: 0, scaleX: 1, scaleY: 1, opacity: 1, duration: 0.5, ease: 'power3.out' }, \n 0.05, \n ); \n } else { \n tl.fromTo( \n panel, \n { y: 16, scale: 0.95, opacity: 0 }, \n { y: 0, scale: 1, opacity: 1, duration: 0.35, ease: 'power2.out' }, \n 0, \n ); \n } \n} \n \nfunction onOverlayLeave(el: Element, done: () => void) { \n // Durante el leave, los template refs de Vue ya fueron desvinculados, \n // así que resolvemos los nodos desde el elemento que Transition nos entrega. \n const overlay = el as HTMLElement; \n const panel = \n overlay.querySelector<HTMLElement>('[data-modo-modal-panel]') \n ?? panelRef.value; \n // Bail out without animating, but never without releasing the lock — this\n // path is the one that used to strand `overflow: hidden` on <body>.\n if (!overlay || !panel) { releaseScrollLock(); done(); return; }\n\n activeTimeline?.kill();\n\n if (prefersReducedMotion()) {\n gsap.to(overlay, {\n opacity: 0,\n duration: 0.12,\n onComplete: () => { releaseScrollLock(); done(); },\n });\n return;\n }\n\n const origin = !props.disableOriginAnimation ? getOriginEl() : null; \n const pRect = panel.getBoundingClientRect(); \n \n const tl = gsap.timeline({ \n onComplete: () => { \n activeTimeline = null; \n releaseScrollLock(); \n done(); \n }, \n }); \n activeTimeline = tl; \n \n // El panel regresa con todo su contenido visible hacia su lugar de origen;\n // el overlay (padre del panel) solo cae en opacidad al final del recorrido\n // para no ocultar el vuelo de regreso antes de llegar al trigger.\n if (origin && document.body.contains(origin)) { \n const oRect = origin.getBoundingClientRect(); \n const dx = oRect.left + oRect.width / 2 - (pRect.left + pRect.width / 2); \n const dy = oRect.top + oRect.height / 2 - (pRect.top + pRect.height / 2); \n const scaleX = Math.max(oRect.width / pRect.width, 0.05); \n const scaleY = Math.max(oRect.height / pRect.height, 0.05); \n tl.to( \n panel, \n { x: dx, y: dy, scaleX, scaleY, transformOrigin: 'center center', duration: 0.38, ease: 'power3.in' }, \n 0, \n ); \n tl.to(overlay, { opacity: 0, duration: 0.28, ease: 'power3.in' }, 0.1); \n } else { \n tl.to( \n panel, \n { y: 10, scale: 0.95, opacity: 0, duration: 0.24, ease: 'power2.in' }, \n 0, \n ); \n tl.to(overlay, { opacity: 0, duration: 0.24, ease: 'power2.in' }, 0.04); \n } \n} \n \n/* ---------- Scroll lock + focus management ---------- */\nlet previouslyFocused: HTMLElement | null = null;\nlet scrollLocked = false;\n\nfunction releaseScrollLock() {\n if (!scrollLocked) return;\n scrollLocked = false;\n unlockBodyScroll();\n}\n\nonMounted(() => {\n if (typeof window !== 'undefined') {\n window.addEventListener('pointerdown', onWindowPointerDown, { capture: true, passive: true });\n }\n});\n\nwatch( \n () => props.modelValue, \n (open) => { \n if (open) { \n const active = document.activeElement as HTMLElement | null; \n const recentPointer =\n lastPointerTrigger\n && Date.now() - lastPointerTrigger.time < 600\n && document.body.contains(lastPointerTrigger.el)\n ? lastPointerTrigger.el\n : null;\n const triggerEl =\n active && active !== document.body && active !== document.documentElement\n ? active\n : recentPointer;\n previouslyFocused = triggerEl; \n capturedOrigin = triggerEl; \n \n if (props.lockScroll && !scrollLocked) {\n scrollLocked = true;\n lockBodyScroll();\n }\n emit('open'); \n nextTick(() => { \n if (!panelRef.value) return; \n const focusables = getFocusable(panelRef.value); \n (focusables[0] ?? panelRef.value).focus(); \n }); \n } else { \n // El scroll lock se libera en onOverlayLeave cuando termina la \n // animación, para evitar que aparezca el scrollbar y empuje el \n // modal antes de que desaparezca. \n if (previouslyFocused && typeof previouslyFocused.focus === 'function') { \n previouslyFocused.focus(); \n } \n previouslyFocused = null; \n emit('afterLeave'); \n } \n }, \n); \n \nonBeforeUnmount(() => { \n if (typeof window !== 'undefined') {\n window.removeEventListener('pointerdown', onWindowPointerDown, { capture: true });\n }\n activeTimeline?.kill(); \n releaseScrollLock(); \n}); \n \n/* ---------- Style maps ---------- */ \nconst sizeClasses = computed(() => { \n switch (props.size) { \n case 'xsmall': return 'max-w-xs';\n case 'small': return 'max-w-sm'; \n case 'large': return 'max-w-2xl'; \n case 'xlarge': return 'max-w-4xl'; \n case 'full': return 'max-w-none w-[calc(100vw-2rem)] h-[calc(100vh-2rem)]'; \n default: return 'max-w-md'; \n } \n}); \n \nconst radiusClasses = computed(() => { \n if (props.size === 'full') return 'rounded-xl'; \n switch (resolvedRadius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-md'; \n case 'large': return 'rounded-2xl'; \n case 'full': return 'rounded-3xl'; \n default: return 'rounded-xl'; \n } \n}); \n \nconst innerBorderRadiusClass = computed(() => { \n if (props.size === 'full') return 'rounded-lg'; \n switch (resolvedRadius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-xl'; \n case 'full': return 'rounded-[calc(1.5rem-4px)]'; \n default: return 'rounded-lg'; \n } \n}); \n \nconst positionClasses = computed(() => { \n if (props.position === 'top') return 'items-start justify-center p-4 sm:p-6 pt-[10vh]'; \n return 'items-center justify-center p-4 sm:p-6'; \n}); \n \nconst scrimVariant = computed(() => props.overlay ?? 'blur'); \n</script>\n"],"mappings":""}
|
|
@@ -77,7 +77,8 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.
|
|
|
77
77
|
default: false
|
|
78
78
|
},
|
|
79
79
|
id: {},
|
|
80
|
-
ariaLabel: {}
|
|
80
|
+
ariaLabel: {},
|
|
81
|
+
closeLabel: {}
|
|
81
82
|
},
|
|
82
83
|
emits: [
|
|
83
84
|
"update:modelValue",
|
|
@@ -87,6 +88,8 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.
|
|
|
87
88
|
],
|
|
88
89
|
setup(__props, { emit: __emit }) {
|
|
89
90
|
const props = __props;
|
|
91
|
+
const loc = require_useModoConfig.useModoLocale();
|
|
92
|
+
const closeLabelText = (0, vue.computed)(() => props.closeLabel ?? loc.value.common.close);
|
|
90
93
|
const emit = __emit;
|
|
91
94
|
const autoId = (0, vue.useId)();
|
|
92
95
|
const titleId = (0, vue.computed)(() => `modo-modal-${autoId}-title`);
|
|
@@ -421,9 +424,13 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.
|
|
|
421
424
|
size: "small",
|
|
422
425
|
color: (0, vue.unref)(resolvedColor),
|
|
423
426
|
icon: (0, vue.unref)(_heroicons_vue_24_outline.XMarkIcon),
|
|
424
|
-
ariaLabel:
|
|
427
|
+
ariaLabel: closeLabelText.value,
|
|
425
428
|
onClick: close
|
|
426
|
-
}, null, 8, [
|
|
429
|
+
}, null, 8, [
|
|
430
|
+
"color",
|
|
431
|
+
"icon",
|
|
432
|
+
"ariaLabel"
|
|
433
|
+
])])) : (0, vue.createCommentVNode)("", true),
|
|
427
434
|
(0, vue.createElementVNode)("div", {
|
|
428
435
|
ref_key: "contentRef",
|
|
429
436
|
ref: contentRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.vue_vue_type_script_setup_true_lang.cjs","names":["$slots"],"sources":["../../../src/components/feedback/Modal.vue"],"sourcesContent":["<template> \n <Teleport to=\"body\"> \n <Transition :css=\"false\" @enter=\"onOverlayEnter\" @leave=\"onOverlayLeave\" appear> \n <div \n v-if=\"modelValue\" \n ref=\"overlayRef\" \n :class=\"[ \n 'modo-modal-overlay fixed inset-0 z-1200 flex opacity-0', \n positionClasses, \n ]\" \n :style=\"overlayStyle\" \n :data-modo-theme=\"scopedTheme || undefined\" \n @mousedown=\"onOverlayMouseDown\" \n @click=\"onOverlayClick\" \n > \n <!-- Scrim (shared Valux material, dark veil in both modes) -->\n <div\n aria-hidden=\"true\"\n class=\"modo-scrim pointer-events-none absolute inset-0\"\n :data-modo-scrim=\"scrimVariant\"\n />\n <div \n ref=\"panelRef\" \n data-modo-modal-panel \n role=\"dialog\" \n aria-modal=\"true\" \n :aria-labelledby=\"title ? titleId : undefined\" \n :aria-describedby=\"description ? descriptionId : undefined\" \n :aria-label=\"!title ? ariaLabel : undefined\" \n :class=\"[ \n 'modo-modal relative flex flex-col w-full bg-card text-foreground overflow-hidden', \n 'dark:bg-card/85 dark:backdrop-blur-xl', \n 'border border-border shadow-xl outline-none focus:outline-none focus-visible:outline-none', \n sizeClasses, \n radiusClasses, \n ]\" \n tabindex=\"-1\" \n @click.stop \n @keydown=\"onPanelKeydown\" \n > \n <!-- Inner border layer --> \n <span \n v-if=\"innerBorder\" \n aria-hidden=\"true\" \n :class=\"[ \n 'pointer-events-none absolute inset-1 border border-border/40', \n innerBorderRadiusClass, \n ]\" \n /> \n \n <!-- Close button (usa nuestro Button en modo icono) --> \n <div v-if=\"showClose\" class=\"absolute top-3 right-3 z-10\"> \n <Button \n variant=\"text\" \n size=\"small\" \n :color=\"resolvedColor\" \n :icon=\"XMarkIcon\" \n ariaLabel=\"Close\" \n @click=\"close\" \n /> \n </div> \n \n <!-- Content wrapper --> \n <div ref=\"contentRef\" data-modo-modal-content class=\"flex flex-col min-h-0 flex-1\"> \n <!-- Header --> \n <header \n v-if=\"$slots.header || title || description\" \n :class=\"[ \n 'relative flex flex-col gap-1 px-6 pt-6', \n showClose ? 'pr-12' : '', \n $slots.default || $slots.body || $slots.footer ? 'pb-4' : 'pb-6', \n ]\" \n > \n <slot name=\"header\"> \n <Typography \n v-if=\"title\" \n :id=\"titleId\" \n variant=\"title\" \n size=\"medium\" \n as=\"h2\" \n weight=\"semibold\" \n > \n {{ title }} \n </Typography> \n <Typography \n v-if=\"description\" \n :id=\"descriptionId\" \n variant=\"body\" \n size=\"small\" \n color=\"muted\" \n > \n {{ description }} \n </Typography> \n </slot> \n </header> \n \n <!-- Body --> \n <div \n v-if=\"$slots.default || $slots.body\" \n :class=\"[ \n 'relative flex-1 overflow-auto px-6', \n ($slots.header || title || description) ? '' : 'pt-6', \n $slots.footer ? 'pb-4' : 'pb-6', \n ]\" \n > \n <slot name=\"body\"> \n <slot /> \n </slot> \n </div> \n \n <!-- Footer (divider respeta inner border con inset) --> \n <footer \n v-if=\"$slots.footer\" \n class=\"relative flex items-center justify-end gap-2 px-6 py-4\" \n > \n <span \n v-if=\"innerBorder\" \n aria-hidden=\"true\" \n class=\"pointer-events-none absolute top-0 left-1 right-1 h-px bg-border/40\" \n /> \n <span \n v-else \n aria-hidden=\"true\" \n class=\"pointer-events-none absolute top-0 left-0 right-0 h-px bg-border\" \n /> \n <slot name=\"footer\" :close=\"close\" /> \n </footer> \n </div> \n </div> \n </div> \n </Transition> \n </Teleport> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, nextTick, onBeforeUnmount, onMounted, ref, useId, watch } from 'vue'; \nimport { gsap } from 'gsap'; \nimport { XMarkIcon } from '@heroicons/vue/24/outline'; \nimport Button from '../forms/Button.vue'; \nimport Typography from '../data-display/Typography.vue'; \nimport type { Modal } from '../../interfaces/feedback/Modal.interface'; \nimport { \n useResolvedColor, \n useResolvedRadius, \n useResolvedTheme, \n useModoConfig, \n} from '../../composables/useModoConfig'; \nimport { resolveColorMode } from '../../composables/useColorMode';\nimport { lockBodyScroll, unlockBodyScroll } from '../../composables/useBodyScrollLock';\nimport { palettesToCssVars, semanticTokensFromPalettes } from '../../config/palettes';\nimport { hexToOklchString, pickForegroundOklch } from '../../config/colorPrimitives';\nimport { surfacesToCssVars } from '../../config/surfaces'; \nimport type { ModoColor, ModoRadius } from '../../config/ModoConfig'; \n \nconst props = withDefaults(defineProps<Modal>(), { \n modelValue: false, \n size: 'medium', \n position: 'center', \n closeOnOverlay: true, \n closeOnEscape: true, \n showClose: true, \n lockScroll: true, \n color: 'default', \n overlay: 'blur', \n innerBorder: true, \n disableOriginAnimation: false, \n}); \n \nconst emit = defineEmits<{ \n 'update:modelValue': [value: boolean]; \n open: []; \n close: []; \n afterLeave: []; \n}>(); \n \nconst autoId = useId(); \nconst titleId = computed(() => `modo-modal-${autoId}-title`); \nconst descriptionId = computed(() => `modo-modal-${autoId}-desc`); \n \nconst overlayRef = ref<HTMLElement | null>(null); \nconst panelRef = ref<HTMLElement | null>(null); \nconst contentRef = ref<HTMLElement | null>(null); \n \nconst resolvedColor = useResolvedColor(() => props.color as ModoColor | undefined); \nconst resolvedRadius = useResolvedRadius(() => props.radius as ModoRadius | undefined); \n \nconst cfg = useModoConfig(); \nconst theme = useResolvedTheme(); \nconst scopedTheme = computed(() => resolveColorMode(theme.value)); \n \nconst overlayStyle = computed(() => { \n const providerVars = cfg?.value.palettes \n ? { \n ...palettesToCssVars(cfg.value.palettes), \n ...semanticTokensFromPalettes(cfg.value.palettes, hexToOklchString, pickForegroundOklch), \n } \n : {};\n const surfaceVars = cfg?.value.surfaces\n ? surfacesToCssVars(cfg.value.surfaces)\n : {};\n const darkSurfaceVars = (scopedTheme.value === 'dark' && cfg?.value.darkSurfaces)\n ? surfacesToCssVars(cfg.value.darkSurfaces)\n : {};\n return { ...providerVars, ...surfaceVars, ...darkSurfaceVars };\n}); \n \nfunction close() { \n if (!props.modelValue) return; \n emit('update:modelValue', false); \n emit('close'); \n} \n \n/* ---------- Click outside ---------- */ \nlet mouseDownOnOverlay = false; \nfunction onOverlayMouseDown(e: MouseEvent) { \n mouseDownOnOverlay = e.target === overlayRef.value; \n} \nfunction onOverlayClick(e: MouseEvent) { \n if (!props.closeOnOverlay) return; \n if (e.target !== overlayRef.value) return; \n if (!mouseDownOnOverlay) return; \n close(); \n} \n \n/* ---------- Keydown (Escape + focus trap) ---------- */ \nfunction onPanelKeydown(e: KeyboardEvent) { \n if (props.closeOnEscape && e.key === 'Escape') { \n e.preventDefault(); \n close(); \n return; \n } \n if (e.key === 'Tab' && panelRef.value) { \n const focusables = getFocusable(panelRef.value); \n if (focusables.length === 0) { \n e.preventDefault(); \n return; \n } \n const first = focusables[0]; \n const last = focusables[focusables.length - 1]; \n const active = document.activeElement as HTMLElement | null; \n if (e.shiftKey && active === first) { \n e.preventDefault(); \n last.focus(); \n } else if (!e.shiftKey && active === last) { \n e.preventDefault(); \n first.focus(); \n } \n } \n} \n \nconst FOCUSABLE_SELECTOR = \n 'a[href], area[href], input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, [tabindex]:not([tabindex=\"-1\"]), [contenteditable=\"true\"]'; \n \nfunction getFocusable(container: HTMLElement): HTMLElement[] { \n return Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)) \n .filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null); \n} \n \n/* ---------- Animations (staged open/close) ---------- */ \n \nfunction prefersReducedMotion() { \n return typeof window !== 'undefined' \n && window.matchMedia('(prefers-reduced-motion: reduce)').matches; \n} \n \nlet capturedOrigin: HTMLElement | null = null; \nlet lastPointerTrigger: { el: HTMLElement; time: number } | null = null;\n\nfunction onWindowPointerDown(e: PointerEvent) {\n const target = e.target as Element | null;\n const trigger = target?.closest?.('button, a, [role=\"button\"], [tabindex]') as HTMLElement | null;\n if (trigger) {\n lastPointerTrigger = { el: trigger, time: Date.now() };\n }\n}\n\nfunction getOriginEl(): HTMLElement | null { \n if (props.origin) return props.origin; \n return capturedOrigin; \n} \n \nlet activeTimeline: gsap.core.Timeline | null = null; \n \nfunction onOverlayEnter(el: Element, done: () => void) { \n const overlay = (el as HTMLElement) ?? overlayRef.value; \n const panel = \n overlay?.querySelector<HTMLElement>('[data-modo-modal-panel]') \n ?? panelRef.value; \n if (!overlay || !panel) { done(); return; } \n \n activeTimeline?.kill(); \n \n if (prefersReducedMotion()) { \n gsap.set([overlay, panel], { opacity: 1, clearProps: 'transform' }); \n done(); \n return; \n } \n \n const origin = !props.disableOriginAnimation ? getOriginEl() : null; \n const pRect = panel.getBoundingClientRect(); \n \n const tl = gsap.timeline({ onComplete: () => { activeTimeline = null; done(); } }); \n activeTimeline = tl; \n \n // 1. Overlay fade in \n tl.fromTo(overlay, { opacity: 0 }, { opacity: 1, duration: 0.25, ease: 'power2.out' }, 0); \n \n // 2. Panel + contenido emergen juntos desde el trigger hasta su tamaño real\n if (origin && document.body.contains(origin)) { \n const oRect = origin.getBoundingClientRect(); \n const dx = oRect.left + oRect.width / 2 - (pRect.left + pRect.width / 2); \n const dy = oRect.top + oRect.height / 2 - (pRect.top + pRect.height / 2); \n const scaleX = Math.max(oRect.width / pRect.width, 0.05); \n const scaleY = Math.max(oRect.height / pRect.height, 0.05); \n tl.fromTo( \n panel, \n { x: dx, y: dy, scaleX, scaleY, opacity: 0.85, transformOrigin: 'center center' }, \n { x: 0, y: 0, scaleX: 1, scaleY: 1, opacity: 1, duration: 0.5, ease: 'power3.out' }, \n 0.05, \n ); \n } else { \n tl.fromTo( \n panel, \n { y: 16, scale: 0.95, opacity: 0 }, \n { y: 0, scale: 1, opacity: 1, duration: 0.35, ease: 'power2.out' }, \n 0, \n ); \n } \n} \n \nfunction onOverlayLeave(el: Element, done: () => void) { \n // Durante el leave, los template refs de Vue ya fueron desvinculados, \n // así que resolvemos los nodos desde el elemento que Transition nos entrega. \n const overlay = el as HTMLElement; \n const panel = \n overlay.querySelector<HTMLElement>('[data-modo-modal-panel]') \n ?? panelRef.value; \n // Bail out without animating, but never without releasing the lock — this\n // path is the one that used to strand `overflow: hidden` on <body>.\n if (!overlay || !panel) { releaseScrollLock(); done(); return; }\n\n activeTimeline?.kill();\n\n if (prefersReducedMotion()) {\n gsap.to(overlay, {\n opacity: 0,\n duration: 0.12,\n onComplete: () => { releaseScrollLock(); done(); },\n });\n return;\n }\n\n const origin = !props.disableOriginAnimation ? getOriginEl() : null; \n const pRect = panel.getBoundingClientRect(); \n \n const tl = gsap.timeline({ \n onComplete: () => { \n activeTimeline = null; \n releaseScrollLock(); \n done(); \n }, \n }); \n activeTimeline = tl; \n \n // El panel regresa con todo su contenido visible hacia su lugar de origen;\n // el overlay (padre del panel) solo cae en opacidad al final del recorrido\n // para no ocultar el vuelo de regreso antes de llegar al trigger.\n if (origin && document.body.contains(origin)) { \n const oRect = origin.getBoundingClientRect(); \n const dx = oRect.left + oRect.width / 2 - (pRect.left + pRect.width / 2); \n const dy = oRect.top + oRect.height / 2 - (pRect.top + pRect.height / 2); \n const scaleX = Math.max(oRect.width / pRect.width, 0.05); \n const scaleY = Math.max(oRect.height / pRect.height, 0.05); \n tl.to( \n panel, \n { x: dx, y: dy, scaleX, scaleY, transformOrigin: 'center center', duration: 0.38, ease: 'power3.in' }, \n 0, \n ); \n tl.to(overlay, { opacity: 0, duration: 0.28, ease: 'power3.in' }, 0.1); \n } else { \n tl.to( \n panel, \n { y: 10, scale: 0.95, opacity: 0, duration: 0.24, ease: 'power2.in' }, \n 0, \n ); \n tl.to(overlay, { opacity: 0, duration: 0.24, ease: 'power2.in' }, 0.04); \n } \n} \n \n/* ---------- Scroll lock + focus management ---------- */\nlet previouslyFocused: HTMLElement | null = null;\nlet scrollLocked = false;\n\nfunction releaseScrollLock() {\n if (!scrollLocked) return;\n scrollLocked = false;\n unlockBodyScroll();\n}\n\nonMounted(() => {\n if (typeof window !== 'undefined') {\n window.addEventListener('pointerdown', onWindowPointerDown, { capture: true, passive: true });\n }\n});\n\nwatch( \n () => props.modelValue, \n (open) => { \n if (open) { \n const active = document.activeElement as HTMLElement | null; \n const recentPointer =\n lastPointerTrigger\n && Date.now() - lastPointerTrigger.time < 600\n && document.body.contains(lastPointerTrigger.el)\n ? lastPointerTrigger.el\n : null;\n const triggerEl =\n active && active !== document.body && active !== document.documentElement\n ? active\n : recentPointer;\n previouslyFocused = triggerEl; \n capturedOrigin = triggerEl; \n \n if (props.lockScroll && !scrollLocked) {\n scrollLocked = true;\n lockBodyScroll();\n }\n emit('open'); \n nextTick(() => { \n if (!panelRef.value) return; \n const focusables = getFocusable(panelRef.value); \n (focusables[0] ?? panelRef.value).focus(); \n }); \n } else { \n // El scroll lock se libera en onOverlayLeave cuando termina la \n // animación, para evitar que aparezca el scrollbar y empuje el \n // modal antes de que desaparezca. \n if (previouslyFocused && typeof previouslyFocused.focus === 'function') { \n previouslyFocused.focus(); \n } \n previouslyFocused = null; \n emit('afterLeave'); \n } \n }, \n); \n \nonBeforeUnmount(() => { \n if (typeof window !== 'undefined') {\n window.removeEventListener('pointerdown', onWindowPointerDown, { capture: true });\n }\n activeTimeline?.kill(); \n releaseScrollLock(); \n}); \n \n/* ---------- Style maps ---------- */ \nconst sizeClasses = computed(() => { \n switch (props.size) { \n case 'xsmall': return 'max-w-xs';\n case 'small': return 'max-w-sm'; \n case 'large': return 'max-w-2xl'; \n case 'xlarge': return 'max-w-4xl'; \n case 'full': return 'max-w-none w-[calc(100vw-2rem)] h-[calc(100vh-2rem)]'; \n default: return 'max-w-md'; \n } \n}); \n \nconst radiusClasses = computed(() => { \n if (props.size === 'full') return 'rounded-xl'; \n switch (resolvedRadius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-md'; \n case 'large': return 'rounded-2xl'; \n case 'full': return 'rounded-3xl'; \n default: return 'rounded-xl'; \n } \n}); \n \nconst innerBorderRadiusClass = computed(() => { \n if (props.size === 'full') return 'rounded-lg'; \n switch (resolvedRadius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-xl'; \n case 'full': return 'rounded-[calc(1.5rem-4px)]'; \n default: return 'rounded-lg'; \n } \n}); \n \nconst positionClasses = computed(() => { \n if (props.position === 'top') return 'items-start justify-center p-4 sm:p-6 pt-[10vh]'; \n return 'items-center justify-center p-4 sm:p-6'; \n}); \n \nconst scrimVariant = computed(() => props.overlay ?? 'blur'); \n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0PA,IAAM,qBACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAjGJ,MAAM,QAAQ;EAcd,MAAM,OAAO;EAOb,MAAM,UAAA,GAAA,IAAA,QAAgB;EACtB,MAAM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A,GAAA,IAAA,kBAAA,GAAA,IAAA,iBAAd,QAAA,YAAW,EAAA,EAAA,CAAA,CAAA;;;MAOhBA,KAAAA,OAAO,WAAWA,KAAAA,OAAO,SAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAU7B,OAAA;;OATD,QAAA,GAAA,IAAA,gBAAK;;QAA6GA,KAAAA,OAAO,UAAU,QAAA,SAAS,QAAA,cAAW,KAAA;QAAkDA,KAAAA,OAAO,SAAM,SAAA;;8BAQhN,KAAA,QAAA,QAAA,EAAA,QAAA,EAAA,GAAA,IAAA,YADK,KAAA,QAAA,UAAA,CAAA,CAAA,CAAA,EAAA,EAAA,KAAA,GAAA,IAAA,oBAAA,IAAA,KAAA;MAMNA,KAAAA,OAAO,WAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAcR,UAfT,YAeS,CAVK,QAAA,gBAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAGR,QAJF,WAIE,MAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAKA,QAJF,WAIE,IAAA,GAAA,IAAA,YACmC,KAAA,QAAA,UAAA,EAAT,OAAK,CAAA,CAAA,CAAA,KAAA,GAAA,IAAA,oBAAA,IAAA,KAAA"}
|
|
1
|
+
{"version":3,"file":"Modal.vue_vue_type_script_setup_true_lang.cjs","names":["$slots"],"sources":["../../../src/components/feedback/Modal.vue"],"sourcesContent":["<template> \n <Teleport to=\"body\"> \n <Transition :css=\"false\" @enter=\"onOverlayEnter\" @leave=\"onOverlayLeave\" appear> \n <div \n v-if=\"modelValue\" \n ref=\"overlayRef\" \n :class=\"[ \n 'modo-modal-overlay fixed inset-0 z-1200 flex opacity-0', \n positionClasses, \n ]\" \n :style=\"overlayStyle\" \n :data-modo-theme=\"scopedTheme || undefined\" \n @mousedown=\"onOverlayMouseDown\" \n @click=\"onOverlayClick\" \n > \n <!-- Scrim (shared Valux material, dark veil in both modes) -->\n <div\n aria-hidden=\"true\"\n class=\"modo-scrim pointer-events-none absolute inset-0\"\n :data-modo-scrim=\"scrimVariant\"\n />\n <div \n ref=\"panelRef\" \n data-modo-modal-panel \n role=\"dialog\" \n aria-modal=\"true\" \n :aria-labelledby=\"title ? titleId : undefined\" \n :aria-describedby=\"description ? descriptionId : undefined\" \n :aria-label=\"!title ? ariaLabel : undefined\" \n :class=\"[ \n 'modo-modal relative flex flex-col w-full bg-card text-foreground overflow-hidden', \n 'dark:bg-card/85 dark:backdrop-blur-xl', \n 'border border-border shadow-xl outline-none focus:outline-none focus-visible:outline-none', \n sizeClasses, \n radiusClasses, \n ]\" \n tabindex=\"-1\" \n @click.stop \n @keydown=\"onPanelKeydown\" \n > \n <!-- Inner border layer --> \n <span \n v-if=\"innerBorder\" \n aria-hidden=\"true\" \n :class=\"[ \n 'pointer-events-none absolute inset-1 border border-border/40', \n innerBorderRadiusClass, \n ]\" \n /> \n \n <!-- Close button (usa nuestro Button en modo icono) --> \n <div v-if=\"showClose\" class=\"absolute top-3 right-3 z-10\"> \n <Button \n variant=\"text\" \n size=\"small\" \n :color=\"resolvedColor\" \n :icon=\"XMarkIcon\" \n :ariaLabel=\"closeLabelText\" \n @click=\"close\" \n /> \n </div> \n \n <!-- Content wrapper --> \n <div ref=\"contentRef\" data-modo-modal-content class=\"flex flex-col min-h-0 flex-1\"> \n <!-- Header --> \n <header \n v-if=\"$slots.header || title || description\" \n :class=\"[ \n 'relative flex flex-col gap-1 px-6 pt-6', \n showClose ? 'pr-12' : '', \n $slots.default || $slots.body || $slots.footer ? 'pb-4' : 'pb-6', \n ]\" \n > \n <slot name=\"header\"> \n <Typography \n v-if=\"title\" \n :id=\"titleId\" \n variant=\"title\" \n size=\"medium\" \n as=\"h2\" \n weight=\"semibold\" \n > \n {{ title }} \n </Typography> \n <Typography \n v-if=\"description\" \n :id=\"descriptionId\" \n variant=\"body\" \n size=\"small\" \n color=\"muted\" \n > \n {{ description }} \n </Typography> \n </slot> \n </header> \n \n <!-- Body --> \n <div \n v-if=\"$slots.default || $slots.body\" \n :class=\"[ \n 'relative flex-1 overflow-auto px-6', \n ($slots.header || title || description) ? '' : 'pt-6', \n $slots.footer ? 'pb-4' : 'pb-6', \n ]\" \n > \n <slot name=\"body\"> \n <slot /> \n </slot> \n </div> \n \n <!-- Footer (divider respeta inner border con inset) --> \n <footer \n v-if=\"$slots.footer\" \n class=\"relative flex items-center justify-end gap-2 px-6 py-4\" \n > \n <span \n v-if=\"innerBorder\" \n aria-hidden=\"true\" \n class=\"pointer-events-none absolute top-0 left-1 right-1 h-px bg-border/40\" \n /> \n <span \n v-else \n aria-hidden=\"true\" \n class=\"pointer-events-none absolute top-0 left-0 right-0 h-px bg-border\" \n /> \n <slot name=\"footer\" :close=\"close\" /> \n </footer> \n </div> \n </div> \n </div> \n </Transition> \n </Teleport> \n</template> \n \n<script setup lang=\"ts\"> \nimport { computed, nextTick, onBeforeUnmount, onMounted, ref, useId, watch } from 'vue'; \nimport { gsap } from 'gsap'; \nimport { XMarkIcon } from '@heroicons/vue/24/outline'; \nimport Button from '../forms/Button.vue'; \nimport Typography from '../data-display/Typography.vue'; \nimport type { Modal } from '../../interfaces/feedback/Modal.interface'; \nimport { \n useResolvedColor, \n useResolvedRadius, \n useResolvedTheme, \n useModoConfig, \n useModoLocale,\n} from '../../composables/useModoConfig'; \nimport { resolveColorMode } from '../../composables/useColorMode';\nimport { lockBodyScroll, unlockBodyScroll } from '../../composables/useBodyScrollLock';\nimport { palettesToCssVars, semanticTokensFromPalettes } from '../../config/palettes';\nimport { hexToOklchString, pickForegroundOklch } from '../../config/colorPrimitives';\nimport { surfacesToCssVars } from '../../config/surfaces'; \nimport type { ModoColor, ModoRadius } from '../../config/ModoConfig'; \n \nconst props = withDefaults(defineProps<Modal>(), { \n modelValue: false, \n size: 'medium', \n position: 'center', \n closeOnOverlay: true, \n closeOnEscape: true, \n showClose: true, \n lockScroll: true, \n color: 'default', \n overlay: 'blur', \n innerBorder: true, \n disableOriginAnimation: false, \n});\n// Close button label: prop wins, then the provider locale (`common.close`).\nconst loc = useModoLocale();\nconst closeLabelText = computed(() => props.closeLabel ?? loc.value.common.close);\n \n \nconst emit = defineEmits<{ \n 'update:modelValue': [value: boolean]; \n open: []; \n close: []; \n afterLeave: []; \n}>(); \n \nconst autoId = useId(); \nconst titleId = computed(() => `modo-modal-${autoId}-title`); \nconst descriptionId = computed(() => `modo-modal-${autoId}-desc`); \n \nconst overlayRef = ref<HTMLElement | null>(null); \nconst panelRef = ref<HTMLElement | null>(null); \nconst contentRef = ref<HTMLElement | null>(null); \n \nconst resolvedColor = useResolvedColor(() => props.color as ModoColor | undefined); \nconst resolvedRadius = useResolvedRadius(() => props.radius as ModoRadius | undefined); \n \nconst cfg = useModoConfig(); \nconst theme = useResolvedTheme(); \nconst scopedTheme = computed(() => resolveColorMode(theme.value)); \n \nconst overlayStyle = computed(() => { \n const providerVars = cfg?.value.palettes \n ? { \n ...palettesToCssVars(cfg.value.palettes), \n ...semanticTokensFromPalettes(cfg.value.palettes, hexToOklchString, pickForegroundOklch), \n } \n : {};\n const surfaceVars = cfg?.value.surfaces\n ? surfacesToCssVars(cfg.value.surfaces)\n : {};\n const darkSurfaceVars = (scopedTheme.value === 'dark' && cfg?.value.darkSurfaces)\n ? surfacesToCssVars(cfg.value.darkSurfaces)\n : {};\n return { ...providerVars, ...surfaceVars, ...darkSurfaceVars };\n}); \n \nfunction close() { \n if (!props.modelValue) return; \n emit('update:modelValue', false); \n emit('close'); \n} \n \n/* ---------- Click outside ---------- */ \nlet mouseDownOnOverlay = false; \nfunction onOverlayMouseDown(e: MouseEvent) { \n mouseDownOnOverlay = e.target === overlayRef.value; \n} \nfunction onOverlayClick(e: MouseEvent) { \n if (!props.closeOnOverlay) return; \n if (e.target !== overlayRef.value) return; \n if (!mouseDownOnOverlay) return; \n close(); \n} \n \n/* ---------- Keydown (Escape + focus trap) ---------- */ \nfunction onPanelKeydown(e: KeyboardEvent) { \n if (props.closeOnEscape && e.key === 'Escape') { \n e.preventDefault(); \n close(); \n return; \n } \n if (e.key === 'Tab' && panelRef.value) { \n const focusables = getFocusable(panelRef.value); \n if (focusables.length === 0) { \n e.preventDefault(); \n return; \n } \n const first = focusables[0]; \n const last = focusables[focusables.length - 1]; \n const active = document.activeElement as HTMLElement | null; \n if (e.shiftKey && active === first) { \n e.preventDefault(); \n last.focus(); \n } else if (!e.shiftKey && active === last) { \n e.preventDefault(); \n first.focus(); \n } \n } \n} \n \nconst FOCUSABLE_SELECTOR = \n 'a[href], area[href], input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, [tabindex]:not([tabindex=\"-1\"]), [contenteditable=\"true\"]'; \n \nfunction getFocusable(container: HTMLElement): HTMLElement[] { \n return Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)) \n .filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null); \n} \n \n/* ---------- Animations (staged open/close) ---------- */ \n \nfunction prefersReducedMotion() { \n return typeof window !== 'undefined' \n && window.matchMedia('(prefers-reduced-motion: reduce)').matches; \n} \n \nlet capturedOrigin: HTMLElement | null = null; \nlet lastPointerTrigger: { el: HTMLElement; time: number } | null = null;\n\nfunction onWindowPointerDown(e: PointerEvent) {\n const target = e.target as Element | null;\n const trigger = target?.closest?.('button, a, [role=\"button\"], [tabindex]') as HTMLElement | null;\n if (trigger) {\n lastPointerTrigger = { el: trigger, time: Date.now() };\n }\n}\n\nfunction getOriginEl(): HTMLElement | null { \n if (props.origin) return props.origin; \n return capturedOrigin; \n} \n \nlet activeTimeline: gsap.core.Timeline | null = null; \n \nfunction onOverlayEnter(el: Element, done: () => void) { \n const overlay = (el as HTMLElement) ?? overlayRef.value; \n const panel = \n overlay?.querySelector<HTMLElement>('[data-modo-modal-panel]') \n ?? panelRef.value; \n if (!overlay || !panel) { done(); return; } \n \n activeTimeline?.kill(); \n \n if (prefersReducedMotion()) { \n gsap.set([overlay, panel], { opacity: 1, clearProps: 'transform' }); \n done(); \n return; \n } \n \n const origin = !props.disableOriginAnimation ? getOriginEl() : null; \n const pRect = panel.getBoundingClientRect(); \n \n const tl = gsap.timeline({ onComplete: () => { activeTimeline = null; done(); } }); \n activeTimeline = tl; \n \n // 1. Overlay fade in \n tl.fromTo(overlay, { opacity: 0 }, { opacity: 1, duration: 0.25, ease: 'power2.out' }, 0); \n \n // 2. Panel + contenido emergen juntos desde el trigger hasta su tamaño real\n if (origin && document.body.contains(origin)) { \n const oRect = origin.getBoundingClientRect(); \n const dx = oRect.left + oRect.width / 2 - (pRect.left + pRect.width / 2); \n const dy = oRect.top + oRect.height / 2 - (pRect.top + pRect.height / 2); \n const scaleX = Math.max(oRect.width / pRect.width, 0.05); \n const scaleY = Math.max(oRect.height / pRect.height, 0.05); \n tl.fromTo( \n panel, \n { x: dx, y: dy, scaleX, scaleY, opacity: 0.85, transformOrigin: 'center center' }, \n { x: 0, y: 0, scaleX: 1, scaleY: 1, opacity: 1, duration: 0.5, ease: 'power3.out' }, \n 0.05, \n ); \n } else { \n tl.fromTo( \n panel, \n { y: 16, scale: 0.95, opacity: 0 }, \n { y: 0, scale: 1, opacity: 1, duration: 0.35, ease: 'power2.out' }, \n 0, \n ); \n } \n} \n \nfunction onOverlayLeave(el: Element, done: () => void) { \n // Durante el leave, los template refs de Vue ya fueron desvinculados, \n // así que resolvemos los nodos desde el elemento que Transition nos entrega. \n const overlay = el as HTMLElement; \n const panel = \n overlay.querySelector<HTMLElement>('[data-modo-modal-panel]') \n ?? panelRef.value; \n // Bail out without animating, but never without releasing the lock — this\n // path is the one that used to strand `overflow: hidden` on <body>.\n if (!overlay || !panel) { releaseScrollLock(); done(); return; }\n\n activeTimeline?.kill();\n\n if (prefersReducedMotion()) {\n gsap.to(overlay, {\n opacity: 0,\n duration: 0.12,\n onComplete: () => { releaseScrollLock(); done(); },\n });\n return;\n }\n\n const origin = !props.disableOriginAnimation ? getOriginEl() : null; \n const pRect = panel.getBoundingClientRect(); \n \n const tl = gsap.timeline({ \n onComplete: () => { \n activeTimeline = null; \n releaseScrollLock(); \n done(); \n }, \n }); \n activeTimeline = tl; \n \n // El panel regresa con todo su contenido visible hacia su lugar de origen;\n // el overlay (padre del panel) solo cae en opacidad al final del recorrido\n // para no ocultar el vuelo de regreso antes de llegar al trigger.\n if (origin && document.body.contains(origin)) { \n const oRect = origin.getBoundingClientRect(); \n const dx = oRect.left + oRect.width / 2 - (pRect.left + pRect.width / 2); \n const dy = oRect.top + oRect.height / 2 - (pRect.top + pRect.height / 2); \n const scaleX = Math.max(oRect.width / pRect.width, 0.05); \n const scaleY = Math.max(oRect.height / pRect.height, 0.05); \n tl.to( \n panel, \n { x: dx, y: dy, scaleX, scaleY, transformOrigin: 'center center', duration: 0.38, ease: 'power3.in' }, \n 0, \n ); \n tl.to(overlay, { opacity: 0, duration: 0.28, ease: 'power3.in' }, 0.1); \n } else { \n tl.to( \n panel, \n { y: 10, scale: 0.95, opacity: 0, duration: 0.24, ease: 'power2.in' }, \n 0, \n ); \n tl.to(overlay, { opacity: 0, duration: 0.24, ease: 'power2.in' }, 0.04); \n } \n} \n \n/* ---------- Scroll lock + focus management ---------- */\nlet previouslyFocused: HTMLElement | null = null;\nlet scrollLocked = false;\n\nfunction releaseScrollLock() {\n if (!scrollLocked) return;\n scrollLocked = false;\n unlockBodyScroll();\n}\n\nonMounted(() => {\n if (typeof window !== 'undefined') {\n window.addEventListener('pointerdown', onWindowPointerDown, { capture: true, passive: true });\n }\n});\n\nwatch( \n () => props.modelValue, \n (open) => { \n if (open) { \n const active = document.activeElement as HTMLElement | null; \n const recentPointer =\n lastPointerTrigger\n && Date.now() - lastPointerTrigger.time < 600\n && document.body.contains(lastPointerTrigger.el)\n ? lastPointerTrigger.el\n : null;\n const triggerEl =\n active && active !== document.body && active !== document.documentElement\n ? active\n : recentPointer;\n previouslyFocused = triggerEl; \n capturedOrigin = triggerEl; \n \n if (props.lockScroll && !scrollLocked) {\n scrollLocked = true;\n lockBodyScroll();\n }\n emit('open'); \n nextTick(() => { \n if (!panelRef.value) return; \n const focusables = getFocusable(panelRef.value); \n (focusables[0] ?? panelRef.value).focus(); \n }); \n } else { \n // El scroll lock se libera en onOverlayLeave cuando termina la \n // animación, para evitar que aparezca el scrollbar y empuje el \n // modal antes de que desaparezca. \n if (previouslyFocused && typeof previouslyFocused.focus === 'function') { \n previouslyFocused.focus(); \n } \n previouslyFocused = null; \n emit('afterLeave'); \n } \n }, \n); \n \nonBeforeUnmount(() => { \n if (typeof window !== 'undefined') {\n window.removeEventListener('pointerdown', onWindowPointerDown, { capture: true });\n }\n activeTimeline?.kill(); \n releaseScrollLock(); \n}); \n \n/* ---------- Style maps ---------- */ \nconst sizeClasses = computed(() => { \n switch (props.size) { \n case 'xsmall': return 'max-w-xs';\n case 'small': return 'max-w-sm'; \n case 'large': return 'max-w-2xl'; \n case 'xlarge': return 'max-w-4xl'; \n case 'full': return 'max-w-none w-[calc(100vw-2rem)] h-[calc(100vh-2rem)]'; \n default: return 'max-w-md'; \n } \n}); \n \nconst radiusClasses = computed(() => { \n if (props.size === 'full') return 'rounded-xl'; \n switch (resolvedRadius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-md'; \n case 'large': return 'rounded-2xl'; \n case 'full': return 'rounded-3xl'; \n default: return 'rounded-xl'; \n } \n}); \n \nconst innerBorderRadiusClass = computed(() => { \n if (props.size === 'full') return 'rounded-lg'; \n switch (resolvedRadius.value) { \n case 'none': return 'rounded-none'; \n case 'small': return 'rounded-sm'; \n case 'large': return 'rounded-xl'; \n case 'full': return 'rounded-[calc(1.5rem-4px)]'; \n default: return 'rounded-lg'; \n } \n}); \n \nconst positionClasses = computed(() => { \n if (props.position === 'top') return 'items-start justify-center p-4 sm:p-6 pt-[10vh]'; \n return 'items-center justify-center p-4 sm:p-6'; \n}); \n \nconst scrimVariant = computed(() => props.overlay ?? 'blur'); \n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+PA,IAAM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ACL,SAAQ;OACR,MAAK;OACL,IAAG;OACH,QAAO;;uCAEI,EAAA,GAAA,IAAA,kBAAA,GAAA,IAAA,iBAAR,QAAA,MAAK,EAAA,EAAA,CAAA,CAAA;;8DAGF,QAAA,gBAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,aAOG,mBAAA,SAAA;;OANR,IAAI,cAAA;OACL,SAAQ;OACR,MAAK;OACL,OAAM;;uCAEW,EAAA,GAAA,IAAA,kBAAA,GAAA,IAAA,iBAAd,QAAA,YAAW,EAAA,EAAA,CAAA,CAAA;;;MAOhBA,KAAAA,OAAO,WAAWA,KAAAA,OAAO,SAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAU7B,OAAA;;OATD,QAAA,GAAA,IAAA,gBAAK;;QAA6GA,KAAAA,OAAO,UAAU,QAAA,SAAS,QAAA,cAAW,KAAA;QAAkDA,KAAAA,OAAO,SAAM,SAAA;;8BAQhN,KAAA,QAAA,QAAA,EAAA,QAAA,EAAA,GAAA,IAAA,YADK,KAAA,QAAA,UAAA,CAAA,CAAA,CAAA,EAAA,EAAA,KAAA,GAAA,IAAA,oBAAA,IAAA,KAAA;MAMNA,KAAAA,OAAO,WAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAcR,UAfT,YAeS,CAVK,QAAA,gBAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAGR,QAJF,WAIE,MAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAKA,QAJF,WAIE,IAAA,GAAA,IAAA,YACmC,KAAA,QAAA,UAAA,EAAT,OAAK,CAAA,CAAA,CAAA,KAAA,GAAA,IAAA,oBAAA,IAAA,KAAA"}
|
|
@@ -2,13 +2,13 @@ import { palettesToCssVars, semanticTokensFromPalettes } from "../../config/pale
|
|
|
2
2
|
import { surfacesToCssVars } from "../../config/surfaces.mjs";
|
|
3
3
|
import { hexToOklchString, pickForegroundOklch } from "../../config/colorPrimitives.mjs";
|
|
4
4
|
import { resolveColorMode } from "../../composables/useColorMode.mjs";
|
|
5
|
-
import { useModoConfig, useResolvedColor, useResolvedRadius, useResolvedTheme } from "../../composables/useModoConfig.mjs";
|
|
5
|
+
import { useModoConfig, useModoLocale, useResolvedColor, useResolvedRadius, useResolvedTheme } from "../../composables/useModoConfig.mjs";
|
|
6
6
|
import Button_default from "../forms/Button.mjs";
|
|
7
7
|
import Typography_default from "../data-display/Typography.mjs";
|
|
8
8
|
import { lockBodyScroll, unlockBodyScroll } from "../../composables/useBodyScrollLock.mjs";
|
|
9
9
|
import { Teleport, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderSlot, toDisplayString, unref, useId, watch, withCtx, withModifiers } from "vue";
|
|
10
10
|
import { XMarkIcon } from "@heroicons/vue/24/outline";
|
|
11
|
-
import { gsap
|
|
11
|
+
import { gsap } from "gsap";
|
|
12
12
|
//#region src/components/feedback/Modal.vue?vue&type=script&setup=true&lang.ts
|
|
13
13
|
var _hoisted_1 = ["data-modo-theme"];
|
|
14
14
|
var _hoisted_2 = ["data-modo-scrim"];
|
|
@@ -76,7 +76,8 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
76
76
|
default: false
|
|
77
77
|
},
|
|
78
78
|
id: {},
|
|
79
|
-
ariaLabel: {}
|
|
79
|
+
ariaLabel: {},
|
|
80
|
+
closeLabel: {}
|
|
80
81
|
},
|
|
81
82
|
emits: [
|
|
82
83
|
"update:modelValue",
|
|
@@ -86,6 +87,8 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
86
87
|
],
|
|
87
88
|
setup(__props, { emit: __emit }) {
|
|
88
89
|
const props = __props;
|
|
90
|
+
const loc = useModoLocale();
|
|
91
|
+
const closeLabelText = computed(() => props.closeLabel ?? loc.value.common.close);
|
|
89
92
|
const emit = __emit;
|
|
90
93
|
const autoId = useId();
|
|
91
94
|
const titleId = computed(() => `modo-modal-${autoId}-title`);
|
|
@@ -179,7 +182,7 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
179
182
|
}
|
|
180
183
|
activeTimeline?.kill();
|
|
181
184
|
if (prefersReducedMotion()) {
|
|
182
|
-
gsap
|
|
185
|
+
gsap.set([overlay, panel], {
|
|
183
186
|
opacity: 1,
|
|
184
187
|
clearProps: "transform"
|
|
185
188
|
});
|
|
@@ -188,7 +191,7 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
188
191
|
}
|
|
189
192
|
const origin = !props.disableOriginAnimation ? getOriginEl() : null;
|
|
190
193
|
const pRect = panel.getBoundingClientRect();
|
|
191
|
-
const tl = gsap
|
|
194
|
+
const tl = gsap.timeline({ onComplete: () => {
|
|
192
195
|
activeTimeline = null;
|
|
193
196
|
done();
|
|
194
197
|
} });
|
|
@@ -242,7 +245,7 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
242
245
|
}
|
|
243
246
|
activeTimeline?.kill();
|
|
244
247
|
if (prefersReducedMotion()) {
|
|
245
|
-
gsap
|
|
248
|
+
gsap.to(overlay, {
|
|
246
249
|
opacity: 0,
|
|
247
250
|
duration: .12,
|
|
248
251
|
onComplete: () => {
|
|
@@ -254,7 +257,7 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
254
257
|
}
|
|
255
258
|
const origin = !props.disableOriginAnimation ? getOriginEl() : null;
|
|
256
259
|
const pRect = panel.getBoundingClientRect();
|
|
257
|
-
const tl = gsap
|
|
260
|
+
const tl = gsap.timeline({ onComplete: () => {
|
|
258
261
|
activeTimeline = null;
|
|
259
262
|
releaseScrollLock();
|
|
260
263
|
done();
|
|
@@ -420,9 +423,13 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
420
423
|
size: "small",
|
|
421
424
|
color: unref(resolvedColor),
|
|
422
425
|
icon: unref(XMarkIcon),
|
|
423
|
-
ariaLabel:
|
|
426
|
+
ariaLabel: closeLabelText.value,
|
|
424
427
|
onClick: close
|
|
425
|
-
}, null, 8, [
|
|
428
|
+
}, null, 8, [
|
|
429
|
+
"color",
|
|
430
|
+
"icon",
|
|
431
|
+
"ariaLabel"
|
|
432
|
+
])])) : createCommentVNode("", true),
|
|
426
433
|
createElementVNode("div", {
|
|
427
434
|
ref_key: "contentRef",
|
|
428
435
|
ref: contentRef,
|