mood-ui 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/data-display/calendar/AgendaView.cjs.map +1 -1
- package/dist/components/data-display/calendar/AgendaView.mjs.map +1 -1
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.cjs +11 -6
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.mjs +18 -13
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/Calendar.vue_vue_type_script_setup_true_lang.mjs +4 -4
- package/dist/components/data-display/calendar/Calendar.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/DayView.cjs.map +1 -1
- package/dist/components/data-display/calendar/DayView.mjs.map +1 -1
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.cjs +14 -9
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.mjs +22 -17
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/MonthView.cjs +1 -1
- package/dist/components/data-display/calendar/MonthView.cjs.map +1 -1
- package/dist/components/data-display/calendar/MonthView.mjs +1 -1
- package/dist/components/data-display/calendar/MonthView.mjs.map +1 -1
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.cjs +15 -17
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.mjs +18 -20
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/Scheduler.cjs.map +1 -1
- package/dist/components/data-display/calendar/Scheduler.mjs.map +1 -1
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.cjs +14 -9
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.mjs +22 -17
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/WeekView.cjs.map +1 -1
- package/dist/components/data-display/calendar/WeekView.mjs.map +1 -1
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.cjs +14 -9
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.mjs +22 -17
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.mjs +3 -3
- package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.cjs.map +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.mjs.map +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.mjs +3 -3
- package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Banner.vue_vue_type_script_setup_true_lang.mjs +4 -4
- package/dist/components/feedback/Banner.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Drawer.cjs.map +1 -1
- package/dist/components/feedback/Drawer.mjs.map +1 -1
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.cjs +4 -9
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.mjs +9 -14
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Modal.cjs.map +1 -1
- package/dist/components/feedback/Modal.mjs.map +1 -1
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.cjs +4 -9
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.mjs +9 -14
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Tooltip.cjs.map +1 -1
- package/dist/components/feedback/Tooltip.mjs.map +1 -1
- package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.cjs +44 -17
- package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.mjs +44 -17
- package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/Combobox.cjs.map +1 -1
- package/dist/components/forms/Combobox.mjs.map +1 -1
- package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.cjs +2 -2
- package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/PhoneInput.cjs.map +1 -1
- package/dist/components/forms/PhoneInput.mjs.map +1 -1
- package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.cjs +6 -1
- package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.mjs +6 -1
- package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/SearchInput.cjs.map +1 -1
- package/dist/components/forms/SearchInput.mjs.map +1 -1
- package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.cjs +8 -6
- package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.mjs +8 -6
- package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/layout/PopoverPanel.cjs +1 -1
- package/dist/components/layout/PopoverPanel.cjs.map +1 -1
- package/dist/components/layout/PopoverPanel.mjs +1 -1
- package/dist/components/layout/PopoverPanel.mjs.map +1 -1
- package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.cjs +2 -2
- package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/navigation/Switcher.cjs.map +1 -1
- package/dist/components/navigation/Switcher.mjs.map +1 -1
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.cjs +38 -40
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.mjs +38 -40
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/composables/eventColors.cjs +51 -27
- package/dist/composables/eventColors.cjs.map +1 -1
- package/dist/composables/eventColors.mjs +51 -27
- package/dist/composables/eventColors.mjs.map +1 -1
- package/dist/composables/useBodyScrollLock.cjs +44 -0
- package/dist/composables/useBodyScrollLock.cjs.map +1 -0
- package/dist/composables/useBodyScrollLock.mjs +43 -0
- package/dist/composables/useBodyScrollLock.mjs.map +1 -0
- package/dist/composables/useCalendarTheme.cjs +29 -8
- package/dist/composables/useCalendarTheme.cjs.map +1 -1
- package/dist/composables/useCalendarTheme.mjs +29 -8
- package/dist/composables/useCalendarTheme.mjs.map +1 -1
- package/dist/composables/usePopover.cjs +44 -12
- package/dist/composables/usePopover.cjs.map +1 -1
- package/dist/composables/usePopover.mjs +44 -12
- package/dist/composables/usePopover.mjs.map +1 -1
- package/dist/mood-ui.css +9 -9
- package/dist/types/composables/eventColors.d.ts +2 -2
- package/dist/types/composables/useBodyScrollLock.d.ts +19 -0
- package/dist/types/composables/useCalendarTheme.d.ts +2 -0
- package/dist/types/interfaces/data-display/calendar/AgendaView.interface.d.ts +5 -0
- package/dist/types/interfaces/data-display/calendar/DayView.interface.d.ts +5 -0
- package/dist/types/interfaces/data-display/calendar/MonthView.interface.d.ts +5 -0
- package/dist/types/interfaces/data-display/calendar/Scheduler.interface.d.ts +5 -0
- package/dist/types/interfaces/data-display/calendar/WeekView.interface.d.ts +5 -0
- package/dist/types/utils/calendarTooltip.d.ts +13 -0
- package/dist/types/utils/cssLength.d.ts +5 -0
- package/dist/types/utils/tooltipArrow.d.ts +34 -0
- package/dist/utils/calendarTooltip.cjs +18 -0
- package/dist/utils/calendarTooltip.cjs.map +1 -0
- package/dist/utils/calendarTooltip.mjs +18 -0
- package/dist/utils/calendarTooltip.mjs.map +1 -0
- package/dist/utils/cssLength.cjs +13 -0
- package/dist/utils/cssLength.cjs.map +1 -0
- package/dist/utils/cssLength.mjs +13 -0
- package/dist/utils/cssLength.mjs.map +1 -0
- package/dist/utils/tooltipArrow.cjs +37 -0
- package/dist/utils/tooltipArrow.cjs.map +1 -0
- package/dist/utils/tooltipArrow.mjs +36 -0
- package/dist/utils/tooltipArrow.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -5,9 +5,10 @@ import { resolveColorMode } from "../../composables/useColorMode.mjs";
|
|
|
5
5
|
import { useModoConfig, 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
|
+
import { lockBodyScroll, unlockBodyScroll } from "../../composables/useBodyScrollLock.mjs";
|
|
8
9
|
import { Teleport, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, openBlock, ref, renderSlot, toDisplayString, unref, useId, watch, withCtx, withModifiers } from "vue";
|
|
9
10
|
import { XMarkIcon } from "@heroicons/vue/24/outline";
|
|
10
|
-
import { gsap
|
|
11
|
+
import { gsap } from "gsap";
|
|
11
12
|
//#region src/components/feedback/Modal.vue?vue&type=script&setup=true&lang.ts
|
|
12
13
|
var _hoisted_1 = ["data-modo-theme"];
|
|
13
14
|
var _hoisted_2 = [
|
|
@@ -170,7 +171,7 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
170
171
|
}
|
|
171
172
|
activeTimeline?.kill();
|
|
172
173
|
if (prefersReducedMotion()) {
|
|
173
|
-
gsap
|
|
174
|
+
gsap.set([
|
|
174
175
|
overlay,
|
|
175
176
|
panel,
|
|
176
177
|
content
|
|
@@ -183,7 +184,7 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
183
184
|
}
|
|
184
185
|
const origin = !props.disableOriginAnimation ? getOriginEl() : null;
|
|
185
186
|
const pRect = panel.getBoundingClientRect();
|
|
186
|
-
const tl = gsap
|
|
187
|
+
const tl = gsap.timeline({ onComplete: () => {
|
|
187
188
|
activeTimeline = null;
|
|
188
189
|
done();
|
|
189
190
|
} });
|
|
@@ -241,12 +242,13 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
241
242
|
const panel = overlay.querySelector("[data-modo-modal-panel]") ?? panelRef.value;
|
|
242
243
|
const content = overlay.querySelector("[data-modo-modal-content]") ?? contentRef.value;
|
|
243
244
|
if (!overlay || !panel || !content) {
|
|
245
|
+
releaseScrollLock();
|
|
244
246
|
done();
|
|
245
247
|
return;
|
|
246
248
|
}
|
|
247
249
|
activeTimeline?.kill();
|
|
248
250
|
if (prefersReducedMotion()) {
|
|
249
|
-
gsap
|
|
251
|
+
gsap.to(overlay, {
|
|
250
252
|
opacity: 0,
|
|
251
253
|
duration: .12,
|
|
252
254
|
onComplete: () => {
|
|
@@ -258,7 +260,7 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
258
260
|
}
|
|
259
261
|
const origin = !props.disableOriginAnimation ? getOriginEl() : null;
|
|
260
262
|
const pRect = panel.getBoundingClientRect();
|
|
261
|
-
const tl = gsap
|
|
263
|
+
const tl = gsap.timeline({ onComplete: () => {
|
|
262
264
|
activeTimeline = null;
|
|
263
265
|
releaseScrollLock();
|
|
264
266
|
done();
|
|
@@ -297,15 +299,12 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
297
299
|
ease: "power2.in"
|
|
298
300
|
}, .22);
|
|
299
301
|
}
|
|
300
|
-
let previousOverflow = "";
|
|
301
|
-
let previousPaddingRight = "";
|
|
302
302
|
let previouslyFocused = null;
|
|
303
303
|
let scrollLocked = false;
|
|
304
304
|
function releaseScrollLock() {
|
|
305
305
|
if (!scrollLocked) return;
|
|
306
|
-
document.body.style.overflow = previousOverflow;
|
|
307
|
-
document.body.style.paddingRight = previousPaddingRight;
|
|
308
306
|
scrollLocked = false;
|
|
307
|
+
unlockBodyScroll();
|
|
309
308
|
}
|
|
310
309
|
watch(() => props.modelValue, (open) => {
|
|
311
310
|
if (open) {
|
|
@@ -313,12 +312,8 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
313
312
|
previouslyFocused = active;
|
|
314
313
|
capturedOrigin = active && active !== document.body ? active : null;
|
|
315
314
|
if (props.lockScroll && !scrollLocked) {
|
|
316
|
-
const scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
317
|
-
previousOverflow = document.body.style.overflow;
|
|
318
|
-
previousPaddingRight = document.body.style.paddingRight;
|
|
319
|
-
document.body.style.overflow = "hidden";
|
|
320
|
-
if (scrollBarWidth > 0) document.body.style.paddingRight = `${scrollBarWidth}px`;
|
|
321
315
|
scrollLocked = true;
|
|
316
|
+
lockBodyScroll();
|
|
322
317
|
}
|
|
323
318
|
emit("open");
|
|
324
319
|
nextTick(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.vue_vue_type_script_setup_true_lang.mjs","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 overlayClasses, \n ]\" \n :style=\"overlayStyle\" \n :data-modo-theme=\"scopedTheme || undefined\" \n @mousedown=\"onOverlayMouseDown\" \n @click=\"onOverlayClick\" \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', \n 'dark:bg-card/85 dark:backdrop-blur-xl', \n 'border border-border shadow-xl', \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 (animado en etapa 2) --> \n <div ref=\"contentRef\" data-modo-modal-content class=\"flex flex-col min-h-0 flex-1 opacity-0\"> \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, 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 { 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; \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 const content = \n overlay?.querySelector<HTMLElement>('[data-modo-modal-content]') \n ?? contentRef.value; \n if (!overlay || !panel || !content) { done(); return; } \n \n activeTimeline?.kill(); \n \n if (prefersReducedMotion()) { \n gsap.set([overlay, panel, content], { 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 emerge from trigger (small) → grows to full size \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 // 3. Contenido fade in una vez el panel tiene tamaño real \n tl.fromTo( \n content, \n { opacity: 0, y: 8 }, \n { opacity: 1, y: 0, duration: 0.28, ease: 'power2.out' }, \n 0.38, \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 const content = \n overlay.querySelector<HTMLElement>('[data-modo-modal-content]') \n ?? contentRef.value; \n if (!overlay || !panel || !content) { 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 // 1. Contenido desaparece (solo opacidad, sin movimiento) \n tl.to(content, { opacity: 0, duration: 0.18, ease: 'power1.in' }, 0); \n \n // 2. Panel se encoge hacia el trigger (inmediatamente despues de que \n // el contenido ya es invisible, no solapado con el fade). \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, opacity: 0, duration: 0.38, ease: 'power3.in' }, \n 0.18, \n ); \n } else { \n tl.to( \n panel, \n { y: 10, scale: 0.95, opacity: 0, duration: 0.24, ease: 'power2.in' }, \n 0.18, \n ); \n } \n \n // 3. Overlay fade out junto al panel \n tl.to(overlay, { opacity: 0, duration: 0.28, ease: 'power2.in' }, 0.22); \n} \n \n/* ---------- Scroll lock + focus management ---------- */ \nlet previousOverflow = ''; \nlet previousPaddingRight = ''; \nlet previouslyFocused: HTMLElement | null = null; \nlet scrollLocked = false; \n \nfunction releaseScrollLock() { \n if (!scrollLocked) return; \n document.body.style.overflow = previousOverflow; \n document.body.style.paddingRight = previousPaddingRight; \n scrollLocked = false; \n} \n \nwatch( \n () => props.modelValue, \n (open) => { \n if (open) { \n const active = document.activeElement as HTMLElement | null; \n previouslyFocused = active; \n capturedOrigin = active && active !== document.body ? active : null; \n \n if (props.lockScroll && !scrollLocked) { \n const scrollBarWidth = window.innerWidth - document.documentElement.clientWidth; \n previousOverflow = document.body.style.overflow; \n previousPaddingRight = document.body.style.paddingRight; \n document.body.style.overflow = 'hidden'; \n if (scrollBarWidth > 0) { \n document.body.style.paddingRight = `${scrollBarWidth}px`; \n } \n scrollLocked = true; \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 activeTimeline?.kill(); \n releaseScrollLock(); \n}); \n \n/* ---------- Style maps ---------- */ \nconst sizeClasses = computed(() => { \n switch (props.size) { \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 overlayClasses = computed(() => { \n switch (props.overlay) { \n case 'solid': return 'bg-foreground/60'; \n case 'transparent': return 'bg-transparent'; \n case 'dark': return 'bg-foreground/80'; \n case 'dim': return 'bg-foreground/20'; \n case 'glass': return 'bg-background/50 backdrop-blur-md'; \n case 'blur': \n default: return 'bg-foreground/40 backdrop-blur-sm'; \n } \n}); \n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoPA,IAAM,qBACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAjGJ,MAAM,QAAQ;EAcd,MAAM,OAAO;EAOb,MAAM,SAAS,OAAO;EACtB,MAAM,UAAU,eAAe,cAAc,OAAO,QAAQ;EAC5D,MAAM,gBAAgB,eAAe,cAAc,OAAO,OAAO;EAEjE,MAAM,aAAa,IAAwB,KAAK;EAChD,MAAM,WAAW,IAAwB,KAAK;EAC9C,MAAM,aAAa,IAAwB,KAAK;EAEhD,MAAM,gBAAgB,uBAAuB,MAAM,MAA+B;EAClF,MAAM,iBAAiB,wBAAwB,MAAM,OAAiC;EAEtF,MAAM,MAAM,eAAe;EAC3B,MAAM,QAAQ,kBAAkB;EAChC,MAAM,cAAc,eAAe,iBAAiB,MAAM,MAAM,CAAC;EAEjE,MAAM,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,SAAA,WAAA,EADV,YASa,oBAAA;;OAPR,IAAI,QAAA;OACL,SAAQ;OACR,MAAK;OACL,IAAG;OACH,QAAO;;8BAEI,CAAA,gBAAA,gBAAR,QAAA,MAAK,EAAA,EAAA,CAAA,CAAA;;qDAGF,QAAA,eAAA,WAAA,EADV,YAQa,oBAAA;;OANR,IAAI,cAAA;OACL,SAAQ;OACR,MAAK;OACL,OAAM;;8BAEW,CAAA,gBAAA,gBAAd,QAAA,YAAW,EAAA,EAAA,CAAA,CAAA;;;MAOhBA,KAAAA,OAAO,WAAWA,KAAAA,OAAO,QAAA,WAAA,EADnC,mBAWM,OAAA;;OATD,OAAK,eAAA;;QAA6GA,KAAAA,OAAO,UAAU,QAAA,SAAS,QAAA,cAAW,KAAA;QAAkDA,KAAAA,OAAO,SAAM,SAAA;;UAMvN,WAEO,KAAA,QAAA,QAAA,EAAA,QAAA,CADH,WAAQ,KAAA,QAAA,UAAA,CAAA,CAAA,CAAA,EAAA,EAAA,IAAA,mBAAA,IAAA,KAAA;MAMNA,KAAAA,OAAO,UAAA,WAAA,EADjB,mBAeS,UAfT,YAeS,CAVK,QAAA,eAAA,WAAA,EADV,mBAIE,QAJF,WAIE,KAAA,WAAA,EACF,mBAIE,QAJF,WAIE,GACF,WAAqC,KAAA,QAAA,UAAA,EAAT,OAAK,CAAA,CAAA,CAAA,IAAA,mBAAA,IAAA,KAAA"}
|
|
1
|
+
{"version":3,"file":"Modal.vue_vue_type_script_setup_true_lang.mjs","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 overlayClasses, \n ]\" \n :style=\"overlayStyle\" \n :data-modo-theme=\"scopedTheme || undefined\" \n @mousedown=\"onOverlayMouseDown\" \n @click=\"onOverlayClick\" \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', \n 'dark:bg-card/85 dark:backdrop-blur-xl', \n 'border border-border shadow-xl', \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 (animado en etapa 2) --> \n <div ref=\"contentRef\" data-modo-modal-content class=\"flex flex-col min-h-0 flex-1 opacity-0\"> \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, 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; \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 const content = \n overlay?.querySelector<HTMLElement>('[data-modo-modal-content]') \n ?? contentRef.value; \n if (!overlay || !panel || !content) { done(); return; } \n \n activeTimeline?.kill(); \n \n if (prefersReducedMotion()) { \n gsap.set([overlay, panel, content], { 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 emerge from trigger (small) → grows to full size \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 // 3. Contenido fade in una vez el panel tiene tamaño real \n tl.fromTo( \n content, \n { opacity: 0, y: 8 }, \n { opacity: 1, y: 0, duration: 0.28, ease: 'power2.out' }, \n 0.38, \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 const content =\n overlay.querySelector<HTMLElement>('[data-modo-modal-content]')\n ?? contentRef.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 || !content) { 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 // 1. Contenido desaparece (solo opacidad, sin movimiento) \n tl.to(content, { opacity: 0, duration: 0.18, ease: 'power1.in' }, 0); \n \n // 2. Panel se encoge hacia el trigger (inmediatamente despues de que \n // el contenido ya es invisible, no solapado con el fade). \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, opacity: 0, duration: 0.38, ease: 'power3.in' }, \n 0.18, \n ); \n } else { \n tl.to( \n panel, \n { y: 10, scale: 0.95, opacity: 0, duration: 0.24, ease: 'power2.in' }, \n 0.18, \n ); \n } \n \n // 3. Overlay fade out junto al panel \n tl.to(overlay, { opacity: 0, duration: 0.28, ease: 'power2.in' }, 0.22); \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\nwatch( \n () => props.modelValue, \n (open) => { \n if (open) { \n const active = document.activeElement as HTMLElement | null; \n previouslyFocused = active; \n capturedOrigin = active && active !== document.body ? active : null; \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 activeTimeline?.kill(); \n releaseScrollLock(); \n}); \n \n/* ---------- Style maps ---------- */ \nconst sizeClasses = computed(() => { \n switch (props.size) { \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 overlayClasses = computed(() => { \n switch (props.overlay) { \n case 'solid': return 'bg-foreground/60'; \n case 'transparent': return 'bg-transparent'; \n case 'dark': return 'bg-foreground/80'; \n case 'dim': return 'bg-foreground/20'; \n case 'glass': return 'bg-background/50 backdrop-blur-md'; \n case 'blur': \n default: return 'bg-foreground/40 backdrop-blur-sm'; \n } \n}); \n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqPA,IAAM,qBACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAjGJ,MAAM,QAAQ;EAcd,MAAM,OAAO;EAOb,MAAM,SAAS,OAAO;EACtB,MAAM,UAAU,eAAe,cAAc,OAAO,QAAQ;EAC5D,MAAM,gBAAgB,eAAe,cAAc,OAAO,OAAO;EAEjE,MAAM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AAA,CAlBO,QAAA,SAAA,WAAA,EADV,YASa,oBAAA;;OAPR,IAAI,QAAA;OACL,SAAQ;OACR,MAAK;OACL,IAAG;OACH,QAAO;;8BAEI,CAAA,gBAAA,gBAAR,QAAA,MAAK,EAAA,EAAA,CAAA,CAAA;;qDAGF,QAAA,eAAA,WAAA,EADV,YAQa,oBAAA;;OANR,IAAI,cAAA;OACL,SAAQ;OACR,MAAK;OACL,OAAM;;8BAEW,CAAA,gBAAA,gBAAd,QAAA,YAAW,EAAA,EAAA,CAAA,CAAA;;;MAOhBA,KAAAA,OAAO,WAAWA,KAAAA,OAAO,QAAA,WAAA,EADnC,mBAWM,OAAA;;OATD,OAAK,eAAA;;QAA6GA,KAAAA,OAAO,UAAU,QAAA,SAAS,QAAA,cAAW,KAAA;QAAkDA,KAAAA,OAAO,SAAM,SAAA;;UAMvN,WAEO,KAAA,QAAA,QAAA,EAAA,QAAA,CADH,WAAQ,KAAA,QAAA,UAAA,CAAA,CAAA,CAAA,EAAA,EAAA,IAAA,mBAAA,IAAA,KAAA;MAMNA,KAAAA,OAAO,UAAA,WAAA,EADjB,mBAeS,UAfT,YAeS,CAVK,QAAA,eAAA,WAAA,EADV,mBAIE,QAJF,WAIE,KAAA,WAAA,EACF,mBAIE,QAJF,WAIE,GACF,WAAqC,KAAA,QAAA,UAAA,EAAT,OAAK,CAAA,CAAA,CAAA,IAAA,mBAAA,IAAA,KAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.cjs","names":[],"sources":["../../../src/components/feedback/Tooltip.vue"],"sourcesContent":["<template>\n <span\n ref=\"triggerRef\"\n :class=\"['inline-flex', wrapperClass]\"\n :aria-describedby=\"isOpen ? tooltipId : undefined\"\n @mouseenter=\"onTriggerEnter\"\n @mouseleave=\"onTriggerLeave\"\n @focusin=\"onTriggerFocus\"\n @focusout=\"onTriggerBlur\"\n @click=\"onTriggerClick\"\n >\n <slot />\n </span>\n\n <Teleport to=\"body\">\n <Transition\n enter-active-class=\"transition duration-fast ease-standard\"\n enter-from-class=\"opacity-0 scale-95\"\n enter-to-class=\"opacity-100 scale-100\"\n leave-active-class=\"transition duration-fast ease-standard\"\n leave-from-class=\"opacity-100 scale-100\"\n leave-to-class=\"opacity-0 scale-95\"\n >\n <div\n v-if=\"isOpen && !disabled\"\n :id=\"tooltipId\"\n ref=\"panelRef\"\n role=\"tooltip\"\n :data-modo-theme=\"scopedTheme || undefined\"\n :class=\"[\n 'modo-tooltip fixed pointer-events-none select-none shadow-md',\n colorClasses,\n sizeClasses,\n radiusClasses,\n ]\"\n :style=\"panelStyle\"\n @mouseenter=\"onPanelEnter\"\n @mouseleave=\"onPanelLeave\"\n >\n <slot name=\"content\">{{ content }}</slot>\n\n <span\n v-if=\"arrow\"\n aria-hidden=\"true\"\n :class=\"[\n 'absolute w-2 h-2 rotate-45',\n arrowColorClass,\n arrowBorderClass,\n ]\"\n :style=\"arrowStyle\"\n />\n </div>\n </Transition>\n </Teleport>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, ref, useId, watch } from \"vue\";\nimport type {\n Tooltip,\n TooltipPlacement,\n TooltipTrigger,\n} from \"../../interfaces/feedback/Tooltip.interface\";\nimport {\n useResolvedColor,\n useResolvedRadius,\n useResolvedTheme,\n useModoConfig,\n useResolvedSize,\n} from \"../../composables/useModoConfig\";\nimport { resolveColorMode } from \"../../composables/useColorMode\";\nimport {\n palettesToCssVars,\n semanticTokensFromPalettes,\n} from \"../../config/palettes\";\nimport {\n hexToOklchString,\n pickForegroundOklch,\n} from \"../../config/colorPrimitives\";\nimport { surfacesToCssVars } from \"../../config/surfaces\";\nimport type { ModoColor, ModoRadius } from \"../../config/ModoConfig\";\n\nconst props = withDefaults(defineProps<Tooltip>(), {\n placement: \"top\",\n offset: 8,\n trigger: () => [\"hover\", \"focus\"] as TooltipTrigger[],\n openDelay: 200,\n closeDelay: 100,\n arrow: true,\n color: \"default\",\n disabled: false,\n open: undefined,\n maxWidth: 260,\n});\n\nconst resolvedSize = useResolvedSize(() => props.size);\n\nconst emit = defineEmits<{\n \"update:open\": [open: boolean];\n show: [];\n hide: [];\n}>();\n\n// Resolver color y radius desde ModoProvider (cascade).\n// 'inverted' es especial del Tooltip y no forma parte de ModoColor.\nconst isInverted = computed(() => props.color === \"inverted\");\nconst resolvedColor = useResolvedColor(() =>\n isInverted.value ? undefined : (props.color as ModoColor | undefined),\n);\nconst resolvedRadius = useResolvedRadius(\n () => props.radius as ModoRadius | undefined,\n);\n\n// Forward provider palette + theme to teleported panel.\nconst cfg = useModoConfig();\nconst theme = useResolvedTheme();\nconst scopedTheme = computed(() => resolveColorMode(theme.value));\n\nconst autoId = useId();\nconst tooltipId = computed(() => props.id ?? `modo-tooltip-${autoId}`);\n\nconst triggerRef = ref<HTMLElement | null>(null);\nconst panelRef = ref<HTMLElement | null>(null);\n\nconst internalOpen = ref(false);\nconst isControlled = computed(() => props.open !== undefined);\nconst isOpen = computed(() =>\n isControlled.value ? !!props.open : internalOpen.value,\n);\n\nconst triggers = computed<TooltipTrigger[]>(() =>\n Array.isArray(props.trigger) ? props.trigger : [props.trigger],\n);\nconst hasHover = computed(() => triggers.value.includes(\"hover\"));\nconst hasFocus = computed(() => triggers.value.includes(\"focus\"));\nconst hasClick = computed(() => triggers.value.includes(\"click\"));\n\n/* ---------- open/close with delays ---------- */\n\nlet openTimer: ReturnType<typeof setTimeout> | null = null;\nlet closeTimer: ReturnType<typeof setTimeout> | null = null;\n\nfunction clearTimers() {\n if (openTimer) {\n clearTimeout(openTimer);\n openTimer = null;\n }\n if (closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n}\n\nfunction scheduleOpen() {\n if (props.disabled || isControlled.value) return;\n if (closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n if (internalOpen.value) return;\n openTimer = setTimeout(() => {\n internalOpen.value = true;\n emit(\"update:open\", true);\n emit(\"show\");\n }, props.openDelay);\n}\nfunction scheduleClose() {\n if (isControlled.value) return;\n if (openTimer) {\n clearTimeout(openTimer);\n openTimer = null;\n }\n if (!internalOpen.value) return;\n closeTimer = setTimeout(() => {\n internalOpen.value = false;\n emit(\"update:open\", false);\n emit(\"hide\");\n }, props.closeDelay);\n}\n\n/* ---------- Trigger events ---------- */\n\nfunction onTriggerEnter() {\n if (hasHover.value) scheduleOpen();\n}\nfunction onTriggerLeave() {\n if (hasHover.value) scheduleClose();\n}\nfunction onTriggerFocus() {\n if (hasFocus.value) scheduleOpen();\n}\nfunction onTriggerBlur() {\n if (hasFocus.value) scheduleClose();\n}\nfunction onTriggerClick() {\n if (!hasClick.value) return;\n if (props.disabled || isControlled.value) return;\n if (internalOpen.value) {\n internalOpen.value = false;\n emit(\"update:open\", false);\n emit(\"hide\");\n } else {\n internalOpen.value = true;\n emit(\"update:open\", true);\n emit(\"show\");\n }\n}\nfunction onPanelEnter() {\n if (hasHover.value && closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n}\nfunction onPanelLeave() {\n if (hasHover.value) scheduleClose();\n}\n\n/* ---------- Positioning ---------- */\n\ninterface Pos {\n top: number;\n left: number;\n placement: TooltipPlacement;\n arrowCross?: number;\n}\nconst position = ref<Pos>({ top: 0, left: 0, placement: props.placement });\n\nfunction measure() {\n const panel = panelRef.value;\n if (!panel) return;\n\n // Anchor mode: position against a virtual point instead of the trigger box.\n const a = props.anchor;\n const tRect: DOMRect = a\n ? ({ top: a.y, bottom: a.y, left: a.x, right: a.x, width: 0, height: 0, x: a.x, y: a.y, toJSON() { return this; } } as DOMRect)\n : (triggerRef.value?.getBoundingClientRect() as DOMRect);\n if (!tRect) return;\n // Usar offsetWidth/Height (ignoran el transform de la transición scale).\n const panelW = panel.offsetWidth;\n const panelH = panel.offsetHeight;\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n const margin = 8;\n const off = props.offset;\n\n let placement = props.placement;\n const axis = placement.split(\"-\")[0] as \"top\" | \"bottom\" | \"left\" | \"right\";\n const side = (placement.split(\"-\")[1] ?? \"center\") as\n | \"start\"\n | \"end\"\n | \"center\";\n\n // Auto-flip vertical/horizontal if not enough room\n if (axis === \"top\" && tRect.top - panelH - off < margin) {\n placement = placement.replace(\"top\", \"bottom\") as TooltipPlacement;\n } else if (axis === \"bottom\" && tRect.bottom + panelH + off > vh - margin) {\n placement = placement.replace(\"bottom\", \"top\") as TooltipPlacement;\n } else if (axis === \"left\" && tRect.left - panelW - off < margin) {\n placement = placement.replace(\"left\", \"right\") as TooltipPlacement;\n } else if (axis === \"right\" && tRect.right + panelW + off > vw - margin) {\n placement = placement.replace(\"right\", \"left\") as TooltipPlacement;\n }\n\n const axis2 = placement.split(\"-\")[0] as \"top\" | \"bottom\" | \"left\" | \"right\";\n\n let top = 0;\n let left = 0;\n\n if (axis2 === \"top\" || axis2 === \"bottom\") {\n top = axis2 === \"top\" ? tRect.top - panelH - off : tRect.bottom + off;\n if (side === \"start\") left = tRect.left;\n else if (side === \"end\") left = tRect.right - panelW;\n else left = tRect.left + tRect.width / 2 - panelW / 2;\n } else {\n left = axis2 === \"left\" ? tRect.left - panelW - off : tRect.right + off;\n if (side === \"start\") top = tRect.top;\n else if (side === \"end\") top = tRect.bottom - panelH;\n else top = tRect.top + tRect.height / 2 - panelH / 2;\n }\n\n // Clamp al viewport\n if (left + panelW > vw - margin) left = vw - panelW - margin;\n if (left < margin) left = margin;\n if (top + panelH > vh - margin) top = vh - panelH - margin;\n if (top < margin) top = margin;\n\n // Arrow position (apuntando al centro del trigger, dentro del panel).\n let arrowCross: number | undefined;\n if (axis2 === \"top\" || axis2 === \"bottom\") {\n arrowCross = Math.min(\n Math.max(tRect.left + tRect.width / 2 - left, 10),\n panelW - 10,\n );\n } else {\n arrowCross = Math.min(\n Math.max(tRect.top + tRect.height / 2 - top, 10),\n panelH - 10,\n );\n }\n\n position.value = { top, left, placement, arrowCross };\n}\n\nconst panelStyle = computed(() => {\n const providerVars = cfg?.value.palettes\n ? {\n ...palettesToCssVars(cfg.value.palettes),\n ...semanticTokensFromPalettes(\n cfg.value.palettes,\n hexToOklchString,\n pickForegroundOklch,\n ),\n }\n : {};\n const surfaceVars = cfg?.value.surfaces\n ? surfacesToCssVars(cfg.value.surfaces)\n : {};\n const darkSurfaceVars =\n scopedTheme.value === \"dark\" && cfg?.value.darkSurfaces\n ? surfacesToCssVars(cfg.value.darkSurfaces)\n : {};\n return {\n ...providerVars,\n ...surfaceVars,\n ...darkSurfaceVars,\n top: `${position.value.top}px`,\n left: `${position.value.left}px`,\n maxWidth: `${props.maxWidth}px`,\n zIndex: \"1400\",\n transformOrigin: transformOriginFromPlacement(position.value.placement),\n };\n});\n\nfunction transformOriginFromPlacement(pl: TooltipPlacement): string {\n const axis = pl.split(\"-\")[0];\n const side = pl.split(\"-\")[1] ?? \"center\";\n switch (axis) {\n case \"top\":\n return side === \"start\"\n ? \"left bottom\"\n : side === \"end\"\n ? \"right bottom\"\n : \"center bottom\";\n case \"bottom\":\n return side === \"start\"\n ? \"left top\"\n : side === \"end\"\n ? \"right top\"\n : \"center top\";\n case \"left\":\n return side === \"start\"\n ? \"right top\"\n : side === \"end\"\n ? \"right bottom\"\n : \"right center\";\n case \"right\":\n return side === \"start\"\n ? \"left top\"\n : side === \"end\"\n ? \"left bottom\"\n : \"left center\";\n }\n return \"center center\";\n}\n\nconst arrowStyle = computed(() => {\n const { arrowCross, placement } = position.value;\n if (arrowCross === undefined) return {};\n const axis = placement.split(\"-\")[0];\n switch (axis) {\n case \"top\": // panel above trigger → arrow on panel bottom\n return { left: `${arrowCross}px`, bottom: \"-4px\" };\n case \"bottom\": // panel below trigger → arrow on panel top\n return { left: `${arrowCross}px`, top: \"-4px\" };\n case \"left\": // panel left of trigger → arrow on panel right\n return { top: `${arrowCross}px`, right: \"-4px\" };\n case \"right\": // panel right of trigger → arrow on panel left\n return { top: `${arrowCross}px`, left: \"-4px\" };\n }\n return {};\n});\n\nfunction onScrollOrResize() {\n if (isOpen.value) measure();\n}\n\n// Anchor mode: reposition as the virtual point moves (e.g. chart hover).\nwatch(\n () => props.anchor,\n () => { if (isOpen.value) measure(); },\n { deep: true },\n);\n\nlet resizeObserver: ResizeObserver | null = null;\n\nfunction onOutsideTouch(e: TouchEvent) {\n if (!internalOpen.value) return;\n const target = e.target as Node | null;\n if (triggerRef.value?.contains(target)) return;\n if (panelRef.value?.contains(target)) return;\n internalOpen.value = false;\n emit(\"update:open\", false);\n emit(\"hide\");\n}\n\nwatch(isOpen, (open) => {\n if (open) {\n requestAnimationFrame(() => {\n measure();\n requestAnimationFrame(measure);\n });\n window.addEventListener(\"scroll\", onScrollOrResize, true);\n window.addEventListener(\"resize\", onScrollOrResize);\n if (triggerRef.value && typeof ResizeObserver !== \"undefined\") {\n resizeObserver = new ResizeObserver(onScrollOrResize);\n resizeObserver.observe(triggerRef.value);\n if (panelRef.value) resizeObserver.observe(panelRef.value);\n }\n // On touch devices, hover never fires mouseleave — close on outside tap.\n if (hasHover.value) document.addEventListener(\"touchstart\", onOutsideTouch, { passive: true });\n } else {\n window.removeEventListener(\"scroll\", onScrollOrResize, true);\n window.removeEventListener(\"resize\", onScrollOrResize);\n resizeObserver?.disconnect();\n resizeObserver = null;\n document.removeEventListener(\"touchstart\", onOutsideTouch);\n }\n});\n\nonBeforeUnmount(() => {\n clearTimers();\n window.removeEventListener(\"scroll\", onScrollOrResize, true);\n window.removeEventListener(\"resize\", onScrollOrResize);\n resizeObserver?.disconnect();\n document.removeEventListener(\"touchstart\", onOutsideTouch);\n});\n\n/* ---------- Style maps ---------- */\n\nconst COLOR_CLASSES: Record<string, string> = {\n default: \"bg-foreground text-background\",\n inverted: \"bg-background text-foreground border border-border\",\n primary: \"bg-primary text-primary-foreground\",\n danger: \"bg-destructive text-destructive-foreground\",\n success: \"bg-success text-success-foreground\",\n warning: \"bg-warning text-warning-foreground\",\n};\nconst ARROW_COLOR_CLASSES: Record<string, string> = {\n default: \"bg-foreground\",\n // No `border` here — borders are applied only on the two outer-facing\n // sides via `arrowBorderClass`, to avoid rendering a full diamond outline.\n inverted: \"bg-background\",\n primary: \"bg-primary\",\n danger: \"bg-destructive\",\n success: \"bg-success\",\n warning: \"bg-warning\",\n};\n\nconst colorClasses = computed(() => {\n if (isInverted.value) return COLOR_CLASSES.inverted;\n return COLOR_CLASSES[resolvedColor.value] ?? COLOR_CLASSES.default;\n});\nconst arrowColorClass = computed(() => {\n if (isInverted.value) return ARROW_COLOR_CLASSES.inverted;\n return (\n ARROW_COLOR_CLASSES[resolvedColor.value] ?? ARROW_COLOR_CLASSES.default\n );\n});\n\n// The rotated square exposes only its two outer-facing sides past the panel\n// edge. We render borders on just those sides so the arrow tip reads as a\n// triangle instead of a diamond. Only applied to the `inverted` variant,\n// which is the only one that uses a visible border on the tooltip body.\nconst arrowBorderClass = computed(() => {\n if (!isInverted.value) return \"\";\n const axis = position.value.placement.split(\"-\")[0];\n switch (axis) {\n case \"top\":\n return \"border-r border-b border-border\";\n case \"bottom\":\n return \"border-t border-l border-border\";\n case \"left\":\n return \"border-t border-r border-border\";\n case \"right\":\n return \"border-b border-l border-border\";\n default:\n return \"\";\n }\n});\n\nconst sizeClasses = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"px-2 py-1 text-[11px]\";\n case \"large\":\n return \"px-3.5 py-2 text-body\";\n default:\n return \"px-2.5 py-1.5 text-caption\";\n }\n});\n\nconst radiusClasses = computed(() => {\n switch (resolvedRadius.value) {\n case \"none\":\n return \"rounded-none\";\n case \"small\":\n return \"rounded-sm\";\n case \"large\":\n return \"rounded-lg\";\n case \"full\":\n return \"rounded-full\";\n default:\n return \"rounded-md\";\n }\n});\n</script>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Tooltip.cjs","names":[],"sources":["../../../src/components/feedback/Tooltip.vue"],"sourcesContent":["<template>\n <span\n ref=\"triggerRef\"\n :class=\"['inline-flex', wrapperClass]\"\n :aria-describedby=\"isOpen ? tooltipId : undefined\"\n @mouseenter=\"onTriggerEnter\"\n @mouseleave=\"onTriggerLeave\"\n @focusin=\"onTriggerFocus\"\n @focusout=\"onTriggerBlur\"\n @click=\"onTriggerClick\"\n @touchmove.passive=\"onTouchScroll\"\n >\n <slot />\n </span>\n\n <Teleport to=\"body\">\n <Transition\n enter-active-class=\"transition duration-fast ease-standard\"\n enter-from-class=\"opacity-0 scale-95\"\n enter-to-class=\"opacity-100 scale-100\"\n leave-active-class=\"transition duration-fast ease-standard\"\n leave-from-class=\"opacity-100 scale-100\"\n leave-to-class=\"opacity-0 scale-95\"\n >\n <div\n v-if=\"isOpen && !disabled\"\n :id=\"tooltipId\"\n ref=\"panelRef\"\n role=\"tooltip\"\n :data-modo-theme=\"scopedTheme || undefined\"\n :class=\"[\n 'modo-tooltip fixed pointer-events-none select-none shadow-md',\n colorClasses,\n sizeClasses,\n radiusClasses,\n ]\"\n :style=\"panelStyle\"\n @mouseenter=\"onPanelEnter\"\n @mouseleave=\"onPanelLeave\"\n >\n <slot name=\"content\">{{ content }}</slot>\n\n <span\n v-if=\"arrow\"\n aria-hidden=\"true\"\n :class=\"[\n 'absolute w-2 h-2 rotate-45',\n arrowColorClass,\n arrowBorderClass,\n ]\"\n :style=\"arrowStyle\"\n />\n </div>\n </Transition>\n </Teleport>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, ref, useId, watch } from \"vue\";\nimport type {\n Tooltip,\n TooltipPlacement,\n TooltipTrigger,\n} from \"../../interfaces/feedback/Tooltip.interface\";\nimport {\n useResolvedColor,\n useResolvedRadius,\n useResolvedTheme,\n useModoConfig,\n useResolvedSize,\n} from \"../../composables/useModoConfig\";\nimport { resolveColorMode } from \"../../composables/useColorMode\";\nimport {\n palettesToCssVars,\n semanticTokensFromPalettes,\n} from \"../../config/palettes\";\nimport {\n hexToOklchString,\n pickForegroundOklch,\n} from \"../../config/colorPrimitives\";\nimport { surfacesToCssVars } from \"../../config/surfaces\";\nimport {\n TOOLTIP_ARROW_SIZE,\n tooltipArrowCross,\n tooltipArrowInset,\n} from \"../../utils/tooltipArrow\";\nimport type { ModoColor, ModoRadius } from \"../../config/ModoConfig\";\n\nconst props = withDefaults(defineProps<Tooltip>(), {\n placement: \"top\",\n offset: 8,\n trigger: () => [\"hover\", \"focus\"] as TooltipTrigger[],\n openDelay: 200,\n closeDelay: 100,\n arrow: true,\n color: \"default\",\n disabled: false,\n open: undefined,\n maxWidth: 260,\n});\n\nconst resolvedSize = useResolvedSize(() => props.size);\n\nconst emit = defineEmits<{\n \"update:open\": [open: boolean];\n show: [];\n hide: [];\n}>();\n\n// Resolver color y radius desde ModoProvider (cascade).\n// 'inverted' es especial del Tooltip y no forma parte de ModoColor.\nconst isInverted = computed(() => props.color === \"inverted\");\nconst resolvedColor = useResolvedColor(() =>\n isInverted.value ? undefined : (props.color as ModoColor | undefined),\n);\nconst resolvedRadius = useResolvedRadius(\n () => props.radius as ModoRadius | undefined,\n);\n\n// Forward provider palette + theme to teleported panel.\nconst cfg = useModoConfig();\nconst theme = useResolvedTheme();\nconst scopedTheme = computed(() => resolveColorMode(theme.value));\n\nconst autoId = useId();\nconst tooltipId = computed(() => props.id ?? `modo-tooltip-${autoId}`);\n\nconst triggerRef = ref<HTMLElement | null>(null);\nconst panelRef = ref<HTMLElement | null>(null);\n\nconst internalOpen = ref(false);\nconst isControlled = computed(() => props.open !== undefined);\nconst isOpen = computed(() =>\n isControlled.value ? !!props.open : internalOpen.value,\n);\n\nconst triggers = computed<TooltipTrigger[]>(() =>\n Array.isArray(props.trigger) ? props.trigger : [props.trigger],\n);\nconst hasHover = computed(() => triggers.value.includes(\"hover\"));\nconst hasFocus = computed(() => triggers.value.includes(\"focus\"));\nconst hasClick = computed(() => triggers.value.includes(\"click\"));\n\n/* ---------- open/close with delays ---------- */\n\nlet openTimer: ReturnType<typeof setTimeout> | null = null;\nlet closeTimer: ReturnType<typeof setTimeout> | null = null;\n\nfunction clearTimers() {\n if (openTimer) {\n clearTimeout(openTimer);\n openTimer = null;\n }\n if (closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n}\n\nfunction scheduleOpen() {\n if (props.disabled || isControlled.value) return;\n if (closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n if (internalOpen.value) return;\n openTimer = setTimeout(() => {\n internalOpen.value = true;\n emit(\"update:open\", true);\n emit(\"show\");\n }, props.openDelay);\n}\nfunction scheduleClose() {\n if (isControlled.value) return;\n if (openTimer) {\n clearTimeout(openTimer);\n openTimer = null;\n }\n if (!internalOpen.value) return;\n closeTimer = setTimeout(() => {\n internalOpen.value = false;\n emit(\"update:open\", false);\n emit(\"hide\");\n }, props.closeDelay);\n}\n\n/* ---------- Trigger events ---------- */\n\nfunction onTriggerEnter() {\n if (hasHover.value) scheduleOpen();\n}\nfunction onTriggerLeave() {\n if (hasHover.value) scheduleClose();\n}\nfunction onTriggerFocus() {\n if (hasFocus.value) scheduleOpen();\n}\nfunction onTriggerBlur() {\n if (hasFocus.value) scheduleClose();\n}\nfunction onTriggerClick() {\n if (!hasClick.value) return;\n if (props.disabled || isControlled.value) return;\n if (internalOpen.value) {\n internalOpen.value = false;\n emit(\"update:open\", false);\n emit(\"hide\");\n } else {\n internalOpen.value = true;\n emit(\"update:open\", true);\n emit(\"show\");\n }\n}\nfunction onPanelEnter() {\n if (hasHover.value && closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n}\nfunction onPanelLeave() {\n if (hasHover.value) scheduleClose();\n}\n\n/* ---------- Positioning ---------- */\n\ninterface Pos {\n top: number;\n left: number;\n placement: TooltipPlacement;\n arrowCross?: number;\n}\nconst position = ref<Pos>({ top: 0, left: 0, placement: props.placement });\n\nfunction measure() {\n const panel = panelRef.value;\n if (!panel) return;\n\n // Anchor mode: position against a virtual point instead of the trigger box.\n const a = props.anchor;\n const tRect: DOMRect = a\n ? ({ top: a.y, bottom: a.y, left: a.x, right: a.x, width: 0, height: 0, x: a.x, y: a.y, toJSON() { return this; } } as DOMRect)\n : (triggerRef.value?.getBoundingClientRect() as DOMRect);\n if (!tRect) return;\n // Usar offsetWidth/Height (ignoran el transform de la transición scale).\n const panelW = panel.offsetWidth;\n const panelH = panel.offsetHeight;\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n const margin = 8;\n const off = props.offset;\n\n let placement = props.placement;\n const axis = placement.split(\"-\")[0] as \"top\" | \"bottom\" | \"left\" | \"right\";\n const side = (placement.split(\"-\")[1] ?? \"center\") as\n | \"start\"\n | \"end\"\n | \"center\";\n\n // Auto-flip vertical/horizontal if not enough room\n if (axis === \"top\" && tRect.top - panelH - off < margin) {\n placement = placement.replace(\"top\", \"bottom\") as TooltipPlacement;\n } else if (axis === \"bottom\" && tRect.bottom + panelH + off > vh - margin) {\n placement = placement.replace(\"bottom\", \"top\") as TooltipPlacement;\n } else if (axis === \"left\" && tRect.left - panelW - off < margin) {\n placement = placement.replace(\"left\", \"right\") as TooltipPlacement;\n } else if (axis === \"right\" && tRect.right + panelW + off > vw - margin) {\n placement = placement.replace(\"right\", \"left\") as TooltipPlacement;\n }\n\n const axis2 = placement.split(\"-\")[0] as \"top\" | \"bottom\" | \"left\" | \"right\";\n\n let top = 0;\n let left = 0;\n\n if (axis2 === \"top\" || axis2 === \"bottom\") {\n top = axis2 === \"top\" ? tRect.top - panelH - off : tRect.bottom + off;\n if (side === \"start\") left = tRect.left;\n else if (side === \"end\") left = tRect.right - panelW;\n else left = tRect.left + tRect.width / 2 - panelW / 2;\n } else {\n left = axis2 === \"left\" ? tRect.left - panelW - off : tRect.right + off;\n if (side === \"start\") top = tRect.top;\n else if (side === \"end\") top = tRect.bottom - panelH;\n else top = tRect.top + tRect.height / 2 - panelH / 2;\n }\n\n // Clamp al viewport\n if (left + panelW > vw - margin) left = vw - panelW - margin;\n if (left < margin) left = margin;\n if (top + panelH > vh - margin) top = vh - panelH - margin;\n if (top < margin) top = margin;\n\n // Arrow centre (apuntando al centro del trigger, dentro del panel).\n const isVerticalAxis = axis2 === \"top\" || axis2 === \"bottom\";\n const edgeSize = isVerticalAxis ? panelW : panelH;\n const arrowCross = tooltipArrowCross(\n isVerticalAxis\n ? tRect.left + tRect.width / 2 - left\n : tRect.top + tRect.height / 2 - top,\n edgeSize,\n tooltipArrowInset(resolvedRadius.value, edgeSize),\n );\n\n position.value = { top, left, placement, arrowCross };\n}\n\nconst panelStyle = computed(() => {\n const providerVars = cfg?.value.palettes\n ? {\n ...palettesToCssVars(cfg.value.palettes),\n ...semanticTokensFromPalettes(\n cfg.value.palettes,\n hexToOklchString,\n pickForegroundOklch,\n ),\n }\n : {};\n const surfaceVars = cfg?.value.surfaces\n ? surfacesToCssVars(cfg.value.surfaces)\n : {};\n const darkSurfaceVars =\n scopedTheme.value === \"dark\" && cfg?.value.darkSurfaces\n ? surfacesToCssVars(cfg.value.darkSurfaces)\n : {};\n return {\n ...providerVars,\n ...surfaceVars,\n ...darkSurfaceVars,\n top: `${position.value.top}px`,\n left: `${position.value.left}px`,\n maxWidth: `${props.maxWidth}px`,\n zIndex: \"1400\",\n transformOrigin: transformOriginFromPlacement(position.value.placement),\n };\n});\n\nfunction transformOriginFromPlacement(pl: TooltipPlacement): string {\n const axis = pl.split(\"-\")[0];\n const side = pl.split(\"-\")[1] ?? \"center\";\n switch (axis) {\n case \"top\":\n return side === \"start\"\n ? \"left bottom\"\n : side === \"end\"\n ? \"right bottom\"\n : \"center bottom\";\n case \"bottom\":\n return side === \"start\"\n ? \"left top\"\n : side === \"end\"\n ? \"right top\"\n : \"center top\";\n case \"left\":\n return side === \"start\"\n ? \"right top\"\n : side === \"end\"\n ? \"right bottom\"\n : \"right center\";\n case \"right\":\n return side === \"start\"\n ? \"left top\"\n : side === \"end\"\n ? \"left bottom\"\n : \"left center\";\n }\n return \"center center\";\n}\n\nconst arrowStyle = computed(() => {\n const { arrowCross, placement } = position.value;\n if (arrowCross === undefined) return {};\n const axis = placement.split(\"-\")[0];\n // `arrowCross` is where the arrow's centre goes; `left`/`top` place its\n // leading edge, hence the half-size shift.\n const cross = `${arrowCross - TOOLTIP_ARROW_SIZE / 2}px`;\n const out = `-${TOOLTIP_ARROW_SIZE / 2}px`;\n switch (axis) {\n case \"top\": // panel above trigger → arrow on panel bottom\n return { left: cross, bottom: out };\n case \"bottom\": // panel below trigger → arrow on panel top\n return { left: cross, top: out };\n case \"left\": // panel left of trigger → arrow on panel right\n return { top: cross, right: out };\n case \"right\": // panel right of trigger → arrow on panel left\n return { top: cross, left: out };\n }\n return {};\n});\n\nfunction onScrollOrResize() {\n if (isOpen.value) measure();\n}\n\n// Anchor mode: reposition as the virtual point moves (e.g. chart hover).\nwatch(\n () => props.anchor,\n () => { if (isOpen.value) measure(); },\n { deep: true },\n);\n\nlet resizeObserver: ResizeObserver | null = null;\n\nfunction dismiss() {\n if (!internalOpen.value) return;\n internalOpen.value = false;\n emit(\"update:open\", false);\n emit(\"hide\");\n}\n\nfunction onOutsideTouch(e: Event) {\n if (!internalOpen.value) return;\n const target = e.target as Node | null;\n if (triggerRef.value?.contains(target)) return;\n if (panelRef.value?.contains(target)) return;\n dismiss();\n}\n\n/**\n * A touch drag is the page being scrolled. On a pointer device the tooltip\n * follows the trigger because the cursor stays put and `mouseleave` ends it;\n * on touch there is no cursor and no `mouseleave`, so repositioning on scroll\n * left the tooltip riding the screen indefinitely. Cancel a pending open too:\n * a tap that turns into a drag must not pop a tooltip mid-scroll.\n *\n * Gestures that start on the trigger never reach the document listener — touch\n * events stay targeted at the element the finger landed on — which is why the\n * trigger binds this as well.\n */\nfunction onTouchScroll() {\n clearTimers();\n dismiss();\n}\n\nwatch(isOpen, (open) => {\n if (open) {\n requestAnimationFrame(() => {\n measure();\n requestAnimationFrame(measure);\n });\n window.addEventListener(\"scroll\", onScrollOrResize, true);\n window.addEventListener(\"resize\", onScrollOrResize);\n if (triggerRef.value && typeof ResizeObserver !== \"undefined\") {\n resizeObserver = new ResizeObserver(onScrollOrResize);\n resizeObserver.observe(triggerRef.value);\n if (panelRef.value) resizeObserver.observe(panelRef.value);\n }\n // On touch devices there is no cursor to move away: nothing dismisses the\n // tooltip on its own, whichever trigger opened it. An outside tap ends it,\n // and so does scrolling the page.\n document.addEventListener(\"touchstart\", onOutsideTouch, { passive: true });\n document.addEventListener(\"touchmove\", onTouchScroll, { passive: true });\n } else {\n window.removeEventListener(\"scroll\", onScrollOrResize, true);\n window.removeEventListener(\"resize\", onScrollOrResize);\n resizeObserver?.disconnect();\n resizeObserver = null;\n document.removeEventListener(\"touchstart\", onOutsideTouch);\n document.removeEventListener(\"touchmove\", onTouchScroll);\n }\n});\n\nonBeforeUnmount(() => {\n clearTimers();\n window.removeEventListener(\"scroll\", onScrollOrResize, true);\n window.removeEventListener(\"resize\", onScrollOrResize);\n resizeObserver?.disconnect();\n document.removeEventListener(\"touchstart\", onOutsideTouch);\n document.removeEventListener(\"touchmove\", onTouchScroll);\n});\n\n/* ---------- Style maps ---------- */\n\nconst COLOR_CLASSES: Record<string, string> = {\n default: \"bg-foreground text-background\",\n inverted: \"bg-background text-foreground border border-border\",\n primary: \"bg-primary text-primary-foreground\",\n danger: \"bg-destructive text-destructive-foreground\",\n success: \"bg-success text-success-foreground\",\n warning: \"bg-warning text-warning-foreground\",\n};\nconst ARROW_COLOR_CLASSES: Record<string, string> = {\n default: \"bg-foreground\",\n // No `border` here — borders are applied only on the two outer-facing\n // sides via `arrowBorderClass`, to avoid rendering a full diamond outline.\n inverted: \"bg-background\",\n primary: \"bg-primary\",\n danger: \"bg-destructive\",\n success: \"bg-success\",\n warning: \"bg-warning\",\n};\n\nconst colorClasses = computed(() => {\n if (isInverted.value) return COLOR_CLASSES.inverted;\n return COLOR_CLASSES[resolvedColor.value] ?? COLOR_CLASSES.default;\n});\nconst arrowColorClass = computed(() => {\n if (isInverted.value) return ARROW_COLOR_CLASSES.inverted;\n return (\n ARROW_COLOR_CLASSES[resolvedColor.value] ?? ARROW_COLOR_CLASSES.default\n );\n});\n\n// The rotated square exposes only its two outer-facing sides past the panel\n// edge. We render borders on just those sides so the arrow tip reads as a\n// triangle instead of a diamond. Only applied to the `inverted` variant,\n// which is the only one that uses a visible border on the tooltip body.\nconst arrowBorderClass = computed(() => {\n if (!isInverted.value) return \"\";\n const axis = position.value.placement.split(\"-\")[0];\n switch (axis) {\n case \"top\":\n return \"border-r border-b border-border\";\n case \"bottom\":\n return \"border-t border-l border-border\";\n case \"left\":\n return \"border-t border-r border-border\";\n case \"right\":\n return \"border-b border-l border-border\";\n default:\n return \"\";\n }\n});\n\nconst sizeClasses = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"px-2 py-1 text-[11px]\";\n case \"large\":\n return \"px-3.5 py-2 text-body\";\n default:\n return \"px-2.5 py-1.5 text-caption\";\n }\n});\n\nconst radiusClasses = computed(() => {\n switch (resolvedRadius.value) {\n case \"none\":\n return \"rounded-none\";\n case \"small\":\n return \"rounded-sm\";\n case \"large\":\n return \"rounded-lg\";\n case \"full\":\n return \"rounded-full\";\n default:\n return \"rounded-md\";\n }\n});\n</script>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.mjs","names":[],"sources":["../../../src/components/feedback/Tooltip.vue"],"sourcesContent":["<template>\n <span\n ref=\"triggerRef\"\n :class=\"['inline-flex', wrapperClass]\"\n :aria-describedby=\"isOpen ? tooltipId : undefined\"\n @mouseenter=\"onTriggerEnter\"\n @mouseleave=\"onTriggerLeave\"\n @focusin=\"onTriggerFocus\"\n @focusout=\"onTriggerBlur\"\n @click=\"onTriggerClick\"\n >\n <slot />\n </span>\n\n <Teleport to=\"body\">\n <Transition\n enter-active-class=\"transition duration-fast ease-standard\"\n enter-from-class=\"opacity-0 scale-95\"\n enter-to-class=\"opacity-100 scale-100\"\n leave-active-class=\"transition duration-fast ease-standard\"\n leave-from-class=\"opacity-100 scale-100\"\n leave-to-class=\"opacity-0 scale-95\"\n >\n <div\n v-if=\"isOpen && !disabled\"\n :id=\"tooltipId\"\n ref=\"panelRef\"\n role=\"tooltip\"\n :data-modo-theme=\"scopedTheme || undefined\"\n :class=\"[\n 'modo-tooltip fixed pointer-events-none select-none shadow-md',\n colorClasses,\n sizeClasses,\n radiusClasses,\n ]\"\n :style=\"panelStyle\"\n @mouseenter=\"onPanelEnter\"\n @mouseleave=\"onPanelLeave\"\n >\n <slot name=\"content\">{{ content }}</slot>\n\n <span\n v-if=\"arrow\"\n aria-hidden=\"true\"\n :class=\"[\n 'absolute w-2 h-2 rotate-45',\n arrowColorClass,\n arrowBorderClass,\n ]\"\n :style=\"arrowStyle\"\n />\n </div>\n </Transition>\n </Teleport>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, ref, useId, watch } from \"vue\";\nimport type {\n Tooltip,\n TooltipPlacement,\n TooltipTrigger,\n} from \"../../interfaces/feedback/Tooltip.interface\";\nimport {\n useResolvedColor,\n useResolvedRadius,\n useResolvedTheme,\n useModoConfig,\n useResolvedSize,\n} from \"../../composables/useModoConfig\";\nimport { resolveColorMode } from \"../../composables/useColorMode\";\nimport {\n palettesToCssVars,\n semanticTokensFromPalettes,\n} from \"../../config/palettes\";\nimport {\n hexToOklchString,\n pickForegroundOklch,\n} from \"../../config/colorPrimitives\";\nimport { surfacesToCssVars } from \"../../config/surfaces\";\nimport type { ModoColor, ModoRadius } from \"../../config/ModoConfig\";\n\nconst props = withDefaults(defineProps<Tooltip>(), {\n placement: \"top\",\n offset: 8,\n trigger: () => [\"hover\", \"focus\"] as TooltipTrigger[],\n openDelay: 200,\n closeDelay: 100,\n arrow: true,\n color: \"default\",\n disabled: false,\n open: undefined,\n maxWidth: 260,\n});\n\nconst resolvedSize = useResolvedSize(() => props.size);\n\nconst emit = defineEmits<{\n \"update:open\": [open: boolean];\n show: [];\n hide: [];\n}>();\n\n// Resolver color y radius desde ModoProvider (cascade).\n// 'inverted' es especial del Tooltip y no forma parte de ModoColor.\nconst isInverted = computed(() => props.color === \"inverted\");\nconst resolvedColor = useResolvedColor(() =>\n isInverted.value ? undefined : (props.color as ModoColor | undefined),\n);\nconst resolvedRadius = useResolvedRadius(\n () => props.radius as ModoRadius | undefined,\n);\n\n// Forward provider palette + theme to teleported panel.\nconst cfg = useModoConfig();\nconst theme = useResolvedTheme();\nconst scopedTheme = computed(() => resolveColorMode(theme.value));\n\nconst autoId = useId();\nconst tooltipId = computed(() => props.id ?? `modo-tooltip-${autoId}`);\n\nconst triggerRef = ref<HTMLElement | null>(null);\nconst panelRef = ref<HTMLElement | null>(null);\n\nconst internalOpen = ref(false);\nconst isControlled = computed(() => props.open !== undefined);\nconst isOpen = computed(() =>\n isControlled.value ? !!props.open : internalOpen.value,\n);\n\nconst triggers = computed<TooltipTrigger[]>(() =>\n Array.isArray(props.trigger) ? props.trigger : [props.trigger],\n);\nconst hasHover = computed(() => triggers.value.includes(\"hover\"));\nconst hasFocus = computed(() => triggers.value.includes(\"focus\"));\nconst hasClick = computed(() => triggers.value.includes(\"click\"));\n\n/* ---------- open/close with delays ---------- */\n\nlet openTimer: ReturnType<typeof setTimeout> | null = null;\nlet closeTimer: ReturnType<typeof setTimeout> | null = null;\n\nfunction clearTimers() {\n if (openTimer) {\n clearTimeout(openTimer);\n openTimer = null;\n }\n if (closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n}\n\nfunction scheduleOpen() {\n if (props.disabled || isControlled.value) return;\n if (closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n if (internalOpen.value) return;\n openTimer = setTimeout(() => {\n internalOpen.value = true;\n emit(\"update:open\", true);\n emit(\"show\");\n }, props.openDelay);\n}\nfunction scheduleClose() {\n if (isControlled.value) return;\n if (openTimer) {\n clearTimeout(openTimer);\n openTimer = null;\n }\n if (!internalOpen.value) return;\n closeTimer = setTimeout(() => {\n internalOpen.value = false;\n emit(\"update:open\", false);\n emit(\"hide\");\n }, props.closeDelay);\n}\n\n/* ---------- Trigger events ---------- */\n\nfunction onTriggerEnter() {\n if (hasHover.value) scheduleOpen();\n}\nfunction onTriggerLeave() {\n if (hasHover.value) scheduleClose();\n}\nfunction onTriggerFocus() {\n if (hasFocus.value) scheduleOpen();\n}\nfunction onTriggerBlur() {\n if (hasFocus.value) scheduleClose();\n}\nfunction onTriggerClick() {\n if (!hasClick.value) return;\n if (props.disabled || isControlled.value) return;\n if (internalOpen.value) {\n internalOpen.value = false;\n emit(\"update:open\", false);\n emit(\"hide\");\n } else {\n internalOpen.value = true;\n emit(\"update:open\", true);\n emit(\"show\");\n }\n}\nfunction onPanelEnter() {\n if (hasHover.value && closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n}\nfunction onPanelLeave() {\n if (hasHover.value) scheduleClose();\n}\n\n/* ---------- Positioning ---------- */\n\ninterface Pos {\n top: number;\n left: number;\n placement: TooltipPlacement;\n arrowCross?: number;\n}\nconst position = ref<Pos>({ top: 0, left: 0, placement: props.placement });\n\nfunction measure() {\n const panel = panelRef.value;\n if (!panel) return;\n\n // Anchor mode: position against a virtual point instead of the trigger box.\n const a = props.anchor;\n const tRect: DOMRect = a\n ? ({ top: a.y, bottom: a.y, left: a.x, right: a.x, width: 0, height: 0, x: a.x, y: a.y, toJSON() { return this; } } as DOMRect)\n : (triggerRef.value?.getBoundingClientRect() as DOMRect);\n if (!tRect) return;\n // Usar offsetWidth/Height (ignoran el transform de la transición scale).\n const panelW = panel.offsetWidth;\n const panelH = panel.offsetHeight;\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n const margin = 8;\n const off = props.offset;\n\n let placement = props.placement;\n const axis = placement.split(\"-\")[0] as \"top\" | \"bottom\" | \"left\" | \"right\";\n const side = (placement.split(\"-\")[1] ?? \"center\") as\n | \"start\"\n | \"end\"\n | \"center\";\n\n // Auto-flip vertical/horizontal if not enough room\n if (axis === \"top\" && tRect.top - panelH - off < margin) {\n placement = placement.replace(\"top\", \"bottom\") as TooltipPlacement;\n } else if (axis === \"bottom\" && tRect.bottom + panelH + off > vh - margin) {\n placement = placement.replace(\"bottom\", \"top\") as TooltipPlacement;\n } else if (axis === \"left\" && tRect.left - panelW - off < margin) {\n placement = placement.replace(\"left\", \"right\") as TooltipPlacement;\n } else if (axis === \"right\" && tRect.right + panelW + off > vw - margin) {\n placement = placement.replace(\"right\", \"left\") as TooltipPlacement;\n }\n\n const axis2 = placement.split(\"-\")[0] as \"top\" | \"bottom\" | \"left\" | \"right\";\n\n let top = 0;\n let left = 0;\n\n if (axis2 === \"top\" || axis2 === \"bottom\") {\n top = axis2 === \"top\" ? tRect.top - panelH - off : tRect.bottom + off;\n if (side === \"start\") left = tRect.left;\n else if (side === \"end\") left = tRect.right - panelW;\n else left = tRect.left + tRect.width / 2 - panelW / 2;\n } else {\n left = axis2 === \"left\" ? tRect.left - panelW - off : tRect.right + off;\n if (side === \"start\") top = tRect.top;\n else if (side === \"end\") top = tRect.bottom - panelH;\n else top = tRect.top + tRect.height / 2 - panelH / 2;\n }\n\n // Clamp al viewport\n if (left + panelW > vw - margin) left = vw - panelW - margin;\n if (left < margin) left = margin;\n if (top + panelH > vh - margin) top = vh - panelH - margin;\n if (top < margin) top = margin;\n\n // Arrow position (apuntando al centro del trigger, dentro del panel).\n let arrowCross: number | undefined;\n if (axis2 === \"top\" || axis2 === \"bottom\") {\n arrowCross = Math.min(\n Math.max(tRect.left + tRect.width / 2 - left, 10),\n panelW - 10,\n );\n } else {\n arrowCross = Math.min(\n Math.max(tRect.top + tRect.height / 2 - top, 10),\n panelH - 10,\n );\n }\n\n position.value = { top, left, placement, arrowCross };\n}\n\nconst panelStyle = computed(() => {\n const providerVars = cfg?.value.palettes\n ? {\n ...palettesToCssVars(cfg.value.palettes),\n ...semanticTokensFromPalettes(\n cfg.value.palettes,\n hexToOklchString,\n pickForegroundOklch,\n ),\n }\n : {};\n const surfaceVars = cfg?.value.surfaces\n ? surfacesToCssVars(cfg.value.surfaces)\n : {};\n const darkSurfaceVars =\n scopedTheme.value === \"dark\" && cfg?.value.darkSurfaces\n ? surfacesToCssVars(cfg.value.darkSurfaces)\n : {};\n return {\n ...providerVars,\n ...surfaceVars,\n ...darkSurfaceVars,\n top: `${position.value.top}px`,\n left: `${position.value.left}px`,\n maxWidth: `${props.maxWidth}px`,\n zIndex: \"1400\",\n transformOrigin: transformOriginFromPlacement(position.value.placement),\n };\n});\n\nfunction transformOriginFromPlacement(pl: TooltipPlacement): string {\n const axis = pl.split(\"-\")[0];\n const side = pl.split(\"-\")[1] ?? \"center\";\n switch (axis) {\n case \"top\":\n return side === \"start\"\n ? \"left bottom\"\n : side === \"end\"\n ? \"right bottom\"\n : \"center bottom\";\n case \"bottom\":\n return side === \"start\"\n ? \"left top\"\n : side === \"end\"\n ? \"right top\"\n : \"center top\";\n case \"left\":\n return side === \"start\"\n ? \"right top\"\n : side === \"end\"\n ? \"right bottom\"\n : \"right center\";\n case \"right\":\n return side === \"start\"\n ? \"left top\"\n : side === \"end\"\n ? \"left bottom\"\n : \"left center\";\n }\n return \"center center\";\n}\n\nconst arrowStyle = computed(() => {\n const { arrowCross, placement } = position.value;\n if (arrowCross === undefined) return {};\n const axis = placement.split(\"-\")[0];\n switch (axis) {\n case \"top\": // panel above trigger → arrow on panel bottom\n return { left: `${arrowCross}px`, bottom: \"-4px\" };\n case \"bottom\": // panel below trigger → arrow on panel top\n return { left: `${arrowCross}px`, top: \"-4px\" };\n case \"left\": // panel left of trigger → arrow on panel right\n return { top: `${arrowCross}px`, right: \"-4px\" };\n case \"right\": // panel right of trigger → arrow on panel left\n return { top: `${arrowCross}px`, left: \"-4px\" };\n }\n return {};\n});\n\nfunction onScrollOrResize() {\n if (isOpen.value) measure();\n}\n\n// Anchor mode: reposition as the virtual point moves (e.g. chart hover).\nwatch(\n () => props.anchor,\n () => { if (isOpen.value) measure(); },\n { deep: true },\n);\n\nlet resizeObserver: ResizeObserver | null = null;\n\nfunction onOutsideTouch(e: TouchEvent) {\n if (!internalOpen.value) return;\n const target = e.target as Node | null;\n if (triggerRef.value?.contains(target)) return;\n if (panelRef.value?.contains(target)) return;\n internalOpen.value = false;\n emit(\"update:open\", false);\n emit(\"hide\");\n}\n\nwatch(isOpen, (open) => {\n if (open) {\n requestAnimationFrame(() => {\n measure();\n requestAnimationFrame(measure);\n });\n window.addEventListener(\"scroll\", onScrollOrResize, true);\n window.addEventListener(\"resize\", onScrollOrResize);\n if (triggerRef.value && typeof ResizeObserver !== \"undefined\") {\n resizeObserver = new ResizeObserver(onScrollOrResize);\n resizeObserver.observe(triggerRef.value);\n if (panelRef.value) resizeObserver.observe(panelRef.value);\n }\n // On touch devices, hover never fires mouseleave — close on outside tap.\n if (hasHover.value) document.addEventListener(\"touchstart\", onOutsideTouch, { passive: true });\n } else {\n window.removeEventListener(\"scroll\", onScrollOrResize, true);\n window.removeEventListener(\"resize\", onScrollOrResize);\n resizeObserver?.disconnect();\n resizeObserver = null;\n document.removeEventListener(\"touchstart\", onOutsideTouch);\n }\n});\n\nonBeforeUnmount(() => {\n clearTimers();\n window.removeEventListener(\"scroll\", onScrollOrResize, true);\n window.removeEventListener(\"resize\", onScrollOrResize);\n resizeObserver?.disconnect();\n document.removeEventListener(\"touchstart\", onOutsideTouch);\n});\n\n/* ---------- Style maps ---------- */\n\nconst COLOR_CLASSES: Record<string, string> = {\n default: \"bg-foreground text-background\",\n inverted: \"bg-background text-foreground border border-border\",\n primary: \"bg-primary text-primary-foreground\",\n danger: \"bg-destructive text-destructive-foreground\",\n success: \"bg-success text-success-foreground\",\n warning: \"bg-warning text-warning-foreground\",\n};\nconst ARROW_COLOR_CLASSES: Record<string, string> = {\n default: \"bg-foreground\",\n // No `border` here — borders are applied only on the two outer-facing\n // sides via `arrowBorderClass`, to avoid rendering a full diamond outline.\n inverted: \"bg-background\",\n primary: \"bg-primary\",\n danger: \"bg-destructive\",\n success: \"bg-success\",\n warning: \"bg-warning\",\n};\n\nconst colorClasses = computed(() => {\n if (isInverted.value) return COLOR_CLASSES.inverted;\n return COLOR_CLASSES[resolvedColor.value] ?? COLOR_CLASSES.default;\n});\nconst arrowColorClass = computed(() => {\n if (isInverted.value) return ARROW_COLOR_CLASSES.inverted;\n return (\n ARROW_COLOR_CLASSES[resolvedColor.value] ?? ARROW_COLOR_CLASSES.default\n );\n});\n\n// The rotated square exposes only its two outer-facing sides past the panel\n// edge. We render borders on just those sides so the arrow tip reads as a\n// triangle instead of a diamond. Only applied to the `inverted` variant,\n// which is the only one that uses a visible border on the tooltip body.\nconst arrowBorderClass = computed(() => {\n if (!isInverted.value) return \"\";\n const axis = position.value.placement.split(\"-\")[0];\n switch (axis) {\n case \"top\":\n return \"border-r border-b border-border\";\n case \"bottom\":\n return \"border-t border-l border-border\";\n case \"left\":\n return \"border-t border-r border-border\";\n case \"right\":\n return \"border-b border-l border-border\";\n default:\n return \"\";\n }\n});\n\nconst sizeClasses = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"px-2 py-1 text-[11px]\";\n case \"large\":\n return \"px-3.5 py-2 text-body\";\n default:\n return \"px-2.5 py-1.5 text-caption\";\n }\n});\n\nconst radiusClasses = computed(() => {\n switch (resolvedRadius.value) {\n case \"none\":\n return \"rounded-none\";\n case \"small\":\n return \"rounded-sm\";\n case \"large\":\n return \"rounded-lg\";\n case \"full\":\n return \"rounded-full\";\n default:\n return \"rounded-md\";\n }\n});\n</script>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Tooltip.mjs","names":[],"sources":["../../../src/components/feedback/Tooltip.vue"],"sourcesContent":["<template>\n <span\n ref=\"triggerRef\"\n :class=\"['inline-flex', wrapperClass]\"\n :aria-describedby=\"isOpen ? tooltipId : undefined\"\n @mouseenter=\"onTriggerEnter\"\n @mouseleave=\"onTriggerLeave\"\n @focusin=\"onTriggerFocus\"\n @focusout=\"onTriggerBlur\"\n @click=\"onTriggerClick\"\n @touchmove.passive=\"onTouchScroll\"\n >\n <slot />\n </span>\n\n <Teleport to=\"body\">\n <Transition\n enter-active-class=\"transition duration-fast ease-standard\"\n enter-from-class=\"opacity-0 scale-95\"\n enter-to-class=\"opacity-100 scale-100\"\n leave-active-class=\"transition duration-fast ease-standard\"\n leave-from-class=\"opacity-100 scale-100\"\n leave-to-class=\"opacity-0 scale-95\"\n >\n <div\n v-if=\"isOpen && !disabled\"\n :id=\"tooltipId\"\n ref=\"panelRef\"\n role=\"tooltip\"\n :data-modo-theme=\"scopedTheme || undefined\"\n :class=\"[\n 'modo-tooltip fixed pointer-events-none select-none shadow-md',\n colorClasses,\n sizeClasses,\n radiusClasses,\n ]\"\n :style=\"panelStyle\"\n @mouseenter=\"onPanelEnter\"\n @mouseleave=\"onPanelLeave\"\n >\n <slot name=\"content\">{{ content }}</slot>\n\n <span\n v-if=\"arrow\"\n aria-hidden=\"true\"\n :class=\"[\n 'absolute w-2 h-2 rotate-45',\n arrowColorClass,\n arrowBorderClass,\n ]\"\n :style=\"arrowStyle\"\n />\n </div>\n </Transition>\n </Teleport>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, ref, useId, watch } from \"vue\";\nimport type {\n Tooltip,\n TooltipPlacement,\n TooltipTrigger,\n} from \"../../interfaces/feedback/Tooltip.interface\";\nimport {\n useResolvedColor,\n useResolvedRadius,\n useResolvedTheme,\n useModoConfig,\n useResolvedSize,\n} from \"../../composables/useModoConfig\";\nimport { resolveColorMode } from \"../../composables/useColorMode\";\nimport {\n palettesToCssVars,\n semanticTokensFromPalettes,\n} from \"../../config/palettes\";\nimport {\n hexToOklchString,\n pickForegroundOklch,\n} from \"../../config/colorPrimitives\";\nimport { surfacesToCssVars } from \"../../config/surfaces\";\nimport {\n TOOLTIP_ARROW_SIZE,\n tooltipArrowCross,\n tooltipArrowInset,\n} from \"../../utils/tooltipArrow\";\nimport type { ModoColor, ModoRadius } from \"../../config/ModoConfig\";\n\nconst props = withDefaults(defineProps<Tooltip>(), {\n placement: \"top\",\n offset: 8,\n trigger: () => [\"hover\", \"focus\"] as TooltipTrigger[],\n openDelay: 200,\n closeDelay: 100,\n arrow: true,\n color: \"default\",\n disabled: false,\n open: undefined,\n maxWidth: 260,\n});\n\nconst resolvedSize = useResolvedSize(() => props.size);\n\nconst emit = defineEmits<{\n \"update:open\": [open: boolean];\n show: [];\n hide: [];\n}>();\n\n// Resolver color y radius desde ModoProvider (cascade).\n// 'inverted' es especial del Tooltip y no forma parte de ModoColor.\nconst isInverted = computed(() => props.color === \"inverted\");\nconst resolvedColor = useResolvedColor(() =>\n isInverted.value ? undefined : (props.color as ModoColor | undefined),\n);\nconst resolvedRadius = useResolvedRadius(\n () => props.radius as ModoRadius | undefined,\n);\n\n// Forward provider palette + theme to teleported panel.\nconst cfg = useModoConfig();\nconst theme = useResolvedTheme();\nconst scopedTheme = computed(() => resolveColorMode(theme.value));\n\nconst autoId = useId();\nconst tooltipId = computed(() => props.id ?? `modo-tooltip-${autoId}`);\n\nconst triggerRef = ref<HTMLElement | null>(null);\nconst panelRef = ref<HTMLElement | null>(null);\n\nconst internalOpen = ref(false);\nconst isControlled = computed(() => props.open !== undefined);\nconst isOpen = computed(() =>\n isControlled.value ? !!props.open : internalOpen.value,\n);\n\nconst triggers = computed<TooltipTrigger[]>(() =>\n Array.isArray(props.trigger) ? props.trigger : [props.trigger],\n);\nconst hasHover = computed(() => triggers.value.includes(\"hover\"));\nconst hasFocus = computed(() => triggers.value.includes(\"focus\"));\nconst hasClick = computed(() => triggers.value.includes(\"click\"));\n\n/* ---------- open/close with delays ---------- */\n\nlet openTimer: ReturnType<typeof setTimeout> | null = null;\nlet closeTimer: ReturnType<typeof setTimeout> | null = null;\n\nfunction clearTimers() {\n if (openTimer) {\n clearTimeout(openTimer);\n openTimer = null;\n }\n if (closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n}\n\nfunction scheduleOpen() {\n if (props.disabled || isControlled.value) return;\n if (closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n if (internalOpen.value) return;\n openTimer = setTimeout(() => {\n internalOpen.value = true;\n emit(\"update:open\", true);\n emit(\"show\");\n }, props.openDelay);\n}\nfunction scheduleClose() {\n if (isControlled.value) return;\n if (openTimer) {\n clearTimeout(openTimer);\n openTimer = null;\n }\n if (!internalOpen.value) return;\n closeTimer = setTimeout(() => {\n internalOpen.value = false;\n emit(\"update:open\", false);\n emit(\"hide\");\n }, props.closeDelay);\n}\n\n/* ---------- Trigger events ---------- */\n\nfunction onTriggerEnter() {\n if (hasHover.value) scheduleOpen();\n}\nfunction onTriggerLeave() {\n if (hasHover.value) scheduleClose();\n}\nfunction onTriggerFocus() {\n if (hasFocus.value) scheduleOpen();\n}\nfunction onTriggerBlur() {\n if (hasFocus.value) scheduleClose();\n}\nfunction onTriggerClick() {\n if (!hasClick.value) return;\n if (props.disabled || isControlled.value) return;\n if (internalOpen.value) {\n internalOpen.value = false;\n emit(\"update:open\", false);\n emit(\"hide\");\n } else {\n internalOpen.value = true;\n emit(\"update:open\", true);\n emit(\"show\");\n }\n}\nfunction onPanelEnter() {\n if (hasHover.value && closeTimer) {\n clearTimeout(closeTimer);\n closeTimer = null;\n }\n}\nfunction onPanelLeave() {\n if (hasHover.value) scheduleClose();\n}\n\n/* ---------- Positioning ---------- */\n\ninterface Pos {\n top: number;\n left: number;\n placement: TooltipPlacement;\n arrowCross?: number;\n}\nconst position = ref<Pos>({ top: 0, left: 0, placement: props.placement });\n\nfunction measure() {\n const panel = panelRef.value;\n if (!panel) return;\n\n // Anchor mode: position against a virtual point instead of the trigger box.\n const a = props.anchor;\n const tRect: DOMRect = a\n ? ({ top: a.y, bottom: a.y, left: a.x, right: a.x, width: 0, height: 0, x: a.x, y: a.y, toJSON() { return this; } } as DOMRect)\n : (triggerRef.value?.getBoundingClientRect() as DOMRect);\n if (!tRect) return;\n // Usar offsetWidth/Height (ignoran el transform de la transición scale).\n const panelW = panel.offsetWidth;\n const panelH = panel.offsetHeight;\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n const margin = 8;\n const off = props.offset;\n\n let placement = props.placement;\n const axis = placement.split(\"-\")[0] as \"top\" | \"bottom\" | \"left\" | \"right\";\n const side = (placement.split(\"-\")[1] ?? \"center\") as\n | \"start\"\n | \"end\"\n | \"center\";\n\n // Auto-flip vertical/horizontal if not enough room\n if (axis === \"top\" && tRect.top - panelH - off < margin) {\n placement = placement.replace(\"top\", \"bottom\") as TooltipPlacement;\n } else if (axis === \"bottom\" && tRect.bottom + panelH + off > vh - margin) {\n placement = placement.replace(\"bottom\", \"top\") as TooltipPlacement;\n } else if (axis === \"left\" && tRect.left - panelW - off < margin) {\n placement = placement.replace(\"left\", \"right\") as TooltipPlacement;\n } else if (axis === \"right\" && tRect.right + panelW + off > vw - margin) {\n placement = placement.replace(\"right\", \"left\") as TooltipPlacement;\n }\n\n const axis2 = placement.split(\"-\")[0] as \"top\" | \"bottom\" | \"left\" | \"right\";\n\n let top = 0;\n let left = 0;\n\n if (axis2 === \"top\" || axis2 === \"bottom\") {\n top = axis2 === \"top\" ? tRect.top - panelH - off : tRect.bottom + off;\n if (side === \"start\") left = tRect.left;\n else if (side === \"end\") left = tRect.right - panelW;\n else left = tRect.left + tRect.width / 2 - panelW / 2;\n } else {\n left = axis2 === \"left\" ? tRect.left - panelW - off : tRect.right + off;\n if (side === \"start\") top = tRect.top;\n else if (side === \"end\") top = tRect.bottom - panelH;\n else top = tRect.top + tRect.height / 2 - panelH / 2;\n }\n\n // Clamp al viewport\n if (left + panelW > vw - margin) left = vw - panelW - margin;\n if (left < margin) left = margin;\n if (top + panelH > vh - margin) top = vh - panelH - margin;\n if (top < margin) top = margin;\n\n // Arrow centre (apuntando al centro del trigger, dentro del panel).\n const isVerticalAxis = axis2 === \"top\" || axis2 === \"bottom\";\n const edgeSize = isVerticalAxis ? panelW : panelH;\n const arrowCross = tooltipArrowCross(\n isVerticalAxis\n ? tRect.left + tRect.width / 2 - left\n : tRect.top + tRect.height / 2 - top,\n edgeSize,\n tooltipArrowInset(resolvedRadius.value, edgeSize),\n );\n\n position.value = { top, left, placement, arrowCross };\n}\n\nconst panelStyle = computed(() => {\n const providerVars = cfg?.value.palettes\n ? {\n ...palettesToCssVars(cfg.value.palettes),\n ...semanticTokensFromPalettes(\n cfg.value.palettes,\n hexToOklchString,\n pickForegroundOklch,\n ),\n }\n : {};\n const surfaceVars = cfg?.value.surfaces\n ? surfacesToCssVars(cfg.value.surfaces)\n : {};\n const darkSurfaceVars =\n scopedTheme.value === \"dark\" && cfg?.value.darkSurfaces\n ? surfacesToCssVars(cfg.value.darkSurfaces)\n : {};\n return {\n ...providerVars,\n ...surfaceVars,\n ...darkSurfaceVars,\n top: `${position.value.top}px`,\n left: `${position.value.left}px`,\n maxWidth: `${props.maxWidth}px`,\n zIndex: \"1400\",\n transformOrigin: transformOriginFromPlacement(position.value.placement),\n };\n});\n\nfunction transformOriginFromPlacement(pl: TooltipPlacement): string {\n const axis = pl.split(\"-\")[0];\n const side = pl.split(\"-\")[1] ?? \"center\";\n switch (axis) {\n case \"top\":\n return side === \"start\"\n ? \"left bottom\"\n : side === \"end\"\n ? \"right bottom\"\n : \"center bottom\";\n case \"bottom\":\n return side === \"start\"\n ? \"left top\"\n : side === \"end\"\n ? \"right top\"\n : \"center top\";\n case \"left\":\n return side === \"start\"\n ? \"right top\"\n : side === \"end\"\n ? \"right bottom\"\n : \"right center\";\n case \"right\":\n return side === \"start\"\n ? \"left top\"\n : side === \"end\"\n ? \"left bottom\"\n : \"left center\";\n }\n return \"center center\";\n}\n\nconst arrowStyle = computed(() => {\n const { arrowCross, placement } = position.value;\n if (arrowCross === undefined) return {};\n const axis = placement.split(\"-\")[0];\n // `arrowCross` is where the arrow's centre goes; `left`/`top` place its\n // leading edge, hence the half-size shift.\n const cross = `${arrowCross - TOOLTIP_ARROW_SIZE / 2}px`;\n const out = `-${TOOLTIP_ARROW_SIZE / 2}px`;\n switch (axis) {\n case \"top\": // panel above trigger → arrow on panel bottom\n return { left: cross, bottom: out };\n case \"bottom\": // panel below trigger → arrow on panel top\n return { left: cross, top: out };\n case \"left\": // panel left of trigger → arrow on panel right\n return { top: cross, right: out };\n case \"right\": // panel right of trigger → arrow on panel left\n return { top: cross, left: out };\n }\n return {};\n});\n\nfunction onScrollOrResize() {\n if (isOpen.value) measure();\n}\n\n// Anchor mode: reposition as the virtual point moves (e.g. chart hover).\nwatch(\n () => props.anchor,\n () => { if (isOpen.value) measure(); },\n { deep: true },\n);\n\nlet resizeObserver: ResizeObserver | null = null;\n\nfunction dismiss() {\n if (!internalOpen.value) return;\n internalOpen.value = false;\n emit(\"update:open\", false);\n emit(\"hide\");\n}\n\nfunction onOutsideTouch(e: Event) {\n if (!internalOpen.value) return;\n const target = e.target as Node | null;\n if (triggerRef.value?.contains(target)) return;\n if (panelRef.value?.contains(target)) return;\n dismiss();\n}\n\n/**\n * A touch drag is the page being scrolled. On a pointer device the tooltip\n * follows the trigger because the cursor stays put and `mouseleave` ends it;\n * on touch there is no cursor and no `mouseleave`, so repositioning on scroll\n * left the tooltip riding the screen indefinitely. Cancel a pending open too:\n * a tap that turns into a drag must not pop a tooltip mid-scroll.\n *\n * Gestures that start on the trigger never reach the document listener — touch\n * events stay targeted at the element the finger landed on — which is why the\n * trigger binds this as well.\n */\nfunction onTouchScroll() {\n clearTimers();\n dismiss();\n}\n\nwatch(isOpen, (open) => {\n if (open) {\n requestAnimationFrame(() => {\n measure();\n requestAnimationFrame(measure);\n });\n window.addEventListener(\"scroll\", onScrollOrResize, true);\n window.addEventListener(\"resize\", onScrollOrResize);\n if (triggerRef.value && typeof ResizeObserver !== \"undefined\") {\n resizeObserver = new ResizeObserver(onScrollOrResize);\n resizeObserver.observe(triggerRef.value);\n if (panelRef.value) resizeObserver.observe(panelRef.value);\n }\n // On touch devices there is no cursor to move away: nothing dismisses the\n // tooltip on its own, whichever trigger opened it. An outside tap ends it,\n // and so does scrolling the page.\n document.addEventListener(\"touchstart\", onOutsideTouch, { passive: true });\n document.addEventListener(\"touchmove\", onTouchScroll, { passive: true });\n } else {\n window.removeEventListener(\"scroll\", onScrollOrResize, true);\n window.removeEventListener(\"resize\", onScrollOrResize);\n resizeObserver?.disconnect();\n resizeObserver = null;\n document.removeEventListener(\"touchstart\", onOutsideTouch);\n document.removeEventListener(\"touchmove\", onTouchScroll);\n }\n});\n\nonBeforeUnmount(() => {\n clearTimers();\n window.removeEventListener(\"scroll\", onScrollOrResize, true);\n window.removeEventListener(\"resize\", onScrollOrResize);\n resizeObserver?.disconnect();\n document.removeEventListener(\"touchstart\", onOutsideTouch);\n document.removeEventListener(\"touchmove\", onTouchScroll);\n});\n\n/* ---------- Style maps ---------- */\n\nconst COLOR_CLASSES: Record<string, string> = {\n default: \"bg-foreground text-background\",\n inverted: \"bg-background text-foreground border border-border\",\n primary: \"bg-primary text-primary-foreground\",\n danger: \"bg-destructive text-destructive-foreground\",\n success: \"bg-success text-success-foreground\",\n warning: \"bg-warning text-warning-foreground\",\n};\nconst ARROW_COLOR_CLASSES: Record<string, string> = {\n default: \"bg-foreground\",\n // No `border` here — borders are applied only on the two outer-facing\n // sides via `arrowBorderClass`, to avoid rendering a full diamond outline.\n inverted: \"bg-background\",\n primary: \"bg-primary\",\n danger: \"bg-destructive\",\n success: \"bg-success\",\n warning: \"bg-warning\",\n};\n\nconst colorClasses = computed(() => {\n if (isInverted.value) return COLOR_CLASSES.inverted;\n return COLOR_CLASSES[resolvedColor.value] ?? COLOR_CLASSES.default;\n});\nconst arrowColorClass = computed(() => {\n if (isInverted.value) return ARROW_COLOR_CLASSES.inverted;\n return (\n ARROW_COLOR_CLASSES[resolvedColor.value] ?? ARROW_COLOR_CLASSES.default\n );\n});\n\n// The rotated square exposes only its two outer-facing sides past the panel\n// edge. We render borders on just those sides so the arrow tip reads as a\n// triangle instead of a diamond. Only applied to the `inverted` variant,\n// which is the only one that uses a visible border on the tooltip body.\nconst arrowBorderClass = computed(() => {\n if (!isInverted.value) return \"\";\n const axis = position.value.placement.split(\"-\")[0];\n switch (axis) {\n case \"top\":\n return \"border-r border-b border-border\";\n case \"bottom\":\n return \"border-t border-l border-border\";\n case \"left\":\n return \"border-t border-r border-border\";\n case \"right\":\n return \"border-b border-l border-border\";\n default:\n return \"\";\n }\n});\n\nconst sizeClasses = computed(() => {\n switch (resolvedSize.value) {\n case \"small\":\n return \"px-2 py-1 text-[11px]\";\n case \"large\":\n return \"px-3.5 py-2 text-body\";\n default:\n return \"px-2.5 py-1.5 text-caption\";\n }\n});\n\nconst radiusClasses = computed(() => {\n switch (resolvedRadius.value) {\n case \"none\":\n return \"rounded-none\";\n case \"small\":\n return \"rounded-sm\";\n case \"large\":\n return \"rounded-lg\";\n case \"full\":\n return \"rounded-full\";\n default:\n return \"rounded-md\";\n }\n});\n</script>\n"],"mappings":""}
|
|
@@ -4,6 +4,7 @@ const require_surfaces = require("../../config/surfaces.cjs");
|
|
|
4
4
|
const require_colorPrimitives = require("../../config/colorPrimitives.cjs");
|
|
5
5
|
const require_useColorMode = require("../../composables/useColorMode.cjs");
|
|
6
6
|
const require_useModoConfig = require("../../composables/useModoConfig.cjs");
|
|
7
|
+
const require_tooltipArrow = require("../../utils/tooltipArrow.cjs");
|
|
7
8
|
let vue = require("vue");
|
|
8
9
|
//#region src/components/feedback/Tooltip.vue?vue&type=script&setup=true&lang.ts
|
|
9
10
|
var _hoisted_1 = ["aria-describedby"];
|
|
@@ -189,9 +190,9 @@ var Tooltip_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vu
|
|
|
189
190
|
if (left < margin) left = margin;
|
|
190
191
|
if (top + panelH > vh - margin) top = vh - panelH - margin;
|
|
191
192
|
if (top < margin) top = margin;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
const isVerticalAxis = axis2 === "top" || axis2 === "bottom";
|
|
194
|
+
const edgeSize = isVerticalAxis ? panelW : panelH;
|
|
195
|
+
const arrowCross = require_tooltipArrow.tooltipArrowCross(isVerticalAxis ? tRect.left + tRect.width / 2 - left : tRect.top + tRect.height / 2 - top, edgeSize, require_tooltipArrow.tooltipArrowInset(resolvedRadius.value, edgeSize));
|
|
195
196
|
position.value = {
|
|
196
197
|
top,
|
|
197
198
|
left,
|
|
@@ -231,22 +232,25 @@ var Tooltip_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vu
|
|
|
231
232
|
const arrowStyle = (0, vue.computed)(() => {
|
|
232
233
|
const { arrowCross, placement } = position.value;
|
|
233
234
|
if (arrowCross === void 0) return {};
|
|
234
|
-
|
|
235
|
+
const axis = placement.split("-")[0];
|
|
236
|
+
const cross = `${arrowCross - 8 / 2}px`;
|
|
237
|
+
const out = `-${8 / 2}px`;
|
|
238
|
+
switch (axis) {
|
|
235
239
|
case "top": return {
|
|
236
|
-
left:
|
|
237
|
-
bottom:
|
|
240
|
+
left: cross,
|
|
241
|
+
bottom: out
|
|
238
242
|
};
|
|
239
243
|
case "bottom": return {
|
|
240
|
-
left:
|
|
241
|
-
top:
|
|
244
|
+
left: cross,
|
|
245
|
+
top: out
|
|
242
246
|
};
|
|
243
247
|
case "left": return {
|
|
244
|
-
top:
|
|
245
|
-
right:
|
|
248
|
+
top: cross,
|
|
249
|
+
right: out
|
|
246
250
|
};
|
|
247
251
|
case "right": return {
|
|
248
|
-
top:
|
|
249
|
-
left:
|
|
252
|
+
top: cross,
|
|
253
|
+
left: out
|
|
250
254
|
};
|
|
251
255
|
}
|
|
252
256
|
return {};
|
|
@@ -258,14 +262,33 @@ var Tooltip_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vu
|
|
|
258
262
|
if (isOpen.value) measure();
|
|
259
263
|
}, { deep: true });
|
|
260
264
|
let resizeObserver = null;
|
|
265
|
+
function dismiss() {
|
|
266
|
+
if (!internalOpen.value) return;
|
|
267
|
+
internalOpen.value = false;
|
|
268
|
+
emit("update:open", false);
|
|
269
|
+
emit("hide");
|
|
270
|
+
}
|
|
261
271
|
function onOutsideTouch(e) {
|
|
262
272
|
if (!internalOpen.value) return;
|
|
263
273
|
const target = e.target;
|
|
264
274
|
if (triggerRef.value?.contains(target)) return;
|
|
265
275
|
if (panelRef.value?.contains(target)) return;
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
276
|
+
dismiss();
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* A touch drag is the page being scrolled. On a pointer device the tooltip
|
|
280
|
+
* follows the trigger because the cursor stays put and `mouseleave` ends it;
|
|
281
|
+
* on touch there is no cursor and no `mouseleave`, so repositioning on scroll
|
|
282
|
+
* left the tooltip riding the screen indefinitely. Cancel a pending open too:
|
|
283
|
+
* a tap that turns into a drag must not pop a tooltip mid-scroll.
|
|
284
|
+
*
|
|
285
|
+
* Gestures that start on the trigger never reach the document listener — touch
|
|
286
|
+
* events stay targeted at the element the finger landed on — which is why the
|
|
287
|
+
* trigger binds this as well.
|
|
288
|
+
*/
|
|
289
|
+
function onTouchScroll() {
|
|
290
|
+
clearTimers();
|
|
291
|
+
dismiss();
|
|
269
292
|
}
|
|
270
293
|
(0, vue.watch)(isOpen, (open) => {
|
|
271
294
|
if (open) {
|
|
@@ -280,13 +303,15 @@ var Tooltip_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vu
|
|
|
280
303
|
resizeObserver.observe(triggerRef.value);
|
|
281
304
|
if (panelRef.value) resizeObserver.observe(panelRef.value);
|
|
282
305
|
}
|
|
283
|
-
|
|
306
|
+
document.addEventListener("touchstart", onOutsideTouch, { passive: true });
|
|
307
|
+
document.addEventListener("touchmove", onTouchScroll, { passive: true });
|
|
284
308
|
} else {
|
|
285
309
|
window.removeEventListener("scroll", onScrollOrResize, true);
|
|
286
310
|
window.removeEventListener("resize", onScrollOrResize);
|
|
287
311
|
resizeObserver?.disconnect();
|
|
288
312
|
resizeObserver = null;
|
|
289
313
|
document.removeEventListener("touchstart", onOutsideTouch);
|
|
314
|
+
document.removeEventListener("touchmove", onTouchScroll);
|
|
290
315
|
}
|
|
291
316
|
});
|
|
292
317
|
(0, vue.onBeforeUnmount)(() => {
|
|
@@ -295,6 +320,7 @@ var Tooltip_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vu
|
|
|
295
320
|
window.removeEventListener("resize", onScrollOrResize);
|
|
296
321
|
resizeObserver?.disconnect();
|
|
297
322
|
document.removeEventListener("touchstart", onOutsideTouch);
|
|
323
|
+
document.removeEventListener("touchmove", onTouchScroll);
|
|
298
324
|
});
|
|
299
325
|
const COLOR_CLASSES = {
|
|
300
326
|
default: "bg-foreground text-background",
|
|
@@ -356,7 +382,8 @@ var Tooltip_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vu
|
|
|
356
382
|
onMouseleave: onTriggerLeave,
|
|
357
383
|
onFocusin: onTriggerFocus,
|
|
358
384
|
onFocusout: onTriggerBlur,
|
|
359
|
-
onClick: onTriggerClick
|
|
385
|
+
onClick: onTriggerClick,
|
|
386
|
+
onTouchmovePassive: onTouchScroll
|
|
360
387
|
}, [(0, vue.renderSlot)(_ctx.$slots, "default")], 42, _hoisted_1), ((0, vue.openBlock)(), (0, vue.createBlock)(vue.Teleport, { to: "body" }, [(0, vue.createVNode)(vue.Transition, {
|
|
361
388
|
"enter-active-class": "transition duration-fast ease-standard",
|
|
362
389
|
"enter-from-class": "opacity-0 scale-95",
|