@hanzogui/animations-css 3.0.6 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,101 +4,153 @@ 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("@hanzogui/animation-helpers"),
40
- import_constants = require("@hanzogui/constants"),
41
- import_use_presence = require("@hanzogui/use-presence"),
42
- import_web = require("@hanzogui/web"),
43
- import_react = __toESM(require("react"), 1);
41
+ var import_animation_helpers = require("@hanzogui/animation-helpers");
42
+ var import_constants = require("@hanzogui/constants");
43
+ var import_use_presence = require("@hanzogui/use-presence");
44
+ var import_web = require("@hanzogui/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
  }
49
- var EXTRACT_MS_REGEX = /(\d+(?:\.\d+)?)\s*ms/,
50
- EXTRACT_S_REGEX = /(\d+(?:\.\d+)?)\s*s/;
51
+ var EXTRACT_MS_REGEX = /(\d+(?:\.\d+)?)\s*ms/;
52
+ var EXTRACT_S_REGEX = /(\d+(?:\.\d+)?)\s*s/;
51
53
  function extractDuration(animation) {
52
54
  var msMatch = animation.match(EXTRACT_MS_REGEX);
53
- if (msMatch) return Number.parseInt(msMatch[1], 10);
55
+ if (msMatch) {
56
+ return Number.parseInt(msMatch[1], 10);
57
+ }
54
58
  var sMatch = animation.match(EXTRACT_S_REGEX);
55
- return sMatch ? Math.round(Number.parseFloat(sMatch[1]) * 1e3) : 300;
59
+ if (sMatch) {
60
+ return Math.round(Number.parseFloat(sMatch[1]) * 1e3);
61
+ }
62
+ return 300;
56
63
  }
57
- var MS_DURATION_REGEX = /(\d+(?:\.\d+)?)\s*ms/,
58
- S_DURATION_REGEX = /(\d+(?:\.\d+)?)\s*s(?!tiffness)/;
64
+ var MS_DURATION_REGEX = /(\d+(?:\.\d+)?)\s*ms/;
65
+ var S_DURATION_REGEX = /(\d+(?:\.\d+)?)\s*s(?!tiffness)/;
59
66
  function applyDurationOverride(animation, durationMs) {
60
67
  var msReplaced = animation.replace(MS_DURATION_REGEX, `${durationMs}ms`);
61
- if (msReplaced !== animation) return msReplaced;
68
+ if (msReplaced !== animation) {
69
+ return msReplaced;
70
+ }
62
71
  var sReplaced = animation.replace(S_DURATION_REGEX, `${durationMs}ms`);
63
- return sReplaced !== animation ? sReplaced : `${durationMs}ms ${animation}`;
72
+ if (sReplaced !== animation) {
73
+ return sReplaced;
74
+ }
75
+ return `${durationMs}ms ${animation}`;
64
76
  }
65
77
  var TRANSFORM_KEYS = ["x", "y", "scale", "scaleX", "scaleY", "rotate", "rotateX", "rotateY", "rotateZ", "skewX", "skewY"];
66
78
  function buildTransformString(style) {
67
79
  if (!style) return "";
68
80
  var parts = [];
69
81
  if (style.x !== void 0 || style.y !== void 0) {
70
- var _style_x,
71
- x = (_style_x = style.x) !== null && _style_x !== void 0 ? _style_x : 0,
72
- _style_y,
73
- y = (_style_y = style.y) !== null && _style_y !== void 0 ? _style_y : 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;
74
86
  parts.push(`translate(${x}px, ${y}px)`);
75
87
  }
76
- 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) {
77
- var val = style.rotate,
78
- unit = typeof val == "string" && val.includes("deg") ? "" : "deg";
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";
79
100
  parts.push(`rotate(${val}${unit})`);
80
101
  }
81
- 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(" ");
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(" ");
82
118
  }
