framer-motion 12.0.10 → 12.0.11

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.
@@ -1078,7 +1078,7 @@
1078
1078
  * This will be replaced by the build step with the latest version number.
1079
1079
  * When MotionValues are provided to motion components, warn if versions are mixed.
1080
1080
  */
1081
- this.version = "12.0.10";
1081
+ this.version = "12.0.11";
1082
1082
  /**
1083
1083
  * Tracks whether this value can output a velocity. Currently this is only true
1084
1084
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -5857,7 +5857,7 @@
5857
5857
  * and warn against mismatches.
5858
5858
  */
5859
5859
  {
5860
- warnOnce(nextValue.version === "12.0.10", `Attempting to mix Motion versions ${nextValue.version} with 12.0.10 may not work as expected.`);
5860
+ warnOnce(nextValue.version === "12.0.11", `Attempting to mix Motion versions ${nextValue.version} with 12.0.11 may not work as expected.`);
5861
5861
  }
5862
5862
  }
5863
5863
  else if (isMotionValue(prevValue)) {
@@ -6608,28 +6608,6 @@
6608
6608
  }
6609
6609
  }
6610
6610
 
6611
- const createHtmlRenderState = () => ({
6612
- style: {},
6613
- transform: {},
6614
- transformOrigin: {},
6615
- vars: {},
6616
- });
6617
-
6618
- const createSvgRenderState = () => ({
6619
- ...createHtmlRenderState(),
6620
- attrs: {},
6621
- });
6622
-
6623
- const isSVGTag = (tag) => typeof tag === "string" && tag.toLowerCase() === "svg";
6624
-
6625
- function renderHTML(element, { style, vars }, styleProp, projection) {
6626
- Object.assign(element.style, style, projection && projection.getProjectionStyles(styleProp));
6627
- // Loop over any CSS variables and assign those.
6628
- for (const key in vars) {
6629
- element.style.setProperty(key, vars[key]);
6630
- }
6631
- }
6632
-
6633
6611
  /**
6634
6612
  * A set of attribute names that are always read/written as camel case.
6635
6613
  */
@@ -6659,6 +6637,34 @@
6659
6637
  "lengthAdjust",
6660
6638
  ]);
6661
6639
 
