@onlynative/inertia 0.0.1-alpha.7 → 0.0.1-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +1 -1
  2. package/dist/gestureLayer/index.d.mts +119 -0
  3. package/dist/gestureLayer/index.d.ts +119 -0
  4. package/dist/gestureLayer/index.js +346 -0
  5. package/dist/gestureLayer/index.js.map +1 -0
  6. package/dist/gestureLayer/index.mjs +344 -0
  7. package/dist/gestureLayer/index.mjs.map +1 -0
  8. package/dist/index.d.mts +114 -74
  9. package/dist/index.d.ts +114 -74
  10. package/dist/index.js +388 -1542
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +388 -1545
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/motion/Image.d.mts +1 -1
  15. package/dist/motion/Image.d.ts +1 -1
  16. package/dist/motion/Image.js +244 -1462
  17. package/dist/motion/Image.js.map +1 -1
  18. package/dist/motion/Image.mjs +247 -1465
  19. package/dist/motion/Image.mjs.map +1 -1
  20. package/dist/motion/Pressable.d.mts +1 -1
  21. package/dist/motion/Pressable.d.ts +1 -1
  22. package/dist/motion/Pressable.js +244 -1462
  23. package/dist/motion/Pressable.js.map +1 -1
  24. package/dist/motion/Pressable.mjs +247 -1465
  25. package/dist/motion/Pressable.mjs.map +1 -1
  26. package/dist/motion/ScrollView.d.mts +1 -1
  27. package/dist/motion/ScrollView.d.ts +1 -1
  28. package/dist/motion/ScrollView.js +244 -1462
  29. package/dist/motion/ScrollView.js.map +1 -1
  30. package/dist/motion/ScrollView.mjs +247 -1465
  31. package/dist/motion/ScrollView.mjs.map +1 -1
  32. package/dist/motion/Text.d.mts +1 -1
  33. package/dist/motion/Text.d.ts +1 -1
  34. package/dist/motion/Text.js +244 -1462
  35. package/dist/motion/Text.js.map +1 -1
  36. package/dist/motion/Text.mjs +247 -1465
  37. package/dist/motion/Text.mjs.map +1 -1
  38. package/dist/motion/View.d.mts +1 -1
  39. package/dist/motion/View.d.ts +1 -1
  40. package/dist/motion/View.js +244 -1462
  41. package/dist/motion/View.js.map +1 -1
  42. package/dist/motion/View.mjs +247 -1465
  43. package/dist/motion/View.mjs.map +1 -1
  44. package/dist/touch/index.d.mts +146 -0
  45. package/dist/touch/index.d.ts +146 -0
  46. package/dist/touch/index.js +166 -0
  47. package/dist/touch/index.js.map +1 -0
  48. package/dist/touch/index.mjs +164 -0
  49. package/dist/touch/index.mjs.map +1 -0
  50. package/dist/{types-NmNeJjo1.d.mts → types-cU43dEmH.d.mts} +64 -17
  51. package/dist/{types-NmNeJjo1.d.ts → types-cU43dEmH.d.ts} +64 -17
  52. package/dist/useGesture-B7A_1DVg.d.ts +84 -0
  53. package/dist/useGesture-cimMrzC1.d.mts +84 -0
  54. package/jest-setup.js +4 -0
  55. package/llms.txt +12 -3
  56. package/package.json +22 -2
  57. package/src/__type-tests__/variants.test-d.tsx +67 -0
  58. package/src/gestureLayer/index.ts +21 -0
  59. package/src/gestureLayer/useGestureLayer.ts +285 -0
  60. package/src/index.ts +7 -0
  61. package/src/layout/index.ts +15 -0
  62. package/src/layout/sharedRegistry.ts +111 -0
  63. package/src/layout/useSharedLayout.ts +289 -0
  64. package/src/motion/createMotionComponent.tsx +123 -37
  65. package/src/motion/installCheck.ts +7 -11
  66. package/src/touch/index.ts +18 -0
  67. package/src/touch/useTouchDrag.ts +289 -0
  68. package/src/types.ts +79 -20
  69. package/src/values/index.ts +11 -0
  70. package/src/values/useBooleanSpring.ts +33 -0
  71. package/src/values/useColorTransition.ts +72 -0
  72. package/src/values/useShadow.ts +116 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/config/MotionConfigContext.ts","../../src/transitions/easing.ts","../../src/transitions/spring.ts","../../src/transitions/resolve.ts","../../src/transitions/keys.ts","../../src/gestures/focusVisibility.ts","../../src/values/useGesture.ts","../../src/gestureLayer/useGestureLayer.ts"],"names":["createContext","useContext","useReducedMotion","isWorkletFunction","withSpring","withTiming","Easing","withDecay","withRepeat","withDelay","Platform","useSharedValue","useCallback","useMemo","useEffect","useAnimatedStyle","interpolateColor"],"mappings":";;;;;;;;AAwBO,IAAM,qBAAA,GAA2C;AAAA,EACtD,aAAA,EAAe;AACjB,CAAA;AAEO,IAAM,mBAAA,GAAsBA,mBAAA;AAAA,EACjC;AACF,CAAA;AAMO,SAAS,eAAA,GAAqC;AACnD,EAAA,OAAOC,iBAAW,mBAAmB,CAAA;AACvC;AAQO,SAAS,qBAAA,GAAiC;AAC/C,EAAA,MAAM,EAAE,aAAA,EAAc,GAAI,eAAA,EAAgB;AAC1C,EAAA,MAAM,YAAYC,sCAAA,EAAiB;AACnC,EAAA,IAAI,aAAA,KAAkB,SAAS,OAAO,KAAA;AACtC,EAAA,IAAI,aAAA,KAAkB,UAAU,OAAO,IAAA;AACvC,EAAA,OAAO,SAAA;AACT;ACzBO,SAAS,oBACd,MAAA,EACqC;AACrC,EAAA,IAAI,CAAC,QAAQ,OAAO,MAAA;AAIpB,EAAA,MAAM,KAAK,eAAA,CAAgB,MAAM,CAAA,GAAI,MAAA,CAAO,SAAQ,GAAI,MAAA;AACxD,EAAA,IAAIC,qCAAA,CAAkB,EAAE,CAAA,EAAG,OAAO,EAAA;AAClC,EAAA,MAAM,OAAA,GAAU,CAAC,CAAA,KAAc;AAC7B,IAAA,SAAA;AACA,IAAA,OAAO,GAAG,CAAC,CAAA;AAAA,EACb,CAAA;AACA,EAAA,OAAO,OAAA;AACT;AAEA,SAAS,gBACP,KAAA,EACmD;AACnD,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,SAAA,IAAa,KAAA,IACb,OAAQ,KAAA,CAA+B,OAAA,KAAY,UAAA;AAEvD;;;ACxCO,IAAM,cAAA,GAET;AAAA,EACF,OAAA,EAAS,GAAA;AAAA,EACT,QAAA,EAAU,EAAA;AAAA,EACV,IAAA,EAAM;AACR,CAAA;AAaO,SAAS,mBAAmB,CAAA,EAAqB;AACtD,EA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AAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["import { createContext, useContext } from 'react'\nimport { useReducedMotion } from 'react-native-reanimated'\n\n/**\n * How descendant Motion primitives should treat reduced-motion preferences.\n *\n * - `'user'` (default): defer to the OS accessibility setting via\n * Reanimated's `useReducedMotion()`. This is the only value that respects\n * user choice and is the right default for app-level wrappers.\n * - `'never'`: animate regardless of OS setting. Use sparingly — e.g. for\n * onboarding transitions you've decided are essential.\n * - `'always'`: never animate, regardless of OS setting. Useful for tests\n * and snapshots.\n */\nexport type ReducedMotion = 'user' | 'never' | 'always'\n\nexport interface MotionConfigValue {\n reducedMotion: ReducedMotion\n}\n\n/**\n * Default config used when a Motion primitive is rendered without a\n * `<MotionConfig>` ancestor. `'user'` means respect the OS setting.\n */\nexport const DEFAULT_MOTION_CONFIG: MotionConfigValue = {\n reducedMotion: 'user',\n}\n\nexport const MotionConfigContext = createContext<MotionConfigValue>(\n DEFAULT_MOTION_CONFIG,\n)\n\n/**\n * Read the active `<MotionConfig>` from a descendant. Returns the default\n * (`'user'`) when no provider is present.\n */\nexport function useMotionConfig(): MotionConfigValue {\n return useContext(MotionConfigContext)\n}\n\n/**\n * Resolve the active reduced-motion mode to a boolean. `'user'` consults\n * Reanimated's OS-backed hook; `'always'` / `'never'` shortcut. Motion\n * primitives call this to decide whether to swap transitions for\n * `no-animation`.\n */\nexport function useShouldReduceMotion(): boolean {\n const { reducedMotion } = useMotionConfig()\n const osReduced = useReducedMotion()\n if (reducedMotion === 'never') return false\n if (reducedMotion === 'always') return true\n return osReduced\n}\n","// `isWorkletFunction` lives in `react-native-worklets` (the Reanimated 4 peer\n// dep); Reanimated's own re-export is deprecated.\nimport { isWorkletFunction } from 'react-native-worklets'\nimport { type EasingInput } from '../types'\n\n/**\n * Reanimated 3.9+ validates that easing functions used in nested-transition\n * contexts (variants, sequences, per-property maps) are worklets, and crashes\n * with `[Reanimated] The easing function is not a worklet` otherwise. The\n * library accepts plain functions on the public surface; this helper wraps\n * them so consumers don't have to think about the worklet boundary.\n *\n * If the input is already a worklet (has been processed by the worklets babel\n * plugin), it's returned as-is. Otherwise it's wrapped in a function whose\n * body declares the `'worklet'` directive — when our source is processed by\n * the consumer's worklets babel plugin (the default Expo/RN setup), the\n * wrapper becomes a real worklet that captures the user fn via closure.\n *\n * Reanimated 4 changed `Easing.bezier(...)` to return an\n * `EasingFunctionFactory` (`{ factory: () => EasingFunction }`) rather than\n * the function itself. The helper accepts both shapes — `EasingFunction` and\n * `EasingFunctionFactory` — and unwraps the factory automatically so\n * consumers don't have to call `.factory()` manually.\n *\n * The user fn must be pure: no JS-thread captured refs, no shared mutable\n * state, no calls to non-worklet APIs.\n */\nexport function ensureWorkletEasing(\n easing: EasingInput | undefined,\n): ((t: number) => number) | undefined {\n if (!easing) return undefined\n // Reanimated 4 `EasingFunctionFactory` — unwrap via `.factory()` before\n // checking worklet status, so the wrapped fn (not the factory wrapper)\n // ends up in the transition config.\n const fn = isEasingFactory(easing) ? easing.factory() : easing\n if (isWorkletFunction(fn)) return fn\n const wrapped = (t: number) => {\n 'worklet'\n return fn(t)\n }\n return wrapped\n}\n\nfunction isEasingFactory(\n value: EasingInput,\n): value is { factory: () => (t: number) => number } {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'factory' in value &&\n typeof (value as { factory: unknown }).factory === 'function'\n )\n}\n","import { type SpringTransition } from '../types'\n\n/**\n * Default spring physics, expressed in react-spring vocabulary.\n *\n * `tension: 170` / `friction: 26` / `mass: 1` was picked over Reanimated's\n * raw `stiffness: 100` / `damping: 10` default because the raw default\n * overshoots noticeably for the small (~100px) translates that dominate\n * UI work — buttons, sheets, popovers. These numbers settle in ~350ms with\n * a single, almost-imperceptible overshoot, which matches the perceptual\n * target the rest of the library is tuned against.\n */\nexport const DEFAULT_SPRING: Required<\n Pick<SpringTransition, 'tension' | 'friction' | 'mass'>\n> = {\n tension: 170,\n friction: 26,\n mass: 1,\n}\n\n/**\n * Convert public react-spring vocabulary (`tension` / `friction` / `mass`)\n * to Reanimated's raw `stiffness` / `damping` / `mass`. This is the single\n * place the mapping lives; resolvers, value hooks, and any future surface\n * that needs a Reanimated spring config import from here.\n *\n * The mapping is identity (tension ≡ stiffness, friction ≡ damping) — the\n * names differ but the underlying physics constants are the same. We don't\n * surface the raw names publicly because the react-spring vocabulary is\n * what designers and prior-art consumers expect.\n */\nexport function springToReanimated(t: SpringTransition) {\n 'worklet'\n return {\n stiffness: t.tension ?? DEFAULT_SPRING.tension,\n damping: t.friction ?? DEFAULT_SPRING.friction,\n mass: t.mass ?? DEFAULT_SPRING.mass,\n velocity: t.velocity,\n restSpeedThreshold: t.restSpeedThreshold,\n restDisplacementThreshold: t.restDisplacementThreshold,\n }\n}\n","import {\n Easing,\n withDecay,\n withDelay,\n withRepeat,\n withSequence,\n withSpring,\n withTiming,\n} from 'react-native-reanimated'\nimport { ensureWorkletEasing } from './easing'\nimport { springToReanimated } from './spring'\nimport {\n type AnimatableValue,\n type DecayTransition,\n type RepeatConfig,\n type SequenceStep,\n type SpringTransition,\n type TimingTransition,\n type TransitionConfig,\n} from '../types'\n\n/**\n * UI-thread callback Reanimated invokes when an animation settles. Must be a\n * worklet — callers either author one with `'worklet'` or build one via\n * `runOnJS(...)` to bridge to JS-thread code.\n */\nexport type AnimationCallback = (\n finished?: boolean,\n current?: number | string,\n) => void\n\n/**\n * Per-step callback factory. Resolvers call this with the step's phase and\n * sequence index (or `undefined` for non-sequence animations) and attach the\n * resulting callback to the underlying `withSpring` / `withTiming` /\n * `withDecay` call.\n */\nexport type CallbackFactory = (\n phase: 'step' | 'animation',\n step: number | undefined,\n) => AnimationCallback | undefined\n\nconst DEFAULT_TIMING_DURATION = 250\n\nfunction buildSpring(\n cfg: SpringTransition,\n toValue: number | string,\n cb?: AnimationCallback,\n) {\n return withSpring(toValue as number, springToReanimated(cfg), cb as never)\n}\n\nfunction buildTiming(\n cfg: TimingTransition,\n toValue: number | string,\n cb?: AnimationCallback,\n) {\n return withTiming(\n toValue as number,\n {\n duration: cfg.duration ?? DEFAULT_TIMING_DURATION,\n easing: ensureWorkletEasing(cfg.easing) ?? Easing.inOut(Easing.ease),\n },\n cb as never,\n )\n}\n\nfunction buildDecay(cfg: DecayTransition, cb?: AnimationCallback) {\n return withDecay(\n {\n velocity: cfg.velocity ?? 0,\n deceleration: cfg.deceleration,\n clamp: cfg.clamp,\n },\n cb as never,\n )\n}\n\n/**\n * Build a single-step animation (no repeat / no delay / no sequence) for a\n * given config + target. Pulled out so sequence steps can compose without\n * recursing into repeat/delay handling per step. The callback is forwarded\n * to Reanimated; for `no-animation` the callback is fired synchronously\n * since there's nothing to wait for.\n */\nfunction buildOne(\n cfg: TransitionConfig,\n toValue: number | string,\n cb?: AnimationCallback,\n): unknown {\n if (cfg.type === 'no-animation') {\n if (cb) cb(true, toValue)\n return toValue\n }\n if (cfg.type === 'decay') return buildDecay(cfg, cb)\n if (cfg.type === 'timing') return buildTiming(cfg, toValue, cb)\n return buildSpring(cfg as SpringTransition, toValue, cb)\n}\n\n/**\n * Wrap an animation in `withRepeat` per the unified `repeat` shape:\n * - `number` → finite count, alternating direction\n * - `'infinite'` → endless, alternating direction\n * - `{ count, alternate }`→ explicit; `alternate` defaults to `true`\n */\nfunction applyRepeat(animation: unknown, repeat: RepeatConfig | undefined) {\n if (repeat === undefined) return animation\n if (repeat === 'infinite') {\n return withRepeat(animation as never, -1, true)\n }\n if (typeof repeat === 'number') {\n return withRepeat(animation as never, repeat, true)\n }\n const count = repeat.count === 'infinite' ? -1 : repeat.count\n const alternate = repeat.alternate ?? true\n return withRepeat(animation as never, count, alternate)\n}\n\nfunction applyDelay(animation: unknown, delay: number | undefined) {\n if (!delay || delay <= 0) return animation\n return withDelay(delay, animation as never)\n}\n\n/**\n * Build a Reanimated animation for a single property. Runs on the JS thread\n * once per change and produces a baked `withSpring` / `withTiming` /\n * `withDecay` (optionally wrapped in `withDelay` / `withRepeat`) call. The\n * worklet body only consumes the result.\n *\n * `callback`, when provided, fires once when the underlying single-shot\n * animation settles. Repeat-wrapped animations forward the callback to\n * `withRepeat`, so it fires once per iteration as Reanimated does.\n */\nexport function resolveTransition(\n config: TransitionConfig | undefined,\n toValue: number | string,\n callback?: AnimationCallback,\n): unknown {\n const cfg = config ?? ({ type: 'spring' } as SpringTransition)\n const base = buildOne(cfg, toValue, callback)\n const repeated = applyRepeat(base, repeatOf(cfg))\n return applyDelay(repeated, delayOf(cfg))\n}\n\nfunction repeatOf(cfg: TransitionConfig): RepeatConfig | undefined {\n if (cfg.type === 'no-animation' || cfg.type === 'decay') return undefined\n return cfg.repeat\n}\n\n/**\n * Return `cfg` minus its `repeat` field. Used when peeling top-level repeat\n * off a base transition before passing it down to per-sequence-step\n * resolution — the sequence as a whole is what should repeat, not each step.\n */\nfunction stripRepeat(\n cfg: TransitionConfig | undefined,\n): TransitionConfig | undefined {\n if (!cfg) return cfg\n if (cfg.type === 'no-animation' || cfg.type === 'decay') return cfg\n if (cfg.repeat === undefined) return cfg\n const next = { ...cfg }\n delete next.repeat\n return next\n}\n\nfunction delayOf(cfg: TransitionConfig): number | undefined {\n if (cfg.type === 'no-animation') return undefined\n return cfg.delay\n}\n\n/**\n * True when the value is a `{ to, ...transitionOverride }` sequence step.\n * Plain numbers and plain transition objects fail this check.\n */\nfunction isStepObject<V>(\n v: SequenceStep<V> | V,\n): v is Extract<SequenceStep<V>, { to: V }> {\n return (\n typeof v === 'object' &&\n v !== null &&\n !Array.isArray(v) &&\n 'to' in (v as object)\n )\n}\n\n/**\n * Resolve a per-property `animate` value into a Reanimated animation.\n *\n * Handles the three shapes of `AnimatableValue`:\n * 1. plain value → single `resolveTransition` call\n * 2. `{ to, ...over }` → single step with the override merged into `base`\n * 3. array of either → `withSequence` of resolved steps, with the\n * top-level `repeat` applied at the **sequence level** (not per step).\n * Per-step `repeat` overrides remain step-local.\n */\nexport function resolveAnimatableValue<V extends number | string>(\n value: AnimatableValue<V>,\n base: TransitionConfig | undefined,\n factory?: CallbackFactory,\n): unknown {\n if (Array.isArray(value)) {\n const steps = value as ReadonlyArray<SequenceStep<V>>\n const stepBase = stripRepeat(base)\n const animations = steps.map((step, i) =>\n resolveStep(step, stepBase, factory?.('step', i)),\n )\n const seq = withSequence(...(animations as never[]))\n return applyRepeat(seq, base ? repeatOf(base) : undefined)\n }\n const step = value as SequenceStep<V>\n const cb = factory?.('animation', undefined)\n if (isStepObject<V>(step)) {\n return resolveStep(step, base, cb)\n }\n return resolveTransition(base, step as V, cb)\n}\n\nfunction resolveStep<V extends number | string>(\n step: SequenceStep<V>,\n base: TransitionConfig | undefined,\n cb?: AnimationCallback,\n): unknown {\n if (isStepObject<V>(step)) {\n const { to, ...override } = step as { to: V } & Partial<TransitionConfig>\n const merged = mergeTransition(base, override as Partial<TransitionConfig>)\n return resolveTransition(merged, to, cb)\n }\n return resolveTransition(base, step as V, cb)\n}\n\nfunction mergeTransition(\n base: TransitionConfig | undefined,\n override: Partial<TransitionConfig>,\n): TransitionConfig {\n // If the override declares a `type`, it wins outright — mixing fields from\n // a spring base into a timing override produces garbage. Otherwise inherit\n // the base's type and shallow-merge the rest.\n if (override.type && base && override.type !== base.type) {\n return override as TransitionConfig\n }\n return { ...(base ?? { type: 'spring' }), ...override } as TransitionConfig\n}\n","import { type TransitionConfig } from '../types'\n\n/**\n * Field names that may appear on a `TransitionConfig` (spring / timing /\n * decay / no-animation). Used as a structural discriminator: if every key on\n * an object is in this set, the object is treated as a top-level transition;\n * otherwise it's a per-property / per-layer transition map.\n *\n * Adding a new field to `TransitionConfig` requires adding the name here.\n */\nexport const TRANSITION_CONFIG_KEYS = new Set([\n 'type',\n 'tension',\n 'friction',\n 'mass',\n 'velocity',\n 'restSpeedThreshold',\n 'restDisplacementThreshold',\n 'duration',\n 'easing',\n 'delay',\n 'repeat',\n 'deceleration',\n 'clamp',\n])\n\nexport function isTopLevelTransition(t: unknown): t is TransitionConfig {\n if (t === null || typeof t !== 'object') return false\n const keys = Object.keys(t as object)\n if (keys.length === 0) return false\n return keys.every((k) => TRANSITION_CONFIG_KEYS.has(k))\n}\n","import { Platform } from 'react-native'\n\n/**\n * Input-modality tracker for the `focusVisible` gesture sub-state.\n *\n * Implements the W3C `:focus-visible` heuristic: a focus event counts as\n * \"visible\" only when the most recent user input was keyboard-driven. Mouse,\n * pointer, and touch events flip the modality to `'pointer'`; keyboard events\n * flip it back to `'keyboard'`.\n *\n * On native platforms there is no pointer-vs-keyboard distinction — focus\n * arrives via D-pad, screen reader, or hardware keyboard, all of which are\n * keyboard-equivalent — so `isFocusVisible()` is unconditionally `true`.\n *\n * The web listeners attach lazily on first call (capture phase, so they run\n * before the focus event reaches the focused element) and stay installed for\n * the lifetime of the document. They are passive and idle-cheap; the cost is\n * one boolean read per `onFocus` dispatch.\n */\n\ntype InputModality = 'keyboard' | 'pointer'\n\n// Default to `'keyboard'` so a programmatic / autofocus that happens before\n// any user input still draws a focus ring — matches the W3C polyfill default.\nlet modality: InputModality = 'keyboard'\nlet installed = false\n\nfunction setKeyboard() {\n modality = 'keyboard'\n}\n\nfunction setPointer() {\n modality = 'pointer'\n}\n\nfunction ensureInstalled(): void {\n if (installed) return\n if (Platform.OS !== 'web') return\n if (typeof document === 'undefined') return\n document.addEventListener('keydown', setKeyboard, true)\n document.addEventListener('mousedown', setPointer, true)\n document.addEventListener('pointerdown', setPointer, true)\n document.addEventListener('touchstart', setPointer, true)\n installed = true\n}\n\n/**\n * `true` if the next `onFocus` should be treated as \"focus-visible\" (keyboard\n * focus). On native, always `true`. On web, reflects the most recent user\n * input modality.\n */\nexport function isFocusVisible(): boolean {\n if (Platform.OS !== 'web') return true\n ensureInstalled()\n return modality === 'keyboard'\n}\n\n/** @internal — test-only hook to reset module state between cases. */\nexport function __resetFocusVisibilityForTests(next: InputModality): void {\n modality = next\n}\n","import { useCallback, useMemo } from 'react'\nimport { useSharedValue, type SharedValue } from 'react-native-reanimated'\nimport { useShouldReduceMotion } from '../config'\nimport { isFocusVisible } from '../gestures'\nimport { isTopLevelTransition, resolveTransition } from '../transitions'\nimport { type GestureLayerTransitions, type TransitionConfig } from '../types'\n\ntype LayerName = 'pressed' | 'focused' | 'focusVisible' | 'hovered'\n\n/**\n * Handler bag returned by `useGesture`. Spread on a `Pressable` to drive the\n * shared values returned alongside.\n *\n * Hover handlers use `Pressable`'s own `onHoverIn` / `onHoverOut` names (web\n * only — no-ops on native). `onFocus` consults `isFocusVisible()` before\n * raising the keyboard-only `focusVisible` layer; `focused` always raises.\n */\nexport interface UseGestureHandlers {\n onPressIn: () => void\n onPressOut: () => void\n onHoverIn: () => void\n onHoverOut: () => void\n onFocus: () => void\n onBlur: () => void\n}\n\nexport interface UseGestureResult {\n /** 0↔1 progress for the pressed layer. */\n pressed: SharedValue<number>\n /** 0↔1 progress for the focused layer (any focus modality). */\n focused: SharedValue<number>\n /** 0↔1 progress for the focusVisible layer (keyboard focus only). */\n focusVisible: SharedValue<number>\n /** 0↔1 progress for the hovered layer (web only — stays at 0 on native). */\n hovered: SharedValue<number>\n /** Handlers to spread on the receiving `Pressable`. */\n handlers: UseGestureHandlers\n}\n\n/**\n * Build a gesture-layer controller. The hook-form of the `gesture` prop —\n * reach for it when you need to drive multiple animated views from the same\n * gesture state (a focus ring + state-layer halo + content tint all on one\n * Pressable), which the prop-form's \"animate the receiver's own style\" model\n * can't express.\n *\n * Returns four 0↔1 shared values (one per layer) and a handler bag to spread\n * on a `Pressable`. The shared values are stable across renders — feed them\n * into any number of `useAnimatedStyle` blocks anywhere in the tree.\n *\n * Transitions follow the same shape as the `gesture` prop's accompanying\n * `transition`: pass a single `TransitionConfig` to use for every layer, or a\n * `GestureLayerTransitions` map to give each layer its own. Layers without an\n * explicit transition fall back to the library default spring.\n *\n * Reduced motion (via `<MotionConfig reducedMotion>`) collapses every\n * transition to `no-animation` so state changes snap instead of interpolating\n * — same behaviour the gesture prop applies.\n *\n * @example\n * ```tsx\n * import { useAnimatedStyle } from 'react-native-reanimated'\n * import { useGesture } from '@onlynative/inertia'\n *\n * function Card() {\n * const { pressed, focused, hovered, handlers } = useGesture({\n * pressed: { type: 'timing', duration: 100 },\n * hovered: { type: 'timing', duration: 150 },\n * focused: { type: 'timing', duration: 200 },\n * })\n *\n * const ringStyle = useAnimatedStyle(() => ({ opacity: focused.value }))\n * const haloStyle = useAnimatedStyle(() => ({\n * opacity: Math.max(\n * hovered.value * 0.08,\n * focused.value * 0.10,\n * pressed.value * 0.10,\n * ),\n * }))\n *\n * return (\n * <Pressable {...handlers}>\n * <Animated.View style={ringStyle} />\n * <Animated.View style={haloStyle} />\n * </Pressable>\n * )\n * }\n * ```\n */\nexport function useGesture(\n transition?: TransitionConfig | GestureLayerTransitions,\n): UseGestureResult {\n const pressed = useSharedValue(0)\n const focused = useSharedValue(0)\n const focusVisible = useSharedValue(0)\n const hovered = useSharedValue(0)\n const shouldReduceMotion = useShouldReduceMotion()\n\n const setLayer = useCallback(\n (sv: SharedValue<number>, layer: LayerName, target: 0 | 1) => {\n const cfg = shouldReduceMotion\n ? ({ type: 'no-animation' } as const)\n : (layerTransition(layer, transition) ?? ({ type: 'spring' } as const))\n sv.value = resolveTransition(cfg, target) as never\n },\n // The transition is intentionally read on every call rather than cooked\n // into the dep array — a fresh literal each render would otherwise\n // rebuild the handler bag and break composing consumers that key off\n // handler identity. `transition` is read inside the callback closure;\n // shared values are stable so the only dep that matters is the reduce-\n // motion flag.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [shouldReduceMotion],\n )\n\n const handlers = useMemo<UseGestureHandlers>(\n () => ({\n onPressIn: () => setLayer(pressed, 'pressed', 1),\n onPressOut: () => setLayer(pressed, 'pressed', 0),\n onHoverIn: () => setLayer(hovered, 'hovered', 1),\n onHoverOut: () => setLayer(hovered, 'hovered', 0),\n onFocus: () => {\n setLayer(focused, 'focused', 1)\n if (isFocusVisible()) setLayer(focusVisible, 'focusVisible', 1)\n },\n onBlur: () => {\n setLayer(focused, 'focused', 0)\n setLayer(focusVisible, 'focusVisible', 0)\n },\n }),\n [setLayer, pressed, focused, focusVisible, hovered],\n )\n\n return { pressed, focused, focusVisible, hovered, handlers }\n}\n\nfunction layerTransition(\n layer: LayerName,\n transition: TransitionConfig | GestureLayerTransitions | undefined,\n): TransitionConfig | undefined {\n if (!transition) return undefined\n if (isTopLevelTransition(transition)) return transition\n return (transition as GestureLayerTransitions)[layer]\n}\n","import { useEffect, useMemo } from 'react'\nimport {\n interpolateColor,\n useAnimatedStyle,\n useSharedValue,\n type AnimatedStyle,\n} from 'react-native-reanimated'\nimport { useShouldReduceMotion } from '../config'\nimport { isTopLevelTransition, resolveTransition } from '../transitions'\nimport { useGesture, type UseGestureHandlers } from '../values/useGesture'\nimport { type GestureLayerTransitions, type TransitionConfig } from '../types'\n\n/**\n * A single gesture-layer style — a flat map of style keys to a value. Numeric\n * values participate in clamped-max composition (the \"strongest active layer\n * wins\" model used by MD3 state-layer haloes); string values are treated as\n * colors and composed via priority cascade with `interpolateColor`.\n *\n * The hook does not validate that string values are valid colors — passing\n * something like `borderStyle: 'solid'` will crash inside the worklet. Keep\n * string values to color strings.\n */\nexport type GestureLayerStyle = {\n [key: string]: number | string | undefined\n}\n\n/**\n * Per-state style maps. Every key is optional; missing layers default to\n * `rest` (or `0` / `'transparent'` if `rest` is also absent for that key).\n *\n * - `rest` — base values, applied when no other layer is active.\n * - `hovered` / `focused` / `focusVisible` / `pressed` — gesture-driven\n * states tracked via the underlying `useGesture` hook. Each owns an\n * independent 0↔1 progress that fades the layer in/out per the configured\n * transition.\n * - `disabled` — gated by the JS-side `options.disabled` flag rather than a\n * gesture. Sits at the top of the priority cascade and overrides every\n * gesture layer when active.\n */\nexport interface GestureLayerStates {\n rest?: GestureLayerStyle\n hovered?: GestureLayerStyle\n focused?: GestureLayerStyle\n focusVisible?: GestureLayerStyle\n pressed?: GestureLayerStyle\n disabled?: GestureLayerStyle\n}\n\nexport interface UseGestureLayerOptions {\n /**\n * When `true`, the `disabled` layer becomes active (or `rest` if `disabled`\n * is undefined). Animates via the top-level transition or the library\n * default spring; per-layer transitions (`GestureLayerTransitions`) do not\n * apply to `disabled`.\n */\n disabled?: boolean\n /**\n * Transition forwarded to the underlying `useGesture` hook. Either a single\n * `TransitionConfig` for every gesture layer, or a `GestureLayerTransitions`\n * map for per-layer fades. Reduced motion collapses every transition to\n * `no-animation`.\n */\n transition?: TransitionConfig | GestureLayerTransitions\n}\n\nexport interface UseGestureLayerResult {\n /**\n * Animated style produced by `useAnimatedStyle` — spread on an\n * `Animated.View` or pass through `<Motion.View style={...} />`.\n */\n style: AnimatedStyle<Record<string, unknown>>\n /** Handlers to spread on the receiving `Pressable`. */\n handlers: UseGestureHandlers\n}\n\n/**\n * A \"strongest active layer wins\" interactive-feedback primitive. Sits one\n * step above `useGesture()` — the consumer supplies the per-state target\n * values, the hook handles the four gesture progress shared values, the\n * disabled override, the worklet, and the transition.\n *\n * Composition model:\n *\n * - **Numeric keys** (opacity, scale, borderWidth, etc.) compose via\n * clamped-max with `rest` as the floor:\n * `out = max(rest, ...for each active gesture layer: lerp(rest, layer, progress))`.\n * This matches the MD3 state-layer halo pattern — multiple states active\n * simultaneously raise the value to the strongest, not the sum.\n * - **Color keys** (any string value) compose via priority cascade with\n * `interpolateColor`, lowest priority first: `hovered → focused →\n * focusVisible → pressed`. Clamped-max doesn't apply to colors; this\n * matches the cascade used by the declarative `gesture` prop.\n * - **Disabled** sits at the top of the cascade for both numeric and color\n * keys — when active, it lerps the composed value toward the `disabled`\n * target.\n *\n * Reach for this when you want MD3 / iOS-translucent state-layer overlays\n * without rewriting the worklet by hand for every consumer; reach for plain\n * `useGesture()` when you need a composition model this hook doesn't\n * express (additive, multiply, per-key custom blends).\n *\n * @example MD3 state-layer halo\n * ```tsx\n * import { useGestureLayer } from '@onlynative/inertia/gesture-layer'\n * import Animated from 'react-native-reanimated'\n * import { Pressable } from 'react-native'\n *\n * function SwitchHalo({ disabled }: { disabled?: boolean }) {\n * const { style, handlers } = useGestureLayer(\n * {\n * rest: { opacity: 0, backgroundColor: 'transparent' },\n * hovered: { opacity: 0.08, backgroundColor: '#000' },\n * focused: { opacity: 0.10, backgroundColor: '#000' },\n * pressed: { opacity: 0.12, backgroundColor: '#000' },\n * },\n * { disabled, transition: { type: 'timing', duration: 150 } },\n * )\n *\n * return (\n * <Pressable {...handlers}>\n * <Animated.View style={style} />\n * </Pressable>\n * )\n * }\n * ```\n */\nexport function useGestureLayer(\n states: GestureLayerStates,\n options: UseGestureLayerOptions = {},\n): UseGestureLayerResult {\n const { disabled: isDisabled = false, transition } = options\n const shouldReduceMotion = useShouldReduceMotion()\n const gesture = useGesture(transition)\n const disabledProgress = useSharedValue(0)\n\n useEffect(() => {\n const target = isDisabled ? 1 : 0\n const cfg = shouldReduceMotion\n ? ({ type: 'no-animation' } as const)\n : (disabledTransition(transition) ?? ({ type: 'spring' } as const))\n disabledProgress.value = resolveTransition(cfg, target) as never\n }, [isDisabled, shouldReduceMotion, transition, disabledProgress])\n\n // JS-thread precompute: union of keys across all layers, per-key type\n // (number vs color), and a rest-fallback table. The worklet body reads\n // from `meta` instead of probing each layer per frame — the type check\n // only runs when layer identities change.\n const meta = useMemo(() => {\n const layers = {\n rest: states.rest,\n hovered: states.hovered,\n focused: states.focused,\n focusVisible: states.focusVisible,\n pressed: states.pressed,\n disabled: states.disabled,\n }\n const sources = [\n layers.rest,\n layers.hovered,\n layers.focused,\n layers.focusVisible,\n layers.pressed,\n layers.disabled,\n ]\n const keySet = new Set<string>()\n for (const src of sources) {\n if (!src) continue\n for (const k in src) if (src[k] !== undefined) keySet.add(k)\n }\n const keys = Array.from(keySet)\n const types: Record<string, 'number' | 'color'> = {}\n const restValues: Record<string, number | string> = {}\n for (const k of keys) {\n let firstDefined: number | string | undefined\n for (const src of sources) {\n if (src && src[k] !== undefined) {\n firstDefined = src[k]\n break\n }\n }\n const isColor = typeof firstDefined === 'string'\n types[k] = isColor ? 'color' : 'number'\n const restRaw = layers.rest ? layers.rest[k] : undefined\n restValues[k] =\n restRaw !== undefined ? restRaw : isColor ? 'transparent' : 0\n }\n return { layers, keys, types, restValues }\n }, [\n states.rest,\n states.hovered,\n states.focused,\n states.focusVisible,\n states.pressed,\n states.disabled,\n ])\n\n const style = useAnimatedStyle(() => {\n const { layers, keys, types, restValues } = meta\n const ph = gesture.hovered.value\n const pf = gesture.focused.value\n const pfv = gesture.focusVisible.value\n const pp = gesture.pressed.value\n const pd = disabledProgress.value\n\n const hoveredLayer = layers.hovered\n const focusedLayer = layers.focused\n const focusVisibleLayer = layers.focusVisible\n const pressedLayer = layers.pressed\n const disabledLayer = layers.disabled\n\n const out: Record<string, unknown> = {}\n\n for (let i = 0; i < keys.length; i++) {\n const k = keys[i]!\n const isColor = types[k] === 'color'\n const rest = restValues[k]!\n\n if (isColor) {\n let v = rest as string\n if (hoveredLayer && ph > 0 && hoveredLayer[k] !== undefined) {\n v = interpolateColor(ph, [0, 1], [v, hoveredLayer[k] as string])\n }\n if (focusedLayer && pf > 0 && focusedLayer[k] !== undefined) {\n v = interpolateColor(pf, [0, 1], [v, focusedLayer[k] as string])\n }\n if (\n focusVisibleLayer &&\n pfv > 0 &&\n focusVisibleLayer[k] !== undefined\n ) {\n v = interpolateColor(pfv, [0, 1], [v, focusVisibleLayer[k] as string])\n }\n if (pressedLayer && pp > 0 && pressedLayer[k] !== undefined) {\n v = interpolateColor(pp, [0, 1], [v, pressedLayer[k] as string])\n }\n if (disabledLayer && pd > 0 && disabledLayer[k] !== undefined) {\n v = interpolateColor(pd, [0, 1], [v, disabledLayer[k] as string])\n }\n out[k] = v\n } else {\n const base = rest as number\n let m = base\n if (hoveredLayer && ph > 0 && hoveredLayer[k] !== undefined) {\n const c = base + ((hoveredLayer[k] as number) - base) * ph\n if (c > m) m = c\n }\n if (focusedLayer && pf > 0 && focusedLayer[k] !== undefined) {\n const c = base + ((focusedLayer[k] as number) - base) * pf\n if (c > m) m = c\n }\n if (\n focusVisibleLayer &&\n pfv > 0 &&\n focusVisibleLayer[k] !== undefined\n ) {\n const c = base + ((focusVisibleLayer[k] as number) - base) * pfv\n if (c > m) m = c\n }\n if (pressedLayer && pp > 0 && pressedLayer[k] !== undefined) {\n const c = base + ((pressedLayer[k] as number) - base) * pp\n if (c > m) m = c\n }\n if (disabledLayer && pd > 0 && disabledLayer[k] !== undefined) {\n m = m + ((disabledLayer[k] as number) - m) * pd\n }\n out[k] = m\n }\n }\n\n return out\n })\n\n return {\n style: style as AnimatedStyle<Record<string, unknown>>,\n handlers: gesture.handlers,\n }\n}\n\nfunction disabledTransition(\n transition: TransitionConfig | GestureLayerTransitions | undefined,\n): TransitionConfig | undefined {\n if (!transition) return undefined\n if (isTopLevelTransition(transition)) return transition\n return undefined\n}\n"]}
