framer-motion 12.23.27 → 12.24.0

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 (48) hide show
  1. package/dist/cjs/client.js +1 -1
  2. package/dist/cjs/{feature-bundle-kvRbMDEA.js → feature-bundle-DhbxBqkJ.js} +32 -15
  3. package/dist/cjs/feature-bundle-DhbxBqkJ.js.map +1 -0
  4. package/dist/cjs/index.js +1 -1
  5. package/dist/cjs/index.js.map +1 -1
  6. package/dist/cjs/m.js +14 -11
  7. package/dist/cjs/m.js.map +1 -1
  8. package/dist/dom-mini.js +1 -1
  9. package/dist/dom.js +1 -1
  10. package/dist/es/components/Reorder/Group.mjs.map +1 -1
  11. package/dist/es/gestures/drag/index.mjs +10 -0
  12. package/dist/es/gestures/drag/index.mjs.map +1 -1
  13. package/dist/es/motion/index.mjs +10 -6
  14. package/dist/es/motion/index.mjs.map +1 -1
  15. package/dist/es/motion/utils/use-visual-element.mjs +2 -1
  16. package/dist/es/motion/utils/use-visual-element.mjs.map +1 -1
  17. package/dist/es/projection/geometry/delta-apply.mjs +1 -1
  18. package/dist/es/projection/geometry/delta-apply.mjs.map +1 -1
  19. package/dist/es/projection/node/create-projection-node.mjs +1 -1
  20. package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
  21. package/dist/es/render/dom/create-visual-element.mjs +5 -1
  22. package/dist/es/render/dom/create-visual-element.mjs.map +1 -1
  23. package/dist/es/render/dom/use-render.mjs +2 -4
  24. package/dist/es/render/dom/use-render.mjs.map +1 -1
  25. package/dist/framer-motion.dev.js +73 -17
  26. package/dist/framer-motion.js +1 -1
  27. package/dist/m.d.ts +9 -1
  28. package/dist/mini.js +1 -1
  29. package/dist/size-rollup-animate.js +1 -1
  30. package/dist/size-rollup-animate.js.map +1 -1
  31. package/dist/size-rollup-dom-animation-assets.js +1 -1
  32. package/dist/size-rollup-dom-animation-m.js +1 -1
  33. package/dist/size-rollup-dom-animation.js +1 -1
  34. package/dist/size-rollup-dom-max-assets.js +1 -1
  35. package/dist/size-rollup-dom-max.js +1 -1
  36. package/dist/size-rollup-m.js +1 -1
  37. package/dist/size-rollup-m.js.map +1 -1
  38. package/dist/size-rollup-motion.js +1 -1
  39. package/dist/size-rollup-motion.js.map +1 -1
  40. package/dist/size-rollup-scroll.js +1 -1
  41. package/dist/size-rollup-scroll.js.map +1 -1
  42. package/dist/size-rollup-waapi-animate.js +1 -1
  43. package/dist/size-rollup-waapi-animate.js.map +1 -1
  44. package/dist/types/client.d.ts +1 -1
  45. package/dist/types/index.d.ts +13 -5
  46. package/dist/{types.d-DagZKalS.d.ts → types.d-a9pt5qxk.d.ts} +6 -1
  47. package/package.json +4 -4
  48. package/dist/cjs/feature-bundle-kvRbMDEA.js.map +0 -1
@@ -4,7 +4,11 @@ import { SVGVisualElement } from '../svg/SVGVisualElement.mjs';
4
4
  import { isSVGComponent } from './utils/is-svg-component.mjs';
5
5
 
