import { resizeColumn } from '../actionCreators' ; import { DispatchFunc } from '../types' ; export const isCellResizeShown = ( isResizable ? , columnResizing ? ) : boolean => ! ! ( ( isResizable !== false ) && ( columnResizing || isResizable ) ) ; export const getMouseMove = ( currentWidth , minWidth , startX , key , dispatch ) => ( event ) => { let newWidth = event . screenX - startX ; if ( newWidth !== currentWidth ) { newWidth = getValidatedWidth ( newWidth , minWidth ) ; dispatch ( resizeColumn ( key , newWidth ) ) ; } } ; export const getValidatedWidth = ( newWidth , minWidth ) => { if ( newWidth < minWidth ) { return minWidth ; } return newWidth ; } ; export const isNumberWidth = ( width ) : boolean => width && typeof width === 'number' ; export const getMinWidth = ( style ) : number => { let minWidth = 20 ; if ( ! style ) { return minWidth ; } const styleMinWidth = style . minWidth ; if ( isNumberWidth ( styleMinWidth ) ) { minWidth = styleMinWidth ; } return minWidth ; } ;