mood-ui 0.13.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/components/feedback/liquid-toast/LiquidToast.cjs.map +1 -1
  2. package/dist/components/feedback/liquid-toast/LiquidToast.mjs.map +1 -1
  3. package/dist/components/feedback/liquid-toast/LiquidToast.vue_vue_type_script_setup_true_lang.cjs +7 -6
  4. package/dist/components/feedback/liquid-toast/LiquidToast.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  5. package/dist/components/feedback/liquid-toast/LiquidToast.vue_vue_type_script_setup_true_lang.mjs +7 -6
  6. package/dist/components/feedback/liquid-toast/LiquidToast.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  7. package/dist/components/feedback/liquid-toast/LiquidToastShape.cjs.map +1 -1
  8. package/dist/components/feedback/liquid-toast/LiquidToastShape.mjs.map +1 -1
  9. package/dist/components/feedback/liquid-toast/LiquidToastShape.vue_vue_type_script_setup_true_lang.cjs +1 -0
  10. package/dist/components/feedback/liquid-toast/LiquidToastShape.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  11. package/dist/components/feedback/liquid-toast/LiquidToastShape.vue_vue_type_script_setup_true_lang.mjs +1 -0
  12. package/dist/components/feedback/liquid-toast/LiquidToastShape.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  13. package/dist/components/feedback/liquid-toast/LiquidToaster.cjs.map +1 -1
  14. package/dist/components/feedback/liquid-toast/LiquidToaster.mjs.map +1 -1
  15. package/dist/components/feedback/liquid-toast/LiquidToaster.vue_vue_type_script_setup_true_lang.cjs +2 -2
  16. package/dist/components/feedback/liquid-toast/LiquidToaster.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  17. package/dist/components/feedback/liquid-toast/LiquidToaster.vue_vue_type_script_setup_true_lang.mjs +2 -2
  18. package/dist/components/feedback/liquid-toast/LiquidToaster.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  19. package/dist/components/feedback/liquid-toast/liquidToast2.cjs +3 -3
  20. package/dist/components/feedback/liquid-toast/liquidToast2.cjs.map +1 -1
  21. package/dist/components/feedback/liquid-toast/liquidToast2.mjs +3 -3
  22. package/dist/components/feedback/liquid-toast/liquidToast2.mjs.map +1 -1
  23. package/dist/components/feedback/morph-tooltip/MorphTooltip.cjs.map +1 -1
  24. package/dist/components/feedback/morph-tooltip/MorphTooltip.mjs.map +1 -1
  25. package/dist/components/feedback/morph-tooltip/MorphTooltip.vue_vue_type_script_setup_true_lang.cjs +9 -4
  26. package/dist/components/feedback/morph-tooltip/MorphTooltip.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  27. package/dist/components/feedback/morph-tooltip/MorphTooltip.vue_vue_type_script_setup_true_lang.mjs +9 -4
  28. package/dist/components/feedback/morph-tooltip/MorphTooltip.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  29. package/dist/components/feedback/morph-tooltip/MorphTooltipContent.cjs.map +1 -1
  30. package/dist/components/feedback/morph-tooltip/MorphTooltipContent.mjs.map +1 -1
  31. package/dist/components/feedback/morph-tooltip/MorphTooltipContent.vue_vue_type_script_setup_true_lang.cjs +8 -4
  32. package/dist/components/feedback/morph-tooltip/MorphTooltipContent.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  33. package/dist/components/feedback/morph-tooltip/MorphTooltipContent.vue_vue_type_script_setup_true_lang.mjs +8 -4
  34. package/dist/components/feedback/morph-tooltip/MorphTooltipContent.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  35. package/dist/components/forms/glass-switch/GlassSwitch.cjs.map +1 -1
  36. package/dist/components/forms/glass-switch/GlassSwitch.mjs.map +1 -1
  37. package/dist/components/forms/glass-switch/GlassSwitch.vue_vue_type_script_setup_true_lang.cjs +21 -25
  38. package/dist/components/forms/glass-switch/GlassSwitch.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  39. package/dist/components/forms/glass-switch/GlassSwitch.vue_vue_type_script_setup_true_lang.mjs +21 -25
  40. package/dist/components/forms/glass-switch/GlassSwitch.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  41. package/dist/components/forms/morph-select/MorphSelectContent.cjs.map +1 -1
  42. package/dist/components/forms/morph-select/MorphSelectContent.mjs.map +1 -1
  43. package/dist/components/forms/morph-select/MorphSelectContent.vue_vue_type_script_setup_true_lang.cjs +3 -1
  44. package/dist/components/forms/morph-select/MorphSelectContent.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  45. package/dist/components/forms/morph-select/MorphSelectContent.vue_vue_type_script_setup_true_lang.mjs +3 -1
  46. package/dist/components/forms/morph-select/MorphSelectContent.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  47. package/dist/components/forms/morph-select/MorphSelectTrigger.cjs.map +1 -1
  48. package/dist/components/forms/morph-select/MorphSelectTrigger.mjs.map +1 -1
  49. package/dist/components/forms/morph-select/MorphSelectTrigger.vue_vue_type_script_setup_true_lang.cjs +11 -6
  50. package/dist/components/forms/morph-select/MorphSelectTrigger.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  51. package/dist/components/forms/morph-select/MorphSelectTrigger.vue_vue_type_script_setup_true_lang.mjs +11 -6
  52. package/dist/components/forms/morph-select/MorphSelectTrigger.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  53. package/dist/mood-ui.css +315 -89
  54. package/dist/types/components/feedback/liquid-toast/liquidToast.d.ts +1 -1
  55. package/dist/types/interfaces/feedback/LiquidToast.interface.d.ts +9 -9
  56. package/dist/types/interfaces/feedback/MorphTooltip.interface.d.ts +4 -4
  57. package/dist/types/interfaces/forms/GlassSwitch.interface.d.ts +1 -1
  58. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"MorphTooltipContent.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../../../src/components/feedback/morph-tooltip/MorphTooltipContent.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'\nimport type { MorphTooltipContentProps } from '../../../interfaces/feedback/MorphTooltip.interface'\nimport type { ModoColor, ModoRadius } from '../../../config/ModoConfig'\nimport { useResolvedColor } from '../../../composables/useModoConfig'\nimport { useTeleportedModoTheme } from '../../../composables/useTeleportedModoTheme'\nimport { prefersReducedMotion } from '../../../utils/morph/morphEngine'\nimport { TOOLTIP_ARROW_SIZE, tooltipArrowCross, tooltipArrowInset } from '../../../utils/tooltipArrow'\nimport { useMorphTooltip } from './MorphTooltipContext'\nimport { resolveTooltipPosition, type TooltipSide } from './tooltipPlacement'\nimport './morph-tooltip.css'\n\nconst props = withDefaults(defineProps<MorphTooltipContentProps>(), {\n side: 'top', align: 'auto', offset: 8, arrow: true, color: 'default', maxWidth: 260,\n})\nconst { id, phase, trigger, disabled, hide } = useMorphTooltip()\nconst panel = ref<HTMLElement | null>(null)\nconst { scopedTheme, providerStyle, resolvedRadius, resolvedSize } = useTeleportedModoTheme({\n radius: () => props.radius, size: () => props.size,\n})\n\n/* ---------- Style maps (same as the native Tooltip) ---------- */\nconst isInverted = computed(() => props.color === 'inverted')\nconst resolvedColor = useResolvedColor(() => isInverted.value ? undefined : props.color as ModoColor | undefined)\nconst COLOR_CLASSES: Record<string, string> = {\n default: 'bg-foreground text-background',\n inverted: 'bg-background text-foreground border border-border',\n primary: 'bg-primary text-primary-foreground',\n danger: 'bg-destructive text-destructive-foreground',\n success: 'bg-success text-success-foreground',\n warning: 'bg-warning text-warning-foreground',\n}\nconst ARROW_COLOR_CLASSES: Record<string, string> = {\n default: 'bg-foreground',\n inverted: 'bg-background',\n primary: 'bg-primary',\n danger: 'bg-destructive',\n success: 'bg-success',\n warning: 'bg-warning',\n}\nconst colorKey = computed(() => isInverted.value ? 'inverted' : resolvedColor.value)\nconst colorClasses = computed(() => COLOR_CLASSES[colorKey.value] ?? COLOR_CLASSES.default)\nconst arrowColorClass = computed(() => ARROW_COLOR_CLASSES[colorKey.value] ?? ARROW_COLOR_CLASSES.default)\nconst sizeClasses = computed(() => {\n switch (resolvedSize.value) {\n case 'xsmall':\n case 'small': return 'px-2 py-1 text-[11px]'\n case 'large': return 'px-3.5 py-2 text-body'\n default: return 'px-2.5 py-1.5 text-caption'\n }\n})\n// Resolved radius as a CSS value so the morph keyframes land exactly on the\n// class the native Tooltip uses (rounded-none / sm / md / lg / full).\nconst RADIUS_VALUE: Record<ModoRadius, string> = {\n none: '0px',\n small: 'var(--radius-sm, calc(var(--radius) - 4px))',\n medium: 'var(--radius-md, calc(var(--radius) - 2px))',\n large: 'var(--radius-lg, var(--radius))',\n full: '9999px',\n}\n// The streak the tooltip grows from: a capsule, except when the provider asks\n// for square corners (then it stays square all the way).\nconst SEED_RADIUS_VALUE: Record<ModoRadius, string> = {\n none: '0px',\n small: 'var(--radius-md, calc(var(--radius) - 2px))',\n medium: '9999px',\n large: '9999px',\n full: '9999px',\n}\n\n/* ---------- Positioning ---------- */\nconst pos = ref<{ left: number; top: number; side: TooltipSide; cross: number } | null>(null)\nfunction position() {\n const el = panel.value, t = trigger.value\n if (!el || !t) return\n const rect = t.getBoundingClientRect()\n const width = el.offsetWidth, height = el.offsetHeight\n const p = resolveTooltipPosition(rect, { width, height }, { width: innerWidth, height: innerHeight }, props.side, props.align, props.offset)\n const vertical = p.side === 'top' || p.side === 'bottom'\n const edge = vertical ? width : height\n const cross = tooltipArrowCross(\n vertical ? rect.left + rect.width / 2 - p.left : rect.top + rect.height / 2 - p.top,\n edge,\n tooltipArrowInset(resolvedRadius.value, edge),\n )\n pos.value = { ...p, cross }\n}\n\nconst panelStyle = computed<Record<string, string | undefined>>(() => {\n const p = pos.value\n const origin = !p ? undefined\n : p.side === 'top' ? `${p.cross}px 100%`\n : p.side === 'bottom' ? `${p.cross}px 0%`\n : p.side === 'left' ? `100% ${p.cross}px`\n : `0% ${p.cross}px`\n return {\n ...providerStyle.value,\n position: 'fixed',\n left: p ? `${p.left}px` : '0px',\n top: p ? `${p.top}px` : '0px',\n maxWidth: `${props.maxWidth}px`,\n transformOrigin: origin,\n '--modo-morph-tooltip-radius': RADIUS_VALUE[resolvedRadius.value],\n '--modo-morph-tooltip-seed-radius': SEED_RADIUS_VALUE[resolvedRadius.value],\n }\n})\nconst arrowStyle = computed(() => {\n const p = pos.value\n if (!p) return {}\n const cross = `${p.cross - TOOLTIP_ARROW_SIZE / 2}px`\n const out = `-${TOOLTIP_ARROW_SIZE / 2}px`\n switch (p.side) {\n case 'top': return { left: cross, bottom: out }\n case 'bottom': return { left: cross, top: out }\n case 'left': return { top: cross, right: out }\n default: return { top: cross, left: out }\n }\n})\n// Only the two outward faces of the rotated square get a border (inverted only).\nconst arrowBorderClass = computed(() => {\n if (!isInverted.value || !pos.value) return ''\n switch (pos.value.side) {\n case 'top': return 'border-r border-b border-border'\n case 'bottom': return 'border-t border-l border-border'\n case 'left': return 'border-t border-r border-border'\n default: return 'border-b border-l border-border'\n }\n})\n\n/* ---------- Lifecycle ---------- */\nlet fallback: ReturnType<typeof setTimeout> | undefined\nfunction finish() { if (phase.value === 'opening') phase.value = 'open'; else if (phase.value === 'closing') { phase.value = 'closed'; pos.value = null } }\nfunction key(e: KeyboardEvent) { if (e.key === 'Escape') hide() }\nfunction reposition() { if (phase.value !== 'closed') position() }\nfunction outsideTouch(e: Event) {\n const target = e.target as Node | null\n if (trigger.value?.contains(target) || panel.value?.contains(target)) return\n hide()\n}\nwatch(phase, async (value, _, cleanup) => {\n clearTimeout(fallback)\n let cancelled = false; cleanup(() => { cancelled = true })\n if (value === 'closed') { pos.value = null; return }\n await nextTick(); if (cancelled) return\n position()\n if (value === 'opening' || value === 'closing') {\n if (prefersReducedMotion()) finish()\n // Safety net in case animationend never fires (tokens: slow 320ms / base 220ms).\n else fallback = setTimeout(finish, value === 'opening' ? 360 : 260)\n }\n}, { immediate: true })\nwatch([() => props.side, () => props.align, () => props.offset], reposition, { flush: 'post' })\nwatch(() => phase.value !== 'closed', (visible, _, cleanup) => {\n if (!visible || typeof document === 'undefined') return\n // Follow the trigger on scroll/resize (like the native Tooltip) instead of closing.\n document.addEventListener('keydown', key)\n window.addEventListener('scroll', reposition, true)\n window.addEventListener('resize', reposition)\n // Touch has no pointer leave: an outside tap or a scroll gesture ends it.\n document.addEventListener('touchstart', outsideTouch, { passive: true })\n document.addEventListener('touchmove', hide, { passive: true })\n let observer: ResizeObserver | undefined\n if (typeof ResizeObserver !== 'undefined') {\n observer = new ResizeObserver(reposition)\n if (trigger.value) observer.observe(trigger.value)\n void nextTick(() => { if (panel.value) observer?.observe(panel.value) })\n }\n cleanup(() => {\n document.removeEventListener('keydown', key)\n window.removeEventListener('scroll', reposition, true)\n window.removeEventListener('resize', reposition)\n document.removeEventListener('touchstart', outsideTouch)\n document.removeEventListener('touchmove', hide)\n observer?.disconnect()\n })\n}, { immediate: true })\nonBeforeUnmount(() => { clearTimeout(fallback) })\n</script>\n<template>\n <Teleport to=\"body\">\n <div\n v-if=\"phase !== 'closed' && !disabled\"\n :id=\"id\"\n ref=\"panel\"\n role=\"tooltip\"\n data-modo-morph-tooltip=\"\"\n :data-modo-phase=\"phase\"\n :data-modo-side=\"pos?.side\"\n :data-modo-theme=\"scopedTheme\"\n :class=\"['pointer-events-none select-none shadow-md', colorClasses, sizeClasses]\"\n :style=\"panelStyle\"\n @animationend.self=\"finish\"\n >\n <slot />\n <span\n v-if=\"arrow && pos\"\n aria-hidden=\"true\"\n :class=\"['modo-morph-tooltip__arrow absolute w-2 h-2 rotate-45', arrowColorClass, arrowBorderClass]\"\n :style=\"arrowStyle\"\n />\n </div>\n </Teleport>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYA,MAAM,QAAQ;EAGd,MAAM,EAAE,IAAI,OAAO,SAAS,UAAU,SAAS,4BAAA,iBAAgB;EAC/D,MAAM,SAAA,GAAA,IAAA,KAAgC,KAAI;EAC1C,MAAM,EAAE,aAAa,eAAe,gBAAgB,iBAAiB,+BAAA,uBAAuB;GAC1F,cAAc,MAAM;GAAQ,YAAY,MAAM;GAC/C,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CAAA;2BAElB,KAAA,QAAA,UAAA,EAEA,QAAA,SAAS,IAAA,UAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAIf,QAAA;;IAHA,eAAY;IACX,QAAA,GAAA,IAAA,gBAAK;KAAA;KAA2D,gBAAA;KAAiB,iBAAA;KAAgB,CAAA;IACjG,QAAA,GAAA,IAAA,gBAAO,WAAA,MAAU"}
