@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,167 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { isArray } from 'maverick.js/std';
|
|
4
|
+
|
|
5
|
+
import { useAudioOptions } from '../../../../../hooks/options/use-audio-options';
|
|
6
|
+
import { useMediaState } from '../../../../../hooks/use-media-state';
|
|
7
|
+
import * as Menu from '../../../../ui/menu';
|
|
8
|
+
import * as AudioGainSlider from '../../../../ui/sliders/audio-gain-slider';
|
|
9
|
+
import { useDefaultLayoutContext, useDefaultLayoutWord } from '../../context';
|
|
10
|
+
import { slot, type DefaultLayoutMenuSlotName, type Slots } from '../../slots';
|
|
11
|
+
import { DefaultMenuButton, DefaultMenuSection } from './items/menu-items';
|
|
12
|
+
import { DefaultMenuSliderItem, DefaultSliderParts, DefaultSliderSteps } from './items/menu-slider';
|
|
13
|
+
|
|
14
|
+
/* -------------------------------------------------------------------------------------------------
|
|
15
|
+
* DefaultAudioMenu
|
|
16
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
17
|
+
|
|
18
|
+
interface DefaultAudioMenuProps {
|
|
19
|
+
slots?: Slots<DefaultLayoutMenuSlotName>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function DefaultAudioMenu({ slots }: DefaultAudioMenuProps) {
|
|
23
|
+
const label = useDefaultLayoutWord('Audio'),
|
|
24
|
+
$canSetAudioGain = useMediaState('canSetAudioGain'),
|
|
25
|
+
$audioTracks = useMediaState('audioTracks'),
|
|
26
|
+
{ noAudioGain, icons: Icons } = useDefaultLayoutContext(),
|
|
27
|
+
hasGainSlider = $canSetAudioGain && !noAudioGain,
|
|
28
|
+
$disabled = !hasGainSlider && $audioTracks.length <= 1;
|
|
29
|
+
|
|
30
|
+
if ($disabled) return null;
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<Menu.Root className="vds-audio-menu vds-menu">
|
|
34
|
+
<DefaultMenuButton label={label} Icon={Icons.Menu.Audio} />
|
|
35
|
+
<Menu.Content className="vds-menu-items">
|
|
36
|
+
{slot(slots, 'audioMenuItemsStart', null)}
|
|
37
|
+
<DefaultAudioTracksMenu />
|
|
38
|
+
{hasGainSlider ? <DefaultAudioBoostMenuSection /> : null}
|
|
39
|
+
{slot(slots, 'audioMenuItemsEnd', null)}
|
|
40
|
+
</Menu.Content>
|
|
41
|
+
</Menu.Root>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
DefaultAudioMenu.displayName = 'DefaultAudioMenu';
|
|
46
|
+
export { DefaultAudioMenu };
|
|
47
|
+
|
|
48
|
+
/* -------------------------------------------------------------------------------------------------
|
|
49
|
+
* DefaultAudioBoostSection
|
|
50
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
51
|
+
|
|
52
|
+
function DefaultAudioBoostMenuSection() {
|
|
53
|
+
const $audioGain = useMediaState('audioGain'),
|
|
54
|
+
label = useDefaultLayoutWord('Boost'),
|
|
55
|
+
value = Math.round((($audioGain ?? 1) - 1) * 100) + '%',
|
|
56
|
+
$canSetAudioGain = useMediaState('canSetAudioGain'),
|
|
57
|
+
{ noAudioGain, icons: Icons } = useDefaultLayoutContext(),
|
|
58
|
+
$disabled = !$canSetAudioGain || noAudioGain,
|
|
59
|
+
min = useGainMin(),
|
|
60
|
+
max = useGainMax();
|
|
61
|
+
|
|
62
|
+
if ($disabled) return null;
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<DefaultMenuSection label={label} value={value}>
|
|
66
|
+
<DefaultMenuSliderItem
|
|
67
|
+
UpIcon={Icons.Menu.AudioBoostUp}
|
|
68
|
+
DownIcon={Icons.Menu.AudioBoostDown}
|
|
69
|
+
isMin={(($audioGain ?? 1) - 1) * 100 <= min}
|
|
70
|
+
isMax={(($audioGain ?? 1) - 1) * 100 === max}
|
|
71
|
+
>
|
|
72
|
+
<DefaultAudioGainSlider />
|
|
73
|
+
</DefaultMenuSliderItem>
|
|
74
|
+
</DefaultMenuSection>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
DefaultAudioBoostMenuSection.displayName = 'DefaultAudioBoostMenuSection';
|
|
79
|
+
|
|
80
|
+
function useGainMin() {
|
|
81
|
+
const { audioGains } = useDefaultLayoutContext(),
|
|
82
|
+
min = isArray(audioGains) ? audioGains[0] : audioGains?.min;
|
|
83
|
+
return min ?? 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function useGainMax() {
|
|
87
|
+
const { audioGains } = useDefaultLayoutContext(),
|
|
88
|
+
max = isArray(audioGains) ? audioGains[audioGains.length - 1] : audioGains?.max;
|
|
89
|
+
return max ?? 300;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function useGainStep() {
|
|
93
|
+
const { audioGains } = useDefaultLayoutContext(),
|
|
94
|
+
step = isArray(audioGains) ? audioGains[1] - audioGains[0] : audioGains?.step;
|
|
95
|
+
return step || 25;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* -------------------------------------------------------------------------------------------------
|
|
99
|
+
* DefaultAudioGainSlider
|
|
100
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
101
|
+
|
|
102
|
+
function DefaultAudioGainSlider() {
|
|
103
|
+
const label = useDefaultLayoutWord('Audio Boost'),
|
|
104
|
+
min = useGainMin(),
|
|
105
|
+
max = useGainMax(),
|
|
106
|
+
step = useGainStep();
|
|
107
|
+
return (
|
|
108
|
+
<AudioGainSlider.Root
|
|
109
|
+
className="vds-audio-gain-slider vds-slider"
|
|
110
|
+
aria-label={label}
|
|
111
|
+
min={min}
|
|
112
|
+
max={max}
|
|
113
|
+
step={step}
|
|
114
|
+
keyStep={step}
|
|
115
|
+
>
|
|
116
|
+
<DefaultSliderParts />
|
|
117
|
+
<DefaultSliderSteps />
|
|
118
|
+
</AudioGainSlider.Root>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
DefaultAudioGainSlider.displayName = 'DefaultAudioGainSlider';
|
|
123
|
+
|
|
124
|
+
/* -------------------------------------------------------------------------------------------------
|
|
125
|
+
* DefaultAudioTracksMenu
|
|
126
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
127
|
+
|
|
128
|
+
function DefaultAudioTracksMenu() {
|
|
129
|
+
const { icons: Icons } = useDefaultLayoutContext(),
|
|
130
|
+
label = useDefaultLayoutWord('Track'),
|
|
131
|
+
defaultText = useDefaultLayoutWord('Default'),
|
|
132
|
+
$track = useMediaState('audioTrack'),
|
|
133
|
+
options = useAudioOptions();
|
|
134
|
+
|
|
135
|
+
if (options.disabled) return null;
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<Menu.Root className="vds-audio-track-menu vds-menu">
|
|
139
|
+
<DefaultMenuButton
|
|
140
|
+
label={label}
|
|
141
|
+
hint={$track?.label ?? defaultText}
|
|
142
|
+
disabled={options.disabled}
|
|
143
|
+
Icon={Icons.Menu.Audio}
|
|
144
|
+
/>
|
|
145
|
+
<Menu.Content className="vds-menu-items">
|
|
146
|
+
<Menu.RadioGroup
|
|
147
|
+
className="vds-audio-radio-group vds-radio-group"
|
|
148
|
+
value={options.selectedValue}
|
|
149
|
+
>
|
|
150
|
+
{options.map(({ label, value, select }) => (
|
|
151
|
+
<Menu.Radio
|
|
152
|
+
className="vds-audio-radio vds-radio"
|
|
153
|
+
value={value}
|
|
154
|
+
onSelect={select}
|
|
155
|
+
key={value}
|
|
156
|
+
>
|
|
157
|
+
<Icons.Menu.RadioCheck className="vds-icon" />
|
|
158
|
+
<span className="vds-radio-label">{label}</span>
|
|
159
|
+
</Menu.Radio>
|
|
160
|
+
))}
|
|
161
|
+
</Menu.RadioGroup>
|
|
162
|
+
</Menu.Content>
|
|
163
|
+
</Menu.Root>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
DefaultAudioTracksMenu.displayName = 'DefaultAudioTracksMenu';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { useCaptionOptions } from '../../../../../hooks/options/use-caption-options';
|
|
4
|
+
import * as Menu from '../../../../ui/menu';
|
|
5
|
+
import { useDefaultLayoutContext, useDefaultLayoutWord } from '../../context';
|
|
6
|
+
import { slot, type DefaultLayoutMenuSlotName, type Slots } from '../../slots';
|
|
7
|
+
import { DefaultMenuButton } from './items/menu-items';
|
|
8
|
+
|
|
9
|
+
/* -------------------------------------------------------------------------------------------------
|
|
10
|
+
* DefaultCaptionMenu
|
|
11
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
12
|
+
|
|
13
|
+
interface DefaultCaptionMenuProps {
|
|
14
|
+
slots?: Slots<DefaultLayoutMenuSlotName>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function DefaultCaptionMenu({ slots }: DefaultCaptionMenuProps) {
|
|
18
|
+
const { icons: Icons } = useDefaultLayoutContext(),
|
|
19
|
+
label = useDefaultLayoutWord('Captions'),
|
|
20
|
+
offText = useDefaultLayoutWord('Off'),
|
|
21
|
+
options = useCaptionOptions({ off: offText }),
|
|
22
|
+
hint = options.selectedTrack?.label ?? offText;
|
|
23
|
+
|
|
24
|
+
if (options.disabled) return null;
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Menu.Root className="vds-captions-menu vds-menu">
|
|
28
|
+
<DefaultMenuButton
|
|
29
|
+
label={label}
|
|
30
|
+
hint={hint}
|
|
31
|
+
disabled={options.disabled}
|
|
32
|
+
Icon={Icons.Menu.Captions}
|
|
33
|
+
/>
|
|
34
|
+
<Menu.Content className="vds-menu-items">
|
|
35
|
+
{slot(slots, 'captionsMenuItemsStart', null)}
|
|
36
|
+
|
|
37
|
+
<Menu.RadioGroup
|
|
38
|
+
className="vds-captions-radio-group vds-radio-group"
|
|
39
|
+
value={options.selectedValue}
|
|
40
|
+
>
|
|
41
|
+
{options.map(({ label, value, select }) => (
|
|
42
|
+
<Menu.Radio
|
|
43
|
+
className="vds-caption-radio vds-radio"
|
|
44
|
+
value={value}
|
|
45
|
+
onSelect={select}
|
|
46
|
+
key={value}
|
|
47
|
+
>
|
|
48
|
+
<Icons.Menu.RadioCheck className="vds-icon" />
|
|
49
|
+
<span className="vds-radio-label">{label}</span>
|
|
50
|
+
</Menu.Radio>
|
|
51
|
+
))}
|
|
52
|
+
</Menu.RadioGroup>
|
|
53
|
+
|
|
54
|
+
{slot(slots, 'captionsMenuItemsEnd', null)}
|
|
55
|
+
</Menu.Content>
|
|
56
|
+
</Menu.Root>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
DefaultCaptionMenu.displayName = 'DefaultCaptionMenu';
|
|
61
|
+
export { DefaultCaptionMenu };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { useSignal } from 'maverick.js/react';
|
|
4
|
+
import { flushSync } from 'react-dom';
|
|
5
|
+
|
|
6
|
+
import { useChapterOptions } from '../../../../../hooks/options/use-chapter-options';
|
|
7
|
+
import { useMediaState } from '../../../../../hooks/use-media-state';
|
|
8
|
+
import { isRemotionSrc } from '../../../../../providers/remotion/type-check';
|
|
9
|
+
import * as Menu from '../../../../ui/menu';
|
|
10
|
+
import * as Thumbnail from '../../../../ui/thumbnail';
|
|
11
|
+
import { RemotionThumbnail } from '../../../remotion-ui';
|
|
12
|
+
import { useDefaultLayoutContext, useDefaultLayoutWord } from '../../context';
|
|
13
|
+
import { useColorSchemeClass } from '../../hooks';
|
|
14
|
+
import { DefaultTooltip } from '../tooltip';
|
|
15
|
+
import type { DefaultMediaMenuProps } from './settings-menu';
|
|
16
|
+
import { useParentDialogEl } from './utils';
|
|
17
|
+
|
|
18
|
+
/* -------------------------------------------------------------------------------------------------
|
|
19
|
+
* DefaultChaptersMenu
|
|
20
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
21
|
+
|
|
22
|
+
function DefaultChaptersMenu({ tooltip, placement, portalClass = '' }: DefaultMediaMenuProps) {
|
|
23
|
+
const {
|
|
24
|
+
showMenuDelay,
|
|
25
|
+
noModal,
|
|
26
|
+
isSmallLayout,
|
|
27
|
+
icons: Icons,
|
|
28
|
+
menuGroup,
|
|
29
|
+
menuContainer,
|
|
30
|
+
colorScheme,
|
|
31
|
+
} = useDefaultLayoutContext(),
|
|
32
|
+
chaptersText = useDefaultLayoutWord('Chapters'),
|
|
33
|
+
options = useChapterOptions(),
|
|
34
|
+
disabled = !options.length,
|
|
35
|
+
{ thumbnails } = useDefaultLayoutContext(),
|
|
36
|
+
$src = useMediaState('currentSrc'),
|
|
37
|
+
$viewType = useMediaState('viewType'),
|
|
38
|
+
$offset = !isSmallLayout && menuGroup === 'bottom' && $viewType === 'video' ? 26 : 0,
|
|
39
|
+
$RemotionThumbnail = useSignal(RemotionThumbnail),
|
|
40
|
+
colorSchemeClass = useColorSchemeClass(colorScheme),
|
|
41
|
+
[isOpen, setIsOpen] = React.useState(false),
|
|
42
|
+
dialogEl = useParentDialogEl();
|
|
43
|
+
|
|
44
|
+
if (disabled) return null;
|
|
45
|
+
|
|
46
|
+
function onOpen() {
|
|
47
|
+
flushSync(() => {
|
|
48
|
+
setIsOpen(true);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function onClose() {
|
|
53
|
+
setIsOpen(false);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const Content = (
|
|
57
|
+
<Menu.Content
|
|
58
|
+
className="vds-chapters-menu-items vds-menu-items"
|
|
59
|
+
placement={placement}
|
|
60
|
+
offset={$offset}
|
|
61
|
+
>
|
|
62
|
+
{isOpen ? (
|
|
63
|
+
<Menu.RadioGroup
|
|
64
|
+
className="vds-chapters-radio-group vds-radio-group"
|
|
65
|
+
value={options.selectedValue}
|
|
66
|
+
data-thumbnails={thumbnails ? '' : null}
|
|
67
|
+
>
|
|
68
|
+
{options.map(
|
|
69
|
+
({ cue, label, value, startTimeText, durationText, select, setProgressVar }) => (
|
|
70
|
+
<Menu.Radio
|
|
71
|
+
className="vds-chapter-radio vds-radio"
|
|
72
|
+
value={value}
|
|
73
|
+
key={value}
|
|
74
|
+
onSelect={select}
|
|
75
|
+
ref={setProgressVar}
|
|
76
|
+
>
|
|
77
|
+
{thumbnails ? (
|
|
78
|
+
<Thumbnail.Root src={thumbnails} className="vds-thumbnail" time={cue.startTime}>
|
|
79
|
+
<Thumbnail.Img />
|
|
80
|
+
</Thumbnail.Root>
|
|
81
|
+
) : $RemotionThumbnail && isRemotionSrc($src) ? (
|
|
82
|
+
<$RemotionThumbnail className="vds-thumbnail" frame={cue.startTime * $src.fps!} />
|
|
83
|
+
) : null}
|
|
84
|
+
<div className="vds-chapter-radio-content">
|
|
85
|
+
<span className="vds-chapter-radio-label">{label}</span>
|
|
86
|
+
<span className="vds-chapter-radio-start-time">{startTimeText}</span>
|
|
87
|
+
<span className="vds-chapter-radio-duration">{durationText}</span>
|
|
88
|
+
</div>
|
|
89
|
+
</Menu.Radio>
|
|
90
|
+
),
|
|
91
|
+
)}
|
|
92
|
+
</Menu.RadioGroup>
|
|
93
|
+
) : null}
|
|
94
|
+
</Menu.Content>
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<Menu.Root
|
|
99
|
+
className="vds-chapters-menu vds-menu"
|
|
100
|
+
showDelay={showMenuDelay}
|
|
101
|
+
onOpen={onOpen}
|
|
102
|
+
onClose={onClose}
|
|
103
|
+
>
|
|
104
|
+
<DefaultTooltip content={chaptersText} placement={tooltip}>
|
|
105
|
+
<Menu.Button
|
|
106
|
+
className="vds-menu-button vds-button"
|
|
107
|
+
disabled={disabled}
|
|
108
|
+
aria-label={chaptersText}
|
|
109
|
+
>
|
|
110
|
+
<Icons.Menu.Chapters className="vds-icon" />
|
|
111
|
+
</Menu.Button>
|
|
112
|
+
</DefaultTooltip>
|
|
113
|
+
{noModal || !isSmallLayout ? (
|
|
114
|
+
Content
|
|
115
|
+
) : (
|
|
116
|
+
<Menu.Portal
|
|
117
|
+
container={menuContainer ?? dialogEl}
|
|
118
|
+
className={portalClass + (colorSchemeClass ? ` ${colorSchemeClass}` : '')}
|
|
119
|
+
disabled="fullscreen"
|
|
120
|
+
data-sm={isSmallLayout ? '' : null}
|
|
121
|
+
data-lg={!isSmallLayout ? '' : null}
|
|
122
|
+
data-size={isSmallLayout ? 'sm' : 'lg'}
|
|
123
|
+
>
|
|
124
|
+
{Content}
|
|
125
|
+
</Menu.Portal>
|
|
126
|
+
)}
|
|
127
|
+
</Menu.Root>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
DefaultChaptersMenu.displayName = 'DefaultChaptersMenu';
|
|
132
|
+
export { DefaultChaptersMenu };
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { useSignal } from 'maverick.js/react';
|
|
4
|
+
import { camelToKebabCase } from 'maverick.js/std';
|
|
5
|
+
import {
|
|
6
|
+
FONT_COLOR_OPTION,
|
|
7
|
+
FONT_FAMILY_OPTION,
|
|
8
|
+
FONT_OPACITY_OPTION,
|
|
9
|
+
FONT_SIGNALS,
|
|
10
|
+
FONT_SIZE_OPTION,
|
|
11
|
+
FONT_TEXT_SHADOW_OPTION,
|
|
12
|
+
onFontReset,
|
|
13
|
+
type DefaultFontSettingProps,
|
|
14
|
+
type FontRadioOption,
|
|
15
|
+
type FontSliderOption,
|
|
16
|
+
} from 'vidstack/exports/font.ts';
|
|
17
|
+
|
|
18
|
+
import { useMediaPlayer } from '../../../../../hooks/use-media-player';
|
|
19
|
+
import { useMediaState } from '../../../../../hooks/use-media-state';
|
|
20
|
+
import * as Menu from '../../../../ui/menu';
|
|
21
|
+
import * as Slider from '../../../../ui/sliders/slider';
|
|
22
|
+
import { i18n, useDefaultLayoutContext, useDefaultLayoutWord } from '../../context';
|
|
23
|
+
import type { DefaultLayoutIcon } from '../../icons';
|
|
24
|
+
import {
|
|
25
|
+
createRadioOptions,
|
|
26
|
+
DefaultMenuButton,
|
|
27
|
+
DefaultMenuItem,
|
|
28
|
+
DefaultMenuRadioGroup,
|
|
29
|
+
DefaultMenuSection,
|
|
30
|
+
} from './items/menu-items';
|
|
31
|
+
import { DefaultMenuSliderItem, DefaultSliderParts, DefaultSliderSteps } from './items/menu-slider';
|
|
32
|
+
|
|
33
|
+
/* -------------------------------------------------------------------------------------------------
|
|
34
|
+
* DefaultFontMenu
|
|
35
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
36
|
+
|
|
37
|
+
function DefaultFontMenu() {
|
|
38
|
+
const label = useDefaultLayoutWord('Caption Styles'),
|
|
39
|
+
$hasCaptions = useMediaState('hasCaptions'),
|
|
40
|
+
fontSectionLabel = useDefaultLayoutWord('Font'),
|
|
41
|
+
textSectionLabel = useDefaultLayoutWord('Text'),
|
|
42
|
+
textBgSectionLabel = useDefaultLayoutWord('Text Background'),
|
|
43
|
+
displayBgSectionLabel = useDefaultLayoutWord('Display Background');
|
|
44
|
+
|
|
45
|
+
if (!$hasCaptions) return null;
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Menu.Root className="vds-font-menu vds-menu">
|
|
49
|
+
<DefaultMenuButton label={label} />
|
|
50
|
+
<Menu.Content className="vds-font-style-items vds-menu-items">
|
|
51
|
+
<DefaultMenuSection label={fontSectionLabel}>
|
|
52
|
+
<DefaultFontFamilyMenu />
|
|
53
|
+
<DefaultFontSizeSlider />
|
|
54
|
+
</DefaultMenuSection>
|
|
55
|
+
|
|
56
|
+
<DefaultMenuSection label={textSectionLabel}>
|
|
57
|
+
<DefaultTextColorInput />
|
|
58
|
+
<DefaultTextShadowMenu />
|
|
59
|
+
<DefaultTextOpacitySlider />
|
|
60
|
+
</DefaultMenuSection>
|
|
61
|
+
|
|
62
|
+
<DefaultMenuSection label={textBgSectionLabel}>
|
|
63
|
+
<DefaultTextBgInput />
|
|
64
|
+
<DefaultTextBgOpacitySlider />
|
|
65
|
+
</DefaultMenuSection>
|
|
66
|
+
|
|
67
|
+
<DefaultMenuSection label={displayBgSectionLabel}>
|
|
68
|
+
<DefaultDisplayBgInput />
|
|
69
|
+
<DefaultDisplayBgOpacitySlider />
|
|
70
|
+
</DefaultMenuSection>
|
|
71
|
+
|
|
72
|
+
<DefaultMenuSection>
|
|
73
|
+
<DefaultResetMenuItem />
|
|
74
|
+
</DefaultMenuSection>
|
|
75
|
+
</Menu.Content>
|
|
76
|
+
</Menu.Root>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
DefaultFontMenu.displayName = 'DefaultFontMenu';
|
|
81
|
+
export { DefaultFontMenu };
|
|
82
|
+
|
|
83
|
+
/* -------------------------------------------------------------------------------------------------
|
|
84
|
+
* DefaultFontFamilyMenu
|
|
85
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
86
|
+
|
|
87
|
+
function DefaultFontFamilyMenu() {
|
|
88
|
+
return <DefaultFontSetting label="Family" type="fontFamily" option={FONT_FAMILY_OPTION} />;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
DefaultFontFamilyMenu.displayName = 'DefaultFontFamilyMenu';
|
|
92
|
+
|
|
93
|
+
/* -------------------------------------------------------------------------------------------------
|
|
94
|
+
* DefaultFontSizeSlider
|
|
95
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
96
|
+
|
|
97
|
+
function DefaultFontSizeSlider() {
|
|
98
|
+
const { icons: Icons } = useDefaultLayoutContext(),
|
|
99
|
+
option: FontSliderOption = {
|
|
100
|
+
...FONT_SIZE_OPTION,
|
|
101
|
+
upIcon: Icons.Menu.FontSizeUp,
|
|
102
|
+
downIcon: Icons.Menu.FontSizeDown,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return <DefaultFontSetting label="Size" type="fontSize" option={option} />;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
DefaultFontSizeSlider.displayName = 'DefaultFontSizeSlider';
|
|
109
|
+
|
|
110
|
+
/* -------------------------------------------------------------------------------------------------
|
|
111
|
+
* DefaultTextColoInput
|
|
112
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
113
|
+
|
|
114
|
+
function DefaultTextColorInput() {
|
|
115
|
+
return <DefaultFontSetting label="Color" type="textColor" option={FONT_COLOR_OPTION} />;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
DefaultTextColorInput.displayName = 'DefaultTextColorInput';
|
|
119
|
+
|
|
120
|
+
/* -------------------------------------------------------------------------------------------------
|
|
121
|
+
* DefaultTextOpacitySlider
|
|
122
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
123
|
+
|
|
124
|
+
function DefaultTextOpacitySlider() {
|
|
125
|
+
const { icons: Icons } = useDefaultLayoutContext(),
|
|
126
|
+
option = {
|
|
127
|
+
...FONT_OPACITY_OPTION,
|
|
128
|
+
upIcon: Icons.Menu.OpacityUp,
|
|
129
|
+
downIcon: Icons.Menu.OpacityDown,
|
|
130
|
+
};
|
|
131
|
+
return <DefaultFontSetting label="Opacity" type="textOpacity" option={option} />;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
DefaultTextOpacitySlider.displayName = 'DefaultTextOpacitySlider';
|
|
135
|
+
|
|
136
|
+
/* -------------------------------------------------------------------------------------------------
|
|
137
|
+
* DefaultTextShadowMenu
|
|
138
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
139
|
+
|
|
140
|
+
function DefaultTextShadowMenu() {
|
|
141
|
+
return <DefaultFontSetting label="Shadow" type="textShadow" option={FONT_TEXT_SHADOW_OPTION} />;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
DefaultTextShadowMenu.displayName = 'DefaultTextShadowMenu';
|
|
145
|
+
|
|
146
|
+
/* -------------------------------------------------------------------------------------------------
|
|
147
|
+
* DefaultTextBgInput
|
|
148
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
149
|
+
|
|
150
|
+
function DefaultTextBgInput() {
|
|
151
|
+
return <DefaultFontSetting label="Color" type="textBg" option={FONT_COLOR_OPTION} />;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
DefaultTextBgInput.displayName = 'DefaultTextBgInput';
|
|
155
|
+
|
|
156
|
+
/* -------------------------------------------------------------------------------------------------
|
|
157
|
+
* DefaultTextBgOpacitySlider
|
|
158
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
159
|
+
|
|
160
|
+
function DefaultTextBgOpacitySlider() {
|
|
161
|
+
const { icons: Icons } = useDefaultLayoutContext(),
|
|
162
|
+
option = {
|
|
163
|
+
...FONT_OPACITY_OPTION,
|
|
164
|
+
upIcon: Icons.Menu.OpacityUp,
|
|
165
|
+
downIcon: Icons.Menu.OpacityDown,
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
return <DefaultFontSetting label="Opacity" type="textBgOpacity" option={option} />;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
DefaultTextBgOpacitySlider.displayName = 'DefaultTextBgOpacitySlider';
|
|
172
|
+
|
|
173
|
+
/* -------------------------------------------------------------------------------------------------
|
|
174
|
+
* DefaultDisplayBgInput
|
|
175
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
176
|
+
|
|
177
|
+
function DefaultDisplayBgInput() {
|
|
178
|
+
return <DefaultFontSetting label="Color" type="displayBg" option={FONT_COLOR_OPTION} />;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
DefaultDisplayBgInput.displayName = 'DefaultDisplayBgInput';
|
|
182
|
+
|
|
183
|
+
/* -------------------------------------------------------------------------------------------------
|
|
184
|
+
* DefaultDisplayBgOpacitySlider
|
|
185
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
186
|
+
|
|
187
|
+
function DefaultDisplayBgOpacitySlider() {
|
|
188
|
+
const { icons: Icons } = useDefaultLayoutContext(),
|
|
189
|
+
option = {
|
|
190
|
+
...FONT_OPACITY_OPTION,
|
|
191
|
+
upIcon: Icons.Menu.OpacityUp,
|
|
192
|
+
downIcon: Icons.Menu.OpacityDown,
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
return <DefaultFontSetting label="Opacity" type="displayBgOpacity" option={option} />;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
DefaultDisplayBgOpacitySlider.displayName = 'DefaultDisplayBgOpacitySlider';
|
|
199
|
+
|
|
200
|
+
/* -------------------------------------------------------------------------------------------------
|
|
201
|
+
* DefaultFontSetting
|
|
202
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
203
|
+
|
|
204
|
+
function DefaultFontSetting({ label, option, type }: DefaultFontSettingProps) {
|
|
205
|
+
const player = useMediaPlayer(),
|
|
206
|
+
$currentValue = FONT_SIGNALS[type],
|
|
207
|
+
$value = useSignal($currentValue),
|
|
208
|
+
translatedLabel = useDefaultLayoutWord(label);
|
|
209
|
+
|
|
210
|
+
const notify = React.useCallback(() => {
|
|
211
|
+
player?.dispatchEvent(new Event('vds-font-change'));
|
|
212
|
+
}, [player]);
|
|
213
|
+
|
|
214
|
+
const onChange = React.useCallback(
|
|
215
|
+
(newValue: string) => {
|
|
216
|
+
$currentValue.set(newValue);
|
|
217
|
+
notify();
|
|
218
|
+
},
|
|
219
|
+
[$currentValue, notify],
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
if (option.type === 'color') {
|
|
223
|
+
function onColorChange(event) {
|
|
224
|
+
onChange(event.target.value);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return (
|
|
228
|
+
<DefaultMenuItem label={translatedLabel}>
|
|
229
|
+
<input className="vds-color-picker" type="color" value={$value} onChange={onColorChange} />
|
|
230
|
+
</DefaultMenuItem>
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (option.type === 'slider') {
|
|
235
|
+
const { min, max, step, upIcon, downIcon } = option;
|
|
236
|
+
|
|
237
|
+
function onSliderValueChange(value) {
|
|
238
|
+
onChange(value + '%');
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return (
|
|
242
|
+
<DefaultMenuSliderItem
|
|
243
|
+
label={translatedLabel}
|
|
244
|
+
value={$value}
|
|
245
|
+
UpIcon={upIcon as DefaultLayoutIcon}
|
|
246
|
+
DownIcon={downIcon as DefaultLayoutIcon}
|
|
247
|
+
isMin={$value === min + '%'}
|
|
248
|
+
isMax={$value === max + '%'}
|
|
249
|
+
>
|
|
250
|
+
<Slider.Root
|
|
251
|
+
className="vds-slider"
|
|
252
|
+
min={min}
|
|
253
|
+
max={max}
|
|
254
|
+
step={step}
|
|
255
|
+
keyStep={step}
|
|
256
|
+
value={parseInt($value)}
|
|
257
|
+
aria-label={translatedLabel}
|
|
258
|
+
onValueChange={onSliderValueChange}
|
|
259
|
+
onDragValueChange={onSliderValueChange}
|
|
260
|
+
>
|
|
261
|
+
<DefaultSliderParts />
|
|
262
|
+
<DefaultSliderSteps />
|
|
263
|
+
</Slider.Root>
|
|
264
|
+
</DefaultMenuSliderItem>
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (option.type === 'radio') {
|
|
269
|
+
return (
|
|
270
|
+
<DefaultFontRadioGroup
|
|
271
|
+
id={camelToKebabCase(type)}
|
|
272
|
+
label={translatedLabel}
|
|
273
|
+
value={$value}
|
|
274
|
+
values={option.values}
|
|
275
|
+
onChange={onChange}
|
|
276
|
+
/>
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
DefaultFontSetting.displayName = 'DefaultFontSetting';
|
|
284
|
+
|
|
285
|
+
/* -------------------------------------------------------------------------------------------------
|
|
286
|
+
* DefaultFontRadioGroup
|
|
287
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
288
|
+
|
|
289
|
+
interface DefaultFontRadioGroupProps {
|
|
290
|
+
id: string;
|
|
291
|
+
label: string;
|
|
292
|
+
value: string;
|
|
293
|
+
values: FontRadioOption['values'];
|
|
294
|
+
onChange: (value: string) => void;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function DefaultFontRadioGroup({ id, label, value, values, onChange }: DefaultFontRadioGroupProps) {
|
|
298
|
+
const radioOptions = createRadioOptions(values),
|
|
299
|
+
{ translations } = useDefaultLayoutContext(),
|
|
300
|
+
hint = React.useMemo(() => {
|
|
301
|
+
const label = radioOptions.find((radio) => radio.value === value)?.label || '';
|
|
302
|
+
return i18n(translations, label);
|
|
303
|
+
}, [value, radioOptions]);
|
|
304
|
+
|
|
305
|
+
return (
|
|
306
|
+
<Menu.Root className={`vds-${id}-menu vds-menu`}>
|
|
307
|
+
<DefaultMenuButton label={label} hint={hint} />
|
|
308
|
+
<Menu.Items className="vds-menu-items">
|
|
309
|
+
<DefaultMenuRadioGroup value={value} options={radioOptions} onChange={onChange} />
|
|
310
|
+
</Menu.Items>
|
|
311
|
+
</Menu.Root>
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
DefaultFontRadioGroup.displayName = 'DefaultFontRadioGroup';
|
|
316
|
+
|
|
317
|
+
/* -------------------------------------------------------------------------------------------------
|
|
318
|
+
* DefaultResetMenuItem
|
|
319
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
320
|
+
|
|
321
|
+
function DefaultResetMenuItem() {
|
|
322
|
+
const resetText = useDefaultLayoutWord('Reset');
|
|
323
|
+
|
|
324
|
+
return (
|
|
325
|
+
<button className="vds-menu-item" role="menuitem" onClick={onFontReset}>
|
|
326
|
+
<span className="vds-menu-item-label">{resetText}</span>
|
|
327
|
+
</button>
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
DefaultResetMenuItem.displayName = 'DefaultResetMenuItem';
|