import cx from 'classnames' ; import React , { ComponentType } from 'react' ; import { getDisplayName , isSizeLarge , isSizeSmall } from '../utils' ; import type { Size } from '../types' ; type Props = any & { className ? : string ; isInvalid ? : boolean ; isValid ? : boolean ; size ? : Size ; } ; function withClassNames ( Component ) { const WrappedComponent = ( { className , isInvalid , isValid , size , ... props } ) => { return ( < Component { ... props } className = { cx ( 'form-control' , 'rbt-input' , { 'form-control-lg' : isSizeLarge ( size ) , 'form-control-sm' : isSizeSmall ( size ) , 'is-invalid' : isInvalid , 'is-valid' : isValid , } , className ) } />); } ; WrappedComponent . displayName = `withClassNames(${ getDisplayName ( Component ) })` ; return WrappedComponent ; } export default withClassNames ;