framer-motion 7.3.1 → 7.3.4

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
  *
@@ -337,7 +339,9 @@ function createMotionComponent({ preloadedFeatures, createVisualElement, project
337
339
  const lazyStrictMode = React.useContext(LazyContext).strict;
338
340
  const initialLayoutGroupConfig = React.useContext(SwitchLayoutGroupContext);
339
341
  if (context.visualElement) {
340
- features = context.visualElement.loadFeatures(props, lazyStrictMode, preloadedFeatures, projectionId, projectionNodeConstructor ||
342
+ features = context.visualElement.loadFeatures(
343
+ // Note: Pass the full new combined props to correctly re-render dynamic feature components.
344
+ configAndProps, lazyStrictMode, preloadedFeatures, projectionId, projectionNodeConstructor ||
341
345
  featureDefinitions.projectionNodeConstructor, initialLayoutGroupConfig);
342
346
  }
343
347
  }
@@ -349,7 +353,9 @@ function createMotionComponent({ preloadedFeatures, createVisualElement, project
349
353
  features,
350
354
  React__namespace.createElement(MotionContext.Provider, { value: context }, useRender(Component, props, projectionId, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, context.visualElement))));
351
355
  }
352
- return React.forwardRef(MotionComponent);
356
+ const ForwardRefComponent = React.forwardRef(MotionComponent);
357
+ ForwardRefComponent[motionComponentSymbol] = Component;
358
+ return ForwardRefComponent;
353
359
  }
354
360
  function useLayoutId({ layoutId }) {
355
361
  const layoutGroupId = React.useContext(LayoutGroupContext).id;
@@ -2236,7 +2242,7 @@ class MotionValue {
2236
2242
  * This will be replaced by the build step with the latest version number.
2237
2243
  * When MotionValues are provided to motion components, warn if versions are mixed.
2238
2244
  */
2239
- this.version = "7.3.1";
2245
+ this.version = "7.3.4";
2240
2246
  /**
2241
2247
  * Duration, in milliseconds, since last updating frame.
2242
2248
  *
@@ -4212,7 +4218,7 @@ function updateMotionValuesFromProps(element, next, prev) {
4212
4218
  * and warn against mismatches.
4213
4219
  */
4214
4220
  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.`);
4221
+ warnOnce(nextValue.version === "7.3.4", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.3.4 may not work as expected.`);
4216
4222
  }
4217
4223
  }
