@hpcc-js/form 2.12.0 → 3.1.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 +227 -1288
- package/dist/index.js.map +7 -1
- package/package.json +31 -34
- package/src/Button.ts +11 -10
- package/src/CheckBox.ts +21 -13
- package/src/ColorInput.ts +16 -10
- package/src/FieldForm.ts +2 -2
- package/src/Form.ts +20 -13
- package/src/Input.ts +39 -24
- package/src/InputRange.ts +24 -15
- package/src/OnOff.ts +15 -10
- package/src/Radio.ts +21 -13
- package/src/Range.ts +33 -21
- package/src/Select.ts +24 -15
- package/src/Slider.ts +7 -3
- package/src/TextArea.ts +19 -12
- package/src/__package__.ts +2 -2
- package/src/index.ts +14 -14
- package/types/Button.d.ts +10 -21
- package/types/CheckBox.d.ts +17 -26
- package/types/ColorInput.d.ts +14 -21
- package/types/FieldForm.d.ts +1 -2
- package/types/Form.d.ts +18 -27
- package/types/Input.d.ts +28 -42
- package/types/InputRange.d.ts +20 -31
- package/types/OnOff.d.ts +12 -21
- package/types/Radio.d.ts +17 -26
- package/types/Range.d.ts +29 -46
- package/types/Select.d.ts +20 -31
- package/types/Slider.d.ts +3 -3
- package/types/TextArea.d.ts +18 -31
- package/types/__package__.d.ts +2 -3
- package/types/index.d.ts +14 -15
- package/dist/index.es6.js +0 -1271
- package/dist/index.es6.js.map +0 -1
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
- package/types/Button.d.ts.map +0 -1
- package/types/CheckBox.d.ts.map +0 -1
- package/types/ColorInput.d.ts.map +0 -1
- package/types/FieldForm.d.ts.map +0 -1
- package/types/Form.d.ts.map +0 -1
- package/types/Input.d.ts.map +0 -1
- package/types/InputRange.d.ts.map +0 -1
- package/types/OnOff.d.ts.map +0 -1
- package/types/Radio.d.ts.map +0 -1
- package/types/Range.d.ts.map +0 -1
- package/types/Select.d.ts.map +0 -1
- package/types/Slider.d.ts.map +0 -1
- package/types/TextArea.d.ts.map +0 -1
- package/types/__package__.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types-3.4/Button.d.ts +0 -29
- package/types-3.4/CheckBox.d.ts +0 -35
- package/types-3.4/ColorInput.d.ts +0 -29
- package/types-3.4/FieldForm.d.ts +0 -11
- package/types-3.4/Form.d.ts +0 -53
- package/types-3.4/Input.d.ts +0 -51
- package/types-3.4/InputRange.d.ts +0 -41
- package/types-3.4/OnOff.d.ts +0 -58
- package/types-3.4/Radio.d.ts +0 -34
- package/types-3.4/Range.d.ts +0 -55
- package/types-3.4/Select.d.ts +0 -40
- package/types-3.4/Slider.d.ts +0 -86
- package/types-3.4/TextArea.d.ts +0 -37
- package/types-3.4/__package__.d.ts +0 -4
- package/types-3.4/index.d.ts +0 -15
package/dist/index.js
CHANGED
|
@@ -1,1291 +1,230 @@
|
|
|
1
|
-
(function (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
var J=Object.defineProperty;var l=(a,i)=>J(a,"name",{value:i,configurable:!0});var mt="@hpcc-js/form",ft="3.1.0",bt="3.2.0";import{IInput as T}from"@hpcc-js/api";import{HTMLWidget as K}from"@hpcc-js/common";(function(){if(!document.getElementById("96f7b713")){var a=document.createElement("style");a.id="96f7b713",a.textContent=`.form_Input input,
|
|
2
|
+
.form_Input select,
|
|
3
|
+
.form_Input button,
|
|
4
|
+
.form_Input textarea{
|
|
5
|
+
padding:2px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.form_Input button{
|
|
9
|
+
cursor:pointer;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.form_Input input.color-text{
|
|
13
|
+
width:120px;
|
|
14
|
+
}
|
|
15
|
+
.form_Input input.color-text+input{
|
|
16
|
+
width:57px;
|
|
17
|
+
position:absolute;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.form_Input textarea{
|
|
21
|
+
width:100%;
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
display:block;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.form_Input input[type="textbox"]{
|
|
27
|
+
width:100%;
|
|
28
|
+
box-sizing: border-box;
|
|
29
|
+
display:block;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.form_Input ul {
|
|
33
|
+
list-style-type: none;
|
|
34
|
+
float: left;
|
|
35
|
+
padding: 0px;
|
|
36
|
+
margin: 0px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.form_Input li {
|
|
40
|
+
float: left;
|
|
41
|
+
list-style-position: inside
|
|
42
|
+
}`,document.head.appendChild(a)}})();var x=class extends K{static{l(this,"Button")}_inputElement=[];constructor(){super(),T.call(this),this._tag="div"}enter(i,e){super.enter(i,e);let t=this;this._inputElement[0]=e.append("button").attr("name",this.name()).on("click",function(n){n.click(n)}).on("blur",function(n){n.blur(n)}).on("change",function(n){t.value([t._inputElement[0].property("value")]),n.change(n,!0)})}update(i,e){super.update(i,e),this._inputElement[0].text(this.value())}};x.prototype._class+=" form_Button";x.prototype.implements(T.prototype);import{IInput as B}from"@hpcc-js/api";import{HTMLWidget as U}from"@hpcc-js/common";var w=class extends U{static{l(this,"CheckBox")}_inputElement=[];constructor(){super(),B.call(this),this._tag="div"}enter(i,e){super.enter(i,e);let t=this,n=e.append("ul");this.selectOptions().length||this.selectOptions().push(""),this.selectOptions().forEach(function(o,s){t._inputElement[s]=n.append("li").append("input").attr("type","checkbox"),t._inputElement[s].node().insertAdjacentHTML("afterend","<text>"+o+"</text>")}),this._inputElement.forEach(function(o,s){o.attr("name",t.name()),o.on("click",function(r){r.click(r)}),o.on("blur",function(r){r.blur(r)}),o.on("change",function(r){let u=[];t._inputElement.forEach(function(h){h.property("checked")&&u.push(h.property("value"))}),t.value(u),r.change(r,!0)})})}update(i,e){super.update(i,e);let t=this;this._inputElement.forEach(function(n,o){n.property("value",t.selectOptions()[o]),t.value().indexOf(t.selectOptions()[o])!==-1&&t.value()!=="false"?n.property("checked",!0):n.property("checked",!1)})}insertSelectOptions(i){let e="";i.length>0?i.forEach(function(t){let n=t instanceof Array?t[0]:t,o=t instanceof Array?t[1]?t[1]:t[0]:t;e+="<option value='"+n+"'>"+o+"</option>"}):e+="<option>selectOptions not set</option>",this._inputElement[0].html(e)}};w.prototype._class+=" form_CheckBox";w.prototype.implements(B.prototype);w.prototype.publish("selectOptions",[],"array","Array of options used to fill a dropdown list");import{IInput as H}from"@hpcc-js/api";import{HTMLWidget as Y}from"@hpcc-js/common";import{rgb as R}from"@hpcc-js/common";var L=class extends Y{static{l(this,"ColorInput")}_inputElement=[];constructor(){super(),H.call(this),this._tag="div"}enter(i,e){super.enter(i,e);let t=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(n,o){n.on("click",function(s){s.click(s)}),n.on("blur",function(s){s.blur(s)}),n.on("change",function(s){o===0?(t._inputElement[1].property("value",R(t._inputElement[0].property("value")).toString()),t.value(t._inputElement[0].property("value"))):(t._inputElement[0].property("value",t._inputElement[1].property("value")),t.value(R(t._inputElement[1].property("value")).toString())),s.change(s,!0)})})}update(i,e){super.update(i,e);let t=this;this._inputElement.forEach(function(o){o.attr("name",t.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",R(this.value()).toString());let n=this._inputElement[0].node().getBoundingClientRect();this._inputElement[1].style("height",n.height-2+"px")}};L.prototype._class+=" form_ColorInput";L.prototype.implements(H.prototype);import{d3Event as Z,HTMLWidget as X,select as M,SVGWidget as tt,WidgetArray as E}from"@hpcc-js/common";(function(){if(!document.getElementById("9fa54847")){var a=document.createElement("style");a.id="9fa54847",a.textContent=`.form_Form {
|
|
43
|
+
color:#404040;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.form_Form tbody td {
|
|
47
|
+
white-space: nowrap;
|
|
48
|
+
border:1px solid #E5E5E5;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.form_Form td.prompt {
|
|
52
|
+
padding:2px;
|
|
53
|
+
vertical-align:middle;
|
|
54
|
+
background-color:#E5E5E5;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.form_Form td.input {
|
|
58
|
+
padding:2px;
|
|
59
|
+
width:100%;
|
|
60
|
+
vertical-align:middle;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.form_Form td.input .common_HTMLWidget ul{
|
|
64
|
+
margin:0px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.form_Form tfoot button{
|
|
68
|
+
margin:5px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.form_Form tbody tr:hover {
|
|
72
|
+
background-color:#FAFAFA;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.form_Form .form_Button button {
|
|
76
|
+
background-position: -1px -1px;
|
|
77
|
+
bottom: 0px;
|
|
78
|
+
box-sizing: border-box;
|
|
79
|
+
color: rgb(36, 41, 46);
|
|
80
|
+
cursor: pointer;
|
|
81
|
+
height: 28px;
|
|
82
|
+
left: 0px;
|
|
83
|
+
overflow-wrap: break-word;
|
|
84
|
+
position: relative;
|
|
85
|
+
right: 0px;
|
|
86
|
+
text-decoration: none solid rgb(36, 41, 46);
|
|
87
|
+
top: 0px;
|
|
88
|
+
vertical-align: middle;
|
|
89
|
+
white-space: nowrap;
|
|
90
|
+
word-wrap: break-word;
|
|
91
|
+
column-rule-color: rgb(36, 41, 46);
|
|
92
|
+
perspective-origin: 57.2938px 14px;
|
|
93
|
+
transform-origin: 57.2938px 14px;
|
|
94
|
+
user-select: none;
|
|
95
|
+
background: rgb(239, 243, 246) linear-gradient(-180deg, rgb(250, 251, 252) 0%, rgb(239, 243, 246) 90%) repeat-x scroll -1px -1px / 110% 110% padding-box border-box;
|
|
96
|
+
border: 1px solid rgba(27, 31, 35, 0.2);
|
|
97
|
+
border-radius: 3px 3px 3px 3px;
|
|
98
|
+
outline: rgb(36, 41, 46) none 0px;
|
|
99
|
+
padding: 3px 10px;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.form_Form .form_Button button[disabled="disabled"] {
|
|
103
|
+
background: rgb(219, 223, 226);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.form_Form .form_Button button:focus {
|
|
107
|
+
box-shadow: 0 0 0 0.2em rgba(3,102,214,0.3)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.form_Form .form_Button button:hover {
|
|
111
|
+
background: rgb(219, 223, 226);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.form_Form .form_Button.default button {
|
|
115
|
+
color: rgb(255, 255, 255);
|
|
116
|
+
text-decoration: none solid rgb(255, 255, 255);
|
|
117
|
+
word-wrap: break-word;
|
|
118
|
+
column-rule-color: rgb(255, 255, 255);
|
|
119
|
+
perspective-origin: 44.975px 17px;
|
|
120
|
+
transform-origin: 44.975px 17px;
|
|
121
|
+
background: rgb(40, 167, 69) linear-gradient(-180deg, rgb(52, 208, 88) 0%, rgb(40, 167, 69) 90%) repeat-x scroll -1px -1px / 110% 110% padding-box border-box;
|
|
122
|
+
outline: rgb(255, 255, 255) none 0px;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.form_Form .form_Button.default button[disabled="disabled"],
|
|
126
|
+
.form_Form .form_Button.default button[disabled="disabled"]:hover {
|
|
127
|
+
background: rgb(219, 223, 226);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.form_Form .form_Button.default button:hover {
|
|
131
|
+
background: rgb(20, 147, 49);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
`,document.head.appendChild(a)}})();var m=class extends X{static{l(this,"Form")}tbody;tfoot;btntd;_controls;_maxCols;constructor(){super(),this._tag="form"}data(i){if(arguments.length)this.inputsForEach(function(e,t){i&&i.length>t&&e.value(i[t]).render()});else{let e=[];return this.inputsForEach(function(t){e.push(t.value())}),e}return this}inputsForEach(i,e){let t=0;this.inputs().forEach(function(n){(n instanceof E?n.content():[n]).forEach(function(s){e?i.call(e,s,t++):i(s,t++)})})}inputsMap(){let i={};return this.inputs().forEach(function(e){i[e.name()]=e}),i}calcMaxColumns(){let i=0;return this.inputs().forEach(function(e){let t=e instanceof E?e.content():[e];t.length>i&&(i=t.length)}),i}values(i){if(arguments.length)this.inputsForEach(function(e){i[e.name()]?e.value(i[e.name()]):this.omitBlank()&&e.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 s=t.value();e[t.name()]=s===""?void 0:+s;break;case"text":default:e[t.name()]=t.value_exists()?t.value():void 0;break}},this),e}return this}submit(){let i=!0;this.validate()&&(i=this.checkValidation()),!(!this.allowEmptyRequest()&&!this.inputs().some(function(e){return e._class.indexOf("WidgetArray")!==-1?e.content().some(function(t){return t.hasValue()}):e.hasValue()}))&&this.click(i?this.values():null,null,i)}clear(){this.inputsForEach(function(i){switch(i.classID()){case"form_Slider":i.allowRange()?i.value([i.low(),i.low()]).render():i.value(i.low()).render();break;case"form_CheckBox":i.value(!1).render();break;case"form_Button":break;default:i.value(void 0).render();break}})}checkValidation(){let i=!0,e=[];return this.inputsForEach(function(t){t.isValid()||e.push("'"+t.label()+"' value is invalid.")}),e.length>0&&(alert(e.join(`
|
|
135
|
+
`)),i=!1),i}enter(i,e){super.enter(i,e),e.on("submit",function(){Z().preventDefault()}),this._placeholderElement.style("overflow","auto");let t=e.append("table");this.tbody=t.append("tbody"),this.tfoot=t.append("tfoot"),this.btntd=this.tfoot.append("tr").append("td").attr("colspan",2);let n=this;this._controls=[new x().classed({default:!0}).value("Submit").on("click",function(){n.submit()},!0),new x().value("Clear").on("click",function(){n.clear()},!0)];let o=n.btntd.append("div").style("float","right");this._controls.forEach(function(s){let r=o.append("span").style("float","left");s.target(r.node()).render()})}update(i,e){super.update(i,e),this._maxCols=this.calcMaxColumns();let t=this,n=this.tbody.selectAll("tr").data(this.inputs());n.enter().append("tr").each(function(o,s){let r=M(this),u=o instanceof E?o.content():[o];u.forEach(function(h,d){r.append("td").attr("class","prompt");let b=r.append("td").attr("class","input");if(d===u.length-1&&u.length<t._maxCols&&b.attr("colspan",(t._maxCols-u.length+1)*2),h.target(b.node()).render(),h instanceof tt){let k=h.element().node().getBBox();b.style("height",k.height+"px"),h.resize().render()}h._inputElement instanceof Array&&h._inputElement.forEach(function(k){k.on("keyup.form",function(P){setTimeout(function(){t._controls[0].disable(!t.allowEmptyRequest()&&!t.inputs().some(function(O){return O._class.indexOf("WidgetArray")!==-1?O.content().some(function(Q){return Q.hasValue()}):O.hasValue()}))},100)})})})}).merge(n).each(function(o,s){let r=M(this);(o instanceof E?o.content():[o]).forEach(function(h,d){r.select("td.prompt").text(h.label()+":")})}),n.each(function(o,s){s===0&&o.setFocus&&o.setFocus()}),n.exit().each(function(o,s){(o instanceof E?o.content():[o]).forEach(function(u,h){u.target(null)})}).remove(),this.tfoot.style("display",this.showSubmit()?"table-footer-group":"none"),this.btntd.attr("colspan",this._maxCols*2),this.allowEmptyRequest()||setTimeout(function(){t._controls[0].disable(!t.allowEmptyRequest()&&!t.inputs().some(function(o){return o._class.indexOf("WidgetArray")!==-1?o.content().some(function(s){return s.hasValue()}):o.hasValue()}))},100)}exit(i,e){this.inputsForEach(t=>t.target(null)),super.exit(i,e)}click(i,e,t){}};m.prototype._class+=" form_Form";m.prototype.publish("validate",!0,"boolean","Enable/Disable input validation");m.prototype.publish("inputs",[],"widgetArray","Array of input widgets",null,{render:!1});m.prototype.publish("showSubmit",!0,"boolean","Show Submit/Cancel Controls");m.prototype.publish("omitBlank",!1,"boolean","Drop Blank Fields From Submit");m.prototype.publish("allowEmptyRequest",!1,"boolean","Allow Blank Form to be Submitted");import{IInput as A}from"@hpcc-js/api";import{HTMLWidget as et}from"@hpcc-js/common";var f=class extends et{static{l(this,"Input")}_inputElement=[];_labelElement=[];constructor(){super(),A.call(this),this._tag="div"}checked(i){return arguments.length?(this._inputElement[0]&&this._inputElement[0].property("checked",i),this):this._inputElement[0]?this._inputElement[0].property("checked"):!1}enter(i,e){super.enter(i,e),this._labelElement[0]=e.append("label").attr("for",this.id()+"_input").style("visibility",this.inlineLabel_exists()?"visible":"hidden");let t=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());break}this._inputElement.forEach(function(n,o){n.attr("name",t.name()),n.on("click",function(s){s.click(s)}),n.on("blur",function(s){s.blur(s)}),n.on("change",function(s){t.value([n.property("value")]),s.change(s,!0)}),n.on("keyup",function(s){t.value([n.property("value")]),s.change(s,!1)})})}update(i,e){switch(super.update(i,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());break}}blur(i){}keyup(i){}focus(i){}click(i){}dblclick(i){}change(i,e){}};f.prototype._class+=" form_Input";f.prototype.implements(A.prototype);f.prototype.publish("type","text","set","Input type",["string","number","boolean","date","time","hidden","nested","button","checkbox","text","textarea","search","email","datetime"]);f.prototype.publish("inlineLabel",null,"string","Input Label",null,{optional:!0});var I=class extends m{static{l(this,"FieldForm")}constructor(){super(),this._tag="form"}fields(i){let e=super.fields.apply(this,arguments);if(arguments.length){let t=this.inputsMap();this.inputs(i.map(n=>t[n.id()]||new f().name(n.id()).label(n.label()).type(n.type())))}return e}data(i){if(!arguments.length)return super.data();if(super.data(i[0]),i[0]){let e=this.inputs(),t=i[0][this.columns().length],n=0;for(let o in t)e[n].name(o),++n}return this}};I.prototype._class+=" form_FieldForm";import{IInput as D}from"@hpcc-js/api";import{HTMLWidget as it}from"@hpcc-js/common";var y=class extends it{static{l(this,"InputRange")}_inputElement=[];_labelElement=[];_rangeData=[];constructor(){super(),D.call(this),this._tag="div"}enter(i,e){super.enter(i,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()));let t=this;this._inputElement.forEach(function(n,o){n.attr("name",t.name()),n.on("click",function(s){s.click(s)}),n.on("blur",function(s){s.blur(s)}),n.on("change",function(s){t._rangeData[o]=n.property("value"),t.value(t._rangeData),s.change(s,!0)})})}update(i,e){super.update(i,e),this._labelElement[0].style("visibility",this.inlineLabel_exists()?"visible":"hidden").text(this.inlineLabel()),this._rangeData=this.value(),this._inputElement.forEach(function(t,n){t.attr("type",this.type()).property("value",this._rangeData.length>n?this._rangeData[n]:"")},this)}};y.prototype._class+=" form_InputRange";y.prototype.implements(D.prototype);y.prototype.publish("type","text","set","InputRange type",["number","date","text","time","datetime","hidden"]);y.prototype.publish("inlineLabel",null,"string","InputRange Label",null,{optional:!0});y.prototype.publish("value",["",""],"array","Input Current Value",null,{override:!0});import{IInput as V}from"@hpcc-js/api";import{HTMLWidget as nt}from"@hpcc-js/common";(function(){if(!document.getElementById("8973115a")){var a=document.createElement("style");a.id="8973115a",a.textContent=`\uFEFF.onoffswitch-checkbox {
|
|
136
|
+
display: none;
|
|
137
|
+
}
|
|
138
|
+
.onoffswitch {
|
|
139
|
+
position: relative; height: 20px; width: 100px;
|
|
140
|
+
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
|
|
141
|
+
}
|
|
142
|
+
.onoffswitch-label {
|
|
143
|
+
display: block; overflow: hidden; cursor: pointer;
|
|
144
|
+
border: 1px solid #999999;
|
|
145
|
+
height: 20px;
|
|
146
|
+
}
|
|
147
|
+
.onoffswitch-inner {
|
|
148
|
+
position: relative;
|
|
149
|
+
display: block;
|
|
150
|
+
transition: margin 0.3s ease-in 0s;
|
|
151
|
+
}
|
|
152
|
+
.onoffswitch-inner > .onoffswitch-offText,
|
|
153
|
+
.onoffswitch-inner > .onoffswitch-onText{
|
|
154
|
+
height: 100%;
|
|
155
|
+
}
|
|
156
|
+
.onoffswitch-inner > .onoffswitch-offText{
|
|
157
|
+
font-weight: bold;
|
|
158
|
+
position: absolute;
|
|
159
|
+
right: 0;
|
|
160
|
+
transition: all 0.3s ease-in 0s;
|
|
161
|
+
width: 100%;
|
|
162
|
+
text-align: right;
|
|
163
|
+
}
|
|
164
|
+
.onoffswitch-inner > .onoffswitch-onText{
|
|
165
|
+
font-weight: bold;
|
|
166
|
+
position: absolute;
|
|
167
|
+
left: -100%;
|
|
168
|
+
transition: all 0.3s ease-in 0s;
|
|
169
|
+
width: 100%;
|
|
170
|
+
text-align: left;
|
|
171
|
+
}
|
|
172
|
+
.onoffswitch-switch {
|
|
173
|
+
display: block; width: 20px; margin: -1px;
|
|
174
|
+
background: #FFFFFF;
|
|
175
|
+
position: absolute; top: 0; bottom: 0;
|
|
176
|
+
right: 78px;
|
|
177
|
+
border: 1px solid #999999;
|
|
178
|
+
transition: all 0.3s ease-in 0s;
|
|
179
|
+
left: 4px;
|
|
180
|
+
}
|
|
181
|
+
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner > .onoffswitch-offText{
|
|
182
|
+
right: -100%;
|
|
183
|
+
}
|
|
184
|
+
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner > .onoffswitch-onText{
|
|
185
|
+
left: 0;
|
|
186
|
+
}
|
|
187
|
+
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
|
|
188
|
+
left: calc(100% - 20px);
|
|
189
|
+
}`,document.head.appendChild(a)}})();var c=class extends nt{static{l(this,"OnOff")}_inputElement=[];_input;constructor(){super(),V.call(this),this._tag="div"}enter(i,e){super.enter(i,e),e.classed("onoffswitch",!0);let t=this;this._input=e.append("input").attr("class","onoffswitch-checkbox").attr("type","checkbox").attr("id",this.id()+"_onOff").on("click",function(s){s.click(s)}).on("blur",function(s){s.blur(s)}).on("change",function(s){let r=[];t._inputElement.forEach(function(u,h){u.property("checked")&&r.push(u.property("value"))}),t.value(r),s.change(s,!0)});let n=e.append("label").attr("class","onoffswitch-label").attr("for",this.id()+"_onOff"),o=n.append("div").attr("class","onoffswitch-inner");o.append("div").attr("class","onoffswitch-offText").style("padding-right",this.containerRadius()/2+"px").text(this.offText()),o.append("div").attr("class","onoffswitch-onText").style("padding-left",this.containerRadius()/2+"px").style("width",`calc(100% - ${this.containerRadius()/2}px)`).text(this.onText()),n.append("div").attr("class","onoffswitch-switch")}update(i,e){super.update(i,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");let t=this.minHeight()-this.gutter()*4;e.select(".onoffswitch-switch").style("height",t+"px").style("width",t+"px").style("top",this.gutter()*2+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())}};c.prototype._class+=" form_OnOff";c.prototype.implements(V.prototype);c.prototype.publish("marginLeft",0,"number","Margin left of OnOff");c.prototype.publish("marginBottom",0,"number","Margin bottom of OnOff");c.prototype.publish("minWidth",100,"number","Minimum width of OnOff (pixels)");c.prototype.publish("minHeight",20,"number","Minimum height of OnOff (pixels)");c.prototype.publish("gutter",1,"number","Space between switch and border of OnOff (pixels)");c.prototype.publish("onText","Save","string","Text to display when 'ON'");c.prototype.publish("offText","Properties","string","Text to display when 'OFF'");c.prototype.publish("switchRadius",10,"number","Border radius of switch (pixels)");c.prototype.publish("containerRadius",10,"number","Border radius of OnOff (pixels)");c.prototype.publish("onColor","#2ecc71","html-color","Background color when 'ON'");c.prototype.publish("offColor","#ecf0f1","html-color","Background color when 'OFF'");c.prototype.publish("onFontColor","#2c3e50","html-color","Font color when 'ON'");c.prototype.publish("offFontColor","#7f8c8d","html-color","Font color when 'OFF'");import{IInput as W}from"@hpcc-js/api";import{HTMLWidget as ot}from"@hpcc-js/common";var F=class extends ot{static{l(this,"Radio")}_inputElement=[];constructor(){super(),W.call(this),this._tag="div"}enter(i,e){super.enter(i,e);let t=this,n=e.append("ul");this.selectOptions().length||this.selectOptions().push(""),this.selectOptions().forEach(function(o,s){t._inputElement[s]=n.append("li").append("input").attr("type","radio"),t._inputElement[s].node().insertAdjacentHTML("afterend","<text>"+o+"</text>")}),this._inputElement.forEach(function(o,s){o.attr("name",t.name()),o.on("click",function(r){r.click(r)}),o.on("blur",function(r){r.blur(r)}),o.on("change",function(r){t.value([o.property("value")]),r.change(r,!0)})})}update(i,e){super.update(i,e);let t=this;this._inputElement.forEach(function(n,o){n.property("value",t.selectOptions()[o]),t.value().indexOf(t.selectOptions()[o])!==-1&&t.value()!=="false"?n.property("checked",!0):n.property("checked",!1)})}};F.prototype._class+=" form_Radio";F.prototype.implements(W.prototype);F.prototype.publish("selectOptions",[],"array","Array of options used to fill a dropdown list");import{IInput as N}from"@hpcc-js/api";import{HTMLWidget as st}from"@hpcc-js/common";import{rgb as z}from"@hpcc-js/common";var g=class extends st{static{l(this,"Range")}_inputElement=[];constructor(){super(),N.call(this),this._tag="div"}enter(i,e){super.enter(i,e);let t=this;this._inputElement[0]=e.append("input").attr("type","range"),this._inputElement[1]=e.append("input").attr("type","number"),this._inputElement.forEach(function(n,o){n.attr("name",t.name()),n.on("click",function(s){s.click(s)}),n.on("blur",function(s){s.blur(s)}),n.on("change",function(s){o===0?(t._inputElement[1].property("value",z(t._inputElement[0].property("value")).toString()),t.value(t._inputElement[0].property("value"))):(t._inputElement[0].property("value",t._inputElement[1].property("value")),t.value(z(t._inputElement[1].property("value")).toString())),s.change(s,!0)})})}update(i,e){super.update(i,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(i){let e="";i.length>0?i.forEach(function(t){let n=t instanceof Array?t[0]:t,o=t instanceof Array?t[1]?t[1]:t[0]:t;e+="<option value='"+n+"'>"+o+"</option>"}):e+="<option>selectOptions not set</option>",this._inputElement[0].html(e)}};g.prototype._class+=" form_Range";g.prototype.implements(N.prototype);g.prototype.publish("type","text","set","Input type",["html-color","number","checkbox","button","select","textarea","date","text","range","search","email","time","datetime"]);g.prototype.publish("selectOptions",[],"array","Array of options used to fill a dropdown list");g.prototype.publish("low",null,"number","Minimum value for Range input");g.prototype.publish("high",null,"number","Maximum value for Range input");g.prototype.publish("step",null,"number","Step value for Range input");import{IInput as q}from"@hpcc-js/api";import{HTMLWidget as at}from"@hpcc-js/common";var v=class extends at{static{l(this,"Select")}_inputElement=[];constructor(){super(),q.call(this),this._tag="div"}enter(i,e){super.enter(i,e);let t=this;this._inputElement[0]=e.append("select").attr("name",this.name()).on("click",function(n){n.click(n)}).on("blur",function(n){n.blur(n)}).on("change",function(n){t.value([t._inputElement[0].property("value")]),n.change(n,!0)})}update(i,e){super.update(i,e),this.insertSelectOptions(this.selectOptions()),this._inputElement[0].property("value",this.value()).style("max-width",this.maxWidth_exists()?this.maxWidth()+"px":null)}insertSelectOptions(i){let e="";i.length>0?i.forEach(function(t){let n=t instanceof Array?t[0]:t,o=t instanceof Array?t[1]?t[1]:t[0]:t;e+="<option value='"+n+"'>"+o+"</option>"}):e+="<option>selectOptions not set</option>",this._inputElement[0].html(e)}};v.prototype._class+=" form_Select";v.prototype.implements(q.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});import{IInput as $}from"@hpcc-js/api";import{d3Event as C,select as j,SVGWidget as S}from"@hpcc-js/common";import{drag as rt}from"@hpcc-js/common";import{format as lt}from"@hpcc-js/common";import{scaleLinear as pt}from"@hpcc-js/common";import{timeFormat as ht,timeParse as G}from"@hpcc-js/common";(function(){if(!document.getElementById("f0fd1c2d")){var a=document.createElement("style");a.id="f0fd1c2d",a.textContent=`.form_Slider .ticks {
|
|
190
|
+
font: 10px sans-serif;
|
|
40
191
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
function styleInject(css, ref) {
|
|
48
|
-
if ( ref === void 0 ) ref = {};
|
|
49
|
-
var insertAt = ref.insertAt;
|
|
50
|
-
|
|
51
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
52
|
-
|
|
53
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
54
|
-
var style = document.createElement('style');
|
|
55
|
-
style.type = 'text/css';
|
|
56
|
-
|
|
57
|
-
if (insertAt === 'top') {
|
|
58
|
-
if (head.firstChild) {
|
|
59
|
-
head.insertBefore(style, head.firstChild);
|
|
60
|
-
} else {
|
|
61
|
-
head.appendChild(style);
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
head.appendChild(style);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (style.styleSheet) {
|
|
68
|
-
style.styleSheet.cssText = css;
|
|
69
|
-
} else {
|
|
70
|
-
style.appendChild(document.createTextNode(css));
|
|
71
|
-
}
|
|
192
|
+
|
|
193
|
+
.form_Slider .track,
|
|
194
|
+
.form_Slider .track-inset,
|
|
195
|
+
.form_Slider .track-overlay {
|
|
196
|
+
stroke-linecap: round;
|
|
72
197
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
};
|
|
106
|
-
return Button;
|
|
107
|
-
}(common.HTMLWidget));
|
|
108
|
-
Button.prototype._class += " form_Button";
|
|
109
|
-
Button.prototype.implements(api.IInput.prototype);
|
|
110
|
-
|
|
111
|
-
var CheckBox = /** @class */ (function (_super) {
|
|
112
|
-
__extends(CheckBox, _super);
|
|
113
|
-
function CheckBox() {
|
|
114
|
-
var _this = _super.call(this) || this;
|
|
115
|
-
_this._inputElement = [];
|
|
116
|
-
api.IInput.call(_this);
|
|
117
|
-
_this._tag = "div";
|
|
118
|
-
return _this;
|
|
119
|
-
}
|
|
120
|
-
CheckBox.prototype.enter = function (domNode, element) {
|
|
121
|
-
_super.prototype.enter.call(this, domNode, element);
|
|
122
|
-
var context = this;
|
|
123
|
-
var checkboxContainer = element.append("ul");
|
|
124
|
-
if (!this.selectOptions().length) {
|
|
125
|
-
this.selectOptions().push(""); // create an empty radio if we using .value and not selectOptions array
|
|
126
|
-
}
|
|
127
|
-
this.selectOptions().forEach(function (val, idx) {
|
|
128
|
-
context._inputElement[idx] = checkboxContainer.append("li").append("input").attr("type", "checkbox");
|
|
129
|
-
context._inputElement[idx].node().insertAdjacentHTML("afterend", "<text>" + val + "</text>");
|
|
130
|
-
});
|
|
131
|
-
this._inputElement.forEach(function (e, idx) {
|
|
132
|
-
e.attr("name", context.name());
|
|
133
|
-
e.on("click", function (w) {
|
|
134
|
-
w.click(w);
|
|
135
|
-
});
|
|
136
|
-
e.on("blur", function (w) {
|
|
137
|
-
w.blur(w);
|
|
138
|
-
});
|
|
139
|
-
e.on("change", function (w) {
|
|
140
|
-
var vals = [];
|
|
141
|
-
context._inputElement.forEach(function (d) {
|
|
142
|
-
if (d.property("checked")) {
|
|
143
|
-
vals.push(d.property("value"));
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
context.value(vals);
|
|
147
|
-
w.change(w, true);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
};
|
|
151
|
-
CheckBox.prototype.update = function (domNode, element) {
|
|
152
|
-
_super.prototype.update.call(this, domNode, element);
|
|
153
|
-
var context = this;
|
|
154
|
-
this._inputElement.forEach(function (e, idx) {
|
|
155
|
-
e.property("value", context.selectOptions()[idx]);
|
|
156
|
-
if (context.value().indexOf(context.selectOptions()[idx]) !== -1 && context.value() !== "false") {
|
|
157
|
-
e.property("checked", true);
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
e.property("checked", false);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
};
|
|
164
|
-
CheckBox.prototype.insertSelectOptions = function (optionsArr) {
|
|
165
|
-
var optionHTML = "";
|
|
166
|
-
if (optionsArr.length > 0) {
|
|
167
|
-
optionsArr.forEach(function (opt) {
|
|
168
|
-
var val = (opt instanceof Array ? opt[0] : opt);
|
|
169
|
-
var text = (opt instanceof Array ? (opt[1] ? opt[1] : opt[0]) : opt);
|
|
170
|
-
optionHTML += "<option value='" + val + "'>" + text + "</option>";
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
optionHTML += "<option>selectOptions not set</option>";
|
|
175
|
-
}
|
|
176
|
-
this._inputElement[0].html(optionHTML);
|
|
177
|
-
};
|
|
178
|
-
return CheckBox;
|
|
179
|
-
}(common.HTMLWidget));
|
|
180
|
-
CheckBox.prototype._class += " form_CheckBox";
|
|
181
|
-
CheckBox.prototype.implements(api.IInput.prototype);
|
|
182
|
-
CheckBox.prototype.publish("selectOptions", [], "array", "Array of options used to fill a dropdown list");
|
|
183
|
-
|
|
184
|
-
var ColorInput = /** @class */ (function (_super) {
|
|
185
|
-
__extends(ColorInput, _super);
|
|
186
|
-
function ColorInput() {
|
|
187
|
-
var _this = _super.call(this) || this;
|
|
188
|
-
_this._inputElement = [];
|
|
189
|
-
api.IInput.call(_this);
|
|
190
|
-
_this._tag = "div";
|
|
191
|
-
return _this;
|
|
192
|
-
}
|
|
193
|
-
ColorInput.prototype.enter = function (domNode, element) {
|
|
194
|
-
_super.prototype.enter.call(this, domNode, element);
|
|
195
|
-
var context = this;
|
|
196
|
-
this._inputElement[0] = element.append("input").attr("type", "text");
|
|
197
|
-
this._inputElement[0].classed("color-text", true);
|
|
198
|
-
this._inputElement[1] = element.append("input").attr("type", "color");
|
|
199
|
-
this._inputElement.forEach(function (e, idx) {
|
|
200
|
-
e.on("click", function (w) {
|
|
201
|
-
w.click(w);
|
|
202
|
-
});
|
|
203
|
-
e.on("blur", function (w) {
|
|
204
|
-
w.blur(w);
|
|
205
|
-
});
|
|
206
|
-
e.on("change", function (w) {
|
|
207
|
-
if (idx === 0) {
|
|
208
|
-
context._inputElement[1].property("value", common.rgb(context._inputElement[0].property("value")).toString());
|
|
209
|
-
context.value(context._inputElement[0].property("value"));
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
context._inputElement[0].property("value", context._inputElement[1].property("value"));
|
|
213
|
-
context.value(common.rgb(context._inputElement[1].property("value")).toString());
|
|
214
|
-
}
|
|
215
|
-
w.change(w, true);
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
};
|
|
219
|
-
ColorInput.prototype.update = function (domNode, element) {
|
|
220
|
-
_super.prototype.update.call(this, domNode, element);
|
|
221
|
-
var context = this;
|
|
222
|
-
this._inputElement.forEach(function (e) {
|
|
223
|
-
e.attr("name", context.name());
|
|
224
|
-
});
|
|
225
|
-
this._inputElement[0].attr("type", "text");
|
|
226
|
-
this._inputElement[1].attr("type", "color");
|
|
227
|
-
this._inputElement[0].property("value", this.value());
|
|
228
|
-
this._inputElement[1].property("value", common.rgb(this.value()).toString());
|
|
229
|
-
var bbox = this._inputElement[0].node().getBoundingClientRect();
|
|
230
|
-
this._inputElement[1].style("height", (bbox.height - 2) + "px");
|
|
231
|
-
};
|
|
232
|
-
return ColorInput;
|
|
233
|
-
}(common.HTMLWidget));
|
|
234
|
-
ColorInput.prototype._class += " form_ColorInput";
|
|
235
|
-
ColorInput.prototype.implements(api.IInput.prototype);
|
|
236
|
-
|
|
237
|
-
var css_248z$2 = ".form_Form{color:#404040}.form_Form tbody td{border:1px solid #e5e5e5;white-space:nowrap}.form_Form td.prompt{background-color:#e5e5e5;padding:2px;vertical-align:middle}.form_Form td.input{padding:2px;vertical-align:middle;width:100%}.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{word-wrap:break-word;background-position:-1px -1px;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 3px 3px 3px;bottom:0;box-sizing:border-box;color:#24292e;column-rule-color:#24292e;cursor:pointer;height:28px;left:0;outline:0 none #24292e;overflow-wrap:break-word;padding:3px 10px;perspective-origin:57.2938px 14px;position:relative;right:0;text-decoration:none solid #24292e;top:0;transform-origin:57.2938px 14px;user-select:none;vertical-align:middle;white-space:nowrap}.form_Form .form_Button button[disabled=disabled]{background:#dbdfe2}.form_Form .form_Button button:focus{box-shadow:0 0 0 .2em rgba(3,102,214,.3)}.form_Form .form_Button button:hover{background:#dbdfe2}.form_Form .form_Button.default button{word-wrap:break-word;background:#28a745 linear-gradient(-180deg,#34d058,#28a745 90%) repeat-x scroll -1px -1px /110% 110% padding-box border-box;color:#fff;column-rule-color:#fff;outline:0 none #fff;perspective-origin:44.975px 17px;text-decoration:none solid #fff;transform-origin:44.975px 17px}.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}";
|
|
238
|
-
styleInject(css_248z$2);
|
|
239
|
-
|
|
240
|
-
var Form = /** @class */ (function (_super) {
|
|
241
|
-
__extends(Form, _super);
|
|
242
|
-
function Form() {
|
|
243
|
-
var _this = _super.call(this) || this;
|
|
244
|
-
_this._tag = "form";
|
|
245
|
-
return _this;
|
|
246
|
-
}
|
|
247
|
-
Form.prototype.data = function (_) {
|
|
248
|
-
if (!arguments.length) {
|
|
249
|
-
var retVal_1 = [];
|
|
250
|
-
this.inputsForEach(function (input) {
|
|
251
|
-
retVal_1.push(input.value());
|
|
252
|
-
});
|
|
253
|
-
return retVal_1;
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
this.inputsForEach(function (input, idx) {
|
|
257
|
-
if (_ && _.length > idx) {
|
|
258
|
-
input.value(_[idx]).render();
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
return this;
|
|
263
|
-
};
|
|
264
|
-
Form.prototype.inputsForEach = function (callback, scope) {
|
|
265
|
-
var idx = 0;
|
|
266
|
-
this.inputs().forEach(function (inp) {
|
|
267
|
-
var inpArray = inp instanceof common.WidgetArray ? inp.content() : [inp];
|
|
268
|
-
inpArray.forEach(function (inp2) {
|
|
269
|
-
if (scope) {
|
|
270
|
-
callback.call(scope, inp2, idx++);
|
|
271
|
-
}
|
|
272
|
-
else {
|
|
273
|
-
callback(inp2, idx++);
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
});
|
|
277
|
-
};
|
|
278
|
-
Form.prototype.inputsMap = function () {
|
|
279
|
-
var retVal = {};
|
|
280
|
-
this.inputs().forEach(function (inp) {
|
|
281
|
-
retVal[inp.name()] = inp;
|
|
282
|
-
});
|
|
283
|
-
return retVal;
|
|
284
|
-
};
|
|
285
|
-
Form.prototype.calcMaxColumns = function () {
|
|
286
|
-
var retVal = 0;
|
|
287
|
-
this.inputs().forEach(function (inputWidget) {
|
|
288
|
-
var inputWidgetArray = inputWidget instanceof common.WidgetArray ? inputWidget.content() : [inputWidget];
|
|
289
|
-
if (inputWidgetArray.length > retVal) {
|
|
290
|
-
retVal = inputWidgetArray.length;
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
return retVal;
|
|
294
|
-
};
|
|
295
|
-
Form.prototype.values = function (_) {
|
|
296
|
-
if (!arguments.length) {
|
|
297
|
-
var dataArr_1 = {};
|
|
298
|
-
this.inputsForEach(function (inp) {
|
|
299
|
-
var type = inp.type ? inp.type() : "text";
|
|
300
|
-
var value = inp.value();
|
|
301
|
-
if (value || !this.omitBlank()) {
|
|
302
|
-
switch (type) {
|
|
303
|
-
case "checkbox":
|
|
304
|
-
dataArr_1[inp.name()] = inp.value_exists() ? !!inp.value() : undefined;
|
|
305
|
-
break;
|
|
306
|
-
case "number":
|
|
307
|
-
var v = inp.value();
|
|
308
|
-
dataArr_1[inp.name()] = v === "" ? undefined : +v;
|
|
309
|
-
break;
|
|
310
|
-
case "text":
|
|
311
|
-
default:
|
|
312
|
-
dataArr_1[inp.name()] = inp.value_exists() ? inp.value() : undefined;
|
|
313
|
-
break;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}, this);
|
|
317
|
-
return dataArr_1;
|
|
318
|
-
}
|
|
319
|
-
else {
|
|
320
|
-
this.inputsForEach(function (inp) {
|
|
321
|
-
if (_[inp.name()]) {
|
|
322
|
-
inp.value(_[inp.name()]);
|
|
323
|
-
}
|
|
324
|
-
else if (this.omitBlank()) {
|
|
325
|
-
inp.value("");
|
|
326
|
-
}
|
|
327
|
-
}, this);
|
|
328
|
-
}
|
|
329
|
-
return this;
|
|
330
|
-
};
|
|
331
|
-
Form.prototype.submit = function () {
|
|
332
|
-
var isValid = true;
|
|
333
|
-
if (this.validate()) {
|
|
334
|
-
isValid = this.checkValidation();
|
|
335
|
-
}
|
|
336
|
-
if (!this.allowEmptyRequest() && !this.inputs().some(function (w) {
|
|
337
|
-
if (w._class.indexOf("WidgetArray") !== -1) {
|
|
338
|
-
return w.content().some(function (wa) {
|
|
339
|
-
return wa.hasValue();
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
return w.hasValue();
|
|
343
|
-
})) {
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
this.click(isValid ? this.values() : null, null, isValid);
|
|
347
|
-
};
|
|
348
|
-
Form.prototype.clear = function () {
|
|
349
|
-
this.inputsForEach(function (inp) {
|
|
350
|
-
switch (inp.classID()) {
|
|
351
|
-
case "form_Slider":
|
|
352
|
-
if (inp.allowRange()) {
|
|
353
|
-
inp.value([inp.low(), inp.low()]).render();
|
|
354
|
-
}
|
|
355
|
-
else {
|
|
356
|
-
inp.value(inp.low()).render();
|
|
357
|
-
}
|
|
358
|
-
break;
|
|
359
|
-
case "form_CheckBox":
|
|
360
|
-
inp.value(false).render();
|
|
361
|
-
break;
|
|
362
|
-
case "form_Button":
|
|
363
|
-
/* skip */
|
|
364
|
-
break;
|
|
365
|
-
default:
|
|
366
|
-
inp.value(undefined).render();
|
|
367
|
-
break;
|
|
368
|
-
}
|
|
369
|
-
});
|
|
370
|
-
};
|
|
371
|
-
Form.prototype.checkValidation = function () {
|
|
372
|
-
var ret = true;
|
|
373
|
-
var msgArr = [];
|
|
374
|
-
this.inputsForEach(function (inp) {
|
|
375
|
-
if (!inp.isValid()) {
|
|
376
|
-
msgArr.push("'" + inp.label() + "'" + " value is invalid.");
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
if (msgArr.length > 0) {
|
|
380
|
-
alert(msgArr.join("\n"));
|
|
381
|
-
ret = false;
|
|
382
|
-
}
|
|
383
|
-
return ret;
|
|
384
|
-
};
|
|
385
|
-
Form.prototype.enter = function (domNode, element) {
|
|
386
|
-
_super.prototype.enter.call(this, domNode, element);
|
|
387
|
-
element.on("submit", function () {
|
|
388
|
-
common.d3Event().preventDefault();
|
|
389
|
-
});
|
|
390
|
-
this._placeholderElement.style("overflow", "auto");
|
|
391
|
-
var table = element
|
|
392
|
-
.append("table");
|
|
393
|
-
this.tbody = table.append("tbody");
|
|
394
|
-
this.tfoot = table.append("tfoot");
|
|
395
|
-
this.btntd = this.tfoot.append("tr").append("td")
|
|
396
|
-
.attr("colspan", 2);
|
|
397
|
-
var context = this;
|
|
398
|
-
this._controls = [
|
|
399
|
-
new Button()
|
|
400
|
-
.classed({ default: true })
|
|
401
|
-
.value("Submit")
|
|
402
|
-
.on("click", function () {
|
|
403
|
-
context.submit();
|
|
404
|
-
}, true),
|
|
405
|
-
new Button()
|
|
406
|
-
.value("Clear")
|
|
407
|
-
.on("click", function () {
|
|
408
|
-
context.clear();
|
|
409
|
-
}, true)
|
|
410
|
-
];
|
|
411
|
-
var rightJust = context.btntd
|
|
412
|
-
.append("div")
|
|
413
|
-
.style("float", "right");
|
|
414
|
-
this._controls.forEach(function (w) {
|
|
415
|
-
var leftJust = rightJust
|
|
416
|
-
.append("span")
|
|
417
|
-
.style("float", "left");
|
|
418
|
-
w.target(leftJust.node()).render();
|
|
419
|
-
});
|
|
420
|
-
};
|
|
421
|
-
Form.prototype.update = function (domNode, element) {
|
|
422
|
-
_super.prototype.update.call(this, domNode, element);
|
|
423
|
-
this._maxCols = this.calcMaxColumns();
|
|
424
|
-
var context = this;
|
|
425
|
-
var rows = this.tbody.selectAll("tr").data(this.inputs());
|
|
426
|
-
rows.enter().append("tr")
|
|
427
|
-
.each(function (inputWidget, i) {
|
|
428
|
-
var element2 = common.select(this);
|
|
429
|
-
var inputWidgetArray = inputWidget instanceof common.WidgetArray ? inputWidget.content() : [inputWidget];
|
|
430
|
-
inputWidgetArray.forEach(function (inputWidget2, idx) {
|
|
431
|
-
element2.append("td")
|
|
432
|
-
.attr("class", "prompt");
|
|
433
|
-
var input = element2.append("td")
|
|
434
|
-
.attr("class", "input");
|
|
435
|
-
if (idx === inputWidgetArray.length - 1 && inputWidgetArray.length < context._maxCols) {
|
|
436
|
-
input.attr("colspan", (context._maxCols - inputWidgetArray.length + 1) * 2);
|
|
437
|
-
}
|
|
438
|
-
inputWidget2.target(input.node()).render();
|
|
439
|
-
if (inputWidget2 instanceof common.SVGWidget) {
|
|
440
|
-
var bbox = inputWidget2.element().node().getBBox();
|
|
441
|
-
input.style("height", bbox.height + "px");
|
|
442
|
-
inputWidget2.resize().render();
|
|
443
|
-
}
|
|
444
|
-
if (inputWidget2._inputElement instanceof Array) {
|
|
445
|
-
inputWidget2._inputElement.forEach(function (e) {
|
|
446
|
-
e.on("keyup.form", function (w) {
|
|
447
|
-
setTimeout(function () {
|
|
448
|
-
context._controls[0].disable(!context.allowEmptyRequest() && !context.inputs().some(function (w2) {
|
|
449
|
-
if (w2._class.indexOf("WidgetArray") !== -1) {
|
|
450
|
-
return w2.content().some(function (wa) {
|
|
451
|
-
return wa.hasValue();
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
return w2.hasValue();
|
|
455
|
-
}));
|
|
456
|
-
}, 100);
|
|
457
|
-
});
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
})
|
|
462
|
-
.merge(rows)
|
|
463
|
-
.each(function (inputWidget, i) {
|
|
464
|
-
var element2 = common.select(this);
|
|
465
|
-
var inputWidgetArray = inputWidget instanceof common.WidgetArray ? inputWidget.content() : [inputWidget];
|
|
466
|
-
inputWidgetArray.forEach(function (inputWidget2, idx) {
|
|
467
|
-
element2.select("td.prompt")
|
|
468
|
-
.text(inputWidget2.label() + ":");
|
|
469
|
-
});
|
|
470
|
-
});
|
|
471
|
-
rows.each(function (inputWidget, i) {
|
|
472
|
-
if (i === 0 && inputWidget.setFocus) {
|
|
473
|
-
inputWidget.setFocus();
|
|
474
|
-
}
|
|
475
|
-
});
|
|
476
|
-
rows.exit()
|
|
477
|
-
.each(function (inputWidget, i) {
|
|
478
|
-
var inputWidgetArray = inputWidget instanceof common.WidgetArray ? inputWidget.content() : [inputWidget];
|
|
479
|
-
inputWidgetArray.forEach(function (inputWidget2, idx) {
|
|
480
|
-
inputWidget2.target(null);
|
|
481
|
-
});
|
|
482
|
-
})
|
|
483
|
-
.remove();
|
|
484
|
-
this.tfoot
|
|
485
|
-
.style("display", this.showSubmit() ? "table-footer-group" : "none");
|
|
486
|
-
this.btntd
|
|
487
|
-
.attr("colspan", this._maxCols * 2);
|
|
488
|
-
// Disable Submit unless there is data
|
|
489
|
-
if (!this.allowEmptyRequest()) {
|
|
490
|
-
setTimeout(function () {
|
|
491
|
-
context._controls[0].disable(!context.allowEmptyRequest() && !context.inputs().some(function (w) {
|
|
492
|
-
if (w._class.indexOf("WidgetArray") !== -1) {
|
|
493
|
-
return w.content().some(function (wa) {
|
|
494
|
-
return wa.hasValue();
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
return w.hasValue();
|
|
498
|
-
}));
|
|
499
|
-
}, 100);
|
|
500
|
-
}
|
|
501
|
-
};
|
|
502
|
-
Form.prototype.exit = function (domNode, element) {
|
|
503
|
-
this.inputsForEach(function (input) { return input.target(null); });
|
|
504
|
-
_super.prototype.exit.call(this, domNode, element);
|
|
505
|
-
};
|
|
506
|
-
Form.prototype.click = function (row, col, sel) {
|
|
507
|
-
};
|
|
508
|
-
return Form;
|
|
509
|
-
}(common.HTMLWidget));
|
|
510
|
-
Form.prototype._class += " form_Form";
|
|
511
|
-
Form.prototype.publish("validate", true, "boolean", "Enable/Disable input validation");
|
|
512
|
-
Form.prototype.publish("inputs", [], "widgetArray", "Array of input widgets", null, { render: false });
|
|
513
|
-
Form.prototype.publish("showSubmit", true, "boolean", "Show Submit/Cancel Controls");
|
|
514
|
-
Form.prototype.publish("omitBlank", false, "boolean", "Drop Blank Fields From Submit");
|
|
515
|
-
Form.prototype.publish("allowEmptyRequest", false, "boolean", "Allow Blank Form to be Submitted");
|
|
516
|
-
|
|
517
|
-
var Input = /** @class */ (function (_super) {
|
|
518
|
-
__extends(Input, _super);
|
|
519
|
-
function Input() {
|
|
520
|
-
var _this = _super.call(this) || this;
|
|
521
|
-
_this._inputElement = [];
|
|
522
|
-
_this._labelElement = [];
|
|
523
|
-
api.IInput.call(_this);
|
|
524
|
-
_this._tag = "div";
|
|
525
|
-
return _this;
|
|
526
|
-
}
|
|
527
|
-
Input.prototype.checked = function (_) {
|
|
528
|
-
if (!arguments.length)
|
|
529
|
-
return this._inputElement[0] ? this._inputElement[0].property("checked") : false;
|
|
530
|
-
if (this._inputElement[0]) {
|
|
531
|
-
this._inputElement[0].property("checked", _);
|
|
532
|
-
}
|
|
533
|
-
return this;
|
|
534
|
-
};
|
|
535
|
-
Input.prototype.enter = function (domNode, element) {
|
|
536
|
-
_super.prototype.enter.call(this, domNode, element);
|
|
537
|
-
this._labelElement[0] = element.append("label")
|
|
538
|
-
.attr("for", this.id() + "_input")
|
|
539
|
-
.style("visibility", this.inlineLabel_exists() ? "visible" : "hidden");
|
|
540
|
-
var context = this;
|
|
541
|
-
switch (this.type()) {
|
|
542
|
-
case "button":
|
|
543
|
-
this._inputElement[0] = element.append("button")
|
|
544
|
-
.attr("id", this.id() + "_input");
|
|
545
|
-
break;
|
|
546
|
-
case "textarea":
|
|
547
|
-
this._inputElement[0] = element.append("textarea")
|
|
548
|
-
.attr("id", this.id() + "_input");
|
|
549
|
-
break;
|
|
550
|
-
default:
|
|
551
|
-
this._inputElement[0] = element.append("input")
|
|
552
|
-
.attr("id", this.id() + "_input")
|
|
553
|
-
.attr("type", this.type());
|
|
554
|
-
break;
|
|
555
|
-
}
|
|
556
|
-
this._inputElement.forEach(function (e, idx) {
|
|
557
|
-
e.attr("name", context.name());
|
|
558
|
-
e.on("click", function (w) {
|
|
559
|
-
w.click(w);
|
|
560
|
-
});
|
|
561
|
-
e.on("blur", function (w) {
|
|
562
|
-
w.blur(w);
|
|
563
|
-
});
|
|
564
|
-
e.on("change", function (w) {
|
|
565
|
-
context.value([e.property("value")]);
|
|
566
|
-
w.change(w, true);
|
|
567
|
-
});
|
|
568
|
-
e.on("keyup", function (w) {
|
|
569
|
-
context.value([e.property("value")]);
|
|
570
|
-
w.change(w, false);
|
|
571
|
-
});
|
|
572
|
-
});
|
|
573
|
-
};
|
|
574
|
-
Input.prototype.update = function (domNode, element) {
|
|
575
|
-
_super.prototype.update.call(this, domNode, element);
|
|
576
|
-
this._labelElement[0]
|
|
577
|
-
.style("visibility", this.inlineLabel_exists() ? "visible" : "hidden")
|
|
578
|
-
.text(this.inlineLabel());
|
|
579
|
-
switch (this.type()) {
|
|
580
|
-
case "button":
|
|
581
|
-
this._inputElement[0].text(this.value());
|
|
582
|
-
break;
|
|
583
|
-
case "textarea":
|
|
584
|
-
this._inputElement[0].property("value", this.value());
|
|
585
|
-
break;
|
|
586
|
-
default:
|
|
587
|
-
this._inputElement[0].attr("type", this.type());
|
|
588
|
-
this._inputElement[0].property("value", this.value());
|
|
589
|
-
break;
|
|
590
|
-
}
|
|
591
|
-
};
|
|
592
|
-
return Input;
|
|
593
|
-
}(common.HTMLWidget));
|
|
594
|
-
Input.prototype._class += " form_Input";
|
|
595
|
-
Input.prototype.implements(api.IInput.prototype);
|
|
596
|
-
Input.prototype.publish("type", "text", "set", "Input type", ["number", "button", "checkbox", "date", "text", "textarea", "search", "email", "time", "datetime", "hidden"]);
|
|
597
|
-
Input.prototype.publish("inlineLabel", null, "string", "Input Label", null, { optional: true });
|
|
598
|
-
|
|
599
|
-
var FieldForm = /** @class */ (function (_super) {
|
|
600
|
-
__extends(FieldForm, _super);
|
|
601
|
-
function FieldForm() {
|
|
602
|
-
var _this = _super.call(this) || this;
|
|
603
|
-
_this._tag = "form";
|
|
604
|
-
return _this;
|
|
605
|
-
}
|
|
606
|
-
FieldForm.prototype.fields = function (_) {
|
|
607
|
-
var retVal = _super.prototype.fields.apply(this, arguments);
|
|
608
|
-
if (arguments.length) {
|
|
609
|
-
var inpMap_1 = this.inputsMap();
|
|
610
|
-
this.inputs(_.map(function (f) { return inpMap_1[f.id()] || new Input()
|
|
611
|
-
.name(f.id())
|
|
612
|
-
.label(f.label())
|
|
613
|
-
.type(f.type()); }));
|
|
614
|
-
}
|
|
615
|
-
return retVal;
|
|
616
|
-
};
|
|
617
|
-
FieldForm.prototype.data = function (_) {
|
|
618
|
-
if (!arguments.length)
|
|
619
|
-
return _super.prototype.data.call(this);
|
|
620
|
-
_super.prototype.data.call(this, _[0]);
|
|
621
|
-
if (_[0]) {
|
|
622
|
-
// Update input "name" with the __lparam ids ---
|
|
623
|
-
var inputs = this.inputs();
|
|
624
|
-
var __lparam = _[0][this.columns().length];
|
|
625
|
-
var i = 0;
|
|
626
|
-
for (var key in __lparam) {
|
|
627
|
-
inputs[i].name(key);
|
|
628
|
-
++i;
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
return this;
|
|
632
|
-
};
|
|
633
|
-
return FieldForm;
|
|
634
|
-
}(Form));
|
|
635
|
-
FieldForm.prototype._class += " form_FieldForm";
|
|
636
|
-
|
|
637
|
-
var InputRange = /** @class */ (function (_super) {
|
|
638
|
-
__extends(InputRange, _super);
|
|
639
|
-
function InputRange() {
|
|
640
|
-
var _this = _super.call(this) || this;
|
|
641
|
-
_this._inputElement = [];
|
|
642
|
-
_this._labelElement = [];
|
|
643
|
-
_this._rangeData = [];
|
|
644
|
-
api.IInput.call(_this);
|
|
645
|
-
_this._tag = "div";
|
|
646
|
-
return _this;
|
|
647
|
-
}
|
|
648
|
-
InputRange.prototype.enter = function (domNode, element) {
|
|
649
|
-
_super.prototype.enter.call(this, domNode, element);
|
|
650
|
-
this._labelElement[0] = element.append("label")
|
|
651
|
-
.attr("for", this.id() + "_input")
|
|
652
|
-
.style("visibility", this.inlineLabel_exists() ? "visible" : "hidden");
|
|
653
|
-
this._inputElement.push(element.append("input")
|
|
654
|
-
.attr("id", this.id() + "_input_min")
|
|
655
|
-
.attr("type", this.type()));
|
|
656
|
-
this._inputElement.push(element.append("input")
|
|
657
|
-
.attr("id", this.id() + "_input_max")
|
|
658
|
-
.attr("type", this.type()));
|
|
659
|
-
var context = this;
|
|
660
|
-
this._inputElement.forEach(function (e, idx) {
|
|
661
|
-
e.attr("name", context.name());
|
|
662
|
-
e.on("click", function (w) {
|
|
663
|
-
w.click(w);
|
|
664
|
-
});
|
|
665
|
-
e.on("blur", function (w) {
|
|
666
|
-
w.blur(w);
|
|
667
|
-
});
|
|
668
|
-
e.on("change", function (w) {
|
|
669
|
-
context._rangeData[idx] = e.property("value");
|
|
670
|
-
context.value(context._rangeData);
|
|
671
|
-
w.change(w, true);
|
|
672
|
-
});
|
|
673
|
-
});
|
|
674
|
-
};
|
|
675
|
-
InputRange.prototype.update = function (domNode, element) {
|
|
676
|
-
_super.prototype.update.call(this, domNode, element);
|
|
677
|
-
this._labelElement[0]
|
|
678
|
-
.style("visibility", this.inlineLabel_exists() ? "visible" : "hidden")
|
|
679
|
-
.text(this.inlineLabel());
|
|
680
|
-
this._rangeData = this.value();
|
|
681
|
-
this._inputElement.forEach(function (e, idx) {
|
|
682
|
-
e
|
|
683
|
-
.attr("type", this.type())
|
|
684
|
-
.property("value", this._rangeData.length > idx ? this._rangeData[idx] : "");
|
|
685
|
-
}, this);
|
|
686
|
-
};
|
|
687
|
-
return InputRange;
|
|
688
|
-
}(common.HTMLWidget));
|
|
689
|
-
InputRange.prototype._class += " form_InputRange";
|
|
690
|
-
InputRange.prototype.implements(api.IInput.prototype);
|
|
691
|
-
InputRange.prototype.publish("type", "text", "set", "InputRange type", ["number", "date", "text", "time", "datetime", "hidden"]);
|
|
692
|
-
InputRange.prototype.publish("inlineLabel", null, "string", "InputRange Label", null, { optional: true });
|
|
693
|
-
InputRange.prototype.publish("value", ["", ""], "array", "Input Current Value", null, { override: true });
|
|
694
|
-
|
|
695
|
-
var css_248z$1 = ".onoffswitch-checkbox{display:none}.onoffswitch{height:20px;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;width:100px}.onoffswitch-label{border:1px solid #999;cursor:pointer;display:block;height:20px;overflow:hidden}.onoffswitch-inner{display:block;position:relative;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;text-align:right;transition:all .3s ease-in 0s;width:100%}.onoffswitch-inner>.onoffswitch-onText{font-weight:700;left:-100%;position:absolute;text-align:left;transition:all .3s ease-in 0s;width:100%}.onoffswitch-switch{background:#fff;border:1px solid #999;bottom:0;display:block;left:4px;margin:-1px;position:absolute;right:78px;top:0;transition:all .3s ease-in 0s;width:20px}.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)}";
|
|
696
|
-
styleInject(css_248z$1);
|
|
697
|
-
|
|
698
|
-
var OnOff = /** @class */ (function (_super) {
|
|
699
|
-
__extends(OnOff, _super);
|
|
700
|
-
function OnOff() {
|
|
701
|
-
var _this = _super.call(this) || this;
|
|
702
|
-
_this._inputElement = [];
|
|
703
|
-
api.IInput.call(_this);
|
|
704
|
-
_this._tag = "div";
|
|
705
|
-
return _this;
|
|
706
|
-
}
|
|
707
|
-
OnOff.prototype.enter = function (domNode, element) {
|
|
708
|
-
_super.prototype.enter.call(this, domNode, element);
|
|
709
|
-
element.classed("onoffswitch", true);
|
|
710
|
-
var context = this;
|
|
711
|
-
this._input = element.append("input")
|
|
712
|
-
.attr("class", "onoffswitch-checkbox")
|
|
713
|
-
.attr("type", "checkbox")
|
|
714
|
-
.attr("id", this.id() + "_onOff")
|
|
715
|
-
.on("click", function (w) {
|
|
716
|
-
w.click(w);
|
|
717
|
-
})
|
|
718
|
-
.on("blur", function (w) {
|
|
719
|
-
w.blur(w);
|
|
720
|
-
})
|
|
721
|
-
.on("change", function (w) {
|
|
722
|
-
var vals = [];
|
|
723
|
-
context._inputElement.forEach(function (d, idx) {
|
|
724
|
-
if (d.property("checked")) {
|
|
725
|
-
vals.push(d.property("value"));
|
|
726
|
-
}
|
|
727
|
-
});
|
|
728
|
-
context.value(vals);
|
|
729
|
-
w.change(w, true);
|
|
730
|
-
});
|
|
731
|
-
var label = element.append("label")
|
|
732
|
-
.attr("class", "onoffswitch-label")
|
|
733
|
-
.attr("for", this.id() + "_onOff");
|
|
734
|
-
var inner = label.append("div")
|
|
735
|
-
.attr("class", "onoffswitch-inner");
|
|
736
|
-
inner.append("div")
|
|
737
|
-
.attr("class", "onoffswitch-offText")
|
|
738
|
-
.style("padding-right", (this.containerRadius() / 2) + "px")
|
|
739
|
-
.text(this.offText());
|
|
740
|
-
inner.append("div")
|
|
741
|
-
.attr("class", "onoffswitch-onText")
|
|
742
|
-
.style("padding-left", (this.containerRadius() / 2) + "px")
|
|
743
|
-
.style("width", "calc(100% - ".concat((this.containerRadius() / 2), "px)"))
|
|
744
|
-
.text(this.onText());
|
|
745
|
-
label.append("div")
|
|
746
|
-
.attr("class", "onoffswitch-switch");
|
|
747
|
-
};
|
|
748
|
-
OnOff.prototype.update = function (domNode, element) {
|
|
749
|
-
_super.prototype.update.call(this, domNode, element);
|
|
750
|
-
this._input
|
|
751
|
-
.attr("name", this.name());
|
|
752
|
-
element
|
|
753
|
-
.style("margin-left", this.marginLeft() + "px")
|
|
754
|
-
.style("margin-bottom", this.marginBottom() + "px")
|
|
755
|
-
.style("width", this.minWidth() + "px");
|
|
756
|
-
var _switch_size = this.minHeight() - (this.gutter() * 4);
|
|
757
|
-
element.select(".onoffswitch-switch")
|
|
758
|
-
.style("height", _switch_size + "px")
|
|
759
|
-
.style("width", _switch_size + "px")
|
|
760
|
-
.style("top", (this.gutter() * 2) + 1 + "px")
|
|
761
|
-
.style("border-radius", this.switchRadius() + "px");
|
|
762
|
-
element.select(".onoffswitch-inner")
|
|
763
|
-
.style("min-height", this.minHeight() + "px");
|
|
764
|
-
element.select(".onoffswitch-label")
|
|
765
|
-
.style("border-radius", this.containerRadius() + "px");
|
|
766
|
-
element.select(".onoffswitch-offText")
|
|
767
|
-
.style("color", this.offFontColor())
|
|
768
|
-
.style("background-color", this.offColor());
|
|
769
|
-
element.select(".onoffswitch-onText")
|
|
770
|
-
.style("color", this.onFontColor())
|
|
771
|
-
.style("background-color", this.onColor());
|
|
772
|
-
};
|
|
773
|
-
return OnOff;
|
|
774
|
-
}(common.HTMLWidget));
|
|
775
|
-
OnOff.prototype._class += " form_OnOff";
|
|
776
|
-
OnOff.prototype.implements(api.IInput.prototype);
|
|
777
|
-
OnOff.prototype.publish("marginLeft", 0, "number", "Margin left of OnOff");
|
|
778
|
-
OnOff.prototype.publish("marginBottom", 0, "number", "Margin bottom of OnOff");
|
|
779
|
-
OnOff.prototype.publish("minWidth", 100, "number", "Minimum width of OnOff (pixels)");
|
|
780
|
-
OnOff.prototype.publish("minHeight", 20, "number", "Minimum height of OnOff (pixels)");
|
|
781
|
-
OnOff.prototype.publish("gutter", 1, "number", "Space between switch and border of OnOff (pixels)");
|
|
782
|
-
OnOff.prototype.publish("onText", "Save", "string", "Text to display when 'ON'");
|
|
783
|
-
OnOff.prototype.publish("offText", "Properties", "string", "Text to display when 'OFF'");
|
|
784
|
-
OnOff.prototype.publish("switchRadius", 10, "number", "Border radius of switch (pixels)");
|
|
785
|
-
OnOff.prototype.publish("containerRadius", 10, "number", "Border radius of OnOff (pixels)");
|
|
786
|
-
OnOff.prototype.publish("onColor", "#2ecc71", "html-color", "Background color when 'ON'");
|
|
787
|
-
OnOff.prototype.publish("offColor", "#ecf0f1", "html-color", "Background color when 'OFF'");
|
|
788
|
-
OnOff.prototype.publish("onFontColor", "#2c3e50", "html-color", "Font color when 'ON'");
|
|
789
|
-
OnOff.prototype.publish("offFontColor", "#7f8c8d", "html-color", "Font color when 'OFF'");
|
|
790
|
-
|
|
791
|
-
var Radio = /** @class */ (function (_super) {
|
|
792
|
-
__extends(Radio, _super);
|
|
793
|
-
function Radio() {
|
|
794
|
-
var _this = _super.call(this) || this;
|
|
795
|
-
_this._inputElement = [];
|
|
796
|
-
api.IInput.call(_this);
|
|
797
|
-
_this._tag = "div";
|
|
798
|
-
return _this;
|
|
799
|
-
}
|
|
800
|
-
Radio.prototype.enter = function (domNode, element) {
|
|
801
|
-
_super.prototype.enter.call(this, domNode, element);
|
|
802
|
-
var context = this;
|
|
803
|
-
var radioContainer = element.append("ul");
|
|
804
|
-
if (!this.selectOptions().length) {
|
|
805
|
-
this.selectOptions().push(""); // create an empty radio if we using .value and not selectOptions array
|
|
806
|
-
}
|
|
807
|
-
this.selectOptions().forEach(function (val, idx) {
|
|
808
|
-
context._inputElement[idx] = radioContainer.append("li").append("input").attr("type", "radio");
|
|
809
|
-
context._inputElement[idx].node().insertAdjacentHTML("afterend", "<text>" + val + "</text>");
|
|
810
|
-
});
|
|
811
|
-
this._inputElement.forEach(function (e, idx) {
|
|
812
|
-
e.attr("name", context.name());
|
|
813
|
-
e.on("click", function (w) {
|
|
814
|
-
w.click(w);
|
|
815
|
-
});
|
|
816
|
-
e.on("blur", function (w) {
|
|
817
|
-
w.blur(w);
|
|
818
|
-
});
|
|
819
|
-
e.on("change", function (w) {
|
|
820
|
-
context.value([e.property("value")]);
|
|
821
|
-
w.change(w, true);
|
|
822
|
-
});
|
|
823
|
-
});
|
|
824
|
-
};
|
|
825
|
-
Radio.prototype.update = function (domNode, element) {
|
|
826
|
-
_super.prototype.update.call(this, domNode, element);
|
|
827
|
-
var context = this;
|
|
828
|
-
this._inputElement.forEach(function (e, idx) {
|
|
829
|
-
e.property("value", context.selectOptions()[idx]);
|
|
830
|
-
if (context.value().indexOf(context.selectOptions()[idx]) !== -1 && context.value() !== "false") {
|
|
831
|
-
e.property("checked", true);
|
|
832
|
-
}
|
|
833
|
-
else {
|
|
834
|
-
e.property("checked", false);
|
|
835
|
-
}
|
|
836
|
-
});
|
|
837
|
-
};
|
|
838
|
-
return Radio;
|
|
839
|
-
}(common.HTMLWidget));
|
|
840
|
-
Radio.prototype._class += " form_Radio";
|
|
841
|
-
Radio.prototype.implements(api.IInput.prototype);
|
|
842
|
-
Radio.prototype.publish("selectOptions", [], "array", "Array of options used to fill a dropdown list");
|
|
843
|
-
|
|
844
|
-
var Range = /** @class */ (function (_super) {
|
|
845
|
-
__extends(Range, _super);
|
|
846
|
-
function Range() {
|
|
847
|
-
var _this = _super.call(this) || this;
|
|
848
|
-
_this._inputElement = [];
|
|
849
|
-
api.IInput.call(_this);
|
|
850
|
-
_this._tag = "div";
|
|
851
|
-
return _this;
|
|
852
|
-
}
|
|
853
|
-
Range.prototype.enter = function (domNode, element) {
|
|
854
|
-
_super.prototype.enter.call(this, domNode, element);
|
|
855
|
-
var context = this;
|
|
856
|
-
this._inputElement[0] = element.append("input").attr("type", "range");
|
|
857
|
-
this._inputElement[1] = element.append("input").attr("type", "number");
|
|
858
|
-
this._inputElement.forEach(function (e, idx) {
|
|
859
|
-
e.attr("name", context.name());
|
|
860
|
-
e.on("click", function (w) {
|
|
861
|
-
w.click(w);
|
|
862
|
-
});
|
|
863
|
-
e.on("blur", function (w) {
|
|
864
|
-
w.blur(w);
|
|
865
|
-
});
|
|
866
|
-
e.on("change", function (w) {
|
|
867
|
-
if (idx === 0) {
|
|
868
|
-
context._inputElement[1].property("value", common.rgb(context._inputElement[0].property("value")).toString());
|
|
869
|
-
context.value(context._inputElement[0].property("value"));
|
|
870
|
-
}
|
|
871
|
-
else {
|
|
872
|
-
context._inputElement[0].property("value", context._inputElement[1].property("value"));
|
|
873
|
-
context.value(common.rgb(context._inputElement[1].property("value")).toString());
|
|
874
|
-
}
|
|
875
|
-
w.change(w, true);
|
|
876
|
-
});
|
|
877
|
-
});
|
|
878
|
-
};
|
|
879
|
-
Range.prototype.update = function (domNode, element) {
|
|
880
|
-
_super.prototype.update.call(this, domNode, element);
|
|
881
|
-
this._inputElement[0].attr("type", "range");
|
|
882
|
-
this._inputElement[0].property("value", this.value());
|
|
883
|
-
this._inputElement[0].attr("min", this.low());
|
|
884
|
-
this._inputElement[0].attr("max", this.high());
|
|
885
|
-
this._inputElement[0].attr("step", this.step());
|
|
886
|
-
this._inputElement[1].attr("type", "number");
|
|
887
|
-
this._inputElement[1].property("value", this.value());
|
|
888
|
-
this._inputElement[1].attr("min", this.low());
|
|
889
|
-
this._inputElement[1].attr("max", this.high());
|
|
890
|
-
this._inputElement[1].attr("step", this.step());
|
|
891
|
-
};
|
|
892
|
-
Range.prototype.insertSelectOptions = function (optionsArr) {
|
|
893
|
-
var optionHTML = "";
|
|
894
|
-
if (optionsArr.length > 0) {
|
|
895
|
-
optionsArr.forEach(function (opt) {
|
|
896
|
-
var val = (opt instanceof Array ? opt[0] : opt);
|
|
897
|
-
var text = (opt instanceof Array ? (opt[1] ? opt[1] : opt[0]) : opt);
|
|
898
|
-
optionHTML += "<option value='" + val + "'>" + text + "</option>";
|
|
899
|
-
});
|
|
900
|
-
}
|
|
901
|
-
else {
|
|
902
|
-
optionHTML += "<option>selectOptions not set</option>";
|
|
903
|
-
}
|
|
904
|
-
this._inputElement[0].html(optionHTML);
|
|
905
|
-
};
|
|
906
|
-
return Range;
|
|
907
|
-
}(common.HTMLWidget));
|
|
908
|
-
Range.prototype._class += " form_Range";
|
|
909
|
-
Range.prototype.implements(api.IInput.prototype);
|
|
910
|
-
Range.prototype.publish("type", "text", "set", "Input type", ["html-color", "number", "checkbox", "button", "select", "textarea", "date", "text", "range", "search", "email", "time", "datetime"]);
|
|
911
|
-
Range.prototype.publish("selectOptions", [], "array", "Array of options used to fill a dropdown list");
|
|
912
|
-
Range.prototype.publish("low", null, "number", "Minimum value for Range input");
|
|
913
|
-
Range.prototype.publish("high", null, "number", "Maximum value for Range input");
|
|
914
|
-
Range.prototype.publish("step", null, "number", "Step value for Range input");
|
|
915
|
-
|
|
916
|
-
var Select = /** @class */ (function (_super) {
|
|
917
|
-
__extends(Select, _super);
|
|
918
|
-
function Select() {
|
|
919
|
-
var _this = _super.call(this) || this;
|
|
920
|
-
_this._inputElement = [];
|
|
921
|
-
api.IInput.call(_this);
|
|
922
|
-
_this._tag = "div";
|
|
923
|
-
return _this;
|
|
924
|
-
}
|
|
925
|
-
Select.prototype.enter = function (domNode, element) {
|
|
926
|
-
_super.prototype.enter.call(this, domNode, element);
|
|
927
|
-
var context = this;
|
|
928
|
-
this._inputElement[0] = element.append("select")
|
|
929
|
-
.attr("name", this.name())
|
|
930
|
-
.on("click", function (w) {
|
|
931
|
-
w.click(w);
|
|
932
|
-
})
|
|
933
|
-
.on("blur", function (w) {
|
|
934
|
-
w.blur(w);
|
|
935
|
-
})
|
|
936
|
-
.on("change", function (w) {
|
|
937
|
-
context.value([context._inputElement[0].property("value")]);
|
|
938
|
-
w.change(w, true);
|
|
939
|
-
});
|
|
940
|
-
};
|
|
941
|
-
Select.prototype.update = function (domNode, element) {
|
|
942
|
-
_super.prototype.update.call(this, domNode, element);
|
|
943
|
-
this.insertSelectOptions(this.selectOptions());
|
|
944
|
-
this._inputElement[0]
|
|
945
|
-
.property("value", this.value())
|
|
946
|
-
.style("max-width", this.maxWidth_exists() ? this.maxWidth() + "px" : null);
|
|
947
|
-
};
|
|
948
|
-
Select.prototype.insertSelectOptions = function (optionsArr) {
|
|
949
|
-
var optionHTML = "";
|
|
950
|
-
if (optionsArr.length > 0) {
|
|
951
|
-
optionsArr.forEach(function (opt) {
|
|
952
|
-
var val = (opt instanceof Array ? opt[0] : opt);
|
|
953
|
-
var text = (opt instanceof Array ? (opt[1] ? opt[1] : opt[0]) : opt);
|
|
954
|
-
optionHTML += "<option value='" + val + "'>" + text + "</option>";
|
|
955
|
-
});
|
|
956
|
-
}
|
|
957
|
-
else {
|
|
958
|
-
optionHTML += "<option>selectOptions not set</option>";
|
|
959
|
-
}
|
|
960
|
-
this._inputElement[0].html(optionHTML);
|
|
961
|
-
};
|
|
962
|
-
return Select;
|
|
963
|
-
}(common.HTMLWidget));
|
|
964
|
-
Select.prototype._class += " form_Select";
|
|
965
|
-
Select.prototype.implements(api.IInput.prototype);
|
|
966
|
-
Select.prototype.publish("selectOptions", [], "array", "Array of options used to fill a dropdown list");
|
|
967
|
-
Select.prototype.publish("maxWidth", 120, "number", "Width", null, { optional: true });
|
|
968
|
-
|
|
969
|
-
var css_248z = ".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{stroke-width:50px;stroke:transparent;cursor:crosshair;pointer-events:stroke}.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}";
|
|
970
|
-
styleInject(css_248z);
|
|
971
|
-
|
|
972
|
-
var Slider = /** @class */ (function (_super) {
|
|
973
|
-
__extends(Slider, _super);
|
|
974
|
-
function Slider() {
|
|
975
|
-
var _this = _super.call(this) || this;
|
|
976
|
-
_this.handleLeftPos = 0;
|
|
977
|
-
_this.handleRightPos = 0;
|
|
978
|
-
_this.handlePath = function (d) {
|
|
979
|
-
var e = +(d === "r");
|
|
980
|
-
var x = e ? 1 : -1;
|
|
981
|
-
var xOffset = this.allowRange() ? 0.5 : 0.0;
|
|
982
|
-
var y = 18;
|
|
983
|
-
var retVal = "M" + (xOffset * x) + "," + y +
|
|
984
|
-
"A6,6 0 0 " + e + " " + (6.5 * x) + "," + (y + 6) +
|
|
985
|
-
"V" + (2 * y - 6) +
|
|
986
|
-
"A6,6 0 0 " + e + " " + (xOffset * x) + "," + (2 * y);
|
|
987
|
-
if (this.allowRange()) {
|
|
988
|
-
retVal += "Z" +
|
|
989
|
-
"M" + (2.5 * x) + "," + (y + 8) +
|
|
990
|
-
"V" + (2 * y - 8) +
|
|
991
|
-
"M" + (4.5 * x) + "," + (y + 8) +
|
|
992
|
-
"V" + (2 * y - 8);
|
|
993
|
-
}
|
|
994
|
-
else {
|
|
995
|
-
retVal += "M" + (1 * x) + "," + (y + 8) +
|
|
996
|
-
"V" + (2 * y - 8);
|
|
997
|
-
}
|
|
998
|
-
return retVal;
|
|
999
|
-
};
|
|
1000
|
-
api.IInput.call(_this);
|
|
1001
|
-
return _this;
|
|
1002
|
-
}
|
|
1003
|
-
Slider.prototype.enter = function (domNode, element) {
|
|
1004
|
-
var _this = this;
|
|
1005
|
-
_super.prototype.enter.call(this, domNode, element);
|
|
1006
|
-
this.resize({ width: this.width(), height: 50 });
|
|
1007
|
-
this.xScale = common.scaleLinear()
|
|
1008
|
-
.clamp(true);
|
|
1009
|
-
this.slider = element.append("g")
|
|
1010
|
-
.attr("class", "slider");
|
|
1011
|
-
if (this.low() === null && this.high() === null) {
|
|
1012
|
-
if (this.lowDatetime() !== null && this.highDatetime() !== null) {
|
|
1013
|
-
var time_parser = common.timeParse(this.timePattern() ? this.timePattern() : "%Q");
|
|
1014
|
-
this.low(time_parser(this.lowDatetime()).getTime());
|
|
1015
|
-
this.high(time_parser(this.highDatetime()).getTime());
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
this.slider.append("line")
|
|
1019
|
-
.attr("class", "track")
|
|
1020
|
-
.select(function () { return this.parentNode.appendChild(this.cloneNode(true)); })
|
|
1021
|
-
.attr("class", "track-inset")
|
|
1022
|
-
.select(function () { return this.parentNode.appendChild(this.cloneNode(true)); })
|
|
1023
|
-
.attr("class", "track-overlay")
|
|
1024
|
-
.call(common.drag()
|
|
1025
|
-
.on("start", function () {
|
|
1026
|
-
var event = common.d3Event();
|
|
1027
|
-
_this.moveStartPos = event.x;
|
|
1028
|
-
_this.handleLeftStartPos = _this.handleLeftPos;
|
|
1029
|
-
_this.handleRightStartPos = _this.handleRightPos;
|
|
1030
|
-
if (_this.allowRange() && _this.handleLeftPos <= event.x && event.x <= _this.handleRightPos) {
|
|
1031
|
-
_this.moveMode = "both";
|
|
1032
|
-
}
|
|
1033
|
-
else if (Math.abs(event.x - _this.handleLeftPos) < Math.abs(event.x - _this.handleRightPos)) {
|
|
1034
|
-
_this.moveMode = "left";
|
|
1035
|
-
}
|
|
1036
|
-
else {
|
|
1037
|
-
_this.moveMode = "right";
|
|
1038
|
-
}
|
|
1039
|
-
_this.moveHandleTo(event.x);
|
|
1040
|
-
})
|
|
1041
|
-
.on("drag", function () {
|
|
1042
|
-
_this.moveHandleTo(common.d3Event().x);
|
|
1043
|
-
})
|
|
1044
|
-
.on("end", function () {
|
|
1045
|
-
_this.moveHandleTo(common.d3Event().x);
|
|
1046
|
-
_this.data([[_this.xScale.invert(_this.handleLeftPos), _this.xScale.invert(_this.handleRightPos)]]);
|
|
1047
|
-
_this.checkChangedValue();
|
|
1048
|
-
}));
|
|
1049
|
-
this.slider.insert("g", ".track-overlay")
|
|
1050
|
-
.attr("class", "ticks")
|
|
1051
|
-
.attr("transform", "translate(0, ".concat(this.fontSize() + (this.tickHeight() / 2), ")"));
|
|
1052
|
-
this.handleRight = this.slider.insert("path", ".track-overlay")
|
|
1053
|
-
.attr("class", "handle");
|
|
1054
|
-
this.handleLeft = this.slider.insert("path", ".track-overlay")
|
|
1055
|
-
.attr("class", "handle");
|
|
1056
|
-
};
|
|
1057
|
-
Slider.prototype.update = function (domNode, element) {
|
|
1058
|
-
_super.prototype.update.call(this, domNode, element);
|
|
1059
|
-
var context = this;
|
|
1060
|
-
this.xScale
|
|
1061
|
-
.domain([this.low(), this.high()])
|
|
1062
|
-
.range([0, this.width() - this.padding() * 2]);
|
|
1063
|
-
this.slider
|
|
1064
|
-
.attr("transform", "translate(" + (-this.width() / 2 + this.padding()) + "," + 0 + ")");
|
|
1065
|
-
this.slider.selectAll("line.track,line.track-inset,line.track-overlay")
|
|
1066
|
-
.attr("x1", this.xScale.range()[0])
|
|
1067
|
-
.attr("x2", this.xScale.range()[1]);
|
|
1068
|
-
var x_distance = (this.width() - (this.padding() * 2)) / (this.tickCount() - 1);
|
|
1069
|
-
var tick_text_arr = [];
|
|
1070
|
-
if (this.tickDateFormat() !== null && this.timePattern() !== null) {
|
|
1071
|
-
var Q_parser = common.timeParse("%Q");
|
|
1072
|
-
var time_formatter = common.timeFormat(this.tickDateFormat());
|
|
1073
|
-
var time_segment = (this.high() - this.low()) / (this.tickCount() - 1);
|
|
1074
|
-
for (var i = 0; i < this.tickCount(); i++) {
|
|
1075
|
-
var date_to_parse = "" + (this.low() + (time_segment * i));
|
|
1076
|
-
var parsed_date = Q_parser(date_to_parse);
|
|
1077
|
-
tick_text_arr.push(time_formatter(parsed_date));
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
else {
|
|
1081
|
-
var value_formatter = common.format(this.tickValueFormat());
|
|
1082
|
-
var value_segment = (this.high() - this.low()) / (this.tickCount() - 1);
|
|
1083
|
-
for (var i = 0; i < this.tickCount(); i++) {
|
|
1084
|
-
var tick_value = this.low() + (value_segment * i);
|
|
1085
|
-
tick_text_arr.push(value_formatter(tick_value));
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
var tickText = this.slider.selectAll("g.tick").data(tick_text_arr);
|
|
1089
|
-
var tickTextEnter = tickText.enter().append("g").attr("class", "tick");
|
|
1090
|
-
tickTextEnter.append("text").attr("class", "tick-text");
|
|
1091
|
-
tickTextEnter.append("line").attr("class", "tick-line");
|
|
1092
|
-
tickTextEnter
|
|
1093
|
-
.merge(tickText)
|
|
1094
|
-
.each(function (d, i) {
|
|
1095
|
-
var x = x_distance * i;
|
|
1096
|
-
common.select(this).select("text.tick-text")
|
|
1097
|
-
.style("font-size", context.fontSize())
|
|
1098
|
-
.attr("x", function () {
|
|
1099
|
-
if (i === 0)
|
|
1100
|
-
return x - 2;
|
|
1101
|
-
return i === context.tickCount() - 1 ? x + 2 : x;
|
|
1102
|
-
})
|
|
1103
|
-
.attr("y", context.tickHeight() + (context.tickOffset() / 2) + context.fontSize())
|
|
1104
|
-
.attr("text-basline", "text-before-edge")
|
|
1105
|
-
.attr("text-anchor", function () {
|
|
1106
|
-
if (i === 0)
|
|
1107
|
-
return "start";
|
|
1108
|
-
return i === context.tickCount() - 1 ? "end" : "middle";
|
|
1109
|
-
})
|
|
1110
|
-
.text(function () { return d; });
|
|
1111
|
-
common.select(this).select("line.tick-line")
|
|
1112
|
-
.attr("x1", x)
|
|
1113
|
-
.attr("x2", x)
|
|
1114
|
-
.attr("y1", context.tickOffset() - 1)
|
|
1115
|
-
.attr("y2", context.tickOffset() + context.tickHeight())
|
|
1116
|
-
.style("stroke", "#000")
|
|
1117
|
-
.style("stroke-width", 1);
|
|
1118
|
-
});
|
|
1119
|
-
this.slider.node().appendChild(this.handleRight.node());
|
|
1120
|
-
this.slider.node().appendChild(this.handleLeft.node());
|
|
1121
|
-
this.handleLeftPos = this.lowPos();
|
|
1122
|
-
this.handleRightPos = this.highPos();
|
|
1123
|
-
this.updateHandles();
|
|
1124
|
-
this.checkChangedValue();
|
|
1125
|
-
};
|
|
1126
|
-
Slider.prototype.checkChangedValue = function () {
|
|
1127
|
-
if (this.prevValue !== this.value() && typeof this.prevValue !== "undefined") {
|
|
1128
|
-
this.change(this);
|
|
1129
|
-
}
|
|
1130
|
-
this.prevValue = this.value();
|
|
1131
|
-
};
|
|
1132
|
-
Slider.prototype.updateHandles = function () {
|
|
1133
|
-
var _this = this;
|
|
1134
|
-
this.handleLeft
|
|
1135
|
-
.attr("transform", "translate(".concat(this.handleLeftPos, ", -28)"))
|
|
1136
|
-
.attr("d", function (d) { return _this.handlePath("l"); });
|
|
1137
|
-
this.handleRight
|
|
1138
|
-
.attr("transform", "translate(".concat(this.handleRightPos, ", -28)"))
|
|
1139
|
-
.attr("d", function (d) { return _this.handlePath("r"); });
|
|
1140
|
-
};
|
|
1141
|
-
Slider.prototype.lowPos = function () {
|
|
1142
|
-
var data = [[this.low(), this.high()]];
|
|
1143
|
-
if (this.data().length > 0 && typeof this.data()[0][0] === "number" && typeof this.data()[0][1] === "number") {
|
|
1144
|
-
data = this.data();
|
|
1145
|
-
}
|
|
1146
|
-
return this.xScale(data[0][0]);
|
|
1147
|
-
};
|
|
1148
|
-
Slider.prototype.highPos = function () {
|
|
1149
|
-
var data = [[this.low(), this.high()]];
|
|
1150
|
-
if (this.data().length > 0 && typeof this.data()[0][0] === "number" && typeof this.data()[0][1] === "number") {
|
|
1151
|
-
data = this.data();
|
|
1152
|
-
}
|
|
1153
|
-
return this.xScale(data[0][this.allowRange() ? 1 : 0]);
|
|
1154
|
-
};
|
|
1155
|
-
Slider.prototype.moveHandleTo = function (pos) {
|
|
1156
|
-
if (this.allowRange()) {
|
|
1157
|
-
switch (this.moveMode) {
|
|
1158
|
-
case "both":
|
|
1159
|
-
this.handleLeftPos = this.handleLeftStartPos + pos - this.moveStartPos;
|
|
1160
|
-
this.handleRightPos = this.handleRightStartPos + pos - this.moveStartPos;
|
|
1161
|
-
break;
|
|
1162
|
-
case "left":
|
|
1163
|
-
this.handleLeftPos = pos;
|
|
1164
|
-
if (this.handleLeftPos > this.handleRightPos) {
|
|
1165
|
-
this.handleRightPos = this.handleLeftPos;
|
|
1166
|
-
}
|
|
1167
|
-
break;
|
|
1168
|
-
case "right":
|
|
1169
|
-
this.handleRightPos = pos;
|
|
1170
|
-
if (this.handleRightPos < this.handleLeftPos) {
|
|
1171
|
-
this.handleLeftPos = this.handleRightPos;
|
|
1172
|
-
}
|
|
1173
|
-
break;
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
else {
|
|
1177
|
-
this.handleLeftPos = this.handleRightPos = pos;
|
|
1178
|
-
}
|
|
1179
|
-
this.handleLeftPos = this.constrain(this.handleLeftPos);
|
|
1180
|
-
this.handleRightPos = this.constrain(this.handleRightPos);
|
|
1181
|
-
this.value(this.allowRange() ? [this.xScale.invert(this.handleLeftPos), this.xScale.invert(this.handleRightPos)] : this.xScale.invert(this.handleLeftPos));
|
|
1182
|
-
this.updateHandles();
|
|
1183
|
-
};
|
|
1184
|
-
Slider.prototype.constrain = function (pos) {
|
|
1185
|
-
var range = this.xScale.range();
|
|
1186
|
-
if (pos < range[0])
|
|
1187
|
-
pos = range[0];
|
|
1188
|
-
if (pos > range[1])
|
|
1189
|
-
pos = range[1];
|
|
1190
|
-
return this.nearestStep(pos);
|
|
1191
|
-
};
|
|
1192
|
-
Slider.prototype.nearestStep = function (pos) {
|
|
1193
|
-
var value = this.xScale.invert(pos);
|
|
1194
|
-
return this.xScale(this.low() + Math.round((value - this.low()) / this.step()) * this.step());
|
|
1195
|
-
};
|
|
1196
|
-
return Slider;
|
|
1197
|
-
}(common.SVGWidget));
|
|
1198
|
-
Slider.prototype._class += " form_Slider";
|
|
1199
|
-
Slider.prototype.implements(api.IInput.prototype);
|
|
1200
|
-
Slider.prototype.publish("padding", 16, "number", "Outer Padding", null, { tags: ["Basic"] });
|
|
1201
|
-
Slider.prototype.publish("fontSize", 12, "number", "Font Size", null, { tags: ["Basic"] });
|
|
1202
|
-
Slider.prototype.publish("fontFamily", null, "string", "Font Name", null, { tags: ["Basic"] });
|
|
1203
|
-
Slider.prototype.publish("fontColor", null, "html-color", "Font Color", null, { tags: ["Basic"] });
|
|
1204
|
-
Slider.prototype.publish("allowRange", false, "boolean", "Allow Range Selection", null, { tags: ["Intermediate"] });
|
|
1205
|
-
Slider.prototype.publish("low", null, "number", "Low", null, { tags: ["Intermediate"] });
|
|
1206
|
-
Slider.prototype.publish("high", null, "number", "High", null, { tags: ["Intermediate"] });
|
|
1207
|
-
Slider.prototype.publish("step", 10, "number", "Step", null, { tags: ["Intermediate"] });
|
|
1208
|
-
Slider.prototype.publish("lowDatetime", null, "string", "Low", null, { tags: ["Intermediate"] });
|
|
1209
|
-
Slider.prototype.publish("highDatetime", null, "string", "High", null, { tags: ["Intermediate"] });
|
|
1210
|
-
Slider.prototype.publish("selectionLabel", "", "string", "Selection Label", null, { tags: ["Intermediate"] });
|
|
1211
|
-
Slider.prototype.publish("timePattern", "%Y-%m-%d", "string");
|
|
1212
|
-
Slider.prototype.publish("tickCount", 10, "number");
|
|
1213
|
-
Slider.prototype.publish("tickOffset", 5, "number");
|
|
1214
|
-
Slider.prototype.publish("tickHeight", 8, "number");
|
|
1215
|
-
Slider.prototype.publish("tickDateFormat", null, "string");
|
|
1216
|
-
Slider.prototype.publish("tickValueFormat", ",.0f", "string");
|
|
1217
|
-
var name = Slider.prototype.name;
|
|
1218
|
-
Slider.prototype.name = function (_) {
|
|
1219
|
-
var retVal = name.apply(this, arguments);
|
|
1220
|
-
if (arguments.length) {
|
|
1221
|
-
var val = _ instanceof Array ? _ : [_];
|
|
1222
|
-
common.SVGWidget.prototype.columns.call(this, val);
|
|
1223
|
-
}
|
|
1224
|
-
return retVal;
|
|
1225
|
-
};
|
|
1226
|
-
var value = Slider.prototype.value;
|
|
1227
|
-
Slider.prototype.value = function (_) {
|
|
1228
|
-
var retVal = value.apply(this, arguments);
|
|
1229
|
-
if (!arguments.length) {
|
|
1230
|
-
if (!this.allowRange()) {
|
|
1231
|
-
return common.SVGWidget.prototype.data.call(this)[0][0];
|
|
1232
|
-
}
|
|
1233
|
-
return common.SVGWidget.prototype.data.call(this)[0];
|
|
1234
|
-
}
|
|
1235
|
-
else {
|
|
1236
|
-
common.SVGWidget.prototype.data.call(this, [this.allowRange() ? _ : [_, _]]);
|
|
1237
|
-
}
|
|
1238
|
-
return retVal;
|
|
1239
|
-
};
|
|
1240
|
-
|
|
1241
|
-
var TextArea = /** @class */ (function (_super) {
|
|
1242
|
-
__extends(TextArea, _super);
|
|
1243
|
-
function TextArea() {
|
|
1244
|
-
var _this = _super.call(this) || this;
|
|
1245
|
-
_this._tag = "div";
|
|
1246
|
-
_this.type("textarea");
|
|
1247
|
-
return _this;
|
|
1248
|
-
}
|
|
1249
|
-
TextArea.prototype.enter = function (domNode, element) {
|
|
1250
|
-
_super.prototype.enter.call(this, domNode, element);
|
|
1251
|
-
};
|
|
1252
|
-
TextArea.prototype.calcHeight = function () {
|
|
1253
|
-
return Math.max(this.minHeight_exists() ? this.minHeight() : 0, this.height());
|
|
1254
|
-
};
|
|
1255
|
-
TextArea.prototype.update = function (domNode, element) {
|
|
1256
|
-
_super.prototype.update.call(this, domNode, element);
|
|
1257
|
-
this._inputElement[0]
|
|
1258
|
-
.attr("rows", this.rows())
|
|
1259
|
-
.attr("cols", this.cols())
|
|
1260
|
-
.attr("wrap", this.wrap())
|
|
1261
|
-
.attr("spellcheck", this.spellcheck())
|
|
1262
|
-
.style("height", this.calcHeight() + "px");
|
|
1263
|
-
};
|
|
1264
|
-
return TextArea;
|
|
1265
|
-
}(Input));
|
|
1266
|
-
TextArea.prototype._class += " form_TextArea";
|
|
1267
|
-
TextArea.prototype.publish("rows", null, "number", "Rows", null, { optional: true });
|
|
1268
|
-
TextArea.prototype.publish("cols", null, "number", "Columns", null, { optional: true });
|
|
1269
|
-
TextArea.prototype.publish("wrap", "off", "set", "Wrap", ["off", "on"]);
|
|
1270
|
-
TextArea.prototype.publish("minHeight", null, "number", "Minimum Height", null, { optional: true });
|
|
1271
|
-
TextArea.prototype.publish("spellcheck", null, "boolean", "Input spell checking", { optional: true });
|
|
1272
|
-
|
|
1273
|
-
exports.BUILD_VERSION = BUILD_VERSION;
|
|
1274
|
-
exports.Button = Button;
|
|
1275
|
-
exports.CheckBox = CheckBox;
|
|
1276
|
-
exports.ColorInput = ColorInput;
|
|
1277
|
-
exports.FieldForm = FieldForm;
|
|
1278
|
-
exports.Form = Form;
|
|
1279
|
-
exports.Input = Input;
|
|
1280
|
-
exports.InputRange = InputRange;
|
|
1281
|
-
exports.OnOff = OnOff;
|
|
1282
|
-
exports.PKG_NAME = PKG_NAME;
|
|
1283
|
-
exports.PKG_VERSION = PKG_VERSION;
|
|
1284
|
-
exports.Radio = Radio;
|
|
1285
|
-
exports.Range = Range;
|
|
1286
|
-
exports.Select = Select;
|
|
1287
|
-
exports.Slider = Slider;
|
|
1288
|
-
exports.TextArea = TextArea;
|
|
1289
|
-
|
|
1290
|
-
}));
|
|
198
|
+
|
|
199
|
+
.form_Slider .track {
|
|
200
|
+
stroke: #000;
|
|
201
|
+
stroke-opacity: 0.3;
|
|
202
|
+
stroke-width: 10px;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.form_Slider .track-inset {
|
|
206
|
+
stroke: #ddd;
|
|
207
|
+
stroke-width: 8px;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.form_Slider .track-overlay {
|
|
211
|
+
pointer-events: stroke;
|
|
212
|
+
stroke-width: 50px;
|
|
213
|
+
stroke: transparent;
|
|
214
|
+
cursor: crosshair;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.form_Slider .handle {
|
|
218
|
+
fill: #fff;
|
|
219
|
+
stroke: #000;
|
|
220
|
+
stroke-opacity: 0.5;
|
|
221
|
+
stroke-width: 1.25px;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.form_Slider .tick-line {
|
|
225
|
+
stroke: #000;
|
|
226
|
+
stroke-opacity: 0.5;
|
|
227
|
+
stroke-width: 1px;
|
|
228
|
+
shape-rendering: crispEdges;
|
|
229
|
+
}`,document.head.appendChild(a)}})();var p=class extends S{static{l(this,"Slider")}xScale;moveMode;moveStartPos;prevValue;slider;handleLeft;handleLeftPos=0;handleLeftStartPos;handleRight;handleRightPos=0;handleRightStartPos;constructor(){super(),$.call(this)}enter(i,e){if(super.enter(i,e),this.resize({width:this.width(),height:50}),this.xScale=pt().clamp(!0),this.slider=e.append("g").attr("class","slider"),this.low()===null&&this.high()===null&&this.lowDatetime()!==null&&this.highDatetime()!==null){let t=G(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(rt().on("start",()=>{let t=C();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(C().x)}).on("end",()=>{this.moveHandleTo(C().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(i,e){super.update(i,e);let t=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 n=(this.width()-this.padding()*2)/(this.tickCount()-1),o=[];if(this.tickDateFormat()!==null&&this.timePattern()!==null){let u=G("%Q"),h=ht(this.tickDateFormat()),d=(this.high()-this.low())/(this.tickCount()-1);for(let b=0;b<this.tickCount();b++){let k=""+(this.low()+d*b),P=u(k);o.push(h(P))}}else{let u=lt(this.tickValueFormat()),h=(this.high()-this.low())/(this.tickCount()-1);for(let d=0;d<this.tickCount();d++){let b=this.low()+h*d;o.push(u(b))}}let s=this.slider.selectAll("g.tick").data(o),r=s.enter().append("g").attr("class","tick");r.append("text").attr("class","tick-text"),r.append("line").attr("class","tick-line"),r.merge(s).each(function(u,h){let d=n*h;j(this).select("text.tick-text").style("font-size",t.fontSize()).attr("x",function(){return h===0?d-2:h===t.tickCount()-1?d+2:d}).attr("y",t.tickHeight()+t.tickOffset()/2+t.fontSize()).attr("text-basline","text-before-edge").attr("text-anchor",function(){return h===0?"start":h===t.tickCount()-1?"end":"middle"}).text(()=>u),j(this).select("line.tick-line").attr("x1",d).attr("x2",d).attr("y1",t.tickOffset()-1).attr("y2",t.tickOffset()+t.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()&&typeof this.prevValue<"u"&&this.change(this),this.prevValue=this.value()}updateHandles(){this.handleLeft.attr("transform",`translate(${this.handleLeftPos}, -28)`).attr("d",i=>this.handlePath("l")),this.handleRight.attr("transform",`translate(${this.handleRightPos}, -28)`).attr("d",i=>this.handlePath("r"))}lowPos(){let i=[[this.low(),this.high()]];return this.data().length>0&&typeof this.data()[0][0]=="number"&&typeof this.data()[0][1]=="number"&&(i=this.data()),this.xScale(i[0][0])}highPos(){let i=[[this.low(),this.high()]];return this.data().length>0&&typeof this.data()[0][0]=="number"&&typeof this.data()[0][1]=="number"&&(i=this.data()),this.xScale(i[0][this.allowRange()?1:0])}moveHandleTo(i){if(this.allowRange())switch(this.moveMode){case"both":this.handleLeftPos=this.handleLeftStartPos+i-this.moveStartPos,this.handleRightPos=this.handleRightStartPos+i-this.moveStartPos;break;case"left":this.handleLeftPos=i,this.handleLeftPos>this.handleRightPos&&(this.handleRightPos=this.handleLeftPos);break;case"right":this.handleRightPos=i,this.handleRightPos<this.handleLeftPos&&(this.handleLeftPos=this.handleRightPos);break}else this.handleLeftPos=this.handleRightPos=i;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(i){let e=this.xScale.range();return i<e[0]&&(i=e[0]),i>e[1]&&(i=e[1]),this.nearestStep(i)}nearestStep(i){let e=this.xScale.invert(i);return this.xScale(this.low()+Math.round((e-this.low())/this.step())*this.step())}handlePath=l(function(i){let e=+(i==="r"),t=e?1:-1,n=this.allowRange()?.5:0,o=18,s="M"+n*t+","+o+"A6,6 0 0 "+e+" "+6.5*t+","+(o+6)+"V"+(2*o-6)+"A6,6 0 0 "+e+" "+n*t+","+2*o;return this.allowRange()?s+="ZM"+2.5*t+","+(o+8)+"V"+(2*o-8)+"M"+4.5*t+","+(o+8)+"V"+(2*o-8):s+="M"+1*t+","+(o+8)+"V"+(2*o-8),s},"handlePath")};p.prototype._class+=" form_Slider";p.prototype.implements($.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");var ut=p.prototype.name;p.prototype.name=function(a){let i=ut.apply(this,arguments);if(arguments.length){let e=a instanceof Array?a:[a];S.prototype.columns.call(this,e)}return i};var ct=p.prototype.value;p.prototype.value=function(a){let i=ct.apply(this,arguments);if(arguments.length)S.prototype.data.call(this,[this.allowRange()?a:[a,a]]);else return this.allowRange()?S.prototype.data.call(this)[0]:S.prototype.data.call(this)[0][0];return i};var _=class extends f{static{l(this,"TextArea")}constructor(){super(),this._tag="div",this.type("textarea")}enter(i,e){super.enter(i,e)}calcHeight(){return Math.max(this.minHeight_exists()?this.minHeight():0,this.height())}update(i,e){super.update(i,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")}};_.prototype._class+=" form_TextArea";_.prototype.publish("rows",null,"number","Rows",null,{optional:!0});_.prototype.publish("cols",null,"number","Columns",null,{optional:!0});_.prototype.publish("wrap","off","set","Wrap",["off","on"]);_.prototype.publish("minHeight",null,"number","Minimum Height",null,{optional:!0});_.prototype.publish("spellcheck",null,"boolean","Input spell checking",{optional:!0});export{bt as BUILD_VERSION,x as Button,w as CheckBox,L as ColorInput,I as FieldForm,m as Form,f as Input,y as InputRange,c as OnOff,mt as PKG_NAME,ft as PKG_VERSION,F as Radio,g as Range,v as Select,p as Slider,_ as TextArea};
|
|
1291
230
|
//# sourceMappingURL=index.js.map
|