@gravity-ui/page-constructor 4.27.3-alpha.0 → 4.28.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.
@@ -20,9 +20,6 @@ unpredictable css rules order in build */
20
20
  position: relative;
21
21
  height: 100%;
22
22
  }
23
- .pc-header-block__content_theme_dark {
24
- --g-color-line-focus: var(--pc-color-line-focus-dark);
25
- }
26
23
  .pc-header-block__content_theme_dark .pc-header-block__title,
27
24
  .pc-header-block__content_theme_dark .pc-header-block__overtitle {
28
25
  color: var(--g-color-text-light-primary);
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { MediaAllProps } from '../Media/Media';
3
- export type ChildMediaRenderProps = Pick<MediaAllProps, 'fullscreen' | 'imageClassName' | 'videoClassName' | 'youtubeClassName' | 'className'>;
3
+ export type ChildMediaRenderProps = Pick<MediaAllProps, 'fullscreen' | 'imageClassName' | 'videoClassName' | 'youtubeClassName' | 'className' | 'previewImg' | 'autoplay'>;
4
4
  export interface FullscreenMediaProps {
5
5
  showFullscreenIcon?: boolean;
6
6
  children: (props?: ChildMediaRenderProps) => JSX.Element;
@@ -35,6 +35,8 @@ const FullscreenMedia = ({ children, showFullscreenIcon = true }) => {
35
35
  videoClassName: getMediaClass('video'),
36
36
  youtubeClassName: getMediaClass('youtube'),
37
37
  fullscreen: true,
38
+ previewImg: undefined,
39
+ autoplay: true,
38
40
  }))))));
39
41
  };
40
42
  exports.default = FullscreenMedia;
@@ -4,6 +4,7 @@ import { VideoAdditionProps } from './Video/Video';
4
4
  export interface MediaAllProps extends MediaProps, VideoAdditionProps, ImageAdditionProps, QAProps {
5
5
  className?: string;
6
6
  youtubeClassName?: string;
7
+ autoplay?: boolean;
7
8
  }
8
9
  export declare const Media: (props: MediaAllProps) => JSX.Element;
9
10
  export default Media;
@@ -11,7 +11,7 @@ const Image_1 = tslib_1.__importDefault(require("./Image/Image"));
11
11
  const Video_1 = tslib_1.__importDefault(require("./Video/Video"));
12
12
  const b = (0, utils_1.block)('Media');
13
13
  const Media = (props) => {
14
- const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, metrika, fullscreen, analyticsEvents, className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, qa, ratio, } = props;
14
+ const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, metrika, fullscreen, analyticsEvents, className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, qa, ratio, autoplay, } = props;
15
15
  const [hasVideoFallback, setHasVideoFallback] = (0, react_1.useState)(false);
16
16
  const qaAttributes = (0, utils_1.getQaAttrubutes)(qa, 'video');
17
17
  const content = (0, react_1.useMemo)(() => {
@@ -43,7 +43,7 @@ const Media = (props) => {
43
43
  }
44
44
  }
45
45
  if (youtube) {
46
- result = (react_1.default.createElement(VideoBlock_1.default, { className: b('youtube', youtubeClassName), record: youtube, attributes: { color: 'white', rel: '0' }, previewImg: previewImg, height: height, fullscreen: fullscreen, analyticsEvents: analyticsEvents }));
46
+ result = (react_1.default.createElement(VideoBlock_1.default, { className: b('youtube', youtubeClassName), record: youtube, attributes: { color: 'white', rel: '0' }, previewImg: previewImg, height: height, fullscreen: fullscreen, analyticsEvents: analyticsEvents, autoplay: autoplay }));
47
47
  }
48
48
  if (dataLens) {
49
49
  result = react_1.default.createElement(DataLens_1.default, { dataLens: dataLens });
@@ -71,6 +71,7 @@ const Media = (props) => {
71
71
  customBarControlsClassName,
72
72
  ratio,
73
73
  youtubeClassName,
74
+ autoplay,
74
75
  ]);
75
76
  return (react_1.default.createElement("div", { className: b(null, className), style: { backgroundColor: color }, "data-qa": qa }, content));
76
77
  };
@@ -32,7 +32,7 @@ const Video = (props) => {
32
32
  }, [playVideo, video, setHasVideoFallback]);
