@hpcc-js/form 3.4.4 → 3.4.6

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/src/Range.ts CHANGED
@@ -1,116 +1,116 @@
1
- import { IInput } from "@hpcc-js/api";
2
- import { HTMLWidget } from "@hpcc-js/common";
3
- import { rgb as d3Rgb } from "d3-color";
4
-
5
- import "../src/Input.css";
6
-
7
- export class Range extends HTMLWidget {
8
- _inputElement = [];
9
-
10
- constructor() {
11
- super();
12
-
13
- IInput.call(this);
14
-
15
- this._tag = "div";
16
- }
17
-
18
- enter(domNode, element) {
19
- super.enter(domNode, element);
20
-
21
- const context = this;
22
-
23
- this._inputElement[0] = element.append("input").attr("type", "range");
24
- this._inputElement[1] = element.append("input").attr("type", "number");
25
-
26
- this._inputElement.forEach(function (e, idx) {
27
- e.attr("name", context.name());
28
- e.on("click", function (w) {
29
- w.click(w);
30
- });
31
- e.on("blur", function (w) {
32
- w.blur(w);
33
- });
34
- e.on("change", function (w) {
35
- if (idx === 0) {
36
- context._inputElement[1].property("value", d3Rgb(context._inputElement[0].property("value")).toString());
37
- context.value(context._inputElement[0].property("value"));
38
- } else {
39
- context._inputElement[0].property("value", context._inputElement[1].property("value"));
40
- context.value(d3Rgb(context._inputElement[1].property("value")).toString());
41
- }
42
- w.change(w, true);
43
- });
44
- });
45
- }
46
-
47
- update(domNode, element) {
48
- super.update(domNode, element);
49
-
50
- this._inputElement[0].attr("type", "range");
51
- this._inputElement[0].property("value", this.value());
52
- this._inputElement[0].attr("min", this.low());
53
- this._inputElement[0].attr("max", this.high());
54
- this._inputElement[0].attr("step", this.step());
55
- this._inputElement[1].attr("type", "number");
56
- this._inputElement[1].property("value", this.value());
57
- this._inputElement[1].attr("min", this.low());
58
- this._inputElement[1].attr("max", this.high());
59
- this._inputElement[1].attr("step", this.step());
60
- }
61
-
62
- insertSelectOptions(optionsArr) {
63
- let optionHTML = "";
64
- if (optionsArr.length > 0) {
65
- optionsArr.forEach(function (opt) {
66
- const val = (opt instanceof Array ? opt[0] : opt);
67
- const text = (opt instanceof Array ? (opt[1] ? opt[1] : opt[0]) : opt);
68
- optionHTML += "<option value='" + val + "'>" + text + "</option>";
69
- });
70
- } else {
71
- optionHTML += "<option>selectOptions not set</option>";
72
- }
73
- this._inputElement[0].html(optionHTML);
74
- }
75
- }
76
- Range.prototype._class += " form_Range";
77
- Range.prototype.implements(IInput.prototype);
78
-
79
- export interface Range {
80
- // IInput ---
81
- name(): string;
82
- name(_: string): this;
83
- name_exists(): boolean;
84
- label(): string;
85
- label(_: string): this;
86
- label_exists(): boolean;
87
- value(): any;
88
- value(_: any): this;
89
- value_exists(): boolean;
90
- validate(): string;
91
- validate(_: string): this;
92
- validate_exists(): boolean;
93
-
94
- // Properties ---
95
- type(): string;
96
- type(_: string): this;
97
- type_exists(): boolean;
98
- selectOptions(): any[];
99
- selectOptions(_: any[]): this;
100
- selectOptions_exists(): boolean;
101
- low(): number;
102
- low(_: number): this;
103
- low_exists(): boolean;
104
- high(): number;
105
- high(_: number): this;
106
- high_exists(): boolean;
107
- step(): number;
108
- step(_: number): this;
109
- step_exists(): boolean;
110
- }
111
-
112
- Range.prototype.publish("type", "text", "set", "Input type", ["html-color", "number", "checkbox", "button", "select", "textarea", "date", "text", "range", "search", "email", "time", "datetime"]);
113
- Range.prototype.publish("selectOptions", [], "array", "Array of options used to fill a dropdown list");
114
- Range.prototype.publish("low", null, "number", "Minimum value for Range input");
115
- Range.prototype.publish("high", null, "number", "Maximum value for Range input");
116
- Range.prototype.publish("step", null, "number", "Step value for Range input");
1
+ import { IInput } from "@hpcc-js/api";
2
+ import { HTMLWidget } from "@hpcc-js/common";
3
+ import { rgb as d3Rgb } from "d3-color";
4
+
5
+ import "../src/Input.css";
6
+
7
+ export class Range extends HTMLWidget {
8
+ _inputElement = [];
9
+
10
+ constructor() {
11
+ super();
12
+
13
+ IInput.call(this);
14
+
15
+ this._tag = "div";
16
+ }
17
+
18
+ enter(domNode, element) {
19
+ super.enter(domNode, element);
20
+
21
+ const context = this;
22
+
23
+ this._inputElement[0] = element.append("input").attr("type", "range");
24
+ this._inputElement[1] = element.append("input").attr("type", "number");
25
+
26
+ this._inputElement.forEach(function (e, idx) {
27
+ e.attr("name", context.name());
28
+ e.on("click", function (w) {
29
+ w.click(w);
30
+ });
31
+ e.on("blur", function (w) {
32
+ w.blur(w);
33
+ });
34
+ e.on("change", function (w) {
35
+ if (idx === 0) {
36
+ context._inputElement[1].property("value", d3Rgb(context._inputElement[0].property("value")).toString());
37
+ context.value(context._inputElement[0].property("value"));
38
+ } else {
39
+ context._inputElement[0].property("value", context._inputElement[1].property("value"));
40
+ context.value(d3Rgb(context._inputElement[1].property("value")).toString());
41
+ }
42
+ w.change(w, true);
43
+ });
44
+ });
45
+ }
46
+
47
+ update(domNode, element) {
48
+ super.update(domNode, element);
49
+
50
+ this._inputElement[0].attr("type", "range");
51
+ this._inputElement[0].property("value", this.value());
52
+ this._inputElement[0].attr("min", this.low());
53
+ this._inputElement[0].attr("max", this.high());
54
+ this._inputElement[0].attr("step", this.step());
55
+ this._inputElement[1].attr("type", "number");
56
+ this._inputElement[1].property("value", this.value());
57
+ this._inputElement[1].attr("min", this.low());
58
+ this._inputElement[1].attr("max", this.high());
59
+ this._inputElement[1].attr("step", this.step());
60
+ }
61
+
62
+ insertSelectOptions(optionsArr) {
63
+ let optionHTML = "";
64
+ if (optionsArr.length > 0) {
65
+ optionsArr.forEach(function (opt) {
66
+ const val = (opt instanceof Array ? opt[0] : opt);
67
+ const text = (opt instanceof Array ? (opt[1] ? opt[1] : opt[0]) : opt);
68
+ optionHTML += "<option value='" + val + "'>" + text + "</option>";
69
+ });
70
+ } else {
71
+ optionHTML += "<option>selectOptions not set</option>";
72
+ }
73
+ this._inputElement[0].html(optionHTML);
74
+ }
75
+ }
76
+ Range.prototype._class += " form_Range";
77
+ Range.prototype.implements(IInput.prototype);
78
+
79
+ export interface Range {
80
+ // IInput ---
81
+ name(): string;
82
+ name(_: string): this;
83
+ name_exists(): boolean;
84
+ label(): string;
85
+ label(_: string): this;
86
+ label_exists(): boolean;
87
+ value(): any;
88
+ value(_: any): this;
89
+ value_exists(): boolean;
90
+ validate(): string;
91
+ validate(_: string): this;
92
+ validate_exists(): boolean;
93
+
94
+ // Properties ---
95
+ type(): string;
96
+ type(_: string): this;
97
+ type_exists(): boolean;
98
+ selectOptions(): any[];
99
+ selectOptions(_: any[]): this;
100
+ selectOptions_exists(): boolean;
101
+ low(): number;
102
+ low(_: number): this;
103
+ low_exists(): boolean;
104
+ high(): number;
105
+ high(_: number): this;
106
+ high_exists(): boolean;
107
+ step(): number;
108
+ step(_: number): this;
109
+ step_exists(): boolean;
110
+ }
111
+
112
+ Range.prototype.publish("type", "text", "set", "Input type", ["html-color", "number", "checkbox", "button", "select", "textarea", "date", "text", "range", "search", "email", "time", "datetime"]);
113
+ Range.prototype.publish("selectOptions", [], "array", "Array of options used to fill a dropdown list");
114
+ Range.prototype.publish("low", null, "number", "Minimum value for Range input");
115
+ Range.prototype.publish("high", null, "number", "Maximum value for Range input");
116
+ Range.prototype.publish("step", null, "number", "Step value for Range input");
package/src/Select.ts CHANGED
@@ -1,89 +1,89 @@
1
- import { IInput } from "@hpcc-js/api";
2
- import { HTMLWidget } from "@hpcc-js/common";
3
-
4
- import "../src/Input.css";
5
-
6
- export class Select extends HTMLWidget {
7
- _inputElement = [];
8
-
9
- constructor() {
10
- super();
11
-
12
- IInput.call(this);
13
-
14
- this._tag = "div";
15
- }
16
-
17
- enter(domNode, element) {
18
- super.enter(domNode, element);
19
-
20
- const context = this;
21
-
22
- this._inputElement[0] = element.append("select")
23
- .attr("name", this.name())
24
- .on("click", function (w) {
25
- w.click(w);
26
- })
27
- .on("blur", function (w) {
28
- w.blur(w);
29
- })
30
- .on("change", function (w) {
31
- context.value([context._inputElement[0].property("value")]);
32
- w.change(w, true);
33
- })
34
- ;
35
- }
36
-
37
- update(domNode, element) {
38
- super.update(domNode, element);
39
-
40
- this.insertSelectOptions(this.selectOptions());
41
- this._inputElement[0]
42
- .property("value", this.value())
43
- .style("max-width", this.maxWidth_exists() ? this.maxWidth() + "px" : null)
44
- ;
45
- }
46
-
47
- insertSelectOptions(optionsArr) {
48
- let optionHTML = "";
49
- if (optionsArr.length > 0) {
50
- optionsArr.forEach(function (opt) {
51
- const val = (opt instanceof Array ? opt[0] : opt);
52
- const text = (opt instanceof Array ? (opt[1] ? opt[1] : opt[0]) : opt);
53
- optionHTML += "<option value='" + val + "'>" + text + "</option>";
54
- });
55
- } else {
56
- optionHTML += "<option>selectOptions not set</option>";
57
- }
58
- this._inputElement[0].html(optionHTML);
59
- }
60
- }
61
- Select.prototype._class += " form_Select";
62
- Select.prototype.implements(IInput.prototype);
63
-
64
- export interface Select {
65
- // IInput ---
66
- name(): string;
67
- name(_: string): this;
68
- name_exists(): boolean;
69
- label(): string;
70
- label(_: string): this;
71
- label_exists(): boolean;
72
- value(): any;
73
- value(_: any): this;
74
- value_exists(): boolean;
75
- validate(): string;
76
- validate(_: string): this;
77
- validate_exists(): boolean;
78
-
79
- // Properties ---
80
- selectOptions(): any[];
81
- selectOptions(_: any[]): this;
82
- selectOptions_exists(): boolean;
83
- maxWidth(): number;
84
- maxWidth(_: number): this;
85
- maxWidth_exists(): boolean;
86
- }
87
-
88
- Select.prototype.publish("selectOptions", [], "array", "Array of options used to fill a dropdown list");
89
- Select.prototype.publish("maxWidth", 120, "number", "Width", null, { optional: true });
1
+ import { IInput } from "@hpcc-js/api";
2
+ import { HTMLWidget } from "@hpcc-js/common";
3
+
4
+ import "../src/Input.css";
5
+
6
+ export class Select extends HTMLWidget {
7
+ _inputElement = [];
8
+
9
+ constructor() {
10
+ super();
11
+
12
+ IInput.call(this);
13
+
14
+ this._tag = "div";
15
+ }
16
+
17
+ enter(domNode, element) {
18
+ super.enter(domNode, element);
19
+
20
+ const context = this;
21
+
22
+ this._inputElement[0] = element.append("select")
23
+ .attr("name", this.name())
24
+ .on("click", function (w) {
25
+ w.click(w);
26
+ })
27
+ .on("blur", function (w) {
28
+ w.blur(w);
29
+ })
30
+ .on("change", function (w) {
31
+ context.value([context._inputElement[0].property("value")]);
32
+ w.change(w, true);
33
+ })
34
+ ;
35
+ }
36
+
37
+ update(domNode, element) {
38
+ super.update(domNode, element);
39
+
40
+ this.insertSelectOptions(this.selectOptions());
41
+ this._inputElement[0]
42
+ .property("value", this.value())
43
+ .style("max-width", this.maxWidth_exists() ? this.maxWidth() + "px" : null)
44
+ ;
45
+ }
46
+
47
+ insertSelectOptions(optionsArr) {
48
+ let optionHTML = "";
49
+ if (optionsArr.length > 0) {
50
+ optionsArr.forEach(function (opt) {
51
+ const val = (opt instanceof Array ? opt[0] : opt);
52
+ const text = (opt instanceof Array ? (opt[1] ? opt[1] : opt[0]) : opt);
53
+ optionHTML += "<option value='" + val + "'>" + text + "</option>";
54
+ });
55
+ } else {
56
+ optionHTML += "<option>selectOptions not set</option>";
57
+ }
58
+ this._inputElement[0].html(optionHTML);
59
+ }
60
+ }
61
+ Select.prototype._class += " form_Select";
62
+ Select.prototype.implements(IInput.prototype);
63
+
64
+ export interface Select {
65
+ // IInput ---
66
+ name(): string;
67
+ name(_: string): this;
68
+ name_exists(): boolean;
69
+ label(): string;
70
+ label(_: string): this;
71
+ label_exists(): boolean;
72
+ value(): any;
73
+ value(_: any): this;
74
+ value_exists(): boolean;
75
+ validate(): string;
76
+ validate(_: string): this;
77
+ validate_exists(): boolean;
78
+
79
+ // Properties ---
80
+ selectOptions(): any[];
81
+ selectOptions(_: any[]): this;
82
+ selectOptions_exists(): boolean;
83
+ maxWidth(): number;
84
+ maxWidth(_: number): this;
85
+ maxWidth_exists(): boolean;
86
+ }
87
+
88
+ Select.prototype.publish("selectOptions", [], "array", "Array of options used to fill a dropdown list");
89
+ Select.prototype.publish("maxWidth", 120, "number", "Width", null, { optional: true });
package/src/Slider.css CHANGED
@@ -1,41 +1,41 @@
1
- .form_Slider .ticks {
2
- font: 10px sans-serif;
3
- }
4
-
5
- .form_Slider .track,
6
- .form_Slider .track-inset,
7
- .form_Slider .track-overlay {
8
- stroke-linecap: round;
9
- }
10
-
11
- .form_Slider .track {
12
- stroke: #000;
13
- stroke-opacity: 0.3;
14
- stroke-width: 10px;
15
- }
16
-
17
- .form_Slider .track-inset {
18
- stroke: #ddd;
19
- stroke-width: 8px;
20
- }
21
-
22
- .form_Slider .track-overlay {
23
- pointer-events: stroke;
24
- stroke-width: 50px;
25
- stroke: transparent;
26
- cursor: crosshair;
27
- }
28
-
29
- .form_Slider .handle {
30
- fill: #fff;
31
- stroke: #000;
32
- stroke-opacity: 0.5;
33
- stroke-width: 1.25px;
34
- }
35
-
36
- .form_Slider .tick-line {
37
- stroke: #000;
38
- stroke-opacity: 0.5;
39
- stroke-width: 1px;
40
- shape-rendering: crispEdges;
1
+ .form_Slider .ticks {
2
+ font: 10px sans-serif;
3
+ }
4
+
5
+ .form_Slider .track,
6
+ .form_Slider .track-inset,
7
+ .form_Slider .track-overlay {
8
+ stroke-linecap: round;
9
+ }
10
+
11
+ .form_Slider .track {
12
+ stroke: #000;
13
+ stroke-opacity: 0.3;
14
+ stroke-width: 10px;
15
+ }
16
+
17
+ .form_Slider .track-inset {
18
+ stroke: #ddd;
19
+ stroke-width: 8px;
20
+ }
21
+
22
+ .form_Slider .track-overlay {
23
+ pointer-events: stroke;
24
+ stroke-width: 50px;
25
+ stroke: transparent;
26
+ cursor: crosshair;
27
+ }
28
+
29
+ .form_Slider .handle {
30
+ fill: #fff;
31
+ stroke: #000;
32
+ stroke-opacity: 0.5;
33
+ stroke-width: 1.25px;
34
+ }
35
+
36
+ .form_Slider .tick-line {
37
+ stroke: #000;
38
+ stroke-opacity: 0.5;
39
+ stroke-width: 1px;
40
+ shape-rendering: crispEdges;
41
41
  }