motion-v 0.6.2 → 0.7.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 (59) hide show
  1. package/dist/cjs/index.js +408 -221
  2. package/dist/es/animation/hooks/animation-controls.mjs +78 -0
  3. package/dist/es/animation/{use-animate.mjs → hooks/use-animate.mjs} +1 -1
  4. package/dist/es/animation/hooks/use-animation-controls.mjs +16 -0
  5. package/dist/es/animation/utils.mjs +6 -0
  6. package/dist/es/components/animate-presence/AnimatePresence.vue.mjs +5 -1
  7. package/dist/es/components/{Motion.vue.mjs → motion/Motion.vue.mjs} +11 -8
  8. package/dist/es/components/motion/NameSpace.mjs +47 -0
  9. package/dist/es/constants/index.mjs +2 -1
  10. package/dist/es/features/animation/animation.mjs +33 -0
  11. package/dist/es/features/feature-manager.mjs +5 -1
  12. package/dist/es/features/gestures/drag/use-drag-controls.mjs +43 -0
  13. package/dist/es/features/gestures/focus/index.mjs +36 -0
  14. package/dist/es/features/gestures/in-view/index.mjs +25 -5
  15. package/dist/es/features/layout/projection.mjs +7 -30
  16. package/dist/es/index.mjs +11 -5
  17. package/dist/es/state/animate-updates.mjs +129 -0
  18. package/dist/es/state/motion-state.mjs +19 -120
  19. package/dist/es/state/style.mjs +2 -2
  20. package/dist/es/state/transform.mjs +1 -0
  21. package/dist/src/animation/hooks/animation-controls.d.ts +8 -0
  22. package/dist/src/animation/hooks/use-animate.d.ts +8 -0
  23. package/dist/src/animation/hooks/use-animation-controls.d.ts +33 -0
  24. package/dist/src/animation/index.d.ts +2 -1
  25. package/dist/src/animation/types.d.ts +68 -0
  26. package/dist/src/animation/utils.d.ts +2 -0
  27. package/dist/src/components/index.d.ts +1 -0
  28. package/dist/src/components/{Motion.d.ts → motion/Motion.d.ts} +1 -1
  29. package/dist/src/components/motion/NameSpace.d.ts +11 -0
  30. package/dist/src/components/motion/index.d.ts +2 -0
  31. package/dist/src/features/animation/animation.d.ts +13 -0
  32. package/dist/src/features/gestures/drag/VisualElementDragControls.d.ts +1 -1
  33. package/dist/src/features/gestures/focus/index.d.ts +7 -0
  34. package/dist/src/features/gestures/focus/types.d.ts +6 -0
  35. package/dist/src/features/gestures/in-view/index.d.ts +2 -0
  36. package/dist/src/features/index.d.ts +1 -0
  37. package/dist/src/features/layout/projection.d.ts +1 -0
  38. package/dist/src/index.d.ts +1 -1
  39. package/dist/src/state/animate-updates.d.ts +19 -0
  40. package/dist/src/state/animate-variants-children.d.ts +2 -2
  41. package/dist/src/state/animation/index.d.ts +0 -0
  42. package/dist/src/state/animation/types.d.ts +0 -0
  43. package/dist/src/state/motion-state.d.ts +5 -4
  44. package/dist/src/state/utils.d.ts +4 -4
  45. package/dist/src/types/framer-motion.d.ts +17 -0
  46. package/dist/src/types/state.d.ts +10 -16
  47. package/package.json +3 -3
  48. package/dist/es/external/.pnpm/@vueuse_shared@12.0.0_typescript@5.7.2/external/@vueuse/shared/index.mjs +0 -6
  49. package/dist/es/state/animate-variants-children.mjs +0 -74
  50. /package/dist/es/components/{Motion.vue2.mjs → motion/Motion.vue2.mjs} +0 -0
  51. /package/dist/es/components/{Primitive.mjs → motion/Primitive.mjs} +0 -0
  52. /package/dist/es/components/{Slot.mjs → motion/Slot.mjs} +0 -0
  53. /package/dist/es/components/{renderSlotFragments.mjs → motion/renderSlotFragments.mjs} +0 -0
  54. /package/dist/es/components/{utils.mjs → motion/utils.mjs} +0 -0
  55. /package/dist/src/{animation/use-animation.d.ts → components/animate-presence/utils.d.ts} +0 -0
  56. /package/dist/src/components/{Primitive.d.ts → motion/Primitive.d.ts} +0 -0
  57. /package/dist/src/components/{Slot.d.ts → motion/Slot.d.ts} +0 -0
  58. /package/dist/src/components/{renderSlotFragments.d.ts → motion/renderSlotFragments.d.ts} +0 -0
  59. /package/dist/src/components/{utils.d.ts → motion/utils.d.ts} +0 -0
