@linzjs/step-ag-grid 29.3.6 → 29.4.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
package/src/components/Grid.tsx
CHANGED
|
@@ -64,7 +64,7 @@ export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
|
|
|
64
64
|
externalSelectedItems?: any[];
|
|
65
65
|
setExternalSelectedItems?: (items: any[]) => void;
|
|
66
66
|
defaultColDef?: GridOptions['defaultColDef'];
|
|
67
|
-
columnDefs: ColDef<TData>[];
|
|
67
|
+
columnDefs: ColDef<TData>[] | ColGroupDef<TData>[];
|
|
68
68
|
rowData: GridOptions['rowData'];
|
|
69
69
|
selectColumnPinned?: ColDef['pinned'];
|
|
70
70
|
noRowsOverlayText?: string;
|
|
@@ -80,6 +80,7 @@ export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
|
|
|
80
80
|
onRowDragEnd?: (props: GridOnRowDragEndProps<TData>) => Promise<void> | void;
|
|
81
81
|
alwaysShowVerticalScroll?: boolean;
|
|
82
82
|
suppressColumnVirtualization?: GridOptions['suppressColumnVirtualisation'];
|
|
83
|
+
suppressReadOnlyStyle?: boolean;
|
|
83
84
|
/**
|
|
84
85
|
* When the grid is rendered using sizeColumns=="auto" this is called initially with the required container size to fit all content.
|
|
85
86
|
* This allows you set the size of the panel to fit perfectly.
|
|
@@ -149,6 +150,7 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
149
150
|
selectable,
|
|
150
151
|
onCellFocused: paramsOnCellFocused,
|
|
151
152
|
maxInitialWidth,
|
|
153
|
+
suppressReadOnlyStyle = false,
|
|
152
154
|
...params
|
|
153
155
|
}: GridProps<TData>): ReactElement => {
|
|
154
156
|
const {
|
|
@@ -402,27 +404,40 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
402
404
|
*/
|
|
403
405
|
useEffect(synchroniseExternallySelectedItemsToGrid, [synchroniseExternallySelectedItemsToGrid]);
|
|
404
406
|
|
|
407
|
+
const mapColDef = useCallback(
|
|
408
|
+
(colDef: ColDef | ColGroupDef): ColDef | ColGroupDef => {
|
|
409
|
+
if ('children' in colDef) {
|
|
410
|
+
return {
|
|
411
|
+
...colDef,
|
|
412
|
+
children: colDef.children.map(mapColDef),
|
|
413
|
+
};
|
|
414
|
+
} else {
|
|
415
|
+
const colDefEditable = colDef.editable;
|
|
416
|
+
const editable = combineEditables(
|
|
417
|
+
params.loading !== true && params.readOnly !== true,
|
|
418
|
+
params.defaultColDef?.editable,
|
|
419
|
+
colDefEditable,
|
|
420
|
+
);
|
|
421
|
+
return {
|
|
422
|
+
...colDef,
|
|
423
|
+
editable,
|
|
424
|
+
cellClassRules: {
|
|
425
|
+
...colDef.cellClassRules,
|
|
426
|
+
'GridCell-readonly': (ccp: CellClassParams<TData>) =>
|
|
427
|
+
!suppressReadOnlyStyle && !editable(ccp as any as EditableCallbackParams<TData>),
|
|
428
|
+
},
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
[params.defaultColDef?.editable, params.loading, params.readOnly, suppressReadOnlyStyle],
|
|
433
|
+
);
|
|
434
|
+
|
|
405
435
|
/**
|
|
406
436
|
* Add selectable column to colDefs. Adjust column defs to block fit for auto sized columns.
|
|
407
437
|
*/
|
|
408
438
|
const columnDefs = useMemo((): (ColDef | ColGroupDef)[] => {
|
|
409
|
-
return params.columnDefs.map(
|
|
410
|
-
|
|
411
|
-
const editable = combineEditables(
|
|
412
|
-
params.loading !== true && params.readOnly !== true,
|
|
413
|
-
params.defaultColDef?.editable,
|
|
414
|
-
colDefEditable,
|
|
415
|
-
);
|
|
416
|
-
return {
|
|
417
|
-
...colDef,
|
|
418
|
-
editable,
|
|
419
|
-
cellClassRules: {
|
|
420
|
-
...colDef.cellClassRules,
|
|
421
|
-
'GridCell-readonly': (ccp: CellClassParams) => !editable(ccp as any as EditableCallbackParams),
|
|
422
|
-
},
|
|
423
|
-
};
|
|
424
|
-
});
|
|
425
|
-
}, [params.columnDefs, params.loading, params.readOnly, params.defaultColDef?.editable]);
|
|
439
|
+
return params.columnDefs.map(mapColDef);
|
|
440
|
+
}, [params.columnDefs, mapColDef]);
|
|
426
441
|
|
|
427
442
|
const hasExternallySelectedItems = !!params.setExternalSelectedItems;
|
|
428
443
|
|