@eightshift/ui-components 6.0.13 → 6.1.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 (97) hide show
  1. package/dist/{Button-JRIu2BnS.js → Button-CFnNdpNZ.js} +9 -9
  2. package/dist/{Dialog-Dd1yqNus.js → Dialog-D0jMcN-a.js} +79 -60
  3. package/dist/{FieldError-DmVwL6Dj.js → FieldError-BPG0hKfB.js} +2 -2
  4. package/dist/{FocusScope-Dri1oBcH.js → FocusScope-BJhC1-1e.js} +6 -7
  5. package/dist/{Heading-eA6LXIKB.js → Heading-CY-_gt-U.js} +2 -2
  6. package/dist/{Input-Cuw9UbNb.js → Input-B4X6-x6r.js} +8 -8
  7. package/dist/{Label-DPWyf-gp.js → Label-BDlf9vIY.js} +3 -2
  8. package/dist/{List-CWheI3JH.js → List-CQFXnN4w.js} +1 -1
  9. package/dist/{ListBox-DT1sFY3e.js → ListBox-BaN0n5h3.js} +30 -28
  10. package/dist/{OverlayArrow-DVJTTfZM.js → OverlayArrow-Dy0qw7WL.js} +7 -7
  11. package/dist/{PortalProvider-CHPnqDSH.js → PortalProvider-BQ1X8vGX.js} +1 -1
  12. package/dist/{RadioGroup-Cp5cdBI_.js → RadioGroup-CjCAbUr4.js} +15 -15
  13. package/dist/{SearchField-CLhr5PGZ.js → SearchField-CafsA525.js} +12 -12
  14. package/dist/{SelectionManager-DbBiF5M8.js → SelectionManager-oojq6MOy.js} +38 -34
  15. package/dist/{SharedElementTransition-B_vnQ1uR.js → SharedElementTransition-CtoWSaF0.js} +1 -1
  16. package/dist/{Slider-CZV3HhHY.js → Slider-BIbaMdUE.js} +17 -16
  17. package/dist/{Text-Dae33gHp.js → Text-CjFEHSfr.js} +3 -2
  18. package/dist/{VisuallyHidden-eaCBtXhE.js → VisuallyHidden-CqnizvzQ.js} +2 -2
  19. package/dist/{animation-DY7CNkr6.js → animation-Dfl8uEb3.js} +2 -2
  20. package/dist/assets/style-admin.css +38 -54
  21. package/dist/assets/style-editor.css +38 -54
  22. package/dist/assets/style.css +38 -54
  23. package/dist/{color-swatch-CZj0jHZd.js → color-swatch-bUFkK7ox.js} +6 -6
  24. package/dist/components/base-control/base-control.js +1 -1
  25. package/dist/components/button/button.js +9 -9
  26. package/dist/components/checkbox/checkbox.js +10 -10
  27. package/dist/components/color-pickers/color-picker.js +1 -1
  28. package/dist/components/color-pickers/color-swatch.js +1 -1
  29. package/dist/components/color-pickers/gradient-editor.js +2 -2
  30. package/dist/components/color-pickers/solid-color-picker.js +27 -23
  31. package/dist/components/draggable/draggable-handle.js +1 -1
  32. package/dist/components/draggable/draggable.js +841 -633
  33. package/dist/components/draggable-list/draggable-list-item.js +1 -1
  34. package/dist/components/draggable-list/draggable-list.js +1 -1
  35. package/dist/components/expandable/expandable.js +10 -10
  36. package/dist/components/index.js +4 -2
  37. package/dist/components/input-field/input-field.js +10 -10
  38. package/dist/components/link-input/link-input.js +24 -23
  39. package/dist/components/matrix-align/matrix-align.js +1 -1
  40. package/dist/components/menu/menu.js +1 -1
  41. package/dist/components/modal/modal.js +21 -22
  42. package/dist/components/number-picker/number-picker.js +11 -11
  43. package/dist/components/options-panel/options-panel.js +1 -1
  44. package/dist/components/placeholders/file-picker-shell.js +49 -44
  45. package/dist/components/popover/popover.js +1 -1
  46. package/dist/components/portal-provider/portal-provider.js +1 -1
  47. package/dist/components/radio/radio.js +2 -2
  48. package/dist/components/repeater/repeater.js +1 -1
  49. package/dist/components/responsive/mini-responsive.js +1 -1
  50. package/dist/components/select/async-multi-select.js +53 -32
  51. package/dist/components/select/async-select.js +8 -8
  52. package/dist/components/select/multi-select.js +9 -9
  53. package/dist/components/select/shared.js +4 -4
  54. package/dist/components/select/single-select.js +9 -9
  55. package/dist/components/slider/column-config-slider.js +3 -3
  56. package/dist/components/slider/slider.js +3 -3
  57. package/dist/components/smart-image/image-analysis-worker-next.js +144 -0
  58. package/dist/components/smart-image/smart-image-next.js +294 -0
  59. package/dist/components/smart-image/smart-image.js +2 -2
  60. package/dist/components/smart-image/worker-inline.js +1 -1
  61. package/dist/components/tabs/tabs.js +17 -16
  62. package/dist/components/toggle/switch.js +7 -7
  63. package/dist/components/toggle/toggle.js +1 -1
  64. package/dist/components/toggle-button/toggle-button.js +10 -7
  65. package/dist/components/tooltip/tooltip.js +8 -8
  66. package/dist/{context-DYYO3Ns3.js → context-iUFQCK8m.js} +1 -1
  67. package/dist/{general-C8Q0dvEx.js → general-BfKmjm56.js} +3 -4
  68. package/dist/icons/icons.js +2 -2
  69. package/dist/icons/jsx-svg.js +1 -1
  70. package/dist/{index-sSixe2j_.js → index-BL5gdWX4.js} +52 -52
  71. package/dist/index.js +3 -1
  72. package/dist/{proxy-B_RaYTfe.js → proxy-DFlYXk07.js} +320 -82
  73. package/dist/{react-jsx-parser.min-B_hvYYa1.js → react-jsx-parser.min-DAh4myol.js} +35 -35
  74. package/dist/{shared-Bg9lx3pE.js → shared-CMLCUova.js} +29 -26
  75. package/dist/{textSelection-Cq_Br7RW.js → textSelection-CeoEP4rL.js} +1 -1
  76. package/dist/{useButton-CeuyDay5.js → useButton-5YL_nmpZ.js} +3 -3
  77. package/dist/{useEvent-DoWvho2u.js → useEvent-Zze2g7CX.js} +1 -1
  78. package/dist/{useFilter-DYtfYPua.js → useFilter-8S94U4xM.js} +1 -1
  79. package/dist/{useFocusRing-WEswknAY.js → useFocusRing-rUOwLdTK.js} +10 -5
  80. package/dist/{useFormReset-BDF1K4E4.js → useFormReset-BxtOoO5Q.js} +1 -1
  81. package/dist/{useFormValidation-Dqzjv4jX.js → useFormValidation-DTmPrTD8.js} +3 -3
  82. package/dist/{useHover-CG39Ci3A.js → useHover-CmyvqeWX.js} +18 -17
  83. package/dist/{useLabel--3fT2XKM.js → useLabel-DzXzKZZZ.js} +2 -2
  84. package/dist/{useLabels-vzdDMGCX.js → useLabels-D8O3gOdV.js} +1 -1
  85. package/dist/{useListState-Bya9g7W8.js → useListState-B22CApJO.js} +1 -1
  86. package/dist/{useLocalizedStringFormatter-M3L6Ge2c.js → useLocalizedStringFormatter-CEDs0LsA.js} +1 -1
  87. package/dist/{useNumberField-D6lsi3Vu.js → useNumberField-CTkI-U9a.js} +50 -40
  88. package/dist/{useNumberFormatter-BWOyCamK.js → useNumberFormatter-CG_IQXp9.js} +1 -1
  89. package/dist/{usePress-B9w0X4Ur.js → usePress-CNefMs8d.js} +14 -8
  90. package/dist/{useSingleSelectListState-D9SqGLJ0.js → useSingleSelectListState-CDZGQDLC.js} +2 -2
  91. package/dist/{useToggle-Deq2xxQV.js → useToggle-CFFOmZWi.js} +4 -4
  92. package/dist/{useToggleState-j3o1PvdS.js → useToggleState-BWrKKisg.js} +1 -1
  93. package/dist/utilities/general.js +1 -1
  94. package/dist/utilities/index.js +1 -1
  95. package/dist/{utils-HC9_3Crc.js → utils-Cr3pLd9c.js} +77 -38
  96. package/dist/workers/image-analysis.worker.js +1 -1
  97. package/package.json +17 -17
