@hpcc-js/html 3.3.12 → 3.3.15

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/JSXWidget.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { HTMLWidget } from "@hpcc-js/common";
2
- import { React } from "@hpcc-js/react";
3
-
4
- export class JSXWidget extends HTMLWidget {
5
- static Component = React.Component;
6
- static createElement = React.createElement;
7
- protected rootNode;
8
-
9
- jsxRender(jsx, domNode) {
10
- this.rootNode = React.render(jsx, domNode, this.rootNode);
11
- }
12
- }
13
- JSXWidget.prototype._class += " html_JSXWidget";
1
+ import { HTMLWidget } from "@hpcc-js/common";
2
+ import { React } from "@hpcc-js/react";
3
+
4
+ export class JSXWidget extends HTMLWidget {
5
+ static Component = React.Component;
6
+ static createElement = React.createElement;
7
+ protected rootNode;
8
+
9
+ jsxRender(jsx, domNode) {
10
+ this.rootNode = React.render(jsx, domNode, this.rootNode);
11
+ }
12
+ }
13
+ JSXWidget.prototype._class += " html_JSXWidget";
@@ -1,63 +1,63 @@
1
- import { HTMLWidget, select as d3Select } from "@hpcc-js/common";
2
-
3
- export class SimpleTable extends HTMLWidget {
4
- protected _table;
5
- protected _tbody;
6
- protected _thead;
7
- protected _theadRow;
8
- constructor() {
9
- super();
10
- }
11
-
12
- protected transformData() {
13
- return this.data();
14
- }
15
-
16
- enter(domNode, element) {
17
- super.enter(domNode, element);
18
-
19
- this._table = element.append("table");
20
- this._thead = this._table.append("thead");
21
- this._theadRow = this._thead.append("tr");
22
- this._tbody = this._table.append("tbody");
23
- }
24
-
25
- update(domNode, element) {
26
- super.update(domNode, element);
27
- this._table
28
- .style("width", this.autoWidth() ? "auto" : "100%")
29
- ;
30
- const theadTrSelection = this._theadRow.selectAll("th").data(this.columns());
31
- theadTrSelection.enter()
32
- .append("th")
33
- .attr("class", (n, i) => `th-${i}`)
34
- .merge(theadTrSelection)
35
- .text(_d => (_d).toString())
36
- ;
37
- theadTrSelection.exit().remove();
38
- const trSelection = this._tbody.selectAll("tr").data(this.transformData());
39
- trSelection.enter()
40
- .append("tr")
41
- .merge(trSelection)
42
- .each(function (this, d) {
43
- const tr = d3Select(this);
44
- const tdSelection = tr.selectAll("td").data(d);
45
- tdSelection.enter()
46
- .append("td")
47
- .attr("class", (n, i) => `col-${i}`)
48
- .merge(tdSelection as any)
49
- .text(_d => (_d).toString())
50
- ;
51
- tdSelection.exit().remove();
52
- })
53
- ;
54
- trSelection.exit().remove();
55
- }
56
- }
57
- SimpleTable.prototype._class += " html_SimpleTable";
58
-
59
- export interface SimpleTable {
60
- autoWidth(): boolean;
61
- autoWidth(_: boolean): this;
62
- }
63
- SimpleTable.prototype.publish("autoWidth", false, "boolean", "If true, table width will be set to 'auto'. If false, the width is set to '100%'");
1
+ import { HTMLWidget, select as d3Select } from "@hpcc-js/common";
2
+
3
+ export class SimpleTable extends HTMLWidget {
4
+ protected _table;
5
+ protected _tbody;
6
+ protected _thead;
7
+ protected _theadRow;
8
+ constructor() {
9
+ super();
10
+ }
11
+
12
+ protected transformData() {
13
+ return this.data();
14
+ }
15
+
16
+ enter(domNode, element) {
17
+ super.enter(domNode, element);
18
+
19
+ this._table = element.append("table");
20
+ this._thead = this._table.append("thead");
21
+ this._theadRow = this._thead.append("tr");
22
+ this._tbody = this._table.append("tbody");
23
+ }
24
+
25
+ update(domNode, element) {
26
+ super.update(domNode, element);
27
+ this._table
28
+ .style("width", this.autoWidth() ? "auto" : "100%")
29
+ ;
30
+ const theadTrSelection = this._theadRow.selectAll("th").data(this.columns());
31
+ theadTrSelection.enter()
32
+ .append("th")
33
+ .attr("class", (n, i) => `th-${i}`)
34
+ .merge(theadTrSelection)
35
+ .text(_d => (_d).toString())
36
+ ;
37
+ theadTrSelection.exit().remove();
38
+ const trSelection = this._tbody.selectAll("tr").data(this.transformData());
39
+ trSelection.enter()
40
+ .append("tr")
41
+ .merge(trSelection)
42
+ .each(function (this, d) {
43
+ const tr = d3Select(this);
44
+ const tdSelection = tr.selectAll("td").data(d);
45
+ tdSelection.enter()
46
+ .append("td")
47
+ .attr("class", (n, i) => `col-${i}`)
48
+ .merge(tdSelection as any)
49
+ .text(_d => (_d).toString())
50
+ ;
51
+ tdSelection.exit().remove();
52
+ })
53
+ ;
54
+ trSelection.exit().remove();
55
+ }
56
+ }
57
+ SimpleTable.prototype._class += " html_SimpleTable";
58
+
59
+ export interface SimpleTable {
60
+ autoWidth(): boolean;
61
+ autoWidth(_: boolean): this;
62
+ }
63
+ SimpleTable.prototype.publish("autoWidth", false, "boolean", "If true, table width will be set to 'auto'. If false, the width is set to '100%'");
package/src/StatsTable.ts CHANGED
@@ -1,103 +1,103 @@
1
- import { format as d3Format } from "d3-format";
2
- import { StyledTable } from "./StyledTable.ts";
3
-
4
- export class StatsTable extends StyledTable {
5
-
6
- protected transformData() {
7
- const totalRow = [["Total", 0, 0]];
8
- const data = this.data();
9
- data.forEach(row => {
10
- totalRow[0][1] += row[1];
11
- totalRow[0][2] += row[2];
12
- });
13
- return data
14
- .concat(totalRow)
15
- .map(row => {
16
- return [
17
- row[0],
18
- this.secondColumnFormat_exists() ? d3Format(this.secondColumnFormat())(row[1]) : row[1],
19
- this.thirdColumnFormat_exists() ? d3Format(this.thirdColumnFormat())(row[2]) : row[2]
20
- ];
21
- })
22
- ;
23
- }
24
-
25
- update(domNode, element) {
26
- this.tbodyColumnStyles_default([
27
- {
28
- "font-weight": "bold",
29
- "width": this.firstColumnWidth(),
30
- "text-align": "left"
31
- },
32
- {
33
- "width": this.secondColumnWidth(),
34
- "text-align": "right"
35
- },
36
- {
37
- "width": this.thirdColumnWidth(),
38
- "text-align": "right"
39
- }
40
- ]);
41
- this.evenRowStyles_default([
42
- {
43
- "font-weight": "bold",
44
- "width": this.firstColumnWidth(),
45
- "text-align": "left",
46
- "font-color": this.evenRowFontColor(),
47
- "background-color": this.evenRowBackgroundColor()
48
- },
49
- {
50
- "width": this.secondColumnWidth(),
51
- "text-align": "right",
52
- "font-color": this.evenRowFontColor(),
53
- "background-color": this.evenRowBackgroundColor()
54
- },
55
- {
56
- "width": this.thirdColumnWidth(),
57
- "text-align": "right",
58
- "font-color": this.evenRowFontColor(),
59
- "background-color": this.evenRowBackgroundColor()
60
- }
61
- ]);
62
- this.lastRowStyles_default({
63
- "font-weight": "bold"
64
- });
65
- super.update(domNode, element);
66
- }
67
- }
68
- StatsTable.prototype._class += " html_StatsTable";
69
-
70
- export interface StatsTable {
71
- labelColor(): string;
72
- labelColor(_: string): this;
73
- primaryValueColor(): string;
74
- primaryValueColor(_: string): this;
75
- secondaryValueColor(): string;
76
- secondaryValueColor(_: string): this;
77
- evenRowFontColor(): string;
78
- evenRowFontColor(_: string): this;
79
- evenRowBackgroundColor(): string;
80
- evenRowBackgroundColor(_: string): this;
81
- firstColumnWidth(): string;
82
- firstColumnWidth(_: string): this;
83
- secondColumnWidth(): string;
84
- secondColumnWidth(_: string): this;
85
- thirdColumnWidth(): string;
86
- thirdColumnWidth(_: string): this;
87
- secondColumnFormat(): string;
88
- secondColumnFormat(_: string): this;
89
- secondColumnFormat_exists(): boolean;
90
- thirdColumnFormat(): string;
91
- thirdColumnFormat(_: string): this;
92
- thirdColumnFormat_exists(): boolean;
93
- }
94
- StatsTable.prototype.publish("labelColor", "#333", "html-color", "Color of the text in the first column");
95
- StatsTable.prototype.publish("primaryValueColor", "#333", "html-color", "Color of the text in the second column");
96
- StatsTable.prototype.publish("secondaryValueColor", "#333", "html-color", "Color of the text in the third column");
97
- StatsTable.prototype.publish("evenRowBackgroundColor", "#333", "html-color", "Background color of the even rows");
98
- StatsTable.prototype.publish("evenRowFontColor", "#333", "html-color", "Font color of the even rows");
99
- StatsTable.prototype.publish("firstColumnWidth", "auto", "string", "CSS style applied as the 'width' for the first column (ex: 40px)");
100
- StatsTable.prototype.publish("secondColumnWidth", "1%", "string", "CSS style applied as the 'width' for the second column (ex: 40px)");
101
- StatsTable.prototype.publish("thirdColumnWidth", "1%", "string", "CSS style applied as the 'width' for the third column (ex: 40px)");
102
- StatsTable.prototype.publish("secondColumnFormat", "$,.0f", "string", "d3-format specifier applied to the second column's values", undefined, { optional: true });
103
- StatsTable.prototype.publish("thirdColumnFormat", null, "string", "d3-format specifier applied to the third column's values", undefined, { optional: true });
1
+ import { format as d3Format } from "d3-format";
2
+ import { StyledTable } from "./StyledTable.ts";
3
+
4
+ export class StatsTable extends StyledTable {
5
+
6
+ protected transformData() {
7
+ const totalRow = [["Total", 0, 0]];
8
+ const data = this.data();
9
+ data.forEach(row => {
10
+ totalRow[0][1] += row[1];
11
+ totalRow[0][2] += row[2];
12
+ });
13
+ return data
14
+ .concat(totalRow)
15
+ .map(row => {
16
+ return [
17
+ row[0],
18
+ this.secondColumnFormat_exists() ? d3Format(this.secondColumnFormat())(row[1]) : row[1],
19
+ this.thirdColumnFormat_exists() ? d3Format(this.thirdColumnFormat())(row[2]) : row[2]
20
+ ];
21
+ })
22
+ ;
23
+ }
24
+
25
+ update(domNode, element) {
26
+ this.tbodyColumnStyles_default([
27
+ {
28
+ "font-weight": "bold",
29
+ "width": this.firstColumnWidth(),
30
+ "text-align": "left"
31
+ },
32
+ {
33
+ "width": this.secondColumnWidth(),
34
+ "text-align": "right"
35
+ },
36
+ {
37
+ "width": this.thirdColumnWidth(),
38
+ "text-align": "right"
39
+ }
40
+ ]);
41
+ this.evenRowStyles_default([
42
+ {
43
+ "font-weight": "bold",
44
+ "width": this.firstColumnWidth(),
45
+ "text-align": "left",
46
+ "font-color": this.evenRowFontColor(),
47
+ "background-color": this.evenRowBackgroundColor()
48
+ },
49
+ {
50
+ "width": this.secondColumnWidth(),
51
+ "text-align": "right",
52
+ "font-color": this.evenRowFontColor(),
53
+ "background-color": this.evenRowBackgroundColor()
54
+ },
55
+ {
56
+ "width": this.thirdColumnWidth(),
57
+ "text-align": "right",
58
+ "font-color": this.evenRowFontColor(),
59
+ "background-color": this.evenRowBackgroundColor()
60
+ }
61
+ ]);
62
+ this.lastRowStyles_default({
63
+ "font-weight": "bold"
64
+ });
65
+ super.update(domNode, element);
66
+ }
67
+ }
68
+ StatsTable.prototype._class += " html_StatsTable";
69
+
70
+ export interface StatsTable {
71
+ labelColor(): string;
72
+ labelColor(_: string): this;
73
+ primaryValueColor(): string;
74
+ primaryValueColor(_: string): this;
75
+ secondaryValueColor(): string;
76
+ secondaryValueColor(_: string): this;
77
+ evenRowFontColor(): string;
78
+ evenRowFontColor(_: string): this;
79
+ evenRowBackgroundColor(): string;
80
+ evenRowBackgroundColor(_: string): this;
81
+ firstColumnWidth(): string;
82
+ firstColumnWidth(_: string): this;
83
+ secondColumnWidth(): string;
84
+ secondColumnWidth(_: string): this;
85
+ thirdColumnWidth(): string;
86
+ thirdColumnWidth(_: string): this;
87
+ secondColumnFormat(): string;
88
+ secondColumnFormat(_: string): this;
89
+ secondColumnFormat_exists(): boolean;
90
+ thirdColumnFormat(): string;
91
+ thirdColumnFormat(_: string): this;
92
+ thirdColumnFormat_exists(): boolean;
93
+ }
94
+ StatsTable.prototype.publish("labelColor", "#333", "html-color", "Color of the text in the first column");
95
+ StatsTable.prototype.publish("primaryValueColor", "#333", "html-color", "Color of the text in the second column");
96
+ StatsTable.prototype.publish("secondaryValueColor", "#333", "html-color", "Color of the text in the third column");
97
+ StatsTable.prototype.publish("evenRowBackgroundColor", "#333", "html-color", "Background color of the even rows");
98
+ StatsTable.prototype.publish("evenRowFontColor", "#333", "html-color", "Font color of the even rows");
99
+ StatsTable.prototype.publish("firstColumnWidth", "auto", "string", "CSS style applied as the 'width' for the first column (ex: 40px)");
100
+ StatsTable.prototype.publish("secondColumnWidth", "1%", "string", "CSS style applied as the 'width' for the second column (ex: 40px)");
101
+ StatsTable.prototype.publish("thirdColumnWidth", "1%", "string", "CSS style applied as the 'width' for the third column (ex: 40px)");
102
+ StatsTable.prototype.publish("secondColumnFormat", "$,.0f", "string", "d3-format specifier applied to the second column's values", undefined, { optional: true });
103
+ StatsTable.prototype.publish("thirdColumnFormat", null, "string", "d3-format specifier applied to the third column's values", undefined, { optional: true });
@@ -1,68 +1,68 @@
1
- import { SimpleTable } from "./SimpleTable.ts";
2
-
3
- export class StyledTable extends SimpleTable {
4
- constructor() {
5
- super();
6
- }
7
-
8
- protected applyStyleObject(selection, styleObject) {
9
- Object.keys(styleObject).forEach(styleName => {
10
- selection.style(styleName, styleObject[styleName]);
11
- });
12
- }
13
-
14
- update(domNode, element) {
15
- super.update(domNode, element);
16
-
17
- element.selectAll("tr,th,td")
18
- .attr("style", "")
19
- .style("font-family", this.fontFamily())
20
- .style("color", this.fontColor())
21
- ;
22
-
23
- this.theadColumnStyles().forEach((styleObj, i) => {
24
- this.applyStyleObject(element.select(`.th-${i}`), styleObj);
25
- });
26
- this.tbodyColumnStyles().forEach((styleObj, i) => {
27
- this.applyStyleObject(element.selectAll(`.col-${i}`), styleObj);
28
- });
29
- const evenRowStylesExist = Object.keys(this.evenRowStyles()).length > 0;
30
- const lastRowStylesExist = Object.keys(this.lastRowStyles()).length > 0;
31
- const tbodyRows = element.selectAll("tbody > tr");
32
- if (evenRowStylesExist) {
33
- const tbodyEvenRows = tbodyRows.select(function (this: HTMLElement, d, i) { return i % 2 ? this : null; });
34
- this.applyStyleObject(tbodyEvenRows, this.evenRowStyles());
35
- }
36
- if (lastRowStylesExist) {
37
- const tbodyLastRow = tbodyRows.select(function (this: HTMLElement, d, i, arr) { return i === arr.length - 1 ? this : null; });
38
- this.applyStyleObject(tbodyLastRow, this.lastRowStyles());
39
- }
40
- }
41
- }
42
- StyledTable.prototype._class += " html_StyledTable";
43
-
44
- export interface StyledTable {
45
- fontFamily(): string;
46
- fontFamily(_: string): this;
47
- fontColor(): string;
48
- fontColor(_: string): this;
49
- tbodyColumnStyles(): Array<{ [styleID: string]: any }>;
50
- tbodyColumnStyles(_: Array<{ [styleID: string]: any }>): this;
51
- tbodyColumnStyles_default(_: Array<{ [styleID: string]: any }>): this;
52
- theadColumnStyles(): Array<{ [styleID: string]: any }>;
53
- theadColumnStyles(_: Array<{ [styleID: string]: any }>): this;
54
- theadColumnStyles_default(_: Array<{ [styleID: string]: any }>): this;
55
- lastRowStyles(): { [styleID: string]: any };
56
- lastRowStyles(_: { [styleID: string]: any }): this;
57
- lastRowStyles_default(_: { [styleID: string]: any }): this;
58
- evenRowStyles(): { [styleID: string]: any };
59
- evenRowStyles(_: { [styleID: string]: any }): this;
60
- evenRowStyles_default(_: { [styleID: string]: any }): this;
61
- }
62
-
63
- StyledTable.prototype.publish("fontFamily", "Verdana", "string", "Base font-family used within the table");
64
- StyledTable.prototype.publish("fontColor", "#333", "string", "Base font color used within the table");
65
- StyledTable.prototype.publish("theadColumnStyles", [], "array", 'Array of objects containing styles for the thead columns (ex: [{"color":"red"},{"color":"blue"}])');
66
- StyledTable.prototype.publish("tbodyColumnStyles", [], "array", 'Array of objects containing styles for the tbody columns (ex: [{"color":"red"},{"color":"blue"}])');
67
- StyledTable.prototype.publish("lastRowStyles", {}, "object", 'Object containing styles for the last row (ex: {"color":"red"})');
68
- StyledTable.prototype.publish("evenRowStyles", {}, "object", 'Object containing styles for even rows (ex: {"background-color":"#AAA"})');
1
+ import { SimpleTable } from "./SimpleTable.ts";
2
+
3
+ export class StyledTable extends SimpleTable {
4
+ constructor() {
5
+ super();
6
+ }
7
+
8
+ protected applyStyleObject(selection, styleObject) {
9
+ Object.keys(styleObject).forEach(styleName => {
10
+ selection.style(styleName, styleObject[styleName]);
11
+ });
12
+ }
13
+
14
+ update(domNode, element) {
15
+ super.update(domNode, element);
16
+
17
+ element.selectAll("tr,th,td")
18
+ .attr("style", "")
19
+ .style("font-family", this.fontFamily())
20
+ .style("color", this.fontColor())
21
+ ;
22
+
23
+ this.theadColumnStyles().forEach((styleObj, i) => {
24
+ this.applyStyleObject(element.select(`.th-${i}`), styleObj);
25
+ });
26
+ this.tbodyColumnStyles().forEach((styleObj, i) => {
27
+ this.applyStyleObject(element.selectAll(`.col-${i}`), styleObj);
28
+ });
29
+ const evenRowStylesExist = Object.keys(this.evenRowStyles()).length > 0;
30
+ const lastRowStylesExist = Object.keys(this.lastRowStyles()).length > 0;
31
+ const tbodyRows = element.selectAll("tbody > tr");
32
+ if (evenRowStylesExist) {
33
+ const tbodyEvenRows = tbodyRows.select(function (this: HTMLElement, d, i) { return i % 2 ? this : null; });
34
+ this.applyStyleObject(tbodyEvenRows, this.evenRowStyles());
35
+ }
36
+ if (lastRowStylesExist) {
37
+ const tbodyLastRow = tbodyRows.select(function (this: HTMLElement, d, i, arr) { return i === arr.length - 1 ? this : null; });
38
+ this.applyStyleObject(tbodyLastRow, this.lastRowStyles());
39
+ }
40
+ }
41
+ }
42
+ StyledTable.prototype._class += " html_StyledTable";
43
+
44
+ export interface StyledTable {
45
+ fontFamily(): string;
46
+ fontFamily(_: string): this;
47
+ fontColor(): string;
48
+ fontColor(_: string): this;
49
+ tbodyColumnStyles(): Array<{ [styleID: string]: any }>;
50
+ tbodyColumnStyles(_: Array<{ [styleID: string]: any }>): this;
51
+ tbodyColumnStyles_default(_: Array<{ [styleID: string]: any }>): this;
52
+ theadColumnStyles(): Array<{ [styleID: string]: any }>;
53
+ theadColumnStyles(_: Array<{ [styleID: string]: any }>): this;
54
+ theadColumnStyles_default(_: Array<{ [styleID: string]: any }>): this;
55
+ lastRowStyles(): { [styleID: string]: any };
56
+ lastRowStyles(_: { [styleID: string]: any }): this;
57
+ lastRowStyles_default(_: { [styleID: string]: any }): this;
58
+ evenRowStyles(): { [styleID: string]: any };
59
+ evenRowStyles(_: { [styleID: string]: any }): this;
60
+ evenRowStyles_default(_: { [styleID: string]: any }): this;
61
+ }
62
+
63
+ StyledTable.prototype.publish("fontFamily", "Verdana", "string", "Base font-family used within the table");
64
+ StyledTable.prototype.publish("fontColor", "#333", "string", "Base font color used within the table");
65
+ StyledTable.prototype.publish("theadColumnStyles", [], "array", 'Array of objects containing styles for the thead columns (ex: [{"color":"red"},{"color":"blue"}])');
66
+ StyledTable.prototype.publish("tbodyColumnStyles", [], "array", 'Array of objects containing styles for the tbody columns (ex: [{"color":"red"},{"color":"blue"}])');
67
+ StyledTable.prototype.publish("lastRowStyles", {}, "object", 'Object containing styles for the last row (ex: {"color":"red"})');
68
+ StyledTable.prototype.publish("evenRowStyles", {}, "object", 'Object containing styles for even rows (ex: {"background-color":"#AAA"})');