@ansh-ui/vue 0.2.0 → 0.3.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 (84) hide show
  1. package/dist/{chunk-B6OXKW5Q.js → chunk-AL4PPK25.js} +5 -2
  2. package/dist/chunk-AL4PPK25.js.map +1 -0
  3. package/dist/{chunk-2VSROZ2N.js → chunk-D3HH726R.js} +152 -144
  4. package/dist/chunk-D3HH726R.js.map +1 -0
  5. package/dist/{chunk-5BQEZYG6.cjs → chunk-EDAF7RAN.cjs} +163 -155
  6. package/dist/chunk-EDAF7RAN.cjs.map +1 -0
  7. package/dist/{chunk-TMG3M6TK.js → chunk-G2OX2NH2.js} +3 -3
  8. package/dist/chunk-G2OX2NH2.js.map +1 -0
  9. package/dist/{chunk-SOYRICHU.js → chunk-G3EIU6VM.js} +14 -8
  10. package/dist/chunk-G3EIU6VM.js.map +1 -0
  11. package/dist/{chunk-KCA7RNJ4.cjs → chunk-IHH6KMBY.cjs} +239 -5
  12. package/dist/chunk-IHH6KMBY.cjs.map +1 -0
  13. package/dist/{chunk-J2LA4GRP.cjs → chunk-IO6WJEJI.cjs} +122 -120
  14. package/dist/chunk-IO6WJEJI.cjs.map +1 -0
  15. package/dist/{chunk-IOXGBPOV.cjs → chunk-JJBYF7AH.cjs} +14 -8
  16. package/dist/chunk-JJBYF7AH.cjs.map +1 -0
  17. package/dist/{chunk-Z7XOFKM4.cjs → chunk-KKCZ5RUE.cjs} +4 -2
  18. package/dist/chunk-KKCZ5RUE.cjs.map +1 -0
  19. package/dist/{chunk-6ABPGOJP.js → chunk-LFGAOD32.js} +4 -2
  20. package/dist/chunk-LFGAOD32.js.map +1 -0
  21. package/dist/{chunk-EISHOEB6.cjs → chunk-MWGVDY6K.cjs} +3 -3
  22. package/dist/chunk-MWGVDY6K.cjs.map +1 -0
  23. package/dist/{chunk-FVKLCGA4.js → chunk-NJMTWLT2.js} +123 -121
  24. package/dist/chunk-NJMTWLT2.js.map +1 -0
  25. package/dist/{chunk-T425FIC7.js → chunk-NKRPZTQA.js} +238 -5
  26. package/dist/chunk-NKRPZTQA.js.map +1 -0
  27. package/dist/{chunk-JQ4YLXXM.cjs → chunk-PNR4RQ4T.cjs} +5 -2
  28. package/dist/chunk-PNR4RQ4T.cjs.map +1 -0
  29. package/dist/data.cjs +16 -16
  30. package/dist/data.d.cts +54 -52
  31. package/dist/data.d.ts +54 -52
  32. package/dist/data.js +1 -1
  33. package/dist/form.cjs +36 -36
  34. package/dist/form.d.cts +53 -45
  35. package/dist/form.d.ts +53 -45
  36. package/dist/form.js +1 -1
  37. package/dist/index.cjs +208 -180
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.d.cts +33 -8
  40. package/dist/index.d.ts +33 -8
  41. package/dist/index.js +31 -15
  42. package/dist/index.js.map +1 -1
  43. package/dist/layout.cjs +13 -13
  44. package/dist/layout.d.cts +23 -14
  45. package/dist/layout.d.ts +23 -14
  46. package/dist/layout.js +1 -1
  47. package/dist/motion.cjs +11 -11
  48. package/dist/motion.d.cts +41 -37
  49. package/dist/motion.d.ts +41 -37
  50. package/dist/motion.js +1 -1
  51. package/dist/navigation.cjs +13 -9
  52. package/dist/navigation.d.cts +125 -4
  53. package/dist/navigation.d.ts +125 -4
  54. package/dist/navigation.js +2 -2
  55. package/dist/overlay.cjs +14 -14
  56. package/dist/overlay.d.cts +36 -33
  57. package/dist/overlay.d.ts +36 -33
  58. package/dist/overlay.js +2 -2
  59. package/dist/{position-Cn7qP1pn.d.cts → position-CiY171HP.d.cts} +2 -1
  60. package/dist/{position-Cn7qP1pn.d.ts → position-CiY171HP.d.ts} +2 -1
  61. package/dist/primitives.cjs +6 -6
  62. package/dist/primitives.d.cts +6 -5
  63. package/dist/primitives.d.ts +6 -5
  64. package/dist/primitives.js +1 -1
  65. package/dist/{sidebar-CTZ-Ckko.d.ts → sidebar-B9zDHMbn.d.cts} +5 -4
  66. package/dist/{sidebar-CQqEmpid.d.cts → sidebar-DMrKHqZ5.d.ts} +5 -4
  67. package/dist/styles.css +464 -0
  68. package/dist/{utils-IKPG3zcC.d.cts → utils-D4XwXDeX.d.cts} +2 -1
  69. package/dist/{utils-IKPG3zcC.d.ts → utils-D4XwXDeX.d.ts} +2 -1
  70. package/package.json +3 -3
  71. package/dist/chunk-2VSROZ2N.js.map +0 -1
  72. package/dist/chunk-5BQEZYG6.cjs.map +0 -1
  73. package/dist/chunk-6ABPGOJP.js.map +0 -1
  74. package/dist/chunk-B6OXKW5Q.js.map +0 -1
  75. package/dist/chunk-EISHOEB6.cjs.map +0 -1
  76. package/dist/chunk-FVKLCGA4.js.map +0 -1
  77. package/dist/chunk-IOXGBPOV.cjs.map +0 -1
  78. package/dist/chunk-J2LA4GRP.cjs.map +0 -1
  79. package/dist/chunk-JQ4YLXXM.cjs.map +0 -1
  80. package/dist/chunk-KCA7RNJ4.cjs.map +0 -1
  81. package/dist/chunk-SOYRICHU.js.map +0 -1
  82. package/dist/chunk-T425FIC7.js.map +0 -1
  83. package/dist/chunk-TMG3M6TK.js.map +0 -1
  84. package/dist/chunk-Z7XOFKM4.cjs.map +0 -1
@@ -419,6 +419,8 @@ function normalizeChildren(nodes) {
419
419
  return true;
420
420
  });
421
421
  }
