@tamagui/animations-css 2.0.0-rc.4 → 2.0.0-rc.40

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.
@@ -4,53 +4,156 @@ 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
- __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
9
  var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: !0
13
- });
14
- },
15
- __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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
- return to;
21
- };
21
+ }
22
+ return to;
23
+ };
22
24
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
- value: mod,
29
- enumerable: !0
30
- }) : target, mod)),
31
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: !0
33
- }), mod);
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
38
  createAnimations: () => createAnimations
37
39
  });
38
40
  module.exports = __toCommonJS(createAnimations_exports);
39
- var import_animation_helpers = require("@tamagui/animation-helpers"),
40
- import_constants = require("@tamagui/constants"),
41
- import_use_presence = require("@tamagui/use-presence"),
42
- import_web = require("@tamagui/web"),
43
- import_react = __toESM(require("react"), 1);
41
+ var import_animation_helpers = require("@tamagui/animation-helpers");
42
+ var import_constants = require("@tamagui/constants");
43
+ var import_use_presence = require("@tamagui/use-presence");
44
+ var import_web = require("@tamagui/web");
45
+ var import_react = __toESM(require("react"), 1);
44
46
  function _type_of(obj) {
45
47
  "@swc/helpers - typeof";
46
48
 
47
- return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
49
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
48
50
  }
51
+ var EXTRACT_MS_REGEX = /(\d+(?:\.\d+)?)\s*ms/;
52
+ var EXTRACT_S_REGEX = /(\d+(?:\.\d+)?)\s*s/;
49
53
  function extractDuration(animation) {
50
- var msMatch = animation.match(/(\d+(?:\.\d+)?)\s*ms/);
51
- if (msMatch) return Number.parseInt(msMatch[1], 10);
52
- var sMatch = animation.match(/(\d+(?:\.\d+)?)\s*s/);
53
- return sMatch ? Math.round(Number.parseFloat(sMatch[1]) * 1e3) : 300;
54
+ var msMatch = animation.match(EXTRACT_MS_REGEX);
55
+ if (msMatch) {
56
+ return Number.parseInt(msMatch[1], 10);
57
+ }
58
+ var sMatch = animation.match(EXTRACT_S_REGEX);
59
+ if (sMatch) {
60
+ return Math.round(Number.parseFloat(sMatch[1]) * 1e3);
61
+ }
62
+ return 300;
63
+ }
64
+ var MS_DURATION_REGEX = /(\d+(?:\.\d+)?)\s*ms/;
65
+ var S_DURATION_REGEX = /(\d+(?:\.\d+)?)\s*s(?!tiffness)/;
66
+ function applyDurationOverride(animation, durationMs) {
67
+ var msReplaced = animation.replace(MS_DURATION_REGEX, `${durationMs}ms`);
68
+ if (msReplaced !== animation) {
69
+ return msReplaced;
70
+ }
71
+ var sReplaced = animation.replace(S_DURATION_REGEX, `${durationMs}ms`);
72
+ if (sReplaced !== animation) {
73
+ return sReplaced;
74
+ }
75
+ return `${durationMs}ms ${animation}`;
76
+ }
77
+ var TRANSFORM_KEYS = ["x", "y", "scale", "scaleX", "scaleY", "rotate", "rotateX", "rotateY", "rotateZ", "skewX", "skewY"];
78
+ function buildTransformString(style) {
79
+ if (!style) return "";
80
+ var parts = [];
81
+ if (style.x !== void 0 || style.y !== void 0) {
82
+ var _style_x;
83
+ var x = (_style_x = style.x) !== null && _style_x !== void 0 ? _style_x : 0;
84
+ var _style_y;
85
+ var y = (_style_y = style.y) !== null && _style_y !== void 0 ? _style_y : 0;
86
+ parts.push(`translate(${x}px, ${y}px)`);
87
+ }
88
+ if (style.scale !== void 0) {
89
+ parts.push(`scale(${style.scale})`);
90
+ }
91
+ if (style.scaleX !== void 0) {
92
+ parts.push(`scaleX(${style.scaleX})`);
93
+ }
94
+ if (style.scaleY !== void 0) {
95
+ parts.push(`scaleY(${style.scaleY})`);
96
+ }
97
+ if (style.rotate !== void 0) {
98
+ var val = style.rotate;
99
+ var unit = typeof val === "string" && val.includes("deg") ? "" : "deg";
100
+ parts.push(`rotate(${val}${unit})`);
101
+ }
102
+ if (style.rotateX !== void 0) {
103
+ parts.push(`rotateX(${style.rotateX}deg)`);
104
+ }
105
+ if (style.rotateY !== void 0) {
106
+ parts.push(`rotateY(${style.rotateY}deg)`);
107
+ }
108
+ if (style.rotateZ !== void 0) {
109
+ parts.push(`rotateZ(${style.rotateZ}deg)`);
110
+ }
111
+ if (style.skewX !== void 0) {
112
+ parts.push(`skewX(${style.skewX}deg)`);
113
+ }
114
+ if (style.skewY !== void 0) {
115
+ parts.push(`skewY(${style.skewY}deg)`);
116
+ }
117
+ return parts.join(" ");
118
+ }
119
+ function applyStylesToNode(node, style) {
120
+ if (!style) return;
121
+ var transformStr = buildTransformString(style);
122
+ if (transformStr) {
123
+ node.style.transform = transformStr;
124
+ }
125
+ var _iteratorNormalCompletion = true,
126
+ _didIteratorError = false,
127
+ _iteratorError = void 0;
128
+ try {
129
+ for (var _iterator = Object.entries(style)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
130
+ var [key, value] = _step.value;
131
+ if (TRANSFORM_KEYS.includes(key)) continue;
132
+ if (value === void 0) continue;
133
+ if (key === "opacity") {
134
+ node.style.opacity = String(value);
135
+ } else if (key === "backgroundColor") {
136
+ node.style.backgroundColor = String(value);
137
+ } else if (key === "color") {
138
+ node.style.color = String(value);
139
+ } else {
140
+ node.style[key] = typeof value === "number" ? `${value}px` : String(value);
141
+ }
142
+ }
143
+ } catch (err) {
144
+ _didIteratorError = true;
145
+ _iteratorError = err;
146
+ } finally {
147
+ try {
148
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
149
+ _iterator.return();
150
+ }
151
+ } finally {
152
+ if (_didIteratorError) {
153
+ throw _iteratorError;
154
+ }
155
+ }
156
+ }
54
157
  }
