@rootnative/inertia 0.0.4 → 0.0.6
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 +87 -1
- package/README.md +5 -1
- package/dist/{chunk-55W7BNO2.mjs → chunk-2ICQLWH2.mjs} +211 -93
- package/dist/{chunk-D5KAHWMC.js → chunk-4NAMD62I.js} +7 -7
- package/dist/{chunk-CENTULW6.js → chunk-5MGWHOSV.js} +2 -2
- package/dist/{chunk-MYE5NMXW.js → chunk-767UKZXG.js} +235 -116
- package/dist/{chunk-NAOXQJ7U.mjs → chunk-BAAQI37F.mjs} +1 -1
- package/dist/{chunk-RF7J5FRM.mjs → chunk-C3EDC5ZW.mjs} +1 -1
- package/dist/{chunk-YKGY22SB.mjs → chunk-CMHVF6F4.mjs} +1 -1
- package/dist/{chunk-4ASOELLA.mjs → chunk-F7LJX56B.mjs} +1 -1
- package/dist/chunk-FWWVHLXB.js +8 -0
- package/dist/chunk-K5SI6VXS.js +8 -0
- package/dist/{chunk-WVRCKOPO.js → chunk-OBRGJAST.js} +3 -3
- package/dist/{chunk-K3CLP74S.mjs → chunk-OW5XTGVN.mjs} +2 -2
- package/dist/{chunk-J5Q46OPW.mjs → chunk-PFPO7DX2.mjs} +1 -1
- package/dist/{chunk-7A6WTXNK.js → chunk-PM6CVGXJ.js} +1 -0
- package/dist/{chunk-TU2XFPAK.mjs → chunk-REYL77RE.mjs} +1 -0
- package/dist/chunk-STARIT6W.js +8 -0
- package/dist/{chunk-XMEVPEMH.js → chunk-X7B5WR5A.js} +2 -2
- package/dist/{chunk-QKC3APP4.mjs → chunk-Z3HCJ43H.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 +32 -4
- package/dist/index.d.ts +32 -4
- package/dist/index.js +52 -48
- package/dist/index.mjs +17 -17
- 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-37pN82yh.d.mts → types-BQgLJeQG.d.mts} +39 -3
- package/dist/{types-37pN82yh.d.ts → types-BQgLJeQG.d.ts} +39 -3
- package/dist/{useGesture-Cl4uzZIr.d.ts → useGesture-B0_CzOUz.d.ts} +1 -1
- package/dist/{useGesture-_IKkS8Dv.d.mts → useGesture-DfaTx-3t.d.mts} +1 -1
- package/llms.txt +1 -0
- package/package.json +1 -1
- package/src/index.ts +4 -0
- package/src/internal/boxShadow.ts +71 -9
- package/src/internal/color.ts +70 -0
- package/src/motion/createMotionComponent.tsx +238 -108
- package/src/transitions/resolveSequence.ts +12 -0
- package/src/types.ts +106 -3
- package/dist/chunk-5SRD2WCO.js +0 -8
- package/dist/chunk-TVFNJ25Z.js +0 -8
- package/dist/chunk-VLDIFL3F.js +0 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkOBRGJAST_js = require('./chunk-OBRGJAST.js');
|
|
4
|
+
var chunkPM6CVGXJ_js = require('./chunk-PM6CVGXJ.js');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var Animated = require('react-native-reanimated');
|
|
@@ -11,6 +11,30 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
11
11
|
|
|
12
12
|
var Animated__default = /*#__PURE__*/_interopDefault(Animated);
|
|
13
13
|
|
|
14
|
+
// src/internal/color.ts
|
|
15
|
+
var TRANSPARENT = "rgba(0, 0, 0, 0)";
|
|
16
|
+
function normalizeAnimatableColor(value) {
|
|
17
|
+
return value === "transparent" ? TRANSPARENT : value;
|
|
18
|
+
}
|
|
19
|
+
function normalizeAnimatableColorTarget(target) {
|
|
20
|
+
if (typeof target === "string") {
|
|
21
|
+
return normalizeAnimatableColor(target);
|
|
22
|
+
}
|
|
23
|
+
if (!Array.isArray(target)) return target;
|
|
24
|
+
let changed = false;
|
|
25
|
+
const next = target.map((step) => {
|
|
26
|
+
if (step === "transparent") {
|
|
27
|
+
changed = true;
|
|
28
|
+
return TRANSPARENT;
|
|
29
|
+
}
|
|
30
|
+
if (step !== null && typeof step === "object" && step.to === "transparent") {
|
|
31
|
+
changed = true;
|
|
32
|
+
return { ...step, to: TRANSPARENT };
|
|
33
|
+
}
|
|
34
|
+
return step;
|
|
35
|
+
});
|
|
36
|
+
return changed ? next : target;
|
|
37
|
+
}
|
|
14
38
|
var PresenceContext = react.createContext(null);
|
|
15
39
|
function usePresence() {
|
|
16
40
|
return react.useContext(PresenceContext);
|
|
@@ -250,7 +274,7 @@ function invisibleLayer(inset) {
|
|
|
250
274
|
offsetY: 0,
|
|
251
275
|
blurRadius: 0,
|
|
252
276
|
spreadDistance: 0,
|
|
253
|
-
color:
|
|
277
|
+
color: TRANSPARENT,
|
|
254
278
|
inset
|
|
255
279
|
};
|
|
256
280
|
}
|
|
@@ -266,8 +290,8 @@ function coerceLength(value, field) {
|
|
|
266
290
|
return parseFloat(trimmed);
|
|
267
291
|
}
|
|
268
292
|
function strip(layer) {
|
|
269
|
-
const { inset: _inset, ...rest } = layer;
|
|
270
|
-
return rest;
|
|
293
|
+
const { inset: _inset, color, ...rest } = layer;
|
|
294
|
+
return { ...rest, color: normalizeAnimatableColor(color) };
|
|
271
295
|
}
|
|
272
296
|
function markInset(insets, i, count) {
|
|
273
297
|
const list = insets ?? new Array(count).fill(false);
|
|
@@ -304,20 +328,31 @@ function prepareBoxShadowAnimation(current, target) {
|
|
|
304
328
|
}
|
|
305
329
|
return { from, to, insets };
|
|
306
330
|
}
|
|
331
|
+
function layersToPayload(layers) {
|
|
332
|
+
const payload = {};
|
|
333
|
+
for (let i = 0; i < layers.length; i++) payload[i] = layers[i];
|
|
334
|
+
return payload;
|
|
335
|
+
}
|
|
336
|
+
function payloadToLayers(payload) {
|
|
337
|
+
"worklet";
|
|
338
|
+
const layers = [];
|
|
339
|
+
for (let i = 0; payload[i] !== void 0; i++) layers.push(payload[i]);
|
|
340
|
+
return layers;
|
|
341
|
+
}
|
|
307
342
|
function resolveLayoutTransition(layout) {
|
|
308
343
|
if (!layout) return void 0;
|
|
309
344
|
const cfg = layout === true ? { type: "spring" } : layout;
|
|
310
345
|
if (cfg.type === "no-animation") return void 0;
|
|
311
346
|
if (cfg.type === "timing") {
|
|
312
347
|
let builder2 = Animated.LinearTransition.duration(cfg.duration ?? 300);
|
|
313
|
-
const easing =
|
|
348
|
+
const easing = chunkPM6CVGXJ_js.ensureWorkletEasing(cfg.easing);
|
|
314
349
|
if (easing) builder2 = builder2.easing(easing);
|
|
315
350
|
if (cfg.delay) builder2 = builder2.delay(cfg.delay);
|
|
316
351
|
return builder2;
|
|
317
352
|
}
|
|
318
353
|
const spring = cfg.type === "decay" ? { type: "spring" } : cfg;
|
|
319
|
-
const { stiffness, damping, mass } =
|
|
320
|
-
...
|
|
354
|
+
const { stiffness, damping, mass } = chunkPM6CVGXJ_js.springToReanimated({
|
|
355
|
+
...chunkPM6CVGXJ_js.DEFAULT_SPRING,
|
|
321
356
|
...spring
|
|
322
357
|
});
|
|
323
358
|
let builder = Animated.LinearTransition.springify().stiffness(stiffness).damping(damping).mass(mass);
|
|
@@ -511,8 +546,8 @@ function legBuilder(transition) {
|
|
|
511
546
|
Animated.withTiming(to, { duration })
|
|
512
547
|
);
|
|
513
548
|
}
|
|
514
|
-
const springCfg = transition?.type === "spring" ? { ...
|
|
515
|
-
const springParams =
|
|
549
|
+
const springCfg = transition?.type === "spring" ? { ...chunkPM6CVGXJ_js.DEFAULT_SPRING, ...transition } : { type: "spring", ...chunkPM6CVGXJ_js.DEFAULT_SPRING };
|
|
550
|
+
const springParams = chunkPM6CVGXJ_js.springToReanimated(springCfg);
|
|
516
551
|
return (from, to) => Animated.withSequence(
|
|
517
552
|
Animated.withTiming(from, { duration: 0 }),
|
|
518
553
|
Animated.withSpring(to, springParams)
|
|
@@ -600,7 +635,79 @@ var NUMERIC_TOP_LEVEL_KEYS = [
|
|
|
600
635
|
"borderRadius",
|
|
601
636
|
"shadowOpacity",
|
|
602
637
|
"shadowRadius",
|
|
603
|
-
"elevation"
|
|
638
|
+
"elevation",
|
|
639
|
+
// ─── Added in 0.0.5 ──────────────────────────────────────────────────────
|
|
640
|
+
//
|
|
641
|
+
// Every key below rides the generic numeric path: one shared value, resolved
|
|
642
|
+
// on the JS thread, emitted by the worklet through the same `out[key] = v`
|
|
643
|
+
// branch as `opacity`. None needs a new interpolation mode, so the cost is
|
|
644
|
+
// the shared value plus a `DEFAULT_RESTING` entry.
|
|
645
|
+
//
|
|
646
|
+
// The load-bearing constraint is the resting default, not the plumbing. A
|
|
647
|
+
// key declared only in `gesture` / `exit` / a non-active variant rests at
|
|
648
|
+
// `DEFAULT_RESTING` unless the static `style` names it, and the animated
|
|
649
|
+
// style merges *after* `style` — so a non-identity default silently stomps
|
|
650
|
+
// the layout. That is the `0.0.3` P0 class, and it is why the sizing and
|
|
651
|
+
// spacing keys below default to `0` only in the sense RN itself does (an
|
|
652
|
+
// unset `padding` *is* 0); `minWidth`/`maxWidth`/`aspectRatio` are
|
|
653
|
+
// deliberately excluded — their "unset" is not a number, so no default can
|
|
654
|
+
// stand in for it without changing layout on activation.
|
|
655
|
+
//
|
|
656
|
+
// Per-corner radii. Animating one corner is common (a card expanding into a
|
|
657
|
+
// sheet keeps its top corners and squares off the bottom); `borderRadius`
|
|
658
|
+
// alone can't express it.
|
|
659
|
+
"borderTopLeftRadius",
|
|
660
|
+
"borderTopRightRadius",
|
|
661
|
+
"borderBottomLeftRadius",
|
|
662
|
+
"borderBottomRightRadius",
|
|
663
|
+
// Border widths. `borderWidth` is the common case; the per-edge keys matter
|
|
664
|
+
// for underline-style focus affordances (`borderBottomWidth` on a field).
|
|
665
|
+
"borderWidth",
|
|
666
|
+
"borderTopWidth",
|
|
667
|
+
"borderRightWidth",
|
|
668
|
+
"borderBottomWidth",
|
|
669
|
+
"borderLeftWidth",
|
|
670
|
+
// Absolute-position insets. Bread-and-butter for drawers, tooltips, and
|
|
671
|
+
// anything pinned to an edge that slides in.
|
|
672
|
+
"top",
|
|
673
|
+
"right",
|
|
674
|
+
"bottom",
|
|
675
|
+
"left",
|
|
676
|
+
// Spacing. Padding animates the box from the inside (a button growing its
|
|
677
|
+
// hit area on press); margin shifts it within its parent's flow.
|
|
678
|
+
"padding",
|
|
679
|
+
"paddingTop",
|
|
680
|
+
"paddingRight",
|
|
681
|
+
"paddingBottom",
|
|
682
|
+
"paddingLeft",
|
|
683
|
+
"paddingHorizontal",
|
|
684
|
+
"paddingVertical",
|
|
685
|
+
"margin",
|
|
686
|
+
"marginTop",
|
|
687
|
+
"marginRight",
|
|
688
|
+
"marginBottom",
|
|
689
|
+
"marginLeft",
|
|
690
|
+
"marginHorizontal",
|
|
691
|
+
"marginVertical",
|
|
692
|
+
// Flex sizing. `flex` / `flexGrow` interpolate the split between siblings —
|
|
693
|
+
// the idiomatic RN way to animate a pane resize without measuring.
|
|
694
|
+
"flex",
|
|
695
|
+
"flexGrow",
|
|
696
|
+
"flexShrink",
|
|
697
|
+
// Text metrics. `TextStyle`-only at the type level (`AnimateStyle<C>` gates
|
|
698
|
+
// them per primitive), but the runtime table is shared across primitives —
|
|
699
|
+
// an unused slot is one ref, same as `tintColor` has always been.
|
|
700
|
+
"fontSize",
|
|
701
|
+
"letterSpacing",
|
|
702
|
+
"lineHeight",
|
|
703
|
+
// Stacking. Integer-valued in practice, and interpolating it mid-flight is
|
|
704
|
+
// rarely what you want, but a `no-animation` transition on `zIndex` is the
|
|
705
|
+
// clean way to reorder at a step boundary in a sequence.
|
|
706
|
+
"zIndex",
|
|
707
|
+
// Gap. Row/column gaps animate a list's density without touching children.
|
|
708
|
+
"gap",
|
|
709
|
+
"rowGap",
|
|
710
|
+
"columnGap"
|
|
604
711
|
];
|
|
605
712
|
var COLOR_KEYS = [
|
|
606
713
|
"backgroundColor",
|
|
@@ -631,7 +738,7 @@ var COLOR_KEY_SET = new Set(COLOR_KEYS);
|
|
|
631
738
|
var SHADOW_OFFSET_KEY_SET = new Set(SHADOW_OFFSET_KEYS);
|
|
632
739
|
var STRUCTURED_KEY_SET = new Set(STRUCTURED_KEYS);
|
|
633
740
|
var SHARED_STYLE_KEY_SET = new Set(SHARED_STYLE_KEYS);
|
|
634
|
-
var NO_BOX_SHADOW = Object.freeze(
|
|
741
|
+
var NO_BOX_SHADOW = Object.freeze({});
|
|
635
742
|
var GESTURE_LAYER_NAMES = [
|
|
636
743
|
"hovered",
|
|
637
744
|
"focused",
|
|
@@ -656,15 +763,69 @@ var DEFAULT_RESTING = {
|
|
|
656
763
|
shadowOpacity: 0,
|
|
657
764
|
shadowRadius: 0,
|
|
658
765
|
elevation: 0,
|
|
659
|
-
//
|
|
660
|
-
//
|
|
661
|
-
//
|
|
662
|
-
//
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
766
|
+
// 0.0.5 keys. Every one of these is 0 because that is RN's own unset value
|
|
767
|
+
// for it — an element with no `paddingTop` has 0 padding, no `borderWidth`
|
|
768
|
+
// has none, no `top` is unpinned at 0 within its positioning context. So a
|
|
769
|
+
// key that reaches its resting default lands where the element already was.
|
|
770
|
+
//
|
|
771
|
+
// The exception worth naming: `flex` / `flexGrow` / `flexShrink` do NOT have
|
|
772
|
+
// 0 as a universal identity (`flexShrink` defaults to 1 on the web, and RN's
|
|
773
|
+
// own default differs by axis). They are still 0 here, because the style-scan
|
|
774
|
+
// in the resting pass reads the real value off the static `style` whenever it
|
|
775
|
+
// is declared — and a consumer animating flex without declaring it is asking
|
|
776
|
+
// for the from-0 growth, which is the readable interpretation.
|
|
777
|
+
borderTopLeftRadius: 0,
|
|
778
|
+
borderTopRightRadius: 0,
|
|
779
|
+
borderBottomLeftRadius: 0,
|
|
780
|
+
borderBottomRightRadius: 0,
|
|
781
|
+
borderWidth: 0,
|
|
782
|
+
borderTopWidth: 0,
|
|
783
|
+
borderRightWidth: 0,
|
|
784
|
+
borderBottomWidth: 0,
|
|
785
|
+
borderLeftWidth: 0,
|
|
786
|
+
top: 0,
|
|
787
|
+
right: 0,
|
|
788
|
+
bottom: 0,
|
|
789
|
+
left: 0,
|
|
790
|
+
padding: 0,
|
|
791
|
+
paddingTop: 0,
|
|
792
|
+
paddingRight: 0,
|
|
793
|
+
paddingBottom: 0,
|
|
794
|
+
paddingLeft: 0,
|
|
795
|
+
paddingHorizontal: 0,
|
|
796
|
+
paddingVertical: 0,
|
|
797
|
+
margin: 0,
|
|
798
|
+
marginTop: 0,
|
|
799
|
+
marginRight: 0,
|
|
800
|
+
marginBottom: 0,
|
|
801
|
+
marginLeft: 0,
|
|
802
|
+
marginHorizontal: 0,
|
|
803
|
+
marginVertical: 0,
|
|
804
|
+
flex: 0,
|
|
805
|
+
flexGrow: 0,
|
|
806
|
+
flexShrink: 0,
|
|
807
|
+
fontSize: 0,
|
|
808
|
+
letterSpacing: 0,
|
|
809
|
+
lineHeight: 0,
|
|
810
|
+
zIndex: 0,
|
|
811
|
+
gap: 0,
|
|
812
|
+
rowGap: 0,
|
|
813
|
+
columnGap: 0,
|
|
814
|
+
// Fully transparent black is the only safe universal default for colors: it
|
|
815
|
+
// works as an initial seed for any color animation (no jarring opaque flash
|
|
816
|
+
// on mount when `initial` is omitted) and interpolates cleanly into any
|
|
817
|
+
// opaque target.
|
|
818
|
+
//
|
|
819
|
+
// Spelled `rgba(0, 0, 0, 0)` and NOT `'transparent'`, which is not optional.
|
|
820
|
+
// Reanimated's color-name table maps `transparent` to `undefined`, so it is
|
|
821
|
+
// the one named color `isColor()` rejects — a slot resting at the keyword
|
|
822
|
+
// takes the prefix-number-suffix branch on its next animation and produces
|
|
823
|
+
// `NaN` instead of a color. See `TRANSPARENT` in `internal/boxShadow.ts`.
|
|
824
|
+
backgroundColor: TRANSPARENT,
|
|
825
|
+
borderColor: TRANSPARENT,
|
|
826
|
+
color: TRANSPARENT,
|
|
827
|
+
tintColor: TRANSPARENT,
|
|
828
|
+
shadowColor: TRANSPARENT,
|
|
668
829
|
shadowOffsetWidth: 0,
|
|
669
830
|
shadowOffsetHeight: 0,
|
|
670
831
|
boxShadow: NO_BOX_SHADOW
|
|
@@ -672,14 +833,14 @@ var DEFAULT_RESTING = {
|
|
|
672
833
|
function transitionFor(prop, transition) {
|
|
673
834
|
if (!transition) return void 0;
|
|
674
835
|
if (typeof transition === "string") return void 0;
|
|
675
|
-
if (
|
|
836
|
+
if (chunkPM6CVGXJ_js.isTopLevelTransition(transition)) return transition;
|
|
676
837
|
if (GESTURE_LAYER_NAME_SET.has(prop)) return void 0;
|
|
677
838
|
return transition[prop];
|
|
678
839
|
}
|
|
679
840
|
function gestureLayerTransitionFor(layer, transition) {
|
|
680
841
|
if (!transition) return void 0;
|
|
681
842
|
if (typeof transition === "string") return void 0;
|
|
682
|
-
if (
|
|
843
|
+
if (chunkPM6CVGXJ_js.isTopLevelTransition(transition)) return transition;
|
|
683
844
|
return transition[layer];
|
|
684
845
|
}
|
|
685
846
|
function createMotionComponent(Component) {
|
|
@@ -729,12 +890,12 @@ function createMotionComponent(Component) {
|
|
|
729
890
|
onLayout: userOnLayout,
|
|
730
891
|
...rest
|
|
731
892
|
} = props;
|
|
732
|
-
const namedTransitions =
|
|
733
|
-
const transition =
|
|
893
|
+
const namedTransitions = chunkOBRGJAST_js.useNamedTransitions();
|
|
894
|
+
const transition = chunkOBRGJAST_js.resolveNamedTransitionProp(
|
|
734
895
|
transitionProp,
|
|
735
896
|
namedTransitions
|
|
736
897
|
);
|
|
737
|
-
const layout = typeof layoutProp === "string" ?
|
|
898
|
+
const layout = typeof layoutProp === "string" ? chunkOBRGJAST_js.lookupNamedTransition(layoutProp, namedTransitions) : layoutProp;
|
|
738
899
|
if (__DEV__ && typeof style === "function") {
|
|
739
900
|
throw new Error(
|
|
740
901
|
"[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."
|
|
@@ -742,7 +903,7 @@ function createMotionComponent(Component) {
|
|
|
742
903
|
}
|
|
743
904
|
const presence = usePresence();
|
|
744
905
|
const isExiting = presence !== null && presence.isPresent === false;
|
|
745
|
-
const shouldReduceMotion =
|
|
906
|
+
const shouldReduceMotion = chunkOBRGJAST_js.useShouldReduceMotion();
|
|
746
907
|
const onAnimationEndRef = react.useRef(onAnimationEnd);
|
|
747
908
|
onAnimationEndRef.current = onAnimationEnd;
|
|
748
909
|
const variantKey = useControllerKey(controller);
|
|
@@ -826,7 +987,7 @@ function createMotionComponent(Component) {
|
|
|
826
987
|
if (__DEV__ && hasBoxShadowRef.current && activeKeysRef.current.some(
|
|
827
988
|
(k) => k !== "boxShadow" && k.startsWith("shadow")
|
|
828
989
|
)) {
|
|
829
|
-
|
|
990
|
+
chunkPM6CVGXJ_js.warnOnce(
|
|
830
991
|
"boxShadow-with-native-shadow",
|
|
831
992
|
"[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
993
|
);
|
|
@@ -851,25 +1012,28 @@ function createMotionComponent(Component) {
|
|
|
851
1012
|
const raw = flat.boxShadow;
|
|
852
1013
|
if (raw !== void 0) {
|
|
853
1014
|
styleRestingShadow = normalizeBoxShadow(raw);
|
|
854
|
-
styleResting.boxShadow =
|
|
1015
|
+
styleResting.boxShadow = layersToPayload(
|
|
1016
|
+
styleRestingShadow.layers
|
|
1017
|
+
);
|
|
855
1018
|
}
|
|
856
1019
|
continue;
|
|
857
1020
|
}
|
|
858
1021
|
const v = styleValueFor(flat, key);
|
|
859
|
-
if (v !== void 0)
|
|
1022
|
+
if (v !== void 0) {
|
|
1023
|
+
styleResting[key] = COLOR_KEY_SET.has(key) ? normalizeAnimatableColor(v) : v;
|
|
1024
|
+
}
|
|
860
1025
|
}
|
|
861
1026
|
}
|
|
862
1027
|
}
|
|
863
1028
|
const boxShadowSeedRef = react.useRef(null);
|
|
864
1029
|
if (boxShadowSeedRef.current === null) {
|
|
865
1030
|
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
|
-
};
|
|
1031
|
+
boxShadowSeedRef.current = source !== void 0 ? normalizeBoxShadow(source) : styleRestingShadow ?? { layers: [], insets: null };
|
|
870
1032
|
}
|
|
871
1033
|
const sharedValues = useAnimatableSharedValues((key) => {
|
|
872
|
-
if (key === "boxShadow")
|
|
1034
|
+
if (key === "boxShadow") {
|
|
1035
|
+
return layersToPayload(boxShadowSeedRef.current.layers);
|
|
1036
|
+
}
|
|
873
1037
|
if (SHADOW_OFFSET_KEY_SET.has(key)) {
|
|
874
1038
|
const axis = shadowOffsetAxisFor(key);
|
|
875
1039
|
if (initial === false) {
|
|
@@ -882,14 +1046,16 @@ function createMotionComponent(Component) {
|
|
|
882
1046
|
}
|
|
883
1047
|
if (initial === false) {
|
|
884
1048
|
const a = animateRecord[key];
|
|
885
|
-
|
|
1049
|
+
const seed2 = restValue(a) ?? styleResting[key] ?? DEFAULT_RESTING[key];
|
|
1050
|
+
return COLOR_KEY_SET.has(key) ? normalizeAnimatableColor(seed2) : seed2;
|
|
886
1051
|
}
|
|
887
|
-
|
|
1052
|
+
const seed = initialRecord?.[key] ?? restValue(animateRecord[key]) ?? styleResting[key] ?? DEFAULT_RESTING[key];
|
|
1053
|
+
return COLOR_KEY_SET.has(key) ? normalizeAnimatableColor(seed) : seed;
|
|
888
1054
|
});
|
|
889
1055
|
const boxShadowInsets = Animated.useSharedValue(
|
|
890
1056
|
boxShadowSeedRef.current.insets
|
|
891
1057
|
);
|
|
892
|
-
const styleRestingSig =
|
|
1058
|
+
const styleRestingSig = chunkPM6CVGXJ_js.stableSig(styleResting);
|
|
893
1059
|
react.useEffect(() => {
|
|
894
1060
|
for (const key of activeKeysRef.current) {
|
|
895
1061
|
if (everDrivenRef.current.has(key)) continue;
|
|
@@ -917,13 +1083,13 @@ function createMotionComponent(Component) {
|
|
|
917
1083
|
const gestureSV = Animated.useSharedValue(
|
|
918
1084
|
resolveGestureLayers(gesture)
|
|
919
1085
|
);
|
|
920
|
-
const gestureTargetsSig =
|
|
1086
|
+
const gestureTargetsSig = chunkPM6CVGXJ_js.stableSig(gesture);
|
|
921
1087
|
react.useEffect(() => {
|
|
922
1088
|
gestureSV.value = resolveGestureLayers(gesture);
|
|
923
1089
|
}, [gestureTargetsSig]);
|
|
924
1090
|
const baseRecord = isExiting && exitRecord ? { ...animateRecord, ...exitRecord } : animateRecord;
|
|
925
|
-
const baseSig =
|
|
926
|
-
const transitionSig =
|
|
1091
|
+
const baseSig = chunkPM6CVGXJ_js.stableSig(baseRecord) + (isExiting ? "|exit" : "") + (shouldReduceMotion ? "|rm" : "");
|
|
1092
|
+
const transitionSig = chunkPM6CVGXJ_js.stableSig(transition);
|
|
927
1093
|
const safeToRemoveRef = react.useRef(void 0);
|
|
928
1094
|
safeToRemoveRef.current = presence?.safeToRemove;
|
|
929
1095
|
react.useEffect(() => {
|
|
@@ -996,8 +1162,8 @@ function createMotionComponent(Component) {
|
|
|
996
1162
|
isExiting ? onSettle : void 0,
|
|
997
1163
|
TRANSFORM_KEY_SET.has(key) ? transformGroup : void 0
|
|
998
1164
|
);
|
|
999
|
-
sharedValues[key].value =
|
|
1000
|
-
target,
|
|
1165
|
+
sharedValues[key].value = chunkPM6CVGXJ_js.resolveAnimatableValue(
|
|
1166
|
+
COLOR_KEY_SET.has(key) ? normalizeAnimatableColorTarget(target) : target,
|
|
1001
1167
|
cfg,
|
|
1002
1168
|
factory
|
|
1003
1169
|
);
|
|
@@ -1058,7 +1224,7 @@ function createMotionComponent(Component) {
|
|
|
1058
1224
|
const sharedLayout = useSharedLayout({
|
|
1059
1225
|
layoutId,
|
|
1060
1226
|
userRef: ref,
|
|
1061
|
-
transition:
|
|
1227
|
+
transition: chunkPM6CVGXJ_js.isTopLevelTransition(transition) ? transition : void 0,
|
|
1062
1228
|
shouldReduceMotion,
|
|
1063
1229
|
userOnLayout,
|
|
1064
1230
|
readStyles: readSharedStyles
|
|
@@ -1134,14 +1300,14 @@ function createMotionComponent(Component) {
|
|
|
1134
1300
|
out.shadowOffset = { width: shadowOffsetW, height: shadowOffsetH };
|
|
1135
1301
|
}
|
|
1136
1302
|
if (hasBoxShadow) {
|
|
1137
|
-
const
|
|
1303
|
+
const payload = sharedValues.boxShadow.value;
|
|
1138
1304
|
const insets = boxShadowInsets.value;
|
|
1139
1305
|
if (insets === null) {
|
|
1140
|
-
out.boxShadow =
|
|
1306
|
+
out.boxShadow = payloadToLayers(payload);
|
|
1141
1307
|
} else {
|
|
1142
1308
|
const withInset = [];
|
|
1143
|
-
for (let i = 0; i
|
|
1144
|
-
withInset.push({ ...
|
|
1309
|
+
for (let i = 0; payload[i] !== void 0; i++) {
|
|
1310
|
+
withInset.push({ ...payload[i], inset: insets[i] });
|
|
1145
1311
|
}
|
|
1146
1312
|
out.boxShadow = withInset;
|
|
1147
1313
|
}
|
|
@@ -1160,7 +1326,7 @@ function createMotionComponent(Component) {
|
|
|
1160
1326
|
setFocusVisible,
|
|
1161
1327
|
setHovered
|
|
1162
1328
|
);
|
|
1163
|
-
const layoutSig =
|
|
1329
|
+
const layoutSig = chunkPM6CVGXJ_js.stableSig(layout);
|
|
1164
1330
|
const layoutTransition = react.useMemo(
|
|
1165
1331
|
() => shouldReduceMotion ? void 0 : resolveLayoutTransition(layout),
|
|
1166
1332
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -1208,64 +1374,15 @@ function hasMotionProps(props) {
|
|
|
1208
1374
|
return false;
|
|
1209
1375
|
}
|
|
1210
1376
|
function useAnimatableSharedValues(init) {
|
|
1211
|
-
const
|
|
1212
|
-
const
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
const scaleY = Animated.useSharedValue(init("scaleY"));
|
|
1216
|
-
const rotate = Animated.useSharedValue(init("rotate"));
|
|
1217
|
-
const rotateX = Animated.useSharedValue(init("rotateX"));
|
|
1218
|
-
const rotateY = Animated.useSharedValue(init("rotateY"));
|
|
1219
|
-
const opacity = Animated.useSharedValue(init("opacity"));
|
|
1220
|
-
const width = Animated.useSharedValue(init("width"));
|
|
1221
|
-
const height = Animated.useSharedValue(init("height"));
|
|
1222
|
-
const borderRadius = Animated.useSharedValue(init("borderRadius"));
|
|
1223
|
-
const shadowOpacity = Animated.useSharedValue(
|
|
1224
|
-
init("shadowOpacity")
|
|
1225
|
-
);
|
|
1226
|
-
const shadowRadius = Animated.useSharedValue(init("shadowRadius"));
|
|
1227
|
-
const elevation = Animated.useSharedValue(init("elevation"));
|
|
1228
|
-
const backgroundColor = Animated.useSharedValue(
|
|
1229
|
-
init("backgroundColor")
|
|
1230
|
-
);
|
|
1231
|
-
const borderColor = Animated.useSharedValue(init("borderColor"));
|
|
1232
|
-
const color = Animated.useSharedValue(init("color"));
|
|
1233
|
-
const tintColor = Animated.useSharedValue(init("tintColor"));
|
|
1234
|
-
const shadowColor = Animated.useSharedValue(init("shadowColor"));
|
|
1235
|
-
const shadowOffsetWidth = Animated.useSharedValue(
|
|
1236
|
-
init("shadowOffsetWidth")
|
|
1237
|
-
);
|
|
1238
|
-
const shadowOffsetHeight = Animated.useSharedValue(
|
|
1239
|
-
init("shadowOffsetHeight")
|
|
1240
|
-
);
|
|
1241
|
-
const boxShadow = Animated.useSharedValue(init("boxShadow"));
|
|
1377
|
+
const entries = [];
|
|
1378
|
+
for (const key of ALL_KEYS) {
|
|
1379
|
+
entries.push([key, Animated.useSharedValue(init(key))]);
|
|
1380
|
+
}
|
|
1242
1381
|
const ref = react.useRef(null);
|
|
1243
1382
|
if (ref.current === null) {
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
scale,
|
|
1248
|
-
scaleX,
|
|
1249
|
-
scaleY,
|
|
1250
|
-
rotate,
|
|
1251
|
-
rotateX,
|
|
1252
|
-
rotateY,
|
|
1253
|
-
opacity,
|
|
1254
|
-
width,
|
|
1255
|
-
height,
|
|
1256
|
-
borderRadius,
|
|
1257
|
-
shadowOpacity,
|
|
1258
|
-
shadowRadius,
|
|
1259
|
-
elevation,
|
|
1260
|
-
backgroundColor,
|
|
1261
|
-
borderColor,
|
|
1262
|
-
color,
|
|
1263
|
-
tintColor,
|
|
1264
|
-
shadowColor,
|
|
1265
|
-
shadowOffsetWidth,
|
|
1266
|
-
shadowOffsetHeight,
|
|
1267
|
-
boxShadow
|
|
1268
|
-
};
|
|
1383
|
+
const map2 = {};
|
|
1384
|
+
for (const [key, sv] of entries) map2[key] = sv;
|
|
1385
|
+
ref.current = map2;
|
|
1269
1386
|
}
|
|
1270
1387
|
const map = ref.current;
|
|
1271
1388
|
react.useEffect(
|
|
@@ -1306,6 +1423,7 @@ function makeKeyCallbackFactory(key, sharedValue, target, onAnimationEndRef, met
|
|
|
1306
1423
|
}
|
|
1307
1424
|
const reportedIteration = state.iteration;
|
|
1308
1425
|
if (phase === "sequence" || phase === "repeat") state.iteration++;
|
|
1426
|
+
const reportedValue = key === "boxShadow" && value !== void 0 ? payloadToLayers(value) : value;
|
|
1309
1427
|
const fn = onAnimationEndRef.current;
|
|
1310
1428
|
if (fn) {
|
|
1311
1429
|
if (isTransformKey && transformGroup && phase === "animation") {
|
|
@@ -1314,7 +1432,7 @@ function makeKeyCallbackFactory(key, sharedValue, target, onAnimationEndRef, met
|
|
|
1314
1432
|
fn({
|
|
1315
1433
|
key: "transform",
|
|
1316
1434
|
finished,
|
|
1317
|
-
value,
|
|
1435
|
+
value: reportedValue,
|
|
1318
1436
|
target,
|
|
1319
1437
|
phase,
|
|
1320
1438
|
step,
|
|
@@ -1325,7 +1443,7 @@ function makeKeyCallbackFactory(key, sharedValue, target, onAnimationEndRef, met
|
|
|
1325
1443
|
fn({
|
|
1326
1444
|
key,
|
|
1327
1445
|
finished,
|
|
1328
|
-
value,
|
|
1446
|
+
value: reportedValue,
|
|
1329
1447
|
target,
|
|
1330
1448
|
phase,
|
|
1331
1449
|
step,
|
|
@@ -1350,16 +1468,16 @@ function shadowOffsetAxisValue(source, axis) {
|
|
|
1350
1468
|
return source?.[axis];
|
|
1351
1469
|
}
|
|
1352
1470
|
function driveBoxShadow(slot, insetSlot, target, cfg, factory) {
|
|
1353
|
-
const currentLayers =
|
|
1471
|
+
const currentLayers = payloadToLayers(slot.value);
|
|
1354
1472
|
const { from, to, insets } = prepareBoxShadowAnimation(
|
|
1355
|
-
{ layers:
|
|
1473
|
+
{ layers: currentLayers, insets: insetSlot.value },
|
|
1356
1474
|
target
|
|
1357
1475
|
);
|
|
1358
1476
|
insetSlot.value = insets;
|
|
1359
|
-
if (from.length !== currentLayers.length) slot.value = from;
|
|
1360
|
-
slot.value =
|
|
1477
|
+
if (from.length !== currentLayers.length) slot.value = layersToPayload(from);
|
|
1478
|
+
slot.value = chunkPM6CVGXJ_js.resolveTransition(
|
|
1361
1479
|
cfg,
|
|
1362
|
-
to,
|
|
1480
|
+
layersToPayload(to),
|
|
1363
1481
|
factory?.("animation", void 0)
|
|
1364
1482
|
);
|
|
1365
1483
|
}
|
|
@@ -1481,7 +1599,7 @@ function resolveGestureLayers(gesture) {
|
|
|
1481
1599
|
for (const key of ALL_KEYS) {
|
|
1482
1600
|
if (STRUCTURED_KEY_SET.has(key)) {
|
|
1483
1601
|
if (__DEV__ && subState[key] !== void 0) {
|
|
1484
|
-
|
|
1602
|
+
chunkPM6CVGXJ_js.warnOnce(
|
|
1485
1603
|
`gesture-structured-${layer}-${key}`,
|
|
1486
1604
|
`[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
1605
|
);
|
|
@@ -1505,7 +1623,7 @@ function resolveGestureLayers(gesture) {
|
|
|
1505
1623
|
return out;
|
|
1506
1624
|
}
|
|
1507
1625
|
function useGestureLayerProgress(progress, active, declared, layer, transition, isExiting, shouldReduceMotion) {
|
|
1508
|
-
const layerCfgSig =
|
|
1626
|
+
const layerCfgSig = chunkPM6CVGXJ_js.stableSig(gestureLayerTransitionFor(layer, transition));
|
|
1509
1627
|
react.useEffect(() => {
|
|
1510
1628
|
if (!declared) return;
|
|
1511
1629
|
if (isExiting) {
|
|
@@ -1514,7 +1632,7 @@ function useGestureLayerProgress(progress, active, declared, layer, transition,
|
|
|
1514
1632
|
}
|
|
1515
1633
|
const target = active ? 1 : 0;
|
|
1516
1634
|
const cfg = shouldReduceMotion ? { type: "no-animation" } : gestureLayerTransitionFor(layer, transition) ?? { type: "spring" };
|
|
1517
|
-
progress.value =
|
|
1635
|
+
progress.value = chunkPM6CVGXJ_js.resolveTransition(cfg, target);
|
|
1518
1636
|
}, [active, declared, isExiting, shouldReduceMotion, layerCfgSig]);
|
|
1519
1637
|
}
|
|
1520
1638
|
function useGestureHandlers(gesture, rest, setPressed, setFocused, setFocusVisible, setHovered) {
|
|
@@ -1538,7 +1656,7 @@ function useGestureHandlers(gesture, rest, setPressed, setFocused, setFocusVisib
|
|
|
1538
1656
|
if (gesture.focused || gesture.focusVisible) {
|
|
1539
1657
|
handlers.onFocus = compose(rest.onFocus, () => {
|
|
1540
1658
|
if (gesture.focused) setFocused(true);
|
|
1541
|
-
if (gesture.focusVisible &&
|
|
1659
|
+
if (gesture.focusVisible && chunkOBRGJAST_js.isFocusVisible()) setFocusVisible(true);
|
|
1542
1660
|
});
|
|
1543
1661
|
handlers.onBlur = compose(rest.onBlur, () => {
|
|
1544
1662
|
if (gesture.focused) setFocused(false);
|
|
@@ -1578,6 +1696,7 @@ function compose(user, ours) {
|
|
|
1578
1696
|
}
|
|
1579
1697
|
|
|
1580
1698
|
exports.Presence = Presence;
|
|
1699
|
+
exports.TRANSPARENT = TRANSPARENT;
|
|
1581
1700
|
exports.createMotionComponent = createMotionComponent;
|
|
1582
1701
|
exports.pairBoxShadowLayers = pairBoxShadowLayers;
|
|
1583
1702
|
exports.resolveBoxShadowInput = resolveBoxShadowInput;
|