@rootnative/inertia 0.0.0-alpha.0 → 0.0.0-alpha.2
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 +10 -0
- package/README.md +2 -0
- package/dist/gestureLayer/index.d.mts +48 -7
- package/dist/gestureLayer/index.d.ts +48 -7
- package/dist/gestureLayer/index.js +107 -30
- package/dist/gestureLayer/index.mjs +107 -30
- package/dist/index.d.mts +127 -16
- package/dist/index.d.ts +127 -16
- package/dist/index.js +177 -62
- package/dist/index.mjs +175 -63
- package/dist/motion/Image.d.mts +1 -1
- package/dist/motion/Image.d.ts +1 -1
- package/dist/motion/Image.js +90 -50
- package/dist/motion/Image.mjs +90 -50
- package/dist/motion/Pressable.d.mts +1 -1
- package/dist/motion/Pressable.d.ts +1 -1
- package/dist/motion/Pressable.js +90 -50
- package/dist/motion/Pressable.mjs +90 -50
- package/dist/motion/ScrollView.d.mts +1 -1
- package/dist/motion/ScrollView.d.ts +1 -1
- package/dist/motion/ScrollView.js +90 -50
- package/dist/motion/ScrollView.mjs +90 -50
- package/dist/motion/Text.d.mts +1 -1
- package/dist/motion/Text.d.ts +1 -1
- package/dist/motion/Text.js +90 -50
- package/dist/motion/Text.mjs +90 -50
- package/dist/motion/View.d.mts +1 -1
- package/dist/motion/View.d.ts +1 -1
- package/dist/motion/View.js +90 -50
- package/dist/motion/View.mjs +90 -50
- package/dist/testing/index.js +0 -2
- package/dist/testing/index.mjs +0 -2
- package/dist/touch/index.d.mts +1 -1
- package/dist/touch/index.d.ts +1 -1
- package/dist/touch/index.js +0 -2
- package/dist/touch/index.mjs +0 -2
- package/dist/{types-cU43dEmH.d.mts → types-BzEgiUdJ.d.mts} +58 -9
- package/dist/{types-cU43dEmH.d.ts → types-BzEgiUdJ.d.ts} +58 -9
- package/dist/{useGesture-BnY65PlQ.d.ts → useGesture-BRLgiNOC.d.ts} +6 -4
- package/dist/{useGesture-DxtXdz-K.d.mts → useGesture-C0GBS7d2.d.mts} +6 -4
- package/llms.txt +9 -5
- package/package.json +2 -1
- package/src/config/MotionConfig.tsx +55 -9
- package/src/config/MotionConfigContext.ts +21 -1
- package/src/config/index.ts +7 -1
- package/src/config/namedTransitions.ts +80 -0
- package/src/gestureLayer/index.ts +1 -0
- package/src/gestureLayer/useGestureLayer.ts +92 -8
- package/src/index.ts +20 -2
- package/src/motion/createMotionComponent.tsx +36 -6
- package/src/transitions/cubicBezier.ts +126 -0
- package/src/transitions/index.ts +1 -0
- package/src/types.ts +63 -8
- package/src/values/useAnimation.ts +12 -6
- package/src/values/useBooleanSpring.ts +5 -3
- package/src/values/useGesture.ts +25 -7
- package/src/values/useMotionValue.ts +11 -0
- package/src/values/useScroll.ts +8 -1
- package/src/values/useSpring.ts +46 -9
- package/dist/gestureLayer/index.js.map +0 -1
- package/dist/gestureLayer/index.mjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/motion/Image.js.map +0 -1
- package/dist/motion/Image.mjs.map +0 -1
- package/dist/motion/Pressable.js.map +0 -1
- package/dist/motion/Pressable.mjs.map +0 -1
- package/dist/motion/ScrollView.js.map +0 -1
- package/dist/motion/ScrollView.mjs.map +0 -1
- package/dist/motion/Text.js.map +0 -1
- package/dist/motion/Text.mjs.map +0 -1
- package/dist/motion/View.js.map +0 -1
- package/dist/motion/View.mjs.map +0 -1
- package/dist/testing/index.js.map +0 -1
- package/dist/testing/index.mjs.map +0 -1
- package/dist/touch/index.js.map +0 -1
- package/dist/touch/index.mjs.map +0 -1
- package/src/__type-tests__/animate.test-d.tsx +0 -88
- package/src/__type-tests__/variants.test-d.tsx +0 -67
package/dist/motion/Text.mjs
CHANGED
|
@@ -5,8 +5,31 @@ import { isWorkletFunction } from 'react-native-worklets';
|
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
6
|
|
|
7
7
|
// src/motion/Text.tsx
|
|
8
|
+
|
|
9
|
+
// src/transitions/sig.ts
|
|
10
|
+
function stableSig(value) {
|
|
11
|
+
if (value === void 0) return "";
|
|
12
|
+
try {
|
|
13
|
+
return stableStringify(value);
|
|
14
|
+
} catch {
|
|
15
|
+
return String(value);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function stableStringify(v) {
|
|
19
|
+
if (v === null || typeof v !== "object") {
|
|
20
|
+
if (typeof v === "function" || v === void 0) return "null";
|
|
21
|
+
return JSON.stringify(v);
|
|
22
|
+
}
|
|
23
|
+
if (Array.isArray(v)) {
|
|
24
|
+
return "[" + v.map(stableStringify).join(",") + "]";
|
|
25
|
+
}
|
|
26
|
+
const obj = v;
|
|
27
|
+
const keys = Object.keys(obj).sort();
|
|
28
|
+
return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",") + "}";
|
|
29
|
+
}
|
|
8
30
|
var DEFAULT_MOTION_CONFIG = {
|
|
9
|
-
reducedMotion: "user"
|
|
31
|
+
reducedMotion: "user",
|
|
32
|
+
transitions: {}
|
|
10
33
|
};
|
|
11
34
|
var MotionConfigContext = createContext(
|
|
12
35
|
DEFAULT_MOTION_CONFIG
|
|
@@ -14,6 +37,9 @@ var MotionConfigContext = createContext(
|
|
|
14
37
|
function useMotionConfig() {
|
|
15
38
|
return useContext(MotionConfigContext);
|
|
16
39
|
}
|
|
40
|
+
function useNamedTransitions() {
|
|
41
|
+
return useMotionConfig().transitions;
|
|
42
|
+
}
|
|
17
43
|
function useShouldReduceMotion() {
|
|
18
44
|
const { reducedMotion } = useMotionConfig();
|
|
19
45
|
const osReduced = useReducedMotion();
|
|
@@ -21,6 +47,59 @@ function useShouldReduceMotion() {
|
|
|
21
47
|
if (reducedMotion === "always") return true;
|
|
22
48
|
return osReduced;
|
|
23
49
|
}
|
|
50
|
+
|
|
51
|
+
// src/transitions/keys.ts
|
|
52
|
+
var TRANSITION_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
53
|
+
"type",
|
|
54
|
+
"tension",
|
|
55
|
+
"friction",
|
|
56
|
+
"mass",
|
|
57
|
+
"velocity",
|
|
58
|
+
"restSpeedThreshold",
|
|
59
|
+
"restDisplacementThreshold",
|
|
60
|
+
"duration",
|
|
61
|
+
"easing",
|
|
62
|
+
"delay",
|
|
63
|
+
"repeat",
|
|
64
|
+
"deceleration",
|
|
65
|
+
"clamp"
|
|
66
|
+
]);
|
|
67
|
+
function isTopLevelTransition(t) {
|
|
68
|
+
if (t === null || typeof t !== "object") return false;
|
|
69
|
+
const keys = Object.keys(t);
|
|
70
|
+
if (keys.length === 0) return false;
|
|
71
|
+
return keys.every((k) => TRANSITION_CONFIG_KEYS.has(k));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/config/namedTransitions.ts
|
|
75
|
+
var UNKNOWN_NAME_FALLBACK = { type: "spring" };
|
|
76
|
+
function lookupNamedTransition(name, registry) {
|
|
77
|
+
const cfg = registry[name];
|
|
78
|
+
if (cfg) return cfg;
|
|
79
|
+
if (__DEV__) {
|
|
80
|
+
console.warn(
|
|
81
|
+
`[inertia] Unknown transition name "${name}" \u2014 falling back to the default spring. Register it on a provider: <MotionConfig transitions={{ '${name}': { ... } }}>.`
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
return UNKNOWN_NAME_FALLBACK;
|
|
85
|
+
}
|
|
86
|
+
function resolveNamedTransitionProp(transition, registry) {
|
|
87
|
+
if (transition === void 0) return void 0;
|
|
88
|
+
if (typeof transition === "string") {
|
|
89
|
+
return lookupNamedTransition(transition, registry);
|
|
90
|
+
}
|
|
91
|
+
if (isTopLevelTransition(transition)) return transition;
|
|
92
|
+
const map = transition;
|
|
93
|
+
let out = null;
|
|
94
|
+
for (const key in map) {
|
|
95
|
+
const value = map[key];
|
|
96
|
+
if (typeof value === "string") {
|
|
97
|
+
if (out === null) out = { ...map };
|
|
98
|
+
out[key] = lookupNamedTransition(value, registry);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return out ?? transition;
|
|
102
|
+
}
|
|
24
103
|
var modality = "keyboard";
|
|
25
104
|
var installed = false;
|
|
26
105
|
function setKeyboard() {
|
|
@@ -357,51 +436,6 @@ function mergeTransition(base, override) {
|
|
|
357
436
|
}
|
|
358
437
|
return { ...base ?? { type: "spring" }, ...override };
|
|
359
438
|
}
|
|
360
|
-
|
|
361
|
-
// src/transitions/keys.ts
|
|
362
|
-
var TRANSITION_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
363
|
-
"type",
|
|
364
|
-
"tension",
|
|
365
|
-
"friction",
|
|
366
|
-
"mass",
|
|
367
|
-
"velocity",
|
|
368
|
-
"restSpeedThreshold",
|
|
369
|
-
"restDisplacementThreshold",
|
|
370
|
-
"duration",
|
|
371
|
-
"easing",
|
|
372
|
-
"delay",
|
|
373
|
-
"repeat",
|
|
374
|
-
"deceleration",
|
|
375
|
-
"clamp"
|
|
376
|
-
]);
|
|
377
|
-
function isTopLevelTransition(t) {
|
|
378
|
-
if (t === null || typeof t !== "object") return false;
|
|
379
|
-
const keys = Object.keys(t);
|
|
380
|
-
if (keys.length === 0) return false;
|
|
381
|
-
return keys.every((k) => TRANSITION_CONFIG_KEYS.has(k));
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
// src/transitions/sig.ts
|
|
385
|
-
function stableSig(value) {
|
|
386
|
-
if (value === void 0) return "";
|
|
387
|
-
try {
|
|
388
|
-
return stableStringify(value);
|
|
389
|
-
} catch {
|
|
390
|
-
return String(value);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
function stableStringify(v) {
|
|
394
|
-
if (v === null || typeof v !== "object") {
|
|
395
|
-
if (typeof v === "function" || v === void 0) return "null";
|
|
396
|
-
return JSON.stringify(v);
|
|
397
|
-
}
|
|
398
|
-
if (Array.isArray(v)) {
|
|
399
|
-
return "[" + v.map(stableStringify).join(",") + "]";
|
|
400
|
-
}
|
|
401
|
-
const obj = v;
|
|
402
|
-
const keys = Object.keys(obj).sort();
|
|
403
|
-
return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",") + "}";
|
|
404
|
-
}
|
|
405
439
|
var alreadyChecked = false;
|
|
406
440
|
function ensureReanimatedInstalled() {
|
|
407
441
|
if (!__DEV__ || alreadyChecked) return;
|
|
@@ -504,12 +538,14 @@ var DEFAULT_RESTING = {
|
|
|
504
538
|
};
|
|
505
539
|
function transitionFor(prop, transition) {
|
|
506
540
|
if (!transition) return void 0;
|
|
541
|
+
if (typeof transition === "string") return void 0;
|
|
507
542
|
if (isTopLevelTransition(transition)) return transition;
|
|
508
543
|
if (GESTURE_LAYER_NAME_SET.has(prop)) return void 0;
|
|
509
544
|
return transition[prop];
|
|
510
545
|
}
|
|
511
546
|
function gestureLayerTransitionFor(layer, transition) {
|
|
512
547
|
if (!transition) return void 0;
|
|
548
|
+
if (typeof transition === "string") return void 0;
|
|
513
549
|
if (isTopLevelTransition(transition)) return transition;
|
|
514
550
|
return transition[layer];
|
|
515
551
|
}
|
|
@@ -524,17 +560,23 @@ function createMotionComponent(Component) {
|
|
|
524
560
|
initial,
|
|
525
561
|
animate,
|
|
526
562
|
exit,
|
|
527
|
-
transition,
|
|
563
|
+
transition: transitionProp,
|
|
528
564
|
variants,
|
|
529
565
|
controller,
|
|
530
566
|
gesture,
|
|
531
|
-
layout,
|
|
567
|
+
layout: layoutProp,
|
|
532
568
|
layoutId,
|
|
533
569
|
onAnimationEnd,
|
|
534
570
|
style,
|
|
535
571
|
onLayout: userOnLayout,
|
|
536
572
|
...rest
|
|
537
573
|
} = props;
|
|
574
|
+
const namedTransitions = useNamedTransitions();
|
|
575
|
+
const transition = resolveNamedTransitionProp(
|
|
576
|
+
transitionProp,
|
|
577
|
+
namedTransitions
|
|
578
|
+
);
|
|
579
|
+
const layout = typeof layoutProp === "string" ? lookupNamedTransition(layoutProp, namedTransitions) : layoutProp;
|
|
538
580
|
if (__DEV__ && typeof style === "function") {
|
|
539
581
|
throw new Error(
|
|
540
582
|
"[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."
|
|
@@ -1128,5 +1170,3 @@ function compose(user, ours) {
|
|
|
1128
1170
|
var MotionText = createMotionComponent(Text);
|
|
1129
1171
|
|
|
1130
1172
|
export { MotionText };
|
|
1131
|
-
//# sourceMappingURL=Text.mjs.map
|
|
1132
|
-
//# sourceMappingURL=Text.mjs.map
|
package/dist/motion/View.d.mts
CHANGED
package/dist/motion/View.d.ts
CHANGED
package/dist/motion/View.js
CHANGED
|
@@ -11,8 +11,31 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
11
11
|
var Animated__default = /*#__PURE__*/_interopDefault(Animated);
|
|
12
12
|
|
|
13
13
|
// src/motion/View.tsx
|
|
14
|
+
|
|
15
|
+
// src/transitions/sig.ts
|
|
16
|
+
function stableSig(value) {
|
|
17
|
+
if (value === void 0) return "";
|
|
18
|
+
try {
|
|
19
|
+
return stableStringify(value);
|
|
20
|
+
} catch {
|
|
21
|
+
return String(value);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function stableStringify(v) {
|
|
25
|
+
if (v === null || typeof v !== "object") {
|
|
26
|
+
if (typeof v === "function" || v === void 0) return "null";
|
|
27
|
+
return JSON.stringify(v);
|
|
28
|
+
}
|
|
29
|
+
if (Array.isArray(v)) {
|
|
30
|
+
return "[" + v.map(stableStringify).join(",") + "]";
|
|
31
|
+
}
|
|
32
|
+
const obj = v;
|
|
33
|
+
const keys = Object.keys(obj).sort();
|
|
34
|
+
return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",") + "}";
|
|
35
|
+
}
|
|
14
36
|
var DEFAULT_MOTION_CONFIG = {
|
|
15
|
-
reducedMotion: "user"
|
|
37
|
+
reducedMotion: "user",
|
|
38
|
+
transitions: {}
|
|
16
39
|
};
|
|
17
40
|
var MotionConfigContext = react.createContext(
|
|
18
41
|
DEFAULT_MOTION_CONFIG
|
|
@@ -20,6 +43,9 @@ var MotionConfigContext = react.createContext(
|
|
|
20
43
|
function useMotionConfig() {
|
|
21
44
|
return react.useContext(MotionConfigContext);
|
|
22
45
|
}
|
|
46
|
+
function useNamedTransitions() {
|
|
47
|
+
return useMotionConfig().transitions;
|
|
48
|
+
}
|
|
23
49
|
function useShouldReduceMotion() {
|
|
24
50
|
const { reducedMotion } = useMotionConfig();
|
|
25
51
|
const osReduced = Animated.useReducedMotion();
|
|
@@ -27,6 +53,59 @@ function useShouldReduceMotion() {
|
|
|
27
53
|
if (reducedMotion === "always") return true;
|
|
28
54
|
return osReduced;
|
|
29
55
|
}
|
|
56
|
+
|
|
57
|
+
// src/transitions/keys.ts
|
|
58
|
+
var TRANSITION_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
59
|
+
"type",
|
|
60
|
+
"tension",
|
|
61
|
+
"friction",
|
|
62
|
+
"mass",
|
|
63
|
+
"velocity",
|
|
64
|
+
"restSpeedThreshold",
|
|
65
|
+
"restDisplacementThreshold",
|
|
66
|
+
"duration",
|
|
67
|
+
"easing",
|
|
68
|
+
"delay",
|
|
69
|
+
"repeat",
|
|
70
|
+
"deceleration",
|
|
71
|
+
"clamp"
|
|
72
|
+
]);
|
|
73
|
+
function isTopLevelTransition(t) {
|
|
74
|
+
if (t === null || typeof t !== "object") return false;
|
|
75
|
+
const keys = Object.keys(t);
|
|
76
|
+
if (keys.length === 0) return false;
|
|
77
|
+
return keys.every((k) => TRANSITION_CONFIG_KEYS.has(k));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/config/namedTransitions.ts
|
|
81
|
+
var UNKNOWN_NAME_FALLBACK = { type: "spring" };
|
|
82
|
+
function lookupNamedTransition(name, registry) {
|
|
83
|
+
const cfg = registry[name];
|
|
84
|
+
if (cfg) return cfg;
|
|
85
|
+
if (__DEV__) {
|
|
86
|
+
console.warn(
|
|
87
|
+
`[inertia] Unknown transition name "${name}" \u2014 falling back to the default spring. Register it on a provider: <MotionConfig transitions={{ '${name}': { ... } }}>.`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
return UNKNOWN_NAME_FALLBACK;
|
|
91
|
+
}
|
|
92
|
+
function resolveNamedTransitionProp(transition, registry) {
|
|
93
|
+
if (transition === void 0) return void 0;
|
|
94
|
+
if (typeof transition === "string") {
|
|
95
|
+
return lookupNamedTransition(transition, registry);
|
|
96
|
+
}
|
|
97
|
+
if (isTopLevelTransition(transition)) return transition;
|
|
98
|
+
const map = transition;
|
|
99
|
+
let out = null;
|
|
100
|
+
for (const key in map) {
|
|
101
|
+
const value = map[key];
|
|
102
|
+
if (typeof value === "string") {
|
|
103
|
+
if (out === null) out = { ...map };
|
|
104
|
+
out[key] = lookupNamedTransition(value, registry);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return out ?? transition;
|
|
108
|
+
}
|
|
30
109
|
var modality = "keyboard";
|
|
31
110
|
var installed = false;
|
|
32
111
|
function setKeyboard() {
|
|
@@ -363,51 +442,6 @@ function mergeTransition(base, override) {
|
|
|
363
442
|
}
|
|
364
443
|
return { ...base ?? { type: "spring" }, ...override };
|
|
365
444
|
}
|
|
366
|
-
|
|
367
|
-
// src/transitions/keys.ts
|
|
368
|
-
var TRANSITION_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
369
|
-
"type",
|
|
370
|
-
"tension",
|
|
371
|
-
"friction",
|
|
372
|
-
"mass",
|
|
373
|
-
"velocity",
|
|
374
|
-
"restSpeedThreshold",
|
|
375
|
-
"restDisplacementThreshold",
|
|
376
|
-
"duration",
|
|
377
|
-
"easing",
|
|
378
|
-
"delay",
|
|
379
|
-
"repeat",
|
|
380
|
-
"deceleration",
|
|
381
|
-
"clamp"
|
|
382
|
-
]);
|
|
383
|
-
function isTopLevelTransition(t) {
|
|
384
|
-
if (t === null || typeof t !== "object") return false;
|
|
385
|
-
const keys = Object.keys(t);
|
|
386
|
-
if (keys.length === 0) return false;
|
|
387
|
-
return keys.every((k) => TRANSITION_CONFIG_KEYS.has(k));
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
// src/transitions/sig.ts
|
|
391
|
-
function stableSig(value) {
|
|
392
|
-
if (value === void 0) return "";
|
|
393
|
-
try {
|
|
394
|
-
return stableStringify(value);
|
|
395
|
-
} catch {
|
|
396
|
-
return String(value);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
function stableStringify(v) {
|
|
400
|
-
if (v === null || typeof v !== "object") {
|
|
401
|
-
if (typeof v === "function" || v === void 0) return "null";
|
|
402
|
-
return JSON.stringify(v);
|
|
403
|
-
}
|
|
404
|
-
if (Array.isArray(v)) {
|
|
405
|
-
return "[" + v.map(stableStringify).join(",") + "]";
|
|
406
|
-
}
|
|
407
|
-
const obj = v;
|
|
408
|
-
const keys = Object.keys(obj).sort();
|
|
409
|
-
return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",") + "}";
|
|
410
|
-
}
|
|
411
445
|
var alreadyChecked = false;
|
|
412
446
|
function ensureReanimatedInstalled() {
|
|
413
447
|
if (!__DEV__ || alreadyChecked) return;
|
|
@@ -510,12 +544,14 @@ var DEFAULT_RESTING = {
|
|
|
510
544
|
};
|
|
511
545
|
function transitionFor(prop, transition) {
|
|
512
546
|
if (!transition) return void 0;
|
|
547
|
+
if (typeof transition === "string") return void 0;
|
|
513
548
|
if (isTopLevelTransition(transition)) return transition;
|
|
514
549
|
if (GESTURE_LAYER_NAME_SET.has(prop)) return void 0;
|
|
515
550
|
return transition[prop];
|
|
516
551
|
}
|
|
517
552
|
function gestureLayerTransitionFor(layer, transition) {
|
|
518
553
|
if (!transition) return void 0;
|
|
554
|
+
if (typeof transition === "string") return void 0;
|
|
519
555
|
if (isTopLevelTransition(transition)) return transition;
|
|
520
556
|
return transition[layer];
|
|
521
557
|
}
|
|
@@ -530,17 +566,23 @@ function createMotionComponent(Component) {
|
|
|
530
566
|
initial,
|
|
531
567
|
animate,
|
|
532
568
|
exit,
|
|
533
|
-
transition,
|
|
569
|
+
transition: transitionProp,
|
|
534
570
|
variants,
|
|
535
571
|
controller,
|
|
536
572
|
gesture,
|
|
537
|
-
layout,
|
|
573
|
+
layout: layoutProp,
|
|
538
574
|
layoutId,
|
|
539
575
|
onAnimationEnd,
|
|
540
576
|
style,
|
|
541
577
|
onLayout: userOnLayout,
|
|
542
578
|
...rest
|
|
543
579
|
} = props;
|
|
580
|
+
const namedTransitions = useNamedTransitions();
|
|
581
|
+
const transition = resolveNamedTransitionProp(
|
|
582
|
+
transitionProp,
|
|
583
|
+
namedTransitions
|
|
584
|
+
);
|
|
585
|
+
const layout = typeof layoutProp === "string" ? lookupNamedTransition(layoutProp, namedTransitions) : layoutProp;
|
|
544
586
|
if (__DEV__ && typeof style === "function") {
|
|
545
587
|
throw new Error(
|
|
546
588
|
"[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."
|
|
@@ -1134,5 +1176,3 @@ function compose(user, ours) {
|
|
|
1134
1176
|
var MotionView = createMotionComponent(reactNative.View);
|
|
1135
1177
|
|
|
1136
1178
|
exports.MotionView = MotionView;
|
|
1137
|
-
//# sourceMappingURL=View.js.map
|
|
1138
|
-
//# sourceMappingURL=View.js.map
|
package/dist/motion/View.mjs
CHANGED
|
@@ -5,8 +5,31 @@ import { isWorkletFunction } from 'react-native-worklets';
|
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
6
|
|
|
7
7
|
// src/motion/View.tsx
|
|
8
|
+
|
|
9
|
+
// src/transitions/sig.ts
|
|
10
|
+
function stableSig(value) {
|
|
11
|
+
if (value === void 0) return "";
|
|
12
|
+
try {
|
|
13
|
+
return stableStringify(value);
|
|
14
|
+
} catch {
|
|
15
|
+
return String(value);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function stableStringify(v) {
|
|
19
|
+
if (v === null || typeof v !== "object") {
|
|
20
|
+
if (typeof v === "function" || v === void 0) return "null";
|
|
21
|
+
return JSON.stringify(v);
|
|
22
|
+
}
|
|
23
|
+
if (Array.isArray(v)) {
|
|
24
|
+
return "[" + v.map(stableStringify).join(",") + "]";
|
|
25
|
+
}
|
|
26
|
+
const obj = v;
|
|
27
|
+
const keys = Object.keys(obj).sort();
|
|
28
|
+
return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",") + "}";
|
|
29
|
+
}
|
|
8
30
|
var DEFAULT_MOTION_CONFIG = {
|
|
9
|
-
reducedMotion: "user"
|
|
31
|
+
reducedMotion: "user",
|
|
32
|
+
transitions: {}
|
|
10
33
|
};
|
|
11
34
|
var MotionConfigContext = createContext(
|
|
12
35
|
DEFAULT_MOTION_CONFIG
|
|
@@ -14,6 +37,9 @@ var MotionConfigContext = createContext(
|
|
|
14
37
|
function useMotionConfig() {
|
|
15
38
|
return useContext(MotionConfigContext);
|
|
16
39
|
}
|
|
40
|
+
function useNamedTransitions() {
|
|
41
|
+
return useMotionConfig().transitions;
|
|
42
|
+
}
|
|
17
43
|
function useShouldReduceMotion() {
|
|
18
44
|
const { reducedMotion } = useMotionConfig();
|
|
19
45
|
const osReduced = useReducedMotion();
|
|
@@ -21,6 +47,59 @@ function useShouldReduceMotion() {
|
|
|
21
47
|
if (reducedMotion === "always") return true;
|
|
22
48
|
return osReduced;
|
|
23
49
|
}
|
|
50
|
+
|
|
51
|
+
// src/transitions/keys.ts
|
|
52
|
+
var TRANSITION_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
53
|
+
"type",
|
|
54
|
+
"tension",
|
|
55
|
+
"friction",
|
|
56
|
+
"mass",
|
|
57
|
+
"velocity",
|
|
58
|
+
"restSpeedThreshold",
|
|
59
|
+
"restDisplacementThreshold",
|
|
60
|
+
"duration",
|
|
61
|
+
"easing",
|
|
62
|
+
"delay",
|
|
63
|
+
"repeat",
|
|
64
|
+
"deceleration",
|
|
65
|
+
"clamp"
|
|
66
|
+
]);
|
|
67
|
+
function isTopLevelTransition(t) {
|
|
68
|
+
if (t === null || typeof t !== "object") return false;
|
|
69
|
+
const keys = Object.keys(t);
|
|
70
|
+
if (keys.length === 0) return false;
|
|
71
|
+
return keys.every((k) => TRANSITION_CONFIG_KEYS.has(k));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/config/namedTransitions.ts
|
|
75
|
+
var UNKNOWN_NAME_FALLBACK = { type: "spring" };
|
|
76
|
+
function lookupNamedTransition(name, registry) {
|
|
77
|
+
const cfg = registry[name];
|
|
78
|
+
if (cfg) return cfg;
|
|
79
|
+
if (__DEV__) {
|
|
80
|
+
console.warn(
|
|
81
|
+
`[inertia] Unknown transition name "${name}" \u2014 falling back to the default spring. Register it on a provider: <MotionConfig transitions={{ '${name}': { ... } }}>.`
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
return UNKNOWN_NAME_FALLBACK;
|
|
85
|
+
}
|
|
86
|
+
function resolveNamedTransitionProp(transition, registry) {
|
|
87
|
+
if (transition === void 0) return void 0;
|
|
88
|
+
if (typeof transition === "string") {
|
|
89
|
+
return lookupNamedTransition(transition, registry);
|
|
90
|
+
}
|
|
91
|
+
if (isTopLevelTransition(transition)) return transition;
|
|
92
|
+
const map = transition;
|
|
93
|
+
let out = null;
|
|
94
|
+
for (const key in map) {
|
|
95
|
+
const value = map[key];
|
|
96
|
+
if (typeof value === "string") {
|
|
97
|
+
if (out === null) out = { ...map };
|
|
98
|
+
out[key] = lookupNamedTransition(value, registry);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return out ?? transition;
|
|
102
|
+
}
|
|
24
103
|
var modality = "keyboard";
|
|
25
104
|
var installed = false;
|
|
26
105
|
function setKeyboard() {
|
|
@@ -357,51 +436,6 @@ function mergeTransition(base, override) {
|
|
|
357
436
|
}
|
|
358
437
|
return { ...base ?? { type: "spring" }, ...override };
|
|
359
438
|
}
|
|
360
|
-
|
|
361
|
-
// src/transitions/keys.ts
|
|
362
|
-
var TRANSITION_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
363
|
-
"type",
|
|
364
|
-
"tension",
|
|
365
|
-
"friction",
|
|
366
|
-
"mass",
|
|
367
|
-
"velocity",
|
|
368
|
-
"restSpeedThreshold",
|
|
369
|
-
"restDisplacementThreshold",
|
|
370
|
-
"duration",
|
|
371
|
-
"easing",
|
|
372
|
-
"delay",
|
|
373
|
-
"repeat",
|
|
374
|
-
"deceleration",
|
|
375
|
-
"clamp"
|
|
376
|
-
]);
|
|
377
|
-
function isTopLevelTransition(t) {
|
|
378
|
-
if (t === null || typeof t !== "object") return false;
|
|
379
|
-
const keys = Object.keys(t);
|
|
380
|
-
if (keys.length === 0) return false;
|
|
381
|
-
return keys.every((k) => TRANSITION_CONFIG_KEYS.has(k));
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
// src/transitions/sig.ts
|
|
385
|
-
function stableSig(value) {
|
|
386
|
-
if (value === void 0) return "";
|
|
387
|
-
try {
|
|
388
|
-
return stableStringify(value);
|
|
389
|
-
} catch {
|
|
390
|
-
return String(value);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
function stableStringify(v) {
|
|
394
|
-
if (v === null || typeof v !== "object") {
|
|
395
|
-
if (typeof v === "function" || v === void 0) return "null";
|
|
396
|
-
return JSON.stringify(v);
|
|
397
|
-
}
|
|
398
|
-
if (Array.isArray(v)) {
|
|
399
|
-
return "[" + v.map(stableStringify).join(",") + "]";
|
|
400
|
-
}
|
|
401
|
-
const obj = v;
|
|
402
|
-
const keys = Object.keys(obj).sort();
|
|
403
|
-
return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",") + "}";
|
|
404
|
-
}
|
|
405
439
|
var alreadyChecked = false;
|
|
406
440
|
function ensureReanimatedInstalled() {
|
|
407
441
|
if (!__DEV__ || alreadyChecked) return;
|
|
@@ -504,12 +538,14 @@ var DEFAULT_RESTING = {
|
|
|
504
538
|
};
|
|
505
539
|
function transitionFor(prop, transition) {
|
|
506
540
|
if (!transition) return void 0;
|
|
541
|
+
if (typeof transition === "string") return void 0;
|
|
507
542
|
if (isTopLevelTransition(transition)) return transition;
|
|
508
543
|
if (GESTURE_LAYER_NAME_SET.has(prop)) return void 0;
|
|
509
544
|
return transition[prop];
|
|
510
545
|
}
|
|
511
546
|
function gestureLayerTransitionFor(layer, transition) {
|
|
512
547
|
if (!transition) return void 0;
|
|
548
|
+
if (typeof transition === "string") return void 0;
|
|
513
549
|
if (isTopLevelTransition(transition)) return transition;
|
|
514
550
|
return transition[layer];
|
|
515
551
|
}
|
|
@@ -524,17 +560,23 @@ function createMotionComponent(Component) {
|
|
|
524
560
|
initial,
|
|
525
561
|
animate,
|
|
526
562
|
exit,
|
|
527
|
-
transition,
|
|
563
|
+
transition: transitionProp,
|
|
528
564
|
variants,
|
|
529
565
|
controller,
|
|
530
566
|
gesture,
|
|
531
|
-
layout,
|
|
567
|
+
layout: layoutProp,
|
|
532
568
|
layoutId,
|
|
533
569
|
onAnimationEnd,
|
|
534
570
|
style,
|
|
535
571
|
onLayout: userOnLayout,
|
|
536
572
|
...rest
|
|
537
573
|
} = props;
|
|
574
|
+
const namedTransitions = useNamedTransitions();
|
|
575
|
+
const transition = resolveNamedTransitionProp(
|
|
576
|
+
transitionProp,
|
|
577
|
+
namedTransitions
|
|
578
|
+
);
|
|
579
|
+
const layout = typeof layoutProp === "string" ? lookupNamedTransition(layoutProp, namedTransitions) : layoutProp;
|
|
538
580
|
if (__DEV__ && typeof style === "function") {
|
|
539
581
|
throw new Error(
|
|
540
582
|
"[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."
|
|
@@ -1128,5 +1170,3 @@ function compose(user, ours) {
|
|
|
1128
1170
|
var MotionView = createMotionComponent(View);
|
|
1129
1171
|
|
|
1130
1172
|
export { MotionView };
|
|
1131
|
-
//# sourceMappingURL=View.mjs.map
|
|
1132
|
-
//# sourceMappingURL=View.mjs.map
|
package/dist/testing/index.js
CHANGED
package/dist/testing/index.mjs
CHANGED
package/dist/touch/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PanResponderInstance } from 'react-native';
|
|
2
2
|
import { useAnimatedStyle, SharedValue } from 'react-native-reanimated';
|
|
3
|
-
import {
|
|
3
|
+
import { a as TransitionConfig } from '../types-BzEgiUdJ.mjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/touch/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PanResponderInstance } from 'react-native';
|
|
2
2
|
import { useAnimatedStyle, SharedValue } from 'react-native-reanimated';
|
|
3
|
-
import {
|
|
3
|
+
import { a as TransitionConfig } from '../types-BzEgiUdJ.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/touch/index.js
CHANGED