@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.27.0](https://github.com/gravity-ui/page-constructor/compare/v1.26.3...v1.27.0) (2023-08-31)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* adding new media component custom controls type ([#532](https://github.com/gravity-ui/page-constructor/issues/532)) ([6ccb56e](https://github.com/gravity-ui/page-constructor/commit/6ccb56ea052da2b94894e68ad3f17acac3f27cdf))
|
|
9
|
+
|
|
10
|
+
## [1.26.3](https://github.com/gravity-ui/page-constructor/compare/v1.26.2...v1.26.3) (2023-04-03)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **validator:** add FilterBlock to schema validators ([#270](https://github.com/gravity-ui/page-constructor/issues/270)) ([#273](https://github.com/gravity-ui/page-constructor/issues/273)) ([badf4e5](https://github.com/gravity-ui/page-constructor/commit/badf4e5f94bbe087d5f1a197f4f08eb13f7eeef6))
|
|
16
|
+
|
|
3
17
|
## [1.26.2](https://github.com/gravity-ui/page-constructor/compare/v1.26.1...v1.26.2) (2023-03-30)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -10,6 +10,6 @@ interface InnerVideoProps {
|
|
|
10
10
|
setHasVideoFallback: React.Dispatch<boolean>;
|
|
11
11
|
hasVideoFallback: boolean;
|
|
12
12
|
}
|
|
13
|
-
type VideoAllProps = VideoAdditionProps & MediaComponentVideoProps & InnerVideoProps;
|
|
13
|
+
export type VideoAllProps = VideoAdditionProps & MediaComponentVideoProps & InnerVideoProps;
|
|
14
14
|
declare const Video: (props: VideoAllProps) => JSX.Element | null;
|
|
15
15
|
export default Video;
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
5
|
const models_1 = require("../../../models");
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
6
7
|
const ReactPlayer_1 = tslib_1.__importDefault(require("../../ReactPlayer/ReactPlayer"));
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const b = (0, utils_2.block)('media-component-video');
|
|
8
|
+
const utils_2 = require("./utils");
|
|
9
|
+
const b = (0, utils_1.block)('media-component-video');
|
|
10
10
|
const Video = (props) => {
|
|
11
11
|
const { video, height, metrika, analyticsEvents, previewImg, playButton: commonPlayButton, customBarControlsClassName, videoClassName, playVideo, setHasVideoFallback, hasVideoFallback, } = props;
|
|
12
12
|
const ref = (0, react_1.useRef)(null);
|
|
@@ -22,7 +22,7 @@ const Video = (props) => {
|
|
|
22
22
|
videoRef.currentTime = start;
|
|
23
23
|
videoRef.play().catch(() => setHasVideoFallback(true));
|
|
24
24
|
}
|
|
25
|
-
});
|
|
25
|
+
}, { passive: true });
|
|
26
26
|
}
|
|
27
27
|
if (playVideo) {
|
|
28
28
|
ref.current.play().catch(() => setHasVideoFallback(true));
|
|
@@ -30,8 +30,8 @@ const Video = (props) => {
|
|
|
30
30
|
}
|
|
31
31
|
}, [playVideo, video, setHasVideoFallback]);
|
|
32
32
|
const reactPlayerBlock = (0, react_1.useMemo)(() => {
|
|
33
|
-
const { src, loop, controls, muted, autoplay = true, elapsedTime, playButton } = video;
|
|
34
|
-
return (react_1.default.createElement(ReactPlayer_1.default, { 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 }));
|
|
33
|
+
const { src, loop, controls, muted, autoplay = true, elapsedTime, playButton, ariaLabel, customControlsOptions, } = video;
|
|
34
|
+
return (react_1.default.createElement(ReactPlayer_1.default, { 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 }));
|
|
35
35
|
}, [
|
|
36
36
|
video,
|
|
37
37
|
height,
|
|
@@ -47,7 +47,8 @@ const Video = (props) => {
|
|
|
47
47
|
return video.src.length && !hasVideoFallback ? (react_1.default.createElement("div", { className: b('wrap', videoClassName), style: { height } },
|
|
48
48
|
react_1.default.createElement("video", { disablePictureInPicture: true, playsInline: true,
|
|
49
49
|
// @ts-ignore
|
|
50
|
-
|
|
50
|
+
// eslint-disable-next-line react/no-unknown-property
|
|
51
|
+
pip: "false", className: b('item'), ref: ref, preload: "metadata", muted: true, "aria-label": video.ariaLabel }, (0, utils_2.getVideoTypesWithPriority)(video.src).map(({ src, type }, index) => (react_1.default.createElement("source", { key: index, src: src, type: type })))))) : null;
|
|
51
52
|
}, [video, videoClassName, hasVideoFallback, height]);
|
|
52
53
|
switch (video.type) {
|
|
53
54
|
case models_1.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
|
interface MuteConfigProps {
|
|
4
4
|
isMuted: boolean;
|
|
5
5
|
changeMute: (event: React.MouseEvent) => void;
|
|
@@ -7,6 +7,10 @@ interface MuteConfigProps {
|
|
|
7
7
|
export interface CustomBarControlsProps extends ClassNameProps {
|
|
8
8
|
mute?: MuteConfigProps;
|
|
9
9
|
elapsedTimePercent?: number;
|
|
10
|
+
type?: CustomControlsType;
|
|
11
|
+
isPaused?: boolean;
|
|
12
|
+
onPlayClick?: () => void;
|
|
13
|
+
isStarted?: boolean;
|
|
10
14
|
}
|
|
11
15
|
declare const CustomBarControls: (props: CustomBarControlsProps) => JSX.Element;
|
|
12
16
|
export default CustomBarControls;
|
|
@@ -2,20 +2,35 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
6
|
+
const VideoControlPause_1 = require("../../icons/VideoControlPause");
|
|
7
|
+
const VideoControlPlay_1 = require("../../icons/VideoControlPlay");
|
|
8
|
+
const models_1 = require("../../models");
|
|
5
9
|
const utils_1 = require("../../utils");
|
|
6
10
|
const CircleProgress_1 = tslib_1.__importDefault(require("./CircleProgress"));
|
|
11
|
+
const i18n_1 = tslib_1.__importDefault(require("./i18n"));
|
|
7
12
|
const b = (0, utils_1.block)('CustomBarControls');
|
|
13
|
+
const PLAY_PAUSE_ICON_SIZE = 24;
|
|
8
14
|
const CustomBarControls = (props) => {
|
|
9
|
-
const { mute, elapsedTimePercent = 0, className } = props;
|
|
10
|
-
const
|
|
11
|
-
if (!
|
|
15
|
+
const { mute, elapsedTimePercent = 0, className, type = models_1.CustomControlsType.WithMuteButton, isPaused, onPlayClick, isStarted = false, } = props;
|
|
16
|
+
const muteButton = (0, react_1.useMemo)(() => {
|
|
17
|
+
if (!mute || type === models_1.CustomControlsType.WithPlayPauseButton) {
|
|
18
|
+
// mute button is not provided for with-play-pause-button
|
|
12
19
|
return null;
|
|
13
20
|
}
|
|
14
|
-
const { isMuted, changeMute } =
|
|
21
|
+
const { isMuted, changeMute } = mute;
|
|
15
22
|
return (react_1.default.createElement("div", { className: b('button'), onClick: changeMute },
|
|
16
23
|
react_1.default.createElement("div", { className: b('mute-button', { muted: isMuted }) }),
|
|
17
|
-
!isMuted && react_1.default.createElement(CircleProgress_1.default, { elapsedTime:
|
|
18
|
-
}, []);
|
|
19
|
-
|
|
24
|
+
!isMuted && react_1.default.createElement(CircleProgress_1.default, { elapsedTime: elapsedTimePercent, strokeWidth: 5 })));
|
|
25
|
+
}, [elapsedTimePercent, mute, type]);
|
|
26
|
+
const playPauseButton = (0, react_1.useMemo)(() => {
|
|
27
|
+
if (type !== models_1.CustomControlsType.WithPlayPauseButton || !isStarted) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return (react_1.default.createElement("button", { onClick: onPlayClick, className: b('play-button'), "aria-label": (0, i18n_1.default)(isPaused ? 'play' : 'pause') }, isPaused ? (react_1.default.createElement(uikit_1.Icon, { data: VideoControlPlay_1.VideoControlPlay, size: PLAY_PAUSE_ICON_SIZE })) : (react_1.default.createElement(uikit_1.Icon, { data: VideoControlPause_1.VideoControlPause, size: PLAY_PAUSE_ICON_SIZE }))));
|
|
31
|
+
}, [isPaused, isStarted, onPlayClick, type]);
|
|
32
|
+
return (react_1.default.createElement("div", { className: b('wrapper', { type }, className) },
|
|
33
|
+
muteButton,
|
|
34
|
+
playPauseButton));
|
|
20
35
|
};
|
|
21
36
|
exports.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;
|
|
@@ -12,17 +12,16 @@ const CustomBarControls_1 = tslib_1.__importDefault(require("./CustomBarControls
|
|
|
12
12
|
const videoContext_1 = require("../../context/videoContext");
|
|
13
13
|
const metrikaContext_1 = require("../../context/metrikaContext");
|
|
14
14
|
const mobileContext_1 = require("../../context/mobileContext");
|
|
15
|
-
const hooks_1 = require("../../hooks");
|
|
16
15
|
const icons_1 = require("../../icons");
|
|
17
|
-
const utils_2 = require("./utils");
|
|
18
16
|
const b = (0, utils_1.block)('ReactPlayer');
|
|
19
17
|
const FPS = 60;
|
|
20
18
|
// eslint-disable-next-line react/display-name
|
|
21
19
|
exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
22
20
|
const isMobile = (0, react_1.useContext)(mobileContext_1.MobileContext);
|
|
23
21
|
const { metrika } = (0, react_1.useContext)(metrikaContext_1.MetrikaContext);
|
|
24
|
-
const { src, previewImgUrl, loop = false, controls = models_1.MediaVideoControlsType.Default, muted: initiallyMuted = false, elapsedTime, playButton, className, customBarControlsClassName, showPreview, onClickPreview, metrika: videoMetrika,
|
|
22
|
+
const { src, previewImgUrl, loop = false, controls = models_1.MediaVideoControlsType.Default, customControlsOptions = {}, muted: initiallyMuted = false, elapsedTime, playButton, className, customBarControlsClassName, showPreview, onClickPreview, metrika: videoMetrika, height, } = props;
|
|
25
23
|
const { type = models_1.PlayButtonType.Default, theme = models_1.PlayButtonThemes.Blue, text, className: buttonClassName, } = playButton || {};
|
|
24
|
+
const { type: customControlsType = models_1.CustomControlsType.WithMuteButton } = customControlsOptions;
|
|
26
25
|
const autoPlay = Boolean(!isMobile && !previewImgUrl && props.autoplay);
|
|
27
26
|
const mute = initiallyMuted || autoPlay;
|
|
28
27
|
const { playingVideoRef, setProps } = (0, react_1.useContext)(videoContext_1.VideoContext);
|
|
@@ -34,16 +33,8 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
34
33
|
const [width, setWidth] = (0, react_1.useState)(0);
|
|
35
34
|
const [muted, setMuted] = (0, react_1.useState)(mute);
|
|
36
35
|
const [started, setStarted] = (0, react_1.useState)(autoPlay);
|
|
37
|
-
const [paused, setPaused] = (0, react_1.useState)(false);
|
|
38
36
|
const [ended, setEnded] = (0, react_1.useState)(false);
|
|
39
|
-
const
|
|
40
|
-
const eventsArray = (0, react_1.useMemo)(() => {
|
|
41
|
-
if (analyticsEvents) {
|
|
42
|
-
return Array.isArray(analyticsEvents) ? analyticsEvents : [analyticsEvents];
|
|
43
|
-
}
|
|
44
|
-
return [];
|
|
45
|
-
}, [analyticsEvents]);
|
|
46
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.ReactPlayerControls);
|
|
37
|
+
const [hovered, setHovered] = (0, react_1.useState)(false);
|
|
47
38
|
(0, react_1.useImperativeHandle)(originRef, () => ({
|
|
48
39
|
pause: () => setIsPlaying(false),
|
|
49
40
|
}));
|
|
@@ -51,14 +42,14 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
51
42
|
if (ref.current && !(playingVideoRef === null || playingVideoRef === void 0 ? void 0 : playingVideoRef.contains(ref.current))) {
|
|
52
43
|
setMuted(true);
|
|
53
44
|
}
|
|
54
|
-
}, [playingVideoRef]);
|
|
45
|
+
}, [playingVideoRef, ref]);
|
|
55
46
|
(0, react_1.useEffect)(() => {
|
|
56
47
|
if (showPreview) {
|
|
57
48
|
playerRef === null || playerRef === void 0 ? void 0 : playerRef.showPreview();
|
|
58
49
|
}
|
|
59
50
|
}, [showPreview, playerRef]);
|
|
60
51
|
(0, react_1.useEffect)(() => {
|
|
61
|
-
if (playerRef) {
|
|
52
|
+
if (playerRef && autoPlay) {
|
|
62
53
|
setIsPlaying(autoPlay);
|
|
63
54
|
}
|
|
64
55
|
}, [autoPlay, playerRef]);
|
|
@@ -92,8 +83,6 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
92
83
|
window.removeEventListener('resize', updateSize);
|
|
93
84
|
};
|
|
94
85
|
}, []);
|
|
95
|
-
const playEvents = (0, react_1.useMemo)(() => eventsArray === null || eventsArray === void 0 ? void 0 : eventsArray.filter((e) => e.type === models_1.PredefinedEventTypes.Play), [eventsArray]);
|
|
96
|
-
const stopEvents = (0, react_1.useMemo)(() => eventsArray === null || eventsArray === void 0 ? void 0 : eventsArray.filter((e) => e.type === models_1.PredefinedEventTypes.Stop), [eventsArray]);
|
|
97
86
|
const playIcon = (0, react_1.useMemo)(() => {
|
|
98
87
|
let playButtonContent;
|
|
99
88
|
switch (type) {
|
|
@@ -108,10 +97,6 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
108
97
|
return (react_1.default.createElement("button", { className: b('button', { theme, text: Boolean(text) }, buttonClassName) }, playButtonContent));
|
|
109
98
|
}, [type, theme, text, buttonClassName]);
|
|
110
99
|
const changeMute = (0, react_1.useCallback)((isMuted) => {
|
|
111
|
-
if (isMuted && playerRef) {
|
|
112
|
-
playerRef.seekTo(0);
|
|
113
|
-
setPlayedPercent(0);
|
|
114
|
-
}
|
|
115
100
|
if (metrika && videoMetrika) {
|
|
116
101
|
const { play, stop, counterName } = videoMetrika;
|
|
117
102
|
const goal = isMuted ? play : stop;
|
|
@@ -119,15 +104,12 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
119
104
|
metrika.reachGoals(goal, counterName);
|
|
120
105
|
}
|
|
121
106
|
}
|
|
122
|
-
const events = isMuted ? playEvents : stopEvents;
|
|
123
|
-
handleAnalytics(events);
|
|
124
107
|
if (isMuted) {
|
|
125
108
|
setProps({ playingVideoRef: ref.current });
|
|
126
109
|
}
|
|
127
110
|
// In order to the progress bar to update (equals 0) before displaying
|
|
128
111
|
setTimeout(() => setMuted(!isMuted), 0);
|
|
129
|
-
}, [
|
|
130
|
-
const handleClick = (0, react_1.useCallback)(() => changeMute(muted), [changeMute, muted]);
|
|
112
|
+
}, [metrika, videoMetrika, setProps]);
|
|
131
113
|
const handleClickPreview = (0, react_1.useCallback)(() => {
|
|
132
114
|
setIsPlaying(true);
|
|
133
115
|
onClickPreview === null || onClickPreview === void 0 ? void 0 : onClickPreview();
|
|
@@ -137,16 +119,10 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
137
119
|
metrika.reachGoals(play, counterName);
|
|
138
120
|
}
|
|
139
121
|
}
|
|
140
|
-
|
|
141
|
-
}, [onClickPreview, metrika, videoMetrika, handleAnalytics, playEvents]);
|
|
122
|
+
}, [onClickPreview, setIsPlaying, videoMetrika, metrika]);
|
|
142
123
|
const onPause = (0, react_1.useCallback)(() => {
|
|
143
|
-
// For support correct state for youtube
|
|
144
124
|
setIsPlaying(false);
|
|
145
|
-
|
|
146
|
-
setPaused(true);
|
|
147
|
-
setIsPlaying(true);
|
|
148
|
-
}
|
|
149
|
-
}, [controls, setIsPlaying, setPaused]);
|
|
125
|
+
}, []);
|
|
150
126
|
const onStart = (0, react_1.useCallback)(() => {
|
|
151
127
|
if (!autoPlay && !initiallyMuted) {
|
|
152
128
|
setMuted(false);
|
|
@@ -155,21 +131,17 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
155
131
|
const onPlay = (0, react_1.useCallback)(() => {
|
|
156
132
|
setIsPlaying(true);
|
|
157
133
|
if (controls === models_1.MediaVideoControlsType.Custom) {
|
|
158
|
-
|
|
159
|
-
changeMute(false);
|
|
160
|
-
}
|
|
161
|
-
else if (paused) {
|
|
162
|
-
changeMute(muted);
|
|
163
|
-
}
|
|
164
|
-
setEnded(false);
|
|
165
|
-
setPaused(false);
|
|
134
|
+
changeMute(true);
|
|
166
135
|
}
|
|
167
|
-
}, [changeMute, controls
|
|
136
|
+
}, [changeMute, controls]);
|
|
168
137
|
const onProgress = (0, react_1.useCallback)((progress) => {
|
|
169
138
|
setPlayedPercent(progress.played);
|
|
170
139
|
if (progress.played === 1) {
|
|
171
140
|
setMuted(true);
|
|
172
141
|
}
|
|
142
|
+
else {
|
|
143
|
+
setEnded(false);
|
|
144
|
+
}
|
|
173
145
|
}, []);
|
|
174
146
|
const onEnded = (0, react_1.useCallback)(() => {
|
|
175
147
|
// Youtube videos not muted after finishing playing and start again.
|
|
@@ -182,21 +154,37 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
182
154
|
}
|
|
183
155
|
setEnded(true);
|
|
184
156
|
}, [loop, playerRef]);
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
187
|
-
|
|
157
|
+
const onPlayClick = (0, react_1.useCallback)(() => {
|
|
158
|
+
if (isPlaying) {
|
|
159
|
+
onPause();
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
onPlay();
|
|
188
163
|
}
|
|
189
|
-
|
|
190
|
-
|
|
164
|
+
}, [isPlaying, onPause, onPlay]);
|
|
165
|
+
const handleClick = (0, react_1.useCallback)(() => {
|
|
166
|
+
if (customControlsType === models_1.CustomControlsType.WithMuteButton) {
|
|
167
|
+
changeMute(muted);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
onPlayClick();
|
|
171
|
+
}
|
|
172
|
+
if (ended) {
|
|
173
|
+
playerRef === null || playerRef === void 0 ? void 0 : playerRef.seekTo(0);
|
|
174
|
+
onPlay();
|
|
175
|
+
}
|
|
176
|
+
}, [changeMute, customControlsType, ended, muted, onPlay, onPlayClick, playerRef]);
|
|
177
|
+
const onFocusIn = (0, react_1.useCallback)(() => setHovered(true), []);
|
|
178
|
+
const onFocusOut = (0, react_1.useCallback)(() => setHovered(false), []);
|
|
179
|
+
return (react_1.default.createElement("div", { className: b({ wrapper: !currentHeight, controls, started, hovered }, className), ref: ref, onClick: handleClick, onMouseEnter: onFocusIn, onMouseLeave: onFocusOut, onFocus: onFocusIn, onBlur: onFocusOut },
|
|
180
|
+
react_1.default.createElement(react_player_1.default, { className: b('player'), url: src, muted: muted, controls: controls === models_1.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 }),
|
|
181
|
+
controls === models_1.MediaVideoControlsType.Custom && (react_1.default.createElement(CustomBarControls_1.default, { className: b('custom-bar-controls', { muted }, customBarControlsClassName), mute: {
|
|
182
|
+
isMuted: muted,
|
|
191
183
|
changeMute: (event) => {
|
|
192
184
|
event.stopPropagation();
|
|
193
|
-
changeMute(
|
|
185
|
+
changeMute(muted);
|
|
194
186
|
},
|
|
195
|
-
}, elapsedTimePercent:
|
|
196
|
-
}, [controls, isPlaying, customBarControlsClassName, changeMute]);
|
|
197
|
-
return (react_1.default.createElement("div", { className: b({ wrapper: !currentHeight }, className), ref: ref, onClick: handleClick },
|
|
198
|
-
react_1.default.createElement(react_player_1.default, { className: b('player'), url: videoSrc, muted: muted, controls: controls === models_1.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 }),
|
|
199
|
-
renderCustomBarControls(muted, playedPercent)));
|
|
187
|
+
}, elapsedTimePercent: playedPercent, type: customControlsType, isPaused: !isPlaying, onPlayClick: onPlayClick, isStarted: started }))));
|
|
200
188
|
});
|
|
201
189
|
function getHeight(width) {
|
|
202
190
|
return (width / 16) * 9;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const registerKeyset_1 = require("../../../utils/registerKeyset");
|
|
5
|
+
const en_json_1 = tslib_1.__importDefault(require("./en.json"));
|
|
6
|
+
const ru_json_1 = tslib_1.__importDefault(require("./ru.json"));
|
|
7
|
+
const COMPONENT = 'ReactPlayer';
|
|
8
|
+
exports.default = (0, registerKeyset_1.registerKeyset)({ en: en_json_1.default, ru: ru_json_1.default }, COMPONENT);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VideoControlPause = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const svg_1 = require("../utils/svg");
|
|
7
|
+
const VideoControlPause = (props) => {
|
|
8
|
+
return (react_1.default.createElement("svg", Object.assign({ width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, svg_1.a11yHiddenSvgProps, props),
|
|
9
|
+
react_1.default.createElement("g", { opacity: "0.9" },
|
|
10
|
+
react_1.default.createElement("mask", { id: "path-1-outside-1_1237_523", maskUnits: "userSpaceOnUse", x: "1", y: "0", width: "22", height: "24", fill: "black" },
|
|
11
|
+
react_1.default.createElement("rect", { fill: "white", x: "1", width: "22", height: "24" }),
|
|
12
|
+
react_1.default.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" })),
|
|
13
|
+
react_1.default.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" }),
|
|
14
|
+
react_1.default.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)" }))));
|
|
15
|
+
};
|
|
16
|
+
exports.VideoControlPause = VideoControlPause;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VideoControlPlay = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const svg_1 = require("../utils/svg");
|
|
7
|
+
const VideoControlPlay = (props) => {
|
|
8
|
+
return (react_1.default.createElement("svg", Object.assign({ width: "24", height: "26", viewBox: "0 0 24 26", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, svg_1.a11yHiddenSvgProps, props),
|
|
9
|
+
react_1.default.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" }),
|
|
10
|
+
react_1.default.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" })));
|
|
11
|
+
};
|
|
12
|
+
exports.VideoControlPlay = VideoControlPlay;
|
|
@@ -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";
|
|
@@ -14,7 +14,7 @@ const getBlocksCases = (blocks) => {
|
|
|
14
14
|
exports.getBlocksCases = getBlocksCases;
|
|
15
15
|
function generateDefaultSchema(config) {
|
|
16
16
|
const { cards = {}, blocks = {}, extensions = {} } = config !== null && config !== void 0 ? config : {};
|
|
17
|
-
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({}, sub_blocks_1.Divider), blocks_1.ExtendedFeaturesBlock), blocks_1.PromoFeaturesBlock), blocks_1.SliderBlock), blocks_1.QuestionsBlock), blocks_1.HeaderBlock), blocks_1.BannerBlock), blocks_1.CompaniesBlock), blocks_1.MediaBlock), blocks_1.MapBlock), blocks_1.InfoBlock), blocks_1.SecurityBlock), blocks_1.TableBlock), blocks_1.TabsBlock), blocks_1.SimpleBlock), blocks_1.LinkTableBlock), blocks_1.PreviewBlock), blocks_1.HeaderSliderBlock), blocks_1.IconsBlock), blocks_1.CardLayoutBlock), blocks_1.ContentLayoutBlock), blocks_1.ShareBlock);
|
|
17
|
+
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({}, sub_blocks_1.Divider), blocks_1.ExtendedFeaturesBlock), blocks_1.PromoFeaturesBlock), blocks_1.SliderBlock), blocks_1.QuestionsBlock), blocks_1.HeaderBlock), blocks_1.BannerBlock), blocks_1.CompaniesBlock), blocks_1.MediaBlock), blocks_1.MapBlock), blocks_1.InfoBlock), blocks_1.SecurityBlock), blocks_1.TableBlock), blocks_1.TabsBlock), blocks_1.SimpleBlock), blocks_1.LinkTableBlock), blocks_1.PreviewBlock), blocks_1.HeaderSliderBlock), blocks_1.IconsBlock), blocks_1.CardLayoutBlock), blocks_1.ContentLayoutBlock), blocks_1.ShareBlock), blocks_1.FilterBlock);
|
|
18
18
|
const cardValidators = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, sub_blocks_1.PartnerBlock), sub_blocks_1.MediaCardBlock), blocks_1.BannerCard), sub_blocks_1.PriceDetailedBlock), sub_blocks_1.TutorialCard), sub_blocks_1.BackgroundCard), sub_blocks_1.NewsCard), sub_blocks_1.CardWithImage), sub_blocks_1.Quote), sub_blocks_1.BasicCard);
|
|
19
19
|
const constructorBlockSchemaNames = [
|
|
20
20
|
'divider',
|
|
@@ -44,6 +44,7 @@ function generateDefaultSchema(config) {
|
|
|
44
44
|
'card-layout-block',
|
|
45
45
|
'content-layout-block',
|
|
46
46
|
'share-block',
|
|
47
|
+
'filter-block',
|
|
47
48
|
];
|
|
48
49
|
const constructorCardSchemaNames = [
|
|
49
50
|
'partner',
|
|
@@ -22,3 +22,4 @@ tslib_1.__exportStar(require("../../blocks/Icons/schema"), exports);
|
|
|
22
22
|
tslib_1.__exportStar(require("../../blocks/CardLayout/schema"), exports);
|
|
23
23
|
tslib_1.__exportStar(require("../../blocks/ContentLayout/schema"), exports);
|
|
24
24
|
tslib_1.__exportStar(require("../../blocks/Share/schema"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("../../blocks/FilterBlock/schema"), exports);
|
|
@@ -11,6 +11,6 @@ interface InnerVideoProps {
|
|
|
11
11
|
setHasVideoFallback: React.Dispatch<boolean>;
|
|
12
12
|
hasVideoFallback: boolean;
|
|
13
13
|
}
|
|
14
|
-
type VideoAllProps = VideoAdditionProps & MediaComponentVideoProps & InnerVideoProps;
|
|
14
|
+
export type VideoAllProps = VideoAdditionProps & MediaComponentVideoProps & InnerVideoProps;
|
|
15
15
|
declare const Video: (props: VideoAllProps) => JSX.Element | null;
|
|
16
16
|
export default Video;
|