@hanifhan1f/vidstack-react 1.12.13
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/.templates/sandbox/document.css +27 -0
- package/.templates/sandbox/favicon-32x32.png +0 -0
- package/.templates/sandbox/index.html +21 -0
- package/.templates/sandbox/main.tsx +12 -0
- package/.templates/sandbox/player.css +39 -0
- package/.templates/sandbox/player.tsx +121 -0
- package/.templates/sandbox/tracks.ts +23 -0
- package/LICENSE +21 -0
- package/README.md +23 -0
- package/analyze.config.ts +7 -0
- package/build/build-icons.js +62 -0
- package/npm/analyze.json.d.ts +7 -0
- package/package.json +162 -0
- package/rollup.config.ts +256 -0
- package/src/components/announcer.tsx +47 -0
- package/src/components/layouts/default/audio-layout.tsx +231 -0
- package/src/components/layouts/default/context.ts +28 -0
- package/src/components/layouts/default/hooks.ts +13 -0
- package/src/components/layouts/default/icons.tsx +225 -0
- package/src/components/layouts/default/index.ts +11 -0
- package/src/components/layouts/default/media-layout.tsx +259 -0
- package/src/components/layouts/default/slots.tsx +98 -0
- package/src/components/layouts/default/ui/announcer.tsx +22 -0
- package/src/components/layouts/default/ui/buttons.tsx +301 -0
- package/src/components/layouts/default/ui/captions.tsx +16 -0
- package/src/components/layouts/default/ui/controls.tsx +12 -0
- package/src/components/layouts/default/ui/keyboard-display.tsx +132 -0
- package/src/components/layouts/default/ui/menus/accessibility-menu.tsx +100 -0
- package/src/components/layouts/default/ui/menus/audio-menu.tsx +167 -0
- package/src/components/layouts/default/ui/menus/captions-menu.tsx +61 -0
- package/src/components/layouts/default/ui/menus/chapters-menu.tsx +132 -0
- package/src/components/layouts/default/ui/menus/font-menu.tsx +331 -0
- package/src/components/layouts/default/ui/menus/items/menu-checkbox.tsx +72 -0
- package/src/components/layouts/default/ui/menus/items/menu-items.tsx +135 -0
- package/src/components/layouts/default/ui/menus/items/menu-slider.tsx +92 -0
- package/src/components/layouts/default/ui/menus/playback-menu.tsx +232 -0
- package/src/components/layouts/default/ui/menus/settings-menu.tsx +114 -0
- package/src/components/layouts/default/ui/menus/utils.ts +12 -0
- package/src/components/layouts/default/ui/sliders.tsx +136 -0
- package/src/components/layouts/default/ui/time.tsx +73 -0
- package/src/components/layouts/default/ui/title.tsx +24 -0
- package/src/components/layouts/default/ui/tooltip.tsx +27 -0
- package/src/components/layouts/default/ui.ts +8 -0
- package/src/components/layouts/default/video-layout.tsx +344 -0
- package/src/components/layouts/plyr/context.ts +26 -0
- package/src/components/layouts/plyr/icons/plyr-airplay.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-captions-off.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-captions-on.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-download.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-enter-fullscreen.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-exit-fullscreen.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-fast-forward.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-muted.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-pause.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-pip.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-play.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-restart.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-rewind.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-settings.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-volume.js +1 -0
- package/src/components/layouts/plyr/icons.tsx +71 -0
- package/src/components/layouts/plyr/index.ts +11 -0
- package/src/components/layouts/plyr/layout.tsx +1024 -0
- package/src/components/layouts/plyr/props.ts +104 -0
- package/src/components/layouts/plyr/slots.tsx +52 -0
- package/src/components/layouts/remotion-ui.ts +13 -0
- package/src/components/layouts/utils.ts +17 -0
- package/src/components/player-callbacks.ts +67 -0
- package/src/components/player.tsx +67 -0
- package/src/components/primitives/instances.ts +92 -0
- package/src/components/primitives/nodes.tsx +58 -0
- package/src/components/primitives/slot.tsx +132 -0
- package/src/components/provider.tsx +187 -0
- package/src/components/text-track.tsx +106 -0
- package/src/components/ui/buttons/airplay-button.tsx +53 -0
- package/src/components/ui/buttons/caption-button.tsx +55 -0
- package/src/components/ui/buttons/fullscreen-button.tsx +55 -0
- package/src/components/ui/buttons/google-cast-button.tsx +53 -0
- package/src/components/ui/buttons/live-button.tsx +56 -0
- package/src/components/ui/buttons/mute-button.tsx +60 -0
- package/src/components/ui/buttons/pip-button.tsx +54 -0
- package/src/components/ui/buttons/play-button.tsx +53 -0
- package/src/components/ui/buttons/seek-button.tsx +55 -0
- package/src/components/ui/buttons/toggle-button.tsx +51 -0
- package/src/components/ui/caption.tsx +70 -0
- package/src/components/ui/captions.tsx +41 -0
- package/src/components/ui/chapter-title.tsx +40 -0
- package/src/components/ui/controls.tsx +90 -0
- package/src/components/ui/gesture.tsx +43 -0
- package/src/components/ui/menu.tsx +251 -0
- package/src/components/ui/poster.tsx +101 -0
- package/src/components/ui/radio-group.tsx +88 -0
- package/src/components/ui/sliders/audio-gain-slider.tsx +55 -0
- package/src/components/ui/sliders/quality-slider.tsx +54 -0
- package/src/components/ui/sliders/slider-callbacks.ts +14 -0
- package/src/components/ui/sliders/slider-value.tsx +13 -0
- package/src/components/ui/sliders/slider.tsx +254 -0
- package/src/components/ui/sliders/speed-slider.tsx +54 -0
- package/src/components/ui/sliders/time-slider.tsx +379 -0
- package/src/components/ui/sliders/volume-slider.tsx +55 -0
- package/src/components/ui/spinner.tsx +105 -0
- package/src/components/ui/thumbnail.tsx +82 -0
- package/src/components/ui/time.tsx +77 -0
- package/src/components/ui/title.tsx +32 -0
- package/src/components/ui/tooltip.tsx +135 -0
- package/src/globals.d.ts +3 -0
- package/src/hooks/create-text-track.ts +22 -0
- package/src/hooks/options/use-audio-gain-options.ts +75 -0
- package/src/hooks/options/use-audio-options.ts +71 -0
- package/src/hooks/options/use-caption-options.ts +95 -0
- package/src/hooks/options/use-chapter-options.ts +97 -0
- package/src/hooks/options/use-playback-rate-options.ts +75 -0
- package/src/hooks/options/use-video-quality-options.ts +123 -0
- package/src/hooks/use-active-text-cues.ts +28 -0
- package/src/hooks/use-active-text-track.ts +19 -0
- package/src/hooks/use-chapter-title.ts +12 -0
- package/src/hooks/use-dom.ts +121 -0
- package/src/hooks/use-media-context.ts +6 -0
- package/src/hooks/use-media-player.ts +19 -0
- package/src/hooks/use-media-provider.ts +31 -0
- package/src/hooks/use-media-remote.ts +37 -0
- package/src/hooks/use-media-state.ts +58 -0
- package/src/hooks/use-signals.ts +24 -0
- package/src/hooks/use-slider-preview.ts +126 -0
- package/src/hooks/use-slider-state.ts +63 -0
- package/src/hooks/use-state.ts +47 -0
- package/src/hooks/use-text-cues.ts +33 -0
- package/src/hooks/use-thumbnails.ts +69 -0
- package/src/icon.ts +37 -0
- package/src/icons.ts +754 -0
- package/src/index.ts +181 -0
- package/src/providers/remotion/index.ts +10 -0
- package/src/providers/remotion/layout-engine.ts +123 -0
- package/src/providers/remotion/loader.ts +35 -0
- package/src/providers/remotion/playback-engine.ts +142 -0
- package/src/providers/remotion/provider.tsx +514 -0
- package/src/providers/remotion/type-check.ts +13 -0
- package/src/providers/remotion/types.ts +94 -0
- package/src/providers/remotion/ui/context.tsx +120 -0
- package/src/providers/remotion/ui/error-boundary.tsx +57 -0
- package/src/providers/remotion/ui/poster.tsx +33 -0
- package/src/providers/remotion/ui/slider-thumbnail.tsx +41 -0
- package/src/providers/remotion/ui/thumbnail.tsx +166 -0
- package/src/providers/remotion/validate.ts +220 -0
- package/src/source.ts +5 -0
- package/src/utils.ts +27 -0
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +11 -0
- package/types/react/src/components/announcer.d.ts +16 -0
- package/types/react/src/components/layouts/default/audio-layout.d.ts +27 -0
- package/types/react/src/components/layouts/default/context.d.ts +14 -0
- package/types/react/src/components/layouts/default/hooks.d.ts +2 -0
- package/types/react/src/components/layouts/default/icons.d.ts +95 -0
- package/types/react/src/components/layouts/default/index.d.ts +5 -0
- package/types/react/src/components/layouts/default/media-layout.d.ts +133 -0
- package/types/react/src/components/layouts/default/slots.d.ts +22 -0
- package/types/react/src/components/layouts/default/ui/announcer.d.ts +6 -0
- package/types/react/src/components/layouts/default/ui/buttons.d.ts +54 -0
- package/types/react/src/components/layouts/default/ui/captions.d.ts +6 -0
- package/types/react/src/components/layouts/default/ui/controls.d.ts +6 -0
- package/types/react/src/components/layouts/default/ui/keyboard-display.d.ts +8 -0
- package/types/react/src/components/layouts/default/ui/menus/accessibility-menu.d.ts +10 -0
- package/types/react/src/components/layouts/default/ui/menus/audio-menu.d.ts +10 -0
- package/types/react/src/components/layouts/default/ui/menus/captions-menu.d.ts +10 -0
- package/types/react/src/components/layouts/default/ui/menus/chapters-menu.d.ts +7 -0
- package/types/react/src/components/layouts/default/ui/menus/font-menu.d.ts +6 -0
- package/types/react/src/components/layouts/default/ui/menus/items/menu-checkbox.d.ts +13 -0
- package/types/react/src/components/layouts/default/ui/menus/items/menu-items.d.ts +49 -0
- package/types/react/src/components/layouts/default/ui/menus/items/menu-slider.d.ts +26 -0
- package/types/react/src/components/layouts/default/ui/menus/playback-menu.d.ts +10 -0
- package/types/react/src/components/layouts/default/ui/menus/settings-menu.d.ts +15 -0
- package/types/react/src/components/layouts/default/ui/menus/utils.d.ts +1 -0
- package/types/react/src/components/layouts/default/ui/sliders.d.ts +24 -0
- package/types/react/src/components/layouts/default/ui/time.d.ts +30 -0
- package/types/react/src/components/layouts/default/ui/title.d.ts +6 -0
- package/types/react/src/components/layouts/default/ui/tooltip.d.ts +12 -0
- package/types/react/src/components/layouts/default/ui.d.ts +8 -0
- package/types/react/src/components/layouts/default/video-layout.d.ts +47 -0
- package/types/react/src/components/layouts/plyr/context.d.ts +12 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-airplay.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-captions-off.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-captions-on.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-download.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-enter-fullscreen.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-exit-fullscreen.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-fast-forward.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-muted.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-pause.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-pip.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-play.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-restart.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-rewind.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-settings.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-volume.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons.d.ts +25 -0
- package/types/react/src/components/layouts/plyr/index.d.ts +6 -0
- package/types/react/src/components/layouts/plyr/layout.d.ts +17 -0
- package/types/react/src/components/layouts/plyr/props.d.ts +71 -0
- package/types/react/src/components/layouts/plyr/slots.d.ts +9 -0
- package/types/react/src/components/layouts/remotion-ui.d.ts +3 -0
- package/types/react/src/components/layouts/utils.d.ts +1 -0
- package/types/react/src/components/player-callbacks.d.ts +6 -0
- package/types/react/src/components/player.d.ts +32 -0
- package/types/react/src/components/primitives/instances.d.ts +83 -0
- package/types/react/src/components/primitives/nodes.d.ts +15 -0
- package/types/react/src/components/primitives/slot.d.ts +11 -0
- package/types/react/src/components/provider.d.ts +26 -0
- package/types/react/src/components/text-track.d.ts +100 -0
- package/types/react/src/components/ui/buttons/airplay-button.d.ts +22 -0
- package/types/react/src/components/ui/buttons/caption-button.d.ts +24 -0
- package/types/react/src/components/ui/buttons/fullscreen-button.d.ts +24 -0
- package/types/react/src/components/ui/buttons/google-cast-button.d.ts +22 -0
- package/types/react/src/components/ui/buttons/live-button.d.ts +26 -0
- package/types/react/src/components/ui/buttons/mute-button.d.ts +30 -0
- package/types/react/src/components/ui/buttons/pip-button.d.ts +24 -0
- package/types/react/src/components/ui/buttons/play-button.d.ts +23 -0
- package/types/react/src/components/ui/buttons/seek-button.d.ts +25 -0
- package/types/react/src/components/ui/buttons/toggle-button.d.ts +22 -0
- package/types/react/src/components/ui/caption.d.ts +11 -0
- package/types/react/src/components/ui/captions.d.ts +20 -0
- package/types/react/src/components/ui/chapter-title.d.ts +20 -0
- package/types/react/src/components/ui/controls.d.ts +40 -0
- package/types/react/src/components/ui/gesture.d.ts +20 -0
- package/types/react/src/components/ui/menu.d.ts +102 -0
- package/types/react/src/components/ui/poster.d.ts +25 -0
- package/types/react/src/components/ui/radio-group.d.ts +39 -0
- package/types/react/src/components/ui/sliders/audio-gain-slider.d.ts +29 -0
- package/types/react/src/components/ui/sliders/quality-slider.d.ts +28 -0
- package/types/react/src/components/ui/sliders/slider-callbacks.d.ts +6 -0
- package/types/react/src/components/ui/sliders/slider-value.d.ts +9 -0
- package/types/react/src/components/ui/sliders/slider.d.ts +134 -0
- package/types/react/src/components/ui/sliders/speed-slider.d.ts +28 -0
- package/types/react/src/components/ui/sliders/time-slider.d.ts +124 -0
- package/types/react/src/components/ui/sliders/volume-slider.d.ts +29 -0
- package/types/react/src/components/ui/spinner.d.ts +31 -0
- package/types/react/src/components/ui/thumbnail.d.ts +26 -0
- package/types/react/src/components/ui/time.d.ts +20 -0
- package/types/react/src/components/ui/title.d.ts +15 -0
- package/types/react/src/components/ui/tooltip.d.ts +63 -0
- package/types/react/src/hooks/create-text-track.d.ts +7 -0
- package/types/react/src/hooks/options/use-audio-gain-options.d.ts +22 -0
- package/types/react/src/hooks/options/use-audio-options.d.ts +17 -0
- package/types/react/src/hooks/options/use-caption-options.d.ts +24 -0
- package/types/react/src/hooks/options/use-chapter-options.d.ts +18 -0
- package/types/react/src/hooks/options/use-playback-rate-options.d.ts +22 -0
- package/types/react/src/hooks/options/use-video-quality-options.d.ts +35 -0
- package/types/react/src/hooks/use-active-text-cues.d.ts +6 -0
- package/types/react/src/hooks/use-active-text-track.d.ts +5 -0
- package/types/react/src/hooks/use-chapter-title.d.ts +4 -0
- package/types/react/src/hooks/use-dom.d.ts +9 -0
- package/types/react/src/hooks/use-media-context.d.ts +1 -0
- package/types/react/src/hooks/use-media-player.d.ts +7 -0
- package/types/react/src/hooks/use-media-provider.d.ts +7 -0
- package/types/react/src/hooks/use-media-remote.d.ts +12 -0
- package/types/react/src/hooks/use-media-state.d.ts +15 -0
- package/types/react/src/hooks/use-signals.d.ts +5 -0
- package/types/react/src/hooks/use-slider-preview.d.ts +27 -0
- package/types/react/src/hooks/use-slider-state.d.ts +16 -0
- package/types/react/src/hooks/use-state.d.ts +18 -0
- package/types/react/src/hooks/use-text-cues.d.ts +6 -0
- package/types/react/src/hooks/use-thumbnails.d.ts +16 -0
- package/types/react/src/icon.d.ts +17 -0
- package/types/react/src/icons.d.ts +215 -0
- package/types/react/src/index.d.ts +78 -0
- package/types/react/src/providers/remotion/index.d.ts +7 -0
- package/types/react/src/providers/remotion/layout-engine.d.ts +8 -0
- package/types/react/src/providers/remotion/loader.d.ts +9 -0
- package/types/react/src/providers/remotion/playback-engine.d.ts +11 -0
- package/types/react/src/providers/remotion/provider.d.ts +26 -0
- package/types/react/src/providers/remotion/type-check.d.ts +6 -0
- package/types/react/src/providers/remotion/types.d.ts +91 -0
- package/types/react/src/providers/remotion/ui/context.d.ts +17 -0
- package/types/react/src/providers/remotion/ui/error-boundary.d.ts +21 -0
- package/types/react/src/providers/remotion/ui/poster.d.ts +18 -0
- package/types/react/src/providers/remotion/ui/slider-thumbnail.d.ts +17 -0
- package/types/react/src/providers/remotion/ui/thumbnail.d.ts +32 -0
- package/types/react/src/providers/remotion/validate.d.ts +12 -0
- package/types/react/src/source.d.ts +3 -0
- package/types/react/src/utils.d.ts +3 -0
- package/types/vidstack/src/core/api/src-types.d.ts +50 -0
- package/types/vidstack/src/utils/mime.d.ts +15 -0
- package/types/vidstack/src/utils/network.d.ts +17 -0
- package/types/vidstack/src/utils/support.d.ts +72 -0
- package/vite.config.ts +23 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { isBoolean, isKeyboardClick } from 'maverick.js/std';
|
|
4
|
+
|
|
5
|
+
export interface DefaultMenuCheckboxProps {
|
|
6
|
+
label: string;
|
|
7
|
+
checked?: boolean;
|
|
8
|
+
storageKey?: string;
|
|
9
|
+
defaultChecked?: boolean;
|
|
10
|
+
onChange?(checked: boolean, trigger?: Event): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function DefaultMenuCheckbox({
|
|
14
|
+
label,
|
|
15
|
+
checked,
|
|
16
|
+
storageKey,
|
|
17
|
+
defaultChecked = false,
|
|
18
|
+
onChange,
|
|
19
|
+
}: DefaultMenuCheckboxProps) {
|
|
20
|
+
const [isChecked, setIsChecked] = React.useState(defaultChecked),
|
|
21
|
+
[isActive, setIsActive] = React.useState(false);
|
|
22
|
+
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
const savedValue = storageKey ? localStorage.getItem(storageKey) : null,
|
|
25
|
+
checked = !!(savedValue ?? defaultChecked);
|
|
26
|
+
setIsChecked(checked);
|
|
27
|
+
onChange?.(checked);
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
if (isBoolean(checked)) setIsChecked(checked);
|
|
32
|
+
}, [checked]);
|
|
33
|
+
|
|
34
|
+
function onPress(event?: React.PointerEvent | React.KeyboardEvent) {
|
|
35
|
+
if (event && 'button' in event && event?.button === 1) return;
|
|
36
|
+
|
|
37
|
+
const toggledCheck = !isChecked;
|
|
38
|
+
|
|
39
|
+
setIsChecked(toggledCheck);
|
|
40
|
+
if (storageKey) localStorage.setItem(storageKey, toggledCheck ? '1' : '');
|
|
41
|
+
|
|
42
|
+
onChange?.(toggledCheck, event?.nativeEvent);
|
|
43
|
+
|
|
44
|
+
setIsActive(false);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function onActive(event: React.PointerEvent) {
|
|
48
|
+
if (event.button !== 0) return;
|
|
49
|
+
setIsActive(true);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function onKeyDown(event: React.KeyboardEvent) {
|
|
53
|
+
if (isKeyboardClick(event.nativeEvent)) onPress();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div
|
|
58
|
+
className="vds-menu-checkbox"
|
|
59
|
+
role="menuitemcheckbox"
|
|
60
|
+
tabIndex={0}
|
|
61
|
+
aria-label={label}
|
|
62
|
+
aria-checked={isChecked ? 'true' : 'false'}
|
|
63
|
+
data-active={isActive ? '' : null}
|
|
64
|
+
onPointerUp={onPress}
|
|
65
|
+
onPointerDown={onActive}
|
|
66
|
+
onKeyDown={onKeyDown}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
DefaultMenuCheckbox.displayName = 'DefaultMenuCheckbox';
|
|
72
|
+
export { DefaultMenuCheckbox };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { isArray } from 'maverick.js/std';
|
|
4
|
+
|
|
5
|
+
import * as Menu from '../../../../../ui/menu';
|
|
6
|
+
import { DefaultLayoutContext, useDefaultLayoutContext } from '../../../context';
|
|
7
|
+
import type { DefaultLayoutIcon } from '../../../icons';
|
|
8
|
+
|
|
9
|
+
/* -------------------------------------------------------------------------------------------------
|
|
10
|
+
* DefaultMenuSection
|
|
11
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
12
|
+
|
|
13
|
+
export interface DefaultMenuSectionProps {
|
|
14
|
+
label?: string;
|
|
15
|
+
value?: string;
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function DefaultMenuSection({ label, value, children }: DefaultMenuSectionProps) {
|
|
20
|
+
const id = React.useId();
|
|
21
|
+
|
|
22
|
+
if (!label) {
|
|
23
|
+
return (
|
|
24
|
+
<div className="vds-menu-section">
|
|
25
|
+
<div className="vds-menu-section-body">{children}</div>
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<section className="vds-menu-section" role="group" aria-labelledby={id}>
|
|
32
|
+
<div className="vds-menu-section-title">
|
|
33
|
+
<header id={id}>{label}</header>
|
|
34
|
+
{value ? <div className="vds-menu-section-value">{value}</div> : null}
|
|
35
|
+
</div>
|
|
36
|
+
<div className="vds-menu-section-body">{children}</div>
|
|
37
|
+
</section>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
DefaultMenuSection.displayName = 'DefaultMenuSection';
|
|
42
|
+
export { DefaultMenuSection };
|
|
43
|
+
|
|
44
|
+
/* -------------------------------------------------------------------------------------------------
|
|
45
|
+
* DefaultMenuButton
|
|
46
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
47
|
+
|
|
48
|
+
export interface DefaultMenuButtonProps {
|
|
49
|
+
label: string;
|
|
50
|
+
hint?: string;
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
Icon?: DefaultLayoutIcon;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function DefaultMenuButton({ label, hint = '', Icon, disabled = false }: DefaultMenuButtonProps) {
|
|
56
|
+
const { icons: Icons } = React.useContext(DefaultLayoutContext);
|
|
57
|
+
return (
|
|
58
|
+
<Menu.Button className="vds-menu-item" disabled={disabled}>
|
|
59
|
+
<Icons.Menu.ArrowLeft className="vds-menu-close-icon vds-icon" />
|
|
60
|
+
{Icon ? <Icon className="vds-menu-item-icon vds-icon" /> : null}
|
|
61
|
+
<span className="vds-menu-item-label">{label}</span>
|
|
62
|
+
<span className="vds-menu-item-hint">{hint}</span>
|
|
63
|
+
<Icons.Menu.ArrowRight className="vds-menu-open-icon vds-icon" />
|
|
64
|
+
</Menu.Button>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
DefaultMenuButton.displayName = 'DefaultMenuButton';
|
|
69
|
+
export { DefaultMenuButton };
|
|
70
|
+
|
|
71
|
+
/* -------------------------------------------------------------------------------------------------
|
|
72
|
+
* DefaultMenuItem
|
|
73
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
74
|
+
|
|
75
|
+
export interface DefaultMenuItemProps {
|
|
76
|
+
label: string;
|
|
77
|
+
children: React.ReactNode;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function DefaultMenuItem({ label, children }: DefaultMenuItemProps) {
|
|
81
|
+
return (
|
|
82
|
+
<div className="vds-menu-item">
|
|
83
|
+
<div className="vds-menu-item-label">{label}</div>
|
|
84
|
+
{children}
|
|
85
|
+
</div>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
DefaultMenuItem.displayName = 'DefaultMenuItem';
|
|
90
|
+
export { DefaultMenuItem };
|
|
91
|
+
|
|
92
|
+
/* -------------------------------------------------------------------------------------------------
|
|
93
|
+
* DefaultMenuRadioGroup
|
|
94
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
95
|
+
|
|
96
|
+
export interface DefaultMenuRadioGroupProps {
|
|
97
|
+
value: string;
|
|
98
|
+
options: { label: string; value: string }[];
|
|
99
|
+
onChange?(newValue: string): void;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function DefaultMenuRadioGroup({ value, options, onChange }: DefaultMenuRadioGroupProps) {
|
|
103
|
+
const { icons: Icons } = useDefaultLayoutContext();
|
|
104
|
+
return (
|
|
105
|
+
<Menu.RadioGroup className="vds-radio-group" value={value} onChange={onChange}>
|
|
106
|
+
{options.map((option) => (
|
|
107
|
+
<Menu.Radio className="vds-radio" value={option.value} key={option.value}>
|
|
108
|
+
<Icons.Menu.RadioCheck className="vds-icon" />
|
|
109
|
+
<span className="vds-radio-label" data-part="label">
|
|
110
|
+
{option.label}
|
|
111
|
+
</span>
|
|
112
|
+
</Menu.Radio>
|
|
113
|
+
))}
|
|
114
|
+
</Menu.RadioGroup>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
DefaultMenuRadioGroup.displayName = 'DefaultMenuRadioGroup';
|
|
119
|
+
export { DefaultMenuRadioGroup };
|
|
120
|
+
|
|
121
|
+
/* -------------------------------------------------------------------------------------------------
|
|
122
|
+
* Utils
|
|
123
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
124
|
+
|
|
125
|
+
export function createRadioOptions(
|
|
126
|
+
entries: string[] | Record<string, string>,
|
|
127
|
+
): { label: string; value: string }[] {
|
|
128
|
+
return React.useMemo(
|
|
129
|
+
() =>
|
|
130
|
+
isArray(entries)
|
|
131
|
+
? entries.map((entry) => ({ label: entry, value: entry.toLowerCase() }))
|
|
132
|
+
: Object.keys(entries).map((label) => ({ label, value: entries[label] })),
|
|
133
|
+
[entries],
|
|
134
|
+
);
|
|
135
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import * as Slider from '../../../../../ui/sliders/slider';
|
|
4
|
+
import type { DefaultLayoutIcon } from '../../../icons';
|
|
5
|
+
|
|
6
|
+
/* -------------------------------------------------------------------------------------------------
|
|
7
|
+
* DefaultMenuSliderItem
|
|
8
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
9
|
+
|
|
10
|
+
export interface DefaultMenuSliderItemProps {
|
|
11
|
+
label?: string;
|
|
12
|
+
value?: string;
|
|
13
|
+
UpIcon?: DefaultLayoutIcon;
|
|
14
|
+
DownIcon?: DefaultLayoutIcon;
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
isMin: boolean;
|
|
17
|
+
isMax: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function DefaultMenuSliderItem({
|
|
21
|
+
label,
|
|
22
|
+
value,
|
|
23
|
+
UpIcon,
|
|
24
|
+
DownIcon,
|
|
25
|
+
children,
|
|
26
|
+
isMin,
|
|
27
|
+
isMax,
|
|
28
|
+
}: DefaultMenuSliderItemProps) {
|
|
29
|
+
const hasTitle = label || value,
|
|
30
|
+
Content = (
|
|
31
|
+
<>
|
|
32
|
+
{DownIcon ? <DownIcon className="vds-icon down" /> : null}
|
|
33
|
+
{children}
|
|
34
|
+
{UpIcon ? <UpIcon className="vds-icon up" /> : null}
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
className={`vds-menu-item vds-menu-slider-item${hasTitle ? ' group' : ''}`}
|
|
41
|
+
data-min={isMin ? '' : null}
|
|
42
|
+
data-max={isMax ? '' : null}
|
|
43
|
+
>
|
|
44
|
+
{hasTitle ? (
|
|
45
|
+
<>
|
|
46
|
+
<div className="vds-menu-slider-title">
|
|
47
|
+
{label ? <div>{label}</div> : null}
|
|
48
|
+
{value ? <div>{value}</div> : null}
|
|
49
|
+
</div>
|
|
50
|
+
<div className="vds-menu-slider-body">{Content}</div>
|
|
51
|
+
</>
|
|
52
|
+
) : (
|
|
53
|
+
Content
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
DefaultMenuSliderItem.displayName = 'DefaultMenuSliderItem';
|
|
60
|
+
export { DefaultMenuSliderItem };
|
|
61
|
+
|
|
62
|
+
/* -------------------------------------------------------------------------------------------------
|
|
63
|
+
* DefaultSliderParts
|
|
64
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
65
|
+
|
|
66
|
+
function DefaultSliderParts() {
|
|
67
|
+
return (
|
|
68
|
+
<>
|
|
69
|
+
<Slider.Track className="vds-slider-track" />
|
|
70
|
+
<Slider.TrackFill className="vds-slider-track-fill vds-slider-track" />
|
|
71
|
+
<Slider.Thumb className="vds-slider-thumb" />
|
|
72
|
+
</>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
DefaultSliderParts.displayName = 'DefaultSliderParts';
|
|
77
|
+
export { DefaultSliderParts };
|
|
78
|
+
|
|
79
|
+
/* -------------------------------------------------------------------------------------------------
|
|
80
|
+
* DefaultSliderSteps
|
|
81
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
82
|
+
|
|
83
|
+
function DefaultSliderSteps() {
|
|
84
|
+
return (
|
|
85
|
+
<Slider.Steps className="vds-slider-steps">
|
|
86
|
+
{(step) => <div className="vds-slider-step" key={String(step)} />}
|
|
87
|
+
</Slider.Steps>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
DefaultSliderSteps.displayName = 'DefaultSliderSteps';
|
|
92
|
+
export { DefaultSliderSteps };
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { isArray } from 'maverick.js/std';
|
|
4
|
+
import { sortVideoQualities } from 'vidstack';
|
|
5
|
+
|
|
6
|
+
import { useMediaContext } from '../../../../../hooks/use-media-context';
|
|
7
|
+
import { useMediaState } from '../../../../../hooks/use-media-state';
|
|
8
|
+
import * as Menu from '../../../../ui/menu';
|
|
9
|
+
import * as QualitySlider from '../../../../ui/sliders/quality-slider';
|
|
10
|
+
import * as SpeedSlider from '../../../../ui/sliders/speed-slider';
|
|
11
|
+
import { useDefaultLayoutContext, useDefaultLayoutWord } from '../../context';
|
|
12
|
+
import { slot, type DefaultLayoutMenuSlotName, type Slots } from '../../slots';
|
|
13
|
+
import { DefaultMenuCheckbox } from './items/menu-checkbox';
|
|
14
|
+
import { DefaultMenuButton, DefaultMenuItem, DefaultMenuSection } from './items/menu-items';
|
|
15
|
+
import { DefaultMenuSliderItem, DefaultSliderParts, DefaultSliderSteps } from './items/menu-slider';
|
|
16
|
+
|
|
17
|
+
/* -------------------------------------------------------------------------------------------------
|
|
18
|
+
* DefaultPlaybackMenu
|
|
19
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
20
|
+
|
|
21
|
+
interface DefaultPlaybackMenuProps {
|
|
22
|
+
slots?: Slots<DefaultLayoutMenuSlotName>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function DefaultPlaybackMenu({ slots }: DefaultPlaybackMenuProps) {
|
|
26
|
+
const label = useDefaultLayoutWord('Playback'),
|
|
27
|
+
{ icons: Icons } = useDefaultLayoutContext();
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Menu.Root className="vds-playback-menu vds-menu">
|
|
31
|
+
<DefaultMenuButton label={label} Icon={Icons.Menu.Playback} />
|
|
32
|
+
<Menu.Content className="vds-menu-items">
|
|
33
|
+
{slot(slots, 'playbackMenuItemsStart', null)}
|
|
34
|
+
|
|
35
|
+
<DefaultMenuSection>
|
|
36
|
+
{slot(slots, 'playbackMenuLoop', <DefaultLoopMenuCheckbox />)}
|
|
37
|
+
</DefaultMenuSection>
|
|
38
|
+
|
|
39
|
+
<DefaultSpeedMenuSection />
|
|
40
|
+
|
|
41
|
+
<DefaultQualityMenuSection />
|
|
42
|
+
|
|
43
|
+
{slot(slots, 'playbackMenuItemsEnd', null)}
|
|
44
|
+
</Menu.Content>
|
|
45
|
+
</Menu.Root>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
DefaultPlaybackMenu.displayName = 'DefaultPlaybackMenu';
|
|
50
|
+
export { DefaultPlaybackMenu };
|
|
51
|
+
|
|
52
|
+
/* -------------------------------------------------------------------------------------------------
|
|
53
|
+
* DefaultLoopMenuCheckbox
|
|
54
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
55
|
+
|
|
56
|
+
function DefaultLoopMenuCheckbox() {
|
|
57
|
+
const { remote } = useMediaContext(),
|
|
58
|
+
label = useDefaultLayoutWord('Loop');
|
|
59
|
+
|
|
60
|
+
function onChange(checked: boolean, trigger?: Event) {
|
|
61
|
+
remote.userPrefersLoopChange(checked, trigger);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<DefaultMenuItem label={label}>
|
|
66
|
+
<DefaultMenuCheckbox label={label} storageKey="vds-player::user-loop" onChange={onChange} />
|
|
67
|
+
</DefaultMenuItem>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
DefaultLoopMenuCheckbox.displayName = 'DefaultLoopMenuCheckbox';
|
|
72
|
+
|
|
73
|
+
/* -------------------------------------------------------------------------------------------------
|
|
74
|
+
* DefaultAutoQualityMenuCheckbox
|
|
75
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
76
|
+
|
|
77
|
+
function DefaultAutoQualityMenuCheckbox() {
|
|
78
|
+
const { remote, qualities } = useMediaContext(),
|
|
79
|
+
$autoQuality = useMediaState('autoQuality'),
|
|
80
|
+
label = useDefaultLayoutWord('Auto');
|
|
81
|
+
|
|
82
|
+
function onChange(checked: boolean, trigger?: Event) {
|
|
83
|
+
if (checked) {
|
|
84
|
+
remote.requestAutoQuality(trigger);
|
|
85
|
+
} else {
|
|
86
|
+
remote.changeQuality(qualities.selectedIndex, trigger);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<DefaultMenuItem label={label}>
|
|
92
|
+
<DefaultMenuCheckbox
|
|
93
|
+
label={label}
|
|
94
|
+
checked={$autoQuality}
|
|
95
|
+
onChange={onChange}
|
|
96
|
+
defaultChecked={$autoQuality}
|
|
97
|
+
/>
|
|
98
|
+
</DefaultMenuItem>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
DefaultAutoQualityMenuCheckbox.displayName = 'DefaultAutoQualityMenuCheckbox';
|
|
103
|
+
|
|
104
|
+
/* -------------------------------------------------------------------------------------------------
|
|
105
|
+
* DefaultQualityMenuSection
|
|
106
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
107
|
+
|
|
108
|
+
function DefaultQualityMenuSection() {
|
|
109
|
+
const { hideQualityBitrate, icons: Icons } = useDefaultLayoutContext(),
|
|
110
|
+
$canSetQuality = useMediaState('canSetQuality'),
|
|
111
|
+
$qualities = useMediaState('qualities'),
|
|
112
|
+
$quality = useMediaState('quality'),
|
|
113
|
+
label = useDefaultLayoutWord('Quality'),
|
|
114
|
+
autoText = useDefaultLayoutWord('Auto'),
|
|
115
|
+
sortedQualities = React.useMemo(() => sortVideoQualities($qualities), [$qualities]);
|
|
116
|
+
|
|
117
|
+
if (!$canSetQuality || $qualities.length <= 1) return null;
|
|
118
|
+
|
|
119
|
+
const height = $quality?.height,
|
|
120
|
+
bitrate = !hideQualityBitrate ? $quality?.bitrate : null,
|
|
121
|
+
bitrateText = bitrate && bitrate > 0 ? `${(bitrate / 1000000).toFixed(2)} Mbps` : null,
|
|
122
|
+
value = height ? `${height}p${bitrateText ? ` (${bitrateText})` : ''}` : autoText,
|
|
123
|
+
isMin = sortedQualities[0] === $quality,
|
|
124
|
+
isMax = sortedQualities.at(-1) === $quality;
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<DefaultMenuSection label={label} value={value}>
|
|
128
|
+
<DefaultMenuSliderItem
|
|
129
|
+
UpIcon={Icons.Menu.QualityUp}
|
|
130
|
+
DownIcon={Icons.Menu.QualityDown}
|
|
131
|
+
isMin={isMin}
|
|
132
|
+
isMax={isMax}
|
|
133
|
+
>
|
|
134
|
+
<DefaultQualitySlider />
|
|
135
|
+
</DefaultMenuSliderItem>
|
|
136
|
+
<DefaultAutoQualityMenuCheckbox />
|
|
137
|
+
</DefaultMenuSection>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
DefaultQualityMenuSection.displayName = 'DefaultQualityMenuSection';
|
|
142
|
+
|
|
143
|
+
/* -------------------------------------------------------------------------------------------------
|
|
144
|
+
* DefaultQualitySlider
|
|
145
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
146
|
+
|
|
147
|
+
function DefaultQualitySlider() {
|
|
148
|
+
const label = useDefaultLayoutWord('Quality');
|
|
149
|
+
return (
|
|
150
|
+
<QualitySlider.Root className="vds-quality-slider vds-slider" aria-label={label}>
|
|
151
|
+
<DefaultSliderParts />
|
|
152
|
+
<DefaultSliderSteps />
|
|
153
|
+
</QualitySlider.Root>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
DefaultQualitySlider.displayName = 'DefaultQualitySlider';
|
|
158
|
+
|
|
159
|
+
/* -------------------------------------------------------------------------------------------------
|
|
160
|
+
* DefaultSpeedMenuSection
|
|
161
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
162
|
+
|
|
163
|
+
function DefaultSpeedMenuSection() {
|
|
164
|
+
const { icons: Icons } = useDefaultLayoutContext(),
|
|
165
|
+
$playbackRate = useMediaState('playbackRate'),
|
|
166
|
+
$canSetPlaybackRate = useMediaState('canSetPlaybackRate'),
|
|
167
|
+
label = useDefaultLayoutWord('Speed'),
|
|
168
|
+
normalText = useDefaultLayoutWord('Normal'),
|
|
169
|
+
min = useSpeedMin(),
|
|
170
|
+
max = useSpeedMax(),
|
|
171
|
+
value = $playbackRate === 1 ? normalText : $playbackRate + 'x';
|
|
172
|
+
|
|
173
|
+
if (!$canSetPlaybackRate) return null;
|
|
174
|
+
|
|
175
|
+
return (
|
|
176
|
+
<DefaultMenuSection label={label} value={value}>
|
|
177
|
+
<DefaultMenuSliderItem
|
|
178
|
+
UpIcon={Icons.Menu.SpeedUp}
|
|
179
|
+
DownIcon={Icons.Menu.SpeedDown}
|
|
180
|
+
isMin={$playbackRate === min}
|
|
181
|
+
isMax={$playbackRate === max}
|
|
182
|
+
>
|
|
183
|
+
<DefaultSpeedSlider />
|
|
184
|
+
</DefaultMenuSliderItem>
|
|
185
|
+
</DefaultMenuSection>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function useSpeedMin() {
|
|
190
|
+
const { playbackRates } = useDefaultLayoutContext(),
|
|
191
|
+
rates = playbackRates;
|
|
192
|
+
return (isArray(rates) ? rates[0] : rates?.min) ?? 0;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function useSpeedMax() {
|
|
196
|
+
const { playbackRates } = useDefaultLayoutContext(),
|
|
197
|
+
rates = playbackRates;
|
|
198
|
+
return (isArray(rates) ? rates[rates.length - 1] : rates?.max) ?? 2;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function useSpeedStep() {
|
|
202
|
+
const { playbackRates } = useDefaultLayoutContext(),
|
|
203
|
+
rates = playbackRates;
|
|
204
|
+
return (isArray(rates) ? rates[1] - rates[0] : rates?.step) || 0.25;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/* -------------------------------------------------------------------------------------------------
|
|
208
|
+
* DefaultSpeedSlider
|
|
209
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
210
|
+
|
|
211
|
+
function DefaultSpeedSlider() {
|
|
212
|
+
const label = useDefaultLayoutWord('Speed'),
|
|
213
|
+
min = useSpeedMin(),
|
|
214
|
+
max = useSpeedMax(),
|
|
215
|
+
step = useSpeedStep();
|
|
216
|
+
|
|
217
|
+
return (
|
|
218
|
+
<SpeedSlider.Root
|
|
219
|
+
className="vds-speed-slider vds-slider"
|
|
220
|
+
aria-label={label}
|
|
221
|
+
min={min}
|
|
222
|
+
max={max}
|
|
223
|
+
step={step}
|
|
224
|
+
keyStep={step}
|
|
225
|
+
>
|
|
226
|
+
<DefaultSliderParts />
|
|
227
|
+
<DefaultSliderSteps />
|
|
228
|
+
</SpeedSlider.Root>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
DefaultSpeedSlider.displayName = 'DefaultSpeedSlider';
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { flushSync } from 'react-dom';
|
|
4
|
+
import { updateFontCssVars } from 'vidstack/exports/font.ts';
|
|
5
|
+
|
|
6
|
+
import { useMediaState } from '../../../../../hooks/use-media-state';
|
|
7
|
+
import { useScoped } from '../../../../../hooks/use-signals';
|
|
8
|
+
import * as Menu from '../../../../ui/menu';
|
|
9
|
+
import type * as Tooltip from '../../../../ui/tooltip';
|
|
10
|
+
import { useDefaultLayoutContext, useDefaultLayoutWord } from '../../context';
|
|
11
|
+
import { useColorSchemeClass } from '../../hooks';
|
|
12
|
+
import { slot, type DefaultLayoutMenuSlotName, type Slots } from '../../slots';
|
|
13
|
+
import { DefaultTooltip } from '../tooltip';
|
|
14
|
+
import { DefaultAccessibilityMenu } from './accessibility-menu';
|
|
15
|
+
import { DefaultAudioMenu } from './audio-menu';
|
|
16
|
+
import { DefaultCaptionMenu } from './captions-menu';
|
|
17
|
+
import { DefaultPlaybackMenu } from './playback-menu';
|
|
18
|
+
import { useParentDialogEl } from './utils';
|
|
19
|
+
|
|
20
|
+
export interface DefaultMediaMenuProps {
|
|
21
|
+
tooltip: Tooltip.ContentProps['placement'];
|
|
22
|
+
placement: Menu.ContentProps['placement'];
|
|
23
|
+
portalClass?: string;
|
|
24
|
+
slots?: Slots<DefaultLayoutMenuSlotName>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function DefaultSettingsMenu({
|
|
28
|
+
tooltip,
|
|
29
|
+
placement,
|
|
30
|
+
portalClass = '',
|
|
31
|
+
slots,
|
|
32
|
+
}: DefaultMediaMenuProps) {
|
|
33
|
+
const {
|
|
34
|
+
showMenuDelay,
|
|
35
|
+
icons: Icons,
|
|
36
|
+
isSmallLayout,
|
|
37
|
+
menuContainer,
|
|
38
|
+
menuGroup,
|
|
39
|
+
noModal,
|
|
40
|
+
colorScheme,
|
|
41
|
+
} = useDefaultLayoutContext(),
|
|
42
|
+
settingsText = useDefaultLayoutWord('Settings'),
|
|
43
|
+
$viewType = useMediaState('viewType'),
|
|
44
|
+
$offset = !isSmallLayout && menuGroup === 'bottom' && $viewType === 'video' ? 26 : 0,
|
|
45
|
+
colorSchemeClass = useColorSchemeClass(colorScheme),
|
|
46
|
+
[isOpen, setIsOpen] = React.useState(false),
|
|
47
|
+
dialogEl = useParentDialogEl();
|
|
48
|
+
|
|
49
|
+
useScoped(updateFontCssVars);
|
|
50
|
+
|
|
51
|
+
function onOpen() {
|
|
52
|
+
flushSync(() => {
|
|
53
|
+
setIsOpen(true);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function onClose() {
|
|
58
|
+
setIsOpen(false);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const Content = (
|
|
62
|
+
<Menu.Content
|
|
63
|
+
className="vds-settings-menu-items vds-menu-items"
|
|
64
|
+
placement={placement}
|
|
65
|
+
offset={$offset}
|
|
66
|
+
>
|
|
67
|
+
{isOpen ? (
|
|
68
|
+
<>
|
|
69
|
+
{slot(slots, 'settingsMenuItemsStart', null)}
|
|
70
|
+
{slot(slots, 'settingsMenuStartItems', null)}
|
|
71
|
+
<DefaultPlaybackMenu slots={slots} />
|
|
72
|
+
<DefaultAccessibilityMenu slots={slots} />
|
|
73
|
+
<DefaultAudioMenu slots={slots} />
|
|
74
|
+
<DefaultCaptionMenu slots={slots} />
|
|
75
|
+
{slot(slots, 'settingsMenuEndItems', null)}
|
|
76
|
+
{slot(slots, 'settingsMenuItemsEnd', null)}
|
|
77
|
+
</>
|
|
78
|
+
) : null}
|
|
79
|
+
</Menu.Content>
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<Menu.Root
|
|
84
|
+
className="vds-settings-menu vds-menu"
|
|
85
|
+
showDelay={showMenuDelay}
|
|
86
|
+
onOpen={onOpen}
|
|
87
|
+
onClose={onClose}
|
|
88
|
+
>
|
|
89
|
+
<DefaultTooltip content={settingsText} placement={tooltip}>
|
|
90
|
+
<Menu.Button className="vds-menu-button vds-button" aria-label={settingsText}>
|
|
91
|
+
<Icons.Menu.Settings className="vds-icon vds-rotate-icon" />
|
|
92
|
+
</Menu.Button>
|
|
93
|
+
</DefaultTooltip>
|
|
94
|
+
{noModal || !isSmallLayout ? (
|
|
95
|
+
Content
|
|
96
|
+
) : (
|
|
97
|
+
<Menu.Portal
|
|
98
|
+
className={portalClass + (colorSchemeClass ? ` ${colorSchemeClass}` : '')}
|
|
99
|
+
container={menuContainer ?? dialogEl}
|
|
100
|
+
disabled="fullscreen"
|
|
101
|
+
data-sm={isSmallLayout ? '' : null}
|
|
102
|
+
data-lg={!isSmallLayout ? '' : null}
|
|
103
|
+
data-size={isSmallLayout ? 'sm' : 'lg'}
|
|
104
|
+
data-view-type={$viewType}
|
|
105
|
+
>
|
|
106
|
+
{Content}
|
|
107
|
+
</Menu.Portal>
|
|
108
|
+
)}
|
|
109
|
+
</Menu.Root>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
DefaultSettingsMenu.displayName = 'DefaultSettingsMenu';
|
|
114
|
+
export { DefaultSettingsMenu };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { useSignal } from 'maverick.js/react';
|
|
4
|
+
|
|
5
|
+
import { useDefaultLayoutContext } from '../../context';
|
|
6
|
+
|
|
7
|
+
export function useParentDialogEl() {
|
|
8
|
+
const { layoutEl } = useDefaultLayoutContext(),
|
|
9
|
+
$layoutEl = useSignal(layoutEl);
|
|
10
|
+
|
|
11
|
+
return React.useMemo(() => $layoutEl?.closest('dialog'), [$layoutEl]);
|
|
12
|
+
}
|