framer-motion 7.0.3 → 7.1.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 (186) hide show
  1. package/dist/cjs/index.js +2090 -2304
  2. package/dist/es/animation/animate.mjs +4 -5
  3. package/dist/es/animation/animation-controls.mjs +22 -24
  4. package/dist/es/animation/use-animated-state.mjs +23 -25
  5. package/dist/es/animation/use-animation.mjs +2 -2
  6. package/dist/es/animation/utils/default-transitions.mjs +13 -14
  7. package/dist/es/animation/utils/easing.mjs +20 -21
  8. package/dist/es/animation/utils/is-animatable.mjs +1 -1
  9. package/dist/es/animation/utils/is-keyframes-target.mjs +1 -1
  10. package/dist/es/animation/utils/transitions.mjs +30 -31
  11. package/dist/es/components/AnimatePresence/PresenceChild.mjs +18 -31
  12. package/dist/es/components/AnimatePresence/index.mjs +33 -35
  13. package/dist/es/components/AnimatePresence/use-presence.mjs +5 -5
  14. package/dist/es/components/AnimateSharedLayout.mjs +4 -5
  15. package/dist/es/components/LayoutGroup/index.mjs +12 -16
  16. package/dist/es/components/LazyMotion/index.mjs +9 -10
  17. package/dist/es/components/MotionConfig/index.mjs +5 -5
  18. package/dist/es/components/Reorder/Group.mjs +16 -16
  19. package/dist/es/components/Reorder/Item.mjs +14 -18
  20. package/dist/es/components/Reorder/index.mjs +3 -3
  21. package/dist/es/components/Reorder/utils/check-reorder.mjs +6 -6
  22. package/dist/es/context/DeprecatedLayoutGroupContext.mjs +1 -1
  23. package/dist/es/context/LayoutGroupContext.mjs +1 -1
  24. package/dist/es/context/LazyContext.mjs +1 -1
  25. package/dist/es/context/MotionConfigContext.mjs +2 -2
  26. package/dist/es/context/MotionContext/create.mjs +2 -2
  27. package/dist/es/context/MotionContext/index.mjs +1 -1
  28. package/dist/es/context/MotionContext/utils.mjs +1 -1
  29. package/dist/es/context/PresenceContext.mjs +1 -1
  30. package/dist/es/context/ReorderContext.mjs +1 -1
  31. package/dist/es/context/SwitchLayoutGroupContext.mjs +1 -1
  32. package/dist/es/events/event-info.mjs +11 -17
  33. package/dist/es/events/use-dom-event.mjs +4 -5
  34. package/dist/es/events/use-pointer-event.mjs +2 -2
  35. package/dist/es/events/utils.mjs +3 -9
  36. package/dist/es/gestures/PanSession.mjs +42 -47
  37. package/dist/es/gestures/drag/VisualElementDragControls.mjs +147 -157
  38. package/dist/es/gestures/drag/use-drag-controls.mjs +10 -12
  39. package/dist/es/gestures/drag/use-drag.mjs +4 -4
  40. package/dist/es/gestures/drag/utils/constraints.mjs +12 -17
  41. package/dist/es/gestures/drag/utils/lock.mjs +17 -17
  42. package/dist/es/gestures/use-focus-gesture.mjs +3 -4
  43. package/dist/es/gestures/use-hover-gesture.mjs +2 -3
  44. package/dist/es/gestures/use-pan-gesture.mjs +9 -10
  45. package/dist/es/gestures/use-tap-gesture.mjs +5 -6
  46. package/dist/es/gestures/utils/event-type.mjs +1 -1
  47. package/dist/es/gestures/utils/is-node-or-child.mjs +1 -1
  48. package/dist/es/index.mjs +1 -0
  49. package/dist/es/motion/features/animations.mjs +9 -11
  50. package/dist/es/motion/features/definitions.mjs +5 -5
  51. package/dist/es/motion/features/drag.mjs +1 -1
  52. package/dist/es/motion/features/gestures.mjs +1 -1
  53. package/dist/es/motion/features/layout/MeasureLayout.mjs +32 -40
  54. package/dist/es/motion/features/layout/index.mjs +1 -1
  55. package/dist/es/motion/features/use-features.mjs +8 -9
  56. package/dist/es/motion/features/use-projection.mjs +10 -11
  57. package/dist/es/motion/features/viewport/observers.mjs +12 -12
  58. package/dist/es/motion/features/viewport/use-viewport.mjs +17 -20
  59. package/dist/es/motion/index.mjs +13 -16
  60. package/dist/es/motion/utils/VisualElementHandler.mjs +10 -16
  61. package/dist/es/motion/utils/is-forced-motion-value.mjs +1 -2
  62. package/dist/es/motion/utils/make-renderless-component.mjs +2 -2
  63. package/dist/es/motion/utils/use-motion-ref.mjs +1 -1
  64. package/dist/es/motion/utils/use-visual-element.mjs +13 -13
  65. package/dist/es/motion/utils/use-visual-state.mjs +26 -31
  66. package/dist/es/motion/utils/valid-prop.mjs +1 -1
  67. package/dist/es/projection/animation/mix-values.mjs +12 -16
  68. package/dist/es/projection/geometry/conversion.mjs +4 -6
  69. package/dist/es/projection/geometry/delta-apply.mjs +14 -20
  70. package/dist/es/projection/geometry/delta-calc.mjs +2 -5
  71. package/dist/es/projection/geometry/delta-remove.mjs +6 -13
  72. package/dist/es/projection/geometry/models.mjs +7 -7
  73. package/dist/es/projection/node/DocumentProjectionNode.mjs +5 -5
  74. package/dist/es/projection/node/HTMLProjectionNode.mjs +8 -10
  75. package/dist/es/projection/node/create-projection-node.mjs +283 -307
  76. package/dist/es/projection/node/group.mjs +6 -8
  77. package/dist/es/projection/node/id.mjs +2 -2
  78. package/dist/es/projection/node/state.mjs +1 -1
  79. package/dist/es/projection/shared/stack.mjs +26 -27
  80. package/dist/es/projection/styles/scale-border-radius.mjs +5 -5
  81. package/dist/es/projection/styles/scale-box-shadow.mjs +18 -19
  82. package/dist/es/projection/styles/scale-correction.mjs +1 -1
  83. package/dist/es/projection/styles/transform.mjs +12 -12
  84. package/dist/es/projection/use-reset-projection.mjs +2 -2
  85. package/dist/es/projection/utils/has-transform.mjs +1 -2
  86. package/dist/es/projection/utils/measure.mjs +2 -2
  87. package/dist/es/render/dom/create-visual-element.mjs +1 -1
  88. package/dist/es/render/dom/features-animation.mjs +1 -2
  89. package/dist/es/render/dom/features-max.mjs +1 -2
  90. package/dist/es/render/dom/motion-minimal.mjs +1 -1
  91. package/dist/es/render/dom/motion-proxy.mjs +3 -4
  92. package/dist/es/render/dom/motion.mjs +2 -5
  93. package/dist/es/render/dom/use-render.mjs +6 -9
  94. package/dist/es/render/dom/utils/camel-to-dash.mjs +3 -5
  95. package/dist/es/render/dom/utils/create-config.mjs +5 -5
  96. package/dist/es/render/dom/utils/css-variables-conversion.mjs +19 -20
  97. package/dist/es/render/dom/utils/filter-props.mjs +4 -6
  98. package/dist/es/render/dom/utils/parse-dom-variant.mjs +2 -2
  99. package/dist/es/render/dom/utils/unit-conversion.mjs +68 -99
  100. package/dist/es/render/dom/value-types/animatable-none.mjs +1 -1
  101. package/dist/es/render/dom/value-types/defaults.mjs +4 -5
  102. package/dist/es/render/dom/value-types/dimensions.mjs +2 -4
  103. package/dist/es/render/dom/value-types/find.mjs +2 -3
  104. package/dist/es/render/dom/value-types/get-as-type.mjs +1 -1
  105. package/dist/es/render/dom/value-types/number.mjs +2 -2
  106. package/dist/es/render/dom/value-types/test.mjs +1 -1
  107. package/dist/es/render/dom/value-types/type-auto.mjs +3 -3
  108. package/dist/es/render/dom/value-types/type-int.mjs +1 -2
  109. package/dist/es/render/html/config-motion.mjs +1 -1
  110. package/dist/es/render/html/use-props.mjs +11 -13
  111. package/dist/es/render/html/utils/build-styles.mjs +8 -8
  112. package/dist/es/render/html/utils/build-transform.mjs +11 -16
  113. package/dist/es/render/html/utils/create-render-state.mjs +2 -2
  114. package/dist/es/render/html/utils/render.mjs +2 -3
  115. package/dist/es/render/html/utils/scrape-motion-values.mjs +3 -3
  116. package/dist/es/render/html/utils/transform.mjs +6 -10
  117. package/dist/es/render/html/visual-element.mjs +22 -23
  118. package/dist/es/render/index.mjs +359 -364
  119. package/dist/es/render/svg/config-motion.mjs +2 -3
  120. package/dist/es/render/svg/lowercase-elements.mjs +1 -1
  121. package/dist/es/render/svg/use-props.mjs +5 -6
  122. package/dist/es/render/svg/utils/build-attrs.mjs +2 -2
  123. package/dist/es/render/svg/utils/camel-case-attrs.mjs +1 -1
  124. package/dist/es/render/svg/utils/create-render-state.mjs +1 -2
  125. package/dist/es/render/svg/utils/path.mjs +7 -10
  126. package/dist/es/render/svg/utils/render.mjs +1 -1
  127. package/dist/es/render/svg/utils/scrape-motion-values.mjs +3 -3
  128. package/dist/es/render/svg/utils/transform-origin.mjs +3 -3
  129. package/dist/es/render/svg/visual-element.mjs +6 -4
  130. package/dist/es/render/utils/animation-state.mjs +71 -87
  131. package/dist/es/render/utils/animation.mjs +48 -60
  132. package/dist/es/render/utils/compare-by-depth.mjs +1 -3
  133. package/dist/es/render/utils/flat-tree.mjs +9 -10
  134. package/dist/es/render/utils/lifecycles.mjs +12 -19
  135. package/dist/es/render/utils/motion-values.mjs +16 -8
  136. package/dist/es/render/utils/setters.mjs +19 -19
  137. package/dist/es/render/utils/variants.mjs +6 -8
  138. package/dist/es/utils/array.mjs +9 -10
  139. package/dist/es/utils/is-browser.mjs +1 -1
  140. package/dist/es/utils/is-numerical-string.mjs +1 -1
  141. package/dist/es/utils/is-zero-value-string.mjs +1 -1
  142. package/dist/es/utils/process.mjs +2 -2
  143. package/dist/es/utils/resolve-value.mjs +2 -2
  144. package/dist/es/utils/shallow-compare.mjs +2 -2
  145. package/dist/es/utils/subscription-manager.mjs +15 -17
  146. package/dist/es/utils/time-conversion.mjs +1 -1
  147. package/dist/es/utils/transform.mjs +10 -15
  148. package/dist/es/utils/use-animation-frame.mjs +5 -6
  149. package/dist/es/utils/use-constant.mjs +1 -1
  150. package/dist/es/utils/use-cycle.mjs +9 -10
  151. package/dist/es/utils/use-force-update.mjs +4 -5
  152. package/dist/es/utils/use-in-view.mjs +7 -9
  153. package/dist/es/utils/use-instant-transition-state.mjs +1 -1
  154. package/dist/es/utils/use-instant-transition.mjs +6 -9
  155. package/dist/es/utils/use-is-mounted.mjs +3 -3
  156. package/dist/es/utils/use-isomorphic-effect.mjs +1 -1
  157. package/dist/es/utils/use-reduced-motion.mjs +8 -11
  158. package/dist/es/utils/use-unmount-effect.mjs +1 -1
  159. package/dist/es/utils/warn-once.mjs +1 -1
  160. package/dist/es/value/index.mjs +53 -59
  161. package/dist/es/value/use-combine-values.mjs +3 -3
  162. package/dist/es/value/use-inverted-scale.mjs +9 -11
  163. package/dist/es/value/use-motion-template.mjs +5 -9
  164. package/dist/es/value/use-motion-value.mjs +4 -5
  165. package/dist/es/value/use-on-change.mjs +4 -4
  166. package/dist/es/value/use-scroll.mjs +9 -11
  167. package/dist/es/value/use-spring.mjs +8 -10
  168. package/dist/es/value/use-time.mjs +2 -2
  169. package/dist/es/value/use-transform.mjs +6 -10
  170. package/dist/es/value/use-velocity.mjs +3 -3
  171. package/dist/es/value/use-will-change/index.mjs +50 -0
  172. package/dist/es/value/use-will-change/is.mjs +7 -0
  173. package/dist/es/value/utils/is-motion-value.mjs +1 -1
  174. package/dist/es/value/utils/resolve-motion-value.mjs +1 -1
  175. package/dist/framer-motion.dev.js +2134 -2414
  176. package/dist/framer-motion.js +1 -1
  177. package/dist/index.d.ts +9 -2
  178. package/dist/projection.dev.js +1154 -1300
  179. package/dist/size-rollup-dom-animation.js +1 -1
  180. package/dist/size-rollup-dom-max.js +1 -1
  181. package/dist/size-rollup-m.js +1 -1
  182. package/dist/size-webpack-dom-animation.js +1 -1
  183. package/dist/size-webpack-dom-max.js +1 -1
  184. package/dist/size-webpack-m.js +1 -1
  185. package/dist/three-entry.d.ts +0 -1
  186. package/package.json +12 -12
