import { IInput } from "@hpcc-js/api" ; import { HTMLWidget } from "@hpcc-js/common" ; import "../src/Input.css" ; export class InputRange extends HTMLWidget { _inputElement = [ ] ; _labelElement = [ ] ; _rangeData = [ ] ; constructor ( ) { super ( ) ; IInput . call ( this ) ; this . _tag = "div" ; } enter ( domNode , element ) { super . enter ( domNode , element ) ; this . _labelElement [ 0 ] = element . append ( "label" ) . attr ( "for" , this . id ( ) + "_input" ) . style ( "visibility" , this . inlineLabel_exists ( ) ? "visible" : "hidden" ) ; this . _inputElement . push ( element . append ( "input" ) . attr ( "id" , this . id ( ) + "_input_min" ) . attr ( "type" , this . type ( ) ) ) ; this . _inputElement . push ( element . append ( "input" ) . attr ( "id" , this . id ( ) + "_input_max" ) . attr ( "type" , this . type ( ) ) ) ; const context = this ; this . _inputElement . forEach ( function ( e , idx ) { e . attr ( "name" , context . name ( ) ) ; e . on ( "click" , function ( w ) { w . click ( w ) ; } ) ; e . on ( "blur" , function ( w ) { w . blur ( w ) ; } ) ; e . on ( "change" , function ( w ) { context . _rangeData [ idx ] = e . property ( "value" ) ; context . value ( context . _rangeData ) ; w . change ( w , true ) ; } ) ; } ) ; } update ( domNode , element ) { super . update ( domNode , element ) ; this . _labelElement [ 0 ] . style ( "visibility" , this . inlineLabel_exists ( ) ? "visible" : "hidden" ) . text ( this . inlineLabel ( ) ) ; this . _rangeData = this . value ( ) ; this . _inputElement . forEach ( function ( e , idx ) { e . attr ( "type" , this . type ( ) ) . property ( "value" , this . _rangeData . length > idx ? this . _rangeData [ idx ] : "" ) ; } , this ) ; } type : { ( ) : string ; ( _ ) : InputRange ; } ; type_exists : ( ) => boolean ; inlineLabel : { ( ) : string ; ( _ ) : InputRange ; } ; inlineLabel_exists : ( ) => boolean ; value : { ( ) : any [ ] ; ( _ ) : InputRange ; } ; value_exists : ( ) => boolean ; name : { ( ) : string ; ( _ ) : InputRange ; } ; name_exists : ( ) => boolean ; label : { ( ) : string ; ( _ ) : InputRange ; } ; label_exists : ( ) => boolean ; validate : { ( ) : string ; ( _ ) : InputRange ; } ; validate_exists : ( ) => boolean ; } InputRange . prototype . _class += " form_InputRange" ; InputRange . prototype . implements ( IInput . prototype ) ; InputRange . prototype . publish ( "type" , "text" , "set" , "InputRange type" , [ "number" , "date" , "text" , "time" , "datetime" , "hidden" ] ) ; InputRange . prototype . publish ( "inlineLabel" , null , "string" , "InputRange Label" , null , { optional : true } ) ; InputRange . prototype . publish ( "value" , [ "" , "" ] , "array" , "Input Current Value" , null , { override : true } ) ;