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