83
119
  function applyStylesToNode(node, style) {
84
- if (style) {
85
- var transformStr = buildTransformString(style);
86
- transformStr && (node.style.transform = transformStr);
87
- var _iteratorNormalCompletion = !0,
88
- _didIteratorError = !1,
89
- _iteratorError = void 0;
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 {
90
147
  try {
91
- for (var _iterator = Object.entries(style)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
92
- var [key, value] = _step.value;
93
- 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));
148
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
149
+ _iterator.return();
94
150
  }
95
- } catch (err) {
96
- _didIteratorError = !0, _iteratorError = err;
97
151
  } finally {
98
- try {
99
- !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
100
- } finally {
101
- if (_didIteratorError) throw _iteratorError;
152
+ if (_didIteratorError) {
153
+ throw _iteratorError;
102
154
  }
103
155
  }
104
156
  }
@@ -112,8 +164,8 @@ function createAnimations(animations) {
112
164
  inputStyle: "css",
113
165
  outputStyle: "css",
114
166
  useAnimatedNumber(initial) {
115
- var [val, setVal] = import_react.default.useState(initial),
116
- finishTimerRef = import_react.default.useRef(null);
167
+ var [val, setVal] = import_react.default.useState(initial);
168
+ var finishTimerRef = import_react.default.useRef(null);
117
169
  return {
118
170
  getInstance() {
119
171
  return setVal;
@@ -122,17 +174,31 @@ function createAnimations(animations) {
122
174
  return val;
123
175
  },
124
176
  setValue(next, config, onFinish) {
125
- 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 {
126
- var duration = config.type === "timing" ? config.duration : 300;
127
- finishTimerRef.current = setTimeout(onFinish, duration);
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
+ }
128
189
  }
129
190
  var listeners = reactionListeners.get(setVal);
130
- listeners && listeners.forEach(function (listener) {
131
- return listener(next);
132
- });
191
+ if (listeners) {
192
+ listeners.forEach(function (listener) {
193
+ return listener(next);
194
+ });
195
+ }
133
196
  },
134
197
  stop() {
135
- finishTimerRef.current && (clearTimeout(finishTimerRef.current), finishTimerRef.current = null);
198
+ if (finishTimerRef.current) {
199
+ clearTimeout(finishTimerRef.current);
200
+ finishTimerRef.current = null;
201
+ }
136
202
  }
137
203
  };
138
204
  },
@@ -141,193 +207,312 @@ function createAnimations(animations) {
141
207
  value
142
208
  } = param;
143
209
  import_react.default.useEffect(function () {
144
- var instance = value.getInstance(),
145
- queue = reactionListeners.get(instance);
210
+ var instance = value.getInstance();
211
+ var queue = reactionListeners.get(instance);
146
212
  if (!queue) {
147
213
  var next = /* @__PURE__ */new Set();
148
- reactionListeners.set(instance, next), queue = next;
214
+ reactionListeners.set(instance, next);
215
+ queue = next;
149
216
  }
150
- return queue.add(onValue), function () {
151
- queue?.delete(onValue);
217
+ queue.add(onValue);
218
+ return function () {
219
+ queue === null || queue === void 0 ? void 0 : queue.delete(onValue);
152
220
  };
153
221
  }, []);
154
222
  },
155
223
  useAnimatedNumberStyle(val, getStyle) {
156
224
  return getStyle(val.getValue());
157
225
  },
226
+ useAnimatedNumbersStyle(vals, getStyle) {
227
+ return getStyle(...vals.map(function (v) {
228
+ return v.getValue();
229
+ }));
230
+ },
158
231
  // @ts-ignore - styleState is added by createComponent
159
232
  useAnimations: function (param) {
160
233
  var {
161
- props,
162
- presence,
163
- style,
164
- componentState,
165
- stateRef,
166
- styleState
167
- } = param,
168
- _normalized_config,
169
- isHydrating = componentState.unmounted === !0,
170
- isEntering = !!componentState.unmounted,
171
- isExiting = presence?.[0] === !1,
172
- sendExitComplete = presence?.[1],
173
- wasEnteringRef = import_react.default.useRef(isEntering),
174
- 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;
175
248
  import_react.default.useEffect(function () {
176
249
  wasEnteringRef.current = isEntering;
177
250
  });
178
- var exitCycleIdRef = import_react.default.useRef(0),
179
- exitCompletedRef = import_react.default.useRef(!1),
180
- wasExitingRef = import_react.default.useRef(!1),
181
- exitInterruptedRef = import_react.default.useRef(!1),
182
- justStartedExiting = isExiting && !wasExitingRef.current,
183
- justStoppedExiting = !isExiting && wasExitingRef.current;
184
- justStartedExiting && (exitCycleIdRef.current++, exitCompletedRef.current = !1), justStoppedExiting && (exitCycleIdRef.current++, exitInterruptedRef.current = !0), import_react.default.useEffect(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 () {
185
266
  wasExitingRef.current = isExiting;
186
267
  });
187
- var _styleState_effectiveTransition,
188
- effectiveTransition = (_styleState_effectiveTransition = styleState?.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition,
189
- normalized = (0, import_animation_helpers.normalizeTransition)(effectiveTransition),
190
- animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default",
191
- effectiveAnimationKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState),
192
- defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null,
193
- animatedProperties = (0, import_animation_helpers.getAnimatedProperties)(normalized),
194
- hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null,
195
- hasPerPropertyConfigs = animatedProperties.length > 0,
196
- keys;
197
- if (props.animateOnly ? keys = props.animateOnly : hasPerPropertyConfigs && !hasDefault ? keys = animatedProperties : hasPerPropertyConfigs && hasDefault ? keys = ["all", ...animatedProperties] : keys = ["all"], (0, import_constants.useIsomorphicLayoutEffect)(function () {
198
- var _normalized_config2,
199
- host = stateRef.current.host;
200
- if (!(!sendExitComplete || !isExiting || !host)) {
201
- var node = host,
202
- cycleId = exitCycleIdRef.current,
203
- completeExit = function () {
204
- cycleId === exitCycleIdRef.current && (exitCompletedRef.current || (exitCompletedRef.current = !0, sendExitComplete()));
205
- };
206
- if (keys.length === 0) {
207
- completeExit();
208
- return;
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;
289
+ var host = stateRef.current.host;
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;
209
319
  }
210
- var rafId,
211
- wasInterrupted = exitInterruptedRef.current,
212
- ignoreCancelEvents = wasInterrupted,
213
- enterStyle = props.enterStyle,
214
- exitStyle = props.exitStyle,
215
- delayStr2 = normalized.delay ? ` ${normalized.delay}ms` : "",
216
- durationOverride2 = (_normalized_config2 = normalized.config) === null || _normalized_config2 === void 0 ? void 0 : _normalized_config2.duration,
217
- exitTransitionString = keys.map(function (key2) {
218
- var propAnimation = normalized.properties[key2],
219
- animationValue2 = null;
220
- return typeof propAnimation == "string" ? animationValue2 = animations[propAnimation] : propAnimation && (typeof propAnimation > "u" ? "undefined" : _type_of(propAnimation)) === "object" && propAnimation.type ? animationValue2 = animations[propAnimation.type] : defaultAnimation && (animationValue2 = defaultAnimation), animationValue2 && durationOverride2 && (animationValue2 = applyDurationOverride(animationValue2, durationOverride2)), animationValue2 ? `${key2} ${animationValue2}${delayStr2}` : null;
221
- }).filter(Boolean).join(", ");
222
- if (wasInterrupted) {
223
- if (exitInterruptedRef.current = !1, node.style.transition = "none", exitStyle) {
224
- var resetStyle = {},
225
- _iteratorNormalCompletion = !0,
226
- _didIteratorError = !1,
227
- _iteratorError = void 0;
228
- try {
229
- for (var _iterator = Object.keys(exitStyle)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
230
- var key = _step.value;
231
- 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]);
232
- }
233
- } catch (err) {
234
- _didIteratorError = !0, _iteratorError = err;
235
- } finally {
236
- try {
237
- !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
238
- } finally {
239
- if (_didIteratorError) throw _iteratorError;
240
- }
241
- }
242
- applyStylesToNode(node, resetStyle);
243
- } else node.style.opacity = "1", node.style.transform = "none";
244
- node.offsetHeight;
245
- } else if (exitStyle) {
246
- ignoreCancelEvents = !0, node.style.transition = "none";
247
- var resetStyle1 = {},
248
- _iteratorNormalCompletion1 = !0,
249
- _didIteratorError1 = !1,
250
- _iteratorError1 = void 0;
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;
251
333
  try {
252
- for (var _iterator1 = Object.keys(exitStyle)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
253
- var key1 = _step1.value;
254
- key1 === "opacity" ? resetStyle1[key1] = 1 : TRANSFORM_KEYS.includes(key1) ? resetStyle1[key1] = key1 === "scale" || key1 === "scaleX" || key1 === "scaleY" ? 1 : 0 : enterStyle?.[key1] !== void 0 && (resetStyle1[key1] = enterStyle[key1]);
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
+ }
255
343
  }
256
344
  } catch (err) {
257
- _didIteratorError1 = !0, _iteratorError1 = err;
345
+ _didIteratorError = true;
346
+ _iteratorError = err;
258
347
  } finally {
259
348
  try {
260
- !_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return();
349
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
350
+ _iterator.return();
351
+ }
261
352
  } finally {
262
- if (_didIteratorError1) throw _iteratorError1;
353
+ if (_didIteratorError) {
354
+ throw _iteratorError;
355
+ }
263
356
  }
264
357
  }
265
- applyStylesToNode(node, resetStyle1), node.offsetHeight, rafId = requestAnimationFrame(function () {
266
- cycleId === exitCycleIdRef.current && (node.style.transition = exitTransitionString, node.offsetHeight, applyStylesToNode(node, exitStyle), ignoreCancelEvents = !1);
267
- });
358
+ applyStylesToNode(node, resetStyle);
359
+ } else {
360
+ node.style.opacity = "1";
361
+ node.style.transform = "none";
268
362
  }
269
- var maxDuration = defaultAnimation ? extractDuration(defaultAnimation) : 200,
270
- animationConfigs = (0, import_animation_helpers.getAnimationConfigsForKeys)(normalized, animations, keys, defaultAnimation),
271
- _iteratorNormalCompletion2 = !0,
272
- _didIteratorError2 = !1,
273
- _iteratorError2 = void 0;
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;
274
371
  try {
275
- for (var _iterator2 = animationConfigs.values()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) {
276
- var animationValue = _step2.value;
277
- if (animationValue) {
278
- var duration = extractDuration(animationValue);
279
- duration > maxDuration && (maxDuration = duration);
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];
280
380
  }
281
381
  }
282
382
  } catch (err) {
283
- _didIteratorError2 = !0, _iteratorError2 = err;
383
+ _didIteratorError1 = true;
384
+ _iteratorError1 = err;
284
385
  } finally {
285
386
  try {
286
- !_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
387
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
388
+ _iterator1.return();
389
+ }
287
390
  } finally {
288
- if (_didIteratorError2) throw _iteratorError2;
391
+ if (_didIteratorError1) {
392
+ throw _iteratorError1;
393
+ }
289
394
  }
290
395
  }
291
- var _normalized_delay,
292
- delay = (_normalized_delay = normalized.delay) !== null && _normalized_delay !== void 0 ? _normalized_delay : 0,
293
- fallbackTimeout = maxDuration + delay,
294
- timeoutId = setTimeout(function () {
295
- completeExit();
296
- }, fallbackTimeout),
297
- transitioningProps = new Set(keys),
298
- completedCount = 0,
299
- onFinishAnimation = function (event) {
300
- if (event.target === node) {
301
- var eventProp = event.propertyName;
302
- (transitioningProps.has(eventProp) || eventProp === "all") && (completedCount++, completedCount >= transitioningProps.size && (clearTimeout(timeoutId), completeExit()));
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;
303
418
  }
304
- },
305
- onCancelAnimation = function () {
306
- ignoreCancelEvents || (clearTimeout(timeoutId), completeExit());
307
- };
308
- return node.addEventListener("transitionend", onFinishAnimation), node.addEventListener("transitioncancel", onCancelAnimation), wasInterrupted && (rafId = requestAnimationFrame(function () {
309
- cycleId === exitCycleIdRef.current && (node.style.transition = exitTransitionString, node.offsetHeight, applyStylesToNode(node, exitStyle), ignoreCancelEvents = !1);
310
- })), function () {
311
- clearTimeout(timeoutId), rafId !== void 0 && cancelAnimationFrame(rafId), node.removeEventListener("transitionend", onFinishAnimation), node.removeEventListener("transitioncancel", onCancelAnimation), node.style.transition = "";
312
- };
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
+ }
313
434
  }
