@gravity-ui/page-constructor 1.15.0-alpha.2 → 1.15.0-alpha.21
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/schema.d.ts +27 -0
- package/build/cjs/blocks/Banner/schema.js +3 -1
- package/build/cjs/blocks/CardLayout/schema.d.ts +6 -0
- package/build/cjs/blocks/ContentLayout/schema.d.ts +3 -0
- package/build/cjs/blocks/ExtendedFeatures/schema.d.ts +3 -0
- package/build/cjs/blocks/Header/schema.d.ts +159 -0
- package/build/cjs/blocks/Header/schema.js +4 -0
- package/build/cjs/blocks/HeaderSlider/schema.d.ts +81 -0
- package/build/cjs/blocks/Icons/schema.d.ts +6 -0
- 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/schema.d.ts +9 -0
- package/build/cjs/blocks/Preview/MediaContent/MediaContent.d.ts +2 -1
- package/build/cjs/blocks/Preview/schema.d.ts +3 -0
- package/build/cjs/blocks/Preview/schema.js +3 -1
- package/build/cjs/blocks/PromoFeaturesBlock/schema.d.ts +3 -0
- package/build/cjs/blocks/Questions/schema.d.ts +3 -0
- 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.js +12 -1
- 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/schema.d.ts +3 -0
- package/build/cjs/components/BackLink/BackLink.d.ts +1 -0
- package/build/cjs/components/BackLink/BackLink.js +12 -2
- package/build/cjs/components/Button/Button.d.ts +1 -0
- package/build/cjs/components/Button/Button.js +15 -2
- package/build/cjs/components/ButtonTabs/ButtonTabs.d.ts +1 -0
- package/build/cjs/components/CardBase/CardBase.d.ts +1 -0
- package/build/cjs/components/CardBase/CardBase.js +11 -2
- package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbs.css +0 -30
- package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +3 -11
- package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbsItem.css +30 -0
- package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbsItem.d.ts +12 -0
- package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbsItem.js +28 -0
- package/build/cjs/components/Link/Link.js +11 -2
- package/build/cjs/components/Media/Video/Video.js +1 -1
- package/build/cjs/components/ReactPlayer/ReactPlayer.js +21 -25
- package/build/cjs/components/YandexForm/YandexForm.d.ts +1 -0
- package/build/cjs/components/YandexForm/YandexForm.js +11 -3
- package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +5 -4
- package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +2 -1
- package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +4 -2
- package/build/cjs/context/analyticsContext/analyticsContext.d.ts +2 -1
- package/build/cjs/context/blockPositionContext/blockPositionContext.d.ts +3 -0
- package/build/cjs/context/blockPositionContext/blockPositionContext.js +6 -0
- package/build/cjs/context/blockPositionContext/index.d.ts +1 -0
- package/build/cjs/context/blockPositionContext/index.js +4 -0
- package/build/cjs/hooks/useAnalytics.d.ts +1 -1
- package/build/cjs/hooks/useAnalytics.js +13 -7
- package/build/cjs/models/common.d.ts +7 -4
- package/build/cjs/models/common.js +7 -1
- package/build/cjs/models/constructor-items/blocks.d.ts +10 -0
- package/build/cjs/models/constructor-items/common.d.ts +9 -4
- package/build/cjs/models/constructor-items/sub-blocks.d.ts +4 -1
- package/build/cjs/navigation/components/NavigationItem/NavigationItem.js +3 -2
- package/build/cjs/schema/validators/common.d.ts +15 -0
- package/build/cjs/schema/validators/common.js +2 -0
- package/build/cjs/schema/validators/event.d.ts +3 -0
- package/build/cjs/schema/validators/event.js +3 -0
- 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/HubspotForm/index.js +10 -2
- package/build/cjs/sub-blocks/Quote/Quote.js +12 -1
- package/build/cjs/sub-blocks/Quote/schema.d.ts +3 -0
- package/build/cjs/sub-blocks/Quote/schema.js +3 -1
- package/build/cjs/utils/blocks.d.ts +7 -0
- package/build/cjs/utils/blocks.js +5 -1
- package/build/esm/blocks/Banner/schema.d.ts +27 -0
- package/build/esm/blocks/Banner/schema.js +3 -1
- package/build/esm/blocks/CardLayout/schema.d.ts +6 -0
- package/build/esm/blocks/ContentLayout/schema.d.ts +3 -0
- package/build/esm/blocks/ExtendedFeatures/schema.d.ts +3 -0
- package/build/esm/blocks/Header/schema.d.ts +159 -0
- package/build/esm/blocks/Header/schema.js +4 -0
- package/build/esm/blocks/HeaderSlider/schema.d.ts +81 -0
- package/build/esm/blocks/Icons/schema.d.ts +6 -0
- 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/schema.d.ts +9 -0
- package/build/esm/blocks/Preview/MediaContent/MediaContent.d.ts +2 -1
- package/build/esm/blocks/Preview/schema.d.ts +3 -0
- package/build/esm/blocks/Preview/schema.js +3 -1
- package/build/esm/blocks/PromoFeaturesBlock/schema.d.ts +3 -0
- package/build/esm/blocks/Questions/schema.d.ts +3 -0
- 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.js +13 -2
- 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/schema.d.ts +3 -0
- package/build/esm/components/BackLink/BackLink.d.ts +1 -0
- package/build/esm/components/BackLink/BackLink.js +12 -2
- package/build/esm/components/Button/Button.d.ts +1 -0
- package/build/esm/components/Button/Button.js +16 -3
- package/build/esm/components/ButtonTabs/ButtonTabs.d.ts +1 -0
- package/build/esm/components/CardBase/CardBase.d.ts +1 -0
- package/build/esm/components/CardBase/CardBase.js +12 -3
- package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbs.css +0 -30
- package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +3 -11
- package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbsItem.css +30 -0
- package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbsItem.d.ts +13 -0
- package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbsItem.js +25 -0
- package/build/esm/components/Link/Link.js +12 -3
- package/build/esm/components/Media/Video/Video.js +1 -1
- package/build/esm/components/ReactPlayer/ReactPlayer.js +22 -26
- package/build/esm/components/YandexForm/YandexForm.d.ts +1 -0
- package/build/esm/components/YandexForm/YandexForm.js +12 -4
- package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +6 -5
- package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +2 -1
- package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +4 -2
- package/build/esm/context/analyticsContext/analyticsContext.d.ts +2 -1
- package/build/esm/context/blockPositionContext/blockPositionContext.d.ts +3 -0
- package/build/esm/context/blockPositionContext/blockPositionContext.js +2 -0
- package/build/esm/context/blockPositionContext/index.d.ts +1 -0
- package/build/esm/context/blockPositionContext/index.js +1 -0
- package/build/esm/hooks/useAnalytics.d.ts +1 -1
- package/build/esm/hooks/useAnalytics.js +13 -7
- package/build/esm/models/common.d.ts +7 -4
- package/build/esm/models/common.js +6 -0
- package/build/esm/models/constructor-items/blocks.d.ts +10 -0
- package/build/esm/models/constructor-items/common.d.ts +9 -4
- package/build/esm/models/constructor-items/sub-blocks.d.ts +4 -1
- package/build/esm/navigation/components/NavigationItem/NavigationItem.js +3 -2
- package/build/esm/schema/validators/common.d.ts +15 -0
- package/build/esm/schema/validators/common.js +2 -0
- package/build/esm/schema/validators/event.d.ts +3 -0
- package/build/esm/schema/validators/event.js +3 -0
- 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/HubspotForm/index.js +10 -2
- package/build/esm/sub-blocks/Quote/Quote.js +14 -3
- package/build/esm/sub-blocks/Quote/schema.d.ts +3 -0
- package/build/esm/sub-blocks/Quote/schema.js +3 -1
- package/build/esm/utils/blocks.d.ts +7 -0
- package/build/esm/utils/blocks.js +3 -0
- package/package.json +1 -1
- package/server/models/common.d.ts +7 -4
- package/server/models/common.js +7 -1
- package/server/models/constructor-items/blocks.d.ts +10 -0
- package/server/models/constructor-items/common.d.ts +9 -4
- package/server/models/constructor-items/sub-blocks.d.ts +4 -1
- package/server/utils/blocks.d.ts +7 -0
- package/server/utils/blocks.js +5 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import React, { Children, Fragment } from 'react';
|
|
1
|
+
import React, { Children, Fragment, useMemo, useContext, } from 'react';
|
|
2
2
|
import { block } from '../../utils';
|
|
3
|
+
import { BlockPositionContext } from '../../context/blockPositionContext';
|
|
3
4
|
import BackgroundImage from '../BackgroundImage/BackgroundImage';
|
|
4
5
|
import RouterLink from '../RouterLink/RouterLink';
|
|
5
6
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
7
|
+
import { PredefinedEventTypes } from '../../models/common';
|
|
6
8
|
import { useAnalytics } from '../../hooks';
|
|
7
9
|
import './CardBase.css';
|
|
8
10
|
const b = block('card-base-block');
|
|
@@ -12,7 +14,14 @@ const Footer = () => null;
|
|
|
12
14
|
export const Layout = (props) => {
|
|
13
15
|
const { className, bodyClassName, metrikaGoals, pixelEvents, analyticsEvents, contentClassName, children, url, target, border = 'shadow', } = props;
|
|
14
16
|
const handleMetrika = useMetrika();
|
|
15
|
-
const
|
|
17
|
+
const context = useContext(BlockPositionContext);
|
|
18
|
+
const defaultEvent = useMemo(() => ({
|
|
19
|
+
name: 'card-base-click',
|
|
20
|
+
type: PredefinedEventTypes.Default,
|
|
21
|
+
context,
|
|
22
|
+
target: url,
|
|
23
|
+
}), [context, url]);
|
|
24
|
+
const handleAnalytics = useAnalytics(defaultEvent);
|
|
16
25
|
let header, content, footer, image, headerClass, footerClass;
|
|
17
26
|
function handleChild(child) {
|
|
18
27
|
switch (child.type) {
|
|
@@ -45,7 +54,7 @@ export const Layout = (props) => {
|
|
|
45
54
|
const fullClassName = b({ border }, className);
|
|
46
55
|
const onClick = () => {
|
|
47
56
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
48
|
-
handleAnalytics
|
|
57
|
+
handleAnalytics(analyticsEvents);
|
|
49
58
|
};
|
|
50
59
|
return url ? (React.createElement(RouterLink, { href: url },
|
|
51
60
|
React.createElement("a", { href: url, target: target, rel: target === '_blank' ? 'noopener noreferrer' : undefined, className: fullClassName, draggable: false, onDragStart: (e) => e.preventDefault(), onClick: onClick }, cardContent))) : (React.createElement("div", { className: fullClassName }, cardContent));
|
|
@@ -1,36 +1,6 @@
|
|
|
1
|
-
@charset "UTF-8";
|
|
2
|
-
/* use this for style redefinitions to awoid problems with
|
|
3
|
-
unpredictable css rules order in build */
|
|
4
1
|
.pc-header-breadcrumbs {
|
|
5
2
|
z-index: 11;
|
|
6
3
|
}
|
|
7
|
-
.pc-header-breadcrumbs__item {
|
|
8
|
-
display: inline-block;
|
|
9
|
-
}
|
|
10
|
-
.pc-header-breadcrumbs__text {
|
|
11
|
-
font-size: var(--yc-text-body-2-font-size);
|
|
12
|
-
line-height: var(--yc-text-body-2-line-height);
|
|
13
|
-
outline: none;
|
|
14
|
-
color: var(--yc-color-text-link);
|
|
15
|
-
text-decoration: none;
|
|
16
|
-
cursor: pointer;
|
|
17
|
-
color: var(--yc-color-text-secondary);
|
|
18
|
-
}
|
|
19
|
-
.utilityfocus .pc-header-breadcrumbs__text:focus {
|
|
20
|
-
outline: 2px solid #ffdb4d;
|
|
21
|
-
}
|
|
22
|
-
.pc-header-breadcrumbs__text:hover, .pc-header-breadcrumbs__text:active {
|
|
23
|
-
--pc-text-header-color: var(--yc-color-text-link-hover);
|
|
24
|
-
color: var(--yc-color-text-link-hover);
|
|
25
|
-
}
|
|
26
|
-
.pc-header-breadcrumbs__text:after {
|
|
27
|
-
content: " / ";
|
|
28
|
-
margin: 0 8px 0 6px;
|
|
29
|
-
color: var(--yc-color-text-secondary);
|
|
30
|
-
}
|
|
31
|
-
.pc-header-breadcrumbs__text:hover {
|
|
32
|
-
color: var(--yc-color-text-primary);
|
|
33
|
-
}
|
|
34
4
|
.pc-header-breadcrumbs_theme_dark .pc-header-breadcrumbs__text {
|
|
35
5
|
color: var(--yc-color-text-light-secondary);
|
|
36
6
|
}
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { block } from '../../utils';
|
|
3
|
-
import
|
|
4
|
-
import { useAnalytics } from '../../hooks';
|
|
3
|
+
import HeaderBreadcrumbsItem from './HeaderBreadcrumbsItem';
|
|
5
4
|
import './HeaderBreadcrumbs.css';
|
|
6
5
|
const b = block('header-breadcrumbs');
|
|
7
6
|
export default function HeaderBreadcrumbs(props) {
|
|
8
|
-
const { items, metrikaGoals, pixelEvents,
|
|
9
|
-
|
|
10
|
-
const handleAnalytics = useAnalytics();
|
|
11
|
-
const onClick = () => {
|
|
12
|
-
handleMetrika({ metrikaGoals, pixelEvents });
|
|
13
|
-
handleAnalytics === null || handleAnalytics === void 0 ? void 0 : handleAnalytics(analyticsEvents);
|
|
14
|
-
};
|
|
15
|
-
return (React.createElement("div", { className: b({ theme }, className) }, items.map((item) => (React.createElement("div", { className: b('item'), key: item.url },
|
|
16
|
-
React.createElement("a", { href: item.url, className: b('text'), onClick: onClick }, item.text))))));
|
|
7
|
+
const { items, metrikaGoals, pixelEvents, theme = 'light', className } = props;
|
|
8
|
+
return (React.createElement("div", { className: b({ theme }, className) }, items.map((item) => (React.createElement(HeaderBreadcrumbsItem, { key: item.url, url: item.url, text: item.text, metrikaGoals: metrikaGoals, pixelEvents: pixelEvents, analyticsEvents: item.analyticsEvents })))));
|
|
17
9
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
/* use this for style redefinitions to awoid problems with
|
|
3
|
+
unpredictable css rules order in build */
|
|
4
|
+
.pc-header-breadcrumbs-item__item {
|
|
5
|
+
display: inline-block;
|
|
6
|
+
}
|
|
7
|
+
.pc-header-breadcrumbs-item__text {
|
|
8
|
+
font-size: var(--yc-text-body-2-font-size);
|
|
9
|
+
line-height: var(--yc-text-body-2-line-height);
|
|
10
|
+
outline: none;
|
|
11
|
+
color: var(--yc-color-text-link);
|
|
12
|
+
text-decoration: none;
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
color: var(--yc-color-text-secondary);
|
|
15
|
+
}
|
|
16
|
+
.utilityfocus .pc-header-breadcrumbs-item__text:focus {
|
|
17
|
+
outline: 2px solid #ffdb4d;
|
|
18
|
+
}
|
|
19
|
+
.pc-header-breadcrumbs-item__text:hover, .pc-header-breadcrumbs-item__text:active {
|
|
20
|
+
--pc-text-header-color: var(--yc-color-text-link-hover);
|
|
21
|
+
color: var(--yc-color-text-link-hover);
|
|
22
|
+
}
|
|
23
|
+
.pc-header-breadcrumbs-item__text:after {
|
|
24
|
+
content: " / ";
|
|
25
|
+
margin: 0 8px 0 6px;
|
|
26
|
+
color: var(--yc-color-text-secondary);
|
|
27
|
+
}
|
|
28
|
+
.pc-header-breadcrumbs-item__text:hover {
|
|
29
|
+
color: var(--yc-color-text-primary);
|
|
30
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AnalyticsEvent, ButtonPixel, MetrikaGoal } from '../../models';
|
|
3
|
+
import './HeaderBreadcrumbsItem.css';
|
|
4
|
+
type HeaderBreadcrumbsItemProps = {
|
|
5
|
+
url: string;
|
|
6
|
+
text: ReactNode;
|
|
7
|
+
metrikaGoals?: MetrikaGoal;
|
|
8
|
+
pixelEvents?: ButtonPixel;
|
|
9
|
+
analyticsEvents?: AnalyticsEvent | AnalyticsEvent[];
|
|
10
|
+
context?: string;
|
|
11
|
+
};
|
|
12
|
+
export default function HeaderBreadcrumbsItem({ url, text, metrikaGoals, pixelEvents, analyticsEvents, }: HeaderBreadcrumbsItemProps): JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { useContext, useMemo } from 'react';
|
|
2
|
+
import { block } from '../../utils';
|
|
3
|
+
import { PredefinedEventTypes } from '../../models';
|
|
4
|
+
import { useMetrika } from '../../hooks/useMetrika';
|
|
5
|
+
import { useAnalytics } from '../../hooks';
|
|
6
|
+
import { BlockPositionContext } from '../../context/blockPositionContext';
|
|
7
|
+
import './HeaderBreadcrumbsItem.css';
|
|
8
|
+
const b = block('header-breadcrumbs-item');
|
|
9
|
+
export default function HeaderBreadcrumbsItem({ url, text, metrikaGoals, pixelEvents, analyticsEvents, }) {
|
|
10
|
+
const handleMetrika = useMetrika();
|
|
11
|
+
const context = useContext(BlockPositionContext);
|
|
12
|
+
const defaultEvent = useMemo(() => ({
|
|
13
|
+
name: 'header-breadcrumbs-click',
|
|
14
|
+
type: PredefinedEventTypes.Default,
|
|
15
|
+
context: context,
|
|
16
|
+
target: url,
|
|
17
|
+
}), [context, url]);
|
|
18
|
+
const handleAnalytics = useAnalytics(defaultEvent);
|
|
19
|
+
const onClick = () => {
|
|
20
|
+
handleMetrika({ metrikaGoals, pixelEvents });
|
|
21
|
+
handleAnalytics(analyticsEvents);
|
|
22
|
+
};
|
|
23
|
+
return (React.createElement("div", { className: b('item'), key: url },
|
|
24
|
+
React.createElement("a", { href: url, className: b('text'), onClick: onClick }, text)));
|
|
25
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React, { Fragment, useContext } from 'react';
|
|
1
|
+
import React, { Fragment, useContext, useMemo } 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';
|
|
@@ -8,6 +9,7 @@ import { LocaleContext } from '../../context/localeContext/localeContext';
|
|
|
8
9
|
import { LocationContext } from '../../context/locationContext/locationContext';
|
|
9
10
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
10
11
|
import { useAnalytics } from '../../hooks';
|
|
12
|
+
import { BlockPositionContext } from '../../context/blockPositionContext';
|
|
11
13
|
import './Link.css';
|
|
12
14
|
const b = block('link-block');
|
|
13
15
|
const WORD_JOINER_SYM = '\u200b';
|
|
@@ -26,14 +28,21 @@ function getArrowSize(size) {
|
|
|
26
28
|
const LinkBlock = (props) => {
|
|
27
29
|
const { text, url, arrow, metrikaGoals, pixelEvents, analyticsEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, } = props;
|
|
28
30
|
const handleMetrika = useMetrika();
|
|
29
|
-
const
|
|
31
|
+
const context = useContext(BlockPositionContext);
|
|
32
|
+
const defaultEvent = useMemo(() => ({
|
|
33
|
+
name: 'link-click',
|
|
34
|
+
type: PredefinedEventTypes.Default,
|
|
35
|
+
context,
|
|
36
|
+
target: url,
|
|
37
|
+
}), [context, url]);
|
|
38
|
+
const handleAnalytics = useAnalytics(defaultEvent);
|
|
30
39
|
const { hostname } = useContext(LocationContext);
|
|
31
40
|
const { tld } = useContext(LocaleContext);
|
|
32
41
|
const href = setUrlTld(props.url, tld);
|
|
33
42
|
const defaultTextSize = theme === 'back' ? 'l' : 'm';
|
|
34
43
|
const onClick = () => {
|
|
35
44
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
36
|
-
handleAnalytics
|
|
45
|
+
handleAnalytics(analyticsEvents);
|
|
37
46
|
};
|
|
38
47
|
const getLinkByType = () => {
|
|
39
48
|
switch (theme) {
|
|
@@ -32,6 +32,7 @@ const Video = (props) => {
|
|
|
32
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
33
|
}, [
|
|
34
34
|
video,
|
|
35
|
+
height,
|
|
35
36
|
videoClassName,
|
|
36
37
|
previewImg,
|
|
37
38
|
playVideo,
|
|
@@ -39,7 +40,6 @@ const Video = (props) => {
|
|
|
39
40
|
customBarControlsClassName,
|
|
40
41
|
metrika,
|
|
41
42
|
analyticsEvents,
|
|
42
|
-
height,
|
|
43
43
|
]);
|
|
44
44
|
const defaultVideoBlock = useMemo(() => {
|
|
45
45
|
return video.src.length && !hasVideoFallback ? (React.createElement("div", { className: b('wrap', videoClassName), style: { height } },
|
|
@@ -3,11 +3,12 @@ import ReactPlayer from 'react-player';
|
|
|
3
3
|
import React, { useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState, } from 'react';
|
|
4
4
|
import { Icon } from '@gravity-ui/uikit';
|
|
5
5
|
import { block } from '../../utils';
|
|
6
|
-
import { PlayButtonThemes, PlayButtonType, MediaVideoControlsType, } 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';
|
|
10
10
|
import { MobileContext } from '../../context/mobileContext';
|
|
11
|
+
import { BlockPositionContext } from '../../context/blockPositionContext';
|
|
11
12
|
import { PlayVideo } from '../../icons';
|
|
12
13
|
import { useAnalytics } from '../../hooks';
|
|
13
14
|
import './ReactPlayer.css';
|
|
@@ -32,7 +33,19 @@ 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
|
|
36
|
+
const eventsArray = useMemo(() => {
|
|
37
|
+
if (analyticsEvents) {
|
|
38
|
+
return Array.isArray(analyticsEvents) ? analyticsEvents : [analyticsEvents];
|
|
39
|
+
}
|
|
40
|
+
return [];
|
|
41
|
+
}, [analyticsEvents]);
|
|
42
|
+
const context = useContext(BlockPositionContext);
|
|
43
|
+
const defaultEvent = useMemo(() => ({
|
|
44
|
+
name: 'react-player-controls-click',
|
|
45
|
+
type: PredefinedEventTypes.Default,
|
|
46
|
+
context: context,
|
|
47
|
+
}), [context]);
|
|
48
|
+
const handleAnalytics = useAnalytics(defaultEvent);
|
|
36
49
|
useImperativeHandle(originRef, () => ({
|
|
37
50
|
pause: () => setIsPlaying(false),
|
|
38
51
|
}));
|
|
@@ -81,8 +94,8 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
81
94
|
window.removeEventListener('resize', updateSize);
|
|
82
95
|
};
|
|
83
96
|
}, []);
|
|
84
|
-
const playEvents = useMemo(() =>
|
|
85
|
-
const stopEvents = useMemo(() =>
|
|
97
|
+
const playEvents = useMemo(() => eventsArray === null || eventsArray === void 0 ? void 0 : eventsArray.filter((e) => e.type === PredefinedEventTypes.Play), [eventsArray]);
|
|
98
|
+
const stopEvents = useMemo(() => eventsArray === null || eventsArray === void 0 ? void 0 : eventsArray.filter((e) => e.type === PredefinedEventTypes.Stop), [eventsArray]);
|
|
86
99
|
const playIcon = useMemo(() => {
|
|
87
100
|
let playButtonContent;
|
|
88
101
|
switch (type) {
|
|
@@ -108,27 +121,14 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
108
121
|
metrika.reachGoals(goal, counterName);
|
|
109
122
|
}
|
|
110
123
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (events) {
|
|
114
|
-
handleAnalytics(events);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
124
|
+
const events = isMuted ? playEvents : stopEvents;
|
|
125
|
+
handleAnalytics(events);
|
|
117
126
|
if (isMuted) {
|
|
118
127
|
setProps({ playingVideoRef: ref.current });
|
|
119
128
|
}
|
|
120
129
|
// In order to the progress bar to update (equals 0) before displaying
|
|
121
130
|
setTimeout(() => setMuted(!isMuted), 0);
|
|
122
|
-
}, [
|
|
123
|
-
playerRef,
|
|
124
|
-
metrika,
|
|
125
|
-
videoMetrika,
|
|
126
|
-
handleAnalytics,
|
|
127
|
-
analyticsEvents,
|
|
128
|
-
playEvents,
|
|
129
|
-
stopEvents,
|
|
130
|
-
setProps,
|
|
131
|
-
]);
|
|
131
|
+
}, [playerRef, metrika, videoMetrika, handleAnalytics, playEvents, stopEvents, setProps]);
|
|
132
132
|
const handleClick = useCallback(() => changeMute(muted), [changeMute, muted]);
|
|
133
133
|
const handleClickPreview = useCallback(() => {
|
|
134
134
|
setIsPlaying(true);
|
|
@@ -139,12 +139,8 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
139
139
|
metrika.reachGoals(play, counterName);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
handleAnalytics(playEvents);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}, [onClickPreview, metrika, videoMetrika, handleAnalytics, analyticsEvents, playEvents]);
|
|
142
|
+
handleAnalytics(playEvents);
|
|
143
|
+
}, [onClickPreview, metrika, videoMetrika, handleAnalytics, playEvents]);
|
|
148
144
|
const onPause = useCallback(() => {
|
|
149
145
|
// For support correct state for youtube
|
|
150
146
|
setIsPlaying(false);
|
|
@@ -16,6 +16,7 @@ export interface YandexFormProps {
|
|
|
16
16
|
metrikaGoals?: string | string[];
|
|
17
17
|
pixelEvents?: string | string[] | PixelEvent | PixelEvent[];
|
|
18
18
|
analyticsEvents?: AnalyticsEvent | AnalyticsEvent[];
|
|
19
|
+
context?: string;
|
|
19
20
|
}
|
|
20
21
|
declare const YandexForm: (props: YandexFormProps) => JSX.Element;
|
|
21
22
|
export default YandexForm;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import React, { useCallback, useContext, useEffect, useRef } from 'react';
|
|
1
|
+
import React, { useCallback, useContext, useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
import { HEADER_HEIGHT } from '../constants';
|
|
3
3
|
import { LocaleContext } from '../../context/localeContext';
|
|
4
4
|
import { MobileContext } from '../../context/mobileContext';
|
|
5
5
|
import { block } from '../../utils';
|
|
6
6
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
7
|
-
import {
|
|
7
|
+
import { PredefinedEventTypes } from '../../models/common';
|
|
8
|
+
import { useAnalytics } from '../../hooks';
|
|
9
|
+
import { BlockPositionContext } from '../../context/blockPositionContext';
|
|
8
10
|
export const YANDEX_FORM_ORIGIN = 'https://forms.yandex.ru';
|
|
9
11
|
const CONTAINER_ID = 'pc-yandex-form-container';
|
|
10
12
|
const b = block('yandex-form');
|
|
@@ -14,7 +16,13 @@ const YandexForm = (props) => {
|
|
|
14
16
|
const iframeRef = useRef();
|
|
15
17
|
const yaFormOrigin = customFormOrigin || YANDEX_FORM_ORIGIN;
|
|
16
18
|
const handleMetrika = useMetrika();
|
|
17
|
-
const
|
|
19
|
+
const context = useContext(BlockPositionContext);
|
|
20
|
+
const defaultEvent = useMemo(() => ({
|
|
21
|
+
name: 'yndex-form-submit',
|
|
22
|
+
type: PredefinedEventTypes.Default,
|
|
23
|
+
context: context,
|
|
24
|
+
}), [context]);
|
|
25
|
+
const handleAnalytics = useAnalytics(defaultEvent);
|
|
18
26
|
const isMobile = useContext(MobileContext);
|
|
19
27
|
const locale = useContext(LocaleContext);
|
|
20
28
|
const updateFormIframe = useCallback((container) => {
|
|
@@ -55,7 +63,7 @@ const YandexForm = (props) => {
|
|
|
55
63
|
window.scrollBy(0, top - headerHeight);
|
|
56
64
|
}
|
|
57
65
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
58
|
-
handleAnalytics
|
|
66
|
+
handleAnalytics(analyticsEvents);
|
|
59
67
|
if (onSubmit) {
|
|
60
68
|
onSubmit();
|
|
61
69
|
}
|
package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import React, { Fragment, useContext } from 'react';
|
|
3
|
-
import { getBlockKey } from '../../../../utils';
|
|
3
|
+
import { getBlockContext, getBlockKey } from '../../../../utils';
|
|
4
4
|
import { InnerContext } from '../../../../context/innerContext';
|
|
5
5
|
import { ConstructorLoadable } from '../ConstructorLoadable';
|
|
6
6
|
import { ConstructorItem } from '../ConstructorItem';
|
|
7
7
|
import { ConstructorBlock } from '../ConstructorBlock/ConstructorBlock';
|
|
8
8
|
export const ConstructorBlocks = ({ items, shouldRenderBlock }) => {
|
|
9
9
|
const { blockTypes, loadables, itemMap } = useContext(InnerContext);
|
|
10
|
-
const renderer = (item, index) => {
|
|
10
|
+
const renderer = (parentContext = '', item, index) => {
|
|
11
11
|
if (!itemMap[item.type]) {
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
14
14
|
let children;
|
|
15
15
|
let itemElement;
|
|
16
16
|
const key = getBlockKey(item, index);
|
|
17
|
+
const context = getBlockContext({ parentContext, block: item, index });
|
|
17
18
|
if (shouldRenderBlock && !shouldRenderBlock(item, key)) {
|
|
18
19
|
return null;
|
|
19
20
|
}
|
|
@@ -27,11 +28,11 @@ export const ConstructorBlocks = ({ items, shouldRenderBlock }) => {
|
|
|
27
28
|
}
|
|
28
29
|
else {
|
|
29
30
|
if ('children' in item && item.children) {
|
|
30
|
-
children = item.children.map(renderer);
|
|
31
|
+
children = item.children.map(renderer.bind(null, context));
|
|
31
32
|
}
|
|
32
|
-
itemElement = (React.createElement(ConstructorItem, { data: item, key: key }, children));
|
|
33
|
+
itemElement = (React.createElement(ConstructorItem, { data: item, key: key, context: context }, children));
|
|
33
34
|
}
|
|
34
35
|
return blockTypes.includes(item.type) ? (React.createElement(ConstructorBlock, { data: item, key: key, Component: itemElement })) : (itemElement);
|
|
35
36
|
};
|
|
36
|
-
return React.createElement(Fragment, null, items.map(renderer));
|
|
37
|
+
return React.createElement(Fragment, null, items.map(renderer.bind(null, '')));
|
|
37
38
|
};
|
package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ConstructorItem as ConstructorItemType, WithChildren } from '../../../../models';
|
|
2
2
|
export interface ConstructorItemProps {
|
|
3
3
|
data: ConstructorItemType;
|
|
4
|
+
context?: string;
|
|
4
5
|
}
|
|
5
|
-
export declare const ConstructorItem: ({ data, children }: WithChildren<ConstructorItemProps>) => JSX.Element;
|
|
6
|
+
export declare const ConstructorItem: ({ data, children, context }: WithChildren<ConstructorItemProps>) => JSX.Element;
|
|
6
7
|
export declare const ConstructorHeader: ({ data }: Pick<ConstructorItemProps, 'data'>) => JSX.Element;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
3
|
import { InnerContext } from '../../../../context/innerContext';
|
|
4
|
-
|
|
4
|
+
import { BlockPositionContext } from '../../../../context/blockPositionContext';
|
|
5
|
+
export const ConstructorItem = ({ data, children, context }) => {
|
|
5
6
|
const { itemMap } = useContext(InnerContext);
|
|
6
7
|
const { type } = data, rest = __rest(data, ["type"]);
|
|
7
8
|
const Component = itemMap[type];
|
|
8
|
-
return React.createElement(
|
|
9
|
+
return (React.createElement(BlockPositionContext.Provider, { value: context || type },
|
|
10
|
+
React.createElement(Component, Object.assign({}, rest), children)));
|
|
9
11
|
};
|
|
10
12
|
export const ConstructorHeader = ({ data }) => (React.createElement(ConstructorItem, { data: data, key: data.type }));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AnalyticsEvent } from '../../models';
|
|
3
3
|
export interface AnalyticsContextProps {
|
|
4
|
-
sendEvents?: (
|
|
4
|
+
sendEvents?: (events: AnalyticsEvent[]) => void;
|
|
5
|
+
autoEvents?: boolean;
|
|
5
6
|
}
|
|
6
7
|
export declare const AnalyticsContext: React.Context<AnalyticsContextProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './blockPositionContext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './blockPositionContext';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AnalyticsEvent } from '../models';
|
|
2
|
-
export declare const useAnalytics: () => ((e?: AnalyticsEvent | AnalyticsEvent[]
|
|
2
|
+
export declare const useAnalytics: (defaultEvent?: AnalyticsEvent) => ((e?: AnalyticsEvent | AnalyticsEvent[]) => void) & import("lodash").MemoizedFunction;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
import { memoize } from 'lodash';
|
|
1
2
|
import { useContext } from 'react';
|
|
2
3
|
import { AnalyticsContext } from '../context/analyticsContext';
|
|
3
|
-
export const useAnalytics = () => {
|
|
4
|
-
const { sendEvents } = useContext(AnalyticsContext);
|
|
4
|
+
export const useAnalytics = (defaultEvent) => {
|
|
5
|
+
const { sendEvents, autoEvents } = useContext(AnalyticsContext);
|
|
5
6
|
if (!sendEvents) {
|
|
6
|
-
return
|
|
7
|
+
return memoize(() => { });
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
const defaultEvents = defaultEvent && autoEvents ? [defaultEvent] : [];
|
|
10
|
+
return memoize((e) => {
|
|
11
|
+
let events = defaultEvents;
|
|
12
|
+
if (e) {
|
|
13
|
+
events = Array.isArray(e) ? [...events, ...e] : [...events, e];
|
|
14
|
+
}
|
|
15
|
+
if (!events) {
|
|
10
16
|
return;
|
|
11
17
|
}
|
|
12
|
-
sendEvents(
|
|
13
|
-
};
|
|
18
|
+
sendEvents(events);
|
|
19
|
+
});
|
|
14
20
|
};
|
|
@@ -64,10 +64,11 @@ export interface ClassNameProps {
|
|
|
64
64
|
className?: string;
|
|
65
65
|
}
|
|
66
66
|
export type Timeout = ReturnType<typeof setTimeout> | undefined;
|
|
67
|
-
export
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
export declare enum PredefinedEventTypes {
|
|
68
|
+
Default = "default-event",
|
|
69
|
+
Play = "play",
|
|
70
|
+
Stop = "stop"
|
|
71
|
+
}
|
|
71
72
|
export type AnalyticsCounters = {
|
|
72
73
|
include?: string[];
|
|
73
74
|
exclude?: string[];
|
|
@@ -76,5 +77,7 @@ export type AnalyticsEvent<T = {}> = T & {
|
|
|
76
77
|
name: string;
|
|
77
78
|
type?: string;
|
|
78
79
|
counters?: AnalyticsCounters;
|
|
80
|
+
context?: string;
|
|
81
|
+
target?: string;
|
|
79
82
|
};
|
|
80
83
|
export {};
|
|
@@ -27,3 +27,9 @@ export var PixelEventType;
|
|
|
27
27
|
PixelEventType["Subscribe"] = "Subscribe";
|
|
28
28
|
PixelEventType["ViewContent"] = "ViewContent";
|
|
29
29
|
})(PixelEventType || (PixelEventType = {}));
|
|
30
|
+
export var PredefinedEventTypes;
|
|
31
|
+
(function (PredefinedEventTypes) {
|
|
32
|
+
PredefinedEventTypes["Default"] = "default-event";
|
|
33
|
+
PredefinedEventTypes["Play"] = "play";
|
|
34
|
+
PredefinedEventTypes["Stop"] = "stop";
|
|
35
|
+
})(PredefinedEventTypes || (PredefinedEventTypes = {}));
|
|
@@ -109,6 +109,7 @@ export interface HeaderBlockProps {
|
|
|
109
109
|
verticalOffset?: 's' | 'm' | 'l' | 'xl';
|
|
110
110
|
breadcrumbs?: HeaderBreadCrumbsProps;
|
|
111
111
|
status?: JSX.Element;
|
|
112
|
+
context?: string;
|
|
112
113
|
}
|
|
113
114
|
export type CalculatorProps = Animatable;
|
|
114
115
|
export interface SimpleBlockProps extends Animatable, Childable {
|
|
@@ -127,6 +128,7 @@ export interface ExtendedFeaturesProps extends Animatable {
|
|
|
127
128
|
title?: TitleProps | string;
|
|
128
129
|
description?: string;
|
|
129
130
|
colSizes?: GridColumnSizesType;
|
|
131
|
+
context?: string;
|
|
130
132
|
}
|
|
131
133
|
export interface PromoFeaturesItem {
|
|
132
134
|
title: string;
|
|
@@ -139,6 +141,7 @@ export interface PromoFeaturesProps extends Animatable {
|
|
|
139
141
|
title?: TitleProps | string;
|
|
140
142
|
description?: string;
|
|
141
143
|
theme?: 'grey' | 'default';
|
|
144
|
+
context?: string;
|
|
142
145
|
}
|
|
143
146
|
export interface QuestionItem {
|
|
144
147
|
title: string;
|
|
@@ -163,6 +166,7 @@ export interface MediaContentProps {
|
|
|
163
166
|
links?: LinkProps[];
|
|
164
167
|
buttons?: ButtonProps[];
|
|
165
168
|
size?: ContentSize;
|
|
169
|
+
context?: string;
|
|
166
170
|
}
|
|
167
171
|
export interface MediaBlockProps extends Animatable, MediaContentProps {
|
|
168
172
|
media: ThemeSupporting<MediaProps>;
|
|
@@ -180,6 +184,7 @@ export interface PreviewBlockProps extends Animatable {
|
|
|
180
184
|
ratioMediaContent?: PreviewRatioMediaContent;
|
|
181
185
|
stopVideo?: boolean;
|
|
182
186
|
showImmediately?: boolean;
|
|
187
|
+
context?: string;
|
|
183
188
|
}
|
|
184
189
|
export interface InfoBlockProps {
|
|
185
190
|
theme?: TextTheme;
|
|
@@ -194,6 +199,7 @@ export interface InfoBlockProps {
|
|
|
194
199
|
links?: Pick<LinkProps, 'text' | 'url'>[];
|
|
195
200
|
leftContent?: Omit<ContentBlockProps, 'colSizes' | 'theme' | 'size'>;
|
|
196
201
|
rightContent?: Omit<ContentBlockProps, 'colSizes' | 'theme' | 'size'>;
|
|
202
|
+
context?: string;
|
|
197
203
|
}
|
|
198
204
|
export interface SecurityBlockPoint {
|
|
199
205
|
img: string;
|
|
@@ -209,6 +215,7 @@ export interface SecurityBlockProps extends Animatable {
|
|
|
209
215
|
title: string;
|
|
210
216
|
points?: SecurityBlockPoint[];
|
|
211
217
|
media: MediaProps;
|
|
218
|
+
context?: string;
|
|
212
219
|
}
|
|
213
220
|
export interface TableProps {
|
|
214
221
|
content: string[][];
|
|
@@ -235,6 +242,7 @@ export interface TabsBlockProps extends BlockHeaderProps, Animatable {
|
|
|
235
242
|
centered?: boolean;
|
|
236
243
|
direction?: MediaDirection;
|
|
237
244
|
items: TabsBlockItem[];
|
|
245
|
+
context?: string;
|
|
238
246
|
}
|
|
239
247
|
export interface LinkTableBlockProps extends BlockHeaderProps {
|
|
240
248
|
items: LinkProps[][];
|
|
@@ -264,6 +272,7 @@ export interface ContentLayoutBlockProps {
|
|
|
264
272
|
};
|
|
265
273
|
textContent: ContentBlockProps;
|
|
266
274
|
fileContent?: FileLinkProps[];
|
|
275
|
+
context?: string;
|
|
267
276
|
}
|
|
268
277
|
export interface ContentBlockProps {
|
|
269
278
|
title?: TitleBaseProps | string;
|
|
@@ -275,6 +284,7 @@ export interface ContentBlockProps {
|
|
|
275
284
|
colSizes?: GridColumnSizesType;
|
|
276
285
|
centered?: boolean;
|
|
277
286
|
theme?: ContentTheme;
|
|
287
|
+
context?: string;
|
|
278
288
|
}
|
|
279
289
|
export declare enum PCShareSocialNetwork {
|
|
280
290
|
Vk = "vk",
|