motion 11.15.0 → 11.16.1

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 (67) hide show
  1. package/README.md +3 -19
  2. package/dist/cjs/index.js +1677 -1645
  3. package/dist/cjs/mini.js +215 -185
  4. package/dist/cjs/react-client.js +3814 -3796
  5. package/dist/cjs/react-m.js +156 -152
  6. package/dist/cjs/react-mini.js +215 -185
  7. package/dist/es/framer-motion/dist/es/animation/animate/index.mjs +2 -1
  8. package/dist/es/framer-motion/dist/es/animation/animate/resolve-subjects.mjs +1 -0
  9. package/dist/es/framer-motion/dist/es/animation/animate/single-value.mjs +1 -1
  10. package/dist/es/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +7 -7
  11. package/dist/es/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +8 -8
  12. package/dist/es/framer-motion/dist/es/animation/animators/utils/can-animate.mjs +1 -1
  13. package/dist/es/framer-motion/dist/es/animation/animators/waapi/NativeAnimation.mjs +26 -89
  14. package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +3 -3
  15. package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-style.mjs +2 -1
  16. package/dist/es/framer-motion/dist/es/animation/animators/waapi/index.mjs +2 -1
  17. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs +2 -1
  18. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +2 -1
  19. package/dist/es/framer-motion/dist/es/animation/generators/spring/find.mjs +1 -1
  20. package/dist/es/framer-motion/dist/es/animation/generators/spring/index.mjs +9 -6
  21. package/dist/es/framer-motion/dist/es/animation/interfaces/motion-value.mjs +7 -6
  22. package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +4 -3
  23. package/dist/es/framer-motion/dist/es/animation/sequence/create.mjs +8 -8
  24. package/dist/es/framer-motion/dist/es/easing/utils/map.mjs +4 -4
  25. package/dist/es/framer-motion/dist/es/events/event-info.mjs +1 -0
  26. package/dist/es/framer-motion/dist/es/gestures/drag/utils/constraints.mjs +2 -1
  27. package/dist/es/framer-motion/dist/es/gestures/hover.mjs +1 -0
  28. package/dist/es/framer-motion/dist/es/gestures/pan/PanSession.mjs +5 -4
  29. package/dist/es/framer-motion/dist/es/gestures/press.mjs +1 -0
  30. package/dist/es/framer-motion/dist/es/motion/index.mjs +11 -7
  31. package/dist/es/framer-motion/dist/es/projection/animation/mix-values.mjs +3 -3
  32. package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +15 -15
  33. package/dist/es/framer-motion/dist/es/render/dom/resize/handle-element.mjs +1 -0
  34. package/dist/es/framer-motion/dist/es/render/dom/scroll/index.mjs +3 -3
  35. package/dist/es/framer-motion/dist/es/render/dom/scroll/info.mjs +2 -1
  36. package/dist/es/framer-motion/dist/es/render/dom/viewport/index.mjs +1 -0
  37. package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
  38. package/dist/es/framer-motion/dist/es/utils/delay.mjs +2 -1
  39. package/dist/es/framer-motion/dist/es/utils/interpolate.mjs +3 -3
  40. package/dist/es/framer-motion/dist/es/utils/offsets/fill.mjs +2 -1
  41. package/dist/es/framer-motion/dist/es/value/index.mjs +2 -2
  42. package/dist/es/framer-motion/dist/es/value/use-spring.mjs +3 -3
  43. package/dist/es/motion/lib/index.mjs +8 -8
  44. package/dist/es/motion/lib/react.mjs +8 -8
  45. package/dist/es/{framer-motion/dist/es/animation/GroupPlaybackControls.mjs → motion-dom/dist/es/animation/controls/BaseGroup.mjs} +6 -5
  46. package/dist/es/motion-dom/dist/es/animation/controls/Group.mjs +13 -0
  47. package/dist/es/{framer-motion/dist/es/easing → motion-dom/dist/es/animation/generators}/utils/create-generator-easing.mjs +6 -3
  48. package/dist/es/motion-dom/dist/es/animation/waapi/NativeAnimationControls.mjs +85 -0
  49. package/dist/es/{framer-motion/dist/es/animation/animators/waapi → motion-dom/dist/es/animation/waapi/utils}/easing.mjs +3 -3
  50. package/dist/es/{framer-motion/dist/es/animation/animators → motion-dom/dist/es/animation}/waapi/utils/linear.mjs +2 -1
  51. package/dist/es/motion-dom/dist/es/gestures/press/index.mjs +4 -3
  52. package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/supports-linear-easing.mjs → motion-dom/dist/es/utils/supports/linear-easing.mjs} +1 -1
  53. package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/memo-supports.mjs → motion-dom/dist/es/utils/supports/memo.mjs} +3 -2
  54. package/dist/es/motion-dom/dist/es/utils/supports/scroll-timeline.mjs +6 -0
  55. package/dist/motion.dev.js +1677 -1645
  56. package/dist/motion.js +1 -1
  57. package/package.json +3 -3
  58. package/dist/es/framer-motion/dist/es/render/dom/scroll/supports.mjs +0 -5
  59. /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/utils/calc-duration.mjs +0 -0
  60. /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/utils/is-generator.mjs +0 -0
  61. /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/utils/get-value-transition.mjs +0 -0
  62. /package/dist/es/{framer-motion/dist/es/animation/animators → motion-dom/dist/es/animation}/waapi/utils/attach-timeline.mjs +0 -0
  63. /package/dist/es/{framer-motion/dist/es/easing → motion-dom/dist/es}/utils/is-bezier-definition.mjs +0 -0
  64. /package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/supports-flags.mjs → motion-dom/dist/es/utils/supports/flags.mjs} +0 -0
  65. /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/memo.mjs +0 -0
  66. /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/progress.mjs +0 -0
  67. /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/time-conversion.mjs +0 -0
