motion-v 0.6.2 → 0.7.0

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 (38) hide show
  1. package/dist/cjs/index.js +201 -160
  2. package/dist/es/components/animate-presence/AnimatePresence.vue.mjs +5 -1
  3. package/dist/es/components/animate-presence/utils.mjs +10 -0
  4. package/dist/es/components/{Motion.vue.mjs → motion/Motion.vue.mjs} +7 -7
  5. package/dist/es/components/motion/NameSpace.mjs +47 -0
  6. package/dist/es/constants/index.mjs +3 -1
  7. package/dist/es/features/gestures/drag/use-drag-controls.mjs +43 -0
  8. package/dist/es/features/gestures/in-view/index.mjs +25 -5
  9. package/dist/es/features/layout/projection.mjs +7 -30
  10. package/dist/es/index.mjs +8 -4
  11. package/dist/es/state/motion-state.mjs +70 -54
  12. package/dist/es/state/transform.mjs +1 -0
  13. package/dist/src/components/animate-presence/utils.d.ts +1 -0
  14. package/dist/src/components/index.d.ts +1 -0
  15. package/dist/src/components/{Motion.d.ts → motion/Motion.d.ts} +1 -1
  16. package/dist/src/components/motion/NameSpace.d.ts +11 -0
  17. package/dist/src/components/motion/index.d.ts +2 -0
  18. package/dist/src/features/gestures/drag/VisualElementDragControls.d.ts +1 -1
  19. package/dist/src/features/gestures/in-view/index.d.ts +2 -0
  20. package/dist/src/features/layout/projection.d.ts +1 -0
  21. package/dist/src/index.d.ts +1 -1
  22. package/dist/src/state/animate-variants-children.d.ts +2 -2
  23. package/dist/src/state/motion-state.d.ts +4 -1
  24. package/dist/src/state/utils.d.ts +3 -3
  25. package/dist/src/types/framer-motion.d.ts +17 -0
  26. package/dist/src/types/state.d.ts +6 -14
  27. package/package.json +1 -2
  28. package/dist/es/external/.pnpm/@vueuse_shared@12.0.0_typescript@5.7.2/external/@vueuse/shared/index.mjs +0 -6
  29. package/dist/es/state/animate-variants-children.mjs +0 -74
  30. /package/dist/es/components/{Motion.vue2.mjs → motion/Motion.vue2.mjs} +0 -0
  31. /package/dist/es/components/{Primitive.mjs → motion/Primitive.mjs} +0 -0
  32. /package/dist/es/components/{Slot.mjs → motion/Slot.mjs} +0 -0
  33. /package/dist/es/components/{renderSlotFragments.mjs → motion/renderSlotFragments.mjs} +0 -0
  34. /package/dist/es/components/{utils.mjs → motion/utils.mjs} +0 -0
  35. /package/dist/src/components/{Primitive.d.ts → motion/Primitive.d.ts} +0 -0
  36. /package/dist/src/components/{Slot.d.ts → motion/Slot.d.ts} +0 -0
  37. /package/dist/src/components/{renderSlotFragments.d.ts → motion/renderSlotFragments.d.ts} +0 -0
  38. /package/dist/src/components/{utils.d.ts → motion/utils.d.ts} +0 -0
