@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 +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","useRef","useMergedRef","useEffect","mountBehaviour","jsx","forwardRef","magnetic","tilt","ripple","marquee","scrollReveal","parallax","useLayoutEffect","useMemo","resolvePalette","createGradient","prefersReducedMotion","jsxs","resolveEasing","stagger","getTicker","observeIntersection","createContext","setReducedMotionMode","attachLifecycle","useContext","useState","applyTheme","resolveTheme","useCallback","springs","animate","Children","isValidElement","currentKeys","Fragment","cloneElement","cx"],"mappings":";;;;;;;;;AAqEO,SAAS,wBAAA,CAId,UAAA,EACA,WAAA,EACA,cAAA,GAA8B,KAAA,EACG;AACjC,EAAA,MAAM,aAAa,IAAI,GAAA,CAAI,OAAO,IAAA,CAAK,UAAA,CAAW,QAAQ,CAAC,CAAA;AAE3D,EAAA,SAAS,MAAA,CAAO,OAAmB,YAAA,EAAgC;AACjE,IAAA,MAAM,EAAE,IAAIA,UAAAA,GAAY,cAAA,EAAgB,WAAW,KAAA,EAAO,QAAA,EAAU,GAAG,IAAA,EAAK,GAAI,KAAA;AAEhF,IAAA,MAAM,OAAA,GAAUC,aAAkB,IAAI,CAAA;AACtC,IAAA,MAAM,SAAA,GAAYA,aAAwC,IAAI,CAAA;AAC9D,IAAA,MAAM,SAAA,GAAYC,8BAAA,CAAiB,OAAA,EAAS,YAAY,CAAA;AAExD,IAAA,MAAM,UAAmC,EAAC;AAC1C,IAAA,MAAM,WAAoC,EAAC;AAC3C,IAAA,KAAA,MAAW,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,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-AVPEA5PB.cjs","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","useRef","useMergedRef","useEffect","mountBehaviour","jsx","forwardRef","magnetic","tilt","ripple","marquee","scrollReveal","parallax","useLayoutEffect","useMemo","resolvePalette","createGradient","prefersReducedMotion","jsxs","resolveEasing","stagger","getTicker","observeIntersection","createContext","setReducedMotionMode","attachLifecycle","useContext","useState","applyTheme","resolveTheme","useCallback","springs","animate","Children","isValidElement","currentKeys","Fragment","cloneElement","cx"],"mappings":";;;;;;;;;AAqEO,SAAS,wBAAA,CAId,UAAA,EACA,WAAA,EACA,cAAA,GAA8B,KAAA,EACG;AACjC,EAAA,MAAM,aAAa,IAAI,GAAA,CAAI,OAAO,IAAA,CAAK,UAAA,CAAW,QAAQ,CAAC,CAAA;AAE3D,EAAA,SAAS,MAAA,CAAO,OAAmB,YAAA,EAAgC;AACjE,IAAA,MAAM,EAAE,IAAIA,UAAAA,GAAY,cAAA,EAAgB,WAAW,KAAA,EAAO,QAAA,EAAU,GAAG,IAAA,E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AAO,gBAAA,CAAiB,iBAAiB,IAAI,CAAA;AAAA,EAC/C,CAAA;AAEA,EAAA,uBACEhB,cAAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA,EAAK,OAAA;AAAA,MACL,SAAA,EAAWiC,oBAAA,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-IZ6T7LO3.cjs","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"]}
|
|
@@ -110,7 +110,7 @@ function useRovingFocus(options) {
|
|
|
110
110
|
if (items.length === 0) return;
|
|
111
111
|
const horizontal = orientation === "horizontal" || orientation === "both";
|
|
112
112
|
const vertical = orientation === "vertical" || orientation === "both";
|
|
113
|
-
let next
|
|
113
|
+
let next;
|
|
114
114
|
switch (event.key) {
|
|
115
115
|
case "ArrowRight":
|
|
116
116
|
if (!horizontal) return;
|
|
@@ -194,5 +194,5 @@ exports.useFocusRestore = useFocusRestore;
|
|
|
194
194
|
exports.useFocusTrap = useFocusTrap;
|
|
195
195
|
exports.usePresence = usePresence;
|
|
196
196
|
exports.useRovingFocus = useRovingFocus;
|
|
197
|
-
//# sourceMappingURL=chunk-
|
|
198
|
-
//# sourceMappingURL=chunk-
|
|
197
|
+
//# sourceMappingURL=chunk-KTLTYHAT.cjs.map
|
|
198
|
+
//# sourceMappingURL=chunk-KTLTYHAT.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/primitives/slot.tsx","../src/primitives/focus.ts","../src/primitives/presence.tsx"],"names":["forwardRef","Slot","isValidElement","cloneElement","mergeProps","mergeRefs","Children","useEffect","useRef","useState","prefersReducedMotion"],"mappings":";;;;;;;AA+BO,IAAM,IAAA,GAAOA,iBAAmC,SAASC,KAAAA,CAC9D,EAAE,QAAA,EAAU,GAAG,SAAA,EAAU,EACzB,YAAA,EACA;AACA,EAAA,IAAI,CAACC,oBAAA,CAAe,QAAQ,CAAA,EAAG;AAG7B,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,MAAM,KAAA,GAAQ,QAAA;AAId,EAAA,MAAM,QAAA,GAAY,KAAA,CAAM,KAAA,CAA2C,GAAA,IAAO,KAAA,CAAM,GAAA;AAEhF,EAAA,OAAOC,mBAAa,KAAA,EAAO;AAAA,IACzB,GAAGC,4BAAA,CAAW,SAAA,EAAW,KAAA,CAAM,KAAK,CAAA;AAAA,IACpC,GAAA,EAAKC,2BAAA,CAAU,YAAA,EAAc,QAAQ;AAAA,GACX,CAAA;AAC9B,CAAC;AAQM,SAAS,OAAA,CACd,SACA,QAAA,EACmB;AACnB,EAAA,OAAO,UAAW,IAAA,GAAwC,QAAA;AAC5D;AAGO,SAAS,cAAc,QAAA,EAA6B;AACzD,EAAA,OAAOC,eAAS,OAAA,CAAQ,QAAQ,CAAA,CAAE,MAAA,CAAOJ,oBAAc,CAAA,CAAE,MAAA;AAC3D;ACtDA,IAAM,kBAAA,GAAqB;AAAA,EACzB,SAAA;AAAA,EACA,wBAAA;AAAA,EACA,4CAAA;AAAA,EACA,wBAAA;AAAA,EACA,0BAAA;AAAA,EACA,iBAAA;AAAA,EACA,iB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AAM,QAAA,EAAS,EAAkB;AAC1D,EAAA,MAAM,GAAA,GAAMF,aAA2B,IAAI,CAAA;AAC3C,EAAA,MAAM,EAAE,OAAA,EAAS,KAAA,EAAM,GAAI,WAAA,CAAY,MAAM,GAAG,CAAA;AAChD,EAAA,IAAI,CAAC,SAAS,OAAO,IAAA;AACrB,EAAA,6DAAU,QAAA,EAAA,QAAA,CAAS,EAAE,GAAA,EAAK,KAAA,EAAO,CAAA,EAAE,CAAA;AACrC","file":"chunk-KTLTYHAT.cjs","sourcesContent":["import {\n Children,\n type ReactElement,\n type ReactNode,\n cloneElement,\n forwardRef,\n isValidElement,\n} from 'react'\nimport { mergeProps, mergeRefs } from './compose'\n\nexport interface SlotProps {\n children?: ReactNode\n [key: string]: unknown\n}\n\n/**\n * Render into the child element instead of rendering a wrapper.\n *\n * This is what powers `asChild`. Without it, a `<Tooltip.Trigger>` wrapping a `<Button>` emits a\n * `<span>` around the button — which breaks flex layouts, adds a node that inherits nothing, and\n * puts the trigger's ARIA attributes on the wrong element for assistive technology.\n *\n * ```tsx\n * <Tooltip.Trigger asChild>\n * <Button>Save</Button>\n * </Tooltip.Trigger>\n * ```\n *\n * The button *is* the trigger: it carries `aria-describedby` and the handlers, and no extra DOM\n * node exists.\n */\nexport const Slot = forwardRef<HTMLElement, SlotProps>(function Slot(\n { children, ...slotProps },\n forwardedRef,\n) {\n if (!isValidElement(children)) {\n // A `Slot` with no element child renders nothing rather than throwing. Throwing here would\n // turn a conditional child (`{loading ? null : <Button/>}`) into a crash.\n return null\n }\n\n const child = children as ReactElement<Record<string, unknown>> & { ref?: React.Ref<HTMLElement> }\n\n // React 19 exposes `ref` as a normal prop; React 18 keeps it on the element. Reading both keeps\n // this working across the supported peer range without a version check.\n const childRef = (child.props as { ref?: React.Ref<HTMLElement> }).ref ?? child.ref\n\n return cloneElement(child, {\n ...mergeProps(slotProps, child.props),\n ref: mergeRefs(forwardedRef, childRef),\n } as Record<string, unknown>)\n})\n\n/**\n * Pick between a host element and its child based on `asChild`.\n *\n * Every component in this library that accepts `asChild` uses this, so the behaviour is identical\n * across all of them rather than reimplemented with small differences.\n */\nexport function slotted(\n asChild: boolean | undefined,\n fallback: React.ElementType,\n): React.ElementType {\n return asChild ? (Slot as unknown as React.ElementType) : fallback\n}\n\n/** Count element children, ignoring `null`/`false` from conditional rendering. */\nexport function countElements(children: ReactNode): number {\n return Children.toArray(children).filter(isValidElement).length\n}\n","import { type RefObject, useEffect, useRef } from 'react'\n\n/**\n * Focus management for overlay surfaces.\n *\n * Three separate concerns that are usually conflated:\n *\n * 1. **Finding what can be focused.** Harder than it looks — `disabled`, `hidden`, `inert`,\n * zero-size elements and negative tabindex all disqualify a node, and CSS-hidden ancestors\n * disqualify their whole subtree.\n * 2. **Trapping.** Tab must cycle within the surface. Required by WCAG 2.4.3 for modals.\n * 3. **Restoring.** Focus must return to the trigger on close, or a keyboard user is dumped at the\n * top of the document and has to navigate all the way back.\n */\n\nconst FOCUSABLE_SELECTOR = [\n 'a[href]',\n 'button:not([disabled])',\n 'input:not([disabled]):not([type=\"hidden\"])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n 'audio[controls]',\n 'video[controls]',\n '[contenteditable]:not([contenteditable=\"false\"])',\n '[tabindex]:not([tabindex=\"-1\"])',\n].join(',')\n\n/** Is this element rendered and interactive right now? */\nfunction isVisible(element: HTMLElement): boolean {\n // `offsetParent === null` catches `display: none` on the element or any ancestor, cheaply.\n // `position: fixed` elements legitimately have a null offsetParent, so they are checked against\n // their box instead.\n if (element.hasAttribute('inert')) return false\n if (element.offsetParent !== null) return true\n const rect = element.getBoundingClientRect()\n return rect.width > 0 || rect.height > 0\n}\n\n/** Every tabbable descendant, in tab order. */\nexport function getTabbable(container: HTMLElement | null): HTMLElement[] {\n if (!container) return []\n const nodes = Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR))\n return nodes.filter((node) => {\n if (node.getAttribute('aria-hidden') === 'true') return false\n if (node.closest('[inert]')) return false\n return isVisible(node)\n })\n}\n\n/**\n * Trap Tab within a container while `active`.\n *\n * Implemented on `keydown` at the container rather than with sentinel elements at either end. The\n * sentinel approach adds two focusable nodes to the accessibility tree that screen readers can\n * land on and announce as blank; intercepting the key does not.\n */\nexport function useFocusTrap(ref: RefObject<HTMLElement | null>, active: boolean): void {\n useEffect(() => {\n if (!active) return\n const container = ref.current\n if (!container) return\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Tab') return\n\n const tabbable = getTabbable(container)\n if (tabbable.length === 0) {\n // Nothing to move to — keep focus on the surface rather than letting it escape.\n event.preventDefault()\n return\n }\n\n const first = tabbable[0]!\n const last = tabbable[tabbable.length - 1]!\n const activeElement = document.activeElement as HTMLElement | null\n\n // Focus may sit on the container itself (given `tabIndex={-1}` for the initial focus), in\n // which case neither branch below matches and the default Tab lands on `first` naturally.\n if (event.shiftKey && (activeElement === first || activeElement === container)) {\n event.preventDefault()\n last.focus()\n } else if (!event.shiftKey && activeElement === last) {\n event.preventDefault()\n first.focus()\n }\n }\n\n container.addEventListener('keydown', onKeyDown)\n return () => container.removeEventListener('keydown', onKeyDown)\n }, [ref, active])\n}\n\n/**\n * Restore focus to whatever was focused before `active` became true.\n *\n * The element is captured on activation, not on mount, because a component can be mounted long\n * before it opens.\n */\nexport function useFocusRestore(active: boolean): void {\n const previousRef = useRef<HTMLElement | null>(null)\n\n useEffect(() => {\n if (!active) return\n previousRef.current = document.activeElement as HTMLElement | null\n\n return () => {\n const previous = previousRef.current\n // Guard against restoring to a node that has since been removed from the document —\n // focusing a detached element silently moves focus to `<body>`, losing the user's place.\n if (previous && previous.isConnected) previous.focus?.({ preventScroll: true })\n }\n }, [active])\n}\n\n/**\n * Move focus into a surface when it opens.\n *\n * Prefers an explicitly marked element, then the first tabbable one, then the container itself.\n * The container fallback matters for a dialog whose only content is text: focus must land inside\n * it so a screen reader announces the dialog rather than continuing from the page behind.\n */\nexport function useAutoFocus(\n ref: RefObject<HTMLElement | null>,\n active: boolean,\n initialFocus?: RefObject<HTMLElement | null>,\n): void {\n useEffect(() => {\n if (!active) return\n const container = ref.current\n if (!container) return\n\n // After paint: the surface may still be animating in, and focusing a node with\n // `visibility: hidden` is a no-op that silently leaves focus on the body.\n const frame = requestAnimationFrame(() => {\n const explicit = initialFocus?.current\n if (explicit?.isConnected) {\n explicit.focus({ preventScroll: true })\n return\n }\n const target = getTabbable(container)[0] ?? container\n target.focus({ preventScroll: true })\n })\n\n return () => cancelAnimationFrame(frame)\n }, [ref, active, initialFocus])\n}\n\n/**\n * Roving tabindex for a composite widget (toolbar, tab list, menu).\n *\n * The ARIA authoring practice: a composite has exactly **one** tab stop, and arrow keys move\n * within it. Ten tabs that are each a tab stop means a keyboard user presses Tab ten times to get\n * past the tab bar — technically operable, practically hostile.\n */\nexport function useRovingFocus(options: {\n /** Items in DOM order. */\n itemsRef: RefObject<Array<HTMLElement | null>>\n /** Index that currently owns the tab stop. */\n active: number\n onActiveChange: (index: number) => void\n orientation?: 'horizontal' | 'vertical' | 'both'\n loop?: boolean\n}): (event: React.KeyboardEvent) => void {\n const { itemsRef, active, onActiveChange, orientation = 'horizontal', loop = true } = options\n\n return (event: React.KeyboardEvent) => {\n const items = (itemsRef.current ?? []).filter((item): item is HTMLElement => item !== null)\n if (items.length === 0) return\n\n const horizontal = orientation === 'horizontal' || orientation === 'both'\n const vertical = orientation === 'vertical' || orientation === 'both'\n\n let next: number\n switch (event.key) {\n case 'ArrowRight':\n if (!horizontal) return\n next = active + 1\n break\n case 'ArrowLeft':\n if (!horizontal) return\n next = active - 1\n break\n case 'ArrowDown':\n if (!vertical) return\n next = active + 1\n break\n case 'ArrowUp':\n if (!vertical) return\n next = active - 1\n break\n case 'Home':\n next = 0\n break\n case 'End':\n next = items.length - 1\n break\n default:\n return\n }\n\n event.preventDefault()\n\n if (next < 0) next = loop ? items.length - 1 : 0\n if (next >= items.length) next = loop ? 0 : items.length - 1\n\n onActiveChange(next)\n items[next]?.focus()\n }\n}\n","import { type ReactNode, type RefObject, useEffect, useRef, useState } from 'react'\nimport { prefersReducedMotion } from '@ansh-ui/core'\n\n/**\n * Keep an element mounted while it animates out.\n *\n * The problem: `{open && <Dialog />}` cannot animate on close, because React removes the node the\n * instant `open` flips. The fix is to keep rendering it and unmount when the exit animation\n * actually finishes.\n *\n * Finishing is detected from `animationend`/`transitionend` rather than a duration prop. A duration\n * prop has to be kept in sync with the CSS by hand, and it drifts the moment someone retimes the\n * animation in the stylesheet — leaving either a flash (unmount too early) or a surface that lingers\n * invisibly and swallows clicks (too late). The timeout below is only a safety net for the case\n * where no animation is declared at all and no event ever fires.\n */\nexport function usePresence(\n open: boolean,\n ref: RefObject<HTMLElement | null>,\n): { mounted: boolean; state: 'open' | 'closed' } {\n const [mounted, setMounted] = useState(open)\n const [state, setState] = useState<'open' | 'closed'>(open ? 'open' : 'closed')\n\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n\n useEffect(() => {\n if (open) {\n clearTimeout(timeoutRef.current)\n setMounted(true)\n // Next frame, so the element mounts in its closed state and *then* transitions. Setting\n // both in the same commit means the browser never sees the start state and no transition\n // runs — the classic \"enter animation doesn't play\" bug.\n const frame = requestAnimationFrame(() => setState('open'))\n return () => cancelAnimationFrame(frame)\n }\n\n if (!mounted) return\n\n setState('closed')\n\n const node = ref.current\n if (!node || prefersReducedMotion()) {\n setMounted(false)\n return\n }\n\n // Only the element's *own* animations count. A child's animation ending would unmount the\n // surface while it is still fading.\n const onEnd = (event: AnimationEvent | TransitionEvent) => {\n if (event.target !== node) return\n setMounted(false)\n }\n\n node.addEventListener('animationend', onEnd)\n node.addEventListener('transitionend', onEnd)\n\n // Safety net: if no animation is declared, neither event ever fires and the surface would\n // stay mounted forever, invisible and intercepting pointer events.\n timeoutRef.current = setTimeout(() => setMounted(false), 400)\n\n return () => {\n node.removeEventListener('animationend', onEnd)\n node.removeEventListener('transitionend', onEnd)\n clearTimeout(timeoutRef.current)\n }\n }, [open, mounted, ref])\n\n return { mounted, state }\n}\n\nexport interface PresenceProps {\n open: boolean\n children: (props: { ref: RefObject<HTMLElement | null>; state: 'open' | 'closed' }) => ReactNode\n}\n\n/**\n * Render-prop form of `usePresence`, for callers that would otherwise need to hoist a ref.\n *\n * ```tsx\n * <Presence open={open}>\n * {({ ref, state }) => <div ref={ref} data-state={state} className=\"fade\" />}\n * </Presence>\n * ```\n */\nexport function Presence({ open, children }: PresenceProps) {\n const ref = useRef<HTMLElement | null>(null)\n const { mounted, state } = usePresence(open, ref)\n if (!mounted) return null\n return <>{children({ ref, state })}</>\n}\n"]}
|
|
@@ -139,6 +139,22 @@ function useFrameBudget(enabled = true) {
|
|
|
139
139
|
}, [enabled]);
|
|
140
140
|
return report;
|
|
141
141
|
}
|
|
142
|
+
function useTickerSubscriberCount(enabled = true) {
|
|
143
|
+
const [count, setCount] = useState(0);
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
if (!enabled) return;
|
|
146
|
+
const ticker = getTicker();
|
|
147
|
+
setCount(ticker.subscriberCount);
|
|
148
|
+
let last = 0;
|
|
149
|
+
return ticker.onBudget(() => {
|
|
150
|
+
const now = performance.now();
|
|
151
|
+
if (now - last < 250) return;
|
|
152
|
+
last = now;
|
|
153
|
+
setCount(ticker.subscriberCount);
|
|
154
|
+
});
|
|
155
|
+
}, [enabled]);
|
|
156
|
+
return count;
|
|
157
|
+
}
|
|
142
158
|
function useMergedRef(...refs) {
|
|
143
159
|
return useCallback((node) => {
|
|
144
160
|
for (const ref of refs) {
|
|
@@ -149,6 +165,6 @@ function useMergedRef(...refs) {
|
|
|
149
165
|
}, refs);
|
|
150
166
|
}
|
|
151
167
|
|
|
152
|
-
export { useElementSize, useFrameBudget, useInView, useMergedRef, usePointer, useReducedMotion, useScrollProgress, useTicker, useWindowScroll };
|
|
153
|
-
//# sourceMappingURL=chunk-
|
|
154
|
-
//# sourceMappingURL=chunk-
|
|
168
|
+
export { useElementSize, useFrameBudget, useInView, useMergedRef, usePointer, useReducedMotion, useScrollProgress, useTicker, useTickerSubscriberCount, useWindowScroll };
|
|
169
|
+
//# sourceMappingURL=chunk-P5MRISBP.js.map
|
|
170
|
+
//# sourceMappingURL=chunk-P5MRISBP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-observers.ts"],"names":[],"mappings":";;;;AAuBO,SAAS,SAAA,CACd,QAAA,EACA,OAAA,GAII,EAAC,EACC;AACN,EAAA,MAAM,WAAA,GAAc,OAAO,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,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,OAAA,EAAS;AACd,IAAA,MAAM,SAAS,SAAA,EAAU;AACzB,IAAA,OAAO,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,KAAU,WAAA,CAAY,OAAA,CAAQ,KAAK,CAAA,EAAG,EAAE,KAAA,EAAO,QAAA,EAAU,IAAA,EAAM,aAAa,CAAA;AAAA,EACjG,CAAA,EAAG,CAAC,KAAA,EAAO,QAAA,EAAU,OAAO,CAAC,CAAA;AAC/B;AAkBO,SAAS,SAAA,CACd,OAAA,GAAyB,EAAC,EACO;AACjC,EAAA,MAAM,GAAA,GAAM,OAAkB,IAAI,CAAA;AAClC,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAI,SAAS,KAAK,CAAA;AAE1C,EAAA,MAAM,EAAE,YAAY,CAAA,EAAG,UAAA,GAAa,OAAO,IAAA,GAAO,KAAA,EAAO,IAAA,GAAO,IAAA,EAAK,GAAI,OAAA;AAEzE,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,UAAU,GAAA,CAAI,OAAA;AACpB,IAAA,IAAI,CAAC,OAAA,EAAS;AAEd,IAAA,IAAI,QAAA,GAA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CAAO,SAAS,MAAM;AAC3B,MAAA,MAAM,GAAA,GAAM,YAAY,GAAA,EAAI;AAC5B,MAAA,IAAI,GAAA,GAAM,OAAO,GAAA,EAAK;AACtB,MAAA,IAAA,GAAO,GAAA;AACP,MAAA,QAAA,CAAS,OAAO,eAAe,CAAA;AAAA,IACjC,CAAC,CAAA;AAAA,EACH,CAAA,EAAG,CAAC,OAAO,CAAC,CAAA;AAEZ,EAAA,OAAO,KAAA;AACT;AAGO,SAAS,gBACX,IAAA,EACuB;AAC1B,EAAA,OAAO,WAAA,CAAY,CAAC,IAAA,KAAmB;AACrC,IAAA,KAAA,MAAW,OAAO,IAAA,EAAM;AACtB,MAAA,IAAI,CAAC,GAAA,EAAK;AACV,MAAA,IAAI,OAAO,GAAA,KAAQ,UAAA,EAAY,GAAA,CAAI,IAAI,CAAA;AAAA,WACjC,IAAyC,OAAA,GAAU,IAAA;AAAA,IAC3D;AAAA,EAEF,GAAG,IAAI,CAAA;AACT","file":"chunk-P5MRISBP.js","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"]}
|
|
@@ -5,6 +5,7 @@ var chunkSFU5EPSN_cjs = require('./chunk-SFU5EPSN.cjs');
|
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
|
|
8
|
+
// src/components/layout/shared.ts
|
|
8
9
|
function space(value) {
|
|
9
10
|
if (value === void 0) return void 0;
|
|
10
11
|
if (typeof value === "string") return value;
|
|
@@ -329,5 +330,5 @@ exports.ScrollArea = ScrollArea;
|
|
|
329
330
|
exports.Spacer = Spacer;
|
|
330
331
|
exports.Stack = Stack;
|
|
331
332
|
exports.VStack = VStack;
|
|
332
|
-
//# sourceMappingURL=chunk-
|
|
333
|
-
//# sourceMappingURL=chunk-
|
|
333
|
+
//# sourceMappingURL=chunk-PUW6BTPQ.cjs.map
|
|
334
|
+
//# sourceMappingURL=chunk-PUW6BTPQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/layout/shared.ts","../src/components/layout/stack.tsx","../src/components/layout/grid.tsx","../src/components/layout/container.tsx","../src/components/layout/divider.tsx","../src/components/layout/spacer.tsx","../src/components/layout/center.tsx","../src/components/layout/aspect-ratio.tsx","../src/components/layout/scroll-area.tsx","../src/components/layout/resizable.tsx"],"names":["forwardRef","Stack","jsx","cx","HStack","VStack","Grid","GridItem","Container","Divider","jsxs","Center","AspectRat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AS,CAAC,CAAA,EAAE;AAAA;AAAA;AAAA,GACjD;AAEJ","file":"chunk-PUW6BTPQ.cjs","sourcesContent":["import type { ElementType, HTMLAttributes, ReactNode } from 'react'\n\n/**\n * Layout primitives.\n *\n * These exist because every application rebuilds them, badly. The rebuilt versions hardcode gaps in\n * pixels, so they don't respond to a density setting; they use margins, so they collapse\n * unpredictably; and they don't handle the RTL case.\n *\n * Everything here takes a **token key**, not a raw value: `gap={4}` means `--ansh-space-4`, so a\n * layout is guaranteed to sit on the spacing scale. Passing an arbitrary string is still possible\n * for the genuine one-off, but the type nudges toward the scale first.\n */\n\n/** A key into the spacing scale, or a raw CSS length for the rare exception. */\nexport type SpaceToken =\n 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24 | (string & {})\n\nexport function space(value: SpaceToken | undefined): string | undefined {\n if (value === undefined) return undefined\n if (typeof value === 'string') return value\n return `var(--ansh-space-${value})`\n}\n\nexport interface BaseProps extends HTMLAttributes<HTMLElement> {\n as?: ElementType\n children?: ReactNode\n}\n","import { type CSSProperties, type ForwardedRef, forwardRef } from 'react'\nimport { cx } from '../../primitives/compose'\nimport { type BaseProps, type SpaceToken, space } from './shared'\n\nexport interface StackProps extends BaseProps {\n /** Default `'vertical'` — the direction that needs a helper more often. */\n direction?: 'horizontal' | 'vertical'\n gap?: SpaceToken\n align?: CSSProperties['alignItems']\n justify?: CSSProperties['justifyContent']\n wrap?: boolean\n /** Grow to fill the cross axis. */\n stretch?: boolean\n /** Insert a hairline divider between children. */\n divide?: boolean\n}\n\n/**\n * One-dimensional flex layout.\n *\n * ```tsx\n * <Stack direction=\"horizontal\" gap={3} align=\"center\">\n * <Avatar src={user.avatar} name={user.name} />\n * <Stack gap={0.5}>\n * <strong>{user.name}</strong>\n * <Text tone=\"secondary\">{user.email}</Text>\n * </Stack>\n * </Stack>\n * ```\n */\nexport const Stack = forwardRef(function Stack(\n {\n as: Component = 'div',\n direction = 'vertical',\n gap = 4,\n align,\n justify,\n wrap = false,\n stretch = false,\n divide = false,\n className,\n style,\n ...rest\n }: StackProps,\n ref: ForwardedRef<HTMLElement>,\n) {\n return (\n <Component\n ref={ref}\n className={cx('ansh-stack', divide && 'ansh-stack--divide', className)}\n data-direction={direction}\n style={{\n display: 'flex',\n flexDirection: direction === 'horizontal' ? 'row' : 'column',\n gap: space(gap),\n alignItems: align ?? (stretch ? 'stretch' : undefined),\n justifyContent: justify,\n flexWrap: wrap ? 'wrap' : undefined,\n ...style,\n }}\n {...rest}\n />\n )\n})\n\n/** Horizontal `Stack`, for readability at call sites. */\nexport const HStack = forwardRef(function HStack(\n props: Omit<StackProps, 'direction'>,\n ref: ForwardedRef<HTMLElement>,\n) {\n return <Stack ref={ref} direction=\"horizontal\" {...props} />\n})\n\n/** Vertical `Stack`, for symmetry with `HStack`. */\nexport const VStack = forwardRef(function VStack(\n props: Omit<StackProps, 'direction'>,\n ref: ForwardedRef<HTMLElement>,\n) {\n return <Stack ref={ref} direction=\"vertical\" {...props} />\n})\n","import { type CSSProperties, type ForwardedRef, forwardRef } from 'react'\nimport { cx } from '../../primitives/compose'\nimport { type BaseProps, type SpaceToken, space } from './shared'\n\nexport interface GridProps extends BaseProps {\n /** Fixed column count, or `'auto'` for a responsive `auto-fill` track. */\n columns?: number | 'auto'\n /** Minimum column width when `columns=\"auto\"`. Default `'16rem'`. */\n minColumnWidth?: string\n gap?: SpaceToken\n /** Row gap, when it should differ from the column gap. */\n rowGap?: SpaceToken\n align?: CSSProperties['alignItems']\n}\n\n/**\n * Two-dimensional layout.\n *\n * `columns=\"auto\"` uses `repeat(auto-fill, minmax(min(N, 100%), 1fr))`. The inner `min()` is what\n * stops the grid overflowing on a phone: without it, a 16rem minimum on a 15rem-wide viewport\n * produces a track wider than the screen and a horizontal scrollbar.\n */\nexport const Grid = forwardRef(function Grid(\n {\n as: Component = 'div',\n columns = 'auto',\n minColumnWidth = '16rem',\n gap = 4,\n rowGap,\n align,\n className,\n style,\n ...rest\n }: GridProps,\n ref: ForwardedRef<HTMLElement>,\n) {\n return (\n <Component\n ref={ref}\n className={cx('ansh-grid', className)}\n style={{\n display: 'grid',\n gridTemplateColumns:\n columns === 'auto'\n ? `repeat(auto-fill, minmax(min(${minColumnWidth}, 100%), 1fr))`\n : `repeat(${columns}, minmax(0, 1fr))`,\n gap: space(gap),\n rowGap: space(rowGap),\n alignItems: align,\n ...style,\n }}\n {...rest}\n />\n )\n})\n\nexport interface GridItemProps extends BaseProps {\n /** Columns to span. `'full'` spans the whole row. */\n span?: number | 'full'\n rowSpan?: number\n}\n\nexport const GridItem = forwardRef(function GridItem(\n { as: Component = 'div', span, rowSpan, className, style, ...rest }: GridItemProps,\n ref: ForwardedRef<HTMLElement>,\n) {\n return (\n <Component\n ref={ref}\n className={className}\n style={{\n gridColumn: span === 'full' ? '1 / -1' : span ? `span ${span} / span ${span}` : undefined,\n gridRow: rowSpan ? `span ${rowSpan} / span ${rowSpan}` : undefined,\n // `minWidth: 0` on every grid child. Without it a child containing a long unbroken string\n // or a table refuses to shrink below its content width and blows out the track.\n minWidth: 0,\n ...style,\n }}\n {...rest}\n />\n )\n})\n","import { type ForwardedRef, forwardRef } from 'react'\nimport { cx } from '../../primitives/compose'\nimport { type BaseProps, type SpaceToken, space } from './shared'\n\nexport interface ContainerProps extends BaseProps {\n /** Max content width. Default `'lg'` (72rem). */\n size?: 'sm' | 'md' | 'lg' | 'xl' | 'full'\n /** Horizontal padding. Default `6`. */\n padding?: SpaceToken\n}\n\nconst CONTAINER_WIDTH = {\n sm: '40rem',\n md: '56rem',\n lg: '72rem',\n xl: '90rem',\n full: '100%',\n} as const\n\n/** Centred, width-constrained page content. */\nexport const Container = forwardRef(function Container(\n { as: Component = 'div', size = 'lg', padding = 6, className, style, ...rest }: ContainerProps,\n ref: ForwardedRef<HTMLElement>,\n) {\n return (\n <Component\n ref={ref}\n className={cx('ansh-container', className)}\n style={{\n width: '100%',\n maxWidth: CONTAINER_WIDTH[size],\n marginInline: 'auto',\n paddingInline: space(padding),\n ...style,\n }}\n {...rest}\n />\n )\n})\n","import { type ForwardedRef, type HTMLAttributes, type ReactNode, forwardRef } from 'react'\nimport { cx } from '../../primitives/compose'\nimport { type BaseProps } from './shared'\n\nexport interface DividerProps extends Omit<BaseProps, 'children'> {\n orientation?: 'horizontal' | 'vertical'\n /** Optional label rendered in the middle of the rule. */\n label?: ReactNode\n}\n\n/**\n * A rule.\n *\n * With a label it becomes a labelled separator — the \"or continue with\" divider on a sign-in form.\n * `role=\"separator\"` is set only when there's no label; with one, it's a heading-like element and\n * announcing it as a separator loses the text.\n */\nexport const Divider = forwardRef(function Divider(\n { orientation = 'horizontal', label, className, ...rest }: DividerProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n if (label) {\n return (\n <div\n ref={ref}\n className={cx('ansh-divider', 'ansh-divider--labelled', className)}\n {...(rest as HTMLAttributes<HTMLDivElement>)}\n >\n <span className=\"ansh-divider__line\" />\n <span className=\"ansh-divider__label\">{label}</span>\n <span className=\"ansh-divider__line\" />\n </div>\n )\n }\n\n return (\n <div\n ref={ref}\n role=\"separator\"\n aria-orientation={orientation}\n className={cx('ansh-divider', `ansh-divider--${orientation}`, className)}\n {...(rest as HTMLAttributes<HTMLDivElement>)}\n />\n )\n})\n","import { type SpaceToken, space } from './shared'\n\nexport interface SpacerProps {\n size?: SpaceToken\n /** Grow to absorb free space in a flex container. */\n grow?: boolean\n}\n\n/** Explicit empty space. `grow` pushes siblings apart in a flex row. */\nexport function Spacer({ size, grow = false }: SpacerProps) {\n return (\n <span\n aria-hidden=\"true\"\n style={{\n display: 'block',\n flexGrow: grow ? 1 : 0,\n flexShrink: 0,\n ...(size !== undefined ? { width: space(size), height: space(size) } : null),\n }}\n />\n )\n}\n","import { type ForwardedRef, forwardRef } from 'react'\nimport { type BaseProps } from './shared'\n\n/** Centre a child on both axes. */\nexport const Center = forwardRef(function Center(\n { as: Component = 'div', className, style, ...rest }: BaseProps,\n ref: ForwardedRef<HTMLElement>,\n) {\n return (\n <Component\n ref={ref}\n className={className}\n style={{ display: 'grid', placeItems: 'center', ...style }}\n {...rest}\n />\n )\n})\n","import { type ForwardedRef, forwardRef } from 'react'\nimport { cx } from '../../primitives/compose'\nimport type { BaseProps } from './shared'\n\nexport interface AspectRatioProps extends BaseProps {\n /** Width ÷ height. `16 / 9` reads better than `1.777`. Default `16 / 9`. */\n ratio?: number\n}\n\n/**\n * Reserve space at a fixed aspect ratio.\n *\n * Uses the `aspect-ratio` property rather than the padding-top hack. The reserved space is what\n * matters: an image that loads without it shifts everything below, which is a Cumulative Layout\n * Shift penalty and the most common cause of a failing Core Web Vitals score.\n */\nexport const AspectRatio = forwardRef(function AspectRatio(\n { as: Component = 'div', ratio = 16 / 9, className, style, ...rest }: AspectRatioProps,\n ref: ForwardedRef<HTMLElement>,\n) {\n return (\n <Component\n ref={ref}\n className={cx('ansh-aspect', className)}\n style={{ aspectRatio: String(ratio), ...style }}\n {...rest}\n />\n )\n})\n","import { type ForwardedRef, forwardRef } from 'react'\nimport { cx } from '../../primitives/compose'\nimport { type BaseProps } from './shared'\n\nexport interface ScrollAreaProps extends BaseProps {\n /** Max height before scrolling starts. */\n maxHeight?: string\n axis?: 'y' | 'x' | 'both'\n /** Fade the content at the scrollable edges. Default `true`. */\n fade?: boolean\n}\n\n/**\n * A scroll container with styled scrollbars and edge fades.\n *\n * The native scrollbar is kept — a JavaScript-rendered one breaks keyboard scrolling, mobile\n * momentum, and the OS \"scroll bar is always visible\" accessibility setting. It is only *styled*,\n * via `scrollbar-width`/`scrollbar-color` with a `::-webkit-scrollbar` fallback.\n *\n * The edge fade is a mask that appears only when there is more content in that direction. It is\n * driven by `animation-timeline: scroll()` where supported, so it costs nothing on the main thread\n * and degrades to no fade where it isn't.\n */\nexport const ScrollArea = forwardRef(function ScrollArea(\n {\n as: Component = 'div',\n maxHeight,\n axis = 'y',\n fade = true,\n className,\n style,\n ...rest\n }: ScrollAreaProps,\n ref: ForwardedRef<HTMLElement>,\n) {\n return (\n <Component\n ref={ref}\n className={cx('ansh-scroll', fade && 'ansh-scroll--fade', className)}\n data-axis={axis}\n style={{\n maxHeight,\n overflowY: axis === 'x' ? 'hidden' : 'auto',\n overflowX: axis === 'y' ? 'hidden' : 'auto',\n ...style,\n }}\n {...rest}\n />\n )\n})\n","import { type ReactNode, useCallback, useEffect, useRef, useState } from 'react'\nimport { cx } from '../../primitives/compose'\nimport { useControllableState } from '../../primitives/use-controllable-state'\n\nexport interface ResizableProps {\n /** Exactly two children: the two panes. */\n children: [ReactNode, ReactNode]\n direction?: 'horizontal' | 'vertical'\n /** First pane's size as a percentage, `0`–`100`. Default `50`. */\n defaultSize?: number\n size?: number\n onSizeChange?: (size: number) => void\n /** Clamp, as percentages. Defaults `10` and `90`. */\n minSize?: number\n maxSize?: number\n /** Snap points in percent, e.g. `[25, 50, 75]`. Within 3% the handle snaps. */\n snapPoints?: readonly number[]\n className?: string\n /** Accessible name for the handle — \"Resize sidebar\", not \"Resize\". */\n label?: string\n}\n\n/**\n * A two-pane split with a draggable divider.\n *\n * The layout every IDE, mail client and admin console needs, and the one most often shipped as\n * mouse-only. The handle here is a real `role=\"separator\"` with `aria-valuenow`, and arrow keys\n * move it in 2% steps — WAI-ARIA calls this a window splitter and it is a documented pattern, not\n * an invention.\n *\n * Sizes are percentages rather than pixels so the split survives a window resize proportionally.\n * Dragging writes to a CSS custom property directly, bypassing React: a re-render per pointer move\n * makes the drag feel heavy on a complex page, and the value is only committed to state on release.\n */\nexport function Resizable({\n children,\n direction = 'horizontal',\n defaultSize = 50,\n size,\n onSizeChange,\n minSize = 10,\n maxSize = 90,\n snapPoints,\n className,\n label = 'Resize panes',\n}: ResizableProps) {\n const [value, setValue] = useControllableState<number>({\n value: size,\n defaultValue: defaultSize,\n onChange: onSizeChange,\n })\n\n const containerRef = useRef<HTMLDivElement | null>(null)\n const [dragging, setDragging] = useState(false)\n\n const clamp = useCallback(\n (next: number) => {\n let result = Math.min(Math.max(next, minSize), maxSize)\n if (snapPoints) {\n for (const point of snapPoints) {\n if (Math.abs(result - point) < 3) {\n result = point\n break\n }\n }\n }\n return result\n },\n [minSize, maxSize, snapPoints],\n )\n\n const onPointerDown = (event: React.PointerEvent<HTMLDivElement>) => {\n const container = containerRef.current\n if (!container) return\n\n // Pointer capture keeps events coming to the handle even when the pointer outruns it, which\n // it will — a fast drag easily leaves the 8px handle behind and the drag would otherwise stop\n // dead mid-gesture.\n event.currentTarget.setPointerCapture(event.pointerId)\n setDragging(true)\n\n let latest = value\n\n const onMove = (moveEvent: PointerEvent) => {\n const rect = container.getBoundingClientRect()\n const fraction =\n direction === 'horizontal'\n ? (moveEvent.clientX - rect.left) / rect.width\n : (moveEvent.clientY - rect.top) / rect.height\n\n latest = clamp(fraction * 100)\n // Written straight to the DOM. React state is updated once, on release.\n container.style.setProperty('--ansh-split', `${latest}%`)\n }\n\n const onUp = () => {\n setDragging(false)\n setValue(latest)\n window.removeEventListener('pointermove', onMove)\n window.removeEventListener('pointerup', onUp)\n window.removeEventListener('pointercancel', onUp)\n }\n\n window.addEventListener('pointermove', onMove)\n window.addEventListener('pointerup', onUp)\n window.addEventListener('pointercancel', onUp)\n }\n\n const onKeyDown = (event: React.KeyboardEvent) => {\n const step = event.shiftKey ? 10 : 2\n const forward = direction === 'horizontal' ? 'ArrowRight' : 'ArrowDown'\n const backward = direction === 'horizontal' ? 'ArrowLeft' : 'ArrowUp'\n\n let next: number | null = null\n if (event.key === forward) next = value + step\n else if (event.key === backward) next = value - step\n else if (event.key === 'Home') next = minSize\n else if (event.key === 'End') next = maxSize\n // Enter toggles between collapsed and the midpoint — the shortcut people expect from a\n // collapsible sidebar, and the only way to fully collapse without a mouse.\n else if (event.key === 'Enter') next = value <= minSize + 1 ? 50 : minSize\n\n if (next === null) return\n event.preventDefault()\n setValue(clamp(next))\n }\n\n // Keep the custom property in sync when the value changes from outside a drag (controlled\n // updates, keyboard steps). During a drag the pointer handler owns it.\n useEffect(() => {\n if (dragging) return\n containerRef.current?.style.setProperty('--ansh-split', `${value}%`)\n }, [value, dragging])\n\n return (\n <div\n ref={containerRef}\n className={cx(\n 'ansh-split',\n `ansh-split--${direction}`,\n dragging && 'ansh-split--dragging',\n className,\n )}\n style={{ ['--ansh-split' as string]: `${value}%` }}\n >\n <div className=\"ansh-split__pane\">{children[0]}</div>\n\n <div\n role=\"separator\"\n tabIndex={0}\n aria-label={label}\n aria-orientation={direction === 'horizontal' ? 'vertical' : 'horizontal'}\n aria-valuenow={Math.round(value)}\n aria-valuemin={minSize}\n aria-valuemax={maxSize}\n className=\"ansh-split__handle ansh-focusable\"\n onPointerDown={onPointerDown}\n onKeyDown={onKeyDown}\n // Double-click resets to centre. Undocumented in the UI but universally expected, and\n // harmless to discover by accident.\n onDoubleClick={() => setValue(50)}\n >\n <span className=\"ansh-split__grip\" aria-hidden=\"true\" />\n </div>\n\n <div className=\"ansh-split__pane\">{children[1]}</div>\n </div>\n )\n}\n"]}
|