motion-v 0.12.0-beta.2 → 0.13.0-beta.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.
@@ -6,4 +6,6 @@ export declare class PressGesture extends Feature {
6
6
  isActive(): boolean;
7
7
  constructor(state: MotionState);
8
8
  mount(): void;
9
+ update(): void;
10
+ register(): void;
9
11
  }
@@ -23,27 +23,39 @@ function handlePressEvent(state, event, lifecycle) {
23
23
  }
24
24
  class PressGesture extends Feature {
25
25
  isActive() {
26
- return Boolean(this.state.options.press);
26
+ return Boolean(this.state.options.whilePress);
27
27
  }
28
28
  constructor(state) {
29
29
  super(state);
30
30
  }
31
31
  mount() {
32
- const element = this.state.element;
33
- if (!element)
34
- return;
35
- this.unmount = press(
36
- element,
37
- (el, startEvent) => {
38
- handlePressEvent(this.state, startEvent, "Start");
39
- return (endEvent, { success }) => handlePressEvent(
40
- this.state,
41
- endEvent,
42
- success ? "End" : "Cancel"
43
- );
44
- },
45
- { useGlobalTarget: this.state.options.globalPressTarget }
46
- );
32
+ this.register();
33
+ }
34
+ update() {
35
+ const preProps = this.state.visualElement.prevProps;
36
+ if (preProps.whilePress !== this.state.options.whilePress) {
37
+ this.register();
38
+ }
39
+ }
40
+ register() {
41
+ this.unmount();
42
+ if (this.isActive()) {
43
+ const element = this.state.element;
44
+ if (!element)
45
+ return;
46
+ this.unmount = press(
47
+ element,
48
+ (el, startEvent) => {
49
+ handlePressEvent(this.state, startEvent, "Start");
50
+ return (endEvent, { success }) => handlePressEvent(
51
+ this.state,
52
+ endEvent,
53
+ success ? "End" : "Cancel"
54
+ );
55
+ },
56
+ { useGlobalTarget: this.state.options.globalPressTarget }
57
+ );
58
+ }
47
59
  }
48
60
  }
