@equinor/eds-data-grid-react 0.9.0 → 1.0.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.
|
@@ -199,7 +199,7 @@ function FilterWrapper({
|
|
|
199
199
|
} = useTableContext();
|
|
200
200
|
const firstValue = table.getPreFilteredRowModel().flatRows[0]?.getValue(column.id);
|
|
201
201
|
const [open, setOpen] = react.useState(false);
|
|
202
|
-
const filterIconRef = react.useRef();
|
|
202
|
+
const filterIconRef = react.useRef(null);
|
|
203
203
|
const togglePopover = event => {
|
|
204
204
|
event.stopPropagation();
|
|
205
205
|
setOpen(!open);
|
|
@@ -521,9 +521,33 @@ function TableRow({
|
|
|
521
521
|
rowClass,
|
|
522
522
|
rowStyle
|
|
523
523
|
} = useTableContext();
|
|
524
|
+
const isMountedRef = react.useRef(true);
|
|
525
|
+
|
|
526
|
+
// Set mounted flag to false on unmount to prevent measurements during cleanup
|
|
527
|
+
react.useEffect(() => {
|
|
528
|
+
return () => {
|
|
529
|
+
isMountedRef.current = false;
|
|
530
|
+
};
|
|
531
|
+
}, []);
|
|
532
|
+
|
|
533
|
+
// Create a stable ref callback that guards against calls during unmount
|
|
534
|
+
const measureRef = react.useCallback(node => {
|
|
535
|
+
// Only measure if we have a node, the component is still mounted, and we have a virtualizer
|
|
536
|
+
if (node && isMountedRef.current && rowVirtualizer) {
|
|
537
|
+
try {
|
|
538
|
+
rowVirtualizer.measureElement(node);
|
|
539
|
+
} catch (error) {
|
|
540
|
+
// Silently catch any errors during measurement to prevent crashes
|
|
541
|
+
// This can happen if the virtualizer is in an inconsistent state during unmount
|
|
542
|
+
if (process.env.NODE_ENV === 'development') {
|
|
543
|
+
console.warn('Failed to measure element during virtualization:', error);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}, [rowVirtualizer]);
|
|
524
548
|
return /*#__PURE__*/jsxRuntime.jsx(StyledTableRow, {
|
|
525
549
|
"data-index": virtualItem?.index,
|
|
526
|
-
ref:
|
|
550
|
+
ref: measureRef //measure dynamic row height safely
|
|
527
551
|
,
|
|
528
552
|
style: {
|
|
529
553
|
...(rowStyle?.(row) ?? {})
|
|
@@ -18,7 +18,7 @@ function FilterWrapper({
|
|
|
18
18
|
} = useTableContext();
|
|
19
19
|
const firstValue = table.getPreFilteredRowModel().flatRows[0]?.getValue(column.id);
|
|
20
20
|
const [open, setOpen] = useState(false);
|
|
21
|
-
const filterIconRef = useRef();
|
|
21
|
+
const filterIconRef = useRef(null);
|
|
22
22
|
const togglePopover = event => {
|
|
23
23
|
event.stopPropagation();
|
|
24
24
|
setOpen(!open);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Table } from '@equinor/eds-core-react';
|
|
2
|
+
import { useRef, useEffect, useCallback } from 'react';
|
|
2
3
|
import styled from 'styled-components';
|
|
3
4
|
import { useTableContext } from '../EdsDataGridContext.js';
|
|
4
5
|
import { TableBodyCell } from './TableBodyCell.js';
|
|
@@ -17,9 +18,33 @@ function TableRow({
|
|
|
17
18
|
rowClass,
|
|
18
19
|
rowStyle
|
|
19
20
|
} = useTableContext();
|
|
21
|
+
const isMountedRef = useRef(true);
|
|
22
|
+
|
|
23
|
+
// Set mounted flag to false on unmount to prevent measurements during cleanup
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
return () => {
|
|
26
|
+
isMountedRef.current = false;
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
// Create a stable ref callback that guards against calls during unmount
|
|
31
|
+
const measureRef = useCallback(node => {
|
|
32
|
+
// Only measure if we have a node, the component is still mounted, and we have a virtualizer
|
|
33
|
+
if (node && isMountedRef.current && rowVirtualizer) {
|
|
34
|
+
try {
|
|
35
|
+
rowVirtualizer.measureElement(node);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
// Silently catch any errors during measurement to prevent crashes
|
|
38
|
+
// This can happen if the virtualizer is in an inconsistent state during unmount
|
|
39
|
+
if (process.env.NODE_ENV === 'development') {
|
|
40
|
+
console.warn('Failed to measure element during virtualization:', error);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}, [rowVirtualizer]);
|
|
20
45
|
return /*#__PURE__*/jsx(StyledTableRow, {
|
|
21
46
|
"data-index": virtualItem?.index,
|
|
22
|
-
ref:
|
|
47
|
+
ref: measureRef //measure dynamic row height safely
|
|
23
48
|
,
|
|
24
49
|
style: {
|
|
25
50
|
...(rowStyle?.(row) ?? {})
|
|
@@ -17,7 +17,7 @@ type Context<T> = {
|
|
|
17
17
|
};
|
|
18
18
|
export declare const EdsDataGridContext: import("react").Context<Context<any>>;
|
|
19
19
|
export declare function TableProvider<T>({ children, ...props }: Context<T> & {
|
|
20
|
-
children: ReactElement |
|
|
20
|
+
children: ReactElement | ReactElement[];
|
|
21
21
|
}): import("react/jsx-runtime").JSX.Element;
|
|
22
22
|
export declare const useTableContext: () => Context<any>;
|
|
23
23
|
export {};
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import { ColumnPinningPosition } from '@tanstack/react-table';
|
|
2
2
|
export declare const FilterVisibility: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
3
|
-
export declare const TableCell: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<(
|
|
4
|
-
variant?: import("@equinor/eds-core-react/dist/types/components/Table/Table.types").Variants;
|
|
5
|
-
color?: import("@equinor/eds-core-react/dist/types/components/Table/Table.types").Colors;
|
|
6
|
-
sort?: React.AriaAttributes["aria-sort"];
|
|
7
|
-
} & import("react").TdHTMLAttributes<HTMLTableCellElement> & import("react").RefAttributes<HTMLTableCellElement>, "ref"> & {
|
|
8
|
-
ref?: import("react").Ref<HTMLTableCellElement>;
|
|
9
|
-
}) | (Omit<{
|
|
10
|
-
variant?: import("@equinor/eds-core-react/dist/types/components/Table/Table.types").Variants;
|
|
11
|
-
color?: import("@equinor/eds-core-react/dist/types/components/Table/Table.types").Colors;
|
|
12
|
-
sort?: React.AriaAttributes["aria-sort"];
|
|
13
|
-
} & import("react").ThHTMLAttributes<HTMLTableCellElement> & import("react").RefAttributes<HTMLTableCellElement>, "ref"> & {
|
|
14
|
-
ref?: import("react").Ref<HTMLTableCellElement>;
|
|
15
|
-
}), {
|
|
3
|
+
export declare const TableCell: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<(import("@equinor/eds-core-react").CellProps & import("react").RefAttributes<HTMLTableCellElement>) & import("styled-components/dist/types").BaseObject, {
|
|
16
4
|
$sticky: boolean;
|
|
17
5
|
$pinned: ColumnPinningPosition;
|
|
18
6
|
$offset: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/eds-data-grid-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "A feature-rich data-grid written in React, implementing the Equinor Design System",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -15,57 +15,53 @@
|
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@equinor/eds-core-react": ">=0.42.0",
|
|
18
|
-
"react": ">=
|
|
18
|
+
"react": ">=19.0.0",
|
|
19
19
|
"react-dom": ">=16.8",
|
|
20
20
|
"styled-components": ">=5.1"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@tanstack/react-table": "^8.21.3",
|
|
24
24
|
"@tanstack/react-virtual": "^3.13.12",
|
|
25
|
-
"@equinor/eds-icons": "^0.
|
|
26
|
-
"@equinor/eds-
|
|
27
|
-
"@equinor/eds-
|
|
25
|
+
"@equinor/eds-icons": "^1.0.0",
|
|
26
|
+
"@equinor/eds-utils": "^1.0.0",
|
|
27
|
+
"@equinor/eds-tokens": "1.0.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@rollup/plugin-babel": "^6.0.4",
|
|
31
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
31
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
32
32
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
33
|
-
"@storybook/addon-a11y": "^
|
|
34
|
-
"@storybook/addon-
|
|
35
|
-
"@storybook/addon-
|
|
36
|
-
"@storybook/
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@storybook/preview-api": "^8.6.12",
|
|
40
|
-
"@storybook/react": "^8.6.12",
|
|
41
|
-
"@storybook/react-vite": "^8.6.12",
|
|
42
|
-
"@testing-library/dom": "^10.4.0",
|
|
43
|
-
"@testing-library/jest-dom": "^6.6.3",
|
|
33
|
+
"@storybook/addon-a11y": "^9.1.5",
|
|
34
|
+
"@storybook/addon-docs": "^9.1.5",
|
|
35
|
+
"@storybook/addon-links": "^9.1.5",
|
|
36
|
+
"@storybook/react-vite": "^9.1.5",
|
|
37
|
+
"@testing-library/dom": "^10.4.1",
|
|
38
|
+
"@testing-library/jest-dom": "^6.8.0",
|
|
44
39
|
"@testing-library/react": "16.3.0",
|
|
45
40
|
"@testing-library/user-event": "^14.6.1",
|
|
46
41
|
"@types/jest": "^29.5.14",
|
|
47
|
-
"@types/node": "^22.
|
|
42
|
+
"@types/node": "^22.18.0",
|
|
48
43
|
"@types/ramda": "^0.30.2",
|
|
49
|
-
"@types/react": "^
|
|
50
|
-
"@types/react-dom": "^
|
|
44
|
+
"@types/react": "^19.1.12",
|
|
45
|
+
"@types/react-dom": "^19.1.9",
|
|
51
46
|
"babel-plugin-styled-components": "^2.1.4",
|
|
47
|
+
"eslint-plugin-storybook": "9.1.5",
|
|
52
48
|
"jest": "29.7.0",
|
|
53
49
|
"jest-environment-jsdom": "29.7.0",
|
|
54
50
|
"jest-styled-components": "^7.2.0",
|
|
55
51
|
"js-file-download": "^0.4.12",
|
|
56
|
-
"postcss": "^8.5.
|
|
52
|
+
"postcss": "^8.5.6",
|
|
57
53
|
"ramda": "^0.31.3",
|
|
58
|
-
"react": "^
|
|
59
|
-
"react-dom": "^
|
|
60
|
-
"react-hook-form": "^7.
|
|
61
|
-
"rollup": "^4.
|
|
54
|
+
"react": "^19.1.1",
|
|
55
|
+
"react-dom": "^19.1.1",
|
|
56
|
+
"react-hook-form": "^7.62.0",
|
|
57
|
+
"rollup": "^4.50.0",
|
|
62
58
|
"rollup-plugin-delete": "^2.2.0",
|
|
63
59
|
"rollup-plugin-postcss": "^4.0.2",
|
|
64
|
-
"storybook": "^
|
|
60
|
+
"storybook": "^9.1.5",
|
|
65
61
|
"styled-components": "6.1.19",
|
|
66
62
|
"ts-jest": "29.4.0",
|
|
67
63
|
"ts-node": "10.9.2",
|
|
68
|
-
"tsc-watch": "^6.
|
|
64
|
+
"tsc-watch": "^6.3.1",
|
|
69
65
|
"typescript": "~5.8.3"
|
|
70
66
|
},
|
|
71
67
|
"homepage": "https://eds.equinor.com",
|
|
@@ -86,7 +82,7 @@
|
|
|
86
82
|
],
|
|
87
83
|
"scripts": {
|
|
88
84
|
"build": "rollup -c --bundleConfigAsCjs && tsc -p tsconfig.build.json",
|
|
89
|
-
"test": "tsc -p tsconfig.
|
|
85
|
+
"test": "tsc -p tsconfig.test.json && jest",
|
|
90
86
|
"test:watch": "tsc-watch -p tsconfig.test.json --onFirstSuccess \"jest --watch\"",
|
|
91
87
|
"test:update-snapshots": "jest --updateSnapshot",
|
|
92
88
|
"storybook": "storybook dev -p 9000 --ci",
|