@@ -0,0 +1,344 @@
1
+ import { createContext, useEffect, useMemo, useCallback, useContext } from 'react';
2
+ import { useSharedValue, useAnimatedStyle, interpolateColor, useReducedMotion, withRepeat, withDelay, withDecay, withTiming, Easing, withSpring } from 'react-native-reanimated';
3
+ import { isWorkletFunction } from 'react-native-worklets';
4
+ import { Platform } from 'react-native';
5
+
6
+ // src/gestureLayer/useGestureLayer.ts
7
+ var DEFAULT_MOTION_CONFIG = {
8
+ reducedMotion: "user"
9
+ };
10
+ var MotionConfigContext = createContext(
11
+ DEFAULT_MOTION_CONFIG
12
+ );
13
+ function useMotionConfig() {
14
+ return useContext(MotionConfigContext);
15
+ }
16
+ function useShouldReduceMotion() {
17
+ const { reducedMotion } = useMotionConfig();
18
+ const osReduced = useReducedMotion();
19
+ if (reducedMotion === "never") return false;
20
+ if (reducedMotion === "always") return true;
21
+ return osReduced;
22
+ }
23
+ function ensureWorkletEasing(easing) {
24
+ if (!easing) return void 0;
25
+ const fn = isEasingFactory(easing) ? easing.factory() : easing;
26
+ if (isWorkletFunction(fn)) return fn;
27
+ const wrapped = (t) => {
28
+ "worklet";
29
+ return fn(t);
30
+ };
31
+ return wrapped;
32
+ }
33
+ function isEasingFactory(value) {
34
+ return typeof value === "object" && value !== null && "factory" in value && typeof value.factory === "function";
35
+ }
36
+
37
+ // src/transitions/spring.ts
38
+ var DEFAULT_SPRING = {
39
+ tension: 170,
40
+ friction: 26,
41
+ mass: 1
42
+ };
43
+ function springToReanimated(t) {
44
+ "worklet";
45
+ return {
46
+ stiffness: t.tension ?? DEFAULT_SPRING.tension,
47
+ damping: t.friction ?? DEFAULT_SPRING.friction,
48
+ mass: t.mass ?? DEFAULT_SPRING.mass,
49
+ velocity: t.velocity,
50
+ restSpeedThreshold: t.restSpeedThreshold,
51
+ restDisplacementThreshold: t.restDisplacementThreshold
52
+ };
53
+ }
54
+
55
+ // src/transitions/resolve.ts
56
+ var DEFAULT_TIMING_DURATION = 250;
57
+ function buildSpring(cfg, toValue, cb) {
58
+ return withSpring(toValue, springToReanimated(cfg), cb);
59
+ }
60
+ function buildTiming(cfg, toValue, cb) {
61
+ return withTiming(
62
+ toValue,
63
+ {
64
+ duration: cfg.duration ?? DEFAULT_TIMING_DURATION,
65
+ easing: ensureWorkletEasing(cfg.easing) ?? Easing.inOut(Easing.ease)
66
+ },
67
+ cb
68
+ );
69
+ }
70
+ function buildDecay(cfg, cb) {
71
+ return withDecay(
72
+ {
73
+ velocity: cfg.velocity ?? 0,
74
+ deceleration: cfg.deceleration,
75
+ clamp: cfg.clamp
76
+ },
77
+ cb
78
+ );
79
+ }
80
+ function buildOne(cfg, toValue, cb) {
81
+ if (cfg.type === "no-animation") {
82
+ return toValue;
83
+ }
84
+ if (cfg.type === "decay") return buildDecay(cfg, cb);
85
+ if (cfg.type === "timing") return buildTiming(cfg, toValue, cb);
86
+ return buildSpring(cfg, toValue, cb);
87
+ }
88
+ function applyRepeat(animation, repeat) {
89
+ if (repeat === void 0) return animation;
90
+ if (repeat === "infinite") {
91
+ return withRepeat(animation, -1, true);
92
+ }
93
+ if (typeof repeat === "number") {
94
+ return withRepeat(animation, repeat, true);
95
+ }
96
+ const count = repeat.count === "infinite" ? -1 : repeat.count;
97
+ const alternate = repeat.alternate ?? true;
98
+ return withRepeat(animation, count, alternate);
99
+ }
100
+ function applyDelay(animation, delay) {
101
+ if (!delay || delay <= 0) return animation;
102
+ return withDelay(delay, animation);
103
+ }
104
+ function resolveTransition(config, toValue, callback) {
105
+ const cfg = config ?? { type: "spring" };
106
+ const base = buildOne(cfg, toValue, callback);
107
+ const repeated = applyRepeat(base, repeatOf(cfg));
108
+ return applyDelay(repeated, delayOf(cfg));
109
+ }
110
+ function repeatOf(cfg) {
111
+ if (cfg.type === "no-animation" || cfg.type === "decay") return void 0;
112
+ return cfg.repeat;
113
+ }
114
+ function delayOf(cfg) {
115
+ if (cfg.type === "no-animation") return void 0;
116
+ return cfg.delay;
117
+ }
118
+
119
+ // src/transitions/keys.ts
120
+ var TRANSITION_CONFIG_KEYS = /* @__PURE__ */ new Set([
121
+ "type",
122
+ "tension",
123
+ "friction",
124
+ "mass",
125
+ "velocity",
126
+ "restSpeedThreshold",
127
+ "restDisplacementThreshold",
128
+ "duration",
129
+ "easing",
130
+ "delay",
131
+ "repeat",
132
+ "deceleration",
133
+ "clamp"
134
+ ]);
135
+ function isTopLevelTransition(t) {
136
+ if (t === null || typeof t !== "object") return false;
137
+ const keys = Object.keys(t);
138
+ if (keys.length === 0) return false;
139
+ return keys.every((k) => TRANSITION_CONFIG_KEYS.has(k));
140
+ }
141
+ var modality = "keyboard";
142
+ var installed = false;
143
+ function setKeyboard() {
144
+ modality = "keyboard";
145
+ }
146
+ function setPointer() {
147
+ modality = "pointer";
148
+ }
149
+ function ensureInstalled() {
150
+ if (installed) return;
151
+ if (Platform.OS !== "web") return;
152
+ if (typeof document === "undefined") return;
153
+ document.addEventListener("keydown", setKeyboard, true);
154
+ document.addEventListener("mousedown", setPointer, true);
155
+ document.addEventListener("pointerdown", setPointer, true);
156
+ document.addEventListener("touchstart", setPointer, true);
157
+ installed = true;
158
+ }
159
+ function isFocusVisible() {
160
+ if (Platform.OS !== "web") return true;
161
+ ensureInstalled();
162
+ return modality === "keyboard";
163
+ }
164
+
165
+ // src/values/useGesture.ts
166
+ function useGesture(transition) {
167
+ const pressed = useSharedValue(0);
168
+ const focused = useSharedValue(0);
169
+ const focusVisible = useSharedValue(0);
170
+ const hovered = useSharedValue(0);
171
+ const shouldReduceMotion = useShouldReduceMotion();
172
+ const setLayer = useCallback(
173
+ (sv, layer, target) => {
174
+ const cfg = shouldReduceMotion ? { type: "no-animation" } : layerTransition(layer, transition) ?? { type: "spring" };
175
+ sv.value = resolveTransition(cfg, target);
176
+ },
177
+ // The transition is intentionally read on every call rather than cooked
178
+ // into the dep array — a fresh literal each render would otherwise
179
+ // rebuild the handler bag and break composing consumers that key off
180
+ // handler identity. `transition` is read inside the callback closure;
181
+ // shared values are stable so the only dep that matters is the reduce-
182
+ // motion flag.
183
+ // eslint-disable-next-line react-hooks/exhaustive-deps
184
+ [shouldReduceMotion]
185
+ );
186
+ const handlers = useMemo(
187
+ () => ({
188
+ onPressIn: () => setLayer(pressed, "pressed", 1),
189
+ onPressOut: () => setLayer(pressed, "pressed", 0),
190
+ onHoverIn: () => setLayer(hovered, "hovered", 1),
191
+ onHoverOut: () => setLayer(hovered, "hovered", 0),
192
+ onFocus: () => {
193
+ setLayer(focused, "focused", 1);
194
+ if (isFocusVisible()) setLayer(focusVisible, "focusVisible", 1);
195
+ },
196
+ onBlur: () => {
197
+ setLayer(focused, "focused", 0);
198
+ setLayer(focusVisible, "focusVisible", 0);
199
+ }
200
+ }),
201
+ [setLayer, pressed, focused, focusVisible, hovered]
202
+ );
203
+ return { pressed, focused, focusVisible, hovered, handlers };
204
+ }
205
+ function layerTransition(layer, transition) {
206
+ if (!transition) return void 0;
207
+ if (isTopLevelTransition(transition)) return transition;
208
+ return transition[layer];
209
+ }
210
+
211
+ // src/gestureLayer/useGestureLayer.ts
212
+ function useGestureLayer(states, options = {}) {
213
+ const { disabled: isDisabled = false, transition } = options;
214
+ const shouldReduceMotion = useShouldReduceMotion();
215
+ const gesture = useGesture(transition);
216
+ const disabledProgress = useSharedValue(0);
217
+ useEffect(() => {
218
+ const target = isDisabled ? 1 : 0;
219
+ const cfg = shouldReduceMotion ? { type: "no-animation" } : disabledTransition(transition) ?? { type: "spring" };
220
+ disabledProgress.value = resolveTransition(cfg, target);
221
+ }, [isDisabled, shouldReduceMotion, transition, disabledProgress]);
222
+ const meta = useMemo(() => {
223
+ const layers = {
224
+ rest: states.rest,
225
+ hovered: states.hovered,
226
+ focused: states.focused,
227
+ focusVisible: states.focusVisible,
228
+ pressed: states.pressed,
229
+ disabled: states.disabled
230
+ };
231
+ const sources = [
232
+ layers.rest,
233
+ layers.hovered,
234
+ layers.focused,
235
+ layers.focusVisible,
236
+ layers.pressed,
237
+ layers.disabled
238
+ ];
239
+ const keySet = /* @__PURE__ */ new Set();
240
+ for (const src of sources) {
241
+ if (!src) continue;
242
+ for (const k in src) if (src[k] !== void 0) keySet.add(k);
243
+ }
244
+ const keys = Array.from(keySet);
245
+ const types = {};
246
+ const restValues = {};
247
+ for (const k of keys) {
248
+ let firstDefined;
249
+ for (const src of sources) {
250
+ if (src && src[k] !== void 0) {
251
+ firstDefined = src[k];
252
+ break;
253
+ }
254
+ }
255
+ const isColor = typeof firstDefined === "string";
256
+ types[k] = isColor ? "color" : "number";
257
+ const restRaw = layers.rest ? layers.rest[k] : void 0;
258
+ restValues[k] = restRaw !== void 0 ? restRaw : isColor ? "transparent" : 0;
259
+ }
260
+ return { layers, keys, types, restValues };
261
+ }, [
262
+ states.rest,
263
+ states.hovered,
264
+ states.focused,
265
+ states.focusVisible,
266
+ states.pressed,
267
+ states.disabled
268
+ ]);
269
+ const style = useAnimatedStyle(() => {
270
+ const { layers, keys, types, restValues } = meta;
271
+ const ph = gesture.hovered.value;
272
+ const pf = gesture.focused.value;
273
+ const pfv = gesture.focusVisible.value;
274
+ const pp = gesture.pressed.value;
275
+ const pd = disabledProgress.value;
276
+ const hoveredLayer = layers.hovered;
277
+ const focusedLayer = layers.focused;
278
+ const focusVisibleLayer = layers.focusVisible;
279
+ const pressedLayer = layers.pressed;
280
+ const disabledLayer = layers.disabled;
281
+ const out = {};
282
+ for (let i = 0; i < keys.length; i++) {
283
+ const k = keys[i];
284
+ const isColor = types[k] === "color";
285
+ const rest = restValues[k];
286
+ if (isColor) {
287
+ let v = rest;
288
+ if (hoveredLayer && ph > 0 && hoveredLayer[k] !== void 0) {
289
+ v = interpolateColor(ph, [0, 1], [v, hoveredLayer[k]]);
290
+ }
291
+ if (focusedLayer && pf > 0 && focusedLayer[k] !== void 0) {
292
+ v = interpolateColor(pf, [0, 1], [v, focusedLayer[k]]);
293
+ }
294
+ if (focusVisibleLayer && pfv > 0 && focusVisibleLayer[k] !== void 0) {
295
+ v = interpolateColor(pfv, [0, 1], [v, focusVisibleLayer[k]]);
296
+ }
297
+ if (pressedLayer && pp > 0 && pressedLayer[k] !== void 0) {
298
+ v = interpolateColor(pp, [0, 1], [v, pressedLayer[k]]);
299
+ }
300
+ if (disabledLayer && pd > 0 && disabledLayer[k] !== void 0) {
301
+ v = interpolateColor(pd, [0, 1], [v, disabledLayer[k]]);
302
+ }
303
+ out[k] = v;
304
+ } else {
305
+ const base = rest;
306
+ let m = base;
307
+ if (hoveredLayer && ph > 0 && hoveredLayer[k] !== void 0) {
308
+ const c = base + (hoveredLayer[k] - base) * ph;
309
+ if (c > m) m = c;
310
+ }
311
+ if (focusedLayer && pf > 0 && focusedLayer[k] !== void 0) {
312
+ const c = base + (focusedLayer[k] - base) * pf;
313
+ if (c > m) m = c;
314
+ }
315
+ if (focusVisibleLayer && pfv > 0 && focusVisibleLayer[k] !== void 0) {
316
+ const c = base + (focusVisibleLayer[k] - base) * pfv;
317
+ if (c > m) m = c;
318
+ }
319
+ if (pressedLayer && pp > 0 && pressedLayer[k] !== void 0) {
320
+ const c = base + (pressedLayer[k] - base) * pp;
321
+ if (c > m) m = c;
322
+ }
323
+ if (disabledLayer && pd > 0 && disabledLayer[k] !== void 0) {
324
+ m = m + (disabledLayer[k] - m) * pd;
325
+ }
326
+ out[k] = m;
327
+ }
328
+ }
329
+ return out;
330
+ });
331
+ return {
332
+ style,
333
+ handlers: gesture.handlers
334
+ };
335
+ }
336
+ function disabledTransition(transition) {
337
+ if (!transition) return void 0;
338
+ if (isTopLevelTransition(transition)) return transition;
339
+ return void 0;
340
+ }
341
+
342
+ export { useGestureLayer };
343
+ //# sourceMappingURL=index.mjs.map
344
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/config/MotionConfigContext.ts","../../src/transitions/easing.ts","../../src/transitions/spring.ts","../../src/transitions/resolve.ts","../../src/transitions/keys.ts","../../src/gestures/focusVisibility.ts","../../src/values/useGesture.ts","../../src/gestureLayer/useGestureLayer.ts"],"names":["useSharedValue","useMemo"],"mappings":";;;;;;AAwBO,IAAM,qBAAA,GAA2C;AAAA,EACtD,aAAA,EAAe;AACjB,CAAA;AAEO,IAAM,mBAAA,GAAsB,aAAA;AAAA,EACjC;AACF,CAAA;AAMO,SAAS,eAAA,GAAqC;AACnD,EAAA,OAAO,WAAW,mBAAmB,CAAA;AACvC;AAQO,SAAS,qBAAA,GAAiC;AAC/C,EAAA,MAAM,EAAE,aAAA,EAAc,GAAI,eAAA,EAAgB;AAC1C,EAAA,MAAM,YAAY,gBAAA,EAAiB;AACnC,EAAA,IAAI,aAAA,KAAkB,SAAS,OAAO,KAAA;AACtC,EAAA,IAAI,aAAA,KAAkB,UAAU,OAAO,IAAA;AACvC,EAAA,OAAO,SAAA;AACT;ACzBO,SAAS,oBACd,MAAA,EACqC;AACrC,EAAA,IAAI,CAAC,QAAQ,OAAO,MAAA;AAIpB,EAAA,MAAM,KAAK,eAAA,CAAgB,MAAM,CAAA,GAAI,MAAA,CAAO,SAAQ,GAAI,MAAA;AACxD,EAAA,IAAI,iBAAA,CAAkB,EAAE,CAAA,EAAG,OAAO,EAAA;AAClC,EAAA,MAAM,OAAA,GAAU,CAAC,CAAA,KAAc;AAC7B,IAAA,SAAA;AACA,IAAA,OAAO,GAAG,CAAC,CAAA;AAAA,EACb,CAAA;AACA,EAAA,OAAO,OAAA;AACT;A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IAAA,OAAO,GAAA;AAAA,EACT,CAAC,CAAA;AAED,EAAA,OAAO;AAAA,IACL,KAAA;AAAA,IACA,UAAU,OAAA,CAAQ;AAAA,GACpB;AACF;AAEA,SAAS,mBACP,UAAA,EAC8B;AAC9B,EAAA,IAAI,CAAC,YAAY,OAAO,MAAA;AACxB,EAAA,IAAI,oBAAA,CAAqB,UAAU,CAAA,EAAG,OAAO,UAAA;AAC7C,EAAA,OAAO,MAAA;AACT","file":"index.mjs","sourcesContent":["import { createContext, useContext } from 'react'\nimport { useReducedMotion } from 'react-native-reanimated'\n\n/**\n * How descendant Motion primitives should treat reduced-motion preferences.\n *\n * - `'user'` (default): defer to the OS accessibility setting via\n * Reanimated's `useReducedMotion()`. This is the only value that respects\n * user choice and is the right default for app-level wrappers.\n * - `'never'`: animate regardless of OS setting. Use sparingly — e.g. for\n * onboarding transitions you've decided are essential.\n * - `'always'`: never animate, regardless of OS setting. Useful for tests\n * and snapshots.\n */\nexport type ReducedMotion = 'user' | 'never' | 'always'\n\nexport interface MotionConfigValue {\n reducedMotion: ReducedMotion\n}\n\n/**\n * Default config used when a Motion primitive is rendered without a\n * `<MotionConfig>` ancestor. `'user'` means respect the OS setting.\n */\nexport const DEFAULT_MOTION_CONFIG: MotionConfigValue = {\n reducedMotion: 'user',\n}\n\nexport const MotionConfigContext = createContext<MotionConfigValue>(\n DEFAULT_MOTION_CONFIG,\n)\n\n/**\n * Read the active `<MotionConfig>` from a descendant. Returns the default\n * (`'user'`) when no provider is present.\n */\nexport function useMotionConfig(): MotionConfigValue {\n return useContext(MotionConfigContext)\n}\n\n/**\n * Resolve the active reduced-motion mode to a boolean. `'user'` consults\n * Reanimated's OS-backed hook; `'always'` / `'never'` shortcut. Motion\n * primitives call this to decide whether to swap transitions for\n * `no-animation`.\n */\nexport function useShouldReduceMotion(): boolean {\n const { reducedMotion } = useMotionConfig()\n const osReduced = useReducedMotion()\n if (reducedMotion === 'never') return false\n if (reducedMotion === 'always') return true\n return osReduced\n}\n","// `isWorkletFunction` lives in `react-native-worklets` (the Reanimated 4 peer\n// dep); Reanimated's own re-export is deprecated.\nimport { isWorkletFunction } from 'react-native-worklets'\nimport { type EasingInput } from '../types'\n\n/**\n * Reanimated 3.9+ validates that easing functions used in nested-transition\n * contexts (variants, sequences, per-property maps) are worklets, and crashes\n * with `[Reanimated] The easing function is not a worklet` otherwise. The\n * library accepts plain functions on the public surface; this helper wraps\n * them so consumers don't have to think about the worklet boundary.\n *\n * If the input is already a worklet (has been processed by the worklets babel\n * plugin), it's returned as-is. Otherwise it's wrapped in a function whose\n * body declares the `'worklet'` directive — when our source is processed by\n * the consumer's worklets babel plugin (the default Expo/RN setup), the\n * wrapper becomes a real worklet that captures the user fn via closure.\n *\n * Reanimated 4 changed `Easing.bezier(...)` to return an\n * `EasingFunctionFactory` (`{ factory: () => EasingFunction }`) rather than\n * the function itself. The helper accepts both shapes — `EasingFunction` and\n * `EasingFunctionFactory` — and unwraps the factory automatically so\n * consumers don't have to call `.factory()` manually.\n *\n * The user fn must be pure: no JS-thread captured refs, no shared mutable\n * state, no calls to non-worklet APIs.\n */\nexport function ensureWorkletEasing(\n easing: EasingInput | undefined,\n): ((t: number) => number) | undefined {\n if (!easing) return undefined\n // Reanimated 4 `EasingFunctionFactory` — unwrap via `.factory()` before\n // checking worklet status, so the wrapped fn (not the factory wrapper)\n // ends up in the transition config.\n const fn = isEasingFactory(easing) ? easing.factory() : easing\n if (isWorkletFunction(fn)) return fn\n const wrapped = (t: number) => {\n 'worklet'\n return fn(t)\n }\n return wrapped\n}\n\nfunction isEasingFactory(\n value: EasingInput,\n): value is { factory: () => (t: number) => number } {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'factory' in value &&\n typeof (value as { factory: unknown }).factory === 'function'\n )\n}\n","import { type SpringTransition } from '../types'\n\n/**\n * Default spring physics, expressed in react-spring vocabulary.\n *\n * `tension: 170` / `friction: 26` / `mass: 1` was picked over Reanimated's\n * raw `stiffness: 100` / `damping: 10` default because the raw default\n * overshoots noticeably for the small (~100px) translates that dominate\n * UI work — buttons, sheets, popovers. These numbers settle in ~350ms with\n * a single, almost-imperceptible overshoot, which matches the perceptual\n * target the rest of the library is tuned against.\n */\nexport const DEFAULT_SPRING: Required<\n Pick<SpringTransition, 'tension' | 'friction' | 'mass'>\n> = {\n tension: 170,\n friction: 26,\n mass: 1,\n}\n\n/**\n * Convert public react-spring vocabulary (`tension` / `friction` / `mass`)\n * to Reanimated's raw `stiffness` / `damping` / `mass`. This is the single\n * place the mapping lives; resolvers, value hooks, and any future surface\n * that needs a Reanimated spring config import from here.\n *\n * The mapping is identity (tension ≡ stiffness, friction ≡ damping) — the\n * names differ but the underlying physics constants are the same. We don't\n * surface the raw names publicly because the react-spring vocabulary is\n * what designers and prior-art consumers expect.\n */\nexport function springToReanimated(t: SpringTransition) {\n 'worklet'\n return {\n stiffness: t.tension ?? DEFAULT_SPRING.tension,\n damping: t.friction ?? DEFAULT_SPRING.friction,\n mass: t.mass ?? DEFAULT_SPRING.mass,\n velocity: t.velocity,\n restSpeedThreshold: t.restSpeedThreshold,\n restDisplacementThreshold: t.restDisplacementThreshold,\n }\n}\n","import {\n Easing,\n withDecay,\n withDelay,\n withRepeat,\n withSequence,\n withSpring,\n withTiming,\n} from 'react-native-reanimated'\nimport { ensureWorkletEasing } from './easing'\nimport { springToReanimated } from './spring'\nimport {\n type AnimatableValue,\n type DecayTransition,\n type RepeatConfig,\n type SequenceStep,\n type SpringTransition,\n type TimingTransition,\n type TransitionConfig,\n} from '../types'\n\n/**\n * UI-thread callback Reanimated invokes when an animation settles. Must be a\n * worklet — callers either author one with `'worklet'` or build one via\n * `runOnJS(...)` to bridge to JS-thread code.\n */\nexport type AnimationCallback = (\n finished?: boolean,\n current?: number | string,\n) => void\n\n/**\n * Per-step callback factory. Resolvers call this with the step's phase and\n * sequence index (or `undefined` for non-sequence animations) and attach the\n * resulting callback to the underlying `withSpring` / `withTiming` /\n * `withDecay` call.\n */\nexport type CallbackFactory = (\n phase: 'step' | 'animation',\n step: number | undefined,\n) => AnimationCallback | undefined\n\nconst DEFAULT_TIMING_DURATION = 250\n\nfunction buildSpring(\n cfg: SpringTransition,\n toValue: number | string,\n cb?: AnimationCallback,\n) {\n return withSpring(toValue as number, springToReanimated(cfg), cb as never)\n}\n\nfunction buildTiming(\n cfg: TimingTransition,\n toValue: number | string,\n cb?: AnimationCallback,\n) {\n return withTiming(\n toValue as number,\n {\n duration: cfg.duration ?? DEFAULT_TIMING_DURATION,\n easing: ensureWorkletEasing(cfg.easing) ?? Easing.inOut(Easing.ease),\n },\n cb as never,\n )\n}\n\nfunction buildDecay(cfg: DecayTransition, cb?: AnimationCallback) {\n return withDecay(\n {\n velocity: cfg.velocity ?? 0,\n deceleration: cfg.deceleration,\n clamp: cfg.clamp,\n },\n cb as never,\n )\n}\n\n/**\n * Build a single-step animation (no repeat / no delay / no sequence) for a\n * given config + target. Pulled out so sequence steps can compose without\n * recursing into repeat/delay handling per step. The callback is forwarded\n * to Reanimated; for `no-animation` the callback is fired synchronously\n * since there's nothing to wait for.\n */\nfunction buildOne(\n cfg: TransitionConfig,\n toValue: number | string,\n cb?: AnimationCallback,\n): unknown {\n if (cfg.type === 'no-animation') {\n if (cb) cb(true, toValue)\n return toValue\n }\n if (cfg.type === 'decay') return buildDecay(cfg, cb)\n if (cfg.type === 'timing') return buildTiming(cfg, toValue, cb)\n return buildSpring(cfg as SpringTransition, toValue, cb)\n}\n\n/**\n * Wrap an animation in `withRepeat` per the unified `repeat` shape:\n * - `number` → finite count, alternating direction\n * - `'infinite'` → endless, alternating direction\n * - `{ count, alternate }`→ explicit; `alternate` defaults to `true`\n */\nfunction applyRepeat(animation: unknown, repeat: RepeatConfig | undefined) {\n if (repeat === undefined) return animation\n if (repeat === 'infinite') {\n return withRepeat(animation as never, -1, true)\n }\n if (typeof repeat === 'number') {\n return withRepeat(animation as never, repeat, true)\n }\n const count = repeat.count === 'infinite' ? -1 : repeat.count\n const alternate = repeat.alternate ?? true\n return withRepeat(animation as never, count, alternate)\n}\n\nfunction applyDelay(animation: unknown, delay: number | undefined) {\n if (!delay || delay <= 0) return animation\n return withDelay(delay, animation as never)\n}\n\n/**\n * Build a Reanimated animation for a single property. Runs on the JS thread\n * once per change and produces a baked `withSpring` / `withTiming` /\n * `withDecay` (optionally wrapped in `withDelay` / `withRepeat`) call. The\n * worklet body only consumes the result.\n *\n * `callback`, when provided, fires once when the underlying single-shot\n * animation settles. Repeat-wrapped animations forward the callback to\n * `withRepeat`, so it fires once per iteration as Reanimated does.\n */\nexport function resolveTransition(\n config: TransitionConfig | undefined,\n toValue: number | string,\n callback?: AnimationCallback,\n): unknown {\n const cfg = config ?? ({ type: 'spring' } as SpringTransition)\n const base = buildOne(cfg, toValue, callback)\n const repeated = applyRepeat(base, repeatOf(cfg))\n return applyDelay(repeated, delayOf(cfg))\n}\n\nfunction repeatOf(cfg: TransitionConfig): RepeatConfig | undefined {\n if (cfg.type === 'no-animation' || cfg.type === 'decay') return undefined\n return cfg.repeat\n}\n\n/**\n * Return `cfg` minus its `repeat` field. Used when peeling top-level repeat\n * off a base transition before passing it down to per-sequence-step\n * resolution — the sequence as a whole is what should repeat, not each step.\n */\nfunction stripRepeat(\n cfg: TransitionConfig | undefined,\n): TransitionConfig | undefined {\n if (!cfg) return cfg\n if (cfg.type === 'no-animation' || cfg.type === 'decay') return cfg\n if (cfg.repeat === undefined) return cfg\n const next = { ...cfg }\n delete next.repeat\n return next\n}\n\nfunction delayOf(cfg: TransitionConfig): number | undefined {\n if (cfg.type === 'no-animation') return undefined\n return cfg.delay\n}\n\n/**\n * True when the value is a `{ to, ...transitionOverride }` sequence step.\n * Plain numbers and plain transition objects fail this check.\n */\nfunction isStepObject<V>(\n v: SequenceStep<V> | V,\n): v is Extract<SequenceStep<V>, { to: V }> {\n return (\n typeof v === 'object' &&\n v !== null &&\n !Array.isArray(v) &&\n 'to' in (v as object)\n )\n}\n\n/**\n * Resolve a per-property `animate` value into a Reanimated animation.\n *\n * Handles the three shapes of `AnimatableValue`:\n * 1. plain value → single `resolveTransition` call\n * 2. `{ to, ...over }` → single step with the override merged into `base`\n * 3. array of either → `withSequence` of resolved steps, with the\n * top-level `repeat` applied at the **sequence level** (not per step).\n * Per-step `repeat` overrides remain step-local.\n */\nexport function resolveAnimatableValue<V extends number | string>(\n value: AnimatableValue<V>,\n base: TransitionConfig | undefined,\n factory?: CallbackFactory,\n): unknown {\n if (Array.isArray(value)) {\n const steps = value as ReadonlyArray<SequenceStep<V>>\n const stepBase = stripRepeat(base)\n const animations = steps.map((step, i) =>\n resolveStep(step, stepBase, factory?.('step', i)),\n )\n const seq = withSequence(...(animations as never[]))\n return applyRepeat(seq, base ? repeatOf(base) : undefined)\n }\n const step = value as SequenceStep<V>\n const cb = factory?.('animation', undefined)\n if (isStepObject<V>(step)) {\n return resolveStep(step, base, cb)\n }\n return resolveTransition(base, step as V, cb)\n}\n\nfunction resolveStep<V extends number | string>(\n step: SequenceStep<V>,\n base: TransitionConfig | undefined,\n cb?: AnimationCallback,\n): unknown {\n if (isStepObject<V>(step)) {\n const { to, ...override } = step as { to: V } & Partial<TransitionConfig>\n const merged = mergeTransition(base, override as Partial<TransitionConfig>)\n return resolveTransition(merged, to, cb)\n }\n return resolveTransition(base, step as V, cb)\n}\n\nfunction mergeTransition(\n base: TransitionConfig | undefined,\n override: Partial<TransitionConfig>,\n): TransitionConfig {\n // If the override declares a `type`, it wins outright — mixing fields from\n // a spring base into a timing override produces garbage. Otherwise inherit\n // the base's type and shallow-merge the rest.\n if (override.type && base && override.type !== base.type) {\n return override as TransitionConfig\n }\n return { ...(base ?? { type: 'spring' }), ...override } as TransitionConfig\n}\n","import { type TransitionConfig } from '../types'\n\n/**\n * Field names that may appear on a `TransitionConfig` (spring / timing /\n * decay / no-animation). Used as a structural discriminator: if every key on\n * an object is in this set, the object is treated as a top-level transition;\n * otherwise it's a per-property / per-layer transition map.\n *\n * Adding a new field to `TransitionConfig` requires adding the name here.\n */\nexport const TRANSITION_CONFIG_KEYS = new Set([\n 'type',\n 'tension',\n 'friction',\n 'mass',\n 'velocity',\n 'restSpeedThreshold',\n 'restDisplacementThreshold',\n 'duration',\n 'easing',\n 'delay',\n 'repeat',\n 'deceleration',\n 'clamp',\n])\n\nexport function isTopLevelTransition(t: unknown): t is TransitionConfig {\n if (t === null || typeof t !== 'object') return false\n const keys = Object.keys(t as object)\n if (keys.length === 0) return false\n return keys.every((k) => TRANSITION_CONFIG_KEYS.has(k))\n}\n","import { Platform } from 'react-native'\n\n/**\n * Input-modality tracker for the `focusVisible` gesture sub-state.\n *\n * Implements the W3C `:focus-visible` heuristic: a focus event counts as\n * \"visible\" only when the most recent user input was keyboard-driven. Mouse,\n * pointer, and touch events flip the modality to `'pointer'`; keyboard events\n * flip it back to `'keyboard'`.\n *\n * On native platforms there is no pointer-vs-keyboard distinction — focus\n * arrives via D-pad, screen reader, or hardware keyboard, all of which are\n * keyboard-equivalent — so `isFocusVisible()` is unconditionally `true`.\n *\n * The web listeners attach lazily on first call (capture phase, so they run\n * before the focus event reaches the focused element) and stay installed for\n * the lifetime of the document. They are passive and idle-cheap; the cost is\n * one boolean read per `onFocus` dispatch.\n */\n\ntype InputModality = 'keyboard' | 'pointer'\n\n// Default to `'keyboard'` so a programmatic / autofocus that happens before\n// any user input still draws a focus ring — matches the W3C polyfill default.\nlet modality: InputModality = 'keyboard'\nlet installed = false\n\nfunction setKeyboard() {\n modality = 'keyboard'\n}\n\nfunction setPointer() {\n modality = 'pointer'\n}\n\nfunction ensureInstalled(): void {\n if (installed) return\n if (Platform.OS !== 'web') return\n if (typeof document === 'undefined') return\n document.addEventListener('keydown', setKeyboard, true)\n document.addEventListener('mousedown', setPointer, true)\n document.addEventListener('pointerdown', setPointer, true)\n document.addEventListener('touchstart', setPointer, true)\n installed = true\n}\n\n/**\n * `true` if the next `onFocus` should be treated as \"focus-visible\" (keyboard\n * focus). On native, always `true`. On web, reflects the most recent user\n * input modality.\n */\nexport function isFocusVisible(): boolean {\n if (Platform.OS !== 'web') return true\n ensureInstalled()\n return modality === 'keyboard'\n}\n\n/** @internal — test-only hook to reset module state between cases. */\nexport function __resetFocusVisibilityForTests(next: InputModality): void {\n modality = next\n}\n","import { useCallback, useMemo } from 'react'\nimport { useSharedValue, type SharedValue } from 'react-native-reanimated'\nimport { useShouldReduceMotion } from '../config'\nimport { isFocusVisible } from '../gestures'\nimport { isTopLevelTransition, resolveTransition } from '../transitions'\nimport { type GestureLayerTransitions, type TransitionConfig } from '../types'\n\ntype LayerName = 'pressed' | 'focused' | 'focusVisible' | 'hovered'\n\n/**\n * Handler bag returned by `useGesture`. Spread on a `Pressable` to drive the\n * shared values returned alongside.\n *\n * Hover handlers use `Pressable`'s own `onHoverIn` / `onHoverOut` names (web\n * only — no-ops on native). `onFocus` consults `isFocusVisible()` before\n * raising the keyboard-only `focusVisible` layer; `focused` always raises.\n */\nexport interface UseGestureHandlers {\n onPressIn: () => void\n onPressOut: () => void\n onHoverIn: () => void\n onHoverOut: () => void\n onFocus: () => void\n onBlur: () => void\n}\n\nexport interface UseGestureResult {\n /** 0↔1 progress for the pressed layer. */\n pressed: SharedValue<number>\n /** 0↔1 progress for the focused layer (any focus modality). */\n focused: SharedValue<number>\n /** 0↔1 progress for the focusVisible layer (keyboard focus only). */\n focusVisible: SharedValue<number>\n /** 0↔1 progress for the hovered layer (web only — stays at 0 on native). */\n hovered: SharedValue<number>\n /** Handlers to spread on the receiving `Pressable`. */\n handlers: UseGestureHandlers\n}\n\n/**\n * Build a gesture-layer controller. The hook-form of the `gesture` prop —\n * reach for it when you need to drive multiple animated views from the same\n * gesture state (a focus ring + state-layer halo + content tint all on one\n * Pressable), which the prop-form's \"animate the receiver's own style\" model\n * can't express.\n *\n * Returns four 0↔1 shared values (one per layer) and a handler bag to spread\n * on a `Pressable`. The shared values are stable across renders — feed them\n * into any number of `useAnimatedStyle` blocks anywhere in the tree.\n *\n * Transitions follow the same shape as the `gesture` prop's accompanying\n * `transition`: pass a single `TransitionConfig` to use for every layer, or a\n * `GestureLayerTransitions` map to give each layer its own. Layers without an\n * explicit transition fall back to the library default spring.\n *\n * Reduced motion (via `<MotionConfig reducedMotion>`) collapses every\n * transition to `no-animation` so state changes snap instead of interpolating\n * — same behaviour the gesture prop applies.\n *\n * @example\n * ```tsx\n * import { useAnimatedStyle } from 'react-native-reanimated'\n * import { useGesture } from '@onlynative/inertia'\n *\n * function Card() {\n * const { pressed, focused, hovered, handlers } = useGesture({\n * pressed: { type: 'timing', duration: 100 },\n * hovered: { type: 'timing', duration: 150 },\n * focused: { type: 'timing', duration: 200 },\n * })\n *\n * const ringStyle = useAnimatedStyle(() => ({ opacity: focused.value }))\n * const haloStyle = useAnimatedStyle(() => ({\n * opacity: Math.max(\n * hovered.value * 0.08,\n * focused.value * 0.10,\n * pressed.value * 0.10,\n * ),\n * }))\n *\n * return (\n * <Pressable {...handlers}>\n * <Animated.View style={ringStyle} />\n * <Animated.View style={haloStyle} />\n * </Pressable>\n * )\n * }\n * ```\n */\nexport function useGesture(\n transition?: TransitionConfig | GestureLayerTransitions,\n): UseGestureResult {\n const pressed = useSharedValue(0)\n const focused = useSharedValue(0)\n const focusVisible = useSharedValue(0)\n const hovered = useSharedValue(0)\n const shouldReduceMotion = useShouldReduceMotion()\n\n const setLayer = useCallback(\n (sv: SharedValue<number>, layer: LayerName, target: 0 | 1) => {\n const cfg = shouldReduceMotion\n ? ({ type: 'no-animation' } as const)\n : (layerTransition(layer, transition) ?? ({ type: 'spring' } as const))\n sv.value = resolveTransition(cfg, target) as never\n },\n // The transition is intentionally read on every call rather than cooked\n // into the dep array — a fresh literal each render would otherwise\n // rebuild the handler bag and break composing consumers that key off\n // handler identity. `transition` is read inside the callback closure;\n // shared values are stable so the only dep that matters is the reduce-\n // motion flag.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [shouldReduceMotion],\n )\n\n const handlers = useMemo<UseGestureHandlers>(\n () => ({\n onPressIn: () => setLayer(pressed, 'pressed', 1),\n onPressOut: () => setLayer(pressed, 'pressed', 0),\n onHoverIn: () => setLayer(hovered, 'hovered', 1),\n onHoverOut: () => setLayer(hovered, 'hovered', 0),\n onFocus: () => {\n setLayer(focused, 'focused', 1)\n if (isFocusVisible()) setLayer(focusVisible, 'focusVisible', 1)\n },\n onBlur: () => {\n setLayer(focused, 'focused', 0)\n setLayer(focusVisible, 'focusVisible', 0)\n },\n }),\n [setLayer, pressed, focused, focusVisible, hovered],\n )\n\n return { pressed, focused, focusVisible, hovered, handlers }\n}\n\nfunction layerTransition(\n layer: LayerName,\n transition: TransitionConfig | GestureLayerTransitions | undefined,\n): TransitionConfig | undefined {\n if (!transition) return undefined\n if (isTopLevelTransition(transition)) return transition\n return (transition as GestureLayerTransitions)[layer]\n}\n","import { useEffect, useMemo } from 'react'\nimport {\n interpolateColor,\n useAnimatedStyle,\n useSharedValue,\n type AnimatedStyle,\n} from 'react-native-reanimated'\nimport { useShouldReduceMotion } from '../config'\nimport { isTopLevelTransition, resolveTransition } from '../transitions'\nimport { useGesture, type UseGestureHandlers } from '../values/useGesture'\nimport { type GestureLayerTransitions, type TransitionConfig } from '../types'\n\n/**\n * A single gesture-layer style — a flat map of style keys to a value. Numeric\n * values participate in clamped-max composition (the \"strongest active layer\n * wins\" model used by MD3 state-layer haloes); string values are treated as\n * colors and composed via priority cascade with `interpolateColor`.\n *\n * The hook does not validate that string values are valid colors — passing\n * something like `borderStyle: 'solid'` will crash inside the worklet. Keep\n * string values to color strings.\n */\nexport type GestureLayerStyle = {\n [key: string]: number | string | undefined\n}\n\n/**\n * Per-state style maps. Every key is optional; missing layers default to\n * `rest` (or `0` / `'transparent'` if `rest` is also absent for that key).\n *\n * - `rest` — base values, applied when no other layer is active.\n * - `hovered` / `focused` / `focusVisible` / `pressed` — gesture-driven\n * states tracked via the underlying `useGesture` hook. Each owns an\n * independent 0↔1 progress that fades the layer in/out per the configured\n * transition.\n * - `disabled` — gated by the JS-side `options.disabled` flag rather than a\n * gesture. Sits at the top of the priority cascade and overrides every\n * gesture layer when active.\n */\nexport interface GestureLayerStates {\n rest?: GestureLayerStyle\n hovered?: GestureLayerStyle\n focused?: GestureLayerStyle\n focusVisible?: GestureLayerStyle\n pressed?: GestureLayerStyle\n disabled?: GestureLayerStyle\n}\n\nexport interface UseGestureLayerOptions {\n /**\n * When `true`, the `disabled` layer becomes active (or `rest` if `disabled`\n * is undefined). Animates via the top-level transition or the library\n * default spring; per-layer transitions (`GestureLayerTransitions`) do not\n * apply to `disabled`.\n */\n disabled?: boolean\n /**\n * Transition forwarded to the underlying `useGesture` hook. Either a single\n * `TransitionConfig` for every gesture layer, or a `GestureLayerTransitions`\n * map for per-layer fades. Reduced motion collapses every transition to\n * `no-animation`.\n */\n transition?: TransitionConfig | GestureLayerTransitions\n}\n\nexport interface UseGestureLayerResult {\n /**\n * Animated style produced by `useAnimatedStyle` — spread on an\n * `Animated.View` or pass through `<Motion.View style={...} />`.\n */\n style: AnimatedStyle<Record<string, unknown>>\n /** Handlers to spread on the receiving `Pressable`. */\n handlers: UseGestureHandlers\n}\n\n/**\n * A \"strongest active layer wins\" interactive-feedback primitive. Sits one\n * step above `useGesture()` — the consumer supplies the per-state target\n * values, the hook handles the four gesture progress shared values, the\n * disabled override, the worklet, and the transition.\n *\n * Composition model:\n *\n * - **Numeric keys** (opacity, scale, borderWidth, etc.) compose via\n * clamped-max with `rest` as the floor:\n * `out = max(rest, ...for each active gesture layer: lerp(rest, layer, progress))`.\n * This matches the MD3 state-layer halo pattern — multiple states active\n * simultaneously raise the value to the strongest, not the sum.\n * - **Color keys** (any string value) compose via priority cascade with\n * `interpolateColor`, lowest priority first: `hovered → focused →\n * focusVisible → pressed`. Clamped-max doesn't apply to colors; this\n * matches the cascade used by the declarative `gesture` prop.\n * - **Disabled** sits at the top of the cascade for both numeric and color\n * keys — when active, it lerps the composed value toward the `disabled`\n * target.\n *\n * Reach for this when you want MD3 / iOS-translucent state-layer overlays\n * without rewriting the worklet by hand for every consumer; reach for plain\n * `useGesture()` when you need a composition model this hook doesn't\n * express (additive, multiply, per-key custom blends).\n *\n * @example MD3 state-layer halo\n * ```tsx\n * import { useGestureLayer } from '@onlynative/inertia/gesture-layer'\n * import Animated from 'react-native-reanimated'\n * import { Pressable } from 'react-native'\n *\n * function SwitchHalo({ disabled }: { disabled?: boolean }) {\n * const { style, handlers } = useGestureLayer(\n * {\n * rest: { opacity: 0, backgroundColor: 'transparent' },\n * hovered: { opacity: 0.08, backgroundColor: '#000' },\n * focused: { opacity: 0.10, backgroundColor: '#000' },\n * pressed: { opacity: 0.12, backgroundColor: '#000' },\n * },\n * { disabled, transition: { type: 'timing', duration: 150 } },\n * )\n *\n * return (\n * <Pressable {...handlers}>\n * <Animated.View style={style} />\n * </Pressable>\n * )\n * }\n * ```\n */\nexport function useGestureLayer(\n states: GestureLayerStates,\n options: UseGestureLayerOptions = {},\n): UseGestureLayerResult {\n const { disabled: isDisabled = false, transition } = options\n const shouldReduceMotion = useShouldReduceMotion()\n const gesture = useGesture(transition)\n const disabledProgress = useSharedValue(0)\n\n useEffect(() => {\n const target = isDisabled ? 1 : 0\n const cfg = shouldReduceMotion\n ? ({ type: 'no-animation' } as const)\n : (disabledTransition(transition) ?? ({ type: 'spring' } as const))\n disabledProgress.value = resolveTransition(cfg, target) as never\n }, [isDisabled, shouldReduceMotion, transition, disabledProgress])\n\n // JS-thread precompute: union of keys across all layers, per-key type\n // (number vs color), and a rest-fallback table. The worklet body reads\n // from `meta` instead of probing each layer per frame — the type check\n // only runs when layer identities change.\n const meta = useMemo(() => {\n const layers = {\n rest: states.rest,\n hovered: states.hovered,\n focused: states.focused,\n focusVisible: states.focusVisible,\n pressed: states.pressed,\n disabled: states.disabled,\n }\n const sources = [\n layers.rest,\n layers.hovered,\n layers.focused,\n layers.focusVisible,\n layers.pressed,\n layers.disabled,\n ]\n const keySet = new Set<string>()\n for (const src of sources) {\n if (!src) continue\n for (const k in src) if (src[k] !== undefined) keySet.add(k)\n }\n const keys = Array.from(keySet)\n const types: Record<string, 'number' | 'color'> = {}\n const restValues: Record<string, number | string> = {}\n for (const k of keys) {\n let firstDefined: number | string | undefined\n for (const src of sources) {\n if (src && src[k] !== undefined) {\n firstDefined = src[k]\n break\n }\n }\n const isColor = typeof firstDefined === 'string'\n types[k] = isColor ? 'color' : 'number'\n const restRaw = layers.rest ? layers.rest[k] : undefined\n restValues[k] =\n restRaw !== undefined ? restRaw : isColor ? 'transparent' : 0\n }\n return { layers, keys, types, restValues }\n }, [\n states.rest,\n states.hovered,\n states.focused,\n states.focusVisible,\n states.pressed,\n states.disabled,\n ])\n\n const style = useAnimatedStyle(() => {\n const { layers, keys, types, restValues } = meta\n const ph = gesture.hovered.value\n const pf = gesture.focused.value\n const pfv = gesture.focusVisible.value\n const pp = gesture.pressed.value\n const pd = disabledProgress.value\n\n const hoveredLayer = layers.hovered\n const focusedLayer = layers.focused\n const focusVisibleLayer = layers.focusVisible\n const pressedLayer = layers.pressed\n const disabledLayer = layers.disabled\n\n const out: Record<string, unknown> = {}\n\n for (let i = 0; i < keys.length; i++) {\n const k = keys[i]!\n const isColor = types[k] === 'color'\n const rest = restValues[k]!\n\n if (isColor) {\n let v = rest as string\n if (hoveredLayer && ph > 0 && hoveredLayer[k] !== undefined) {\n v = interpolateColor(ph, [0, 1], [v, hoveredLayer[k] as string])\n }\n if (focusedLayer && pf > 0 && focusedLayer[k] !== undefined) {\n v = interpolateColor(pf, [0, 1], [v, focusedLayer[k] as string])\n }\n if (\n focusVisibleLayer &&\n pfv > 0 &&\n focusVisibleLayer[k] !== undefined\n ) {\n v = interpolateColor(pfv, [0, 1], [v, focusVisibleLayer[k] as string])\n }\n if (pressedLayer && pp > 0 && pressedLayer[k] !== undefined) {\n v = interpolateColor(pp, [0, 1], [v, pressedLayer[k] as string])\n }\n if (disabledLayer && pd > 0 && disabledLayer[k] !== undefined) {\n v = interpolateColor(pd, [0, 1], [v, disabledLayer[k] as string])\n }\n out[k] = v\n } else {\n const base = rest as number\n let m = base\n if (hoveredLayer && ph > 0 && hoveredLayer[k] !== undefined) {\n const c = base + ((hoveredLayer[k] as number) - base) * ph\n if (c > m) m = c\n }\n if (focusedLayer && pf > 0 && focusedLayer[k] !== undefined) {\n const c = base + ((focusedLayer[k] as number) - base) * pf\n if (c > m) m = c\n }\n if (\n focusVisibleLayer &&\n pfv > 0 &&\n focusVisibleLayer[k] !== undefined\n ) {\n const c = base + ((focusVisibleLayer[k] as number) - base) * pfv\n if (c > m) m = c\n }\n if (pressedLayer && pp > 0 && pressedLayer[k] !== undefined) {\n const c = base + ((pressedLayer[k] as number) - base) * pp\n if (c > m) m = c\n }\n if (disabledLayer && pd > 0 && disabledLayer[k] !== undefined) {\n m = m + ((disabledLayer[k] as number) - m) * pd\n }\n out[k] = m\n }\n }\n\n return out\n })\n\n return {\n style: style as AnimatedStyle<Record<string, unknown>>,\n handlers: gesture.handlers,\n }\n}\n\nfunction disabledTransition(\n transition: TransitionConfig | GestureLayerTransitions | undefined,\n): TransitionConfig | undefined {\n if (!transition) return undefined\n if (isTopLevelTransition(transition)) return transition\n return undefined\n}\n"]}