@gravity-ui/page-constructor 3.0.0-alpha.4 → 3.0.0-alpha.6

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.
Files changed (130) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/build/cjs/components/BackgroundImage/BackgroundImage.js +2 -2
  3. package/build/cjs/components/BlockBase/BlockBase.d.ts +3 -2
  4. package/build/cjs/components/BlockBase/BlockBase.js +4 -2
  5. package/build/cjs/components/Button/Button.css +3 -0
  6. package/build/cjs/components/Button/Button.js +5 -4
  7. package/build/cjs/components/Image/Image.d.ts +1 -0
  8. package/build/cjs/components/Image/Image.js +2 -2
  9. package/build/cjs/containers/Loadable/Loadable.d.ts +2 -2
  10. package/build/cjs/containers/PageConstructor/PageConstructor.js +5 -3
  11. package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +3 -2
  12. package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +1 -1
  13. package/build/cjs/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +5 -5
  14. package/build/cjs/context/innerContext/InnerContext.d.ts +2 -1
  15. package/build/cjs/customization/BlockDecoration.d.ts +3 -0
  16. package/build/cjs/customization/BlockDecoration.js +22 -0
  17. package/build/cjs/editor/Components/AddBlock/AddBlock.css +82 -0
  18. package/build/cjs/editor/Components/AddBlock/AddBlock.d.ts +7 -0
  19. package/build/cjs/editor/Components/AddBlock/AddBlock.js +43 -0
  20. package/build/cjs/editor/Components/EditBlock/EditBlock.css +47 -0
  21. package/build/cjs/editor/Components/EditBlock/EditBlock.d.ts +4 -0
  22. package/build/cjs/editor/Components/EditBlock/EditBlock.js +32 -0
  23. package/build/cjs/editor/Containers/Editor.d.ts +2 -0
  24. package/build/cjs/editor/Containers/Editor.js +24 -0
  25. package/build/cjs/editor/data/index.d.ts +13 -0
  26. package/build/cjs/editor/data/index.js +27 -0
  27. package/build/cjs/editor/data/previews/default-preview.d.ts +3 -0
  28. package/build/cjs/editor/data/previews/default-preview.js +18 -0
  29. package/build/cjs/editor/data/previews/header-block.d.ts +3 -0
  30. package/build/cjs/editor/data/previews/header-block.js +19 -0
  31. package/build/cjs/editor/index.d.ts +2 -0
  32. package/build/cjs/editor/index.js +7 -0
  33. package/build/cjs/editor/store/index.d.ts +15 -0
  34. package/build/cjs/editor/store/index.js +32 -0
  35. package/build/cjs/editor/store/reducer.d.ts +41 -0
  36. package/build/cjs/editor/store/reducer.js +59 -0
  37. package/build/cjs/editor/store/utils.d.ts +12 -0
  38. package/build/cjs/editor/store/utils.js +34 -0
  39. package/build/cjs/editor/styles/mixins.css +0 -0
  40. package/build/cjs/editor/styles/variables.css +0 -0
  41. package/build/cjs/editor/types/index.d.ts +17 -0
  42. package/build/cjs/editor/types/index.js +2 -0
  43. package/build/cjs/editor/utils/index.d.ts +11 -0
  44. package/build/cjs/editor/utils/index.js +12 -0
  45. package/build/cjs/hooks/useMetrika.js +0 -7
  46. package/build/cjs/models/constructor-items/blocks.d.ts +1 -11
  47. package/build/cjs/models/constructor-items/blocks.js +0 -2
  48. package/build/cjs/models/constructor-items/common.d.ts +3 -3
  49. package/build/cjs/models/constructor.d.ts +4 -1
  50. package/build/cjs/models/customization.d.ts +9 -0
  51. package/build/cjs/models/customization.js +2 -0
  52. package/build/cjs/models/index.d.ts +1 -0
  53. package/build/cjs/models/index.js +1 -0
  54. package/build/cjs/schema/index.js +0 -1
  55. package/build/cjs/sub-blocks/Content/Content.js +2 -2
  56. package/build/cjs/text-transform/transformers.js +2 -4
  57. package/build/cjs/utils/blocks.d.ts +4 -1
  58. package/build/cjs/utils/blocks.js +11 -1
  59. package/build/esm/components/BackgroundImage/BackgroundImage.js +2 -2
  60. package/build/esm/components/BlockBase/BlockBase.d.ts +3 -2
  61. package/build/esm/components/BlockBase/BlockBase.js +4 -2
  62. package/build/esm/components/Button/Button.css +3 -0
  63. package/build/esm/components/Button/Button.js +5 -4
  64. package/build/esm/components/Image/Image.d.ts +1 -0
  65. package/build/esm/components/Image/Image.js +2 -2
  66. package/build/esm/containers/Loadable/Loadable.d.ts +2 -2
  67. package/build/esm/containers/PageConstructor/PageConstructor.js +6 -4
  68. package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +3 -2
  69. package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.d.ts +1 -1
  70. package/build/esm/containers/PageConstructor/components/ConstructorItem/ConstructorItem.js +5 -5
  71. package/build/esm/context/innerContext/InnerContext.d.ts +2 -1
  72. package/build/esm/customization/BlockDecoration.d.ts +3 -0
  73. package/build/esm/customization/BlockDecoration.js +17 -0
  74. package/build/esm/editor/Components/AddBlock/AddBlock.css +82 -0
  75. package/build/esm/editor/Components/AddBlock/AddBlock.d.ts +8 -0
  76. package/build/esm/editor/Components/AddBlock/AddBlock.js +41 -0
  77. package/build/esm/editor/Components/EditBlock/EditBlock.css +47 -0
  78. package/build/esm/editor/Components/EditBlock/EditBlock.d.ts +5 -0
  79. package/build/esm/editor/Components/EditBlock/EditBlock.js +30 -0
  80. package/build/esm/editor/Containers/Editor.d.ts +2 -0
  81. package/build/esm/editor/Containers/Editor.js +20 -0
  82. package/build/esm/editor/data/index.d.ts +13 -0
  83. package/build/esm/editor/data/index.js +24 -0
  84. package/build/esm/editor/data/previews/default-preview.d.ts +3 -0
  85. package/build/esm/editor/data/previews/default-preview.js +15 -0
  86. package/build/esm/editor/data/previews/header-block.d.ts +3 -0
  87. package/build/esm/editor/data/previews/header-block.js +16 -0
  88. package/build/esm/editor/index.d.ts +2 -0
  89. package/build/esm/editor/index.js +2 -0
  90. package/build/esm/editor/store/index.d.ts +15 -0
  91. package/build/esm/editor/store/index.js +28 -0
  92. package/build/esm/editor/store/reducer.d.ts +41 -0
  93. package/build/esm/editor/store/reducer.js +55 -0
  94. package/build/esm/editor/store/utils.d.ts +12 -0
  95. package/build/esm/editor/store/utils.js +26 -0
  96. package/build/esm/editor/styles/mixins.css +0 -0
  97. package/build/esm/editor/styles/variables.css +0 -0
  98. package/build/esm/editor/types/index.d.ts +17 -0
  99. package/build/esm/editor/types/index.js +1 -0
  100. package/build/esm/editor/utils/index.d.ts +11 -0
  101. package/build/esm/editor/utils/index.js +6 -0
  102. package/build/esm/hooks/useMetrika.js +0 -7
  103. package/build/esm/models/constructor-items/blocks.d.ts +1 -11
  104. package/build/esm/models/constructor-items/blocks.js +0 -2
  105. package/build/esm/models/constructor-items/common.d.ts +3 -3
  106. package/build/esm/models/constructor.d.ts +4 -1
  107. package/build/esm/models/customization.d.ts +9 -0
  108. package/build/esm/models/customization.js +1 -0
  109. package/build/esm/models/index.d.ts +1 -0
  110. package/build/esm/models/index.js +1 -0
  111. package/build/esm/schema/index.js +0 -1
  112. package/build/esm/sub-blocks/Content/Content.js +2 -3
  113. package/build/esm/text-transform/transformers.js +2 -4
  114. package/build/esm/utils/blocks.d.ts +4 -1
  115. package/build/esm/utils/blocks.js +7 -0
  116. package/package.json +4 -3
  117. package/server/models/constructor-items/blocks.d.ts +1 -11
  118. package/server/models/constructor-items/blocks.js +0 -2
  119. package/server/models/constructor-items/common.d.ts +3 -3
  120. package/server/models/constructor.d.ts +4 -1
  121. package/server/models/customization.d.ts +9 -0
  122. package/server/models/customization.js +2 -0
  123. package/server/models/index.d.ts +1 -0
  124. package/server/models/index.js +1 -0
  125. package/server/text-transform/transformers.js +2 -4
  126. package/server/utils/blocks.d.ts +4 -1
  127. package/server/utils/blocks.js +11 -1
  128. package/styles/styles.css +0 -196
  129. package/styles/styles.scss +0 -1
  130. package/styles/fonts.scss +0 -223
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importDefault(require("react"));
5
+ const svg_1 = require("../../../utils/svg");
6
+ const Header = (props) => (react_1.default.createElement("svg", Object.assign({ width: "150", height: "76", viewBox: "0 0 150 76", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, svg_1.a11yHiddenSvgProps, props),
7
+ react_1.default.createElement("rect", { x: "1", y: "1", width: "148", height: "74", rx: "8", fill: "white" }),
8
+ react_1.default.createElement("rect", { x: "4.44174", y: "9.60464", width: "141.116", height: "56.7907", rx: "5.16279", fill: "#A967FF" }),
9
+ react_1.default.createElement("rect", { x: "14.7674", y: "21.6512", width: "28.3953", height: "6.88372", rx: "0.860465", fill: "white" }),
10
+ react_1.default.createElement("rect", { x: "43.1628", y: "21.6512", width: "28.3953", height: "6.88372", rx: "0.860465", fill: "#A967FF" }),
11
+ react_1.default.createElement("rect", { x: "14.7674", y: "31.9767", width: "56.7907", height: "3.44186", rx: "0.860465", fill: "white" }),
12
+ react_1.default.createElement("rect", { x: "14.7674", y: "37.1395", width: "56.7907", height: "3.44186", rx: "0.860465", fill: "white" }),
13
+ react_1.default.createElement("rect", { x: "14.7674", y: "42.3023", width: "56.7907", height: "3.44186", rx: "0.860465", fill: "white" }),
14
+ react_1.default.createElement("rect", { x: "14.7674", y: "49.186", width: "18.9302", height: "5.16279", rx: "0.860465", fill: "white" }),
15
+ react_1.default.createElement("rect", { x: "33.6976", y: "49.186", width: "18.9302", height: "5.16279", rx: "0.860465", fill: "#A967FF" }),
16
+ react_1.default.createElement("rect", { x: "52.6279", y: "49.186", width: "18.9302", height: "5.16279", rx: "0.860465", fill: "#A967FF" }),
17
+ react_1.default.createElement("rect", { x: "78.4418", y: "9.60464", width: "56.7907", height: "56.7907", rx: "5.16279", fill: "#A967FF" }),
18
+ react_1.default.createElement("rect", { x: "0.5", y: "0.5", width: "149", height: "75", rx: "8.5", stroke: "black", strokeOpacity: "0.1" })));
19
+ exports.default = Header;
@@ -0,0 +1,2 @@
1
+ export { Editor } from './Containers/Editor';
2
+ export * from './types';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Editor = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var Editor_1 = require("./Containers/Editor");
6
+ Object.defineProperty(exports, "Editor", { enumerable: true, get: function () { return Editor_1.Editor; } });
7
+ tslib_1.__exportStar(require("./types"), exports);
@@ -0,0 +1,15 @@
1
+ import { Block } from '../../models';
2
+ import { EditorProps } from '../types';
3
+ export type EditorBlockId = number | string;
4
+ export declare function useEditorState({ content: intialContent, custom }: Omit<EditorProps, 'children'>): {
5
+ content: import("../../models").PageContent;
6
+ editControlsProps: {
7
+ activeBlockId: import("./reducer").EditorBlockId;
8
+ orderedBlocksCount: number;
9
+ onDelete: (id: EditorBlockId) => void;
10
+ onSelect: (id: EditorBlockId) => void;
11
+ onCopy: (index: number) => void;
12
+ onOrderChange: (oldIndex: number, newIndex: number) => void;
13
+ };
14
+ onAdd: (block: Block) => void;
15
+ };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useEditorState = void 0;
4
+ const react_1 = require("react");
5
+ const models_1 = require("../../models");
6
+ const utils_1 = require("../../utils");
7
+ const reducer_1 = require("./reducer");
8
+ const utils_2 = require("./utils");
9
+ function useEditorState({ content: intialContent, custom }) {
10
+ const headerBlockTypes = (0, react_1.useMemo)(() => [...models_1.HeaderBlockTypes, ...(0, utils_1.getCustomHeaderTypes)(custom)], [custom]);
11
+ const reducer = (0, react_1.useMemo)(() => (0, reducer_1.getReducer)(headerBlockTypes), [headerBlockTypes]);
12
+ const [{ activeBlockId, content, orderedBlocksCount }, dispatch] = (0, react_1.useReducer)(reducer, {
13
+ activeBlockId: 0,
14
+ orderedBlocksCount: (0, utils_1.getOrderedBlocks)(intialContent.blocks, headerBlockTypes).length,
15
+ content: (0, utils_2.addEditorProps)(intialContent),
16
+ });
17
+ return (0, react_1.useMemo)(() => {
18
+ return {
19
+ content,
20
+ editControlsProps: {
21
+ activeBlockId,
22
+ orderedBlocksCount,
23
+ onDelete: (id) => dispatch({ type: reducer_1.DELETE_BLOCK, payload: id }),
24
+ onSelect: (id) => dispatch({ type: reducer_1.SELECT_BLOCK, payload: id }),
25
+ onCopy: (index) => dispatch({ type: reducer_1.COPY_BLOCK, payload: index }),
26
+ onOrderChange: (oldIndex, newIndex) => dispatch({ type: reducer_1.ORDER_BLOCK, payload: { oldIndex, newIndex } }),
27
+ },
28
+ onAdd: (block) => dispatch({ type: reducer_1.ADD_BLOCK, payload: block }),
29
+ };
30
+ }, [content, activeBlockId, orderedBlocksCount]);
31
+ }
32
+ exports.useEditorState = useEditorState;
@@ -0,0 +1,41 @@
1
+ import { Block, CustomConfig, PageContent } from '../../models';
2
+ export type EditorBlockId = number | string;
3
+ interface EditorState {
4
+ content: PageContent;
5
+ activeBlockId: EditorBlockId;
6
+ orderedBlocksCount: number;
7
+ custom?: CustomConfig;
8
+ }
9
+ interface OrderBlockParams {
10
+ oldIndex: number;
11
+ newIndex: number;
12
+ }
13
+ export declare const SELECT_BLOCK = "SELECT_BLOCK";
14
+ export declare const DELETE_BLOCK = "DELETE_BLOCK";
15
+ export declare const COPY_BLOCK = "COPY_BLOCK";
16
+ export declare const ADD_BLOCK = "ADD_BLOCK";
17
+ export declare const SET_REGION = "SET_REGION";
18
+ export declare const ORDER_BLOCK = "ORDER_BLOCK";
19
+ interface SelectBlock {
20
+ type: typeof SELECT_BLOCK;
21
+ payload: EditorBlockId;
22
+ }
23
+ interface DeleteBlock {
24
+ type: typeof DELETE_BLOCK;
25
+ payload: EditorBlockId;
26
+ }
27
+ interface CopyBlock {
28
+ type: typeof COPY_BLOCK;
29
+ payload: number;
30
+ }
31
+ interface AddBlock {
32
+ type: typeof ADD_BLOCK;
33
+ payload: Block;
34
+ }
35
+ interface OrderBlock {
36
+ type: typeof ORDER_BLOCK;
37
+ payload: OrderBlockParams;
38
+ }
39
+ export type EditorAction = SelectBlock | DeleteBlock | CopyBlock | AddBlock | OrderBlock;
40
+ export declare const getReducer: (headerBlockTypes: string[]) => (state: EditorState, action: EditorAction) => EditorState;
41
+ export {};
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getReducer = exports.ORDER_BLOCK = exports.SET_REGION = exports.ADD_BLOCK = exports.COPY_BLOCK = exports.DELETE_BLOCK = exports.SELECT_BLOCK = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const utils_2 = require("./utils");
6
+ // actions
7
+ exports.SELECT_BLOCK = 'SELECT_BLOCK';
8
+ exports.DELETE_BLOCK = 'DELETE_BLOCK';
9
+ exports.COPY_BLOCK = 'COPY_BLOCK';
10
+ exports.ADD_BLOCK = 'ADD_BLOCK';
11
+ exports.SET_REGION = 'SET_REGION';
12
+ exports.ORDER_BLOCK = 'ORDER_BLOCK';
13
+ // reducer
14
+ const getReducer = (headerBlockTypes) => (state, action) => {
15
+ const { content } = state;
16
+ const header = (0, utils_1.getHeaderBlock)(content.blocks, headerBlockTypes);
17
+ const orderedBlocks = (0, utils_1.getOrderedBlocks)(content.blocks, headerBlockTypes);
18
+ const withHeader = (blocks) => [header, ...blocks].filter(Boolean);
19
+ const getNewState = (blocks, activeBlockId) => (Object.assign(Object.assign({}, state), { content: Object.assign(Object.assign({}, content), { blocks }), activeBlockId, orderedBlocksCount: orderedBlocks.length }));
20
+ switch (action.type) {
21
+ case exports.SELECT_BLOCK:
22
+ return getNewState(content.blocks, action.payload);
23
+ case exports.DELETE_BLOCK: {
24
+ const blockId = action.payload;
25
+ return getNewState(typeof blockId === 'string'
26
+ ? content.blocks.filter(({ type }) => type !== blockId)
27
+ : withHeader(orderedBlocks.filter((_block, index) => index !== blockId)), -1);
28
+ }
29
+ case exports.COPY_BLOCK: {
30
+ const index = action.payload;
31
+ return getNewState(withHeader((0, utils_2.duplicateBlock)(orderedBlocks, index)), index + 1);
32
+ }
33
+ case exports.ADD_BLOCK: {
34
+ let blocks;
35
+ let activeBlockId;
36
+ const block = action.payload;
37
+ if (headerBlockTypes.includes(block.type)) {
38
+ blocks = header ? blocks : [block, ...orderedBlocks];
39
+ activeBlockId = block.type;
40
+ }
41
+ else {
42
+ const newBlockIndex = (0, utils_2.getNewBlockIndex)(state.activeBlockId, orderedBlocks.length);
43
+ blocks = withHeader((0, utils_2.addBlock)(orderedBlocks, block, newBlockIndex));
44
+ activeBlockId = newBlockIndex;
45
+ }
46
+ if (blocks) {
47
+ return getNewState(blocks, activeBlockId);
48
+ }
49
+ return state;
50
+ }
51
+ case exports.ORDER_BLOCK: {
52
+ const { oldIndex, newIndex } = action.payload;
53
+ return getNewState(withHeader((0, utils_2.changeBlocksOrder)(orderedBlocks, oldIndex, newIndex)), newIndex);
54
+ }
55
+ default:
56
+ return state;
57
+ }
58
+ };
59
+ exports.getReducer = getReducer;
@@ -0,0 +1,12 @@
1
+ import { Block, PageContent } from '../../models';
2
+ import { EditorBlockId } from './reducer';
3
+ export declare const changeBlocksOrder: (array: Block[], oldIndex: number, newIndex: number) => Block[];
4
+ export declare const duplicateBlock: (array: Block[], index: number) => Block[];
5
+ export declare const getNewBlockIndex: (id: EditorBlockId, orderedBlocksCount: number) => number;
6
+ export declare const addBlock: (array: Block[], block: Block, index: number) => Block[];
7
+ export declare const addEditorProps: (content: PageContent) => {
8
+ animated: boolean;
9
+ blocks: Block[];
10
+ menu?: import("../../models").Menu | undefined;
11
+ background?: import("../../models").ThemedMediaProps | undefined;
12
+ };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addEditorProps = exports.addBlock = exports.getNewBlockIndex = exports.duplicateBlock = exports.changeBlocksOrder = void 0;
4
+ const changeBlocksOrder = (array, oldIndex, newIndex) => {
5
+ const result = [...array];
6
+ const element = result.splice(oldIndex, 1)[0];
7
+ result.splice(newIndex, 0, element);
8
+ return result;
9
+ };
10
+ exports.changeBlocksOrder = changeBlocksOrder;
11
+ const duplicateBlock = (array, index) => {
12
+ const result = [...array];
13
+ result.splice(index + 1, 0, result[index]);
14
+ return result;
15
+ };
16
+ exports.duplicateBlock = duplicateBlock;
17
+ const getNewBlockIndex = (id, orderedBlocksCount) => {
18
+ if (id === -1) {
19
+ return orderedBlocksCount;
20
+ }
21
+ // id === 'string' - header block
22
+ return typeof id === 'string' ? 0 : id + 1;
23
+ };
24
+ exports.getNewBlockIndex = getNewBlockIndex;
25
+ const addBlock = (array, block, index) => {
26
+ const result = [...array];
27
+ result.splice(index, 0, block);
28
+ return result;
29
+ };
30
+ exports.addBlock = addBlock;
31
+ const addEditorProps = (content) => {
32
+ return Object.assign(Object.assign({}, content), { animated: false });
33
+ };
34
+ exports.addEditorProps = addEditorProps;
File without changes
File without changes
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ import { PageConstructorProps } from '../../containers/PageConstructor';
3
+ import { BlockDecoratorProps, PageData } from '../../models';
4
+ export type EditorBlockId = number | string;
5
+ export interface EditorProps extends Required<Pick<PageConstructorProps, 'content'>>, Partial<Omit<PageConstructorProps, 'content'>> {
6
+ children: (props: Partial<PageConstructorProps>) => React.ReactNode;
7
+ onChange?: (data: PageData) => void;
8
+ }
9
+ export interface EditBlockEditorProps {
10
+ activeBlockId: EditorBlockId;
11
+ orderedBlocksCount: number;
12
+ onSelect: (index: EditorBlockId) => void;
13
+ onDelete: (index: EditorBlockId) => void;
14
+ onCopy: (index: number) => void;
15
+ onOrderChange: (index: number, newIndex: number) => void;
16
+ }
17
+ export type EditBlockProps = EditBlockEditorProps & BlockDecoratorProps;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ import { BlockDecorator, CustomConfig } from '../../models';
2
+ export declare const formatBlockName: (name: string) => string;
3
+ export declare const addCustomDecorator: (decorator: BlockDecorator, custom?: CustomConfig) => {
4
+ decorators: {
5
+ block: ((props: import("../../models").BlockDecoratorProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>)[];
6
+ };
7
+ blocks?: import("../../models").CustomItems | undefined;
8
+ subBlocks?: import("../../models").CustomItems | undefined;
9
+ headers?: import("../../models").CustomItems | undefined;
10
+ loadable?: import("../../models").LoadableConfig | undefined;
11
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addCustomDecorator = exports.formatBlockName = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
6
+ const formatBlockName = (name) => lodash_1.default.capitalize(name).replace(/(block|-)/g, ' ');
7
+ exports.formatBlockName = formatBlockName;
8
+ const addCustomDecorator = (decorator, custom = {}) => {
9
+ const decorators = custom.decorators || {};
10
+ return Object.assign(Object.assign({}, custom), { decorators: Object.assign(Object.assign({}, decorators), { block: [...(decorators.block || []), decorator] }) });
11
+ };
12
+ exports.addCustomDecorator = addCustomDecorator;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useMetrika = void 0;
4
4
  const react_1 = require("react");
5
5
  const metrikaContext_1 = require("../context/metrikaContext");
6
- const models_1 = require("../models");
7
6
  const guards_1 = require("../models/guards");
8
7
  // eslint-disable-next-line valid-jsdoc
9
8
  /**
@@ -29,12 +28,6 @@ const useMetrika = () => {
29
28
  else {
30
29
  metrika.reachGoals(metrikaGoals);
31
30
  }
32
- if (!pixelEvents && pixel) {
33
- pixel.trackStandard(models_1.PixelEventType.SubmitApplication, {
34
- content_category: 'custom',
35
- content_ids: Array.isArray(metrikaGoals) ? metrikaGoals : [metrikaGoals],
36
- });
37
- }
38
31
  }
39
32
  if (pixel && pixelEvents) {
40
33
  if (isButtonPixel(pixelEvents)) {
@@ -8,8 +8,6 @@ export declare enum BlockType {
8
8
  PromoFeaturesBlock = "promo-features-block",
9
9
  ExtendedFeaturesBlock = "extended-features-block",
10
10
  SliderBlock = "slider-block",
11
- CalculatorBlock = "calculator-block",
12
- ServiceDemoBlock = "service-demo-block",
13
11
  QuestionsBlock = "questions-block",
14
12
  BannerBlock = "banner-block",
15
13
  CompaniesBlock = "companies-block",
@@ -48,7 +46,6 @@ export interface LoadableProps {
48
46
  export interface LoadableChildren {
49
47
  loadable?: LoadableProps;
50
48
  }
51
- export type ServiceDemoProps = Animatable;
52
49
  export declare enum SliderBreakpointNames {
53
50
  Sm = "sm",
54
51
  Md = "md",
@@ -110,7 +107,6 @@ export interface HeaderBlockProps {
110
107
  breadcrumbs?: HeaderBreadCrumbsProps;
111
108
  status?: JSX.Element;
112
109
  }
113
- export type CalculatorProps = Animatable;
114
110
  export interface ExtendedFeaturesItem extends Omit<ContentBlockProps, 'theme' | 'centered' | 'colSizes' | 'size' | 'title'> {
115
111
  title: string;
116
112
  label?: string;
@@ -283,15 +279,9 @@ export interface ShareBlockProps {
283
279
  export type HeaderBlockModel = {
284
280
  type: BlockType.HeaderBlock;
285
281
  } & HeaderBlockProps;
286
- export type CalculatorBlockModel = {
287
- type: BlockType.CalculatorBlock;
288
- } & CalculatorProps;
289
282
  export type SliderBlockModel = {
290
283
  type: BlockType.SliderBlock;
291
284
  } & SliderProps;
292
- export type ServiceDemoBlockModel = {
293
- type: BlockType.ServiceDemoBlock;
294
- } & ServiceDemoProps;
295
285
  export type ExtendedFeaturesBlockModel = {
296
286
  type: BlockType.ExtendedFeaturesBlock;
297
287
  } & ExtendedFeaturesProps;
@@ -340,6 +330,6 @@ export type ContentLayoutBlockModel = {
340
330
  export type ShareBLockModel = {
341
331
  type: BlockType.ShareBlock;
342
332
  } & ShareBlockProps;
343
- type BlockModels = SliderBlockModel | ServiceDemoBlockModel | ExtendedFeaturesBlockModel | PromoFeaturesBlockModel | QuestionsBlockModel | CalculatorBlockModel | BannerBlockModel | CompaniesBlockModel | MediaBlockModel | MapBlockModel | InfoBlockModel | TableBlockModel | TabsBlockModel | HeaderBlockModel | IconsBlockModel | HeaderSliderBlockModel | CardLayoutBlockModel | ContentLayoutBlockModel | ShareBLockModel | FilterBlockModel;
333
+ type BlockModels = SliderBlockModel | ExtendedFeaturesBlockModel | PromoFeaturesBlockModel | QuestionsBlockModel | BannerBlockModel | CompaniesBlockModel | MediaBlockModel | MapBlockModel | InfoBlockModel | TableBlockModel | TabsBlockModel | HeaderBlockModel | IconsBlockModel | HeaderSliderBlockModel | CardLayoutBlockModel | ContentLayoutBlockModel | ShareBLockModel | FilterBlockModel;
344
334
  export type Block = BlockModels & BlockBaseProps;
345
335
  export {};
@@ -6,8 +6,6 @@ var BlockType;
6
6
  BlockType["PromoFeaturesBlock"] = "promo-features-block";
7
7
  BlockType["ExtendedFeaturesBlock"] = "extended-features-block";
8
8
  BlockType["SliderBlock"] = "slider-block";
9
- BlockType["CalculatorBlock"] = "calculator-block";
10
- BlockType["ServiceDemoBlock"] = "service-demo-block";
11
9
  BlockType["QuestionsBlock"] = "questions-block";
12
10
  BlockType["BannerBlock"] = "banner-block";
13
11
  BlockType["CompaniesBlock"] = "companies-block";
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, ReactNode } from 'react';
2
- import { ButtonSize, ButtonView } from '@gravity-ui/uikit';
2
+ import { ButtonView, ButtonProps as UikitButtonProps } from '@gravity-ui/uikit';
3
3
  import { ThemeSupporting } from '../../utils/theme';
4
4
  import { AnalyticsEventsBase, ClassNameProps, PixelEventType } from '../common';
5
5
  export declare enum AuthorType {
@@ -94,6 +94,7 @@ export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement>, P
94
94
  style?: CSSProperties;
95
95
  imageClassName?: string;
96
96
  hide?: boolean;
97
+ qa?: string;
97
98
  }
98
99
  export interface MediaVideoProps extends AnalyticsEventsBase {
99
100
  src: string[];
@@ -126,11 +127,10 @@ export interface FileLinkProps extends ClassNameProps {
126
127
  onClick?: () => void;
127
128
  }
128
129
  export type ButtonTheme = ButtonView | 'github' | 'app-store' | 'google-play' | 'scale' | 'monochrome';
129
- export interface ButtonProps extends AnalyticsEventsBase {
130
+ export interface ButtonProps extends AnalyticsEventsBase, Pick<UikitButtonProps, 'size' | 'width'> {
130
131
  text: string;
131
132
  url: string;
132
133
  primary?: boolean;
133
- size?: ButtonSize;
134
134
  theme?: ButtonTheme;
135
135
  img?: ButtonImageProps | string;
136
136
  metrikaGoals?: MetrikaGoal;
@@ -1,5 +1,5 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
- import { Animatable, Block, ConstructorItem, ThemedMediaProps, WithChildren } from './';
2
+ import { Animatable, Block, BlockDecoratorProps, ConstructorItem, ThemedMediaProps, WithChildren } from './';
3
3
  export interface PageData {
4
4
  content: PageContent;
5
5
  }
@@ -40,5 +40,8 @@ export interface CustomConfig {
40
40
  subBlocks?: CustomItems;
41
41
  headers?: CustomItems;
42
42
  loadable?: LoadableConfig;
43
+ decorators?: {
44
+ block?: ((props: BlockDecoratorProps) => React.ReactElement)[];
45
+ };
43
46
  }
44
47
  export {};
@@ -0,0 +1,9 @@
1
+ import { PropsWithChildren } from 'react';
2
+ export interface BlockDecorationProps extends PropsWithChildren {
3
+ id?: string;
4
+ }
5
+ export interface BlockDecoratorProps extends PropsWithChildren {
6
+ id: string | number;
7
+ isHeader?: boolean;
8
+ }
9
+ export type BlockDecorator = (props: BlockDecoratorProps) => React.ReactElement;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -5,3 +5,4 @@ export * from './components';
5
5
  export * from './guards';
6
6
  export * from './react';
7
7
  export * from './navigation';
8
+ export * from './customization';
@@ -8,3 +8,4 @@ tslib_1.__exportStar(require("./components"), exports);
8
8
  tslib_1.__exportStar(require("./guards"), exports);
9
9
  tslib_1.__exportStar(require("./react"), exports);
10
10
  tslib_1.__exportStar(require("./navigation"), exports);
11
+ tslib_1.__exportStar(require("./customization"), exports);
@@ -33,7 +33,6 @@ function generateDefaultSchema(config) {
33
33
  'info-block',
34
34
  'table-block',
35
35
  'tabs-block',
36
- 'preview-block',
37
36
  'price-detailed',
38
37
  'header-slider-block',
39
38
  'cards-with-image-block',
@@ -36,9 +36,9 @@ function getButtonSize(size) {
36
36
  }
37
37
  const Content = (props) => {
38
38
  const { title, text, additionalInfo, size = 'l', links, buttons, colSizes = { all: 12, sm: 8 }, centered, theme, className, } = props;
39
- const titleProps = tslib_1.__rest(!title || typeof title === 'string'
39
+ const titleProps = !title || typeof title === 'string'
40
40
  ? { text: title, textSize: getTextSize(size) }
41
- : Object.assign({}, title), []);
41
+ : title;
42
42
  const hasTitle = Boolean(title);
43
43
  return (react_1.default.createElement(grid_1.Col, { className: b({ size, centered, theme }, className), reset: true, sizes: colSizes },
44
44
  title && react_1.default.createElement(components_1.Title, { className: b('title'), title: titleProps, colSizes: { all: 12 } }),
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.contentTransformer = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ /* eslint-disable no-param-reassign */
6
+ /* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
5
7
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
6
8
  const config_1 = require("./config");
7
9
  function transformBlocks(blocks, lang, customConfig = {}) {
@@ -13,7 +15,6 @@ function transformBlock(lang, blocksConfig, block) {
13
15
  const blockConfig = blocksConfig[block.type];
14
16
  if (block) {
15
17
  if ('randomOrder' in block && block.randomOrder && 'children' in block && block.children) {
16
- // eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign, no-param-reassign
17
18
  block.children = lodash_1.default.shuffle(block.children);
18
19
  }
19
20
  }
@@ -26,11 +27,9 @@ function transformBlock(lang, blocksConfig, block) {
26
27
  fields.forEach((field) => {
27
28
  if (block[field]) {
28
29
  if (parser) {
29
- // eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign, no-param-reassign
30
30
  block[field] = parser(transformer, block[field]);
31
31
  }
32
32
  else if (typeof block[field] === 'string') {
33
- // eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign, no-param-reassign
34
33
  block[field] = transformer(block[field]);
35
34
  }
36
35
  }
@@ -42,7 +41,6 @@ function transformBlock(lang, blocksConfig, block) {
42
41
  });
43
42
  }
44
43
  if ('children' in block && block.children) {
45
- // eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign, no-param-reassign
46
44
  block.children = transformBlocks(block.children, lang, blocksConfig);
47
45
  }
48
46
  return block;
@@ -1,4 +1,4 @@
1
- import { CustomConfig, PCShareSocialNetwork, TextSize } from '../models';
1
+ import { Block, CustomConfig, PCShareSocialNetwork, TextSize } from '../models';
2
2
  import { ConstructorBlock } from '../models/constructor';
3
3
  export declare function getHeaderTag(size: TextSize): "h1" | "h2" | "h4" | "h5";
4
4
  export declare function getBlockKey(block: ConstructorBlock, index: number): string;
@@ -8,4 +8,7 @@ export declare const getCustomItems: ({ blocks, headers, subBlocks }?: CustomCon
8
8
  };
9
9
  export declare const getCustomSubBlockTypes: (customBlocks?: CustomConfig) => string[];
10
10
  export declare const getCustomHeaderTypes: (customBlocks?: CustomConfig) => string[];
11
+ export declare const getOrderedBlocks: (blocks: Block[], headerBlockTypes?: string[]) => Block[];
12
+ export declare const getHeaderBlock: (blocks: Block[], headerBlockTypes?: string[]) => Block | undefined;
11
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.getShareLink = exports.getCustomHeaderTypes = exports.getCustomSubBlockTypes = exports.getCustomItems = exports.getCustomBlockTypes = exports.getBlockKey = exports.getHeaderTag = void 0;
3
+ exports.getBlockIndexFromId = 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) {
@@ -46,6 +46,14 @@ const getShareUrlWithParams = (url, params = {}) => {
46
46
  });
47
47
  return result.toString();
48
48
  };
49
+ const getOrderedBlocks = (blocks, headerBlockTypes = []) => {
50
+ return blocks.filter(({ type }) => !headerBlockTypes.includes(type));
51
+ };
52
+ exports.getOrderedBlocks = getOrderedBlocks;
53
+ const getHeaderBlock = (blocks, headerBlockTypes = []) => {
54
+ return blocks.find(({ type }) => headerBlockTypes.includes(type));
55
+ };
56
+ exports.getHeaderBlock = getHeaderBlock;
49
57
  const getShareLink = (url, type, title, text) => {
50
58
  // https://github.com/bradvin/social-share-urls
51
59
  switch (type) {
@@ -75,3 +83,5 @@ const getShareLink = (url, type, title, text) => {
75
83
  }
76
84
  };
77
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;
@@ -4,8 +4,8 @@ import Image from '../Image/Image';
4
4
  import './BackgroundImage.css';
5
5
  const b = block('storage-background-image');
6
6
  const BackgroundImage = (props) => {
7
- const { children, src, desktop, className, imageClassName, style, hide } = props;
8
- return (React.createElement("div", { className: b(null, className), style: style },
7
+ const { children, src, desktop, className, imageClassName, style, hide, qa } = props;
8
+ return (React.createElement("div", { className: b(null, className), style: style, "data-qa": qa },
9
9
  (src || desktop) && !hide && React.createElement(Image, Object.assign({}, props, { className: b('img', imageClassName) })),
10
10
  children && React.createElement("div", { className: b('container') }, children)));
11
11
  };
@@ -1,4 +1,5 @@
1
- import { BlockBaseProps, ClassNameProps, WithChildren } from '../../models';
1
+ import { PropsWithChildren } from 'react';
2
+ import { BlockBaseProps, ClassNameProps } from '../../models';
2
3
  import './BlockBase.css';
3
- declare const BlockBase: (props: WithChildren<BlockBaseProps & ClassNameProps>) => JSX.Element;
4
+ declare const BlockBase: (props: PropsWithChildren<BlockBaseProps & ClassNameProps>) => JSX.Element;
4
5
  export default BlockBase;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { BlockDecoration } from '../../customization/BlockDecoration';
2
3
  import { Col } from '../../grid';
3
4
  import { block } from '../../utils';
4
5
  import Anchor from '../Anchor/Anchor';
@@ -7,7 +8,8 @@ const b = block('block-base');
7
8
  const BlockBase = (props) => {
8
9
  const { anchor, visible, children, className, resetPaddings, qa } = props;
9
10
  return (React.createElement(Col, { className: b({ ['reset-paddings']: resetPaddings }, className), visible: visible, reset: true, dataQa: qa },
10
- anchor && React.createElement(Anchor, { id: anchor.url, className: b('anchor') }),
11
- children));
11
+ React.createElement(BlockDecoration, null,
12
+ anchor && React.createElement(Anchor, { id: anchor.url, className: b('anchor') }),
13
+ children)));
12
14
  };
13
15
  export default BlockBase;
@@ -45,4 +45,7 @@ unpredictable css rules order in build */
45
45
  }
46
46
  .pc-button-block_size_xl {
47
47
  --btn-image-margin: 25px;
48
+ }
49
+ .pc-button-block_width_max .pc-button-block__text {
50
+ width: 100%;
48
51
  }
@@ -14,7 +14,7 @@ const b = block('button-block');
14
14
  const Button = (props) => {
15
15
  const handleMetrika = useMetrika();
16
16
  const { lang, tld } = useContext(LocaleContext);
17
- const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = __rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text"]);
17
+ const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text, width } = props, rest = __rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text", "width"]);
18
18
  const defaultImgPosition = 'left';
19
19
  const handleAnalytics = useAnalytics(DefaultEventNames.Button, url);
20
20
  const onClick = useCallback((e) => {
@@ -24,12 +24,13 @@ const Button = (props) => {
24
24
  onClickOrigin(e);
25
25
  }
26
26
  }, [handleMetrika, metrikaGoals, pixelEvents, handleAnalytics, analyticsEvents, onClickOrigin]);
27
+ const buttonModifiers = { size, theme, width };
27
28
  const buttonImg = img instanceof Object
28
29
  ? { url: img.url, position: img.position || defaultImgPosition, alt: img.alt }
29
30
  : { url: img, position: defaultImgPosition };
30
31
  const buttonClass = img
31
- ? b({ position: buttonImg.position, size, theme }, className)
32
- : b({ size, theme }, className);
32
+ ? b(Object.assign({ position: buttonImg.position }, buttonModifiers), className)
33
+ : b(Object.assign({}, buttonModifiers), className);
33
34
  const buttonProps = Object.assign(Object.assign({}, rest), { onClick });
34
35
  if (theme === 'app-store' || theme === 'google-play') {
35
36
  const platform = theme === 'app-store' ? Platform.IOS : Platform.ANDROID;
@@ -42,7 +43,7 @@ const Button = (props) => {
42
43
  image = undefined;
43
44
  }
44
45
  const buttonTheme = theme === 'scale' ? 'accent' : theme;
45
- return (React.createElement(CommonButton, Object.assign({ className: buttonClass, view: toCommonView(buttonTheme), size: toCommonSize(size), href: url ? setUrlTld(url, tld) : undefined }, buttonProps),
46
+ return (React.createElement(CommonButton, Object.assign({ className: buttonClass, view: toCommonView(buttonTheme), size: toCommonSize(size), href: url ? setUrlTld(url, tld) : undefined, width: width }, buttonProps),
46
47
  icon && buttonImg.position === 'left' ? icon : null,
47
48
  React.createElement("span", { className: b('content') },
48
49
  image && buttonImg.position === 'left' ? image : null,