@rootnative/inertia 0.0.0-alpha.1 → 0.0.0-alpha.3

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 (64) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/dist/chunk-5RCMIJGZ.js +8 -0
  3. package/dist/chunk-6FENLMCA.mjs +257 -0
  4. package/dist/chunk-E4MDU4YV.mjs +6 -0
  5. package/dist/chunk-FSPQVLBF.mjs +6 -0
  6. package/dist/chunk-GJD4VVAS.mjs +103 -0
  7. package/dist/chunk-JWHKMNYA.js +112 -0
  8. package/dist/chunk-K7ICHCTZ.js +54 -0
  9. package/dist/chunk-KARV7QKF.mjs +6 -0
  10. package/dist/chunk-KVSJWO5X.js +1011 -0
  11. package/dist/chunk-NJYRN3WG.js +8 -0
  12. package/dist/chunk-R3ODWDTI.js +8 -0
  13. package/dist/chunk-RJNR7CFN.mjs +6 -0
  14. package/dist/chunk-S4AEU72O.js +8 -0
  15. package/dist/chunk-SFRNO6AW.js +267 -0
  16. package/dist/chunk-UM3WVSKQ.mjs +6 -0
  17. package/dist/chunk-UMFBAFZP.js +8 -0
  18. package/dist/chunk-UXK4YCT6.mjs +1003 -0
  19. package/dist/chunk-W6IS4HAK.mjs +52 -0
  20. package/dist/gestureLayer/index.d.mts +42 -2
  21. package/dist/gestureLayer/index.d.ts +42 -2
  22. package/dist/gestureLayer/index.js +28 -275
  23. package/dist/gestureLayer/index.mjs +23 -270
  24. package/dist/index.js +122 -1459
  25. package/dist/index.mjs +19 -1402
  26. package/dist/motion/Image.js +8 -1175
  27. package/dist/motion/Image.mjs +4 -1174
  28. package/dist/motion/Pressable.js +8 -1175
  29. package/dist/motion/Pressable.mjs +4 -1174
  30. package/dist/motion/ScrollView.js +8 -1175
  31. package/dist/motion/ScrollView.mjs +4 -1174
  32. package/dist/motion/Text.js +8 -1175
  33. package/dist/motion/Text.mjs +4 -1174
  34. package/dist/motion/View.js +8 -1175
  35. package/dist/motion/View.mjs +4 -1174
  36. package/dist/testing/index.js +0 -2
  37. package/dist/testing/index.mjs +0 -2
  38. package/dist/touch/index.js +3 -47
  39. package/dist/touch/index.mjs +2 -46
  40. package/llms.txt +2 -2
  41. package/package.json +2 -1
  42. package/src/gestureLayer/index.ts +1 -0
  43. package/src/gestureLayer/useGestureLayer.ts +60 -0
  44. package/dist/gestureLayer/index.js.map +0 -1
  45. package/dist/gestureLayer/index.mjs.map +0 -1
  46. package/dist/index.js.map +0 -1
  47. package/dist/index.mjs.map +0 -1
  48. package/dist/motion/Image.js.map +0 -1
  49. package/dist/motion/Image.mjs.map +0 -1
  50. package/dist/motion/Pressable.js.map +0 -1
  51. package/dist/motion/Pressable.mjs.map +0 -1
  52. package/dist/motion/ScrollView.js.map +0 -1
  53. package/dist/motion/ScrollView.mjs.map +0 -1
  54. package/dist/motion/Text.js.map +0 -1
  55. package/dist/motion/Text.mjs.map +0 -1
  56. package/dist/motion/View.js.map +0 -1
  57. package/dist/motion/View.mjs.map +0 -1
  58. package/dist/testing/index.js.map +0 -1
  59. package/dist/testing/index.mjs.map +0 -1
  60. package/dist/touch/index.js.map +0 -1
  61. package/dist/touch/index.mjs.map +0 -1
  62. package/src/__type-tests__/animate.test-d.tsx +0 -88
  63. package/src/__type-tests__/motion-value.test-d.ts +0 -39
  64. package/src/__type-tests__/variants.test-d.tsx +0 -67
