mood-ui 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/data-display/calendar/AgendaView.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 +4 -1
- 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 +4 -1
- package/dist/components/data-display/calendar/AgendaView.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 +7 -4
- 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 +7 -4
- 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 +8 -12
- 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 +8 -12
- 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 +7 -4
- 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 +7 -4
- 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 +7 -4
- 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 +7 -4
- 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/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 +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.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 +4 -9
- 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 +4 -9
- 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/cssLength.d.ts +5 -0
- package/dist/types/utils/tooltipArrow.d.ts +34 -0
- package/dist/utils/cssLength.cjs +13 -0
- package/dist/utils/cssLength.cjs.map +1 -0
- package/dist/utils/cssLength.mjs +13 -0
- package/dist/utils/cssLength.mjs.map +1 -0
- package/dist/utils/tooltipArrow.cjs +37 -0
- package/dist/utils/tooltipArrow.cjs.map +1 -0
- package/dist/utils/tooltipArrow.mjs +36 -0
- package/dist/utils/tooltipArrow.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimePicker.mjs","names":[],"sources":["../../../../src/components/data-display/date-picker/DateTimePicker.vue"],"sourcesContent":["<template>\n <div\n :class=\"[\n 'relative inline-flex flex-col items-stretch bg-card w-fit self-start',\n !timeOnly ? 'sm:flex-row max-w-65 sm:max-w-none' : '',\n variant === 'outline' ? 'border border-border' : '',\n containerRadiusClass,\n ]\"\n >\n <Calendar\n v-if=\"!timeOnly\"\n v-model=\"dateOnly\"\n :locale=\"locale\"\n :first-day-of-week=\"firstDayOfWeek\"\n :min-date=\"minDate\"\n :max-date=\"maxDate\"\n :disabled-dates=\"disabledDates\"\n :color=\"color\"\n variant=\"filled\"\n :radius=\"radius\"\n />\n\n <div :class=\"['relative shrink-0', timePanelWidthClass]\">\n <div\n :class=\"[\n 'flex flex-col h-52',\n !timeOnly ? 'border-t border-border sm:border-t-0 sm:border-l sm:absolute sm:inset-0 sm:h-auto' : '',\n ]\"\n >\n <div class=\"px-3 py-3 border-b border-border text-center shrink-0\">\n <span class=\"text-sm font-semibold text-foreground\">{{\n timeLabel\n }}</span>\n </div>\n\n <div class=\"flex flex-1 min-h-0 overflow-hidden\">\n <div\n v-for=\"col in columns\"\n :key=\"col.key\"\n class=\"flex flex-col flex-1 border-r last:border-r-0 border-border\"\n >\n <div\n class=\"px-2 py-1.5 text-center text-xs font-medium text-muted-foreground border-b border-border\"\n >\n {{ col.label }}\n </div>\n <div\n :ref=\"\n (el: unknown) => setScrollRef(col.key, el as HTMLElement | null)\n \"\n class=\"flex-1 overflow-y-auto scroll-smooth\"\n style=\"scrollbar-width: thin\"\n >\n <div class=\"py-14\">\n <button\n v-for=\"item in col.items\"\n :key=\"item.value\"\n type=\"button\"\n :disabled=\"item.disabled\"\n :data-col=\"col.key\"\n :data-value=\"item.value\"\n @click=\"selectTimeItem(col.key, item.value)\"\n :class=\"[\n 'w-full px-2 py-1.5 text-sm text-center transition-colors cursor-pointer focus:outline-none',\n item.disabled\n ? 'text-muted-foreground/60 cursor-not-allowed'\n : item.value === col.selected\n ? selectedItemClasses\n : 'text-foreground/80 hover:bg-muted',\n ]\"\n >\n {{ item.label }}\n </button>\n </div>\n </div>\n </div>\n </div>\n\n <div\n class=\"px-3 py-2 border-t border-border flex justify-end gap-2 shrink-0\"\n >\n <Button\n variant=\"text\"\n size=\"xs\"\n radius=\"medium\"\n label=\"Now\"\n :class=\"todayTextClass\"\n @click=\"handleNow\"\n />\n </div>\n </div>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, computed, watch, nextTick, onMounted } from \"vue\";\nimport gsap from \"gsap\";\nimport Calendar from \"../calendar/Calendar.vue\";\nimport Button from \"../../forms/Button.vue\";\nimport {\n useResolvedColor,\n useResolvedRadius,\n} from \"../../../composables/useModoConfig\";\nimport type { DateTimePicker } from \"../../../interfaces/data-display/date-picker/DateTimePicker.interface\";\n\nconst props = withDefaults(defineProps<DateTimePicker>(), {\n modelValue: null,\n locale: \"default\",\n firstDayOfWeek: 0,\n color: \"default\",\n variant: \"outline\",\n format: \"24h\",\n step: 5,\n showSeconds: false,\n timeOnly: false,\n});\n\nconst resolvedColor = useResolvedColor(() => props.color);\nconst resolvedRadius = useResolvedRadius(() => props.radius);\n\nconst emit = defineEmits<{\n \"update:modelValue\": [date: Date];\n}>();\n\ntype ColKey = \"hour\" | \"minute\" | \"second\" | \"period\";\n\nconst scrollRefs = ref<Record<ColKey, HTMLElement | null>>({\n hour: null,\n minute: null,\n second: null,\n period: null,\n});\nconst setScrollRef = (key: ColKey, el: HTMLElement | null) => {\n scrollRefs.value[key] = el;\n};\n\nconst initialDate = props.modelValue ?? new Date();\n\nconst dateOnly = ref<Date>(new Date(initialDate));\nconst hour = ref(initialDate.getHours());\nconst minute = ref(\n Math.round(initialDate.getMinutes() / props.step) * props.step,\n);\nconst second = ref(initialDate.getSeconds());\n\nconst parseTimeStr = (t?: string): number | null => {\n if (!t) return null;\n const [h, m, s] = t.split(\":\").map(Number);\n return h * 3600 + (m || 0) * 60 + (s || 0);\n};\nconst minTimeSec = computed(() => parseTimeStr(props.minTime));\nconst maxTimeSec = computed(() => parseTimeStr(props.maxTime));\n\nconst pad2 = (n: number) => n.toString().padStart(2, \"0\");\n\nconst is12h = computed(() => props.format === \"12h\");\n\nconst hourValues = computed(() => {\n if (is12h.value) {\n return Array.from({ length: 12 }, (_, i) => (i === 0 ? 12 : i));\n }\n return Array.from({ length: 24 }, (_, i) => i);\n});\n\nconst minuteValues = computed(() => {\n const values: number[] = [];\n for (let i = 0; i < 60; i += props.step) values.push(i);\n return values;\n});\n\nconst secondValues = computed(() => {\n const values: number[] = [];\n for (let i = 0; i < 60; i += props.step) values.push(i);\n return values;\n});\n\nconst currentPeriod = computed<\"AM\" | \"PM\">(() =>\n hour.value < 12 ? \"AM\" : \"PM\",\n);\n\nconst hourDisplay = computed(() => {\n if (!is12h.value) return hour.value;\n const h = hour.value % 12;\n return h === 0 ? 12 : h;\n});\n\nconst isTimeDisabled = (h: number, m: number, s: number): boolean => {\n const total = h * 3600 + m * 60 + s;\n if (minTimeSec.value !== null && total < minTimeSec.value) return true;\n if (maxTimeSec.value !== null && total > maxTimeSec.value) return true;\n return false;\n};\n\ninterface TimeItem {\n value: number;\n label: string;\n disabled: boolean;\n}\n\ninterface TimeColumn {\n key: ColKey;\n label: string;\n items: TimeItem[];\n selected: number;\n}\n\nconst columns = computed<TimeColumn[]>(() => {\n const cols: TimeColumn[] = [];\n\n cols.push({\n key: \"hour\",\n label: \"Hour\",\n selected: hourDisplay.value,\n items: hourValues.value.map((v) => {\n const h24 = is12h.value\n ? currentPeriod.value === \"AM\"\n ? v === 12\n ? 0\n : v\n : v === 12\n ? 12\n : v + 12\n : v;\n return {\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(h24, minute.value, second.value),\n };\n }),\n });\n\n cols.push({\n key: \"minute\",\n label: \"Min\",\n selected: minute.value,\n items: minuteValues.value.map((v) => ({\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(hour.value, v, second.value),\n })),\n });\n\n if (props.showSeconds) {\n cols.push({\n key: \"second\",\n label: \"Sec\",\n selected: second.value,\n items: secondValues.value.map((v) => ({\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(hour.value, minute.value, v),\n })),\n });\n }\n\n if (is12h.value) {\n cols.push({\n key: \"period\",\n label: \"AM/PM\",\n selected: currentPeriod.value === \"AM\" ? 0 : 1,\n items: [\n { value: 0, label: \"AM\", disabled: false },\n { value: 1, label: \"PM\", disabled: false },\n ],\n });\n }\n\n return cols;\n});\n\nconst timeLabel = computed(() => {\n const h = is12h.value ? hourDisplay.value : hour.value;\n let s = `${pad2(h)}:${pad2(minute.value)}`;\n if (props.showSeconds) s += `:${pad2(second.value)}`;\n if (is12h.value) s += ` ${currentPeriod.value}`;\n return s;\n});\n\nconst commitDate = () => {\n const d = new Date(dateOnly.value);\n d.setHours(hour.value, minute.value, props.showSeconds ? second.value : 0, 0);\n if (props.modelValue && d.getTime() === props.modelValue.getTime()) return;\n emit(\"update:modelValue\", d);\n};\n\nconst selectTimeItem = (col: ColKey, value: number) => {\n if (col === \"hour\") {\n if (is12h.value) {\n const base = value === 12 ? 0 : value;\n hour.value = currentPeriod.value === \"AM\" ? base : base + 12;\n } else {\n hour.value = value;\n }\n } else if (col === \"minute\") {\n minute.value = value;\n } else if (col === \"second\") {\n second.value = value;\n } else if (col === \"period\") {\n const targetAM = value === 0;\n if (targetAM && hour.value >= 12) hour.value -= 12;\n else if (!targetAM && hour.value < 12) hour.value += 12;\n }\n commitDate();\n scrollColumnToSelected(col);\n};\n\nconst scrollColumnToSelected = (col: ColKey, animate = true) => {\n nextTick(() => {\n const container = scrollRefs.value[col];\n if (!container) return;\n const colInfo = columns.value.find((c) => c.key === col);\n if (!colInfo) return;\n const targetBtn = container.querySelector<HTMLElement>(\n `button[data-col=\"${col}\"][data-value=\"${colInfo.selected}\"]`,\n );\n if (!targetBtn) return;\n const apply = () => {\n const targetTop =\n targetBtn.offsetTop -\n container.clientHeight / 2 +\n targetBtn.clientHeight / 2;\n if (animate) {\n gsap.to(container, {\n scrollTop: targetTop,\n duration: 0.3,\n ease: \"power2.out\",\n });\n } else {\n container.scrollTop = targetTop;\n }\n };\n // Defer hasta un segundo frame para que el layout esté asentado\n // (especialmente en mount, cuando el Calendar todavía no determinó altura final).\n requestAnimationFrame(() => requestAnimationFrame(apply));\n });\n};\n\nwatch(dateOnly, () => commitDate());\n\nwatch(\n () => props.modelValue,\n (v) => {\n if (!v) return;\n dateOnly.value = new Date(v);\n hour.value = v.getHours();\n minute.value = v.getMinutes();\n second.value = v.getSeconds();\n columns.value.forEach((c) => scrollColumnToSelected(c.key));\n },\n);\n\nonMounted(() => {\n if (!props.modelValue) commitDate();\n nextTick(() => {\n columns.value.forEach((c) => scrollColumnToSelected(c.key, false));\n });\n});\n\nconst handleNow = () => {\n const now = new Date();\n dateOnly.value = new Date(now);\n hour.value = now.getHours();\n minute.value = Math.round(now.getMinutes() / props.step) * props.step;\n second.value = now.getSeconds();\n commitDate();\n columns.value.forEach((c) => scrollColumnToSelected(c.key));\n};\n\nconst timePanelWidthClass = computed(() => {\n const n = columns.value.length;\n // Mobile: stretches to full calendar width. sm+: fixed width per column count.\n if (n <= 2) return \"sm:w-32\"; // 128px\n if (n === 3) return \"sm:w-48\"; // 192px sm+\n return \"sm:w-64\"; // 256px sm+\n});\n\nconst selectedItemClasses = computed(\n () =>\n ({\n default: \"bg-foreground text-background font-semibold\",\n primary: \"bg-primary text-primary-foreground font-semibold\",\n danger: \"bg-destructive text-destructive-foreground font-semibold\",\n success: \"bg-success text-success-foreground font-semibold\",\n warning: \"bg-warning text-warning-foreground font-semibold\",\n })[resolvedColor.value] ??\n \"bg-primary text-primary-foreground font-semibold\",\n);\n\nconst todayTextClass = computed(\n () =>\n ({\n default: \"text-foreground\",\n primary: \"text-primary\",\n danger: \"text-destructive\",\n success: \"text-success\",\n warning: \"text-warning\",\n })[resolvedColor.value] ?? \"text-primary\",\n);\n\nconst containerRadiusClass = computed(\n () =>\n ({\n none: \"rounded-none\",\n small: \"rounded-sm\",\n medium: \"rounded-md\",\n large: \"rounded-lg\",\n full: \"rounded-xl\",\n })[resolvedRadius.value] ?? \"rounded-lg\",\n);\n</script>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"DateTimePicker.mjs","names":[],"sources":["../../../../src/components/data-display/date-picker/DateTimePicker.vue"],"sourcesContent":["<template>\n <div\n :class=\"[\n 'relative inline-flex flex-col items-stretch bg-card w-fit self-start',\n !timeOnly ? 'sm:flex-row max-w-65 sm:max-w-none' : '',\n variant === 'outline' ? 'border border-border' : '',\n containerRadiusClass,\n ]\"\n >\n <Calendar\n v-if=\"!timeOnly\"\n v-model=\"dateOnly\"\n :locale=\"locale\"\n :first-day-of-week=\"firstDayOfWeek\"\n :min-date=\"minDate\"\n :max-date=\"maxDate\"\n :disabled-dates=\"disabledDates\"\n :color=\"color\"\n variant=\"filled\"\n :radius=\"radius\"\n />\n\n <div :class=\"['relative shrink-0', timePanelWidthClass]\">\n <div\n :class=\"[\n 'flex flex-col h-52',\n !timeOnly ? 'border-t border-border sm:border-t-0 sm:border-l sm:absolute sm:inset-0 sm:h-auto' : '',\n ]\"\n >\n <div class=\"px-3 py-3 border-b border-border text-center shrink-0\">\n <span class=\"text-sm font-semibold text-foreground\">{{\n timeLabel\n }}</span>\n </div>\n\n <div class=\"flex flex-1 min-h-0 overflow-hidden\">\n <div\n v-for=\"col in columns\"\n :key=\"col.key\"\n class=\"flex flex-col flex-1 border-r last:border-r-0 border-border\"\n >\n <div\n class=\"px-2 py-1.5 text-center text-xs font-medium text-muted-foreground border-b border-border\"\n >\n {{ col.label }}\n </div>\n <div\n :ref=\"\n (el: unknown) => setScrollRef(col.key, el as HTMLElement | null)\n \"\n class=\"flex-1 overflow-y-auto scroll-smooth\"\n style=\"scrollbar-width: thin\"\n >\n <div class=\"py-14\">\n <button\n v-for=\"item in col.items\"\n :key=\"item.value\"\n type=\"button\"\n :disabled=\"item.disabled\"\n :data-col=\"col.key\"\n :data-value=\"item.value\"\n @click=\"selectTimeItem(col.key, item.value)\"\n :class=\"[\n 'w-full px-2 py-1.5 text-sm text-center transition-colors cursor-pointer focus:outline-none',\n item.disabled\n ? 'text-muted-foreground/60 cursor-not-allowed'\n : item.value === col.selected\n ? selectedItemClasses\n : 'text-foreground/80 hover:bg-muted',\n ]\"\n >\n {{ item.label }}\n </button>\n </div>\n </div>\n </div>\n </div>\n\n <div\n class=\"px-3 py-2 border-t border-border flex justify-end gap-2 shrink-0\"\n >\n <Button\n variant=\"text\"\n size=\"xs\"\n radius=\"medium\"\n label=\"Now\"\n :class=\"todayTextClass\"\n @click=\"handleNow\"\n />\n </div>\n </div>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, computed, watch, nextTick, onMounted } from \"vue\";\nimport gsap from \"gsap\";\nimport Calendar from \"../calendar/Calendar.vue\";\nimport Button from \"../../forms/Button.vue\";\nimport {\n useResolvedColor,\n useResolvedRadius,\n} from \"../../../composables/useModoConfig\";\nimport type { DateTimePicker } from \"../../../interfaces/data-display/date-picker/DateTimePicker.interface\";\n\nconst props = withDefaults(defineProps<DateTimePicker>(), {\n modelValue: null,\n locale: \"default\",\n firstDayOfWeek: 0,\n color: \"default\",\n variant: \"outline\",\n format: \"24h\",\n step: 5,\n showSeconds: false,\n timeOnly: false,\n});\n\nconst resolvedColor = useResolvedColor(() => props.color);\nconst resolvedRadius = useResolvedRadius(() => props.radius);\n\nconst emit = defineEmits<{\n \"update:modelValue\": [date: Date];\n}>();\n\ntype ColKey = \"hour\" | \"minute\" | \"second\" | \"period\";\n\nconst scrollRefs = ref<Record<ColKey, HTMLElement | null>>({\n hour: null,\n minute: null,\n second: null,\n period: null,\n});\nconst setScrollRef = (key: ColKey, el: HTMLElement | null) => {\n scrollRefs.value[key] = el;\n};\n\nconst initialDate = props.modelValue ?? new Date();\n\nconst dateOnly = ref<Date>(new Date(initialDate));\nconst hour = ref(initialDate.getHours());\nconst minute = ref(\n Math.round(initialDate.getMinutes() / props.step) * props.step,\n);\nconst second = ref(initialDate.getSeconds());\n\nconst parseTimeStr = (t?: string): number | null => {\n if (!t) return null;\n const [h, m, s] = t.split(\":\").map(Number);\n return h * 3600 + (m || 0) * 60 + (s || 0);\n};\nconst minTimeSec = computed(() => parseTimeStr(props.minTime));\nconst maxTimeSec = computed(() => parseTimeStr(props.maxTime));\n\nconst pad2 = (n: number) => n.toString().padStart(2, \"0\");\n\nconst is12h = computed(() => props.format === \"12h\");\n\nconst hourValues = computed(() => {\n if (is12h.value) {\n return Array.from({ length: 12 }, (_, i) => (i === 0 ? 12 : i));\n }\n return Array.from({ length: 24 }, (_, i) => i);\n});\n\nconst minuteValues = computed(() => {\n const values: number[] = [];\n for (let i = 0; i < 60; i += props.step) values.push(i);\n return values;\n});\n\nconst secondValues = computed(() => {\n const values: number[] = [];\n for (let i = 0; i < 60; i += props.step) values.push(i);\n return values;\n});\n\nconst currentPeriod = computed<\"AM\" | \"PM\">(() =>\n hour.value < 12 ? \"AM\" : \"PM\",\n);\n\nconst hourDisplay = computed(() => {\n if (!is12h.value) return hour.value;\n const h = hour.value % 12;\n return h === 0 ? 12 : h;\n});\n\nconst isTimeDisabled = (h: number, m: number, s: number): boolean => {\n const total = h * 3600 + m * 60 + s;\n if (minTimeSec.value !== null && total < minTimeSec.value) return true;\n if (maxTimeSec.value !== null && total > maxTimeSec.value) return true;\n return false;\n};\n\ninterface TimeItem {\n value: number;\n label: string;\n disabled: boolean;\n}\n\ninterface TimeColumn {\n key: ColKey;\n label: string;\n items: TimeItem[];\n selected: number;\n}\n\nconst columns = computed<TimeColumn[]>(() => {\n const cols: TimeColumn[] = [];\n\n cols.push({\n key: \"hour\",\n label: \"Hour\",\n selected: hourDisplay.value,\n items: hourValues.value.map((v) => {\n const h24 = is12h.value\n ? currentPeriod.value === \"AM\"\n ? v === 12\n ? 0\n : v\n : v === 12\n ? 12\n : v + 12\n : v;\n return {\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(h24, minute.value, second.value),\n };\n }),\n });\n\n cols.push({\n key: \"minute\",\n label: \"Min\",\n selected: minute.value,\n items: minuteValues.value.map((v) => ({\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(hour.value, v, second.value),\n })),\n });\n\n if (props.showSeconds) {\n cols.push({\n key: \"second\",\n label: \"Sec\",\n selected: second.value,\n items: secondValues.value.map((v) => ({\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(hour.value, minute.value, v),\n })),\n });\n }\n\n if (is12h.value) {\n cols.push({\n key: \"period\",\n label: \"AM/PM\",\n selected: currentPeriod.value === \"AM\" ? 0 : 1,\n items: [\n { value: 0, label: \"AM\", disabled: false },\n { value: 1, label: \"PM\", disabled: false },\n ],\n });\n }\n\n return cols;\n});\n\nconst timeLabel = computed(() => {\n const h = is12h.value ? hourDisplay.value : hour.value;\n let s = `${pad2(h)}:${pad2(minute.value)}`;\n if (props.showSeconds) s += `:${pad2(second.value)}`;\n if (is12h.value) s += ` ${currentPeriod.value}`;\n return s;\n});\n\nconst commitDate = () => {\n const d = new Date(dateOnly.value);\n d.setHours(hour.value, minute.value, props.showSeconds ? second.value : 0, 0);\n if (props.modelValue && d.getTime() === props.modelValue.getTime()) return;\n emit(\"update:modelValue\", d);\n};\n\nconst selectTimeItem = (col: ColKey, value: number) => {\n if (col === \"hour\") {\n if (is12h.value) {\n const base = value === 12 ? 0 : value;\n hour.value = currentPeriod.value === \"AM\" ? base : base + 12;\n } else {\n hour.value = value;\n }\n } else if (col === \"minute\") {\n minute.value = value;\n } else if (col === \"second\") {\n second.value = value;\n } else if (col === \"period\") {\n const targetAM = value === 0;\n if (targetAM && hour.value >= 12) hour.value -= 12;\n else if (!targetAM && hour.value < 12) hour.value += 12;\n }\n commitDate();\n scrollColumnToSelected(col);\n};\n\nconst scrollColumnToSelected = (col: ColKey, animate = true) => {\n nextTick(() => {\n const container = scrollRefs.value[col];\n if (!container) return;\n const colInfo = columns.value.find((c) => c.key === col);\n if (!colInfo) return;\n const targetBtn = container.querySelector<HTMLElement>(\n `button[data-col=\"${col}\"][data-value=\"${colInfo.selected}\"]`,\n );\n if (!targetBtn) return;\n const apply = () => {\n // Measured against the scroll container itself rather than\n // `targetBtn.offsetTop`: the nearest positioned ancestor is the time\n // panel wrapper, not this container, so offsetTop also carries the\n // \"Time\" header and the column label. That constant error is what\n // pushed the selected option up behind the hour/min label — most\n // visible in `timeOnly`, where the column is only h-52 tall.\n const offsetWithinScroller =\n targetBtn.getBoundingClientRect().top\n - container.getBoundingClientRect().top\n + container.scrollTop;\n const targetTop =\n offsetWithinScroller -\n container.clientHeight / 2 +\n targetBtn.clientHeight / 2;\n if (animate) {\n gsap.to(container, {\n scrollTop: targetTop,\n duration: 0.3,\n ease: \"power2.out\",\n });\n } else {\n container.scrollTop = targetTop;\n }\n };\n // Defer hasta un segundo frame para que el layout esté asentado\n // (especialmente en mount, cuando el Calendar todavía no determinó altura final).\n requestAnimationFrame(() => requestAnimationFrame(apply));\n });\n};\n\nwatch(dateOnly, () => commitDate());\n\nwatch(\n () => props.modelValue,\n (v) => {\n if (!v) return;\n dateOnly.value = new Date(v);\n hour.value = v.getHours();\n minute.value = v.getMinutes();\n second.value = v.getSeconds();\n columns.value.forEach((c) => scrollColumnToSelected(c.key));\n },\n);\n\nonMounted(() => {\n if (!props.modelValue) commitDate();\n nextTick(() => {\n columns.value.forEach((c) => scrollColumnToSelected(c.key, false));\n });\n});\n\nconst handleNow = () => {\n const now = new Date();\n dateOnly.value = new Date(now);\n hour.value = now.getHours();\n minute.value = Math.round(now.getMinutes() / props.step) * props.step;\n second.value = now.getSeconds();\n commitDate();\n columns.value.forEach((c) => scrollColumnToSelected(c.key));\n};\n\nconst timePanelWidthClass = computed(() => {\n const n = columns.value.length;\n // Mobile: stretches to full calendar width. sm+: fixed width per column count.\n if (n <= 2) return \"sm:w-32\"; // 128px\n if (n === 3) return \"sm:w-48\"; // 192px sm+\n return \"sm:w-64\"; // 256px sm+\n});\n\nconst selectedItemClasses = computed(\n () =>\n ({\n default: \"bg-foreground text-background font-semibold\",\n primary: \"bg-primary text-primary-foreground font-semibold\",\n danger: \"bg-destructive text-destructive-foreground font-semibold\",\n success: \"bg-success text-success-foreground font-semibold\",\n warning: \"bg-warning text-warning-foreground font-semibold\",\n })[resolvedColor.value] ??\n \"bg-primary text-primary-foreground font-semibold\",\n);\n\nconst todayTextClass = computed(\n () =>\n ({\n default: \"text-foreground\",\n primary: \"text-primary\",\n danger: \"text-destructive\",\n success: \"text-success\",\n warning: \"text-warning\",\n })[resolvedColor.value] ?? \"text-primary\",\n);\n\nconst containerRadiusClass = computed(\n () =>\n ({\n none: \"rounded-none\",\n small: \"rounded-sm\",\n medium: \"rounded-md\",\n large: \"rounded-lg\",\n full: \"rounded-xl\",\n })[resolvedRadius.value] ?? \"rounded-lg\",\n);\n</script>\n"],"mappings":""}
|
|
@@ -185,7 +185,7 @@ var DateTimePicker_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
185
185
|
const targetBtn = container.querySelector(`button[data-col="${col}"][data-value="${colInfo.selected}"]`);
|
|
186
186
|
if (!targetBtn) return;
|
|
187
187
|
const apply = () => {
|
|
188
|
-
const targetTop = targetBtn.
|
|
188
|
+
const targetTop = targetBtn.getBoundingClientRect().top - container.getBoundingClientRect().top + container.scrollTop - container.clientHeight / 2 + targetBtn.clientHeight / 2;
|
|
189
189
|
if (animate) gsap.default.to(container, {
|
|
190
190
|
scrollTop: targetTop,
|
|
191
191
|
duration: .3,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimePicker.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../../../src/components/data-display/date-picker/DateTimePicker.vue"],"sourcesContent":["<template>\n <div\n :class=\"[\n 'relative inline-flex flex-col items-stretch bg-card w-fit self-start',\n !timeOnly ? 'sm:flex-row max-w-65 sm:max-w-none' : '',\n variant === 'outline' ? 'border border-border' : '',\n containerRadiusClass,\n ]\"\n >\n <Calendar\n v-if=\"!timeOnly\"\n v-model=\"dateOnly\"\n :locale=\"locale\"\n :first-day-of-week=\"firstDayOfWeek\"\n :min-date=\"minDate\"\n :max-date=\"maxDate\"\n :disabled-dates=\"disabledDates\"\n :color=\"color\"\n variant=\"filled\"\n :radius=\"radius\"\n />\n\n <div :class=\"['relative shrink-0', timePanelWidthClass]\">\n <div\n :class=\"[\n 'flex flex-col h-52',\n !timeOnly ? 'border-t border-border sm:border-t-0 sm:border-l sm:absolute sm:inset-0 sm:h-auto' : '',\n ]\"\n >\n <div class=\"px-3 py-3 border-b border-border text-center shrink-0\">\n <span class=\"text-sm font-semibold text-foreground\">{{\n timeLabel\n }}</span>\n </div>\n\n <div class=\"flex flex-1 min-h-0 overflow-hidden\">\n <div\n v-for=\"col in columns\"\n :key=\"col.key\"\n class=\"flex flex-col flex-1 border-r last:border-r-0 border-border\"\n >\n <div\n class=\"px-2 py-1.5 text-center text-xs font-medium text-muted-foreground border-b border-border\"\n >\n {{ col.label }}\n </div>\n <div\n :ref=\"\n (el: unknown) => setScrollRef(col.key, el as HTMLElement | null)\n \"\n class=\"flex-1 overflow-y-auto scroll-smooth\"\n style=\"scrollbar-width: thin\"\n >\n <div class=\"py-14\">\n <button\n v-for=\"item in col.items\"\n :key=\"item.value\"\n type=\"button\"\n :disabled=\"item.disabled\"\n :data-col=\"col.key\"\n :data-value=\"item.value\"\n @click=\"selectTimeItem(col.key, item.value)\"\n :class=\"[\n 'w-full px-2 py-1.5 text-sm text-center transition-colors cursor-pointer focus:outline-none',\n item.disabled\n ? 'text-muted-foreground/60 cursor-not-allowed'\n : item.value === col.selected\n ? selectedItemClasses\n : 'text-foreground/80 hover:bg-muted',\n ]\"\n >\n {{ item.label }}\n </button>\n </div>\n </div>\n </div>\n </div>\n\n <div\n class=\"px-3 py-2 border-t border-border flex justify-end gap-2 shrink-0\"\n >\n <Button\n variant=\"text\"\n size=\"xs\"\n radius=\"medium\"\n label=\"Now\"\n :class=\"todayTextClass\"\n @click=\"handleNow\"\n />\n </div>\n </div>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, computed, watch, nextTick, onMounted } from \"vue\";\nimport gsap from \"gsap\";\nimport Calendar from \"../calendar/Calendar.vue\";\nimport Button from \"../../forms/Button.vue\";\nimport {\n useResolvedColor,\n useResolvedRadius,\n} from \"../../../composables/useModoConfig\";\nimport type { DateTimePicker } from \"../../../interfaces/data-display/date-picker/DateTimePicker.interface\";\n\nconst props = withDefaults(defineProps<DateTimePicker>(), {\n modelValue: null,\n locale: \"default\",\n firstDayOfWeek: 0,\n color: \"default\",\n variant: \"outline\",\n format: \"24h\",\n step: 5,\n showSeconds: false,\n timeOnly: false,\n});\n\nconst resolvedColor = useResolvedColor(() => props.color);\nconst resolvedRadius = useResolvedRadius(() => props.radius);\n\nconst emit = defineEmits<{\n \"update:modelValue\": [date: Date];\n}>();\n\ntype ColKey = \"hour\" | \"minute\" | \"second\" | \"period\";\n\nconst scrollRefs = ref<Record<ColKey, HTMLElement | null>>({\n hour: null,\n minute: null,\n second: null,\n period: null,\n});\nconst setScrollRef = (key: ColKey, el: HTMLElement | null) => {\n scrollRefs.value[key] = el;\n};\n\nconst initialDate = props.modelValue ?? new Date();\n\nconst dateOnly = ref<Date>(new Date(initialDate));\nconst hour = ref(initialDate.getHours());\nconst minute = ref(\n Math.round(initialDate.getMinutes() / props.step) * props.step,\n);\nconst second = ref(initialDate.getSeconds());\n\nconst parseTimeStr = (t?: string): number | null => {\n if (!t) return null;\n const [h, m, s] = t.split(\":\").map(Number);\n return h * 3600 + (m || 0) * 60 + (s || 0);\n};\nconst minTimeSec = computed(() => parseTimeStr(props.minTime));\nconst maxTimeSec = computed(() => parseTimeStr(props.maxTime));\n\nconst pad2 = (n: number) => n.toString().padStart(2, \"0\");\n\nconst is12h = computed(() => props.format === \"12h\");\n\nconst hourValues = computed(() => {\n if (is12h.value) {\n return Array.from({ length: 12 }, (_, i) => (i === 0 ? 12 : i));\n }\n return Array.from({ length: 24 }, (_, i) => i);\n});\n\nconst minuteValues = computed(() => {\n const values: number[] = [];\n for (let i = 0; i < 60; i += props.step) values.push(i);\n return values;\n});\n\nconst secondValues = computed(() => {\n const values: number[] = [];\n for (let i = 0; i < 60; i += props.step) values.push(i);\n return values;\n});\n\nconst currentPeriod = computed<\"AM\" | \"PM\">(() =>\n hour.value < 12 ? \"AM\" : \"PM\",\n);\n\nconst hourDisplay = computed(() => {\n if (!is12h.value) return hour.value;\n const h = hour.value % 12;\n return h === 0 ? 12 : h;\n});\n\nconst isTimeDisabled = (h: number, m: number, s: number): boolean => {\n const total = h * 3600 + m * 60 + s;\n if (minTimeSec.value !== null && total < minTimeSec.value) return true;\n if (maxTimeSec.value !== null && total > maxTimeSec.value) return true;\n return false;\n};\n\ninterface TimeItem {\n value: number;\n label: string;\n disabled: boolean;\n}\n\ninterface TimeColumn {\n key: ColKey;\n label: string;\n items: TimeItem[];\n selected: number;\n}\n\nconst columns = computed<TimeColumn[]>(() => {\n const cols: TimeColumn[] = [];\n\n cols.push({\n key: \"hour\",\n label: \"Hour\",\n selected: hourDisplay.value,\n items: hourValues.value.map((v) => {\n const h24 = is12h.value\n ? currentPeriod.value === \"AM\"\n ? v === 12\n ? 0\n : v\n : v === 12\n ? 12\n : v + 12\n : v;\n return {\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(h24, minute.value, second.value),\n };\n }),\n });\n\n cols.push({\n key: \"minute\",\n label: \"Min\",\n selected: minute.value,\n items: minuteValues.value.map((v) => ({\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(hour.value, v, second.value),\n })),\n });\n\n if (props.showSeconds) {\n cols.push({\n key: \"second\",\n label: \"Sec\",\n selected: second.value,\n items: secondValues.value.map((v) => ({\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(hour.value, minute.value, v),\n })),\n });\n }\n\n if (is12h.value) {\n cols.push({\n key: \"period\",\n label: \"AM/PM\",\n selected: currentPeriod.value === \"AM\" ? 0 : 1,\n items: [\n { value: 0, label: \"AM\", disabled: false },\n { value: 1, label: \"PM\", disabled: false },\n ],\n });\n }\n\n return cols;\n});\n\nconst timeLabel = computed(() => {\n const h = is12h.value ? hourDisplay.value : hour.value;\n let s = `${pad2(h)}:${pad2(minute.value)}`;\n if (props.showSeconds) s += `:${pad2(second.value)}`;\n if (is12h.value) s += ` ${currentPeriod.value}`;\n return s;\n});\n\nconst commitDate = () => {\n const d = new Date(dateOnly.value);\n d.setHours(hour.value, minute.value, props.showSeconds ? second.value : 0, 0);\n if (props.modelValue && d.getTime() === props.modelValue.getTime()) return;\n emit(\"update:modelValue\", d);\n};\n\nconst selectTimeItem = (col: ColKey, value: number) => {\n if (col === \"hour\") {\n if (is12h.value) {\n const base = value === 12 ? 0 : value;\n hour.value = currentPeriod.value === \"AM\" ? base : base + 12;\n } else {\n hour.value = value;\n }\n } else if (col === \"minute\") {\n minute.value = value;\n } else if (col === \"second\") {\n second.value = value;\n } else if (col === \"period\") {\n const targetAM = value === 0;\n if (targetAM && hour.value >= 12) hour.value -= 12;\n else if (!targetAM && hour.value < 12) hour.value += 12;\n }\n commitDate();\n scrollColumnToSelected(col);\n};\n\nconst scrollColumnToSelected = (col: ColKey, animate = true) => {\n nextTick(() => {\n const container = scrollRefs.value[col];\n if (!container) return;\n const colInfo = columns.value.find((c) => c.key === col);\n if (!colInfo) return;\n const targetBtn = container.querySelector<HTMLElement>(\n `button[data-col=\"${col}\"][data-value=\"${colInfo.selected}\"]`,\n );\n if (!targetBtn) return;\n const apply = () => {\n const targetTop =\n targetBtn.offsetTop -\n container.clientHeight / 2 +\n targetBtn.clientHeight / 2;\n if (animate) {\n gsap.to(container, {\n scrollTop: targetTop,\n duration: 0.3,\n ease: \"power2.out\",\n });\n } else {\n container.scrollTop = targetTop;\n }\n };\n // Defer hasta un segundo frame para que el layout esté asentado\n // (especialmente en mount, cuando el Calendar todavía no determinó altura final).\n requestAnimationFrame(() => requestAnimationFrame(apply));\n });\n};\n\nwatch(dateOnly, () => commitDate());\n\nwatch(\n () => props.modelValue,\n (v) => {\n if (!v) return;\n dateOnly.value = new Date(v);\n hour.value = v.getHours();\n minute.value = v.getMinutes();\n second.value = v.getSeconds();\n columns.value.forEach((c) => scrollColumnToSelected(c.key));\n },\n);\n\nonMounted(() => {\n if (!props.modelValue) commitDate();\n nextTick(() => {\n columns.value.forEach((c) => scrollColumnToSelected(c.key, false));\n });\n});\n\nconst handleNow = () => {\n const now = new Date();\n dateOnly.value = new Date(now);\n hour.value = now.getHours();\n minute.value = Math.round(now.getMinutes() / props.step) * props.step;\n second.value = now.getSeconds();\n commitDate();\n columns.value.forEach((c) => scrollColumnToSelected(c.key));\n};\n\nconst timePanelWidthClass = computed(() => {\n const n = columns.value.length;\n // Mobile: stretches to full calendar width. sm+: fixed width per column count.\n if (n <= 2) return \"sm:w-32\"; // 128px\n if (n === 3) return \"sm:w-48\"; // 192px sm+\n return \"sm:w-64\"; // 256px sm+\n});\n\nconst selectedItemClasses = computed(\n () =>\n ({\n default: \"bg-foreground text-background font-semibold\",\n primary: \"bg-primary text-primary-foreground font-semibold\",\n danger: \"bg-destructive text-destructive-foreground font-semibold\",\n success: \"bg-success text-success-foreground font-semibold\",\n warning: \"bg-warning text-warning-foreground font-semibold\",\n })[resolvedColor.value] ??\n \"bg-primary text-primary-foreground font-semibold\",\n);\n\nconst todayTextClass = computed(\n () =>\n ({\n default: \"text-foreground\",\n primary: \"text-primary\",\n danger: \"text-destructive\",\n success: \"text-success\",\n warning: \"text-warning\",\n })[resolvedColor.value] ?? \"text-primary\",\n);\n\nconst containerRadiusClass = computed(\n () =>\n ({\n none: \"rounded-none\",\n small: \"rounded-sm\",\n medium: \"rounded-md\",\n large: \"rounded-lg\",\n full: \"rounded-xl\",\n })[resolvedRadius.value] ?? \"rounded-lg\",\n);\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0GA,MAAM,QAAQ;EAYd,MAAM,gBAAgB,sBAAA,uBAAuB,MAAM,MAAM;EACzD,MAAM,iBAAiB,sBAAA,wBAAwB,MAAM,OAAO;EAE5D,MAAM,OAAO;EAMb,MAAM,cAAA,GAAA,IAAA,KAAqD;GACzD,MAAM;GACN,QAAQ;GACR,QAAQ;GACR,QAAQ;GACT,CAAC;EACF,MAAM,gBAAgB,KAAa,OAA2B;GAC5D,WAAW,MAAM,OAAO;;EAG1B,MAAM,cAAc,MAAM,8BAAc,IAAI,MAAM;EAElD,MAAM,YAAA,GAAA,IAAA,KAAqB,IAAI,KAAK,YAAY,CAAC;EACjD,MAAM,QAAA,GAAA,IAAA,KAAW,YAAY,UAAU,CAAC;EACxC,MAAM,UAAA,GAAA,IAAA,KACJ,KAAK,MAAM,YAAY,YAAY,GAAG,MAAM,KAAK,GAAG,MA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OAJN,aAAA,GAAA,IAAA,iBAGK,IAAI,MAAK,EAAA,EAAA,GAAA,GAAA,IAAA,oBA8BR,OAAA;;MA3BH,MAAuB,OAAgB,aAAa,IAAI,KAAK,GAAE;MAGhE,OAAM;MACN,OAAA,EAAA,mBAAA,QAA6B;qCAsBvB,OApBN,YAoBM,GAAA,GAAA,IAAA,WAAA,KAAA,GAAA,GAAA,IAAA,oBADK,IAAA,UAAA,OAAA,GAAA,IAAA,YAjBQ,IAAI,QAAZ,SAAI;+DAiBJ,UAAA;OAhBN,KAAK,KAAK;OACX,MAAK;OACJ,UAAU,KAAK;OACf,YAAU,IAAI;OACd,cAAY,KAAK;OACjB,UAAK,WAAE,eAAe,IAAI,KAAK,KAAK,MAAK;OACzC,QAAA,GAAA,IAAA,gBAAK,CAAA,8FAA0I,KAAK,WAAA,gDAAuG,KAAK,UAAU,IAAI,WAAmC,oBAAA,QAAA,oCAAA,CAAA;kCAS/S,KAAK,MAAK,EAAA,IAAA,WAAA;;;gCAkBjB,OAXN,YAWM,EAAA,GAAA,IAAA,aADF,eAAA,SAAA;KANA,SAAQ;KACR,MAAK;KACL,QAAO;KACP,OAAM;KACL,QAAA,GAAA,IAAA,gBAAO,eAAA,MAAc;KACrB,SAAO"}
|
|
1
|
+
{"version":3,"file":"DateTimePicker.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../../../src/components/data-display/date-picker/DateTimePicker.vue"],"sourcesContent":["<template>\n <div\n :class=\"[\n 'relative inline-flex flex-col items-stretch bg-card w-fit self-start',\n !timeOnly ? 'sm:flex-row max-w-65 sm:max-w-none' : '',\n variant === 'outline' ? 'border border-border' : '',\n containerRadiusClass,\n ]\"\n >\n <Calendar\n v-if=\"!timeOnly\"\n v-model=\"dateOnly\"\n :locale=\"locale\"\n :first-day-of-week=\"firstDayOfWeek\"\n :min-date=\"minDate\"\n :max-date=\"maxDate\"\n :disabled-dates=\"disabledDates\"\n :color=\"color\"\n variant=\"filled\"\n :radius=\"radius\"\n />\n\n <div :class=\"['relative shrink-0', timePanelWidthClass]\">\n <div\n :class=\"[\n 'flex flex-col h-52',\n !timeOnly ? 'border-t border-border sm:border-t-0 sm:border-l sm:absolute sm:inset-0 sm:h-auto' : '',\n ]\"\n >\n <div class=\"px-3 py-3 border-b border-border text-center shrink-0\">\n <span class=\"text-sm font-semibold text-foreground\">{{\n timeLabel\n }}</span>\n </div>\n\n <div class=\"flex flex-1 min-h-0 overflow-hidden\">\n <div\n v-for=\"col in columns\"\n :key=\"col.key\"\n class=\"flex flex-col flex-1 border-r last:border-r-0 border-border\"\n >\n <div\n class=\"px-2 py-1.5 text-center text-xs font-medium text-muted-foreground border-b border-border\"\n >\n {{ col.label }}\n </div>\n <div\n :ref=\"\n (el: unknown) => setScrollRef(col.key, el as HTMLElement | null)\n \"\n class=\"flex-1 overflow-y-auto scroll-smooth\"\n style=\"scrollbar-width: thin\"\n >\n <div class=\"py-14\">\n <button\n v-for=\"item in col.items\"\n :key=\"item.value\"\n type=\"button\"\n :disabled=\"item.disabled\"\n :data-col=\"col.key\"\n :data-value=\"item.value\"\n @click=\"selectTimeItem(col.key, item.value)\"\n :class=\"[\n 'w-full px-2 py-1.5 text-sm text-center transition-colors cursor-pointer focus:outline-none',\n item.disabled\n ? 'text-muted-foreground/60 cursor-not-allowed'\n : item.value === col.selected\n ? selectedItemClasses\n : 'text-foreground/80 hover:bg-muted',\n ]\"\n >\n {{ item.label }}\n </button>\n </div>\n </div>\n </div>\n </div>\n\n <div\n class=\"px-3 py-2 border-t border-border flex justify-end gap-2 shrink-0\"\n >\n <Button\n variant=\"text\"\n size=\"xs\"\n radius=\"medium\"\n label=\"Now\"\n :class=\"todayTextClass\"\n @click=\"handleNow\"\n />\n </div>\n </div>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, computed, watch, nextTick, onMounted } from \"vue\";\nimport gsap from \"gsap\";\nimport Calendar from \"../calendar/Calendar.vue\";\nimport Button from \"../../forms/Button.vue\";\nimport {\n useResolvedColor,\n useResolvedRadius,\n} from \"../../../composables/useModoConfig\";\nimport type { DateTimePicker } from \"../../../interfaces/data-display/date-picker/DateTimePicker.interface\";\n\nconst props = withDefaults(defineProps<DateTimePicker>(), {\n modelValue: null,\n locale: \"default\",\n firstDayOfWeek: 0,\n color: \"default\",\n variant: \"outline\",\n format: \"24h\",\n step: 5,\n showSeconds: false,\n timeOnly: false,\n});\n\nconst resolvedColor = useResolvedColor(() => props.color);\nconst resolvedRadius = useResolvedRadius(() => props.radius);\n\nconst emit = defineEmits<{\n \"update:modelValue\": [date: Date];\n}>();\n\ntype ColKey = \"hour\" | \"minute\" | \"second\" | \"period\";\n\nconst scrollRefs = ref<Record<ColKey, HTMLElement | null>>({\n hour: null,\n minute: null,\n second: null,\n period: null,\n});\nconst setScrollRef = (key: ColKey, el: HTMLElement | null) => {\n scrollRefs.value[key] = el;\n};\n\nconst initialDate = props.modelValue ?? new Date();\n\nconst dateOnly = ref<Date>(new Date(initialDate));\nconst hour = ref(initialDate.getHours());\nconst minute = ref(\n Math.round(initialDate.getMinutes() / props.step) * props.step,\n);\nconst second = ref(initialDate.getSeconds());\n\nconst parseTimeStr = (t?: string): number | null => {\n if (!t) return null;\n const [h, m, s] = t.split(\":\").map(Number);\n return h * 3600 + (m || 0) * 60 + (s || 0);\n};\nconst minTimeSec = computed(() => parseTimeStr(props.minTime));\nconst maxTimeSec = computed(() => parseTimeStr(props.maxTime));\n\nconst pad2 = (n: number) => n.toString().padStart(2, \"0\");\n\nconst is12h = computed(() => props.format === \"12h\");\n\nconst hourValues = computed(() => {\n if (is12h.value) {\n return Array.from({ length: 12 }, (_, i) => (i === 0 ? 12 : i));\n }\n return Array.from({ length: 24 }, (_, i) => i);\n});\n\nconst minuteValues = computed(() => {\n const values: number[] = [];\n for (let i = 0; i < 60; i += props.step) values.push(i);\n return values;\n});\n\nconst secondValues = computed(() => {\n const values: number[] = [];\n for (let i = 0; i < 60; i += props.step) values.push(i);\n return values;\n});\n\nconst currentPeriod = computed<\"AM\" | \"PM\">(() =>\n hour.value < 12 ? \"AM\" : \"PM\",\n);\n\nconst hourDisplay = computed(() => {\n if (!is12h.value) return hour.value;\n const h = hour.value % 12;\n return h === 0 ? 12 : h;\n});\n\nconst isTimeDisabled = (h: number, m: number, s: number): boolean => {\n const total = h * 3600 + m * 60 + s;\n if (minTimeSec.value !== null && total < minTimeSec.value) return true;\n if (maxTimeSec.value !== null && total > maxTimeSec.value) return true;\n return false;\n};\n\ninterface TimeItem {\n value: number;\n label: string;\n disabled: boolean;\n}\n\ninterface TimeColumn {\n key: ColKey;\n label: string;\n items: TimeItem[];\n selected: number;\n}\n\nconst columns = computed<TimeColumn[]>(() => {\n const cols: TimeColumn[] = [];\n\n cols.push({\n key: \"hour\",\n label: \"Hour\",\n selected: hourDisplay.value,\n items: hourValues.value.map((v) => {\n const h24 = is12h.value\n ? currentPeriod.value === \"AM\"\n ? v === 12\n ? 0\n : v\n : v === 12\n ? 12\n : v + 12\n : v;\n return {\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(h24, minute.value, second.value),\n };\n }),\n });\n\n cols.push({\n key: \"minute\",\n label: \"Min\",\n selected: minute.value,\n items: minuteValues.value.map((v) => ({\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(hour.value, v, second.value),\n })),\n });\n\n if (props.showSeconds) {\n cols.push({\n key: \"second\",\n label: \"Sec\",\n selected: second.value,\n items: secondValues.value.map((v) => ({\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(hour.value, minute.value, v),\n })),\n });\n }\n\n if (is12h.value) {\n cols.push({\n key: \"period\",\n label: \"AM/PM\",\n selected: currentPeriod.value === \"AM\" ? 0 : 1,\n items: [\n { value: 0, label: \"AM\", disabled: false },\n { value: 1, label: \"PM\", disabled: false },\n ],\n });\n }\n\n return cols;\n});\n\nconst timeLabel = computed(() => {\n const h = is12h.value ? hourDisplay.value : hour.value;\n let s = `${pad2(h)}:${pad2(minute.value)}`;\n if (props.showSeconds) s += `:${pad2(second.value)}`;\n if (is12h.value) s += ` ${currentPeriod.value}`;\n return s;\n});\n\nconst commitDate = () => {\n const d = new Date(dateOnly.value);\n d.setHours(hour.value, minute.value, props.showSeconds ? second.value : 0, 0);\n if (props.modelValue && d.getTime() === props.modelValue.getTime()) return;\n emit(\"update:modelValue\", d);\n};\n\nconst selectTimeItem = (col: ColKey, value: number) => {\n if (col === \"hour\") {\n if (is12h.value) {\n const base = value === 12 ? 0 : value;\n hour.value = currentPeriod.value === \"AM\" ? base : base + 12;\n } else {\n hour.value = value;\n }\n } else if (col === \"minute\") {\n minute.value = value;\n } else if (col === \"second\") {\n second.value = value;\n } else if (col === \"period\") {\n const targetAM = value === 0;\n if (targetAM && hour.value >= 12) hour.value -= 12;\n else if (!targetAM && hour.value < 12) hour.value += 12;\n }\n commitDate();\n scrollColumnToSelected(col);\n};\n\nconst scrollColumnToSelected = (col: ColKey, animate = true) => {\n nextTick(() => {\n const container = scrollRefs.value[col];\n if (!container) return;\n const colInfo = columns.value.find((c) => c.key === col);\n if (!colInfo) return;\n const targetBtn = container.querySelector<HTMLElement>(\n `button[data-col=\"${col}\"][data-value=\"${colInfo.selected}\"]`,\n );\n if (!targetBtn) return;\n const apply = () => {\n // Measured against the scroll container itself rather than\n // `targetBtn.offsetTop`: the nearest positioned ancestor is the time\n // panel wrapper, not this container, so offsetTop also carries the\n // \"Time\" header and the column label. That constant error is what\n // pushed the selected option up behind the hour/min label — most\n // visible in `timeOnly`, where the column is only h-52 tall.\n const offsetWithinScroller =\n targetBtn.getBoundingClientRect().top\n - container.getBoundingClientRect().top\n + container.scrollTop;\n const targetTop =\n offsetWithinScroller -\n container.clientHeight / 2 +\n targetBtn.clientHeight / 2;\n if (animate) {\n gsap.to(container, {\n scrollTop: targetTop,\n duration: 0.3,\n ease: \"power2.out\",\n });\n } else {\n container.scrollTop = targetTop;\n }\n };\n // Defer hasta un segundo frame para que el layout esté asentado\n // (especialmente en mount, cuando el Calendar todavía no determinó altura final).\n requestAnimationFrame(() => requestAnimationFrame(apply));\n });\n};\n\nwatch(dateOnly, () => commitDate());\n\nwatch(\n () => props.modelValue,\n (v) => {\n if (!v) return;\n dateOnly.value = new Date(v);\n hour.value = v.getHours();\n minute.value = v.getMinutes();\n second.value = v.getSeconds();\n columns.value.forEach((c) => scrollColumnToSelected(c.key));\n },\n);\n\nonMounted(() => {\n if (!props.modelValue) commitDate();\n nextTick(() => {\n columns.value.forEach((c) => scrollColumnToSelected(c.key, false));\n });\n});\n\nconst handleNow = () => {\n const now = new Date();\n dateOnly.value = new Date(now);\n hour.value = now.getHours();\n minute.value = Math.round(now.getMinutes() / props.step) * props.step;\n second.value = now.getSeconds();\n commitDate();\n columns.value.forEach((c) => scrollColumnToSelected(c.key));\n};\n\nconst timePanelWidthClass = computed(() => {\n const n = columns.value.length;\n // Mobile: stretches to full calendar width. sm+: fixed width per column count.\n if (n <= 2) return \"sm:w-32\"; // 128px\n if (n === 3) return \"sm:w-48\"; // 192px sm+\n return \"sm:w-64\"; // 256px sm+\n});\n\nconst selectedItemClasses = computed(\n () =>\n ({\n default: \"bg-foreground text-background font-semibold\",\n primary: \"bg-primary text-primary-foreground font-semibold\",\n danger: \"bg-destructive text-destructive-foreground font-semibold\",\n success: \"bg-success text-success-foreground font-semibold\",\n warning: \"bg-warning text-warning-foreground font-semibold\",\n })[resolvedColor.value] ??\n \"bg-primary text-primary-foreground font-semibold\",\n);\n\nconst todayTextClass = computed(\n () =>\n ({\n default: \"text-foreground\",\n primary: \"text-primary\",\n danger: \"text-destructive\",\n success: \"text-success\",\n warning: \"text-warning\",\n })[resolvedColor.value] ?? \"text-primary\",\n);\n\nconst containerRadiusClass = computed(\n () =>\n ({\n none: \"rounded-none\",\n small: \"rounded-sm\",\n medium: \"rounded-md\",\n large: \"rounded-lg\",\n full: \"rounded-xl\",\n })[resolvedRadius.value] ?? \"rounded-lg\",\n);\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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B,OAXN,YAWM,EAAA,GAAA,IAAA,aADF,eAAA,SAAA;KANA,SAAQ;KACR,MAAK;KACL,QAAO;KACP,OAAM;KACL,QAAA,GAAA,IAAA,gBAAO,eAAA,MAAc;KACrB,SAAO"}
|
|
@@ -183,7 +183,7 @@ var DateTimePicker_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
183
183
|
const targetBtn = container.querySelector(`button[data-col="${col}"][data-value="${colInfo.selected}"]`);
|
|
184
184
|
if (!targetBtn) return;
|
|
185
185
|
const apply = () => {
|
|
186
|
-
const targetTop = targetBtn.
|
|
186
|
+
const targetTop = targetBtn.getBoundingClientRect().top - container.getBoundingClientRect().top + container.scrollTop - container.clientHeight / 2 + targetBtn.clientHeight / 2;
|
|
187
187
|
if (animate) gsap.to(container, {
|
|
188
188
|
scrollTop: targetTop,
|
|
189
189
|
duration: .3,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimePicker.vue_vue_type_script_setup_true_lang.mjs","names":[],"sources":["../../../../src/components/data-display/date-picker/DateTimePicker.vue"],"sourcesContent":["<template>\n <div\n :class=\"[\n 'relative inline-flex flex-col items-stretch bg-card w-fit self-start',\n !timeOnly ? 'sm:flex-row max-w-65 sm:max-w-none' : '',\n variant === 'outline' ? 'border border-border' : '',\n containerRadiusClass,\n ]\"\n >\n <Calendar\n v-if=\"!timeOnly\"\n v-model=\"dateOnly\"\n :locale=\"locale\"\n :first-day-of-week=\"firstDayOfWeek\"\n :min-date=\"minDate\"\n :max-date=\"maxDate\"\n :disabled-dates=\"disabledDates\"\n :color=\"color\"\n variant=\"filled\"\n :radius=\"radius\"\n />\n\n <div :class=\"['relative shrink-0', timePanelWidthClass]\">\n <div\n :class=\"[\n 'flex flex-col h-52',\n !timeOnly ? 'border-t border-border sm:border-t-0 sm:border-l sm:absolute sm:inset-0 sm:h-auto' : '',\n ]\"\n >\n <div class=\"px-3 py-3 border-b border-border text-center shrink-0\">\n <span class=\"text-sm font-semibold text-foreground\">{{\n timeLabel\n }}</span>\n </div>\n\n <div class=\"flex flex-1 min-h-0 overflow-hidden\">\n <div\n v-for=\"col in columns\"\n :key=\"col.key\"\n class=\"flex flex-col flex-1 border-r last:border-r-0 border-border\"\n >\n <div\n class=\"px-2 py-1.5 text-center text-xs font-medium text-muted-foreground border-b border-border\"\n >\n {{ col.label }}\n </div>\n <div\n :ref=\"\n (el: unknown) => setScrollRef(col.key, el as HTMLElement | null)\n \"\n class=\"flex-1 overflow-y-auto scroll-smooth\"\n style=\"scrollbar-width: thin\"\n >\n <div class=\"py-14\">\n <button\n v-for=\"item in col.items\"\n :key=\"item.value\"\n type=\"button\"\n :disabled=\"item.disabled\"\n :data-col=\"col.key\"\n :data-value=\"item.value\"\n @click=\"selectTimeItem(col.key, item.value)\"\n :class=\"[\n 'w-full px-2 py-1.5 text-sm text-center transition-colors cursor-pointer focus:outline-none',\n item.disabled\n ? 'text-muted-foreground/60 cursor-not-allowed'\n : item.value === col.selected\n ? selectedItemClasses\n : 'text-foreground/80 hover:bg-muted',\n ]\"\n >\n {{ item.label }}\n </button>\n </div>\n </div>\n </div>\n </div>\n\n <div\n class=\"px-3 py-2 border-t border-border flex justify-end gap-2 shrink-0\"\n >\n <Button\n variant=\"text\"\n size=\"xs\"\n radius=\"medium\"\n label=\"Now\"\n :class=\"todayTextClass\"\n @click=\"handleNow\"\n />\n </div>\n </div>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, computed, watch, nextTick, onMounted } from \"vue\";\nimport gsap from \"gsap\";\nimport Calendar from \"../calendar/Calendar.vue\";\nimport Button from \"../../forms/Button.vue\";\nimport {\n useResolvedColor,\n useResolvedRadius,\n} from \"../../../composables/useModoConfig\";\nimport type { DateTimePicker } from \"../../../interfaces/data-display/date-picker/DateTimePicker.interface\";\n\nconst props = withDefaults(defineProps<DateTimePicker>(), {\n modelValue: null,\n locale: \"default\",\n firstDayOfWeek: 0,\n color: \"default\",\n variant: \"outline\",\n format: \"24h\",\n step: 5,\n showSeconds: false,\n timeOnly: false,\n});\n\nconst resolvedColor = useResolvedColor(() => props.color);\nconst resolvedRadius = useResolvedRadius(() => props.radius);\n\nconst emit = defineEmits<{\n \"update:modelValue\": [date: Date];\n}>();\n\ntype ColKey = \"hour\" | \"minute\" | \"second\" | \"period\";\n\nconst scrollRefs = ref<Record<ColKey, HTMLElement | null>>({\n hour: null,\n minute: null,\n second: null,\n period: null,\n});\nconst setScrollRef = (key: ColKey, el: HTMLElement | null) => {\n scrollRefs.value[key] = el;\n};\n\nconst initialDate = props.modelValue ?? new Date();\n\nconst dateOnly = ref<Date>(new Date(initialDate));\nconst hour = ref(initialDate.getHours());\nconst minute = ref(\n Math.round(initialDate.getMinutes() / props.step) * props.step,\n);\nconst second = ref(initialDate.getSeconds());\n\nconst parseTimeStr = (t?: string): number | null => {\n if (!t) return null;\n const [h, m, s] = t.split(\":\").map(Number);\n return h * 3600 + (m || 0) * 60 + (s || 0);\n};\nconst minTimeSec = computed(() => parseTimeStr(props.minTime));\nconst maxTimeSec = computed(() => parseTimeStr(props.maxTime));\n\nconst pad2 = (n: number) => n.toString().padStart(2, \"0\");\n\nconst is12h = computed(() => props.format === \"12h\");\n\nconst hourValues = computed(() => {\n if (is12h.value) {\n return Array.from({ length: 12 }, (_, i) => (i === 0 ? 12 : i));\n }\n return Array.from({ length: 24 }, (_, i) => i);\n});\n\nconst minuteValues = computed(() => {\n const values: number[] = [];\n for (let i = 0; i < 60; i += props.step) values.push(i);\n return values;\n});\n\nconst secondValues = computed(() => {\n const values: number[] = [];\n for (let i = 0; i < 60; i += props.step) values.push(i);\n return values;\n});\n\nconst currentPeriod = computed<\"AM\" | \"PM\">(() =>\n hour.value < 12 ? \"AM\" : \"PM\",\n);\n\nconst hourDisplay = computed(() => {\n if (!is12h.value) return hour.value;\n const h = hour.value % 12;\n return h === 0 ? 12 : h;\n});\n\nconst isTimeDisabled = (h: number, m: number, s: number): boolean => {\n const total = h * 3600 + m * 60 + s;\n if (minTimeSec.value !== null && total < minTimeSec.value) return true;\n if (maxTimeSec.value !== null && total > maxTimeSec.value) return true;\n return false;\n};\n\ninterface TimeItem {\n value: number;\n label: string;\n disabled: boolean;\n}\n\ninterface TimeColumn {\n key: ColKey;\n label: string;\n items: TimeItem[];\n selected: number;\n}\n\nconst columns = computed<TimeColumn[]>(() => {\n const cols: TimeColumn[] = [];\n\n cols.push({\n key: \"hour\",\n label: \"Hour\",\n selected: hourDisplay.value,\n items: hourValues.value.map((v) => {\n const h24 = is12h.value\n ? currentPeriod.value === \"AM\"\n ? v === 12\n ? 0\n : v\n : v === 12\n ? 12\n : v + 12\n : v;\n return {\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(h24, minute.value, second.value),\n };\n }),\n });\n\n cols.push({\n key: \"minute\",\n label: \"Min\",\n selected: minute.value,\n items: minuteValues.value.map((v) => ({\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(hour.value, v, second.value),\n })),\n });\n\n if (props.showSeconds) {\n cols.push({\n key: \"second\",\n label: \"Sec\",\n selected: second.value,\n items: secondValues.value.map((v) => ({\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(hour.value, minute.value, v),\n })),\n });\n }\n\n if (is12h.value) {\n cols.push({\n key: \"period\",\n label: \"AM/PM\",\n selected: currentPeriod.value === \"AM\" ? 0 : 1,\n items: [\n { value: 0, label: \"AM\", disabled: false },\n { value: 1, label: \"PM\", disabled: false },\n ],\n });\n }\n\n return cols;\n});\n\nconst timeLabel = computed(() => {\n const h = is12h.value ? hourDisplay.value : hour.value;\n let s = `${pad2(h)}:${pad2(minute.value)}`;\n if (props.showSeconds) s += `:${pad2(second.value)}`;\n if (is12h.value) s += ` ${currentPeriod.value}`;\n return s;\n});\n\nconst commitDate = () => {\n const d = new Date(dateOnly.value);\n d.setHours(hour.value, minute.value, props.showSeconds ? second.value : 0, 0);\n if (props.modelValue && d.getTime() === props.modelValue.getTime()) return;\n emit(\"update:modelValue\", d);\n};\n\nconst selectTimeItem = (col: ColKey, value: number) => {\n if (col === \"hour\") {\n if (is12h.value) {\n const base = value === 12 ? 0 : value;\n hour.value = currentPeriod.value === \"AM\" ? base : base + 12;\n } else {\n hour.value = value;\n }\n } else if (col === \"minute\") {\n minute.value = value;\n } else if (col === \"second\") {\n second.value = value;\n } else if (col === \"period\") {\n const targetAM = value === 0;\n if (targetAM && hour.value >= 12) hour.value -= 12;\n else if (!targetAM && hour.value < 12) hour.value += 12;\n }\n commitDate();\n scrollColumnToSelected(col);\n};\n\nconst scrollColumnToSelected = (col: ColKey, animate = true) => {\n nextTick(() => {\n const container = scrollRefs.value[col];\n if (!container) return;\n const colInfo = columns.value.find((c) => c.key === col);\n if (!colInfo) return;\n const targetBtn = container.querySelector<HTMLElement>(\n `button[data-col=\"${col}\"][data-value=\"${colInfo.selected}\"]`,\n );\n if (!targetBtn) return;\n const apply = () => {\n const targetTop =\n targetBtn.offsetTop -\n container.clientHeight / 2 +\n targetBtn.clientHeight / 2;\n if (animate) {\n gsap.to(container, {\n scrollTop: targetTop,\n duration: 0.3,\n ease: \"power2.out\",\n });\n } else {\n container.scrollTop = targetTop;\n }\n };\n // Defer hasta un segundo frame para que el layout esté asentado\n // (especialmente en mount, cuando el Calendar todavía no determinó altura final).\n requestAnimationFrame(() => requestAnimationFrame(apply));\n });\n};\n\nwatch(dateOnly, () => commitDate());\n\nwatch(\n () => props.modelValue,\n (v) => {\n if (!v) return;\n dateOnly.value = new Date(v);\n hour.value = v.getHours();\n minute.value = v.getMinutes();\n second.value = v.getSeconds();\n columns.value.forEach((c) => scrollColumnToSelected(c.key));\n },\n);\n\nonMounted(() => {\n if (!props.modelValue) commitDate();\n nextTick(() => {\n columns.value.forEach((c) => scrollColumnToSelected(c.key, false));\n });\n});\n\nconst handleNow = () => {\n const now = new Date();\n dateOnly.value = new Date(now);\n hour.value = now.getHours();\n minute.value = Math.round(now.getMinutes() / props.step) * props.step;\n second.value = now.getSeconds();\n commitDate();\n columns.value.forEach((c) => scrollColumnToSelected(c.key));\n};\n\nconst timePanelWidthClass = computed(() => {\n const n = columns.value.length;\n // Mobile: stretches to full calendar width. sm+: fixed width per column count.\n if (n <= 2) return \"sm:w-32\"; // 128px\n if (n === 3) return \"sm:w-48\"; // 192px sm+\n return \"sm:w-64\"; // 256px sm+\n});\n\nconst selectedItemClasses = computed(\n () =>\n ({\n default: \"bg-foreground text-background font-semibold\",\n primary: \"bg-primary text-primary-foreground font-semibold\",\n danger: \"bg-destructive text-destructive-foreground font-semibold\",\n success: \"bg-success text-success-foreground font-semibold\",\n warning: \"bg-warning text-warning-foreground font-semibold\",\n })[resolvedColor.value] ??\n \"bg-primary text-primary-foreground font-semibold\",\n);\n\nconst todayTextClass = computed(\n () =>\n ({\n default: \"text-foreground\",\n primary: \"text-primary\",\n danger: \"text-destructive\",\n success: \"text-success\",\n warning: \"text-warning\",\n })[resolvedColor.value] ?? \"text-primary\",\n);\n\nconst containerRadiusClass = computed(\n () =>\n ({\n none: \"rounded-none\",\n small: \"rounded-sm\",\n medium: \"rounded-md\",\n large: \"rounded-lg\",\n full: \"rounded-xl\",\n })[resolvedRadius.value] ?? \"rounded-lg\",\n);\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0GA,MAAM,QAAQ;EAYd,MAAM,gBAAgB,uBAAuB,MAAM,MAAM;EACzD,MAAM,iBAAiB,wBAAwB,MAAM,OAAO;EAE5D,MAAM,OAAO;EAMb,MAAM,aAAa,IAAwC;GACzD,MAAM;GACN,QAAQ;GACR,QAAQ;GACR,QAAQ;GACT,CAAC;EACF,MAAM,gBAAgB,KAAa,OAA2B;GAC5D,WAAW,MAAM,OAAO;;EAG1B,MAAM,cAAc,MAAM,8BAAc,IAAI,MAAM;EAElD,MAAM,WAAW,IAAU,IAAI,KAAK,YAAY,CAAC;EACjD,MAAM,OAAO,IAAI,YAAY,UAAU,CAAC;EACxC,MAAM,SAAS,IACb,KAAK,MAAM,YAAY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B,UAAK,WAAE,eAAe,IAAI,KAAK,KAAK,MAAK;OACzC,OAAK,eAAA,CAAA,8FAA0I,KAAK,WAAA,gDAAuG,KAAK,UAAU,IAAI,WAAmC,oBAAA,QAAA,oCAAA,CAAA;yBAS/S,KAAK,MAAK,EAAA,IAAA,WAAA;;;IAOvB,mBAWM,OAXN,YAWM,CARJ,YAOE,gBAAA;KANA,SAAQ;KACR,MAAK;KACL,QAAO;KACP,OAAM;KACL,OAAK,eAAE,eAAA,MAAc;KACrB,SAAO"}
|
|
1
|
+
{"version":3,"file":"DateTimePicker.vue_vue_type_script_setup_true_lang.mjs","names":[],"sources":["../../../../src/components/data-display/date-picker/DateTimePicker.vue"],"sourcesContent":["<template>\n <div\n :class=\"[\n 'relative inline-flex flex-col items-stretch bg-card w-fit self-start',\n !timeOnly ? 'sm:flex-row max-w-65 sm:max-w-none' : '',\n variant === 'outline' ? 'border border-border' : '',\n containerRadiusClass,\n ]\"\n >\n <Calendar\n v-if=\"!timeOnly\"\n v-model=\"dateOnly\"\n :locale=\"locale\"\n :first-day-of-week=\"firstDayOfWeek\"\n :min-date=\"minDate\"\n :max-date=\"maxDate\"\n :disabled-dates=\"disabledDates\"\n :color=\"color\"\n variant=\"filled\"\n :radius=\"radius\"\n />\n\n <div :class=\"['relative shrink-0', timePanelWidthClass]\">\n <div\n :class=\"[\n 'flex flex-col h-52',\n !timeOnly ? 'border-t border-border sm:border-t-0 sm:border-l sm:absolute sm:inset-0 sm:h-auto' : '',\n ]\"\n >\n <div class=\"px-3 py-3 border-b border-border text-center shrink-0\">\n <span class=\"text-sm font-semibold text-foreground\">{{\n timeLabel\n }}</span>\n </div>\n\n <div class=\"flex flex-1 min-h-0 overflow-hidden\">\n <div\n v-for=\"col in columns\"\n :key=\"col.key\"\n class=\"flex flex-col flex-1 border-r last:border-r-0 border-border\"\n >\n <div\n class=\"px-2 py-1.5 text-center text-xs font-medium text-muted-foreground border-b border-border\"\n >\n {{ col.label }}\n </div>\n <div\n :ref=\"\n (el: unknown) => setScrollRef(col.key, el as HTMLElement | null)\n \"\n class=\"flex-1 overflow-y-auto scroll-smooth\"\n style=\"scrollbar-width: thin\"\n >\n <div class=\"py-14\">\n <button\n v-for=\"item in col.items\"\n :key=\"item.value\"\n type=\"button\"\n :disabled=\"item.disabled\"\n :data-col=\"col.key\"\n :data-value=\"item.value\"\n @click=\"selectTimeItem(col.key, item.value)\"\n :class=\"[\n 'w-full px-2 py-1.5 text-sm text-center transition-colors cursor-pointer focus:outline-none',\n item.disabled\n ? 'text-muted-foreground/60 cursor-not-allowed'\n : item.value === col.selected\n ? selectedItemClasses\n : 'text-foreground/80 hover:bg-muted',\n ]\"\n >\n {{ item.label }}\n </button>\n </div>\n </div>\n </div>\n </div>\n\n <div\n class=\"px-3 py-2 border-t border-border flex justify-end gap-2 shrink-0\"\n >\n <Button\n variant=\"text\"\n size=\"xs\"\n radius=\"medium\"\n label=\"Now\"\n :class=\"todayTextClass\"\n @click=\"handleNow\"\n />\n </div>\n </div>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, computed, watch, nextTick, onMounted } from \"vue\";\nimport gsap from \"gsap\";\nimport Calendar from \"../calendar/Calendar.vue\";\nimport Button from \"../../forms/Button.vue\";\nimport {\n useResolvedColor,\n useResolvedRadius,\n} from \"../../../composables/useModoConfig\";\nimport type { DateTimePicker } from \"../../../interfaces/data-display/date-picker/DateTimePicker.interface\";\n\nconst props = withDefaults(defineProps<DateTimePicker>(), {\n modelValue: null,\n locale: \"default\",\n firstDayOfWeek: 0,\n color: \"default\",\n variant: \"outline\",\n format: \"24h\",\n step: 5,\n showSeconds: false,\n timeOnly: false,\n});\n\nconst resolvedColor = useResolvedColor(() => props.color);\nconst resolvedRadius = useResolvedRadius(() => props.radius);\n\nconst emit = defineEmits<{\n \"update:modelValue\": [date: Date];\n}>();\n\ntype ColKey = \"hour\" | \"minute\" | \"second\" | \"period\";\n\nconst scrollRefs = ref<Record<ColKey, HTMLElement | null>>({\n hour: null,\n minute: null,\n second: null,\n period: null,\n});\nconst setScrollRef = (key: ColKey, el: HTMLElement | null) => {\n scrollRefs.value[key] = el;\n};\n\nconst initialDate = props.modelValue ?? new Date();\n\nconst dateOnly = ref<Date>(new Date(initialDate));\nconst hour = ref(initialDate.getHours());\nconst minute = ref(\n Math.round(initialDate.getMinutes() / props.step) * props.step,\n);\nconst second = ref(initialDate.getSeconds());\n\nconst parseTimeStr = (t?: string): number | null => {\n if (!t) return null;\n const [h, m, s] = t.split(\":\").map(Number);\n return h * 3600 + (m || 0) * 60 + (s || 0);\n};\nconst minTimeSec = computed(() => parseTimeStr(props.minTime));\nconst maxTimeSec = computed(() => parseTimeStr(props.maxTime));\n\nconst pad2 = (n: number) => n.toString().padStart(2, \"0\");\n\nconst is12h = computed(() => props.format === \"12h\");\n\nconst hourValues = computed(() => {\n if (is12h.value) {\n return Array.from({ length: 12 }, (_, i) => (i === 0 ? 12 : i));\n }\n return Array.from({ length: 24 }, (_, i) => i);\n});\n\nconst minuteValues = computed(() => {\n const values: number[] = [];\n for (let i = 0; i < 60; i += props.step) values.push(i);\n return values;\n});\n\nconst secondValues = computed(() => {\n const values: number[] = [];\n for (let i = 0; i < 60; i += props.step) values.push(i);\n return values;\n});\n\nconst currentPeriod = computed<\"AM\" | \"PM\">(() =>\n hour.value < 12 ? \"AM\" : \"PM\",\n);\n\nconst hourDisplay = computed(() => {\n if (!is12h.value) return hour.value;\n const h = hour.value % 12;\n return h === 0 ? 12 : h;\n});\n\nconst isTimeDisabled = (h: number, m: number, s: number): boolean => {\n const total = h * 3600 + m * 60 + s;\n if (minTimeSec.value !== null && total < minTimeSec.value) return true;\n if (maxTimeSec.value !== null && total > maxTimeSec.value) return true;\n return false;\n};\n\ninterface TimeItem {\n value: number;\n label: string;\n disabled: boolean;\n}\n\ninterface TimeColumn {\n key: ColKey;\n label: string;\n items: TimeItem[];\n selected: number;\n}\n\nconst columns = computed<TimeColumn[]>(() => {\n const cols: TimeColumn[] = [];\n\n cols.push({\n key: \"hour\",\n label: \"Hour\",\n selected: hourDisplay.value,\n items: hourValues.value.map((v) => {\n const h24 = is12h.value\n ? currentPeriod.value === \"AM\"\n ? v === 12\n ? 0\n : v\n : v === 12\n ? 12\n : v + 12\n : v;\n return {\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(h24, minute.value, second.value),\n };\n }),\n });\n\n cols.push({\n key: \"minute\",\n label: \"Min\",\n selected: minute.value,\n items: minuteValues.value.map((v) => ({\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(hour.value, v, second.value),\n })),\n });\n\n if (props.showSeconds) {\n cols.push({\n key: \"second\",\n label: \"Sec\",\n selected: second.value,\n items: secondValues.value.map((v) => ({\n value: v,\n label: pad2(v),\n disabled: isTimeDisabled(hour.value, minute.value, v),\n })),\n });\n }\n\n if (is12h.value) {\n cols.push({\n key: \"period\",\n label: \"AM/PM\",\n selected: currentPeriod.value === \"AM\" ? 0 : 1,\n items: [\n { value: 0, label: \"AM\", disabled: false },\n { value: 1, label: \"PM\", disabled: false },\n ],\n });\n }\n\n return cols;\n});\n\nconst timeLabel = computed(() => {\n const h = is12h.value ? hourDisplay.value : hour.value;\n let s = `${pad2(h)}:${pad2(minute.value)}`;\n if (props.showSeconds) s += `:${pad2(second.value)}`;\n if (is12h.value) s += ` ${currentPeriod.value}`;\n return s;\n});\n\nconst commitDate = () => {\n const d = new Date(dateOnly.value);\n d.setHours(hour.value, minute.value, props.showSeconds ? second.value : 0, 0);\n if (props.modelValue && d.getTime() === props.modelValue.getTime()) return;\n emit(\"update:modelValue\", d);\n};\n\nconst selectTimeItem = (col: ColKey, value: number) => {\n if (col === \"hour\") {\n if (is12h.value) {\n const base = value === 12 ? 0 : value;\n hour.value = currentPeriod.value === \"AM\" ? base : base + 12;\n } else {\n hour.value = value;\n }\n } else if (col === \"minute\") {\n minute.value = value;\n } else if (col === \"second\") {\n second.value = value;\n } else if (col === \"period\") {\n const targetAM = value === 0;\n if (targetAM && hour.value >= 12) hour.value -= 12;\n else if (!targetAM && hour.value < 12) hour.value += 12;\n }\n commitDate();\n scrollColumnToSelected(col);\n};\n\nconst scrollColumnToSelected = (col: ColKey, animate = true) => {\n nextTick(() => {\n const container = scrollRefs.value[col];\n if (!container) return;\n const colInfo = columns.value.find((c) => c.key === col);\n if (!colInfo) return;\n const targetBtn = container.querySelector<HTMLElement>(\n `button[data-col=\"${col}\"][data-value=\"${colInfo.selected}\"]`,\n );\n if (!targetBtn) return;\n const apply = () => {\n // Measured against the scroll container itself rather than\n // `targetBtn.offsetTop`: the nearest positioned ancestor is the time\n // panel wrapper, not this container, so offsetTop also carries the\n // \"Time\" header and the column label. That constant error is what\n // pushed the selected option up behind the hour/min label — most\n // visible in `timeOnly`, where the column is only h-52 tall.\n const offsetWithinScroller =\n targetBtn.getBoundingClientRect().top\n - container.getBoundingClientRect().top\n + container.scrollTop;\n const targetTop =\n offsetWithinScroller -\n container.clientHeight / 2 +\n targetBtn.clientHeight / 2;\n if (animate) {\n gsap.to(container, {\n scrollTop: targetTop,\n duration: 0.3,\n ease: \"power2.out\",\n });\n } else {\n container.scrollTop = targetTop;\n }\n };\n // Defer hasta un segundo frame para que el layout esté asentado\n // (especialmente en mount, cuando el Calendar todavía no determinó altura final).\n requestAnimationFrame(() => requestAnimationFrame(apply));\n });\n};\n\nwatch(dateOnly, () => commitDate());\n\nwatch(\n () => props.modelValue,\n (v) => {\n if (!v) return;\n dateOnly.value = new Date(v);\n hour.value = v.getHours();\n minute.value = v.getMinutes();\n second.value = v.getSeconds();\n columns.value.forEach((c) => scrollColumnToSelected(c.key));\n },\n);\n\nonMounted(() => {\n if (!props.modelValue) commitDate();\n nextTick(() => {\n columns.value.forEach((c) => scrollColumnToSelected(c.key, false));\n });\n});\n\nconst handleNow = () => {\n const now = new Date();\n dateOnly.value = new Date(now);\n hour.value = now.getHours();\n minute.value = Math.round(now.getMinutes() / props.step) * props.step;\n second.value = now.getSeconds();\n commitDate();\n columns.value.forEach((c) => scrollColumnToSelected(c.key));\n};\n\nconst timePanelWidthClass = computed(() => {\n const n = columns.value.length;\n // Mobile: stretches to full calendar width. sm+: fixed width per column count.\n if (n <= 2) return \"sm:w-32\"; // 128px\n if (n === 3) return \"sm:w-48\"; // 192px sm+\n return \"sm:w-64\"; // 256px sm+\n});\n\nconst selectedItemClasses = computed(\n () =>\n ({\n default: \"bg-foreground text-background font-semibold\",\n primary: \"bg-primary text-primary-foreground font-semibold\",\n danger: \"bg-destructive text-destructive-foreground font-semibold\",\n success: \"bg-success text-success-foreground font-semibold\",\n warning: \"bg-warning text-warning-foreground font-semibold\",\n })[resolvedColor.value] ??\n \"bg-primary text-primary-foreground font-semibold\",\n);\n\nconst todayTextClass = computed(\n () =>\n ({\n default: \"text-foreground\",\n primary: \"text-primary\",\n danger: \"text-destructive\",\n success: \"text-success\",\n warning: \"text-warning\",\n })[resolvedColor.value] ?? \"text-primary\",\n);\n\nconst containerRadiusClass = computed(\n () =>\n ({\n none: \"rounded-none\",\n small: \"rounded-sm\",\n medium: \"rounded-md\",\n large: \"rounded-lg\",\n full: \"rounded-xl\",\n })[resolvedRadius.value] ?? \"rounded-lg\",\n);\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0GA,MAAM,QAAQ;EAYd,MAAM,gBAAgB,uBAAuB,MAAM,MAAM;EACzD,MAAM,iBAAiB,wBAAwB,MAAM,OAAO;EAE5D,MAAM,OAAO;EAMb,MAAM,aAAa,IAAwC;GACzD,MAAM;GACN,QAAQ;GACR,QAAQ;GACR,QAAQ;GACT,CAAC;EACF,MAAM,gBAAgB,KAAa,OAA2B;GAC5D,WAAW,MAAM,OAAO;;EAG1B,MAAM,cAAc,MAAM,8BAAc,IAAI,MAAM;EAElD,MAAM,WAAW,IAAU,IAAI,KAAK,YAAY,CAAC;EACjD,MAAM,OAAO,IAAI,YAAY,UAAU,CAAC;EACxC,MAAM,SAAS,IACb,KAAK,MAAM,YAAY,YAA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J,UAAU,KAAK;OACf,YAAU,IAAI;OACd,cAAY,KAAK;OACjB,UAAK,WAAE,eAAe,IAAI,KAAK,KAAK,MAAK;OACzC,OAAK,eAAA,CAAA,8FAA0I,KAAK,WAAA,gDAAuG,KAAK,UAAU,IAAI,WAAmC,oBAAA,QAAA,oCAAA,CAAA;yBAS/S,KAAK,MAAK,EAAA,IAAA,WAAA;;;IAOvB,mBAWM,OAXN,YAWM,CARJ,YAOE,gBAAA;KANA,SAAQ;KACR,MAAK;KACL,QAAO;KACP,OAAM;KACL,OAAK,eAAE,eAAA,MAAc;KACrB,SAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.cjs","names":[],"sources":["../../../src/components/feedback/Drawer.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-drawer-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-drawer-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-drawer relative flex flex-col bg-card text-foreground', \n 'dark:bg-card/85 dark:backdrop-blur-xl', \n 'border-border shadow-xl', \n sideBorderClass, \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 --> \n <div v-if=\"showClose\" class=\"absolute top-3 right-3 z-10\"> \n <Button \n variant=\"text\" \n size=\"small\" \n :color=\"resolvedColor\" \n :icon=\"XMarkIcon\" \n ariaLabel=\"Close\" \n @click=\"close\" \n /> \n </div> \n \n <!-- Content wrapper --> \n <div ref=\"contentRef\" data-modo-drawer-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 --> \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 { Drawer } from '../../interfaces/feedback/Drawer.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<Drawer>(), { \n modelValue: false, \n side: 'right', \n size: 'medium', \n closeOnOverlay: true, \n closeOnEscape: true, \n showClose: true, \n lockScroll: true, \n color: 'default', \n overlay: 'blur', \n innerBorder: 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-drawer-${autoId}-title`); \nconst descriptionId = computed(() => `modo-drawer-${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 (slide from edge) ---------- */ \n \nfunction prefersReducedMotion() { \n return typeof window !== 'undefined' \n && window.matchMedia('(prefers-reduced-motion: reduce)').matches; \n} \n \nlet activeTimeline: gsap.core.Timeline | null = null; \n \nfunction getEnterTransform() { \n switch (props.side) { \n case 'left': return { x: '-100%', y: 0 }; \n case 'right': return { x: '100%', y: 0 }; \n case 'top': return { x: 0, y: '-100%' }; \n case 'bottom': return { x: 0, y: '100%' }; \n default: return { x: '100%', y: 0 }; \n } \n} \n \nfunction onOverlayEnter(el: Element, done: () => void) { \n const overlay = (el as HTMLElement) ?? overlayRef.value; \n const panel = \n overlay?.querySelector<HTMLElement>('[data-modo-drawer-panel]') \n ?? panelRef.value; \n const content = \n overlay?.querySelector<HTMLElement>('[data-modo-drawer-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 enter = getEnterTransform(); \n const tl = gsap.timeline({ onComplete: () => { activeTimeline = null; done(); } }); \n activeTimeline = tl; \n \n tl.fromTo(overlay, { opacity: 0 }, { opacity: 1, duration: 0.25, ease: 'power2.out' }, 0); \n \n tl.fromTo( \n panel, \n { x: enter.x, y: enter.y, opacity: 1 }, \n { x: 0, y: 0, opacity: 1, duration: 0.4, ease: 'power3.out' }, \n 0, \n ); \n \n tl.fromTo( \n content, \n { opacity: 0 }, \n { opacity: 1, duration: 0.22, ease: 'power2.out' }, \n 0.18, \n ); \n} \n \nfunction onOverlayLeave(el: Element, done: () => void) { \n const overlay = el as HTMLElement; \n const panel = \n overlay.querySelector<HTMLElement>('[data-modo-drawer-panel]') \n ?? panelRef.value; \n const content = \n overlay.querySelector<HTMLElement>('[data-modo-drawer-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 enter = getEnterTransform(); \n const tl = gsap.timeline({ \n onComplete: () => { \n activeTimeline = null; \n releaseScrollLock(); \n done(); \n }, \n }); \n activeTimeline = tl; \n \n tl.to(content, { opacity: 0, duration: 0.14, ease: 'power1.in' }, 0); \n tl.to( \n panel, \n { x: enter.x, y: enter.y, duration: 0.32, ease: 'power3.in' }, \n 0.08, \n ); \n tl.to(overlay, { opacity: 0, duration: 0.28, ease: 'power2.in' }, 0.12); \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 \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 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 ---------- */ \n \nconst isHorizontal = computed(() => props.side === 'left' || props.side === 'right'); \n \nconst positionClasses = computed(() => { \n switch (props.side) { \n case 'left': return 'flex-row items-stretch justify-start'; \n case 'right': return 'flex-row items-stretch justify-end'; \n case 'top': return 'flex-col items-stretch justify-start'; \n case 'bottom': return 'flex-col items-stretch justify-end'; \n default: return 'flex-row items-stretch justify-end'; \n } \n}); \n \nconst sizeClasses = computed(() => { \n if (isHorizontal.value) { \n // Width + full height \n const heightCls = 'h-full'; \n switch (props.size) { \n case 'small': return `${heightCls} w-[20rem] max-w-[90vw]`; \n case 'large': return `${heightCls} w-[36rem] max-w-[95vw]`; \n case 'full': return `${heightCls} w-screen`; \n default: return `${heightCls} w-[28rem] max-w-[92vw]`; \n } \n } else { \n // Height + full width \n const widthCls = 'w-full'; \n switch (props.size) { \n case 'small': return `${widthCls} h-[18rem] max-h-[80vh]`; \n case 'large': return `${widthCls} h-[32rem] max-h-[90vh]`; \n case 'full': return `${widthCls} h-screen`; \n default: return `${widthCls} h-[24rem] max-h-[85vh]`; \n } \n } \n}); \n \nconst sideBorderClass = computed(() => { \n switch (props.side) { \n case 'left': return 'border-r'; \n case 'right': return 'border-l'; \n case 'top': return 'border-b'; \n case 'bottom': return 'border-t'; \n default: return 'border-l'; \n } \n}); \n \n/** \n * El radius se aplica solo a las dos esquinas opuestas al borde de entrada \n * (las que quedan visibles dentro del viewport). El lado pegado al borde \n * queda recto. \n */ \nconst radiusClasses = computed(() => { \n if (props.size === 'full') return 'rounded-none'; \n // Mapeo explícito (Tailwind JIT requiere class names literales). \n const map = { \n none: { \n left: 'rounded-none', right: 'rounded-none', \n top: 'rounded-none', bottom: 'rounded-none', \n }, \n small: { \n left: 'rounded-r-md', right: 'rounded-l-md', \n top: 'rounded-b-md', bottom: 'rounded-t-md', \n }, \n medium: { \n left: 'rounded-r-xl', right: 'rounded-l-xl', \n top: 'rounded-b-xl', bottom: 'rounded-t-xl', \n }, \n large: { \n left: 'rounded-r-2xl', right: 'rounded-l-2xl', \n top: 'rounded-b-2xl', bottom: 'rounded-t-2xl', \n }, \n full: { \n left: 'rounded-r-3xl', right: 'rounded-l-3xl', \n top: 'rounded-b-3xl', bottom: 'rounded-t-3xl', \n }, \n } as const; \n const r = (resolvedRadius.value ?? 'medium') as keyof typeof map; \n const safeR = map[r] ? r : 'medium'; \n return map[safeR][props.side]; \n}); \n \nconst innerBorderRadiusClass = computed(() => { \n if (props.size === 'full') return 'rounded-none'; \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 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":""}
|
|
1
|
+
{"version":3,"file":"Drawer.cjs","names":[],"sources":["../../../src/components/feedback/Drawer.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-drawer-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-drawer-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-drawer relative flex flex-col bg-card text-foreground', \n 'dark:bg-card/85 dark:backdrop-blur-xl', \n 'border-border shadow-xl', \n sideBorderClass, \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 --> \n <div v-if=\"showClose\" class=\"absolute top-3 right-3 z-10\"> \n <Button \n variant=\"text\" \n size=\"small\" \n :color=\"resolvedColor\" \n :icon=\"XMarkIcon\" \n ariaLabel=\"Close\" \n @click=\"close\" \n /> \n </div> \n \n <!-- Content wrapper --> \n <div ref=\"contentRef\" data-modo-drawer-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 --> \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 { Drawer } from '../../interfaces/feedback/Drawer.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<Drawer>(), { \n modelValue: false, \n side: 'right', \n size: 'medium', \n closeOnOverlay: true, \n closeOnEscape: true, \n showClose: true, \n lockScroll: true, \n color: 'default', \n overlay: 'blur', \n innerBorder: 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-drawer-${autoId}-title`); \nconst descriptionId = computed(() => `modo-drawer-${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 (slide from edge) ---------- */ \n \nfunction prefersReducedMotion() { \n return typeof window !== 'undefined' \n && window.matchMedia('(prefers-reduced-motion: reduce)').matches; \n} \n \nlet activeTimeline: gsap.core.Timeline | null = null; \n \nfunction getEnterTransform() { \n switch (props.side) { \n case 'left': return { x: '-100%', y: 0 }; \n case 'right': return { x: '100%', y: 0 }; \n case 'top': return { x: 0, y: '-100%' }; \n case 'bottom': return { x: 0, y: '100%' }; \n default: return { x: '100%', y: 0 }; \n } \n} \n \nfunction onOverlayEnter(el: Element, done: () => void) { \n const overlay = (el as HTMLElement) ?? overlayRef.value; \n const panel = \n overlay?.querySelector<HTMLElement>('[data-modo-drawer-panel]') \n ?? panelRef.value; \n const content = \n overlay?.querySelector<HTMLElement>('[data-modo-drawer-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 enter = getEnterTransform(); \n const tl = gsap.timeline({ onComplete: () => { activeTimeline = null; done(); } }); \n activeTimeline = tl; \n \n tl.fromTo(overlay, { opacity: 0 }, { opacity: 1, duration: 0.25, ease: 'power2.out' }, 0); \n \n tl.fromTo( \n panel, \n { x: enter.x, y: enter.y, opacity: 1 }, \n { x: 0, y: 0, opacity: 1, duration: 0.4, ease: 'power3.out' }, \n 0, \n ); \n \n tl.fromTo( \n content, \n { opacity: 0 }, \n { opacity: 1, duration: 0.22, ease: 'power2.out' }, \n 0.18, \n ); \n} \n \nfunction onOverlayLeave(el: Element, done: () => void) { \n const overlay = el as HTMLElement; \n const panel = \n overlay.querySelector<HTMLElement>('[data-modo-drawer-panel]') \n ?? panelRef.value; \n const content = \n overlay.querySelector<HTMLElement>('[data-modo-drawer-content]')\n ?? contentRef.value;\n // Bail out without animating, but never without releasing the lock.\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 enter = getEnterTransform(); \n const tl = gsap.timeline({ \n onComplete: () => { \n activeTimeline = null; \n releaseScrollLock(); \n done(); \n }, \n }); \n activeTimeline = tl; \n \n tl.to(content, { opacity: 0, duration: 0.14, ease: 'power1.in' }, 0); \n tl.to( \n panel, \n { x: enter.x, y: enter.y, duration: 0.32, ease: 'power3.in' }, \n 0.08, \n ); \n tl.to(overlay, { opacity: 0, duration: 0.28, ease: 'power2.in' }, 0.12); \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 \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 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 ---------- */ \n \nconst isHorizontal = computed(() => props.side === 'left' || props.side === 'right'); \n \nconst positionClasses = computed(() => { \n switch (props.side) { \n case 'left': return 'flex-row items-stretch justify-start'; \n case 'right': return 'flex-row items-stretch justify-end'; \n case 'top': return 'flex-col items-stretch justify-start'; \n case 'bottom': return 'flex-col items-stretch justify-end'; \n default: return 'flex-row items-stretch justify-end'; \n } \n}); \n \nconst sizeClasses = computed(() => { \n if (isHorizontal.value) { \n // Width + full height \n const heightCls = 'h-full'; \n switch (props.size) { \n case 'small': return `${heightCls} w-[20rem] max-w-[90vw]`; \n case 'large': return `${heightCls} w-[36rem] max-w-[95vw]`; \n case 'full': return `${heightCls} w-screen`; \n default: return `${heightCls} w-[28rem] max-w-[92vw]`; \n } \n } else { \n // Height + full width \n const widthCls = 'w-full'; \n switch (props.size) { \n case 'small': return `${widthCls} h-[18rem] max-h-[80vh]`; \n case 'large': return `${widthCls} h-[32rem] max-h-[90vh]`; \n case 'full': return `${widthCls} h-screen`; \n default: return `${widthCls} h-[24rem] max-h-[85vh]`; \n } \n } \n}); \n \nconst sideBorderClass = computed(() => { \n switch (props.side) { \n case 'left': return 'border-r'; \n case 'right': return 'border-l'; \n case 'top': return 'border-b'; \n case 'bottom': return 'border-t'; \n default: return 'border-l'; \n } \n}); \n \n/** \n * El radius se aplica solo a las dos esquinas opuestas al borde de entrada \n * (las que quedan visibles dentro del viewport). El lado pegado al borde \n * queda recto. \n */ \nconst radiusClasses = computed(() => { \n if (props.size === 'full') return 'rounded-none'; \n // Mapeo explícito (Tailwind JIT requiere class names literales). \n const map = { \n none: { \n left: 'rounded-none', right: 'rounded-none', \n top: 'rounded-none', bottom: 'rounded-none', \n }, \n small: { \n left: 'rounded-r-md', right: 'rounded-l-md', \n top: 'rounded-b-md', bottom: 'rounded-t-md', \n }, \n medium: { \n left: 'rounded-r-xl', right: 'rounded-l-xl', \n top: 'rounded-b-xl', bottom: 'rounded-t-xl', \n }, \n large: { \n left: 'rounded-r-2xl', right: 'rounded-l-2xl', \n top: 'rounded-b-2xl', bottom: 'rounded-t-2xl', \n }, \n full: { \n left: 'rounded-r-3xl', right: 'rounded-l-3xl', \n top: 'rounded-b-3xl', bottom: 'rounded-t-3xl', \n }, \n } as const; \n const r = (resolvedRadius.value ?? 'medium') as keyof typeof map; \n const safeR = map[r] ? r : 'medium'; \n return map[safeR][props.side]; \n}); \n \nconst innerBorderRadiusClass = computed(() => { \n if (props.size === 'full') return 'rounded-none'; \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 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":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.mjs","names":[],"sources":["../../../src/components/feedback/Drawer.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-drawer-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-drawer-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-drawer relative flex flex-col bg-card text-foreground', \n 'dark:bg-card/85 dark:backdrop-blur-xl', \n 'border-border shadow-xl', \n sideBorderClass, \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 --> \n <div v-if=\"showClose\" class=\"absolute top-3 right-3 z-10\"> \n <Button \n variant=\"text\" \n size=\"small\" \n :color=\"resolvedColor\" \n :icon=\"XMarkIcon\" \n ariaLabel=\"Close\" \n @click=\"close\" \n /> \n </div> \n \n <!-- Content wrapper --> \n <div ref=\"contentRef\" data-modo-drawer-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 --> \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 { Drawer } from '../../interfaces/feedback/Drawer.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<Drawer>(), { \n modelValue: false, \n side: 'right', \n size: 'medium', \n closeOnOverlay: true, \n closeOnEscape: true, \n showClose: true, \n lockScroll: true, \n color: 'default', \n overlay: 'blur', \n innerBorder: 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-drawer-${autoId}-title`); \nconst descriptionId = computed(() => `modo-drawer-${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 (slide from edge) ---------- */ \n \nfunction prefersReducedMotion() { \n return typeof window !== 'undefined' \n && window.matchMedia('(prefers-reduced-motion: reduce)').matches; \n} \n \nlet activeTimeline: gsap.core.Timeline | null = null; \n \nfunction getEnterTransform() { \n switch (props.side) { \n case 'left': return { x: '-100%', y: 0 }; \n case 'right': return { x: '100%', y: 0 }; \n case 'top': return { x: 0, y: '-100%' }; \n case 'bottom': return { x: 0, y: '100%' }; \n default: return { x: '100%', y: 0 }; \n } \n} \n \nfunction onOverlayEnter(el: Element, done: () => void) { \n const overlay = (el as HTMLElement) ?? overlayRef.value; \n const panel = \n overlay?.querySelector<HTMLElement>('[data-modo-drawer-panel]') \n ?? panelRef.value; \n const content = \n overlay?.querySelector<HTMLElement>('[data-modo-drawer-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 enter = getEnterTransform(); \n const tl = gsap.timeline({ onComplete: () => { activeTimeline = null; done(); } }); \n activeTimeline = tl; \n \n tl.fromTo(overlay, { opacity: 0 }, { opacity: 1, duration: 0.25, ease: 'power2.out' }, 0); \n \n tl.fromTo( \n panel, \n { x: enter.x, y: enter.y, opacity: 1 }, \n { x: 0, y: 0, opacity: 1, duration: 0.4, ease: 'power3.out' }, \n 0, \n ); \n \n tl.fromTo( \n content, \n { opacity: 0 }, \n { opacity: 1, duration: 0.22, ease: 'power2.out' }, \n 0.18, \n ); \n} \n \nfunction onOverlayLeave(el: Element, done: () => void) { \n const overlay = el as HTMLElement; \n const panel = \n overlay.querySelector<HTMLElement>('[data-modo-drawer-panel]') \n ?? panelRef.value; \n const content = \n overlay.querySelector<HTMLElement>('[data-modo-drawer-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 enter = getEnterTransform(); \n const tl = gsap.timeline({ \n onComplete: () => { \n activeTimeline = null; \n releaseScrollLock(); \n done(); \n }, \n }); \n activeTimeline = tl; \n \n tl.to(content, { opacity: 0, duration: 0.14, ease: 'power1.in' }, 0); \n tl.to( \n panel, \n { x: enter.x, y: enter.y, duration: 0.32, ease: 'power3.in' }, \n 0.08, \n ); \n tl.to(overlay, { opacity: 0, duration: 0.28, ease: 'power2.in' }, 0.12); \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 \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 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 ---------- */ \n \nconst isHorizontal = computed(() => props.side === 'left' || props.side === 'right'); \n \nconst positionClasses = computed(() => { \n switch (props.side) { \n case 'left': return 'flex-row items-stretch justify-start'; \n case 'right': return 'flex-row items-stretch justify-end'; \n case 'top': return 'flex-col items-stretch justify-start'; \n case 'bottom': return 'flex-col items-stretch justify-end'; \n default: return 'flex-row items-stretch justify-end'; \n } \n}); \n \nconst sizeClasses = computed(() => { \n if (isHorizontal.value) { \n // Width + full height \n const heightCls = 'h-full'; \n switch (props.size) { \n case 'small': return `${heightCls} w-[20rem] max-w-[90vw]`; \n case 'large': return `${heightCls} w-[36rem] max-w-[95vw]`; \n case 'full': return `${heightCls} w-screen`; \n default: return `${heightCls} w-[28rem] max-w-[92vw]`; \n } \n } else { \n // Height + full width \n const widthCls = 'w-full'; \n switch (props.size) { \n case 'small': return `${widthCls} h-[18rem] max-h-[80vh]`; \n case 'large': return `${widthCls} h-[32rem] max-h-[90vh]`; \n case 'full': return `${widthCls} h-screen`; \n default: return `${widthCls} h-[24rem] max-h-[85vh]`; \n } \n } \n}); \n \nconst sideBorderClass = computed(() => { \n switch (props.side) { \n case 'left': return 'border-r'; \n case 'right': return 'border-l'; \n case 'top': return 'border-b'; \n case 'bottom': return 'border-t'; \n default: return 'border-l'; \n } \n}); \n \n/** \n * El radius se aplica solo a las dos esquinas opuestas al borde de entrada \n * (las que quedan visibles dentro del viewport). El lado pegado al borde \n * queda recto. \n */ \nconst radiusClasses = computed(() => { \n if (props.size === 'full') return 'rounded-none'; \n // Mapeo explícito (Tailwind JIT requiere class names literales). \n const map = { \n none: { \n left: 'rounded-none', right: 'rounded-none', \n top: 'rounded-none', bottom: 'rounded-none', \n }, \n small: { \n left: 'rounded-r-md', right: 'rounded-l-md', \n top: 'rounded-b-md', bottom: 'rounded-t-md', \n }, \n medium: { \n left: 'rounded-r-xl', right: 'rounded-l-xl', \n top: 'rounded-b-xl', bottom: 'rounded-t-xl', \n }, \n large: { \n left: 'rounded-r-2xl', right: 'rounded-l-2xl', \n top: 'rounded-b-2xl', bottom: 'rounded-t-2xl', \n }, \n full: { \n left: 'rounded-r-3xl', right: 'rounded-l-3xl', \n top: 'rounded-b-3xl', bottom: 'rounded-t-3xl', \n }, \n } as const; \n const r = (resolvedRadius.value ?? 'medium') as keyof typeof map; \n const safeR = map[r] ? r : 'medium'; \n return map[safeR][props.side]; \n}); \n \nconst innerBorderRadiusClass = computed(() => { \n if (props.size === 'full') return 'rounded-none'; \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 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":""}
|
|
1
|
+
{"version":3,"file":"Drawer.mjs","names":[],"sources":["../../../src/components/feedback/Drawer.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-drawer-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-drawer-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-drawer relative flex flex-col bg-card text-foreground', \n 'dark:bg-card/85 dark:backdrop-blur-xl', \n 'border-border shadow-xl', \n sideBorderClass, \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 --> \n <div v-if=\"showClose\" class=\"absolute top-3 right-3 z-10\"> \n <Button \n variant=\"text\" \n size=\"small\" \n :color=\"resolvedColor\" \n :icon=\"XMarkIcon\" \n ariaLabel=\"Close\" \n @click=\"close\" \n /> \n </div> \n \n <!-- Content wrapper --> \n <div ref=\"contentRef\" data-modo-drawer-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 --> \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 { Drawer } from '../../interfaces/feedback/Drawer.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<Drawer>(), { \n modelValue: false, \n side: 'right', \n size: 'medium', \n closeOnOverlay: true, \n closeOnEscape: true, \n showClose: true, \n lockScroll: true, \n color: 'default', \n overlay: 'blur', \n innerBorder: 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-drawer-${autoId}-title`); \nconst descriptionId = computed(() => `modo-drawer-${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 (slide from edge) ---------- */ \n \nfunction prefersReducedMotion() { \n return typeof window !== 'undefined' \n && window.matchMedia('(prefers-reduced-motion: reduce)').matches; \n} \n \nlet activeTimeline: gsap.core.Timeline | null = null; \n \nfunction getEnterTransform() { \n switch (props.side) { \n case 'left': return { x: '-100%', y: 0 }; \n case 'right': return { x: '100%', y: 0 }; \n case 'top': return { x: 0, y: '-100%' }; \n case 'bottom': return { x: 0, y: '100%' }; \n default: return { x: '100%', y: 0 }; \n } \n} \n \nfunction onOverlayEnter(el: Element, done: () => void) { \n const overlay = (el as HTMLElement) ?? overlayRef.value; \n const panel = \n overlay?.querySelector<HTMLElement>('[data-modo-drawer-panel]') \n ?? panelRef.value; \n const content = \n overlay?.querySelector<HTMLElement>('[data-modo-drawer-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 enter = getEnterTransform(); \n const tl = gsap.timeline({ onComplete: () => { activeTimeline = null; done(); } }); \n activeTimeline = tl; \n \n tl.fromTo(overlay, { opacity: 0 }, { opacity: 1, duration: 0.25, ease: 'power2.out' }, 0); \n \n tl.fromTo( \n panel, \n { x: enter.x, y: enter.y, opacity: 1 }, \n { x: 0, y: 0, opacity: 1, duration: 0.4, ease: 'power3.out' }, \n 0, \n ); \n \n tl.fromTo( \n content, \n { opacity: 0 }, \n { opacity: 1, duration: 0.22, ease: 'power2.out' }, \n 0.18, \n ); \n} \n \nfunction onOverlayLeave(el: Element, done: () => void) { \n const overlay = el as HTMLElement; \n const panel = \n overlay.querySelector<HTMLElement>('[data-modo-drawer-panel]') \n ?? panelRef.value; \n const content = \n overlay.querySelector<HTMLElement>('[data-modo-drawer-content]')\n ?? contentRef.value;\n // Bail out without animating, but never without releasing the lock.\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 enter = getEnterTransform(); \n const tl = gsap.timeline({ \n onComplete: () => { \n activeTimeline = null; \n releaseScrollLock(); \n done(); \n }, \n }); \n activeTimeline = tl; \n \n tl.to(content, { opacity: 0, duration: 0.14, ease: 'power1.in' }, 0); \n tl.to( \n panel, \n { x: enter.x, y: enter.y, duration: 0.32, ease: 'power3.in' }, \n 0.08, \n ); \n tl.to(overlay, { opacity: 0, duration: 0.28, ease: 'power2.in' }, 0.12); \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 \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 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 ---------- */ \n \nconst isHorizontal = computed(() => props.side === 'left' || props.side === 'right'); \n \nconst positionClasses = computed(() => { \n switch (props.side) { \n case 'left': return 'flex-row items-stretch justify-start'; \n case 'right': return 'flex-row items-stretch justify-end'; \n case 'top': return 'flex-col items-stretch justify-start'; \n case 'bottom': return 'flex-col items-stretch justify-end'; \n default: return 'flex-row items-stretch justify-end'; \n } \n}); \n \nconst sizeClasses = computed(() => { \n if (isHorizontal.value) { \n // Width + full height \n const heightCls = 'h-full'; \n switch (props.size) { \n case 'small': return `${heightCls} w-[20rem] max-w-[90vw]`; \n case 'large': return `${heightCls} w-[36rem] max-w-[95vw]`; \n case 'full': return `${heightCls} w-screen`; \n default: return `${heightCls} w-[28rem] max-w-[92vw]`; \n } \n } else { \n // Height + full width \n const widthCls = 'w-full'; \n switch (props.size) { \n case 'small': return `${widthCls} h-[18rem] max-h-[80vh]`; \n case 'large': return `${widthCls} h-[32rem] max-h-[90vh]`; \n case 'full': return `${widthCls} h-screen`; \n default: return `${widthCls} h-[24rem] max-h-[85vh]`; \n } \n } \n}); \n \nconst sideBorderClass = computed(() => { \n switch (props.side) { \n case 'left': return 'border-r'; \n case 'right': return 'border-l'; \n case 'top': return 'border-b'; \n case 'bottom': return 'border-t'; \n default: return 'border-l'; \n } \n}); \n \n/** \n * El radius se aplica solo a las dos esquinas opuestas al borde de entrada \n * (las que quedan visibles dentro del viewport). El lado pegado al borde \n * queda recto. \n */ \nconst radiusClasses = computed(() => { \n if (props.size === 'full') return 'rounded-none'; \n // Mapeo explícito (Tailwind JIT requiere class names literales). \n const map = { \n none: { \n left: 'rounded-none', right: 'rounded-none', \n top: 'rounded-none', bottom: 'rounded-none', \n }, \n small: { \n left: 'rounded-r-md', right: 'rounded-l-md', \n top: 'rounded-b-md', bottom: 'rounded-t-md', \n }, \n medium: { \n left: 'rounded-r-xl', right: 'rounded-l-xl', \n top: 'rounded-b-xl', bottom: 'rounded-t-xl', \n }, \n large: { \n left: 'rounded-r-2xl', right: 'rounded-l-2xl', \n top: 'rounded-b-2xl', bottom: 'rounded-t-2xl', \n }, \n full: { \n left: 'rounded-r-3xl', right: 'rounded-l-3xl', \n top: 'rounded-b-3xl', bottom: 'rounded-t-3xl', \n }, \n } as const; \n const r = (resolvedRadius.value ?? 'medium') as keyof typeof map; \n const safeR = map[r] ? r : 'medium'; \n return map[safeR][props.side]; \n}); \n \nconst innerBorderRadiusClass = computed(() => { \n if (props.size === 'full') return 'rounded-none'; \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 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":""}
|
|
@@ -6,6 +6,7 @@ const require_useColorMode = require("../../composables/useColorMode.cjs");
|
|
|
6
6
|
const require_useModoConfig = require("../../composables/useModoConfig.cjs");
|
|
7
7
|
const require_Button = require("../forms/Button.cjs");
|
|
8
8
|
const require_Typography = require("../data-display/Typography.cjs");
|
|
9
|
+
const require_useBodyScrollLock = require("../../composables/useBodyScrollLock.cjs");
|
|
9
10
|
let vue = require("vue");
|
|
10
11
|
let _heroicons_vue_24_outline = require("@heroicons/vue/24/outline");
|
|
11
12
|
let gsap = require("gsap");
|
|
@@ -229,6 +230,7 @@ var Drawer_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue
|
|
|
229
230
|
const panel = overlay.querySelector("[data-modo-drawer-panel]") ?? panelRef.value;
|
|
230
231
|
const content = overlay.querySelector("[data-modo-drawer-content]") ?? contentRef.value;
|
|
231
232
|
if (!overlay || !panel || !content) {
|
|
233
|
+
releaseScrollLock();
|
|
232
234
|
done();
|
|
233
235
|
return;
|
|
234
236
|
}
|
|
@@ -268,26 +270,19 @@ var Drawer_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue
|
|
|
268
270
|
ease: "power2.in"
|
|
269
271
|
}, .12);
|
|
270
272
|
}
|
|
271
|
-
let previousOverflow = "";
|
|
272
|
-
let previousPaddingRight = "";
|
|
273
273
|
let previouslyFocused = null;
|
|
274
274
|
let scrollLocked = false;
|
|
275
275
|
function releaseScrollLock() {
|
|
276
276
|
if (!scrollLocked) return;
|
|
277
|
-
document.body.style.overflow = previousOverflow;
|
|
278
|
-
document.body.style.paddingRight = previousPaddingRight;
|
|
279
277
|
scrollLocked = false;
|
|
278
|
+
require_useBodyScrollLock.unlockBodyScroll();
|
|
280
279
|
}
|
|
281
280
|
(0, vue.watch)(() => props.modelValue, (open) => {
|
|
282
281
|
if (open) {
|
|
283
282
|
previouslyFocused = document.activeElement;
|
|
284
283
|
if (props.lockScroll && !scrollLocked) {
|
|
285
|
-
const scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
286
|
-
previousOverflow = document.body.style.overflow;
|
|
287
|
-
previousPaddingRight = document.body.style.paddingRight;
|
|
288
|
-
document.body.style.overflow = "hidden";
|
|
289
|
-
if (scrollBarWidth > 0) document.body.style.paddingRight = `${scrollBarWidth}px`;
|
|
290
284
|
scrollLocked = true;
|
|
285
|
+
require_useBodyScrollLock.lockBodyScroll();
|
|
291
286
|
}
|
|
292
287
|
emit("open");
|
|
293
288
|
(0, vue.nextTick)(() => {
|