@x-plat/design-system 0.19.0 → 0.21.0
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/chunk-2EGVOUGV.cjs +93 -0
- package/dist/chunk-2T3BVV7R.js +0 -0
- package/dist/chunk-3FYYFDKQ.js +159 -0
- package/dist/chunk-3M3GFSHJ.js +67 -0
- package/dist/chunk-3WBHUFOA.cjs +48 -0
- package/dist/chunk-3XYYZQR5.cjs +22 -0
- package/dist/chunk-4EF7NVAL.js +67 -0
- package/dist/chunk-4ISERXK2.cjs +1 -0
- package/dist/chunk-4KYHHJ6Z.cjs +250 -0
- package/dist/chunk-4NSRDRXC.cjs +70 -0
- package/dist/chunk-4OXMRSVE.cjs +99 -0
- package/dist/chunk-55EPYLXN.js +30 -0
- package/dist/chunk-5CE3ADO5.js +254 -0
- package/dist/chunk-5F6Y2JD6.cjs +1 -0
- package/dist/chunk-5FMTMXSP.cjs +127 -0
- package/dist/chunk-5POCKDDY.js +36 -0
- package/dist/chunk-5VDI56BV.js +33 -0
- package/dist/chunk-5WLBUPSK.js +77 -0
- package/dist/chunk-5WNNWQHD.cjs +272 -0
- package/dist/chunk-66STZB6I.cjs +404 -0
- package/dist/chunk-6AIKCZN7.js +1455 -0
- package/dist/chunk-6IUJJUVP.js +18 -0
- package/dist/chunk-6P2B3ZGP.js +79 -0
- package/dist/chunk-764ILIDG.cjs +22 -0
- package/dist/chunk-7B44DWC4.js +0 -0
- package/dist/chunk-7BE6ETFY.js +18 -0
- package/dist/chunk-7BSUS5A4.js +97 -0
- package/dist/chunk-7RPWCDEW.cjs +20 -0
- package/dist/chunk-7ULXHGLO.cjs +77 -0
- package/dist/chunk-7YOI5XOW.js +55 -0
- package/dist/chunk-AFVTM5CP.js +0 -0
- package/dist/chunk-AN2WSL3B.cjs +1 -0
- package/dist/chunk-AT5Y5GLS.cjs +118 -0
- package/dist/chunk-AWPO2FI7.js +404 -0
- package/dist/chunk-BGXHIDUR.js +103 -0
- package/dist/chunk-BPZXL5TP.js +99 -0
- package/dist/chunk-BRTS5GWV.js +275 -0
- package/dist/chunk-BS3MLZCK.cjs +97 -0
- package/dist/chunk-BSPYYE2U.js +36 -0
- package/dist/chunk-BWJAEB42.js +48 -0
- package/dist/chunk-C4RMTISI.cjs +18 -0
- package/dist/chunk-C6M4XVR7.cjs +36 -0
- package/dist/chunk-CGC4D5MP.cjs +89 -0
- package/dist/chunk-CIRQYSQW.js +70 -0
- package/dist/chunk-CLOTWJNP.cjs +310 -0
- package/dist/chunk-CS7ZY35M.cjs +49 -0
- package/dist/chunk-CUV4RLDE.js +89 -0
- package/dist/chunk-CZAMLFSE.cjs +275 -0
- package/dist/chunk-D7QZLJ3Z.cjs +18 -0
- package/dist/chunk-DMSAAZ3M.cjs +92 -0
- package/dist/chunk-DUIZC7VJ.cjs +36 -0
- package/dist/chunk-DVBF4BDH.js +43 -0
- package/dist/chunk-EETYMP6K.cjs +584 -0
- package/dist/chunk-EFQL7JPX.js +0 -0
- package/dist/chunk-EFU7IAF5.cjs +12 -0
- package/dist/chunk-F3M2H5EX.cjs +79 -0
- package/dist/chunk-F436V2SX.cjs +254 -0
- package/dist/chunk-F664X2OY.js +250 -0
- package/dist/chunk-FF7ELUQW.cjs +1 -0
- package/dist/chunk-G3HE4S3Q.cjs +296 -0
- package/dist/chunk-GOPD5KUK.js +23 -0
- package/dist/chunk-GYTB24V6.cjs +107 -0
- package/dist/chunk-GZ657SGO.js +310 -0
- package/dist/chunk-H2QN65L6.cjs +1 -0
- package/dist/chunk-H6WUT7CK.js +22 -0
- package/dist/chunk-H76OQ75T.js +49 -0
- package/dist/chunk-HA3XONYI.js +18 -0
- package/dist/chunk-HF3UFXEU.js +296 -0
- package/dist/chunk-HGA47QVV.cjs +55 -0
- package/dist/chunk-HHPPAMXF.cjs +674 -0
- package/dist/chunk-HLV2XIE2.cjs +385 -0
- package/dist/chunk-HNQGIL45.cjs +96 -0
- package/dist/chunk-HQ37R7T3.js +53 -0
- package/dist/chunk-HXUGW4RR.js +187 -0
- package/dist/chunk-HYPRLWD3.js +272 -0
- package/dist/chunk-I7TLJUTP.cjs +6 -0
- package/dist/chunk-ICTWDTKC.cjs +1 -0
- package/dist/chunk-IPYKHDP4.cjs +187 -0
- package/dist/chunk-IRKREQ2X.cjs +18 -0
- package/dist/chunk-IVJJBMRY.js +92 -0
- package/dist/chunk-JPVIVOFG.js +26 -0
- package/dist/chunk-JYNBNSNF.js +151 -0
- package/dist/chunk-JZC3BXAC.js +93 -0
- package/dist/chunk-K5XPQWXN.cjs +92 -0
- package/dist/chunk-KQ3GOMHL.js +31 -0
- package/dist/chunk-KUJH72U6.cjs +159 -0
- package/dist/chunk-KVUXLC6M.cjs +479 -0
- package/dist/chunk-KZOJN57Q.js +19 -0
- package/dist/chunk-L3XPL4NP.cjs +53 -0
- package/dist/chunk-LOEMSXYB.js +0 -0
- package/dist/chunk-LU4KBPNG.cjs +23 -0
- package/dist/chunk-MWWWPQDB.js +26 -0
- package/dist/chunk-NCBB3WUJ.js +562 -0
- package/dist/chunk-NGCZTZST.cjs +562 -0
- package/dist/chunk-NSDKALIS.cjs +67 -0
- package/dist/chunk-NZHCRLNB.cjs +26 -0
- package/dist/chunk-OL4NANHB.js +0 -0
- package/dist/chunk-OTJRNKLR.js +96 -0
- package/dist/chunk-OWWFKTSK.js +0 -0
- package/dist/chunk-P2E3PB62.cjs +99 -0
- package/dist/chunk-P2QVFR7S.js +20 -0
- package/dist/chunk-P6ZGIYY7.cjs +18 -0
- package/dist/chunk-PFGSJJRY.cjs +19 -0
- package/dist/chunk-PNIUW7AJ.cjs +32 -0
- package/dist/chunk-Q2M2ONGO.js +70 -0
- package/dist/chunk-Q4PGP5KE.cjs +562 -0
- package/dist/chunk-QAI2YQPY.cjs +51 -0
- package/dist/chunk-QCD7UEZ3.cjs +59 -0
- package/dist/chunk-QEZ4R3SK.js +6 -0
- package/dist/chunk-QKDCPM2D.cjs +23 -0
- package/dist/chunk-QRGG3V7W.cjs +59 -0
- package/dist/chunk-QURIHUEC.js +107 -0
- package/dist/chunk-QY742LWN.js +30 -0
- package/dist/chunk-QYMRGYTN.js +127 -0
- package/dist/chunk-RLKJ2RZG.js +23 -0
- package/dist/chunk-RRR5BUOM.cjs +30 -0
- package/dist/chunk-RU3FCVXM.cjs +1 -0
- package/dist/chunk-RYTDVTV2.js +32 -0
- package/dist/chunk-RYYGUYDE.js +92 -0
- package/dist/chunk-SGLP4U3Y.cjs +67 -0
- package/dist/chunk-SJC543ZK.js +71 -0
- package/dist/chunk-SLYQK4SC.js +20 -0
- package/dist/chunk-SMLCOMLS.js +2888 -0
- package/dist/chunk-SNMOPLMH.cjs +372 -0
- package/dist/chunk-TRJUJYW7.cjs +151 -0
- package/dist/chunk-TTY5PE3P.js +30 -0
- package/dist/chunk-TXARYG3J.js +22 -0
- package/dist/chunk-TYXJU4EF.js +18 -0
- package/dist/chunk-U3PC7FYZ.cjs +26 -0
- package/dist/chunk-U67JM2WL.cjs +34 -0
- package/dist/chunk-UARGO5UG.js +59 -0
- package/dist/chunk-UCYE3H3F.cjs +43 -0
- package/dist/chunk-UGEGN35F.js +118 -0
- package/dist/chunk-UHUA3GQC.cjs +30 -0
- package/dist/chunk-UJQN477L.js +59 -0
- package/dist/chunk-UMX7DTFZ.cjs +70 -0
- package/dist/chunk-UT42P54P.js +372 -0
- package/dist/chunk-V76ZRGHQ.cjs +1 -0
- package/dist/chunk-VCIK366Y.cjs +1455 -0
- package/dist/chunk-VMA74ABT.cjs +137 -0
- package/dist/chunk-VSA62N2O.js +12 -0
- package/dist/chunk-WDAFLVQK.js +479 -0
- package/dist/chunk-WHMLMAMO.js +674 -0
- package/dist/chunk-WNBLKKLM.js +0 -0
- package/dist/chunk-WQ2GY7F3.js +46 -0
- package/dist/chunk-WRLCCK3M.cjs +30 -0
- package/dist/chunk-WVCZIOLY.js +562 -0
- package/dist/chunk-WZLGJQLW.js +385 -0
- package/dist/chunk-XB6FEBK6.js +34 -0
- package/dist/chunk-XMERDSRE.js +75 -0
- package/dist/chunk-XMLFKZYY.js +137 -0
- package/dist/chunk-XMM52J3T.js +584 -0
- package/dist/chunk-XZ7C5CGB.cjs +103 -0
- package/dist/chunk-YGFBAOKX.js +51 -0
- package/dist/chunk-YIN552MF.cjs +20 -0
- package/dist/chunk-YLC42E65.cjs +31 -0
- package/dist/chunk-YOTXRYJL.cjs +46 -0
- package/dist/chunk-ZAUGJZK7.js +99 -0
- package/dist/chunk-ZIZOQTDG.cjs +75 -0
- package/dist/chunk-ZMSV5VZI.cjs +2888 -0
- package/dist/chunk-ZN6MLZAE.cjs +71 -0
- package/dist/chunk-ZNCT6HXA.cjs +33 -0
- package/dist/components/Accordion/index.cjs +5 -1036
- package/dist/components/Accordion/index.js +5 -999
- package/dist/components/Alert/index.cjs +4 -69
- package/dist/components/Alert/index.js +4 -42
- package/dist/components/AutoResizeTextArea/index.cjs +6 -260
- package/dist/components/AutoResizeTextArea/index.js +6 -223
- package/dist/components/Avatar/index.cjs +4 -65
- package/dist/components/Avatar/index.js +4 -38
- package/dist/components/Badge/index.cjs +6 -69
- package/dist/components/Badge/index.js +5 -40
- package/dist/components/Box/index.cjs +4 -58
- package/dist/components/Box/index.js +4 -31
- package/dist/components/Breadcrumb/index.cjs +4 -42
- package/dist/components/Breadcrumb/index.js +3 -14
- package/dist/components/Button/index.cjs +5 -65
- package/dist/components/Button/index.js +5 -38
- package/dist/components/Calendar/index.cjs +6 -1317
- package/dist/components/Calendar/index.js +10 -1281
- package/dist/components/CardTab/index.cjs +4 -120
- package/dist/components/CardTab/index.js +4 -83
- package/dist/components/Chart/index.cjs +5 -708
- package/dist/components/Chart/index.js +4 -670
- package/dist/components/ChatInput/index.cjs +9 -390
- package/dist/components/ChatInput/index.js +9 -353
- package/dist/components/CheckBox/index.cjs +20 -1125
- package/dist/components/CheckBox/index.js +17 -1095
- package/dist/components/Chip/index.cjs +5 -55
- package/dist/components/Chip/index.js +5 -28
- package/dist/components/DatePicker/index.cjs +16 -2136
- package/dist/components/DatePicker/index.js +19 -2099
- package/dist/components/Divider/index.cjs +4 -58
- package/dist/components/Divider/index.js +4 -31
- package/dist/components/Drawer/index.cjs +5 -190
- package/dist/components/Drawer/index.js +5 -153
- package/dist/components/Dropdown/index.cjs +7 -375
- package/dist/components/Dropdown/index.js +7 -338
- package/dist/components/Editor/index.cjs +6 -1486
- package/dist/components/Editor/index.css +53 -0
- package/dist/components/Editor/index.d.cts +13 -0
- package/dist/components/Editor/index.d.ts +13 -0
- package/dist/components/Editor/index.js +6 -1453
- package/dist/components/EmptyState/index.cjs +4 -42
- package/dist/components/EmptyState/index.js +3 -14
- package/dist/components/FieldMessage/index.cjs +7 -182
- package/dist/components/FieldMessage/index.js +8 -154
- package/dist/components/FileUpload/index.cjs +7 -1171
- package/dist/components/FileUpload/index.js +7 -1134
- package/dist/components/HtmlTypeWriter/index.cjs +3 -171
- package/dist/components/HtmlTypeWriter/index.js +3 -133
- package/dist/components/IconButton/index.cjs +4 -65
- package/dist/components/IconButton/index.js +4 -38
- package/dist/components/ImageSelector/index.cjs +8 -1214
- package/dist/components/ImageSelector/index.js +8 -1177
- package/dist/components/Input/index.cjs +7 -429
- package/dist/components/Input/index.js +8 -392
- package/dist/components/Link/index.cjs +4 -61
- package/dist/components/Link/index.js +4 -34
- package/dist/components/LinkButton/index.cjs +5 -61
- package/dist/components/LinkButton/index.js +5 -34
- package/dist/components/Modal/index.cjs +5 -190
- package/dist/components/Modal/index.js +5 -153
- package/dist/components/NotificationBadge/index.cjs +5 -68
- package/dist/components/NotificationBadge/index.js +5 -40
- package/dist/components/Pagination/index.cjs +6 -1034
- package/dist/components/Pagination/index.js +6 -1007
- package/dist/components/PopOver/index.cjs +7 -363
- package/dist/components/PopOver/index.js +7 -326
- package/dist/components/Progress/index.cjs +5 -84
- package/dist/components/Progress/index.js +5 -57
- package/dist/components/Radio/index.cjs +7 -274
- package/dist/components/Radio/index.js +8 -237
- package/dist/components/Select/index.cjs +10 -1577
- package/dist/components/Select/index.js +11 -1540
- package/dist/components/Skeleton/index.cjs +4 -71
- package/dist/components/Skeleton/index.js +4 -44
- package/dist/components/Spinner/index.cjs +5 -88
- package/dist/components/Spinner/index.js +5 -61
- package/dist/components/Stat/index.cjs +5 -81
- package/dist/components/Stat/index.js +5 -54
- package/dist/components/Steps/index.cjs +7 -968
- package/dist/components/Steps/index.js +7 -941
- package/dist/components/Swiper/index.cjs +4 -357
- package/dist/components/Swiper/index.js +4 -320
- package/dist/components/Switch/index.cjs +7 -252
- package/dist/components/Switch/index.js +7 -215
- package/dist/components/Tab/index.cjs +4 -144
- package/dist/components/Tab/index.js +4 -107
- package/dist/components/Table/index.cjs +4 -310
- package/dist/components/Table/index.css +31 -5
- package/dist/components/Table/index.js +8 -273
- package/dist/components/Tag/index.cjs +6 -969
- package/dist/components/Tag/index.js +6 -942
- package/dist/components/TextArea/index.cjs +6 -229
- package/dist/components/TextArea/index.js +6 -192
- package/dist/components/TimePicker/index.cjs +9 -579
- package/dist/components/TimePicker/index.js +9 -542
- package/dist/components/Toast/index.cjs +5 -146
- package/dist/components/Toast/index.js +5 -108
- package/dist/components/ToggleChip/index.cjs +5 -66
- package/dist/components/ToggleChip/index.js +5 -39
- package/dist/components/Tooltip/index.cjs +6 -204
- package/dist/components/Tooltip/index.js +6 -167
- package/dist/components/Tour/index.cjs +6 -414
- package/dist/components/Tour/index.js +6 -377
- package/dist/components/Video/index.cjs +7 -796
- package/dist/components/Video/index.js +7 -759
- package/dist/components/index.cjs +140 -8315
- package/dist/components/index.css +31 -5
- package/dist/components/index.js +190 -8261
- package/dist/index.cjs +903 -13291
- package/dist/index.css +31 -5
- package/dist/index.js +524 -12499
- package/dist/layout/Grid/FullGrid/index.cjs +4 -46
- package/dist/layout/Grid/FullGrid/index.js +3 -18
- package/dist/layout/Grid/FullScreen/index.cjs +4 -46
- package/dist/layout/Grid/FullScreen/index.js +3 -18
- package/dist/layout/Grid/Item/index.cjs +5 -68
- package/dist/layout/Grid/Item/index.js +5 -41
- package/dist/layout/Grid/index.cjs +14 -109
- package/dist/layout/Grid/index.js +14 -79
- package/dist/layout/Header/index.cjs +4 -44
- package/dist/layout/Header/index.js +3 -16
- package/dist/layout/Layout/index.cjs +4 -42
- package/dist/layout/Layout/index.js +3 -14
- package/dist/layout/SideBar/index.cjs +6 -96
- package/dist/layout/SideBar/index.js +6 -57
- package/dist/layout/index.cjs +38 -209
- package/dist/layout/index.js +27 -153
- package/dist/tokens/index.cjs +627 -6119
- package/dist/tokens/index.js +324 -5489
- package/guidelines/components/editor.md +3 -0
- package/guidelines/components/table.md +23 -0
- package/guidelines/setup.md +7 -0
- package/package.json +6 -3
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MaximizeIcon_default,
|
|
3
|
+
MinimizeIcon_default,
|
|
4
|
+
TypeIcon_default
|
|
5
|
+
} from "./chunk-AWPO2FI7.js";
|
|
6
|
+
import {
|
|
7
|
+
PauseIcon_default,
|
|
8
|
+
PlayCircleIcon_default,
|
|
9
|
+
PlayIcon_default,
|
|
10
|
+
Volume2Icon_default,
|
|
11
|
+
VolumeIcon_default,
|
|
12
|
+
VolumeXIcon_default
|
|
13
|
+
} from "./chunk-WVCZIOLY.js";
|
|
14
|
+
import {
|
|
15
|
+
DownloadIcon_default
|
|
16
|
+
} from "./chunk-NCBB3WUJ.js";
|
|
17
|
+
import {
|
|
18
|
+
clsx_default
|
|
19
|
+
} from "./chunk-KZOJN57Q.js";
|
|
20
|
+
|
|
21
|
+
// src/components/Video/Video.tsx
|
|
22
|
+
import React from "react";
|
|
23
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
24
|
+
var PipIcon = () => /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
25
|
+
/* @__PURE__ */ jsx("rect", { x: "3", y: "5", width: "18", height: "14", rx: "2" }),
|
|
26
|
+
/* @__PURE__ */ jsx("rect", { x: "12", y: "11", width: "7", height: "6", rx: "1", fill: "currentColor" })
|
|
27
|
+
] });
|
|
28
|
+
var formatTime = (sec) => {
|
|
29
|
+
if (!Number.isFinite(sec) || sec < 0) return "0:00";
|
|
30
|
+
const m = Math.floor(sec / 60);
|
|
31
|
+
const s = Math.floor(sec % 60);
|
|
32
|
+
return `${m}:${s.toString().padStart(2, "0")}`;
|
|
33
|
+
};
|
|
34
|
+
var Video = React.forwardRef((props, ref) => {
|
|
35
|
+
const {
|
|
36
|
+
src,
|
|
37
|
+
poster,
|
|
38
|
+
autoPlay,
|
|
39
|
+
muted,
|
|
40
|
+
loop,
|
|
41
|
+
playsInline,
|
|
42
|
+
showControls = true,
|
|
43
|
+
showCenterPlay = true,
|
|
44
|
+
playbackRates,
|
|
45
|
+
showCaptions = false,
|
|
46
|
+
showPip = false,
|
|
47
|
+
showDownload = false,
|
|
48
|
+
downloadFileName,
|
|
49
|
+
onPlay,
|
|
50
|
+
onPause,
|
|
51
|
+
onTimeUpdate,
|
|
52
|
+
onVolumeChange,
|
|
53
|
+
onLoadedMetadata,
|
|
54
|
+
onRateChange,
|
|
55
|
+
children,
|
|
56
|
+
...rest
|
|
57
|
+
} = props;
|
|
58
|
+
const containerRef = React.useRef(null);
|
|
59
|
+
const videoRef = React.useRef(null);
|
|
60
|
+
const [isPlaying, setIsPlaying] = React.useState(Boolean(autoPlay));
|
|
61
|
+
const [isLoaded, setIsLoaded] = React.useState(false);
|
|
62
|
+
const [currentTime, setCurrentTime] = React.useState(0);
|
|
63
|
+
const [duration, setDuration] = React.useState(0);
|
|
64
|
+
const [buffered, setBuffered] = React.useState(0);
|
|
65
|
+
const [volume, setVolume] = React.useState(1);
|
|
66
|
+
const [isMuted, setIsMuted] = React.useState(Boolean(muted));
|
|
67
|
+
const [isFullscreen, setIsFullscreen] = React.useState(false);
|
|
68
|
+
const [playbackRate, setPlaybackRate] = React.useState(1);
|
|
69
|
+
const [rateMenuOpen, setRateMenuOpen] = React.useState(false);
|
|
70
|
+
const [captionsOn, setCaptionsOn] = React.useState(false);
|
|
71
|
+
const [isPip, setIsPip] = React.useState(false);
|
|
72
|
+
const setRefs = React.useCallback(
|
|
73
|
+
(el) => {
|
|
74
|
+
videoRef.current = el;
|
|
75
|
+
if (typeof ref === "function") ref(el);
|
|
76
|
+
else if (ref) ref.current = el;
|
|
77
|
+
},
|
|
78
|
+
[ref]
|
|
79
|
+
);
|
|
80
|
+
React.useEffect(() => {
|
|
81
|
+
const onFsChange = () => {
|
|
82
|
+
setIsFullscreen(document.fullscreenElement === containerRef.current);
|
|
83
|
+
};
|
|
84
|
+
document.addEventListener("fullscreenchange", onFsChange);
|
|
85
|
+
return () => document.removeEventListener("fullscreenchange", onFsChange);
|
|
86
|
+
}, []);
|
|
87
|
+
React.useEffect(() => {
|
|
88
|
+
const v = videoRef.current;
|
|
89
|
+
if (!v) return;
|
|
90
|
+
const onEnter = () => setIsPip(true);
|
|
91
|
+
const onLeave = () => setIsPip(false);
|
|
92
|
+
v.addEventListener("enterpictureinpicture", onEnter);
|
|
93
|
+
v.addEventListener("leavepictureinpicture", onLeave);
|
|
94
|
+
return () => {
|
|
95
|
+
v.removeEventListener("enterpictureinpicture", onEnter);
|
|
96
|
+
v.removeEventListener("leavepictureinpicture", onLeave);
|
|
97
|
+
};
|
|
98
|
+
}, []);
|
|
99
|
+
const handlePlay = (e) => {
|
|
100
|
+
setIsPlaying(true);
|
|
101
|
+
onPlay?.(e);
|
|
102
|
+
};
|
|
103
|
+
const handlePause = (e) => {
|
|
104
|
+
setIsPlaying(false);
|
|
105
|
+
onPause?.(e);
|
|
106
|
+
};
|
|
107
|
+
const handleLoadedMetadata = (e) => {
|
|
108
|
+
const v = e.currentTarget;
|
|
109
|
+
setDuration(v.duration);
|
|
110
|
+
setIsLoaded(true);
|
|
111
|
+
onLoadedMetadata?.(e);
|
|
112
|
+
};
|
|
113
|
+
const handleTimeUpdate = (e) => {
|
|
114
|
+
const v = e.currentTarget;
|
|
115
|
+
setCurrentTime(v.currentTime);
|
|
116
|
+
if (v.buffered.length > 0) {
|
|
117
|
+
setBuffered(v.buffered.end(v.buffered.length - 1));
|
|
118
|
+
}
|
|
119
|
+
onTimeUpdate?.(e);
|
|
120
|
+
};
|
|
121
|
+
const handleVolumeChange = (e) => {
|
|
122
|
+
const v = e.currentTarget;
|
|
123
|
+
setVolume(v.volume);
|
|
124
|
+
setIsMuted(v.muted);
|
|
125
|
+
onVolumeChange?.(e);
|
|
126
|
+
};
|
|
127
|
+
const handleRateChange = (e) => {
|
|
128
|
+
setPlaybackRate(e.currentTarget.playbackRate);
|
|
129
|
+
onRateChange?.(e);
|
|
130
|
+
};
|
|
131
|
+
const togglePlay = () => {
|
|
132
|
+
const v = videoRef.current;
|
|
133
|
+
if (!v) return;
|
|
134
|
+
if (v.paused) v.play();
|
|
135
|
+
else v.pause();
|
|
136
|
+
};
|
|
137
|
+
const toggleMute = () => {
|
|
138
|
+
const v = videoRef.current;
|
|
139
|
+
if (!v) return;
|
|
140
|
+
v.muted = !v.muted;
|
|
141
|
+
};
|
|
142
|
+
const toggleFullscreen = () => {
|
|
143
|
+
const el = containerRef.current;
|
|
144
|
+
if (!el) return;
|
|
145
|
+
if (document.fullscreenElement === el) {
|
|
146
|
+
document.exitFullscreen();
|
|
147
|
+
} else {
|
|
148
|
+
el.requestFullscreen?.();
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const togglePip = async () => {
|
|
152
|
+
const v = videoRef.current;
|
|
153
|
+
if (!v) return;
|
|
154
|
+
try {
|
|
155
|
+
if (document.pictureInPictureElement === v) {
|
|
156
|
+
await document.exitPictureInPicture?.();
|
|
157
|
+
} else {
|
|
158
|
+
await v.requestPictureInPicture?.();
|
|
159
|
+
}
|
|
160
|
+
} catch {
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const toggleCaptions = () => {
|
|
164
|
+
const v = videoRef.current;
|
|
165
|
+
if (!v) return;
|
|
166
|
+
const next = !captionsOn;
|
|
167
|
+
for (let i = 0; i < v.textTracks.length; i++) {
|
|
168
|
+
const t = v.textTracks[i];
|
|
169
|
+
if (t.kind === "captions" || t.kind === "subtitles") {
|
|
170
|
+
t.mode = next ? "showing" : "hidden";
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
setCaptionsOn(next);
|
|
174
|
+
};
|
|
175
|
+
const selectRate = (rate) => {
|
|
176
|
+
const v = videoRef.current;
|
|
177
|
+
if (!v) return;
|
|
178
|
+
v.playbackRate = rate;
|
|
179
|
+
setRateMenuOpen(false);
|
|
180
|
+
};
|
|
181
|
+
const handleSeek = (e) => {
|
|
182
|
+
const v = videoRef.current;
|
|
183
|
+
if (!v) return;
|
|
184
|
+
const next = Number(e.target.value);
|
|
185
|
+
v.currentTime = next;
|
|
186
|
+
setCurrentTime(next);
|
|
187
|
+
};
|
|
188
|
+
const handleVolumeSlider = (e) => {
|
|
189
|
+
const v = videoRef.current;
|
|
190
|
+
if (!v) return;
|
|
191
|
+
const next = Number(e.target.value);
|
|
192
|
+
v.volume = next;
|
|
193
|
+
if (next > 0 && v.muted) v.muted = false;
|
|
194
|
+
if (next === 0) v.muted = true;
|
|
195
|
+
};
|
|
196
|
+
const progressPct = duration > 0 ? currentTime / duration * 100 : 0;
|
|
197
|
+
const bufferedPct = duration > 0 ? buffered / duration * 100 : 0;
|
|
198
|
+
const volumePct = (isMuted ? 0 : volume) * 100;
|
|
199
|
+
const VolumeGlyph = isMuted || volume === 0 ? VolumeXIcon_default : volume < 0.5 ? VolumeIcon_default : Volume2Icon_default;
|
|
200
|
+
const pipSupported = typeof document !== "undefined" && "pictureInPictureEnabled" in document && document.pictureInPictureEnabled;
|
|
201
|
+
return /* @__PURE__ */ jsxs(
|
|
202
|
+
"div",
|
|
203
|
+
{
|
|
204
|
+
ref: containerRef,
|
|
205
|
+
className: clsx_default("lib-xplat-video", showControls && "has-controls"),
|
|
206
|
+
children: [
|
|
207
|
+
/* @__PURE__ */ jsx(
|
|
208
|
+
"video",
|
|
209
|
+
{
|
|
210
|
+
ref: setRefs,
|
|
211
|
+
src,
|
|
212
|
+
poster,
|
|
213
|
+
autoPlay,
|
|
214
|
+
muted,
|
|
215
|
+
loop,
|
|
216
|
+
playsInline: playsInline ?? true,
|
|
217
|
+
onPlay: handlePlay,
|
|
218
|
+
onPause: handlePause,
|
|
219
|
+
onLoadedMetadata: handleLoadedMetadata,
|
|
220
|
+
onTimeUpdate: handleTimeUpdate,
|
|
221
|
+
onVolumeChange: handleVolumeChange,
|
|
222
|
+
onRateChange: handleRateChange,
|
|
223
|
+
onClick: showControls || showCenterPlay ? togglePlay : void 0,
|
|
224
|
+
...rest,
|
|
225
|
+
children
|
|
226
|
+
}
|
|
227
|
+
),
|
|
228
|
+
showCenterPlay && /* @__PURE__ */ jsx(
|
|
229
|
+
"button",
|
|
230
|
+
{
|
|
231
|
+
type: "button",
|
|
232
|
+
className: clsx_default(
|
|
233
|
+
"center-play",
|
|
234
|
+
isPlaying && "is-playing",
|
|
235
|
+
!isLoaded && "is-loading"
|
|
236
|
+
),
|
|
237
|
+
onClick: togglePlay,
|
|
238
|
+
"aria-label": isPlaying ? "\uC77C\uC2DC\uC815\uC9C0" : "\uC7AC\uC0DD",
|
|
239
|
+
tabIndex: -1,
|
|
240
|
+
children: /* @__PURE__ */ jsx("span", { className: "center-play-icon", children: /* @__PURE__ */ jsx(PlayCircleIcon_default, {}) })
|
|
241
|
+
}
|
|
242
|
+
),
|
|
243
|
+
showControls && /* @__PURE__ */ jsxs("div", { className: "controls", onClick: (e) => e.stopPropagation(), children: [
|
|
244
|
+
/* @__PURE__ */ jsx(
|
|
245
|
+
"input",
|
|
246
|
+
{
|
|
247
|
+
type: "range",
|
|
248
|
+
className: "seekbar",
|
|
249
|
+
min: 0,
|
|
250
|
+
max: duration || 0,
|
|
251
|
+
step: 0.1,
|
|
252
|
+
value: currentTime,
|
|
253
|
+
onChange: handleSeek,
|
|
254
|
+
"aria-label": "\uC7AC\uC0DD \uC704\uCE58",
|
|
255
|
+
style: {
|
|
256
|
+
["--progress"]: `${progressPct}%`,
|
|
257
|
+
["--buffered"]: `${bufferedPct}%`
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
),
|
|
261
|
+
/* @__PURE__ */ jsxs("div", { className: "controls-row", children: [
|
|
262
|
+
/* @__PURE__ */ jsx(
|
|
263
|
+
"button",
|
|
264
|
+
{
|
|
265
|
+
type: "button",
|
|
266
|
+
className: "control-btn",
|
|
267
|
+
onClick: togglePlay,
|
|
268
|
+
"aria-label": isPlaying ? "\uC77C\uC2DC\uC815\uC9C0" : "\uC7AC\uC0DD",
|
|
269
|
+
children: isPlaying ? /* @__PURE__ */ jsx(PauseIcon_default, {}) : /* @__PURE__ */ jsx(PlayIcon_default, {})
|
|
270
|
+
}
|
|
271
|
+
),
|
|
272
|
+
/* @__PURE__ */ jsxs("div", { className: "volume-group", children: [
|
|
273
|
+
/* @__PURE__ */ jsx(
|
|
274
|
+
"button",
|
|
275
|
+
{
|
|
276
|
+
type: "button",
|
|
277
|
+
className: "control-btn",
|
|
278
|
+
onClick: toggleMute,
|
|
279
|
+
"aria-label": isMuted ? "\uC74C\uC18C\uAC70 \uD574\uC81C" : "\uC74C\uC18C\uAC70",
|
|
280
|
+
children: /* @__PURE__ */ jsx(VolumeGlyph, {})
|
|
281
|
+
}
|
|
282
|
+
),
|
|
283
|
+
/* @__PURE__ */ jsx(
|
|
284
|
+
"input",
|
|
285
|
+
{
|
|
286
|
+
type: "range",
|
|
287
|
+
className: "volume-slider",
|
|
288
|
+
min: 0,
|
|
289
|
+
max: 1,
|
|
290
|
+
step: 0.05,
|
|
291
|
+
value: isMuted ? 0 : volume,
|
|
292
|
+
onChange: handleVolumeSlider,
|
|
293
|
+
"aria-label": "\uBCFC\uB968",
|
|
294
|
+
style: { ["--volume"]: `${volumePct}%` }
|
|
295
|
+
}
|
|
296
|
+
)
|
|
297
|
+
] }),
|
|
298
|
+
/* @__PURE__ */ jsxs("span", { className: "time", children: [
|
|
299
|
+
formatTime(currentTime),
|
|
300
|
+
" / ",
|
|
301
|
+
formatTime(duration)
|
|
302
|
+
] }),
|
|
303
|
+
/* @__PURE__ */ jsx("div", { className: "controls-spacer" }),
|
|
304
|
+
playbackRates && playbackRates.length > 0 && /* @__PURE__ */ jsxs("div", { className: clsx_default("rate-group", rateMenuOpen && "is-open"), children: [
|
|
305
|
+
/* @__PURE__ */ jsxs(
|
|
306
|
+
"button",
|
|
307
|
+
{
|
|
308
|
+
type: "button",
|
|
309
|
+
className: "control-btn rate-btn",
|
|
310
|
+
onClick: () => setRateMenuOpen((o) => !o),
|
|
311
|
+
"aria-label": "\uC7AC\uC0DD \uC18D\uB3C4",
|
|
312
|
+
"aria-expanded": rateMenuOpen,
|
|
313
|
+
children: [
|
|
314
|
+
playbackRate,
|
|
315
|
+
"x"
|
|
316
|
+
]
|
|
317
|
+
}
|
|
318
|
+
),
|
|
319
|
+
rateMenuOpen && /* @__PURE__ */ jsx("ul", { className: "rate-menu", role: "menu", children: playbackRates.map((r) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
320
|
+
"button",
|
|
321
|
+
{
|
|
322
|
+
type: "button",
|
|
323
|
+
role: "menuitem",
|
|
324
|
+
className: clsx_default("rate-item", r === playbackRate && "is-active"),
|
|
325
|
+
onClick: () => selectRate(r),
|
|
326
|
+
children: [
|
|
327
|
+
r,
|
|
328
|
+
"x"
|
|
329
|
+
]
|
|
330
|
+
}
|
|
331
|
+
) }, r)) })
|
|
332
|
+
] }),
|
|
333
|
+
showCaptions && /* @__PURE__ */ jsx(
|
|
334
|
+
"button",
|
|
335
|
+
{
|
|
336
|
+
type: "button",
|
|
337
|
+
className: clsx_default("control-btn", captionsOn && "is-active"),
|
|
338
|
+
onClick: toggleCaptions,
|
|
339
|
+
"aria-label": captionsOn ? "\uC790\uB9C9 \uB044\uAE30" : "\uC790\uB9C9 \uCF1C\uAE30",
|
|
340
|
+
"aria-pressed": captionsOn,
|
|
341
|
+
children: /* @__PURE__ */ jsx(TypeIcon_default, {})
|
|
342
|
+
}
|
|
343
|
+
),
|
|
344
|
+
showPip && pipSupported && /* @__PURE__ */ jsx(
|
|
345
|
+
"button",
|
|
346
|
+
{
|
|
347
|
+
type: "button",
|
|
348
|
+
className: clsx_default("control-btn", isPip && "is-active"),
|
|
349
|
+
onClick: togglePip,
|
|
350
|
+
"aria-label": isPip ? "PIP \uC885\uB8CC" : "PIP",
|
|
351
|
+
children: /* @__PURE__ */ jsx(PipIcon, {})
|
|
352
|
+
}
|
|
353
|
+
),
|
|
354
|
+
showDownload && /* @__PURE__ */ jsx(
|
|
355
|
+
"a",
|
|
356
|
+
{
|
|
357
|
+
className: "control-btn",
|
|
358
|
+
href: src,
|
|
359
|
+
download: downloadFileName ?? true,
|
|
360
|
+
"aria-label": "\uB2E4\uC6B4\uB85C\uB4DC",
|
|
361
|
+
children: /* @__PURE__ */ jsx(DownloadIcon_default, {})
|
|
362
|
+
}
|
|
363
|
+
),
|
|
364
|
+
/* @__PURE__ */ jsx(
|
|
365
|
+
"button",
|
|
366
|
+
{
|
|
367
|
+
type: "button",
|
|
368
|
+
className: "control-btn",
|
|
369
|
+
onClick: toggleFullscreen,
|
|
370
|
+
"aria-label": isFullscreen ? "\uC804\uCCB4\uD654\uBA74 \uC885\uB8CC" : "\uC804\uCCB4\uD654\uBA74",
|
|
371
|
+
children: isFullscreen ? /* @__PURE__ */ jsx(MinimizeIcon_default, {}) : /* @__PURE__ */ jsx(MaximizeIcon_default, {})
|
|
372
|
+
}
|
|
373
|
+
)
|
|
374
|
+
] })
|
|
375
|
+
] })
|
|
376
|
+
]
|
|
377
|
+
}
|
|
378
|
+
);
|
|
379
|
+
});
|
|
380
|
+
Video.displayName = "Video";
|
|
381
|
+
var Video_default = Video;
|
|
382
|
+
|
|
383
|
+
export {
|
|
384
|
+
Video_default
|
|
385
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clsx_default
|
|
3
|
+
} from "./chunk-KZOJN57Q.js";
|
|
4
|
+
|
|
5
|
+
// src/components/Alert/Alert.tsx
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
var Alert = (props) => {
|
|
8
|
+
const { type = "info", children, onClose } = props;
|
|
9
|
+
return /* @__PURE__ */ jsxs(
|
|
10
|
+
"div",
|
|
11
|
+
{
|
|
12
|
+
className: clsx_default("lib-xplat-alert", type),
|
|
13
|
+
role: "alert",
|
|
14
|
+
children: [
|
|
15
|
+
/* @__PURE__ */ jsx("div", { className: "content", children }),
|
|
16
|
+
onClose && /* @__PURE__ */ jsx(
|
|
17
|
+
"button",
|
|
18
|
+
{
|
|
19
|
+
className: "close-btn",
|
|
20
|
+
onClick: onClose,
|
|
21
|
+
"aria-label": "\uB2EB\uAE30",
|
|
22
|
+
children: "\xD7"
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
Alert.displayName = "Alert";
|
|
30
|
+
var Alert_default = Alert;
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
Alert_default
|
|
34
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clsx_default
|
|
3
|
+
} from "./chunk-KZOJN57Q.js";
|
|
4
|
+
|
|
5
|
+
// src/components/CardTab/CardTab.tsx
|
|
6
|
+
import React from "react";
|
|
7
|
+
|
|
8
|
+
// src/components/CardTab/CardTabPanel.tsx
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
var CardTabPanel = (props) => {
|
|
11
|
+
const { children, columns = 3 } = props;
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
"div",
|
|
14
|
+
{
|
|
15
|
+
className: "card-tab-panel",
|
|
16
|
+
style: { "--card-tab-columns": columns },
|
|
17
|
+
children
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
CardTabPanel.displayName = "CardTab.Panel";
|
|
22
|
+
var CardTabPanel_default = CardTabPanel;
|
|
23
|
+
|
|
24
|
+
// src/components/CardTab/CardTab.tsx
|
|
25
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
26
|
+
var CardTabRoot = (props) => {
|
|
27
|
+
const {
|
|
28
|
+
tabs,
|
|
29
|
+
activeValue: activeValueProp,
|
|
30
|
+
onChange,
|
|
31
|
+
size = "md",
|
|
32
|
+
children
|
|
33
|
+
} = props;
|
|
34
|
+
const isControlled = activeValueProp !== void 0;
|
|
35
|
+
const [uncontrolledValue, setUncontrolledValue] = React.useState(tabs[0]?.value ?? "");
|
|
36
|
+
const activeValue = isControlled ? activeValueProp : uncontrolledValue;
|
|
37
|
+
const handleTabClick = (tab) => {
|
|
38
|
+
if (!isControlled) {
|
|
39
|
+
setUncontrolledValue(tab.value);
|
|
40
|
+
}
|
|
41
|
+
onChange?.(tab);
|
|
42
|
+
};
|
|
43
|
+
const panels = React.Children.toArray(children).filter(
|
|
44
|
+
(child) => React.isValidElement(child) && child.type === CardTabPanel_default
|
|
45
|
+
);
|
|
46
|
+
const activePanel = panels.find(
|
|
47
|
+
(panel) => panel.props.value === activeValue
|
|
48
|
+
);
|
|
49
|
+
return /* @__PURE__ */ jsxs("div", { className: clsx_default("lib-xplat-card-tab", size), children: [
|
|
50
|
+
/* @__PURE__ */ jsx2("div", { className: "card-tab-bar", children: tabs.map((tab) => {
|
|
51
|
+
const isActive = tab.value === activeValue;
|
|
52
|
+
return /* @__PURE__ */ jsx2(
|
|
53
|
+
"button",
|
|
54
|
+
{
|
|
55
|
+
className: clsx_default("card-tab-trigger", isActive && "active"),
|
|
56
|
+
onClick: () => handleTabClick(tab),
|
|
57
|
+
role: "tab",
|
|
58
|
+
"aria-selected": isActive,
|
|
59
|
+
children: tab.title
|
|
60
|
+
},
|
|
61
|
+
tab.value
|
|
62
|
+
);
|
|
63
|
+
}) }),
|
|
64
|
+
/* @__PURE__ */ jsx2("div", { className: "card-tab-body", children: activePanel })
|
|
65
|
+
] });
|
|
66
|
+
};
|
|
67
|
+
CardTabRoot.displayName = "CardTab";
|
|
68
|
+
var CardTab = Object.assign(CardTabRoot, {
|
|
69
|
+
Panel: CardTabPanel_default
|
|
70
|
+
});
|
|
71
|
+
var CardTab_default = CardTab;
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
CardTab_default
|
|
75
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// src/components/HtmlTypeWriter/HtmlTypeWriter.tsx
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
|
|
4
|
+
// src/components/HtmlTypeWriter/utils.ts
|
|
5
|
+
import React from "react";
|
|
6
|
+
var voidTags = /* @__PURE__ */ new Set([
|
|
7
|
+
"br",
|
|
8
|
+
"img",
|
|
9
|
+
"hr",
|
|
10
|
+
"input",
|
|
11
|
+
"meta",
|
|
12
|
+
"link",
|
|
13
|
+
"area",
|
|
14
|
+
"base",
|
|
15
|
+
"col",
|
|
16
|
+
"embed",
|
|
17
|
+
"param",
|
|
18
|
+
"source",
|
|
19
|
+
"track",
|
|
20
|
+
"wbr"
|
|
21
|
+
]);
|
|
22
|
+
var decodeHtmlEntities = (str) => {
|
|
23
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/'/g, "'").replace(/&#(\d+);/g, (_, code) => String.fromCharCode(Number(code))).replace(
|
|
24
|
+
/&#x([0-9a-fA-F]+);/g,
|
|
25
|
+
(_, code) => String.fromCharCode(parseInt(code, 16))
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
var buildRangeMap = (root) => {
|
|
29
|
+
const rangeMap = /* @__PURE__ */ new WeakMap();
|
|
30
|
+
let index = 0;
|
|
31
|
+
const assign = (node) => {
|
|
32
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
33
|
+
const len = (node.textContent || "").length;
|
|
34
|
+
rangeMap.set(node, { start: index, end: index + len });
|
|
35
|
+
index += len;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
39
|
+
const el = node;
|
|
40
|
+
const tag = el.tagName.toLowerCase();
|
|
41
|
+
const start = index;
|
|
42
|
+
if (voidTags.has(tag)) {
|
|
43
|
+
rangeMap.set(node, { start: index, end: index + 1 });
|
|
44
|
+
index += 1;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
Array.from(el.childNodes).forEach(assign);
|
|
48
|
+
rangeMap.set(node, { start, end: index });
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
rangeMap.set(node, { start: index, end: index });
|
|
52
|
+
};
|
|
53
|
+
Array.from(root.childNodes).forEach(assign);
|
|
54
|
+
return { rangeMap, totalLength: index };
|
|
55
|
+
};
|
|
56
|
+
var convertNodeToReactWithRange = (node, typedLen, rangeMap) => {
|
|
57
|
+
const range = rangeMap.get(node);
|
|
58
|
+
if (!range) return null;
|
|
59
|
+
if (range.start >= typedLen) return null;
|
|
60
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
61
|
+
const text = node.textContent || "";
|
|
62
|
+
if (range.end <= typedLen) return text;
|
|
63
|
+
return text.slice(0, typedLen - range.start);
|
|
64
|
+
}
|
|
65
|
+
if (node.nodeType !== Node.ELEMENT_NODE) return null;
|
|
66
|
+
const element = node;
|
|
67
|
+
const tag = element.tagName.toLowerCase();
|
|
68
|
+
const props = {};
|
|
69
|
+
Array.from(element.attributes).forEach((attr) => {
|
|
70
|
+
props[attr.name] = attr.value;
|
|
71
|
+
});
|
|
72
|
+
if (voidTags.has(tag)) {
|
|
73
|
+
return React.createElement(tag, props);
|
|
74
|
+
}
|
|
75
|
+
const children = Array.from(element.childNodes).map((child) => convertNodeToReactWithRange(child, typedLen, rangeMap)).filter((n) => n != null);
|
|
76
|
+
return React.createElement(tag, props, ...children);
|
|
77
|
+
};
|
|
78
|
+
var htmlToReactProgressive = (root, typedLen, rangeMap) => {
|
|
79
|
+
const nodes = Array.from(root.childNodes).map((child, idx) => {
|
|
80
|
+
const node = convertNodeToReactWithRange(child, typedLen, rangeMap);
|
|
81
|
+
return node == null ? null : React.createElement(React.Fragment, { key: idx }, node);
|
|
82
|
+
}).filter(Boolean);
|
|
83
|
+
return nodes.length === 0 ? null : nodes;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// src/components/HtmlTypeWriter/HtmlTypeWriter.tsx
|
|
87
|
+
import { jsx } from "react/jsx-runtime";
|
|
88
|
+
var HtmlTypeWriter = ({
|
|
89
|
+
html,
|
|
90
|
+
duration = 20,
|
|
91
|
+
onDone,
|
|
92
|
+
onChange
|
|
93
|
+
}) => {
|
|
94
|
+
const [typedLen, setTypedLen] = React2.useState(0);
|
|
95
|
+
const doneCalledRef = React2.useRef(false);
|
|
96
|
+
const { doc, rangeMap, totalLength } = React2.useMemo(() => {
|
|
97
|
+
if (typeof window === "undefined") return { doc: null, rangeMap: /* @__PURE__ */ new Map(), totalLength: 0 };
|
|
98
|
+
const decoded = decodeHtmlEntities(html);
|
|
99
|
+
const doc2 = new DOMParser().parseFromString(decoded, "text/html");
|
|
100
|
+
const { rangeMap: rangeMap2, totalLength: totalLength2 } = buildRangeMap(doc2.body);
|
|
101
|
+
return { doc: doc2, rangeMap: rangeMap2, totalLength: totalLength2 };
|
|
102
|
+
}, [html]);
|
|
103
|
+
React2.useEffect(() => {
|
|
104
|
+
setTypedLen(0);
|
|
105
|
+
doneCalledRef.current = false;
|
|
106
|
+
}, [html]);
|
|
107
|
+
React2.useEffect(() => {
|
|
108
|
+
if (!totalLength) return;
|
|
109
|
+
if (typedLen >= totalLength) return;
|
|
110
|
+
const timer = window.setInterval(() => {
|
|
111
|
+
setTypedLen((prev) => Math.min(prev + 1, totalLength));
|
|
112
|
+
}, duration);
|
|
113
|
+
return () => window.clearInterval(timer);
|
|
114
|
+
}, [typedLen, totalLength, duration]);
|
|
115
|
+
React2.useEffect(() => {
|
|
116
|
+
if (typedLen > 0 && typedLen < totalLength) {
|
|
117
|
+
onChange?.();
|
|
118
|
+
}
|
|
119
|
+
}, [typedLen, totalLength, onChange]);
|
|
120
|
+
React2.useEffect(() => {
|
|
121
|
+
if (typedLen === totalLength && totalLength > 0 && !doneCalledRef.current) {
|
|
122
|
+
doneCalledRef.current = true;
|
|
123
|
+
onDone?.();
|
|
124
|
+
}
|
|
125
|
+
}, [typedLen, totalLength, onDone]);
|
|
126
|
+
const parsed = React2.useMemo(
|
|
127
|
+
() => doc ? htmlToReactProgressive(doc.body, typedLen, rangeMap) : null,
|
|
128
|
+
[doc, typedLen, rangeMap]
|
|
129
|
+
);
|
|
130
|
+
return /* @__PURE__ */ jsx("div", { className: "lib-xplat-htmlTypewriter", children: parsed });
|
|
131
|
+
};
|
|
132
|
+
HtmlTypeWriter.displayName = "HtmlTypeWriter";
|
|
133
|
+
var HtmlTypeWriter_default = HtmlTypeWriter;
|
|
134
|
+
|
|
135
|
+
export {
|
|
136
|
+
HtmlTypeWriter_default
|
|
137
|
+
};
|