@tamagui/animations-motion 2.0.0-rc.9 → 2.0.0
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/dist/cjs/createAnimations.cjs +559 -299
- package/dist/cjs/createAnimations.native.js +653 -318
- package/dist/cjs/createAnimations.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +21 -13
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/polyfill.cjs +3 -1
- package/dist/cjs/polyfill.native.js +3 -1
- package/dist/cjs/polyfill.native.js.map +1 -1
- package/dist/esm/createAnimations.mjs +529 -272
- package/dist/esm/createAnimations.mjs.map +1 -1
- package/dist/esm/createAnimations.native.js +623 -291
- package/dist/esm/createAnimations.native.js.map +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/index.mjs +0 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +9 -3
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/polyfill.mjs +3 -1
- package/dist/esm/polyfill.mjs.map +1 -1
- package/dist/esm/polyfill.native.js +3 -1
- package/dist/esm/polyfill.native.js.map +1 -1
- package/package.json +8 -7
- package/src/createAnimations.tsx +469 -351
- package/types/createAnimations.d.ts +1 -0
- package/types/createAnimations.d.ts.map +4 -4
- package/types/index.d.ts.map +2 -2
- package/types/index.native.d.ts.map +2 -2
- package/types/polyfill.d.ts.map +2 -2
- package/dist/cjs/createAnimations.js +0 -412
- package/dist/cjs/createAnimations.js.map +0 -6
- package/dist/cjs/index.js +0 -16
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/polyfill.js +0 -2
- package/dist/cjs/polyfill.js.map +0 -6
- package/dist/esm/createAnimations.js +0 -416
- package/dist/esm/createAnimations.js.map +0 -6
- package/dist/esm/polyfill.js +0 -2
- package/dist/esm/polyfill.js.map +0 -6
|
@@ -4,246 +4,383 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
8
|
-
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
18
|
get: () => from[key],
|
|
18
19
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
22
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
34
36
|
var createAnimations_exports = {};
|
|
35
37
|
__export(createAnimations_exports, {
|
|
36
|
-
createAnimations: () => createAnimations
|
|
38
|
+
createAnimations: () => createAnimations,
|
|
39
|
+
disableAnimationProps: () => disableAnimationProps
|
|
37
40
|
});
|
|
38
41
|
module.exports = __toCommonJS(createAnimations_exports);
|
|
39
|
-
var import_jsx_runtime = require("react/jsx-runtime")
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
43
|
+
var import_animation_helpers = require("@tamagui/animation-helpers");
|
|
44
|
+
var import_use_presence = require("@tamagui/use-presence");
|
|
45
|
+
var import_web = require("@tamagui/web");
|
|
46
|
+
var import_react = require("motion/react");
|
|
47
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
45
48
|
function _instanceof(left, right) {
|
|
46
|
-
|
|
49
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
50
|
+
return !!right[Symbol.hasInstance](left);
|
|
51
|
+
} else {
|
|
52
|
+
return left instanceof right;
|
|
53
|
+
}
|
|
47
54
|
}
|
|
48
55
|
function _type_of(obj) {
|
|
49
56
|
"@swc/helpers - typeof";
|
|
50
57
|
|
|
51
|
-
return obj && typeof Symbol
|
|
58
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
59
|
+
}
|
|
60
|
+
var isServer = typeof window === "undefined";
|
|
61
|
+
function useAnimateSSRSafe() {
|
|
62
|
+
if (isServer) {
|
|
63
|
+
return [(0, import_react2.useRef)(null), function () {}];
|
|
64
|
+
}
|
|
65
|
+
return (0, import_react.useAnimate)();
|
|
66
|
+
}
|
|
67
|
+
var MotionValueStrategy = /* @__PURE__ */new WeakMap();
|
|
68
|
+
var PendingMotionOnFinish = /* @__PURE__ */new WeakMap();
|
|
69
|
+
function settlePendingMotionOnFinish(mv, controls) {
|
|
70
|
+
var onFinish = PendingMotionOnFinish.get(mv);
|
|
71
|
+
if (!onFinish) return;
|
|
72
|
+
PendingMotionOnFinish.delete(mv);
|
|
73
|
+
controls.then(function () {
|
|
74
|
+
return onFinish();
|
|
75
|
+
}).catch(function () {
|
|
76
|
+
return onFinish();
|
|
77
|
+
});
|
|
52
78
|
}
|
|
53
|
-
var MotionValueStrategy = /* @__PURE__ */new WeakMap(),
|
|
54
|
-
nonPositionTransformRe = /scale|rotate|skew|matrix|perspective/;
|
|
55
79
|
function createAnimations(animations) {
|
|
56
|
-
var isHydratingGlobal
|
|
57
|
-
|
|
80
|
+
var isHydratingGlobal;
|
|
81
|
+
var hydratingComponents = /* @__PURE__ */new Set();
|
|
58
82
|
return {
|
|
59
|
-
// this is only used by Sheet basically for now to pass result of useAnimatedStyle to
|
|
60
83
|
View: MotionView,
|
|
61
84
|
Text: MotionText,
|
|
62
|
-
isReactNative:
|
|
63
|
-
supportsCSS: !0,
|
|
85
|
+
isReactNative: false,
|
|
64
86
|
inputStyle: "css",
|
|
65
87
|
outputStyle: "inline",
|
|
66
|
-
|
|
67
|
-
avoidReRenders: !0,
|
|
88
|
+
avoidReRenders: true,
|
|
68
89
|
animations,
|
|
69
90
|
usePresence: import_use_presence.usePresence,
|
|
70
91
|
ResetPresence: import_use_presence.ResetPresence,
|
|
71
92
|
onMount() {
|
|
72
|
-
isHydratingGlobal =
|
|
93
|
+
isHydratingGlobal = false;
|
|
94
|
+
hydratingComponents.forEach(function (cb) {
|
|
73
95
|
return cb();
|
|
74
96
|
});
|
|
75
97
|
},
|
|
76
98
|
useAnimations: function (animationProps) {
|
|
77
|
-
isHydratingGlobal === void 0 && !(0, import_web.getConfig)().settings.disableSSR
|
|
99
|
+
if (isHydratingGlobal === void 0 && !(0, import_web.getConfig)().settings.disableSSR) {
|
|
100
|
+
isHydratingGlobal = true;
|
|
101
|
+
}
|
|
78
102
|
var {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
103
|
+
props,
|
|
104
|
+
style,
|
|
105
|
+
componentState,
|
|
106
|
+
stateRef,
|
|
107
|
+
useStyleEmitter,
|
|
108
|
+
presence
|
|
109
|
+
} = animationProps;
|
|
110
|
+
var animationKey = Array.isArray(props.transition) ? props.transition[0] : props.transition;
|
|
111
|
+
var isComponentHydrating = componentState.unmounted === true;
|
|
112
|
+
var isMounting = componentState.unmounted === "should-enter";
|
|
113
|
+
var isEntering = !!componentState.unmounted;
|
|
114
|
+
var isExiting = (presence === null || presence === void 0 ? void 0 : presence[0]) === false;
|
|
115
|
+
var sendExitComplete = presence === null || presence === void 0 ? void 0 : presence[1];
|
|
116
|
+
var refs = (0, import_react2.useRef)(null);
|
|
117
|
+
if (!refs.current) {
|
|
118
|
+
refs.current = {
|
|
119
|
+
isFirstRender: true,
|
|
120
|
+
lastDoAnimate: null,
|
|
121
|
+
lastDontAnimate: null,
|
|
122
|
+
controls: null,
|
|
123
|
+
lastAnimateAt: 0,
|
|
124
|
+
disposed: false,
|
|
125
|
+
wasExiting: false,
|
|
126
|
+
isExiting: false,
|
|
127
|
+
sendExitComplete: void 0,
|
|
128
|
+
animationState: "default",
|
|
129
|
+
frozenExitTarget: null,
|
|
130
|
+
exitCompleteScheduled: false,
|
|
131
|
+
wasEntering: false,
|
|
132
|
+
wasDisabled: false
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
var justFinishedEntering = refs.current.wasEntering && !isEntering;
|
|
94
136
|
(0, import_react2.useEffect)(function () {
|
|
95
|
-
|
|
137
|
+
refs.current.wasEntering = isEntering;
|
|
96
138
|
});
|
|
97
|
-
var animationState = isExiting ? "exit" : isMounting || justFinishedEntering ? "enter" : "default"
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
139
|
+
var animationState = isExiting ? "exit" : isMounting || justFinishedEntering ? "enter" : "default";
|
|
140
|
+
var disableAnimation = isComponentHydrating || isMounting || !animationKey;
|
|
141
|
+
var [scope, animate] = useAnimateSSRSafe();
|
|
142
|
+
refs.current.isExiting = isExiting;
|
|
143
|
+
refs.current.sendExitComplete = sendExitComplete;
|
|
144
|
+
refs.current.animationState = animationState;
|
|
145
|
+
var justStartedExiting = isExiting && !refs.current.wasExiting;
|
|
146
|
+
var justStoppedExiting = !isExiting && refs.current.wasExiting;
|
|
147
|
+
if (justStartedExiting || justStoppedExiting) {
|
|
148
|
+
refs.current.frozenExitTarget = null;
|
|
149
|
+
refs.current.exitCompleteScheduled = false;
|
|
150
|
+
}
|
|
151
|
+
(0, import_react2.useEffect)(function () {
|
|
152
|
+
refs.current.wasExiting = isExiting;
|
|
153
|
+
});
|
|
154
|
+
var {
|
|
155
|
+
dontAnimate = {},
|
|
156
|
+
doAnimate,
|
|
157
|
+
animationOptions
|
|
158
|
+
} = getMotionAnimatedProps(props, style, disableAnimation, animationState);
|
|
159
|
+
var [firstRenderStyle] = (0, import_react2.useState)(style);
|
|
160
|
+
if (refs.current.isFirstRender) {
|
|
161
|
+
refs.current.lastDontAnimate = firstRenderStyle;
|
|
162
|
+
}
|
|
163
|
+
var [isHydrating, setIsHydrating] = (0, import_react2.useState)(isHydratingGlobal);
|
|
122
164
|
(0, import_react2.useLayoutEffect)(function () {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
165
|
+
if (isHydratingGlobal) {
|
|
166
|
+
hydratingComponents.add(function () {
|
|
167
|
+
setIsHydrating(false);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return function () {
|
|
171
|
+
refs.current.disposed = true;
|
|
127
172
|
};
|
|
128
173
|
}, []);
|
|
129
174
|
var flushAnimation = function (param) {
|
|
130
175
|
var {
|
|
131
|
-
doAnimate:
|
|
132
|
-
animationOptions:
|
|
176
|
+
doAnimate: doAnimateRaw = {},
|
|
177
|
+
animationOptions: passedOptions = {},
|
|
133
178
|
dontAnimate: dontAnimate2
|
|
134
179
|
} = param;
|
|
180
|
+
var startedControls = null;
|
|
181
|
+
var isCurrentlyExiting = refs.current.isExiting;
|
|
182
|
+
var currentSendExitComplete = refs.current.sendExitComplete;
|
|
183
|
+
var doAnimate2 = doAnimateRaw;
|
|
184
|
+
if (isCurrentlyExiting && refs.current.frozenExitTarget) {
|
|
185
|
+
doAnimate2 = refs.current.frozenExitTarget;
|
|
186
|
+
}
|
|
187
|
+
var _props_transition;
|
|
188
|
+
var animationOptions2 = isCurrentlyExiting && currentSendExitComplete ? getAnimationOptions((_props_transition = props.transition) !== null && _props_transition !== void 0 ? _props_transition : null, "exit") : passedOptions;
|
|
135
189
|
try {
|
|
136
190
|
var node = stateRef.current.host;
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
191
|
+
if (refs.current.isFirstRender) {
|
|
192
|
+
refs.current.lastDontAnimate = null;
|
|
193
|
+
refs.current.lastDoAnimate = null;
|
|
194
|
+
}
|
|
195
|
+
if (process.env.NODE_ENV === "development") {
|
|
196
|
+
if (props["debug"] && props["debug"] !== "profile") {
|
|
197
|
+
console.groupCollapsed(`[motion] animate (${JSON.stringify(getDiff(refs.current.lastDoAnimate, doAnimate2), null, 2)})`);
|
|
198
|
+
console.info({
|
|
199
|
+
props,
|
|
200
|
+
componentState,
|
|
201
|
+
doAnimate: doAnimate2,
|
|
202
|
+
dontAnimate: dontAnimate2,
|
|
203
|
+
animationOptions: animationOptions2,
|
|
204
|
+
animationProps,
|
|
205
|
+
lastDoAnimate: {
|
|
206
|
+
...refs.current.lastDoAnimate
|
|
207
|
+
},
|
|
208
|
+
lastDontAnimate: {
|
|
209
|
+
...refs.current.lastDontAnimate
|
|
210
|
+
},
|
|
211
|
+
isExiting,
|
|
212
|
+
style,
|
|
213
|
+
node
|
|
214
|
+
});
|
|
215
|
+
console.groupCollapsed(`trace >`);
|
|
216
|
+
console.trace();
|
|
217
|
+
console.groupEnd();
|
|
218
|
+
console.groupEnd();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (!_instanceof(node, HTMLElement)) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
var prevDont = refs.current.lastDontAnimate;
|
|
225
|
+
if (dontAnimate2) {
|
|
226
|
+
if (prevDont) {
|
|
227
|
+
removeRemovedStyles(prevDont, dontAnimate2, node, doAnimate2);
|
|
228
|
+
var changed = getDiff(prevDont, dontAnimate2);
|
|
229
|
+
if (changed) {
|
|
230
|
+
Object.assign(node.style, changed);
|
|
231
|
+
}
|
|
232
|
+
} else {
|
|
233
|
+
Object.assign(node.style, dontAnimate2);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
160
236
|
if (doAnimate2) {
|
|
161
237
|
if (prevDont) {
|
|
162
|
-
var
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
238
|
+
for (var key in prevDont) {
|
|
239
|
+
if (key in doAnimate2) {
|
|
240
|
+
node.style[key] = prevDont[key];
|
|
241
|
+
if (refs.current.lastDoAnimate) {
|
|
242
|
+
refs.current.lastDoAnimate[key] = prevDont[key];
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
var lastAnimated = refs.current.lastDoAnimate;
|
|
248
|
+
if (lastAnimated) {
|
|
249
|
+
removeRemovedStyles(lastAnimated, doAnimate2, node, dontAnimate2);
|
|
169
250
|
}
|
|
170
|
-
var
|
|
171
|
-
lastAnimated && removeRemovedStyles(lastAnimated, doAnimate2, node, dontAnimate2);
|
|
172
|
-
var diff = getDiff(lastDoAnimate.current, doAnimate2);
|
|
251
|
+
var diff = getDiff(refs.current.lastDoAnimate, doAnimate2);
|
|
173
252
|
if (diff) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
var
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
keyframeDiff = {
|
|
191
|
-
...diff,
|
|
192
|
-
transform: [`translateX(${currentX}px) translateY(${currentY}px)`, targetTransform]
|
|
193
|
-
};
|
|
194
|
-
controls.current = animate(scope.current, keyframeDiff, animationOptions2), lastAnimateAt.current = Date.now(), lastDontAnimate.current = dontAnimate2 ? {
|
|
195
|
-
...dontAnimate2
|
|
196
|
-
} : {}, lastDoAnimate.current = doAnimate2 ? {
|
|
197
|
-
...doAnimate2
|
|
198
|
-
} : {};
|
|
199
|
-
return;
|
|
253
|
+
if (isCurrentlyExiting && !refs.current.frozenExitTarget) {
|
|
254
|
+
refs.current.frozenExitTarget = {
|
|
255
|
+
...doAnimate2
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
var isPopperPosition = node.hasAttribute("data-popper-animate-position");
|
|
259
|
+
var midFlightValues = null;
|
|
260
|
+
if (refs.current.controls) {
|
|
261
|
+
try {
|
|
262
|
+
var computed = getComputedStyle(node);
|
|
263
|
+
midFlightValues = {};
|
|
264
|
+
for (var key1 in diff) {
|
|
265
|
+
var val = computed[key1];
|
|
266
|
+
if (val !== void 0 && val !== "") {
|
|
267
|
+
midFlightValues[key1] = val;
|
|
268
|
+
}
|
|
200
269
|
}
|
|
270
|
+
} catch (e) {}
|
|
271
|
+
if (isCurrentlyExiting) {
|
|
272
|
+
refs.current.controls.stop();
|
|
201
273
|
}
|
|
274
|
+
if (midFlightValues) {
|
|
275
|
+
for (var key2 in midFlightValues) {
|
|
276
|
+
;
|
|
277
|
+
node.style[key2] = midFlightValues[key2];
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (isPopperPosition) {
|
|
281
|
+
var anims = node.getAnimations();
|
|
282
|
+
var _iteratorNormalCompletion = true,
|
|
283
|
+
_didIteratorError = false,
|
|
284
|
+
_iteratorError = void 0;
|
|
285
|
+
try {
|
|
286
|
+
for (var _iterator = anims[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
287
|
+
var anim = _step.value;
|
|
288
|
+
anim.cancel();
|
|
289
|
+
}
|
|
290
|
+
} catch (err) {
|
|
291
|
+
_didIteratorError = true;
|
|
292
|
+
_iteratorError = err;
|
|
293
|
+
} finally {
|
|
294
|
+
try {
|
|
295
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
296
|
+
_iterator.return();
|
|
297
|
+
}
|
|
298
|
+
} finally {
|
|
299
|
+
if (_didIteratorError) {
|
|
300
|
+
throw _iteratorError;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
var fixedDiff = fixTransparentColors(diff, refs.current.lastDoAnimate, doAnimate2);
|
|
307
|
+
if ((midFlightValues === null || midFlightValues === void 0 ? void 0 : midFlightValues.transform) && fixedDiff.transform) {
|
|
308
|
+
fixedDiff.transform = [midFlightValues.transform, fixedDiff.transform];
|
|
202
309
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
controls.current = animate(scope.current, fixedDiff, animationOptions2), lastAnimateAt.current = Date.now();
|
|
310
|
+
startedControls = animate(scope.current, fixedDiff, animationOptions2);
|
|
311
|
+
refs.current.controls = startedControls;
|
|
312
|
+
refs.current.lastAnimateAt = Date.now();
|
|
207
313
|
}
|
|
208
314
|
}
|
|
209
|
-
|
|
315
|
+
refs.current.lastDontAnimate = dontAnimate2 ? {
|
|
210
316
|
...dontAnimate2
|
|
211
|
-
} : {}
|
|
317
|
+
} : {};
|
|
318
|
+
refs.current.lastDoAnimate = doAnimate2 ? {
|
|
212
319
|
...doAnimate2
|
|
213
320
|
} : {};
|
|
214
321
|
} finally {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
322
|
+
if (isCurrentlyExiting && currentSendExitComplete) {
|
|
323
|
+
if (startedControls) {
|
|
324
|
+
refs.current.exitCompleteScheduled = true;
|
|
325
|
+
startedControls.finished.then(function () {
|
|
326
|
+
if (refs.current.isExiting) {
|
|
327
|
+
currentSendExitComplete();
|
|
328
|
+
}
|
|
329
|
+
}).catch(function () {
|
|
330
|
+
if (refs.current.isExiting) {
|
|
331
|
+
currentSendExitComplete();
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
} else if (!refs.current.exitCompleteScheduled) {
|
|
335
|
+
currentSendExitComplete();
|
|
336
|
+
}
|
|
337
|
+
}
|
|
218
338
|
}
|
|
219
339
|
};
|
|
220
|
-
|
|
221
|
-
var _$animationProps = getMotionAnimatedProps(props, nextStyle, disableAnimation, animationState);
|
|
340
|
+
useStyleEmitter === null || useStyleEmitter === void 0 ? void 0 : useStyleEmitter(function (nextStyle, effectiveTransition) {
|
|
341
|
+
var _$animationProps = getMotionAnimatedProps(props, nextStyle, disableAnimation, refs.current.animationState, effectiveTransition);
|
|
222
342
|
flushAnimation(_$animationProps);
|
|
223
|
-
})
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
} : {}), lastDontAnimate.current = dontAnimate ? {
|
|
343
|
+
});
|
|
344
|
+
(0, import_web.useIsomorphicLayoutEffect)(function () {
|
|
345
|
+
if (refs.current.isFirstRender) {
|
|
346
|
+
refs.current.isFirstRender = false;
|
|
347
|
+
refs.current.wasDisabled = disableAnimation;
|
|
348
|
+
if (isHydrating) {
|
|
349
|
+
if (doAnimate && Object.keys(doAnimate).length > 0) {
|
|
350
|
+
refs.current.lastDoAnimate = {
|
|
351
|
+
...doAnimate
|
|
352
|
+
};
|
|
353
|
+
} else {
|
|
354
|
+
refs.current.lastDoAnimate = dontAnimate ? {
|
|
355
|
+
...dontAnimate
|
|
356
|
+
} : {};
|
|
357
|
+
}
|
|
358
|
+
refs.current.lastDontAnimate = dontAnimate ? {
|
|
240
359
|
...dontAnimate
|
|
241
|
-
} : {}
|
|
360
|
+
} : {};
|
|
361
|
+
refs.current.lastAnimateAt = Date.now();
|
|
242
362
|
return;
|
|
243
363
|
}
|
|
244
|
-
|
|
364
|
+
refs.current.lastDontAnimate = dontAnimate ? {
|
|
365
|
+
...dontAnimate
|
|
366
|
+
} : {};
|
|
367
|
+
refs.current.lastDoAnimate = doAnimate ? {
|
|
368
|
+
...doAnimate
|
|
369
|
+
} : {};
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
var justEnabled = refs.current.wasDisabled && !disableAnimation;
|
|
373
|
+
refs.current.wasDisabled = disableAnimation;
|
|
374
|
+
if (justEnabled && animationState !== "enter") {
|
|
375
|
+
var node = stateRef.current.host;
|
|
376
|
+
if (_instanceof(node, HTMLElement)) {
|
|
377
|
+
if (dontAnimate) Object.assign(node.style, dontAnimate);
|
|
378
|
+
if (doAnimate) Object.assign(node.style, doAnimate);
|
|
379
|
+
}
|
|
380
|
+
refs.current.lastDontAnimate = dontAnimate ? {
|
|
245
381
|
...dontAnimate
|
|
246
|
-
} : {}
|
|
382
|
+
} : {};
|
|
383
|
+
refs.current.lastDoAnimate = doAnimate ? {
|
|
247
384
|
...doAnimate
|
|
248
385
|
} : {};
|
|
249
386
|
return;
|
|
@@ -253,18 +390,24 @@ function createAnimations(animations) {
|
|
|
253
390
|
dontAnimate,
|
|
254
391
|
animationOptions
|
|
255
392
|
});
|
|
256
|
-
}, [
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
393
|
+
}, [style, isExiting, disableAnimation]);
|
|
394
|
+
if (process.env.NODE_ENV === "development") {
|
|
395
|
+
if (props["debug"] && props["debug"] !== "profile") {
|
|
396
|
+
console.groupCollapsed(`[motion] render`);
|
|
397
|
+
console.info({
|
|
398
|
+
style,
|
|
399
|
+
doAnimate,
|
|
400
|
+
dontAnimate,
|
|
401
|
+
scope,
|
|
402
|
+
animationOptions,
|
|
403
|
+
isExiting,
|
|
404
|
+
isFirstRender: refs.current.isFirstRender,
|
|
405
|
+
animationProps
|
|
406
|
+
});
|
|
407
|
+
console.groupEnd();
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return {
|
|
268
411
|
style: firstRenderStyle,
|
|
269
412
|
ref: scope,
|
|
270
413
|
render: "div"
|
|
@@ -285,16 +428,25 @@ function createAnimations(animations) {
|
|
|
285
428
|
type: "spring"
|
|
286
429
|
},
|
|
287
430
|
onFinish = arguments.length > 2 ? arguments[2] : void 0;
|
|
288
|
-
if (config.type === "direct")
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
if (MotionValueStrategy.set(motionValue, config), onFinish) var unsubscribe = motionValue.on("change", function (value) {
|
|
292
|
-
Math.abs(value - next) < 0.01 && (unsubscribe(), onFinish());
|
|
431
|
+
if (config.type === "direct") {
|
|
432
|
+
MotionValueStrategy.set(motionValue, {
|
|
433
|
+
type: "direct"
|
|
293
434
|
});
|
|
294
435
|
motionValue.set(next);
|
|
436
|
+
onFinish === null || onFinish === void 0 ? void 0 : onFinish();
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
MotionValueStrategy.set(motionValue, config);
|
|
440
|
+
if (onFinish) {
|
|
441
|
+
var prior = PendingMotionOnFinish.get(motionValue);
|
|
442
|
+
if (prior) {
|
|
443
|
+
PendingMotionOnFinish.delete(motionValue);
|
|
444
|
+
prior();
|
|
445
|
+
}
|
|
446
|
+
PendingMotionOnFinish.set(motionValue, onFinish);
|
|
295
447
|
}
|
|
448
|
+
motionValue.set(next);
|
|
296
449
|
},
|
|
297
|
-
// Motion doesn't have a direct onFinish callback, so we simulate it
|
|
298
450
|
stop() {
|
|
299
451
|
motionValue.stop();
|
|
300
452
|
}
|
|
@@ -303,15 +455,16 @@ function createAnimations(animations) {
|
|
|
303
455
|
},
|
|
304
456
|
useAnimatedNumberReaction(param, onValue) {
|
|
305
457
|
var {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
458
|
+
value
|
|
459
|
+
} = param;
|
|
460
|
+
var instance = value.getInstance();
|
|
309
461
|
(0, import_react.useMotionValueEvent)(instance, "change", onValue);
|
|
310
462
|
},
|
|
311
463
|
useAnimatedNumberStyle(val, getStyleProp) {
|
|
312
|
-
var motionValue = val.getInstance()
|
|
313
|
-
|
|
314
|
-
|
|
464
|
+
var motionValue = val.getInstance();
|
|
465
|
+
var getStyleRef = (0, import_react2.useRef)(getStyleProp);
|
|
466
|
+
getStyleRef.current = getStyleProp;
|
|
467
|
+
return (0, import_react2.useMemo)(function () {
|
|
315
468
|
return {
|
|
316
469
|
getStyle: function (cur) {
|
|
317
470
|
return getStyleRef.current(cur);
|
|
@@ -319,20 +472,48 @@ function createAnimations(animations) {
|
|
|
319
472
|
motionValue
|
|
320
473
|
};
|
|
321
474
|
}, []);
|
|
475
|
+
},
|
|
476
|
+
useAnimatedNumbersStyle(vals, getStyleProp) {
|
|
477
|
+
var motionValues = vals.map(function (v) {
|
|
478
|
+
return v.getInstance();
|
|
479
|
+
});
|
|
480
|
+
var getStyleRef = (0, import_react2.useRef)(getStyleProp);
|
|
481
|
+
getStyleRef.current = getStyleProp;
|
|
482
|
+
return (0, import_react2.useMemo)(function () {
|
|
483
|
+
return {
|
|
484
|
+
getStyle: function () {
|
|
485
|
+
for (var _len = arguments.length, currentValues = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
486
|
+
currentValues[_key] = arguments[_key];
|
|
487
|
+
}
|
|
488
|
+
return getStyleRef.current(...currentValues);
|
|
489
|
+
},
|
|
490
|
+
motionValues
|
|
491
|
+
};
|
|
492
|
+
}, []);
|
|
322
493
|
}
|
|
323
494
|
};
|
|
324
495
|
function getMotionAnimatedProps(props, style, disable) {
|
|
325
|
-
var animationState = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "default"
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
496
|
+
var animationState = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "default",
|
|
497
|
+
transitionOverride = arguments.length > 4 ? arguments[4] : void 0;
|
|
498
|
+
if (disable) {
|
|
499
|
+
return {
|
|
500
|
+
dontAnimate: style
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
var _ref;
|
|
504
|
+
var animationOptions = getAnimationOptions((_ref = transitionOverride !== null && transitionOverride !== void 0 ? transitionOverride : props.transition) !== null && _ref !== void 0 ? _ref : null, animationState);
|
|
505
|
+
var dontAnimate;
|
|
506
|
+
var doAnimate;
|
|
507
|
+
var animateOnly = props.animateOnly;
|
|
333
508
|
for (var key in style) {
|
|
334
509
|
var value = style[key];
|
|
335
|
-
disableAnimationProps.has(key) || animateOnly && !animateOnly.includes(key)
|
|
510
|
+
if (disableAnimationProps.has(key) || animateOnly && !animateOnly.includes(key)) {
|
|
511
|
+
dontAnimate || (dontAnimate = {});
|
|
512
|
+
dontAnimate[key] = value;
|
|
513
|
+
} else {
|
|
514
|
+
doAnimate || (doAnimate = {});
|
|
515
|
+
doAnimate[key] = value;
|
|
516
|
+
}
|
|
336
517
|
}
|
|
337
518
|
return {
|
|
338
519
|
dontAnimate,
|
|
@@ -341,31 +522,51 @@ function createAnimations(animations) {
|
|
|
341
522
|
};
|
|
342
523
|
}
|
|
343
524
|
function getAnimationOptions(transitionProp) {
|
|
344
|
-
var animationState = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "default"
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
if (!effectiveKey &&
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
normalized.config && (globalConfigOverride = {
|
|
525
|
+
var animationState = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "default";
|
|
526
|
+
var normalized = (0, import_animation_helpers.normalizeTransition)(transitionProp);
|
|
527
|
+
var effectiveKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState);
|
|
528
|
+
if (!effectiveKey && animationState === "default") {
|
|
529
|
+
effectiveKey = normalized.enter || normalized.exit || null;
|
|
530
|
+
}
|
|
531
|
+
var globalConfigOverride = normalized.config ? {
|
|
352
532
|
...normalized.config
|
|
353
|
-
}
|
|
533
|
+
} : void 0;
|
|
534
|
+
if (!effectiveKey && Object.keys(normalized.properties).length === 0 && !globalConfigOverride) {
|
|
535
|
+
return {};
|
|
536
|
+
}
|
|
537
|
+
var defaultConfig = effectiveKey ? withInferredType(animations[effectiveKey]) : null;
|
|
538
|
+
var delay = normalized.delay;
|
|
354
539
|
var result = {};
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
540
|
+
if (defaultConfig) {
|
|
541
|
+
Object.assign(result, defaultConfig);
|
|
542
|
+
}
|
|
543
|
+
if (globalConfigOverride) {
|
|
544
|
+
Object.assign(result, globalConfigOverride);
|
|
545
|
+
if (result.type === void 0 && result.duration !== void 0 && result.damping === void 0 && result.stiffness === void 0 && result.mass === void 0) {
|
|
546
|
+
result.type = "tween";
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
if (delay) {
|
|
550
|
+
result.delay = delay;
|
|
551
|
+
}
|
|
552
|
+
if (defaultConfig || globalConfigOverride || delay) {
|
|
553
|
+
result.default = {
|
|
554
|
+
...defaultConfig,
|
|
555
|
+
...globalConfigOverride,
|
|
556
|
+
...(delay ? {
|
|
557
|
+
delay
|
|
558
|
+
} : null)
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
var _iteratorNormalCompletion = true,
|
|
562
|
+
_didIteratorError = false,
|
|
364
563
|
_iteratorError = void 0;
|
|
365
564
|
try {
|
|
366
|
-
for (var _iterator = Object.entries(normalized.properties)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion =
|
|
565
|
+
for (var _iterator = Object.entries(normalized.properties)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
367
566
|
var [propName, animationNameOrConfig] = _step.value;
|
|
368
|
-
if (typeof animationNameOrConfig
|
|
567
|
+
if (typeof animationNameOrConfig === "string") {
|
|
568
|
+
result[propName] = withInferredType(animations[animationNameOrConfig]);
|
|
569
|
+
} else if (animationNameOrConfig && (typeof animationNameOrConfig === "undefined" ? "undefined" : _type_of(animationNameOrConfig)) === "object") {
|
|
369
570
|
var baseConfig = animationNameOrConfig.type ? withInferredType(animations[animationNameOrConfig.type]) : defaultConfig;
|
|
370
571
|
result[propName] = {
|
|
371
572
|
...baseConfig,
|
|
@@ -374,20 +575,35 @@ function createAnimations(animations) {
|
|
|
374
575
|
}
|
|
375
576
|
}
|
|
376
577
|
} catch (err) {
|
|
377
|
-
_didIteratorError =
|
|
578
|
+
_didIteratorError = true;
|
|
579
|
+
_iteratorError = err;
|
|
378
580
|
} finally {
|
|
379
581
|
try {
|
|
380
|
-
!_iteratorNormalCompletion && _iterator.return != null
|
|
582
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
583
|
+
_iterator.return();
|
|
584
|
+
}
|
|
381
585
|
} finally {
|
|
382
|
-
if (_didIteratorError)
|
|
586
|
+
if (_didIteratorError) {
|
|
587
|
+
throw _iteratorError;
|
|
588
|
+
}
|
|
383
589
|
}
|
|
384
590
|
}
|
|
591
|
+
convertMsToS(result);
|
|
385
592
|
convertMsToS(result.default);
|
|
386
|
-
for (var key in result)
|
|
593
|
+
for (var key in result) {
|
|
594
|
+
if (key !== "default" && _type_of(result[key]) === "object") {
|
|
595
|
+
convertMsToS(result[key]);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
387
598
|
return result;
|
|
388
599
|
}
|
|
389
600
|
}
|
|
390
601
|
function withInferredType(config) {
|
|
602
|
+
if (!config) {
|
|
603
|
+
return {
|
|
604
|
+
type: "spring"
|
|
605
|
+
};
|
|
606
|
+
}
|
|
391
607
|
var isTimingBased = config.duration !== void 0 && config.damping === void 0 && config.stiffness === void 0 && config.mass === void 0;
|
|
392
608
|
return {
|
|
393
609
|
type: isTimingBased ? "tween" : "spring",
|
|
@@ -395,110 +611,229 @@ function withInferredType(config) {
|
|
|
395
611
|
};
|
|
396
612
|
}
|
|
397
613
|
function convertMsToS(config) {
|
|
398
|
-
|
|
614
|
+
if (!config) return;
|
|
615
|
+
if (typeof config.delay === "number") config.delay = config.delay / 1e3;
|
|
616
|
+
if (typeof config.duration === "number") {
|
|
617
|
+
var isTimingBased = config.type === "tween" || config.type === void 0 && config.damping === void 0 && config.stiffness === void 0 && config.mass === void 0;
|
|
618
|
+
if (isTimingBased) {
|
|
619
|
+
config.duration = config.duration / 1e3;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
399
622
|
}
|
|
400
623
|
function removeRemovedStyles(prev, next, node, dontClearIfIn) {
|
|
401
|
-
for (var key in prev)
|
|
402
|
-
if (
|
|
403
|
-
|
|
624
|
+
for (var key in prev) {
|
|
625
|
+
if (!(key in next)) {
|
|
626
|
+
if (dontClearIfIn && key in dontClearIfIn) {
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
node.style[key] = "";
|
|
630
|
+
}
|
|
404
631
|
}
|
|
405
632
|
}
|
|
406
|
-
var disableAnimationProps = /* @__PURE__ */new Set(["alignContent", "alignItems", "
|
|
407
|
-
|
|
408
|
-
|
|
633
|
+
var disableAnimationProps = /* @__PURE__ */new Set(["alignContent", "alignItems", "boxSizing", "contain", "containerType", "display", "flexBasis", "flexDirection", "fontFamily", "justifyContent", "overflow", "overflowX", "overflowY", "pointerEvents", "position", "textWrap", "userSelect"]);
|
|
634
|
+
var MotionView = createMotionView("div");
|
|
635
|
+
var MotionText = createMotionView("span");
|
|
409
636
|
function createMotionView(defaultTag) {
|
|
410
|
-
var isText = defaultTag === "span"
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
637
|
+
var isText = defaultTag === "span";
|
|
638
|
+
var Component = /* @__PURE__ */(0, import_react2.forwardRef)(function (propsIn, ref) {
|
|
639
|
+
var _hooks_usePropsTransform;
|
|
640
|
+
var {
|
|
641
|
+
forwardedRef,
|
|
642
|
+
animation,
|
|
643
|
+
render = defaultTag,
|
|
644
|
+
style,
|
|
645
|
+
...propsRest
|
|
646
|
+
} = propsIn;
|
|
647
|
+
var [scope, animate] = useAnimateSSRSafe();
|
|
648
|
+
var hostRef = (0, import_react2.useRef)(null);
|
|
649
|
+
var composedRefs = (0, import_web.useComposedRefs)(forwardedRef, ref, hostRef, scope);
|
|
650
|
+
var stateRef = (0, import_react2.useRef)(null);
|
|
651
|
+
if (!stateRef.current) {
|
|
652
|
+
stateRef.current = {
|
|
425
653
|
get host() {
|
|
426
654
|
return hostRef.current;
|
|
427
655
|
}
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
var [_, state] = (0, import_web.useThemeWithState)({});
|
|
659
|
+
var styles = Array.isArray(style) ? style : [style];
|
|
660
|
+
var [animatedStyle, nonAnimatedStyles] = function () {
|
|
661
|
+
var animatedStyle2;
|
|
662
|
+
var nonAnimatedStyles2 = [];
|
|
663
|
+
var _iteratorNormalCompletion = true,
|
|
664
|
+
_didIteratorError = false,
|
|
665
|
+
_iteratorError = void 0;
|
|
666
|
+
try {
|
|
667
|
+
for (var _iterator = styles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
668
|
+
var style2 = _step.value;
|
|
669
|
+
if (style2.getStyle) {
|
|
670
|
+
animatedStyle2 = style2;
|
|
671
|
+
} else {
|
|
672
|
+
nonAnimatedStyles2.push(style2);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
} catch (err) {
|
|
676
|
+
_didIteratorError = true;
|
|
677
|
+
_iteratorError = err;
|
|
678
|
+
} finally {
|
|
679
|
+
try {
|
|
680
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
681
|
+
_iterator.return();
|
|
682
|
+
}
|
|
683
|
+
} finally {
|
|
684
|
+
if (_didIteratorError) {
|
|
685
|
+
throw _iteratorError;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
return [animatedStyle2, nonAnimatedStyles2];
|
|
690
|
+
}();
|
|
691
|
+
function getProps(props2) {
|
|
692
|
+
var out = (0, import_web.getSplitStyles)(props2, isText ? import_web.Text.staticConfig : import_web.View.staticConfig, state === null || state === void 0 ? void 0 : state.theme, state === null || state === void 0 ? void 0 : state.name, {
|
|
693
|
+
unmounted: false
|
|
694
|
+
}, {
|
|
695
|
+
isAnimated: false,
|
|
696
|
+
noClass: true,
|
|
697
|
+
resolveValues: "auto"
|
|
428
698
|
});
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
return !x.getStyle;
|
|
436
|
-
})];
|
|
437
|
-
}();
|
|
438
|
-
function getProps(props2) {
|
|
439
|
-
var out = (0, import_web.getSplitStyles)(props2, isText ? import_web.Text.staticConfig : import_web.View.staticConfig, state?.theme, state?.name, {
|
|
440
|
-
unmounted: !1
|
|
441
|
-
}, {
|
|
442
|
-
isAnimated: !1,
|
|
443
|
-
noClass: !0,
|
|
444
|
-
// noMergeStyle: true,
|
|
445
|
-
resolveValues: "auto"
|
|
446
|
-
});
|
|
447
|
-
return out ? (out.viewProps.style && ((0, import_web.fixStyles)(out.viewProps.style), (0, import_web.styleToCSS)(out.viewProps.style)), out.viewProps) : {};
|
|
699
|
+
if (!out) {
|
|
700
|
+
return {};
|
|
701
|
+
}
|
|
702
|
+
if (out.viewProps.style) {
|
|
703
|
+
(0, import_web.fixStyles)(out.viewProps.style);
|
|
704
|
+
(0, import_web.styleToCSS)(out.viewProps.style);
|
|
448
705
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
706
|
+
return out.viewProps;
|
|
707
|
+
}
|
|
708
|
+
var props = getProps({
|
|
709
|
+
...propsRest,
|
|
710
|
+
style: nonAnimatedStyles
|
|
711
|
+
});
|
|
712
|
+
var Element = render || "div";
|
|
713
|
+
var transformedProps = (_hooks_usePropsTransform = import_web.hooks.usePropsTransform) === null || _hooks_usePropsTransform === void 0 ? void 0 : _hooks_usePropsTransform.call(import_web.hooks, render, props, stateRef, false);
|
|
714
|
+
(0, import_react2.useEffect)(function () {
|
|
715
|
+
if (!animatedStyle) return;
|
|
716
|
+
if (animatedStyle.motionValues) {
|
|
717
|
+
var mvs = animatedStyle.motionValues;
|
|
718
|
+
var unsubs = mvs.map(function (mv) {
|
|
719
|
+
return mv.on("change", function () {
|
|
720
|
+
var currentValues = mvs.map(function (v) {
|
|
721
|
+
return v.get();
|
|
722
|
+
});
|
|
723
|
+
var nextStyle = animatedStyle.getStyle(...currentValues);
|
|
724
|
+
var animationConfig = MotionValueStrategy.get(mv);
|
|
725
|
+
var node = hostRef.current;
|
|
726
|
+
var webStyle = getProps({
|
|
461
727
|
style: nextStyle
|
|
462
728
|
}).style;
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
729
|
+
if (webStyle && _instanceof(node, HTMLElement)) {
|
|
730
|
+
var motionAnimationConfig = (animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.type) === "timing" ? {
|
|
731
|
+
type: "tween",
|
|
732
|
+
duration: ((animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.duration) || 0) / 1e3
|
|
733
|
+
} : (animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.type) === "direct" ? {
|
|
734
|
+
type: "tween",
|
|
735
|
+
duration: 0
|
|
736
|
+
} : {
|
|
737
|
+
type: "spring",
|
|
738
|
+
...animationConfig
|
|
739
|
+
};
|
|
740
|
+
var controls = animate(node, webStyle, motionAnimationConfig);
|
|
741
|
+
settlePendingMotionOnFinish(mv, controls);
|
|
742
|
+
}
|
|
743
|
+
});
|
|
476
744
|
});
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
745
|
+
return function () {
|
|
746
|
+
return unsubs.forEach(function (fn) {
|
|
747
|
+
return fn();
|
|
748
|
+
});
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
if (!animatedStyle.motionValue) return;
|
|
752
|
+
return animatedStyle.motionValue.on("change", function (value) {
|
|
753
|
+
var nextStyle = animatedStyle.getStyle(value);
|
|
754
|
+
var animationConfig = MotionValueStrategy.get(animatedStyle.motionValue);
|
|
755
|
+
var node = hostRef.current;
|
|
756
|
+
var webStyle = getProps({
|
|
757
|
+
style: nextStyle
|
|
758
|
+
}).style;
|
|
759
|
+
if (webStyle && _instanceof(node, HTMLElement)) {
|
|
760
|
+
var motionAnimationConfig = (animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.type) === "timing" ? {
|
|
761
|
+
type: "tween",
|
|
762
|
+
duration: ((animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.duration) || 0) / 1e3
|
|
763
|
+
} : (animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.type) === "direct" ? {
|
|
764
|
+
type: "tween",
|
|
765
|
+
duration: 0
|
|
766
|
+
} : {
|
|
767
|
+
type: "spring",
|
|
768
|
+
...animationConfig
|
|
769
|
+
};
|
|
770
|
+
var controls = animate(node, webStyle, motionAnimationConfig);
|
|
771
|
+
settlePendingMotionOnFinish(animatedStyle.motionValue, controls);
|
|
772
|
+
}
|
|
480
773
|
});
|
|
774
|
+
}, [animatedStyle]);
|
|
775
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Element, {
|
|
776
|
+
...transformedProps,
|
|
777
|
+
ref: composedRefs
|
|
481
778
|
});
|
|
482
|
-
|
|
779
|
+
});
|
|
780
|
+
Component["acceptRenderProp"] = true;
|
|
781
|
+
return Component;
|
|
483
782
|
}
|
|
484
783
|
function getDiff(previous, next) {
|
|
485
|
-
if (!previous)
|
|
784
|
+
if (!previous) {
|
|
785
|
+
return next;
|
|
786
|
+
}
|
|
486
787
|
var diff = null;
|
|
487
|
-
for (var key in next)
|
|
788
|
+
for (var key in next) {
|
|
789
|
+
if (next[key] !== previous[key]) {
|
|
790
|
+
diff || (diff = {});
|
|
791
|
+
diff[key] = next[key];
|
|
792
|
+
}
|
|
793
|
+
}
|
|
488
794
|
return diff;
|
|
489
795
|
}
|
|
490
|
-
function fixTransparentColors(diff, previous) {
|
|
796
|
+
function fixTransparentColors(diff, previous, next) {
|
|
491
797
|
var result = diff;
|
|
492
|
-
for (var key in diff)
|
|
493
|
-
|
|
494
|
-
fixed = "rgba(0, 0, 0, 0)";
|
|
495
|
-
|
|
496
|
-
var
|
|
497
|
-
|
|
798
|
+
for (var key in diff) {
|
|
799
|
+
if (diff[key] === "transparent") {
|
|
800
|
+
var fixed = "rgba(0, 0, 0, 0)";
|
|
801
|
+
var candidates = [previous === null || previous === void 0 ? void 0 : previous[key], next === null || next === void 0 ? void 0 : next[key]];
|
|
802
|
+
var _iteratorNormalCompletion = true,
|
|
803
|
+
_didIteratorError = false,
|
|
804
|
+
_iteratorError = void 0;
|
|
805
|
+
try {
|
|
806
|
+
for (var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
807
|
+
var candidate = _step.value;
|
|
808
|
+
if (typeof candidate === "string" && candidate !== "transparent") {
|
|
809
|
+
var rgbaMatch = candidate.match(/^rgba?\(([^,]+),\s*([^,]+),\s*([^,)]+)/);
|
|
810
|
+
if (rgbaMatch) {
|
|
811
|
+
fixed = `rgba(${rgbaMatch[1]}, ${rgbaMatch[2]}, ${rgbaMatch[3]}, 0)`;
|
|
812
|
+
break;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
} catch (err) {
|
|
817
|
+
_didIteratorError = true;
|
|
818
|
+
_iteratorError = err;
|
|
819
|
+
} finally {
|
|
820
|
+
try {
|
|
821
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
822
|
+
_iterator.return();
|
|
823
|
+
}
|
|
824
|
+
} finally {
|
|
825
|
+
if (_didIteratorError) {
|
|
826
|
+
throw _iteratorError;
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
if (result === diff) {
|
|
831
|
+
result = {
|
|
832
|
+
...diff
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
result[key] = fixed;
|
|
498
836
|
}
|
|
499
|
-
result === diff && (result = {
|
|
500
|
-
...diff
|
|
501
|
-
}), result[key] = fixed;
|
|
502
837
|
}
|
|
503
838
|
return result;
|
|
504
839
|
}
|