@@ -1800,7 +1800,8 @@ class NativeAnimation extends WithPromise {
1800
1800
  * while deferring the commit until the next animation frame.
1801
1801
  */
1802
1802
  commitStyles() {
1803
- if (!this.isPseudoElement) {
1803
+ const element = this.options?.element;
1804
+ if (!this.isPseudoElement && element?.isConnected) {
1804
1805
  this.animation.commitStyles?.();
1805
1806
  }
1806
1807
  }
@@ -1948,7 +1949,7 @@ function makeAnimationInstant(options) {
1948
1949
  options.duration = 0;
1949
1950
  options.type = "keyframes";
1950
1951
  }
1951
- const acceleratedValues = /* @__PURE__ */ new Set([
1952
+ const acceleratedValues$1 = /* @__PURE__ */ new Set([
1952
1953
  "opacity",
1953
1954
  "clipPath",
1954
1955
  "filter",
@@ -1964,7 +1965,7 @@ function supportsBrowserAnimation(options) {
1964
1965
  return false;
1965
1966
  }
1966
1967
  const { onUpdate, transformTemplate } = motionValue2.owner.getProps();
1967
- return supportsWaapi() && name && acceleratedValues.has(name) && (name !== "transform" || !transformTemplate) && /**
1968
+ return supportsWaapi() && name && acceleratedValues$1.has(name) && (name !== "transform" || !transformTemplate) && /**
1968
1969
  * If we're outputting values to onUpdate then we can't use WAAPI as there's
1969
1970
  * no way to read the value from WAAPI every frame.
1970
1971
  */
@@ -2164,8 +2165,19 @@ function getFinalKeyframe(keyframes2, { repeat, repeatType = "loop" }, finalKeyf
2164
2165
  const index = repeat && repeatType !== "loop" && repeat % 2 === 1 ? 0 : resolvedKeyframes.length - 1;
2165
2166
  return resolvedKeyframes[index];
2166
2167
  }
2168
+ function resolveTransition(transition, parentTransition) {
2169
+ if (transition?.inherit && parentTransition) {
2170
+ const { inherit: _, ...rest } = transition;
2171
+ return { ...parentTransition, ...rest };
2172
+ }
2173
+ return transition;
2174
+ }
2167
2175
  function getValueTransition(transition, key) {
2168
- return transition?.[key] ?? transition?.["default"] ?? transition;
2176
+ const valueTransition = transition?.[key] ?? transition?.["default"] ?? transition;
2177
+ if (valueTransition !== transition) {
2178
+ return resolveTransition(valueTransition, transition);
2179
+ }
2180
+ return valueTransition;
2169
2181
  }
2170
2182
  function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, elapsed, ...transition }) {
2171
2183
  return !!Object.keys(transition).length;
@@ -2208,7 +2220,7 @@ const animateMotionValue = (name, value, target, transition = {}, element, isHan
2208
2220
  shouldSkip = true;
2209
2221
  }
2210
2222
  }
2211
- if (MotionGlobalConfig.instantAnimations || MotionGlobalConfig.skipAnimations) {
2223
+ if (MotionGlobalConfig.instantAnimations || MotionGlobalConfig.skipAnimations || element?.shouldSkipAnimations) {
2212
2224
  shouldSkip = true;
2213
2225
  makeAnimationInstant(options);
2214
2226
  options.delay = 0;
@@ -2588,7 +2600,9 @@ function shouldBlockAnimation({ protectedKeys, needsAnimating }, key) {
2588
2600
  return shouldBlock;
2589
2601
  }
2590
2602
  function animateTarget(visualElement, targetAndTransition, { delay: delay2 = 0, transitionOverride, type } = {}) {
2591
- let { transition = visualElement.getDefaultTransition(), transitionEnd, ...target } = targetAndTransition;
2603
+ let { transition, transitionEnd, ...target } = targetAndTransition;
2604
+ const defaultTransition = visualElement.getDefaultTransition();
2605
+ transition = transition ? resolveTransition(transition, defaultTransition) : defaultTransition;
2592
2606
  const reduceMotion = transition?.reduceMotion;
2593
2607
  if (transitionOverride)
2594
2608
  transition = transitionOverride;
@@ -2628,11 +2642,14 @@ function animateTarget(visualElement, targetAndTransition, { delay: delay2 = 0,
2628
2642
  }
2629
2643
  }
2630
2644
  if (transitionEnd) {
2631
- Promise.all(animations2).then(() => {
2632
- frame.update(() => {
2633
- transitionEnd && setTarget(visualElement, transitionEnd);
2634
- });
2645
+ const applyTransitionEnd = () => frame.update(() => {
2646
+ transitionEnd && setTarget(visualElement, transitionEnd);
2635
2647
  });
2648
+ if (animations2.length) {
2649
+ Promise.all(animations2).then(applyTransitionEnd);
2650
+ } else {
2651
+ applyTransitionEnd();
2652
+ }
2636
2653
  }
2637
2654
  return animations2;
2638
2655
  }
@@ -2950,6 +2967,15 @@ class DOMKeyframesResolver extends KeyframeResolver {
2950
2967
  this.resolveNoneKeyframes();
2951
2968
  }
2952
2969
  }
2970
+ const acceleratedValues = /* @__PURE__ */ new Set([
2971
+ "opacity",
2972
+ "clipPath",
2973
+ "filter",
2974
+ "transform"
2975
+ // TODO: Can be accelerated but currently disabled until https://issues.chromium.org/issues/41491098 is resolved
2976
+ // or until we implement support for linear() easing.
2977
+ // "background-color"
2978
+ ]);
2953
2979
  function resolveElements(elementOrSelector, scope, selectorCache) {
2954
2980
  if (elementOrSelector == null) {
2955
2981
  return [];
@@ -3014,23 +3040,55 @@ function isValidHover(event) {
3014
3040
  }
3015
3041
  function hover(elementOrSelector, onHoverStart, options = {}) {
3016
3042
  const [elements, eventOptions, cancel] = setupGesture(elementOrSelector, options);
3017
- const onPointerEnter = (enterEvent) => {
3018
- if (!isValidHover(enterEvent))
3019
- return;
3020
- const { target } = enterEvent;
3021
- const onHoverEnd = onHoverStart(target, enterEvent);
3022
- if (typeof onHoverEnd !== "function" || !target)
3023
- return;
3043
+ elements.forEach((element) => {
3044
+ let isPressed = false;
3045
+ let deferredHoverEnd = false;
3046
+ let hoverEndCallback;
3047
+ const removePointerLeave = () => {
3048
+ element.removeEventListener("pointerleave", onPointerLeave);
3049
+ };
3050
+ const endHover = (event) => {
3051
+ if (hoverEndCallback) {
3052
+ hoverEndCallback(event);
3053
+ hoverEndCallback = void 0;
3054
+ }
3055
+ removePointerLeave();
3056
+ };
3057
+ const onPointerUp = (event) => {
3058
+ isPressed = false;
3059
+ window.removeEventListener("pointerup", onPointerUp);
3060
+ window.removeEventListener("pointercancel", onPointerUp);
3061
+ if (deferredHoverEnd) {
3062
+ deferredHoverEnd = false;
3063
+ endHover(event);
3064
+ }
3065
+ };
3066
+ const onPointerDown = () => {
3067
+ isPressed = true;
3068
+ window.addEventListener("pointerup", onPointerUp, eventOptions);
3069
+ window.addEventListener("pointercancel", onPointerUp, eventOptions);
3070
+ };
3024
3071
  const onPointerLeave = (leaveEvent) => {
3025
- if (!isValidHover(leaveEvent))
3072
+ if (leaveEvent.pointerType === "touch")
3073
+ return;
3074
+ if (isPressed) {
3075
+ deferredHoverEnd = true;
3026
3076
  return;
3027
- onHoverEnd(leaveEvent);
3028
- target.removeEventListener("pointerleave", onPointerLeave);
3077
+ }
3078
+ endHover(leaveEvent);
3079
+ };
3080
+ const onPointerEnter = (enterEvent) => {
3081
+ if (!isValidHover(enterEvent))
3082
+ return;
3083
+ deferredHoverEnd = false;
3084
+ const onHoverEnd = onHoverStart(element, enterEvent);
3085
+ if (typeof onHoverEnd !== "function")
3086
+ return;
3087
+ hoverEndCallback = onHoverEnd;
3088
+ element.addEventListener("pointerleave", onPointerLeave, eventOptions);
3029
3089
  };
3030
- target.addEventListener("pointerleave", onPointerLeave, eventOptions);
3031
- };
3032
- elements.forEach((element) => {
3033
3090
  element.addEventListener("pointerenter", onPointerEnter, eventOptions);
3091
+ element.addEventListener("pointerdown", onPointerDown, eventOptions);
3034
3092
  });
3035
3093
  return cancel;
3036
3094
  }
@@ -3050,7 +3108,7 @@ const isPrimaryPointer = (event) => {
3050
3108
  return event.isPrimary !== false;
3051
3109
  }
3052
3110
  };
3053
- const interactiveElements = /* @__PURE__ */ new Set([
3111
+ const keyboardAccessibleElements = /* @__PURE__ */ new Set([
3054
3112
  "BUTTON",
3055
3113
  "INPUT",
3056
3114
  "SELECT",
@@ -3058,7 +3116,11 @@ const interactiveElements = /* @__PURE__ */ new Set([
3058
3116
  "A"
3059
3117
  ]);
3060
3118
  function isElementKeyboardAccessible(element) {
3061
- return interactiveElements.has(element.tagName) || element.isContentEditable === true;
3119
+ return keyboardAccessibleElements.has(element.tagName) || element.isContentEditable === true;
3120
+ }
3121
+ const textInputElements = /* @__PURE__ */ new Set(["INPUT", "SELECT", "TEXTAREA"]);
3122
+ function isElementTextInput(element) {
3123
+ return textInputElements.has(element.tagName) || element.isContentEditable === true;
3062
3124
  }
3063
3125
  const isPressing = /* @__PURE__ */ new WeakSet();
3064
3126
  function filterEvents(callback) {
@@ -3092,13 +3154,19 @@ const enableKeyboardPress = (focusEvent, eventOptions) => {
3092
3154
  function isValidPressEvent(event) {
3093
3155
  return isPrimaryPointer(event) && !isDragActive();
3094
3156
  }
3157
+ const claimedPointerDownEvents = /* @__PURE__ */ new WeakSet();
3095
3158
  function press(targetOrSelector, onPressStart, options = {}) {
3096
3159
  const [targets, eventOptions, cancelEvents] = setupGesture(targetOrSelector, options);
3097
3160
  const startPress = (startEvent) => {
3098
3161
  const target = startEvent.currentTarget;
3099
3162
  if (!isValidPressEvent(startEvent))
3100
3163
  return;
3164
+ if (claimedPointerDownEvents.has(startEvent))
3165
+ return;
3101
3166
  isPressing.add(target);
3167
+ if (options.stopPropagation) {
3168
+ claimedPointerDownEvents.add(startEvent);
3169
+ }
3102
3170
  const onPressEnd = onPressStart(target, startEvent);
3103
3171
  const onPointerEnd = (endEvent, success) => {
3104
3172
  window.removeEventListener("pointerup", onPointerUp);
@@ -3137,6 +3205,93 @@ function press(targetOrSelector, onPressStart, options = {}) {
3137
3205
  function isSVGElement(element) {
3138
3206
  return isObject(element) && "ownerSVGElement" in element;
3139
3207
  }
3208
+ const resizeHandlers = /* @__PURE__ */ new WeakMap();
3209
+ let observer;
3210
+ const getSize = (borderBoxAxis, svgAxis, htmlAxis) => (target, borderBoxSize) => {
3211
+ if (borderBoxSize && borderBoxSize[0]) {
3212
+ return borderBoxSize[0][borderBoxAxis + "Size"];
3213
+ } else if (isSVGElement(target) && "getBBox" in target) {
3214
+ return target.getBBox()[svgAxis];
3215
+ } else {
3216
+ return target[htmlAxis];
3217
+ }
3218
+ };
3219
+ const getWidth = /* @__PURE__ */ getSize("inline", "width", "offsetWidth");
3220
+ const getHeight = /* @__PURE__ */ getSize("block", "height", "offsetHeight");
3221
+ function notifyTarget({ target, borderBoxSize }) {
3222
+ resizeHandlers.get(target)?.forEach((handler) => {
3223
+ handler(target, {
3224
+ get width() {
3225
+ return getWidth(target, borderBoxSize);
3226
+ },
3227
+ get height() {
3228
+ return getHeight(target, borderBoxSize);
3229
+ }
3230
+ });
3231
+ });
3232
+ }
3233
+ function notifyAll(entries) {
3234
+ entries.forEach(notifyTarget);
3235
+ }
3236
+ function createResizeObserver() {
3237
+ if (typeof ResizeObserver === "undefined")
3238
+ return;
3239
+ observer = new ResizeObserver(notifyAll);
3240
+ }
3241
+ function resizeElement(target, handler) {
3242
+ if (!observer)
3243
+ createResizeObserver();
3244
+ const elements = resolveElements(target);
3245
+ elements.forEach((element) => {
3246
+ let elementHandlers = resizeHandlers.get(element);
3247
+ if (!elementHandlers) {
3248
+ elementHandlers = /* @__PURE__ */ new Set();
3249
+ resizeHandlers.set(element, elementHandlers);
3250
+ }
3251
+ elementHandlers.add(handler);
3252
+ observer?.observe(element);
3253
+ });
3254
+ return () => {
3255
+ elements.forEach((element) => {
3256
+ const elementHandlers = resizeHandlers.get(element);
3257
+ elementHandlers?.delete(handler);
3258
+ if (!elementHandlers?.size) {
3259
+ observer?.unobserve(element);
3260
+ }
3261
+ });
3262
+ };
3263
+ }
3264
+ const windowCallbacks = /* @__PURE__ */ new Set();
3265
+ let windowResizeHandler;
3266
+ function createWindowResizeHandler() {
3267
+ windowResizeHandler = () => {
3268
+ const info = {
3269
+ get width() {
3270
+ return window.innerWidth;
3271
+ },
3272
+ get height() {
3273
+ return window.innerHeight;
3274
+ }
3275
+ };
3276
+ windowCallbacks.forEach((callback) => callback(info));
3277
+ };
3278
+ window.addEventListener("resize", windowResizeHandler);
3279
+ }
3280
+ function resizeWindow(callback) {
3281
+ windowCallbacks.add(callback);
3282
+ if (!windowResizeHandler)
3283
+ createWindowResizeHandler();
3284
+ return () => {
3285
+ windowCallbacks.delete(callback);
3286
+ if (!windowCallbacks.size && typeof windowResizeHandler === "function") {
3287
+ window.removeEventListener("resize", windowResizeHandler);
3288
+ windowResizeHandler = void 0;
3289
+ }
3290
+ };
3291
+ }
3292
+ function resize(a, b) {
3293
+ return typeof a === "function" ? resizeWindow(a) : resizeElement(a, b);
3294
+ }
3140
3295
  function isSVGSVGElement(element) {
3141
3296
  return isSVGElement(element) && element.tagName === "svg";
3142
3297
  }
@@ -3157,22 +3312,6 @@ const createBox = () => ({
3157
3312
  x: createAxis(),
3158
3313
  y: createAxis()
3159
3314
  });
3160
- const prefersReducedMotion = { current: null };
3161
- const hasReducedMotionListener = { current: false };
3162
- const isBrowser = typeof window !== "undefined";
3163
- function initPrefersReducedMotion() {
3164
- hasReducedMotionListener.current = true;
3165
- if (!isBrowser)
3166
- return;
3167
- if (window.matchMedia) {
3168
- const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
3169
- const setReducedMotionPreferences = () => prefersReducedMotion.current = motionMediaQuery.matches;
3170
- motionMediaQuery.addEventListener("change", setReducedMotionPreferences);
3171
- setReducedMotionPreferences();
3172
- } else {
3173
- prefersReducedMotion.current = false;
3174
- }
3175
- }
3176
3315
  const visualElementStore = /* @__PURE__ */ new WeakMap();
3177
3316
  function isAnimationControls(v) {
3178
3317
  return v !== null && typeof v === "object" && typeof v.start === "function";
@@ -3224,6 +3363,22 @@ function updateMotionValuesFromProps(element, next, prev) {
3224
3363
  }
3225
3364
  return next;
3226
3365
  }
3366
+ const prefersReducedMotion = { current: null };
3367
+ const hasReducedMotionListener = { current: false };
3368
+ const isBrowser = typeof window !== "undefined";
3369
+ function initPrefersReducedMotion() {
3370
+ hasReducedMotionListener.current = true;
3371
+ if (!isBrowser)
3372
+ return;
3373
+ if (window.matchMedia) {
3374
+ const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
3375
+ const setReducedMotionPreferences = () => prefersReducedMotion.current = motionMediaQuery.matches;
3376
+ motionMediaQuery.addEventListener("change", setReducedMotionPreferences);
3377
+ setReducedMotionPreferences();
3378
+ } else {
3379
+ prefersReducedMotion.current = false;
3380
+ }
3381
+ }
3227
3382
  const propEventHandlers = [
3228
3383
  "AnimationStart",
3229
3384
  "AnimationComplete",
@@ -3251,17 +3406,19 @@ class VisualElement {
3251
3406
  scrapeMotionValuesFromProps(_props, _prevProps, _visualElement) {
3252
3407
  return {};
3253
3408
  }
3254
- constructor({ parent, props, presenceContext, reducedMotionConfig, blockInitialAnimation, visualState }, options = {}) {
3409
+ constructor({ parent, props, presenceContext, reducedMotionConfig, skipAnimations, blockInitialAnimation, visualState }, options = {}) {
3255
3410
  this.current = null;
3256
3411
  this.children = /* @__PURE__ */ new Set();
3257
3412
  this.isVariantNode = false;
3258
3413
  this.isControllingVariants = false;
3259
3414
  this.shouldReduceMotion = null;
3415
+ this.shouldSkipAnimations = false;
3260
3416
  this.values = /* @__PURE__ */ new Map();
3261
3417
  this.KeyframeResolver = KeyframeResolver;
3262
3418
  this.features = {};
3263
3419
  this.valueSubscriptions = /* @__PURE__ */ new Map();
3264
3420
  this.prevMotionValues = {};
3421
+ this.hasBeenMounted = false;
3265
3422
  this.events = {};
3266
3423
  this.propEventSubscriptions = {};
3267
3424
  this.notifyUpdate = () => this.notify("Update", this.latestValues);
@@ -3289,6 +3446,7 @@ class VisualElement {
3289
3446
  this.presenceContext = presenceContext;
3290
3447
  this.depth = parent ? parent.depth + 1 : 0;
3291
3448
  this.reducedMotionConfig = reducedMotionConfig;
3449
+ this.skipAnimationsConfig = skipAnimations;
3292
3450
  this.options = options;
3293
3451
  this.blockInitialAnimation = Boolean(blockInitialAnimation);
3294
3452
  this.isControllingVariants = isControllingVariants(props);
@@ -3306,6 +3464,12 @@ class VisualElement {
3306
3464
  }
3307
3465
  }
3308
3466
  mount(instance) {
3467
+ if (this.hasBeenMounted) {
3468
+ for (const key in this.initialValues) {
3469
+ this.values.get(key)?.jump(this.initialValues[key]);
3470
+ this.latestValues[key] = this.initialValues[key];
3471
+ }
3472
+ }
3309
3473
  this.current = instance;
3310
3474
  visualElementStore.set(instance, this);
3311
3475
  if (this.projection && !this.projection.instance) {
@@ -3328,8 +3492,10 @@ class VisualElement {
3328
3492
  if (process.env.NODE_ENV !== "production") {
3329
3493
  warnOnce(this.shouldReduceMotion !== true, "You have Reduced Motion enabled on your device. Animations may not appear as expected.", "reduced-motion-disabled");
3330
3494
  }
3495
+ this.shouldSkipAnimations = this.skipAnimationsConfig ?? false;
3331
3496
  this.parent?.addChild(this);
3332
3497
  this.update(this.props, this.presenceContext);
3498
+ this.hasBeenMounted = true;
3333
3499
  }
3334
3500
  unmount() {
3335
3501
  this.projection && this.projection.unmount();
@@ -3364,6 +3530,23 @@ class VisualElement {
3364
3530
  if (this.valueSubscriptions.has(key)) {
3365
3531
  this.valueSubscriptions.get(key)();
3366
3532
  }
3533
+ if (value.accelerate && acceleratedValues.has(key) && this.current instanceof HTMLElement) {
3534
+ const { factory, keyframes: keyframes2, times, ease: ease2, duration } = value.accelerate;
3535
+ const animation = new NativeAnimation({
3536
+ element: this.current,
3537
+ name: key,
3538
+ keyframes: keyframes2,
3539
+ times,
3540
+ ease: ease2,
3541
+ duration: /* @__PURE__ */ secondsToMilliseconds(duration)
3542
+ });
3543
+ const cleanup = factory(animation);
3544
+ this.valueSubscriptions.set(key, () => {
3545
+ cleanup();
3546
+ animation.cancel();
3547
+ });
3548
+ return;
3549
+ }
3367
3550
  const valueIsTransform = transformProps.has(key);
3368
3551
  if (valueIsTransform && this.onBindTransform) {
3369
3552
  this.onBindTransform();
@@ -4164,6 +4347,15 @@ function createAnimationState(visualElement) {
4164
4347
  ) {
4165
4348
  continue;
4166
4349
  }
4350
+ if (type === "exit" && typeState.isActive && activeDelta !== true) {
4351
+ if (typeState.prevResolvedValues) {
4352
+ encounteredKeys = {
4353
+ ...encounteredKeys,
4354
+ ...typeState.prevResolvedValues
4355
+ };
4356
+ }
4357
+ continue;
4358
+ }
4167
4359
  const variantDidChange = checkVariantsDidChange(typeState.prevProp, prop);
4168
4360
  let shouldAnimateType = variantDidChange || // If we're making this variant active, we want to always make it active
4169
4361
  type === changedActiveType && typeState.isActive && !isInherited && propIsVariant || // If we removed a higher-priority variant (i is in reverse order)
@@ -4558,6 +4750,15 @@ class NodeStack {
4558
4750
  }
4559
4751
  add(node) {
4560
4752
  addUniqueItem(this.members, node);
4753
+ for (let i = this.members.length - 1; i >= 0; i--) {
4754
+ const m = this.members[i];
4755
+ if (m === node || m === this.lead || m === this.prevLead)
4756
+ continue;
4757
+ const inst = m.instance;
4758
+ if (inst && inst.isConnected === false && m.isPresent !== false && !m.snapshot) {
4759
+ removeItem(this.members, m);
4760
+ }
4761
+ }
4561
4762
  node.scheduleRender();
4562
4763
  }
4563
4764
  remove(node) {
@@ -4579,7 +4780,8 @@ class NodeStack {
4579
4780
  let prevLead;
4580
4781
  for (let i = indexOfNode; i >= 0; i--) {
4581
4782
  const member = this.members[i];
4582
- if (member.isPresent !== false) {
4783
+ const inst = member.instance;
4784
+ if (member.isPresent !== false && (!inst || inst.isConnected !== false)) {
4583
4785
  prevLead = member;
4584
4786
  break;
4585
4787
  }
@@ -4605,16 +4807,20 @@ class NodeStack {
4605
4807
  const nextDep = node.options.layoutDependency;
4606
4808
  const dependencyMatches = prevDep !== void 0 && nextDep !== void 0 && prevDep === nextDep;
4607
4809
  if (!dependencyMatches) {
4608
- node.resumeFrom = prevLead;
4609
- if (preserveFollowOpacity) {
4610
- node.resumeFrom.preserveOpacity = true;
4611
- }
4612
- if (prevLead.snapshot) {
4613
- node.snapshot = prevLead.snapshot;
4614
- node.snapshot.latestValues = prevLead.animationValues || prevLead.latestValues;
4615
- }
4616
- if (node.root && node.root.isUpdating) {
4617
- node.isLayoutDirty = true;
4810
+ const prevInstance = prevLead.instance;
4811
+ const isStale = prevInstance && prevInstance.isConnected === false && !prevLead.snapshot;
4812
+ if (!isStale) {
4813
+ node.resumeFrom = prevLead;
4814
+ if (preserveFollowOpacity) {
4815
+ node.resumeFrom.preserveOpacity = true;
4816
+ }
4817
+ if (prevLead.snapshot) {
4818
+ node.snapshot = prevLead.snapshot;
4819
+ node.snapshot.latestValues = prevLead.animationValues || prevLead.latestValues;
4820
+ }
4821
+ if (node.root && node.root.isUpdating) {
4822
+ node.isLayoutDirty = true;
4823
+ }
4618
4824
  }
4619
4825
  }
4620
4826
  const { crossfade } = node.options;
@@ -5276,9 +5482,9 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
5276
5482
  show() {
5277
5483
  this.isVisible = true;
5278
5484
  }
5279
- scheduleRender(notifyAll = true) {
5485
+ scheduleRender(notifyAll2 = true) {
5280
5486
  this.options.visualElement?.scheduleRender();
5281
- if (notifyAll) {
5487
+ if (notifyAll2) {
5282
5488
  const stack = this.getStack();
5283
5489
  stack && stack.scheduleRender();
5284
5490
  }
@@ -5778,7 +5984,7 @@ function useComposedRefs(...refs) {
5778
5984
  class PopChildMeasure extends $dbSRa$react.Component {
5779
5985
  getSnapshotBeforeUpdate(prevProps) {
5780
5986
  const element = this.props.childRef.current;
5781
- if (element && prevProps.isPresent && !this.props.isPresent) {
5987
+ if (element && prevProps.isPresent && !this.props.isPresent && this.props.pop !== false) {
5782
5988
  const parent = element.offsetParent;
5783
5989
  const parentWidth = isHTMLElement(parent) ? parent.offsetWidth || 0 : 0;
5784
5990
  const parentHeight = isHTMLElement(parent) ? parent.offsetHeight || 0 : 0;
@@ -5801,7 +6007,7 @@ class PopChildMeasure extends $dbSRa$react.Component {
5801
6007
  return this.props.children;
5802
6008
  }
5803
6009
  }
5804
- function PopChild({ children, isPresent, anchorX, anchorY, root }) {
6010
+ function PopChild({ children, isPresent, anchorX, anchorY, root, pop }) {
5805
6011
  const id2 = useId();
5806
6012
  const ref = useRef(null);
5807
6013
  const size = useRef({
@@ -5817,7 +6023,7 @@ function PopChild({ children, isPresent, anchorX, anchorY, root }) {
5817
6023
  const composedRef = useComposedRefs(ref, childRef);
5818
6024
  useInsertionEffect(() => {
5819
6025
  const { width, height, top, left, right, bottom } = size.current;
5820
- if (isPresent || !ref.current || !width || !height)
6026
+ if (isPresent || pop === false || !ref.current || !width || !height)
5821
6027
  return;
5822
6028
  const x = anchorX === "left" ? `left: ${left}` : `right: ${right}`;
5823
6029
  const y = anchorY === "bottom" ? `bottom: ${bottom}` : `top: ${top}`;
@@ -5844,7 +6050,7 @@ function PopChild({ children, isPresent, anchorX, anchorY, root }) {
5844
6050
  }
5845
6051
  };
5846
6052
  }, [isPresent]);
5847
- return jsx(PopChildMeasure, { isPresent, childRef: ref, sizeRef: size, children: $dbSRa$react.cloneElement(children, { ref: composedRef }) });
6053
+ return jsx(PopChildMeasure, { isPresent, childRef: ref, sizeRef: size, pop, children: pop === false ? children : $dbSRa$react.cloneElement(children, { ref: composedRef }) });
5848
6054
  }
5849
6055
  const PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, presenceAffectsLayout, mode, anchorX, anchorY, root }) => {
5850
6056
  const presenceChildren = useConstant(newChildrenMap);
@@ -5880,9 +6086,7 @@ const PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, p
5880
6086
  $dbSRa$react.useEffect(() => {
5881
6087
  !isPresent && !presenceChildren.size && onExitComplete && onExitComplete();
5882
6088
  }, [isPresent]);
5883
- if (mode === "popLayout") {
5884
- children = jsx(PopChild, { isPresent, anchorX, anchorY, root, children });
5885
- }
6089
+ children = jsx(PopChild, { pop: mode === "popLayout", isPresent, anchorX, anchorY, root, children });
5886
6090
  return jsx(PresenceContext.Provider, { value: context, children });
5887
6091
  };
5888
6092
  function newChildrenMap() {
@@ -6063,6 +6267,7 @@ const validMotionProps = /* @__PURE__ */ new Set([
6063
6267
  "onViewportEnter",
6064
6268
  "onViewportLeave",
6065
6269
  "globalTapTarget",
6270
+ "propagate",
6066
6271
  "ignoreStrict",
6067
6272
  "viewport"
6068
6273
  ]);
@@ -6337,7 +6542,9 @@ function useVisualElement(Component2, visualState, props, createVisualElement, P
6337
6542
  const { visualElement: parent } = useContext(MotionContext);
6338
6543
  const lazyContext = useContext(LazyContext);
6339
6544
  const presenceContext = useContext(PresenceContext);
6340
- const reducedMotionConfig = useContext(MotionConfigContext).reducedMotion;
6545
+ const motionConfig = useContext(MotionConfigContext);
6546
+ const reducedMotionConfig = motionConfig.reducedMotion;
6547
+ const skipAnimations = motionConfig.skipAnimations;
6341
6548
  const visualElementRef = useRef(null);
6342
6549
  const hasMountedOnce = useRef(false);
6343
6550
  createVisualElement = createVisualElement || lazyContext.renderer;
@@ -6349,6 +6556,7 @@ function useVisualElement(Component2, visualState, props, createVisualElement, P
6349
6556
  presenceContext,
6350
6557
  blockInitialAnimation: presenceContext ? presenceContext.initial === false : false,
6351
6558
  reducedMotionConfig,
6559
+ skipAnimations,
6352
6560
  isSVG
6353
6561
  });
6354
6562
  if (hasMountedOnce.current && visualElementRef.current) {
@@ -6790,6 +6998,9 @@ function getVelocity(history, timeDelta) {
6790
6998
  if (!timestampedPoint) {
6791
6999
  return { x: 0, y: 0 };
6792
7000
  }
7001
+ if (timestampedPoint === history[0] && history.length > 2 && lastPoint.timestamp - timestampedPoint.timestamp > /* @__PURE__ */ secondsToMilliseconds(timeDelta) * 2) {
7002
+ timestampedPoint = history[1];
7003
+ }
6793
7004
  const time2 = /* @__PURE__ */ millisecondsToSeconds(lastPoint.timestamp - timestampedPoint.timestamp);
6794
7005
  if (time2 === 0) {
6795
7006
  return { x: 0, y: 0 };
@@ -6902,14 +7113,11 @@ class VisualElementDragControls {
6902
7113
  return;
6903
7114
  const onSessionStart = (event) => {
6904
7115
  if (snapToCursor) {
6905
- this.stopAnimation();
6906
7116
  this.snapToCursor(extractEventInfo(event).point);
6907
- } else {
6908
- this.pauseAnimation();
6909
7117
  }
7118
+ this.stopAnimation();
6910
7119
  };
6911
7120
  const onStart = (event, info) => {
6912
- this.stopAnimation();
6913
7121
  const { drag: drag2, dragPropagation, onDragStart } = this.getProps();
6914
7122
  if (drag2 && !dragPropagation) {
6915
7123
  if (this.openDragLock)
@@ -6942,7 +7150,7 @@ class VisualElementDragControls {
6942
7150
  this.originPoint[axis] = current;
6943
7151
  });
6944
7152
  if (onDragStart) {
6945
- frame.postRender(() => onDragStart(event, info));
7153
+ frame.update(() => onDragStart(event, info), false, true);
6946
7154
  }
6947
7155
  addValueToWillChange(this.visualElement, "transform");
6948
7156
  const { animationState } = this.visualElement;
@@ -6965,7 +7173,9 @@ class VisualElementDragControls {
6965
7173
  this.updateAxis("x", info.point, offset);
6966
7174
  this.updateAxis("y", info.point, offset);
6967
7175
  this.visualElement.render();
6968
- onDrag && onDrag(event, info);
7176
+ if (onDrag) {
7177
+ frame.update(() => onDrag(event, info), false, true);
7178
+ }
6969
7179
  };
6970
7180
  const onSessionEnd = (event, info) => {
6971
7181
  this.latestPointerEvent = event;
@@ -6974,7 +7184,12 @@ class VisualElementDragControls {
6974
7184
  this.latestPointerEvent = null;
6975
7185
  this.latestPanInfo = null;
6976
7186
  };
6977
- const resumeAnimation = () => eachAxis((axis) => this.getAnimationState(axis) === "paused" && this.getAxisMotionValue(axis).animation?.play());
7187
+ const resumeAnimation = () => {
7188
+ const { dragSnapToOrigin: snap } = this.getProps();
7189
+ if (snap || this.constraints) {
7190
+ this.startAnimation({ x: 0, y: 0 });
7191
+ }
7192
+ };
6978
7193
  const { dragSnapToOrigin } = this.getProps();
6979
7194
  this.panSession = new PanSession(originEvent, {
6980
7195
  onSessionStart,
@@ -7061,7 +7276,7 @@ class VisualElementDragControls {
7061
7276
  }
7062
7277
  }
7063
7278
  this.elastic = resolveDragElastic(dragElastic);
7064
- if (prevConstraints !== this.constraints && layout2 && this.constraints && !this.hasMutatedConstraints) {
7279
+ if (prevConstraints !== this.constraints && !isRefObject(dragConstraints) && layout2 && this.constraints && !this.hasMutatedConstraints) {
7065
7280
  eachAxis((axis) => {
7066
7281
  if (this.constraints !== false && this.getAxisMotionValue(axis)) {
7067
7282
  this.constraints[axis] = rebaseAxisConstraints(layout2.layoutBox[axis], this.constraints[axis]);
@@ -7124,12 +7339,6 @@ class VisualElementDragControls {
7124
7339
  stopAnimation() {
7125
7340
  eachAxis((axis) => this.getAxisMotionValue(axis).stop());
7126
7341
  }
7127
- pauseAnimation() {
7128
- eachAxis((axis) => this.getAxisMotionValue(axis).animation?.pause());
7129
- }
7130
- getAnimationState(axis) {
7131
- return this.getAxisMotionValue(axis).animation?.state;
7132
- }
7133
7342
  /**
7134
7343
  * Drag works differently depending on which props are provided.
7135
7344
  *
@@ -7181,6 +7390,7 @@ class VisualElementDragControls {
7181
7390
  this.visualElement.current.style.transform = transformTemplate ? transformTemplate({}, "") : "none";
7182
7391
  projection.root && projection.root.updateScroll();
7183
7392
  projection.updateLayout();
7393
+ this.constraints = false;
7184
7394
  this.resolveConstraints();
7185
7395
  eachAxis((axis) => {
7186
7396
  if (!shouldDrag(axis, drag2, null))
@@ -7189,6 +7399,7 @@ class VisualElementDragControls {
7189
7399
  const { min, max } = this.constraints[axis];
7190
7400
  axisValue.set(mixNumber$1(min, max, boxProgress[axis]));
7191
7401
  });
7402
+ this.visualElement.render();
7192
7403
  }
7193
7404
  addListeners() {
7194
7405
  if (!this.visualElement.current)
@@ -7198,15 +7409,19 @@ class VisualElementDragControls {
7198
7409
  const stopPointerListener = addPointerEvent(element, "pointerdown", (event) => {
7199
7410
  const { drag: drag2, dragListener = true } = this.getProps();
7200
7411
  const target = event.target;
7201
- const isClickingKeyboardAccessibleChild = target !== element && isElementKeyboardAccessible(target);
7202
- if (drag2 && dragListener && !isClickingKeyboardAccessibleChild) {
7412
+ const isClickingTextInputChild = target !== element && isElementTextInput(target);
7413
+ if (drag2 && dragListener && !isClickingTextInputChild) {
7203
7414
  this.start(event);
7204
7415
  }
7205
7416
  });
7417
+ let stopResizeObservers;
7206
7418
  const measureDragConstraints = () => {
7207
7419
  const { dragConstraints } = this.getProps();
7208
7420
  if (isRefObject(dragConstraints) && dragConstraints.current) {
7209
7421
  this.constraints = this.resolveRefConstraints();
7422
+ if (!stopResizeObservers) {
7423
+ stopResizeObservers = startResizeObservers(element, dragConstraints.current, () => this.scalePositionWithinConstraints());
7424
+ }
7210
7425
  }
7211
7426
  };
7212
7427
  const { projection } = this.visualElement;
@@ -7234,6 +7449,7 @@ class VisualElementDragControls {
7234
7449
  stopPointerListener();
7235
7450
  stopMeasureLayoutListener();
7236
7451
  stopLayoutUpdateListener && stopLayoutUpdateListener();
7452
+ stopResizeObservers && stopResizeObservers();
7237
7453
  };
7238
7454
  }
7239
7455
  getProps() {
@@ -7250,6 +7466,24 @@ class VisualElementDragControls {
7250
7466
  };
7251
7467
  }
7252
7468
  }
7469
+ function skipFirstCall(callback) {
7470
+ let isFirst = true;
7471
+ return () => {
7472
+ if (isFirst) {
7473
+ isFirst = false;
7474
+ return;
7475
+ }
7476
+ callback();
7477
+ };
7478
+ }
7479
+ function startResizeObservers(element, constraintsElement, onResize) {
7480
+ const stopElement = resize(element, skipFirstCall(onResize));
7481
+ const stopContainer = resize(constraintsElement, skipFirstCall(onResize));
7482
+ return () => {
7483
+ stopElement();
7484
+ stopContainer();
7485
+ };
7486
+ }
7253
7487
  function shouldDrag(direction, drag2, currentDirection) {
7254
7488
  return (drag2 === true || drag2 === direction) && (currentDirection === null || currentDirection === direction);
7255
7489
  }
@@ -7296,7 +7530,7 @@ class DragGesture extends Feature {
7296
7530
  }
7297
7531
  const asyncHandler = (handler) => (event, info) => {
7298
7532
  if (handler) {
7299
- frame.postRender(() => handler(event, info));
7533
+ frame.update(() => handler(event, info), false, true);
7300
7534
  }
7301
7535
  };
7302
7536
  class PanGesture extends Feature {
@@ -7315,7 +7549,7 @@ class PanGesture extends Feature {
7315
7549
  return {
7316
7550
  onSessionStart: asyncHandler(onPanSessionStart),
7317
7551
  onStart: asyncHandler(onPanStart),
7318
- onMove: onPan,
7552
+ onMove: asyncHandler(onPan),
7319
7553
  onEnd: (event, info) => {
7320
7554
  delete this.session;
7321
7555
  if (onPanEnd) {
@@ -7515,10 +7749,14 @@ class PressGesture extends Feature {
7515
7749
  const { current } = this.node;
7516
7750
  if (!current)
7517
7751
  return;
7752
+ const { globalTapTarget, propagate } = this.node.props;
7518
7753
  this.unmount = press(current, (_element, startEvent) => {
7519
7754
  handlePressEvent(this.node, startEvent, "Start");
7520
7755
  return (endEvent, { success }) => handlePressEvent(this.node, endEvent, success ? "End" : "Cancel");
7521
- }, { useGlobalTarget: this.node.props.globalTapTarget });
7756
+ }, {
7757
+ useGlobalTarget: globalTapTarget,
7758
+ stopPropagation: propagate?.tap === false
7759
+ });
7522
7760
  }
7523
7761
  unmount() {
7524
7762
  }