@hpcc-js/form 3.4.8 → 3.5.0
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 +7 -7
package/dist/index.umd.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@hpcc-js/api"),require("@hpcc-js/common")):"function"==typeof define&&define.amd?define(["exports","@hpcc-js/api","@hpcc-js/common"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@hpcc-js/form"]={},t["@hpcc-js/api"],t["@hpcc-js/common"])}(this,function(t,e,n){"use strict";var i=Object.defineProperty,s=(t,e)=>i(t,"name",{value:e,configurable:!0});const o=class _Button extends n.HTMLWidget{_inputElement=[];constructor(){super(),e.IInput.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())}};s(o,"Button");let l=o;l.prototype._class+=" form_Button",l.prototype.implements(e.IInput.prototype);const a=class _CheckBox extends n.HTMLWidget{_inputElement=[];constructor(){super(),e.IInput.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)}};s(a,"CheckBox");let r=a;r.prototype._class+=" form_CheckBox",r.prototype.implements(e.IInput.prototype),r.prototype.publish("selectOptions",[],"array","Array of options used to fill a dropdown list");const p=class _ColorInput extends n.HTMLWidget{_inputElement=[];constructor(){super(),e.IInput.call(this),this._tag="div"}enter(t,e){super.enter(t,e);const i=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?(i._inputElement[1].property("value",n.rgb(i._inputElement[0].property("value")).toString()),i.value(i._inputElement[0].property("value"))):(i._inputElement[0].property("value",i._inputElement[1].property("value")),i.value(n.rgb(i._inputElement[1].property("value")).toString())),t.change(t,!0)})})}update(t,e){super.update(t,e);const i=this;this._inputElement.forEach(function(t){t.attr("name",i.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",n.rgb(this.value()).toString());const s=this._inputElement[0].node().getBoundingClientRect();this._inputElement[1].style("height",s.height-2+"px")}};s(p,"ColorInput");let h=p;h.prototype._class+=" form_ColorInput",h.prototype.implements(e.IInput.prototype);const u=class _Form extends n.HTMLWidget{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 i=0;this.inputs().forEach(function(s){(s instanceof n.WidgetArray?s.content():[s]).forEach(function(n){e?t.call(e,n,i++):t(n,i++)})})}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 i=e instanceof n.WidgetArray?e.content():[e];i.length>t&&(t=i.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(){n.d3Event().preventDefault()}),this._placeholderElement.style("overflow","auto");const i=e.append("table");this.tbody=i.append("tbody"),this.tfoot=i.append("tfoot"),this.btntd=this.tfoot.append("tr").append("td").attr("colspan",2);const s=this;this._controls=[(new l).classed({default:!0}).value("Submit").on("click",function(){s.submit()},!0),(new l).value("Clear").on("click",function(){s.clear()},!0)];const o=s.btntd.append("div").style("float","right");this._controls.forEach(function(t){const e=o.append("span").style("float","left");t.target(e.node()).render()})}update(t,e){super.update(t,e),this._maxCols=this.calcMaxColumns();const i=this,s=this.tbody.selectAll("tr").data(this.inputs());s.enter().append("tr").each(function(t,e){const s=n.select(this),o=t instanceof n.WidgetArray?t.content():[t];o.forEach(function(t,e){s.append("td").attr("class","prompt");const l=s.append("td").attr("class","input");if(e===o.length-1&&o.length<i._maxCols&&l.attr("colspan",2*(i._maxCols-o.length+1)),t.target(l.node()).render(),t instanceof n.SVGWidget){const e=t.element().node().getBBox();l.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(){i._controls[0].disable(!i.allowEmptyRequest()&&!i.inputs().some(function(t){return-1!==t._class.indexOf("WidgetArray")?t.content().some(function(t){return t.hasValue()}):t.hasValue()}))},100)})})})}).merge(s).each(function(t,e){const i=n.select(this);(t instanceof n.WidgetArray?t.content():[t]).forEach(function(t,e){i.select("td.prompt").text(t.label()+":")})}),s.each(function(t,e){0===e&&t.setFocus&&t.setFocus()}),s.exit().each(function(t,e){(t instanceof n.WidgetArray?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(){i._controls[0].disable(!i.allowEmptyRequest()&&!i.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){}};s(u,"Form");let c=u;c.prototype._class+=" form_Form",c.prototype.publish("validate",!0,"boolean","Enable/Disable input validation"),c.prototype.publish("inputs",[],"widgetArray","Array of input widgets",null,{render:!1}),c.prototype.publish("showSubmit",!0,"boolean","Show Submit/Cancel Controls"),c.prototype.publish("omitBlank",!1,"boolean","Drop Blank Fields From Submit"),c.prototype.publish("allowEmptyRequest",!1,"boolean","Allow Blank Form to be Submitted");const d=class _Input extends n.HTMLWidget{_inputElement=[];_labelElement=[];constructor(){super(),e.IInput.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){}};s(d,"Input");let m=d;m.prototype._class+=" form_Input",m.prototype.implements(e.IInput.prototype),m.prototype.publish("type","text","set","Input type",["string","number","boolean","date","time","hidden","nested","button","checkbox","text","textarea","search","email","datetime"]),m.prototype.publish("inlineLabel",null,"string","Input Label",null,{optional:!0});const f=class _FieldForm extends c{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 m).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}};s(f,"FieldForm");let g=f;g.prototype._class+=" form_FieldForm";const y=class _InputRange extends n.HTMLWidget{_inputElement=[];_labelElement=[];_rangeData=[];constructor(){super(),e.IInput.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)}};s(y,"InputRange");let b=y;b.prototype._class+=" form_InputRange",b.prototype.implements(e.IInput.prototype),b.prototype.publish("type","text","set","InputRange type",["number","date","text","time","datetime","hidden"]),b.prototype.publish("inlineLabel",null,"string","InputRange Label",null,{optional:!0}),b.prototype.publish("value",["",""],"array","Input Current Value",null,{override:!0});const _=class _OnOff extends n.HTMLWidget{_inputElement=[];_input;constructor(){super(),e.IInput.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())}};s(_,"OnOff");let v=_;v.prototype._class+=" form_OnOff",v.prototype.implements(e.IInput.prototype),v.prototype.publish("marginLeft",0,"number","Margin left of OnOff"),v.prototype.publish("marginBottom",0,"number","Margin bottom of OnOff"),v.prototype.publish("minWidth",100,"number","Minimum width of OnOff (pixels)"),v.prototype.publish("minHeight",20,"number","Minimum height of OnOff (pixels)"),v.prototype.publish("gutter",1,"number","Space between switch and border of OnOff (pixels)"),v.prototype.publish("onText","Save","string","Text to display when 'ON'"),v.prototype.publish("offText","Properties","string","Text to display when 'OFF'"),v.prototype.publish("switchRadius",10,"number","Border radius of switch (pixels)"),v.prototype.publish("containerRadius",10,"number","Border radius of OnOff (pixels)"),v.prototype.publish("onColor","#2ecc71","html-color","Background color when 'ON'"),v.prototype.publish("offColor","#ecf0f1","html-color","Background color when 'OFF'"),v.prototype.publish("onFontColor","#2c3e50","html-color","Font color when 'ON'"),v.prototype.publish("offFontColor","#7f8c8d","html-color","Font color when 'OFF'");const x=class _Radio extends n.HTMLWidget{_inputElement=[];constructor(){super(),e.IInput.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)})}};s(x,"Radio");let E=x;E.prototype._class+=" form_Radio",E.prototype.implements(e.IInput.prototype),E.prototype.publish("selectOptions",[],"array","Array of options used to fill a dropdown list");const k=class _Range extends n.HTMLWidget{_inputElement=[];constructor(){super(),e.IInput.call(this),this._tag="div"}enter(t,e){super.enter(t,e);const i=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",i.name()),t.on("click",function(t){t.click(t)}),t.on("blur",function(t){t.blur(t)}),t.on("change",function(t){0===e?(i._inputElement[1].property("value",n.rgb(i._inputElement[0].property("value")).toString()),i.value(i._inputElement[0].property("value"))):(i._inputElement[0].property("value",i._inputElement[1].property("value")),i.value(n.rgb(i._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)}};s(k,"Range");let w=k;w.prototype._class+=" form_Range",w.prototype.implements(e.IInput.prototype),w.prototype.publish("type","text","set","Input type",["html-color","number","checkbox","button","select","textarea","date","text","range","search","email","time","datetime"]),w.prototype.publish("selectOptions",[],"array","Array of options used to fill a dropdown list"),w.prototype.publish("low",null,"number","Minimum value for Range input"),w.prototype.publish("high",null,"number","Maximum value for Range input"),w.prototype.publish("step",null,"number","Step value for Range input");const S=class _Select extends n.HTMLWidget{_inputElement=[];constructor(){super(),e.IInput.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)}};s(S,"Select");let I=S;I.prototype._class+=" form_Select",I.prototype.implements(e.IInput.prototype),I.prototype.publish("selectOptions",[],"array","Array of options used to fill a dropdown list"),I.prototype.publish("maxWidth",120,"number","Width",null,{optional:!0});const R=class _Slider extends n.SVGWidget{xScale;moveMode;moveStartPos;prevValue;slider;handleLeft;handleLeftPos=0;handleLeftStartPos;handleRight;handleRightPos=0;handleRightStartPos;constructor(){super(),e.IInput.call(this)}enter(t,e){if(super.enter(t,e),this.resize({width:this.width(),height:50}),this.xScale=n.scaleLinear().clamp(!0),this.slider=e.append("g").attr("class","slider"),null===this.low()&&null===this.high()&&null!==this.lowDatetime()&&null!==this.highDatetime()){const t=n.timeParse(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(n.drag().on("start",()=>{const t=n.d3Event();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(n.d3Event().x)}).on("end",()=>{this.moveHandleTo(n.d3Event().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 i=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 s=(this.width()-2*this.padding())/(this.tickCount()-1),o=[];if(null!==this.tickDateFormat()&&null!==this.timePattern()){const t=n.timeParse("%Q"),e=n.timeFormat(this.tickDateFormat()),i=(this.high()-this.low())/(this.tickCount()-1);for(let n=0;n<this.tickCount();n++){const s=t(""+(this.low()+i*n));o.push(e(s))}}else{const t=n.format(this.tickValueFormat()),e=(this.high()-this.low())/(this.tickCount()-1);for(let n=0;n<this.tickCount();n++){const i=this.low()+e*n;o.push(t(i))}}const l=this.slider.selectAll("g.tick").data(o),a=l.enter().append("g").attr("class","tick");a.append("text").attr("class","tick-text"),a.append("line").attr("class","tick-line"),a.merge(l).each(function(t,e){const o=s*e;n.select(this).select("text.tick-text").style("font-size",i.fontSize()).attr("x",function(){return 0===e?o-2:e===i.tickCount()-1?o+2:o}).attr("y",i.tickHeight()+i.tickOffset()/2+i.fontSize()).attr("text-basline","text-before-edge").attr("text-anchor",function(){return 0===e?"start":e===i.tickCount()-1?"end":"middle"}).text(()=>t),n.select(this).select("line.tick-line").attr("x1",o).attr("x2",o).attr("y1",i.tickOffset()-1).attr("y2",i.tickOffset()+i.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=s(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")};s(R,"Slider");let P=R;P.prototype._class+=" form_Slider",P.prototype.implements(e.IInput.prototype),P.prototype.publish("padding",16,"number","Outer Padding",null,{tags:["Basic"]}),P.prototype.publish("fontSize",12,"number","Font Size",null,{tags:["Basic"]}),P.prototype.publish("fontFamily",null,"string","Font Name",null,{tags:["Basic"]}),P.prototype.publish("fontColor",null,"html-color","Font Color",null,{tags:["Basic"]}),P.prototype.publish("allowRange",!1,"boolean","Allow Range Selection",null,{tags:["Intermediate"]}),P.prototype.publish("low",null,"number","Low",null,{tags:["Intermediate"]}),P.prototype.publish("high",null,"number","High",null,{tags:["Intermediate"]}),P.prototype.publish("step",10,"number","Step",null,{tags:["Intermediate"]}),P.prototype.publish("lowDatetime",null,"string","Low",null,{tags:["Intermediate"]}),P.prototype.publish("highDatetime",null,"string","High",null,{tags:["Intermediate"]}),P.prototype.publish("selectionLabel","","string","Selection Label",null,{tags:["Intermediate"]}),P.prototype.publish("timePattern","%Y-%m-%d","string"),P.prototype.publish("tickCount",10,"number"),P.prototype.publish("tickOffset",5,"number"),P.prototype.publish("tickHeight",8,"number"),P.prototype.publish("tickDateFormat",null,"string"),P.prototype.publish("tickValueFormat",",.0f","string");const O=P.prototype.name;P.prototype.name=function(t){const e=O.apply(this,arguments);if(arguments.length){const e=t instanceof Array?t:[t];n.SVGWidget.prototype.columns.call(this,e)}return e};const L=P.prototype.value;P.prototype.value=function(t){const e=L.apply(this,arguments);return arguments.length?(n.SVGWidget.prototype.data.call(this,[this.allowRange()?t:[t,t]]),e):this.allowRange()?n.SVGWidget.prototype.data.call(this)[0]:n.SVGWidget.prototype.data.call(this)[0][0]};const C=class _TextArea extends m{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")}};s(C,"TextArea");let F=C;F.prototype._class+=" form_TextArea",F.prototype.publish("rows",null,"number","Rows",null,{optional:!0}),F.prototype.publish("cols",null,"number","Columns",null,{optional:!0}),F.prototype.publish("wrap","off","set","Wrap",["off","on"]),F.prototype.publish("minHeight",null,"number","Minimum Height",null,{optional:!0}),F.prototype.publish("spellcheck",null,"boolean","Input spell checking",{optional:!0}),t.BUILD_VERSION="3.24.0",t.Button=l,t.CheckBox=r,t.ColorInput=h,t.FieldForm=g,t.Form=c,t.Input=m,t.InputRange=b,t.OnOff=v,t.PKG_NAME="@hpcc-js/form",t.PKG_VERSION="3.4.8",t.Radio=E,t.Range=w,t.Select=I,t.Slider=P,t.TextArea=F,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@hpcc-js/api"),require("@hpcc-js/common")):typeof define==`function`&&define.amd?define([`exports`,`@hpcc-js/api`,`@hpcc-js/common`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`@hpcc-js/form`]={},e[`@hpcc-js/api`],e[`@hpcc-js/common`]))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=`@hpcc-js/form`,i=`3.5.0`,a=`3.26.0`,Button=class extends n.HTMLWidget{_inputElement=[];constructor(){super(),t.IInput.call(this),this._tag=`div`}enter(e,t){super.enter(e,t);let n=this;this._inputElement[0]=t.append(`button`).attr(`name`,this.name()).on(`click`,function(e){e.click(e)}).on(`blur`,function(e){e.blur(e)}).on(`change`,function(e){n.value([n._inputElement[0].property(`value`)]),e.change(e,!0)})}update(e,t){super.update(e,t),this._inputElement[0].text(this.value())}};Button.prototype._class+=` form_Button`,Button.prototype.implements(t.IInput.prototype);var CheckBox=class extends n.HTMLWidget{_inputElement=[];constructor(){super(),t.IInput.call(this),this._tag=`div`}enter(e,t){super.enter(e,t);let n=this,r=t.append(`ul`);this.selectOptions().length||this.selectOptions().push(``),this.selectOptions().forEach(function(e,t){n._inputElement[t]=r.append(`li`).append(`input`).attr(`type`,`checkbox`),n._inputElement[t].node().insertAdjacentHTML(`afterend`,`<text>`+e+`</text>`)}),this._inputElement.forEach(function(e,t){e.attr(`name`,n.name()),e.on(`click`,function(e){e.click(e)}),e.on(`blur`,function(e){e.blur(e)}),e.on(`change`,function(e){let t=[];n._inputElement.forEach(function(e){e.property(`checked`)&&t.push(e.property(`value`))}),n.value(t),e.change(e,!0)})})}update(e,t){super.update(e,t);let n=this;this._inputElement.forEach(function(e,t){e.property(`value`,n.selectOptions()[t]),n.value().indexOf(n.selectOptions()[t])!==-1&&n.value()!==`false`?e.property(`checked`,!0):e.property(`checked`,!1)})}insertSelectOptions(e){let t=``;e.length>0?e.forEach(function(e){let n=e instanceof Array?e[0]:e,r=e instanceof Array?e[1]?e[1]:e[0]:e;t+=`<option value='`+n+`'>`+r+`</option>`}):t+=`<option>selectOptions not set</option>`,this._inputElement[0].html(t)}};CheckBox.prototype._class+=` form_CheckBox`,CheckBox.prototype.implements(t.IInput.prototype),CheckBox.prototype.publish(`selectOptions`,[],`array`,`Array of options used to fill a dropdown list`);var ColorInput=class extends n.HTMLWidget{_inputElement=[];constructor(){super(),t.IInput.call(this),this._tag=`div`}enter(e,t){super.enter(e,t);let r=this;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){e.on(`click`,function(e){e.click(e)}),e.on(`blur`,function(e){e.blur(e)}),e.on(`change`,function(e){t===0?(r._inputElement[1].property(`value`,(0,n.rgb)(r._inputElement[0].property(`value`)).toString()),r.value(r._inputElement[0].property(`value`))):(r._inputElement[0].property(`value`,r._inputElement[1].property(`value`)),r.value((0,n.rgb)(r._inputElement[1].property(`value`)).toString())),e.change(e,!0)})})}update(e,t){super.update(e,t);let r=this;this._inputElement.forEach(function(e){e.attr(`name`,r.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`,(0,n.rgb)(this.value()).toString());let i=this._inputElement[0].node().getBoundingClientRect();this._inputElement[1].style(`height`,i.height-2+`px`)}};ColorInput.prototype._class+=` form_ColorInput`,ColorInput.prototype.implements(t.IInput.prototype);var Form=class extends n.HTMLWidget{tbody;tfoot;btntd;_controls;_maxCols;constructor(){super(),this._tag=`form`}data(e){if(arguments.length)this.inputsForEach(function(t,n){e&&e.length>n&&t.value(e[n]).render()});else{let e=[];return this.inputsForEach(function(t){e.push(t.value())}),e}return this}inputsForEach(e,t){let r=0;this.inputs().forEach(function(i){(i instanceof n.WidgetArray?i.content():[i]).forEach(function(n){t?e.call(t,n,r++):e(n,r++)})})}inputsMap(){let e={};return this.inputs().forEach(function(t){e[t.name()]=t}),e}calcMaxColumns(){let e=0;return this.inputs().forEach(function(t){let r=t instanceof n.WidgetArray?t.content():[t];r.length>e&&(e=r.length)}),e}values(e){if(arguments.length)this.inputsForEach(function(t){e[t.name()]?t.value(e[t.name()]):this.omitBlank()&&t.value(``)},this);else{let e={};return this.inputsForEach(function(t){let n=t.type?t.type():`text`;if(t.value()||!this.omitBlank())switch(n){case`checkbox`:e[t.name()]=t.value_exists()?!!t.value():void 0;break;case`number`:let n=t.value();e[t.name()]=n===``?void 0:+n;break;default:e[t.name()]=t.value_exists()?t.value():void 0;break}},this),e}return this}submit(){let e=!0;this.validate()&&(e=this.checkValidation()),!(!this.allowEmptyRequest()&&!this.inputs().some(function(e){return e._class.indexOf(`WidgetArray`)===-1?e.hasValue():e.content().some(function(e){return e.hasValue()})}))&&this.click(e?this.values():null,null,e)}clear(){this.inputsForEach(function(e){switch(e.classID()){case`form_Slider`:e.allowRange()?e.value([e.low(),e.low()]).render():e.value(e.low()).render();break;case`form_CheckBox`:e.value(!1).render();break;case`form_Button`:break;default:e.value(void 0).render();break}})}checkValidation(){let e=!0,t=[];return this.inputsForEach(function(e){e.isValid()||t.push(`'`+e.label()+`' value is invalid.`)}),t.length>0&&(alert(t.join(`
|
|
2
|
+
`)),e=!1),e}enter(e,t){super.enter(e,t),t.on(`submit`,function(){(0,n.d3Event)().preventDefault()}),this._placeholderElement.style(`overflow`,`auto`);let r=t.append(`table`);this.tbody=r.append(`tbody`),this.tfoot=r.append(`tfoot`),this.btntd=this.tfoot.append(`tr`).append(`td`).attr(`colspan`,2);let i=this;this._controls=[new Button().classed({default:!0}).value(`Submit`).on(`click`,function(){i.submit()},!0),new Button().value(`Clear`).on(`click`,function(){i.clear()},!0)];let a=i.btntd.append(`div`).style(`float`,`right`);this._controls.forEach(function(e){let t=a.append(`span`).style(`float`,`left`);e.target(t.node()).render()})}update(e,t){super.update(e,t),this._maxCols=this.calcMaxColumns();let r=this,i=this.tbody.selectAll(`tr`).data(this.inputs());i.enter().append(`tr`).each(function(e,t){let i=(0,n.select)(this),a=e instanceof n.WidgetArray?e.content():[e];a.forEach(function(e,t){i.append(`td`).attr(`class`,`prompt`);let o=i.append(`td`).attr(`class`,`input`);if(t===a.length-1&&a.length<r._maxCols&&o.attr(`colspan`,(r._maxCols-a.length+1)*2),e.target(o.node()).render(),e instanceof n.SVGWidget){let t=e.element().node().getBBox();o.style(`height`,t.height+`px`),e.resize().render()}e._inputElement instanceof Array&&e._inputElement.forEach(function(e){e.on(`keyup.form`,function(e){setTimeout(function(){r._controls[0].disable(!r.allowEmptyRequest()&&!r.inputs().some(function(e){return e._class.indexOf(`WidgetArray`)===-1?e.hasValue():e.content().some(function(e){return e.hasValue()})}))},100)})})})}).merge(i).each(function(e,t){let r=(0,n.select)(this);(e instanceof n.WidgetArray?e.content():[e]).forEach(function(e,t){r.select(`td.prompt`).text(e.label()+`:`)})}),i.each(function(e,t){t===0&&e.setFocus&&e.setFocus()}),i.exit().each(function(e,t){(e instanceof n.WidgetArray?e.content():[e]).forEach(function(e,t){e.target(null)})}).remove(),this.tfoot.style(`display`,this.showSubmit()?`table-footer-group`:`none`),this.btntd.attr(`colspan`,this._maxCols*2),this.allowEmptyRequest()||setTimeout(function(){r._controls[0].disable(!r.allowEmptyRequest()&&!r.inputs().some(function(e){return e._class.indexOf(`WidgetArray`)===-1?e.hasValue():e.content().some(function(e){return e.hasValue()})}))},100)}exit(e,t){this.inputsForEach(e=>e.target(null)),super.exit(e,t)}click(e,t,n){}};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`);var Input=class extends n.HTMLWidget{_inputElement=[];_labelElement=[];constructor(){super(),t.IInput.call(this),this._tag=`div`}checked(e){return arguments.length?(this._inputElement[0]&&this._inputElement[0].property(`checked`,e),this):this._inputElement[0]?this._inputElement[0].property(`checked`):!1}enter(e,t){super.enter(e,t),this._labelElement[0]=t.append(`label`).attr(`for`,this.id()+`_input`).style(`visibility`,this.inlineLabel_exists()?`visible`:`hidden`);let n=this;switch(this.type()){case`button`:this._inputElement[0]=t.append(`button`).attr(`id`,this.id()+`_input`);break;case`textarea`:this._inputElement[0]=t.append(`textarea`).attr(`id`,this.id()+`_input`);break;default:this._inputElement[0]=t.append(`input`).attr(`id`,this.id()+`_input`).attr(`type`,this.type());break}this._inputElement.forEach(function(e,t){e.attr(`name`,n.name()),e.on(`click`,function(e){e.click(e)}),e.on(`blur`,function(e){e.blur(e)}),e.on(`change`,function(t){n.value([e.property(`value`)]),t.change(t,!0)}),e.on(`keyup`,function(t){n.value([e.property(`value`)]),t.change(t,!1)})})}update(e,t){switch(super.update(e,t),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());break}}blur(e){}keyup(e){}focus(e){}click(e){}dblclick(e){}change(e,t){}};Input.prototype._class+=` form_Input`,Input.prototype.implements(t.IInput.prototype),Input.prototype.publish(`type`,`text`,`set`,`Input type`,[`string`,`number`,`boolean`,`date`,`time`,`hidden`,`nested`,`button`,`checkbox`,`text`,`textarea`,`search`,`email`,`datetime`]),Input.prototype.publish(`inlineLabel`,null,`string`,`Input Label`,null,{optional:!0});var FieldForm=class extends Form{constructor(){super(),this._tag=`form`}fields(e){let t=super.fields.apply(this,arguments);if(arguments.length){let t=this.inputsMap();this.inputs(e.map(e=>t[e.id()]||new Input().name(e.id()).label(e.label()).type(e.type())))}return t}data(e){if(!arguments.length)return super.data();if(super.data(e[0]),e[0]){let t=this.inputs(),n=e[0][this.columns().length],r=0;for(let e in n)t[r].name(e),++r}return this}};FieldForm.prototype._class+=` form_FieldForm`;var InputRange=class extends n.HTMLWidget{_inputElement=[];_labelElement=[];_rangeData=[];constructor(){super(),t.IInput.call(this),this._tag=`div`}enter(e,t){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()));let n=this;this._inputElement.forEach(function(e,t){e.attr(`name`,n.name()),e.on(`click`,function(e){e.click(e)}),e.on(`blur`,function(e){e.blur(e)}),e.on(`change`,function(r){n._rangeData[t]=e.property(`value`),n.value(n._rangeData),r.change(r,!0)})})}update(e,t){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){e.attr(`type`,this.type()).property(`value`,this._rangeData.length>t?this._rangeData[t]:``)},this)}};InputRange.prototype._class+=` form_InputRange`,InputRange.prototype.implements(t.IInput.prototype),InputRange.prototype.publish(`type`,`text`,`set`,`InputRange type`,[`number`,`date`,`text`,`time`,`datetime`,`hidden`]),InputRange.prototype.publish(`inlineLabel`,null,`string`,`InputRange Label`,null,{optional:!0}),InputRange.prototype.publish(`value`,[``,``],`array`,`Input Current Value`,null,{override:!0});var OnOff=class extends n.HTMLWidget{_inputElement=[];_input;constructor(){super(),t.IInput.call(this),this._tag=`div`}enter(e,t){super.enter(e,t),t.classed(`onoffswitch`,!0);let n=this;this._input=t.append(`input`).attr(`class`,`onoffswitch-checkbox`).attr(`type`,`checkbox`).attr(`id`,this.id()+`_onOff`).on(`click`,function(e){e.click(e)}).on(`blur`,function(e){e.blur(e)}).on(`change`,function(e){let t=[];n._inputElement.forEach(function(e,n){e.property(`checked`)&&t.push(e.property(`value`))}),n.value(t),e.change(e,!0)});let r=t.append(`label`).attr(`class`,`onoffswitch-label`).attr(`for`,this.id()+`_onOff`),i=r.append(`div`).attr(`class`,`onoffswitch-inner`);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`)}update(e,t){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`);let n=this.minHeight()-this.gutter()*4;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())}};OnOff.prototype._class+=` form_OnOff`,OnOff.prototype.implements(t.IInput.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'`);var Radio=class extends n.HTMLWidget{_inputElement=[];constructor(){super(),t.IInput.call(this),this._tag=`div`}enter(e,t){super.enter(e,t);let n=this,r=t.append(`ul`);this.selectOptions().length||this.selectOptions().push(``),this.selectOptions().forEach(function(e,t){n._inputElement[t]=r.append(`li`).append(`input`).attr(`type`,`radio`),n._inputElement[t].node().insertAdjacentHTML(`afterend`,`<text>`+e+`</text>`)}),this._inputElement.forEach(function(e,t){e.attr(`name`,n.name()),e.on(`click`,function(e){e.click(e)}),e.on(`blur`,function(e){e.blur(e)}),e.on(`change`,function(t){n.value([e.property(`value`)]),t.change(t,!0)})})}update(e,t){super.update(e,t);let n=this;this._inputElement.forEach(function(e,t){e.property(`value`,n.selectOptions()[t]),n.value().indexOf(n.selectOptions()[t])!==-1&&n.value()!==`false`?e.property(`checked`,!0):e.property(`checked`,!1)})}};Radio.prototype._class+=` form_Radio`,Radio.prototype.implements(t.IInput.prototype),Radio.prototype.publish(`selectOptions`,[],`array`,`Array of options used to fill a dropdown list`);var Range=class extends n.HTMLWidget{_inputElement=[];constructor(){super(),t.IInput.call(this),this._tag=`div`}enter(e,t){super.enter(e,t);let r=this;this._inputElement[0]=t.append(`input`).attr(`type`,`range`),this._inputElement[1]=t.append(`input`).attr(`type`,`number`),this._inputElement.forEach(function(e,t){e.attr(`name`,r.name()),e.on(`click`,function(e){e.click(e)}),e.on(`blur`,function(e){e.blur(e)}),e.on(`change`,function(e){t===0?(r._inputElement[1].property(`value`,(0,n.rgb)(r._inputElement[0].property(`value`)).toString()),r.value(r._inputElement[0].property(`value`))):(r._inputElement[0].property(`value`,r._inputElement[1].property(`value`)),r.value((0,n.rgb)(r._inputElement[1].property(`value`)).toString())),e.change(e,!0)})})}update(e,t){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())}insertSelectOptions(e){let t=``;e.length>0?e.forEach(function(e){let n=e instanceof Array?e[0]:e,r=e instanceof Array?e[1]?e[1]:e[0]:e;t+=`<option value='`+n+`'>`+r+`</option>`}):t+=`<option>selectOptions not set</option>`,this._inputElement[0].html(t)}};Range.prototype._class+=` form_Range`,Range.prototype.implements(t.IInput.prototype),Range.prototype.publish(`type`,`text`,`set`,`Input type`,[`html-color`,`number`,`checkbox`,`button`,`select`,`textarea`,`date`,`text`,`range`,`search`,`email`,`time`,`datetime`]),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`);var Select=class extends n.HTMLWidget{_inputElement=[];constructor(){super(),t.IInput.call(this),this._tag=`div`}enter(e,t){super.enter(e,t);let n=this;this._inputElement[0]=t.append(`select`).attr(`name`,this.name()).on(`click`,function(e){e.click(e)}).on(`blur`,function(e){e.blur(e)}).on(`change`,function(e){n.value([n._inputElement[0].property(`value`)]),e.change(e,!0)})}update(e,t){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)}insertSelectOptions(e){let t=``;e.length>0?e.forEach(function(e){let n=e instanceof Array?e[0]:e,r=e instanceof Array?e[1]?e[1]:e[0]:e;t+=`<option value='`+n+`'>`+r+`</option>`}):t+=`<option>selectOptions not set</option>`,this._inputElement[0].html(t)}};Select.prototype._class+=` form_Select`,Select.prototype.implements(t.IInput.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});var Slider=class extends n.SVGWidget{xScale;moveMode;moveStartPos;prevValue;slider;handleLeft;handleLeftPos=0;handleLeftStartPos;handleRight;handleRightPos=0;handleRightStartPos;constructor(){super(),t.IInput.call(this)}enter(e,t){if(super.enter(e,t),this.resize({width:this.width(),height:50}),this.xScale=(0,n.scaleLinear)().clamp(!0),this.slider=t.append(`g`).attr(`class`,`slider`),this.low()===null&&this.high()===null&&this.lowDatetime()!==null&&this.highDatetime()!==null){let e=(0,n.timeParse)(this.timePattern()?this.timePattern():`%Q`);this.low(e(this.lowDatetime()).getTime()),this.high(e(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((0,n.drag)().on(`start`,()=>{let e=(0,n.d3Event)();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)}).on(`drag`,()=>{this.moveHandleTo((0,n.d3Event)().x)}).on(`end`,()=>{this.moveHandleTo((0,n.d3Event)().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(e,t){super.update(e,t);let r=this;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]);let i=(this.width()-this.padding()*2)/(this.tickCount()-1),a=[];if(this.tickDateFormat()!==null&&this.timePattern()!==null){let e=(0,n.timeParse)(`%Q`),t=(0,n.timeFormat)(this.tickDateFormat()),r=(this.high()-this.low())/(this.tickCount()-1);for(let n=0;n<this.tickCount();n++){let i=e(``+(this.low()+r*n));a.push(t(i))}}else{let e=(0,n.format)(this.tickValueFormat()),t=(this.high()-this.low())/(this.tickCount()-1);for(let n=0;n<this.tickCount();n++){let r=this.low()+t*n;a.push(e(r))}}let o=this.slider.selectAll(`g.tick`).data(a),s=o.enter().append(`g`).attr(`class`,`tick`);s.append(`text`).attr(`class`,`tick-text`),s.append(`line`).attr(`class`,`tick-line`),s.merge(o).each(function(e,t){let a=i*t;(0,n.select)(this).select(`text.tick-text`).style(`font-size`,r.fontSize()).attr(`x`,function(){return t===0?a-2:t===r.tickCount()-1?a+2:a}).attr(`y`,r.tickHeight()+r.tickOffset()/2+r.fontSize()).attr(`text-basline`,`text-before-edge`).attr(`text-anchor`,function(){return t===0?`start`:t===r.tickCount()-1?`end`:`middle`}).text(()=>e),(0,n.select)(this).select(`line.tick-line`).attr(`x1`,a).attr(`x2`,a).attr(`y1`,r.tickOffset()-1).attr(`y2`,r.tickOffset()+r.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()&&this.prevValue!==void 0&&this.change(this),this.prevValue=this.value()}updateHandles(){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`))}lowPos(){let e=[[this.low(),this.high()]];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])}highPos(){let e=[[this.low(),this.high()]];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()])}moveHandleTo(e){if(this.allowRange())switch(this.moveMode){case`both`:this.handleLeftPos=this.handleLeftStartPos+e-this.moveStartPos,this.handleRightPos=this.handleRightStartPos+e-this.moveStartPos;break;case`left`:this.handleLeftPos=e,this.handleLeftPos>this.handleRightPos&&(this.handleRightPos=this.handleLeftPos);break;case`right`:this.handleRightPos=e,this.handleRightPos<this.handleLeftPos&&(this.handleLeftPos=this.handleRightPos);break}else this.handleLeftPos=this.handleRightPos=e;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(e){let t=this.xScale.range();return e<t[0]&&(e=t[0]),e>t[1]&&(e=t[1]),this.nearestStep(e)}nearestStep(e){let t=this.xScale.invert(e);return this.xScale(this.low()+Math.round((t-this.low())/this.step())*this.step())}handlePath=function(e){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`;return this.allowRange()?i+=`ZM`+2.5*n+`,26V28M`+4.5*n+`,26V28`:i+=`M`+1*n+`,26V28`,i}};Slider.prototype._class+=` form_Slider`,Slider.prototype.implements(t.IInput.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`);var o=Slider.prototype.name;Slider.prototype.name=function(e){let t=o.apply(this,arguments);if(arguments.length){let t=e instanceof Array?e:[e];n.SVGWidget.prototype.columns.call(this,t)}return t};var s=Slider.prototype.value;Slider.prototype.value=function(e){let t=s.apply(this,arguments);if(arguments.length)n.SVGWidget.prototype.data.call(this,[this.allowRange()?e:[e,e]]);else return this.allowRange()?n.SVGWidget.prototype.data.call(this)[0]:n.SVGWidget.prototype.data.call(this)[0][0];return t};var TextArea=class extends Input{constructor(){super(),this._tag=`div`,this.type(`textarea`)}enter(e,t){super.enter(e,t)}calcHeight(){return Math.max(this.minHeight_exists()?this.minHeight():0,this.height())}update(e,t){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`)}};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}),e.BUILD_VERSION=a,e.Button=Button,e.CheckBox=CheckBox,e.ColorInput=ColorInput,e.FieldForm=FieldForm,e.Form=Form,e.Input=Input,e.InputRange=InputRange,e.OnOff=OnOff,e.PKG_NAME=r,e.PKG_VERSION=i,e.Radio=Radio,e.Range=Range,e.Select=Select,e.Slider=Slider,e.TextArea=TextArea});
|
|
2
3
|
//# sourceMappingURL=index.umd.cjs.map
|
|
3
|
-
|
|
4
|
+
(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)}})();
|