jsdk-offical
Version:
JSDK is the most comprehensive TypeScript framework, like JDK.
2 lines • 112 kB
JavaScript
//JSDK 2.7.0 MIT
var JS;(function(JS){let fx;(function(fx){let SizeMode;(function(SizeMode){SizeMode["hg"]="hg";SizeMode["lg"]="lg";SizeMode["md"]="md";SizeMode["sm"]="sm";SizeMode["xs"]="xs"})(SizeMode=fx.SizeMode||(fx.SizeMode={}));let ColorMode;(function(ColorMode){ColorMode["success"]="success";ColorMode["danger"]="danger";ColorMode["warning"]="warning";ColorMode["info"]="info";ColorMode["primary"]="primary";ColorMode["secondary"]="secondary";ColorMode["accent"]="accent";ColorMode["metal"]="metal";ColorMode["light"]="light";ColorMode["dark"]="dark"})(ColorMode=fx.ColorMode||(fx.ColorMode={}));class WidgetConfig{constructor(){this.name="";this.tip="";this.style="";this.cls="";this.appendTo="body";this.renderTo=null;this.hidden=false;this.sizeMode=SizeMode.md;this.faceMode=null;this.locale="en";this.i18n=null}}fx.WidgetConfig=WidgetConfig})(fx=JS.fx||(JS.fx={}))})(JS||(JS={}));var SizeMode=JS.fx.SizeMode;var ColorMode=JS.fx.ColorMode;var WidgetConfig=JS.fx.WidgetConfig;var __decorate=this&&this.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r};var __metadata=this&&this.__metadata||function(k,v){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(k,v)};var JS;(function(JS){let fx;(function(fx){let J=Jsons;let Widget=class Widget{constructor(cfg){this._config=null;this._initialConfig=null;this._isD=false;this._i18nObj=null;if(!cfg.id&&cfg.renderTo){let wgt=$(cfg.renderTo);if(wgt.length==1){this.widgetEl=wgt;let id=wgt.attr("id");if(id){this.id=id}else{this.id=Random.uuid(4,10).toString();wgt.attr("id",this.id)}}}else{this.id=cfg.id||Random.uuid(4,10).toString()}this._initConfig(cfg);this._onBeforeInit();this._initDom();this._onAfterInit()}_onBeforeInit(){}_onAfterInit(){}_initDom(){let cfg=this._config;this.widgetEl=$("#"+this.id);if(this.widgetEl.length==0){this.widgetEl=$("<div />",{id:this.id,width:cfg.width,height:cfg.height,title:cfg.tip,style:cfg.style,"klass-name":this.className}).appendTo(cfg.appendTo||"body")}else{let attrs={};if(cfg.tip)attrs["title"]=cfg.tip;if(cfg.style)attrs["style"]=(this.widgetEl.attr("style")||"")+cfg.style;if(!Check.isEmpty(attrs))this.widgetEl.attr(attrs);if(cfg.width)this.widgetEl.css("width",cfg.width)}this._eventBus=new EventBus(this);let listeners=cfg.listeners;if(listeners&&listeners.rendering)this.on("rendering",listeners.rendering);this.render()}_initConfig(cfg){let defaultCfg=Class.newInstance(this.className+"Config");cfg.name=cfg.name||this.id;this._config=J.union(defaultCfg,cfg);this._initialConfig=J.clone(this._config)}initialConfig(key){return J.clone(key?this._initialConfig[key]:this._initialConfig)}_onBeforeRender(){}_onAfterRender(){}render(){this._onBeforeRender();this._fire("rendering");this.off();this.widgetEl.off().empty();let cfg=this._config;this.widgetEl.addClass(`jsfx-${this.getClass().shortName.toLowerCase()} ${cfg.colorMode?"color-"+cfg.colorMode:""} size-${cfg.sizeMode} ${cfg.cls||""}`);let is=this._render();let lts=cfg.listeners||{};J.forEach(lts,function(handler,type){if(handler)this.on(type,handler)},this);this._onAfterRender();if(is!==false)this._fire("rendered");return this}name(){return this._config.name||""}_hasFaceMode(key,cfg){cfg=cfg||this._config;let t=cfg.faceMode;if(!t)return false;return t==key||t[key]===true||$.inArray(key,t)!=-1}_eachMode(type,fn,cfg){cfg=cfg||this._config;let mode=cfg[type];if(!mode)return;let me=this;if(Types.isArray(mode)){mode.forEach(m=>{fn.apply(this,[m])})}else{fn.apply(me,[mode])}}destroy(){this._fire("destroying");this._destroy();this._fire("destroyed")}_destroy(){this.off();this.widgetEl.remove();this._eventBus.destroy();this._isD=true}show(){this._fire("showing");this.widgetEl.css("display","");this._fire("shown");return this}hide(){this._fire("hiding");this.widgetEl.css("display","none");this._fire("hidden");return this}isShown(){return this.widgetEl.css("display")!="none"}on(types,fn,once){this._eventBus.on(types,fn,once);return this}off(types){this._eventBus.off(types);return this}_fire(e,args){return this._eventBus.fire(e,args)}_newI18N(){let lc=this._config.locale,n=new I18N(lc),v=this.getClass().getKlass()["I18N"];if(v)typeof v=="string"?n.load(v):n.set(v);let i18n=this._config.i18n;if(i18n){if(Types.isString(i18n)){n.load(i18n,lc)}else{n.set(J.union(n.get(),i18n))}}this._i18nObj=n}_i18n(key){if(!this._i18nObj)this._newI18N();return this._i18nObj.get(key)}locale(lc){if(arguments.length==0)return this._config.locale;this._config.locale=lc;return this}};Widget.I18N=null;Widget=__decorate([klass("JS.fx.Widget"),__metadata("design:paramtypes",[fx.WidgetConfig])],Widget);fx.Widget=Widget})(fx=JS.fx||(JS.fx={}))})(JS||(JS={}));var Widget=JS.fx.Widget;var JS;(function(JS){let fx;(function(fx){let J=Jsons;class FormWidgetConfig extends fx.WidgetConfig{constructor(){super(...arguments);this.disabled=false;this.dataModel=ListModel;this.valueModel=Model;this.validators=[];this.autoValidate=false;this.validateMode="tip";this.readonly=false;this.titlePlace="left";this.titleTextPlace="rm";this.data=null;this.iniValue=null}}fx.FormWidgetConfig=FormWidgetConfig;class FormWidget extends fx.Widget{constructor(cfg){super(cfg)}iniValue(v,render){let cfg=this._config;if(arguments.length==0)return cfg.iniValue;cfg.iniValue=v;if(render)this.value(v,true);return this}readonly(is){if(arguments.length==0)return this._config.readonly;this._mainEl.prop("readonly",is);this._config.readonly=is;return this}_onBeforeInit(){this._initDataModel();this._initValueModel()}_onAfterInit(){let cfg=this._config;if(cfg.dataQuery)this.load(cfg.dataQuery,true);cfg.disabled?this.disable():this.enable()}disable(){this._mainEl.prop("disabled",true);this._config.disabled=true;return this}enable(){this._mainEl.prop("disabled",false);this._config.disabled=false;return this}isEnabled(){return!this._config.disabled}title(text){let cfg=this._config;if(arguments.length==0)return cfg.title;this.widgetEl.find('div[jsfx-role="title"]>span').html(text);cfg.title=text;return this}_hAlign(){let al=this._config.titleTextPlace||"lm";return{l:"left",r:"right",c:"center"}[al.substr(0,1)]}_vAlign(){let al=this._config.titleTextPlace||"lm";return{t:"top",b:"bottom",m:"middle"}[al.substr(1,1)]}_render(){let cfg=this._config,titleAttrs=cfg.tip?` title=${cfg.tip}`:"";if(cfg.title){let tValign=this._vAlign(),tHalign=this._hAlign(),p0=tHalign=="right"&&cfg.titlePlace=="top"?"p-0":"",cls=`${p0} font-${cfg.sizeMode||"md"} items-${tValign} items-${tHalign} ${cfg.colorMode?"text-"+cfg.colorMode:""} ${cfg.titleCls||""}"`;let style=Types.isDefined(cfg.titleWidth)?`width:${CssTool.normValue(cfg.titleWidth,"100%")};`:"";if(cfg.titleStyle)style+=cfg.titleStyle;titleAttrs+=` class="${cls}"`;if(style)titleAttrs+=` style="${style}"`}let html=`<div jsfx-role="title"${titleAttrs}>${cfg.title?"<span>"+cfg.title+"</span>":""}</div> \n <div jsfx-role="body" class="font-${cfg.sizeMode||"md"} items-middle ${cfg.bodyCls||""}" style="flex:1;${cfg.bodyStyle||""}">\n ${this._bodyFragment()}\n </div>`;this.widgetEl.html(html);this._mainEl=this.widgetEl.find("[jsfx-role=main]")}_onBeforeRender(){let cfg=this._config,w=CssTool.normValue(cfg.width,"100%"),d=cfg.titlePlace=="left"?"flex":"grid",css={display:(w=="auto"?"inline-":"")+d,width:w};this.widgetEl.css(css)}_iniValue(){let cfg=this._config;this.value(cfg.iniValue,true)}_onAfterRender(){this.on("validated",(e,rst,val,name)=>{window.setTimeout(()=>{rst.hasError()?this._showError(rst.getErrors(name)[0].message):this._hideError()},100)});this._iniValue()}_showError(msg){let cfg=this._config,mode=cfg.validateMode,fn=mode=="tip"||mode&&mode["mode"]=="tip"?this._showTipError:mode["showError"];if(fn)fn.apply(this,[msg])}_hideError(){let cfg=this._config,mode=cfg.validateMode,fn=mode=="tip"||mode&&mode["mode"]=="tip"?this._hideTipError:mode["hideError"];if(fn)fn.call(this)}_getTipEl(place){let cfg=this._config;return this.widgetEl.find(cfg.titlePlace=="left"&&place=="left"?"[jsfx-role=title]>span":"[jsfx-role=body]")}_showTipError(msg){if(!msg)return;let div=this.widgetEl.find(".error .tooltip-inner");if(div.length==1){div.html(msg)}else{let cfg=this._config,mode=cfg.validateMode,place=mode&&mode["place"]?mode["place"]:"right",el=this._getTipEl(place);el.tooltip({placement:place,offset:"0, 2px",fallbackPlacement:"clockwise",container:el[0],trigger:"manual",html:false,title:msg,template:'<div class="tooltip error" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>'}).tooltip("show")}}_hideTipError(){let cfg=this._config,mode=cfg.validateMode,place=mode&&mode["place"]?mode["place"]:"right",el=this._getTipEl(place);if(el.tooltip)el.tooltip("dispose")}_validate(name,val,rst){let field=new ModelField({name,validators:this._config.validators});return field.validate(val,rst)}validate(){if(Check.isEmpty(this._config.validators))return true;let name=this.name(),rst=new ValidateResult,val=J.clone(this.value());this._fire("validating",[rst,val,name]);let vdt=this._validate(name,val,rst);this._fire("validated",[rst,val,name]);return vdt}dataModel(){return this._dataModel}_initDataModel(){let me=this,cfg=this._config;this._dataModel=Class.newInstance(cfg.dataModel);["loading","loadsuccess","loadfailure","loaderror","dataupdating","dataupdated"].forEach(e=>{this._dataModel.on(e,function(){if(e=="dataupdated")me.data(this.getData(),true);me._fire(e,Arrays.slice(arguments,1))})})}data(data,silent){let cfg=this._config;if(arguments.length==0)return cfg.data;let newData=J.clone(data),oldData=J.clone(cfg.data);if(!silent)this._fire("dataupdating",[newData,oldData]);cfg.data=data;if(this._dataModel)this._dataModel.setData(data,true);this._renderData();this._renderValue();if(!silent)this._fire("dataupdated",[newData,oldData]);return this}_renderData(){}clear(silent){return this.value(null,silent)}load(quy,silent){let cfg=this._config;cfg.dataQuery=J.union(Http.toRequest(cfg.dataQuery),Http.toRequest(quy));return this._dataModel.load(cfg.dataQuery,silent)}reload(){if(this._dataModel)this._dataModel.reload();return this}_equalValues(newVal,oldVal){return oldVal==newVal}value(val,silent){let cfg=this._config,oldVal=this._valueModel.get(this.name());if(arguments.length==0)return oldVal;this._setValue(val,silent);this._renderValue();return this}_setValue(val,silent){this._hideError();this._valueModel.set(this.name(),val,silent||this._equalValues(val,this.value()));if(this._config.autoValidate)this.validate()}_renderValue(){let v=this.value()||"";if(this._mainEl.val()!==v)this._mainEl.val(v)}reset(){return this.value(this._config.iniValue)}valueModel(){return this._valueModel}_initValueModel(){let cfg=this._config,vModel=cfg.valueModel;if(!vModel){this._valueModel=new Model}else if(Types.subklassOf(vModel,Model)){this._valueModel=Class.newInstance(vModel)}else{this._valueModel=vModel}this._valueModel.addField({name:this.name(),validators:cfg.validators});let me=this;this._valueModel.on("dataupdated",function(e,newData){let fName=me.name();if(newData&&newData.hasOwnProperty(fName)){me.value(newData[fName])}});this._valueModel.on("fieldchanged",(e,newVal,oldVal)=>{this._fire("changed",[newVal,oldVal])})}}fx.FormWidget=FormWidget})(fx=JS.fx||(JS.fx={}))})(JS||(JS={}));var FormWidgetConfig=JS.fx.FormWidgetConfig;var FormWidget=JS.fx.FormWidget;var JS;(function(JS){let fx;(function(fx){let ButtonFaceMode;(function(ButtonFaceMode){ButtonFaceMode["square"]="square";ButtonFaceMode["round"]="round";ButtonFaceMode["round_left"]="round-left";ButtonFaceMode["round_right"]="round-right";ButtonFaceMode["pill"]="pill";ButtonFaceMode["pill_left"]="pill-left";ButtonFaceMode["pill_right"]="pill-right";ButtonFaceMode["shadow"]="shadow"})(ButtonFaceMode=fx.ButtonFaceMode||(fx.ButtonFaceMode={}));class ButtonConfig extends fx.WidgetConfig{constructor(){super(...arguments);this.faceMode=ButtonFaceMode.square;this.outline=false;this.dropMenu=null;this.disabled=false}}fx.ButtonConfig=ButtonConfig;let Button=class Button extends fx.Widget{constructor(cfg){super(cfg)}_render(){let cfg=this._config,text=cfg.text||"",cls="btn btn-block",bdgAttr="";if(cfg.colorMode)cls+=` btn-${cfg.colorMode}`;if(cfg.outline)cls+=" btn-outline";if(cfg.sizeMode)cls+=` btn-${cfg.sizeMode}`;if(cfg.badge){let isStr=Types.isString(cfg.badge),bdg={text:isStr?cfg.badge:cfg.badge.text||"",color:isStr?fx.ColorMode.danger:cfg.badge.color||fx.ColorMode.danger};cls+=" jsfx-badge jsfx-badge-"+bdg.color;bdgAttr=` data-badge="${bdg.text}"`}if(cfg.dropMenu)cls+=` dropdown-toggle`;this._eachMode("faceMode",mode=>{cls+=" border-"+mode});if(cfg.cls)cls+=" "+cfg.cls;let icon="";if(cfg.iconCls)icon=`<i class="${cfg.iconCls}"></i>`;let button=`<button type="button" ${cfg.style?'style="'+cfg.style+'"':""} ${cfg.disabled?"disabled":""} ${bdgAttr} title="${cfg.tip}" ${cfg.dropMenu?'data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"':""} class="${cls}" jsfx-role="main">\n ${icon}${text?icon?` ${text}`:text:""}</button>`;if(cfg.dropMenu)button=this._dropDown(button);this.widgetEl.html(button);this._mainEl=this.widgetEl.find("[jsfx-role=main]")}_onAfterRender(){this._mainEl.on("click",()=>{return this._fire("click")})}_dropDown(buttonHtml){let dropDown=this._config.dropMenu,html=`\n <div class="btn-group ${"drop"+(dropDown.dir||"down")}">\n ${buttonHtml}\n <div class="dropdown-menu">\n ${this._dropDownItems(dropDown.items)}\n </div>\n </div>\n `;return html}_dropDownItems(items){if(!Types.isDefined(items))return"";let html="";items.forEach((item,i)=>{html+=this._dropDownItem(item,i)});return html}_dropDownItem(item,index){let id="dropdown-item"+index+"-"+Random.uuid(3,10),span=item.html||`${item.iconCls?`<i class="${item.iconCls}"></i>`:""}<span class="">${Strings.escapeHTML(item.text)}</span>`,html="";if(item.caption)html+=`<h6 class='dropdown-header'>${Strings.escapeHTML(item.caption)}</h6>`;html+=`<a class='dropdown-item ${this._config.colorMode} ${item.selected?"active":""}' id='${id}' href='${item.href?encodeURI(item.href):"javascript:void(0);"}'>${span}</a>`;if(item.hasDivider)html+=`<div class='dropdown-divider'></div>`;let me=this;if(item.onClick)$(document).on("click","#"+id,function(e){return item.onClick.apply(me,[e.originalEvent,item])});return html}disable(){this._mainEl.prop("disabled",true);this._config.disabled=true;return this}enable(){this._mainEl.prop("disabled",false);this._config.disabled=false;return this}toggle(){let d=this._mainEl.find(".dropdown-toggle");if(d.length<1)return;d.dropdown("toggle");return this}badge(option){if(arguments.length==0){return this._mainEl.attr("data-badge")}else if(Check.isEmpty(option)){this._mainEl.removeAttr("data-badge")}else{let isStr=Types.isString(option),bdg={text:isStr?option:option.text||"",color:isStr?fx.ColorMode.danger:option.color||fx.ColorMode.danger};this._mainEl.addClass("jsfx-badge jsfx-badge-"+bdg.color);bdg.text?this._mainEl.attr("data-badge",bdg.text):this._mainEl.removeAttr("data-badge")}return this}};Button=__decorate([widget("JS.fx.Button"),__metadata("design:paramtypes",[ButtonConfig])],Button);fx.Button=Button})(fx=JS.fx||(JS.fx={}))})(JS||(JS={}));var Button=JS.fx.Button;var ButtonConfig=JS.fx.ButtonConfig;var ButtonFaceMode=JS.fx.ButtonFaceMode;var JS;(function(JS){let fx;(function(fx){let J=Jsons,Y=Types,E=Check.isEmpty;let SelectFaceMode;(function(SelectFaceMode){SelectFaceMode["square"]="square";SelectFaceMode["round"]="round";SelectFaceMode["pill"]="pill";SelectFaceMode["shadow"]="shadow"})(SelectFaceMode=fx.SelectFaceMode||(fx.SelectFaceMode={}));class SelectOption{constructor(){this.selected=false;this.disabled=false}}fx.SelectOption=SelectOption;class SelectConfig extends fx.FormWidgetConfig{constructor(){super(...arguments);this.rtl=false;this.outline=false;this.autoSelectFirst=false;this.crud=false;this.multiple=false;this.allowClear=false;this.maximumSelectionLength=Infinity;this.autoSearch=false;this.minimumInputLength=0;this.inputable=false;this.autoEscape=true}}fx.SelectConfig=SelectConfig;let Select=class Select extends fx.FormWidget{constructor(cfg){super(cfg)}load(api){if(this._config.autoSearch)throw new RefusedError("The method be not supported when autoSearch is true!");return super.load(api)}iniValue(v,render){if(arguments.length==0)return super.iniValue();return super.iniValue(v,render)}_destroy(){this._mainEl.select2("destroy");super._destroy()}_bodyFragment(){let cfg=this._config,cls="";if(cfg.colorMode){if(cfg.outline)cls+=" outline";cls+=` ${cfg.colorMode}`}this._eachMode("faceMode",mode=>{cls+=" face-"+mode});return`<div class="w-100 font-${cfg.sizeMode||"md"} ${cls}">\n <select name="${this.name()}" jsfx-role="main" class="form-control"></select>\n </div>`}_onAfterRender(){this._initSelect2();this._renderData();let me=this;this._mainEl.on("change",function(e,data){if(data=="_jsfx")return;let nv=$(this).val();me._setValue(E(nv)?null:nv)});let evts=["selected","unselected"];["select2:select","select2:unselect"].forEach((type,i)=>{this._mainEl.on(type,e=>{me._fire(evts[i],[e.params.data])})});super._onAfterRender()}_optionHtml(data){let html="";data.forEach(op=>{if(op.children){let childrenHtml=this._optionHtml(op.children);html+=`<optgroup label="${op.text}">${childrenHtml}</optgroup>`}else{html+=`<option value="${op.id}" ${op.disabled?"disabled":""} ${op.selected?"selected":""}>${op.text}</option>`}});return html}_initSelect2(){let cfg=this._config,dataQuery=cfg.dataQuery,url=dataQuery?Y.isString(dataQuery)?dataQuery:dataQuery.url:null,jsonParams=dataQuery?Y.isString(dataQuery)?null:dataQuery.data:null,options={disabled:cfg.disabled,allowClear:cfg.allowClear,width:"100%",minimumInputLength:cfg.minimumInputLength<1?1:cfg.minimumInputLength,language:cfg.locale,placeholder:cfg.placeholder,multiple:cfg.multiple,tags:cfg.inputable,tokenSeparators:[" "]};let cls="jsfx-select "+" "+(cfg.colorMode||"")+" font-"+(cfg.sizeMode||"md")+(cfg.cls||"");this._eachMode("faceMode",mode=>{cls+=" border-"+mode});options.dropdownCssClass=cls;if(cfg.rtl)options.dir="rtl";if(!cfg.autoSearch){options.minimumResultsForSearch=Infinity;options.minimumInputLength=0}if(!cfg.autoEscape){options.escapeMarkup=(c=>{return c})}let me=this;if(cfg.optionRender)options.templateResult=function(data,el){return cfg.optionRender.apply(me,[data,el])};if(cfg.selectionRender)options.templateSelection=function(data,el){return cfg.selectionRender.apply(me,[data,el])};if(cfg.autoSearch&&url)options.ajax={url:function(pms){return url+(pms.term||"")},dataType:"json",delay:500,data:function(){return jsonParams?jsonParams:{}},processResults:(res,params)=>{let data=J.find(res,ResultSet.DEFAULT_FORMAT.dataProperty);this.data(data);return{results:data}},cache:true};this._mainEl.select2(options)}addOption(opt){return this.data([opt],false,"append")}addOptions(data){return this.data(data,false,"append")}removeOption(id){return this.data([id],false,"remove")}removeOptions(ids){return this.data(ids,false,"remove")}select(i,silent){let cfg=this._config;if(i<0||E(cfg.data)||i>=cfg.data.length)return;this.value(""+cfg.data[i].id,silent)}isCrud(){let cfg=this._config;return cfg.multiple&&cfg.crud}crudValue(){if(!this.isCrud())return null;let val=Arrays.toArray(this.value()),iniVal=Arrays.toArray(this.iniValue()),arr=[];iniVal.forEach(v=>{if(val.findIndex(it=>{return it==v})<0){arr[arr.length]={_crud:"D",id:v}}});val.forEach(v=>{if(iniVal.findIndex(it=>{return it==v})<0){arr[arr.length]={_crud:"C",id:v}}});return arr}data(data,silent,mode){let cfg=this._config;if(arguments.length==0)return cfg.data;let newData,newDataCopy,oldData=J.clone(cfg.data);if(mode=="append"){let tmp=J.clone(cfg.data)||[];newData=tmp.add(data);newDataCopy=J.clone(newData)}else if(mode=="remove"){let tmp=J.clone(cfg.data)||[];data.forEach(id=>{tmp.remove(item=>{return item.id==id})});newData=tmp;newDataCopy=J.clone(newData)}else{newData=data;newDataCopy=J.clone(newData)}if(!silent)this._fire("dataupdating",[newDataCopy,oldData]);cfg.data=newData;if(this._dataModel)this._dataModel.setData(newData,true);this._renderDataBy(mode?data:newData,mode);this._renderValue();if(!silent)this._fire("dataupdated",[newDataCopy,oldData]);return this}_iniValue(){let cfg=this._config;if(cfg.autoSelectFirst&&cfg.data&&cfg.data.length>0)cfg.iniValue=""+cfg.data[0].id;super._iniValue()}_renderData(){this._renderDataBy(this._config.data)}_renderDataBy(data,mode){if(data){if(!mode)this._mainEl.empty();if(mode!="remove"){this._mainEl.append(this._optionHtml(data))}else{data.forEach(id=>{this._mainEl.find(`option[value="${id}"]`).remove()})}}else{if(mode!="remove")this._mainEl.empty()}}_renderValue(){let v=this.value();if(!this._equalValues(v,this._mainEl.val()))this._mainEl.val(v).trigger("change","_jsfx")}_equalValues(newVal,oldVal){if(E(oldVal)&&E(newVal))return true;let cfg=this._config;return cfg.multiple?Arrays.equalToString(oldVal,newVal):oldVal==newVal}value(val,silent){if(arguments.length==0)return super.value();let cfg=this._config;if(cfg.multiple&&Y.isString(val)||!cfg.multiple&&Y.isArray(val))throw new TypeError(`Wrong value type for select<${this.id}>!`);return super.value(val,silent)}_showError(msg){super._showError(msg);this.widgetEl.find(".select2-selection").addClass("jsfx-input-error")}_hideError(){super._hideError();this.widgetEl.find(".select2-selection").removeClass("jsfx-input-error")}};Select=__decorate([widget("JS.fx.Select"),__metadata("design:paramtypes",[SelectConfig])],Select);fx.Select=Select})(fx=JS.fx||(JS.fx={}))})(JS||(JS={}));var Select=JS.fx.Select;var SelectFaceMode=JS.fx.SelectFaceMode;var SelectOption=JS.fx.SelectOption;var SelectConfig=JS.fx.SelectConfig;var JS;(function(JS){let fx;(function(fx){let SwitchFaceMode;(function(SwitchFaceMode){SwitchFaceMode["shadow"]="shadow"})(SwitchFaceMode=fx.SwitchFaceMode||(fx.SwitchFaceMode={}));class SwitchConfig extends fx.FormWidgetConfig{constructor(){super(...arguments);this.iniValue="off"}}fx.SwitchConfig=SwitchConfig;let Switch=class Switch extends fx.FormWidget{constructor(config){super(config)}_onAfterRender(){let me=this;this._mainEl.on("change",function(){let is=$(this).is(":checked");me._setValue(is?"on":"off");me._fire(is?"on":"off")});super._onAfterRender()}_bodyFragment(){let cls="",cfg=this._config;if(this._hasFaceMode(SwitchFaceMode.shadow))cls+=" border-shadow";return`<input name="${this.name()}" jsfx-role="main" type="checkbox" class="${cls}" ${cfg.readonly?"readonly":""}/>`}value(val,silent){if(arguments.length==0)return super.value()||"off";return super.value(val,silent)}_renderValue(){this._mainEl.prop("checked",this.value()=="on")}toggle(){let v=this.value();return this.value(v=="on"?"off":"on")}};Switch=__decorate([widget("JS.fx.Switch"),__metadata("design:paramtypes",[SwitchConfig])],Switch);fx.Switch=Switch})(fx=JS.fx||(JS.fx={}))})(JS||(JS={}));var Switch=JS.fx.Switch;var SwitchFaceMode=JS.fx.SwitchFaceMode;var SwitchConfig=JS.fx.SwitchConfig;var JS;(function(JS){let fx;(function(fx){let E=Check.isEmpty,A=Arrays;let UploaderFaceMode;(function(UploaderFaceMode){UploaderFaceMode["list"]="list";UploaderFaceMode["image"]="image";UploaderFaceMode["square"]="square";UploaderFaceMode["round"]="round";UploaderFaceMode["shadow"]="shadow"})(UploaderFaceMode=fx.UploaderFaceMode||(fx.UploaderFaceMode={}));class UploaderConfig extends fx.FormWidgetConfig{constructor(){super(...arguments);this.readonly=false;this.dnd=false;this.paste=false;this.thumb={width:1,height:1};this.duplicate=true;this.multiple=false;this.fieldName="file";this.faceMode=[UploaderFaceMode.square,UploaderFaceMode.list];this.iniValue=null;this.data=null}}fx.UploaderConfig=UploaderConfig;let Uploader=class Uploader extends fx.FormWidget{constructor(cfg){super(cfg)}_initUploader(cfg){if(this._uploader)return;let me=this;$("#"+this.id).find(".classic-pick").on("click",function(){$("#"+me.id).find(".webuploader-element-invisible").click()});let url=JS.config("libs")["webuploader.swf"];url=url.startsWith("~")?(JS.config("libRoot")||"")+url.slice(1):url;let cf={pick:{id:`#${this.id} .pick`,multiple:cfg.multiple},paste:cfg.paste==true?`#${this.id}`:cfg.paste=="body"?document.body:undefined,dnd:cfg.dnd?`#${this.id}`:undefined,swf:url,auto:true,accept:cfg.accept||null,fileNumLimit:cfg.maxNumbers||undefined,fileSizeLimit:cfg.maxTotalSize||undefined,fileSingleSizeLimit:cfg.maxSingleSize||undefined,disableGlobalDnd:false,duplicate:cfg.duplicate,fileVal:cfg.fieldName,formData:cfg.uploadData||{},thumb:{width:cfg.thumb&&cfg.thumb.width,height:cfg.thumb&&cfg.thumb.height,allowMagnify:false,crop:false,type:""},compress:cfg.compress&&cfg.compress.width&&cfg.compress.height?{width:cfg.compress.width,height:cfg.compress.height,quality:90,allowMagnify:false,crop:false,preserveHeaders:true,noCompressIfLarger:true,compressSize:0}:false};this._uploader=WebUploader.Uploader.create(cf);let eMap={adding:"beforeFileQueued",added:"filesQueued",removed:"fileDequeued",uploading:"uploadStart",uploadprogress:"uploadProgress",uploadsuccess:"uploadSuccess",uploaderror:"uploadError",uploaded:"uploadComplete",beginupload:"startUpload",endupload:"uploadFinished"};this._uploader.on(eMap["adding"],function(file){return me._fire("adding",[me._toMimeFile(file)])});this._uploader.on(eMap["added"],function(files){files.forEach(file=>{me._onFileQueued(file)});me._fire("added",[me._toMimeFiles(files)])});this._uploader.on(eMap["removed"],function(file){me._onFileDequeued(file);me._fire("removed",[me._toMimeFile(file)])});this._uploader.on(eMap["uploading"],function(file,percentage){me._fire("uploading",[me._toMimeFile(file),percentage])});this._uploader.on(eMap["uploaderror"],function(file,reason){me._onUploadFail(file);me._fire("uploaderror",[me._toMimeFile(file),reason])});this._uploader.on(eMap["uploadsuccess"],function(file,response){me._onUploadSuccess(file,response);me._fire("uploadsuccess",[me._toMimeFile(file),response])});this._uploader.on(eMap["uploaded"],function(file){me._fire("uploaded",[me._toMimeFile(file)])});this._uploader.on(eMap["beginupload"],function(){me._fire("beginupload")});this._uploader.on(eMap["endupload"],function(){me._fire("endupload")});let errors={F_EXCEED_SIZE:"exceedMaxSize",F_DUPLICATE:"wrongDuplicate",Q_TYPE_DENIED:"wrongType",Q_EXCEED_NUM_LIMIT:"exceedNumbers",Q_EXCEED_SIZE_LIMIT:"exceedMaxTotalSize"};this._uploader.on("error",type=>{fx.Toast.show({type:"error",message:me._i18n(errors[type]),place:"cb"})})}_showError(msg){super._showError(msg);this.widgetEl.find(".body").addClass("jsfx-input-error")}_hideError(){super._hideError();this.widgetEl.find(".body").removeClass("jsfx-input-error")}_onAfterRender(){this._initUploader(this._config);super._onAfterRender()}_createShadow(id,ctor){return $(`<div id="${id}"></div>`).css({position:"absolute",top:0,left:0,width:"100%",height:"100%",backgroundColor:"#808080",opacity:.1,zIndex:(Number(ctor.css("z-index"))||0)+1})}readonly(is){let cfg=this._config;if(arguments.length==0)return cfg.readonly;if(cfg.readonly==is)return this;cfg.readonly=is;$(`#${this.id} .body`)[is?"addClass":"removeClass"]("readonly");let p=$(`#${this.id} .pick`);is?p.hide():p.show();return this}disable(){if(!this.isEnabled())return this;this._config.disabled=true;let ctor=$(`#${this.id} .body`).addClass("disabled");this._createShadow(this.id+"_shadow",ctor).appendTo(ctor);return this}enable(){if(this.isEnabled())return this;this._config.disabled=false;$(`#${this.id} .body`).removeClass("disabled");$("#"+this.id+"_shadow").remove();return this}_pickText(key){let cfg=this._config,fileExts=cfg.accept&&cfg.accept.title||"*",maxTotalSize=cfg.maxTotalSize?Files.toSizeString(cfg.maxTotalSize):"*",maxNumbers=cfg.maxNumbers||"*",maxSingleSize=cfg.maxSingleSize?Files.toSizeString(cfg.maxSingleSize):"*";return Strings.merge(this._i18n(key)||"",{fileExts,maxTotalSize,maxNumbers,maxSingleSize})}_bodyFragment(){let cfg=this._config,title=this._pickText("pickTitle"),tip=this._pickText("pickTip").replace(/\n/g," "),fag=!this._hasFaceMode(UploaderFaceMode.image)?`<ul class="files-area list"></ul>`:`<div class="files-area image"></div>`,cls="";if(this._hasFaceMode(UploaderFaceMode.shadow))cls+=" border-shadow";if(this._hasFaceMode(UploaderFaceMode.round))cls+=" border-round";return`\n <div class="body font-${cfg.sizeMode||"md"}${cls}">\n <div class="pick" title="${tip}">\n <i class="la la-cloud-upload"></i>\n <span class="pick-title">${title}</span>\n </div>\n ${fag}\n </div>`}isCrud(){return true}crudValue(){let val=this.value()||[],iniVal=this.iniValue()||[],arr=[];iniVal.forEach(v=>{if(val.findIndex(it=>{return it.id==v.id})<0){arr[arr.length]=Jsons.union(v,{_crud:"D"})}});val.forEach(v=>{if(iniVal.findIndex(it=>{return it.id==v.id})<0){if(!v.id.startsWith("WU_FILE_")&&v.id!=v["_wuid"])arr[arr.length]=Jsons.union(v,{_crud:"C"})}});return arr}iniValue(v,render){if(arguments.length==0)return super.iniValue();return super.iniValue(v,render)}value(file){if(arguments.length==0)return super.value();if(E(file)){this._uploader.reset();$(`#${this.id} .files-area`).children().remove();this._setValue(null);return this}return this.add(file)}_equalValues(newVal,oldVal){return A.equal(oldVal,newVal,(file1,file2)=>{return file1.id==file2.id})}add(file){if(E(file))return this;this._addFiles(A.toArray(file));return this}remove(id){if(E(id))return this;let rms=A.toArray(id);rms.forEach(i=>{let el=this.widgetEl.find(`[file-id="${i}"]`);if(el.length==1)this._removeFile(el.attr("wu-id"))});return this}data(data){if(arguments.length==0)return this.value();return this.value(data)}_onUploadSuccess(wuFile,res){let cfg=this._config,fmt=cfg.dataFormat,result=Types.isFunction(fmt)?fmt.apply(this,res):ResultSet.parseJSON(res,fmt);if(result.success()){let file=result.data(),val=this.value()||[],index=val.findIndex(item=>{return wuFile.id==item.id});if(index>=0){let oFile=val[index];oFile.id=file.id;oFile.uri=file.uri}}else{this._onUploadFail(wuFile)}}_onUploadFail(file){this.widgetEl.find(`[file-id="${file.id}"]`).addClass("fail")}_onFileDequeued(file){this.widgetEl.find(`[wu-id="${file.id}"]`).remove();let newVal=Jsons.clone(this.value()).remove(mFile=>{return mFile["_wuid"]==file.id});this._valueModel.set(this.name(),newVal)}_fileIcon(path){let icon="alt";if(Files.isFileType(path,"pdf")){icon="pdf"}else if(Files.isFileType(path,"doc,docx")){icon="word"}else if(Files.isFileType(path,"xls,xlsx")){icon="excel"}else if(Files.isFileType(path,"ppt,pptx")){icon="powerpoint"}else if(Files.isFileType(path,FileTypes.AUDIOS)){icon="audio"}else if(Files.isFileType(path,FileTypes.VIDEOS)){icon="video"}else if(Files.isFileType(path,FileTypes.ZIPS)){icon="archive"}else if(Files.isFileType(path,FileTypes.CODES)){icon="code"}else if(Files.isFileType(path,FileTypes.IMAGES)){icon="image"}return'<span><i class="far fa-file-'+icon+'"></i></span>'}_onFileQueued(wuFile){let file=this._toMimeFile(wuFile);this._renderFile(file);if(this._hasFaceMode(UploaderFaceMode.image)){let isImage=Files.isFileType(file.name,FileTypes.IMAGES);if(!file.uri&&isImage){this._makeThumb(wuFile)}else if(!isImage)this.widgetEl.find(`[file-id=${file.id}] img`).replaceWith(this._fileIcon("."+file.ext))}if(file.uri)this._uploader.skipFile(wuFile.id);file["_wuid"]=wuFile.id;this.widgetEl.find("[file-id]:last-child").attr("wu-id",wuFile.id);this._setValue((this.value()||[]).concat(file))}_renderFile(file){let url=file.uri||"",fId=file.id||"",fileLink=`<a id="${this.id}-${fId}" src="${url}" href="javascript:void(0);">${file.name}</a>`,retryTip=this._i18n("retryTip")||"Retry",removeTip=this._i18n("removeTip")||"Remove",html=!this._hasFaceMode(UploaderFaceMode.image)?$(`<li file-id="${fId}">\n <div class="text-truncate file-name" title="${Strings.escapeHTML(file.name)}">\n ${this._fileIcon("."+file.ext)}\n ${fileLink}\n </div>\n <div class="file-actions">\n <span class="action remove text-center" title="${removeTip}"><i class="fa fa-times"></i></span>\n <span class="action retry text-center" title="${retryTip}"><i class="fa fa-upload"></i></span>\n </div>\n </li>`):$(`\n <div file-id="${fId}">\n <div class="file-image-area">\n <div class="file-image items-center items-middle"><img id="${this.id}-${fId}" src="${url}"/></div>\n <div class="file-actions">\n <span class="action remove text-center" title="${removeTip}"><i class="fa fa-times"></i></span>\n <span class="action retry text-center" title="${retryTip}"><i class="fa fa-upload"></i></span>\n </div>\n </div>\n <div class="text-truncate file-name" title="${Strings.escapeHTML(file.name)}">\n ${fileLink}\n </div>\n </div>\n `);this.widgetEl.find(`.files-area`).append(html);this._bindActions(fId)}_makeThumb(file){this._uploader.makeThumb(file,(error,src)=>{let el=this.widgetEl.find(`[file-id=${file.id}]`);if(error){el.find("img").replaceWith(this._fileIcon("."+file.ext));return}el.find(`#${this.id}-${file.id}`).attr("src",src)})}_bindActions(fileId){let fEl=this.widgetEl.find(`[file-id="${fileId}"]`);fEl.on("click",!this._hasFaceMode(UploaderFaceMode.image)?"a":"a,.file-image",e=>{let src=this.widgetEl.find(`#${this.id}-${fileId}`).attr("src");if(src){Files.isFileType(src,FileTypes.IMAGES)||src.indexOf("data:image/")==0?window.open().document.body.innerHTML=`<img src="${src}" >`:window.open(src)}else{fx.Toast.show({type:"error",message:this._i18n("viewDenied")})}return false});fEl.on("click",".action.remove",e=>{this._removeFile(fEl.attr("wu-id"));fEl.remove();return false});fEl.on("click",".action.retry",e=>{this._retryFile(fEl.attr("wu-id"));return false})}_toMimeFiles(wfs){if(E(wfs))return[];let fs=[];wfs.forEach(file=>{fs.push(this._toMimeFile(file))});return fs}_toMimeFile(wf){if(!wf)return null;return{id:wf.source.id||wf.id,mime:wf.type,name:wf.name,ext:wf.ext,size:wf.size,uri:wf.source.uri}}_toWUFile(cf){if(!cf)return null;if(!cf.uri)throw new URIError(`The file<${cf.name}> has not URI.`);let file={id:cf.id,type:cf.mime,name:cf.name,ext:cf.ext||Files.getFileType(cf.name),size:cf.size||1,getRuid:()=>{return""},getSource:()=>{return null}};file["uri"]=cf.uri;return file}_removeFile(wuFileId){let f=this._uploader.getFile(wuFileId);if(f)this._uploader.removeFile(f,true);return this}_retryFile(wuFileId){let f=this._uploader.getFile(wuFileId);if(f)this._uploader.retry(f);return this}_addFiles(files){if(E(files))return this;let wuFiles=[],value=this.value()||[];files.forEach(f=>{if(value.findIndex(v=>{return v.id==f.id})<0)wuFiles.push(new WebUploader.File(this._toWUFile(f)))});if(wuFiles.length>0)this._uploader.addFiles(wuFiles);return this}inProgress(){return this._uploader.isInProgress()}};Uploader.I18N={pickTitle:"Select your local files please",pickTip:"<Accepts>\nFileExts={fileExts}\nMaxTotalSize={maxTotalSize}\nMaxNumbers={maxNumbers}\nMaxSingleSize={maxSingleSize}",retryTip:"Retry",removeTip:"Remove",viewDenied:"The file can't be viewed in local mode",exceedMaxSize:"Exceed the max size of single file",wrongDuplicate:"Can't upload duplicate file",wrongType:"Wrong file type",exceedNumbers:"Exceed the max numbers of file",exceedMaxTotalSize:"Exceed the max size of total files"};Uploader=__decorate([widget("JS.fx.Uploader"),__metadata("design:paramtypes",[UploaderConfig])],Uploader);fx.Uploader=Uploader})(fx=JS.fx||(JS.fx={}))})(JS||(JS={}));var Uploader=JS.fx.Uploader;var UploaderConfig=JS.fx.UploaderConfig;var UploaderFaceMode=JS.fx.UploaderFaceMode;var JS;(function(JS){let fx;(function(fx){let ProgressFaceMode;(function(ProgressFaceMode){ProgressFaceMode["square"]="square";ProgressFaceMode["round"]="round";ProgressFaceMode["striped"]="striped";ProgressFaceMode["animated"]="animated"})(ProgressFaceMode=fx.ProgressFaceMode||(fx.ProgressFaceMode={}));class ProgressConfig extends fx.FormWidgetConfig{constructor(){super(...arguments);this.iniValue=0}}fx.ProgressConfig=ProgressConfig;let Progress=class Progress extends fx.FormWidget{constructor(config){super(config)}value(val,silent){if(arguments.length==0)return super.value();val=val||0;if(val>1||val<0)throw new RangeError("Progress value must in [0,1]!");let newVal=val?val.round(2):0;this._setValue(newVal,silent);this._mainEl.css("width",newVal*100+"%");this._mainEl.text(newVal?newVal*100+"%":"");return this}height(val){if(arguments.length==0)return this._mainEl.parent().css("height");this._mainEl.parent().css("height",val);this._config.height=val;return this}_bodyFragment(){let cfg=this._config,cls=`progress ${cfg.sizeMode||""}`,barCls="progress-bar",val=cfg.iniValue||0;if(this._hasFaceMode(ProgressFaceMode.square))cls+=" border-square";if(this._hasFaceMode(ProgressFaceMode.striped))barCls+=" progress-bar-striped";if(this._hasFaceMode(ProgressFaceMode.animated))barCls+=" progress-bar-striped progress-bar-animated";if(cfg.colorMode)barCls+=` bg-${cfg.colorMode}`;return`\n <div class="${cls}" ${cfg.height?'style="height:'+cfg.height+'px"':""}>\n <div class="${barCls} ${cfg.disabled?"disabled":""}" style="width:${val*100}%" jsfx-role="main" role="progressbar">${val?val*100+"%":""}</div>\n </div>\n `}disable(){this._mainEl.addClass("disabled");this._config.disabled=true;return this}enable(){this._mainEl.removeClass("disabled");this._config.disabled=false;return this}};Progress=__decorate([widget("JS.fx.Progress"),__metadata("design:paramtypes",[ProgressConfig])],Progress);fx.Progress=Progress})(fx=JS.fx||(JS.fx={}))})(JS||(JS={}));var Progress=JS.fx.Progress;var ProgressFaceMode=JS.fx.ProgressFaceMode;var ProgressConfig=JS.fx.ProgressConfig;var JS;(function(JS){let fx;(function(fx){let RangeSliderFaceMode;(function(RangeSliderFaceMode){RangeSliderFaceMode["flat"]="flat";RangeSliderFaceMode["big"]="big";RangeSliderFaceMode["modern"]="modern";RangeSliderFaceMode["sharp"]="sharp";RangeSliderFaceMode["round"]="round";RangeSliderFaceMode["square"]="square"})(RangeSliderFaceMode=fx.RangeSliderFaceMode||(fx.RangeSliderFaceMode={}));class RangeSliderConfig extends fx.FormWidgetConfig{constructor(){super(...arguments);this.faceMode=RangeSliderFaceMode.round}}fx.RangeSliderConfig=RangeSliderConfig;let RangeSlider=class RangeSlider extends fx.FormWidget{constructor(cfg){super(cfg)}_getFromTo(){let arr=Arrays.toArray(this.value()),from=arr.length>0?arr[0]:null,to=arr.length>1?arr[1]:null;return[from,to]}_transfer(){let cfg=this._config,fromTo=this._getFromTo();return{type:cfg.type,min:cfg.data[0],max:cfg.data[1],from:fromTo[0],to:fromTo[1],step:cfg.step,keyboard:false,grid:cfg.scaled,grid_margin:true,grid_num:cfg.scales,grid_snap:false,drag_interval:true,min_interval:cfg.minInterval,max_interval:cfg.maxInterval,from_fixed:cfg.fromFixed,from_min:cfg.fromMin,from_max:cfg.fromMax,from_shadow:cfg.fromShadow,to_fixed:cfg.toFixed,to_min:cfg.toMin,to_max:cfg.toMax,to_shadow:cfg.toShadow,skin:cfg.faceMode||"round",hide_min_max:cfg.hideMinMax,hide_from_to:cfg.hideFromTo,force_edges:true,extra_classes:cfg.sliderCls,block:cfg.readonly,prettify_enabled:cfg.format?true:false,prettify_separator:Types.isString(cfg.format)?cfg.format:" ",prettify:Types.isFunction(cfg.format)?cfg.format:null,prefix:cfg.dataPrefix,postfix:cfg.dataPostfix,max_postfix:cfg.maxValuePostfix,decorate_both:cfg.closeValuesDecorate,values_separator:cfg.closeValuesSeparator,input_values_separator:cfg.valuesSeparator,disable:cfg.disabled,scope:this,onFinish:data=>{let cfg=this._config,v=cfg.type=="double"?[data.from,data.to]:data.from;this._setValue(v)}}}_destroy(){this._slider.destroy();super._destroy()}_bodyFragment(){let cfg=this._config;if(!cfg.data)cfg.data=[0,100];return`<input name="${this.name()}" type="text" jsfx-role="main" data-min="${cfg.data[0]}" data-max="${cfg.data[1]}"/>`}_onBeforeRender(){if(this._slider)this._slider.destroy();super._onBeforeRender()}_onAfterRender(){if(this._config.colorMode)this.widgetEl.find("[jsfx-role=body]").addClass(this._config.colorMode);this._mainEl.ionRangeSlider(this._transfer());this._slider=this._mainEl.data("ionRangeSlider");super._onAfterRender()}_iniValue(){let cfg=this._config,type=cfg.type,min=this.minValue(),max=this.maxValue();if(cfg.iniValue==null)cfg.iniValue=type=="double"?[min,max]:min;super._iniValue()}data(data,silent){if(arguments.length==0)return super.data();if(data==null)data=[0,100];return super.data(data,silent)}_renderData(){let data=this._config.data,min=this._mainEl.data("min"),max=this._mainEl.data("max");if(data&&min+"-"+max!=data[0]+"-"+data[1]){this._slider.update({min:data[0],max:data[1]});this._mainEl.data({min:data[0],max:data[1]})}}value(val,silent){if(arguments.length==0)return super.value();let cfg=this._config;if(val!=null){let min=this.minValue(),max=this.maxValue();if(cfg.type=="double"){if(val[0]<min)val[0]=min;if(val[1]>max)val[1]=max}else{if(val<min){val=min}else if(val>max){val=max}}}return super.value(val,silent)}_renderValue(){let cfg=this._config,fromTo=this._getFromTo(),sValue=cfg.type=="double"?fromTo[0]||""+cfg.valuesSeparator+fromTo[1]||"":String(fromTo[0]||"");if(sValue!=this._mainEl.prop("value"))this._slider.update({from:fromTo[0],to:fromTo[1]})}maxValue(){return this._config.data[1]}minValue(){return this._config.data[0]}};RangeSlider=__decorate([widget("JS.fx.RangeSlider"),__metadata("design:paramtypes",[RangeSliderConfig])],RangeSlider);fx.RangeSlider=RangeSlider})(fx=JS.fx||(JS.fx={}))})(JS||(JS={}));var RangeSliderFaceMode=JS.fx.RangeSliderFaceMode;var RangeSliderConfig=JS.fx.RangeSliderConfig;var RangeSlider=JS.fx.RangeSlider;var JS;(function(JS){let fx;(function(fx){let A=Arrays;class ChoiceConfig extends fx.FormWidgetConfig{}fx.ChoiceConfig=ChoiceConfig;class Choice extends fx.FormWidget{constructor(cfg){super(cfg)}_bodyFragment(){let isList=this._hasFaceMode("list")?true:false;return`<div class="jsfx-choice-${isList?"list":"inline"}"> </div>`}_choicesHtml(type){let cfg=this._config,data=cfg.data;if(!data)return"";let val=A.toArray(this.value()),html="",textColor=cfg.textColorMode?"text-"+cfg.textColorMode:"",mode1=this._hasFaceMode("round")?"round":"square",mode2=this._hasFaceMode("ring")?"ring":"dot",disable=cfg.disabled?"disabled":"";data.forEach((d,i)=>{html+=`\n <label class="font-${cfg.sizeMode||"md"} ${mode1} ${mode2} ${cfg.colorMode||""} ${textColor} ${disable}">\n <input id="${this.id}_${i}" name="${this.name()}" ${disable} ${val.findIndex(it=>{return it==d.id})>=0?"checked":""} type="${type}" value="${d.id}"/>\n <span class="text">${d.text||""}</span>\n <span class="choice"></span>\n </label>`});return html}isSelected(){return!Check.isEmpty(this.value())}_renderData(type){this.widgetEl.find("[jsfx-role=body]>div").off().empty().html(this._choicesHtml(type));if(!this.readonly()){let el=this.widgetEl.find("input");el.on("change",()=>{this._setValue(this._getDomValue())}).on("click",()=>{this._setValue(this._getDomValue(),true);this._fire("click")})}}_renderValue(){let cVal=this.value(),v=A.toArray(cVal),val=A.toArray(this._getDomValue());if(!A.same(val,v)){this._setDomValue(cVal)}}_onAfterRender(){this._renderData();super._onAfterRender()}disable(){this._config.disabled=true;this.widgetEl.find("input").prop("disabled",true);this.widgetEl.find("label").addClass("disabled");return this}enable(){this._config.disabled=false;this.widgetEl.find("input").prop("disabled",false);this.widgetEl.find("label").removeClass("disabled");return this}readonly(is){if(arguments.length==0)return this._config.readonly;this.widgetEl.find("input").prop("readonly",is);this._config.readonly=is;return this}}fx.Choice=Choice})(fx=JS.fx||(JS.fx={}))})(JS||(JS={}));var Choice=JS.fx.Choice;var JS;(function(JS){let fx;(function(fx){class CheckboxConfig extends fx.ChoiceConfig{constructor(){super(...arguments);this.faceMode=CheckboxFaceMode.inline}}fx.CheckboxConfig=CheckboxConfig;let CheckboxFaceMode;(function(CheckboxFaceMode){CheckboxFaceMode["square"]="square";CheckboxFaceMode["round"]="round";CheckboxFaceMode["inline"]="inline";CheckboxFaceMode["list"]="list"})(CheckboxFaceMode=fx.CheckboxFaceMode||(fx.CheckboxFaceMode={}));let Checkbox=class Checkbox extends fx.Choice{_getDomValue(){let v=[],els=this.widgetEl.find("input:checked");els.each((i,el)=>{v.push($(el).val())});return v}_setDomValue(v){this.widgetEl.find("input").each((i,el)=>{let n=$(el);n.prop("checked",!Check.isEmpty(v)&&v.findIndex(it=>{return it==n.val()})>-1?true:false)})}constructor(cfg){super(cfg)}_equalValues(newVal,oldVal){return Arrays.same(newVal,oldVal)}_renderData(){super._renderData("checkbox")}value(val,silent){if(arguments.length==0)return super.value();return super.value(val||[],silent)}select(val){if(Check.isEmpty(val)){let v=[],els=this.widgetEl.find("input:checkbox");els.each((i,el)=>{v.push($(el).val())});this._setDomValue(v)}else{this.unselect();let oldVal=this.value()||[],addVal=Arrays.toArray(val);addVal.forEach(v=>{if(oldVal.findIndex(it=>{return it==v})==-1)oldVal.push(v)});this.value(oldVal)}return this}unselect(val){if(!val){this.value(null)}else{let oldVal=this.value()||[],delVal=Arrays.toArray(val);delVal.forEach(v=>{oldVal.remove(it=>{return it==v})});this.value(oldVal)}return this}};Checkbox=__decorate([widget("JS.fx.Checkbox"),__metadata("design:paramtypes",[CheckboxConfig])],Checkbox);fx.Checkbox=Checkbox})(fx=JS.fx||(JS.fx={}))})(JS||(JS={}));var CheckboxConfig=JS.fx.CheckboxConfig;var CheckboxFaceMode=JS.fx.CheckboxFaceMode;var Checkbox=JS.fx.Checkbox;var JS;(function(JS){let fx;(function(fx){class RadioConfig extends fx.ChoiceConfig{constructor(){super(...arguments);this.faceMode=RadioFaceMode.inline}}fx.RadioConfig=RadioConfig;let RadioFaceMode;(function(RadioFaceMode){RadioFaceMode["dot"]="dot";RadioFaceMode["ring"]="ring";RadioFaceMode["inline"]="inline";RadioFaceMode["list"]="list"})(RadioFaceMode=fx.RadioFaceMode||(fx.RadioFaceMode={}));let Radio=class Radio extends fx.Choice{_getDomValue(){return this.widgetEl.find("input:checked").val()}_setDomValue(v){v?this.widgetEl.find(`input[value=${v}]`).prop("checked",true):this.widgetEl.find("input").prop("checked",false)}constructor(cfg){super(cfg)}value(val,silent){if(arguments.length==0)return super.value();return super.value(val,silent)}_renderData(){super._renderData("radio")}select(val){return this.value(val)}unselect(){return this.value(null)}};Radio=__decorate([widget("JS.fx.Radio"),__metadata("design:paramtypes",[RadioConfig])],Radio);fx.Radio=Radio})(fx=JS.fx||(JS.fx={}))})(JS||(JS={}));var RadioConfig=JS.fx.RadioConfig;var RadioFaceMode=JS.fx.RadioFaceMode;var Radio=JS.fx.Radio;var JS;(function(JS){let fx;(function(fx){class InputConfig extends fx.FormWidgetConfig{constructor(){super(...arguments);this.inputCls="";this.inputStyle="";this.maxlength=Infinity;this.placeholder="";this.autoclear=true;this.autofocus=false;this.outline=false}}fx.InputConfig=InputConfig;class Input extends fx.FormWidget{constructor(cfg){super(cfg)}maxlength(len){if(arguments.length==0)return this._config.maxlength;this._mainEl.prop("maxlength",len);this._config.maxlength=len;return this}placeholder(holder){if(arguments.length==0)return this._config.placeholder;holder=holder||"";this._config.placeholder=holder;this._mainEl.attr("placeholder",holder);return this}}fx.Input=Input})(fx=JS.fx||(JS.fx={}))})(JS||(JS={}));var InputConfig=JS.fx.InputConfig;var Input=JS.fx.Input;var JS;(function(JS){let fx;(function(fx){let LineInputFaceMode;(function(LineInputFaceMode){LineInputFaceMode["square"]="square";LineInputFaceMode["round"]="round";LineInputFaceMode["pill"]="pill";LineInputFaceMode["shadow"]="shadow"})(LineInputFaceMode=fx.LineInputFaceMode||(fx.LineInputFaceMode={}));class LineInputConfig extends fx.InputConfig{constructor(){super(...arguments);this.inputCls="";this.inputStyle="";this.textAlign="left";this.faceMode=LineInputFaceMode.square}}fx.LineInputConfig=LineInputConfig;class LineInput extends fx.Input{constructor(cfg){super(cfg)}_inputAttrs(type="text"){let cfg=this._config,cls="",shape=LineInputFaceMode.square;this._eachMode("faceMode",mode=>{cls+=" border-"+mode;if(mode!=LineInputFaceMode.shadow)shape=mode});if(cfg.leftAddon||cfg.rightAddon)cls+=` border-${cfg.leftAddon?"square":shape}-left border-${cfg.rightAddon?"square":shape}-right`;let color=cfg.colorMode;if(color)cls+=` ${cfg.outline?"border":"focus"}-${color}`;let style=`text-align:${cfg.textAlign};${cfg.inputStyle}`;return{"jsfx-role":"main",type,placeholder:Strings.escapeHTML(cfg.placeholder),autofocus:cfg.autofocus?"autofocus":undefined,readonly:cfg.readonly?"readonly":undefined,disabled:cfg.disabled?"disabled":undefined,maxlength:Number.isFinite(cfg.maxlength)&&cfg.maxlength>0?cfg.maxlength+"":"",style,class:`form-control ${cls} ${cfg.inputCls}`,"data-toggle":"tooltip","data-trigger":"hover focus"}}_inputHtml(type="text"){return Strings.nodeHTML("input",this._inputAttrs(type))}_iconHtml(icon,id,lr){if(!icon)return"";let me=this,cfg=this._config;if(icon.onClick)$(document).on("click","#"+id,function(e){if(me.isE