motion-plus-vue 0.0.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 (66) hide show
  1. package/dist/cjs/index.js +9 -0
  2. package/dist/components/AnimateNumber/AnimateNumber.d.ts +15 -0
  3. package/dist/components/AnimateNumber/Mask.d.ts +22 -0
  4. package/dist/components/AnimateNumber/NumberDigit.d.ts +5 -0
  5. package/dist/components/AnimateNumber/NumberSection.d.ts +15 -0
  6. package/dist/components/AnimateNumber/NumberSymbol.d.ts +3 -0
  7. package/dist/components/AnimateNumber/config.d.ts +6 -0
  8. package/dist/components/AnimateNumber/context.d.ts +15 -0
  9. package/dist/components/AnimateNumber/hooks/use-is-initial-render.d.ts +3 -0
  10. package/dist/components/AnimateNumber/index.d.ts +5 -0
  11. package/dist/components/AnimateNumber/types.d.ts +55 -0
  12. package/dist/components/AnimateNumber/use-animate.d.ts +6 -0
  13. package/dist/components/AnimateNumber/utils/format-parts.d.ts +5 -0
  14. package/dist/components/AnimateNumber/utils/get-width-in-ems.d.ts +2 -0
  15. package/dist/components/AnimateNumber/utils/target-widths.d.ts +1 -0
  16. package/dist/components/Cursor/Cursor.d.ts +69 -0
  17. package/dist/components/Cursor/config.d.ts +23 -0
  18. package/dist/components/Cursor/get-cursor-size.d.ts +10 -0
  19. package/dist/components/Cursor/hooks/use-cursor-in-view.d.ts +1 -0
  20. package/dist/components/Cursor/hooks/use-cursor-state/find-target.d.ts +3 -0
  21. package/dist/components/Cursor/hooks/use-cursor-state/index.d.ts +3 -0
  22. package/dist/components/Cursor/hooks/use-cursor-state/types.d.ts +14 -0
  23. package/dist/components/Cursor/hooks/use-has-pointer-moved.d.ts +5 -0
  24. package/dist/components/Cursor/hooks/use-mixed.d.ts +2 -0
  25. package/dist/components/Cursor/hooks/use-offset.d.ts +10 -0
  26. package/dist/components/Cursor/hooks/use-pointer-position.d.ts +5 -0
  27. package/dist/components/Cursor/hooks/use-snap-to-target.d.ts +7 -0
  28. package/dist/components/Cursor/hooks/utils/only-mouse-events.d.ts +2 -0
  29. package/dist/components/Cursor/index.d.ts +5 -0
  30. package/dist/components/Cursor/use-cursor-styles.d.ts +1 -0
  31. package/dist/es/components/AnimateNumber/AnimateNumber.vue.mjs +111 -0
  32. package/dist/es/components/AnimateNumber/AnimateNumber.vue2.mjs +4 -0
  33. package/dist/es/components/AnimateNumber/Mask.vue.mjs +33 -0
  34. package/dist/es/components/AnimateNumber/Mask.vue2.mjs +4 -0
  35. package/dist/es/components/AnimateNumber/NumberDigit.vue.mjs +124 -0
  36. package/dist/es/components/AnimateNumber/NumberDigit.vue2.mjs +4 -0
  37. package/dist/es/components/AnimateNumber/NumberSection.vue.mjs +133 -0
  38. package/dist/es/components/AnimateNumber/NumberSection.vue2.mjs +4 -0
  39. package/dist/es/components/AnimateNumber/NumberSymbol.vue.mjs +73 -0
  40. package/dist/es/components/AnimateNumber/NumberSymbol.vue2.mjs +4 -0
  41. package/dist/es/components/AnimateNumber/config.mjs +21 -0
  42. package/dist/es/components/AnimateNumber/context.mjs +6 -0
  43. package/dist/es/components/AnimateNumber/hooks/use-is-initial-render.mjs +12 -0
  44. package/dist/es/components/AnimateNumber/index.mjs +5 -0
  45. package/dist/es/components/AnimateNumber/use-animate.mjs +24 -0
  46. package/dist/es/components/AnimateNumber/utils/format-parts.mjs +61 -0
  47. package/dist/es/components/AnimateNumber/utils/get-width-in-ems.mjs +7 -0
  48. package/dist/es/components/AnimateNumber/utils/target-widths.mjs +4 -0
  49. package/dist/es/components/Cursor/Cursor.vue.mjs +135 -0
  50. package/dist/es/components/Cursor/Cursor.vue2.mjs +4 -0
  51. package/dist/es/components/Cursor/config.mjs +8 -0
  52. package/dist/es/components/Cursor/get-cursor-size.mjs +16 -0
  53. package/dist/es/components/Cursor/hooks/use-cursor-in-view.mjs +41 -0
  54. package/dist/es/components/Cursor/hooks/use-cursor-state/find-target.mjs +18 -0
  55. package/dist/es/components/Cursor/hooks/use-cursor-state/index.mjs +67 -0
  56. package/dist/es/components/Cursor/hooks/use-has-pointer-moved.mjs +22 -0
  57. package/dist/es/components/Cursor/hooks/use-mixed.mjs +7 -0
  58. package/dist/es/components/Cursor/hooks/use-offset.mjs +10 -0
  59. package/dist/es/components/Cursor/hooks/use-pointer-position.mjs +22 -0
  60. package/dist/es/components/Cursor/hooks/use-snap-to-target.mjs +20 -0
  61. package/dist/es/components/Cursor/hooks/utils/only-mouse-events.mjs +14 -0
  62. package/dist/es/components/Cursor/index.mjs +5 -0
  63. package/dist/es/components/Cursor/use-cursor-styles.mjs +27 -0
  64. package/dist/es/index.mjs +6 -0
  65. package/dist/index.d.ts +2 -0
  66. package/package.json +62 -0