@@ -29,13 +29,12 @@ import { startAnimation } from './utils/transitions.mjs';
29
29
  *
30
30
  * @public
31
31
  */
32
- function animate(from, to, transition) {
33
- if (transition === void 0) { transition = {}; }
34
- var value = isMotionValue(from) ? from : motionValue(from);
32
+ function animate(from, to, transition = {}) {
33
+ const value = isMotionValue(from) ? from : motionValue(from);
35
34
  startAnimation("", value, to, transition);
36
35
  return {
37
- stop: function () { return value.stop(); },
38
- isAnimating: function () { return value.isAnimating(); },
36
+ stop: () => value.stop(),
37
+ isAnimating: () => value.isAnimating(),
39
38
  };
40
39
  }
41
40
 
@@ -1,4 +1,3 @@
1
- import { __spreadArray, __read } from 'tslib';
2
1
  import { invariant } from 'hey-listen';
3
2
  import { stopAnimation, animateVisualElement } from '../render/utils/animation.mjs';
4
3
  import { setValues } from '../render/utils/setters.mjs';
@@ -10,22 +9,22 @@ function animationControls() {
10
9
  /**
11
10
  * Track whether the host component has mounted.
12
11
  */
13
- var hasMounted = false;
12
+ let hasMounted = false;
14
13
  /**
15
14
  * Pending animations that are started before a component is mounted.
16
15
  * TODO: Remove this as animations should only run in effects
17
16
  */
18
- var pendingAnimations = [];
17
+ const pendingAnimations = [];
19
18
  /**
20
19
  * A collection of linked component animation controls.
21
20
  */
22
- var subscribers = new Set();
23
- var controls = {
24
- subscribe: function (visualElement) {
21
+ const subscribers = new Set();
22
+ const controls = {
23
+ subscribe(visualElement) {
25
24
  subscribers.add(visualElement);
26
- return function () { return void subscribers.delete(visualElement); };
25
+ return () => void subscribers.delete(visualElement);
27
26
  },
28
- start: function (definition, transitionOverride) {
27
+ start(definition, transitionOverride) {
29
28
  /**
30
29
  * TODO: We only perform this hasMounted check because in Framer we used to
31
30
  * encourage the ability to start an animation within the render phase. This
@@ -33,41 +32,40 @@ function animationControls() {
33
32
  * we can ditch this.
34
33
  */
35
34
  if (hasMounted) {
36
- var animations_1 = [];
37
- subscribers.forEach(function (visualElement) {
38
- animations_1.push(animateVisualElement(visualElement, definition, {
39
- transitionOverride: transitionOverride,
35
+ const animations = [];
36
+ subscribers.forEach((visualElement) => {
37
+ animations.push(animateVisualElement(visualElement, definition, {
38
+ transitionOverride,
40
39
  }));
41
40
  });
42
- return Promise.all(animations_1);
41
+ return Promise.all(animations);
43
42
  }
44
43
  else {
45
- return new Promise(function (resolve) {
44
+ return new Promise((resolve) => {
46
45
  pendingAnimations.push({
47
46
  animation: [definition, transitionOverride],
48
- resolve: resolve,
47
+ resolve,
49
48
  });
50
49
  });
51
50
  }
52
51
  },
53
- set: function (definition) {
52
+ set(definition) {
54
53
  invariant(hasMounted, "controls.set() should only be called after a component has mounted. Consider calling within a useEffect hook.");
55
- return subscribers.forEach(function (visualElement) {
54
+ return subscribers.forEach((visualElement) => {
56
55
  setValues(visualElement, definition);
57
56
  });
58
57
  },
59
- stop: function () {
60
- subscribers.forEach(function (visualElement) {
58
+ stop() {
59
+ subscribers.forEach((visualElement) => {
61
60
  stopAnimation(visualElement);
62
61
  });
63
62
  },
64
- mount: function () {
63
+ mount() {
65
64
  hasMounted = true;
66
- pendingAnimations.forEach(function (_a) {
67
- var animation = _a.animation, resolve = _a.resolve;
68
- controls.start.apply(controls, __spreadArray([], __read(animation), false)).then(resolve);
65
+ pendingAnimations.forEach(({ animation, resolve }) => {
66
+ controls.start(...animation).then(resolve);
69
67
  });
70
- return function () {
68
+ return () => {
71
69
  hasMounted = false;
72
70
  controls.stop();
73
71
  };
@@ -1,4 +1,4 @@
1
- import { __rest, __assign, __read } from 'tslib';
1
+ import { __rest } from 'tslib';
2
2
  import { useState, useEffect } from 'react';
3
3
  import { useConstant } from '../utils/use-constant.mjs';
4
4
  import { getOrigin, checkTargetForNewValues } from '../render/utils/setters.mjs';
@@ -7,26 +7,26 @@ import { animateVisualElement } from '../render/utils/animation.mjs';
7
7
  import { makeUseVisualState } from '../motion/utils/use-visual-state.mjs';
8
8
  import { createBox } from '../projection/geometry/models.mjs';
9
9
 
10
- var createObject = function () { return ({}); };
11
- var stateVisualElement = visualElement({
12
- build: function () { },
10
+ const createObject = () => ({});
11
+ const stateVisualElement = visualElement({
12
+ build() { },
13
13
  measureViewportBox: createBox,
14
- resetTransform: function () { },
15
- restoreTransform: function () { },
16
- removeValueFromRenderState: function () { },
17
- render: function () { },
14
+ resetTransform() { },
15
+ restoreTransform() { },
16
+ removeValueFromRenderState() { },
17
+ render() { },
18
18
  scrapeMotionValuesFromProps: createObject,
19
- readValueFromInstance: function (_state, key, options) {
19
+ readValueFromInstance(_state, key, options) {
20
20
  return options.initialState[key] || 0;
21
21
  },
22
- makeTargetAnimatable: function (element, _a) {
23
- var transition = _a.transition, transitionEnd = _a.transitionEnd, target = __rest(_a, ["transition", "transitionEnd"]);
24
- var origin = getOrigin(target, transition || {}, element);
22
+ makeTargetAnimatable(element, _a) {
23
+ var { transition, transitionEnd } = _a, target = __rest(_a, ["transition", "transitionEnd"]);
24
+ const origin = getOrigin(target, transition || {}, element);
25
25
  checkTargetForNewValues(element, target, origin);
26
- return __assign({ transition: transition, transitionEnd: transitionEnd }, target);
26
+ return Object.assign({ transition, transitionEnd }, target);
27
27
  },
28
28
  });
29
- var useVisualState = makeUseVisualState({
29
+ const useVisualState = makeUseVisualState({
30
30
  scrapeMotionValuesFromProps: createObject,
31
31
  createRenderState: createObject,
32
32
  });
@@ -35,25 +35,23 @@ var useVisualState = makeUseVisualState({
35
35
  * on any version.
36
36
  */
37
37
  function useAnimatedState(initialState) {
38
- var _a = __read(useState(initialState), 2), animationState = _a[0], setAnimationState = _a[1];
39
- var visualState = useVisualState({}, false);
40
- var element = useConstant(function () {
41
- return stateVisualElement({ props: {}, visualState: visualState }, { initialState: initialState });
42
- });
43
- useEffect(function () {
38
+ const [animationState, setAnimationState] = useState(initialState);
39
+ const visualState = useVisualState({}, false);
40
+ const element = useConstant(() => stateVisualElement({ props: {}, visualState }, { initialState }));
41
+ useEffect(() => {
44
42
  element.mount({});
45
43
  return element.unmount;
46
44
  }, [element]);
47
- useEffect(function () {
45
+ useEffect(() => {
48
46
  element.setProps({
49
- onUpdate: function (v) {
50
- setAnimationState(__assign({}, v));
47
+ onUpdate: (v) => {
48
+ setAnimationState(Object.assign({}, v));
51
49
  },
52
50
  });
53
51
  }, [setAnimationState, element]);
54
- var startAnimation = useConstant(function () { return function (animationDefinition) {
52
+ const startAnimation = useConstant(() => (animationDefinition) => {
55
53
  return animateVisualElement(element, animationDefinition);
56
- }; });
54
+ });
57
55
  return [animationState, startAnimation];
58
56
  }
59
57
 
@@ -32,10 +32,10 @@ import { useConstant } from '../utils/use-constant.mjs';
32
32
  * @public
33
33
  */
34
34
  function useAnimationControls() {
35
- var controls = useConstant(animationControls);
35
+ const controls = useConstant(animationControls);
36
36
  useEffect(controls.mount, []);
37
37
  return controls;
38
38
  }
39
- var useAnimation = useAnimationControls;
39
+ const useAnimation = useAnimationControls;
40
40
 
41
41
  export { useAnimation, useAnimationControls };
@@ -1,29 +1,28 @@
1
- import { __assign } from 'tslib';
2
1
  import { isKeyframesTarget } from './is-keyframes-target.mjs';
3
2
 
4
- var underDampedSpring = function () { return ({
3
+ const underDampedSpring = () => ({
5
4
  type: "spring",
6
5
  stiffness: 500,
7
6
  damping: 25,
8
7
  restSpeed: 10,
9
- }); };
10
- var criticallyDampedSpring = function (to) { return ({
8
+ });
9
+ const criticallyDampedSpring = (to) => ({
11
10
  type: "spring",
12
11
  stiffness: 550,
13
12
  damping: to === 0 ? 2 * Math.sqrt(550) : 30,
14
13
  restSpeed: 10,
15
- }); };
16
- var linearTween = function () { return ({
14
+ });
15
+ const linearTween = () => ({
17
16
  type: "keyframes",
18
17
  ease: "linear",
19
18
  duration: 0.3,
20
- }); };
21
- var keyframes = function (values) { return ({
19
+ });
20
+ const keyframes = (values) => ({
22
21
  type: "keyframes",
23
22
  duration: 0.8,
24
- values: values,
25
- }); };
26
- var defaultTransitions = {
23
+ values,
24
+ });
25
+ const defaultTransitions = {
27
26
  x: underDampedSpring,
28
27
  y: underDampedSpring,
29
28
  z: underDampedSpring,
@@ -39,8 +38,8 @@ var defaultTransitions = {
39
38
  color: linearTween,
40
39
  default: criticallyDampedSpring,
41
40
  };
42
- var getDefaultTransition = function (valueKey, to) {
43
- var transitionFactory;
41
+ const getDefaultTransition = (valueKey, to) => {
42
+ let transitionFactory;
44
43
  if (isKeyframesTarget(to)) {
45
44
  transitionFactory = keyframes;
46
45
  }
@@ -48,7 +47,7 @@ var getDefaultTransition = function (valueKey, to) {
48
47
  transitionFactory =
49
48
  defaultTransitions[valueKey] || defaultTransitions.default;
50
49
  }
51
- return __assign({ to: to }, transitionFactory(to));
50
+ return Object.assign({ to }, transitionFactory(to));
52
51
  };
53
52
 
54
53
  export { criticallyDampedSpring, getDefaultTransition, linearTween, underDampedSpring };
@@ -1,38 +1,37 @@
1
- import { __read } from 'tslib';
2
1
  import { invariant } from 'hey-listen';
3
2
  import { cubicBezier, linear, easeIn, easeInOut, easeOut, circIn, circInOut, circOut, backIn, backInOut, backOut, anticipate, bounceIn, bounceInOut, bounceOut } from 'popmotion';
4
3
 
5
- var easingLookup = {
6
- linear: linear,
7
- easeIn: easeIn,
8
- easeInOut: easeInOut,
9
- easeOut: easeOut,
10
- circIn: circIn,
11
- circInOut: circInOut,
12
- circOut: circOut,
13
- backIn: backIn,
14
- backInOut: backInOut,
15
- backOut: backOut,
16
- anticipate: anticipate,
17
- bounceIn: bounceIn,
18
- bounceInOut: bounceInOut,
19
- bounceOut: bounceOut,
4
+ const easingLookup = {
5
+ linear,
6
+ easeIn,
7
+ easeInOut,
8
+ easeOut,
9
+ circIn,
10
+ circInOut,
11
+ circOut,
12
+ backIn,
13
+ backInOut,
14
+ backOut,
15
+ anticipate,
16
+ bounceIn,
17
+ bounceInOut,
18
+ bounceOut,
20
19
  };
21
- var easingDefinitionToFunction = function (definition) {
20
+ const easingDefinitionToFunction = (definition) => {
22
21
  if (Array.isArray(definition)) {
23
22
  // If cubic bezier definition, create bezier curve
24
- invariant(definition.length === 4, "Cubic bezier arrays must contain four numerical values.");
25
- var _a = __read(definition, 4), x1 = _a[0], y1 = _a[1], x2 = _a[2], y2 = _a[3];
23
+ invariant(definition.length === 4, `Cubic bezier arrays must contain four numerical values.`);
24
+ const [x1, y1, x2, y2] = definition;
26
25
  return cubicBezier(x1, y1, x2, y2);
27
26
  }
28
27
  else if (typeof definition === "string") {
29
28
  // Else lookup from table
30
- invariant(easingLookup[definition] !== undefined, "Invalid easing type '".concat(definition, "'"));
29
+ invariant(easingLookup[definition] !== undefined, `Invalid easing type '${definition}'`);
31
30
  return easingLookup[definition];
32
31
  }
33
32
  return definition;
34
33
  };
35
- var isEasingArray = function (ease) {
34
+ const isEasingArray = (ease) => {
36
35
  return Array.isArray(ease) && typeof ease[0] !== "number";
37
36
  };
38
37
 
@@ -9,7 +9,7 @@ import { complex } from 'style-value-types';
9
9
  *
10
10
  * @internal
11
11
  */
12
- var isAnimatable = function (key, value) {
12
+ const isAnimatable = (key, value) => {
13
13
  // If the list of keys tat might be non-animatable grows, replace with Set
14
14
  if (key === "zIndex")
15
15
  return false;
@@ -1,4 +1,4 @@
1
- var isKeyframesTarget = function (v) {
1
+ const isKeyframesTarget = (v) => {
2
2
  return Array.isArray(v);
3
3
  };
4
4
 
@@ -1,4 +1,4 @@
1
- import { __assign, __rest, __spreadArray, __read } from 'tslib';
1
+ import { __rest } from 'tslib';
2
2
  import { inertia, animate } from 'popmotion';
3
3
  import { secondsToMilliseconds } from '../../utils/time-conversion.mjs';
4
4
  import { isEasingArray, easingDefinitionToFunction } from './easing.mjs';
@@ -15,16 +15,16 @@ import { resolveFinalValueInKeyframes } from '../../utils/resolve-value.mjs';
15
15
  * if any options are left.
16
16
  */
17
17
  function isTransitionDefined(_a) {
18
- _a.when; _a.delay; _a.delayChildren; _a.staggerChildren; _a.staggerDirection; _a.repeat; _a.repeatType; _a.repeatDelay; _a.from; var transition = __rest(_a, ["when", "delay", "delayChildren", "staggerChildren", "staggerDirection", "repeat", "repeatType", "repeatDelay", "from"]);
18
+ var transition = __rest(_a, ["when", "delay", "delayChildren", "staggerChildren", "staggerDirection", "repeat", "repeatType", "repeatDelay", "from"]);
19
19
  return !!Object.keys(transition).length;
20
20
  }
21
- var legacyRepeatWarning = false;
21
+ let legacyRepeatWarning = false;
22
22
  /**
23
23
  * Convert Framer Motion's Transition type into Popmotion-compatible options.
24
24
  */
25
25
  function convertTransitionToAnimationOptions(_a) {
26
- var ease = _a.ease, times = _a.times, yoyo = _a.yoyo, flip = _a.flip, loop = _a.loop, transition = __rest(_a, ["ease", "times", "yoyo", "flip", "loop"]);
27
- var options = __assign({}, transition);
26
+ var { ease, times, yoyo, flip, loop } = _a, transition = __rest(_a, ["ease", "times", "yoyo", "flip", "loop"]);
27
+ const options = Object.assign({}, transition);
28
28
  if (times)
29
29
  options["offset"] = times;
30
30
  /**
@@ -78,12 +78,12 @@ function convertTransitionToAnimationOptions(_a) {
78
78
  */
79
79
  function getDelayFromTransition(transition, key) {
80
80
  var _a, _b;
81
- var valueTransition = getValueTransition(transition, key) || {};
81
+ const valueTransition = getValueTransition(transition, key) || {};
82
82
  return (_b = (_a = valueTransition.delay) !== null && _a !== void 0 ? _a : transition.delay) !== null && _b !== void 0 ? _b : 0;
83
83
  }
84
84
  function hydrateKeyframes(options) {
85
85
  if (Array.isArray(options.to) && options.to[0] === null) {
86
- options.to = __spreadArray([], __read(options.to), false);
86
+ options.to = [...options.to];
87
87
  options.to[0] = options.from;
88
88
  }
89
89
  return options;
@@ -98,18 +98,18 @@ function getPopmotionAnimationOptions(transition, options, key) {
98
98
  * Get a default transition if none is determined to be defined.
99
99
  */
100
100
  if (!isTransitionDefined(transition)) {
101
- transition = __assign(__assign({}, transition), getDefaultTransition(key, options.to));
101
+ transition = Object.assign(Object.assign({}, transition), getDefaultTransition(key, options.to));
102
102
  }
103
- return __assign(__assign({}, options), convertTransitionToAnimationOptions(transition));
103
+ return Object.assign(Object.assign({}, options), convertTransitionToAnimationOptions(transition));
104
104
  }
105
105
  /**
106
106
  *
107
107
  */
108
108
  function getAnimation(key, value, target, transition, onComplete) {
109
109
  var _a;
110
- var valueTransition = getValueTransition(transition, key);
111
- var origin = (_a = valueTransition.from) !== null && _a !== void 0 ? _a : value.get();
112
- var isTargetAnimatable = isAnimatable(key, target);
110
+ const valueTransition = getValueTransition(transition, key);
111
+ let origin = (_a = valueTransition.from) !== null && _a !== void 0 ? _a : value.get();
112
+ const isTargetAnimatable = isAnimatable(key, target);
113
113
  if (origin === "none" && isTargetAnimatable && typeof target === "string") {
114
114
  /**
115
115
  * If we're trying to animate from "none", try and get an animatable version
@@ -125,24 +125,24 @@ function getAnimation(key, value, target, transition, onComplete) {
125
125
  typeof origin === "string") {
126
126
  target = getZeroUnit(origin);
127
127
  }
128
- var isOriginAnimatable = isAnimatable(key, origin);
129
- warning(isOriginAnimatable === isTargetAnimatable, "You are trying to animate ".concat(key, " from \"").concat(origin, "\" to \"").concat(target, "\". ").concat(origin, " is not an animatable value - to enable this animation set ").concat(origin, " to a value animatable to ").concat(target, " via the `style` property."));
128
+ const isOriginAnimatable = isAnimatable(key, origin);
129
+ warning(isOriginAnimatable === isTargetAnimatable, `You are trying to animate ${key} from "${origin}" to "${target}". ${origin} is not an animatable value - to enable this animation set ${origin} to a value animatable to ${target} via the \`style\` property.`);
130
130
  function start() {
131
- var options = {
131
+ const options = {
132
132
  from: origin,
133
133
  to: target,
134
134
  velocity: value.getVelocity(),
135
- onComplete: onComplete,
136
- onUpdate: function (v) { return value.set(v); },
135
+ onComplete,
136
+ onUpdate: (v) => value.set(v),
137
137
  };
138
138
  return valueTransition.type === "inertia" ||
139
139
  valueTransition.type === "decay"
140
- ? inertia(__assign(__assign({}, options), valueTransition))
141
- : animate(__assign(__assign({}, getPopmotionAnimationOptions(valueTransition, options, key)), { onUpdate: function (v) {
140
+ ? inertia(Object.assign(Object.assign({}, options), valueTransition))
141
+ : animate(Object.assign(Object.assign({}, getPopmotionAnimationOptions(valueTransition, options, key)), { onUpdate: (v) => {
142
142
  var _a;
143
143
  options.onUpdate(v);
144
144
  (_a = valueTransition.onUpdate) === null || _a === void 0 ? void 0 : _a.call(valueTransition, v);
145
- }, onComplete: function () {
145
+ }, onComplete: () => {
146
146
  var _a;
147
147
  options.onComplete();
148
148
  (_a = valueTransition.onComplete) === null || _a === void 0 ? void 0 : _a.call(valueTransition);
@@ -150,12 +150,12 @@ function getAnimation(key, value, target, transition, onComplete) {
150
150
  }
151
151
  function set() {
152
152
  var _a, _b;
153
- var finalTarget = resolveFinalValueInKeyframes(target);
153
+ const finalTarget = resolveFinalValueInKeyframes(target);
154
154
  value.set(finalTarget);
155
155
  onComplete();
156
156
  (_a = valueTransition === null || valueTransition === void 0 ? void 0 : valueTransition.onUpdate) === null || _a === void 0 ? void 0 : _a.call(valueTransition, finalTarget);
157
157
  (_b = valueTransition === null || valueTransition === void 0 ? void 0 : valueTransition.onComplete) === null || _b === void 0 ? void 0 : _b.call(valueTransition);
158
- return { stop: function () { } };
158
+ return { stop: () => { } };
159
159
  }
160
160
  return !isOriginAnimatable ||
161
161
  !isTargetAnimatable ||
@@ -181,24 +181,23 @@ function getValueTransition(transition, key) {
181
181
  * Start animation on a MotionValue. This function is an interface between
182
182
  * Framer Motion and Popmotion
183
183
  */
184
- function startAnimation(key, value, target, transition) {
185
- if (transition === void 0) { transition = {}; }
184
+ function startAnimation(key, value, target, transition = {}) {
186
185
  if (instantAnimationState.current) {
187
186
  transition = { type: false };
188
187
  }
189
- return value.start(function (onComplete) {
190
- var delayTimer;
191
- var controls;
192
- var animation = getAnimation(key, value, target, transition, onComplete);
193
- var delay = getDelayFromTransition(transition, key);
194
- var start = function () { return (controls = animation()); };
188
+ return value.start((onComplete) => {
189
+ let delayTimer;
190
+ let controls;
191
+ const animation = getAnimation(key, value, target, transition, onComplete);
192
+ const delay = getDelayFromTransition(transition, key);
193
+ const start = () => (controls = animation());
195
194
  if (delay) {
196
195
  delayTimer = window.setTimeout(start, secondsToMilliseconds(delay));
197
196
  }
198
197
  else {
199
198
  start();
200
199
  }
201
- return function () {
200
+ return () => {
202
201
  clearTimeout(delayTimer);
203
202
  controls === null || controls === void 0 ? void 0 : controls.stop();
204
203
  };
@@ -1,56 +1,43 @@
1
- import { __values } from 'tslib';
2
1
  import * as React from 'react';
3
2
  import { useId, useMemo } from 'react';
4
3
  import { PresenceContext } from '../../context/PresenceContext.mjs';
5
4
  import { useConstant } from '../../utils/use-constant.mjs';
6
5
 
7
- var PresenceChild = function (_a) {
8
- var children = _a.children, initial = _a.initial, isPresent = _a.isPresent, onExitComplete = _a.onExitComplete, custom = _a.custom, presenceAffectsLayout = _a.presenceAffectsLayout;
9
- var presenceChildren = useConstant(newChildrenMap);
10
- var id = useId();
11
- var context = useMemo(function () { return ({
12
- id: id,
13
- initial: initial,
14
- isPresent: isPresent,
15
- custom: custom,
16
- onExitComplete: function (childId) {
17
- var e_1, _a;
6
+ const PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, presenceAffectsLayout, }) => {
7
+ const presenceChildren = useConstant(newChildrenMap);
8
+ const id = useId();
9
+ const context = useMemo(() => ({
10
+ id,
11
+ initial,
12
+ isPresent,
13
+ custom,
14
+ onExitComplete: (childId) => {
18
15
  presenceChildren.set(childId, true);
19
- try {
20
- for (var _b = __values(presenceChildren.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
21
- var isComplete = _c.value;
22
- if (!isComplete)
23
- return; // can stop searching when any is incomplete
24
- }
25
- }
26
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
27
- finally {
28
- try {
29
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
30
- }
31
- finally { if (e_1) throw e_1.error; }
16
+ for (const isComplete of presenceChildren.values()) {
17
+ if (!isComplete)
18
+ return; // can stop searching when any is incomplete
32
19
  }
33
20
  onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete();
34
21
  },
35
- register: function (childId) {
22
+ register: (childId) => {
36
23
  presenceChildren.set(childId, false);
37
- return function () { return presenceChildren.delete(childId); };
24
+ return () => presenceChildren.delete(childId);
38
25
  },
39
- }); },
26
+ }),
40
27
  /**
41
28
  * If the presence of a child affects the layout of the components around it,
42
29
  * we want to make a new context value to ensure they get re-rendered
43
30
  * so they can detect that layout change.
44
31
  */
45
32
  presenceAffectsLayout ? undefined : [isPresent]);
46
- useMemo(function () {
47
- presenceChildren.forEach(function (_, key) { return presenceChildren.set(key, false); });
33
+ useMemo(() => {
34
+ presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
48
35
  }, [isPresent]);
49
36
  /**
50
37
  * If there's no `motion` components to fire exit animations, we want to remove this
51
38
  * component immediately.
52
39
  */
53
- React.useEffect(function () {
40
+ React.useEffect(() => {
54
41
  !isPresent && !presenceChildren.size && (onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete());
55
42
  }, [isPresent]);
56
43
  return (React.createElement(PresenceContext.Provider, { value: context }, children));