@linzjs/step-ag-grid 14.3.2 → 14.3.3
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/contexts/GridContext.d.ts +3 -2
- package/dist/src/contexts/GridUpdatingContext.d.ts +1 -1
- package/dist/step-ag-grid.esm.js +41 -37
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +31 -45
- package/src/contexts/GridContext.tsx +7 -2
- package/src/contexts/GridContextProvider.tsx +6 -0
- package/src/contexts/GridUpdatingContext.tsx +3 -3
- package/src/contexts/GridUpdatingContextProvider.tsx +3 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ColumnApi, GridApi, RowNode } from "ag-grid-community";
|
|
2
|
+
import { ColDef, ColumnApi, GridApi, RowNode } from "ag-grid-community";
|
|
3
3
|
import { CsvExportParams } from "ag-grid-community/dist/lib/interfaces/exportParams";
|
|
4
4
|
import { ColDefT, GridBaseRow } from "../components";
|
|
5
5
|
export type GridFilterExternal<RowType extends GridBaseRow> = (data: RowType, rowNode: RowNode) => boolean;
|
|
@@ -13,6 +13,8 @@ export type AutoSizeColumnsResult = {
|
|
|
13
13
|
} | null;
|
|
14
14
|
export interface GridContextType<RowType extends GridBaseRow> {
|
|
15
15
|
gridReady: boolean;
|
|
16
|
+
getColDef: (colId?: string) => ColDef | undefined;
|
|
17
|
+
getColumns: () => ColDefT<RowType>[];
|
|
16
18
|
setApis: (gridApi: GridApi | undefined, columnApi: ColumnApi | undefined, dataTestId?: string) => void;
|
|
17
19
|
prePopupOps: () => void;
|
|
18
20
|
setQuickFilter: (quickFilter: string) => void;
|
|
@@ -47,7 +49,6 @@ export interface GridContextType<RowType extends GridBaseRow> {
|
|
|
47
49
|
removeExternalFilter: (filter: GridFilterExternal<RowType>) => void;
|
|
48
50
|
isExternalFilterPresent: () => boolean;
|
|
49
51
|
doesExternalFilterPass: (node: RowNode) => boolean;
|
|
50
|
-
getColumns: () => ColDefT<RowType>[];
|
|
51
52
|
invisibleColumnIds: string[];
|
|
52
53
|
setInvisibleColumnIds: (colIds: string[]) => void;
|
|
53
54
|
downloadCsv: (csvExportParams?: CsvExportParams) => void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export type GridUpdatingContextType = {
|
|
3
3
|
checkUpdating: (fields: string | string[], id: number | string) => boolean;
|
|
4
|
-
isUpdating: () => boolean;
|
|
5
4
|
modifyUpdating: (fields: string | string[], ids: (number | string)[], fn: () => void | Promise<void>) => Promise<void>;
|
|
6
5
|
updatedDep: number;
|
|
6
|
+
updatingCols: () => string[];
|
|
7
7
|
};
|
|
8
8
|
export declare const GridUpdatingContext: import("react").Context<GridUpdatingContextType>;
|
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -123,6 +123,10 @@ function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else i
|
|
|
123
123
|
|
|
124
124
|
var GridContext = createContext({
|
|
125
125
|
gridReady: false,
|
|
126
|
+
getColDef: function () {
|
|
127
|
+
console.error("no context provider for getColDef");
|
|
128
|
+
return undefined;
|
|
129
|
+
},
|
|
126
130
|
getColumns: function () {
|
|
127
131
|
console.error("no context provider for getColumns");
|
|
128
132
|
return [];
|
|
@@ -265,9 +269,9 @@ var GridUpdatingContext = createContext({
|
|
|
265
269
|
console.error("Missing GridUpdatingContext");
|
|
266
270
|
return false;
|
|
267
271
|
},
|
|
268
|
-
|
|
272
|
+
updatingCols: function () {
|
|
269
273
|
console.error("Missing GridUpdatingContext");
|
|
270
|
-
return
|
|
274
|
+
return [];
|
|
271
275
|
},
|
|
272
276
|
modifyUpdating: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
273
277
|
return __generator(this, function (_a) {
|
|
@@ -714,8 +718,8 @@ var GridHeaderSelect = function (_a) {
|
|
|
714
718
|
var Grid = function (_a) {
|
|
715
719
|
var _b, _c, _d;
|
|
716
720
|
var dataTestId = _a["data-testid"], _e = _a.rowSelection, rowSelection = _e === void 0 ? "multiple" : _e, _f = _a.suppressColumnVirtualization, suppressColumnVirtualization = _f === void 0 ? true : _f, _g = _a.theme, theme = _g === void 0 ? "ag-theme-alpine" : _g, _h = _a.sizeColumns, sizeColumns = _h === void 0 ? "auto" : _h, _j = _a.selectColumnPinned, selectColumnPinned = _j === void 0 ? null : _j, params = __rest(_a, ["data-testid", "rowSelection", "suppressColumnVirtualization", "theme", "sizeColumns", "selectColumnPinned"]);
|
|
717
|
-
var _k = useContext(GridContext), gridReady = _k.gridReady, setApis = _k.setApis, prePopupOps = _k.prePopupOps, ensureRowVisible = _k.ensureRowVisible, getFirstRowId = _k.getFirstRowId, selectRowsById = _k.selectRowsById, focusByRowById = _k.focusByRowById, ensureSelectedRowIsVisible = _k.ensureSelectedRowIsVisible, autoSizeColumns = _k.autoSizeColumns, sizeColumnsToFit = _k.sizeColumnsToFit, externallySelectedItemsAreInSync = _k.externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync = _k.setExternallySelectedItemsAreInSync, isExternalFilterPresent = _k.isExternalFilterPresent, doesExternalFilterPass = _k.doesExternalFilterPass, setOnCellEditingComplete = _k.setOnCellEditingComplete;
|
|
718
|
-
var _l = useContext(GridUpdatingContext), checkUpdating = _l.checkUpdating, updatedDep = _l.updatedDep,
|
|
721
|
+
var _k = useContext(GridContext), gridReady = _k.gridReady, setApis = _k.setApis, prePopupOps = _k.prePopupOps, ensureRowVisible = _k.ensureRowVisible, getFirstRowId = _k.getFirstRowId, selectRowsById = _k.selectRowsById, focusByRowById = _k.focusByRowById, ensureSelectedRowIsVisible = _k.ensureSelectedRowIsVisible, autoSizeColumns = _k.autoSizeColumns, sizeColumnsToFit = _k.sizeColumnsToFit, externallySelectedItemsAreInSync = _k.externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync = _k.setExternallySelectedItemsAreInSync, isExternalFilterPresent = _k.isExternalFilterPresent, doesExternalFilterPass = _k.doesExternalFilterPass, setOnCellEditingComplete = _k.setOnCellEditingComplete, getColDef = _k.getColDef;
|
|
722
|
+
var _l = useContext(GridUpdatingContext), checkUpdating = _l.checkUpdating, updatedDep = _l.updatedDep, updatingCols = _l.updatingCols;
|
|
719
723
|
var gridDivRef = useRef(null);
|
|
720
724
|
var lastSelectedIds = useRef([]);
|
|
721
725
|
var _m = useState(false), staleGrid = _m[0], setStaleGrid = _m[1];
|
|
@@ -944,12 +948,12 @@ var Grid = function (_a) {
|
|
|
944
948
|
return;
|
|
945
949
|
lastUpdatedDep.current = updatedDep;
|
|
946
950
|
// Don't update while there are spinners
|
|
947
|
-
if (
|
|
951
|
+
if (!isEmpty(updatingCols()))
|
|
948
952
|
return;
|
|
949
953
|
var skipHeader = sizeColumns === "auto-skip-headers";
|
|
950
954
|
autoSizeColumns({ skipHeader: skipHeader, userSizedColIds: userSizedColIds.current, colIds: colIdsEdited.current });
|
|
951
955
|
colIdsEdited.current.clear();
|
|
952
|
-
}, [autoSizeColumns,
|
|
956
|
+
}, [autoSizeColumns, (_c = params.rowData) === null || _c === void 0 ? void 0 : _c.length, setInitialContentSize, sizeColumns, updatedDep, updatingCols]);
|
|
953
957
|
/**
|
|
954
958
|
* Show/hide no rows overlay when model changes.
|
|
955
959
|
*/
|
|
@@ -1050,42 +1054,40 @@ var Grid = function (_a) {
|
|
|
1050
1054
|
* Set of colIds that need auto-sizing.
|
|
1051
1055
|
*/
|
|
1052
1056
|
var colIdsEdited = useRef(new Set());
|
|
1057
|
+
var lastUpdatedDep = useRef(updatedDep);
|
|
1053
1058
|
/**
|
|
1054
|
-
* When cell editing has completed
|
|
1059
|
+
* When cell editing has completed the colId as needing auto-sizing
|
|
1055
1060
|
*/
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1061
|
+
useEffect(function () {
|
|
1062
|
+
if (lastUpdatedDep.current === updatedDep)
|
|
1063
|
+
return;
|
|
1064
|
+
lastUpdatedDep.current = updatedDep;
|
|
1065
|
+
var colIds = updatingCols();
|
|
1066
|
+
// Updating possibly completed
|
|
1067
|
+
if (isEmpty(colIds)) {
|
|
1068
|
+
// Columns to resize?
|
|
1069
|
+
if (!isEmpty(colIdsEdited.current)) {
|
|
1070
|
+
var skipHeader = sizeColumns === "auto-skip-headers";
|
|
1071
|
+
if (sizeColumns === "auto" || skipHeader) {
|
|
1066
1072
|
autoSizeColumns({
|
|
1067
1073
|
skipHeader: skipHeader,
|
|
1068
1074
|
userSizedColIds: userSizedColIds.current,
|
|
1069
|
-
colIds:
|
|
1075
|
+
colIds: colIdsEdited.current
|
|
1070
1076
|
});
|
|
1077
|
+
}
|
|
1078
|
+
colIdsEdited.current.clear();
|
|
1071
1079
|
}
|
|
1072
1080
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
if (isUpdating())
|
|
1084
|
-
return;
|
|
1085
|
-
var skipHeader = sizeColumns === "auto-skip-headers";
|
|
1086
|
-
autoSizeColumns({ skipHeader: skipHeader, userSizedColIds: userSizedColIds.current, colIds: colIdsEdited.current });
|
|
1087
|
-
colIdsEdited.current.clear();
|
|
1088
|
-
}, [autoSizeColumns, updatedDep, sizeColumns, isUpdating]);
|
|
1081
|
+
else {
|
|
1082
|
+
// Updates not complete, add them to a list of columns needing resize
|
|
1083
|
+
colIds.forEach(function (colId) {
|
|
1084
|
+
var _a;
|
|
1085
|
+
if (colId && !((_a = getColDef(colId)) === null || _a === void 0 ? void 0 : _a.flex)) {
|
|
1086
|
+
colIdsEdited.current.add(colId);
|
|
1087
|
+
}
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
}, [autoSizeColumns, getColDef, sizeColumns, updatedDep, updatingCols]);
|
|
1089
1091
|
/**
|
|
1090
1092
|
* Resize columns to fit if required on window/container resize
|
|
1091
1093
|
*/
|
|
@@ -1118,7 +1120,7 @@ var Grid = function (_a) {
|
|
|
1118
1120
|
setOnCellEditingComplete(params.onCellEditingComplete);
|
|
1119
1121
|
return (jsx("div", __assign({ "data-testid": dataTestId, className: clsx("Grid-container", theme, staleGrid && "Grid-sortIsStale", gridReady && params.rowData && "Grid-ready") }, { children: jsx("div", __assign({ style: { flex: 1 }, ref: gridDivRef }, { children: jsx(AgGridReact, { animateRows: params.animateRows, rowClassRules: params.rowClassRules, getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: rowSelection, suppressBrowserResizeObserver: true, onGridSizeChanged: onGridSizeChanged, suppressColumnVirtualisation: suppressColumnVirtualization, suppressClickEdit: true, onColumnVisible: function () {
|
|
1120
1122
|
setInitialContentSize();
|
|
1121
|
-
}, onRowDataChanged: onRowDataChanged, onCellKeyPress: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, domLayout: params.domLayout,
|
|
1123
|
+
}, onRowDataChanged: onRowDataChanged, onCellKeyPress: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, domLayout: params.domLayout, onColumnResized: onColumnResized, defaultColDef: __assign({ minWidth: 48 }, omit(params.defaultColDef, ["editable"])), columnDefs: columnDefsAdjusted, rowData: params.rowData, noRowsOverlayComponent: GridNoRowsOverlay, noRowsOverlayComponentParams: {
|
|
1122
1124
|
rowData: params.rowData,
|
|
1123
1125
|
noRowsOverlayText: params.noRowsOverlayText
|
|
1124
1126
|
}, onModelUpdated: onModelUpdated, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: (_d = params.postSortRows) !== null && _d !== void 0 ? _d : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved, alwaysShowVerticalScroll: params.alwaysShowVerticalScroll, isExternalFilterPresent: isExternalFilterPresent, doesExternalFilterPass: doesExternalFilterPass, maintainColumnOrder: true }) })) })));
|
|
@@ -5101,6 +5103,7 @@ var GridContextProvider = function (props) {
|
|
|
5101
5103
|
var doesExternalFilterPass = function (node) {
|
|
5102
5104
|
return externalFilters.current.every(function (filter) { return filter(node.data, node); });
|
|
5103
5105
|
};
|
|
5106
|
+
var getColDef = useCallback(function (colId) { return (!!colId && (gridApi === null || gridApi === void 0 ? void 0 : gridApi.getColumnDef(colId))) || undefined; }, [gridApi]);
|
|
5104
5107
|
var getColumns = useCallback(function () { var _a; return (_a = gridApi === null || gridApi === void 0 ? void 0 : gridApi.getColumnDefs()) !== null && _a !== void 0 ? _a : []; }, [gridApi]);
|
|
5105
5108
|
useEffect(function () {
|
|
5106
5109
|
if (columnApi) {
|
|
@@ -5123,6 +5126,7 @@ var GridContextProvider = function (props) {
|
|
|
5123
5126
|
gridApi.exportDataAsCsv(__assign(__assign({ columnKeys: columnKeys, processCellCallback: downloadCsvUseValueFormattersProcessCellCallback }, csvExportParams), { fileName: fileName }));
|
|
5124
5127
|
}, [columnApi, gridApi]);
|
|
5125
5128
|
return (jsx(GridContext.Provider, __assign({ value: {
|
|
5129
|
+
getColDef: getColDef,
|
|
5126
5130
|
getColumns: getColumns,
|
|
5127
5131
|
invisibleColumnIds: invisibleColumnIds,
|
|
5128
5132
|
setInvisibleColumnIds: setInvisibleColumnIds,
|
|
@@ -5222,7 +5226,7 @@ var GridUpdatingContextProvider = function (props) {
|
|
|
5222
5226
|
updating.current = mergedUpdatingBlocks;
|
|
5223
5227
|
setUpdatedDep(function (updatedDep) { return updatedDep + 1; });
|
|
5224
5228
|
};
|
|
5225
|
-
var
|
|
5229
|
+
var updatingCols = function () { return Object.keys(updating.current); };
|
|
5226
5230
|
var modifyUpdating = function (fields, ids, fn) { return __awaiter(void 0, void 0, void 0, function () {
|
|
5227
5231
|
var idRef;
|
|
5228
5232
|
return __generator(this, function (_a) {
|
|
@@ -5250,7 +5254,7 @@ var GridUpdatingContextProvider = function (props) {
|
|
|
5250
5254
|
var checkUpdating = function (fields, id) {
|
|
5251
5255
|
return castArray(fields).some(function (f) { var _a; return (_a = updating.current[f]) === null || _a === void 0 ? void 0 : _a.includes(id); });
|
|
5252
5256
|
};
|
|
5253
|
-
return (jsx(GridUpdatingContext.Provider, __assign({ value: { modifyUpdating: modifyUpdating, checkUpdating: checkUpdating,
|
|
5257
|
+
return (jsx(GridUpdatingContext.Provider, __assign({ value: { modifyUpdating: modifyUpdating, checkUpdating: checkUpdating, updatingCols: updatingCols, updatedDep: updatedDep } }, { children: props.children })));
|
|
5254
5258
|
};
|
|
5255
5259
|
|
|
5256
5260
|
var css_248z = ".ActionButton{align-items:center;display:flex}.ActionButton-minimal.lui-button-lg.lui-button-icon-right{padding-right:38px}.ActionButton.lui-button-lg.lui-button-icon-right:not(.ActionButton-tight) .LuiIcon{margin:0 4px}.ActionButton.ActionButton-tight.lui-button-lg.lui-button-icon-right .LuiIcon{margin:0}.ActionButton-iconOnly.lui-button-lg.lui-button-icon-right:not(.ActionButton-tight){padding:8px 5px}.ActionButton-iconOnly.lui-button-lg.lui-button-icon-right.ActionButton-tight{padding:0}.ActionButton-minimalArea{position:relative}.ActionButton-minimalAreaDisplay{position:absolute}.ActionButton-minimalAreaExpand{visibility:hidden}.ActionButton-inProgress.lui-button-lg.lui-button-icon-right{background-color:#e2f3f7;color:#007198;cursor:progress}.ActionButton-inProgress.lui-button-lg.lui-button-icon-right svg *{fill:#0000}.ActionButton-fill{justify-content:center;width:100%}";
|