@@ -5,6 +5,27 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var react = require('react');
7
7
 
8
+ const noop = (any) => any;
9
+
10
+ let warning = noop;
11
+ let invariant = noop;
12
+ if (process.env.NODE_ENV !== "production") {
13
+ warning = (check, message) => {
14
+ if (!check && typeof console !== "undefined") {
15
+ console.warn(message);
16
+ }
17
+ };
18
+ invariant = (check, message) => {
19
+ if (!check) {
20
+ throw new Error(message);
21
+ }
22
+ };
23
+ }
24
+
25
+ const LayoutGroupContext = react.createContext({});
26
+
27
+ const LazyContext = react.createContext({ strict: false });
28
+
8
29
  /**
9
30
  * @public
10
31
  */
@@ -17,15 +38,142 @@ const MotionConfigContext = react.createContext({
17
38
  const MotionContext = react.createContext({});
18
39
 
19
40
  /**
20
- * @public
41
+ * Decides if the supplied variable is variant label
21
42
  */
22
- const PresenceContext = react.createContext(null);
43
+ function isVariantLabel(v) {
44
+ return typeof v === "string" || Array.isArray(v);
45
+ }
46
+
47
+ function isAnimationControls(v) {
48
+ return (v !== null &&
49
+ typeof v === "object" &&
50
+ typeof v.start === "function");
51
+ }
52
+
53
+ const variantPriorityOrder = [
54
+ "animate",
55
+ "whileInView",
56
+ "whileFocus",
57
+ "whileHover",
58
+ "whileTap",
59
+ "whileDrag",
60
+ "exit",
61
+ ];
62
+ const variantProps = ["initial", ...variantPriorityOrder];
63
+
64
+ function isControllingVariants(props) {
65
+ return (isAnimationControls(props.animate) ||
66
+ variantProps.some((name) => isVariantLabel(props[name])));
67
+ }
68
+ function isVariantNode(props) {
69
+ return Boolean(isControllingVariants(props) || props.variants);
70
+ }
71
+
72
+ function getCurrentTreeVariants(props, context) {
73
+ if (isControllingVariants(props)) {
74
+ const { initial, animate } = props;
75
+ return {
76
+ initial: initial === false || isVariantLabel(initial)
77
+ ? initial
78
+ : undefined,
79
+ animate: isVariantLabel(animate) ? animate : undefined,
80
+ };
81
+ }
82
+ return props.inherit !== false ? context : {};
83
+ }
84
+
85
+ function useCreateMotionContext(props) {
86
+ const { initial, animate } = getCurrentTreeVariants(props, react.useContext(MotionContext));
87
+ return react.useMemo(() => ({ initial, animate }), [variantLabelsAsDependency(initial), variantLabelsAsDependency(animate)]);
88
+ }
89
+ function variantLabelsAsDependency(prop) {
90
+ return Array.isArray(prop) ? prop.join(" ") : prop;
91
+ }
23
92
 
24
93
  const isBrowser = typeof window !== "undefined";
25
94
 
26
- const useIsomorphicLayoutEffect = isBrowser ? react.useLayoutEffect : react.useEffect;
95
+ const featureProps = {
96
+ animation: [
97
+ "animate",
98
+ "variants",
99
+ "whileHover",
100
+ "whileTap",
101
+ "exit",
102
+ "whileInView",
103
+ "whileFocus",
104
+ "whileDrag",
105
+ ],
106
+ exit: ["exit"],
107
+ drag: ["drag", "dragControls"],
108
+ focus: ["whileFocus"],
109
+ hover: ["whileHover", "onHoverStart", "onHoverEnd"],
110
+ tap: ["whileTap", "onTap", "onTapStart", "onTapCancel"],
111
+ pan: ["onPan", "onPanStart", "onPanSessionStart", "onPanEnd"],
112
+ inView: ["whileInView", "onViewportEnter", "onViewportLeave"],
113
+ layout: ["layout", "layoutId"],
114
+ };
115
+ const featureDefinitions = {};
116
+ for (const key in featureProps) {
117
+ featureDefinitions[key] = {
118
+ isEnabled: (props) => featureProps[key].some((name) => !!props[name]),
119
+ };
120
+ }
27
121
 
28
- const LazyContext = react.createContext({ strict: false });
122
+ function loadFeatures(features) {
123
+ for (const key in features) {
124
+ featureDefinitions[key] = {
125
+ ...featureDefinitions[key],
126
+ ...features[key],
127
+ };
128
+ }
129
+ }
130
+
131
+ const motionComponentSymbol = Symbol.for("motionComponentSymbol");
132
+
133
+ function isRefObject(ref) {
134
+ return (ref &&
135
+ typeof ref === "object" &&
136
+ Object.prototype.hasOwnProperty.call(ref, "current"));
137
+ }
138
+
139
+ /**
140
+ * Creates a ref function that, when called, hydrates the provided
141
+ * external ref and VisualElement.
142
+ */
143
+ function useMotionRef(visualState, visualElement, externalRef) {
144
+ return react.useCallback((instance) => {
145
+ instance && visualState.mount && visualState.mount(instance);
146
+ if (visualElement) {
147
+ if (instance) {
148
+ visualElement.mount(instance);
149
+ }
150
+ else {
151
+ visualElement.unmount();
152
+ }
153
+ }
154
+ if (externalRef) {
155
+ if (typeof externalRef === "function") {
156
+ externalRef(instance);
157
+ }
158
+ else if (isRefObject(externalRef)) {
159
+ externalRef.current = instance;
160
+ }
161
+ }
162
+ },
163
+ /**
164
+ * Only pass a new ref callback to React if we've received a visual element
165
+ * factory. Otherwise we'll be mounting/remounting every time externalRef
166
+ * or other dependencies change.
167
+ */
168
+ [visualElement]);
169
+ }
170
+
171
+ /**
172
+ * @public
173
+ */
174
+ const PresenceContext = react.createContext(null);
175
+
176
+ const useIsomorphicLayoutEffect = isBrowser ? react.useLayoutEffect : react.useEffect;
29
177
 
30
178
  /**
31
179
  * Convert camelCase to dash-case properties.
@@ -185,12 +333,6 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
185
333
 
186
334
  const { schedule: microtask, cancel: cancelMicrotask } = createRenderBatcher(queueMicrotask, false);
187
335
 
188
- function isRefObject(ref) {
189
- return (ref &&
190
- typeof ref === "object" &&
191
- Object.prototype.hasOwnProperty.call(ref, "current"));
192
- }
193
-
194
336
  /**
195
337
  * Internal, exported only for usage in Framer
196
338
  */
@@ -318,148 +460,6 @@ function getClosestProjectingNode(visualElement) {
318
460
  : getClosestProjectingNode(visualElement.parent);
319
461
  }
320
462
 
321
- /**
322
- * Creates a ref function that, when called, hydrates the provided
323
- * external ref and VisualElement.
324
- */
325
- function useMotionRef(visualState, visualElement, externalRef) {
326
- return react.useCallback((instance) => {
327
- instance && visualState.mount && visualState.mount(instance);
328
- if (visualElement) {
329
- if (instance) {
330
- visualElement.mount(instance);
331
- }
332
- else {
333
- visualElement.unmount();
334
- }
335
- }
336
- if (externalRef) {
337
- if (typeof externalRef === "function") {
338
- externalRef(instance);
339
- }
340
- else if (isRefObject(externalRef)) {
341
- externalRef.current = instance;
342
- }
343
- }
344
- },
345
- /**
346
- * Only pass a new ref callback to React if we've received a visual element
347
- * factory. Otherwise we'll be mounting/remounting every time externalRef
348
- * or other dependencies change.
349
- */
350
- [visualElement]);
351
- }
352
-
353
- /**
354
- * Decides if the supplied variable is variant label
355
- */
356
- function isVariantLabel(v) {
357
- return typeof v === "string" || Array.isArray(v);
358
- }
359
-
360
- function isAnimationControls(v) {
361
- return (v !== null &&
362
- typeof v === "object" &&
363
- typeof v.start === "function");
364
- }
365
-
366
- const variantPriorityOrder = [
367
- "animate",
368
- "whileInView",
369
- "whileFocus",
370
- "whileHover",
371
- "whileTap",
372
- "whileDrag",
373
- "exit",
374
- ];
375
- const variantProps = ["initial", ...variantPriorityOrder];
376
-
377
- function isControllingVariants(props) {
378
- return (isAnimationControls(props.animate) ||
379
- variantProps.some((name) => isVariantLabel(props[name])));
380
- }
381
- function isVariantNode(props) {
382
- return Boolean(isControllingVariants(props) || props.variants);
383
- }
384
-
385
- function getCurrentTreeVariants(props, context) {
386
- if (isControllingVariants(props)) {
387
- const { initial, animate } = props;
388
- return {
389
- initial: initial === false || isVariantLabel(initial)
390
- ? initial
391
- : undefined,
392
- animate: isVariantLabel(animate) ? animate : undefined,
393
- };
394
- }
395
- return props.inherit !== false ? context : {};
396
- }
397
-
398
- function useCreateMotionContext(props) {
399
- const { initial, animate } = getCurrentTreeVariants(props, react.useContext(MotionContext));
400
- return react.useMemo(() => ({ initial, animate }), [variantLabelsAsDependency(initial), variantLabelsAsDependency(animate)]);
401
- }
402
- function variantLabelsAsDependency(prop) {
403
- return Array.isArray(prop) ? prop.join(" ") : prop;
404
- }
405
-
406
- const featureProps = {
407
- animation: [
408
- "animate",
409
- "variants",
410
- "whileHover",
411
- "whileTap",
412
- "exit",
413
- "whileInView",
414
- "whileFocus",
415
- "whileDrag",
416
- ],
417
- exit: ["exit"],
418
- drag: ["drag", "dragControls"],
419
- focus: ["whileFocus"],
420
- hover: ["whileHover", "onHoverStart", "onHoverEnd"],
421
- tap: ["whileTap", "onTap", "onTapStart", "onTapCancel"],
422
- pan: ["onPan", "onPanStart", "onPanSessionStart", "onPanEnd"],
423
- inView: ["whileInView", "onViewportEnter", "onViewportLeave"],
424
- layout: ["layout", "layoutId"],
425
- };
426
- const featureDefinitions = {};
427
- for (const key in featureProps) {
428
- featureDefinitions[key] = {
429
- isEnabled: (props) => featureProps[key].some((name) => !!props[name]),
430
- };
431
- }
432
-
433
- function loadFeatures(features) {
434
- for (const key in features) {
435
- featureDefinitions[key] = {
436
- ...featureDefinitions[key],
437
- ...features[key],
438
- };
439
- }
440
- }
441
-
442
- const LayoutGroupContext = react.createContext({});
443
-
444
- const motionComponentSymbol = Symbol.for("motionComponentSymbol");
445
-
446
- const noop = (any) => any;
447
-
448
- let warning = noop;
449
- let invariant = noop;
450
- if (process.env.NODE_ENV !== "production") {
451
- warning = (check, message) => {
452
- if (!check && typeof console !== "undefined") {
453
- console.warn(message);
454
- }
455
- };
456
- invariant = (check, message) => {
457
- if (!check) {
458
- throw new Error(message);
459
- }
460
- };
461
- }
462
-
463
463
  /**
464
464
  * Create a `motion` component.
465
465
  *
@@ -470,6 +470,7 @@ if (process.env.NODE_ENV !== "production") {
470
470
  * component "offline", or outside the React render cycle.
471
471
  */
472
472
  function createRendererMotionComponent({ preloadedFeatures, createVisualElement, useRender, useVisualState, Component, }) {
473
+ var _a, _b;
473
474
  preloadedFeatures && loadFeatures(preloadedFeatures);
474
475
  function MotionComponent(props, externalRef) {
475
476
  /**
@@ -503,6 +504,9 @@ function createRendererMotionComponent({ preloadedFeatures, createVisualElement,
503
504
  */
504
505
  return (jsxRuntime.jsxs(MotionContext.Provider, { value: context, children: [MeasureLayout && context.visualElement ? (jsxRuntime.jsx(MeasureLayout, { visualElement: context.visualElement, ...configAndProps })) : null, useRender(Component, props, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, context.visualElement)] }));
505
506
  }
507
+ MotionComponent.displayName = `motion.${typeof Component === "string"
508
+ ? Component
509
+ : `create(${(_b = (_a = Component.displayName) !== null && _a !== void 0 ? _a : Component.name) !== null && _b !== void 0 ? _b : ""})`}`;
506
510
  const ForwardRefMotionComponent = react.forwardRef(MotionComponent);
507
511
  ForwardRefMotionComponent[motionComponentSymbol] = Component;
508
512
  return ForwardRefMotionComponent;