@@ -0,0 +1,52 @@
1
+ import { useShouldReduceMotion, resolveNamedTransitionProp, useNamedTransitions, isFocusVisible } from './chunk-GJD4VVAS.mjs';
2
+ import { resolveTransition, isTopLevelTransition } from './chunk-6FENLMCA.mjs';
3
+ import { useCallback, useMemo } from 'react';
4
+ import { useSharedValue } from 'react-native-reanimated';
5
+
6
+ function useGesture(transition) {
7
+ const pressed = useSharedValue(0);
8
+ const focused = useSharedValue(0);
9
+ const focusVisible = useSharedValue(0);
10
+ const hovered = useSharedValue(0);
11
+ const shouldReduceMotion = useShouldReduceMotion();
12
+ const resolved = resolveNamedTransitionProp(transition, useNamedTransitions());
13
+ const setLayer = useCallback(
14
+ (sv, layer, target) => {
15
+ const cfg = shouldReduceMotion ? { type: "no-animation" } : layerTransition(layer, resolved) ?? { type: "spring" };
16
+ sv.value = resolveTransition(cfg, target);
17
+ },
18
+ // The transition is intentionally read on every call rather than cooked
19
+ // into the dep array — a fresh literal each render would otherwise
20
+ // rebuild the handler bag and break composing consumers that key off
21
+ // handler identity. `transition` is read inside the callback closure;
22
+ // shared values are stable so the only dep that matters is the reduce-
23
+ // motion flag.
24
+ // eslint-disable-next-line react-hooks/exhaustive-deps
25
+ [shouldReduceMotion]
26
+ );
27
+ const handlers = useMemo(
28
+ () => ({
29
+ onPressIn: () => setLayer(pressed, "pressed", 1),
30
+ onPressOut: () => setLayer(pressed, "pressed", 0),
31
+ onHoverIn: () => setLayer(hovered, "hovered", 1),
32
+ onHoverOut: () => setLayer(hovered, "hovered", 0),
33
+ onFocus: () => {
34
+ setLayer(focused, "focused", 1);
35
+ if (isFocusVisible()) setLayer(focusVisible, "focusVisible", 1);
36
+ },
37
+ onBlur: () => {
38
+ setLayer(focused, "focused", 0);
39
+ setLayer(focusVisible, "focusVisible", 0);
40
+ }
41
+ }),
42
+ [setLayer, pressed, focused, focusVisible, hovered]
43
+ );
44
+ return { pressed, focused, focusVisible, hovered, handlers };
45
+ }
46
+ function layerTransition(layer, transition) {
47
+ if (!transition) return void 0;
48
+ if (isTopLevelTransition(transition)) return transition;
49
+ return transition[layer];
50
+ }
51
+
52
+ export { useGesture };
@@ -1,4 +1,4 @@
1
- import { AnimatedStyle } from 'react-native-reanimated';
1
+ import { SharedValue, AnimatedStyle } from 'react-native-reanimated';
2
2
  import { U as UseGestureHandlers } from '../useGesture-C0GBS7d2.mjs';
3
3
  import { T as TransitionInput, n as GestureLayerTransitions } from '../types-BzEgiUdJ.mjs';
4
4
  import 'react';
@@ -55,6 +55,26 @@ interface UseGestureLayerOptions {
55
55
  */
56
56
  transition?: TransitionInput | GestureLayerTransitions;
57
57
  }
58
+ /**
59
+ * The per-state 0↔1 progress shared values behind a `useGestureLayer` call.
60
+ * The gesture entries are the same shared values `useGesture` owns; `disabled`
61
+ * is driven by `options.disabled`. All five are stable across renders — feed
62
+ * them into any `useAnimatedStyle` / `useDerivedValue` (or hooks like
63
+ * `useShadow({ progress })`) to derive extra styles from the same gesture
64
+ * wiring without a second `useGesture` call.
65
+ */
66
+ interface GestureLayerProgress {
67
+ /** 0↔1 progress for the hovered layer (web only — stays at 0 on native). */
68
+ hovered: SharedValue<number>;
69
+ /** 0↔1 progress for the focused layer (any focus modality). */
70
+ focused: SharedValue<number>;
71
+ /** 0↔1 progress for the focusVisible layer (keyboard focus only). */
72
+ focusVisible: SharedValue<number>;
73
+ /** 0↔1 progress for the pressed layer. */
74
+ pressed: SharedValue<number>;
75
+ /** 0↔1 progress for the disabled override (driven by `options.disabled`). */
76
+ disabled: SharedValue<number>;
77
+ }
58
78
  interface UseGestureLayerResult {
59
79
  /**
60
80
  * Animated style produced by `useAnimatedStyle` — spread on an
@@ -63,6 +83,12 @@ interface UseGestureLayerResult {
63
83
  style: AnimatedStyle<Record<string, unknown>>;
64
84
  /** Handlers to spread on the receiving `Pressable`. */
65
85
  handlers: UseGestureHandlers;
86
+ /**
87
+ * Per-state progress shared values — the inputs the composed `style` is
88
+ * derived from. Read-only by convention: writing to them fights the
89
+ * handlers.
90
+ */
91
+ states: GestureLayerProgress;
66
92
  }
