@linzjs/step-ag-grid 12.1.2 → 13.1.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/README.md +50 -13
- package/dist/GridTheme.scss +2 -2
- package/dist/index.css +26 -2
- package/dist/src/components/Grid.d.ts +1 -0
- package/dist/src/components/GridCell.d.ts +1 -1
- package/dist/src/components/gridFilter/GridFilterColumnsToggle.d.ts +5 -0
- package/dist/src/components/gridFilter/GridFilterHeaderIconButton.d.ts +11 -0
- package/dist/src/components/gridFilter/index.d.ts +3 -0
- package/dist/src/components/{GridFilter.d.ts → gridFilter/useGridFilter.d.ts} +2 -2
- package/dist/src/components/index.d.ts +0 -1
- package/dist/src/contexts/GridContext.d.ts +8 -3
- package/dist/src/contexts/GridContextProvider.d.ts +1 -1
- package/dist/step-ag-grid.esm.js +497 -56186
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +3 -1
- package/src/components/Grid.tsx +13 -6
- package/src/components/GridCell.tsx +1 -1
- package/src/components/gridFilter/GridFilterButtons.tsx +2 -2
- package/src/components/gridFilter/GridFilterColumnsToggle.tsx +141 -0
- package/src/components/gridFilter/GridFilterHeaderIconButton.tsx +33 -0
- package/src/components/gridFilter/GridFilterQuick.tsx +2 -2
- package/src/components/gridFilter/index.ts +3 -0
- package/src/components/{GridFilter.ts → gridFilter/useGridFilter.ts} +2 -2
- package/src/components/index.ts +0 -1
- package/src/contexts/GridContext.tsx +26 -5
- package/src/contexts/GridContextProvider.tsx +94 -29
- package/src/contexts/GridPopoverContextProvider.tsx +4 -3
- package/src/stories/grid/GridReadOnly.stories.tsx +13 -6
- package/src/styles/Grid.scss +18 -2
- package/src/styles/GridFilterColumnsToggle.scss +4 -0
- package/src/styles/GridFilterHeaderIconButton.scss +3 -0
- package/src/styles/GridTheme.scss +2 -2
- package/src/styles/index.scss +3 -0
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# step-ag-grid
|
|
2
2
|
|
|
3
|
+
[](https://github.com/semantic-release/semantic-release)
|
|
4
|
+
|
|
3
5
|
> Reusable [ag-grid](https://www.ag-grid.com/) component for LINZ / Toitū te whenua.
|
|
4
6
|
|
|
5
7
|
## Features
|
|
@@ -44,21 +46,25 @@ Storybook demo deployed at: https://linz.github.io/step-ag-grid/
|
|
|
44
46
|
Check `src\stories` for more usage examples
|
|
45
47
|
|
|
46
48
|
```tsx
|
|
47
|
-
import "@linzjs/lui/dist/scss/base.scss";
|
|
48
|
-
import "@linzjs/lui/dist/fonts";
|
|
49
|
-
import "@linzjs/step-ag-grid/dist/index.css";
|
|
50
|
-
// Only required for LINZ themes otherwise import the default theme from ag-grid
|
|
51
|
-
import "@linzjs/step-ag-grid/dist/GridTheme.scss";
|
|
52
|
-
|
|
53
49
|
import { useMemo } from "react";
|
|
50
|
+
|
|
51
|
+
import "@linzjs/lui/dist/fonts";
|
|
52
|
+
import "@linzjs/lui/dist/scss/base.scss";
|
|
54
53
|
import {
|
|
55
|
-
GridUpdatingContextProvider,
|
|
56
|
-
GridContextProvider,
|
|
57
54
|
ColDefT,
|
|
58
55
|
GridCell,
|
|
59
|
-
|
|
56
|
+
GridContextProvider,
|
|
60
57
|
GridPopoverEditDropDown,
|
|
58
|
+
GridPopoverMessage,
|
|
59
|
+
GridUpdatingContextProvider,
|
|
60
|
+
GridWrapper,
|
|
61
|
+
GridFilters,
|
|
62
|
+
GridFilterQuick,
|
|
63
|
+
GridFilterButtons
|
|
61
64
|
} from "@linzjs/step-ag-grid";
|
|
65
|
+
// Only required for LINZ themes otherwise import the default theme from ag-grid
|
|
66
|
+
import "@linzjs/step-ag-grid/dist/GridTheme.scss";
|
|
67
|
+
import "@linzjs/step-ag-grid/dist/index.css";
|
|
62
68
|
|
|
63
69
|
const GridDemo = () => {
|
|
64
70
|
interface ITestRow {
|
|
@@ -81,8 +87,8 @@ const GridDemo = () => {
|
|
|
81
87
|
initialWidth: 65,
|
|
82
88
|
maxWidth: 150,
|
|
83
89
|
cellRendererParams: {
|
|
84
|
-
warning: ({value}) => value === "Tester" && "Testers are testing",
|
|
85
|
-
info: ({value}) => value === "Developer" && "Developers are awesome",
|
|
90
|
+
warning: ({ value }) => value === "Tester" && "Testers are testing",
|
|
91
|
+
info: ({ value }) => value === "Developer" && "Developers are awesome",
|
|
86
92
|
},
|
|
87
93
|
}),
|
|
88
94
|
GridPopoverEditDropDown(
|
|
@@ -107,7 +113,7 @@ const GridDemo = () => {
|
|
|
107
113
|
{
|
|
108
114
|
multiEdit: true,
|
|
109
115
|
editorParams: {
|
|
110
|
-
message: async ({selectedRows}) => {
|
|
116
|
+
message: async ({ selectedRows }) => {
|
|
111
117
|
return `There are ${selectedRows.length} row(s) selected`;
|
|
112
118
|
},
|
|
113
119
|
},
|
|
@@ -128,7 +134,28 @@ const GridDemo = () => {
|
|
|
128
134
|
return (
|
|
129
135
|
<GridUpdatingContextProvider>
|
|
130
136
|
<GridContextProvider>
|
|
131
|
-
<
|
|
137
|
+
<GridWrapper>
|
|
138
|
+
<GridFilters>
|
|
139
|
+
<GridFilterQuick quickFilterPlaceholder={"Search..."} />
|
|
140
|
+
<GridFilterButtons<ITestRow>
|
|
141
|
+
options={[
|
|
142
|
+
{
|
|
143
|
+
label: "All",
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
label: "Developers",
|
|
147
|
+
filter: (row) => row.position === "Developer",
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
label: "Testers",
|
|
151
|
+
filter: (row) => row.position === "Tester",
|
|
152
|
+
},
|
|
153
|
+
]}
|
|
154
|
+
/>
|
|
155
|
+
<GridFilterColumnsToggle/>
|
|
156
|
+
</GridFilters>
|
|
157
|
+
<Grid selectable={true} columnDefs={columnDefs} rowData={rowData} />
|
|
158
|
+
</GridWrapper>
|
|
132
159
|
</GridContextProvider>
|
|
133
160
|
</GridUpdatingContextProvider>
|
|
134
161
|
);
|
|
@@ -185,3 +212,13 @@ test("click Delete menu option removes row from the table", async () => {
|
|
|
185
212
|
await waitFor(async () => expect((await queryRow(12345)).not.toBeDefined());
|
|
186
213
|
});
|
|
187
214
|
```
|
|
215
|
+
|
|
216
|
+
## Playwright support
|
|
217
|
+
|
|
218
|
+
If your grid has a data-testid a global will be exposed in window with the helper scrollRowIntoViewById.
|
|
219
|
+
This will throw an exception if the row id is not found.
|
|
220
|
+
|
|
221
|
+
```tsx
|
|
222
|
+
window.__stepAgGrid.grids[dataTestId].scrollRowIntoViewById("1000")
|
|
223
|
+
```
|
|
224
|
+
|
package/dist/GridTheme.scss
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
@include ag-theme-alpine(
|
|
14
14
|
(
|
|
15
15
|
alpine-active-color: lui.$sea,
|
|
16
|
-
foreground-color: lui.$
|
|
17
|
-
data-color: lui.$
|
|
16
|
+
foreground-color: lui.$charcoal,
|
|
17
|
+
data-color: lui.$charcoal,
|
|
18
18
|
// ag-grid-community >=28
|
|
19
19
|
selected-row-background-color: lui.$polar,
|
|
20
20
|
header-foreground-color: lui.$surfie,
|
package/dist/index.css
CHANGED
|
@@ -342,17 +342,20 @@
|
|
|
342
342
|
margin-bottom: 16px;
|
|
343
343
|
flex: 0;
|
|
344
344
|
display: flex;
|
|
345
|
+
align-items: center;
|
|
345
346
|
flex-direction: row;
|
|
346
347
|
grid-column-gap: 1em;
|
|
348
|
+
padding: 0.25rem 0;
|
|
347
349
|
}
|
|
348
350
|
|
|
349
351
|
.Grid-quickFilterBox {
|
|
350
352
|
width: 100%;
|
|
351
|
-
height:
|
|
353
|
+
height: 40px;
|
|
352
354
|
border: 0.06rem solid #beb9b4;
|
|
353
355
|
border-radius: 3px;
|
|
354
356
|
padding-left: 0.75rem;
|
|
355
357
|
padding-right: 0.75rem;
|
|
358
|
+
font-family: "Open Sans", system-ui, sans-serif;
|
|
356
359
|
}
|
|
357
360
|
|
|
358
361
|
.Grid-popoverContainer {
|
|
@@ -374,7 +377,7 @@
|
|
|
374
377
|
}
|
|
375
378
|
|
|
376
379
|
.GridCell-readonly {
|
|
377
|
-
color: #
|
|
380
|
+
color: #6b6966;
|
|
378
381
|
}
|
|
379
382
|
|
|
380
383
|
.Grid-container.ag-theme-alpine .ag-cell {
|
|
@@ -393,6 +396,18 @@
|
|
|
393
396
|
width: 100%;
|
|
394
397
|
}
|
|
395
398
|
|
|
399
|
+
.flex-col-center {
|
|
400
|
+
display: flex;
|
|
401
|
+
flex-direction: column;
|
|
402
|
+
align-items: center;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
.flex-row-center {
|
|
406
|
+
display: flex;
|
|
407
|
+
flex-direction: row;
|
|
408
|
+
align-items: center;
|
|
409
|
+
}
|
|
410
|
+
|
|
396
411
|
.GridPopoverEditDropDown-containerSmall .GridFormDropDown-options {
|
|
397
412
|
max-height: 120px;
|
|
398
413
|
overflow-y: auto;
|
|
@@ -492,3 +507,12 @@
|
|
|
492
507
|
.GridPopoutMenu-burgerDisabled svg {
|
|
493
508
|
fill: #989189;
|
|
494
509
|
}
|
|
510
|
+
|
|
511
|
+
.GridFilterColumnsToggle-container {
|
|
512
|
+
max-height: 280px;
|
|
513
|
+
overflow: auto;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
.MenuItem-icon {
|
|
517
|
+
margin-right: 8px;
|
|
518
|
+
}
|
|
@@ -14,6 +14,7 @@ export interface GridProps {
|
|
|
14
14
|
defaultColDef?: GridOptions["defaultColDef"];
|
|
15
15
|
columnDefs: ColDef[];
|
|
16
16
|
rowData: GridOptions["rowData"];
|
|
17
|
+
noRowsOverlayText?: string;
|
|
17
18
|
postSortRows?: GridOptions["postSortRows"];
|
|
18
19
|
animateRows?: boolean;
|
|
19
20
|
rowClassRules?: GridOptions["rowClassRules"];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { ColDef, ICellEditorParams, ICellRendererParams } from "ag-grid-community";
|
|
3
3
|
import { SuppressKeyboardEventParams } from "ag-grid-community/dist/lib/entities/colDef";
|
|
4
4
|
import { GridBaseRow } from "./Grid";
|
|
5
|
-
import { GenericCellColDef, RowValueFormatterParams, RowValueGetterParams } from "./gridRender
|
|
5
|
+
import { GenericCellColDef, RowValueFormatterParams, RowValueGetterParams } from "./gridRender";
|
|
6
6
|
export interface GenericCellEditorProps<E> {
|
|
7
7
|
multiEdit?: boolean;
|
|
8
8
|
editor?: (editorProps: E) => JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, MouseEvent } from "react";
|
|
2
|
+
import { IconName, IconSize } from "@linzjs/lui/dist/components/LuiIcon/LuiIcon";
|
|
3
|
+
export interface GridFilterHeaderIconButtonProps {
|
|
4
|
+
icon: IconName;
|
|
5
|
+
onClick?: (e: MouseEvent) => void;
|
|
6
|
+
buttonProps?: Partial<ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
size?: IconSize;
|
|
9
|
+
title: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const GridFilterHeaderIconButton: import("react").ForwardRefExoticComponent<GridFilterHeaderIconButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { GridFilterExternal } from "
|
|
2
|
-
import { GridBaseRow } from "
|
|
1
|
+
import { GridFilterExternal } from "../../contexts/GridContext";
|
|
2
|
+
import { GridBaseRow } from "../Grid";
|
|
3
3
|
export declare const useGridFilter: <RowType extends GridBaseRow>(filter: GridFilterExternal<RowType> | undefined) => void;
|
|
@@ -4,7 +4,6 @@ export * from "./GridCell";
|
|
|
4
4
|
export * from "./GridCellMultiEditor";
|
|
5
5
|
export * from "./GridCellMultiSelectClassRules";
|
|
6
6
|
export * from "./gridFilter";
|
|
7
|
-
export * from "./GridFilter";
|
|
8
7
|
export * from "./gridForm";
|
|
9
8
|
export * from "./gridHeader";
|
|
10
9
|
export * from "./GridIcon";
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { GridApi, RowNode } from "ag-grid-community";
|
|
3
|
-
import { GridBaseRow } from "../components
|
|
2
|
+
import { ColumnApi, GridApi, RowNode } from "ag-grid-community";
|
|
3
|
+
import { ColDefT, GridBaseRow } from "../components";
|
|
4
4
|
export type GridFilterExternal<RowType extends GridBaseRow> = (data: RowType, rowNode: RowNode) => boolean;
|
|
5
5
|
export interface GridContextType<RowType extends GridBaseRow> {
|
|
6
6
|
gridReady: boolean;
|
|
7
|
-
|
|
7
|
+
setApis: (gridApi: GridApi | undefined, columnApi: ColumnApi | undefined, dataTestId?: string) => void;
|
|
8
8
|
prePopupOps: () => void;
|
|
9
9
|
setQuickFilter: (quickFilter: string) => void;
|
|
10
10
|
editingCells: () => boolean;
|
|
11
11
|
getSelectedRows: <T extends GridBaseRow>() => T[];
|
|
12
|
+
getFilteredSelectedRows: <T extends GridBaseRow>() => T[];
|
|
12
13
|
getSelectedRowIds: () => number[];
|
|
14
|
+
getFilteredSelectedRowIds: () => number[];
|
|
13
15
|
selectRowsDiff: (updateFn: () => Promise<any>) => Promise<void>;
|
|
14
16
|
selectRowsWithFlashDiff: (updateFn: () => Promise<any>) => Promise<void>;
|
|
15
17
|
selectRowsById: (rowIds?: number[]) => void;
|
|
@@ -33,6 +35,9 @@ export interface GridContextType<RowType extends GridBaseRow> {
|
|
|
33
35
|
removeExternalFilter: (filter: GridFilterExternal<RowType>) => void;
|
|
34
36
|
isExternalFilterPresent: () => boolean;
|
|
35
37
|
doesExternalFilterPass: (node: RowNode) => boolean;
|
|
38
|
+
getColumns: () => ColDefT<RowType>[];
|
|
39
|
+
invisibleColumnIds: string[];
|
|
40
|
+
setInvisibleColumnIds: (colIds: string[]) => void;
|
|
36
41
|
}
|
|
37
42
|
export declare const GridContext: import("react").Context<GridContextType<any>>;
|
|
38
43
|
export declare const useGridContext: <RowType extends GridBaseRow>() => GridContextType<RowType>;
|