@gravity-ui/page-constructor 1.15.0-alpha.0 → 1.15.0-alpha.10
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/README.md +110 -5
- package/build/cjs/blocks/Banner/Banner.js +3 -2
- package/build/cjs/blocks/Banner/schema.d.ts +33 -24
- package/build/cjs/blocks/Banner/schema.js +3 -1
- package/build/cjs/blocks/CardLayout/schema.d.ts +6 -0
- package/build/cjs/blocks/ContentLayout/ContentLayout.js +3 -2
- package/build/cjs/blocks/ContentLayout/schema.d.ts +3 -0
- package/build/cjs/blocks/ExtendedFeatures/ExtendedFeatures.d.ts +1 -1
- package/build/cjs/blocks/ExtendedFeatures/ExtendedFeatures.js +3 -2
- package/build/cjs/blocks/ExtendedFeatures/schema.d.ts +3 -0
- package/build/cjs/blocks/Header/Header.js +6 -5
- package/build/cjs/blocks/Header/schema.d.ts +3 -0
- package/build/cjs/blocks/HeaderSlider/schema.d.ts +3 -0
- package/build/cjs/blocks/Icons/schema.d.ts +6 -0
- package/build/cjs/blocks/Info/Info.js +4 -3
- package/build/cjs/blocks/Info/schema.d.ts +3 -0
- package/build/cjs/blocks/Info/schema.js +2 -0
- package/build/cjs/blocks/LinkTable/schema.d.ts +3 -0
- package/build/cjs/blocks/Media/Media.js +3 -2
- package/build/cjs/blocks/Media/MediaContent.js +3 -2
- package/build/cjs/blocks/Media/schema.d.ts +11 -8
- package/build/cjs/blocks/Preview/MediaContent/MediaContent.d.ts +2 -1
- package/build/cjs/blocks/Preview/MediaContent/MediaContent.js +3 -2
- package/build/cjs/blocks/Preview/MediaContent/PreviewMedia.d.ts +1 -0
- package/build/cjs/blocks/Preview/MediaContent/PreviewMedia.js +3 -2
- package/build/cjs/blocks/Preview/Preview.js +3 -2
- package/build/cjs/blocks/Preview/schema.d.ts +3 -0
- package/build/cjs/blocks/Preview/schema.js +3 -1
- package/build/cjs/blocks/PromoFeaturesBlock/PromoFeaturesBlock.js +3 -2
- package/build/cjs/blocks/PromoFeaturesBlock/schema.d.ts +3 -0
- package/build/cjs/blocks/Questions/Questions.js +3 -2
- package/build/cjs/blocks/Questions/schema.d.ts +3 -0
- package/build/cjs/blocks/Security/Security.js +3 -2
- package/build/cjs/blocks/Security/schema.d.ts +3 -0
- package/build/cjs/blocks/Security/schema.js +3 -1
- package/build/cjs/blocks/Share/Share.d.ts +1 -1
- package/build/cjs/blocks/Share/Share.js +10 -2
- package/build/cjs/blocks/Simple/schema.d.ts +3 -0
- package/build/cjs/blocks/Slider/schema.d.ts +3 -0
- package/build/cjs/blocks/Table/schema.d.ts +3 -0
- package/build/cjs/blocks/Tabs/Tabs.d.ts +1 -1
- package/build/cjs/blocks/Tabs/Tabs.js +5 -4
- package/build/cjs/blocks/Tabs/schema.d.ts +3 -0
- package/build/cjs/components/BackLink/BackLink.d.ts +1 -0
- package/build/cjs/components/BackLink/BackLink.js +11 -2
- package/build/cjs/components/BackgroundMedia/BackgroundMedia.js +2 -1
- package/build/cjs/components/Button/Button.d.ts +1 -0
- package/build/cjs/components/Button/Button.js +8 -2
- package/build/cjs/components/ButtonTabs/ButtonTabs.d.ts +1 -0
- package/build/cjs/components/ButtonTabs/ButtonTabs.js +11 -2
- package/build/cjs/components/CardBase/CardBase.d.ts +3 -2
- package/build/cjs/components/CardBase/CardBase.js +8 -2
- package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +8 -2
- package/build/cjs/components/Link/Link.js +9 -3
- package/build/cjs/components/Media/Media.js +4 -2
- package/build/cjs/components/Media/Video/Video.js +5 -3
- package/build/cjs/components/ReactPlayer/ReactPlayer.js +14 -26
- package/build/cjs/components/YandexForm/YandexForm.d.ts +3 -2
- package/build/cjs/components/YandexForm/YandexForm.js +9 -3
- package/build/cjs/constructor-items.d.ts +5 -5
- package/build/cjs/context/analyticsContext/analyticsContext.d.ts +3 -2
- package/build/cjs/hooks/useAnalytics.d.ts +2 -2
- package/build/cjs/hooks/useAnalytics.js +9 -4
- package/build/cjs/models/common.d.ts +7 -9
- package/build/cjs/models/common.js +7 -1
- package/build/cjs/models/constructor-items/blocks.d.ts +11 -0
- package/build/cjs/models/constructor-items/common.d.ts +11 -6
- package/build/cjs/models/constructor-items/sub-blocks.d.ts +6 -3
- package/build/cjs/navigation/components/NavigationItem/NavigationItem.js +3 -2
- package/build/cjs/schema/validators/common.d.ts +19 -16
- package/build/cjs/schema/validators/common.js +3 -1
- package/build/cjs/schema/validators/event.d.ts +4 -58
- package/build/cjs/schema/validators/event.js +3 -55
- package/build/cjs/sub-blocks/BackgroundCard/BackgroundCard.js +3 -2
- package/build/cjs/sub-blocks/BackgroundCard/schema.d.ts +3 -0
- package/build/cjs/sub-blocks/BackgroundCard/schema.js +2 -0
- package/build/cjs/sub-blocks/BannerCard/BannerCard.js +3 -2
- package/build/cjs/sub-blocks/BasicCard/BasicCard.js +3 -2
- package/build/cjs/sub-blocks/CardWithImage/CardWithImage.d.ts +1 -1
- package/build/cjs/sub-blocks/CardWithImage/CardWithImage.js +3 -2
- package/build/cjs/sub-blocks/Content/Content.js +4 -3
- package/build/cjs/sub-blocks/HubspotForm/index.js +7 -2
- package/build/cjs/sub-blocks/MediaCard/MediaCard.d.ts +1 -1
- package/build/cjs/sub-blocks/MediaCard/MediaCard.js +3 -2
- package/build/cjs/sub-blocks/Quote/Quote.js +9 -2
- package/build/cjs/sub-blocks/Quote/schema.d.ts +3 -0
- package/build/cjs/sub-blocks/Quote/schema.js +3 -1
- package/build/esm/blocks/Banner/Banner.js +3 -2
- package/build/esm/blocks/Banner/schema.d.ts +33 -24
- package/build/esm/blocks/Banner/schema.js +3 -1
- package/build/esm/blocks/CardLayout/schema.d.ts +6 -0
- package/build/esm/blocks/ContentLayout/ContentLayout.js +3 -2
- package/build/esm/blocks/ContentLayout/schema.d.ts +3 -0
- package/build/esm/blocks/ExtendedFeatures/ExtendedFeatures.d.ts +1 -1
- package/build/esm/blocks/ExtendedFeatures/ExtendedFeatures.js +3 -2
- package/build/esm/blocks/ExtendedFeatures/schema.d.ts +3 -0
- package/build/esm/blocks/Header/Header.js +6 -5
- package/build/esm/blocks/Header/schema.d.ts +3 -0
- package/build/esm/blocks/HeaderSlider/schema.d.ts +3 -0
- package/build/esm/blocks/Icons/schema.d.ts +6 -0
- package/build/esm/blocks/Info/Info.js +4 -3
- package/build/esm/blocks/Info/schema.d.ts +3 -0
- package/build/esm/blocks/Info/schema.js +2 -0
- package/build/esm/blocks/LinkTable/schema.d.ts +3 -0
- package/build/esm/blocks/Media/Media.js +3 -2
- package/build/esm/blocks/Media/MediaContent.js +3 -2
- package/build/esm/blocks/Media/schema.d.ts +11 -8
- package/build/esm/blocks/Preview/MediaContent/MediaContent.d.ts +2 -1
- package/build/esm/blocks/Preview/MediaContent/MediaContent.js +3 -2
- package/build/esm/blocks/Preview/MediaContent/PreviewMedia.d.ts +1 -0
- package/build/esm/blocks/Preview/MediaContent/PreviewMedia.js +3 -2
- package/build/esm/blocks/Preview/Preview.js +3 -2
- package/build/esm/blocks/Preview/schema.d.ts +3 -0
- package/build/esm/blocks/Preview/schema.js +3 -1
- package/build/esm/blocks/PromoFeaturesBlock/PromoFeaturesBlock.js +3 -2
- package/build/esm/blocks/PromoFeaturesBlock/schema.d.ts +3 -0
- package/build/esm/blocks/Questions/Questions.js +3 -2
- package/build/esm/blocks/Questions/schema.d.ts +3 -0
- package/build/esm/blocks/Security/Security.js +3 -2
- package/build/esm/blocks/Security/schema.d.ts +3 -0
- package/build/esm/blocks/Security/schema.js +3 -1
- package/build/esm/blocks/Share/Share.d.ts +1 -1
- package/build/esm/blocks/Share/Share.js +11 -3
- package/build/esm/blocks/Simple/schema.d.ts +3 -0
- package/build/esm/blocks/Slider/schema.d.ts +3 -0
- package/build/esm/blocks/Table/schema.d.ts +3 -0
- package/build/esm/blocks/Tabs/Tabs.d.ts +1 -1
- package/build/esm/blocks/Tabs/Tabs.js +5 -4
- package/build/esm/blocks/Tabs/schema.d.ts +3 -0
- package/build/esm/components/BackLink/BackLink.d.ts +1 -0
- package/build/esm/components/BackLink/BackLink.js +11 -2
- package/build/esm/components/BackgroundMedia/BackgroundMedia.js +2 -1
- package/build/esm/components/Button/Button.d.ts +1 -0
- package/build/esm/components/Button/Button.js +8 -2
- package/build/esm/components/ButtonTabs/ButtonTabs.d.ts +1 -0
- package/build/esm/components/ButtonTabs/ButtonTabs.js +11 -2
- package/build/esm/components/CardBase/CardBase.d.ts +3 -2
- package/build/esm/components/CardBase/CardBase.js +8 -2
- package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +8 -2
- package/build/esm/components/Link/Link.js +9 -3
- package/build/esm/components/Media/Media.js +4 -2
- package/build/esm/components/Media/Video/Video.js +5 -3
- package/build/esm/components/ReactPlayer/ReactPlayer.js +15 -27
- package/build/esm/components/YandexForm/YandexForm.d.ts +3 -2
- package/build/esm/components/YandexForm/YandexForm.js +9 -3
- package/build/esm/constructor-items.d.ts +5 -5
- package/build/esm/context/analyticsContext/analyticsContext.d.ts +3 -2
- package/build/esm/hooks/useAnalytics.d.ts +2 -2
- package/build/esm/hooks/useAnalytics.js +9 -4
- package/build/esm/models/common.d.ts +7 -9
- package/build/esm/models/common.js +6 -0
- package/build/esm/models/constructor-items/blocks.d.ts +11 -0
- package/build/esm/models/constructor-items/common.d.ts +11 -6
- package/build/esm/models/constructor-items/sub-blocks.d.ts +6 -3
- package/build/esm/navigation/components/NavigationItem/NavigationItem.js +3 -2
- package/build/esm/schema/validators/common.d.ts +19 -16
- package/build/esm/schema/validators/common.js +4 -2
- package/build/esm/schema/validators/event.d.ts +4 -58
- package/build/esm/schema/validators/event.js +2 -54
- package/build/esm/sub-blocks/BackgroundCard/BackgroundCard.js +3 -2
- package/build/esm/sub-blocks/BackgroundCard/schema.d.ts +3 -0
- package/build/esm/sub-blocks/BackgroundCard/schema.js +2 -0
- package/build/esm/sub-blocks/BannerCard/BannerCard.js +3 -2
- package/build/esm/sub-blocks/BasicCard/BasicCard.js +3 -2
- package/build/esm/sub-blocks/CardWithImage/CardWithImage.d.ts +1 -1
- package/build/esm/sub-blocks/CardWithImage/CardWithImage.js +3 -2
- package/build/esm/sub-blocks/Content/Content.js +4 -3
- package/build/esm/sub-blocks/HubspotForm/index.js +7 -2
- package/build/esm/sub-blocks/MediaCard/MediaCard.d.ts +1 -1
- package/build/esm/sub-blocks/MediaCard/MediaCard.js +3 -2
- package/build/esm/sub-blocks/Quote/Quote.js +11 -4
- package/build/esm/sub-blocks/Quote/schema.d.ts +3 -0
- package/build/esm/sub-blocks/Quote/schema.js +3 -1
- package/package.json +1 -1
- package/server/models/common.d.ts +7 -9
- package/server/models/common.js +7 -1
- package/server/models/constructor-items/blocks.d.ts +11 -0
- package/server/models/constructor-items/common.d.ts +11 -6
- package/server/models/constructor-items/sub-blocks.d.ts +6 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { block } from '../../utils';
|
|
3
|
+
import { BlockType } from '../../models';
|
|
3
4
|
import Link from '../../components/Link/Link';
|
|
4
5
|
import { YFMWrapper, ToggleArrow, Foldable, HTML } from '../../components';
|
|
5
6
|
import { Row, Col } from '../../grid';
|
|
@@ -7,7 +8,7 @@ import { Content } from '../../sub-blocks';
|
|
|
7
8
|
import './Questions.css';
|
|
8
9
|
const b = block('QuestionsBlock');
|
|
9
10
|
const QuestionsBlock = (props) => {
|
|
10
|
-
const { title, text, additionalInfo, links, buttons, items } = props;
|
|
11
|
+
const { title, text, additionalInfo, links, buttons, items, blockName = BlockType.QuestionsBlock, } = props;
|
|
11
12
|
const [opened, setOpened] = useState([0]);
|
|
12
13
|
const toggleItem = (index) => {
|
|
13
14
|
let newState;
|
|
@@ -23,7 +24,7 @@ const QuestionsBlock = (props) => {
|
|
|
23
24
|
React.createElement(Row, null,
|
|
24
25
|
React.createElement(Col, { sizes: { all: 12, md: 4 } },
|
|
25
26
|
React.createElement("div", { className: b('title') },
|
|
26
|
-
React.createElement(Content, { title: title, text: text, additionalInfo: additionalInfo, links: links, buttons: buttons, colSizes: { all: 12, md: 12 } }))),
|
|
27
|
+
React.createElement(Content, { title: title, text: text, additionalInfo: additionalInfo, links: links, buttons: buttons, colSizes: { all: 12, md: 12 }, blockName: blockName }))),
|
|
27
28
|
React.createElement(Col, { sizes: { all: 12, md: 8 } }, items.map(({ title: itemTitle, text: itemText, link, listStyle = 'dash' }, index) => {
|
|
28
29
|
const isOpened = opened.includes(index);
|
|
29
30
|
return (React.createElement("div", { key: itemTitle, className: b('item') },
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { block } from '../../utils';
|
|
3
|
+
import { BlockType } from '../../models';
|
|
3
4
|
import { FullWidthBackground, HTML, Media, Link, AnimateBlock } from '../../components';
|
|
4
5
|
import { Grid, Row, Col } from '../../grid';
|
|
5
6
|
import './Security.css';
|
|
6
7
|
const b = block('SecurityBlock');
|
|
7
8
|
export const SecurityBlock = (props) => {
|
|
8
|
-
const { backgroundColor, theme = 'dark', title, points, media, animated } = props;
|
|
9
|
+
const { backgroundColor, theme = 'dark', title, points, media, animated, blockName = BlockType.SecurityBlock, } = props;
|
|
9
10
|
return (React.createElement(AnimateBlock, { className: b({ theme }), offset: 200, animate: animated },
|
|
10
11
|
React.createElement("div", { className: b('content') },
|
|
11
12
|
React.createElement(FullWidthBackground, { className: b('background'), style: { backgroundColor } }),
|
|
@@ -19,6 +20,6 @@ export const SecurityBlock = (props) => {
|
|
|
19
20
|
link && (React.createElement(Link, { className: b('point-link'), text: link.text, url: link.url, theme: 'normal', arrow: true }))))))),
|
|
20
21
|
media && (React.createElement(Row, { className: b('media') },
|
|
21
22
|
React.createElement(Col, null,
|
|
22
|
-
React.createElement(Media, Object.assign({ className: b('media') }, media)))))))));
|
|
23
|
+
React.createElement(Media, Object.assign({ className: b('media') }, media, { blockName: blockName })))))))));
|
|
23
24
|
};
|
|
24
25
|
export default SecurityBlock;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
1
|
+
import React, { useContext, useCallback } from 'react';
|
|
2
2
|
import { Icon, Button } from '@gravity-ui/uikit';
|
|
3
3
|
import { block, getAbsolutePath, getShareLink } from '../../utils';
|
|
4
|
+
import { BlockType, PredefinedEventTypes } from '../../models';
|
|
4
5
|
import { LocationContext } from '../../context/locationContext';
|
|
5
6
|
import i18n from './i18n';
|
|
7
|
+
import { useAnalytics } from '../../hooks';
|
|
6
8
|
import { Facebook } from '../../icons/Facebook';
|
|
7
9
|
import { Twitter } from '../../icons/Twitter';
|
|
8
10
|
import { Linkedin } from '../../icons/Linkedin';
|
|
@@ -17,15 +19,21 @@ const icons = {
|
|
|
17
19
|
telegram: Telegram,
|
|
18
20
|
};
|
|
19
21
|
const b = block('share-block');
|
|
20
|
-
const Share = ({ items, title }) => {
|
|
22
|
+
const Share = ({ items, title, blockName = BlockType.ShareBlock }) => {
|
|
21
23
|
const { pathname, hostname } = useContext(LocationContext);
|
|
24
|
+
const handleAnalytics = useAnalytics({
|
|
25
|
+
name: 'share-button-click',
|
|
26
|
+
type: PredefinedEventTypes.Default,
|
|
27
|
+
blockName: blockName,
|
|
28
|
+
});
|
|
29
|
+
const handleButtonClick = useCallback(() => handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(), [handleAnalytics]);
|
|
22
30
|
return (React.createElement("div", { className: b() },
|
|
23
31
|
React.createElement("h5", { className: b('title') }, title || i18n('constructor-share')),
|
|
24
32
|
React.createElement("div", { className: b('items') }, items.map((type) => {
|
|
25
33
|
const url = getAbsolutePath(hostname, pathname);
|
|
26
34
|
const socialUrl = getShareLink(url, type);
|
|
27
35
|
const icon = icons[type];
|
|
28
|
-
return (React.createElement(Button, { key: type, view: "flat", size: "l", target: "_blank", href: socialUrl, className: b('item', { type: type.toLowerCase() }) }, icon && React.createElement(Icon, { data: icon, size: 24, className: b('icon', { type }) })));
|
|
36
|
+
return (React.createElement(Button, { key: type, view: "flat", size: "l", target: "_blank", href: socialUrl, className: b('item', { type: type.toLowerCase() }), onClick: handleButtonClick }, icon && React.createElement(Icon, { data: icon, size: 24, className: b('icon', { type }) })));
|
|
29
37
|
}))));
|
|
30
38
|
};
|
|
31
39
|
export default Share;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { TabsBlockProps } from '../../models';
|
|
2
2
|
import './Tabs.css';
|
|
3
|
-
export declare const TabsBlock: ({ items, title, description, animated, tabsColSizes, centered, direction, }: TabsBlockProps) => JSX.Element;
|
|
3
|
+
export declare const TabsBlock: ({ items, title, description, animated, tabsColSizes, centered, direction, blockName, }: TabsBlockProps) => JSX.Element;
|
|
4
4
|
export default TabsBlock;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { Fragment, useContext, useRef, useState } from 'react';
|
|
2
2
|
import { block, getThemedValue } from '../../utils';
|
|
3
3
|
import { Row, Col, GridColumnOrderClasses } from '../../grid';
|
|
4
|
+
import { BlockType } from '../../models';
|
|
4
5
|
import AnimateBlock from '../../components/AnimateBlock/AnimateBlock';
|
|
5
6
|
import BlockHeader from '../../components/BlockHeader/BlockHeader';
|
|
6
7
|
import FullScreenImage from '../../components/FullscreenImage/FullscreenImage';
|
|
@@ -12,7 +13,7 @@ import { Content } from '../../sub-blocks';
|
|
|
12
13
|
import { getHeight } from '../../components/VideoBlock/VideoBlock';
|
|
13
14
|
import './Tabs.css';
|
|
14
15
|
const b = block('tabs-block');
|
|
15
|
-
export const TabsBlock = ({ items, title, description, animated, tabsColSizes, centered, direction = 'media-content', }) => {
|
|
16
|
+
export const TabsBlock = ({ items, title, description, animated, tabsColSizes, centered, direction = 'media-content', blockName = BlockType.TabsBlock, }) => {
|
|
16
17
|
var _a;
|
|
17
18
|
const [activeTab, setActiveTab] = useState(items[0].tabName);
|
|
18
19
|
const [play, setPlay] = useState(false);
|
|
@@ -37,12 +38,12 @@ export const TabsBlock = ({ items, title, description, animated, tabsColSizes, c
|
|
|
37
38
|
React.createElement(Content, { title: activeTabData.title, text: activeTabData.text, additionalInfo: activeTabData.additionalInfo, size: "s", links: [
|
|
38
39
|
...(activeTabData.link ? [activeTabData.link] : []),
|
|
39
40
|
...(activeTabData.links || []),
|
|
40
|
-
], buttons: activeTabData.buttons, colSizes: { all: 12 } }))));
|
|
41
|
+
], buttons: activeTabData.buttons, colSizes: { all: 12 }, blockName: blockName }))));
|
|
41
42
|
const mediaContent = showMedia && (React.createElement(Col, { sizes: { all: 12, md: 8 }, orders: {
|
|
42
43
|
all: GridColumnOrderClasses.Last,
|
|
43
44
|
md: GridColumnOrderClasses.First,
|
|
44
45
|
}, className: b('col', { centered: centered }) },
|
|
45
|
-
React.createElement("div", { ref: ref }, (activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.media) && (React.createElement(Media, Object.assign({}, getThemedValue(activeTabData.media, theme), { key: activeTab, className: b('media'), playVideo: play, height: mediaHeight })))),
|
|
46
|
+
React.createElement("div", { ref: ref }, (activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.media) && (React.createElement(Media, Object.assign({}, getThemedValue(activeTabData.media, theme), { key: activeTab, className: b('media'), playVideo: play, height: mediaHeight, blockName: blockName })))),
|
|
46
47
|
imageProps && (React.createElement(Fragment, null,
|
|
47
48
|
React.createElement(FullScreenImage, Object.assign({}, imageProps, { imageClassName: b('image') })))),
|
|
48
49
|
(activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.caption) && React.createElement("p", { className: b('caption') }, activeTabData.caption)));
|
|
@@ -50,7 +51,7 @@ export const TabsBlock = ({ items, title, description, animated, tabsColSizes, c
|
|
|
50
51
|
React.createElement(BlockHeader, { title: title, description: description, className: b('block-title', { centered: centered }) }),
|
|
51
52
|
React.createElement(Row, null,
|
|
52
53
|
React.createElement(Col, { sizes: tabsColSizes },
|
|
53
|
-
React.createElement(ButtonTabs, { items: tabs, onSelectTab: setActiveTab, activeTab: activeTab, className: b('tabs', { centered: centered }) }))),
|
|
54
|
+
React.createElement(ButtonTabs, { items: tabs, onSelectTab: setActiveTab, activeTab: activeTab, className: b('tabs', { centered: centered }), blockName: BlockType.TabsBlock }))),
|
|
54
55
|
activeTabData && (React.createElement(Row, { className: b('row', { reverse: isReverse }) },
|
|
55
56
|
mediaContent,
|
|
56
57
|
textContent))));
|
|
@@ -2,10 +2,19 @@ import React, { useCallback, useContext } from 'react';
|
|
|
2
2
|
import { Button, Icon } from '@gravity-ui/uikit';
|
|
3
3
|
import { ArrowSidebar } from '../../icons';
|
|
4
4
|
import { LocationContext } from '../../context/locationContext';
|
|
5
|
+
import { useAnalytics } from '../../hooks';
|
|
6
|
+
import { PredefinedEventTypes } from '../../models';
|
|
7
|
+
const COMPONENT_NAME = 'backlink';
|
|
5
8
|
export default function BackLink(props) {
|
|
6
9
|
const { history } = useContext(LocationContext);
|
|
7
|
-
const { url, title, theme = 'default', size = 'l', className, shouldHandleBackAction = false, onClick, } = props;
|
|
10
|
+
const { url, title, theme = 'default', size = 'l', className, shouldHandleBackAction = false, onClick, blockName = COMPONENT_NAME, } = props;
|
|
11
|
+
const handleAnalytics = useAnalytics({
|
|
12
|
+
name: 'back-link-click',
|
|
13
|
+
type: PredefinedEventTypes.Default,
|
|
14
|
+
blockName: blockName,
|
|
15
|
+
});
|
|
8
16
|
const backActionHandler = useCallback(async () => {
|
|
17
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics();
|
|
9
18
|
if (!history) {
|
|
10
19
|
return;
|
|
11
20
|
}
|
|
@@ -18,7 +27,7 @@ export default function BackLink(props) {
|
|
|
18
27
|
else {
|
|
19
28
|
history.push({ pathname: url });
|
|
20
29
|
}
|
|
21
|
-
}, [history, onClick, url]);
|
|
30
|
+
}, [handleAnalytics, history, onClick, url]);
|
|
22
31
|
return (React.createElement(Button, { className: className, view: theme === 'special' ? 'flat-contrast' : 'flat-secondary', size: size, href: shouldHandleBackAction ? undefined : url, onClick: shouldHandleBackAction ? backActionHandler : undefined },
|
|
23
32
|
React.createElement(Icon, { data: ArrowSidebar, size: 24 }),
|
|
24
33
|
React.createElement("span", null, title)));
|
|
@@ -6,11 +6,12 @@ import AnimateBlock from '../AnimateBlock/AnimateBlock';
|
|
|
6
6
|
import { MobileContext } from '../../context/mobileContext';
|
|
7
7
|
import './BackgroundMedia.css';
|
|
8
8
|
const b = block('BackgroundMedia');
|
|
9
|
+
const COMPONENT_NAME = 'backgound-media-component';
|
|
9
10
|
const BackgroundMedia = (_a) => {
|
|
10
11
|
var { className, color, animated, parallax = true, video, mediaClassName } = _a, props = __rest(_a, ["className", "color", "animated", "parallax", "video", "mediaClassName"]);
|
|
11
12
|
const isMobile = useContext(MobileContext);
|
|
12
13
|
return (React.createElement(AnimateBlock, { className: b(null, className), style: { backgroundColor: color }, animate: animated },
|
|
13
14
|
React.createElement(Media, Object.assign({ className: b('media', mediaClassName), imageClassName: b('image'), videoClassName: b('video'), isBackground: true }, Object.assign({ height: 720, color,
|
|
14
|
-
parallax, video: isMobile ? undefined : video }, props)))));
|
|
15
|
+
parallax, video: isMobile ? undefined : video }, props), { blockName: COMPONENT_NAME }))));
|
|
15
16
|
};
|
|
16
17
|
export default BackgroundMedia;
|
|
@@ -2,19 +2,25 @@ import { __rest } from "tslib";
|
|
|
2
2
|
import React, { useCallback, useContext } from 'react';
|
|
3
3
|
import { Platform, Button as CommonButton, Icon, StoreBadge } from '@gravity-ui/uikit';
|
|
4
4
|
import { block, setUrlTld } from '../../utils';
|
|
5
|
+
import { PredefinedEventTypes } from '../../models';
|
|
5
6
|
import { toCommonSize, toCommonView } from './utils';
|
|
6
7
|
import { LocaleContext } from '../../context/localeContext/localeContext';
|
|
7
8
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
8
9
|
import { useAnalytics } from '../../hooks';
|
|
9
10
|
import { Github } from '../../icons';
|
|
10
11
|
import './Button.css';
|
|
12
|
+
const COMPONENT_NAME = 'button';
|
|
11
13
|
const b = block('button-block');
|
|
12
14
|
const Button = (props) => {
|
|
13
15
|
const handleMetrika = useMetrika();
|
|
14
|
-
const handleAnalytics = useAnalytics();
|
|
15
16
|
const { lang, tld } = useContext(LocaleContext);
|
|
16
|
-
const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = __rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text"]);
|
|
17
|
+
const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text, blockName = COMPONENT_NAME } = props, rest = __rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text", "blockName"]);
|
|
17
18
|
const defaultImgPosition = 'left';
|
|
19
|
+
const handleAnalytics = useAnalytics({
|
|
20
|
+
name: 'button-click',
|
|
21
|
+
type: PredefinedEventTypes.Default,
|
|
22
|
+
blockName: blockName,
|
|
23
|
+
});
|
|
18
24
|
const onClick = useCallback(() => {
|
|
19
25
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
20
26
|
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import React, { useCallback, useMemo } from 'react';
|
|
2
2
|
import { block } from '../../utils';
|
|
3
|
+
import { PredefinedEventTypes } from '../../models';
|
|
3
4
|
import { Button } from '../index';
|
|
5
|
+
import { useAnalytics } from '../../hooks';
|
|
4
6
|
import './ButtonTabs.css';
|
|
5
7
|
const b = block('button-tabs');
|
|
8
|
+
const COMPONENT_NAME = 'button-tabs';
|
|
6
9
|
const ButtonTabs = (props) => {
|
|
7
|
-
const { className, items, activeTab, onSelectTab } = props;
|
|
10
|
+
const { className, items, activeTab, onSelectTab, blockName = COMPONENT_NAME } = props;
|
|
11
|
+
const handleAnalytics = useAnalytics({
|
|
12
|
+
name: 'button-tabs-click',
|
|
13
|
+
type: PredefinedEventTypes.Default,
|
|
14
|
+
blockName: blockName,
|
|
15
|
+
});
|
|
8
16
|
const activeTabId = useMemo(() => {
|
|
9
17
|
if (activeTab) {
|
|
10
18
|
return activeTab;
|
|
@@ -12,10 +20,11 @@ const ButtonTabs = (props) => {
|
|
|
12
20
|
return items[0].id;
|
|
13
21
|
}, [activeTab, items]);
|
|
14
22
|
const handleClick = useCallback((tabId) => {
|
|
23
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics();
|
|
15
24
|
if (onSelectTab) {
|
|
16
25
|
onSelectTab(tabId);
|
|
17
26
|
}
|
|
18
|
-
}, [onSelectTab]);
|
|
27
|
+
}, [handleAnalytics, onSelectTab]);
|
|
19
28
|
return (React.createElement("div", { className: b(null, className) }, items.map((item) => {
|
|
20
29
|
const isActive = item.id === activeTabId;
|
|
21
30
|
return (React.createElement(Button, { text: item.title, className: b('item', { active: isActive }), key: item.title, size: 'l', onClick: () => handleClick(item.id), theme: isActive ? 'monochrome' : 'normal' }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactElement, HTMLAttributeAnchorTarget } from 'react';
|
|
2
2
|
import { ButtonPixel, CardBaseProps as CardBaseParams, ImageProps, MetrikaGoal, WithChildren } from '../../models';
|
|
3
|
-
import {
|
|
3
|
+
import { AnalyticsEvent } from '../../models/common';
|
|
4
4
|
import './CardBase.css';
|
|
5
5
|
export interface CardBaseProps extends CardBaseParams {
|
|
6
6
|
className?: string;
|
|
@@ -11,7 +11,8 @@ export interface CardBaseProps extends CardBaseParams {
|
|
|
11
11
|
target?: HTMLAttributeAnchorTarget;
|
|
12
12
|
metrikaGoals?: MetrikaGoal;
|
|
13
13
|
pixelEvents?: ButtonPixel;
|
|
14
|
-
analyticsEvents?:
|
|
14
|
+
analyticsEvents?: AnalyticsEvent | AnalyticsEvent[];
|
|
15
|
+
blockName?: string;
|
|
15
16
|
}
|
|
16
17
|
export interface CardHeaderBaseProps {
|
|
17
18
|
className?: string;
|
|
@@ -3,16 +3,22 @@ import { block } from '../../utils';
|
|
|
3
3
|
import BackgroundImage from '../BackgroundImage/BackgroundImage';
|
|
4
4
|
import RouterLink from '../RouterLink/RouterLink';
|
|
5
5
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
6
|
+
import { PredefinedEventTypes } from '../../models/common';
|
|
6
7
|
import { useAnalytics } from '../../hooks';
|
|
7
8
|
import './CardBase.css';
|
|
9
|
+
const COMPONENT_NAME = 'card-base';
|
|
8
10
|
const b = block('card-base-block');
|
|
9
11
|
const Header = () => null;
|
|
10
12
|
const Content = () => null;
|
|
11
13
|
const Footer = () => null;
|
|
12
14
|
export const Layout = (props) => {
|
|
13
|
-
const { className, bodyClassName, metrikaGoals, pixelEvents, analyticsEvents, contentClassName, children, url, target, border = 'shadow', } = props;
|
|
15
|
+
const { className, bodyClassName, metrikaGoals, pixelEvents, analyticsEvents, contentClassName, children, url, target, border = 'shadow', blockName = COMPONENT_NAME, } = props;
|
|
14
16
|
const handleMetrika = useMetrika();
|
|
15
|
-
const handleAnalytics = useAnalytics(
|
|
17
|
+
const handleAnalytics = useAnalytics({
|
|
18
|
+
name: 'card-base-click',
|
|
19
|
+
type: PredefinedEventTypes.Default,
|
|
20
|
+
blockName: blockName,
|
|
21
|
+
});
|
|
16
22
|
let header, content, footer, image, headerClass, footerClass;
|
|
17
23
|
function handleChild(child) {
|
|
18
24
|
switch (child.type) {
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { block } from '../../utils';
|
|
3
|
+
import { PredefinedEventTypes } from '../../models';
|
|
3
4
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
4
5
|
import { useAnalytics } from '../../hooks';
|
|
5
6
|
import './HeaderBreadcrumbs.css';
|
|
6
7
|
const b = block('header-breadcrumbs');
|
|
8
|
+
const COMPONENT_NAME = 'header-breadcrumbs';
|
|
7
9
|
export default function HeaderBreadcrumbs(props) {
|
|
8
|
-
const { items, metrikaGoals, pixelEvents, analyticsEvents, theme = 'light', className } = props;
|
|
10
|
+
const { items, metrikaGoals, pixelEvents, analyticsEvents, theme = 'light', blockName = COMPONENT_NAME, className, } = props;
|
|
9
11
|
const handleMetrika = useMetrika();
|
|
10
|
-
const handleAnalytics = useAnalytics(
|
|
12
|
+
const handleAnalytics = useAnalytics({
|
|
13
|
+
name: 'header-breadcrumbs-click',
|
|
14
|
+
type: PredefinedEventTypes.Default,
|
|
15
|
+
blockName: blockName,
|
|
16
|
+
});
|
|
11
17
|
const onClick = () => {
|
|
12
18
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
13
19
|
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { Fragment, useContext } from 'react';
|
|
2
2
|
import { Icon } from '@gravity-ui/uikit';
|
|
3
3
|
import { block, getLinkProps, setUrlTld } from '../../utils';
|
|
4
|
+
import { PredefinedEventTypes, } from '../../models';
|
|
4
5
|
import { Chevron } from '../../icons';
|
|
5
6
|
import FileLink from '../FileLink/FileLink';
|
|
6
7
|
import BackLink from '../BackLink/BackLink';
|
|
@@ -11,6 +12,7 @@ import { useAnalytics } from '../../hooks';
|
|
|
11
12
|
import './Link.css';
|
|
12
13
|
const b = block('link-block');
|
|
13
14
|
const WORD_JOINER_SYM = '\u200b';
|
|
15
|
+
const COMPONENT_NAME = 'link';
|
|
14
16
|
function getArrowSize(size) {
|
|
15
17
|
switch (size) {
|
|
16
18
|
case 'l':
|
|
@@ -24,9 +26,13 @@ function getArrowSize(size) {
|
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
const LinkBlock = (props) => {
|
|
27
|
-
const { text, url, arrow, metrikaGoals, pixelEvents, analyticsEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, } = props;
|
|
29
|
+
const { text, url, arrow, metrikaGoals, pixelEvents, analyticsEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, blockName = COMPONENT_NAME, } = props;
|
|
28
30
|
const handleMetrika = useMetrika();
|
|
29
|
-
const handleAnalytics = useAnalytics(
|
|
31
|
+
const handleAnalytics = useAnalytics({
|
|
32
|
+
name: 'link-click',
|
|
33
|
+
type: PredefinedEventTypes.Default,
|
|
34
|
+
blockName: blockName,
|
|
35
|
+
});
|
|
30
36
|
const { hostname } = useContext(LocationContext);
|
|
31
37
|
const { tld } = useContext(LocaleContext);
|
|
32
38
|
const href = setUrlTld(props.url, tld);
|
|
@@ -38,7 +44,7 @@ const LinkBlock = (props) => {
|
|
|
38
44
|
const getLinkByType = () => {
|
|
39
45
|
switch (theme) {
|
|
40
46
|
case 'back':
|
|
41
|
-
return React.createElement(BackLink, { title: children || text, url: href, onClick: onClick });
|
|
47
|
+
return (React.createElement(BackLink, { title: children || text, url: href, onClick: onClick, blockName: blockName }));
|
|
42
48
|
case 'file-link':
|
|
43
49
|
case 'underline':
|
|
44
50
|
return (React.createElement(FileLink, { text: children || text, href: href, type: "horizontal", textSize: textSize, onClick: onClick }));
|
|
@@ -6,9 +6,10 @@ import Video from './Video/Video';
|
|
|
6
6
|
import YoutubeBlock from '../VideoBlock/VideoBlock';
|
|
7
7
|
import './Media.css';
|
|
8
8
|
const b = block('Media');
|
|
9
|
+
const COMPONENT_NAME = 'media-component';
|
|
9
10
|
export const Media = (props) => {
|
|
10
11
|
const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, metrika, analyticsEvents, } = props;
|
|
11
|
-
const { className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, } = props;
|
|
12
|
+
const { className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, blockName = COMPONENT_NAME, } = props;
|
|
12
13
|
const [hasVideoFallback, setHasVideoFallback] = useState(false);
|
|
13
14
|
const content = useMemo(() => {
|
|
14
15
|
let result = [];
|
|
@@ -16,7 +17,7 @@ export const Media = (props) => {
|
|
|
16
17
|
result.push(React.createElement(Image, { key: "image", parallax: parallax, image: image, height: height, imageClassName: imageClassName, isBackground: isBackground, video: video, hasVideoFallback: hasVideoFallback }));
|
|
17
18
|
}
|
|
18
19
|
if (video) {
|
|
19
|
-
result.push(React.createElement(Video, { key: "video", video: video, videoClassName: videoClassName, height: height, metrika: metrika, analyticsEvents: analyticsEvents, playVideo: playVideo, previewImg: previewImg, playButton: playButton, customBarControlsClassName: customBarControlsClassName, hasVideoFallback: hasVideoFallback, setHasVideoFallback: setHasVideoFallback }));
|
|
20
|
+
result.push(React.createElement(Video, { key: "video", video: video, videoClassName: videoClassName, height: height, metrika: metrika, analyticsEvents: analyticsEvents, playVideo: playVideo, previewImg: previewImg, playButton: playButton, customBarControlsClassName: customBarControlsClassName, hasVideoFallback: hasVideoFallback, setHasVideoFallback: setHasVideoFallback, blockName: blockName }));
|
|
20
21
|
}
|
|
21
22
|
if (youtube) {
|
|
22
23
|
result = (React.createElement(YoutubeBlock, { className: b('youtube', youtubeClassName), record: youtube, attributes: { color: 'white', rel: '0' }, previewImg: previewImg, height: height }));
|
|
@@ -42,6 +43,7 @@ export const Media = (props) => {
|
|
|
42
43
|
previewImg,
|
|
43
44
|
playButton,
|
|
44
45
|
customBarControlsClassName,
|
|
46
|
+
blockName,
|
|
45
47
|
youtubeClassName,
|
|
46
48
|
]);
|
|
47
49
|
return (React.createElement("div", { className: b(null, className), style: { backgroundColor: color } }, content));
|
|
@@ -5,8 +5,9 @@ import { getVideoTypesWithPriority } from './utils';
|
|
|
5
5
|
import { block } from '../../../utils';
|
|
6
6
|
import './Video.css';
|
|
7
7
|
const b = block('media-component-video');
|
|
8
|
+
const COMPONENT_NAME = 'media-video';
|
|
8
9
|
const Video = (props) => {
|
|
9
|
-
const { video, height, metrika, analyticsEvents, previewImg, playButton: commonPlayButton, customBarControlsClassName, videoClassName, playVideo, setHasVideoFallback, hasVideoFallback, } = props;
|
|
10
|
+
const { video, height, metrika, analyticsEvents, previewImg, playButton: commonPlayButton, customBarControlsClassName, videoClassName, playVideo, setHasVideoFallback, hasVideoFallback, blockName = COMPONENT_NAME, } = props;
|
|
10
11
|
const ref = useRef(null);
|
|
11
12
|
useEffect(() => {
|
|
12
13
|
if (ref && ref.current) {
|
|
@@ -29,9 +30,10 @@ const Video = (props) => {
|
|
|
29
30
|
}, [playVideo, video, setHasVideoFallback]);
|
|
30
31
|
const reactPlayerBlock = useMemo(() => {
|
|
31
32
|
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 }));
|
|
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, blockName: blockName }));
|
|
33
34
|
}, [
|
|
34
35
|
video,
|
|
36
|
+
height,
|
|
35
37
|
videoClassName,
|
|
36
38
|
previewImg,
|
|
37
39
|
playVideo,
|
|
@@ -39,7 +41,7 @@ const Video = (props) => {
|
|
|
39
41
|
customBarControlsClassName,
|
|
40
42
|
metrika,
|
|
41
43
|
analyticsEvents,
|
|
42
|
-
|
|
44
|
+
blockName,
|
|
43
45
|
]);
|
|
44
46
|
const defaultVideoBlock = useMemo(() => {
|
|
45
47
|
return video.src.length && !hasVideoFallback ? (React.createElement("div", { className: b('wrap', videoClassName), style: { height } },
|
|
@@ -3,7 +3,7 @@ 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, } from '../../models';
|
|
6
|
+
import { PlayButtonThemes, PlayButtonType, MediaVideoControlsType, PredefinedEventTypes, } from '../../models';
|
|
7
7
|
import CustomBarControls from './CustomBarControls';
|
|
8
8
|
import { VideoContext } from '../../context/videoContext';
|
|
9
9
|
import { MetrikaContext } from '../../context/metrikaContext';
|
|
@@ -13,11 +13,12 @@ import { useAnalytics } from '../../hooks';
|
|
|
13
13
|
import './ReactPlayer.css';
|
|
14
14
|
const b = block('ReactPlayer');
|
|
15
15
|
const FPS = 60;
|
|
16
|
+
const COMPONENT_NAME = 'react-player';
|
|
16
17
|
// eslint-disable-next-line react/display-name
|
|
17
18
|
export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
18
19
|
const isMobile = useContext(MobileContext);
|
|
19
20
|
const { metrika } = useContext(MetrikaContext);
|
|
20
|
-
const { src, previewImgUrl, loop = false, controls = MediaVideoControlsType.Default, muted: initiallyMuted = false, elapsedTime, playButton, className, customBarControlsClassName, showPreview, onClickPreview, metrika: videoMetrika, analyticsEvents, height, } = props;
|
|
21
|
+
const { src, previewImgUrl, loop = false, controls = MediaVideoControlsType.Default, muted: initiallyMuted = false, elapsedTime, playButton, className, customBarControlsClassName, showPreview, onClickPreview, metrika: videoMetrika, analyticsEvents, height, blockName = COMPONENT_NAME, } = props;
|
|
21
22
|
const { type = PlayButtonType.Default, theme = PlayButtonThemes.Blue, text, className: buttonClassName, } = playButton || {};
|
|
22
23
|
const autoPlay = Boolean(!isMobile && !previewImgUrl && props.autoplay);
|
|
23
24
|
const mute = initiallyMuted || autoPlay;
|
|
@@ -32,7 +33,11 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
32
33
|
const [started, setStarted] = useState(autoPlay);
|
|
33
34
|
const [paused, setPaused] = useState(false);
|
|
34
35
|
const [ended, setEnded] = useState(false);
|
|
35
|
-
const handleAnalytics = useAnalytics(
|
|
36
|
+
const handleAnalytics = useAnalytics({
|
|
37
|
+
name: 'react-player-controls-click',
|
|
38
|
+
type: PredefinedEventTypes.Default,
|
|
39
|
+
blockName: blockName,
|
|
40
|
+
});
|
|
36
41
|
useImperativeHandle(originRef, () => ({
|
|
37
42
|
pause: () => setIsPlaying(false),
|
|
38
43
|
}));
|
|
@@ -81,8 +86,8 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
81
86
|
window.removeEventListener('resize', updateSize);
|
|
82
87
|
};
|
|
83
88
|
}, []);
|
|
84
|
-
const playEvents = useMemo(() => analyticsEvents === null || analyticsEvents === void 0 ? void 0 : analyticsEvents.filter((e) => e.type ===
|
|
85
|
-
const stopEvents = useMemo(() => analyticsEvents === null || analyticsEvents === void 0 ? void 0 : analyticsEvents.filter((e) => e.type ===
|
|
89
|
+
const playEvents = useMemo(() => analyticsEvents === null || analyticsEvents === void 0 ? void 0 : analyticsEvents.filter((e) => e.type === PredefinedEventTypes.Play), [analyticsEvents]);
|
|
90
|
+
const stopEvents = useMemo(() => analyticsEvents === null || analyticsEvents === void 0 ? void 0 : analyticsEvents.filter((e) => e.type === PredefinedEventTypes.Stop), [analyticsEvents]);
|
|
86
91
|
const playIcon = useMemo(() => {
|
|
87
92
|
let playButtonContent;
|
|
88
93
|
switch (type) {
|
|
@@ -108,27 +113,14 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
108
113
|
metrika.reachGoals(goal, counterName);
|
|
109
114
|
}
|
|
110
115
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (events) {
|
|
114
|
-
handleAnalytics(events);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
116
|
+
const events = isMuted ? playEvents : stopEvents;
|
|
117
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(events);
|
|
117
118
|
if (isMuted) {
|
|
118
119
|
setProps({ playingVideoRef: ref.current });
|
|
119
120
|
}
|
|
120
121
|
// In order to the progress bar to update (equals 0) before displaying
|
|
121
122
|
setTimeout(() => setMuted(!isMuted), 0);
|
|
122
|
-
}, [
|
|
123
|
-
playerRef,
|
|
124
|
-
metrika,
|
|
125
|
-
videoMetrika,
|
|
126
|
-
handleAnalytics,
|
|
127
|
-
analyticsEvents,
|
|
128
|
-
playEvents,
|
|
129
|
-
stopEvents,
|
|
130
|
-
setProps,
|
|
131
|
-
]);
|
|
123
|
+
}, [playerRef, metrika, videoMetrika, handleAnalytics, playEvents, stopEvents, setProps]);
|
|
132
124
|
const handleClick = useCallback(() => changeMute(muted), [changeMute, muted]);
|
|
133
125
|
const handleClickPreview = useCallback(() => {
|
|
134
126
|
setIsPlaying(true);
|
|
@@ -139,12 +131,8 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
139
131
|
metrika.reachGoals(play, counterName);
|
|
140
132
|
}
|
|
141
133
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
handleAnalytics(playEvents);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}, [onClickPreview, metrika, videoMetrika, handleAnalytics, analyticsEvents, playEvents]);
|
|
134
|
+
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(playEvents);
|
|
135
|
+
}, [onClickPreview, metrika, videoMetrika, handleAnalytics, playEvents]);
|
|
148
136
|
const onPause = useCallback(() => {
|
|
149
137
|
// For support correct state for youtube
|
|
150
138
|
setIsPlaying(false);
|