import { SafeAny } from 'ngx-tethys/types' ; import { coerceBooleanProperty , coerceCssPixelValue , coerceNumberValue } from 'ngx-tethys/util' ; export function InputBoolean ( ) { return makePropDecorator ( 'InputBoolean' , coerceBooleanProperty ) ; } export function InputCssPixel ( ) { return makePropDecorator ( 'InputCssPixel' , coerceCssPixelValue ) ; } export function InputNumber ( ) { return makePropDecorator ( 'InputNumber' , coerceNumberValue ) ; } function makePropDecorator < T , D > ( name , transform , initialize ? ) { function propDecorator ( target , propName , originalDescriptor ? ) { initialize && initialize ( target , propName ) ; const privatePropName = `$$__${ propName }` ; if ( Object . prototype . hasOwnProperty . call ( target , privatePropName ) ) { console . warn ( `The property "${ privatePropName }" is already exist, it will be overrided by ${ name } decorator.` ) ; } Object . defineProperty ( target , privatePropName , { configurable : true , writable : true } ) ; return { get ( ) { return originalDescriptor && originalDescriptor . get ? originalDescriptor . get . bind ( this ) ( ) : this [ privatePropName ] ; } , set ( value ) { const finalValue = transform ( value , target ) ; if ( originalDescriptor && originalDescriptor . set ) { originalDescriptor . set . bind ( this ) ( finalValue ) ; } this [ privatePropName ] = finalValue ; } } ; } return propDecorator ; }