@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,53 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { composeRefs, createReactComponent, type ReactElementProps } from 'maverick.js/react';
|
|
4
|
+
|
|
5
|
+
import { PlayButtonInstance } from '../../primitives/instances';
|
|
6
|
+
import { Primitive } from '../../primitives/nodes';
|
|
7
|
+
|
|
8
|
+
/* -------------------------------------------------------------------------------------------------
|
|
9
|
+
* PlayButton
|
|
10
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
11
|
+
|
|
12
|
+
const PlayButtonBridge = createReactComponent(PlayButtonInstance, {
|
|
13
|
+
domEventsRegex: /^onMedia/,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export interface PlayButtonProps extends ReactElementProps<PlayButtonInstance, HTMLButtonElement> {
|
|
17
|
+
asChild?: boolean;
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A button for toggling the playback state (play/pause) of the current media.
|
|
24
|
+
*
|
|
25
|
+
* @docs {@link https://www.vidstack.io/docs/player/components/buttons/play-button}
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* const isPaused = useMediaState('paused');
|
|
29
|
+
*
|
|
30
|
+
* <PlayButton>
|
|
31
|
+
* {isPaused ? <PlayIcon /> : <PauseIcon />}
|
|
32
|
+
* </PlayButton>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
const PlayButton = React.forwardRef<HTMLButtonElement, PlayButtonProps>(
|
|
36
|
+
({ children, ...props }, forwardRef) => {
|
|
37
|
+
return (
|
|
38
|
+
<PlayButtonBridge {...(props as Omit<PlayButtonProps, 'ref'>)}>
|
|
39
|
+
{(props) => (
|
|
40
|
+
<Primitive.button
|
|
41
|
+
{...props}
|
|
42
|
+
ref={composeRefs(props.ref as React.Ref<any>, forwardRef as React.Ref<any>)}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</Primitive.button>
|
|
46
|
+
)}
|
|
47
|
+
</PlayButtonBridge>
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
PlayButton.displayName = 'PlayButton';
|
|
53
|
+
export { PlayButton };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { composeRefs, createReactComponent, type ReactElementProps } from 'maverick.js/react';
|
|
4
|
+
|
|
5
|
+
import { SeekButtonInstance } from '../../primitives/instances';
|
|
6
|
+
import { Primitive } from '../../primitives/nodes';
|
|
7
|
+
|
|
8
|
+
/* -------------------------------------------------------------------------------------------------
|
|
9
|
+
* SeekButton
|
|
10
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
11
|
+
|
|
12
|
+
const SeekButtonBridge = createReactComponent(SeekButtonInstance, {
|
|
13
|
+
domEventsRegex: /^onMedia/,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export interface SeekButtonProps extends ReactElementProps<SeekButtonInstance, HTMLButtonElement> {
|
|
17
|
+
asChild?: boolean;
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A button for seeking the current media playback forwards or backwards by a specified amount.
|
|
24
|
+
*
|
|
25
|
+
* @docs {@link https://www.vidstack.io/docs/player/components/buttons/seek-button}
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* <SeekButton seconds={-10}>
|
|
29
|
+
* <SeekBackwardIcon />
|
|
30
|
+
* </SeekButton>
|
|
31
|
+
*
|
|
32
|
+
* <SeekButton seconds={10}>
|
|
33
|
+
* <SeekForwardIcon />
|
|
34
|
+
* </SeekButton>
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
const SeekButton = React.forwardRef<HTMLButtonElement, SeekButtonProps>(
|
|
38
|
+
({ children, ...props }, forwardRef) => {
|
|
39
|
+
return (
|
|
40
|
+
<SeekButtonBridge {...(props as Omit<SeekButtonProps, 'ref'>)}>
|
|
41
|
+
{(props) => (
|
|
42
|
+
<Primitive.button
|
|
43
|
+
{...props}
|
|
44
|
+
ref={composeRefs(props.ref as React.Ref<any>, forwardRef as React.Ref<any>)}
|
|
45
|
+
>
|
|
46
|
+
{children}
|
|
47
|
+
</Primitive.button>
|
|
48
|
+
)}
|
|
49
|
+
</SeekButtonBridge>
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
SeekButton.displayName = 'SeekButton';
|
|
55
|
+
export { SeekButton };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { composeRefs, createReactComponent, type ReactElementProps } from 'maverick.js/react';
|
|
4
|
+
|
|
5
|
+
import { ToggleButtonInstance } from '../../primitives/instances';
|
|
6
|
+
import { Primitive } from '../../primitives/nodes';
|
|
7
|
+
|
|
8
|
+
/* -------------------------------------------------------------------------------------------------
|
|
9
|
+
* ToggleButton
|
|
10
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
11
|
+
|
|
12
|
+
const ToggleButtonBridge = createReactComponent(ToggleButtonInstance);
|
|
13
|
+
|
|
14
|
+
export interface ToggleButtonProps
|
|
15
|
+
extends ReactElementProps<ToggleButtonInstance, HTMLButtonElement> {
|
|
16
|
+
asChild?: boolean;
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A toggle button is a two-state button that can be either off (not pressed) or on (pressed).
|
|
23
|
+
*
|
|
24
|
+
* @docs {@link https://www.vidstack.io/docs/player/components/buttons/toggle-button}
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <ToggleButton aria-label="...">
|
|
28
|
+
* <OnIcon />
|
|
29
|
+
* <OffIcon />
|
|
30
|
+
* </ToggleButton>
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
const ToggleButton = React.forwardRef<HTMLButtonElement, ToggleButtonProps>(
|
|
34
|
+
({ children, ...props }, forwardRef) => {
|
|
35
|
+
return (
|
|
36
|
+
<ToggleButtonBridge {...(props as Omit<ToggleButtonProps, 'ref'>)}>
|
|
37
|
+
{(props) => (
|
|
38
|
+
<Primitive.button
|
|
39
|
+
{...props}
|
|
40
|
+
ref={composeRefs(props.ref as React.Ref<any>, forwardRef as React.Ref<any>)}
|
|
41
|
+
>
|
|
42
|
+
{children}
|
|
43
|
+
</Primitive.button>
|
|
44
|
+
)}
|
|
45
|
+
</ToggleButtonBridge>
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
ToggleButton.displayName = 'ToggleButton';
|
|
51
|
+
export { ToggleButton };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import type { VTTCue } from 'media-captions';
|
|
4
|
+
|
|
5
|
+
import { useMediaState } from '../../hooks/use-media-state';
|
|
6
|
+
import { Primitive, type PrimitivePropsWithRef } from '../primitives/nodes';
|
|
7
|
+
|
|
8
|
+
/* -------------------------------------------------------------------------------------------------
|
|
9
|
+
* Caption
|
|
10
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
11
|
+
|
|
12
|
+
export interface RootProps extends PrimitivePropsWithRef<'div'> {
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const Root = React.forwardRef<HTMLElement, RootProps>(({ children, ...props }, forwardRef) => {
|
|
17
|
+
return (
|
|
18
|
+
<Primitive.div
|
|
19
|
+
translate="yes"
|
|
20
|
+
aria-live="off"
|
|
21
|
+
aria-atomic="true"
|
|
22
|
+
{...props}
|
|
23
|
+
ref={forwardRef as React.Ref<any>}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
</Primitive.div>
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
Root.displayName = 'Caption';
|
|
31
|
+
export { Root };
|
|
32
|
+
|
|
33
|
+
/* -------------------------------------------------------------------------------------------------
|
|
34
|
+
* CaptionText
|
|
35
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
36
|
+
|
|
37
|
+
export interface TextProps extends PrimitivePropsWithRef<'span'> {}
|
|
38
|
+
|
|
39
|
+
const Text = React.forwardRef<HTMLElement, TextProps>((props, forwardRef) => {
|
|
40
|
+
const textTrack = useMediaState('textTrack'),
|
|
41
|
+
[activeCue, setActiveCue] = React.useState<VTTCue | undefined>();
|
|
42
|
+
|
|
43
|
+
React.useEffect(() => {
|
|
44
|
+
if (!textTrack) return;
|
|
45
|
+
|
|
46
|
+
function onCueChange() {
|
|
47
|
+
setActiveCue(textTrack?.activeCues[0]);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
textTrack.addEventListener('cue-change', onCueChange);
|
|
51
|
+
return () => {
|
|
52
|
+
textTrack.removeEventListener('cue-change', onCueChange);
|
|
53
|
+
setActiveCue(undefined);
|
|
54
|
+
};
|
|
55
|
+
}, [textTrack]);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Primitive.span
|
|
59
|
+
{...props}
|
|
60
|
+
data-part="cue"
|
|
61
|
+
dangerouslySetInnerHTML={{
|
|
62
|
+
__html: activeCue?.text || '',
|
|
63
|
+
}}
|
|
64
|
+
ref={forwardRef as React.Ref<any>}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
Text.displayName = 'CaptionText';
|
|
70
|
+
export { Text };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { createReactComponent, type ReactElementProps } from 'maverick.js/react';
|
|
4
|
+
|
|
5
|
+
import { CaptionsInstance } from '../primitives/instances';
|
|
6
|
+
import { Primitive } from '../primitives/nodes';
|
|
7
|
+
|
|
8
|
+
/* -------------------------------------------------------------------------------------------------
|
|
9
|
+
* Captions
|
|
10
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
11
|
+
|
|
12
|
+
const CaptionsBridge = createReactComponent(CaptionsInstance);
|
|
13
|
+
|
|
14
|
+
export interface CaptionsProps extends ReactElementProps<CaptionsInstance> {
|
|
15
|
+
asChild?: boolean;
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
ref?: React.Ref<CaptionsInstance>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Renders and displays captions/subtitles. This will be an overlay for video and a simple
|
|
22
|
+
* captions box for audio.
|
|
23
|
+
*
|
|
24
|
+
* @docs {@link https://www.vidstack.io/docs/player/components/display/captions}
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <Captions />
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
const Captions = React.forwardRef<CaptionsInstance, CaptionsProps>(
|
|
31
|
+
({ children, ...props }, forwardRef) => {
|
|
32
|
+
return (
|
|
33
|
+
<CaptionsBridge {...props} ref={forwardRef}>
|
|
34
|
+
{(props) => <Primitive.div {...props}>{children}</Primitive.div>}
|
|
35
|
+
</CaptionsBridge>
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
Captions.displayName = 'Captions';
|
|
41
|
+
export { Captions };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { useChapterTitle } from '../../hooks/use-chapter-title';
|
|
4
|
+
import { Primitive, type PrimitivePropsWithRef } from '../primitives/nodes';
|
|
5
|
+
|
|
6
|
+
/* -------------------------------------------------------------------------------------------------
|
|
7
|
+
* Chapter Title
|
|
8
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
9
|
+
|
|
10
|
+
export interface ChapterTitleProps extends PrimitivePropsWithRef<'span'> {
|
|
11
|
+
/**
|
|
12
|
+
* Specify text to be displayed when no chapter title is available.
|
|
13
|
+
*/
|
|
14
|
+
defaultText?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This component is used to load and display the current chapter title based on the text tracks
|
|
19
|
+
* provided.
|
|
20
|
+
*
|
|
21
|
+
* @docs {@link https://www.vidstack.io/docs/player/components/display/chapter-title}
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <ChapterTitle />
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
const ChapterTitle = React.forwardRef<HTMLElement, ChapterTitleProps>(
|
|
28
|
+
({ defaultText = '', children, ...props }, forwardRef) => {
|
|
29
|
+
const $chapterTitle = useChapterTitle();
|
|
30
|
+
return (
|
|
31
|
+
<Primitive.span {...props} ref={forwardRef as React.Ref<any>}>
|
|
32
|
+
{$chapterTitle || defaultText}
|
|
33
|
+
{children}
|
|
34
|
+
</Primitive.span>
|
|
35
|
+
);
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
ChapterTitle.displayName = 'ChapterTitle';
|
|
40
|
+
export { ChapterTitle };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { composeRefs, createReactComponent, type ReactElementProps } from 'maverick.js/react';
|
|
4
|
+
|
|
5
|
+
import { ControlsGroupInstance, ControlsInstance } from '../primitives/instances';
|
|
6
|
+
import { Primitive } from '../primitives/nodes';
|
|
7
|
+
|
|
8
|
+
/* -------------------------------------------------------------------------------------------------
|
|
9
|
+
* Controls
|
|
10
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
11
|
+
|
|
12
|
+
const ControlsBridge = createReactComponent(ControlsInstance);
|
|
13
|
+
|
|
14
|
+
export interface RootProps extends ReactElementProps<ControlsInstance> {
|
|
15
|
+
asChild?: boolean;
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
ref?: React.Ref<HTMLElement>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* This component creates a container for control groups.
|
|
22
|
+
*
|
|
23
|
+
* @docs {@link https://www.vidstack.io/docs/player/components/media/controls}
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <Controls.Root>
|
|
27
|
+
* <Controls.Group></Controls.Group>
|
|
28
|
+
* <Controls.Group></Controls.Group>
|
|
29
|
+
* <Controls.Root>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
const Root = React.forwardRef<HTMLElement, RootProps>(({ children, ...props }, forwardRef) => {
|
|
33
|
+
return (
|
|
34
|
+
<ControlsBridge {...(props as Omit<RootProps, 'ref'>)}>
|
|
35
|
+
{(props) => (
|
|
36
|
+
<Primitive.div
|
|
37
|
+
{...props}
|
|
38
|
+
ref={composeRefs(props.ref as React.Ref<any>, forwardRef as React.Ref<any>)}
|
|
39
|
+
>
|
|
40
|
+
{children}
|
|
41
|
+
</Primitive.div>
|
|
42
|
+
)}
|
|
43
|
+
</ControlsBridge>
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
Root.displayName = 'Controls';
|
|
48
|
+
|
|
49
|
+
/* -------------------------------------------------------------------------------------------------
|
|
50
|
+
* ControlsGroup
|
|
51
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
52
|
+
|
|
53
|
+
const ControlsGroupBridge = createReactComponent(ControlsGroupInstance);
|
|
54
|
+
|
|
55
|
+
export interface GroupProps extends ReactElementProps<ControlsGroupInstance> {
|
|
56
|
+
asChild?: boolean;
|
|
57
|
+
children?: React.ReactNode;
|
|
58
|
+
ref?: React.Ref<HTMLElement>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* This component creates a container for media controls.
|
|
63
|
+
*
|
|
64
|
+
* @docs {@link https://www.vidstack.io/docs/player/components/media/controls#group}
|
|
65
|
+
* @example
|
|
66
|
+
* ```tsx
|
|
67
|
+
* <Controls.Root>
|
|
68
|
+
* <Controls.Group></Controls.Group>
|
|
69
|
+
* <Controls.Group></Controls.Group>
|
|
70
|
+
* <Controls.Root>
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
const Group = React.forwardRef<HTMLElement, GroupProps>(({ children, ...props }, forwardRef) => {
|
|
74
|
+
return (
|
|
75
|
+
<ControlsGroupBridge {...(props as Omit<GroupProps, 'ref'>)}>
|
|
76
|
+
{(props) => (
|
|
77
|
+
<Primitive.div
|
|
78
|
+
{...props}
|
|
79
|
+
ref={composeRefs(props.ref as React.Ref<any>, forwardRef as React.Ref<any>)}
|
|
80
|
+
>
|
|
81
|
+
{children}
|
|
82
|
+
</Primitive.div>
|
|
83
|
+
)}
|
|
84
|
+
</ControlsGroupBridge>
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
Group.displayName = 'ControlsGroup';
|
|
89
|
+
|
|
90
|
+
export { Root, Group };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { createReactComponent, type ReactElementProps } from 'maverick.js/react';
|
|
4
|
+
|
|
5
|
+
import { GestureInstance } from '../primitives/instances';
|
|
6
|
+
import { Primitive } from '../primitives/nodes';
|
|
7
|
+
|
|
8
|
+
/* -------------------------------------------------------------------------------------------------
|
|
9
|
+
* Gesture
|
|
10
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
11
|
+
|
|
12
|
+
const GestureBridge = createReactComponent(GestureInstance, {
|
|
13
|
+
events: ['onWillTrigger', 'onTrigger'],
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export interface GestureProps extends ReactElementProps<GestureInstance> {
|
|
17
|
+
asChild?: boolean;
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
ref?: React.Ref<GestureInstance>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* This component enables actions to be performed on the media based on user gestures.
|
|
24
|
+
*
|
|
25
|
+
* @docs {@link https://www.vidstack.io/docs/player/components/media/gesture}
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* <Gesture event="pointerup" action="toggle:paused" />
|
|
29
|
+
* <Gesture event="dblpointerup" action="toggle:fullscreen" />
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
const Gesture = React.forwardRef<GestureInstance, GestureProps>(
|
|
33
|
+
({ children, ...props }, forwardRef) => {
|
|
34
|
+
return (
|
|
35
|
+
<GestureBridge {...props} ref={forwardRef}>
|
|
36
|
+
{(props) => <Primitive.div {...props}>{children}</Primitive.div>}
|
|
37
|
+
</GestureBridge>
|
|
38
|
+
);
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
Gesture.displayName = 'Gesture';
|
|
43
|
+
export { Gesture };
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { composeRefs, createReactComponent, type ReactElementProps } from 'maverick.js/react';
|
|
4
|
+
import { isString } from 'maverick.js/std';
|
|
5
|
+
import { createPortal } from 'react-dom';
|
|
6
|
+
|
|
7
|
+
import { useMediaState } from '../../hooks/use-media-state';
|
|
8
|
+
import {
|
|
9
|
+
MenuButtonInstance,
|
|
10
|
+
MenuInstance,
|
|
11
|
+
MenuItemInstance,
|
|
12
|
+
MenuItemsInstance,
|
|
13
|
+
MenuPortalInstance,
|
|
14
|
+
} from '../primitives/instances';
|
|
15
|
+
import { Primitive } from '../primitives/nodes';
|
|
16
|
+
|
|
17
|
+
/* -------------------------------------------------------------------------------------------------
|
|
18
|
+
* Menu
|
|
19
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
20
|
+
|
|
21
|
+
const MenuBridge = createReactComponent(MenuInstance, {
|
|
22
|
+
events: ['onOpen', 'onClose'],
|
|
23
|
+
domEventsRegex: /^onMedia/,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export interface RootProps extends ReactElementProps<MenuInstance> {
|
|
27
|
+
asChild?: boolean;
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
ref?: React.Ref<MenuInstance>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Root menu container used to hold and manage a menu button and menu items. This component is
|
|
34
|
+
* used to display options in a floating panel. They can be nested to create submenus.
|
|
35
|
+
*
|
|
36
|
+
* @docs {@link https://www.vidstack.io/docs/player/components/menu/menu}
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <Menu.Root>
|
|
40
|
+
* <Menu.Button></Menu.Button>
|
|
41
|
+
* <Menu.Content placement="top end"></Menu.Content>
|
|
42
|
+
* </Menu.Root>
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
const Root = React.forwardRef<MenuInstance, RootProps>(({ children, ...props }, forwardRef) => {
|
|
46
|
+
return (
|
|
47
|
+
<MenuBridge {...props} ref={forwardRef}>
|
|
48
|
+
{(props, instance) => (
|
|
49
|
+
<Primitive.div
|
|
50
|
+
{...props}
|
|
51
|
+
style={{ display: !instance.isSubmenu ? 'contents' : undefined, ...props.style }}
|
|
52
|
+
>
|
|
53
|
+
{children}
|
|
54
|
+
</Primitive.div>
|
|
55
|
+
)}
|
|
56
|
+
</MenuBridge>
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
Root.displayName = 'Menu';
|
|
61
|
+
|
|
62
|
+
/* -------------------------------------------------------------------------------------------------
|
|
63
|
+
* MenuButton
|
|
64
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
65
|
+
|
|
66
|
+
const ButtonBridge = createReactComponent(MenuButtonInstance, {
|
|
67
|
+
events: ['onSelect'],
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export interface ButtonProps extends ReactElementProps<MenuButtonInstance, HTMLButtonElement> {
|
|
71
|
+
asChild?: boolean;
|
|
72
|
+
children?: React.ReactNode;
|
|
73
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* A button that controls the opening and closing of a menu component. The button will become a
|
|
78
|
+
* `menuitem` when used inside a submenu.
|
|
79
|
+
*
|
|
80
|
+
* @docs {@link https://www.vidstack.io/docs/player/components/menu/menu}
|
|
81
|
+
* @example
|
|
82
|
+
* ```tsx
|
|
83
|
+
* <Menu.Root>
|
|
84
|
+
* <Menu.Button></Menu.Button>
|
|
85
|
+
* <Menu.Content placement="top end"></Menu.Content>
|
|
86
|
+
* </Menu.Root>
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
90
|
+
({ children, ...props }, forwardRef) => {
|
|
91
|
+
return (
|
|
92
|
+
<ButtonBridge {...(props as Omit<ButtonProps, 'ref'>)}>
|
|
93
|
+
{(props) => (
|
|
94
|
+
<Primitive.button
|
|
95
|
+
{...props}
|
|
96
|
+
ref={composeRefs(props.ref as React.Ref<any>, forwardRef as React.Ref<any>)}
|
|
97
|
+
>
|
|
98
|
+
{children}
|
|
99
|
+
</Primitive.button>
|
|
100
|
+
)}
|
|
101
|
+
</ButtonBridge>
|
|
102
|
+
);
|
|
103
|
+
},
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
Button.displayName = 'MenuButton';
|
|
107
|
+
|
|
108
|
+
/* -------------------------------------------------------------------------------------------------
|
|
109
|
+
* Portal
|
|
110
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
111
|
+
|
|
112
|
+
export interface PortalProps extends ReactElementProps<MenuPortalInstance> {
|
|
113
|
+
asChild?: boolean;
|
|
114
|
+
children?: React.ReactNode;
|
|
115
|
+
ref?: React.Ref<HTMLElement>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Portals menu items into the given container.
|
|
120
|
+
*
|
|
121
|
+
* @docs {@link https://www.vidstack.io/docs/player/components/menu#portal}
|
|
122
|
+
* @example
|
|
123
|
+
* ```tsx
|
|
124
|
+
* <Menu.Root>
|
|
125
|
+
* <Menu.Button></Menu.Button>
|
|
126
|
+
* <Menu.Portal>
|
|
127
|
+
* <Menu.Content placement="top end"></Menu.Content>
|
|
128
|
+
* </Menu.Portal>
|
|
129
|
+
* </Menu.Root>
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
const Portal = React.forwardRef<HTMLElement, PortalProps>(
|
|
133
|
+
({ container = null, disabled = false, children, ...props }, forwardRef) => {
|
|
134
|
+
let fullscreen = useMediaState('fullscreen'),
|
|
135
|
+
shouldPortal = disabled === 'fullscreen' ? !fullscreen : !disabled;
|
|
136
|
+
|
|
137
|
+
const target = React.useMemo(() => {
|
|
138
|
+
if (__SERVER__) return null;
|
|
139
|
+
const node = isString(container) ? document.querySelector(container) : container;
|
|
140
|
+
return node ?? document.body;
|
|
141
|
+
}, [container]);
|
|
142
|
+
|
|
143
|
+
return !target || !shouldPortal
|
|
144
|
+
? children
|
|
145
|
+
: createPortal(
|
|
146
|
+
<Primitive.div
|
|
147
|
+
{...props}
|
|
148
|
+
style={{ display: 'contents', ...props.style }}
|
|
149
|
+
ref={forwardRef as React.Ref<any>}
|
|
150
|
+
>
|
|
151
|
+
{children}
|
|
152
|
+
</Primitive.div>,
|
|
153
|
+
target,
|
|
154
|
+
);
|
|
155
|
+
},
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
Portal.displayName = 'MenuPortal';
|
|
159
|
+
|
|
160
|
+
/* -------------------------------------------------------------------------------------------------
|
|
161
|
+
* MenuItems
|
|
162
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
163
|
+
|
|
164
|
+
const ItemsBridge = createReactComponent(MenuItemsInstance);
|
|
165
|
+
|
|
166
|
+
export interface ItemsProps extends ReactElementProps<MenuItemsInstance> {
|
|
167
|
+
asChild?: boolean;
|
|
168
|
+
children?: React.ReactNode;
|
|
169
|
+
ref?: React.Ref<HTMLElement>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Used to group and display settings or arbitrary content in a floating panel.
|
|
174
|
+
*
|
|
175
|
+
* @docs {@link https://www.vidstack.io/docs/player/components/menu/menu}
|
|
176
|
+
* @example
|
|
177
|
+
* ```tsx
|
|
178
|
+
* <Menu.Root>
|
|
179
|
+
* <Menu.Button></Menu.Button>
|
|
180
|
+
* <Menu.Items placement="top end"></Menu.Items>
|
|
181
|
+
* </Menu.Root>
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
const Items = React.forwardRef<HTMLElement, ItemsProps>(({ children, ...props }, forwardRef) => {
|
|
185
|
+
return (
|
|
186
|
+
<ItemsBridge {...(props as Omit<ItemsProps, 'ref'>)}>
|
|
187
|
+
{(props) => (
|
|
188
|
+
<Primitive.div
|
|
189
|
+
{...props}
|
|
190
|
+
ref={composeRefs(props.ref as React.Ref<any>, forwardRef as React.Ref<any>)}
|
|
191
|
+
>
|
|
192
|
+
{children}
|
|
193
|
+
</Primitive.div>
|
|
194
|
+
)}
|
|
195
|
+
</ItemsBridge>
|
|
196
|
+
);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
Items.displayName = 'MenuItems';
|
|
200
|
+
|
|
201
|
+
/* -------------------------------------------------------------------------------------------------
|
|
202
|
+
* MenuItem
|
|
203
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
204
|
+
|
|
205
|
+
const ItemBridge = createReactComponent(MenuItemInstance);
|
|
206
|
+
|
|
207
|
+
export interface ItemProps extends ReactElementProps<MenuItemInstance> {
|
|
208
|
+
asChild?: boolean;
|
|
209
|
+
children?: React.ReactNode;
|
|
210
|
+
ref?: React.Ref<HTMLElement>;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Represents a specific option or action, typically displayed as a text label or icon, which
|
|
215
|
+
* users can select to access or perform a particular function or view related content.
|
|
216
|
+
*
|
|
217
|
+
* @docs {@link https://www.vidstack.io/docs/player/components/menu/menu}
|
|
218
|
+
* @example
|
|
219
|
+
* ```tsx
|
|
220
|
+
* <Menu.Root>
|
|
221
|
+
* <Menu.Button></Menu.Button>
|
|
222
|
+
* <Menu.Content placement="top end">
|
|
223
|
+
* <Menu.Item></Menu.Item>
|
|
224
|
+
* </Menu.Content>
|
|
225
|
+
* </Menu.Root>
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
const Item = React.forwardRef<HTMLElement, ItemProps>(({ children, ...props }, forwardRef) => {
|
|
229
|
+
return (
|
|
230
|
+
<ItemBridge {...(props as Omit<ItemProps, 'ref'>)}>
|
|
231
|
+
{(props) => (
|
|
232
|
+
<Primitive.div
|
|
233
|
+
{...props}
|
|
234
|
+
ref={composeRefs(props.ref as React.Ref<any>, forwardRef as React.Ref<any>)}
|
|
235
|
+
>
|
|
236
|
+
{children}
|
|
237
|
+
</Primitive.div>
|
|
238
|
+
)}
|
|
239
|
+
</ItemBridge>
|
|
240
|
+
);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
Item.displayName = 'MenuItem';
|
|
244
|
+
|
|
245
|
+
export { Root, Button, Portal, Items, Items as Content, type ItemsProps as ContentProps, Item };
|
|
246
|
+
export {
|
|
247
|
+
Root as RadioGroup,
|
|
248
|
+
Item as Radio,
|
|
249
|
+
type RootProps as RadioGroupProps,
|
|
250
|
+
type ItemProps as RadioProps,
|
|
251
|
+
} from './radio-group';
|