@hpcc-js/form 3.2.11 → 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 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, rgb, WidgetArray, d3Event, select, SVGWidget, scaleLinear, timeParse, drag, timeFormat, format } from "@hpcc-js/common";
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
- const _Button = class _Button extends HTMLWidget {
9
- _inputElement = [];
10
- constructor() {
11
- super();
12
- IInput.call(this);
13
- this._tag = "div";
14
- }
15
- enter(domNode, element) {
16
- super.enter(domNode, element);
17
- const context = this;
18
- this._inputElement[0] = element.append("button").attr("name", this.name()).on("click", function(w) {
19
- w.click(w);
20
- }).on("blur", function(w) {
21
- w.blur(w);
22
- }).on("change", function(w) {
23
- context.value([context._inputElement[0].property("value")]);
24
- w.change(w, true);
25
- });
26
- }
27
- update(domNode, element) {
28
- super.update(domNode, element);
29
- this._inputElement[0].text(this.value());
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
- const _CheckBox = class _CheckBox extends HTMLWidget {
37
- _inputElement = [];
38
- constructor() {
39
- super();
40
- IInput.call(this);
41
- this._tag = "div";
42
- }
43
- enter(domNode, element) {
44
- super.enter(domNode, element);
45
- const context = this;
46
- const checkboxContainer = element.append("ul");
47
- if (!this.selectOptions().length) {
48
- this.selectOptions().push("");
49
- }
50
- this.selectOptions().forEach(function(val, idx) {
51
- context._inputElement[idx] = checkboxContainer.append("li").append("input").attr("type", "checkbox");
52
- context._inputElement[idx].node().insertAdjacentHTML("afterend", "<text>" + val + "</text>");
53
- });
54
- this._inputElement.forEach(function(e, idx) {
55
- e.attr("name", context.name());
56
- e.on("click", function(w) {
57
- w.click(w);
58
- });
59
- e.on("blur", function(w) {
60
- w.blur(w);
61
- });
62
- e.on("change", function(w) {
63
- const vals = [];
64
- context._inputElement.forEach(function(d) {
65
- if (d.property("checked")) {
66
- vals.push(d.property("value"));
67
- }
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") {
80
- e.property("checked", true);
81
- } else {
82
- e.property("checked", false);
83
- }
84
- });
85
- }
86
- insertSelectOptions(optionsArr) {
87
- let optionHTML = "";
88
- if (optionsArr.length > 0) {
89
- optionsArr.forEach(function(opt) {
90
- const val = opt instanceof Array ? opt[0] : opt;
91
- const text = opt instanceof Array ? opt[1] ? opt[1] : opt[0] : opt;
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
- const _ColorInput = class _ColorInput extends HTMLWidget {
106
- _inputElement = [];
107
- constructor() {
108
- super();
109
- IInput.call(this);
110
- this._tag = "div";
111
- }
112
- enter(domNode, element) {
113
- super.enter(domNode, element);
114
- const context = this;
115
- this._inputElement[0] = element.append("input").attr("type", "text");
116
- this._inputElement[0].classed("color-text", true);
117
- this._inputElement[1] = element.append("input").attr("type", "color");
118
- this._inputElement.forEach(function(e, idx) {
119
- e.on("click", function(w) {
120
- w.click(w);
121
- });
122
- e.on("blur", function(w) {
123
- w.blur(w);
124
- });
125
- e.on("change", function(w) {
126
- if (idx === 0) {
127
- context._inputElement[1].property("value", rgb(context._inputElement[0].property("value")).toString());
128
- context.value(context._inputElement[0].property("value"));
129
- } else {
130
- context._inputElement[0].property("value", context._inputElement[1].property("value"));
131
- context.value(rgb(context._inputElement[1].property("value")).toString());
132
- }
133
- w.change(w, true);
134
- });
135
- });
136
- }
137
- update(domNode, element) {
138
- super.update(domNode, element);
139
- const context = this;
140
- this._inputElement.forEach(function(e) {
141
- e.attr("name", context.name());
142
- });
143
- this._inputElement[0].attr("type", "text");
144
- this._inputElement[1].attr("type", "color");
145
- this._inputElement[0].property("value", this.value());
146
- this._inputElement[1].property("value", rgb(this.value()).toString());
147
- const bbox = this._inputElement[0].node().getBoundingClientRect();
148
- this._inputElement[1].style("height", bbox.height - 2 + "px");
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
- const _Form = class _Form extends HTMLWidget {
156
- tbody;
157
- tfoot;
158
- btntd;
159
- _controls;
160
- _maxCols;
161
- constructor() {
162
- super();
163
- this._tag = "form";
164
- }
165
- data(_) {
166
- if (!arguments.length) {
167
- const retVal = [];
168
- this.inputsForEach(function(input) {
169
- retVal.push(input.value());
170
- });
171
- return retVal;
172
- } else {
173
- this.inputsForEach(function(input, idx) {
174
- if (_ && _.length > idx) {
175
- input.value(_[idx]).render();
176
- }
177
- });
178
- }
179
- return this;
180
- }
181
- inputsForEach(callback, scope) {
182
- let idx = 0;
183
- this.inputs().forEach(function(inp) {
184
- const inpArray = inp instanceof WidgetArray ? inp.content() : [inp];
185
- inpArray.forEach(function(inp2) {
186
- if (scope) {
187
- callback.call(scope, inp2, idx++);
188
- } else {
189
- callback(inp2, idx++);
190
- }
191
- });
192
- });
193
- }
194
- inputsMap() {
195
- const retVal = {};
196
- this.inputs().forEach(function(inp) {
197
- retVal[inp.name()] = inp;
198
- });
199
- return retVal;
200
- }
201
- calcMaxColumns() {
202
- let retVal = 0;
203
- this.inputs().forEach(function(inputWidget) {
204
- const inputWidgetArray = inputWidget instanceof WidgetArray ? inputWidget.content() : [inputWidget];
205
- if (inputWidgetArray.length > retVal) {
206
- retVal = inputWidgetArray.length;
207
- }
208
- });
209
- return retVal;
210
- }
211
- values(_) {
212
- if (!arguments.length) {
213
- const dataArr = {};
214
- this.inputsForEach(function(inp) {
215
- const type = inp.type ? inp.type() : "text";
216
- const value2 = inp.value();
217
- if (value2 || !this.omitBlank()) {
218
- switch (type) {
219
- case "checkbox":
220
- dataArr[inp.name()] = inp.value_exists() ? !!inp.value() : void 0;
221
- break;
222
- case "number":
223
- const v = inp.value();
224
- dataArr[inp.name()] = v === "" ? void 0 : +v;
225
- break;
226
- case "text":
227
- default:
228
- dataArr[inp.name()] = inp.value_exists() ? inp.value() : void 0;
229
- break;
230
- }
231
- }
232
- }, this);
233
- return dataArr;
234
- } else {
235
- this.inputsForEach(function(inp) {
236
- if (_[inp.name()]) {
237
- inp.value(_[inp.name()]);
238
- } else if (this.omitBlank()) {
239
- inp.value("");
240
- }
241
- }, this);
242
- }
243
- return this;
244
- }
245
- submit() {
246
- let isValid = true;
247
- if (this.validate()) {
248
- isValid = this.checkValidation();
249
- }
250
- if (!this.allowEmptyRequest() && !this.inputs().some(function(w) {
251
- if (w._class.indexOf("WidgetArray") !== -1) {
252
- return w.content().some(function(wa) {
253
- return wa.hasValue();
254
- });
255
- }
256
- return w.hasValue();
257
- })) {
258
- return;
259
- }
260
- this.click(isValid ? this.values() : null, null, isValid);
261
- }
262
- clear() {
263
- this.inputsForEach(function(inp) {
264
- switch (inp.classID()) {
265
- case "form_Slider":
266
- if (inp.allowRange()) {
267
- inp.value([inp.low(), inp.low()]).render();
268
- } else {
269
- inp.value(inp.low()).render();
270
- }
271
- break;
272
- case "form_CheckBox":
273
- inp.value(false).render();
274
- break;
275
- case "form_Button":
276
- break;
277
- default:
278
- inp.value(void 0).render();
279
- break;
280
- }
281
- });
282
- }
283
- checkValidation() {
284
- let ret = true;
285
- const msgArr = [];
286
- this.inputsForEach(function(inp) {
287
- if (!inp.isValid()) {
288
- msgArr.push("'" + inp.label() + "' value is invalid.");
289
- }
290
- });
291
- if (msgArr.length > 0) {
292
- alert(msgArr.join("\n"));
293
- ret = false;
294
- }
295
- return ret;
296
- }
297
- enter(domNode, element) {
298
- super.enter(domNode, element);
299
- element.on("submit", function() {
300
- d3Event().preventDefault();
301
- });
302
- this._placeholderElement.style("overflow", "auto");
303
- const table = element.append("table");
304
- this.tbody = table.append("tbody");
305
- this.tfoot = table.append("tfoot");
306
- this.btntd = this.tfoot.append("tr").append("td").attr("colspan", 2);
307
- const context = this;
308
- this._controls = [
309
- new Button().classed({ default: true }).value("Submit").on("click", function() {
310
- context.submit();
311
- }, true),
312
- new Button().value("Clear").on("click", function() {
313
- context.clear();
314
- }, true)
315
- ];
316
- const rightJust = context.btntd.append("div").style("float", "right");
317
- this._controls.forEach(function(w) {
318
- const leftJust = rightJust.append("span").style("float", "left");
319
- w.target(leftJust.node()).render();
320
- });
321
- }
322
- update(domNode, element) {
323
- super.update(domNode, element);
324
- this._maxCols = this.calcMaxColumns();
325
- const context = this;
326
- const rows = this.tbody.selectAll("tr").data(this.inputs());
327
- rows.enter().append("tr").each(function(inputWidget, i) {
328
- const element2 = select(this);
329
- const inputWidgetArray = inputWidget instanceof WidgetArray ? inputWidget.content() : [inputWidget];
330
- inputWidgetArray.forEach(function(inputWidget2, idx) {
331
- element2.append("td").attr("class", "prompt");
332
- const input = element2.append("td").attr("class", "input");
333
- if (idx === inputWidgetArray.length - 1 && inputWidgetArray.length < context._maxCols) {
334
- input.attr("colspan", (context._maxCols - inputWidgetArray.length + 1) * 2);
335
- }
336
- inputWidget2.target(input.node()).render();
337
- if (inputWidget2 instanceof SVGWidget) {
338
- const bbox = inputWidget2.element().node().getBBox();
339
- input.style("height", bbox.height + "px");
340
- inputWidget2.resize().render();
341
- }
342
- if (inputWidget2._inputElement instanceof Array) {
343
- inputWidget2._inputElement.forEach(function(e) {
344
- e.on("keyup.form", function(w) {
345
- setTimeout(function() {
346
- context._controls[0].disable(!context.allowEmptyRequest() && !context.inputs().some(function(w2) {
347
- if (w2._class.indexOf("WidgetArray") !== -1) {
348
- return w2.content().some(function(wa) {
349
- return wa.hasValue();
350
- });
351
- }
352
- return w2.hasValue();
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
- const _Input = class _Input extends HTMLWidget {
408
- _inputElement = [];
409
- _labelElement = [];
410
- constructor() {
411
- super();
412
- IInput.call(this);
413
- this._tag = "div";
414
- }
415
- checked(_) {
416
- if (!arguments.length) return this._inputElement[0] ? this._inputElement[0].property("checked") : false;
417
- if (this._inputElement[0]) {
418
- this._inputElement[0].property("checked", _);
419
- }
420
- return this;
421
- }
422
- enter(domNode, element) {
423
- super.enter(domNode, element);
424
- this._labelElement[0] = element.append("label").attr("for", this.id() + "_input").style("visibility", this.inlineLabel_exists() ? "visible" : "hidden");
425
- const context = this;
426
- switch (this.type()) {
427
- case "button":
428
- this._inputElement[0] = element.append("button").attr("id", this.id() + "_input");
429
- break;
430
- case "textarea":
431
- this._inputElement[0] = element.append("textarea").attr("id", this.id() + "_input");
432
- break;
433
- default:
434
- this._inputElement[0] = element.append("input").attr("id", this.id() + "_input").attr("type", this.type());
435
- break;
436
- }
437
- this._inputElement.forEach(function(e, idx) {
438
- e.attr("name", context.name());
439
- e.on("click", function(w) {
440
- w.click(w);
441
- });
442
- e.on("blur", function(w) {
443
- w.blur(w);
444
- });
445
- e.on("change", function(w) {
446
- context.value([e.property("value")]);
447
- w.change(w, true);
448
- });
449
- e.on("keyup", function(w) {
450
- context.value([e.property("value")]);
451
- w.change(w, false);
452
- });
453
- });
454
- }
455
- update(domNode, element) {
456
- super.update(domNode, element);
457
- this._labelElement[0].style("visibility", this.inlineLabel_exists() ? "visible" : "hidden").text(this.inlineLabel());
458
- switch (this.type()) {
459
- case "button":
460
- this._inputElement[0].text(this.value());
461
- break;
462
- case "textarea":
463
- this._inputElement[0].property("value", this.value());
464
- break;
465
- default:
466
- this._inputElement[0].attr("type", this.type());
467
- this._inputElement[0].property("value", this.value());
468
- break;
469
- }
470
- }
471
- // IInput Events ---
472
- blur(w) {
473
- }
474
- keyup(w) {
475
- }
476
- focus(w) {
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", ["string", "number", "boolean", "date", "time", "hidden", "nested", "button", "checkbox", "text", "textarea", "search", "email", "datetime"]);
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
- const _FieldForm = class _FieldForm extends Form {
492
- constructor() {
493
- super();
494
- this._tag = "form";
495
- }
496
- fields(_) {
497
- const retVal = super.fields.apply(this, arguments);
498
- if (arguments.length) {
499
- const inpMap = this.inputsMap();
500
- this.inputs(_.map(
501
- (f) => inpMap[f.id()] || new Input().name(f.id()).label(f.label()).type(f.type())
502
- ));
503
- }
504
- return retVal;
505
- }
506
- data(_) {
507
- if (!arguments.length) return super.data();
508
- super.data(_[0]);
509
- if (_[0]) {
510
- const inputs = this.inputs();
511
- const __lparam = _[0][this.columns().length];
512
- let i = 0;
513
- for (const key in __lparam) {
514
- inputs[i].name(key);
515
- ++i;
516
- }
517
- }
518
- return this;
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
- const _InputRange = class _InputRange extends HTMLWidget {
525
- _inputElement = [];
526
- _labelElement = [];
527
- _rangeData = [];
528
- constructor() {
529
- super();
530
- IInput.call(this);
531
- this._tag = "div";
532
- }
533
- enter(domNode, element) {
534
- super.enter(domNode, element);
535
- this._labelElement[0] = element.append("label").attr("for", this.id() + "_input").style("visibility", this.inlineLabel_exists() ? "visible" : "hidden");
536
- this._inputElement.push(element.append("input").attr("id", this.id() + "_input_min").attr("type", this.type()));
537
- this._inputElement.push(element.append("input").attr("id", this.id() + "_input_max").attr("type", this.type()));
538
- const context = this;
539
- this._inputElement.forEach(function(e, idx) {
540
- e.attr("name", context.name());
541
- e.on("click", function(w) {
542
- w.click(w);
543
- });
544
- e.on("blur", function(w) {
545
- w.blur(w);
546
- });
547
- e.on("change", function(w) {
548
- context._rangeData[idx] = e.property("value");
549
- context.value(context._rangeData);
550
- w.change(w, true);
551
- });
552
- });
553
- }
554
- update(domNode, element) {
555
- super.update(domNode, element);
556
- this._labelElement[0].style("visibility", this.inlineLabel_exists() ? "visible" : "hidden").text(this.inlineLabel());
557
- this._rangeData = this.value();
558
- this._inputElement.forEach(function(e, idx) {
559
- e.attr("type", this.type()).property("value", this._rangeData.length > idx ? this._rangeData[idx] : "");
560
- }, this);
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", ["number", "date", "text", "time", "datetime", "hidden"]);
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
- const _OnOff = class _OnOff extends HTMLWidget {
571
- _inputElement = [];
572
- _input;
573
- constructor() {
574
- super();
575
- IInput.call(this);
576
- this._tag = "div";
577
- }
578
- enter(domNode, element) {
579
- super.enter(domNode, element);
580
- element.classed("onoffswitch", true);
581
- const context = this;
582
- this._input = element.append("input").attr("class", "onoffswitch-checkbox").attr("type", "checkbox").attr("id", this.id() + "_onOff").on("click", function(w) {
583
- w.click(w);
584
- }).on("blur", function(w) {
585
- w.blur(w);
586
- }).on("change", function(w) {
587
- const vals = [];
588
- context._inputElement.forEach(function(d, idx) {
589
- if (d.property("checked")) {
590
- vals.push(d.property("value"));
591
- }
592
- });
593
- context.value(vals);
594
- w.change(w, true);
595
- });
596
- const label = element.append("label").attr("class", "onoffswitch-label").attr("for", this.id() + "_onOff");
597
- const inner = label.append("div").attr("class", "onoffswitch-inner");
598
- inner.append("div").attr("class", "onoffswitch-offText").style("padding-right", this.containerRadius() / 2 + "px").text(this.offText());
599
- 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());
600
- label.append("div").attr("class", "onoffswitch-switch");
601
- }
602
- update(domNode, element) {
603
- super.update(domNode, element);
604
- this._input.attr("name", this.name());
605
- element.style("margin-left", this.marginLeft() + "px").style("margin-bottom", this.marginBottom() + "px").style("width", this.minWidth() + "px");
606
- const _switch_size = this.minHeight() - this.gutter() * 4;
607
- 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");
608
- element.select(".onoffswitch-inner").style("min-height", this.minHeight() + "px");
609
- element.select(".onoffswitch-label").style("border-radius", this.containerRadius() + "px");
610
- element.select(".onoffswitch-offText").style("color", this.offFontColor()).style("background-color", this.offColor());
611
- element.select(".onoffswitch-onText").style("color", this.onFontColor()).style("background-color", this.onColor());
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
- const _Radio = class _Radio extends HTMLWidget {
632
- _inputElement = [];
633
- constructor() {
634
- super();
635
- IInput.call(this);
636
- this._tag = "div";
637
- }
638
- enter(domNode, element) {
639
- super.enter(domNode, element);
640
- const context = this;
641
- const radioContainer = element.append("ul");
642
- if (!this.selectOptions().length) {
643
- this.selectOptions().push("");
644
- }
645
- this.selectOptions().forEach(function(val, idx) {
646
- context._inputElement[idx] = radioContainer.append("li").append("input").attr("type", "radio");
647
- context._inputElement[idx].node().insertAdjacentHTML("afterend", "<text>" + val + "</text>");
648
- });
649
- this._inputElement.forEach(function(e, idx) {
650
- e.attr("name", context.name());
651
- e.on("click", function(w) {
652
- w.click(w);
653
- });
654
- e.on("blur", function(w) {
655
- w.blur(w);
656
- });
657
- e.on("change", function(w) {
658
- context.value([e.property("value")]);
659
- w.change(w, true);
660
- });
661
- });
662
- }
663
- update(domNode, element) {
664
- super.update(domNode, element);
665
- const context = this;
666
- this._inputElement.forEach(function(e, idx) {
667
- e.property("value", context.selectOptions()[idx]);
668
- if (context.value().indexOf(context.selectOptions()[idx]) !== -1 && context.value() !== "false") {
669
- e.property("checked", true);
670
- } else {
671
- e.property("checked", false);
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
- const _Range = class _Range extends HTMLWidget {
682
- _inputElement = [];
683
- constructor() {
684
- super();
685
- IInput.call(this);
686
- this._tag = "div";
687
- }
688
- enter(domNode, element) {
689
- super.enter(domNode, element);
690
- const context = this;
691
- this._inputElement[0] = element.append("input").attr("type", "range");
692
- this._inputElement[1] = element.append("input").attr("type", "number");
693
- this._inputElement.forEach(function(e, idx) {
694
- e.attr("name", context.name());
695
- e.on("click", function(w) {
696
- w.click(w);
697
- });
698
- e.on("blur", function(w) {
699
- w.blur(w);
700
- });
701
- e.on("change", function(w) {
702
- if (idx === 0) {
703
- context._inputElement[1].property("value", rgb(context._inputElement[0].property("value")).toString());
704
- context.value(context._inputElement[0].property("value"));
705
- } else {
706
- context._inputElement[0].property("value", context._inputElement[1].property("value"));
707
- context.value(rgb(context._inputElement[1].property("value")).toString());
708
- }
709
- w.change(w, true);
710
- });
711
- });
712
- }
713
- update(domNode, element) {
714
- super.update(domNode, element);
715
- this._inputElement[0].attr("type", "range");
716
- this._inputElement[0].property("value", this.value());
717
- this._inputElement[0].attr("min", this.low());
718
- this._inputElement[0].attr("max", this.high());
719
- this._inputElement[0].attr("step", this.step());
720
- this._inputElement[1].attr("type", "number");
721
- this._inputElement[1].property("value", this.value());
722
- this._inputElement[1].attr("min", this.low());
723
- this._inputElement[1].attr("max", this.high());
724
- this._inputElement[1].attr("step", this.step());
725
- }
726
- insertSelectOptions(optionsArr) {
727
- let optionHTML = "";
728
- if (optionsArr.length > 0) {
729
- optionsArr.forEach(function(opt) {
730
- const val = opt instanceof Array ? opt[0] : opt;
731
- const text = opt instanceof Array ? opt[1] ? opt[1] : opt[0] : opt;
732
- optionHTML += "<option value='" + val + "'>" + text + "</option>";
733
- });
734
- } else {
735
- optionHTML += "<option>selectOptions not set</option>";
736
- }
737
- this._inputElement[0].html(optionHTML);
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", ["html-color", "number", "checkbox", "button", "select", "textarea", "date", "text", "range", "search", "email", "time", "datetime"]);
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
- const _Select = class _Select extends HTMLWidget {
750
- _inputElement = [];
751
- constructor() {
752
- super();
753
- IInput.call(this);
754
- this._tag = "div";
755
- }
756
- enter(domNode, element) {
757
- super.enter(domNode, element);
758
- const context = this;
759
- this._inputElement[0] = element.append("select").attr("name", this.name()).on("click", function(w) {
760
- w.click(w);
761
- }).on("blur", function(w) {
762
- w.blur(w);
763
- }).on("change", function(w) {
764
- context.value([context._inputElement[0].property("value")]);
765
- w.change(w, true);
766
- });
767
- }
768
- update(domNode, element) {
769
- super.update(domNode, element);
770
- this.insertSelectOptions(this.selectOptions());
771
- this._inputElement[0].property("value", this.value()).style("max-width", this.maxWidth_exists() ? this.maxWidth() + "px" : null);
772
- }
773
- insertSelectOptions(optionsArr) {
774
- let optionHTML = "";
775
- if (optionsArr.length > 0) {
776
- optionsArr.forEach(function(opt) {
777
- const val = opt instanceof Array ? opt[0] : opt;
778
- const text = opt instanceof Array ? opt[1] ? opt[1] : opt[0] : opt;
779
- optionHTML += "<option value='" + val + "'>" + text + "</option>";
780
- });
781
- } else {
782
- optionHTML += "<option>selectOptions not set</option>";
783
- }
784
- this._inputElement[0].html(optionHTML);
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
- const _Slider = class _Slider extends SVGWidget {
794
- xScale;
795
- moveMode;
796
- moveStartPos;
797
- prevValue;
798
- slider;
799
- handleLeft;
800
- handleLeftPos = 0;
801
- handleLeftStartPos;
802
- handleRight;
803
- handleRightPos = 0;
804
- handleRightStartPos;
805
- constructor() {
806
- super();
807
- IInput.call(this);
808
- }
809
- enter(domNode, element) {
810
- super.enter(domNode, element);
811
- this.resize({ width: this.width(), height: 50 });
812
- this.xScale = scaleLinear().clamp(true);
813
- this.slider = element.append("g").attr("class", "slider");
814
- if (this.low() === null && this.high() === null) {
815
- if (this.lowDatetime() !== null && this.highDatetime() !== null) {
816
- const time_parser = timeParse(this.timePattern() ? this.timePattern() : "%Q");
817
- this.low(time_parser(this.lowDatetime()).getTime());
818
- this.high(time_parser(this.highDatetime()).getTime());
819
- }
820
- }
821
- this.slider.append("line").attr("class", "track").select(function() {
822
- return this.parentNode.appendChild(this.cloneNode(true));
823
- }).attr("class", "track-inset").select(function() {
824
- return this.parentNode.appendChild(this.cloneNode(true));
825
- }).attr("class", "track-overlay").call(drag().on("start", () => {
826
- const event = d3Event();
827
- this.moveStartPos = event.x;
828
- this.handleLeftStartPos = this.handleLeftPos;
829
- this.handleRightStartPos = this.handleRightPos;
830
- if (this.allowRange() && this.handleLeftPos <= event.x && event.x <= this.handleRightPos) {
831
- this.moveMode = "both";
832
- } else if (Math.abs(event.x - this.handleLeftPos) < Math.abs(event.x - this.handleRightPos)) {
833
- this.moveMode = "left";
834
- } else {
835
- this.moveMode = "right";
836
- }
837
- this.moveHandleTo(event.x);
838
- }).on("drag", () => {
839
- this.moveHandleTo(d3Event().x);
840
- }).on("end", () => {
841
- this.moveHandleTo(d3Event().x);
842
- this.data([[this.xScale.invert(this.handleLeftPos), this.xScale.invert(this.handleRightPos)]]);
843
- this.checkChangedValue();
844
- }));
845
- this.slider.insert("g", ".track-overlay").attr("class", "ticks").attr("transform", `translate(0, ${this.fontSize() + this.tickHeight() / 2})`);
846
- this.handleRight = this.slider.insert("path", ".track-overlay").attr("class", "handle");
847
- this.handleLeft = this.slider.insert("path", ".track-overlay").attr("class", "handle");
848
- }
849
- update(domNode, element) {
850
- super.update(domNode, element);
851
- const context = this;
852
- this.xScale.domain([this.low(), this.high()]).range([0, this.width() - this.padding() * 2]);
853
- this.slider.attr("transform", "translate(" + (-this.width() / 2 + this.padding()) + ",0)");
854
- this.slider.selectAll("line.track,line.track-inset,line.track-overlay").attr("x1", this.xScale.range()[0]).attr("x2", this.xScale.range()[1]);
855
- const x_distance = (this.width() - this.padding() * 2) / (this.tickCount() - 1);
856
- const tick_text_arr = [];
857
- if (this.tickDateFormat() !== null && this.timePattern() !== null) {
858
- const Q_parser = timeParse("%Q");
859
- const time_formatter = timeFormat(this.tickDateFormat());
860
- const time_segment = (this.high() - this.low()) / (this.tickCount() - 1);
861
- for (let i = 0; i < this.tickCount(); i++) {
862
- const date_to_parse = "" + (this.low() + time_segment * i);
863
- const parsed_date = Q_parser(date_to_parse);
864
- tick_text_arr.push(time_formatter(parsed_date));
865
- }
866
- } else {
867
- const value_formatter = format(this.tickValueFormat());
868
- const value_segment = (this.high() - this.low()) / (this.tickCount() - 1);
869
- for (let i = 0; i < this.tickCount(); i++) {
870
- const tick_value = this.low() + value_segment * i;
871
- tick_text_arr.push(value_formatter(tick_value));
872
- }
873
- }
874
- const tickText = this.slider.selectAll("g.tick").data(tick_text_arr);
875
- const tickTextEnter = tickText.enter().append("g").attr("class", "tick");
876
- tickTextEnter.append("text").attr("class", "tick-text");
877
- tickTextEnter.append("line").attr("class", "tick-line");
878
- tickTextEnter.merge(tickText).each(function(d, i) {
879
- const x = x_distance * i;
880
- select(this).select("text.tick-text").style("font-size", context.fontSize()).attr("x", function() {
881
- if (i === 0) return x - 2;
882
- return i === context.tickCount() - 1 ? x + 2 : x;
883
- }).attr("y", context.tickHeight() + context.tickOffset() / 2 + context.fontSize()).attr("text-basline", "text-before-edge").attr("text-anchor", function() {
884
- if (i === 0) return "start";
885
- return i === context.tickCount() - 1 ? "end" : "middle";
886
- }).text(() => d);
887
- 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);
888
- });
889
- this.slider.node().appendChild(this.handleRight.node());
890
- this.slider.node().appendChild(this.handleLeft.node());
891
- this.handleLeftPos = this.lowPos();
892
- this.handleRightPos = this.highPos();
893
- this.updateHandles();
894
- this.checkChangedValue();
895
- }
896
- checkChangedValue() {
897
- if (this.prevValue !== this.value() && typeof this.prevValue !== "undefined") {
898
- this.change(this);
899
- }
900
- this.prevValue = this.value();
901
- }
902
- updateHandles() {
903
- this.handleLeft.attr("transform", `translate(${this.handleLeftPos}, -28)`).attr("d", (d) => this.handlePath("l"));
904
- this.handleRight.attr("transform", `translate(${this.handleRightPos}, -28)`).attr("d", (d) => this.handlePath("r"));
905
- }
906
- lowPos() {
907
- let data = [[this.low(), this.high()]];
908
- if (this.data().length > 0 && typeof this.data()[0][0] === "number" && typeof this.data()[0][1] === "number") {
909
- data = this.data();
910
- }
911
- return this.xScale(data[0][0]);
912
- }
913
- highPos() {
914
- let data = [[this.low(), this.high()]];
915
- if (this.data().length > 0 && typeof this.data()[0][0] === "number" && typeof this.data()[0][1] === "number") {
916
- data = this.data();
917
- }
918
- return this.xScale(data[0][this.allowRange() ? 1 : 0]);
919
- }
920
- moveHandleTo(pos) {
921
- if (this.allowRange()) {
922
- switch (this.moveMode) {
923
- case "both":
924
- this.handleLeftPos = this.handleLeftStartPos + pos - this.moveStartPos;
925
- this.handleRightPos = this.handleRightStartPos + pos - this.moveStartPos;
926
- break;
927
- case "left":
928
- this.handleLeftPos = pos;
929
- if (this.handleLeftPos > this.handleRightPos) {
930
- this.handleRightPos = this.handleLeftPos;
931
- }
932
- break;
933
- case "right":
934
- this.handleRightPos = pos;
935
- if (this.handleRightPos < this.handleLeftPos) {
936
- this.handleLeftPos = this.handleRightPos;
937
- }
938
- break;
939
- }
940
- } else {
941
- this.handleLeftPos = this.handleRightPos = pos;
942
- }
943
- this.handleLeftPos = this.constrain(this.handleLeftPos);
944
- this.handleRightPos = this.constrain(this.handleRightPos);
945
- this.value(this.allowRange() ? [this.xScale.invert(this.handleLeftPos), this.xScale.invert(this.handleRightPos)] : this.xScale.invert(this.handleLeftPos));
946
- this.updateHandles();
947
- }
948
- constrain(pos) {
949
- const range = this.xScale.range();
950
- if (pos < range[0]) pos = range[0];
951
- if (pos > range[1]) pos = range[1];
952
- return this.nearestStep(pos);
953
- }
954
- nearestStep(pos) {
955
- const value2 = this.xScale.invert(pos);
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
- const name = Slider.prototype.name;
941
+ var name = Slider.prototype.name;
994
942
  Slider.prototype.name = function(_) {
995
- const retVal = name.apply(this, arguments);
996
- if (arguments.length) {
997
- const val = _ instanceof Array ? _ : [_];
998
- SVGWidget.prototype.columns.call(this, val);
999
- }
1000
- return retVal;
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
- const value = Slider.prototype.value;
950
+ var value = Slider.prototype.value;
1003
951
  Slider.prototype.value = function(_) {
1004
- const retVal = value.apply(this, arguments);
1005
- if (!arguments.length) {
1006
- if (!this.allowRange()) {
1007
- return SVGWidget.prototype.data.call(this)[0][0];
1008
- }
1009
- return SVGWidget.prototype.data.call(this)[0];
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
- const _TextArea = class _TextArea extends Input {
1016
- constructor() {
1017
- super();
1018
- this._tag = "div";
1019
- this.type("textarea");
1020
- }
1021
- enter(domNode, element) {
1022
- super.enter(domNode, element);
1023
- }
1024
- calcHeight() {
1025
- return Math.max(this.minHeight_exists() ? this.minHeight() : 0, this.height());
1026
- }
1027
- update(domNode, element) {
1028
- super.update(domNode, element);
1029
- this._inputElement[0].attr("rows", this.rows()).attr("cols", this.cols()).attr("wrap", this.wrap()).attr("spellcheck", this.spellcheck()).style("height", this.calcHeight() + "px");
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
- export {
1041
- BUILD_VERSION,
1042
- Button,
1043
- CheckBox,
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)}}();