framer-motion 12.23.28 → 12.24.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 (48) hide show
  1. package/dist/cjs/client.js +1 -1
  2. package/dist/cjs/dom.js +15 -0
  3. package/dist/cjs/dom.js.map +1 -1
  4. package/dist/cjs/{feature-bundle-Dt2VtvSZ.js → feature-bundle-DRMwxyzS.js} +45 -13
  5. package/dist/cjs/feature-bundle-DRMwxyzS.js.map +1 -0
  6. package/dist/cjs/index.js +1 -1
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/cjs/m.js +29 -11
  9. package/dist/cjs/m.js.map +1 -1
  10. package/dist/dom-mini.js +1 -1
  11. package/dist/dom.js +1 -1
  12. package/dist/es/components/Reorder/Group.mjs.map +1 -1
  13. package/dist/es/components/Reorder/Item.mjs.map +1 -1
  14. package/dist/es/gestures/drag/index.mjs +10 -0
  15. package/dist/es/gestures/drag/index.mjs.map +1 -1
  16. package/dist/es/motion/index.mjs +10 -6
  17. package/dist/es/motion/index.mjs.map +1 -1
  18. package/dist/es/motion/utils/use-visual-element.mjs +2 -1
  19. package/dist/es/motion/utils/use-visual-element.mjs.map +1 -1
  20. package/dist/es/render/dom/create-visual-element.mjs +5 -1
  21. package/dist/es/render/dom/create-visual-element.mjs.map +1 -1
  22. package/dist/es/render/dom/use-render.mjs +2 -4
  23. package/dist/es/render/dom/use-render.mjs.map +1 -1
  24. package/dist/es/render/svg/utils/build-attrs.mjs +15 -0
  25. package/dist/es/render/svg/utils/build-attrs.mjs.map +1 -1
  26. package/dist/framer-motion.dev.js +82 -34
  27. package/dist/framer-motion.js +1 -1
  28. package/dist/m.d.ts +8 -0
  29. package/dist/mini.js +1 -1
  30. package/dist/size-rollup-animate.js +1 -1
  31. package/dist/size-rollup-animate.js.map +1 -1
  32. package/dist/size-rollup-dom-animation-assets.js +1 -1
  33. package/dist/size-rollup-dom-animation-m.js +1 -1
  34. package/dist/size-rollup-dom-animation.js +1 -1
  35. package/dist/size-rollup-dom-max-assets.js +1 -1
  36. package/dist/size-rollup-dom-max.js +1 -1
  37. package/dist/size-rollup-m.js +1 -1
  38. package/dist/size-rollup-m.js.map +1 -1
  39. package/dist/size-rollup-motion.js +1 -1
  40. package/dist/size-rollup-motion.js.map +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-C8SDx5n-.d.ts → types.d-a9pt5qxk.d.ts} +5 -0
  47. package/package.json +3 -3
  48. package/dist/cjs/feature-bundle-Dt2VtvSZ.js.map +0 -1
@@ -3672,6 +3672,15 @@ function buildSVGPath(attrs, length, spacing = 1, offset = 0, useDashCase = true
3672
3672
  attrs[keys.array] = `${pathLength} ${pathSpacing}`;
3673
3673
  }
3674
3674
 
3675
+ /**
3676
+ * CSS Motion Path properties that should remain as CSS styles on SVG elements.
3677
+ */
3678
+ const cssMotionPathProperties = [
3679
+ "offsetDistance",
3680
+ "offsetPath",
3681
+ "offsetRotate",
3682
+ "offsetAnchor",
3683
+ ];
3675
3684
  /**
3676
3685
  * Build SVG visual attributes, like cx and style.transform
3677
3686
  */