67
93
  /**
68
94
  * A "strongest active layer wins" interactive-feedback primitive. Sits one
@@ -85,6 +111,13 @@ interface UseGestureLayerResult {
85
111
  * keys — when active, it lerps the composed value toward the `disabled`
86
112
  * target.
87
113
  *
114
+ * Alongside `style` and `handlers`, the hook returns `states` — the per-state
115
+ * 0↔1 progress shared values the style is derived from (the four gesture
116
+ * layers plus the disabled override). Feed them into other progress-driven
117
+ * hooks (`useShadow`, `useColorTransition`) or a custom `useAnimatedStyle`
118
+ * to derive extra styles from the same gesture wiring — no second
119
+ * `useGesture` call, no duplicated handlers.
120
+ *
88
121
  * Reach for this when you want MD3 / iOS-translucent state-layer overlays
89
122
  * without rewriting the worklet by hand for every consumer; reach for plain
90
123
  * `useGesture()` when you need a composition model this hook doesn't
@@ -114,7 +147,14 @@ interface UseGestureLayerResult {
114
147
  * )
115
148
  * }
116
149
  * ```
150
+ *
151
+ * @example Elevation crossfade driven by the hover progress
152
+ * ```tsx
153
+ * const { style, handlers, states } = useGestureLayer(layers, options)
154
+ * const shadow = useShadow({ from: restShadow, to: raisedShadow, progress: states.hovered })
155
+ * // <Animated.View style={[style, shadow]} />
156
+ * ```
117
157
  */
118
158
  declare function useGestureLayer(states: GestureLayerStates, options?: UseGestureLayerOptions): UseGestureLayerResult;
119
159
 
120
- export { type GestureLayerStates, type GestureLayerStyle, type UseGestureLayerOptions, type UseGestureLayerResult, useGestureLayer };
160
+ export { type GestureLayerProgress, type GestureLayerStates, type GestureLayerStyle, type UseGestureLayerOptions, type UseGestureLayerResult, useGestureLayer };
@@ -1,4 +1,4 @@
1
- import { AnimatedStyle } from 'react-native-reanimated';
1
+ import { SharedValue, AnimatedStyle } from 'react-native-reanimated';
2
2
  import { U as UseGestureHandlers } from '../useGesture-BRLgiNOC.js';
3
3
  import { T as TransitionInput, n as GestureLayerTransitions } from '../types-BzEgiUdJ.js';
4
4
  import 'react';
@@ -55,6 +55,26 @@ interface UseGestureLayerOptions {
55
55
  */
56
56
  transition?: TransitionInput | GestureLayerTransitions;
57
57
  }
