motion-v 0.4.1 → 0.5.0-beta.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 (30) hide show
  1. package/dist/cjs/index.js +294 -96
  2. package/dist/es/components/AnimatePresence.vue.mjs +13 -2
  3. package/dist/es/components/LayoutGroup.vue.mjs +3 -23
  4. package/dist/es/components/Motion.vue.mjs +16 -15
  5. package/dist/es/components/presence.mjs +5 -2
  6. package/dist/es/components/use-layout-group.mjs +34 -0
  7. package/dist/es/components/use-pop-layout.mjs +47 -0
  8. package/dist/es/components/utils.mjs +8 -0
  9. package/dist/es/constants/index.mjs +1 -1
  10. package/dist/es/features/gestures/hover.mjs +4 -0
  11. package/dist/es/features/gestures/in-view.mjs +4 -0
  12. package/dist/es/features/layout/layout.mjs +7 -4
  13. package/dist/es/state/animate-variants-children.mjs +72 -0
  14. package/dist/es/state/motion-state.mjs +74 -20
  15. package/dist/es/state/schedule.mjs +1 -1
  16. package/dist/src/components/AnimatePresence.d.ts +2 -7
  17. package/dist/src/components/LayoutGroup.d.ts +1 -5
  18. package/dist/src/components/Motion.d.ts +1 -3
  19. package/dist/src/components/presence.d.ts +2 -1
  20. package/dist/src/components/type.d.ts +5 -24
  21. package/dist/src/components/use-layout-group.d.ts +20 -0
  22. package/dist/src/components/use-pop-layout.d.ts +6 -0
  23. package/dist/src/components/utils.d.ts +1 -0
  24. package/dist/src/features/layout/types.d.ts +1 -1
  25. package/dist/src/index.d.ts +5 -3
  26. package/dist/src/state/animate-variants-children.d.ts +15 -0
  27. package/dist/src/state/motion-state.d.ts +8 -7
  28. package/dist/src/types/state.d.ts +11 -2
  29. package/package.json +4 -3
  30. /package/dist/es/external/.pnpm/{@vueuse_shared@12.0.0_typescript@5.5.4 → @vueuse_shared@12.0.0_typescript@5.7.2}/external/@vueuse/shared/index.mjs +0 -0
