@linzjs/step-ag-grid 7.1.1 → 7.2.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/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": "7.1.1",
5
+ "version": "7.2.0",
6
6
  "keywords": [
7
7
  "aggrid",
8
8
  "ag-grid",
@@ -29,6 +29,8 @@ export interface GridProps {
29
29
  rowData: GridOptions["rowData"];
30
30
  noRowsOverlayText?: string;
31
31
  postSortRows?: GridOptions["postSortRows"];
32
+ animateRows?: boolean;
33
+ rowClassRules?: GridOptions["rowClassRules"];
32
34
  }
33
35
 
34
36
  /**
@@ -246,6 +248,9 @@ export const Grid = (params: GridProps): JSX.Element => {
246
248
  </div>
247
249
  )}
248
250
  <AgGridReact
251
+ animateRows={params.animateRows}
252
+ rowClassRules={params.rowClassRules}
253
+ defaultColDef={params.defaultColDef}
249
254
  getRowId={(params) => `${params.data.id}`}
250
255
  suppressRowClickSelection={true}
251
256
  rowSelection={"multiple"}
@@ -1,7 +1,7 @@
1
1
  import { forwardRef, useContext } from "react";
2
2
  import { GridBaseRow } from "./Grid";
3
3
  import { GridUpdatingContext } from "../contexts/GridUpdatingContext";
4
- import { GenericMultiEditCellClass } from "./GenericCellClass";
4
+ import { GridCellMultiSelectClassRules } from "./GridCellMultiSelectClassRules";
5
5
  import {
6
6
  GenericCellColDef,
7
7
  GenericCellRendererParams,
@@ -64,7 +64,7 @@ export const GridCell = <RowType extends GridBaseRow, Props extends CellEditorCo
64
64
  sortable: !!(props?.field || props?.valueGetter),
65
65
  resizable: true,
66
66
  ...(custom?.editor && {
67
- cellClass: custom?.multiEdit ? GenericMultiEditCellClass : undefined,
67
+ cellClassRules: GridCellMultiSelectClassRules,
68
68
  editable: props.editable ?? true,
69
69
  cellEditor: GenericCellEditorComponentWrapper(custom),
70
70
  }),
@@ -0,0 +1,9 @@
1
+ import { CellClassParams, CellClassRules } from "ag-grid-community/dist/lib/entities/colDef";
2
+
3
+ export const GridCellMultiSelectClassRules: CellClassRules = {
4
+ "ag-selected-for-edit": ({ api, node, colDef }: CellClassParams) =>
5
+ api
6
+ .getSelectedNodes()
7
+ .map((row) => row.id)
8
+ .includes(node.id) && api.getEditingCells().some((cell) => cell.column.getColDef() === colDef),
9
+ };
@@ -24,6 +24,7 @@ import { GridSubComponentContext } from "contexts/GridSubComponentContext";
24
24
  import { useGridPopoverContext } from "../../contexts/GridPopoverContext";
25
25
  import { FormError } from "../../lui/FormError";
26
26
  import { textMatch } from "../../utils/textMatcher";
27
+ import { GridIcon } from "../GridIcon";
27
28
 
28
29
  type HeaderGroupType = Record<string, MultiSelectOption[]> | undefined;
29
30
 
@@ -34,6 +35,7 @@ export interface MultiSelectOption {
34
35
  subValue?: any;
35
36
  filter?: string;
36
37
  checked?: boolean;
38
+ warning?: string | undefined;
37
39
  }
38
40
 
39
41
  export interface GridFormMultiSelectGroup {
@@ -363,7 +365,12 @@ const MenuRadioItem = (props: {
363
365
  <LuiCheckboxInput
364
366
  isChecked={item.checked ?? false}
365
367
  value={`${item.value}`}
366
- label={item.label ?? (item.value == null ? `<${item.value}>` : `${item.value}`)}
368
+ label={
369
+ <>
370
+ {item.warning && <GridIcon icon={"ic_warning"} title={item.warning} />}
371
+ {item.label ?? (item.value == null ? `<${item.value}>` : `${item.value}`)}
372
+ </>
373
+ }
367
374
  inputProps={{
368
375
  onClick: (e) => {
369
376
  // Click is handled by MenuItem onClick
@@ -1,6 +1,5 @@
1
1
  import "./GridPopoverMenu.scss";
2
2
 
3
- import { GenericMultiEditCellClass } from "../GenericCellClass";
4
3
  import { GridBaseRow } from "../Grid";
5
4
  import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
6
5
  import { GridFormPopoverMenu, GridFormPopoutMenuProps } from "../gridForm/GridFormPopoverMenu";
@@ -18,9 +17,8 @@ export const GridPopoverMenu = <RowType extends GridBaseRow>(
18
17
  {
19
18
  maxWidth: 40,
20
19
  editable: colDef.editable != null ? colDef.editable : true,
21
- cellStyle: { justifyContent: "flex-end" },
20
+ cellStyle: { justifyContent: "center" },
22
21
  cellRenderer: GridRenderPopoutMenuCell,
23
- cellClass: custom?.multiEdit ? GenericMultiEditCellClass : undefined,
24
22
  ...colDef,
25
23
  cellRendererParams: {
26
24
  // Menus open on single click, this parameter is picked up in Grid.tsx
package/src/index.ts CHANGED
@@ -14,7 +14,7 @@ export { Grid } from "./components/Grid";
14
14
  export * from "./components/GridCell";
15
15
  export { GridIcon } from "./components/GridIcon";
16
16
  export { ComponentLoadingWrapper } from "./components/ComponentLoadingWrapper";
17
- export { GenericMultiEditCellClass } from "./components/GenericCellClass";
17
+ export { GridCellMultiSelectClassRules } from "./components/GridCellMultiSelectClassRules";
18
18
  export { GridLoadableCell } from "./components/GridLoadableCell";
19
19
  export { useGridPopoverHook } from "./components/GridPopoverHook";
20
20
  export { usePostSortRowsHook } from "./components/PostSortRowsHook";
@@ -145,7 +145,7 @@ const GridEditMultiSelectTemplate: ComponentStory<typeof Grid> = (props: GridPro
145
145
  const firstRow = selectedRows[0];
146
146
  const r: MultiSelectOption[] = [
147
147
  { value: "lot1", label: "Lot 1" },
148
- { value: "lot2", label: "Lot 2" },
148
+ { value: "lot2", label: "Lot 2", warning: "Don't select me" },
149
149
  { value: "lot3", label: "Lot 3" },
150
150
  { value: "lot11", label: "Lot 11" },
151
151
  { value: "lot4", label: "Lot A 482392" },
@@ -1,2 +0,0 @@
1
- import { CellClassFunc } from "ag-grid-community";
2
- export declare const GenericMultiEditCellClass: CellClassFunc;
@@ -1,15 +0,0 @@
1
- import { CellClassFunc } from "ag-grid-community";
2
-
3
- export const GenericMultiEditCellClass: CellClassFunc = (props): string => {
4
- const api = props.api;
5
- if (api == null) return "";
6
-
7
- const rowSelected = api
8
- .getSelectedNodes()
9
- .map((row) => row.id)
10
- .includes(props.node.id);
11
-
12
- return rowSelected && api.getEditingCells().some((cell) => cell.column.getColDef() === props.colDef)
13
- ? "ag-selected-for-edit"
14
- : "";
15
- };