@@ -1,19 +1,12 @@
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 { resolveVariant, getOptions, hasChanged } from "./utils.mjs";
3
+ import { isDef } from "@vueuse/core";
4
+ import { resolveVariant } from "./utils.mjs";
4
5
  import { FeatureManager } from "../features/feature-manager.mjs";
5
- import { style } from "./style.mjs";
6
- import { transformResetValue } from "./transform.mjs";
7
- import { motionEvent } from "./event.mjs";
8
6
  import { createVisualElement } from "./create-visual-element.mjs";
9
- import { animateVariantsChildren } from "./animate-variants-children.mjs";
10
7
  import { doneCallbacks } from "../components/presence.mjs";
8
+ import { animateUpdates } from "./animate-updates.mjs";
11
9
  import { frame } from "../external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/frameloop/frame.mjs";
12
- import { noop } from "../external/.pnpm/motion-utils@11.16.0/external/motion-utils/dist/es/noop.mjs";
13
- import "../external/.pnpm/motion-utils@11.16.0/external/motion-utils/dist/es/errors.mjs";
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
- const STATE_TYPES = ["initial", "animate", "inView", "hover", "press", "whileDrag", "exit"];
17
10
  const mountedStates = /* @__PURE__ */ new WeakMap();
18
11
  let id = 0;
