@hanzogui/animation-helpers 8.3.1 → 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 +16 -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
@@ -1,54 +1,53 @@
1
- import type { AnimationConfig, NormalizedTransition, TransitionPropInput } from "./types";
1
+ import type { AnimationConfig, NormalizedTransition, TransitionPropInput } from './types.ts';
2
2
  /**
3
- * Normalizes the various transition prop formats into a consistent structure.
4
- *
5
- * Supported input formats:
6
- * - String: "bouncy" -> { default: "bouncy", enter: null, exit: null, properties: {} }
7
- * - Object: { x: 'quick', default: 'slow' } -> { default: "slow", enter: null, exit: null, properties: { x: "quick" } }
8
- * - Object with enter/exit: { enter: 'bouncy', exit: 'quick' } -> { default: null, enter: "bouncy", exit: "quick", properties: {} }
9
- * - Array: ['bouncy', { delay: 100, x: 'quick' }] -> { default: "bouncy", enter: null, exit: null, delay: 100, properties: { x: "quick" } }
10
- *
11
- * @param transition - The transition prop value in any supported format
12
- * @returns Normalized transition object with consistent structure
13
- */
3
+ * Normalizes the various transition prop formats into a consistent structure.
4
+ *
5
+ * Supported input formats:
6
+ * - String: "bouncy" -> { default: "bouncy", enter: null, exit: null, properties: {} }
7
+ * - Object: { x: 'quick', default: 'slow' } -> { default: "slow", enter: null, exit: null, properties: { x: "quick" } }
8
+ * - Object with enter/exit: { enter: 'bouncy', exit: 'quick' } -> { default: null, enter: "bouncy", exit: "quick", properties: {} }
9
+ * - Array: ['bouncy', { delay: 100, x: 'quick' }] -> { default: "bouncy", enter: null, exit: null, delay: 100, properties: { x: "quick" } }
10
+ *
11
+ * @param transition - The transition prop value in any supported format
12
+ * @returns Normalized transition object with consistent structure
13
+ */
14
14
  export declare function normalizeTransition(transition: TransitionPropInput): NormalizedTransition;
15
15
  /**
16
- * Gets the animation key for a specific property from a normalized transition.
17
- * Falls back to the default animation if no property-specific one is defined.
18
- *
19
- * @param normalized - The normalized transition object
20
- * @param property - The property name to get animation for (e.g., 'x', 'opacity')
21
- * @returns The animation key/config or null if none defined
22
- */
16
+ * Gets the animation key for a specific property from a normalized transition.
17
+ * Falls back to the default animation if no property-specific one is defined.
18
+ *
19
+ * @param normalized - The normalized transition object
20
+ * @param property - The property name to get animation for (e.g., 'x', 'opacity')
21
+ * @returns The animation key/config or null if none defined
22
+ */
23
23
  export declare function getAnimationForProperty(normalized: NormalizedTransition, property: string): string | AnimationConfig | null;
24
24
  /**
25
- * Checks if the normalized transition has any animations defined.
26
- */
25
+ * Checks if the normalized transition has any animations defined.
26
+ */
27
27
  export declare function hasAnimation(normalized: NormalizedTransition): boolean;
28
28
  /**
29
- * Gets all property names that have specific animations defined.
30
- * Does not include 'default' in the list.
31
- */
29
+ * Gets all property names that have specific animations defined.
30
+ * Does not include 'default' in the list.
31
+ */
32
32
  export declare function getAnimatedProperties(normalized: NormalizedTransition): string[];
33
33
  /**
34
- * Gets the effective animation key based on the current animation state.
35
- * Priority: enter/exit specific > default > null
36
- *
37
- * @param normalized - The normalized transition object
38
- * @param state - The animation state: 'enter', 'exit', or 'default'
39
- * @returns The effective animation key or null
40
- */
41
- export declare function getEffectiveAnimation(normalized: NormalizedTransition, state: "enter" | "exit" | "default"): string | null;
34
+ * Gets the effective animation key based on the current animation state.
35
+ * Priority: enter/exit specific > default > null
36
+ *
37
+ * @param normalized - The normalized transition object
38
+ * @param state - The animation state: 'enter', 'exit', or 'default'
39
+ * @returns The effective animation key or null
40
+ */
41
+ export declare function getEffectiveAnimation(normalized: NormalizedTransition, state: 'enter' | 'exit' | 'default'): string | null;
42
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
- */
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
52
  export declare function getAnimationConfigsForKeys<T>(normalized: NormalizedTransition, animations: Record<string, T>, keys: string[], defaultAnimation: T | null): Map<string, T | null>;