1
+ {"version":3,"file":"MorphTooltipContent.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../../../src/components/feedback/morph-tooltip/MorphTooltipContent.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'\nimport type { MorphTooltipContentProps } from '../../../interfaces/feedback/MorphTooltip.interface'\nimport type { ModoColor, ModoRadius } from '../../../config/ModoConfig'\nimport { useResolvedColor } from '../../../composables/useModoConfig'\nimport { useTeleportedModoTheme } from '../../../composables/useTeleportedModoTheme'\nimport { prefersReducedMotion } from '../../../utils/morph/morphEngine'\nimport { TOOLTIP_ARROW_SIZE, tooltipArrowCross, tooltipArrowInset } from '../../../utils/tooltipArrow'\nimport { useMorphTooltip } from './MorphTooltipContext'\nimport { resolveTooltipPosition, type TooltipSide } from './tooltipPlacement'\nimport './morph-tooltip.css'\n\nconst props = withDefaults(defineProps<MorphTooltipContentProps>(), {\n side: 'top', align: 'auto', offset: 8, arrow: false, color: 'default', maxWidth: undefined,\n})\nconst { id, phase, trigger, disabled, hide } = useMorphTooltip()\nconst panel = ref<HTMLElement | null>(null)\nconst { scopedTheme, providerStyle, resolvedRadius, resolvedSize } = useTeleportedModoTheme({\n radius: () => props.radius, size: () => props.size,\n})\n\n/* ---------- Style maps (same as the native Tooltip) ---------- */\nconst isInverted = computed(() => props.color === 'inverted')\nconst resolvedColor = useResolvedColor(() => isInverted.value ? undefined : props.color as ModoColor | undefined)\nconst COLOR_CLASSES: Record<string, string> = {\n default: 'bg-foreground text-background',\n inverted: 'bg-background text-foreground border border-border',\n primary: 'bg-primary text-primary-foreground',\n danger: 'bg-destructive text-destructive-foreground',\n success: 'bg-success text-success-foreground',\n warning: 'bg-warning text-warning-foreground',\n}\nconst ARROW_COLOR_CLASSES: Record<string, string> = {\n default: 'bg-foreground',\n inverted: 'bg-background',\n primary: 'bg-primary',\n danger: 'bg-destructive',\n success: 'bg-success',\n warning: 'bg-warning',\n}\nconst colorKey = computed(() => isInverted.value ? 'inverted' : resolvedColor.value)\nconst colorClasses = computed(() => COLOR_CLASSES[colorKey.value] ?? COLOR_CLASSES.default)\nconst arrowColorClass = computed(() => ARROW_COLOR_CLASSES[colorKey.value] ?? ARROW_COLOR_CLASSES.default)\nconst sizeClasses = computed(() => {\n switch (resolvedSize.value) {\n case 'xsmall':\n case 'small': return 'px-2 py-1 text-[11px]'\n case 'large': return 'px-3.5 py-2 text-body'\n default: return 'px-2.5 py-1.5 text-caption'\n }\n})\n// Resolved radius as a CSS value so the morph keyframes land exactly on the\n// class the native Tooltip uses (rounded-none / sm / md / lg / full).\nconst RADIUS_VALUE: Record<ModoRadius, string> = {\n none: '0px',\n small: 'var(--radius-sm, calc(var(--radius) - 4px))',\n medium: 'var(--radius-md, calc(var(--radius) - 2px))',\n large: 'var(--radius-lg, var(--radius))',\n full: '9999px',\n}\n// The streak the tooltip grows from: a capsule, except when the provider asks\n// for square corners (then it stays square all the way).\nconst SEED_RADIUS_VALUE: Record<ModoRadius, string> = {\n none: '0px',\n small: 'var(--radius-md, calc(var(--radius) - 2px))',\n medium: '9999px',\n large: '9999px',\n full: '9999px',\n}\n\n/* ---------- Positioning ---------- */\nconst pos = ref<{ left: number; top: number; side: TooltipSide; cross: number } | null>(null)\nfunction position() {\n const el = panel.value, t = trigger.value\n if (!el || !t) return\n const rect = t.getBoundingClientRect()\n const width = el.offsetWidth, height = el.offsetHeight\n const p = resolveTooltipPosition(rect, { width, height }, { width: innerWidth, height: innerHeight }, props.side, props.align, props.offset)\n const vertical = p.side === 'top' || p.side === 'bottom'\n const edge = vertical ? width : height\n const cross = tooltipArrowCross(\n vertical ? rect.left + rect.width / 2 - p.left : rect.top + rect.height / 2 - p.top,\n edge,\n tooltipArrowInset(resolvedRadius.value, edge),\n )\n pos.value = { ...p, cross }\n}\n\nconst panelStyle = computed<Record<string, string | undefined>>(() => {\n const p = pos.value\n const origin = !p ? undefined\n : p.side === 'top' ? `${p.cross}px 100%`\n : p.side === 'bottom' ? `${p.cross}px 0%`\n : p.side === 'left' ? `100% ${p.cross}px`\n : `0% ${p.cross}px`\n return {\n ...providerStyle.value,\n position: 'fixed',\n left: p ? `${p.left}px` : '0px',\n top: p ? `${p.top}px` : '0px',\n maxWidth: props.maxWidth === undefined ? undefined : `${props.maxWidth}px`,\n transformOrigin: origin,\n '--modo-morph-tooltip-radius': props.radius === undefined && resolvedRadius.value === 'medium' ? '1rem' : RADIUS_VALUE[resolvedRadius.value],\n '--modo-morph-tooltip-seed-radius': SEED_RADIUS_VALUE[resolvedRadius.value],\n }\n})\nconst arrowStyle = computed(() => {\n const p = pos.value\n if (!p) return {}\n const cross = `${p.cross - TOOLTIP_ARROW_SIZE / 2}px`\n const out = `-${TOOLTIP_ARROW_SIZE / 2}px`\n switch (p.side) {\n case 'top': return { left: cross, bottom: out }\n case 'bottom': return { left: cross, top: out }\n case 'left': return { top: cross, right: out }\n default: return { top: cross, left: out }\n }\n})\n// Only the two outward faces of the rotated square get a border (inverted only).\nconst arrowBorderClass = computed(() => {\n if (!isInverted.value || !pos.value) return ''\n switch (pos.value.side) {\n case 'top': return 'border-r border-b border-border'\n case 'bottom': return 'border-t border-l border-border'\n case 'left': return 'border-t border-r border-border'\n default: return 'border-b border-l border-border'\n }\n})\n\n/* ---------- Lifecycle ---------- */\nlet fallback: ReturnType<typeof setTimeout> | undefined\nfunction finish() { if (phase.value === 'opening') phase.value = 'open'; else if (phase.value === 'closing') { phase.value = 'closed'; pos.value = null } }\nfunction key(e: KeyboardEvent) { if (e.key === 'Escape') hide() }\nfunction reposition() { if (phase.value !== 'closed') position() }\nfunction outsideTouch(e: Event) {\n const target = e.target as Node | null\n if (trigger.value?.contains(target) || panel.value?.contains(target)) return\n hide()\n}\nwatch(phase, async (value, _, cleanup) => {\n clearTimeout(fallback)\n let cancelled = false; cleanup(() => { cancelled = true })\n if (value === 'closed') { pos.value = null; return }\n await nextTick(); if (cancelled) return\n position()\n if (value === 'opening' || value === 'closing') {\n if (prefersReducedMotion()) finish()\n // Safety net in case animationend never fires (tokens: slow 320ms / base 220ms).\n else fallback = setTimeout(finish, value === 'opening' ? 360 : 260)\n }\n}, { immediate: true })\nwatch([() => props.side, () => props.align, () => props.offset], reposition, { flush: 'post' })\nwatch(() => phase.value !== 'closed', (visible, _, cleanup) => {\n if (!visible || typeof document === 'undefined') return\n // Follow the trigger on scroll/resize (like the native Tooltip) instead of closing.\n document.addEventListener('keydown', key)\n window.addEventListener('scroll', reposition, true)\n window.addEventListener('resize', reposition)\n // Touch has no pointer leave: an outside tap or a scroll gesture ends it.\n document.addEventListener('touchstart', outsideTouch, { passive: true })\n document.addEventListener('touchmove', hide, { passive: true })\n let observer: ResizeObserver | undefined\n if (typeof ResizeObserver !== 'undefined') {\n observer = new ResizeObserver(reposition)\n if (trigger.value) observer.observe(trigger.value)\n void nextTick(() => { if (panel.value) observer?.observe(panel.value) })\n }\n cleanup(() => {\n document.removeEventListener('keydown', key)\n window.removeEventListener('scroll', reposition, true)\n window.removeEventListener('resize', reposition)\n document.removeEventListener('touchstart', outsideTouch)\n document.removeEventListener('touchmove', hide)\n observer?.disconnect()\n })\n}, { immediate: true })\nonBeforeUnmount(() => { clearTimeout(fallback) })\n</script>\n<template>\n <Teleport to=\"body\">\n <div\n v-if=\"phase !== 'closed' && !disabled\"\n :id=\"id\"\n ref=\"panel\"\n role=\"tooltip\"\n data-modo-morph-tooltip=\"\"\n :data-modo-phase=\"phase\"\n :data-modo-color=\"colorKey\"\n :data-modo-size=\"resolvedSize\"\n :data-modo-side=\"pos?.side\"\n :data-modo-theme=\"scopedTheme\"\n :class=\"['pointer-events-none select-none shadow-md', colorClasses, sizeClasses]\"\n :style=\"panelStyle\"\n @animationend.self=\"finish\"\n >\n <slot />\n <span\n v-if=\"arrow && pos\"\n aria-hidden=\"true\"\n :class=\"['modo-morph-tooltip__arrow absolute w-2 h-2 rotate-45', arrowColorClass, arrowBorderClass]\"\n :style=\"arrowStyle\"\n />\n </div>\n </Teleport>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYA,MAAM,QAAQ;EAGd,MAAM,EAAE,IAAI,OAAO,SAAS,UAAU,SAAS,4BAAA,iBAAgB;EAC/D,MAAM,SAAA,GAAA,IAAA,KAAgC,KAAI;EAC1C,MAAM,EAAE,aAAa,eAAe,gBAAgB,iBAAiB,+BAAA,uBAAuB;GAC1F,cAAc,MAAM;GAAQ,YAAY,MAAM;GAC/C,CAAA;EAGD,MAAM,cAAA,GAAA,IAAA,gBAA4B,MAAM,UAAU,WAAU;EAC5D,MAAM,gBAAgB,sBAAA,uBAAuB,WAAW,QAAQ,KAAA,IAAY,MAAM,MAA8B;EAChH,MAAM,gBAAwC;GAC5C,SAAS;GACT,UAAU;GACV,SAAS;GACT,QAAQ;GACR,SAAS;GACT,SAAS;GACX;EACA,MAAM,sBAA8C;GAClD,SAAS;GACT,UAAU;GACV,SAAS;GACT,QAAQ;GACR,SAAS;GACT,SAAS;GACX;EACA,MAAM,YAAA,GAAA,IAAA,gBAA0B,WAAW,QAAQ,aAAa,cAAc,MAAK;EACnF,MAAM,gBAAA,GAAA,IAAA,gBAA8B,cAAc,SAAS,UAAU,cAAc,QAAO;EAC1F,MAAM,mBAAA,GAAA,IAAA,gBAAiC,oBAAoB,SAAS,UAAU,oBAAoB,QAAO;EACzG,MAAM,eAAA,GAAA,IAAA,gBAA6B;GACjC,QAAQ,aAAa,OAArB;IACE,KAAK;IACL,KAAK,SAAS,OAAO;IACrB,KAAK,SAAS,OAAO;IACrB,SAAS,OAAO;;IAEnB;EAGD,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;KACA,EAAE,WAAW,MAAM,CAAA;EACtB,CAAA,GAAA,IAAA,uBAAsB;GAAE,aAAa,SAAS;IAAE;;qDA2BnC,IAAA,UAAA,EAxBD,IAAG,QAAM,EAAA,EAAA,GAAA,IAAA,OAET,MAAK,KAAA,YAAA,EAAA,GAAA,IAAA,OAAkB,SAAQ,KAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAqBjC,OAAA;;IApBH,KAAA,GAAA,IAAA,OAAI,GAAE;aACH;IAAJ,KAAI;IACJ,MAAK;IACL,2BAAwB;IACvB,oBAAA,GAAA,IAAA,OAAiB,MAAK;IACtB,mBAAiB,SAAA;IACjB,mBAAA,GAAA,IAAA,OAAgB,aAAY;IAC5B,kBAAgB,IAAA,OAAK;IACrB,oBAAA,GAAA,IAAA,OAAiB,YAAW;IAC5B,QAAA,GAAA,IAAA,gBAAK;KAAA;KAAgD,aAAA;KAAc,YAAA;KAAW,CAAA;IAC9E,QAAA,GAAA,IAAA,gBAAO,WAAA,MAAU;IACjB,iBAAA,GAAA,IAAA,eAAmB,QAAM,CAAA,OAAA,CAAA;2BAElB,KAAA,QAAA,UAAA,EAEA,QAAA,SAAS,IAAA,UAAA,GAAA,IAAA,YAAA,GAAA,GAAA,IAAA,oBAIf,QAAA;;IAHA,eAAY;IACX,QAAA,GAAA,IAAA,gBAAK;KAAA;KAA2D,gBAAA;KAAiB,iBAAA;KAAgB,CAAA;IACjG,QAAA,GAAA,IAAA,gBAAO,WAAA,MAAU"}
@@ -10,6 +10,8 @@ import { Teleport, computed, createBlock, createCommentVNode, createElementBlock
10
10
  var _hoisted_1 = [
11
11
  "id",
12
12
  "data-modo-phase",
13
+ "data-modo-color",
14
+ "data-modo-size",
13
15
  "data-modo-side",
14
16
  "data-modo-theme"
15
17
  ];
@@ -21,12 +23,12 @@ var MorphTooltipContent_vue_vue_type_script_setup_true_lang_default = /* @__PURE
21
23
  offset: { default: 8 },
22
24
  arrow: {
23
25
  type: Boolean,
24
- default: true
26
+ default: false
25
27
  },
26
28
  color: { default: "default" },
27
29
  size: {},
28
30
  radius: {},
29
- maxWidth: { default: 260 }
31
+ maxWidth: { default: void 0 }
30
32
  },
31
33
  setup(__props) {
32
34
  const props = __props;
@@ -108,9 +110,9 @@ var MorphTooltipContent_vue_vue_type_script_setup_true_lang_default = /* @__PURE
108
110
  position: "fixed",
109
111
  left: p ? `${p.left}px` : "0px",
110
112
  top: p ? `${p.top}px` : "0px",
111
- maxWidth: `${props.maxWidth}px`,
113
+ maxWidth: props.maxWidth === void 0 ? void 0 : `${props.maxWidth}px`,
112
114
  transformOrigin: origin,
113
- "--modo-morph-tooltip-radius": RADIUS_VALUE[resolvedRadius.value],
115
+ "--modo-morph-tooltip-radius": props.radius === void 0 && resolvedRadius.value === "medium" ? "1rem" : RADIUS_VALUE[resolvedRadius.value],
114
116
  "--modo-morph-tooltip-seed-radius": SEED_RADIUS_VALUE[resolvedRadius.value]
115
117
  };
116
118
  });
@@ -223,6 +225,8 @@ var MorphTooltipContent_vue_vue_type_script_setup_true_lang_default = /* @__PURE
223
225
  role: "tooltip",
224
226
  "data-modo-morph-tooltip": "",
225
227
  "data-modo-phase": unref(phase),
228
+ "data-modo-color": colorKey.value,
229
+ "data-modo-size": unref(resolvedSize),
226
230
  "data-modo-side": pos.value?.side,
227
231
  "data-modo-theme": unref(scopedTheme),
228
232
  class: normalizeClass([
@@ -1 +1 @@
1
- {"version":3,"file":"MorphTooltipContent.vue_vue_type_script_setup_true_lang.mjs","names":[],"sources":["../../../../src/components/feedback/morph-tooltip/MorphTooltipContent.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'\nimport type { MorphTooltipContentProps } from '../../../interfaces/feedback/MorphTooltip.interface'\nimport type { ModoColor, ModoRadius } from '../../../config/ModoConfig'\nimport { useResolvedColor } from '../../../composables/useModoConfig'\nimport { useTeleportedModoTheme } from '../../../composables/useTeleportedModoTheme'\nimport { prefersReducedMotion } from '../../../utils/morph/morphEngine'\nimport { TOOLTIP_ARROW_SIZE, tooltipArrowCross, tooltipArrowInset } from '../../../utils/tooltipArrow'\nimport { useMorphTooltip } from './MorphTooltipContext'\nimport { resolveTooltipPosition, type TooltipSide } from './tooltipPlacement'\nimport './morph-tooltip.css'\n\nconst props = withDefaults(defineProps<MorphTooltipContentProps>(), {\n side: 'top', align: 'auto', offset: 8, arrow: true, color: 'default', maxWidth: 260,\n})\nconst { id, phase, trigger, disabled, hide } = useMorphTooltip()\nconst panel = ref<HTMLElement | null>(null)\nconst { scopedTheme, providerStyle, resolvedRadius, resolvedSize } = useTeleportedModoTheme({\n radius: () => props.radius, size: () => props.size,\n})\n\n/* ---------- Style maps (same as the native Tooltip) ---------- */\nconst isInverted = computed(() => props.color === 'inverted')\nconst resolvedColor = useResolvedColor(() => isInverted.value ? undefined : props.color as ModoColor | undefined)\nconst COLOR_CLASSES: Record<string, string> = {\n default: 'bg-foreground text-background',\n inverted: 'bg-background text-foreground border border-border',\n primary: 'bg-primary text-primary-foreground',\n danger: 'bg-destructive text-destructive-foreground',\n success: 'bg-success text-success-foreground',\n warning: 'bg-warning text-warning-foreground',\n}\nconst ARROW_COLOR_CLASSES: Record<string, string> = {\n default: 'bg-foreground',\n inverted: 'bg-background',\n primary: 'bg-primary',\n danger: 'bg-destructive',\n success: 'bg-success',\n warning: 'bg-warning',\n}\nconst colorKey = computed(() => isInverted.value ? 'inverted' : resolvedColor.value)\nconst colorClasses = computed(() => COLOR_CLASSES[colorKey.value] ?? COLOR_CLASSES.default)\nconst arrowColorClass = computed(() => ARROW_COLOR_CLASSES[colorKey.value] ?? ARROW_COLOR_CLASSES.default)\nconst sizeClasses = computed(() => {\n switch (resolvedSize.value) {\n case 'xsmall':\n case 'small': return 'px-2 py-1 text-[11px]'\n case 'large': return 'px-3.5 py-2 text-body'\n default: return 'px-2.5 py-1.5 text-caption'\n }\n})\n// Resolved radius as a CSS value so the morph keyframes land exactly on the\n// class the native Tooltip uses (rounded-none / sm / md / lg / full).\nconst RADIUS_VALUE: Record<ModoRadius, string> = {\n none: '0px',\n small: 'var(--radius-sm, calc(var(--radius) - 4px))',\n medium: 'var(--radius-md, calc(var(--radius) - 2px))',\n large: 'var(--radius-lg, var(--radius))',\n full: '9999px',\n}\n// The streak the tooltip grows from: a capsule, except when the provider asks\n// for square corners (then it stays square all the way).\nconst SEED_RADIUS_VALUE: Record<ModoRadius, string> = {\n none: '0px',\n small: 'var(--radius-md, calc(var(--radius) - 2px))',\n medium: '9999px',\n large: '9999px',\n full: '9999px',\n}\n\n/* ---------- Positioning ---------- */\nconst pos = ref<{ left: number; top: number; side: TooltipSide; cross: number } | null>(null)\nfunction position() {\n const el = panel.value, t = trigger.value\n if (!el || !t) return\n const rect = t.getBoundingClientRect()\n const width = el.offsetWidth, height = el.offsetHeight\n const p = resolveTooltipPosition(rect, { width, height }, { width: innerWidth, height: innerHeight }, props.side, props.align, props.offset)\n const vertical = p.side === 'top' || p.side === 'bottom'\n const edge = vertical ? width : height\n const cross = tooltipArrowCross(\n vertical ? rect.left + rect.width / 2 - p.left : rect.top + rect.height / 2 - p.top,\n edge,\n tooltipArrowInset(resolvedRadius.value, edge),\n )\n pos.value = { ...p, cross }\n}\n\nconst panelStyle = computed<Record<string, string | undefined>>(() => {\n const p = pos.value\n const origin = !p ? undefined\n : p.side === 'top' ? `${p.cross}px 100%`\n : p.side === 'bottom' ? `${p.cross}px 0%`\n : p.side === 'left' ? `100% ${p.cross}px`\n : `0% ${p.cross}px`\n return {\n ...providerStyle.value,\n position: 'fixed',\n left: p ? `${p.left}px` : '0px',\n top: p ? `${p.top}px` : '0px',\n maxWidth: `${props.maxWidth}px`,\n transformOrigin: origin,\n '--modo-morph-tooltip-radius': RADIUS_VALUE[resolvedRadius.value],\n '--modo-morph-tooltip-seed-radius': SEED_RADIUS_VALUE[resolvedRadius.value],\n }\n})\nconst arrowStyle = computed(() => {\n const p = pos.value\n if (!p) return {}\n const cross = `${p.cross - TOOLTIP_ARROW_SIZE / 2}px`\n const out = `-${TOOLTIP_ARROW_SIZE / 2}px`\n switch (p.side) {\n case 'top': return { left: cross, bottom: out }\n case 'bottom': return { left: cross, top: out }\n case 'left': return { top: cross, right: out }\n default: return { top: cross, left: out }\n }\n})\n// Only the two outward faces of the rotated square get a border (inverted only).\nconst arrowBorderClass = computed(() => {\n if (!isInverted.value || !pos.value) return ''\n switch (pos.value.side) {\n case 'top': return 'border-r border-b border-border'\n case 'bottom': return 'border-t border-l border-border'\n case 'left': return 'border-t border-r border-border'\n default: return 'border-b border-l border-border'\n }\n})\n\n/* ---------- Lifecycle ---------- */\nlet fallback: ReturnType<typeof setTimeout> | undefined\nfunction finish() { if (phase.value === 'opening') phase.value = 'open'; else if (phase.value === 'closing') { phase.value = 'closed'; pos.value = null } }\nfunction key(e: KeyboardEvent) { if (e.key === 'Escape') hide() }\nfunction reposition() { if (phase.value !== 'closed') position() }\nfunction outsideTouch(e: Event) {\n const target = e.target as Node | null\n if (trigger.value?.contains(target) || panel.value?.contains(target)) return\n hide()\n}\nwatch(phase, async (value, _, cleanup) => {\n clearTimeout(fallback)\n let cancelled = false; cleanup(() => { cancelled = true })\n if (value === 'closed') { pos.value = null; return }\n await nextTick(); if (cancelled) return\n position()\n if (value === 'opening' || value === 'closing') {\n if (prefersReducedMotion()) finish()\n // Safety net in case animationend never fires (tokens: slow 320ms / base 220ms).\n else fallback = setTimeout(finish, value === 'opening' ? 360 : 260)\n }\n}, { immediate: true })\nwatch([() => props.side, () => props.align, () => props.offset], reposition, { flush: 'post' })\nwatch(() => phase.value !== 'closed', (visible, _, cleanup) => {\n if (!visible || typeof document === 'undefined') return\n // Follow the trigger on scroll/resize (like the native Tooltip) instead of closing.\n document.addEventListener('keydown', key)\n window.addEventListener('scroll', reposition, true)\n window.addEventListener('resize', reposition)\n // Touch has no pointer leave: an outside tap or a scroll gesture ends it.\n document.addEventListener('touchstart', outsideTouch, { passive: true })\n document.addEventListener('touchmove', hide, { passive: true })\n let observer: ResizeObserver | undefined\n if (typeof ResizeObserver !== 'undefined') {\n observer = new ResizeObserver(reposition)\n if (trigger.value) observer.observe(trigger.value)\n void nextTick(() => { if (panel.value) observer?.observe(panel.value) })\n }\n cleanup(() => {\n document.removeEventListener('keydown', key)\n window.removeEventListener('scroll', reposition, true)\n window.removeEventListener('resize', reposition)\n document.removeEventListener('touchstart', outsideTouch)\n document.removeEventListener('touchmove', hide)\n observer?.disconnect()\n })\n}, { immediate: true })\nonBeforeUnmount(() => { clearTimeout(fallback) })\n</script>\n<template>\n <Teleport to=\"body\">\n <div\n v-if=\"phase !== 'closed' && !disabled\"\n :id=\"id\"\n ref=\"panel\"\n role=\"tooltip\"\n data-modo-morph-tooltip=\"\"\n :data-modo-phase=\"phase\"\n :data-modo-side=\"pos?.side\"\n :data-modo-theme=\"scopedTheme\"\n :class=\"['pointer-events-none select-none shadow-md', colorClasses, sizeClasses]\"\n :style=\"panelStyle\"\n @animationend.self=\"finish\"\n >\n <slot />\n <span\n v-if=\"arrow && pos\"\n aria-hidden=\"true\"\n :class=\"['modo-morph-tooltip__arrow absolute w-2 h-2 rotate-45', arrowColorClass, arrowBorderClass]\"\n :style=\"arrowStyle\"\n />\n </div>\n </Teleport>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYA,MAAM,QAAQ;EAGd,MAAM,EAAE,IAAI,OAAO,SAAS,UAAU,SAAS,iBAAgB;EAC/D,MAAM,QAAQ,IAAwB,KAAI;EAC1C,MAAM,EAAE,aAAa,eAAe,gBAAgB,iBAAiB,uBAAuB;GAC1F,cAAc,MAAM;GAAQ,YAAY,MAAM;GAC/C,CAAA;EAGD,MAAM,aAAa,eAAe,MAAM,UAAU,WAAU;EAC5D,MAAM,gBAAgB,uBAAuB,WAAW,QAAQ,KAAA,IAAY,MAAM,MAA8B;EAChH,MAAM,gBAAwC;GAC5C,SAAS;GACT,UAAU;GACV,SAAS;GACT,QAAQ;GACR,SAAS;GACT,SAA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3C,OAAO,oBAAoB,UAAU,YAAY,KAAI;IACrD,OAAO,oBAAoB,UAAU,WAAU;IAC/C,SAAS,oBAAoB,cAAc,aAAY;IACvD,SAAS,oBAAoB,aAAa,KAAI;IAC9C,UAAU,YAAW;KACtB;KACA,EAAE,WAAW,MAAM,CAAA;EACtB,sBAAsB;GAAE,aAAa,SAAS;IAAE;;uBAG9C,YAsBW,UAAA,EAtBD,IAAG,QAAM,EAAA,CAET,MAAA,MAAK,KAAA,YAAA,CAAkB,MAAA,SAAQ,IAAA,WAAA,EADvC,mBAoBM,OAAA;;IAlBH,IAAI,MAAA,GAAE;aACH;IAAJ,KAAI;IACJ,MAAK;IACL,2BAAwB;IACvB,mBAAiB,MAAA,MAAK;IACtB,kBAAgB,IAAA,OAAK;IACrB,mBAAiB,MAAA,YAAW;IAC5B,OAAK,eAAA;KAAA;KAAgD,aAAA;KAAc,YAAA;KAAW,CAAA;IAC9E,OAAK,eAAE,WAAA,MAAU;IACjB,gBAAY,cAAO,QAAM,CAAA,OAAA,CAAA;OAE1B,WAAQ,KAAA,QAAA,UAAA,EAEA,QAAA,SAAS,IAAA,SAAA,WAAA,EADjB,mBAKE,QAAA;;IAHA,eAAY;IACX,OAAK,eAAA;KAAA;KAA2D,gBAAA;KAAiB,iBAAA;KAAgB,CAAA;IACjG,OAAK,eAAE,WAAA,MAAU"}
1
+ {"version":3,"file":"MorphTooltipContent.vue_vue_type_script_setup_true_lang.mjs","names":[],"sources":["../../../../src/components/feedback/morph-tooltip/MorphTooltipContent.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'\nimport type { MorphTooltipContentProps } from '../../../interfaces/feedback/MorphTooltip.interface'\nimport type { ModoColor, ModoRadius } from '../../../config/ModoConfig'\nimport { useResolvedColor } from '../../../composables/useModoConfig'\nimport { useTeleportedModoTheme } from '../../../composables/useTeleportedModoTheme'\nimport { prefersReducedMotion } from '../../../utils/morph/morphEngine'\nimport { TOOLTIP_ARROW_SIZE, tooltipArrowCross, tooltipArrowInset } from '../../../utils/tooltipArrow'\nimport { useMorphTooltip } from './MorphTooltipContext'\nimport { resolveTooltipPosition, type TooltipSide } from './tooltipPlacement'\nimport './morph-tooltip.css'\n\nconst props = withDefaults(defineProps<MorphTooltipContentProps>(), {\n side: 'top', align: 'auto', offset: 8, arrow: false, color: 'default', maxWidth: undefined,\n})\nconst { id, phase, trigger, disabled, hide } = useMorphTooltip()\nconst panel = ref<HTMLElement | null>(null)\nconst { scopedTheme, providerStyle, resolvedRadius, resolvedSize } = useTeleportedModoTheme({\n radius: () => props.radius, size: () => props.size,\n})\n\n/* ---------- Style maps (same as the native Tooltip) ---------- */\nconst isInverted = computed(() => props.color === 'inverted')\nconst resolvedColor = useResolvedColor(() => isInverted.value ? undefined : props.color as ModoColor | undefined)\nconst COLOR_CLASSES: Record<string, string> = {\n default: 'bg-foreground text-background',\n inverted: 'bg-background text-foreground border border-border',\n primary: 'bg-primary text-primary-foreground',\n danger: 'bg-destructive text-destructive-foreground',\n success: 'bg-success text-success-foreground',\n warning: 'bg-warning text-warning-foreground',\n}\nconst ARROW_COLOR_CLASSES: Record<string, string> = {\n default: 'bg-foreground',\n inverted: 'bg-background',\n primary: 'bg-primary',\n danger: 'bg-destructive',\n success: 'bg-success',\n warning: 'bg-warning',\n}\nconst colorKey = computed(() => isInverted.value ? 'inverted' : resolvedColor.value)\nconst colorClasses = computed(() => COLOR_CLASSES[colorKey.value] ?? COLOR_CLASSES.default)\nconst arrowColorClass = computed(() => ARROW_COLOR_CLASSES[colorKey.value] ?? ARROW_COLOR_CLASSES.default)\nconst sizeClasses = computed(() => {\n switch (resolvedSize.value) {\n case 'xsmall':\n case 'small': return 'px-2 py-1 text-[11px]'\n case 'large': return 'px-3.5 py-2 text-body'\n default: return 'px-2.5 py-1.5 text-caption'\n }\n})\n// Resolved radius as a CSS value so the morph keyframes land exactly on the\n// class the native Tooltip uses (rounded-none / sm / md / lg / full).\nconst RADIUS_VALUE: Record<ModoRadius, string> = {\n none: '0px',\n small: 'var(--radius-sm, calc(var(--radius) - 4px))',\n medium: 'var(--radius-md, calc(var(--radius) - 2px))',\n large: 'var(--radius-lg, var(--radius))',\n full: '9999px',\n}\n// The streak the tooltip grows from: a capsule, except when the provider asks\n// for square corners (then it stays square all the way).\nconst SEED_RADIUS_VALUE: Record<ModoRadius, string> = {\n none: '0px',\n small: 'var(--radius-md, calc(var(--radius) - 2px))',\n medium: '9999px',\n large: '9999px',\n full: '9999px',\n}\n\n/* ---------- Positioning ---------- */\nconst pos = ref<{ left: number; top: number; side: TooltipSide; cross: number } | null>(null)\nfunction position() {\n const el = panel.value, t = trigger.value\n if (!el || !t) return\n const rect = t.getBoundingClientRect()\n const width = el.offsetWidth, height = el.offsetHeight\n const p = resolveTooltipPosition(rect, { width, height }, { width: innerWidth, height: innerHeight }, props.side, props.align, props.offset)\n const vertical = p.side === 'top' || p.side === 'bottom'\n const edge = vertical ? width : height\n const cross = tooltipArrowCross(\n vertical ? rect.left + rect.width / 2 - p.left : rect.top + rect.height / 2 - p.top,\n edge,\n tooltipArrowInset(resolvedRadius.value, edge),\n )\n pos.value = { ...p, cross }\n}\n\nconst panelStyle = computed<Record<string, string | undefined>>(() => {\n const p = pos.value\n const origin = !p ? undefined\n : p.side === 'top' ? `${p.cross}px 100%`\n : p.side === 'bottom' ? `${p.cross}px 0%`\n : p.side === 'left' ? `100% ${p.cross}px`\n : `0% ${p.cross}px`\n return {\n ...providerStyle.value,\n position: 'fixed',\n left: p ? `${p.left}px` : '0px',\n top: p ? `${p.top}px` : '0px',\n maxWidth: props.maxWidth === undefined ? undefined : `${props.maxWidth}px`,\n transformOrigin: origin,\n '--modo-morph-tooltip-radius': props.radius === undefined && resolvedRadius.value === 'medium' ? '1rem' : RADIUS_VALUE[resolvedRadius.value],\n '--modo-morph-tooltip-seed-radius': SEED_RADIUS_VALUE[resolvedRadius.value],\n }\n})\nconst arrowStyle = computed(() => {\n const p = pos.value\n if (!p) return {}\n const cross = `${p.cross - TOOLTIP_ARROW_SIZE / 2}px`\n const out = `-${TOOLTIP_ARROW_SIZE / 2}px`\n switch (p.side) {\n case 'top': return { left: cross, bottom: out }\n case 'bottom': return { left: cross, top: out }\n case 'left': return { top: cross, right: out }\n default: return { top: cross, left: out }\n }\n})\n// Only the two outward faces of the rotated square get a border (inverted only).\nconst arrowBorderClass = computed(() => {\n if (!isInverted.value || !pos.value) return ''\n switch (pos.value.side) {\n case 'top': return 'border-r border-b border-border'\n case 'bottom': return 'border-t border-l border-border'\n case 'left': return 'border-t border-r border-border'\n default: return 'border-b border-l border-border'\n }\n})\n\n/* ---------- Lifecycle ---------- */\nlet fallback: ReturnType<typeof setTimeout> | undefined\nfunction finish() { if (phase.value === 'opening') phase.value = 'open'; else if (phase.value === 'closing') { phase.value = 'closed'; pos.value = null } }\nfunction key(e: KeyboardEvent) { if (e.key === 'Escape') hide() }\nfunction reposition() { if (phase.value !== 'closed') position() }\nfunction outsideTouch(e: Event) {\n const target = e.target as Node | null\n if (trigger.value?.contains(target) || panel.value?.contains(target)) return\n hide()\n}\nwatch(phase, async (value, _, cleanup) => {\n clearTimeout(fallback)\n let cancelled = false; cleanup(() => { cancelled = true })\n if (value === 'closed') { pos.value = null; return }\n await nextTick(); if (cancelled) return\n position()\n if (value === 'opening' || value === 'closing') {\n if (prefersReducedMotion()) finish()\n // Safety net in case animationend never fires (tokens: slow 320ms / base 220ms).\n else fallback = setTimeout(finish, value === 'opening' ? 360 : 260)\n }\n}, { immediate: true })\nwatch([() => props.side, () => props.align, () => props.offset], reposition, { flush: 'post' })\nwatch(() => phase.value !== 'closed', (visible, _, cleanup) => {\n if (!visible || typeof document === 'undefined') return\n // Follow the trigger on scroll/resize (like the native Tooltip) instead of closing.\n document.addEventListener('keydown', key)\n window.addEventListener('scroll', reposition, true)\n window.addEventListener('resize', reposition)\n // Touch has no pointer leave: an outside tap or a scroll gesture ends it.\n document.addEventListener('touchstart', outsideTouch, { passive: true })\n document.addEventListener('touchmove', hide, { passive: true })\n let observer: ResizeObserver | undefined\n if (typeof ResizeObserver !== 'undefined') {\n observer = new ResizeObserver(reposition)\n if (trigger.value) observer.observe(trigger.value)\n void nextTick(() => { if (panel.value) observer?.observe(panel.value) })\n }\n cleanup(() => {\n document.removeEventListener('keydown', key)\n window.removeEventListener('scroll', reposition, true)\n window.removeEventListener('resize', reposition)\n document.removeEventListener('touchstart', outsideTouch)\n document.removeEventListener('touchmove', hide)\n observer?.disconnect()\n })\n}, { immediate: true })\nonBeforeUnmount(() => { clearTimeout(fallback) })\n</script>\n<template>\n <Teleport to=\"body\">\n <div\n v-if=\"phase !== 'closed' && !disabled\"\n :id=\"id\"\n ref=\"panel\"\n role=\"tooltip\"\n data-modo-morph-tooltip=\"\"\n :data-modo-phase=\"phase\"\n :data-modo-color=\"colorKey\"\n :data-modo-size=\"resolvedSize\"\n :data-modo-side=\"pos?.side\"\n :data-modo-theme=\"scopedTheme\"\n :class=\"['pointer-events-none select-none shadow-md', colorClasses, sizeClasses]\"\n :style=\"panelStyle\"\n @animationend.self=\"finish\"\n >\n <slot />\n <span\n v-if=\"arrow && pos\"\n aria-hidden=\"true\"\n :class=\"['modo-morph-tooltip__arrow absolute w-2 h-2 rotate-45', arrowColorClass, arrowBorderClass]\"\n :style=\"arrowStyle\"\n />\n </div>\n </Teleport>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYA,MAAM,QAAQ;EAGd,MAAM,EAAE,IAAI,OAAO,SAAS,UAAU,SAAS,iBAAgB;EAC/D,MAAM,QAAQ,IAAwB,KAAI;EAC1C,MAAM,EAAE,aAAa,eAAe,gBAAgB,iBAAiB,uBAAuB;GAC1F,cAAc,MAAM;GAAQ,YAAY,MAAM;GAC/C,CAAA;EAGD,MAAM,aAAa,eAAe,MAAM,UAAU,WAAU;EAC5D,MAAM,gBAAgB,uBAAuB,WAAW,QAAQ,KAAA,IAAY,MAAM,MAA8B;EAChH,M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I,QAAQ,OAAO,SAAS,QAAQ,QAAQ,MAAK;IACjD,eAAoB;KAAE,IAAI,MAAM,OAAO,UAAU,QAAQ,MAAM,MAAM;MAAE;;GAEzE,cAAc;IACZ,SAAS,oBAAoB,WAAW,IAAG;IAC3C,OAAO,oBAAoB,UAAU,YAAY,KAAI;IACrD,OAAO,oBAAoB,UAAU,WAAU;IAC/C,SAAS,oBAAoB,cAAc,aAAY;IACvD,SAAS,oBAAoB,aAAa,KAAI;IAC9C,UAAU,YAAW;KACtB;KACA,EAAE,WAAW,MAAM,CAAA;EACtB,sBAAsB;GAAE,aAAa,SAAS;IAAE;;uBAG9C,YAwBW,UAAA,EAxBD,IAAG,QAAM,EAAA,CAET,MAAA,MAAK,KAAA,YAAA,CAAkB,MAAA,SAAQ,IAAA,WAAA,EADvC,mBAsBM,OAAA;;IApBH,IAAI,MAAA,GAAE;aACH;IAAJ,KAAI;IACJ,MAAK;IACL,2BAAwB;IACvB,mBAAiB,MAAA,MAAK;IACtB,mBAAiB,SAAA;IACjB,kBAAgB,MAAA,aAAY;IAC5B,kBAAgB,IAAA,OAAK;IACrB,mBAAiB,MAAA,YAAW;IAC5B,OAAK,eAAA;KAAA;KAAgD,aAAA;KAAc,YAAA;KAAW,CAAA;IAC9E,OAAK,eAAE,WAAA,MAAU;IACjB,gBAAY,cAAO,QAAM,CAAA,OAAA,CAAA;OAE1B,WAAQ,KAAA,QAAA,UAAA,EAEA,QAAA,SAAS,IAAA,SAAA,WAAA,EADjB,mBAKE,QAAA;;IAHA,eAAY;IACX,OAAK,eAAA;KAAA;KAA2D,gBAAA;KAAiB,iBAAA;KAAgB,CAAA;IACjG,OAAK,eAAE,WAAA,MAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"GlassSwitch.cjs","names":[],"sources":["../../../../src/components/forms/glass-switch/GlassSwitch.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, onMounted, ref, useAttrs } from 'vue'\nimport type { GlassSwitchProps } from '../../../interfaces/forms/GlassSwitch.interface'\nimport { useFieldState } from '../../../composables/useField'\nimport { useResolvedRadius, useResolvedSize } from '../../../composables/useModoConfig'\nimport Typography from '../../data-display/Typography.vue'\nimport './glass-switch.css'\n\ndefineOptions({ name: 'GlassSwitch', inheritAttrs: false })\nconst props = withDefaults(defineProps<GlassSwitchProps>(), {\n modelValue: undefined,\n defaultChecked: false,\n color: 'default',\n labelPosition: 'right',\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n value: 'on',\n})\nconst emit = defineEmits<{ 'update:modelValue': [value: boolean]; change: [value: boolean] }>()\nconst attrs = useAttrs()\n// class/style lay out the field; every other attribute lands on the real input.\nconst inputAttrs = computed(() => { const { class: _c, style: _s, ...rest } = attrs; return rest })\n\nconst { fieldId, stateColor, hasError, isDisabled, errorId, helperId, describedBy } = useFieldState(props, {\n componentName: 'GlassSwitch',\n idPrefix: 'modo-glass-switch',\n})\n\nconst size = useResolvedSize(() => props.size)\n// Track radius (default pill), same steps as the native Switch track. The thumb stays round.\nconst resolvedRadius = useResolvedRadius(() => props.radius ?? 'full')\nconst trackRadiusClass = computed(() => {\n switch (resolvedRadius.value) {\n case 'none': return 'rounded-none'\n case 'small': return 'rounded-sm'\n case 'medium': return 'rounded-md'\n case 'large': return 'rounded-lg'\n case 'full':\n default: return 'rounded-full'\n }\n})\nconst labelSizeClass = computed(() => {\n switch (size.value) {\n case 'xsmall':\n case 'small': return 'text-caption'\n case 'large': return 'text-body-lg'\n case 'medium':\n default: return 'text-body'\n }\n})\n\nconst CHECKED_BG_BY_COLOR: Record<string, string> = {\n default: 'bg-foreground',\n primary: 'bg-primary',\n danger: 'bg-destructive',\n success: 'bg-success',\n warning: 'bg-warning',\n}\nconst fillClass = computed(() => CHECKED_BG_BY_COLOR[stateColor.value] ?? 'bg-foreground')\nconst trackStateClass = computed(() => (hasError.value ? 'bg-destructive/20' : 'bg-input group-hover:bg-muted'))\n\nconst internal = ref(props.defaultChecked)\nconst checked = computed(() => props.modelValue ?? internal.value)\nconst descriptionId = computed(() => `${fieldId.value}-description`)\nconst ariaDescribedBy = computed(() => {\n const ids = [props.description ? descriptionId.value : '', describedBy.value, attrs['aria-describedby'] as string | undefined]\n return ids.filter(Boolean).join(' ') || undefined\n})\nconst isLocked = computed(() => isDisabled.value || props.readonly)\n\nconst input = ref<HTMLInputElement | null>(null)\nconst track = ref<HTMLElement | null>(null)\nlet stopDrag: (() => void) | undefined\nlet suppressUntil = 0\nlet resetForm: HTMLFormElement | null = null\n\nfunction change(event: Event) {\n const target = event.target as HTMLInputElement\n if (props.readonly) { target.checked = checked.value; return }\n internal.value = target.checked\n emit('update:modelValue', target.checked)\n emit('change', target.checked)\n // Controlled consumers remain the source of truth.\n if (props.modelValue !== undefined) target.checked = checked.value\n}\nfunction reset() { internal.value = props.defaultChecked; emit('update:modelValue', props.defaultChecked) }\nonMounted(() => { resetForm = input.value?.form ?? null; resetForm?.addEventListener('reset', reset) })\nfunction click(event: MouseEvent) {\n if (Date.now() < suppressUntil) { event.preventDefault(); event.stopPropagation(); suppressUntil = 0 }\n}\nfunction start(event: PointerEvent) {\n const el = input.value, rail = track.value\n if (!el || !rail || isLocked.value || event.button > 0) return\n stopDrag?.()\n suppressUntil = 0\n const thumb = rail.querySelector<HTMLElement>('.modo-glass-switch__thumb')!\n const fill = rail.querySelector<HTMLElement>('.modo-glass-switch__fill')!\n const travel = Math.max(1, rail.clientWidth - thumb.offsetWidth - thumb.offsetLeft * 2)\n const from = checked.value ? 1 : 0\n const startX = event.clientX\n let progress = from, moved = false\n const move = (e: PointerEvent) => {\n if (e.pointerId !== event.pointerId) return\n const dx = e.clientX - startX\n if (Math.abs(dx) > 4) moved = true\n if (!moved) return\n progress = Math.min(1, Math.max(0, from + dx / travel))\n rail.setAttribute('data-modo-dragging', '')\n thumb.style.transform = `translateX(${progress * travel}px)`\n fill.style.opacity = String(progress)\n }\n const clean = () => {\n document.removeEventListener('pointermove', move)\n document.removeEventListener('pointerup', end)\n document.removeEventListener('pointercancel', end)\n rail.removeAttribute('data-modo-dragging')\n thumb.style.transform = ''; fill.style.opacity = ''\n stopDrag = undefined\n }\n const end = (e: PointerEvent) => {\n if (e.pointerId !== event.pointerId) return\n clean()\n if (!moved) return\n if (e.type !== 'pointercancel' && !isLocked.value && (progress > .5) !== checked.value) el.click()\n suppressUntil = Date.now() + 350\n }\n document.addEventListener('pointermove', move, { passive: true })\n document.addEventListener('pointerup', end)\n document.addEventListener('pointercancel', end)\n stopDrag = clean\n}\nonBeforeUnmount(() => { stopDrag?.(); resetForm?.removeEventListener('reset', reset) })\ndefineExpose({ focus: () => input.value?.focus() })\n</script>\n\n<template>\n <div :class=\"['flex flex-col gap-1', fullWidth ? 'w-full' : 'inline-flex', attrs.class]\" :style=\"attrs.style as any\">\n <label\n :for=\"fieldId\"\n :data-modo-size=\"size\"\n :class=\"[\n 'modo-glass-switch group inline-flex items-start gap-2.5 select-none',\n labelPosition === 'left' ? 'flex-row-reverse justify-end' : '',\n isDisabled ? 'opacity-60 cursor-not-allowed' : readonly ? 'cursor-default' : 'cursor-pointer',\n ]\"\n @click.capture=\"click\"\n >\n <input\n v-bind=\"inputAttrs\"\n :id=\"fieldId\"\n ref=\"input\"\n class=\"modo-glass-switch__input peer sr-only\"\n type=\"checkbox\"\n role=\"switch\"\n :checked=\"checked\"\n :disabled=\"isDisabled\"\n :readonly=\"readonly\"\n :required=\"required\"\n :name=\"name\"\n :value=\"value\"\n :aria-label=\"!label ? ariaLabel : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-readonly=\"readonly || undefined\"\n :aria-describedby=\"ariaDescribedBy\"\n @change=\"change\"\n />\n <span\n ref=\"track\"\n aria-hidden=\"true\"\n :class=\"[\n 'modo-glass-switch__track mt-0.5 ring-4 ring-border/25',\n 'peer-focus-visible:ring-2 peer-focus-visible:ring-ring/60',\n trackRadiusClass,\n trackStateClass,\n ]\"\n @pointerdown=\"start\"\n >\n <span :class=\"['modo-glass-switch__fill', fillClass]\" /><span class=\"modo-glass-switch__thumb\" />\n </span>\n <span v-if=\"label || description\" class=\"flex flex-col gap-0.5\">\n <span v-if=\"label\" :class=\"['font-medium text-foreground', labelSizeClass]\">\n {{ label }}\n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span>\n </span>\n <span v-if=\"description\" :id=\"descriptionId\" class=\"text-caption text-muted-foreground\">{{ description }}</span>\n </span>\n </label>\n\n <Typography v-if=\"hasError && errorText\" :id=\"errorId\" variant=\"caption\" size=\"medium\" color=\"danger\" as=\"p\" role=\"alert\">\n {{ errorText }}\n </Typography>\n <Typography v-else-if=\"helperText\" :id=\"helperId\" variant=\"caption\" size=\"medium\" color=\"muted\" as=\"p\">\n {{ helperText }}\n </Typography>\n </div>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"GlassSwitch.cjs","names":[],"sources":["../../../../src/components/forms/glass-switch/GlassSwitch.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, onMounted, ref, useAttrs } from 'vue'\nimport type { GlassSwitchProps } from '../../../interfaces/forms/GlassSwitch.interface'\nimport { useFieldState } from '../../../composables/useField'\nimport { useResolvedRadius, useResolvedSize } from '../../../composables/useModoConfig'\nimport Typography from '../../data-display/Typography.vue'\nimport './glass-switch.css'\n\ndefineOptions({ name: 'GlassSwitch', inheritAttrs: false })\nconst props = withDefaults(defineProps<GlassSwitchProps>(), {\n modelValue: undefined,\n defaultChecked: false,\n color: 'default',\n labelPosition: 'right',\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n value: 'on',\n})\nconst emit = defineEmits<{ 'update:modelValue': [value: boolean]; change: [value: boolean] }>()\nconst attrs = useAttrs()\n// class/style lay out the field; every other attribute lands on the real input.\nconst inputAttrs = computed(() => { const { class: _c, style: _s, ...rest } = attrs; return rest })\n\nconst { fieldId, stateColor, hasError, isDisabled, errorId, helperId, describedBy } = useFieldState(props, {\n componentName: 'GlassSwitch',\n idPrefix: 'modo-glass-switch',\n})\n\nconst size = useResolvedSize(() => props.size)\n// Track radius (default pill), same steps as the native Switch track. The thumb stays round.\nconst resolvedRadius = useResolvedRadius(() => props.radius ?? 'full')\nconst trackRadiusClass = computed(() => {\n switch (resolvedRadius.value) {\n case 'none': return 'rounded-none'\n case 'small': return 'rounded-sm'\n case 'medium': return 'rounded-md'\n case 'large': return 'rounded-lg'\n case 'full':\n default: return 'rounded-full'\n }\n})\nconst CHECKED_BG_BY_COLOR: Record<string, string> = {\n default: 'bg-primary',\n primary: 'bg-primary',\n danger: 'bg-destructive',\n success: 'bg-success',\n warning: 'bg-warning',\n}\nconst fillClass = computed(() => CHECKED_BG_BY_COLOR[stateColor.value] ?? 'bg-primary')\n\n\nconst internal = ref(props.defaultChecked)\nconst checked = computed(() => props.modelValue ?? internal.value)\nconst descriptionId = computed(() => `${fieldId.value}-description`)\nconst ariaDescribedBy = computed(() => {\n const ids = [props.description ? descriptionId.value : '', describedBy.value, attrs['aria-describedby'] as string | undefined]\n return ids.filter(Boolean).join(' ') || undefined\n})\nconst isLocked = computed(() => isDisabled.value || props.readonly)\n\nconst input = ref<HTMLInputElement | null>(null)\nconst track = ref<HTMLElement | null>(null)\nlet stopDrag: (() => void) | undefined\nlet suppressUntil = 0\nlet resetForm: HTMLFormElement | null = null\n\nfunction change(event: Event) {\n const target = event.target as HTMLInputElement\n if (props.readonly) { target.checked = checked.value; return }\n internal.value = target.checked\n emit('update:modelValue', target.checked)\n emit('change', target.checked)\n // Controlled consumers remain the source of truth.\n if (props.modelValue !== undefined) target.checked = checked.value\n}\nfunction reset() { internal.value = props.defaultChecked; emit('update:modelValue', props.defaultChecked) }\nonMounted(() => { resetForm = input.value?.form ?? null; resetForm?.addEventListener('reset', reset) })\nfunction click(event: MouseEvent) {\n if (Date.now() < suppressUntil) { event.preventDefault(); event.stopPropagation(); suppressUntil = 0 }\n}\nfunction start(event: PointerEvent) {\n const el = input.value, rail = track.value\n if (!el || !rail || isLocked.value || event.button > 0) return\n stopDrag?.()\n suppressUntil = 0\n const thumb = rail.querySelector<HTMLElement>('.modo-glass-switch__thumb')!\n const fill = rail.querySelector<HTMLElement>('.modo-glass-switch__fill')!\n const travel = Math.max(1, rail.clientWidth - thumb.offsetWidth - thumb.offsetLeft * 2)\n const from = checked.value ? 1 : 0\n const startX = event.clientX\n let progress = from, moved = false\n const move = (e: PointerEvent) => {\n if (e.pointerId !== event.pointerId) return\n const dx = e.clientX - startX\n if (Math.abs(dx) > 4) moved = true\n if (!moved) return\n progress = Math.min(1, Math.max(0, from + dx / travel))\n rail.setAttribute('data-modo-dragging', '')\n thumb.style.transform = `translateX(${progress * travel}px)`\n fill.style.opacity = String(progress)\n }\n const clean = () => {\n document.removeEventListener('pointermove', move)\n document.removeEventListener('pointerup', end)\n document.removeEventListener('pointercancel', end)\n rail.removeAttribute('data-modo-dragging')\n thumb.style.transform = ''; fill.style.opacity = ''\n stopDrag = undefined\n }\n const end = (e: PointerEvent) => {\n if (e.pointerId !== event.pointerId) return\n clean()\n if (!moved) return\n if (e.type !== 'pointercancel' && !isLocked.value && (progress > .5) !== checked.value) el.click()\n suppressUntil = Date.now() + 350\n }\n document.addEventListener('pointermove', move, { passive: true })\n document.addEventListener('pointerup', end)\n document.addEventListener('pointercancel', end)\n stopDrag = clean\n}\nonBeforeUnmount(() => { stopDrag?.(); resetForm?.removeEventListener('reset', reset) })\ndefineExpose({ focus: () => input.value?.focus() })\n</script>\n\n<template>\n <div :class=\"['flex flex-col gap-1', fullWidth ? 'w-full' : 'inline-flex', attrs.class]\" :style=\"attrs.style as any\">\n <label\n :for=\"fieldId\"\n :data-modo-size=\"size\"\n :data-modo-label-first=\"labelPosition === 'left' ? '' : undefined\"\n :class=\"[\n 'modo-glass-switch group inline-flex items-start select-none',\n labelPosition === 'left' ? 'flex-row-reverse justify-between' : '',\n isDisabled ? 'opacity-60 cursor-not-allowed' : readonly ? 'cursor-default' : 'cursor-pointer',\n ]\"\n @click.capture=\"click\"\n >\n <input\n v-bind=\"inputAttrs\"\n :id=\"fieldId\"\n ref=\"input\"\n class=\"modo-glass-switch__input peer sr-only\"\n type=\"checkbox\"\n role=\"switch\"\n :checked=\"checked\"\n :disabled=\"isDisabled\"\n :readonly=\"readonly\"\n :required=\"required\"\n :name=\"name\"\n :value=\"value\"\n :aria-label=\"!label ? ariaLabel : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-readonly=\"readonly || undefined\"\n :aria-describedby=\"ariaDescribedBy\"\n @change=\"change\"\n />\n <span\n ref=\"track\"\n aria-hidden=\"true\"\n :class=\"[\n 'modo-glass-switch__track',\n 'peer-focus-visible:ring-2 peer-focus-visible:ring-ring/60',\n trackRadiusClass,\n\n ]\"\n @pointerdown=\"start\"\n >\n <span :class=\"['modo-glass-switch__fill', fillClass]\" /><span class=\"modo-glass-switch__thumb\" />\n </span>\n <span v-if=\"label || description\" class=\"modo-glass-switch__text\">\n <span v-if=\"label\" class=\"modo-glass-switch__label\">\n {{ label }}\n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span>\n </span>\n <span v-if=\"description\" :id=\"descriptionId\" class=\"modo-glass-switch__description\">{{ description }}</span>\n </span>\n </label>\n\n <Typography v-if=\"hasError && errorText\" :id=\"errorId\" variant=\"caption\" size=\"medium\" color=\"danger\" as=\"p\" role=\"alert\">\n {{ errorText }}\n </Typography>\n <Typography v-else-if=\"helperText\" :id=\"helperId\" variant=\"caption\" size=\"medium\" color=\"muted\" as=\"p\">\n {{ helperText }}\n </Typography>\n </div>\n</template>\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"GlassSwitch.mjs","names":[],"sources":["../../../../src/components/forms/glass-switch/GlassSwitch.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, onMounted, ref, useAttrs } from 'vue'\nimport type { GlassSwitchProps } from '../../../interfaces/forms/GlassSwitch.interface'\nimport { useFieldState } from '../../../composables/useField'\nimport { useResolvedRadius, useResolvedSize } from '../../../composables/useModoConfig'\nimport Typography from '../../data-display/Typography.vue'\nimport './glass-switch.css'\n\ndefineOptions({ name: 'GlassSwitch', inheritAttrs: false })\nconst props = withDefaults(defineProps<GlassSwitchProps>(), {\n modelValue: undefined,\n defaultChecked: false,\n color: 'default',\n labelPosition: 'right',\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n value: 'on',\n})\nconst emit = defineEmits<{ 'update:modelValue': [value: boolean]; change: [value: boolean] }>()\nconst attrs = useAttrs()\n// class/style lay out the field; every other attribute lands on the real input.\nconst inputAttrs = computed(() => { const { class: _c, style: _s, ...rest } = attrs; return rest })\n\nconst { fieldId, stateColor, hasError, isDisabled, errorId, helperId, describedBy } = useFieldState(props, {\n componentName: 'GlassSwitch',\n idPrefix: 'modo-glass-switch',\n})\n\nconst size = useResolvedSize(() => props.size)\n// Track radius (default pill), same steps as the native Switch track. The thumb stays round.\nconst resolvedRadius = useResolvedRadius(() => props.radius ?? 'full')\nconst trackRadiusClass = computed(() => {\n switch (resolvedRadius.value) {\n case 'none': return 'rounded-none'\n case 'small': return 'rounded-sm'\n case 'medium': return 'rounded-md'\n case 'large': return 'rounded-lg'\n case 'full':\n default: return 'rounded-full'\n }\n})\nconst labelSizeClass = computed(() => {\n switch (size.value) {\n case 'xsmall':\n case 'small': return 'text-caption'\n case 'large': return 'text-body-lg'\n case 'medium':\n default: return 'text-body'\n }\n})\n\nconst CHECKED_BG_BY_COLOR: Record<string, string> = {\n default: 'bg-foreground',\n primary: 'bg-primary',\n danger: 'bg-destructive',\n success: 'bg-success',\n warning: 'bg-warning',\n}\nconst fillClass = computed(() => CHECKED_BG_BY_COLOR[stateColor.value] ?? 'bg-foreground')\nconst trackStateClass = computed(() => (hasError.value ? 'bg-destructive/20' : 'bg-input group-hover:bg-muted'))\n\nconst internal = ref(props.defaultChecked)\nconst checked = computed(() => props.modelValue ?? internal.value)\nconst descriptionId = computed(() => `${fieldId.value}-description`)\nconst ariaDescribedBy = computed(() => {\n const ids = [props.description ? descriptionId.value : '', describedBy.value, attrs['aria-describedby'] as string | undefined]\n return ids.filter(Boolean).join(' ') || undefined\n})\nconst isLocked = computed(() => isDisabled.value || props.readonly)\n\nconst input = ref<HTMLInputElement | null>(null)\nconst track = ref<HTMLElement | null>(null)\nlet stopDrag: (() => void) | undefined\nlet suppressUntil = 0\nlet resetForm: HTMLFormElement | null = null\n\nfunction change(event: Event) {\n const target = event.target as HTMLInputElement\n if (props.readonly) { target.checked = checked.value; return }\n internal.value = target.checked\n emit('update:modelValue', target.checked)\n emit('change', target.checked)\n // Controlled consumers remain the source of truth.\n if (props.modelValue !== undefined) target.checked = checked.value\n}\nfunction reset() { internal.value = props.defaultChecked; emit('update:modelValue', props.defaultChecked) }\nonMounted(() => { resetForm = input.value?.form ?? null; resetForm?.addEventListener('reset', reset) })\nfunction click(event: MouseEvent) {\n if (Date.now() < suppressUntil) { event.preventDefault(); event.stopPropagation(); suppressUntil = 0 }\n}\nfunction start(event: PointerEvent) {\n const el = input.value, rail = track.value\n if (!el || !rail || isLocked.value || event.button > 0) return\n stopDrag?.()\n suppressUntil = 0\n const thumb = rail.querySelector<HTMLElement>('.modo-glass-switch__thumb')!\n const fill = rail.querySelector<HTMLElement>('.modo-glass-switch__fill')!\n const travel = Math.max(1, rail.clientWidth - thumb.offsetWidth - thumb.offsetLeft * 2)\n const from = checked.value ? 1 : 0\n const startX = event.clientX\n let progress = from, moved = false\n const move = (e: PointerEvent) => {\n if (e.pointerId !== event.pointerId) return\n const dx = e.clientX - startX\n if (Math.abs(dx) > 4) moved = true\n if (!moved) return\n progress = Math.min(1, Math.max(0, from + dx / travel))\n rail.setAttribute('data-modo-dragging', '')\n thumb.style.transform = `translateX(${progress * travel}px)`\n fill.style.opacity = String(progress)\n }\n const clean = () => {\n document.removeEventListener('pointermove', move)\n document.removeEventListener('pointerup', end)\n document.removeEventListener('pointercancel', end)\n rail.removeAttribute('data-modo-dragging')\n thumb.style.transform = ''; fill.style.opacity = ''\n stopDrag = undefined\n }\n const end = (e: PointerEvent) => {\n if (e.pointerId !== event.pointerId) return\n clean()\n if (!moved) return\n if (e.type !== 'pointercancel' && !isLocked.value && (progress > .5) !== checked.value) el.click()\n suppressUntil = Date.now() + 350\n }\n document.addEventListener('pointermove', move, { passive: true })\n document.addEventListener('pointerup', end)\n document.addEventListener('pointercancel', end)\n stopDrag = clean\n}\nonBeforeUnmount(() => { stopDrag?.(); resetForm?.removeEventListener('reset', reset) })\ndefineExpose({ focus: () => input.value?.focus() })\n</script>\n\n<template>\n <div :class=\"['flex flex-col gap-1', fullWidth ? 'w-full' : 'inline-flex', attrs.class]\" :style=\"attrs.style as any\">\n <label\n :for=\"fieldId\"\n :data-modo-size=\"size\"\n :class=\"[\n 'modo-glass-switch group inline-flex items-start gap-2.5 select-none',\n labelPosition === 'left' ? 'flex-row-reverse justify-end' : '',\n isDisabled ? 'opacity-60 cursor-not-allowed' : readonly ? 'cursor-default' : 'cursor-pointer',\n ]\"\n @click.capture=\"click\"\n >\n <input\n v-bind=\"inputAttrs\"\n :id=\"fieldId\"\n ref=\"input\"\n class=\"modo-glass-switch__input peer sr-only\"\n type=\"checkbox\"\n role=\"switch\"\n :checked=\"checked\"\n :disabled=\"isDisabled\"\n :readonly=\"readonly\"\n :required=\"required\"\n :name=\"name\"\n :value=\"value\"\n :aria-label=\"!label ? ariaLabel : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-readonly=\"readonly || undefined\"\n :aria-describedby=\"ariaDescribedBy\"\n @change=\"change\"\n />\n <span\n ref=\"track\"\n aria-hidden=\"true\"\n :class=\"[\n 'modo-glass-switch__track mt-0.5 ring-4 ring-border/25',\n 'peer-focus-visible:ring-2 peer-focus-visible:ring-ring/60',\n trackRadiusClass,\n trackStateClass,\n ]\"\n @pointerdown=\"start\"\n >\n <span :class=\"['modo-glass-switch__fill', fillClass]\" /><span class=\"modo-glass-switch__thumb\" />\n </span>\n <span v-if=\"label || description\" class=\"flex flex-col gap-0.5\">\n <span v-if=\"label\" :class=\"['font-medium text-foreground', labelSizeClass]\">\n {{ label }}\n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span>\n </span>\n <span v-if=\"description\" :id=\"descriptionId\" class=\"text-caption text-muted-foreground\">{{ description }}</span>\n </span>\n </label>\n\n <Typography v-if=\"hasError && errorText\" :id=\"errorId\" variant=\"caption\" size=\"medium\" color=\"danger\" as=\"p\" role=\"alert\">\n {{ errorText }}\n </Typography>\n <Typography v-else-if=\"helperText\" :id=\"helperId\" variant=\"caption\" size=\"medium\" color=\"muted\" as=\"p\">\n {{ helperText }}\n </Typography>\n </div>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"GlassSwitch.mjs","names":[],"sources":["../../../../src/components/forms/glass-switch/GlassSwitch.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, onMounted, ref, useAttrs } from 'vue'\nimport type { GlassSwitchProps } from '../../../interfaces/forms/GlassSwitch.interface'\nimport { useFieldState } from '../../../composables/useField'\nimport { useResolvedRadius, useResolvedSize } from '../../../composables/useModoConfig'\nimport Typography from '../../data-display/Typography.vue'\nimport './glass-switch.css'\n\ndefineOptions({ name: 'GlassSwitch', inheritAttrs: false })\nconst props = withDefaults(defineProps<GlassSwitchProps>(), {\n modelValue: undefined,\n defaultChecked: false,\n color: 'default',\n labelPosition: 'right',\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n value: 'on',\n})\nconst emit = defineEmits<{ 'update:modelValue': [value: boolean]; change: [value: boolean] }>()\nconst attrs = useAttrs()\n// class/style lay out the field; every other attribute lands on the real input.\nconst inputAttrs = computed(() => { const { class: _c, style: _s, ...rest } = attrs; return rest })\n\nconst { fieldId, stateColor, hasError, isDisabled, errorId, helperId, describedBy } = useFieldState(props, {\n componentName: 'GlassSwitch',\n idPrefix: 'modo-glass-switch',\n})\n\nconst size = useResolvedSize(() => props.size)\n// Track radius (default pill), same steps as the native Switch track. The thumb stays round.\nconst resolvedRadius = useResolvedRadius(() => props.radius ?? 'full')\nconst trackRadiusClass = computed(() => {\n switch (resolvedRadius.value) {\n case 'none': return 'rounded-none'\n case 'small': return 'rounded-sm'\n case 'medium': return 'rounded-md'\n case 'large': return 'rounded-lg'\n case 'full':\n default: return 'rounded-full'\n }\n})\nconst CHECKED_BG_BY_COLOR: Record<string, string> = {\n default: 'bg-primary',\n primary: 'bg-primary',\n danger: 'bg-destructive',\n success: 'bg-success',\n warning: 'bg-warning',\n}\nconst fillClass = computed(() => CHECKED_BG_BY_COLOR[stateColor.value] ?? 'bg-primary')\n\n\nconst internal = ref(props.defaultChecked)\nconst checked = computed(() => props.modelValue ?? internal.value)\nconst descriptionId = computed(() => `${fieldId.value}-description`)\nconst ariaDescribedBy = computed(() => {\n const ids = [props.description ? descriptionId.value : '', describedBy.value, attrs['aria-describedby'] as string | undefined]\n return ids.filter(Boolean).join(' ') || undefined\n})\nconst isLocked = computed(() => isDisabled.value || props.readonly)\n\nconst input = ref<HTMLInputElement | null>(null)\nconst track = ref<HTMLElement | null>(null)\nlet stopDrag: (() => void) | undefined\nlet suppressUntil = 0\nlet resetForm: HTMLFormElement | null = null\n\nfunction change(event: Event) {\n const target = event.target as HTMLInputElement\n if (props.readonly) { target.checked = checked.value; return }\n internal.value = target.checked\n emit('update:modelValue', target.checked)\n emit('change', target.checked)\n // Controlled consumers remain the source of truth.\n if (props.modelValue !== undefined) target.checked = checked.value\n}\nfunction reset() { internal.value = props.defaultChecked; emit('update:modelValue', props.defaultChecked) }\nonMounted(() => { resetForm = input.value?.form ?? null; resetForm?.addEventListener('reset', reset) })\nfunction click(event: MouseEvent) {\n if (Date.now() < suppressUntil) { event.preventDefault(); event.stopPropagation(); suppressUntil = 0 }\n}\nfunction start(event: PointerEvent) {\n const el = input.value, rail = track.value\n if (!el || !rail || isLocked.value || event.button > 0) return\n stopDrag?.()\n suppressUntil = 0\n const thumb = rail.querySelector<HTMLElement>('.modo-glass-switch__thumb')!\n const fill = rail.querySelector<HTMLElement>('.modo-glass-switch__fill')!\n const travel = Math.max(1, rail.clientWidth - thumb.offsetWidth - thumb.offsetLeft * 2)\n const from = checked.value ? 1 : 0\n const startX = event.clientX\n let progress = from, moved = false\n const move = (e: PointerEvent) => {\n if (e.pointerId !== event.pointerId) return\n const dx = e.clientX - startX\n if (Math.abs(dx) > 4) moved = true\n if (!moved) return\n progress = Math.min(1, Math.max(0, from + dx / travel))\n rail.setAttribute('data-modo-dragging', '')\n thumb.style.transform = `translateX(${progress * travel}px)`\n fill.style.opacity = String(progress)\n }\n const clean = () => {\n document.removeEventListener('pointermove', move)\n document.removeEventListener('pointerup', end)\n document.removeEventListener('pointercancel', end)\n rail.removeAttribute('data-modo-dragging')\n thumb.style.transform = ''; fill.style.opacity = ''\n stopDrag = undefined\n }\n const end = (e: PointerEvent) => {\n if (e.pointerId !== event.pointerId) return\n clean()\n if (!moved) return\n if (e.type !== 'pointercancel' && !isLocked.value && (progress > .5) !== checked.value) el.click()\n suppressUntil = Date.now() + 350\n }\n document.addEventListener('pointermove', move, { passive: true })\n document.addEventListener('pointerup', end)\n document.addEventListener('pointercancel', end)\n stopDrag = clean\n}\nonBeforeUnmount(() => { stopDrag?.(); resetForm?.removeEventListener('reset', reset) })\ndefineExpose({ focus: () => input.value?.focus() })\n</script>\n\n<template>\n <div :class=\"['flex flex-col gap-1', fullWidth ? 'w-full' : 'inline-flex', attrs.class]\" :style=\"attrs.style as any\">\n <label\n :for=\"fieldId\"\n :data-modo-size=\"size\"\n :data-modo-label-first=\"labelPosition === 'left' ? '' : undefined\"\n :class=\"[\n 'modo-glass-switch group inline-flex items-start select-none',\n labelPosition === 'left' ? 'flex-row-reverse justify-between' : '',\n isDisabled ? 'opacity-60 cursor-not-allowed' : readonly ? 'cursor-default' : 'cursor-pointer',\n ]\"\n @click.capture=\"click\"\n >\n <input\n v-bind=\"inputAttrs\"\n :id=\"fieldId\"\n ref=\"input\"\n class=\"modo-glass-switch__input peer sr-only\"\n type=\"checkbox\"\n role=\"switch\"\n :checked=\"checked\"\n :disabled=\"isDisabled\"\n :readonly=\"readonly\"\n :required=\"required\"\n :name=\"name\"\n :value=\"value\"\n :aria-label=\"!label ? ariaLabel : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-readonly=\"readonly || undefined\"\n :aria-describedby=\"ariaDescribedBy\"\n @change=\"change\"\n />\n <span\n ref=\"track\"\n aria-hidden=\"true\"\n :class=\"[\n 'modo-glass-switch__track',\n 'peer-focus-visible:ring-2 peer-focus-visible:ring-ring/60',\n trackRadiusClass,\n\n ]\"\n @pointerdown=\"start\"\n >\n <span :class=\"['modo-glass-switch__fill', fillClass]\" /><span class=\"modo-glass-switch__thumb\" />\n </span>\n <span v-if=\"label || description\" class=\"modo-glass-switch__text\">\n <span v-if=\"label\" class=\"modo-glass-switch__label\">\n {{ label }}\n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span>\n </span>\n <span v-if=\"description\" :id=\"descriptionId\" class=\"modo-glass-switch__description\">{{ description }}</span>\n </span>\n </label>\n\n <Typography v-if=\"hasError && errorText\" :id=\"errorId\" variant=\"caption\" size=\"medium\" color=\"danger\" as=\"p\" role=\"alert\">\n {{ errorText }}\n </Typography>\n <Typography v-else-if=\"helperText\" :id=\"helperId\" variant=\"caption\" size=\"medium\" color=\"muted\" as=\"p\">\n {{ helperText }}\n </Typography>\n </div>\n</template>\n"],"mappings":""}
@@ -5,7 +5,11 @@ const require_Typography = require("../../data-display/Typography.cjs");
5
5
  ;/* empty css */
6
6
  let vue = require("vue");
7
7
  //#region src/components/forms/glass-switch/GlassSwitch.vue?vue&type=script&setup=true&lang.ts
8
- var _hoisted_1 = ["for", "data-modo-size"];
8
+ var _hoisted_1 = [
9
+ "for",
10
+ "data-modo-size",
11
+ "data-modo-label-first"
12
+ ];
9
13
  var _hoisted_2 = [
10
14
  "id",
11
15
  "checked",
@@ -21,14 +25,18 @@ var _hoisted_2 = [
21
25
  ];
22
26
  var _hoisted_3 = {
23
27
  key: 0,
24
- class: "flex flex-col gap-0.5"
28
+ class: "modo-glass-switch__text"
25
29
  };
26
30
  var _hoisted_4 = {
31
+ key: 0,
32
+ class: "modo-glass-switch__label"
33
+ };
34
+ var _hoisted_5 = {
27
35
  key: 0,
28
36
  "aria-hidden": "true",
29
37
  class: "text-destructive ml-0.5"
30
38
  };
31
- var _hoisted_5 = ["id"];
39
+ var _hoisted_6 = ["id"];
32
40
  var GlassSwitch_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
33
41
  name: "GlassSwitch",
34
42
  inheritAttrs: false,
@@ -100,23 +108,14 @@ var GlassSwitch_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0
100
108
  default: return "rounded-full";
101
109
  }
102
110
  });