19
12
  class MotionState {
@@ -24,10 +17,11 @@ class MotionState {
24
17
  this.isVShow = false;
25
18
  this.children = /* @__PURE__ */ new Set();
26
19
  this.activeStates = {
27
- // initial: true,
20
+ initial: true,
28
21
  animate: true
29
22
  };
30
23
  this._context = null;
24
+ this.animateUpdates = animateUpdates;
31
25
  this.id = `motion-state-${id++}`;
32
26
  this.options = options;
33
27
  this.parent = parent;
@@ -58,6 +52,7 @@ class MotionState {
58
52
  this.initTarget(initialVariantSource);
59
53
  this.featureManager = new FeatureManager(this);
60
54
  }
55
+ // Get animation context, falling back to parent context
61
56
  get context() {
62
57
  if (!this._context) {
63
58
  const handler = {
@@ -70,13 +65,16 @@ class MotionState {
70
65
  }
71
66
  return this._context;
72
67
  }
68
+ // Initialize animation target values
73
69
  initTarget(initialVariantSource) {
74
70
  this.baseTarget = resolveVariant(this.options[initialVariantSource] || this.context[initialVariantSource], this.options.variants) || {};
75
71
  this.target = {};
76
72
  }
73
+ // Get initial animation state
77
74
  get initial() {
78
75
  return isDef(this.options.initial) ? this.options.initial : this.context.initial;
79
76
  }
77
+ // Update visual element with new options
80
78
  updateOptions() {
81
79
  this.visualElement.update({
82
80
  ...this.options,
@@ -91,6 +89,7 @@ class MotionState {
91
89
  beforeMount() {
92
90
  this.featureManager.beforeMount();
93
91
  }
92
+ // Mount motion state to DOM element
94
93
  mount(element, options, notAnimate = false) {
95
94
  invariant(
96
95
  Boolean(element),
@@ -115,13 +114,14 @@ class MotionState {
115
114
  }
116
115
  }
117
116
  this.featureManager.mount();
118
- if (!notAnimate) {
119
- this.animateUpdates(true);
117
+ if (!notAnimate && this.options.animate) {
118
+ this.animateUpdates();
120
119
  }
121
120
  }
122
121
  beforeUnmount() {
123
122
  this.featureManager.beforeUnmount();
124
123
  }
124
+ // Unmount motion state and optionally unmount children
125
125
  unmount(unMountChildren = false) {
126
126
  var _a, _b, _c;
127
127
  mountedStates.delete(this.element);
@@ -147,6 +147,7 @@ class MotionState {
147
147
  beforeUpdate() {
148
148
  this.featureManager.beforeUpdate();
149
149
  }
150
+ // Update motion state with new options
150
151
  update(options, notAnimate = false) {
151
152
  const prevAnimate = JSON.stringify(this.options.animate);
152
153
  this.options = options;
@@ -160,122 +161,20 @@ class MotionState {
160
161
  this.animateUpdates();
161
162
  }
162
163
  }
164
+ // Set animation state active status
163
165
  setActive(name, isActive, isAnimate = true) {
164
166
  var _a;
165
167
  if (!this.element || this.activeStates[name] === isActive)
166
168
  return;
167
169
  this.activeStates[name] = isActive;
168
170
  (_a = this.visualElement.variantChildren) == null ? void 0 : _a.forEach((child) => {
169
- child.state.setActive(name, isActive, !isActive);
171
+ child.state.setActive(name, isActive, false);
170
172
  });
171
173
  if (isAnimate) {
172
- this.animateUpdates();
173
- }
174
- }
175
- animateUpdates(isInitial = false) {
176
- const prevTarget = this.target;
177
- this.target = {};
178
- const activeState = {};
179
- const animationOptions = {};
180
- let transition;
181
- for (const name of STATE_TYPES) {
182
- if (name === "initial") {
183
- if (!isInitial) {
184
- continue;
185
- }
186
- }
187
- if (!this.activeStates[name] && name !== "initial") {
188
- continue;
189
- }
190
- const definition = isDef(this.options[name]) ? this.options[name] : this.context[name];
191
- const variant = resolveVariant(
192
- definition,
193
- this.options.variants,
194
- this.options.custom
195
- );
196
- 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
- if (!variant)
204
- continue;
205
- const allTarget = { ...prevTarget, ...variant };
206
- for (const key in allTarget) {
207
- if (key === "transition")
208
- continue;
209
- this.target[key] = variant[key];
210
- animationOptions[key] = getOptions(
211
- transition,
212
- key
213
- );
214
- }
215
- }
216
- const allTargetKeys = /* @__PURE__ */ new Set([
217
- ...Object.keys(this.target),
218
- ...Object.keys(prevTarget)
219
- ]);
220
- const animationFactories = [];
221
- allTargetKeys.forEach((key) => {
222
- var _a;
223
- if (this.target[key] === void 0) {
224
- this.target[key] = this.baseTarget[key];
225
- }
226
- if (hasChanged(prevTarget[key], this.target[key])) {
227
- (_a = this.baseTarget)[key] ?? (_a[key] = style.get(this.element, key));
228
- const keyValue = this.target[key] === "none" ? transformResetValue[key] : this.target[key];
229
- animationFactories.push(
230
- () => {
231
- return animate(
232
- this.element,
233
- {
234
- [key]: keyValue
235
- },
236
- animationOptions[key] || {}
237
- );
238
- }
239
- );
240
- }
241
- });
242
- let getChildAnimations = () => Promise.resolve();
243
- let childAnimations = [];
244
- if (Object.keys(activeState).length) {
245
- const { getAnimations, animations: animations2 } = animateVariantsChildren(this, activeState, isInitial);
246
- getChildAnimations = getAnimations;
247
- childAnimations = animations2;
248
- }
249
- let animations;
250
- const getAnimation = () => {
251
- animations = animationFactories.map((factory) => factory()).filter(Boolean);
252
- return Promise.all(animations);
253
- };
254
- const { when } = transition;
255
- 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
- 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));
269
- }
270
- return;
174
+ this.animateUpdates({
175
+ isFallback: !isActive
176
+ });
271
177
  }
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);
279
178
  }
280
179
  isMounted() {
281
180
  return Boolean(this.element);
@@ -1,5 +1,5 @@
1
- import { isCssVar, isNumber } from "./utils.mjs";
2
- import { transformDefinitions, isTransform, transformAlias, buildTransformTemplate } from "./transform.mjs";
1
+ import { isNumber, isCssVar } from "./utils.mjs";
2
+ import { isTransform, transformAlias, transformDefinitions, buildTransformTemplate } from "./transform.mjs";
3
3
  import { isMotionValue } from "../utils/motion-value.mjs";
4
4
  const style = {
5
5
  get: (element, name) => {
@@ -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,8 @@
1
+ import { AnimationControls } from '../types';
2
+ import { MotionState } from '../../state';
3
+ import { Options } from '../../types';
4
+ /**
5
+ * @public
6
+ */
7
+ export declare function animationControls(): AnimationControls;
8
+ export declare function setValues(state: MotionState, definition: Options['animate']): void;
@@ -0,0 +1,8 @@
1
+ import { AnimationPlaybackControls } from 'framer-motion';
2
+ import { Ref, UnwrapRef } from 'vue';
3
+ import { createScopedAnimate } from 'framer-motion/dom';
4
+ type Scope = Ref<UnwrapRef<Element>> & {
5
+ animations: AnimationPlaybackControls[];
6
+ };
7
+ export declare function useAnimate<T extends Element = any>(): [Scope, ReturnType<typeof createScopedAnimate>];
8
+ export {};
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Creates `AnimationControls`, which can be used to manually start, stop
3
+ * and sequence animations on one or more components.
4
+ *
5
+ * The returned `AnimationControls` should be passed to the `animate` property
6
+ * of the components you want to animate.
7
+ *
8
+ * These components can then be animated with the `start` method.
9
+ *
10
+ * ```jsx
11
+ * import { motion, useAnimationControls } from 'motion-v'
12
+ *
13
+ * export default defineComponent({
14
+ * setup() {
15
+ * const controls = useAnimationControls()
16
+ *
17
+ * controls.start({
18
+ * x: 100,
19
+ * transition: { duration: 0.5 },
20
+ * })
21
+ *
22
+ * return () => (
23
+ * <motion.div animate={controls} />
24
+ * )
25
+ * }
26
+ * })
27
+ * ```
28
+ *
29
+ * @returns Animation controller with `start`, `stop`, `set` and `mount` methods
30
+ *
31
+ * @public
32
+ */
33
+ export declare function useAnimationControls(): import('../types').AnimationControls;
@@ -1 +1,2 @@
1
- export * from './use-animate';
1
+ export * from './hooks/use-animate';
2
+ export * from './hooks/use-animation-controls';
@@ -0,0 +1,68 @@
1
+ import { MotionState } from '../state';
2
+ import { $Transition, Options } from '../types';
3
+ /**
4
+ * @public
5
+ */
6
+ export interface AnimationControls {
7
+ /**
8
+ * Subscribes a component's animation controls to this.
9
+ *
10
+ * @param controls - The controls to subscribe
11
+ * @returns An unsubscribe function.
12
+ *
13
+ * @internal
14
+ */
15
+ subscribe: (state: MotionState) => () => void;
16
+ /**
17
+ * Starts an animation on all linked components.
18
+ *
19
+ * @remarks
20
+ *
21
+ * ```jsx
22
+ * controls.start("variantLabel")
23
+ * controls.start({
24
+ * x: 0,
25
+ * transition: { duration: 1 }
26
+ * })
27
+ * ```
28
+ *
29
+ * @param definition - Properties or variant label to animate to
30
+ * @param transition - Optional `transtion` to apply to a variant
31
+ * @returns - A `Promise` that resolves when all animations have completed.
32
+ *
33
+ * @public
34
+ */
35
+ start: (definition: Options['animate'], transitionOverride?: $Transition) => Promise<any>;
36
+ /**
37
+ * Instantly set to a set of properties or a variant.
38
+ *
39
+ * ```jsx
40
+ * // With properties
41
+ * controls.set({ opacity: 0 })
42
+ *
43
+ * // With variants
44
+ * controls.set("hidden")
45
+ * ```
46
+ *
47
+ * @privateRemarks
48
+ * We could perform a similar trick to `.start` where this can be called before mount
49
+ * and we maintain a list of of pending actions that get applied on mount. But the
50
+ * expectation of `set` is that it happens synchronously and this would be difficult
51
+ * to do before any children have even attached themselves. It's also poor practise
52
+ * and we should discourage render-synchronous `.start` calls rather than lean into this.
53
+ *
54
+ * @public
55
+ */
56
+ set: (definition: Options['animate']) => void;
57
+ /**
58
+ * Stops animations on all linked components.
59
+ *
60
+ * ```jsx
61
+ * controls.stop()
62
+ * ```
63
+ *
64
+ * @public
65
+ */
66
+ stop: () => void;
67
+ mount: () => () => void;
68
+ }
@@ -0,0 +1,2 @@
1
+ import { AnimationControls } from './types';
2
+ export declare function isAnimationControls(v?: unknown): v is AnimationControls;
@@ -1,2 +1,3 @@
1
+ export { Motion, motion, type MotionProps } 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 = {
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>>> {
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';
@@ -0,0 +1,13 @@
1
+ import { Feature } from '../feature';
2
+ import { MotionState } from '../../state';
3
+ export declare class AnimationFeature extends Feature {
4
+ unmountControls?: () => void;
5
+ constructor(state: MotionState);
6
+ updateAnimationControlsSubscription(): void;
7
+ /**
8
+ * Subscribe any provided AnimationControls to the component's VisualElement
9
+ */
10
+ mount(): void;
11
+ update(): void;
12
+ unmount(): void;
13
+ }
@@ -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>;
@@ -0,0 +1,7 @@
1
+ import { Feature } from '../../feature';
2
+ export declare class FocusGesture extends Feature {
3
+ private isActive;
4
+ onFocus(): void;
5
+ onBlur(): void;
6
+ mount(): void;
7
+ }
@@ -0,0 +1,6 @@
1
+ import { Variant } from '../../../types';
2
+ export type FocusProps = {
3
+ focus?: string | Variant;
4
+ onFocus?: (e: FocusEvent) => void;
5
+ onBlur?: (e: FocusEvent) => void;
6
+ };
@@ -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
  }
@@ -4,3 +4,4 @@ export * from './svg';
4
4
  export * from './layout/layout';
5
5
  export * from './gestures/pan';
6
6
  export * from './feature-manager';
7
+ export * from './animation/animation';
@@ -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';
@@ -0,0 +1,19 @@
1
+ import { $Transition, Options } from '../types';
2
+ import { MotionState } from './motion-state';
3
+ declare const STATE_TYPES: readonly ["initial", "animate", "inView", "hover", "press", "whileDrag", "focus", "exit"];
4
+ export type StateType = typeof STATE_TYPES[number];
5
+ /**
6
+ * 核心动画更新函数,处理所有动画状态变化和执行
7
+ * @param controlActiveState - 需要更新的动画状态
8
+ * @param controlDelay - 动画延迟时间
9
+ * @param directAnimate - 直接动画目标值
10
+ * @param directTransition - 直接动画过渡配置
11
+ */
12
+ export declare function animateUpdates(this: MotionState, { controlActiveState, controlDelay, directAnimate, directTransition, isFallback, }?: {
13
+ controlActiveState?: Partial<Record<string, boolean>>;
14
+ controlDelay?: number;
15
+ directAnimate?: Options['animate'];
16
+ directTransition?: $Transition;
17
+ isFallback?: boolean;
18
+ }): any;
19
+ export {};
@@ -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): {
File without changes
File without changes
@@ -1,8 +1,10 @@
1
1
  import { MotionStateContext, Options } from '../types';
2
2
  import { DOMKeyframesDefinition, VisualElement } from 'framer-motion';
3
- declare const STATE_TYPES: readonly ["initial", "animate", "inView", "hover", "press", "whileDrag", "exit"];
4
- type StateType = typeof STATE_TYPES[number];
3
+ import { StateType, animateUpdates } from './animate-updates';
5
4
  export declare const mountedStates: WeakMap<Element, MotionState>;
5
+ /**
6
+ * Core class that manages animation state and orchestrates animations
7
+ */
6
8
  export declare class MotionState {
7
9
  readonly id: string;
8
10
  element: HTMLElement | null;
@@ -30,9 +32,8 @@ export declare class MotionState {
30
32
  beforeUpdate(): void;
31
33
  update(options: Options, notAnimate?: boolean): void;
32
34
  setActive(name: StateType, isActive: boolean, isAnimate?: boolean): void;
33
- animateUpdates(isInitial?: boolean): void;
35
+ animateUpdates: typeof animateUpdates;
34
36
  isMounted(): boolean;
35
37
  getOptions(): Options<any>;
36
38
  willUpdate(label: string): void;
37
39
  }
38
- export {};
@@ -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
- export declare function resolveVariant(definition?: Options['initial'], variants?: Options['variants'], custom?: Options['custom']): Variant | undefined;
4
+ export declare function resolveVariant(definition?: Options['animate'], 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;
@@ -1,3 +1,4 @@
1
+ import { Inertia, Keyframes, None, Repeat, Spring, Tween } from 'framer-motion';
1
2
  export interface FrameData {
2
3
  delta: number;
3
4
  timestamp: number;
@@ -24,3 +25,19 @@ export interface ScrollInfoOptions {
24
25
  axis?: 'x' | 'y';
25
26
  offset?: ScrollOffset;
26
27
  }
28
+ export interface Orchestration {
29
+ delay?: number;
30
+ when?: false | 'beforeChildren' | 'afterChildren' | string;
31
+ delayChildren?: number;
32
+ staggerChildren?: number;
33
+ staggerDirection?: number;
34
+ }
35
+ type PermissiveTransitionDefinition = {
36
+ [key: string]: any;
37
+ };
38
+ type TransitionDefinition = Tween | Spring | Keyframes | Inertia | None | PermissiveTransitionDefinition;
39
+ type TransitionMap = Orchestration & TransitionDefinition & {
40
+ [key: string]: TransitionDefinition;
41
+ };
42
+ export type $Transition = (Orchestration & Repeat & TransitionDefinition) | (Orchestration & Repeat & TransitionMap);
43
+ export {};
@@ -1,4 +1,4 @@
1
- import { AnimationOptions, DOMKeyframesDefinition, ResolvedValues, Target, TargetAndTransition } from 'framer-motion';
1
+ import { DOMKeyframesDefinition, ResolvedValues, Target, TargetAndTransition } from 'framer-motion';
2
2
  import { MotionValue, TransformProperties, animate } from 'framer-motion/dom';
3
3
  import { IntrinsicElementAttributes } from 'vue';
4
4
  import { LayoutOptions } from '../features/layout/types';
@@ -9,19 +9,13 @@ import { InViewProps } from '../features/gestures/in-view/types';
9
9
  import { LayoutGroupState } from '../components/context';
10
10
  import { PanProps } from '../features/gestures/pan/types';
11
11
  import { MotionConfigState } from '../components/motion-config/types';
12
+ import { $Transition } from './framer-motion';
13
+ import { FocusProps } from '../features/gestures/focus/types';
14
+ import { AnimationControls } from '../animation/types';
12
15
  type AnimationPlaybackControls = ReturnType<typeof animate>;
13
- export interface Orchestration {
14
- delay?: number;
15
- when?: false | 'beforeChildren' | 'afterChildren' | string;
16
- delayChildren?: number;
17
- staggerChildren?: number;
18
- staggerDirection?: number;
19
- }
20
- export interface AnimateOptions extends Omit<Orchestration, 'delay'>, AnimationOptions {
21
- }
22
16
  export type TargetResolver = (custom: any, current: Target, velocity: Target) => TargetAndTransition | string;
23
17
  export interface Variant extends DOMKeyframesDefinition {
24
- transition?: AnimateOptions;
18
+ transition?: $Transition;
25
19
  }
26
20
  export type VariantLabels = string | Variant;
27
21
  interface BoundingBox {
@@ -38,23 +32,23 @@ export type MotionStyle = Partial<{
38
32
  [K in keyof Variant]: Variant[K] | MotionValue;
39
33
  }>;
40
34
  export type ElementType = keyof IntrinsicElementAttributes;
41
- export interface Options<T = any> extends LayoutOptions, PressProps, HoverProps, InViewProps, DragProps, PanProps {
35
+ export interface Options<T = any> extends LayoutOptions, PressProps, HoverProps, InViewProps, DragProps, PanProps, FocusProps {
42
36
  custom?: T;
43
37
  as?: ElementType;
44
38
  initial?: string | Variant | boolean;
45
- animate?: string | Variant;
39
+ animate?: string | Variant | AnimationControls;
46
40
  exit?: string | Variant;
47
41
  variants?: {
48
42
  [k: string]: Variant | ((custom: T) => Variant);
49
43
  };
50
44
  style?: MotionStyle;
51
45
  transformTemplate?: (transform: TransformProperties, generatedTransform: string) => string;
52
- transition?: AnimateOptions & {
53
- layout?: AnimationOptions;
46
+ transition?: $Transition & {
47
+ layout?: $Transition;
54
48
  };
55
49
  layoutGroup?: LayoutGroupState;
56
50
  motionConfig?: MotionConfigState;
57
- onAnimationComplete?: (definition: AnimateOptions) => void;
51
+ onAnimationComplete?: (definition: Options['animate']) => void;
58
52
  onUpdate?: (latest: ResolvedValues) => void;
59
53
  }
60
54
  export interface MotionStateContext {