@xiping/react-components 1.0.40 → 1.0.45
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/shimmer-button/ShimmerButton.js +1 -1
- package/dist/cjs/components/shiny-button/ShinyButton.js +1 -1
- package/dist/cjs/components/sparkles-text/SparklesText.js +1 -1
- package/dist/cjs/components/split-text/SplitText.js +1 -1
- package/dist/cjs/components/subtitle-player/SubtitlePlayer.d.ts +30 -0
- package/dist/cjs/components/subtitle-player/SubtitlePlayer.js +3 -0
- package/dist/cjs/components/subtitle-player/index.d.ts +2 -0
- package/dist/cjs/components/txt-editor/TxtEditor.d.ts +5 -4
- package/dist/cjs/components/txt-editor/TxtEditor.js +32 -1
- package/dist/cjs/components/txt-reader/TxtReader.js +1 -1
- package/dist/cjs/components/txt-reader/index.module.css.js +1 -1
- package/dist/cjs/components/typing-animation/index.js +1 -1
- package/dist/cjs/components/variable-proximity/index.d.ts +25 -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 +3 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/react-components.css +1 -1
- package/dist/cjs/subtitle/lib/src/parser.js +5 -0
- 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/shimmer-button/ShimmerButton.js +29 -62
- package/dist/es/components/shiny-button/ShinyButton.js +15 -17
- package/dist/es/components/sparkles-text/SparklesText.js +30 -29
- package/dist/es/components/split-text/SplitText.js +37 -35
- package/dist/es/components/subtitle-player/SubtitlePlayer.d.ts +30 -0
- package/dist/es/components/subtitle-player/SubtitlePlayer.js +103 -0
- package/dist/es/components/subtitle-player/index.d.ts +2 -0
- package/dist/es/components/txt-editor/TxtEditor.d.ts +5 -4
- package/dist/es/components/txt-editor/TxtEditor.js +102 -43
- package/dist/es/components/txt-reader/TxtReader.js +48 -55
- package/dist/es/components/txt-reader/index.module.css.js +6 -2
- package/dist/es/components/typing-animation/index.js +11 -13
- package/dist/es/components/variable-proximity/index.d.ts +25 -0
- package/dist/es/components/variable-proximity/index.js +212 -0
- package/dist/es/components/video-dialog/VideoDialog.js +35 -48
- package/dist/es/index.d.ts +3 -0
- package/dist/es/index.js +60 -54
- package/dist/es/react-components.css +1 -1
- package/dist/es/subtitle/lib/src/parser.js +56 -0
- package/package.json +16 -12
|
@@ -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,75 +1,42 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { cn as
|
|
4
|
-
|
|
1
|
+
import { jsxs as c, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import d from "react";
|
|
3
|
+
import { cn as h } from "../../utils/utils.js";
|
|
4
|
+
/* empty css */
|
|
5
|
+
const l = d.forwardRef(
|
|
5
6
|
({
|
|
6
|
-
shimmerColor:
|
|
7
|
-
shimmerSize:
|
|
8
|
-
shimmerDuration:
|
|
9
|
-
borderRadius:
|
|
10
|
-
background:
|
|
11
|
-
className:
|
|
12
|
-
children:
|
|
13
|
-
...
|
|
14
|
-
},
|
|
7
|
+
shimmerColor: r = "#ffffff",
|
|
8
|
+
shimmerSize: e = "0.05em",
|
|
9
|
+
shimmerDuration: m = "3s",
|
|
10
|
+
borderRadius: s = "100px",
|
|
11
|
+
background: t = "rgba(0, 0, 0, 1)",
|
|
12
|
+
className: a,
|
|
13
|
+
children: o,
|
|
14
|
+
...n
|
|
15
|
+
}, p) => /* @__PURE__ */ c(
|
|
15
16
|
"button",
|
|
16
17
|
{
|
|
17
18
|
style: {
|
|
18
19
|
"--spread": "90deg",
|
|
19
|
-
"--shimmer-color":
|
|
20
|
-
"--radius":
|
|
21
|
-
"--speed":
|
|
22
|
-
"--cut":
|
|
23
|
-
"--bg":
|
|
20
|
+
"--shimmer-color": r,
|
|
21
|
+
"--radius": s,
|
|
22
|
+
"--speed": m,
|
|
23
|
+
"--cut": e,
|
|
24
|
+
"--bg": t
|
|
24
25
|
},
|
|
25
|
-
className:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
n
|
|
29
|
-
),
|
|
30
|
-
ref: u,
|
|
31
|
-
...f,
|
|
26
|
+
className: h("xiping-shimmer-button", a),
|
|
27
|
+
ref: p,
|
|
28
|
+
...n,
|
|
32
29
|
children: [
|
|
33
|
-
/* @__PURE__ */
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"-z-30 blur-[2px]",
|
|
38
|
-
"absolute inset-0 overflow-visible [container-type:size]"
|
|
39
|
-
),
|
|
40
|
-
children: /* @__PURE__ */ r("div", { className: "absolute inset-0 h-[100cqh] animate-shimmer-slide [aspect-ratio:1] [border-radius:0] [mask:none]", children: /* @__PURE__ */ r("div", { className: "absolute -inset-full w-auto rotate-0 animate-spin-around [background:conic-gradient(from_calc(270deg-(var(--spread)*0.5)),transparent_0,var(--shimmer-color)_var(--spread),transparent_var(--spread))] [translate:0_0]" }) })
|
|
41
|
-
}
|
|
42
|
-
),
|
|
43
|
-
d,
|
|
44
|
-
/* @__PURE__ */ r(
|
|
45
|
-
"div",
|
|
46
|
-
{
|
|
47
|
-
className: e(
|
|
48
|
-
"insert-0 absolute size-full",
|
|
49
|
-
"rounded-2xl px-4 py-1.5 text-sm font-medium shadow-[inset_0_-8px_10px_#ffffff1f]",
|
|
50
|
-
// transition
|
|
51
|
-
"transform-gpu transition-all duration-300 ease-in-out",
|
|
52
|
-
// on hover
|
|
53
|
-
"group-hover:shadow-[inset_0_-6px_10px_#ffffff3f]",
|
|
54
|
-
// on click
|
|
55
|
-
"group-active:shadow-[inset_0_-10px_10px_#ffffff3f]"
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
),
|
|
59
|
-
/* @__PURE__ */ r(
|
|
60
|
-
"div",
|
|
61
|
-
{
|
|
62
|
-
className: e(
|
|
63
|
-
"absolute -z-20 [background:var(--bg)] [border-radius:var(--radius)] [inset:var(--cut)]"
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
)
|
|
30
|
+
/* @__PURE__ */ i("div", { className: "xiping-shimmer-button-spark-container", children: /* @__PURE__ */ i("div", { className: "xiping-shimmer-button-spark", children: /* @__PURE__ */ i("div", { className: "xiping-shimmer-button-spark-before" }) }) }),
|
|
31
|
+
o,
|
|
32
|
+
/* @__PURE__ */ i("div", { className: "xiping-shimmer-button-highlight" }),
|
|
33
|
+
/* @__PURE__ */ i("div", { className: "xiping-shimmer-button-backdrop" })
|
|
67
34
|
]
|
|
68
35
|
}
|
|
69
36
|
)
|
|
70
37
|
);
|
|
71
|
-
|
|
38
|
+
l.displayName = "ShimmerButton";
|
|
72
39
|
export {
|
|
73
|
-
|
|
74
|
-
|
|
40
|
+
l as ShimmerButton,
|
|
41
|
+
l as default
|
|
75
42
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
2
|
+
import { jsxs as t, jsx as a } from "react/jsx-runtime";
|
|
3
3
|
import { cn as s } from "../../utils/utils.js";
|
|
4
4
|
import { motion as o } from "motion/react";
|
|
5
|
-
import
|
|
6
|
-
|
|
5
|
+
import p from "react";
|
|
6
|
+
/* empty css */
|
|
7
|
+
const c = {
|
|
7
8
|
initial: { "--x": "100%", scale: 0.8 },
|
|
8
9
|
animate: { "--x": "-100%", scale: 1 },
|
|
9
10
|
whileTap: { scale: 0.95 },
|
|
@@ -22,28 +23,25 @@ const p = {
|
|
|
22
23
|
mass: 0.5
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
},
|
|
26
|
+
}, l = p.forwardRef(({ children: r, className: e, ...n }, i) => /* @__PURE__ */ t(
|
|
26
27
|
o.button,
|
|
27
28
|
{
|
|
28
29
|
ref: i,
|
|
29
|
-
className: s(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
),
|
|
33
|
-
...p,
|
|
34
|
-
...t,
|
|
30
|
+
className: s("xiping-shiny-button", e),
|
|
31
|
+
...c,
|
|
32
|
+
...n,
|
|
35
33
|
children: [
|
|
36
|
-
/* @__PURE__ */
|
|
34
|
+
/* @__PURE__ */ a(
|
|
37
35
|
"span",
|
|
38
36
|
{
|
|
39
|
-
className: "
|
|
37
|
+
className: "xiping-shiny-button-text",
|
|
40
38
|
style: {
|
|
41
39
|
maskImage: "linear-gradient(-75deg,var(--primary) calc(var(--x) + 20%),transparent calc(var(--x) + 30%),var(--primary) calc(var(--x) + 100%))"
|
|
42
40
|
},
|
|
43
|
-
children:
|
|
41
|
+
children: r
|
|
44
42
|
}
|
|
45
43
|
),
|
|
46
|
-
/* @__PURE__ */
|
|
44
|
+
/* @__PURE__ */ a(
|
|
47
45
|
"span",
|
|
48
46
|
{
|
|
49
47
|
style: {
|
|
@@ -51,13 +49,13 @@ const p = {
|
|
|
51
49
|
WebkitMask: "linear-gradient(rgb(0,0,0), rgb(0,0,0)) content-box exclude,linear-gradient(rgb(0,0,0), rgb(0,0,0))",
|
|
52
50
|
backgroundImage: "linear-gradient(-75deg,var(--primary)/10% calc(var(--x)+20%),var(--primary)/50% calc(var(--x)+25%),var(--primary)/10% calc(var(--x)+100%))"
|
|
53
51
|
},
|
|
54
|
-
className: "
|
|
52
|
+
className: "xiping-shiny-button-border"
|
|
55
53
|
}
|
|
56
54
|
)
|
|
57
55
|
]
|
|
58
56
|
}
|
|
59
57
|
));
|
|
60
|
-
|
|
58
|
+
l.displayName = "ShinyButton";
|
|
61
59
|
export {
|
|
62
|
-
|
|
60
|
+
l as ShinyButton
|
|
63
61
|
};
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as r, jsxs as
|
|
3
|
-
import { motion as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { cn as
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { jsx as r, jsxs as g } from "react/jsx-runtime";
|
|
3
|
+
import { motion as k } from "motion/react";
|
|
4
|
+
import { useState as L, useEffect as S } from "react";
|
|
5
|
+
import { cn as y } from "../../utils/utils.js";
|
|
6
|
+
/* empty css */
|
|
7
|
+
const M = ({ id: i, x: t, y: o, color: s, delay: c, scale: l }) => /* @__PURE__ */ r(
|
|
8
|
+
k.svg,
|
|
8
9
|
{
|
|
9
|
-
className: "
|
|
10
|
-
initial: { opacity: 0, left: t, top:
|
|
10
|
+
className: "xiping-sparkle",
|
|
11
|
+
initial: { opacity: 0, left: t, top: o },
|
|
11
12
|
animate: {
|
|
12
13
|
opacity: [0, 1, 0],
|
|
13
|
-
scale: [0,
|
|
14
|
+
scale: [0, l, 0],
|
|
14
15
|
rotate: [75, 120, 150]
|
|
15
16
|
},
|
|
16
|
-
transition: { duration: 0.8, repeat: 1 / 0, delay:
|
|
17
|
+
transition: { duration: 0.8, repeat: 1 / 0, delay: c },
|
|
17
18
|
width: "21",
|
|
18
19
|
height: "21",
|
|
19
20
|
viewBox: "0 0 21 21",
|
|
@@ -25,46 +26,46 @@ const $ = ({ id: o, x: t, y: i, color: s, delay: l, scale: c }) => /* @__PURE__
|
|
|
25
26
|
}
|
|
26
27
|
)
|
|
27
28
|
},
|
|
28
|
-
|
|
29
|
-
),
|
|
30
|
-
children:
|
|
29
|
+
i
|
|
30
|
+
), I = ({
|
|
31
|
+
children: i,
|
|
31
32
|
colors: t = { first: "#9E7AFF", second: "#FE8BBB" },
|
|
32
|
-
className:
|
|
33
|
+
className: o,
|
|
33
34
|
sparklesCount: s = 10,
|
|
34
|
-
...
|
|
35
|
+
...c
|
|
35
36
|
}) => {
|
|
36
|
-
const [
|
|
37
|
-
return
|
|
37
|
+
const [l, p] = L([]);
|
|
38
|
+
return S(() => {
|
|
38
39
|
const a = () => {
|
|
39
|
-
const e = `${Math.random() * 100}%`, n = `${Math.random() * 100}%`, h = Math.random() > 0.5 ? t.first : t.second,
|
|
40
|
-
return { id: `${e}-${n}-${Date.now()}`, x: e, y: n, color: h, delay:
|
|
41
|
-
},
|
|
40
|
+
const e = `${Math.random() * 100}%`, n = `${Math.random() * 100}%`, h = Math.random() > 0.5 ? t.first : t.second, x = Math.random() * 2, C = Math.random() * 1 + 0.3, u = Math.random() * 10 + 5;
|
|
41
|
+
return { id: `${e}-${n}-${Date.now()}`, x: e, y: n, color: h, delay: x, scale: C, lifespan: u };
|
|
42
|
+
}, d = () => {
|
|
42
43
|
const e = Array.from({ length: s }, a);
|
|
43
|
-
|
|
44
|
+
p(e);
|
|
44
45
|
}, m = () => {
|
|
45
|
-
|
|
46
|
+
p(
|
|
46
47
|
(e) => e.map((n) => n.lifespan <= 0 ? a() : { ...n, lifespan: n.lifespan - 0.1 })
|
|
47
48
|
);
|
|
48
49
|
};
|
|
49
|
-
|
|
50
|
+
d();
|
|
50
51
|
const f = setInterval(m, 100);
|
|
51
52
|
return () => clearInterval(f);
|
|
52
53
|
}, [t.first, t.second, s]), /* @__PURE__ */ r(
|
|
53
54
|
"div",
|
|
54
55
|
{
|
|
55
|
-
className:
|
|
56
|
-
...
|
|
56
|
+
className: y("xiping-sparkles-text", o),
|
|
57
|
+
...c,
|
|
57
58
|
style: {
|
|
58
59
|
"--sparkles-first-color": `${t.first}`,
|
|
59
60
|
"--sparkles-second-color": `${t.second}`
|
|
60
61
|
},
|
|
61
|
-
children: /* @__PURE__ */
|
|
62
|
-
|
|
63
|
-
/* @__PURE__ */ r("strong", { children:
|
|
62
|
+
children: /* @__PURE__ */ g("span", { className: "xiping-sparkles-text-wrapper", children: [
|
|
63
|
+
l.map((a) => /* @__PURE__ */ r(M, { ...a }, a.id)),
|
|
64
|
+
/* @__PURE__ */ r("strong", { children: i })
|
|
64
65
|
] })
|
|
65
66
|
}
|
|
66
67
|
);
|
|
67
68
|
};
|
|
68
69
|
export {
|
|
69
|
-
|
|
70
|
+
I as SparklesText
|
|
70
71
|
};
|
|
@@ -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
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type SubtitleType = 'srt' | 'vtt';
|
|
3
|
+
export interface SubtitleData {
|
|
4
|
+
/** 字幕类型 */
|
|
5
|
+
type: SubtitleType;
|
|
6
|
+
/** 字幕内容字符串 */
|
|
7
|
+
content: string;
|
|
8
|
+
/** 可选的语言标识,用于多字幕对照时的标签显示 */
|
|
9
|
+
label?: string;
|
|
10
|
+
}
|
|
11
|
+
export type SubtitleDisplayMode = 'current' | 'lyrics';
|
|
12
|
+
export interface SubtitlePlayerProps {
|
|
13
|
+
/** 字幕数据,可以是单个字幕或多个字幕(用于对照) */
|
|
14
|
+
subtitles: SubtitleData | SubtitleData[];
|
|
15
|
+
/** 当前播放进度(秒数) */
|
|
16
|
+
currentTime: number;
|
|
17
|
+
/** 显示模式:'current' 只显示当前字幕,'lyrics' 显示全部字幕并高亮当前 */
|
|
18
|
+
mode?: SubtitleDisplayMode;
|
|
19
|
+
/** 自定义类名 */
|
|
20
|
+
className?: string;
|
|
21
|
+
/** 自定义样式 */
|
|
22
|
+
style?: React.CSSProperties;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 字幕播放组件
|
|
26
|
+
* 支持 SRT 和 WebVTT 格式,可以同时显示多个字幕进行对照
|
|
27
|
+
* 支持两种显示模式:当前模式(只显示当前字幕)和歌词模式(显示全部并高亮当前)
|
|
28
|
+
*/
|
|
29
|
+
export declare const SubtitlePlayer: React.FC<SubtitlePlayerProps>;
|
|
30
|
+
export default SubtitlePlayer;
|