49
61
  export {
@@ -7,7 +7,6 @@ export { useLayoutGroup } from './components/use-layout-group';
7
7
  export type { LayoutGroupProps } from './components/use-layout-group';
8
8
  export * from './components/context';
9
9
  export * from './value';
10
- export * from './constants';
11
10
  export * from './types';
12
11
  export * from './animation';
13
12
  export * from './utils';
package/dist/es/index.mjs CHANGED
@@ -2,7 +2,6 @@ import { addScaleCorrector } from "./external/.pnpm/framer-motion@12.4.10/extern
2
2
  import { default as default2 } from "./components/LayoutGroup.vue.mjs";
3
3
  import { useLayoutGroup } from "./components/use-layout-group.mjs";
4
4
  import { injectLayoutGroup, injectMotion, provideLayoutGroup, provideMotion } from "./components/context.mjs";
5
- import { components, utilities } from "./constants/index.mjs";
6
5
  import { useDragControls } from "./features/gestures/drag/use-drag-controls.mjs";
7
6
  import { default as default3 } from "./components/motion/Motion.vue.mjs";
8
7
  import { default as default4 } from "./components/RowValue.vue.mjs";
@@ -58,6 +57,7 @@ import { useScroll } from "./value/use-scroll.mjs";
58
57
  import { useVelocity } from "./value/use-velocity.mjs";
59
58
  import { useAnimate } from "./animation/hooks/use-animate.mjs";
60
59
  import { useAnimationControls } from "./animation/hooks/use-animation-controls.mjs";
60
+ import { useReducedMotion } from "./animation/hooks/use-reduced-motion.mjs";
61
61
  import { createContext } from "./utils/createContext.mjs";
62
62
  import { isMotionValue } from "./utils/motion-value.mjs";
63
63
  import { useInView } from "./utils/use-in-view.mjs";
@@ -88,7 +88,6 @@ export {
88
88
  circInOut,
89
89
  circOut,
90
90
  clamp,
91
- components,
92
91
  createContext,
93
92
  createScopedAnimate,
94
93
  cubicBezier,
@@ -148,11 +147,11 @@ export {
148
147
  useMotionTemplate,
149
148
  motionValue2 as useMotionValue,
150
149
  useMotionValueEvent,
150
+ useReducedMotion,
151
151
  useScroll,
152
152
  useSpring,
153
153
  useTime,
154
154
  useTransform,
155
155
  useVelocity,
156
- utilities,
157
156
  wrap
158
157
  };
@@ -196,7 +196,7 @@ class MotionState {
196
196
  if (isAnimate) {
197
197
  this.animateUpdates({
198
198
  isFallback: !isActive && name !== "exit" && this.visualElement.isControllingVariants,
199
- isExit: this.activeStates.exit
199
+ isExit: name === "exit" && this.activeStates.exit
200
200
  });
201
201
  }
202
202
  }
@@ -1,8 +1,31 @@
1
1
  'use strict';
2
2
 
3
3
  const kit = require('@nuxt/kit');
4
- const motionV = require('motion-v');
5
4
 
5
+ const components = [
6
+ "Motion",
7
+ "AnimatePresence",
8
+ "LayoutGroup",
9
+ "MotionConfig",
10
+ "ReorderGroup",
11
+ "ReorderItem"
12
+ ];
13
+ const utilities = [
14
+ "useTransform",
15
+ "useTime",
16
+ "useMotionTemplate",
17
+ "useSpring",
18
+ "useScroll",
19
+ "useMotionValue",
20
+ "useVelocity",
21
+ "useAnimate",
22
+ "useInView",
23
+ "useAnimationFrame",
24
+ "useMotionValueEvent",
25
+ "useLayoutGroup",
26
+ "useDragControls",
27
+ "useReducedMotion"
28
+ ];
6
29
  const index = kit.defineNuxtModule({
7
30
  meta: {
8
31
  name: "motion-v",
@@ -13,36 +36,25 @@ const index = kit.defineNuxtModule({
13
36
  },
14
37
  defaults: {
15
38
  prefix: "",
16
- components: true
39
+ components: true,
40
+ utilities: true
17
41
  },
18
42
  setup(options, _nuxtApp) {
19
- function getComponents() {
20
- if (typeof options.components === "object") {
21
- return Object.entries(motionV.components).filter(([name]) => options.components[name]).flatMap(([_, components]) => components);
22
- }
23
- if (options.components)
24
- return Object.values(motionV.components).flat();
25
- return [];
26
- }
27
- for (const component of getComponents()) {
28
- kit.addComponent({
29
- name: `${options.prefix}${component}`,
30
- export: component,
31
- filePath: "motion-v"
43
+ if (options.components) {
44
+ components.forEach((component) => {
45
+ kit.addComponent({
46
+ name: `${options.prefix}${component}`,
47
+ export: component,
48
+ filePath: "motion-v"
49
+ });
32
50
  });
33
51
  }
34
- function getUtilities() {
35
- if (typeof options.components === "object") {
36
- return Object.entries(motionV.utilities).filter(([name]) => options.components[name]).flatMap(([_, utilities]) => utilities);
37
- }
38
- if (options.components)
39
- return Object.values(motionV.utilities).flat();
40
- return [];
41
- }
42
- for (const utility of getUtilities()) {
43
- kit.addImports({
44
- from: "motion-v",
45
- name: utility
52
+ if (options.utilities) {
53
+ utilities.forEach((utility) => {
54
+ kit.addImports({
55
+ from: "motion-v",
56
+ name: utility
57
+ });
46
58
  });
47
59
  }
48
60
  }
@@ -1,10 +1,14 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { components } from 'motion-v';
3
2
 
3
+ declare const components: string[];
4
+ declare const utilities: string[];
5
+ type Components = keyof typeof components;
6
+ type Utilities = keyof typeof utilities;
4
7
  interface ModuleOptions {
5
- components: Partial<Record<keyof typeof components, boolean>> | boolean;
8
+ components: boolean;
9
+ utilities: boolean;
6
10
  prefix: string;
7
11
  }
8
12
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
9
13
 
10
- export { type ModuleOptions, _default as default };
14
+ export { type Components, type ModuleOptions, type Utilities, _default as default };
@@ -1,10 +1,14 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { components } from 'motion-v';
3
2
 
3
+ declare const components: string[];
4
+ declare const utilities: string[];
5
+ type Components = keyof typeof components;
6
+ type Utilities = keyof typeof utilities;
4
7
  interface ModuleOptions {
5
- components: Partial<Record<keyof typeof components, boolean>> | boolean;
8
+ components: boolean;
9
+ utilities: boolean;
6
10
  prefix: string;
7
11
  }
8
12
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
9
13
 
10
- export { type ModuleOptions, _default as default };
14
+ export { type Components, type ModuleOptions, type Utilities, _default as default };
@@ -1,6 +1,29 @@
1
1
  import { defineNuxtModule, addComponent, addImports } from '@nuxt/kit';
2
- import { components, utilities } from 'motion-v';
3
2
 
3
+ const components = [
4
+ "Motion",
5
+ "AnimatePresence",
6
+ "LayoutGroup",
7
+ "MotionConfig",
8
+ "ReorderGroup",
9
+ "ReorderItem"
10
+ ];
11
+ const utilities = [
12
+ "useTransform",
13
+ "useTime",
14
+ "useMotionTemplate",
15
+ "useSpring",
16
+ "useScroll",
17
+ "useMotionValue",
18
+ "useVelocity",
19
+ "useAnimate",
20
+ "useInView",
21
+ "useAnimationFrame",
22
+ "useMotionValueEvent",
23
+ "useLayoutGroup",
24
+ "useDragControls",
25
+ "useReducedMotion"
26
+ ];
4
27
  const index = defineNuxtModule({
5
28
  meta: {
6
29
  name: "motion-v",
@@ -11,36 +34,25 @@ const index = defineNuxtModule({
11
34
  },
12
35
  defaults: {
13
36
  prefix: "",
14
- components: true
37
+ components: true,
38
+ utilities: true
15
39
  },
16
40
  setup(options, _nuxtApp) {
17
- function getComponents() {
18
- if (typeof options.components === "object") {
19
- return Object.entries(components).filter(([name]) => options.components[name]).flatMap(([_, components]) => components);
20
- }
21
- if (options.components)
22
- return Object.values(components).flat();
23
- return [];
24
- }
25
- for (const component of getComponents()) {
26
- addComponent({
27
- name: `${options.prefix}${component}`,
28
- export: component,
29
- filePath: "motion-v"
41
+ if (options.components) {
42
+ components.forEach((component) => {
43
+ addComponent({
44
+ name: `${options.prefix}${component}`,
45
+ export: component,
46
+ filePath: "motion-v"
47
+ });
30
48
  });
31
49
  }
32
- function getUtilities() {
33
- if (typeof options.components === "object") {
34
- return Object.entries(utilities).filter(([name]) => options.components[name]).flatMap(([_, utilities]) => utilities);
35
- }
36
- if (options.components)
37
- return Object.values(utilities).flat();
38
- return [];
39
- }
40
- for (const utility of getUtilities()) {
41
- addImports({
42
- from: "motion-v",
43
- name: utility
50
+ if (options.utilities) {
51
+ utilities.forEach((utility) => {
52
+ addImports({
53
+ from: "motion-v",
54
+ name: utility
55
+ });
44
56
  });
45
57
  }
46
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion-v",
3
- "version": "0.12.0-beta.2",
3
+ "version": "0.13.0-beta.1",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",
@@ -1,9 +0,0 @@
1
- declare const components: {
2
- motion: string[];
3
- };
4
- export { components };
5
- export type Components = keyof typeof components;
6
- export declare const utilities: {
7
- utilities: string[];
8
- };
9
- export type Utilities = keyof typeof utilities;
@@ -1,31 +0,0 @@
1
- const components = {
2
- motion: [
3
- "Motion",
4
- "AnimatePresence",
5
- "LayoutGroup",
6
- "MotionConfig",
7
- "ReorderGroup",
8
- "ReorderItem"
9
- ]
10
- };
11
- const utilities = {
12
- utilities: [
13
- "useTransform",
14
- "useTime",
15
- "useMotionTemplate",
16
- "useSpring",
17
- "useScroll",
18
- "useMotionValue",
19
- "useVelocity",
20
- "useAnimate",
21
- "useInView",
22
- "useAnimationFrame",
23
- "useMotionValueEvent",
24
- "useLayoutGroup",
25
- "useDragControls"
26
- ]
27
- };
28
- export {
29
- components,
30
- utilities
31
- };