@hpcc-js/form 3.6.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +30 -31
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +2 -2
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +10 -10
- package/src/Form.ts +3 -3
- package/src/Slider.ts +6 -7
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IInput as e } from "@hpcc-js/api";
|
|
2
|
-
import { HTMLWidget as t, SVGWidget as n, WidgetArray as r,
|
|
2
|
+
import { HTMLWidget as t, SVGWidget as n, WidgetArray as r, drag as i, format as a, rgb as o, scaleLinear as s, select as c, timeFormat as l, timeParse as u } from "@hpcc-js/common";
|
|
3
3
|
//#region \0rolldown/runtime.js
|
|
4
|
-
var
|
|
4
|
+
var d = "@hpcc-js/form", f = "3.7.0", p = "3.35.0", Button = class extends t {
|
|
5
5
|
_inputElement = [];
|
|
6
6
|
constructor() {
|
|
7
7
|
super(), e.call(this), this._tag = "div";
|
|
@@ -79,7 +79,7 @@ var ColorInput = class extends t {
|
|
|
79
79
|
}), e.on("blur", function(e) {
|
|
80
80
|
e.blur(e);
|
|
81
81
|
}), e.on("change", function(e) {
|
|
82
|
-
t === 0 ? (n._inputElement[1].property("value",
|
|
82
|
+
t === 0 ? (n._inputElement[1].property("value", o(n._inputElement[0].property("value")).toString()), n.value(n._inputElement[0].property("value"))) : (n._inputElement[0].property("value", n._inputElement[1].property("value")), n.value(o(n._inputElement[1].property("value")).toString())), e.change(e, !0);
|
|
83
83
|
});
|
|
84
84
|
});
|
|
85
85
|
}
|
|
@@ -88,7 +88,7 @@ var ColorInput = class extends t {
|
|
|
88
88
|
let n = this;
|
|
89
89
|
this._inputElement.forEach(function(e) {
|
|
90
90
|
e.attr("name", n.name());
|
|
91
|
-
}), this._inputElement[0].attr("type", "text"), this._inputElement[1].attr("type", "color"), this._inputElement[0].property("value", this.value()), this._inputElement[1].property("value",
|
|
91
|
+
}), this._inputElement[0].attr("type", "text"), this._inputElement[1].attr("type", "color"), this._inputElement[0].property("value", this.value()), this._inputElement[1].property("value", o(this.value()).toString());
|
|
92
92
|
let r = this._inputElement[0].node().getBoundingClientRect();
|
|
93
93
|
this._inputElement[1].style("height", r.height - 2 + "px");
|
|
94
94
|
}
|
|
@@ -162,7 +162,7 @@ var Form = class extends t {
|
|
|
162
162
|
}
|
|
163
163
|
submit() {
|
|
164
164
|
let e = !0;
|
|
165
|
-
this.validate() && (e = this.checkValidation()),
|
|
165
|
+
this.validate() && (e = this.checkValidation()), (this.allowEmptyRequest() || this.inputs().some(function(e) {
|
|
166
166
|
return e._class.indexOf("WidgetArray") === -1 ? e.hasValue() : e.content().some(function(e) {
|
|
167
167
|
return e.hasValue();
|
|
168
168
|
});
|
|
@@ -189,8 +189,8 @@ var Form = class extends t {
|
|
|
189
189
|
}), t.length > 0 && (alert(t.join("\n")), e = !1), e;
|
|
190
190
|
}
|
|
191
191
|
enter(e, t) {
|
|
192
|
-
super.enter(e, t), t.on("submit", function() {
|
|
193
|
-
|
|
192
|
+
super.enter(e, t), t.on("submit", function(e) {
|
|
193
|
+
e.preventDefault();
|
|
194
194
|
}), this._placeholderElement.style("overflow", "auto");
|
|
195
195
|
let n = t.append("table");
|
|
196
196
|
this.tbody = n.append("tbody"), this.tfoot = n.append("tfoot"), this.btntd = this.tfoot.append("tr").append("td").attr("colspan", 2);
|
|
@@ -200,9 +200,9 @@ var Form = class extends t {
|
|
|
200
200
|
}, !0), new Button().value("Clear").on("click", function() {
|
|
201
201
|
r.clear();
|
|
202
202
|
}, !0)];
|
|
203
|
-
let
|
|
203
|
+
let i = r.btntd.append("div").style("float", "right");
|
|
204
204
|
this._controls.forEach(function(e) {
|
|
205
|
-
let t =
|
|
205
|
+
let t = i.append("span").style("float", "left");
|
|
206
206
|
e.target(t.node()).render();
|
|
207
207
|
});
|
|
208
208
|
}
|
|
@@ -210,7 +210,7 @@ var Form = class extends t {
|
|
|
210
210
|
super.update(e, t), this._maxCols = this.calcMaxColumns();
|
|
211
211
|
let i = this, a = this.tbody.selectAll("tr").data(this.inputs());
|
|
212
212
|
a.enter().append("tr").each(function(e, t) {
|
|
213
|
-
let a =
|
|
213
|
+
let a = c(this), o = e instanceof r ? e.content() : [e];
|
|
214
214
|
o.forEach(function(e, t) {
|
|
215
215
|
a.append("td").attr("class", "prompt");
|
|
216
216
|
let r = a.append("td").attr("class", "input");
|
|
@@ -231,7 +231,7 @@ var Form = class extends t {
|
|
|
231
231
|
});
|
|
232
232
|
});
|
|
233
233
|
}).merge(a).each(function(e, t) {
|
|
234
|
-
let n =
|
|
234
|
+
let n = c(this);
|
|
235
235
|
(e instanceof r ? e.content() : [e]).forEach(function(e, t) {
|
|
236
236
|
n.select("td.prompt").text(e.label() + ":");
|
|
237
237
|
});
|
|
@@ -462,7 +462,7 @@ var Range = class extends t {
|
|
|
462
462
|
}), e.on("blur", function(e) {
|
|
463
463
|
e.blur(e);
|
|
464
464
|
}), e.on("change", function(e) {
|
|
465
|
-
t === 0 ? (n._inputElement[1].property("value",
|
|
465
|
+
t === 0 ? (n._inputElement[1].property("value", o(n._inputElement[0].property("value")).toString()), n.value(n._inputElement[0].property("value"))) : (n._inputElement[0].property("value", n._inputElement[1].property("value")), n.value(o(n._inputElement[1].property("value")).toString())), e.change(e, !0);
|
|
466
466
|
});
|
|
467
467
|
});
|
|
468
468
|
}
|
|
@@ -543,21 +543,20 @@ var Slider = class extends n {
|
|
|
543
543
|
if (super.enter(e, t), this.resize({
|
|
544
544
|
width: this.width(),
|
|
545
545
|
height: 50
|
|
546
|
-
}), this.xScale =
|
|
547
|
-
let e =
|
|
546
|
+
}), this.xScale = s().clamp(!0), this.slider = t.append("g").attr("class", "slider"), this.low() === null && this.high() === null && this.lowDatetime() !== null && this.highDatetime() !== null) {
|
|
547
|
+
let e = u(this.timePattern() ? this.timePattern() : "%Q");
|
|
548
548
|
this.low(e(this.lowDatetime()).getTime()), this.high(e(this.highDatetime()).getTime());
|
|
549
549
|
}
|
|
550
550
|
this.slider.append("line").attr("class", "track").select(function() {
|
|
551
551
|
return this.parentNode.appendChild(this.cloneNode(!0));
|
|
552
552
|
}).attr("class", "track-inset").select(function() {
|
|
553
553
|
return this.parentNode.appendChild(this.cloneNode(!0));
|
|
554
|
-
}).attr("class", "track-overlay").call(
|
|
555
|
-
let e = i();
|
|
554
|
+
}).attr("class", "track-overlay").call(i().on("start", (e) => {
|
|
556
555
|
this.moveStartPos = e.x, this.handleLeftStartPos = this.handleLeftPos, this.handleRightStartPos = this.handleRightPos, this.moveMode = this.allowRange() && this.handleLeftPos <= e.x && e.x <= this.handleRightPos ? "both" : Math.abs(e.x - this.handleLeftPos) < Math.abs(e.x - this.handleRightPos) ? "left" : "right", this.moveHandleTo(e.x);
|
|
557
|
-
}).on("drag", () => {
|
|
558
|
-
this.moveHandleTo(
|
|
559
|
-
}).on("end", () => {
|
|
560
|
-
this.moveHandleTo(
|
|
556
|
+
}).on("drag", (e) => {
|
|
557
|
+
this.moveHandleTo(e.x);
|
|
558
|
+
}).on("end", (e) => {
|
|
559
|
+
this.moveHandleTo(e.x), this.data([[this.xScale.invert(this.handleLeftPos), this.xScale.invert(this.handleRightPos)]]), this.checkChangedValue();
|
|
561
560
|
})), this.slider.insert("g", ".track-overlay").attr("class", "ticks").attr("transform", `translate(0, ${this.fontSize() + this.tickHeight() / 2})`), this.handleRight = this.slider.insert("path", ".track-overlay").attr("class", "handle"), this.handleLeft = this.slider.insert("path", ".track-overlay").attr("class", "handle");
|
|
562
561
|
}
|
|
563
562
|
update(e, t) {
|
|
@@ -566,26 +565,26 @@ var Slider = class extends n {
|
|
|
566
565
|
this.xScale.domain([this.low(), this.high()]).range([0, this.width() - this.padding() * 2]), this.slider.attr("transform", "translate(" + (-this.width() / 2 + this.padding()) + ",0)"), this.slider.selectAll("line.track,line.track-inset,line.track-overlay").attr("x1", this.xScale.range()[0]).attr("x2", this.xScale.range()[1]);
|
|
567
566
|
let r = (this.width() - this.padding() * 2) / (this.tickCount() - 1), i = [];
|
|
568
567
|
if (this.tickDateFormat() !== null && this.timePattern() !== null) {
|
|
569
|
-
let e =
|
|
568
|
+
let e = u("%Q"), t = l(this.tickDateFormat()), n = (this.high() - this.low()) / (this.tickCount() - 1);
|
|
570
569
|
for (let r = 0; r < this.tickCount(); r++) {
|
|
571
570
|
let a = e("" + (this.low() + n * r));
|
|
572
571
|
i.push(t(a));
|
|
573
572
|
}
|
|
574
573
|
} else {
|
|
575
|
-
let e =
|
|
574
|
+
let e = a(this.tickValueFormat()), t = (this.high() - this.low()) / (this.tickCount() - 1);
|
|
576
575
|
for (let n = 0; n < this.tickCount(); n++) {
|
|
577
576
|
let r = this.low() + t * n;
|
|
578
577
|
i.push(e(r));
|
|
579
578
|
}
|
|
580
579
|
}
|
|
581
|
-
let
|
|
582
|
-
s.append("text").attr("class", "tick-text"), s.append("line").attr("class", "tick-line"), s.merge(
|
|
580
|
+
let o = this.slider.selectAll("g.tick").data(i), s = o.enter().append("g").attr("class", "tick");
|
|
581
|
+
s.append("text").attr("class", "tick-text"), s.append("line").attr("class", "tick-line"), s.merge(o).each(function(e, t) {
|
|
583
582
|
let i = r * t;
|
|
584
|
-
|
|
583
|
+
c(this).select("text.tick-text").style("font-size", n.fontSize()).attr("x", function() {
|
|
585
584
|
return t === 0 ? i - 2 : t === n.tickCount() - 1 ? i + 2 : i;
|
|
586
585
|
}).attr("y", n.tickHeight() + n.tickOffset() / 2 + n.fontSize()).attr("text-basline", "text-before-edge").attr("text-anchor", function() {
|
|
587
586
|
return t === 0 ? "start" : t === n.tickCount() - 1 ? "end" : "middle";
|
|
588
|
-
}).text(() => e),
|
|
587
|
+
}).text(() => e), c(this).select("line.tick-line").attr("x1", i).attr("x2", i).attr("y1", n.tickOffset() - 1).attr("y2", n.tickOffset() + n.tickHeight()).style("stroke", "#000").style("stroke-width", 1);
|
|
589
588
|
}), this.slider.node().appendChild(this.handleRight.node()), this.slider.node().appendChild(this.handleLeft.node()), this.handleLeftPos = this.lowPos(), this.handleRightPos = this.highPos(), this.updateHandles(), this.checkChangedValue();
|
|
590
589
|
}
|
|
591
590
|
checkChangedValue() {
|
|
@@ -629,18 +628,18 @@ var Slider = class extends n {
|
|
|
629
628
|
};
|
|
630
629
|
};
|
|
631
630
|
Slider.prototype._class += " form_Slider", Slider.prototype.implements(e.prototype), Slider.prototype.publish("padding", 16, "number", "Outer Padding", null, { tags: ["Basic"] }), Slider.prototype.publish("fontSize", 12, "number", "Font Size", null, { tags: ["Basic"] }), Slider.prototype.publish("fontFamily", null, "string", "Font Name", null, { tags: ["Basic"] }), Slider.prototype.publish("fontColor", null, "html-color", "Font Color", null, { tags: ["Basic"] }), Slider.prototype.publish("allowRange", !1, "boolean", "Allow Range Selection", null, { tags: ["Intermediate"] }), Slider.prototype.publish("low", null, "number", "Low", null, { tags: ["Intermediate"] }), Slider.prototype.publish("high", null, "number", "High", null, { tags: ["Intermediate"] }), Slider.prototype.publish("step", 10, "number", "Step", null, { tags: ["Intermediate"] }), Slider.prototype.publish("lowDatetime", null, "string", "Low", null, { tags: ["Intermediate"] }), Slider.prototype.publish("highDatetime", null, "string", "High", null, { tags: ["Intermediate"] }), Slider.prototype.publish("selectionLabel", "", "string", "Selection Label", null, { tags: ["Intermediate"] }), Slider.prototype.publish("timePattern", "%Y-%m-%d", "string"), Slider.prototype.publish("tickCount", 10, "number"), Slider.prototype.publish("tickOffset", 5, "number"), Slider.prototype.publish("tickHeight", 8, "number"), Slider.prototype.publish("tickDateFormat", null, "string"), Slider.prototype.publish("tickValueFormat", ",.0f", "string");
|
|
632
|
-
var
|
|
631
|
+
var m = Slider.prototype.name;
|
|
633
632
|
Slider.prototype.name = function(e) {
|
|
634
|
-
let t =
|
|
633
|
+
let t = m.apply(this, arguments);
|
|
635
634
|
if (arguments.length) {
|
|
636
635
|
let t = e instanceof Array ? e : [e];
|
|
637
636
|
n.prototype.columns.call(this, t);
|
|
638
637
|
}
|
|
639
638
|
return t;
|
|
640
639
|
};
|
|
641
|
-
var
|
|
640
|
+
var h = Slider.prototype.value;
|
|
642
641
|
Slider.prototype.value = function(e) {
|
|
643
|
-
let t =
|
|
642
|
+
let t = h.apply(this, arguments);
|
|
644
643
|
if (arguments.length) n.prototype.data.call(this, [this.allowRange() ? e : [e, e]]);
|
|
645
644
|
else return this.allowRange() ? n.prototype.data.call(this)[0] : n.prototype.data.call(this)[0][0];
|
|
646
645
|
return t;
|
|
@@ -663,7 +662,7 @@ var TextArea = class extends Input {
|
|
|
663
662
|
};
|
|
664
663
|
TextArea.prototype._class += " form_TextArea", TextArea.prototype.publish("rows", null, "number", "Rows", null, { optional: !0 }), TextArea.prototype.publish("cols", null, "number", "Columns", null, { optional: !0 }), TextArea.prototype.publish("wrap", "off", "set", "Wrap", ["off", "on"]), TextArea.prototype.publish("minHeight", null, "number", "Minimum Height", null, { optional: !0 }), TextArea.prototype.publish("spellcheck", null, "boolean", "Input spell checking", { optional: !0 });
|
|
665
664
|
//#endregion
|
|
666
|
-
export {
|
|
665
|
+
export { p as BUILD_VERSION, Button, CheckBox, ColorInput, FieldForm, Form, Input, InputRange, OnOff, d as PKG_NAME, f as PKG_VERSION, Radio, Range, Select, Slider, TextArea };
|
|
667
666
|
|
|
668
667
|
//# sourceMappingURL=index.js.map
|
|
669
668
|
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.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}/*$vite$:1*/`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();
|