@tamagui/animation-helpers 2.0.0-rc.3 → 2.0.0-rc.30
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/index.cjs +1 -0
- package/dist/cjs/index.js +17 -11
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +1 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/normalizeTransition.cjs +25 -7
- package/dist/cjs/normalizeTransition.native.js +46 -7
- package/dist/cjs/normalizeTransition.native.js.map +1 -1
- package/dist/esm/index.js +2 -14
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +2 -2
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/normalizeTransition.mjs +25 -8
- package/dist/esm/normalizeTransition.mjs.map +1 -1
- package/dist/esm/normalizeTransition.native.js +46 -8
- package/dist/esm/normalizeTransition.native.js.map +1 -1
- package/package.json +5 -8
- package/src/index.ts +1 -0
- package/src/normalizeTransition.ts +84 -4
- package/src/types.ts +19 -0
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +4 -4
- package/types/normalizeTransition.d.ts +11 -0
- package/types/normalizeTransition.d.ts.map +4 -4
- package/types/types.d.ts +18 -0
- package/types/types.d.ts.map +4 -4
- package/dist/cjs/normalizeTransition.js +0 -89
- package/dist/cjs/normalizeTransition.js.map +0 -6
- package/dist/cjs/types.js +0 -14
- package/dist/cjs/types.js.map +0 -6
- package/dist/esm/normalizeTransition.js +0 -73
- package/dist/esm/normalizeTransition.js.map +0 -6
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -6
package/dist/cjs/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
getAnimatedProperties: () => import_normalizeTransition.getAnimatedProperties,
|
|
24
|
+
getAnimationConfigsForKeys: () => import_normalizeTransition.getAnimationConfigsForKeys,
|
|
24
25
|
getAnimationForProperty: () => import_normalizeTransition.getAnimationForProperty,
|
|
25
26
|
getEffectiveAnimation: () => import_normalizeTransition.getEffectiveAnimation,
|
|
26
27
|
hasAnimation: () => import_normalizeTransition.hasAnimation,
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,23 +3,29 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
15
21
|
var index_exports = {};
|
|
16
22
|
__export(index_exports, {
|
|
17
23
|
getAnimatedProperties: () => import_normalizeTransition.getAnimatedProperties,
|
|
24
|
+
getAnimationConfigsForKeys: () => import_normalizeTransition.getAnimationConfigsForKeys,
|
|
18
25
|
getAnimationForProperty: () => import_normalizeTransition.getAnimationForProperty,
|
|
19
26
|
getEffectiveAnimation: () => import_normalizeTransition.getEffectiveAnimation,
|
|
20
27
|
hasAnimation: () => import_normalizeTransition.hasAnimation,
|
|
21
28
|
normalizeTransition: () => import_normalizeTransition.normalizeTransition
|
|
22
29
|
});
|
|
23
30
|
module.exports = __toCommonJS(index_exports);
|
|
24
|
-
var import_normalizeTransition = require("./normalizeTransition");
|
|
25
|
-
//# sourceMappingURL=index.js.map
|
|
31
|
+
var import_normalizeTransition = require("./normalizeTransition.cjs");
|
package/dist/cjs/index.js.map
CHANGED
package/dist/cjs/index.native.js
CHANGED
|
@@ -23,6 +23,7 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
23
23
|
var index_exports = {};
|
|
24
24
|
__export(index_exports, {
|
|
25
25
|
getAnimatedProperties: () => import_normalizeTransition.getAnimatedProperties,
|
|
26
|
+
getAnimationConfigsForKeys: () => import_normalizeTransition.getAnimationConfigsForKeys,
|
|
26
27
|
getAnimationForProperty: () => import_normalizeTransition.getAnimationForProperty,
|
|
27
28
|
getEffectiveAnimation: () => import_normalizeTransition.getEffectiveAnimation,
|
|
28
29
|
hasAnimation: () => import_normalizeTransition.hasAnimation,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","getAnimatedProperties","import_normalizeTransition","getAnimationForProperty","getEffectiveAnimation","hasAnimation","normalizeTransition","module","exports"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,qBAAA,EAAAA,CAAA,KAAAC,0BAAA,CAAAD,qBAAA;EAAAE,
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","getAnimatedProperties","import_normalizeTransition","getAnimationConfigsForKeys","getAnimationForProperty","getEffectiveAnimation","hasAnimation","normalizeTransition","module","exports"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,qBAAA,EAAAA,CAAA,KAAAC,0BAAA,CAAAD,qBAAA;EAAAE,0BAAA,EAAAA,CAAA,KAAAD,0BAAA,CAAAC,0BAAA;EAAAC,uBAAA,EAAAA,CAAA,KAAAF,0BAAA,CAAAE,uBAAA;EAAAC,qBAAA,EAAAA,CAAA,KAAAH,0BAAA,CAAAG,qBAAA;EAAAC,YAAA,EAAAA,CAAA,KAAAJ,0BAAA,CAAAI,YAAA;EAAAC,mBAAA,EAAAA,CAAA,KAAAL,0BAAA,CAAAK;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAf,YAAA,CAAAK,aAOO","ignoreList":[]}
|
|
@@ -21,12 +21,17 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
21
21
|
var normalizeTransition_exports = {};
|
|
22
22
|
__export(normalizeTransition_exports, {
|
|
23
23
|
getAnimatedProperties: () => getAnimatedProperties,
|
|
24
|
+
getAnimationConfigsForKeys: () => getAnimationConfigsForKeys,
|
|
24
25
|
getAnimationForProperty: () => getAnimationForProperty,
|
|
25
26
|
getEffectiveAnimation: () => getEffectiveAnimation,
|
|
26
27
|
hasAnimation: () => hasAnimation,
|
|
27
28
|
normalizeTransition: () => normalizeTransition
|
|
28
29
|
});
|
|
29
30
|
module.exports = __toCommonJS(normalizeTransition_exports);
|
|
31
|
+
const SPRING_CONFIG_KEYS = /* @__PURE__ */new Set(["stiffness", "damping", "mass", "tension", "friction", "velocity", "overshootClamping", "duration", "bounciness", "speed"]);
|
|
32
|
+
function isSpringConfigKey(key) {
|
|
33
|
+
return SPRING_CONFIG_KEYS.has(key);
|
|
34
|
+
}
|
|
30
35
|
function normalizeTransition(transition) {
|
|
31
36
|
if (!transition) return {
|
|
32
37
|
default: null,
|
|
@@ -43,33 +48,37 @@ function normalizeTransition(transition) {
|
|
|
43
48
|
properties: {}
|
|
44
49
|
};
|
|
45
50
|
if (Array.isArray(transition)) {
|
|
46
|
-
const [defaultAnimation,
|
|
47
|
-
properties = {}
|
|
51
|
+
const [defaultAnimation, configObj] = transition,
|
|
52
|
+
properties = {},
|
|
53
|
+
springConfig = {};
|
|
48
54
|
let delay,
|
|
49
55
|
enter = null,
|
|
50
56
|
exit = null;
|
|
51
|
-
if (
|
|
57
|
+
if (configObj && typeof configObj == "object") for (const [key, value] of Object.entries(configObj)) key === "delay" && typeof value == "number" ? delay = value : key === "enter" && typeof value == "string" ? enter = value : key === "exit" && typeof value == "string" ? exit = value : isSpringConfigKey(key) && value !== void 0 ? springConfig[key] = value : value !== void 0 && (properties[key] = value);
|
|
52
58
|
return {
|
|
53
59
|
default: defaultAnimation,
|
|
54
60
|
enter,
|
|
55
61
|
exit,
|
|
56
62
|
delay,
|
|
57
|
-
properties
|
|
63
|
+
properties,
|
|
64
|
+
config: Object.keys(springConfig).length > 0 ? springConfig : void 0
|
|
58
65
|
};
|
|
59
66
|
}
|
|
60
67
|
if (typeof transition == "object") {
|
|
61
|
-
const properties = {}
|
|
68
|
+
const properties = {},
|
|
69
|
+
springConfig = {};
|
|
62
70
|
let defaultAnimation = null,
|
|
63
71
|
enter = null,
|
|
64
72
|
exit = null,
|
|
65
73
|
delay;
|
|
66
|
-
for (const [key, value] of Object.entries(transition)) key === "default" && typeof value == "string" ? defaultAnimation = value : key === "enter" && typeof value == "string" ? enter = value : key === "exit" && typeof value == "string" ? exit = value : key === "delay" && typeof value == "number" ? delay = value : value !== void 0 && (properties[key] = value);
|
|
74
|
+
for (const [key, value] of Object.entries(transition)) key === "default" && typeof value == "string" ? defaultAnimation = value : key === "enter" && typeof value == "string" ? enter = value : key === "exit" && typeof value == "string" ? exit = value : key === "delay" && typeof value == "number" ? delay = value : isSpringConfigKey(key) && value !== void 0 ? springConfig[key] = value : value !== void 0 && (properties[key] = value);
|
|
67
75
|
return {
|
|
68
76
|
default: defaultAnimation,
|
|
69
77
|
enter,
|
|
70
78
|
exit,
|
|
71
79
|
delay,
|
|
72
|
-
properties
|
|
80
|
+
properties,
|
|
81
|
+
config: Object.keys(springConfig).length > 0 ? springConfig : void 0
|
|
73
82
|
};
|
|
74
83
|
}
|
|
75
84
|
return {
|
|
@@ -92,4 +101,13 @@ function getAnimatedProperties(normalized) {
|
|
|
92
101
|
}
|
|
93
102
|
function getEffectiveAnimation(normalized, state) {
|
|
94
103
|
return state === "enter" && normalized.enter ? normalized.enter : state === "exit" && normalized.exit ? normalized.exit : normalized.default;
|
|
104
|
+
}
|
|
105
|
+
function getAnimationConfigsForKeys(normalized, animations, keys, defaultAnimation) {
|
|
106
|
+
const result = /* @__PURE__ */new Map();
|
|
107
|
+
for (const key of keys) {
|
|
108
|
+
const propAnimation = normalized.properties[key];
|
|
109
|
+
let animationValue = null;
|
|
110
|
+
typeof propAnimation == "string" ? animationValue = animations[propAnimation] ?? null : propAnimation && typeof propAnimation == "object" && propAnimation.type && (animationValue = animations[propAnimation.type] ?? null), animationValue === null && (animationValue = defaultAnimation), result.set(key, animationValue);
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
95
113
|
}
|
|
@@ -23,6 +23,7 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
23
23
|
var normalizeTransition_exports = {};
|
|
24
24
|
__export(normalizeTransition_exports, {
|
|
25
25
|
getAnimatedProperties: () => getAnimatedProperties,
|
|
26
|
+
getAnimationConfigsForKeys: () => getAnimationConfigsForKeys,
|
|
26
27
|
getAnimationForProperty: () => getAnimationForProperty,
|
|
27
28
|
getEffectiveAnimation: () => getEffectiveAnimation,
|
|
28
29
|
hasAnimation: () => hasAnimation,
|
|
@@ -34,6 +35,10 @@ function _type_of(obj) {
|
|
|
34
35
|
|
|
35
36
|
return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
36
37
|
}
|
|
38
|
+
var SPRING_CONFIG_KEYS = /* @__PURE__ */new Set(["stiffness", "damping", "mass", "tension", "friction", "velocity", "overshootClamping", "duration", "bounciness", "speed"]);
|
|
39
|
+
function isSpringConfigKey(key) {
|
|
40
|
+
return SPRING_CONFIG_KEYS.has(key);
|
|
41
|
+
}
|
|
37
42
|
function normalizeTransition(transition) {
|
|
38
43
|
if (!transition) return {
|
|
39
44
|
default: null,
|
|
@@ -50,19 +55,20 @@ function normalizeTransition(transition) {
|
|
|
50
55
|
properties: {}
|
|
51
56
|
};
|
|
52
57
|
if (Array.isArray(transition)) {
|
|
53
|
-
var [defaultAnimation,
|
|
58
|
+
var [defaultAnimation, configObj] = transition,
|
|
54
59
|
properties = {},
|
|
60
|
+
springConfig = {},
|
|
55
61
|
delay,
|
|
56
62
|
enter = null,
|
|
57
63
|
exit = null;
|
|
58
|
-
if (
|
|
64
|
+
if (configObj && (typeof configObj > "u" ? "undefined" : _type_of(configObj)) === "object") {
|
|
59
65
|
var _iteratorNormalCompletion = !0,
|
|
60
66
|
_didIteratorError = !1,
|
|
61
67
|
_iteratorError = void 0;
|
|
62
68
|
try {
|
|
63
|
-
for (var _iterator = Object.entries(
|
|
69
|
+
for (var _iterator = Object.entries(configObj)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
64
70
|
var [key, value] = _step.value;
|
|
65
|
-
key === "delay" && typeof value == "number" ? delay = value : key === "enter" && typeof value == "string" ? enter = value : key === "exit" && typeof value == "string" ? exit = value : value !== void 0 && (properties[key] = value);
|
|
71
|
+
key === "delay" && typeof value == "number" ? delay = value : key === "enter" && typeof value == "string" ? enter = value : key === "exit" && typeof value == "string" ? exit = value : isSpringConfigKey(key) && value !== void 0 ? springConfig[key] = value : value !== void 0 && (properties[key] = value);
|
|
66
72
|
}
|
|
67
73
|
} catch (err) {
|
|
68
74
|
_didIteratorError = !0, _iteratorError = err;
|
|
@@ -79,11 +85,13 @@ function normalizeTransition(transition) {
|
|
|
79
85
|
enter,
|
|
80
86
|
exit,
|
|
81
87
|
delay,
|
|
82
|
-
properties
|
|
88
|
+
properties,
|
|
89
|
+
config: Object.keys(springConfig).length > 0 ? springConfig : void 0
|
|
83
90
|
};
|
|
84
91
|
}
|
|
85
92
|
if ((typeof transition > "u" ? "undefined" : _type_of(transition)) === "object") {
|
|
86
93
|
var properties1 = {},
|
|
94
|
+
springConfig1 = {},
|
|
87
95
|
defaultAnimation1 = null,
|
|
88
96
|
enter1 = null,
|
|
89
97
|
exit1 = null,
|
|
@@ -94,7 +102,7 @@ function normalizeTransition(transition) {
|
|
|
94
102
|
try {
|
|
95
103
|
for (var _iterator1 = Object.entries(transition)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
|
|
96
104
|
var [key1, value1] = _step1.value;
|
|
97
|
-
key1 === "default" && typeof value1 == "string" ? defaultAnimation1 = value1 : key1 === "enter" && typeof value1 == "string" ? enter1 = value1 : key1 === "exit" && typeof value1 == "string" ? exit1 = value1 : key1 === "delay" && typeof value1 == "number" ? delay1 = value1 : value1 !== void 0 && (properties1[key1] = value1);
|
|
105
|
+
key1 === "default" && typeof value1 == "string" ? defaultAnimation1 = value1 : key1 === "enter" && typeof value1 == "string" ? enter1 = value1 : key1 === "exit" && typeof value1 == "string" ? exit1 = value1 : key1 === "delay" && typeof value1 == "number" ? delay1 = value1 : isSpringConfigKey(key1) && value1 !== void 0 ? springConfig1[key1] = value1 : value1 !== void 0 && (properties1[key1] = value1);
|
|
98
106
|
}
|
|
99
107
|
} catch (err) {
|
|
100
108
|
_didIteratorError1 = !0, _iteratorError1 = err;
|
|
@@ -110,7 +118,8 @@ function normalizeTransition(transition) {
|
|
|
110
118
|
enter: enter1,
|
|
111
119
|
exit: exit1,
|
|
112
120
|
delay: delay1,
|
|
113
|
-
properties: properties1
|
|
121
|
+
properties: properties1,
|
|
122
|
+
config: Object.keys(springConfig1).length > 0 ? springConfig1 : void 0
|
|
114
123
|
};
|
|
115
124
|
}
|
|
116
125
|
return {
|
|
@@ -134,4 +143,34 @@ function getAnimatedProperties(normalized) {
|
|
|
134
143
|
function getEffectiveAnimation(normalized, state) {
|
|
135
144
|
return state === "enter" && normalized.enter ? normalized.enter : state === "exit" && normalized.exit ? normalized.exit : normalized.default;
|
|
136
145
|
}
|
|
146
|
+
function getAnimationConfigsForKeys(normalized, animations, keys, defaultAnimation) {
|
|
147
|
+
var result = /* @__PURE__ */new Map(),
|
|
148
|
+
_iteratorNormalCompletion = !0,
|
|
149
|
+
_didIteratorError = !1,
|
|
150
|
+
_iteratorError = void 0;
|
|
151
|
+
try {
|
|
152
|
+
for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
153
|
+
var key = _step.value,
|
|
154
|
+
propAnimation = normalized.properties[key],
|
|
155
|
+
animationValue = null;
|
|
156
|
+
if (typeof propAnimation == "string") {
|
|
157
|
+
var _animations_propAnimation;
|
|
158
|
+
animationValue = (_animations_propAnimation = animations[propAnimation]) !== null && _animations_propAnimation !== void 0 ? _animations_propAnimation : null;
|
|
159
|
+
} else if (propAnimation && (typeof propAnimation > "u" ? "undefined" : _type_of(propAnimation)) === "object" && propAnimation.type) {
|
|
160
|
+
var _animations_propAnimation_type;
|
|
161
|
+
animationValue = (_animations_propAnimation_type = animations[propAnimation.type]) !== null && _animations_propAnimation_type !== void 0 ? _animations_propAnimation_type : null;
|
|
162
|
+
}
|
|
163
|
+
animationValue === null && (animationValue = defaultAnimation), result.set(key, animationValue);
|
|
164
|
+
}
|
|
165
|
+
} catch (err) {
|
|
166
|
+
_didIteratorError = !0, _iteratorError = err;
|
|
167
|
+
} finally {
|
|
168
|
+
try {
|
|
169
|
+
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
170
|
+
} finally {
|
|
171
|
+
if (_didIteratorError) throw _iteratorError;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
137
176
|
//# sourceMappingURL=normalizeTransition.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","normalizeTransition_exports","__export","getAnimatedProperties","getAnimationForProperty","getEffectiveAnimation","hasAnimation","normalizeTransition","module","exports","_type_of","obj","Symbol","constructor","transition","default","enter","exit","delay","properties","Array","isArray","defaultAnimation","
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","normalizeTransition_exports","__export","getAnimatedProperties","getAnimationConfigsForKeys","getAnimationForProperty","getEffectiveAnimation","hasAnimation","normalizeTransition","module","exports","_type_of","obj","Symbol","constructor","SPRING_CONFIG_KEYS","Set","isSpringConfigKey","key","has","transition","default","enter","exit","delay","properties","Array","isArray","defaultAnimation","configObj","springConfig","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Object","entries","iterator","_step","next","done","err","return","config","keys","length","properties1","springConfig1","defaultAnimation1","enter1","exit1","delay1","_iteratorNormalCompletion1","_didIteratorError1","_iteratorError1","_iterator1","_step1","key1","value1"],"sources":["../../src/normalizeTransition.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,2BAAA;AAAAC,QAAA,CAAAD,2BAAA;EAAAE,qBAAA,EAAAA,CAAA,KAAAA,qBAAA;EAAAC,0BAAA,EAAAA,CAAA,KAAAA,0BAAA;EAAAC,uBAAA,EAAAA,CAAA,KAAAA,uBAAA;EAAAC,qBAAA,EAAAA,CAAA,KAAAA,qBAAA;EAAAC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MACjB,eAAAV,iBAIS,GAAAU,MAAA,GAAAD,IAAA,uBAAAC,MAAA,eAAAT,MAAA,GAAAS,MAAA,GAAAD,IAAA,sBAAAC,MAAA,eAAAR,KAAA,GAAAQ,MAAA,GAAAD,IAAA,uBAAAC,MAAA,eAAAP,MAAA,GAAAO,MAAA,GAAAzC,iBAAA,CAAAwC,IAAA,KAAAC,MAAA,cAAAX,aAAA,CAAAU,IAAA,IAAAC,MAAA,GAAAA,MAAA,gBAAAZ,WAAA,CAAAW,IAAA,IAAAC,MAAA;MACpB;IAKO,SAASjB,GAAA;MACdY,kBACa,OAAAC,eACX,GAAAb,GAAW;IAIf;MAMO,IAAS;QACd,CAAOW,0BAAuB,IAAAG,UAAU,CAAAb,MAAA,YAAAa,UAAA,CAAAb,MAAA;MAC1C;QAUO,IAASW,kBAAA,EAIV,MAAAC,eAAqB;MAO3B;IAYO;IAML,OAAM;MAENjC,OAAW,EAAA2B,iBAAa;MACtB1B,KAAM,EAAA2B,MAAA;MACN1B,IAAI,EAAA2B,KAAA;MAEA1B,KAAO,EAAA2B,MAAA;MAgBb1B,UAAA,EAAAqB,WAAA;MAEAH,MAAO,EAAAR,MAAA,CAAAS,IAAA,CAAAG,aAAA,EAAAF,MAAA,OAAAE,aAAA;IACT","ignoreList":[]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
getAnimationForProperty,
|
|
4
|
-
hasAnimation,
|
|
5
|
-
getAnimatedProperties,
|
|
6
|
-
getEffectiveAnimation
|
|
7
|
-
} from "./normalizeTransition";
|
|
8
|
-
export {
|
|
9
|
-
getAnimatedProperties,
|
|
10
|
-
getAnimationForProperty,
|
|
11
|
-
getEffectiveAnimation,
|
|
12
|
-
hasAnimation,
|
|
13
|
-
normalizeTransition
|
|
14
|
-
};
|
|
1
|
+
import { normalizeTransition, getAnimationForProperty, hasAnimation, getAnimatedProperties, getEffectiveAnimation, getAnimationConfigsForKeys } from "./normalizeTransition.mjs";
|
|
2
|
+
export { getAnimatedProperties, getAnimationConfigsForKeys, getAnimationForProperty, getEffectiveAnimation, hasAnimation, normalizeTransition };
|
|
15
3
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
1
|
+
{"version":3,"names":["normalizeTransition","getAnimationForProperty","hasAnimation","getAnimatedProperties","getEffectiveAnimation","getAnimationConfigsForKeys"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SACEA,mBAAA,EACAC,uBAAA,EACAC,YAAA,EACAC,qBAAA,EACAC,qBAAA,EACAC,0BAAA,QACK","ignoreList":[]}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { normalizeTransition, getAnimationForProperty, hasAnimation, getAnimatedProperties, getEffectiveAnimation } from "./normalizeTransition.mjs";
|
|
2
|
-
export { getAnimatedProperties, getAnimationForProperty, getEffectiveAnimation, hasAnimation, normalizeTransition };
|
|
1
|
+
import { normalizeTransition, getAnimationForProperty, hasAnimation, getAnimatedProperties, getEffectiveAnimation, getAnimationConfigsForKeys } from "./normalizeTransition.mjs";
|
|
2
|
+
export { getAnimatedProperties, getAnimationConfigsForKeys, getAnimationForProperty, getEffectiveAnimation, hasAnimation, normalizeTransition };
|
|
3
3
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["normalizeTransition","getAnimationForProperty","hasAnimation","getAnimatedProperties","getEffectiveAnimation"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SACEA,mBAAA,EACAC,uBAAA,EACAC,YAAA,EACAC,qBAAA,EACAC,qBAAA,QACK","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["normalizeTransition","getAnimationForProperty","hasAnimation","getAnimatedProperties","getEffectiveAnimation","getAnimationConfigsForKeys"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SACEA,mBAAA,EACAC,uBAAA,EACAC,YAAA,EACAC,qBAAA,EACAC,qBAAA,EACAC,0BAAA,QACK","ignoreList":[]}
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { normalizeTransition, getAnimationForProperty, hasAnimation, getAnimatedProperties, getEffectiveAnimation } from "./normalizeTransition.native.js";
|
|
2
|
-
export { getAnimatedProperties, getAnimationForProperty, getEffectiveAnimation, hasAnimation, normalizeTransition };
|
|
1
|
+
import { normalizeTransition, getAnimationForProperty, hasAnimation, getAnimatedProperties, getEffectiveAnimation, getAnimationConfigsForKeys } from "./normalizeTransition.native.js";
|
|
2
|
+
export { getAnimatedProperties, getAnimationConfigsForKeys, getAnimationForProperty, getEffectiveAnimation, hasAnimation, normalizeTransition };
|
|
3
3
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["normalizeTransition","getAnimationForProperty","hasAnimation","getAnimatedProperties","getEffectiveAnimation"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAAAA,mBAAA,EAAAC,uBAAA,EAAAC,YAAA,EAAAC,qBAAA,EAAAC,qBAAA;AAAA,
|
|
1
|
+
{"version":3,"names":["normalizeTransition","getAnimationForProperty","hasAnimation","getAnimatedProperties","getEffectiveAnimation","getAnimationConfigsForKeys"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAAAA,mBAAA,EAAAC,uBAAA,EAAAC,YAAA,EAAAC,qBAAA,EAAAC,qBAAA,EAAAC,0BAAA;AAAA,SAEEF,qBAAA,EACAE,0BAAA,EACAJ,uBAAA,EACAG,qBAAA,EACAF,YAAA,EAAAF,mBACK","ignoreList":[]}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const SPRING_CONFIG_KEYS = /* @__PURE__ */new Set(["stiffness", "damping", "mass", "tension", "friction", "velocity", "overshootClamping", "duration", "bounciness", "speed"]);
|
|
2
|
+
function isSpringConfigKey(key) {
|
|
3
|
+
return SPRING_CONFIG_KEYS.has(key);
|
|
4
|
+
}
|
|
1
5
|
function normalizeTransition(transition) {
|
|
2
6
|
if (!transition) return {
|
|
3
7
|
default: null,
|
|
@@ -14,33 +18,37 @@ function normalizeTransition(transition) {
|
|
|
14
18
|
properties: {}
|
|
15
19
|
};
|
|
16
20
|
if (Array.isArray(transition)) {
|
|
17
|
-
const [defaultAnimation,
|
|
18
|
-
properties = {}
|
|
21
|
+
const [defaultAnimation, configObj] = transition,
|
|
22
|
+
properties = {},
|
|
23
|
+
springConfig = {};
|
|
19
24
|
let delay,
|
|
20
25
|
enter = null,
|
|
21
26
|
exit = null;
|
|
22
|
-
if (
|
|
27
|
+
if (configObj && typeof configObj == "object") for (const [key, value] of Object.entries(configObj)) key === "delay" && typeof value == "number" ? delay = value : key === "enter" && typeof value == "string" ? enter = value : key === "exit" && typeof value == "string" ? exit = value : isSpringConfigKey(key) && value !== void 0 ? springConfig[key] = value : value !== void 0 && (properties[key] = value);
|
|
23
28
|
return {
|
|
24
29
|
default: defaultAnimation,
|
|
25
30
|
enter,
|
|
26
31
|
exit,
|
|
27
32
|
delay,
|
|
28
|
-
properties
|
|
33
|
+
properties,
|
|
34
|
+
config: Object.keys(springConfig).length > 0 ? springConfig : void 0
|
|
29
35
|
};
|
|
30
36
|
}
|
|
31
37
|
if (typeof transition == "object") {
|
|
32
|
-
const properties = {}
|
|
38
|
+
const properties = {},
|
|
39
|
+
springConfig = {};
|
|
33
40
|
let defaultAnimation = null,
|
|
34
41
|
enter = null,
|
|
35
42
|
exit = null,
|
|
36
43
|
delay;
|
|
37
|
-
for (const [key, value] of Object.entries(transition)) key === "default" && typeof value == "string" ? defaultAnimation = value : key === "enter" && typeof value == "string" ? enter = value : key === "exit" && typeof value == "string" ? exit = value : key === "delay" && typeof value == "number" ? delay = value : value !== void 0 && (properties[key] = value);
|
|
44
|
+
for (const [key, value] of Object.entries(transition)) key === "default" && typeof value == "string" ? defaultAnimation = value : key === "enter" && typeof value == "string" ? enter = value : key === "exit" && typeof value == "string" ? exit = value : key === "delay" && typeof value == "number" ? delay = value : isSpringConfigKey(key) && value !== void 0 ? springConfig[key] = value : value !== void 0 && (properties[key] = value);
|
|
38
45
|
return {
|
|
39
46
|
default: defaultAnimation,
|
|
40
47
|
enter,
|
|
41
48
|
exit,
|
|
42
49
|
delay,
|
|
43
|
-
properties
|
|
50
|
+
properties,
|
|
51
|
+
config: Object.keys(springConfig).length > 0 ? springConfig : void 0
|
|
44
52
|
};
|
|
45
53
|
}
|
|
46
54
|
return {
|
|
@@ -64,5 +72,14 @@ function getAnimatedProperties(normalized) {
|
|
|
64
72
|
function getEffectiveAnimation(normalized, state) {
|
|
65
73
|
return state === "enter" && normalized.enter ? normalized.enter : state === "exit" && normalized.exit ? normalized.exit : normalized.default;
|
|
66
74
|
}
|
|
67
|
-
|
|
75
|
+
function getAnimationConfigsForKeys(normalized, animations, keys, defaultAnimation) {
|
|
76
|
+
const result = /* @__PURE__ */new Map();
|
|
77
|
+
for (const key of keys) {
|
|
78
|
+
const propAnimation = normalized.properties[key];
|
|
79
|
+
let animationValue = null;
|
|
80
|
+
typeof propAnimation == "string" ? animationValue = animations[propAnimation] ?? null : propAnimation && typeof propAnimation == "object" && propAnimation.type && (animationValue = animations[propAnimation.type] ?? null), animationValue === null && (animationValue = defaultAnimation), result.set(key, animationValue);
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
export { getAnimatedProperties, getAnimationConfigsForKeys, getAnimationForProperty, getEffectiveAnimation, hasAnimation, normalizeTransition };
|
|
68
85
|
//# sourceMappingURL=normalizeTransition.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["normalizeTransition","transition","default","enter","exit","delay","properties","Array","isArray","defaultAnimation","
|
|
1
|
+
{"version":3,"names":["SPRING_CONFIG_KEYS","Set","isSpringConfigKey","key","has","normalizeTransition","transition","default","enter","exit","delay","properties","Array","isArray","defaultAnimation","configObj","springConfig","value","Object","entries","config","keys","length","getAnimationForProperty","normalized","property","propertyAnimation","hasAnimation","getAnimatedProperties","getEffectiveAnimation","state","getAnimationConfigsForKeys","animations","result","Map","propAnimation","animationValue","type","set"],"sources":["../../src/normalizeTransition.ts"],"sourcesContent":[null],"mappings":"AAOA,MAAMA,kBAAA,GAAkC,mBAAIC,GAAA,CAAI,CAC9C,aACA,WACA,QACA,WACA,YACA,YACA,qBACA,YACA,cACA,QACD;AAKD,SAASC,kBAAkBC,GAAA,EAAwC;EACjE,OAAOH,kBAAA,CAAmBI,GAAA,CAAID,GAAG;AACnC;AAcO,SAASE,oBACdC,UAAA,EACsB;EAEtB,IAAI,CAACA,UAAA,EACH,OAAO;IACLC,OAAA,EAAS;IACTC,KAAA,EAAO;IACPC,IAAA,EAAM;IACNC,KAAA,EAAO;IACPC,UAAA,EAAY,CAAC;EACf;EAIF,IAAI,OAAOL,UAAA,IAAe,UACxB,OAAO;IACLC,OAAA,EAASD,UAAA;IACTE,KAAA,EAAO;IACPC,IAAA,EAAM;IACNC,KAAA,EAAO;IACPC,UAAA,EAAY,CAAC;EACf;EAKF,IAAIC,KAAA,CAAMC,OAAA,CAAQP,UAAU,GAAG;IAC7B,MAAM,CAACQ,gBAAA,EAAkBC,SAAS,IAAIT,UAAA;MAChCK,UAAA,GAAuD,CAAC;MACxDK,YAAA,GAA6B,CAAC;IACpC,IAAIN,KAAA;MACAF,KAAA,GAAuB;MACvBC,IAAA,GAAsB;IAE1B,IAAIM,SAAA,IAAa,OAAOA,SAAA,IAAc,UACpC,WAAW,CAACZ,GAA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sB;EAEzC,WAAW/B,GAAA,IAAOkB,IAAA,EAAM;IACtB,MAAMc,aAAA,GAAgBX,UAAA,CAAWb,UAAA,CAAWR,GAAG;IAC/C,IAAIiC,cAAA,GAA2B;IAE3B,OAAOD,aAAA,IAAkB,WAC3BC,cAAA,GAAiBJ,UAAA,CAAWG,aAAa,KAAK,OAE9CA,aAAA,IACA,OAAOA,aAAA,IAAkB,YACxBA,aAAA,CAAsBE,IAAA,KAEvBD,cAAA,GAAiBJ,UAAA,CAAYG,aAAA,CAAsBE,IAAI,KAAK,OAI1DD,cAAA,KAAmB,SACrBA,cAAA,GAAiBtB,gBAAA,GAGnBmB,MAAA,CAAOK,GAAA,CAAInC,GAAA,EAAKiC,cAAc;EAChC;EAEA,OAAOH,MAAA;AACT","ignoreList":[]}
|
|
@@ -3,6 +3,10 @@ function _type_of(obj) {
|
|
|
3
3
|
|
|
4
4
|
return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
5
5
|
}
|
|
6
|
+
var SPRING_CONFIG_KEYS = /* @__PURE__ */new Set(["stiffness", "damping", "mass", "tension", "friction", "velocity", "overshootClamping", "duration", "bounciness", "speed"]);
|
|
7
|
+
function isSpringConfigKey(key) {
|
|
8
|
+
return SPRING_CONFIG_KEYS.has(key);
|
|
9
|
+
}
|
|
6
10
|
function normalizeTransition(transition) {
|
|
7
11
|
if (!transition) return {
|
|
8
12
|
default: null,
|
|
@@ -19,19 +23,20 @@ function normalizeTransition(transition) {
|
|
|
19
23
|
properties: {}
|
|
20
24
|
};
|
|
21
25
|
if (Array.isArray(transition)) {
|
|
22
|
-
var [defaultAnimation,
|
|
26
|
+
var [defaultAnimation, configObj] = transition,
|
|
23
27
|
properties = {},
|
|
28
|
+
springConfig = {},
|
|
24
29
|
delay,
|
|
25
30
|
enter = null,
|
|
26
31
|
exit = null;
|
|
27
|
-
if (
|
|
32
|
+
if (configObj && (typeof configObj > "u" ? "undefined" : _type_of(configObj)) === "object") {
|
|
28
33
|
var _iteratorNormalCompletion = !0,
|
|
29
34
|
_didIteratorError = !1,
|
|
30
35
|
_iteratorError = void 0;
|
|
31
36
|
try {
|
|
32
|
-
for (var _iterator = Object.entries(
|
|
37
|
+
for (var _iterator = Object.entries(configObj)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
33
38
|
var [key, value] = _step.value;
|
|
34
|
-
key === "delay" && typeof value == "number" ? delay = value : key === "enter" && typeof value == "string" ? enter = value : key === "exit" && typeof value == "string" ? exit = value : value !== void 0 && (properties[key] = value);
|
|
39
|
+
key === "delay" && typeof value == "number" ? delay = value : key === "enter" && typeof value == "string" ? enter = value : key === "exit" && typeof value == "string" ? exit = value : isSpringConfigKey(key) && value !== void 0 ? springConfig[key] = value : value !== void 0 && (properties[key] = value);
|
|
35
40
|
}
|
|
36
41
|
} catch (err) {
|
|
37
42
|
_didIteratorError = !0, _iteratorError = err;
|
|
@@ -48,11 +53,13 @@ function normalizeTransition(transition) {
|
|
|
48
53
|
enter,
|
|
49
54
|
exit,
|
|
50
55
|
delay,
|
|
51
|
-
properties
|
|
56
|
+
properties,
|
|
57
|
+
config: Object.keys(springConfig).length > 0 ? springConfig : void 0
|
|
52
58
|
};
|
|
53
59
|
}
|
|
54
60
|
if ((typeof transition > "u" ? "undefined" : _type_of(transition)) === "object") {
|
|
55
61
|
var properties1 = {},
|
|
62
|
+
springConfig1 = {},
|
|
56
63
|
defaultAnimation1 = null,
|
|
57
64
|
enter1 = null,
|
|
58
65
|
exit1 = null,
|
|
@@ -63,7 +70,7 @@ function normalizeTransition(transition) {
|
|
|
63
70
|
try {
|
|
64
71
|
for (var _iterator1 = Object.entries(transition)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
|
|
65
72
|
var [key1, value1] = _step1.value;
|
|
66
|
-
key1 === "default" && typeof value1 == "string" ? defaultAnimation1 = value1 : key1 === "enter" && typeof value1 == "string" ? enter1 = value1 : key1 === "exit" && typeof value1 == "string" ? exit1 = value1 : key1 === "delay" && typeof value1 == "number" ? delay1 = value1 : value1 !== void 0 && (properties1[key1] = value1);
|
|
73
|
+
key1 === "default" && typeof value1 == "string" ? defaultAnimation1 = value1 : key1 === "enter" && typeof value1 == "string" ? enter1 = value1 : key1 === "exit" && typeof value1 == "string" ? exit1 = value1 : key1 === "delay" && typeof value1 == "number" ? delay1 = value1 : isSpringConfigKey(key1) && value1 !== void 0 ? springConfig1[key1] = value1 : value1 !== void 0 && (properties1[key1] = value1);
|
|
67
74
|
}
|
|
68
75
|
} catch (err) {
|
|
69
76
|
_didIteratorError1 = !0, _iteratorError1 = err;
|
|
@@ -79,7 +86,8 @@ function normalizeTransition(transition) {
|
|
|
79
86
|
enter: enter1,
|
|
80
87
|
exit: exit1,
|
|
81
88
|
delay: delay1,
|
|
82
|
-
properties: properties1
|
|
89
|
+
properties: properties1,
|
|
90
|
+
config: Object.keys(springConfig1).length > 0 ? springConfig1 : void 0
|
|
83
91
|
};
|
|
84
92
|
}
|
|
85
93
|
return {
|
|
@@ -103,5 +111,35 @@ function getAnimatedProperties(normalized) {
|
|
|
103
111
|
function getEffectiveAnimation(normalized, state) {
|
|
104
112
|
return state === "enter" && normalized.enter ? normalized.enter : state === "exit" && normalized.exit ? normalized.exit : normalized.default;
|
|
105
113
|
}
|
|
106
|
-
|
|
114
|
+
function getAnimationConfigsForKeys(normalized, animations, keys, defaultAnimation) {
|
|
115
|
+
var result = /* @__PURE__ */new Map(),
|
|
116
|
+
_iteratorNormalCompletion = !0,
|
|
117
|
+
_didIteratorError = !1,
|
|
118
|
+
_iteratorError = void 0;
|
|
119
|
+
try {
|
|
120
|
+
for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
121
|
+
var key = _step.value,
|
|
122
|
+
propAnimation = normalized.properties[key],
|
|
123
|
+
animationValue = null;
|
|
124
|
+
if (typeof propAnimation == "string") {
|
|
125
|
+
var _animations_propAnimation;
|
|
126
|
+
animationValue = (_animations_propAnimation = animations[propAnimation]) !== null && _animations_propAnimation !== void 0 ? _animations_propAnimation : null;
|
|
127
|
+
} else if (propAnimation && (typeof propAnimation > "u" ? "undefined" : _type_of(propAnimation)) === "object" && propAnimation.type) {
|
|
128
|
+
var _animations_propAnimation_type;
|
|
129
|
+
animationValue = (_animations_propAnimation_type = animations[propAnimation.type]) !== null && _animations_propAnimation_type !== void 0 ? _animations_propAnimation_type : null;
|
|
130
|
+
}
|
|
131
|
+
animationValue === null && (animationValue = defaultAnimation), result.set(key, animationValue);
|
|
132
|
+
}
|
|
133
|
+
} catch (err) {
|
|
134
|
+
_didIteratorError = !0, _iteratorError = err;
|
|
135
|
+
} finally {
|
|
136
|
+
try {
|
|
137
|
+
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
138
|
+
} finally {
|
|
139
|
+
if (_didIteratorError) throw _iteratorError;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
export { getAnimatedProperties, getAnimationConfigsForKeys, getAnimationForProperty, getEffectiveAnimation, hasAnimation, normalizeTransition };
|
|
107
145
|
//# sourceMappingURL=normalizeTransition.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_type_of","obj","Symbol","constructor","normalizeTransition","transition","default","enter","exit","delay","properties","Array","isArray","defaultAnimation","
|
|
1
|
+
{"version":3,"names":["_type_of","obj","Symbol","constructor","SPRING_CONFIG_KEYS","Set","isSpringConfigKey","key","has","normalizeTransition","transition","default","enter","exit","delay","properties","Array","isArray","defaultAnimation","configObj","springConfig","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Object","entries","iterator","_step","next","done","value","err","return","config","keys","length","properties1","springConfig1","defaultAnimation1","enter1","exit1","delay1","_iteratorNormalCompletion1","_didIteratorError1","_iteratorError1","_iterator1","_step1","key1","value1"],"sources":["../../src/normalizeTransition.ts"],"sourcesContent":[null],"mappings":"AAOA,SAAMA,SAAAC,GAAA;EACJ;;EACA,OAAAA,GAAA,WAAAC,MAAA,UAAAD,GAAA,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AAAA;AACA,IACAG,kBAAA,sBAAAC,GAAA,EACA,aACA,WACA,QACA,WACA,YACA,YACD,qBAKD,UAAS,EACP,YAAO,EACT,QAcO;AAIL,SAAKC,kBAAAC,GAAA;EACH,OAAAH,kBAAO,CAAAI,GAAA,CAAAD,GAAA;AAAA;AACI,SACTE,mBAAOA,CAAAC,UAAA;EAAA,IACP,CAAAA,UAAM,SACN;IACAC,OAAA,MAAa;IACfC,KAAA;IAIEC,IAAA,MAAO;IACTC,KAAO;IACLC,UAAS;EAAA;EACF,IACP,OAAML,UAAA,qBACN;IACAC,OAAA,EAAAD,UAAa;IACfE,KAAA;IAKEC,IAAA,EAAM;IACRC,KAAO;IAGPC,UACI;EAGJ;EACE,IAAAC,KAAA,CAAAC,OAAY,CAAAP,UAAU,GAAK;IACzB,IAAI,CAAAQ,gBAAQ,EAAWC,SAAO,IAAAT,UAAU;MAAAK,UAC9B;MAAAK,YACS;MAAAN,KAAW;MAAAF,KAAO,OAAU;MAAAC,IAAA,GAC7C;IAaN,IAAAM,SAAO,YAAAA,SAAA,uBAAAnB,QAAA,CAAAmB,SAAA;MACL,IAAAE,yBAAS;QAAAC,iBAAA;QAAAC,cAAA;MACT;QACA,SAAAC,SAAA,GAAAC,MAAA,CAAAC,OAAA,CAAAP,SAAA,EAAAjB,MAAA,CAAAyB,QAAA,KAAAC,KAAA,IAAAP,yBAAA,IAAAO,KAAA,GAAAJ,SAAA,CAAAK,IAAA,IAAAC,IAAA,GAAAT,yBAAA;UACA,KAAAd,GAAA,EAAAwB,KAAA,IAAAH,KAAA,CAAAG,KAAA;UACAxB,GAAA,uBAAAwB,KAAA,eAAAjB,KAAA,GAAAiB,KAAA,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D,IAAA,sBAAAC,MAAA,eAAAR,KAAA,GAAAQ,MAAA,GAAAD,IAAA,uBAAAC,MAAA,eAAAP,MAAA,GAAAO,MAAA,GAAA3C,iBAAA,CAAA0C,IAAA,KAAAC,MAAA,cAAAX,aAAA,CAAAU,IAAA,IAAAC,MAAA,GAAAA,MAAA,gBAAAZ,WAAA,CAAAW,IAAA,IAAAC,MAAA;MACxD;IAMF,SAAAjB,GAAA;MAKOY,kBAAsB,OAAAC,eAA2C,GAAAb,GAAA;IACtE,UACE;MAKJ;QAMO,CAASW,0BAAsB,IAAAG,UAA4C,CAAAb,MAAA,YAAAa,UAAA,CAAAb,MAAA;MAChF,UAAc;QAChB,IAAAW,kBAAA,EAUgB,MAAAC,eACd;MAGA;IAOF;IAYO,OAAS;MAMdlC,OAAM,EAAA4B,iBAAS;MAEf3B,KAAA,EAAW4B,MAAA;MACT3B,IAAM,EAAA4B,KAAA;MACN3B,KAAI,EAAA4B,MAAA;MAEA3B,UAAO,EAAAsB,WAAkB;MAgB/BH,MAAA,EAAAT,MAAA,CAAAU,IAAA,CAAAG,aAAA,EAAAF,MAAA,OAAAE,aAAA;IAEA;EACF","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/animation-helpers",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.30",
|
|
4
4
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -18,15 +18,12 @@
|
|
|
18
18
|
"./package.json": "./package.json",
|
|
19
19
|
".": {
|
|
20
20
|
"types": "./types/index.d.ts",
|
|
21
|
-
"react-native":
|
|
22
|
-
|
|
23
|
-
"import": "./dist/esm/index.native.js",
|
|
24
|
-
"require": "./dist/cjs/index.native.js"
|
|
25
|
-
},
|
|
21
|
+
"react-native": "./dist/esm/index.native.js",
|
|
22
|
+
"browser": "./dist/esm/index.mjs",
|
|
26
23
|
"module": "./dist/esm/index.mjs",
|
|
27
24
|
"import": "./dist/esm/index.mjs",
|
|
28
25
|
"require": "./dist/cjs/index.cjs",
|
|
29
|
-
"default": "./dist/
|
|
26
|
+
"default": "./dist/esm/index.mjs"
|
|
30
27
|
}
|
|
31
28
|
},
|
|
32
29
|
"publishConfig": {
|
|
@@ -39,6 +36,6 @@
|
|
|
39
36
|
"clean:build": "tamagui-build clean:build"
|
|
40
37
|
},
|
|
41
38
|
"devDependencies": {
|
|
42
|
-
"@tamagui/build": "2.0.0-rc.
|
|
39
|
+
"@tamagui/build": "2.0.0-rc.30"
|
|
43
40
|
}
|
|
44
41
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
AnimationConfig,
|
|
3
|
+
NormalizedTransition,
|
|
4
|
+
SpringConfig,
|
|
5
|
+
TransitionPropInput,
|
|
6
|
+
} from './types'
|
|
7
|
+
|
|
8
|
+
const SPRING_CONFIG_KEYS: Set<string> = new Set([
|
|
9
|
+
'stiffness',
|
|
10
|
+
'damping',
|
|
11
|
+
'mass',
|
|
12
|
+
'tension',
|
|
13
|
+
'friction',
|
|
14
|
+
'velocity',
|
|
15
|
+
'overshootClamping',
|
|
16
|
+
'duration',
|
|
17
|
+
'bounciness',
|
|
18
|
+
'speed',
|
|
19
|
+
])
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Check if a key is a spring config parameter
|
|
23
|
+
*/
|
|
24
|
+
function isSpringConfigKey(key: string): key is keyof SpringConfig {
|
|
25
|
+
return SPRING_CONFIG_KEYS.has(key)
|
|
26
|
+
}
|
|
2
27
|
|
|
3
28
|
/**
|
|
4
29
|
* Normalizes the various transition prop formats into a consistent structure.
|
|
@@ -38,21 +63,26 @@ export function normalizeTransition(
|
|
|
38
63
|
}
|
|
39
64
|
|
|
40
65
|
// Array format: ['bouncy', { delay: 100, x: 'quick', enter: 'slow', exit: 'fast' }]
|
|
66
|
+
// Also supports spring config overrides: ['bouncy', { stiffness: 1000, damping: 70 }]
|
|
41
67
|
if (Array.isArray(transition)) {
|
|
42
|
-
const [defaultAnimation,
|
|
68
|
+
const [defaultAnimation, configObj] = transition
|
|
43
69
|
const properties: Record<string, string | AnimationConfig> = {}
|
|
70
|
+
const springConfig: SpringConfig = {}
|
|
44
71
|
let delay: number | undefined
|
|
45
72
|
let enter: string | null = null
|
|
46
73
|
let exit: string | null = null
|
|
47
74
|
|
|
48
|
-
if (
|
|
49
|
-
for (const [key, value] of Object.entries(
|
|
75
|
+
if (configObj && typeof configObj === 'object') {
|
|
76
|
+
for (const [key, value] of Object.entries(configObj)) {
|
|
50
77
|
if (key === 'delay' && typeof value === 'number') {
|
|
51
78
|
delay = value
|
|
52
79
|
} else if (key === 'enter' && typeof value === 'string') {
|
|
53
80
|
enter = value
|
|
54
81
|
} else if (key === 'exit' && typeof value === 'string') {
|
|
55
82
|
exit = value
|
|
83
|
+
} else if (isSpringConfigKey(key) && value !== undefined) {
|
|
84
|
+
// Spring config override: { stiffness: 1000, damping: 70 }
|
|
85
|
+
springConfig[key] = value as SpringConfig[keyof SpringConfig]
|
|
56
86
|
} else if (value !== undefined) {
|
|
57
87
|
// Property-specific animation: string or config object
|
|
58
88
|
properties[key] = value as string | AnimationConfig
|
|
@@ -66,12 +96,15 @@ export function normalizeTransition(
|
|
|
66
96
|
exit,
|
|
67
97
|
delay,
|
|
68
98
|
properties,
|
|
99
|
+
config: Object.keys(springConfig).length > 0 ? springConfig : undefined,
|
|
69
100
|
}
|
|
70
101
|
}
|
|
71
102
|
|
|
72
103
|
// Object format: { x: 'quick', y: 'bouncy', default: 'slow', enter: 'bouncy', exit: 'quick' }
|
|
104
|
+
// Also supports spring config overrides: { default: 'bouncy', stiffness: 1000 }
|
|
73
105
|
if (typeof transition === 'object') {
|
|
74
106
|
const properties: Record<string, string | AnimationConfig> = {}
|
|
107
|
+
const springConfig: SpringConfig = {}
|
|
75
108
|
let defaultAnimation: string | null = null
|
|
76
109
|
let enter: string | null = null
|
|
77
110
|
let exit: string | null = null
|
|
@@ -86,6 +119,9 @@ export function normalizeTransition(
|
|
|
86
119
|
exit = value
|
|
87
120
|
} else if (key === 'delay' && typeof value === 'number') {
|
|
88
121
|
delay = value
|
|
122
|
+
} else if (isSpringConfigKey(key) && value !== undefined) {
|
|
123
|
+
// Spring config override: { stiffness: 1000, damping: 70 }
|
|
124
|
+
springConfig[key] = value as SpringConfig[keyof SpringConfig]
|
|
89
125
|
} else if (value !== undefined) {
|
|
90
126
|
// Property-specific animation: string or config object
|
|
91
127
|
properties[key] = value as string | AnimationConfig
|
|
@@ -98,6 +134,7 @@ export function normalizeTransition(
|
|
|
98
134
|
exit,
|
|
99
135
|
delay,
|
|
100
136
|
properties,
|
|
137
|
+
config: Object.keys(springConfig).length > 0 ? springConfig : undefined,
|
|
101
138
|
}
|
|
102
139
|
}
|
|
103
140
|
|
|
@@ -173,3 +210,46 @@ export function getEffectiveAnimation(
|
|
|
173
210
|
}
|
|
174
211
|
return normalized.default
|
|
175
212
|
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Gets the resolved animation config for each key, looking up in animations config.
|
|
216
|
+
* Useful for calculating max duration across all animated properties.
|
|
217
|
+
*
|
|
218
|
+
* @param normalized - The normalized transition object
|
|
219
|
+
* @param animations - The animations config object (driver-specific format)
|
|
220
|
+
* @param keys - Property keys to get animations for
|
|
221
|
+
* @param defaultAnimation - The default animation value to fall back to
|
|
222
|
+
* @returns Map of key -> resolved animation config (or null if not found)
|
|
223
|
+
*/
|
|
224
|
+
export function getAnimationConfigsForKeys<T>(
|
|
225
|
+
normalized: NormalizedTransition,
|
|
226
|
+
animations: Record<string, T>,
|
|
227
|
+
keys: string[],
|
|
228
|
+
defaultAnimation: T | null
|
|
229
|
+
): Map<string, T | null> {
|
|
230
|
+
const result = new Map<string, T | null>()
|
|
231
|
+
|
|
232
|
+
for (const key of keys) {
|
|
233
|
+
const propAnimation = normalized.properties[key]
|
|
234
|
+
let animationValue: T | null = null
|
|
235
|
+
|
|
236
|
+
if (typeof propAnimation === 'string') {
|
|
237
|
+
animationValue = animations[propAnimation] ?? null
|
|
238
|
+
} else if (
|
|
239
|
+
propAnimation &&
|
|
240
|
+
typeof propAnimation === 'object' &&
|
|
241
|
+
(propAnimation as any).type
|
|
242
|
+
) {
|
|
243
|
+
animationValue = animations[(propAnimation as any).type] ?? null
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// fall back to default if no per-property config found
|
|
247
|
+
if (animationValue === null) {
|
|
248
|
+
animationValue = defaultAnimation
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
result.set(key, animationValue)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return result
|
|
255
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -20,6 +20,23 @@ export type AnimationConfig = {
|
|
|
20
20
|
*/
|
|
21
21
|
export type TransitionPropInput = any
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Spring configuration parameters that can override preset defaults.
|
|
25
|
+
* These are the common parameters across animation drivers.
|
|
26
|
+
*/
|
|
27
|
+
export type SpringConfig = {
|
|
28
|
+
stiffness?: number
|
|
29
|
+
damping?: number
|
|
30
|
+
mass?: number
|
|
31
|
+
tension?: number
|
|
32
|
+
friction?: number
|
|
33
|
+
velocity?: number
|
|
34
|
+
overshootClamping?: boolean
|
|
35
|
+
duration?: number
|
|
36
|
+
bounciness?: number
|
|
37
|
+
speed?: number
|
|
38
|
+
}
|
|
39
|
+
|
|
23
40
|
/**
|
|
24
41
|
* Normalized output format that all animation drivers consume.
|
|
25
42
|
* Provides a consistent structure regardless of input format.
|
|
@@ -35,4 +52,6 @@ export type NormalizedTransition = {
|
|
|
35
52
|
delay: number | undefined
|
|
36
53
|
/** Per-property animation configs: propertyName -> animationKey or config */
|
|
37
54
|
properties: Record<string, string | AnimationConfig>
|
|
55
|
+
/** Global spring config overrides that merge with the preset defaults */
|
|
56
|
+
config?: SpringConfig
|
|
38
57
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { normalizeTransition, getAnimationForProperty, hasAnimation, getAnimatedProperties, getEffectiveAnimation } from "./normalizeTransition";
|
|
1
|
+
export { normalizeTransition, getAnimationForProperty, hasAnimation, getAnimatedProperties, getEffectiveAnimation, getAnimationConfigsForKeys } from "./normalizeTransition";
|
|
2
2
|
export type { AnimationConfig, NormalizedTransition, TransitionPropInput } from "./types";
|
|
3
3
|
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "AAAA,SACE,qBACA,yBACA,cACA,uBACA,
|
|
2
|
+
"mappings": "AAAA,SACE,qBACA,yBACA,cACA,uBACA,uBACA,kCACK;AAEP,cAAc,iBAAiB,sBAAsB,2BAA2B",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/index.ts"
|
|
6
6
|
],
|
|
7
|
+
"version": 3,
|
|
7
8
|
"sourcesContent": [
|
|
8
|
-
"export {\n normalizeTransition,\n getAnimationForProperty,\n hasAnimation,\n getAnimatedProperties,\n getEffectiveAnimation,\n} from './normalizeTransition'\n\nexport type { AnimationConfig, NormalizedTransition, TransitionPropInput } from './types'\n"
|
|
9
|
-
]
|
|
10
|
-
"version": 3
|
|
9
|
+
"export {\n normalizeTransition,\n getAnimationForProperty,\n hasAnimation,\n getAnimatedProperties,\n getEffectiveAnimation,\n getAnimationConfigsForKeys,\n} from './normalizeTransition'\n\nexport type { AnimationConfig, NormalizedTransition, TransitionPropInput } from './types'\n"
|
|
10
|
+
]
|
|
11
11
|
}
|
|
@@ -39,5 +39,16 @@ export declare function getAnimatedProperties(normalized: NormalizedTransition):
|
|
|
39
39
|
* @returns The effective animation key or null
|
|
40
40
|
*/
|
|
41
41
|
export declare function getEffectiveAnimation(normalized: NormalizedTransition, state: "enter" | "exit" | "default"): string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Gets the resolved animation config for each key, looking up in animations config.
|
|
44
|
+
* Useful for calculating max duration across all animated properties.
|
|
45
|
+
*
|
|
46
|
+
* @param normalized - The normalized transition object
|
|
47
|
+
* @param animations - The animations config object (driver-specific format)
|
|
48
|
+
* @param keys - Property keys to get animations for
|
|
49
|
+
* @param defaultAnimation - The default animation value to fall back to
|
|
50
|
+
* @returns Map of key -> resolved animation config (or null if not found)
|
|
51
|
+
*/
|
|
52
|
+
export declare function getAnimationConfigsForKeys<T>(normalized: NormalizedTransition, animations: Record<string, T>, keys: string[], defaultAnimation: T | null): Map<string, T | null>;
|
|
42
53
|
|
|
43
54
|
//# sourceMappingURL=normalizeTransition.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "AAAA,
|
|
2
|
+
"mappings": "AAAA,cACE,iBACA,sBAEA,2BACK;;;;;;;;;;;;;AAkCP,OAAO,iBAAS,oBACd,YAAY,sBACX;;;;;;;;;AAqHH,OAAO,iBAAS,wBACd,YAAY,sBACZ,4BACU;;;;AAcZ,OAAO,iBAAS,aAAa,YAAY;;;;;AAazC,OAAO,iBAAS,sBAAsB,YAAY;;;;;;;;;AAYlD,OAAO,iBAAS,sBACd,YAAY,sBACZ,OAAO,UAAU,SAAS;;;;;;;;;;;AAqB5B,OAAO,iBAAS,2BAA2B,GACzC,YAAY,sBACZ,YAAY,eAAe,IAC3B,gBACA,kBAAkB,WACjB,YAAY",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/normalizeTransition.ts"
|
|
6
6
|
],
|
|
7
|
+
"version": 3,
|
|
7
8
|
"sourcesContent": [
|
|
8
|
-
"import type {
|
|
9
|
-
]
|
|
10
|
-
"version": 3
|
|
9
|
+
"import type {\n AnimationConfig,\n NormalizedTransition,\n SpringConfig,\n TransitionPropInput,\n} from './types'\n\nconst SPRING_CONFIG_KEYS: Set<string> = new Set([\n 'stiffness',\n 'damping',\n 'mass',\n 'tension',\n 'friction',\n 'velocity',\n 'overshootClamping',\n 'duration',\n 'bounciness',\n 'speed',\n])\n\n/**\n * Check if a key is a spring config parameter\n */\nfunction isSpringConfigKey(key: string): key is keyof SpringConfig {\n return SPRING_CONFIG_KEYS.has(key)\n}\n\n/**\n * Normalizes the various transition prop formats into a consistent structure.\n *\n * Supported input formats:\n * - String: \"bouncy\" -> { default: \"bouncy\", enter: null, exit: null, properties: {} }\n * - Object: { x: 'quick', default: 'slow' } -> { default: \"slow\", enter: null, exit: null, properties: { x: \"quick\" } }\n * - Object with enter/exit: { enter: 'bouncy', exit: 'quick' } -> { default: null, enter: \"bouncy\", exit: \"quick\", properties: {} }\n * - Array: ['bouncy', { delay: 100, x: 'quick' }] -> { default: \"bouncy\", enter: null, exit: null, delay: 100, properties: { x: \"quick\" } }\n *\n * @param transition - The transition prop value in any supported format\n * @returns Normalized transition object with consistent structure\n */\nexport function normalizeTransition(\n transition: TransitionPropInput\n): NormalizedTransition {\n // Handle null/undefined\n if (!transition) {\n return {\n default: null,\n enter: null,\n exit: null,\n delay: undefined,\n properties: {},\n }\n }\n\n // String format: \"bouncy\"\n if (typeof transition === 'string') {\n return {\n default: transition,\n enter: null,\n exit: null,\n delay: undefined,\n properties: {},\n }\n }\n\n // Array format: ['bouncy', { delay: 100, x: 'quick', enter: 'slow', exit: 'fast' }]\n // Also supports spring config overrides: ['bouncy', { stiffness: 1000, damping: 70 }]\n if (Array.isArray(transition)) {\n const [defaultAnimation, configObj] = transition\n const properties: Record<string, string | AnimationConfig> = {}\n const springConfig: SpringConfig = {}\n let delay: number | undefined\n let enter: string | null = null\n let exit: string | null = null\n\n if (configObj && typeof configObj === 'object') {\n for (const [key, value] of Object.entries(configObj)) {\n if (key === 'delay' && typeof value === 'number') {\n delay = value\n } else if (key === 'enter' && typeof value === 'string') {\n enter = value\n } else if (key === 'exit' && typeof value === 'string') {\n exit = value\n } else if (isSpringConfigKey(key) && value !== undefined) {\n // Spring config override: { stiffness: 1000, damping: 70 }\n springConfig[key] = value as SpringConfig[keyof SpringConfig]\n } else if (value !== undefined) {\n // Property-specific animation: string or config object\n properties[key] = value as string | AnimationConfig\n }\n }\n }\n\n return {\n default: defaultAnimation,\n enter,\n exit,\n delay,\n properties,\n config: Object.keys(springConfig).length > 0 ? springConfig : undefined,\n }\n }\n\n // Object format: { x: 'quick', y: 'bouncy', default: 'slow', enter: 'bouncy', exit: 'quick' }\n // Also supports spring config overrides: { default: 'bouncy', stiffness: 1000 }\n if (typeof transition === 'object') {\n const properties: Record<string, string | AnimationConfig> = {}\n const springConfig: SpringConfig = {}\n let defaultAnimation: string | null = null\n let enter: string | null = null\n let exit: string | null = null\n let delay: number | undefined\n\n for (const [key, value] of Object.entries(transition)) {\n if (key === 'default' && typeof value === 'string') {\n defaultAnimation = value\n } else if (key === 'enter' && typeof value === 'string') {\n enter = value\n } else if (key === 'exit' && typeof value === 'string') {\n exit = value\n } else if (key === 'delay' && typeof value === 'number') {\n delay = value\n } else if (isSpringConfigKey(key) && value !== undefined) {\n // Spring config override: { stiffness: 1000, damping: 70 }\n springConfig[key] = value as SpringConfig[keyof SpringConfig]\n } else if (value !== undefined) {\n // Property-specific animation: string or config object\n properties[key] = value as string | AnimationConfig\n }\n }\n\n return {\n default: defaultAnimation,\n enter,\n exit,\n delay,\n properties,\n config: Object.keys(springConfig).length > 0 ? springConfig : undefined,\n }\n }\n\n // Fallback\n return {\n default: null,\n enter: null,\n exit: null,\n delay: undefined,\n properties: {},\n }\n}\n\n/**\n * Gets the animation key for a specific property from a normalized transition.\n * Falls back to the default animation if no property-specific one is defined.\n *\n * @param normalized - The normalized transition object\n * @param property - The property name to get animation for (e.g., 'x', 'opacity')\n * @returns The animation key/config or null if none defined\n */\nexport function getAnimationForProperty(\n normalized: NormalizedTransition,\n property: string\n): string | AnimationConfig | null {\n // Check for property-specific animation\n const propertyAnimation = normalized.properties[property]\n if (propertyAnimation !== undefined) {\n return propertyAnimation\n }\n\n // Fall back to default\n return normalized.default\n}\n\n/**\n * Checks if the normalized transition has any animations defined.\n */\nexport function hasAnimation(normalized: NormalizedTransition): boolean {\n return (\n normalized.default !== null ||\n normalized.enter !== null ||\n normalized.exit !== null ||\n Object.keys(normalized.properties).length > 0\n )\n}\n\n/**\n * Gets all property names that have specific animations defined.\n * Does not include 'default' in the list.\n */\nexport function getAnimatedProperties(normalized: NormalizedTransition): string[] {\n return Object.keys(normalized.properties)\n}\n\n/**\n * Gets the effective animation key based on the current animation state.\n * Priority: enter/exit specific > default > null\n *\n * @param normalized - The normalized transition object\n * @param state - The animation state: 'enter', 'exit', or 'default'\n * @returns The effective animation key or null\n */\nexport function getEffectiveAnimation(\n normalized: NormalizedTransition,\n state: 'enter' | 'exit' | 'default'\n): string | null {\n if (state === 'enter' && normalized.enter) {\n return normalized.enter\n }\n if (state === 'exit' && normalized.exit) {\n return normalized.exit\n }\n return normalized.default\n}\n\n/**\n * Gets the resolved animation config for each key, looking up in animations config.\n * Useful for calculating max duration across all animated properties.\n *\n * @param normalized - The normalized transition object\n * @param animations - The animations config object (driver-specific format)\n * @param keys - Property keys to get animations for\n * @param defaultAnimation - The default animation value to fall back to\n * @returns Map of key -> resolved animation config (or null if not found)\n */\nexport function getAnimationConfigsForKeys<T>(\n normalized: NormalizedTransition,\n animations: Record<string, T>,\n keys: string[],\n defaultAnimation: T | null\n): Map<string, T | null> {\n const result = new Map<string, T | null>()\n\n for (const key of keys) {\n const propAnimation = normalized.properties[key]\n let animationValue: T | null = null\n\n if (typeof propAnimation === 'string') {\n animationValue = animations[propAnimation] ?? null\n } else if (\n propAnimation &&\n typeof propAnimation === 'object' &&\n (propAnimation as any).type\n ) {\n animationValue = animations[(propAnimation as any).type] ?? null\n }\n\n // fall back to default if no per-property config found\n if (animationValue === null) {\n animationValue = defaultAnimation\n }\n\n result.set(key, animationValue)\n }\n\n return result\n}\n"
|
|
10
|
+
]
|
|
11
11
|
}
|
package/types/types.d.ts
CHANGED
|
@@ -19,6 +19,22 @@ export type AnimationConfig = {
|
|
|
19
19
|
*/
|
|
20
20
|
export type TransitionPropInput = any;
|
|
21
21
|
/**
|
|
22
|
+
* Spring configuration parameters that can override preset defaults.
|
|
23
|
+
* These are the common parameters across animation drivers.
|
|
24
|
+
*/
|
|
25
|
+
export type SpringConfig = {
|
|
26
|
+
stiffness?: number;
|
|
27
|
+
damping?: number;
|
|
28
|
+
mass?: number;
|
|
29
|
+
tension?: number;
|
|
30
|
+
friction?: number;
|
|
31
|
+
velocity?: number;
|
|
32
|
+
overshootClamping?: boolean;
|
|
33
|
+
duration?: number;
|
|
34
|
+
bounciness?: number;
|
|
35
|
+
speed?: number;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
22
38
|
* Normalized output format that all animation drivers consume.
|
|
23
39
|
* Provides a consistent structure regardless of input format.
|
|
24
40
|
*/
|
|
@@ -33,6 +49,8 @@ export type NormalizedTransition = {
|
|
|
33
49
|
delay: number | undefined;
|
|
34
50
|
/** Per-property animation configs: propertyName -> animationKey or config */
|
|
35
51
|
properties: Record<string, string | AnimationConfig>;
|
|
52
|
+
/** Global spring config overrides that merge with the preset defaults */
|
|
53
|
+
config?: SpringConfig;
|
|
36
54
|
};
|
|
37
55
|
|
|
38
56
|
//# sourceMappingURL=types.d.ts.map
|
package/types/types.d.ts.map
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": ";;;;AAIA,YAAY,kBAAkB;CAC5B;;;;;;;;;;;;;;AAeF,YAAY;;;;;AAMZ,YAAY,uBAAuB;;CAEjC;;CAEA;;CAEA;;CAEA;;CAEA,YAAY,wBAAwB",
|
|
2
|
+
"mappings": ";;;;AAIA,YAAY,kBAAkB;CAC5B;;;;;;;;;;;;;;AAeF,YAAY;;;;;AAMZ,YAAY,eAAe;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;;;;AAOF,YAAY,uBAAuB;;CAEjC;;CAEA;;CAEA;;CAEA;;CAEA,YAAY,wBAAwB;;CAEpC,SAAS",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/types.ts"
|
|
6
6
|
],
|
|
7
|
+
"version": 3,
|
|
7
8
|
"sourcesContent": [
|
|
8
|
-
"/**\n * Animation configuration that can include additional properties\n * like delay, duration, stiffness, damping, etc.\n */\nexport type AnimationConfig = {\n type?: string\n [key: string]: any\n}\n\n/**\n * Input format for the transition prop - supports multiple syntaxes:\n *\n * 1. String: \"bouncy\"\n * 2. Object with property mappings: { x: 'quick', y: 'bouncy', default: 'slow' }\n * 3. Array with config: ['bouncy', { delay: 100, x: 'quick' }]\n * 4. Object with enter/exit: { enter: 'bouncy', exit: 'quick', default: 'slow' }\n *\n * Note: Uses `any` to be compatible with the TransitionProp type from @tamagui/web\n * which has more complex union types.\n */\nexport type TransitionPropInput = any\n\n/**\n * Normalized output format that all animation drivers consume.\n * Provides a consistent structure regardless of input format.\n */\nexport type NormalizedTransition = {\n /** Default animation key for properties not explicitly listed */\n default: string | null\n /** Animation key to use during enter transitions (mount) */\n enter: string | null\n /** Animation key to use during exit transitions (unmount) */\n exit: string | null\n /** Global delay in ms */\n delay: number | undefined\n /** Per-property animation configs: propertyName -> animationKey or config */\n properties: Record<string, string | AnimationConfig>\n}\n"
|
|
9
|
-
]
|
|
10
|
-
"version": 3
|
|
9
|
+
"/**\n * Animation configuration that can include additional properties\n * like delay, duration, stiffness, damping, etc.\n */\nexport type AnimationConfig = {\n type?: string\n [key: string]: any\n}\n\n/**\n * Input format for the transition prop - supports multiple syntaxes:\n *\n * 1. String: \"bouncy\"\n * 2. Object with property mappings: { x: 'quick', y: 'bouncy', default: 'slow' }\n * 3. Array with config: ['bouncy', { delay: 100, x: 'quick' }]\n * 4. Object with enter/exit: { enter: 'bouncy', exit: 'quick', default: 'slow' }\n *\n * Note: Uses `any` to be compatible with the TransitionProp type from @tamagui/web\n * which has more complex union types.\n */\nexport type TransitionPropInput = any\n\n/**\n * Spring configuration parameters that can override preset defaults.\n * These are the common parameters across animation drivers.\n */\nexport type SpringConfig = {\n stiffness?: number\n damping?: number\n mass?: number\n tension?: number\n friction?: number\n velocity?: number\n overshootClamping?: boolean\n duration?: number\n bounciness?: number\n speed?: number\n}\n\n/**\n * Normalized output format that all animation drivers consume.\n * Provides a consistent structure regardless of input format.\n */\nexport type NormalizedTransition = {\n /** Default animation key for properties not explicitly listed */\n default: string | null\n /** Animation key to use during enter transitions (mount) */\n enter: string | null\n /** Animation key to use during exit transitions (unmount) */\n exit: string | null\n /** Global delay in ms */\n delay: number | undefined\n /** Per-property animation configs: propertyName -> animationKey or config */\n properties: Record<string, string | AnimationConfig>\n /** Global spring config overrides that merge with the preset defaults */\n config?: SpringConfig\n}\n"
|
|
10
|
+
]
|
|
11
11
|
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var normalizeTransition_exports = {};
|
|
16
|
-
__export(normalizeTransition_exports, {
|
|
17
|
-
getAnimatedProperties: () => getAnimatedProperties,
|
|
18
|
-
getAnimationForProperty: () => getAnimationForProperty,
|
|
19
|
-
getEffectiveAnimation: () => getEffectiveAnimation,
|
|
20
|
-
hasAnimation: () => hasAnimation,
|
|
21
|
-
normalizeTransition: () => normalizeTransition
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(normalizeTransition_exports);
|
|
24
|
-
function normalizeTransition(transition) {
|
|
25
|
-
if (!transition)
|
|
26
|
-
return {
|
|
27
|
-
default: null,
|
|
28
|
-
enter: null,
|
|
29
|
-
exit: null,
|
|
30
|
-
delay: void 0,
|
|
31
|
-
properties: {}
|
|
32
|
-
};
|
|
33
|
-
if (typeof transition == "string")
|
|
34
|
-
return {
|
|
35
|
-
default: transition,
|
|
36
|
-
enter: null,
|
|
37
|
-
exit: null,
|
|
38
|
-
delay: void 0,
|
|
39
|
-
properties: {}
|
|
40
|
-
};
|
|
41
|
-
if (Array.isArray(transition)) {
|
|
42
|
-
const [defaultAnimation, config] = transition, properties = {};
|
|
43
|
-
let delay, enter = null, exit = null;
|
|
44
|
-
if (config && typeof config == "object")
|
|
45
|
-
for (const [key, value] of Object.entries(config))
|
|
46
|
-
key === "delay" && typeof value == "number" ? delay = value : key === "enter" && typeof value == "string" ? enter = value : key === "exit" && typeof value == "string" ? exit = value : value !== void 0 && (properties[key] = value);
|
|
47
|
-
return {
|
|
48
|
-
default: defaultAnimation,
|
|
49
|
-
enter,
|
|
50
|
-
exit,
|
|
51
|
-
delay,
|
|
52
|
-
properties
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
if (typeof transition == "object") {
|
|
56
|
-
const properties = {};
|
|
57
|
-
let defaultAnimation = null, enter = null, exit = null, delay;
|
|
58
|
-
for (const [key, value] of Object.entries(transition))
|
|
59
|
-
key === "default" && typeof value == "string" ? defaultAnimation = value : key === "enter" && typeof value == "string" ? enter = value : key === "exit" && typeof value == "string" ? exit = value : key === "delay" && typeof value == "number" ? delay = value : value !== void 0 && (properties[key] = value);
|
|
60
|
-
return {
|
|
61
|
-
default: defaultAnimation,
|
|
62
|
-
enter,
|
|
63
|
-
exit,
|
|
64
|
-
delay,
|
|
65
|
-
properties
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
default: null,
|
|
70
|
-
enter: null,
|
|
71
|
-
exit: null,
|
|
72
|
-
delay: void 0,
|
|
73
|
-
properties: {}
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
function getAnimationForProperty(normalized, property) {
|
|
77
|
-
const propertyAnimation = normalized.properties[property];
|
|
78
|
-
return propertyAnimation !== void 0 ? propertyAnimation : normalized.default;
|
|
79
|
-
}
|
|
80
|
-
function hasAnimation(normalized) {
|
|
81
|
-
return normalized.default !== null || normalized.enter !== null || normalized.exit !== null || Object.keys(normalized.properties).length > 0;
|
|
82
|
-
}
|
|
83
|
-
function getAnimatedProperties(normalized) {
|
|
84
|
-
return Object.keys(normalized.properties);
|
|
85
|
-
}
|
|
86
|
-
function getEffectiveAnimation(normalized, state) {
|
|
87
|
-
return state === "enter" && normalized.enter ? normalized.enter : state === "exit" && normalized.exit ? normalized.exit : normalized.default;
|
|
88
|
-
}
|
|
89
|
-
//# sourceMappingURL=normalizeTransition.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/normalizeTransition.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcO,SAAS,oBACd,YACsB;AAEtB,MAAI,CAAC;AACH,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,MACP,MAAM;AAAA,MACN,OAAO;AAAA,MACP,YAAY,CAAC;AAAA,IACf;AAIF,MAAI,OAAO,cAAe;AACxB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,MACP,MAAM;AAAA,MACN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BAIF,WAAW;AACpB;AAKO,SAAS,aAAa,YAA2C;AACtE,SACE,WAAW,YAAY,QACvB,WAAW,UAAU,QACrB,WAAW,SAAS,QACpB,OAAO,KAAK,WAAW,UAAU,EAAE,SAAS;AAEhD;AAMO,SAAS,sBAAsB,YAA4C;AAChF,SAAO,OAAO,KAAK,WAAW,UAAU;AAC1C;AAUO,SAAS,sBACd,YACA,OACe;AACf,SAAI,UAAU,WAAW,WAAW,QAC3B,WAAW,QAEhB,UAAU,UAAU,WAAW,OAC1B,WAAW,OAEb,WAAW;AACpB;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/cjs/types.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
-
return to;
|
|
10
|
-
};
|
|
11
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
-
var types_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(types_exports);
|
|
14
|
-
//# sourceMappingURL=types.js.map
|
package/dist/cjs/types.js.map
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
function normalizeTransition(transition) {
|
|
2
|
-
if (!transition)
|
|
3
|
-
return {
|
|
4
|
-
default: null,
|
|
5
|
-
enter: null,
|
|
6
|
-
exit: null,
|
|
7
|
-
delay: void 0,
|
|
8
|
-
properties: {}
|
|
9
|
-
};
|
|
10
|
-
if (typeof transition == "string")
|
|
11
|
-
return {
|
|
12
|
-
default: transition,
|
|
13
|
-
enter: null,
|
|
14
|
-
exit: null,
|
|
15
|
-
delay: void 0,
|
|
16
|
-
properties: {}
|
|
17
|
-
};
|
|
18
|
-
if (Array.isArray(transition)) {
|
|
19
|
-
const [defaultAnimation, config] = transition, properties = {};
|
|
20
|
-
let delay, enter = null, exit = null;
|
|
21
|
-
if (config && typeof config == "object")
|
|
22
|
-
for (const [key, value] of Object.entries(config))
|
|
23
|
-
key === "delay" && typeof value == "number" ? delay = value : key === "enter" && typeof value == "string" ? enter = value : key === "exit" && typeof value == "string" ? exit = value : value !== void 0 && (properties[key] = value);
|
|
24
|
-
return {
|
|
25
|
-
default: defaultAnimation,
|
|
26
|
-
enter,
|
|
27
|
-
exit,
|
|
28
|
-
delay,
|
|
29
|
-
properties
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
if (typeof transition == "object") {
|
|
33
|
-
const properties = {};
|
|
34
|
-
let defaultAnimation = null, enter = null, exit = null, delay;
|
|
35
|
-
for (const [key, value] of Object.entries(transition))
|
|
36
|
-
key === "default" && typeof value == "string" ? defaultAnimation = value : key === "enter" && typeof value == "string" ? enter = value : key === "exit" && typeof value == "string" ? exit = value : key === "delay" && typeof value == "number" ? delay = value : value !== void 0 && (properties[key] = value);
|
|
37
|
-
return {
|
|
38
|
-
default: defaultAnimation,
|
|
39
|
-
enter,
|
|
40
|
-
exit,
|
|
41
|
-
delay,
|
|
42
|
-
properties
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
default: null,
|
|
47
|
-
enter: null,
|
|
48
|
-
exit: null,
|
|
49
|
-
delay: void 0,
|
|
50
|
-
properties: {}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function getAnimationForProperty(normalized, property) {
|
|
54
|
-
const propertyAnimation = normalized.properties[property];
|
|
55
|
-
return propertyAnimation !== void 0 ? propertyAnimation : normalized.default;
|
|
56
|
-
}
|
|
57
|
-
function hasAnimation(normalized) {
|
|
58
|
-
return normalized.default !== null || normalized.enter !== null || normalized.exit !== null || Object.keys(normalized.properties).length > 0;
|
|
59
|
-
}
|
|
60
|
-
function getAnimatedProperties(normalized) {
|
|
61
|
-
return Object.keys(normalized.properties);
|
|
62
|
-
}
|
|
63
|
-
function getEffectiveAnimation(normalized, state) {
|
|
64
|
-
return state === "enter" && normalized.enter ? normalized.enter : state === "exit" && normalized.exit ? normalized.exit : normalized.default;
|
|
65
|
-
}
|
|
66
|
-
export {
|
|
67
|
-
getAnimatedProperties,
|
|
68
|
-
getAnimationForProperty,
|
|
69
|
-
getEffectiveAnimation,
|
|
70
|
-
hasAnimation,
|
|
71
|
-
normalizeTransition
|
|
72
|
-
};
|
|
73
|
-
//# sourceMappingURL=normalizeTransition.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/normalizeTransition.ts"],
|
|
4
|
-
"mappings": "AAcO,SAAS,oBACd,YACsB;AAEtB,MAAI,CAAC;AACH,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,MACP,MAAM;AAAA,MACN,OAAO;AAAA,MACP,YAAY,CAAC;AAAA,IACf;AAIF,MAAI,OAAO,cAAe;AACxB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,MACP,MAAM;AAAA,MACN,OAAO;AAAA,MACP,YAAY,CAAC;AAAA,IACf;AAIF,MAAI,MAAM,QAAQ,UAAU,GAAG;AAC7B,UAAM,CAAC,kBAAkB,MAAM,IAAI,YAC7B,aAAuD,CAAC;AAC9D,QAAI,OACA,QAAuB,MACvB,OAAsB;AAE1B,QAAI,UAAU,OAAO,UAAW;AAC9B,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM;AAC9C,QAAI,QAAQ,WAAW,OAAO,SAAU,WACtC,QAAQ,QACC,QAAQ,WAAW,OAAO,SAAU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