58
+ /**
59
+ * The per-state 0↔1 progress shared values behind a `useGestureLayer` call.
60
+ * The gesture entries are the same shared values `useGesture` owns; `disabled`
61
+ * is driven by `options.disabled`. All five are stable across renders — feed
62
+ * them into any `useAnimatedStyle` / `useDerivedValue` (or hooks like
63
+ * `useShadow({ progress })`) to derive extra styles from the same gesture
64
+ * wiring without a second `useGesture` call.
65
+ */
66
+ interface GestureLayerProgress {
67
+ /** 0↔1 progress for the hovered layer (web only — stays at 0 on native). */
68
+ hovered: SharedValue<number>;
69
+ /** 0↔1 progress for the focused layer (any focus modality). */
70
+ focused: SharedValue<number>;
71
+ /** 0↔1 progress for the focusVisible layer (keyboard focus only). */
72
+ focusVisible: SharedValue<number>;
73
+ /** 0↔1 progress for the pressed layer. */
74
+ pressed: SharedValue<number>;
75
+ /** 0↔1 progress for the disabled override (driven by `options.disabled`). */
76
+ disabled: SharedValue<number>;
77
+ }
58
78
  interface UseGestureLayerResult {
59
79
  /**
60
80
  * Animated style produced by `useAnimatedStyle` — spread on an
@@ -63,6 +83,12 @@ interface UseGestureLayerResult {
63
83
  style: AnimatedStyle<Record<string, unknown>>;
64
84
  /** Handlers to spread on the receiving `Pressable`. */
65
85
  handlers: UseGestureHandlers;
86
+ /**
87
+ * Per-state progress shared values — the inputs the composed `style` is
88
+ * derived from. Read-only by convention: writing to them fights the
89
+ * handlers.
90
+ */
91
+ states: GestureLayerProgress;
66
92
  }
67
93
  /**
68
94
  * A "strongest active layer wins" interactive-feedback primitive. Sits one
@@ -85,6 +111,13 @@ interface UseGestureLayerResult {
85
111
  * keys — when active, it lerps the composed value toward the `disabled`
86
112
  * target.
87
113
  *
114
+ * Alongside `style` and `handlers`, the hook returns `states` — the per-state
115
+ * 0↔1 progress shared values the style is derived from (the four gesture
116
+ * layers plus the disabled override). Feed them into other progress-driven
117
+ * hooks (`useShadow`, `useColorTransition`) or a custom `useAnimatedStyle`
118
+ * to derive extra styles from the same gesture wiring — no second
119
+ * `useGesture` call, no duplicated handlers.
120
+ *
88
121
  * Reach for this when you want MD3 / iOS-translucent state-layer overlays
89
122
  * without rewriting the worklet by hand for every consumer; reach for plain
90
123
  * `useGesture()` when you need a composition model this hook doesn't
@@ -114,7 +147,14 @@ interface UseGestureLayerResult {
114
147
  * )
115
148
  * }
116
149
  * ```
150
+ *
151
+ * @example Elevation crossfade driven by the hover progress
152
+ * ```tsx
153
+ * const { style, handlers, states } = useGestureLayer(layers, options)
154
+ * const shadow = useShadow({ from: restShadow, to: raisedShadow, progress: states.hovered })
155
+ * // <Animated.View style={[style, shadow]} />
156
+ * ```
117
157
  */
118
158
  declare function useGestureLayer(states: GestureLayerStates, options?: UseGestureLayerOptions): UseGestureLayerResult;
119
159
 
120
- export { type GestureLayerStates, type GestureLayerStyle, type UseGestureLayerOptions, type UseGestureLayerResult, useGestureLayer };
160
+ export { type GestureLayerProgress, type GestureLayerStates, type GestureLayerStyle, type UseGestureLayerOptions, type UseGestureLayerResult, useGestureLayer };
@@ -1,287 +1,25 @@
1
1
  'use strict';
2
2
 
3
+ var chunkK7ICHCTZ_js = require('../chunk-K7ICHCTZ.js');
4
+ var chunkJWHKMNYA_js = require('../chunk-JWHKMNYA.js');
5
+ var chunkSFRNO6AW_js = require('../chunk-SFRNO6AW.js');
3
6
  var react = require('react');
4
7
  var reactNativeReanimated = require('react-native-reanimated');
5
- var reactNativeWorklets = require('react-native-worklets');
6
- var reactNative = require('react-native');
7
8
 
