11import { AllProps , IState , AnchorTypes , ResizeType } from './Types' ;
22import * as React from 'react' ;
3- import { initialState , isHorizontalSpace , isVerticalSpace , getSizeString , isFilledSpace , applyResize , createContext } from './Utils' ;
3+ import { initialState , isHorizontalSpace , isVerticalSpace , getSizeString , isFilledSpace , applyResize , createContext , cssValue } from './Utils' ;
44import { ResizeSensor } from 'css-element-queries' ;
55import { AnchorType } from './Types' ;
66import { SpaceContext , SpaceLayerContext } from './Contexts' ;
@@ -70,12 +70,12 @@ export const useSpace = (props: AllProps, divElementRef: React.MutableRefObject<
7070 } )
7171
7272 const outerStyle = {
73- left : ( state . left !== undefined ? `calc( ${ getSizeString ( state . left || 0 ) } ${ state . adjustedLeft ? ` + ${ state . adjustedLeft } px` : `` } )` : undefined ) ,
74- top : ( state . top !== undefined ? `calc( ${ getSizeString ( state . top || 0 ) } ${ state . adjustedTop ? ` + ${ state . adjustedTop } px` : `` } )` : undefined ) ,
75- right : ( state . right !== undefined ? `calc( ${ getSizeString ( state . right || 0 ) } ${ state . adjustedLeft ? ` - ${ state . adjustedLeft } px` : `` } )` : undefined ) ,
76- bottom : ( state . bottom !== undefined ? `calc( ${ getSizeString ( state . bottom || 0 ) } ${ state . adjustedTop ? ` - ${ state . adjustedTop } px` : `` } )` : undefined ) ,
77- width : isHorizontalSpace ( props ) ? `calc( ${ getSizeString ( props . anchorSize || 0 ) } + ${ state . adjustedSize } px)` : state . width ,
78- height : isVerticalSpace ( props ) ? `calc( ${ getSizeString ( props . anchorSize || 0 ) } + ${ state . adjustedSize } px)` : state . height ,
73+ left : ( state . left !== undefined ? cssValue ( state . left , state . adjustedLeft ) : undefined ) ,
74+ top : ( state . top !== undefined ? cssValue ( state . top , state . adjustedTop ) : undefined ) ,
75+ right : ( state . right !== undefined ? cssValue ( state . right , state . adjustedLeft ) : undefined ) ,
76+ bottom : ( state . bottom !== undefined ? cssValue ( state . bottom , state . adjustedTop ) : undefined ) ,
77+ width : isHorizontalSpace ( props ) ? cssValue ( props . anchorSize , state . adjustedSize ) : state . width ,
78+ height : isVerticalSpace ( props ) ? cssValue ( props . anchorSize , state . adjustedSize ) : state . height ,
7979 zIndex : currentZIndex ,
8080 } ;
8181
@@ -100,7 +100,7 @@ export const useSpace = (props: AllProps, divElementRef: React.MutableRefObject<
100100 {
101101 const t = spaceTakers [ i ] ;
102102 if ( t . id !== state . id ) {
103- const adjustedSize = t . adjustedSize !== 0 ?` + ${ t . adjustedSize } px ` : `` ;
103+ const adjustedSize = t . adjustedSize !== 0 ? ` + ${ getSizeString ( t . adjustedSize ) } ` : `` ;
104104 if ( isFilledSpace ( props ) )
105105 {
106106 if ( t . anchorType === AnchorType . Top ) {
@@ -178,12 +178,11 @@ export const useSpace = (props: AllProps, divElementRef: React.MutableRefObject<
178178 [
179179 ...[
180180 "spaces-space" ,
181- props . anchor || undefined ,
182181 resize . resizeType || undefined ,
183- props . scrollable ? "scrollable" : undefined ,
182+ props . scrollable ? ( resize . resizeHandle ? "scrollable" : "scrollable-a" ) : undefined ,
184183 debug ? 'debug' : undefined
185184 ] ,
186- ...userClasses . map ( c => `${ c } -container` )
185+ ...( resize . resizeHandle && props . scrollable ? userClasses . map ( c => `${ c } -container` ) : userClasses )
187186 ] . filter ( c => c ) ;
188187
189188 const innerClasses =
0 commit comments