422
+
423
+ // src/components/motion/motion.ts
422
424
  var Motion = vue.defineComponent({
423
425
  name: "AnshMotion",
424
426
  inheritAttrs: false,
@@ -729,5 +731,5 @@ exports.ThemeProvider = ThemeProvider;
729
731
  exports.themeScript = themeScript;
730
732
  exports.useMotionConfig = useMotionConfig;
731
733
  exports.useTheme = useTheme;
732
- //# sourceMappingURL=chunk-Z7XOFKM4.cjs.map
733
- //# sourceMappingURL=chunk-Z7XOFKM4.cjs.map
734
+ //# sourceMappingURL=chunk-KKCZ5RUE.cjs.map
735
+ //# sourceMappingURL=chunk-KKCZ5RUE.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/text.ts","../src/components/providers.ts","../src/components/motion/shared.ts","../src/components/motion/motion.ts","../src/components/motion/animate-presence.ts","../src/components/motion/draggable.ts"],"names":["defineComponent","computed","resolvePalette","createGradient","prefersReducedMotion","h","ref","onMounted","resolveEasing","stagger","getTicker","observeIntersection","onBeforeUnmount","watch","setReducedMotionMode","attachLifecycle","provide","inject","applyTheme","resolveTheme","Comment","Text","useAnimate","springs","useInView","onScopeDispose","cloneVNode","cx"],"mappings":";;;;;;;;AAmCA,IAAM,eAAA,GAAiC;AAAA,EACrC,QAAA,EAAU,UAAA;AAAA,EACV,KAAA,EAAO,KAAA;AAAA,EACP,MAAA,EAAQ,KAAA;AAAA,EACR,OAAA,EAAS,GAAA;AAAA,EACT,MAAA,EAAQ,MAAA;AAAA,EACR,QAAA,EAAU,QAAA;AAAA,EACV,QAAA,EAAU,YAAA;AAAA,EACV,UAAA,EAAY,QAAA;AAAA,EACZ,WAAA,EAAa;AACf,CAAA;AAkBO,IAAM,eAAeA,mBAAA,CAAgB;AAAA,EAC1C,IAAA,EAAM,kBAAA;AAAA,EACN,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,EAAA,EAAG;AAAA,IAClC,MAAA,EAAQ;AAAA,MACN,IAAA,EAAM,CAAC,KAAA,EAAO,MAAM,CAAA;AAAA,MACpB,OAAA,EAAS;AAAA,KACX;AAAA;AAAA,IAEA,KAAA,EAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,GAAA,EAAI;AAAA;AAAA,IAEpC,QAAA,EAAU,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,CAAA,EAAE;AAAA;AAAA,IAErC,KAAA,EAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,EAAA,EAAG;AAAA,IACnC,EAAA,EAAI,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,MAAA;AAAO,GACtC;AAAA,EAEA,KAAA,CAAM,KAAA,EAAO,EAAE,KAAA,EAAM,EAAG;AACtB,IAAA,MAAM,QAAA,GAAW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,oBAAA;AAAA,YACL,gBAAA;AAAA,YACA,SAAS,KAAA,IAAS,wBAAA;AAAA,YAClB;AAAA,WACF;AAAA,UACA,KAAA,EAAO;AAAA,YACL;AAAA,cACE,WAAA,EAAa,MAAM,IAAA,KAAS,GAAA,GAAM,UAAU,KAAA,CAAM,IAAA,KAAS,MAAM,OAAA,GAAU;AAAA,aAC7E;AAAA,YACA;AAAA,WACF;AAAA,UACA,aAAA;AAAA,UACA,GAAG;AAAA,SACL;AAAA,QACA,MAAM,OAAA;AAAU,OAClB;AAAA,IACF,CAAA;AAAA,EACF;AACF,CAAC","file":"chunk-KKCZ5RUE.cjs","sourcesContent":["import {\n type CSSProperties,\n type PropType,\n computed,\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n ref,\n} from 'vue'\nimport {\n type ColorInput,\n type EasingInput,\n type StaggerFrom,\n createGradient,\n getTicker,\n observeIntersection,\n prefersReducedMotion,\n resolveEasing,\n resolvePalette,\n stagger,\n} from '@ansh-ui/core'\n\n/**\n * Text components.\n *\n * Hand-written rather than factory-generated, because text animation has a requirement no generic\n * factory can meet: **the accessible text must never be the animated text.** Splitting a heading\n * into per-character spans is fine visually and an accessibility failure if that structure is what\n * a screen reader reads — some engines announce \"W. E. L. C. O. M. E.\" and you cannot rely on which.\n *\n * The pattern used here: the real string lives in a visually-hidden element that remains the\n * accessible representation, and the whole animated structure is `aria-hidden`.\n */\n\nconst VISUALLY_HIDDEN: CSSProperties = {\n position: 'absolute',\n width: '1px',\n height: '1px',\n padding: '0',\n margin: '-1px',\n overflow: 'hidden',\n clipPath: 'inset(50%)',\n whiteSpace: 'nowrap',\n borderWidth: '0',\n}\n\n// ---------------------------------------------------------------------------\n// GradientText\n// ---------------------------------------------------------------------------\n\n/**\n * Text filled with a perceptual gradient.\n *\n * The stops are generated through the OKLab interpolator rather than handed to CSS as two\n * endpoints. That is the entire point: a CSS `linear-gradient(#0275f4, #9f0550)` passes through a\n * desaturated grey-brown at its midpoint, and on text — where the gradient crosses a narrow band —\n * the midpoint is exactly where the eye lands.\n *\n * The optional animation is a CSS `background-position` shift rather than a JS loop, because for a\n * single non-interactive property the browser's compositor beats anything we could do on the main\n * thread.\n */\nexport const GradientText = defineComponent({\n name: 'AnshGradientText',\n props: {\n text: { type: String, default: '' },\n colors: {\n type: [Array, String] as PropType<readonly ColorInput[] | string>,\n default: undefined,\n },\n /** Gradient angle in degrees. */\n angle: { type: Number, default: 100 },\n /** Seconds per cycle. `0` holds a static gradient. */\n duration: { type: Number, default: 0 },\n /** Interpolated stops handed to CSS. More is smoother. */\n stops: { type: Number, default: 16 },\n as: { type: String, default: 'span' },\n },\n\n setup(props, { slots }) {\n const gradient = computed(() => {\n const palette = resolvePalette(props.colors as never)\n // Duplicated so an animated background-position shift wraps seamlessly rather than jumping.\n const looped = props.duration > 0 ? [...palette, ...palette] : palette\n return createGradient(looped, { space: 'oklab' }).toCss(`${props.angle}deg`, props.stops)\n })\n\n const animated = computed(() => props.duration > 0 && !prefersReducedMotion())\n\n return () =>\n h(\n props.as,\n {\n style: {\n backgroundImage: gradient.value,\n backgroundSize: animated.value ? '200% 100%' : '100% 100%',\n backgroundClip: 'text',\n WebkitBackgroundClip: 'text',\n color: 'transparent',\n WebkitTextFillColor: 'transparent',\n display: 'inline-block',\n ...(animated.value\n ? { animation: `ansh-gradient-shift ${props.duration}s linear infinite` }\n : {}),\n } as CSSProperties,\n },\n [\n slots.default?.() ?? props.text,\n // The keyframes are injected inline so `<GradientText :duration=\"6\" />` works with no\n // stylesheet import. Identical rules from multiple instances are deduplicated by the\n // browser, so this costs nothing at scale.\n animated.value\n ? h('style', {\n innerHTML:\n '@keyframes ansh-gradient-shift{from{background-position:0% 50%}' +\n 'to{background-position:200% 50%}}',\n })\n : null,\n ],\n )\n },\n})\n\n// ---------------------------------------------------------------------------\n// AnimatedText\n// ---------------------------------------------------------------------------\n\ninterface Unit {\n text: string\n /** Whitespace is rendered as a plain gap rather than an animated unit. */\n space: boolean\n}\n\n/**\n * Text that reveals unit by unit.\n *\n * The split happens during render, so the markup is server-rendered and the real text is present in\n * the HTML source for SEO and for readers without JavaScript. The animation runs on the shared\n * ticker, so a page full of these shares one clock and cannot drift apart.\n *\n * Under `prefers-reduced-motion` the text renders in its final state and never animates.\n */\nexport const AnimatedText = defineComponent({\n name: 'AnshAnimatedText',\n props: {\n text: { type: String, required: true },\n /** Split granularity. */\n by: { type: String as PropType<'chars' | 'words'>, default: 'chars' },\n /** Seconds per unit. */\n duration: { type: Number, default: 0.6 },\n /** Seconds between units. */\n each: { type: Number, default: 0.03 },\n /** Where the reveal wave begins. */\n from: { type: [String, Number] as PropType<StaggerFrom>, default: 'first' },\n easing: { type: [String, Function, Array] as PropType<EasingInput>, default: 'cinematic' },\n /** Distance each unit travels into place, in pixels. */\n distance: { type: Number, default: 18 },\n /** Starting blur in pixels — the \"focus in\" look. */\n blur: { type: Number, default: 0 },\n /** Starting rotation in degrees. */\n rotate: { type: Number, default: 0 },\n /** Clip each unit so it rises from behind a mask. */\n mask: { type: Boolean, default: false },\n /** Wait until scrolled into view. */\n whenInView: { type: Boolean, default: true },\n /** Replay every time it re-enters the viewport. */\n repeat: { type: Boolean, default: false },\n /** Seconds to wait before starting. */\n delay: { type: Number, default: 0 },\n as: { type: String, default: 'span' },\n },\n emits: ['complete'],\n\n setup(props, { emit }) {\n const host = ref<HTMLElement | null>(null)\n const unitNodes = ref<(HTMLElement | null)[]>([])\n\n const units = computed<Unit[]>(() => {\n if (props.by === 'words') {\n return props.text\n .split(/(\\s+)/)\n .filter((token) => token.length > 0)\n .map((token) => ({ text: token, space: /^\\s+$/.test(token) }))\n }\n\n // Grapheme-aware: `[...string]` splits by code point, which breaks emoji with modifiers and\n // combining accents into multiple \"characters\".\n const graphemes =\n typeof Intl !== 'undefined' && 'Segmenter' in Intl\n ? Array.from(\n new Intl.Segmenter(undefined, { granularity: 'grapheme' }).segment(props.text),\n (s) => s.segment,\n )\n : Array.from(props.text)\n\n return graphemes.map((character) => ({ text: character, space: /^\\s$/.test(character) }))\n })\n\n let stopTicker: (() => void) | null = null\n let stopObserver: (() => void) | null = null\n\n onMounted(() => {\n const element = host.value\n if (!element) return\n\n if (prefersReducedMotion()) {\n emit('complete')\n return\n }\n\n const ease = resolveEasing(props.easing)\n const animatedUnits = units.value.filter((u) => !u.space)\n const delayFor = stagger(animatedUnits.length, { each: props.each, from: props.from })\n\n const targets: { node: HTMLElement; delay: number }[] = []\n let animationIndex = 0\n units.value.forEach((unit, i) => {\n if (unit.space) return\n const node = unitNodes.value[i]\n if (node) targets.push({ node, delay: props.delay + delayFor(animationIndex) })\n animationIndex++\n })\n\n const apply = (node: HTMLElement, progress: number): void => {\n const eased = ease(progress)\n const inverse = 1 - eased\n node.style.opacity = String(eased)\n const parts = [`translate3d(0, ${(props.distance * inverse).toFixed(2)}px, 0)`]\n if (props.rotate !== 0) parts.push(`rotate(${(props.rotate * inverse).toFixed(2)}deg)`)\n node.style.transform = parts.join(' ')\n if (props.blur > 0) {\n const amount = props.blur * inverse\n node.style.filter = amount > 0.05 ? `blur(${amount.toFixed(2)}px)` : ''\n }\n }\n\n const settle = (node: HTMLElement): void => {\n node.style.opacity = ''\n node.style.transform = ''\n node.style.filter = ''\n // Drop the compositor promotion once at rest, so a page of these doesn't hold hundreds of\n // permanent layers.\n node.style.willChange = ''\n }\n\n const reset = (): void => {\n for (const { node } of targets) apply(node, 0)\n }\n\n let elapsed = 0\n let running = false\n\n const start = (): void => {\n if (running) return\n running = true\n elapsed = 0\n for (const { node } of targets) node.style.willChange = 'opacity, transform'\n reset()\n\n stopTicker = getTicker().add(\n ({ delta }) => {\n elapsed += delta\n let allDone = true\n\n for (const target of targets) {\n const local = elapsed - target.delay\n if (local < 0) {\n allDone = false\n continue\n }\n const progress = props.duration <= 0 ? 1 : local / props.duration\n if (progress >= 1) {\n settle(target.node)\n continue\n }\n apply(target.node, progress)\n allDone = false\n }\n\n if (allDone) {\n stopTicker?.()\n stopTicker = null\n running = false\n emit('complete')\n }\n },\n { phase: 'write', name: 'AnimatedText' },\n )\n }\n\n // Hide before the browser paints. `onMounted` in Vue runs after the DOM is inserted but\n // before paint, so unlike React's `useEffect` there is no flash to guard against here.\n reset()\n\n if (!props.whenInView) {\n start()\n return\n }\n\n stopObserver = observeIntersection(\n element,\n (entry) => {\n if (entry.isIntersecting) {\n start()\n } else if (props.repeat) {\n stopTicker?.()\n stopTicker = null\n running = false\n reset()\n }\n },\n { threshold: 0.2, rootMargin: '0px 0px -8% 0px' },\n )\n })\n\n onBeforeUnmount(() => {\n stopObserver?.()\n stopTicker?.()\n stopObserver = null\n stopTicker = null\n })\n\n return () =>\n h(props.as, { ref: host, style: { display: 'inline-block' } as CSSProperties }, [\n // The accessible representation: the real string, unfragmented.\n h('span', { style: VISUALLY_HIDDEN }, props.text),\n\n h(\n 'span',\n { 'aria-hidden': 'true' },\n units.value.map((unit, i) => {\n if (unit.space) return h('span', {}, unit.text)\n\n const inner = h(\n 'span',\n {\n ref: (node: unknown) => {\n unitNodes.value[i] = (node as HTMLElement | null) ?? null\n },\n style: { display: 'inline-block' } as CSSProperties,\n },\n unit.text,\n )\n\n return props.mask\n ? h(\n 'span',\n {\n style: {\n display: 'inline-block',\n overflow: 'hidden',\n // Without this, descenders (g, y, p) are clipped by the mask box.\n verticalAlign: 'top',\n } as CSSProperties,\n },\n [inner],\n )\n : inner\n }),\n ),\n ])\n },\n})\n","import {\n type ComputedRef,\n type InjectionKey,\n type PropType,\n computed,\n defineComponent,\n inject,\n onBeforeUnmount,\n provide,\n ref,\n watch,\n} from 'vue'\nimport {\n type ReducedMotionMode,\n attachLifecycle,\n getTicker,\n setReducedMotionMode,\n} from '@ansh-ui/core'\nimport { applyTheme, resolveTheme } from '@ansh-ui/tokens'\n\n/**\n * Application-level configuration providers — the Vue counterpart of `@ansh-ui/react`'s\n * `providers.tsx`. `provide`/`inject` replace React context; everything else about the two designs\n * is intentionally identical, because the underlying correctness constraints (no hydration\n * mismatch, no theme flash) don't change with the framework.\n */\n\n// ---------------------------------------------------------------------------\n// MotionConfig\n// ---------------------------------------------------------------------------\n\nexport interface MotionConfigValue {\n reducedMotion: ReducedMotionMode\n /** Global playback rate. `0.5` is slow motion across every animation on the page. */\n timeScale: number\n /** Pin adaptive quality, or `null` to let the frame budget decide. */\n quality: number | null\n}\n\nconst DEFAULT_MOTION_CONFIG: MotionConfigValue = {\n reducedMotion: 'auto',\n timeScale: 1,\n quality: null,\n}\n\nconst MotionConfigKey: InjectionKey<ComputedRef<MotionConfigValue>> = Symbol('ansh-motion-config')\n\n/**\n * Application-level motion configuration.\n *\n * Optional — every component works without it. Mount it once at the root when you need app-wide\n * control:\n *\n * ```vue\n * <MotionConfig :reduced-motion=\"userPrefersCalm ? 'always' : 'auto'\">\n * <App />\n * </MotionConfig>\n * ```\n *\n * `reducedMotion=\"always\"` is genuinely useful in production, as the backing for an in-app \"reduce\n * motion\" setting — many users who want calmer interfaces have never found the OS toggle.\n */\nexport const MotionConfig = defineComponent({\n name: 'AnshMotionConfig',\n props: {\n reducedMotion: { type: String as PropType<ReducedMotionMode>, default: 'auto' },\n timeScale: { type: Number, default: 1 },\n quality: { type: Number as PropType<number | null>, default: null },\n /**\n * Pause every animation while the document is hidden. Default `true`.\n *\n * Leave this on. Animating a background tab burns battery and spins fans for output nobody can\n * see, and it is the most common performance complaint about animation-heavy sites.\n */\n pauseWhenHidden: { type: Boolean, default: true },\n pauseWhenBlurred: { type: Boolean, default: false },\n respectBattery: { type: Boolean, default: true },\n },\n setup(props, { slots }) {\n watch(\n () => props.reducedMotion,\n (mode) => setReducedMotionMode(mode),\n { immediate: true },\n )\n watch(\n () => props.timeScale,\n (scale) => {\n getTicker().timeScale = scale\n },\n { immediate: true },\n )\n watch(\n () => props.quality,\n (quality) => {\n if (quality !== null) getTicker().lockQuality(quality)\n },\n { immediate: true },\n )\n\n let detach: (() => void) | null = null\n watch(\n () => [props.pauseWhenHidden, props.pauseWhenBlurred, props.respectBattery] as const,\n ([pauseWhenHidden, pauseWhenBlurred, respectBattery]) => {\n detach?.()\n detach = attachLifecycle(getTicker(), { pauseWhenHidden, pauseWhenBlurred, respectBattery })\n },\n { immediate: true },\n )\n onBeforeUnmount(() => detach?.())\n\n provide(\n MotionConfigKey,\n computed(() => ({\n reducedMotion: props.reducedMotion,\n timeScale: props.timeScale,\n quality: props.quality,\n })),\n )\n\n return () => slots.default?.()\n },\n})\n\n/** Read the nearest {@link MotionConfig}. Returns sensible defaults with no provider present. */\nexport function useMotionConfig(): ComputedRef<MotionConfigValue> {\n return inject(\n MotionConfigKey,\n computed(() => DEFAULT_MOTION_CONFIG),\n )\n}\n\n// ---------------------------------------------------------------------------\n// ThemeProvider\n// ---------------------------------------------------------------------------\n\nexport type ThemeSetting = 'light' | 'dark' | 'system'\n\nexport interface ThemeContextValue {\n /** What was requested, including `'system'`. */\n theme: ThemeSetting\n /** What is actually rendering. `'system'` is resolved to one or the other. */\n resolved: 'light' | 'dark'\n setTheme: (theme: ThemeSetting) => void\n}\n\nconst DEFAULT_THEME: ThemeContextValue = { theme: 'system', resolved: 'light', setTheme: () => {} }\n\nconst ThemeKey: InjectionKey<ComputedRef<ThemeContextValue>> = Symbol('ansh-theme')\n\n/**\n * Theme control over the `@ansh-ui/tokens` stylesheet.\n *\n * Sets `data-theme` on `<html>`, which the token stylesheet already understands. Two details that\n * are easy to get wrong and are handled here:\n *\n * **`'system'` removes the attribute rather than writing a resolved value.** The token stylesheet\n * guards its `prefers-color-scheme` rule with `:root:not([data-theme])`, so removing the attribute\n * hands control back to the OS — and, importantly, means the theme keeps following the OS if the\n * user changes it while the page is open.\n *\n * **The initial render always reports `'light'`.** Reading `localStorage` during setup would be a\n * hydration mismatch, since the server has no access to it. The stored value is applied `onMounted`.\n * To avoid a flash of the wrong theme, ship the small inline script from {@link themeScript} in your\n * document `<head>` — that is the only way to set the attribute before first paint. `@ansh-ui/nuxt`\n * does this automatically.\n */\nexport const ThemeProvider = defineComponent({\n name: 'AnshThemeProvider',\n props: {\n /** Initial setting. Default `'system'`. */\n defaultTheme: { type: String as PropType<ThemeSetting>, default: 'system' },\n /** Persist the choice under this `localStorage` key. Pass `null` to disable. */\n storageKey: { type: String as PropType<string | null>, default: 'ansh-theme' },\n },\n setup(props, { slots }) {\n const theme = ref<ThemeSetting>(props.defaultTheme)\n const resolved = ref<'light' | 'dark'>('light')\n\n const setTheme = (next: ThemeSetting): void => {\n theme.value = next\n }\n\n // Read the stored preference after mount, never during setup.\n let mediaQuery: MediaQueryList | null = null\n let onMediaChange: (() => void) | null = null\n\n const syncMedia = (): void => {\n mediaQuery?.removeEventListener('change', onMediaChange!)\n mediaQuery = null\n onMediaChange = null\n if (theme.value !== 'system' || typeof matchMedia !== 'function') return\n mediaQuery = matchMedia('(prefers-color-scheme: dark)')\n onMediaChange = () => {\n resolved.value = mediaQuery!.matches ? 'dark' : 'light'\n }\n mediaQuery.addEventListener('change', onMediaChange)\n }\n\n watch(\n theme,\n (next) => {\n applyTheme(next)\n resolved.value = resolveTheme()\n syncMedia()\n if (props.storageKey) {\n try {\n localStorage.setItem(props.storageKey, next)\n } catch {\n // Storage can throw in private browsing or with cookies disabled. A theme preference\n // is not worth breaking the page over.\n }\n }\n },\n { flush: 'post' },\n )\n\n // Runs once, after mount — the `watch` above has already applied `defaultTheme` by then, and\n // this only overrides it if something was actually stored.\n if (typeof document !== 'undefined') {\n queueMicrotask(() => {\n if (!props.storageKey) return\n try {\n const stored = localStorage.getItem(props.storageKey)\n if (stored === 'light' || stored === 'dark' || stored === 'system') theme.value = stored\n } catch {\n // As above.\n }\n })\n // Apply the default immediately too, so there is no gap before the microtask above runs.\n applyTheme(theme.value)\n resolved.value = resolveTheme()\n syncMedia()\n }\n\n onBeforeUnmount(() => mediaQuery?.removeEventListener('change', onMediaChange!))\n\n provide(\n ThemeKey,\n computed(() => ({ theme: theme.value, resolved: resolved.value, setTheme })),\n )\n\n return () => slots.default?.()\n },\n})\n\nexport function useTheme(): ComputedRef<ThemeContextValue> {\n return inject(\n ThemeKey,\n computed(() => DEFAULT_THEME),\n )\n}\n\n/**\n * The blocking script that prevents a theme flash.\n *\n * Inject this in `<head>`, before any stylesheet. It reads the stored preference and sets\n * `data-theme` synchronously, before the browser paints — the only point at which it can be done\n * without a visible flash. Deliberately tiny and dependency-free.\n *\n * `@ansh-ui/nuxt` injects this automatically; a bare Vue app should call it from `index.html`.\n */\nexport function themeScript(storageKey = 'ansh-theme'): string {\n return (\n `(function(){try{var t=localStorage.getItem(${JSON.stringify(storageKey)});` +\n `if(t==='light'||t==='dark'){document.documentElement.setAttribute('data-theme',t)}}` +\n `catch(e){}})()`\n )\n}\n","import { Comment, Text, type VNode } from 'vue'\nimport { type EasingInput, type SpringOptions, type springs } from '@ansh-ui/core'\n\nexport interface MotionValues {\n opacity?: number\n x?: number\n y?: number\n scale?: number\n scaleX?: number\n scaleY?: number\n rotate?: number\n /** Blur radius in px. */\n blur?: number\n}\n\nexport interface MotionTransition {\n /** Seconds. Ignored when `spring` is set. Default `0.4`. */\n duration?: number\n /** Seconds to wait. Default `0`. */\n delay?: number\n easing?: EasingInput\n /** Use a spring instead of a tween. `true` uses the `smooth` preset. */\n spring?: boolean | SpringOptions | keyof typeof springs\n}\n\nexport const DEFAULTS: Required<MotionValues> = {\n opacity: 1,\n x: 0,\n y: 0,\n scale: 1,\n scaleX: 1,\n scaleY: 1,\n rotate: 0,\n blur: 0,\n}\n\n/** Compose the values into a transform string plus the properties that aren't transforms. */\nexport function applyValues(node: HTMLElement, values: Required<MotionValues>): void {\n const transform =\n `translate3d(${values.x}px, ${values.y}px, 0)` +\n ` scale(${values.scale * values.scaleX}, ${values.scale * values.scaleY})` +\n ` rotate(${values.rotate}deg)`\n\n node.style.transform = transform\n node.style.opacity = String(values.opacity)\n // Only written when non-zero: an always-present `filter` creates a containing block and a new\n // stacking context, which changes how `position: fixed` descendants resolve.\n node.style.filter = values.blur > 0 ? `blur(${values.blur}px)` : ''\n}\n\nexport function resolve(\n values: MotionValues | undefined,\n base: Required<MotionValues>,\n): Required<MotionValues> {\n return { ...base, ...values }\n}\n\n/** Drop whitespace-only text nodes and `v-if=\"false\"` comment placeholders from a slot's output. */\nexport function normalizeChildren(nodes: VNode[] | undefined): VNode[] {\n return (nodes ?? []).filter((node) => {\n if (node.type === Comment) return false\n if (node.type === Text && typeof node.children === 'string' && node.children.trim() === '') {\n return false\n }\n return true\n })\n}\n","import { type PropType, computed, defineComponent, h, onMounted, ref, watch } from 'vue'\nimport { type AnimationOptions, springs } from '@ansh-ui/core'\nimport { useAnimate } from '../../composables/use-motion'\nimport { useInView } from '../../composables/use-observers'\nimport { DEFAULTS, type MotionTransition, type MotionValues, applyValues, resolve } from './shared'\n\n/**\n * Declarative motion — the Vue counterpart of `@ansh-ui/react`'s `Motion`/`AnimatePresence`/\n * `Draggable`.\n *\n * A deliberately **small** subset of what a full motion library does: transform properties and\n * opacity, animated from `initial` to `animate`, plus hover and press states and an exit animation\n * when paired with `AnimatePresence`.\n *\n * That scope is a decision, not a gap. Layout animation (FLIP), shared-element transitions and\n * variant propagation each need machinery an order of magnitude larger than this file, and a\n * half-implementation of them is worse than none — it works in the demo and fails on the real page.\n * For those, use a dedicated library; for the 90% case of \"fade this in, slide that up, spring the\n * card on hover\", this costs a fraction of the bundle.\n *\n * Values are written straight to the element's `style` from the ticker's write phase, outside Vue's\n * reactivity — the same principle `useMotionStyle` documents in `composables/use-motion.ts`. `Motion`\n * and `Draggable` are built on `useAnimate()` (scope-bound imperative animation, auto-stopping the\n * previous run) and `useInView()` (the `whileInView` trigger) rather than calling the ticker\n * primitives from scratch, so cleanup and scope-disposal are inherited for free.\n */\n\n// --- Motion -----------------------------------------------------------------\n\n/**\n * An animated element.\n *\n * ```vue\n * <Motion :initial=\"{ opacity: 0, y: 24 }\" :animate=\"{ opacity: 1, y: 0 }\" while-in-view>\n * <Card />\n * </Motion>\n * ```\n */\nexport const Motion = defineComponent({\n name: 'AnshMotion',\n inheritAttrs: false,\n props: {\n as: { type: String, default: 'div' },\n /** Starting values. Applied before the first paint. */\n initial: { type: Object as PropType<MotionValues>, default: undefined },\n /** Target values. Changing these animates to the new target. */\n animate: { type: Object as PropType<MotionValues>, default: undefined },\n // Declared so it lands here rather than in `attrs`: `AnimatePresence` reads it off the vnode's\n // props when the child is removed and swaps it into `animate`. Left undeclared, it would reach\n // the DOM as an unknown `exit` attribute.\n exit: { type: Object as PropType<MotionValues>, default: undefined },\n transition: { type: Object as PropType<MotionTransition>, default: undefined },\n whileHover: { type: Object as PropType<MotionValues>, default: undefined },\n whileTap: { type: Object as PropType<MotionValues>, default: undefined },\n /** Animate to `animate` only once scrolled into view. */\n whileInView: { type: Boolean, default: false },\n /** Fraction visible before `whileInView` triggers. Default `0.2`. */\n inViewAmount: { type: Number, default: 0.2 },\n },\n setup(props, { attrs, slots, expose }) {\n const node = ref<HTMLElement | null>(null)\n // Plain closure state, deliberately outside Vue's reactivity — a value driven by the ticker\n // changes up to 60 times a second, and a `ref` here would flush a reactive effect on every one.\n let current = resolve(props.initial, DEFAULTS)\n const start = useAnimate()\n\n expose({\n get element() {\n return node.value\n },\n })\n\n // Applied in `onMounted`, not a plain function call during setup: the DOM node the template\n // `ref` points at only exists once Vue has patched it in, which — for the initial render — is\n // still before the browser's next paint. That ordering is what avoids the element flashing at\n // full opacity for one frame before the \"hidden\" `initial` state ever gets applied.\n //\n // The first run of the `animate` target is kicked off here too, rather than from the `watch`\n // below with `immediate: true`. Vue runs an immediate watcher's callback *synchronously during\n // `setup()`*, regardless of `flush` — `flush: 'post'` only defers a watcher's *subsequent*\n // re-runs, not its immediate one. `node.value` is still null at that point (the element hasn't\n // mounted yet), so `runTo` would silently no-op and the component would never animate to its\n // initial `animate` target. `onMounted` is the actual first point at which `node.value` exists.\n onMounted(() => {\n if (!node.value) return\n applyValues(node.value, current)\n if (inView.value) runTo(resolve(props.animate, DEFAULTS))\n })\n\n const runTo = (next: Required<MotionValues>, options?: MotionTransition): void => {\n const element = node.value\n if (!element) return\n\n const from = { ...current }\n const springOption = options?.spring ?? props.transition?.spring\n\n const animationOptions: AnimationOptions<number> = {\n ...((options?.delay ?? props.transition?.delay) !== undefined\n ? { delay: options?.delay ?? props.transition?.delay ?? 0 }\n : null),\n ...(springOption\n ? {\n spring:\n springOption === true\n ? springs.default\n : typeof springOption === 'string'\n ? springs[springOption]\n : springOption,\n }\n : {\n duration: options?.duration ?? props.transition?.duration ?? 0.4,\n ...((options?.easing ?? props.transition?.easing)\n ? { easing: (options?.easing ?? props.transition?.easing)! }\n : null),\n }),\n onUpdate: (t: number) => {\n // One scalar drives every property, so all of them stay in lockstep. Animating each\n // independently would need one ticker subscription per property and they would drift\n // apart under a spring, which is not time-based.\n const frame = {} as Required<MotionValues>\n for (const key of Object.keys(DEFAULTS) as Array<keyof MotionValues>) {\n frame[key] = from[key] + (next[key] - from[key]) * t\n }\n current = frame\n applyValues(element, frame)\n },\n onComplete: () => {\n current = next\n applyValues(element, next)\n },\n }\n\n // `useAnimate()` stops any in-flight run of its own before starting the next, and again on\n // scope disposal — the two cleanup spots the React version's `controlsRef` handles by hand.\n start(0, 1, animationOptions)\n }\n\n // `whileInView` gating, via the same observer composable `useElementSize`/`useScrollProgress`\n // are built on. Always attached (harmless when `whileInView` is false — the observer simply\n // goes unused) rather than conditionally, since `inViewAmount` and `whileInView` are expected\n // to be set once and not toggled.\n const inViewState = useInView(node, { threshold: props.inViewAmount, once: true })\n const inView = computed(() => !props.whileInView || inViewState.value)\n\n // Animate to the target whenever it changes after mount (or when it scrolls into view). The\n // *first* run is handled explicitly in `onMounted` above, not here — see the comment there.\n // No `immediate: true`: this only needs to react to changes from here on.\n watch(\n [() => JSON.stringify(props.animate ?? null), inView],\n ([, isInView]) => {\n if (!isInView) return\n runTo(resolve(props.animate, DEFAULTS))\n },\n { flush: 'post' },\n )\n\n return () => {\n const { class: attrClass, style: attrStyle, ...restAttrs } = attrs as Record<string, unknown>\n\n const interaction: Record<string, unknown> = {}\n if (props.whileHover) {\n interaction.onMouseenter = () =>\n runTo(resolve({ ...props.animate, ...props.whileHover }, DEFAULTS))\n interaction.onMouseleave = () => runTo(resolve(props.animate, DEFAULTS))\n }\n if (props.whileTap) {\n interaction.onPointerdown = () =>\n runTo(resolve({ ...props.animate, ...props.whileTap }, DEFAULTS), { duration: 0.12 })\n interaction.onPointerup = () =>\n runTo(resolve({ ...props.animate, ...props.whileHover }, DEFAULTS))\n }\n\n return h(\n props.as,\n {\n ref: node,\n class: attrClass,\n // `will-change` is set once, statically. Toggling it per animation causes the compositor\n // to create and destroy a layer on every interaction, which is more expensive than the\n // hint saves.\n style: [{ willChange: 'transform, opacity' }, attrStyle],\n ...interaction,\n ...restAttrs,\n },\n slots.default?.(),\n )\n }\n },\n})\n","import { type VNode, cloneVNode, computed, defineComponent, onScopeDispose, ref, watch } from 'vue'\nimport { prefersReducedMotion } from '@ansh-ui/core'\nimport { type MotionTransition, type MotionValues, normalizeChildren } from './shared'\n\n// --- AnimatePresence ----------------------------------------------------------\n\nexport interface AnimatePresenceProps {\n /** Seconds to keep a removed child mounted. Default `0.35`. */\n exitDuration?: number\n}\n\n/**\n * Keep removed children mounted long enough to animate out.\n *\n * Vue unmounts a `v-for`/`v-if` item the instant it disappears from its source array, so an exit\n * animation never gets a chance to run. This holds departing children in its own state, plays their\n * `exit` values (swapped into `animate` on a cloned vnode), then drops them.\n *\n * Children **must** have stable `:key`s — that is how removals are detected at all. Without keys,\n * Vue reuses vnode positions and this sees no removal to animate, same as the React version.\n *\n * Vue's own `<TransitionGroup>` was considered instead of this hand-rolled reconciliation, but it\n * drives *CSS* transition/animation classes on move — it has no hook for \"swap this prop and let the\n * child's own animation system take it from here,\" which is what `exit` needs to compose with\n * `Motion`. Cloning the departing vnode with its `animate` prop swapped to `exit` is the direct\n * Vue-side equivalent of the React version's `cloneElement`.\n */\nexport const AnimatePresence = defineComponent({\n name: 'AnshAnimatePresence',\n props: {\n exitDuration: { type: Number, default: 0.35 },\n },\n setup(props, { slots }) {\n // Reading `slots.default()` inside a `computed` tracks whatever reactive state the parent's\n // slot closure reads (e.g. `v-for=\"item in items\"`), the same way Vue's own `<Transition>` and\n // `<KeepAlive>` track slot content — dependency tracking isn't scoped to \"this component's own\n // state\", it follows whichever reactive effect is active when the read happens.\n const currentChildren = computed(() => normalizeChildren(slots.default?.()))\n const keyOf = (node: VNode): string => String(node.key)\n const keysSignature = computed(() => currentChildren.value.map(keyOf).join('|'))\n\n const rendered = ref<VNode[]>(currentChildren.value)\n const timers = new Map<string, ReturnType<typeof setTimeout>>()\n\n watch(\n [keysSignature, () => props.exitDuration],\n () => {\n const next = currentChildren.value\n const nextKeys = new Set(next.map(keyOf))\n const departing = rendered.value.filter((node) => !nextKeys.has(keyOf(node)))\n\n if (departing.length === 0) {\n // Straight replacement keeps updated props flowing to children that are still present.\n rendered.value = next\n return\n }\n\n // Keep the departing children in place, appended after the current set so they don't\n // reorder the survivors while they animate out.\n rendered.value = [...next, ...departing]\n\n const delay = prefersReducedMotion() ? 0 : props.exitDuration * 1000\n for (const node of departing) {\n const key = keyOf(node)\n const existing = timers.get(key)\n if (existing !== undefined) clearTimeout(existing)\n timers.set(\n key,\n setTimeout(() => {\n rendered.value = rendered.value.filter((entry) => keyOf(entry) !== key)\n timers.delete(key)\n }, delay),\n )\n }\n },\n { flush: 'post' },\n )\n\n onScopeDispose(() => {\n for (const timer of timers.values()) clearTimeout(timer)\n timers.clear()\n })\n\n return () => {\n const nextKeys = new Set(currentChildren.value.map(keyOf))\n\n return rendered.value.map((node) => {\n const leaving = !nextKeys.has(keyOf(node))\n if (!leaving) return node\n\n // A departing child animates to its `exit` values by having them swapped into `animate`.\n const nodeProps = (node.props ?? {}) as {\n exit?: MotionValues\n transition?: MotionTransition\n }\n return cloneVNode(node, {\n animate: nodeProps.exit ?? { opacity: 0, scale: 0.96 },\n transition: { duration: props.exitDuration, ...nodeProps.transition },\n })\n })\n }\n },\n})\n","import { type PropType, defineComponent, h, onScopeDispose, ref } from 'vue'\nimport { getTicker, springs } from '@ansh-ui/core'\nimport { useAnimate } from '../../composables/use-motion'\nimport { cx } from '../../primitives/utils'\n\n// --- Draggable ----------------------------------------------------------------\n\nexport interface DraggableProps {\n /** Constrain movement. */\n axis?: 'x' | 'y' | 'both'\n /** Bounds relative to the starting position, in px. */\n bounds?: { left?: number; right?: number; top?: number; bottom?: number }\n /** Spring back to the origin on release. */\n snapBack?: boolean\n /** Carry momentum after release. Default `true` when not snapping back. */\n momentum?: boolean\n}\n\n/**\n * A draggable surface with inertia.\n *\n * The momentum on release is what separates a drag that feels physical from one that stops dead.\n * Velocity is measured over the last few pointer samples rather than the last two — a single pair\n * of events is dominated by whatever jitter the final sample had, which produces a flick in the\n * wrong direction often enough to be noticeable.\n *\n * `onDragStart`/`onDragEnd` from the React version become `dragStart`/`dragEnd` emits — this\n * package's convention for event-callback props (see `Input`'s `change`/`clear` emits).\n */\nexport const Draggable = defineComponent({\n name: 'AnshDraggable',\n inheritAttrs: false,\n props: {\n axis: { type: String as PropType<'x' | 'y' | 'both'>, default: 'both' },\n bounds: {\n type: Object as PropType<{ left?: number; right?: number; top?: number; bottom?: number }>,\n default: undefined,\n },\n snapBack: { type: Boolean, default: false },\n momentum: { type: Boolean, default: undefined },\n },\n emits: ['dragStart', 'dragEnd'],\n setup(props, { attrs, slots, emit, expose }) {\n const node = ref<HTMLDivElement | null>(null)\n let offset = { x: 0, y: 0 }\n const dragging = ref(false)\n const runAnimation = useAnimate()\n\n let stopMomentum: (() => void) | null = null\n // Not a concern the React version handles — Vue's pervasive scope-disposal discipline makes it\n // cheap to add here: stop an in-flight momentum glide if the component unmounts mid-gesture,\n // rather than leaving a ticker subscription writing to a detached node.\n onScopeDispose(() => stopMomentum?.())\n\n expose({\n get element() {\n return node.value\n },\n get offset() {\n return offset\n },\n })\n\n const clamp = (value: { x: number; y: number }): { x: number; y: number } => ({\n x: Math.min(\n Math.max(value.x, props.bounds?.left ?? -Infinity),\n props.bounds?.right ?? Infinity,\n ),\n y: Math.min(\n Math.max(value.y, props.bounds?.top ?? -Infinity),\n props.bounds?.bottom ?? Infinity,\n ),\n })\n\n const write = (value: { x: number; y: number }): void => {\n if (node.value) node.value.style.transform = `translate3d(${value.x}px, ${value.y}px, 0)`\n }\n\n const onPointerdown = (event: PointerEvent): void => {\n stopMomentum?.()\n stopMomentum = null\n\n ;(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId)\n dragging.value = true\n emit('dragStart')\n\n const useMomentum = props.momentum ?? !props.snapBack\n const start = { x: event.clientX, y: event.clientY }\n const origin = { ...offset }\n // A short ring of recent samples, for a velocity estimate that isn't hostage to the last\n // event.\n const samples: Array<{ x: number; y: number; t: number }> = []\n\n const onMove = (moveEvent: PointerEvent): void => {\n const next = clamp({\n x: props.axis === 'y' ? origin.x : origin.x + (moveEvent.clientX - start.x),\n y: props.axis === 'x' ? origin.y : origin.y + (moveEvent.clientY - start.y),\n })\n offset = next\n write(next)\n\n samples.push({ x: next.x, y: next.y, t: performance.now() })\n if (samples.length > 5) samples.shift()\n }\n\n const onUp = (): void => {\n dragging.value = false\n window.removeEventListener('pointermove', onMove)\n window.removeEventListener('pointerup', onUp)\n window.removeEventListener('pointercancel', onUp)\n\n if (props.snapBack) {\n runAnimation(0, 1, {\n spring: springs.subtle,\n onUpdate: (t: number) => {\n const value = { x: offset.x * (1 - t), y: offset.y * (1 - t) }\n write(value)\n },\n onComplete: () => {\n offset = { x: 0, y: 0 }\n write(offset)\n emit('dragEnd', offset)\n },\n })\n return\n }\n\n if (useMomentum && samples.length >= 2) {\n const first = samples[0]!\n const last = samples[samples.length - 1]!\n const elapsed = Math.max(1, last.t - first.t)\n let velocity = {\n x: ((last.x - first.x) / elapsed) * 1000,\n y: ((last.y - first.y) / elapsed) * 1000,\n }\n\n const decay = 0.95\n const stop = getTicker().add(\n ({ delta }) => {\n // Exponential decay, frame-rate independent: raising the per-second factor to the\n // power of the frame time keeps the glide identical at 60 and 120 Hz.\n const factor = Math.pow(decay, delta * 60)\n velocity = { x: velocity.x * factor, y: velocity.y * factor }\n\n const next = clamp({\n x: offset.x + velocity.x * delta,\n y: offset.y + velocity.y * delta,\n })\n offset = next\n write(next)\n\n if (Math.hypot(velocity.x, velocity.y) < 8) {\n stop()\n stopMomentum = null\n emit('dragEnd', offset)\n }\n },\n { phase: 'write', name: 'Draggable' },\n )\n stopMomentum = stop\n return\n }\n\n emit('dragEnd', offset)\n }\n\n window.addEventListener('pointermove', onMove)\n window.addEventListener('pointerup', onUp)\n window.addEventListener('pointercancel', onUp)\n }\n\n return () => {\n const { class: attrClass, style: attrStyle, ...restAttrs } = attrs as Record<string, unknown>\n\n return h(\n 'div',\n {\n ref: node,\n class: cx(\n 'ansh-draggable',\n dragging.value && 'ansh-draggable--active',\n attrClass as string,\n ),\n style: [\n {\n touchAction: props.axis === 'x' ? 'pan-y' : props.axis === 'y' ? 'pan-x' : 'none',\n },\n attrStyle,\n ],\n onPointerdown,\n ...restAttrs,\n },\n slots.default?.(),\n )\n }\n },\n})\n"]}
@@ -417,6 +417,8 @@ function normalizeChildren(nodes) {
417
417
  return true;
418
418
  });
419
419
  }
