motion-plus-vue 1.3.1 → 1.5.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.
Files changed (49) hide show
  1. package/dist/cjs/index.js +2 -2
  2. package/dist/components/Carousel/Carousel.d.ts +28 -0
  3. package/dist/components/Carousel/CarouselView.d.ts +32 -0
  4. package/dist/components/Carousel/const.d.ts +3 -0
  5. package/dist/components/Carousel/context.d.ts +15 -0
  6. package/dist/components/Carousel/index.d.ts +3 -0
  7. package/dist/components/Carousel/utils/calc-current-page.d.ts +1 -0
  8. package/dist/components/Carousel/utils/calc-page-insets.d.ts +5 -0
  9. package/dist/components/Carousel/utils/find-current-index.d.ts +2 -0
  10. package/dist/components/Carousel/utils/find-next-page.d.ts +3 -0
  11. package/dist/components/Carousel/utils/find-prev-page.d.ts +3 -0
  12. package/dist/components/Cursor/Cursor.d.ts +2 -2
  13. package/dist/components/Ticker/DefaultTickerItem.d.ts +14 -0
  14. package/dist/components/Ticker/Ticker.d.ts +60 -5
  15. package/dist/components/Ticker/TickerItem.d.ts +59 -13
  16. package/dist/components/Ticker/const.d.ts +3 -0
  17. package/dist/components/Ticker/context.d.ts +4259 -2
  18. package/dist/components/Ticker/index.d.ts +1 -1
  19. package/dist/components/Ticker/types.d.ts +16 -1
  20. package/dist/components/Ticker/utils/layout-strategy.d.ts +2 -0
  21. package/dist/components/Typewriter/Typewriter.d.ts +98 -0
  22. package/dist/components/Typewriter/index.d.ts +1 -0
  23. package/dist/components/Typewriter/types.d.ts +6 -0
  24. package/dist/es/components/Carousel/Carousel.vue.mjs +79 -0
  25. package/dist/es/components/Carousel/Carousel.vue2.mjs +4 -0
  26. package/dist/es/components/Carousel/CarouselView.vue.mjs +115 -0
  27. package/dist/es/components/Carousel/CarouselView.vue2.mjs +4 -0
  28. package/dist/es/components/Carousel/const.mjs +13 -0
  29. package/dist/es/components/Carousel/context.mjs +6 -0
  30. package/dist/es/components/Carousel/utils/calc-current-page.mjs +13 -0
  31. package/dist/es/components/Carousel/utils/calc-page-insets.mjs +42 -0
  32. package/dist/es/components/Carousel/utils/find-current-index.mjs +13 -0
  33. package/dist/es/components/Carousel/utils/find-next-page.mjs +26 -0
  34. package/dist/es/components/Carousel/utils/find-prev-page.mjs +31 -0
  35. package/dist/es/components/Ticker/Ticker.vue.mjs +270 -111
  36. package/dist/es/components/Ticker/TickerItem.vue.mjs +68 -36
  37. package/dist/es/components/Ticker/const.mjs +12 -3
  38. package/dist/es/components/Ticker/context.mjs +5 -3
  39. package/dist/es/components/Ticker/utils/layout-strategy.mjs +57 -0
  40. package/dist/es/components/Typewriter/Typewriter.vue.mjs +129 -0
  41. package/dist/es/components/Typewriter/Typewriter.vue2.mjs +4 -0
  42. package/dist/es/components/Typewriter/types.mjs +8 -0
  43. package/dist/es/index.mjs +23 -16
  44. package/dist/es/utils/flatten-slots.mjs +22 -16
  45. package/dist/index.d.ts +2 -0
  46. package/dist/utils/types.d.ts +0 -0
  47. package/package.json +5 -2
  48. package/dist/es/components/Ticker/use-item-offset.mjs +0 -12
  49. package/dist/es/components/Ticker/utils/get-cumulative-offset.mjs +0 -9