6640
+ const isSVGTag = (tag) => typeof tag === "string" && tag.toLowerCase() === "svg";
6641
+
6642
+ function updateSVGDimensions(instance, renderState) {
6643
+ try {
6644
+ renderState.dimensions =
6645
+ typeof instance.getBBox === "function"
6646
+ ? instance.getBBox()
6647
+ : instance.getBoundingClientRect();
6648
+ }
6649
+ catch (e) {
6650
+ // Most likely trying to measure an unrendered element under Firefox
6651
+ renderState.dimensions = {
6652
+ x: 0,
6653
+ y: 0,
6654
+ width: 0,
6655
+ height: 0,
6656
+ };
6657
+ }
6658
+ }
6659
+
6660
+ function renderHTML(element, { style, vars }, styleProp, projection) {
6661
+ Object.assign(element.style, style, projection && projection.getProjectionStyles(styleProp));
6662
+ // Loop over any CSS variables and assign those.
6663
+ for (const key in vars) {
6664
+ element.style.setProperty(key, vars[key]);
6665
+ }
6666
+ }
6667
+
6662
6668
  function renderSVG(element, renderState, _styleProp, projection) {
6663
6669
  renderHTML(element, renderState, undefined, projection);
6664
6670
  for (const key in renderState.attrs) {
@@ -6713,69 +6719,6 @@
6713
6719
  return newValues;
6714
6720
  }
6715
6721
 
6716
- function updateSVGDimensions(instance, renderState) {
6717
- try {
6718
- renderState.dimensions =
6719
- typeof instance.getBBox === "function"
6720
- ? instance.getBBox()
6721
- : instance.getBoundingClientRect();
6722
- }
6723
- catch (e) {
6724
- // Most likely trying to measure an unrendered element under Firefox
6725
- renderState.dimensions = {
6726
- x: 0,
6727
- y: 0,
6728
- width: 0,
6729
- height: 0,
6730
- };
6731
- }
6732
- }
6733
- const layoutProps = ["x", "y", "width", "height", "cx", "cy", "r"];
6734
- const svgMotionConfig = {
6735
- useVisualState: makeUseVisualState({
6736
- scrapeMotionValuesFromProps: scrapeMotionValuesFromProps,
6737
- createRenderState: createSvgRenderState,
6738
- onUpdate: ({ props, prevProps, current, renderState, latestValues, }) => {
6739
- if (!current)
6740
- return;
6741
- let hasTransform = !!props.drag;
6742
- if (!hasTransform) {
6743
- for (const key in latestValues) {
6744
- if (transformProps.has(key)) {
6745
- hasTransform = true;
6746
- break;
6747
- }
6748
- }
6749
- }
6750
- if (!hasTransform)
6751
- return;
6752
- let needsMeasure = !prevProps;
6753
- if (prevProps) {
6754
- /**
6755
- * Check the layout props for changes, if any are found we need to
6756
- * measure the element again.
6757
- */
6758
- for (let i = 0; i < layoutProps.length; i++) {
6759
- const key = layoutProps[i];
6760
- if (props[key] !==
6761
- prevProps[key]) {
6762
- needsMeasure = true;
6763
- }
6764
- }
6765
- }
6766
- if (!needsMeasure)
6767
- return;
6768
- frame.read(() => {
6769
- updateSVGDimensions(current, renderState);
6770
- frame.render(() => {
6771
- buildSVGAttrs(renderState, latestValues, isSVGTag(current.tagName), props.transformTemplate);
6772
- renderSVG(current, renderState);
6773
- });
6774
- });
6775
- },
6776
- }),
6777
- };
6778
-
6779
6722
  class SVGVisualElement extends DOMVisualElement {
6780
6723
  constructor() {
6781
6724
  super(...arguments);
@@ -11727,6 +11670,13 @@
11727
11670
  };
11728
11671
  }
11729
11672
 
11673
+ const createHtmlRenderState = () => ({
11674
+ style: {},
11675
+ transform: {},
11676
+ transformOrigin: {},
11677
+ vars: {},
11678
+ });
11679
+
11730
11680
  function copyRawValuesOnly(target, source, props) {
11731
11681
  for (const key in source) {
11732
11682
  if (!isMotionValue(source[key]) && !isForcedMotionValue(key, props)) {
@@ -11836,6 +11786,11 @@
11836
11786
  return false;
11837
11787
  }
11838
11788
 
11789
+ const createSvgRenderState = () => ({
11790
+ ...createHtmlRenderState(),
11791
+ attrs: {},
11792
+ });
11793
+
11839
11794
  function useSVGProps(props, visualState, _isStatic, Component) {
11840
11795
  const visualProps = React$1.useMemo(() => {
11841
11796
  const state = createSvgRenderState();
@@ -11885,6 +11840,52 @@
11885
11840
  }),
11886
11841
  };
11887
11842
 
11843
+ const layoutProps = ["x", "y", "width", "height", "cx", "cy", "r"];
11844
+ const svgMotionConfig = {
11845
+ useVisualState: makeUseVisualState({
11846
+ scrapeMotionValuesFromProps: scrapeMotionValuesFromProps,
11847
+ createRenderState: createSvgRenderState,
11848
+ onUpdate: ({ props, prevProps, current, renderState, latestValues, }) => {
11849
+ if (!current)
11850
+ return;
11851
+ let hasTransform = !!props.drag;
11852
+ if (!hasTransform) {
11853
+ for (const key in latestValues) {
11854
+ if (transformProps.has(key)) {
11855
+ hasTransform = true;
11856
+ break;
11857
+ }
11858
+ }
11859
+ }
11860
+ if (!hasTransform)
11861
+ return;
11862
+ let needsMeasure = !prevProps;
11863
+ if (prevProps) {
11864
+ /**
11865
+ * Check the layout props for changes, if any are found we need to
11866
+ * measure the element again.
11867
+ */
11868
+ for (let i = 0; i < layoutProps.length; i++) {
11869
+ const key = layoutProps[i];
11870
+ if (props[key] !==
11871
+ prevProps[key]) {
11872
+ needsMeasure = true;
11873
+ }
11874
+ }
11875
+ }
11876
+ if (!needsMeasure)
11877
+ return;
11878
+ frame.read(() => {
11879
+ updateSVGDimensions(current, renderState);
11880
+ frame.render(() => {
11881
+ buildSVGAttrs(renderState, latestValues, isSVGTag(current.tagName), props.transformTemplate);
11882
+ renderSVG(current, renderState);
11883
+ });
11884
+ });
11885
+ },
11886
+ }),
11887
+ };
11888
+
11888
11889
  function createMotionComponentFactory(preloadedFeatures, createVisualElement) {
11889
11890
  return function createMotionComponent(Component, { forwardMotionProps } = { forwardMotionProps: false }) {
11890
11891
  const baseConfig = isSVGComponent(Component)