framer-motion 7.3.1 → 7.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -286,6 +286,8 @@ class VisualElementHandler extends React__default["default"].Component {
286
286
  */
287
287
  const SwitchLayoutGroupContext = React.createContext({});
288
288
 
289
+ const motionComponentSymbol = Symbol.for("motionComponentSymbol");
290
+
289
291
  /**
290
292
  * Create a `motion` component.
291
293
  *
@@ -349,7 +351,9 @@ function createMotionComponent({ preloadedFeatures, createVisualElement, project
349
351
  features,
350
352
  React__namespace.createElement(MotionContext.Provider, { value: context }, useRender(Component, props, projectionId, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, context.visualElement))));
351
353
  }
352
- return React.forwardRef(MotionComponent);
354
+ const ForwardRefComponent = React.forwardRef(MotionComponent);
355
+ ForwardRefComponent[motionComponentSymbol] = Component;
356
+ return ForwardRefComponent;
353
357
  }
354
358
  function useLayoutId({ layoutId }) {
355
359
  const layoutGroupId = React.useContext(LayoutGroupContext).id;
@@ -2236,7 +2240,7 @@ class MotionValue {
2236
2240
  * This will be replaced by the build step with the latest version number.
2237
2241
  * When MotionValues are provided to motion components, warn if versions are mixed.
2238
2242
  */
2239
- this.version = "7.3.1";
2243
+ this.version = "7.3.2";
2240
2244
  /**
2241
2245
  * Duration, in milliseconds, since last updating frame.
2242
2246
  *
@@ -4212,7 +4216,7 @@ function updateMotionValuesFromProps(element, next, prev) {
4212
4216
  * and warn against mismatches.
4213
4217
  */
4214
4218
  if (process.env.NODE_ENV === "development") {
4215
- warnOnce(nextValue.version === "7.3.1", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.3.1 may not work as expected.`);
4219
+ warnOnce(nextValue.version === "7.3.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.3.2 may not work as expected.`);
4216
4220
  }
4217
4221
  }
