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