@tamagui/animations-css 3.0.0-beta.924.1 → 3.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.
- package/dist/cjs/createAnimations.cjs +7 -40
- package/dist/cjs/createAnimations.native.cjs +8 -43
- package/dist/cjs/createAnimations.native.js +8 -43
- package/dist/cjs/createAnimations.native.js.map +1 -1
- package/dist/esm/createAnimations.mjs +8 -41
- package/dist/esm/createAnimations.mjs.map +1 -1
- package/dist/esm/createAnimations.native.js +9 -44
- package/dist/esm/createAnimations.native.js.map +1 -1
- package/package.json +9 -8
- package/src/createAnimations.tsx +27 -78
- package/src/extras.ts +2 -1
- package/types/createAnimations.d.ts +2 -1
- package/types/createAnimations.d.ts.map +2 -2
- package/types/extras.d.ts +2 -1
- package/types/extras.d.ts.map +2 -2
|
@@ -60,11 +60,6 @@ function waitForAnimations(node) {
|
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
const DURATION_REGEX = /(\d+(?:\.\d+)?)\s*(?:ms|s(?!tiffness))/;
|
|
64
|
-
function applyDurationOverride(animation, durationMs) {
|
|
65
|
-
const replaced = animation.replace(DURATION_REGEX, `${durationMs}ms`);
|
|
66
|
-
return replaced === animation ? `${durationMs}ms ${animation}` : replaced;
|
|
67
|
-
}
|
|
68
63
|
const CSS_TRANSFORM_PROPERTIES = {
|
|
69
64
|
transform: [
|
|
70
65
|
"translate",
|
|
@@ -97,6 +92,7 @@ function getLifecycleCSSProperties(keys) {
|
|
|
97
92
|
if (!keys?.size) return emptyProperties;
|
|
98
93
|
const properties = /* @__PURE__ */ new Set();
|
|
99
94
|
for (const key of keys) {
|
|
95
|
+
if (key === "transition" || key === "transitionProperty") continue;
|
|
100
96
|
for (const property of getCSSProperties(key)) {
|
|
101
97
|
properties.add(hyphenateProperty(property));
|
|
102
98
|
}
|
|
@@ -200,41 +196,13 @@ function createAnimations(animations) {
|
|
|
200
196
|
exitCSSPropertiesSignature
|
|
201
197
|
]);
|
|
202
198
|
const effectiveTransition = styleState?.effectiveTransition ?? props.transition;
|
|
203
|
-
const normalized = (0, import_animation_helpers.normalizeTransition)(effectiveTransition);
|
|
204
199
|
const animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default";
|
|
205
|
-
const
|
|
206
|
-
const
|
|
207
|
-
const animatedProperties = (0, import_animation_helpers.getAnimatedProperties)(normalized);
|
|
208
|
-
const hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null;
|
|
209
|
-
const hasPerPropertyConfigs = animatedProperties.length > 0;
|
|
210
|
-
let keys;
|
|
211
|
-
if (props.animateOnly) {
|
|
212
|
-
keys = props.animateOnly;
|
|
213
|
-
} else if (hasPerPropertyConfigs && !hasDefault) {
|
|
214
|
-
keys = animatedProperties;
|
|
215
|
-
} else if (hasPerPropertyConfigs && hasDefault) {
|
|
216
|
-
keys = ["all", ...animatedProperties];
|
|
217
|
-
} else {
|
|
218
|
-
keys = ["all"];
|
|
219
|
-
}
|
|
200
|
+
const resolved = (0, import_animation_helpers.forAnimationState)((0, import_animation_helpers.resolveTransition)(effectiveTransition, { animations }), animationState);
|
|
201
|
+
const hasKeys = (0, import_animation_helpers.hasTransition)(resolved);
|
|
220
202
|
let transition;
|
|
221
203
|
const getTransition = () => {
|
|
222
204
|
if (transition !== void 0) return transition;
|
|
223
|
-
|
|
224
|
-
const duration = normalized.config?.duration;
|
|
225
|
-
transition = keys.flatMap((key) => {
|
|
226
|
-
const propertyAnimation = normalized.properties[key];
|
|
227
|
-
let animation = defaultAnimation;
|
|
228
|
-
if (typeof propertyAnimation === "string") {
|
|
229
|
-
animation = animations[propertyAnimation];
|
|
230
|
-
} else if (propertyAnimation?.type) {
|
|
231
|
-
animation = animations[propertyAnimation.type];
|
|
232
|
-
}
|
|
233
|
-
if (animation && duration) {
|
|
234
|
-
animation = applyDurationOverride(animation, duration);
|
|
235
|
-
}
|
|
236
|
-
return animation ? getCSSProperties(key).map((property) => `${property} ${animation}${delay}`) : [];
|
|
237
|
-
}).join(", ");
|
|
205
|
+
transition = (0, import_animation_helpers.toCSSTransition)(resolved) ?? "";
|
|
238
206
|
return transition;
|
|
239
207
|
};
|
|
240
208
|
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
@@ -256,7 +224,7 @@ function createAnimations(animations) {
|
|
|
256
224
|
}
|
|
257
225
|
sendExitCompleteRef.current?.();
|
|
258
226
|
};
|
|
259
|
-
if (
|
|
227
|
+
if (!hasKeys) {
|
|
260
228
|
completeExit();
|
|
261
229
|
return;
|
|
262
230
|
}
|
|
@@ -350,7 +318,7 @@ function createAnimations(animations) {
|
|
|
350
318
|
if (isHydrating) {
|
|
351
319
|
return null;
|
|
352
320
|
}
|
|
353
|
-
if (!(0, import_animation_helpers.
|
|
321
|
+
if (!(0, import_animation_helpers.hasTransition)(resolved)) {
|
|
354
322
|
return null;
|
|
355
323
|
}
|
|
356
324
|
if (Array.isArray(style.transform)) {
|
|
@@ -361,8 +329,7 @@ function createAnimations(animations) {
|
|
|
361
329
|
console.info("CSS animation", {
|
|
362
330
|
props,
|
|
363
331
|
animations,
|
|
364
|
-
|
|
365
|
-
defaultAnimation,
|
|
332
|
+
resolved,
|
|
366
333
|
style,
|
|
367
334
|
isEntering,
|
|
368
335
|
isExiting
|
|
@@ -68,11 +68,6 @@ function waitForAnimations(node) {
|
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
var DURATION_REGEX = /(\d+(?:\.\d+)?)\s*(?:ms|s(?!tiffness))/;
|
|
72
|
-
function applyDurationOverride(animation, durationMs) {
|
|
73
|
-
var replaced = animation.replace(DURATION_REGEX, `${durationMs}ms`);
|
|
74
|
-
return replaced === animation ? `${durationMs}ms ${animation}` : replaced;
|
|
75
|
-
}
|
|
76
71
|
var CSS_TRANSFORM_PROPERTIES = {
|
|
77
72
|
transform: [
|
|
78
73
|
"translate",
|
|
@@ -111,6 +106,7 @@ function getLifecycleCSSProperties(keys) {
|
|
|
111
106
|
try {
|
|
112
107
|
for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
113
108
|
var key = _step.value;
|
|
109
|
+
if (key === "transition" || key === "transitionProperty") continue;
|
|
114
110
|
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
115
111
|
try {
|
|
116
112
|
for (var _iterator1 = getCSSProperties(key)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
@@ -283,44 +279,14 @@ function createAnimations(animations) {
|
|
|
283
279
|
]);
|
|
284
280
|
var _styleState_effectiveTransition;
|
|
285
281
|
var effectiveTransition = (_styleState_effectiveTransition = styleState === null || styleState === void 0 ? void 0 : styleState.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition;
|
|
286
|
-
var normalized = (0, import_animation_helpers.normalizeTransition)(effectiveTransition);
|
|
287
282
|
var animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default";
|
|
288
|
-
var
|
|
289
|
-
var
|
|
290
|
-
var animatedProperties = (0, import_animation_helpers.getAnimatedProperties)(normalized);
|
|
291
|
-
var hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null;
|
|
292
|
-
var hasPerPropertyConfigs = animatedProperties.length > 0;
|
|
293
|
-
var keys;
|
|
294
|
-
if (props.animateOnly) {
|
|
295
|
-
keys = props.animateOnly;
|
|
296
|
-
} else if (hasPerPropertyConfigs && !hasDefault) {
|
|
297
|
-
keys = animatedProperties;
|
|
298
|
-
} else if (hasPerPropertyConfigs && hasDefault) {
|
|
299
|
-
keys = ["all", ...animatedProperties];
|
|
300
|
-
} else {
|
|
301
|
-
keys = ["all"];
|
|
302
|
-
}
|
|
283
|
+
var resolved = (0, import_animation_helpers.forAnimationState)((0, import_animation_helpers.resolveTransition)(effectiveTransition, { animations }), animationState);
|
|
284
|
+
var hasKeys = (0, import_animation_helpers.hasTransition)(resolved);
|
|
303
285
|
var transition;
|
|
304
286
|
var getTransition = function() {
|
|
305
|
-
var _normalized_config;
|
|
306
287
|
if (transition !== void 0) return transition;
|
|
307
|
-
var
|
|
308
|
-
|
|
309
|
-
transition = keys.flatMap(function(key) {
|
|
310
|
-
var propertyAnimation = normalized.properties[key];
|
|
311
|
-
var animation = defaultAnimation;
|
|
312
|
-
if (typeof propertyAnimation === "string") {
|
|
313
|
-
animation = animations[propertyAnimation];
|
|
314
|
-
} else if (propertyAnimation === null || propertyAnimation === void 0 ? void 0 : propertyAnimation.type) {
|
|
315
|
-
animation = animations[propertyAnimation.type];
|
|
316
|
-
}
|
|
317
|
-
if (animation && duration) {
|
|
318
|
-
animation = applyDurationOverride(animation, duration);
|
|
319
|
-
}
|
|
320
|
-
return animation ? getCSSProperties(key).map(function(property) {
|
|
321
|
-
return `${property} ${animation}${delay}`;
|
|
322
|
-
}) : [];
|
|
323
|
-
}).join(", ");
|
|
288
|
+
var _toCSSTransition;
|
|
289
|
+
transition = (_toCSSTransition = (0, import_animation_helpers.toCSSTransition)(resolved)) !== null && _toCSSTransition !== void 0 ? _toCSSTransition : "";
|
|
324
290
|
return transition;
|
|
325
291
|
};
|
|
326
292
|
(0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
@@ -344,7 +310,7 @@ function createAnimations(animations) {
|
|
|
344
310
|
}
|
|
345
311
|
(_sendExitCompleteRef_current = sendExitCompleteRef.current) === null || _sendExitCompleteRef_current === void 0 ? void 0 : _sendExitCompleteRef_current.call(sendExitCompleteRef);
|
|
346
312
|
};
|
|
347
|
-
if (
|
|
313
|
+
if (!hasKeys) {
|
|
348
314
|
completeExit();
|
|
349
315
|
return;
|
|
350
316
|
}
|
|
@@ -439,7 +405,7 @@ function createAnimations(animations) {
|
|
|
439
405
|
if (isHydrating) {
|
|
440
406
|
return null;
|
|
441
407
|
}
|
|
442
|
-
if (!(0, import_animation_helpers.
|
|
408
|
+
if (!(0, import_animation_helpers.hasTransition)(resolved)) {
|
|
443
409
|
return null;
|
|
444
410
|
}
|
|
445
411
|
if (Array.isArray(style.transform)) {
|
|
@@ -450,8 +416,7 @@ function createAnimations(animations) {
|
|
|
450
416
|
console.info("CSS animation", {
|
|
451
417
|
props,
|
|
452
418
|
animations,
|
|
453
|
-
|
|
454
|
-
defaultAnimation,
|
|
419
|
+
resolved,
|
|
455
420
|
style,
|
|
456
421
|
isEntering,
|
|
457
422
|
isExiting
|
|
@@ -68,11 +68,6 @@ function waitForAnimations(node) {
|
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
var DURATION_REGEX = /(\d+(?:\.\d+)?)\s*(?:ms|s(?!tiffness))/;
|
|
72
|
-
function applyDurationOverride(animation, durationMs) {
|
|
73
|
-
var replaced = animation.replace(DURATION_REGEX, `${durationMs}ms`);
|
|
74
|
-
return replaced === animation ? `${durationMs}ms ${animation}` : replaced;
|
|
75
|
-
}
|
|
76
71
|
var CSS_TRANSFORM_PROPERTIES = {
|
|
77
72
|
transform: [
|
|
78
73
|
"translate",
|
|
@@ -111,6 +106,7 @@ function getLifecycleCSSProperties(keys) {
|
|
|
111
106
|
try {
|
|
112
107
|
for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
113
108
|
var key = _step.value;
|
|
109
|
+
if (key === "transition" || key === "transitionProperty") continue;
|
|
114
110
|
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
115
111
|
try {
|
|
116
112
|
for (var _iterator1 = getCSSProperties(key)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
@@ -283,44 +279,14 @@ function createAnimations(animations) {
|
|
|
283
279
|
]);
|
|
284
280
|
var _styleState_effectiveTransition;
|
|
285
281
|
var effectiveTransition = (_styleState_effectiveTransition = styleState === null || styleState === void 0 ? void 0 : styleState.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition;
|
|
286
|
-
var normalized = (0, import_animation_helpers.normalizeTransition)(effectiveTransition);
|
|
287
282
|
var animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default";
|
|
288
|
-
var
|
|
289
|
-
var
|
|
290
|
-
var animatedProperties = (0, import_animation_helpers.getAnimatedProperties)(normalized);
|
|
291
|
-
var hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null;
|
|
292
|
-
var hasPerPropertyConfigs = animatedProperties.length > 0;
|
|
293
|
-
var keys;
|
|
294
|
-
if (props.animateOnly) {
|
|
295
|
-
keys = props.animateOnly;
|
|
296
|
-
} else if (hasPerPropertyConfigs && !hasDefault) {
|
|
297
|
-
keys = animatedProperties;
|
|
298
|
-
} else if (hasPerPropertyConfigs && hasDefault) {
|
|
299
|
-
keys = ["all", ...animatedProperties];
|
|
300
|
-
} else {
|
|
301
|
-
keys = ["all"];
|
|
302
|
-
}
|
|
283
|
+
var resolved = (0, import_animation_helpers.forAnimationState)((0, import_animation_helpers.resolveTransition)(effectiveTransition, { animations }), animationState);
|
|
284
|
+
var hasKeys = (0, import_animation_helpers.hasTransition)(resolved);
|
|
303
285
|
var transition;
|
|
304
286
|
var getTransition = function() {
|
|
305
|
-
var _normalized_config;
|
|
306
287
|
if (transition !== void 0) return transition;
|
|
307
|
-
var
|
|
308
|
-
|
|
309
|
-
transition = keys.flatMap(function(key) {
|
|
310
|
-
var propertyAnimation = normalized.properties[key];
|
|
311
|
-
var animation = defaultAnimation;
|
|
312
|
-
if (typeof propertyAnimation === "string") {
|
|
313
|
-
animation = animations[propertyAnimation];
|
|
314
|
-
} else if (propertyAnimation === null || propertyAnimation === void 0 ? void 0 : propertyAnimation.type) {
|
|
315
|
-
animation = animations[propertyAnimation.type];
|
|
316
|
-
}
|
|
317
|
-
if (animation && duration) {
|
|
318
|
-
animation = applyDurationOverride(animation, duration);
|
|
319
|
-
}
|
|
320
|
-
return animation ? getCSSProperties(key).map(function(property) {
|
|
321
|
-
return `${property} ${animation}${delay}`;
|
|
322
|
-
}) : [];
|
|
323
|
-
}).join(", ");
|
|
288
|
+
var _toCSSTransition;
|
|
289
|
+
transition = (_toCSSTransition = (0, import_animation_helpers.toCSSTransition)(resolved)) !== null && _toCSSTransition !== void 0 ? _toCSSTransition : "";
|
|
324
290
|
return transition;
|
|
325
291
|
};
|
|
326
292
|
(0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
@@ -344,7 +310,7 @@ function createAnimations(animations) {
|
|
|
344
310
|
}
|
|
345
311
|
(_sendExitCompleteRef_current = sendExitCompleteRef.current) === null || _sendExitCompleteRef_current === void 0 ? void 0 : _sendExitCompleteRef_current.call(sendExitCompleteRef);
|
|
346
312
|
};
|
|
347
|
-
if (
|
|
313
|
+
if (!hasKeys) {
|
|
348
314
|
completeExit();
|
|
349
315
|
return;
|
|
350
316
|
}
|
|
@@ -439,7 +405,7 @@ function createAnimations(animations) {
|
|
|
439
405
|
if (isHydrating) {
|
|
440
406
|
return null;
|
|
441
407
|
}
|
|
442
|
-
if (!(0, import_animation_helpers.
|
|
408
|
+
if (!(0, import_animation_helpers.hasTransition)(resolved)) {
|
|
443
409
|
return null;
|
|
444
410
|
}
|
|
445
411
|
if (Array.isArray(style.transform)) {
|
|
@@ -450,8 +416,7 @@ function createAnimations(animations) {
|
|
|
450
416
|
console.info("CSS animation", {
|
|
451
417
|
props,
|
|
452
418
|
animations,
|
|
453
|
-
|
|
454
|
-
defaultAnimation,
|
|
419
|
+
resolved,
|
|
455
420
|
style,
|
|
456
421
|
isEntering,
|
|
457
422
|
isExiting
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAnimations.native.js","names":[],"sources":["cjs/createAnimations.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar createAnimations_exports = {};\n__export(createAnimations_exports, {\n createAnimations: () => createAnimations\n});\nmodule.exports = __toCommonJS(createAnimations_exports);\nvar import_animation_helpers = require(\"@tamagui/animation-helpers\");\nvar import_constants = require(\"@tamagui/constants\");\nvar import_use_presence = require(\"@tamagui/use-presence\");\nvar import_internal_runtime = require(\"@tamagui/web/internal-runtime\");\nvar import_react = __toESM(require(\"react\"), 1);\nvar hasRAF = typeof requestAnimationFrame !== \"undefined\";\nfunction waitForAnimations(node) {\n if (typeof node.getAnimations !== \"function\") {\n return Promise.resolve(true);\n }\n return new Promise(function(resolve) {\n var check = function() {\n var animations = node.getAnimations();\n if (animations.length === 0) {\n resolve(true);\n return;\n }\n Promise.all(animations.map(function(a) {\n return a.finished;\n })).then(function() {\n return resolve(true);\n }).catch(function() {\n var remaining = node.getAnimations();\n if (remaining.some(function(a) {\n return a.playState === \"running\" || a.pending;\n })) {\n check();\n return;\n }\n resolve(false);\n });\n };\n if (hasRAF) {\n requestAnimationFrame(check);\n } else {\n check();\n }\n });\n}\nvar DURATION_REGEX = /(\\d+(?:\\.\\d+)?)\\s*(?:ms|s(?!tiffness))/;\nfunction applyDurationOverride(animation, durationMs) {\n var replaced = animation.replace(DURATION_REGEX, `${durationMs}ms`);\n return replaced === animation ? `${durationMs}ms ${animation}` : replaced;\n}\nvar CSS_TRANSFORM_PROPERTIES = {\n transform: [\n \"translate\",\n \"scale\",\n \"rotate\",\n \"transform\"\n ],\n x: [\n \"translate\"\n ],\n y: [\n \"translate\"\n ],\n scale: [\n \"scale\"\n ],\n scaleX: [\n \"scale\"\n ],\n scaleY: [\n \"scale\"\n ],\n rotate: [\n \"rotate\"\n ],\n rotateX: [\n \"transform\"\n ],\n rotateY: [\n \"transform\"\n ],\n rotateZ: [\n \"transform\"\n ],\n skewX: [\n \"transform\"\n ],\n skewY: [\n \"transform\"\n ]\n};\nvar getCSSProperties = function(key) {\n return CSS_TRANSFORM_PROPERTIES[key] || [\n key\n ];\n};\nvar hyphenatedPropertyCache = {};\nvar emptyProperties = [];\nfunction hyphenateProperty(property) {\n var _hyphenatedPropertyCache, _property;\n if (property.startsWith(\"--\")) return property;\n return (_hyphenatedPropertyCache = hyphenatedPropertyCache)[_property = property] || (_hyphenatedPropertyCache[_property] = property.replace(/[A-Z]/g, function(letter) {\n return `-${letter.toLowerCase()}`;\n }));\n}\nfunction getLifecycleCSSProperties(keys) {\n if (!(keys === null || keys === void 0 ? void 0 : keys.size)) return emptyProperties;\n var properties = /* @__PURE__ */ new Set();\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var key = _step.value;\n var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n try {\n for (var _iterator1 = getCSSProperties(key)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n var property = _step1.value;\n properties.add(hyphenateProperty(property));\n }\n } catch (err) {\n _didIteratorError1 = true;\n _iteratorError1 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion1 && _iterator1.return != null) {\n _iterator1.return();\n }\n } finally {\n if (_didIteratorError1) {\n throw _iteratorError1;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return [\n ...properties\n ].sort();\n}\nfunction readComputedProperties(node, properties) {\n var computed = getComputedStyle(node);\n var values = {};\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = properties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var property = _step.value;\n var value = computed.getPropertyValue(property);\n if (value) values[property] = value;\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return values;\n}\nfunction applyCSSProperties(node, values) {\n for (var property in values) {\n node.style.setProperty(property, values[property]);\n }\n}\nfunction clearCSSProperties(node, properties) {\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = properties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var property = _step.value;\n node.style.removeProperty(property);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n}\nfunction createAnimations(animations) {\n return {\n animations,\n usePresence: import_use_presence.usePresence,\n ResetPresence: import_use_presence.ResetPresence,\n inputStyle: \"css\",\n outputStyle: \"css\",\n // @ts-ignore - styleState is added by createComponent\n useAnimations: function(param) {\n var { props, presence, style, componentState, stateRef, styleState, onTransition } = param;\n var _styleState_programLifecycleStyleKeys;\n var isHydrating = componentState.unmounted === true;\n var isEntering = !!componentState.unmounted;\n var isExiting = (presence === null || presence === void 0 ? void 0 : presence[0]) === false;\n var sendExitComplete = presence === null || presence === void 0 ? void 0 : presence[1];\n var onTransitionRef = import_react.default.useRef(onTransition);\n onTransitionRef.current = onTransition;\n var emit = function(phase, cause, finished) {\n var _onTransitionRef_current;\n (_onTransitionRef_current = onTransitionRef.current) === null || _onTransitionRef_current === void 0 ? void 0 : _onTransitionRef_current.call(onTransitionRef, phase === \"end\" ? {\n phase,\n cause,\n finished\n } : {\n phase,\n cause\n });\n };\n var wasEnteringRef = import_react.default.useRef(isEntering);\n var justFinishedEntering = wasEnteringRef.current && !isEntering;\n import_react.default.useEffect(function() {\n wasEnteringRef.current = isEntering;\n });\n var exitCycleIdRef = import_react.default.useRef(0);\n var exitCompletedRef = import_react.default.useRef(false);\n var wasExitingRef = import_react.default.useRef(false);\n var sendExitCompleteRef = import_react.default.useRef(sendExitComplete);\n var lastMountedStyleRef = import_react.default.useRef({});\n sendExitCompleteRef.current = sendExitComplete;\n var exitCSSProperties = getLifecycleCSSProperties(styleState === null || styleState === void 0 ? void 0 : (_styleState_programLifecycleStyleKeys = styleState.programLifecycleStyleKeys) === null || _styleState_programLifecycleStyleKeys === void 0 ? void 0 : _styleState_programLifecycleStyleKeys.exit);\n var exitCSSPropertiesSignature = exitCSSProperties.join(\"\\0\");\n var enterCycleIdRef = import_react.default.useRef(0);\n var enterStartedRef = import_react.default.useRef(false);\n var updateCycleIdRef = import_react.default.useRef(0);\n var updateInFlightRef = import_react.default.useRef(false);\n var prevUpdateSigRef = import_react.default.useRef(null);\n var exitStartedRef = import_react.default.useRef(false);\n var justStartedExiting = isExiting && !wasExitingRef.current;\n var justStoppedExiting = !isExiting && wasExitingRef.current;\n if (justStartedExiting) {\n exitCycleIdRef.current++;\n exitCompletedRef.current = false;\n }\n if (justStoppedExiting) {\n exitCycleIdRef.current++;\n }\n import_react.default.useEffect(function() {\n wasExitingRef.current = isExiting;\n });\n (0, import_constants.useIsomorphicLayoutEffect)(function() {\n if (isExiting) return;\n var host = stateRef.current.host;\n if (!host || !exitCSSProperties.length) {\n lastMountedStyleRef.current = {};\n return;\n }\n var node = host;\n var capture = function() {\n if (stateRef.current.host !== node || wasExitingRef.current) return;\n lastMountedStyleRef.current = readComputedProperties(node, exitCSSProperties);\n };\n if (justFinishedEntering) {\n void waitForAnimations(node).then(capture);\n } else {\n capture();\n }\n }, [\n isExiting,\n justFinishedEntering,\n exitCSSPropertiesSignature\n ]);\n var _styleState_effectiveTransition;\n var effectiveTransition = (_styleState_effectiveTransition = styleState === null || styleState === void 0 ? void 0 : styleState.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition;\n var normalized = (0, import_animation_helpers.normalizeTransition)(effectiveTransition);\n var animationState = isExiting ? \"exit\" : isEntering || justFinishedEntering ? \"enter\" : \"default\";\n var effectiveAnimationKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState);\n var defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null;\n var animatedProperties = (0, import_animation_helpers.getAnimatedProperties)(normalized);\n var hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null;\n var hasPerPropertyConfigs = animatedProperties.length > 0;\n var keys;\n if (props.animateOnly) {\n keys = props.animateOnly;\n } else if (hasPerPropertyConfigs && !hasDefault) {\n keys = animatedProperties;\n } else if (hasPerPropertyConfigs && hasDefault) {\n keys = [\n \"all\",\n ...animatedProperties\n ];\n } else {\n keys = [\n \"all\"\n ];\n }\n var transition;\n var getTransition = function() {\n var _normalized_config;\n if (transition !== void 0) return transition;\n var delay = normalized.delay ? ` ${normalized.delay}ms` : \"\";\n var duration = (_normalized_config = normalized.config) === null || _normalized_config === void 0 ? void 0 : _normalized_config.duration;\n transition = keys.flatMap(function(key) {\n var propertyAnimation = normalized.properties[key];\n var animation = defaultAnimation;\n if (typeof propertyAnimation === \"string\") {\n animation = animations[propertyAnimation];\n } else if (propertyAnimation === null || propertyAnimation === void 0 ? void 0 : propertyAnimation.type) {\n animation = animations[propertyAnimation.type];\n }\n if (animation && duration) {\n animation = applyDurationOverride(animation, duration);\n }\n return animation ? getCSSProperties(key).map(function(property) {\n return `${property} ${animation}${delay}`;\n }) : [];\n }).join(\", \");\n return transition;\n };\n (0, import_constants.useIsomorphicLayoutEffect)(function() {\n var host = stateRef.current.host;\n if (!sendExitComplete || !isExiting || !host) return;\n var node = host;\n var cycleId = exitCycleIdRef.current;\n if (!exitStartedRef.current) {\n exitStartedRef.current = true;\n emit(\"start\", \"exit\");\n }\n var completeExit = function() {\n var finished = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;\n var _sendExitCompleteRef_current;\n if (cycleId !== exitCycleIdRef.current) return;\n if (exitCompletedRef.current) return;\n exitCompletedRef.current = true;\n if (exitStartedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", finished);\n }\n (_sendExitCompleteRef_current = sendExitCompleteRef.current) === null || _sendExitCompleteRef_current === void 0 ? void 0 : _sendExitCompleteRef_current.call(sendExitCompleteRef);\n };\n if (keys.length === 0) {\n completeExit();\n return;\n }\n var rafId;\n var disposed = false;\n var mountedStyle = lastMountedStyleRef.current;\n var canRestart = exitCSSProperties.length > 0 && Object.keys(mountedStyle).length > 0;\n var exitTarget;\n if (canRestart) {\n node.style.transition = \"none\";\n exitTarget = readComputedProperties(node, exitCSSProperties);\n applyCSSProperties(node, mountedStyle);\n void node.offsetHeight;\n rafId = requestAnimationFrame(function() {\n if (cycleId !== exitCycleIdRef.current) return;\n node.style.transition = getTransition();\n void node.offsetHeight;\n applyCSSProperties(node, exitTarget);\n });\n }\n void waitForAnimations(node).then(function(finished) {\n if (!disposed) completeExit(finished);\n });\n return function() {\n disposed = true;\n if (rafId !== void 0) cancelAnimationFrame(rafId);\n clearCSSProperties(node, exitCSSProperties);\n node.style.transition = \"\";\n };\n }, [\n isExiting,\n exitCSSPropertiesSignature\n ]);\n var styleSignature = onTransition ? (function() {\n var { transition: _t, ...rest } = style;\n var _styleState_classNames;\n return `${JSON.stringify((_styleState_classNames = styleState === null || styleState === void 0 ? void 0 : styleState.classNames) !== null && _styleState_classNames !== void 0 ? _styleState_classNames : null)}|${JSON.stringify(rest)}`;\n })() : \"\";\n (0, import_constants.useIsomorphicLayoutEffect)(function() {\n var host = stateRef.current.host;\n if (!onTransitionRef.current || isExiting || !justFinishedEntering || !host) {\n return;\n }\n var node = host;\n var cycleId = ++enterCycleIdRef.current;\n enterStartedRef.current = true;\n emit(\"start\", \"enter\");\n void waitForAnimations(node).then(function(finished) {\n if (cycleId !== enterCycleIdRef.current || !enterStartedRef.current) return;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", finished);\n });\n }, [\n justFinishedEntering,\n isExiting\n ]);\n (0, import_constants.useIsomorphicLayoutEffect)(function() {\n var host = stateRef.current.host;\n if (!onTransitionRef.current || isEntering || justFinishedEntering || isExiting || !host) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (prevUpdateSigRef.current === null) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (styleSignature === prevUpdateSigRef.current) return;\n prevUpdateSigRef.current = styleSignature;\n var node = host;\n if (updateInFlightRef.current) {\n emit(\"end\", \"update\", false);\n }\n updateInFlightRef.current = true;\n var cycleId = ++updateCycleIdRef.current;\n emit(\"start\", \"update\");\n void waitForAnimations(node).then(function(finished) {\n if (cycleId !== updateCycleIdRef.current) return;\n updateInFlightRef.current = false;\n emit(\"end\", \"update\", finished);\n });\n }, [\n styleSignature,\n isEntering,\n justFinishedEntering,\n isExiting\n ]);\n (0, import_constants.useIsomorphicLayoutEffect)(function() {\n if (justStartedExiting && enterStartedRef.current) {\n enterCycleIdRef.current++;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", false);\n }\n if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", false);\n }\n }, [\n justStartedExiting,\n justStoppedExiting\n ]);\n if (isHydrating) {\n return null;\n }\n if (!(0, import_animation_helpers.hasAnimation)(normalized)) {\n return null;\n }\n if (Array.isArray(style.transform)) {\n style.transform = (0, import_internal_runtime.transformsToString)(style.transform);\n }\n style.transition = getTransition();\n if (process.env.NODE_ENV === \"development\" && props[\"debug\"] === \"verbose\") {\n console.info(\"CSS animation\", {\n props,\n animations,\n normalized,\n defaultAnimation,\n style,\n isEntering,\n isExiting\n });\n }\n return {\n style,\n className: isEntering ? \"t_unmounted\" : \"\"\n };\n }\n };\n}\n//# sourceMappingURL=createAnimations.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAA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sBAAsB,eAAe,WAAW,CAAC,iBAAiB,SAAS;KAC7E,eAAe,UAAU;KACzB,KAAK,OAAO,QAAQ,KAAK;IAC3B;GACF,GAAG,CACD,oBACA,kBACF,CAAC;GACD,IAAI,aAAa;IACf,OAAO;GACT;GACA,IAAI,EAAE,GAAG,yBAAyB,aAAY,CAAE,UAAU,GAAG;IAC3D,OAAO;GACT;GACA,IAAI,MAAM,QAAQ,MAAM,SAAS,GAAG;IAClC,MAAM,aAAa,GAAG,wBAAwB,mBAAkB,CAAE,MAAM,SAAS;GACnF;GACA,MAAM,aAAa,cAAc;GACjC,IAAI,QAAQ,IAAI,aAAa,iBAAiB,MAAM,aAAa,WAAW;IAC1E,QAAQ,KAAK,iBAAiB;KAC5B;KACA;KACA;KACA;KACA;KACA;KACA;IACF,CAAC;GACH;GACA,OAAO;IACL;IACA,WAAW,aAAa,gBAAgB;GAC1C;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"createAnimations.native.js","names":[],"sources":["cjs/createAnimations.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar createAnimations_exports = {};\n__export(createAnimations_exports, {\n createAnimations: () => createAnimations\n});\nmodule.exports = __toCommonJS(createAnimations_exports);\nvar import_animation_helpers = require(\"@tamagui/animation-helpers\");\nvar import_constants = require(\"@tamagui/constants\");\nvar import_use_presence = require(\"@tamagui/use-presence\");\nvar import_internal_runtime = require(\"@tamagui/web/internal-runtime\");\nvar import_react = __toESM(require(\"react\"), 1);\nvar hasRAF = typeof requestAnimationFrame !== \"undefined\";\nfunction waitForAnimations(node) {\n if (typeof node.getAnimations !== \"function\") {\n return Promise.resolve(true);\n }\n return new Promise(function(resolve) {\n var check = function() {\n var animations = node.getAnimations();\n if (animations.length === 0) {\n resolve(true);\n return;\n }\n Promise.all(animations.map(function(a) {\n return a.finished;\n })).then(function() {\n return resolve(true);\n }).catch(function() {\n var remaining = node.getAnimations();\n if (remaining.some(function(a) {\n return a.playState === \"running\" || a.pending;\n })) {\n check();\n return;\n }\n resolve(false);\n });\n };\n if (hasRAF) {\n requestAnimationFrame(check);\n } else {\n check();\n }\n });\n}\nvar CSS_TRANSFORM_PROPERTIES = {\n transform: [\n \"translate\",\n \"scale\",\n \"rotate\",\n \"transform\"\n ],\n x: [\n \"translate\"\n ],\n y: [\n \"translate\"\n ],\n scale: [\n \"scale\"\n ],\n scaleX: [\n \"scale\"\n ],\n scaleY: [\n \"scale\"\n ],\n rotate: [\n \"rotate\"\n ],\n rotateX: [\n \"transform\"\n ],\n rotateY: [\n \"transform\"\n ],\n rotateZ: [\n \"transform\"\n ],\n skewX: [\n \"transform\"\n ],\n skewY: [\n \"transform\"\n ]\n};\nvar getCSSProperties = function(key) {\n return CSS_TRANSFORM_PROPERTIES[key] || [\n key\n ];\n};\nvar hyphenatedPropertyCache = {};\nvar emptyProperties = [];\nfunction hyphenateProperty(property) {\n var _hyphenatedPropertyCache, _property;\n if (property.startsWith(\"--\")) return property;\n return (_hyphenatedPropertyCache = hyphenatedPropertyCache)[_property = property] || (_hyphenatedPropertyCache[_property] = property.replace(/[A-Z]/g, function(letter) {\n return `-${letter.toLowerCase()}`;\n }));\n}\nfunction getLifecycleCSSProperties(keys) {\n if (!(keys === null || keys === void 0 ? void 0 : keys.size)) return emptyProperties;\n var properties = /* @__PURE__ */ new Set();\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var key = _step.value;\n if (key === \"transition\" || key === \"transitionProperty\") continue;\n var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n try {\n for (var _iterator1 = getCSSProperties(key)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n var property = _step1.value;\n properties.add(hyphenateProperty(property));\n }\n } catch (err) {\n _didIteratorError1 = true;\n _iteratorError1 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion1 && _iterator1.return != null) {\n _iterator1.return();\n }\n } finally {\n if (_didIteratorError1) {\n throw _iteratorError1;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return [\n ...properties\n ].sort();\n}\nfunction readComputedProperties(node, properties) {\n var computed = getComputedStyle(node);\n var values = {};\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = properties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var property = _step.value;\n var value = computed.getPropertyValue(property);\n if (value) values[property] = value;\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return values;\n}\nfunction applyCSSProperties(node, values) {\n for (var property in values) {\n node.style.setProperty(property, values[property]);\n }\n}\nfunction clearCSSProperties(node, properties) {\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = properties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var property = _step.value;\n node.style.removeProperty(property);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n}\nfunction createAnimations(animations) {\n return {\n animations,\n usePresence: import_use_presence.usePresence,\n ResetPresence: import_use_presence.ResetPresence,\n inputStyle: \"css\",\n outputStyle: \"css\",\n // @ts-ignore - styleState is added by createComponent\n useAnimations: function(param) {\n var { props, presence, style, componentState, stateRef, styleState, onTransition } = param;\n var _styleState_programLifecycleStyleKeys;\n var isHydrating = componentState.unmounted === true;\n var isEntering = !!componentState.unmounted;\n var isExiting = (presence === null || presence === void 0 ? void 0 : presence[0]) === false;\n var sendExitComplete = presence === null || presence === void 0 ? void 0 : presence[1];\n var onTransitionRef = import_react.default.useRef(onTransition);\n onTransitionRef.current = onTransition;\n var emit = function(phase, cause, finished) {\n var _onTransitionRef_current;\n (_onTransitionRef_current = onTransitionRef.current) === null || _onTransitionRef_current === void 0 ? void 0 : _onTransitionRef_current.call(onTransitionRef, phase === \"end\" ? {\n phase,\n cause,\n finished\n } : {\n phase,\n cause\n });\n };\n var wasEnteringRef = import_react.default.useRef(isEntering);\n var justFinishedEntering = wasEnteringRef.current && !isEntering;\n import_react.default.useEffect(function() {\n wasEnteringRef.current = isEntering;\n });\n var exitCycleIdRef = import_react.default.useRef(0);\n var exitCompletedRef = import_react.default.useRef(false);\n var wasExitingRef = import_react.default.useRef(false);\n var sendExitCompleteRef = import_react.default.useRef(sendExitComplete);\n var lastMountedStyleRef = import_react.default.useRef({});\n sendExitCompleteRef.current = sendExitComplete;\n var exitCSSProperties = getLifecycleCSSProperties(styleState === null || styleState === void 0 ? void 0 : (_styleState_programLifecycleStyleKeys = styleState.programLifecycleStyleKeys) === null || _styleState_programLifecycleStyleKeys === void 0 ? void 0 : _styleState_programLifecycleStyleKeys.exit);\n var exitCSSPropertiesSignature = exitCSSProperties.join(\"\\0\");\n var enterCycleIdRef = import_react.default.useRef(0);\n var enterStartedRef = import_react.default.useRef(false);\n var updateCycleIdRef = import_react.default.useRef(0);\n var updateInFlightRef = import_react.default.useRef(false);\n var prevUpdateSigRef = import_react.default.useRef(null);\n var exitStartedRef = import_react.default.useRef(false);\n var justStartedExiting = isExiting && !wasExitingRef.current;\n var justStoppedExiting = !isExiting && wasExitingRef.current;\n if (justStartedExiting) {\n exitCycleIdRef.current++;\n exitCompletedRef.current = false;\n }\n if (justStoppedExiting) {\n exitCycleIdRef.current++;\n }\n import_react.default.useEffect(function() {\n wasExitingRef.current = isExiting;\n });\n (0, import_constants.useIsomorphicLayoutEffect)(function() {\n if (isExiting) return;\n var host = stateRef.current.host;\n if (!host || !exitCSSProperties.length) {\n lastMountedStyleRef.current = {};\n return;\n }\n var node = host;\n var capture = function() {\n if (stateRef.current.host !== node || wasExitingRef.current) return;\n lastMountedStyleRef.current = readComputedProperties(node, exitCSSProperties);\n };\n if (justFinishedEntering) {\n void waitForAnimations(node).then(capture);\n } else {\n capture();\n }\n }, [\n isExiting,\n justFinishedEntering,\n exitCSSPropertiesSignature\n ]);\n var _styleState_effectiveTransition;\n var effectiveTransition = (_styleState_effectiveTransition = styleState === null || styleState === void 0 ? void 0 : styleState.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition;\n var animationState = isExiting ? \"exit\" : isEntering || justFinishedEntering ? \"enter\" : \"default\";\n var resolved = (0, import_animation_helpers.forAnimationState)((0, import_animation_helpers.resolveTransition)(effectiveTransition, {\n animations\n }), animationState);\n var hasKeys = (0, import_animation_helpers.hasTransition)(resolved);\n var transition;\n var getTransition = function() {\n if (transition !== void 0) return transition;\n var _toCSSTransition;\n transition = (_toCSSTransition = (0, import_animation_helpers.toCSSTransition)(resolved)) !== null && _toCSSTransition !== void 0 ? _toCSSTransition : \"\";\n return transition;\n };\n (0, import_constants.useIsomorphicLayoutEffect)(function() {\n var host = stateRef.current.host;\n if (!sendExitComplete || !isExiting || !host) return;\n var node = host;\n var cycleId = exitCycleIdRef.current;\n if (!exitStartedRef.current) {\n exitStartedRef.current = true;\n emit(\"start\", \"exit\");\n }\n var completeExit = function() {\n var finished = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;\n var _sendExitCompleteRef_current;\n if (cycleId !== exitCycleIdRef.current) return;\n if (exitCompletedRef.current) return;\n exitCompletedRef.current = true;\n if (exitStartedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", finished);\n }\n (_sendExitCompleteRef_current = sendExitCompleteRef.current) === null || _sendExitCompleteRef_current === void 0 ? void 0 : _sendExitCompleteRef_current.call(sendExitCompleteRef);\n };\n if (!hasKeys) {\n completeExit();\n return;\n }\n var rafId;\n var disposed = false;\n var mountedStyle = lastMountedStyleRef.current;\n var canRestart = exitCSSProperties.length > 0 && Object.keys(mountedStyle).length > 0;\n var exitTarget;\n if (canRestart) {\n node.style.transition = \"none\";\n exitTarget = readComputedProperties(node, exitCSSProperties);\n applyCSSProperties(node, mountedStyle);\n void node.offsetHeight;\n rafId = requestAnimationFrame(function() {\n if (cycleId !== exitCycleIdRef.current) return;\n node.style.transition = getTransition();\n void node.offsetHeight;\n applyCSSProperties(node, exitTarget);\n });\n }\n void waitForAnimations(node).then(function(finished) {\n if (!disposed) completeExit(finished);\n });\n return function() {\n disposed = true;\n if (rafId !== void 0) cancelAnimationFrame(rafId);\n clearCSSProperties(node, exitCSSProperties);\n node.style.transition = \"\";\n };\n }, [\n isExiting,\n exitCSSPropertiesSignature\n ]);\n var styleSignature = onTransition ? (function() {\n var { transition: _t, ...rest } = style;\n var _styleState_classNames;\n return `${JSON.stringify((_styleState_classNames = styleState === null || styleState === void 0 ? void 0 : styleState.classNames) !== null && _styleState_classNames !== void 0 ? _styleState_classNames : null)}|${JSON.stringify(rest)}`;\n })() : \"\";\n (0, import_constants.useIsomorphicLayoutEffect)(function() {\n var host = stateRef.current.host;\n if (!onTransitionRef.current || isExiting || !justFinishedEntering || !host) {\n return;\n }\n var node = host;\n var cycleId = ++enterCycleIdRef.current;\n enterStartedRef.current = true;\n emit(\"start\", \"enter\");\n void waitForAnimations(node).then(function(finished) {\n if (cycleId !== enterCycleIdRef.current || !enterStartedRef.current) return;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", finished);\n });\n }, [\n justFinishedEntering,\n isExiting\n ]);\n (0, import_constants.useIsomorphicLayoutEffect)(function() {\n var host = stateRef.current.host;\n if (!onTransitionRef.current || isEntering || justFinishedEntering || isExiting || !host) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (prevUpdateSigRef.current === null) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (styleSignature === prevUpdateSigRef.current) return;\n prevUpdateSigRef.current = styleSignature;\n var node = host;\n if (updateInFlightRef.current) {\n emit(\"end\", \"update\", false);\n }\n updateInFlightRef.current = true;\n var cycleId = ++updateCycleIdRef.current;\n emit(\"start\", \"update\");\n void waitForAnimations(node).then(function(finished) {\n if (cycleId !== updateCycleIdRef.current) return;\n updateInFlightRef.current = false;\n emit(\"end\", \"update\", finished);\n });\n }, [\n styleSignature,\n isEntering,\n justFinishedEntering,\n isExiting\n ]);\n (0, import_constants.useIsomorphicLayoutEffect)(function() {\n if (justStartedExiting && enterStartedRef.current) {\n enterCycleIdRef.current++;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", false);\n }\n if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", false);\n }\n }, [\n justStartedExiting,\n justStoppedExiting\n ]);\n if (isHydrating) {\n return null;\n }\n if (!(0, import_animation_helpers.hasTransition)(resolved)) {\n return null;\n }\n if (Array.isArray(style.transform)) {\n style.transform = (0, import_internal_runtime.transformsToString)(style.transform);\n }\n style.transition = getTransition();\n if (process.env.NODE_ENV === \"development\" && props[\"debug\"] === \"verbose\") {\n console.info(\"CSS animation\", {\n props,\n animations,\n resolved,\n style,\n isEntering,\n isExiting\n });\n }\n return {\n style,\n className: isEntering ? \"t_unmounted\" : \"\"\n };\n }\n };\n}\n//# sourceMappingURL=createAnimations.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,WAAW,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAA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D,IAAI,sBAAsB,gBAAgB,SAAS;KACjD,gBAAgB;KAChB,gBAAgB,UAAU;KAC1B,KAAK,OAAO,SAAS,KAAK;IAC5B;IACA,IAAI,sBAAsB,eAAe,WAAW,CAAC,iBAAiB,SAAS;KAC7E,eAAe,UAAU;KACzB,KAAK,OAAO,QAAQ,KAAK;IAC3B;GACF,GAAG,CACD,oBACA,kBACF,CAAC;GACD,IAAI,aAAa;IACf,OAAO;GACT;GACA,IAAI,EAAE,GAAG,yBAAyB,cAAa,CAAE,QAAQ,GAAG;IAC1D,OAAO;GACT;GACA,IAAI,MAAM,QAAQ,MAAM,SAAS,GAAG;IAClC,MAAM,aAAa,GAAG,wBAAwB,mBAAkB,CAAE,MAAM,SAAS;GACnF;GACA,MAAM,aAAa,cAAc;GACjC,IAAI,QAAQ,IAAI,aAAa,iBAAiB,MAAM,aAAa,WAAW;IAC1E,QAAQ,KAAK,iBAAiB;KAC5B;KACA;KACA;KACA;KACA;KACA;IACF,CAAC;GACH;GACA,OAAO;IACL;IACA,WAAW,aAAa,gBAAgB;GAC1C;EACF;CACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { forAnimationState, hasTransition, resolveTransition, toCSSTransition } from "@tamagui/animation-helpers";
|
|
2
2
|
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
3
3
|
import { ResetPresence, usePresence } from "@tamagui/use-presence";
|
|
4
4
|
import { transformsToString } from "@tamagui/web/internal-runtime";
|
|
@@ -32,11 +32,6 @@ function waitForAnimations(node) {
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
const DURATION_REGEX = /(\d+(?:\.\d+)?)\s*(?:ms|s(?!tiffness))/;
|
|
36
|
-
function applyDurationOverride(animation, durationMs) {
|
|
37
|
-
const replaced = animation.replace(DURATION_REGEX, `${durationMs}ms`);
|
|
38
|
-
return replaced === animation ? `${durationMs}ms ${animation}` : replaced;
|
|
39
|
-
}
|
|
40
35
|
const CSS_TRANSFORM_PROPERTIES = {
|
|
41
36
|
transform: [
|
|
42
37
|
"translate",
|
|
@@ -69,6 +64,7 @@ function getLifecycleCSSProperties(keys) {
|
|
|
69
64
|
if (!keys?.size) return emptyProperties;
|
|
70
65
|
const properties = /* @__PURE__ */ new Set();
|
|
71
66
|
for (const key of keys) {
|
|
67
|
+
if (key === "transition" || key === "transitionProperty") continue;
|
|
72
68
|
for (const property of getCSSProperties(key)) {
|
|
73
69
|
properties.add(hyphenateProperty(property));
|
|
74
70
|
}
|
|
@@ -172,41 +168,13 @@ function createAnimations(animations) {
|
|
|
172
168
|
exitCSSPropertiesSignature
|
|
173
169
|
]);
|
|
174
170
|
const effectiveTransition = styleState?.effectiveTransition ?? props.transition;
|
|
175
|
-
const normalized = normalizeTransition(effectiveTransition);
|
|
176
171
|
const animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default";
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
const animatedProperties = getAnimatedProperties(normalized);
|
|
180
|
-
const hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null;
|
|
181
|
-
const hasPerPropertyConfigs = animatedProperties.length > 0;
|
|
182
|
-
let keys;
|
|
183
|
-
if (props.animateOnly) {
|
|
184
|
-
keys = props.animateOnly;
|
|
185
|
-
} else if (hasPerPropertyConfigs && !hasDefault) {
|
|
186
|
-
keys = animatedProperties;
|
|
187
|
-
} else if (hasPerPropertyConfigs && hasDefault) {
|
|
188
|
-
keys = ["all", ...animatedProperties];
|
|
189
|
-
} else {
|
|
190
|
-
keys = ["all"];
|
|
191
|
-
}
|
|
172
|
+
const resolved = forAnimationState(resolveTransition(effectiveTransition, { animations }), animationState);
|
|
173
|
+
const hasKeys = hasTransition(resolved);
|
|
192
174
|
let transition;
|
|
193
175
|
const getTransition = () => {
|
|
194
176
|
if (transition !== void 0) return transition;
|
|
195
|
-
|
|
196
|
-
const duration = normalized.config?.duration;
|
|
197
|
-
transition = keys.flatMap((key) => {
|
|
198
|
-
const propertyAnimation = normalized.properties[key];
|
|
199
|
-
let animation = defaultAnimation;
|
|
200
|
-
if (typeof propertyAnimation === "string") {
|
|
201
|
-
animation = animations[propertyAnimation];
|
|
202
|
-
} else if (propertyAnimation?.type) {
|
|
203
|
-
animation = animations[propertyAnimation.type];
|
|
204
|
-
}
|
|
205
|
-
if (animation && duration) {
|
|
206
|
-
animation = applyDurationOverride(animation, duration);
|
|
207
|
-
}
|
|
208
|
-
return animation ? getCSSProperties(key).map((property) => `${property} ${animation}${delay}`) : [];
|
|
209
|
-
}).join(", ");
|
|
177
|
+
transition = toCSSTransition(resolved) ?? "";
|
|
210
178
|
return transition;
|
|
211
179
|
};
|
|
212
180
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -228,7 +196,7 @@ function createAnimations(animations) {
|
|
|
228
196
|
}
|
|
229
197
|
sendExitCompleteRef.current?.();
|
|
230
198
|
};
|
|
231
|
-
if (
|
|
199
|
+
if (!hasKeys) {
|
|
232
200
|
completeExit();
|
|
233
201
|
return;
|
|
234
202
|
}
|
|
@@ -322,7 +290,7 @@ function createAnimations(animations) {
|
|
|
322
290
|
if (isHydrating) {
|
|
323
291
|
return null;
|
|
324
292
|
}
|
|
325
|
-
if (!
|
|
293
|
+
if (!hasTransition(resolved)) {
|
|
326
294
|
return null;
|
|
327
295
|
}
|
|
328
296
|
if (Array.isArray(style.transform)) {
|
|
@@ -333,8 +301,7 @@ function createAnimations(animations) {
|
|
|
333
301
|
console.info("CSS animation", {
|
|
334
302
|
props,
|
|
335
303
|
animations,
|
|
336
|
-
|
|
337
|
-
defaultAnimation,
|
|
304
|
+
resolved,
|
|
338
305
|
style,
|
|
339
306
|
isEntering,
|
|
340
307
|
isExiting
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAnimations.js","names":["hasNormalizedAnimation"],"sources":["esm/createAnimations.js"],"sourcesContent":["import {\n normalizeTransition,\n getAnimatedProperties,\n hasAnimation as hasNormalizedAnimation,\n getEffectiveAnimation\n} from \"@tamagui/animation-helpers\";\nimport { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { ResetPresence, usePresence } from \"@tamagui/use-presence\";\nimport { transformsToString } from \"@tamagui/web/internal-runtime\";\nimport React from \"react\";\nconst hasRAF = typeof requestAnimationFrame !== \"undefined\";\nfunction waitForAnimations(node) {\n if (typeof node.getAnimations !== \"function\") {\n return Promise.resolve(true);\n }\n return new Promise((resolve) => {\n const check = () => {\n const animations = node.getAnimations();\n if (animations.length === 0) {\n resolve(true);\n return;\n }\n Promise.all(animations.map((a) => a.finished)).then(() => resolve(true)).catch(() => {\n const remaining = node.getAnimations();\n if (remaining.some((a) => a.playState === \"running\" || a.pending)) {\n check();\n return;\n }\n resolve(false);\n });\n };\n if (hasRAF) {\n requestAnimationFrame(check);\n } else {\n check();\n }\n });\n}\nconst DURATION_REGEX = /(\\d+(?:\\.\\d+)?)\\s*(?:ms|s(?!tiffness))/;\nfunction applyDurationOverride(animation, durationMs) {\n const replaced = animation.replace(DURATION_REGEX, `${durationMs}ms`);\n return replaced === animation ? `${durationMs}ms ${animation}` : replaced;\n}\nconst CSS_TRANSFORM_PROPERTIES = {\n transform: [\"translate\", \"scale\", \"rotate\", \"transform\"],\n x: [\"translate\"],\n y: [\"translate\"],\n scale: [\"scale\"],\n scaleX: [\"scale\"],\n scaleY: [\"scale\"],\n rotate: [\"rotate\"],\n rotateX: [\"transform\"],\n rotateY: [\"transform\"],\n rotateZ: [\"transform\"],\n skewX: [\"transform\"],\n skewY: [\"transform\"]\n};\nconst getCSSProperties = (key) => {\n return CSS_TRANSFORM_PROPERTIES[key] || [key];\n};\nconst hyphenatedPropertyCache = {};\nconst emptyProperties = [];\nfunction hyphenateProperty(property) {\n if (property.startsWith(\"--\")) return property;\n return hyphenatedPropertyCache[property] ||= property.replace(\n /[A-Z]/g,\n (letter) => `-${letter.toLowerCase()}`\n );\n}\nfunction getLifecycleCSSProperties(keys) {\n if (!keys?.size) return emptyProperties;\n const properties = /* @__PURE__ */ new Set();\n for (const key of keys) {\n for (const property of getCSSProperties(key)) {\n properties.add(hyphenateProperty(property));\n }\n }\n return [...properties].sort();\n}\nfunction readComputedProperties(node, properties) {\n const computed = getComputedStyle(node);\n const values = {};\n for (const property of properties) {\n const value = computed.getPropertyValue(property);\n if (value) values[property] = value;\n }\n return values;\n}\nfunction applyCSSProperties(node, values) {\n for (const property in values) {\n node.style.setProperty(property, values[property]);\n }\n}\nfunction clearCSSProperties(node, properties) {\n for (const property of properties) {\n node.style.removeProperty(property);\n }\n}\nfunction createAnimations(animations) {\n return {\n animations,\n usePresence,\n ResetPresence,\n inputStyle: \"css\",\n outputStyle: \"css\",\n // @ts-ignore - styleState is added by createComponent\n useAnimations: ({\n props,\n presence,\n style,\n componentState,\n stateRef,\n styleState,\n onTransition\n }) => {\n const isHydrating = componentState.unmounted === true;\n const isEntering = !!componentState.unmounted;\n const isExiting = presence?.[0] === false;\n const sendExitComplete = presence?.[1];\n const onTransitionRef = React.useRef(onTransition);\n onTransitionRef.current = onTransition;\n const emit = (phase, cause, finished) => {\n onTransitionRef.current?.(\n phase === \"end\" ? { phase, cause, finished } : { phase, cause }\n );\n };\n const wasEnteringRef = React.useRef(isEntering);\n const justFinishedEntering = wasEnteringRef.current && !isEntering;\n React.useEffect(() => {\n wasEnteringRef.current = isEntering;\n });\n const exitCycleIdRef = React.useRef(0);\n const exitCompletedRef = React.useRef(false);\n const wasExitingRef = React.useRef(false);\n const sendExitCompleteRef = React.useRef(sendExitComplete);\n const lastMountedStyleRef = React.useRef({});\n sendExitCompleteRef.current = sendExitComplete;\n const exitCSSProperties = getLifecycleCSSProperties(\n styleState?.programLifecycleStyleKeys?.exit\n );\n const exitCSSPropertiesSignature = exitCSSProperties.join(\"\\0\");\n const enterCycleIdRef = React.useRef(0);\n const enterStartedRef = React.useRef(false);\n const updateCycleIdRef = React.useRef(0);\n const updateInFlightRef = React.useRef(false);\n const prevUpdateSigRef = React.useRef(null);\n const exitStartedRef = React.useRef(false);\n const justStartedExiting = isExiting && !wasExitingRef.current;\n const justStoppedExiting = !isExiting && wasExitingRef.current;\n if (justStartedExiting) {\n exitCycleIdRef.current++;\n exitCompletedRef.current = false;\n }\n if (justStoppedExiting) {\n exitCycleIdRef.current++;\n }\n React.useEffect(() => {\n wasExitingRef.current = isExiting;\n });\n useIsomorphicLayoutEffect(() => {\n if (isExiting) return;\n const host = stateRef.current.host;\n if (!host || !exitCSSProperties.length) {\n lastMountedStyleRef.current = {};\n return;\n }\n const node = host;\n const capture = () => {\n if (stateRef.current.host !== node || wasExitingRef.current) return;\n lastMountedStyleRef.current = readComputedProperties(node, exitCSSProperties);\n };\n if (justFinishedEntering) {\n void waitForAnimations(node).then(capture);\n } else {\n capture();\n }\n }, [isExiting, justFinishedEntering, exitCSSPropertiesSignature]);\n const effectiveTransition = styleState?.effectiveTransition ?? props.transition;\n const normalized = normalizeTransition(effectiveTransition);\n const animationState = isExiting ? \"exit\" : isEntering || justFinishedEntering ? \"enter\" : \"default\";\n const effectiveAnimationKey = getEffectiveAnimation(normalized, animationState);\n const defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null;\n const animatedProperties = getAnimatedProperties(normalized);\n const hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null;\n const hasPerPropertyConfigs = animatedProperties.length > 0;\n let keys;\n if (props.animateOnly) {\n keys = props.animateOnly;\n } else if (hasPerPropertyConfigs && !hasDefault) {\n keys = animatedProperties;\n } else if (hasPerPropertyConfigs && hasDefault) {\n keys = [\"all\", ...animatedProperties];\n } else {\n keys = [\"all\"];\n }\n let transition;\n const getTransition = () => {\n if (transition !== void 0) return transition;\n const delay = normalized.delay ? ` ${normalized.delay}ms` : \"\";\n const duration = normalized.config?.duration;\n transition = keys.flatMap((key) => {\n const propertyAnimation = normalized.properties[key];\n let animation = defaultAnimation;\n if (typeof propertyAnimation === \"string\") {\n animation = animations[propertyAnimation];\n } else if (propertyAnimation?.type) {\n animation = animations[propertyAnimation.type];\n }\n if (animation && duration) {\n animation = applyDurationOverride(animation, duration);\n }\n return animation ? getCSSProperties(key).map(\n (property) => `${property} ${animation}${delay}`\n ) : [];\n }).join(\", \");\n return transition;\n };\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host;\n if (!sendExitComplete || !isExiting || !host) return;\n const node = host;\n const cycleId = exitCycleIdRef.current;\n if (!exitStartedRef.current) {\n exitStartedRef.current = true;\n emit(\"start\", \"exit\");\n }\n const completeExit = (finished = true) => {\n if (cycleId !== exitCycleIdRef.current) return;\n if (exitCompletedRef.current) return;\n exitCompletedRef.current = true;\n if (exitStartedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", finished);\n }\n sendExitCompleteRef.current?.();\n };\n if (keys.length === 0) {\n completeExit();\n return;\n }\n let rafId;\n let disposed = false;\n const mountedStyle = lastMountedStyleRef.current;\n const canRestart = exitCSSProperties.length > 0 && Object.keys(mountedStyle).length > 0;\n let exitTarget;\n if (canRestart) {\n node.style.transition = \"none\";\n exitTarget = readComputedProperties(node, exitCSSProperties);\n applyCSSProperties(node, mountedStyle);\n void node.offsetHeight;\n rafId = requestAnimationFrame(() => {\n if (cycleId !== exitCycleIdRef.current) return;\n node.style.transition = getTransition();\n void node.offsetHeight;\n applyCSSProperties(node, exitTarget);\n });\n }\n void waitForAnimations(node).then((finished) => {\n if (!disposed) completeExit(finished);\n });\n return () => {\n disposed = true;\n if (rafId !== void 0) cancelAnimationFrame(rafId);\n clearCSSProperties(node, exitCSSProperties);\n node.style.transition = \"\";\n };\n }, [isExiting, exitCSSPropertiesSignature]);\n const styleSignature = onTransition ? (() => {\n const { transition: _t, ...rest } = style;\n return `${JSON.stringify(styleState?.classNames ?? null)}|${JSON.stringify(rest)}`;\n })() : \"\";\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host;\n if (!onTransitionRef.current || isExiting || !justFinishedEntering || !host) {\n return;\n }\n const node = host;\n const cycleId = ++enterCycleIdRef.current;\n enterStartedRef.current = true;\n emit(\"start\", \"enter\");\n void waitForAnimations(node).then((finished) => {\n if (cycleId !== enterCycleIdRef.current || !enterStartedRef.current) return;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", finished);\n });\n }, [justFinishedEntering, isExiting]);\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host;\n if (!onTransitionRef.current || isEntering || justFinishedEntering || isExiting || !host) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (prevUpdateSigRef.current === null) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (styleSignature === prevUpdateSigRef.current) return;\n prevUpdateSigRef.current = styleSignature;\n const node = host;\n if (updateInFlightRef.current) {\n emit(\"end\", \"update\", false);\n }\n updateInFlightRef.current = true;\n const cycleId = ++updateCycleIdRef.current;\n emit(\"start\", \"update\");\n void waitForAnimations(node).then((finished) => {\n if (cycleId !== updateCycleIdRef.current) return;\n updateInFlightRef.current = false;\n emit(\"end\", \"update\", finished);\n });\n }, [styleSignature, isEntering, justFinishedEntering, isExiting]);\n useIsomorphicLayoutEffect(() => {\n if (justStartedExiting && enterStartedRef.current) {\n enterCycleIdRef.current++;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", false);\n }\n if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", false);\n }\n }, [justStartedExiting, justStoppedExiting]);\n if (isHydrating) {\n return null;\n }\n if (!hasNormalizedAnimation(normalized)) {\n return null;\n }\n if (Array.isArray(style.transform)) {\n style.transform = transformsToString(style.transform);\n }\n style.transition = getTransition();\n if (process.env.NODE_ENV === \"development\" && props[\"debug\"] === \"verbose\") {\n console.info(\"CSS animation\", {\n props,\n animations,\n normalized,\n defaultAnimation,\n style,\n isEntering,\n isExiting\n });\n }\n return { style, className: isEntering ? \"t_unmounted\" : \"\" };\n }\n };\n}\nexport {\n createAnimations\n};\n//# sourceMappingURL=createAnimations.js.map\n"],"mapp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AAsB;GAAS,CAAC;GAChE,gCAAgC;IAC9B,IAAI,sBAAsB,gBAAgB,SAAS;KACjD,gBAAgB;KAChB,gBAAgB,UAAU;KAC1B,KAAK,OAAO,SAAS,KAAK;IAC5B;IACA,IAAI,sBAAsB,eAAe,WAAW,CAAC,iBAAiB,SAAS;KAC7E,eAAe,UAAU;KACzB,KAAK,OAAO,QAAQ,KAAK;IAC3B;GACF,GAAG,CAAC,oBAAoB,kBAAkB,CAAC;GAC3C,IAAI,aAAa;IACf,OAAO;GACT;GACA,IAAI,CAACA,aAAuB,UAAU,GAAG;IACvC,OAAO;GACT;GACA,IAAI,MAAM,QAAQ,MAAM,SAAS,GAAG;IAClC,MAAM,YAAY,mBAAmB,MAAM,SAAS;GACtD;GACA,MAAM,aAAa,cAAc;GACjC,IAAI,QAAQ,IAAI,aAAa,iBAAiB,MAAM,aAAa,WAAW;IAC1E,QAAQ,KAAK,iBAAiB;KAC5B;KACA;KACA;KACA;KACA;KACA;KACA;IACF,CAAC;GACH;GACA,OAAO;IAAE;IAAO,WAAW,aAAa,gBAAgB;GAAG;EAC7D;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"createAnimations.js","names":[],"sources":["esm/createAnimations.js"],"sourcesContent":["import {\n forAnimationState,\n hasTransition,\n resolveTransition,\n toCSSTransition\n} from \"@tamagui/animation-helpers\";\nimport { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { ResetPresence, usePresence } from \"@tamagui/use-presence\";\nimport { transformsToString } from \"@tamagui/web/internal-runtime\";\nimport React from \"react\";\nconst hasRAF = typeof requestAnimationFrame !== \"undefined\";\nfunction waitForAnimations(node) {\n if (typeof node.getAnimations !== \"function\") {\n return Promise.resolve(true);\n }\n return new Promise((resolve) => {\n const check = () => {\n const animations = node.getAnimations();\n if (animations.length === 0) {\n resolve(true);\n return;\n }\n Promise.all(animations.map((a) => a.finished)).then(() => resolve(true)).catch(() => {\n const remaining = node.getAnimations();\n if (remaining.some((a) => a.playState === \"running\" || a.pending)) {\n check();\n return;\n }\n resolve(false);\n });\n };\n if (hasRAF) {\n requestAnimationFrame(check);\n } else {\n check();\n }\n });\n}\nconst CSS_TRANSFORM_PROPERTIES = {\n transform: [\"translate\", \"scale\", \"rotate\", \"transform\"],\n x: [\"translate\"],\n y: [\"translate\"],\n scale: [\"scale\"],\n scaleX: [\"scale\"],\n scaleY: [\"scale\"],\n rotate: [\"rotate\"],\n rotateX: [\"transform\"],\n rotateY: [\"transform\"],\n rotateZ: [\"transform\"],\n skewX: [\"transform\"],\n skewY: [\"transform\"]\n};\nconst getCSSProperties = (key) => {\n return CSS_TRANSFORM_PROPERTIES[key] || [key];\n};\nconst hyphenatedPropertyCache = {};\nconst emptyProperties = [];\nfunction hyphenateProperty(property) {\n if (property.startsWith(\"--\")) return property;\n return hyphenatedPropertyCache[property] ||= property.replace(\n /[A-Z]/g,\n (letter) => `-${letter.toLowerCase()}`\n );\n}\nfunction getLifecycleCSSProperties(keys) {\n if (!keys?.size) return emptyProperties;\n const properties = /* @__PURE__ */ new Set();\n for (const key of keys) {\n if (key === \"transition\" || key === \"transitionProperty\") continue;\n for (const property of getCSSProperties(key)) {\n properties.add(hyphenateProperty(property));\n }\n }\n return [...properties].sort();\n}\nfunction readComputedProperties(node, properties) {\n const computed = getComputedStyle(node);\n const values = {};\n for (const property of properties) {\n const value = computed.getPropertyValue(property);\n if (value) values[property] = value;\n }\n return values;\n}\nfunction applyCSSProperties(node, values) {\n for (const property in values) {\n node.style.setProperty(property, values[property]);\n }\n}\nfunction clearCSSProperties(node, properties) {\n for (const property of properties) {\n node.style.removeProperty(property);\n }\n}\nfunction createAnimations(animations) {\n return {\n animations,\n usePresence,\n ResetPresence,\n inputStyle: \"css\",\n outputStyle: \"css\",\n // @ts-ignore - styleState is added by createComponent\n useAnimations: ({\n props,\n presence,\n style,\n componentState,\n stateRef,\n styleState,\n onTransition\n }) => {\n const isHydrating = componentState.unmounted === true;\n const isEntering = !!componentState.unmounted;\n const isExiting = presence?.[0] === false;\n const sendExitComplete = presence?.[1];\n const onTransitionRef = React.useRef(onTransition);\n onTransitionRef.current = onTransition;\n const emit = (phase, cause, finished) => {\n onTransitionRef.current?.(\n phase === \"end\" ? { phase, cause, finished } : { phase, cause }\n );\n };\n const wasEnteringRef = React.useRef(isEntering);\n const justFinishedEntering = wasEnteringRef.current && !isEntering;\n React.useEffect(() => {\n wasEnteringRef.current = isEntering;\n });\n const exitCycleIdRef = React.useRef(0);\n const exitCompletedRef = React.useRef(false);\n const wasExitingRef = React.useRef(false);\n const sendExitCompleteRef = React.useRef(sendExitComplete);\n const lastMountedStyleRef = React.useRef({});\n sendExitCompleteRef.current = sendExitComplete;\n const exitCSSProperties = getLifecycleCSSProperties(\n styleState?.programLifecycleStyleKeys?.exit\n );\n const exitCSSPropertiesSignature = exitCSSProperties.join(\"\\0\");\n const enterCycleIdRef = React.useRef(0);\n const enterStartedRef = React.useRef(false);\n const updateCycleIdRef = React.useRef(0);\n const updateInFlightRef = React.useRef(false);\n const prevUpdateSigRef = React.useRef(null);\n const exitStartedRef = React.useRef(false);\n const justStartedExiting = isExiting && !wasExitingRef.current;\n const justStoppedExiting = !isExiting && wasExitingRef.current;\n if (justStartedExiting) {\n exitCycleIdRef.current++;\n exitCompletedRef.current = false;\n }\n if (justStoppedExiting) {\n exitCycleIdRef.current++;\n }\n React.useEffect(() => {\n wasExitingRef.current = isExiting;\n });\n useIsomorphicLayoutEffect(() => {\n if (isExiting) return;\n const host = stateRef.current.host;\n if (!host || !exitCSSProperties.length) {\n lastMountedStyleRef.current = {};\n return;\n }\n const node = host;\n const capture = () => {\n if (stateRef.current.host !== node || wasExitingRef.current) return;\n lastMountedStyleRef.current = readComputedProperties(node, exitCSSProperties);\n };\n if (justFinishedEntering) {\n void waitForAnimations(node).then(capture);\n } else {\n capture();\n }\n }, [isExiting, justFinishedEntering, exitCSSPropertiesSignature]);\n const effectiveTransition = styleState?.effectiveTransition ?? props.transition;\n const animationState = isExiting ? \"exit\" : isEntering || justFinishedEntering ? \"enter\" : \"default\";\n const resolved = forAnimationState(\n resolveTransition(effectiveTransition, {\n animations\n }),\n animationState\n );\n const hasKeys = hasTransition(resolved);\n let transition;\n const getTransition = () => {\n if (transition !== void 0) return transition;\n transition = toCSSTransition(resolved) ?? \"\";\n return transition;\n };\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host;\n if (!sendExitComplete || !isExiting || !host) return;\n const node = host;\n const cycleId = exitCycleIdRef.current;\n if (!exitStartedRef.current) {\n exitStartedRef.current = true;\n emit(\"start\", \"exit\");\n }\n const completeExit = (finished = true) => {\n if (cycleId !== exitCycleIdRef.current) return;\n if (exitCompletedRef.current) return;\n exitCompletedRef.current = true;\n if (exitStartedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", finished);\n }\n sendExitCompleteRef.current?.();\n };\n if (!hasKeys) {\n completeExit();\n return;\n }\n let rafId;\n let disposed = false;\n const mountedStyle = lastMountedStyleRef.current;\n const canRestart = exitCSSProperties.length > 0 && Object.keys(mountedStyle).length > 0;\n let exitTarget;\n if (canRestart) {\n node.style.transition = \"none\";\n exitTarget = readComputedProperties(node, exitCSSProperties);\n applyCSSProperties(node, mountedStyle);\n void node.offsetHeight;\n rafId = requestAnimationFrame(() => {\n if (cycleId !== exitCycleIdRef.current) return;\n node.style.transition = getTransition();\n void node.offsetHeight;\n applyCSSProperties(node, exitTarget);\n });\n }\n void waitForAnimations(node).then((finished) => {\n if (!disposed) completeExit(finished);\n });\n return () => {\n disposed = true;\n if (rafId !== void 0) cancelAnimationFrame(rafId);\n clearCSSProperties(node, exitCSSProperties);\n node.style.transition = \"\";\n };\n }, [isExiting, exitCSSPropertiesSignature]);\n const styleSignature = onTransition ? (() => {\n const { transition: _t, ...rest } = style;\n return `${JSON.stringify(styleState?.classNames ?? null)}|${JSON.stringify(rest)}`;\n })() : \"\";\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host;\n if (!onTransitionRef.current || isExiting || !justFinishedEntering || !host) {\n return;\n }\n const node = host;\n const cycleId = ++enterCycleIdRef.current;\n enterStartedRef.current = true;\n emit(\"start\", \"enter\");\n void waitForAnimations(node).then((finished) => {\n if (cycleId !== enterCycleIdRef.current || !enterStartedRef.current) return;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", finished);\n });\n }, [justFinishedEntering, isExiting]);\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host;\n if (!onTransitionRef.current || isEntering || justFinishedEntering || isExiting || !host) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (prevUpdateSigRef.current === null) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (styleSignature === prevUpdateSigRef.current) return;\n prevUpdateSigRef.current = styleSignature;\n const node = host;\n if (updateInFlightRef.current) {\n emit(\"end\", \"update\", false);\n }\n updateInFlightRef.current = true;\n const cycleId = ++updateCycleIdRef.current;\n emit(\"start\", \"update\");\n void waitForAnimations(node).then((finished) => {\n if (cycleId !== updateCycleIdRef.current) return;\n updateInFlightRef.current = false;\n emit(\"end\", \"update\", finished);\n });\n }, [styleSignature, isEntering, justFinishedEntering, isExiting]);\n useIsomorphicLayoutEffect(() => {\n if (justStartedExiting && enterStartedRef.current) {\n enterCycleIdRef.current++;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", false);\n }\n if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", false);\n }\n }, [justStartedExiting, justStoppedExiting]);\n if (isHydrating) {\n return null;\n }\n if (!hasTransition(resolved)) {\n return null;\n }\n if (Array.isArray(style.transform)) {\n style.transform = transformsToString(style.transform);\n }\n style.transition = getTransition();\n if (process.env.NODE_ENV === \"development\" && props[\"debug\"] === \"verbose\") {\n console.info(\"CSS animation\", {\n props,\n animations,\n resolved,\n style,\n isEntering,\n isExiting\n });\n }\n return { style, className: isEntering ? \"t_unmounted\" : \"\" };\n }\n };\n}\nexport {\n createAnimations\n};\n//# sourceMappingUR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S;KAC7B,KAAK,OAAO,UAAU,KAAK;IAC7B;IACA,kBAAkB,UAAU;IAC5B,MAAM,UAAU,EAAE,iBAAiB;IACnC,KAAK,SAAS,QAAQ;IACtB,KAAK,kBAAkB,IAAI,CAAC,CAAC,MAAM,aAAa;KAC9C,IAAI,YAAY,iBAAiB,SAAS;KAC1C,kBAAkB,UAAU;KAC5B,KAAK,OAAO,UAAU,QAAQ;IAChC,CAAC;GACH,GAAG;IAAC;IAAgB;IAAY;IAAsB;GAAS,CAAC;GAChE,gCAAgC;IAC9B,IAAI,sBAAsB,gBAAgB,SAAS;KACjD,gBAAgB;KAChB,gBAAgB,UAAU;KAC1B,KAAK,OAAO,SAAS,KAAK;IAC5B;IACA,IAAI,sBAAsB,eAAe,WAAW,CAAC,iBAAiB,SAAS;KAC7E,eAAe,UAAU;KACzB,KAAK,OAAO,QAAQ,KAAK;IAC3B;GACF,GAAG,CAAC,oBAAoB,kBAAkB,CAAC;GAC3C,IAAI,aAAa;IACf,OAAO;GACT;GACA,IAAI,CAAC,cAAc,QAAQ,GAAG;IAC5B,OAAO;GACT;GACA,IAAI,MAAM,QAAQ,MAAM,SAAS,GAAG;IAClC,MAAM,YAAY,mBAAmB,MAAM,SAAS;GACtD;GACA,MAAM,aAAa,cAAc;GACjC,IAAI,QAAQ,IAAI,aAAa,iBAAiB,MAAM,aAAa,WAAW;IAC1E,QAAQ,KAAK,iBAAiB;KAC5B;KACA;KACA;KACA;KACA;KACA;IACF,CAAC;GACH;GACA,OAAO;IAAE;IAAO,WAAW,aAAa,gBAAgB;GAAG;EAC7D;CACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { forAnimationState, hasTransition, resolveTransition, toCSSTransition } from "@tamagui/animation-helpers";
|
|
2
2
|
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
3
3
|
import { ResetPresence, usePresence } from "@tamagui/use-presence";
|
|
4
4
|
import { transformsToString } from "@tamagui/web/internal-runtime";
|
|
@@ -38,11 +38,6 @@ function waitForAnimations(node) {
|
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
var DURATION_REGEX = /(\d+(?:\.\d+)?)\s*(?:ms|s(?!tiffness))/;
|
|
42
|
-
function applyDurationOverride(animation, durationMs) {
|
|
43
|
-
var replaced = animation.replace(DURATION_REGEX, `${durationMs}ms`);
|
|
44
|
-
return replaced === animation ? `${durationMs}ms ${animation}` : replaced;
|
|
45
|
-
}
|
|
46
41
|
var CSS_TRANSFORM_PROPERTIES = {
|
|
47
42
|
transform: [
|
|
48
43
|
"translate",
|
|
@@ -81,6 +76,7 @@ function getLifecycleCSSProperties(keys) {
|
|
|
81
76
|
try {
|
|
82
77
|
for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
83
78
|
var key = _step.value;
|
|
79
|
+
if (key === "transition" || key === "transitionProperty") continue;
|
|
84
80
|
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
85
81
|
try {
|
|
86
82
|
for (var _iterator1 = getCSSProperties(key)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
@@ -253,44 +249,14 @@ function createAnimations(animations) {
|
|
|
253
249
|
]);
|
|
254
250
|
var _styleState_effectiveTransition;
|
|
255
251
|
var effectiveTransition = (_styleState_effectiveTransition = styleState === null || styleState === void 0 ? void 0 : styleState.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition;
|
|
256
|
-
var normalized = normalizeTransition(effectiveTransition);
|
|
257
252
|
var animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default";
|
|
258
|
-
var
|
|
259
|
-
var
|
|
260
|
-
var animatedProperties = getAnimatedProperties(normalized);
|
|
261
|
-
var hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null;
|
|
262
|
-
var hasPerPropertyConfigs = animatedProperties.length > 0;
|
|
263
|
-
var keys;
|
|
264
|
-
if (props.animateOnly) {
|
|
265
|
-
keys = props.animateOnly;
|
|
266
|
-
} else if (hasPerPropertyConfigs && !hasDefault) {
|
|
267
|
-
keys = animatedProperties;
|
|
268
|
-
} else if (hasPerPropertyConfigs && hasDefault) {
|
|
269
|
-
keys = ["all", ...animatedProperties];
|
|
270
|
-
} else {
|
|
271
|
-
keys = ["all"];
|
|
272
|
-
}
|
|
253
|
+
var resolved = forAnimationState(resolveTransition(effectiveTransition, { animations }), animationState);
|
|
254
|
+
var hasKeys = hasTransition(resolved);
|
|
273
255
|
var transition;
|
|
274
256
|
var getTransition = function() {
|
|
275
|
-
var _normalized_config;
|
|
276
257
|
if (transition !== void 0) return transition;
|
|
277
|
-
var
|
|
278
|
-
|
|
279
|
-
transition = keys.flatMap(function(key) {
|
|
280
|
-
var propertyAnimation = normalized.properties[key];
|
|
281
|
-
var animation = defaultAnimation;
|
|
282
|
-
if (typeof propertyAnimation === "string") {
|
|
283
|
-
animation = animations[propertyAnimation];
|
|
284
|
-
} else if (propertyAnimation === null || propertyAnimation === void 0 ? void 0 : propertyAnimation.type) {
|
|
285
|
-
animation = animations[propertyAnimation.type];
|
|
286
|
-
}
|
|
287
|
-
if (animation && duration) {
|
|
288
|
-
animation = applyDurationOverride(animation, duration);
|
|
289
|
-
}
|
|
290
|
-
return animation ? getCSSProperties(key).map(function(property) {
|
|
291
|
-
return `${property} ${animation}${delay}`;
|
|
292
|
-
}) : [];
|
|
293
|
-
}).join(", ");
|
|
258
|
+
var _toCSSTransition;
|
|
259
|
+
transition = (_toCSSTransition = toCSSTransition(resolved)) !== null && _toCSSTransition !== void 0 ? _toCSSTransition : "";
|
|
294
260
|
return transition;
|
|
295
261
|
};
|
|
296
262
|
useIsomorphicLayoutEffect(function() {
|
|
@@ -314,7 +280,7 @@ function createAnimations(animations) {
|
|
|
314
280
|
}
|
|
315
281
|
(_sendExitCompleteRef_current = sendExitCompleteRef.current) === null || _sendExitCompleteRef_current === void 0 ? void 0 : _sendExitCompleteRef_current.call(sendExitCompleteRef);
|
|
316
282
|
};
|
|
317
|
-
if (
|
|
283
|
+
if (!hasKeys) {
|
|
318
284
|
completeExit();
|
|
319
285
|
return;
|
|
320
286
|
}
|
|
@@ -409,7 +375,7 @@ function createAnimations(animations) {
|
|
|
409
375
|
if (isHydrating) {
|
|
410
376
|
return null;
|
|
411
377
|
}
|
|
412
|
-
if (!
|
|
378
|
+
if (!hasTransition(resolved)) {
|
|
413
379
|
return null;
|
|
414
380
|
}
|
|
415
381
|
if (Array.isArray(style.transform)) {
|
|
@@ -420,8 +386,7 @@ function createAnimations(animations) {
|
|
|
420
386
|
console.info("CSS animation", {
|
|
421
387
|
props,
|
|
422
388
|
animations,
|
|
423
|
-
|
|
424
|
-
defaultAnimation,
|
|
389
|
+
resolved,
|
|
425
390
|
style,
|
|
426
391
|
isEntering,
|
|
427
392
|
isExiting
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAnimations.native.js","names":["hasNormalizedAnimation"],"sources":["esm/createAnimations.native.js"],"sourcesContent":["import { normalizeTransition, getAnimatedProperties, hasAnimation as hasNormalizedAnimation, getEffectiveAnimation } from \"@tamagui/animation-helpers\";\nimport { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { ResetPresence, usePresence } from \"@tamagui/use-presence\";\nimport { transformsToString } from \"@tamagui/web/internal-runtime\";\nimport React from \"react\";\nvar hasRAF = typeof requestAnimationFrame !== \"undefined\";\nfunction waitForAnimations(node) {\n if (typeof node.getAnimations !== \"function\") {\n return Promise.resolve(true);\n }\n return new Promise(function(resolve) {\n var check = function() {\n var animations = node.getAnimations();\n if (animations.length === 0) {\n resolve(true);\n return;\n }\n Promise.all(animations.map(function(a) {\n return a.finished;\n })).then(function() {\n return resolve(true);\n }).catch(function() {\n var remaining = node.getAnimations();\n if (remaining.some(function(a) {\n return a.playState === \"running\" || a.pending;\n })) {\n check();\n return;\n }\n resolve(false);\n });\n };\n if (hasRAF) {\n requestAnimationFrame(check);\n } else {\n check();\n }\n });\n}\nvar DURATION_REGEX = /(\\d+(?:\\.\\d+)?)\\s*(?:ms|s(?!tiffness))/;\nfunction applyDurationOverride(animation, durationMs) {\n var replaced = animation.replace(DURATION_REGEX, `${durationMs}ms`);\n return replaced === animation ? `${durationMs}ms ${animation}` : replaced;\n}\nvar CSS_TRANSFORM_PROPERTIES = {\n transform: [\n \"translate\",\n \"scale\",\n \"rotate\",\n \"transform\"\n ],\n x: [\n \"translate\"\n ],\n y: [\n \"translate\"\n ],\n scale: [\n \"scale\"\n ],\n scaleX: [\n \"scale\"\n ],\n scaleY: [\n \"scale\"\n ],\n rotate: [\n \"rotate\"\n ],\n rotateX: [\n \"transform\"\n ],\n rotateY: [\n \"transform\"\n ],\n rotateZ: [\n \"transform\"\n ],\n skewX: [\n \"transform\"\n ],\n skewY: [\n \"transform\"\n ]\n};\nvar getCSSProperties = function(key) {\n return CSS_TRANSFORM_PROPERTIES[key] || [\n key\n ];\n};\nvar hyphenatedPropertyCache = {};\nvar emptyProperties = [];\nfunction hyphenateProperty(property) {\n var _hyphenatedPropertyCache, _property;\n if (property.startsWith(\"--\")) return property;\n return (_hyphenatedPropertyCache = hyphenatedPropertyCache)[_property = property] || (_hyphenatedPropertyCache[_property] = property.replace(/[A-Z]/g, function(letter) {\n return `-${letter.toLowerCase()}`;\n }));\n}\nfunction getLifecycleCSSProperties(keys) {\n if (!(keys === null || keys === void 0 ? void 0 : keys.size)) return emptyProperties;\n var properties = /* @__PURE__ */ new Set();\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var key = _step.value;\n var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n try {\n for (var _iterator1 = getCSSProperties(key)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n var property = _step1.value;\n properties.add(hyphenateProperty(property));\n }\n } catch (err) {\n _didIteratorError1 = true;\n _iteratorError1 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion1 && _iterator1.return != null) {\n _iterator1.return();\n }\n } finally {\n if (_didIteratorError1) {\n throw _iteratorError1;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return [\n ...properties\n ].sort();\n}\nfunction readComputedProperties(node, properties) {\n var computed = getComputedStyle(node);\n var values = {};\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = properties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var property = _step.value;\n var value = computed.getPropertyValue(property);\n if (value) values[property] = value;\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return values;\n}\nfunction applyCSSProperties(node, values) {\n for (var property in values) {\n node.style.setProperty(property, values[property]);\n }\n}\nfunction clearCSSProperties(node, properties) {\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = properties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var property = _step.value;\n node.style.removeProperty(property);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n}\nfunction createAnimations(animations) {\n return {\n animations,\n usePresence,\n ResetPresence,\n inputStyle: \"css\",\n outputStyle: \"css\",\n // @ts-ignore - styleState is added by createComponent\n useAnimations: function(param) {\n var { props, presence, style, componentState, stateRef, styleState, onTransition } = param;\n var _styleState_programLifecycleStyleKeys;\n var isHydrating = componentState.unmounted === true;\n var isEntering = !!componentState.unmounted;\n var isExiting = (presence === null || presence === void 0 ? void 0 : presence[0]) === false;\n var sendExitComplete = presence === null || presence === void 0 ? void 0 : presence[1];\n var onTransitionRef = React.useRef(onTransition);\n onTransitionRef.current = onTransition;\n var emit = function(phase, cause, finished) {\n var _onTransitionRef_current;\n (_onTransitionRef_current = onTransitionRef.current) === null || _onTransitionRef_current === void 0 ? void 0 : _onTransitionRef_current.call(onTransitionRef, phase === \"end\" ? {\n phase,\n cause,\n finished\n } : {\n phase,\n cause\n });\n };\n var wasEnteringRef = React.useRef(isEntering);\n var justFinishedEntering = wasEnteringRef.current && !isEntering;\n React.useEffect(function() {\n wasEnteringRef.current = isEntering;\n });\n var exitCycleIdRef = React.useRef(0);\n var exitCompletedRef = React.useRef(false);\n var wasExitingRef = React.useRef(false);\n var sendExitCompleteRef = React.useRef(sendExitComplete);\n var lastMountedStyleRef = React.useRef({});\n sendExitCompleteRef.current = sendExitComplete;\n var exitCSSProperties = getLifecycleCSSProperties(styleState === null || styleState === void 0 ? void 0 : (_styleState_programLifecycleStyleKeys = styleState.programLifecycleStyleKeys) === null || _styleState_programLifecycleStyleKeys === void 0 ? void 0 : _styleState_programLifecycleStyleKeys.exit);\n var exitCSSPropertiesSignature = exitCSSProperties.join(\"\\0\");\n var enterCycleIdRef = React.useRef(0);\n var enterStartedRef = React.useRef(false);\n var updateCycleIdRef = React.useRef(0);\n var updateInFlightRef = React.useRef(false);\n var prevUpdateSigRef = React.useRef(null);\n var exitStartedRef = React.useRef(false);\n var justStartedExiting = isExiting && !wasExitingRef.current;\n var justStoppedExiting = !isExiting && wasExitingRef.current;\n if (justStartedExiting) {\n exitCycleIdRef.current++;\n exitCompletedRef.current = false;\n }\n if (justStoppedExiting) {\n exitCycleIdRef.current++;\n }\n React.useEffect(function() {\n wasExitingRef.current = isExiting;\n });\n useIsomorphicLayoutEffect(function() {\n if (isExiting) return;\n var host = stateRef.current.host;\n if (!host || !exitCSSProperties.length) {\n lastMountedStyleRef.current = {};\n return;\n }\n var node = host;\n var capture = function() {\n if (stateRef.current.host !== node || wasExitingRef.current) return;\n lastMountedStyleRef.current = readComputedProperties(node, exitCSSProperties);\n };\n if (justFinishedEntering) {\n void waitForAnimations(node).then(capture);\n } else {\n capture();\n }\n }, [\n isExiting,\n justFinishedEntering,\n exitCSSPropertiesSignature\n ]);\n var _styleState_effectiveTransition;\n var effectiveTransition = (_styleState_effectiveTransition = styleState === null || styleState === void 0 ? void 0 : styleState.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition;\n var normalized = normalizeTransition(effectiveTransition);\n var animationState = isExiting ? \"exit\" : isEntering || justFinishedEntering ? \"enter\" : \"default\";\n var effectiveAnimationKey = getEffectiveAnimation(normalized, animationState);\n var defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null;\n var animatedProperties = getAnimatedProperties(normalized);\n var hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null;\n var hasPerPropertyConfigs = animatedProperties.length > 0;\n var keys;\n if (props.animateOnly) {\n keys = props.animateOnly;\n } else if (hasPerPropertyConfigs && !hasDefault) {\n keys = animatedProperties;\n } else if (hasPerPropertyConfigs && hasDefault) {\n keys = [\n \"all\",\n ...animatedProperties\n ];\n } else {\n keys = [\n \"all\"\n ];\n }\n var transition;\n var getTransition = function() {\n var _normalized_config;\n if (transition !== void 0) return transition;\n var delay = normalized.delay ? ` ${normalized.delay}ms` : \"\";\n var duration = (_normalized_config = normalized.config) === null || _normalized_config === void 0 ? void 0 : _normalized_config.duration;\n transition = keys.flatMap(function(key) {\n var propertyAnimation = normalized.properties[key];\n var animation = defaultAnimation;\n if (typeof propertyAnimation === \"string\") {\n animation = animations[propertyAnimation];\n } else if (propertyAnimation === null || propertyAnimation === void 0 ? void 0 : propertyAnimation.type) {\n animation = animations[propertyAnimation.type];\n }\n if (animation && duration) {\n animation = applyDurationOverride(animation, duration);\n }\n return animation ? getCSSProperties(key).map(function(property) {\n return `${property} ${animation}${delay}`;\n }) : [];\n }).join(\", \");\n return transition;\n };\n useIsomorphicLayoutEffect(function() {\n var host = stateRef.current.host;\n if (!sendExitComplete || !isExiting || !host) return;\n var node = host;\n var cycleId = exitCycleIdRef.current;\n if (!exitStartedRef.current) {\n exitStartedRef.current = true;\n emit(\"start\", \"exit\");\n }\n var completeExit = function() {\n var finished = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;\n var _sendExitCompleteRef_current;\n if (cycleId !== exitCycleIdRef.current) return;\n if (exitCompletedRef.current) return;\n exitCompletedRef.current = true;\n if (exitStartedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", finished);\n }\n (_sendExitCompleteRef_current = sendExitCompleteRef.current) === null || _sendExitCompleteRef_current === void 0 ? void 0 : _sendExitCompleteRef_current.call(sendExitCompleteRef);\n };\n if (keys.length === 0) {\n completeExit();\n return;\n }\n var rafId;\n var disposed = false;\n var mountedStyle = lastMountedStyleRef.current;\n var canRestart = exitCSSProperties.length > 0 && Object.keys(mountedStyle).length > 0;\n var exitTarget;\n if (canRestart) {\n node.style.transition = \"none\";\n exitTarget = readComputedProperties(node, exitCSSProperties);\n applyCSSProperties(node, mountedStyle);\n void node.offsetHeight;\n rafId = requestAnimationFrame(function() {\n if (cycleId !== exitCycleIdRef.current) return;\n node.style.transition = getTransition();\n void node.offsetHeight;\n applyCSSProperties(node, exitTarget);\n });\n }\n void waitForAnimations(node).then(function(finished) {\n if (!disposed) completeExit(finished);\n });\n return function() {\n disposed = true;\n if (rafId !== void 0) cancelAnimationFrame(rafId);\n clearCSSProperties(node, exitCSSProperties);\n node.style.transition = \"\";\n };\n }, [\n isExiting,\n exitCSSPropertiesSignature\n ]);\n var styleSignature = onTransition ? (function() {\n var { transition: _t, ...rest } = style;\n var _styleState_classNames;\n return `${JSON.stringify((_styleState_classNames = styleState === null || styleState === void 0 ? void 0 : styleState.classNames) !== null && _styleState_classNames !== void 0 ? _styleState_classNames : null)}|${JSON.stringify(rest)}`;\n })() : \"\";\n useIsomorphicLayoutEffect(function() {\n var host = stateRef.current.host;\n if (!onTransitionRef.current || isExiting || !justFinishedEntering || !host) {\n return;\n }\n var node = host;\n var cycleId = ++enterCycleIdRef.current;\n enterStartedRef.current = true;\n emit(\"start\", \"enter\");\n void waitForAnimations(node).then(function(finished) {\n if (cycleId !== enterCycleIdRef.current || !enterStartedRef.current) return;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", finished);\n });\n }, [\n justFinishedEntering,\n isExiting\n ]);\n useIsomorphicLayoutEffect(function() {\n var host = stateRef.current.host;\n if (!onTransitionRef.current || isEntering || justFinishedEntering || isExiting || !host) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (prevUpdateSigRef.current === null) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (styleSignature === prevUpdateSigRef.current) return;\n prevUpdateSigRef.current = styleSignature;\n var node = host;\n if (updateInFlightRef.current) {\n emit(\"end\", \"update\", false);\n }\n updateInFlightRef.current = true;\n var cycleId = ++updateCycleIdRef.current;\n emit(\"start\", \"update\");\n void waitForAnimations(node).then(function(finished) {\n if (cycleId !== updateCycleIdRef.current) return;\n updateInFlightRef.current = false;\n emit(\"end\", \"update\", finished);\n });\n }, [\n styleSignature,\n isEntering,\n justFinishedEntering,\n isExiting\n ]);\n useIsomorphicLayoutEffect(function() {\n if (justStartedExiting && enterStartedRef.current) {\n enterCycleIdRef.current++;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", false);\n }\n if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", false);\n }\n }, [\n justStartedExiting,\n justStoppedExiting\n ]);\n if (isHydrating) {\n return null;\n }\n if (!hasNormalizedAnimation(normalized)) {\n return null;\n }\n if (Array.isArray(style.transform)) {\n style.transform = transformsToString(style.transform);\n }\n style.transition = getTransition();\n if (process.env.NODE_ENV === \"development\" && props[\"debug\"] === \"verbose\") {\n console.info(\"CSS animation\", {\n props,\n animations,\n normalized,\n defaultAnimation,\n style,\n isEntering,\n isExiting\n });\n }\n return {\n style,\n className: isEntering ? \"t_unmounted\" : \"\"\n };\n }\n };\n}\nexport {\n createAnimations\n};\n//# sourceMappingURL=createAnimations.js.map\n"],"mappings":";;;;;;;AAKA,IAAI,SAAS,OAAO,0BAA0B;AAC9C,SAAS,kBAAkB,MAAM;CAC/B,IAAI,OAAO,KAAK,kBAAkB,YAAY;EAC5C,OAAO,QAAQ,QAAQ,IAAI;CAC7B;CACA,OAAO,IAAI,QAAQ,SAAS,SAAS;EACnC,IAAI,QAAQ,WAAW;GACrB,IAAI,aAAa,KAAK,cAAc;GACpC,IAAI,WAAW,WAAW,GAAG;IAC3B,QAAQ,IAAI;IACZ;GACF;GACA,QAAQ,IAAI,WAAW,IAAI,SAAS,GAAG;IACrC,OAAO,EAAE;GACX,CAAC,CAAC,CAAC,CAAC,KAAK,WAAW;IAClB,OAAO,QAAQ,IAAI;GACrB,CAAC,CAAC,CAAC,MAAM,WAAW;IAClB,IAAI,YAAY,KAAK,cAAc;IACnC,IAAI,UAAU,KAAK,SAAS,GAAG;KAC7B,OAAO,EAAE,cAAc,aAAa,EAAE;IACxC,CAAC,GAAG;KACF,MAAM;KACN;IACF;IACA,QAAQ,KAAK;GACf,CAAC;EACH;EACA,IAAI,QAAQ;GACV,sBAAsB,KAAK;EAC7B,OAAO;GACL,MAAM;EACR;CACF,CAAC;AACH;AACA,IAAI,iBAAiB;AACrB,SAAS,sBAAsB,WAAW,YAAY;CACpD,IAAI,WAAW,UAAU,QA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":"createAnimations.native.js","names":[],"sources":["esm/createAnimations.native.js"],"sourcesContent":["import { forAnimationState, hasTransition, resolveTransition, toCSSTransition } from \"@tamagui/animation-helpers\";\nimport { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { ResetPresence, usePresence } from \"@tamagui/use-presence\";\nimport { transformsToString } from \"@tamagui/web/internal-runtime\";\nimport React from \"react\";\nvar hasRAF = typeof requestAnimationFrame !== \"undefined\";\nfunction waitForAnimations(node) {\n if (typeof node.getAnimations !== \"function\") {\n return Promise.resolve(true);\n }\n return new Promise(function(resolve) {\n var check = function() {\n var animations = node.getAnimations();\n if (animations.length === 0) {\n resolve(true);\n return;\n }\n Promise.all(animations.map(function(a) {\n return a.finished;\n })).then(function() {\n return resolve(true);\n }).catch(function() {\n var remaining = node.getAnimations();\n if (remaining.some(function(a) {\n return a.playState === \"running\" || a.pending;\n })) {\n check();\n return;\n }\n resolve(false);\n });\n };\n if (hasRAF) {\n requestAnimationFrame(check);\n } else {\n check();\n }\n });\n}\nvar CSS_TRANSFORM_PROPERTIES = {\n transform: [\n \"translate\",\n \"scale\",\n \"rotate\",\n \"transform\"\n ],\n x: [\n \"translate\"\n ],\n y: [\n \"translate\"\n ],\n scale: [\n \"scale\"\n ],\n scaleX: [\n \"scale\"\n ],\n scaleY: [\n \"scale\"\n ],\n rotate: [\n \"rotate\"\n ],\n rotateX: [\n \"transform\"\n ],\n rotateY: [\n \"transform\"\n ],\n rotateZ: [\n \"transform\"\n ],\n skewX: [\n \"transform\"\n ],\n skewY: [\n \"transform\"\n ]\n};\nvar getCSSProperties = function(key) {\n return CSS_TRANSFORM_PROPERTIES[key] || [\n key\n ];\n};\nvar hyphenatedPropertyCache = {};\nvar emptyProperties = [];\nfunction hyphenateProperty(property) {\n var _hyphenatedPropertyCache, _property;\n if (property.startsWith(\"--\")) return property;\n return (_hyphenatedPropertyCache = hyphenatedPropertyCache)[_property = property] || (_hyphenatedPropertyCache[_property] = property.replace(/[A-Z]/g, function(letter) {\n return `-${letter.toLowerCase()}`;\n }));\n}\nfunction getLifecycleCSSProperties(keys) {\n if (!(keys === null || keys === void 0 ? void 0 : keys.size)) return emptyProperties;\n var properties = /* @__PURE__ */ new Set();\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var key = _step.value;\n if (key === \"transition\" || key === \"transitionProperty\") continue;\n var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n try {\n for (var _iterator1 = getCSSProperties(key)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n var property = _step1.value;\n properties.add(hyphenateProperty(property));\n }\n } catch (err) {\n _didIteratorError1 = true;\n _iteratorError1 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion1 && _iterator1.return != null) {\n _iterator1.return();\n }\n } finally {\n if (_didIteratorError1) {\n throw _iteratorError1;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return [\n ...properties\n ].sort();\n}\nfunction readComputedProperties(node, properties) {\n var computed = getComputedStyle(node);\n var values = {};\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = properties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var property = _step.value;\n var value = computed.getPropertyValue(property);\n if (value) values[property] = value;\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return values;\n}\nfunction applyCSSProperties(node, values) {\n for (var property in values) {\n node.style.setProperty(property, values[property]);\n }\n}\nfunction clearCSSProperties(node, properties) {\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = properties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var property = _step.value;\n node.style.removeProperty(property);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n}\nfunction createAnimations(animations) {\n return {\n animations,\n usePresence,\n ResetPresence,\n inputStyle: \"css\",\n outputStyle: \"css\",\n // @ts-ignore - styleState is added by createComponent\n useAnimations: function(param) {\n var { props, presence, style, componentState, stateRef, styleState, onTransition } = param;\n var _styleState_programLifecycleStyleKeys;\n var isHydrating = componentState.unmounted === true;\n var isEntering = !!componentState.unmounted;\n var isExiting = (presence === null || presence === void 0 ? void 0 : presence[0]) === false;\n var sendExitComplete = presence === null || presence === void 0 ? void 0 : presence[1];\n var onTransitionRef = React.useRef(onTransition);\n onTransitionRef.current = onTransition;\n var emit = function(phase, cause, finished) {\n var _onTransitionRef_current;\n (_onTransitionRef_current = onTransitionRef.current) === null || _onTransitionRef_current === void 0 ? void 0 : _onTransitionRef_current.call(onTransitionRef, phase === \"end\" ? {\n phase,\n cause,\n finished\n } : {\n phase,\n cause\n });\n };\n var wasEnteringRef = React.useRef(isEntering);\n var justFinishedEntering = wasEnteringRef.current && !isEntering;\n React.useEffect(function() {\n wasEnteringRef.current = isEntering;\n });\n var exitCycleIdRef = React.useRef(0);\n var exitCompletedRef = React.useRef(false);\n var wasExitingRef = React.useRef(false);\n var sendExitCompleteRef = React.useRef(sendExitComplete);\n var lastMountedStyleRef = React.useRef({});\n sendExitCompleteRef.current = sendExitComplete;\n var exitCSSProperties = getLifecycleCSSProperties(styleState === null || styleState === void 0 ? void 0 : (_styleState_programLifecycleStyleKeys = styleState.programLifecycleStyleKeys) === null || _styleState_programLifecycleStyleKeys === void 0 ? void 0 : _styleState_programLifecycleStyleKeys.exit);\n var exitCSSPropertiesSignature = exitCSSProperties.join(\"\\0\");\n var enterCycleIdRef = React.useRef(0);\n var enterStartedRef = React.useRef(false);\n var updateCycleIdRef = React.useRef(0);\n var updateInFlightRef = React.useRef(false);\n var prevUpdateSigRef = React.useRef(null);\n var exitStartedRef = React.useRef(false);\n var justStartedExiting = isExiting && !wasExitingRef.current;\n var justStoppedExiting = !isExiting && wasExitingRef.current;\n if (justStartedExiting) {\n exitCycleIdRef.current++;\n exitCompletedRef.current = false;\n }\n if (justStoppedExiting) {\n exitCycleIdRef.current++;\n }\n React.useEffect(function() {\n wasExitingRef.current = isExiting;\n });\n useIsomorphicLayoutEffect(function() {\n if (isExiting) return;\n var host = stateRef.current.host;\n if (!host || !exitCSSProperties.length) {\n lastMountedStyleRef.current = {};\n return;\n }\n var node = host;\n var capture = function() {\n if (stateRef.current.host !== node || wasExitingRef.current) return;\n lastMountedStyleRef.current = readComputedProperties(node, exitCSSProperties);\n };\n if (justFinishedEntering) {\n void waitForAnimations(node).then(capture);\n } else {\n capture();\n }\n }, [\n isExiting,\n justFinishedEntering,\n exitCSSPropertiesSignature\n ]);\n var _styleState_effectiveTransition;\n var effectiveTransition = (_styleState_effectiveTransition = styleState === null || styleState === void 0 ? void 0 : styleState.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition;\n var animationState = isExiting ? \"exit\" : isEntering || justFinishedEntering ? \"enter\" : \"default\";\n var resolved = forAnimationState(resolveTransition(effectiveTransition, {\n animations\n }), animationState);\n var hasKeys = hasTransition(resolved);\n var transition;\n var getTransition = function() {\n if (transition !== void 0) return transition;\n var _toCSSTransition;\n transition = (_toCSSTransition = toCSSTransition(resolved)) !== null && _toCSSTransition !== void 0 ? _toCSSTransition : \"\";\n return transition;\n };\n useIsomorphicLayoutEffect(function() {\n var host = stateRef.current.host;\n if (!sendExitComplete || !isExiting || !host) return;\n var node = host;\n var cycleId = exitCycleIdRef.current;\n if (!exitStartedRef.current) {\n exitStartedRef.current = true;\n emit(\"start\", \"exit\");\n }\n var completeExit = function() {\n var finished = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;\n var _sendExitCompleteRef_current;\n if (cycleId !== exitCycleIdRef.current) return;\n if (exitCompletedRef.current) return;\n exitCompletedRef.current = true;\n if (exitStartedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", finished);\n }\n (_sendExitCompleteRef_current = sendExitCompleteRef.current) === null || _sendExitCompleteRef_current === void 0 ? void 0 : _sendExitCompleteRef_current.call(sendExitCompleteRef);\n };\n if (!hasKeys) {\n completeExit();\n return;\n }\n var rafId;\n var disposed = false;\n var mountedStyle = lastMountedStyleRef.current;\n var canRestart = exitCSSProperties.length > 0 && Object.keys(mountedStyle).length > 0;\n var exitTarget;\n if (canRestart) {\n node.style.transition = \"none\";\n exitTarget = readComputedProperties(node, exitCSSProperties);\n applyCSSProperties(node, mountedStyle);\n void node.offsetHeight;\n rafId = requestAnimationFrame(function() {\n if (cycleId !== exitCycleIdRef.current) return;\n node.style.transition = getTransition();\n void node.offsetHeight;\n applyCSSProperties(node, exitTarget);\n });\n }\n void waitForAnimations(node).then(function(finished) {\n if (!disposed) completeExit(finished);\n });\n return function() {\n disposed = true;\n if (rafId !== void 0) cancelAnimationFrame(rafId);\n clearCSSProperties(node, exitCSSProperties);\n node.style.transition = \"\";\n };\n }, [\n isExiting,\n exitCSSPropertiesSignature\n ]);\n var styleSignature = onTransition ? (function() {\n var { transition: _t, ...rest } = style;\n var _styleState_classNames;\n return `${JSON.stringify((_styleState_classNames = styleState === null || styleState === void 0 ? void 0 : styleState.classNames) !== null && _styleState_classNames !== void 0 ? _styleState_classNames : null)}|${JSON.stringify(rest)}`;\n })() : \"\";\n useIsomorphicLayoutEffect(function() {\n var host = stateRef.current.host;\n if (!onTransitionRef.current || isExiting || !justFinishedEntering || !host) {\n return;\n }\n var node = host;\n var cycleId = ++enterCycleIdRef.current;\n enterStartedRef.current = true;\n emit(\"start\", \"enter\");\n void waitForAnimations(node).then(function(finished) {\n if (cycleId !== enterCycleIdRef.current || !enterStartedRef.current) return;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", finished);\n });\n }, [\n justFinishedEntering,\n isExiting\n ]);\n useIsomorphicLayoutEffect(function() {\n var host = stateRef.current.host;\n if (!onTransitionRef.current || isEntering || justFinishedEntering || isExiting || !host) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (prevUpdateSigRef.current === null) {\n prevUpdateSigRef.current = styleSignature;\n return;\n }\n if (styleSignature === prevUpdateSigRef.current) return;\n prevUpdateSigRef.current = styleSignature;\n var node = host;\n if (updateInFlightRef.current) {\n emit(\"end\", \"update\", false);\n }\n updateInFlightRef.current = true;\n var cycleId = ++updateCycleIdRef.current;\n emit(\"start\", \"update\");\n void waitForAnimations(node).then(function(finished) {\n if (cycleId !== updateCycleIdRef.current) return;\n updateInFlightRef.current = false;\n emit(\"end\", \"update\", finished);\n });\n }, [\n styleSignature,\n isEntering,\n justFinishedEntering,\n isExiting\n ]);\n useIsomorphicLayoutEffect(function() {\n if (justStartedExiting && enterStartedRef.current) {\n enterCycleIdRef.current++;\n enterStartedRef.current = false;\n emit(\"end\", \"enter\", false);\n }\n if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {\n exitStartedRef.current = false;\n emit(\"end\", \"exit\", false);\n }\n }, [\n justStartedExiting,\n justStoppedExiting\n ]);\n if (isHydrating) {\n return null;\n }\n if (!hasTransition(resolved)) {\n return null;\n }\n if (Array.isArray(style.transform)) {\n style.transform = transformsToString(style.transform);\n }\n style.transition = getTransition();\n if (process.env.NODE_ENV === \"development\" && props[\"debug\"] === \"verbose\") {\n console.info(\"CSS animation\", {\n props,\n animations,\n resolved,\n style,\n isEntering,\n isExiting\n });\n }\n return {\n style,\n className: isEntering ? \"t_unmounted\" : \"\"\n };\n }\n };\n}\nexport {\n createAnimations\n};\n//# sourceMappingURL=createAnimations.js.map\n"],"mappings":";;;;;;;AAKA,IAAI,SAAS,OAAO,0BAA0B;AAC9C,SAAS,kBAAkB,MAAM;CAC/B,IAAI,OAAO,KAAK,kBAAkB,YAAY;EAC5C,OAAO,QAAQ,QAAQ,IAAI;CAC7B;CACA,OAAO,IAAI,QAAQ,SAAS,SAAS;EACnC,IAAI,QAAQ,WAAW;GACrB,IAAI,aAAa,KAAK,cAAc;GACpC,IAAI,WAAW,WAAW,GAAG;IAC3B,QAAQ,IAAI;IACZ;GACF;GACA,QAAQ,IAAI,WAAW,IAAI,SAAS,GAAG;IACrC,OAAO,EAAE;GACX,CAAC,CAAC,CAAC,CAAC,KAAK,WAAW;IAClB,OAAO,QAAQ,IAAI;GACrB,CAAC,CAAC,CAAC,MAAM,WAAW;IAClB,IAAI,YAAY,KAAK,cAAc;IACnC,IAAI,UAAU,KAAK,SAAS,GAAG;KAC7B,OAAO,EAAE,cAAc,aAAa,EAAE;IACxC,CAAC,GAAG;KACF,MAAM;KACN;IACF;IACA,QAAQ,KAAK;GACf,CAAC;EACH;EACA,IAAI,QAAQ;GACV,sBAAsB,KAAK;EAC7B,OAAO;GACL,MAAM;EACR;CACF,CAAC;AACH;AACA,IAAI,2BAA2B;CAC7B,WAAW;EACT;EACA;EACA;EACA;CACF;CACA,GAAG,CACD,WACF;CACA,GAAG,CACD,WACF;CACA,OAAO,CACL,OACF;CACA,QAAQ,CACN,OACF;CACA,QAAQ,CACN,OACF;CACA,QAAQ,CACN,QACF;CACA,SAAS,CACP,WACF;CACA,SAAS,CACP,WACF;CACA,SAAS,CACP,WACF;CACA,OAAO,CACL,WACF;CACA,OAAO,CACL,WACF;AACF;AACA,IAAI,mBAAmB,SAAS,KAAK;CACnC,OAAO,yBAAyB,QAAQ,CACtC,GACF;AACF;AACA,IAAI,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
|
+
"version": "3.0.0",
|
|
4
4
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -54,14 +54,14 @@
|
|
|
54
54
|
"clean:build": "tamagui-build clean:build"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@tamagui/animation-helpers": "3.0.0
|
|
58
|
-
"@tamagui/constants": "3.0.0
|
|
59
|
-
"@tamagui/cubic-bezier-animator": "3.0.0
|
|
60
|
-
"@tamagui/use-presence": "3.0.0
|
|
61
|
-
"@tamagui/web": "3.0.0
|
|
57
|
+
"@tamagui/animation-helpers": "3.0.0",
|
|
58
|
+
"@tamagui/constants": "3.0.0",
|
|
59
|
+
"@tamagui/cubic-bezier-animator": "3.0.0",
|
|
60
|
+
"@tamagui/use-presence": "3.0.0",
|
|
61
|
+
"@tamagui/web": "3.0.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@tamagui/build": "3.0.0
|
|
64
|
+
"@tamagui/build": "3.0.0",
|
|
65
65
|
"react": "19.2.3",
|
|
66
66
|
"react-dom": "19.2.3"
|
|
67
67
|
},
|
|
@@ -73,5 +73,6 @@
|
|
|
73
73
|
"type": "git",
|
|
74
74
|
"url": "git+https://github.com/tamagui/tamagui.git",
|
|
75
75
|
"directory": "code/core/animations-css"
|
|
76
|
-
}
|
|
76
|
+
},
|
|
77
|
+
"releaseSourceCommit": "15fbca480b143f876f6975601e23a17d3f90d2ee"
|
|
77
78
|
}
|
package/src/createAnimations.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
forAnimationState,
|
|
3
|
+
hasTransition,
|
|
4
|
+
resolveTransition,
|
|
5
|
+
toCSSTransition,
|
|
6
|
+
type AnimationsConfig,
|
|
6
7
|
} from '@tamagui/animation-helpers'
|
|
7
8
|
import { useIsomorphicLayoutEffect } from '@tamagui/constants'
|
|
8
9
|
import { ResetPresence, usePresence } from '@tamagui/use-presence'
|
|
@@ -53,17 +54,6 @@ function waitForAnimations(node: HTMLElement): Promise<boolean> {
|
|
|
53
54
|
})
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
const DURATION_REGEX = /(\d+(?:\.\d+)?)\s*(?:ms|s(?!tiffness))/
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Apply duration override to a CSS animation string
|
|
60
|
-
* Replaces the existing duration with the override value
|
|
61
|
-
*/
|
|
62
|
-
function applyDurationOverride(animation: string, durationMs: number): string {
|
|
63
|
-
const replaced = animation.replace(DURATION_REGEX, `${durationMs}ms`)
|
|
64
|
-
return replaced === animation ? `${durationMs}ms ${animation}` : replaced
|
|
65
|
-
}
|
|
66
|
-
|
|
67
57
|
const CSS_TRANSFORM_PROPERTIES: Record<string, string[]> = {
|
|
68
58
|
transform: ['translate', 'scale', 'rotate', 'transform'],
|
|
69
59
|
x: ['translate'],
|
|
@@ -98,6 +88,8 @@ function getLifecycleCSSProperties(keys: Set<string> | undefined): string[] {
|
|
|
98
88
|
if (!keys?.size) return emptyProperties
|
|
99
89
|
const properties = new Set<string>()
|
|
100
90
|
for (const key of keys) {
|
|
91
|
+
// timing clauses configure the transition, not its destination properties.
|
|
92
|
+
if (key === 'transition' || key === 'transitionProperty') continue
|
|
101
93
|
for (const property of getCSSProperties(key)) {
|
|
102
94
|
properties.add(hyphenateProperty(property))
|
|
103
95
|
}
|
|
@@ -130,7 +122,9 @@ function clearCSSProperties(node: HTMLElement, properties: readonly string[]): v
|
|
|
130
122
|
}
|
|
131
123
|
}
|
|
132
124
|
|
|
133
|
-
export function createAnimations<A extends
|
|
125
|
+
export function createAnimations<A extends AnimationsConfig>(
|
|
126
|
+
animations: A
|
|
127
|
+
): AnimationDriver<A> {
|
|
134
128
|
return {
|
|
135
129
|
animations,
|
|
136
130
|
usePresence,
|
|
@@ -241,72 +235,28 @@ export function createAnimations<A extends object>(animations: A): AnimationDriv
|
|
|
241
235
|
// use effectiveTransition computed by createComponent (single source of truth)
|
|
242
236
|
const effectiveTransition = styleState?.effectiveTransition ?? props.transition
|
|
243
237
|
|
|
244
|
-
//
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
// Determine animation state and get effective animation
|
|
248
|
-
// Use 'enter' if we're entering OR if we just finished entering (transition is happening)
|
|
238
|
+
// one parser, one preset lookup, one spring solver, shared with the other
|
|
239
|
+
// three drivers. this driver decides nothing about what a transition means.
|
|
249
240
|
const animationState = isExiting
|
|
250
241
|
? 'exit'
|
|
251
242
|
: isEntering || justFinishedEntering
|
|
252
243
|
? 'enter'
|
|
253
244
|
: 'default'
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
//
|
|
262
|
-
// -
|
|
263
|
-
|
|
264
|
-
const hasDefault =
|
|
265
|
-
normalized.default !== null ||
|
|
266
|
-
normalized.enter !== null ||
|
|
267
|
-
normalized.exit !== null
|
|
268
|
-
const hasPerPropertyConfigs = animatedProperties.length > 0
|
|
269
|
-
|
|
270
|
-
let keys: string[]
|
|
271
|
-
if (props.animateOnly) {
|
|
272
|
-
// animateOnly is explicit filter
|
|
273
|
-
keys = props.animateOnly
|
|
274
|
-
} else if (hasPerPropertyConfigs && !hasDefault) {
|
|
275
|
-
// object format without default: { opacity: '200ms' } = only animate opacity
|
|
276
|
-
keys = animatedProperties
|
|
277
|
-
} else if (hasPerPropertyConfigs && hasDefault) {
|
|
278
|
-
// array format or object with default: 'all' first, then per-property overrides
|
|
279
|
-
// CSS transition specificity: later declarations override earlier ones for the same property
|
|
280
|
-
keys = ['all', ...animatedProperties]
|
|
281
|
-
} else {
|
|
282
|
-
// simple string format: 'quick' = animate all
|
|
283
|
-
keys = ['all']
|
|
284
|
-
}
|
|
245
|
+
const resolved = forAnimationState(
|
|
246
|
+
resolveTransition(effectiveTransition, {
|
|
247
|
+
animations: animations as Record<string, unknown>,
|
|
248
|
+
}),
|
|
249
|
+
animationState
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
// the entries stand as authored; the browser resolves them under css
|
|
253
|
+
// last-wins, and narrowing to a property list is `transitionProperty`
|
|
254
|
+
const hasKeys = hasTransition(resolved)
|
|
285
255
|
|
|
286
256
|
let transition: string | undefined
|
|
287
257
|
const getTransition = () => {
|
|
288
258
|
if (transition !== undefined) return transition
|
|
289
|
-
|
|
290
|
-
const duration = normalized.config?.duration
|
|
291
|
-
transition = keys
|
|
292
|
-
.flatMap((key) => {
|
|
293
|
-
const propertyAnimation = normalized.properties[key]
|
|
294
|
-
let animation = defaultAnimation
|
|
295
|
-
if (typeof propertyAnimation === 'string') {
|
|
296
|
-
animation = animations[propertyAnimation]
|
|
297
|
-
} else if (propertyAnimation?.type) {
|
|
298
|
-
animation = animations[propertyAnimation.type]
|
|
299
|
-
}
|
|
300
|
-
if (animation && duration) {
|
|
301
|
-
animation = applyDurationOverride(animation, duration)
|
|
302
|
-
}
|
|
303
|
-
return animation
|
|
304
|
-
? getCSSProperties(key).map(
|
|
305
|
-
(property) => `${property} ${animation}${delay}`
|
|
306
|
-
)
|
|
307
|
-
: []
|
|
308
|
-
})
|
|
309
|
-
.join(', ')
|
|
259
|
+
transition = toCSSTransition(resolved) ?? ''
|
|
310
260
|
return transition
|
|
311
261
|
}
|
|
312
262
|
|
|
@@ -338,8 +288,8 @@ export function createAnimations<A extends object>(animations: A): AnimationDriv
|
|
|
338
288
|
sendExitCompleteRef.current?.()
|
|
339
289
|
}
|
|
340
290
|
|
|
341
|
-
// if no properties
|
|
342
|
-
if (
|
|
291
|
+
// if no properties animate (`transition="none"`), complete immediately
|
|
292
|
+
if (!hasKeys) {
|
|
343
293
|
completeExit()
|
|
344
294
|
return
|
|
345
295
|
}
|
|
@@ -476,7 +426,7 @@ export function createAnimations<A extends object>(animations: A): AnimationDriv
|
|
|
476
426
|
}
|
|
477
427
|
|
|
478
428
|
// Check if we have any animation to apply
|
|
479
|
-
if (!
|
|
429
|
+
if (!hasTransition(resolved)) {
|
|
480
430
|
return null
|
|
481
431
|
}
|
|
482
432
|
|
|
@@ -490,8 +440,7 @@ export function createAnimations<A extends object>(animations: A): AnimationDriv
|
|
|
490
440
|
console.info('CSS animation', {
|
|
491
441
|
props,
|
|
492
442
|
animations,
|
|
493
|
-
|
|
494
|
-
defaultAnimation,
|
|
443
|
+
resolved,
|
|
495
444
|
style,
|
|
496
445
|
isEntering,
|
|
497
446
|
isExiting,
|
package/src/extras.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AnimationsConfig } from '@tamagui/animation-helpers'
|
|
1
2
|
import type { AnimationDriverWithAnimatedNumbers } from '@tamagui/web'
|
|
2
3
|
|
|
3
4
|
import {
|
|
@@ -10,7 +11,7 @@ import { createAnimations as createCoreAnimations } from './createAnimations'
|
|
|
10
11
|
|
|
11
12
|
export * from './animated-number'
|
|
12
13
|
|
|
13
|
-
export function createAnimations<A extends
|
|
14
|
+
export function createAnimations<A extends AnimationsConfig>(
|
|
14
15
|
animations: A
|
|
15
16
|
): AnimationDriverWithAnimatedNumbers<A> {
|
|
16
17
|
return {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { type AnimationsConfig } from "@tamagui/animation-helpers";
|
|
1
2
|
import type { AnimationDriver } from "@tamagui/web";
|
|
2
|
-
export declare function createAnimations<A extends
|
|
3
|
+
export declare function createAnimations<A extends AnimationsConfig>(animations: A): AnimationDriver<A>;
|
|
3
4
|
|
|
4
5
|
//# sourceMappingURL=createAnimations.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "
|
|
2
|
+
"mappings": "AAAA,cAKO,wBACA;AAGP,cAAc,uBAAuB;AAmHrC,OAAO,iBAAS,iBAAiB,UAAU,kBACzC,YAAY,IACX,gBAAgB",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/createAnimations.tsx"
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"import {\n normalizeTransition,\n getAnimatedProperties,\n hasAnimation as hasNormalizedAnimation,\n getEffectiveAnimation,\n} from '@tamagui/animation-helpers'\nimport { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { ResetPresence, usePresence } from '@tamagui/use-presence'\nimport type { AnimationDriver } from '@tamagui/web'\nimport { transformsToString } from '@tamagui/web/internal-runtime'\nimport React from 'react'\n\n// rAF-driven animated number is browser-only. read (don't call) at module scope\n// so ssr never touches requestAnimationFrame.\nconst hasRAF = typeof requestAnimationFrame !== 'undefined'\n\n// resolve once all WAAPI animations on `node` finish. mirrors base-ui's\n// useAnimationsFinished: resolves immediately when the browser exposes no\n// animations (zero-animation elements), and re-checks after an aborted\n// animation in case a property it depended on changed mid-flight and started a\n// new one. falls back to immediate resolve when getAnimations is unavailable\n// (ssr / older webviews). resolves `false` when animations were canceled with\n// nothing left running (interruption).\nfunction waitForAnimations(node: HTMLElement): Promise<boolean> {\n if (typeof node.getAnimations !== 'function') {\n return Promise.resolve(true)\n }\n return new Promise<boolean>((resolve) => {\n const check = () => {\n const animations = node.getAnimations()\n if (animations.length === 0) {\n resolve(true)\n return\n }\n Promise.all(animations.map((a) => a.finished))\n .then(() => resolve(true))\n .catch(() => {\n const remaining = node.getAnimations()\n if (remaining.some((a) => a.playState === 'running' || a.pending)) {\n check()\n return\n }\n resolve(false)\n })\n }\n // css transitions register as pending until the next style recalc, so give\n // the browser one frame to start them before we read getAnimations.\n if (hasRAF) {\n requestAnimationFrame(check)\n } else {\n check()\n }\n })\n}\n\nconst DURATION_REGEX = /(\\d+(?:\\.\\d+)?)\\s*(?:ms|s(?!tiffness))/\n\n/**\n * Apply duration override to a CSS animation string\n * Replaces the existing duration with the override value\n */\nfunction applyDurationOverride(animation: string, durationMs: number): string {\n const replaced = animation.replace(DURATION_REGEX, `${durationMs}ms`)\n return replaced === animation ? `${durationMs}ms ${animation}` : replaced\n}\n\nconst CSS_TRANSFORM_PROPERTIES: Record<string, string[]> = {\n transform: ['translate', 'scale', 'rotate', 'transform'],\n x: ['translate'],\n y: ['translate'],\n scale: ['scale'],\n scaleX: ['scale'],\n scaleY: ['scale'],\n rotate: ['rotate'],\n rotateX: ['transform'],\n rotateY: ['transform'],\n rotateZ: ['transform'],\n skewX: ['transform'],\n skewY: ['transform'],\n}\n\nconst getCSSProperties = (key: string) => {\n return CSS_TRANSFORM_PROPERTIES[key] || [key]\n}\n\nconst hyphenatedPropertyCache: Record<string, string> = {}\nconst emptyProperties: string[] = []\n\nfunction hyphenateProperty(property: string): string {\n if (property.startsWith('--')) return property\n return (hyphenatedPropertyCache[property] ||= property.replace(\n /[A-Z]/g,\n (letter) => `-${letter.toLowerCase()}`\n ))\n}\n\nfunction getLifecycleCSSProperties(keys: Set<string> | undefined): string[] {\n if (!keys?.size) return emptyProperties\n const properties = new Set<string>()\n for (const key of keys) {\n for (const property of getCSSProperties(key)) {\n properties.add(hyphenateProperty(property))\n }\n }\n return [...properties].sort()\n}\n\nfunction readComputedProperties(\n node: HTMLElement,\n properties: readonly string[]\n): Record<string, string> {\n const computed = getComputedStyle(node)\n const values: Record<string, string> = {}\n for (const property of properties) {\n const value = computed.getPropertyValue(property)\n if (value) values[property] = value\n }\n return values\n}\n\nfunction applyCSSProperties(node: HTMLElement, values: Record<string, string>): void {\n for (const property in values) {\n node.style.setProperty(property, values[property])\n }\n}\n\nfunction clearCSSProperties(node: HTMLElement, properties: readonly string[]): void {\n for (const property of properties) {\n node.style.removeProperty(property)\n }\n}\n\nexport function createAnimations<A extends object>(animations: A): AnimationDriver<A> {\n return {\n animations,\n usePresence,\n ResetPresence,\n inputStyle: 'css',\n outputStyle: 'css',\n\n // @ts-ignore - styleState is added by createComponent\n useAnimations: ({\n props,\n presence,\n style,\n componentState,\n stateRef,\n styleState,\n onTransition,\n }: any) => {\n const isHydrating = componentState.unmounted === true\n const isEntering = !!componentState.unmounted\n const isExiting = presence?.[0] === false\n const sendExitComplete = presence?.[1]\n const onTransitionRef = React.useRef(onTransition)\n onTransitionRef.current = onTransition\n const emit = (\n phase: 'start' | 'end',\n cause: 'enter' | 'exit' | 'update',\n finished?: boolean\n ) => {\n onTransitionRef.current?.(\n phase === 'end' ? { phase, cause, finished } : { phase, cause }\n )\n }\n\n // Track if we just finished entering (transition from entering to not entering)\n // This is needed because the CSS transition happens on the render AFTER t_unmounted is removed\n const wasEnteringRef = React.useRef(isEntering)\n const justFinishedEntering = wasEnteringRef.current && !isEntering\n React.useEffect(() => {\n wasEnteringRef.current = isEntering\n })\n\n // exit cycle guards to prevent stale/duplicate completion\n const exitCycleIdRef = React.useRef(0)\n const exitCompletedRef = React.useRef(false)\n const wasExitingRef = React.useRef(false)\n const sendExitCompleteRef = React.useRef(sendExitComplete)\n const lastMountedStyleRef = React.useRef<Record<string, string>>({})\n sendExitCompleteRef.current = sendExitComplete\n\n const exitCSSProperties = getLifecycleCSSProperties(\n styleState?.programLifecycleStyleKeys?.exit\n )\n const exitCSSPropertiesSignature = exitCSSProperties.join('\\0')\n\n // onTransition lifecycle bookkeeping (independent from presence completion)\n const enterCycleIdRef = React.useRef(0)\n const enterStartedRef = React.useRef(false)\n const updateCycleIdRef = React.useRef(0)\n const updateInFlightRef = React.useRef(false)\n const prevUpdateSigRef = React.useRef<string | null>(null)\n const exitStartedRef = React.useRef(false)\n\n // detect transition into/out of exiting state\n const justStartedExiting = isExiting && !wasExitingRef.current\n const justStoppedExiting = !isExiting && wasExitingRef.current\n\n // start new exit cycle only on transition INTO exiting\n if (justStartedExiting) {\n exitCycleIdRef.current++\n exitCompletedRef.current = false\n }\n if (justStoppedExiting) {\n exitCycleIdRef.current++\n }\n\n // track previous exiting state\n React.useEffect(() => {\n wasExitingRef.current = isExiting\n })\n\n // Snapshot the actual mounted CSS values for every property with an exit\n // clause. Most program values live in generated classes rather than the\n // inline `style` object, so computed style is the only complete source.\n // The snapshot becomes the reset point for normal and interrupted exits.\n useIsomorphicLayoutEffect(() => {\n if (isExiting) return\n const host = stateRef.current.host\n if (!host || !exitCSSProperties.length) {\n lastMountedStyleRef.current = {}\n return\n }\n const node = host as HTMLElement\n const capture = () => {\n if (stateRef.current.host !== node || wasExitingRef.current) return\n lastMountedStyleRef.current = readComputedProperties(node, exitCSSProperties)\n }\n\n // The first mounted layout effect can run while an enter clause is still\n // active. Capture again after that concrete transition settles so a later\n // exit restarts from the mounted value, not the enter value.\n if (justFinishedEntering) {\n void waitForAnimations(node).then(capture)\n } else {\n capture()\n }\n }, [isExiting, justFinishedEntering, exitCSSPropertiesSignature])\n\n // use effectiveTransition computed by createComponent (single source of truth)\n const effectiveTransition = styleState?.effectiveTransition ?? props.transition\n\n // Normalize the transition prop to a consistent format\n const normalized = normalizeTransition(effectiveTransition)\n\n // Determine animation state and get effective animation\n // Use 'enter' if we're entering OR if we just finished entering (transition is happening)\n const animationState = isExiting\n ? 'exit'\n : isEntering || justFinishedEntering\n ? 'enter'\n : 'default'\n const effectiveAnimationKey = getEffectiveAnimation(normalized, animationState)\n const defaultAnimation = effectiveAnimationKey\n ? animations[effectiveAnimationKey]\n : null\n const animatedProperties = getAnimatedProperties(normalized)\n\n // Determine which properties to animate\n // - animateOnly prop is an exclusive filter (only animate those properties)\n // - per-property configs WITHOUT a default = only animate those specific properties\n // - per-property configs WITH a default = per-property overrides + default for rest\n const hasDefault =\n normalized.default !== null ||\n normalized.enter !== null ||\n normalized.exit !== null\n const hasPerPropertyConfigs = animatedProperties.length > 0\n\n let keys: string[]\n if (props.animateOnly) {\n // animateOnly is explicit filter\n keys = props.animateOnly\n } else if (hasPerPropertyConfigs && !hasDefault) {\n // object format without default: { opacity: '200ms' } = only animate opacity\n keys = animatedProperties\n } else if (hasPerPropertyConfigs && hasDefault) {\n // array format or object with default: 'all' first, then per-property overrides\n // CSS transition specificity: later declarations override earlier ones for the same property\n keys = ['all', ...animatedProperties]\n } else {\n // simple string format: 'quick' = animate all\n keys = ['all']\n }\n\n let transition: string | undefined\n const getTransition = () => {\n if (transition !== undefined) return transition\n const delay = normalized.delay ? ` ${normalized.delay}ms` : ''\n const duration = normalized.config?.duration\n transition = keys\n .flatMap((key) => {\n const propertyAnimation = normalized.properties[key]\n let animation = defaultAnimation\n if (typeof propertyAnimation === 'string') {\n animation = animations[propertyAnimation]\n } else if (propertyAnimation?.type) {\n animation = animations[propertyAnimation.type]\n }\n if (animation && duration) {\n animation = applyDurationOverride(animation, duration)\n }\n return animation\n ? getCSSProperties(key).map(\n (property) => `${property} ${animation}${delay}`\n )\n : []\n })\n .join(', ')\n return transition\n }\n\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host\n if (!sendExitComplete || !isExiting || !host) return\n const node = host as HTMLElement\n\n // capture current cycle id for this effect\n const cycleId = exitCycleIdRef.current\n\n // emit exit start once per cycle\n if (!exitStartedRef.current) {\n exitStartedRef.current = true\n emit('start', 'exit')\n }\n\n // helper to complete exit with guards. the exit 'end' event fires\n // immediately before presence safeToRemove so users can observe exit\n // completion without reaching into presence internals.\n const completeExit = (finished = true) => {\n if (cycleId !== exitCycleIdRef.current) return\n if (exitCompletedRef.current) return\n exitCompletedRef.current = true\n if (exitStartedRef.current) {\n exitStartedRef.current = false\n emit('end', 'exit', finished)\n }\n sendExitCompleteRef.current?.()\n }\n\n // if no properties to animate (animateOnly=[]), complete immediately\n if (keys.length === 0) {\n completeExit()\n return\n }\n\n // React can apply the exit class in the same render batch as the\n // transition. Restart from the last mounted computed values so normal\n // and interrupted exits both produce a concrete browser transition.\n let rafId: number | undefined\n let disposed = false\n\n const mountedStyle = lastMountedStyleRef.current\n const canRestart =\n exitCSSProperties.length > 0 && Object.keys(mountedStyle).length > 0\n let exitTarget: Record<string, string> | undefined\n if (canRestart) {\n node.style.transition = 'none'\n // With transitions disabled, the exit classes expose their final\n // targets immediately. Capture those, then restore the mounted values.\n exitTarget = readComputedProperties(node, exitCSSProperties)\n applyCSSProperties(node, mountedStyle)\n void node.offsetHeight\n rafId = requestAnimationFrame(() => {\n if (cycleId !== exitCycleIdRef.current) return\n node.style.transition = getTransition()\n void node.offsetHeight\n applyCSSProperties(node, exitTarget!)\n })\n }\n\n // wait for the browser's concrete animations. this covers `all`,\n // transform aliases, delays, and concurrent WAAPI animations without\n // guessing property names or maintaining a duration timer.\n void waitForAnimations(node).then((finished) => {\n if (!disposed) completeExit(finished)\n })\n\n return () => {\n disposed = true\n if (rafId !== undefined) cancelAnimationFrame(rafId)\n clearCSSProperties(node, exitCSSProperties)\n // restore transition: the exit handling sets node.style.transition='none'\n // directly on the DOM (bypassing React). if exit is interrupted (e.g. same-key\n // re-entry in AnimatePresence), React won't re-apply its managed transition\n // value because it hasn't changed in the virtual DOM. clearing the inline\n // override lets React's value take effect again.\n node.style.transition = ''\n }\n }, [isExiting, exitCSSPropertiesSignature])\n\n // signature of the animatable style, so the update effect can detect\n // in-place style changes. the css driver applies most style values as\n // atomic classNames (not inline style), so the signature must include the\n // className map. only computed when a listener is attached.\n const styleSignature = onTransition\n ? (() => {\n const { transition: _t, ...rest } = style\n return `${JSON.stringify(styleState?.classNames ?? null)}|${JSON.stringify(rest)}`\n })()\n : ''\n\n // enter lifecycle: emit start when the enter transition kicks off, end\n // once every animation on the node finishes (getAnimations-based, resolves\n // immediately for zero-animation elements). the promise outlives benign\n // re-renders because it keys off the cycle id, not the effect lifetime.\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host\n if (!onTransitionRef.current || isExiting || !justFinishedEntering || !host) {\n return\n }\n const node = host as HTMLElement\n const cycleId = ++enterCycleIdRef.current\n enterStartedRef.current = true\n emit('start', 'enter')\n void waitForAnimations(node).then((finished) => {\n if (cycleId !== enterCycleIdRef.current || !enterStartedRef.current) return\n enterStartedRef.current = false\n emit('end', 'enter', finished)\n })\n }, [justFinishedEntering, isExiting])\n\n // update lifecycle: a style change while mounted (not entering or exiting).\n // a new update that supersedes an in-flight one emits end(finished:false).\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host\n if (\n !onTransitionRef.current ||\n isEntering ||\n justFinishedEntering ||\n isExiting ||\n !host\n ) {\n // keep the signature current so leaving enter/exit isn't seen as an update\n prevUpdateSigRef.current = styleSignature\n return\n }\n if (prevUpdateSigRef.current === null) {\n prevUpdateSigRef.current = styleSignature\n return\n }\n if (styleSignature === prevUpdateSigRef.current) return\n prevUpdateSigRef.current = styleSignature\n\n const node = host as HTMLElement\n if (updateInFlightRef.current) {\n emit('end', 'update', false)\n }\n updateInFlightRef.current = true\n const cycleId = ++updateCycleIdRef.current\n emit('start', 'update')\n void waitForAnimations(node).then((finished) => {\n if (cycleId !== updateCycleIdRef.current) return\n updateInFlightRef.current = false\n emit('end', 'update', finished)\n })\n }, [styleSignature, isEntering, justFinishedEntering, isExiting])\n\n // interruption: emit a finished:false end for an enter canceled by an exit,\n // or an exit canceled by a re-enter (before its own completion fired).\n useIsomorphicLayoutEffect(() => {\n if (justStartedExiting && enterStartedRef.current) {\n enterCycleIdRef.current++\n enterStartedRef.current = false\n emit('end', 'enter', false)\n }\n if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {\n exitStartedRef.current = false\n emit('end', 'exit', false)\n }\n }, [justStartedExiting, justStoppedExiting])\n\n // tamagui doesnt even use animation output during hydration\n if (isHydrating) {\n return null\n }\n\n // Check if we have any animation to apply\n if (!hasNormalizedAnimation(normalized)) {\n return null\n }\n\n if (Array.isArray(style.transform)) {\n style.transform = transformsToString(style.transform)\n }\n\n style.transition = getTransition()\n\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n console.info('CSS animation', {\n props,\n animations,\n normalized,\n defaultAnimation,\n style,\n isEntering,\n isExiting,\n })\n }\n\n return { style, className: isEntering ? 't_unmounted' : '' }\n },\n }\n}\n"
|
|
9
|
+
"import {\n forAnimationState,\n hasTransition,\n resolveTransition,\n toCSSTransition,\n type AnimationsConfig,\n} from '@tamagui/animation-helpers'\nimport { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { ResetPresence, usePresence } from '@tamagui/use-presence'\nimport type { AnimationDriver } from '@tamagui/web'\nimport { transformsToString } from '@tamagui/web/internal-runtime'\nimport React from 'react'\n\n// rAF-driven animated number is browser-only. read (don't call) at module scope\n// so ssr never touches requestAnimationFrame.\nconst hasRAF = typeof requestAnimationFrame !== 'undefined'\n\n// resolve once all WAAPI animations on `node` finish. mirrors base-ui's\n// useAnimationsFinished: resolves immediately when the browser exposes no\n// animations (zero-animation elements), and re-checks after an aborted\n// animation in case a property it depended on changed mid-flight and started a\n// new one. falls back to immediate resolve when getAnimations is unavailable\n// (ssr / older webviews). resolves `false` when animations were canceled with\n// nothing left running (interruption).\nfunction waitForAnimations(node: HTMLElement): Promise<boolean> {\n if (typeof node.getAnimations !== 'function') {\n return Promise.resolve(true)\n }\n return new Promise<boolean>((resolve) => {\n const check = () => {\n const animations = node.getAnimations()\n if (animations.length === 0) {\n resolve(true)\n return\n }\n Promise.all(animations.map((a) => a.finished))\n .then(() => resolve(true))\n .catch(() => {\n const remaining = node.getAnimations()\n if (remaining.some((a) => a.playState === 'running' || a.pending)) {\n check()\n return\n }\n resolve(false)\n })\n }\n // css transitions register as pending until the next style recalc, so give\n // the browser one frame to start them before we read getAnimations.\n if (hasRAF) {\n requestAnimationFrame(check)\n } else {\n check()\n }\n })\n}\n\nconst CSS_TRANSFORM_PROPERTIES: Record<string, string[]> = {\n transform: ['translate', 'scale', 'rotate', 'transform'],\n x: ['translate'],\n y: ['translate'],\n scale: ['scale'],\n scaleX: ['scale'],\n scaleY: ['scale'],\n rotate: ['rotate'],\n rotateX: ['transform'],\n rotateY: ['transform'],\n rotateZ: ['transform'],\n skewX: ['transform'],\n skewY: ['transform'],\n}\n\nconst getCSSProperties = (key: string) => {\n return CSS_TRANSFORM_PROPERTIES[key] || [key]\n}\n\nconst hyphenatedPropertyCache: Record<string, string> = {}\nconst emptyProperties: string[] = []\n\nfunction hyphenateProperty(property: string): string {\n if (property.startsWith('--')) return property\n return (hyphenatedPropertyCache[property] ||= property.replace(\n /[A-Z]/g,\n (letter) => `-${letter.toLowerCase()}`\n ))\n}\n\nfunction getLifecycleCSSProperties(keys: Set<string> | undefined): string[] {\n if (!keys?.size) return emptyProperties\n const properties = new Set<string>()\n for (const key of keys) {\n // timing clauses configure the transition, not its destination properties.\n if (key === 'transition' || key === 'transitionProperty') continue\n for (const property of getCSSProperties(key)) {\n properties.add(hyphenateProperty(property))\n }\n }\n return [...properties].sort()\n}\n\nfunction readComputedProperties(\n node: HTMLElement,\n properties: readonly string[]\n): Record<string, string> {\n const computed = getComputedStyle(node)\n const values: Record<string, string> = {}\n for (const property of properties) {\n const value = computed.getPropertyValue(property)\n if (value) values[property] = value\n }\n return values\n}\n\nfunction applyCSSProperties(node: HTMLElement, values: Record<string, string>): void {\n for (const property in values) {\n node.style.setProperty(property, values[property])\n }\n}\n\nfunction clearCSSProperties(node: HTMLElement, properties: readonly string[]): void {\n for (const property of properties) {\n node.style.removeProperty(property)\n }\n}\n\nexport function createAnimations<A extends AnimationsConfig>(\n animations: A\n): AnimationDriver<A> {\n return {\n animations,\n usePresence,\n ResetPresence,\n inputStyle: 'css',\n outputStyle: 'css',\n\n // @ts-ignore - styleState is added by createComponent\n useAnimations: ({\n props,\n presence,\n style,\n componentState,\n stateRef,\n styleState,\n onTransition,\n }: any) => {\n const isHydrating = componentState.unmounted === true\n const isEntering = !!componentState.unmounted\n const isExiting = presence?.[0] === false\n const sendExitComplete = presence?.[1]\n const onTransitionRef = React.useRef(onTransition)\n onTransitionRef.current = onTransition\n const emit = (\n phase: 'start' | 'end',\n cause: 'enter' | 'exit' | 'update',\n finished?: boolean\n ) => {\n onTransitionRef.current?.(\n phase === 'end' ? { phase, cause, finished } : { phase, cause }\n )\n }\n\n // Track if we just finished entering (transition from entering to not entering)\n // This is needed because the CSS transition happens on the render AFTER t_unmounted is removed\n const wasEnteringRef = React.useRef(isEntering)\n const justFinishedEntering = wasEnteringRef.current && !isEntering\n React.useEffect(() => {\n wasEnteringRef.current = isEntering\n })\n\n // exit cycle guards to prevent stale/duplicate completion\n const exitCycleIdRef = React.useRef(0)\n const exitCompletedRef = React.useRef(false)\n const wasExitingRef = React.useRef(false)\n const sendExitCompleteRef = React.useRef(sendExitComplete)\n const lastMountedStyleRef = React.useRef<Record<string, string>>({})\n sendExitCompleteRef.current = sendExitComplete\n\n const exitCSSProperties = getLifecycleCSSProperties(\n styleState?.programLifecycleStyleKeys?.exit\n )\n const exitCSSPropertiesSignature = exitCSSProperties.join('\\0')\n\n // onTransition lifecycle bookkeeping (independent from presence completion)\n const enterCycleIdRef = React.useRef(0)\n const enterStartedRef = React.useRef(false)\n const updateCycleIdRef = React.useRef(0)\n const updateInFlightRef = React.useRef(false)\n const prevUpdateSigRef = React.useRef<string | null>(null)\n const exitStartedRef = React.useRef(false)\n\n // detect transition into/out of exiting state\n const justStartedExiting = isExiting && !wasExitingRef.current\n const justStoppedExiting = !isExiting && wasExitingRef.current\n\n // start new exit cycle only on transition INTO exiting\n if (justStartedExiting) {\n exitCycleIdRef.current++\n exitCompletedRef.current = false\n }\n if (justStoppedExiting) {\n exitCycleIdRef.current++\n }\n\n // track previous exiting state\n React.useEffect(() => {\n wasExitingRef.current = isExiting\n })\n\n // Snapshot the actual mounted CSS values for every property with an exit\n // clause. Most program values live in generated classes rather than the\n // inline `style` object, so computed style is the only complete source.\n // The snapshot becomes the reset point for normal and interrupted exits.\n useIsomorphicLayoutEffect(() => {\n if (isExiting) return\n const host = stateRef.current.host\n if (!host || !exitCSSProperties.length) {\n lastMountedStyleRef.current = {}\n return\n }\n const node = host as HTMLElement\n const capture = () => {\n if (stateRef.current.host !== node || wasExitingRef.current) return\n lastMountedStyleRef.current = readComputedProperties(node, exitCSSProperties)\n }\n\n // The first mounted layout effect can run while an enter clause is still\n // active. Capture again after that concrete transition settles so a later\n // exit restarts from the mounted value, not the enter value.\n if (justFinishedEntering) {\n void waitForAnimations(node).then(capture)\n } else {\n capture()\n }\n }, [isExiting, justFinishedEntering, exitCSSPropertiesSignature])\n\n // use effectiveTransition computed by createComponent (single source of truth)\n const effectiveTransition = styleState?.effectiveTransition ?? props.transition\n\n // one parser, one preset lookup, one spring solver, shared with the other\n // three drivers. this driver decides nothing about what a transition means.\n const animationState = isExiting\n ? 'exit'\n : isEntering || justFinishedEntering\n ? 'enter'\n : 'default'\n const resolved = forAnimationState(\n resolveTransition(effectiveTransition, {\n animations: animations as Record<string, unknown>,\n }),\n animationState\n )\n\n // the entries stand as authored; the browser resolves them under css\n // last-wins, and narrowing to a property list is `transitionProperty`\n const hasKeys = hasTransition(resolved)\n\n let transition: string | undefined\n const getTransition = () => {\n if (transition !== undefined) return transition\n transition = toCSSTransition(resolved) ?? ''\n return transition\n }\n\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host\n if (!sendExitComplete || !isExiting || !host) return\n const node = host as HTMLElement\n\n // capture current cycle id for this effect\n const cycleId = exitCycleIdRef.current\n\n // emit exit start once per cycle\n if (!exitStartedRef.current) {\n exitStartedRef.current = true\n emit('start', 'exit')\n }\n\n // helper to complete exit with guards. the exit 'end' event fires\n // immediately before presence safeToRemove so users can observe exit\n // completion without reaching into presence internals.\n const completeExit = (finished = true) => {\n if (cycleId !== exitCycleIdRef.current) return\n if (exitCompletedRef.current) return\n exitCompletedRef.current = true\n if (exitStartedRef.current) {\n exitStartedRef.current = false\n emit('end', 'exit', finished)\n }\n sendExitCompleteRef.current?.()\n }\n\n // if no properties animate (`transition=\"none\"`), complete immediately\n if (!hasKeys) {\n completeExit()\n return\n }\n\n // React can apply the exit class in the same render batch as the\n // transition. Restart from the last mounted computed values so normal\n // and interrupted exits both produce a concrete browser transition.\n let rafId: number | undefined\n let disposed = false\n\n const mountedStyle = lastMountedStyleRef.current\n const canRestart =\n exitCSSProperties.length > 0 && Object.keys(mountedStyle).length > 0\n let exitTarget: Record<string, string> | undefined\n if (canRestart) {\n node.style.transition = 'none'\n // With transitions disabled, the exit classes expose their final\n // targets immediately. Capture those, then restore the mounted values.\n exitTarget = readComputedProperties(node, exitCSSProperties)\n applyCSSProperties(node, mountedStyle)\n void node.offsetHeight\n rafId = requestAnimationFrame(() => {\n if (cycleId !== exitCycleIdRef.current) return\n node.style.transition = getTransition()\n void node.offsetHeight\n applyCSSProperties(node, exitTarget!)\n })\n }\n\n // wait for the browser's concrete animations. this covers `all`,\n // transform aliases, delays, and concurrent WAAPI animations without\n // guessing property names or maintaining a duration timer.\n void waitForAnimations(node).then((finished) => {\n if (!disposed) completeExit(finished)\n })\n\n return () => {\n disposed = true\n if (rafId !== undefined) cancelAnimationFrame(rafId)\n clearCSSProperties(node, exitCSSProperties)\n // restore transition: the exit handling sets node.style.transition='none'\n // directly on the DOM (bypassing React). if exit is interrupted (e.g. same-key\n // re-entry in AnimatePresence), React won't re-apply its managed transition\n // value because it hasn't changed in the virtual DOM. clearing the inline\n // override lets React's value take effect again.\n node.style.transition = ''\n }\n }, [isExiting, exitCSSPropertiesSignature])\n\n // signature of the animatable style, so the update effect can detect\n // in-place style changes. the css driver applies most style values as\n // atomic classNames (not inline style), so the signature must include the\n // className map. only computed when a listener is attached.\n const styleSignature = onTransition\n ? (() => {\n const { transition: _t, ...rest } = style\n return `${JSON.stringify(styleState?.classNames ?? null)}|${JSON.stringify(rest)}`\n })()\n : ''\n\n // enter lifecycle: emit start when the enter transition kicks off, end\n // once every animation on the node finishes (getAnimations-based, resolves\n // immediately for zero-animation elements). the promise outlives benign\n // re-renders because it keys off the cycle id, not the effect lifetime.\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host\n if (!onTransitionRef.current || isExiting || !justFinishedEntering || !host) {\n return\n }\n const node = host as HTMLElement\n const cycleId = ++enterCycleIdRef.current\n enterStartedRef.current = true\n emit('start', 'enter')\n void waitForAnimations(node).then((finished) => {\n if (cycleId !== enterCycleIdRef.current || !enterStartedRef.current) return\n enterStartedRef.current = false\n emit('end', 'enter', finished)\n })\n }, [justFinishedEntering, isExiting])\n\n // update lifecycle: a style change while mounted (not entering or exiting).\n // a new update that supersedes an in-flight one emits end(finished:false).\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host\n if (\n !onTransitionRef.current ||\n isEntering ||\n justFinishedEntering ||\n isExiting ||\n !host\n ) {\n // keep the signature current so leaving enter/exit isn't seen as an update\n prevUpdateSigRef.current = styleSignature\n return\n }\n if (prevUpdateSigRef.current === null) {\n prevUpdateSigRef.current = styleSignature\n return\n }\n if (styleSignature === prevUpdateSigRef.current) return\n prevUpdateSigRef.current = styleSignature\n\n const node = host as HTMLElement\n if (updateInFlightRef.current) {\n emit('end', 'update', false)\n }\n updateInFlightRef.current = true\n const cycleId = ++updateCycleIdRef.current\n emit('start', 'update')\n void waitForAnimations(node).then((finished) => {\n if (cycleId !== updateCycleIdRef.current) return\n updateInFlightRef.current = false\n emit('end', 'update', finished)\n })\n }, [styleSignature, isEntering, justFinishedEntering, isExiting])\n\n // interruption: emit a finished:false end for an enter canceled by an exit,\n // or an exit canceled by a re-enter (before its own completion fired).\n useIsomorphicLayoutEffect(() => {\n if (justStartedExiting && enterStartedRef.current) {\n enterCycleIdRef.current++\n enterStartedRef.current = false\n emit('end', 'enter', false)\n }\n if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {\n exitStartedRef.current = false\n emit('end', 'exit', false)\n }\n }, [justStartedExiting, justStoppedExiting])\n\n // tamagui doesnt even use animation output during hydration\n if (isHydrating) {\n return null\n }\n\n // Check if we have any animation to apply\n if (!hasTransition(resolved)) {\n return null\n }\n\n if (Array.isArray(style.transform)) {\n style.transform = transformsToString(style.transform)\n }\n\n style.transition = getTransition()\n\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n console.info('CSS animation', {\n props,\n animations,\n resolved,\n style,\n isEntering,\n isExiting,\n })\n }\n\n return { style, className: isEntering ? 't_unmounted' : '' }\n },\n }\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
package/types/extras.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { AnimationsConfig } from "@tamagui/animation-helpers";
|
|
1
2
|
import type { AnimationDriverWithAnimatedNumbers } from "@tamagui/web";
|
|
2
3
|
export * from "./animated-number";
|
|
3
|
-
export declare function createAnimations<A extends
|
|
4
|
+
export declare function createAnimations<A extends AnimationsConfig>(animations: A): AnimationDriverWithAnimatedNumbers<A>;
|
|
4
5
|
|
|
5
6
|
//# sourceMappingURL=extras.d.ts.map
|
package/types/extras.d.ts.map
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "AAAA,cAAc,0CAA0C;AAUxD,cAAc;AAEd,OAAO,iBAAS,iBAAiB,
|
|
2
|
+
"mappings": "AAAA,cAAc,wBAAwB;AACtC,cAAc,0CAA0C;AAUxD,cAAc;AAEd,OAAO,iBAAS,iBAAiB,UAAU,kBACzC,YAAY,IACX,mCAAmC",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/extras.ts"
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"import type { AnimationDriverWithAnimatedNumbers } from '@tamagui/web'\n\nimport {\n useAnimatedNumber,\n useAnimatedNumberReaction,\n useAnimatedNumberStyle,\n useAnimatedNumbersStyle,\n} from './animated-number'\nimport { createAnimations as createCoreAnimations } from './createAnimations'\n\nexport * from './animated-number'\n\nexport function createAnimations<A extends
|
|
9
|
+
"import type { AnimationsConfig } from '@tamagui/animation-helpers'\nimport type { AnimationDriverWithAnimatedNumbers } from '@tamagui/web'\n\nimport {\n useAnimatedNumber,\n useAnimatedNumberReaction,\n useAnimatedNumberStyle,\n useAnimatedNumbersStyle,\n} from './animated-number'\nimport { createAnimations as createCoreAnimations } from './createAnimations'\n\nexport * from './animated-number'\n\nexport function createAnimations<A extends AnimationsConfig>(\n animations: A\n): AnimationDriverWithAnimatedNumbers<A> {\n return {\n ...createCoreAnimations(animations),\n useAnimatedNumber,\n useAnimatedNumberReaction,\n useAnimatedNumberStyle,\n useAnimatedNumbersStyle,\n }\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|