@@ -2,12 +2,14 @@ import { ShapeSizeRestrictions, ShapeType } from '@/core/model';
22import { forwardRef , useEffect , useState } from 'react' ;
33import { Group , Image , Rect , Text } from 'react-konva' ;
44import { ShapeProps } from '../../shape.model' ;
5- import { fitSizeToShapeSizeRestrictions } from '@/common/utils/shapes' ;
65import { useGroupShapeProps } from '../../mock-components.utils' ;
76import { loadSvgWithFill } from '@/common/utils/svg.utils' ;
87import { useShapeProps } from '@/common/components/shapes/use-shape-props.hook' ;
98import { BASIC_SHAPE } from '../../front-components/shape.const' ;
10- import { parseFileTreeText } from './file-tree.business' ;
9+ import {
10+ calculateFileTreeDynamicSize ,
11+ parseFileTreeText ,
12+ } from './file-tree.business' ;
1113
1214const fileTreeShapeRestrictions : ShapeSizeRestrictions = {
1315 minWidth : 220 ,
@@ -51,20 +53,23 @@ export const FileTreeShape = forwardRef<any, FileTreeShapeProps>(
5153 }
5254 ) ;
5355
54- const restrictedSize = fitSizeToShapeSizeRestrictions (
55- fileTreeShapeRestrictions ,
56- width ,
57- height
58- ) ;
59- const { width : restrictedWidth , height : restrictedHeight } = restrictedSize ;
60-
6156 const iconWidth = 50 ;
6257 const elementHeight = 60 ;
6358 const paddingX = 40 ;
64- const paddingTop = 30 ;
59+ const paddingY = 30 ;
6560 const fileX = 50 + paddingX ;
6661 const iconTextSpacing = 10 ;
6762
63+ const restrictedSize = calculateFileTreeDynamicSize ( treeItems , {
64+ width,
65+ height,
66+ elementHeight,
67+ paddingY,
68+ baseRestrictions : fileTreeShapeRestrictions ,
69+ } ) ;
70+
71+ const { width : restrictedWidth , height : restrictedHeight } = restrictedSize ;
72+
6873 const folderTextX = iconWidth + iconTextSpacing + paddingX ;
6974 const fileTextX = fileX + iconWidth + iconTextSpacing ;
7075
@@ -102,7 +107,7 @@ export const FileTreeShape = forwardRef<any, FileTreeShapeProps>(
102107 x = { 0 }
103108 y = { 0 }
104109 width = { restrictedWidth }
105- height = { restrictedHeight + 20 }
110+ height = { restrictedHeight }
106111 stroke = { stroke }
107112 strokeWidth = { 2 }
108113 fill = { fill }
@@ -116,14 +121,14 @@ export const FileTreeShape = forwardRef<any, FileTreeShapeProps>(
116121 < Image
117122 image = { icons [ item . type ] ! }
118123 x = { item . type === 'file' ? fileX : paddingX }
119- y = { paddingTop + elementHeight * index }
124+ y = { paddingY + elementHeight * index }
120125 width = { iconWidth }
121126 height = { iconWidth }
122127 />
123128 ) }
124129 < Text
125130 x = { item . type === 'file' ? fileTextX : folderTextX }
126- y = { paddingTop + elementHeight * index + 20 }
131+ y = { paddingY + elementHeight * index + 20 }
127132 text = { item . text }
128133 width = {
129134 item . type === 'file' ? fileAvailableWidth : folderAvailableWidth
0 commit comments