@hpcc-js/form 3.3.9 → 3.4.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/LICENSE CHANGED
@@ -1,43 +1,43 @@
1
- HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
-
7
- http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
14
-
15
-
16
- Intersection Algorithms Provided by Kevin Lindsey
17
- Copyright (c) 2000-2011, Kevin Lindsey
18
- All rights reserved.
19
-
20
- Redistribution and use in source and binary forms, with or without
21
- modification, are permitted provided that the following conditions are met:
22
-
23
- - Redistributions of source code must retain the above copyright notice,
24
- this list of conditions and the following disclaimer.
25
-
26
- - Redistributions in binary form must reproduce the above copyright
27
- notice, this list of conditions and the following disclaimer in the
28
- documentation and/or other materials provided with the distribution.
29
-
30
- - Neither the name of this software nor the names of its contributors
31
- may be used to endorse or promote products derived from this software
32
- without specific prior written permission.
33
-
34
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
35
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
36
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
38
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
39
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
40
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
41
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
42
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
43
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1
+ HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
15
+
16
+ Intersection Algorithms Provided by Kevin Lindsey
17
+ Copyright (c) 2000-2011, Kevin Lindsey
18
+ All rights reserved.
19
+
20
+ Redistribution and use in source and binary forms, with or without
21
+ modification, are permitted provided that the following conditions are met:
22
+
23
+ - Redistributions of source code must retain the above copyright notice,
24
+ this list of conditions and the following disclaimer.
25
+
26
+ - Redistributions in binary form must reproduce the above copyright
27
+ notice, this list of conditions and the following disclaimer in the
28
+ documentation and/or other materials provided with the distribution.
29
+
30
+ - Neither the name of this software nor the names of its contributors
31
+ may be used to endorse or promote products derived from this software
32
+ without specific prior written permission.
33
+
34
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
35
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
36
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
38
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
39
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
40
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
41
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
42
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
43
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
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.3.9",y="3.19.3",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
+ 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.0",y="3.21.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};
2
2
  //# sourceMappingURL=index.js.map
3
3
  !function(){"use strict";try{if("undefined"!=typeof document){var o=document.createElement("style");o.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]{width:100%;box-sizing:border-box;display:block}.form_Input ul{list-style-type:none;float:left;padding:0;margin:0}.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{padding:2px;vertical-align:middle;background-color:#e5e5e5}.form_Form td.input{padding:2px;width:100%;vertical-align:middle}.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{background-position:-1px -1px;box-sizing:border-box;color:#24292e;cursor:pointer;height:28px;inset:0;overflow-wrap:break-word;position:relative;text-decoration:none solid rgb(36,41,46);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,#eff3f6 90%) repeat-x scroll -1px -1px / 110% 110% padding-box border-box;border:1px solid rgba(27,31,35,.2);border-radius:3px;outline:rgb(36,41,46) none 0px;padding:3px 10px}.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;text-decoration:none solid rgb(255,255,255);word-wrap:break-word;column-rule-color:#fff;perspective-origin:44.975px 17px;transform-origin:44.975px 17px;background:#28a745 linear-gradient(-180deg,#34d058,#28a745 90%) repeat-x scroll -1px -1px / 110% 110% padding-box border-box;outline:rgb(255,255,255) none 0px}.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{position:relative;height:20px;width:100px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.onoffswitch-label{display:block;overflow:hidden;cursor:pointer;border:1px solid #999999;height:20px}.onoffswitch-inner{position:relative;display:block;transition:margin .3s ease-in 0s}.onoffswitch-inner>.onoffswitch-offText,.onoffswitch-inner>.onoffswitch-onText{height:100%}.onoffswitch-inner>.onoffswitch-offText{font-weight:700;position:absolute;right:0;transition:all .3s ease-in 0s;width:100%;text-align:right}.onoffswitch-inner>.onoffswitch-onText{font-weight:700;position:absolute;left:-100%;transition:all .3s ease-in 0s;width:100%;text-align:left}.onoffswitch-switch{display:block;width:20px;margin:-1px;background:#fff;position:absolute;border:1px solid #999999;transition:all .3s ease-in 0s;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:transparent;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}")),document.head.appendChild(o)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();