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