@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
package/README.md
CHANGED
|
@@ -232,11 +232,6 @@ function sendEvents(events: MyEventType []) {
|
|
|
232
232
|
An event object has only one required field - `name`. It also has predefined fields, which serve to help manage complex logic. For example, `counter.include` can help to send event in a particular counter if several analytics systems are used in a project.
|
|
233
233
|
|
|
234
234
|
```ts
|
|
235
|
-
type AnalyticsCounters = {
|
|
236
|
-
include?: string[];
|
|
237
|
-
exclude?: string[];
|
|
238
|
-
};
|
|
239
|
-
|
|
240
235
|
type AnalyticsEvent<T = {}> = T & {
|
|
241
236
|
name: string;
|
|
242
237
|
type?: string;
|
|
@@ -271,21 +266,6 @@ Pass `context` value to define place in a project where an event is fired.
|
|
|
271
266
|
Use selector below or create logic that serves project needs.
|
|
272
267
|
|
|
273
268
|
```ts
|
|
274
|
-
// utils.ts
|
|
275
|
-
const isCounterAllowed = (counter: Counter, counters?: AnalyticsCounters) => {
|
|
276
|
-
if (!counters) {
|
|
277
|
-
return true;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
if (counters.exclude?.includes(counter)) {
|
|
281
|
-
return false;
|
|
282
|
-
} else if (counters.include?.includes(counter)) {
|
|
283
|
-
return true;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
return false;
|
|
287
|
-
};
|
|
288
|
-
|
|
289
269
|
// analyticsHandler.ts
|
|
290
270
|
if (isCounterAllowed(counterName, counters)) {
|
|
291
271
|
analyticsCounter.reachGoal(counterName, name, parameters);
|
|
@@ -6,7 +6,6 @@ const uikit_1 = require("@gravity-ui/uikit");
|
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const models_1 = require("../../models");
|
|
8
8
|
const locationContext_1 = require("../../context/locationContext");
|
|
9
|
-
const blockPositionContext_1 = require("../../context/blockPositionContext");
|
|
10
9
|
const i18n_1 = tslib_1.__importDefault(require("./i18n"));
|
|
11
10
|
const hooks_1 = require("../../hooks");
|
|
12
11
|
const Facebook_1 = require("../../icons/Facebook");
|
|
@@ -24,13 +23,7 @@ const icons = {
|
|
|
24
23
|
const b = (0, utils_1.block)('share-block');
|
|
25
24
|
const Share = ({ items, title }) => {
|
|
26
25
|
const { pathname, hostname } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
27
|
-
const
|
|
28
|
-
const defaultEvent = (0, react_1.useMemo)(() => ({
|
|
29
|
-
name: 'share-button-click',
|
|
30
|
-
type: models_1.PredefinedEventTypes.Default,
|
|
31
|
-
context,
|
|
32
|
-
}), [context]);
|
|
33
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
|
|
26
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.ShareButton);
|
|
34
27
|
const handleButtonClick = (0, react_1.useCallback)(() => handleAnalytics(), [handleAnalytics]);
|
|
35
28
|
return (react_1.default.createElement("div", { className: b() },
|
|
36
29
|
react_1.default.createElement("h5", { className: b('title') }, title || (0, i18n_1.default)('constructor-share')),
|
|
@@ -5,20 +5,12 @@ const react_1 = tslib_1.__importStar(require("react"));
|
|
|
5
5
|
const uikit_1 = require("@gravity-ui/uikit");
|
|
6
6
|
const icons_1 = require("../../icons");
|
|
7
7
|
const locationContext_1 = require("../../context/locationContext");
|
|
8
|
-
const blockPositionContext_1 = require("../../context/blockPositionContext");
|
|
9
8
|
const hooks_1 = require("../../hooks");
|
|
10
9
|
const models_1 = require("../../models");
|
|
11
|
-
const COMPONENT_NAME = 'backlink';
|
|
12
10
|
function BackLink(props) {
|
|
13
11
|
const { history } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
14
12
|
const { url, title, theme = 'default', size = 'l', className, shouldHandleBackAction = false, onClick, } = props;
|
|
15
|
-
const
|
|
16
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)({
|
|
17
|
-
name: 'back-link-click',
|
|
18
|
-
type: models_1.PredefinedEventTypes.Default,
|
|
19
|
-
context: context || COMPONENT_NAME,
|
|
20
|
-
target: url,
|
|
21
|
-
});
|
|
13
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.ShareButton, url);
|
|
22
14
|
const backActionHandler = (0, react_1.useCallback)(async () => {
|
|
23
15
|
handleAnalytics();
|
|
24
16
|
if (!history) {
|
|
@@ -7,25 +7,16 @@ const utils_1 = require("../../utils");
|
|
|
7
7
|
const models_1 = require("../../models");
|
|
8
8
|
const utils_2 = require("./utils");
|
|
9
9
|
const localeContext_1 = require("../../context/localeContext/localeContext");
|
|
10
|
-
const blockPositionContext_1 = require("../../context/blockPositionContext");
|
|
11
10
|
const useMetrika_1 = require("../../hooks/useMetrika");
|
|
12
11
|
const hooks_1 = require("../../hooks");
|
|
13
12
|
const icons_1 = require("../../icons");
|
|
14
|
-
const COMPONENT_NAME = 'button';
|
|
15
13
|
const b = (0, utils_1.block)('button-block');
|
|
16
14
|
const Button = (props) => {
|
|
17
15
|
const handleMetrika = (0, useMetrika_1.useMetrika)();
|
|
18
16
|
const { lang, tld } = (0, react_1.useContext)(localeContext_1.LocaleContext);
|
|
19
17
|
const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = tslib_1.__rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text"]);
|
|
20
|
-
const context = (0, react_1.useContext)(blockPositionContext_1.BlockPositionContext);
|
|
21
18
|
const defaultImgPosition = 'left';
|
|
22
|
-
const
|
|
23
|
-
name: 'button-click',
|
|
24
|
-
type: models_1.PredefinedEventTypes.Default,
|
|
25
|
-
context: context || COMPONENT_NAME,
|
|
26
|
-
target: url,
|
|
27
|
-
}), [context, url]);
|
|
28
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
|
|
19
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.Button, url);
|
|
29
20
|
const onClick = (0, react_1.useCallback)(() => {
|
|
30
21
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
31
22
|
handleAnalytics(analyticsEvents);
|
|
@@ -4,7 +4,6 @@ exports.Layout = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
|
-
const blockPositionContext_1 = require("../../context/blockPositionContext");
|
|
8
7
|
const BackgroundImage_1 = tslib_1.__importDefault(require("../BackgroundImage/BackgroundImage"));
|
|
9
8
|
const RouterLink_1 = tslib_1.__importDefault(require("../RouterLink/RouterLink"));
|
|
10
9
|
const useMetrika_1 = require("../../hooks/useMetrika");
|
|
@@ -17,14 +16,7 @@ const Footer = () => null;
|
|
|
17
16
|
const Layout = (props) => {
|
|
18
17
|
const { className, bodyClassName, metrikaGoals, pixelEvents, analyticsEvents, contentClassName, children, url, target, border = 'shadow', } = props;
|
|
19
18
|
const handleMetrika = (0, useMetrika_1.useMetrika)();
|
|
20
|
-
const
|
|
21
|
-
const defaultEvent = (0, react_1.useMemo)(() => ({
|
|
22
|
-
name: 'card-base-click',
|
|
23
|
-
type: common_1.PredefinedEventTypes.Default,
|
|
24
|
-
context,
|
|
25
|
-
target: url,
|
|
26
|
-
}), [context, url]);
|
|
27
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
|
|
19
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(common_1.DefaultEventNames.CardBase, url);
|
|
28
20
|
let header, content, footer, image, headerClass, footerClass;
|
|
29
21
|
function handleChild(child) {
|
|
30
22
|
switch (child.type) {
|
|
@@ -10,7 +10,6 @@ const FileLink_1 = tslib_1.__importDefault(require("../FileLink/FileLink"));
|
|
|
10
10
|
const BackLink_1 = tslib_1.__importDefault(require("../BackLink/BackLink"));
|
|
11
11
|
const localeContext_1 = require("../../context/localeContext/localeContext");
|
|
12
12
|
const locationContext_1 = require("../../context/locationContext/locationContext");
|
|
13
|
-
const blockPositionContext_1 = require("../../context/blockPositionContext");
|
|
14
13
|
const useMetrika_1 = require("../../hooks/useMetrika");
|
|
15
14
|
const hooks_1 = require("../../hooks");
|
|
16
15
|
const b = (0, utils_1.block)('link-block');
|
|
@@ -30,14 +29,7 @@ function getArrowSize(size) {
|
|
|
30
29
|
const LinkBlock = (props) => {
|
|
31
30
|
const { text, url, arrow, metrikaGoals, pixelEvents, analyticsEvents, theme = 'file-link', colorTheme = 'light', textSize = 'm', className, target, children, } = props;
|
|
32
31
|
const handleMetrika = (0, useMetrika_1.useMetrika)();
|
|
33
|
-
const
|
|
34
|
-
const defaultEvent = (0, react_1.useMemo)(() => ({
|
|
35
|
-
name: 'link-click',
|
|
36
|
-
type: models_1.PredefinedEventTypes.Default,
|
|
37
|
-
context,
|
|
38
|
-
target: url,
|
|
39
|
-
}), [context, url]);
|
|
40
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
|
|
32
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.Link, url);
|
|
41
33
|
const { hostname } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
42
34
|
const { tld } = (0, react_1.useContext)(localeContext_1.LocaleContext);
|
|
43
35
|
const href = (0, utils_1.setUrlTld)(props.url, tld);
|
|
@@ -12,9 +12,8 @@ const CustomBarControls_1 = tslib_1.__importDefault(require("./CustomBarControls
|
|
|
12
12
|
const videoContext_1 = require("../../context/videoContext");
|
|
13
13
|
const metrikaContext_1 = require("../../context/metrikaContext");
|
|
14
14
|
const mobileContext_1 = require("../../context/mobileContext");
|
|
15
|
-
const blockPositionContext_1 = require("../../context/blockPositionContext");
|
|
16
|
-
const icons_1 = require("../../icons");
|
|
17
15
|
const hooks_1 = require("../../hooks");
|
|
16
|
+
const icons_1 = require("../../icons");
|
|
18
17
|
const b = (0, utils_1.block)('ReactPlayer');
|
|
19
18
|
const FPS = 60;
|
|
20
19
|
// eslint-disable-next-line react/display-name
|
|
@@ -42,13 +41,7 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
42
41
|
}
|
|
43
42
|
return [];
|
|
44
43
|
}, [analyticsEvents]);
|
|
45
|
-
const
|
|
46
|
-
const defaultEvent = (0, react_1.useMemo)(() => ({
|
|
47
|
-
name: 'react-player-controls-click',
|
|
48
|
-
type: models_1.PredefinedEventTypes.Default,
|
|
49
|
-
context,
|
|
50
|
-
}), [context]);
|
|
51
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
|
|
44
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.ReactPlayerControls);
|
|
52
45
|
(0, react_1.useImperativeHandle)(originRef, () => ({
|
|
53
46
|
pause: () => setIsPlaying(false),
|
|
54
47
|
}));
|
|
@@ -6,7 +6,6 @@ const react_1 = tslib_1.__importStar(require("react"));
|
|
|
6
6
|
const constants_1 = require("../constants");
|
|
7
7
|
const localeContext_1 = require("../../context/localeContext");
|
|
8
8
|
const mobileContext_1 = require("../../context/mobileContext");
|
|
9
|
-
const blockPositionContext_1 = require("../../context/blockPositionContext");
|
|
10
9
|
const utils_1 = require("../../utils");
|
|
11
10
|
const common_1 = require("../../models/common");
|
|
12
11
|
const useMetrika_1 = require("../../hooks/useMetrika");
|
|
@@ -20,13 +19,7 @@ const YandexForm = (props) => {
|
|
|
20
19
|
const iframeRef = (0, react_1.useRef)();
|
|
21
20
|
const yaFormOrigin = customFormOrigin || exports.YANDEX_FORM_ORIGIN;
|
|
22
21
|
const handleMetrika = (0, useMetrika_1.useMetrika)();
|
|
23
|
-
const
|
|
24
|
-
const defaultEvent = (0, react_1.useMemo)(() => ({
|
|
25
|
-
name: 'yndex-form-submit',
|
|
26
|
-
type: common_1.PredefinedEventTypes.Default,
|
|
27
|
-
context: context,
|
|
28
|
-
}), [context]);
|
|
29
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
|
|
22
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(common_1.DefaultEventNames.YandexFormSubmit);
|
|
30
23
|
const isMobile = (0, react_1.useContext)(mobileContext_1.MobileContext);
|
|
31
24
|
const locale = (0, react_1.useContext)(localeContext_1.LocaleContext);
|
|
32
25
|
const updateFormIframe = (0, react_1.useCallback)((container) => {
|
package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js
CHANGED
|
@@ -6,19 +6,20 @@ const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
|
6
6
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
7
7
|
const utils_1 = require("../../../../utils");
|
|
8
8
|
const innerContext_1 = require("../../../../context/innerContext");
|
|
9
|
+
const blockIdContext_1 = require("../../../../context/blockIdContext");
|
|
9
10
|
const ConstructorLoadable_1 = require("../ConstructorLoadable");
|
|
10
11
|
const ConstructorItem_1 = require("../ConstructorItem");
|
|
11
12
|
const ConstructorBlock_1 = require("../ConstructorBlock/ConstructorBlock");
|
|
12
13
|
const ConstructorBlocks = ({ items, shouldRenderBlock }) => {
|
|
13
14
|
const { blockTypes, loadables, itemMap } = (0, react_1.useContext)(innerContext_1.InnerContext);
|
|
14
|
-
const renderer = (
|
|
15
|
+
const renderer = (parentId = '', item, index) => {
|
|
15
16
|
if (!itemMap[item.type]) {
|
|
16
17
|
return null;
|
|
17
18
|
}
|
|
18
19
|
let children;
|
|
19
20
|
let itemElement;
|
|
20
21
|
const key = (0, utils_1.getBlockKey)(item, index);
|
|
21
|
-
const
|
|
22
|
+
const blockId = parentId ? `${parentId}_${key}` : key;
|
|
22
23
|
if (shouldRenderBlock && !shouldRenderBlock(item, key)) {
|
|
23
24
|
return null;
|
|
24
25
|
}
|
|
@@ -32,9 +33,10 @@ const ConstructorBlocks = ({ items, shouldRenderBlock }) => {
|
|
|
32
33
|
}
|
|
33
34
|
else {
|
|
34
35
|
if ('children' in item && item.children) {
|
|
35
|
-
children = item.children.map(renderer.bind(null,
|
|
36
|
+
children = item.children.map(renderer.bind(null, blockId));
|
|
36
37
|
}
|
|
37
|
-
itemElement = (react_1.default.createElement(
|
|
38
|
+
itemElement = (react_1.default.createElement(blockIdContext_1.BlockIdContext.Provider, { value: blockId },
|
|
39
|
+
react_1.default.createElement(ConstructorItem_1.ConstructorItem, { data: item, key: key }, children)));
|
|
38
40
|
}
|
|
39
41
|
return blockTypes.includes(item.type) ? (react_1.default.createElement(ConstructorBlock_1.ConstructorBlock, { data: item, key: key, Component: itemElement })) : (itemElement);
|
|
40
42
|
};
|
package/build/cjs/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;
|
|
@@ -4,13 +4,11 @@ exports.ConstructorHeader = exports.ConstructorItem = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
6
|
const innerContext_1 = require("../../../../context/innerContext");
|
|
7
|
-
const
|
|
8
|
-
const ConstructorItem = ({ data, children, context }) => {
|
|
7
|
+
const ConstructorItem = ({ data, children }) => {
|
|
9
8
|
const { itemMap } = (0, react_1.useContext)(innerContext_1.InnerContext);
|
|
10
9
|
const { type } = data, rest = tslib_1.__rest(data, ["type"]);
|
|
11
10
|
const Component = itemMap[type];
|
|
12
|
-
return
|
|
13
|
-
react_1.default.createElement(Component, Object.assign({}, rest), children)));
|
|
11
|
+
return react_1.default.createElement(Component, Object.assign({}, rest), children);
|
|
14
12
|
};
|
|
15
13
|
exports.ConstructorItem = ConstructorItem;
|
|
16
14
|
const ConstructorHeader = ({ data }) => (react_1.default.createElement(exports.ConstructorItem, { data: data, key: data.type }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.BlockIdContext = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
exports.
|
|
6
|
+
exports.BlockIdContext = react_1.default.createContext('');
|
|
@@ -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;
|
|
@@ -3,9 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useAnalytics = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const blockIdContext_1 = require("../context/blockIdContext");
|
|
6
7
|
const analyticsContext_1 = require("../context/analyticsContext");
|
|
7
|
-
const
|
|
8
|
+
const models_1 = require("../models");
|
|
9
|
+
const useAnalytics = (name = '', target) => {
|
|
8
10
|
const { sendEvents, autoEvents } = (0, react_1.useContext)(analyticsContext_1.AnalyticsContext);
|
|
11
|
+
const context = (0, react_1.useContext)(blockIdContext_1.BlockIdContext);
|
|
12
|
+
const defaultEvent = (0, react_1.useMemo)(() => name
|
|
13
|
+
? {
|
|
14
|
+
name,
|
|
15
|
+
context,
|
|
16
|
+
type: models_1.PredefinedEventTypes.Default,
|
|
17
|
+
target: target,
|
|
18
|
+
}
|
|
19
|
+
: undefined, [context, name, target]);
|
|
9
20
|
if (!sendEvents) {
|
|
10
21
|
return (0, lodash_1.memoize)(() => { });
|
|
11
22
|
}
|
|
@@ -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[];
|
|
@@ -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;
|
|
@@ -9,7 +9,9 @@ const models_1 = require("../../../models");
|
|
|
9
9
|
const icons_1 = require("../../../icons");
|
|
10
10
|
const SocialIcon_1 = tslib_1.__importDefault(require("../SocialIcon/SocialIcon"));
|
|
11
11
|
const utils_2 = require("../../../components/Media/Image/utils");
|
|
12
|
+
const blockIdContext_1 = require("../../../context/blockIdContext");
|
|
12
13
|
const b = (0, utils_1.block)('navigation-item');
|
|
14
|
+
const ANALYTICS_ID = 'navigation';
|
|
13
15
|
const Content = ({ text, icon }) => (react_1.default.createElement(react_1.Fragment, null,
|
|
14
16
|
icon && typeof icon !== 'string' && react_1.default.createElement(components_1.Image, Object.assign({ className: b('icon') }, icon)),
|
|
15
17
|
react_1.default.createElement("span", { className: b('text') }, text)));
|
|
@@ -38,11 +40,8 @@ const NavigationLink = (props) => {
|
|
|
38
40
|
};
|
|
39
41
|
const NavigationButton = (props) => {
|
|
40
42
|
const { url, target } = props;
|
|
41
|
-
return target ? (
|
|
42
|
-
|
|
43
|
-
// <Button {...props} url={url} context={BLOCK_NAME} />
|
|
44
|
-
react_1.default.createElement(components_1.Button, Object.assign({}, props, { url: url }))) : (react_1.default.createElement(components_1.RouterLink, { href: url },
|
|
45
|
-
react_1.default.createElement(components_1.Button, Object.assign({}, props, { url: url }))));
|
|
43
|
+
return (react_1.default.createElement(blockIdContext_1.BlockIdContext.Provider, { value: ANALYTICS_ID }, target ? (react_1.default.createElement(components_1.Button, Object.assign({}, props, { url: url }))) : (react_1.default.createElement(components_1.RouterLink, { href: url },
|
|
44
|
+
react_1.default.createElement(components_1.Button, Object.assign({}, props, { url: url }))))));
|
|
46
45
|
};
|
|
47
46
|
//todo: add types support form component in map
|
|
48
47
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -5,7 +5,6 @@ const react_1 = tslib_1.__importStar(require("react"));
|
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const ThemeValueContext_1 = require("../../context/theme/ThemeValueContext");
|
|
7
7
|
const mobileContext_1 = require("../../context/mobileContext");
|
|
8
|
-
const blockPositionContext_1 = require("../../context/blockPositionContext");
|
|
9
8
|
const useMetrika_1 = require("../../hooks/useMetrika");
|
|
10
9
|
const models_1 = require("../../models");
|
|
11
10
|
const hooks_1 = require("../../hooks");
|
|
@@ -16,13 +15,7 @@ const HubspotForm = (props) => {
|
|
|
16
15
|
// hubspotEvents, // TODO: decide how to handle them
|
|
17
16
|
analyticsEvents, onBeforeSubmit, onSubmit, onBeforeLoad, onLoad, createDOMElement, onSubmitError, } = props;
|
|
18
17
|
const handleMetrika = (0, useMetrika_1.useMetrika)();
|
|
19
|
-
const
|
|
20
|
-
const defaultEvent = (0, react_1.useMemo)(() => ({
|
|
21
|
-
name: 'hubspot-form-submit',
|
|
22
|
-
type: models_1.PredefinedEventTypes.Default,
|
|
23
|
-
context,
|
|
24
|
-
}), [context]);
|
|
25
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
|
|
18
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.HubspotFormSubmit);
|
|
26
19
|
const { themeValue } = (0, react_1.useContext)(ThemeValueContext_1.ThemeValueContext);
|
|
27
20
|
const isMobileValue = (0, react_1.useContext)(mobileContext_1.MobileContext);
|
|
28
21
|
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;
|
|
@@ -7,23 +7,15 @@ const utils_1 = require("../../utils");
|
|
|
7
7
|
const models_1 = require("../../models");
|
|
8
8
|
const components_1 = require("../../components");
|
|
9
9
|
const ThemeValueContext_1 = require("../../context/theme/ThemeValueContext");
|
|
10
|
-
const blockPositionContext_1 = require("../../context/blockPositionContext");
|
|
11
10
|
const utils_2 = require("../../components/Media/Image/utils");
|
|
12
11
|
const hooks_1 = require("../../hooks");
|
|
13
12
|
const b = (0, utils_1.block)('quote');
|
|
14
13
|
const Quote = (props) => {
|
|
15
14
|
const { theme: textTheme = 'light', color, image, border = 'shadow', text, logo, author, url, buttonText, } = props;
|
|
16
15
|
const { themeValue: theme } = (0, react_1.useContext)(ThemeValueContext_1.ThemeValueContext);
|
|
17
|
-
const context = (0, react_1.useContext)(blockPositionContext_1.BlockPositionContext);
|
|
18
16
|
const imageThemed = (0, utils_1.getThemedValue)(image, theme);
|
|
19
17
|
const imageData = (0, utils_2.getMediaImage)(imageThemed);
|
|
20
|
-
const
|
|
21
|
-
name: 'quote-button-click',
|
|
22
|
-
type: models_1.PredefinedEventTypes.Default,
|
|
23
|
-
context,
|
|
24
|
-
target: url,
|
|
25
|
-
}), [context, url]);
|
|
26
|
-
const handleAnalytics = (0, hooks_1.useAnalytics)(defaultEvent);
|
|
18
|
+
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.QuoteButton, url);
|
|
27
19
|
const handleButtonClick = (0, react_1.useCallback)(() => handleAnalytics(), [handleAnalytics]);
|
|
28
20
|
const renderFooter = Boolean(author || url) && (react_1.default.createElement("div", { className: b('author-wrapper') },
|
|
29
21
|
author && (react_1.default.createElement(components_1.Author, { className: b('author', { theme: textTheme }), author: author, type: models_1.AuthorType.Line })),
|
|
@@ -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;
|
|
@@ -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 {};
|
|
@@ -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/build/cjs/utils/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isHubspotEventData = exports.configure = exports.Lang = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./analytics"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./blocks"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./scroll"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./url"), exports);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import React, { useContext, useCallback
|
|
1
|
+
import React, { useContext, useCallback } from 'react';
|
|
2
2
|
import { Icon, Button } from '@gravity-ui/uikit';
|
|
3
3
|
import { block, getAbsolutePath, getShareLink } from '../../utils';
|
|
4
|
-
import {
|
|
4
|
+
import { DefaultEventNames } from '../../models';
|
|
5
5
|
import { LocationContext } from '../../context/locationContext';
|
|
6
|
-
import { BlockPositionContext } from '../../context/blockPositionContext';
|
|
7
6
|
import i18n from './i18n';
|
|
8
7
|
import { useAnalytics } from '../../hooks';
|
|
9
8
|
import { Facebook } from '../../icons/Facebook';
|
|
@@ -22,13 +21,7 @@ const icons = {
|
|
|
22
21
|
const b = block('share-block');
|
|
23
22
|
const Share = ({ items, title }) => {
|
|
24
23
|
const { pathname, hostname } = useContext(LocationContext);
|
|
25
|
-
const
|
|
26
|
-
const defaultEvent = useMemo(() => ({
|
|
27
|
-
name: 'share-button-click',
|
|
28
|
-
type: PredefinedEventTypes.Default,
|
|
29
|
-
context,
|
|
30
|
-
}), [context]);
|
|
31
|
-
const handleAnalytics = useAnalytics(defaultEvent);
|
|
24
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.ShareButton);
|
|
32
25
|
const handleButtonClick = useCallback(() => handleAnalytics(), [handleAnalytics]);
|
|
33
26
|
return (React.createElement("div", { className: b() },
|
|
34
27
|
React.createElement("h5", { className: b('title') }, title || i18n('constructor-share')),
|
|
@@ -2,20 +2,12 @@ import React, { useCallback, useContext } from 'react';
|
|
|
2
2
|
import { Button, Icon } from '@gravity-ui/uikit';
|
|
3
3
|
import { ArrowSidebar } from '../../icons';
|
|
4
4
|
import { LocationContext } from '../../context/locationContext';
|
|
5
|
-
import { BlockPositionContext } from '../../context/blockPositionContext';
|
|
6
5
|
import { useAnalytics } from '../../hooks';
|
|
7
|
-
import {
|
|
8
|
-
const COMPONENT_NAME = 'backlink';
|
|
6
|
+
import { DefaultEventNames } from '../../models';
|
|
9
7
|
export default function BackLink(props) {
|
|
10
8
|
const { history } = useContext(LocationContext);
|
|
11
9
|
const { url, title, theme = 'default', size = 'l', className, shouldHandleBackAction = false, onClick, } = props;
|
|
12
|
-
const
|
|
13
|
-
const handleAnalytics = useAnalytics({
|
|
14
|
-
name: 'back-link-click',
|
|
15
|
-
type: PredefinedEventTypes.Default,
|
|
16
|
-
context: context || COMPONENT_NAME,
|
|
17
|
-
target: url,
|
|
18
|
-
});
|
|
10
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.ShareButton, url);
|
|
19
11
|
const backActionHandler = useCallback(async () => {
|
|
20
12
|
handleAnalytics();
|
|
21
13
|
if (!history) {
|