@eightshift/ui-components 6.0.8 → 6.0.10

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 (98) hide show
  1. package/dist/{Button-BXjXzdW_.js → Button-JRIu2BnS.js} +8 -8
  2. package/dist/{Dialog-D8bjn-nh.js → Dialog-Dd1yqNus.js} +31 -27
  3. package/dist/{FieldError-DwBG6m1U.js → FieldError-DmVwL6Dj.js} +2 -2
  4. package/dist/{FocusScope-BMk5oZCk.js → FocusScope-Dri1oBcH.js} +2 -2
  5. package/dist/{Heading-BmRX4BRL.js → Heading-eA6LXIKB.js} +1 -1
  6. package/dist/{Input-CNNksOWg.js → Input-Cuw9UbNb.js} +14 -24
  7. package/dist/{Label-D8a3eYb-.js → Label-DPWyf-gp.js} +1 -1
  8. package/dist/{List-BGHOoFf0.js → List-CWheI3JH.js} +1 -1
  9. package/dist/{ListBox-Dd37zMvs.js → ListBox-DT1sFY3e.js} +17 -16
  10. package/dist/{OverlayArrow-DokC40S3.js → OverlayArrow-DVJTTfZM.js} +67 -123
  11. package/dist/{RadioGroup-BVFvITWO.js → RadioGroup-Cp5cdBI_.js} +14 -14
  12. package/dist/{SearchField-CHYnN-jt.js → SearchField-CLhr5PGZ.js} +44 -37
  13. package/dist/{SelectionManager-N8X7T_4D.js → SelectionManager-DbBiF5M8.js} +41 -68
  14. package/dist/{SharedElementTransition-BDT84GtD.js → SharedElementTransition-B_vnQ1uR.js} +1 -1
  15. package/dist/{Slider-CL5CM9S8.js → Slider-CZV3HhHY.js} +119 -83
  16. package/dist/{Text-ztX6G1zR.js → Text-Dae33gHp.js} +1 -1
  17. package/dist/{VisuallyHidden-DTUuKFiI.js → VisuallyHidden-eaCBtXhE.js} +2 -2
  18. package/dist/animation-DY7CNkr6.js +67 -0
  19. package/dist/assets/style-admin.css +44 -57
  20. package/dist/assets/style-editor.css +44 -57
  21. package/dist/assets/style.css +44 -57
  22. package/dist/assets/wp-overrides/allow-full-width-blocks.css +1 -1
  23. package/dist/assets/wp-overrides/fix-label-text-case.css +1 -1
  24. package/dist/assets/wp-overrides/increase-sidebar-width.css +1 -1
  25. package/dist/assets/wp-overrides/make-block-messages-nicer.css +1 -1
  26. package/dist/assets/wp-overrides/replace-fonts.css +1 -1
  27. package/dist/assets/wp-overrides/restyle-tooltips.css +1 -1
  28. package/dist/assets/wp-overrides/round-corners.css +1 -1
  29. package/dist/assets/wp-overrides/unify-button-sizes.css +1 -1
  30. package/dist/{color-swatch-BEBLRxTy.js → color-swatch-CZj0jHZd.js} +4 -4
  31. package/dist/components/animated-visibility/animated-visibility.js +2 -2
  32. package/dist/components/base-control/base-control.js +1 -1
  33. package/dist/components/button/button.js +5 -5
  34. package/dist/components/checkbox/checkbox.js +10 -10
  35. package/dist/components/color-pickers/color-picker.js +1 -1
  36. package/dist/components/color-pickers/color-swatch.js +1 -1
  37. package/dist/components/color-pickers/gradient-editor.js +2 -2
  38. package/dist/components/color-pickers/solid-color-picker.js +17 -17
  39. package/dist/components/draggable/draggable.js +329 -156
  40. package/dist/components/draggable-list/draggable-list.js +1 -1
  41. package/dist/components/expandable/expandable.js +16 -13
  42. package/dist/components/index.js +1 -1
  43. package/dist/components/input-field/input-field.js +8 -8
  44. package/dist/components/link-input/link-input.js +25 -25
  45. package/dist/components/matrix-align/matrix-align.js +1 -1
  46. package/dist/components/menu/menu.js +1 -1
  47. package/dist/components/modal/modal.js +19 -12
  48. package/dist/components/number-picker/number-picker.js +9 -9
  49. package/dist/components/options-panel/options-panel.js +1 -1
  50. package/dist/components/popover/popover.js +5 -5
  51. package/dist/components/radio/radio.js +2 -2
  52. package/dist/components/repeater/repeater.js +1 -1
  53. package/dist/components/responsive/mini-responsive.js +1 -1
  54. package/dist/components/select/async-multi-select.js +10 -10
  55. package/dist/components/select/async-select.js +10 -10
  56. package/dist/components/select/multi-select.js +10 -10
  57. package/dist/components/select/shared.js +3 -3
  58. package/dist/components/select/single-select.js +10 -10
  59. package/dist/components/slider/column-config-slider.js +3 -3
  60. package/dist/components/slider/slider.js +3 -3
  61. package/dist/components/smart-image/smart-image.js +1 -1
  62. package/dist/components/smart-image/worker-inline.js +1 -1
  63. package/dist/components/tabs/tabs.js +36 -17
  64. package/dist/components/toggle/switch.js +7 -7
  65. package/dist/components/toggle/toggle.js +1 -1
  66. package/dist/components/toggle-button/toggle-button.js +6 -6
  67. package/dist/components/tooltip/tooltip.js +10 -8
  68. package/dist/{context-BQvmiUqb.js → context-DYYO3Ns3.js} +9 -6
  69. package/dist/{filterDOMProps-D2C6R0DK.js → filterDOMProps-eGTqWSTd.js} +1 -1
  70. package/dist/{general-ChNQK6O9.js → general-C8Q0dvEx.js} +15 -14
  71. package/dist/{index-oFgxU4zs.js → index-sSixe2j_.js} +20 -20
  72. package/dist/index.js +1 -1
  73. package/dist/{proxy-DkQpcQgI.js → proxy-CcjltLEW.js} +272 -121
  74. package/dist/{shared-DOxXagm0.js → shared-Bg9lx3pE.js} +20 -20
  75. package/dist/{textSelection-CwHUtNVX.js → textSelection-Cq_Br7RW.js} +1 -1
  76. package/dist/{useAsyncList-D52mQcrH.js → useAsyncList-DsZvQXls.js} +5 -2
  77. package/dist/{useButton-DdZrS1Kz.js → useButton-CeuyDay5.js} +4 -4
  78. package/dist/{useEvent-BD7Olibq.js → useEvent-DoWvho2u.js} +2 -3
  79. package/dist/{useFilter-bhxeEDg8.js → useFilter-DYtfYPua.js} +1 -1
  80. package/dist/{useFocusRing-D3b7Kh4P.js → useFocusRing-WEswknAY.js} +1 -1
  81. package/dist/{useFormReset-WUv2PdFO.js → useFormReset-BDF1K4E4.js} +2 -3
  82. package/dist/{useFormValidation-DQeXkyLm.js → useFormValidation-Dqzjv4jX.js} +2 -5
  83. package/dist/{useHover-Bycb7BsD.js → useHover-CG39Ci3A.js} +164 -66
  84. package/dist/{useLabel-Bnv4-T24.js → useLabel--3fT2XKM.js} +2 -2
  85. package/dist/{useLabels-B49ptFDX.js → useLabels-vzdDMGCX.js} +1 -1
  86. package/dist/{useListState-ZKhRO8ML.js → useListState-Bya9g7W8.js} +1 -1
  87. package/dist/{useLocalizedStringFormatter-NETP-8H8.js → useLocalizedStringFormatter-M3L6Ge2c.js} +3 -3
  88. package/dist/{useNumberField-D2fUHql3.js → useNumberField-D6lsi3Vu.js} +91 -24
  89. package/dist/{useNumberFormatter-DGvuRCn7.js → useNumberFormatter-BWOyCamK.js} +1 -1
  90. package/dist/{usePress-B8OteQMu.js → usePress-B9w0X4Ur.js} +168 -180
  91. package/dist/{useSingleSelectListState-BBTu4shO.js → useSingleSelectListState-D9SqGLJ0.js} +2 -2
  92. package/dist/{useToggle-BZhaYwZl.js → useToggle-Deq2xxQV.js} +5 -5
  93. package/dist/{useToggleState-VkXJjsru.js → useToggleState-j3o1PvdS.js} +1 -1
  94. package/dist/utilities/general.js +1 -1
  95. package/dist/utilities/index.js +1 -1
  96. package/dist/{utils-DGpXyJOJ.js → utils-HC9_3Crc.js} +20 -31
  97. package/dist/workers/image-analysis.worker.js +1 -1
  98. package/package.json +24 -28
