@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.
Files changed (49) hide show
  1. package/dist/cjs/components/flip-text/FlipText.js +1 -1
  2. package/dist/cjs/components/gradient-text/index.d.ts +10 -0
  3. package/dist/cjs/components/gradient-text/index.js +1 -0
  4. package/dist/cjs/components/hyper-text/index.js +1 -1
  5. package/dist/cjs/components/image-viewer/ImageViewer.js +1 -1
  6. package/dist/cjs/components/shimmer-button/ShimmerButton.js +1 -1
  7. package/dist/cjs/components/shiny-button/ShinyButton.js +1 -1
  8. package/dist/cjs/components/sparkles-text/SparklesText.js +1 -1
  9. package/dist/cjs/components/split-text/SplitText.js +1 -1
  10. package/dist/cjs/components/subtitle-player/SubtitlePlayer.d.ts +30 -0
  11. package/dist/cjs/components/subtitle-player/SubtitlePlayer.js +3 -0
  12. package/dist/cjs/components/subtitle-player/index.d.ts +2 -0
  13. package/dist/cjs/components/txt-editor/TxtEditor.d.ts +5 -4
  14. package/dist/cjs/components/txt-editor/TxtEditor.js +32 -1
  15. package/dist/cjs/components/txt-reader/TxtReader.js +1 -1
  16. package/dist/cjs/components/txt-reader/index.module.css.js +1 -1
  17. package/dist/cjs/components/typing-animation/index.js +1 -1
  18. package/dist/cjs/components/variable-proximity/index.d.ts +25 -0
  19. package/dist/cjs/components/variable-proximity/index.js +1 -0
  20. package/dist/cjs/components/video-dialog/VideoDialog.js +1 -1
  21. package/dist/cjs/index.d.ts +3 -0
  22. package/dist/cjs/index.js +1 -1
  23. package/dist/cjs/react-components.css +1 -1
  24. package/dist/cjs/subtitle/lib/src/parser.js +5 -0
  25. package/dist/es/components/flip-text/FlipText.js +15 -14
  26. package/dist/es/components/gradient-text/index.d.ts +10 -0
  27. package/dist/es/components/gradient-text/index.js +22 -0
  28. package/dist/es/components/hyper-text/index.js +27 -25
  29. package/dist/es/components/image-viewer/ImageViewer.js +89 -65
  30. package/dist/es/components/shimmer-button/ShimmerButton.js +29 -62
  31. package/dist/es/components/shiny-button/ShinyButton.js +15 -17
  32. package/dist/es/components/sparkles-text/SparklesText.js +30 -29
  33. package/dist/es/components/split-text/SplitText.js +37 -35
  34. package/dist/es/components/subtitle-player/SubtitlePlayer.d.ts +30 -0
  35. package/dist/es/components/subtitle-player/SubtitlePlayer.js +103 -0
  36. package/dist/es/components/subtitle-player/index.d.ts +2 -0
  37. package/dist/es/components/txt-editor/TxtEditor.d.ts +5 -4
  38. package/dist/es/components/txt-editor/TxtEditor.js +102 -43
  39. package/dist/es/components/txt-reader/TxtReader.js +48 -55
  40. package/dist/es/components/txt-reader/index.module.css.js +6 -2
  41. package/dist/es/components/typing-animation/index.js +11 -13
  42. package/dist/es/components/variable-proximity/index.d.ts +25 -0
  43. package/dist/es/components/variable-proximity/index.js +212 -0
  44. package/dist/es/components/video-dialog/VideoDialog.js +35 -48
  45. package/dist/es/index.d.ts +3 -0
  46. package/dist/es/index.js +60 -54
  47. package/dist/es/react-components.css +1 -1
  48. package/dist/es/subtitle/lib/src/parser.js +56 -0
  49. package/package.json +16 -12
@@ -1,94 +1,118 @@
1
1
  "use client";
