@ansh-ui/react 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-RHTLNSVW.cjs → chunk-3SWO2M33.cjs} +7 -7
- package/dist/chunk-3SWO2M33.cjs.map +1 -0
- package/dist/{chunk-HO2YSF5O.js → chunk-742E5FQS.js} +3 -3
- package/dist/chunk-742E5FQS.js.map +1 -0
- package/dist/{chunk-EGG4CP7C.js → chunk-BQJ6H3HC.js} +3 -2
- package/dist/chunk-BQJ6H3HC.js.map +1 -0
- package/dist/{chunk-LDCZQP3R.js → chunk-CWYBOVCZ.js} +3 -3
- package/dist/{chunk-LDCZQP3R.js.map → chunk-CWYBOVCZ.js.map} +1 -1
- package/dist/{chunk-AVPEA5PB.cjs → chunk-IZ6T7LO3.cjs} +4 -4
- package/dist/{chunk-AVPEA5PB.cjs.map → chunk-IZ6T7LO3.cjs.map} +1 -1
- package/dist/{chunk-C32LKF23.cjs → chunk-KTLTYHAT.cjs} +3 -3
- package/dist/chunk-KTLTYHAT.cjs.map +1 -0
- package/dist/{chunk-IBXLC5IE.js → chunk-P5MRISBP.js} +19 -3
- package/dist/chunk-P5MRISBP.js.map +1 -0
- package/dist/{chunk-WGYNCSTP.cjs → chunk-PUW6BTPQ.cjs} +3 -2
- package/dist/chunk-PUW6BTPQ.cjs.map +1 -0
- package/dist/{chunk-T4AK2KLM.js → chunk-PVDQPVYF.js} +3 -3
- package/dist/{chunk-T4AK2KLM.js.map → chunk-PVDQPVYF.js.map} +1 -1
- package/dist/{chunk-6VRF7X5C.cjs → chunk-TEPQGFR4.cjs} +19 -2
- package/dist/chunk-TEPQGFR4.cjs.map +1 -0
- package/dist/{chunk-QO3E7TJS.js → chunk-WNWGYXJY.js} +4 -4
- package/dist/chunk-WNWGYXJY.js.map +1 -0
- package/dist/{chunk-C5JG6TMM.cjs → chunk-YACOHFYJ.cjs} +27 -27
- package/dist/{chunk-C5JG6TMM.cjs.map → chunk-YACOHFYJ.cjs.map} +1 -1
- package/dist/data.d.cts +2 -1
- package/dist/data.d.ts +2 -1
- package/dist/form.cjs +37 -37
- package/dist/form.d.cts +2 -1
- package/dist/form.d.ts +2 -1
- package/dist/form.js +2 -2
- package/dist/index.cjs +641 -110
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +220 -7
- package/dist/index.d.ts +220 -7
- package/dist/index.js +526 -11
- package/dist/index.js.map +1 -1
- package/dist/layout.cjs +13 -13
- package/dist/layout.d.cts +11 -2
- package/dist/layout.d.ts +11 -2
- package/dist/layout.js +1 -1
- package/dist/{motion-CQmCq6_k.d.ts → motion-DoT_sTl1.d.ts} +3 -2
- package/dist/{motion-CSX4g2N8.d.cts → motion-DsQPOsTT.d.cts} +3 -2
- package/dist/motion.cjs +19 -19
- package/dist/motion.d.cts +2 -2
- package/dist/motion.d.ts +2 -2
- package/dist/motion.js +2 -2
- package/dist/navigation.d.cts +3 -2
- package/dist/navigation.d.ts +3 -2
- package/dist/overlay.cjs +16 -16
- package/dist/overlay.d.cts +3 -2
- package/dist/overlay.d.ts +3 -2
- package/dist/overlay.js +2 -2
- package/dist/{position-DVScKcaa.d.cts → position-CW6cGpSF.d.cts} +2 -1
- package/dist/{position-DVScKcaa.d.ts → position-CW6cGpSF.d.ts} +2 -1
- package/dist/primitives.cjs +25 -21
- package/dist/primitives.d.cts +5 -4
- package/dist/primitives.d.ts +5 -4
- package/dist/primitives.js +2 -2
- package/dist/{sidebar-D-PafAXw.d.cts → sidebar-Dyt67t2z.d.cts} +2 -1
- package/dist/{sidebar-D-PafAXw.d.ts → sidebar-Dyt67t2z.d.ts} +2 -1
- package/dist/styles.css +464 -0
- package/dist/{use-observers-B9qtimrk.d.cts → use-observers-DvA7hSz4.d.cts} +10 -1
- package/dist/{use-observers-B9qtimrk.d.ts → use-observers-DvA7hSz4.d.ts} +10 -1
- package/package.json +3 -3
- package/dist/chunk-6VRF7X5C.cjs.map +0 -1
- package/dist/chunk-C32LKF23.cjs.map +0 -1
- package/dist/chunk-EGG4CP7C.js.map +0 -1
- package/dist/chunk-HO2YSF5O.js.map +0 -1
- package/dist/chunk-IBXLC5IE.js.map +0 -1
- package/dist/chunk-QO3E7TJS.js.map +0 -1
- package/dist/chunk-RHTLNSVW.cjs.map +0 -1
- package/dist/chunk-WGYNCSTP.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMergedRef } from './chunk-
|
|
1
|
+
import { useMergedRef } from './chunk-P5MRISBP.js';
|
|
2
2
|
import { cx } from './chunk-H34OXXJU.js';
|
|
3
3
|
import { createContext, forwardRef, useRef, useEffect, useMemo, useContext, useState, useLayoutEffect, useCallback, Children, isValidElement, cloneElement } from 'react';
|
|
4
4
|
import { mountBehaviour, magnetic, tilt, ripple, marquee, scrollReveal, parallax, resolvePalette, createGradient, prefersReducedMotion, resolveEasing, stagger, getTicker, observeIntersection, setReducedMotionMode, attachLifecycle, springs, animate } from '@ansh-ui/core';
|
|
@@ -695,5 +695,5 @@ function Draggable({
|
|
|
695
695
|
}
|
|
696
696
|
|
|
697
697
|
export { AnimatePresence, AnimatedText, Draggable, GradientText, MagneticButton, Marquee, Motion, MotionConfig, Parallax, Ripple, ScrollReveal, ThemeProvider, TiltCard, createBehaviourComponent, themeScript, useBehaviour, useMotionConfig, useTheme };
|
|
698
|
-
//# sourceMappingURL=chunk-
|
|
699
|
-
//# sourceMappingURL=chunk-
|
|
698
|
+
//# sourceMappingURL=chunk-PVDQPVYF.js.map
|
|
699
|
+
//# sourceMappingURL=chunk-PVDQPVYF.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/factory/create-behaviour-component.tsx","../src/components/interaction.tsx","../src/components/text.tsx","../src/components/providers.tsx","../src/components/motion.tsx"],"names":["Component","useEffect","jsx","useRef","getTicker","useMemo","useState","useLayoutEffect","currentKeys","prefersReducedMotion"],"mappings":";;;;;;;AAqEO,SAAS,wBAAA,CAId,U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AO,CAAA;AAAA,IAC/B,CAAA;AAEA,IAAA,MAAA,CAAO,gBAAA,CAAiB,eAAe,MAAM,CAAA;AAC7C,IAAA,MAAA,CAAO,gBAAA,CAAiB,aAAa,IAAI,CAAA;AACzC,IAAA,MAAA,CAAO,gBAAA,CAAiB,iBAAiB,IAAI,CAAA;AAAA,EAC/C,CAAA;AAEA,EAAA,uBACEF,GAAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA,EAAK,OAAA;AAAA,MACL,SAAA,EAAW,EAAA,CAAG,gBAAA,EAAkB,QAAA,IAAY,0BAA0B,SAAS,CAAA;AAAA,MAC/E,KAAA,EAAO,EAAE,WAAA,EAAa,IAAA,KAAS,GAAA,GAAM,OAAA,GAAU,IAAA,KAAS,GAAA,GAAM,OAAA,GAAU,MAAA,EAAQ,GAAG,KAAA,EAAM;AAAA,MACzF,aAAA;AAAA,MAEC;AAAA;AAAA,GACH;AAEJ","file":"chunk-T4AK2KLM.js","sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type CSSProperties,\n type ElementType,\n type ForwardRefExoticComponent,\n type ForwardedRef,\n type ReactNode,\n type RefAttributes,\n forwardRef,\n useEffect,\n useRef,\n} from 'react'\nimport {\n type BaseBehaviourOptions,\n type BehaviourDefinition,\n type BehaviourHandle,\n mountBehaviour,\n} from '@ansh-ui/core'\nimport { useMergedRef } from '../hooks/use-observers'\n\n/**\n * Turn a {@link BehaviourDefinition} into a React component.\n *\n * The DOM counterpart of {@link import('./create-effect-component').createEffectComponent}. The\n * difference in the API is deliberate and small: a behaviour component renders its children\n * *directly* rather than wrapping them in a positioned layer, because a behaviour manipulates the\n * host element itself and inserting a wrapper would break the author's layout.\n *\n * ```tsx\n * export const MagneticButton = createBehaviourComponent(magnetic, 'MagneticButton', 'button')\n * ```\n */\n\nexport interface BehaviourComponentBaseProps {\n as?: ElementType\n className?: string\n style?: React.CSSProperties\n children?: ReactNode\n}\n\nexport type BehaviourComponentProps<Options extends BaseBehaviourOptions> = Options &\n BehaviourComponentBaseProps &\n Omit<ComponentPropsWithoutRef<'div'>, keyof Options | 'style' | 'className' | 'children'> &\n /**\n * Attributes that only make sense on the elements `as` is actually used with.\n *\n * `as=\"a\"` without this is a type error on `href`, which makes the prop useless for the case it\n * exists for — turning a magnetic button into a link. Full polymorphic typing (`as` as a generic\n * that rewrites the whole prop set) is the textbook answer and it collapses inference for every\n * behaviour option in the intersection, producing error messages nobody can read. Naming the two\n * element types `as` is realistically pointed at is the trade that keeps both working.\n */\n Partial<Pick<ComponentPropsWithoutRef<'a'>, 'href' | 'target' | 'rel' | 'download'>> &\n Partial<Pick<ComponentPropsWithoutRef<'button'>, 'type' | 'disabled' | 'form' | 'name' | 'value'>>\n\n/** The type of a component produced by {@link createBehaviourComponent}. */\nexport type BehaviourComponent<\n Options extends BaseBehaviourOptions,\n El extends HTMLElement = HTMLElement,\n> = ForwardRefExoticComponent<BehaviourComponentProps<Options> & RefAttributes<El>>\n\n/** See the note on the equivalent type in `create-effect-component.tsx`. */\ntype LooseProps = Record<string, unknown> & {\n as?: ElementType\n className?: string\n style?: CSSProperties\n children?: ReactNode\n}\n\nexport function createBehaviourComponent<\n Options extends BaseBehaviourOptions,\n El extends HTMLElement = HTMLElement,\n>(\n definition: BehaviourDefinition<Options, El>,\n displayName?: string,\n defaultElement: ElementType = 'div',\n): BehaviourComponent<Options, El> {\n const optionKeys = new Set(Object.keys(definition.defaults))\n\n function Render(props: LooseProps, forwardedRef: ForwardedRef<El>) {\n const { as: Component = defaultElement, className, style, children, ...rest } = props\n\n const hostRef = useRef<El | null>(null)\n const handleRef = useRef<BehaviourHandle<Options> | null>(null)\n const mergedRef = useMergedRef<El>(hostRef, forwardedRef)\n\n const options: Record<string, unknown> = {}\n const domProps: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(rest)) {\n if (optionKeys.has(key)) options[key] = value\n else domProps[key] = value\n }\n\n const optionsKey = stableKey(options)\n const optionsRef = useRef(options)\n optionsRef.current = options\n\n useEffect(() => {\n const host = hostRef.current\n if (!host) return\n\n const handle = mountBehaviour(definition, host, optionsRef.current as Partial<Options>)\n handleRef.current = handle\n\n return () => {\n handle.destroy()\n handleRef.current = null\n }\n // Mount-only. Behaviours that restructure the DOM (marquee, split-text) must not be torn\n // down and rebuilt on an unrelated prop change — that would lose scroll position and\n // restart animations.\n }, [])\n\n useEffect(() => {\n handleRef.current?.update(optionsRef.current as Partial<Options>)\n }, [optionsKey])\n\n return (\n <Component ref={mergedRef} className={className} style={style} {...domProps}>\n {children}\n </Component>\n )\n }\n\n const Component = forwardRef(Render)\n Component.displayName = displayName ?? `Ansh(${definition.name})`\n\n return Component as unknown as BehaviourComponent<Options, El>\n}\n\n/** See the note on the identical helper in `create-effect-component.tsx`. */\nfunction stableKey(options: Record<string, unknown>): string {\n const keys = Object.keys(options).sort()\n const parts: string[] = []\n for (const key of keys) {\n const value = options[key]\n if (typeof value === 'function') parts.push(`${key}:fn`)\n else if (value === undefined) continue\n else parts.push(`${key}:${JSON.stringify(value)}`)\n }\n return parts.join('|')\n}\n\n/**\n * Attach a behaviour to an element you already have a ref to.\n *\n * The hook form, for when a component's own element must carry the behaviour rather than being\n * wrapped — which is most of the time when integrating with an existing design system.\n *\n * ```tsx\n * const ref = useRef<HTMLButtonElement>(null)\n * useBehaviour(ref, magnetic, { strength: 16 })\n * ```\n */\nexport function useBehaviour<Options extends BaseBehaviourOptions, El extends HTMLElement>(\n ref: React.RefObject<El | null>,\n definition: BehaviourDefinition<Options, El>,\n options?: Partial<Options>,\n): void {\n const handleRef = useRef<BehaviourHandle<Options> | null>(null)\n const optionsRef = useRef(options ?? {})\n optionsRef.current = options ?? {}\n\n const optionsKey = stableKey(optionsRef.current as Record<string, unknown>)\n\n useEffect(() => {\n const element = ref.current\n if (!element) return\n\n const handle = mountBehaviour(definition, element, optionsRef.current)\n handleRef.current = handle\n\n return () => {\n handle.destroy()\n handleRef.current = null\n }\n }, [definition, ref])\n\n useEffect(() => {\n handleRef.current?.update(optionsRef.current)\n }, [optionsKey])\n}\n","import { magnetic, marquee, parallax, ripple, scrollReveal, tilt } from '@ansh-ui/core'\nimport { createBehaviourComponent } from '../factory/create-behaviour-component'\n\n/**\n * DOM behaviour components.\n *\n * Unlike the canvas backgrounds these render their children directly — no wrapper, no positioned\n * layer — because a behaviour manipulates the host element and inserting a wrapper would break the\n * author's layout.\n */\n\n/**\n * An element that leans toward the pointer, spring-driven.\n *\n * Renders a `<button>` by default so it is keyboard-focusable and announced correctly. Pass\n * `as=\"a\"` or `as=\"div\"` when it isn't a button — but if it *acts* like a button, leave it.\n *\n * ```tsx\n * <MagneticButton strength={16} scale={1.04} onClick={submit}>\n * Get started\n * </MagneticButton>\n * ```\n */\nexport const MagneticButton = createBehaviourComponent(magnetic, 'MagneticButton', 'button')\n\n/**\n * A card that rotates in 3D toward the pointer, with a moving specular highlight.\n *\n * The `perspective()` is baked into the transform as its first function, so no parent wrapper is\n * needed — which is the usual reason tilt implementations come out looking sheared rather than 3D.\n */\nexport const TiltCard = createBehaviourComponent(tilt, 'TiltCard', 'div')\n\n/**\n * A wave that expands from the point of contact.\n *\n * Also fires on Enter and Space, so keyboard activation gets the same feedback as a click. The\n * ripple layer inherits the host's `border-radius`, so a pill button clips its ripple to a pill\n * with no extra configuration.\n */\nexport const Ripple = createBehaviourComponent(ripple, 'Ripple', 'div')\n\n/**\n * Seamless infinite scrolling content.\n *\n * Speed is in **pixels per second**, not a duration, so adding an item to a logo strip doesn't\n * change how fast it scrolls. Content is duplicated as many times as needed to cover the\n * container, and clones are `aria-hidden` so a screen reader reads the list once.\n *\n * ```tsx\n * <Marquee speed={40} fadeEdges={64} pauseOnHover>\n * {logos.map((logo) => <img key={logo.id} src={logo.src} alt={logo.name} />)}\n * </Marquee>\n * ```\n */\nexport const Marquee = createBehaviourComponent(marquee, 'Marquee', 'div')\n\n/**\n * Reveal content as it enters the viewport.\n *\n * The hidden starting state is applied **in JavaScript**, not CSS. If the script never runs, the\n * content is simply visible — degraded but readable. A CSS-hidden initial state means content that\n * is permanently invisible when JavaScript fails, which has shipped to production on a lot of\n * marketing sites.\n *\n * Pass `children=\".selector\"` to stagger descendants instead of revealing the host as one block.\n */\nexport const ScrollReveal = createBehaviourComponent(scrollReveal, 'ScrollReveal', 'div')\n\n/**\n * Move an element at a different rate from the scroll.\n *\n * All measurement happens in the ticker's `read` phase, so fifty parallax elements cost one layout\n * read per frame between them rather than one per scroll event each. Disabled outright under\n * `prefers-reduced-motion` — parallax is the canonical vestibular trigger, and a slow parallax is\n * still parallax.\n */\nexport const Parallax = createBehaviourComponent(parallax, 'Parallax', 'div')\n","import { type ElementType, useEffect, useLayoutEffect, useMemo, useRef } from 'react'\nimport {\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 * These are written by hand rather than generated from a behaviour, because text animation has one\n * requirement no generic factory can satisfy: **the accessible text must never be the animated\n * text.** Splitting a heading into per-character spans and animating them is fine visually and an\n * accessibility failure if the split structure is what a screen reader reads.\n *\n * The pattern used throughout: the real string lives in a visually-hidden element that remains the\n * accessible name, and the entire animated structure is `aria-hidden`. Assistive technology reads\n * \"Motion, refined.\"; the eye sees fifteen characters arriving in sequence.\n */\n\n/**\n * `useLayoutEffect` on the client, `useEffect` on the server.\n *\n * The distinction matters here specifically. `AnimatedText` renders its units *visible* so the\n * server HTML and the first client render agree — anything else is a hydration mismatch. The hidden\n * starting state is then applied by an effect. With `useEffect` that happens **after** the browser\n * paints, so there is a visible one-frame flash of the final text before it hides and animates in.\n * `useLayoutEffect` runs before paint, so the flash cannot occur.\n *\n * The plain `useEffect` fallback on the server exists only to silence React's warning; layout\n * effects never run during SSR anyway.\n */\nconst useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect\n\nconst VISUALLY_HIDDEN: React.CSSProperties = {\n position: 'absolute',\n width: 1,\n height: 1,\n padding: 0,\n margin: -1,\n overflow: 'hidden',\n clipPath: 'inset(50%)',\n whiteSpace: 'nowrap',\n borderWidth: 0,\n}\n\n// ---------------------------------------------------------------------------\n// GradientText\n// ---------------------------------------------------------------------------\n\nexport interface GradientTextProps {\n children: string\n /** Any number of colours, or a built-in palette name. */\n colors?: readonly string[] | Parameters<typeof resolvePalette>[0]\n /** Gradient angle in degrees. Default `100`. */\n angle?: number\n /** Seconds for one full cycle. `0` holds a static gradient. Default `0` (static). */\n duration?: number\n /** Interpolated stops handed to CSS. More is smoother. Default `16`. */\n stops?: number\n as?: ElementType\n className?: string\n style?: React.CSSProperties\n}\n\n/**\n * Text filled with a perceptual gradient.\n *\n * Uses `background-clip: text`, and the stops are generated through the OKLab interpolator rather\n * than handed to CSS as two endpoints. That is the whole point: a CSS\n * `linear-gradient(#0275f4, #9f0550)` passes through a desaturated grey-brown at its midpoint,\n * which on text — where the gradient crosses a narrow band — is exactly where the eye lands.\n *\n * Animation is a CSS `background-position` shift rather than a JS loop, because for a single\n * property with no interaction the browser's own compositor is strictly better than anything we\n * could do on the main thread.\n */\nexport function GradientText({\n children,\n colors,\n angle = 100,\n duration = 0,\n stops = 16,\n as: Component = 'span',\n className,\n style,\n}: GradientTextProps) {\n const gradientCss = useMemo(() => {\n const palette = resolvePalette(colors as never)\n // Duplicated so an animated background-position shift wraps seamlessly instead of jumping.\n const looped = duration > 0 ? [...palette, ...palette] : palette\n return createGradient(looped, { space: 'oklab' }).toCss(`${angle}deg`, stops)\n }, [colors, angle, duration, stops])\n\n const animated = duration > 0 && !prefersReducedMotion()\n\n return (\n <Component\n className={className}\n style={{\n backgroundImage: gradientCss,\n backgroundSize: animated ? '200% 100%' : '100% 100%',\n backgroundClip: 'text',\n WebkitBackgroundClip: 'text',\n color: 'transparent',\n // A fallback for the rare engine without background-clip support: the first colour still\n // renders as solid text rather than the content vanishing entirely.\n WebkitTextFillColor: 'transparent',\n display: 'inline-block',\n ...(animated\n ? {\n animation: `ansh-gradient-shift ${duration}s linear infinite`,\n }\n : {}),\n ...style,\n }}\n >\n {children}\n {animated ? <GradientKeyframes /> : null}\n </Component>\n )\n}\n\n/**\n * The keyframes for {@link GradientText}.\n *\n * Injected as a `<style>` element rather than requiring a stylesheet import, so\n * `<GradientText duration={6} />` works with no setup. The rule is idempotent — several instances\n * emit identical CSS and the browser deduplicates it.\n */\nfunction GradientKeyframes() {\n return (\n <style\n dangerouslySetInnerHTML={{\n __html:\n '@keyframes ansh-gradient-shift{from{background-position:0% 50%}to{background-position:200% 50%}}',\n }}\n />\n )\n}\n\n// ---------------------------------------------------------------------------\n// AnimatedText\n// ---------------------------------------------------------------------------\n\nexport interface AnimatedTextProps {\n children: string\n /** Split granularity. Default `'chars'`. */\n by?: 'chars' | 'words'\n /** Seconds per unit's animation. Default `0.6`. */\n duration?: number\n /** Seconds between units. Default `0.03`. */\n each?: number\n /** Where the reveal wave begins. Default `'first'`. */\n from?: StaggerFrom\n easing?: EasingInput\n /** Distance each unit travels into place, in pixels. Default `18`. */\n distance?: number\n /** Starting blur in pixels — the \"focus in\" look. Default `0`. */\n blur?: number\n /** Starting rotation in degrees. Default `0`. */\n rotate?: number\n /** Clip each unit so it rises from behind a mask. Default `false`. */\n mask?: boolean\n /** Wait until scrolled into view. Default `true`. */\n whenInView?: boolean\n /** Replay every time it re-enters the viewport. Default `false`. */\n repeat?: boolean\n /** Seconds to wait before starting. Default `0`. */\n delay?: number\n as?: ElementType\n className?: string\n style?: React.CSSProperties\n onComplete?: () => void\n}\n\ninterface Unit {\n text: string\n /** `true` for whitespace, which 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 in React (so the markup is server-rendered and present in the HTML source for\n * SEO and for no-JS readers) while the animation runs on the shared ticker (so a page full of these\n * shares one clock and cannot drift).\n *\n * Under `prefers-reduced-motion` the text renders in its final state immediately — no hidden\n * frame, no fade.\n */\nexport function AnimatedText({\n children,\n by = 'chars',\n duration = 0.6,\n each = 0.03,\n from = 'first',\n easing = 'cinematic',\n distance = 18,\n blur = 0,\n rotate = 0,\n mask = false,\n whenInView = true,\n repeat = false,\n delay = 0,\n as: Component = 'span',\n className,\n style,\n onComplete,\n}: AnimatedTextProps) {\n const hostRef = useRef<HTMLElement | null>(null)\n const unitRefs = useRef<(HTMLSpanElement | null)[]>([])\n const onCompleteRef = useRef(onComplete)\n onCompleteRef.current = onComplete\n\n /**\n * Split into units.\n *\n * Grapheme-aware via `Intl.Segmenter`: `[...string]` splits by code point, which breaks emoji\n * with modifiers and combining accents into multiple \"characters\".\n */\n const units = useMemo<Unit[]>(() => {\n if (by === 'words') {\n return children\n .split(/(\\s+)/)\n .filter((token) => token.length > 0)\n .map((token) => ({ text: token, space: /^\\s+$/.test(token) }))\n }\n\n const graphemes =\n typeof Intl !== 'undefined' && 'Segmenter' in Intl\n ? Array.from(\n new Intl.Segmenter(undefined, { granularity: 'grapheme' }).segment(children),\n (s) => s.segment,\n )\n : Array.from(children)\n\n return graphemes.map((character) => ({ text: character, space: /^\\s$/.test(character) }))\n }, [children, by])\n\n const animatedCount = useMemo(() => units.filter((u) => !u.space).length, [units])\n\n useIsomorphicLayoutEffect(() => {\n const host = hostRef.current\n if (!host) return\n\n // Reduced motion: leave everything at its final state. The units are rendered without inline\n // styles below when this is true, so there is nothing to undo.\n if (prefersReducedMotion()) {\n onCompleteRef.current?.()\n return\n }\n\n const ease = resolveEasing(easing)\n const delayFor = stagger(animatedCount, { each, from })\n const ticker = getTicker()\n\n // Map each rendered unit to its animation index, skipping whitespace so the stagger counts\n // visible characters rather than including gaps.\n const targets: { node: HTMLSpanElement; delay: number }[] = []\n let animationIndex = 0\n units.forEach((unit, i) => {\n if (unit.space) return\n const node = unitRefs.current[i]\n if (node) targets.push({ node, delay: delay + delayFor(animationIndex) })\n animationIndex++\n })\n\n const apply = (node: HTMLSpanElement, progress: number): void => {\n const eased = ease(progress)\n const inverse = 1 - eased\n node.style.opacity = String(eased)\n const parts = [`translate3d(0, ${(distance * inverse).toFixed(2)}px, 0)`]\n if (rotate !== 0) parts.push(`rotate(${(rotate * inverse).toFixed(2)}deg)`)\n node.style.transform = parts.join(' ')\n if (blur > 0) {\n const amount = blur * inverse\n node.style.filter = amount > 0.05 ? `blur(${amount.toFixed(2)}px)` : ''\n }\n }\n\n const reset = (): void => {\n for (const { node } of targets) apply(node, 0)\n }\n\n const settle = (node: HTMLSpanElement): void => {\n node.style.opacity = ''\n node.style.transform = ''\n node.style.filter = ''\n // Drop the compositor promotion once at rest.\n node.style.willChange = ''\n }\n\n let elapsed = 0\n let running = false\n let stopTicker: (() => void) | null = null\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 = ticker.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 = duration <= 0 ? 1 : local / 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 onCompleteRef.current?.()\n }\n },\n { phase: 'write', name: 'AnimatedText' },\n )\n }\n\n if (!whenInView) {\n // Hide immediately so there is no flash of final state before the first frame.\n reset()\n start()\n return () => {\n stopTicker?.()\n for (const { node } of targets) settle(node)\n }\n }\n\n reset()\n\n const stopObserver = observeIntersection(\n host,\n (entry) => {\n if (entry.isIntersecting) {\n start()\n } else if (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 return () => {\n stopObserver()\n stopTicker?.()\n for (const { node } of targets) settle(node)\n }\n }, [\n units,\n animatedCount,\n duration,\n each,\n from,\n easing,\n distance,\n blur,\n rotate,\n whenInView,\n repeat,\n delay,\n ])\n\n return (\n <Component ref={hostRef} className={className} style={{ display: 'inline-block', ...style }}>\n {/* The accessible representation: the real string, unfragmented. */}\n <span style={VISUALLY_HIDDEN}>{children}</span>\n\n <span aria-hidden=\"true\">\n {units.map((unit, i) =>\n unit.space ? (\n // Whitespace as a plain text node so it collapses and wraps like real text.\n <span key={i}>{unit.text}</span>\n ) : mask ? (\n <span\n key={i}\n style={{ display: 'inline-block', overflow: 'hidden', verticalAlign: 'top' }}\n >\n <span\n ref={(node) => {\n unitRefs.current[i] = node\n }}\n style={{ display: 'inline-block' }}\n >\n {unit.text}\n </span>\n </span>\n ) : (\n <span\n key={i}\n ref={(node) => {\n unitRefs.current[i] = node\n }}\n style={{ display: 'inline-block' }}\n >\n {unit.text}\n </span>\n ),\n )}\n </span>\n </Component>\n )\n}\n","import { type ReactNode, createContext, useContext, useEffect, useMemo, useState } from 'react'\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// 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 MotionConfigContext = createContext<MotionConfigValue>({\n reducedMotion: 'auto',\n timeScale: 1,\n quality: null,\n})\n\nexport interface MotionConfigProps extends Partial<MotionConfigValue> {\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?: boolean\n /** Also pause when the window loses focus. Default `false` — a visible unfocused window still\n * expects to animate. */\n pauseWhenBlurred?: boolean\n /** Reduce quality on low battery where the platform exposes it. Default `true`. */\n respectBattery?: boolean\n children?: ReactNode\n}\n\n/**\n * Application-level motion configuration.\n *\n * Optional — every component works without it. Mount it once at the root when you need\n * app-wide control:\n *\n * ```tsx\n * <MotionConfig reducedMotion={userPrefersCalm ? 'always' : 'auto'}>\n * <App />\n * </MotionConfig>\n * ```\n *\n * `reducedMotion=\"always\"` is genuinely useful in production, as the backing for an in-app\n * \"reduce motion\" setting — many users who want calmer interfaces have never found the OS toggle.\n */\nexport function MotionConfig({\n reducedMotion = 'auto',\n timeScale = 1,\n quality = null,\n pauseWhenHidden = true,\n pauseWhenBlurred = false,\n respectBattery = true,\n children,\n}: MotionConfigProps) {\n useEffect(() => {\n setReducedMotionMode(reducedMotion)\n }, [reducedMotion])\n\n useEffect(() => {\n getTicker().timeScale = timeScale\n }, [timeScale])\n\n useEffect(() => {\n if (quality !== null) getTicker().lockQuality(quality)\n }, [quality])\n\n useEffect(\n () =>\n attachLifecycle(getTicker(), {\n pauseWhenHidden,\n pauseWhenBlurred,\n respectBattery,\n }),\n [pauseWhenHidden, pauseWhenBlurred, respectBattery],\n )\n\n const value = useMemo(\n () => ({ reducedMotion, timeScale, quality }),\n [reducedMotion, timeScale, quality],\n )\n\n return <MotionConfigContext.Provider value={value}>{children}</MotionConfigContext.Provider>\n}\n\n/** Read the nearest {@link MotionConfig}. Returns sensible defaults with no provider present. */\nexport function useMotionConfig(): MotionConfigValue {\n return useContext(MotionConfigContext)\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 ThemeContext = createContext<ThemeContextValue>({\n theme: 'system',\n resolved: 'light',\n setTheme: () => {},\n})\n\nexport interface ThemeProviderProps {\n /** Initial setting. Default `'system'`. */\n defaultTheme?: ThemeSetting\n /** Persist the choice under this `localStorage` key. Pass `null` to disable. Default `'ansh-theme'`. */\n storageKey?: string | null\n children?: ReactNode\n}\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 render would be a\n * hydration mismatch, since the server has no access to it. The stored value is applied in an\n * effect. To avoid a flash of the wrong theme, ship the small inline script from\n * {@link themeScript} in your document `<head>` — that is the only way to set the attribute before\n * first paint, and it is what every correct implementation does.\n */\nexport function ThemeProvider({\n defaultTheme = 'system',\n storageKey = 'ansh-theme',\n children,\n}: ThemeProviderProps) {\n const [theme, setThemeState] = useState<ThemeSetting>(defaultTheme)\n const [resolved, setResolved] = useState<'light' | 'dark'>('light')\n\n // Read the stored preference after mount, never during render.\n useEffect(() => {\n if (!storageKey) return\n try {\n const stored = localStorage.getItem(storageKey)\n if (stored === 'light' || stored === 'dark' || stored === 'system') {\n setThemeState(stored)\n }\n } catch {\n // Storage can throw in private browsing or with cookies disabled. A theme preference is\n // not worth breaking the page over.\n }\n }, [storageKey])\n\n useEffect(() => {\n applyTheme(theme)\n setResolved(resolveTheme())\n\n if (storageKey) {\n try {\n localStorage.setItem(storageKey, theme)\n } catch {\n // As above.\n }\n }\n }, [theme, storageKey])\n\n // Follow the OS while set to `'system'`.\n useEffect(() => {\n if (theme !== 'system' || typeof matchMedia !== 'function') return\n const query = matchMedia('(prefers-color-scheme: dark)')\n const onChange = () => setResolved(query.matches ? 'dark' : 'light')\n query.addEventListener('change', onChange)\n return () => query.removeEventListener('change', onChange)\n }, [theme])\n\n const value = useMemo(() => ({ theme, resolved, setTheme: setThemeState }), [theme, resolved])\n\n return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>\n}\n\nexport function useTheme(): ThemeContextValue {\n return useContext(ThemeContext)\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 — which is the only point at which it can\n * be done without a visible flash. It is deliberately tiny and dependency-free.\n *\n * ```tsx\n * // Next.js app/layout.tsx\n * <head>\n * <script dangerouslySetInnerHTML={{ __html: themeScript() }} />\n * </head>\n * ```\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 {\n type CSSProperties,\n type ElementType,\n type ReactElement,\n type ReactNode,\n Children,\n cloneElement,\n isValidElement,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react'\nimport {\n type AnimationOptions,\n type EasingInput,\n type SpringOptions,\n animate,\n getTicker,\n prefersReducedMotion,\n springs,\n} from '@ansh-ui/core'\nimport { cx } from '../primitives/compose'\nimport { useMergedRef } from '../hooks/use-observers'\n\n/**\n * Declarative motion.\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. React never\n * re-renders during an animation.\n */\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\ntype MotionElementProps = {\n as?: ElementType\n /** Starting values. Applied before the first paint. */\n initial?: MotionValues\n /** Target values. Changing these animates to the new target. */\n animate?: MotionValues\n /** Values to animate to when removed by `AnimatePresence`. */\n exit?: MotionValues\n transition?: MotionTransition\n whileHover?: MotionValues\n whileTap?: MotionValues\n /** Animate to `animate` only once scrolled into view. */\n whileInView?: boolean\n /** Fraction visible before `whileInView` triggers. Default `0.2`. */\n inViewAmount?: number\n className?: string\n style?: CSSProperties\n children?: ReactNode\n}\n\nconst DEFAULTS: Required<Omit<MotionValues, never>> = {\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. */\nfunction 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\nfunction resolve(\n values: MotionValues | undefined,\n base: Required<MotionValues>,\n): Required<MotionValues> {\n return { ...base, ...values }\n}\n\n/**\n * An animated element.\n *\n * ```tsx\n * <Motion initial={{ opacity: 0, y: 24 }} animate={{ opacity: 1, y: 0 }} whileInView>\n * <Card />\n * </Motion>\n * ```\n */\nexport function Motion({\n as: Component = 'div',\n initial,\n animate: target,\n // Destructured but unused here: `AnimatePresence` reads `exit` off the element's props when the\n // child is removed and swaps it into `animate`. Pulling it out of `rest` stops it reaching the\n // DOM as an unknown attribute.\n exit: _exit,\n transition,\n whileHover,\n whileTap,\n whileInView = false,\n inViewAmount = 0.2,\n className,\n style,\n children,\n ...rest\n}: MotionElementProps & Record<string, unknown>) {\n const nodeRef = useRef<HTMLElement | null>(null)\n const currentRef = useRef<Required<MotionValues>>(resolve(initial, DEFAULTS))\n const controlsRef = useRef<ReturnType<typeof animate> | null>(null)\n const [inView, setInView] = useState(!whileInView)\n\n // Applied before paint, not in an effect. `useEffect` runs after the browser has already painted\n // the element at its natural position, so an element that should fade in flashes at full opacity\n // for one frame first.\n useLayoutEffect(() => {\n if (nodeRef.current) applyValues(nodeRef.current, currentRef.current)\n }, [])\n\n const runTo = useCallback(\n (next: Required<MotionValues>, options?: MotionTransition) => {\n const node = nodeRef.current\n if (!node) return\n\n controlsRef.current?.stop()\n\n const from = { ...currentRef.current }\n const springOption = options?.spring ?? transition?.spring\n\n const animationOptions: AnimationOptions<number> = {\n ...((options?.delay ?? transition?.delay !== undefined)\n ? { delay: options?.delay ?? 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 ?? transition?.duration ?? 0.4,\n ...((options?.easing ?? transition?.easing)\n ? { easing: (options?.easing ?? transition?.easing)! }\n : null),\n }),\n onUpdate: (t) => {\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 currentRef.current = frame\n applyValues(node, frame)\n },\n onComplete: () => {\n currentRef.current = next\n applyValues(node, next)\n },\n }\n\n controlsRef.current = animate(0, 1, animationOptions)\n },\n [transition],\n )\n\n // Animate to the target whenever it changes (or when it scrolls into view).\n const targetKey = JSON.stringify(target ?? null)\n useEffect(() => {\n if (!inView) return\n runTo(resolve(target, DEFAULTS))\n // `targetKey` stands in for `target`, which is nearly always an inline object literal whose\n // identity changes on every render.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [targetKey, inView, runTo])\n\n useEffect(() => {\n if (!whileInView) return\n const node = nodeRef.current\n if (!node || typeof IntersectionObserver === 'undefined') {\n setInView(true)\n return\n }\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry?.isIntersecting) {\n setInView(true)\n observer.disconnect()\n }\n },\n { threshold: inViewAmount },\n )\n observer.observe(node)\n return () => observer.disconnect()\n }, [whileInView, inViewAmount])\n\n useEffect(() => () => controlsRef.current?.stop(), [])\n\n const interaction: Record<string, unknown> = {}\n if (whileHover) {\n interaction.onMouseEnter = () => runTo(resolve({ ...target, ...whileHover }, DEFAULTS))\n interaction.onMouseLeave = () => runTo(resolve(target, DEFAULTS))\n }\n if (whileTap) {\n interaction.onPointerDown = () =>\n runTo(resolve({ ...target, ...whileTap }, DEFAULTS), { duration: 0.12 })\n interaction.onPointerUp = () => runTo(resolve({ ...target, ...whileHover }, DEFAULTS))\n }\n\n return (\n <Component\n ref={nodeRef}\n className={className}\n // `will-change` is set once, statically. Toggling it per animation causes the compositor to\n // create and destroy a layer on every interaction, which is more expensive than the hint saves.\n style={{ willChange: 'transform, opacity', ...style }}\n {...interaction}\n {...rest}\n >\n {children}\n </Component>\n )\n}\n\nexport interface AnimatePresenceProps {\n children: ReactNode\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 * React unmounts immediately when a child disappears from the tree, so an exit animation never gets\n * a chance to run. This holds departing children in its own state, plays their `exit` values, then\n * drops them.\n *\n * Children **must** have stable `key`s — that is how removals are detected at all. Without keys,\n * React reuses element positions and this sees no removal to animate.\n */\nexport function AnimatePresence({ children, exitDuration = 0.35 }: AnimatePresenceProps) {\n const currentChildren = Children.toArray(children).filter(isValidElement) as ReactElement[]\n const [rendered, setRendered] = useState<ReactElement[]>(currentChildren)\n const timersRef = useRef(new Map<string, ReturnType<typeof setTimeout>>())\n\n const keys = currentChildren.map((child) => String(child.key))\n const keysSignature = keys.join('|')\n\n useEffect(() => {\n const currentKeys = new Set(keys)\n const departing = rendered.filter((child) => !currentKeys.has(String(child.key)))\n\n if (departing.length === 0) {\n // Straight replacement keeps updated props flowing to children that are still present.\n setRendered(currentChildren)\n return\n }\n\n // Keep the departing children in place, appended after the current set so they don't reorder\n // the survivors while they animate out.\n setRendered([...currentChildren, ...departing])\n\n const delay = prefersReducedMotion() ? 0 : exitDuration * 1000\n for (const child of departing) {\n const key = String(child.key)\n clearTimeout(timersRef.current.get(key))\n timersRef.current.set(\n key,\n setTimeout(() => {\n setRendered((previous) => previous.filter((entry) => String(entry.key) !== key))\n timersRef.current.delete(key)\n }, delay),\n )\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [keysSignature, exitDuration])\n\n useEffect(() => {\n const timers = timersRef.current\n return () => {\n for (const timer of timers.values()) clearTimeout(timer)\n timers.clear()\n }\n }, [])\n\n const currentKeys = new Set(keys)\n\n return (\n <>\n {rendered.map((child) => {\n const leaving = !currentKeys.has(String(child.key))\n if (!leaving) return child\n\n // A departing child animates to its `exit` values by having them swapped into `animate`.\n const props = child.props as MotionElementProps\n return cloneElement(child as ReactElement<MotionElementProps>, {\n animate: props.exit ?? { opacity: 0, scale: 0.96 },\n transition: { duration: exitDuration, ...props.transition },\n })\n })}\n </>\n )\n}\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 onDragStart?: () => void\n onDragEnd?: (offset: { x: number; y: number }) => void\n className?: string\n style?: CSSProperties\n children: ReactNode\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 */\nexport function Draggable({\n axis = 'both',\n bounds,\n snapBack = false,\n momentum,\n onDragStart,\n onDragEnd,\n className,\n style,\n children,\n}: DraggableProps) {\n const nodeRef = useRef<HTMLDivElement | null>(null)\n const offsetRef = useRef({ x: 0, y: 0 })\n const [dragging, setDragging] = useState(false)\n\n const useMomentum = momentum ?? !snapBack\n\n const clamp = useCallback(\n (value: { x: number; y: number }) => ({\n x: Math.min(Math.max(value.x, bounds?.left ?? -Infinity), bounds?.right ?? Infinity),\n y: Math.min(Math.max(value.y, bounds?.top ?? -Infinity), bounds?.bottom ?? Infinity),\n }),\n [bounds],\n )\n\n const write = (value: { x: number; y: number }) => {\n if (nodeRef.current) {\n nodeRef.current.style.transform = `translate3d(${value.x}px, ${value.y}px, 0)`\n }\n }\n\n const onPointerDown = (event: React.PointerEvent<HTMLDivElement>) => {\n event.currentTarget.setPointerCapture(event.pointerId)\n setDragging(true)\n onDragStart?.()\n\n const start = { x: event.clientX, y: event.clientY }\n const origin = { ...offsetRef.current }\n // A short ring of recent samples, for a velocity estimate that isn't hostage to the last event.\n const samples: Array<{ x: number; y: number; t: number }> = []\n\n const onMove = (moveEvent: PointerEvent) => {\n const next = clamp({\n x: axis === 'y' ? origin.x : origin.x + (moveEvent.clientX - start.x),\n y: axis === 'x' ? origin.y : origin.y + (moveEvent.clientY - start.y),\n })\n offsetRef.current = 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 = () => {\n setDragging(false)\n window.removeEventListener('pointermove', onMove)\n window.removeEventListener('pointerup', onUp)\n window.removeEventListener('pointercancel', onUp)\n\n if (snapBack) {\n animate(0, 1, {\n spring: springs.subtle,\n onUpdate: (t) => {\n const value = { x: offsetRef.current.x * (1 - t), y: offsetRef.current.y * (1 - t) }\n write(value)\n },\n onComplete: () => {\n offsetRef.current = { x: 0, y: 0 }\n write(offsetRef.current)\n onDragEnd?.(offsetRef.current)\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: offsetRef.current.x + velocity.x * delta,\n y: offsetRef.current.y + velocity.y * delta,\n })\n offsetRef.current = next\n write(next)\n\n if (Math.hypot(velocity.x, velocity.y) < 8) {\n stop()\n onDragEnd?.(offsetRef.current)\n }\n },\n { phase: 'write', name: 'Draggable' },\n )\n return\n }\n\n onDragEnd?.(offsetRef.current)\n }\n\n window.addEventListener('pointermove', onMove)\n window.addEventListener('pointerup', onUp)\n window.addEventListener('pointercancel', onUp)\n }\n\n return (\n <div\n ref={nodeRef}\n className={cx('ansh-draggable', dragging && 'ansh-draggable--active', className)}\n style={{ touchAction: axis === 'x' ? 'pan-y' : axis === 'y' ? 'pan-x' : 'none', ...style }}\n onPointerDown={onPointerDown}\n >\n {children}\n </div>\n )\n}\n\n/** Merge a forwarded ref with the internal one, re-exported for consumers wrapping `Motion`. */\nexport { useMergedRef }\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/factory/create-behaviour-component.tsx","../src/components/interaction.tsx","../src/components/text.tsx","../src/components/providers.tsx","../src/components/motion.tsx"],"names":["Component","useEffect","jsx","useRef","getTicker","useMemo","useState","useLayoutEffect","currentKeys","prefersReducedMotion"],"mappings":";;;;;;;AAqEO,SAAS,wBAAA,CAId,UAAA,EACA,WAAA,EACA,cAAA,GAA8B,KAAA,EACG;A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,CAAO,gBAAA,CAAiB,eAAe,MAAM,CAAA;AAC7C,IAAA,MAAA,CAAO,gBAAA,CAAiB,aAAa,IAAI,CAAA;AACzC,IAAA,MAAA,CAAO,gBAAA,CAAiB,iBAAiB,IAAI,CAAA;AAAA,EAC/C,CAAA;AAEA,EAAA,uBACEF,GAAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA,EAAK,OAAA;AAAA,MACL,SAAA,EAAW,EAAA,CAAG,gBAAA,EAAkB,QAAA,IAAY,0BAA0B,SAAS,CAAA;AAAA,MAC/E,KAAA,EAAO,EAAE,WAAA,EAAa,IAAA,KAAS,GAAA,GAAM,OAAA,GAAU,IAAA,KAAS,GAAA,GAAM,OAAA,GAAU,MAAA,EAAQ,GAAG,KAAA,EAAM;AAAA,MACzF,aAAA;AAAA,MAEC;AAAA;AAAA,GACH;AAEJ","file":"chunk-PVDQPVYF.js","sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type CSSProperties,\n type ElementType,\n type ForwardRefExoticComponent,\n type ForwardedRef,\n type ReactNode,\n type RefAttributes,\n forwardRef,\n useEffect,\n useRef,\n} from 'react'\nimport {\n type BaseBehaviourOptions,\n type BehaviourDefinition,\n type BehaviourHandle,\n mountBehaviour,\n} from '@ansh-ui/core'\nimport { useMergedRef } from '../hooks/use-observers'\n\n/**\n * Turn a {@link BehaviourDefinition} into a React component.\n *\n * The DOM counterpart of {@link import('./create-effect-component').createEffectComponent}. The\n * difference in the API is deliberate and small: a behaviour component renders its children\n * *directly* rather than wrapping them in a positioned layer, because a behaviour manipulates the\n * host element itself and inserting a wrapper would break the author's layout.\n *\n * ```tsx\n * export const MagneticButton = createBehaviourComponent(magnetic, 'MagneticButton', 'button')\n * ```\n */\n\nexport interface BehaviourComponentBaseProps {\n as?: ElementType\n className?: string\n style?: React.CSSProperties\n children?: ReactNode\n}\n\nexport type BehaviourComponentProps<Options extends BaseBehaviourOptions> = Options &\n BehaviourComponentBaseProps &\n Omit<ComponentPropsWithoutRef<'div'>, keyof Options | 'style' | 'className' | 'children'> &\n /**\n * Attributes that only make sense on the elements `as` is actually used with.\n *\n * `as=\"a\"` without this is a type error on `href`, which makes the prop useless for the case it\n * exists for — turning a magnetic button into a link. Full polymorphic typing (`as` as a generic\n * that rewrites the whole prop set) is the textbook answer and it collapses inference for every\n * behaviour option in the intersection, producing error messages nobody can read. Naming the two\n * element types `as` is realistically pointed at is the trade that keeps both working.\n */\n Partial<Pick<ComponentPropsWithoutRef<'a'>, 'href' | 'target' | 'rel' | 'download'>> &\n Partial<Pick<ComponentPropsWithoutRef<'button'>, 'type' | 'disabled' | 'form' | 'name' | 'value'>>\n\n/** The type of a component produced by {@link createBehaviourComponent}. */\nexport type BehaviourComponent<\n Options extends BaseBehaviourOptions,\n El extends HTMLElement = HTMLElement,\n> = ForwardRefExoticComponent<BehaviourComponentProps<Options> & RefAttributes<El>>\n\n/** See the note on the equivalent type in `create-effect-component.tsx`. */\ntype LooseProps = Record<string, unknown> & {\n as?: ElementType\n className?: string\n style?: CSSProperties\n children?: ReactNode\n}\n\nexport function createBehaviourComponent<\n Options extends BaseBehaviourOptions,\n El extends HTMLElement = HTMLElement,\n>(\n definition: BehaviourDefinition<Options, El>,\n displayName?: string,\n defaultElement: ElementType = 'div',\n): BehaviourComponent<Options, El> {\n const optionKeys = new Set(Object.keys(definition.defaults))\n\n function Render(props: LooseProps, forwardedRef: ForwardedRef<El>) {\n const { as: Component = defaultElement, className, style, children, ...rest } = props\n\n const hostRef = useRef<El | null>(null)\n const handleRef = useRef<BehaviourHandle<Options> | null>(null)\n const mergedRef = useMergedRef<El>(hostRef, forwardedRef)\n\n const options: Record<string, unknown> = {}\n const domProps: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(rest)) {\n if (optionKeys.has(key)) options[key] = value\n else domProps[key] = value\n }\n\n const optionsKey = stableKey(options)\n const optionsRef = useRef(options)\n optionsRef.current = options\n\n useEffect(() => {\n const host = hostRef.current\n if (!host) return\n\n const handle = mountBehaviour(definition, host, optionsRef.current as Partial<Options>)\n handleRef.current = handle\n\n return () => {\n handle.destroy()\n handleRef.current = null\n }\n // Mount-only. Behaviours that restructure the DOM (marquee, split-text) must not be torn\n // down and rebuilt on an unrelated prop change — that would lose scroll position and\n // restart animations.\n }, [])\n\n useEffect(() => {\n handleRef.current?.update(optionsRef.current as Partial<Options>)\n }, [optionsKey])\n\n return (\n <Component ref={mergedRef} className={className} style={style} {...domProps}>\n {children}\n </Component>\n )\n }\n\n const Component = forwardRef(Render)\n Component.displayName = displayName ?? `Ansh(${definition.name})`\n\n return Component as unknown as BehaviourComponent<Options, El>\n}\n\n/** See the note on the identical helper in `create-effect-component.tsx`. */\nfunction stableKey(options: Record<string, unknown>): string {\n const keys = Object.keys(options).sort()\n const parts: string[] = []\n for (const key of keys) {\n const value = options[key]\n if (typeof value === 'function') parts.push(`${key}:fn`)\n else if (value === undefined) continue\n else parts.push(`${key}:${JSON.stringify(value)}`)\n }\n return parts.join('|')\n}\n\n/**\n * Attach a behaviour to an element you already have a ref to.\n *\n * The hook form, for when a component's own element must carry the behaviour rather than being\n * wrapped — which is most of the time when integrating with an existing design system.\n *\n * ```tsx\n * const ref = useRef<HTMLButtonElement>(null)\n * useBehaviour(ref, magnetic, { strength: 16 })\n * ```\n */\nexport function useBehaviour<Options extends BaseBehaviourOptions, El extends HTMLElement>(\n ref: React.RefObject<El | null>,\n definition: BehaviourDefinition<Options, El>,\n options?: Partial<Options>,\n): void {\n const handleRef = useRef<BehaviourHandle<Options> | null>(null)\n const optionsRef = useRef(options ?? {})\n optionsRef.current = options ?? {}\n\n const optionsKey = stableKey(optionsRef.current as Record<string, unknown>)\n\n useEffect(() => {\n const element = ref.current\n if (!element) return\n\n const handle = mountBehaviour(definition, element, optionsRef.current)\n handleRef.current = handle\n\n return () => {\n handle.destroy()\n handleRef.current = null\n }\n }, [definition, ref])\n\n useEffect(() => {\n handleRef.current?.update(optionsRef.current)\n }, [optionsKey])\n}\n","import { magnetic, marquee, parallax, ripple, scrollReveal, tilt } from '@ansh-ui/core'\nimport { createBehaviourComponent } from '../factory/create-behaviour-component'\n\n/**\n * DOM behaviour components.\n *\n * Unlike the canvas backgrounds these render their children directly — no wrapper, no positioned\n * layer — because a behaviour manipulates the host element and inserting a wrapper would break the\n * author's layout.\n */\n\n/**\n * An element that leans toward the pointer, spring-driven.\n *\n * Renders a `<button>` by default so it is keyboard-focusable and announced correctly. Pass\n * `as=\"a\"` or `as=\"div\"` when it isn't a button — but if it *acts* like a button, leave it.\n *\n * ```tsx\n * <MagneticButton strength={16} scale={1.04} onClick={submit}>\n * Get started\n * </MagneticButton>\n * ```\n */\nexport const MagneticButton = createBehaviourComponent(magnetic, 'MagneticButton', 'button')\n\n/**\n * A card that rotates in 3D toward the pointer, with a moving specular highlight.\n *\n * The `perspective()` is baked into the transform as its first function, so no parent wrapper is\n * needed — which is the usual reason tilt implementations come out looking sheared rather than 3D.\n */\nexport const TiltCard = createBehaviourComponent(tilt, 'TiltCard', 'div')\n\n/**\n * A wave that expands from the point of contact.\n *\n * Also fires on Enter and Space, so keyboard activation gets the same feedback as a click. The\n * ripple layer inherits the host's `border-radius`, so a pill button clips its ripple to a pill\n * with no extra configuration.\n */\nexport const Ripple = createBehaviourComponent(ripple, 'Ripple', 'div')\n\n/**\n * Seamless infinite scrolling content.\n *\n * Speed is in **pixels per second**, not a duration, so adding an item to a logo strip doesn't\n * change how fast it scrolls. Content is duplicated as many times as needed to cover the\n * container, and clones are `aria-hidden` so a screen reader reads the list once.\n *\n * ```tsx\n * <Marquee speed={40} fadeEdges={64} pauseOnHover>\n * {logos.map((logo) => <img key={logo.id} src={logo.src} alt={logo.name} />)}\n * </Marquee>\n * ```\n */\nexport const Marquee = createBehaviourComponent(marquee, 'Marquee', 'div')\n\n/**\n * Reveal content as it enters the viewport.\n *\n * The hidden starting state is applied **in JavaScript**, not CSS. If the script never runs, the\n * content is simply visible — degraded but readable. A CSS-hidden initial state means content that\n * is permanently invisible when JavaScript fails, which has shipped to production on a lot of\n * marketing sites.\n *\n * Pass `children=\".selector\"` to stagger descendants instead of revealing the host as one block.\n */\nexport const ScrollReveal = createBehaviourComponent(scrollReveal, 'ScrollReveal', 'div')\n\n/**\n * Move an element at a different rate from the scroll.\n *\n * All measurement happens in the ticker's `read` phase, so fifty parallax elements cost one layout\n * read per frame between them rather than one per scroll event each. Disabled outright under\n * `prefers-reduced-motion` — parallax is the canonical vestibular trigger, and a slow parallax is\n * still parallax.\n */\nexport const Parallax = createBehaviourComponent(parallax, 'Parallax', 'div')\n","import { type ElementType, useEffect, useLayoutEffect, useMemo, useRef } from 'react'\nimport {\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 * These are written by hand rather than generated from a behaviour, because text animation has one\n * requirement no generic factory can satisfy: **the accessible text must never be the animated\n * text.** Splitting a heading into per-character spans and animating them is fine visually and an\n * accessibility failure if the split structure is what a screen reader reads.\n *\n * The pattern used throughout: the real string lives in a visually-hidden element that remains the\n * accessible name, and the entire animated structure is `aria-hidden`. Assistive technology reads\n * \"Motion, refined.\"; the eye sees fifteen characters arriving in sequence.\n */\n\n/**\n * `useLayoutEffect` on the client, `useEffect` on the server.\n *\n * The distinction matters here specifically. `AnimatedText` renders its units *visible* so the\n * server HTML and the first client render agree — anything else is a hydration mismatch. The hidden\n * starting state is then applied by an effect. With `useEffect` that happens **after** the browser\n * paints, so there is a visible one-frame flash of the final text before it hides and animates in.\n * `useLayoutEffect` runs before paint, so the flash cannot occur.\n *\n * The plain `useEffect` fallback on the server exists only to silence React's warning; layout\n * effects never run during SSR anyway.\n */\nconst useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect\n\nconst VISUALLY_HIDDEN: React.CSSProperties = {\n position: 'absolute',\n width: 1,\n height: 1,\n padding: 0,\n margin: -1,\n overflow: 'hidden',\n clipPath: 'inset(50%)',\n whiteSpace: 'nowrap',\n borderWidth: 0,\n}\n\n// ---------------------------------------------------------------------------\n// GradientText\n// ---------------------------------------------------------------------------\n\nexport interface GradientTextProps {\n children: string\n /** Any number of colours, or a built-in palette name. */\n colors?: readonly string[] | Parameters<typeof resolvePalette>[0]\n /** Gradient angle in degrees. Default `100`. */\n angle?: number\n /** Seconds for one full cycle. `0` holds a static gradient. Default `0` (static). */\n duration?: number\n /** Interpolated stops handed to CSS. More is smoother. Default `16`. */\n stops?: number\n as?: ElementType\n className?: string\n style?: React.CSSProperties\n}\n\n/**\n * Text filled with a perceptual gradient.\n *\n * Uses `background-clip: text`, and the stops are generated through the OKLab interpolator rather\n * than handed to CSS as two endpoints. That is the whole point: a CSS\n * `linear-gradient(#0275f4, #9f0550)` passes through a desaturated grey-brown at its midpoint,\n * which on text — where the gradient crosses a narrow band — is exactly where the eye lands.\n *\n * Animation is a CSS `background-position` shift rather than a JS loop, because for a single\n * property with no interaction the browser's own compositor is strictly better than anything we\n * could do on the main thread.\n */\nexport function GradientText({\n children,\n colors,\n angle = 100,\n duration = 0,\n stops = 16,\n as: Component = 'span',\n className,\n style,\n}: GradientTextProps) {\n const gradientCss = useMemo(() => {\n const palette = resolvePalette(colors as never)\n // Duplicated so an animated background-position shift wraps seamlessly instead of jumping.\n const looped = duration > 0 ? [...palette, ...palette] : palette\n return createGradient(looped, { space: 'oklab' }).toCss(`${angle}deg`, stops)\n }, [colors, angle, duration, stops])\n\n const animated = duration > 0 && !prefersReducedMotion()\n\n return (\n <Component\n className={className}\n style={{\n backgroundImage: gradientCss,\n backgroundSize: animated ? '200% 100%' : '100% 100%',\n backgroundClip: 'text',\n WebkitBackgroundClip: 'text',\n color: 'transparent',\n // A fallback for the rare engine without background-clip support: the first colour still\n // renders as solid text rather than the content vanishing entirely.\n WebkitTextFillColor: 'transparent',\n display: 'inline-block',\n ...(animated\n ? {\n animation: `ansh-gradient-shift ${duration}s linear infinite`,\n }\n : {}),\n ...style,\n }}\n >\n {children}\n {animated ? <GradientKeyframes /> : null}\n </Component>\n )\n}\n\n/**\n * The keyframes for {@link GradientText}.\n *\n * Injected as a `<style>` element rather than requiring a stylesheet import, so\n * `<GradientText duration={6} />` works with no setup. The rule is idempotent — several instances\n * emit identical CSS and the browser deduplicates it.\n */\nfunction GradientKeyframes() {\n return (\n <style\n dangerouslySetInnerHTML={{\n __html:\n '@keyframes ansh-gradient-shift{from{background-position:0% 50%}to{background-position:200% 50%}}',\n }}\n />\n )\n}\n\n// ---------------------------------------------------------------------------\n// AnimatedText\n// ---------------------------------------------------------------------------\n\nexport interface AnimatedTextProps {\n children: string\n /** Split granularity. Default `'chars'`. */\n by?: 'chars' | 'words'\n /** Seconds per unit's animation. Default `0.6`. */\n duration?: number\n /** Seconds between units. Default `0.03`. */\n each?: number\n /** Where the reveal wave begins. Default `'first'`. */\n from?: StaggerFrom\n easing?: EasingInput\n /** Distance each unit travels into place, in pixels. Default `18`. */\n distance?: number\n /** Starting blur in pixels — the \"focus in\" look. Default `0`. */\n blur?: number\n /** Starting rotation in degrees. Default `0`. */\n rotate?: number\n /** Clip each unit so it rises from behind a mask. Default `false`. */\n mask?: boolean\n /** Wait until scrolled into view. Default `true`. */\n whenInView?: boolean\n /** Replay every time it re-enters the viewport. Default `false`. */\n repeat?: boolean\n /** Seconds to wait before starting. Default `0`. */\n delay?: number\n as?: ElementType\n className?: string\n style?: React.CSSProperties\n onComplete?: () => void\n}\n\ninterface Unit {\n text: string\n /** `true` for whitespace, which 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 in React (so the markup is server-rendered and present in the HTML source for\n * SEO and for no-JS readers) while the animation runs on the shared ticker (so a page full of these\n * shares one clock and cannot drift).\n *\n * Under `prefers-reduced-motion` the text renders in its final state immediately — no hidden\n * frame, no fade.\n */\nexport function AnimatedText({\n children,\n by = 'chars',\n duration = 0.6,\n each = 0.03,\n from = 'first',\n easing = 'cinematic',\n distance = 18,\n blur = 0,\n rotate = 0,\n mask = false,\n whenInView = true,\n repeat = false,\n delay = 0,\n as: Component = 'span',\n className,\n style,\n onComplete,\n}: AnimatedTextProps) {\n const hostRef = useRef<HTMLElement | null>(null)\n const unitRefs = useRef<(HTMLSpanElement | null)[]>([])\n const onCompleteRef = useRef(onComplete)\n onCompleteRef.current = onComplete\n\n /**\n * Split into units.\n *\n * Grapheme-aware via `Intl.Segmenter`: `[...string]` splits by code point, which breaks emoji\n * with modifiers and combining accents into multiple \"characters\".\n */\n const units = useMemo<Unit[]>(() => {\n if (by === 'words') {\n return children\n .split(/(\\s+)/)\n .filter((token) => token.length > 0)\n .map((token) => ({ text: token, space: /^\\s+$/.test(token) }))\n }\n\n const graphemes =\n typeof Intl !== 'undefined' && 'Segmenter' in Intl\n ? Array.from(\n new Intl.Segmenter(undefined, { granularity: 'grapheme' }).segment(children),\n (s) => s.segment,\n )\n : Array.from(children)\n\n return graphemes.map((character) => ({ text: character, space: /^\\s$/.test(character) }))\n }, [children, by])\n\n const animatedCount = useMemo(() => units.filter((u) => !u.space).length, [units])\n\n useIsomorphicLayoutEffect(() => {\n const host = hostRef.current\n if (!host) return\n\n // Reduced motion: leave everything at its final state. The units are rendered without inline\n // styles below when this is true, so there is nothing to undo.\n if (prefersReducedMotion()) {\n onCompleteRef.current?.()\n return\n }\n\n const ease = resolveEasing(easing)\n const delayFor = stagger(animatedCount, { each, from })\n const ticker = getTicker()\n\n // Map each rendered unit to its animation index, skipping whitespace so the stagger counts\n // visible characters rather than including gaps.\n const targets: { node: HTMLSpanElement; delay: number }[] = []\n let animationIndex = 0\n units.forEach((unit, i) => {\n if (unit.space) return\n const node = unitRefs.current[i]\n if (node) targets.push({ node, delay: delay + delayFor(animationIndex) })\n animationIndex++\n })\n\n const apply = (node: HTMLSpanElement, progress: number): void => {\n const eased = ease(progress)\n const inverse = 1 - eased\n node.style.opacity = String(eased)\n const parts = [`translate3d(0, ${(distance * inverse).toFixed(2)}px, 0)`]\n if (rotate !== 0) parts.push(`rotate(${(rotate * inverse).toFixed(2)}deg)`)\n node.style.transform = parts.join(' ')\n if (blur > 0) {\n const amount = blur * inverse\n node.style.filter = amount > 0.05 ? `blur(${amount.toFixed(2)}px)` : ''\n }\n }\n\n const reset = (): void => {\n for (const { node } of targets) apply(node, 0)\n }\n\n const settle = (node: HTMLSpanElement): void => {\n node.style.opacity = ''\n node.style.transform = ''\n node.style.filter = ''\n // Drop the compositor promotion once at rest.\n node.style.willChange = ''\n }\n\n let elapsed = 0\n let running = false\n let stopTicker: (() => void) | null = null\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 = ticker.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 = duration <= 0 ? 1 : local / 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 onCompleteRef.current?.()\n }\n },\n { phase: 'write', name: 'AnimatedText' },\n )\n }\n\n if (!whenInView) {\n // Hide immediately so there is no flash of final state before the first frame.\n reset()\n start()\n return () => {\n stopTicker?.()\n for (const { node } of targets) settle(node)\n }\n }\n\n reset()\n\n const stopObserver = observeIntersection(\n host,\n (entry) => {\n if (entry.isIntersecting) {\n start()\n } else if (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 return () => {\n stopObserver()\n stopTicker?.()\n for (const { node } of targets) settle(node)\n }\n }, [\n units,\n animatedCount,\n duration,\n each,\n from,\n easing,\n distance,\n blur,\n rotate,\n whenInView,\n repeat,\n delay,\n ])\n\n return (\n <Component ref={hostRef} className={className} style={{ display: 'inline-block', ...style }}>\n {/* The accessible representation: the real string, unfragmented. */}\n <span style={VISUALLY_HIDDEN}>{children}</span>\n\n <span aria-hidden=\"true\">\n {units.map((unit, i) =>\n unit.space ? (\n // Whitespace as a plain text node so it collapses and wraps like real text.\n <span key={i}>{unit.text}</span>\n ) : mask ? (\n <span\n key={i}\n style={{ display: 'inline-block', overflow: 'hidden', verticalAlign: 'top' }}\n >\n <span\n ref={(node) => {\n unitRefs.current[i] = node\n }}\n style={{ display: 'inline-block' }}\n >\n {unit.text}\n </span>\n </span>\n ) : (\n <span\n key={i}\n ref={(node) => {\n unitRefs.current[i] = node\n }}\n style={{ display: 'inline-block' }}\n >\n {unit.text}\n </span>\n ),\n )}\n </span>\n </Component>\n )\n}\n","import { type ReactNode, createContext, useContext, useEffect, useMemo, useState } from 'react'\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// 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 MotionConfigContext = createContext<MotionConfigValue>({\n reducedMotion: 'auto',\n timeScale: 1,\n quality: null,\n})\n\nexport interface MotionConfigProps extends Partial<MotionConfigValue> {\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?: boolean\n /** Also pause when the window loses focus. Default `false` — a visible unfocused window still\n * expects to animate. */\n pauseWhenBlurred?: boolean\n /** Reduce quality on low battery where the platform exposes it. Default `true`. */\n respectBattery?: boolean\n children?: ReactNode\n}\n\n/**\n * Application-level motion configuration.\n *\n * Optional — every component works without it. Mount it once at the root when you need\n * app-wide control:\n *\n * ```tsx\n * <MotionConfig reducedMotion={userPrefersCalm ? 'always' : 'auto'}>\n * <App />\n * </MotionConfig>\n * ```\n *\n * `reducedMotion=\"always\"` is genuinely useful in production, as the backing for an in-app\n * \"reduce motion\" setting — many users who want calmer interfaces have never found the OS toggle.\n */\nexport function MotionConfig({\n reducedMotion = 'auto',\n timeScale = 1,\n quality = null,\n pauseWhenHidden = true,\n pauseWhenBlurred = false,\n respectBattery = true,\n children,\n}: MotionConfigProps) {\n useEffect(() => {\n setReducedMotionMode(reducedMotion)\n }, [reducedMotion])\n\n useEffect(() => {\n getTicker().timeScale = timeScale\n }, [timeScale])\n\n useEffect(() => {\n if (quality !== null) getTicker().lockQuality(quality)\n }, [quality])\n\n useEffect(\n () =>\n attachLifecycle(getTicker(), {\n pauseWhenHidden,\n pauseWhenBlurred,\n respectBattery,\n }),\n [pauseWhenHidden, pauseWhenBlurred, respectBattery],\n )\n\n const value = useMemo(\n () => ({ reducedMotion, timeScale, quality }),\n [reducedMotion, timeScale, quality],\n )\n\n return <MotionConfigContext.Provider value={value}>{children}</MotionConfigContext.Provider>\n}\n\n/** Read the nearest {@link MotionConfig}. Returns sensible defaults with no provider present. */\nexport function useMotionConfig(): MotionConfigValue {\n return useContext(MotionConfigContext)\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 ThemeContext = createContext<ThemeContextValue>({\n theme: 'system',\n resolved: 'light',\n setTheme: () => {},\n})\n\nexport interface ThemeProviderProps {\n /** Initial setting. Default `'system'`. */\n defaultTheme?: ThemeSetting\n /** Persist the choice under this `localStorage` key. Pass `null` to disable. Default `'ansh-theme'`. */\n storageKey?: string | null\n children?: ReactNode\n}\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 render would be a\n * hydration mismatch, since the server has no access to it. The stored value is applied in an\n * effect. To avoid a flash of the wrong theme, ship the small inline script from\n * {@link themeScript} in your document `<head>` — that is the only way to set the attribute before\n * first paint, and it is what every correct implementation does.\n */\nexport function ThemeProvider({\n defaultTheme = 'system',\n storageKey = 'ansh-theme',\n children,\n}: ThemeProviderProps) {\n const [theme, setThemeState] = useState<ThemeSetting>(defaultTheme)\n const [resolved, setResolved] = useState<'light' | 'dark'>('light')\n\n // Read the stored preference after mount, never during render.\n useEffect(() => {\n if (!storageKey) return\n try {\n const stored = localStorage.getItem(storageKey)\n if (stored === 'light' || stored === 'dark' || stored === 'system') {\n setThemeState(stored)\n }\n } catch {\n // Storage can throw in private browsing or with cookies disabled. A theme preference is\n // not worth breaking the page over.\n }\n }, [storageKey])\n\n useEffect(() => {\n applyTheme(theme)\n setResolved(resolveTheme())\n\n if (storageKey) {\n try {\n localStorage.setItem(storageKey, theme)\n } catch {\n // As above.\n }\n }\n }, [theme, storageKey])\n\n // Follow the OS while set to `'system'`.\n useEffect(() => {\n if (theme !== 'system' || typeof matchMedia !== 'function') return\n const query = matchMedia('(prefers-color-scheme: dark)')\n const onChange = () => setResolved(query.matches ? 'dark' : 'light')\n query.addEventListener('change', onChange)\n return () => query.removeEventListener('change', onChange)\n }, [theme])\n\n const value = useMemo(() => ({ theme, resolved, setTheme: setThemeState }), [theme, resolved])\n\n return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>\n}\n\nexport function useTheme(): ThemeContextValue {\n return useContext(ThemeContext)\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 — which is the only point at which it can\n * be done without a visible flash. It is deliberately tiny and dependency-free.\n *\n * ```tsx\n * // Next.js app/layout.tsx\n * <head>\n * <script dangerouslySetInnerHTML={{ __html: themeScript() }} />\n * </head>\n * ```\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 {\n type CSSProperties,\n type ElementType,\n type ReactElement,\n type ReactNode,\n Children,\n cloneElement,\n isValidElement,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react'\nimport {\n type AnimationOptions,\n type EasingInput,\n type SpringOptions,\n animate,\n getTicker,\n prefersReducedMotion,\n springs,\n} from '@ansh-ui/core'\nimport { cx } from '../primitives/compose'\nimport { useMergedRef } from '../hooks/use-observers'\n\n/**\n * Declarative motion.\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. React never\n * re-renders during an animation.\n */\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\ntype MotionElementProps = {\n as?: ElementType\n /** Starting values. Applied before the first paint. */\n initial?: MotionValues\n /** Target values. Changing these animates to the new target. */\n animate?: MotionValues\n /** Values to animate to when removed by `AnimatePresence`. */\n exit?: MotionValues\n transition?: MotionTransition\n whileHover?: MotionValues\n whileTap?: MotionValues\n /** Animate to `animate` only once scrolled into view. */\n whileInView?: boolean\n /** Fraction visible before `whileInView` triggers. Default `0.2`. */\n inViewAmount?: number\n className?: string\n style?: CSSProperties\n children?: ReactNode\n}\n\nconst DEFAULTS: Required<Omit<MotionValues, never>> = {\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. */\nfunction 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\nfunction resolve(\n values: MotionValues | undefined,\n base: Required<MotionValues>,\n): Required<MotionValues> {\n return { ...base, ...values }\n}\n\n/**\n * An animated element.\n *\n * ```tsx\n * <Motion initial={{ opacity: 0, y: 24 }} animate={{ opacity: 1, y: 0 }} whileInView>\n * <Card />\n * </Motion>\n * ```\n */\nexport function Motion({\n as: Component = 'div',\n initial,\n animate: target,\n // Destructured but unused here: `AnimatePresence` reads `exit` off the element's props when the\n // child is removed and swaps it into `animate`. Pulling it out of `rest` stops it reaching the\n // DOM as an unknown attribute.\n exit: _exit,\n transition,\n whileHover,\n whileTap,\n whileInView = false,\n inViewAmount = 0.2,\n className,\n style,\n children,\n ...rest\n}: MotionElementProps & Record<string, unknown>) {\n const nodeRef = useRef<HTMLElement | null>(null)\n const currentRef = useRef<Required<MotionValues>>(resolve(initial, DEFAULTS))\n const controlsRef = useRef<ReturnType<typeof animate> | null>(null)\n const [inView, setInView] = useState(!whileInView)\n\n // Applied before paint, not in an effect. `useEffect` runs after the browser has already painted\n // the element at its natural position, so an element that should fade in flashes at full opacity\n // for one frame first.\n useLayoutEffect(() => {\n if (nodeRef.current) applyValues(nodeRef.current, currentRef.current)\n }, [])\n\n const runTo = useCallback(\n (next: Required<MotionValues>, options?: MotionTransition) => {\n const node = nodeRef.current\n if (!node) return\n\n controlsRef.current?.stop()\n\n const from = { ...currentRef.current }\n const springOption = options?.spring ?? transition?.spring\n\n const animationOptions: AnimationOptions<number> = {\n ...((options?.delay ?? transition?.delay !== undefined)\n ? { delay: options?.delay ?? 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 ?? transition?.duration ?? 0.4,\n ...((options?.easing ?? transition?.easing)\n ? { easing: (options?.easing ?? transition?.easing)! }\n : null),\n }),\n onUpdate: (t) => {\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 currentRef.current = frame\n applyValues(node, frame)\n },\n onComplete: () => {\n currentRef.current = next\n applyValues(node, next)\n },\n }\n\n controlsRef.current = animate(0, 1, animationOptions)\n },\n [transition],\n )\n\n // Animate to the target whenever it changes (or when it scrolls into view).\n const targetKey = JSON.stringify(target ?? null)\n useEffect(() => {\n if (!inView) return\n runTo(resolve(target, DEFAULTS))\n // `targetKey` stands in for `target`, which is nearly always an inline object literal whose\n // identity changes on every render.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [targetKey, inView, runTo])\n\n useEffect(() => {\n if (!whileInView) return\n const node = nodeRef.current\n if (!node || typeof IntersectionObserver === 'undefined') {\n setInView(true)\n return\n }\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry?.isIntersecting) {\n setInView(true)\n observer.disconnect()\n }\n },\n { threshold: inViewAmount },\n )\n observer.observe(node)\n return () => observer.disconnect()\n }, [whileInView, inViewAmount])\n\n useEffect(() => () => controlsRef.current?.stop(), [])\n\n const interaction: Record<string, unknown> = {}\n if (whileHover) {\n interaction.onMouseEnter = () => runTo(resolve({ ...target, ...whileHover }, DEFAULTS))\n interaction.onMouseLeave = () => runTo(resolve(target, DEFAULTS))\n }\n if (whileTap) {\n interaction.onPointerDown = () =>\n runTo(resolve({ ...target, ...whileTap }, DEFAULTS), { duration: 0.12 })\n interaction.onPointerUp = () => runTo(resolve({ ...target, ...whileHover }, DEFAULTS))\n }\n\n return (\n <Component\n ref={nodeRef}\n className={className}\n // `will-change` is set once, statically. Toggling it per animation causes the compositor to\n // create and destroy a layer on every interaction, which is more expensive than the hint saves.\n style={{ willChange: 'transform, opacity', ...style }}\n {...interaction}\n {...rest}\n >\n {children}\n </Component>\n )\n}\n\nexport interface AnimatePresenceProps {\n children: ReactNode\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 * React unmounts immediately when a child disappears from the tree, so an exit animation never gets\n * a chance to run. This holds departing children in its own state, plays their `exit` values, then\n * drops them.\n *\n * Children **must** have stable `key`s — that is how removals are detected at all. Without keys,\n * React reuses element positions and this sees no removal to animate.\n */\nexport function AnimatePresence({ children, exitDuration = 0.35 }: AnimatePresenceProps) {\n const currentChildren = Children.toArray(children).filter(isValidElement) as ReactElement[]\n const [rendered, setRendered] = useState<ReactElement[]>(currentChildren)\n const timersRef = useRef(new Map<string, ReturnType<typeof setTimeout>>())\n\n const keys = currentChildren.map((child) => String(child.key))\n const keysSignature = keys.join('|')\n\n useEffect(() => {\n const currentKeys = new Set(keys)\n const departing = rendered.filter((child) => !currentKeys.has(String(child.key)))\n\n if (departing.length === 0) {\n // Straight replacement keeps updated props flowing to children that are still present.\n setRendered(currentChildren)\n return\n }\n\n // Keep the departing children in place, appended after the current set so they don't reorder\n // the survivors while they animate out.\n setRendered([...currentChildren, ...departing])\n\n const delay = prefersReducedMotion() ? 0 : exitDuration * 1000\n for (const child of departing) {\n const key = String(child.key)\n clearTimeout(timersRef.current.get(key))\n timersRef.current.set(\n key,\n setTimeout(() => {\n setRendered((previous) => previous.filter((entry) => String(entry.key) !== key))\n timersRef.current.delete(key)\n }, delay),\n )\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [keysSignature, exitDuration])\n\n useEffect(() => {\n const timers = timersRef.current\n return () => {\n for (const timer of timers.values()) clearTimeout(timer)\n timers.clear()\n }\n }, [])\n\n const currentKeys = new Set(keys)\n\n return (\n <>\n {rendered.map((child) => {\n const leaving = !currentKeys.has(String(child.key))\n if (!leaving) return child\n\n // A departing child animates to its `exit` values by having them swapped into `animate`.\n const props = child.props as MotionElementProps\n return cloneElement(child as ReactElement<MotionElementProps>, {\n animate: props.exit ?? { opacity: 0, scale: 0.96 },\n transition: { duration: exitDuration, ...props.transition },\n })\n })}\n </>\n )\n}\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 onDragStart?: () => void\n onDragEnd?: (offset: { x: number; y: number }) => void\n className?: string\n style?: CSSProperties\n children: ReactNode\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 */\nexport function Draggable({\n axis = 'both',\n bounds,\n snapBack = false,\n momentum,\n onDragStart,\n onDragEnd,\n className,\n style,\n children,\n}: DraggableProps) {\n const nodeRef = useRef<HTMLDivElement | null>(null)\n const offsetRef = useRef({ x: 0, y: 0 })\n const [dragging, setDragging] = useState(false)\n\n const useMomentum = momentum ?? !snapBack\n\n const clamp = useCallback(\n (value: { x: number; y: number }) => ({\n x: Math.min(Math.max(value.x, bounds?.left ?? -Infinity), bounds?.right ?? Infinity),\n y: Math.min(Math.max(value.y, bounds?.top ?? -Infinity), bounds?.bottom ?? Infinity),\n }),\n [bounds],\n )\n\n const write = (value: { x: number; y: number }) => {\n if (nodeRef.current) {\n nodeRef.current.style.transform = `translate3d(${value.x}px, ${value.y}px, 0)`\n }\n }\n\n const onPointerDown = (event: React.PointerEvent<HTMLDivElement>) => {\n event.currentTarget.setPointerCapture(event.pointerId)\n setDragging(true)\n onDragStart?.()\n\n const start = { x: event.clientX, y: event.clientY }\n const origin = { ...offsetRef.current }\n // A short ring of recent samples, for a velocity estimate that isn't hostage to the last event.\n const samples: Array<{ x: number; y: number; t: number }> = []\n\n const onMove = (moveEvent: PointerEvent) => {\n const next = clamp({\n x: axis === 'y' ? origin.x : origin.x + (moveEvent.clientX - start.x),\n y: axis === 'x' ? origin.y : origin.y + (moveEvent.clientY - start.y),\n })\n offsetRef.current = 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 = () => {\n setDragging(false)\n window.removeEventListener('pointermove', onMove)\n window.removeEventListener('pointerup', onUp)\n window.removeEventListener('pointercancel', onUp)\n\n if (snapBack) {\n animate(0, 1, {\n spring: springs.subtle,\n onUpdate: (t) => {\n const value = { x: offsetRef.current.x * (1 - t), y: offsetRef.current.y * (1 - t) }\n write(value)\n },\n onComplete: () => {\n offsetRef.current = { x: 0, y: 0 }\n write(offsetRef.current)\n onDragEnd?.(offsetRef.current)\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: offsetRef.current.x + velocity.x * delta,\n y: offsetRef.current.y + velocity.y * delta,\n })\n offsetRef.current = next\n write(next)\n\n if (Math.hypot(velocity.x, velocity.y) < 8) {\n stop()\n onDragEnd?.(offsetRef.current)\n }\n },\n { phase: 'write', name: 'Draggable' },\n )\n return\n }\n\n onDragEnd?.(offsetRef.current)\n }\n\n window.addEventListener('pointermove', onMove)\n window.addEventListener('pointerup', onUp)\n window.addEventListener('pointercancel', onUp)\n }\n\n return (\n <div\n ref={nodeRef}\n className={cx('ansh-draggable', dragging && 'ansh-draggable--active', className)}\n style={{ touchAction: axis === 'x' ? 'pan-y' : axis === 'y' ? 'pan-x' : 'none', ...style }}\n onPointerDown={onPointerDown}\n >\n {children}\n </div>\n )\n}\n\n/** Merge a forwarded ref with the internal one, re-exported for consumers wrapping `Motion`. */\nexport { useMergedRef }\n"]}
|
|
@@ -141,6 +141,22 @@ function useFrameBudget(enabled = true) {
|
|
|
141
141
|
}, [enabled]);
|
|
142
142
|
return report;
|
|
143
143
|
}
|
|
144
|
+
function useTickerSubscriberCount(enabled = true) {
|
|
145
|
+
const [count, setCount] = react.useState(0);
|
|
146
|
+
react.useEffect(() => {
|
|
147
|
+
if (!enabled) return;
|
|
148
|
+
const ticker = core.getTicker();
|
|
149
|
+
setCount(ticker.subscriberCount);
|
|
150
|
+
let last = 0;
|
|
151
|
+
return ticker.onBudget(() => {
|
|
152
|
+
const now = performance.now();
|
|
153
|
+
if (now - last < 250) return;
|
|
154
|
+
last = now;
|
|
155
|
+
setCount(ticker.subscriberCount);
|
|
156
|
+
});
|
|
157
|
+
}, [enabled]);
|
|
158
|
+
return count;
|
|
159
|
+
}
|
|
144
160
|
function useMergedRef(...refs) {
|
|
145
161
|
return react.useCallback((node) => {
|
|
146
162
|
for (const ref of refs) {
|
|
@@ -159,6 +175,7 @@ exports.usePointer = usePointer;
|
|
|
159
175
|
exports.useReducedMotion = useReducedMotion;
|
|
160
176
|
exports.useScrollProgress = useScrollProgress;
|
|
161
177
|
exports.useTicker = useTicker;
|
|
178
|
+
exports.useTickerSubscriberCount = useTickerSubscriberCount;
|
|
162
179
|
exports.useWindowScroll = useWindowScroll;
|
|
163
|
-
//# sourceMappingURL=chunk-
|
|
164
|
-
//# sourceMappingURL=chunk-
|
|
180
|
+
//# sourceMappingURL=chunk-TEPQGFR4.cjs.map
|
|
181
|
+
//# sourceMappingURL=chunk-TEPQGFR4.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-observers.ts"],"names":["useRef","useEffect","getTicker","useState","observeIntersection","observeResize","trackScroll","trackContainerScroll","trackPointer","onReducedMotionChange","useCallback"],"mappings":";;;;;;AAuBO,SAAS,SAAA,CACd,QAAA,EACA,OAAA,GAII,EAAC,EACC;AACN,EAAA,MAAM,WAAA,GAAcA,aAAO,QAAQ,CAAA;AACnC,EAAA,WAAA,CAAY,OAAA,GAAU,QAAA;AAEtB,EAAA,MAAM,EAAE,KAAA,GAAQ,OAAA,EAAS,WAAW,CAAA,EAAG,OAAA,GAAU,MAAK,GAAI,OAAA;AAE1D,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,OAAA,EAAS;AACd,IAAA,MAAM,SAASC,cAAA,EAAU;AACzB,IAAA,OAAO,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,KAAU,WAAA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AAI,CAAA;AACT","file":"chunk-TEPQGFR4.cjs","sourcesContent":["import { type RefObject, useCallback, useEffect, useRef, useState } from 'react'\nimport {\n type BudgetReport,\n type FrameState,\n type PointerState,\n type ScrollProgress,\n type ScrollTrackOptions,\n getTicker,\n observeIntersection,\n observeResize,\n onReducedMotionChange,\n trackContainerScroll,\n trackPointer,\n trackScroll,\n} from '@ansh-ui/core'\n\n/**\n * Subscribe to the shared ticker.\n *\n * The callback is held in a ref and never re-subscribes, so a component that closes over changing\n * props doesn't tear down and rebuild its subscription on every render. That matters: resubscribing\n * changes execution order within the phase, which can visibly reorder dependent animations.\n */\nexport function useTicker(\n callback: (state: FrameState) => void,\n options: {\n phase?: 'read' | 'compute' | 'write' | 'post'\n priority?: number\n enabled?: boolean\n } = {},\n): void {\n const callbackRef = useRef(callback)\n callbackRef.current = callback\n\n const { phase = 'write', priority = 0, enabled = true } = options\n\n useEffect(() => {\n if (!enabled) return\n const ticker = getTicker()\n return ticker.add((state) => callbackRef.current(state), { phase, priority, name: 'useTicker' })\n }, [phase, priority, enabled])\n}\n\nexport interface InViewOptions {\n /** Fraction visible before triggering, in `[0, 1]`. Default `0`. */\n threshold?: number\n /** Extra margin around the root. Default `'0px'`. */\n rootMargin?: string\n /** Stop observing after the first intersection. Default `false`. */\n once?: boolean\n root?: Element | null\n}\n\n/**\n * Is the element in the viewport?\n *\n * Uses the pooled observer, so a page with 200 scroll-revealed elements creates one\n * `IntersectionObserver` rather than 200.\n */\nexport function useInView<El extends Element = HTMLDivElement>(\n options: InViewOptions = {},\n): [RefObject<El | null>, boolean] {\n const ref = useRef<El | null>(null)\n const [inView, setInView] = useState(false)\n\n const { threshold = 0, rootMargin = '0px', once = false, root = null } = options\n\n useEffect(() => {\n const element = ref.current\n if (!element) return\n\n let released = false\n const stop = observeIntersection(\n element,\n (entry) => {\n setInView(entry.isIntersecting)\n if (entry.isIntersecting && once && !released) {\n released = true\n // Release inside a microtask: unsubscribing from within the observer callback would\n // mutate the pool's callback set while it is being iterated.\n queueMicrotask(() => stop())\n }\n },\n { threshold, rootMargin, root },\n )\n\n return () => {\n released = true\n stop()\n }\n }, [threshold, rootMargin, once, root])\n\n return [ref, inView]\n}\n\n/**\n * Track an element's size.\n *\n * Returns state rather than a MotionValue because size changes at interaction rate, not frame\n * rate, so a re-render per change is appropriate and far more ergonomic.\n */\nexport function useElementSize<El extends Element = HTMLDivElement>(): [\n RefObject<El | null>,\n { width: number; height: number },\n] {\n const ref = useRef<El | null>(null)\n const [size, setSize] = useState({ width: 0, height: 0 })\n\n useEffect(() => {\n const element = ref.current\n if (!element) return\n return observeResize(element, ({ width, height }) => {\n // Guard against redundant renders: ResizeObserver fires on sub-pixel changes during\n // animation, and setting identical state still costs a render pass in React 18.\n setSize((previous) =>\n previous.width === width && previous.height === height ? previous : { width, height },\n )\n })\n }, [])\n\n return [ref, size]\n}\n\n/**\n * Track an element's scroll progress through the viewport.\n *\n * The returned progress is a **ref**, not state, deliberately — scroll progress changes every\n * frame, and rendering on each change would make scrolling janky. Read `progress.current` inside a\n * `useTicker` callback, or pass the `onChange` callback and write to the DOM directly.\n */\nexport function useScrollProgress<El extends HTMLElement = HTMLDivElement>(\n options: ScrollTrackOptions & { onChange?: (progress: ScrollProgress) => void } = {},\n): [RefObject<El | null>, RefObject<ScrollProgress>] {\n const ref = useRef<El | null>(null)\n const progressRef = useRef<ScrollProgress>({\n progress: 0,\n velocity: 0,\n scroll: 0,\n direction: 0,\n inView: false,\n })\n\n const onChangeRef = useRef(options.onChange)\n onChangeRef.current = options.onChange\n\n const { axis = 'y', container = null } = options\n const offsetKey = JSON.stringify(options.offset ?? null)\n\n useEffect(() => {\n const element = ref.current\n if (!element) return\n\n return trackScroll(\n element,\n (progress) => {\n progressRef.current = progress\n onChangeRef.current?.(progress)\n },\n {\n axis,\n container,\n ...(options.offset ? { offset: options.offset } : {}),\n },\n )\n // `offsetKey` stands in for the offset object, which is usually an inline literal and would\n // otherwise change identity on every render.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [axis, container, offsetKey])\n\n return [ref, progressRef]\n}\n\n/** Track the window's (or a container's) overall scroll progress. */\nexport function useWindowScroll(\n onChange?: (info: { progress: number; scroll: number; velocity: number; max: number }) => void,\n options: { axis?: 'y' | 'x'; container?: HTMLElement | null } = {},\n): RefObject<{ progress: number; scroll: number; velocity: number; max: number }> {\n const stateRef = useRef({ progress: 0, scroll: 0, velocity: 0, max: 1 })\n const onChangeRef = useRef(onChange)\n onChangeRef.current = onChange\n\n const { axis = 'y', container = null } = options\n\n useEffect(\n () =>\n trackContainerScroll(\n (info) => {\n stateRef.current = info\n onChangeRef.current?.(info)\n },\n { axis, container },\n ),\n [axis, container],\n )\n\n return stateRef\n}\n\n/**\n * Track pointer position over an element.\n *\n * Returns a ref to the live state object, which is mutated in place by the tracker. Reading it\n * inside a `useTicker` callback is the intended use; it deliberately does not trigger renders.\n */\nexport function usePointer<El extends HTMLElement = HTMLDivElement>(\n options: { smoothing?: number; trackOutside?: boolean; enabled?: boolean } = {},\n): [RefObject<El | null>, RefObject<Readonly<PointerState> | null>] {\n const ref = useRef<El | null>(null)\n const stateRef = useRef<Readonly<PointerState> | null>(null)\n\n const { smoothing, trackOutside = false, enabled = true } = options\n\n useEffect(() => {\n const element = ref.current\n if (!element || !enabled) return\n\n const tracker = trackPointer(element, {\n ...(smoothing !== undefined ? { smoothing } : {}),\n trackOutside,\n })\n stateRef.current = tracker.state\n\n return () => {\n tracker.destroy()\n stateRef.current = null\n }\n }, [smoothing, trackOutside, enabled])\n\n return [ref, stateRef]\n}\n\n/**\n * Does the user prefer reduced motion?\n *\n * Returns `false` during SSR and on the first client render, then updates. That ordering is\n * deliberate: returning the real value during SSR is impossible (the server cannot know), and\n * returning it on the first client render would be a hydration mismatch.\n */\nexport function useReducedMotion(): boolean {\n const [reduced, setReduced] = useState(false)\n useEffect(() => onReducedMotionChange(setReduced), [])\n return reduced\n}\n\n/**\n * Live frame-budget telemetry — FPS, frame cost percentiles, and the adaptive quality scalar.\n *\n * Intended for a development overlay. Subscribing causes a re-render every frame, so this must not\n * ship in production render paths; the `enabled` flag exists so it can be gated on `NODE_ENV`.\n */\nexport function useFrameBudget(enabled = true): BudgetReport | null {\n const [report, setReport] = useState<BudgetReport | null>(null)\n\n useEffect(() => {\n if (!enabled) return\n const ticker = getTicker()\n // Sample at ~4 Hz rather than per frame. A number that changes 60 times a second is\n // unreadable, and rendering it 60 times a second distorts the very measurement being shown.\n let last = 0\n return ticker.onBudget((next) => {\n const now = performance.now()\n if (now - last < 250) return\n last = now\n setReport(next)\n })\n }, [enabled])\n\n return report\n}\n\n/**\n * Live count of components currently subscribed to the shared ticker.\n *\n * Intended for a devtools-style overlay, alongside `useFrameBudget` — the ticker only exposes\n * `subscriberCount` as a getter with no change event, so this piggybacks on `onBudget`'s existing\n * ~4 Hz sample instead of opening a second interval or rAF loop just to poll one number.\n */\nexport function useTickerSubscriberCount(enabled = true): number {\n const [count, setCount] = useState(0)\n\n useEffect(() => {\n if (!enabled) return\n const ticker = getTicker()\n setCount(ticker.subscriberCount)\n let last = 0\n return ticker.onBudget(() => {\n const now = performance.now()\n if (now - last < 250) return\n last = now\n setCount(ticker.subscriberCount)\n })\n }, [enabled])\n\n return count\n}\n\n/** Merge several refs into one callback ref, for components that both forward and use a ref. */\nexport function useMergedRef<T>(\n ...refs: Array<React.Ref<T> | undefined | null>\n): (node: T | null) => void {\n return useCallback((node: T | null) => {\n for (const ref of refs) {\n if (!ref) continue\n if (typeof ref === 'function') ref(node)\n else (ref as React.MutableRefObject<T | null>).current = node\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, refs)\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useAnchoredPosition, useDismiss, Portal } from './chunk-XEP6P7E6.js';
|
|
2
2
|
import { useControllableState } from './chunk-LXCIXR5T.js';
|
|
3
|
-
import { useMergedRef } from './chunk-
|
|
3
|
+
import { useMergedRef } from './chunk-P5MRISBP.js';
|
|
4
4
|
import { cx } from './chunk-H34OXXJU.js';
|
|
5
5
|
import { createContext, forwardRef, useRef, useState, useEffect, useCallback, useId, useContext, useMemo } from 'react';
|
|
6
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -2474,7 +2474,7 @@ function Calendar({
|
|
|
2474
2474
|
}
|
|
2475
2475
|
};
|
|
2476
2476
|
const onKeyDown = (event) => {
|
|
2477
|
-
let next
|
|
2477
|
+
let next;
|
|
2478
2478
|
switch (event.key) {
|
|
2479
2479
|
case "ArrowLeft":
|
|
2480
2480
|
next = addDays(cursor, -1);
|
|
@@ -2936,5 +2936,5 @@ function DateRangePicker({
|
|
|
2936
2936
|
}
|
|
2937
2937
|
|
|
2938
2938
|
export { Calendar, Checkbox, ChoiceCard, ColorPicker, Combobox, DatePicker, DateRangePicker, Dropzone, Field, Fieldset, Input, NumberInput, OptionList, PinInput, Radio, RadioGroup, RangeSlider, Rating, Select, Slider, Switch, TagsInput, Textarea, VisuallyHidden, addDays, addMonths, filterOptions, firstEnabled, isSameDay, scoreOption, startOfDay, stepActive, useFieldContext, useFieldControl, useTypeahead };
|
|
2939
|
-
//# sourceMappingURL=chunk-
|
|
2940
|
-
//# sourceMappingURL=chunk-
|
|
2939
|
+
//# sourceMappingURL=chunk-WNWGYXJY.js.map
|
|
2940
|
+
//# sourceMappingURL=chunk-WNWGYXJY.js.map
|