4218
4224
  else if (isMotionValue(prevValue)) {
@@ -4457,7 +4463,7 @@ const visualElement = ({ treeType = "", build, getBaseTarget, makeTargetAnimatab
4457
4463
  * dynamically request functionality. In initial tests this
4458
4464
  * was producing a lot of duplication amongst bundles.
4459
4465
  */
4460
- if (isEnabled(props) && Component) {
4466
+ if (isEnabled(renderedProps) && Component) {
4461
4467
  features.push(React.createElement(Component, {
4462
4468
  key: name,
4463
4469
  ...renderedProps,
@@ -8199,6 +8205,28 @@ function useDragControls() {
8199
8205
  return useConstant(createDragControls);
8200
8206
  }
8201
8207
 
8208
+ /**
8209
+ * Checks if a component is a `motion` component.
8210
+ */
8211
+ function isMotionComponent(component) {
8212
+ return (component !== null &&
8213
+ typeof component === "object" &&
8214
+ motionComponentSymbol in component);
8215
+ }
8216
+
8217
+ /**
8218
+ * Unwraps a `motion` component and returns either a string for `motion.div` or
8219
+ * the React component for `motion(Component)`.
8220
+ *
8221
+ * If the component is not a `motion` component it returns undefined.
8222
+ */
8223
+ function unwrapMotionComponent(component) {
8224
+ if (isMotionComponent(component)) {
8225
+ return component[motionComponentSymbol];
8226
+ }
8227
+ return undefined;
8228
+ }
8229
+
8202
8230
  function useInstantLayoutTransition() {
8203
8231
  return startTransition;
8204
8232
  }
@@ -8361,6 +8389,7 @@ exports.domMax = domMax;
8361
8389
  exports.filterProps = filterProps;
8362
8390
  exports.isBrowser = isBrowser;
8363
8391
  exports.isDragActive = isDragActive;
8392
+ exports.isMotionComponent = isMotionComponent;
8364
8393
  exports.isMotionValue = isMotionValue;
8365
8394
  exports.isValidMotionProp = isValidMotionProp;
8366
8395
  exports.m = m;
@@ -8369,6 +8398,7 @@ exports.motion = motion;
8369
8398
  exports.motionValue = motionValue;
8370
8399
  exports.resolveMotionValue = resolveMotionValue;
8371
8400
  exports.transform = transform;
8401
+ exports.unwrapMotionComponent = unwrapMotionComponent;
8372
8402
  exports.useAnimation = useAnimation;
8373
8403
  exports.useAnimationControls = useAnimationControls;
8374
8404
  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.
@@ -65,7 +66,9 @@ function createMotionComponent({ preloadedFeatures, createVisualElement, project
65
66
  const lazyStrictMode = useContext(LazyContext).strict;
66
67
  const initialLayoutGroupConfig = useContext(SwitchLayoutGroupContext);
67
68
  if (context.visualElement) {
68
- features = context.visualElement.loadFeatures(props, lazyStrictMode, preloadedFeatures, projectionId, projectionNodeConstructor ||
69
+ features = context.visualElement.loadFeatures(
70
+ // Note: Pass the full new combined props to correctly re-render dynamic feature components.
71
+ configAndProps, lazyStrictMode, preloadedFeatures, projectionId, projectionNodeConstructor ||
69
72
  featureDefinitions.projectionNodeConstructor, initialLayoutGroupConfig);
70
73
  }
71
74
  }
@@ -77,7 +80,9 @@ function createMotionComponent({ preloadedFeatures, createVisualElement, project
77
80
  features,
78
81
  React.createElement(MotionContext.Provider, { value: context }, useRender(Component, props, projectionId, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, context.visualElement))));
79
82
  }
80
- return forwardRef(MotionComponent);
83
+ const ForwardRefComponent = forwardRef(MotionComponent);
84
+ ForwardRefComponent[motionComponentSymbol] = Component;
85
+ return ForwardRefComponent;
81
86
  }
82
87
  function useLayoutId({ layoutId }) {
83
88
  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 };
@@ -222,7 +222,7 @@ const visualElement = ({ treeType = "", build, getBaseTarget, makeTargetAnimatab
222
222
  * dynamically request functionality. In initial tests this
223
223
  * was producing a lot of duplication amongst bundles.
224
224
  */
225
- if (isEnabled(props) && Component) {
225
+ if (isEnabled(renderedProps) && Component) {
226
226
  features.push(createElement(Component, {
227
227
  key: name,
228
228
  ...renderedProps,
@@ -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.4", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.3.4 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.4";
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
  *
@@ -331,7 +333,9 @@
331
333
  const lazyStrictMode = React.useContext(LazyContext).strict;
332
334
  const initialLayoutGroupConfig = React.useContext(SwitchLayoutGroupContext);
333
335
  if (context.visualElement) {
334
- features = context.visualElement.loadFeatures(props, lazyStrictMode, preloadedFeatures, projectionId, projectionNodeConstructor ||
336
+ features = context.visualElement.loadFeatures(
337
+ // Note: Pass the full new combined props to correctly re-render dynamic feature components.
338
+ configAndProps, lazyStrictMode, preloadedFeatures, projectionId, projectionNodeConstructor ||
335
339
  featureDefinitions.projectionNodeConstructor, initialLayoutGroupConfig);
336
340
  }
337
341
  }
@@ -343,7 +347,9 @@
343
347
  features,
344
348
  React__namespace.createElement(MotionContext.Provider, { value: context }, useRender(Component, props, projectionId, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, context.visualElement))));
345
349
  }
346
- return React.forwardRef(MotionComponent);
350
+ const ForwardRefComponent = React.forwardRef(MotionComponent);
351
+ ForwardRefComponent[motionComponentSymbol] = Component;
352
+ return ForwardRefComponent;
347
353
  }
348
354
  function useLayoutId({ layoutId }) {
349
355
  const layoutGroupId = React.useContext(LayoutGroupContext).id;
@@ -3404,7 +3410,7 @@
3404
3410
  * This will be replaced by the build step with the latest version number.
3405
3411
  * When MotionValues are provided to motion components, warn if versions are mixed.
3406
3412
  */
3407
- this.version = "7.3.1";
3413
+ this.version = "7.3.4";
3408
3414
  /**
3409
3415
  * Duration, in milliseconds, since last updating frame.
3410
3416
  *
@@ -5380,7 +5386,7 @@
5380
5386
  * and warn against mismatches.
5381
5387
  */
5382
5388
  {
5383
- warnOnce(nextValue.version === "7.3.1", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.3.1 may not work as expected.`);
5389
+ warnOnce(nextValue.version === "7.3.4", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.3.4 may not work as expected.`);
5384
5390
  }
5385
5391
  }
5386
5392
  else if (isMotionValue(prevValue)) {
@@ -5625,7 +5631,7 @@
5625
5631
  * dynamically request functionality. In initial tests this
5626
5632
  * was producing a lot of duplication amongst bundles.
5627
5633
  */
5628
- if (isEnabled(props) && Component) {
5634
+ if (isEnabled(renderedProps) && Component) {
5629
5635
  features.push(React.createElement(Component, {
5630
5636
  key: name,
5631
5637
  ...renderedProps,
@@ -9948,6 +9954,28 @@
9948
9954
  return useConstant(createDragControls);
9949
9955
  }
9950
9956
 
9957
+ /**
9958
+ * Checks if a component is a `motion` component.
9959
+ */
9960
+ function isMotionComponent(component) {
9961
+ return (component !== null &&
9962
+ typeof component === "object" &&
9963
+ motionComponentSymbol in component);
9964
+ }
9965
+
9966
+ /**
9967
+ * Unwraps a `motion` component and returns either a string for `motion.div` or
9968
+ * the React component for `motion(Component)`.
9969
+ *
9970
+ * If the component is not a `motion` component it returns undefined.
9971
+ */
9972
+ function unwrapMotionComponent(component) {
9973
+ if (isMotionComponent(component)) {
9974
+ return component[motionComponentSymbol];
9975
+ }
9976
+ return undefined;
9977
+ }
9978
+
9951
9979
  function useInstantLayoutTransition() {
9952
9980
  return startTransition;
9953
9981
  }
@@ -10110,6 +10138,7 @@
10110
10138
  exports.filterProps = filterProps;
10111
10139
  exports.isBrowser = isBrowser;
10112
10140
  exports.isDragActive = isDragActive;
10141
+ exports.isMotionComponent = isMotionComponent;
10113
10142
  exports.isMotionValue = isMotionValue;
10114
10143
  exports.isValidMotionProp = isValidMotionProp;
10115
10144
  exports.m = m;
@@ -10118,6 +10147,7 @@
10118
10147
  exports.motionValue = motionValue;
10119
10148
  exports.resolveMotionValue = resolveMotionValue;
10120
10149
  exports.transform = transform;
10150
+ exports.unwrapMotionComponent = unwrapMotionComponent;
10121
10151
  exports.useAnimation = useAnimation;
10122
10152
  exports.useAnimationControls = useAnimationControls;
10123
10153
  exports.useAnimationFrame = useAnimationFrame;