@gravity-ui/page-constructor 3.1.0 → 3.1.2
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/components/BlockBase/BlockBase.js +2 -2
- package/build/cjs/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.d.ts +2 -2
- package/build/cjs/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js +2 -2
- package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +5 -3
- package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +1 -1
- package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +4 -2
- package/build/cjs/customization/BlockDecoration.d.ts +1 -1
- package/build/cjs/customization/BlockDecoration.js +4 -8
- package/build/cjs/models/constructor-items/blocks.d.ts +1 -0
- package/build/cjs/models/customization.d.ts +1 -1
- package/build/cjs/navigation/components/Header/Header.js +10 -3
- package/build/cjs/utils/blocks.d.ts +0 -1
- package/build/cjs/utils/blocks.js +1 -3
- package/build/esm/components/BlockBase/BlockBase.js +2 -2
- package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.d.ts +2 -2
- package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js +2 -2
- package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +5 -3
- package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +1 -1
- package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +4 -2
- package/build/esm/customization/BlockDecoration.d.ts +1 -1
- package/build/esm/customization/BlockDecoration.js +4 -8
- package/build/esm/models/constructor-items/blocks.d.ts +1 -0
- package/build/esm/models/customization.d.ts +1 -1
- package/build/esm/navigation/components/Header/Header.js +10 -3
- package/build/esm/utils/blocks.d.ts +0 -1
- package/build/esm/utils/blocks.js +0 -1
- package/package.json +1 -1
- package/server/models/constructor-items/blocks.d.ts +1 -0
- package/server/models/customization.d.ts +1 -1
- package/server/utils/blocks.d.ts +0 -1
- package/server/utils/blocks.js +1 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [3.1.2](https://github.com/gravity-ui/page-constructor/compare/v3.1.1...v3.1.2) (2023-06-07)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* icon size in navigation popup ([#382](https://github.com/gravity-ui/page-constructor/issues/382)) ([cb7c7b1](https://github.com/gravity-ui/page-constructor/commit/cb7c7b1031777c92f6d303c5a5f2c3de2ad1c2d8))
|
|
9
|
+
|
|
10
|
+
## [3.1.1](https://github.com/gravity-ui/page-constructor/compare/v3.1.0...v3.1.1) (2023-06-07)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* constructor items inner data structure ([#386](https://github.com/gravity-ui/page-constructor/issues/386)) ([f73ccde](https://github.com/gravity-ui/page-constructor/commit/f73ccde7369f38ec887ded7534f6907e4da8b4ac))
|
|
16
|
+
|
|
3
17
|
## [3.1.0](https://github.com/gravity-ui/page-constructor/compare/v3.0.0...v3.1.0) (2023-06-05)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -8,9 +8,9 @@ const utils_1 = require("../../utils");
|
|
|
8
8
|
const Anchor_1 = tslib_1.__importDefault(require("../Anchor/Anchor"));
|
|
9
9
|
const b = (0, utils_1.block)('block-base');
|
|
10
10
|
const BlockBase = (props) => {
|
|
11
|
-
const { anchor, visible, children, className, resetPaddings, qa } = props;
|
|
11
|
+
const { anchor, visible, children, className, resetPaddings, qa, index = 0 } = props;
|
|
12
12
|
return (react_1.default.createElement(grid_1.Col, { className: b({ ['reset-paddings']: resetPaddings }, className), visible: visible, reset: true, dataQa: qa },
|
|
13
|
-
react_1.default.createElement(BlockDecoration_1.BlockDecoration,
|
|
13
|
+
react_1.default.createElement(BlockDecoration_1.BlockDecoration, { id: index },
|
|
14
14
|
anchor && react_1.default.createElement(Anchor_1.default, { id: anchor.url, className: b('anchor') }),
|
|
15
15
|
children)));
|
|
16
16
|
};
|
package/build/cjs/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Block, WithChildren } from '../../../../models';
|
|
3
|
-
interface ConstructorBlockProps {
|
|
2
|
+
import { Block, BlockBaseProps, WithChildren } from '../../../../models';
|
|
3
|
+
interface ConstructorBlockProps extends Pick<BlockBaseProps, 'index'> {
|
|
4
4
|
data: Block;
|
|
5
5
|
}
|
|
6
6
|
export declare const ConstructorBlock: React.FC<WithChildren<ConstructorBlockProps>>;
|
package/build/cjs/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js
CHANGED
|
@@ -6,8 +6,8 @@ const react_1 = tslib_1.__importDefault(require("react"));
|
|
|
6
6
|
const BlockBase_1 = tslib_1.__importDefault(require("../../../../components/BlockBase/BlockBase"));
|
|
7
7
|
const utils_1 = require("../../../../utils");
|
|
8
8
|
const b = (0, utils_1.block)('constructor-block');
|
|
9
|
-
const ConstructorBlock = ({ data, children, }) => {
|
|
9
|
+
const ConstructorBlock = ({ index = 0, data, children, }) => {
|
|
10
10
|
const { anchor, visible, type } = data;
|
|
11
|
-
return (react_1.default.createElement(BlockBase_1.default, { className: b({ type }), anchor: anchor, visible: visible, resetPaddings: data.resetPaddings }, children));
|
|
11
|
+
return (react_1.default.createElement(BlockBase_1.default, { index: index, className: b({ type }), anchor: anchor, visible: visible, resetPaddings: data.resetPaddings }, children));
|
|
12
12
|
};
|
|
13
13
|
exports.ConstructorBlock = ConstructorBlock;
|
package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.ConstructorBlocks = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
6
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
7
|
-
const blockIdContext_1 = require("../../../../context/blockIdContext");
|
|
8
7
|
const innerContext_1 = require("../../../../context/innerContext");
|
|
9
8
|
const utils_1 = require("../../../../utils");
|
|
10
9
|
const ConstructorBlock_1 = require("../ConstructorBlock/ConstructorBlock");
|
|
@@ -35,9 +34,12 @@ const ConstructorBlocks = ({ items }) => {
|
|
|
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(ConstructorItem_1.ConstructorItem, { data: item, blockKey: blockId }, children));
|
|
37
|
+
itemElement = (react_1.default.createElement(ConstructorItem_1.ConstructorItem, { data: item, key: blockId, blockKey: blockId }, children));
|
|
39
38
|
}
|
|
40
|
-
return
|
|
39
|
+
return blockTypes.includes(item.type) ? (
|
|
40
|
+
//TODO: replace ConstructorBlock (and delete it) with BlockBase when all
|
|
41
|
+
// components relying on constructor inner structure like Slider or blog-constructor will be refactored
|
|
42
|
+
react_1.default.createElement(ConstructorBlock_1.ConstructorBlock, { data: item, key: blockId, index: index }, itemElement)) : (itemElement);
|
|
41
43
|
};
|
|
42
44
|
return react_1.default.createElement(react_1.Fragment, null, items.map(renderer.bind(null, '')));
|
|
43
45
|
};
|
package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export interface ConstructorItemProps {
|
|
|
3
3
|
data: ConstructorItemType;
|
|
4
4
|
blockKey: string;
|
|
5
5
|
}
|
|
6
|
-
export declare const ConstructorItem: ({ data, children }: WithChildren<ConstructorItemProps>) => JSX.Element;
|
|
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;
|
|
@@ -3,13 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ConstructorHeader = exports.ConstructorItem = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
const blockIdContext_1 = require("../../../../context/blockIdContext");
|
|
6
7
|
const innerContext_1 = require("../../../../context/innerContext");
|
|
7
8
|
const BlockDecoration_1 = require("../../../../customization/BlockDecoration");
|
|
8
|
-
const ConstructorItem = ({ data, children }) => {
|
|
9
|
+
const ConstructorItem = ({ data, blockKey, children }) => {
|
|
9
10
|
const { itemMap } = (0, react_1.useContext)(innerContext_1.InnerContext);
|
|
10
11
|
const { type } = data, rest = tslib_1.__rest(data, ["type"]);
|
|
11
12
|
const Component = itemMap[type];
|
|
12
|
-
return react_1.default.createElement(
|
|
13
|
+
return (react_1.default.createElement(blockIdContext_1.BlockIdContext.Provider, { value: blockKey },
|
|
14
|
+
react_1.default.createElement(Component, Object.assign({}, rest), children)));
|
|
13
15
|
};
|
|
14
16
|
exports.ConstructorItem = ConstructorItem;
|
|
15
17
|
const ConstructorHeader = ({ data, blockKey, }) => (react_1.default.createElement(BlockDecoration_1.BlockDecoration, { id: data.type },
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { BlockDecorationProps } from '../models';
|
|
3
|
-
export declare const BlockDecoration: (
|
|
3
|
+
export declare const BlockDecoration: ({ id, children: blockChildren, }: PropsWithChildren<BlockDecorationProps>) => JSX.Element;
|
|
@@ -3,20 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BlockDecoration = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
-
const blockIdContext_1 = require("../context/blockIdContext");
|
|
7
6
|
const innerContext_1 = require("../context/innerContext");
|
|
8
|
-
const
|
|
9
|
-
const BlockDecoration = (props) => {
|
|
7
|
+
const BlockDecoration = ({ id, children: blockChildren, }) => {
|
|
10
8
|
var _a, _b;
|
|
11
|
-
const blockContenxtId = (0, utils_1.getBlockIndexFromId)((0, react_1.useContext)(blockIdContext_1.BlockIdContext));
|
|
12
9
|
const { headerBlockTypes } = (0, react_1.useContext)(innerContext_1.InnerContext);
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const block = react_1.default.createElement(react_1.Fragment, null, props.children);
|
|
10
|
+
const isHeader = Boolean(typeof id === 'string' && headerBlockTypes.includes(id));
|
|
11
|
+
const block = react_1.default.createElement(react_1.Fragment, null, blockChildren);
|
|
16
12
|
const blockDecorators = (_b = (_a = (0, react_1.useContext)(innerContext_1.InnerContext).customization) === null || _a === void 0 ? void 0 : _a.decorators) === null || _b === void 0 ? void 0 : _b.block;
|
|
17
13
|
if (!blockDecorators) {
|
|
18
14
|
return block;
|
|
19
15
|
}
|
|
20
|
-
return blockDecorators.reduce((children, decorator) =>
|
|
16
|
+
return blockDecorators.reduce((children, decorator) => react_1.default.createElement(react_1.Fragment, null, decorator({ children, id, isHeader })), block);
|
|
21
17
|
};
|
|
22
18
|
exports.BlockDecoration = BlockDecoration;
|
|
@@ -7,6 +7,7 @@ const Control_1 = tslib_1.__importDefault(require("../../../components/Control/C
|
|
|
7
7
|
const OutsideClick_1 = tslib_1.__importDefault(require("../../../components/OutsideClick/OutsideClick"));
|
|
8
8
|
const grid_1 = require("../../../grid");
|
|
9
9
|
const icons_1 = require("../../../icons");
|
|
10
|
+
const models_1 = require("../../../models");
|
|
10
11
|
const utils_1 = require("../../../utils");
|
|
11
12
|
const constants_1 = require("../../constants");
|
|
12
13
|
const Logo_1 = tslib_1.__importDefault(require("../Logo/Logo"));
|
|
@@ -26,15 +27,21 @@ const MobileMenuButton = ({ isSidebarOpened, onSidebarOpenedChange, }) => {
|
|
|
26
27
|
}, size: "l" }, iconProps)));
|
|
27
28
|
};
|
|
28
29
|
const iconSizeKey = 'iconSize';
|
|
30
|
+
const isButtonItem = (item) => item.type === models_1.NavigationItemType.Button;
|
|
31
|
+
const isDropdownItem = (item) => item.type === models_1.NavigationItemType.Dropdown;
|
|
29
32
|
const Header = ({ data, logo }) => {
|
|
30
33
|
const { leftItems, rightItems, iconSize = 20 } = data;
|
|
31
34
|
const [isSidebarOpened, setIsSidebarOpened] = (0, react_1.useState)(false);
|
|
32
35
|
const [activeItemId, setactiveItemId] = (0, react_1.useState)(undefined);
|
|
33
36
|
const getNavigationItemWithIconSize = (0, react_1.useCallback)((item) => {
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
const newItem = Object.assign({}, item);
|
|
38
|
+
if ('items' in newItem && isDropdownItem(newItem)) {
|
|
39
|
+
newItem.items = newItem.items.map(getNavigationItemWithIconSize);
|
|
36
40
|
}
|
|
37
|
-
|
|
41
|
+
if (!(iconSizeKey in newItem) && !isButtonItem(newItem)) {
|
|
42
|
+
newItem.iconSize = iconSize;
|
|
43
|
+
}
|
|
44
|
+
return newItem;
|
|
38
45
|
}, [iconSize]);
|
|
39
46
|
const leftItemsWithIconSize = (0, react_1.useMemo)(() => leftItems.map(getNavigationItemWithIconSize), [getNavigationItemWithIconSize, leftItems]);
|
|
40
47
|
const rightItemsWithIconSize = (0, react_1.useMemo)(() => rightItems === null || rightItems === void 0 ? void 0 : rightItems.map(getNavigationItemWithIconSize), [getNavigationItemWithIconSize, rightItems]);
|
|
@@ -11,4 +11,3 @@ export declare const getCustomHeaderTypes: (customBlocks?: CustomConfig) => stri
|
|
|
11
11
|
export declare const getOrderedBlocks: (blocks: Block[], headerBlockTypes?: string[]) => Block[];
|
|
12
12
|
export declare const getHeaderBlock: (blocks: Block[], headerBlockTypes?: string[]) => Block | undefined;
|
|
13
13
|
export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string, text?: string) => string | undefined;
|
|
14
|
-
export declare const getBlockIndexFromId: (blockId?: string) => number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getShareLink = exports.getHeaderBlock = exports.getOrderedBlocks = exports.getCustomHeaderTypes = exports.getCustomSubBlockTypes = 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) {
|
|
@@ -83,5 +83,3 @@ const getShareLink = (url, type, title, text) => {
|
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
exports.getShareLink = getShareLink;
|
|
86
|
-
const getBlockIndexFromId = (blockId) => { var _a; return Number((_a = blockId === null || blockId === void 0 ? void 0 : blockId.split('-')) === null || _a === void 0 ? void 0 : _a.slice(-1).pop()); };
|
|
87
|
-
exports.getBlockIndexFromId = getBlockIndexFromId;
|
|
@@ -6,9 +6,9 @@ import Anchor from '../Anchor/Anchor';
|
|
|
6
6
|
import './BlockBase.css';
|
|
7
7
|
const b = block('block-base');
|
|
8
8
|
const BlockBase = (props) => {
|
|
9
|
-
const { anchor, visible, children, className, resetPaddings, qa } = props;
|
|
9
|
+
const { anchor, visible, children, className, resetPaddings, qa, index = 0 } = props;
|
|
10
10
|
return (React.createElement(Col, { className: b({ ['reset-paddings']: resetPaddings }, className), visible: visible, reset: true, dataQa: qa },
|
|
11
|
-
React.createElement(BlockDecoration,
|
|
11
|
+
React.createElement(BlockDecoration, { id: index },
|
|
12
12
|
anchor && React.createElement(Anchor, { id: anchor.url, className: b('anchor') }),
|
|
13
13
|
children)));
|
|
14
14
|
};
|
package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Block, WithChildren } from '../../../../models';
|
|
3
|
-
interface ConstructorBlockProps {
|
|
2
|
+
import { Block, BlockBaseProps, WithChildren } from '../../../../models';
|
|
3
|
+
interface ConstructorBlockProps extends Pick<BlockBaseProps, 'index'> {
|
|
4
4
|
data: Block;
|
|
5
5
|
}
|
|
6
6
|
export declare const ConstructorBlock: React.FC<WithChildren<ConstructorBlockProps>>;
|
package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import BlockBase from '../../../../components/BlockBase/BlockBase';
|
|
3
3
|
import { block } from '../../../../utils';
|
|
4
4
|
const b = block('constructor-block');
|
|
5
|
-
export const ConstructorBlock = ({ data, children, }) => {
|
|
5
|
+
export const ConstructorBlock = ({ index = 0, data, children, }) => {
|
|
6
6
|
const { anchor, visible, type } = data;
|
|
7
|
-
return (React.createElement(BlockBase, { className: b({ type }), anchor: anchor, visible: visible, resetPaddings: data.resetPaddings }, children));
|
|
7
|
+
return (React.createElement(BlockBase, { index: index, className: b({ type }), anchor: anchor, visible: visible, resetPaddings: data.resetPaddings }, children));
|
|
8
8
|
};
|
package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { Fragment, useContext } from 'react';
|
|
2
2
|
import _ from 'lodash';
|
|
3
|
-
import { BlockIdContext } from '../../../../context/blockIdContext';
|
|
4
3
|
import { InnerContext } from '../../../../context/innerContext';
|
|
5
4
|
import { getBlockKey } from '../../../../utils';
|
|
6
5
|
import { ConstructorBlock } from '../ConstructorBlock/ConstructorBlock';
|
|
@@ -31,9 +30,12 @@ export const ConstructorBlocks = ({ items }) => {
|
|
|
31
30
|
if ('children' in item && item.children) {
|
|
32
31
|
children = item.children.map(renderer.bind(null, blockId));
|
|
33
32
|
}
|
|
34
|
-
itemElement = (React.createElement(ConstructorItem, { data: item, blockKey: blockId }, children));
|
|
33
|
+
itemElement = (React.createElement(ConstructorItem, { data: item, key: blockId, blockKey: blockId }, children));
|
|
35
34
|
}
|
|
36
|
-
return
|
|
35
|
+
return blockTypes.includes(item.type) ? (
|
|
36
|
+
//TODO: replace ConstructorBlock (and delete it) with BlockBase when all
|
|
37
|
+
// components relying on constructor inner structure like Slider or blog-constructor will be refactored
|
|
38
|
+
React.createElement(ConstructorBlock, { data: item, key: blockId, index: index }, itemElement)) : (itemElement);
|
|
37
39
|
};
|
|
38
40
|
return React.createElement(Fragment, null, items.map(renderer.bind(null, '')));
|
|
39
41
|
};
|
package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export interface ConstructorItemProps {
|
|
|
3
3
|
data: ConstructorItemType;
|
|
4
4
|
blockKey: string;
|
|
5
5
|
}
|
|
6
|
-
export declare const ConstructorItem: ({ data, children }: WithChildren<ConstructorItemProps>) => JSX.Element;
|
|
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;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
|
+
import { BlockIdContext } from '../../../../context/blockIdContext';
|
|
3
4
|
import { InnerContext } from '../../../../context/innerContext';
|
|
4
5
|
import { BlockDecoration } from '../../../../customization/BlockDecoration';
|
|
5
|
-
export const ConstructorItem = ({ data, children }) => {
|
|
6
|
+
export const ConstructorItem = ({ data, blockKey, children }) => {
|
|
6
7
|
const { itemMap } = useContext(InnerContext);
|
|
7
8
|
const { type } = data, rest = __rest(data, ["type"]);
|
|
8
9
|
const Component = itemMap[type];
|
|
9
|
-
return React.createElement(
|
|
10
|
+
return (React.createElement(BlockIdContext.Provider, { value: blockKey },
|
|
11
|
+
React.createElement(Component, Object.assign({}, rest), children)));
|
|
10
12
|
};
|
|
11
13
|
export const ConstructorHeader = ({ data, blockKey, }) => (React.createElement(BlockDecoration, { id: data.type },
|
|
12
14
|
React.createElement(ConstructorItem, { data: data, key: data.type, blockKey: blockKey })));
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { BlockDecorationProps } from '../models';
|
|
3
|
-
export declare const BlockDecoration: (
|
|
3
|
+
export declare const BlockDecoration: ({ id, children: blockChildren, }: PropsWithChildren<BlockDecorationProps>) => JSX.Element;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import React, { Fragment, useContext } from 'react';
|
|
2
|
-
import { BlockIdContext } from '../context/blockIdContext';
|
|
3
2
|
import { InnerContext } from '../context/innerContext';
|
|
4
|
-
|
|
5
|
-
export const BlockDecoration = (props) => {
|
|
3
|
+
export const BlockDecoration = ({ id, children: blockChildren, }) => {
|
|
6
4
|
var _a, _b;
|
|
7
|
-
const blockContenxtId = getBlockIndexFromId(useContext(BlockIdContext));
|
|
8
5
|
const { headerBlockTypes } = useContext(InnerContext);
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const block = React.createElement(Fragment, null, props.children);
|
|
6
|
+
const isHeader = Boolean(typeof id === 'string' && headerBlockTypes.includes(id));
|
|
7
|
+
const block = React.createElement(Fragment, null, blockChildren);
|
|
12
8
|
const blockDecorators = (_b = (_a = useContext(InnerContext).customization) === null || _a === void 0 ? void 0 : _a.decorators) === null || _b === void 0 ? void 0 : _b.block;
|
|
13
9
|
if (!blockDecorators) {
|
|
14
10
|
return block;
|
|
15
11
|
}
|
|
16
|
-
return blockDecorators.reduce((children, decorator) =>
|
|
12
|
+
return blockDecorators.reduce((children, decorator) => React.createElement(Fragment, null, decorator({ children, id, isHeader })), block);
|
|
17
13
|
};
|
|
@@ -3,6 +3,7 @@ import Control from '../../../components/Control/Control';
|
|
|
3
3
|
import OutsideClick from '../../../components/OutsideClick/OutsideClick';
|
|
4
4
|
import { Col, Grid, Row } from '../../../grid';
|
|
5
5
|
import { NavigationClose, NavigationOpen } from '../../../icons';
|
|
6
|
+
import { NavigationItemType, } from '../../../models';
|
|
6
7
|
import { block } from '../../../utils';
|
|
7
8
|
import { ItemColumnName } from '../../constants';
|
|
8
9
|
import Logo from '../Logo/Logo';
|
|
@@ -23,15 +24,21 @@ const MobileMenuButton = ({ isSidebarOpened, onSidebarOpenedChange, }) => {
|
|
|
23
24
|
}, size: "l" }, iconProps)));
|
|
24
25
|
};
|
|
25
26
|
const iconSizeKey = 'iconSize';
|
|
27
|
+
const isButtonItem = (item) => item.type === NavigationItemType.Button;
|
|
28
|
+
const isDropdownItem = (item) => item.type === NavigationItemType.Dropdown;
|
|
26
29
|
export const Header = ({ data, logo }) => {
|
|
27
30
|
const { leftItems, rightItems, iconSize = 20 } = data;
|
|
28
31
|
const [isSidebarOpened, setIsSidebarOpened] = useState(false);
|
|
29
32
|
const [activeItemId, setactiveItemId] = useState(undefined);
|
|
30
33
|
const getNavigationItemWithIconSize = useCallback((item) => {
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
const newItem = Object.assign({}, item);
|
|
35
|
+
if ('items' in newItem && isDropdownItem(newItem)) {
|
|
36
|
+
newItem.items = newItem.items.map(getNavigationItemWithIconSize);
|
|
33
37
|
}
|
|
34
|
-
|
|
38
|
+
if (!(iconSizeKey in newItem) && !isButtonItem(newItem)) {
|
|
39
|
+
newItem.iconSize = iconSize;
|
|
40
|
+
}
|
|
41
|
+
return newItem;
|
|
35
42
|
}, [iconSize]);
|
|
36
43
|
const leftItemsWithIconSize = useMemo(() => leftItems.map(getNavigationItemWithIconSize), [getNavigationItemWithIconSize, leftItems]);
|
|
37
44
|
const rightItemsWithIconSize = useMemo(() => rightItems === null || rightItems === void 0 ? void 0 : rightItems.map(getNavigationItemWithIconSize), [getNavigationItemWithIconSize, rightItems]);
|
|
@@ -11,4 +11,3 @@ export declare const getCustomHeaderTypes: (customBlocks?: CustomConfig) => stri
|
|
|
11
11
|
export declare const getOrderedBlocks: (blocks: Block[], headerBlockTypes?: string[]) => Block[];
|
|
12
12
|
export declare const getHeaderBlock: (blocks: Block[], headerBlockTypes?: string[]) => Block | undefined;
|
|
13
13
|
export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string, text?: string) => string | undefined;
|
|
14
|
-
export declare const getBlockIndexFromId: (blockId?: string) => number;
|
|
@@ -71,4 +71,3 @@ export const getShareLink = (url, type, title, text) => {
|
|
|
71
71
|
return undefined;
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
|
-
export const getBlockIndexFromId = (blockId) => { var _a; return Number((_a = blockId === null || blockId === void 0 ? void 0 : blockId.split('-')) === null || _a === void 0 ? void 0 : _a.slice(-1).pop()); };
|
package/package.json
CHANGED
package/server/utils/blocks.d.ts
CHANGED
|
@@ -11,4 +11,3 @@ export declare const getCustomHeaderTypes: (customBlocks?: CustomConfig) => stri
|
|
|
11
11
|
export declare const getOrderedBlocks: (blocks: Block[], headerBlockTypes?: string[]) => Block[];
|
|
12
12
|
export declare const getHeaderBlock: (blocks: Block[], headerBlockTypes?: string[]) => Block | undefined;
|
|
13
13
|
export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string, text?: string) => string | undefined;
|
|
14
|
-
export declare const getBlockIndexFromId: (blockId?: string) => number;
|
package/server/utils/blocks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getShareLink = exports.getHeaderBlock = exports.getOrderedBlocks = exports.getCustomHeaderTypes = exports.getCustomSubBlockTypes = 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) {
|
|
@@ -83,5 +83,3 @@ const getShareLink = (url, type, title, text) => {
|
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
exports.getShareLink = getShareLink;
|
|
86
|
-
const getBlockIndexFromId = (blockId) => { var _a; return Number((_a = blockId === null || blockId === void 0 ? void 0 : blockId.split('-')) === null || _a === void 0 ? void 0 : _a.slice(-1).pop()); };
|
|
87
|
-
exports.getBlockIndexFromId = getBlockIndexFromId;
|