103
- const labelSizeClass = (0, vue.computed)(() => {
104
- switch (size.value) {
105
- case "xsmall":
106
- case "small": return "text-caption";
107
- case "large": return "text-body-lg";
108
- default: return "text-body";
109
- }
110
- });
111
111
  const CHECKED_BG_BY_COLOR = {
112
- default: "bg-foreground",
112
+ default: "bg-primary",
113
113
  primary: "bg-primary",
114
114
  danger: "bg-destructive",
115
115
  success: "bg-success",
116
116
  warning: "bg-warning"
117
117
  };
118
- const fillClass = (0, vue.computed)(() => CHECKED_BG_BY_COLOR[stateColor.value] ?? "bg-foreground");
119
- const trackStateClass = (0, vue.computed)(() => hasError.value ? "bg-destructive/20" : "bg-input group-hover:bg-muted");
118
+ const fillClass = (0, vue.computed)(() => CHECKED_BG_BY_COLOR[stateColor.value] ?? "bg-primary");
120
119
  const internal = (0, vue.ref)(props.defaultChecked);
121
120
  const checked = (0, vue.computed)(() => props.modelValue ?? internal.value);
122
121
  const descriptionId = (0, vue.computed)(() => `${fieldId.value}-description`);
@@ -217,9 +216,10 @@ var GlassSwitch_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0
217
216
  }, [(0, vue.createElementVNode)("label", {
218
217
  for: (0, vue.unref)(fieldId),
219
218
  "data-modo-size": (0, vue.unref)(size),
219
+ "data-modo-label-first": __props.labelPosition === "left" ? "" : void 0,
220
220
  class: (0, vue.normalizeClass)([
221
- "modo-glass-switch group inline-flex items-start gap-2.5 select-none",
222
- __props.labelPosition === "left" ? "flex-row-reverse justify-end" : "",
221
+ "modo-glass-switch group inline-flex items-start select-none",
222
+ __props.labelPosition === "left" ? "flex-row-reverse justify-between" : "",
223
223
  (0, vue.unref)(isDisabled) ? "opacity-60 cursor-not-allowed" : __props.readonly ? "cursor-default" : "cursor-pointer"
224
224
  ]),
225
225
  onClickCapture: click
@@ -248,21 +248,17 @@ var GlassSwitch_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0
248
248
  ref: track,
249
249
  "aria-hidden": "true",
250
250
  class: (0, vue.normalizeClass)([
251
- "modo-glass-switch__track mt-0.5 ring-4 ring-border/25",
251
+ "modo-glass-switch__track",
252
252
  "peer-focus-visible:ring-2 peer-focus-visible:ring-ring/60",
253
- trackRadiusClass.value,
254
- trackStateClass.value
253
+ trackRadiusClass.value
255
254
  ]),
256
255
  onPointerdown: start
257
256
  }, [(0, vue.createElementVNode)("span", { class: (0, vue.normalizeClass)(["modo-glass-switch__fill", fillClass.value]) }, null, 2), _cache[0] || (_cache[0] = (0, vue.createElementVNode)("span", { class: "modo-glass-switch__thumb" }, null, -1))], 34),
258
- __props.label || __props.description ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_3, [__props.label ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", {
259
- key: 0,
260
- class: (0, vue.normalizeClass)(["font-medium text-foreground", labelSizeClass.value])
261
- }, [(0, vue.createTextVNode)((0, vue.toDisplayString)(__props.label) + " ", 1), __props.required ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_4, "*")) : (0, vue.createCommentVNode)("", true)], 2)) : (0, vue.createCommentVNode)("", true), __props.description ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", {
257
+ __props.label || __props.description ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_3, [__props.label ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_4, [(0, vue.createTextVNode)((0, vue.toDisplayString)(__props.label) + " ", 1), __props.required ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_5, "*")) : (0, vue.createCommentVNode)("", true)])) : (0, vue.createCommentVNode)("", true), __props.description ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", {
262
258
  key: 1,
