@tamagui/animations-css 2.0.0-rc.35 → 2.0.0-rc.36-1775243248161

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.
@@ -2,80 +2,130 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
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: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
32
34
  var createAnimations_exports = {};
33
35
  __export(createAnimations_exports, {
34
36
  createAnimations: () => createAnimations
35
37
  });
36
38
  module.exports = __toCommonJS(createAnimations_exports);
37
- var import_animation_helpers = require("@tamagui/animation-helpers"),
38
- import_constants = require("@tamagui/constants"),
39
- import_use_presence = require("@tamagui/use-presence"),
40
- import_web = require("@tamagui/web"),
41
- import_react = __toESM(require("react"), 1);
42
- const EXTRACT_MS_REGEX = /(\d+(?:\.\d+)?)\s*ms/,
43
- EXTRACT_S_REGEX = /(\d+(?:\.\d+)?)\s*s/;
39
+ var import_animation_helpers = require("@tamagui/animation-helpers");
40
+ var import_constants = require("@tamagui/constants");
41
+ var import_use_presence = require("@tamagui/use-presence");
42
+ var import_web = require("@tamagui/web");
43
+ var import_react = __toESM(require("react"), 1);
44
+ const EXTRACT_MS_REGEX = /(\d+(?:\.\d+)?)\s*ms/;
45
+ const EXTRACT_S_REGEX = /(\d+(?:\.\d+)?)\s*s/;
44
46
  function extractDuration(animation) {
45
47
  const msMatch = animation.match(EXTRACT_MS_REGEX);
46
- if (msMatch) return Number.parseInt(msMatch[1], 10);
48
+ if (msMatch) {
49
+ return Number.parseInt(msMatch[1], 10);
50
+ }
47
51
  const sMatch = animation.match(EXTRACT_S_REGEX);
48
- return sMatch ? Math.round(Number.parseFloat(sMatch[1]) * 1e3) : 300;
52
+ if (sMatch) {
53
+ return Math.round(Number.parseFloat(sMatch[1]) * 1e3);
54
+ }
55
+ return 300;
49
56
  }
50
- const MS_DURATION_REGEX = /(\d+(?:\.\d+)?)\s*ms/,
51
- S_DURATION_REGEX = /(\d+(?:\.\d+)?)\s*s(?!tiffness)/;
57
+ const MS_DURATION_REGEX = /(\d+(?:\.\d+)?)\s*ms/;
58
+ const S_DURATION_REGEX = /(\d+(?:\.\d+)?)\s*s(?!tiffness)/;
52
59
  function applyDurationOverride(animation, durationMs) {
53
60
  const msReplaced = animation.replace(MS_DURATION_REGEX, `${durationMs}ms`);
54
- if (msReplaced !== animation) return msReplaced;
61
+ if (msReplaced !== animation) {
62
+ return msReplaced;
63
+ }
55
64
  const sReplaced = animation.replace(S_DURATION_REGEX, `${durationMs}ms`);
56
- return sReplaced !== animation ? sReplaced : `${durationMs}ms ${animation}`;
65
+ if (sReplaced !== animation) {
66
+ return sReplaced;
67
+ }
68
+ return `${durationMs}ms ${animation}`;
57
69
  }
58
70
  const TRANSFORM_KEYS = ["x", "y", "scale", "scaleX", "scaleY", "rotate", "rotateX", "rotateY", "rotateZ", "skewX", "skewY"];
