@gravity-ui/page-constructor 4.9.0 → 4.10.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/README.md CHANGED
@@ -386,3 +386,7 @@ export const MyAppEditor = ({initialContent, onChange, transformContent}: MyAppE
386
386
  <Editor content={initialContent} onChange={onChange} transformContent={transformContent} />
387
387
  );
388
388
  ```
389
+
390
+ ## Tests
391
+
392
+ Comprehensive documentation is available at the provided [link](./test-utils/docs/README.md).
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { CardLayoutBlockProps as CardLayoutBlockParams, WithChildren } from '../../models';
3
- export type CardLayoutBlockProps = WithChildren<Omit<CardLayoutBlockParams, 'children'>>;
2
+ import { CardLayoutBlockProps as CardLayoutBlockParams, ClassNameProps, WithChildren } from '../../models';
3
+ export type CardLayoutBlockProps = WithChildren<Omit<CardLayoutBlockParams, 'children'>> & ClassNameProps;
4
4
  declare const CardLayout: React.FC<CardLayoutBlockProps>;
5
5
  export default CardLayout;
@@ -11,7 +11,7 @@ const DEFAULT_SIZES = {
11
11
  md: 4,
12
12
  };
13
13
  const b = (0, utils_1.block)('card-layout-block');
14
- const CardLayout = ({ title, description, animated, colSizes = DEFAULT_SIZES, children, }) => (react_1.default.createElement(components_1.AnimateBlock, { className: b(), animate: animated },
14
+ const CardLayout = ({ title, description, animated, colSizes = DEFAULT_SIZES, children, className, }) => (react_1.default.createElement(components_1.AnimateBlock, { className: b(null, className), animate: animated },
15
15
  (title || description) && react_1.default.createElement(components_1.Title, { title: title, subtitle: description }),
16
16
  react_1.default.createElement(grid_1.Row, null, react_1.default.Children.map(children, (child, index) => (react_1.default.createElement(grid_1.Col, { key: index, sizes: colSizes, className: b('item') }, child))))));
17
17
  exports.default = CardLayout;
@@ -0,0 +1,38 @@
1
+ /* use this for style redefinitions to awoid problems with
2
+ unpredictable css rules order in build */
3
+ .pc-constructor-block.pc-constructor-block_indentTop_0 {
4
+ margin-top: 0;
5
+ }
6
+ .pc-constructor-block.pc-constructor-block_indentTop_xs {
7
+ margin-top: 16px;
8
+ }
9
+ .pc-constructor-block.pc-constructor-block_indentTop_s {
10
+ margin-top: 24px;
11
+ }
12
+ .pc-constructor-block.pc-constructor-block_indentTop_m {
13
+ margin-top: 32px;
14
+ }
15
+ .pc-constructor-block.pc-constructor-block_indentTop_l {
16
+ margin-top: 48px;
17
+ }
18
+ .pc-constructor-block.pc-constructor-block_indentTop_xl {
19
+ margin-top: 64px;
20
+ }
21
+ .pc-constructor-block.pc-constructor-block_indentBottom_0 {
22
+ padding-bottom: 0;
23
+ }
24
+ .pc-constructor-block.pc-constructor-block_indentBottom_xs {
25
+ padding-bottom: 16px;
26
+ }
27
+ .pc-constructor-block.pc-constructor-block_indentBottom_s {
28
+ padding-bottom: 24px;
29
+ }
30
+ .pc-constructor-block.pc-constructor-block_indentBottom_m {
31
+ padding-bottom: 32px;
32
+ }
33
+ .pc-constructor-block.pc-constructor-block_indentBottom_l {
34
+ padding-bottom: 48px;
35
+ }
36
+ .pc-constructor-block.pc-constructor-block_indentBottom_xl {
37
+ padding-bottom: 64px;
38
+ }
@@ -9,9 +9,10 @@ const BlockDecoration_1 = require("../../../../customization/BlockDecoration");
9
9
  const utils_1 = require("../../../../utils");
10
10
  const b = (0, utils_1.block)('constructor-block');
11
11
  const ConstructorBlock = ({ index = 0, data, children, }) => {
12
- const { type } = data;
12
+ const { type, indent } = data;
13
13
  const blockBaseProps = (0, react_1.useMemo)(() => lodash_1.default.pick(data, ['anchor', 'visible', 'resetPaddings']), [data]);
14
+ const { top, bottom } = indent || { top: 'l', bottom: 'l' };
14
15
  return (react_1.default.createElement(BlockDecoration_1.BlockDecoration, Object.assign({ type: type, index: index }, blockBaseProps),
15
- react_1.default.createElement(BlockBase_1.default, Object.assign({ className: b({ type }) }, blockBaseProps), children)));
16
+ react_1.default.createElement(BlockBase_1.default, Object.assign({ className: b({ type, indentTop: top, indentBottom: bottom }) }, blockBaseProps), children)));
16
17
  };
17
18
  exports.ConstructorBlock = ConstructorBlock;
@@ -32,6 +32,7 @@ export interface Childable {
32
32
  export interface BlockBaseProps {
33
33
  anchor?: AnchorProps;
34
34
  visible?: GridColumnSize;
35
+ /** @deprecated */
35
36
  resetPaddings?: boolean;
36
37
  qa?: string;
37
38
  }
@@ -6,7 +6,12 @@ export interface PageData {
6
6
  export interface Menu {
7
7
  title: string;
8
8
  }
9
- export type ConstructorBlock = ConstructorItem | CustomBlock;
9
+ export type ConstructorBlock = (ConstructorItem | CustomBlock) & {
10
+ indent?: {
11
+ top?: string;
12
+ bottom?: string;
13
+ };
14
+ };
10
15
  export interface PageContent extends Animatable {
11
16
  blocks: ConstructorBlock[];
12
17
  menu?: Menu;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { CardLayoutBlockProps as CardLayoutBlockParams, WithChildren } from '../../models';
2
+ import { CardLayoutBlockProps as CardLayoutBlockParams, ClassNameProps, WithChildren } from '../../models';
3
3
  import './CardLayout.css';
4
- export type CardLayoutBlockProps = WithChildren<Omit<CardLayoutBlockParams, 'children'>>;
4
+ export type CardLayoutBlockProps = WithChildren<Omit<CardLayoutBlockParams, 'children'>> & ClassNameProps;
5
5
  declare const CardLayout: React.FC<CardLayoutBlockProps>;
6
6
  export default CardLayout;
@@ -9,7 +9,7 @@ const DEFAULT_SIZES = {
9
9
  md: 4,
10
10
  };
11
11
  const b = block('card-layout-block');
12
- const CardLayout = ({ title, description, animated, colSizes = DEFAULT_SIZES, children, }) => (React.createElement(AnimateBlock, { className: b(), animate: animated },
12
+ const CardLayout = ({ title, description, animated, colSizes = DEFAULT_SIZES, children, className, }) => (React.createElement(AnimateBlock, { className: b(null, className), animate: animated },
13
13
  (title || description) && React.createElement(Title, { title: title, subtitle: description }),
14
14
  React.createElement(Row, null, React.Children.map(children, (child, index) => (React.createElement(Col, { key: index, sizes: colSizes, className: b('item') }, child))))));
15
15
  export default CardLayout;
@@ -0,0 +1,38 @@
1
+ /* use this for style redefinitions to awoid problems with
2
+ unpredictable css rules order in build */
3
+ .pc-constructor-block.pc-constructor-block_indentTop_0 {
4
+ margin-top: 0;
5
+ }
6
+ .pc-constructor-block.pc-constructor-block_indentTop_xs {
7
+ margin-top: 16px;
8
+ }
9
+ .pc-constructor-block.pc-constructor-block_indentTop_s {
10
+ margin-top: 24px;
11
+ }
12
+ .pc-constructor-block.pc-constructor-block_indentTop_m {
13
+ margin-top: 32px;
14
+ }
15
+ .pc-constructor-block.pc-constructor-block_indentTop_l {
16
+ margin-top: 48px;
17
+ }
18
+ .pc-constructor-block.pc-constructor-block_indentTop_xl {
19
+ margin-top: 64px;
20
+ }
21
+ .pc-constructor-block.pc-constructor-block_indentBottom_0 {
22
+ padding-bottom: 0;
23
+ }
24
+ .pc-constructor-block.pc-constructor-block_indentBottom_xs {
25
+ padding-bottom: 16px;
26
+ }
27
+ .pc-constructor-block.pc-constructor-block_indentBottom_s {
28
+ padding-bottom: 24px;
29
+ }
30
+ .pc-constructor-block.pc-constructor-block_indentBottom_m {
31
+ padding-bottom: 32px;
32
+ }
33
+ .pc-constructor-block.pc-constructor-block_indentBottom_l {
34
+ padding-bottom: 48px;
35
+ }
36
+ .pc-constructor-block.pc-constructor-block_indentBottom_xl {
37
+ padding-bottom: 64px;
38
+ }
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { BlockDecorationProps, ConstructorBlock as ConstructorBlockType, WithChildren } from '../../../../models';
3
+ import './ConstructorBlock.css';
3
4
  interface ConstructorBlockProps extends Pick<BlockDecorationProps, 'index'> {
4
5
  data: ConstructorBlockType;
5
6
  }
@@ -3,10 +3,12 @@ import _ from 'lodash';
3
3
  import BlockBase from '../../../../components/BlockBase/BlockBase';
4
4
  import { BlockDecoration } from '../../../../customization/BlockDecoration';
5
5
  import { block } from '../../../../utils';
6
+ import './ConstructorBlock.css';
6
7
  const b = block('constructor-block');
7
8
  export const ConstructorBlock = ({ index = 0, data, children, }) => {
8
- const { type } = data;
9
+ const { type, indent } = data;
9
10
  const blockBaseProps = useMemo(() => _.pick(data, ['anchor', 'visible', 'resetPaddings']), [data]);
11
+ const { top, bottom } = indent || { top: 'l', bottom: 'l' };
10
12
  return (React.createElement(BlockDecoration, Object.assign({ type: type, index: index }, blockBaseProps),
11
- React.createElement(BlockBase, Object.assign({ className: b({ type }) }, blockBaseProps), children)));
13
+ React.createElement(BlockBase, Object.assign({ className: b({ type, indentTop: top, indentBottom: bottom }) }, blockBaseProps), children)));
12
14
  };
@@ -32,6 +32,7 @@ export interface Childable {
32
32
  export interface BlockBaseProps {
33
33
  anchor?: AnchorProps;
34
34
  visible?: GridColumnSize;
35
+ /** @deprecated */
35
36
  resetPaddings?: boolean;
36
37
  qa?: string;
37
38
  }
@@ -6,7 +6,12 @@ export interface PageData {
6
6
  export interface Menu {
7
7
  title: string;
8
8
  }
9
- export type ConstructorBlock = ConstructorItem | CustomBlock;
9
+ export type ConstructorBlock = (ConstructorItem | CustomBlock) & {
10
+ indent?: {
11
+ top?: string;
12
+ bottom?: string;
13
+ };
14
+ };
10
15
  export interface PageContent extends Animatable {
11
16
  blocks: ConstructorBlock[];
12
17
  menu?: Menu;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "4.9.0",
3
+ "version": "4.10.0",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -32,6 +32,7 @@ export interface Childable {
32
32
  export interface BlockBaseProps {
33
33
  anchor?: AnchorProps;
34
34
  visible?: GridColumnSize;
35
+ /** @deprecated */
35
36
  resetPaddings?: boolean;
36
37
  qa?: string;
37
38
  }
@@ -6,7 +6,12 @@ export interface PageData {
6
6
  export interface Menu {
7
7
  title: string;
8
8
  }
9
- export type ConstructorBlock = ConstructorItem | CustomBlock;
9
+ export type ConstructorBlock = (ConstructorItem | CustomBlock) & {
10
+ indent?: {
11
+ top?: string;
12
+ bottom?: string;
13
+ };
14
+ };
10
15
  export interface PageContent extends Animatable {
11
16
  blocks: ConstructorBlock[];
12
17
  menu?: Menu;
@@ -164,6 +164,7 @@
164
164
  padding: 0 0 $indentL;
165
165
 
166
166
  &:first-child {
167
+ // @deprecated
167
168
  margin-top: var(--pc-first-block-indent, #{$indentXXL});
168
169
  }
169
170
  }
@@ -29,7 +29,9 @@
29
29
  }
30
30
 
31
31
  .pc-page-constructor {
32
+ // @deprecated
32
33
  --pc-first-block-mobile-indent: 32px;
34
+ // @deprecated
33
35
  --pc-first-block-indent: 64px;
34
36
  margin-bottom: 120px;
35
37
  }