@linzjs/step-ag-grid 13.0.0 → 13.1.1

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.
Files changed (33) hide show
  1. package/README.md +36 -1
  2. package/dist/GridTheme.scss +2 -2
  3. package/dist/index.css +26 -2
  4. package/dist/src/components/Grid.d.ts +2 -1
  5. package/dist/src/components/GridCell.d.ts +1 -1
  6. package/dist/src/components/gridFilter/GridFilterColumnsToggle.d.ts +5 -0
  7. package/dist/src/components/gridFilter/GridFilterHeaderIconButton.d.ts +11 -0
  8. package/dist/src/components/gridFilter/index.d.ts +3 -0
  9. package/dist/src/components/{GridFilter.d.ts → gridFilter/useGridFilter.d.ts} +2 -2
  10. package/dist/src/components/index.d.ts +0 -1
  11. package/dist/src/contexts/GridContext.d.ts +8 -3
  12. package/dist/src/contexts/GridContextProvider.d.ts +1 -1
  13. package/dist/step-ag-grid.esm.js +405 -238
  14. package/dist/step-ag-grid.esm.js.map +1 -1
  15. package/package.json +1 -1
  16. package/src/components/Grid.tsx +20 -14
  17. package/src/components/GridCell.tsx +1 -1
  18. package/src/components/gridFilter/GridFilterButtons.tsx +2 -2
  19. package/src/components/gridFilter/GridFilterColumnsToggle.tsx +141 -0
  20. package/src/components/gridFilter/GridFilterHeaderIconButton.tsx +33 -0
  21. package/src/components/gridFilter/GridFilterQuick.tsx +2 -2
  22. package/src/components/gridFilter/index.ts +3 -0
  23. package/src/components/{GridFilter.ts → gridFilter/useGridFilter.ts} +2 -2
  24. package/src/components/index.ts +0 -1
  25. package/src/contexts/GridContext.tsx +26 -5
  26. package/src/contexts/GridContextProvider.tsx +94 -29
  27. package/src/contexts/GridPopoverContextProvider.tsx +4 -3
  28. package/src/stories/grid/GridReadOnly.stories.tsx +13 -6
  29. package/src/styles/Grid.scss +18 -2
  30. package/src/styles/GridFilterColumnsToggle.scss +4 -0
  31. package/src/styles/GridFilterHeaderIconButton.scss +3 -0
  32. package/src/styles/GridTheme.scss +2 -2
  33. package/src/styles/index.scss +3 -0
package/README.md CHANGED
@@ -57,6 +57,10 @@ import {
57
57
  GridPopoverEditDropDown,
58
58
  GridPopoverMessage,
59
59
  GridUpdatingContextProvider,
60
+ GridWrapper,
61
+ GridFilters,
62
+ GridFilterQuick,
63
+ GridFilterButtons
60
64
  } from "@linzjs/step-ag-grid";
61
65
  // Only required for LINZ themes otherwise import the default theme from ag-grid
62
66
  import "@linzjs/step-ag-grid/dist/GridTheme.scss";
@@ -130,7 +134,28 @@ const GridDemo = () => {
130
134
  return (
131
135
  <GridUpdatingContextProvider>
132
136
  <GridContextProvider>
133
- <Grid selectable={true} columnDefs={columnDefs} rowData={rowData} />
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>
134
159
  </GridContextProvider>
135
160
  </GridUpdatingContextProvider>
136
161
  );
@@ -187,3 +212,13 @@ test("click Delete menu option removes row from the table", async () => {
187
212
  await waitFor(async () => expect((await queryRow(12345)).not.toBeDefined());
188
213
  });
189
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
+
@@ -13,8 +13,8 @@
13
13
  @include ag-theme-alpine(
14
14
  (
15
15
  alpine-active-color: lui.$sea,
16
- foreground-color: lui.$grey-80,
17
- data-color: lui.$grey-80,
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: 48px;
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: #989189;
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"];
@@ -25,4 +26,4 @@ export interface GridProps {
25
26
  /**
26
27
  * Wrapper for AgGrid to add commonly used functionality.
27
28
  */
28
- export declare const Grid: (params: GridProps) => JSX.Element;
29
+ export declare const Grid: ({ rowSelection, "data-testid": dataTestId, ...params }: GridProps) => JSX.Element;
@@ -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/GridRenderGenericCell";
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,5 @@
1
+ /// <reference types="react" />
2
+ export interface GridFilterColumnsToggleProps {
3
+ saveState?: boolean;
4
+ }
5
+ export declare const GridFilterColumnsToggle: ({ saveState }: GridFilterColumnsToggleProps) => 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,6 @@
1
+ export * from "./GridFilterHeaderIconButton";
2
+ export * from "./GridFilterColumnsToggle";
1
3
  export * from "./GridFilterButtons";
2
4
  export * from "./GridFilterQuick";
3
5
  export * from "./GridFilters";
6
+ export * from "./useGridFilter";
@@ -1,3 +1,3 @@
1
- import { GridFilterExternal } from "../contexts/GridContext";
2
- import { GridBaseRow } from "./Grid";
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/Grid";
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
- setGridApi: (gridApi: GridApi | undefined) => void;
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>;
@@ -1,5 +1,5 @@
1
1
  import { ReactElement, ReactNode } from "react";
2
- import { GridBaseRow } from "../components/Grid";
2
+ import { GridBaseRow } from "../components";
3
3
  interface GridContextProps {
4
4
  children: ReactNode;
5
5
  }