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,4 +1,3 @@
1
- import { __read, __spreadArray } from 'tslib';
2
1
  import * as React from 'react';
3
2
  import { useContext, useRef, cloneElement, Children, isValidElement } from 'react';
4
3
  import { env } from '../../utils/process.mjs';
@@ -9,17 +8,17 @@ import { LayoutGroupContext } from '../../context/LayoutGroupContext.mjs';
9
8
  import { useIsomorphicLayoutEffect } from '../../utils/use-isomorphic-effect.mjs';
10
9
  import { useUnmountEffect } from '../../utils/use-unmount-effect.mjs';
11
10
 
12
- var getChildKey = function (child) { return child.key || ""; };
11
+ const getChildKey = (child) => child.key || "";
13
12
  function updateChildLookup(children, allChildren) {
14
- children.forEach(function (child) {
15
- var key = getChildKey(child);
13
+ children.forEach((child) => {
14
+ const key = getChildKey(child);
16
15
  allChildren.set(key, child);
17
16
  });
18
17
  }
19
18
  function onlyElements(children) {
20
- var filtered = [];
19
+ const filtered = [];
21
20
  // We use forEach here instead of map as map mutates the component key by preprending `.$`
22
- Children.forEach(children, function (child) {
21
+ Children.forEach(children, (child) => {
23
22
  if (isValidElement(child))
24
23
  filtered.push(child);
25
24
  });
@@ -58,50 +57,49 @@ function onlyElements(children) {
58
57
  *
59
58
  * @public
60
59
  */
61
- var AnimatePresence = function (_a) {
62
- var children = _a.children, custom = _a.custom, _b = _a.initial, initial = _b === void 0 ? true : _b, onExitComplete = _a.onExitComplete, exitBeforeEnter = _a.exitBeforeEnter, _c = _a.presenceAffectsLayout, presenceAffectsLayout = _c === void 0 ? true : _c;
60
+ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exitBeforeEnter, presenceAffectsLayout = true, }) => {
63
61
  // We want to force a re-render once all exiting animations have finished. We
64
62
  // either use a local forceRender function, or one from a parent context if it exists.
65
- var _d = __read(useForceUpdate(), 1), forceRender = _d[0];
66
- var forceRenderLayoutGroup = useContext(LayoutGroupContext).forceRender;
63
+ let [forceRender] = useForceUpdate();
64
+ const forceRenderLayoutGroup = useContext(LayoutGroupContext).forceRender;
67
65
  if (forceRenderLayoutGroup)
68
66
  forceRender = forceRenderLayoutGroup;
69
- var isMounted = useIsMounted();
67
+ const isMounted = useIsMounted();
70
68
  // Filter out any children that aren't ReactElements. We can only track ReactElements with a props.key
71
- var filteredChildren = onlyElements(children);
72
- var childrenToRender = filteredChildren;
73
- var exiting = new Set();
69
+ const filteredChildren = onlyElements(children);
70
+ let childrenToRender = filteredChildren;
71
+ const exiting = new Set();
74
72
  // Keep a living record of the children we're actually rendering so we
75
73
  // can diff to figure out which are entering and exiting
76
- var presentChildren = useRef(childrenToRender);
74
+ const presentChildren = useRef(childrenToRender);
77
75
  // A lookup table to quickly reference components by key
78
- var allChildren = useRef(new Map()).current;
76
+ const allChildren = useRef(new Map()).current;
79
77
  // If this is the initial component render, just deal with logic surrounding whether
80
78
  // we play onMount animations or not.
81
- var isInitialRender = useRef(true);
82
- useIsomorphicLayoutEffect(function () {
79
+ const isInitialRender = useRef(true);
80
+ useIsomorphicLayoutEffect(() => {
83
81
  isInitialRender.current = false;
84
82
  updateChildLookup(filteredChildren, allChildren);
85
83
  presentChildren.current = childrenToRender;
86
84
  });
87
- useUnmountEffect(function () {
85
+ useUnmountEffect(() => {
88
86
  isInitialRender.current = true;
89
87
  allChildren.clear();
90
88
  exiting.clear();
91
89
  });
92
90
  if (isInitialRender.current) {
93
- return (React.createElement(React.Fragment, null, childrenToRender.map(function (child) { return (React.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, initial: initial ? undefined : false, presenceAffectsLayout: presenceAffectsLayout }, child)); })));
91
+ return (React.createElement(React.Fragment, null, childrenToRender.map((child) => (React.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, initial: initial ? undefined : false, presenceAffectsLayout: presenceAffectsLayout }, child)))));
94
92
  }
95
93
  // If this is a subsequent render, deal with entering and exiting children
96
- childrenToRender = __spreadArray([], __read(childrenToRender), false);
94
+ childrenToRender = [...childrenToRender];
97
95
  // Diff the keys of the currently-present and target children to update our
98
96
  // exiting list.
99
- var presentKeys = presentChildren.current.map(getChildKey);
100
- var targetKeys = filteredChildren.map(getChildKey);
97
+ const presentKeys = presentChildren.current.map(getChildKey);
98
+ const targetKeys = filteredChildren.map(getChildKey);
101
99
  // Diff the present children with our target children and mark those that are exiting
102
- var numPresent = presentKeys.length;
103
- for (var i = 0; i < numPresent; i++) {
104
- var key = presentKeys[i];
100
+ const numPresent = presentKeys.length;
101
+ for (let i = 0; i < numPresent; i++) {
102
+ const key = presentKeys[i];
105
103
  if (targetKeys.indexOf(key) === -1) {
106
104
  exiting.add(key);
107
105
  }
@@ -113,19 +111,19 @@ var AnimatePresence = function (_a) {
113
111
  }
114
112
  // Loop through all currently exiting components and clone them to overwrite `animate`
115
113
  // with any `exit` prop they might have defined.
116
- exiting.forEach(function (key) {
114
+ exiting.forEach((key) => {
117
115
  // If this component is actually entering again, early return
118
116
  if (targetKeys.indexOf(key) !== -1)
119
117
  return;
120
- var child = allChildren.get(key);
118
+ const child = allChildren.get(key);
121
119
  if (!child)
122
120
  return;
123
- var insertionIndex = presentKeys.indexOf(key);
124
- var onExit = function () {
121
+ const insertionIndex = presentKeys.indexOf(key);
122
+ const onExit = () => {
125
123
  allChildren.delete(key);
126
124
  exiting.delete(key);
127
125
  // Remove this child from the present children
128
- var removeIndex = presentChildren.current.findIndex(function (presentChild) { return presentChild.key === key; });
126
+ const removeIndex = presentChildren.current.findIndex((presentChild) => presentChild.key === key);
129
127
  presentChildren.current.splice(removeIndex, 1);
130
128
  // Defer re-rendering until all exiting children have indeed left
131
129
  if (!exiting.size) {
@@ -140,18 +138,18 @@ var AnimatePresence = function (_a) {
140
138
  });
141
139
  // Add `MotionContext` even to children that don't need it to ensure we're rendering
142
140
  // the same tree between renders
143
- childrenToRender = childrenToRender.map(function (child) {
144
- var key = child.key;
141
+ childrenToRender = childrenToRender.map((child) => {
142
+ const key = child.key;
145
143
  return exiting.has(key) ? (child) : (React.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, presenceAffectsLayout: presenceAffectsLayout }, child));
146
144
  });
147
145
  if (env !== "production" &&
148
146
  exitBeforeEnter &&
149
147
  childrenToRender.length > 1) {
150
- console.warn("You're attempting to animate multiple children within AnimatePresence, but its exitBeforeEnter prop is set to true. This will lead to odd visual behaviour.");
148
+ console.warn(`You're attempting to animate multiple children within AnimatePresence, but its exitBeforeEnter prop is set to true. This will lead to odd visual behaviour.`);
151
149
  }
152
150
  return (React.createElement(React.Fragment, null, exiting.size
153
151
  ? childrenToRender
154
- : childrenToRender.map(function (child) { return cloneElement(child); })));
152
+ : childrenToRender.map((child) => cloneElement(child))));
155
153
  };
156
154
 
157
155
  export { AnimatePresence };
@@ -25,16 +25,16 @@ import { PresenceContext } from '../../context/PresenceContext.mjs';
25
25
  * @public
26
26
  */
27
27
  function usePresence() {
28
- var context = useContext(PresenceContext);
28
+ const context = useContext(PresenceContext);
29
29
  if (context === null)
30
30
  return [true, null];
31
- var isPresent = context.isPresent, onExitComplete = context.onExitComplete, register = context.register;
31
+ const { isPresent, onExitComplete, register } = context;
32
32
  // It's safe to call the following hooks conditionally (after an early return) because the context will always
33
33
  // either be null or non-null for the lifespan of the component.
34
34
  // Replace with useId when released in React
35
- var id = useId();
36
- useEffect(function () { return register(id); }, []);
37
- var safeToRemove = function () { return onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete(id); };
35
+ const id = useId();
36
+ useEffect(() => register(id), []);
37
+ const safeToRemove = () => onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete(id);
38
38
  return !isPresent && onExitComplete ? [false, safeToRemove] : [true];
39
39
  }
40
40
  /**
@@ -3,13 +3,12 @@ import * as React from 'react';
3
3
  import { useConstant } from '../utils/use-constant.mjs';
4
4
  import { LayoutGroup } from './LayoutGroup/index.mjs';
5
5
 
6
- var id = 0;
7
- var AnimateSharedLayout = function (_a) {
8
- var children = _a.children;
9
- React.useEffect(function () {
6
+ let id = 0;
7
+ const AnimateSharedLayout = ({ children, }) => {
8
+ React.useEffect(() => {
10
9
  warning(false, "AnimateSharedLayout is deprecated: https://www.framer.com/docs/guide-upgrade/##shared-layout-animations");
11
10
  }, []);
12
- return (React.createElement(LayoutGroup, { id: useConstant(function () { return "asl-".concat(id++); }) }, children));
11
+ return (React.createElement(LayoutGroup, { id: useConstant(() => `asl-${id++}`) }, children));
13
12
  };
14
13
 
15
14
  export { AnimateSharedLayout };
@@ -1,4 +1,3 @@
1
- import { __read, __assign } from 'tslib';
2
1
  import * as React from 'react';
3
2
  import { useContext, useRef, useMemo } from 'react';
4
3
  import { LayoutGroupContext } from '../../context/LayoutGroupContext.mjs';
@@ -6,33 +5,30 @@ import { DeprecatedLayoutGroupContext } from '../../context/DeprecatedLayoutGrou
6
5
  import { useForceUpdate } from '../../utils/use-force-update.mjs';
7
6
  import { nodeGroup } from '../../projection/node/group.mjs';
8
7
 
9
- var shouldInheritGroup = function (inherit) { return inherit === true; };
10
- var shouldInheritId = function (inherit) {
11
- return shouldInheritGroup(inherit === true) || inherit === "id";
12
- };
13
- var LayoutGroup = function (_a) {
14
- var _b, _c;
15
- var children = _a.children, id = _a.id, inheritId = _a.inheritId, _d = _a.inherit, inherit = _d === void 0 ? true : _d;
8
+ const shouldInheritGroup = (inherit) => inherit === true;
9
+ const shouldInheritId = (inherit) => shouldInheritGroup(inherit === true) || inherit === "id";
10
+ const LayoutGroup = ({ children, id, inheritId, inherit = true, }) => {
11
+ var _a, _b;
16
12
  // Maintain backwards-compatibility with inheritId until 7.0
17
13
  if (inheritId !== undefined)
18
14
  inherit = inheritId;
19
- var layoutGroupContext = useContext(LayoutGroupContext);
20
- var deprecatedLayoutGroupContext = useContext(DeprecatedLayoutGroupContext);
21
- var _e = __read(useForceUpdate(), 2), forceRender = _e[0], key = _e[1];
22
- var context = useRef(null);
23
- var upstreamId = (_b = layoutGroupContext.id) !== null && _b !== void 0 ? _b : deprecatedLayoutGroupContext;
15
+ const layoutGroupContext = useContext(LayoutGroupContext);
16
+ const deprecatedLayoutGroupContext = useContext(DeprecatedLayoutGroupContext);
17
+ const [forceRender, key] = useForceUpdate();
18
+ const context = useRef(null);
19
+ const upstreamId = (_a = layoutGroupContext.id) !== null && _a !== void 0 ? _a : deprecatedLayoutGroupContext;
24
20
  if (context.current === null) {
25
21
  if (shouldInheritId(inherit) && upstreamId) {
26
22
  id = id ? upstreamId + "-" + id : upstreamId;
27
23
  }
28
24
  context.current = {
29
- id: id,
25
+ id,
30
26
  group: shouldInheritGroup(inherit)
31
- ? (_c = layoutGroupContext === null || layoutGroupContext === void 0 ? void 0 : layoutGroupContext.group) !== null && _c !== void 0 ? _c : nodeGroup()
27
+ ? (_b = layoutGroupContext === null || layoutGroupContext === void 0 ? void 0 : layoutGroupContext.group) !== null && _b !== void 0 ? _b : nodeGroup()
32
28
  : nodeGroup(),
33
29
  };
34
30
  }
35
- var memoizedContext = useMemo(function () { return (__assign(__assign({}, context.current), { forceRender: forceRender })); }, [key]);
31
+ const memoizedContext = useMemo(() => (Object.assign(Object.assign({}, context.current), { forceRender })), [key]);
36
32
  return (React.createElement(LayoutGroupContext.Provider, { value: memoizedContext }, children));
37
33
  };
38
34
 
@@ -1,4 +1,4 @@
1
- import { __read, __rest } from 'tslib';
1
+ import { __rest } from 'tslib';
2
2
  import * as React from 'react';
3
3
  import { useState, useRef, useEffect } from 'react';
4
4
  import { LazyContext } from '../../context/LazyContext.mjs';
@@ -39,29 +39,28 @@ import { loadFeatures } from '../../motion/features/definitions.mjs';
39
39
  *
40
40
  * @public
41
41
  */
42
- function LazyMotion(_a) {
43
- var children = _a.children, features = _a.features, _b = _a.strict, strict = _b === void 0 ? false : _b;
44
- var _c = __read(useState(!isLazyBundle(features)), 2), setIsLoaded = _c[1];
45
- var loadedRenderer = useRef(undefined);
42
+ function LazyMotion({ children, features, strict = false }) {
43
+ const [, setIsLoaded] = useState(!isLazyBundle(features));
44
+ const loadedRenderer = useRef(undefined);
46
45
  /**
47
46
  * If this is a synchronous load, load features immediately
48
47
  */
49
48
  if (!isLazyBundle(features)) {
50
- var renderer = features.renderer, loadedFeatures = __rest(features, ["renderer"]);
49
+ const { renderer } = features, loadedFeatures = __rest(features, ["renderer"]);
51
50
  loadedRenderer.current = renderer;
52
51
  loadFeatures(loadedFeatures);
53
52
  }
54
- useEffect(function () {
53
+ useEffect(() => {
55
54
  if (isLazyBundle(features)) {
56
- features().then(function (_a) {
57
- var renderer = _a.renderer, loadedFeatures = __rest(_a, ["renderer"]);
55
+ features().then((_a) => {
56
+ var { renderer } = _a, loadedFeatures = __rest(_a, ["renderer"]);
58
57
  loadFeatures(loadedFeatures);
59
58
  loadedRenderer.current = renderer;
60
59
  setIsLoaded(true);
61
60
  });
62
61
  }
63
62
  }, []);
64
- return (React.createElement(LazyContext.Provider, { value: { renderer: loadedRenderer.current, strict: strict } }, children));
63
+ return (React.createElement(LazyContext.Provider, { value: { renderer: loadedRenderer.current, strict } }, children));
65
64
  }
66
65
  function isLazyBundle(features) {
67
66
  return typeof features === "function";
@@ -1,4 +1,4 @@
1
- import { __rest, __assign } from 'tslib';
1
+ import { __rest } from 'tslib';
2
2
  import * as React from 'react';
3
3
  import { useContext, useMemo } from 'react';
4
4
  import { MotionConfigContext } from '../../context/MotionConfigContext.mjs';
@@ -23,22 +23,22 @@ import { useConstant } from '../../utils/use-constant.mjs';
23
23
  * @public
24
24
  */
25
25
  function MotionConfig(_a) {
26
- var children = _a.children, isValidProp = _a.isValidProp, config = __rest(_a, ["children", "isValidProp"]);
26
+ var { children, isValidProp } = _a, config = __rest(_a, ["children", "isValidProp"]);
27
27
  isValidProp && loadExternalIsValidProp(isValidProp);
28
28
  /**
29
29
  * Inherit props from any parent MotionConfig components
30
30
  */
31
- config = __assign(__assign({}, useContext(MotionConfigContext)), config);
31
+ config = Object.assign(Object.assign({}, useContext(MotionConfigContext)), config);
32
32
  /**
33
33
  * Don't allow isStatic to change between renders as it affects how many hooks
34
34
  * motion components fire.
35
35
  */
36
- config.isStatic = useConstant(function () { return config.isStatic; });
36
+ config.isStatic = useConstant(() => config.isStatic);
37
37
  /**
38
38
  * Creating a new config context object will re-render every `motion` component
39
39
  * every time it renders. So we only want to create a new one sparingly.
40
40
  */
41
- var context = useMemo(function () { return config; }, [JSON.stringify(config.transition), config.transformPagePoint, config.reducedMotion]);
41
+ const context = useMemo(() => config, [JSON.stringify(config.transition), config.transformPagePoint, config.reducedMotion]);
42
42
  return (React.createElement(MotionConfigContext.Provider, { value: context }, children));
43
43
  }
44
44
 
@@ -1,4 +1,4 @@
1
- import { __rest, __assign } from 'tslib';
1
+ import { __rest } from 'tslib';
2
2
  import { invariant } from 'hey-listen';
3
3
  import * as React from 'react';
4
4
  import { forwardRef, useRef, useEffect } from 'react';
@@ -8,42 +8,42 @@ import { useConstant } from '../../utils/use-constant.mjs';
8
8
  import { checkReorder } from './utils/check-reorder.mjs';
9
9
 
10
10
  function ReorderGroup(_a, externalRef) {
11
- var children = _a.children, _b = _a.as, as = _b === void 0 ? "ul" : _b, _c = _a.axis, axis = _c === void 0 ? "y" : _c, onReorder = _a.onReorder, values = _a.values, props = __rest(_a, ["children", "as", "axis", "onReorder", "values"]);
12
- var Component = useConstant(function () { return motion(as); });
13
- var order = [];
14
- var isReordering = useRef(false);
11
+ var { children, as = "ul", axis = "y", onReorder, values } = _a, props = __rest(_a, ["children", "as", "axis", "onReorder", "values"]);
12
+ const Component = useConstant(() => motion(as));
13
+ const order = [];
14
+ const isReordering = useRef(false);
15
15
  invariant(Boolean(values), "Reorder.Group must be provided a values prop");
16
- var context = {
17
- axis: axis,
18
- registerItem: function (value, layout) {
16
+ const context = {
17
+ axis,
18
+ registerItem: (value, layout) => {
19
19
  /**
20
20
  * Ensure entries can't add themselves more than once
21
21
  */
22
22
  if (layout &&
23
- order.findIndex(function (entry) { return value === entry.value; }) === -1) {
24
- order.push({ value: value, layout: layout[axis] });
23
+ order.findIndex((entry) => value === entry.value) === -1) {
24
+ order.push({ value, layout: layout[axis] });
25
25
  order.sort(compareMin);
26
26
  }
27
27
  },
28
- updateOrder: function (id, offset, velocity) {
28
+ updateOrder: (id, offset, velocity) => {
29
29
  if (isReordering.current)
30
30
  return;
31
- var newOrder = checkReorder(order, id, offset, velocity);
31
+ const newOrder = checkReorder(order, id, offset, velocity);
32
32
  if (order !== newOrder) {
33
33
  isReordering.current = true;
34
34
  onReorder(newOrder
35
35
  .map(getValue)
36
- .filter(function (value) { return values.indexOf(value) !== -1; }));
36
+ .filter((value) => values.indexOf(value) !== -1));
37
37
  }
38
38
  },
39
39
  };
40
- useEffect(function () {
40
+ useEffect(() => {
41
41
  isReordering.current = false;
42
42
  });
43
- return (React.createElement(Component, __assign({}, props, { ref: externalRef }),
43
+ return (React.createElement(Component, Object.assign({}, props, { ref: externalRef }),
44
44
  React.createElement(ReorderContext.Provider, { value: context }, children)));
45
45
  }
46
- var Group = forwardRef(ReorderGroup);
46
+ const Group = forwardRef(ReorderGroup);
47
47
  function getValue(item) {
48
48
  return item.value;
49
49
  }
@@ -1,4 +1,4 @@
1
- import { __rest, __read, __assign } from 'tslib';
1
+ import { __rest } from 'tslib';
2
2
  import { invariant } from 'hey-listen';
3
3
  import * as React from 'react';
4
4
  import { forwardRef, useContext, useRef, useEffect } from 'react';
@@ -9,37 +9,33 @@ import { useMotionValue } from '../../value/use-motion-value.mjs';
9
9
  import { useTransform } from '../../value/use-transform.mjs';
10
10
  import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
11
11
 
12
- function useDefaultMotionValue(value, defaultValue) {
13
- if (defaultValue === void 0) { defaultValue = 0; }
12
+ function useDefaultMotionValue(value, defaultValue = 0) {
14
13
  return isMotionValue(value) ? value : useMotionValue(defaultValue);
15
14
  }
16
15
  function ReorderItem(_a, externalRef) {
17
- var children = _a.children, style = _a.style, value = _a.value, _b = _a.as, as = _b === void 0 ? "li" : _b, onDrag = _a.onDrag, _c = _a.layout, layout = _c === void 0 ? true : _c, props = __rest(_a, ["children", "style", "value", "as", "onDrag", "layout"]);
18
- var Component = useConstant(function () { return motion(as); });
19
- var context = useContext(ReorderContext);
20
- var point = {
16
+ var { children, style, value, as = "li", onDrag, layout = true } = _a, props = __rest(_a, ["children", "style", "value", "as", "onDrag", "layout"]);
17
+ const Component = useConstant(() => motion(as));
18
+ const context = useContext(ReorderContext);
19
+ const point = {
21
20
  x: useDefaultMotionValue(style === null || style === void 0 ? void 0 : style.x),
22
21
  y: useDefaultMotionValue(style === null || style === void 0 ? void 0 : style.y),
23
22
  };
24
- var zIndex = useTransform([point.x, point.y], function (_a) {
25
- var _b = __read(_a, 2), latestX = _b[0], latestY = _b[1];
26
- return latestX || latestY ? 1 : "unset";
27
- });
28
- var measuredLayout = useRef(null);
23
+ const zIndex = useTransform([point.x, point.y], ([latestX, latestY]) => latestX || latestY ? 1 : "unset");
24
+ const measuredLayout = useRef(null);
29
25
  invariant(Boolean(context), "Reorder.Item must be a child of Reorder.Group");
30
- var _d = context, axis = _d.axis, registerItem = _d.registerItem, updateOrder = _d.updateOrder;
31
- useEffect(function () {
26
+ const { axis, registerItem, updateOrder } = context;
27
+ useEffect(() => {
32
28
  registerItem(value, measuredLayout.current);
33
29
  }, [context]);
34
- return (React.createElement(Component, __assign({ drag: axis }, props, { dragSnapToOrigin: true, style: __assign(__assign({}, style), { x: point.x, y: point.y, zIndex: zIndex }), layout: layout, onDrag: function (event, gesturePoint) {
35
- var velocity = gesturePoint.velocity;
30
+ return (React.createElement(Component, Object.assign({ drag: axis }, props, { dragSnapToOrigin: true, style: Object.assign(Object.assign({}, style), { x: point.x, y: point.y, zIndex }), layout: layout, onDrag: (event, gesturePoint) => {
31
+ const { velocity } = gesturePoint;
36
32
  velocity[axis] &&
37
33
  updateOrder(value, point[axis].get(), velocity[axis]);
38
34
  onDrag === null || onDrag === void 0 ? void 0 : onDrag(event, gesturePoint);
39
- }, onLayoutMeasure: function (measured) {
35
+ }, onLayoutMeasure: (measured) => {
40
36
  measuredLayout.current = measured;
41
37
  }, ref: externalRef }), children));
42
38
  }
43
- var Item = forwardRef(ReorderItem);
39
+ const Item = forwardRef(ReorderItem);
44
40
 
45
41
  export { Item, ReorderItem };
@@ -1,9 +1,9 @@
1
1
  import { Group } from './Group.mjs';
2
2
  import { Item } from './Item.mjs';
3
3
 
4
- var Reorder = {
5
- Group: Group,
6
- Item: Item,
4
+ const Reorder = {
5
+ Group,
6
+ Item,
7
7
  };
8
8
 
9
9
  export { Reorder };
@@ -4,16 +4,16 @@ import { moveItem } from '../../../utils/array.mjs';
4
4
  function checkReorder(order, value, offset, velocity) {
5
5
  if (!velocity)
6
6
  return order;
7
- var index = order.findIndex(function (item) { return item.value === value; });
7
+ const index = order.findIndex((item) => item.value === value);
8
8
  if (index === -1)
9
9
  return order;
10
- var nextOffset = velocity > 0 ? 1 : -1;
11
- var nextItem = order[index + nextOffset];
10
+ const nextOffset = velocity > 0 ? 1 : -1;
11
+ const nextItem = order[index + nextOffset];
12
12
  if (!nextItem)
13
13
  return order;
14
- var item = order[index];
15
- var nextLayout = nextItem.layout;
16
- var nextItemCenter = mix(nextLayout.min, nextLayout.max, 0.5);
14
+ const item = order[index];
15
+ const nextLayout = nextItem.layout;
16
+ const nextItemCenter = mix(nextLayout.min, nextLayout.max, 0.5);
17
17
  if ((nextOffset === 1 && item.layout.max + offset > nextItemCenter) ||
18
18
  (nextOffset === -1 && item.layout.min + offset < nextItemCenter)) {
19
19
  return moveItem(order, index, index + nextOffset);
@@ -3,6 +3,6 @@ import { createContext } from 'react';
3
3
  /**
4
4
  * @deprecated
5
5
  */
6
- var DeprecatedLayoutGroupContext = createContext(null);
6
+ const DeprecatedLayoutGroupContext = createContext(null);
7
7
 
8
8
  export { DeprecatedLayoutGroupContext };
@@ -1,5 +1,5 @@
1
1
  import { createContext } from 'react';
2
2
 
3
- var LayoutGroupContext = createContext({});
3
+ const LayoutGroupContext = createContext({});
4
4
 
5
5
  export { LayoutGroupContext };
@@ -1,5 +1,5 @@
1
1
  import { createContext } from 'react';
2
2
 
3
- var LazyContext = createContext({ strict: false });
3
+ const LazyContext = createContext({ strict: false });
4
4
 
5
5
  export { LazyContext };
@@ -3,8 +3,8 @@ import { createContext } from 'react';
3
3
  /**
4
4
  * @public
5
5
  */
6
- var MotionConfigContext = createContext({
7
- transformPagePoint: function (p) { return p; },
6
+ const MotionConfigContext = createContext({
7
+ transformPagePoint: (p) => p,
8
8
  isStatic: false,
9
9
  reducedMotion: "never",
10
10
  });
@@ -3,8 +3,8 @@ import { MotionContext } from './index.mjs';
3
3
  import { getCurrentTreeVariants } from './utils.mjs';
4
4
 
5
5
  function useCreateMotionContext(props) {
6
- var _a = getCurrentTreeVariants(props, useContext(MotionContext)), initial = _a.initial, animate = _a.animate;
7
- return useMemo(function () { return ({ initial: initial, animate: animate }); }, [variantLabelsAsDependency(initial), variantLabelsAsDependency(animate)]);
6
+ const { initial, animate } = getCurrentTreeVariants(props, useContext(MotionContext));
7
+ return useMemo(() => ({ initial, animate }), [variantLabelsAsDependency(initial), variantLabelsAsDependency(animate)]);
8
8
  }
9
9
  function variantLabelsAsDependency(prop) {
10
10
  return Array.isArray(prop) ? prop.join(" ") : prop;
@@ -1,6 +1,6 @@
1
1
  import { createContext, useContext } from 'react';
2
2
 
3
- var MotionContext = createContext({});
3
+ const MotionContext = createContext({});
4
4
  function useVisualElementContext() {
5
5
  return useContext(MotionContext).visualElement;
6
6
  }
@@ -2,7 +2,7 @@ import { checkIfControllingVariants, isVariantLabel } from '../../render/utils/v
2
2
 
3
3
  function getCurrentTreeVariants(props, context) {
4
4
  if (checkIfControllingVariants(props)) {
5
- var initial = props.initial, animate = props.animate;
5
+ const { initial, animate } = props;
6
6
  return {
7
7
  initial: initial === false || isVariantLabel(initial)
8
8
  ? initial
@@ -3,6 +3,6 @@ import { createContext } from 'react';
3
3
  /**
4
4
  * @public
5
5
  */
6
- var PresenceContext = createContext(null);
6
+ const PresenceContext = createContext(null);
7
7
 
8
8
  export { PresenceContext };
@@ -1,5 +1,5 @@
1
1
  import { createContext } from 'react';
2
2
 
3
- var ReorderContext = createContext(null);
3
+ const ReorderContext = createContext(null);
4
4
 
5
5
  export { ReorderContext };
@@ -3,6 +3,6 @@ import { createContext } from 'react';
3
3
  /**
4
4
  * Internal, exported only for usage in Framer
5
5
  */
6
- var SwitchLayoutGroupContext = createContext({});
6
+ const SwitchLayoutGroupContext = createContext({});
7
7
 
8
8
  export { SwitchLayoutGroupContext };
@@ -5,45 +5,39 @@ import { isTouchEvent } from '../gestures/utils/event-type.mjs';
5
5
  * @param eventHandler
6
6
  */
7
7
  function filterPrimaryPointer(eventHandler) {
8
- return function (event) {
9
- var isMouseEvent = event instanceof MouseEvent;
10
- var isPrimaryPointer = !isMouseEvent ||
8
+ return (event) => {
9
+ const isMouseEvent = event instanceof MouseEvent;
10
+ const isPrimaryPointer = !isMouseEvent ||
11
11
  (isMouseEvent && event.button === 0);
12
12
  if (isPrimaryPointer) {
13
13
  eventHandler(event);
14
14
  }
15
15
  };
16
16
  }
17
- var defaultPagePoint = { pageX: 0, pageY: 0 };
18
- function pointFromTouch(e, pointType) {
19
- if (pointType === void 0) { pointType = "page"; }
20
- var primaryTouch = e.touches[0] || e.changedTouches[0];
21
- var point = primaryTouch || defaultPagePoint;
17
+ const defaultPagePoint = { pageX: 0, pageY: 0 };
18
+ function pointFromTouch(e, pointType = "page") {
19
+ const primaryTouch = e.touches[0] || e.changedTouches[0];
20
+ const point = primaryTouch || defaultPagePoint;
22
21
  return {
23
22
  x: point[pointType + "X"],
24
23
  y: point[pointType + "Y"],
25
24
  };
26
25
  }
27
- function pointFromMouse(point, pointType) {
28
- if (pointType === void 0) { pointType = "page"; }
26
+ function pointFromMouse(point, pointType = "page") {
29
27
  return {
30
28
  x: point[pointType + "X"],
31
29
  y: point[pointType + "Y"],
32
30
  };
33
31
  }
34
- function extractEventInfo(event, pointType) {
35
- if (pointType === void 0) { pointType = "page"; }
32
+ function extractEventInfo(event, pointType = "page") {
36
33
  return {
37
34
  point: isTouchEvent(event)
38
35
  ? pointFromTouch(event, pointType)
39
36
  : pointFromMouse(event, pointType),
40
37
  };
41
38
  }
42
- var wrapHandler = function (handler, shouldFilterPrimaryPointer) {
43
- if (shouldFilterPrimaryPointer === void 0) { shouldFilterPrimaryPointer = false; }
44
- var listener = function (event) {
45
- return handler(event, extractEventInfo(event));
46
- };
39
+ const wrapHandler = (handler, shouldFilterPrimaryPointer = false) => {
40
+ const listener = (event) => handler(event, extractEventInfo(event));
47
41
  return shouldFilterPrimaryPointer
48
42
  ? filterPrimaryPointer(listener)
49
43
  : listener;