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