@hpcc-js/dgrid2 3.1.0 → 3.2.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 +3106 -496
- package/dist/index.js.map +1 -7
- package/dist/index.umd.cjs +3 -0
- package/dist/index.umd.cjs.map +1 -0
- package/package.json +16 -19
- package/src/__package__.ts +2 -2
- package/src/hooks.ts +2 -3
- package/src/reactTable.tsx +16 -15
- package/src/table.ts +2 -6
- package/types/__package__.d.ts +2 -2
- package/types/reactTable.d.ts +2 -2
- package/types/table.d.ts +0 -2
package/package.json
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpcc-js/dgrid2",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "hpcc-js - DGrid2",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"main": "./dist/index.umd.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
6
8
|
"exports": {
|
|
7
9
|
".": {
|
|
8
10
|
"types": "./types/index.d.ts",
|
|
9
|
-
"
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.umd.cjs"
|
|
10
13
|
},
|
|
11
14
|
"./dist/*": "./dist/*"
|
|
12
15
|
},
|
|
13
|
-
"
|
|
14
|
-
"browser": "./dist/index.js",
|
|
16
|
+
"browser": "./dist/index.umd.cjs",
|
|
15
17
|
"types": "./types/index.d.ts",
|
|
16
18
|
"files": [
|
|
17
19
|
"dist/*",
|
|
18
20
|
"src/*",
|
|
19
|
-
"types/*"
|
|
20
|
-
"font-awesome/**/*"
|
|
21
|
+
"types/*"
|
|
21
22
|
],
|
|
22
23
|
"scripts": {
|
|
23
24
|
"clean": "rimraf --glob lib* types dist *.tsbuildinfo .turbo",
|
|
24
|
-
"bundle": "
|
|
25
|
-
"bundle-watch": "
|
|
25
|
+
"bundle": "vite build",
|
|
26
|
+
"bundle-watch": "vite --port 5507",
|
|
26
27
|
"gen-types": "tsc --project tsconfig.json",
|
|
27
28
|
"gen-types-watch": "npm run gen-types -- --watch",
|
|
28
29
|
"build": "run-p gen-types bundle",
|
|
@@ -36,18 +37,14 @@
|
|
|
36
37
|
"update-major": "npx --yes npm-check-updates -u"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"@hpcc-js/common": "^3.
|
|
40
|
-
"@hpcc-js/util": "^3.
|
|
40
|
+
"@hpcc-js/common": "^3.3.0",
|
|
41
|
+
"@hpcc-js/util": "^3.3.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@hpcc-js/esbuild-plugins": "^1.
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"react-
|
|
47
|
-
},
|
|
48
|
-
"peerDependencies": {
|
|
49
|
-
"react": "^17.0.0 || ^18.0.0",
|
|
50
|
-
"react-dom": "^17.0.0 || ^18.0.0"
|
|
44
|
+
"@hpcc-js/esbuild-plugins": "^1.4.0",
|
|
45
|
+
"@preact/preset-vite": "2.9.2",
|
|
46
|
+
"preact": "10.25.0",
|
|
47
|
+
"react-data-grid": "7.0.0-beta.47"
|
|
51
48
|
},
|
|
52
49
|
"repository": {
|
|
53
50
|
"type": "git",
|
|
@@ -60,5 +57,5 @@
|
|
|
60
57
|
"url": "https://github.com/hpcc-systems/Visualization/issues"
|
|
61
58
|
},
|
|
62
59
|
"homepage": "https://github.com/hpcc-systems/Visualization",
|
|
63
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "145a4d4c8189c70f08e9804e63959d6dd398bd9f"
|
|
64
61
|
}
|
package/src/__package__.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export const PKG_NAME = "@hpcc-js/dgrid2";
|
|
2
|
-
export const PKG_VERSION = "3.1.
|
|
3
|
-
export const BUILD_VERSION = "3.2.
|
|
2
|
+
export const PKG_VERSION = "3.1.1";
|
|
3
|
+
export const BUILD_VERSION = "3.2.1";
|
package/src/hooks.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import React from "
|
|
1
|
+
import React from "preact/compat";
|
|
2
2
|
import { Widget } from "@hpcc-js/common";
|
|
3
3
|
|
|
4
4
|
export function useData(widget: Widget): [string[], Array<string | number>[]] {
|
|
5
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6
5
|
const columns: string[] = React.useMemo(() => widget.columns(), [widget, widget.dataChecksum()]);
|
|
7
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8
6
|
const data: Array<string | number>[] = React.useMemo(() => widget.data(), [widget, widget.dataChecksum()]);
|
|
9
7
|
|
|
10
8
|
return [columns, data];
|
|
11
9
|
}
|
|
10
|
+
|
package/src/reactTable.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FunctionComponent } from "preact";
|
|
2
|
+
import { useCallback, useEffect, useState } from "preact/hooks";
|
|
2
3
|
import DataGrid, { Column, SelectColumn, SortColumn } from "react-data-grid";
|
|
3
4
|
import { format, timeFormat, timeParse } from "@hpcc-js/common";
|
|
4
5
|
import { useData } from "./hooks.ts";
|
|
@@ -23,7 +24,7 @@ interface EmptyRowsRendererProps {
|
|
|
23
24
|
message: string
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
const EmptyRowsRenderer:
|
|
27
|
+
const EmptyRowsRenderer: FunctionComponent<EmptyRowsRendererProps> = ({
|
|
27
28
|
message
|
|
28
29
|
}) => {
|
|
29
30
|
|
|
@@ -33,7 +34,7 @@ const EmptyRowsRenderer: React.FunctionComponent<EmptyRowsRendererProps> = ({
|
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
interface ColumnEx<TRow, TSummaryRow = unknown> extends Column<TRow, TSummaryRow> {
|
|
36
|
-
renderCell?: (props: any) =>
|
|
37
|
+
renderCell?: (props: any) => any;
|
|
37
38
|
__hpcc_pattern?: ReturnType<typeof timeParse>;
|
|
38
39
|
__hpcc_format?: ReturnType<typeof format> | ReturnType<typeof timeFormat>;
|
|
39
40
|
}
|
|
@@ -43,7 +44,7 @@ export interface ReactTableProps {
|
|
|
43
44
|
sort?: QuerySortItem,
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
export const ReactTable:
|
|
47
|
+
export const ReactTable: FunctionComponent<ReactTableProps> = ({
|
|
47
48
|
table,
|
|
48
49
|
sort
|
|
49
50
|
}) => {
|
|
@@ -53,13 +54,13 @@ export const ReactTable: React.FunctionComponent<ReactTableProps> = ({
|
|
|
53
54
|
const columnPatterns = table.columnPatterns();
|
|
54
55
|
const columnFormats = table.columnFormats();
|
|
55
56
|
|
|
56
|
-
const [listColumns, setListColumns] =
|
|
57
|
-
const [sortColumn, setSortColumn] =
|
|
58
|
-
const [rows, setRows] =
|
|
59
|
-
const [selectedRows, setSelectedRows] =
|
|
57
|
+
const [listColumns, setListColumns] = useState<ColumnEx<any[]>[]>([]);
|
|
58
|
+
const [sortColumn, setSortColumn] = useState<SortColumn>();
|
|
59
|
+
const [rows, setRows] = useState<any[]>([]);
|
|
60
|
+
const [selectedRows, setSelectedRows] = useState<ReadonlySet<number>>(new Set());
|
|
60
61
|
|
|
61
62
|
// Columns ---
|
|
62
|
-
|
|
63
|
+
useEffect(() => {
|
|
63
64
|
setListColumns([
|
|
64
65
|
...multiSelect ? [SelectColumn as ColumnEx<any[]>] : [],
|
|
65
66
|
...columns.map((column): ColumnEx<any[]> => {
|
|
@@ -94,7 +95,7 @@ export const ReactTable: React.FunctionComponent<ReactTableProps> = ({
|
|
|
94
95
|
]);
|
|
95
96
|
}, [columnFormats, columnPatterns, columnTypes, columns, multiSelect]);
|
|
96
97
|
|
|
97
|
-
const onSortColumnsChange =
|
|
98
|
+
const onSortColumnsChange = useCallback((sortColumns: SortColumn[]) => {
|
|
98
99
|
const futureSortColumn = sortColumns.slice(-1)[0];
|
|
99
100
|
const sorted = futureSortColumn !== undefined;
|
|
100
101
|
const isSortedDescending: boolean = futureSortColumn?.direction === "DESC";
|
|
@@ -102,20 +103,20 @@ export const ReactTable: React.FunctionComponent<ReactTableProps> = ({
|
|
|
102
103
|
setRows(copyAndSort(rows, sorted ? futureSortColumn.columnKey : "key", sorted ? isSortedDescending : false));
|
|
103
104
|
}, [rows]);
|
|
104
105
|
|
|
105
|
-
const rowKeyGetter =
|
|
106
|
+
const rowKeyGetter = useCallback((row: any) => {
|
|
106
107
|
return row.key;
|
|
107
108
|
}, []);
|
|
108
109
|
|
|
109
|
-
const onSelectedRowsChange =
|
|
110
|
+
const onSelectedRowsChange = useCallback((selectedRows: Set<any>) => {
|
|
110
111
|
setSelectedRows(selectedRows);
|
|
111
112
|
}, []);
|
|
112
113
|
|
|
113
|
-
const onCellClick =
|
|
114
|
+
const onCellClick = useCallback((row, column) => {
|
|
114
115
|
table.onRowClickCallback(row, column.key);
|
|
115
116
|
}, [table]);
|
|
116
117
|
|
|
117
118
|
// Rows ---
|
|
118
|
-
|
|
119
|
+
useEffect(() => {
|
|
119
120
|
let items = data.map((row, index) => {
|
|
120
121
|
const retVal = {
|
|
121
122
|
key: index
|
|
@@ -145,7 +146,7 @@ export const ReactTable: React.FunctionComponent<ReactTableProps> = ({
|
|
|
145
146
|
rows={rows}
|
|
146
147
|
rowKeyGetter={rowKeyGetter}
|
|
147
148
|
rowHeight={20}
|
|
148
|
-
renderers={{ noRowsFallback: <EmptyRowsRenderer message={table.noDataMessage()} /> }}
|
|
149
|
+
renderers={{ noRowsFallback: <EmptyRowsRenderer message={table.noDataMessage()} /> as any }}
|
|
149
150
|
className={table.darkMode() ? "rdg-dark" : "rdg-light"}
|
|
150
151
|
sortColumns={sortColumn ? [sortColumn] : []}
|
|
151
152
|
onSortColumnsChange={onSortColumnsChange}
|
package/src/table.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createRoot, Root } from "react-dom/client";
|
|
1
|
+
import { render, createElement } from "preact";
|
|
3
2
|
import { HTMLWidget } from "@hpcc-js/common";
|
|
4
3
|
import { ReactTable } from "./reactTable.tsx";
|
|
5
4
|
|
|
@@ -10,7 +9,6 @@ export type ColumnType = "boolean" | "number" | "string" | "time";
|
|
|
10
9
|
export class Table extends HTMLWidget {
|
|
11
10
|
|
|
12
11
|
protected _div;
|
|
13
|
-
protected _root: Root;
|
|
14
12
|
|
|
15
13
|
constructor() {
|
|
16
14
|
super();
|
|
@@ -59,18 +57,16 @@ export class Table extends HTMLWidget {
|
|
|
59
57
|
.append("div")
|
|
60
58
|
.style("display", "grid")
|
|
61
59
|
;
|
|
62
|
-
this._root = createRoot(this._div.node());
|
|
63
60
|
}
|
|
64
61
|
|
|
65
62
|
update(domNode, element) {
|
|
66
63
|
super.update(domNode, element);
|
|
67
64
|
this._div.style("width", this.width() + "px");
|
|
68
65
|
this._div.style("height", this.height() + "px");
|
|
69
|
-
|
|
66
|
+
render(createElement(ReactTable, { table: this }), this._div.node());
|
|
70
67
|
}
|
|
71
68
|
|
|
72
69
|
exit(domNode, element) {
|
|
73
|
-
this._root.unmount();
|
|
74
70
|
this._div.remove();
|
|
75
71
|
super.exit(domNode, element);
|
|
76
72
|
}
|
package/types/__package__.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const PKG_NAME = "@hpcc-js/dgrid2";
|
|
2
|
-
export declare const PKG_VERSION = "3.1.
|
|
3
|
-
export declare const BUILD_VERSION = "3.2.
|
|
2
|
+
export declare const PKG_VERSION = "3.1.1";
|
|
3
|
+
export declare const BUILD_VERSION = "3.2.1";
|
package/types/reactTable.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FunctionComponent } from "preact";
|
|
2
2
|
import type { Table } from "./table.ts";
|
|
3
3
|
import "react-data-grid/lib/styles.css";
|
|
4
4
|
export type QuerySortItem = {
|
|
@@ -9,4 +9,4 @@ export interface ReactTableProps {
|
|
|
9
9
|
table: Table;
|
|
10
10
|
sort?: QuerySortItem;
|
|
11
11
|
}
|
|
12
|
-
export declare const ReactTable:
|
|
12
|
+
export declare const ReactTable: FunctionComponent<ReactTableProps>;
|
package/types/table.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { Root } from "react-dom/client";
|
|
2
1
|
import { HTMLWidget } from "@hpcc-js/common";
|
|
3
2
|
import "./table.css";
|
|
4
3
|
export type ColumnType = "boolean" | "number" | "string" | "time";
|
|
5
4
|
export declare class Table extends HTMLWidget {
|
|
6
5
|
protected _div: any;
|
|
7
|
-
protected _root: Root;
|
|
8
6
|
constructor();
|
|
9
7
|
columnType(column: string): ColumnType;
|
|
10
8
|
columnType(column: string, type: ColumnType): this;
|