Skip to content

Commit 616d387

Browse files
authored
fix: block base inner types (#413)
1 parent fc6ea6d commit 616d387

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

src/components/BlockBase/BlockBase.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@ import React, {PropsWithChildren} from 'react';
22

33
import {BlockDecoration} from '../../customization/BlockDecoration';
44
import {Col} from '../../grid';
5-
import {BlockBaseProps, ClassNameProps} from '../../models';
5+
import {BlockBaseProps, BlockDecorationProps, ClassNameProps} from '../../models';
66
import {block} from '../../utils';
77
import Anchor from '../Anchor/Anchor';
88

99
import './BlockBase.scss';
1010

1111
const b = block('block-base');
1212

13-
const BlockBase = (props: PropsWithChildren<BlockBaseProps & ClassNameProps>) => {
13+
export type BlockBaseFullProps = BlockBaseProps &
14+
BlockDecorationProps &
15+
ClassNameProps &
16+
PropsWithChildren;
17+
18+
const BlockBase = (props: BlockBaseFullProps) => {
1419
const {anchor, visible, children, className, resetPaddings, qa, type, index} = props;
1520

1621
return (

src/components/BlockBase/__tests__/BlockBase.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import {render, screen} from '@testing-library/react';
55
import {testCustomClassName} from '../../../../test-utils/shared/common';
66
import {qaIdByDefault} from '../../../components/Anchor/Anchor';
77
import {GridColumnSize} from '../../../grid';
8-
import {BlockBaseProps, BlockTypes, ClassNameProps, WithChildren} from '../../../models';
9-
import BlockBase from '../BlockBase';
8+
import {BlockTypes, ClassNameProps, WithChildren} from '../../../models';
9+
import BlockBase, {BlockBaseFullProps} from '../BlockBase';
1010

1111
const qaId = 'block-base-component';
1212
const blockType = BlockTypes[0];
1313

14-
type ComponentProps = WithChildren<BlockBaseProps & ClassNameProps>;
14+
type ComponentProps = WithChildren<BlockBaseFullProps & ClassNameProps>;
1515

1616
describe('BlockBase', () => {
1717
test('render component by default', async () => {

src/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
22

3-
import BlockBase from '../../../../components/BlockBase/BlockBase';
4-
import {Block, BlockBaseProps, WithChildren} from '../../../../models';
3+
import BlockBase, {BlockBaseFullProps} from '../../../../components/BlockBase/BlockBase';
4+
import {Block, WithChildren} from '../../../../models';
55
import {block} from '../../../../utils';
66

7-
interface ConstructorBlockProps extends Pick<BlockBaseProps, 'index'> {
7+
interface ConstructorBlockProps extends Pick<BlockBaseFullProps, 'index'> {
88
data: Block;
99
}
1010

src/models/constructor-items/blocks.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ export interface Childable {
6363

6464
//block props
6565
export interface BlockBaseProps {
66-
type: BlockType;
67-
index?: number;
6866
anchor?: AnchorProps;
6967
visible?: GridColumnSize;
7068
resetPaddings?: boolean;

src/models/customization.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import {PropsWithChildren} from 'react';
22

3-
import {BlockBaseProps} from './constructor-items';
3+
import {BlockType} from './constructor-items';
44

5-
export type BlockDecorationProps = Pick<BlockBaseProps, 'index' | 'type'> & PropsWithChildren;
5+
export interface BlockDecorationProps extends PropsWithChildren {
6+
type: BlockType;
7+
index?: number;
8+
}
69
export type BlockDecorator = (props: BlockDecorationProps) => React.ReactElement;

0 commit comments

Comments
 (0)