@hpcc-js/dgrid2 3.6.2 → 3.6.4
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/LICENSE +43 -43
- package/README.md +5 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +5 -5
- package/src/ErrorBoundary.tsx +56 -56
- package/src/__package__.ts +3 -3
- package/src/hooks.ts +10 -10
- package/src/index.ts +2 -2
- package/src/reactTable.tsx +163 -163
- package/src/table.css +9 -9
- package/src/table.md +57 -57
- package/src/table.ts +106 -106
package/src/table.ts
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
import { createRoot } from "react-dom/client";
|
|
3
|
-
import { HTMLWidget } from "@hpcc-js/common";
|
|
4
|
-
import { ReactTable } from "./reactTable.tsx";
|
|
5
|
-
|
|
6
|
-
import "./table.css";
|
|
7
|
-
|
|
8
|
-
export type ColumnType = "boolean" | "number" | "string" | "time";
|
|
9
|
-
|
|
10
|
-
export class Table extends HTMLWidget {
|
|
11
|
-
|
|
12
|
-
protected _div;
|
|
13
|
-
protected _root: any;
|
|
14
|
-
protected _component: any;
|
|
15
|
-
|
|
16
|
-
constructor() {
|
|
17
|
-
super();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
columnType(column: string): ColumnType;
|
|
21
|
-
columnType(column: string, type: ColumnType): this;
|
|
22
|
-
columnType(column: string, type?: ColumnType): ColumnType | this {
|
|
23
|
-
if (arguments.length === 1) return this.columnTypes()[column];
|
|
24
|
-
this.columnTypes({ ...this.columnTypes(), [column]: type });
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
columnPattern(column: string): string;
|
|
29
|
-
columnPattern(column: string, pattern: string): this;
|
|
30
|
-
columnPattern(column: string, pattern?: string): string | this {
|
|
31
|
-
if (arguments.length === 1) return this.columnPatterns()[column];
|
|
32
|
-
this.columnPatterns({ ...this.columnPatterns(), [column]: pattern });
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
columnFormat(column: string): string;
|
|
37
|
-
columnFormat(column: string, format: string): this;
|
|
38
|
-
columnFormat(column: string, format?: string): string | this {
|
|
39
|
-
if (arguments.length === 1) return this.columnFormats()[column];
|
|
40
|
-
this.columnFormats({ ...this.columnFormats(), [column]: format });
|
|
41
|
-
return this;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
private _prevRow;
|
|
45
|
-
private _prevColumn;
|
|
46
|
-
onRowClickCallback(row, column) {
|
|
47
|
-
if (this._prevRow && JSON.stringify(this._prevRow) !== JSON.stringify(row)) {
|
|
48
|
-
this.click(this._prevRow, this._prevColumn ?? "", false);
|
|
49
|
-
}
|
|
50
|
-
if (row) {
|
|
51
|
-
this.click(row, column, true);
|
|
52
|
-
}
|
|
53
|
-
this._prevRow = row;
|
|
54
|
-
this._prevColumn = column;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
enter(domNode, element) {
|
|
58
|
-
super.enter(domNode, element);
|
|
59
|
-
this._div = element
|
|
60
|
-
.append("div")
|
|
61
|
-
.style("display", "grid")
|
|
62
|
-
;
|
|
63
|
-
this._root = createRoot(this._div.node(), { identifierPrefix: this.id() });
|
|
64
|
-
this._component = createElement(ReactTable, { table: this });
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
update(domNode, element) {
|
|
68
|
-
super.update(domNode, element);
|
|
69
|
-
this._div.style("width", this.width() + "px");
|
|
70
|
-
this._div.style("height", this.height() + "px");
|
|
71
|
-
this._root.render(this._component);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
exit(domNode, element) {
|
|
75
|
-
this._div.remove();
|
|
76
|
-
super.exit(domNode, element);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Events ---
|
|
80
|
-
click(row, col, sel) {
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
Table.prototype._class += " dgrid2_Table";
|
|
84
|
-
|
|
85
|
-
export interface Table {
|
|
86
|
-
noDataMessage(): string;
|
|
87
|
-
noDataMessage(_: string): this;
|
|
88
|
-
darkMode(): boolean;
|
|
89
|
-
darkMode(_: boolean): this;
|
|
90
|
-
multiSelect(): boolean;
|
|
91
|
-
multiSelect(_: boolean): this;
|
|
92
|
-
columnTypes(): { [column: string]: ColumnType };
|
|
93
|
-
columnTypes(_: { [column: string]: ColumnType }): this;
|
|
94
|
-
columnPatterns(): { [column: string]: string };
|
|
95
|
-
columnPatterns(_: { [column: string]: string }): this;
|
|
96
|
-
columnFormats(): { [column: string]: string };
|
|
97
|
-
columnFormats(_: { [column: string]: string }): this;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
Table.prototype.publish("noDataMessage", "...empty...", "string", "No Data Message");
|
|
101
|
-
Table.prototype.publish("darkMode", false, "boolean", "Dark Mode");
|
|
102
|
-
Table.prototype.publish("multiSelect", false, "boolean", "Multiple Selection");
|
|
103
|
-
Table.prototype.publish("columnTypes", {}, "object", "Column Types (\"boolean\" | \"number\" | \"string\" | \"time\"");
|
|
104
|
-
Table.prototype.publish("columnPatterns", {}, "object", "Column Patterns");
|
|
105
|
-
Table.prototype.publish("columnFormats", {}, "object", "Column Formats");
|
|
106
|
-
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
import { HTMLWidget } from "@hpcc-js/common";
|
|
4
|
+
import { ReactTable } from "./reactTable.tsx";
|
|
5
|
+
|
|
6
|
+
import "./table.css";
|
|
7
|
+
|
|
8
|
+
export type ColumnType = "boolean" | "number" | "string" | "time";
|
|
9
|
+
|
|
10
|
+
export class Table extends HTMLWidget {
|
|
11
|
+
|
|
12
|
+
protected _div;
|
|
13
|
+
protected _root: any;
|
|
14
|
+
protected _component: any;
|
|
15
|
+
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
columnType(column: string): ColumnType;
|
|
21
|
+
columnType(column: string, type: ColumnType): this;
|
|
22
|
+
columnType(column: string, type?: ColumnType): ColumnType | this {
|
|
23
|
+
if (arguments.length === 1) return this.columnTypes()[column];
|
|
24
|
+
this.columnTypes({ ...this.columnTypes(), [column]: type });
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
columnPattern(column: string): string;
|
|
29
|
+
columnPattern(column: string, pattern: string): this;
|
|
30
|
+
columnPattern(column: string, pattern?: string): string | this {
|
|
31
|
+
if (arguments.length === 1) return this.columnPatterns()[column];
|
|
32
|
+
this.columnPatterns({ ...this.columnPatterns(), [column]: pattern });
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
columnFormat(column: string): string;
|
|
37
|
+
columnFormat(column: string, format: string): this;
|
|
38
|
+
columnFormat(column: string, format?: string): string | this {
|
|
39
|
+
if (arguments.length === 1) return this.columnFormats()[column];
|
|
40
|
+
this.columnFormats({ ...this.columnFormats(), [column]: format });
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private _prevRow;
|
|
45
|
+
private _prevColumn;
|
|
46
|
+
onRowClickCallback(row, column) {
|
|
47
|
+
if (this._prevRow && JSON.stringify(this._prevRow) !== JSON.stringify(row)) {
|
|
48
|
+
this.click(this._prevRow, this._prevColumn ?? "", false);
|
|
49
|
+
}
|
|
50
|
+
if (row) {
|
|
51
|
+
this.click(row, column, true);
|
|
52
|
+
}
|
|
53
|
+
this._prevRow = row;
|
|
54
|
+
this._prevColumn = column;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
enter(domNode, element) {
|
|
58
|
+
super.enter(domNode, element);
|
|
59
|
+
this._div = element
|
|
60
|
+
.append("div")
|
|
61
|
+
.style("display", "grid")
|
|
62
|
+
;
|
|
63
|
+
this._root = createRoot(this._div.node(), { identifierPrefix: this.id() });
|
|
64
|
+
this._component = createElement(ReactTable, { table: this });
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
update(domNode, element) {
|
|
68
|
+
super.update(domNode, element);
|
|
69
|
+
this._div.style("width", this.width() + "px");
|
|
70
|
+
this._div.style("height", this.height() + "px");
|
|
71
|
+
this._root.render(this._component);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
exit(domNode, element) {
|
|
75
|
+
this._div.remove();
|
|
76
|
+
super.exit(domNode, element);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Events ---
|
|
80
|
+
click(row, col, sel) {
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
Table.prototype._class += " dgrid2_Table";
|
|
84
|
+
|
|
85
|
+
export interface Table {
|
|
86
|
+
noDataMessage(): string;
|
|
87
|
+
noDataMessage(_: string): this;
|
|
88
|
+
darkMode(): boolean;
|
|
89
|
+
darkMode(_: boolean): this;
|
|
90
|
+
multiSelect(): boolean;
|
|
91
|
+
multiSelect(_: boolean): this;
|
|
92
|
+
columnTypes(): { [column: string]: ColumnType };
|
|
93
|
+
columnTypes(_: { [column: string]: ColumnType }): this;
|
|
94
|
+
columnPatterns(): { [column: string]: string };
|
|
95
|
+
columnPatterns(_: { [column: string]: string }): this;
|
|
96
|
+
columnFormats(): { [column: string]: string };
|
|
97
|
+
columnFormats(_: { [column: string]: string }): this;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
Table.prototype.publish("noDataMessage", "...empty...", "string", "No Data Message");
|
|
101
|
+
Table.prototype.publish("darkMode", false, "boolean", "Dark Mode");
|
|
102
|
+
Table.prototype.publish("multiSelect", false, "boolean", "Multiple Selection");
|
|
103
|
+
Table.prototype.publish("columnTypes", {}, "object", "Column Types (\"boolean\" | \"number\" | \"string\" | \"time\"");
|
|
104
|
+
Table.prototype.publish("columnPatterns", {}, "object", "Column Patterns");
|
|
105
|
+
Table.prototype.publish("columnFormats", {}, "object", "Column Formats");
|
|
106
|
+
|