@@ -3712,6 +3721,12 @@ function buildSVGAttrs(state, { attrX, attrY, attrScale, pathLength, pathSpacing
3712
3721
  style.transformBox = styleProp?.transformBox ?? "fill-box";
3713
3722
  delete attrs.transformBox;
3714
3723
  }
3724
+ for (const key of cssMotionPathProperties) {
3725
+ if (attrs[key] !== undefined) {
3726
+ style[key] = attrs[key];
3727
+ delete attrs[key];
3728
+ }
3729
+ }
3715
3730
  // Render attrX/attrY/attrScale as attributes
3716
3731
  if (attrX !== undefined)
3717
3732
  attrs.x = attrX;
@@ -3870,7 +3885,11 @@ function isSVGComponent(Component) {
3870
3885
  }
3871
3886
 
3872
3887
  const createDomVisualElement = (Component, options) => {
3873
- return isSVGComponent(Component)
3888
+ /**
3889
+ * Use explicit isSVG override if provided, otherwise auto-detect
3890
+ */
3891
+ const isSVG = options.isSVG ?? isSVGComponent(Component);
3892
+ return isSVG
3874
3893
  ? new SVGVisualElement(options)
3875
3894
  : new HTMLVisualElement(options, {
3876
3895
  allowProjection: Component !== React.Fragment,
@@ -3979,10 +3998,8 @@ function useSVGProps(props, visualState, _isStatic, Component) {
3979
3998
  return visualProps;
3980
3999
  }
3981
4000
 
3982
- function useRender(Component, props, ref, { latestValues, }, isStatic, forwardMotionProps = false) {
3983
- const useVisualProps = isSVGComponent(Component)
3984
- ? useSVGProps
3985
- : useHTMLProps;
4001
+ function useRender(Component, props, ref, { latestValues, }, isStatic, forwardMotionProps = false, isSVG) {
4002
+ const useVisualProps = (isSVG ?? isSVGComponent(Component)) ? useSVGProps : useHTMLProps;
3986
4003
  const visualProps = useVisualProps(props, latestValues, isStatic, Component);
3987
4004
  const filteredProps = filterProps(props, typeof Component === "string", forwardMotionProps);
3988
4005
  const elementProps = Component !== React.Fragment ? { ...filteredProps, ...visualProps, ref } : {};
@@ -4124,7 +4141,7 @@ function useMotionRef(visualState, visualElement, externalRef) {
4124
4141
  */
4125
4142
  const SwitchLayoutGroupContext = React.createContext({});
4126
4143
 
4127
- function useVisualElement(Component, visualState, props, createVisualElement, ProjectionNodeConstructor) {
4144
+ function useVisualElement(Component, visualState, props, createVisualElement, ProjectionNodeConstructor, isSVG) {
4128
4145
  const { visualElement: parent } = React.useContext(MotionContext);
4129
4146
  const lazyContext = React.useContext(LazyContext);
4130
4147
  const presenceContext = React.useContext(PresenceContext);
@@ -4146,6 +4163,7 @@ function useVisualElement(Component, visualState, props, createVisualElement, Pr
4146
4163
  ? presenceContext.initial === false
4147
4164
  : false,
4148
4165
  reducedMotionConfig,
4166
+ isSVG,
4149
4167
  });
4150
4168
  }
4151
4169
  const visualElement = visualElementRef.current;
@@ -4261,11 +4279,15 @@ function getClosestProjectingNode(visualElement) {
4261
4279
  * Alongside this is a config option which provides a way of rendering the provided
4262
4280
  * component "offline", or outside the React render cycle.
4263
4281
  */
4264
- function createMotionComponent(Component, { forwardMotionProps = false } = {}, preloadedFeatures, createVisualElement) {
4282
+ function createMotionComponent(Component, { forwardMotionProps = false, type } = {}, preloadedFeatures, createVisualElement) {
4265
4283
  preloadedFeatures && loadFeatures(preloadedFeatures);
4266
- const useVisualState = isSVGComponent(Component)
4267
- ? useSVGVisualState
4268
- : useHTMLVisualState;
4284
+ /**
4285
+ * Determine whether to use SVG or HTML rendering based on:
4286
+ * 1. Explicit `type` option (highest priority)
4287
+ * 2. Auto-detection via `isSVGComponent`
4288
+ */
4289
+ const isSVG = type ? type === "svg" : isSVGComponent(Component);
4290
+ const useVisualState = isSVG ? useSVGVisualState : useHTMLVisualState;
4269
4291
  function MotionDOMComponent(props, externalRef) {
4270
4292
  /**
4271
4293
  * If we need to measure the element we load this functionality in a
@@ -4290,13 +4312,13 @@ function createMotionComponent(Component, { forwardMotionProps = false } = {}, p
4290
4312
  * providing a way of rendering to these APIs outside of the React render loop
4291
4313
  * for more performant animations and interactions
4292
4314
  */
4293
- context.visualElement = useVisualElement(Component, visualState, configAndProps, createVisualElement, layoutProjection.ProjectionNode);
4315
+ context.visualElement = useVisualElement(Component, visualState, configAndProps, createVisualElement, layoutProjection.ProjectionNode, isSVG);
4294
4316
  }
4295
4317
  /**
4296
4318
  * The mount order and hierarchy is specific to ensure our element ref
4297
4319
  * is hydrated by the time features fire their effects.
4298
4320
  */
4299
- 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, forwardMotionProps)] }));
4321
+ 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, forwardMotionProps, isSVG)] }));
4300
4322
  }
4301
4323
  MotionDOMComponent.displayName = `motion.${typeof Component === "string"
4302
4324
  ? Component
@@ -5828,6 +5850,16 @@ class DragGesture extends Feature {
5828
5850
  }
5829
5851
  this.removeListeners = this.controls.addListeners() || motionUtils.noop;
5830
5852
  }
5853
+ update() {
5854
+ const { dragControls } = this.node.getProps();
5855
+ const { dragControls: prevDragControls } = this.node.prevProps || {};
5856
+ if (dragControls !== prevDragControls) {
5857
+ this.removeGroupControls();
5858
+ if (dragControls) {
5859
+ this.removeGroupControls = dragControls.subscribe(this.controls);
5860
+ }
5861
+ }
5862
+ }
5831
5863
  unmount() {
5832
5864
  this.removeGroupControls();
5833
5865
  this.removeListeners();
@@ -6286,4 +6318,4 @@ exports.useIsPresent = useIsPresent;
6286
6318
  exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
6287
6319
  exports.usePresence = usePresence;
6288
6320
  exports.visualElementStore = visualElementStore;
6289
- //# sourceMappingURL=feature-bundle-Dt2VtvSZ.js.map
6321
+ //# sourceMappingURL=feature-bundle-DRMwxyzS.js.map