@xiping/react-components 1.0.40 → 1.0.43
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/components/flip-text/FlipText.js +1 -1
- package/dist/cjs/components/gradient-text/index.d.ts +10 -0
- package/dist/cjs/components/gradient-text/index.js +1 -0
- package/dist/cjs/components/hyper-text/index.js +1 -1
- package/dist/cjs/components/image-viewer/ImageViewer.js +1 -1
- package/dist/cjs/components/split-text/SplitText.js +1 -1
- package/dist/cjs/components/typing-animation/index.js +1 -1
- package/dist/cjs/components/variable-proximity/index.d.ts +15 -0
- package/dist/cjs/components/variable-proximity/index.js +1 -0
- package/dist/cjs/components/video-dialog/VideoDialog.js +1 -1
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/react-components.css +1 -1
- package/dist/es/components/flip-text/FlipText.js +15 -14
- package/dist/es/components/gradient-text/index.d.ts +10 -0
- package/dist/es/components/gradient-text/index.js +22 -0
- package/dist/es/components/hyper-text/index.js +27 -25
- package/dist/es/components/image-viewer/ImageViewer.js +89 -65
- package/dist/es/components/split-text/SplitText.js +37 -35
- package/dist/es/components/typing-animation/index.js +11 -13
- package/dist/es/components/variable-proximity/index.d.ts +15 -0
- package/dist/es/components/variable-proximity/index.js +140 -0
- package/dist/es/components/video-dialog/VideoDialog.js +35 -48
- package/dist/es/index.d.ts +2 -0
- package/dist/es/index.js +58 -54
- package/dist/es/react-components.css +1 -1
- package/package.json +10 -10
|
@@ -1,69 +1,71 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { cn as
|
|
2
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
3
|
+
import { cn as h } from "../../utils/utils.js";
|
|
4
4
|
import { motion as x, AnimatePresence as U } from "motion/react";
|
|
5
|
-
import { useState as M, useRef as
|
|
5
|
+
import { useState as M, useRef as d, useEffect as I } from "react";
|
|
6
|
+
/* empty css */
|
|
6
7
|
const j = Object.freeze(
|
|
7
8
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("")
|
|
8
9
|
), q = (n) => Math.floor(Math.random() * n);
|
|
9
|
-
function
|
|
10
|
+
function B({
|
|
10
11
|
children: n,
|
|
11
12
|
className: C,
|
|
12
|
-
duration:
|
|
13
|
-
delay:
|
|
13
|
+
duration: u = 800,
|
|
14
|
+
delay: o = 0,
|
|
14
15
|
as: E = "div",
|
|
15
|
-
startOnView:
|
|
16
|
+
startOnView: f = !1,
|
|
16
17
|
animateOnHover: F = !0,
|
|
17
18
|
characterSet: s = j,
|
|
18
19
|
...R
|
|
19
20
|
}) {
|
|
20
21
|
const b = x.create(E, {
|
|
21
22
|
forwardMotionProps: !0
|
|
22
|
-
}), [v,
|
|
23
|
+
}), [v, y] = M(
|
|
23
24
|
() => n.split("")
|
|
24
|
-
), [i,
|
|
25
|
-
F && !i && (a.current = 0,
|
|
25
|
+
), [i, r] = M(!1), a = d(0), m = d(null), D = () => {
|
|
26
|
+
F && !i && (a.current = 0, r(!0));
|
|
26
27
|
};
|
|
27
28
|
return I(() => {
|
|
28
|
-
if (!
|
|
29
|
+
if (!f) {
|
|
29
30
|
const t = setTimeout(() => {
|
|
30
|
-
|
|
31
|
-
},
|
|
31
|
+
r(!0);
|
|
32
|
+
}, o);
|
|
32
33
|
return () => clearTimeout(t);
|
|
33
34
|
}
|
|
34
35
|
const e = new IntersectionObserver(
|
|
35
36
|
([t]) => {
|
|
36
37
|
t.isIntersecting && (setTimeout(() => {
|
|
37
|
-
|
|
38
|
-
},
|
|
38
|
+
r(!0);
|
|
39
|
+
}, o), e.disconnect());
|
|
39
40
|
},
|
|
40
41
|
{ threshold: 0.1, rootMargin: "-30% 0px -30% 0px" }
|
|
41
42
|
);
|
|
42
43
|
return m.current && e.observe(m.current), () => e.disconnect();
|
|
43
|
-
}, [
|
|
44
|
+
}, [o, f]), I(() => {
|
|
44
45
|
if (!i) return;
|
|
45
46
|
const e = n.length, t = performance.now();
|
|
46
47
|
let c;
|
|
47
48
|
const l = (H) => {
|
|
48
|
-
const N = H - t,
|
|
49
|
-
a.current =
|
|
49
|
+
const N = H - t, g = Math.min(N / u, 1);
|
|
50
|
+
a.current = g * e, y(
|
|
50
51
|
(P) => P.map(
|
|
51
|
-
(
|
|
52
|
+
(T, A) => T === " " ? T : A <= a.current ? n[A] : s[q(s.length)]
|
|
52
53
|
)
|
|
53
|
-
),
|
|
54
|
+
), g < 1 ? c = requestAnimationFrame(l) : r(!1);
|
|
54
55
|
};
|
|
55
56
|
return c = requestAnimationFrame(l), () => cancelAnimationFrame(c);
|
|
56
|
-
}, [n,
|
|
57
|
+
}, [n, u, i, s]), // eslint-disable-next-line react-hooks/static-components
|
|
58
|
+
/* @__PURE__ */ p(
|
|
57
59
|
b,
|
|
58
60
|
{
|
|
59
61
|
ref: m,
|
|
60
|
-
className:
|
|
62
|
+
className: h("xiping-hyper-container", C),
|
|
61
63
|
onMouseEnter: D,
|
|
62
64
|
...R,
|
|
63
|
-
children: /* @__PURE__ */
|
|
65
|
+
children: /* @__PURE__ */ p(U, { children: v.map((e, t) => /* @__PURE__ */ p(
|
|
64
66
|
x.span,
|
|
65
67
|
{
|
|
66
|
-
className:
|
|
68
|
+
className: h("xiping-hyper-char", e === " " ? "xiping-hyper-space" : ""),
|
|
67
69
|
children: e.toUpperCase()
|
|
68
70
|
},
|
|
69
71
|
t
|
|
@@ -72,5 +74,5 @@ function z({
|
|
|
72
74
|
);
|
|
73
75
|
}
|
|
74
76
|
export {
|
|
75
|
-
|
|
77
|
+
B as HyperText
|
|
76
78
|
};
|
|
@@ -1,94 +1,118 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { Modal as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { useState as
|
|
7
|
-
import
|
|
8
|
-
import { Download as B, X as
|
|
9
|
-
import { AnimatePresence as W, motion as
|
|
10
|
-
import { cn as
|
|
2
|
+
import { jsx as n, jsxs as h } from "react/jsx-runtime";
|
|
3
|
+
import { Modal as z, ModalContent as O, Spinner as S } from "@heroui/react";
|
|
4
|
+
import P from "../pinch-content/PinchContent.js";
|
|
5
|
+
import V from "./ImageThumbnails.js";
|
|
6
|
+
import { useState as v, useCallback as b, useEffect as x } from "react";
|
|
7
|
+
import X from "clsx";
|
|
8
|
+
import { Download as B, X as K } from "lucide-react";
|
|
9
|
+
import { AnimatePresence as W, motion as _ } from "motion/react";
|
|
10
|
+
import { cn as f } from "../../utils/utils.js";
|
|
11
11
|
/* empty css */
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
},
|
|
12
|
+
const C = (c) => {
|
|
13
|
+
c.target.closest(".xiping-main-content") && c.preventDefault();
|
|
14
|
+
}, ne = (c) => {
|
|
15
15
|
const {
|
|
16
|
-
isOpen:
|
|
17
|
-
onClose:
|
|
18
|
-
imgSrc:
|
|
19
|
-
thumbnailImages:
|
|
20
|
-
canDownload:
|
|
21
|
-
wrapperClassName:
|
|
22
|
-
closeClassName:
|
|
23
|
-
downloadClassName:
|
|
24
|
-
toolWrapperClassName:
|
|
25
|
-
initialIndex:
|
|
26
|
-
} =
|
|
16
|
+
isOpen: a,
|
|
17
|
+
onClose: w,
|
|
18
|
+
imgSrc: d,
|
|
19
|
+
thumbnailImages: N,
|
|
20
|
+
canDownload: y = !1,
|
|
21
|
+
wrapperClassName: I,
|
|
22
|
+
closeClassName: E,
|
|
23
|
+
downloadClassName: L,
|
|
24
|
+
toolWrapperClassName: k,
|
|
25
|
+
initialIndex: D = 0
|
|
26
|
+
} = c, o = Array.isArray(d) ? d : [d], A = N || o, R = Math.max(
|
|
27
27
|
0,
|
|
28
|
-
Math.min(
|
|
29
|
-
), [
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
const
|
|
28
|
+
Math.min(D, o.length - 1)
|
|
29
|
+
), [l, g] = v(R), [M, p] = v(!0), m = b(() => {
|
|
30
|
+
p(!0), w();
|
|
31
|
+
}, [w]), T = async () => {
|
|
32
|
+
const i = o[l];
|
|
33
33
|
try {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
} catch (
|
|
37
|
-
console.error("Error downloading image:",
|
|
34
|
+
const r = await (await fetch(i)).blob(), e = window.URL.createObjectURL(r), s = document.createElement("a");
|
|
35
|
+
s.href = e, s.download = i.split("/").pop() || "image", document.body.appendChild(s), s.click(), window.URL.revokeObjectURL(e), document.body.removeChild(s);
|
|
36
|
+
} catch (t) {
|
|
37
|
+
console.error("Error downloading image:", t);
|
|
38
38
|
}
|
|
39
|
+
}, U = () => {
|
|
40
|
+
p(!1);
|
|
39
41
|
}, j = () => {
|
|
40
|
-
|
|
41
|
-
}, k = () => {
|
|
42
|
-
r(!1);
|
|
42
|
+
p(!1);
|
|
43
43
|
};
|
|
44
|
-
|
|
45
|
-
if (
|
|
46
|
-
return document.addEventListener("touchmove",
|
|
44
|
+
x(() => {
|
|
45
|
+
if (a)
|
|
46
|
+
return document.addEventListener("touchmove", C, {
|
|
47
47
|
passive: !1
|
|
48
48
|
}), () => {
|
|
49
|
-
document.removeEventListener("touchmove",
|
|
49
|
+
document.removeEventListener("touchmove", C);
|
|
50
50
|
};
|
|
51
|
-
}, [
|
|
52
|
-
|
|
51
|
+
}, [a]);
|
|
52
|
+
const u = b(() => {
|
|
53
|
+
"vibrate" in navigator && navigator.vibrate([50, 50, 50]);
|
|
54
|
+
}, []);
|
|
55
|
+
return x(() => {
|
|
56
|
+
if (!a) return;
|
|
57
|
+
const i = (t) => {
|
|
58
|
+
const r = t.target;
|
|
59
|
+
if (!(r.tagName === "INPUT" || r.tagName === "TEXTAREA" || r.isContentEditable))
|
|
60
|
+
switch (t.key) {
|
|
61
|
+
case "ArrowLeft":
|
|
62
|
+
t.preventDefault(), g((e) => e > 0 ? e - 1 : (u(), e));
|
|
63
|
+
break;
|
|
64
|
+
case "ArrowRight":
|
|
65
|
+
t.preventDefault(), g((e) => e < o.length - 1 ? e + 1 : (u(), e));
|
|
66
|
+
break;
|
|
67
|
+
case "Escape":
|
|
68
|
+
t.preventDefault(), m();
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
return document.addEventListener("keydown", i), () => {
|
|
73
|
+
document.removeEventListener("keydown", i);
|
|
74
|
+
};
|
|
75
|
+
}, [a, o.length, m, u]), /* @__PURE__ */ n(
|
|
76
|
+
z,
|
|
53
77
|
{
|
|
54
|
-
isOpen:
|
|
78
|
+
isOpen: a,
|
|
55
79
|
size: "full",
|
|
56
80
|
onClose: m,
|
|
57
81
|
classNames: {
|
|
58
|
-
wrapper:
|
|
82
|
+
wrapper: X(I)
|
|
59
83
|
},
|
|
60
84
|
className: "xiping-modal-overlay",
|
|
61
85
|
hideCloseButton: !0,
|
|
62
86
|
portalContainer: document.body,
|
|
63
|
-
children: /* @__PURE__ */
|
|
64
|
-
/* @__PURE__ */
|
|
65
|
-
|
|
87
|
+
children: /* @__PURE__ */ n(O, { className: "xiping-modal-content", children: /* @__PURE__ */ h("div", { className: "xiping-wrapper", children: [
|
|
88
|
+
/* @__PURE__ */ h("div", { className: f("xiping-tool-wrapper", k), children: [
|
|
89
|
+
y && /* @__PURE__ */ n(
|
|
66
90
|
B,
|
|
67
91
|
{
|
|
68
92
|
size: 24,
|
|
69
|
-
className:
|
|
70
|
-
onClick:
|
|
93
|
+
className: f("xiping-download-icon", L),
|
|
94
|
+
onClick: T
|
|
71
95
|
}
|
|
72
96
|
),
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
|
|
97
|
+
/* @__PURE__ */ n(
|
|
98
|
+
K,
|
|
75
99
|
{
|
|
76
100
|
size: 24,
|
|
77
|
-
className:
|
|
101
|
+
className: f("xiping-close-icon", E),
|
|
78
102
|
onClick: m
|
|
79
103
|
}
|
|
80
104
|
)
|
|
81
105
|
] }),
|
|
82
|
-
/* @__PURE__ */
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
|
|
106
|
+
/* @__PURE__ */ h("div", { className: "xiping-main-content", children: [
|
|
107
|
+
/* @__PURE__ */ n(P, { canRotate: !1, className: "xiping-pinch-content", children: /* @__PURE__ */ n(W, { mode: "wait", children: /* @__PURE__ */ n(
|
|
108
|
+
_.img,
|
|
85
109
|
{
|
|
86
110
|
draggable: "false",
|
|
87
|
-
src:
|
|
111
|
+
src: o[l],
|
|
88
112
|
alt: "",
|
|
89
113
|
className: "xiping-image",
|
|
90
|
-
onLoad:
|
|
91
|
-
onError:
|
|
114
|
+
onLoad: U,
|
|
115
|
+
onError: j,
|
|
92
116
|
initial: { opacity: 0, scale: 0.95 },
|
|
93
117
|
animate: { opacity: 1, scale: 1 },
|
|
94
118
|
exit: { opacity: 0, scale: 1.05 },
|
|
@@ -97,16 +121,16 @@ const u = (a) => {
|
|
|
97
121
|
ease: "easeInOut"
|
|
98
122
|
}
|
|
99
123
|
},
|
|
100
|
-
|
|
124
|
+
l
|
|
101
125
|
) }) }),
|
|
102
|
-
M && /* @__PURE__ */
|
|
126
|
+
M && /* @__PURE__ */ n("div", { className: "xiping-loading", children: /* @__PURE__ */ n(S, { color: "white", size: "lg" }) })
|
|
103
127
|
] }),
|
|
104
|
-
/* @__PURE__ */
|
|
105
|
-
|
|
128
|
+
/* @__PURE__ */ n(
|
|
129
|
+
V,
|
|
106
130
|
{
|
|
107
|
-
images:
|
|
108
|
-
currentIndex:
|
|
109
|
-
onImageSelect:
|
|
131
|
+
images: A,
|
|
132
|
+
currentIndex: l,
|
|
133
|
+
onImageSelect: g
|
|
110
134
|
}
|
|
111
135
|
)
|
|
112
136
|
] }) })
|
|
@@ -114,5 +138,5 @@ const u = (a) => {
|
|
|
114
138
|
);
|
|
115
139
|
};
|
|
116
140
|
export {
|
|
117
|
-
|
|
141
|
+
ne as default
|
|
118
142
|
};
|
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
import { jsx as E } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { gsap as
|
|
2
|
+
import { useRef as m, useEffect as F } from "react";
|
|
3
|
+
import { gsap as i } from "gsap";
|
|
4
4
|
import { ScrollTrigger as N } from "gsap/ScrollTrigger";
|
|
5
5
|
import { SplitText as S } from "gsap/SplitText";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import j from "clsx";
|
|
7
|
+
/* empty css */
|
|
8
|
+
i.registerPlugin(N, S);
|
|
9
|
+
const A = ({
|
|
10
|
+
text: l,
|
|
9
11
|
className: C = "",
|
|
10
|
-
delay:
|
|
12
|
+
delay: g = 100,
|
|
11
13
|
duration: d = 0.6,
|
|
12
14
|
ease: h = "power3.out",
|
|
13
15
|
splitType: n = "chars",
|
|
14
16
|
from: w = { opacity: 0, y: 40 },
|
|
15
|
-
to:
|
|
17
|
+
to: c = { opacity: 1, y: 0 },
|
|
16
18
|
threshold: x = 0.1,
|
|
17
|
-
rootMargin:
|
|
19
|
+
rootMargin: y = "-100px",
|
|
18
20
|
textAlign: R = "center",
|
|
19
|
-
onLetterAnimationComplete:
|
|
21
|
+
onLetterAnimationComplete: T
|
|
20
22
|
}) => {
|
|
21
|
-
const
|
|
23
|
+
const a = m(null), $ = m(!1), o = m(null);
|
|
22
24
|
return F(() => {
|
|
23
|
-
if (typeof window > "u" || !
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
25
|
+
if (typeof window > "u" || !a.current || !l) return;
|
|
26
|
+
const p = a.current;
|
|
27
|
+
$.current = !1;
|
|
28
|
+
const b = n === "lines";
|
|
29
|
+
b && (p.style.position = "relative");
|
|
28
30
|
let r;
|
|
29
31
|
try {
|
|
30
|
-
r = new S(
|
|
32
|
+
r = new S(p, {
|
|
31
33
|
type: n,
|
|
32
|
-
absolute:
|
|
34
|
+
absolute: b,
|
|
33
35
|
linesClass: "split-line"
|
|
34
36
|
});
|
|
35
37
|
} catch (t) {
|
|
@@ -57,9 +59,9 @@ const W = ({
|
|
|
57
59
|
e.forEach((t) => {
|
|
58
60
|
t.style.willChange = "transform, opacity";
|
|
59
61
|
});
|
|
60
|
-
const v = (1 - x) * 100,
|
|
62
|
+
const v = (1 - x) * 100, s = /^(-?\d+(?:\.\d+)?)(px|em|rem|%)?$/.exec(y), u = s ? parseFloat(s[1]) : 0, k = s && s[2] || "px", P = u < 0 ? `-=${Math.abs(u)}${k}` : `+=${u}${k}`, D = `top ${v}%${P}`, f = i.timeline({
|
|
61
63
|
scrollTrigger: {
|
|
62
|
-
trigger:
|
|
64
|
+
trigger: p,
|
|
63
65
|
start: D,
|
|
64
66
|
toggleActions: "play none none none",
|
|
65
67
|
once: !0,
|
|
@@ -69,46 +71,46 @@ const W = ({
|
|
|
69
71
|
},
|
|
70
72
|
smoothChildTiming: !0,
|
|
71
73
|
onComplete: () => {
|
|
72
|
-
|
|
73
|
-
...
|
|
74
|
+
$.current = !0, i.set(e, {
|
|
75
|
+
...c,
|
|
74
76
|
clearProps: "willChange",
|
|
75
77
|
immediateRender: !0
|
|
76
|
-
}),
|
|
78
|
+
}), T?.();
|
|
77
79
|
}
|
|
78
80
|
});
|
|
79
|
-
return
|
|
80
|
-
...
|
|
81
|
+
return f.set(e, { ...w, immediateRender: !1, force3D: !0 }), f.to(e, {
|
|
82
|
+
...c,
|
|
81
83
|
duration: d,
|
|
82
84
|
ease: h,
|
|
83
|
-
stagger:
|
|
85
|
+
stagger: g / 1e3,
|
|
84
86
|
force3D: !0
|
|
85
87
|
}), () => {
|
|
86
|
-
|
|
88
|
+
f.kill(), o.current && (o.current.kill(), o.current = null), i.killTweensOf(e), r && r.revert();
|
|
87
89
|
};
|
|
88
90
|
}, [
|
|
89
|
-
|
|
90
|
-
|
|
91
|
+
l,
|
|
92
|
+
g,
|
|
91
93
|
d,
|
|
92
94
|
h,
|
|
93
95
|
n,
|
|
94
96
|
w,
|
|
95
|
-
|
|
97
|
+
c,
|
|
96
98
|
x,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
y,
|
|
100
|
+
T
|
|
99
101
|
]), /* @__PURE__ */ E(
|
|
100
102
|
"p",
|
|
101
103
|
{
|
|
102
|
-
ref:
|
|
103
|
-
className:
|
|
104
|
+
ref: a,
|
|
105
|
+
className: j("xiping-split-parent", C),
|
|
104
106
|
style: {
|
|
105
107
|
textAlign: R,
|
|
106
108
|
wordWrap: "break-word"
|
|
107
109
|
},
|
|
108
|
-
children:
|
|
110
|
+
children: l
|
|
109
111
|
}
|
|
110
112
|
);
|
|
111
113
|
};
|
|
112
114
|
export {
|
|
113
|
-
|
|
115
|
+
A as SplitText
|
|
114
116
|
};
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as T } from "react/jsx-runtime";
|
|
3
3
|
import { cn as x } from "../../utils/utils.js";
|
|
4
|
-
import { motion as
|
|
5
|
-
import { useState as u, useRef as
|
|
6
|
-
|
|
4
|
+
import { motion as I } from "motion/react";
|
|
5
|
+
import { useState as u, useRef as b, useEffect as a } from "react";
|
|
6
|
+
/* empty css */
|
|
7
|
+
function S({
|
|
7
8
|
children: r,
|
|
8
|
-
className:
|
|
9
|
+
className: m,
|
|
9
10
|
duration: s = 100,
|
|
10
11
|
delay: n = 0,
|
|
11
|
-
as:
|
|
12
|
+
as: l = "div",
|
|
12
13
|
startOnView: i = !1,
|
|
13
14
|
...p
|
|
14
15
|
}) {
|
|
15
|
-
const d =
|
|
16
|
+
const d = I.create(l, {
|
|
16
17
|
forwardMotionProps: !0
|
|
17
|
-
}), [g, v] = u(""), [c, f] = u(!1), o =
|
|
18
|
+
}), [g, v] = u(""), [c, f] = u(!1), o = b(null);
|
|
18
19
|
return a(() => {
|
|
19
20
|
if (!i) {
|
|
20
21
|
const t = setTimeout(() => {
|
|
@@ -44,16 +45,13 @@ function R({
|
|
|
44
45
|
d,
|
|
45
46
|
{
|
|
46
47
|
ref: o,
|
|
47
|
-
className: x(
|
|
48
|
-
"text-4xl font-bold leading-[5rem] tracking-[-0.02em]",
|
|
49
|
-
l
|
|
50
|
-
),
|
|
48
|
+
className: x("xiping-typing-animation", m),
|
|
51
49
|
...p,
|
|
52
50
|
children: g
|
|
53
51
|
}
|
|
54
52
|
);
|
|
55
53
|
}
|
|
56
54
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
S as TypingAnimation,
|
|
56
|
+
S as default
|
|
59
57
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RefObject, HTMLAttributes } from 'react';
|
|
2
|
+
interface VariableProximityProps extends HTMLAttributes<HTMLSpanElement> {
|
|
3
|
+
label: string;
|
|
4
|
+
fromFontVariationSettings: string;
|
|
5
|
+
toFontVariationSettings: string;
|
|
6
|
+
containerRef: RefObject<HTMLElement>;
|
|
7
|
+
radius?: number;
|
|
8
|
+
falloff?: "linear" | "exponential" | "gaussian";
|
|
9
|
+
className?: string;
|
|
10
|
+
onClick?: () => void;
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
}
|
|
13
|
+
declare const VariableProximity: import('react').ForwardRefExoticComponent<VariableProximityProps & import('react').RefAttributes<HTMLSpanElement>>;
|
|
14
|
+
export { VariableProximity };
|
|
15
|
+
export default VariableProximity;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { jsxs as $, jsx as C } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as k, useRef as d, useMemo as D, useEffect as F } from "react";
|
|
3
|
+
import { motion as T } from "motion/react";
|
|
4
|
+
/* empty css */
|
|
5
|
+
function z(c) {
|
|
6
|
+
F(() => {
|
|
7
|
+
let i;
|
|
8
|
+
const s = () => {
|
|
9
|
+
c(), i = requestAnimationFrame(s);
|
|
10
|
+
};
|
|
11
|
+
return i = requestAnimationFrame(s), () => cancelAnimationFrame(i);
|
|
12
|
+
}, [c]);
|
|
13
|
+
}
|
|
14
|
+
function G(c) {
|
|
15
|
+
const i = d({ x: 0, y: 0 });
|
|
16
|
+
return F(() => {
|
|
17
|
+
const s = (r, a) => {
|
|
18
|
+
if (c?.current) {
|
|
19
|
+
const p = c.current.getBoundingClientRect();
|
|
20
|
+
i.current = { x: r - p.left, y: a - p.top };
|
|
21
|
+
} else
|
|
22
|
+
i.current = { x: r, y: a };
|
|
23
|
+
}, u = (r) => s(r.clientX, r.clientY), f = (r) => {
|
|
24
|
+
const a = r.touches[0];
|
|
25
|
+
s(a.clientX, a.clientY);
|
|
26
|
+
};
|
|
27
|
+
return window.addEventListener("mousemove", u), window.addEventListener("touchmove", f), () => {
|
|
28
|
+
window.removeEventListener("mousemove", u), window.removeEventListener("touchmove", f);
|
|
29
|
+
};
|
|
30
|
+
}, [c]), i;
|
|
31
|
+
}
|
|
32
|
+
const H = k(
|
|
33
|
+
(c, i) => {
|
|
34
|
+
const {
|
|
35
|
+
label: s,
|
|
36
|
+
fromFontVariationSettings: u,
|
|
37
|
+
toFontVariationSettings: f,
|
|
38
|
+
containerRef: r,
|
|
39
|
+
radius: a = 50,
|
|
40
|
+
falloff: p = "linear",
|
|
41
|
+
className: R = "",
|
|
42
|
+
onClick: V,
|
|
43
|
+
style: P,
|
|
44
|
+
...E
|
|
45
|
+
} = c, x = d([]), v = d([]), h = G(r), g = d({
|
|
46
|
+
x: null,
|
|
47
|
+
y: null
|
|
48
|
+
}), A = D(() => {
|
|
49
|
+
const e = (t) => new Map(
|
|
50
|
+
t.split(",").map((l) => l.trim()).map((l) => {
|
|
51
|
+
const [m, y] = l.split(" ");
|
|
52
|
+
return [m.replace(/['"]/g, ""), parseFloat(y)];
|
|
53
|
+
})
|
|
54
|
+
), n = e(u), o = e(f);
|
|
55
|
+
return Array.from(n.entries()).map(([t, l]) => ({
|
|
56
|
+
axis: t,
|
|
57
|
+
fromValue: l,
|
|
58
|
+
toValue: o.get(t) ?? l
|
|
59
|
+
}));
|
|
60
|
+
}, [u, f]), L = (e, n, o, t) => Math.sqrt((o - e) ** 2 + (t - n) ** 2), b = (e) => {
|
|
61
|
+
const n = Math.min(Math.max(1 - e / a, 0), 1);
|
|
62
|
+
switch (p) {
|
|
63
|
+
case "exponential":
|
|
64
|
+
return n ** 2;
|
|
65
|
+
case "gaussian":
|
|
66
|
+
return Math.exp(-((e / (a / 2)) ** 2) / 2);
|
|
67
|
+
case "linear":
|
|
68
|
+
default:
|
|
69
|
+
return n;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
z(() => {
|
|
73
|
+
if (!r?.current) return;
|
|
74
|
+
const { x: e, y: n } = h.current;
|
|
75
|
+
if (g.current.x === e && g.current.y === n)
|
|
76
|
+
return;
|
|
77
|
+
g.current = { x: e, y: n };
|
|
78
|
+
const o = r.current.getBoundingClientRect();
|
|
79
|
+
x.current.forEach((t, l) => {
|
|
80
|
+
if (!t) return;
|
|
81
|
+
const m = t.getBoundingClientRect(), y = m.left + m.width / 2 - o.left, q = m.top + m.height / 2 - o.top, w = L(
|
|
82
|
+
h.current.x,
|
|
83
|
+
h.current.y,
|
|
84
|
+
y,
|
|
85
|
+
q
|
|
86
|
+
);
|
|
87
|
+
if (w >= a) {
|
|
88
|
+
t.style.fontVariationSettings = u;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const B = b(w), M = A.map(({ axis: I, fromValue: S, toValue: X }) => {
|
|
92
|
+
const Y = S + (X - S) * B;
|
|
93
|
+
return `'${I}' ${Y}`;
|
|
94
|
+
}).join(", ");
|
|
95
|
+
v.current[l] = M, t.style.fontVariationSettings = M;
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
const N = /[\u4e00-\u9fa5]/.test(s) ? s.split("") : s.split(" ").flatMap((e, n, o) => {
|
|
99
|
+
const t = e.split("");
|
|
100
|
+
return n < o.length - 1 ? [...t, " "] : t;
|
|
101
|
+
});
|
|
102
|
+
let j = 0;
|
|
103
|
+
return /* @__PURE__ */ $(
|
|
104
|
+
"span",
|
|
105
|
+
{
|
|
106
|
+
ref: i,
|
|
107
|
+
className: `${R} variable-proximity`,
|
|
108
|
+
onClick: V,
|
|
109
|
+
style: { display: "inline", ...P },
|
|
110
|
+
...E,
|
|
111
|
+
children: [
|
|
112
|
+
N.map((e, n) => {
|
|
113
|
+
const o = j++;
|
|
114
|
+
return /* @__PURE__ */ C(
|
|
115
|
+
T.span,
|
|
116
|
+
{
|
|
117
|
+
ref: (t) => {
|
|
118
|
+
x.current[o] = t;
|
|
119
|
+
},
|
|
120
|
+
style: {
|
|
121
|
+
display: e === " " ? "inline" : "inline-block",
|
|
122
|
+
fontVariationSettings: v.current[o]
|
|
123
|
+
},
|
|
124
|
+
"aria-hidden": "true",
|
|
125
|
+
children: e
|
|
126
|
+
},
|
|
127
|
+
n
|
|
128
|
+
);
|
|
129
|
+
}),
|
|
130
|
+
/* @__PURE__ */ C("span", { className: "sr-only", children: s })
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
H.displayName = "VariableProximity";
|
|
137
|
+
export {
|
|
138
|
+
H as VariableProximity,
|
|
139
|
+
H as default
|
|
140
|
+
};
|