@hpcc-js/form 3.3.9 → 3.3.10

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/OnOff.ts CHANGED
@@ -1,159 +1,159 @@
1
- import { IInput } from "@hpcc-js/api";
2
- import { HTMLWidget } from "@hpcc-js/common";
3
-
4
- import "../src/OnOff.css";
5
-
6
- export class OnOff extends HTMLWidget {
7
- _inputElement = [];
8
- _input;
9
-
10
- constructor() {
11
- super();
12
- IInput.call(this);
13
-
14
- this._tag = "div";
15
- }
16
-
17
- enter(domNode, element) {
18
- super.enter(domNode, element);
19
- element.classed("onoffswitch", true);
20
- const context = this;
21
- this._input = element.append("input")
22
- .attr("class", "onoffswitch-checkbox")
23
- .attr("type", "checkbox")
24
- .attr("id", this.id() + "_onOff")
25
- .on("click", function (w) {
26
- w.click(w);
27
- })
28
- .on("blur", function (w) {
29
- w.blur(w);
30
- })
31
- .on("change", function (w) {
32
- const vals = [];
33
- context._inputElement.forEach(function (d, idx) {
34
- if (d.property("checked")) {
35
- vals.push(d.property("value"));
36
- }
37
- });
38
- context.value(vals);
39
- w.change(w, true);
40
- })
41
- ;
42
- const label = element.append("label")
43
- .attr("class", "onoffswitch-label")
44
- .attr("for", this.id() + "_onOff")
45
- ;
46
- const inner = label.append("div")
47
- .attr("class", "onoffswitch-inner")
48
- ;
49
- inner.append("div")
50
- .attr("class", "onoffswitch-offText")
51
- .style("padding-right", (this.containerRadius() / 2) + "px")
52
- .text(this.offText())
53
- ;
54
- inner.append("div")
55
- .attr("class", "onoffswitch-onText")
56
- .style("padding-left", (this.containerRadius() / 2) + "px")
57
- .style("width", `calc(100% - ${(this.containerRadius() / 2)}px)`)
58
- .text(this.onText())
59
- ;
60
- label.append("div")
61
- .attr("class", "onoffswitch-switch")
62
- ;
63
- }
64
-
65
- update(domNode, element) {
66
- super.update(domNode, element);
67
- this._input
68
- .attr("name", this.name())
69
- ;
70
- element
71
- .style("margin-left", this.marginLeft() + "px")
72
- .style("margin-bottom", this.marginBottom() + "px")
73
- .style("width", this.minWidth() + "px")
74
- ;
75
-
76
- const _switch_size = this.minHeight() - (this.gutter() * 4);
77
-
78
- element.select(".onoffswitch-switch")
79
- .style("height", _switch_size + "px")
80
- .style("width", _switch_size + "px")
81
- .style("top", (this.gutter() * 2) + 1 + "px")
82
- .style("border-radius", this.switchRadius() + "px")
83
- ;
84
- element.select(".onoffswitch-inner")
85
- .style("min-height", this.minHeight() + "px")
86
- ;
87
- element.select(".onoffswitch-label")
88
- .style("border-radius", this.containerRadius() + "px")
89
- ;
90
- element.select(".onoffswitch-offText")
91
- .style("color", this.offFontColor())
92
- .style("background-color", this.offColor())
93
- ;
94
- element.select(".onoffswitch-onText")
95
- .style("color", this.onFontColor())
96
- .style("background-color", this.onColor())
97
- ;
98
- }
99
- }
100
- OnOff.prototype._class += " form_OnOff";
101
- export interface OnOff {
102
- // IInput ---
103
- name(): string;
104
- name(_: string): this;
105
- name_exists(): boolean;
106
- label(): string;
107
- label(_: string): this;
108
- label_exists(): boolean;
109
- value(): any;
110
- value(_: any): this;
111
- value_exists(): boolean;
112
- validate(): string;
113
- validate(_: string): this;
114
- validate_exists(): boolean;
115
-
116
- // Properties ---
117
- marginLeft(): number;
118
- marginLeft(_: number): this;
119
- marginBottom(): number;
120
- marginBottom(_: number): this;
121
- minWidth(): number;
122
- minWidth(_: number): this;
123
- minHeight(): number;
124
- minHeight(_: number): this;
125
- gutter(): number;
126
- gutter(_: number): this;
127
- offText(): string;
128
- offText(_: string): this;
129
- onText(): string;
130
- onText(_: string): this;
131
- switchRadius(): number;
132
- switchRadius(_: number): this;
133
- containerRadius(): number;
134
- containerRadius(_: number): this;
135
- offColor(): string;
136
- offColor(_: string): this;
137
- onColor(): string;
138
- onColor(_: string): this;
139
- offFontColor(): string;
140
- offFontColor(_: string): this;
141
- onFontColor(): string;
142
- onFontColor(_: string): this;
143
-
144
- }
145
- OnOff.prototype.implements(IInput.prototype);
146
-
147
- OnOff.prototype.publish("marginLeft", 0, "number", "Margin left of OnOff");
148
- OnOff.prototype.publish("marginBottom", 0, "number", "Margin bottom of OnOff");
149
- OnOff.prototype.publish("minWidth", 100, "number", "Minimum width of OnOff (pixels)");
150
- OnOff.prototype.publish("minHeight", 20, "number", "Minimum height of OnOff (pixels)");
151
- OnOff.prototype.publish("gutter", 1, "number", "Space between switch and border of OnOff (pixels)");
152
- OnOff.prototype.publish("onText", "Save", "string", "Text to display when 'ON'");
153
- OnOff.prototype.publish("offText", "Properties", "string", "Text to display when 'OFF'");
154
- OnOff.prototype.publish("switchRadius", 10, "number", "Border radius of switch (pixels)");
155
- OnOff.prototype.publish("containerRadius", 10, "number", "Border radius of OnOff (pixels)");
156
- OnOff.prototype.publish("onColor", "#2ecc71", "html-color", "Background color when 'ON'");
157
- OnOff.prototype.publish("offColor", "#ecf0f1", "html-color", "Background color when 'OFF'");
158
- OnOff.prototype.publish("onFontColor", "#2c3e50", "html-color", "Font color when 'ON'");
159
- OnOff.prototype.publish("offFontColor", "#7f8c8d", "html-color", "Font color when 'OFF'");
1
+ import { IInput } from "@hpcc-js/api";
2
+ import { HTMLWidget } from "@hpcc-js/common";
3
+
4
+ import "../src/OnOff.css";
5
+
6
+ export class OnOff extends HTMLWidget {
7
+ _inputElement = [];
8
+ _input;
9
+
10
+ constructor() {
11
+ super();
12
+ IInput.call(this);
13
+
14
+ this._tag = "div";
15
+ }
16
+
17
+ enter(domNode, element) {
18
+ super.enter(domNode, element);
19
+ element.classed("onoffswitch", true);
20
+ const context = this;
21
+ this._input = element.append("input")
22
+ .attr("class", "onoffswitch-checkbox")
23
+ .attr("type", "checkbox")
24
+ .attr("id", this.id() + "_onOff")
25
+ .on("click", function (w) {
26
+ w.click(w);
27
+ })
28
+ .on("blur", function (w) {
29
+ w.blur(w);
30
+ })
31
+ .on("change", function (w) {
32
+ const vals = [];
33
+ context._inputElement.forEach(function (d, idx) {
34
+ if (d.property("checked")) {
35
+ vals.push(d.property("value"));
36
+ }
37
+ });
38
+ context.value(vals);
39
+ w.change(w, true);
40
+ })
41
+ ;
42
+ const label = element.append("label")
43
+ .attr("class", "onoffswitch-label")
44
+ .attr("for", this.id() + "_onOff")
45
+ ;
46
+ const inner = label.append("div")
47
+ .attr("class", "onoffswitch-inner")
48
+ ;
49
+ inner.append("div")
50
+ .attr("class", "onoffswitch-offText")
51
+ .style("padding-right", (this.containerRadius() / 2) + "px")
52
+ .text(this.offText())
53
+ ;
54
+ inner.append("div")
55
+ .attr("class", "onoffswitch-onText")
56
+ .style("padding-left", (this.containerRadius() / 2) + "px")
57
+ .style("width", `calc(100% - ${(this.containerRadius() / 2)}px)`)
58
+ .text(this.onText())
59
+ ;
60
+ label.append("div")
61
+ .attr("class", "onoffswitch-switch")
62
+ ;
63
+ }
64
+
65
+ update(domNode, element) {
66
+ super.update(domNode, element);
67
+ this._input
68
+ .attr("name", this.name())
69
+ ;
70
+ element
71
+ .style("margin-left", this.marginLeft() + "px")
72
+ .style("margin-bottom", this.marginBottom() + "px")
73
+ .style("width", this.minWidth() + "px")
74
+ ;
75
+
76
+ const _switch_size = this.minHeight() - (this.gutter() * 4);
77
+
78
+ element.select(".onoffswitch-switch")
79
+ .style("height", _switch_size + "px")
80
+ .style("width", _switch_size + "px")
81
+ .style("top", (this.gutter() * 2) + 1 + "px")
82
+ .style("border-radius", this.switchRadius() + "px")
83
+ ;
84
+ element.select(".onoffswitch-inner")
85
+ .style("min-height", this.minHeight() + "px")
86
+ ;
87
+ element.select(".onoffswitch-label")
88
+ .style("border-radius", this.containerRadius() + "px")
89
+ ;
90
+ element.select(".onoffswitch-offText")
91
+ .style("color", this.offFontColor())
92
+ .style("background-color", this.offColor())
93
+ ;
94
+ element.select(".onoffswitch-onText")
95
+ .style("color", this.onFontColor())
96
+ .style("background-color", this.onColor())
97
+ ;
98
+ }
99
+ }
100
+ OnOff.prototype._class += " form_OnOff";
101
+ export interface OnOff {
102
+ // IInput ---
103
+ name(): string;
104
+ name(_: string): this;
105
+ name_exists(): boolean;
106
+ label(): string;
107
+ label(_: string): this;
108
+ label_exists(): boolean;
109
+ value(): any;
110
+ value(_: any): this;
111
+ value_exists(): boolean;
112
+ validate(): string;
113
+ validate(_: string): this;
114
+ validate_exists(): boolean;
115
+
116
+ // Properties ---
117
+ marginLeft(): number;
118
+ marginLeft(_: number): this;
119
+ marginBottom(): number;
120
+ marginBottom(_: number): this;
121
+ minWidth(): number;
122
+ minWidth(_: number): this;
123
+ minHeight(): number;
124
+ minHeight(_: number): this;
125
+ gutter(): number;
126
+ gutter(_: number): this;
127
+ offText(): string;
128
+ offText(_: string): this;
129
+ onText(): string;
130
+ onText(_: string): this;
131
+ switchRadius(): number;
132
+ switchRadius(_: number): this;
133
+ containerRadius(): number;
134
+ containerRadius(_: number): this;
135
+ offColor(): string;
136
+ offColor(_: string): this;
137
+ onColor(): string;
138
+ onColor(_: string): this;
139
+ offFontColor(): string;
140
+ offFontColor(_: string): this;
141
+ onFontColor(): string;
142
+ onFontColor(_: string): this;
143
+
144
+ }
145
+ OnOff.prototype.implements(IInput.prototype);
146
+
147
+ OnOff.prototype.publish("marginLeft", 0, "number", "Margin left of OnOff");
148
+ OnOff.prototype.publish("marginBottom", 0, "number", "Margin bottom of OnOff");
149
+ OnOff.prototype.publish("minWidth", 100, "number", "Minimum width of OnOff (pixels)");
150
+ OnOff.prototype.publish("minHeight", 20, "number", "Minimum height of OnOff (pixels)");
151
+ OnOff.prototype.publish("gutter", 1, "number", "Space between switch and border of OnOff (pixels)");
152
+ OnOff.prototype.publish("onText", "Save", "string", "Text to display when 'ON'");
153
+ OnOff.prototype.publish("offText", "Properties", "string", "Text to display when 'OFF'");
154
+ OnOff.prototype.publish("switchRadius", 10, "number", "Border radius of switch (pixels)");
155
+ OnOff.prototype.publish("containerRadius", 10, "number", "Border radius of OnOff (pixels)");
156
+ OnOff.prototype.publish("onColor", "#2ecc71", "html-color", "Background color when 'ON'");
157
+ OnOff.prototype.publish("offColor", "#ecf0f1", "html-color", "Background color when 'OFF'");
158
+ OnOff.prototype.publish("onFontColor", "#2c3e50", "html-color", "Font color when 'ON'");
159
+ OnOff.prototype.publish("offFontColor", "#7f8c8d", "html-color", "Font color when 'OFF'");
package/src/Radio.ts CHANGED
@@ -1,83 +1,83 @@
1
- import { IInput } from "@hpcc-js/api";
2
- import { HTMLWidget } from "@hpcc-js/common";
3
-
4
- import "../src/Input.css";
5
-
6
- export class Radio extends HTMLWidget {
7
- _inputElement = [];
8
- constructor() {
9
- super();
10
- IInput.call(this);
11
-
12
- this._tag = "div";
13
- }
14
-
15
- enter(domNode, element) {
16
- super.enter(domNode, element);
17
-
18
- const context = this;
19
-
20
- const radioContainer = element.append("ul");
21
- if (!this.selectOptions().length) {
22
- this.selectOptions().push(""); // create an empty radio if we using .value and not selectOptions array
23
- }
24
- this.selectOptions().forEach(function (val, idx) {
25
- context._inputElement[idx] = radioContainer.append("li").append("input").attr("type", "radio");
26
- context._inputElement[idx].node().insertAdjacentHTML("afterend", "<text>" + val + "</text>");
27
- });
28
-
29
- this._inputElement.forEach(function (e, idx) {
30
- e.attr("name", context.name());
31
- e.on("click", function (w) {
32
- w.click(w);
33
- });
34
- e.on("blur", function (w) {
35
- w.blur(w);
36
- });
37
- e.on("change", function (w) {
38
- context.value([e.property("value")]);
39
- w.change(w, true);
40
- });
41
- });
42
- }
43
-
44
- update(domNode, element) {
45
- super.update(domNode, element);
46
-
47
- const context = this;
48
-
49
- this._inputElement.forEach(function (e, idx) {
50
- e.property("value", context.selectOptions()[idx]);
51
- if (context.value().indexOf(context.selectOptions()[idx]) !== -1 && context.value() !== "false") {
52
- e.property("checked", true);
53
- } else {
54
- e.property("checked", false);
55
- }
56
- });
57
- }
58
- }
59
- Radio.prototype._class += " form_Radio";
60
- Radio.prototype.implements(IInput.prototype);
61
-
62
- export interface Radio {
63
- // IInput ---
64
- name(): string;
65
- name(_: string): this;
66
- name_exists(): boolean;
67
- label(): string;
68
- label(_: string): this;
69
- label_exists(): boolean;
70
- value(): any;
71
- value(_: any): this;
72
- value_exists(): boolean;
73
- validate(): string;
74
- validate(_: string): this;
75
- validate_exists(): boolean;
76
-
77
- // Properties ---
78
- selectOptions(): any[];
79
- selectOptions(_: any[]): this;
80
- selectOptions_exists(): boolean;
81
- }
82
-
83
- Radio.prototype.publish("selectOptions", [], "array", "Array of options used to fill a dropdown list");
1
+ import { IInput } from "@hpcc-js/api";
2
+ import { HTMLWidget } from "@hpcc-js/common";
3
+
4
+ import "../src/Input.css";
5
+
6
+ export class Radio extends HTMLWidget {
7
+ _inputElement = [];
8
+ constructor() {
9
+ super();
10
+ IInput.call(this);
11
+
12
+ this._tag = "div";
13
+ }
14
+
15
+ enter(domNode, element) {
16
+ super.enter(domNode, element);
17
+
18
+ const context = this;
19
+
20
+ const radioContainer = element.append("ul");
21
+ if (!this.selectOptions().length) {
22
+ this.selectOptions().push(""); // create an empty radio if we using .value and not selectOptions array
23
+ }
24
+ this.selectOptions().forEach(function (val, idx) {
25
+ context._inputElement[idx] = radioContainer.append("li").append("input").attr("type", "radio");
26
+ context._inputElement[idx].node().insertAdjacentHTML("afterend", "<text>" + val + "</text>");
27
+ });
28
+
29
+ this._inputElement.forEach(function (e, idx) {
30
+ e.attr("name", context.name());
31
+ e.on("click", function (w) {
32
+ w.click(w);
33
+ });
34
+ e.on("blur", function (w) {
35
+ w.blur(w);
36
+ });
37
+ e.on("change", function (w) {
38
+ context.value([e.property("value")]);
39
+ w.change(w, true);
40
+ });
41
+ });
42
+ }
43
+
44
+ update(domNode, element) {
45
+ super.update(domNode, element);
46
+
47
+ const context = this;
48
+
49
+ this._inputElement.forEach(function (e, idx) {
50
+ e.property("value", context.selectOptions()[idx]);
51
+ if (context.value().indexOf(context.selectOptions()[idx]) !== -1 && context.value() !== "false") {
52
+ e.property("checked", true);
53
+ } else {
54
+ e.property("checked", false);
55
+ }
56
+ });
57
+ }
58
+ }
59
+ Radio.prototype._class += " form_Radio";
60
+ Radio.prototype.implements(IInput.prototype);
61
+
62
+ export interface Radio {
63
+ // IInput ---
64
+ name(): string;
65
+ name(_: string): this;
66
+ name_exists(): boolean;
67
+ label(): string;
68
+ label(_: string): this;
69
+ label_exists(): boolean;
70
+ value(): any;
71
+ value(_: any): this;
72
+ value_exists(): boolean;
73
+ validate(): string;
74
+ validate(_: string): this;
75
+ validate_exists(): boolean;
76
+
77
+ // Properties ---
78
+ selectOptions(): any[];
79
+ selectOptions(_: any[]): this;
80
+ selectOptions_exists(): boolean;
81
+ }
82
+
83
+ Radio.prototype.publish("selectOptions", [], "array", "Array of options used to fill a dropdown list");