@@ -35,7 +35,7 @@ let warning = () => {
35
35
  };
36
36
  let invariant = () => {
37
37
  };
38
- if (process.env.NODE_ENV !== "production") {
38
+ if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") {
39
39
  warning = (check, message, errorCode) => {
40
40
  if (!check && typeof console !== "undefined") {
41
41
  console.warn(formatErrorMessage(message, errorCode));
@@ -341,6 +341,11 @@ const isCSSVariableToken = (value) => {
341
341
  return singleCssVariableRegex.test(value.split("/*")[0].trim());
342
342
  };
343
343
  const singleCssVariableRegex = /var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;
344
+ function containsCSSVariable(value) {
345
+ if (typeof value !== "string")
346
+ return false;
347
+ return value.split("/*")[0].includes("var(--");
348
+ }
344
349
  const number = {
345
350
  test: (v) => typeof v === "number",
346
351
  parse: parseFloat,
@@ -1717,6 +1722,7 @@ class NativeAnimation extends WithPromise {
1717
1722
  super();
1718
1723
  this.finishedTime = null;
1719
1724
  this.isStopped = false;
1725
+ this.manualStartTime = null;
1720
1726
  if (!options)
1721
1727
  return;
1722
1728
  const { element, name, keyframes: keyframes2, pseudoElement, allowFlatten = false, finalKeyframe, onComplete } = options;
@@ -1747,6 +1753,7 @@ class NativeAnimation extends WithPromise {
1747
1753
  play() {
1748
1754
  if (this.isStopped)
1749
1755
  return;
1756
+ this.manualStartTime = null;
1750
1757
  this.animation.play();
1751
1758
  if (this.state === "finished") {
1752
1759
  this.updateFinished();
@@ -1809,6 +1816,7 @@ class NativeAnimation extends WithPromise {
1809
1816
  return /* @__PURE__ */ millisecondsToSeconds(Number(this.animation.currentTime) || 0);
1810
1817
  }
1811
1818
  set time(newTime) {
1819
+ this.manualStartTime = null;
1812
1820
  this.finishedTime = null;
1813
1821
  this.animation.currentTime = /* @__PURE__ */ secondsToMilliseconds(newTime);
1814
1822
  }
@@ -1828,10 +1836,10 @@ class NativeAnimation extends WithPromise {
1828
1836
  return this.finishedTime !== null ? "finished" : this.animation.playState;
1829
1837
  }
1830
1838
  get startTime() {
1831
- return Number(this.animation.startTime);
1839
+ return this.manualStartTime ?? Number(this.animation.startTime);
1832
1840
  }
1833
1841
  set startTime(newStartTime) {
1834
- this.animation.startTime = newStartTime;
1842
+ this.manualStartTime = this.animation.startTime = newStartTime;
1835
1843
  }
1836
1844
  /**
1837
1845
  * Attaches a timeline to the animation, for instance the `ScrollTimeline`.
@@ -1868,7 +1876,7 @@ class NativeAnimationExtended extends NativeAnimation {
1868
1876
  replaceStringEasing(options);
1869
1877
  replaceTransitionType(options);
1870
1878
  super(options);
1871
- if (options.startTime) {
1879
+ if (options.startTime !== void 0) {
1872
1880
  this.startTime = options.startTime;
1873
1881
  }
1874
1882
  this.options = options;
@@ -1876,7 +1884,7 @@ class NativeAnimationExtended extends NativeAnimation {
1876
1884
  /**
1877
1885
  * WAAPI doesn't natively have any interruption capabilities.
1878
1886
  *
1879
- * Rather than read commited styles back out of the DOM, we can
1887
+ * Rather than read committed styles back out of the DOM, we can
1880
1888
  * create a renderless JS animation and sample it twice to calculate
1881
1889
  * its current value, "previous" value, and therefore allow
1882
1890
  * Motion to calculate velocity for any subsequent animation.
@@ -1893,8 +1901,9 @@ class NativeAnimationExtended extends NativeAnimation {
1893
1901
  ...options,
1894
1902
  autoplay: false
1895
1903
  });
1896
- const sampleTime = /* @__PURE__ */ secondsToMilliseconds(this.finishedTime ?? this.time);
1897
- motionValue2.setWithVelocity(sampleAnimation.sample(sampleTime - sampleDelta).value, sampleAnimation.sample(sampleTime).value, sampleDelta);
1904
+ const sampleTime = Math.max(sampleDelta, time.now() - this.startTime);
1905
+ const delta = clamp(0, sampleDelta, sampleTime - sampleDelta);
1906
+ motionValue2.setWithVelocity(sampleAnimation.sample(Math.max(0, sampleTime - delta)).value, sampleAnimation.sample(sampleTime).value, delta);
1898
1907
  sampleAnimation.stop();
1899
1908
  }
1900
1909
  }
@@ -2210,17 +2219,36 @@ const numberValueTypes = {
2210
2219
  right: px,
2211
2220
  bottom: px,
2212
2221
  left: px,
2222
+ inset: px,
2223
+ insetBlock: px,
2224
+ insetBlockStart: px,
2225
+ insetBlockEnd: px,
2226
+ insetInline: px,
2227
+ insetInlineStart: px,
2228
+ insetInlineEnd: px,
2213
2229
  // Spacing props
2214
2230
  padding: px,
2215
2231
  paddingTop: px,
2216
2232
  paddingRight: px,
2217
2233
  paddingBottom: px,
2218
2234
  paddingLeft: px,
2235
+ paddingBlock: px,
2236
+ paddingBlockStart: px,
2237
+ paddingBlockEnd: px,
2238
+ paddingInline: px,
2239
+ paddingInlineStart: px,
2240
+ paddingInlineEnd: px,
2219
2241
  margin: px,
2220
2242
  marginTop: px,
2221
2243
  marginRight: px,
2222
2244
  marginBottom: px,
2223
2245
  marginLeft: px,
2246
+ marginBlock: px,
2247
+ marginBlockStart: px,
2248
+ marginBlockEnd: px,
2249
+ marginInline: px,
2250
+ marginInlineStart: px,
2251
+ marginInlineEnd: px,
2224
2252
  // Misc
2225
2253
  backgroundPositionX: px,
2226
2254
  backgroundPositionY: px,
@@ -2303,6 +2331,12 @@ class DOMKeyframesResolver extends KeyframeResolver {
2303
2331
  const [origin, target] = unresolvedKeyframes;
2304
2332
  const originType = findDimensionValueType(origin);
2305
2333
  const targetType = findDimensionValueType(target);
2334
+ const originHasVar = containsCSSVariable(origin);
2335
+ const targetHasVar = containsCSSVariable(target);
2336
+ if (originHasVar !== targetHasVar && positionalValues[name]) {
2337
+ this.needsMeasurement = true;
2338
+ return;
2339
+ }
2306
2340
  if (originType === targetType)
2307
2341
  return;
2308
2342
  if (isNumOrPxType(originType) && isNumOrPxType(targetType)) {
@@ -2736,7 +2770,7 @@ const isPrimaryPointer = (event) => {
2736
2770
  return event.isPrimary !== false;
2737
2771
  }
2738
2772
  };
2739
- const focusableElements = /* @__PURE__ */ new Set([
2773
+ const interactiveElements = /* @__PURE__ */ new Set([
2740
2774
  "BUTTON",
2741
2775
  "INPUT",
2742
2776
  "SELECT",
@@ -2744,7 +2778,7 @@ const focusableElements = /* @__PURE__ */ new Set([
2744
2778
  "A"
2745
2779
  ]);
2746
2780
  function isElementKeyboardAccessible(element) {
2747
- return focusableElements.has(element.tagName) || element.tabIndex !== -1;
2781
+ return interactiveElements.has(element.tagName) || element.isContentEditable === true;
2748
2782
  }
2749
2783
  const isPressing = /* @__PURE__ */ new WeakSet();
2750
2784
  function filterEvents(callback) {
@@ -2903,7 +2937,8 @@ function PopChild({ children, isPresent, anchorX, root }) {
2903
2937
  right: 0
2904
2938
  });
2905
2939
  const { nonce } = useContext(MotionConfigContext);
2906
- const composedRef = useComposedRefs(ref, children?.ref);
2940
+ const childRef = children.props?.ref ?? children?.ref;
2941
+ const composedRef = useComposedRefs(ref, childRef);
2907
2942
  useInsertionEffect(() => {
2908
2943
  const { width, height, top, left, right } = size.current;
2909
2944
  if (isPresent || !ref.current || !width || !height)
@@ -3006,6 +3041,7 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, pre
3006
3041
  const isInitialRender = useRef(true);
3007
3042
  const pendingPresentChildren = useRef(presentChildren);
3008
3043
  const exitComplete = useConstant(() => /* @__PURE__ */ new Map());
3044
+ const exitingComponents = useRef(/* @__PURE__ */ new Set());
3009
3045
  const [diffedChildren, setDiffedChildren] = useState(presentChildren);
3010
3046
  const [renderedChildren, setRenderedChildren] = useState(presentChildren);
3011
3047
  useIsomorphicLayoutEffect(() => {
@@ -3019,6 +3055,7 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, pre
3019
3055
  }
3020
3056
  } else {
3021
3057
  exitComplete.delete(key);
3058
+ exitingComponents.current.delete(key);
3022
3059
  }
3023
3060
  }
3024
3061
  }, [renderedChildren, presentKeys.length, presentKeys.join("-")]);
@@ -3048,6 +3085,10 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, pre
3048
3085
  const key = getChildKey(child);
3049
3086
  const isPresent = propagate && !isParentPresent ? false : presentChildren === renderedChildren || presentKeys.includes(key);
3050
3087
  const onExit = () => {
3088
+ if (exitingComponents.current.has(key)) {
3089
+ return;
3090
+ }
3091
+ exitingComponents.current.add(key);
3051
3092
  if (exitComplete.has(key)) {
3052
3093
  exitComplete.set(key, true);
3053
3094
  } else {
@@ -3200,15 +3241,63 @@ function useCreateMotionContext(props) {
3200
3241
  function variantLabelsAsDependency(prop) {
3201
3242
  return Array.isArray(prop) ? prop.join(" ") : prop;
3202
3243
  }
3203
- const scaleCorrectors = {};
3204
- function addScaleCorrector(correctors) {
3205
- for (const key in correctors) {
3206
- scaleCorrectors[key] = correctors[key];
3207
- if (isCSSVariableName(key)) {
3208
- scaleCorrectors[key].isCSSVariable = true;
3244
+ function pixelsToPercent(pixels, axis) {
3245
+ if (axis.max === axis.min)
3246
+ return 0;
3247
+ return pixels / (axis.max - axis.min) * 100;
3248
+ }
3249
+ const correctBorderRadius = {
3250
+ correct: (latest, node) => {
3251
+ if (!node.target)
3252
+ return latest;
3253
+ if (typeof latest === "string") {
3254
+ if (px.test(latest)) {
3255
+ latest = parseFloat(latest);
3256
+ } else {
3257
+ return latest;
3258
+ }
3209
3259
  }
3260
+ const x = pixelsToPercent(latest, node.target.x);
3261
+ const y = pixelsToPercent(latest, node.target.y);
3262
+ return `${x}% ${y}%`;
3210
3263
  }
3211
- }
3264
+ };
3265
+ const correctBoxShadow = {
3266
+ correct: (latest, { treeScale, projectionDelta }) => {
3267
+ const original = latest;
3268
+ const shadow = complex.parse(latest);
3269
+ if (shadow.length > 5)
3270
+ return original;
3271
+ const template = complex.createTransformer(latest);
3272
+ const offset = typeof shadow[0] !== "number" ? 1 : 0;
3273
+ const xScale = projectionDelta.x.scale * treeScale.x;
3274
+ const yScale = projectionDelta.y.scale * treeScale.y;
3275
+ shadow[0 + offset] /= xScale;
3276
+ shadow[1 + offset] /= yScale;
3277
+ const averageScale = mixNumber$1(xScale, yScale, 0.5);
3278
+ if (typeof shadow[2 + offset] === "number")
3279
+ shadow[2 + offset] /= averageScale;
3280
+ if (typeof shadow[3 + offset] === "number")
3281
+ shadow[3 + offset] /= averageScale;
3282
+ return template(shadow);
3283
+ }
3284
+ };
3285
+ const scaleCorrectors = {
3286
+ borderRadius: {
3287
+ ...correctBorderRadius,
3288
+ applyTo: [
3289
+ "borderTopLeftRadius",
3290
+ "borderTopRightRadius",
3291
+ "borderBottomLeftRadius",
3292
+ "borderBottomRightRadius"
3293
+ ]
3294
+ },
3295
+ borderTopLeftRadius: correctBorderRadius,
3296
+ borderTopRightRadius: correctBorderRadius,
3297
+ borderBottomLeftRadius: correctBorderRadius,
3298
+ borderBottomRightRadius: correctBorderRadius,
3299
+ boxShadow: correctBoxShadow
3300
+ };
3212
3301
  function isForcedMotionValue(key, { layout: layout2, layoutId }) {
3213
3302
  return transformProps.has(key) || key.startsWith("origin") || (layout2 || layoutId !== void 0) && (!!scaleCorrectors[key] || key === "opacity");
3214
3303
  }
@@ -3344,6 +3433,12 @@ function buildSVGPath(attrs, length, spacing = 1, offset = 0, useDashCase = true
3344
3433
  const pathSpacing = px.transform(spacing);
3345
3434
  attrs[keys.array] = `${pathLength} ${pathSpacing}`;
3346
3435
  }
3436
+ const cssMotionPathProperties = [
3437
+ "offsetDistance",
3438
+ "offsetPath",
3439
+ "offsetRotate",
3440
+ "offsetAnchor"
3441
+ ];
3347
3442
  function buildSVGAttrs(state, {
3348
3443
  attrX,
3349
3444
  attrY,
@@ -3376,6 +3471,12 @@ function buildSVGAttrs(state, {
3376
3471
  style.transformBox = styleProp?.transformBox ?? "fill-box";
3377
3472
  delete attrs.transformBox;
3378
3473
  }
3474
+ for (const key of cssMotionPathProperties) {
3475
+ if (attrs[key] !== void 0) {
3476
+ style[key] = attrs[key];
3477
+ delete attrs[key];
3478
+ }
3479
+ }
3379
3480
  if (attrX !== void 0)
3380
3481
  attrs.x = attrX;
3381
3482
  if (attrY !== void 0)
@@ -3459,8 +3560,8 @@ function isSVGComponent(Component2) {
3459
3560
  }
3460
3561
  return false;
3461
3562
  }
3462
- function useRender(Component2, props, ref, { latestValues }, isStatic, forwardMotionProps = false) {
3463
- const useVisualProps = isSVGComponent(Component2) ? useSVGProps : useHTMLProps;
3563
+ function useRender(Component2, props, ref, { latestValues }, isStatic, forwardMotionProps = false, isSVG) {
3564
+ const useVisualProps = isSVG ?? isSVGComponent(Component2) ? useSVGProps : useHTMLProps;
3464
3565
  const visualProps = useVisualProps(props, latestValues, isStatic, Component2);
3465
3566
  const filteredProps = filterProps(props, typeof Component2 === "string", forwardMotionProps);
3466
3567
  const elementProps = Component2 !== Fragment$1 ? { ...filteredProps, ...visualProps, ref } : {};
@@ -3579,43 +3680,46 @@ const useSVGVisualState = /* @__PURE__ */ makeUseVisualState({
3579
3680
  scrapeMotionValuesFromProps,
3580
3681
  createRenderState: createSvgRenderState
3581
3682
  });
3582
- const motionComponentSymbol = Symbol.for("motionComponentSymbol");
3583
- function isRefObject(ref) {
3584
- return ref && typeof ref === "object" && Object.prototype.hasOwnProperty.call(ref, "current");
3585
- }
3683
+ const motionComponentSymbol = /* @__PURE__ */ Symbol.for("motionComponentSymbol");
3586
3684
  function useMotionRef(visualState, visualElement, externalRef) {
3587
- return useCallback(
3588
- (instance) => {
3685
+ const externalRefContainer = useRef(externalRef);
3686
+ useInsertionEffect(() => {
3687
+ externalRefContainer.current = externalRef;
3688
+ });
3689
+ const refCleanup = useRef(null);
3690
+ return useCallback((instance) => {
3691
+ if (instance) {
3692
+ visualState.onMount?.(instance);
3693
+ }
3694
+ if (visualElement) {
3695
+ instance ? visualElement.mount(instance) : visualElement.unmount();
3696
+ }
3697
+ const ref = externalRefContainer.current;
3698
+ if (typeof ref === "function") {
3589
3699
  if (instance) {
3590
- visualState.onMount && visualState.onMount(instance);
3591
- }
3592
- if (visualElement) {
3593
- if (instance) {
3594
- visualElement.mount(instance);
3595
- } else {
3596
- visualElement.unmount();
3597
- }
3598
- }
3599
- if (externalRef) {
3600
- if (typeof externalRef === "function") {
3601
- externalRef(instance);
3602
- } else if (isRefObject(externalRef)) {
3603
- externalRef.current = instance;
3700
+ const cleanup = ref(instance);
3701
+ if (typeof cleanup === "function") {
3702
+ refCleanup.current = cleanup;
3604
3703
  }
3704
+ } else if (refCleanup.current) {
3705
+ refCleanup.current();
3706
+ refCleanup.current = null;
3707
+ } else {
3708
+ ref(instance);
3605
3709
  }
3606
- },
3607
- /**
3608
- * Include externalRef in dependencies to ensure the callback updates
3609
- * when the ref changes, allowing proper ref forwarding.
3610
- */
3611
- [visualElement]
3612
- );
3710
+ } else if (ref) {
3711
+ ref.current = instance;
3712
+ }
3713
+ }, [visualElement]);
3613
3714
  }
3614
3715
  const camelToDash = (str) => str.replace(/([a-z])([A-Z])/gu, "$1-$2").toLowerCase();
3615
3716
  const optimizedAppearDataId = "framerAppearId";
3616
3717
  const optimizedAppearDataAttribute = "data-" + camelToDash(optimizedAppearDataId);
3617
3718
  const SwitchLayoutGroupContext = createContext({});
3618
- function useVisualElement(Component2, visualState, props, createVisualElement, ProjectionNodeConstructor) {
3719
+ function isRefObject(ref) {
3720
+ return ref && typeof ref === "object" && Object.prototype.hasOwnProperty.call(ref, "current");
3721
+ }
3722
+ function useVisualElement(Component2, visualState, props, createVisualElement, ProjectionNodeConstructor, isSVG) {
3619
3723
  const { visualElement: parent } = useContext(MotionContext);
3620
3724
  const lazyContext = useContext(LazyContext);
3621
3725
  const presenceContext = useContext(PresenceContext);
@@ -3629,7 +3733,8 @@ function useVisualElement(Component2, visualState, props, createVisualElement, P
3629
3733
  props,
3630
3734
  presenceContext,
3631
3735
  blockInitialAnimation: presenceContext ? presenceContext.initial === false : false,
3632
- reducedMotionConfig
3736
+ reducedMotionConfig,
3737
+ isSVG
3633
3738
  });
3634
3739
  }
3635
3740
  const visualElement = visualElementRef.current;
@@ -3699,9 +3804,10 @@ function getClosestProjectingNode(visualElement) {
3699
3804
  return void 0;
3700
3805
  return visualElement.options.allowProjection !== false ? visualElement.projection : getClosestProjectingNode(visualElement.parent);
3701
3806
  }
3702
- function createMotionComponent(Component2, { forwardMotionProps = false } = {}, preloadedFeatures, createVisualElement) {
3807
+ function createMotionComponent(Component2, { forwardMotionProps = false, type } = {}, preloadedFeatures, createVisualElement) {
3703
3808
  preloadedFeatures && loadFeatures(preloadedFeatures);
3704
- const useVisualState = isSVGComponent(Component2) ? useSVGVisualState : useHTMLVisualState;
3809
+ const isSVG = type ? type === "svg" : isSVGComponent(Component2);
3810
+ const useVisualState = isSVG ? useSVGVisualState : useHTMLVisualState;
3705
3811
  function MotionDOMComponent(props, externalRef) {
3706
3812
  let MeasureLayout2;
3707
3813
  const configAndProps = {
@@ -3716,9 +3822,9 @@ function createMotionComponent(Component2, { forwardMotionProps = false } = {},
3716
3822
  useStrictMode(configAndProps, preloadedFeatures);
3717
3823
  const layoutProjection = getProjectionFunctionality(configAndProps);
3718
3824
  MeasureLayout2 = layoutProjection.MeasureLayout;
3719
- context.visualElement = useVisualElement(Component2, visualState, configAndProps, createVisualElement, layoutProjection.ProjectionNode);
3825
+ context.visualElement = useVisualElement(Component2, visualState, configAndProps, createVisualElement, layoutProjection.ProjectionNode, isSVG);
3720
3826
  }
3721
- return jsxs(MotionContext.Provider, { value: context, children: [MeasureLayout2 && context.visualElement ? jsx(MeasureLayout2, { visualElement: context.visualElement, ...configAndProps }) : null, useRender(Component2, props, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, forwardMotionProps)] });
3827
+ return jsxs(MotionContext.Provider, { value: context, children: [MeasureLayout2 && context.visualElement ? jsx(MeasureLayout2, { visualElement: context.visualElement, ...configAndProps }) : null, useRender(Component2, props, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, forwardMotionProps, isSVG)] });
3722
3828
  }
3723
3829
  MotionDOMComponent.displayName = `motion.${typeof Component2 === "string" ? Component2 : `create(${Component2.displayName ?? Component2.name ?? ""})`}`;
3724
3830
  const ForwardRefMotionComponent = forwardRef(MotionDOMComponent);
@@ -4036,10 +4142,16 @@ class VisualElement {
4036
4142
  this.removeFromVariantTree = this.parent.addVariantChild(this);
4037
4143
  }
4038
4144
  this.values.forEach((value, key) => this.bindToMotionValue(key, value));
4039
- if (!hasReducedMotionListener.current) {
4040
- initPrefersReducedMotion();
4145
+ if (this.reducedMotionConfig === "never") {
4146
+ this.shouldReduceMotion = false;
4147
+ } else if (this.reducedMotionConfig === "always") {
4148
+ this.shouldReduceMotion = true;
4149
+ } else {
4150
+ if (!hasReducedMotionListener.current) {
4151
+ initPrefersReducedMotion();
4152
+ }
4153
+ this.shouldReduceMotion = prefersReducedMotion.current;
4041
4154
  }
4042
- this.shouldReduceMotion = this.reducedMotionConfig === "never" ? false : this.reducedMotionConfig === "always" ? true : prefersReducedMotion.current;
4043
4155
  if (process.env.NODE_ENV !== "production") {
4044
4156
  warnOnce(this.shouldReduceMotion !== true, "You have Reduced Motion enabled on your device. Animations may not appear as expected.", "reduced-motion-disabled");
4045
4157
  }
@@ -4443,7 +4555,8 @@ class SVGVisualElement extends DOMVisualElement {
4443
4555
  }
4444
4556
  }
4445
4557
  const createDomVisualElement = (Component2, options) => {
4446
- return isSVGComponent(Component2) ? new SVGVisualElement(options) : new HTMLVisualElement(options, {
4558
+ const isSVG = options.isSVG ?? isSVGComponent(Component2);
4559
+ return isSVG ? new SVGVisualElement(options) : new HTMLVisualElement(options, {
4447
4560
  allowProjection: Component2 !== Fragment$1
4448
4561
  });
4449
4562
  };
@@ -5074,13 +5187,22 @@ function distance2D(a, b) {
5074
5187
  const yDelta = distance(a.y, b.y);
5075
5188
  return Math.sqrt(xDelta ** 2 + yDelta ** 2);
5076
5189
  }
5190
+ const overflowStyles = /* @__PURE__ */ new Set(["auto", "scroll"]);
5077
5191
  class PanSession {
5078
- constructor(event, handlers, { transformPagePoint, contextWindow = window, dragSnapToOrigin = false, distanceThreshold = 3 } = {}) {
5192
+ constructor(event, handlers, { transformPagePoint, contextWindow = window, dragSnapToOrigin = false, distanceThreshold = 3, element } = {}) {
5079
5193
  this.startEvent = null;
5080
5194
  this.lastMoveEvent = null;
5081
5195
  this.lastMoveEventInfo = null;
5082
5196
  this.handlers = {};
5083
5197
  this.contextWindow = window;
5198
+ this.scrollPositions = /* @__PURE__ */ new Map();
5199
+ this.removeScrollListeners = null;
5200
+ this.onElementScroll = (event2) => {
5201
+ this.handleScroll(event2.target);
5202
+ };
5203
+ this.onWindowScroll = () => {
5204
+ this.handleScroll(window);
5205
+ };
5084
5206
  this.updatePoint = () => {
5085
5207
  if (!(this.lastMoveEvent && this.lastMoveEventInfo))
5086
5208
  return;
@@ -5107,8 +5229,9 @@ class PanSession {
5107
5229
  this.handlePointerUp = (event2, info2) => {
5108
5230
  this.end();
5109
5231
  const { onEnd, onSessionEnd, resumeAnimation } = this.handlers;
5110
- if (this.dragSnapToOrigin)
5232
+ if (this.dragSnapToOrigin || !this.startEvent) {
5111
5233
  resumeAnimation && resumeAnimation();
5234
+ }
5112
5235
  if (!(this.lastMoveEvent && this.lastMoveEventInfo))
5113
5236
  return;
5114
5237
  const panInfo = getPanInfo(event2.type === "pointercancel" ? this.lastMoveEventInfo : transformPoint(info2, this.transformPagePoint), this.history);
@@ -5132,12 +5255,82 @@ class PanSession {
5132
5255
  const { onSessionStart } = handlers;
5133
5256
  onSessionStart && onSessionStart(event, getPanInfo(initialInfo, this.history));
5134
5257
  this.removeListeners = pipe(addPointerEvent(this.contextWindow, "pointermove", this.handlePointerMove), addPointerEvent(this.contextWindow, "pointerup", this.handlePointerUp), addPointerEvent(this.contextWindow, "pointercancel", this.handlePointerUp));
5258
+ if (element) {
5259
+ this.startScrollTracking(element);
5260
+ }
5261
+ }
5262
+ /**
5263
+ * Start tracking scroll on ancestors and window.
5264
+ */
5265
+ startScrollTracking(element) {
5266
+ let current = element.parentElement;
5267
+ while (current) {
5268
+ const style = getComputedStyle(current);
5269
+ if (overflowStyles.has(style.overflowX) || overflowStyles.has(style.overflowY)) {
5270
+ this.scrollPositions.set(current, {
5271
+ x: current.scrollLeft,
5272
+ y: current.scrollTop
5273
+ });
5274
+ }
5275
+ current = current.parentElement;
5276
+ }
5277
+ this.scrollPositions.set(window, {
5278
+ x: window.scrollX,
5279
+ y: window.scrollY
5280
+ });
5281
+ window.addEventListener("scroll", this.onElementScroll, {
5282
+ capture: true,
5283
+ passive: true
5284
+ });
5285
+ window.addEventListener("scroll", this.onWindowScroll, {
5286
+ passive: true
5287
+ });
5288
+ this.removeScrollListeners = () => {
5289
+ window.removeEventListener("scroll", this.onElementScroll, {
5290
+ capture: true
5291
+ });
5292
+ window.removeEventListener("scroll", this.onWindowScroll);
5293
+ };
5294
+ }
5295
+ /**
5296
+ * Handle scroll compensation during drag.
5297
+ *
5298
+ * For element scroll: adjusts history origin since pageX/pageY doesn't change.
5299
+ * For window scroll: adjusts lastMoveEventInfo since pageX/pageY would change.
5300
+ */
5301
+ handleScroll(target) {
5302
+ const initial = this.scrollPositions.get(target);
5303
+ if (!initial)
5304
+ return;
5305
+ const isWindow = target === window;
5306
+ const current = isWindow ? { x: window.scrollX, y: window.scrollY } : {
5307
+ x: target.scrollLeft,
5308
+ y: target.scrollTop
5309
+ };
5310
+ const delta = { x: current.x - initial.x, y: current.y - initial.y };
5311
+ if (delta.x === 0 && delta.y === 0)
5312
+ return;
5313
+ if (isWindow) {
5314
+ if (this.lastMoveEventInfo) {
5315
+ this.lastMoveEventInfo.point.x += delta.x;
5316
+ this.lastMoveEventInfo.point.y += delta.y;
5317
+ }
5318
+ } else {
5319
+ if (this.history.length > 0) {
5320
+ this.history[0].x -= delta.x;
5321
+ this.history[0].y -= delta.y;
5322
+ }
5323
+ }
5324
+ this.scrollPositions.set(target, current);
5325
+ frame.update(this.updatePoint, true);
5135
5326
  }
5136
5327
  updateHandlers(handlers) {
5137
5328
  this.handlers = handlers;
5138
5329
  }
5139
5330
  end() {
5140
5331
  this.removeListeners && this.removeListeners();
5332
+ this.removeScrollListeners && this.removeScrollListeners();
5333
+ this.scrollPositions.clear();
5141
5334
  cancelFrame(this.updatePoint);
5142
5335
  }
5143
5336
  }
@@ -5289,13 +5482,15 @@ class VisualElementDragControls {
5289
5482
  if (presenceContext && presenceContext.isPresent === false)
5290
5483
  return;
5291
5484
  const onSessionStart = (event) => {
5292
- const { dragSnapToOrigin: dragSnapToOrigin2 } = this.getProps();
5293
- dragSnapToOrigin2 ? this.pauseAnimation() : this.stopAnimation();
5294
5485
  if (snapToCursor) {
5486
+ this.stopAnimation();
5295
5487
  this.snapToCursor(extractEventInfo(event).point);
5488
+ } else {
5489
+ this.pauseAnimation();
5296
5490
  }
5297
5491
  };
5298
5492
  const onStart = (event, info) => {
5493
+ this.stopAnimation();
5299
5494
  const { drag: drag2, dragPropagation, onDragStart } = this.getProps();
5300
5495
  if (drag2 && !dragPropagation) {
5301
5496
  if (this.openDragLock)
@@ -5372,7 +5567,8 @@ class VisualElementDragControls {
5372
5567
  transformPagePoint: this.visualElement.getTransformPagePoint(),
5373
5568
  dragSnapToOrigin,
5374
5569
  distanceThreshold,
5375
- contextWindow: getContextWindow(this.visualElement)
5570
+ contextWindow: getContextWindow(this.visualElement),
5571
+ element: this.visualElement.current
5376
5572
  });
5377
5573
  }
5378
5574
  /**
@@ -5527,7 +5723,8 @@ class VisualElementDragControls {
5527
5723
  const axisValue = this.getAxisMotionValue(axis);
5528
5724
  if (projection && projection.layout) {
5529
5725
  const { min, max } = projection.layout.layoutBox[axis];
5530
- axisValue.set(point[axis] - mixNumber$1(min, max, 0.5));
5726
+ const current = axisValue.get() || 0;
5727
+ axisValue.set(point[axis] - mixNumber$1(min, max, 0.5) + current);
5531
5728
  }
5532
5729
  });
5533
5730
  }
@@ -5572,7 +5769,9 @@ class VisualElementDragControls {
5572
5769
  const element = this.visualElement.current;
5573
5770
  const stopPointerListener = addPointerEvent(element, "pointerdown", (event) => {
5574
5771
  const { drag: drag2, dragListener = true } = this.getProps();
5575
- drag2 && dragListener && this.start(event);
5772
+ if (drag2 && dragListener && !isElementKeyboardAccessible(event.target)) {
5773
+ this.start(event);
5774
+ }
5576
5775
  });
5577
5776
  const measureDragConstraints = () => {
5578
5777
  const { dragConstraints } = this.getProps();
@@ -5647,6 +5846,16 @@ class DragGesture extends Feature {
5647
5846
  }
5648
5847
  this.removeListeners = this.controls.addListeners() || noop;
5649
5848
  }
5849
+ update() {
5850
+ const { dragControls } = this.node.getProps();
5851
+ const { dragControls: prevDragControls } = this.node.prevProps || {};
5852
+ if (dragControls !== prevDragControls) {
5853
+ this.removeGroupControls();
5854
+ if (dragControls) {
5855
+ this.removeGroupControls = dragControls.subscribe(this.controls);
5856
+ }
5857
+ }
5858
+ }
5650
5859
  unmount() {
5651
5860
  this.removeGroupControls();
5652
5861
  this.removeListeners();
@@ -5705,47 +5914,6 @@ const globalProjectionState = {
5705
5914
  */
5706
5915
  hasEverUpdated: false
5707
5916
  };
5708
- function pixelsToPercent(pixels, axis) {
5709
- if (axis.max === axis.min)
5710
- return 0;
5711
- return pixels / (axis.max - axis.min) * 100;
5712
- }
5713
- const correctBorderRadius = {
5714
- correct: (latest, node) => {
5715
- if (!node.target)
5716
- return latest;
5717
- if (typeof latest === "string") {
5718
- if (px.test(latest)) {
5719
- latest = parseFloat(latest);
5720
- } else {
5721
- return latest;
5722
- }
5723
- }
5724
- const x = pixelsToPercent(latest, node.target.x);
5725
- const y = pixelsToPercent(latest, node.target.y);
5726
- return `${x}% ${y}%`;
5727
- }
5728
- };
5729
- const correctBoxShadow = {
5730
- correct: (latest, { treeScale, projectionDelta }) => {
5731
- const original = latest;
5732
- const shadow = complex.parse(latest);
5733
- if (shadow.length > 5)
5734
- return original;
5735
- const template = complex.createTransformer(latest);
5736
- const offset = typeof shadow[0] !== "number" ? 1 : 0;
5737
- const xScale = projectionDelta.x.scale * treeScale.x;
5738
- const yScale = projectionDelta.y.scale * treeScale.y;
5739
- shadow[0 + offset] /= xScale;
5740
- shadow[1 + offset] /= yScale;
5741
- const averageScale = mixNumber$1(xScale, yScale, 0.5);
5742
- if (typeof shadow[2 + offset] === "number")
5743
- shadow[2 + offset] /= averageScale;
5744
- if (typeof shadow[3 + offset] === "number")
5745
- shadow[3 + offset] /= averageScale;
5746
- return template(shadow);
5747
- }
5748
- };
5749
5917
  let hasTakenAnySnapshot = false;
5750
5918
  class MeasureLayoutWithContext extends Component {
5751
5919
  /**
@@ -5756,7 +5924,6 @@ class MeasureLayoutWithContext extends Component {
5756
5924
  componentDidMount() {
5757
5925
  const { visualElement, layoutGroup, switchLayoutGroup, layoutId } = this.props;
5758
5926
  const { projection } = visualElement;
5759
- addScaleCorrector(defaultScaleCorrectors);
5760
5927
  if (projection) {
5761
5928
  if (layoutGroup.group)
5762
5929
  layoutGroup.group.add(projection);
@@ -5838,22 +6005,6 @@ function MeasureLayout(props) {
5838
6005
  const layoutGroup = useContext(LayoutGroupContext);
5839
6006
  return jsx(MeasureLayoutWithContext, { ...props, layoutGroup, switchLayoutGroup: useContext(SwitchLayoutGroupContext), isPresent, safeToRemove });
5840
6007
  }
5841
- const defaultScaleCorrectors = {
5842
- borderRadius: {
5843
- ...correctBorderRadius,
5844
- applyTo: [
5845
- "borderTopLeftRadius",
5846
- "borderTopRightRadius",
5847
- "borderBottomLeftRadius",
5848
- "borderBottomRightRadius"
5849
- ]
5850
- },
5851
- borderTopLeftRadius: correctBorderRadius,
5852
- borderTopRightRadius: correctBorderRadius,
5853
- borderBottomLeftRadius: correctBorderRadius,
5854
- borderBottomRightRadius: correctBorderRadius,
5855
- boxShadow: correctBoxShadow
5856
- };
5857
6008
  function animateSingleValue(value, keyframes2, options) {
5858
6009
  const motionValue$1 = isMotionValue(value) ? value : motionValue(value);
5859
6010
  motionValue$1.start(animateMotionValue("", motionValue$1, keyframes2, options));