@hanzogui/animation-helpers 8.3.0 → 8.3.2

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.
Files changed (43) hide show
  1. package/dist/cjs/index.js +11 -0
  2. package/dist/cjs/index.js.map +1 -0
  3. package/dist/cjs/normalizeTransition.js +229 -0
  4. package/dist/cjs/normalizeTransition.js.map +1 -0
  5. package/dist/cjs/package.json +1 -0
  6. package/dist/cjs/types.js +3 -0
  7. package/dist/cjs/types.js.map +1 -0
  8. package/dist/esm/index.js +2 -3
  9. package/dist/esm/index.js.map +1 -1
  10. package/dist/esm/normalizeTransition.js +221 -0
  11. package/dist/esm/normalizeTransition.js.map +1 -0
  12. package/dist/esm/types.js +2 -0
  13. package/dist/esm/types.js.map +1 -0
  14. package/package.json +11 -11
  15. package/src/index.ts +6 -2
  16. package/src/normalizeTransition.ts +3 -3
  17. package/types/index.d.ts +2 -3
  18. package/types/index.d.ts.map +1 -11
  19. package/types/normalizeTransition.d.ts +41 -42
  20. package/types/normalizeTransition.d.ts.map +1 -11
  21. package/types/types.d.ts +43 -44
  22. package/types/types.d.ts.map +1 -11
  23. package/dist/cjs/index.cjs +0 -33
  24. package/dist/cjs/index.native.js +0 -36
  25. package/dist/cjs/index.native.js.map +0 -1
  26. package/dist/cjs/normalizeTransition.cjs +0 -164
  27. package/dist/cjs/normalizeTransition.native.js +0 -231
  28. package/dist/cjs/normalizeTransition.native.js.map +0 -1
  29. package/dist/cjs/types.cjs +0 -18
  30. package/dist/cjs/types.native.js +0 -21
  31. package/dist/cjs/types.native.js.map +0 -1
  32. package/dist/esm/index.mjs +0 -3
  33. package/dist/esm/index.mjs.map +0 -1
  34. package/dist/esm/index.native.js +0 -3
  35. package/dist/esm/index.native.js.map +0 -1
  36. package/dist/esm/normalizeTransition.mjs +0 -134
  37. package/dist/esm/normalizeTransition.mjs.map +0 -1
  38. package/dist/esm/normalizeTransition.native.js +0 -198
  39. package/dist/esm/normalizeTransition.native.js.map +0 -1
  40. package/dist/esm/types.mjs +0 -2
  41. package/dist/esm/types.mjs.map +0 -1
  42. package/dist/esm/types.native.js +0 -2
  43. package/dist/esm/types.native.js.map +0 -1
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAnimationConfigsForKeys = exports.getEffectiveAnimation = exports.getAnimatedProperties = exports.hasAnimation = exports.getAnimationForProperty = exports.normalizeTransition = void 0;
4
+ var normalizeTransition_ts_1 = require("./normalizeTransition.js");
5
+ Object.defineProperty(exports, "normalizeTransition", { enumerable: true, get: function () { return normalizeTransition_ts_1.normalizeTransition; } });
6
+ Object.defineProperty(exports, "getAnimationForProperty", { enumerable: true, get: function () { return normalizeTransition_ts_1.getAnimationForProperty; } });
7
+ Object.defineProperty(exports, "hasAnimation", { enumerable: true, get: function () { return normalizeTransition_ts_1.hasAnimation; } });
8
+ Object.defineProperty(exports, "getAnimatedProperties", { enumerable: true, get: function () { return normalizeTransition_ts_1.getAnimatedProperties; } });
9
+ Object.defineProperty(exports, "getEffectiveAnimation", { enumerable: true, get: function () { return normalizeTransition_ts_1.getEffectiveAnimation; } });
10
+ Object.defineProperty(exports, "getAnimationConfigsForKeys", { enumerable: true, get: function () { return normalizeTransition_ts_1.getAnimationConfigsForKeys; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,mEAOiC;AAN/B,6HAAA,mBAAmB,OAAA;AACnB,iIAAA,uBAAuB,OAAA;AACvB,sHAAA,YAAY,OAAA;AACZ,+HAAA,qBAAqB,OAAA;AACrB,+HAAA,qBAAqB,OAAA;AACrB,oIAAA,0BAA0B,OAAA"}
@@ -0,0 +1,229 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeTransition = normalizeTransition;
4
+ exports.getAnimationForProperty = getAnimationForProperty;
5
+ exports.hasAnimation = hasAnimation;
6
+ exports.getAnimatedProperties = getAnimatedProperties;
7
+ exports.getEffectiveAnimation = getEffectiveAnimation;
8
+ exports.getAnimationConfigsForKeys = getAnimationConfigsForKeys;
9
+ const SPRING_CONFIG_KEYS = new Set([
10
+ 'stiffness',
11
+ 'damping',
12
+ 'mass',
13
+ 'tension',
14
+ 'friction',
15
+ 'velocity',
16
+ 'overshootClamping',
17
+ 'duration',
18
+ 'bounciness',
19
+ 'speed',
20
+ ]);
21
+ /**
22
+ * Check if a key is a spring config parameter
23
+ */
24
+ function isSpringConfigKey(key) {
25
+ return SPRING_CONFIG_KEYS.has(key);
26
+ }
27
+ /**
28
+ * Normalizes the various transition prop formats into a consistent structure.
29
+ *
30
+ * Supported input formats:
31
+ * - String: "bouncy" -> { default: "bouncy", enter: null, exit: null, properties: {} }
32
+ * - Object: { x: 'quick', default: 'slow' } -> { default: "slow", enter: null, exit: null, properties: { x: "quick" } }
33
+ * - Object with enter/exit: { enter: 'bouncy', exit: 'quick' } -> { default: null, enter: "bouncy", exit: "quick", properties: {} }
34
+ * - Array: ['bouncy', { delay: 100, x: 'quick' }] -> { default: "bouncy", enter: null, exit: null, delay: 100, properties: { x: "quick" } }
35
+ *
36
+ * @param transition - The transition prop value in any supported format
37
+ * @returns Normalized transition object with consistent structure
38
+ */
39
+ function normalizeTransition(transition) {
40
+ // Handle null/undefined
41
+ if (!transition) {
42
+ return {
43
+ default: null,
44
+ enter: null,
45
+ exit: null,
46
+ delay: undefined,
47
+ properties: {},
48
+ };
49
+ }
50
+ // String format: "bouncy"
51
+ if (typeof transition === 'string') {
52
+ return {
53
+ default: transition,
54
+ enter: null,
55
+ exit: null,
56
+ delay: undefined,
57
+ properties: {},
58
+ };
59
+ }
60
+ // Array format: ['bouncy', { delay: 100, x: 'quick', enter: 'slow', exit: 'fast' }]
61
+ // Also supports spring config overrides: ['bouncy', { stiffness: 1000, damping: 70 }]
62
+ if (Array.isArray(transition)) {
63
+ const [defaultAnimation, configObj] = transition;
64
+ const properties = {};
65
+ const springConfig = {};
66
+ let delay;
67
+ let enter = null;
68
+ let exit = null;
69
+ if (configObj && typeof configObj === 'object') {
70
+ for (const [key, value] of Object.entries(configObj)) {
71
+ if (key === 'delay' && typeof value === 'number') {
72
+ delay = value;
73
+ }
74
+ else if (key === 'enter' && typeof value === 'string') {
75
+ enter = value;
76
+ }
77
+ else if (key === 'exit' && typeof value === 'string') {
78
+ exit = value;
79
+ }
80
+ else if (isSpringConfigKey(key) && value !== undefined) {
81
+ // Spring config override: { stiffness: 1000, damping: 70 }
82
+ Object.assign(springConfig, { [key]: value });
83
+ }
84
+ else if (value !== undefined) {
85
+ // Property-specific animation: string or config object
86
+ properties[key] = value;
87
+ }
88
+ }
89
+ }
90
+ return {
91
+ default: defaultAnimation,
92
+ enter,
93
+ exit,
94
+ delay,
95
+ properties,
96
+ config: Object.keys(springConfig).length > 0 ? springConfig : undefined,
97
+ };
98
+ }
99
+ // Object format: { x: 'quick', y: 'bouncy', default: 'slow', enter: 'bouncy', exit: 'quick' }
100
+ // Also supports spring config overrides: { default: 'bouncy', stiffness: 1000 }
101
+ if (typeof transition === 'object') {
102
+ const properties = {};
103
+ const springConfig = {};
104
+ let defaultAnimation = null;
105
+ let enter = null;
106
+ let exit = null;
107
+ let delay;
108
+ for (const [key, value] of Object.entries(transition)) {
109
+ if (key === 'default' && typeof value === 'string') {
110
+ defaultAnimation = value;
111
+ }
112
+ else if (key === 'enter' && typeof value === 'string') {
113
+ enter = value;
114
+ }
115
+ else if (key === 'exit' && typeof value === 'string') {
116
+ exit = value;
117
+ }
118
+ else if (key === 'delay' && typeof value === 'number') {
119
+ delay = value;
120
+ }
121
+ else if (isSpringConfigKey(key) && value !== undefined) {
122
+ // Spring config override: { stiffness: 1000, damping: 70 }
123
+ Object.assign(springConfig, { [key]: value });
124
+ }
125
+ else if (value !== undefined) {
126
+ // Property-specific animation: string or config object
127
+ properties[key] = value;
128
+ }
129
+ }
130
+ return {
131
+ default: defaultAnimation,
132
+ enter,
133
+ exit,
134
+ delay,
135
+ properties,
136
+ config: Object.keys(springConfig).length > 0 ? springConfig : undefined,
137
+ };
138
+ }
139
+ // Fallback
140
+ return {
141
+ default: null,
142
+ enter: null,
143
+ exit: null,
144
+ delay: undefined,
145
+ properties: {},
146
+ };
147
+ }
148
+ /**
149
+ * Gets the animation key for a specific property from a normalized transition.
150
+ * Falls back to the default animation if no property-specific one is defined.
151
+ *
152
+ * @param normalized - The normalized transition object
153
+ * @param property - The property name to get animation for (e.g., 'x', 'opacity')
154
+ * @returns The animation key/config or null if none defined
155
+ */
156
+ function getAnimationForProperty(normalized, property) {
157
+ // Check for property-specific animation
158
+ const propertyAnimation = normalized.properties[property];
159
+ if (propertyAnimation !== undefined) {
160
+ return propertyAnimation;
161
+ }
162
+ // Fall back to default
163
+ return normalized.default;
164
+ }
165
+ /**
166
+ * Checks if the normalized transition has any animations defined.
167
+ */
168
+ function hasAnimation(normalized) {
169
+ return (normalized.default !== null ||
170
+ normalized.enter !== null ||
171
+ normalized.exit !== null ||
172
+ Object.keys(normalized.properties).length > 0);
173
+ }
174
+ /**
175
+ * Gets all property names that have specific animations defined.
176
+ * Does not include 'default' in the list.
177
+ */
178
+ function getAnimatedProperties(normalized) {
179
+ return Object.keys(normalized.properties);
180
+ }
181
+ /**
182
+ * Gets the effective animation key based on the current animation state.
183
+ * Priority: enter/exit specific > default > null
184
+ *
185
+ * @param normalized - The normalized transition object
186
+ * @param state - The animation state: 'enter', 'exit', or 'default'
187
+ * @returns The effective animation key or null
188
+ */
189
+ function getEffectiveAnimation(normalized, state) {
190
+ if (state === 'enter' && normalized.enter) {
191
+ return normalized.enter;
192
+ }
193
+ if (state === 'exit' && normalized.exit) {
194
+ return normalized.exit;
195
+ }
196
+ return normalized.default;
197
+ }
198
+ /**
199
+ * Gets the resolved animation config for each key, looking up in animations config.
200
+ * Useful for calculating max duration across all animated properties.
201
+ *
202
+ * @param normalized - The normalized transition object
203
+ * @param animations - The animations config object (driver-specific format)
204
+ * @param keys - Property keys to get animations for
205
+ * @param defaultAnimation - The default animation value to fall back to
206
+ * @returns Map of key -> resolved animation config (or null if not found)
207
+ */
208
+ function getAnimationConfigsForKeys(normalized, animations, keys, defaultAnimation) {
209
+ const result = new Map();
210
+ for (const key of keys) {
211
+ const propAnimation = normalized.properties[key];
212
+ let animationValue = null;
213
+ if (typeof propAnimation === 'string') {
214
+ animationValue = animations[propAnimation] ?? null;
215
+ }
216
+ else if (propAnimation &&
217
+ typeof propAnimation === 'object' &&
218
+ propAnimation.type) {
219
+ animationValue = animations[propAnimation.type] ?? null;
220
+ }
221
+ // fall back to default if no per-property config found
222
+ if (animationValue === null) {
223
+ animationValue = defaultAnimation;
224
+ }
225
+ result.set(key, animationValue);
226
+ }
227
+ return result;
228
+ }
229
+ //# sourceMappingURL=normalizeTransition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeTransition.js","sourceRoot":"","sources":["../../src/normalizeTransition.ts"],"names":[],"mappings":";;;;;;;;AAOA,MAAM,kBAAkB,GAAgB,IAAI,GAAG,CAAC;IAC9C,WAAW;IACX,SAAS;IACT,MAAM;IACN,SAAS;IACT,UAAU;IACV,UAAU;IACV,mBAAmB;IACnB,UAAU;IACV,YAAY;IACZ,OAAO;CACR,CAAC,CAAA;AAEF;;GAEG;AACH,SAAS,iBAAiB,CAAC,GAAW;IACpC,OAAO,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACpC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,6BACE,UAA+B;IAE/B,wBAAwB;IACxB,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO;YACL,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,SAAS;YAChB,UAAU,EAAE,EAAE;SACf,CAAA;IACH,CAAC;IAED,0BAA0B;IAC1B,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE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AACf,CAAC"}
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
package/dist/esm/index.js CHANGED
@@ -1,3 +1,2 @@
1
- import { normalizeTransition, getAnimationForProperty, hasAnimation, getAnimatedProperties, getEffectiveAnimation, getAnimationConfigsForKeys } from "./normalizeTransition.mjs";
2
- export { getAnimatedProperties, getAnimationConfigsForKeys, getAnimationForProperty, getEffectiveAnimation, hasAnimation, normalizeTransition };
3
- //# sourceMappingURL=index.js.map
1
+ export { normalizeTransition, getAnimationForProperty, hasAnimation, getAnimatedProperties, getEffectiveAnimation, getAnimationConfigsForKeys, } from './normalizeTransition.js';
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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":[]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,YAAY,EACZ,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,0BAA0B,CAAA"}
@@ -0,0 +1,221 @@
1
+ const SPRING_CONFIG_KEYS = new Set([
2
+ 'stiffness',
3
+ 'damping',
4
+ 'mass',
5
+ 'tension',
6
+ 'friction',
7
+ 'velocity',
8
+ 'overshootClamping',
9
+ 'duration',
10
+ 'bounciness',
11
+ 'speed',
12
+ ]);
13
+ /**
14
+ * Check if a key is a spring config parameter
15
+ */
16
+ function isSpringConfigKey(key) {
17
+ return SPRING_CONFIG_KEYS.has(key);
18
+ }
19
+ /**
20
+ * Normalizes the various transition prop formats into a consistent structure.
21
+ *
22
+ * Supported input formats:
23
+ * - String: "bouncy" -> { default: "bouncy", enter: null, exit: null, properties: {} }
24
+ * - Object: { x: 'quick', default: 'slow' } -> { default: "slow", enter: null, exit: null, properties: { x: "quick" } }
25
+ * - Object with enter/exit: { enter: 'bouncy', exit: 'quick' } -> { default: null, enter: "bouncy", exit: "quick", properties: {} }
26
+ * - Array: ['bouncy', { delay: 100, x: 'quick' }] -> { default: "bouncy", enter: null, exit: null, delay: 100, properties: { x: "quick" } }
27
+ *
28
+ * @param transition - The transition prop value in any supported format
29
+ * @returns Normalized transition object with consistent structure
30
+ */
31
+ export function normalizeTransition(transition) {
32
+ // Handle null/undefined
33
+ if (!transition) {
34
+ return {
35
+ default: null,
36
+ enter: null,
37
+ exit: null,
38
+ delay: undefined,
39
+ properties: {},
40
+ };
41
+ }
42
+ // String format: "bouncy"
43
+ if (typeof transition === 'string') {
44
+ return {
45
+ default: transition,
46
+ enter: null,
47
+ exit: null,
48
+ delay: undefined,
49
+ properties: {},
50
+ };
51
+ }
52
+ // Array format: ['bouncy', { delay: 100, x: 'quick', enter: 'slow', exit: 'fast' }]
53
+ // Also supports spring config overrides: ['bouncy', { stiffness: 1000, damping: 70 }]
54
+ if (Array.isArray(transition)) {
55
+ const [defaultAnimation, configObj] = transition;
56
+ const properties = {};
57
+ const springConfig = {};
58
+ let delay;
59
+ let enter = null;
60
+ let exit = null;
61
+ if (configObj && typeof configObj === 'object') {
62
+ for (const [key, value] of Object.entries(configObj)) {
63
+ if (key === 'delay' && typeof value === 'number') {
64
+ delay = value;
65
+ }
66
+ else if (key === 'enter' && typeof value === 'string') {
67
+ enter = value;
68
+ }
69
+ else if (key === 'exit' && typeof value === 'string') {
70
+ exit = value;
71
+ }
72
+ else if (isSpringConfigKey(key) && value !== undefined) {
73
+ // Spring config override: { stiffness: 1000, damping: 70 }
74
+ Object.assign(springConfig, { [key]: value });
75
+ }
76
+ else if (value !== undefined) {
77
+ // Property-specific animation: string or config object
78
+ properties[key] = value;
79
+ }
80
+ }
81
+ }
82
+ return {
83
+ default: defaultAnimation,
84
+ enter,
85
+ exit,
86
+ delay,
87
+ properties,
88
+ config: Object.keys(springConfig).length > 0 ? springConfig : undefined,
89
+ };
90
+ }
91
+ // Object format: { x: 'quick', y: 'bouncy', default: 'slow', enter: 'bouncy', exit: 'quick' }
92
+ // Also supports spring config overrides: { default: 'bouncy', stiffness: 1000 }
93
+ if (typeof transition === 'object') {
94
+ const properties = {};
95
+ const springConfig = {};
96
+ let defaultAnimation = null;
97
+ let enter = null;
98
+ let exit = null;
99
+ let delay;
100
+ for (const [key, value] of Object.entries(transition)) {
101
+ if (key === 'default' && typeof value === 'string') {
102
+ defaultAnimation = value;
103
+ }
104
+ else if (key === 'enter' && typeof value === 'string') {
105
+ enter = value;
106
+ }
107
+ else if (key === 'exit' && typeof value === 'string') {
108
+ exit = value;
109
+ }
110
+ else if (key === 'delay' && typeof value === 'number') {
111
+ delay = value;
112
+ }
113
+ else if (isSpringConfigKey(key) && value !== undefined) {
114
+ // Spring config override: { stiffness: 1000, damping: 70 }
115
+ Object.assign(springConfig, { [key]: value });
116
+ }
117
+ else if (value !== undefined) {
118
+ // Property-specific animation: string or config object
119
+ properties[key] = value;
120
+ }
121
+ }
122
+ return {
123
+ default: defaultAnimation,
124
+ enter,
125
+ exit,
126
+ delay,
127
+ properties,
128
+ config: Object.keys(springConfig).length > 0 ? springConfig : undefined,
129
+ };
130
+ }
131
+ // Fallback
132
+ return {
133
+ default: null,
134
+ enter: null,
135
+ exit: null,
136
+ delay: undefined,
137
+ properties: {},
138
+ };
139
+ }
140
+ /**
141
+ * Gets the animation key for a specific property from a normalized transition.
142
+ * Falls back to the default animation if no property-specific one is defined.
143
+ *
144
+ * @param normalized - The normalized transition object
145
+ * @param property - The property name to get animation for (e.g., 'x', 'opacity')
146
+ * @returns The animation key/config or null if none defined
147
+ */
148
+ export function getAnimationForProperty(normalized, property) {
149
+ // Check for property-specific animation
150
+ const propertyAnimation = normalized.properties[property];
151
+ if (propertyAnimation !== undefined) {
152
+ return propertyAnimation;
153
+ }
154
+ // Fall back to default
155
+ return normalized.default;
156
+ }
157
+ /**
158
+ * Checks if the normalized transition has any animations defined.
159
+ */
160
+ export function hasAnimation(normalized) {
161
+ return (normalized.default !== null ||
162
+ normalized.enter !== null ||
163
+ normalized.exit !== null ||
164
+ Object.keys(normalized.properties).length > 0);
165
+ }
166
+ /**
167
+ * Gets all property names that have specific animations defined.
168
+ * Does not include 'default' in the list.
169
+ */
170
+ export function getAnimatedProperties(normalized) {
171
+ return Object.keys(normalized.properties);
172
+ }
173
+ /**
174
+ * Gets the effective animation key based on the current animation state.
175
+ * Priority: enter/exit specific > default > null
176
+ *
177
+ * @param normalized - The normalized transition object
178
+ * @param state - The animation state: 'enter', 'exit', or 'default'
179
+ * @returns The effective animation key or null
180
+ */
181
+ export function getEffectiveAnimation(normalized, state) {
182
+ if (state === 'enter' && normalized.enter) {
183
+ return normalized.enter;
184
+ }
185
+ if (state === 'exit' && normalized.exit) {
186
+ return normalized.exit;
187
+ }
188
+ return normalized.default;
189
+ }
190
+ /**
191
+ * Gets the resolved animation config for each key, looking up in animations config.
192
+ * Useful for calculating max duration across all animated properties.
193
+ *
194
+ * @param normalized - The normalized transition object
195
+ * @param animations - The animations config object (driver-specific format)
196
+ * @param keys - Property keys to get animations for
197
+ * @param defaultAnimation - The default animation value to fall back to
198
+ * @returns Map of key -> resolved animation config (or null if not found)
199
+ */
200
+ export function getAnimationConfigsForKeys(normalized, animations, keys, defaultAnimation) {
201
+ const result = new Map();
202
+ for (const key of keys) {
203
+ const propAnimation = normalized.properties[key];
204
+ let animationValue = null;
205
+ if (typeof propAnimation === 'string') {
206
+ animationValue = animations[propAnimation] ?? null;
207
+ }
208
+ else if (propAnimation &&
209
+ typeof propAnimation === 'object' &&
210
+ propAnimation.type) {
211
+ animationValue = animations[propAnimation.type] ?? null;
212
+ }
213
+ // fall back to default if no per-property config found
214
+ if (animationValue === null) {
215
+ animationValue = defaultAnimation;
216
+ }
217
+ result.set(key, animationValue);
218
+ }
219
+ return result;
220
+ }
221
+ //# sourceMappingURL=normalizeTransition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeTransition.js","sourceRoot":"","sources":["../../src/normalizeTransition.ts"],"names":[],"mappings":"AAOA,MAAM,kBAAkB,GAAgB,IAAI,GAAG,CAAC;IAC9C,WAAW;IACX,SAAS;IACT,MAAM;IACN,SAAS;IACT,UAAU;IACV,UAAU;IACV,mBAAmB;IACnB,UAAU;IACV,YAAY;IACZ,OAAO;CACR,CAAC,CAAA;AAEF;;GAEG;AACH,SAAS,iBAAiB,CAAC,GAAW;IACpC,OAAO,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACpC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CACjC,UAA+B;IAE/B,wBAAwB;IACxB,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO;YACL,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,SAAS;YAChB,UAAU,EAAE,EAAE;SACf,CAAA;IACH,CAAC;IAED,0BAA0B;IAC1B,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;QACnC,OAAO;YACL,OAAO,EAAE,UAAU;YACnB,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,SAAS;YAChB,UAAU,EAAE,EAAE;SACf,CAAA;IACH,CAAC;IAED,oFAAoF;IACpF,sFAAsF;IACtF,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,MAAM,CAAC,gBAAgB,EAAE,SAAS,CAAC,GAAG,UAAU,CAAA;QAChD,MAAM,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E,CAAC;QAC1C,OAAO,UAAU,CAAC,KAAK,CAAA;IACzB,CAAC;IACD,IAAI,KAAK,KAAK,MAAM,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;QACxC,OAAO,UAAU,CAAC,IAAI,CAAA;IACxB,CAAC;IACD,OAAO,UAAU,CAAC,OAAO,CAAA;AAC3B,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,0BAA0B,CACxC,UAAgC,EAChC,UAA6B,EAC7B,IAAc,EACd,gBAA0B;IAE1B,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoB,CAAA;IAE1C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,aAAa,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;QAChD,IAAI,cAAc,GAAa,IAAI,CAAA;QAEnC,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;YACtC,cAAc,GAAG,UAAU,CAAC,aAAa,CAAC,IAAI,IAAI,CAAA;QACpD,CAAC;aAAM,IACL,aAAa;YACb,OAAO,aAAa,KAAK,QAAQ;YAChC,aAAqB,CAAC,IAAI,EAC3B,CAAC;YACD,cAAc,GAAG,UAAU,CAAE,aAAqB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAA;QAClE,CAAC;QAED,uDAAuD;QACvD,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;YAC5B,cAAc,GAAG,gBAAgB,CAAA;QACnC,CAAC;QAED,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,cAAc,CAAC,CAAA;IACjC,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzogui/animation-helpers",
3
- "version": "8.3.0",
3
+ "version": "8.3.2",
4
4
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
5
5
  "license": "MIT",
6
6
  "source": "src/index.ts",
@@ -11,32 +11,32 @@
11
11
  ],
12
12
  "type": "module",
13
13
  "sideEffects": false,
14
- "main": "dist/cjs",
15
- "module": "dist/esm",
14
+ "main": "./dist/cjs/index.js",
15
+ "module": "./dist/esm/index.js",
16
16
  "types": "./types/index.d.ts",
17
17
  "exports": {
18
18
  "./package.json": "./package.json",
19
19
  ".": {
20
20
  "types": "./types/index.d.ts",
21
- "react-native": "./dist/esm/index.native.js",
22
- "browser": "./dist/esm/index.mjs",
23
- "module": "./dist/esm/index.mjs",
24
- "import": "./dist/esm/index.mjs",
25
- "require": "./dist/cjs/index.cjs",
26
- "default": "./dist/esm/index.mjs"
21
+ "react-native": "./dist/esm/index.js",
22
+ "browser": "./dist/esm/index.js",
23
+ "module": "./dist/esm/index.js",
24
+ "import": "./dist/esm/index.js",
25
+ "require": "./dist/cjs/index.js",
26
+ "default": "./dist/esm/index.js"
27
27
  }
28
28
  },
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
32
  "scripts": {
33
- "build": "hanzogui-build",
33
+ "build": "hanzogui-build --skip-native",
34
34
  "watch": "hanzogui-build --watch",
35
35
  "clean": "hanzogui-build clean",
36
36
  "clean:build": "hanzogui-build clean:build"
37
37
  },
38
38
  "devDependencies": {
39
- "@hanzogui/build": "8.3.0"
39
+ "@hanzogui/build": "8.3.2"
40
40
  },
41
41
  "repository": {
42
42
  "type": "git",
package/src/index.ts CHANGED
@@ -5,6 +5,10 @@ export {
5
5
  getAnimatedProperties,
6
6
  getEffectiveAnimation,
7
7
  getAnimationConfigsForKeys,
8
- } from './normalizeTransition'
8
+ } from './normalizeTransition.ts'
9
9
 
10
- export type { AnimationConfig, NormalizedTransition, TransitionPropInput } from './types'
10
+ export type {
11
+ AnimationConfig,
12
+ NormalizedTransition,
13
+ TransitionPropInput,
14
+ } from './types.ts'
@@ -3,7 +3,7 @@ import type {
3
3
  NormalizedTransition,
4
4
  SpringConfig,
5
5
  TransitionPropInput,
6
- } from './types'
6
+ } from './types.ts'
7
7
 
