@gravity-ui/page-constructor 1.20.4 → 1.20.5
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 +7 -0
- package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +1 -3
- package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +3 -2
- package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +5 -3
- package/build/cjs/containers/PageConstructor/components/ConstructorLoadable/ConstructorLoadable.js +3 -1
- package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +1 -3
- package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +3 -2
- package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +5 -3
- package/build/esm/containers/PageConstructor/components/ConstructorLoadable/ConstructorLoadable.js +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.20.5](https://github.com/gravity-ui/page-constructor/compare/v1.20.4...v1.20.5) (2023-03-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* move BlockIdContext.Provider inside ConstructorItem and ConstructorLoadable ([#201](https://github.com/gravity-ui/page-constructor/issues/201)) ([f2036e3](https://github.com/gravity-ui/page-constructor/commit/f2036e333f10711ca51ad3a62c735ca285904cff))
|
|
9
|
+
|
|
3
10
|
## [1.20.4](https://github.com/gravity-ui/page-constructor/compare/v1.20.3...v1.20.4) (2023-03-03)
|
|
4
11
|
|
|
5
12
|
|
package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js
CHANGED
|
@@ -6,7 +6,6 @@ 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");
|
|
10
9
|
const ConstructorLoadable_1 = require("../ConstructorLoadable");
|
|
11
10
|
const ConstructorItem_1 = require("../ConstructorItem");
|
|
12
11
|
const ConstructorBlock_1 = require("../ConstructorBlock/ConstructorBlock");
|
|
@@ -35,8 +34,7 @@ const ConstructorBlocks = ({ items, shouldRenderBlock }) => {
|
|
|
35
34
|
if ('children' in item && item.children) {
|
|
36
35
|
children = item.children.map(renderer.bind(null, blockId));
|
|
37
36
|
}
|
|
38
|
-
itemElement = (react_1.default.createElement(
|
|
39
|
-
react_1.default.createElement(ConstructorItem_1.ConstructorItem, { data: item }, children)));
|
|
37
|
+
itemElement = (react_1.default.createElement(ConstructorItem_1.ConstructorItem, { data: item, key: blockId, blockKey: blockId }, children));
|
|
40
38
|
}
|
|
41
39
|
return blockTypes.includes(item.type) ? (react_1.default.createElement(ConstructorBlock_1.ConstructorBlock, { data: item, key: blockId, Component: itemElement })) : (itemElement);
|
|
42
40
|
};
|
package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ConstructorItem as ConstructorItemType, WithChildren } from '../../../../models';
|
|
2
2
|
export interface ConstructorItemProps {
|
|
3
3
|
data: ConstructorItemType;
|
|
4
|
+
blockKey?: string;
|
|
4
5
|
}
|
|
5
|
-
export declare const ConstructorItem: ({ data, children }: WithChildren<ConstructorItemProps>) => JSX.Element;
|
|
6
|
-
export declare const ConstructorHeader: ({ data }: Pick<ConstructorItemProps, 'data'>) => JSX.Element;
|
|
6
|
+
export declare const ConstructorItem: ({ data, blockKey, children, }: WithChildren<ConstructorItemProps>) => JSX.Element;
|
|
7
|
+
export declare const ConstructorHeader: ({ data, blockKey, }: Pick<ConstructorItemProps, 'data' | 'blockKey'>) => JSX.Element;
|
|
@@ -4,12 +4,14 @@ 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
|
|
7
|
+
const blockIdContext_1 = require("../../../../context/blockIdContext");
|
|
8
|
+
const ConstructorItem = ({ data, blockKey = '', children, }) => {
|
|
8
9
|
const { itemMap } = (0, react_1.useContext)(innerContext_1.InnerContext);
|
|
9
10
|
const { type } = data, rest = tslib_1.__rest(data, ["type"]);
|
|
10
11
|
const Component = itemMap[type];
|
|
11
|
-
return react_1.default.createElement(
|
|
12
|
+
return (react_1.default.createElement(blockIdContext_1.BlockIdContext.Provider, { value: blockKey },
|
|
13
|
+
react_1.default.createElement(Component, Object.assign({}, rest), children)));
|
|
12
14
|
};
|
|
13
15
|
exports.ConstructorItem = ConstructorItem;
|
|
14
|
-
const ConstructorHeader = ({ data }) => (react_1.default.createElement(exports.ConstructorItem, { data: data, key: data.type }));
|
|
16
|
+
const ConstructorHeader = ({ data, blockKey = '', }) => (react_1.default.createElement(exports.ConstructorItem, { data: data, key: data.type, blockKey: blockKey }));
|
|
15
17
|
exports.ConstructorHeader = ConstructorHeader;
|
package/build/cjs/containers/PageConstructor/components/ConstructorLoadable/ConstructorLoadable.js
CHANGED
|
@@ -5,12 +5,14 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
6
|
const Loadable_1 = tslib_1.__importDefault(require("../../../Loadable/Loadable"));
|
|
7
7
|
const innerContext_1 = require("../../../../context/innerContext");
|
|
8
|
+
const blockIdContext_1 = require("../../../../context/blockIdContext");
|
|
8
9
|
const ConstructorLoadable = (props) => {
|
|
9
10
|
const { itemMap } = (0, react_1.useContext)(innerContext_1.InnerContext);
|
|
10
11
|
const { block, blockKey, config, serviceId, params } = props;
|
|
11
12
|
const { type } = block;
|
|
12
13
|
const { fetch, component: ChildComponent } = config;
|
|
13
14
|
const Component = itemMap[type];
|
|
14
|
-
return (react_1.default.createElement(
|
|
15
|
+
return (react_1.default.createElement(blockIdContext_1.BlockIdContext.Provider, { value: blockKey, key: blockKey },
|
|
16
|
+
react_1.default.createElement(Loadable_1.default, { key: blockKey, block: block, blockKey: blockKey, Component: Component, ChildComponent: ChildComponent, fetch: fetch, serviceId: serviceId, params: params })));
|
|
15
17
|
};
|
|
16
18
|
exports.ConstructorLoadable = ConstructorLoadable;
|
package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js
CHANGED
|
@@ -2,7 +2,6 @@ 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';
|
|
6
5
|
import { ConstructorLoadable } from '../ConstructorLoadable';
|
|
7
6
|
import { ConstructorItem } from '../ConstructorItem';
|
|
8
7
|
import { ConstructorBlock } from '../ConstructorBlock/ConstructorBlock';
|
|
@@ -31,8 +30,7 @@ export const ConstructorBlocks = ({ items, shouldRenderBlock }) => {
|
|
|
31
30
|
if ('children' in item && item.children) {
|
|
32
31
|
children = item.children.map(renderer.bind(null, blockId));
|
|
33
32
|
}
|
|
34
|
-
itemElement = (React.createElement(
|
|
35
|
-
React.createElement(ConstructorItem, { data: item }, children)));
|
|
33
|
+
itemElement = (React.createElement(ConstructorItem, { data: item, key: blockId, blockKey: blockId }, children));
|
|
36
34
|
}
|
|
37
35
|
return blockTypes.includes(item.type) ? (React.createElement(ConstructorBlock, { data: item, key: blockId, Component: itemElement })) : (itemElement);
|
|
38
36
|
};
|
package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ConstructorItem as ConstructorItemType, WithChildren } from '../../../../models';
|
|
2
2
|
export interface ConstructorItemProps {
|
|
3
3
|
data: ConstructorItemType;
|
|
4
|
+
blockKey?: string;
|
|
4
5
|
}
|
|
5
|
-
export declare const ConstructorItem: ({ data, children }: WithChildren<ConstructorItemProps>) => JSX.Element;
|
|
6
|
-
export declare const ConstructorHeader: ({ data }: Pick<ConstructorItemProps, 'data'>) => JSX.Element;
|
|
6
|
+
export declare const ConstructorItem: ({ data, blockKey, children, }: WithChildren<ConstructorItemProps>) => JSX.Element;
|
|
7
|
+
export declare const ConstructorHeader: ({ data, blockKey, }: Pick<ConstructorItemProps, 'data' | 'blockKey'>) => JSX.Element;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
3
|
import { InnerContext } from '../../../../context/innerContext';
|
|
4
|
-
|
|
4
|
+
import { BlockIdContext } from '../../../../context/blockIdContext';
|
|
5
|
+
export const ConstructorItem = ({ data, blockKey = '', children, }) => {
|
|
5
6
|
const { itemMap } = useContext(InnerContext);
|
|
6
7
|
const { type } = data, rest = __rest(data, ["type"]);
|
|
7
8
|
const Component = itemMap[type];
|
|
8
|
-
return React.createElement(
|
|
9
|
+
return (React.createElement(BlockIdContext.Provider, { value: blockKey },
|
|
10
|
+
React.createElement(Component, Object.assign({}, rest), children)));
|
|
9
11
|
};
|
|
10
|
-
export const ConstructorHeader = ({ data }) => (React.createElement(ConstructorItem, { data: data, key: data.type }));
|
|
12
|
+
export const ConstructorHeader = ({ data, blockKey = '', }) => (React.createElement(ConstructorItem, { data: data, key: data.type, blockKey: blockKey }));
|
package/build/esm/containers/PageConstructor/components/ConstructorLoadable/ConstructorLoadable.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
2
|
import Loadable from '../../../Loadable/Loadable';
|
|
3
3
|
import { InnerContext } from '../../../../context/innerContext';
|
|
4
|
+
import { BlockIdContext } from '../../../../context/blockIdContext';
|
|
4
5
|
export const ConstructorLoadable = (props) => {
|
|
5
6
|
const { itemMap } = useContext(InnerContext);
|
|
6
7
|
const { block, blockKey, config, serviceId, params } = props;
|
|
7
8
|
const { type } = block;
|
|
8
9
|
const { fetch, component: ChildComponent } = config;
|
|
9
10
|
const Component = itemMap[type];
|
|
10
|
-
return (React.createElement(
|
|
11
|
+
return (React.createElement(BlockIdContext.Provider, { value: blockKey, key: blockKey },
|
|
12
|
+
React.createElement(Loadable, { key: blockKey, block: block, blockKey: blockKey, Component: Component, ChildComponent: ChildComponent, fetch: fetch, serviceId: serviceId, params: params })));
|
|
11
13
|
};
|