framer-motion 7.0.3 → 7.1.2

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 (186) hide show
  1. package/dist/cjs/index.js +2090 -2304
  2. package/dist/es/animation/animate.mjs +4 -5
  3. package/dist/es/animation/animation-controls.mjs +22 -24
  4. package/dist/es/animation/use-animated-state.mjs +23 -25
  5. package/dist/es/animation/use-animation.mjs +2 -2
  6. package/dist/es/animation/utils/default-transitions.mjs +13 -14
  7. package/dist/es/animation/utils/easing.mjs +20 -21
  8. package/dist/es/animation/utils/is-animatable.mjs +1 -1
  9. package/dist/es/animation/utils/is-keyframes-target.mjs +1 -1
  10. package/dist/es/animation/utils/transitions.mjs +30 -31
  11. package/dist/es/components/AnimatePresence/PresenceChild.mjs +18 -31
  12. package/dist/es/components/AnimatePresence/index.mjs +33 -35
  13. package/dist/es/components/AnimatePresence/use-presence.mjs +5 -5
  14. package/dist/es/components/AnimateSharedLayout.mjs +4 -5
  15. package/dist/es/components/LayoutGroup/index.mjs +12 -16
  16. package/dist/es/components/LazyMotion/index.mjs +9 -10
  17. package/dist/es/components/MotionConfig/index.mjs +5 -5
  18. package/dist/es/components/Reorder/Group.mjs +16 -16
  19. package/dist/es/components/Reorder/Item.mjs +14 -18
  20. package/dist/es/components/Reorder/index.mjs +3 -3
  21. package/dist/es/components/Reorder/utils/check-reorder.mjs +6 -6
  22. package/dist/es/context/DeprecatedLayoutGroupContext.mjs +1 -1
  23. package/dist/es/context/LayoutGroupContext.mjs +1 -1
  24. package/dist/es/context/LazyContext.mjs +1 -1
  25. package/dist/es/context/MotionConfigContext.mjs +2 -2
  26. package/dist/es/context/MotionContext/create.mjs +2 -2
  27. package/dist/es/context/MotionContext/index.mjs +1 -1
  28. package/dist/es/context/MotionContext/utils.mjs +1 -1
  29. package/dist/es/context/PresenceContext.mjs +1 -1
  30. package/dist/es/context/ReorderContext.mjs +1 -1
  31. package/dist/es/context/SwitchLayoutGroupContext.mjs +1 -1
  32. package/dist/es/events/event-info.mjs +11 -17
  33. package/dist/es/events/use-dom-event.mjs +4 -5
  34. package/dist/es/events/use-pointer-event.mjs +2 -2
  35. package/dist/es/events/utils.mjs +3 -9
  36. package/dist/es/gestures/PanSession.mjs +42 -47
  37. package/dist/es/gestures/drag/VisualElementDragControls.mjs +147 -157
  38. package/dist/es/gestures/drag/use-drag-controls.mjs +10 -12
  39. package/dist/es/gestures/drag/use-drag.mjs +4 -4
  40. package/dist/es/gestures/drag/utils/constraints.mjs +12 -17
  41. package/dist/es/gestures/drag/utils/lock.mjs +17 -17
  42. package/dist/es/gestures/use-focus-gesture.mjs +3 -4
  43. package/dist/es/gestures/use-hover-gesture.mjs +2 -3
  44. package/dist/es/gestures/use-pan-gesture.mjs +9 -10
  45. package/dist/es/gestures/use-tap-gesture.mjs +5 -6
  46. package/dist/es/gestures/utils/event-type.mjs +1 -1
  47. package/dist/es/gestures/utils/is-node-or-child.mjs +1 -1
  48. package/dist/es/index.mjs +1 -0
  49. package/dist/es/motion/features/animations.mjs +9 -11
  50. package/dist/es/motion/features/definitions.mjs +5 -5
  51. package/dist/es/motion/features/drag.mjs +1 -1
  52. package/dist/es/motion/features/gestures.mjs +1 -1
  53. package/dist/es/motion/features/layout/MeasureLayout.mjs +32 -40
  54. package/dist/es/motion/features/layout/index.mjs +1 -1
  55. package/dist/es/motion/features/use-features.mjs +8 -9
  56. package/dist/es/motion/features/use-projection.mjs +10 -11
  57. package/dist/es/motion/features/viewport/observers.mjs +12 -12
  58. package/dist/es/motion/features/viewport/use-viewport.mjs +17 -20
  59. package/dist/es/motion/index.mjs +13 -16
  60. package/dist/es/motion/utils/VisualElementHandler.mjs +10 -16
  61. package/dist/es/motion/utils/is-forced-motion-value.mjs +1 -2
  62. package/dist/es/motion/utils/make-renderless-component.mjs +2 -2
  63. package/dist/es/motion/utils/use-motion-ref.mjs +1 -1
  64. package/dist/es/motion/utils/use-visual-element.mjs +13 -13
  65. package/dist/es/motion/utils/use-visual-state.mjs +26 -31
  66. package/dist/es/motion/utils/valid-prop.mjs +1 -1
  67. package/dist/es/projection/animation/mix-values.mjs +12 -16
  68. package/dist/es/projection/geometry/conversion.mjs +4 -6
  69. package/dist/es/projection/geometry/delta-apply.mjs +14 -20
  70. package/dist/es/projection/geometry/delta-calc.mjs +2 -5
  71. package/dist/es/projection/geometry/delta-remove.mjs +6 -13
  72. package/dist/es/projection/geometry/models.mjs +7 -7
  73. package/dist/es/projection/node/DocumentProjectionNode.mjs +5 -5
  74. package/dist/es/projection/node/HTMLProjectionNode.mjs +8 -10
  75. package/dist/es/projection/node/create-projection-node.mjs +283 -307
  76. package/dist/es/projection/node/group.mjs +6 -8
  77. package/dist/es/projection/node/id.mjs +2 -2
  78. package/dist/es/projection/node/state.mjs +1 -1
  79. package/dist/es/projection/shared/stack.mjs +26 -27
  80. package/dist/es/projection/styles/scale-border-radius.mjs +5 -5
  81. package/dist/es/projection/styles/scale-box-shadow.mjs +18 -19
  82. package/dist/es/projection/styles/scale-correction.mjs +1 -1
  83. package/dist/es/projection/styles/transform.mjs +12 -12
  84. package/dist/es/projection/use-reset-projection.mjs +2 -2
  85. package/dist/es/projection/utils/has-transform.mjs +1 -2
  86. package/dist/es/projection/utils/measure.mjs +2 -2
  87. package/dist/es/render/dom/create-visual-element.mjs +1 -1
  88. package/dist/es/render/dom/features-animation.mjs +1 -2
  89. package/dist/es/render/dom/features-max.mjs +1 -2
  90. package/dist/es/render/dom/motion-minimal.mjs +1 -1
  91. package/dist/es/render/dom/motion-proxy.mjs +3 -4
  92. package/dist/es/render/dom/motion.mjs +2 -5
  93. package/dist/es/render/dom/use-render.mjs +6 -9
  94. package/dist/es/render/dom/utils/camel-to-dash.mjs +3 -5
  95. package/dist/es/render/dom/utils/create-config.mjs +5 -5
  96. package/dist/es/render/dom/utils/css-variables-conversion.mjs +19 -20
  97. package/dist/es/render/dom/utils/filter-props.mjs +4 -6
  98. package/dist/es/render/dom/utils/parse-dom-variant.mjs +2 -2
  99. package/dist/es/render/dom/utils/unit-conversion.mjs +68 -99
  100. package/dist/es/render/dom/value-types/animatable-none.mjs +1 -1
  101. package/dist/es/render/dom/value-types/defaults.mjs +4 -5
  102. package/dist/es/render/dom/value-types/dimensions.mjs +2 -4
  103. package/dist/es/render/dom/value-types/find.mjs +2 -3
  104. package/dist/es/render/dom/value-types/get-as-type.mjs +1 -1
  105. package/dist/es/render/dom/value-types/number.mjs +2 -2
  106. package/dist/es/render/dom/value-types/test.mjs +1 -1
  107. package/dist/es/render/dom/value-types/type-auto.mjs +3 -3
  108. package/dist/es/render/dom/value-types/type-int.mjs +1 -2
  109. package/dist/es/render/html/config-motion.mjs +1 -1
  110. package/dist/es/render/html/use-props.mjs +11 -13
  111. package/dist/es/render/html/utils/build-styles.mjs +8 -8
  112. package/dist/es/render/html/utils/build-transform.mjs +11 -16
  113. package/dist/es/render/html/utils/create-render-state.mjs +2 -2
  114. package/dist/es/render/html/utils/render.mjs +2 -3
  115. package/dist/es/render/html/utils/scrape-motion-values.mjs +3 -3
  116. package/dist/es/render/html/utils/transform.mjs +6 -10
  117. package/dist/es/render/html/visual-element.mjs +22 -23
  118. package/dist/es/render/index.mjs +359 -364
  119. package/dist/es/render/svg/config-motion.mjs +2 -3
  120. package/dist/es/render/svg/lowercase-elements.mjs +1 -1
  121. package/dist/es/render/svg/use-props.mjs +5 -6
  122. package/dist/es/render/svg/utils/build-attrs.mjs +2 -2
  123. package/dist/es/render/svg/utils/camel-case-attrs.mjs +1 -1
  124. package/dist/es/render/svg/utils/create-render-state.mjs +1 -2
  125. package/dist/es/render/svg/utils/path.mjs +7 -10
  126. package/dist/es/render/svg/utils/render.mjs +1 -1
  127. package/dist/es/render/svg/utils/scrape-motion-values.mjs +3 -3
  128. package/dist/es/render/svg/utils/transform-origin.mjs +3 -3
  129. package/dist/es/render/svg/visual-element.mjs +6 -4
  130. package/dist/es/render/utils/animation-state.mjs +71 -87
  131. package/dist/es/render/utils/animation.mjs +48 -60
  132. package/dist/es/render/utils/compare-by-depth.mjs +1 -3
  133. package/dist/es/render/utils/flat-tree.mjs +9 -10
  134. package/dist/es/render/utils/lifecycles.mjs +12 -19
  135. package/dist/es/render/utils/motion-values.mjs +16 -8
  136. package/dist/es/render/utils/setters.mjs +19 -19
  137. package/dist/es/render/utils/variants.mjs +6 -8
  138. package/dist/es/utils/array.mjs +9 -10
  139. package/dist/es/utils/is-browser.mjs +1 -1
  140. package/dist/es/utils/is-numerical-string.mjs +1 -1
  141. package/dist/es/utils/is-zero-value-string.mjs +1 -1
  142. package/dist/es/utils/process.mjs +2 -2
  143. package/dist/es/utils/resolve-value.mjs +2 -2
  144. package/dist/es/utils/shallow-compare.mjs +2 -2
  145. package/dist/es/utils/subscription-manager.mjs +15 -17
  146. package/dist/es/utils/time-conversion.mjs +1 -1
  147. package/dist/es/utils/transform.mjs +10 -15
  148. package/dist/es/utils/use-animation-frame.mjs +5 -6
  149. package/dist/es/utils/use-constant.mjs +1 -1
  150. package/dist/es/utils/use-cycle.mjs +9 -10
  151. package/dist/es/utils/use-force-update.mjs +4 -5
  152. package/dist/es/utils/use-in-view.mjs +7 -9
  153. package/dist/es/utils/use-instant-transition-state.mjs +1 -1
  154. package/dist/es/utils/use-instant-transition.mjs +6 -9
  155. package/dist/es/utils/use-is-mounted.mjs +3 -3
  156. package/dist/es/utils/use-isomorphic-effect.mjs +1 -1
  157. package/dist/es/utils/use-reduced-motion.mjs +8 -11
  158. package/dist/es/utils/use-unmount-effect.mjs +1 -1
  159. package/dist/es/utils/warn-once.mjs +1 -1
  160. package/dist/es/value/index.mjs +53 -59
  161. package/dist/es/value/use-combine-values.mjs +3 -3
  162. package/dist/es/value/use-inverted-scale.mjs +9 -11
  163. package/dist/es/value/use-motion-template.mjs +5 -9
  164. package/dist/es/value/use-motion-value.mjs +4 -5
  165. package/dist/es/value/use-on-change.mjs +4 -4
  166. package/dist/es/value/use-scroll.mjs +9 -11
  167. package/dist/es/value/use-spring.mjs +8 -10
  168. package/dist/es/value/use-time.mjs +2 -2
  169. package/dist/es/value/use-transform.mjs +6 -10
  170. package/dist/es/value/use-velocity.mjs +3 -3
  171. package/dist/es/value/use-will-change/index.mjs +50 -0
  172. package/dist/es/value/use-will-change/is.mjs +7 -0
  173. package/dist/es/value/utils/is-motion-value.mjs +1 -1
  174. package/dist/es/value/utils/resolve-motion-value.mjs +1 -1
  175. package/dist/framer-motion.dev.js +2134 -2414
  176. package/dist/framer-motion.js +1 -1
  177. package/dist/index.d.ts +9 -2
  178. package/dist/projection.dev.js +1154 -1300
  179. package/dist/size-rollup-dom-animation.js +1 -1
  180. package/dist/size-rollup-dom-max.js +1 -1
  181. package/dist/size-rollup-m.js +1 -1
  182. package/dist/size-webpack-dom-animation.js +1 -1
  183. package/dist/size-webpack-dom-max.js +1 -1
  184. package/dist/size-webpack-m.js +1 -1
  185. package/dist/three-entry.d.ts +0 -1
  186. package/package.json +12 -12
