@hpcc-js/dgrid2 3.1.1 → 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 +3086 -423
- 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 +15 -13
- package/src/hooks.ts +1 -3
- package/src/reactTable.tsx +14 -13
- package/src/table.ts +2 -4
- package/types/reactTable.d.ts +2 -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,12 +37,13 @@
|
|
|
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
|
-
"@
|
|
44
|
+
"@hpcc-js/esbuild-plugins": "^1.4.0",
|
|
45
|
+
"@preact/preset-vite": "2.9.2",
|
|
46
|
+
"preact": "10.25.0",
|
|
45
47
|
"react-data-grid": "7.0.0-beta.47"
|
|
46
48
|
},
|
|
47
49
|
"repository": {
|
|
@@ -55,5 +57,5 @@
|
|
|
55
57
|
"url": "https://github.com/hpcc-systems/Visualization/issues"
|
|
56
58
|
},
|
|
57
59
|
"homepage": "https://github.com/hpcc-systems/Visualization",
|
|
58
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "145a4d4c8189c70f08e9804e63959d6dd398bd9f"
|
|
59
61
|
}
|
package/src/hooks.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
import React from "preact/compat";
|
|
1
2
|
import { Widget } from "@hpcc-js/common";
|
|
2
|
-
import * as React from "react";
|
|
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];
|
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
|
|
|
@@ -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
|
package/src/table.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { render, createElement } from "preact";
|
|
2
2
|
import { HTMLWidget } from "@hpcc-js/common";
|
|
3
|
-
import { render, unmountComponentAtNode } from "react-dom";
|
|
4
3
|
import { ReactTable } from "./reactTable.tsx";
|
|
5
4
|
|
|
6
5
|
import "./table.css";
|
|
@@ -64,11 +63,10 @@ export class Table extends HTMLWidget {
|
|
|
64
63
|
super.update(domNode, element);
|
|
65
64
|
this._div.style("width", this.width() + "px");
|
|
66
65
|
this._div.style("height", this.height() + "px");
|
|
67
|
-
render(
|
|
66
|
+
render(createElement(ReactTable, { table: this }), this._div.node());
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
exit(domNode, element) {
|
|
71
|
-
unmountComponentAtNode(this._div.node());
|
|
72
70
|
this._div.remove();
|
|
73
71
|
super.exit(domNode, element);
|
|
74
72
|
}
|
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>;
|