export enum EElementSignature { checkbox = 'checkbox' , string = 'string' , number = 'number' } export function getElementType ( el ) { if ( typeof el !== 'object' || el === null ) { return undefined ; } return typeof el . signature === 'string' ? el . signature : undefined ; } export function getElement ( signature , params ) { if ( typeof signature !== 'string' ) { return ; } const references = { [ EElementSignature . checkbox ] : ElementCheckboxRef , [ EElementSignature . string ] : ElementInputStringRef , [ EElementSignature . number ] : ElementInputNumberRef , } ; if ( ( references as any ) [ signature ] === undefined ) { return undefined ; } try { return new ( references as any ) [ signature ] ( params ) ; } catch ( e ) { return undefined ; } } export class Element < T > { private _value : T | undefined ; public set ( value ) { this . _value = value ; } public get ( ) { return this . _value ; } } export interface IElement { getParams ( ) : any ; } export class ElementCheckboxRef implements IElement { public static readonly signature : EElementSignature = EElementSignature . checkbox ; public readonly signature : EElementSignature = ElementCheckboxRef . signature ; public getParams ( ) { return undefined ; } } interface IElementInputStringRef { placeholder : string ; } export class ElementInputStringRef implements IElement { public static readonly signature : EElementSignature = EElementSignature . string ; public readonly signature : EElementSignature = ElementInputStringRef . signature ; public placeholder : string ; constructor ( params ) { this . placeholder = params . placeholder ; } public getParams ( ) { return { placeholder : this . placeholder , } ; } } interface IElementInputNumberRef { placeholder : string ; min : number ; max : number ; } export class ElementInputNumberRef implements IElement { public static readonly signature : EElementSignature = EElementSignature . number ; public readonly signature : EElementSignature = ElementInputNumberRef . signature ; public placeholder : string ; public min : number ; public max : number ; constructor ( params ) { this . placeholder = params . placeholder ; this . min = params . min ; this . max = params . max ; } public getParams ( ) { return { placeholder : this . placeholder , min : this . min , max : this . max , } ; } } export type ElementRefs = ElementCheckboxRef | ElementInputNumberRef | ElementInputStringRef ;