@lobehub/ui 6.0.0-beta.1 → 6.0.0-beta.3
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 +3 -1
- package/es/Accordion/style.d.mts +1 -1
- package/es/ActionIcon/type.d.mts +1 -0
- package/es/Alert/type.d.mts +1 -0
- package/es/AutoComplete/style.d.mts +2 -1
- package/es/AutoComplete/type.d.mts +1 -0
- package/es/Button/type.d.mts +1 -0
- package/es/Checkbox/type.d.mts +1 -0
- package/es/ColorSwatches/type.d.mts +1 -0
- package/es/Drawer/atoms.d.mts +1 -0
- package/es/Drawer/constants.d.mts +1 -0
- package/es/FileTypeIcon/type.d.mts +1 -0
- package/es/Form/type.d.mts +1 -0
- package/es/GroupAvatar/type.d.mts +1 -0
- package/es/Highlighter/const.d.mts +1 -0
- package/es/Input/style.d.mts +1 -0
- package/es/Input/type.d.mts +1 -0
- package/es/Markdown/plugins/remarkColor.d.mts +1 -0
- package/es/Markdown/plugins/remarkGfmPlus.d.mts +1 -0
- package/es/Markdown/plugins/remarkVideo.d.mts +1 -0
- package/es/Mermaid/const.d.mts +1 -0
- package/es/Modal/atoms.d.mts +1 -0
- package/es/Modal/constants.d.mts +1 -0
- package/es/Modal/type.d.mts +1 -0
- package/es/Radio/type.d.mts +1 -0
- package/es/Segmented/atoms.d.mts +1 -0
- package/es/Slider/type.d.mts +1 -0
- package/es/Switch/atoms.d.mts +1 -0
- package/es/Text/style.d.mts +2 -1
- package/es/ToggleGroup/atoms.d.mts +1 -0
- package/es/Video/Video.mjs +46 -0
- package/es/Video/Video.mjs.map +1 -0
- package/es/Video/context.mjs +14 -0
- package/es/Video/context.mjs.map +1 -0
- package/es/Video/index.d.mts +23 -39
- package/es/Video/index.mjs +21 -111
- package/es/Video/index.mjs.map +1 -1
- package/es/Video/parts/Caption.d.mts +9 -0
- package/es/Video/parts/Caption.mjs +34 -0
- package/es/Video/parts/Caption.mjs.map +1 -0
- package/es/Video/parts/CenterPlay.d.mts +8 -0
- package/es/Video/parts/CenterPlay.mjs +34 -0
- package/es/Video/parts/CenterPlay.mjs.map +1 -0
- package/es/Video/parts/Controls.d.mts +9 -0
- package/es/Video/parts/Controls.mjs +123 -0
- package/es/Video/parts/Controls.mjs.map +1 -0
- package/es/Video/parts/Frame.d.mts +9 -0
- package/es/Video/parts/Frame.mjs +94 -0
- package/es/Video/parts/Frame.mjs.map +1 -0
- package/es/Video/parts/HoverPreview.mjs +93 -0
- package/es/Video/parts/HoverPreview.mjs.map +1 -0
- package/es/Video/parts/LoadError.d.mts +8 -0
- package/es/Video/parts/LoadError.mjs +47 -0
- package/es/Video/parts/LoadError.mjs.map +1 -0
- package/es/Video/parts/PlayPauseIcon.mjs +48 -0
- package/es/Video/parts/PlayPauseIcon.mjs.map +1 -0
- package/es/Video/parts/RateMenu.mjs +48 -0
- package/es/Video/parts/RateMenu.mjs.map +1 -0
- package/es/Video/parts/Root.d.mts +9 -0
- package/es/Video/parts/Root.mjs +110 -0
- package/es/Video/parts/Root.mjs.map +1 -0
- package/es/Video/parts/SectionList.d.mts +9 -0
- package/es/Video/parts/SectionList.mjs +32 -0
- package/es/Video/parts/SectionList.mjs.map +1 -0
- package/es/Video/parts/SectionMenu.mjs +63 -0
- package/es/Video/parts/SectionMenu.mjs.map +1 -0
- package/es/Video/parts/Timeline.d.mts +9 -0
- package/es/Video/parts/Timeline.mjs +169 -0
- package/es/Video/parts/Timeline.mjs.map +1 -0
- package/es/Video/store.mjs +241 -0
- package/es/Video/store.mjs.map +1 -0
- package/es/Video/style.mjs +393 -23
- package/es/Video/style.mjs.map +1 -1
- package/es/Video/time.mjs +60 -0
- package/es/Video/time.mjs.map +1 -0
- package/es/Video/type.d.mts +125 -0
- package/es/Video/useControlsIdle.mjs +39 -0
- package/es/Video/useControlsIdle.mjs.map +1 -0
- package/es/Video/useFullscreen.mjs +17 -0
- package/es/Video/useFullscreen.mjs.map +1 -0
- package/es/Video/useKeyboard.mjs +60 -0
- package/es/Video/useKeyboard.mjs.map +1 -0
- package/es/Video/useVideo.d.mts +9 -0
- package/es/Video/useVideo.mjs +17 -0
- package/es/Video/useVideo.mjs.map +1 -0
- package/es/color/types.d.mts +1 -0
- package/es/hooks/useMarkdown/utils.d.mts +1 -0
- package/es/i18n/resources/en/index.d.mts +3 -2
- package/es/i18n/resources/en/index.mjs +4 -2
- package/es/i18n/resources/en/index.mjs.map +1 -1
- package/es/i18n/resources/en/video.d.mts +23 -0
- package/es/i18n/resources/en/video.mjs +24 -0
- package/es/i18n/resources/en/video.mjs.map +1 -0
- package/es/i18n/resources/zhCn/index.d.mts +3 -2
- package/es/i18n/resources/zhCn/index.mjs +4 -2
- package/es/i18n/resources/zhCn/index.mjs.map +1 -1
- package/es/i18n/resources/zhCn/video.d.mts +23 -0
- package/es/i18n/resources/zhCn/video.mjs +24 -0
- package/es/i18n/resources/zhCn/video.mjs.map +1 -0
- package/es/i18n/types.d.mts +3 -1
- package/es/index.d.mts +4 -2
- package/es/index.mjs +2 -1
- package/es/internal/menu/itemInterface.d.mts +1 -0
- package/es/internal/menu/renderUtils.d.mts +1 -0
- package/es/mdx/mdxComponents/Video.d.mts +2 -1
- package/es/mdx/mdxComponents/Video.mjs +5 -3
- package/es/mdx/mdxComponents/Video.mjs.map +1 -1
- package/es/node_modules/.pnpm/@types_mdx@2.0.14/node_modules/@types/mdx/types.d.mts +1 -0
- package/es/node_modules/.pnpm/eslint@10.12.0_jiti@2.6.1_supports-color@10.2.2/node_modules/eslint/lib/types/index.d.mts +1 -0
- package/es/style.css +263 -23
- package/es/styles/createGlobalStyle.d.mts +1 -0
- package/es/styles/theme/generateColorPalette.d.mts +1 -0
- package/es/styles/theme/scope.d.mts +1 -0
- package/es/types/customToken.d.mts +1 -0
- package/package.json +5 -5
- package/es/Video/marker.stylex.mjs +0 -9
- package/es/Video/marker.stylex.mjs.map +0 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { styleProps } from "../../styles/stylex/props.mjs";
|
|
3
|
+
import { VideoContext } from "../context.mjs";
|
|
4
|
+
import { styles } from "../style.mjs";
|
|
5
|
+
import { sortSections } from "../time.mjs";
|
|
6
|
+
import { createVideoStore } from "../store.mjs";
|
|
7
|
+
import { useVideoState } from "../useVideo.mjs";
|
|
8
|
+
import { handleVideoKey } from "../useKeyboard.mjs";
|
|
9
|
+
import { useImperativeHandle, useLayoutEffect, useMemo, useState } from "react";
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
//#region src/Video/parts/Root.tsx
|
|
12
|
+
const NO_MARKERS = [];
|
|
13
|
+
const NO_SECTIONS = [];
|
|
14
|
+
const Root = ({ ref, player, src, poster, autoPlay, loop, preload = "metadata", onPlay, onPause, onEnded, onError, onTimeUpdate, sections = NO_SECTIONS, markers = NO_MARKERS, fps = 30, playbackRates, defaultPlaybackRate, muted, onMutedChange, onRateChange, onMarkerClick, onRetry, captions = true, width, height, maxHeight, className, style, children }) => {
|
|
15
|
+
const [ownStore] = useState(createVideoStore);
|
|
16
|
+
const store = player ?? ownStore;
|
|
17
|
+
store.setOptions({
|
|
18
|
+
defaultPlaybackRate,
|
|
19
|
+
muted,
|
|
20
|
+
onMutedChange,
|
|
21
|
+
onRateChange
|
|
22
|
+
});
|
|
23
|
+
useImperativeHandle(ref, () => store, [store]);
|
|
24
|
+
const sorted = useMemo(() => sortSections(sections), [sections]);
|
|
25
|
+
useLayoutEffect(() => {
|
|
26
|
+
store.setData({
|
|
27
|
+
fps,
|
|
28
|
+
markers,
|
|
29
|
+
sections: sorted
|
|
30
|
+
});
|
|
31
|
+
}, [
|
|
32
|
+
store,
|
|
33
|
+
fps,
|
|
34
|
+
markers,
|
|
35
|
+
sorted
|
|
36
|
+
]);
|
|
37
|
+
useLayoutEffect(() => {
|
|
38
|
+
if (!captions) store.setCaptions(false);
|
|
39
|
+
}, [store]);
|
|
40
|
+
const size = useVideoState(store, (state) => state.size);
|
|
41
|
+
const aspect = size?.height ? size.width / size.height : 16 / 9;
|
|
42
|
+
const sizing = maxHeight === void 0 ? {
|
|
43
|
+
height,
|
|
44
|
+
width
|
|
45
|
+
} : {
|
|
46
|
+
maxWidth: `${Math.round(maxHeight * aspect)}px`,
|
|
47
|
+
width: "100%"
|
|
48
|
+
};
|
|
49
|
+
const value = useMemo(() => ({
|
|
50
|
+
config: {
|
|
51
|
+
fps,
|
|
52
|
+
markers,
|
|
53
|
+
onMarkerClick,
|
|
54
|
+
onRetry,
|
|
55
|
+
playbackRates,
|
|
56
|
+
sections: sorted
|
|
57
|
+
},
|
|
58
|
+
media: {
|
|
59
|
+
autoPlay,
|
|
60
|
+
loop,
|
|
61
|
+
onEnded,
|
|
62
|
+
onError,
|
|
63
|
+
onPause,
|
|
64
|
+
onPlay,
|
|
65
|
+
onTimeUpdate,
|
|
66
|
+
poster,
|
|
67
|
+
preload,
|
|
68
|
+
src
|
|
69
|
+
},
|
|
70
|
+
store
|
|
71
|
+
}), [
|
|
72
|
+
autoPlay,
|
|
73
|
+
fps,
|
|
74
|
+
loop,
|
|
75
|
+
markers,
|
|
76
|
+
onEnded,
|
|
77
|
+
onError,
|
|
78
|
+
onMarkerClick,
|
|
79
|
+
onPause,
|
|
80
|
+
onPlay,
|
|
81
|
+
onRetry,
|
|
82
|
+
onTimeUpdate,
|
|
83
|
+
playbackRates,
|
|
84
|
+
poster,
|
|
85
|
+
preload,
|
|
86
|
+
sorted,
|
|
87
|
+
src,
|
|
88
|
+
store
|
|
89
|
+
]);
|
|
90
|
+
return /* @__PURE__ */ jsx(VideoContext, {
|
|
91
|
+
value,
|
|
92
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
93
|
+
ref: store.attachRoot,
|
|
94
|
+
tabIndex: 0,
|
|
95
|
+
onKeyDown: (event) => {
|
|
96
|
+
if (handleVideoKey(event, store, playbackRates)) event.preventDefault();
|
|
97
|
+
},
|
|
98
|
+
...styleProps(styles.root, className, {
|
|
99
|
+
...sizing,
|
|
100
|
+
...style
|
|
101
|
+
}),
|
|
102
|
+
children
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
Root.displayName = "VideoRoot";
|
|
107
|
+
//#endregion
|
|
108
|
+
export { Root as default };
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=Root.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Root.mjs","names":[],"sources":["../../../src/Video/parts/Root.tsx"],"sourcesContent":["'use client';\n\nimport { useImperativeHandle, useLayoutEffect, useMemo, useState } from 'react';\n\nimport { styleProps } from '@/styles/stylex/props';\n\nimport { VideoContext, type VideoContextValue } from '../context';\nimport { createVideoStore, type VideoStore } from '../store';\nimport { styles } from '../style';\nimport { sortSections } from '../time';\nimport type { VideoMarker, VideoRootProps, VideoSection } from '../type';\nimport { handleVideoKey } from '../useKeyboard';\nimport { useVideoState } from '../useVideo';\n\nconst NO_MARKERS: VideoMarker[] = [];\nconst NO_SECTIONS: VideoSection[] = [];\n\nconst Root = ({\n ref,\n player,\n src,\n poster,\n autoPlay,\n loop,\n preload = 'metadata',\n onPlay,\n onPause,\n onEnded,\n onError,\n onTimeUpdate,\n sections = NO_SECTIONS,\n markers = NO_MARKERS,\n fps = 30,\n playbackRates,\n defaultPlaybackRate,\n muted,\n onMutedChange,\n onRateChange,\n onMarkerClick,\n onRetry,\n captions = true,\n width,\n height,\n maxHeight,\n className,\n style,\n children,\n}: VideoRootProps) => {\n const [ownStore] = useState(createVideoStore);\n const store = (player as VideoStore | undefined) ?? ownStore;\n\n // Assigned during render so the store already has them when a child Frame\n // attaches its <video> in an effect, which runs before this component's own.\n store.setOptions({ defaultPlaybackRate, muted, onMutedChange, onRateChange });\n\n useImperativeHandle(ref, () => store, [store]);\n\n const sorted = useMemo(() => sortSections(sections), [sections]);\n\n useLayoutEffect(() => {\n store.setData({ fps, markers, sections: sorted });\n }, [store, fps, markers, sorted]);\n\n useLayoutEffect(() => {\n if (!captions) store.setCaptions(false);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [store]);\n\n const size = useVideoState(store, (state) => state.size);\n const aspect = size?.height ? size.width / size.height : 16 / 9;\n const sizing =\n maxHeight === undefined\n ? { height, width }\n : { maxWidth: `${Math.round(maxHeight * aspect)}px`, width: '100%' };\n\n const value = useMemo<VideoContextValue>(\n () => ({\n config: { fps, markers, onMarkerClick, onRetry, playbackRates, sections: sorted },\n media: {\n autoPlay,\n loop,\n onEnded,\n onError,\n onPause,\n onPlay,\n onTimeUpdate,\n poster,\n preload,\n src,\n },\n store,\n }),\n [\n autoPlay,\n fps,\n loop,\n markers,\n onEnded,\n onError,\n onMarkerClick,\n onPause,\n onPlay,\n onRetry,\n onTimeUpdate,\n playbackRates,\n poster,\n preload,\n sorted,\n src,\n store,\n ],\n );\n\n return (\n <VideoContext value={value}>\n <div\n ref={store.attachRoot}\n tabIndex={0}\n onKeyDown={(event) => {\n if (handleVideoKey(event, store, playbackRates)) event.preventDefault();\n }}\n {...styleProps(styles.root, className, { ...sizing, ...style })}\n >\n {children}\n </div>\n </VideoContext>\n );\n};\n\nRoot.displayName = 'VideoRoot';\n\nexport default Root;\n"],"mappings":";;;;;;;;;;;AAcA,MAAM,aAA4B,CAAC;AACnC,MAAM,cAA8B,CAAC;AAErC,MAAM,QAAQ,EACZ,KACA,QACA,KACA,QACA,UACA,MACA,UAAU,YACV,QACA,SACA,SACA,SACA,cACA,WAAW,aACX,UAAU,YACV,MAAM,IACN,eACA,qBACA,OACA,eACA,cACA,eACA,SACA,WAAW,MACX,OACA,QACA,WACA,WACA,OACA,eACoB;CACpB,MAAM,CAAC,YAAY,SAAS,gBAAgB;CAC5C,MAAM,QAAS,UAAqC;CAIpD,MAAM,WAAW;EAAE;EAAqB;EAAO;EAAe;CAAa,CAAC;CAE5E,oBAAoB,WAAW,OAAO,CAAC,KAAK,CAAC;CAE7C,MAAM,SAAS,cAAc,aAAa,QAAQ,GAAG,CAAC,QAAQ,CAAC;CAE/D,sBAAsB;EACpB,MAAM,QAAQ;GAAE;GAAK;GAAS,UAAU;EAAO,CAAC;CAClD,GAAG;EAAC;EAAO;EAAK;EAAS;CAAM,CAAC;CAEhC,sBAAsB;EACpB,IAAI,CAAC,UAAU,MAAM,YAAY,KAAK;CAExC,GAAG,CAAC,KAAK,CAAC;CAEV,MAAM,OAAO,cAAc,QAAQ,UAAU,MAAM,IAAI;CACvD,MAAM,SAAS,MAAM,SAAS,KAAK,QAAQ,KAAK,SAAS,KAAK;CAC9D,MAAM,SACJ,cAAc,KAAA,IACV;EAAE;EAAQ;CAAM,IAChB;EAAE,UAAU,GAAG,KAAK,MAAM,YAAY,MAAM,EAAE;EAAK,OAAO;CAAO;CAEvE,MAAM,QAAQ,eACL;EACL,QAAQ;GAAE;GAAK;GAAS;GAAe;GAAS;GAAe,UAAU;EAAO;EAChF,OAAO;GACL;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,OACE,oBAAC,cAAD;EAAqB;EACnB,UAAA,oBAAC,OAAD;GACE,KAAK,MAAM;GACX,UAAU;GACV,YAAY,UAAU;IACpB,IAAI,eAAe,OAAO,OAAO,aAAa,GAAG,MAAM,eAAe;GACxE;GACA,GAAI,WAAW,OAAO,MAAM,WAAW;IAAE,GAAG;IAAQ,GAAG;GAAM,CAAC;GAE7D;EACE,CAAA;CACO,CAAA;AAElB;AAEA,KAAK,cAAc"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { VideoSectionListProps } from "../type.mjs";
|
|
2
|
+
//#region src/Video/parts/SectionList.d.ts
|
|
3
|
+
declare const SectionList: {
|
|
4
|
+
({ className, style }: VideoSectionListProps): import("react").JSX.Element | null;
|
|
5
|
+
displayName: string;
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { SectionList as default };
|
|
9
|
+
//# sourceMappingURL=SectionList.d.mts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { styleProps } from "../../styles/stylex/props.mjs";
|
|
3
|
+
import { useVideoContext } from "../context.mjs";
|
|
4
|
+
import { styles } from "../style.mjs";
|
|
5
|
+
import { formatTime } from "../time.mjs";
|
|
6
|
+
import { useVideo } from "../useVideo.mjs";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/Video/parts/SectionList.tsx
|
|
9
|
+
const SectionList = ({ className, style }) => {
|
|
10
|
+
const { config, store } = useVideoContext();
|
|
11
|
+
const active = useVideo((state) => state.activeSection);
|
|
12
|
+
if (config.sections.length === 0) return null;
|
|
13
|
+
return /* @__PURE__ */ jsx("div", {
|
|
14
|
+
...styleProps(styles.sectionList, className, style),
|
|
15
|
+
children: config.sections.map((section) => /* @__PURE__ */ jsxs("button", {
|
|
16
|
+
"aria-current": section === active ? "true" : void 0,
|
|
17
|
+
"data-video-section": "",
|
|
18
|
+
type: "button",
|
|
19
|
+
...styleProps([styles.sectionChip, section === active && styles.sectionChipActive]),
|
|
20
|
+
onClick: () => store.seek(section.start),
|
|
21
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
22
|
+
...styleProps(styles.sectionChipTime),
|
|
23
|
+
children: formatTime(section.start)
|
|
24
|
+
}), section.title]
|
|
25
|
+
}, section.start))
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
SectionList.displayName = "VideoSectionList";
|
|
29
|
+
//#endregion
|
|
30
|
+
export { SectionList as default };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=SectionList.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionList.mjs","names":[],"sources":["../../../src/Video/parts/SectionList.tsx"],"sourcesContent":["'use client';\n\nimport { styleProps } from '@/styles/stylex/props';\n\nimport { useVideoContext } from '../context';\nimport { styles } from '../style';\nimport { formatTime } from '../time';\nimport type { VideoSectionListProps } from '../type';\nimport { useVideo } from '../useVideo';\n\nconst SectionList = ({ className, style }: VideoSectionListProps) => {\n const { config, store } = useVideoContext();\n const active = useVideo((state) => state.activeSection);\n if (config.sections.length === 0) return null;\n\n return (\n <div {...styleProps(styles.sectionList, className, style)}>\n {config.sections.map((section) => (\n <button\n aria-current={section === active ? 'true' : undefined}\n data-video-section=\"\"\n key={section.start}\n type=\"button\"\n {...styleProps([styles.sectionChip, section === active && styles.sectionChipActive])}\n onClick={() => store.seek(section.start)}\n >\n <span {...styleProps(styles.sectionChipTime)}>{formatTime(section.start)}</span>\n {section.title}\n </button>\n ))}\n </div>\n );\n};\n\nSectionList.displayName = 'VideoSectionList';\n\nexport default SectionList;\n"],"mappings":";;;;;;;;AAUA,MAAM,eAAe,EAAE,WAAW,YAAmC;CACnE,MAAM,EAAE,QAAQ,UAAU,gBAAgB;CAC1C,MAAM,SAAS,UAAU,UAAU,MAAM,aAAa;CACtD,IAAI,OAAO,SAAS,WAAW,GAAG,OAAO;CAEzC,OACE,oBAAC,OAAD;EAAK,GAAI,WAAW,OAAO,aAAa,WAAW,KAAK;EACrD,UAAA,OAAO,SAAS,KAAK,YACpB,qBAAC,UAAD;GACE,gBAAc,YAAY,SAAS,SAAS,KAAA;GAC5C,sBAAmB;GAEnB,MAAK;GACL,GAAI,WAAW,CAAC,OAAO,aAAa,YAAY,UAAU,OAAO,iBAAiB,CAAC;GACnF,eAAe,MAAM,KAAK,QAAQ,KAAK;GANzC,UAAA,CAQE,oBAAC,QAAD;IAAM,GAAI,WAAW,OAAO,eAAe;IAAI,UAAA,WAAW,QAAQ,KAAK;GAAQ,CAAA,GAC9E,QAAQ,KACH;EAPD,GAAA,QAAQ,KAOP,CACT;CACE,CAAA;AAET;AAEA,YAAY,cAAc"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { styleProps } from "../../styles/stylex/props.mjs";
|
|
3
|
+
import DropdownMenu from "../../DropdownMenu/DropdownMenu.mjs";
|
|
4
|
+
import { useTranslation } from "../../i18n/useTranslation.mjs";
|
|
5
|
+
import { FrameContext, useVideoContext } from "../context.mjs";
|
|
6
|
+
import { styles } from "../style.mjs";
|
|
7
|
+
import { formatTime } from "../time.mjs";
|
|
8
|
+
import { useVideo } from "../useVideo.mjs";
|
|
9
|
+
import video_default from "../../i18n/resources/en/video.mjs";
|
|
10
|
+
import { useFullscreen } from "../useFullscreen.mjs";
|
|
11
|
+
import { use, useState } from "react";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Check, ChevronRight } from "lucide-react";
|
|
14
|
+
//#region src/Video/parts/SectionMenu.tsx
|
|
15
|
+
const SectionMenu = () => {
|
|
16
|
+
const { config, store } = useVideoContext();
|
|
17
|
+
const frame = use(FrameContext);
|
|
18
|
+
const fullscreen = useFullscreen(store);
|
|
19
|
+
const { t } = useTranslation(video_default);
|
|
20
|
+
const active = useVideo((state) => state.activeSection);
|
|
21
|
+
const [shown, setShown] = useState({
|
|
22
|
+
direction: "none",
|
|
23
|
+
section: active
|
|
24
|
+
});
|
|
25
|
+
if (shown.section !== active) {
|
|
26
|
+
const from = shown.section ? config.sections.indexOf(shown.section) : -1;
|
|
27
|
+
setShown({
|
|
28
|
+
direction: (active ? config.sections.indexOf(active) : -1) >= from ? "forward" : "backward",
|
|
29
|
+
section: active
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (config.sections.length === 0) return null;
|
|
33
|
+
return /* @__PURE__ */ jsx(DropdownMenu, {
|
|
34
|
+
portalProps: fullscreen && store.root ? { container: store.root } : void 0,
|
|
35
|
+
items: config.sections.map((section) => ({
|
|
36
|
+
extra: section === active ? /* @__PURE__ */ jsx(Check, { size: 14 }) : formatTime(section.start),
|
|
37
|
+
key: `${section.start}`,
|
|
38
|
+
label: section.title,
|
|
39
|
+
onClick: () => store.seek(section.start)
|
|
40
|
+
})),
|
|
41
|
+
onOpenChange: (open) => frame?.hold(open),
|
|
42
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
43
|
+
title: t("video.sections"),
|
|
44
|
+
type: "button",
|
|
45
|
+
...styleProps(styles.chip),
|
|
46
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
47
|
+
"data-direction": shown.direction,
|
|
48
|
+
"data-video-section-label": "",
|
|
49
|
+
...styleProps([
|
|
50
|
+
styles.chipText,
|
|
51
|
+
shown.direction === "forward" && styles.chipLabelForward,
|
|
52
|
+
shown.direction === "backward" && styles.chipLabelBackward
|
|
53
|
+
]),
|
|
54
|
+
children: active?.title ?? t("video.sections")
|
|
55
|
+
}, active?.start ?? "none"), /* @__PURE__ */ jsx(ChevronRight, { size: 14 })]
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
SectionMenu.displayName = "VideoSectionMenu";
|
|
60
|
+
//#endregion
|
|
61
|
+
export { SectionMenu as default };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=SectionMenu.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionMenu.mjs","names":["videoMessages"],"sources":["../../../src/Video/parts/SectionMenu.tsx"],"sourcesContent":["'use client';\n\nimport { Check, ChevronRight } from 'lucide-react';\nimport { use, useState } from 'react';\n\nimport DropdownMenu from '@/DropdownMenu';\nimport videoMessages from '@/i18n/resources/en/video';\nimport { useTranslation } from '@/i18n/useTranslation';\nimport { styleProps } from '@/styles/stylex/props';\n\nimport { FrameContext, useVideoContext } from '../context';\nimport { styles } from '../style';\nimport { formatTime } from '../time';\nimport { useFullscreen } from '../useFullscreen';\nimport { useVideo } from '../useVideo';\n\nconst SectionMenu = () => {\n const { config, store } = useVideoContext();\n const frame = use(FrameContext);\n const fullscreen = useFullscreen(store);\n const { t } = useTranslation(videoMessages);\n const active = useVideo((state) => state.activeSection);\n const [shown, setShown] = useState({ direction: 'none', section: active });\n if (shown.section !== active) {\n const from = shown.section ? config.sections.indexOf(shown.section) : -1;\n const to = active ? config.sections.indexOf(active) : -1;\n setShown({ direction: to >= from ? 'forward' : 'backward', section: active });\n }\n if (config.sections.length === 0) return null;\n\n return (\n <DropdownMenu\n portalProps={fullscreen && store.root ? { container: store.root } : undefined}\n items={config.sections.map((section) => ({\n extra: section === active ? <Check size={14} /> : formatTime(section.start),\n key: `${section.start}`,\n label: section.title,\n onClick: () => store.seek(section.start),\n }))}\n onOpenChange={(open) => frame?.hold(open)}\n >\n <button title={t('video.sections')} type=\"button\" {...styleProps(styles.chip)}>\n <span\n data-direction={shown.direction}\n data-video-section-label=\"\"\n key={active?.start ?? 'none'}\n {...styleProps([\n styles.chipText,\n shown.direction === 'forward' && styles.chipLabelForward,\n shown.direction === 'backward' && styles.chipLabelBackward,\n ])}\n >\n {active?.title ?? t('video.sections')}\n </span>\n <ChevronRight size={14} />\n </button>\n </DropdownMenu>\n );\n};\n\nSectionMenu.displayName = 'VideoSectionMenu';\n\nexport default SectionMenu;\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAM,oBAAoB;CACxB,MAAM,EAAE,QAAQ,UAAU,gBAAgB;CAC1C,MAAM,QAAQ,IAAI,YAAY;CAC9B,MAAM,aAAa,cAAc,KAAK;CACtC,MAAM,EAAE,MAAM,eAAeA,aAAa;CAC1C,MAAM,SAAS,UAAU,UAAU,MAAM,aAAa;CACtD,MAAM,CAAC,OAAO,YAAY,SAAS;EAAE,WAAW;EAAQ,SAAS;CAAO,CAAC;CACzE,IAAI,MAAM,YAAY,QAAQ;EAC5B,MAAM,OAAO,MAAM,UAAU,OAAO,SAAS,QAAQ,MAAM,OAAO,IAAI;EAEtE,SAAS;GAAE,YADA,SAAS,OAAO,SAAS,QAAQ,MAAM,IAAI,OAC1B,OAAO,YAAY;GAAY,SAAS;EAAO,CAAC;CAC9E;CACA,IAAI,OAAO,SAAS,WAAW,GAAG,OAAO;CAEzC,OACE,oBAAC,cAAD;EACE,aAAa,cAAc,MAAM,OAAO,EAAE,WAAW,MAAM,KAAK,IAAI,KAAA;EACpE,OAAO,OAAO,SAAS,KAAK,aAAa;GACvC,OAAO,YAAY,SAAS,oBAAC,OAAD,EAAO,MAAM,GAAK,CAAA,IAAI,WAAW,QAAQ,KAAK;GAC1E,KAAK,GAAG,QAAQ;GAChB,OAAO,QAAQ;GACf,eAAe,MAAM,KAAK,QAAQ,KAAK;EACzC,EAAE;EACF,eAAe,SAAS,OAAO,KAAK,IAAI;EAExC,UAAA,qBAAC,UAAD;GAAQ,OAAO,EAAE,gBAAgB;GAAG,MAAK;GAAS,GAAI,WAAW,OAAO,IAAI;GAA5E,UAAA,CACE,oBAAC,QAAD;IACE,kBAAgB,MAAM;IACtB,4BAAyB;IAEzB,GAAI,WAAW;KACb,OAAO;KACP,MAAM,cAAc,aAAa,OAAO;KACxC,MAAM,cAAc,cAAc,OAAO;IAC3C,CAAC;IAEA,UAAA,QAAQ,SAAS,EAAE,gBAAgB;GAChC,GARC,QAAQ,SAAS,MAQlB,GACN,oBAAC,cAAD,EAAc,MAAM,GAAK,CAAA,CACnB;;CACI,CAAA;AAElB;AAEA,YAAY,cAAc"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { VideoTimelineProps } from "../type.mjs";
|
|
2
|
+
//#region src/Video/parts/Timeline.d.ts
|
|
3
|
+
declare const Timeline: {
|
|
4
|
+
({ children, className, style, thumbnails }: VideoTimelineProps): import("react").JSX.Element;
|
|
5
|
+
displayName: string;
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { Timeline as default };
|
|
9
|
+
//# sourceMappingURL=Timeline.d.mts.map
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { styleProps } from "../../styles/stylex/props.mjs";
|
|
3
|
+
import { useTranslation } from "../../i18n/useTranslation.mjs";
|
|
4
|
+
import { useVideoContext } from "../context.mjs";
|
|
5
|
+
import { markerColor, styles } from "../style.mjs";
|
|
6
|
+
import { formatTime, mergeSegments, sectionAt } from "../time.mjs";
|
|
7
|
+
import { useVideo } from "../useVideo.mjs";
|
|
8
|
+
import video_default from "../../i18n/resources/en/video.mjs";
|
|
9
|
+
import HoverPreview from "./HoverPreview.mjs";
|
|
10
|
+
import { useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
//#region src/Video/parts/Timeline.tsx
|
|
13
|
+
const SNAP_RATIO = .012;
|
|
14
|
+
const GAP_PX = 3;
|
|
15
|
+
const PREVIEW_HALF = 88;
|
|
16
|
+
const canHover = () => typeof window === "undefined" || !window.matchMedia?.("(hover: none)").matches;
|
|
17
|
+
const markerName = (marker) => [
|
|
18
|
+
formatTime(marker.time),
|
|
19
|
+
marker.label,
|
|
20
|
+
marker.content
|
|
21
|
+
].filter((part) => typeof part === "string").join(" ");
|
|
22
|
+
const Timeline = ({ children, className, style, thumbnails = true }) => {
|
|
23
|
+
const { config, media, store } = useVideoContext();
|
|
24
|
+
const { t } = useTranslation(video_default);
|
|
25
|
+
const duration = useVideo((state) => Number.isFinite(state.duration) ? state.duration : 0);
|
|
26
|
+
const trackRef = useRef(null);
|
|
27
|
+
const [width, setWidth] = useState(0);
|
|
28
|
+
const [hover, setHover] = useState(null);
|
|
29
|
+
const [hovering, setHovering] = useState(false);
|
|
30
|
+
useLayoutEffect(() => {
|
|
31
|
+
const track = trackRef.current;
|
|
32
|
+
if (!track) return;
|
|
33
|
+
setWidth(track.getBoundingClientRect().width);
|
|
34
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
35
|
+
const observer = new ResizeObserver(([entry]) => setWidth(entry.contentRect.width));
|
|
36
|
+
observer.observe(track);
|
|
37
|
+
return () => observer.disconnect();
|
|
38
|
+
}, []);
|
|
39
|
+
useLayoutEffect(() => {
|
|
40
|
+
const track = trackRef.current;
|
|
41
|
+
if (!track) return;
|
|
42
|
+
const setOnChange = (name, value) => {
|
|
43
|
+
if (track.getAttribute(name) !== value) track.setAttribute(name, value);
|
|
44
|
+
};
|
|
45
|
+
const paint = (state) => {
|
|
46
|
+
track.style.setProperty("--video-time", String(state.time));
|
|
47
|
+
setOnChange("aria-valuenow", String(Math.round(state.time)));
|
|
48
|
+
setOnChange("aria-valuetext", [`${formatTime(state.time)} / ${formatTime(state.duration)}`, state.activeSection?.title].filter(Boolean).join(", "));
|
|
49
|
+
};
|
|
50
|
+
paint(store.getState());
|
|
51
|
+
return store.subscribe(paint);
|
|
52
|
+
}, [store]);
|
|
53
|
+
const { hairlines, segments } = useMemo(() => mergeSegments(config.sections, duration, width), [
|
|
54
|
+
config.sections,
|
|
55
|
+
duration,
|
|
56
|
+
width
|
|
57
|
+
]);
|
|
58
|
+
const visibleMarkers = useMemo(() => config.markers.filter((marker) => marker.time >= 0 && marker.time <= duration), [config.markers, duration]);
|
|
59
|
+
const pct = (seconds) => duration > 0 ? seconds / duration * 100 : 0;
|
|
60
|
+
const timeAt = (element, clientX) => {
|
|
61
|
+
const box = element.getBoundingClientRect();
|
|
62
|
+
if (!box.width) return 0;
|
|
63
|
+
return Math.min(Math.max((clientX - box.left) / box.width, 0), 1) * duration;
|
|
64
|
+
};
|
|
65
|
+
const onPointerDown = (event) => {
|
|
66
|
+
if (event.button !== 0 || !duration) return;
|
|
67
|
+
const element = event.currentTarget;
|
|
68
|
+
store.seek(timeAt(element, event.clientX));
|
|
69
|
+
element.setPointerCapture?.(event.pointerId);
|
|
70
|
+
const move = (next) => store.seek(timeAt(element, next.clientX));
|
|
71
|
+
const up = () => {
|
|
72
|
+
element.removeEventListener("pointermove", move);
|
|
73
|
+
element.removeEventListener("pointerup", up);
|
|
74
|
+
element.removeEventListener("pointercancel", up);
|
|
75
|
+
};
|
|
76
|
+
element.addEventListener("pointermove", move);
|
|
77
|
+
element.addEventListener("pointerup", up);
|
|
78
|
+
element.addEventListener("pointercancel", up);
|
|
79
|
+
};
|
|
80
|
+
const onPointerMove = (event) => {
|
|
81
|
+
if (event.pointerType === "touch" || !duration || !canHover()) return;
|
|
82
|
+
const element = event.currentTarget;
|
|
83
|
+
const box = element.getBoundingClientRect();
|
|
84
|
+
const seconds = timeAt(element, event.clientX);
|
|
85
|
+
const snap = duration * SNAP_RATIO;
|
|
86
|
+
const marker = visibleMarkers.find((item) => Math.abs(item.time - seconds) < snap);
|
|
87
|
+
setHovering(true);
|
|
88
|
+
setHover({
|
|
89
|
+
marker,
|
|
90
|
+
time: marker?.time ?? seconds,
|
|
91
|
+
x: Math.min(Math.max(event.clientX - box.left, PREVIEW_HALF), Math.max(box.width - PREVIEW_HALF, PREVIEW_HALF))
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
95
|
+
...styleProps(void 0, className, {
|
|
96
|
+
position: "relative",
|
|
97
|
+
...style
|
|
98
|
+
}),
|
|
99
|
+
children: [
|
|
100
|
+
hover && /* @__PURE__ */ jsx(HoverPreview, {
|
|
101
|
+
marker: hover.marker,
|
|
102
|
+
section: sectionAt(config.sections, hover.time),
|
|
103
|
+
src: media.src,
|
|
104
|
+
thumbnail: thumbnails,
|
|
105
|
+
time: hover.time,
|
|
106
|
+
visible: hovering,
|
|
107
|
+
x: hover.x
|
|
108
|
+
}),
|
|
109
|
+
/* @__PURE__ */ jsxs("div", {
|
|
110
|
+
"aria-label": t("video.seek"),
|
|
111
|
+
"aria-valuemax": Math.round(duration),
|
|
112
|
+
"aria-valuemin": 0,
|
|
113
|
+
ref: trackRef,
|
|
114
|
+
role: "slider",
|
|
115
|
+
...styleProps(styles.track),
|
|
116
|
+
onPointerDown,
|
|
117
|
+
onPointerLeave: () => setHovering(false),
|
|
118
|
+
onPointerMove,
|
|
119
|
+
children: [
|
|
120
|
+
segments.map((segment, index) => {
|
|
121
|
+
const span = segment.end - segment.start;
|
|
122
|
+
const hovered = hovering && hover !== null && hover.time >= segment.start && hover.time < segment.end;
|
|
123
|
+
const hoverFill = hovering && hover ? Math.min(Math.max((hover.time - segment.start) / span, 0), 1) : 0;
|
|
124
|
+
const leftInset = index === 0 ? 0 : GAP_PX / 2;
|
|
125
|
+
const rightInset = index === segments.length - 1 ? 0 : GAP_PX / 2;
|
|
126
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
127
|
+
"data-video-segment": "",
|
|
128
|
+
...styleProps([styles.segment, hovered && styles.segmentHovered], void 0, {
|
|
129
|
+
left: `calc(${pct(segment.start)}% + ${leftInset}px)`,
|
|
130
|
+
width: `calc(${pct(span)}% - ${leftInset + rightInset}px)`
|
|
131
|
+
}),
|
|
132
|
+
children: [hoverFill > 0 && /* @__PURE__ */ jsx("div", { ...styleProps(styles.segmentFill, void 0, {
|
|
133
|
+
background: "rgb(255 255 255 / 32%)",
|
|
134
|
+
width: `${hoverFill * 100}%`
|
|
135
|
+
}) }), /* @__PURE__ */ jsx("div", { ...styleProps(styles.segmentFill, void 0, {
|
|
136
|
+
background: "#fff",
|
|
137
|
+
width: `calc(clamp(0, (var(--video-time, 0) - ${segment.start}) / ${span}, 1) * 100%)`
|
|
138
|
+
}) })]
|
|
139
|
+
}, segment.start);
|
|
140
|
+
}),
|
|
141
|
+
hairlines.map((at) => /* @__PURE__ */ jsx("div", { ...styleProps(styles.hairline, void 0, { left: `${pct(at)}%` }) }, at)),
|
|
142
|
+
/* @__PURE__ */ jsx("div", { ...styleProps(styles.head, void 0, { left: duration > 0 ? `calc(var(--video-time, 0) / ${duration} * 100%)` : 0 }) }),
|
|
143
|
+
visibleMarkers.map((marker, index) => /* @__PURE__ */ jsx("button", {
|
|
144
|
+
"aria-label": markerName(marker),
|
|
145
|
+
type: "button",
|
|
146
|
+
...styleProps(styles.marker, void 0, {
|
|
147
|
+
background: markerColor(marker.color),
|
|
148
|
+
left: `${pct(marker.time)}%`
|
|
149
|
+
}),
|
|
150
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
151
|
+
onClick: (event) => {
|
|
152
|
+
event.stopPropagation();
|
|
153
|
+
store.pause();
|
|
154
|
+
store.seek(marker.time);
|
|
155
|
+
store.setCaptions(true);
|
|
156
|
+
config.onMarkerClick?.(marker);
|
|
157
|
+
}
|
|
158
|
+
}, marker.key ?? `${marker.time}-${index}`))
|
|
159
|
+
]
|
|
160
|
+
}),
|
|
161
|
+
children
|
|
162
|
+
]
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
Timeline.displayName = "VideoTimeline";
|
|
166
|
+
//#endregion
|
|
167
|
+
export { Timeline as default };
|
|
168
|
+
|
|
169
|
+
//# sourceMappingURL=Timeline.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Timeline.mjs","names":["videoMessages"],"sources":["../../../src/Video/parts/Timeline.tsx"],"sourcesContent":["'use client';\n\nimport {\n type PointerEvent as ReactPointerEvent,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport videoMessages from '@/i18n/resources/en/video';\nimport { useTranslation } from '@/i18n/useTranslation';\nimport { styleProps } from '@/styles/stylex/props';\n\nimport { useVideoContext } from '../context';\nimport { markerColor, styles } from '../style';\nimport { formatTime, mergeSegments, sectionAt } from '../time';\nimport type { VideoMarker, VideoState, VideoTimelineProps } from '../type';\nimport { useVideo } from '../useVideo';\nimport HoverPreview from './HoverPreview';\n\nconst SNAP_RATIO = 0.012;\nconst GAP_PX = 3;\nconst PREVIEW_HALF = 88;\n\ninterface Hover {\n marker?: VideoMarker;\n time: number;\n x: number;\n}\n\nconst canHover = () =>\n typeof window === 'undefined' || !window.matchMedia?.('(hover: none)').matches;\n\nconst markerName = (marker: VideoMarker) =>\n [formatTime(marker.time), marker.label, marker.content]\n .filter((part) => typeof part === 'string')\n .join(' ');\n\nconst Timeline = ({ children, className, style, thumbnails = true }: VideoTimelineProps) => {\n const { config, media, store } = useVideoContext();\n const { t } = useTranslation(videoMessages);\n const duration = useVideo((state) => (Number.isFinite(state.duration) ? state.duration : 0));\n const trackRef = useRef<HTMLDivElement>(null);\n const [width, setWidth] = useState(0);\n const [hover, setHover] = useState<Hover | null>(null);\n const [hovering, setHovering] = useState(false);\n\n useLayoutEffect(() => {\n const track = trackRef.current;\n if (!track) return;\n setWidth(track.getBoundingClientRect().width);\n if (typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver(([entry]) => setWidth(entry.contentRect.width));\n observer.observe(track);\n return () => observer.disconnect();\n }, []);\n\n // Playback must not re-render the timeline: the playhead and the played\n // fills read --video-time, written straight to the track on every frame.\n useLayoutEffect(() => {\n const track = trackRef.current;\n if (!track) return;\n const setOnChange = (name: string, value: string) => {\n if (track.getAttribute(name) !== value) track.setAttribute(name, value);\n };\n const paint = (state: VideoState) => {\n track.style.setProperty('--video-time', String(state.time));\n setOnChange('aria-valuenow', String(Math.round(state.time)));\n setOnChange(\n 'aria-valuetext',\n [`${formatTime(state.time)} / ${formatTime(state.duration)}`, state.activeSection?.title]\n .filter(Boolean)\n .join(', '),\n );\n };\n paint(store.getState());\n return store.subscribe(paint);\n }, [store]);\n\n const { hairlines, segments } = useMemo(\n () => mergeSegments(config.sections, duration, width),\n [config.sections, duration, width],\n );\n\n const visibleMarkers = useMemo(\n () => config.markers.filter((marker) => marker.time >= 0 && marker.time <= duration),\n [config.markers, duration],\n );\n\n const pct = (seconds: number) => (duration > 0 ? (seconds / duration) * 100 : 0);\n const timeAt = (element: HTMLElement, clientX: number) => {\n const box = element.getBoundingClientRect();\n if (!box.width) return 0;\n return Math.min(Math.max((clientX - box.left) / box.width, 0), 1) * duration;\n };\n\n const onPointerDown = (event: ReactPointerEvent<HTMLDivElement>) => {\n if (event.button !== 0 || !duration) return;\n const element = event.currentTarget;\n store.seek(timeAt(element, event.clientX));\n element.setPointerCapture?.(event.pointerId);\n const move = (next: PointerEvent) => store.seek(timeAt(element, next.clientX));\n const up = () => {\n element.removeEventListener('pointermove', move);\n element.removeEventListener('pointerup', up);\n element.removeEventListener('pointercancel', up);\n };\n element.addEventListener('pointermove', move);\n element.addEventListener('pointerup', up);\n element.addEventListener('pointercancel', up);\n };\n\n const onPointerMove = (event: ReactPointerEvent<HTMLDivElement>) => {\n if (event.pointerType === 'touch' || !duration || !canHover()) return;\n const element = event.currentTarget;\n const box = element.getBoundingClientRect();\n const seconds = timeAt(element, event.clientX);\n const snap = duration * SNAP_RATIO;\n const marker = visibleMarkers.find((item) => Math.abs(item.time - seconds) < snap);\n setHovering(true);\n setHover({\n marker,\n time: marker?.time ?? seconds,\n x: Math.min(\n Math.max(event.clientX - box.left, PREVIEW_HALF),\n Math.max(box.width - PREVIEW_HALF, PREVIEW_HALF),\n ),\n });\n };\n\n return (\n <div {...styleProps(undefined, className, { position: 'relative', ...style })}>\n {hover && (\n <HoverPreview\n marker={hover.marker}\n section={sectionAt(config.sections, hover.time)}\n src={media.src}\n thumbnail={thumbnails}\n time={hover.time}\n visible={hovering}\n x={hover.x}\n />\n )}\n <div\n aria-label={t('video.seek')}\n aria-valuemax={Math.round(duration)}\n aria-valuemin={0}\n ref={trackRef}\n role=\"slider\"\n {...styleProps(styles.track)}\n onPointerDown={onPointerDown}\n onPointerLeave={() => setHovering(false)}\n onPointerMove={onPointerMove}\n >\n {segments.map((segment, index) => {\n const span = segment.end - segment.start;\n const hovered =\n hovering && hover !== null && hover.time >= segment.start && hover.time < segment.end;\n const hoverFill =\n hovering && hover ? Math.min(Math.max((hover.time - segment.start) / span, 0), 1) : 0;\n const leftInset = index === 0 ? 0 : GAP_PX / 2;\n const rightInset = index === segments.length - 1 ? 0 : GAP_PX / 2;\n return (\n <div\n data-video-segment=\"\"\n key={segment.start}\n {...styleProps([styles.segment, hovered && styles.segmentHovered], undefined, {\n left: `calc(${pct(segment.start)}% + ${leftInset}px)`,\n width: `calc(${pct(span)}% - ${leftInset + rightInset}px)`,\n })}\n >\n {hoverFill > 0 && (\n <div\n {...styleProps(styles.segmentFill, undefined, {\n background: 'rgb(255 255 255 / 32%)',\n width: `${hoverFill * 100}%`,\n })}\n />\n )}\n <div\n {...styleProps(styles.segmentFill, undefined, {\n background: '#fff',\n width: `calc(clamp(0, (var(--video-time, 0) - ${segment.start}) / ${span}, 1) * 100%)`,\n })}\n />\n </div>\n );\n })}\n {hairlines.map((at) => (\n <div key={at} {...styleProps(styles.hairline, undefined, { left: `${pct(at)}%` })} />\n ))}\n <div\n {...styleProps(styles.head, undefined, {\n left: duration > 0 ? `calc(var(--video-time, 0) / ${duration} * 100%)` : 0,\n })}\n />\n {visibleMarkers.map((marker, index) => (\n <button\n aria-label={markerName(marker)}\n key={marker.key ?? `${marker.time}-${index}`}\n type=\"button\"\n {...styleProps(styles.marker, undefined, {\n background: markerColor(marker.color),\n left: `${pct(marker.time)}%`,\n })}\n onPointerDown={(event) => event.stopPropagation()}\n onClick={(event) => {\n event.stopPropagation();\n store.pause();\n store.seek(marker.time);\n store.setCaptions(true);\n config.onMarkerClick?.(marker);\n }}\n />\n ))}\n </div>\n {children}\n </div>\n );\n};\n\nTimeline.displayName = 'VideoTimeline';\n\nexport default Timeline;\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAM,aAAa;AACnB,MAAM,SAAS;AACf,MAAM,eAAe;AAQrB,MAAM,iBACJ,OAAO,WAAW,eAAe,CAAC,OAAO,aAAa,eAAe,CAAC,CAAC;AAEzE,MAAM,cAAc,WAClB;CAAC,WAAW,OAAO,IAAI;CAAG,OAAO;CAAO,OAAO;AAAO,CAAC,CACpD,QAAQ,SAAS,OAAO,SAAS,QAAQ,CAAC,CAC1C,KAAK,GAAG;AAEb,MAAM,YAAY,EAAE,UAAU,WAAW,OAAO,aAAa,WAA+B;CAC1F,MAAM,EAAE,QAAQ,OAAO,UAAU,gBAAgB;CACjD,MAAM,EAAE,MAAM,eAAeA,aAAa;CAC1C,MAAM,WAAW,UAAU,UAAW,OAAO,SAAS,MAAM,QAAQ,IAAI,MAAM,WAAW,CAAE;CAC3F,MAAM,WAAW,OAAuB,IAAI;CAC5C,MAAM,CAAC,OAAO,YAAY,SAAS,CAAC;CACpC,MAAM,CAAC,OAAO,YAAY,SAAuB,IAAI;CACrD,MAAM,CAAC,UAAU,e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