@@ -0,0 +1,6 @@
1
+ import { AnimatePresenceProps } from './type';
2
+ import { MotionState } from '../state';
3
+ export declare function usePopLayout(props: AnimatePresenceProps): {
4
+ addPopStyle: (state: MotionState) => void;
5
+ removePopStyle: (state: MotionState) => void;
6
+ };
@@ -0,0 +1 @@
1
+ export declare function getMotionElement(el: HTMLElement): HTMLElement;
@@ -1,5 +1,5 @@
1
1
  export interface LayoutOptions {
2
- 'layout'?: boolean;
2
+ 'layout'?: boolean | 'position' | 'size' | 'preserve-aspect';
3
3
  'layoutId'?: string;
4
4
  'layoutScroll'?: boolean;
5
5
  'layoutRoot'?: boolean;
@@ -1,11 +1,13 @@
1
1
  export * from 'framer-motion/dom';
2
2
  export { motionValue as useMotionValue } from 'framer-motion/dom';
3
3
  export { default as Motion, type MotionProps } from './components/Motion';
4
- export { default as AnimatePresence, type AnimatePresenceProps } from './components/AnimatePresence';
5
- export { default as LayoutGroup, type LayoutGroupProps } from './components/LayoutGroup';
4
+ export { default as AnimatePresence } from './components/AnimatePresence';
5
+ export type { AnimatePresenceProps } from './components/type';
6
+ export { default as LayoutGroup } from './components/LayoutGroup';
7
+ export type { LayoutGroupProps } from './components/use-layout-group';
6
8
  export * from './components/context';
7
9
  export * from './value';
8
10
  export * from './constants';
9
- export type { Variant, Options } from './types';
11
+ export * from './types';
10
12
  export * from './animation';
11
13
  export * from './utils';
@@ -0,0 +1,15 @@
1
+ import { MotionState } from './motion-state';
2
+ import { AnimateOptions, AnimationFactory } from '../types';
3
+ export type ActiveVariant = {
4
+ [key: string]: {
5
+ definition: string;
6
+ transition: AnimateOptions;
7
+ };
8
+ };
9
+ export declare function animateVariantsChildren(state: MotionState, activeState: ActiveVariant): {
10
+ animations: any[];
11
+ getAnimations: () => Promise<void>;
12
+ } | {
13
+ animations: AnimationFactory[];
14
+ getAnimations: () => Promise<unknown[]>;
15
+ };
@@ -4,13 +4,15 @@ declare const STATE_TYPES: readonly ["initial", "animate", "inView", "hover", "p
4
4
  type StateType = typeof STATE_TYPES[number];
5
5
  export declare const mountedStates: WeakMap<Element, MotionState>;
6
6
  export declare class MotionState {
7
+ readonly id: string;
7
8
  element: HTMLElement | null;
8
9
  private parent?;
9
10
  private options;
10
- private activeStates;
11
- private depth;
12
- private baseTarget;
13
- private target;
11
+ private isFirstAnimate;
12
+ activeStates: Partial<Record<StateType, boolean>>;
13
+ depth: number;
14
+ baseTarget: DOMKeyframesDefinition;
15
+ target: DOMKeyframesDefinition;
14
16
  private featureManager;
15
17
  visualElement: VisualElement;
16
18
  constructor(options: Options, parent?: MotionState);
@@ -18,14 +20,13 @@ export declare class MotionState {
18
20
  get context(): MotionStateContext;
19
21
  private initTarget;
20
22
  get initial(): string | boolean | import('../types').Variant;
21
- mount(element: HTMLElement): void;
23
+ updateOptions(): void;
24
+ mount(element: HTMLElement, options: Options): void;
22
25
  unmount(): void;
23
26
  update(options: Options): void;
24
27
  setActive(name: StateType, isActive: boolean): void;
25
28
  animateUpdates(): Generator<any, void, unknown>;
26
29
  isMounted(): boolean;
27
- getDepth(): number;
28
30
  getOptions(): Options<any>;
29
- getTarget(): DOMKeyframesDefinition;
30
31
  }
31
32
  export {};
@@ -4,8 +4,17 @@ import { IntrinsicElementAttributes } from 'vue';
4
4
  import { TransformProperties } from './transform';
5
5
  import { LayoutOptions } from '../features/layout/types';
6
6
  type AnimationPlaybackControls = ReturnType<typeof animate>;
7
+ export interface Orchestration {
8
+ delay?: number;
9
+ when?: false | 'beforeChildren' | 'afterChildren' | string;
10
+ delayChildren?: number;
11
+ staggerChildren?: number;
12
+ staggerDirection?: number;
13
+ }
14
+ export interface AnimateOptions extends Omit<Orchestration, 'delay'>, DynamicAnimationOptions {
15
+ }
7
16
  export interface Variant extends DOMKeyframesDefinition {
8
- transition?: DynamicAnimationOptions;
17
+ transition?: AnimateOptions;
9
18
  }
10
19
  export type VariantLabels = string | Variant;
11
20
  type MarginValue = `${number}${'px' | '%'}`;
@@ -46,7 +55,7 @@ export interface Options<T = any> extends LayoutOptions {
46
55
  };
47
56
  style?: MotionStyle;
48
57
  transformTemplate?: (transform: TransformProperties, generatedTransform: string) => string;
49
- transition?: DynamicAnimationOptions;
58
+ transition?: AnimateOptions;
50
59
  onMotionStart?: (target: DOMKeyframesDefinition) => void;
51
60
  onMotionComplete?: (target: DOMKeyframesDefinition) => void;
52
61
  onHoverStart?: (e: PointerEvent) => void;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "motion-v",
3
- "version": "0.4.1",
3
+ "version": "0.5.0-beta.2",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",
7
- "homepage": "https://github.com/rick-hup/motion-vue",
7
+ "homepage": "https://github.com/unovue/motion-vue",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "https://github.com/rick-hup/motion-vue.git"
10
+ "url": "https://github.com/unovue/motion-vue.git"
11
11
  },
12
12
  "keywords": [
13
13
  "vue",
@@ -62,6 +62,7 @@
62
62
  "@vue/test-utils": "^2.4.5",
63
63
  "framer-motion": "^11.0.0",
64
64
  "jsdom": "^24.0.0",
65
+ "vite": "^5.4.8",
65
66
  "vite-plugin-dts": "^4.2.4",
66
67
  "vitest": "^1.4.0"
67
68
  },