6
6
  const createDomVisualElement = (Component, options) => {
7
- return isSVGComponent(Component)
7
+ /**
8
+ * Use explicit isSVG override if provided, otherwise auto-detect
9
+ */
10
+ const isSVG = options.isSVG ?? isSVGComponent(Component);
11
+ return isSVG
8
12
  ? new SVGVisualElement(options)
9
13
  : new HTMLVisualElement(options, {
10
14
  allowProjection: Component !== Fragment,
@@ -1 +1 @@
1
- {"version":3,"file":"create-visual-element.mjs","sources":["../../../../src/render/dom/create-visual-element.ts"],"sourcesContent":["import { ComponentType, Fragment } from \"react\"\nimport { HTMLVisualElement } from \"../html/HTMLVisualElement\"\nimport { SVGVisualElement } from \"../svg/SVGVisualElement\"\nimport { CreateVisualElement, VisualElementOptions } from \"../types\"\nimport { isSVGComponent } from \"./utils/is-svg-component\"\n\nexport const createDomVisualElement: CreateVisualElement = (\n Component: string | ComponentType<React.PropsWithChildren<unknown>>,\n options: VisualElementOptions<HTMLElement | SVGElement>\n) => {\n return isSVGComponent(Component)\n ? new SVGVisualElement(options)\n : new HTMLVisualElement(options, {\n allowProjection: Component !== Fragment,\n })\n}\n"],"names":[],"mappings":";;;;;MAMa,sBAAsB,GAAwB,CACvD,SAAmE,EACnE,OAAuD,KACvD;IACA,OAAO,cAAc,CAAC,SAAS,CAAC;AAC5B,UAAE,IAAI,gBAAgB,CAAC,OAAO,CAAC;AAC/B,UAAE,IAAI,iBAAiB,CAAC,OAAO,EAAE;YAC3B,eAAe,EAAE,SAAS,KAAK,QAAQ;AAC1C,SAAA,CAAC,CAAA;AACZ;;;;"}
1
+ {"version":3,"file":"create-visual-element.mjs","sources":["../../../../src/render/dom/create-visual-element.ts"],"sourcesContent":["import { ComponentType, Fragment } from \"react\"\nimport { HTMLVisualElement } from \"../html/HTMLVisualElement\"\nimport { SVGVisualElement } from \"../svg/SVGVisualElement\"\nimport { CreateVisualElement, VisualElementOptions } from \"../types\"\nimport { isSVGComponent } from \"./utils/is-svg-component\"\n\nexport const createDomVisualElement: CreateVisualElement = (\n Component: string | ComponentType<React.PropsWithChildren<unknown>>,\n options: VisualElementOptions<HTMLElement | SVGElement>\n) => {\n /**\n * Use explicit isSVG override if provided, otherwise auto-detect\n */\n const isSVG = options.isSVG ?? isSVGComponent(Component)\n\n return isSVG\n ? new SVGVisualElement(options)\n : new HTMLVisualElement(options, {\n allowProjection: Component !== Fragment,\n })\n}\n"],"names":[],"mappings":";;;;;MAMa,sBAAsB,GAAwB,CACvD,SAAmE,EACnE,OAAuD,KACvD;AACA;;AAEG;IACH,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,cAAc,CAAC,SAAS,CAAC,CAAA;AAExD,IAAA,OAAO,KAAK;AACR,UAAE,IAAI,gBAAgB,CAAC,OAAO,CAAC;AAC/B,UAAE,IAAI,iBAAiB,CAAC,OAAO,EAAE;YAC3B,eAAe,EAAE,SAAS,KAAK,QAAQ;AAC1C,SAAA,CAAC,CAAA;AACZ;;;;"}
@@ -6,10 +6,8 @@ import { useSVGProps } from '../svg/use-props.mjs';
6
6
  import { filterProps } from './utils/filter-props.mjs';
7
7
  import { isSVGComponent } from './utils/is-svg-component.mjs';
8
8
 
9
- function useRender(Component, props, ref, { latestValues, }, isStatic, forwardMotionProps = false) {
10
- const useVisualProps = isSVGComponent(Component)
11
- ? useSVGProps
12
- : useHTMLProps;
9
+ function useRender(Component, props, ref, { latestValues, }, isStatic, forwardMotionProps = false, isSVG) {
10
+ const useVisualProps = (isSVG ?? isSVGComponent(Component)) ? useSVGProps : useHTMLProps;
13
11
  const visualProps = useVisualProps(props, latestValues, isStatic, Component);
14
12
  const filteredProps = filterProps(props, typeof Component === "string", forwardMotionProps);
15
13
  const elementProps = Component !== Fragment ? { ...filteredProps, ...visualProps, ref } : {};
@@ -1 +1 @@
1
- {"version":3,"file":"use-render.mjs","sources":["../../../../src/render/dom/use-render.ts"],"sourcesContent":["\"use client\"\n\nimport { isMotionValue } from \"motion-dom\"\nimport { Fragment, createElement, useMemo } from \"react\"\nimport { MotionProps } from \"../../motion/types\"\nimport { VisualState } from \"../../motion/utils/use-visual-state\"\nimport { HTMLRenderState } from \"../html/types\"\nimport { useHTMLProps } from \"../html/use-props\"\nimport { SVGRenderState } from \"../svg/types\"\nimport { useSVGProps } from \"../svg/use-props\"\nimport { DOMMotionComponents } from \"./types\"\nimport { filterProps } from \"./utils/filter-props\"\nimport { isSVGComponent } from \"./utils/is-svg-component\"\n\nexport function useRender<\n Props = {},\n TagName extends keyof DOMMotionComponents | string = \"div\"\n>(\n Component: TagName | string | React.ComponentType<Props>,\n props: MotionProps,\n ref: React.Ref<HTMLElement | SVGElement>,\n {\n latestValues,\n }: VisualState<HTMLElement | SVGElement, HTMLRenderState | SVGRenderState>,\n isStatic: boolean,\n forwardMotionProps: boolean = false\n) {\n const useVisualProps = isSVGComponent(Component)\n ? useSVGProps\n : useHTMLProps\n\n const visualProps = useVisualProps(\n props as any,\n latestValues,\n isStatic,\n Component as any\n )\n const filteredProps = filterProps(\n props,\n typeof Component === \"string\",\n forwardMotionProps\n )\n const elementProps =\n Component !== Fragment ? { ...filteredProps, ...visualProps, ref } : {}\n\n /**\n * If component has been handed a motion value as its child,\n * memoise its initial value and render that. Subsequent updates\n * will be handled by the onChange handler\n */\n const { children } = props\n const renderedChildren = useMemo(\n () => (isMotionValue(children) ? children.get() : children),\n [children]\n )\n\n return createElement<any>(Component, {\n ...elementProps,\n children: renderedChildren,\n })\n}\n"],"names":[],"mappings":";;;;;;;;;AA2BI;AACI;;AAGJ;AAMA;;AAQA;;;;AAIG;AACH;AACA;;AAMI;AACA;AACH;AACL;;"}
1
+ {"version":3,"file":"use-render.mjs","sources":["../../../../src/render/dom/use-render.ts"],"sourcesContent":["\"use client\"\n\nimport { isMotionValue } from \"motion-dom\"\nimport { Fragment, createElement, useMemo } from \"react\"\nimport { MotionProps } from \"../../motion/types\"\nimport { VisualState } from \"../../motion/utils/use-visual-state\"\nimport { HTMLRenderState } from \"../html/types\"\nimport { useHTMLProps } from \"../html/use-props\"\nimport { SVGRenderState } from \"../svg/types\"\nimport { useSVGProps } from \"../svg/use-props\"\nimport { DOMMotionComponents } from \"./types\"\nimport { filterProps } from \"./utils/filter-props\"\nimport { isSVGComponent } from \"./utils/is-svg-component\"\n\nexport function useRender<\n Props = {},\n TagName extends keyof DOMMotionComponents | string = \"div\"\n>(\n Component: TagName | string | React.ComponentType<Props>,\n props: MotionProps,\n ref: React.Ref<HTMLElement | SVGElement>,\n {\n latestValues,\n }: VisualState<HTMLElement | SVGElement, HTMLRenderState | SVGRenderState>,\n isStatic: boolean,\n forwardMotionProps: boolean = false,\n isSVG?: boolean\n) {\n const useVisualProps =\n (isSVG ?? isSVGComponent(Component)) ? useSVGProps : useHTMLProps\n\n const visualProps = useVisualProps(\n props as any,\n latestValues,\n isStatic,\n Component as any\n )\n const filteredProps = filterProps(\n props,\n typeof Component === \"string\",\n forwardMotionProps\n )\n const elementProps =\n Component !== Fragment ? { ...filteredProps, ...visualProps, ref } : {}\n\n /**\n * If component has been handed a motion value as its child,\n * memoise its initial value and render that. Subsequent updates\n * will be handled by the onChange handler\n */\n const { children } = props\n const renderedChildren = useMemo(\n () => (isMotionValue(children) ? children.get() : children),\n [children]\n )\n\n return createElement<any>(Component, {\n ...elementProps,\n children: renderedChildren,\n })\n}\n"],"names":[],"mappings":";;;;;;;;;AA4BI;AAGA;AAMA;;AAQA;;;;AAIG;AACH;AACA;;AAMI;AACA;AACH;AACL;;"}
@@ -119,7 +119,8 @@
119
119
 
120
120
  exports.warning = () => { };
121
121
  exports.invariant = () => { };
122
- {
122
+ if (typeof process !== "undefined" &&
123
+ process.env?.NODE_ENV !== "production") {
123
124
  exports.warning = (check, message, errorCode) => {
124
125
  if (!check && typeof console !== "undefined") {
125
126
  console.warn(formatErrorMessage(message, errorCode));
@@ -2608,7 +2609,7 @@
2608
2609
  /**
2609
2610
  * WAAPI doesn't natively have any interruption capabilities.
2610
2611
  *
2611
- * Rather than read commited styles back out of the DOM, we can
2612
+ * Rather than read committed styles back out of the DOM, we can
2612
2613
  * create a renderless JS animation and sample it twice to calculate
2613
2614
  * its current value, "previous" value, and therefore allow
2614
2615
  * Motion to calculate velocity for any subsequent animation.
@@ -2804,7 +2805,7 @@
2804
2805
  * progress, which would feel snappier.
2805
2806
  *
2806
2807
  * However, if there's a delay (main thread work) between the creation of
2807
- * the animation and the first commited frame, we prefer to use resolvedAt
2808
+ * the animation and the first committed frame, we prefer to use resolvedAt
2808
2809
  * to avoid a sudden jump into the animation.
2809
2810
  */
2810
2811
  const startTime = sync
@@ -3178,17 +3179,36 @@
3178
3179
  right: px,
3179
3180
  bottom: px,
3180
3181
  left: px,
3182
+ inset: px,
3183
+ insetBlock: px,
3184
+ insetBlockStart: px,
3185
+ insetBlockEnd: px,
3186
+ insetInline: px,
3187
+ insetInlineStart: px,
3188
+ insetInlineEnd: px,
3181
3189
  // Spacing props
3182
3190
  padding: px,
3183
3191
  paddingTop: px,
3184
3192
  paddingRight: px,
3185
3193
  paddingBottom: px,
3186
3194
  paddingLeft: px,
3195
+ paddingBlock: px,
3196
+ paddingBlockStart: px,
3197
+ paddingBlockEnd: px,
3198
+ paddingInline: px,
3199
+ paddingInlineStart: px,
3200
+ paddingInlineEnd: px,
3187
3201
  margin: px,
3188
3202
  marginTop: px,
3189
3203
  marginRight: px,
3190
3204
  marginBottom: px,
3191
3205
  marginLeft: px,
3206
+ marginBlock: px,
3207
+ marginBlockStart: px,
3208
+ marginBlockEnd: px,
3209
+ marginInline: px,
3210
+ marginInlineStart: px,
3211
+ marginInlineEnd: px,
3192
3212
  // Misc
3193
3213
  backgroundPositionX: px,
3194
3214
  backgroundPositionY: px,
@@ -3404,17 +3424,36 @@
3404
3424
  "right",
3405
3425
  "bottom",
3406
3426
  "left",
3427
+ "inset",
3428
+ "insetBlock",
3429
+ "insetBlockStart",
3430
+ "insetBlockEnd",
3431
+ "insetInline",
3432
+ "insetInlineStart",
3433
+ "insetInlineEnd",
3407
3434
  // Spacing props
3408
3435
  "padding",
3409
3436
  "paddingTop",
3410
3437
  "paddingRight",
3411
3438
  "paddingBottom",
3412
3439
  "paddingLeft",
3440
+ "paddingBlock",
3441
+ "paddingBlockStart",
3442
+ "paddingBlockEnd",
3443
+ "paddingInline",
3444
+ "paddingInlineStart",
3445
+ "paddingInlineEnd",
3413
3446
  "margin",
3414
3447
  "marginTop",
3415
3448
  "marginRight",
3416
3449
  "marginBottom",
3417
3450
  "marginLeft",
3451
+ "marginBlock",
3452
+ "marginBlockStart",
3453
+ "marginBlockEnd",
3454
+ "marginInline",
3455
+ "marginInlineStart",
3456
+ "marginInlineEnd",
3418
3457
  // Misc
3419
3458
  "backgroundPositionX",
3420
3459
  "backgroundPositionY",
@@ -5981,7 +6020,7 @@
5981
6020
  });
5982
6021
  }
5983
6022
  if (delta) {
5984
- // Incoporate each ancestor's scale into a culmulative treeScale for this component
6023
+ // Incoporate each ancestor's scale into a cumulative treeScale for this component
5985
6024
  treeScale.x *= delta.x.scale;
5986
6025
  treeScale.y *= delta.y.scale;
5987
6026
  // Apply each ancestor's calculated delta into this component's recorded layout box
@@ -6707,7 +6746,7 @@
6707
6746
  /**
6708
6747
  * If the layout hasn't changed and we have an animation that hasn't started yet,
6709
6748
  * finish it immediately. Otherwise it will be animating from a location
6710
- * that was probably never commited to screen and look like a jumpy box.
6749
+ * that was probably never committed to screen and look like a jumpy box.
6711
6750
  */
6712
6751
  if (!hasLayoutChanged) {
6713
6752
  finishAnimation(this);
@@ -9424,7 +9463,11 @@
9424
9463
  }
9425
9464
 
9426
9465
  const createDomVisualElement = (Component, options) => {
9427
- return isSVGComponent(Component)
9466
+ /**
9467
+ * Use explicit isSVG override if provided, otherwise auto-detect
9468
+ */
9469
+ const isSVG = options.isSVG ?? isSVGComponent(Component);
9470
+ return isSVG
9428
9471
  ? new SVGVisualElement(options)
9429
9472
  : new HTMLVisualElement(options, {
9430
9473
  allowProjection: Component !== React$1.Fragment,
@@ -9533,10 +9576,8 @@
9533
9576
  return visualProps;
9534
9577
  }
9535
9578
 
9536
- function useRender(Component, props, ref, { latestValues, }, isStatic, forwardMotionProps = false) {
9537
- const useVisualProps = isSVGComponent(Component)
9538
- ? useSVGProps
9539
- : useHTMLProps;
9579
+ function useRender(Component, props, ref, { latestValues, }, isStatic, forwardMotionProps = false, isSVG) {
9580
+ const useVisualProps = (isSVG ?? isSVGComponent(Component)) ? useSVGProps : useHTMLProps;
9540
9581
  const visualProps = useVisualProps(props, latestValues, isStatic, Component);
9541
9582
  const filteredProps = filterProps(props, typeof Component === "string", forwardMotionProps);
9542
9583
  const elementProps = Component !== React$1.Fragment ? { ...filteredProps, ...visualProps, ref } : {};
@@ -9678,7 +9719,7 @@
9678
9719
  */
9679
9720
  const SwitchLayoutGroupContext = React$1.createContext({});
9680
9721
 
9681
- function useVisualElement(Component, visualState, props, createVisualElement, ProjectionNodeConstructor) {
9722
+ function useVisualElement(Component, visualState, props, createVisualElement, ProjectionNodeConstructor, isSVG) {
9682
9723
  const { visualElement: parent } = React$1.useContext(MotionContext);
9683
9724
  const lazyContext = React$1.useContext(LazyContext);
9684
9725
  const presenceContext = React$1.useContext(PresenceContext);
@@ -9700,6 +9741,7 @@
9700
9741
  ? presenceContext.initial === false
9701
9742
  : false,
9702
9743
  reducedMotionConfig,
9744
+ isSVG,
9703
9745
  });
9704
9746
  }
9705
9747
  const visualElement = visualElementRef.current;
@@ -9815,11 +9857,15 @@
9815
9857
  * Alongside this is a config option which provides a way of rendering the provided
9816
9858
  * component "offline", or outside the React render cycle.
9817
9859
  */
9818
- function createMotionComponent(Component, { forwardMotionProps = false } = {}, preloadedFeatures, createVisualElement) {
9860
+ function createMotionComponent(Component, { forwardMotionProps = false, type } = {}, preloadedFeatures, createVisualElement) {
9819
9861
  preloadedFeatures && loadFeatures(preloadedFeatures);
9820
- const useVisualState = isSVGComponent(Component)
9821
- ? useSVGVisualState
9822
- : useHTMLVisualState;
9862
+ /**
9863
+ * Determine whether to use SVG or HTML rendering based on:
9864
+ * 1. Explicit `type` option (highest priority)
9865
+ * 2. Auto-detection via `isSVGComponent`
9866
+ */
9867
+ const isSVG = type ? type === "svg" : isSVGComponent(Component);
9868
+ const useVisualState = isSVG ? useSVGVisualState : useHTMLVisualState;
9823
9869
  function MotionDOMComponent(props, externalRef) {
9824
9870
  /**
9825
9871
  * If we need to measure the element we load this functionality in a
@@ -9844,13 +9890,13 @@
9844
9890
  * providing a way of rendering to these APIs outside of the React render loop
9845
9891
  * for more performant animations and interactions
9846
9892
  */
9847
- context.visualElement = useVisualElement(Component, visualState, configAndProps, createVisualElement, layoutProjection.ProjectionNode);
9893
+ context.visualElement = useVisualElement(Component, visualState, configAndProps, createVisualElement, layoutProjection.ProjectionNode, isSVG);
9848
9894
  }
9849
9895
  /**
9850
9896
  * The mount order and hierarchy is specific to ensure our element ref
9851
9897
  * is hydrated by the time features fire their effects.
9852
9898
  */
9853
- return (jsxs(MotionContext.Provider, { value: context, children: [MeasureLayout && context.visualElement ? (jsx(MeasureLayout, { visualElement: context.visualElement, ...configAndProps })) : null, useRender(Component, props, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, forwardMotionProps)] }));
9899
+ return (jsxs(MotionContext.Provider, { value: context, children: [MeasureLayout && context.visualElement ? (jsx(MeasureLayout, { visualElement: context.visualElement, ...configAndProps })) : null, useRender(Component, props, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, forwardMotionProps, isSVG)] }));
9854
9900
  }
9855
9901
  MotionDOMComponent.displayName = `motion.${typeof Component === "string"
9856
9902
  ? Component
@@ -11422,6 +11468,16 @@
11422
11468
  }
11423
11469
  this.removeListeners = this.controls.addListeners() || noop;
11424
11470
  }
11471
+ update() {
11472
+ const { dragControls } = this.node.getProps();
11473
+ const { dragControls: prevDragControls } = this.node.prevProps || {};
11474
+ if (dragControls !== prevDragControls) {
11475
+ this.removeGroupControls();
11476
+ if (dragControls) {
11477
+ this.removeGroupControls = dragControls.subscribe(this.controls);
11478
+ }
11479
+ }
11480
+ }
11425
11481
  unmount() {
11426
11482
  this.removeGroupControls();
11427
11483
  this.removeListeners();