@gravity-ui/page-constructor 1.20.4 → 1.21.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/blocks/CardLayout/CardLayout.d.ts +3 -5
- package/build/cjs/blocks/CardLayout/CardLayout.js +2 -6
- package/build/cjs/blocks/FilterBlock/FilterBlock.css +50 -0
- package/build/cjs/blocks/FilterBlock/FilterBlock.d.ts +4 -0
- package/build/cjs/blocks/FilterBlock/FilterBlock.js +48 -0
- package/build/cjs/blocks/FilterBlock/i18n/en.json +3 -0
- package/build/cjs/blocks/FilterBlock/i18n/index.d.ts +2 -0
- package/build/cjs/blocks/FilterBlock/i18n/index.js +8 -0
- package/build/cjs/blocks/FilterBlock/i18n/ru.json +3 -0
- package/build/cjs/blocks/FilterBlock/schema.d.ts +229 -0
- package/build/cjs/blocks/FilterBlock/schema.js +41 -0
- package/build/cjs/blocks/Tabs/Tabs.css +27 -18
- package/build/cjs/blocks/index.d.ts +1 -0
- package/build/cjs/blocks/index.js +3 -1
- package/build/cjs/components/Button/Button.css +4 -0
- package/build/cjs/components/ButtonTabs/ButtonTabs.css +16 -3
- package/build/cjs/components/ButtonTabs/ButtonTabs.d.ts +7 -4
- package/build/cjs/components/ButtonTabs/ButtonTabs.js +2 -6
- package/build/cjs/constructor-items.d.ts +2 -1
- package/build/cjs/constructor-items.js +1 -0
- package/build/cjs/containers/PageConstructor/PageConstructor.css +8 -0
- package/build/cjs/containers/PageConstructor/PageConstructor.js +13 -14
- package/build/cjs/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.d.ts +3 -5
- package/build/cjs/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js +3 -3
- package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.d.ts +3 -3
- package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +5 -7
- 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/cjs/context/innerContext/InnerContext.d.ts +4 -1
- package/build/cjs/context/innerContext/InnerContext.js +2 -0
- package/build/cjs/models/constructor-items/blocks.d.ts +26 -3
- package/build/cjs/models/constructor-items/blocks.js +1 -0
- package/build/cjs/utils/blocks.d.ts +1 -0
- package/build/cjs/utils/blocks.js +6 -1
- package/build/esm/blocks/CardLayout/CardLayout.d.ts +3 -5
- package/build/esm/blocks/CardLayout/CardLayout.js +3 -7
- package/build/esm/blocks/FilterBlock/FilterBlock.css +50 -0
- package/build/esm/blocks/FilterBlock/FilterBlock.d.ts +5 -0
- package/build/esm/blocks/FilterBlock/FilterBlock.js +46 -0
- package/build/esm/blocks/FilterBlock/i18n/en.json +3 -0
- package/build/esm/blocks/FilterBlock/i18n/index.d.ts +2 -0
- package/build/esm/blocks/FilterBlock/i18n/index.js +5 -0
- package/build/esm/blocks/FilterBlock/i18n/ru.json +3 -0
- package/build/esm/blocks/FilterBlock/schema.d.ts +229 -0
- package/build/esm/blocks/FilterBlock/schema.js +38 -0
- package/build/esm/blocks/Tabs/Tabs.css +27 -18
- package/build/esm/blocks/index.d.ts +1 -0
- package/build/esm/blocks/index.js +1 -0
- package/build/esm/components/Button/Button.css +4 -0
- package/build/esm/components/ButtonTabs/ButtonTabs.css +16 -3
- package/build/esm/components/ButtonTabs/ButtonTabs.d.ts +7 -4
- package/build/esm/components/ButtonTabs/ButtonTabs.js +2 -6
- package/build/esm/constructor-items.d.ts +2 -1
- package/build/esm/constructor-items.js +2 -1
- package/build/esm/containers/PageConstructor/PageConstructor.css +8 -0
- package/build/esm/containers/PageConstructor/PageConstructor.js +15 -16
- package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.d.ts +3 -5
- package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js +3 -3
- package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.d.ts +3 -3
- package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +5 -7
- 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/build/esm/context/innerContext/InnerContext.d.ts +4 -1
- package/build/esm/context/innerContext/InnerContext.js +2 -0
- package/build/esm/models/constructor-items/blocks.d.ts +26 -3
- package/build/esm/models/constructor-items/blocks.js +1 -0
- package/build/esm/utils/blocks.d.ts +1 -0
- package/build/esm/utils/blocks.js +4 -0
- package/package.json +1 -1
- package/server/models/constructor-items/blocks.d.ts +26 -3
- package/server/models/constructor-items/blocks.js +1 -0
- package/server/utils/blocks.d.ts +1 -0
- package/server/utils/blocks.js +6 -1
- package/styles/mixins.scss +62 -5
- package/styles/root.scss +10 -0
|
@@ -19,6 +19,14 @@ unpredictable css rules order in build */
|
|
|
19
19
|
--pc-monochrome-button-color: var(--yc-color-text-light-primary);
|
|
20
20
|
--pc-text-header-color: var(--yc-color-text-primary);
|
|
21
21
|
--pc-media-card-meta-info-color: var(--yc-color-text-secondary);
|
|
22
|
+
--pc-tab-item-color: var(--yc-color-text-primary);
|
|
23
|
+
--pc-tab-item-background-color: var(--yc-color-base-generic);
|
|
24
|
+
--pc-tab-item-background-color-hover: var(--yc-color-base-generic-hover);
|
|
25
|
+
--pc-selected-tab-item-color: var(--pc-monochrome-button-color);
|
|
26
|
+
--pc-selected-tab-item-background-color: var(--pc-monochrome-button-background-color);
|
|
27
|
+
--pc-selected-tab-item-background-color-hover: var(
|
|
28
|
+
--pc-monochrome-button-background-color-hover
|
|
29
|
+
);
|
|
22
30
|
}
|
|
23
31
|
.yc-root.yc-root_theme_dark {
|
|
24
32
|
--pc-color-sfx-shadow: var(--yc-color-sfx-shadow);
|
|
@@ -19,21 +19,20 @@ const ConstructorBlocks_1 = require("./components/ConstructorBlocks");
|
|
|
19
19
|
const Layout_1 = tslib_1.__importDefault(require("../../navigation/containers/Layout/Layout"));
|
|
20
20
|
const b = (0, utils_1.block)('page-constructor');
|
|
21
21
|
const Constructor = (props) => {
|
|
22
|
-
const {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
}, [
|
|
22
|
+
const { content: { blocks = [], background = {}, footnotes = [] } = {}, renderMenu, shouldRenderBlock, navigation, custom, } = props;
|
|
23
|
+
const { context } = (0, react_1.useMemo)(() => ({
|
|
24
|
+
context: {
|
|
25
|
+
blockTypes: [...models_1.BlockTypes, ...(0, utils_1.getCustomBlockTypes)(custom)],
|
|
26
|
+
subBlockTypes: [...models_1.SubBlockTypes, ...(0, utils_1.getCustomSubBlockTypes)(custom)],
|
|
27
|
+
headerBlockTypes: [...models_1.HeaderBlockTypes, ...(0, utils_1.getCustomHeaderTypes)(custom)],
|
|
28
|
+
itemMap: Object.assign(Object.assign(Object.assign({}, constructor_items_1.blockMap), constructor_items_1.subBlockMap), (0, utils_1.getCustomItems)(custom)),
|
|
29
|
+
loadables: custom === null || custom === void 0 ? void 0 : custom.loadable,
|
|
30
|
+
shouldRenderBlock,
|
|
31
|
+
},
|
|
32
|
+
}), [custom, shouldRenderBlock]);
|
|
33
33
|
const { themeValue: theme } = (0, react_1.useContext)(ThemeValueContext_1.ThemeValueContext);
|
|
34
|
-
const { content: { blocks = [], background = {}, footnotes = [] } = {}, renderMenu, shouldRenderBlock, navigation, } = props;
|
|
35
34
|
const hasFootnotes = footnotes.length > 0;
|
|
36
|
-
const isHeaderBlock = (block) => headerBlockTypes.includes(block.type);
|
|
35
|
+
const isHeaderBlock = (block) => context.headerBlockTypes.includes(block.type);
|
|
37
36
|
const header = blocks === null || blocks === void 0 ? void 0 : blocks.find(isHeaderBlock);
|
|
38
37
|
const restBlocks = blocks === null || blocks === void 0 ? void 0 : blocks.filter((block) => !isHeaderBlock(block));
|
|
39
38
|
const themedBackground = (0, utils_1.getThemedValue)(background, theme);
|
|
@@ -46,7 +45,7 @@ const Constructor = (props) => {
|
|
|
46
45
|
header && react_1.default.createElement(ConstructorItem_1.ConstructorHeader, { data: header }),
|
|
47
46
|
react_1.default.createElement(grid_1.Grid, null,
|
|
48
47
|
restBlocks && (react_1.default.createElement(ConstructorRow_1.ConstructorRow, null,
|
|
49
|
-
react_1.default.createElement(ConstructorBlocks_1.ConstructorBlocks, { items: restBlocks
|
|
48
|
+
react_1.default.createElement(ConstructorBlocks_1.ConstructorBlocks, { items: restBlocks }))),
|
|
50
49
|
hasFootnotes && (react_1.default.createElement(ConstructorRow_1.ConstructorRow, null,
|
|
51
50
|
react_1.default.createElement(ConstructorFootnotes_1.ConstructorFootnotes, { items: footnotes })))))))));
|
|
52
51
|
};
|
package/build/cjs/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Block,
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Block, WithChildren } from '../../../../models';
|
|
3
3
|
interface ConstructorBlockProps {
|
|
4
4
|
data: Block;
|
|
5
|
-
Component: ReactElement;
|
|
6
|
-
shouldRenderBlock?: ShouldRenderBlock;
|
|
7
5
|
}
|
|
8
|
-
export declare const ConstructorBlock:
|
|
6
|
+
export declare const ConstructorBlock: React.FC<WithChildren<ConstructorBlockProps>>;
|
|
9
7
|
export {};
|
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,
|
|
10
|
-
const { anchor, visible } = data;
|
|
11
|
-
return (react_1.default.createElement(BlockBase_1.default, { className: b({ type
|
|
9
|
+
const ConstructorBlock = ({ data, children, }) => {
|
|
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));
|
|
12
12
|
};
|
|
13
13
|
exports.ConstructorBlock = ConstructorBlock;
|
package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ConstructorItem as ConstructorItemType } from '../../../../models';
|
|
2
3
|
interface ConstructorBlocksProps {
|
|
3
4
|
items: ConstructorItemType[];
|
|
4
|
-
shouldRenderBlock?: ShouldRenderBlock;
|
|
5
5
|
}
|
|
6
|
-
export declare const ConstructorBlocks:
|
|
6
|
+
export declare const ConstructorBlocks: React.FC<ConstructorBlocksProps>;
|
|
7
7
|
export {};
|
package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js
CHANGED
|
@@ -6,17 +6,15 @@ 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");
|
|
13
|
-
const ConstructorBlocks = ({ items
|
|
14
|
-
const { blockTypes, loadables, itemMap } = (0, react_1.useContext)(innerContext_1.InnerContext);
|
|
12
|
+
const ConstructorBlocks = ({ items }) => {
|
|
13
|
+
const { blockTypes, loadables, itemMap, shouldRenderBlock } = (0, react_1.useContext)(innerContext_1.InnerContext);
|
|
15
14
|
const renderer = (parentId = '', item, index) => {
|
|
16
15
|
if (!itemMap[item.type]) {
|
|
17
16
|
return null;
|
|
18
17
|
}
|
|
19
|
-
let children;
|
|
20
18
|
let itemElement;
|
|
21
19
|
const key = (0, utils_1.getBlockKey)(item, index);
|
|
22
20
|
const blockId = parentId ? `${parentId}_${key}` : key;
|
|
@@ -32,13 +30,13 @@ const ConstructorBlocks = ({ items, shouldRenderBlock }) => {
|
|
|
32
30
|
itemElement = (react_1.default.createElement(ConstructorLoadable_1.ConstructorLoadable, { block: item, key: blockId, blockKey: blockId, config: config, serviceId: serviceId, params: params }));
|
|
33
31
|
}
|
|
34
32
|
else {
|
|
33
|
+
let children;
|
|
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
|
-
return blockTypes.includes(item.type) ? (react_1.default.createElement(ConstructorBlock_1.ConstructorBlock, { data: item, key: blockId,
|
|
39
|
+
return blockTypes.includes(item.type) ? (react_1.default.createElement(ConstructorBlock_1.ConstructorBlock, { data: item, key: blockId }, itemElement)) : (itemElement);
|
|
42
40
|
};
|
|
43
41
|
return react_1.default.createElement(react_1.Fragment, null, items.map(renderer.bind(null, '')));
|
|
44
42
|
};
|
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;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ItemMap } from '../../containers/PageConstructor/PageConstructor';
|
|
3
|
-
import { LoadableConfig } from '../../models';
|
|
3
|
+
import { LoadableConfig, ShouldRenderBlock } from '../../models';
|
|
4
4
|
export interface InnerContextType {
|
|
5
5
|
blockTypes: string[];
|
|
6
|
+
subBlockTypes: string[];
|
|
7
|
+
headerBlockTypes: string[];
|
|
6
8
|
itemMap: ItemMap;
|
|
7
9
|
loadables?: LoadableConfig;
|
|
10
|
+
shouldRenderBlock?: ShouldRenderBlock;
|
|
8
11
|
}
|
|
9
12
|
export declare const InnerContext: React.Context<InnerContextType>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { ButtonSize } from '@gravity-ui/uikit';
|
|
2
3
|
import { BackgroundImageProps, ButtonProps, ContentSize, ContentTextSize, ContentTheme, FileLinkProps, HeaderBreadCrumbsProps, HeaderImageSize, HeaderOffset, HeaderWidth, Justify, LinkProps, LinkTheme, MediaDirection, MediaProps, MapProps, PreviewItemProps, PreviewRatioMediaContent, TextSize, TextTheme, ThemedImage, ThemedMediaProps, ThemedMediaVideoProps, TitleProps, LegendTableMarkerType, AnchorProps, TitleBaseProps, Animatable, BlockHeaderProps, ImageDeviceProps } from './common';
|
|
3
4
|
import { ThemeSupporting } from '../../utils';
|
|
4
5
|
import { GridColumnSize, GridColumnSizesType } from '../../grid/types';
|
|
5
|
-
import { BannerCardProps, SubBlock } from './sub-blocks';
|
|
6
|
+
import { BannerCardProps, SubBlock, SubBlockModels } from './sub-blocks';
|
|
6
7
|
export declare enum BlockType {
|
|
7
8
|
PromoFeaturesBlock = "promo-features-block",
|
|
8
9
|
ExtendedFeaturesBlock = "extended-features-block",
|
|
@@ -26,7 +27,8 @@ export declare enum BlockType {
|
|
|
26
27
|
CardLayoutBlock = "card-layout-block",
|
|
27
28
|
ContentLayoutBlock = "content-layout-block",
|
|
28
29
|
ShareBlock = "share-block",
|
|
29
|
-
MapBlock = "map-block"
|
|
30
|
+
MapBlock = "map-block",
|
|
31
|
+
FilterBlock = "filter-block"
|
|
30
32
|
}
|
|
31
33
|
export declare const BlockTypes: BlockType[];
|
|
32
34
|
export declare const HeaderBlockTypes: BlockType[];
|
|
@@ -251,6 +253,24 @@ export interface CardLayoutBlockProps extends Childable, Animatable, LoadableChi
|
|
|
251
253
|
description?: string;
|
|
252
254
|
colSizes?: GridColumnSizesType;
|
|
253
255
|
}
|
|
256
|
+
export type FilterTag = {
|
|
257
|
+
id: string;
|
|
258
|
+
label: string;
|
|
259
|
+
};
|
|
260
|
+
export type FilterItem = {
|
|
261
|
+
tags: string[];
|
|
262
|
+
card: SubBlockModels;
|
|
263
|
+
};
|
|
264
|
+
export interface FilterBlockProps extends Animatable, LoadableChildren {
|
|
265
|
+
title?: TitleProps | string;
|
|
266
|
+
description?: string;
|
|
267
|
+
tags: FilterTag[];
|
|
268
|
+
items: FilterItem[];
|
|
269
|
+
tagButtonSize?: ButtonSize;
|
|
270
|
+
allTag?: boolean | string;
|
|
271
|
+
colSizes?: GridColumnSizesType;
|
|
272
|
+
centered?: boolean;
|
|
273
|
+
}
|
|
254
274
|
export interface IconsBlockProps {
|
|
255
275
|
title?: string;
|
|
256
276
|
size?: 's' | 'm' | 'l';
|
|
@@ -350,6 +370,9 @@ export type LinkTableBlockModel = {
|
|
|
350
370
|
export type CardLayoutBlockModel = {
|
|
351
371
|
type: BlockType.CardLayoutBlock;
|
|
352
372
|
} & CardLayoutBlockProps;
|
|
373
|
+
export type FilterBlockModel = {
|
|
374
|
+
type: BlockType.FilterBlock;
|
|
375
|
+
} & FilterBlockProps;
|
|
353
376
|
export type IconsBlockModel = {
|
|
354
377
|
type: BlockType.IconsBlock;
|
|
355
378
|
} & IconsBlockProps;
|
|
@@ -362,6 +385,6 @@ export type ContentLayoutBlockModel = {
|
|
|
362
385
|
export type ShareBLockModel = {
|
|
363
386
|
type: BlockType.ShareBlock;
|
|
364
387
|
} & ShareBlockProps;
|
|
365
|
-
type BlockModels = SliderBlockModel | ServiceDemoBlockModel | ExtendedFeaturesBlockModel | PromoFeaturesBlockModel | QuestionsBlockModel | CalculatorBlockModel | BannerBlockModel | CompaniesBlockModel | MediaBlockModel | MapBlockModel | InfoBlockModel | SecurityBlockModel | TableBlockModel | TabsBlockModel | SimpleBlockModel | LinkTableBlockModel | HeaderBlockModel | PreviewBlockModel | IconsBlockModel | HeaderSliderBlockModel | CardLayoutBlockModel | ContentLayoutBlockModel | ShareBLockModel;
|
|
388
|
+
type BlockModels = SliderBlockModel | ServiceDemoBlockModel | ExtendedFeaturesBlockModel | PromoFeaturesBlockModel | QuestionsBlockModel | CalculatorBlockModel | BannerBlockModel | CompaniesBlockModel | MediaBlockModel | MapBlockModel | InfoBlockModel | SecurityBlockModel | TableBlockModel | TabsBlockModel | SimpleBlockModel | LinkTableBlockModel | HeaderBlockModel | PreviewBlockModel | IconsBlockModel | HeaderSliderBlockModel | CardLayoutBlockModel | ContentLayoutBlockModel | ShareBLockModel | FilterBlockModel;
|
|
366
389
|
export type Block = BlockModels & BlockBaseProps;
|
|
367
390
|
export {};
|
|
@@ -26,6 +26,7 @@ var BlockType;
|
|
|
26
26
|
BlockType["ContentLayoutBlock"] = "content-layout-block";
|
|
27
27
|
BlockType["ShareBlock"] = "share-block";
|
|
28
28
|
BlockType["MapBlock"] = "map-block";
|
|
29
|
+
BlockType["FilterBlock"] = "filter-block";
|
|
29
30
|
})(BlockType = exports.BlockType || (exports.BlockType = {}));
|
|
30
31
|
exports.BlockTypes = Object.values(BlockType);
|
|
31
32
|
exports.HeaderBlockTypes = [BlockType.HeaderBlock, BlockType.HeaderSliderBlock];
|
|
@@ -6,5 +6,6 @@ export declare const getCustomBlockTypes: ({ blocks, headers }?: CustomConfig) =
|
|
|
6
6
|
export declare const getCustomItems: ({ blocks, headers, subBlocks }?: CustomConfig) => {
|
|
7
7
|
[x: string]: any;
|
|
8
8
|
};
|
|
9
|
+
export declare const getCustomSubBlockTypes: (customBlocks?: CustomConfig) => string[];
|
|
9
10
|
export declare const getCustomHeaderTypes: (customBlocks?: CustomConfig) => string[];
|
|
10
11
|
export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string, text?: string) => string | undefined;
|
|
@@ -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.getBlockKey = exports.getHeaderTag = void 0;
|
|
3
|
+
exports.getShareLink = 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) {
|
|
@@ -25,6 +25,11 @@ const getCustomBlockTypes = ({ blocks = {}, headers = {} } = {}) => [
|
|
|
25
25
|
exports.getCustomBlockTypes = getCustomBlockTypes;
|
|
26
26
|
const getCustomItems = ({ blocks = {}, headers = {}, subBlocks = {} } = {}) => (Object.assign(Object.assign(Object.assign({}, blocks), headers), subBlocks));
|
|
27
27
|
exports.getCustomItems = getCustomItems;
|
|
28
|
+
const getCustomSubBlockTypes = (customBlocks = {}) => {
|
|
29
|
+
const { subBlocks = {} } = customBlocks;
|
|
30
|
+
return Object.keys(subBlocks);
|
|
31
|
+
};
|
|
32
|
+
exports.getCustomSubBlockTypes = getCustomSubBlockTypes;
|
|
28
33
|
const getCustomHeaderTypes = (customBlocks = {}) => {
|
|
29
34
|
const { headers = {} } = customBlocks;
|
|
30
35
|
return Object.keys(headers);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { CardLayoutBlockProps as CardLayoutBlockParams } from '../../models';
|
|
2
|
+
import { CardLayoutBlockProps as CardLayoutBlockParams, WithChildren } from '../../models';
|
|
3
3
|
import './CardLayout.css';
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
declare const CardLayout: ({ title, description, animated, colSizes, children, }: CardLayoutBlockProps) => JSX.Element;
|
|
4
|
+
export type CardLayoutBlockProps = WithChildren<Omit<CardLayoutBlockParams, 'children'>>;
|
|
5
|
+
declare const CardLayout: React.FC<CardLayoutBlockProps>;
|
|
8
6
|
export default CardLayout;
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { block } from '../../utils';
|
|
3
|
-
import {
|
|
3
|
+
import { Col, Row } from '../../grid';
|
|
4
4
|
import { BlockHeader, AnimateBlock } from '../../components';
|
|
5
5
|
import './CardLayout.css';
|
|
6
|
-
const b = block('card-layout-block');
|
|
7
6
|
const DEFAULT_SIZES = {
|
|
8
7
|
all: 12,
|
|
9
8
|
sm: 6,
|
|
10
9
|
md: 4,
|
|
11
10
|
};
|
|
11
|
+
const b = block('card-layout-block');
|
|
12
12
|
const CardLayout = ({ title, description, animated, colSizes = DEFAULT_SIZES, children, }) => (React.createElement(AnimateBlock, { className: b(), animate: animated },
|
|
13
13
|
React.createElement(BlockHeader, { title: title, description: description }),
|
|
14
|
-
React.createElement(
|
|
15
|
-
React.createElement(Row, null, children &&
|
|
16
|
-
React.Children.map(children, (child, i) => {
|
|
17
|
-
return (React.createElement(Col, { sizes: colSizes, key: i, className: b('item') }, child));
|
|
18
|
-
})))));
|
|
14
|
+
React.createElement(Row, null, React.Children.map(children, (child, index) => (React.createElement(Col, { key: index, sizes: colSizes, className: b('item') }, child))))));
|
|
19
15
|
export default CardLayout;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
.pc-filter-block {
|
|
4
|
+
--pc-first-block-indent: 0;
|
|
5
|
+
--pc-first-block-mobile-indent: 0;
|
|
6
|
+
}
|
|
7
|
+
.pc-filter-block__title {
|
|
8
|
+
margin-bottom: 24px;
|
|
9
|
+
}
|
|
10
|
+
.pc-filter-block__title_centered {
|
|
11
|
+
text-align: center;
|
|
12
|
+
}
|
|
13
|
+
.pc-filter-block__title_centered > * {
|
|
14
|
+
margin: 0 auto;
|
|
15
|
+
}
|
|
16
|
+
.pc-filter-block__tabs {
|
|
17
|
+
margin-bottom: 0;
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-wrap: nowrap;
|
|
20
|
+
justify-content: flex-start;
|
|
21
|
+
overflow: auto;
|
|
22
|
+
}
|
|
23
|
+
.pc-filter-block__tabs_centered {
|
|
24
|
+
display: flex;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
flex-wrap: wrap;
|
|
27
|
+
}
|
|
28
|
+
@media (max-width: 769px) {
|
|
29
|
+
.pc-filter-block__tabs {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-wrap: nowrap;
|
|
32
|
+
justify-content: flex-start;
|
|
33
|
+
overflow: auto;
|
|
34
|
+
margin-left: -48px;
|
|
35
|
+
margin-right: -48px;
|
|
36
|
+
padding-left: 48px;
|
|
37
|
+
padding-right: 40px;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
@media (max-width: 577px) {
|
|
41
|
+
.pc-filter-block__tabs {
|
|
42
|
+
margin-left: -24px;
|
|
43
|
+
margin-right: -24px;
|
|
44
|
+
padding-left: 24px;
|
|
45
|
+
padding-right: 16px;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
.row .pc-filter-block__block-container.row {
|
|
49
|
+
margin: 0px;
|
|
50
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
2
|
+
import i18n from './i18n';
|
|
3
|
+
import { block } from '../../utils';
|
|
4
|
+
import { BlockType } from '../../models';
|
|
5
|
+
import { Row, Col } from '../../grid';
|
|
6
|
+
import { BlockHeader, AnimateBlock } from '../../components';
|
|
7
|
+
import ButtonTabs from '../../components/ButtonTabs/ButtonTabs';
|
|
8
|
+
import { ConstructorBlocks } from '../../containers/PageConstructor/components/ConstructorBlocks';
|
|
9
|
+
import './FilterBlock.css';
|
|
10
|
+
const b = block('filter-block');
|
|
11
|
+
const FilterBlock = ({ title, description, tags, tagButtonSize, allTag, items, colSizes, centered, animated, }) => {
|
|
12
|
+
const tabButtons = useMemo(() => {
|
|
13
|
+
const allButton = allTag
|
|
14
|
+
? { id: null, title: typeof allTag === 'boolean' ? i18n('label-all-tag') : allTag }
|
|
15
|
+
: undefined;
|
|
16
|
+
const otherButtons = tags && tags.map((tag) => ({ id: tag.id, title: tag.label }));
|
|
17
|
+
return [...(allButton ? [allButton] : []), ...(otherButtons ? otherButtons : [])];
|
|
18
|
+
}, [allTag, tags]);
|
|
19
|
+
const [selectedTag, setSelectedTag] = useState(tabButtons.length ? tabButtons[0].id : null);
|
|
20
|
+
const actualTag = useMemo(() => {
|
|
21
|
+
return tabButtons.length && !tabButtons.find((tab) => tab.id === selectedTag)
|
|
22
|
+
? tabButtons[0].id
|
|
23
|
+
: selectedTag;
|
|
24
|
+
}, [tabButtons, selectedTag]);
|
|
25
|
+
const container = useMemo(() => {
|
|
26
|
+
const itemsToShow = actualTag
|
|
27
|
+
? items.filter((item) => item.tags.includes(actualTag))
|
|
28
|
+
: items;
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
type: BlockType.CardLayoutBlock,
|
|
32
|
+
title: '',
|
|
33
|
+
colSizes: colSizes,
|
|
34
|
+
children: itemsToShow.map((item) => item.card),
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
}, [actualTag, items, colSizes]);
|
|
38
|
+
return (React.createElement(AnimateBlock, { className: b(), animate: animated },
|
|
39
|
+
title && (React.createElement(BlockHeader, { className: b('title', { centered: centered }), title: title, description: description })),
|
|
40
|
+
tabButtons.length && (React.createElement(Row, null,
|
|
41
|
+
React.createElement(Col, null,
|
|
42
|
+
React.createElement(ButtonTabs, { className: b('tabs', { centered: centered }), items: tabButtons, activeTab: selectedTag, onSelectTab: setSelectedTag, tabSize: tagButtonSize })))),
|
|
43
|
+
React.createElement(Row, { className: b('block-container') },
|
|
44
|
+
React.createElement(ConstructorBlocks, { items: container }))));
|
|
45
|
+
};
|
|
46
|
+
export default FilterBlock;
|