@@ -0,0 +1,41 @@
1
+ import { noop as u } from "motion-v";
2
+ import { ref as d, watch as f } from "vue";
3
+ let i = null;
4
+ function m() {
5
+ const e = /* @__PURE__ */ new Set();
6
+ function n() {
7
+ e.forEach((t) => t.show());
8
+ }
9
+ function r() {
10
+ e.forEach((t) => t.hide());
11
+ }
12
+ function s() {
13
+ document.body.addEventListener("mouseenter", n), document.body.addEventListener("mouseleave", r);
14
+ }
15
+ function o() {
16
+ document.body.removeEventListener("mouseenter", n), document.body.removeEventListener("mouseleave", r);
17
+ }
18
+ return {
19
+ on: (t) => typeof window > "u" ? u : (e.size || s(), e.add(t), () => {
20
+ e.delete(t), e.size === 0 && o();
21
+ })
22
+ };
23
+ }
24
+ function c() {
25
+ return i || (i = m()), i;
26
+ }
27
+ function l(e) {
28
+ const n = d(!0);
29
+ return f(n, (r, s, o) => {
30
+ const t = c().on({
31
+ show: () => {
32
+ n.value || (e(), n.value = !0);
33
+ },
34
+ hide: () => n.value = !1
35
+ });
36
+ o(t);
37
+ }, { immediate: !0 }), n;
38
+ }
39
+ export {
40
+ l as useCursorIsInView
41
+ };
@@ -0,0 +1,18 @@
1
+ function e(t) {
2
+ return t.closest("[data-cursor]");
3
+ }
4
+ function r(t) {
5
+ return t.closest('a, button, input[type="button"]:not(:disabled)');
6
+ }
7
+ function u(t) {
8
+ return window.getComputedStyle(t).userSelect === "none" ? null : t.closest(
9
+ "p, textarea:not(:disabled), input[type='text']:not(:disabled), h1, h2, h3, h4, h5, h6"
10
+ );
11
+ }
12
+ function o(t) {
13
+ let n = e(t);
14
+ return n ? [n.dataset.cursor, n] : (n = r(t), n ? ["pointer", n] : (n = u(t), n ? ["text", n] : ["default", null]));
15
+ }
16
+ export {
17
+ o as findTarget
18
+ };
@@ -0,0 +1,67 @@
1
+ import { onlyMouse as g, onlyLeftClicks as m } from "../utils/only-mouse-events.mjs";
2
+ import { findTarget as z } from "./find-target.mjs";
3
+ import { ref as L, watch as h } from "vue";
4
+ let a = null, e = {
5
+ type: "default",
6
+ isPressed: !1,
7
+ fontSize: null,
8
+ targetBoundingBox: null
9
+ };
10
+ function P() {
11
+ if (typeof window > "u")
12
+ return {
13
+ onChange: () => () => {
14
+ }
15
+ };
16
+ const t = /* @__PURE__ */ new Set();
17
+ function s(n) {
18
+ e = { ...e, ...n }, t.forEach((o) => o(e));
19
+ }
20
+ const f = m(() => {
21
+ e.isPressed || s({ isPressed: !0 });
22
+ }), d = m(() => {
23
+ e.isPressed && s({ isPressed: !1 });
24
+ }), u = g(({ target: n }) => {
25
+ if (!n)
26
+ return;
27
+ const [o, p] = z(n);
28
+ let i = !1;
29
+ const r = {};
30
+ o !== e.type && (r.type = o, i = !0);
31
+ const w = o === "pointer" && p ? p.getBoundingClientRect() : null;
32
+ if (w !== e.targetBoundingBox && (r.targetBoundingBox = w, i = !0), o === "text") {
33
+ const { fontSize: c } = window.getComputedStyle(
34
+ n
35
+ ), v = c ? parseInt(c) : null;
36
+ v !== e.fontSize && (r.fontSize = v, i = !0);
37
+ } else
38
+ e.fontSize && (r.fontSize = null, i = !0);
39
+ i && s(r);
40
+ });
41
+ function l() {
42
+ typeof window > "u" || (window.addEventListener("pointerover", u), window.addEventListener("pointerdown", f), window.addEventListener("pointerup", d));
43
+ }
44
+ function S() {
45
+ window.removeEventListener("pointerover", u), window.removeEventListener("pointerdown", f), window.removeEventListener("pointerup", d);
46
+ }
47
+ return {
48
+ onChange: (n) => (t.size || l(), t.add(n), () => {
49
+ t.delete(n), t.size || S();
50
+ })
51
+ };
52
+ }
53
+ function y() {
54
+ return a || (a = P()), a;
55
+ }
56
+ function x() {
57
+ const t = L({ ...e });
58
+ return h(t, (s, f, d) => {
59
+ const u = y().onChange((l) => {
60
+ t.value = l;
61
+ });
62
+ d(u);
63
+ }, { immediate: !0, flush: "post" }), t;
64
+ }
65
+ export {
66
+ x as useCursorState
67
+ };
@@ -0,0 +1,22 @@
1
+ import { ref as a, watch as p } from "vue";
2
+ import { pipe as s } from "motion-v";
3
+ function c({
4
+ x: o,
5
+ y: r
6
+ }, i) {
7
+ const e = a(o.prev !== void 0 || r.prev !== void 0);
8
+ return p(e, () => {
9
+ if (e.value)
10
+ return;
11
+ const t = () => {
12
+ e.value = !0, i(), n();
13
+ }, n = s(
14
+ o.on("change", t),
15
+ r.on("change", t)
16
+ );
17
+ return () => n();
18
+ }, { immediate: !0 }), e;
19
+ }
20
+ export {
21
+ c as useHasPointerMoved
22
+ };
@@ -0,0 +1,7 @@
1
+ import { useTransform as o, mix as i } from "motion-v";
2
+ function n(e, r, t) {
3
+ return o(() => i(e.get(), r.get(), t.get()));
4
+ }
5
+ export {
6
+ n as useMixed
7
+ };
@@ -0,0 +1,10 @@
1
+ import { useTransform as u } from "motion-v";
2
+ function x(e, r) {
3
+ return {
4
+ x: u(() => e.x.get() + r.value.x),
5
+ y: u(() => e.y.get() + r.value.y)
6
+ };
7
+ }
8
+ export {
9
+ x as useOffset
10
+ };
@@ -0,0 +1,22 @@
1
+ import { onlyMouse as u } from "./utils/only-mouse-events.mjs";
2
+ import { motionValue as r, frame as p } from "motion-v";
3
+ let t, e;
4
+ function d() {
5
+ t = r(0), e = r(0);
6
+ let i = 0, n = 0;
7
+ function f() {
8
+ t.set(i), e.set(n);
9
+ }
10
+ typeof window < "u" && window.addEventListener(
11
+ "pointermove",
12
+ u((o) => {
13
+ i = o.clientX, n = o.clientY, p.update(f);
14
+ })
15
+ );
16
+ }
17
+ function a() {
18
+ return t || d(), { x: t, y: e };
19
+ }
20
+ export {
21
+ a as usePointerPosition
22
+ };
@@ -0,0 +1,20 @@
1
+ import { useMixed as i } from "./use-mixed.mjs";
2
+ import { useMotionValue as e, animate as d } from "motion-v";
3
+ import { watch as m } from "vue";
4
+ function v(n, r, t) {
5
+ const o = e(0), u = e(0), a = e(0), g = i(n.x, u, o), B = i(n.y, a, o);
6
+ return m([r, () => t.value.targetBoundingBox], () => {
7
+ if (!r.value)
8
+ return;
9
+ t.value.targetBoundingBox && (u.set(
10
+ t.value.targetBoundingBox.left + t.value.targetBoundingBox.width / 2
11
+ ), a.set(
12
+ t.value.targetBoundingBox.top + t.value.targetBoundingBox.height / 2
13
+ ));
14
+ const x = d(o, t.value.targetBoundingBox ? 0.9 : 0);
15
+ return () => x.stop();
16
+ }, { immediate: !0 }), { x: g, y: B };
17
+ }
18
+ export {
19
+ v as useSnapToTarget
20
+ };
@@ -0,0 +1,14 @@
1
+ function t(n) {
2
+ return (o) => {
3
+ o.pointerType === "mouse" && n(o);
4
+ };
5
+ }
6
+ function u(n) {
7
+ return t((o) => {
8
+ o.button === 0 && n(o);
9
+ });
10
+ }
11
+ export {
12
+ u as onlyLeftClicks,
13
+ t as onlyMouse
14
+ };
@@ -0,0 +1,5 @@
1
+ import o from "./Cursor.vue.mjs";
2
+ const m = o;
3
+ export {
4
+ m as Cursor
5
+ };
@@ -0,0 +1,27 @@
1
+ import { noop as r } from "motion-v";
2
+ import { watch as c } from "vue";
3
+ function m() {
4
+ const o = document.createElement("style");
5
+ return o.textContent = `
6
+ * {
7
+ cursor: none !important;
8
+ }
9
+
10
+ [data-motion-cursor="pointer"] {
11
+ background-color: #333;
12
+ }
13
+ `, document.head.appendChild(o), () => {
14
+ document.head.removeChild(o);
15
+ };
16
+ }
17
+ function s(o) {
18
+ c(o, (t, u, e) => {
19
+ const n = t ? m() : r;
20
+ e(() => {
21
+ n(0);
22
+ });
23
+ });
24
+ }
25
+ export {
26
+ s as useCursorStyles
27
+ };
@@ -0,0 +1,6 @@
1
+ import { AnimateNumber as e } from "./components/AnimateNumber/index.mjs";
2
+ import { Cursor as t } from "./components/Cursor/index.mjs";
3
+ export {
4
+ e as AnimateNumber,
5
+ t as Cursor
6
+ };
@@ -0,0 +1,2 @@
1
+ export * from './components/AnimateNumber/index';
2
+ export * from './components/Cursor/index';
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "motion-plus-vue",
3
+ "version": "0.0.1",
4
+ "description": "Motion Plus Vue",
5
+ "author": "",
6
+ "license": "ISC",
7
+ "keywords": [
8
+ "ui",
9
+ "vue"
10
+ ],
11
+ "sideEffects": false,
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/es/index.mjs",
16
+ "require": "./dist/cjs/index.js"
17
+ }
18
+ },
19
+ "main": "./dist/cjs/index.js",
20
+ "module": "./dist/es/index.mjs",
21
+ "types": "./dist/index.d.ts",
22
+ "files": [
23
+ "./LICENSE",
24
+ "./dist"
25
+ ],
26
+ "typings": "./dist/index.d.ts",
27
+ "peerDependencies": {
28
+ "motion-v": ">=0.11.0-beta.5",
29
+ "vue": ">=3.0.0"
30
+ },
31
+ "devDependencies": {
32
+ "motion-v": "0.11.0-beta.5",
33
+ "vue": "^3.5.13"
34
+ },
35
+ "size-limit": [
36
+ {
37
+ "path": "dist/es/components/AnimateNumber/index.mjs",
38
+ "limit": "3.5 kb",
39
+ "ignore": [
40
+ "vue",
41
+ "motion-v"
42
+ ]
43
+ },
44
+ {
45
+ "path": "dist/es/components/Cursor/index.mjs",
46
+ "limit": "2.5 kb",
47
+ "ignore": [
48
+ "vue",
49
+ "motion-v"
50
+ ]
51
+ }
52
+ ],
53
+ "scripts": {
54
+ "clean": "rm -rf dist",
55
+ "build": "npm run clean && vite build",
56
+ "dev": "vite build --watch",
57
+ "test": "vitest",
58
+ "bumpp": "bumpp package.json",
59
+ "pub:release": "pnpm publish --access public",
60
+ "size": "size-limit"
61
+ }
62
+ }