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
@@ -1,49 +1,49 @@
1
- import { __rest, __assign } from 'tslib';
1
+ import { __rest } from 'tslib';
2
2
 
3
3
  /**
4
4
  * Map an IntersectionHandler callback to an element. We only ever make one handler for one
5
5
  * element, so even though these handlers might all be triggered by different
6
6
  * observers, we can keep them in the same map.
7
7
  */
8
- var observerCallbacks = new WeakMap();
8
+ const observerCallbacks = new WeakMap();
9
9
  /**
10
10
  * Multiple observers can be created for multiple element/document roots. Each with
11
11
  * different settings. So here we store dictionaries of observers to each root,
12
12
  * using serialised settings (threshold/margin) as lookup keys.
13
13
  */
14
- var observers = new WeakMap();
15
- var fireObserverCallback = function (entry) {
14
+ const observers = new WeakMap();
15
+ const fireObserverCallback = (entry) => {
16
16
  var _a;
17
17
  (_a = observerCallbacks.get(entry.target)) === null || _a === void 0 ? void 0 : _a(entry);
18
18
  };
19
- var fireAllObserverCallbacks = function (entries) {
19
+ const fireAllObserverCallbacks = (entries) => {
20
20
  entries.forEach(fireObserverCallback);
21
21
  };
22
22
  function initIntersectionObserver(_a) {
23
- var root = _a.root, options = __rest(_a, ["root"]);
24
- var lookupRoot = root || document;
23
+ var { root } = _a, options = __rest(_a, ["root"]);
24
+ const lookupRoot = root || document;
25
25
  /**
26
26
  * If we don't have an observer lookup map for this root, create one.
27
27
  */
28
28
  if (!observers.has(lookupRoot)) {
29
29
  observers.set(lookupRoot, {});
30
30
  }
31
- var rootObservers = observers.get(lookupRoot);
32
- var key = JSON.stringify(options);
31
+ const rootObservers = observers.get(lookupRoot);
32
+ const key = JSON.stringify(options);
33
33
  /**
34
34
  * If we don't have an observer for this combination of root and settings,
35
35
  * create one.
36
36
  */
37
37
  if (!rootObservers[key]) {
38
- rootObservers[key] = new IntersectionObserver(fireAllObserverCallbacks, __assign({ root: root }, options));
38
+ rootObservers[key] = new IntersectionObserver(fireAllObserverCallbacks, Object.assign({ root }, options));
39
39
  }
40
40
  return rootObservers[key];
41
41
  }
42
42
  function observeIntersection(element, options, callback) {
43
- var rootInteresectionObserver = initIntersectionObserver(options);
43
+ const rootInteresectionObserver = initIntersectionObserver(options);
44
44
  observerCallbacks.set(element, callback);
45
45
  rootInteresectionObserver.observe(element);
46
- return function () {
46
+ return () => {
47
47
  observerCallbacks.delete(element);
48
48
  rootInteresectionObserver.unobserve(element);
49
49
  };
@@ -4,37 +4,35 @@ import { AnimationType } from '../../../render/utils/types.mjs';
4
4
  import { warnOnce } from '../../../utils/warn-once.mjs';
5
5
  import { observeIntersection } from './observers.mjs';
6
6
 
7
- function useViewport(_a) {
8
- var visualElement = _a.visualElement, whileInView = _a.whileInView, onViewportEnter = _a.onViewportEnter, onViewportLeave = _a.onViewportLeave, _b = _a.viewport, viewport = _b === void 0 ? {} : _b;
9
- var state = useRef({
7
+ function useViewport({ visualElement, whileInView, onViewportEnter, onViewportLeave, viewport = {}, }) {
8
+ const state = useRef({
10
9
  hasEnteredView: false,
11
10
  isInView: false,
12
11
  });
13
- var shouldObserve = Boolean(whileInView || onViewportEnter || onViewportLeave);
12
+ let shouldObserve = Boolean(whileInView || onViewportEnter || onViewportLeave);
14
13
  if (viewport.once && state.current.hasEnteredView)
15
14
  shouldObserve = false;
16
- var useObserver = typeof IntersectionObserver === "undefined"
15
+ const useObserver = typeof IntersectionObserver === "undefined"
17
16
  ? useMissingIntersectionObserver
18
17
  : useIntersectionObserver;
19
18
  useObserver(shouldObserve, state.current, visualElement, viewport);
20
19
  }
21
- var thresholdNames = {
20
+ const thresholdNames = {
22
21
  some: 0,
23
22
  all: 1,
24
23
  };
25
- function useIntersectionObserver(shouldObserve, state, visualElement, _a) {
26
- var root = _a.root, rootMargin = _a.margin, _b = _a.amount, amount = _b === void 0 ? "some" : _b, once = _a.once;
27
- useEffect(function () {
24
+ function useIntersectionObserver(shouldObserve, state, visualElement, { root, margin: rootMargin, amount = "some", once }) {
25
+ useEffect(() => {
28
26
  if (!shouldObserve)
29
27
  return;
30
- var options = {
28
+ const options = {
31
29
  root: root === null || root === void 0 ? void 0 : root.current,
32
- rootMargin: rootMargin,
30
+ rootMargin,
33
31
  threshold: typeof amount === "number" ? amount : thresholdNames[amount],
34
32
  };
35
- var intersectionCallback = function (entry) {
33
+ const intersectionCallback = (entry) => {
36
34
  var _a;
37
- var isIntersecting = entry.isIntersecting;
35
+ const { isIntersecting } = entry;
38
36
  /**
39
37
  * If there's been no change in the viewport state, early return.
40
38
  */
@@ -56,8 +54,8 @@ function useIntersectionObserver(shouldObserve, state, visualElement, _a) {
56
54
  * Use the latest committed props rather than the ones in scope
57
55
  * when this observer is created
58
56
  */
59
- var props = visualElement.getProps();
60
- var callback = isIntersecting
57
+ const props = visualElement.getProps();
58
+ const callback = isIntersecting
61
59
  ? props.onViewportEnter
62
60
  : props.onViewportLeave;
63
61
  callback === null || callback === void 0 ? void 0 : callback(entry);
@@ -70,9 +68,8 @@ function useIntersectionObserver(shouldObserve, state, visualElement, _a) {
70
68
  * on mount. This way, the page will be in the state the author expects users
71
69
  * to see it in for everyone.
72
70
  */
73
- function useMissingIntersectionObserver(shouldObserve, state, visualElement, _a) {
74
- var _b = _a.fallback, fallback = _b === void 0 ? true : _b;
75
- useEffect(function () {
71
+ function useMissingIntersectionObserver(shouldObserve, state, visualElement, { fallback = true }) {
72
+ useEffect(() => {
76
73
  if (!shouldObserve || !fallback)
77
74
  return;
78
75
  if (env !== "production") {
@@ -86,10 +83,10 @@ function useMissingIntersectionObserver(shouldObserve, state, visualElement, _a)
86
83
  * This hook should be quite rarely called so setting this in an rAF
87
84
  * is preferred to changing the behaviour of the animation state.
88
85
  */
89
- requestAnimationFrame(function () {
86
+ requestAnimationFrame(() => {
90
87
  var _a;
91
88
  state.hasEnteredView = true;
92
- var onViewportEnter = visualElement.getProps().onViewportEnter;
89
+ const { onViewportEnter } = visualElement.getProps();
93
90
  onViewportEnter === null || onViewportEnter === void 0 ? void 0 : onViewportEnter(null);
94
91
  (_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.InView, true);
95
92
  });
@@ -1,4 +1,3 @@
1
- import { __assign } from 'tslib';
2
1
  import * as React from 'react';
3
2
  import { forwardRef, useContext } from 'react';
4
3
  import { useFeatures } from './features/use-features.mjs';
@@ -23,21 +22,20 @@ import { VisualElementHandler } from './utils/VisualElementHandler.mjs';
23
22
  * Alongside this is a config option which provides a way of rendering the provided
24
23
  * component "offline", or outside the React render cycle.
25
24
  */
26
- function createMotionComponent(_a) {
27
- var preloadedFeatures = _a.preloadedFeatures, createVisualElement = _a.createVisualElement, projectionNodeConstructor = _a.projectionNodeConstructor, useRender = _a.useRender, useVisualState = _a.useVisualState, Component = _a.Component;
25
+ function createMotionComponent({ preloadedFeatures, createVisualElement, projectionNodeConstructor, useRender, useVisualState, Component, }) {
28
26
  preloadedFeatures && loadFeatures(preloadedFeatures);
29
27
  function MotionComponent(props, externalRef) {
30
- var layoutId = useLayoutId(props);
31
- props = __assign(__assign({}, props), { layoutId: layoutId });
28
+ const layoutId = useLayoutId(props);
29
+ props = Object.assign(Object.assign({}, props), { layoutId });
32
30
  /**
33
31
  * If we're rendering in a static environment, we only visually update the component
34
32
  * as a result of a React-rerender rather than interactions or animations. This
35
33
  * means we don't need to load additional memory structures like VisualElement,
36
34
  * or any gesture/animation features.
37
35
  */
38
- var config = useContext(MotionConfigContext);
39
- var features = null;
40
- var context = useCreateMotionContext(props);
36
+ const config = useContext(MotionConfigContext);
37
+ let features = null;
38
+ const context = useCreateMotionContext(props);
41
39
  /**
42
40
  * Create a unique projection ID for this component. If a new component is added
43
41
  * during a layout animation we'll use this to query the DOM and hydrate its ref early, allowing
@@ -49,11 +47,11 @@ function createMotionComponent(_a) {
49
47
  * shared element transitions however. Perhaps for those we could revert to a root node
50
48
  * that gets forceRendered and layout animations are triggered on its layout effect.
51
49
  */
52
- var projectionId = config.isStatic ? undefined : useProjectionId();
50
+ const projectionId = config.isStatic ? undefined : useProjectionId();
53
51
  /**
54
52
  *
55
53
  */
56
- var visualState = useVisualState(props, config.isStatic);
54
+ const visualState = useVisualState(props, config.isStatic);
57
55
  if (!config.isStatic && isBrowser) {
58
56
  /**
59
57
  * Create a VisualElement for this component. A VisualElement provides a common
@@ -61,7 +59,7 @@ function createMotionComponent(_a) {
61
59
  * providing a way of rendering to these APIs outside of the React render loop
62
60
  * for more performant animations and interactions
63
61
  */
64
- context.visualElement = useVisualElement(Component, visualState, __assign(__assign({}, config), props), createVisualElement);
62
+ context.visualElement = useVisualElement(Component, visualState, Object.assign(Object.assign({}, config), props), createVisualElement);
65
63
  useProjection(projectionId, props, context.visualElement, projectionNodeConstructor ||
66
64
  featureDefinitions.projectionNodeConstructor);
67
65
  /**
@@ -74,16 +72,15 @@ function createMotionComponent(_a) {
74
72
  * The mount order and hierarchy is specific to ensure our element ref
75
73
  * is hydrated by the time features fire their effects.
76
74
  */
77
- return (React.createElement(VisualElementHandler, { visualElement: context.visualElement, props: __assign(__assign({}, config), props) },
75
+ return (React.createElement(VisualElementHandler, { visualElement: context.visualElement, props: Object.assign(Object.assign({}, config), props) },
78
76
  features,
79
77
  React.createElement(MotionContext.Provider, { value: context }, useRender(Component, props, projectionId, useMotionRef(visualState, context.visualElement, externalRef), visualState, config.isStatic, context.visualElement))));
80
78
  }
81
79
  return forwardRef(MotionComponent);
82
80
  }
83
- function useLayoutId(_a) {
84
- var _b;
85
- var layoutId = _a.layoutId;
86
- var layoutGroupId = (_b = useContext(LayoutGroupContext)) === null || _b === void 0 ? void 0 : _b.id;
81
+ function useLayoutId({ layoutId }) {
82
+ var _a;
83
+ const layoutGroupId = (_a = useContext(LayoutGroupContext)) === null || _a === void 0 ? void 0 : _a.id;
87
84
  return layoutGroupId && layoutId !== undefined
88
85
  ? layoutGroupId + "-" + layoutId
89
86
  : layoutId;
@@ -1,28 +1,22 @@
1
- import { __extends } from 'tslib';
2
1
  import React__default from 'react';
3
2
 
4
- var VisualElementHandler = /** @class */ (function (_super) {
5
- __extends(VisualElementHandler, _super);
6
- function VisualElementHandler() {
7
- return _super !== null && _super.apply(this, arguments) || this;
8
- }
3
+ class VisualElementHandler extends React__default.Component {
9
4
  /**
10
5
  * Update visual element props as soon as we know this update is going to be commited.
11
6
  */
12
- VisualElementHandler.prototype.getSnapshotBeforeUpdate = function () {
7
+ getSnapshotBeforeUpdate() {
13
8
  this.updateProps();
14
9
  return null;
15
- };
16
- VisualElementHandler.prototype.componentDidUpdate = function () { };
17
- VisualElementHandler.prototype.updateProps = function () {
18
- var _a = this.props, visualElement = _a.visualElement, props = _a.props;
10
+ }
11
+ componentDidUpdate() { }
12
+ updateProps() {
13
+ const { visualElement, props } = this.props;
19
14
  if (visualElement)
20
15
  visualElement.setProps(props);
21
- };
22
- VisualElementHandler.prototype.render = function () {
16
+ }
17
+ render() {
23
18
  return this.props.children;
24
- };
25
- return VisualElementHandler;
26
- }(React__default.Component));
19
+ }
20
+ }
27
21
 
28
22
  export { VisualElementHandler };
@@ -1,8 +1,7 @@
1
1
  import { scaleCorrectors } from '../../projection/styles/scale-correction.mjs';
2
2
  import { isTransformProp, isTransformOriginProp } from '../../render/html/utils/transform.mjs';
3
3
 
4
- function isForcedMotionValue(key, _a) {
5
- var layout = _a.layout, layoutId = _a.layoutId;
4
+ function isForcedMotionValue(key, { layout, layoutId }) {
6
5
  return (isTransformProp(key) ||
7
6
  isTransformOriginProp(key) ||
8
7
  ((layout || layoutId !== undefined) &&
@@ -1,6 +1,6 @@
1
- var makeRenderlessComponent = function (hook) { return function (props) {
1
+ const makeRenderlessComponent = (hook) => (props) => {
2
2
  hook(props);
3
3
  return null;
4
- }; };
4
+ };
5
5
 
6
6
  export { makeRenderlessComponent };
@@ -6,7 +6,7 @@ import { isRefObject } from '../../utils/is-ref-object.mjs';
6
6
  * external ref and VisualElement.
7
7
  */
8
8
  function useMotionRef(visualState, visualElement, externalRef) {
9
- return useCallback(function (instance) {
9
+ return useCallback((instance) => {
10
10
  var _a;
11
11
  instance && ((_a = visualState.mount) === null || _a === void 0 ? void 0 : _a.call(visualState, instance));
12
12
  if (visualElement) {
@@ -6,11 +6,11 @@ import { LazyContext } from '../../context/LazyContext.mjs';
6
6
  import { useReducedMotionConfig } from '../../utils/use-reduced-motion.mjs';
7
7
 
8
8
  function useVisualElement(Component, visualState, props, createVisualElement) {
9
- var lazyContext = useContext(LazyContext);
10
- var parent = useVisualElementContext();
11
- var presenceContext = useContext(PresenceContext);
12
- var shouldReduceMotion = useReducedMotionConfig();
13
- var visualElementRef = useRef(undefined);
9
+ const lazyContext = useContext(LazyContext);
10
+ const parent = useVisualElementContext();
11
+ const presenceContext = useContext(PresenceContext);
12
+ const shouldReduceMotion = useReducedMotionConfig();
13
+ const visualElementRef = useRef(undefined);
14
14
  /**
15
15
  * If we haven't preloaded a renderer, check to see if we have one lazy-loaded
16
16
  */
@@ -18,23 +18,23 @@ function useVisualElement(Component, visualState, props, createVisualElement) {
18
18
  createVisualElement = lazyContext.renderer;
19
19
  if (!visualElementRef.current && createVisualElement) {
20
20
  visualElementRef.current = createVisualElement(Component, {
21
- visualState: visualState,
22
- parent: parent,
23
- props: props,
21
+ visualState,
22
+ parent,
23
+ props,
24
24
  presenceId: presenceContext === null || presenceContext === void 0 ? void 0 : presenceContext.id,
25
25
  blockInitialAnimation: (presenceContext === null || presenceContext === void 0 ? void 0 : presenceContext.initial) === false,
26
- shouldReduceMotion: shouldReduceMotion,
26
+ shouldReduceMotion,
27
27
  });
28
28
  }
29
- var visualElement = visualElementRef.current;
30
- useIsomorphicLayoutEffect(function () {
29
+ const visualElement = visualElementRef.current;
30
+ useIsomorphicLayoutEffect(() => {
31
31
  visualElement === null || visualElement === void 0 ? void 0 : visualElement.syncRender();
32
32
  });
33
- useEffect(function () {
33
+ useEffect(() => {
34
34
  var _a;
35
35
  (_a = visualElement === null || visualElement === void 0 ? void 0 : visualElement.animationState) === null || _a === void 0 ? void 0 : _a.animateChanges();
36
36
  });
37
- useIsomorphicLayoutEffect(function () { return function () { return visualElement === null || visualElement === void 0 ? void 0 : visualElement.notifyUnmount(); }; }, []);
37
+ useIsomorphicLayoutEffect(() => () => visualElement === null || visualElement === void 0 ? void 0 : visualElement.notifyUnmount(), []);
38
38
  return visualElement;
39
39
  }
40
40
 
@@ -7,38 +7,33 @@ import { useConstant } from '../../utils/use-constant.mjs';
7
7
  import { resolveMotionValue } from '../../value/utils/resolve-motion-value.mjs';
8
8
  import { MotionContext } from '../../context/MotionContext/index.mjs';
9
9
 
10
- function makeState(_a, props, context, presenceContext) {
11
- var scrapeMotionValuesFromProps = _a.scrapeMotionValuesFromProps, createRenderState = _a.createRenderState, onMount = _a.onMount;
12
- var state = {
10
+ function makeState({ scrapeMotionValuesFromProps, createRenderState, onMount, }, props, context, presenceContext) {
11
+ const state = {
13
12
  latestValues: makeLatestValues(props, context, presenceContext, scrapeMotionValuesFromProps),
14
13
  renderState: createRenderState(),
15
14
  };
16
15
  if (onMount) {
17
- state.mount = function (instance) { return onMount(props, instance, state); };
16
+ state.mount = (instance) => onMount(props, instance, state);
18
17
  }
19
18
  return state;
20
19
  }
21
- var makeUseVisualState = function (config) {
22
- return function (props, isStatic) {
23
- var context = useContext(MotionContext);
24
- var presenceContext = useContext(PresenceContext);
25
- return isStatic
26
- ? makeState(config, props, context, presenceContext)
27
- : useConstant(function () {
28
- return makeState(config, props, context, presenceContext);
29
- });
30
- };
20
+ const makeUseVisualState = (config) => (props, isStatic) => {
21
+ const context = useContext(MotionContext);
22
+ const presenceContext = useContext(PresenceContext);
23
+ return isStatic
24
+ ? makeState(config, props, context, presenceContext)
25
+ : useConstant(() => makeState(config, props, context, presenceContext));
31
26
  };
32
27
  function makeLatestValues(props, context, presenceContext, scrapeMotionValues) {
33
- var values = {};
34
- var blockInitialAnimation = (presenceContext === null || presenceContext === void 0 ? void 0 : presenceContext.initial) === false;
35
- var motionValues = scrapeMotionValues(props);
36
- for (var key in motionValues) {
28
+ const values = {};
29
+ const blockInitialAnimation = (presenceContext === null || presenceContext === void 0 ? void 0 : presenceContext.initial) === false;
30
+ const motionValues = scrapeMotionValues(props);
31
+ for (const key in motionValues) {
37
32
  values[key] = resolveMotionValue(motionValues[key]);
38
33
  }
39
- var initial = props.initial, animate = props.animate;
40
- var isControllingVariants = checkIfControllingVariants(props);
41
- var isVariantNode = checkIfVariantNode(props);
34
+ let { initial, animate } = props;
35
+ const isControllingVariants = checkIfControllingVariants(props);
36
+ const isVariantNode = checkIfVariantNode(props);
42
37
  if (context &&
43
38
  isVariantNode &&
44
39
  !isControllingVariants &&
@@ -46,25 +41,25 @@ function makeLatestValues(props, context, presenceContext, scrapeMotionValues) {
46
41
  initial !== null && initial !== void 0 ? initial : (initial = context.initial);
47
42
  animate !== null && animate !== void 0 ? animate : (animate = context.animate);
48
43
  }
49
- var initialAnimationIsBlocked = blockInitialAnimation || initial === false;
50
- var variantToSet = initialAnimationIsBlocked ? animate : initial;
44
+ const initialAnimationIsBlocked = blockInitialAnimation || initial === false;
45
+ const variantToSet = initialAnimationIsBlocked ? animate : initial;
51
46
  if (variantToSet &&
52
47
  typeof variantToSet !== "boolean" &&
53
48
  !isAnimationControls(variantToSet)) {
54
- var list = Array.isArray(variantToSet) ? variantToSet : [variantToSet];
55
- list.forEach(function (definition) {
56
- var resolved = resolveVariantFromProps(props, definition);
49
+ const list = Array.isArray(variantToSet) ? variantToSet : [variantToSet];
50
+ list.forEach((definition) => {
51
+ const resolved = resolveVariantFromProps(props, definition);
57
52
  if (!resolved)
58
53
  return;
59
- var transitionEnd = resolved.transitionEnd; resolved.transition; var target = __rest(resolved, ["transitionEnd", "transition"]);
60
- for (var key in target) {
61
- var valueTarget = target[key];
54
+ const { transitionEnd, transition } = resolved, target = __rest(resolved, ["transitionEnd", "transition"]);
55
+ for (const key in target) {
56
+ let valueTarget = target[key];
62
57
  if (Array.isArray(valueTarget)) {
63
58
  /**
64
59
  * Take final keyframe if the initial animation is blocked because
65
60
  * we want to initialise at the end of that blocked animation.
66
61
  */
67
- var index = initialAnimationIsBlocked
62
+ const index = initialAnimationIsBlocked
68
63
  ? valueTarget.length - 1
69
64
  : 0;
70
65
  valueTarget = valueTarget[index];
@@ -73,7 +68,7 @@ function makeLatestValues(props, context, presenceContext, scrapeMotionValues) {
73
68
  values[key] = valueTarget;
74
69
  }
75
70
  }
76
- for (var key in transitionEnd)
71
+ for (const key in transitionEnd)
77
72
  values[key] = transitionEnd[key];
78
73
  });
79
74
  }
@@ -4,7 +4,7 @@
4
4
  * @privateRemarks
5
5
  * This doesn't throw if a `MotionProp` name is missing - it should.
6
6
  */
7
- var validMotionProps = new Set([
7
+ const validMotionProps = new Set([
8
8
  "initial",
9
9
  "animate",
10
10
  "exit",
@@ -1,14 +1,10 @@
1
1
  import { mix, progress, circOut, linear } from 'popmotion';
2
2
  import { percent, px } from 'style-value-types';
3
3
 
4
- var borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
5
- var numBorders = borders.length;
6
- var asNumber = function (value) {
7
- return typeof value === "string" ? parseFloat(value) : value;
8
- };
9
- var isPx = function (value) {
10
- return typeof value === "number" || px.test(value);
11
- };
4
+ const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
5
+ const numBorders = borders.length;
6
+ const asNumber = (value) => typeof value === "string" ? parseFloat(value) : value;
7
+ const isPx = (value) => typeof value === "number" || px.test(value);
12
8
  function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnlyMember) {
13
9
  var _a, _b, _c, _d;
14
10
  if (shouldCrossfadeOpacity) {
@@ -24,15 +20,15 @@ function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnl
24
20
  /**
25
21
  * Mix border radius
26
22
  */
27
- for (var i = 0; i < numBorders; i++) {
28
- var borderLabel = "border".concat(borders[i], "Radius");
29
- var followRadius = getRadius(follow, borderLabel);
30
- var leadRadius = getRadius(lead, borderLabel);
23
+ for (let i = 0; i < numBorders; i++) {
24
+ const borderLabel = `border${borders[i]}Radius`;
25
+ let followRadius = getRadius(follow, borderLabel);
26
+ let leadRadius = getRadius(lead, borderLabel);
31
27
  if (followRadius === undefined && leadRadius === undefined)
32
28
  continue;
33
29
  followRadius || (followRadius = 0);
34
30
  leadRadius || (leadRadius = 0);
35
- var canMix = followRadius === 0 ||
31
+ const canMix = followRadius === 0 ||
36
32
  leadRadius === 0 ||
37
33
  isPx(followRadius) === isPx(leadRadius);
38
34
  if (canMix) {
@@ -79,10 +75,10 @@ function getRadius(values, radiusName) {
79
75
  // latestLeadValues.backgroundColor as string
80
76
  // )(p)
81
77
  // }
82
- var easeCrossfadeIn = compress(0, 0.5, circOut);
83
- var easeCrossfadeOut = compress(0.5, 0.95, linear);
78
+ const easeCrossfadeIn = compress(0, 0.5, circOut);
79
+ const easeCrossfadeOut = compress(0.5, 0.95, linear);
84
80
  function compress(min, max, easing) {
85
- return function (p) {
81
+ return (p) => {
86
82
  // Could replace ifs with clamp
87
83
  if (p < min)
88
84
  return 0;
@@ -3,15 +3,13 @@
3
3
  * it's easier to consider each axis individually. This function returns a bounding box
4
4
  * as a map of single-axis min/max values.
5
5
  */
6
- function convertBoundingBoxToBox(_a) {
7
- var top = _a.top, left = _a.left, right = _a.right, bottom = _a.bottom;
6
+ function convertBoundingBoxToBox({ top, left, right, bottom, }) {
8
7
  return {
9
8
  x: { min: left, max: right },
10
9
  y: { min: top, max: bottom },
11
10
  };
12
11
  }
13
- function convertBoxToBoundingBox(_a) {
14
- var x = _a.x, y = _a.y;
12
+ function convertBoxToBoundingBox({ x, y }) {
15
13
  return { top: y.min, right: x.max, bottom: y.max, left: x.min };
16
14
  }
17
15
  /**
@@ -22,8 +20,8 @@ function convertBoxToBoundingBox(_a) {
22
20
  function transformBoxPoints(point, transformPoint) {
23
21
  if (!transformPoint)
24
22
  return point;
25
- var topLeft = transformPoint({ x: point.left, y: point.top });
26
- var bottomRight = transformPoint({ x: point.right, y: point.bottom });
23
+ const topLeft = transformPoint({ x: point.left, y: point.top });
24
+ const bottomRight = transformPoint({ x: point.right, y: point.bottom });
27
25
  return {
28
26
  top: topLeft.y,
29
27
  left: topLeft.x,
@@ -1,4 +1,3 @@
1
- import { __read } from 'tslib';
2
1
  import { mix } from 'popmotion';
3
2
  import { hasTransform } from '../utils/has-transform.mjs';
4
3
 
@@ -6,8 +5,8 @@ import { hasTransform } from '../utils/has-transform.mjs';
6
5
  * Scales a point based on a factor and an originPoint
7
6
  */
8
7
  function scalePoint(point, scale, originPoint) {
9
- var distanceFromOrigin = point - originPoint;
10
- var scaled = scale * distanceFromOrigin;
8
+ const distanceFromOrigin = point - originPoint;
9
+ const scaled = scale * distanceFromOrigin;
11
10
  return originPoint + scaled;
12
11
  }
13
12
  /**
@@ -22,17 +21,14 @@ function applyPointDelta(point, translate, scale, originPoint, boxScale) {
22
21
  /**
23
22
  * Applies a translate/scale delta to an axis
24
23
  */
25
- function applyAxisDelta(axis, translate, scale, originPoint, boxScale) {
26
- if (translate === void 0) { translate = 0; }
27
- if (scale === void 0) { scale = 1; }
24
+ function applyAxisDelta(axis, translate = 0, scale = 1, originPoint, boxScale) {
28
25
  axis.min = applyPointDelta(axis.min, translate, scale, originPoint, boxScale);
29
26
  axis.max = applyPointDelta(axis.max, translate, scale, originPoint, boxScale);
30
27
  }
31
28
  /**
32
29
  * Applies a translate/scale delta to a box
33
30
  */
34
- function applyBoxDelta(box, _a) {
35
- var x = _a.x, y = _a.y;
31
+ function applyBoxDelta(box, { x, y }) {
36
32
  applyAxisDelta(box.x, x.translate, x.scale, x.originPoint);
37
33
  applyAxisDelta(box.y, y.translate, y.scale, y.originPoint);
38
34
  }
@@ -42,17 +38,16 @@ function applyBoxDelta(box, _a) {
42
38
  *
43
39
  * This is the final nested loop within updateLayoutDelta for future refactoring
44
40
  */
45
- function applyTreeDeltas(box, treeScale, treePath, isSharedTransition) {
41
+ function applyTreeDeltas(box, treeScale, treePath, isSharedTransition = false) {
46
42
  var _a, _b;
47
- if (isSharedTransition === void 0) { isSharedTransition = false; }
48
- var treeLength = treePath.length;
43
+ const treeLength = treePath.length;
49
44
  if (!treeLength)
50
45
  return;
51
46
  // Reset the treeScale
52
47
  treeScale.x = treeScale.y = 1;
53
- var node;
54
- var delta;
55
- for (var i = 0; i < treeLength; i++) {
48
+ let node;
49
+ let delta;
50
+ for (let i = 0; i < treeLength; i++) {
56
51
  node = treePath[i];
57
52
  delta = node.projectionDelta;
58
53
  if (((_b = (_a = node.instance) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.display) === "contents")
@@ -84,18 +79,17 @@ function translateAxis(axis, distance) {
84
79
  * This function basically acts as a bridge between a flat motion value map
85
80
  * and applyAxisDelta
86
81
  */
87
- function transformAxis(axis, transforms, _a) {
88
- var _b = __read(_a, 3), key = _b[0], scaleKey = _b[1], originKey = _b[2];
89
- var axisOrigin = transforms[originKey] !== undefined ? transforms[originKey] : 0.5;
90
- var originPoint = mix(axis.min, axis.max, axisOrigin);
82
+ function transformAxis(axis, transforms, [key, scaleKey, originKey]) {
83
+ const axisOrigin = transforms[originKey] !== undefined ? transforms[originKey] : 0.5;
84
+ const originPoint = mix(axis.min, axis.max, axisOrigin);
91
85
  // Apply the axis delta to the final axis
92
86
  applyAxisDelta(axis, transforms[key], transforms[scaleKey], originPoint, transforms.scale);
93
87
  }
94
88
  /**
95
89
  * The names of the motion values we want to apply as translation, scale and origin.
96
90
  */
97
- var xKeys = ["x", "scaleX", "originX"];
98
- var yKeys = ["y", "scaleY", "originY"];
91
+ const xKeys = ["x", "scaleX", "originX"];
92
+ const yKeys = ["y", "scaleY", "originY"];
99
93
  /**
100
94
  * Apply a transform to a box from the latest resolved motion values.
101
95
  */
@@ -3,13 +3,10 @@ import { mix, distance } from 'popmotion';
3
3
  function calcLength(axis) {
4
4
  return axis.max - axis.min;
5
5
  }
6
- function isNear(value, target, maxDistance) {
7
- if (target === void 0) { target = 0; }
8
- if (maxDistance === void 0) { maxDistance = 0.01; }
6
+ function isNear(value, target = 0, maxDistance = 0.01) {
9
7
  return distance(value, target) < maxDistance;
10
8
  }
11
- function calcAxisDelta(delta, source, target, origin) {
12
- if (origin === void 0) { origin = 0.5; }
9
+ function calcAxisDelta(delta, source, target, origin = 0.5) {
13
10
  delta.origin = origin;
14
11
  delta.originPoint = mix(source.min, source.max, delta.origin);
15
12
  delta.scale = calcLength(target) / calcLength(source);