33
33
  const reactPlayerBlock = (0, react_1.useMemo)(() => {
34
34
  const { src, loop, controls, muted, autoplay = true, elapsedTime, playButton, ariaLabel, customControlsOptions, } = video;
35
- return (react_1.default.createElement(ReactPlayer_1.default, { ref: ref, 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, ratio: ratio }));
35
+ 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, ratio: ratio }));
36
36
  }, [
37
37
  video,
38
38
  height,
@@ -11,6 +11,5 @@ export interface ReactPlayerBlockProps extends Omit<MediaVideoProps, 'loop' | 's
11
11
  ratio?: number;
12
12
  children?: React.ReactNode;
13
13
  }
14
- type ReactPlayerBlockRefType = ReactPlayerBlockHandler | undefined;
15
- export declare const ReactPlayerBlock: React.ForwardRefExoticComponent<ReactPlayerBlockProps & React.RefAttributes<ReactPlayerBlockRefType>>;
14
+ export declare const ReactPlayerBlock: React.ForwardRefExoticComponent<ReactPlayerBlockProps & React.RefAttributes<ReactPlayerBlockHandler>>;
16
15
  export default ReactPlayerBlock;
@@ -48,19 +48,9 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
48
48
  return [];
49
49
  }, [analyticsEvents]);
50
50
  const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.ReactPlayerControls);
51
- (0, react_1.useImperativeHandle)(originRef, () => {
52
- if (!playerRef) {
53
- return;
54
- }
55
- const videoInstance = playerRef.getInternalPlayer();
56
- const { play, pause, addEventListener } = videoInstance;
57
- // eslint-disable-next-line consistent-return
58
- return {
59
- play: play.bind(videoInstance),
60
- pause: pause.bind(videoInstance),
61
- addEventListener: addEventListener.bind(videoInstance),
62
- };
63
- }, [playerRef]);
51
+ (0, react_1.useImperativeHandle)(originRef, () => ({
52
+ pause: () => setIsPlaying(false),
53
+ }));
64
54
  (0, react_1.useEffect)(() => {
65
55
  if (ref.current && !(playingVideoRef === null || playingVideoRef === void 0 ? void 0 : playingVideoRef.contains(ref.current))) {
66
56
  setMuted(true);
@@ -15,6 +15,7 @@ export interface VideoBlockProps extends AnalyticsEventsBase {
15
15
  playButton?: React.ReactNode;
16
16
  height?: number;
17
17
  fullscreen?: boolean;
18
+ autoplay?: boolean;
18
19
  }
19
20
  declare const VideoBlock: (props: VideoBlockProps) => JSX.Element | null;
20
21
  export default VideoBlock;
@@ -41,7 +41,7 @@ function getHeight(width) {
41
41
  }
42
42
  exports.getHeight = getHeight;
43
43
  const VideoBlock = (props) => {
44
- const { stream, record, attributes, className, id, previewImg, playButton, height, fullscreen, analyticsEvents, } = props;
44
+ const { stream, record, attributes, className, id, previewImg, playButton, height, fullscreen, analyticsEvents, autoplay, } = props;
45
45
  const handleAnalytics = (0, useAnalytics_1.useAnalytics)(common_1.DefaultEventNames.VideoPreview);
46
46
  const src = getVideoSrc(stream, record);
47
47
  const ref = (0, react_1.useRef)(null);
@@ -75,7 +75,7 @@ const VideoBlock = (props) => {
75
75
  const iframe = document.createElement('iframe');
76
76
  iframe.id = fullId;
77
77
  if (!previewImg) {
78
- iframe.src = `${src}?${(0, utils_1.getPageSearchParams)(attributes || {})}`;
78
+ iframe.src = `${src}?${(0, utils_1.getPageSearchParams)(Object.assign(Object.assign({}, (attributes || {})), (autoplay ? exports.AUTOPLAY_ATTRIBUTES : {})))}`;
79
79
  }
80
80
  iframe.width = '100%';
81
81
  iframe.height = '100%';
@@ -87,7 +87,7 @@ const VideoBlock = (props) => {
87
87
  ref.current.appendChild(iframe);
88
88
  iframeRef.current = iframe;
89
89
  }
90
- }, [stream, record, norender, src, fullId, attributes, iframeRef, previewImg]);
90
+ }, [stream, record, norender, src, fullId, attributes, iframeRef, previewImg, autoplay]);
91
91
  (0, react_1.useEffect)(() => {
92
92
  setHidePreview(false);
93
93
  }, [src, setHidePreview]);
@@ -1,3 +1,4 @@
1
1
  export type ArrowDirection = 'left' | 'right';
2
- export interface ReactPlayerBlockHandler extends Pick<HTMLVideoElement, 'play' | 'pause' | 'addEventListener'> {
2
+ export interface ReactPlayerBlockHandler {
3
+ pause: () => void;
3
4
  }
@@ -20,9 +20,6 @@ unpredictable css rules order in build */
20
20
  position: relative;
21
21
  height: 100%;
22
22
  }
23
- .pc-header-block__content_theme_dark {
24
- --g-color-line-focus: var(--pc-color-line-focus-dark);
25
- }
26
23
  .pc-header-block__content_theme_dark .pc-header-block__title,
27
24
  .pc-header-block__content_theme_dark .pc-header-block__overtitle {
28
25
  color: var(--g-color-text-light-primary);
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { MediaAllProps } from '../Media/Media';
3
3
  import './FullscreenMedia.css';
4
- export type ChildMediaRenderProps = Pick<MediaAllProps, 'fullscreen' | 'imageClassName' | 'videoClassName' | 'youtubeClassName' | 'className'>;
4
+ export type ChildMediaRenderProps = Pick<MediaAllProps, 'fullscreen' | 'imageClassName' | 'videoClassName' | 'youtubeClassName' | 'className' | 'previewImg' | 'autoplay'>;
5
5
  export interface FullscreenMediaProps {
6
6
  showFullscreenIcon?: boolean;
7
7
  children: (props?: ChildMediaRenderProps) => JSX.Element;
@@ -33,6 +33,8 @@ const FullscreenMedia = ({ children, showFullscreenIcon = true }) => {
33
33
  videoClassName: getMediaClass('video'),
34
34
  youtubeClassName: getMediaClass('youtube'),
35
35
  fullscreen: true,
36
+ previewImg: undefined,
37
+ autoplay: true,
36
38
  }))))));