420
+
421
+ // src/components/motion/motion.ts
420
422
  var Motion = defineComponent({
421
423
  name: "AnshMotion",
422
424
  inheritAttrs: false,
@@ -718,5 +720,5 @@ var Draggable = defineComponent({
718
720
  });
719
721
 
720
722
  export { AnimatePresence, AnimatedText, Draggable, GradientText, Motion, MotionConfig, ThemeProvider, themeScript, useMotionConfig, useTheme };
721
- //# sourceMappingURL=chunk-6ABPGOJP.js.map
722
- //# sourceMappingURL=chunk-6ABPGOJP.js.map
723
+ //# sourceMappingURL=chunk-LFGAOD32.js.map
724
+ //# sourceMappingURL=chunk-LFGAOD32.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/text.ts","../src/components/providers.ts","../src/components/motion/shared.ts","../src/components/motion/motion.ts","../src/components/motion/animate-presence.ts","../src/components/motion/draggable.ts"],"names":["defineComponent","getTicker","onBeforeUnmount","computed","ref","onMounted","watch","h","pref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ACA,MAAM,OAAA;AAAU,OAClB;AAAA,IACF,CAAA;AAAA,EACF;AACF,CAAC","file":"chunk-LFGAOD32.js","sourcesContent":["import {\n type CSSProperties,\n type PropType,\n computed,\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n ref,\n} from 'vue'\nimport {\n type ColorInput,\n type EasingInput,\n type StaggerFrom,\n createGradient,\n getTicker,\n observeIntersection,\n prefersReducedMotion,\n resolveEasing,\n resolvePalette,\n stagger,\n} from '@ansh-ui/core'\n\n/**\n * Text components.\n *\n * Hand-written rather than factory-generated, because text animation has a requirement no generic\n * factory can meet: **the accessible text must never be the animated text.** Splitting a heading\n * into per-character spans is fine visually and an accessibility failure if that structure is what\n * a screen reader reads — some engines announce \"W. E. L. C. O. M. E.\" and you cannot rely on which.\n *\n * The pattern used here: the real string lives in a visually-hidden element that remains the\n * accessible representation, and the whole animated structure is `aria-hidden`.\n */\n\nconst VISUALLY_HIDDEN: CSSProperties = {\n position: 'absolute',\n width: '1px',\n height: '1px',\n padding: '0',\n margin: '-1px',\n overflow: 'hidden',\n clipPath: 'inset(50%)',\n whiteSpace: 'nowrap',\n borderWidth: '0',\n}\n\n// ---------------------------------------------------------------------------\n// GradientText\n// ---------------------------------------------------------------------------\n\n/**\n * Text filled with a perceptual gradient.\n *\n * The stops are generated through the OKLab interpolator rather than handed to CSS as two\n * endpoints. That is the entire point: a CSS `linear-gradient(#0275f4, #9f0550)` passes through a\n * desaturated grey-brown at its midpoint, and on text — where the gradient crosses a narrow band —\n * the midpoint is exactly where the eye lands.\n *\n * The optional animation is a CSS `background-position` shift rather than a JS loop, because for a\n * single non-interactive property the browser's compositor beats anything we could do on the main\n * thread.\n */\nexport const GradientText = defineComponent({\n name: 'AnshGradientText',\n props: {\n text: { type: String, default: '' },\n colors: {\n type: [Array, String] as PropType<readonly ColorInput[] | string>,\n default: undefined,\n },\n /** Gradient angle in degrees. */\n angle: { type: Number, default: 100 },\n /** Seconds per cycle. `0` holds a static gradient. */\n duration: { type: Number, default: 0 },\n /** Interpolated stops handed to CSS. More is smoother. */\n stops: { type: Number, default: 16 },\n as: { type: String, default: 'span' },\n },\n\n setup(props, { slots }) {\n const gradient = computed(() => {\n const palette = resolvePalette(props.colors as never)\n // Duplicated so an animated background-position shift wraps seamlessly rather than jumping.\n const looped = props.duration > 0 ? [...palette, ...palette] : palette\n return createGradient(looped, { space: 'oklab' }).toCss(`${props.angle}deg`, props.stops)\n })\n\n const animated = computed(() => props.duration > 0 && !prefersReducedMotion())\n\n return () =>\n h(\n props.as,\n {\n style: {\n backgroundImage: gradient.value,\n backgroundSize: animated.value ? '200% 100%' : '100% 100%',\n backgroundClip: 'text',\n WebkitBackgroundClip: 'text',\n color: 'transparent',\n WebkitTextFillColor: 'transparent',\n display: 'inline-block',\n ...(animated.value\n ? { animation: `ansh-gradient-shift ${props.duration}s linear infinite` }\n : {}),\n } as CSSProperties,\n },\n [\n slots.default?.() ?? props.text,\n // The keyframes are injected inline so `<GradientText :duration=\"6\" />` works with no\n // stylesheet import. Identical rules from multiple instances are deduplicated by the\n // browser, so this costs nothing at scale.\n animated.value\n ? h('style', {\n innerHTML:\n '@keyframes ansh-gradient-shift{from{background-position:0% 50%}' +\n 'to{background-position:200% 50%}}',\n })\n : null,\n ],\n )\n },\n})\n\n// ---------------------------------------------------------------------------\n// AnimatedText\n// ---------------------------------------------------------------------------\n\ninterface Unit {\n text: string\n /** Whitespace is rendered as a plain gap rather than an animated unit. */\n space: boolean\n}\n\n/**\n * Text that reveals unit by unit.\n *\n * The split happens during render, so the markup is server-rendered and the real text is present in\n * the HTML source for SEO and for readers without JavaScript. The animation runs on the shared\n * ticker, so a page full of these shares one clock and cannot drift apart.\n *\n * Under `prefers-reduced-motion` the text renders in its final state and never animates.\n */\nexport const AnimatedText = defineComponent({\n name: 'AnshAnimatedText',\n props: {\n text: { type: String, required: true },\n /** Split granularity. */\n by: { type: String as PropType<'chars' | 'words'>, default: 'chars' },\n /** Seconds per unit. */\n duration: { type: Number, default: 0.6 },\n /** Seconds between units. */\n each: { type: Number, default: 0.03 },\n /** Where the reveal wave begins. */\n from: { type: [String, Number] as PropType<StaggerFrom>, default: 'first' },\n easing: { type: [String, Function, Array] as PropType<EasingInput>, default: 'cinematic' },\n /** Distance each unit travels into place, in pixels. */\n distance: { type: Number, default: 18 },\n /** Starting blur in pixels — the \"focus in\" look. */\n blur: { type: Number, default: 0 },\n /** Starting rotation in degrees. */\n rotate: { type: Number, default: 0 },\n /** Clip each unit so it rises from behind a mask. */\n mask: { type: Boolean, default: false },\n /** Wait until scrolled into view. */\n whenInView: { type: Boolean, default: true },\n /** Replay every time it re-enters the viewport. */\n repeat: { type: Boolean, default: false },\n /** Seconds to wait before starting. */\n delay: { type: Number, default: 0 },\n as: { type: String, default: 'span' },\n },\n emits: ['complete'],\n\n setup(props, { emit }) {\n const host = ref<HTMLElement | null>(null)\n const unitNodes = ref<(HTMLElement | null)[]>([])\n\n const units = computed<Unit[]>(() => {\n if (props.by === 'words') {\n return props.text\n .split(/(\\s+)/)\n .filter((token) => token.length > 0)\n .map((token) => ({ text: token, space: /^\\s+$/.test(token) }))\n }\n\n // Grapheme-aware: `[...string]` splits by code point, which breaks emoji with modifiers and\n // combining accents into multiple \"characters\".\n const graphemes =\n typeof Intl !== 'undefined' && 'Segmenter' in Intl\n ? Array.from(\n new Intl.Segmenter(undefined, { granularity: 'grapheme' }).segment(props.text),\n (s) => s.segment,\n )\n : Array.from(props.text)\n\n return graphemes.map((character) => ({ text: character, space: /^\\s$/.test(character) }))\n })\n\n let stopTicker: (() => void) | null = null\n let stopObserver: (() => void) | null = null\n\n onMounted(() => {\n const element = host.value\n if (!element) return\n\n if (prefersReducedMotion()) {\n emit('complete')\n return\n }\n\n const ease = resolveEasing(props.easing)\n const animatedUnits = units.value.filter((u) => !u.space)\n const delayFor = stagger(animatedUnits.length, { each: props.each, from: props.from })\n\n const targets: { node: HTMLElement; delay: number }[] = []\n let animationIndex = 0\n units.value.forEach((unit, i) => {\n if (unit.space) return\n const node = unitNodes.value[i]\n if (node) targets.push({ node, delay: props.delay + delayFor(animationIndex) })\n animationIndex++\n })\n\n const apply = (node: HTMLElement, progress: number): void => {\n const eased = ease(progress)\n const inverse = 1 - eased\n node.style.opacity = String(eased)\n const parts = [`translate3d(0, ${(props.distance * inverse).toFixed(2)}px, 0)`]\n if (props.rotate !== 0) parts.push(`rotate(${(props.rotate * inverse).toFixed(2)}deg)`)\n node.style.transform = parts.join(' ')\n if (props.blur > 0) {\n const amount = props.blur * inverse\n node.style.filter = amount > 0.05 ? `blur(${amount.toFixed(2)}px)` : ''\n }\n }\n\n const settle = (node: HTMLElement): void => {\n node.style.opacity = ''\n node.style.transform = ''\n node.style.filter = ''\n // Drop the compositor promotion once at rest, so a page of these doesn't hold hundreds of\n // permanent layers.\n node.style.willChange = ''\n }\n\n const reset = (): void => {\n for (const { node } of targets) apply(node, 0)\n }\n\n let elapsed = 0\n let running = false\n\n const start = (): void => {\n if (running) return\n running = true\n elapsed = 0\n for (const { node } of targets) node.style.willChange = 'opacity, transform'\n reset()\n\n stopTicker = getTicker().add(\n ({ delta }) => {\n elapsed += delta\n let allDone = true\n\n for (const target of targets) {\n const local = elapsed - target.delay\n if (local < 0) {\n allDone = false\n continue\n }\n const progress = props.duration <= 0 ? 1 : local / props.duration\n if (progress >= 1) {\n settle(target.node)\n continue\n }\n apply(target.node, progress)\n allDone = false\n }\n\n if (allDone) {\n stopTicker?.()\n stopTicker = null\n running = false\n emit('complete')\n }\n },\n { phase: 'write', name: 'AnimatedText' },\n )\n }\n\n // Hide before the browser paints. `onMounted` in Vue runs after the DOM is inserted but\n // before paint, so unlike React's `useEffect` there is no flash to guard against here.\n reset()\n\n if (!props.whenInView) {\n start()\n return\n }\n\n stopObserver = observeIntersection(\n element,\n (entry) => {\n if (entry.isIntersecting) {\n start()\n } else if (props.repeat) {\n stopTicker?.()\n stopTicker = null\n running = false\n reset()\n }\n },\n { threshold: 0.2, rootMargin: '0px 0px -8% 0px' },\n )\n })\n\n onBeforeUnmount(() => {\n stopObserver?.()\n stopTicker?.()\n stopObserver = null\n stopTicker = null\n })\n\n return () =>\n h(props.as, { ref: host, style: { display: 'inline-block' } as CSSProperties }, [\n // The accessible representation: the real string, unfragmented.\n h('span', { style: VISUALLY_HIDDEN }, props.text),\n\n h(\n 'span',\n { 'aria-hidden': 'true' },\n units.value.map((unit, i) => {\n if (unit.space) return h('span', {}, unit.text)\n\n const inner = h(\n 'span',\n {\n ref: (node: unknown) => {\n unitNodes.value[i] = (node as HTMLElement | null) ?? null\n },\n style: { display: 'inline-block' } as CSSProperties,\n },\n unit.text,\n )\n\n return props.mask\n ? h(\n 'span',\n {\n style: {\n display: 'inline-block',\n overflow: 'hidden',\n // Without this, descenders (g, y, p) are clipped by the mask box.\n verticalAlign: 'top',\n } as CSSProperties,\n },\n [inner],\n )\n : inner\n }),\n ),\n ])\n },\n})\n","import {\n type ComputedRef,\n type InjectionKey,\n type PropType,\n computed,\n defineComponent,\n inject,\n onBeforeUnmount,\n provide,\n ref,\n watch,\n} from 'vue'\nimport {\n type ReducedMotionMode,\n attachLifecycle,\n getTicker,\n setReducedMotionMode,\n} from '@ansh-ui/core'\nimport { applyTheme, resolveTheme } from '@ansh-ui/tokens'\n\n/**\n * Application-level configuration providers — the Vue counterpart of `@ansh-ui/react`'s\n * `providers.tsx`. `provide`/`inject` replace React context; everything else about the two designs\n * is intentionally identical, because the underlying correctness constraints (no hydration\n * mismatch, no theme flash) don't change with the framework.\n */\n\n// ---------------------------------------------------------------------------\n// MotionConfig\n// ---------------------------------------------------------------------------\n\nexport interface MotionConfigValue {\n reducedMotion: ReducedMotionMode\n /** Global playback rate. `0.5` is slow motion across every animation on the page. */\n timeScale: number\n /** Pin adaptive quality, or `null` to let the frame budget decide. */\n quality: number | null\n}\n\nconst DEFAULT_MOTION_CONFIG: MotionConfigValue = {\n reducedMotion: 'auto',\n timeScale: 1,\n quality: null,\n}\n\nconst MotionConfigKey: InjectionKey<ComputedRef<MotionConfigValue>> = Symbol('ansh-motion-config')\n\n/**\n * Application-level motion configuration.\n *\n * Optional — every component works without it. Mount it once at the root when you need app-wide\n * control:\n *\n * ```vue\n * <MotionConfig :reduced-motion=\"userPrefersCalm ? 'always' : 'auto'\">\n * <App />\n * </MotionConfig>\n * ```\n *\n * `reducedMotion=\"always\"` is genuinely useful in production, as the backing for an in-app \"reduce\n * motion\" setting — many users who want calmer interfaces have never found the OS toggle.\n */\nexport const MotionConfig = defineComponent({\n name: 'AnshMotionConfig',\n props: {\n reducedMotion: { type: String as PropType<ReducedMotionMode>, default: 'auto' },\n timeScale: { type: Number, default: 1 },\n quality: { type: Number as PropType<number | null>, default: null },\n /**\n * Pause every animation while the document is hidden. Default `true`.\n *\n * Leave this on. Animating a background tab burns battery and spins fans for output nobody can\n * see, and it is the most common performance complaint about animation-heavy sites.\n */\n pauseWhenHidden: { type: Boolean, default: true },\n pauseWhenBlurred: { type: Boolean, default: false },\n respectBattery: { type: Boolean, default: true },\n },\n setup(props, { slots }) {\n watch(\n () => props.reducedMotion,\n (mode) => setReducedMotionMode(mode),\n { immediate: true },\n )\n watch(\n () => props.timeScale,\n (scale) => {\n getTicker().timeScale = scale\n },\n { immediate: true },\n )\n watch(\n () => props.quality,\n (quality) => {\n if (quality !== null) getTicker().lockQuality(quality)\n },\n { immediate: true },\n )\n\n let detach: (() => void) | null = null\n watch(\n () => [props.pauseWhenHidden, props.pauseWhenBlurred, props.respectBattery] as const,\n ([pauseWhenHidden, pauseWhenBlurred, respectBattery]) => {\n detach?.()\n detach = attachLifecycle(getTicker(), { pauseWhenHidden, pauseWhenBlurred, respectBattery })\n },\n { immediate: true },\n )\n onBeforeUnmount(() => detach?.())\n\n provide(\n MotionConfigKey,\n computed(() => ({\n reducedMotion: props.reducedMotion,\n timeScale: props.timeScale,\n quality: props.quality,\n })),\n )\n\n return () => slots.default?.()\n },\n})\n\n/** Read the nearest {@link MotionConfig}. Returns sensible defaults with no provider present. */\nexport function useMotionConfig(): ComputedRef<MotionConfigValue> {\n return inject(\n MotionConfigKey,\n computed(() => DEFAULT_MOTION_CONFIG),\n )\n}\n\n// ---------------------------------------------------------------------------\n// ThemeProvider\n// ---------------------------------------------------------------------------\n\nexport type ThemeSetting = 'light' | 'dark' | 'system'\n\nexport interface ThemeContextValue {\n /** What was requested, including `'system'`. */\n theme: ThemeSetting\n /** What is actually rendering. `'system'` is resolved to one or the other. */\n resolved: 'light' | 'dark'\n setTheme: (theme: ThemeSetting) => void\n}\n\nconst DEFAULT_THEME: ThemeContextValue = { theme: 'system', resolved: 'light', setTheme: () => {} }\n\nconst ThemeKey: InjectionKey<ComputedRef<ThemeContextValue>> = Symbol('ansh-theme')\n\n/**\n * Theme control over the `@ansh-ui/tokens` stylesheet.\n *\n * Sets `data-theme` on `<html>`, which the token stylesheet already understands. Two details that\n * are easy to get wrong and are handled here:\n *\n * **`'system'` removes the attribute rather than writing a resolved value.** The token stylesheet\n * guards its `prefers-color-scheme` rule with `:root:not([data-theme])`, so removing the attribute\n * hands control back to the OS — and, importantly, means the theme keeps following the OS if the\n * user changes it while the page is open.\n *\n * **The initial render always reports `'light'`.** Reading `localStorage` during setup would be a\n * hydration mismatch, since the server has no access to it. The stored value is applied `onMounted`.\n * To avoid a flash of the wrong theme, ship the small inline script from {@link themeScript} in your\n * document `<head>` — that is the only way to set the attribute before first paint. `@ansh-ui/nuxt`\n * does this automatically.\n */\nexport const ThemeProvider = defineComponent({\n name: 'AnshThemeProvider',\n props: {\n /** Initial setting. Default `'system'`. */\n defaultTheme: { type: String as PropType<ThemeSetting>, default: 'system' },\n /** Persist the choice under this `localStorage` key. Pass `null` to disable. */\n storageKey: { type: String as PropType<string | null>, default: 'ansh-theme' },\n },\n setup(props, { slots }) {\n const theme = ref<ThemeSetting>(props.defaultTheme)\n const resolved = ref<'light' | 'dark'>('light')\n\n const setTheme = (next: ThemeSetting): void => {\n theme.value = next\n }\n\n // Read the stored preference after mount, never during setup.\n let mediaQuery: MediaQueryList | null = null\n let onMediaChange: (() => void) | null = null\n\n const syncMedia = (): void => {\n mediaQuery?.removeEventListener('change', onMediaChange!)\n mediaQuery = null\n onMediaChange = null\n if (theme.value !== 'system' || typeof matchMedia !== 'function') return\n mediaQuery = matchMedia('(prefers-color-scheme: dark)')\n onMediaChange = () => {\n resolved.value = mediaQuery!.matches ? 'dark' : 'light'\n }\n mediaQuery.addEventListener('change', onMediaChange)\n }\n\n watch(\n theme,\n (next) => {\n applyTheme(next)\n resolved.value = resolveTheme()\n syncMedia()\n if (props.storageKey) {\n try {\n localStorage.setItem(props.storageKey, next)\n } catch {\n // Storage can throw in private browsing or with cookies disabled. A theme preference\n // is not worth breaking the page over.\n }\n }\n },\n { flush: 'post' },\n )\n\n // Runs once, after mount — the `watch` above has already applied `defaultTheme` by then, and\n // this only overrides it if something was actually stored.\n if (typeof document !== 'undefined') {\n queueMicrotask(() => {\n if (!props.storageKey) return\n try {\n const stored = localStorage.getItem(props.storageKey)\n if (stored === 'light' || stored === 'dark' || stored === 'system') theme.value = stored\n } catch {\n // As above.\n }\n })\n // Apply the default immediately too, so there is no gap before the microtask above runs.\n applyTheme(theme.value)\n resolved.value = resolveTheme()\n syncMedia()\n }\n\n onBeforeUnmount(() => mediaQuery?.removeEventListener('change', onMediaChange!))\n\n provide(\n ThemeKey,\n computed(() => ({ theme: theme.value, resolved: resolved.value, setTheme })),\n )\n\n return () => slots.default?.()\n },\n})\n\nexport function useTheme(): ComputedRef<ThemeContextValue> {\n return inject(\n ThemeKey,\n computed(() => DEFAULT_THEME),\n )\n}\n\n/**\n * The blocking script that prevents a theme flash.\n *\n * Inject this in `<head>`, before any stylesheet. It reads the stored preference and sets\n * `data-theme` synchronously, before the browser paints — the only point at which it can be done\n * without a visible flash. Deliberately tiny and dependency-free.\n *\n * `@ansh-ui/nuxt` injects this automatically; a bare Vue app should call it from `index.html`.\n */\nexport function themeScript(storageKey = 'ansh-theme'): string {\n return (\n `(function(){try{var t=localStorage.getItem(${JSON.stringify(storageKey)});` +\n `if(t==='light'||t==='dark'){document.documentElement.setAttribute('data-theme',t)}}` +\n `catch(e){}})()`\n )\n}\n","import { Comment, Text, type VNode } from 'vue'\nimport { type EasingInput, type SpringOptions, type springs } from '@ansh-ui/core'\n\nexport interface MotionValues {\n opacity?: number\n x?: number\n y?: number\n scale?: number\n scaleX?: number\n scaleY?: number\n rotate?: number\n /** Blur radius in px. */\n blur?: number\n}\n\nexport interface MotionTransition {\n /** Seconds. Ignored when `spring` is set. Default `0.4`. */\n duration?: number\n /** Seconds to wait. Default `0`. */\n delay?: number\n easing?: EasingInput\n /** Use a spring instead of a tween. `true` uses the `smooth` preset. */\n spring?: boolean | SpringOptions | keyof typeof springs\n}\n\nexport const DEFAULTS: Required<MotionValues> = {\n opacity: 1,\n x: 0,\n y: 0,\n scale: 1,\n scaleX: 1,\n scaleY: 1,\n rotate: 0,\n blur: 0,\n}\n\n/** Compose the values into a transform string plus the properties that aren't transforms. */\nexport function applyValues(node: HTMLElement, values: Required<MotionValues>): void {\n const transform =\n `translate3d(${values.x}px, ${values.y}px, 0)` +\n ` scale(${values.scale * values.scaleX}, ${values.scale * values.scaleY})` +\n ` rotate(${values.rotate}deg)`\n\n node.style.transform = transform\n node.style.opacity = String(values.opacity)\n // Only written when non-zero: an always-present `filter` creates a containing block and a new\n // stacking context, which changes how `position: fixed` descendants resolve.\n node.style.filter = values.blur > 0 ? `blur(${values.blur}px)` : ''\n}\n\nexport function resolve(\n values: MotionValues | undefined,\n base: Required<MotionValues>,\n): Required<MotionValues> {\n return { ...base, ...values }\n}\n\n/** Drop whitespace-only text nodes and `v-if=\"false\"` comment placeholders from a slot's output. */\nexport function normalizeChildren(nodes: VNode[] | undefined): VNode[] {\n return (nodes ?? []).filter((node) => {\n if (node.type === Comment) return false\n if (node.type === Text && typeof node.children === 'string' && node.children.trim() === '') {\n return false\n }\n return true\n })\n}\n","import { type PropType, computed, defineComponent, h, onMounted, ref, watch } from 'vue'\nimport { type AnimationOptions, springs } from '@ansh-ui/core'\nimport { useAnimate } from '../../composables/use-motion'\nimport { useInView } from '../../composables/use-observers'\nimport { DEFAULTS, type MotionTransition, type MotionValues, applyValues, resolve } from './shared'\n\n/**\n * Declarative motion — the Vue counterpart of `@ansh-ui/react`'s `Motion`/`AnimatePresence`/\n * `Draggable`.\n *\n * A deliberately **small** subset of what a full motion library does: transform properties and\n * opacity, animated from `initial` to `animate`, plus hover and press states and an exit animation\n * when paired with `AnimatePresence`.\n *\n * That scope is a decision, not a gap. Layout animation (FLIP), shared-element transitions and\n * variant propagation each need machinery an order of magnitude larger than this file, and a\n * half-implementation of them is worse than none — it works in the demo and fails on the real page.\n * For those, use a dedicated library; for the 90% case of \"fade this in, slide that up, spring the\n * card on hover\", this costs a fraction of the bundle.\n *\n * Values are written straight to the element's `style` from the ticker's write phase, outside Vue's\n * reactivity — the same principle `useMotionStyle` documents in `composables/use-motion.ts`. `Motion`\n * and `Draggable` are built on `useAnimate()` (scope-bound imperative animation, auto-stopping the\n * previous run) and `useInView()` (the `whileInView` trigger) rather than calling the ticker\n * primitives from scratch, so cleanup and scope-disposal are inherited for free.\n */\n\n// --- Motion -----------------------------------------------------------------\n\n/**\n * An animated element.\n *\n * ```vue\n * <Motion :initial=\"{ opacity: 0, y: 24 }\" :animate=\"{ opacity: 1, y: 0 }\" while-in-view>\n * <Card />\n * </Motion>\n * ```\n */\nexport const Motion = defineComponent({\n name: 'AnshMotion',\n inheritAttrs: false,\n props: {\n as: { type: String, default: 'div' },\n /** Starting values. Applied before the first paint. */\n initial: { type: Object as PropType<MotionValues>, default: undefined },\n /** Target values. Changing these animates to the new target. */\n animate: { type: Object as PropType<MotionValues>, default: undefined },\n // Declared so it lands here rather than in `attrs`: `AnimatePresence` reads it off the vnode's\n // props when the child is removed and swaps it into `animate`. Left undeclared, it would reach\n // the DOM as an unknown `exit` attribute.\n exit: { type: Object as PropType<MotionValues>, default: undefined },\n transition: { type: Object as PropType<MotionTransition>, default: undefined },\n whileHover: { type: Object as PropType<MotionValues>, default: undefined },\n whileTap: { type: Object as PropType<MotionValues>, default: undefined },\n /** Animate to `animate` only once scrolled into view. */\n whileInView: { type: Boolean, default: false },\n /** Fraction visible before `whileInView` triggers. Default `0.2`. */\n inViewAmount: { type: Number, default: 0.2 },\n },\n setup(props, { attrs, slots, expose }) {\n const node = ref<HTMLElement | null>(null)\n // Plain closure state, deliberately outside Vue's reactivity — a value driven by the ticker\n // changes up to 60 times a second, and a `ref` here would flush a reactive effect on every one.\n let current = resolve(props.initial, DEFAULTS)\n const start = useAnimate()\n\n expose({\n get element() {\n return node.value\n },\n })\n\n // Applied in `onMounted`, not a plain function call during setup: the DOM node the template\n // `ref` points at only exists once Vue has patched it in, which — for the initial render — is\n // still before the browser's next paint. That ordering is what avoids the element flashing at\n // full opacity for one frame before the \"hidden\" `initial` state ever gets applied.\n //\n // The first run of the `animate` target is kicked off here too, rather than from the `watch`\n // below with `immediate: true`. Vue runs an immediate watcher's callback *synchronously during\n // `setup()`*, regardless of `flush` — `flush: 'post'` only defers a watcher's *subsequent*\n // re-runs, not its immediate one. `node.value` is still null at that point (the element hasn't\n // mounted yet), so `runTo` would silently no-op and the component would never animate to its\n // initial `animate` target. `onMounted` is the actual first point at which `node.value` exists.\n onMounted(() => {\n if (!node.value) return\n applyValues(node.value, current)\n if (inView.value) runTo(resolve(props.animate, DEFAULTS))\n })\n\n const runTo = (next: Required<MotionValues>, options?: MotionTransition): void => {\n const element = node.value\n if (!element) return\n\n const from = { ...current }\n const springOption = options?.spring ?? props.transition?.spring\n\n const animationOptions: AnimationOptions<number> = {\n ...((options?.delay ?? props.transition?.delay) !== undefined\n ? { delay: options?.delay ?? props.transition?.delay ?? 0 }\n : null),\n ...(springOption\n ? {\n spring:\n springOption === true\n ? springs.default\n : typeof springOption === 'string'\n ? springs[springOption]\n : springOption,\n }\n : {\n duration: options?.duration ?? props.transition?.duration ?? 0.4,\n ...((options?.easing ?? props.transition?.easing)\n ? { easing: (options?.easing ?? props.transition?.easing)! }\n : null),\n }),\n onUpdate: (t: number) => {\n // One scalar drives every property, so all of them stay in lockstep. Animating each\n // independently would need one ticker subscription per property and they would drift\n // apart under a spring, which is not time-based.\n const frame = {} as Required<MotionValues>\n for (const key of Object.keys(DEFAULTS) as Array<keyof MotionValues>) {\n frame[key] = from[key] + (next[key] - from[key]) * t\n }\n current = frame\n applyValues(element, frame)\n },\n onComplete: () => {\n current = next\n applyValues(element, next)\n },\n }\n\n // `useAnimate()` stops any in-flight run of its own before starting the next, and again on\n // scope disposal — the two cleanup spots the React version's `controlsRef` handles by hand.\n start(0, 1, animationOptions)\n }\n\n // `whileInView` gating, via the same observer composable `useElementSize`/`useScrollProgress`\n // are built on. Always attached (harmless when `whileInView` is false — the observer simply\n // goes unused) rather than conditionally, since `inViewAmount` and `whileInView` are expected\n // to be set once and not toggled.\n const inViewState = useInView(node, { threshold: props.inViewAmount, once: true })\n const inView = computed(() => !props.whileInView || inViewState.value)\n\n // Animate to the target whenever it changes after mount (or when it scrolls into view). The\n // *first* run is handled explicitly in `onMounted` above, not here — see the comment there.\n // No `immediate: true`: this only needs to react to changes from here on.\n watch(\n [() => JSON.stringify(props.animate ?? null), inView],\n ([, isInView]) => {\n if (!isInView) return\n runTo(resolve(props.animate, DEFAULTS))\n },\n { flush: 'post' },\n )\n\n return () => {\n const { class: attrClass, style: attrStyle, ...restAttrs } = attrs as Record<string, unknown>\n\n const interaction: Record<string, unknown> = {}\n if (props.whileHover) {\n interaction.onMouseenter = () =>\n runTo(resolve({ ...props.animate, ...props.whileHover }, DEFAULTS))\n interaction.onMouseleave = () => runTo(resolve(props.animate, DEFAULTS))\n }\n if (props.whileTap) {\n interaction.onPointerdown = () =>\n runTo(resolve({ ...props.animate, ...props.whileTap }, DEFAULTS), { duration: 0.12 })\n interaction.onPointerup = () =>\n runTo(resolve({ ...props.animate, ...props.whileHover }, DEFAULTS))\n }\n\n return h(\n props.as,\n {\n ref: node,\n class: attrClass,\n // `will-change` is set once, statically. Toggling it per animation causes the compositor\n // to create and destroy a layer on every interaction, which is more expensive than the\n // hint saves.\n style: [{ willChange: 'transform, opacity' }, attrStyle],\n ...interaction,\n ...restAttrs,\n },\n slots.default?.(),\n )\n }\n },\n})\n","import { type VNode, cloneVNode, computed, defineComponent, onScopeDispose, ref, watch } from 'vue'\nimport { prefersReducedMotion } from '@ansh-ui/core'\nimport { type MotionTransition, type MotionValues, normalizeChildren } from './shared'\n\n// --- AnimatePresence ----------------------------------------------------------\n\nexport interface AnimatePresenceProps {\n /** Seconds to keep a removed child mounted. Default `0.35`. */\n exitDuration?: number\n}\n\n/**\n * Keep removed children mounted long enough to animate out.\n *\n * Vue unmounts a `v-for`/`v-if` item the instant it disappears from its source array, so an exit\n * animation never gets a chance to run. This holds departing children in its own state, plays their\n * `exit` values (swapped into `animate` on a cloned vnode), then drops them.\n *\n * Children **must** have stable `:key`s — that is how removals are detected at all. Without keys,\n * Vue reuses vnode positions and this sees no removal to animate, same as the React version.\n *\n * Vue's own `<TransitionGroup>` was considered instead of this hand-rolled reconciliation, but it\n * drives *CSS* transition/animation classes on move — it has no hook for \"swap this prop and let the\n * child's own animation system take it from here,\" which is what `exit` needs to compose with\n * `Motion`. Cloning the departing vnode with its `animate` prop swapped to `exit` is the direct\n * Vue-side equivalent of the React version's `cloneElement`.\n */\nexport const AnimatePresence = defineComponent({\n name: 'AnshAnimatePresence',\n props: {\n exitDuration: { type: Number, default: 0.35 },\n },\n setup(props, { slots }) {\n // Reading `slots.default()` inside a `computed` tracks whatever reactive state the parent's\n // slot closure reads (e.g. `v-for=\"item in items\"`), the same way Vue's own `<Transition>` and\n // `<KeepAlive>` track slot content — dependency tracking isn't scoped to \"this component's own\n // state\", it follows whichever reactive effect is active when the read happens.\n const currentChildren = computed(() => normalizeChildren(slots.default?.()))\n const keyOf = (node: VNode): string => String(node.key)\n const keysSignature = computed(() => currentChildren.value.map(keyOf).join('|'))\n\n const rendered = ref<VNode[]>(currentChildren.value)\n const timers = new Map<string, ReturnType<typeof setTimeout>>()\n\n watch(\n [keysSignature, () => props.exitDuration],\n () => {\n const next = currentChildren.value\n const nextKeys = new Set(next.map(keyOf))\n const departing = rendered.value.filter((node) => !nextKeys.has(keyOf(node)))\n\n if (departing.length === 0) {\n // Straight replacement keeps updated props flowing to children that are still present.\n rendered.value = next\n return\n }\n\n // Keep the departing children in place, appended after the current set so they don't\n // reorder the survivors while they animate out.\n rendered.value = [...next, ...departing]\n\n const delay = prefersReducedMotion() ? 0 : props.exitDuration * 1000\n for (const node of departing) {\n const key = keyOf(node)\n const existing = timers.get(key)\n if (existing !== undefined) clearTimeout(existing)\n timers.set(\n key,\n setTimeout(() => {\n rendered.value = rendered.value.filter((entry) => keyOf(entry) !== key)\n timers.delete(key)\n }, delay),\n )\n }\n },\n { flush: 'post' },\n )\n\n onScopeDispose(() => {\n for (const timer of timers.values()) clearTimeout(timer)\n timers.clear()\n })\n\n return () => {\n const nextKeys = new Set(currentChildren.value.map(keyOf))\n\n return rendered.value.map((node) => {\n const leaving = !nextKeys.has(keyOf(node))\n if (!leaving) return node\n\n // A departing child animates to its `exit` values by having them swapped into `animate`.\n const nodeProps = (node.props ?? {}) as {\n exit?: MotionValues\n transition?: MotionTransition\n }\n return cloneVNode(node, {\n animate: nodeProps.exit ?? { opacity: 0, scale: 0.96 },\n transition: { duration: props.exitDuration, ...nodeProps.transition },\n })\n })\n }\n },\n})\n","import { type PropType, defineComponent, h, onScopeDispose, ref } from 'vue'\nimport { getTicker, springs } from '@ansh-ui/core'\nimport { useAnimate } from '../../composables/use-motion'\nimport { cx } from '../../primitives/utils'\n\n// --- Draggable ----------------------------------------------------------------\n\nexport interface DraggableProps {\n /** Constrain movement. */\n axis?: 'x' | 'y' | 'both'\n /** Bounds relative to the starting position, in px. */\n bounds?: { left?: number; right?: number; top?: number; bottom?: number }\n /** Spring back to the origin on release. */\n snapBack?: boolean\n /** Carry momentum after release. Default `true` when not snapping back. */\n momentum?: boolean\n}\n\n/**\n * A draggable surface with inertia.\n *\n * The momentum on release is what separates a drag that feels physical from one that stops dead.\n * Velocity is measured over the last few pointer samples rather than the last two — a single pair\n * of events is dominated by whatever jitter the final sample had, which produces a flick in the\n * wrong direction often enough to be noticeable.\n *\n * `onDragStart`/`onDragEnd` from the React version become `dragStart`/`dragEnd` emits — this\n * package's convention for event-callback props (see `Input`'s `change`/`clear` emits).\n */\nexport const Draggable = defineComponent({\n name: 'AnshDraggable',\n inheritAttrs: false,\n props: {\n axis: { type: String as PropType<'x' | 'y' | 'both'>, default: 'both' },\n bounds: {\n type: Object as PropType<{ left?: number; right?: number; top?: number; bottom?: number }>,\n default: undefined,\n },\n snapBack: { type: Boolean, default: false },\n momentum: { type: Boolean, default: undefined },\n },\n emits: ['dragStart', 'dragEnd'],\n setup(props, { attrs, slots, emit, expose }) {\n const node = ref<HTMLDivElement | null>(null)\n let offset = { x: 0, y: 0 }\n const dragging = ref(false)\n const runAnimation = useAnimate()\n\n let stopMomentum: (() => void) | null = null\n // Not a concern the React version handles — Vue's pervasive scope-disposal discipline makes it\n // cheap to add here: stop an in-flight momentum glide if the component unmounts mid-gesture,\n // rather than leaving a ticker subscription writing to a detached node.\n onScopeDispose(() => stopMomentum?.())\n\n expose({\n get element() {\n return node.value\n },\n get offset() {\n return offset\n },\n })\n\n const clamp = (value: { x: number; y: number }): { x: number; y: number } => ({\n x: Math.min(\n Math.max(value.x, props.bounds?.left ?? -Infinity),\n props.bounds?.right ?? Infinity,\n ),\n y: Math.min(\n Math.max(value.y, props.bounds?.top ?? -Infinity),\n props.bounds?.bottom ?? Infinity,\n ),\n })\n\n const write = (value: { x: number; y: number }): void => {\n if (node.value) node.value.style.transform = `translate3d(${value.x}px, ${value.y}px, 0)`\n }\n\n const onPointerdown = (event: PointerEvent): void => {\n stopMomentum?.()\n stopMomentum = null\n\n ;(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId)\n dragging.value = true\n emit('dragStart')\n\n const useMomentum = props.momentum ?? !props.snapBack\n const start = { x: event.clientX, y: event.clientY }\n const origin = { ...offset }\n // A short ring of recent samples, for a velocity estimate that isn't hostage to the last\n // event.\n const samples: Array<{ x: number; y: number; t: number }> = []\n\n const onMove = (moveEvent: PointerEvent): void => {\n const next = clamp({\n x: props.axis === 'y' ? origin.x : origin.x + (moveEvent.clientX - start.x),\n y: props.axis === 'x' ? origin.y : origin.y + (moveEvent.clientY - start.y),\n })\n offset = next\n write(next)\n\n samples.push({ x: next.x, y: next.y, t: performance.now() })\n if (samples.length > 5) samples.shift()\n }\n\n const onUp = (): void => {\n dragging.value = false\n window.removeEventListener('pointermove', onMove)\n window.removeEventListener('pointerup', onUp)\n window.removeEventListener('pointercancel', onUp)\n\n if (props.snapBack) {\n runAnimation(0, 1, {\n spring: springs.subtle,\n onUpdate: (t: number) => {\n const value = { x: offset.x * (1 - t), y: offset.y * (1 - t) }\n write(value)\n },\n onComplete: () => {\n offset = { x: 0, y: 0 }\n write(offset)\n emit('dragEnd', offset)\n },\n })\n return\n }\n\n if (useMomentum && samples.length >= 2) {\n const first = samples[0]!\n const last = samples[samples.length - 1]!\n const elapsed = Math.max(1, last.t - first.t)\n let velocity = {\n x: ((last.x - first.x) / elapsed) * 1000,\n y: ((last.y - first.y) / elapsed) * 1000,\n }\n\n const decay = 0.95\n const stop = getTicker().add(\n ({ delta }) => {\n // Exponential decay, frame-rate independent: raising the per-second factor to the\n // power of the frame time keeps the glide identical at 60 and 120 Hz.\n const factor = Math.pow(decay, delta * 60)\n velocity = { x: velocity.x * factor, y: velocity.y * factor }\n\n const next = clamp({\n x: offset.x + velocity.x * delta,\n y: offset.y + velocity.y * delta,\n })\n offset = next\n write(next)\n\n if (Math.hypot(velocity.x, velocity.y) < 8) {\n stop()\n stopMomentum = null\n emit('dragEnd', offset)\n }\n },\n { phase: 'write', name: 'Draggable' },\n )\n stopMomentum = stop\n return\n }\n\n emit('dragEnd', offset)\n }\n\n window.addEventListener('pointermove', onMove)\n window.addEventListener('pointerup', onUp)\n window.addEventListener('pointercancel', onUp)\n }\n\n return () => {\n const { class: attrClass, style: attrStyle, ...restAttrs } = attrs as Record<string, unknown>\n\n return h(\n 'div',\n {\n ref: node,\n class: cx(\n 'ansh-draggable',\n dragging.value && 'ansh-draggable--active',\n attrClass as string,\n ),\n style: [\n {\n touchAction: props.axis === 'x' ? 'pan-y' : props.axis === 'y' ? 'pan-x' : 'none',\n },\n attrStyle,\n ],\n onPointerdown,\n ...restAttrs,\n },\n slots.default?.(),\n )\n }\n },\n})\n"]}
@@ -114,7 +114,7 @@ function useRovingFocus(options) {
114
114
  if (nodes.length === 0) return;
115
115
  const horizontal = orientation === "horizontal" || orientation === "both";
116
116
  const vertical = orientation === "vertical" || orientation === "both";
117
- let next = active();
117
+ let next;
118
118
  switch (event.key) {
119
119
  case "ArrowRight":
120
120
  if (!horizontal) return;
@@ -154,5 +154,5 @@ exports.useAutoFocus = useAutoFocus;
154
154
  exports.useFocusRestore = useFocusRestore;
155
155
  exports.useFocusTrap = useFocusTrap;
156
156
  exports.useRovingFocus = useRovingFocus;
157
- //# sourceMappingURL=chunk-EISHOEB6.cjs.map
158
- //# sourceMappingURL=chunk-EISHOEB6.cjs.map
157
+ //# sourceMappingURL=chunk-MWGVDY6K.cjs.map
158
+ //# sourceMappingURL=chunk-MWGVDY6K.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/primitives/focus.ts"],"names":["watch","getCurrentScope","onScopeDispose"],"mappings":";;;;;AAgBA,IAAM,kBAAA,GAAqB;AAAA,EACzB,SAAA;AAAA,EACA,wBAAA;AAAA,EACA,4CAAA;AAAA,EACA,wBAAA;AAAA,EACA,0BAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AAAA,EACA,kDAAA;AAAA,EACA;AACF,CAAA,CAAE,KAAK,GAAG,CAAA;AAEV,SAAS,UAAU,OAAA,EAA+B;AAChD,EAAA,IAAI,OAAA,CAAQ,YAAA,CAAa,OAAO,CAAA,EAAG,OAAO,KAAA;AAC1C,EAAA,IAAI,OA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AA;AAE3D,IAAA,cAAA,CAAe,IAAI,CAAA;AACnB,IAAA,KAAA,CAAM,IAAI,GAAG,KAAA,EAAM;AAAA,EACrB,CAAA;AACF","file":"chunk-MWGVDY6K.cjs","sourcesContent":["import { type Ref, getCurrentScope, onScopeDispose, watch } from 'vue'\nimport { type ReadonlyRef } from './utils'\n\n/**\n * Focus management for overlay surfaces — the Vue counterpart of `@ansh-ui/react`'s `focus.ts`.\n *\n * Three separate concerns that are usually conflated:\n *\n * 1. **Finding what can be focused.** Harder than it looks — `disabled`, `hidden`, `inert`,\n * zero-size elements and negative tabindex all disqualify a node, and CSS-hidden ancestors\n * disqualify their whole subtree.\n * 2. **Trapping.** Tab must cycle within the surface. Required by WCAG 2.4.3 for modals.\n * 3. **Restoring.** Focus must return to the trigger on close, or a keyboard user is dumped at the\n * top of the document and has to navigate all the way back.\n */\n\nconst FOCUSABLE_SELECTOR = [\n 'a[href]',\n 'button:not([disabled])',\n 'input:not([disabled]):not([type=\"hidden\"])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n 'audio[controls]',\n 'video[controls]',\n '[contenteditable]:not([contenteditable=\"false\"])',\n '[tabindex]:not([tabindex=\"-1\"])',\n].join(',')\n\nfunction isVisible(element: HTMLElement): boolean {\n if (element.hasAttribute('inert')) return false\n if (element.offsetParent !== null) return true\n const rect = element.getBoundingClientRect()\n return rect.width > 0 || rect.height > 0\n}\n\n/** Every tabbable descendant, in tab order. */\nexport function getTabbable(container: HTMLElement | null | undefined): HTMLElement[] {\n if (!container) return []\n const nodes = Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR))\n return nodes.filter((node) => {\n if (node.getAttribute('aria-hidden') === 'true') return false\n if (node.closest('[inert]')) return false\n return isVisible(node)\n })\n}\n\n/**\n * Trap Tab within a container while `active`.\n *\n * Implemented on `keydown` at the container rather than with sentinel elements at either end. The\n * sentinel approach adds two focusable nodes to the accessibility tree that screen readers can land\n * on and announce as blank; intercepting the key does not.\n */\nexport function useFocusTrap(\n target: Ref<HTMLElement | null | undefined>,\n active: ReadonlyRef<boolean>,\n): void {\n let detach: (() => void) | null = null\n\n const attach = (): void => {\n const container = target.value\n if (!container || detach) return\n\n const onKeyDown = (event: KeyboardEvent): void => {\n if (event.key !== 'Tab') return\n\n const tabbable = getTabbable(container)\n if (tabbable.length === 0) {\n event.preventDefault()\n return\n }\n\n const first = tabbable[0]!\n const last = tabbable[tabbable.length - 1]!\n const activeElement = document.activeElement as HTMLElement | null\n\n if (event.shiftKey && (activeElement === first || activeElement === container)) {\n event.preventDefault()\n last.focus()\n } else if (!event.shiftKey && activeElement === last) {\n event.preventDefault()\n first.focus()\n }\n }\n\n container.addEventListener('keydown', onKeyDown)\n detach = () => {\n container.removeEventListener('keydown', onKeyDown)\n detach = null\n }\n }\n\n watch([active, target], () => (active.value ? attach() : detach?.()), {\n immediate: true,\n flush: 'post',\n })\n\n if (getCurrentScope()) onScopeDispose(() => detach?.())\n}\n\n/**\n * Restore focus to whatever was focused before `active` became true.\n *\n * The element is captured on activation, not on mount, because a component can be mounted long\n * before it opens.\n */\nexport function useFocusRestore(active: ReadonlyRef<boolean>): void {\n let previous: HTMLElement | null = null\n\n watch(\n active,\n (isActive) => {\n if (isActive) {\n previous = document.activeElement as HTMLElement | null\n return\n }\n // Guard against restoring to a node that has since been removed from the document —\n // focusing a detached element silently moves focus to `<body>`, losing the user's place.\n if (previous && previous.isConnected) previous.focus?.({ preventScroll: true })\n previous = null\n },\n { flush: 'post' },\n )\n}\n\n/**\n * Move focus into a surface when it opens.\n *\n * Prefers an explicitly marked element, then the first tabbable one, then the container itself. The\n * container fallback matters for a dialog whose only content is text: focus must land inside it so a\n * screen reader announces the dialog rather than continuing from the page behind.\n */\nexport function useAutoFocus(\n target: Ref<HTMLElement | null | undefined>,\n active: ReadonlyRef<boolean>,\n initialFocus?: Ref<HTMLElement | null | undefined>,\n): void {\n let frame: number | null = null\n\n watch(\n [active, target],\n () => {\n if (frame !== null) cancelAnimationFrame(frame)\n if (!active.value) return\n const container = target.value\n if (!container) return\n\n // After paint: the surface may still be animating in, and focusing a node with\n // `visibility: hidden` is a no-op that silently leaves focus on the body.\n frame = requestAnimationFrame(() => {\n frame = null\n const explicit = initialFocus?.value\n if (explicit?.isConnected) {\n explicit.focus({ preventScroll: true })\n return\n }\n const target2 = getTabbable(container)[0] ?? container\n target2.focus({ preventScroll: true })\n })\n },\n { immediate: true, flush: 'post' },\n )\n\n if (getCurrentScope()) {\n onScopeDispose(() => {\n if (frame !== null) cancelAnimationFrame(frame)\n })\n }\n}\n\n/**\n * Roving tabindex for a composite widget (toolbar, tab list, menu).\n *\n * The ARIA authoring practice: a composite has exactly **one** tab stop, and arrow keys move within\n * it. Returns a keydown handler to bind on the composite's container.\n */\nexport function useRovingFocus(options: {\n /** Items in DOM order. */\n items: Ref<Array<HTMLElement | null>>\n /** Index that currently owns the tab stop. */\n active: () => number\n onActiveChange: (index: number) => void\n orientation?: 'horizontal' | 'vertical' | 'both'\n loop?: boolean\n}): (event: KeyboardEvent) => void {\n const { items, active, onActiveChange, orientation = 'horizontal', loop = true } = options\n\n return (event: KeyboardEvent) => {\n const nodes = items.value.filter((item): item is HTMLElement => item !== null)\n if (nodes.length === 0) return\n\n const horizontal = orientation === 'horizontal' || orientation === 'both'\n const vertical = orientation === 'vertical' || orientation === 'both'\n\n let next: number\n switch (event.key) {\n case 'ArrowRight':\n if (!horizontal) return\n next = active() + 1\n break\n case 'ArrowLeft':\n if (!horizontal) return\n next = active() - 1\n break\n case 'ArrowDown':\n if (!vertical) return\n next = active() + 1\n break\n case 'ArrowUp':\n if (!vertical) return\n next = active() - 1\n break\n case 'Home':\n next = 0\n break\n case 'End':\n next = nodes.length - 1\n break\n default:\n return\n }\n\n event.preventDefault()\n\n if (next < 0) next = loop ? nodes.length - 1 : 0\n if (next >= nodes.length) next = loop ? 0 : nodes.length - 1\n\n onActiveChange(next)\n nodes[next]?.focus()\n }\n}\n"]}