@gravity-ui/page-constructor 2.5.0 → 2.7.0
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/build/cjs/containers/PageConstructor/PageConstructor.js +1 -1
- package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +2 -2
- package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +2 -2
- package/build/cjs/hooks/useAnalytics.d.ts +1 -1
- package/build/cjs/hooks/useAnalytics.js +5 -2
- package/build/esm/containers/PageConstructor/PageConstructor.js +2 -2
- package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +2 -2
- package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +2 -2
- package/build/esm/hooks/useAnalytics.d.ts +1 -1
- package/build/esm/hooks/useAnalytics.js +5 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.7.0](https://github.com/gravity-ui/page-constructor/compare/v2.6.0...v2.7.0) (2023-04-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add default analytics context to header block ([#289](https://github.com/gravity-ui/page-constructor/issues/289)) ([c1b8e45](https://github.com/gravity-ui/page-constructor/commit/c1b8e45423e7d8e2bd7daa108a8b296aebb811ef))
|
|
9
|
+
|
|
10
|
+
## [2.6.0](https://github.com/gravity-ui/page-constructor/compare/v2.5.0...v2.6.0) (2023-04-05)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* add options to useAnalytics ([#287](https://github.com/gravity-ui/page-constructor/issues/287)) ([17c2c75](https://github.com/gravity-ui/page-constructor/commit/17c2c750042718ca4f90d23245cf8d2caadde3b2))
|
|
16
|
+
|
|
3
17
|
## [2.5.0](https://github.com/gravity-ui/page-constructor/compare/v2.4.0...v2.5.0) (2023-04-05)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -42,7 +42,7 @@ const Constructor = (props) => {
|
|
|
42
42
|
themedBackground && (react_1.default.createElement(BackgroundMedia_1.default, Object.assign({}, themedBackground, { className: b('background') }))),
|
|
43
43
|
react_1.default.createElement(Layout_1.default, { navigation: navigation },
|
|
44
44
|
renderMenu && renderMenu(),
|
|
45
|
-
header && react_1.default.createElement(ConstructorItem_1.ConstructorHeader, { data: header }),
|
|
45
|
+
header && (react_1.default.createElement(ConstructorItem_1.ConstructorHeader, { data: header, blockKey: models_1.BlockType.HeaderBlock })),
|
|
46
46
|
react_1.default.createElement(grid_1.Grid, null,
|
|
47
47
|
restBlocks && (react_1.default.createElement(ConstructorRow_1.ConstructorRow, null,
|
|
48
48
|
react_1.default.createElement(ConstructorBlocks_1.ConstructorBlocks, { items: restBlocks }))),
|
package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConstructorItem as ConstructorItemType, WithChildren } from '../../../../models';
|
|
2
2
|
export interface ConstructorItemProps {
|
|
3
3
|
data: ConstructorItemType;
|
|
4
|
-
blockKey
|
|
4
|
+
blockKey: string;
|
|
5
5
|
}
|
|
6
|
-
export declare const ConstructorItem: ({ data, blockKey, children
|
|
6
|
+
export declare const ConstructorItem: ({ data, blockKey, children }: WithChildren<ConstructorItemProps>) => JSX.Element;
|
|
7
7
|
export declare const ConstructorHeader: ({ data, blockKey, }: Pick<ConstructorItemProps, 'data' | 'blockKey'>) => JSX.Element;
|
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
6
|
const blockIdContext_1 = require("../../../../context/blockIdContext");
|
|
7
7
|
const innerContext_1 = require("../../../../context/innerContext");
|
|
8
|
-
const ConstructorItem = ({ data, blockKey
|
|
8
|
+
const ConstructorItem = ({ data, blockKey, children }) => {
|
|
9
9
|
const { itemMap } = (0, react_1.useContext)(innerContext_1.InnerContext);
|
|
10
10
|
const { type } = data, rest = tslib_1.__rest(data, ["type"]);
|
|
11
11
|
const Component = itemMap[type];
|
|
@@ -13,5 +13,5 @@ const ConstructorItem = ({ data, blockKey = '', children, }) => {
|
|
|
13
13
|
react_1.default.createElement(Component, Object.assign({}, rest), children)));
|
|
14
14
|
};
|
|
15
15
|
exports.ConstructorItem = ConstructorItem;
|
|
16
|
-
const ConstructorHeader = ({ data, blockKey
|
|
16
|
+
const ConstructorHeader = ({ data, blockKey, }) => (react_1.default.createElement(exports.ConstructorItem, { data: data, key: data.type, blockKey: blockKey }));
|
|
17
17
|
exports.ConstructorHeader = ConstructorHeader;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AnalyticsEvent } from '../models';
|
|
2
|
-
export declare const useAnalytics: (name?: string, target?: string) => ((e?: AnalyticsEvent | AnalyticsEvent[]) => void) & import("lodash").MemoizedFunction;
|
|
2
|
+
export declare const useAnalytics: (name?: string, target?: string) => ((e?: AnalyticsEvent | AnalyticsEvent[] | null, additionalContext?: Record<string, string>) => void) & import("lodash").MemoizedFunction;
|
|
@@ -21,7 +21,7 @@ const useAnalytics = (name = '', target) => {
|
|
|
21
21
|
return (0, lodash_1.memoize)(() => { });
|
|
22
22
|
}
|
|
23
23
|
const defaultEvents = defaultEvent && autoEvents ? [defaultEvent] : [];
|
|
24
|
-
return (0, lodash_1.memoize)((e) => {
|
|
24
|
+
return (0, lodash_1.memoize)((e, additionalContext) => {
|
|
25
25
|
let events = defaultEvents;
|
|
26
26
|
if (e) {
|
|
27
27
|
events = Array.isArray(e) ? [...events, ...e] : [...events, e];
|
|
@@ -29,7 +29,10 @@ const useAnalytics = (name = '', target) => {
|
|
|
29
29
|
if (!events) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
const preparedEvents = additionalContext
|
|
33
|
+
? events.map((event) => (Object.assign(Object.assign({}, event), additionalContext)))
|
|
34
|
+
: events;
|
|
35
|
+
sendEvents(preparedEvents);
|
|
33
36
|
});
|
|
34
37
|
};
|
|
35
38
|
exports.useAnalytics = useAnalytics;
|
|
@@ -7,7 +7,7 @@ import { AnimateContext } from '../../context/animateContext';
|
|
|
7
7
|
import { InnerContext } from '../../context/innerContext';
|
|
8
8
|
import { ThemeValueContext } from '../../context/theme/ThemeValueContext';
|
|
9
9
|
import { Grid } from '../../grid';
|
|
10
|
-
import { BlockTypes, HeaderBlockTypes, SubBlockTypes, } from '../../models';
|
|
10
|
+
import { BlockType, BlockTypes, HeaderBlockTypes, SubBlockTypes, } from '../../models';
|
|
11
11
|
import Layout from '../../navigation/containers/Layout/Layout';
|
|
12
12
|
import { block as cnBlock, getCustomBlockTypes, getCustomHeaderTypes, getCustomItems, getCustomSubBlockTypes, getThemedValue, } from '../../utils';
|
|
13
13
|
import { ConstructorBlocks } from './components/ConstructorBlocks';
|
|
@@ -40,7 +40,7 @@ export const Constructor = (props) => {
|
|
|
40
40
|
themedBackground && (React.createElement(BackgroundMedia, Object.assign({}, themedBackground, { className: b('background') }))),
|
|
41
41
|
React.createElement(Layout, { navigation: navigation },
|
|
42
42
|
renderMenu && renderMenu(),
|
|
43
|
-
header && React.createElement(ConstructorHeader, { data: header }),
|
|
43
|
+
header && (React.createElement(ConstructorHeader, { data: header, blockKey: BlockType.HeaderBlock })),
|
|
44
44
|
React.createElement(Grid, null,
|
|
45
45
|
restBlocks && (React.createElement(ConstructorRow, null,
|
|
46
46
|
React.createElement(ConstructorBlocks, { items: restBlocks }))),
|
package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConstructorItem as ConstructorItemType, WithChildren } from '../../../../models';
|
|
2
2
|
export interface ConstructorItemProps {
|
|
3
3
|
data: ConstructorItemType;
|
|
4
|
-
blockKey
|
|
4
|
+
blockKey: string;
|
|
5
5
|
}
|
|
6
|
-
export declare const ConstructorItem: ({ data, blockKey, children
|
|
6
|
+
export declare const ConstructorItem: ({ data, blockKey, children }: WithChildren<ConstructorItemProps>) => JSX.Element;
|
|
7
7
|
export declare const ConstructorHeader: ({ data, blockKey, }: Pick<ConstructorItemProps, 'data' | 'blockKey'>) => JSX.Element;
|
|
@@ -2,11 +2,11 @@ import { __rest } from "tslib";
|
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
3
|
import { BlockIdContext } from '../../../../context/blockIdContext';
|
|
4
4
|
import { InnerContext } from '../../../../context/innerContext';
|
|
5
|
-
export const ConstructorItem = ({ data, blockKey
|
|
5
|
+
export const ConstructorItem = ({ data, blockKey, children }) => {
|
|
6
6
|
const { itemMap } = useContext(InnerContext);
|
|
7
7
|
const { type } = data, rest = __rest(data, ["type"]);
|
|
8
8
|
const Component = itemMap[type];
|
|
9
9
|
return (React.createElement(BlockIdContext.Provider, { value: blockKey },
|
|
10
10
|
React.createElement(Component, Object.assign({}, rest), children)));
|
|
11
11
|
};
|
|
12
|
-
export const ConstructorHeader = ({ data, blockKey
|
|
12
|
+
export const ConstructorHeader = ({ data, blockKey, }) => (React.createElement(ConstructorItem, { data: data, key: data.type, blockKey: blockKey }));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AnalyticsEvent } from '../models';
|
|
2
|
-
export declare const useAnalytics: (name?: string, target?: string) => ((e?: AnalyticsEvent | AnalyticsEvent[]) => void) & import("lodash").MemoizedFunction;
|
|
2
|
+
export declare const useAnalytics: (name?: string, target?: string) => ((e?: AnalyticsEvent | AnalyticsEvent[] | null, additionalContext?: Record<string, string>) => void) & import("lodash").MemoizedFunction;
|
|
@@ -18,7 +18,7 @@ export const useAnalytics = (name = '', target) => {
|
|
|
18
18
|
return memoize(() => { });
|
|
19
19
|
}
|
|
20
20
|
const defaultEvents = defaultEvent && autoEvents ? [defaultEvent] : [];
|
|
21
|
-
return memoize((e) => {
|
|
21
|
+
return memoize((e, additionalContext) => {
|
|
22
22
|
let events = defaultEvents;
|
|
23
23
|
if (e) {
|
|
24
24
|
events = Array.isArray(e) ? [...events, ...e] : [...events, e];
|
|
@@ -26,6 +26,9 @@ export const useAnalytics = (name = '', target) => {
|
|
|
26
26
|
if (!events) {
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
const preparedEvents = additionalContext
|
|
30
|
+
? events.map((event) => (Object.assign(Object.assign({}, event), additionalContext)))
|
|
31
|
+
: events;
|
|
32
|
+
sendEvents(preparedEvents);
|
|
30
33
|
});
|
|
31
34
|
};
|