263
259
  id: descriptionId.value,
264
- class: "text-caption text-muted-foreground"
265
- }, (0, vue.toDisplayString)(__props.description), 9, _hoisted_5)) : (0, vue.createCommentVNode)("", true)])) : (0, vue.createCommentVNode)("", true)
260
+ class: "modo-glass-switch__description"
261
+ }, (0, vue.toDisplayString)(__props.description), 9, _hoisted_6)) : (0, vue.createCommentVNode)("", true)])) : (0, vue.createCommentVNode)("", true)
266
262
  ], 42, _hoisted_1), (0, vue.unref)(hasError) && __props.errorText ? ((0, vue.openBlock)(), (0, vue.createBlock)(require_Typography.default, {
267
263
  key: 0,
268
264
  id: (0, vue.unref)(errorId),
@@ -1 +1 @@
1
- {"version":3,"file":"GlassSwitch.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../../../src/components/forms/glass-switch/GlassSwitch.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, onMounted, ref, useAttrs } from 'vue'\nimport type { GlassSwitchProps } from '../../../interfaces/forms/GlassSwitch.interface'\nimport { useFieldState } from '../../../composables/useField'\nimport { useResolvedRadius, useResolvedSize } from '../../../composables/useModoConfig'\nimport Typography from '../../data-display/Typography.vue'\nimport './glass-switch.css'\n\ndefineOptions({ name: 'GlassSwitch', inheritAttrs: false })\nconst props = withDefaults(defineProps<GlassSwitchProps>(), {\n modelValue: undefined,\n defaultChecked: false,\n color: 'default',\n labelPosition: 'right',\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n value: 'on',\n})\nconst emit = defineEmits<{ 'update:modelValue': [value: boolean]; change: [value: boolean] }>()\nconst attrs = useAttrs()\n// class/style lay out the field; every other attribute lands on the real input.\nconst inputAttrs = computed(() => { const { class: _c, style: _s, ...rest } = attrs; return rest })\n\nconst { fieldId, stateColor, hasError, isDisabled, errorId, helperId, describedBy } = useFieldState(props, {\n componentName: 'GlassSwitch',\n idPrefix: 'modo-glass-switch',\n})\n\nconst size = useResolvedSize(() => props.size)\n// Track radius (default pill), same steps as the native Switch track. The thumb stays round.\nconst resolvedRadius = useResolvedRadius(() => props.radius ?? 'full')\nconst trackRadiusClass = computed(() => {\n switch (resolvedRadius.value) {\n case 'none': return 'rounded-none'\n case 'small': return 'rounded-sm'\n case 'medium': return 'rounded-md'\n case 'large': return 'rounded-lg'\n case 'full':\n default: return 'rounded-full'\n }\n})\nconst labelSizeClass = computed(() => {\n switch (size.value) {\n case 'xsmall':\n case 'small': return 'text-caption'\n case 'large': return 'text-body-lg'\n case 'medium':\n default: return 'text-body'\n }\n})\n\nconst CHECKED_BG_BY_COLOR: Record<string, string> = {\n default: 'bg-foreground',\n primary: 'bg-primary',\n danger: 'bg-destructive',\n success: 'bg-success',\n warning: 'bg-warning',\n}\nconst fillClass = computed(() => CHECKED_BG_BY_COLOR[stateColor.value] ?? 'bg-foreground')\nconst trackStateClass = computed(() => (hasError.value ? 'bg-destructive/20' : 'bg-input group-hover:bg-muted'))\n\nconst internal = ref(props.defaultChecked)\nconst checked = computed(() => props.modelValue ?? internal.value)\nconst descriptionId = computed(() => `${fieldId.value}-description`)\nconst ariaDescribedBy = computed(() => {\n const ids = [props.description ? descriptionId.value : '', describedBy.value, attrs['aria-describedby'] as string | undefined]\n return ids.filter(Boolean).join(' ') || undefined\n})\nconst isLocked = computed(() => isDisabled.value || props.readonly)\n\nconst input = ref<HTMLInputElement | null>(null)\nconst track = ref<HTMLElement | null>(null)\nlet stopDrag: (() => void) | undefined\nlet suppressUntil = 0\nlet resetForm: HTMLFormElement | null = null\n\nfunction change(event: Event) {\n const target = event.target as HTMLInputElement\n if (props.readonly) { target.checked = checked.value; return }\n internal.value = target.checked\n emit('update:modelValue', target.checked)\n emit('change', target.checked)\n // Controlled consumers remain the source of truth.\n if (props.modelValue !== undefined) target.checked = checked.value\n}\nfunction reset() { internal.value = props.defaultChecked; emit('update:modelValue', props.defaultChecked) }\nonMounted(() => { resetForm = input.value?.form ?? null; resetForm?.addEventListener('reset', reset) })\nfunction click(event: MouseEvent) {\n if (Date.now() < suppressUntil) { event.preventDefault(); event.stopPropagation(); suppressUntil = 0 }\n}\nfunction start(event: PointerEvent) {\n const el = input.value, rail = track.value\n if (!el || !rail || isLocked.value || event.button > 0) return\n stopDrag?.()\n suppressUntil = 0\n const thumb = rail.querySelector<HTMLElement>('.modo-glass-switch__thumb')!\n const fill = rail.querySelector<HTMLElement>('.modo-glass-switch__fill')!\n const travel = Math.max(1, rail.clientWidth - thumb.offsetWidth - thumb.offsetLeft * 2)\n const from = checked.value ? 1 : 0\n const startX = event.clientX\n let progress = from, moved = false\n const move = (e: PointerEvent) => {\n if (e.pointerId !== event.pointerId) return\n const dx = e.clientX - startX\n if (Math.abs(dx) > 4) moved = true\n if (!moved) return\n progress = Math.min(1, Math.max(0, from + dx / travel))\n rail.setAttribute('data-modo-dragging', '')\n thumb.style.transform = `translateX(${progress * travel}px)`\n fill.style.opacity = String(progress)\n }\n const clean = () => {\n document.removeEventListener('pointermove', move)\n document.removeEventListener('pointerup', end)\n document.removeEventListener('pointercancel', end)\n rail.removeAttribute('data-modo-dragging')\n thumb.style.transform = ''; fill.style.opacity = ''\n stopDrag = undefined\n }\n const end = (e: PointerEvent) => {\n if (e.pointerId !== event.pointerId) return\n clean()\n if (!moved) return\n if (e.type !== 'pointercancel' && !isLocked.value && (progress > .5) !== checked.value) el.click()\n suppressUntil = Date.now() + 350\n }\n document.addEventListener('pointermove', move, { passive: true })\n document.addEventListener('pointerup', end)\n document.addEventListener('pointercancel', end)\n stopDrag = clean\n}\nonBeforeUnmount(() => { stopDrag?.(); resetForm?.removeEventListener('reset', reset) })\ndefineExpose({ focus: () => input.value?.focus() })\n</script>\n\n<template>\n <div :class=\"['flex flex-col gap-1', fullWidth ? 'w-full' : 'inline-flex', attrs.class]\" :style=\"attrs.style as any\">\n <label\n :for=\"fieldId\"\n :data-modo-size=\"size\"\n :class=\"[\n 'modo-glass-switch group inline-flex items-start gap-2.5 select-none',\n labelPosition === 'left' ? 'flex-row-reverse justify-end' : '',\n isDisabled ? 'opacity-60 cursor-not-allowed' : readonly ? 'cursor-default' : 'cursor-pointer',\n ]\"\n @click.capture=\"click\"\n >\n <input\n v-bind=\"inputAttrs\"\n :id=\"fieldId\"\n ref=\"input\"\n class=\"modo-glass-switch__input peer sr-only\"\n type=\"checkbox\"\n role=\"switch\"\n :checked=\"checked\"\n :disabled=\"isDisabled\"\n :readonly=\"readonly\"\n :required=\"required\"\n :name=\"name\"\n :value=\"value\"\n :aria-label=\"!label ? ariaLabel : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-readonly=\"readonly || undefined\"\n :aria-describedby=\"ariaDescribedBy\"\n @change=\"change\"\n />\n <span\n ref=\"track\"\n aria-hidden=\"true\"\n :class=\"[\n 'modo-glass-switch__track mt-0.5 ring-4 ring-border/25',\n 'peer-focus-visible:ring-2 peer-focus-visible:ring-ring/60',\n trackRadiusClass,\n trackStateClass,\n ]\"\n @pointerdown=\"start\"\n >\n <span :class=\"['modo-glass-switch__fill', fillClass]\" /><span class=\"modo-glass-switch__thumb\" />\n </span>\n <span v-if=\"label || description\" class=\"flex flex-col gap-0.5\">\n <span v-if=\"label\" :class=\"['font-medium text-foreground', labelSizeClass]\">\n {{ label }}\n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span>\n </span>\n <span v-if=\"description\" :id=\"descriptionId\" class=\"text-caption text-muted-foreground\">{{ description }}</span>\n </span>\n </label>\n\n <Typography v-if=\"hasError && errorText\" :id=\"errorId\" variant=\"caption\" size=\"medium\" color=\"danger\" as=\"p\" role=\"alert\">\n {{ errorText }}\n </Typography>\n <Typography v-else-if=\"helperText\" :id=\"helperId\" variant=\"caption\" size=\"medium\" color=\"muted\" as=\"p\">\n {{ helperText }}\n </Typography>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASA,MAAM,QAAQ;EAYd,MAAM,OAAO;EACb,MAAM,SAAA,GAAA,IAAA,WAAiB;EAEvB,MAAM,cAAA,GAAA,IAAA,gBAA4B;GAAE,MAAM,EAAE,OAAO,IAAI,OAAO,IAAI,GAAG,SAAS;GAAO,OAAO;IAAM;EAElG,MAAM,EAAE,SAAS,YAAY,UAAU,YAAY,SAAS,UAAU,gBAAgB,iBAAA,cAAc,OAAO;GACzG,eAAe;GACf,UAAU;GACX,CAAA;EAED,MAAM,OAAO,sBAAA,sBAAsB,MAAM,KAAI;EAE7C,MAAM,iBAAiB,sBAAA,wBAAwB,MAAM,UAAU,OAAM;EACrE,MAAM,oBAAA,GAAA,IAAA,gBAAkC;GACtC,QAAQ,eAAe,OAAvB;IACE,KAAK,QAAQ,OAAO;IACpB,KAAK,SAAS,OAAO;IACrB,KAAK,UAAU,OAAO;IACtB,KAAK,SAAS,OAAO;IAErB,SAAS,OAAO;;IAEnB;EACD,MAAM,kBAAA,GAAA,IAAA,gBAAgC;GACpC,QAAQ,KAAK,OAAb;IACE,KAAK;IACL,KAAK,SAAS,OAAO;IACrB,KAAK,SAAS,OAAO;IAErB,SAAS,OAAO;;IAEnB;EAED,MAAM,sBAA8C;GAClD,SAAS;GACT,SAAS;GACT,QAAQ;GACR,SAAS;GACT,SAAS;GACX;EACA,MAAM,aAAA,GAAA,IAAA,gBAA2B,oBAAoB,WAAW,UAAU,gBAAe;EACzF,MAAM,mBAAA,GAAA,IAAA,gBAAkC,SAAS,QAAQ,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AA,WAAU,EAAA,EAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"GlassSwitch.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../../../src/components/forms/glass-switch/GlassSwitch.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, onMounted, ref, useAttrs } from 'vue'\nimport type { GlassSwitchProps } from '../../../interfaces/forms/GlassSwitch.interface'\nimport { useFieldState } from '../../../composables/useField'\nimport { useResolvedRadius, useResolvedSize } from '../../../composables/useModoConfig'\nimport Typography from '../../data-display/Typography.vue'\nimport './glass-switch.css'\n\ndefineOptions({ name: 'GlassSwitch', inheritAttrs: false })\nconst props = withDefaults(defineProps<GlassSwitchProps>(), {\n modelValue: undefined,\n defaultChecked: false,\n color: 'default',\n labelPosition: 'right',\n disabled: false,\n readonly: false,\n required: false,\n loading: false,\n fullWidth: false,\n value: 'on',\n})\nconst emit = defineEmits<{ 'update:modelValue': [value: boolean]; change: [value: boolean] }>()\nconst attrs = useAttrs()\n// class/style lay out the field; every other attribute lands on the real input.\nconst inputAttrs = computed(() => { const { class: _c, style: _s, ...rest } = attrs; return rest })\n\nconst { fieldId, stateColor, hasError, isDisabled, errorId, helperId, describedBy } = useFieldState(props, {\n componentName: 'GlassSwitch',\n idPrefix: 'modo-glass-switch',\n})\n\nconst size = useResolvedSize(() => props.size)\n// Track radius (default pill), same steps as the native Switch track. The thumb stays round.\nconst resolvedRadius = useResolvedRadius(() => props.radius ?? 'full')\nconst trackRadiusClass = computed(() => {\n switch (resolvedRadius.value) {\n case 'none': return 'rounded-none'\n case 'small': return 'rounded-sm'\n case 'medium': return 'rounded-md'\n case 'large': return 'rounded-lg'\n case 'full':\n default: return 'rounded-full'\n }\n})\nconst CHECKED_BG_BY_COLOR: Record<string, string> = {\n default: 'bg-primary',\n primary: 'bg-primary',\n danger: 'bg-destructive',\n success: 'bg-success',\n warning: 'bg-warning',\n}\nconst fillClass = computed(() => CHECKED_BG_BY_COLOR[stateColor.value] ?? 'bg-primary')\n\n\nconst internal = ref(props.defaultChecked)\nconst checked = computed(() => props.modelValue ?? internal.value)\nconst descriptionId = computed(() => `${fieldId.value}-description`)\nconst ariaDescribedBy = computed(() => {\n const ids = [props.description ? descriptionId.value : '', describedBy.value, attrs['aria-describedby'] as string | undefined]\n return ids.filter(Boolean).join(' ') || undefined\n})\nconst isLocked = computed(() => isDisabled.value || props.readonly)\n\nconst input = ref<HTMLInputElement | null>(null)\nconst track = ref<HTMLElement | null>(null)\nlet stopDrag: (() => void) | undefined\nlet suppressUntil = 0\nlet resetForm: HTMLFormElement | null = null\n\nfunction change(event: Event) {\n const target = event.target as HTMLInputElement\n if (props.readonly) { target.checked = checked.value; return }\n internal.value = target.checked\n emit('update:modelValue', target.checked)\n emit('change', target.checked)\n // Controlled consumers remain the source of truth.\n if (props.modelValue !== undefined) target.checked = checked.value\n}\nfunction reset() { internal.value = props.defaultChecked; emit('update:modelValue', props.defaultChecked) }\nonMounted(() => { resetForm = input.value?.form ?? null; resetForm?.addEventListener('reset', reset) })\nfunction click(event: MouseEvent) {\n if (Date.now() < suppressUntil) { event.preventDefault(); event.stopPropagation(); suppressUntil = 0 }\n}\nfunction start(event: PointerEvent) {\n const el = input.value, rail = track.value\n if (!el || !rail || isLocked.value || event.button > 0) return\n stopDrag?.()\n suppressUntil = 0\n const thumb = rail.querySelector<HTMLElement>('.modo-glass-switch__thumb')!\n const fill = rail.querySelector<HTMLElement>('.modo-glass-switch__fill')!\n const travel = Math.max(1, rail.clientWidth - thumb.offsetWidth - thumb.offsetLeft * 2)\n const from = checked.value ? 1 : 0\n const startX = event.clientX\n let progress = from, moved = false\n const move = (e: PointerEvent) => {\n if (e.pointerId !== event.pointerId) return\n const dx = e.clientX - startX\n if (Math.abs(dx) > 4) moved = true\n if (!moved) return\n progress = Math.min(1, Math.max(0, from + dx / travel))\n rail.setAttribute('data-modo-dragging', '')\n thumb.style.transform = `translateX(${progress * travel}px)`\n fill.style.opacity = String(progress)\n }\n const clean = () => {\n document.removeEventListener('pointermove', move)\n document.removeEventListener('pointerup', end)\n document.removeEventListener('pointercancel', end)\n rail.removeAttribute('data-modo-dragging')\n thumb.style.transform = ''; fill.style.opacity = ''\n stopDrag = undefined\n }\n const end = (e: PointerEvent) => {\n if (e.pointerId !== event.pointerId) return\n clean()\n if (!moved) return\n if (e.type !== 'pointercancel' && !isLocked.value && (progress > .5) !== checked.value) el.click()\n suppressUntil = Date.now() + 350\n }\n document.addEventListener('pointermove', move, { passive: true })\n document.addEventListener('pointerup', end)\n document.addEventListener('pointercancel', end)\n stopDrag = clean\n}\nonBeforeUnmount(() => { stopDrag?.(); resetForm?.removeEventListener('reset', reset) })\ndefineExpose({ focus: () => input.value?.focus() })\n</script>\n\n<template>\n <div :class=\"['flex flex-col gap-1', fullWidth ? 'w-full' : 'inline-flex', attrs.class]\" :style=\"attrs.style as any\">\n <label\n :for=\"fieldId\"\n :data-modo-size=\"size\"\n :data-modo-label-first=\"labelPosition === 'left' ? '' : undefined\"\n :class=\"[\n 'modo-glass-switch group inline-flex items-start select-none',\n labelPosition === 'left' ? 'flex-row-reverse justify-between' : '',\n isDisabled ? 'opacity-60 cursor-not-allowed' : readonly ? 'cursor-default' : 'cursor-pointer',\n ]\"\n @click.capture=\"click\"\n >\n <input\n v-bind=\"inputAttrs\"\n :id=\"fieldId\"\n ref=\"input\"\n class=\"modo-glass-switch__input peer sr-only\"\n type=\"checkbox\"\n role=\"switch\"\n :checked=\"checked\"\n :disabled=\"isDisabled\"\n :readonly=\"readonly\"\n :required=\"required\"\n :name=\"name\"\n :value=\"value\"\n :aria-label=\"!label ? ariaLabel : undefined\"\n :aria-invalid=\"hasError || undefined\"\n :aria-readonly=\"readonly || undefined\"\n :aria-describedby=\"ariaDescribedBy\"\n @change=\"change\"\n />\n <span\n ref=\"track\"\n aria-hidden=\"true\"\n :class=\"[\n 'modo-glass-switch__track',\n 'peer-focus-visible:ring-2 peer-focus-visible:ring-ring/60',\n trackRadiusClass,\n\n ]\"\n @pointerdown=\"start\"\n >\n <span :class=\"['modo-glass-switch__fill', fillClass]\" /><span class=\"modo-glass-switch__thumb\" />\n </span>\n <span v-if=\"label || description\" class=\"modo-glass-switch__text\">\n <span v-if=\"label\" class=\"modo-glass-switch__label\">\n {{ label }}\n <span v-if=\"required\" aria-hidden=\"true\" class=\"text-destructive ml-0.5\">*</span>\n </span>\n <span v-if=\"description\" :id=\"descriptionId\" class=\"modo-glass-switch__description\">{{ description }}</span>\n </span>\n </label>\n\n <Typography v-if=\"hasError && errorText\" :id=\"errorId\" variant=\"caption\" size=\"medium\" color=\"danger\" as=\"p\" role=\"alert\">\n {{ errorText }}\n </Typography>\n <Typography v-else-if=\"helperText\" :id=\"helperId\" variant=\"caption\" size=\"medium\" color=\"muted\" as=\"p\">\n {{ helperText }}\n </Typography>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASA,MAAM,QAAQ;EAYd,MAAM,OAAO;EACb,MAAM,SAAA,GAAA,IAAA,WAAiB;EAEvB,MAAM,cAAA,GAAA,IAAA,gBAA4B;GAAE,MAAM,EAAE,OAAO,IAAI,OAAO,IAAI,GAAG,SAAS;GAAO,OAAO;IAAM;EAElG,MAAM,EAAE,SAAS,YAAY,UAAU,YAAY,SAAS,UAAU,gBAAgB,iBAAA,cAAc,OAAO;GACzG,eAAe;GACf,UAAU;GACX,CAAA;EAED,MAAM,OAAO,sBAAA,sBAAsB,MAAM,KAAI;EAE7C,MAAM,iBAAiB,sBAAA,wBAAwB,MAAM,UAAU,OAAM;EACrE,MAAM,oBAAA,GAAA,IAAA,gBAAkC;GACtC,QAAQ,eAAe,OAAvB;IACE,KAAK,QAAQ,OAAO;IACpB,KAAK,SAAS,OAAO;IACrB,KAAK,UAAU,OAAO;IACtB,KAAK,SAAS,OAAO;IAErB,SAAS,OAAO;;IAEnB;EACD,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,IAAA,OAAI,SAAQ;IAAE,SAAQ;IAAU,MAAK;IAAS,OAAM;IAAQ,IAAG;;oCACjF,EAAA,GAAA,IAAA,kBAAA,GAAA,IAAA,iBAAb,QAAA,WAAU,EAAA,EAAA,CAAA,CAAA"}
@@ -4,7 +4,11 @@ import Typography_default from "../../data-display/Typography.mjs";
4
4
  /* empty css */
5
5
  import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, mergeProps, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, toDisplayString, unref, useAttrs, withCtx } from "vue";
6
6
  //#region src/components/forms/glass-switch/GlassSwitch.vue?vue&type=script&setup=true&lang.ts
7
- var _hoisted_1 = ["for", "data-modo-size"];
7
+ var _hoisted_1 = [
8
+ "for",
9
+ "data-modo-size",
10
+ "data-modo-label-first"
11
+ ];
8
12
  var _hoisted_2 = [
9
13
  "id",
10
14
  "checked",
@@ -20,14 +24,18 @@ var _hoisted_2 = [
20
24
  ];
21
25
  var _hoisted_3 = {
22
26
  key: 0,
23
- class: "flex flex-col gap-0.5"
27
+ class: "modo-glass-switch__text"
24
28
  };
25
29
  var _hoisted_4 = {
30
+ key: 0,
31
+ class: "modo-glass-switch__label"
32
+ };
33
+ var _hoisted_5 = {
26
34
  key: 0,
27
35
  "aria-hidden": "true",
28
36
  class: "text-destructive ml-0.5"
29
37
  };
30
- var _hoisted_5 = ["id"];
38
+ var _hoisted_6 = ["id"];
31
39
  var GlassSwitch_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
32
40
  name: "GlassSwitch",
33
41
  inheritAttrs: false,
@@ -99,23 +107,14 @@ var GlassSwitch_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
99
107
  default: return "rounded-full";
100
108
  }
101
109
  });
