@hpcc-js/form 3.4.7 → 3.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +678 -2
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +3 -2
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,3 +1,679 @@
|
|
|
1
|
-
var t=Object.defineProperty,e=(e,n)=>t(e,"name",{value:n,configurable:!0});import{IInput as n}from"@hpcc-js/api";import{HTMLWidget as i,rgb as s,WidgetArray as o,d3Event as l,select as a,SVGWidget as r,scaleLinear as p,timeParse as h,drag as u,timeFormat as c,format as d}from"@hpcc-js/common";const m="@hpcc-js/form",f="3.4.7",y="3.23.0",g=class _Button extends i{_inputElement=[];constructor(){super(),n.call(this),this._tag="div"}enter(t,e){super.enter(t,e);const n=this;this._inputElement[0]=e.append("button").attr("name",this.name()).on("click",function(t){t.click(t)}).on("blur",function(t){t.blur(t)}).on("change",function(t){n.value([n._inputElement[0].property("value")]),t.change(t,!0)})}update(t,e){super.update(t,e),this._inputElement[0].text(this.value())}};e(g,"Button");let b=g;b.prototype._class+=" form_Button",b.prototype.implements(n.prototype);const _=class _CheckBox extends i{_inputElement=[];constructor(){super(),n.call(this),this._tag="div"}enter(t,e){super.enter(t,e);const n=this,i=e.append("ul");this.selectOptions().length||this.selectOptions().push(""),this.selectOptions().forEach(function(t,e){n._inputElement[e]=i.append("li").append("input").attr("type","checkbox"),n._inputElement[e].node().insertAdjacentHTML("afterend","<text>"+t+"</text>")}),this._inputElement.forEach(function(t,e){t.attr("name",n.name()),t.on("click",function(t){t.click(t)}),t.on("blur",function(t){t.blur(t)}),t.on("change",function(t){const e=[];n._inputElement.forEach(function(t){t.property("checked")&&e.push(t.property("value"))}),n.value(e),t.change(t,!0)})})}update(t,e){super.update(t,e);const n=this;this._inputElement.forEach(function(t,e){t.property("value",n.selectOptions()[e]),-1!==n.value().indexOf(n.selectOptions()[e])&&"false"!==n.value()?t.property("checked",!0):t.property("checked",!1)})}insertSelectOptions(t){let e="";t.length>0?t.forEach(function(t){const n=t instanceof Array?t[0]:t,i=t instanceof Array?t[1]?t[1]:t[0]:t;e+="<option value='"+n+"'>"+i+"</option>"}):e+="<option>selectOptions not set</option>",this._inputElement[0].html(e)}};e(_,"CheckBox");let v=_;v.prototype._class+=" form_CheckBox",v.prototype.implements(n.prototype),v.prototype.publish("selectOptions",[],"array","Array of options used to fill a dropdown list");const x=class _ColorInput extends i{_inputElement=[];constructor(){super(),n.call(this),this._tag="div"}enter(t,e){super.enter(t,e);const n=this;this._inputElement[0]=e.append("input").attr("type","text"),this._inputElement[0].classed("color-text",!0),this._inputElement[1]=e.append("input").attr("type","color"),this._inputElement.forEach(function(t,e){t.on("click",function(t){t.click(t)}),t.on("blur",function(t){t.blur(t)}),t.on("change",function(t){0===e?(n._inputElement[1].property("value",s(n._inputElement[0].property("value")).toString()),n.value(n._inputElement[0].property("value"))):(n._inputElement[0].property("value",n._inputElement[1].property("value")),n.value(s(n._inputElement[1].property("value")).toString())),t.change(t,!0)})})}update(t,e){super.update(t,e);const n=this;this._inputElement.forEach(function(t){t.attr("name",n.name())}),this._inputElement[0].attr("type","text"),this._inputElement[1].attr("type","color"),this._inputElement[0].property("value",this.value()),this._inputElement[1].property("value",s(this.value()).toString());const i=this._inputElement[0].node().getBoundingClientRect();this._inputElement[1].style("height",i.height-2+"px")}};e(x,"ColorInput");let E=x;E.prototype._class+=" form_ColorInput",E.prototype.implements(n.prototype);const k=class _Form extends i{tbody;tfoot;btntd;_controls;_maxCols;constructor(){super(),this._tag="form"}data(t){if(!arguments.length){const t=[];return this.inputsForEach(function(e){t.push(e.value())}),t}return this.inputsForEach(function(e,n){t&&t.length>n&&e.value(t[n]).render()}),this}inputsForEach(t,e){let n=0;this.inputs().forEach(function(i){(i instanceof o?i.content():[i]).forEach(function(i){e?t.call(e,i,n++):t(i,n++)})})}inputsMap(){const t={};return this.inputs().forEach(function(e){t[e.name()]=e}),t}calcMaxColumns(){let t=0;return this.inputs().forEach(function(e){const n=e instanceof o?e.content():[e];n.length>t&&(t=n.length)}),t}values(t){if(!arguments.length){const t={};return this.inputsForEach(function(e){const n=e.type?e.type():"text";if(e.value()||!this.omitBlank())switch(n){case"checkbox":t[e.name()]=e.value_exists()?!!e.value():void 0;break;case"number":const n=e.value();t[e.name()]=""===n?void 0:+n;break;default:t[e.name()]=e.value_exists()?e.value():void 0}},this),t}return this.inputsForEach(function(e){t[e.name()]?e.value(t[e.name()]):this.omitBlank()&&e.value("")},this),this}submit(){let t=!0;this.validate()&&(t=this.checkValidation()),(this.allowEmptyRequest()||this.inputs().some(function(t){return-1!==t._class.indexOf("WidgetArray")?t.content().some(function(t){return t.hasValue()}):t.hasValue()}))&&this.click(t?this.values():null,null,t)}clear(){this.inputsForEach(function(t){switch(t.classID()){case"form_Slider":t.allowRange()?t.value([t.low(),t.low()]).render():t.value(t.low()).render();break;case"form_CheckBox":t.value(!1).render();break;case"form_Button":break;default:t.value(void 0).render()}})}checkValidation(){let t=!0;const e=[];return this.inputsForEach(function(t){t.isValid()||e.push("'"+t.label()+"' value is invalid.")}),e.length>0&&(alert(e.join("\n")),t=!1),t}enter(t,e){super.enter(t,e),e.on("submit",function(){l().preventDefault()}),this._placeholderElement.style("overflow","auto");const n=e.append("table");this.tbody=n.append("tbody"),this.tfoot=n.append("tfoot"),this.btntd=this.tfoot.append("tr").append("td").attr("colspan",2);const i=this;this._controls=[(new b).classed({default:!0}).value("Submit").on("click",function(){i.submit()},!0),(new b).value("Clear").on("click",function(){i.clear()},!0)];const s=i.btntd.append("div").style("float","right");this._controls.forEach(function(t){const e=s.append("span").style("float","left");t.target(e.node()).render()})}update(t,e){super.update(t,e),this._maxCols=this.calcMaxColumns();const n=this,i=this.tbody.selectAll("tr").data(this.inputs());i.enter().append("tr").each(function(t,e){const i=a(this),s=t instanceof o?t.content():[t];s.forEach(function(t,e){i.append("td").attr("class","prompt");const o=i.append("td").attr("class","input");if(e===s.length-1&&s.length<n._maxCols&&o.attr("colspan",2*(n._maxCols-s.length+1)),t.target(o.node()).render(),t instanceof r){const e=t.element().node().getBBox();o.style("height",e.height+"px"),t.resize().render()}t._inputElement instanceof Array&&t._inputElement.forEach(function(t){t.on("keyup.form",function(t){setTimeout(function(){n._controls[0].disable(!n.allowEmptyRequest()&&!n.inputs().some(function(t){return-1!==t._class.indexOf("WidgetArray")?t.content().some(function(t){return t.hasValue()}):t.hasValue()}))},100)})})})}).merge(i).each(function(t,e){const n=a(this);(t instanceof o?t.content():[t]).forEach(function(t,e){n.select("td.prompt").text(t.label()+":")})}),i.each(function(t,e){0===e&&t.setFocus&&t.setFocus()}),i.exit().each(function(t,e){(t instanceof o?t.content():[t]).forEach(function(t,e){t.target(null)})}).remove(),this.tfoot.style("display",this.showSubmit()?"table-footer-group":"none"),this.btntd.attr("colspan",2*this._maxCols),this.allowEmptyRequest()||setTimeout(function(){n._controls[0].disable(!n.allowEmptyRequest()&&!n.inputs().some(function(t){return-1!==t._class.indexOf("WidgetArray")?t.content().some(function(t){return t.hasValue()}):t.hasValue()}))},100)}exit(t,e){this.inputsForEach(t=>t.target(null)),super.exit(t,e)}click(t,e,n){}};e(k,"Form");let w=k;w.prototype._class+=" form_Form",w.prototype.publish("validate",!0,"boolean","Enable/Disable input validation"),w.prototype.publish("inputs",[],"widgetArray","Array of input widgets",null,{render:!1}),w.prototype.publish("showSubmit",!0,"boolean","Show Submit/Cancel Controls"),w.prototype.publish("omitBlank",!1,"boolean","Drop Blank Fields From Submit"),w.prototype.publish("allowEmptyRequest",!1,"boolean","Allow Blank Form to be Submitted");const R=class _Input extends i{_inputElement=[];_labelElement=[];constructor(){super(),n.call(this),this._tag="div"}checked(t){return arguments.length?(this._inputElement[0]&&this._inputElement[0].property("checked",t),this):!!this._inputElement[0]&&this._inputElement[0].property("checked")}enter(t,e){super.enter(t,e),this._labelElement[0]=e.append("label").attr("for",this.id()+"_input").style("visibility",this.inlineLabel_exists()?"visible":"hidden");const n=this;switch(this.type()){case"button":this._inputElement[0]=e.append("button").attr("id",this.id()+"_input");break;case"textarea":this._inputElement[0]=e.append("textarea").attr("id",this.id()+"_input");break;default:this._inputElement[0]=e.append("input").attr("id",this.id()+"_input").attr("type",this.type())}this._inputElement.forEach(function(t,e){t.attr("name",n.name()),t.on("click",function(t){t.click(t)}),t.on("blur",function(t){t.blur(t)}),t.on("change",function(e){n.value([t.property("value")]),e.change(e,!0)}),t.on("keyup",function(e){n.value([t.property("value")]),e.change(e,!1)})})}update(t,e){switch(super.update(t,e),this._labelElement[0].style("visibility",this.inlineLabel_exists()?"visible":"hidden").text(this.inlineLabel()),this.type()){case"button":this._inputElement[0].text(this.value());break;case"textarea":this._inputElement[0].property("value",this.value());break;default:this._inputElement[0].attr("type",this.type()),this._inputElement[0].property("value",this.value())}}blur(t){}keyup(t){}focus(t){}click(t){}dblclick(t){}change(t,e){}};e(R,"Input");let S=R;S.prototype._class+=" form_Input",S.prototype.implements(n.prototype),S.prototype.publish("type","text","set","Input type",["string","number","boolean","date","time","hidden","nested","button","checkbox","text","textarea","search","email","datetime"]),S.prototype.publish("inlineLabel",null,"string","Input Label",null,{optional:!0});const P=class _FieldForm extends w{constructor(){super(),this._tag="form"}fields(t){const e=super.fields.apply(this,arguments);if(arguments.length){const e=this.inputsMap();this.inputs(t.map(t=>e[t.id()]||(new S).name(t.id()).label(t.label()).type(t.type())))}return e}data(t){if(!arguments.length)return super.data();if(super.data(t[0]),t[0]){const e=this.inputs(),n=t[0][this.columns().length];let i=0;for(const t in n)e[i].name(t),++i}return this}};e(P,"FieldForm");let O=P;O.prototype._class+=" form_FieldForm";const C=class _InputRange extends i{_inputElement=[];_labelElement=[];_rangeData=[];constructor(){super(),n.call(this),this._tag="div"}enter(t,e){super.enter(t,e),this._labelElement[0]=e.append("label").attr("for",this.id()+"_input").style("visibility",this.inlineLabel_exists()?"visible":"hidden"),this._inputElement.push(e.append("input").attr("id",this.id()+"_input_min").attr("type",this.type())),this._inputElement.push(e.append("input").attr("id",this.id()+"_input_max").attr("type",this.type()));const n=this;this._inputElement.forEach(function(t,e){t.attr("name",n.name()),t.on("click",function(t){t.click(t)}),t.on("blur",function(t){t.blur(t)}),t.on("change",function(i){n._rangeData[e]=t.property("value"),n.value(n._rangeData),i.change(i,!0)})})}update(t,e){super.update(t,e),this._labelElement[0].style("visibility",this.inlineLabel_exists()?"visible":"hidden").text(this.inlineLabel()),this._rangeData=this.value(),this._inputElement.forEach(function(t,e){t.attr("type",this.type()).property("value",this._rangeData.length>e?this._rangeData[e]:"")},this)}};e(C,"InputRange");let F=C;F.prototype._class+=" form_InputRange",F.prototype.implements(n.prototype),F.prototype.publish("type","text","set","InputRange type",["number","date","text","time","datetime","hidden"]),F.prototype.publish("inlineLabel",null,"string","InputRange Label",null,{optional:!0}),F.prototype.publish("value",["",""],"array","Input Current Value",null,{override:!0});const L=class _OnOff extends i{_inputElement=[];_input;constructor(){super(),n.call(this),this._tag="div"}enter(t,e){super.enter(t,e),e.classed("onoffswitch",!0);const n=this;this._input=e.append("input").attr("class","onoffswitch-checkbox").attr("type","checkbox").attr("id",this.id()+"_onOff").on("click",function(t){t.click(t)}).on("blur",function(t){t.blur(t)}).on("change",function(t){const e=[];n._inputElement.forEach(function(t,n){t.property("checked")&&e.push(t.property("value"))}),n.value(e),t.change(t,!0)});const i=e.append("label").attr("class","onoffswitch-label").attr("for",this.id()+"_onOff"),s=i.append("div").attr("class","onoffswitch-inner");s.append("div").attr("class","onoffswitch-offText").style("padding-right",this.containerRadius()/2+"px").text(this.offText()),s.append("div").attr("class","onoffswitch-onText").style("padding-left",this.containerRadius()/2+"px").style("width",`calc(100% - ${this.containerRadius()/2}px)`).text(this.onText()),i.append("div").attr("class","onoffswitch-switch")}update(t,e){super.update(t,e),this._input.attr("name",this.name()),e.style("margin-left",this.marginLeft()+"px").style("margin-bottom",this.marginBottom()+"px").style("width",this.minWidth()+"px");const n=this.minHeight()-4*this.gutter();e.select(".onoffswitch-switch").style("height",n+"px").style("width",n+"px").style("top",2*this.gutter()+1+"px").style("border-radius",this.switchRadius()+"px"),e.select(".onoffswitch-inner").style("min-height",this.minHeight()+"px"),e.select(".onoffswitch-label").style("border-radius",this.containerRadius()+"px"),e.select(".onoffswitch-offText").style("color",this.offFontColor()).style("background-color",this.offColor()),e.select(".onoffswitch-onText").style("color",this.onFontColor()).style("background-color",this.onColor())}};e(L,"OnOff");let A=L;A.prototype._class+=" form_OnOff",A.prototype.implements(n.prototype),A.prototype.publish("marginLeft",0,"number","Margin left of OnOff"),A.prototype.publish("marginBottom",0,"number","Margin bottom of OnOff"),A.prototype.publish("minWidth",100,"number","Minimum width of OnOff (pixels)"),A.prototype.publish("minHeight",20,"number","Minimum height of OnOff (pixels)"),A.prototype.publish("gutter",1,"number","Space between switch and border of OnOff (pixels)"),A.prototype.publish("onText","Save","string","Text to display when 'ON'"),A.prototype.publish("offText","Properties","string","Text to display when 'OFF'"),A.prototype.publish("switchRadius",10,"number","Border radius of switch (pixels)"),A.prototype.publish("containerRadius",10,"number","Border radius of OnOff (pixels)"),A.prototype.publish("onColor","#2ecc71","html-color","Background color when 'ON'"),A.prototype.publish("offColor","#ecf0f1","html-color","Background color when 'OFF'"),A.prototype.publish("onFontColor","#2c3e50","html-color","Font color when 'ON'"),A.prototype.publish("offFontColor","#7f8c8d","html-color","Font color when 'OFF'");const B=class _Radio extends i{_inputElement=[];constructor(){super(),n.call(this),this._tag="div"}enter(t,e){super.enter(t,e);const n=this,i=e.append("ul");this.selectOptions().length||this.selectOptions().push(""),this.selectOptions().forEach(function(t,e){n._inputElement[e]=i.append("li").append("input").attr("type","radio"),n._inputElement[e].node().insertAdjacentHTML("afterend","<text>"+t+"</text>")}),this._inputElement.forEach(function(t,e){t.attr("name",n.name()),t.on("click",function(t){t.click(t)}),t.on("blur",function(t){t.blur(t)}),t.on("change",function(e){n.value([t.property("value")]),e.change(e,!0)})})}update(t,e){super.update(t,e);const n=this;this._inputElement.forEach(function(t,e){t.property("value",n.selectOptions()[e]),-1!==n.value().indexOf(n.selectOptions()[e])&&"false"!==n.value()?t.property("checked",!0):t.property("checked",!1)})}};e(B,"Radio");let M=B;M.prototype._class+=" form_Radio",M.prototype.implements(n.prototype),M.prototype.publish("selectOptions",[],"array","Array of options used to fill a dropdown list");const H=class _Range extends i{_inputElement=[];constructor(){super(),n.call(this),this._tag="div"}enter(t,e){super.enter(t,e);const n=this;this._inputElement[0]=e.append("input").attr("type","range"),this._inputElement[1]=e.append("input").attr("type","number"),this._inputElement.forEach(function(t,e){t.attr("name",n.name()),t.on("click",function(t){t.click(t)}),t.on("blur",function(t){t.blur(t)}),t.on("change",function(t){0===e?(n._inputElement[1].property("value",s(n._inputElement[0].property("value")).toString()),n.value(n._inputElement[0].property("value"))):(n._inputElement[0].property("value",n._inputElement[1].property("value")),n.value(s(n._inputElement[1].property("value")).toString())),t.change(t,!0)})})}update(t,e){super.update(t,e),this._inputElement[0].attr("type","range"),this._inputElement[0].property("value",this.value()),this._inputElement[0].attr("min",this.low()),this._inputElement[0].attr("max",this.high()),this._inputElement[0].attr("step",this.step()),this._inputElement[1].attr("type","number"),this._inputElement[1].property("value",this.value()),this._inputElement[1].attr("min",this.low()),this._inputElement[1].attr("max",this.high()),this._inputElement[1].attr("step",this.step())}insertSelectOptions(t){let e="";t.length>0?t.forEach(function(t){const n=t instanceof Array?t[0]:t,i=t instanceof Array?t[1]?t[1]:t[0]:t;e+="<option value='"+n+"'>"+i+"</option>"}):e+="<option>selectOptions not set</option>",this._inputElement[0].html(e)}};e(H,"Range");let I=H;I.prototype._class+=" form_Range",I.prototype.implements(n.prototype),I.prototype.publish("type","text","set","Input type",["html-color","number","checkbox","button","select","textarea","date","text","range","search","email","time","datetime"]),I.prototype.publish("selectOptions",[],"array","Array of options used to fill a dropdown list"),I.prototype.publish("low",null,"number","Minimum value for Range input"),I.prototype.publish("high",null,"number","Maximum value for Range input"),I.prototype.publish("step",null,"number","Step value for Range input");const T=class _Select extends i{_inputElement=[];constructor(){super(),n.call(this),this._tag="div"}enter(t,e){super.enter(t,e);const n=this;this._inputElement[0]=e.append("select").attr("name",this.name()).on("click",function(t){t.click(t)}).on("blur",function(t){t.blur(t)}).on("change",function(t){n.value([n._inputElement[0].property("value")]),t.change(t,!0)})}update(t,e){super.update(t,e),this.insertSelectOptions(this.selectOptions()),this._inputElement[0].property("value",this.value()).style("max-width",this.maxWidth_exists()?this.maxWidth()+"px":null)}insertSelectOptions(t){let e="";t.length>0?t.forEach(function(t){const n=t instanceof Array?t[0]:t,i=t instanceof Array?t[1]?t[1]:t[0]:t;e+="<option value='"+n+"'>"+i+"</option>"}):e+="<option>selectOptions not set</option>",this._inputElement[0].html(e)}};e(T,"Select");let V=T;V.prototype._class+=" form_Select",V.prototype.implements(n.prototype),V.prototype.publish("selectOptions",[],"array","Array of options used to fill a dropdown list"),V.prototype.publish("maxWidth",120,"number","Width",null,{optional:!0});const D=class _Slider extends r{xScale;moveMode;moveStartPos;prevValue;slider;handleLeft;handleLeftPos=0;handleLeftStartPos;handleRight;handleRightPos=0;handleRightStartPos;constructor(){super(),n.call(this)}enter(t,e){if(super.enter(t,e),this.resize({width:this.width(),height:50}),this.xScale=p().clamp(!0),this.slider=e.append("g").attr("class","slider"),null===this.low()&&null===this.high()&&null!==this.lowDatetime()&&null!==this.highDatetime()){const t=h(this.timePattern()?this.timePattern():"%Q");this.low(t(this.lowDatetime()).getTime()),this.high(t(this.highDatetime()).getTime())}this.slider.append("line").attr("class","track").select(function(){return this.parentNode.appendChild(this.cloneNode(!0))}).attr("class","track-inset").select(function(){return this.parentNode.appendChild(this.cloneNode(!0))}).attr("class","track-overlay").call(u().on("start",()=>{const t=l();this.moveStartPos=t.x,this.handleLeftStartPos=this.handleLeftPos,this.handleRightStartPos=this.handleRightPos,this.allowRange()&&this.handleLeftPos<=t.x&&t.x<=this.handleRightPos?this.moveMode="both":Math.abs(t.x-this.handleLeftPos)<Math.abs(t.x-this.handleRightPos)?this.moveMode="left":this.moveMode="right",this.moveHandleTo(t.x)}).on("drag",()=>{this.moveHandleTo(l().x)}).on("end",()=>{this.moveHandleTo(l().x),this.data([[this.xScale.invert(this.handleLeftPos),this.xScale.invert(this.handleRightPos)]]),this.checkChangedValue()})),this.slider.insert("g",".track-overlay").attr("class","ticks").attr("transform",`translate(0, ${this.fontSize()+this.tickHeight()/2})`),this.handleRight=this.slider.insert("path",".track-overlay").attr("class","handle"),this.handleLeft=this.slider.insert("path",".track-overlay").attr("class","handle")}update(t,e){super.update(t,e);const n=this;this.xScale.domain([this.low(),this.high()]).range([0,this.width()-2*this.padding()]),this.slider.attr("transform","translate("+(-this.width()/2+this.padding())+",0)"),this.slider.selectAll("line.track,line.track-inset,line.track-overlay").attr("x1",this.xScale.range()[0]).attr("x2",this.xScale.range()[1]);const i=(this.width()-2*this.padding())/(this.tickCount()-1),s=[];if(null!==this.tickDateFormat()&&null!==this.timePattern()){const t=h("%Q"),e=c(this.tickDateFormat()),n=(this.high()-this.low())/(this.tickCount()-1);for(let i=0;i<this.tickCount();i++){const o=t(""+(this.low()+n*i));s.push(e(o))}}else{const t=d(this.tickValueFormat()),e=(this.high()-this.low())/(this.tickCount()-1);for(let n=0;n<this.tickCount();n++){const i=this.low()+e*n;s.push(t(i))}}const o=this.slider.selectAll("g.tick").data(s),l=o.enter().append("g").attr("class","tick");l.append("text").attr("class","tick-text"),l.append("line").attr("class","tick-line"),l.merge(o).each(function(t,e){const s=i*e;a(this).select("text.tick-text").style("font-size",n.fontSize()).attr("x",function(){return 0===e?s-2:e===n.tickCount()-1?s+2:s}).attr("y",n.tickHeight()+n.tickOffset()/2+n.fontSize()).attr("text-basline","text-before-edge").attr("text-anchor",function(){return 0===e?"start":e===n.tickCount()-1?"end":"middle"}).text(()=>t),a(this).select("line.tick-line").attr("x1",s).attr("x2",s).attr("y1",n.tickOffset()-1).attr("y2",n.tickOffset()+n.tickHeight()).style("stroke","#000").style("stroke-width",1)}),this.slider.node().appendChild(this.handleRight.node()),this.slider.node().appendChild(this.handleLeft.node()),this.handleLeftPos=this.lowPos(),this.handleRightPos=this.highPos(),this.updateHandles(),this.checkChangedValue()}checkChangedValue(){this.prevValue!==this.value()&&void 0!==this.prevValue&&this.change(this),this.prevValue=this.value()}updateHandles(){this.handleLeft.attr("transform",`translate(${this.handleLeftPos}, -28)`).attr("d",t=>this.handlePath("l")),this.handleRight.attr("transform",`translate(${this.handleRightPos}, -28)`).attr("d",t=>this.handlePath("r"))}lowPos(){let t=[[this.low(),this.high()]];return this.data().length>0&&"number"==typeof this.data()[0][0]&&"number"==typeof this.data()[0][1]&&(t=this.data()),this.xScale(t[0][0])}highPos(){let t=[[this.low(),this.high()]];return this.data().length>0&&"number"==typeof this.data()[0][0]&&"number"==typeof this.data()[0][1]&&(t=this.data()),this.xScale(t[0][this.allowRange()?1:0])}moveHandleTo(t){if(this.allowRange())switch(this.moveMode){case"both":this.handleLeftPos=this.handleLeftStartPos+t-this.moveStartPos,this.handleRightPos=this.handleRightStartPos+t-this.moveStartPos;break;case"left":this.handleLeftPos=t,this.handleLeftPos>this.handleRightPos&&(this.handleRightPos=this.handleLeftPos);break;case"right":this.handleRightPos=t,this.handleRightPos<this.handleLeftPos&&(this.handleLeftPos=this.handleRightPos)}else this.handleLeftPos=this.handleRightPos=t;this.handleLeftPos=this.constrain(this.handleLeftPos),this.handleRightPos=this.constrain(this.handleRightPos),this.value(this.allowRange()?[this.xScale.invert(this.handleLeftPos),this.xScale.invert(this.handleRightPos)]:this.xScale.invert(this.handleLeftPos)),this.updateHandles()}constrain(t){const e=this.xScale.range();return t<e[0]&&(t=e[0]),t>e[1]&&(t=e[1]),this.nearestStep(t)}nearestStep(t){const e=this.xScale.invert(t);return this.xScale(this.low()+Math.round((e-this.low())/this.step())*this.step())}handlePath=/* @__PURE__ */e(function(t){const e=+("r"===t),n=e?1:-1,i=this.allowRange()?.5:0;let s="M"+i*n+","+"18A6,6 0 0 "+e+" "+6.5*n+",24V30A6,6 0 0 "+e+" "+i*n+",36";return this.allowRange()?s+="ZM"+2.5*n+",26V28M"+4.5*n+",26V28":s+="M"+1*n+",26V28",s},"handlePath")};e(D,"Slider");let W=D;W.prototype._class+=" form_Slider",W.prototype.implements(n.prototype),W.prototype.publish("padding",16,"number","Outer Padding",null,{tags:["Basic"]}),W.prototype.publish("fontSize",12,"number","Font Size",null,{tags:["Basic"]}),W.prototype.publish("fontFamily",null,"string","Font Name",null,{tags:["Basic"]}),W.prototype.publish("fontColor",null,"html-color","Font Color",null,{tags:["Basic"]}),W.prototype.publish("allowRange",!1,"boolean","Allow Range Selection",null,{tags:["Intermediate"]}),W.prototype.publish("low",null,"number","Low",null,{tags:["Intermediate"]}),W.prototype.publish("high",null,"number","High",null,{tags:["Intermediate"]}),W.prototype.publish("step",10,"number","Step",null,{tags:["Intermediate"]}),W.prototype.publish("lowDatetime",null,"string","Low",null,{tags:["Intermediate"]}),W.prototype.publish("highDatetime",null,"string","High",null,{tags:["Intermediate"]}),W.prototype.publish("selectionLabel","","string","Selection Label",null,{tags:["Intermediate"]}),W.prototype.publish("timePattern","%Y-%m-%d","string"),W.prototype.publish("tickCount",10,"number"),W.prototype.publish("tickOffset",5,"number"),W.prototype.publish("tickHeight",8,"number"),W.prototype.publish("tickDateFormat",null,"string"),W.prototype.publish("tickValueFormat",",.0f","string");const z=W.prototype.name;W.prototype.name=function(t){const e=z.apply(this,arguments);if(arguments.length){const e=t instanceof Array?t:[t];r.prototype.columns.call(this,e)}return e};const N=W.prototype.value;W.prototype.value=function(t){const e=N.apply(this,arguments);return arguments.length?(r.prototype.data.call(this,[this.allowRange()?t:[t,t]]),e):this.allowRange()?r.prototype.data.call(this)[0]:r.prototype.data.call(this)[0][0]};const j=class _TextArea extends S{constructor(){super(),this._tag="div",this.type("textarea")}enter(t,e){super.enter(t,e)}calcHeight(){return Math.max(this.minHeight_exists()?this.minHeight():0,this.height())}update(t,e){super.update(t,e),this._inputElement[0].attr("rows",this.rows()).attr("cols",this.cols()).attr("wrap",this.wrap()).attr("spellcheck",this.spellcheck()).style("height",this.calcHeight()+"px")}};e(j,"TextArea");let q=j;q.prototype._class+=" form_TextArea",q.prototype.publish("rows",null,"number","Rows",null,{optional:!0}),q.prototype.publish("cols",null,"number","Columns",null,{optional:!0}),q.prototype.publish("wrap","off","set","Wrap",["off","on"]),q.prototype.publish("minHeight",null,"number","Minimum Height",null,{optional:!0}),q.prototype.publish("spellcheck",null,"boolean","Input spell checking",{optional:!0});export{y as BUILD_VERSION,b as Button,v as CheckBox,E as ColorInput,O as FieldForm,w as Form,S as Input,F as InputRange,A as OnOff,m as PKG_NAME,f as PKG_VERSION,M as Radio,I as Range,V as Select,W as Slider,q as TextArea};
|
|
1
|
+
import { IInput as e } from "@hpcc-js/api";
|
|
2
|
+
import { HTMLWidget as t, SVGWidget as n, WidgetArray as r, d3Event as i, drag as a, format as o, rgb as s, scaleLinear as c, select as l, timeFormat as u, timeParse as d } from "@hpcc-js/common";
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
|
+
var f = "@hpcc-js/form", p = "3.4.9", m = "3.25.1", Button = class extends t {
|
|
5
|
+
_inputElement = [];
|
|
6
|
+
constructor() {
|
|
7
|
+
super(), e.call(this), this._tag = "div";
|
|
8
|
+
}
|
|
9
|
+
enter(e, t) {
|
|
10
|
+
super.enter(e, t);
|
|
11
|
+
let n = this;
|
|
12
|
+
this._inputElement[0] = t.append("button").attr("name", this.name()).on("click", function(e) {
|
|
13
|
+
e.click(e);
|
|
14
|
+
}).on("blur", function(e) {
|
|
15
|
+
e.blur(e);
|
|
16
|
+
}).on("change", function(e) {
|
|
17
|
+
n.value([n._inputElement[0].property("value")]), e.change(e, !0);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
update(e, t) {
|
|
21
|
+
super.update(e, t), this._inputElement[0].text(this.value());
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
Button.prototype._class += " form_Button", Button.prototype.implements(e.prototype);
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/CheckBox.ts
|
|
27
|
+
var CheckBox = class extends t {
|
|
28
|
+
_inputElement = [];
|
|
29
|
+
constructor() {
|
|
30
|
+
super(), e.call(this), this._tag = "div";
|
|
31
|
+
}
|
|
32
|
+
enter(e, t) {
|
|
33
|
+
super.enter(e, t);
|
|
34
|
+
let n = this, r = t.append("ul");
|
|
35
|
+
this.selectOptions().length || this.selectOptions().push(""), this.selectOptions().forEach(function(e, t) {
|
|
36
|
+
n._inputElement[t] = r.append("li").append("input").attr("type", "checkbox"), n._inputElement[t].node().insertAdjacentHTML("afterend", "<text>" + e + "</text>");
|
|
37
|
+
}), this._inputElement.forEach(function(e, t) {
|
|
38
|
+
e.attr("name", n.name()), e.on("click", function(e) {
|
|
39
|
+
e.click(e);
|
|
40
|
+
}), e.on("blur", function(e) {
|
|
41
|
+
e.blur(e);
|
|
42
|
+
}), e.on("change", function(e) {
|
|
43
|
+
let t = [];
|
|
44
|
+
n._inputElement.forEach(function(e) {
|
|
45
|
+
e.property("checked") && t.push(e.property("value"));
|
|
46
|
+
}), n.value(t), e.change(e, !0);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
update(e, t) {
|
|
51
|
+
super.update(e, t);
|
|
52
|
+
let n = this;
|
|
53
|
+
this._inputElement.forEach(function(e, t) {
|
|
54
|
+
e.property("value", n.selectOptions()[t]), n.value().indexOf(n.selectOptions()[t]) !== -1 && n.value() !== "false" ? e.property("checked", !0) : e.property("checked", !1);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
insertSelectOptions(e) {
|
|
58
|
+
let t = "";
|
|
59
|
+
e.length > 0 ? e.forEach(function(e) {
|
|
60
|
+
let n = e instanceof Array ? e[0] : e, r = e instanceof Array ? e[1] ? e[1] : e[0] : e;
|
|
61
|
+
t += "<option value='" + n + "'>" + r + "</option>";
|
|
62
|
+
}) : t += "<option>selectOptions not set</option>", this._inputElement[0].html(t);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
CheckBox.prototype._class += " form_CheckBox", CheckBox.prototype.implements(e.prototype), CheckBox.prototype.publish("selectOptions", [], "array", "Array of options used to fill a dropdown list");
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/ColorInput.ts
|
|
68
|
+
var ColorInput = class extends t {
|
|
69
|
+
_inputElement = [];
|
|
70
|
+
constructor() {
|
|
71
|
+
super(), e.call(this), this._tag = "div";
|
|
72
|
+
}
|
|
73
|
+
enter(e, t) {
|
|
74
|
+
super.enter(e, t);
|
|
75
|
+
let n = this;
|
|
76
|
+
this._inputElement[0] = t.append("input").attr("type", "text"), this._inputElement[0].classed("color-text", !0), this._inputElement[1] = t.append("input").attr("type", "color"), this._inputElement.forEach(function(e, t) {
|
|
77
|
+
e.on("click", function(e) {
|
|
78
|
+
e.click(e);
|
|
79
|
+
}), e.on("blur", function(e) {
|
|
80
|
+
e.blur(e);
|
|
81
|
+
}), e.on("change", function(e) {
|
|
82
|
+
t === 0 ? (n._inputElement[1].property("value", s(n._inputElement[0].property("value")).toString()), n.value(n._inputElement[0].property("value"))) : (n._inputElement[0].property("value", n._inputElement[1].property("value")), n.value(s(n._inputElement[1].property("value")).toString())), e.change(e, !0);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
update(e, t) {
|
|
87
|
+
super.update(e, t);
|
|
88
|
+
let n = this;
|
|
89
|
+
this._inputElement.forEach(function(e) {
|
|
90
|
+
e.attr("name", n.name());
|
|
91
|
+
}), this._inputElement[0].attr("type", "text"), this._inputElement[1].attr("type", "color"), this._inputElement[0].property("value", this.value()), this._inputElement[1].property("value", s(this.value()).toString());
|
|
92
|
+
let r = this._inputElement[0].node().getBoundingClientRect();
|
|
93
|
+
this._inputElement[1].style("height", r.height - 2 + "px");
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
ColorInput.prototype._class += " form_ColorInput", ColorInput.prototype.implements(e.prototype);
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/Form.ts
|
|
99
|
+
var Form = class extends t {
|
|
100
|
+
tbody;
|
|
101
|
+
tfoot;
|
|
102
|
+
btntd;
|
|
103
|
+
_controls;
|
|
104
|
+
_maxCols;
|
|
105
|
+
constructor() {
|
|
106
|
+
super(), this._tag = "form";
|
|
107
|
+
}
|
|
108
|
+
data(e) {
|
|
109
|
+
if (arguments.length) this.inputsForEach(function(t, n) {
|
|
110
|
+
e && e.length > n && t.value(e[n]).render();
|
|
111
|
+
});
|
|
112
|
+
else {
|
|
113
|
+
let e = [];
|
|
114
|
+
return this.inputsForEach(function(t) {
|
|
115
|
+
e.push(t.value());
|
|
116
|
+
}), e;
|
|
117
|
+
}
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
inputsForEach(e, t) {
|
|
121
|
+
let n = 0;
|
|
122
|
+
this.inputs().forEach(function(i) {
|
|
123
|
+
(i instanceof r ? i.content() : [i]).forEach(function(r) {
|
|
124
|
+
t ? e.call(t, r, n++) : e(r, n++);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
inputsMap() {
|
|
129
|
+
let e = {};
|
|
130
|
+
return this.inputs().forEach(function(t) {
|
|
131
|
+
e[t.name()] = t;
|
|
132
|
+
}), e;
|
|
133
|
+
}
|
|
134
|
+
calcMaxColumns() {
|
|
135
|
+
let e = 0;
|
|
136
|
+
return this.inputs().forEach(function(t) {
|
|
137
|
+
let n = t instanceof r ? t.content() : [t];
|
|
138
|
+
n.length > e && (e = n.length);
|
|
139
|
+
}), e;
|
|
140
|
+
}
|
|
141
|
+
values(e) {
|
|
142
|
+
if (arguments.length) this.inputsForEach(function(t) {
|
|
143
|
+
e[t.name()] ? t.value(e[t.name()]) : this.omitBlank() && t.value("");
|
|
144
|
+
}, this);
|
|
145
|
+
else {
|
|
146
|
+
let e = {};
|
|
147
|
+
return this.inputsForEach(function(t) {
|
|
148
|
+
let n = t.type ? t.type() : "text";
|
|
149
|
+
if (t.value() || !this.omitBlank()) switch (n) {
|
|
150
|
+
case "checkbox":
|
|
151
|
+
e[t.name()] = t.value_exists() ? !!t.value() : void 0;
|
|
152
|
+
break;
|
|
153
|
+
case "number":
|
|
154
|
+
let n = t.value();
|
|
155
|
+
e[t.name()] = n === "" ? void 0 : +n;
|
|
156
|
+
break;
|
|
157
|
+
default:
|
|
158
|
+
e[t.name()] = t.value_exists() ? t.value() : void 0;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}, this), e;
|
|
162
|
+
}
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
submit() {
|
|
166
|
+
let e = !0;
|
|
167
|
+
this.validate() && (e = this.checkValidation()), !(!this.allowEmptyRequest() && !this.inputs().some(function(e) {
|
|
168
|
+
return e._class.indexOf("WidgetArray") === -1 ? e.hasValue() : e.content().some(function(e) {
|
|
169
|
+
return e.hasValue();
|
|
170
|
+
});
|
|
171
|
+
})) && this.click(e ? this.values() : null, null, e);
|
|
172
|
+
}
|
|
173
|
+
clear() {
|
|
174
|
+
this.inputsForEach(function(e) {
|
|
175
|
+
switch (e.classID()) {
|
|
176
|
+
case "form_Slider":
|
|
177
|
+
e.allowRange() ? e.value([e.low(), e.low()]).render() : e.value(e.low()).render();
|
|
178
|
+
break;
|
|
179
|
+
case "form_CheckBox":
|
|
180
|
+
e.value(!1).render();
|
|
181
|
+
break;
|
|
182
|
+
case "form_Button": break;
|
|
183
|
+
default:
|
|
184
|
+
e.value(void 0).render();
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
checkValidation() {
|
|
190
|
+
let e = !0, t = [];
|
|
191
|
+
return this.inputsForEach(function(e) {
|
|
192
|
+
e.isValid() || t.push("'" + e.label() + "' value is invalid.");
|
|
193
|
+
}), t.length > 0 && (alert(t.join("\n")), e = !1), e;
|
|
194
|
+
}
|
|
195
|
+
enter(e, t) {
|
|
196
|
+
super.enter(e, t), t.on("submit", function() {
|
|
197
|
+
i().preventDefault();
|
|
198
|
+
}), this._placeholderElement.style("overflow", "auto");
|
|
199
|
+
let n = t.append("table");
|
|
200
|
+
this.tbody = n.append("tbody"), this.tfoot = n.append("tfoot"), this.btntd = this.tfoot.append("tr").append("td").attr("colspan", 2);
|
|
201
|
+
let r = this;
|
|
202
|
+
this._controls = [new Button().classed({ default: !0 }).value("Submit").on("click", function() {
|
|
203
|
+
r.submit();
|
|
204
|
+
}, !0), new Button().value("Clear").on("click", function() {
|
|
205
|
+
r.clear();
|
|
206
|
+
}, !0)];
|
|
207
|
+
let a = r.btntd.append("div").style("float", "right");
|
|
208
|
+
this._controls.forEach(function(e) {
|
|
209
|
+
let t = a.append("span").style("float", "left");
|
|
210
|
+
e.target(t.node()).render();
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
update(e, t) {
|
|
214
|
+
super.update(e, t), this._maxCols = this.calcMaxColumns();
|
|
215
|
+
let i = this, a = this.tbody.selectAll("tr").data(this.inputs());
|
|
216
|
+
a.enter().append("tr").each(function(e, t) {
|
|
217
|
+
let a = l(this), o = e instanceof r ? e.content() : [e];
|
|
218
|
+
o.forEach(function(e, t) {
|
|
219
|
+
a.append("td").attr("class", "prompt");
|
|
220
|
+
let r = a.append("td").attr("class", "input");
|
|
221
|
+
if (t === o.length - 1 && o.length < i._maxCols && r.attr("colspan", (i._maxCols - o.length + 1) * 2), e.target(r.node()).render(), e instanceof n) {
|
|
222
|
+
let t = e.element().node().getBBox();
|
|
223
|
+
r.style("height", t.height + "px"), e.resize().render();
|
|
224
|
+
}
|
|
225
|
+
e._inputElement instanceof Array && e._inputElement.forEach(function(e) {
|
|
226
|
+
e.on("keyup.form", function(e) {
|
|
227
|
+
setTimeout(function() {
|
|
228
|
+
i._controls[0].disable(!i.allowEmptyRequest() && !i.inputs().some(function(e) {
|
|
229
|
+
return e._class.indexOf("WidgetArray") === -1 ? e.hasValue() : e.content().some(function(e) {
|
|
230
|
+
return e.hasValue();
|
|
231
|
+
});
|
|
232
|
+
}));
|
|
233
|
+
}, 100);
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
}).merge(a).each(function(e, t) {
|
|
238
|
+
let n = l(this);
|
|
239
|
+
(e instanceof r ? e.content() : [e]).forEach(function(e, t) {
|
|
240
|
+
n.select("td.prompt").text(e.label() + ":");
|
|
241
|
+
});
|
|
242
|
+
}), a.each(function(e, t) {
|
|
243
|
+
t === 0 && e.setFocus && e.setFocus();
|
|
244
|
+
}), a.exit().each(function(e, t) {
|
|
245
|
+
(e instanceof r ? e.content() : [e]).forEach(function(e, t) {
|
|
246
|
+
e.target(null);
|
|
247
|
+
});
|
|
248
|
+
}).remove(), this.tfoot.style("display", this.showSubmit() ? "table-footer-group" : "none"), this.btntd.attr("colspan", this._maxCols * 2), this.allowEmptyRequest() || setTimeout(function() {
|
|
249
|
+
i._controls[0].disable(!i.allowEmptyRequest() && !i.inputs().some(function(e) {
|
|
250
|
+
return e._class.indexOf("WidgetArray") === -1 ? e.hasValue() : e.content().some(function(e) {
|
|
251
|
+
return e.hasValue();
|
|
252
|
+
});
|
|
253
|
+
}));
|
|
254
|
+
}, 100);
|
|
255
|
+
}
|
|
256
|
+
exit(e, t) {
|
|
257
|
+
this.inputsForEach((e) => e.target(null)), super.exit(e, t);
|
|
258
|
+
}
|
|
259
|
+
click(e, t, n) {}
|
|
260
|
+
};
|
|
261
|
+
Form.prototype._class += " form_Form", Form.prototype.publish("validate", !0, "boolean", "Enable/Disable input validation"), Form.prototype.publish("inputs", [], "widgetArray", "Array of input widgets", null, { render: !1 }), Form.prototype.publish("showSubmit", !0, "boolean", "Show Submit/Cancel Controls"), Form.prototype.publish("omitBlank", !1, "boolean", "Drop Blank Fields From Submit"), Form.prototype.publish("allowEmptyRequest", !1, "boolean", "Allow Blank Form to be Submitted");
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/Input.ts
|
|
264
|
+
var Input = class extends t {
|
|
265
|
+
_inputElement = [];
|
|
266
|
+
_labelElement = [];
|
|
267
|
+
constructor() {
|
|
268
|
+
super(), e.call(this), this._tag = "div";
|
|
269
|
+
}
|
|
270
|
+
checked(e) {
|
|
271
|
+
return arguments.length ? (this._inputElement[0] && this._inputElement[0].property("checked", e), this) : this._inputElement[0] ? this._inputElement[0].property("checked") : !1;
|
|
272
|
+
}
|
|
273
|
+
enter(e, t) {
|
|
274
|
+
super.enter(e, t), this._labelElement[0] = t.append("label").attr("for", this.id() + "_input").style("visibility", this.inlineLabel_exists() ? "visible" : "hidden");
|
|
275
|
+
let n = this;
|
|
276
|
+
switch (this.type()) {
|
|
277
|
+
case "button":
|
|
278
|
+
this._inputElement[0] = t.append("button").attr("id", this.id() + "_input");
|
|
279
|
+
break;
|
|
280
|
+
case "textarea":
|
|
281
|
+
this._inputElement[0] = t.append("textarea").attr("id", this.id() + "_input");
|
|
282
|
+
break;
|
|
283
|
+
default:
|
|
284
|
+
this._inputElement[0] = t.append("input").attr("id", this.id() + "_input").attr("type", this.type());
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
this._inputElement.forEach(function(e, t) {
|
|
288
|
+
e.attr("name", n.name()), e.on("click", function(e) {
|
|
289
|
+
e.click(e);
|
|
290
|
+
}), e.on("blur", function(e) {
|
|
291
|
+
e.blur(e);
|
|
292
|
+
}), e.on("change", function(t) {
|
|
293
|
+
n.value([e.property("value")]), t.change(t, !0);
|
|
294
|
+
}), e.on("keyup", function(t) {
|
|
295
|
+
n.value([e.property("value")]), t.change(t, !1);
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
update(e, t) {
|
|
300
|
+
switch (super.update(e, t), this._labelElement[0].style("visibility", this.inlineLabel_exists() ? "visible" : "hidden").text(this.inlineLabel()), this.type()) {
|
|
301
|
+
case "button":
|
|
302
|
+
this._inputElement[0].text(this.value());
|
|
303
|
+
break;
|
|
304
|
+
case "textarea":
|
|
305
|
+
this._inputElement[0].property("value", this.value());
|
|
306
|
+
break;
|
|
307
|
+
default:
|
|
308
|
+
this._inputElement[0].attr("type", this.type()), this._inputElement[0].property("value", this.value());
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
blur(e) {}
|
|
313
|
+
keyup(e) {}
|
|
314
|
+
focus(e) {}
|
|
315
|
+
click(e) {}
|
|
316
|
+
dblclick(e) {}
|
|
317
|
+
change(e, t) {}
|
|
318
|
+
};
|
|
319
|
+
Input.prototype._class += " form_Input", Input.prototype.implements(e.prototype), Input.prototype.publish("type", "text", "set", "Input type", [
|
|
320
|
+
"string",
|
|
321
|
+
"number",
|
|
322
|
+
"boolean",
|
|
323
|
+
"date",
|
|
324
|
+
"time",
|
|
325
|
+
"hidden",
|
|
326
|
+
"nested",
|
|
327
|
+
"button",
|
|
328
|
+
"checkbox",
|
|
329
|
+
"text",
|
|
330
|
+
"textarea",
|
|
331
|
+
"search",
|
|
332
|
+
"email",
|
|
333
|
+
"datetime"
|
|
334
|
+
]), Input.prototype.publish("inlineLabel", null, "string", "Input Label", null, { optional: !0 });
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region src/FieldForm.ts
|
|
337
|
+
var FieldForm = class extends Form {
|
|
338
|
+
constructor() {
|
|
339
|
+
super(), this._tag = "form";
|
|
340
|
+
}
|
|
341
|
+
fields(e) {
|
|
342
|
+
let t = super.fields.apply(this, arguments);
|
|
343
|
+
if (arguments.length) {
|
|
344
|
+
let t = this.inputsMap();
|
|
345
|
+
this.inputs(e.map((e) => t[e.id()] || new Input().name(e.id()).label(e.label()).type(e.type())));
|
|
346
|
+
}
|
|
347
|
+
return t;
|
|
348
|
+
}
|
|
349
|
+
data(e) {
|
|
350
|
+
if (!arguments.length) return super.data();
|
|
351
|
+
if (super.data(e[0]), e[0]) {
|
|
352
|
+
let t = this.inputs(), n = e[0][this.columns().length], r = 0;
|
|
353
|
+
for (let e in n) t[r].name(e), ++r;
|
|
354
|
+
}
|
|
355
|
+
return this;
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
FieldForm.prototype._class += " form_FieldForm";
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region src/InputRange.ts
|
|
361
|
+
var InputRange = class extends t {
|
|
362
|
+
_inputElement = [];
|
|
363
|
+
_labelElement = [];
|
|
364
|
+
_rangeData = [];
|
|
365
|
+
constructor() {
|
|
366
|
+
super(), e.call(this), this._tag = "div";
|
|
367
|
+
}
|
|
368
|
+
enter(e, t) {
|
|
369
|
+
super.enter(e, t), this._labelElement[0] = t.append("label").attr("for", this.id() + "_input").style("visibility", this.inlineLabel_exists() ? "visible" : "hidden"), this._inputElement.push(t.append("input").attr("id", this.id() + "_input_min").attr("type", this.type())), this._inputElement.push(t.append("input").attr("id", this.id() + "_input_max").attr("type", this.type()));
|
|
370
|
+
let n = this;
|
|
371
|
+
this._inputElement.forEach(function(e, t) {
|
|
372
|
+
e.attr("name", n.name()), e.on("click", function(e) {
|
|
373
|
+
e.click(e);
|
|
374
|
+
}), e.on("blur", function(e) {
|
|
375
|
+
e.blur(e);
|
|
376
|
+
}), e.on("change", function(r) {
|
|
377
|
+
n._rangeData[t] = e.property("value"), n.value(n._rangeData), r.change(r, !0);
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
update(e, t) {
|
|
382
|
+
super.update(e, t), this._labelElement[0].style("visibility", this.inlineLabel_exists() ? "visible" : "hidden").text(this.inlineLabel()), this._rangeData = this.value(), this._inputElement.forEach(function(e, t) {
|
|
383
|
+
e.attr("type", this.type()).property("value", this._rangeData.length > t ? this._rangeData[t] : "");
|
|
384
|
+
}, this);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
InputRange.prototype._class += " form_InputRange", InputRange.prototype.implements(e.prototype), InputRange.prototype.publish("type", "text", "set", "InputRange type", [
|
|
388
|
+
"number",
|
|
389
|
+
"date",
|
|
390
|
+
"text",
|
|
391
|
+
"time",
|
|
392
|
+
"datetime",
|
|
393
|
+
"hidden"
|
|
394
|
+
]), InputRange.prototype.publish("inlineLabel", null, "string", "InputRange Label", null, { optional: !0 }), InputRange.prototype.publish("value", ["", ""], "array", "Input Current Value", null, { override: !0 });
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/OnOff.ts
|
|
397
|
+
var OnOff = class extends t {
|
|
398
|
+
_inputElement = [];
|
|
399
|
+
_input;
|
|
400
|
+
constructor() {
|
|
401
|
+
super(), e.call(this), this._tag = "div";
|
|
402
|
+
}
|
|
403
|
+
enter(e, t) {
|
|
404
|
+
super.enter(e, t), t.classed("onoffswitch", !0);
|
|
405
|
+
let n = this;
|
|
406
|
+
this._input = t.append("input").attr("class", "onoffswitch-checkbox").attr("type", "checkbox").attr("id", this.id() + "_onOff").on("click", function(e) {
|
|
407
|
+
e.click(e);
|
|
408
|
+
}).on("blur", function(e) {
|
|
409
|
+
e.blur(e);
|
|
410
|
+
}).on("change", function(e) {
|
|
411
|
+
let t = [];
|
|
412
|
+
n._inputElement.forEach(function(e, n) {
|
|
413
|
+
e.property("checked") && t.push(e.property("value"));
|
|
414
|
+
}), n.value(t), e.change(e, !0);
|
|
415
|
+
});
|
|
416
|
+
let r = t.append("label").attr("class", "onoffswitch-label").attr("for", this.id() + "_onOff"), i = r.append("div").attr("class", "onoffswitch-inner");
|
|
417
|
+
i.append("div").attr("class", "onoffswitch-offText").style("padding-right", this.containerRadius() / 2 + "px").text(this.offText()), i.append("div").attr("class", "onoffswitch-onText").style("padding-left", this.containerRadius() / 2 + "px").style("width", `calc(100% - ${this.containerRadius() / 2}px)`).text(this.onText()), r.append("div").attr("class", "onoffswitch-switch");
|
|
418
|
+
}
|
|
419
|
+
update(e, t) {
|
|
420
|
+
super.update(e, t), this._input.attr("name", this.name()), t.style("margin-left", this.marginLeft() + "px").style("margin-bottom", this.marginBottom() + "px").style("width", this.minWidth() + "px");
|
|
421
|
+
let n = this.minHeight() - this.gutter() * 4;
|
|
422
|
+
t.select(".onoffswitch-switch").style("height", n + "px").style("width", n + "px").style("top", this.gutter() * 2 + 1 + "px").style("border-radius", this.switchRadius() + "px"), t.select(".onoffswitch-inner").style("min-height", this.minHeight() + "px"), t.select(".onoffswitch-label").style("border-radius", this.containerRadius() + "px"), t.select(".onoffswitch-offText").style("color", this.offFontColor()).style("background-color", this.offColor()), t.select(".onoffswitch-onText").style("color", this.onFontColor()).style("background-color", this.onColor());
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
OnOff.prototype._class += " form_OnOff", OnOff.prototype.implements(e.prototype), OnOff.prototype.publish("marginLeft", 0, "number", "Margin left of OnOff"), OnOff.prototype.publish("marginBottom", 0, "number", "Margin bottom of OnOff"), OnOff.prototype.publish("minWidth", 100, "number", "Minimum width of OnOff (pixels)"), OnOff.prototype.publish("minHeight", 20, "number", "Minimum height of OnOff (pixels)"), OnOff.prototype.publish("gutter", 1, "number", "Space between switch and border of OnOff (pixels)"), OnOff.prototype.publish("onText", "Save", "string", "Text to display when 'ON'"), OnOff.prototype.publish("offText", "Properties", "string", "Text to display when 'OFF'"), OnOff.prototype.publish("switchRadius", 10, "number", "Border radius of switch (pixels)"), OnOff.prototype.publish("containerRadius", 10, "number", "Border radius of OnOff (pixels)"), OnOff.prototype.publish("onColor", "#2ecc71", "html-color", "Background color when 'ON'"), OnOff.prototype.publish("offColor", "#ecf0f1", "html-color", "Background color when 'OFF'"), OnOff.prototype.publish("onFontColor", "#2c3e50", "html-color", "Font color when 'ON'"), OnOff.prototype.publish("offFontColor", "#7f8c8d", "html-color", "Font color when 'OFF'");
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region src/Radio.ts
|
|
428
|
+
var Radio = class extends t {
|
|
429
|
+
_inputElement = [];
|
|
430
|
+
constructor() {
|
|
431
|
+
super(), e.call(this), this._tag = "div";
|
|
432
|
+
}
|
|
433
|
+
enter(e, t) {
|
|
434
|
+
super.enter(e, t);
|
|
435
|
+
let n = this, r = t.append("ul");
|
|
436
|
+
this.selectOptions().length || this.selectOptions().push(""), this.selectOptions().forEach(function(e, t) {
|
|
437
|
+
n._inputElement[t] = r.append("li").append("input").attr("type", "radio"), n._inputElement[t].node().insertAdjacentHTML("afterend", "<text>" + e + "</text>");
|
|
438
|
+
}), this._inputElement.forEach(function(e, t) {
|
|
439
|
+
e.attr("name", n.name()), e.on("click", function(e) {
|
|
440
|
+
e.click(e);
|
|
441
|
+
}), e.on("blur", function(e) {
|
|
442
|
+
e.blur(e);
|
|
443
|
+
}), e.on("change", function(t) {
|
|
444
|
+
n.value([e.property("value")]), t.change(t, !0);
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
update(e, t) {
|
|
449
|
+
super.update(e, t);
|
|
450
|
+
let n = this;
|
|
451
|
+
this._inputElement.forEach(function(e, t) {
|
|
452
|
+
e.property("value", n.selectOptions()[t]), n.value().indexOf(n.selectOptions()[t]) !== -1 && n.value() !== "false" ? e.property("checked", !0) : e.property("checked", !1);
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
Radio.prototype._class += " form_Radio", Radio.prototype.implements(e.prototype), Radio.prototype.publish("selectOptions", [], "array", "Array of options used to fill a dropdown list");
|
|
457
|
+
//#endregion
|
|
458
|
+
//#region src/Range.ts
|
|
459
|
+
var Range = class extends t {
|
|
460
|
+
_inputElement = [];
|
|
461
|
+
constructor() {
|
|
462
|
+
super(), e.call(this), this._tag = "div";
|
|
463
|
+
}
|
|
464
|
+
enter(e, t) {
|
|
465
|
+
super.enter(e, t);
|
|
466
|
+
let n = this;
|
|
467
|
+
this._inputElement[0] = t.append("input").attr("type", "range"), this._inputElement[1] = t.append("input").attr("type", "number"), this._inputElement.forEach(function(e, t) {
|
|
468
|
+
e.attr("name", n.name()), e.on("click", function(e) {
|
|
469
|
+
e.click(e);
|
|
470
|
+
}), e.on("blur", function(e) {
|
|
471
|
+
e.blur(e);
|
|
472
|
+
}), e.on("change", function(e) {
|
|
473
|
+
t === 0 ? (n._inputElement[1].property("value", s(n._inputElement[0].property("value")).toString()), n.value(n._inputElement[0].property("value"))) : (n._inputElement[0].property("value", n._inputElement[1].property("value")), n.value(s(n._inputElement[1].property("value")).toString())), e.change(e, !0);
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
update(e, t) {
|
|
478
|
+
super.update(e, t), this._inputElement[0].attr("type", "range"), this._inputElement[0].property("value", this.value()), this._inputElement[0].attr("min", this.low()), this._inputElement[0].attr("max", this.high()), this._inputElement[0].attr("step", this.step()), this._inputElement[1].attr("type", "number"), this._inputElement[1].property("value", this.value()), this._inputElement[1].attr("min", this.low()), this._inputElement[1].attr("max", this.high()), this._inputElement[1].attr("step", this.step());
|
|
479
|
+
}
|
|
480
|
+
insertSelectOptions(e) {
|
|
481
|
+
let t = "";
|
|
482
|
+
e.length > 0 ? e.forEach(function(e) {
|
|
483
|
+
let n = e instanceof Array ? e[0] : e, r = e instanceof Array ? e[1] ? e[1] : e[0] : e;
|
|
484
|
+
t += "<option value='" + n + "'>" + r + "</option>";
|
|
485
|
+
}) : t += "<option>selectOptions not set</option>", this._inputElement[0].html(t);
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
Range.prototype._class += " form_Range", Range.prototype.implements(e.prototype), Range.prototype.publish("type", "text", "set", "Input type", [
|
|
489
|
+
"html-color",
|
|
490
|
+
"number",
|
|
491
|
+
"checkbox",
|
|
492
|
+
"button",
|
|
493
|
+
"select",
|
|
494
|
+
"textarea",
|
|
495
|
+
"date",
|
|
496
|
+
"text",
|
|
497
|
+
"range",
|
|
498
|
+
"search",
|
|
499
|
+
"email",
|
|
500
|
+
"time",
|
|
501
|
+
"datetime"
|
|
502
|
+
]), Range.prototype.publish("selectOptions", [], "array", "Array of options used to fill a dropdown list"), Range.prototype.publish("low", null, "number", "Minimum value for Range input"), Range.prototype.publish("high", null, "number", "Maximum value for Range input"), Range.prototype.publish("step", null, "number", "Step value for Range input");
|
|
503
|
+
//#endregion
|
|
504
|
+
//#region src/Select.ts
|
|
505
|
+
var Select = class extends t {
|
|
506
|
+
_inputElement = [];
|
|
507
|
+
constructor() {
|
|
508
|
+
super(), e.call(this), this._tag = "div";
|
|
509
|
+
}
|
|
510
|
+
enter(e, t) {
|
|
511
|
+
super.enter(e, t);
|
|
512
|
+
let n = this;
|
|
513
|
+
this._inputElement[0] = t.append("select").attr("name", this.name()).on("click", function(e) {
|
|
514
|
+
e.click(e);
|
|
515
|
+
}).on("blur", function(e) {
|
|
516
|
+
e.blur(e);
|
|
517
|
+
}).on("change", function(e) {
|
|
518
|
+
n.value([n._inputElement[0].property("value")]), e.change(e, !0);
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
update(e, t) {
|
|
522
|
+
super.update(e, t), this.insertSelectOptions(this.selectOptions()), this._inputElement[0].property("value", this.value()).style("max-width", this.maxWidth_exists() ? this.maxWidth() + "px" : null);
|
|
523
|
+
}
|
|
524
|
+
insertSelectOptions(e) {
|
|
525
|
+
let t = "";
|
|
526
|
+
e.length > 0 ? e.forEach(function(e) {
|
|
527
|
+
let n = e instanceof Array ? e[0] : e, r = e instanceof Array ? e[1] ? e[1] : e[0] : e;
|
|
528
|
+
t += "<option value='" + n + "'>" + r + "</option>";
|
|
529
|
+
}) : t += "<option>selectOptions not set</option>", this._inputElement[0].html(t);
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
Select.prototype._class += " form_Select", Select.prototype.implements(e.prototype), Select.prototype.publish("selectOptions", [], "array", "Array of options used to fill a dropdown list"), Select.prototype.publish("maxWidth", 120, "number", "Width", null, { optional: !0 });
|
|
533
|
+
//#endregion
|
|
534
|
+
//#region src/Slider.ts
|
|
535
|
+
var Slider = class extends n {
|
|
536
|
+
xScale;
|
|
537
|
+
moveMode;
|
|
538
|
+
moveStartPos;
|
|
539
|
+
prevValue;
|
|
540
|
+
slider;
|
|
541
|
+
handleLeft;
|
|
542
|
+
handleLeftPos = 0;
|
|
543
|
+
handleLeftStartPos;
|
|
544
|
+
handleRight;
|
|
545
|
+
handleRightPos = 0;
|
|
546
|
+
handleRightStartPos;
|
|
547
|
+
constructor() {
|
|
548
|
+
super(), e.call(this);
|
|
549
|
+
}
|
|
550
|
+
enter(e, t) {
|
|
551
|
+
if (super.enter(e, t), this.resize({
|
|
552
|
+
width: this.width(),
|
|
553
|
+
height: 50
|
|
554
|
+
}), this.xScale = c().clamp(!0), this.slider = t.append("g").attr("class", "slider"), this.low() === null && this.high() === null && this.lowDatetime() !== null && this.highDatetime() !== null) {
|
|
555
|
+
let e = d(this.timePattern() ? this.timePattern() : "%Q");
|
|
556
|
+
this.low(e(this.lowDatetime()).getTime()), this.high(e(this.highDatetime()).getTime());
|
|
557
|
+
}
|
|
558
|
+
this.slider.append("line").attr("class", "track").select(function() {
|
|
559
|
+
return this.parentNode.appendChild(this.cloneNode(!0));
|
|
560
|
+
}).attr("class", "track-inset").select(function() {
|
|
561
|
+
return this.parentNode.appendChild(this.cloneNode(!0));
|
|
562
|
+
}).attr("class", "track-overlay").call(a().on("start", () => {
|
|
563
|
+
let e = i();
|
|
564
|
+
this.moveStartPos = e.x, this.handleLeftStartPos = this.handleLeftPos, this.handleRightStartPos = this.handleRightPos, this.allowRange() && this.handleLeftPos <= e.x && e.x <= this.handleRightPos ? this.moveMode = "both" : Math.abs(e.x - this.handleLeftPos) < Math.abs(e.x - this.handleRightPos) ? this.moveMode = "left" : this.moveMode = "right", this.moveHandleTo(e.x);
|
|
565
|
+
}).on("drag", () => {
|
|
566
|
+
this.moveHandleTo(i().x);
|
|
567
|
+
}).on("end", () => {
|
|
568
|
+
this.moveHandleTo(i().x), this.data([[this.xScale.invert(this.handleLeftPos), this.xScale.invert(this.handleRightPos)]]), this.checkChangedValue();
|
|
569
|
+
})), this.slider.insert("g", ".track-overlay").attr("class", "ticks").attr("transform", `translate(0, ${this.fontSize() + this.tickHeight() / 2})`), this.handleRight = this.slider.insert("path", ".track-overlay").attr("class", "handle"), this.handleLeft = this.slider.insert("path", ".track-overlay").attr("class", "handle");
|
|
570
|
+
}
|
|
571
|
+
update(e, t) {
|
|
572
|
+
super.update(e, t);
|
|
573
|
+
let n = this;
|
|
574
|
+
this.xScale.domain([this.low(), this.high()]).range([0, this.width() - this.padding() * 2]), this.slider.attr("transform", "translate(" + (-this.width() / 2 + this.padding()) + ",0)"), this.slider.selectAll("line.track,line.track-inset,line.track-overlay").attr("x1", this.xScale.range()[0]).attr("x2", this.xScale.range()[1]);
|
|
575
|
+
let r = (this.width() - this.padding() * 2) / (this.tickCount() - 1), i = [];
|
|
576
|
+
if (this.tickDateFormat() !== null && this.timePattern() !== null) {
|
|
577
|
+
let e = d("%Q"), t = u(this.tickDateFormat()), n = (this.high() - this.low()) / (this.tickCount() - 1);
|
|
578
|
+
for (let r = 0; r < this.tickCount(); r++) {
|
|
579
|
+
let a = e("" + (this.low() + n * r));
|
|
580
|
+
i.push(t(a));
|
|
581
|
+
}
|
|
582
|
+
} else {
|
|
583
|
+
let e = o(this.tickValueFormat()), t = (this.high() - this.low()) / (this.tickCount() - 1);
|
|
584
|
+
for (let n = 0; n < this.tickCount(); n++) {
|
|
585
|
+
let r = this.low() + t * n;
|
|
586
|
+
i.push(e(r));
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
let a = this.slider.selectAll("g.tick").data(i), s = a.enter().append("g").attr("class", "tick");
|
|
590
|
+
s.append("text").attr("class", "tick-text"), s.append("line").attr("class", "tick-line"), s.merge(a).each(function(e, t) {
|
|
591
|
+
let i = r * t;
|
|
592
|
+
l(this).select("text.tick-text").style("font-size", n.fontSize()).attr("x", function() {
|
|
593
|
+
return t === 0 ? i - 2 : t === n.tickCount() - 1 ? i + 2 : i;
|
|
594
|
+
}).attr("y", n.tickHeight() + n.tickOffset() / 2 + n.fontSize()).attr("text-basline", "text-before-edge").attr("text-anchor", function() {
|
|
595
|
+
return t === 0 ? "start" : t === n.tickCount() - 1 ? "end" : "middle";
|
|
596
|
+
}).text(() => e), l(this).select("line.tick-line").attr("x1", i).attr("x2", i).attr("y1", n.tickOffset() - 1).attr("y2", n.tickOffset() + n.tickHeight()).style("stroke", "#000").style("stroke-width", 1);
|
|
597
|
+
}), this.slider.node().appendChild(this.handleRight.node()), this.slider.node().appendChild(this.handleLeft.node()), this.handleLeftPos = this.lowPos(), this.handleRightPos = this.highPos(), this.updateHandles(), this.checkChangedValue();
|
|
598
|
+
}
|
|
599
|
+
checkChangedValue() {
|
|
600
|
+
this.prevValue !== this.value() && this.prevValue !== void 0 && this.change(this), this.prevValue = this.value();
|
|
601
|
+
}
|
|
602
|
+
updateHandles() {
|
|
603
|
+
this.handleLeft.attr("transform", `translate(${this.handleLeftPos}, -28)`).attr("d", (e) => this.handlePath("l")), this.handleRight.attr("transform", `translate(${this.handleRightPos}, -28)`).attr("d", (e) => this.handlePath("r"));
|
|
604
|
+
}
|
|
605
|
+
lowPos() {
|
|
606
|
+
let e = [[this.low(), this.high()]];
|
|
607
|
+
return this.data().length > 0 && typeof this.data()[0][0] == "number" && typeof this.data()[0][1] == "number" && (e = this.data()), this.xScale(e[0][0]);
|
|
608
|
+
}
|
|
609
|
+
highPos() {
|
|
610
|
+
let e = [[this.low(), this.high()]];
|
|
611
|
+
return this.data().length > 0 && typeof this.data()[0][0] == "number" && typeof this.data()[0][1] == "number" && (e = this.data()), this.xScale(e[0][+!!this.allowRange()]);
|
|
612
|
+
}
|
|
613
|
+
moveHandleTo(e) {
|
|
614
|
+
if (this.allowRange()) switch (this.moveMode) {
|
|
615
|
+
case "both":
|
|
616
|
+
this.handleLeftPos = this.handleLeftStartPos + e - this.moveStartPos, this.handleRightPos = this.handleRightStartPos + e - this.moveStartPos;
|
|
617
|
+
break;
|
|
618
|
+
case "left":
|
|
619
|
+
this.handleLeftPos = e, this.handleLeftPos > this.handleRightPos && (this.handleRightPos = this.handleLeftPos);
|
|
620
|
+
break;
|
|
621
|
+
case "right":
|
|
622
|
+
this.handleRightPos = e, this.handleRightPos < this.handleLeftPos && (this.handleLeftPos = this.handleRightPos);
|
|
623
|
+
break;
|
|
624
|
+
}
|
|
625
|
+
else this.handleLeftPos = this.handleRightPos = e;
|
|
626
|
+
this.handleLeftPos = this.constrain(this.handleLeftPos), this.handleRightPos = this.constrain(this.handleRightPos), this.value(this.allowRange() ? [this.xScale.invert(this.handleLeftPos), this.xScale.invert(this.handleRightPos)] : this.xScale.invert(this.handleLeftPos)), this.updateHandles();
|
|
627
|
+
}
|
|
628
|
+
constrain(e) {
|
|
629
|
+
let t = this.xScale.range();
|
|
630
|
+
return e < t[0] && (e = t[0]), e > t[1] && (e = t[1]), this.nearestStep(e);
|
|
631
|
+
}
|
|
632
|
+
nearestStep(e) {
|
|
633
|
+
let t = this.xScale.invert(e);
|
|
634
|
+
return this.xScale(this.low() + Math.round((t - this.low()) / this.step()) * this.step());
|
|
635
|
+
}
|
|
636
|
+
handlePath = function(e) {
|
|
637
|
+
let t = +(e === "r"), n = t ? 1 : -1, r = this.allowRange() ? .5 : 0, i = "M" + r * n + ",18A6,6 0 0 " + t + " " + 6.5 * n + ",24V30A6,6 0 0 " + t + " " + r * n + ",36";
|
|
638
|
+
return this.allowRange() ? i += "ZM" + 2.5 * n + ",26V28M" + 4.5 * n + ",26V28" : i += "M" + 1 * n + ",26V28", i;
|
|
639
|
+
};
|
|
640
|
+
};
|
|
641
|
+
Slider.prototype._class += " form_Slider", Slider.prototype.implements(e.prototype), Slider.prototype.publish("padding", 16, "number", "Outer Padding", null, { tags: ["Basic"] }), Slider.prototype.publish("fontSize", 12, "number", "Font Size", null, { tags: ["Basic"] }), Slider.prototype.publish("fontFamily", null, "string", "Font Name", null, { tags: ["Basic"] }), Slider.prototype.publish("fontColor", null, "html-color", "Font Color", null, { tags: ["Basic"] }), Slider.prototype.publish("allowRange", !1, "boolean", "Allow Range Selection", null, { tags: ["Intermediate"] }), Slider.prototype.publish("low", null, "number", "Low", null, { tags: ["Intermediate"] }), Slider.prototype.publish("high", null, "number", "High", null, { tags: ["Intermediate"] }), Slider.prototype.publish("step", 10, "number", "Step", null, { tags: ["Intermediate"] }), Slider.prototype.publish("lowDatetime", null, "string", "Low", null, { tags: ["Intermediate"] }), Slider.prototype.publish("highDatetime", null, "string", "High", null, { tags: ["Intermediate"] }), Slider.prototype.publish("selectionLabel", "", "string", "Selection Label", null, { tags: ["Intermediate"] }), Slider.prototype.publish("timePattern", "%Y-%m-%d", "string"), Slider.prototype.publish("tickCount", 10, "number"), Slider.prototype.publish("tickOffset", 5, "number"), Slider.prototype.publish("tickHeight", 8, "number"), Slider.prototype.publish("tickDateFormat", null, "string"), Slider.prototype.publish("tickValueFormat", ",.0f", "string");
|
|
642
|
+
var h = Slider.prototype.name;
|
|
643
|
+
Slider.prototype.name = function(e) {
|
|
644
|
+
let t = h.apply(this, arguments);
|
|
645
|
+
if (arguments.length) {
|
|
646
|
+
let t = e instanceof Array ? e : [e];
|
|
647
|
+
n.prototype.columns.call(this, t);
|
|
648
|
+
}
|
|
649
|
+
return t;
|
|
650
|
+
};
|
|
651
|
+
var g = Slider.prototype.value;
|
|
652
|
+
Slider.prototype.value = function(e) {
|
|
653
|
+
let t = g.apply(this, arguments);
|
|
654
|
+
if (arguments.length) n.prototype.data.call(this, [this.allowRange() ? e : [e, e]]);
|
|
655
|
+
else return this.allowRange() ? n.prototype.data.call(this)[0] : n.prototype.data.call(this)[0][0];
|
|
656
|
+
return t;
|
|
657
|
+
};
|
|
658
|
+
//#endregion
|
|
659
|
+
//#region src/TextArea.ts
|
|
660
|
+
var TextArea = class extends Input {
|
|
661
|
+
constructor() {
|
|
662
|
+
super(), this._tag = "div", this.type("textarea");
|
|
663
|
+
}
|
|
664
|
+
enter(e, t) {
|
|
665
|
+
super.enter(e, t);
|
|
666
|
+
}
|
|
667
|
+
calcHeight() {
|
|
668
|
+
return Math.max(this.minHeight_exists() ? this.minHeight() : 0, this.height());
|
|
669
|
+
}
|
|
670
|
+
update(e, t) {
|
|
671
|
+
super.update(e, t), this._inputElement[0].attr("rows", this.rows()).attr("cols", this.cols()).attr("wrap", this.wrap()).attr("spellcheck", this.spellcheck()).style("height", this.calcHeight() + "px");
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
TextArea.prototype._class += " form_TextArea", TextArea.prototype.publish("rows", null, "number", "Rows", null, { optional: !0 }), TextArea.prototype.publish("cols", null, "number", "Columns", null, { optional: !0 }), TextArea.prototype.publish("wrap", "off", "set", "Wrap", ["off", "on"]), TextArea.prototype.publish("minHeight", null, "number", "Minimum Height", null, { optional: !0 }), TextArea.prototype.publish("spellcheck", null, "boolean", "Input spell checking", { optional: !0 });
|
|
675
|
+
//#endregion
|
|
676
|
+
export { m as BUILD_VERSION, Button, CheckBox, ColorInput, FieldForm, Form, Input, InputRange, OnOff, f as PKG_NAME, p as PKG_VERSION, Radio, Range, Select, Slider, TextArea };
|
|
677
|
+
|
|
2
678
|
//# sourceMappingURL=index.js.map
|
|
3
|
-
|
|
679
|
+
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`.form_Input input,.form_Input select,.form_Input button,.form_Input textarea{padding:2px}.form_Input button{cursor:pointer}.form_Input input.color-text{width:120px}.form_Input input.color-text+input{width:57px;position:absolute}.form_Input textarea,.form_Input input[type=textbox]{box-sizing:border-box;width:100%;display:block}.form_Input ul{float:left;margin:0;padding:0;list-style-type:none}.form_Input li{float:left;list-style-position:inside}.form_Form{color:#404040}.form_Form tbody td{white-space:nowrap;border:1px solid #e5e5e5}.form_Form td.prompt{vertical-align:middle;background-color:#e5e5e5;padding:2px}.form_Form td.input{vertical-align:middle;width:100%;padding:2px}.form_Form td.input .common_HTMLWidget ul{margin:0}.form_Form tfoot button{margin:5px}.form_Form tbody tr:hover{background-color:#fafafa}.form_Form .form_Button button{box-sizing:border-box;color:#24292e;cursor:pointer;overflow-wrap:break-word;vertical-align:middle;white-space:nowrap;word-wrap:break-word;column-rule-color:#24292e;perspective-origin:57.2938px 14px;transform-origin:57.2938px 14px;-webkit-user-select:none;user-select:none;background:#eff3f6 linear-gradient(-180deg,#fafbfc 0%,#eff3f6 90%) -1px -1px/110% 110% repeat-x;border:1px solid #1b1f2333;border-radius:3px;outline:0 #24292e;height:28px;padding:3px 10px;-webkit-text-decoration:none;text-decoration:none;position:relative;inset:0}.form_Form .form_Button button[disabled=disabled]{background:#dbdfe2}.form_Form .form_Button button:focus{box-shadow:0 0 0 .2em #0366d64d}.form_Form .form_Button button:hover{background:#dbdfe2}.form_Form .form_Button.default button{color:#fff;word-wrap:break-word;column-rule-color:#fff;perspective-origin:44.975px 17px;transform-origin:44.975px 17px;background:#28a745 linear-gradient(-180deg,#34d058 0%,#28a745 90%) -1px -1px/110% 110% repeat-x;outline:0 #fff;-webkit-text-decoration:none;text-decoration:none}.form_Form .form_Button.default button[disabled=disabled],.form_Form .form_Button.default button[disabled=disabled]:hover{background:#dbdfe2}.form_Form .form_Button.default button:hover{background:#149331}.onoffswitch-checkbox{display:none}.onoffswitch{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;width:100px;height:20px;position:relative}.onoffswitch-label{cursor:pointer;border:1px solid #999;height:20px;display:block;overflow:hidden}.onoffswitch-inner{transition:margin .3s ease-in;display:block;position:relative}.onoffswitch-inner>.onoffswitch-offText,.onoffswitch-inner>.onoffswitch-onText{height:100%}.onoffswitch-inner>.onoffswitch-offText{text-align:right;width:100%;font-weight:700;transition:all .3s ease-in;position:absolute;right:0}.onoffswitch-inner>.onoffswitch-onText{text-align:left;width:100%;font-weight:700;transition:all .3s ease-in;position:absolute;left:-100%}.onoffswitch-switch{background:#fff;border:1px solid #999;width:20px;margin:-1px;transition:all .3s ease-in;display:block;position:absolute;inset:0 78px 0 4px}.onoffswitch-checkbox:checked+.onoffswitch-label .onoffswitch-inner>.onoffswitch-offText{right:-100%}.onoffswitch-checkbox:checked+.onoffswitch-label .onoffswitch-inner>.onoffswitch-onText{left:0}.onoffswitch-checkbox:checked+.onoffswitch-label .onoffswitch-switch{left:calc(100% - 20px)}.form_Slider .ticks{font:10px sans-serif}.form_Slider .track,.form_Slider .track-inset,.form_Slider .track-overlay{stroke-linecap:round}.form_Slider .track{stroke:#000;stroke-opacity:.3;stroke-width:10px}.form_Slider .track-inset{stroke:#ddd;stroke-width:8px}.form_Slider .track-overlay{pointer-events:stroke;stroke-width:50px;stroke:#0000;cursor:crosshair}.form_Slider .handle{fill:#fff;stroke:#000;stroke-opacity:.5;stroke-width:1.25px}.form_Slider .tick-line{stroke:#000;stroke-opacity:.5;stroke-width:1px;shape-rendering:crispedges}/*$vite$:1*/`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();
|