@linzjs/step-ag-grid 26.1.0 → 27.0.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/dist/src/components/GridCell.d.ts +5 -28
- package/dist/step-ag-grid.cjs +1 -1
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +1 -1
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/GridCell.test.tsx +3 -2
- package/src/components/GridCell.tsx +4 -38
- package/src/components/gridPopoverEdit/GridButton.tsx +4 -4
- package/src/react-menu3/components/ControlledMenu.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { ValueGetterParams } from 'ag-grid-community';
|
|
1
2
|
import { describe, expect, test } from 'vitest';
|
|
2
3
|
|
|
3
4
|
import { GridBaseRow } from './Grid';
|
|
4
|
-
import { generateFilterGetter
|
|
5
|
+
import { generateFilterGetter } from './GridCell';
|
|
5
6
|
|
|
6
7
|
describe('GridCell', () => {
|
|
7
8
|
test('generateFilterGetter returns passed filterValueGetter', () => {
|
|
@@ -26,7 +27,7 @@ describe('GridCell', () => {
|
|
|
26
27
|
const filterGetter = generateFilterGetter(field, undefined, valueFormatter);
|
|
27
28
|
expect(typeof filterGetter).toBe('function');
|
|
28
29
|
if (typeof filterGetter !== 'function') return;
|
|
29
|
-
expect(filterGetter({ getValue: () => test.value } as
|
|
30
|
+
expect(filterGetter({ getValue: () => test.value } as unknown as ValueGetterParams<GridBaseRow>)).toBe(
|
|
30
31
|
test.expected,
|
|
31
32
|
);
|
|
32
33
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ColDef, EditableCallback, ICellEditorParams, ICellRendererParams } from 'ag-grid-community';
|
|
2
2
|
import {
|
|
3
|
-
EditableCallbackParams,
|
|
4
3
|
SuppressKeyboardEventParams,
|
|
5
4
|
ValueFormatterFunc,
|
|
6
5
|
ValueFormatterParams,
|
|
@@ -24,11 +23,6 @@ export interface GenericCellEditorProps<E> {
|
|
|
24
23
|
editorParams?: E;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
export interface SAICellRendererParams<TData = any, TValue = any, TContext = any>
|
|
28
|
-
extends Omit<ICellRendererParams<TData, TValue, TContext>, 'data'> {
|
|
29
|
-
data: TData;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
26
|
export const GridCellRenderer = (props: ICellRendererParams) => {
|
|
33
27
|
const { checkUpdating } = useContext(GridUpdatingContext);
|
|
34
28
|
const colDef = props.colDef as ColDef;
|
|
@@ -63,41 +57,13 @@ export const GridCellRenderer = (props: ICellRendererParams) => {
|
|
|
63
57
|
);
|
|
64
58
|
};
|
|
65
59
|
|
|
66
|
-
export interface SAValueGetterParams<TData = any, TValue = any> extends Omit<ValueGetterParams<TData, TValue>, 'data'> {
|
|
67
|
-
data: TData;
|
|
68
|
-
getValue: (field: string) => any;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface SAValueGetterFunc<TData = any, TValue = any> {
|
|
72
|
-
(params: SAValueGetterParams<TData, TValue>): TValue | null | undefined;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface SAEditableCallbackParams<TData = any, TValue = any>
|
|
76
|
-
extends Omit<EditableCallbackParams<TData, TValue>, 'data'> {
|
|
77
|
-
data: TData;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface SAEditableCallback<TData = any, TValue = any> {
|
|
81
|
-
(params: SAEditableCallbackParams<TData, TValue>): boolean;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface SAValueFormatterParams<TData = any, TValue = any>
|
|
85
|
-
extends Omit<ValueFormatterParams<TData, TValue>, 'data' | 'value'> {
|
|
86
|
-
data: TData;
|
|
87
|
-
value: TValue;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface SAValueFormatterFunc<TData = any, TValue = any> {
|
|
91
|
-
(params: SAValueFormatterParams<TData, TValue>): string;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
60
|
// This is so that typescript retains the row type to pass to the GridCells
|
|
95
61
|
export interface ColDefT<TData extends GridBaseRow, ValueType = any> extends ColDef<TData, ValueType> {
|
|
96
62
|
editable?: boolean | EditableCallback<TData, ValueType>;
|
|
97
63
|
valueGetter?: string | ValueGetterFunc<TData, ValueType>;
|
|
98
64
|
valueFormatter?: string | ValueFormatterFunc<TData, ValueType>;
|
|
99
65
|
cellRenderer?:
|
|
100
|
-
| ((props:
|
|
66
|
+
| ((props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined)
|
|
101
67
|
| string;
|
|
102
68
|
cellRendererParams?: {
|
|
103
69
|
singleClickEdit?: boolean;
|
|
@@ -105,8 +71,8 @@ export interface ColDefT<TData extends GridBaseRow, ValueType = any> extends Col
|
|
|
105
71
|
originalCellRenderer?: any;
|
|
106
72
|
editAction?: (selectedRows: TData[]) => void;
|
|
107
73
|
shortcutKeys?: Record<string, () => void>;
|
|
108
|
-
warning?: (props:
|
|
109
|
-
info?: (props:
|
|
74
|
+
warning?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
|
|
75
|
+
info?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
|
|
110
76
|
};
|
|
111
77
|
editor?: (editorProps: any) => ReactElement;
|
|
112
78
|
}
|
|
@@ -129,7 +95,7 @@ export const generateFilterGetter = <TData extends GridBaseRow, ValueType>(
|
|
|
129
95
|
field: string | undefined,
|
|
130
96
|
filterValueGetter: string | ValueGetterFunc<TData, ValueType> | undefined,
|
|
131
97
|
valueFormatter: string | ValueFormatterFunc<TData, ValueType> | undefined,
|
|
132
|
-
): string |
|
|
98
|
+
): string | ValueGetterFunc<TData, ValueType> | undefined => {
|
|
133
99
|
if (filterValueGetter) return filterValueGetter;
|
|
134
100
|
// aggrid will default to valueGetter
|
|
135
101
|
if (typeof valueFormatter !== 'function' || !field) return undefined;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { LuiButton, LuiIcon } from '@linzjs/lui';
|
|
2
|
-
import { CellFocusedEvent, ICellEditorParams } from 'ag-grid-community';
|
|
2
|
+
import { CellFocusedEvent, ICellEditorParams, ICellRendererParams } from 'ag-grid-community';
|
|
3
3
|
import { useEffect, useRef } from 'react';
|
|
4
4
|
|
|
5
5
|
import { GridBaseRow } from '../Grid';
|
|
6
|
-
import { ColDefT, GridCell
|
|
6
|
+
import { ColDefT, GridCell } from '../GridCell';
|
|
7
7
|
import { GenericCellColDef } from '../gridRender';
|
|
8
8
|
|
|
9
|
-
const ButtonCellRenderer = <TData extends GridBaseRow>(props:
|
|
9
|
+
const ButtonCellRenderer = <TData extends GridBaseRow>(props: ICellRendererParams<TData>) => {
|
|
10
10
|
const { data, node, column, colDef, api } = props;
|
|
11
11
|
const inputRef = useRef<HTMLButtonElement>(null);
|
|
12
12
|
|
|
@@ -30,7 +30,7 @@ const ButtonCellRenderer = <TData extends GridBaseRow>(props: SAICellRendererPar
|
|
|
30
30
|
level="text"
|
|
31
31
|
onClick={() => {
|
|
32
32
|
const selectedRows = [data];
|
|
33
|
-
const selectedRowIds = selectedRows.map((r) => r
|
|
33
|
+
const selectedRowIds = selectedRows.map((r) => r!.id);
|
|
34
34
|
colDef?.cellEditorParams.onClick?.({ selectedRows, selectedRowIds });
|
|
35
35
|
}}
|
|
36
36
|
style={{ display: colDef?.cellEditorParams?.visible?.(props) !== false ? '' : 'none' }}
|
|
@@ -198,7 +198,7 @@ export const ControlledMenuFr = (
|
|
|
198
198
|
break;
|
|
199
199
|
}
|
|
200
200
|
},
|
|
201
|
-
[anchorRef, saveButtonRef],
|
|
201
|
+
[anchorRef, onClose, saveButtonRef],
|
|
202
202
|
);
|
|
203
203
|
|
|
204
204
|
const handleKeydownTabAndEnter = useMemo(() => handleKeyboardTabAndEnter(true), [handleKeyboardTabAndEnter]);
|