59
71
  function buildTransformString(style) {
60
72
  if (!style) return "";
61
73
  const parts = [];
62
74
  if (style.x !== void 0 || style.y !== void 0) {
63
- const x = style.x ?? 0,
64
- y = style.y ?? 0;
75
+ const x = style.x ?? 0;
76
+ const y = style.y ?? 0;
65
77
  parts.push(`translate(${x}px, ${y}px)`);
66
78
  }
67
- if (style.scale !== void 0 && parts.push(`scale(${style.scale})`), style.scaleX !== void 0 && parts.push(`scaleX(${style.scaleX})`), style.scaleY !== void 0 && parts.push(`scaleY(${style.scaleY})`), style.rotate !== void 0) {
68
- const val = style.rotate,
69
- unit = typeof val == "string" && val.includes("deg") ? "" : "deg";
79
+ if (style.scale !== void 0) {
80
+ parts.push(`scale(${style.scale})`);
81
+ }
82
+ if (style.scaleX !== void 0) {
83
+ parts.push(`scaleX(${style.scaleX})`);
84
+ }
85
+ if (style.scaleY !== void 0) {
86
+ parts.push(`scaleY(${style.scaleY})`);
87
+ }
88
+ if (style.rotate !== void 0) {
89
+ const val = style.rotate;
90
+ const unit = typeof val === "string" && val.includes("deg") ? "" : "deg";
70
91
  parts.push(`rotate(${val}${unit})`);
71
92
  }
72
- return style.rotateX !== void 0 && parts.push(`rotateX(${style.rotateX}deg)`), style.rotateY !== void 0 && parts.push(`rotateY(${style.rotateY}deg)`), style.rotateZ !== void 0 && parts.push(`rotateZ(${style.rotateZ}deg)`), style.skewX !== void 0 && parts.push(`skewX(${style.skewX}deg)`), style.skewY !== void 0 && parts.push(`skewY(${style.skewY}deg)`), parts.join(" ");
93
+ if (style.rotateX !== void 0) {
94
+ parts.push(`rotateX(${style.rotateX}deg)`);
95
+ }
96
+ if (style.rotateY !== void 0) {
97
+ parts.push(`rotateY(${style.rotateY}deg)`);
98
+ }
99
+ if (style.rotateZ !== void 0) {
100
+ parts.push(`rotateZ(${style.rotateZ}deg)`);
101
+ }
102
+ if (style.skewX !== void 0) {
103
+ parts.push(`skewX(${style.skewX}deg)`);
104
+ }
105
+ if (style.skewY !== void 0) {
106
+ parts.push(`skewY(${style.skewY}deg)`);
107
+ }
108
+ return parts.join(" ");
73
109
  }
74
110
  function applyStylesToNode(node, style) {
75
111
  if (!style) return;
76
112
  const transformStr = buildTransformString(style);
77
- transformStr && (node.style.transform = transformStr);
78
- for (const [key, value] of Object.entries(style)) TRANSFORM_KEYS.includes(key) || value !== void 0 && (key === "opacity" ? node.style.opacity = String(value) : key === "backgroundColor" ? node.style.backgroundColor = String(value) : key === "color" ? node.style.color = String(value) : node.style[key] = typeof value == "number" ? `${value}px` : String(value));
113
+ if (transformStr) {
114
+ node.style.transform = transformStr;
115
+ }
116
+ for (const [key, value] of Object.entries(style)) {
117
+ if (TRANSFORM_KEYS.includes(key)) continue;
118
+ if (value === void 0) continue;
119
+ if (key === "opacity") {
120
+ node.style.opacity = String(value);
121
+ } else if (key === "backgroundColor") {
122
+ node.style.backgroundColor = String(value);
123
+ } else if (key === "color") {
124
+ node.style.color = String(value);
125
+ } else {
126
+ node.style[key] = typeof value === "number" ? `${value}px` : String(value);
127
+ }
128
+ }
79
129
  }
80
130
  function createAnimations(animations) {
81
131
  const reactionListeners = /* @__PURE__ */new WeakMap();
@@ -86,8 +136,8 @@ function createAnimations(animations) {
86
136
  inputStyle: "css",
87
137
  outputStyle: "css",
88
138
  useAnimatedNumber(initial) {
89
- const [val, setVal] = import_react.default.useState(initial),
90
- finishTimerRef = import_react.default.useRef(null);
139
+ const [val, setVal] = import_react.default.useState(initial);
140
+ const finishTimerRef = import_react.default.useRef(null);
91
141
  return {
92
142
  getInstance() {
93
143
  return setVal;
@@ -96,15 +146,29 @@ function createAnimations(animations) {
96
146
  return val;
97
147
  },
98
148
  setValue(next, config, onFinish) {
99
- if (setVal(next), finishTimerRef.current && (clearTimeout(finishTimerRef.current), finishTimerRef.current = null), onFinish) if (!config || config.type === "direct" || config.type === "timing" && config.duration === 0) onFinish();else {
100
- const duration = config.type === "timing" ? config.duration : 300;
101
- finishTimerRef.current = setTimeout(onFinish, duration);
149
+ setVal(next);
150
+ if (finishTimerRef.current) {
151
+ clearTimeout(finishTimerRef.current);
152
+ finishTimerRef.current = null;
153
+ }
154
+ if (onFinish) {
155
+ if (!config || config.type === "direct" || config.type === "timing" && config.duration === 0) {
156
+ onFinish();
157
+ } else {
158
+ const duration = config.type === "timing" ? config.duration : 300;
159
+ finishTimerRef.current = setTimeout(onFinish, duration);
160
+ }
102
161
  }
103
162
  const listeners = reactionListeners.get(setVal);
104
- listeners && listeners.forEach(listener => listener(next));
163
+ if (listeners) {
164
+ listeners.forEach(listener => listener(next));
165
+ }
105
166
  },
106
167
  stop() {
107
- finishTimerRef.current && (clearTimeout(finishTimerRef.current), finishTimerRef.current = null);
168
+ if (finishTimerRef.current) {
169
+ clearTimeout(finishTimerRef.current);
170
+ finishTimerRef.current = null;
171
+ }
108
172
  }
109
173
  };
110
174
  },
@@ -116,9 +180,11 @@ function createAnimations(animations) {
116
180
  let queue = reactionListeners.get(instance);
117
181
  if (!queue) {
118
182
  const next = /* @__PURE__ */new Set();
119
- reactionListeners.set(instance, next), queue = next;
183
+ reactionListeners.set(instance, next);
184
+ queue = next;
120
185
  }
121
- return queue.add(onValue), () => {
186
+ queue.add(onValue);
187
+ return () => {
122
188
  queue?.delete(onValue);
123
189
  };
124
190
  }, []);
@@ -138,40 +204,61 @@ function createAnimations(animations) {
138
204
  stateRef,
139
205
  styleState
140
206
  }) => {
141
- const isHydrating = componentState.unmounted === !0,
142
- isEntering = !!componentState.unmounted,
143
- isExiting = presence?.[0] === !1,
144
- sendExitComplete = presence?.[1],
145
- wasEnteringRef = import_react.default.useRef(isEntering),
146
- justFinishedEntering = wasEnteringRef.current && !isEntering;
207
+ const isHydrating = componentState.unmounted === true;
208
+ const isEntering = !!componentState.unmounted;
209
+ const isExiting = presence?.[0] === false;
210
+ const sendExitComplete = presence?.[1];
211
+ const wasEnteringRef = import_react.default.useRef(isEntering);
212
+ const justFinishedEntering = wasEnteringRef.current && !isEntering;
147
213
  import_react.default.useEffect(() => {
148
214
  wasEnteringRef.current = isEntering;
149
215
  });
150
- const exitCycleIdRef = import_react.default.useRef(0),
151
- exitCompletedRef = import_react.default.useRef(!1),
152
- wasExitingRef = import_react.default.useRef(!1),
153
- exitInterruptedRef = import_react.default.useRef(!1),
154
- justStartedExiting = isExiting && !wasExitingRef.current,
155
- justStoppedExiting = !isExiting && wasExitingRef.current;
156
- justStartedExiting && (exitCycleIdRef.current++, exitCompletedRef.current = !1), justStoppedExiting && (exitCycleIdRef.current++, exitInterruptedRef.current = !0), import_react.default.useEffect(() => {
216
+ const exitCycleIdRef = import_react.default.useRef(0);
217
+ const exitCompletedRef = import_react.default.useRef(false);
218
+ const wasExitingRef = import_react.default.useRef(false);
219
+ const exitInterruptedRef = import_react.default.useRef(false);
220
+ const justStartedExiting = isExiting && !wasExitingRef.current;
221
+ const justStoppedExiting = !isExiting && wasExitingRef.current;
222
+ if (justStartedExiting) {
223
+ exitCycleIdRef.current++;
224
+ exitCompletedRef.current = false;
225
+ }
226
+ if (justStoppedExiting) {
227
+ exitCycleIdRef.current++;
228
+ exitInterruptedRef.current = true;
229
+ }
230
+ import_react.default.useEffect(() => {
157
231
  wasExitingRef.current = isExiting;
158
232
  });
159
- const effectiveTransition = styleState?.effectiveTransition ?? props.transition,
160
- normalized = (0, import_animation_helpers.normalizeTransition)(effectiveTransition),
161
- effectiveAnimationKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default"),
162
- defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null,
163
- animatedProperties = (0, import_animation_helpers.getAnimatedProperties)(normalized),
164
- hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null,
165
- hasPerPropertyConfigs = animatedProperties.length > 0;
233
+ const effectiveTransition = styleState?.effectiveTransition ?? props.transition;
234
+ const normalized = (0, import_animation_helpers.normalizeTransition)(effectiveTransition);
235
+ const animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default";
236
+ const effectiveAnimationKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState);
237
+ const defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null;
238
+ const animatedProperties = (0, import_animation_helpers.getAnimatedProperties)(normalized);
239
+ const hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null;
240
+ const hasPerPropertyConfigs = animatedProperties.length > 0;
166
241
  let keys;
167
- if (props.animateOnly ? keys = props.animateOnly : hasPerPropertyConfigs && !hasDefault ? keys = animatedProperties : hasPerPropertyConfigs && hasDefault ? keys = ["all", ...animatedProperties] : keys = ["all"], (0, import_constants.useIsomorphicLayoutEffect)(() => {
242
+ if (props.animateOnly) {
243
+ keys = props.animateOnly;
244
+ } else if (hasPerPropertyConfigs && !hasDefault) {
245
+ keys = animatedProperties;
246
+ } else if (hasPerPropertyConfigs && hasDefault) {
247
+ keys = ["all", ...animatedProperties];
248
+ } else {
249
+ keys = ["all"];
250
+ }
251
+ (0, import_constants.useIsomorphicLayoutEffect)(() => {
168
252
  const host = stateRef.current.host;
169
253
  if (!sendExitComplete || !isExiting || !host) return;
170
- const node = host,
171
- cycleId = exitCycleIdRef.current,
172
- completeExit = () => {
173
- cycleId === exitCycleIdRef.current && (exitCompletedRef.current || (exitCompletedRef.current = !0, sendExitComplete()));
174
- };
254
+ const node = host;
255
+ const cycleId = exitCycleIdRef.current;
256
+ const completeExit = () => {
257
+ if (cycleId !== exitCycleIdRef.current) return;
258
+ if (exitCompletedRef.current) return;
259
+ exitCompletedRef.current = true;
260
+ sendExitComplete();
261
+ };
175
262
  if (keys.length === 0) {
176
263
  completeExit();
177
264
  return;
@@ -179,73 +266,158 @@ function createAnimations(animations) {
179
266
  let rafId;
180
267
  const wasInterrupted = exitInterruptedRef.current;
181
268
  let ignoreCancelEvents = wasInterrupted;
182
- const enterStyle = props.enterStyle,
183
- exitStyle = props.exitStyle,
184
- delayStr2 = normalized.delay ? ` ${normalized.delay}ms` : "",
185
- durationOverride2 = normalized.config?.duration,
186
- exitTransitionString = keys.map(key => {
187
- const propAnimation = normalized.properties[key];
188
- let animationValue = null;
189
- return typeof propAnimation == "string" ? animationValue = animations[propAnimation] : propAnimation && typeof propAnimation == "object" && propAnimation.type ? animationValue = animations[propAnimation.type] : defaultAnimation && (animationValue = defaultAnimation), animationValue && durationOverride2 && (animationValue = applyDurationOverride(animationValue, durationOverride2)), animationValue ? `${key} ${animationValue}${delayStr2}` : null;
190
- }).filter(Boolean).join(", ");
269
+ const enterStyle = props.enterStyle;
270
+ const exitStyle = props.exitStyle;
271
+ const delayStr2 = normalized.delay ? ` ${normalized.delay}ms` : "";
272
+ const durationOverride2 = normalized.config?.duration;
273
+ const exitTransitionString = keys.map(key => {
274
+ const propAnimation = normalized.properties[key];
275
+ let animationValue = null;
276
+ if (typeof propAnimation === "string") {
277
+ animationValue = animations[propAnimation];
278
+ } else if (propAnimation && typeof propAnimation === "object" && propAnimation.type) {
279
+ animationValue = animations[propAnimation.type];
280
+ } else if (defaultAnimation) {
281
+ animationValue = defaultAnimation;
282
+ }
283
+ if (animationValue && durationOverride2) {
284
+ animationValue = applyDurationOverride(animationValue, durationOverride2);
285
+ }
286
+ return animationValue ? `${key} ${animationValue}${delayStr2}` : null;
287
+ }).filter(Boolean).join(", ");
191
288
  if (wasInterrupted) {
192
- if (exitInterruptedRef.current = !1, node.style.transition = "none", exitStyle) {
289
+ exitInterruptedRef.current = false;
290
+ node.style.transition = "none";
291
+ if (exitStyle) {
193
292
  const resetStyle = {};
194
- for (const key of Object.keys(exitStyle)) key === "opacity" ? resetStyle[key] = 1 : TRANSFORM_KEYS.includes(key) ? resetStyle[key] = key === "scale" || key === "scaleX" || key === "scaleY" ? 1 : 0 : enterStyle?.[key] !== void 0 && (resetStyle[key] = enterStyle[key]);
293
+ for (const key of Object.keys(exitStyle)) {
294
+ if (key === "opacity") {
295
+ resetStyle[key] = 1;
296
+ } else if (TRANSFORM_KEYS.includes(key)) {
297
+ resetStyle[key] = key === "scale" || key === "scaleX" || key === "scaleY" ? 1 : 0;
298
+ } else if (enterStyle?.[key] !== void 0) {
299
+ resetStyle[key] = enterStyle[key];
300
+ }
301
+ }
195
302
  applyStylesToNode(node, resetStyle);
196
- } else node.style.opacity = "1", node.style.transform = "none";
197
- node.offsetHeight;
303
+ } else {
304
+ node.style.opacity = "1";
305
+ node.style.transform = "none";
306
+ }
307
+ void node.offsetHeight;
198
308
  } else if (exitStyle) {
199
- ignoreCancelEvents = !0, node.style.transition = "none";
309
+ ignoreCancelEvents = true;
310
+ node.style.transition = "none";
200
311
  const resetStyle = {};
201
- for (const key of Object.keys(exitStyle)) key === "opacity" ? resetStyle[key] = 1 : TRANSFORM_KEYS.includes(key) ? resetStyle[key] = key === "scale" || key === "scaleX" || key === "scaleY" ? 1 : 0 : enterStyle?.[key] !== void 0 && (resetStyle[key] = enterStyle[key]);
202
- applyStylesToNode(node, resetStyle), node.offsetHeight, rafId = requestAnimationFrame(() => {
203
- cycleId === exitCycleIdRef.current && (node.style.transition = exitTransitionString, node.offsetHeight, applyStylesToNode(node, exitStyle), ignoreCancelEvents = !1);
312
+ for (const key of Object.keys(exitStyle)) {
313
+ if (key === "opacity") {
314
+ resetStyle[key] = 1;
315
+ } else if (TRANSFORM_KEYS.includes(key)) {
316
+ resetStyle[key] = key === "scale" || key === "scaleX" || key === "scaleY" ? 1 : 0;
317
+ } else if (enterStyle?.[key] !== void 0) {
318
+ resetStyle[key] = enterStyle[key];
319
+ }
320
+ }
321
+ applyStylesToNode(node, resetStyle);
322
+ void node.offsetHeight;
323
+ rafId = requestAnimationFrame(() => {
324
+ if (cycleId !== exitCycleIdRef.current) return;
325
+ node.style.transition = exitTransitionString;
326
+ void node.offsetHeight;
327
+ applyStylesToNode(node, exitStyle);
328
+ ignoreCancelEvents = false;
204
329
  });
205
330
  }
206
331
  let maxDuration = defaultAnimation ? extractDuration(defaultAnimation) : 200;
207
332
  const animationConfigs = (0, import_animation_helpers.getAnimationConfigsForKeys)(normalized, animations, keys, defaultAnimation);
208
- for (const animationValue of animationConfigs.values()) if (animationValue) {
209
- const duration = extractDuration(animationValue);
210
- duration > maxDuration && (maxDuration = duration);
333
+ for (const animationValue of animationConfigs.values()) {
334
+ if (animationValue) {
335
+ const duration = extractDuration(animationValue);
336
+ if (duration > maxDuration) {
337
+ maxDuration = duration;
338
+ }
339
+ }
211
340
  }
212
- const delay = normalized.delay ?? 0,
213
- fallbackTimeout = maxDuration + delay,
214
- timeoutId = setTimeout(() => {
215
- completeExit();
216
- }, fallbackTimeout),
217
- transitioningProps = new Set(keys);
341
+ const delay = normalized.delay ?? 0;
342
+ const fallbackTimeout = maxDuration + delay;
343
+ const timeoutId = setTimeout(() => {
344
+ completeExit();
345
+ }, fallbackTimeout);
346
+ const transitioningProps = new Set(keys);
218
347
  let completedCount = 0;
219
348
  const onFinishAnimation = event => {
220
- if (event.target !== node) return;
221
- const eventProp = event.propertyName;
222
- (transitioningProps.has(eventProp) || eventProp === "all") && (completedCount++, completedCount >= transitioningProps.size && (clearTimeout(timeoutId), completeExit()));
223
- },
224
- onCancelAnimation = () => {
225
- ignoreCancelEvents || (clearTimeout(timeoutId), completeExit());
226
- };
227
- return node.addEventListener("transitionend", onFinishAnimation), node.addEventListener("transitioncancel", onCancelAnimation), wasInterrupted && (rafId = requestAnimationFrame(() => {
228
- cycleId === exitCycleIdRef.current && (node.style.transition = exitTransitionString, node.offsetHeight, applyStylesToNode(node, exitStyle), ignoreCancelEvents = !1);
229
- })), () => {
230
- clearTimeout(timeoutId), rafId !== void 0 && cancelAnimationFrame(rafId), node.removeEventListener("transitionend", onFinishAnimation), node.removeEventListener("transitioncancel", onCancelAnimation), node.style.transition = "";
349
+ if (event.target !== node) return;
350
+ const eventProp = event.propertyName;
351
+ if (transitioningProps.has(eventProp) || eventProp === "all") {
352
+ completedCount++;
353
+ if (completedCount >= transitioningProps.size) {
354
+ clearTimeout(timeoutId);
355
+ completeExit();
356
+ }
357
+ }
231
358
  };
232
- }, [sendExitComplete, isExiting, stateRef, keys, normalized, defaultAnimation, props.enterStyle, props.exitStyle]), isHydrating || !(0, import_animation_helpers.hasAnimation)(normalized)) return null;
233
- Array.isArray(style.transform) && (style.transform = (0, import_web.transformsToString)(style.transform));
234
- const delayStr = normalized.delay ? ` ${normalized.delay}ms` : "",
235
- durationOverride = normalized.config?.duration;
236
- return style.transition = keys.map(key => {
359
+ const onCancelAnimation = () => {
360
+ if (ignoreCancelEvents) return;
361
+ clearTimeout(timeoutId);
362
+ completeExit();
363
+ };
364
+ node.addEventListener("transitionend", onFinishAnimation);
365
+ node.addEventListener("transitioncancel", onCancelAnimation);
366
+ if (wasInterrupted) {
367
+ rafId = requestAnimationFrame(() => {
368
+ if (cycleId !== exitCycleIdRef.current) return;
369
+ node.style.transition = exitTransitionString;
370
+ void node.offsetHeight;
371
+ applyStylesToNode(node, exitStyle);
372
+ ignoreCancelEvents = false;
373
+ });
374
+ }
375
+ return () => {
376
+ clearTimeout(timeoutId);
377
+ if (rafId !== void 0) cancelAnimationFrame(rafId);
378
+ node.removeEventListener("transitionend", onFinishAnimation);
379
+ node.removeEventListener("transitioncancel", onCancelAnimation);
380
+ node.style.transition = "";
381
+ };
382
+ }, [sendExitComplete, isExiting, stateRef, keys, normalized, defaultAnimation, props.enterStyle, props.exitStyle]);
383
+ if (isHydrating) {
384
+ return null;
385
+ }
386
+ if (!(0, import_animation_helpers.hasAnimation)(normalized)) {
387
+ return null;
388
+ }
389
+ if (Array.isArray(style.transform)) {
390
+ style.transform = (0, import_web.transformsToString)(style.transform);
391
+ }
392
+ const delayStr = normalized.delay ? ` ${normalized.delay}ms` : "";
393
+ const durationOverride = normalized.config?.duration;
394
+ style.transition = keys.map(key => {
237
395
  const propAnimation = normalized.properties[key];
238
396
  let animationValue = null;
239
- return typeof propAnimation == "string" ? animationValue = animations[propAnimation] : propAnimation && typeof propAnimation == "object" && propAnimation.type ? animationValue = animations[propAnimation.type] : defaultAnimation && (animationValue = defaultAnimation), animationValue && durationOverride && (animationValue = applyDurationOverride(animationValue, durationOverride)), animationValue ? `${key} ${animationValue}${delayStr}` : null;
240
- }).filter(Boolean).join(", "), process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info("CSS animation", {
241
- props,
242
- animations,
243
- normalized,
244
- defaultAnimation,
245
- style,
246
- isEntering,
247
- isExiting
248
- }), {
397
+ if (typeof propAnimation === "string") {
398
+ animationValue = animations[propAnimation];
399
+ } else if (propAnimation && typeof propAnimation === "object" && propAnimation.type) {
400
+ animationValue = animations[propAnimation.type];
401
+ } else if (defaultAnimation) {
402
+ animationValue = defaultAnimation;
403
+ }
404
+ if (animationValue && durationOverride) {
405
+ animationValue = applyDurationOverride(animationValue, durationOverride);
406
+ }
407
+ return animationValue ? `${key} ${animationValue}${delayStr}` : null;
408
+ }).filter(Boolean).join(", ");
409
+ if (process.env.NODE_ENV === "development" && props["debug"] === "verbose") {
410
+ console.info("CSS animation", {
411
+ props,
412
+ animations,
413
+ normalized,
414
+ defaultAnimation,
415
+ style,
416
+ isEntering,
417
+ isExiting
418
+ });
419
+ }
420
+ return {
249
421
  style,
250
422
  className: isEntering ? "t_unmounted" : ""
251
423
  };