37
39
  };
38
40
  export default FullscreenMedia;
@@ -5,6 +5,7 @@ import './Media.css';
5
5
  export interface MediaAllProps extends MediaProps, VideoAdditionProps, ImageAdditionProps, QAProps {
6
6
  className?: string;
7
7
  youtubeClassName?: string;
8
+ autoplay?: boolean;
8
9
  }
9
10
  export declare const Media: (props: MediaAllProps) => JSX.Element;
10
11
  export default Media;
@@ -8,7 +8,7 @@ import Video from './Video/Video';
8
8
  import './Media.css';
9
9
  const b = block('Media');
10
10
  export const Media = (props) => {
11
- const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, metrika, fullscreen, analyticsEvents, className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, qa, ratio, } = props;
11
+ const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, metrika, fullscreen, analyticsEvents, className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, qa, ratio, autoplay, } = props;
12
12
  const [hasVideoFallback, setHasVideoFallback] = useState(false);
13
13
  const qaAttributes = getQaAttrubutes(qa, 'video');
14
14
  const content = useMemo(() => {
@@ -40,7 +40,7 @@ export const Media = (props) => {
40
40
  }
41
41
  }
42
42
  if (youtube) {
43
- result = (React.createElement(YoutubeBlock, { className: b('youtube', youtubeClassName), record: youtube, attributes: { color: 'white', rel: '0' }, previewImg: previewImg, height: height, fullscreen: fullscreen, analyticsEvents: analyticsEvents }));
43
+ result = (React.createElement(YoutubeBlock, { className: b('youtube', youtubeClassName), record: youtube, attributes: { color: 'white', rel: '0' }, previewImg: previewImg, height: height, fullscreen: fullscreen, analyticsEvents: analyticsEvents, autoplay: autoplay }));
44
44
  }
45
45
  if (dataLens) {
46
46
  result = React.createElement(DataLens, { dataLens: dataLens });
@@ -68,6 +68,7 @@ export const Media = (props) => {
68
68
  customBarControlsClassName,
69
69
  ratio,
70
70
  youtubeClassName,
71
+ autoplay,
71
72
  ]);
72
73
  return (React.createElement("div", { className: b(null, className), style: { backgroundColor: color }, "data-qa": qa }, content));
73
74
  };
@@ -30,7 +30,7 @@ const Video = (props) => {
30
30
  }, [playVideo, video, setHasVideoFallback]);
31
31
  const reactPlayerBlock = useMemo(() => {
32
32
  const { src, loop, controls, muted, autoplay = true, elapsedTime, playButton, ariaLabel, customControlsOptions, } = video;
33
- return (React.createElement(ReactPlayerBlock, { ref: ref, 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, ratio: ratio }));
33
+ 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, ratio: ratio }));
34
34
  }, [
35
35
  video,
36
36
  height,
@@ -12,6 +12,5 @@ export interface ReactPlayerBlockProps extends Omit<MediaVideoProps, 'loop' | 's
12
12
  ratio?: number;
13
13
  children?: React.ReactNode;
14
14
  }
