@gravity-ui/page-constructor 1.15.0-alpha.23 → 1.15.0-alpha.25
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 +0 -20
- package/build/cjs/blocks/Share/Share.js +1 -8
- package/build/cjs/components/BackLink/BackLink.js +1 -9
- package/build/cjs/components/Button/Button.d.ts +0 -1
- package/build/cjs/components/Button/Button.js +1 -10
- package/build/cjs/components/CardBase/CardBase.js +1 -9
- package/build/cjs/components/Link/Link.js +1 -9
- package/build/cjs/components/ReactPlayer/ReactPlayer.js +2 -9
- package/build/cjs/components/YandexForm/YandexForm.js +1 -8
- package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +6 -4
- package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +1 -2
- package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +2 -4
- package/build/cjs/context/blockIdContext/blockIdContext.d.ts +3 -0
- package/build/cjs/context/{blockPositionContext/blockPositionContext.js → blockIdContext/blockIdContext.js} +2 -2
- package/build/cjs/context/blockIdContext/index.d.ts +1 -0
- package/build/cjs/context/{blockPositionContext → blockIdContext}/index.js +1 -1
- package/build/cjs/hooks/useAnalytics.d.ts +1 -1
- package/build/cjs/hooks/useAnalytics.js +12 -1
- package/build/cjs/models/common.d.ts +11 -0
- package/build/cjs/models/common.js +13 -1
- package/build/cjs/models/constructor-items/common.d.ts +0 -2
- package/build/cjs/navigation/components/NavigationItem/NavigationItem.js +4 -5
- package/build/cjs/sub-blocks/HubspotForm/index.js +1 -8
- package/build/cjs/sub-blocks/LayoutItem/utils.d.ts +0 -1
- package/build/cjs/sub-blocks/Quote/Quote.js +1 -9
- package/build/cjs/utils/analytics.d.ts +2 -0
- package/build/cjs/utils/analytics.js +17 -0
- package/build/cjs/utils/blocks.d.ts +0 -7
- package/build/cjs/utils/blocks.js +1 -5
- package/build/cjs/utils/index.d.ts +1 -0
- package/build/cjs/utils/index.js +1 -0
- package/build/esm/blocks/Share/Share.js +3 -10
- package/build/esm/components/BackLink/BackLink.js +2 -10
- package/build/esm/components/Button/Button.d.ts +0 -1
- package/build/esm/components/Button/Button.js +3 -12
- package/build/esm/components/CardBase/CardBase.js +3 -11
- package/build/esm/components/Link/Link.js +3 -11
- package/build/esm/components/ReactPlayer/ReactPlayer.js +3 -10
- package/build/esm/components/YandexForm/YandexForm.js +3 -10
- package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +7 -5
- package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +1 -2
- package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +2 -4
- 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/hooks/useAnalytics.d.ts +1 -1
- package/build/esm/hooks/useAnalytics.js +13 -2
- package/build/esm/models/common.d.ts +11 -0
- package/build/esm/models/common.js +12 -0
- package/build/esm/models/constructor-items/common.d.ts +0 -2
- package/build/esm/navigation/components/NavigationItem/NavigationItem.js +4 -5
- package/build/esm/sub-blocks/HubspotForm/index.js +2 -9
- package/build/esm/sub-blocks/LayoutItem/utils.d.ts +0 -1
- package/build/esm/sub-blocks/Quote/Quote.js +3 -11
- package/build/esm/utils/analytics.d.ts +2 -0
- package/build/esm/utils/analytics.js +13 -0
- package/build/esm/utils/blocks.d.ts +0 -7
- package/build/esm/utils/blocks.js +0 -3
- package/build/esm/utils/index.d.ts +1 -0
- package/build/esm/utils/index.js +1 -0
- package/package.json +1 -1
- package/server/models/common.d.ts +11 -0
- package/server/models/common.js +13 -1
- package/server/models/constructor-items/common.d.ts +0 -2
- package/server/utils/analytics.d.ts +2 -0
- package/server/utils/analytics.js +17 -0
- package/server/utils/blocks.d.ts +0 -7
- package/server/utils/blocks.js +1 -5
- package/server/utils/index.d.ts +1 -0
- package/server/utils/index.js +1 -0
- package/build/cjs/context/blockPositionContext/blockPositionContext.d.ts +0 -3
- package/build/cjs/context/blockPositionContext/index.d.ts +0 -1
- package/build/esm/context/blockPositionContext/blockPositionContext.d.ts +0 -3
- package/build/esm/context/blockPositionContext/blockPositionContext.js +0 -2
- package/build/esm/context/blockPositionContext/index.d.ts +0 -1
- package/build/esm/context/blockPositionContext/index.js +0 -1
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import React, { useCallback, useContext
|
|
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 {
|
|
5
|
+
import { DefaultEventNames } from '../../models';
|
|
6
6
|
import { toCommonSize, toCommonView } from './utils';
|
|
7
7
|
import { LocaleContext } from '../../context/localeContext/localeContext';
|
|
8
|
-
import { BlockPositionContext } from '../../context/blockPositionContext';
|
|
9
8
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
10
9
|
import { useAnalytics } from '../../hooks';
|
|
11
10
|
import { Github } from '../../icons';
|
|
12
11
|
import './Button.css';
|
|
13
|
-
const COMPONENT_NAME = 'button';
|
|
14
12
|
const b = block('button-block');
|
|
15
13
|
const Button = (props) => {
|
|
16
14
|
const handleMetrika = useMetrika();
|
|
17
15
|
const { lang, tld } = useContext(LocaleContext);
|
|
18
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"]);
|
|
19
|
-
const context = useContext(BlockPositionContext);
|
|
20
17
|
const defaultImgPosition = 'left';
|
|
21
|
-
const
|
|
22
|
-
name: 'button-click',
|
|
23
|
-
type: PredefinedEventTypes.Default,
|
|
24
|
-
context: context || COMPONENT_NAME,
|
|
25
|
-
target: url,
|
|
26
|
-
}), [context, url]);
|
|
27
|
-
const handleAnalytics = useAnalytics(defaultEvent);
|
|
18
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.Button, url);
|
|
28
19
|
const onClick = useCallback(() => {
|
|
29
20
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
30
21
|
handleAnalytics(analyticsEvents);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import React, { Children, Fragment
|
|
1
|
+
import React, { Children, Fragment } from 'react';
|
|
2
2
|
import { block } from '../../utils';
|
|
3
|
-
import { BlockPositionContext } from '../../context/blockPositionContext';
|
|
4
3
|
import BackgroundImage from '../BackgroundImage/BackgroundImage';
|
|
5
4
|
import RouterLink from '../RouterLink/RouterLink';
|
|
6
5
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
7
|
-
import {
|
|
6
|
+
import { DefaultEventNames } from '../../models/common';
|
|
8
7
|
import { useAnalytics } from '../../hooks';
|
|
9
8
|
import './CardBase.css';
|
|
10
9
|
const b = block('card-base-block');
|
|
@@ -14,14 +13,7 @@ const Footer = () => null;
|
|
|
14
13
|
export const Layout = (props) => {
|
|
15
14
|
const { className, bodyClassName, metrikaGoals, pixelEvents, analyticsEvents, contentClassName, children, url, target, border = 'shadow', } = props;
|
|
16
15
|
const handleMetrika = useMetrika();
|
|
17
|
-
const
|
|
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
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.CardBase, url);
|
|
25
17
|
let header, content, footer, image, headerClass, footerClass;
|
|
26
18
|
function handleChild(child) {
|
|
27
19
|
switch (child.type) {
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import React, { Fragment, useContext
|
|
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 {
|
|
4
|
+
import { DefaultEventNames } from '../../models';
|
|
5
5
|
import { Chevron } from '../../icons';
|
|
6
6
|
import FileLink from '../FileLink/FileLink';
|
|
7
7
|
import BackLink from '../BackLink/BackLink';
|
|
8
8
|
import { LocaleContext } from '../../context/localeContext/localeContext';
|
|
9
9
|
import { LocationContext } from '../../context/locationContext/locationContext';
|
|
10
|
-
import { BlockPositionContext } from '../../context/blockPositionContext';
|
|
11
10
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
12
11
|
import { useAnalytics } from '../../hooks';
|
|
13
12
|
import './Link.css';
|
|
@@ -28,14 +27,7 @@ function getArrowSize(size) {
|
|
|
28
27
|
const LinkBlock = (props) => {
|
|
29
28
|
const { text, url, arrow, metrikaGoals, pixelEvents, analyticsEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, } = props;
|
|
30
29
|
const handleMetrika = useMetrika();
|
|
31
|
-
const
|
|
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
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.Link, url);
|
|
39
31
|
const { hostname } = useContext(LocationContext);
|
|
40
32
|
const { tld } = useContext(LocaleContext);
|
|
41
33
|
const href = setUrlTld(props.url, tld);
|
|
@@ -3,14 +3,13 @@ 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, PredefinedEventTypes, } from '../../models';
|
|
6
|
+
import { PlayButtonThemes, PlayButtonType, MediaVideoControlsType, PredefinedEventTypes, DefaultEventNames, } 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';
|
|
12
|
-
import { PlayVideo } from '../../icons';
|
|
13
11
|
import { useAnalytics } from '../../hooks';
|
|
12
|
+
import { PlayVideo } from '../../icons';
|
|
14
13
|
import './ReactPlayer.css';
|
|
15
14
|
const b = block('ReactPlayer');
|
|
16
15
|
const FPS = 60;
|
|
@@ -39,13 +38,7 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
39
38
|
}
|
|
40
39
|
return [];
|
|
41
40
|
}, [analyticsEvents]);
|
|
42
|
-
const
|
|
43
|
-
const defaultEvent = useMemo(() => ({
|
|
44
|
-
name: 'react-player-controls-click',
|
|
45
|
-
type: PredefinedEventTypes.Default,
|
|
46
|
-
context,
|
|
47
|
-
}), [context]);
|
|
48
|
-
const handleAnalytics = useAnalytics(defaultEvent);
|
|
41
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.ReactPlayerControls);
|
|
49
42
|
useImperativeHandle(originRef, () => ({
|
|
50
43
|
pause: () => setIsPlaying(false),
|
|
51
44
|
}));
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import React, { useCallback, useContext, useEffect,
|
|
1
|
+
import React, { useCallback, useContext, useEffect, 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
|
-
import { BlockPositionContext } from '../../context/blockPositionContext';
|
|
6
5
|
import { block } from '../../utils';
|
|
7
|
-
import {
|
|
6
|
+
import { DefaultEventNames } from '../../models/common';
|
|
8
7
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
9
8
|
import { useAnalytics } from '../../hooks';
|
|
10
9
|
export const YANDEX_FORM_ORIGIN = 'https://forms.yandex.ru';
|
|
@@ -16,13 +15,7 @@ const YandexForm = (props) => {
|
|
|
16
15
|
const iframeRef = useRef();
|
|
17
16
|
const yaFormOrigin = customFormOrigin || YANDEX_FORM_ORIGIN;
|
|
18
17
|
const handleMetrika = useMetrika();
|
|
19
|
-
const
|
|
20
|
-
const defaultEvent = useMemo(() => ({
|
|
21
|
-
name: 'yndex-form-submit',
|
|
22
|
-
type: PredefinedEventTypes.Default,
|
|
23
|
-
context: context,
|
|
24
|
-
}), [context]);
|
|
25
|
-
const handleAnalytics = useAnalytics(defaultEvent);
|
|
18
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.YandexFormSubmit);
|
|
26
19
|
const isMobile = useContext(MobileContext);
|
|
27
20
|
const locale = useContext(LocaleContext);
|
|
28
21
|
const updateFormIframe = useCallback((container) => {
|
package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import React, { Fragment, useContext } from 'react';
|
|
3
|
-
import {
|
|
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 = (
|
|
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);
|
|
17
|
-
const
|
|
18
|
+
const blockId = parentId ? `${parentId}_${key}` : key;
|
|
18
19
|
if (shouldRenderBlock && !shouldRenderBlock(item, key)) {
|
|
19
20
|
return null;
|
|
20
21
|
}
|
|
@@ -28,9 +29,10 @@ export const ConstructorBlocks = ({ items, shouldRenderBlock }) => {
|
|
|
28
29
|
}
|
|
29
30
|
else {
|
|
30
31
|
if ('children' in item && item.children) {
|
|
31
|
-
children = item.children.map(renderer.bind(null,
|
|
32
|
+
children = item.children.map(renderer.bind(null, blockId));
|
|
32
33
|
}
|
|
33
|
-
itemElement = (React.createElement(
|
|
34
|
+
itemElement = (React.createElement(BlockIdContext.Provider, { value: blockId },
|
|
35
|
+
React.createElement(ConstructorItem, { data: item, key: key }, children)));
|
|
34
36
|
}
|
|
35
37
|
return blockTypes.includes(item.type) ? (React.createElement(ConstructorBlock, { data: item, key: key, Component: itemElement })) : (itemElement);
|
|
36
38
|
};
|
package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ConstructorItem as ConstructorItemType, WithChildren } from '../../../../models';
|
|
2
2
|
export interface ConstructorItemProps {
|
|
3
3
|
data: ConstructorItemType;
|
|
4
|
-
context?: string;
|
|
5
4
|
}
|
|
6
|
-
export declare const ConstructorItem: ({ data, children
|
|
5
|
+
export declare const ConstructorItem: ({ data, children }: WithChildren<ConstructorItemProps>) => JSX.Element;
|
|
7
6
|
export declare const ConstructorHeader: ({ data }: Pick<ConstructorItemProps, 'data'>) => JSX.Element;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
3
|
import { InnerContext } from '../../../../context/innerContext';
|
|
4
|
-
|
|
5
|
-
export const ConstructorItem = ({ data, children, context }) => {
|
|
4
|
+
export const ConstructorItem = ({ data, children }) => {
|
|
6
5
|
const { itemMap } = useContext(InnerContext);
|
|
7
6
|
const { type } = data, rest = __rest(data, ["type"]);
|
|
8
7
|
const Component = itemMap[type];
|
|
9
|
-
return
|
|
10
|
-
React.createElement(Component, Object.assign({}, rest), children)));
|
|
8
|
+
return React.createElement(Component, Object.assign({}, rest), children);
|
|
11
9
|
};
|
|
12
10
|
export const ConstructorHeader = ({ data }) => (React.createElement(ConstructorItem, { data: data, key: data.type }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './blockIdContext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './blockIdContext';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AnalyticsEvent } from '../models';
|
|
2
|
-
export declare const useAnalytics: (
|
|
2
|
+
export declare const useAnalytics: (name?: string, target?: string) => ((e?: AnalyticsEvent | AnalyticsEvent[]) => void) & import("lodash").MemoizedFunction;
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { memoize } from 'lodash';
|
|
2
|
-
import { useContext } from 'react';
|
|
2
|
+
import { useContext, useMemo } from 'react';
|
|
3
|
+
import { BlockIdContext } from '../context/blockIdContext';
|
|
3
4
|
import { AnalyticsContext } from '../context/analyticsContext';
|
|
4
|
-
|
|
5
|
+
import { PredefinedEventTypes } from '../models';
|
|
6
|
+
export const useAnalytics = (name = '', target) => {
|
|
5
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]);
|
|
6
17
|
if (!sendEvents) {
|
|
7
18
|
return memoize(() => { });
|
|
8
19
|
}
|
|
@@ -69,6 +69,17 @@ export declare enum PredefinedEventTypes {
|
|
|
69
69
|
Play = "play",
|
|
70
70
|
Stop = "stop"
|
|
71
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
|
+
}
|
|
72
83
|
export type AnalyticsCounters = {
|
|
73
84
|
include?: string[];
|
|
74
85
|
exclude?: string[];
|
|
@@ -33,3 +33,15 @@ export var PredefinedEventTypes;
|
|
|
33
33
|
PredefinedEventTypes["Play"] = "play";
|
|
34
34
|
PredefinedEventTypes["Stop"] = "stop";
|
|
35
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 = {}));
|
|
@@ -121,7 +121,6 @@ export interface LinkProps extends AnalyticsEventsBase, Stylable {
|
|
|
121
121
|
target?: string;
|
|
122
122
|
metrikaGoals?: MetrikaGoal;
|
|
123
123
|
pixelEvents?: ButtonPixel;
|
|
124
|
-
context?: string;
|
|
125
124
|
}
|
|
126
125
|
export interface FileLinkProps extends ClassNameProps {
|
|
127
126
|
href: string;
|
|
@@ -141,7 +140,6 @@ export interface ButtonProps extends AnalyticsEventsBase {
|
|
|
141
140
|
metrikaGoals?: MetrikaGoal;
|
|
142
141
|
pixelEvents?: ButtonPixel;
|
|
143
142
|
target?: string;
|
|
144
|
-
context?: string;
|
|
145
143
|
}
|
|
146
144
|
export interface ButtonImageProps {
|
|
147
145
|
url: string;
|
|
@@ -7,8 +7,10 @@ import { NavigationItemType, } from '../../../models';
|
|
|
7
7
|
import { NavigationArrow } from '../../../icons';
|
|
8
8
|
import SocialIcon from '../SocialIcon/SocialIcon';
|
|
9
9
|
import { getMediaImage } from '../../../components/Media/Image/utils';
|
|
10
|
+
import { BlockIdContext } from '../../../context/blockIdContext';
|
|
10
11
|
import './NavigationItem.css';
|
|
11
12
|
const b = block('navigation-item');
|
|
13
|
+
const ANALYTICS_ID = 'navigation';
|
|
12
14
|
const Content = ({ text, icon }) => (React.createElement(Fragment, null,
|
|
13
15
|
icon && typeof icon !== 'string' && React.createElement(Image, Object.assign({ className: b('icon') }, icon)),
|
|
14
16
|
React.createElement("span", { className: b('text') }, text)));
|
|
@@ -37,11 +39,8 @@ const NavigationLink = (props) => {
|
|
|
37
39
|
};
|
|
38
40
|
const NavigationButton = (props) => {
|
|
39
41
|
const { url, target } = props;
|
|
40
|
-
return target ? (
|
|
41
|
-
|
|
42
|
-
// <Button {...props} url={url} context={BLOCK_NAME} />
|
|
43
|
-
React.createElement(Button, Object.assign({}, props, { url: url }))) : (React.createElement(RouterLink, { href: url },
|
|
44
|
-
React.createElement(Button, Object.assign({}, props, { url: url }))));
|
|
42
|
+
return (React.createElement(BlockIdContext.Provider, { value: ANALYTICS_ID }, target ? (React.createElement(Button, Object.assign({}, props, { url: url }))) : (React.createElement(RouterLink, { href: url },
|
|
43
|
+
React.createElement(Button, Object.assign({}, props, { url: url }))))));
|
|
45
44
|
};
|
|
46
45
|
//todo: add types support form component in map
|
|
47
46
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -2,9 +2,8 @@ import React, { useContext, useMemo } from 'react';
|
|
|
2
2
|
import { block } from '../../utils';
|
|
3
3
|
import { ThemeValueContext } from '../../context/theme/ThemeValueContext';
|
|
4
4
|
import { MobileContext } from '../../context/mobileContext';
|
|
5
|
-
import { BlockPositionContext } from '../../context/blockPositionContext';
|
|
6
5
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
7
|
-
import {
|
|
6
|
+
import { DefaultEventNames } from '../../models';
|
|
8
7
|
import { useHandleHubspotEvents, useAnalytics } from '../../hooks';
|
|
9
8
|
import HubspotFormContainer from './HubspotFormContainer';
|
|
10
9
|
import './HubspotForm.css';
|
|
@@ -14,13 +13,7 @@ const HubspotForm = (props) => {
|
|
|
14
13
|
// hubspotEvents, // TODO: decide how to handle them
|
|
15
14
|
analyticsEvents, onBeforeSubmit, onSubmit, onBeforeLoad, onLoad, createDOMElement, onSubmitError, } = props;
|
|
16
15
|
const handleMetrika = useMetrika();
|
|
17
|
-
const
|
|
18
|
-
const defaultEvent = useMemo(() => ({
|
|
19
|
-
name: 'hubspot-form-submit',
|
|
20
|
-
type: PredefinedEventTypes.Default,
|
|
21
|
-
context,
|
|
22
|
-
}), [context]);
|
|
23
|
-
const handleAnalytics = useAnalytics(defaultEvent);
|
|
16
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.HubspotFormSubmit);
|
|
24
17
|
const { themeValue } = useContext(ThemeValueContext);
|
|
25
18
|
const isMobileValue = useContext(MobileContext);
|
|
26
19
|
const theme = themeProp !== null && themeProp !== void 0 ? themeProp : themeValue;
|
|
@@ -9,7 +9,6 @@ export declare const getLayoutItemLinks: (links: LayoutItemProps['content']['lin
|
|
|
9
9
|
target?: string | undefined;
|
|
10
10
|
metrikaGoals?: import("../../models").MetrikaGoal | undefined;
|
|
11
11
|
pixelEvents?: import("../../models").ButtonPixel | undefined;
|
|
12
|
-
context?: string | undefined;
|
|
13
12
|
analyticsEvents?: {
|
|
14
13
|
name: string;
|
|
15
14
|
type?: string | undefined;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import React, { useCallback, useContext
|
|
1
|
+
import React, { useCallback, useContext } from 'react';
|
|
2
2
|
import { Button } from '@gravity-ui/uikit';
|
|
3
3
|
import { block, getThemedValue } from '../../utils';
|
|
4
|
-
import { AuthorType,
|
|
4
|
+
import { AuthorType, DefaultEventNames } from '../../models';
|
|
5
5
|
import { Author, Image, HTML } from '../../components';
|
|
6
6
|
import { ThemeValueContext } from '../../context/theme/ThemeValueContext';
|
|
7
|
-
import { BlockPositionContext } from '../../context/blockPositionContext';
|
|
8
7
|
import { getMediaImage } from '../../components/Media/Image/utils';
|
|
9
8
|
import { useAnalytics } from '../../hooks';
|
|
10
9
|
import './Quote.css';
|
|
@@ -12,16 +11,9 @@ const b = block('quote');
|
|
|
12
11
|
const Quote = (props) => {
|
|
13
12
|
const { theme: textTheme = 'light', color, image, border = 'shadow', text, logo, author, url, buttonText, } = props;
|
|
14
13
|
const { themeValue: theme } = useContext(ThemeValueContext);
|
|
15
|
-
const context = useContext(BlockPositionContext);
|
|
16
14
|
const imageThemed = getThemedValue(image, theme);
|
|
17
15
|
const imageData = getMediaImage(imageThemed);
|
|
18
|
-
const
|
|
19
|
-
name: 'quote-button-click',
|
|
20
|
-
type: PredefinedEventTypes.Default,
|
|
21
|
-
context,
|
|
22
|
-
target: url,
|
|
23
|
-
}), [context, url]);
|
|
24
|
-
const handleAnalytics = useAnalytics(defaultEvent);
|
|
16
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.QuoteButton, url);
|
|
25
17
|
const handleButtonClick = useCallback(() => handleAnalytics(), [handleAnalytics]);
|
|
26
18
|
const renderFooter = Boolean(author || url) && (React.createElement("div", { className: b('author-wrapper') },
|
|
27
19
|
author && (React.createElement(Author, { className: b('author', { theme: textTheme }), author: author, type: AuthorType.Line })),
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const isCounterAllowed = (counter, counters) => {
|
|
2
|
+
var _a, _b;
|
|
3
|
+
if (!counters) {
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
if ((_a = counters.exclude) === null || _a === void 0 ? void 0 : _a.includes(counter)) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
else if ((_b = counters.include) === null || _b === void 0 ? void 0 : _b.includes(counter)) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
};
|
|
@@ -2,16 +2,9 @@ import { ConstructorBlock } from '../models/constructor';
|
|
|
2
2
|
import { TextSize, CustomConfig, PCShareSocialNetwork } from '../models';
|
|
3
3
|
export declare function getHeaderTag(size: TextSize): "h1" | "h4" | "h2";
|
|
4
4
|
export declare function getBlockKey(block: ConstructorBlock, index: number): string;
|
|
5
|
-
type GetBlockContextArgs = {
|
|
6
|
-
block: ConstructorBlock;
|
|
7
|
-
index: number;
|
|
8
|
-
parentContext?: string;
|
|
9
|
-
};
|
|
10
|
-
export declare function getBlockContext({ parentContext, block, index }: GetBlockContextArgs): string;
|
|
11
5
|
export declare const getCustomBlockTypes: ({ blocks, headers }?: CustomConfig) => string[];
|
|
12
6
|
export declare const getCustomItems: ({ blocks, headers, subBlocks }?: CustomConfig) => {
|
|
13
7
|
[x: string]: any;
|
|
14
8
|
};
|
|
15
9
|
export declare const getCustomHeaderTypes: (customBlocks?: CustomConfig) => string[];
|
|
16
10
|
export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string, text?: string) => string | undefined;
|
|
17
|
-
export {};
|
|
@@ -13,9 +13,6 @@ export function getHeaderTag(size) {
|
|
|
13
13
|
export function getBlockKey(block, index) {
|
|
14
14
|
return `${block.type}-${index}`;
|
|
15
15
|
}
|
|
16
|
-
export function getBlockContext({ parentContext = '', block, index }) {
|
|
17
|
-
return `${parentContext}${parentContext ? '_' : ''}${block.type}-${index}`;
|
|
18
|
-
}
|
|
19
16
|
export const getCustomBlockTypes = ({ blocks = {}, headers = {} } = {}) => [
|
|
20
17
|
...Object.keys(blocks),
|
|
21
18
|
...Object.keys(headers),
|
package/build/esm/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -69,6 +69,17 @@ export declare enum PredefinedEventTypes {
|
|
|
69
69
|
Play = "play",
|
|
70
70
|
Stop = "stop"
|
|
71
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
|
+
}
|
|
72
83
|
export type AnalyticsCounters = {
|
|
73
84
|
include?: string[];
|
|
74
85
|
exclude?: string[];
|
package/server/models/common.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PredefinedEventTypes = exports.PixelEventType = exports.Theme = void 0;
|
|
3
|
+
exports.DefaultEventNames = exports.PredefinedEventTypes = exports.PixelEventType = exports.Theme = void 0;
|
|
4
4
|
var Theme;
|
|
5
5
|
(function (Theme) {
|
|
6
6
|
Theme["Light"] = "light";
|
|
@@ -36,3 +36,15 @@ var PredefinedEventTypes;
|
|
|
36
36
|
PredefinedEventTypes["Play"] = "play";
|
|
37
37
|
PredefinedEventTypes["Stop"] = "stop";
|
|
38
38
|
})(PredefinedEventTypes = exports.PredefinedEventTypes || (exports.PredefinedEventTypes = {}));
|
|
39
|
+
var DefaultEventNames;
|
|
40
|
+
(function (DefaultEventNames) {
|
|
41
|
+
DefaultEventNames["ShareButton"] = "share-button-click";
|
|
42
|
+
DefaultEventNames["Button"] = "button-click";
|
|
43
|
+
DefaultEventNames["CardBase"] = "card-base-click";
|
|
44
|
+
DefaultEventNames["Link"] = "link-click";
|
|
45
|
+
DefaultEventNames["ReactPlayerControls"] = "react-player-controls-click";
|
|
46
|
+
DefaultEventNames["YandexFormSubmit"] = "yandex-form-submit";
|
|
47
|
+
DefaultEventNames["HubspotFormSubmit"] = "hubspot-form-submit";
|
|
48
|
+
DefaultEventNames["QuoteButton"] = "quote-button-click";
|
|
49
|
+
DefaultEventNames["BackLink"] = "back-link-click";
|
|
50
|
+
})(DefaultEventNames = exports.DefaultEventNames || (exports.DefaultEventNames = {}));
|
|
@@ -121,7 +121,6 @@ export interface LinkProps extends AnalyticsEventsBase, Stylable {
|
|
|
121
121
|
target?: string;
|
|
122
122
|
metrikaGoals?: MetrikaGoal;
|
|
123
123
|
pixelEvents?: ButtonPixel;
|
|
124
|
-
context?: string;
|
|
125
124
|
}
|
|
126
125
|
export interface FileLinkProps extends ClassNameProps {
|
|
127
126
|
href: string;
|
|
@@ -141,7 +140,6 @@ export interface ButtonProps extends AnalyticsEventsBase {
|
|
|
141
140
|
metrikaGoals?: MetrikaGoal;
|
|
142
141
|
pixelEvents?: ButtonPixel;
|
|
143
142
|
target?: string;
|
|
144
|
-
context?: string;
|
|
145
143
|
}
|
|
146
144
|
export interface ButtonImageProps {
|
|
147
145
|
url: string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCounterAllowed = void 0;
|
|
4
|
+
const isCounterAllowed = (counter, counters) => {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
if (!counters) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
if ((_a = counters.exclude) === null || _a === void 0 ? void 0 : _a.includes(counter)) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
else if ((_b = counters.include) === null || _b === void 0 ? void 0 : _b.includes(counter)) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
};
|
|
17
|
+
exports.isCounterAllowed = isCounterAllowed;
|
package/server/utils/blocks.d.ts
CHANGED
|
@@ -2,16 +2,9 @@ import { ConstructorBlock } from '../models/constructor';
|
|
|
2
2
|
import { TextSize, CustomConfig, PCShareSocialNetwork } from '../models';
|
|
3
3
|
export declare function getHeaderTag(size: TextSize): "h1" | "h4" | "h2";
|
|
4
4
|
export declare function getBlockKey(block: ConstructorBlock, index: number): string;
|
|
5
|
-
type GetBlockContextArgs = {
|
|
6
|
-
block: ConstructorBlock;
|
|
7
|
-
index: number;
|
|
8
|
-
parentContext?: string;
|
|
9
|
-
};
|
|
10
|
-
export declare function getBlockContext({ parentContext, block, index }: GetBlockContextArgs): string;
|
|
11
5
|
export declare const getCustomBlockTypes: ({ blocks, headers }?: CustomConfig) => string[];
|
|
12
6
|
export declare const getCustomItems: ({ blocks, headers, subBlocks }?: CustomConfig) => {
|
|
13
7
|
[x: string]: any;
|
|
14
8
|
};
|
|
15
9
|
export declare const getCustomHeaderTypes: (customBlocks?: CustomConfig) => string[];
|
|
16
10
|
export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string, text?: string) => string | undefined;
|
|
17
|
-
export {};
|
package/server/utils/blocks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getShareLink = exports.getCustomHeaderTypes = exports.getCustomItems = exports.getCustomBlockTypes = exports.
|
|
3
|
+
exports.getShareLink = exports.getCustomHeaderTypes = exports.getCustomItems = exports.getCustomBlockTypes = exports.getBlockKey = exports.getHeaderTag = void 0;
|
|
4
4
|
const models_1 = require("../models");
|
|
5
5
|
function getHeaderTag(size) {
|
|
6
6
|
switch (size) {
|
|
@@ -18,10 +18,6 @@ function getBlockKey(block, index) {
|
|
|
18
18
|
return `${block.type}-${index}`;
|
|
19
19
|
}
|
|
20
20
|
exports.getBlockKey = getBlockKey;
|
|
21
|
-
function getBlockContext({ parentContext = '', block, index }) {
|
|
22
|
-
return `${parentContext}${parentContext ? '_' : ''}${block.type}-${index}`;
|
|
23
|
-
}
|
|
24
|
-
exports.getBlockContext = getBlockContext;
|
|
25
21
|
const getCustomBlockTypes = ({ blocks = {}, headers = {} } = {}) => [
|
|
26
22
|
...Object.keys(blocks),
|
|
27
23
|
...Object.keys(headers),
|
package/server/utils/index.d.ts
CHANGED
package/server/utils/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.isHubspotEventData = exports.configure = exports.Lang = void 0;
|
|
18
|
+
__exportStar(require("./analytics"), exports);
|
|
18
19
|
__exportStar(require("./blocks"), exports);
|
|
19
20
|
__exportStar(require("./scroll"), exports);
|
|
20
21
|
__exportStar(require("./url"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './blockPositionContext';
|