motion-v 0.12.0 → 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.
package/dist/cjs/index.js CHANGED
@@ -9598,33 +9598,6 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
9598
9598
  };
9599
9599
  }
9600
9600
  });
9601
- const components = {
9602
- motion: [
9603
- "Motion",
9604
- "AnimatePresence",
9605
- "LayoutGroup",
9606
- "MotionConfig",
9607
- "ReorderGroup",
9608
- "ReorderItem"
9609
- ]
9610
- };
9611
- const utilities = {
9612
- utilities: [
9613
- "useTransform",
9614
- "useTime",
9615
- "useMotionTemplate",
9616
- "useSpring",
9617
- "useScroll",
9618
- "useMotionValue",
9619
- "useVelocity",
9620
- "useAnimate",
9621
- "useInView",
9622
- "useAnimationFrame",
9623
- "useMotionValueEvent",
9624
- "useLayoutGroup",
9625
- "useDragControls"
9626
- ]
9627
- };
9628
9601
  function useAnimate() {
9629
9602
  const dom = vue.ref(null);
9630
9603
  const domProxy = new Proxy(dom, {
@@ -9745,6 +9718,10 @@ function useAnimationControls() {
9745
9718
  });
9746
9719
  return controls;
9747
9720
  }
9721
+ function useReducedMotion(options = {}) {
9722
+ const reducedMotion = core.useMediaQuery("(prefers-reduced-motion: reduce)", options);
9723
+ return vue.computed(() => reducedMotion.value);
9724
+ }
9748
9725
  class DragControls {
9749
9726
  constructor() {
9750
9727
  this.componentControls = /* @__PURE__ */ new Set();
@@ -9806,7 +9783,6 @@ exports.circIn = circIn;
9806
9783
  exports.circInOut = circInOut;
9807
9784
  exports.circOut = circOut;
9808
9785
  exports.clamp = clamp$1;
9809
- exports.components = components;
9810
9786
  exports.createContext = createContext;
9811
9787
  exports.createScopedAnimate = createScopedAnimate;
9812
9788
  exports.cubicBezier = cubicBezier;
@@ -9865,10 +9841,10 @@ exports.useMotionConfig = useMotionConfig;
9865
9841
  exports.useMotionTemplate = useMotionTemplate;
9866
9842
  exports.useMotionValue = motionValue;
9867
9843
  exports.useMotionValueEvent = useMotionValueEvent;
9844
+ exports.useReducedMotion = useReducedMotion;
9868
9845
  exports.useScroll = useScroll;
9869
9846
  exports.useSpring = useSpring;
9870
9847
  exports.useTime = useTime;
9871
9848
  exports.useTransform = useTransform;
9872
9849
  exports.useVelocity = useVelocity;
9873
- exports.utilities = utilities;
9874
9850
  exports.wrap = wrap;
@@ -0,0 +1,7 @@
1
+ import { Ref } from 'vue';
2
+ /**
3
+ * Reactive prefers-reduced-motion.
4
+ */
5
+ export declare function useReducedMotion(options?: {
6
+ window?: Window;
7
+ }): Ref<boolean>;
@@ -0,0 +1,9 @@
1
+ import { computed } from "vue";
2
+ import { useMediaQuery } from "@vueuse/core";
3
+ function useReducedMotion(options = {}) {
4
+ const reducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)", options);
5
+ return computed(() => reducedMotion.value);
6
+ }
7
+ export {
8
+ useReducedMotion
9
+ };
@@ -1,2 +1,3 @@
1
1
  export * from './hooks/use-animate';
2
2
  export * from './hooks/use-animation-controls';
3
+ export * from './hooks/use-reduced-motion';
@@ -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
  };
@@ -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",
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
- };