@gravity-ui/page-constructor 1.26.2 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/build/cjs/blocks/FilterBlock/schema.js +1 -1
- package/build/cjs/components/Media/Video/Video.d.ts +1 -1
- package/build/cjs/components/Media/Video/Video.js +8 -7
- package/build/cjs/components/ReactPlayer/CustomBarControls.css +21 -0
- package/build/cjs/components/ReactPlayer/CustomBarControls.d.ts +5 -1
- package/build/cjs/components/ReactPlayer/CustomBarControls.js +22 -7
- package/build/cjs/components/ReactPlayer/ReactPlayer.css +12 -0
- package/build/cjs/components/ReactPlayer/ReactPlayer.js +40 -52
- package/build/cjs/components/ReactPlayer/i18n/en.json +4 -0
- package/build/cjs/components/ReactPlayer/i18n/index.d.ts +2 -0
- package/build/cjs/components/ReactPlayer/i18n/index.js +8 -0
- package/build/cjs/components/ReactPlayer/i18n/ru.json +4 -0
- package/build/cjs/icons/VideoControlPause.d.ts +2 -0
- package/build/cjs/icons/VideoControlPause.js +16 -0
- package/build/cjs/icons/VideoControlPlay.d.ts +2 -0
- package/build/cjs/icons/VideoControlPlay.js +12 -0
- package/build/cjs/models/constructor-items/common.d.ts +9 -29
- package/build/cjs/models/constructor-items/common.js +6 -1
- package/build/cjs/schema/index.js +2 -1
- package/build/cjs/schema/validators/blocks.d.ts +1 -0
- package/build/cjs/schema/validators/blocks.js +1 -0
- package/build/esm/blocks/FilterBlock/schema.js +1 -1
- package/build/esm/components/Media/Video/Video.d.ts +1 -1
- package/build/esm/components/Media/Video/Video.js +6 -5
- package/build/esm/components/ReactPlayer/CustomBarControls.css +21 -0
- package/build/esm/components/ReactPlayer/CustomBarControls.d.ts +5 -1
- package/build/esm/components/ReactPlayer/CustomBarControls.js +23 -8
- package/build/esm/components/ReactPlayer/ReactPlayer.css +12 -0
- package/build/esm/components/ReactPlayer/ReactPlayer.js +41 -53
- package/build/esm/components/ReactPlayer/i18n/en.json +4 -0
- package/build/esm/components/ReactPlayer/i18n/index.d.ts +2 -0
- package/build/esm/components/ReactPlayer/i18n/index.js +5 -0
- package/build/esm/components/ReactPlayer/i18n/ru.json +4 -0
- package/build/esm/icons/VideoControlPause.d.ts +2 -0
- package/build/esm/icons/VideoControlPause.js +11 -0
- package/build/esm/icons/VideoControlPlay.d.ts +2 -0
- package/build/esm/icons/VideoControlPlay.js +7 -0
- package/build/esm/models/constructor-items/common.d.ts +9 -29
- package/build/esm/models/constructor-items/common.js +5 -0
- package/build/esm/schema/index.js +3 -2
- package/build/esm/schema/validators/blocks.d.ts +1 -0
- package/build/esm/schema/validators/blocks.js +1 -0
- package/package.json +1 -1
- package/server/models/constructor-items/common.d.ts +9 -29
- package/server/models/constructor-items/common.js +6 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
import { MediaVideoType } from '../../../models';
|
|
3
|
+
import { block } from '../../../utils';
|
|
3
4
|
import ReactPlayerBlock from '../../ReactPlayer/ReactPlayer';
|
|
4
5
|
import { getVideoTypesWithPriority } from './utils';
|
|
5
|
-
import { block } from '../../../utils';
|
|
6
6
|
import './Video.css';
|
|
7
7
|
const b = block('media-component-video');
|
|
8
8
|
const Video = (props) => {
|
|
@@ -20,7 +20,7 @@ const Video = (props) => {
|
|
|
20
20
|
videoRef.currentTime = start;
|
|
21
21
|
videoRef.play().catch(() => setHasVideoFallback(true));
|
|
22
22
|
}
|
|
23
|
-
});
|
|
23
|
+
}, { passive: true });
|
|
24
24
|
}
|
|
25
25
|
if (playVideo) {
|
|
26
26
|
ref.current.play().catch(() => setHasVideoFallback(true));
|
|
@@ -28,8 +28,8 @@ const Video = (props) => {
|
|
|
28
28
|
}
|
|
29
29
|
}, [playVideo, video, setHasVideoFallback]);
|
|
30
30
|
const reactPlayerBlock = useMemo(() => {
|
|
31
|
-
const { src, loop, controls, muted, autoplay = true, elapsedTime, playButton } = video;
|
|
32
|
-
return (React.createElement(ReactPlayerBlock, { className: b('react-player', videoClassName), src: src, previewImgUrl: previewImg, loop: Boolean(loop), controls: controls, muted: muted, autoplay: autoplay && playVideo, elapsedTime: elapsedTime, playButton: playButton || commonPlayButton, customBarControlsClassName: customBarControlsClassName, metrika: metrika, analyticsEvents: analyticsEvents, height: height }));
|
|
31
|
+
const { src, loop, controls, muted, autoplay = true, elapsedTime, playButton, ariaLabel, customControlsOptions, } = video;
|
|
32
|
+
return (React.createElement(ReactPlayerBlock, { className: b('react-player', videoClassName), src: src, previewImgUrl: previewImg, loop: Boolean(loop), controls: controls, muted: muted, autoplay: autoplay && playVideo, elapsedTime: elapsedTime, playButton: playButton || commonPlayButton, customBarControlsClassName: customBarControlsClassName, metrika: metrika, analyticsEvents: analyticsEvents, height: height, ariaLabel: ariaLabel, customControlsOptions: customControlsOptions }));
|
|
33
33
|
}, [
|
|
34
34
|
video,
|
|
35
35
|
height,
|
|
@@ -45,7 +45,8 @@ const Video = (props) => {
|
|
|
45
45
|
return video.src.length && !hasVideoFallback ? (React.createElement("div", { className: b('wrap', videoClassName), style: { height } },
|
|
46
46
|
React.createElement("video", { disablePictureInPicture: true, playsInline: true,
|
|
47
47
|
// @ts-ignore
|
|
48
|
-
|
|
48
|
+
// eslint-disable-next-line react/no-unknown-property
|
|
49
|
+
pip: "false", className: b('item'), ref: ref, preload: "metadata", muted: true, "aria-label": video.ariaLabel }, getVideoTypesWithPriority(video.src).map(({ src, type }, index) => (React.createElement("source", { key: index, src: src, type: type })))))) : null;
|
|
49
50
|
}, [video, videoClassName, hasVideoFallback, height]);
|
|
50
51
|
switch (video.type) {
|
|
51
52
|
case MediaVideoType.Player:
|
|
@@ -4,6 +4,10 @@ unpredictable css rules order in build */
|
|
|
4
4
|
position: absolute;
|
|
5
5
|
bottom: 0;
|
|
6
6
|
}
|
|
7
|
+
.pc-CustomBarControls__wrapper_type_with-play-pause-button {
|
|
8
|
+
width: 100%;
|
|
9
|
+
padding: 20px;
|
|
10
|
+
}
|
|
7
11
|
.pc-CustomBarControls__button {
|
|
8
12
|
margin: 12px;
|
|
9
13
|
border-radius: 50%;
|
|
@@ -18,6 +22,23 @@ unpredictable css rules order in build */
|
|
|
18
22
|
.pc-CustomBarControls__button:hover {
|
|
19
23
|
background: #eff2f8;
|
|
20
24
|
}
|
|
25
|
+
.pc-CustomBarControls__play-button {
|
|
26
|
+
opacity: 0.9;
|
|
27
|
+
background-color: transparent;
|
|
28
|
+
border: 0;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
transition: opacity 300ms ease 3s;
|
|
31
|
+
}
|
|
32
|
+
.pc-CustomBarControls__play-button:hover, .pc-CustomBarControls__play-button:focus {
|
|
33
|
+
opacity: 1;
|
|
34
|
+
}
|
|
35
|
+
.pc-CustomBarControls__play-button:focus {
|
|
36
|
+
outline: 1px solid var(--g-color-line-light);
|
|
37
|
+
border-radius: 4px;
|
|
38
|
+
}
|
|
39
|
+
.pc-CustomBarControls__play-button:focus:not(:focus-visible) {
|
|
40
|
+
outline: none;
|
|
41
|
+
}
|
|
21
42
|
.pc-CustomBarControls__icon {
|
|
22
43
|
margin: auto;
|
|
23
44
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ClassNameProps } from '../../models';
|
|
2
|
+
import { ClassNameProps, CustomControlsType } from '../../models';
|
|
3
3
|
import './CustomBarControls.css';
|
|
4
4
|
interface MuteConfigProps {
|
|
5
5
|
isMuted: boolean;
|
|
@@ -8,6 +8,10 @@ interface MuteConfigProps {
|
|
|
8
8
|
export interface CustomBarControlsProps extends ClassNameProps {
|
|
9
9
|
mute?: MuteConfigProps;
|
|
10
10
|
elapsedTimePercent?: number;
|
|
11
|
+
type?: CustomControlsType;
|
|
12
|
+
isPaused?: boolean;
|
|
13
|
+
onPlayClick?: () => void;
|
|
14
|
+
isStarted?: boolean;
|
|
11
15
|
}
|
|
12
16
|
declare const CustomBarControls: (props: CustomBarControlsProps) => JSX.Element;
|
|
13
17
|
export default CustomBarControls;
|
|
@@ -1,19 +1,34 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { Icon } from '@gravity-ui/uikit';
|
|
3
|
+
import { VideoControlPause } from '../../icons/VideoControlPause';
|
|
4
|
+
import { VideoControlPlay } from '../../icons/VideoControlPlay';
|
|
5
|
+
import { CustomControlsType } from '../../models';
|
|
2
6
|
import { block } from '../../utils';
|
|
3
7
|
import CircleProgress from './CircleProgress';
|
|
8
|
+
import i18n from './i18n';
|
|
4
9
|
import './CustomBarControls.css';
|
|
5
10
|
const b = block('CustomBarControls');
|
|
11
|
+
const PLAY_PAUSE_ICON_SIZE = 24;
|
|
6
12
|
const CustomBarControls = (props) => {
|
|
7
|
-
const { mute, elapsedTimePercent = 0, className } = props;
|
|
8
|
-
const
|
|
9
|
-
if (!
|
|
13
|
+
const { mute, elapsedTimePercent = 0, className, type = CustomControlsType.WithMuteButton, isPaused, onPlayClick, isStarted = false, } = props;
|
|
14
|
+
const muteButton = useMemo(() => {
|
|
15
|
+
if (!mute || type === CustomControlsType.WithPlayPauseButton) {
|
|
16
|
+
// mute button is not provided for with-play-pause-button
|
|
10
17
|
return null;
|
|
11
18
|
}
|
|
12
|
-
const { isMuted, changeMute } =
|
|
19
|
+
const { isMuted, changeMute } = mute;
|
|
13
20
|
return (React.createElement("div", { className: b('button'), onClick: changeMute },
|
|
14
21
|
React.createElement("div", { className: b('mute-button', { muted: isMuted }) }),
|
|
15
|
-
!isMuted && React.createElement(CircleProgress, { elapsedTime:
|
|
16
|
-
}, []);
|
|
17
|
-
|
|
22
|
+
!isMuted && React.createElement(CircleProgress, { elapsedTime: elapsedTimePercent, strokeWidth: 5 })));
|
|
23
|
+
}, [elapsedTimePercent, mute, type]);
|
|
24
|
+
const playPauseButton = useMemo(() => {
|
|
25
|
+
if (type !== CustomControlsType.WithPlayPauseButton || !isStarted) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return (React.createElement("button", { onClick: onPlayClick, className: b('play-button'), "aria-label": i18n(isPaused ? 'play' : 'pause') }, isPaused ? (React.createElement(Icon, { data: VideoControlPlay, size: PLAY_PAUSE_ICON_SIZE })) : (React.createElement(Icon, { data: VideoControlPause, size: PLAY_PAUSE_ICON_SIZE }))));
|
|
29
|
+
}, [isPaused, isStarted, onPlayClick, type]);
|
|
30
|
+
return (React.createElement("div", { className: b('wrapper', { type }, className) },
|
|
31
|
+
muteButton,
|
|
32
|
+
playPauseButton));
|
|
18
33
|
};
|
|
19
34
|
export default CustomBarControls;
|
|
@@ -50,6 +50,18 @@ unpredictable css rules order in build */
|
|
|
50
50
|
opacity: 1;
|
|
51
51
|
transition: opacity 300ms ease 0s;
|
|
52
52
|
}
|
|
53
|
+
.pc-ReactPlayer_started.pc-ReactPlayer_controls_custom.pc-ReactPlayer_hovered::before {
|
|
54
|
+
opacity: 1;
|
|
55
|
+
}
|
|
56
|
+
.pc-ReactPlayer_started.pc-ReactPlayer_controls_custom::before {
|
|
57
|
+
position: absolute;
|
|
58
|
+
width: 100%;
|
|
59
|
+
height: 100%;
|
|
60
|
+
content: "";
|
|
61
|
+
background: linear-gradient(180deg, rgba(0, 0, 0, 0) 65.36%, rgba(0, 0, 0, 0.35) 100%);
|
|
62
|
+
opacity: 0;
|
|
63
|
+
transition: opacity 300ms;
|
|
64
|
+
}
|
|
53
65
|
.pc-ReactPlayer__custom-bar-controls {
|
|
54
66
|
opacity: 0;
|
|
55
67
|
transition: opacity 300ms ease 3s;
|
|
@@ -3,14 +3,12 @@ import ReactPlayer from 'react-player';
|
|
|
3
3
|
import React, { useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState, } from 'react';
|
|
4
4
|
import { Icon } from '@gravity-ui/uikit';
|
|
5
5
|
import { block } from '../../utils';
|
|
6
|
-
import { PlayButtonThemes, PlayButtonType, MediaVideoControlsType,
|
|
6
|
+
import { CustomControlsType, PlayButtonThemes, PlayButtonType, MediaVideoControlsType, } from '../../models';
|
|
7
7
|
import CustomBarControls from './CustomBarControls';
|
|
8
8
|
import { VideoContext } from '../../context/videoContext';
|
|
9
9
|
import { MetrikaContext } from '../../context/metrikaContext';
|
|
10
10
|
import { MobileContext } from '../../context/mobileContext';
|
|
11
|
-
import { useAnalytics } from '../../hooks';
|
|
12
11
|
import { PlayVideo } from '../../icons';
|
|
13
|
-
import { checkYoutubeVideos } from './utils';
|
|
14
12
|
import './ReactPlayer.css';
|
|
15
13
|
const b = block('ReactPlayer');
|
|
16
14
|
const FPS = 60;
|
|
@@ -18,8 +16,9 @@ const FPS = 60;
|
|
|
18
16
|
export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
19
17
|
const isMobile = useContext(MobileContext);
|
|
20
18
|
const { metrika } = useContext(MetrikaContext);
|
|
21
|
-
const { src, previewImgUrl, loop = false, controls = MediaVideoControlsType.Default, muted: initiallyMuted = false, elapsedTime, playButton, className, customBarControlsClassName, showPreview, onClickPreview, metrika: videoMetrika,
|
|
19
|
+
const { src, previewImgUrl, loop = false, controls = MediaVideoControlsType.Default, customControlsOptions = {}, muted: initiallyMuted = false, elapsedTime, playButton, className, customBarControlsClassName, showPreview, onClickPreview, metrika: videoMetrika, height, } = props;
|
|
22
20
|
const { type = PlayButtonType.Default, theme = PlayButtonThemes.Blue, text, className: buttonClassName, } = playButton || {};
|
|
21
|
+
const { type: customControlsType = CustomControlsType.WithMuteButton } = customControlsOptions;
|
|
23
22
|
const autoPlay = Boolean(!isMobile && !previewImgUrl && props.autoplay);
|
|
24
23
|
const mute = initiallyMuted || autoPlay;
|
|
25
24
|
const { playingVideoRef, setProps } = useContext(VideoContext);
|
|
@@ -31,16 +30,8 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
31
30
|
const [width, setWidth] = useState(0);
|
|
32
31
|
const [muted, setMuted] = useState(mute);
|
|
33
32
|
const [started, setStarted] = useState(autoPlay);
|
|
34
|
-
const [paused, setPaused] = useState(false);
|
|
35
33
|
const [ended, setEnded] = useState(false);
|
|
36
|
-
const
|
|
37
|
-
const eventsArray = useMemo(() => {
|
|
38
|
-
if (analyticsEvents) {
|
|
39
|
-
return Array.isArray(analyticsEvents) ? analyticsEvents : [analyticsEvents];
|
|
40
|
-
}
|
|
41
|
-
return [];
|
|
42
|
-
}, [analyticsEvents]);
|
|
43
|
-
const handleAnalytics = useAnalytics(DefaultEventNames.ReactPlayerControls);
|
|
34
|
+
const [hovered, setHovered] = useState(false);
|
|
44
35
|
useImperativeHandle(originRef, () => ({
|
|
45
36
|
pause: () => setIsPlaying(false),
|
|
46
37
|
}));
|
|
@@ -48,14 +39,14 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
48
39
|
if (ref.current && !(playingVideoRef === null || playingVideoRef === void 0 ? void 0 : playingVideoRef.contains(ref.current))) {
|
|
49
40
|
setMuted(true);
|
|
50
41
|
}
|
|
51
|
-
}, [playingVideoRef]);
|
|
42
|
+
}, [playingVideoRef, ref]);
|
|
52
43
|
useEffect(() => {
|
|
53
44
|
if (showPreview) {
|
|
54
45
|
playerRef === null || playerRef === void 0 ? void 0 : playerRef.showPreview();
|
|
55
46
|
}
|
|
56
47
|
}, [showPreview, playerRef]);
|
|
57
48
|
useEffect(() => {
|
|
58
|
-
if (playerRef) {
|
|
49
|
+
if (playerRef && autoPlay) {
|
|
59
50
|
setIsPlaying(autoPlay);
|
|
60
51
|
}
|
|
61
52
|
}, [autoPlay, playerRef]);
|
|
@@ -89,8 +80,6 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
89
80
|
window.removeEventListener('resize', updateSize);
|
|
90
81
|
};
|
|
91
82
|
}, []);
|
|
92
|
-
const playEvents = useMemo(() => eventsArray === null || eventsArray === void 0 ? void 0 : eventsArray.filter((e) => e.type === PredefinedEventTypes.Play), [eventsArray]);
|
|
93
|
-
const stopEvents = useMemo(() => eventsArray === null || eventsArray === void 0 ? void 0 : eventsArray.filter((e) => e.type === PredefinedEventTypes.Stop), [eventsArray]);
|
|
94
83
|
const playIcon = useMemo(() => {
|
|
95
84
|
let playButtonContent;
|
|
96
85
|
switch (type) {
|
|
@@ -105,10 +94,6 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
105
94
|
return (React.createElement("button", { className: b('button', { theme, text: Boolean(text) }, buttonClassName) }, playButtonContent));
|
|
106
95
|
}, [type, theme, text, buttonClassName]);
|
|
107
96
|
const changeMute = useCallback((isMuted) => {
|
|
108
|
-
if (isMuted && playerRef) {
|
|
109
|
-
playerRef.seekTo(0);
|
|
110
|
-
setPlayedPercent(0);
|
|
111
|
-
}
|
|
112
97
|
if (metrika && videoMetrika) {
|
|
113
98
|
const { play, stop, counterName } = videoMetrika;
|
|
114
99
|
const goal = isMuted ? play : stop;
|
|
@@ -116,15 +101,12 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
116
101
|
metrika.reachGoals(goal, counterName);
|
|
117
102
|
}
|
|
118
103
|
}
|
|
119
|
-
const events = isMuted ? playEvents : stopEvents;
|
|
120
|
-
handleAnalytics(events);
|
|
121
104
|
if (isMuted) {
|
|
122
105
|
setProps({ playingVideoRef: ref.current });
|
|
123
106
|
}
|
|
124
107
|
// In order to the progress bar to update (equals 0) before displaying
|
|
125
108
|
setTimeout(() => setMuted(!isMuted), 0);
|
|
126
|
-
}, [
|
|
127
|
-
const handleClick = useCallback(() => changeMute(muted), [changeMute, muted]);
|
|
109
|
+
}, [metrika, videoMetrika, setProps]);
|
|
128
110
|
const handleClickPreview = useCallback(() => {
|
|
129
111
|
setIsPlaying(true);
|
|
130
112
|
onClickPreview === null || onClickPreview === void 0 ? void 0 : onClickPreview();
|
|
@@ -134,16 +116,10 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
134
116
|
metrika.reachGoals(play, counterName);
|
|
135
117
|
}
|
|
136
118
|
}
|
|
137
|
-
|
|
138
|
-
}, [onClickPreview, metrika, videoMetrika, handleAnalytics, playEvents]);
|
|
119
|
+
}, [onClickPreview, setIsPlaying, videoMetrika, metrika]);
|
|
139
120
|
const onPause = useCallback(() => {
|
|
140
|
-
// For support correct state for youtube
|
|
141
121
|
setIsPlaying(false);
|
|
142
|
-
|
|
143
|
-
setPaused(true);
|
|
144
|
-
setIsPlaying(true);
|
|
145
|
-
}
|
|
146
|
-
}, [controls, setIsPlaying, setPaused]);
|
|
122
|
+
}, []);
|
|
147
123
|
const onStart = useCallback(() => {
|
|
148
124
|
if (!autoPlay && !initiallyMuted) {
|
|
149
125
|
setMuted(false);
|
|
@@ -152,21 +128,17 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
152
128
|
const onPlay = useCallback(() => {
|
|
153
129
|
setIsPlaying(true);
|
|
154
130
|
if (controls === MediaVideoControlsType.Custom) {
|
|
155
|
-
|
|
156
|
-
changeMute(false);
|
|
157
|
-
}
|
|
158
|
-
else if (paused) {
|
|
159
|
-
changeMute(muted);
|
|
160
|
-
}
|
|
161
|
-
setEnded(false);
|
|
162
|
-
setPaused(false);
|
|
131
|
+
changeMute(true);
|
|
163
132
|
}
|
|
164
|
-
}, [changeMute, controls
|
|
133
|
+
}, [changeMute, controls]);
|
|
165
134
|
const onProgress = useCallback((progress) => {
|
|
166
135
|
setPlayedPercent(progress.played);
|
|
167
136
|
if (progress.played === 1) {
|
|
168
137
|
setMuted(true);
|
|
169
138
|
}
|
|
139
|
+
else {
|
|
140
|
+
setEnded(false);
|
|
141
|
+
}
|
|
170
142
|
}, []);
|
|
171
143
|
const onEnded = useCallback(() => {
|
|
172
144
|
// Youtube videos not muted after finishing playing and start again.
|
|
@@ -179,21 +151,37 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
179
151
|
}
|
|
180
152
|
setEnded(true);
|
|
181
153
|
}, [loop, playerRef]);
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
184
|
-
|
|
154
|
+
const onPlayClick = useCallback(() => {
|
|
155
|
+
if (isPlaying) {
|
|
156
|
+
onPause();
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
onPlay();
|
|
185
160
|
}
|
|
186
|
-
|
|
187
|
-
|
|
161
|
+
}, [isPlaying, onPause, onPlay]);
|
|
162
|
+
const handleClick = useCallback(() => {
|
|
163
|
+
if (customControlsType === CustomControlsType.WithMuteButton) {
|
|
164
|
+
changeMute(muted);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
onPlayClick();
|
|
168
|
+
}
|
|
169
|
+
if (ended) {
|
|
170
|
+
playerRef === null || playerRef === void 0 ? void 0 : playerRef.seekTo(0);
|
|
171
|
+
onPlay();
|
|
172
|
+
}
|
|
173
|
+
}, [changeMute, customControlsType, ended, muted, onPlay, onPlayClick, playerRef]);
|
|
174
|
+
const onFocusIn = useCallback(() => setHovered(true), []);
|
|
175
|
+
const onFocusOut = useCallback(() => setHovered(false), []);
|
|
176
|
+
return (React.createElement("div", { className: b({ wrapper: !currentHeight, controls, started, hovered }, className), ref: ref, onClick: handleClick, onMouseEnter: onFocusIn, onMouseLeave: onFocusOut, onFocus: onFocusIn, onBlur: onFocusOut },
|
|
177
|
+
React.createElement(ReactPlayer, { className: b('player'), url: src, muted: muted, controls: controls === MediaVideoControlsType.Default, height: currentHeight || '100%', width: width || '100%', light: previewImgUrl, playing: isPlaying, playIcon: playIcon, progressInterval: FPS, onClickPreview: handleClickPreview, onStart: onStart, onReady: setPlayerRef, onPlay: onPlay, onPause: onPause, onProgress: onProgress, onEnded: onEnded }),
|
|
178
|
+
controls === MediaVideoControlsType.Custom && (React.createElement(CustomBarControls, { className: b('custom-bar-controls', { muted }, customBarControlsClassName), mute: {
|
|
179
|
+
isMuted: muted,
|
|
188
180
|
changeMute: (event) => {
|
|
189
181
|
event.stopPropagation();
|
|
190
|
-
changeMute(
|
|
182
|
+
changeMute(muted);
|
|
191
183
|
},
|
|
192
|
-
}, elapsedTimePercent:
|
|
193
|
-
}, [controls, isPlaying, customBarControlsClassName, changeMute]);
|
|
194
|
-
return (React.createElement("div", { className: b({ wrapper: !currentHeight }, className), ref: ref, onClick: handleClick },
|
|
195
|
-
React.createElement(ReactPlayer, { className: b('player'), url: videoSrc, muted: muted, controls: controls === MediaVideoControlsType.Default, height: currentHeight || '100%', width: width || '100%', light: previewImgUrl, playing: isPlaying, playIcon: playIcon, progressInterval: FPS, onClickPreview: handleClickPreview, onStart: onStart, onReady: setPlayerRef, onPlay: onPlay, onPause: onPause, onProgress: onProgress, onEnded: onEnded }),
|
|
196
|
-
renderCustomBarControls(muted, playedPercent)));
|
|
184
|
+
}, elapsedTimePercent: playedPercent, type: customControlsType, isPaused: !isPlaying, onPlayClick: onPlayClick, isStarted: started }))));
|
|
197
185
|
});
|
|
198
186
|
function getHeight(width) {
|
|
199
187
|
return (width / 16) * 9;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { a11yHiddenSvgProps } from '../utils/svg';
|
|
3
|
+
export const VideoControlPause = (props) => {
|
|
4
|
+
return (React.createElement("svg", Object.assign({ width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, a11yHiddenSvgProps, props),
|
|
5
|
+
React.createElement("g", { opacity: "0.9" },
|
|
6
|
+
React.createElement("mask", { id: "path-1-outside-1_1237_523", maskUnits: "userSpaceOnUse", x: "1", y: "0", width: "22", height: "24", fill: "black" },
|
|
7
|
+
React.createElement("rect", { fill: "white", x: "1", width: "22", height: "24" }),
|
|
8
|
+
React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M4 1C2.89543 1 2 1.89543 2 3V21C2 22.1046 2.89543 23 4 23H8C9.10457 23 10 22.1046 10 21V3C10 1.89543 9.10457 1 8 1H4ZM16 1C14.8954 1 14 1.89543 14 3V21C14 22.1046 14.8954 23 16 23H20C21.1046 23 22 22.1046 22 21V3C22 1.89543 21.1046 1 20 1H16Z" })),
|
|
9
|
+
React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M4 1C2.89543 1 2 1.89543 2 3V21C2 22.1046 2.89543 23 4 23H8C9.10457 23 10 22.1046 10 21V3C10 1.89543 9.10457 1 8 1H4ZM16 1C14.8954 1 14 1.89543 14 3V21C14 22.1046 14.8954 23 16 23H20C21.1046 23 22 22.1046 22 21V3C22 1.89543 21.1046 1 20 1H16Z", fill: "white" }),
|
|
10
|
+
React.createElement("path", { d: "M3 3C3 2.44772 3.44771 2 4 2V0C2.34315 0 1 1.34314 1 3H3ZM3 21V3H1V21H3ZM4 22C3.44772 22 3 21.5523 3 21H1C1 22.6569 2.34315 24 4 24V22ZM8 22H4V24H8V22ZM9 21C9 21.5523 8.55229 22 8 22V24C9.65685 24 11 22.6569 11 21H9ZM9 3V21H11V3H9ZM8 2C8.55228 2 9 2.44772 9 3H11C11 1.34315 9.65685 0 8 0V2ZM4 2H8V0H4V2ZM15 3C15 2.44772 15.4477 2 16 2V0C14.3431 0 13 1.34314 13 3H15ZM15 21V3H13V21H15ZM16 22C15.4477 22 15 21.5523 15 21H13C13 22.6569 14.3431 24 16 24V22ZM20 22H16V24H20V22ZM21 21C21 21.5523 20.5523 22 20 22V24C21.6569 24 23 22.6569 23 21H21ZM21 3V21H23V3H21ZM20 2C20.5523 2 21 2.44772 21 3H23C23 1.34315 21.6569 0 20 0V2ZM16 2H20V0H16V2Z", fill: "black", fillOpacity: "0.15", mask: "url(#path-1-outside-1_1237_523)" }))));
|
|
11
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { a11yHiddenSvgProps } from '../utils/svg';
|
|
3
|
+
export const VideoControlPlay = (props) => {
|
|
4
|
+
return (React.createElement("svg", Object.assign({ width: "24", height: "26", viewBox: "0 0 24 26", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, a11yHiddenSvgProps, props),
|
|
5
|
+
React.createElement("path", { d: "M20.5028 15.6408C22.4991 14.4663 22.4991 11.5337 20.5028 10.3592L6.99778 2.41411C4.99944 1.23846 2.5 2.70595 2.5 5.05488L2.5 20.9451C2.5 23.2941 4.99943 24.7615 6.99777 23.5859L20.5028 15.6408Z", fill: "white" }),
|
|
6
|
+
React.createElement("path", { d: "M20.7563 16.0717C23.0812 14.7039 23.0812 11.2961 20.7563 9.92827L7.25131 1.98315C4.90651 0.603685 2 2.33458 2 5.05488L2 20.9451C2 23.6654 4.90651 25.3963 7.25131 24.0168L20.7563 16.0717Z", stroke: "black", strokeOpacity: "0.15" })));
|
|
7
|
+
};
|
|
@@ -29,6 +29,10 @@ export declare enum PlayButtonThemes {
|
|
|
29
29
|
Blue = "blue",
|
|
30
30
|
Grey = "grey"
|
|
31
31
|
}
|
|
32
|
+
export declare enum CustomControlsType {
|
|
33
|
+
WithMuteButton = "with-mute-button",
|
|
34
|
+
WithPlayPauseButton = "with-play-pause-button"
|
|
35
|
+
}
|
|
32
36
|
export declare enum MediaVideoType {
|
|
33
37
|
Default = "default",
|
|
34
38
|
Player = "player"
|
|
@@ -109,7 +113,9 @@ export interface MediaVideoProps extends AnalyticsEventsBase {
|
|
|
109
113
|
elapsedTime?: number;
|
|
110
114
|
playButton?: PlayButtonProps;
|
|
111
115
|
controls?: MediaVideoControlsType;
|
|
116
|
+
customControlsOptions?: CustomControlsOptions;
|
|
112
117
|
metrika?: MetrikaVideo;
|
|
118
|
+
ariaLabel?: string;
|
|
113
119
|
}
|
|
114
120
|
export interface LinkProps extends AnalyticsEventsBase, Stylable {
|
|
115
121
|
url: string;
|
|
@@ -146,22 +152,14 @@ export interface ButtonImageProps {
|
|
|
146
152
|
position?: 'left' | 'right';
|
|
147
153
|
alt?: string;
|
|
148
154
|
}
|
|
155
|
+
export interface CustomControlsOptions {
|
|
156
|
+
type?: CustomControlsType;
|
|
157
|
+
}
|
|
149
158
|
export interface PlayButtonProps extends ClassNameProps {
|
|
150
159
|
type?: PlayButtonType;
|
|
151
160
|
theme?: PlayButtonThemes;
|
|
152
161
|
text?: string;
|
|
153
162
|
}
|
|
154
|
-
export interface MediaVideoProps {
|
|
155
|
-
src: string[];
|
|
156
|
-
type?: MediaVideoType;
|
|
157
|
-
loop?: LoopProps | boolean;
|
|
158
|
-
muted?: boolean;
|
|
159
|
-
autoplay?: boolean;
|
|
160
|
-
elapsedTime?: number;
|
|
161
|
-
playButton?: PlayButtonProps;
|
|
162
|
-
controls?: MediaVideoControlsType;
|
|
163
|
-
metrika?: MetrikaVideo;
|
|
164
|
-
}
|
|
165
163
|
export type ThemedMediaVideoProps = ThemeSupporting<MediaVideoProps>;
|
|
166
164
|
export interface MediaComponentVideoProps extends AnalyticsEventsBase {
|
|
167
165
|
video: MediaVideoProps;
|
|
@@ -318,24 +316,6 @@ export interface PriceDetailedProps extends CardBaseProps {
|
|
|
318
316
|
foldable?: PriceFoldableDetailsProps;
|
|
319
317
|
labelsDefaultText?: Record<PriceLabelColor, string>;
|
|
320
318
|
}
|
|
321
|
-
export interface PriceDetailedProps extends CardBaseProps {
|
|
322
|
-
items: PriceItemProps[];
|
|
323
|
-
description?: {
|
|
324
|
-
titleSize?: TextSize;
|
|
325
|
-
descriptionSize?: TextSize;
|
|
326
|
-
titleColor?: PriceDescriptionColor;
|
|
327
|
-
};
|
|
328
|
-
details?: {
|
|
329
|
-
titleSize?: TextSize;
|
|
330
|
-
descriptionSize?: TextSize;
|
|
331
|
-
};
|
|
332
|
-
priceType?: PriceDetailsType;
|
|
333
|
-
numberGroupItems?: 3 | 4 | 5;
|
|
334
|
-
isCombined?: boolean;
|
|
335
|
-
useMixedView?: boolean;
|
|
336
|
-
foldable?: PriceFoldableDetailsProps;
|
|
337
|
-
labelsDefaultText?: Record<PriceLabelColor, string>;
|
|
338
|
-
}
|
|
339
319
|
export interface AuthorProps {
|
|
340
320
|
author: AuthorItem;
|
|
341
321
|
className?: string;
|
|
@@ -32,6 +32,11 @@ export var PlayButtonThemes;
|
|
|
32
32
|
PlayButtonThemes["Blue"] = "blue";
|
|
33
33
|
PlayButtonThemes["Grey"] = "grey";
|
|
34
34
|
})(PlayButtonThemes || (PlayButtonThemes = {}));
|
|
35
|
+
export var CustomControlsType;
|
|
36
|
+
(function (CustomControlsType) {
|
|
37
|
+
CustomControlsType["WithMuteButton"] = "with-mute-button";
|
|
38
|
+
CustomControlsType["WithPlayPauseButton"] = "with-play-pause-button";
|
|
39
|
+
})(CustomControlsType || (CustomControlsType = {}));
|
|
35
40
|
export var MediaVideoType;
|
|
36
41
|
(function (MediaVideoType) {
|
|
37
42
|
MediaVideoType["Default"] = "default";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { validators } from './validators';
|
|
2
|
-
import { TabsBlock, BannerCard, SliderBlock, ExtendedFeaturesBlock, HeaderBlock, BannerBlock, CompaniesBlock, MediaBlock, InfoBlock, QuestionsBlock, SecurityBlock, TableBlock, SimpleBlock, LinkTableBlock, PromoFeaturesBlock, PreviewBlock, ContentLayoutBlock, HeaderSliderBlock, IconsBlock, CardLayoutBlock, ShareBlock, MapBlock, } from './validators/blocks';
|
|
2
|
+
import { TabsBlock, BannerCard, SliderBlock, ExtendedFeaturesBlock, HeaderBlock, BannerBlock, CompaniesBlock, MediaBlock, InfoBlock, QuestionsBlock, SecurityBlock, TableBlock, SimpleBlock, LinkTableBlock, PromoFeaturesBlock, PreviewBlock, ContentLayoutBlock, HeaderSliderBlock, IconsBlock, CardLayoutBlock, ShareBlock, MapBlock, FilterBlock, } from './validators/blocks';
|
|
3
3
|
import { PartnerBlock, MediaCardBlock, TutorialCard, BackgroundCard, NewsCard, CardWithImage, PriceDetailedBlock, Quote, Divider, BasicCard, } from './validators/sub-blocks';
|
|
4
4
|
import { AnimatableProps, BackgroundProps, MenuProps, withTheme } from './validators/common';
|
|
5
5
|
import { filteredItem } from './validators/utils';
|
|
@@ -9,7 +9,7 @@ export const getBlocksCases = (blocks) => {
|
|
|
9
9
|
};
|
|
10
10
|
export function generateDefaultSchema(config) {
|
|
11
11
|
const { cards = {}, blocks = {}, extensions = {} } = config !== null && config !== void 0 ? config : {};
|
|
12
|
-
const blockValidators = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, Divider), ExtendedFeaturesBlock), PromoFeaturesBlock), SliderBlock), QuestionsBlock), HeaderBlock), BannerBlock), CompaniesBlock), MediaBlock), MapBlock), InfoBlock), SecurityBlock), TableBlock), TabsBlock), SimpleBlock), LinkTableBlock), PreviewBlock), HeaderSliderBlock), IconsBlock), CardLayoutBlock), ContentLayoutBlock), ShareBlock);
|
|
12
|
+
const blockValidators = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, Divider), ExtendedFeaturesBlock), PromoFeaturesBlock), SliderBlock), QuestionsBlock), HeaderBlock), BannerBlock), CompaniesBlock), MediaBlock), MapBlock), InfoBlock), SecurityBlock), TableBlock), TabsBlock), SimpleBlock), LinkTableBlock), PreviewBlock), HeaderSliderBlock), IconsBlock), CardLayoutBlock), ContentLayoutBlock), ShareBlock), FilterBlock);
|
|
13
13
|
const cardValidators = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, PartnerBlock), MediaCardBlock), BannerCard), PriceDetailedBlock), TutorialCard), BackgroundCard), NewsCard), CardWithImage), Quote), BasicCard);
|
|
14
14
|
const constructorBlockSchemaNames = [
|
|
15
15
|
'divider',
|
|
@@ -39,6 +39,7 @@ export function generateDefaultSchema(config) {
|
|
|
39
39
|
'card-layout-block',
|
|
40
40
|
'content-layout-block',
|
|
41
41
|
'share-block',
|
|
42
|
+
'filter-block',
|
|
42
43
|
];
|
|
43
44
|
const constructorCardSchemaNames = [
|
|
44
45
|
'partner',
|
package/package.json
CHANGED
|
@@ -29,6 +29,10 @@ export declare enum PlayButtonThemes {
|
|
|
29
29
|
Blue = "blue",
|
|
30
30
|
Grey = "grey"
|
|
31
31
|
}
|
|
32
|
+
export declare enum CustomControlsType {
|
|
33
|
+
WithMuteButton = "with-mute-button",
|
|
34
|
+
WithPlayPauseButton = "with-play-pause-button"
|
|
35
|
+
}
|
|
32
36
|
export declare enum MediaVideoType {
|
|
33
37
|
Default = "default",
|
|
34
38
|
Player = "player"
|
|
@@ -109,7 +113,9 @@ export interface MediaVideoProps extends AnalyticsEventsBase {
|
|
|
109
113
|
elapsedTime?: number;
|
|
110
114
|
playButton?: PlayButtonProps;
|
|
111
115
|
controls?: MediaVideoControlsType;
|
|
116
|
+
customControlsOptions?: CustomControlsOptions;
|
|
112
117
|
metrika?: MetrikaVideo;
|
|
118
|
+
ariaLabel?: string;
|
|
113
119
|
}
|
|
114
120
|
export interface LinkProps extends AnalyticsEventsBase, Stylable {
|
|
115
121
|
url: string;
|
|
@@ -146,22 +152,14 @@ export interface ButtonImageProps {
|
|
|
146
152
|
position?: 'left' | 'right';
|
|
147
153
|
alt?: string;
|
|
148
154
|
}
|
|
155
|
+
export interface CustomControlsOptions {
|
|
156
|
+
type?: CustomControlsType;
|
|
157
|
+
}
|
|
149
158
|
export interface PlayButtonProps extends ClassNameProps {
|
|
150
159
|
type?: PlayButtonType;
|
|
151
160
|
theme?: PlayButtonThemes;
|
|
152
161
|
text?: string;
|
|
153
162
|
}
|
|
154
|
-
export interface MediaVideoProps {
|
|
155
|
-
src: string[];
|
|
156
|
-
type?: MediaVideoType;
|
|
157
|
-
loop?: LoopProps | boolean;
|
|
158
|
-
muted?: boolean;
|
|
159
|
-
autoplay?: boolean;
|
|
160
|
-
elapsedTime?: number;
|
|
161
|
-
playButton?: PlayButtonProps;
|
|
162
|
-
controls?: MediaVideoControlsType;
|
|
163
|
-
metrika?: MetrikaVideo;
|
|
164
|
-
}
|
|
165
163
|
export type ThemedMediaVideoProps = ThemeSupporting<MediaVideoProps>;
|
|
166
164
|
export interface MediaComponentVideoProps extends AnalyticsEventsBase {
|
|
167
165
|
video: MediaVideoProps;
|
|
@@ -318,24 +316,6 @@ export interface PriceDetailedProps extends CardBaseProps {
|
|
|
318
316
|
foldable?: PriceFoldableDetailsProps;
|
|
319
317
|
labelsDefaultText?: Record<PriceLabelColor, string>;
|
|
320
318
|
}
|
|
321
|
-
export interface PriceDetailedProps extends CardBaseProps {
|
|
322
|
-
items: PriceItemProps[];
|
|
323
|
-
description?: {
|
|
324
|
-
titleSize?: TextSize;
|
|
325
|
-
descriptionSize?: TextSize;
|
|
326
|
-
titleColor?: PriceDescriptionColor;
|
|
327
|
-
};
|
|
328
|
-
details?: {
|
|
329
|
-
titleSize?: TextSize;
|
|
330
|
-
descriptionSize?: TextSize;
|
|
331
|
-
};
|
|
332
|
-
priceType?: PriceDetailsType;
|
|
333
|
-
numberGroupItems?: 3 | 4 | 5;
|
|
334
|
-
isCombined?: boolean;
|
|
335
|
-
useMixedView?: boolean;
|
|
336
|
-
foldable?: PriceFoldableDetailsProps;
|
|
337
|
-
labelsDefaultText?: Record<PriceLabelColor, string>;
|
|
338
|
-
}
|
|
339
319
|
export interface AuthorProps {
|
|
340
320
|
author: AuthorItem;
|
|
341
321
|
className?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MediaVideoControlsType = exports.MediaVideoType = exports.PlayButtonThemes = exports.PlayButtonType = exports.PreviewItemType = exports.PriceLabelColor = exports.PriceDetailsType = exports.AuthorType = void 0;
|
|
3
|
+
exports.MediaVideoControlsType = exports.MediaVideoType = exports.CustomControlsType = exports.PlayButtonThemes = exports.PlayButtonType = exports.PreviewItemType = exports.PriceLabelColor = exports.PriceDetailsType = exports.AuthorType = void 0;
|
|
4
4
|
// enums
|
|
5
5
|
var AuthorType;
|
|
6
6
|
(function (AuthorType) {
|
|
@@ -35,6 +35,11 @@ var PlayButtonThemes;
|
|
|
35
35
|
PlayButtonThemes["Blue"] = "blue";
|
|
36
36
|
PlayButtonThemes["Grey"] = "grey";
|
|
37
37
|
})(PlayButtonThemes = exports.PlayButtonThemes || (exports.PlayButtonThemes = {}));
|
|
38
|
+
var CustomControlsType;
|
|
39
|
+
(function (CustomControlsType) {
|
|
40
|
+
CustomControlsType["WithMuteButton"] = "with-mute-button";
|
|
41
|
+
CustomControlsType["WithPlayPauseButton"] = "with-play-pause-button";
|
|
42
|
+
})(CustomControlsType = exports.CustomControlsType || (exports.CustomControlsType = {}));
|
|
38
43
|
var MediaVideoType;
|
|
39
44
|
(function (MediaVideoType) {
|
|
40
45
|
MediaVideoType["Default"] = "default";
|