15
- type ReactPlayerBlockRefType = ReactPlayerBlockHandler | undefined;
16
- export declare const ReactPlayerBlock: React.ForwardRefExoticComponent<ReactPlayerBlockProps & React.RefAttributes<ReactPlayerBlockRefType>>;
15
+ export declare const ReactPlayerBlock: React.ForwardRefExoticComponent<ReactPlayerBlockProps & React.RefAttributes<ReactPlayerBlockHandler>>;
17
16
  export default ReactPlayerBlock;
@@ -45,19 +45,9 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
45
45
  return [];
46
46
  }, [analyticsEvents]);
47
47
  const handleAnalytics = useAnalytics(DefaultEventNames.ReactPlayerControls);
48
- useImperativeHandle(originRef, () => {
49
- if (!playerRef) {
50
- return;
51
- }
52
- const videoInstance = playerRef.getInternalPlayer();
53
- const { play, pause, addEventListener } = videoInstance;
54
- // eslint-disable-next-line consistent-return
55
- return {
56
- play: play.bind(videoInstance),
57
- pause: pause.bind(videoInstance),
58
- addEventListener: addEventListener.bind(videoInstance),
59
- };
60
- }, [playerRef]);
48
+ useImperativeHandle(originRef, () => ({
49
+ pause: () => setIsPlaying(false),
50
+ }));
61
51
  useEffect(() => {
62
52
  if (ref.current && !(playingVideoRef === null || playingVideoRef === void 0 ? void 0 : playingVideoRef.contains(ref.current))) {
63
53
  setMuted(true);
@@ -16,6 +16,7 @@ export interface VideoBlockProps extends AnalyticsEventsBase {
16
16
  playButton?: React.ReactNode;
17
17
  height?: number;
18
18
  fullscreen?: boolean;
19
+ autoplay?: boolean;
19
20
  }
20
21
  declare const VideoBlock: (props: VideoBlockProps) => JSX.Element | null;
21
22
  export default VideoBlock;
@@ -37,7 +37,7 @@ export function getHeight(width) {
37
37
  return (width / 16) * 9;
38
38
  }
39
39
  const VideoBlock = (props) => {
40
- const { stream, record, attributes, className, id, previewImg, playButton, height, fullscreen, analyticsEvents, } = props;
40
+ const { stream, record, attributes, className, id, previewImg, playButton, height, fullscreen, analyticsEvents, autoplay, } = props;
41
41
  const handleAnalytics = useAnalytics(DefaultEventNames.VideoPreview);
42
42
  const src = getVideoSrc(stream, record);
43
43
  const ref = useRef(null);
@@ -71,7 +71,7 @@ const VideoBlock = (props) => {
71
71
  const iframe = document.createElement('iframe');
72
72
  iframe.id = fullId;
73
73
  if (!previewImg) {
74
- iframe.src = `${src}?${getPageSearchParams(attributes || {})}`;
74
+ iframe.src = `${src}?${getPageSearchParams(Object.assign(Object.assign({}, (attributes || {})), (autoplay ? AUTOPLAY_ATTRIBUTES : {})))}`;
75
75
  }
76
76
  iframe.width = '100%';
77
77
  iframe.height = '100%';
@@ -83,7 +83,7 @@ const VideoBlock = (props) => {
83
83
  ref.current.appendChild(iframe);
84
84
  iframeRef.current = iframe;
85
85
  }
86
- }, [stream, record, norender, src, fullId, attributes, iframeRef, previewImg]);
86
+ }, [stream, record, norender, src, fullId, attributes, iframeRef, previewImg, autoplay]);
87
87
  useEffect(() => {
88
88
  setHidePreview(false);
89
89
  }, [src, setHidePreview]);
@@ -1,3 +1,4 @@
1
1
  export type ArrowDirection = 'left' | 'right';
2
- export interface ReactPlayerBlockHandler extends Pick<HTMLVideoElement, 'play' | 'pause' | 'addEventListener'> {
2
+ export interface ReactPlayerBlockHandler {
3
+ pause: () => void;
3
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "4.27.3-alpha.0",
3
+ "version": "4.28.0",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,3 +1,4 @@
1
1
  export type ArrowDirection = 'left' | 'right';
2
- export interface ReactPlayerBlockHandler extends Pick<HTMLVideoElement, 'play' | 'pause' | 'addEventListener'> {
2
+ export interface ReactPlayerBlockHandler {
3
+ pause: () => void;
3
4
  }