@@ -0,0 +1,129 @@
1
+ import { defineComponent as N, mergeDefaults as T, useSlots as _, watchEffect as C, ref as S, computed as w, onMounted as D, createBlock as B, openBlock as E, resolveDynamicComponent as F, unref as p, withCtx as V, createElementVNode as k, normalizeStyle as h, normalizeClass as b, createVNode as I } from "vue";
2
+ import { useMotionValue as M, RowValue as R, delayInMs as z, animate as P } from "motion-v";
3
+ import { getTypewriterDelay as j, getNextText as G } from "motion-plus-dom";
4
+ import { TYPING_SPEEDS as Y } from "./types.mjs";
5
+ const K = /* @__PURE__ */ N({
6
+ __name: "Typewriter",
7
+ props: /* @__PURE__ */ T({
8
+ as: {},
9
+ speed: {},
10
+ variance: {},
11
+ play: { type: Boolean },
12
+ cursorClassName: {},
13
+ cursorStyle: {},
14
+ textClassName: {},
15
+ textStyle: {},
16
+ cursorBlinkDuration: {},
17
+ onComplete: { type: Function },
18
+ replace: {},
19
+ backspace: {},
20
+ backspaceFactor: {}
21
+ }, {
22
+ as: "span",
23
+ speed: "normal",
24
+ variance: "natural",
25
+ cursorClassName: "motion-typewriter-cursor",
26
+ play: !0,
27
+ cursorBlinkDuration: 0.5,
28
+ replace: "type",
29
+ backspace: "character",
30
+ backspaceFactor: 0.2
31
+ }),
32
+ setup(g) {
33
+ const e = g, r = _();
34
+ function s() {
35
+ var l;
36
+ return (((l = r == null ? void 0 : r.default) == null ? void 0 : l.call(r)) ?? []).map((o) => typeof o.children == "string" ? o.children : "").join("");
37
+ }
38
+ let i = s();
39
+ const n = M("");
40
+ C(() => {
41
+ const t = s();
42
+ e.replace === "all" && t !== i && n.set(""), i = t;
43
+ });
44
+ const u = S();
45
+ let c = null;
46
+ const v = w(() => typeof e.speed == "number" ? e.speed : Y[e.speed]);
47
+ function m() {
48
+ u.value && (c = P(
49
+ u.value,
50
+ {
51
+ opacity: [1, 1, 0, 0]
52
+ },
53
+ {
54
+ duration: e.cursorBlinkDuration,
55
+ times: [0, 0.5, 0.5, 1],
56
+ ease: "linear",
57
+ repeat: 1 / 0,
58
+ repeatType: "reverse"
59
+ }
60
+ ));
61
+ }
62
+ let a = null;
63
+ function f() {
64
+ a == null || a(), a = null;
65
+ }
66
+ function y() {
67
+ if (!e.play) {
68
+ m(), f();
69
+ return;
70
+ }
71
+ c == null || c.cancel();
72
+ const t = s(), l = () => {
73
+ var x;
74
+ const d = G(
75
+ n.get(),
76
+ t,
77
+ e.replace,
78
+ e.backspace
79
+ );
80
+ n.set(d), d !== t ? o() : (m(), (x = e.onComplete) == null || x.call(e));
81
+ }, o = () => {
82
+ a = z(
83
+ l,
84
+ j(
85
+ t,
86
+ n.get(),
87
+ v.value,
88
+ e.variance,
89
+ e.backspaceFactor
90
+ )
91
+ );
92
+ };
93
+ a || o();
94
+ }
95
+ return C((t) => {
96
+ y(), t(f);
97
+ }), D(() => {
98
+ y();
99
+ }), (t, l) => (E(), B(F(e.as), { "aria-label": p(i) }, {
100
+ default: V(() => [
101
+ k("span", {
102
+ class: b(e.textClassName),
103
+ style: h(e.textStyle)
104
+ }, [
105
+ I(p(R), { value: p(n) }, null, 8, ["value"])
106
+ ], 6),
107
+ k("span", {
108
+ ref_key: "cursorRef",
109
+ ref: u,
110
+ class: b(e.cursorClassName),
111
+ style: h({
112
+ display: "inline-block",
113
+ width: "2px",
114
+ height: "1em",
115
+ backgroundColor: "currentColor",
116
+ position: "relative",
117
+ top: "0.1em",
118
+ left: "0.2em",
119
+ ...e.cursorStyle
120
+ })
121
+ }, null, 6)
122
+ ]),
123
+ _: 1
124
+ }, 8, ["aria-label"]));
125
+ }
126
+ });
127
+ export {
128
+ K as default
129
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./Typewriter.vue.mjs";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,8 @@
1
+ const o = {
2
+ slow: 130,
3
+ normal: 75,
4
+ fast: 30
5
+ };
6
+ export {
7
+ o as TYPING_SPEEDS
8
+ };
package/dist/es/index.mjs CHANGED
@@ -1,20 +1,27 @@
1
1
  import { AnimateNumber as o } from "./components/AnimateNumber/index.mjs";
2
- import { Ticker as f } from "./components/Ticker/index.mjs";
3
- import { default as s } from "./components/Cursor/Cursor.vue.mjs";
4
- import { default as p } from "./components/Ticker/TickerItem.vue.mjs";
5
- import { useCursorState as i } from "./components/Cursor/hooks/use-cursor-state/index.mjs";
6
- import { useCursorIsInView as n } from "./components/Cursor/hooks/use-cursor-in-view.mjs";
7
- import { usePointerPosition as I } from "./components/Cursor/hooks/use-pointer-position.mjs";
8
- import { useMagneticPull as C } from "./components/Cursor/magnetic/use-magnetic-pull.mjs";
9
- import { useItemOffset as d } from "./components/Ticker/use-item-offset.mjs";
2
+ import { Ticker as s } from "./components/Ticker/index.mjs";
3
+ import { default as f } from "./components/Cursor/Cursor.vue.mjs";
4
+ import { default as a } from "./components/Ticker/TickerItem.vue.mjs";
5
+ import { default as x } from "./components/Typewriter/Typewriter.vue.mjs";
6
+ import { default as l } from "./components/Carousel/Carousel.vue.mjs";
7
+ import { useCursorState as n } from "./components/Cursor/hooks/use-cursor-state/index.mjs";
8
+ import { useCursorIsInView as T } from "./components/Cursor/hooks/use-cursor-in-view.mjs";
9
+ import { usePointerPosition as k } from "./components/Cursor/hooks/use-pointer-position.mjs";
10
+ import { useMagneticPull as P } from "./components/Cursor/magnetic/use-magnetic-pull.mjs";
11
+ import { useTicker as b, useTickerItem as g } from "./components/Ticker/context.mjs";
12
+ import { useCarousel as A } from "./components/Carousel/context.mjs";
10
13
  export {
11
14
  o as AnimateNumber,
12
- s as Cursor,
13
- f as Ticker,
14
- p as TickerItem,
15
- n as useCursorIsInView,
16
- i as useCursorState,
17
- d as useItemOffset,
18
- C as useMagneticPull,
19
- I as usePointerPosition
15
+ l as Carousel,
16
+ f as Cursor,
17
+ s as Ticker,
18
+ a as TickerItem,
19
+ x as Typewriter,
20
+ A as useCarousel,
21
+ T as useCursorIsInView,
22
+ n as useCursorState,
23
+ P as useMagneticPull,
24
+ k as usePointerPosition,
25
+ b as useTicker,
26
+ g as useTickerItem
20
27
  };
@@ -1,22 +1,28 @@
1
- import { Comment as s, Fragment as c } from "vue";
2
- function u(t = []) {
3
- const e = [];
4
- for (const n of t)
5
- n.type !== s && e.push(n);
6
- return e;
1
+ import { Comment as i, Fragment as c } from "vue";
2
+ function s(t = []) {
3
+ var n;
4
+ const r = [];
5
+ for (const e of t)
6
+ if (e.type !== i)
7
+ if (e.type === c) {
8
+ const o = Array.isArray(e.children) ? e.children : (n = e.children) == null ? void 0 : n.default();
9
+ r.push(...s(o));
10
+ } else
11
+ r.push(e);
12
+ return r;
7
13
  }
8
- function f(t) {
14
+ function l(t) {
9
15
  var n;
10
- const e = [];
11
- for (const r of t)
12
- if (r.type === c) {
13
- const o = Array.isArray(r.children) ? r.children : (n = r.children) == null ? void 0 : n.default();
14
- e.push(...f(o));
16
+ const r = [];
17
+ for (const e of t)
18
+ if (e.type === c) {
19
+ const o = Array.isArray(e.children) ? e.children : (n = e.children) == null ? void 0 : n.default();
20
+ r.push(...l(o));
15
21
  } else
16
- e.push(r);
17
- return e;
22
+ r.push(e);
23
+ return r;
18
24
  }
19
25
  export {
20
- u as flattenSlots,
21
- f as renderVNode
26
+ s as flattenSlots,
27
+ l as renderVNode
22
28
  };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export * from './components/AnimateNumber';
2
2
  export * from './components/Cursor';
3
3
  export * from './components/Ticker';
4
+ export * from './components/Typewriter';
5
+ export * from './components/Carousel';
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion-plus-vue",
3
- "version": "1.3.1",
3
+ "version": "1.5.0-beta.1",
4
4
  "description": "Motion Plus Vue",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -25,9 +25,12 @@
25
25
  ],
26
26
  "typings": "./dist/index.d.ts",
27
27
  "peerDependencies": {
28
- "motion-v": "^1.5.0",
28
+ "motion-v": "^1.7.4",
29
29
  "vue": ">=3.0.0"
30
30
  },
31
+ "dependencies": {
32
+ "motion-plus-dom": "^2.0.2"
33
+ },
31
34
  "size-limit": [
32
35
  {
33
36
  "path": "dist/es/components/AnimateNumber/index.mjs",
@@ -1,12 +0,0 @@
1
- import { invariant as t } from "motion-v";
2
- import { useTickerItemContext as o } from "./context.mjs";
3
- function n() {
4
- const e = o(null);
5
- return t(
6
- !!e,
7
- "useItemOffset must be used within a TickerItem"
8
- ), e == null ? void 0 : e.offset;
9
- }
10
- export {
11
- n as useItemOffset
12
- };
@@ -1,9 +0,0 @@
1
- function l(f, o) {
2
- let t = 0, e = f;
3
- for (; e; )
4
- t += o === "x" ? e.offsetLeft : e.offsetTop, e = e.offsetParent;
5
- return t;
6
- }
7
- export {
8
- l as getCumulativeOffset
9
- };