@linzjs/step-ag-grid 29.3.1 → 29.3.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.cjs +12 -13
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +13 -14
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +14 -15
package/package.json
CHANGED
package/src/components/Grid.tsx
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
} from 'ag-grid-community';
|
|
27
27
|
import { AgGridReact } from 'ag-grid-react';
|
|
28
28
|
import clsx from 'clsx';
|
|
29
|
-
import { defer,
|
|
29
|
+
import { defer, difference, isEmpty, last, omit, xorBy } from 'lodash-es';
|
|
30
30
|
import { ReactElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
31
31
|
import { useInterval } from 'usehooks-ts';
|
|
32
32
|
|
|
@@ -172,7 +172,6 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
172
172
|
prePopupOps,
|
|
173
173
|
startCellEditing,
|
|
174
174
|
} = useGridContext<TData>();
|
|
175
|
-
|
|
176
175
|
const { updatedDep, updatingCols } = useContext(GridUpdatingContext);
|
|
177
176
|
|
|
178
177
|
const gridDivRef = useRef<HTMLDivElement>(null);
|
|
@@ -254,21 +253,11 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
254
253
|
// It should be impossible to get here
|
|
255
254
|
console.error('Unknown value returned from hasGridRendered');
|
|
256
255
|
}
|
|
257
|
-
|
|
258
|
-
// If there's no contentSize callback there'll be on onGridResize callback
|
|
259
|
-
// which is required to run sizeColumnsToFit.
|
|
260
|
-
// There's also the possibility that the panel was already the right size so didn't trigger onGridResize.
|
|
261
|
-
delay(() => {
|
|
262
|
-
if (requiresInitialSizeToFitRef.current) {
|
|
263
|
-
requiresInitialSizeToFitRef.current = false;
|
|
264
|
-
sizeColumnsToFit();
|
|
265
|
-
}
|
|
266
|
-
}, 50);
|
|
267
256
|
}
|
|
268
257
|
|
|
269
258
|
setAutoSized(true);
|
|
270
259
|
needsAutoSize.current = false;
|
|
271
|
-
}, [autoSizeColumns, gridRenderState, maxInitialWidth, params, rowData, sizeColumns
|
|
260
|
+
}, [autoSizeColumns, gridRenderState, maxInitialWidth, params, rowData, sizeColumns]);
|
|
272
261
|
|
|
273
262
|
const lastOwnerDocumentRef = useRef<Document>();
|
|
274
263
|
const wasVisibleRef = useRef(false);
|
|
@@ -614,6 +603,9 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
614
603
|
*/
|
|
615
604
|
const onGridResize = useCallback(
|
|
616
605
|
(event: AgGridEvent<TData>) => {
|
|
606
|
+
if (!hasSetContentSizeEmpty.current && !hasSetContentSize.current) {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
617
609
|
if (sizeColumns !== 'none') {
|
|
618
610
|
// Flex columns can expand to fit after resize, but they cannot shrink less than use resized value
|
|
619
611
|
// Double click column resize handle to reset this behaviour
|
|
@@ -626,7 +618,6 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
626
618
|
}),
|
|
627
619
|
),
|
|
628
620
|
];
|
|
629
|
-
requiresInitialSizeToFitRef.current = false;
|
|
630
621
|
defer(() => event.api.sizeColumnsToFit({ columnLimits }));
|
|
631
622
|
}
|
|
632
623
|
},
|
|
@@ -651,6 +642,7 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
651
642
|
if (width == null) {
|
|
652
643
|
return;
|
|
653
644
|
}
|
|
645
|
+
|
|
654
646
|
switch (e.source) {
|
|
655
647
|
case 'uiColumnResized':
|
|
656
648
|
userSizedColIds.current.set(colId, width);
|
|
@@ -863,10 +855,17 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
863
855
|
? {
|
|
864
856
|
enableSelectionWithoutKeys: params.enableSelectionWithoutKeys ?? false,
|
|
865
857
|
enableClickSelection: params.enableClickSelection ?? false,
|
|
866
|
-
mode: rowSelection
|
|
858
|
+
mode: rowSelection === 'single' ? 'singleRow' : 'multiRow',
|
|
867
859
|
}
|
|
868
860
|
: undefined
|
|
869
861
|
}
|
|
862
|
+
onDisplayedColumnsChanged={() => {
|
|
863
|
+
// This happens after an autosize event, if we don't wait for it size columns to fit doesn't work
|
|
864
|
+
if (requiresInitialSizeToFitRef.current) {
|
|
865
|
+
requiresInitialSizeToFitRef.current = false;
|
|
866
|
+
sizeColumnsToFit();
|
|
867
|
+
}
|
|
868
|
+
}}
|
|
870
869
|
rowHeight={rowHeight}
|
|
871
870
|
animateRows={params.animateRows ?? false}
|
|
872
871
|
rowClassRules={params.rowClassRules}
|