@linzjs/step-ag-grid 21.1.0 → 21.1.2
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/src/components/GridNoRowsOverlay.d.ts +3 -1
- package/dist/step-ag-grid.cjs.js +24 -11
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +25 -13
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +9 -2
- package/src/components/GridNoRowsOverlay.tsx +21 -7
package/package.json
CHANGED
package/src/components/Grid.tsx
CHANGED
|
@@ -165,6 +165,8 @@ export const Grid = ({
|
|
|
165
165
|
const hasSetContentSizeEmpty = useRef(false);
|
|
166
166
|
const needsAutoSize = useRef(true);
|
|
167
167
|
|
|
168
|
+
const lastFullResize = useRef<number>();
|
|
169
|
+
|
|
168
170
|
const setInitialContentSize = useCallback(() => {
|
|
169
171
|
if (!gridDivRef.current?.clientWidth || rowData == null) {
|
|
170
172
|
// Don't resize grids if they are offscreen as it doesn't work.
|
|
@@ -193,8 +195,13 @@ export const Grid = ({
|
|
|
193
195
|
}
|
|
194
196
|
} else if (gridRendered === "rows-visible") {
|
|
195
197
|
if (!hasSetContentSize.current) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
+
if (lastFullResize.current === result.width) {
|
|
199
|
+
hasSetContentSize.current = true;
|
|
200
|
+
params.onContentSize?.(result);
|
|
201
|
+
} else {
|
|
202
|
+
needsAutoSize.current = true;
|
|
203
|
+
}
|
|
204
|
+
lastFullResize.current = result.width;
|
|
198
205
|
}
|
|
199
206
|
} else {
|
|
200
207
|
// It should be impossible to get here
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { LuiStatusSpinner } from "@linzjs/lui";
|
|
2
|
+
import { ForwardedRef, forwardRef } from "react";
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
+
const GridLoadingOverlayComponentFr = (
|
|
5
|
+
props: { headerRowHeight: number },
|
|
6
|
+
externalRef: ForwardedRef<HTMLDivElement>,
|
|
7
|
+
) => (
|
|
4
8
|
<div
|
|
9
|
+
ref={externalRef}
|
|
5
10
|
style={{
|
|
6
11
|
left: 0,
|
|
7
12
|
top: 0,
|
|
@@ -19,6 +24,8 @@ const GridLoadingOverlayComponent = (props: { headerRowHeight: number }) => (
|
|
|
19
24
|
</div>
|
|
20
25
|
);
|
|
21
26
|
|
|
27
|
+
const GridLoadingOverlayComponent = forwardRef(GridLoadingOverlayComponentFr);
|
|
28
|
+
|
|
22
29
|
export interface GridNoRowsOverlayProps {
|
|
23
30
|
loading: boolean;
|
|
24
31
|
rowCount: number | undefined | null;
|
|
@@ -28,10 +35,17 @@ export interface GridNoRowsOverlayProps {
|
|
|
28
35
|
headerRowHeight: number;
|
|
29
36
|
}
|
|
30
37
|
|
|
31
|
-
export const
|
|
32
|
-
if (props.loading)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
export const GridNoRowsOverlayFr = (props: GridNoRowsOverlayProps, externalRef: ForwardedRef<HTMLDivElement>) => {
|
|
39
|
+
if (props.loading) {
|
|
40
|
+
return <GridLoadingOverlayComponent ref={externalRef} headerRowHeight={props.headerRowHeight} />;
|
|
41
|
+
}
|
|
42
|
+
if (props.rowCount === 0) {
|
|
43
|
+
return <div ref={externalRef}>{props.noRowsOverlayText ?? "There are currently no rows"}</div>;
|
|
44
|
+
}
|
|
45
|
+
if (props.filteredRowCount === 0) {
|
|
46
|
+
return <div ref={externalRef}>{props.noRowsMatchingOverlayText ?? "All rows have been filtered"}</div>;
|
|
47
|
+
}
|
|
48
|
+
return <div ref={externalRef} />;
|
|
37
49
|
};
|
|
50
|
+
|
|
51
|
+
export const GridNoRowsOverlay = forwardRef(GridNoRowsOverlayFr);
|