8
8
  const SPRING_CONFIG_KEYS: Set<string> = new Set([
9
9
  'stiffness',
@@ -82,7 +82,7 @@ export function normalizeTransition(
82
82
  exit = value
83
83
  } else if (isSpringConfigKey(key) && value !== undefined) {
84
84
  // Spring config override: { stiffness: 1000, damping: 70 }
85
- springConfig[key] = value as SpringConfig[keyof SpringConfig]
85
+ Object.assign(springConfig, { [key]: value })
86
86
  } else if (value !== undefined) {
87
87
  // Property-specific animation: string or config object
88
88
  properties[key] = value as string | AnimationConfig
@@ -121,7 +121,7 @@ export function normalizeTransition(
121
121
  delay = value
122
122
  } else if (isSpringConfigKey(key) && value !== undefined) {
123
123
  // Spring config override: { stiffness: 1000, damping: 70 }
124
- springConfig[key] = value as SpringConfig[keyof SpringConfig]
124
+ Object.assign(springConfig, { [key]: value })
125
125
  } else if (value !== undefined) {
126
126
  // Property-specific animation: string or config object
127
127
  properties[key] = value as string | AnimationConfig
package/types/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export { normalizeTransition, getAnimationForProperty, hasAnimation, getAnimatedProperties, getEffectiveAnimation, getAnimationConfigsForKeys } from "./normalizeTransition";
2
- export type { AnimationConfig, NormalizedTransition, TransitionPropInput } from "./types";
3
-
1
+ export { normalizeTransition, getAnimationForProperty, hasAnimation, getAnimatedProperties, getEffectiveAnimation, getAnimationConfigsForKeys, } from './normalizeTransition.ts';
2
+ export type { AnimationConfig, NormalizedTransition, TransitionPropInput, } from './types.ts';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,11 +1 @@
1
- {
2
- "mappings": "AAAA,SACE,qBACA,yBACA,cACA,uBACA,uBACA,kCACK;AAEP,cAAc,iBAAiB,sBAAsB,2BAA2B",
3
- "names": [],
4
- "sources": [
5
- "src/index.ts"
6
- ],
7
- "version": 3,
8
- "sourcesContent": [
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
- }
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,YAAY,EACZ,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,0BAA0B,CAAA;AAEjC,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,YAAY,CAAA"}