framer-motion 6.2.6 → 6.2.9-alpha

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
@@ -33,6 +33,14 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
33
33
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
34
34
  var sync__default = /*#__PURE__*/_interopDefaultLegacy(sync);
35
35
 
36
+ /**
37
+ * Browser-safe usage of process
38
+ */
39
+ var mockProcess = { env: { NODE_ENV: "production" } };
40
+ var safeProcess = typeof process === "undefined" ? mockProcess : process;
41
+ // eslint-disable-next-line import/no-default-export
42
+ var process$1 = safeProcess;
43
+
36
44
  var createDefinition = function (propNames) { return ({
37
45
  isEnabled: function (props) { return propNames.some(function (name) { return !!props[name]; }); },
38
46
  }); };
@@ -94,7 +102,7 @@ function useFeatures(props, visualElement, preloadedFeatures) {
94
102
  * If we're in development mode, check to make sure we're not rendering a motion component
95
103
  * as a child of LazyMotion, as this will break the file-size benefits of using it.
96
104
  */
97
- if (process.env.NODE_ENV !== "production" &&
105
+ if (process$1.env.NODE_ENV !== "production" &&
98
106
  preloadedFeatures &&
99
107
  lazyContext.strict) {
100
108
  heyListen.invariant(false, "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.");
@@ -4316,7 +4324,7 @@ function useMissingIntersectionObserver(shouldObserve, state, visualElement, _a)
4316
4324
  React.useEffect(function () {
4317
4325
  if (!shouldObserve || !fallback)
4318
4326
  return;
4319
- if (process.env.NODE_ENV !== "production") {
4327
+ if (process$1.env.NODE_ENV !== "production") {
4320
4328
  warnOnce(false, "IntersectionObserver not available on this device. whileInView animations will trigger on mount.");
4321
4329
  }
4322
4330
  /**
@@ -5014,7 +5022,11 @@ function createAnimationState(visualElement) {
5014
5022
  // Propagate active change to children
5015
5023
  (_a = visualElement.variantChildren) === null || _a === void 0 ? void 0 : _a.forEach(function (child) { var _a; return (_a = child.animationState) === null || _a === void 0 ? void 0 : _a.setActive(type, isActive); });
5016
5024
  state[type].isActive = isActive;
5017
- return animateChanges(options, type);
5025
+ var animations = animateChanges(options, type);
5026
+ for (var key in state) {
5027
+ state[key].protectedKeys = {};
5028
+ }
5029
+ return animations;
5018
5030
  }
5019
5031
  return {
5020
5032
  isAnimated: isAnimated,
@@ -7110,7 +7122,7 @@ var m = createMotionProxy(createDomMotionConfig);
7110
7122
 
7111
7123
  function useIsMounted() {
7112
7124
  var isMounted = React.useRef(false);
7113
- React.useLayoutEffect(function () {
7125
+ useIsomorphicLayoutEffect(function () {
7114
7126
  isMounted.current = true;
7115
7127
  return function () {
7116
7128
  isMounted.current = false;
@@ -7189,7 +7201,7 @@ function newChildrenMap() {
7189
7201
  }
7190
7202
 
7191
7203
  var getChildKey = function (child) { return child.key || ""; };
7192
- var isDev = process.env.NODE_ENV !== "production";
7204
+ var isDev = process$1.env.NODE_ENV !== "production";
7193
7205
  function updateChildLookup(children, allChildren) {
7194
7206
  var seenChildren = isDev ? new Set() : null;
7195
7207
  children.forEach(function (child) {
@@ -7329,7 +7341,7 @@ var AnimatePresence = function (_a) {
7329
7341
  var key = child.key;
7330
7342
  return exiting.has(key) ? (child) : (React__namespace.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, presenceAffectsLayout: presenceAffectsLayout }, child));
7331
7343
  });
7332
- if (process.env.NODE_ENV !== "production" &&
7344
+ if (process$1.env.NODE_ENV !== "production" &&
7333
7345
  exitBeforeEnter &&
7334
7346
  childrenToRender.length > 1) {
7335
7347
  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.");
@@ -7368,21 +7380,28 @@ function nodeGroup() {
7368
7380
  };
7369
7381
  }
7370
7382
 
7383
+ var shouldInheritGroup = function (inherit) { return inherit === true; };
7384
+ var shouldInheritId = function (inherit) {
7385
+ return shouldInheritGroup(inherit === true) || inherit === "id";
7386
+ };
7371
7387
  var LayoutGroup = function (_a) {
7372
7388
  var _b, _c;
7373
- var children = _a.children, id = _a.id, _d = _a.inheritId, inheritId = _d === void 0 ? true : _d;
7389
+ var children = _a.children, id = _a.id, inheritId = _a.inheritId, _d = _a.inherit, inherit = _d === void 0 ? true : _d;
7390
+ // Maintain backwards-compatibility with inheritId until 7.0
7391
+ if (inheritId !== undefined)
7392
+ inherit = inheritId;
7374
7393
  var layoutGroupContext = React.useContext(LayoutGroupContext);
7375
7394
  var deprecatedLayoutGroupContext = React.useContext(DeprecatedLayoutGroupContext);
7376
7395
  var _e = tslib.__read(useForceUpdate(), 2), forceRender = _e[0], key = _e[1];
7377
7396
  var context = React.useRef(null);
7378
7397
  var upstreamId = (_b = layoutGroupContext.id) !== null && _b !== void 0 ? _b : deprecatedLayoutGroupContext;
7379
7398
  if (context.current === null) {
7380
- if (inheritId && upstreamId) {
7399
+ if (shouldInheritId(inherit) && upstreamId) {
7381
7400
  id = id ? upstreamId + "-" + id : upstreamId;
7382
7401
  }
7383
7402
  context.current = {
7384
7403
  id: id,
7385
- group: inheritId
7404
+ group: shouldInheritGroup(inherit)
7386
7405
  ? (_c = layoutGroupContext === null || layoutGroupContext === void 0 ? void 0 : layoutGroupContext.group) !== null && _c !== void 0 ? _c : nodeGroup()
7387
7406
  : nodeGroup(),
7388
7407
  };
@@ -1,6 +1,7 @@
1
1
  import { __read, __spreadArray } from 'tslib';
2
2
  import * as React from 'react';
3
3
  import { useContext, useRef, cloneElement, Children, isValidElement } from 'react';
4
+ import process from '../../utils/process.mjs';
4
5
  import { useForceUpdate } from '../../utils/use-force-update.mjs';
5
6
  import { useIsMounted } from '../../utils/use-is-mounted.mjs';
6
7
  import { PresenceChild } from './PresenceChild.mjs';
@@ -6,21 +6,28 @@ import { DeprecatedLayoutGroupContext } from '../../context/DeprecatedLayoutGrou
6
6
  import { useForceUpdate } from '../../utils/use-force-update.mjs';
7
7
  import { nodeGroup } from '../../projection/node/group.mjs';
8
8
 
9
+ var shouldInheritGroup = function (inherit) { return inherit === true; };
10
+ var shouldInheritId = function (inherit) {
11
+ return shouldInheritGroup(inherit === true) || inherit === "id";
12
+ };
9
13
  var LayoutGroup = function (_a) {
10
14
  var _b, _c;
11
- var children = _a.children, id = _a.id, _d = _a.inheritId, inheritId = _d === void 0 ? true : _d;
15
+ var children = _a.children, id = _a.id, inheritId = _a.inheritId, _d = _a.inherit, inherit = _d === void 0 ? true : _d;
16
+ // Maintain backwards-compatibility with inheritId until 7.0
17
+ if (inheritId !== undefined)
18
+ inherit = inheritId;
12
19
  var layoutGroupContext = useContext(LayoutGroupContext);
13
20
  var deprecatedLayoutGroupContext = useContext(DeprecatedLayoutGroupContext);
14
21
  var _e = __read(useForceUpdate(), 2), forceRender = _e[0], key = _e[1];
15
22
  var context = useRef(null);
16
23
  var upstreamId = (_b = layoutGroupContext.id) !== null && _b !== void 0 ? _b : deprecatedLayoutGroupContext;
17
24
  if (context.current === null) {
18
- if (inheritId && upstreamId) {
25
+ if (shouldInheritId(inherit) && upstreamId) {
19
26
  id = id ? upstreamId + "-" + id : upstreamId;
20
27
  }
21
28
  context.current = {
22
29
  id: id,
23
- group: inheritId
30
+ group: shouldInheritGroup(inherit)
24
31
  ? (_c = layoutGroupContext === null || layoutGroupContext === void 0 ? void 0 : layoutGroupContext.group) !== null && _c !== void 0 ? _c : nodeGroup()
25
32
  : nodeGroup(),
26
33
  };
@@ -1,6 +1,7 @@
1
1
  import { __assign } from 'tslib';
2
2
  import * as React from 'react';
3
3
  import { useContext } from 'react';
4
+ import process from '../../utils/process.mjs';
4
5
  import { featureDefinitions } from './definitions.mjs';
5
6
  import { invariant } from 'hey-listen';
6
7
  import { LazyContext } from '../../context/LazyContext.mjs';
@@ -1,3 +1,4 @@
1
+ import process from '../../../utils/process.mjs';
1
2
  import { useRef, useEffect } from 'react';
2
3
  import { AnimationType } from '../../../render/utils/types.mjs';
3
4
  import { warnOnce } from '../../../utils/warn-once.mjs';
@@ -294,7 +294,11 @@ function createAnimationState(visualElement) {
294
294
  // Propagate active change to children
295
295
  (_a = visualElement.variantChildren) === null || _a === void 0 ? void 0 : _a.forEach(function (child) { var _a; return (_a = child.animationState) === null || _a === void 0 ? void 0 : _a.setActive(type, isActive); });
296
296
  state[type].isActive = isActive;
297
- return animateChanges(options, type);
297
+ var animations = animateChanges(options, type);
298
+ for (var key in state) {
299
+ state[key].protectedKeys = {};
300
+ }
301
+ return animations;
298
302
  }
299
303
  return {
300
304
  isAnimated: isAnimated,
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Browser-safe usage of process
3
+ */
4
+ var mockProcess = { env: { NODE_ENV: "production" } };
5
+ var safeProcess = typeof process === "undefined" ? mockProcess : process;
6
+ // eslint-disable-next-line import/no-default-export
7
+ var process$1 = safeProcess;
8
+
9
+ export { process$1 as default };
@@ -1,8 +1,9 @@
1
- import { useRef, useLayoutEffect } from 'react';
1
+ import { useRef } from 'react';
2
+ import { useIsomorphicLayoutEffect } from './use-isomorphic-effect.mjs';
2
3
 
3
4
  function useIsMounted() {
4
5
  var isMounted = useRef(false);
5
- useLayoutEffect(function () {
6
+ useIsomorphicLayoutEffect(function () {
6
7
  isMounted.current = true;
7
8
  return function () {
8
9
  isMounted.current = false;
@@ -6247,7 +6247,11 @@
6247
6247
  // Propagate active change to children
6248
6248
  (_a = visualElement.variantChildren) === null || _a === void 0 ? void 0 : _a.forEach(function (child) { var _a; return (_a = child.animationState) === null || _a === void 0 ? void 0 : _a.setActive(type, isActive); });
6249
6249
  state[type].isActive = isActive;
6250
- return animateChanges(options, type);
6250
+ var animations = animateChanges(options, type);
6251
+ for (var key in state) {
6252
+ state[key].protectedKeys = {};
6253
+ }
6254
+ return animations;
6251
6255
  }
6252
6256
  return {
6253
6257
  isAnimated: isAnimated,
@@ -8343,7 +8347,7 @@
8343
8347
 
8344
8348
  function useIsMounted() {
8345
8349
  var isMounted = React.useRef(false);
8346
- React.useLayoutEffect(function () {
8350
+ useIsomorphicLayoutEffect(function () {
8347
8351
  isMounted.current = true;
8348
8352
  return function () {
8349
8353
  isMounted.current = false;
@@ -8599,21 +8603,28 @@
8599
8603
  };
8600
8604
  }
8601
8605
 
8606
+ var shouldInheritGroup = function (inherit) { return inherit === true; };
8607
+ var shouldInheritId = function (inherit) {
8608
+ return shouldInheritGroup(inherit === true) || inherit === "id";
8609
+ };
8602
8610
  var LayoutGroup = function (_a) {
8603
8611
  var _b, _c;
8604
- var children = _a.children, id = _a.id, _d = _a.inheritId, inheritId = _d === void 0 ? true : _d;
8612
+ var children = _a.children, id = _a.id, inheritId = _a.inheritId, _d = _a.inherit, inherit = _d === void 0 ? true : _d;
8613
+ // Maintain backwards-compatibility with inheritId until 7.0
8614
+ if (inheritId !== undefined)
8615
+ inherit = inheritId;
8605
8616
  var layoutGroupContext = React.useContext(LayoutGroupContext);
8606
8617
  var deprecatedLayoutGroupContext = React.useContext(DeprecatedLayoutGroupContext);
8607
8618
  var _e = __read(useForceUpdate(), 2), forceRender = _e[0], key = _e[1];
8608
8619
  var context = React.useRef(null);
8609
8620
  var upstreamId = (_b = layoutGroupContext.id) !== null && _b !== void 0 ? _b : deprecatedLayoutGroupContext;
8610
8621
  if (context.current === null) {
8611
- if (inheritId && upstreamId) {
8622
+ if (shouldInheritId(inherit) && upstreamId) {
8612
8623
  id = id ? upstreamId + "-" + id : upstreamId;
8613
8624
  }
8614
8625
  context.current = {
8615
8626
  id: id,
8616
- group: inheritId
8627
+ group: shouldInheritGroup(inherit)
8617
8628
  ? (_c = layoutGroupContext === null || layoutGroupContext === void 0 ? void 0 : layoutGroupContext.group) !== null && _c !== void 0 ? _c : nodeGroup()
8618
8629
  : nodeGroup(),
8619
8630
  };