8
- // src/gestureLayer/useGestureLayer.ts
9
-
10
- // src/transitions/sig.ts
11
- function stableSig(value) {
12
- if (value === void 0) return "";
13
- try {
14
- return stableStringify(value);
15
- } catch {
16
- return String(value);
17
- }
18
- }
19
- function stableStringify(v) {
20
- if (v === null || typeof v !== "object") {
21
- if (typeof v === "function" || v === void 0) return "null";
22
- return JSON.stringify(v);
23
- }
24
- if (Array.isArray(v)) {
25
- return "[" + v.map(stableStringify).join(",") + "]";
26
- }
27
- const obj = v;
28
- const keys = Object.keys(obj).sort();
29
- return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",") + "}";
30
- }
31
- var DEFAULT_MOTION_CONFIG = {
32
- reducedMotion: "user",
33
- transitions: {}
34
- };
35
- var MotionConfigContext = react.createContext(
36
- DEFAULT_MOTION_CONFIG
37
- );
38
- function useMotionConfig() {
39
- return react.useContext(MotionConfigContext);
40
- }
41
- function useNamedTransitions() {
42
- return useMotionConfig().transitions;
43
- }
44
- function useShouldReduceMotion() {
45
- const { reducedMotion } = useMotionConfig();
46
- const osReduced = reactNativeReanimated.useReducedMotion();
47
- if (reducedMotion === "never") return false;
48
- if (reducedMotion === "always") return true;
49
- return osReduced;
50
- }
51
-
52
- // src/transitions/keys.ts
53
- var TRANSITION_CONFIG_KEYS = /* @__PURE__ */ new Set([
54
- "type",
55
- "tension",
56
- "friction",
57
- "mass",
58
- "velocity",
59
- "restSpeedThreshold",
60
- "restDisplacementThreshold",
61
- "duration",
62
- "easing",
63
- "delay",
64
- "repeat",
65
- "deceleration",
66
- "clamp"
67
- ]);
68
- function isTopLevelTransition(t) {
69
- if (t === null || typeof t !== "object") return false;
70
- const keys = Object.keys(t);
71
- if (keys.length === 0) return false;
72
- return keys.every((k) => TRANSITION_CONFIG_KEYS.has(k));
73
- }
74
-
75
- // src/config/namedTransitions.ts
76
- var UNKNOWN_NAME_FALLBACK = { type: "spring" };
77
- function lookupNamedTransition(name, registry) {
78
- const cfg = registry[name];
79
- if (cfg) return cfg;
80
- if (__DEV__) {
81
- console.warn(
82
- `[inertia] Unknown transition name "${name}" \u2014 falling back to the default spring. Register it on a provider: <MotionConfig transitions={{ '${name}': { ... } }}>.`
83
- );
84
- }
85
- return UNKNOWN_NAME_FALLBACK;
86
- }
87
- function resolveNamedTransitionProp(transition, registry) {
88
- if (transition === void 0) return void 0;
89
- if (typeof transition === "string") {
90
- return lookupNamedTransition(transition, registry);
91
- }
92
- if (isTopLevelTransition(transition)) return transition;
93
- const map = transition;
94
- let out = null;
95
- for (const key in map) {
96
- const value = map[key];
97
- if (typeof value === "string") {
98
- if (out === null) out = { ...map };
99
- out[key] = lookupNamedTransition(value, registry);
100
- }
101
- }
102
- return out ?? transition;
103
- }
104
- function ensureWorkletEasing(easing) {
105
- if (!easing) return void 0;
106
- const fn = isEasingFactory(easing) ? easing.factory() : easing;
107
- if (reactNativeWorklets.isWorkletFunction(fn)) return fn;
108
- const wrapped = (t) => {
109
- "worklet";
110
- return fn(t);
111
- };
112
- return wrapped;
113
- }
114
- function isEasingFactory(value) {
115
- return typeof value === "object" && value !== null && "factory" in value && typeof value.factory === "function";
116
- }
117
-
118
- // src/transitions/spring.ts
119
- var DEFAULT_SPRING = {
120
- tension: 170,
121
- friction: 26,
122
- mass: 1
123
- };
124
- function springToReanimated(t) {
125
- "worklet";
126
- return {
127
- stiffness: t.tension ?? DEFAULT_SPRING.tension,
128
- damping: t.friction ?? DEFAULT_SPRING.friction,
129
- mass: t.mass ?? DEFAULT_SPRING.mass,
130
- velocity: t.velocity,
131
- restSpeedThreshold: t.restSpeedThreshold,
132
- restDisplacementThreshold: t.restDisplacementThreshold
133
- };
134
- }
135
-
136
- // src/transitions/resolve.ts
137
- var DEFAULT_TIMING_DURATION = 250;
138
- function buildSpring(cfg, toValue, cb) {
139
- return reactNativeReanimated.withSpring(toValue, springToReanimated(cfg), cb);
140
- }
141
- function buildTiming(cfg, toValue, cb) {
142
- return reactNativeReanimated.withTiming(
143
- toValue,
144
- {
145
- duration: cfg.duration ?? DEFAULT_TIMING_DURATION,
146
- easing: ensureWorkletEasing(cfg.easing) ?? reactNativeReanimated.Easing.inOut(reactNativeReanimated.Easing.ease)
147
- },
148
- cb
149
- );
150
- }
151
- function buildDecay(cfg, cb) {
152
- return reactNativeReanimated.withDecay(
153
- {
154
- velocity: cfg.velocity ?? 0,
155
- deceleration: cfg.deceleration,
156
- clamp: cfg.clamp
157
- },
158
- cb
159
- );
160
- }
161
- function buildOne(cfg, toValue, cb) {
162
- if (cfg.type === "no-animation") {
163
- return toValue;
164
- }
165
- if (cfg.type === "decay") return buildDecay(cfg, cb);
166
- if (cfg.type === "timing") return buildTiming(cfg, toValue, cb);
167
- return buildSpring(cfg, toValue, cb);
168
- }
169
- function applyRepeat(animation, repeat) {
170
- if (repeat === void 0) return animation;
171
- if (repeat === "infinite") {
172
- return reactNativeReanimated.withRepeat(animation, -1, true);
173
- }
174
- if (typeof repeat === "number") {
175
- return reactNativeReanimated.withRepeat(animation, repeat, true);
176
- }
177
- const count = repeat.count === "infinite" ? -1 : repeat.count;
178
- const alternate = repeat.alternate ?? true;
179
- return reactNativeReanimated.withRepeat(animation, count, alternate);
180
- }
181
- function applyDelay(animation, delay) {
182
- if (!delay || delay <= 0) return animation;
183
- return reactNativeReanimated.withDelay(delay, animation);
184
- }
185
- function resolveTransition(config, toValue, callback) {
186
- const cfg = config ?? { type: "spring" };
187
- const base = buildOne(cfg, toValue, callback);
188
- const repeated = applyRepeat(base, repeatOf(cfg));
189
- return applyDelay(repeated, delayOf(cfg));
190
- }
191
- function repeatOf(cfg) {
192
- if (cfg.type === "no-animation" || cfg.type === "decay") return void 0;
193
- return cfg.repeat;
194
- }
195
- function delayOf(cfg) {
196
- if (cfg.type === "no-animation") return void 0;
197
- return cfg.delay;
198
- }
199
- var modality = "keyboard";
200
- var installed = false;
201
- function setKeyboard() {
202
- modality = "keyboard";
203
- }
204
- function setPointer() {
205
- modality = "pointer";
206
- }
207
- function ensureInstalled() {
208
- if (installed) return;
209
- if (reactNative.Platform.OS !== "web") return;
210
- if (typeof document === "undefined") return;
211
- document.addEventListener("keydown", setKeyboard, true);
212
- document.addEventListener("mousedown", setPointer, true);
213
- document.addEventListener("pointerdown", setPointer, true);
214
- document.addEventListener("touchstart", setPointer, true);
215
- installed = true;
216
- }
217
- function isFocusVisible() {
218
- if (reactNative.Platform.OS !== "web") return true;
219
- ensureInstalled();
220
- return modality === "keyboard";
221
- }
222
-
223
- // src/values/useGesture.ts
224
- function useGesture(transition) {
225
- const pressed = reactNativeReanimated.useSharedValue(0);
226
- const focused = reactNativeReanimated.useSharedValue(0);
227
- const focusVisible = reactNativeReanimated.useSharedValue(0);
228
- const hovered = reactNativeReanimated.useSharedValue(0);
229
- const shouldReduceMotion = useShouldReduceMotion();
230
- const resolved = resolveNamedTransitionProp(transition, useNamedTransitions());
231
- const setLayer = react.useCallback(
232
- (sv, layer, target) => {
233
- const cfg = shouldReduceMotion ? { type: "no-animation" } : layerTransition(layer, resolved) ?? { type: "spring" };
234
- sv.value = resolveTransition(cfg, target);
235
- },
236
- // The transition is intentionally read on every call rather than cooked
237
- // into the dep array — a fresh literal each render would otherwise
238
- // rebuild the handler bag and break composing consumers that key off
239
- // handler identity. `transition` is read inside the callback closure;
240
- // shared values are stable so the only dep that matters is the reduce-
241
- // motion flag.
242
- // eslint-disable-next-line react-hooks/exhaustive-deps
243
- [shouldReduceMotion]
244
- );
245
- const handlers = react.useMemo(
246
- () => ({
247
- onPressIn: () => setLayer(pressed, "pressed", 1),
248
- onPressOut: () => setLayer(pressed, "pressed", 0),
249
- onHoverIn: () => setLayer(hovered, "hovered", 1),
250
- onHoverOut: () => setLayer(hovered, "hovered", 0),
251
- onFocus: () => {
252
- setLayer(focused, "focused", 1);
253
- if (isFocusVisible()) setLayer(focusVisible, "focusVisible", 1);
254
- },
255
- onBlur: () => {
256
- setLayer(focused, "focused", 0);
257
- setLayer(focusVisible, "focusVisible", 0);
258
- }
259
- }),
260
- [setLayer, pressed, focused, focusVisible, hovered]
261
- );
262
- return { pressed, focused, focusVisible, hovered, handlers };
263
- }
264
- function layerTransition(layer, transition) {
265
- if (!transition) return void 0;
266
- if (isTopLevelTransition(transition)) return transition;
267
- return transition[layer];
268
- }
269
-
270
- // src/gestureLayer/useGestureLayer.ts
271
9
  function useGestureLayer(states, options = {}) {
272
10
  const { disabled: isDisabled = false, transition: transitionInput } = options;
273
- const shouldReduceMotion = useShouldReduceMotion();
274
- const transition = resolveNamedTransitionProp(
11
+ const shouldReduceMotion = chunkJWHKMNYA_js.useShouldReduceMotion();
12
+ const transition = chunkJWHKMNYA_js.resolveNamedTransitionProp(
275
13
  transitionInput,
276
- useNamedTransitions()
14
+ chunkJWHKMNYA_js.useNamedTransitions()
277
15
  );
278
- const gesture = useGesture(transition);
16
+ const gesture = chunkK7ICHCTZ_js.useGesture(transition);
279
17
  const disabledProgress = reactNativeReanimated.useSharedValue(0);
280
- const transitionSig = stableSig(transition);
18
+ const transitionSig = chunkSFRNO6AW_js.stableSig(transition);
281
19
  react.useEffect(() => {
282
20
  const target = isDisabled ? 1 : 0;
283
21
  const cfg = shouldReduceMotion ? { type: "no-animation" } : disabledTransition(transition) ?? { type: "spring" };
284
- disabledProgress.value = resolveTransition(cfg, target);
22
+ disabledProgress.value = chunkSFRNO6AW_js.resolveTransition(cfg, target);
285
23
  }, [isDisabled, shouldReduceMotion, transitionSig, disabledProgress]);
286
24
  const meta = react.useMemo(() => {
287
25
  const layers = {
@@ -392,17 +130,32 @@ function useGestureLayer(states, options = {}) {
392
130
  }
393
131
  return out;
394
132
  });
133
+ const progress = react.useMemo(
134
+ () => ({
135
+ hovered: gesture.hovered,
136
+ focused: gesture.focused,
137
+ focusVisible: gesture.focusVisible,
138
+ pressed: gesture.pressed,
139
+ disabled: disabledProgress
140
+ }),
141
+ [
142
+ gesture.hovered,
143
+ gesture.focused,
144
+ gesture.focusVisible,
145
+ gesture.pressed,
146
+ disabledProgress
147
+ ]
148
+ );
395
149
  return {
396
150
  style,
397
- handlers: gesture.handlers
151
+ handlers: gesture.handlers,
152
+ states: progress
398
153
  };
399
154
  }
400
155
  function disabledTransition(transition) {
401
156
  if (!transition) return void 0;
402
- if (isTopLevelTransition(transition)) return transition;
157
+ if (chunkSFRNO6AW_js.isTopLevelTransition(transition)) return transition;
403
158
  return void 0;
404
159
  }
405
160
 
406
161
  exports.useGestureLayer = useGestureLayer;
407
- //# sourceMappingURL=index.js.map
408
- //# sourceMappingURL=index.js.map