@hpcc-js/dgrid 3.7.8 → 3.8.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.
- 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 +7 -7
- package/src/ColumnSetTable.ts +97 -0
- package/src/Common.ts +10 -2
- package/src/Table.ts +5 -1
- package/src/dgrid-shim.ts +1 -0
- package/src/index.ts +2 -1
- package/types/ColumnSetTable.d.ts +16 -0
- package/types/Common.d.ts +2 -0
- package/types/Table.d.ts +1 -0
- package/types/dgrid-shim.d.ts +1 -0
- package/types/index.d.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpcc-js/dgrid",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "hpcc-js - Viz DGrid",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.umd.cjs",
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"update-major": "npx --yes npm-check-updates -u"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@hpcc-js/common": "^3.7.
|
|
43
|
-
"@hpcc-js/dgrid-shim": "^3.
|
|
44
|
-
"@hpcc-js/util": "^3.5.
|
|
42
|
+
"@hpcc-js/common": "^3.7.9",
|
|
43
|
+
"@hpcc-js/dgrid-shim": "^3.5.0",
|
|
44
|
+
"@hpcc-js/util": "^3.5.8"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@hpcc-js/ddl-shim": "^3.3.
|
|
48
|
-
"@hpcc-js/esbuild-plugins": "^1.8.
|
|
47
|
+
"@hpcc-js/ddl-shim": "^3.3.8",
|
|
48
|
+
"@hpcc-js/esbuild-plugins": "^1.8.10",
|
|
49
49
|
"@testing-library/dom": "10.4.1",
|
|
50
50
|
"d3-format": "^1",
|
|
51
51
|
"d3-selection": "^1"
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"url": "https://github.com/hpcc-systems/Visualization/issues"
|
|
62
62
|
},
|
|
63
63
|
"homepage": "https://github.com/hpcc-systems/Visualization",
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "40c9476d944129ade31563679b2c08ee526f9df0"
|
|
65
65
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ColumnSetGrid } from "./dgrid-shim.ts";
|
|
2
|
+
import { type ColumnType } from "./RowFormatter.ts";
|
|
3
|
+
import { Table } from "./Table.ts";
|
|
4
|
+
|
|
5
|
+
export class ColumnSetTable extends Table {
|
|
6
|
+
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
protected _buildColumnSets(): ColumnType[][][] {
|
|
12
|
+
const sets = this.columnSets();
|
|
13
|
+
const colNames = this.columns();
|
|
14
|
+
const used = new Set<string>();
|
|
15
|
+
const result: ColumnType[][][] = [];
|
|
16
|
+
|
|
17
|
+
const lookup = (name: string): ColumnType | undefined => {
|
|
18
|
+
const idx = colNames.indexOf(name);
|
|
19
|
+
if (idx < 0) return undefined;
|
|
20
|
+
const col = this._columns[idx];
|
|
21
|
+
if (!col || col.hidden) return undefined;
|
|
22
|
+
return col;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
if (sets && sets.length) {
|
|
26
|
+
for (const set of sets) {
|
|
27
|
+
const cols: ColumnType[] = [];
|
|
28
|
+
for (const name of set) {
|
|
29
|
+
const col = lookup(name);
|
|
30
|
+
if (col) {
|
|
31
|
+
cols.push(col);
|
|
32
|
+
used.add(name);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (cols.length) {
|
|
36
|
+
result.push([cols]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (this.autoColumnSet()) {
|
|
42
|
+
const remaining: ColumnType[] = [];
|
|
43
|
+
for (const name of colNames) {
|
|
44
|
+
if (!used.has(name)) {
|
|
45
|
+
const col = lookup(name);
|
|
46
|
+
if (col) remaining.push(col);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (remaining.length) {
|
|
50
|
+
result.push([remaining]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!result.length && this._columns.length) {
|
|
55
|
+
result.push([this._columns.filter(c => !c.hidden)]);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
protected _gridColumnsConfig(): object {
|
|
62
|
+
return { columnSets: this._buildColumnSets() };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
protected _createGrid(opts: any, node: HTMLElement): any {
|
|
66
|
+
return new ColumnSetGrid({ ...opts }, node);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
protected _applyColumnsToGrid() {
|
|
70
|
+
const sets = this._buildColumnSets();
|
|
71
|
+
this._dgrid.set("columnSets", sets);
|
|
72
|
+
for (let i = 0; i < sets.length - 1; i++) {
|
|
73
|
+
const setWidth = sets[i][0].reduce((total: number, col: ColumnType) => total + (col.width ?? 0), 0);
|
|
74
|
+
if (setWidth > 0) {
|
|
75
|
+
(this._dgrid as any).styleColumnSet(i, `width: ${setWidth}px;`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
this._dgrid.resize();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
dblclickColResize(column: string, dgridColumn: any): void {
|
|
82
|
+
this.guessWidth([dgridColumn], this.data());
|
|
83
|
+
this._dgrid.applyWidth(dgridColumn.id, dgridColumn.width + "px");
|
|
84
|
+
this._dgrid.resize();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
ColumnSetTable.prototype._class += " dgrid_ColumnSetTable";
|
|
88
|
+
|
|
89
|
+
export interface ColumnSetTable {
|
|
90
|
+
columnSets(): string[][];
|
|
91
|
+
columnSets(_: string[][]): this;
|
|
92
|
+
autoColumnSet(): boolean;
|
|
93
|
+
autoColumnSet(_: boolean): this;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
ColumnSetTable.prototype.publish("columnSets", [], "array", "Column sets - array of arrays of column names");
|
|
97
|
+
ColumnSetTable.prototype.publish("autoColumnSet", true, "boolean", "Append columns not referenced by columnSets() into a trailing column-set");
|
package/src/Common.ts
CHANGED
|
@@ -82,8 +82,8 @@ export class Common extends HTMLWidget {
|
|
|
82
82
|
.attr("class", "flat")
|
|
83
83
|
;
|
|
84
84
|
}
|
|
85
|
-
this._dgrid =
|
|
86
|
-
|
|
85
|
+
this._dgrid = this._createGrid({
|
|
86
|
+
...this._gridColumnsConfig(),
|
|
87
87
|
collection: this._store,
|
|
88
88
|
sort: this.formatSortBy(),
|
|
89
89
|
selectionMode: this.multiSelect() ? "extended" : "single",
|
|
@@ -142,6 +142,14 @@ export class Common extends HTMLWidget {
|
|
|
142
142
|
|
|
143
143
|
dblclickColResize(column, dgridColumn) {
|
|
144
144
|
}
|
|
145
|
+
|
|
146
|
+
protected _gridColumnsConfig(): object {
|
|
147
|
+
return { columns: this._columns };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
protected _createGrid(opts: any, node: HTMLElement): any {
|
|
151
|
+
return new (this._prevPaging ? PagingGrid : Grid)(opts, node);
|
|
152
|
+
}
|
|
145
153
|
}
|
|
146
154
|
Common.prototype._class += " dgrid_Common";
|
|
147
155
|
|
package/src/Table.ts
CHANGED
|
@@ -193,7 +193,7 @@ export class Table extends Common {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
this.
|
|
196
|
+
this._applyColumnsToGrid();
|
|
197
197
|
this._colsRefresh = false;
|
|
198
198
|
}
|
|
199
199
|
if (this._colsRefresh || this._dataRefresh) {
|
|
@@ -213,6 +213,10 @@ export class Table extends Common {
|
|
|
213
213
|
super.exit(domNode, element);
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
+
protected _applyColumnsToGrid() {
|
|
217
|
+
this._dgrid.set("columns", this._columns.filter(col => !col.hidden));
|
|
218
|
+
}
|
|
219
|
+
|
|
216
220
|
// Cell ---
|
|
217
221
|
formatterFunc(): CellFormatter | undefined {
|
|
218
222
|
return function (this: ColumnType, cell: any, row: RowType): string | any {
|
package/src/dgrid-shim.ts
CHANGED
|
@@ -17,4 +17,5 @@ export const Memory = globalThis["@hpcc-js/dgrid-shim"].Memory as typeof dgrid_s
|
|
|
17
17
|
export const QueryResults = globalThis["@hpcc-js/dgrid-shim"].QueryResults as typeof dgrid_shim.QueryResults;
|
|
18
18
|
export const Grid = globalThis["@hpcc-js/dgrid-shim"].Grid as typeof dgrid_shim.Grid;
|
|
19
19
|
export const PagingGrid = globalThis["@hpcc-js/dgrid-shim"].PagingGrid as typeof dgrid_shim.PagingGrid;
|
|
20
|
+
export const ColumnSetGrid = globalThis["@hpcc-js/dgrid-shim"].ColumnSetGrid as typeof dgrid_shim.ColumnSetGrid;
|
|
20
21
|
export const domConstruct = globalThis["@hpcc-js/dgrid-shim"].domConstruct as typeof dgrid_shim.domConstruct;
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./__package__.ts";
|
|
2
2
|
export * from "./Common.ts";
|
|
3
|
+
export * from "./ColumnSetTable.ts";
|
|
3
4
|
export * from "./DatasourceStore.ts";
|
|
4
5
|
export * from "./DatasourceTable.ts";
|
|
5
6
|
export * from "./DBStore.ts";
|
|
@@ -7,4 +8,4 @@ export * from "./RowFormatter.ts";
|
|
|
7
8
|
export * from "./Table.ts";
|
|
8
9
|
|
|
9
10
|
// Must be last...
|
|
10
|
-
export { Deferred, Memory, QueryResults, Grid, PagingGrid, domConstruct } from "./dgrid-shim.ts";
|
|
11
|
+
export { Deferred, Memory, QueryResults, Grid, PagingGrid, ColumnSetGrid, domConstruct } from "./dgrid-shim.ts";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ColumnType } from "./RowFormatter.ts";
|
|
2
|
+
import { Table } from "./Table.ts";
|
|
3
|
+
export declare class ColumnSetTable extends Table {
|
|
4
|
+
constructor();
|
|
5
|
+
protected _buildColumnSets(): ColumnType[][][];
|
|
6
|
+
protected _gridColumnsConfig(): object;
|
|
7
|
+
protected _createGrid(opts: any, node: HTMLElement): any;
|
|
8
|
+
protected _applyColumnsToGrid(): void;
|
|
9
|
+
dblclickColResize(column: string, dgridColumn: any): void;
|
|
10
|
+
}
|
|
11
|
+
export interface ColumnSetTable {
|
|
12
|
+
columnSets(): string[][];
|
|
13
|
+
columnSets(_: string[][]): this;
|
|
14
|
+
autoColumnSet(): boolean;
|
|
15
|
+
autoColumnSet(_: boolean): this;
|
|
16
|
+
}
|
package/types/Common.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ export declare class Common extends HTMLWidget {
|
|
|
25
25
|
exit(domNode: any, element: any): void;
|
|
26
26
|
click(row: any, col: any, sel: any, more: any): void;
|
|
27
27
|
dblclickColResize(column: any, dgridColumn: any): void;
|
|
28
|
+
protected _gridColumnsConfig(): object;
|
|
29
|
+
protected _createGrid(opts: any, node: HTMLElement): any;
|
|
28
30
|
}
|
|
29
31
|
export interface Common {
|
|
30
32
|
noDataMessage(): string;
|
package/types/Table.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export declare class Table extends Common {
|
|
|
43
43
|
_prevHash: any;
|
|
44
44
|
update(domNode: any, element: any): void;
|
|
45
45
|
exit(domNode: any, element: any): void;
|
|
46
|
+
protected _applyColumnsToGrid(): void;
|
|
46
47
|
formatterFunc(): CellFormatter | undefined;
|
|
47
48
|
renderCellFunc(): CellRenderer | undefined;
|
|
48
49
|
click(row: any, col: any, sel: any): void;
|
package/types/dgrid-shim.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export declare const Memory: typeof dgrid_shim.Memory;
|
|
|
4
4
|
export declare const QueryResults: typeof dgrid_shim.QueryResults;
|
|
5
5
|
export declare const Grid: typeof dgrid_shim.Grid;
|
|
6
6
|
export declare const PagingGrid: typeof dgrid_shim.PagingGrid;
|
|
7
|
+
export declare const ColumnSetGrid: typeof dgrid_shim.ColumnSetGrid;
|
|
7
8
|
export declare const domConstruct: typeof dgrid_shim.domConstruct;
|
package/types/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export * from "./__package__.ts";
|
|
2
2
|
export * from "./Common.ts";
|
|
3
|
+
export * from "./ColumnSetTable.ts";
|
|
3
4
|
export * from "./DatasourceStore.ts";
|
|
4
5
|
export * from "./DatasourceTable.ts";
|
|
5
6
|
export * from "./DBStore.ts";
|
|
6
7
|
export * from "./RowFormatter.ts";
|
|
7
8
|
export * from "./Table.ts";
|
|
8
|
-
export { Deferred, Memory, QueryResults, Grid, PagingGrid, domConstruct } from "./dgrid-shim.ts";
|
|
9
|
+
export { Deferred, Memory, QueryResults, Grid, PagingGrid, ColumnSetGrid, domConstruct } from "./dgrid-shim.ts";
|