@linzjs/step-ag-grid 29.8.0 → 29.9.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": "29.8.0",
5
+ "version": "29.9.0",
6
6
  "keywords": [
7
7
  "aggrid",
8
8
  "ag-grid",
@@ -33,10 +33,15 @@ export const GridCellRenderer = (props: ICellRendererParams) => {
33
33
  const colDef = props.colDef as ColDef;
34
34
 
35
35
  const rendererParams = colDef.cellRendererParams as GenericCellRendererParams<any> | undefined;
36
+ const errorFn = rendererParams?.error;
37
+ let errorText = props.data !== undefined && errorFn ? errorFn(props) : undefined;
36
38
  const warningFn = rendererParams?.warning;
37
39
  let warningText = props.data !== undefined && warningFn ? warningFn(props) : undefined;
38
40
  const infoFn = rendererParams?.info;
39
41
  let infoText = props.data !== undefined && infoFn ? infoFn(props) : undefined;
42
+ if (Array.isArray(errorText)) {
43
+ errorText = errorText.join('\n');
44
+ }
40
45
  if (Array.isArray(warningText)) {
41
46
  warningText = warningText.join('\n');
42
47
  }
@@ -48,6 +53,9 @@ export const GridCellRenderer = (props: ICellRendererParams) => {
48
53
  <GridLoadableCell />
49
54
  ) : (
50
55
  <>
56
+ {!!errorText && (
57
+ <GridIcon icon={'ic_error_outline'} title={typeof errorText === 'string' ? errorText : 'Error'} />
58
+ )}
51
59
  {!!warningText && (
52
60
  <GridIcon icon={'ic_warning_outline'} title={typeof warningText === 'string' ? warningText : 'Warning'} />
53
61
  )}
@@ -79,6 +87,7 @@ export interface ColDefT<TData extends GridBaseRow, ValueType = any> extends Col
79
87
  originalCellRenderer?: any;
80
88
  editAction?: (selectedRows: TData[]) => void;
81
89
  shortcutKeys?: Record<string, () => void>;
90
+ error?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
82
91
  warning?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
83
92
  info?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
84
93
  };
@@ -13,6 +13,7 @@ export interface GenericCellRendererParams<TData extends GridBaseRow> {
13
13
  rightHoverElement?: ReactElement | undefined;
14
14
  editAction?: (selectedRows: TData[]) => void;
15
15
  shortcutKeys?: Record<string, ((params: SuppressKeyboardEventParams) => boolean | void) | undefined>;
16
+ error?: (props: ICellRendererParams<TData>) => string | string[] | boolean | null | undefined;
16
17
  warning?: (props: ICellRendererParams<TData>) => string | string[] | boolean | null | undefined;
17
18
  info?: (props: ICellRendererParams<TData>) => string | string[] | boolean | null | undefined;
18
19
  }
@@ -83,6 +83,7 @@ const GridReadOnlyTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridProps<I
83
83
  field: 'position',
84
84
  headerName: 'Position',
85
85
  cellRendererParams: {
86
+ error: ({ value }) => value === 'Manager' && 'Managers need management',
86
87
  warning: ({ value }) => value === 'Tester' && 'Testers are testing',
87
88
  info: ({ value }) => value === 'Developer' && 'Developers are awesome',
88
89
  },
@@ -24,6 +24,16 @@
24
24
  fill: lui.$warning;
25
25
  }
26
26
 
27
+ .AgGridGenericCellRenderer-ic_error_Icon {
28
+ margin-right: 4px;
29
+ fill: lui.$error;
30
+ }
31
+
32
+ .AgGridGenericCellRenderer-ic_error_outlineIcon {
33
+ margin-right: 4px;
34
+ fill: lui.$error;
35
+ }
36
+
27
37
  .GridIcon-disabled {
28
38
  fill: lui.$silver !important;
29
39
  }