@xiping/react-components 0.0.64 → 0.0.67
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/README.md +10 -2
- package/dist/cjs/components/hyper-text/index.d.ts +22 -0
- package/dist/cjs/components/hyper-text/index.js +1 -0
- package/dist/cjs/components/image-viewer/ImageViewer.js +1 -1
- package/dist/cjs/components/morphing-text/index.d.ts +6 -0
- package/dist/cjs/components/pinch-content/PinchContent.d.ts +1 -0
- package/dist/cjs/components/pinch-content/PinchContent.js +1 -1
- package/dist/cjs/components/shimmer-button/ShimmerButton.d.ts +12 -0
- package/dist/cjs/components/text-animate/TextAnimate.d.ts +52 -0
- package/dist/cjs/components/text-animate/index.d.ts +3 -0
- package/dist/cjs/components/txt-reader/TxtReader.d.ts +4 -0
- package/dist/cjs/components/txt-reader/TxtReader.js +1 -1
- package/dist/cjs/components/typing-animation/index.d.ts +11 -0
- package/dist/cjs/components/typing-animation/index.js +1 -0
- 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/cjs/utils/utils.d.ts +2 -0
- package/dist/cjs/utils/utils.js +1 -0
- package/dist/es/components/hyper-text/index.d.ts +22 -0
- package/dist/es/components/hyper-text/index.js +73 -0
- package/dist/es/components/image-viewer/ImageViewer.js +52 -41
- package/dist/es/components/morphing-text/index.d.ts +6 -0
- package/dist/es/components/pinch-content/PinchContent.d.ts +1 -0
- package/dist/es/components/pinch-content/PinchContent.js +53 -45
- package/dist/es/components/shimmer-button/ShimmerButton.d.ts +12 -0
- package/dist/es/components/text-animate/TextAnimate.d.ts +52 -0
- package/dist/es/components/text-animate/index.d.ts +3 -0
- package/dist/es/components/txt-reader/TxtReader.d.ts +4 -0
- package/dist/es/components/txt-reader/TxtReader.js +69 -57
- package/dist/es/components/typing-animation/index.d.ts +11 -0
- package/dist/es/components/typing-animation/index.js +58 -0
- package/dist/es/index.d.ts +2 -0
- package/dist/es/index.js +12 -8
- package/dist/es/react-components.css +1 -1
- package/dist/es/utils/utils.d.ts +2 -0
- package/dist/es/utils/utils.js +8 -0
- package/package.json +29 -27
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("clsx"),t=require("tailwind-merge");function n(...e){return t.twMerge(r(e))}exports.cn=n;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MotionProps } from 'motion/react';
|
|
2
|
+
type CharacterSet = string[] | readonly string[];
|
|
3
|
+
interface HyperTextProps extends MotionProps {
|
|
4
|
+
/** The text content to be animated */
|
|
5
|
+
children: string;
|
|
6
|
+
/** Optional className for styling */
|
|
7
|
+
className?: string;
|
|
8
|
+
/** Duration of the animation in milliseconds */
|
|
9
|
+
duration?: number;
|
|
10
|
+
/** Delay before animation starts in milliseconds */
|
|
11
|
+
delay?: number;
|
|
12
|
+
/** Component to render as - defaults to div */
|
|
13
|
+
as?: React.ElementType;
|
|
14
|
+
/** Whether to start animation when element comes into view */
|
|
15
|
+
startOnView?: boolean;
|
|
16
|
+
/** Whether to trigger animation on hover */
|
|
17
|
+
animateOnHover?: boolean;
|
|
18
|
+
/** Custom character set for scramble effect. Defaults to uppercase alphabet */
|
|
19
|
+
characterSet?: CharacterSet;
|
|
20
|
+
}
|
|
21
|
+
export declare function HyperText({ children, className, duration, delay, as: Component, startOnView, animateOnHover, characterSet, ...props }: HyperTextProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export default HyperText;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import { cn as g } from "../../utils/utils.js";
|
|
3
|
+
import { motion as v, AnimatePresence as H } from "motion/react";
|
|
4
|
+
import { useState as x, useRef as I, useEffect as d } from "react";
|
|
5
|
+
const N = Object.freeze(
|
|
6
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("")
|
|
7
|
+
), P = (e) => Math.floor(Math.random() * e);
|
|
8
|
+
function L({
|
|
9
|
+
children: e,
|
|
10
|
+
className: A,
|
|
11
|
+
duration: m = 800,
|
|
12
|
+
delay: s = 0,
|
|
13
|
+
as: M = "div",
|
|
14
|
+
startOnView: f = !1,
|
|
15
|
+
animateOnHover: h = !0,
|
|
16
|
+
characterSet: i = N,
|
|
17
|
+
...C
|
|
18
|
+
}) {
|
|
19
|
+
const E = v.create(M, {
|
|
20
|
+
forwardMotionProps: !0
|
|
21
|
+
}), [R, b] = x(
|
|
22
|
+
() => e.split("")
|
|
23
|
+
), [a, o] = x(!1), r = I(0), c = I(null), D = () => {
|
|
24
|
+
h && !a && (r.current = 0, o(!0));
|
|
25
|
+
};
|
|
26
|
+
return d(() => {
|
|
27
|
+
if (!f) {
|
|
28
|
+
const n = setTimeout(() => {
|
|
29
|
+
o(!0);
|
|
30
|
+
}, s);
|
|
31
|
+
return () => clearTimeout(n);
|
|
32
|
+
}
|
|
33
|
+
const t = new IntersectionObserver(
|
|
34
|
+
([n]) => {
|
|
35
|
+
n.isIntersecting && (setTimeout(() => {
|
|
36
|
+
o(!0);
|
|
37
|
+
}, s), t.disconnect());
|
|
38
|
+
},
|
|
39
|
+
{ threshold: 0.1, rootMargin: "-30% 0px -30% 0px" }
|
|
40
|
+
);
|
|
41
|
+
return c.current && t.observe(c.current), () => t.disconnect();
|
|
42
|
+
}, [s, f]), d(() => {
|
|
43
|
+
if (!a) return;
|
|
44
|
+
const t = m / (e.length * 10), n = e.length, l = setInterval(() => {
|
|
45
|
+
r.current < n ? (b(
|
|
46
|
+
(w) => w.map(
|
|
47
|
+
(p, T) => p === " " ? p : T <= r.current ? e[T] : i[P(i.length)]
|
|
48
|
+
)
|
|
49
|
+
), r.current = r.current + 0.1) : (o(!1), clearInterval(l));
|
|
50
|
+
}, t);
|
|
51
|
+
return () => clearInterval(l);
|
|
52
|
+
}, [e, m, a, i]), /* @__PURE__ */ u(
|
|
53
|
+
E,
|
|
54
|
+
{
|
|
55
|
+
ref: c,
|
|
56
|
+
className: g("overflow-hidden py-2 text-4xl font-bold", A),
|
|
57
|
+
onMouseEnter: D,
|
|
58
|
+
...C,
|
|
59
|
+
children: /* @__PURE__ */ u(H, { children: R.map((t, n) => /* @__PURE__ */ u(
|
|
60
|
+
v.span,
|
|
61
|
+
{
|
|
62
|
+
className: g("font-mono", t === " " ? "w-3" : ""),
|
|
63
|
+
children: t.toUpperCase()
|
|
64
|
+
},
|
|
65
|
+
n
|
|
66
|
+
)) })
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
L as HyperText,
|
|
72
|
+
L as default
|
|
73
|
+
};
|
|
@@ -1,42 +1,43 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { Modal as
|
|
3
|
-
import { Spinner as
|
|
1
|
+
import { jsx as e, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { Modal as C, ModalContent as k } from "@heroui/modal";
|
|
3
|
+
import { Spinner as z } from "@heroui/spinner";
|
|
4
4
|
import { IoDownloadOutline as j, IoCloseSharp as I } from "react-icons/io5";
|
|
5
5
|
import L from "../pinch-content/PinchContent.js";
|
|
6
|
+
import * as n from "@radix-ui/react-scroll-area";
|
|
6
7
|
import { useState as m } from "react";
|
|
7
8
|
const D = (h) => {
|
|
8
|
-
const { isOpen:
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
const o = r[
|
|
9
|
+
const { isOpen: p, onClose: b, imgSrc: s, canDownload: u = !1 } = h, r = Array.isArray(s) ? s : [s], [i, g] = m(0), [w, c] = m(!0), d = () => {
|
|
10
|
+
c(!0), b();
|
|
11
|
+
}, x = async () => {
|
|
12
|
+
const o = r[i];
|
|
12
13
|
try {
|
|
13
|
-
const
|
|
14
|
-
|
|
14
|
+
const y = await (await fetch(o)).blob(), f = window.URL.createObjectURL(y), t = document.createElement("a");
|
|
15
|
+
t.href = f, t.download = o.split("/").pop() || "image", document.body.appendChild(t), t.click(), window.URL.revokeObjectURL(f), document.body.removeChild(t);
|
|
15
16
|
} catch (a) {
|
|
16
17
|
console.error("Error downloading image:", a);
|
|
17
18
|
}
|
|
18
|
-
},
|
|
19
|
-
|
|
19
|
+
}, N = () => {
|
|
20
|
+
c(!1);
|
|
20
21
|
}, v = () => {
|
|
21
|
-
|
|
22
|
+
c(!1);
|
|
22
23
|
};
|
|
23
24
|
return /* @__PURE__ */ e(
|
|
24
|
-
|
|
25
|
+
C,
|
|
25
26
|
{
|
|
26
|
-
isOpen:
|
|
27
|
+
isOpen: p,
|
|
27
28
|
size: "full",
|
|
28
|
-
onClose:
|
|
29
|
+
onClose: d,
|
|
29
30
|
className: "bg-black bg-opacity-70",
|
|
30
31
|
hideCloseButton: !0,
|
|
31
32
|
portalContainer: document.body,
|
|
32
|
-
children: /* @__PURE__ */ e(
|
|
33
|
-
/* @__PURE__ */
|
|
34
|
-
|
|
33
|
+
children: /* @__PURE__ */ e(k, { className: "overflow-hidden", children: /* @__PURE__ */ l("div", { className: "w-screen h-screen relative flex flex-col pt-safe-offset-0", children: [
|
|
34
|
+
/* @__PURE__ */ l("div", { className: "absolute top-2 right-2 flex gap-4 z-10", children: [
|
|
35
|
+
u && /* @__PURE__ */ e(
|
|
35
36
|
j,
|
|
36
37
|
{
|
|
37
38
|
size: 24,
|
|
38
39
|
className: "text-white cursor-pointer",
|
|
39
|
-
onClick:
|
|
40
|
+
onClick: x
|
|
40
41
|
}
|
|
41
42
|
),
|
|
42
43
|
/* @__PURE__ */ e(
|
|
@@ -44,41 +45,51 @@ const D = (h) => {
|
|
|
44
45
|
{
|
|
45
46
|
size: 24,
|
|
46
47
|
className: "text-white cursor-pointer",
|
|
47
|
-
onClick:
|
|
48
|
+
onClick: d
|
|
48
49
|
}
|
|
49
50
|
)
|
|
50
51
|
] }),
|
|
51
|
-
/* @__PURE__ */
|
|
52
|
+
/* @__PURE__ */ l("div", { className: "flex-1 min-h-0 relative flex items-center justify-center", children: [
|
|
52
53
|
/* @__PURE__ */ e(L, { canRotate: !1, className: "w-full h-full", children: /* @__PURE__ */ e(
|
|
53
54
|
"img",
|
|
54
55
|
{
|
|
55
56
|
draggable: "false",
|
|
56
|
-
src: r[
|
|
57
|
+
src: r[i],
|
|
57
58
|
alt: "",
|
|
58
59
|
className: "w-screen h-full object-contain pointer-events-none",
|
|
59
|
-
onLoad:
|
|
60
|
+
onLoad: N,
|
|
60
61
|
onError: v
|
|
61
62
|
}
|
|
62
63
|
) }),
|
|
63
|
-
|
|
64
|
+
w && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center bg-black bg-opacity-50", children: /* @__PURE__ */ e(z, { color: "white", size: "lg" }) })
|
|
64
65
|
] }),
|
|
65
|
-
r.length > 1 && /* @__PURE__ */ e("div", { className: "h-24 bg-black bg-opacity-50 shrink-0 z-10", children: /* @__PURE__ */
|
|
66
|
-
"div",
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
66
|
+
r.length > 1 && /* @__PURE__ */ e("div", { className: "h-24 bg-black bg-opacity-50 shrink-0 z-10 pb-safe-offset-0 pl-safe-offset-0 pr-safe-offset-0", children: /* @__PURE__ */ l(n.Root, { className: "h-24 w-screen", type: "auto", children: [
|
|
67
|
+
/* @__PURE__ */ e(n.Viewport, { className: "pppp h-full w-full", children: /* @__PURE__ */ e("div", { className: "flex gap-2 p-2 h-24", children: r.map((o, a) => /* @__PURE__ */ e(
|
|
68
|
+
"div",
|
|
69
|
+
{
|
|
70
|
+
className: `h-full aspect-square flex-shrink-0 cursor-pointer border-2 transition-all ${a === i ? "border-white" : "border-transparent"}`,
|
|
71
|
+
onClick: () => g(a),
|
|
72
|
+
children: /* @__PURE__ */ e(
|
|
73
|
+
"img",
|
|
74
|
+
{
|
|
75
|
+
src: o,
|
|
76
|
+
alt: "",
|
|
77
|
+
className: "w-full h-full object-contain",
|
|
78
|
+
draggable: "false"
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
},
|
|
82
|
+
o
|
|
83
|
+
)) }) }),
|
|
84
|
+
/* @__PURE__ */ e(
|
|
85
|
+
n.Scrollbar,
|
|
86
|
+
{
|
|
87
|
+
className: "flex select-none touch-none p-0.5 bg-black/50 transition-colors duration-150 ease-out hover:bg-black/80 data-[orientation=horizontal]:h-2.5 data-[orientation=vertical]:w-2.5 data-[orientation=horizontal]:flex-col",
|
|
88
|
+
orientation: "horizontal",
|
|
89
|
+
children: /* @__PURE__ */ e(n.Thumb, { className: "flex-1 bg-white/50 rounded-[10px] relative before:content-[''] before:absolute before:top-1/2 before:left-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:w-full before:h-full before:min-w-[44px] before:min-h-[44px]" })
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
] }) })
|
|
82
93
|
] }) })
|
|
83
94
|
}
|
|
84
95
|
);
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useSpring as
|
|
3
|
-
import { createUseGesture as
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { useMount as
|
|
1
|
+
import { jsx as P } from "react/jsx-runtime";
|
|
2
|
+
import { useSpring as R, animated as B } from "@react-spring/web";
|
|
3
|
+
import { createUseGesture as C, dragAction as G, pinchAction as N, wheelAction as U } from "@use-gesture/react";
|
|
4
|
+
import { useRef as j } from "react";
|
|
5
|
+
import { useMount as F, useUnmount as W } from "ahooks";
|
|
6
6
|
import k from "clsx";
|
|
7
|
-
const q =
|
|
7
|
+
const q = C([G, N, U]), o = (i) => i.preventDefault(), Q = (i) => {
|
|
8
8
|
const {
|
|
9
|
-
className:
|
|
10
|
-
children:
|
|
11
|
-
canPinch:
|
|
9
|
+
className: m,
|
|
10
|
+
children: h,
|
|
11
|
+
canPinch: g = !0,
|
|
12
12
|
canDrag: p = !0,
|
|
13
|
-
canRotate:
|
|
14
|
-
scaleBounds:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
canRotate: v = !0,
|
|
14
|
+
scaleBounds: l = { min: 0.3, max: 10 },
|
|
15
|
+
wheelZoomFactor: x = 0.1
|
|
16
|
+
} = i, n = j(null);
|
|
17
|
+
F(() => {
|
|
18
|
+
var t, e, r;
|
|
19
|
+
(t = n.current) == null || t.addEventListener("gesturestart", o), (e = n.current) == null || e.addEventListener("gesturechange", o), (r = n.current) == null || r.addEventListener("gestureend", o);
|
|
20
|
+
}), W(() => {
|
|
21
|
+
var t, e, r;
|
|
22
|
+
(t = n.current) == null || t.removeEventListener("gesturestart", o), (e = n.current) == null || e.removeEventListener("gesturechange", o), (r = n.current) == null || r.removeEventListener("gestureend", o);
|
|
22
23
|
});
|
|
23
|
-
const [
|
|
24
|
+
const [s, d] = R(() => ({
|
|
24
25
|
x: 0,
|
|
25
26
|
y: 0,
|
|
26
27
|
scale: 1,
|
|
@@ -28,45 +29,52 @@ const q = N([U, j]), o = (u) => u.preventDefault(), O = (u) => {
|
|
|
28
29
|
}));
|
|
29
30
|
return q(
|
|
30
31
|
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
onWheel: ({ event: t, delta: [, e] }) => {
|
|
33
|
+
if (!g) return;
|
|
34
|
+
const a = s.scale.get() * (1 - e * x), u = Math.min(
|
|
35
|
+
Math.max(a, l.min),
|
|
36
|
+
l.max
|
|
37
|
+
);
|
|
38
|
+
d.start({ scale: u });
|
|
39
|
+
},
|
|
40
|
+
onDrag: ({ pinching: t, cancel: e, offset: [r, a], ...u }) => {
|
|
41
|
+
if (!p || t) return e();
|
|
42
|
+
d.start({ x: r, y: a });
|
|
36
43
|
},
|
|
37
44
|
onPinch: ({
|
|
38
|
-
origin: [
|
|
39
|
-
first:
|
|
45
|
+
origin: [t, e],
|
|
46
|
+
first: r,
|
|
40
47
|
movement: [a],
|
|
41
|
-
offset: [
|
|
42
|
-
memo:
|
|
43
|
-
cancel:
|
|
48
|
+
offset: [u, y],
|
|
49
|
+
memo: c,
|
|
50
|
+
cancel: E
|
|
44
51
|
}) => {
|
|
45
|
-
if (!
|
|
46
|
-
if (
|
|
47
|
-
const { width:
|
|
48
|
-
|
|
52
|
+
if (!g) return E();
|
|
53
|
+
if (r) {
|
|
54
|
+
const { width: S, height: b, x: Z, y: A } = n.current.getBoundingClientRect(), D = t - (Z + S / 2), M = e - (A + b / 2);
|
|
55
|
+
c = [s.x.get(), s.y.get(), D, M];
|
|
49
56
|
}
|
|
50
|
-
const
|
|
51
|
-
return
|
|
57
|
+
const L = c[0] - (a - 1) * c[2], w = c[1] - (a - 1) * c[3], f = { scale: u, rotateZ: 0, x: L, y: w };
|
|
58
|
+
return v && (f.rotateZ = y), d.start(f), c;
|
|
52
59
|
}
|
|
53
60
|
},
|
|
54
61
|
{
|
|
55
|
-
target:
|
|
56
|
-
drag: { from: () => [
|
|
57
|
-
pinch: { scaleBounds:
|
|
62
|
+
target: n,
|
|
63
|
+
drag: { from: () => [s.x.get(), s.y.get()] },
|
|
64
|
+
pinch: { scaleBounds: l, rubberband: !0 },
|
|
65
|
+
wheel: { enabled: !0 }
|
|
58
66
|
}
|
|
59
67
|
), // <div className="flex items-center justify-center h-full w-full">
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
|
|
68
|
+
/* @__PURE__ */ P(
|
|
69
|
+
B.div,
|
|
62
70
|
{
|
|
63
|
-
className: k("select-none",
|
|
64
|
-
ref:
|
|
65
|
-
style:
|
|
66
|
-
children:
|
|
71
|
+
className: k("select-none", m),
|
|
72
|
+
ref: n,
|
|
73
|
+
style: s,
|
|
74
|
+
children: h
|
|
67
75
|
}
|
|
68
76
|
);
|
|
69
77
|
};
|
|
70
78
|
export {
|
|
71
|
-
|
|
79
|
+
Q as default
|
|
72
80
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as React, ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
export interface ShimmerButtonProps extends ComponentPropsWithoutRef<"button"> {
|
|
3
|
+
shimmerColor?: string;
|
|
4
|
+
shimmerSize?: string;
|
|
5
|
+
borderRadius?: string;
|
|
6
|
+
shimmerDuration?: string;
|
|
7
|
+
background?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export declare const ShimmerButton: React.ForwardRefExoticComponent<ShimmerButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
12
|
+
export default ShimmerButton;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { MotionProps, Variants } from 'motion/react';
|
|
2
|
+
import { ElementType } from 'react';
|
|
3
|
+
type AnimationType = "text" | "word" | "character" | "line";
|
|
4
|
+
type AnimationVariant = "fadeIn" | "blurIn" | "blurInUp" | "blurInDown" | "slideUp" | "slideDown" | "slideLeft" | "slideRight" | "scaleUp" | "scaleDown";
|
|
5
|
+
interface TextAnimateProps extends MotionProps {
|
|
6
|
+
/**
|
|
7
|
+
* The text content to animate
|
|
8
|
+
*/
|
|
9
|
+
children: string;
|
|
10
|
+
/**
|
|
11
|
+
* The class name to be applied to the component
|
|
12
|
+
*/
|
|
13
|
+
className?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The class name to be applied to each segment
|
|
16
|
+
*/
|
|
17
|
+
segmentClassName?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The delay before the animation starts
|
|
20
|
+
*/
|
|
21
|
+
delay?: number;
|
|
22
|
+
/**
|
|
23
|
+
* The duration of the animation
|
|
24
|
+
*/
|
|
25
|
+
duration?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Custom motion variants for the animation
|
|
28
|
+
*/
|
|
29
|
+
variants?: Variants;
|
|
30
|
+
/**
|
|
31
|
+
* The element type to render
|
|
32
|
+
*/
|
|
33
|
+
as?: ElementType;
|
|
34
|
+
/**
|
|
35
|
+
* How to split the text ("text", "word", "character")
|
|
36
|
+
*/
|
|
37
|
+
by?: AnimationType;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to start animation when component enters viewport
|
|
40
|
+
*/
|
|
41
|
+
startOnView?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Whether to animate only once
|
|
44
|
+
*/
|
|
45
|
+
once?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* The animation preset to use
|
|
48
|
+
*/
|
|
49
|
+
animation?: AnimationVariant;
|
|
50
|
+
}
|
|
51
|
+
export declare function TextAnimate({ children, delay, duration, variants, className, segmentClassName, as: Component, startOnView, once, by, animation, ...props }: TextAnimateProps): import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
export {};
|
|
@@ -9,6 +9,10 @@ interface TxtReaderProps {
|
|
|
9
9
|
onProgressChange?: (progress: number) => void;
|
|
10
10
|
initialScrollPosition?: number;
|
|
11
11
|
cacheKey?: string;
|
|
12
|
+
showTopProgress?: boolean;
|
|
13
|
+
topProgressClassName?: string;
|
|
14
|
+
showBottomProgress?: boolean;
|
|
15
|
+
bottomProgressClassName?: string;
|
|
12
16
|
}
|
|
13
17
|
export declare const TxtReader: FC<TxtReaderProps>;
|
|
14
18
|
export default TxtReader;
|
|
@@ -1,68 +1,80 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import { jsxs as s, Fragment as F, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as a } from "react";
|
|
3
|
+
import r from "clsx";
|
|
4
|
+
import { useScroll as _, useTransform as v, useMotionTemplate as y, motion as n } from "motion/react";
|
|
5
|
+
const g = 16, I = 1.5, L = "normal", j = ({
|
|
6
6
|
content: f,
|
|
7
|
-
lineHeight:
|
|
8
|
-
fontSize:
|
|
9
|
-
fontWeight:
|
|
10
|
-
className:
|
|
11
|
-
style:
|
|
12
|
-
onProgressChange:
|
|
13
|
-
initialScrollPosition:
|
|
14
|
-
cacheKey:
|
|
7
|
+
lineHeight: m = I,
|
|
8
|
+
fontSize: d = g,
|
|
9
|
+
fontWeight: p = L,
|
|
10
|
+
className: u = "",
|
|
11
|
+
style: x = {},
|
|
12
|
+
onProgressChange: t,
|
|
13
|
+
initialScrollPosition: R,
|
|
14
|
+
cacheKey: S,
|
|
15
|
+
showTopProgress: T = !0,
|
|
16
|
+
topProgressClassName: b,
|
|
17
|
+
showBottomProgress: h = !0,
|
|
18
|
+
bottomProgressClassName: N
|
|
15
19
|
}) => {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
[l]
|
|
26
|
-
);
|
|
27
|
-
return d(() => {
|
|
28
|
-
if (!r.current) return;
|
|
29
|
-
let t = c;
|
|
30
|
-
if (e) {
|
|
31
|
-
const o = localStorage.getItem(`txtReader-${e}`);
|
|
32
|
-
o && (t = parseInt(o, 10));
|
|
33
|
-
}
|
|
34
|
-
t && (r.current.scrollTop = t, l());
|
|
35
|
-
}, [e, c, l]), d(() => {
|
|
36
|
-
const t = r.current;
|
|
37
|
-
if (t)
|
|
38
|
-
return t.addEventListener("scroll", n), () => {
|
|
39
|
-
t.removeEventListener("scroll", n);
|
|
40
|
-
};
|
|
41
|
-
}, [n]), /* @__PURE__ */ a("div", { className: "relative w-full h-full", children: [
|
|
42
|
-
/* @__PURE__ */ H(
|
|
43
|
-
"div",
|
|
20
|
+
const l = a(null), o = a(null), { scrollYProgress: i } = _({
|
|
21
|
+
container: l,
|
|
22
|
+
target: o
|
|
23
|
+
}), c = v(() => (i.get() * 100).toFixed(2)), w = y`${c}%`;
|
|
24
|
+
return c.on("change", (E) => {
|
|
25
|
+
t == null || t(Number(E));
|
|
26
|
+
}), /* @__PURE__ */ s(F, { children: [
|
|
27
|
+
T && /* @__PURE__ */ e(
|
|
28
|
+
n.div,
|
|
44
29
|
{
|
|
45
|
-
|
|
46
|
-
className:
|
|
47
|
-
"
|
|
48
|
-
|
|
30
|
+
id: "scroll-indicator",
|
|
31
|
+
className: r(
|
|
32
|
+
"fixed left-0 top-0 right-0 bg-[#ff0088] h-2.5",
|
|
33
|
+
b
|
|
49
34
|
),
|
|
50
35
|
style: {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
...E
|
|
55
|
-
},
|
|
56
|
-
children: f
|
|
36
|
+
scaleX: i,
|
|
37
|
+
originX: 0
|
|
38
|
+
}
|
|
57
39
|
}
|
|
58
40
|
),
|
|
59
|
-
/* @__PURE__ */
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
41
|
+
/* @__PURE__ */ s(
|
|
42
|
+
"div",
|
|
43
|
+
{
|
|
44
|
+
className: "relative w-full h-full overflow-y-auto",
|
|
45
|
+
ref: l,
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ e(
|
|
48
|
+
"div",
|
|
49
|
+
{
|
|
50
|
+
ref: o,
|
|
51
|
+
className: r("w-full whitespace-pre-wrap break-words", u),
|
|
52
|
+
style: {
|
|
53
|
+
fontSize: `${d}px`,
|
|
54
|
+
lineHeight: m,
|
|
55
|
+
fontWeight: p,
|
|
56
|
+
...x
|
|
57
|
+
},
|
|
58
|
+
children: f
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
h && /* @__PURE__ */ e(
|
|
62
|
+
n.div,
|
|
63
|
+
{
|
|
64
|
+
id: "scroll-present",
|
|
65
|
+
className: r(
|
|
66
|
+
"fixed text-white rounded text-sm bg-black bg-opacity-70 pl-2 pr-2 pb-1 pt-1 right-5 bottom-5",
|
|
67
|
+
N
|
|
68
|
+
),
|
|
69
|
+
children: w
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
)
|
|
63
75
|
] });
|
|
64
76
|
};
|
|
65
77
|
export {
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
j as TxtReader,
|
|
79
|
+
j as default
|
|
68
80
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MotionProps } from 'motion/react';
|
|
2
|
+
interface TypingAnimationProps extends MotionProps {
|
|
3
|
+
children: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
duration?: number;
|
|
6
|
+
delay?: number;
|
|
7
|
+
as?: React.ElementType;
|
|
8
|
+
startOnView?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function TypingAnimation({ children, className, duration, delay, as: Component, startOnView, ...props }: TypingAnimationProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default TypingAnimation;
|