@linzjs/step-ag-grid 14.1.1 → 14.1.2
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/step-ag-grid.esm.js
CHANGED
|
@@ -665,12 +665,23 @@ var Grid = function (_a) {
|
|
|
665
665
|
var lastSelectedIds = useRef([]);
|
|
666
666
|
var _k = useState(false), staleGrid = _k[0], setStaleGrid = _k[1];
|
|
667
667
|
var postSortRows = usePostSortRowsHook({ setStaleGrid: setStaleGrid });
|
|
668
|
+
var hasSetContentSize = useRef(false);
|
|
669
|
+
var hasSetContentSizeEmpty = useRef(false);
|
|
668
670
|
var setInitialContentSize = useCallback(function () {
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
671
|
+
if ((!isEmpty(params.rowData) && !hasSetContentSize.current) ||
|
|
672
|
+
(isEmpty(params.rowData) && !hasSetContentSizeEmpty.current)) {
|
|
673
|
+
var skipHeaders = sizeColumns === "auto-skip-headers";
|
|
674
|
+
if (sizeColumns === "auto" || skipHeaders) {
|
|
675
|
+
// If we aren't skipping headers and there's no data, then don't skip headers
|
|
676
|
+
var result = autoSizeAllColumns({ skipHeader: skipHeaders && !isEmpty(params.rowData) });
|
|
677
|
+
if (isEmpty(params.rowData)) {
|
|
678
|
+
hasSetContentSizeEmpty.current = true;
|
|
679
|
+
}
|
|
680
|
+
else {
|
|
681
|
+
hasSetContentSize.current = true;
|
|
682
|
+
}
|
|
683
|
+
params.onContentSize && result && params.onContentSize(result);
|
|
684
|
+
}
|
|
674
685
|
}
|
|
675
686
|
if (sizeColumns !== "none") {
|
|
676
687
|
sizeColumnsToFit();
|
|
@@ -829,6 +840,8 @@ var Grid = function (_a) {
|
|
|
829
840
|
var previousRowDataLength = useRef(0);
|
|
830
841
|
useEffect(function () {
|
|
831
842
|
var _a, _b;
|
|
843
|
+
if (!gridReady)
|
|
844
|
+
return;
|
|
832
845
|
var length = (_b = (_a = params.rowData) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
833
846
|
if (previousRowDataLength.current !== length) {
|
|
834
847
|
if (previousRowDataLength.current === 0 && length > 0) {
|
|
@@ -836,7 +849,7 @@ var Grid = function (_a) {
|
|
|
836
849
|
}
|
|
837
850
|
previousRowDataLength.current = length;
|
|
838
851
|
}
|
|
839
|
-
}, [(_c = params.rowData) === null || _c === void 0 ? void 0 : _c.length, setInitialContentSize]);
|
|
852
|
+
}, [gridReady, (_c = params.rowData) === null || _c === void 0 ? void 0 : _c.length, setInitialContentSize]);
|
|
840
853
|
var onModelUpdated = useCallback(function (event) {
|
|
841
854
|
event.api.getDisplayedRowCount() === 0 ? event.api.showNoRowsOverlay() : event.api.hideOverlay();
|
|
842
855
|
}, []);
|
|
@@ -894,9 +907,6 @@ var Grid = function (_a) {
|
|
|
894
907
|
startCellEditing(e);
|
|
895
908
|
}
|
|
896
909
|
}, [startCellEditing]);
|
|
897
|
-
var onGridSizeChanged = useCallback(function () {
|
|
898
|
-
sizeColumns !== "none" && sizeColumnsToFit();
|
|
899
|
-
}, [sizeColumns, sizeColumnsToFit]);
|
|
900
910
|
/**
|
|
901
911
|
* Once the grid has auto-sized we want to run fit to fit the grid in its container,
|
|
902
912
|
* but we don't want the non-flex auto-sized columns to "fit" size, so suppressSizeToFit is set to true.
|
|
@@ -904,7 +914,7 @@ var Grid = function (_a) {
|
|
|
904
914
|
var columnDefsAdjusted = useMemo(function () {
|
|
905
915
|
return columnDefs.map(function (colDef) { return (__assign(__assign({}, colDef), { suppressSizeToFit: (sizeColumns === "auto" || sizeColumns === "auto-skip-headers") && !colDef.flex })); });
|
|
906
916
|
}, [columnDefs, sizeColumns]);
|
|
907
|
-
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 } }, { children: jsx(AgGridReact, { animateRows: params.animateRows, rowClassRules: params.rowClassRules, getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: rowSelection, suppressBrowserResizeObserver: true, onGridSizeChanged:
|
|
917
|
+
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 } }, { children: jsx(AgGridReact, { animateRows: params.animateRows, rowClassRules: params.rowClassRules, getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: rowSelection, suppressBrowserResizeObserver: true, onGridSizeChanged: setInitialContentSize, suppressColumnVirtualisation: suppressColumnVirtualization, suppressClickEdit: true, onCellKeyPress: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, domLayout: params.domLayout, columnDefs: columnDefsAdjusted, rowData: params.rowData, noRowsOverlayComponent: GridNoRowsOverlay, noRowsOverlayComponentParams: { rowData: params.rowData, noRowsOverlayText: params.noRowsOverlayText }, 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 }) })) })));
|
|
908
918
|
};
|
|
909
919
|
|
|
910
920
|
var GridPopoverContext = createContext({
|
|
@@ -4727,7 +4737,9 @@ var GridContextProvider = function (props) {
|
|
|
4727
4737
|
var skipHeader = _a.skipHeader;
|
|
4728
4738
|
if (columnApi) {
|
|
4729
4739
|
columnApi.autoSizeAllColumns(skipHeader);
|
|
4730
|
-
return {
|
|
4740
|
+
return {
|
|
4741
|
+
width: sumBy(columnApi.getColumnState().filter(function (col) { return col.hide !== true; }), "width")
|
|
4742
|
+
};
|
|
4731
4743
|
}
|
|
4732
4744
|
return null;
|
|
4733
4745
|
}, [columnApi]);
|