@@ -4,12 +4,11 @@ import { makeUseVisualState } from '../../motion/utils/use-visual-state.mjs';
4
4
  import { createSvgRenderState } from './utils/create-render-state.mjs';
5
5
  import { buildSVGAttrs } from './utils/build-attrs.mjs';
6
6
 
7
- var svgMotionConfig = {
7
+ const svgMotionConfig = {
8
8
  useVisualState: makeUseVisualState({
9
9
  scrapeMotionValuesFromProps: scrapeMotionValuesFromProps,
10
10
  createRenderState: createSvgRenderState,
11
- onMount: function (props, instance, _a) {
12
- var renderState = _a.renderState, latestValues = _a.latestValues;
11
+ onMount: (props, instance, { renderState, latestValues }) => {
13
12
  try {
14
13
  renderState.dimensions =
15
14
  typeof instance.getBBox ===
@@ -2,7 +2,7 @@
2
2
  * We keep these listed seperately as we use the lowercase tag names as part
3
3
  * of the runtime bundle to detect SVG components
4
4
  */
5
- var lowercaseSVGElements = [
5
+ const lowercaseSVGElements = [
6
6
  "animate",
7
7
  "circle",
8
8
  "defs",
@@ -1,19 +1,18 @@
1
- import { __assign } from 'tslib';
2
1
  import { useMemo } from 'react';
3
2
  import { copyRawValuesOnly } from '../html/use-props.mjs';
4
3
  import { buildSVGAttrs } from './utils/build-attrs.mjs';
5
4
  import { createSvgRenderState } from './utils/create-render-state.mjs';
6
5
 
7
6
  function useSVGProps(props, visualState) {
8
- var visualProps = useMemo(function () {
9
- var state = createSvgRenderState();
7
+ const visualProps = useMemo(() => {
8
+ const state = createSvgRenderState();
10
9
  buildSVGAttrs(state, visualState, { enableHardwareAcceleration: false }, props.transformTemplate);
11
- return __assign(__assign({}, state.attrs), { style: __assign({}, state.style) });
10
+ return Object.assign(Object.assign({}, state.attrs), { style: Object.assign({}, state.style) });
12
11
  }, [visualState]);
13
12
  if (props.style) {
14
- var rawStyles = {};
13
+ const rawStyles = {};
15
14
  copyRawValuesOnly(rawStyles, props.style, props);
16
- visualProps.style = __assign(__assign({}, rawStyles), visualProps.style);
15
+ visualProps.style = Object.assign(Object.assign({}, rawStyles), visualProps.style);
17
16
  }
18
17
  return visualProps;
19
18
  }
@@ -7,13 +7,13 @@ import { buildSVGPath } from './path.mjs';
7
7
  * Build SVG visual attrbutes, like cx and style.transform
8
8
  */
9
9
  function buildSVGAttrs(state, _a, options, transformTemplate) {
10
- var attrX = _a.attrX, attrY = _a.attrY, originX = _a.originX, originY = _a.originY, pathLength = _a.pathLength, _b = _a.pathSpacing, pathSpacing = _b === void 0 ? 1 : _b, _c = _a.pathOffset, pathOffset = _c === void 0 ? 0 : _c,
10
+ var { attrX, attrY, originX, originY, pathLength, pathSpacing = 1, pathOffset = 0 } = _a,
11
11
  // This is object creation, which we try to avoid per-frame.
12
12
  latest = __rest(_a, ["attrX", "attrY", "originX", "originY", "pathLength", "pathSpacing", "pathOffset"]);
13
13
  buildHTMLStyles(state, latest, options, transformTemplate);
14
14
  state.attrs = state.style;
15
15
  state.style = {};
16
- var attrs = state.attrs, style = state.style, dimensions = state.dimensions;
16
+ const { attrs, style, dimensions } = state;
17
17
  /**
18
18
  * However, we apply transforms as CSS transforms. So if we detect a transform we take it from attrs
19
19
  * and copy it into style.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * A set of attribute names that are always read/written as camel case.
3
3
  */
4
- var camelCaseAttributes = new Set([
4
+ const camelCaseAttributes = new Set([
5
5
  "baseFrequency",
6
6
  "diffuseConstant",
7
7
  "kernelMatrix",
@@ -1,6 +1,5 @@
1
- import { __assign } from 'tslib';
2
1
  import { createHtmlRenderState } from '../../html/utils/create-render-state.mjs';
3
2
 
4
- var createSvgRenderState = function () { return (__assign(__assign({}, createHtmlRenderState()), { attrs: {} })); };
3
+ const createSvgRenderState = () => (Object.assign(Object.assign({}, createHtmlRenderState()), { attrs: {} }));
5
4
 
6
5
  export { createSvgRenderState };
@@ -1,10 +1,10 @@
1
1
  import { px } from 'style-value-types';
2
2
 
3
- var dashKeys = {
3
+ const dashKeys = {
4
4
  offset: "stroke-dashoffset",
5
5
  array: "stroke-dasharray",
6
6
  };
7
- var camelKeys = {
7
+ const camelKeys = {
8
8
  offset: "strokeDashoffset",
9
9
  array: "strokeDasharray",
10
10
  };
@@ -15,21 +15,18 @@ var camelKeys = {
15
15
  *
16
16
  * This function is mutative to reduce per-frame GC.
17
17
  */
18
- function buildSVGPath(attrs, length, spacing, offset, useDashCase) {
19
- if (spacing === void 0) { spacing = 1; }
20
- if (offset === void 0) { offset = 0; }
21
- if (useDashCase === void 0) { useDashCase = true; }
18
+ function buildSVGPath(attrs, length, spacing = 1, offset = 0, useDashCase = true) {
22
19
  // Normalise path length by setting SVG attribute pathLength to 1
23
20
  attrs.pathLength = 1;
24
21
  // We use dash case when setting attributes directly to the DOM node and camel case
25
22
  // when defining props on a React component.
26
- var keys = useDashCase ? dashKeys : camelKeys;
23
+ const keys = useDashCase ? dashKeys : camelKeys;
27
24
  // Build the dash offset
28
25
  attrs[keys.offset] = px.transform(-offset);
29
26
  // Build the dash array
30
- var pathLength = px.transform(length);
31
- var pathSpacing = px.transform(spacing);
32
- attrs[keys.array] = "".concat(pathLength, " ").concat(pathSpacing);
27
+ const pathLength = px.transform(length);
28
+ const pathSpacing = px.transform(spacing);
29
+ attrs[keys.array] = `${pathLength} ${pathSpacing}`;
33
30
  }
34
31
 
35
32
  export { buildSVGPath };
@@ -4,7 +4,7 @@ import { camelCaseAttributes } from './camel-case-attrs.mjs';
4
4
 
5
5
  function renderSVG(element, renderState, _styleProp, projection) {
6
6
  renderHTML(element, renderState, undefined, projection);
7
- for (var key in renderState.attrs) {
7
+ for (const key in renderState.attrs) {
8
8
  element.setAttribute(!camelCaseAttributes.has(key) ? camelToDash(key) : key, renderState.attrs[key]);
9
9
  }
10
10
  }
@@ -2,10 +2,10 @@ import { isMotionValue } from '../../../value/utils/is-motion-value.mjs';
2
2
  import { scrapeMotionValuesFromProps as scrapeMotionValuesFromProps$1 } from '../../html/utils/scrape-motion-values.mjs';
3
3
 
4
4
  function scrapeMotionValuesFromProps(props) {
5
- var newValues = scrapeMotionValuesFromProps$1(props);
6
- for (var key in props) {
5
+ const newValues = scrapeMotionValuesFromProps$1(props);
6
+ for (const key in props) {
7
7
  if (isMotionValue(props[key])) {
8
- var targetKey = key === "x" || key === "y" ? "attr" + key.toUpperCase() : key;
8
+ const targetKey = key === "x" || key === "y" ? "attr" + key.toUpperCase() : key;
9
9
  newValues[targetKey] = props[key];
10
10
  }
11
11
  }
@@ -10,9 +10,9 @@ function calcOrigin(origin, offset, size) {
10
10
  * so we use the measured dimensions of the SVG to reconcile these.
11
11
  */
12
12
  function calcSVGTransformOrigin(dimensions, originX, originY) {
13
- var pxOriginX = calcOrigin(originX, dimensions.x, dimensions.width);
14
- var pxOriginY = calcOrigin(originY, dimensions.y, dimensions.height);
15
- return "".concat(pxOriginX, " ").concat(pxOriginY);
13
+ const pxOriginX = calcOrigin(originX, dimensions.x, dimensions.width);
14
+ const pxOriginY = calcOrigin(originY, dimensions.y, dimensions.height);
15
+ return `${pxOriginX} ${pxOriginY}`;
16
16
  }
17
17
 
18
18
  export { calcSVGTransformOrigin };
@@ -1,4 +1,3 @@
1
- import { __assign } from 'tslib';
2
1
  import { visualElement } from '../index.mjs';
3
2
  import { scrapeMotionValuesFromProps } from './utils/scrape-motion-values.mjs';
4
3
  import { htmlConfig } from '../html/visual-element.mjs';
@@ -9,16 +8,19 @@ import { isTransformProp } from '../html/utils/transform.mjs';
9
8
  import { renderSVG } from './utils/render.mjs';
10
9
  import { getDefaultValueType } from '../dom/value-types/defaults.mjs';
11
10
 
12
- var svgVisualElement = visualElement(__assign(__assign({}, htmlConfig), { getBaseTarget: function (props, key) {
11
+ const svgVisualElement = visualElement(Object.assign(Object.assign({}, htmlConfig), { getBaseTarget(props, key) {
13
12
  return props[key];
14
- }, readValueFromInstance: function (domElement, key) {
13
+ },
14
+ readValueFromInstance(domElement, key) {
15
15
  var _a;
16
16
  if (isTransformProp(key)) {
17
17
  return ((_a = getDefaultValueType(key)) === null || _a === void 0 ? void 0 : _a.default) || 0;
18
18
  }
19
19
  key = !camelCaseAttributes.has(key) ? camelToDash(key) : key;
20
20
  return domElement.getAttribute(key);
21
- }, scrapeMotionValuesFromProps: scrapeMotionValuesFromProps, build: function (_element, renderState, latestValues, options, props) {
21
+ },
22
+ scrapeMotionValuesFromProps,
23
+ build(_element, renderState, latestValues, options, props) {
22
24
  buildSVGAttrs(renderState, latestValues, options, props.transformTemplate);
23
25
  }, render: renderSVG }));
24
26
 
@@ -1,4 +1,4 @@
1
- import { __spreadArray, __read, __assign, __rest } from 'tslib';
1
+ import { __rest } from 'tslib';
2
2
  import { isAnimationControls } from '../../animation/utils/is-animation-controls.mjs';
3
3
  import { isKeyframesTarget } from '../../animation/utils/is-keyframes-target.mjs';
4
4
  import { shallowCompare } from '../../utils/shallow-compare.mjs';
@@ -6,7 +6,7 @@ import { animateVisualElement } from './animation.mjs';
6
6
  import { AnimationType } from './types.mjs';
7
7
  import { isVariantLabels, resolveVariant, isVariantLabel } from './variants.mjs';
8
8
 
9
- var variantPriorityOrder = [
9
+ const variantPriorityOrder = [
10
10
  AnimationType.Animate,
11
11
  AnimationType.InView,
12
12
  AnimationType.Focus,
@@ -15,36 +15,27 @@ var variantPriorityOrder = [
15
15
  AnimationType.Drag,
16
16
  AnimationType.Exit,
17
17
  ];
18
- var reversePriorityOrder = __spreadArray([], __read(variantPriorityOrder), false).reverse();
19
- var numAnimationTypes = variantPriorityOrder.length;
18
+ const reversePriorityOrder = [...variantPriorityOrder].reverse();
19
+ const numAnimationTypes = variantPriorityOrder.length;
20
20
  function animateList(visualElement) {
21
- return function (animations) {
22
- return Promise.all(animations.map(function (_a) {
23
- var animation = _a.animation, options = _a.options;
24
- return animateVisualElement(visualElement, animation, options);
25
- }));
26
- };
21
+ return (animations) => Promise.all(animations.map(({ animation, options }) => animateVisualElement(visualElement, animation, options)));
27
22
  }
28
23
  function createAnimationState(visualElement) {
29
- var animate = animateList(visualElement);
30
- var state = createState();
31
- var allAnimatedKeys = {};
32
- var isInitialRender = true;
24
+ let animate = animateList(visualElement);
25
+ const state = createState();
26
+ let isInitialRender = true;
33
27
  /**
34
28
  * This function will be used to reduce the animation definitions for
35
29
  * each active animation type into an object of resolved values for it.
36
30
  */
37
- var buildResolvedTypeValues = function (acc, definition) {
38
- var resolved = resolveVariant(visualElement, definition);
31
+ const buildResolvedTypeValues = (acc, definition) => {
32
+ const resolved = resolveVariant(visualElement, definition);
39
33
  if (resolved) {
40
- resolved.transition; var transitionEnd = resolved.transitionEnd, target = __rest(resolved, ["transition", "transitionEnd"]);
41
- acc = __assign(__assign(__assign({}, acc), target), transitionEnd);
34
+ const { transition, transitionEnd } = resolved, target = __rest(resolved, ["transition", "transitionEnd"]);
35
+ acc = Object.assign(Object.assign(Object.assign({}, acc), target), transitionEnd);
42
36
  }
43
37
  return acc;
44
38
  };
45
- function isAnimated(key) {
46
- return allAnimatedKeys[key] !== undefined;
47
- }
48
39
  /**
49
40
  * This just allows us to inject mocked animation functions
50
41
  * @internal
@@ -64,39 +55,45 @@ function createAnimationState(visualElement) {
64
55
  */
65
56
  function animateChanges(options, changedActiveType) {
66
57
  var _a;
67
- var props = visualElement.getProps();
68
- var context = visualElement.getVariantContext(true) || {};
58
+ const props = visualElement.getProps();
59
+ const context = visualElement.getVariantContext(true) || {};
69
60
  /**
70
61
  * A list of animations that we'll build into as we iterate through the animation
71
62
  * types. This will get executed at the end of the function.
72
63
  */
73
- var animations = [];
64
+ const animations = [];
74
65
  /**
75
66
  * Keep track of which values have been removed. Then, as we hit lower priority
76
67
  * animation types, we can check if they contain removed values and animate to that.
77
68
  */
78
- var removedKeys = new Set();
69
+ const removedKeys = new Set();
79
70
  /**
80
71
  * A dictionary of all encountered keys. This is an object to let us build into and
81
72
  * copy it without iteration. Each time we hit an animation type we set its protected
82
73
  * keys - the keys its not allowed to animate - to the latest version of this object.
83
74
  */
84
- var encounteredKeys = {};
75
+ let encounteredKeys = {};
85
76
  /**
86
77
  * If a variant has been removed at a given index, and this component is controlling
87
78
  * variant animations, we want to ensure lower-priority variants are forced to animate.
88
79
  */
89
- var removedVariantIndex = Infinity;
90
- var _loop_1 = function (i) {
91
- var type = reversePriorityOrder[i];
92
- var typeState = state[type];
93
- var prop = (_a = props[type]) !== null && _a !== void 0 ? _a : context[type];
94
- var propIsVariant = isVariantLabel(prop);
80
+ let removedVariantIndex = Infinity;
81
+ /**
82
+ * Iterate through all animation types in reverse priority order. For each, we want to
83
+ * detect which values it's handling and whether or not they've changed (and therefore
84
+ * need to be animated). If any values have been removed, we want to detect those in
85
+ * lower priority props and flag for animation.
86
+ */
87
+ for (let i = 0; i < numAnimationTypes; i++) {
88
+ const type = reversePriorityOrder[i];
89
+ const typeState = state[type];
90
+ const prop = (_a = props[type]) !== null && _a !== void 0 ? _a : context[type];
91
+ const propIsVariant = isVariantLabel(prop);
95
92
  /**
96
93
  * If this type has *just* changed isActive status, set activeDelta
97
94
  * to that status. Otherwise set to null.
98
95
  */
99
- var activeDelta = type === changedActiveType ? typeState.isActive : null;
96
+ const activeDelta = type === changedActiveType ? typeState.isActive : null;
100
97
  if (activeDelta === false)
101
98
  removedVariantIndex = i;
102
99
  /**
@@ -105,7 +102,7 @@ function createAnimationState(visualElement) {
105
102
  *
106
103
  * TODO: Can probably change this to a !isControllingVariants check
107
104
  */
108
- var isInherited = prop === context[type] && prop !== props[type] && propIsVariant;
105
+ let isInherited = prop === context[type] && prop !== props[type] && propIsVariant;
109
106
  /**
110
107
  *
111
108
  */
@@ -118,7 +115,7 @@ function createAnimationState(visualElement) {
118
115
  * Set all encountered keys so far as the protected keys for this type. This will
119
116
  * be any key that has been animated or otherwise handled by active, higher-priortiy types.
120
117
  */
121
- typeState.protectedKeys = __assign({}, encounteredKeys);
118
+ typeState.protectedKeys = Object.assign({}, encounteredKeys);
122
119
  // Check if we can skip analysing this prop early
123
120
  if (
124
121
  // If it isn't active and hasn't *just* been set as inactive
@@ -128,15 +125,15 @@ function createAnimationState(visualElement) {
128
125
  // Or if the prop doesn't define an animation
129
126
  isAnimationControls(prop) ||
130
127
  typeof prop === "boolean") {
131
- return "continue";
128
+ continue;
132
129
  }
133
130
  /**
134
131
  * As we go look through the values defined on this type, if we detect
135
132
  * a changed value or a value that was removed in a higher priority, we set
136
133
  * this to true and add this prop to the animation list.
137
134
  */
138
- var variantDidChange = checkVariantsDidChange(typeState.prevProp, prop);
139
- var shouldAnimateType = variantDidChange ||
135
+ const variantDidChange = checkVariantsDidChange(typeState.prevProp, prop);
136
+ let shouldAnimateType = variantDidChange ||
140
137
  // If we're making this variant active, we want to always make it active
141
138
  (type === changedActiveType &&
142
139
  typeState.isActive &&
@@ -148,12 +145,12 @@ function createAnimationState(visualElement) {
148
145
  * As animations can be set as variant lists, variants or target objects, we
149
146
  * coerce everything to an array if it isn't one already
150
147
  */
151
- var definitionList = Array.isArray(prop) ? prop : [prop];
148
+ const definitionList = Array.isArray(prop) ? prop : [prop];
152
149
  /**
153
150
  * Build an object of all the resolved values. We'll use this in the subsequent
154
151
  * animateChanges calls to determine whether a value has changed.
155
152
  */
156
- var resolvedValues = definitionList.reduce(buildResolvedTypeValues, {});
153
+ let resolvedValues = definitionList.reduce(buildResolvedTypeValues, {});
157
154
  if (activeDelta === false)
158
155
  resolvedValues = {};
159
156
  /**
@@ -165,16 +162,16 @@ function createAnimationState(visualElement) {
165
162
  * 4. If it hasn't been removed in a higher priority but hasn't changed, and
166
163
  * needs adding to the type's protectedKeys list.
167
164
  */
168
- var _b = typeState.prevResolvedValues, prevResolvedValues = _b === void 0 ? {} : _b;
169
- var allKeys = __assign(__assign({}, prevResolvedValues), resolvedValues);
170
- var markToAnimate = function (key) {
165
+ const { prevResolvedValues = {} } = typeState;
166
+ const allKeys = Object.assign(Object.assign({}, prevResolvedValues), resolvedValues);
167
+ const markToAnimate = (key) => {
171
168
  shouldAnimateType = true;
172
169
  removedKeys.delete(key);
173
170
  typeState.needsAnimating[key] = true;
174
171
  };
175
- for (var key in allKeys) {
176
- var next = resolvedValues[key];
177
- var prev = prevResolvedValues[key];
172
+ for (const key in allKeys) {
173
+ const next = resolvedValues[key];
174
+ const prev = prevResolvedValues[key];
178
175
  // If we've already handled this we can just skip ahead
179
176
  if (encounteredKeys.hasOwnProperty(key))
180
177
  continue;
@@ -232,7 +229,7 @@ function createAnimationState(visualElement) {
232
229
  *
233
230
  */
234
231
  if (typeState.isActive) {
235
- encounteredKeys = __assign(__assign({}, encounteredKeys), resolvedValues);
232
+ encounteredKeys = Object.assign(Object.assign({}, encounteredKeys), resolvedValues);
236
233
  }
237
234
  if (isInitialRender && visualElement.blockInitialAnimation) {
238
235
  shouldAnimateType = false;
@@ -243,38 +240,28 @@ function createAnimationState(visualElement) {
243
240
  * by removed values?
244
241
  */
245
242
  if (shouldAnimateType && !isInherited) {
246
- animations.push.apply(animations, __spreadArray([], __read(definitionList.map(function (animation) { return ({
243
+ animations.push(...definitionList.map((animation) => ({
247
244
  animation: animation,
248
- options: __assign({ type: type }, options),
249
- }); })), false));
245
+ options: Object.assign({ type }, options),
246
+ })));
250
247
  }
251
- };
252
- /**
253
- * Iterate through all animation types in reverse priority order. For each, we want to
254
- * detect which values it's handling and whether or not they've changed (and therefore
255
- * need to be animated). If any values have been removed, we want to detect those in
256
- * lower priority props and flag for animation.
257
- */
258
- for (var i = 0; i < numAnimationTypes; i++) {
259
- _loop_1(i);
260
248
  }
261
- allAnimatedKeys = __assign({}, encounteredKeys);
262
249
  /**
263
250
  * If there are some removed value that haven't been dealt with,
264
251
  * we need to create a new animation that falls back either to the value
265
252
  * defined in the style prop, or the last read value.
266
253
  */
267
254
  if (removedKeys.size) {
268
- var fallbackAnimation_1 = {};
269
- removedKeys.forEach(function (key) {
270
- var fallbackTarget = visualElement.getBaseTarget(key);
255
+ const fallbackAnimation = {};
256
+ removedKeys.forEach((key) => {
257
+ const fallbackTarget = visualElement.getBaseTarget(key);
271
258
  if (fallbackTarget !== undefined) {
272
- fallbackAnimation_1[key] = fallbackTarget;
259
+ fallbackAnimation[key] = fallbackTarget;
273
260
  }
274
261
  });
275
- animations.push({ animation: fallbackAnimation_1 });
262
+ animations.push({ animation: fallbackAnimation });
276
263
  }
277
- var shouldAnimate = Boolean(animations.length);
264
+ let shouldAnimate = Boolean(animations.length);
278
265
  if (isInitialRender &&
279
266
  props.initial === false &&
280
267
  !visualElement.manuallyAnimateOnMount) {
@@ -292,20 +279,19 @@ function createAnimationState(visualElement) {
292
279
  if (state[type].isActive === isActive)
293
280
  return Promise.resolve();
294
281
  // Propagate active change to children
295
- (_a = visualElement.variantChildren) === null || _a === void 0 ? void 0 : _a.forEach(function (child) { var _a; return (_a = child.animationState) === null || _a === void 0 ? void 0 : _a.setActive(type, isActive); });
282
+ (_a = visualElement.variantChildren) === null || _a === void 0 ? void 0 : _a.forEach((child) => { var _a; return (_a = child.animationState) === null || _a === void 0 ? void 0 : _a.setActive(type, isActive); });
296
283
  state[type].isActive = isActive;
297
- var animations = animateChanges(options, type);
298
- for (var key in state) {
284
+ const animations = animateChanges(options, type);
285
+ for (const key in state) {
299
286
  state[key].protectedKeys = {};
300
287
  }
301
288
  return animations;
302
289
  }
303
290
  return {
304
- isAnimated: isAnimated,
305
- animateChanges: animateChanges,
306
- setActive: setActive,
307
- setAnimateFunction: setAnimateFunction,
308
- getState: function () { return state; },
291
+ animateChanges,
292
+ setActive,
293
+ setAnimateFunction,
294
+ getState: () => state,
309
295
  };
310
296
  }
311
297
  function checkVariantsDidChange(prev, next) {
@@ -317,26 +303,24 @@ function checkVariantsDidChange(prev, next) {
317
303
  }
318
304
  return false;
319
305
  }
320
- function createTypeState(isActive) {
321
- if (isActive === void 0) { isActive = false; }
306
+ function createTypeState(isActive = false) {
322
307
  return {
323
- isActive: isActive,
308
+ isActive,
324
309
  protectedKeys: {},
325
310
  needsAnimating: {},
326
311
  prevResolvedValues: {},
327
312
  };
328
313
  }
329
314
  function createState() {
330
- var _a;
331
- return _a = {},
332
- _a[AnimationType.Animate] = createTypeState(true),
333
- _a[AnimationType.InView] = createTypeState(),
334
- _a[AnimationType.Hover] = createTypeState(),
335
- _a[AnimationType.Tap] = createTypeState(),
336
- _a[AnimationType.Drag] = createTypeState(),
337
- _a[AnimationType.Focus] = createTypeState(),
338
- _a[AnimationType.Exit] = createTypeState(),
339
- _a;
315
+ return {
316
+ [AnimationType.Animate]: createTypeState(true),
317
+ [AnimationType.InView]: createTypeState(),
318
+ [AnimationType.Hover]: createTypeState(),
319
+ [AnimationType.Tap]: createTypeState(),
320
+ [AnimationType.Drag]: createTypeState(),
321
+ [AnimationType.Focus]: createTypeState(),
322
+ [AnimationType.Exit]: createTypeState(),
323
+ };
340
324
  }
341
325
 
342
326
  export { checkVariantsDidChange, createAnimationState, variantPriorityOrder };