-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathrectangle-low-shape.tsx
66 lines (57 loc) · 1.6 KB
/
rectangle-low-shape.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { ShapeSizeRestrictions, ShapeType } from '@/core/model';
import { forwardRef } from 'react';
import { ShapeProps } from '../shape.model';
import { fitSizeToShapeSizeRestrictions } from '@/common/utils/shapes';
import { Group, Rect } from 'react-konva';
import { useGroupShapeProps } from '../mock-components.utils';
import { useShapeProps } from '../../shapes/use-shape-props.hook';
import { BASIC_SHAPE } from '../front-components/shape.const';
const rectangleLowShapeRestriction: ShapeSizeRestrictions = {
minWidth: 10,
minHeight: 10,
maxWidth: -1,
maxHeight: -1,
defaultWidth: 160,
defaultHeight: 160,
};
export const getRectangleLowShapeRestrictions = (): ShapeSizeRestrictions =>
rectangleLowShapeRestriction;
const shapeType: ShapeType = 'rectangleLow';
export const RectangleLowShape = forwardRef<any, ShapeProps>((props, ref) => {
const {
x,
y,
width,
height,
id,
onSelected,
text,
otherProps,
...shapeProps
} = props;
const restrictedSize = fitSizeToShapeSizeRestrictions(
rectangleLowShapeRestriction,
width,
height
);
const { width: restrictedWidth, height: restrictedHeight } = restrictedSize;
const { stroke, strokeStyle } = useShapeProps(otherProps, BASIC_SHAPE);
const commonGroupProps = useGroupShapeProps(
props,
restrictedSize,
shapeType,
ref
);
return (
<Group {...commonGroupProps} {...shapeProps}>
<Rect
width={restrictedWidth}
height={restrictedHeight}
stroke={stroke}
dash={strokeStyle}
strokeWidth={6}
fill="white"
/>
</Group>
);
});