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
package/dist/cjs/m.js CHANGED
@@ -369,6 +369,15 @@ function buildSVGPath(attrs, length, spacing = 1, offset = 0, useDashCase = true
369
369
  attrs[keys.array] = `${pathLength} ${pathSpacing}`;
370
370
  }
371
371
 
372
+ /**
373
+ * CSS Motion Path properties that should remain as CSS styles on SVG elements.
374
+ */
375
+ const cssMotionPathProperties = [
376
+ "offsetDistance",
377
+ "offsetPath",
378
+ "offsetRotate",
379
+ "offsetAnchor",
380
+ ];
372
381
  /**
373
382
  * Build SVG visual attributes, like cx and style.transform
374
383
  */
@@ -409,6 +418,12 @@ function buildSVGAttrs(state, { attrX, attrY, attrScale, pathLength, pathSpacing
409
418
  style.transformBox = styleProp?.transformBox ?? "fill-box";
410
419
  delete attrs.transformBox;
411
420
  }
421
+ for (const key of cssMotionPathProperties) {
422
+ if (attrs[key] !== undefined) {
423
+ style[key] = attrs[key];
424
+ delete attrs[key];
425
+ }
426
+ }
412
427
  // Render attrX/attrY/attrScale as attributes
413
428
  if (attrX !== undefined)
414
429
  attrs.x = attrX;
@@ -617,10 +632,8 @@ function isSVGComponent(Component) {
617
632
  return false;
618
633
  }
619
634
 
620
- function useRender(Component, props, ref, { latestValues, }, isStatic, forwardMotionProps = false) {
621
- const useVisualProps = isSVGComponent(Component)
622
- ? useSVGProps
623
- : useHTMLProps;
635
+ function useRender(Component, props, ref, { latestValues, }, isStatic, forwardMotionProps = false, isSVG) {
636
+ const useVisualProps = (isSVG ?? isSVGComponent(Component)) ? useSVGProps : useHTMLProps;
624
637
  const visualProps = useVisualProps(props, latestValues, isStatic, Component);
625
638
  const filteredProps = filterProps(props, typeof Component === "string", forwardMotionProps);
626
639
  const elementProps = Component !== react.Fragment ? { ...filteredProps, ...visualProps, ref } : {};
@@ -891,7 +904,7 @@ const SwitchLayoutGroupContext = react.createContext({});
891
904
 
892
905
  const useIsomorphicLayoutEffect = isBrowser ? react.useLayoutEffect : react.useEffect;
893
906
 
894
- function useVisualElement(Component, visualState, props, createVisualElement, ProjectionNodeConstructor) {
907
+ function useVisualElement(Component, visualState, props, createVisualElement, ProjectionNodeConstructor, isSVG) {
895
908
  const { visualElement: parent } = react.useContext(MotionContext);
896
909
  const lazyContext = react.useContext(LazyContext);
897
910
  const presenceContext = react.useContext(PresenceContext);
@@ -913,6 +926,7 @@ function useVisualElement(Component, visualState, props, createVisualElement, Pr
913
926
  ? presenceContext.initial === false
914
927
  : false,
915
928
  reducedMotionConfig,
929
+ isSVG,
916
930
  });
917
931
  }
918
932
  const visualElement = visualElementRef.current;
@@ -1028,10 +1042,14 @@ function getClosestProjectingNode(visualElement) {
1028
1042
  * Alongside this is a config option which provides a way of rendering the provided
1029
1043
  * component "offline", or outside the React render cycle.
1030
1044
  */
1031
- function createMotionComponent(Component, { forwardMotionProps = false } = {}, preloadedFeatures, createVisualElement) {
1032
- const useVisualState = isSVGComponent(Component)
1033
- ? useSVGVisualState
1034
- : useHTMLVisualState;
1045
+ function createMotionComponent(Component, { forwardMotionProps = false, type } = {}, preloadedFeatures, createVisualElement) {
1046
+ /**
1047
+ * Determine whether to use SVG or HTML rendering based on:
1048
+ * 1. Explicit `type` option (highest priority)
1049
+ * 2. Auto-detection via `isSVGComponent`
1050
+ */
1051
+ const isSVG = type ? type === "svg" : isSVGComponent(Component);
1052
+ const useVisualState = isSVG ? useSVGVisualState : useHTMLVisualState;
1035
1053
  function MotionDOMComponent(props, externalRef) {
1036
1054
  /**
1037
1055
  * If we need to measure the element we load this functionality in a
@@ -1056,13 +1074,13 @@ function createMotionComponent(Component, { forwardMotionProps = false } = {}, p
1056
1074
  * providing a way of rendering to these APIs outside of the React render loop
1057
1075
  * for more performant animations and interactions
1058
1076
  */
1059
- context.visualElement = useVisualElement(Component, visualState, configAndProps, createVisualElement, layoutProjection.ProjectionNode);
1077
+ context.visualElement = useVisualElement(Component, visualState, configAndProps, createVisualElement, layoutProjection.ProjectionNode, isSVG);
1060
1078
  }
1061
1079
  /**
1062
1080
  * The mount order and hierarchy is specific to ensure our element ref
1063
1081
  * is hydrated by the time features fire their effects.
1064
1082
  */
1065
- 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)] }));
1083
+ 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)] }));
1066
1084
  }
1067
1085
  MotionDOMComponent.displayName = `motion.${typeof Component === "string"
1068
1086
  ? Component