@@ -20,7 +20,7 @@ interface IPrivateProps {
2020}
2121
2222interface IAnchoredProps {
23- size ?: number ,
23+ size ?: number | string ,
2424 order ?: number
2525}
2626
@@ -36,12 +36,13 @@ interface IState {
3636 adjustedSize : number ,
3737 spaceTakers : ISpaceTaker [ ] ,
3838
39+ parsedSize ?: number ;
3940 left ?: number ;
4041 top ?: number ;
4142 right ?: number ;
4243 bottom ?: number ;
43- width ?: number ;
44- height ?: number ;
44+ width ?: number | string ;
45+ height ?: number | string ;
4546}
4647
4748export const Fill : React . FC < IPublicProps > = ( props ) => < Space { ...props } />
@@ -78,6 +79,7 @@ class Space extends React.Component<AllProps, IState> {
7879 adjustedSize : 0 ,
7980 spaceTakers : [ ] ,
8081
82+ parsedSize : typeof props . size === "string" ? 0 : props . size as number | undefined ,
8183 left : props . anchor !== AnchorType . Right ? 0 : undefined ,
8284 top : props . anchor !== AnchorType . Bottom ? 0 : undefined ,
8385 right : props . anchor !== AnchorType . Left ? 0 : undefined ,
@@ -95,8 +97,9 @@ class Space extends React.Component<AllProps, IState> {
9597
9698 const currentRect = this . divElementRef . current . getBoundingClientRect ( ) ;
9799 this . setState ( {
98- currentWidth : parseInt ( currentRect . width . toFixed ( ) , 10 ) ,
99- currentHeight : parseInt ( currentRect . height . toFixed ( ) , 10 )
100+ parsedSize : ! this . state . parsedSize ? currentRect . width : this . state . parsedSize ,
101+ currentWidth : currentRect . width ,
102+ currentHeight : currentRect . height
100103 } ) ;
101104 }
102105 }
@@ -124,8 +127,8 @@ class Space extends React.Component<AllProps, IState> {
124127 top : this . state . top ,
125128 right : this . state . right ,
126129 bottom : this . state . bottom ,
127- width : this . isHorizontalSpace ( ) && this . state . adjustedSize !== 0 ? ( this . state . width || 0 ) + this . state . adjustedSize : this . state . width ,
128- height : this . isVerticalSpace ( ) && this . state . adjustedSize !== 0 ? ( this . state . height || 0 ) + this . state . adjustedSize : this . state . height
130+ width : this . isHorizontalSpace ( ) ? ( this . state . parsedSize || 0 ) + this . state . adjustedSize : undefined ,
131+ height : this . isVerticalSpace ( ) ? ( this . state . parsedSize || 0 ) + this . state . adjustedSize : undefined
129132 } ;
130133
131134 if ( parentContext ) {
@@ -182,7 +185,7 @@ class Space extends React.Component<AllProps, IState> {
182185 id : this . state . id ,
183186 order : this . props . order || 1 ,
184187 anchorType : this . props . anchor ,
185- size : this . props . size || ( this . isVerticalSpace ( ) ? this . state . currentHeight : this . state . currentWidth ) ,
188+ size : ( this . state . parsedSize || 0 ) ,
186189 adjustedSize : 0
187190 } ) ;
188191 }
@@ -217,7 +220,7 @@ class Space extends React.Component<AllProps, IState> {
217220 < Resizable
218221 type = { resizeType }
219222 minimumAdjust = { - ( this . props . size || 0 ) + ( this . props . minimumSize || 20 ) }
220- maximumAdjust = { this . props . maximumSize ? ( this . props . maximumSize - ( this . props . size || 0 ) ) : undefined }
223+ maximumAdjust = { this . props . maximumSize ? ( this . props . maximumSize - ( this . state . parsedSize || 0 ) ) : undefined }
221224 onResize = { ( adjustedSize ) => {
222225 this . setState (
223226 { adjustedSize : adjustedSize } ,
0 commit comments