2
- import { jsx as e, jsxs as c } from "react/jsx-runtime";
3
- import { Modal as D, ModalContent as O, Spinner as S } from "@heroui/react";
4
- import U from "../pinch-content/PinchContent.js";
5
- import A from "./ImageThumbnails.js";
6
- import { useState as h, useEffect as P } from "react";
7
- import T from "clsx";
8
- import { Download as B, X as V } from "lucide-react";
9
- import { AnimatePresence as W, motion as X } from "motion/react";
10
- import { cn as l } from "../../utils/utils.js";
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 u = (a) => {
13
- a.target.closest(".xiping-main-content") && a.preventDefault();
14
- }, $ = (a) => {
12
+ const C = (c) => {
13
+ c.target.closest(".xiping-main-content") && c.preventDefault();
14
+ }, ne = (c) => {
15
15
  const {
16
- isOpen: n,
17
- onClose: f,
18
- imgSrc: s,
19
- thumbnailImages: x,
20
- canDownload: w = !1,
21
- wrapperClassName: v,
22
- closeClassName: C,
23
- downloadClassName: N,
24
- toolWrapperClassName: I,
25
- initialIndex: b = 0
26
- } = a, t = Array.isArray(s) ? s : [s], y = x || t, L = Math.max(
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(b, t.length - 1)
29
- ), [i, E] = h(L), [M, r] = h(!0), m = () => {
30
- r(!0), f();
31
- }, R = async () => {
32
- const d = t[i];
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 z = await (await fetch(d)).blob(), g = window.URL.createObjectURL(z), o = document.createElement("a");
35
- o.href = g, o.download = d.split("/").pop() || "image", document.body.appendChild(o), o.click(), window.URL.revokeObjectURL(g), document.body.removeChild(o);
36
- } catch (p) {
37
- console.error("Error downloading image:", p);
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
- r(!1);
41
- }, k = () => {
42
- r(!1);
42
+ p(!1);
43
43
  };
44
- return P(() => {
45
- if (n)
46
- return document.addEventListener("touchmove", u, {
44
+ x(() => {
45
+ if (a)
46
+ return document.addEventListener("touchmove", C, {
47
47
  passive: !1
48
48
  }), () => {
49
- document.removeEventListener("touchmove", u);
49
+ document.removeEventListener("touchmove", C);
50
50
  };
51
- }, [n]), /* @__PURE__ */ e(
52
- D,
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: n,
78
+ isOpen: a,
55
79
  size: "full",
56
80
  onClose: m,
57
81
  classNames: {
58
- wrapper: T(v)
82
+ wrapper: X(I)
59
83
  },
60
84
  className: "xiping-modal-overlay",
61
85
  hideCloseButton: !0,
62
86
  portalContainer: document.body,
63
- children: /* @__PURE__ */ e(O, { className: "xiping-modal-content", children: /* @__PURE__ */ c("div", { className: "xiping-wrapper", children: [
64
- /* @__PURE__ */ c("div", { className: l("xiping-tool-wrapper", I), children: [
65
- w && /* @__PURE__ */ e(
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: l("xiping-download-icon", N),
70
- onClick: R
93
+ className: f("xiping-download-icon", L),
94
+ onClick: T
71
95
  }
72
96
  ),
73
- /* @__PURE__ */ e(
74
- V,
97
+ /* @__PURE__ */ n(
98
+ K,
75
99
  {
76
100
  size: 24,
77
- className: l("xiping-close-icon", C),
101
+ className: f("xiping-close-icon", E),
78
102
  onClick: m
79
103
  }
80
104
  )
81
105
  ] }),
82
- /* @__PURE__ */ c("div", { className: "xiping-main-content", children: [
83
- /* @__PURE__ */ e(U, { canRotate: !1, className: "xiping-pinch-content", children: /* @__PURE__ */ e(W, { mode: "wait", children: /* @__PURE__ */ e(
84
- X.img,
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: t[i],
111
+ src: o[l],
88
112
  alt: "",
89
113
  className: "xiping-image",
90
- onLoad: j,
91
- onError: k,
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
- i
124
+ l
101
125
  ) }) }),
102
- M && /* @__PURE__ */ e("div", { className: "xiping-loading", children: /* @__PURE__ */ e(S, { color: "white", size: "lg" }) })
126
+ M && /* @__PURE__ */ n("div", { className: "xiping-loading", children: /* @__PURE__ */ n(S, { color: "white", size: "lg" }) })
103
127
  ] }),
104
- /* @__PURE__ */ e(
105
- A,
128
+ /* @__PURE__ */ n(
129
+ V,
106
130
  {
107
- images: y,
108
- currentIndex: i,
109
- onImageSelect: E
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
- $ as default
141
+ ne as default
118
142
  };
@@ -1,75 +1,42 @@
1
- import { jsxs as l, jsx as r } from "react/jsx-runtime";
2
- import p from "react";
3
- import { cn as e } from "../../utils/utils.js";
4
- const m = p.forwardRef(
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: a = "#ffffff",
7
- shimmerSize: t = "0.05em",
8
- shimmerDuration: s = "3s",
9
- borderRadius: i = "100px",
10
- background: o = "rgba(0, 0, 0, 1)",
11
- className: n,
12
- children: d,
13
- ...f
14
- }, u) => /* @__PURE__ */ l(
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": a,
20
- "--radius": i,
21
- "--speed": s,
22
- "--cut": t,
23
- "--bg": o
20
+ "--shimmer-color": r,
21
+ "--radius": s,
22
+ "--speed": m,
23
+ "--cut": e,
24
+ "--bg": t
24
25
  },
25
- className: e(
26
- "group relative z-0 flex cursor-pointer items-center justify-center overflow-hidden whitespace-nowrap border border-white/10 px-6 py-3 text-white [background:var(--bg)] [border-radius:var(--radius)] dark:text-black",
27
- "transform-gpu transition-transform duration-300 ease-in-out active:translate-y-px",
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__ */ r(
34
- "div",
35
- {
36
- className: e(
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
- m.displayName = "ShimmerButton";
38
+ l.displayName = "ShimmerButton";
72
39
  export {
73
- m as ShimmerButton,
74
- m as default
40
+ l as ShimmerButton,
41
+ l as default
75
42
  };
@@ -1,9 +1,10 @@
1
1
  "use client";
2
- import { jsxs as n, jsx as r } from "react/jsx-runtime";
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 l from "react";
6
- const p = {
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
- }, c = l.forwardRef(({ children: a, className: e, ...t }, i) => /* @__PURE__ */ n(
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
- "relative cursor-pointer rounded-lg px-6 py-2 font-medium backdrop-blur-xl border transition-shadow duration-300 ease-in-out hover:shadow dark:bg-[radial-gradient(circle_at_50%_0%,var(--primary)/10%_0%,transparent_60%)] dark:hover:shadow-[0_0_20px_var(--primary)/10%]",
31
- e
32
- ),
33
- ...p,
34
- ...t,
30
+ className: s("xiping-shiny-button", e),
31
+ ...c,
32
+ ...n,
35
33
  children: [
36
- /* @__PURE__ */ r(
34
+ /* @__PURE__ */ a(
37
35
  "span",
38
36
  {
39
- className: "relative block size-full text-sm uppercase tracking-wide text-[rgb(0,0,0,65%)] dark:font-light dark:text-[rgb(255,255,255,90%)]",
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: a
41
+ children: r
44
42
  }
45
43
  ),
46
- /* @__PURE__ */ r(
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: "absolute inset-0 z-10 block rounded-[inherit] p-px"
52
+ className: "xiping-shiny-button-border"
55
53
  }
56
54
  )
57
55
  ]
58
56
  }
59
57
  ));
60
- c.displayName = "ShinyButton";
58
+ l.displayName = "ShinyButton";
61
59
  export {
62
- c as ShinyButton
60
+ l as ShinyButton
63
61
  };
@@ -1,19 +1,20 @@
1
1
  "use client";
2
- import { jsx as r, jsxs as x } from "react/jsx-runtime";
3
- import { motion as L } from "motion/react";
4
- import { useState as S, useEffect as y } from "react";
5
- import { cn as M } from "../../utils/utils.js";
6
- const $ = ({ id: o, x: t, y: i, color: s, delay: l, scale: c }) => /* @__PURE__ */ r(
7
- L.svg,
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: "pointer-events-none absolute z-20",
10
- initial: { opacity: 0, left: t, top: i },
10
+ className: "xiping-sparkle",
11
+ initial: { opacity: 0, left: t, top: o },
11
12
  animate: {
12
13
  opacity: [0, 1, 0],
13
- scale: [0, c, 0],
14
+ scale: [0, l, 0],
14
15
  rotate: [75, 120, 150]
15
16
  },
16
- transition: { duration: 0.8, repeat: 1 / 0, delay: l },
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
- o
29
- ), E = ({
30
- children: o,
29
+ i
30
+ ), I = ({
31
+ children: i,
31
32
  colors: t = { first: "#9E7AFF", second: "#FE8BBB" },
32
- className: i,
33
+ className: o,
33
34
  sparklesCount: s = 10,
34
- ...l
35
+ ...c
35
36
  }) => {
36
- const [c, d] = S([]);
37
- return y(() => {
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, u = Math.random() * 2, C = Math.random() * 1 + 0.3, v = Math.random() * 10 + 5;
40
- return { id: `${e}-${n}-${Date.now()}`, x: e, y: n, color: h, delay: u, scale: C, lifespan: v };
41
- }, p = () => {
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
- d(e);
44
+ p(e);
44
45
  }, m = () => {
45
- d(
46
+ p(
46
47
  (e) => e.map((n) => n.lifespan <= 0 ? a() : { ...n, lifespan: n.lifespan - 0.1 })
47
48
  );
48
49
  };
49
- p();
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: M("text-6xl font-bold", i),
56
- ...l,
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__ */ x("span", { className: "relative inline-block", children: [
62
- c.map((a) => /* @__PURE__ */ r($, { ...a }, a.id)),
63
- /* @__PURE__ */ r("strong", { children: o })
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
- E as SparklesText
70
+ I as SparklesText
70
71
  };
@@ -1,35 +1,37 @@
1
1
  import { jsx as E } from "react/jsx-runtime";
2
- import { useRef as g, useEffect as F } from "react";
3
- import { gsap as s } from "gsap";
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
- s.registerPlugin(N, S);
7
- const W = ({
8
- text: i,
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: m = 100,
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: a = { opacity: 1, y: 0 },
17
+ to: c = { opacity: 1, y: 0 },
16
18
  threshold: x = 0.1,
17
- rootMargin: $ = "-100px",
19
+ rootMargin: y = "-100px",
18
20
  textAlign: R = "center",
19
- onLetterAnimationComplete: b
21
+ onLetterAnimationComplete: T
20
22
  }) => {
21
- const c = g(null), k = g(!1), o = g(null);
23
+ const a = m(null), $ = m(!1), o = m(null);
22
24
  return F(() => {
23
- if (typeof window > "u" || !c.current || !i) return;
24
- const u = c.current;
25
- k.current = !1;
26
- const y = n === "lines";
27
- y && (u.style.position = "relative");
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(u, {
32
+ r = new S(p, {
31
33
  type: n,
32
- absolute: y,
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, l = /^(-?\d+(?:\.\d+)?)(px|em|rem|%)?$/.exec($), f = l ? parseFloat(l[1]) : 0, T = l && l[2] || "px", P = f < 0 ? `-=${Math.abs(f)}${T}` : `+=${f}${T}`, D = `top ${v}%${P}`, p = s.timeline({
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: u,
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
- k.current = !0, s.set(e, {
73
- ...a,
74
+ $.current = !0, i.set(e, {
75
+ ...c,
74
76
  clearProps: "willChange",
75
77
  immediateRender: !0
76
- }), b?.();
78
+ }), T?.();
77
79
  }
78
80
  });
79
- return p.set(e, { ...w, immediateRender: !1, force3D: !0 }), p.to(e, {
80
- ...a,
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: m / 1e3,
85
+ stagger: g / 1e3,
84
86
  force3D: !0
85
87
  }), () => {
86
- p.kill(), o.current && (o.current.kill(), o.current = null), s.killTweensOf(e), r && r.revert();
88
+ f.kill(), o.current && (o.current.kill(), o.current = null), i.killTweensOf(e), r && r.revert();
87
89
  };
88
90
  }, [
89
- i,
90
- m,
91
+ l,
92
+ g,
91
93
  d,
92
94
  h,
93
95
  n,
94
96
  w,
95
- a,
97
+ c,
96
98
  x,
97
- $,
98
- b
99
+ y,
100
+ T
99
101
  ]), /* @__PURE__ */ E(
100
102
  "p",
101
103
  {
102
- ref: c,
103
- className: `split-parent overflow-hidden inline-block whitespace-normal ${C}`,
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: i
110
+ children: l
109
111
  }
110
112
  );
111
113
  };
112
114
  export {
113
- W as SplitText
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;