102
- const labelSizeClass = computed(() => {
103
- switch (size.value) {
104
- case "xsmall":
105
- case "small": return "text-caption";
106
- case "large": return "text-body-lg";
107
- default: return "text-body";
108
- }
109
- });
110
110
  const CHECKED_BG_BY_COLOR = {
111
- default: "bg-foreground",
111
+ default: "bg-primary",
112
112
  primary: "bg-primary",
113
113
  danger: "bg-destructive",
114
114
  success: "bg-success",
115
115
  warning: "bg-warning"
116
116
  };
117
- const fillClass = computed(() => CHECKED_BG_BY_COLOR[stateColor.value] ?? "bg-foreground");
118
- const trackStateClass = computed(() => hasError.value ? "bg-destructive/20" : "bg-input group-hover:bg-muted");
117
+ const fillClass = computed(() => CHECKED_BG_BY_COLOR[stateColor.value] ?? "bg-primary");
119
118
  const internal = ref(props.defaultChecked);
120
119
  const checked = computed(() => props.modelValue ?? internal.value);
121
120
  const descriptionId = computed(() => `${fieldId.value}-description`);
@@ -216,9 +215,10 @@ var GlassSwitch_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
216
215
  }, [createElementVNode("label", {
217
216
  for: unref(fieldId),
218
217
  "data-modo-size": unref(size),
218
+ "data-modo-label-first": __props.labelPosition === "left" ? "" : void 0,
219
219
  class: normalizeClass([
220
- "modo-glass-switch group inline-flex items-start gap-2.5 select-none",
221
- __props.labelPosition === "left" ? "flex-row-reverse justify-end" : "",
220
+ "modo-glass-switch group inline-flex items-start select-none",
221
+ __props.labelPosition === "left" ? "flex-row-reverse justify-between" : "",
222
222
  unref(isDisabled) ? "opacity-60 cursor-not-allowed" : __props.readonly ? "cursor-default" : "cursor-pointer"
223
223
  ]),
224
224
  onClickCapture: click
@@ -247,21 +247,17 @@ var GlassSwitch_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
247
247
  ref: track,
248
248
  "aria-hidden": "true",
249
249
  class: normalizeClass([
250
- "modo-glass-switch__track mt-0.5 ring-4 ring-border/25",
250
+ "modo-glass-switch__track",
251
251
  "peer-focus-visible:ring-2 peer-focus-visible:ring-ring/60",
252
- trackRadiusClass.value,
253
- trackStateClass.value
252
+ trackRadiusClass.value
254
253
  ]),
255
254
  onPointerdown: start
256
255
  }, [createElementVNode("span", { class: normalizeClass(["modo-glass-switch__fill", fillClass.value]) }, null, 2), _cache[0] || (_cache[0] = createElementVNode("span", { class: "modo-glass-switch__thumb" }, null, -1))], 34),
257
- __props.label || __props.description ? (openBlock(), createElementBlock("span", _hoisted_3, [__props.label ? (openBlock(), createElementBlock("span", {
258
- key: 0,
259
- class: normalizeClass(["font-medium text-foreground", labelSizeClass.value])
260
- }, [createTextVNode(toDisplayString(__props.label) + " ", 1), __props.required ? (openBlock(), createElementBlock("span", _hoisted_4, "*")) : createCommentVNode("", true)], 2)) : createCommentVNode("", true), __props.description ? (openBlock(), createElementBlock("span", {
256
+ __props.label || __props.description ? (openBlock(), createElementBlock("span", _hoisted_3, [__props.label ? (openBlock(), createElementBlock("span", _hoisted_4, [createTextVNode(toDisplayString(__props.label) + " ", 1), __props.required ? (openBlock(), createElementBlock("span", _hoisted_5, "*")) : createCommentVNode("", true)])) : createCommentVNode("", true), __props.description ? (openBlock(), createElementBlock("span", {
261
257
  key: 1,
262
258
  id: descriptionId.value,
263
- class: "text-caption text-muted-foreground"
264
- }, toDisplayString(__props.description), 9, _hoisted_5)) : createCommentVNode("", true)])) : createCommentVNode("", true)
259
+ class: "modo-glass-switch__description"
260
+ }, toDisplayString(__props.description), 9, _hoisted_6)) : createCommentVNode("", true)])) : createCommentVNode("", true)
265
261
  ], 42, _hoisted_1), unref(hasError) && __props.errorText ? (openBlock(), createBlock(Typography_default, {
266
262
  key: 0,
267
263
  id: unref(errorId),