55
158
  function createAnimations(animations) {
56
159
  var reactionListeners = /* @__PURE__ */new WeakMap();
@@ -58,30 +161,45 @@ function createAnimations(animations) {
58
161
  animations,
59
162
  usePresence: import_use_presence.usePresence,
60
163
  ResetPresence: import_use_presence.ResetPresence,
61
- supportsCSS: !0,
62
164
  inputStyle: "css",
63
165
  outputStyle: "css",
64
- classNameAnimation: !0,
65
166
  useAnimatedNumber(initial) {
66
- var [val, setVal] = import_react.default.useState(initial),
67
- [onFinish, setOnFinish] = (0, import_react.useState)();
68
- return (0, import_constants.useIsomorphicLayoutEffect)(function () {
69
- onFinish && (onFinish?.(), setOnFinish(void 0));
70
- }, [onFinish]), {
167
+ var [val, setVal] = import_react.default.useState(initial);
168
+ var finishTimerRef = import_react.default.useRef(null);
169
+ return {
71
170
  getInstance() {
72
171
  return setVal;
73
172
  },
74
173
  getValue() {
75
174
  return val;
76
175
  },
77
- setValue(next, config, onFinish2) {
78
- setVal(next), setOnFinish(onFinish2);
176
+ setValue(next, config, onFinish) {
177
+ setVal(next);
178
+ if (finishTimerRef.current) {
179
+ clearTimeout(finishTimerRef.current);
180
+ finishTimerRef.current = null;
181
+ }
182
+ if (onFinish) {
183
+ if (!config || config.type === "direct" || config.type === "timing" && config.duration === 0) {
184
+ onFinish();
185
+ } else {
186
+ var duration = config.type === "timing" ? config.duration : 300;
187
+ finishTimerRef.current = setTimeout(onFinish, duration);
188
+ }
189
+ }
79
190
  var listeners = reactionListeners.get(setVal);
80
- listeners && listeners.forEach(function (listener) {
81
- return listener(next);
82
- });
191
+ if (listeners) {
192
+ listeners.forEach(function (listener) {
193
+ return listener(next);
194
+ });
195
+ }
83
196
  },
84
- stop() {}
197
+ stop() {
198
+ if (finishTimerRef.current) {
199
+ clearTimeout(finishTimerRef.current);
200
+ finishTimerRef.current = null;
201
+ }
202
+ }
85
203
  };
86
204
  },
87
205
  useAnimatedNumberReaction(param, onValue) {
@@ -89,78 +207,312 @@ function createAnimations(animations) {
89
207
  value
90
208
  } = param;
91
209
  import_react.default.useEffect(function () {
92
- var instance = value.getInstance(),
93
- queue = reactionListeners.get(instance);
210
+ var instance = value.getInstance();
211
+ var queue = reactionListeners.get(instance);
94
212
  if (!queue) {
95
213
  var next = /* @__PURE__ */new Set();
96
- reactionListeners.set(instance, next), queue = next;
214
+ reactionListeners.set(instance, next);
215
+ queue = next;
97
216
  }
98
- return queue.add(onValue), function () {
99
- queue?.delete(onValue);
217
+ queue.add(onValue);
218
+ return function () {
219
+ queue === null || queue === void 0 ? void 0 : queue.delete(onValue);
100
220
  };
101
221
  }, []);
102
222
  },
103
223
  useAnimatedNumberStyle(val, getStyle) {
104
224
  return getStyle(val.getValue());
105
225
  },
226
+ useAnimatedNumbersStyle(vals, getStyle) {
227
+ return getStyle(...vals.map(function (v) {
228
+ return v.getValue();
229
+ }));
230
+ },
231
+ // @ts-ignore - styleState is added by createComponent
106
232
  useAnimations: function (param) {
107
233
  var {
108
- props,
109
- presence,
110
- style,
111
- componentState,
112
- stateRef
113
- } = param,
114
- isEntering = !!componentState.unmounted,
115
- isExiting = presence?.[0] === !1,
116
- sendExitComplete = presence?.[1],
117
- wasEnteringRef = import_react.default.useRef(isEntering),
118
- justFinishedEntering = wasEnteringRef.current && !isEntering;
234
+ props,
235
+ presence,
236
+ style,
237
+ componentState,
238
+ stateRef,
239
+ styleState
240
+ } = param;
241
+ var _normalized_config;
242
+ var isHydrating = componentState.unmounted === true;
243
+ var isEntering = !!componentState.unmounted;
244
+ var isExiting = (presence === null || presence === void 0 ? void 0 : presence[0]) === false;
245
+ var sendExitComplete = presence === null || presence === void 0 ? void 0 : presence[1];
246
+ var wasEnteringRef = import_react.default.useRef(isEntering);
247
+ var justFinishedEntering = wasEnteringRef.current && !isEntering;
119
248
  import_react.default.useEffect(function () {
120
249
  wasEnteringRef.current = isEntering;
121
250
  });
122
- var normalized = (0, import_animation_helpers.normalizeTransition)(props.transition),
123
- animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default",
124
- effectiveAnimationKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState),
125
- defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null,
126
- animatedProperties = (0, import_animation_helpers.getAnimatedProperties)(normalized),
127
- hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null,
128
- hasPerPropertyConfigs = animatedProperties.length > 0,
129
- keys;
130
- if (props.animateOnly ? keys = props.animateOnly : hasPerPropertyConfigs && !hasDefault ? keys = animatedProperties : hasPerPropertyConfigs && hasDefault ? keys = ["all", ...animatedProperties] : keys = ["all"], (0, import_constants.useIsomorphicLayoutEffect)(function () {
251
+ var exitCycleIdRef = import_react.default.useRef(0);
252
+ var exitCompletedRef = import_react.default.useRef(false);
253
+ var wasExitingRef = import_react.default.useRef(false);
254
+ var exitInterruptedRef = import_react.default.useRef(false);
255
+ var justStartedExiting = isExiting && !wasExitingRef.current;
256
+ var justStoppedExiting = !isExiting && wasExitingRef.current;
257
+ if (justStartedExiting) {
258
+ exitCycleIdRef.current++;
259
+ exitCompletedRef.current = false;
260
+ }
261
+ if (justStoppedExiting) {
262
+ exitCycleIdRef.current++;
263
+ exitInterruptedRef.current = true;
264
+ }
265
+ import_react.default.useEffect(function () {
266
+ wasExitingRef.current = isExiting;
267
+ });
268
+ var _styleState_effectiveTransition;
269
+ var effectiveTransition = (_styleState_effectiveTransition = styleState === null || styleState === void 0 ? void 0 : styleState.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition;
270
+ var normalized = (0, import_animation_helpers.normalizeTransition)(effectiveTransition);
271
+ var animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default";
272
+ var effectiveAnimationKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState);
273
+ var defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null;
274
+ var animatedProperties = (0, import_animation_helpers.getAnimatedProperties)(normalized);
275
+ var hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null;
276
+ var hasPerPropertyConfigs = animatedProperties.length > 0;
277
+ var keys;
278
+ if (props.animateOnly) {
279
+ keys = props.animateOnly;
280
+ } else if (hasPerPropertyConfigs && !hasDefault) {
281
+ keys = animatedProperties;
282
+ } else if (hasPerPropertyConfigs && hasDefault) {
283
+ keys = ["all", ...animatedProperties];
284
+ } else {
285
+ keys = ["all"];
286
+ }
287
+ (0, import_constants.useIsomorphicLayoutEffect)(function () {
288
+ var _normalized_config2;
131
289
  var host = stateRef.current.host;
132
- if (!(!sendExitComplete || !isExiting || !host)) {
133
- var node = host,
134
- animationDuration = defaultAnimation ? extractDuration(defaultAnimation) : 200,
135
- _normalized_delay,
136
- delay = (_normalized_delay = normalized.delay) !== null && _normalized_delay !== void 0 ? _normalized_delay : 0,
137
- fallbackTimeout = animationDuration + delay,
138
- timeoutId = setTimeout(function () {
139
- sendExitComplete?.();
140
- }, fallbackTimeout),
141
- onFinishAnimation = function () {
142
- clearTimeout(timeoutId), sendExitComplete?.();
143
- };
144
- return node.addEventListener("transitionend", onFinishAnimation), node.addEventListener("transitioncancel", onFinishAnimation), function () {
145
- clearTimeout(timeoutId), node.removeEventListener("transitionend", onFinishAnimation), node.removeEventListener("transitioncancel", onFinishAnimation);
146
- };
290
+ if (!sendExitComplete || !isExiting || !host) return;
291
+ var node = host;
292
+ var cycleId = exitCycleIdRef.current;
293
+ var completeExit = function () {
294
+ if (cycleId !== exitCycleIdRef.current) return;
295
+ if (exitCompletedRef.current) return;
296
+ exitCompletedRef.current = true;
297
+ sendExitComplete();
298
+ };
299
+ if (keys.length === 0) {
300
+ completeExit();
301
+ return;
302
+ }
303
+ var rafId;
304
+ var wasInterrupted = exitInterruptedRef.current;
305
+ var ignoreCancelEvents = wasInterrupted;
306
+ var enterStyle = props.enterStyle;
307
+ var exitStyle = props.exitStyle;
308
+ var delayStr2 = normalized.delay ? ` ${normalized.delay}ms` : "";
309
+ var durationOverride2 = (_normalized_config2 = normalized.config) === null || _normalized_config2 === void 0 ? void 0 : _normalized_config2.duration;
310
+ var exitTransitionString = keys.map(function (key2) {
311
+ var propAnimation = normalized.properties[key2];
312
+ var animationValue2 = null;
313
+ if (typeof propAnimation === "string") {
314
+ animationValue2 = animations[propAnimation];
315
+ } else if (propAnimation && (typeof propAnimation === "undefined" ? "undefined" : _type_of(propAnimation)) === "object" && propAnimation.type) {
316
+ animationValue2 = animations[propAnimation.type];
317
+ } else if (defaultAnimation) {
318
+ animationValue2 = defaultAnimation;
319
+ }
320
+ if (animationValue2 && durationOverride2) {
321
+ animationValue2 = applyDurationOverride(animationValue2, durationOverride2);
322
+ }
323
+ return animationValue2 ? `${key2} ${animationValue2}${delayStr2}` : null;
324
+ }).filter(Boolean).join(", ");
325
+ if (wasInterrupted) {
326
+ exitInterruptedRef.current = false;
327
+ node.style.transition = "none";
328
+ if (exitStyle) {
329
+ var resetStyle = {};
330
+ var _iteratorNormalCompletion = true,
331
+ _didIteratorError = false,
332
+ _iteratorError = void 0;
333
+ try {
334
+ for (var _iterator = Object.keys(exitStyle)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
335
+ var key = _step.value;
336
+ if (key === "opacity") {
337
+ resetStyle[key] = 1;
338
+ } else if (TRANSFORM_KEYS.includes(key)) {
339
+ resetStyle[key] = key === "scale" || key === "scaleX" || key === "scaleY" ? 1 : 0;
340
+ } else if ((enterStyle === null || enterStyle === void 0 ? void 0 : enterStyle[key]) !== void 0) {
341
+ resetStyle[key] = enterStyle[key];
342
+ }
343
+ }
344
+ } catch (err) {
345
+ _didIteratorError = true;
346
+ _iteratorError = err;
347
+ } finally {
348
+ try {
349
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
350
+ _iterator.return();
351
+ }
352
+ } finally {
353
+ if (_didIteratorError) {
354
+ throw _iteratorError;
355
+ }
356
+ }
357
+ }
358
+ applyStylesToNode(node, resetStyle);
359
+ } else {
360
+ node.style.opacity = "1";
361
+ node.style.transform = "none";
362
+ }
363
+ void node.offsetHeight;
364
+ } else if (exitStyle) {
365
+ ignoreCancelEvents = true;
366
+ node.style.transition = "none";
367
+ var resetStyle1 = {};
368
+ var _iteratorNormalCompletion1 = true,
369
+ _didIteratorError1 = false,
370
+ _iteratorError1 = void 0;
371
+ try {
372
+ for (var _iterator1 = Object.keys(exitStyle)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
373
+ var key1 = _step1.value;
374
+ if (key1 === "opacity") {
375
+ resetStyle1[key1] = 1;
376
+ } else if (TRANSFORM_KEYS.includes(key1)) {
377
+ resetStyle1[key1] = key1 === "scale" || key1 === "scaleX" || key1 === "scaleY" ? 1 : 0;
378
+ } else if ((enterStyle === null || enterStyle === void 0 ? void 0 : enterStyle[key1]) !== void 0) {
379
+ resetStyle1[key1] = enterStyle[key1];
380
+ }
381
+ }
382
+ } catch (err) {
383
+ _didIteratorError1 = true;
384
+ _iteratorError1 = err;
385
+ } finally {
386
+ try {
387
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
388
+ _iterator1.return();
389
+ }
390
+ } finally {
391
+ if (_didIteratorError1) {
392
+ throw _iteratorError1;
393
+ }
394
+ }
395
+ }
396
+ applyStylesToNode(node, resetStyle1);
397
+ void node.offsetHeight;
398
+ rafId = requestAnimationFrame(function () {
399
+ if (cycleId !== exitCycleIdRef.current) return;
400
+ node.style.transition = exitTransitionString;
401
+ void node.offsetHeight;
402
+ applyStylesToNode(node, exitStyle);
403
+ ignoreCancelEvents = false;
404
+ });
405
+ }
406
+ var maxDuration = defaultAnimation ? extractDuration(defaultAnimation) : 200;
407
+ var animationConfigs = (0, import_animation_helpers.getAnimationConfigsForKeys)(normalized, animations, keys, defaultAnimation);
408
+ var _iteratorNormalCompletion2 = true,
409
+ _didIteratorError2 = false,
410
+ _iteratorError2 = void 0;
411
+ try {
412
+ for (var _iterator2 = animationConfigs.values()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
413
+ var animationValue = _step2.value;
414
+ if (animationValue) {
415
+ var duration = extractDuration(animationValue);
416
+ if (duration > maxDuration) {
417
+ maxDuration = duration;
418
+ }
419
+ }
420
+ }
421
+ } catch (err) {
422
+ _didIteratorError2 = true;
423
+ _iteratorError2 = err;
424
+ } finally {
425
+ try {
426
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
427
+ _iterator2.return();
428
+ }
429
+ } finally {
430
+ if (_didIteratorError2) {
431
+ throw _iteratorError2;
432
+ }
433
+ }
434
+ }
435
+ var _normalized_delay;
436
+ var delay = (_normalized_delay = normalized.delay) !== null && _normalized_delay !== void 0 ? _normalized_delay : 0;
437
+ var fallbackTimeout = maxDuration + delay;
438
+ var timeoutId = setTimeout(function () {
439
+ completeExit();
440
+ }, fallbackTimeout);
441
+ var transitioningProps = new Set(keys);
442
+ var completedCount = 0;
443
+ var onFinishAnimation = function (event) {
444
+ if (event.target !== node) return;
445
+ var eventProp = event.propertyName;
446
+ if (transitioningProps.has(eventProp) || eventProp === "all") {
447
+ completedCount++;
448
+ if (completedCount >= transitioningProps.size) {
449
+ clearTimeout(timeoutId);
450
+ completeExit();
451
+ }
452
+ }
453
+ };
454
+ var onCancelAnimation = function () {
455
+ if (ignoreCancelEvents) return;
456
+ clearTimeout(timeoutId);
457
+ completeExit();
458
+ };
459
+ node.addEventListener("transitionend", onFinishAnimation);
460
+ node.addEventListener("transitioncancel", onCancelAnimation);
461
+ if (wasInterrupted) {
462
+ rafId = requestAnimationFrame(function () {
463
+ if (cycleId !== exitCycleIdRef.current) return;
464
+ node.style.transition = exitTransitionString;
465
+ void node.offsetHeight;
466
+ applyStylesToNode(node, exitStyle);
467
+ ignoreCancelEvents = false;
468
+ });
147
469
  }
148
- }, [sendExitComplete, isExiting]), !(0, import_animation_helpers.hasAnimation)(normalized)) return null;
149
- Array.isArray(style.transform) && (style.transform = (0, import_web.transformsToString)(style.transform));
470
+ return function () {
471
+ clearTimeout(timeoutId);
472
+ if (rafId !== void 0) cancelAnimationFrame(rafId);
473
+ node.removeEventListener("transitionend", onFinishAnimation);
474
+ node.removeEventListener("transitioncancel", onCancelAnimation);
475
+ node.style.transition = "";
476
+ };
477
+ }, [sendExitComplete, isExiting, stateRef, keys, normalized, defaultAnimation, props.enterStyle, props.exitStyle]);
478
+ if (isHydrating) {
479
+ return null;
480
+ }
481
+ if (!(0, import_animation_helpers.hasAnimation)(normalized)) {
482
+ return null;
483
+ }
484
+ if (Array.isArray(style.transform)) {
485
+ style.transform = (0, import_web.transformsToString)(style.transform);
486
+ }
150
487
  var delayStr = normalized.delay ? ` ${normalized.delay}ms` : "";
151
- return style.transition = keys.map(function (key) {
152
- var propAnimation = normalized.properties[key],
153
- animationValue = null;
154
- return typeof propAnimation == "string" ? animationValue = animations[propAnimation] : propAnimation && (typeof propAnimation > "u" ? "undefined" : _type_of(propAnimation)) === "object" && propAnimation.type ? animationValue = animations[propAnimation.type] : defaultAnimation && (animationValue = defaultAnimation), animationValue ? `${key} ${animationValue}${delayStr}` : null;
155
- }).filter(Boolean).join(", "), process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info("CSS animation", {
156
- props,
157
- animations,
158
- normalized,
159
- defaultAnimation,
160
- style,
161
- isEntering,
162
- isExiting
163
- }), {
488
+ var durationOverride = (_normalized_config = normalized.config) === null || _normalized_config === void 0 ? void 0 : _normalized_config.duration;
489
+ style.transition = keys.map(function (key) {
490
+ var propAnimation = normalized.properties[key];
491
+ var animationValue = null;
492
+ if (typeof propAnimation === "string") {
493
+ animationValue = animations[propAnimation];
494
+ } else if (propAnimation && (typeof propAnimation === "undefined" ? "undefined" : _type_of(propAnimation)) === "object" && propAnimation.type) {
495
+ animationValue = animations[propAnimation.type];
496
+ } else if (defaultAnimation) {
497
+ animationValue = defaultAnimation;
498
+ }
499
+ if (animationValue && durationOverride) {
500
+ animationValue = applyDurationOverride(animationValue, durationOverride);
501
+ }
502
+ return animationValue ? `${key} ${animationValue}${delayStr}` : null;
503
+ }).filter(Boolean).join(", ");
504
+ if (process.env.NODE_ENV === "development" && props["debug"] === "verbose") {
505
+ console.info("CSS animation", {
506
+ props,
507
+ animations,
508
+ normalized,
509
+ defaultAnimation,
510
+ style,
511
+ isEntering,
512
+ isExiting
513
+ });
514
+ }
515
+ return {
164
516
  style,
165
517
  className: isEntering ? "t_unmounted" : ""
166
518
  };