314
- }, [sendExitComplete, isExiting, stateRef, keys, normalized, defaultAnimation, props.enterStyle, props.exitStyle]), isHydrating || !(0, import_animation_helpers.hasAnimation)(normalized)) return null;
315
- Array.isArray(style.transform) && (style.transform = (0, import_web.transformsToString)(style.transform));
316
- var delayStr = normalized.delay ? ` ${normalized.delay}ms` : "",
317
- durationOverride = (_normalized_config = normalized.config) === null || _normalized_config === void 0 ? void 0 : _normalized_config.duration;
318
- return style.transition = keys.map(function (key) {
319
- var propAnimation = normalized.properties[key],
320
- animationValue = null;
321
- 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 && durationOverride && (animationValue = applyDurationOverride(animationValue, durationOverride)), animationValue ? `${key} ${animationValue}${delayStr}` : null;
322
- }).filter(Boolean).join(", "), process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info("CSS animation", {
323
- props,
324
- animations,
325
- normalized,
326
- defaultAnimation,
327
- style,
328
- isEntering,
329
- isExiting
330
- }), {
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
+ });
469
+ }
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
+ }
487
+ var delayStr = normalized.delay ? ` ${normalized.delay}ms` : "";
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 {
331
516
  style,
332
517
  className: isEntering ? "t_unmounted" : ""
333
518
  };