@rootnative/inertia 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -5
- package/README.md +5 -3
- package/dist/{chunk-SGUHE5CX.mjs → chunk-4ASOELLA.mjs} +1 -1
- package/dist/{chunk-CSODMRJ7.mjs → chunk-55W7BNO2.mjs} +475 -83
- package/dist/chunk-5SRD2WCO.js +8 -0
- package/dist/{chunk-PTRF47DA.js → chunk-7A6WTXNK.js} +10 -3
- package/dist/{chunk-3XTVY34H.js → chunk-CENTULW6.js} +2 -2
- package/dist/{chunk-4PEHWDAZ.js → chunk-D5KAHWMC.js} +7 -7
- package/dist/{chunk-O22NXXCZ.mjs → chunk-J5Q46OPW.mjs} +1 -1
- package/dist/{chunk-RGNX6UZN.mjs → chunk-K3CLP74S.mjs} +2 -2
- package/dist/{chunk-BP3Y2SHQ.js → chunk-MYE5NMXW.js} +495 -101
- package/dist/{chunk-OQV66TBQ.mjs → chunk-NAOXQJ7U.mjs} +1 -1
- package/dist/{chunk-R63GIUNU.mjs → chunk-QKC3APP4.mjs} +1 -1
- package/dist/{chunk-46P57VMY.mjs → chunk-RF7J5FRM.mjs} +1 -1
- package/dist/{chunk-CY7Y64C3.mjs → chunk-TU2XFPAK.mjs} +10 -4
- package/dist/chunk-TVFNJ25Z.js +8 -0
- package/dist/chunk-VLDIFL3F.js +8 -0
- package/dist/{chunk-7AOERN53.js → chunk-WVRCKOPO.js} +3 -3
- package/dist/{chunk-W5MC3P4N.js → chunk-XMEVPEMH.js} +2 -2
- package/dist/{chunk-BQQTHG2V.mjs → chunk-YKGY22SB.mjs} +1 -1
- package/dist/gestureLayer/index.d.mts +2 -2
- package/dist/gestureLayer/index.d.ts +2 -2
- package/dist/gestureLayer/index.js +10 -10
- package/dist/gestureLayer/index.mjs +3 -3
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +48 -169
- package/dist/index.mjs +17 -137
- package/dist/motion/Image.d.mts +1 -1
- package/dist/motion/Image.d.ts +1 -1
- package/dist/motion/Image.js +5 -5
- package/dist/motion/Image.mjs +4 -4
- package/dist/motion/Pressable.d.mts +1 -1
- package/dist/motion/Pressable.d.ts +1 -1
- package/dist/motion/Pressable.js +5 -5
- package/dist/motion/Pressable.mjs +4 -4
- package/dist/motion/ScrollView.d.mts +1 -1
- package/dist/motion/ScrollView.d.ts +1 -1
- package/dist/motion/ScrollView.js +5 -5
- package/dist/motion/ScrollView.mjs +4 -4
- package/dist/motion/Text.d.mts +1 -1
- package/dist/motion/Text.d.ts +1 -1
- package/dist/motion/Text.js +5 -5
- package/dist/motion/Text.mjs +4 -4
- package/dist/motion/View.d.mts +1 -1
- package/dist/motion/View.d.ts +1 -1
- package/dist/motion/View.js +5 -5
- package/dist/motion/View.mjs +4 -4
- package/dist/touch/index.d.mts +1 -1
- package/dist/touch/index.d.ts +1 -1
- package/dist/touch/index.js +3 -3
- package/dist/touch/index.mjs +1 -1
- package/dist/{types-G1dBU2IQ.d.mts → types-37pN82yh.d.mts} +49 -14
- package/dist/{types-G1dBU2IQ.d.ts → types-37pN82yh.d.ts} +49 -14
- package/dist/{useGesture-D1e4ixJo.d.ts → useGesture-Cl4uzZIr.d.ts} +1 -1
- package/dist/{useGesture-RFY6kTL3.d.mts → useGesture-_IKkS8Dv.d.mts} +1 -1
- package/llms.txt +3 -1
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/internal/boxShadow.ts +177 -6
- package/src/internal/nonWorkletWarning.ts +4 -6
- package/src/internal/warnOnce.ts +28 -0
- package/src/layout/index.ts +10 -0
- package/src/layout/measureWindow.ts +135 -0
- package/src/layout/sharedRegistry.ts +107 -18
- package/src/layout/useSharedLayout.ts +256 -91
- package/src/motion/createMotionComponent.tsx +378 -39
- package/src/motion/installCheck.ts +1 -1
- package/src/transitions/index.ts +1 -1
- package/src/types.ts +52 -12
- package/src/values/useColorTransition.ts +1 -1
- package/dist/chunk-FNVFV4EY.js +0 -8
- package/dist/chunk-FWQOXA43.js +0 -8
- package/dist/chunk-KBP4LR75.js +0 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkWVRCKOPO_js = require('./chunk-WVRCKOPO.js');
|
|
4
|
+
var chunk7A6WTXNK_js = require('./chunk-7A6WTXNK.js');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var Animated = require('react-native-reanimated');
|
|
@@ -135,20 +135,189 @@ function PresenceItem({
|
|
|
135
135
|
);
|
|
136
136
|
return /* @__PURE__ */ jsxRuntime.jsx(PresenceContext.Provider, { value, children });
|
|
137
137
|
}
|
|
138
|
+
|
|
139
|
+
// src/internal/boxShadow.ts
|
|
140
|
+
var LENGTH = /^[+-]?(\d+\.?\d*|\.\d+)(px)?$/i;
|
|
141
|
+
var UNIT_LIKE = /^[+-]?(\d+\.?\d*|\.\d+)[a-z%]+$/i;
|
|
142
|
+
function invalid(input, reason) {
|
|
143
|
+
return new Error(
|
|
144
|
+
`[inertia] parseBoxShadow: ${reason} in ${JSON.stringify(input)}. Expected CSS box-shadow syntax with px lengths: '[inset] <offset-x> <offset-y> [blur] [spread] [color], ...'`
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
function splitLayers(input) {
|
|
148
|
+
const layers = [];
|
|
149
|
+
let depth = 0;
|
|
150
|
+
let start = 0;
|
|
151
|
+
for (let i = 0; i < input.length; i++) {
|
|
152
|
+
const ch = input[i];
|
|
153
|
+
if (ch === "(") depth++;
|
|
154
|
+
else if (ch === ")") depth--;
|
|
155
|
+
else if (ch === "," && depth === 0) {
|
|
156
|
+
layers.push(input.slice(start, i));
|
|
157
|
+
start = i + 1;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
layers.push(input.slice(start));
|
|
161
|
+
return layers;
|
|
162
|
+
}
|
|
163
|
+
function tokenize(layer) {
|
|
164
|
+
const tokens = [];
|
|
165
|
+
let depth = 0;
|
|
166
|
+
let current = "";
|
|
167
|
+
for (const ch of layer) {
|
|
168
|
+
if (ch === "(") depth++;
|
|
169
|
+
else if (ch === ")") depth--;
|
|
170
|
+
if (depth === 0 && /\s/.test(ch)) {
|
|
171
|
+
if (current) tokens.push(current);
|
|
172
|
+
current = "";
|
|
173
|
+
} else {
|
|
174
|
+
current += ch;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (current) tokens.push(current);
|
|
178
|
+
return tokens;
|
|
179
|
+
}
|
|
180
|
+
function parseBoxShadow(input) {
|
|
181
|
+
const trimmed = input.trim();
|
|
182
|
+
if (trimmed === "") throw invalid(input, "empty string");
|
|
183
|
+
if (trimmed.toLowerCase() === "none") return [];
|
|
184
|
+
return splitLayers(trimmed).map((layerString) => {
|
|
185
|
+
const tokens = tokenize(layerString.trim());
|
|
186
|
+
if (tokens.length === 0) throw invalid(input, "empty layer");
|
|
187
|
+
const lengths = [];
|
|
188
|
+
let color;
|
|
189
|
+
let inset = false;
|
|
190
|
+
for (const token of tokens) {
|
|
191
|
+
if (token.toLowerCase() === "inset") {
|
|
192
|
+
if (inset) throw invalid(input, "duplicate 'inset'");
|
|
193
|
+
inset = true;
|
|
194
|
+
} else if (LENGTH.test(token)) {
|
|
195
|
+
lengths.push(parseFloat(token));
|
|
196
|
+
} else if (UNIT_LIKE.test(token)) {
|
|
197
|
+
throw invalid(input, `unsupported unit in ${JSON.stringify(token)}`);
|
|
198
|
+
} else {
|
|
199
|
+
if (color !== void 0) throw invalid(input, "multiple colors");
|
|
200
|
+
color = token;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (lengths.length < 2 || lengths.length > 4) {
|
|
204
|
+
throw invalid(input, `expected 2-4 lengths, got ${lengths.length}`);
|
|
205
|
+
}
|
|
206
|
+
const [offsetX = 0, offsetY = 0, blurRadius = 0, spreadDistance = 0] = lengths;
|
|
207
|
+
if (blurRadius < 0) throw invalid(input, "negative blur radius");
|
|
208
|
+
return {
|
|
209
|
+
offsetX,
|
|
210
|
+
offsetY,
|
|
211
|
+
blurRadius,
|
|
212
|
+
spreadDistance,
|
|
213
|
+
color: color ?? "black",
|
|
214
|
+
inset
|
|
215
|
+
};
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function resolveBoxShadowInput(input) {
|
|
219
|
+
if (input === void 0) return [];
|
|
220
|
+
if (typeof input === "string") return parseBoxShadow(input);
|
|
221
|
+
return input.map((layer) => ({
|
|
222
|
+
offsetX: coerceLength(layer.offsetX, "offsetX"),
|
|
223
|
+
offsetY: coerceLength(layer.offsetY, "offsetY"),
|
|
224
|
+
blurRadius: coerceLength(layer.blurRadius, "blurRadius"),
|
|
225
|
+
spreadDistance: coerceLength(layer.spreadDistance, "spreadDistance"),
|
|
226
|
+
color: layer.color ?? "black",
|
|
227
|
+
inset: layer.inset ?? false
|
|
228
|
+
}));
|
|
229
|
+
}
|
|
230
|
+
function pairBoxShadowLayers(from, to) {
|
|
231
|
+
const count = Math.max(from.length, to.length);
|
|
232
|
+
const pairs = [];
|
|
233
|
+
for (let i = 0; i < count; i++) {
|
|
234
|
+
const a = from[i];
|
|
235
|
+
const b = to[i];
|
|
236
|
+
const fromLayer = a ?? invisibleLayer(b.inset);
|
|
237
|
+
const toLayer = b ?? invisibleLayer(a.inset);
|
|
238
|
+
if (fromLayer.inset !== toLayer.inset) {
|
|
239
|
+
throw new Error(
|
|
240
|
+
`[inertia] useShadow: boxShadow layer ${i} is 'inset' on one side but not the other \u2014 inset cannot be interpolated. Give both sides the same inset-ness (pad with a transparent layer if needed).`
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
pairs.push({ from: fromLayer, to: toLayer });
|
|
244
|
+
}
|
|
245
|
+
return pairs;
|
|
246
|
+
}
|
|
247
|
+
function invisibleLayer(inset) {
|
|
248
|
+
return {
|
|
249
|
+
offsetX: 0,
|
|
250
|
+
offsetY: 0,
|
|
251
|
+
blurRadius: 0,
|
|
252
|
+
spreadDistance: 0,
|
|
253
|
+
color: "transparent",
|
|
254
|
+
inset
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function coerceLength(value, field) {
|
|
258
|
+
if (value === void 0) return 0;
|
|
259
|
+
if (typeof value === "number") return value;
|
|
260
|
+
const trimmed = typeof value === "string" ? value.trim() : "";
|
|
261
|
+
if (!LENGTH.test(trimmed)) {
|
|
262
|
+
throw new Error(
|
|
263
|
+
`[inertia] boxShadow: ${field} must be a number or a px length, got ${JSON.stringify(value)}.`
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
return parseFloat(trimmed);
|
|
267
|
+
}
|
|
268
|
+
function strip(layer) {
|
|
269
|
+
const { inset: _inset, ...rest } = layer;
|
|
270
|
+
return rest;
|
|
271
|
+
}
|
|
272
|
+
function markInset(insets, i, count) {
|
|
273
|
+
const list = insets ?? new Array(count).fill(false);
|
|
274
|
+
list[i] = true;
|
|
275
|
+
return list;
|
|
276
|
+
}
|
|
277
|
+
function normalizeBoxShadow(input) {
|
|
278
|
+
const resolved = resolveBoxShadowInput(input);
|
|
279
|
+
const layers = [];
|
|
280
|
+
let insets = null;
|
|
281
|
+
for (let i = 0; i < resolved.length; i++) {
|
|
282
|
+
const layer = resolved[i];
|
|
283
|
+
layers.push(strip(layer));
|
|
284
|
+
if (layer.inset) insets = markInset(insets, i, resolved.length);
|
|
285
|
+
}
|
|
286
|
+
return { layers, insets };
|
|
287
|
+
}
|
|
288
|
+
function prepareBoxShadowAnimation(current, target) {
|
|
289
|
+
const pairs = pairBoxShadowLayers(
|
|
290
|
+
current.layers.map((layer, i) => ({
|
|
291
|
+
...layer,
|
|
292
|
+
inset: current.insets?.[i] ?? false
|
|
293
|
+
})),
|
|
294
|
+
resolveBoxShadowInput(target)
|
|
295
|
+
);
|
|
296
|
+
const from = [];
|
|
297
|
+
const to = [];
|
|
298
|
+
let insets = null;
|
|
299
|
+
for (let i = 0; i < pairs.length; i++) {
|
|
300
|
+
const pair = pairs[i];
|
|
301
|
+
from.push(strip(pair.from));
|
|
302
|
+
to.push(strip(pair.to));
|
|
303
|
+
if (pair.to.inset) insets = markInset(insets, i, pairs.length);
|
|
304
|
+
}
|
|
305
|
+
return { from, to, insets };
|
|
306
|
+
}
|
|
138
307
|
function resolveLayoutTransition(layout) {
|
|
139
308
|
if (!layout) return void 0;
|
|
140
309
|
const cfg = layout === true ? { type: "spring" } : layout;
|
|
141
310
|
if (cfg.type === "no-animation") return void 0;
|
|
142
311
|
if (cfg.type === "timing") {
|
|
143
312
|
let builder2 = Animated.LinearTransition.duration(cfg.duration ?? 300);
|
|
144
|
-
const easing =
|
|
313
|
+
const easing = chunk7A6WTXNK_js.ensureWorkletEasing(cfg.easing);
|
|
145
314
|
if (easing) builder2 = builder2.easing(easing);
|
|
146
315
|
if (cfg.delay) builder2 = builder2.delay(cfg.delay);
|
|
147
316
|
return builder2;
|
|
148
317
|
}
|
|
149
318
|
const spring = cfg.type === "decay" ? { type: "spring" } : cfg;
|
|
150
|
-
const { stiffness, damping, mass } =
|
|
151
|
-
...
|
|
319
|
+
const { stiffness, damping, mass } = chunk7A6WTXNK_js.springToReanimated({
|
|
320
|
+
...chunk7A6WTXNK_js.DEFAULT_SPRING,
|
|
152
321
|
...spring
|
|
153
322
|
});
|
|
154
323
|
let builder = Animated.LinearTransition.springify().stiffness(stiffness).damping(damping).mass(mass);
|
|
@@ -168,72 +337,138 @@ function sweepExpired(at) {
|
|
|
168
337
|
if (entry.expiresAt < at) REGISTRY.delete(id);
|
|
169
338
|
}
|
|
170
339
|
}
|
|
171
|
-
function registerLayout(id, rect) {
|
|
340
|
+
function registerLayout(id, rect, remeasure, readStyles) {
|
|
172
341
|
const at = now();
|
|
173
342
|
sweepExpired(at);
|
|
174
|
-
REGISTRY.set(id, {
|
|
343
|
+
REGISTRY.set(id, {
|
|
344
|
+
rect,
|
|
345
|
+
expiresAt: at + SHARED_LAYOUT_TTL_MS,
|
|
346
|
+
remeasure,
|
|
347
|
+
readStyles
|
|
348
|
+
});
|
|
175
349
|
}
|
|
176
|
-
function releaseLayout(id, rect) {
|
|
350
|
+
function releaseLayout(id, rect, styles) {
|
|
177
351
|
const at = now();
|
|
178
352
|
sweepExpired(at);
|
|
179
|
-
REGISTRY.set(id, { rect, expiresAt: at + SHARED_LAYOUT_TTL_MS });
|
|
353
|
+
REGISTRY.set(id, { rect, expiresAt: at + SHARED_LAYOUT_TTL_MS, styles });
|
|
180
354
|
}
|
|
181
355
|
function consumeLayout(id) {
|
|
182
356
|
const entry = REGISTRY.get(id);
|
|
183
357
|
if (!entry) return void 0;
|
|
184
358
|
REGISTRY.delete(id);
|
|
185
359
|
if (entry.expiresAt < now()) return void 0;
|
|
186
|
-
return
|
|
360
|
+
return {
|
|
361
|
+
rect: entry.rect,
|
|
362
|
+
remeasure: entry.remeasure,
|
|
363
|
+
styles: entry.styles,
|
|
364
|
+
readStyles: entry.readStyles
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// src/layout/measureWindow.ts
|
|
369
|
+
var defaultMeasurer = (node) => {
|
|
370
|
+
const measure = node?.measureInWindow;
|
|
371
|
+
if (typeof measure !== "function") return void 0;
|
|
372
|
+
let result;
|
|
373
|
+
let returned = false;
|
|
374
|
+
try {
|
|
375
|
+
measure.call(node, (x, y, width, height) => {
|
|
376
|
+
if (returned) return;
|
|
377
|
+
result = { x, y, width, height };
|
|
378
|
+
});
|
|
379
|
+
} catch {
|
|
380
|
+
returned = true;
|
|
381
|
+
return void 0;
|
|
382
|
+
}
|
|
383
|
+
returned = true;
|
|
384
|
+
return result;
|
|
385
|
+
};
|
|
386
|
+
var measurer = defaultMeasurer;
|
|
387
|
+
function usable(rect) {
|
|
388
|
+
const { x, y, width, height } = rect;
|
|
389
|
+
for (const v of [x, y, width, height]) {
|
|
390
|
+
if (typeof v !== "number" || !Number.isFinite(v)) return false;
|
|
391
|
+
}
|
|
392
|
+
return width !== 0 || height !== 0;
|
|
393
|
+
}
|
|
394
|
+
function measureWindowRect(node) {
|
|
395
|
+
const measured = measurer(node);
|
|
396
|
+
if (!measured || !usable(measured)) return void 0;
|
|
397
|
+
return toSharedRect(measured, "window");
|
|
398
|
+
}
|
|
399
|
+
function toSharedRect(rect, space) {
|
|
400
|
+
return { ...rect, space };
|
|
187
401
|
}
|
|
188
402
|
function useSharedLayout(options) {
|
|
189
|
-
const {
|
|
403
|
+
const {
|
|
404
|
+
layoutId,
|
|
405
|
+
userRef,
|
|
406
|
+
transition,
|
|
407
|
+
shouldReduceMotion,
|
|
408
|
+
userOnLayout,
|
|
409
|
+
readStyles
|
|
410
|
+
} = options;
|
|
190
411
|
const dx = Animated.useSharedValue(0);
|
|
191
412
|
const dy = Animated.useSharedValue(0);
|
|
192
413
|
const sx = Animated.useSharedValue(1);
|
|
193
414
|
const sy = Animated.useSharedValue(1);
|
|
415
|
+
const snapshot = Animated.useSharedValue(null);
|
|
416
|
+
const carryProgress = Animated.useSharedValue(0);
|
|
194
417
|
const lastRectRef = react.useRef(null);
|
|
195
418
|
const consumedRef = react.useRef(false);
|
|
419
|
+
const nodeRef = react.useRef(null);
|
|
196
420
|
const transitionRef = react.useRef(transition);
|
|
197
421
|
transitionRef.current = transition;
|
|
198
422
|
const reducedMotionRef = react.useRef(shouldReduceMotion);
|
|
199
423
|
reducedMotionRef.current = shouldReduceMotion;
|
|
424
|
+
const readStylesRef = react.useRef(readStyles);
|
|
425
|
+
readStylesRef.current = readStyles;
|
|
200
426
|
const setRef = react.useCallback(
|
|
201
427
|
(node) => {
|
|
428
|
+
nodeRef.current = node;
|
|
202
429
|
if (typeof userRef === "function") userRef(node);
|
|
203
430
|
else if (userRef) userRef.current = node;
|
|
204
431
|
},
|
|
205
432
|
[userRef]
|
|
206
433
|
);
|
|
434
|
+
const remeasure = react.useCallback(() => measureWindowRect(nodeRef.current), []);
|
|
435
|
+
const snapshotStyles = react.useCallback(() => readStylesRef.current?.(), []);
|
|
436
|
+
const startTransition = react.useCallback(
|
|
437
|
+
(source, sourceRect, target) => {
|
|
438
|
+
if (sourceRect.space !== target.space) return;
|
|
439
|
+
const shared = {
|
|
440
|
+
transition: transitionRef.current,
|
|
441
|
+
shouldReduceMotion: reducedMotionRef.current
|
|
442
|
+
};
|
|
443
|
+
applyFlip({ source: sourceRect, target, dx, dy, sx, sy, ...shared });
|
|
444
|
+
applyStyleCarry({
|
|
445
|
+
snapshot,
|
|
446
|
+
progress: carryProgress,
|
|
447
|
+
// Prefer a live read for the same reason the rect is re-measured: a
|
|
448
|
+
// still-mounted source may have moved on since its last layout.
|
|
449
|
+
styles: source.readStyles?.() ?? source.styles,
|
|
450
|
+
...shared
|
|
451
|
+
});
|
|
452
|
+
},
|
|
453
|
+
[dx, dy, sx, sy, snapshot, carryProgress]
|
|
454
|
+
);
|
|
207
455
|
const onLayout = react.useCallback(
|
|
208
456
|
(event) => {
|
|
209
457
|
userOnLayout?.(event);
|
|
210
458
|
if (!layoutId) return;
|
|
211
459
|
const { x, y, width, height } = event.nativeEvent.layout;
|
|
212
|
-
const rect = { x, y, width, height };
|
|
213
|
-
lastRectRef.current = rect;
|
|
214
460
|
let source;
|
|
215
461
|
if (!consumedRef.current) {
|
|
216
462
|
consumedRef.current = true;
|
|
217
463
|
source = consumeLayout(layoutId);
|
|
218
464
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
dx,
|
|
225
|
-
dy,
|
|
226
|
-
sx,
|
|
227
|
-
sy,
|
|
228
|
-
transition: transitionRef.current,
|
|
229
|
-
shouldReduceMotion: reducedMotionRef.current
|
|
230
|
-
});
|
|
231
|
-
}
|
|
465
|
+
const rect = measureWindowRect(nodeRef.current) ?? { x, y, width, height, space: "parent" };
|
|
466
|
+
lastRectRef.current = rect;
|
|
467
|
+
registerLayout(layoutId, rect, remeasure, snapshotStyles);
|
|
468
|
+
if (!source) return;
|
|
469
|
+
startTransition(source, source.remeasure?.() ?? source.rect, rect);
|
|
232
470
|
},
|
|
233
|
-
|
|
234
|
-
// exhaustive-deps would flag them — including them is harmless and
|
|
235
|
-
// silences the warning.
|
|
236
|
-
[layoutId, userOnLayout, dx, dy, sx, sy]
|
|
471
|
+
[layoutId, userOnLayout, remeasure, snapshotStyles, startTransition]
|
|
237
472
|
);
|
|
238
473
|
react.useEffect(() => {
|
|
239
474
|
consumedRef.current = false;
|
|
@@ -243,18 +478,49 @@ function useSharedLayout(options) {
|
|
|
243
478
|
if (!layoutId) return;
|
|
244
479
|
const rect = lastRectRef.current;
|
|
245
480
|
if (!rect) return;
|
|
246
|
-
releaseLayout(layoutId, rect);
|
|
481
|
+
releaseLayout(layoutId, rect, snapshotStyles());
|
|
247
482
|
};
|
|
248
|
-
}, [layoutId]);
|
|
483
|
+
}, [layoutId, snapshotStyles]);
|
|
484
|
+
react.useEffect(
|
|
485
|
+
() => () => {
|
|
486
|
+
Animated.cancelAnimation(dx);
|
|
487
|
+
Animated.cancelAnimation(dy);
|
|
488
|
+
Animated.cancelAnimation(sx);
|
|
489
|
+
Animated.cancelAnimation(sy);
|
|
490
|
+
Animated.cancelAnimation(carryProgress);
|
|
491
|
+
},
|
|
492
|
+
// The FLIP shared values are identity-stable per hook instance.
|
|
493
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
494
|
+
[]
|
|
495
|
+
);
|
|
249
496
|
return react.useMemo(
|
|
250
497
|
() => ({
|
|
251
498
|
flip: { dx, dy, sx, sy },
|
|
499
|
+
carry: { snapshot, progress: carryProgress },
|
|
252
500
|
setRef,
|
|
253
501
|
onLayout
|
|
254
502
|
}),
|
|
255
|
-
[dx, dy, sx, sy, setRef, onLayout]
|
|
503
|
+
[dx, dy, sx, sy, snapshot, carryProgress, setRef, onLayout]
|
|
256
504
|
);
|
|
257
505
|
}
|
|
506
|
+
function legBuilder(transition) {
|
|
507
|
+
if (transition?.type === "timing") {
|
|
508
|
+
const duration = transition.duration ?? 300;
|
|
509
|
+
return (from, to) => Animated.withSequence(
|
|
510
|
+
Animated.withTiming(from, { duration: 0 }),
|
|
511
|
+
Animated.withTiming(to, { duration })
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
const springCfg = transition?.type === "spring" ? { ...chunk7A6WTXNK_js.DEFAULT_SPRING, ...transition } : { type: "spring", ...chunk7A6WTXNK_js.DEFAULT_SPRING };
|
|
515
|
+
const springParams = chunk7A6WTXNK_js.springToReanimated(springCfg);
|
|
516
|
+
return (from, to) => Animated.withSequence(
|
|
517
|
+
Animated.withTiming(from, { duration: 0 }),
|
|
518
|
+
Animated.withSpring(to, springParams)
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
function shouldSnap(transition, shouldReduceMotion) {
|
|
522
|
+
return shouldReduceMotion || transition?.type === "no-animation";
|
|
523
|
+
}
|
|
258
524
|
function applyFlip(args) {
|
|
259
525
|
const { source, target, dx, dy, sx, sy, transition, shouldReduceMotion } = args;
|
|
260
526
|
const sourceCenterX = source.x + source.width / 2;
|
|
@@ -265,58 +531,29 @@ function applyFlip(args) {
|
|
|
265
531
|
const deltaY = sourceCenterY - targetCenterY;
|
|
266
532
|
const scaleX = target.width > 0 ? source.width / target.width : 1;
|
|
267
533
|
const scaleY = target.height > 0 ? source.height / target.height : 1;
|
|
268
|
-
if (shouldReduceMotion) {
|
|
534
|
+
if (shouldSnap(transition, shouldReduceMotion)) {
|
|
269
535
|
dx.value = 0;
|
|
270
536
|
dy.value = 0;
|
|
271
537
|
sx.value = 1;
|
|
272
538
|
sy.value = 1;
|
|
273
539
|
return;
|
|
274
540
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
);
|
|
288
|
-
dy.value = Animated.withSequence(
|
|
289
|
-
Animated.withTiming(deltaY, { duration: 0 }),
|
|
290
|
-
Animated.withTiming(0, { duration })
|
|
291
|
-
);
|
|
292
|
-
sx.value = Animated.withSequence(
|
|
293
|
-
Animated.withTiming(scaleX, { duration: 0 }),
|
|
294
|
-
Animated.withTiming(1, { duration })
|
|
295
|
-
);
|
|
296
|
-
sy.value = Animated.withSequence(
|
|
297
|
-
Animated.withTiming(scaleY, { duration: 0 }),
|
|
298
|
-
Animated.withTiming(1, { duration })
|
|
299
|
-
);
|
|
541
|
+
const leg = legBuilder(transition);
|
|
542
|
+
dx.value = leg(deltaX, 0);
|
|
543
|
+
dy.value = leg(deltaY, 0);
|
|
544
|
+
sx.value = leg(scaleX, 1);
|
|
545
|
+
sy.value = leg(scaleY, 1);
|
|
546
|
+
}
|
|
547
|
+
function applyStyleCarry(args) {
|
|
548
|
+
const { snapshot, progress, styles, transition, shouldReduceMotion } = args;
|
|
549
|
+
if (!styles) return;
|
|
550
|
+
if (shouldSnap(transition, shouldReduceMotion)) {
|
|
551
|
+
snapshot.value = null;
|
|
552
|
+
progress.value = 0;
|
|
300
553
|
return;
|
|
301
554
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
dx.value = Animated.withSequence(
|
|
305
|
-
Animated.withTiming(deltaX, { duration: 0 }),
|
|
306
|
-
Animated.withSpring(0, springParams)
|
|
307
|
-
);
|
|
308
|
-
dy.value = Animated.withSequence(
|
|
309
|
-
Animated.withTiming(deltaY, { duration: 0 }),
|
|
310
|
-
Animated.withSpring(0, springParams)
|
|
311
|
-
);
|
|
312
|
-
sx.value = Animated.withSequence(
|
|
313
|
-
Animated.withTiming(scaleX, { duration: 0 }),
|
|
314
|
-
Animated.withSpring(1, springParams)
|
|
315
|
-
);
|
|
316
|
-
sy.value = Animated.withSequence(
|
|
317
|
-
Animated.withTiming(scaleY, { duration: 0 }),
|
|
318
|
-
Animated.withSpring(1, springParams)
|
|
319
|
-
);
|
|
555
|
+
snapshot.value = styles;
|
|
556
|
+
progress.value = legBuilder(transition)(1, 0);
|
|
320
557
|
}
|
|
321
558
|
var alreadyChecked = false;
|
|
322
559
|
function ensureReanimatedInstalled() {
|
|
@@ -330,7 +567,7 @@ function ensureReanimatedInstalled() {
|
|
|
330
567
|
const major = parseInt(version.split(".")[0] ?? "0", 10);
|
|
331
568
|
if (major < 4) {
|
|
332
569
|
console.error(
|
|
333
|
-
`[inertia] react-native-reanimated
|
|
570
|
+
`[inertia] react-native-reanimated ${version} is installed, but @rootnative/inertia requires 4.0.0 or later. Upgrade with \`pnpm add react-native-reanimated@^4\` (or your package manager's equivalent).`
|
|
334
571
|
);
|
|
335
572
|
return;
|
|
336
573
|
}
|
|
@@ -373,15 +610,28 @@ var COLOR_KEYS = [
|
|
|
373
610
|
"shadowColor"
|
|
374
611
|
];
|
|
375
612
|
var SHADOW_OFFSET_KEYS = ["shadowOffsetWidth", "shadowOffsetHeight"];
|
|
613
|
+
var STRUCTURED_KEYS = ["boxShadow"];
|
|
614
|
+
var SHARED_STYLE_KEYS = [
|
|
615
|
+
"opacity",
|
|
616
|
+
"borderRadius",
|
|
617
|
+
"backgroundColor",
|
|
618
|
+
"borderColor",
|
|
619
|
+
"color",
|
|
620
|
+
"tintColor"
|
|
621
|
+
];
|
|
376
622
|
var ALL_KEYS = [
|
|
377
623
|
...TRANSFORM_KEYS,
|
|
378
624
|
...NUMERIC_TOP_LEVEL_KEYS,
|
|
379
625
|
...COLOR_KEYS,
|
|
380
|
-
...SHADOW_OFFSET_KEYS
|
|
626
|
+
...SHADOW_OFFSET_KEYS,
|
|
627
|
+
...STRUCTURED_KEYS
|
|
381
628
|
];
|
|
382
629
|
var TRANSFORM_KEY_SET = new Set(TRANSFORM_KEYS);
|
|
383
630
|
var COLOR_KEY_SET = new Set(COLOR_KEYS);
|
|
384
631
|
var SHADOW_OFFSET_KEY_SET = new Set(SHADOW_OFFSET_KEYS);
|
|
632
|
+
var STRUCTURED_KEY_SET = new Set(STRUCTURED_KEYS);
|
|
633
|
+
var SHARED_STYLE_KEY_SET = new Set(SHARED_STYLE_KEYS);
|
|
634
|
+
var NO_BOX_SHADOW = Object.freeze([]);
|
|
385
635
|
var GESTURE_LAYER_NAMES = [
|
|
386
636
|
"hovered",
|
|
387
637
|
"focused",
|
|
@@ -416,19 +666,20 @@ var DEFAULT_RESTING = {
|
|
|
416
666
|
tintColor: "transparent",
|
|
417
667
|
shadowColor: "transparent",
|
|
418
668
|
shadowOffsetWidth: 0,
|
|
419
|
-
shadowOffsetHeight: 0
|
|
669
|
+
shadowOffsetHeight: 0,
|
|
670
|
+
boxShadow: NO_BOX_SHADOW
|
|
420
671
|
};
|
|
421
672
|
function transitionFor(prop, transition) {
|
|
422
673
|
if (!transition) return void 0;
|
|
423
674
|
if (typeof transition === "string") return void 0;
|
|
424
|
-
if (
|
|
675
|
+
if (chunk7A6WTXNK_js.isTopLevelTransition(transition)) return transition;
|
|
425
676
|
if (GESTURE_LAYER_NAME_SET.has(prop)) return void 0;
|
|
426
677
|
return transition[prop];
|
|
427
678
|
}
|
|
428
679
|
function gestureLayerTransitionFor(layer, transition) {
|
|
429
680
|
if (!transition) return void 0;
|
|
430
681
|
if (typeof transition === "string") return void 0;
|
|
431
|
-
if (
|
|
682
|
+
if (chunk7A6WTXNK_js.isTopLevelTransition(transition)) return transition;
|
|
432
683
|
return transition[layer];
|
|
433
684
|
}
|
|
434
685
|
function createMotionComponent(Component) {
|
|
@@ -478,12 +729,12 @@ function createMotionComponent(Component) {
|
|
|
478
729
|
onLayout: userOnLayout,
|
|
479
730
|
...rest
|
|
480
731
|
} = props;
|
|
481
|
-
const namedTransitions =
|
|
482
|
-
const transition =
|
|
732
|
+
const namedTransitions = chunkWVRCKOPO_js.useNamedTransitions();
|
|
733
|
+
const transition = chunkWVRCKOPO_js.resolveNamedTransitionProp(
|
|
483
734
|
transitionProp,
|
|
484
735
|
namedTransitions
|
|
485
736
|
);
|
|
486
|
-
const layout = typeof layoutProp === "string" ?
|
|
737
|
+
const layout = typeof layoutProp === "string" ? chunkWVRCKOPO_js.lookupNamedTransition(layoutProp, namedTransitions) : layoutProp;
|
|
487
738
|
if (__DEV__ && typeof style === "function") {
|
|
488
739
|
throw new Error(
|
|
489
740
|
"[inertia] `style` must be a style object or array of style objects, not a function. The function-form `style={(state) => ...}` Pressable API is not supported \u2014 use `gesture.pressed` (or `gesture.focused`, etc.) to drive state-dependent styling instead."
|
|
@@ -491,7 +742,7 @@ function createMotionComponent(Component) {
|
|
|
491
742
|
}
|
|
492
743
|
const presence = usePresence();
|
|
493
744
|
const isExiting = presence !== null && presence.isPresent === false;
|
|
494
|
-
const shouldReduceMotion =
|
|
745
|
+
const shouldReduceMotion = chunkWVRCKOPO_js.useShouldReduceMotion();
|
|
495
746
|
const onAnimationEndRef = react.useRef(onAnimationEnd);
|
|
496
747
|
onAnimationEndRef.current = onAnimationEnd;
|
|
497
748
|
const variantKey = useControllerKey(controller);
|
|
@@ -507,6 +758,16 @@ function createMotionComponent(Component) {
|
|
|
507
758
|
const [focused, setFocused] = react.useState(false);
|
|
508
759
|
const [focusVisible, setFocusVisible] = react.useState(false);
|
|
509
760
|
const [hovered, setHovered] = react.useState(false);
|
|
761
|
+
const hasLayoutId = layoutId !== void 0;
|
|
762
|
+
let flatStyle;
|
|
763
|
+
let flatStyleRead = false;
|
|
764
|
+
const getFlatStyle = () => {
|
|
765
|
+
if (!flatStyleRead) {
|
|
766
|
+
flatStyleRead = true;
|
|
767
|
+
flatStyle = reactNative.StyleSheet.flatten(style);
|
|
768
|
+
}
|
|
769
|
+
return flatStyle;
|
|
770
|
+
};
|
|
510
771
|
const touched = /* @__PURE__ */ new Set();
|
|
511
772
|
collectTouchedKeys(touched, animateRecord);
|
|
512
773
|
if (initialRecord) collectTouchedKeys(touched, initialRecord);
|
|
@@ -528,9 +789,19 @@ function createMotionComponent(Component) {
|
|
|
528
789
|
}
|
|
529
790
|
}
|
|
530
791
|
if (exitRecord) collectTouchedKeys(touched, exitRecord);
|
|
792
|
+
if (hasLayoutId) {
|
|
793
|
+
const flat = getFlatStyle();
|
|
794
|
+
if (flat) {
|
|
795
|
+
for (const key of SHARED_STYLE_KEYS) {
|
|
796
|
+
if (touched.has(key)) continue;
|
|
797
|
+
if (styleValueFor(flat, key) !== void 0) touched.add(key);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
531
801
|
const activeKeysRef = react.useRef(null);
|
|
532
802
|
const hasTransformRef = react.useRef(false);
|
|
533
803
|
const hasShadowOffsetRef = react.useRef(false);
|
|
804
|
+
const hasBoxShadowRef = react.useRef(false);
|
|
534
805
|
const prevActive = activeKeysRef.current;
|
|
535
806
|
let grew = prevActive === null;
|
|
536
807
|
if (!grew && prevActive) {
|
|
@@ -551,6 +822,15 @@ function createMotionComponent(Component) {
|
|
|
551
822
|
hasShadowOffsetRef.current = activeKeysRef.current.some(
|
|
552
823
|
(k) => SHADOW_OFFSET_KEY_SET.has(k)
|
|
553
824
|
);
|
|
825
|
+
hasBoxShadowRef.current = activeKeysRef.current.includes("boxShadow");
|
|
826
|
+
if (__DEV__ && hasBoxShadowRef.current && activeKeysRef.current.some(
|
|
827
|
+
(k) => k !== "boxShadow" && k.startsWith("shadow")
|
|
828
|
+
)) {
|
|
829
|
+
chunk7A6WTXNK_js.warnOnce(
|
|
830
|
+
"boxShadow-with-native-shadow",
|
|
831
|
+
"[inertia] `boxShadow` is animated alongside the native `shadow*` keys on the same element, which applies two shadow systems at once. Pick one: `boxShadow` for the cross-platform CSS form, or the native `shadow*` keys."
|
|
832
|
+
);
|
|
833
|
+
}
|
|
554
834
|
}
|
|
555
835
|
const drivenNow = /* @__PURE__ */ new Set();
|
|
556
836
|
collectTouchedKeys(drivenNow, animateRecord);
|
|
@@ -561,17 +841,35 @@ function createMotionComponent(Component) {
|
|
|
561
841
|
const activeKeys = activeKeysRef.current;
|
|
562
842
|
const everDriven = everDrivenRef.current;
|
|
563
843
|
const styleResting = {};
|
|
844
|
+
let styleRestingShadow = null;
|
|
564
845
|
if (activeKeys.some((k) => !everDriven.has(k))) {
|
|
565
|
-
const flat =
|
|
846
|
+
const flat = getFlatStyle();
|
|
566
847
|
if (flat) {
|
|
567
848
|
for (const key of activeKeys) {
|
|
568
849
|
if (everDriven.has(key)) continue;
|
|
850
|
+
if (key === "boxShadow") {
|
|
851
|
+
const raw = flat.boxShadow;
|
|
852
|
+
if (raw !== void 0) {
|
|
853
|
+
styleRestingShadow = normalizeBoxShadow(raw);
|
|
854
|
+
styleResting.boxShadow = styleRestingShadow.layers;
|
|
855
|
+
}
|
|
856
|
+
continue;
|
|
857
|
+
}
|
|
569
858
|
const v = styleValueFor(flat, key);
|
|
570
859
|
if (v !== void 0) styleResting[key] = v;
|
|
571
860
|
}
|
|
572
861
|
}
|
|
573
862
|
}
|
|
863
|
+
const boxShadowSeedRef = react.useRef(null);
|
|
864
|
+
if (boxShadowSeedRef.current === null) {
|
|
865
|
+
const source = initial === false ? animateRecord.boxShadow : initialRecord?.boxShadow ?? animateRecord.boxShadow;
|
|
866
|
+
boxShadowSeedRef.current = source !== void 0 ? normalizeBoxShadow(source) : styleRestingShadow ?? {
|
|
867
|
+
layers: [...NO_BOX_SHADOW],
|
|
868
|
+
insets: null
|
|
869
|
+
};
|
|
870
|
+
}
|
|
574
871
|
const sharedValues = useAnimatableSharedValues((key) => {
|
|
872
|
+
if (key === "boxShadow") return boxShadowSeedRef.current.layers;
|
|
575
873
|
if (SHADOW_OFFSET_KEY_SET.has(key)) {
|
|
576
874
|
const axis = shadowOffsetAxisFor(key);
|
|
577
875
|
if (initial === false) {
|
|
@@ -588,11 +886,17 @@ function createMotionComponent(Component) {
|
|
|
588
886
|
}
|
|
589
887
|
return initialRecord?.[key] ?? restValue(animateRecord[key]) ?? styleResting[key] ?? DEFAULT_RESTING[key];
|
|
590
888
|
});
|
|
591
|
-
const
|
|
889
|
+
const boxShadowInsets = Animated.useSharedValue(
|
|
890
|
+
boxShadowSeedRef.current.insets
|
|
891
|
+
);
|
|
892
|
+
const styleRestingSig = chunk7A6WTXNK_js.stableSig(styleResting);
|
|
592
893
|
react.useEffect(() => {
|
|
593
894
|
for (const key of activeKeysRef.current) {
|
|
594
895
|
if (everDrivenRef.current.has(key)) continue;
|
|
595
896
|
sharedValues[key].value = styleResting[key] ?? DEFAULT_RESTING[key];
|
|
897
|
+
if (key === "boxShadow") {
|
|
898
|
+
boxShadowInsets.value = styleRestingShadow?.insets ?? null;
|
|
899
|
+
}
|
|
596
900
|
}
|
|
597
901
|
}, [styleRestingSig]);
|
|
598
902
|
const pressedProgress = Animated.useSharedValue(0);
|
|
@@ -613,13 +917,13 @@ function createMotionComponent(Component) {
|
|
|
613
917
|
const gestureSV = Animated.useSharedValue(
|
|
614
918
|
resolveGestureLayers(gesture)
|
|
615
919
|
);
|
|
616
|
-
const gestureTargetsSig =
|
|
920
|
+
const gestureTargetsSig = chunk7A6WTXNK_js.stableSig(gesture);
|
|
617
921
|
react.useEffect(() => {
|
|
618
922
|
gestureSV.value = resolveGestureLayers(gesture);
|
|
619
923
|
}, [gestureTargetsSig]);
|
|
620
924
|
const baseRecord = isExiting && exitRecord ? { ...animateRecord, ...exitRecord } : animateRecord;
|
|
621
|
-
const baseSig =
|
|
622
|
-
const transitionSig =
|
|
925
|
+
const baseSig = chunk7A6WTXNK_js.stableSig(baseRecord) + (isExiting ? "|exit" : "") + (shouldReduceMotion ? "|rm" : "");
|
|
926
|
+
const transitionSig = chunk7A6WTXNK_js.stableSig(transition);
|
|
623
927
|
const safeToRemoveRef = react.useRef(void 0);
|
|
624
928
|
safeToRemoveRef.current = presence?.safeToRemove;
|
|
625
929
|
react.useEffect(() => {
|
|
@@ -649,6 +953,30 @@ function createMotionComponent(Component) {
|
|
|
649
953
|
}
|
|
650
954
|
const transformGroup = transformPending > 0 ? { remaining: transformPending } : void 0;
|
|
651
955
|
for (const key of ALL_KEYS) {
|
|
956
|
+
if (key === "boxShadow") {
|
|
957
|
+
const shadowTarget = baseRecord.boxShadow;
|
|
958
|
+
if (shadowTarget === void 0) continue;
|
|
959
|
+
const cfg2 = configFor("boxShadow");
|
|
960
|
+
if (isExiting && reachesTerminalPhase(cfg2)) pending++;
|
|
961
|
+
driveBoxShadow(
|
|
962
|
+
sharedValues.boxShadow,
|
|
963
|
+
boxShadowInsets,
|
|
964
|
+
shadowTarget,
|
|
965
|
+
cfg2,
|
|
966
|
+
makeKeyCallbackFactory(
|
|
967
|
+
"boxShadow",
|
|
968
|
+
sharedValues.boxShadow,
|
|
969
|
+
// The declared target, not the padded one — the padding is an
|
|
970
|
+
// implementation detail of getting Reanimated to interpolate.
|
|
971
|
+
shadowTarget,
|
|
972
|
+
onAnimationEndRef,
|
|
973
|
+
{ stepCount: 1, totalIterations: totalIterationsOf(cfg2) },
|
|
974
|
+
isExiting ? onSettle : void 0,
|
|
975
|
+
void 0
|
|
976
|
+
)
|
|
977
|
+
);
|
|
978
|
+
continue;
|
|
979
|
+
}
|
|
652
980
|
const target = SHADOW_OFFSET_KEY_SET.has(key) ? shadowOffsetAxisValue(
|
|
653
981
|
baseRecord.shadowOffset,
|
|
654
982
|
shadowOffsetAxisFor(key)
|
|
@@ -668,7 +996,7 @@ function createMotionComponent(Component) {
|
|
|
668
996
|
isExiting ? onSettle : void 0,
|
|
669
997
|
TRANSFORM_KEY_SET.has(key) ? transformGroup : void 0
|
|
670
998
|
);
|
|
671
|
-
sharedValues[key].value =
|
|
999
|
+
sharedValues[key].value = chunk7A6WTXNK_js.resolveAnimatableValue(
|
|
672
1000
|
target,
|
|
673
1001
|
cfg,
|
|
674
1002
|
factory
|
|
@@ -714,19 +1042,34 @@ function createMotionComponent(Component) {
|
|
|
714
1042
|
isExiting,
|
|
715
1043
|
shouldReduceMotion
|
|
716
1044
|
);
|
|
1045
|
+
const readSharedStyles = () => {
|
|
1046
|
+
if (!hasLayoutId) return void 0;
|
|
1047
|
+
const out = {};
|
|
1048
|
+
let any = false;
|
|
1049
|
+
for (const key of activeKeysRef.current) {
|
|
1050
|
+
if (!SHARED_STYLE_KEY_SET.has(key)) continue;
|
|
1051
|
+
const v = sharedValues[key].value;
|
|
1052
|
+
if (typeof v !== "number" && typeof v !== "string") continue;
|
|
1053
|
+
out[key] = v;
|
|
1054
|
+
any = true;
|
|
1055
|
+
}
|
|
1056
|
+
return any ? out : void 0;
|
|
1057
|
+
};
|
|
717
1058
|
const sharedLayout = useSharedLayout({
|
|
718
1059
|
layoutId,
|
|
719
1060
|
userRef: ref,
|
|
720
|
-
transition:
|
|
1061
|
+
transition: chunk7A6WTXNK_js.isTopLevelTransition(transition) ? transition : void 0,
|
|
721
1062
|
shouldReduceMotion,
|
|
722
|
-
userOnLayout
|
|
1063
|
+
userOnLayout,
|
|
1064
|
+
readStyles: readSharedStyles
|
|
723
1065
|
});
|
|
724
1066
|
const flip = sharedLayout.flip;
|
|
725
|
-
const
|
|
1067
|
+
const carry = sharedLayout.carry;
|
|
726
1068
|
const animatedStyle = Animated.useAnimatedStyle(() => {
|
|
727
1069
|
const activeKeys2 = activeKeysRef.current;
|
|
728
1070
|
const hasTransform = hasTransformRef.current;
|
|
729
1071
|
const hasShadowOffset = hasShadowOffsetRef.current;
|
|
1072
|
+
const hasBoxShadow = hasBoxShadowRef.current;
|
|
730
1073
|
const out = {};
|
|
731
1074
|
const transform = [];
|
|
732
1075
|
let shadowOffsetW = 0;
|
|
@@ -735,12 +1078,15 @@ function createMotionComponent(Component) {
|
|
|
735
1078
|
const pf = focusedProgress.value;
|
|
736
1079
|
const pfv = focusVisibleProgress.value;
|
|
737
1080
|
const pp = pressedProgress.value;
|
|
1081
|
+
const carried = carry.snapshot.value;
|
|
1082
|
+
const pc = carry.progress.value;
|
|
738
1083
|
const layers = gestureSV.value;
|
|
739
1084
|
const hoveredLayer = layers ? layers.hovered : null;
|
|
740
1085
|
const focusedLayer = layers ? layers.focused : null;
|
|
741
1086
|
const focusVisibleLayer = layers ? layers.focusVisible : null;
|
|
742
1087
|
const pressedLayer = layers ? layers.pressed : null;
|
|
743
1088
|
for (const key of activeKeys2) {
|
|
1089
|
+
if (key === "boxShadow") continue;
|
|
744
1090
|
let v = sharedValues[key].value;
|
|
745
1091
|
const isColor = COLOR_KEY_SET.has(key);
|
|
746
1092
|
if (hoveredLayer && ph > 0 && hoveredLayer[key] !== void 0) {
|
|
@@ -759,6 +1105,12 @@ function createMotionComponent(Component) {
|
|
|
759
1105
|
const t = pressedLayer[key];
|
|
760
1106
|
v = isColor ? Animated.interpolateColor(pp, [0, 1], [v, t]) : v + (t - v) * pp;
|
|
761
1107
|
}
|
|
1108
|
+
if (carried !== null && pc > 0) {
|
|
1109
|
+
const s = carried[key];
|
|
1110
|
+
if (s !== void 0) {
|
|
1111
|
+
v = isColor ? Animated.interpolateColor(pc, [0, 1], [v, s]) : v + (s - v) * pc;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
762
1114
|
if (TRANSFORM_KEY_SET.has(key)) {
|
|
763
1115
|
transform.push(
|
|
764
1116
|
ROTATION_KEYS.has(key) ? { [key]: `${v}deg` } : { [key]: v }
|
|
@@ -781,6 +1133,19 @@ function createMotionComponent(Component) {
|
|
|
781
1133
|
if (hasShadowOffset) {
|
|
782
1134
|
out.shadowOffset = { width: shadowOffsetW, height: shadowOffsetH };
|
|
783
1135
|
}
|
|
1136
|
+
if (hasBoxShadow) {
|
|
1137
|
+
const layers2 = sharedValues.boxShadow.value;
|
|
1138
|
+
const insets = boxShadowInsets.value;
|
|
1139
|
+
if (insets === null) {
|
|
1140
|
+
out.boxShadow = layers2;
|
|
1141
|
+
} else {
|
|
1142
|
+
const withInset = [];
|
|
1143
|
+
for (let i = 0; i < layers2.length; i++) {
|
|
1144
|
+
withInset.push({ ...layers2[i], inset: insets[i] });
|
|
1145
|
+
}
|
|
1146
|
+
out.boxShadow = withInset;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
784
1149
|
return out;
|
|
785
1150
|
});
|
|
786
1151
|
const mergedStyle = react.useMemo(
|
|
@@ -795,7 +1160,7 @@ function createMotionComponent(Component) {
|
|
|
795
1160
|
setFocusVisible,
|
|
796
1161
|
setHovered
|
|
797
1162
|
);
|
|
798
|
-
const layoutSig =
|
|
1163
|
+
const layoutSig = chunk7A6WTXNK_js.stableSig(layout);
|
|
799
1164
|
const layoutTransition = react.useMemo(
|
|
800
1165
|
() => shouldReduceMotion ? void 0 : resolveLayoutTransition(layout),
|
|
801
1166
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -855,7 +1220,9 @@ function useAnimatableSharedValues(init) {
|
|
|
855
1220
|
const width = Animated.useSharedValue(init("width"));
|
|
856
1221
|
const height = Animated.useSharedValue(init("height"));
|
|
857
1222
|
const borderRadius = Animated.useSharedValue(init("borderRadius"));
|
|
858
|
-
const shadowOpacity = Animated.useSharedValue(
|
|
1223
|
+
const shadowOpacity = Animated.useSharedValue(
|
|
1224
|
+
init("shadowOpacity")
|
|
1225
|
+
);
|
|
859
1226
|
const shadowRadius = Animated.useSharedValue(init("shadowRadius"));
|
|
860
1227
|
const elevation = Animated.useSharedValue(init("elevation"));
|
|
861
1228
|
const backgroundColor = Animated.useSharedValue(
|
|
@@ -871,6 +1238,7 @@ function useAnimatableSharedValues(init) {
|
|
|
871
1238
|
const shadowOffsetHeight = Animated.useSharedValue(
|
|
872
1239
|
init("shadowOffsetHeight")
|
|
873
1240
|
);
|
|
1241
|
+
const boxShadow = Animated.useSharedValue(init("boxShadow"));
|
|
874
1242
|
const ref = react.useRef(null);
|
|
875
1243
|
if (ref.current === null) {
|
|
876
1244
|
ref.current = {
|
|
@@ -895,7 +1263,8 @@ function useAnimatableSharedValues(init) {
|
|
|
895
1263
|
tintColor,
|
|
896
1264
|
shadowColor,
|
|
897
1265
|
shadowOffsetWidth,
|
|
898
|
-
shadowOffsetHeight
|
|
1266
|
+
shadowOffsetHeight,
|
|
1267
|
+
boxShadow
|
|
899
1268
|
};
|
|
900
1269
|
}
|
|
901
1270
|
const map = ref.current;
|
|
@@ -980,6 +1349,20 @@ function shadowOffsetAxisFor(key) {
|
|
|
980
1349
|
function shadowOffsetAxisValue(source, axis) {
|
|
981
1350
|
return source?.[axis];
|
|
982
1351
|
}
|
|
1352
|
+
function driveBoxShadow(slot, insetSlot, target, cfg, factory) {
|
|
1353
|
+
const currentLayers = Array.isArray(slot.value) ? slot.value : NO_BOX_SHADOW;
|
|
1354
|
+
const { from, to, insets } = prepareBoxShadowAnimation(
|
|
1355
|
+
{ layers: [...currentLayers], insets: insetSlot.value },
|
|
1356
|
+
target
|
|
1357
|
+
);
|
|
1358
|
+
insetSlot.value = insets;
|
|
1359
|
+
if (from.length !== currentLayers.length) slot.value = from;
|
|
1360
|
+
slot.value = chunk7A6WTXNK_js.resolveTransition(
|
|
1361
|
+
cfg,
|
|
1362
|
+
to,
|
|
1363
|
+
factory?.("animation", void 0)
|
|
1364
|
+
);
|
|
1365
|
+
}
|
|
983
1366
|
function styleValueFor(flat, key) {
|
|
984
1367
|
if (SHADOW_OFFSET_KEY_SET.has(key)) {
|
|
985
1368
|
return shadowOffsetAxisValue(
|
|
@@ -1096,6 +1479,15 @@ function resolveGestureLayers(gesture) {
|
|
|
1096
1479
|
if (!subState) continue;
|
|
1097
1480
|
const resolved = {};
|
|
1098
1481
|
for (const key of ALL_KEYS) {
|
|
1482
|
+
if (STRUCTURED_KEY_SET.has(key)) {
|
|
1483
|
+
if (__DEV__ && subState[key] !== void 0) {
|
|
1484
|
+
chunk7A6WTXNK_js.warnOnce(
|
|
1485
|
+
`gesture-structured-${layer}-${key}`,
|
|
1486
|
+
`[inertia] \`${key}\` is not supported inside \`gesture.${layer}\` and will be ignored. Drive it from \`animate\` (optionally via a variant keyed off the same state), or interpolate it yourself with \`useShadow\`.`
|
|
1487
|
+
);
|
|
1488
|
+
}
|
|
1489
|
+
continue;
|
|
1490
|
+
}
|
|
1099
1491
|
if (SHADOW_OFFSET_KEY_SET.has(key)) {
|
|
1100
1492
|
const axis = shadowOffsetAxisFor(key);
|
|
1101
1493
|
const so = subState.shadowOffset;
|
|
@@ -1113,7 +1505,7 @@ function resolveGestureLayers(gesture) {
|
|
|
1113
1505
|
return out;
|
|
1114
1506
|
}
|
|
1115
1507
|
function useGestureLayerProgress(progress, active, declared, layer, transition, isExiting, shouldReduceMotion) {
|
|
1116
|
-
const layerCfgSig =
|
|
1508
|
+
const layerCfgSig = chunk7A6WTXNK_js.stableSig(gestureLayerTransitionFor(layer, transition));
|
|
1117
1509
|
react.useEffect(() => {
|
|
1118
1510
|
if (!declared) return;
|
|
1119
1511
|
if (isExiting) {
|
|
@@ -1122,7 +1514,7 @@ function useGestureLayerProgress(progress, active, declared, layer, transition,
|
|
|
1122
1514
|
}
|
|
1123
1515
|
const target = active ? 1 : 0;
|
|
1124
1516
|
const cfg = shouldReduceMotion ? { type: "no-animation" } : gestureLayerTransitionFor(layer, transition) ?? { type: "spring" };
|
|
1125
|
-
progress.value =
|
|
1517
|
+
progress.value = chunk7A6WTXNK_js.resolveTransition(cfg, target);
|
|
1126
1518
|
}, [active, declared, isExiting, shouldReduceMotion, layerCfgSig]);
|
|
1127
1519
|
}
|
|
1128
1520
|
function useGestureHandlers(gesture, rest, setPressed, setFocused, setFocusVisible, setHovered) {
|
|
@@ -1146,7 +1538,7 @@ function useGestureHandlers(gesture, rest, setPressed, setFocused, setFocusVisib
|
|
|
1146
1538
|
if (gesture.focused || gesture.focusVisible) {
|
|
1147
1539
|
handlers.onFocus = compose(rest.onFocus, () => {
|
|
1148
1540
|
if (gesture.focused) setFocused(true);
|
|
1149
|
-
if (gesture.focusVisible &&
|
|
1541
|
+
if (gesture.focusVisible && chunkWVRCKOPO_js.isFocusVisible()) setFocusVisible(true);
|
|
1150
1542
|
});
|
|
1151
1543
|
handlers.onBlur = compose(rest.onBlur, () => {
|
|
1152
1544
|
if (gesture.focused) setFocused(false);
|
|
@@ -1187,4 +1579,6 @@ function compose(user, ours) {
|
|
|
1187
1579
|
|
|
1188
1580
|
exports.Presence = Presence;
|
|
1189
1581
|
exports.createMotionComponent = createMotionComponent;
|
|
1582
|
+
exports.pairBoxShadowLayers = pairBoxShadowLayers;
|
|
1583
|
+
exports.resolveBoxShadowInput = resolveBoxShadowInput;
|
|
1190
1584
|
exports.usePresence = usePresence;
|