@hpcc-js/other 3.4.10 → 3.5.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.
@@ -1,7 +1,6 @@
1
- .other_RadioCheckbox input {
2
- }
3
-
4
- .other_RadioCheckbox span,
5
- .other_RadioCheckbox label {
6
- vertical-align: top;
1
+ .other_RadioCheckbox input {}
2
+
3
+ .other_RadioCheckbox span,
4
+ .other_RadioCheckbox label {
5
+ vertical-align: top;
7
6
  }
@@ -1,130 +1,130 @@
1
- import { HTMLWidget } from "@hpcc-js/common";
2
- import { select as d3Select } from "d3-selection";
3
-
4
- import "../src/RadioCheckbox.css";
5
-
6
- export class RadioCheckbox extends HTMLWidget {
7
- _span;
8
- _label;
9
- _Checkbox;
10
-
11
- constructor() {
12
- super();
13
- }
14
-
15
- rcData() {
16
- if (this.data().length === 0) return [];
17
- const view = this._db.rollupView([this.textColumn(), this.valueColumn()]);
18
- let retVal = [];
19
- retVal = retVal.concat(view.entries().map(function (row) {
20
- return {
21
- text: row.key,
22
- value: row.values.length ? row.values[0].key : "",
23
- origRow: row.values.length && row.values[0].values.length ? row.values[0].values[0] : []
24
- };
25
- }, this));
26
- if (this.sort_exists()) {
27
- const descending = this.sort() === "descending";
28
- retVal.sort(function (l, r) {
29
- if (l.text < r.text) return descending ? 1 : -1;
30
- if (l.text > r.text) return descending ? -1 : 1;
31
- return 0;
32
- });
33
- }
34
- return retVal;
35
- }
36
-
37
- enter(domNode, element) {
38
- super.enter(domNode, element);
39
- this._span = element.append("span");
40
- this._label = this._span.append("label")
41
- .attr("for", this.id() + "_radioCheckbox")
42
- ;
43
- this._Checkbox = this._span.append("div")
44
- .attr("id", this.id() + "_radioCheckbox");
45
- }
46
-
47
- update(domNode, element) {
48
- super.update(domNode, element);
49
- const context = this;
50
- this._label
51
- .text(this.label())
52
- ;
53
- const radioCheckbox = this._Checkbox.selectAll(".dataRow").data(this.rcData());
54
- radioCheckbox.enter().append("div")
55
- .attr("class", "dataRow")
56
- .each(function (row, idx) {
57
- const checkboxDiv = d3Select(this);
58
- const id = context.id() + "_checkbox_" + idx;
59
- checkboxDiv.append("input")
60
- .attr("id", id)
61
- .attr("name", context.id() + "_radioCheckbox")
62
- .on("change", function (selectedData) {
63
- context.handleClick();
64
- });
65
- checkboxDiv.append("label")
66
- .attr("for", id);
67
- });
68
- radioCheckbox
69
- .each(function (row, idx) {
70
- const rcDiv = d3Select(this);
71
- rcDiv.select("input")
72
- .attr("type", context.multiple() ? "checkbox" : "radio")
73
- .attr("value", row.value);
74
- rcDiv.select("label")
75
- .text(row.text);
76
- });
77
- radioCheckbox.exit().remove();
78
- radioCheckbox.order();
79
- }
80
-
81
- exit(domNode, element) {
82
- this._span.remove();
83
- super.exit(domNode, element);
84
- }
85
-
86
- handleClick() {
87
- const options = [];
88
- this._Checkbox.selectAll(".dataRow > input")
89
- .each(function (row, idx) {
90
- const input = d3Select(this);
91
- if (input.property("checked") && row && row.origRow) {
92
- options.push(row.origRow);
93
- }
94
- });
95
- if (options.length) {
96
- // TODO Handle Multiple Selections - part of 1.16.x
97
- this.click(this.rowToObj(options[0]), this.valueColumn(), true);
98
- } else {
99
- this.click([], this.valueColumn(), false);
100
- }
101
- }
102
-
103
- click(row, column, selected) {
104
- }
105
- }
106
- RadioCheckbox.prototype._class += " other_RadioCheckbox";
107
-
108
- export interface RadioCheckbox {
109
- label(): string;
110
- label(_: string): this;
111
- label_exists(): boolean;
112
- valueColumn(): string;
113
- valueColumn(_: string): this;
114
- valueColumn_exists(): boolean;
115
- textColumn(): string;
116
- textColumn(_: string): this;
117
- textColumn_exists(): boolean;
118
- sort(): string;
119
- sort(_: string): this;
120
- sort_exists
121
- multiple(): boolean;
122
- multiple(_: boolean): this;
123
- multiple_exists(): boolean;
124
- }
125
-
126
- RadioCheckbox.prototype.publish("label", null, "string", "Label for RadioCheckbox");
127
- RadioCheckbox.prototype.publish("valueColumn", null, "set", "RadioCheckbox display value", function () { return this.columns(); }, { optional: true });
128
- RadioCheckbox.prototype.publish("textColumn", null, "set", "RadioCheckbox value(s)", function () { return this.columns(); }, { optional: true });
129
- RadioCheckbox.prototype.publish("sort", null, "set", "Sort contents", ["", "ascending", "descending"], { optional: true });
130
- RadioCheckbox.prototype.publish("multiple", false, "boolean", "Multiple selection");
1
+ import { HTMLWidget } from "@hpcc-js/common";
2
+ import { select as d3Select } from "d3-selection";
3
+
4
+ import "../src/RadioCheckbox.css";
5
+
6
+ export class RadioCheckbox extends HTMLWidget {
7
+ _span;
8
+ _label;
9
+ _Checkbox;
10
+
11
+ constructor() {
12
+ super();
13
+ }
14
+
15
+ rcData() {
16
+ if (this.data().length === 0) return [];
17
+ const view = this._db.rollupView([this.textColumn(), this.valueColumn()]);
18
+ let retVal = [];
19
+ retVal = retVal.concat(view.entries().map(function (row) {
20
+ return {
21
+ text: row.key,
22
+ value: row.values.length ? row.values[0].key : "",
23
+ origRow: row.values.length && row.values[0].values.length ? row.values[0].values[0] : []
24
+ };
25
+ }, this));
26
+ if (this.sort_exists()) {
27
+ const descending = this.sort() === "descending";
28
+ retVal.sort(function (l, r) {
29
+ if (l.text < r.text) return descending ? 1 : -1;
30
+ if (l.text > r.text) return descending ? -1 : 1;
31
+ return 0;
32
+ });
33
+ }
34
+ return retVal;
35
+ }
36
+
37
+ enter(domNode, element) {
38
+ super.enter(domNode, element);
39
+ this._span = element.append("span");
40
+ this._label = this._span.append("label")
41
+ .attr("for", this.id() + "_radioCheckbox")
42
+ ;
43
+ this._Checkbox = this._span.append("div")
44
+ .attr("id", this.id() + "_radioCheckbox");
45
+ }
46
+
47
+ update(domNode, element) {
48
+ super.update(domNode, element);
49
+ const context = this;
50
+ this._label
51
+ .text(this.label())
52
+ ;
53
+ const radioCheckbox = this._Checkbox.selectAll(".dataRow").data(this.rcData());
54
+ radioCheckbox.enter().append("div")
55
+ .attr("class", "dataRow")
56
+ .each(function (row, idx) {
57
+ const checkboxDiv = d3Select(this);
58
+ const id = context.id() + "_checkbox_" + idx;
59
+ checkboxDiv.append("input")
60
+ .attr("id", id)
61
+ .attr("name", context.id() + "_radioCheckbox")
62
+ .on("change", function (selectedData) {
63
+ context.handleClick();
64
+ });
65
+ checkboxDiv.append("label")
66
+ .attr("for", id);
67
+ });
68
+ radioCheckbox
69
+ .each(function (row, idx) {
70
+ const rcDiv = d3Select(this);
71
+ rcDiv.select("input")
72
+ .attr("type", context.multiple() ? "checkbox" : "radio")
73
+ .attr("value", row.value);
74
+ rcDiv.select("label")
75
+ .text(row.text);
76
+ });
77
+ radioCheckbox.exit().remove();
78
+ radioCheckbox.order();
79
+ }
80
+
81
+ exit(domNode, element) {
82
+ this._span.remove();
83
+ super.exit(domNode, element);
84
+ }
85
+
86
+ handleClick() {
87
+ const options = [];
88
+ this._Checkbox.selectAll(".dataRow > input")
89
+ .each(function (row, idx) {
90
+ const input = d3Select(this);
91
+ if (input.property("checked") && row && row.origRow) {
92
+ options.push(row.origRow);
93
+ }
94
+ });
95
+ if (options.length) {
96
+ // TODO Handle Multiple Selections - part of 1.16.x
97
+ this.click(this.rowToObj(options[0]), this.valueColumn(), true);
98
+ } else {
99
+ this.click([], this.valueColumn(), false);
100
+ }
101
+ }
102
+
103
+ click(row, column, selected) {
104
+ }
105
+ }
106
+ RadioCheckbox.prototype._class += " other_RadioCheckbox";
107
+
108
+ export interface RadioCheckbox {
109
+ label(): string;
110
+ label(_: string): this;
111
+ label_exists(): boolean;
112
+ valueColumn(): string;
113
+ valueColumn(_: string): this;
114
+ valueColumn_exists(): boolean;
115
+ textColumn(): string;
116
+ textColumn(_: string): this;
117
+ textColumn_exists(): boolean;
118
+ sort(): string;
119
+ sort(_: string): this;
120
+ sort_exists
121
+ multiple(): boolean;
122
+ multiple(_: boolean): this;
123
+ multiple_exists(): boolean;
124
+ }
125
+
126
+ RadioCheckbox.prototype.publish("label", null, "string", "Label for RadioCheckbox");
127
+ RadioCheckbox.prototype.publish("valueColumn", null, "set", "RadioCheckbox display value", function () { return this.columns(); }, { optional: true });
128
+ RadioCheckbox.prototype.publish("textColumn", null, "set", "RadioCheckbox value(s)", function () { return this.columns(); }, { optional: true });
129
+ RadioCheckbox.prototype.publish("sort", null, "set", "Sort contents", ["", "ascending", "descending"], { optional: true });
130
+ RadioCheckbox.prototype.publish("multiple", false, "boolean", "Multiple selection");
package/src/Select.css CHANGED
@@ -1,7 +1,6 @@
1
- .other_Select select {
2
- }
3
-
4
- .other_Select span,
5
- .other_Select label {
6
- vertical-align:top;
7
- }
1
+ .other_Select select {}
2
+
3
+ .other_Select span,
4
+ .other_Select label {
5
+ vertical-align: top;
6
+ }
package/src/Select.ts CHANGED
@@ -1,130 +1,130 @@
1
- import { HTMLWidget } from "@hpcc-js/common";
2
- import { select as d3Select } from "d3-selection";
3
-
4
- import "../src/Select.css";
5
-
6
- export class Select extends HTMLWidget {
7
- _span;
8
- _prompt;
9
- _select;
10
-
11
- constructor() {
12
- super();
13
- }
14
-
15
- selectData() {
16
- if (this.data().length === 0) return [];
17
- const view = this._db.rollupView([this.textColumn(), this.valueColumn()]);
18
- let retVal = [];
19
- retVal = retVal.concat(view.entries().map(function (row) {
20
- return {
21
- text: row.key,
22
- value: row.values.length ? row.values[0].key : "",
23
- origRow: row.values.length && row.values[0].value.length ? row.values[0].value[0] : []
24
- };
25
- }, this));
26
- if (this.sort_exists()) {
27
- const descending = this.sort() === "descending";
28
- retVal.sort(function (l, r) {
29
- if (l.text < r.text) return descending ? 1 : -1;
30
- if (l.text > r.text) return descending ? -1 : 1;
31
- return 0;
32
- });
33
- }
34
- if (this.optional()) {
35
- retVal.unshift({ value: "", text: "" });
36
- }
37
- return retVal;
38
- }
39
-
40
- enter(domNode, element) {
41
- super.enter(domNode, element);
42
- this._span = element.append("span");
43
- this._prompt = this._span.append("label")
44
- .attr("for", this.id() + "_select")
45
- ;
46
-
47
- const context = this;
48
- this._select = this._span.append("select")
49
- .attr("id", this.id() + "_select")
50
- .on("change", function (d) {
51
- const options = [];
52
- const options_dom_node = context._select.node().options;
53
- for (let i = 0; i < options_dom_node.length; ++i) {
54
- const optionNode = options_dom_node[i];
55
- if (optionNode.selected) {
56
- options.push((d3Select(optionNode).datum() as any).origRow);
57
- }
58
- }
59
- if (options.length) {
60
- context.click(context.rowToObj(options[0]), context.valueColumn(), true); // TODO: Multiselect not support in HIPIE
61
- } else {
62
- context.click([], context.valueColumn(), false);
63
- }
64
- })
65
- ;
66
- }
67
-
68
- update(domNode, element) {
69
- super.update(domNode, element);
70
-
71
- this._prompt
72
- .text(this.label())
73
- ;
74
- this._select
75
- .attr("multiple", this.multiple() ? this.multiple() : null)
76
- .attr("size", this.multiple() && this.selectSize() ? this.selectSize() : null)
77
- ;
78
-
79
- const option = this._select.selectAll(".dataRow").data(this.selectData());
80
- const optionUpdate = option.enter().append("option")
81
- .attr("class", "dataRow")
82
- .merge(option)
83
- .attr("value", function (row) { return row.value; })
84
- .text(function (row) { return row.text; })
85
- ;
86
- option.exit().remove();
87
- optionUpdate.order();
88
- }
89
-
90
- exit(domNode, element) {
91
- this._span.remove();
92
- super.exit(domNode, element);
93
- }
94
-
95
- click(row, column, selected) {
96
- }
97
- }
98
- Select.prototype._class += " other_Select";
99
-
100
- export interface Select {
101
- label(): string;
102
- label(_: string): this;
103
- label_exists(): boolean;
104
- valueColumn(): string;
105
- valueColumn(_: string): this;
106
- valueColumn_exists(): boolean;
107
- textColumn(): string;
108
- textColumn(_: string): this;
109
- textColumn_exists(): boolean;
110
- optional(): boolean;
111
- optional(_: boolean): this;
112
- optional_exists(): boolean;
113
- sort(): string;
114
- sort(_: string): this;
115
- sort_exists(): boolean;
116
- multiple(): boolean;
117
- multiple(_: boolean): this;
118
- multiple_exists(): boolean;
119
- selectSize(): number;
120
- selectSize(_: number): this;
121
- selectSize_exists(): boolean;
122
- }
123
-
124
- Select.prototype.publish("label", null, "string", "Label for select");
125
- Select.prototype.publish("valueColumn", null, "set", "Select display value", function () { return this.columns(); }, { optional: true });
126
- Select.prototype.publish("textColumn", null, "set", "Select value(s)", function () { return this.columns(); }, { optional: true });
127
- Select.prototype.publish("optional", true, "boolean", "Optional Select");
128
- Select.prototype.publish("sort", null, "set", "Sort contents", ["", "ascending", "descending"], { optional: true });
129
- Select.prototype.publish("multiple", false, "boolean", "Multiple selection");
130
- Select.prototype.publish("selectSize", 5, "number", "Size of multiselect box", null, { disable: w => !w.multiple() });
1
+ import { HTMLWidget } from "@hpcc-js/common";
2
+ import { select as d3Select } from "d3-selection";
3
+
4
+ import "../src/Select.css";
5
+
6
+ export class Select extends HTMLWidget {
7
+ _span;
8
+ _prompt;
9
+ _select;
10
+
11
+ constructor() {
12
+ super();
13
+ }
14
+
15
+ selectData() {
16
+ if (this.data().length === 0) return [];
17
+ const view = this._db.rollupView([this.textColumn(), this.valueColumn()]);
18
+ let retVal = [];
19
+ retVal = retVal.concat(view.entries().map(function (row) {
20
+ return {
21
+ text: row.key,
22
+ value: row.values.length ? row.values[0].key : "",
23
+ origRow: row.values.length && row.values[0].value.length ? row.values[0].value[0] : []
24
+ };
25
+ }, this));
26
+ if (this.sort_exists()) {
27
+ const descending = this.sort() === "descending";
28
+ retVal.sort(function (l, r) {
29
+ if (l.text < r.text) return descending ? 1 : -1;
30
+ if (l.text > r.text) return descending ? -1 : 1;
31
+ return 0;
32
+ });
33
+ }
34
+ if (this.optional()) {
35
+ retVal.unshift({ value: "", text: "" });
36
+ }
37
+ return retVal;
38
+ }
39
+
40
+ enter(domNode, element) {
41
+ super.enter(domNode, element);
42
+ this._span = element.append("span");
43
+ this._prompt = this._span.append("label")
44
+ .attr("for", this.id() + "_select")
45
+ ;
46
+
47
+ const context = this;
48
+ this._select = this._span.append("select")
49
+ .attr("id", this.id() + "_select")
50
+ .on("change", function (d) {
51
+ const options = [];
52
+ const options_dom_node = context._select.node().options;
53
+ for (let i = 0; i < options_dom_node.length; ++i) {
54
+ const optionNode = options_dom_node[i];
55
+ if (optionNode.selected) {
56
+ options.push((d3Select(optionNode).datum() as any).origRow);
57
+ }
58
+ }
59
+ if (options.length) {
60
+ context.click(context.rowToObj(options[0]), context.valueColumn(), true); // TODO: Multiselect not support in HIPIE
61
+ } else {
62
+ context.click([], context.valueColumn(), false);
63
+ }
64
+ })
65
+ ;
66
+ }
67
+
68
+ update(domNode, element) {
69
+ super.update(domNode, element);
70
+
71
+ this._prompt
72
+ .text(this.label())
73
+ ;
74
+ this._select
75
+ .attr("multiple", this.multiple() ? this.multiple() : null)
76
+ .attr("size", this.multiple() && this.selectSize() ? this.selectSize() : null)
77
+ ;
78
+
79
+ const option = this._select.selectAll(".dataRow").data(this.selectData());
80
+ const optionUpdate = option.enter().append("option")
81
+ .attr("class", "dataRow")
82
+ .merge(option)
83
+ .attr("value", function (row) { return row.value; })
84
+ .text(function (row) { return row.text; })
85
+ ;
86
+ option.exit().remove();
87
+ optionUpdate.order();
88
+ }
89
+
90
+ exit(domNode, element) {
91
+ this._span.remove();
92
+ super.exit(domNode, element);
93
+ }
94
+
95
+ click(row, column, selected) {
96
+ }
97
+ }
98
+ Select.prototype._class += " other_Select";
99
+
100
+ export interface Select {
101
+ label(): string;
102
+ label(_: string): this;
103
+ label_exists(): boolean;
104
+ valueColumn(): string;
105
+ valueColumn(_: string): this;
106
+ valueColumn_exists(): boolean;
107
+ textColumn(): string;
108
+ textColumn(_: string): this;
109
+ textColumn_exists(): boolean;
110
+ optional(): boolean;
111
+ optional(_: boolean): this;
112
+ optional_exists(): boolean;
113
+ sort(): string;
114
+ sort(_: string): this;
115
+ sort_exists(): boolean;
116
+ multiple(): boolean;
117
+ multiple(_: boolean): this;
118
+ multiple_exists(): boolean;
119
+ selectSize(): number;
120
+ selectSize(_: number): this;
121
+ selectSize_exists(): boolean;
122
+ }
123
+
124
+ Select.prototype.publish("label", null, "string", "Label for select");
125
+ Select.prototype.publish("valueColumn", null, "set", "Select display value", function () { return this.columns(); }, { optional: true });
126
+ Select.prototype.publish("textColumn", null, "set", "Select value(s)", function () { return this.columns(); }, { optional: true });
127
+ Select.prototype.publish("optional", true, "boolean", "Optional Select");
128
+ Select.prototype.publish("sort", null, "set", "Sort contents", ["", "ascending", "descending"], { optional: true });
129
+ Select.prototype.publish("multiple", false, "boolean", "Multiple selection");
130
+ Select.prototype.publish("selectSize", 5, "number", "Size of multiselect box", null, { disable: w => !w.multiple() });