@linzjs/step-ag-grid 13.1.2 → 13.1.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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@linzjs/step-ag-grid",
3
3
  "repository": "github:linz/step-ag-grid.git",
4
4
  "license": "MIT",
5
- "version": "13.1.2",
5
+ "version": "13.1.3",
6
6
  "keywords": [
7
7
  "aggrid",
8
8
  "ag-grid",
@@ -1,7 +1,7 @@
1
1
  import { CellClickedEvent, ColDef, ModelUpdatedEvent } from "ag-grid-community";
2
2
  import { CellClassParams, EditableCallback, EditableCallbackParams } from "ag-grid-community/dist/lib/entities/colDef";
3
3
  import { GridOptions } from "ag-grid-community/dist/lib/entities/gridOptions";
4
- import { AgGridEvent, CellEvent, GridReadyEvent, SelectionChangedEvent } from "ag-grid-community/dist/lib/events";
4
+ import { CellEvent, GridReadyEvent, SelectionChangedEvent } from "ag-grid-community/dist/lib/events";
5
5
  import { AgGridReact } from "ag-grid-react";
6
6
  import clsx from "clsx";
7
7
  import { difference, isEmpty, last, xorBy } from "lodash-es";
@@ -10,6 +10,7 @@ import { useCallback, useContext, useEffect, useMemo, useRef, useState } from "r
10
10
  import { GridContext } from "../contexts/GridContext";
11
11
  import { GridUpdatingContext } from "../contexts/GridUpdatingContext";
12
12
  import { fnOrVar, isNotEmpty } from "../utils/util";
13
+ import { GridNoRowsOverlay } from "./GridNoRowsOverlay";
13
14
  import { usePostSortRowsHook } from "./PostSortRowsHook";
14
15
  import { GridHeaderSelect } from "./gridHeader";
15
16
 
@@ -213,23 +214,6 @@ export const Grid = ({ rowSelection = "multiple", "data-testid": dataTestId, ...
213
214
  [dataTestId, setApis, synchroniseExternallySelectedItemsToGrid],
214
215
  );
215
216
 
216
- const noRowsOverlayComponent = useCallback(
217
- (event: AgGridEvent) => {
218
- const hasData = (params.rowData?.length ?? 0) > 0;
219
- const hasFilteredData = event.api.getDisplayedRowCount() > 0;
220
- return (
221
- <span>
222
- {!hasData
223
- ? params.noRowsOverlayText ?? "There are currently no rows"
224
- : !hasFilteredData
225
- ? "All rows have been filtered"
226
- : ""}
227
- </span>
228
- );
229
- },
230
- [params.noRowsOverlayText, params.rowData?.length],
231
- );
232
-
233
217
  const onModelUpdated = useCallback((event: ModelUpdatedEvent) => {
234
218
  event.api.getDisplayedRowCount() === 0 ? event.api.showNoRowsOverlay() : event.api.hideOverlay();
235
219
  }, []);
@@ -338,7 +322,8 @@ export const Grid = ({ rowSelection = "multiple", "data-testid": dataTestId, ...
338
322
  domLayout={params.domLayout}
339
323
  columnDefs={columnDefs}
340
324
  rowData={params.rowData}
341
- noRowsOverlayComponent={noRowsOverlayComponent}
325
+ noRowsOverlayComponent={GridNoRowsOverlay}
326
+ noRowsOverlayComponentParams={{ rowData: params.rowData, noRowsOverlayText: params.noRowsOverlayText }}
342
327
  onModelUpdated={onModelUpdated}
343
328
  onGridReady={onGridReady}
344
329
  onSortChanged={ensureSelectedRowIsVisible}
@@ -0,0 +1,12 @@
1
+ import { isEmpty } from "lodash-es";
2
+
3
+ export const GridNoRowsOverlay = (params: {
4
+ rowData: any[] | null | undefined;
5
+ noRowsOverlayText: string | undefined;
6
+ }) => (
7
+ <span>
8
+ {isEmpty(params.rowData)
9
+ ? params.noRowsOverlayText ?? "There are currently no rows"
10
+ : "All rows have been filtered"}
11
+ </span>
12
+ );
@@ -8,6 +8,7 @@ export * from "./gridForm";
8
8
  export * from "./gridHeader";
9
9
  export * from "./GridIcon";
10
10
  export * from "./GridLoadableCell";
11
+ export * from "./GridNoRowsOverlay";
11
12
  export * from "./gridPopoverEdit";
12
13
  export * from "./GridPopoverHook";
13
14
  export * from "./gridRender";
@@ -0,0 +1,36 @@
1
+ import { expect } from "@storybook/jest";
2
+ import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
3
+ import { within } from "@storybook/testing-library";
4
+
5
+ import "@linzjs/lui/dist/fonts";
6
+ import "@linzjs/lui/dist/scss/base.scss";
7
+
8
+ import { GridNoRowsOverlay } from "../../components";
9
+
10
+ export default {
11
+ title: "Components / Grids / GridNoRowsOverlay",
12
+ component: GridNoRowsOverlay,
13
+ args: {},
14
+ } as ComponentMeta<typeof GridNoRowsOverlay>;
15
+
16
+ const GridNoRowsOverlayTemplate: ComponentStory<typeof GridNoRowsOverlay> = (params) => {
17
+ return <GridNoRowsOverlay {...params} />;
18
+ };
19
+
20
+ export const GridNoRowsEmpty = GridNoRowsOverlayTemplate.bind({});
21
+ GridNoRowsEmpty.args = {
22
+ rowData: [],
23
+ };
24
+ GridNoRowsEmpty.play = async ({ canvasElement }) => {
25
+ const canvas = within(canvasElement);
26
+ expect(await canvas.findByText("There are currently no rows")).toBeInTheDocument();
27
+ };
28
+
29
+ export const GridNoRowsFiltered = GridNoRowsOverlayTemplate.bind({});
30
+ GridNoRowsFiltered.args = {
31
+ rowData: [{}],
32
+ };
33
+ GridNoRowsFiltered.play = async ({ canvasElement }) => {
34
+ const canvas = within(canvasElement);
35
+ expect(await canvas.findByText("All rows have been filtered")).toBeInTheDocument();
36
+ };
@@ -20,9 +20,9 @@ import {
20
20
  GridUpdatingContextProvider,
21
21
  MenuOption,
22
22
  wait,
23
- } from "../..";
24
- import "../../styles/GridTheme.scss";
25
- import "../../styles/index.scss";
23
+ } from "../../../";
24
+ import "../../../styles/GridTheme.scss";
25
+ import "../../../styles/index.scss";
26
26
 
27
27
  export default {
28
28
  title: "Components / Grids",