@gravity-ui/page-constructor 1.20.5 → 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 +7 -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 +4 -4
- 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 +4 -4
- 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,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
|
@@ -9,13 +9,12 @@ const innerContext_1 = require("../../../../context/innerContext");
|
|
|
9
9
|
const ConstructorLoadable_1 = require("../ConstructorLoadable");
|
|
10
10
|
const ConstructorItem_1 = require("../ConstructorItem");
|
|
11
11
|
const ConstructorBlock_1 = require("../ConstructorBlock/ConstructorBlock");
|
|
12
|
-
const ConstructorBlocks = ({ items
|
|
13
|
-
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);
|
|
14
14
|
const renderer = (parentId = '', item, index) => {
|
|
15
15
|
if (!itemMap[item.type]) {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
|
-
let children;
|
|
19
18
|
let itemElement;
|
|
20
19
|
const key = (0, utils_1.getBlockKey)(item, index);
|
|
21
20
|
const blockId = parentId ? `${parentId}_${key}` : key;
|
|
@@ -31,12 +30,13 @@ const ConstructorBlocks = ({ items, shouldRenderBlock }) => {
|
|
|
31
30
|
itemElement = (react_1.default.createElement(ConstructorLoadable_1.ConstructorLoadable, { block: item, key: blockId, blockKey: blockId, config: config, serviceId: serviceId, params: params }));
|
|
32
31
|
}
|
|
33
32
|
else {
|
|
33
|
+
let children;
|
|
34
34
|
if ('children' in item && item.children) {
|
|
35
35
|
children = item.children.map(renderer.bind(null, blockId));
|
|
36
36
|
}
|
|
37
37
|
itemElement = (react_1.default.createElement(ConstructorItem_1.ConstructorItem, { data: item, key: blockId, blockKey: blockId }, children));
|
|
38
38
|
}
|
|
39
|
-
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);
|
|
40
40
|
};
|
|
41
41
|
return react_1.default.createElement(react_1.Fragment, null, items.map(renderer.bind(null, '')));
|
|
42
42
|
};
|
|
@@ -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;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
export declare const FilterTagProps: {
|
|
2
|
+
additionalProperties: boolean;
|
|
3
|
+
required: string[];
|
|
4
|
+
properties: {
|
|
5
|
+
id: {
|
|
6
|
+
type: string;
|
|
7
|
+
};
|
|
8
|
+
label: {
|
|
9
|
+
type: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare const FilterItemProps: {
|
|
14
|
+
additionalProperties: boolean;
|
|
15
|
+
required: string[];
|
|
16
|
+
properties: {
|
|
17
|
+
tags: {
|
|
18
|
+
type: string;
|
|
19
|
+
items: {
|
|
20
|
+
type: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
card: {
|
|
24
|
+
$ref: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare const FilterProps: {
|
|
29
|
+
additionalProperties: boolean;
|
|
30
|
+
required: string[];
|
|
31
|
+
properties: {
|
|
32
|
+
allTag: {
|
|
33
|
+
oneOf: {
|
|
34
|
+
type: string;
|
|
35
|
+
}[];
|
|
36
|
+
};
|
|
37
|
+
colSizes: {
|
|
38
|
+
type: string;
|
|
39
|
+
additionalProperties: boolean;
|
|
40
|
+
properties: {};
|
|
41
|
+
};
|
|
42
|
+
tags: {
|
|
43
|
+
type: string;
|
|
44
|
+
items: {
|
|
45
|
+
type: string;
|
|
46
|
+
properties: {
|
|
47
|
+
when: {
|
|
48
|
+
type: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
items: {
|
|
54
|
+
type: string;
|
|
55
|
+
items: {
|
|
56
|
+
type: string;
|
|
57
|
+
properties: {
|
|
58
|
+
when: {
|
|
59
|
+
type: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
tagButtonSize: {
|
|
65
|
+
type: string;
|
|
66
|
+
enum: string[];
|
|
67
|
+
};
|
|
68
|
+
title: {
|
|
69
|
+
oneOf: ({
|
|
70
|
+
type: string;
|
|
71
|
+
additionalProperties: boolean;
|
|
72
|
+
required: string[];
|
|
73
|
+
properties: {
|
|
74
|
+
text: {
|
|
75
|
+
type: string;
|
|
76
|
+
contentType: string;
|
|
77
|
+
};
|
|
78
|
+
textSize: {
|
|
79
|
+
type: string;
|
|
80
|
+
enum: string[];
|
|
81
|
+
};
|
|
82
|
+
url: {
|
|
83
|
+
type: string;
|
|
84
|
+
};
|
|
85
|
+
resetMargin: {
|
|
86
|
+
type: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
} | {
|
|
90
|
+
type: string;
|
|
91
|
+
})[];
|
|
92
|
+
};
|
|
93
|
+
description: {
|
|
94
|
+
type: string;
|
|
95
|
+
contentType: string;
|
|
96
|
+
};
|
|
97
|
+
animated: {
|
|
98
|
+
type: string;
|
|
99
|
+
};
|
|
100
|
+
anchor: {
|
|
101
|
+
type: string;
|
|
102
|
+
additionalProperties: boolean;
|
|
103
|
+
required: string[];
|
|
104
|
+
properties: {
|
|
105
|
+
text: {
|
|
106
|
+
type: string;
|
|
107
|
+
contentType: string;
|
|
108
|
+
};
|
|
109
|
+
url: {
|
|
110
|
+
type: string;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
visible: {
|
|
115
|
+
type: string;
|
|
116
|
+
enum: string[];
|
|
117
|
+
};
|
|
118
|
+
resetPaddings: {
|
|
119
|
+
type: string;
|
|
120
|
+
};
|
|
121
|
+
context: {
|
|
122
|
+
type: string;
|
|
123
|
+
};
|
|
124
|
+
type: {};
|
|
125
|
+
when: {};
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
export declare const FilterBlock: {
|
|
129
|
+
'filterable-block': {
|
|
130
|
+
additionalProperties: boolean;
|
|
131
|
+
required: string[];
|
|
132
|
+
properties: {
|
|
133
|
+
allTag: {
|
|
134
|
+
oneOf: {
|
|
135
|
+
type: string;
|
|
136
|
+
}[];
|
|
137
|
+
};
|
|
138
|
+
colSizes: {
|
|
139
|
+
type: string;
|
|
140
|
+
additionalProperties: boolean;
|
|
141
|
+
properties: {};
|
|
142
|
+
};
|
|
143
|
+
tags: {
|
|
144
|
+
type: string;
|
|
145
|
+
items: {
|
|
146
|
+
type: string;
|
|
147
|
+
properties: {
|
|
148
|
+
when: {
|
|
149
|
+
type: string;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
items: {
|
|
155
|
+
type: string;
|
|
156
|
+
items: {
|
|
157
|
+
type: string;
|
|
158
|
+
properties: {
|
|
159
|
+
when: {
|
|
160
|
+
type: string;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
tagButtonSize: {
|
|
166
|
+
type: string;
|
|
167
|
+
enum: string[];
|
|
168
|
+
};
|
|
169
|
+
title: {
|
|
170
|
+
oneOf: ({
|
|
171
|
+
type: string;
|
|
172
|
+
additionalProperties: boolean;
|
|
173
|
+
required: string[];
|
|
174
|
+
properties: {
|
|
175
|
+
text: {
|
|
176
|
+
type: string;
|
|
177
|
+
contentType: string;
|
|
178
|
+
};
|
|
179
|
+
textSize: {
|
|
180
|
+
type: string;
|
|
181
|
+
enum: string[];
|
|
182
|
+
};
|
|
183
|
+
url: {
|
|
184
|
+
type: string;
|
|
185
|
+
};
|
|
186
|
+
resetMargin: {
|
|
187
|
+
type: string;
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
} | {
|
|
191
|
+
type: string;
|
|
192
|
+
})[];
|
|
193
|
+
};
|
|
194
|
+
description: {
|
|
195
|
+
type: string;
|
|
196
|
+
contentType: string;
|
|
197
|
+
};
|
|
198
|
+
animated: {
|
|
199
|
+
type: string;
|
|
200
|
+
};
|
|
201
|
+
anchor: {
|
|
202
|
+
type: string;
|
|
203
|
+
additionalProperties: boolean;
|
|
204
|
+
required: string[];
|
|
205
|
+
properties: {
|
|
206
|
+
text: {
|
|
207
|
+
type: string;
|
|
208
|
+
contentType: string;
|
|
209
|
+
};
|
|
210
|
+
url: {
|
|
211
|
+
type: string;
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
visible: {
|
|
216
|
+
type: string;
|
|
217
|
+
enum: string[];
|
|
218
|
+
};
|
|
219
|
+
resetPaddings: {
|
|
220
|
+
type: string;
|
|
221
|
+
};
|
|
222
|
+
context: {
|
|
223
|
+
type: string;
|
|
224
|
+
};
|
|
225
|
+
type: {};
|
|
226
|
+
when: {};
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
};
|