@@ -0,0 +1,47 @@
1
+ import { defineComponent, h } from "vue";
2
+ import _sfc_main from "./Motion.vue.mjs";
3
+ const componentCache = /* @__PURE__ */ new Map();
4
+ const motion = new Proxy(_sfc_main, {
5
+ get(target, prop) {
6
+ if (typeof prop === "symbol")
7
+ return target[prop];
8
+ let motionComponent = componentCache.get(prop);
9
+ if (prop === "create") {
10
+ return (component) => {
11
+ return defineComponent({
12
+ inheritAttrs: false,
13
+ name: `motion.${component.$name}`,
14
+ setup(_, { attrs, slots }) {
15
+ return () => {
16
+ return h(_sfc_main, {
17
+ ...attrs,
18
+ as: component,
19
+ asChild: false
20
+ }, slots);
21
+ };
22
+ }
23
+ });
24
+ };
25
+ }
26
+ if (!motionComponent) {
27
+ motionComponent = defineComponent({
28
+ inheritAttrs: false,
29
+ name: `motion.${prop}`,
30
+ setup(_, { attrs, slots }) {
31
+ return () => {
32
+ return h(_sfc_main, {
33
+ ...attrs,
34
+ as: prop,
35
+ asChild: false
36
+ }, slots);
37
+ };
38
+ }
39
+ });
40
+ componentCache.set(prop, motionComponent);
41
+ }
42
+ return motionComponent;
43
+ }
44
+ });
45
+ export {
46
+ motion
47
+ };
@@ -1,5 +1,6 @@
1
1
  const components = {
2
2
  motion: [
3
+ "motion",
3
4
  "Motion",
4
5
  "AnimatePresence",
5
6
  "LayoutGroup",
@@ -19,7 +20,8 @@ const utilities = {
19
20
  "useInView",
20
21
  "useAnimationFrame",
21
22
  "useMotionValueEvent",
22
- "useLayoutGroup"
23
+ "useLayoutGroup",
24
+ "useDragControls"
23
25
  ]
24
26
  };
25
27
  export {
@@ -0,0 +1,43 @@
1
+ class DragControls {
2
+ constructor() {
3
+ this.componentControls = /* @__PURE__ */ new Set();
4
+ }
5
+ /**
6
+ * Subscribe a component's internal `VisualElementDragControls` to the user-facing API.
7
+ *
8
+ * @internal
9
+ */
10
+ subscribe(controls) {
11
+ this.componentControls.add(controls);
12
+ return () => this.componentControls.delete(controls);
13
+ }
14
+ /**
15
+ * Start a drag gesture on every `motion` component that has this set of drag controls
16
+ * passed into it via the `dragControls` prop.
17
+ *
18
+ * ```jsx
19
+ * dragControls.start(e, {
20
+ * snapToCursor: true
21
+ * })
22
+ * ```
23
+ *
24
+ * @param event - PointerEvent
25
+ * @param options - Options
26
+ *
27
+ * @public
28
+ */
29
+ start(event, options) {
30
+ this.componentControls.forEach((controls) => {
31
+ controls.start(
32
+ event,
33
+ options
34
+ );
35
+ });
36
+ }
37
+ }
38
+ const createDragControls = () => new DragControls();
39
+ const useDragControls = createDragControls;
40
+ export {
41
+ DragControls,
42
+ useDragControls
43
+ };
@@ -19,21 +19,41 @@ class InViewGesture extends Feature {
19
19
  constructor(state) {
20
20
  super(state);
21
21
  }
22
- mount() {
22
+ startObserver() {
23
23
  const element = this.state.element;
24
24
  if (!element)
25
25
  return;
26
+ this.unmount();
27
+ const { once, ...viewOptions } = this.state.getOptions().inViewOptions || {};
26
28
  this.unmount = inView(
27
29
  element,
28
30
  (entry) => {
29
31
  handleHoverEvent(this.state, entry, "Enter");
30
- return (endEvent) => {
31
- handleHoverEvent(this.state, entry, "Leave");
32
- };
33
- }
32
+ if (!once) {
33
+ return (endEvent) => {
34
+ handleHoverEvent(this.state, entry, "Leave");
35
+ };
36
+ }
37
+ },
38
+ viewOptions
39
+ );
40
+ }
41
+ mount() {
42
+ this.startObserver();
43
+ }
44
+ update() {
45
+ const { props, prevProps } = this.state.visualElement;
46
+ const hasOptionsChanged = ["amount", "margin", "root"].some(
47
+ hasViewportOptionChanged(props, prevProps)
34
48
  );
49
+ if (hasOptionsChanged) {
50
+ this.startObserver();
51
+ }
35
52
  }
36
53
  }
54
+ function hasViewportOptionChanged({ inViewOptions = {} }, { inViewOptions: prevViewport = {} } = {}) {
55
+ return (name) => inViewOptions[name] !== prevViewport[name];
56
+ }
37
57
  export {
38
58
  InViewGesture
39
59
  };
@@ -3,7 +3,7 @@ import { HTMLProjectionNode } from "../../external/.pnpm/framer-motion@11.16.6/e
3
3
  import { getClosestProjectingNode } from "./utils.mjs";
4
4
  import { addScaleCorrector } from "../../external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/projection/styles/scale-correction.mjs";
5
5
  import { defaultScaleCorrector } from "./config.mjs";
6
- import { doneCallbacks } from "../../components/presence.mjs";
6
+ import { isHTMLElement } from "../gestures/drag/utils/is.mjs";
7
7
  class ProjectionFeature extends Feature {
8
8
  constructor(state) {
9
9
  super(state);
@@ -16,43 +16,17 @@ class ProjectionFeature extends Feature {
16
16
  options["data-framer-portal-id"] ? void 0 : getClosestProjectingNode(this.state.visualElement.parent)
17
17
  );
18
18
  this.state.visualElement.projection.isPresent = true;
19
- this.state.visualElement.projection.setOptions({
20
- layout: options.layout,
21
- layoutId: options.layoutId,
22
- // TODO: drag
23
- alwaysMeasureLayout: false,
24
- visualElement: this.state.visualElement,
25
- animationType: typeof options.layout === "string" ? options.layout : "both",
26
- // initialPromotionConfig
27
- layoutRoot: options.layoutRoot,
28
- layoutScroll: options.layoutScroll,
29
- crossfade: options.crossfade,
30
- onExitComplete: () => {
31
- var _a;
32
- if (!((_a = this.state.visualElement.projection) == null ? void 0 : _a.isPresent)) {
33
- const done = doneCallbacks.get(this.state.element);
34
- this.state.isSafeToRemove = true;
35
- if (done) {
36
- done({
37
- detail: {
38
- isExit: true
39
- }
40
- }, true);
41
- }
42
- }
43
- }
44
- });
19
+ this.setOptions();
45
20
  }
46
21
  beforeMount() {
47
22
  this.initProjection();
48
23
  }
49
- update() {
24
+ setOptions() {
50
25
  const options = this.state.options;
51
26
  this.state.visualElement.projection.setOptions({
52
27
  layout: options.layout,
53
28
  layoutId: options.layoutId,
54
- // TODO: drag
55
- alwaysMeasureLayout: false,
29
+ alwaysMeasureLayout: Boolean(options.drag) || options.dragConstraints && isHTMLElement(options.dragConstraints),
56
30
  visualElement: this.state.visualElement,
57
31
  animationType: typeof options.layout === "string" ? options.layout : "both",
58
32
  // initialPromotionConfig
@@ -61,6 +35,9 @@ class ProjectionFeature extends Feature {
61
35
  crossfade: options.crossfade
62
36
  });
63
37
  }
38
+ update() {
39
+ this.setOptions();
40
+ }
64
41
  mount() {
65
42
  var _a;
66
43
  (_a = this.state.visualElement.projection) == null ? void 0 : _a.mount(this.state.element);
package/dist/es/index.mjs CHANGED
@@ -1,8 +1,9 @@
1
- import { default as default2 } from "./components/Motion.vue.mjs";
2
- import { default as default3 } from "./components/LayoutGroup.vue.mjs";
1
+ import { default as default2 } from "./components/LayoutGroup.vue.mjs";
3
2
  import { useLayoutGroup } from "./components/use-layout-group.mjs";
4
3
  import { injectLayoutGroup, injectMotion, provideLayoutGroup, provideMotion } from "./components/context.mjs";
5
4
  import { components, utilities } from "./constants/index.mjs";
5
+ import { useDragControls } from "./features/gestures/drag/use-drag-controls.mjs";
6
+ import { default as default3 } from "./components/motion/Motion.vue.mjs";
6
7
  import { default as default4 } from "./components/animate-presence/AnimatePresence.vue.mjs";
7
8
  import { default as default5 } from "./components/motion-config/MotionConfig.vue.mjs";
8
9
  import { MotionValue, motionValue, motionValue as motionValue2 } from "./external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/value/index.mjs";
@@ -38,6 +39,7 @@ import { transform } from "./external/.pnpm/framer-motion@11.16.6/external/frame
38
39
  import { wrap } from "./external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/utils/wrap.mjs";
39
40
  import { cancelSync, sync } from "./external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/frameloop/index-legacy.mjs";
40
41
  import { cancelFrame, frame, frameData, frameSteps } from "./external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/frameloop/frame.mjs";
42
+ import { motion } from "./components/motion/NameSpace.mjs";
41
43
  import { provideMotionConfig, useMotionConfig } from "./components/motion-config/context.mjs";
42
44
  import { useComputed } from "./value/use-computed.mjs";
43
45
  import { useCombineMotionValues } from "./value/use-combine-values.mjs";
@@ -57,8 +59,8 @@ import { millisecondsToSeconds, secondsToMilliseconds } from "./utils/time-conve
57
59
  import { getContextWindow } from "./utils/get-context-window.mjs";
58
60
  export {
59
61
  default4 as AnimatePresence,
60
- default3 as LayoutGroup,
61
- default2 as Motion,
62
+ default2 as LayoutGroup,
63
+ default3 as Motion,
62
64
  default5 as MotionConfig,
63
65
  MotionValue,
64
66
  animate,
@@ -99,6 +101,7 @@ export {
99
101
  millisecondsToSeconds,
100
102
  mirrorEasing,
101
103
  mix,
104
+ motion,
102
105
  motionValue,
103
106
  noop,
104
107
  pipe,
@@ -120,6 +123,7 @@ export {
120
123
  useAnimationFrame,
121
124
  useCombineMotionValues,
122
125
  useComputed,
126
+ useDragControls,
123
127
  useInView,
124
128
  useLayoutGroup,
125
129
  useMotionConfig,
@@ -1,18 +1,17 @@
1
1
  import { invariant } from "hey-listen";
2
2
  import { visualElementStore } from "../external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/render/store.mjs";
3
+ import { isDef } from "@vueuse/core";
3
4
  import { resolveVariant, getOptions, hasChanged } from "./utils.mjs";
4
5
  import { FeatureManager } from "../features/feature-manager.mjs";
5
6
  import { style } from "./style.mjs";
6
7
  import { transformResetValue } from "./transform.mjs";
7
8
  import { motionEvent } from "./event.mjs";
8
9
  import { createVisualElement } from "./create-visual-element.mjs";
9
- import { animateVariantsChildren } from "./animate-variants-children.mjs";
10
10
  import { doneCallbacks } from "../components/presence.mjs";
11
11
  import { frame } from "../external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/frameloop/frame.mjs";
12
12
  import { noop } from "../external/.pnpm/motion-utils@11.16.0/external/motion-utils/dist/es/noop.mjs";
13
13
  import "../external/.pnpm/motion-utils@11.16.0/external/motion-utils/dist/es/errors.mjs";
14
14
  import { animate } from "../external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/animation/animate/index.mjs";
15
- import { isDef } from "../external/.pnpm/@vueuse_shared@12.0.0_typescript@5.7.2/external/@vueuse/shared/index.mjs";
16
15
  const STATE_TYPES = ["initial", "animate", "inView", "hover", "press", "whileDrag", "exit"];
17
16
  const mountedStates = /* @__PURE__ */ new WeakMap();
18
17
  let id = 0;
@@ -24,7 +23,7 @@ class MotionState {
24
23
  this.isVShow = false;
25
24
  this.children = /* @__PURE__ */ new Set();
26
25
  this.activeStates = {
27
- // initial: true,
26
+ initial: true,
28
27
  animate: true
29
28
  };
30
29
  this._context = null;
@@ -58,6 +57,7 @@ class MotionState {
58
57
  this.initTarget(initialVariantSource);
59
58
  this.featureManager = new FeatureManager(this);
60
59
  }
60
+ // Get animation context, falling back to parent context
61
61
  get context() {
62
62
  if (!this._context) {
63
63
  const handler = {
@@ -70,13 +70,16 @@ class MotionState {
70
70
  }
71
71
  return this._context;
72
72
  }
73
+ // Initialize animation target values
73
74
  initTarget(initialVariantSource) {
74
75
  this.baseTarget = resolveVariant(this.options[initialVariantSource] || this.context[initialVariantSource], this.options.variants) || {};
75
76
  this.target = {};
76
77
  }
78
+ // Get initial animation state
77
79
  get initial() {
78
80
  return isDef(this.options.initial) ? this.options.initial : this.context.initial;
79
81
  }
82
+ // Update visual element with new options
80
83
  updateOptions() {
81
84
  this.visualElement.update({
82
85
  ...this.options,
@@ -91,6 +94,7 @@ class MotionState {
91
94
  beforeMount() {
92
95
  this.featureManager.beforeMount();
93
96
  }
97
+ // Mount motion state to DOM element
94
98
  mount(element, options, notAnimate = false) {
95
99
  invariant(
96
100
  Boolean(element),
@@ -115,13 +119,14 @@ class MotionState {
115
119
  }
116
120
  }
117
121
  this.featureManager.mount();
118
- if (!notAnimate) {
119
- this.animateUpdates(true);
122
+ if (!notAnimate && this.options.animate) {
123
+ this.animateUpdates();
120
124
  }
121
125
  }
122
126
  beforeUnmount() {
123
127
  this.featureManager.beforeUnmount();
124
128
  }
129
+ // Unmount motion state and optionally unmount children
125
130
  unmount(unMountChildren = false) {
126
131
  var _a, _b, _c;
127
132
  mountedStates.delete(this.element);
@@ -147,6 +152,7 @@ class MotionState {
147
152
  beforeUpdate() {
148
153
  this.featureManager.beforeUpdate();
149
154
  }
155
+ // Update motion state with new options
150
156
  update(options, notAnimate = false) {
151
157
  const prevAnimate = JSON.stringify(this.options.animate);
152
158
  this.options = options;
@@ -160,31 +166,33 @@ class MotionState {
160
166
  this.animateUpdates();
161
167
  }
162
168
  }
169
+ // Set animation state active status
163
170
  setActive(name, isActive, isAnimate = true) {
164
171
  var _a;
165
172
  if (!this.element || this.activeStates[name] === isActive)
166
173
  return;
167
174
  this.activeStates[name] = isActive;
168
175
  (_a = this.visualElement.variantChildren) == null ? void 0 : _a.forEach((child) => {
169
- child.state.setActive(name, isActive, !isActive);
176
+ child.state.setActive(name, isActive, false);
170
177
  });
171
178
  if (isAnimate) {
172
179
  this.animateUpdates();
173
180
  }
174
181
  }
175
- animateUpdates(isInitial = false) {
182
+ // Core animation update logic
183
+ animateUpdates(controlActiveState = void 0, controlDelay = 0) {
184
+ var _a;
176
185
  const prevTarget = this.target;
177
- this.target = {};
178
- const activeState = {};
186
+ this.target = {
187
+ ...this.baseTarget
188
+ };
179
189
  const animationOptions = {};
180
190
  let transition;
191
+ if (controlActiveState) {
192
+ this.activeStates = { ...this.activeStates, ...controlActiveState };
193
+ }
181
194
  for (const name of STATE_TYPES) {
182
- if (name === "initial") {
183
- if (!isInitial) {
184
- continue;
185
- }
186
- }
187
- if (!this.activeStates[name] && name !== "initial") {
195
+ if (!this.activeStates[name]) {
188
196
  continue;
189
197
  }
190
198
  const definition = isDef(this.options[name]) ? this.options[name] : this.context[name];
@@ -194,15 +202,9 @@ class MotionState {
194
202
  this.options.custom
195
203
  );
196
204
  transition = Object.assign({}, this.options.transition, variant == null ? void 0 : variant.transition);
197
- if (typeof definition === "string") {
198
- activeState[name] = {
199
- definition,
200
- transition
201
- };
202
- }
203
205
  if (!variant)
204
206
  continue;
205
- const allTarget = { ...prevTarget, ...variant };
207
+ const allTarget = { ...variant };
206
208
  for (const key in allTarget) {
207
209
  if (key === "transition")
208
210
  continue;
@@ -214,18 +216,15 @@ class MotionState {
214
216
  }
215
217
  }
216
218
  const allTargetKeys = /* @__PURE__ */ new Set([
217
- ...Object.keys(this.target),
218
- ...Object.keys(prevTarget)
219
+ ...Object.keys(this.target)
219
220
  ]);
220
221
  const animationFactories = [];
221
222
  allTargetKeys.forEach((key) => {
222
- var _a;
223
- if (this.target[key] === void 0) {
224
- this.target[key] = this.baseTarget[key];
225
- }
223
+ var _a2;
226
224
  if (hasChanged(prevTarget[key], this.target[key])) {
227
- (_a = this.baseTarget)[key] ?? (_a[key] = style.get(this.element, key));
225
+ (_a2 = this.baseTarget)[key] ?? (_a2[key] = style.get(this.element, key));
228
226
  const keyValue = this.target[key] === "none" ? transformResetValue[key] : this.target[key];
227
+ const targetTransition = animationOptions[key];
229
228
  animationFactories.push(
230
229
  () => {
231
230
  return animate(
@@ -233,7 +232,10 @@ class MotionState {
233
232
  {
234
233
  [key]: keyValue
235
234
  },
236
- animationOptions[key] || {}
235
+ {
236
+ ...targetTransition,
237
+ delay: ((targetTransition == null ? void 0 : targetTransition.delay) || 0) + controlDelay
238
+ }
237
239
  );
238
240
  }
239
241
  );
@@ -241,10 +243,15 @@ class MotionState {
241
243
  });
242
244
  let getChildAnimations = () => Promise.resolve();
243
245
  let childAnimations = [];
244
- if (Object.keys(activeState).length) {
245
- const { getAnimations, animations: animations2 } = animateVariantsChildren(this, activeState, isInitial);
246
- getChildAnimations = getAnimations;
247
- childAnimations = animations2;
246
+ if (((_a = this.visualElement.variantChildren) == null ? void 0 : _a.size) && !controlActiveState) {
247
+ const { staggerChildren = 0, staggerDirection = 1, delayChildren = 0 } = transition || {};
248
+ const maxStaggerDuration = (this.visualElement.variantChildren.size - 1) * staggerChildren;
249
+ const generateStaggerDuration = staggerDirection === 1 ? (i = 0) => i * staggerChildren : (i = 0) => maxStaggerDuration - i * staggerChildren;
250
+ childAnimations = Array.from(this.visualElement.variantChildren).map((child, index) => {
251
+ const childDelay = delayChildren + generateStaggerDuration(index);
252
+ return child.state.animateUpdates(this.activeStates, childDelay);
253
+ }).filter(Boolean);
254
+ getChildAnimations = () => Promise.all(childAnimations.map((animation) => animation()));
248
255
  }
249
256
  let animations;
250
257
  const getAnimation = () => {
@@ -253,29 +260,38 @@ class MotionState {
253
260
  };
254
261
  const { when } = transition;
255
262
  let animationPromise;
256
- if (when) {
257
- const [first, last] = when === "beforeChildren" ? [getAnimation, getChildAnimations] : [getChildAnimations, getAnimation];
258
- animationPromise = first().then(() => last());
259
- } else {
260
- animationPromise = Promise.all([getAnimation(), getChildAnimations()]);
261
- }
262
263
  const isExit = this.activeStates.exit;
263
- if (!(animations == null ? void 0 : animations.length) && !childAnimations.length) {
264
- if (isExit) {
265
- this.element.dispatchEvent(motionEvent("motionstart", this.target));
266
- this.element.dispatchEvent(motionEvent("motioncomplete", {
267
- ...this.target
268
- }, isExit));
264
+ const animationTarget = { ...this.target };
265
+ const element = this.element;
266
+ function finishAnimation() {
267
+ if (!(animations == null ? void 0 : animations.length) && !childAnimations.length) {
268
+ if (isExit) {
269
+ element.dispatchEvent(motionEvent("motionstart", animationTarget));
270
+ element.dispatchEvent(motionEvent("motioncomplete", animationTarget, isExit));
271
+ }
272
+ return;
269
273
  }
270
- return;
274
+ element.dispatchEvent(motionEvent("motionstart", animationTarget));
275
+ animationPromise.then(() => {
276
+ element.dispatchEvent(motionEvent("motioncomplete", animationTarget, isExit));
277
+ }).catch(noop);
278
+ }
279
+ function getAnimationPromise() {
280
+ if (when) {
281
+ const [first, last] = when === "beforeChildren" ? [getAnimation, getChildAnimations] : [getChildAnimations, getAnimation];
282
+ animationPromise = first().then(() => last());
283
+ finishAnimation();
284
+ return animationPromise;
285
+ } else {
286
+ animationPromise = Promise.all([getAnimation(), getChildAnimations()]);
287
+ finishAnimation();
288
+ return animationPromise;
289
+ }
290
+ }
291
+ if (controlActiveState) {
292
+ return getAnimationPromise;
271
293
  }
272
- const animationTarget = this.target;
273
- this.element.dispatchEvent(motionEvent("motionstart", animationTarget));
274
- animationPromise.then(() => {
275
- this.element.dispatchEvent(motionEvent("motioncomplete", {
276
- ...animationTarget
277
- }, isExit));
278
- }).catch(noop);
294
+ getAnimationPromise();
279
295
  }
280
296
  isMounted() {
281
297
  return Boolean(this.element);
@@ -1,3 +1,4 @@
1
+ import "@vueuse/core";
1
2
  import { noopReturn } from "./utils.mjs";
2
3
  const rotation = {
3
4
  syntax: "<angle>",
@@ -0,0 +1 @@
1
+ export declare function requestIdleCallback(callback: () => void): void;
@@ -1,2 +1,3 @@
1
+ export { Motion, motion } from './motion';
1
2
  export * from './animate-presence';
2
3
  export * from './motion-config';
@@ -1,5 +1,5 @@
1
1
  import { IntrinsicElementAttributes } from 'vue';
2
- import { ElementType, Options, SVGAttributesWithMotionValues, SetMotionValueType } from '../types';
2
+ import { ElementType, Options, SVGAttributesWithMotionValues, SetMotionValueType } from '../../types';
3
3
  export interface MotionProps<T extends ElementType = 'div', K = unknown> extends Options<K> {
4
4
  as?: T;
5
5
  asChild?: boolean;
@@ -0,0 +1,11 @@
1
+ import { DefineComponent, ExtractPropTypes, ExtractPublicPropTypes, IntrinsicElementAttributes } from 'vue';
2
+ import { MotionProps } from './Motion';
3
+ type ComponentProps<T> = T extends DefineComponent<ExtractPropTypes<infer Props>, any, any> ? ExtractPublicPropTypes<Props> : never;
4
+ type MotionComponentProps = IntrinsicElementAttributes & {
5
+ create: <T extends DefineComponent>(T: any) => DefineComponent<MotionProps<any, unknown> & ComponentProps<T>>;
6
+ };
7
+ interface MotionNameSpace extends Record<keyof IntrinsicElementAttributes, DefineComponent<MotionProps<keyof IntrinsicElementAttributes, unknown> & MotionComponentProps[keyof IntrinsicElementAttributes]>> {
8
+ create: MotionComponentProps['create'];
9
+ }
10
+ export declare const motion: MotionNameSpace;
11
+ export {};
@@ -0,0 +1,2 @@
1
+ export { motion } from './NameSpace';
2
+ export { default as Motion, type MotionProps } from './Motion';
@@ -1,4 +1,4 @@
1
- import { MotionProps } from '../../../components/Motion';
1
+ import { MotionProps } from '../../../components/motion/Motion';
2
2
  import { Options } from '../../../types';
3
3
  import { Point, VisualElement } from 'framer-motion';
4
4
  export declare const elementDragControls: WeakMap<VisualElement<unknown, unknown, {}>, VisualElementDragControls>;
@@ -3,5 +3,7 @@ import { Feature } from '../..';
3
3
  export declare class InViewGesture extends Feature {
4
4
  isActive(): boolean;
5
5
  constructor(state: MotionState);
6
+ startObserver(): void;
6
7
  mount(): void;
8
+ update(): void;
7
9
  }
@@ -3,6 +3,7 @@ export declare class ProjectionFeature extends Feature {
3
3
  constructor(state: any);
4
4
  initProjection(): void;
5
5
  beforeMount(): void;
6
+ setOptions(): void;
6
7
  update(): void;
7
8
  mount(): void;
8
9
  }
@@ -1,6 +1,5 @@
1
1
  export * from 'framer-motion/dom';
2
2
  export { motionValue as useMotionValue } from 'framer-motion/dom';
3
- export { default as Motion, type MotionProps } from './components/Motion';
4
3
  export * from './components';
5
4
  export { default as LayoutGroup } from './components/LayoutGroup';
6
5
  export { useLayoutGroup } from './components/use-layout-group';
@@ -11,4 +10,5 @@ export * from './constants';
11
10
  export * from './types';
12
11
  export * from './animation';
13
12
  export * from './utils';
13
+ export { useDragControls } from './features/gestures/drag/use-drag-controls';
14
14
  export type { PanInfo } from './features/gestures/pan/PanSession';
@@ -1,9 +1,9 @@
1
1
  import { MotionState } from './motion-state';
2
- import { AnimateOptions, AnimationFactory } from '../types';
2
+ import { $Transition, AnimationFactory } from '../types';
3
3
  export type ActiveVariant = {
4
4
  [key: string]: {
5
5
  definition: string;
6
- transition: AnimateOptions;
6
+ transition: $Transition;
7
7
  };
8
8
  };
9
9
  export declare function animateVariantsChildren(state: MotionState, activeState: ActiveVariant, isFirstAnimate?: boolean): {
@@ -3,6 +3,9 @@ import { DOMKeyframesDefinition, VisualElement } from 'framer-motion';
3
3
  declare const STATE_TYPES: readonly ["initial", "animate", "inView", "hover", "press", "whileDrag", "exit"];
4
4
  type StateType = typeof STATE_TYPES[number];
5
5
  export declare const mountedStates: WeakMap<Element, MotionState>;
6
+ /**
7
+ * Core class that manages animation state and orchestrates animations
8
+ */
6
9
  export declare class MotionState {
7
10
  readonly id: string;
8
11
  element: HTMLElement | null;
@@ -30,7 +33,7 @@ export declare class MotionState {
30
33
  beforeUpdate(): void;
31
34
  update(options: Options, notAnimate?: boolean): void;
32
35
  setActive(name: StateType, isActive: boolean, isAnimate?: boolean): void;
33
- animateUpdates(isInitial?: boolean): void;
36
+ animateUpdates(controlActiveState?: typeof this.activeStates, controlDelay?: number): () => Promise<any>;
34
37
  isMounted(): boolean;
35
38
  getOptions(): Options<any>;
36
39
  willUpdate(label: string): void;
@@ -1,12 +1,12 @@
1
- import { Options } from '../types';
2
- import { AnimationOptions, Variant } from 'framer-motion';
1
+ import { $Transition, Options } from '../types';
2
+ import { Variant } from 'framer-motion';
3
3
  import { IntrinsicElementAttributes } from 'vue';
4
4
  export declare function resolveVariant(definition?: Options['initial'], variants?: Options['variants'], custom?: Options['custom']): Variant | undefined;
5
5
  export declare function hasChanged(a: any, b: any): boolean;
6
6
  export declare function shallowCompare(next: any[], prev: any[]): boolean;
7
7
  export declare function addUniqueItem<T>(array: T[], item: T): void;
8
8
  export declare function removeItem<T>(array: T[], item: T): void;
9
- export declare function getOptions(options: AnimationOptions, key: string): AnimationOptions;
9
+ export declare function getOptions(options: $Transition, key: string): $Transition;
10
10
  export declare function isCssVar(name: string): boolean;
11
11
  export declare const noopReturn: <V>(v: V) => V;
12
12
  export declare function isNumber(value: any): boolean;