53
-
54
53
  //# sourceMappingURL=normalizeTransition.d.ts.map
@@ -1,11 +1 @@
1
- {
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
- "names": [],
4
- "sources": [
5
- "src/normalizeTransition.ts"
6
- ],
7
- "version": 3,
8
- "sourcesContent": [
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
- }
1
+ {"version":3,"file":"normalizeTransition.d.ts","sourceRoot":"","sources":["../src/normalizeTransition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EAEpB,mBAAmB,EACpB,MAAM,YAAY,CAAA;AAsBnB;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,mBAAmB,GAC9B,oBAAoB,CA2GtB;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,oBAAoB,EAChC,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,eAAe,GAAG,IAAI,CASjC;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,oBAAoB,GAAG,OAAO,CAOtE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,oBAAoB,GAAG,MAAM,EAAE,CAEhF;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,oBAAoB,EAChC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAClC,MAAM,GAAG,IAAI,CAQf;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAC1C,UAAU,EAAE,oBAAoB,EAChC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAC7B,IAAI,EAAE,MAAM,EAAE,EACd,gBAAgB,EAAE,CAAC,GAAG,IAAI,GACzB,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CA0BvB"}
package/types/types.d.ts CHANGED
@@ -1,56 +1,55 @@
1
1
  /**
2
- * Animation configuration that can include additional properties
3
- * like delay, duration, stiffness, damping, etc.
4
- */
2
+ * Animation configuration that can include additional properties
3
+ * like delay, duration, stiffness, damping, etc.
4
+ */
5
5
  export type AnimationConfig = {
6
- type?: string;
7
- [key: string]: any;
6
+ type?: string;
7
+ [key: string]: any;
8
8
  };
9
9
  /**
10
- * Input format for the transition prop - supports multiple syntaxes:
11
- *
12
- * 1. String: "bouncy"
13
- * 2. Object with property mappings: { x: 'quick', y: 'bouncy', default: 'slow' }
14
- * 3. Array with config: ['bouncy', { delay: 100, x: 'quick' }]
15
- * 4. Object with enter/exit: { enter: 'bouncy', exit: 'quick', default: 'slow' }
16
- *
17
- * Note: Uses `any` to be compatible with the TransitionProp type from @hanzogui/web
18
- * which has more complex union types.
19
- */
10
+ * Input format for the transition prop - supports multiple syntaxes:
11
+ *
12
+ * 1. String: "bouncy"
13
+ * 2. Object with property mappings: { x: 'quick', y: 'bouncy', default: 'slow' }
14
+ * 3. Array with config: ['bouncy', { delay: 100, x: 'quick' }]
15
+ * 4. Object with enter/exit: { enter: 'bouncy', exit: 'quick', default: 'slow' }
16
+ *
17
+ * Note: Uses `any` to be compatible with the TransitionProp type from @hanzogui/web
18
+ * which has more complex union types.
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
- */
22
+ * Spring configuration parameters that can override preset defaults.
23
+ * These are the common parameters across animation drivers.
24
+ */
25
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;
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
36
  };
37
37
  /**
38
- * Normalized output format that all animation drivers consume.
39
- * Provides a consistent structure regardless of input format.
40
- */
38
+ * Normalized output format that all animation drivers consume.
39
+ * Provides a consistent structure regardless of input format.
40
+ */
41
41
  export type NormalizedTransition = {
42
- /** Default animation key for properties not explicitly listed */
43
- default: string | null;
44
- /** Animation key to use during enter transitions (mount) */
45
- enter: string | null;
46
- /** Animation key to use during exit transitions (unmount) */
47
- exit: string | null;
48
- /** Global delay in ms */
49
- delay: number | undefined;
50
- /** Per-property animation configs: propertyName -> animationKey or config */
51
- properties: Record<string, string | AnimationConfig>;
52
- /** Global spring config overrides that merge with the preset defaults */
53
- config?: SpringConfig;
42
+ /** Default animation key for properties not explicitly listed */
43
+ default: string | null;
44
+ /** Animation key to use during enter transitions (mount) */
45
+ enter: string | null;
46
+ /** Animation key to use during exit transitions (unmount) */
47
+ exit: string | null;
48
+ /** Global delay in ms */
49
+ delay: number | undefined;
50
+ /** Per-property animation configs: propertyName -> animationKey or config */
51
+ properties: Record<string, string | AnimationConfig>;
52
+ /** Global spring config overrides that merge with the preset defaults */
53
+ config?: SpringConfig;
54
54
  };
55
-
56
55
  //# sourceMappingURL=types.d.ts.map
@@ -1,11 +1 @@
1
- {
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
- "names": [],
4
- "sources": [
5
- "src/types.ts"
6
- ],
7
- "version": 3,
8
- "sourcesContent": [
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 @hanzogui/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
- }
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,mBAAmB,GAAG,GAAG,CAAA;AAErC;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,iEAAiE;IACjE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,4DAA4D;IAC5D,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,yBAAyB;IACzB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,6EAA6E;IAC7E,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,CAAC,CAAA;IACpD,yEAAyE;IACzE,MAAM,CAAC,EAAE,YAAY,CAAA;CACtB,CAAA"}
@@ -1,33 +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) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: true
22
- }), mod);
23
- var index_exports = {};
24
- __export(index_exports, {
25
- getAnimatedProperties: () => import_normalizeTransition.getAnimatedProperties,
26
- getAnimationConfigsForKeys: () => import_normalizeTransition.getAnimationConfigsForKeys,
27
- getAnimationForProperty: () => import_normalizeTransition.getAnimationForProperty,
28
- getEffectiveAnimation: () => import_normalizeTransition.getEffectiveAnimation,
29
- hasAnimation: () => import_normalizeTransition.hasAnimation,
30
- normalizeTransition: () => import_normalizeTransition.normalizeTransition
31
- });
32
- module.exports = __toCommonJS(index_exports);
33
- var import_normalizeTransition = require("./normalizeTransition.cjs");
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
21
- };
22
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
- value: true
24
- }), mod);
25
- var index_exports = {};
26
- __export(index_exports, {
27
- getAnimatedProperties: () => import_normalizeTransition.getAnimatedProperties,
28
- getAnimationConfigsForKeys: () => import_normalizeTransition.getAnimationConfigsForKeys,
29
- getAnimationForProperty: () => import_normalizeTransition.getAnimationForProperty,
30
- getEffectiveAnimation: () => import_normalizeTransition.getEffectiveAnimation,
31
- hasAnimation: () => import_normalizeTransition.hasAnimation,
32
- normalizeTransition: () => import_normalizeTransition.normalizeTransition
33
- });
34
- module.exports = __toCommonJS(index_exports);
35
- var import_normalizeTransition = require("./normalizeTransition.native.js");
36
- //# sourceMappingURL=index.native.js.map
@@ -1 +0,0 @@
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":[]}
@@ -1,164 +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) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: true
22
- }), mod);
23
- var normalizeTransition_exports = {};
24
- __export(normalizeTransition_exports, {
25
- getAnimatedProperties: () => getAnimatedProperties,
26
- getAnimationConfigsForKeys: () => getAnimationConfigsForKeys,
27
- getAnimationForProperty: () => getAnimationForProperty,
28
- getEffectiveAnimation: () => getEffectiveAnimation,
29
- hasAnimation: () => hasAnimation,
30
- normalizeTransition: () => normalizeTransition
31
- });
32
- module.exports = __toCommonJS(normalizeTransition_exports);
33
- const SPRING_CONFIG_KEYS = /* @__PURE__ */new Set(["stiffness", "damping", "mass", "tension", "friction", "velocity", "overshootClamping", "duration", "bounciness", "speed"]);
34
- function isSpringConfigKey(key) {
35
- return SPRING_CONFIG_KEYS.has(key);
36
- }
37
- function normalizeTransition(transition) {
38
- if (!transition) {
39
- return {
40
- default: null,
41
- enter: null,
42
- exit: null,
43
- delay: void 0,
44
- properties: {}
45
- };
46
- }
47
- if (typeof transition === "string") {
48
- return {
49
- default: transition,
50
- enter: null,
51
- exit: null,
52
- delay: void 0,
53
- properties: {}
54
- };
55
- }
56
- if (Array.isArray(transition)) {
57
- const [defaultAnimation, configObj] = transition;
58
- const properties = {};
59
- const springConfig = {};
60
- let delay;
61
- let enter = null;
62
- let exit = null;
63
- if (configObj && typeof configObj === "object") {
64
- for (const [key, value] of Object.entries(configObj)) {
65
- if (key === "delay" && typeof value === "number") {
66
- delay = value;
67
- } else if (key === "enter" && typeof value === "string") {
68
- enter = value;
69
- } else if (key === "exit" && typeof value === "string") {
70
- exit = value;
71
- } else if (isSpringConfigKey(key) && value !== void 0) {
72
- springConfig[key] = value;
73
- } else if (value !== void 0) {
74
- properties[key] = value;
75
- }
76
- }
77
- }
78
- return {
79
- default: defaultAnimation,
80
- enter,
81
- exit,
82
- delay,
83
- properties,
84
- config: Object.keys(springConfig).length > 0 ? springConfig : void 0
85
- };
86
- }
87
- if (typeof transition === "object") {
88
- const properties = {};
89
- const springConfig = {};
90
- let defaultAnimation = null;
91
- let enter = null;
92
- let exit = null;
93
- let delay;
94
- for (const [key, value] of Object.entries(transition)) {
95
- if (key === "default" && typeof value === "string") {
96
- defaultAnimation = value;
97
- } else if (key === "enter" && typeof value === "string") {
98
- enter = value;
99
- } else if (key === "exit" && typeof value === "string") {
100
- exit = value;
101
- } else if (key === "delay" && typeof value === "number") {
102
- delay = value;
103
- } else if (isSpringConfigKey(key) && value !== void 0) {
104
- springConfig[key] = value;
105
- } else if (value !== void 0) {
106
- properties[key] = value;
107
- }
108
- }
109
- return {
110
- default: defaultAnimation,
111
- enter,
112
- exit,
113
- delay,
114
- properties,
115
- config: Object.keys(springConfig).length > 0 ? springConfig : void 0
116
- };
117
- }
118
- return {
119
- default: null,
120
- enter: null,
121
- exit: null,
122
- delay: void 0,
123
- properties: {}
124
- };
125
- }
126
- function getAnimationForProperty(normalized, property) {
127
- const propertyAnimation = normalized.properties[property];
128
- if (propertyAnimation !== void 0) {
129
- return propertyAnimation;
130
- }
131
- return normalized.default;
132
- }
133
- function hasAnimation(normalized) {
134
- return normalized.default !== null || normalized.enter !== null || normalized.exit !== null || Object.keys(normalized.properties).length > 0;
135
- }
136
- function getAnimatedProperties(normalized) {
137
- return Object.keys(normalized.properties);
138
- }
139
- function getEffectiveAnimation(normalized, state) {
140
- if (state === "enter" && normalized.enter) {
141
- return normalized.enter;
142
- }
143
- if (state === "exit" && normalized.exit) {
144
- return normalized.exit;
145
- }
146
- return normalized.default;
147
- }
148
- function getAnimationConfigsForKeys(normalized, animations, keys, defaultAnimation) {
149
- const result = /* @__PURE__ */new Map();
150
- for (const key of keys) {
151
- const propAnimation = normalized.properties[key];
152
- let animationValue = null;
153
- if (typeof propAnimation === "string") {
154
- animationValue = animations[propAnimation] ?? null;
155
- } else if (propAnimation && typeof propAnimation === "object" && propAnimation.type) {
156
- animationValue = animations[propAnimation.type] ?? null;
157
- }
158
- if (animationValue === null) {
159
- animationValue = defaultAnimation;
160
- }
161
- result.set(key, animationValue);
162
- }
163
- return result;
164
- }