import { mergeCallback } from './mergeCallback' ; /**
 * Merges source props into target props, overwriting target props that are also defined on source
 * props. Callback will be merged in such a way that both callbacks will be called.
 */ export function mergeProps < T extends object , S extends object > ( targetProps , sourceProps ) { const returnProps = { ... targetProps } as S & T ; for ( const key in sourceProps ) { if ( sourceProps . hasOwnProperty ( key ) ) { if ( key === 'css' && targetProps . hasOwnProperty ( 'css' ) ) { const css = [ ] . concat ( targetProps [ key ] , sourceProps [ key ] ) ; returnProps [ key ] = css ; } else if ( key === 'style' && targetProps . hasOwnProperty ( 'style' ) ) { returnProps [ key ] = { ... targetProps [ key ] , ... sourceProps [ key ] } ; } else if ( typeof sourceProps [ key ] === 'function' && typeof targetProps [ key ] === 'function' ) { returnProps [ key ] = mergeCallback ( targetProps [ key ] , sourceProps [ key ] ) ; } else if ( typeof sourceProps [ key ] === 'undefined' && typeof targetProps [ key ] === 'function' ) { } else if ( key === 'ref' && sourceProps . hasOwnProperty ( 'ref' ) ) { ( returnProps as any ) . ref = ( returnProps as any ) . ref || ( sourceProps as any ) . ref ; } else { returnProps [ key ] = sourceProps [ key ] ; } } } return returnProps ; }