4218
4222
  else if (isMotionValue(prevValue)) {
@@ -8199,6 +8203,28 @@ function useDragControls() {
8199
8203
  return useConstant(createDragControls);
8200
8204
  }
8201
8205
 
8206
+ /**
8207
+ * Checks if a component is a `motion` component.
8208
+ */
8209
+ function isMotionComponent(component) {
8210
+ return (component !== null &&
8211
+ typeof component === "object" &&
8212
+ motionComponentSymbol in component);
8213
+ }
8214
+
8215
+ /**
8216
+ * Unwraps a `motion` component and returns either a string for `motion.div` or
8217
+ * the React component for `motion(Component)`.
8218
+ *
8219
+ * If the component is not a `motion` component it returns undefined.
8220
+ */
8221
+ function unwrapMotionComponent(component) {
8222
+ if (isMotionComponent(component)) {
8223
+ return component[motionComponentSymbol];
8224
+ }
8225
+ return undefined;
8226
+ }
8227
+
8202
8228
  function useInstantLayoutTransition() {
8203
8229
  return startTransition;
8204
8230
  }
@@ -8361,6 +8387,7 @@ exports.domMax = domMax;
8361
8387
  exports.filterProps = filterProps;
8362
8388
  exports.isBrowser = isBrowser;
8363
8389
  exports.isDragActive = isDragActive;
8390
+ exports.isMotionComponent = isMotionComponent;
8364
8391
  exports.isMotionValue = isMotionValue;
8365
8392
  exports.isValidMotionProp = isValidMotionProp;
8366
8393
  exports.m = m;
@@ -8369,6 +8396,7 @@ exports.motion = motion;
8369
8396
  exports.motionValue = motionValue;
8370
8397
  exports.resolveMotionValue = resolveMotionValue;
8371
8398
  exports.transform = transform;
8399
+ exports.unwrapMotionComponent = unwrapMotionComponent;
8372
8400
  exports.useAnimation = useAnimation;
8373
8401
  exports.useAnimationControls = useAnimationControls;
8374
8402
  exports.useAnimationFrame = useAnimationFrame;
package/dist/es/index.mjs CHANGED
@@ -35,6 +35,8 @@ export { useInView } from './utils/use-in-view.mjs';
35
35
  export { DragControls, useDragControls } from './gestures/drag/use-drag-controls.mjs';
36
36
  export { useDomEvent } from './events/use-dom-event.mjs';
37
37
  export { createMotionComponent } from './motion/index.mjs';
38
+ export { isMotionComponent } from './motion/utils/is-motion-component.mjs';
39
+ export { unwrapMotionComponent } from './motion/utils/unwrap-motion-component.mjs';
38
40
  export { visualElement } from './render/index.mjs';
39
41
  export { addScaleCorrector } from './projection/styles/scale-correction.mjs';
40
42
  export { useInstantTransition } from './utils/use-instant-transition.mjs';
@@ -13,6 +13,7 @@ import { LayoutGroupContext } from '../context/LayoutGroupContext.mjs';
13
13
  import { VisualElementHandler } from './utils/VisualElementHandler.mjs';
14
14
  import { LazyContext } from '../context/LazyContext.mjs';
15
15
  import { SwitchLayoutGroupContext } from '../context/SwitchLayoutGroupContext.mjs';
16
+ import { motionComponentSymbol } from './utils/symbol.mjs';
16
17
 
17
18
  /**
18
19
  * Create a `motion` component.
@@ -77,7 +78,9 @@ function createMotionComponent({ preloadedFeatures, createVisualElement, project
77
78
  features,
78
79
  React.createElement(MotionContext.Provider, { value: context }, useRender(Component, props, projectionId, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, context.visualElement))));
79
80
  }
80
- return forwardRef(MotionComponent);
81
+ const ForwardRefComponent = forwardRef(MotionComponent);
82
+ ForwardRefComponent[motionComponentSymbol] = Component;
83
+ return ForwardRefComponent;
81
84
  }
82
85
  function useLayoutId({ layoutId }) {
83
86
  const layoutGroupId = useContext(LayoutGroupContext).id;
@@ -0,0 +1,12 @@
1
+ import { motionComponentSymbol } from './symbol.mjs';
2
+
3
+ /**
4
+ * Checks if a component is a `motion` component.
5
+ */
6
+ function isMotionComponent(component) {
7
+ return (component !== null &&
8
+ typeof component === "object" &&
9
+ motionComponentSymbol in component);
10
+ }
11
+
12
+ export { isMotionComponent };
@@ -0,0 +1,3 @@
1
+ const motionComponentSymbol = Symbol.for("motionComponentSymbol");
2
+
3
+ export { motionComponentSymbol };
@@ -0,0 +1,17 @@
1
+ import { isMotionComponent } from './is-motion-component.mjs';
2
+ import { motionComponentSymbol } from './symbol.mjs';
3
+
4
+ /**
5
+ * Unwraps a `motion` component and returns either a string for `motion.div` or
6
+ * the React component for `motion(Component)`.
7
+ *
8
+ * If the component is not a `motion` component it returns undefined.
9
+ */
10
+ function unwrapMotionComponent(component) {
11
+ if (isMotionComponent(component)) {
12
+ return component[motionComponentSymbol];
13
+ }
14
+ return undefined;
15
+ }
16
+
17
+ export { unwrapMotionComponent };
@@ -22,7 +22,7 @@ function updateMotionValuesFromProps(element, next, prev) {
22
22
  * and warn against mismatches.
23
23
  */
24
24
  if (process.env.NODE_ENV === "development") {
25
- warnOnce(nextValue.version === "7.3.1", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.3.1 may not work as expected.`);
25
+ warnOnce(nextValue.version === "7.3.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.3.2 may not work as expected.`);
26
26
  }
27
27
  }
28
28
  else if (isMotionValue(prevValue)) {
@@ -24,7 +24,7 @@ class MotionValue {
24
24
  * This will be replaced by the build step with the latest version number.
25
25
  * When MotionValues are provided to motion components, warn if versions are mixed.
26
26
  */
27
- this.version = "7.3.1";
27
+ this.version = "7.3.2";
28
28
  /**
29
29
  * Duration, in milliseconds, since last updating frame.
30
30
  *
@@ -280,6 +280,8 @@
280
280
  */
281
281
  const SwitchLayoutGroupContext = React.createContext({});
282
282
 
283
+ const motionComponentSymbol = Symbol.for("motionComponentSymbol");
284
+
283
285
  /**
284
286
  * Create a `motion` component.
285
287
  *
@@ -343,7 +345,9 @@
343
345
  features,
344
346
  React__namespace.createElement(MotionContext.Provider, { value: context }, useRender(Component, props, projectionId, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, context.visualElement))));
345
347
  }
346
- return React.forwardRef(MotionComponent);
348
+ const ForwardRefComponent = React.forwardRef(MotionComponent);
349
+ ForwardRefComponent[motionComponentSymbol] = Component;
350
+ return ForwardRefComponent;
347
351
  }
348
352
  function useLayoutId({ layoutId }) {
349
353
  const layoutGroupId = React.useContext(LayoutGroupContext).id;
@@ -3404,7 +3408,7 @@
3404
3408
  * This will be replaced by the build step with the latest version number.
3405
3409
  * When MotionValues are provided to motion components, warn if versions are mixed.
3406
3410
  */
3407
- this.version = "7.3.1";
3411
+ this.version = "7.3.2";
3408
3412
  /**
3409
3413
  * Duration, in milliseconds, since last updating frame.
3410
3414
  *
@@ -5380,7 +5384,7 @@
5380
5384
  * and warn against mismatches.
5381
5385
  */
5382
5386
  {
5383
- warnOnce(nextValue.version === "7.3.1", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.3.1 may not work as expected.`);
5387
+ warnOnce(nextValue.version === "7.3.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.3.2 may not work as expected.`);
5384
5388
  }
5385
5389
  }
5386
5390
  else if (isMotionValue(prevValue)) {
@@ -9948,6 +9952,28 @@
9948
9952
  return useConstant(createDragControls);
9949
9953
  }
9950
9954
 
9955
+ /**
9956
+ * Checks if a component is a `motion` component.
9957
+ */
9958
+ function isMotionComponent(component) {
9959
+ return (component !== null &&
9960
+ typeof component === "object" &&
9961
+ motionComponentSymbol in component);
9962
+ }
9963
+
9964
+ /**
9965
+ * Unwraps a `motion` component and returns either a string for `motion.div` or
9966
+ * the React component for `motion(Component)`.
9967
+ *
9968
+ * If the component is not a `motion` component it returns undefined.
9969
+ */
9970
+ function unwrapMotionComponent(component) {
9971
+ if (isMotionComponent(component)) {
9972
+ return component[motionComponentSymbol];
9973
+ }
9974
+ return undefined;
9975
+ }
9976
+
9951
9977
  function useInstantLayoutTransition() {
9952
9978
  return startTransition;
9953
9979
  }
@@ -10110,6 +10136,7 @@
10110
10136
  exports.filterProps = filterProps;
10111
10137
  exports.isBrowser = isBrowser;
10112
10138
  exports.isDragActive = isDragActive;
10139
+ exports.isMotionComponent = isMotionComponent;
10113
10140
  exports.isMotionValue = isMotionValue;
10114
10141
  exports.isValidMotionProp = isValidMotionProp;
10115
10142
  exports.m = m;
@@ -10118,6 +10145,7 @@
10118
10145
  exports.motionValue = motionValue;
10119
10146
  exports.resolveMotionValue = resolveMotionValue;
10120
10147
  exports.transform = transform;
10148
+ exports.unwrapMotionComponent = unwrapMotionComponent;
10121
10149
  exports.useAnimation = useAnimation;
10122
10150
  exports.useAnimationControls = useAnimationControls;
10123
10151
  exports.useAnimationFrame = useAnimationFrame;