@gravity-ui/page-constructor 1.19.1 → 1.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +79 -6
- package/build/cjs/blocks/Banner/schema.d.ts +234 -0
- 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 +81 -0
- 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/LinkTable/schema.d.ts +3 -0
- package/build/cjs/blocks/Map/schema.d.ts +81 -0
- package/build/cjs/blocks/Media/schema.d.ts +162 -0
- package/build/cjs/blocks/PromoFeaturesBlock/schema.d.ts +3 -0
- package/build/cjs/blocks/Questions/schema.d.ts +3 -0
- package/build/cjs/blocks/Share/Share.js +5 -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 +81 -0
- package/build/cjs/components/BackLink/BackLink.js +5 -1
- package/build/cjs/components/Button/Button.js +6 -2
- package/build/cjs/components/CardBase/CardBase.d.ts +2 -1
- package/build/cjs/components/CardBase/CardBase.js +5 -1
- package/build/cjs/components/Link/Link.js +5 -1
- package/build/cjs/components/Media/Media.js +3 -2
- package/build/cjs/components/Media/Video/Video.js +3 -2
- package/build/cjs/components/ReactPlayer/ReactPlayer.js +16 -3
- package/build/cjs/components/YandexForm/YandexForm.d.ts +2 -1
- package/build/cjs/components/YandexForm/YandexForm.js +14 -2
- package/build/cjs/containers/PageConstructor/Provider.d.ts +2 -0
- package/build/cjs/containers/PageConstructor/Provider.js +3 -1
- package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +7 -4
- package/build/cjs/context/analyticsContext/analyticsContext.d.ts +7 -0
- package/build/cjs/context/analyticsContext/analyticsContext.js +6 -0
- package/build/cjs/context/analyticsContext/index.d.ts +1 -0
- package/build/cjs/context/analyticsContext/index.js +4 -0
- package/build/cjs/context/blockIdContext/blockIdContext.d.ts +3 -0
- package/build/cjs/context/blockIdContext/blockIdContext.js +6 -0
- package/build/cjs/context/blockIdContext/index.d.ts +1 -0
- package/build/cjs/context/blockIdContext/index.js +4 -0
- package/build/cjs/context/metrikaContext/metrikaContext.d.ts +6 -0
- package/build/cjs/hooks/index.d.ts +1 -0
- package/build/cjs/hooks/index.js +1 -0
- package/build/cjs/hooks/useAnalytics.d.ts +2 -0
- package/build/cjs/hooks/useAnalytics.js +35 -0
- package/build/cjs/hooks/useMetrika.d.ts +6 -0
- package/build/cjs/hooks/useMetrika.js +8 -0
- package/build/cjs/models/common.d.ts +45 -0
- package/build/cjs/models/common.js +22 -1
- package/build/cjs/models/constructor-items/common.d.ts +5 -5
- package/build/cjs/models/constructor-items/sub-blocks.d.ts +2 -2
- package/build/cjs/models/navigation.d.ts +3 -9
- package/build/cjs/models/navigation.js +0 -1
- package/build/cjs/navigation/components/NavigationItem/NavigationItem.js +4 -3
- package/build/cjs/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.js +4 -2
- package/build/cjs/schema/validators/common.d.ts +249 -0
- package/build/cjs/schema/validators/common.js +14 -0
- package/build/cjs/schema/validators/event.d.ts +37 -0
- package/build/cjs/schema/validators/event.js +38 -0
- package/build/cjs/sub-blocks/HubspotForm/index.js +15 -2
- package/build/cjs/sub-blocks/LayoutItem/utils.d.ts +13 -0
- package/build/cjs/sub-blocks/Quote/Quote.js +4 -1
- package/build/cjs/utils/analytics.d.ts +2 -0
- package/build/cjs/utils/analytics.js +17 -0
- package/build/cjs/utils/index.d.ts +1 -0
- package/build/cjs/utils/index.js +1 -0
- package/build/esm/blocks/Banner/schema.d.ts +234 -0
- 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 +81 -0
- 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/LinkTable/schema.d.ts +3 -0
- package/build/esm/blocks/Map/schema.d.ts +81 -0
- package/build/esm/blocks/Media/schema.d.ts +162 -0
- package/build/esm/blocks/PromoFeaturesBlock/schema.d.ts +3 -0
- package/build/esm/blocks/Questions/schema.d.ts +3 -0
- package/build/esm/blocks/Share/Share.js +6 -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 +81 -0
- package/build/esm/components/BackLink/BackLink.js +5 -1
- package/build/esm/components/Button/Button.js +6 -2
- package/build/esm/components/CardBase/CardBase.d.ts +2 -1
- package/build/esm/components/CardBase/CardBase.js +5 -1
- package/build/esm/components/Link/Link.js +5 -1
- package/build/esm/components/Media/Media.js +3 -2
- package/build/esm/components/Media/Video/Video.js +3 -2
- package/build/esm/components/ReactPlayer/ReactPlayer.js +17 -4
- package/build/esm/components/YandexForm/YandexForm.d.ts +2 -1
- package/build/esm/components/YandexForm/YandexForm.js +14 -2
- package/build/esm/containers/PageConstructor/Provider.d.ts +2 -0
- package/build/esm/containers/PageConstructor/Provider.js +3 -1
- package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +7 -4
- package/build/esm/context/analyticsContext/analyticsContext.d.ts +7 -0
- package/build/esm/context/analyticsContext/analyticsContext.js +2 -0
- package/build/esm/context/analyticsContext/index.d.ts +1 -0
- package/build/esm/context/analyticsContext/index.js +1 -0
- package/build/esm/context/blockIdContext/blockIdContext.d.ts +3 -0
- package/build/esm/context/blockIdContext/blockIdContext.js +2 -0
- package/build/esm/context/blockIdContext/index.d.ts +1 -0
- package/build/esm/context/blockIdContext/index.js +1 -0
- package/build/esm/context/metrikaContext/metrikaContext.d.ts +6 -0
- package/build/esm/hooks/index.d.ts +1 -0
- package/build/esm/hooks/index.js +1 -0
- package/build/esm/hooks/useAnalytics.d.ts +2 -0
- package/build/esm/hooks/useAnalytics.js +31 -0
- package/build/esm/hooks/useMetrika.d.ts +6 -0
- package/build/esm/hooks/useMetrika.js +8 -0
- package/build/esm/models/common.d.ts +45 -0
- package/build/esm/models/common.js +21 -0
- package/build/esm/models/constructor-items/common.d.ts +5 -5
- package/build/esm/models/constructor-items/sub-blocks.d.ts +2 -2
- package/build/esm/models/navigation.d.ts +3 -9
- package/build/esm/models/navigation.js +0 -1
- package/build/esm/navigation/components/NavigationItem/NavigationItem.js +4 -3
- package/build/esm/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.js +4 -2
- package/build/esm/schema/validators/common.d.ts +249 -0
- package/build/esm/schema/validators/common.js +14 -0
- package/build/esm/schema/validators/event.d.ts +37 -0
- package/build/esm/schema/validators/event.js +35 -0
- package/build/esm/sub-blocks/HubspotForm/index.js +16 -3
- package/build/esm/sub-blocks/LayoutItem/utils.d.ts +13 -0
- package/build/esm/sub-blocks/Quote/Quote.js +6 -3
- package/build/esm/utils/analytics.d.ts +2 -0
- package/build/esm/utils/analytics.js +13 -0
- package/build/esm/utils/index.d.ts +1 -0
- package/build/esm/utils/index.js +1 -0
- package/package.json +1 -2
- package/server/models/common.d.ts +45 -0
- package/server/models/common.js +22 -1
- package/server/models/constructor-items/common.d.ts +5 -5
- package/server/models/constructor-items/sub-blocks.d.ts +2 -2
- package/server/models/navigation.d.ts +3 -9
- package/server/models/navigation.js +0 -1
- package/server/utils/analytics.d.ts +2 -0
- package/server/utils/analytics.js +17 -0
- package/server/utils/index.d.ts +1 -0
- package/server/utils/index.js +1 -0
- package/build/cjs/navigation/components/NavigationItem/components/GithubStars/GithubStars.css +0 -14
- package/build/cjs/navigation/components/NavigationItem/components/GithubStars/GithubStars.d.ts +0 -5
- package/build/cjs/navigation/components/NavigationItem/components/GithubStars/GithubStars.js +0 -11
- package/build/esm/navigation/components/NavigationItem/components/GithubStars/GithubStars.css +0 -14
- package/build/esm/navigation/components/NavigationItem/components/GithubStars/GithubStars.d.ts +0 -6
- package/build/esm/navigation/components/NavigationItem/components/GithubStars/GithubStars.js +0 -7
|
@@ -3,16 +3,19 @@ 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
|
+
import { DefaultEventNames } from '../../models/common';
|
|
6
7
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
8
|
+
import { useAnalytics } from '../../hooks';
|
|
7
9
|
export const YANDEX_FORM_ORIGIN = 'https://forms.yandex.ru';
|
|
8
10
|
const CONTAINER_ID = 'pc-yandex-form-container';
|
|
9
11
|
const b = block('yandex-form');
|
|
10
12
|
const YandexForm = (props) => {
|
|
11
|
-
const { onLoad, id, params, className, theme, containerId = CONTAINER_ID, headerHeight = HEADER_HEIGHT, onSubmit, metrikaGoals, pixelEvents, customFormOrigin, } = props;
|
|
13
|
+
const { onLoad, id, params, className, theme, containerId = CONTAINER_ID, headerHeight = HEADER_HEIGHT, onSubmit, metrikaGoals, pixelEvents, analyticsEvents, customFormOrigin, } = props;
|
|
12
14
|
const formContainerRef = useRef(null);
|
|
13
15
|
const iframeRef = useRef();
|
|
14
16
|
const yaFormOrigin = customFormOrigin || YANDEX_FORM_ORIGIN;
|
|
15
17
|
const handleMetrika = useMetrika();
|
|
18
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.YandexFormSubmit);
|
|
16
19
|
const isMobile = useContext(MobileContext);
|
|
17
20
|
const locale = useContext(LocaleContext);
|
|
18
21
|
const updateFormIframe = useCallback((container) => {
|
|
@@ -53,10 +56,19 @@ const YandexForm = (props) => {
|
|
|
53
56
|
window.scrollBy(0, top - headerHeight);
|
|
54
57
|
}
|
|
55
58
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
59
|
+
handleAnalytics(analyticsEvents);
|
|
56
60
|
if (onSubmit) {
|
|
57
61
|
onSubmit();
|
|
58
62
|
}
|
|
59
|
-
}, [
|
|
63
|
+
}, [
|
|
64
|
+
handleMetrika,
|
|
65
|
+
metrikaGoals,
|
|
66
|
+
pixelEvents,
|
|
67
|
+
handleAnalytics,
|
|
68
|
+
analyticsEvents,
|
|
69
|
+
onSubmit,
|
|
70
|
+
headerHeight,
|
|
71
|
+
]);
|
|
60
72
|
const handleMessage = useCallback(({ origin, data }) => {
|
|
61
73
|
if (origin !== yaFormOrigin) {
|
|
62
74
|
return;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MetrikaContextProps } from '../../context/metrikaContext';
|
|
2
|
+
import { AnalyticsContextProps } from '../../context/analyticsContext';
|
|
2
3
|
import { MapsContextType } from '../../context/mapsContext/mapsContext';
|
|
3
4
|
import { ProjectSettingsContextProps } from '../../context/projectSettingsContext';
|
|
4
5
|
import { SSRContextProps } from '../../context/ssrContext';
|
|
@@ -15,5 +16,6 @@ export interface PageConstructorProviderProps {
|
|
|
15
16
|
theme?: ConstructorTheme;
|
|
16
17
|
mapsContext?: MapsContextType;
|
|
17
18
|
projectSettings?: ProjectSettingsContextProps;
|
|
19
|
+
analytics?: AnalyticsContextProps;
|
|
18
20
|
}
|
|
19
21
|
export declare const PageConstructorProvider: (props: WithChildren<PageConstructorProviderProps>) => JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { Fragment } from 'react';
|
|
2
2
|
import { MetrikaContext } from '../../context/metrikaContext';
|
|
3
|
+
import { AnalyticsContext } from '../../context/analyticsContext';
|
|
3
4
|
import { MobileContext } from '../../context/mobileContext';
|
|
4
5
|
import { MapsContext, initialMapValue } from '../../context/mapsContext/mapsContext';
|
|
5
6
|
import { ProjectSettingsContext, } from '../../context/projectSettingsContext';
|
|
@@ -9,7 +10,7 @@ import { LocationContext } from '../../context/locationContext';
|
|
|
9
10
|
import { ThemeValueContext } from '../../context/theme/ThemeValueContext';
|
|
10
11
|
import { DEFAULT_THEME } from '../../components/constants';
|
|
11
12
|
export const PageConstructorProvider = (props) => {
|
|
12
|
-
const { isMobile, mapsContext = initialMapValue, locale = {}, location = {}, metrika = {}, ssrConfig = {}, projectSettings = {}, theme = DEFAULT_THEME, children, } = props;
|
|
13
|
+
const { isMobile, mapsContext = initialMapValue, locale = {}, location = {}, metrika = {}, analytics = {}, ssrConfig = {}, projectSettings = {}, theme = DEFAULT_THEME, children, } = props;
|
|
13
14
|
/* eslint-disable react/jsx-key */
|
|
14
15
|
const context = [
|
|
15
16
|
React.createElement(ThemeValueContext.Provider, { value: { themeValue: theme } }),
|
|
@@ -19,6 +20,7 @@ export const PageConstructorProvider = (props) => {
|
|
|
19
20
|
React.createElement(MobileContext.Provider, { value: Boolean(isMobile) }),
|
|
20
21
|
React.createElement(MapsContext.Provider, { value: mapsContext }),
|
|
21
22
|
React.createElement(MetrikaContext.Provider, { value: metrika }),
|
|
23
|
+
React.createElement(AnalyticsContext.Provider, { value: analytics }),
|
|
22
24
|
React.createElement(SSRContext.Provider, { value: { isServer: ssrConfig === null || ssrConfig === void 0 ? void 0 : ssrConfig.isServer } }),
|
|
23
25
|
].reduceRight((prev, provider) => React.cloneElement(provider, {}, prev), children);
|
|
24
26
|
/* eslint-enable react/jsx-key */
|
package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js
CHANGED
|
@@ -2,18 +2,20 @@ import _ from 'lodash';
|
|
|
2
2
|
import React, { Fragment, useContext } from 'react';
|
|
3
3
|
import { getBlockKey } from '../../../../utils';
|
|
4
4
|
import { InnerContext } from '../../../../context/innerContext';
|
|
5
|
+
import { BlockIdContext } from '../../../../context/blockIdContext';
|
|
5
6
|
import { ConstructorLoadable } from '../ConstructorLoadable';
|
|
6
7
|
import { ConstructorItem } from '../ConstructorItem';
|
|
7
8
|
import { ConstructorBlock } from '../ConstructorBlock/ConstructorBlock';
|
|
8
9
|
export const ConstructorBlocks = ({ items, shouldRenderBlock }) => {
|
|
9
10
|
const { blockTypes, loadables, itemMap } = useContext(InnerContext);
|
|
10
|
-
const renderer = (item, index) => {
|
|
11
|
+
const renderer = (parentId = '', item, index) => {
|
|
11
12
|
if (!itemMap[item.type]) {
|
|
12
13
|
return null;
|
|
13
14
|
}
|
|
14
15
|
let children;
|
|
15
16
|
let itemElement;
|
|
16
17
|
const key = getBlockKey(item, index);
|
|
18
|
+
const blockId = parentId ? `${parentId}_${key}` : key;
|
|
17
19
|
if (shouldRenderBlock && !shouldRenderBlock(item, key)) {
|
|
18
20
|
return null;
|
|
19
21
|
}
|
|
@@ -27,11 +29,12 @@ export const ConstructorBlocks = ({ items, shouldRenderBlock }) => {
|
|
|
27
29
|
}
|
|
28
30
|
else {
|
|
29
31
|
if ('children' in item && item.children) {
|
|
30
|
-
children = item.children.map(renderer);
|
|
32
|
+
children = item.children.map(renderer.bind(null, blockId));
|
|
31
33
|
}
|
|
32
|
-
itemElement = (React.createElement(
|
|
34
|
+
itemElement = (React.createElement(BlockIdContext.Provider, { value: blockId },
|
|
35
|
+
React.createElement(ConstructorItem, { data: item, key: key }, children)));
|
|
33
36
|
}
|
|
34
37
|
return blockTypes.includes(item.type) ? (React.createElement(ConstructorBlock, { data: item, key: key, Component: itemElement })) : (itemElement);
|
|
35
38
|
};
|
|
36
|
-
return React.createElement(Fragment, null, items.map(renderer));
|
|
39
|
+
return React.createElement(Fragment, null, items.map(renderer.bind(null, '')));
|
|
37
40
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AnalyticsEvent } from '../../models';
|
|
3
|
+
export interface AnalyticsContextProps {
|
|
4
|
+
sendEvents?: (events: AnalyticsEvent[]) => void;
|
|
5
|
+
autoEvents?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const AnalyticsContext: React.Context<AnalyticsContextProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './analyticsContext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './analyticsContext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './blockIdContext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './blockIdContext';
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Metrika, Pixel } from '../../models';
|
|
3
3
|
export interface MetrikaContextProps {
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Metrika will be deleted
|
|
6
|
+
*/
|
|
4
7
|
metrika?: Metrika;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Metrika will be deleted
|
|
10
|
+
*/
|
|
5
11
|
pixel?: Pixel;
|
|
6
12
|
}
|
|
7
13
|
export declare const MetrikaContext: React.Context<MetrikaContextProps>;
|
|
@@ -2,4 +2,5 @@ export { default as useFocus } from './useFocus';
|
|
|
2
2
|
export { default as useWindowBreakpoint } from './useWindowBreakpoint';
|
|
3
3
|
export { useIntersection } from './useIntersection';
|
|
4
4
|
export { default as useMount } from './useMount';
|
|
5
|
+
export * from './useAnalytics';
|
|
5
6
|
export * from './hubspot';
|
package/build/esm/hooks/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export { default as useFocus } from './useFocus';
|
|
|
2
2
|
export { default as useWindowBreakpoint } from './useWindowBreakpoint';
|
|
3
3
|
export { useIntersection } from './useIntersection';
|
|
4
4
|
export { default as useMount } from './useMount';
|
|
5
|
+
export * from './useAnalytics';
|
|
5
6
|
export * from './hubspot';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { memoize } from 'lodash';
|
|
2
|
+
import { useContext, useMemo } from 'react';
|
|
3
|
+
import { BlockIdContext } from '../context/blockIdContext';
|
|
4
|
+
import { AnalyticsContext } from '../context/analyticsContext';
|
|
5
|
+
import { PredefinedEventTypes } from '../models';
|
|
6
|
+
export const useAnalytics = (name = '', target) => {
|
|
7
|
+
const { sendEvents, autoEvents } = useContext(AnalyticsContext);
|
|
8
|
+
const context = useContext(BlockIdContext);
|
|
9
|
+
const defaultEvent = useMemo(() => name
|
|
10
|
+
? {
|
|
11
|
+
name,
|
|
12
|
+
context,
|
|
13
|
+
type: PredefinedEventTypes.Default,
|
|
14
|
+
target: target,
|
|
15
|
+
}
|
|
16
|
+
: undefined, [context, name, target]);
|
|
17
|
+
if (!sendEvents) {
|
|
18
|
+
return memoize(() => { });
|
|
19
|
+
}
|
|
20
|
+
const defaultEvents = defaultEvent && autoEvents ? [defaultEvent] : [];
|
|
21
|
+
return memoize((e) => {
|
|
22
|
+
let events = defaultEvents;
|
|
23
|
+
if (e) {
|
|
24
|
+
events = Array.isArray(e) ? [...events, ...e] : [...events, e];
|
|
25
|
+
}
|
|
26
|
+
if (!events) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
sendEvents(events);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { ButtonPixel, MetrikaGoal, PixelEvent } from '../models';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Metrika will be deleted
|
|
4
|
+
*/
|
|
2
5
|
type UseMetrikaProps = {
|
|
3
6
|
metrikaGoals?: MetrikaGoal;
|
|
4
7
|
pixelEvents?: string | string[] | PixelEvent | PixelEvent[] | ButtonPixel;
|
|
5
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated useMetrika will be deleted
|
|
11
|
+
*/
|
|
6
12
|
export declare const useMetrika: () => ({ metrikaGoals, pixelEvents }: UseMetrikaProps) => void;
|
|
7
13
|
export {};
|
|
@@ -2,12 +2,20 @@ import { useContext } from 'react';
|
|
|
2
2
|
import { MetrikaContext } from '../context/metrikaContext';
|
|
3
3
|
import { PixelEventType } from '../models';
|
|
4
4
|
import { isNewMetrikaFormat } from '../models/guards';
|
|
5
|
+
// eslint-disable-next-line valid-jsdoc
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Metrika will be deleted, which uses this logic
|
|
8
|
+
*/
|
|
5
9
|
function isButtonPixel(pixelEvents) {
|
|
6
10
|
if (Array.isArray(pixelEvents) && pixelEvents.length && 'name' in pixelEvents) {
|
|
7
11
|
return true;
|
|
8
12
|
}
|
|
9
13
|
return false;
|
|
10
14
|
}
|
|
15
|
+
// eslint-disable-next-line valid-jsdoc
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated useMetrika will be deleted
|
|
18
|
+
*/
|
|
11
19
|
export const useMetrika = () => {
|
|
12
20
|
const { metrika, pixel } = useContext(MetrikaContext);
|
|
13
21
|
return ({ metrikaGoals, pixelEvents }) => {
|
|
@@ -7,12 +7,21 @@ export declare enum Theme {
|
|
|
7
7
|
Light = "light",
|
|
8
8
|
Dark = "dark"
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Pixel will be deleted
|
|
12
|
+
*/
|
|
10
13
|
type PixelCommand = 'track' | 'trackCustom';
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Pixel will be deleted
|
|
16
|
+
*/
|
|
11
17
|
export interface PixelEvent {
|
|
12
18
|
command: PixelCommand;
|
|
13
19
|
event: PixelEventType | string;
|
|
14
20
|
data?: Object;
|
|
15
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated Pixel will be deleted from package
|
|
24
|
+
*/
|
|
16
25
|
export declare enum PixelEventType {
|
|
17
26
|
AddPaymentInfo = "AddPaymentInfo",
|
|
18
27
|
AddToCart = "AddToCart",
|
|
@@ -36,11 +45,17 @@ export declare enum PixelEventType {
|
|
|
36
45
|
export type Modifiers = {
|
|
37
46
|
[name: string]: string | boolean | undefined;
|
|
38
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated Pixel will be deleted
|
|
50
|
+
*/
|
|
39
51
|
export interface Pixel<TEvent = string> {
|
|
40
52
|
trackStandard: (event: TEvent, data?: Object) => void;
|
|
41
53
|
trackCustom: (event: string, data?: Object) => void;
|
|
42
54
|
track: (trackEvents: string | string[] | PixelEvent[] | PixelEvent) => void;
|
|
43
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated Metrika will be deleted
|
|
58
|
+
*/
|
|
44
59
|
export interface Metrika {
|
|
45
60
|
reachGoal: (counterName: string, ...args: any) => void;
|
|
46
61
|
reachGoals: (goals: MetrikaGoal, counterName?: string) => void;
|
|
@@ -49,4 +64,34 @@ export interface ClassNameProps {
|
|
|
49
64
|
className?: string;
|
|
50
65
|
}
|
|
51
66
|
export type Timeout = ReturnType<typeof setTimeout> | undefined;
|
|
67
|
+
export declare enum PredefinedEventTypes {
|
|
68
|
+
Default = "default-event",
|
|
69
|
+
Play = "play",
|
|
70
|
+
Stop = "stop"
|
|
71
|
+
}
|
|
72
|
+
export declare enum DefaultEventNames {
|
|
73
|
+
ShareButton = "share-button-click",
|
|
74
|
+
Button = "button-click",
|
|
75
|
+
CardBase = "card-base-click",
|
|
76
|
+
Link = "link-click",
|
|
77
|
+
ReactPlayerControls = "react-player-controls-click",
|
|
78
|
+
YandexFormSubmit = "yandex-form-submit",
|
|
79
|
+
HubspotFormSubmit = "hubspot-form-submit",
|
|
80
|
+
QuoteButton = "quote-button-click",
|
|
81
|
+
BackLink = "back-link-click"
|
|
82
|
+
}
|
|
83
|
+
export type AnalyticsCounters = {
|
|
84
|
+
include?: string[];
|
|
85
|
+
exclude?: string[];
|
|
86
|
+
};
|
|
87
|
+
export type AnalyticsEvent<T = {}> = T & {
|
|
88
|
+
name: string;
|
|
89
|
+
type?: string;
|
|
90
|
+
counters?: AnalyticsCounters;
|
|
91
|
+
context?: string;
|
|
92
|
+
target?: string;
|
|
93
|
+
};
|
|
94
|
+
export interface AnalyticsEventsBase {
|
|
95
|
+
analyticsEvents?: AnalyticsEvent | AnalyticsEvent[];
|
|
96
|
+
}
|
|
52
97
|
export {};
|
|
@@ -3,6 +3,9 @@ export var Theme;
|
|
|
3
3
|
Theme["Light"] = "light";
|
|
4
4
|
Theme["Dark"] = "dark";
|
|
5
5
|
})(Theme || (Theme = {}));
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Pixel will be deleted from package
|
|
8
|
+
*/
|
|
6
9
|
export var PixelEventType;
|
|
7
10
|
(function (PixelEventType) {
|
|
8
11
|
PixelEventType["AddPaymentInfo"] = "AddPaymentInfo";
|
|
@@ -24,3 +27,21 @@ export var PixelEventType;
|
|
|
24
27
|
PixelEventType["Subscribe"] = "Subscribe";
|
|
25
28
|
PixelEventType["ViewContent"] = "ViewContent";
|
|
26
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 = {}));
|
|
36
|
+
export var DefaultEventNames;
|
|
37
|
+
(function (DefaultEventNames) {
|
|
38
|
+
DefaultEventNames["ShareButton"] = "share-button-click";
|
|
39
|
+
DefaultEventNames["Button"] = "button-click";
|
|
40
|
+
DefaultEventNames["CardBase"] = "card-base-click";
|
|
41
|
+
DefaultEventNames["Link"] = "link-click";
|
|
42
|
+
DefaultEventNames["ReactPlayerControls"] = "react-player-controls-click";
|
|
43
|
+
DefaultEventNames["YandexFormSubmit"] = "yandex-form-submit";
|
|
44
|
+
DefaultEventNames["HubspotFormSubmit"] = "hubspot-form-submit";
|
|
45
|
+
DefaultEventNames["QuoteButton"] = "quote-button-click";
|
|
46
|
+
DefaultEventNames["BackLink"] = "back-link-click";
|
|
47
|
+
})(DefaultEventNames || (DefaultEventNames = {}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import { ButtonSize, ButtonView } from '@gravity-ui/uikit';
|
|
3
3
|
import { ThemeSupporting } from '../../utils/theme';
|
|
4
|
-
import { ClassNameProps, PixelEventType } from '../common';
|
|
4
|
+
import { AnalyticsEventsBase, ClassNameProps, PixelEventType } from '../common';
|
|
5
5
|
export declare enum AuthorType {
|
|
6
6
|
Column = "column",
|
|
7
7
|
Line = "line"
|
|
@@ -100,7 +100,7 @@ export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement>, P
|
|
|
100
100
|
imageClassName?: string;
|
|
101
101
|
hide?: boolean;
|
|
102
102
|
}
|
|
103
|
-
export interface MediaVideoProps {
|
|
103
|
+
export interface MediaVideoProps extends AnalyticsEventsBase {
|
|
104
104
|
src: string[];
|
|
105
105
|
type?: MediaVideoType;
|
|
106
106
|
loop?: LoopProps | boolean;
|
|
@@ -111,7 +111,7 @@ export interface MediaVideoProps {
|
|
|
111
111
|
controls?: MediaVideoControlsType;
|
|
112
112
|
metrika?: MetrikaVideo;
|
|
113
113
|
}
|
|
114
|
-
export interface LinkProps extends Stylable {
|
|
114
|
+
export interface LinkProps extends AnalyticsEventsBase, Stylable {
|
|
115
115
|
url: string;
|
|
116
116
|
text?: string;
|
|
117
117
|
textSize?: TextSize;
|
|
@@ -130,7 +130,7 @@ export interface FileLinkProps extends ClassNameProps {
|
|
|
130
130
|
theme?: ContentTheme;
|
|
131
131
|
onClick?: () => void;
|
|
132
132
|
}
|
|
133
|
-
export interface ButtonProps {
|
|
133
|
+
export interface ButtonProps extends AnalyticsEventsBase {
|
|
134
134
|
text: string;
|
|
135
135
|
url: string;
|
|
136
136
|
primary?: boolean;
|
|
@@ -163,7 +163,7 @@ export interface MediaVideoProps {
|
|
|
163
163
|
metrika?: MetrikaVideo;
|
|
164
164
|
}
|
|
165
165
|
export type ThemedMediaVideoProps = ThemeSupporting<MediaVideoProps>;
|
|
166
|
-
export interface MediaComponentVideoProps {
|
|
166
|
+
export interface MediaComponentVideoProps extends AnalyticsEventsBase {
|
|
167
167
|
video: MediaVideoProps;
|
|
168
168
|
height?: number;
|
|
169
169
|
metrika?: MetrikaVideo;
|
|
@@ -3,7 +3,7 @@ import { ThemeSupporting } from '../../utils';
|
|
|
3
3
|
import { HubspotEventData, HubspotEventHandlers } from '../../utils/hubspot';
|
|
4
4
|
import { AuthorItem, ButtonPixel, ButtonProps, CardBaseProps, ContentTheme, DividerSize, ImageObjectProps, ImageProps, LinkProps, MediaProps, PriceDetailedProps, TextTheme, Themable, ThemedImage } from './common';
|
|
5
5
|
import { ContentBlockProps } from './blocks';
|
|
6
|
-
import { PixelEvent } from '../common';
|
|
6
|
+
import { AnalyticsEventsBase, PixelEvent } from '../common';
|
|
7
7
|
export declare enum SubBlockType {
|
|
8
8
|
Divider = "divider",
|
|
9
9
|
Quote = "quote",
|
|
@@ -38,7 +38,7 @@ export interface DividerProps {
|
|
|
38
38
|
size?: DividerSize;
|
|
39
39
|
border?: boolean;
|
|
40
40
|
}
|
|
41
|
-
export interface HubspotFormProps extends HubspotEventHandlers {
|
|
41
|
+
export interface HubspotFormProps extends HubspotEventHandlers, AnalyticsEventsBase {
|
|
42
42
|
className?: string;
|
|
43
43
|
theme?: ContentTheme;
|
|
44
44
|
isMobile?: boolean;
|
|
@@ -4,19 +4,13 @@ export declare enum NavigationItemType {
|
|
|
4
4
|
Link = "link",
|
|
5
5
|
Dropdown = "dropdown",
|
|
6
6
|
Button = "button",
|
|
7
|
-
Social = "social"
|
|
8
|
-
GithubStars = "github-stars"
|
|
7
|
+
Social = "social"
|
|
9
8
|
}
|
|
10
9
|
export interface NavigationItemBase {
|
|
11
10
|
text: string;
|
|
12
11
|
icon?: ImageProps;
|
|
13
12
|
url?: string;
|
|
14
13
|
}
|
|
15
|
-
export interface NavigationGithubButton extends Omit<NavigationItemBase, 'icon'> {
|
|
16
|
-
type: NavigationItemType.GithubStars;
|
|
17
|
-
url: string;
|
|
18
|
-
label?: string;
|
|
19
|
-
}
|
|
20
14
|
export interface NavigationLinkItem extends Omit<NavigationItemBase, 'url'> {
|
|
21
15
|
type: NavigationItemType.Link;
|
|
22
16
|
url: string;
|
|
@@ -35,8 +29,8 @@ export interface NavigationSocialItem extends Omit<NavigationItemBase, 'text'> {
|
|
|
35
29
|
icon: ImageProps;
|
|
36
30
|
url: string;
|
|
37
31
|
}
|
|
38
|
-
export type NavigationItemModel = NavigationLinkItem | NavigationButtonItem | NavigationDropdownItem
|
|
39
|
-
export type NavigationItemData = NavigationLinkItem | NavigationButtonItem | NavigationSocialItem | DropdownItemData
|
|
32
|
+
export type NavigationItemModel = NavigationLinkItem | NavigationButtonItem | NavigationDropdownItem;
|
|
33
|
+
export type NavigationItemData = NavigationLinkItem | NavigationButtonItem | NavigationSocialItem | DropdownItemData;
|
|
40
34
|
export type DropdownItemData = Omit<NavigationDropdownItem, 'items'>;
|
|
41
35
|
export interface NavigationLogoData {
|
|
42
36
|
icon: ImageProps;
|
|
@@ -2,10 +2,11 @@ import { __rest } from "tslib";
|
|
|
2
2
|
import React, { useMemo } from 'react';
|
|
3
3
|
import { NavigationItemType } from '../../../models';
|
|
4
4
|
import SocialIcon from '../SocialIcon/SocialIcon';
|
|
5
|
+
import { BlockIdContext } from '../../../context/blockIdContext';
|
|
5
6
|
import { NavigationButton } from './components/NavigationButton/NavigationButton';
|
|
6
7
|
import { NavigationDropdown } from './components/NavigationDropdown/NavigationDropdown';
|
|
7
8
|
import { NavigationLink } from './components/NavigationLink/NavigationLink';
|
|
8
|
-
|
|
9
|
+
const ANALYTICS_ID = 'navigation';
|
|
9
10
|
//todo: add types support form component in map
|
|
10
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
12
|
const NavigationItemsMap = {
|
|
@@ -13,13 +14,13 @@ const NavigationItemsMap = {
|
|
|
13
14
|
[NavigationItemType.Social]: SocialIcon,
|
|
14
15
|
[NavigationItemType.Dropdown]: NavigationDropdown,
|
|
15
16
|
[NavigationItemType.Link]: NavigationLink,
|
|
16
|
-
[NavigationItemType.GithubStars]: GithubStars,
|
|
17
17
|
};
|
|
18
18
|
const NavigationItem = (_a) => {
|
|
19
19
|
var { data, className } = _a, props = __rest(_a, ["data", "className"]);
|
|
20
20
|
const { type = NavigationItemType.Link } = data;
|
|
21
21
|
const Component = NavigationItemsMap[type];
|
|
22
22
|
const componentProps = useMemo(() => (Object.assign(Object.assign({ className }, data), props)), [className, data, props]);
|
|
23
|
-
return React.createElement(
|
|
23
|
+
return (React.createElement(BlockIdContext.Provider, { value: ANALYTICS_ID },
|
|
24
|
+
React.createElement(Component, Object.assign({}, componentProps))));
|
|
24
25
|
};
|
|
25
26
|
export default NavigationItem;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { block } from '../../../../../utils';
|
|
3
3
|
import { RouterLink, Button } from '../../../../../components';
|
|
4
|
+
import { BlockIdContext } from '../../../../../context/blockIdContext';
|
|
4
5
|
import './NavigationButton.css';
|
|
5
6
|
const b = block('navigation-button');
|
|
7
|
+
const ANALYTICS_ID = 'navigation';
|
|
6
8
|
export const NavigationButton = (props) => {
|
|
7
9
|
const { url, target, className } = props;
|
|
8
10
|
const classes = b(null, className);
|
|
9
|
-
return target ? (React.createElement(Button, Object.assign({ className: classes }, props, { url: url }))) : (React.createElement(RouterLink, { href: url },
|
|
10
|
-
React.createElement(Button, Object.assign({}, props, { className: classes, url: url }))));
|
|
11
|
+
return (React.createElement(BlockIdContext.Provider, { value: ANALYTICS_ID }, target ? (React.createElement(Button, Object.assign({ className: classes }, props, { url: url }))) : (React.createElement(RouterLink, { href: url },
|
|
12
|
+
React.createElement(Button, Object.assign({}, props, { className: classes, url: url }))))));
|
|
11
13
|
};
|