@hpcc-js/dgrid2 3.2.1 → 3.2.3
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 +27779 -1663
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +304 -15
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +10 -12
- package/src/ErrorBoundary.tsx +56 -0
- package/src/reactTable.tsx +21 -19
- package/types/ErrorBoundary.d.ts +17 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpcc-js/dgrid2",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.3",
|
|
4
4
|
"description": "hpcc-js - DGrid2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.umd.cjs",
|
|
@@ -37,19 +37,17 @@
|
|
|
37
37
|
"update-major": "npx --yes npm-check-updates -u"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@hpcc-js/common": "^3.3.
|
|
41
|
-
"@hpcc-js/util": "^3.3.
|
|
42
|
-
},
|
|
43
|
-
"peerDependencies": {
|
|
44
|
-
"react": "^18.0.0",
|
|
45
|
-
"react-dom": "^18.0.0"
|
|
40
|
+
"@hpcc-js/common": "^3.3.3",
|
|
41
|
+
"@hpcc-js/util": "^3.3.3"
|
|
46
42
|
},
|
|
47
43
|
"devDependencies": {
|
|
48
|
-
"@hpcc-js/esbuild-plugins": "^1.4.
|
|
49
|
-
"@types/react": "
|
|
50
|
-
"@types/react-dom": "
|
|
44
|
+
"@hpcc-js/esbuild-plugins": "^1.4.3",
|
|
45
|
+
"@types/react": "19.1.0",
|
|
46
|
+
"@types/react-dom": "19.1.0",
|
|
51
47
|
"@vitejs/plugin-react": "4.3.4",
|
|
52
|
-
"react
|
|
48
|
+
"react": "19.1.0",
|
|
49
|
+
"react-data-grid": "7.0.0-beta.51",
|
|
50
|
+
"react-dom": "19.1.0",
|
|
53
51
|
"vite-plugin-html": "3.2.2"
|
|
54
52
|
},
|
|
55
53
|
"repository": {
|
|
@@ -63,5 +61,5 @@
|
|
|
63
61
|
"url": "https://github.com/hpcc-systems/Visualization/issues"
|
|
64
62
|
},
|
|
65
63
|
"homepage": "https://github.com/hpcc-systems/Visualization",
|
|
66
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "8afa398a6246f7f913bc2cb88402b776d65deb00"
|
|
67
65
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React, { Component, ErrorInfo, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
interface Props {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
fallback?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface State {
|
|
9
|
+
hasError: boolean;
|
|
10
|
+
error: Error | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class ErrorBoundary extends Component<Props, State> {
|
|
14
|
+
public state: State = {
|
|
15
|
+
hasError: false,
|
|
16
|
+
error: null
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
public static getDerivedStateFromError(error: Error): State {
|
|
20
|
+
return { hasError: true, error };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
|
24
|
+
console.error("Error caught by boundary:", error);
|
|
25
|
+
console.error("Component stack:", errorInfo.componentStack);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private handleReset = () => {
|
|
29
|
+
this.setState({ hasError: false, error: null });
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
public render() {
|
|
33
|
+
if (this.state.hasError) {
|
|
34
|
+
if (this.props.fallback) {
|
|
35
|
+
return this.props.fallback;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div className="min-h-[200px] flex items-center justify-center p-8 bg-red-50 rounded-lg border border-red-100">
|
|
40
|
+
<div className="text-center">
|
|
41
|
+
<h2 className="text-xl font-semibold text-red-700 mb-2">Something went wrong</h2>
|
|
42
|
+
<p className="text-red-600">{this.state.error?.message}</p>
|
|
43
|
+
<button
|
|
44
|
+
onClick={this.handleReset}
|
|
45
|
+
className="mt-4 px-4 py-2 bg-red-600 text-white rounded-md hover:bg-red-700 transition-colors"
|
|
46
|
+
>
|
|
47
|
+
Try again
|
|
48
|
+
</button>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return this.props.children;
|
|
55
|
+
}
|
|
56
|
+
}
|
package/src/reactTable.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { FunctionComponent, useCallback, useEffect, useState } from "react";
|
|
2
|
-
import DataGrid,
|
|
2
|
+
import { DataGrid, Column, SelectColumn, SortColumn } from "react-data-grid";
|
|
3
3
|
import { format, timeFormat, timeParse } from "@hpcc-js/common";
|
|
4
|
+
import { ErrorBoundary } from "./ErrorBoundary.tsx";
|
|
4
5
|
import { useData } from "./hooks.ts";
|
|
5
6
|
import type { Table } from "./table.ts";
|
|
6
7
|
|
|
@@ -139,23 +140,24 @@ export const ReactTable: FunctionComponent<ReactTableProps> = ({
|
|
|
139
140
|
setRows(items);
|
|
140
141
|
}, [listColumns, data, sort]);
|
|
141
142
|
|
|
142
|
-
return
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
143
|
+
return (
|
|
144
|
+
<ErrorBoundary fallback={<div>Error loading table</div>}>
|
|
145
|
+
<DataGrid
|
|
146
|
+
columns={listColumns}
|
|
147
|
+
headerRowHeight={24}
|
|
148
|
+
rows={rows}
|
|
149
|
+
rowKeyGetter={rowKeyGetter}
|
|
150
|
+
rowHeight={20}
|
|
151
|
+
renderers={{ noRowsFallback: <EmptyRowsRenderer message={table.noDataMessage()} /> as any }}
|
|
152
|
+
className={table.darkMode() ? "rdg-dark" : "rdg-light"}
|
|
153
|
+
sortColumns={sortColumn ? [sortColumn] : []}
|
|
154
|
+
onSortColumnsChange={onSortColumnsChange}
|
|
155
|
+
selectedRows={selectedRows}
|
|
156
|
+
onSelectedRowsChange={multiSelect ? onSelectedRowsChange : undefined}
|
|
157
|
+
onCellClick={multiSelect ? undefined : (args, event) => onCellClick(args.row, args.column)}
|
|
158
|
+
style={{ height: "100%" }}
|
|
159
|
+
/>
|
|
160
|
+
</ErrorBoundary>
|
|
161
|
+
);
|
|
160
162
|
};
|
|
161
163
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { Component, ErrorInfo, ReactNode } from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
fallback?: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
interface State {
|
|
7
|
+
hasError: boolean;
|
|
8
|
+
error: Error | null;
|
|
9
|
+
}
|
|
10
|
+
export declare class ErrorBoundary extends Component<Props, State> {
|
|
11
|
+
state: State;
|
|
12
|
+
static getDerivedStateFromError(error: Error): State;
|
|
13
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
14
|
+
private handleReset;
|
|
15
|
+
render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode>> | React.JSX.Element;
|
|
16
|
+
}
|
|
17
|
+
export {};
|