@linzjs/step-ag-grid 14.3.3 → 14.5.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
|
@@ -83,7 +83,6 @@ export const Grid = ({
|
|
|
83
83
|
const {
|
|
84
84
|
gridReady,
|
|
85
85
|
setApis,
|
|
86
|
-
prePopupOps,
|
|
87
86
|
ensureRowVisible,
|
|
88
87
|
getFirstRowId,
|
|
89
88
|
selectRowsById,
|
|
@@ -98,7 +97,8 @@ export const Grid = ({
|
|
|
98
97
|
setOnCellEditingComplete,
|
|
99
98
|
getColDef,
|
|
100
99
|
} = useContext(GridContext);
|
|
101
|
-
const {
|
|
100
|
+
const { updatedDep, updatingCols } = useContext(GridUpdatingContext);
|
|
101
|
+
const gridContext = useContext(GridContext);
|
|
102
102
|
|
|
103
103
|
const gridDivRef = useRef<HTMLDivElement>(null);
|
|
104
104
|
|
|
@@ -387,23 +387,13 @@ export const Grid = ({
|
|
|
387
387
|
*/
|
|
388
388
|
const startCellEditing = useCallback(
|
|
389
389
|
(event: CellEvent) => {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
// Cell already being edited, so don't re-edit until finished
|
|
395
|
-
if (checkUpdating([event.colDef.field ?? ""], event.data.id)) {
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
if (event.rowIndex !== null) {
|
|
400
|
-
event.api.startEditingCell({
|
|
401
|
-
rowIndex: event.rowIndex,
|
|
402
|
-
colKey: event.column.getColId(),
|
|
390
|
+
event.data.id &&
|
|
391
|
+
gridContext.startCellEditing({
|
|
392
|
+
rowId: event.data.id,
|
|
393
|
+
colId: event.column.getColId(),
|
|
403
394
|
});
|
|
404
|
-
}
|
|
405
395
|
},
|
|
406
|
-
[
|
|
396
|
+
[gridContext],
|
|
407
397
|
);
|
|
408
398
|
|
|
409
399
|
/**
|
|
@@ -466,8 +456,9 @@ export const Grid = ({
|
|
|
466
456
|
columnDefs.map((colDef) => ({
|
|
467
457
|
...colDef,
|
|
468
458
|
suppressSizeToFit: (sizeColumns === "auto" || sizeColumns === "auto-skip-headers") && !colDef.flex,
|
|
459
|
+
sortable: colDef.sortable && params.defaultColDef?.sortable !== false,
|
|
469
460
|
})),
|
|
470
|
-
[columnDefs, sizeColumns],
|
|
461
|
+
[columnDefs, params.defaultColDef?.sortable, sizeColumns],
|
|
471
462
|
);
|
|
472
463
|
|
|
473
464
|
/**
|
|
@@ -39,6 +39,7 @@ export interface GridContextType<RowType extends GridBaseRow> {
|
|
|
39
39
|
autoSizeColumns: (props?: AutoSizeColumnsProps) => AutoSizeColumnsResult;
|
|
40
40
|
sizeColumnsToFit: () => void;
|
|
41
41
|
cancelEdit: () => void;
|
|
42
|
+
startCellEditing: ({ rowId, colId }: { rowId: number; colId: string }) => void;
|
|
42
43
|
stopEditing: () => void;
|
|
43
44
|
updatingCells: (
|
|
44
45
|
props: { selectedRows: GridBaseRow[]; field?: string },
|
|
@@ -147,6 +148,9 @@ export const GridContext = createContext<GridContextType<any>>({
|
|
|
147
148
|
cancelEdit: () => {
|
|
148
149
|
console.error("no context provider for cancelEdit");
|
|
149
150
|
},
|
|
151
|
+
startCellEditing: () => {
|
|
152
|
+
console.error("no context provider for startCellEditing");
|
|
153
|
+
},
|
|
150
154
|
stopEditing: () => {
|
|
151
155
|
console.error("no context provider for stopEditing");
|
|
152
156
|
},
|
|
@@ -21,7 +21,7 @@ interface GridContextProps {
|
|
|
21
21
|
* Also, make sure the provider is created in a separate component, otherwise it won't be found.
|
|
22
22
|
*/
|
|
23
23
|
export const GridContextProvider = <RowType extends GridBaseRow>(props: GridContextProps): ReactElement => {
|
|
24
|
-
const { modifyUpdating } = useContext(GridUpdatingContext);
|
|
24
|
+
const { modifyUpdating, checkUpdating } = useContext(GridUpdatingContext);
|
|
25
25
|
const [gridApi, setGridApi] = useState<GridApi>();
|
|
26
26
|
const [columnApi, setColumnApi] = useState<ColumnApi>();
|
|
27
27
|
const [gridReady, setGridReady] = useState(false);
|
|
@@ -377,6 +377,42 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: GridCont
|
|
|
377
377
|
gridApi.stopEditing();
|
|
378
378
|
}, [gridApi]);
|
|
379
379
|
|
|
380
|
+
const startCellEditing = useCallback(
|
|
381
|
+
async ({ rowId, colId }: { rowId: number; colId: string }) => {
|
|
382
|
+
if (!gridApi) return;
|
|
383
|
+
|
|
384
|
+
const colDef = gridApi.getColumnDef(colId);
|
|
385
|
+
if (!colDef) return;
|
|
386
|
+
|
|
387
|
+
prePopupOps();
|
|
388
|
+
const rowNode = gridApi.getRowNode(`${rowId}`);
|
|
389
|
+
if (!rowNode) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if (!rowNode.isSelected()) {
|
|
394
|
+
rowNode.setSelected(true, false);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// Cell already being edited, so don't re-edit until finished
|
|
398
|
+
if (checkUpdating([colDef.field ?? ""], rowId)) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const rowIndex = rowNode.rowIndex;
|
|
403
|
+
if (rowIndex != null) {
|
|
404
|
+
const focusAndEdit = () => {
|
|
405
|
+
gridApi.startEditingCell({
|
|
406
|
+
rowIndex,
|
|
407
|
+
colKey: colId,
|
|
408
|
+
});
|
|
409
|
+
};
|
|
410
|
+
defer(focusAndEdit);
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
[checkUpdating, gridApi, prePopupOps],
|
|
414
|
+
);
|
|
415
|
+
|
|
380
416
|
/**
|
|
381
417
|
* This differs from stopEdit in that it will also invoke cellEditingCompleteCallback
|
|
382
418
|
*/
|
|
@@ -618,6 +654,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: GridCont
|
|
|
618
654
|
ensureSelectedRowIsVisible,
|
|
619
655
|
sizeColumnsToFit,
|
|
620
656
|
autoSizeColumns,
|
|
657
|
+
startCellEditing,
|
|
621
658
|
stopEditing,
|
|
622
659
|
cancelEdit,
|
|
623
660
|
updatingCells,
|