@linzjs/step-ag-grid 14.9.3 → 14.10.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/README.md +5 -0
- package/dist/src/components/GridCellFiller.d.ts +4 -0
- package/dist/src/components/gridUtil.d.ts +3 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/contexts/GridContext.d.ts +3 -2
- package/dist/step-ag-grid.esm.js +103 -57
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +29 -11
- package/src/components/GridCellFiller.tsx +11 -0
- package/src/components/gridFilter/GridFilterColumnsToggle.tsx +52 -51
- package/src/components/gridUtil.ts +6 -0
- package/src/components/index.ts +1 -0
- package/src/contexts/GridContext.tsx +10 -3
- package/src/contexts/GridContextProvider.tsx +63 -35
- package/src/stories/grid/GridReadOnly.stories.tsx +21 -7
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ import "@linzjs/lui/dist/scss/base.scss";
|
|
|
53
53
|
import {
|
|
54
54
|
ColDefT,
|
|
55
55
|
GridCell,
|
|
56
|
+
GridCellFiller,
|
|
56
57
|
GridContextProvider,
|
|
57
58
|
GridPopoverEditDropDown,
|
|
58
59
|
GridPopoverMessage,
|
|
@@ -81,9 +82,11 @@ const GridDemo = () => {
|
|
|
81
82
|
headerName: "Id",
|
|
82
83
|
export: false,
|
|
83
84
|
}),
|
|
85
|
+
// This is the flex column that will expand to fit
|
|
84
86
|
GridCell({
|
|
85
87
|
field: "name",
|
|
86
88
|
headerName: "Name",
|
|
89
|
+
flex: 1,
|
|
87
90
|
cellRendererParams: {
|
|
88
91
|
warning: ({ value }) => value === "Tester" && "Testers are testing",
|
|
89
92
|
info: ({ value }) => value === "Developer" && "Developers are awesome",
|
|
@@ -115,6 +118,8 @@ const GridDemo = () => {
|
|
|
115
118
|
},
|
|
116
119
|
},
|
|
117
120
|
),
|
|
121
|
+
// If your flex column gets hidden this will become active
|
|
122
|
+
GridCellFiller(),
|
|
118
123
|
],
|
|
119
124
|
[],
|
|
120
125
|
);
|
|
@@ -14,7 +14,8 @@ export type AutoSizeColumnsResult = {
|
|
|
14
14
|
export interface GridContextType<RowType extends GridBaseRow> {
|
|
15
15
|
gridReady: boolean;
|
|
16
16
|
getColDef: (colId?: string) => ColDef | undefined;
|
|
17
|
-
getColumns: () => ColDefT<RowType>[];
|
|
17
|
+
getColumns: (filter?: keyof ColDef | ((r: ColDef) => boolean | undefined | null | number | string)) => ColDefT<RowType>[];
|
|
18
|
+
getColumnIds: (filter?: keyof ColDef | ((r: ColDef) => boolean | undefined | null | number | string)) => string[];
|
|
18
19
|
setApis: (gridApi: GridApi | undefined, columnApi: ColumnApi | undefined, dataTestId?: string) => void;
|
|
19
20
|
prePopupOps: () => void;
|
|
20
21
|
setQuickFilter: (quickFilter: string) => void;
|
|
@@ -53,7 +54,7 @@ export interface GridContextType<RowType extends GridBaseRow> {
|
|
|
53
54
|
removeExternalFilter: (filter: GridFilterExternal<RowType>) => void;
|
|
54
55
|
isExternalFilterPresent: () => boolean;
|
|
55
56
|
doesExternalFilterPass: (node: RowNode) => boolean;
|
|
56
|
-
invisibleColumnIds: string[];
|
|
57
|
+
invisibleColumnIds: string[] | undefined;
|
|
57
58
|
setInvisibleColumnIds: (colIds: string[]) => void;
|
|
58
59
|
downloadCsv: (csvExportParams?: CsvExportParams) => void;
|
|
59
60
|
setOnCellEditingComplete: (callback: (() => void) | undefined) => void;
|
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { LuiMiniSpinner, LuiIcon, LuiButton, LuiCheckboxInput, LuiButtonGroup } from '@linzjs/lui';
|
|
3
3
|
import { AgGridReact } from 'ag-grid-react';
|
|
4
|
-
import { negate, isEmpty, xorBy, last, difference, defer as defer$1, omit, sortBy, findIndex, debounce as debounce$1, delay, partition, pick, groupBy, fromPairs, toPairs, isEqual, sumBy,
|
|
4
|
+
import { negate, isEmpty, xorBy, last, difference, defer as defer$1, omit, sortBy, findIndex, debounce as debounce$1, delay, partition, pick, groupBy, fromPairs, toPairs, isEqual, compact, filter, sumBy, pull, remove, castArray, flatten } from 'lodash-es';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { createContext, useContext, useRef, useEffect, useCallback, useState, useMemo, forwardRef, useLayoutEffect, memo, useReducer, cloneElement, useImperativeHandle, Fragment as Fragment$1 } from 'react';
|
|
7
7
|
import ReactDOM, { unstable_batchedUpdates, flushSync, createPortal } from 'react-dom';
|
|
@@ -42,7 +42,11 @@ const GridContext = createContext({
|
|
|
42
42
|
console.error("no context provider for getColumns");
|
|
43
43
|
return [];
|
|
44
44
|
},
|
|
45
|
-
|
|
45
|
+
getColumnIds: () => {
|
|
46
|
+
console.error("no context provider for getColumnIds");
|
|
47
|
+
return [];
|
|
48
|
+
},
|
|
49
|
+
invisibleColumnIds: undefined,
|
|
46
50
|
setInvisibleColumnIds: () => {
|
|
47
51
|
console.error("no context provider for setInvisibleColumnIds");
|
|
48
52
|
},
|
|
@@ -518,11 +522,20 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
|
|
|
518
522
|
}
|
|
519
523
|
needsAutoSize.current = false;
|
|
520
524
|
}, [autoSizeColumns, params, sizeColumns, sizeColumnsToFit]);
|
|
525
|
+
const lastOwnerDocumentRef = useRef();
|
|
521
526
|
/**
|
|
522
527
|
* Auto-size windows that had deferred auto-size
|
|
523
528
|
*/
|
|
524
529
|
useIntervalHook({
|
|
525
530
|
callback: () => {
|
|
531
|
+
// Check if window has been popped out and needs resize
|
|
532
|
+
const currentDocument = gridDivRef.current?.ownerDocument;
|
|
533
|
+
if (currentDocument !== lastOwnerDocumentRef.current) {
|
|
534
|
+
lastOwnerDocumentRef.current = currentDocument;
|
|
535
|
+
if (currentDocument) {
|
|
536
|
+
needsAutoSize.current = true;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
526
539
|
if (needsAutoSize.current) {
|
|
527
540
|
needsAutoSize.current = false;
|
|
528
541
|
setInitialContentSize();
|
|
@@ -801,11 +814,19 @@ const Grid = ({ "data-testid": dataTestId, rowSelection = "multiple", suppressCo
|
|
|
801
814
|
* Once the grid has auto-sized we want to run fit to fit the grid in its container,
|
|
802
815
|
* but we don't want the non-flex auto-sized columns to "fit" size, so suppressSizeToFit is set to true.
|
|
803
816
|
*/
|
|
804
|
-
const columnDefsAdjusted = useMemo(() =>
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
817
|
+
const columnDefsAdjusted = useMemo(() => {
|
|
818
|
+
const adjustColDefOrGroup = (colDef) => "children" in colDef ? adjustGroupColDef(colDef) : adjustColDef(colDef);
|
|
819
|
+
const adjustGroupColDef = (colDef) => ({
|
|
820
|
+
...colDef,
|
|
821
|
+
children: colDef.children.map((colDef) => adjustColDefOrGroup(colDef)),
|
|
822
|
+
});
|
|
823
|
+
const adjustColDef = (colDef) => ({
|
|
824
|
+
...colDef,
|
|
825
|
+
suppressSizeToFit: (sizeColumns === "auto" || sizeColumns === "auto-skip-headers") && !colDef.flex,
|
|
826
|
+
sortable: colDef.sortable && params.defaultColDef?.sortable !== false,
|
|
827
|
+
});
|
|
828
|
+
return columnDefs.map((colDef) => adjustColDefOrGroup(colDef));
|
|
829
|
+
}, [columnDefs, params.defaultColDef?.sortable, sizeColumns]);
|
|
809
830
|
/**
|
|
810
831
|
* Set of colIds that need auto-sizing.
|
|
811
832
|
*/
|
|
@@ -1051,6 +1072,14 @@ const GenericCellEditorComponentWrapper = (editor) => {
|
|
|
1051
1072
|
});
|
|
1052
1073
|
};
|
|
1053
1074
|
|
|
1075
|
+
const GridCellFillerColId = "gridCellFiller";
|
|
1076
|
+
const isGridCellFiller = (col) => col.colId === GridCellFillerColId;
|
|
1077
|
+
const GridCellFiller = () => ({
|
|
1078
|
+
colId: GridCellFillerColId,
|
|
1079
|
+
headerName: "",
|
|
1080
|
+
flex: 1,
|
|
1081
|
+
});
|
|
1082
|
+
|
|
1054
1083
|
const Editor = (props) => ({
|
|
1055
1084
|
component: GenericCellEditorComponentWrapper(props.editor),
|
|
1056
1085
|
params: { ...props.editorParams, multiEdit: props.multiEdit },
|
|
@@ -2886,13 +2915,12 @@ const MenuRadioGroup = forwardRef(MenuRadioGroupFr);
|
|
|
2886
2915
|
|
|
2887
2916
|
const GridFilterColumnsToggle = ({ saveState = true }) => {
|
|
2888
2917
|
const [loaded, setLoaded] = useState(false);
|
|
2889
|
-
const { getColumns, invisibleColumnIds, setInvisibleColumnIds } = useContext(GridContext);
|
|
2890
|
-
const columnStorageKey = useMemo(() => isEmpty(
|
|
2918
|
+
const { getColumns, getColumnIds, invisibleColumnIds, setInvisibleColumnIds } = useContext(GridContext);
|
|
2919
|
+
const columnStorageKey = useMemo(() => isEmpty(getColumnIds())
|
|
2891
2920
|
? null // Grid hasn't been initialised yet
|
|
2892
|
-
: "stepAgGrid_invisibleColumnIds_" +
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
.join("_"), [getColumns]);
|
|
2921
|
+
: "stepAgGrid_invisibleColumnIds_" + getColumnIds().join("_"), [getColumnIds]);
|
|
2922
|
+
// infer the invisible ids from colDefs
|
|
2923
|
+
const resetColumns = useCallback(() => setInvisibleColumnIds(getColumnIds("initialHide")), [getColumnIds, setInvisibleColumnIds]);
|
|
2896
2924
|
// Load state on start
|
|
2897
2925
|
useEffect(() => {
|
|
2898
2926
|
if (!columnStorageKey || loaded)
|
|
@@ -2900,15 +2928,20 @@ const GridFilterColumnsToggle = ({ saveState = true }) => {
|
|
|
2900
2928
|
if (saveState) {
|
|
2901
2929
|
try {
|
|
2902
2930
|
const stored = window.localStorage.getItem(columnStorageKey);
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
console.error(`stored invisible ids not an array: ${stored}`);
|
|
2906
|
-
}
|
|
2907
|
-
else if (!invisibleIds.every((id) => typeof id === "string")) {
|
|
2908
|
-
console.error(`stored invisible ids not strings: ${stored}`);
|
|
2931
|
+
if (!stored) {
|
|
2932
|
+
resetColumns();
|
|
2909
2933
|
}
|
|
2910
2934
|
else {
|
|
2911
|
-
invisibleIds
|
|
2935
|
+
const invisibleIds = JSON.parse(stored ?? "[]");
|
|
2936
|
+
if (!Array.isArray(invisibleIds)) {
|
|
2937
|
+
console.error(`stored invisible ids not an array: ${stored}`);
|
|
2938
|
+
}
|
|
2939
|
+
else if (!invisibleIds.every((id) => typeof id === "string")) {
|
|
2940
|
+
console.error(`stored invisible ids not strings: ${stored}`);
|
|
2941
|
+
}
|
|
2942
|
+
else {
|
|
2943
|
+
invisibleIds && setInvisibleColumnIds(invisibleIds);
|
|
2944
|
+
}
|
|
2912
2945
|
}
|
|
2913
2946
|
}
|
|
2914
2947
|
catch (ex) {
|
|
@@ -2916,7 +2949,7 @@ const GridFilterColumnsToggle = ({ saveState = true }) => {
|
|
|
2916
2949
|
}
|
|
2917
2950
|
setLoaded(true);
|
|
2918
2951
|
}
|
|
2919
|
-
}, [columnStorageKey, loaded, saveState, setInvisibleColumnIds]);
|
|
2952
|
+
}, [columnStorageKey, getColumns, loaded, resetColumns, saveState, setInvisibleColumnIds]);
|
|
2920
2953
|
// Save state on column visibility change
|
|
2921
2954
|
useEffect(() => {
|
|
2922
2955
|
loaded &&
|
|
@@ -2925,22 +2958,17 @@ const GridFilterColumnsToggle = ({ saveState = true }) => {
|
|
|
2925
2958
|
window.localStorage.setItem(columnStorageKey, JSON.stringify(invisibleColumnIds));
|
|
2926
2959
|
}, [columnStorageKey, invisibleColumnIds, loaded, saveState]);
|
|
2927
2960
|
const toggleColumn = useCallback((colId) => {
|
|
2928
|
-
if (!colId)
|
|
2961
|
+
if (!colId || !invisibleColumnIds)
|
|
2929
2962
|
return;
|
|
2930
2963
|
setInvisibleColumnIds(invisibleColumnIds.includes(colId)
|
|
2931
2964
|
? invisibleColumnIds.filter((id) => id !== colId)
|
|
2932
2965
|
: [...invisibleColumnIds, colId]);
|
|
2933
2966
|
}, [invisibleColumnIds, setInvisibleColumnIds]);
|
|
2934
|
-
const resetColumns = () => {
|
|
2935
|
-
setInvisibleColumnIds([]);
|
|
2936
|
-
};
|
|
2937
2967
|
const numericRegExp = /^\d+$/;
|
|
2938
2968
|
const isNonManageableColumn = (col) => {
|
|
2939
2969
|
return col.lockVisible || col.colId == null || numericRegExp.test(col.colId);
|
|
2940
2970
|
};
|
|
2941
|
-
return (jsxs(Menu, { menuButton: jsx(GridFilterHeaderIconButton, { icon: "ic_columns", title: "Column visibility" }), menuClassName: "step-ag-grid-react-menu", portal: true, unmountOnClose: true, children: [jsx("div", { className: "GridFilterColumnsToggle-container", children: getColumns()
|
|
2942
|
-
.filter((col) => !!col.headerName)
|
|
2943
|
-
.map((col) => (jsx(MenuItem, { disabled: isNonManageableColumn(col), onClick: (e) => {
|
|
2971
|
+
return (jsxs(Menu, { menuButton: jsx(GridFilterHeaderIconButton, { icon: "ic_columns", title: "Column visibility" }), menuClassName: "step-ag-grid-react-menu", portal: true, unmountOnClose: true, children: [jsx("div", { className: "GridFilterColumnsToggle-container", children: getColumns("headerName").map((col) => (jsx(MenuItem, { disabled: isNonManageableColumn(col), onClick: (e) => {
|
|
2944
2972
|
// Global react-menu MenuItem handler handles tabs
|
|
2945
2973
|
if (e.key !== "Tab") {
|
|
2946
2974
|
e.keepOpen = true;
|
|
@@ -2948,7 +2976,7 @@ const GridFilterColumnsToggle = ({ saveState = true }) => {
|
|
|
2948
2976
|
toggleColumn(col.colId);
|
|
2949
2977
|
}
|
|
2950
2978
|
}
|
|
2951
|
-
}, children: jsx(LuiCheckboxInput, { isChecked: !invisibleColumnIds.includes(col.colId ?? ""), value: `${col.colId}`, label: col.headerName ?? "", isDisabled: isNonManageableColumn(col), inputProps: {
|
|
2979
|
+
}, children: jsx(LuiCheckboxInput, { isChecked: !!invisibleColumnIds && !invisibleColumnIds.includes(col.colId ?? ""), value: `${col.colId}`, label: col.headerName ?? "", isDisabled: isNonManageableColumn(col), inputProps: {
|
|
2952
2980
|
onClick: (e) => {
|
|
2953
2981
|
// Click is handled by MenuItem onClick so keyboard events work
|
|
2954
2982
|
e.preventDefault();
|
|
@@ -4419,6 +4447,9 @@ const GridPopoverTextInput = (colDef, params) => GridCell(colDef, {
|
|
|
4419
4447
|
|
|
4420
4448
|
const GridWrapper = ({ children, maxHeight }) => (jsx("div", { className: "Grid-wrapper", style: { maxHeight }, children: children }));
|
|
4421
4449
|
|
|
4450
|
+
const getColId = (colDef) => colDef.colId ?? "";
|
|
4451
|
+
const isFlexColumn = (colDef) => !!colDef.flex && !isGridCellFiller(colDef);
|
|
4452
|
+
|
|
4422
4453
|
/**
|
|
4423
4454
|
* Context for AgGrid operations.
|
|
4424
4455
|
* Make sure you wrap AgGrid in this.
|
|
@@ -4430,12 +4461,16 @@ const GridContextProvider = (props) => {
|
|
|
4430
4461
|
const [columnApi, setColumnApi] = useState();
|
|
4431
4462
|
const [gridReady, setGridReady] = useState(false);
|
|
4432
4463
|
const [quickFilter, setQuickFilter] = useState("");
|
|
4433
|
-
const [invisibleColumnIds,
|
|
4464
|
+
const [invisibleColumnIds, _setInvisibleColumnIds] = useState();
|
|
4434
4465
|
const testId = useRef();
|
|
4435
4466
|
const idsBeforeUpdate = useRef([]);
|
|
4436
4467
|
const prePopupFocusedCell = useRef();
|
|
4437
4468
|
const [externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync] = useState(false);
|
|
4438
4469
|
const externalFilters = useRef([]);
|
|
4470
|
+
/**
|
|
4471
|
+
* Make extra sure the GridCellFillerColId never gets added to invisibleColumnIds as it's dynamically determined
|
|
4472
|
+
*/
|
|
4473
|
+
const setInvisibleColumnIds = (invisibleColumnIds) => _setInvisibleColumnIds(pull(invisibleColumnIds, GridCellFillerColId));
|
|
4439
4474
|
/**
|
|
4440
4475
|
* Set quick filter directly on grid, based on previously save quickFilter state.
|
|
4441
4476
|
*/
|
|
@@ -4535,9 +4570,7 @@ const GridContextProvider = (props) => {
|
|
|
4535
4570
|
* Uses beforeUpdate ids to find new nodes.
|
|
4536
4571
|
*/
|
|
4537
4572
|
const _getNewNodes = useCallback(() => {
|
|
4538
|
-
return gridApiOp((gridApi) => difference(_getAllRowIds(), idsBeforeUpdate.current)
|
|
4539
|
-
.map((rowId) => gridApi.getRowNode("" + rowId)) //
|
|
4540
|
-
.filter((r) => r), () => []);
|
|
4573
|
+
return gridApiOp((gridApi) => compact(difference(_getAllRowIds(), idsBeforeUpdate.current).map((rowId) => gridApi.getRowNode("" + rowId))), () => []);
|
|
4541
4574
|
}, [_getAllRowIds, gridApiOp]);
|
|
4542
4575
|
/**
|
|
4543
4576
|
* Get grid nodes via rowIds. If rowIds has no matching node the result may be smaller than expected.
|
|
@@ -4546,10 +4579,13 @@ const GridContextProvider = (props) => {
|
|
|
4546
4579
|
* @param rowIds Row ids to get from grid.
|
|
4547
4580
|
*/
|
|
4548
4581
|
const _rowIdsToNodes = useCallback((rowIds) => {
|
|
4549
|
-
return gridApiOp((gridApi) => rowIds
|
|
4550
|
-
.map((rowId) => gridApi.getRowNode("" + rowId)) //
|
|
4551
|
-
.filter((r) => r), () => []);
|
|
4582
|
+
return gridApiOp((gridApi) => compact(rowIds.map((rowId) => gridApi.getRowNode("" + rowId))), () => []);
|
|
4552
4583
|
}, [gridApiOp]);
|
|
4584
|
+
/**
|
|
4585
|
+
* Get ColDefs, with flattened ColGroupDefs
|
|
4586
|
+
*/
|
|
4587
|
+
const getColumns = useCallback((filterDef = () => true) => filter(columnApi?.getAllColumns()?.map((col) => col.getColDef()) ?? [], filterDef), [columnApi]);
|
|
4588
|
+
const getColumnIds = useCallback((filterDef = () => true) => compact(getColumns(filterDef).map(getColId)), [getColumns]);
|
|
4553
4589
|
/**
|
|
4554
4590
|
* Internal method for selecting and flashing rows.
|
|
4555
4591
|
*
|
|
@@ -4573,9 +4609,9 @@ const GridContextProvider = (props) => {
|
|
|
4573
4609
|
const firstNode = rowsThatNeedSelecting[0];
|
|
4574
4610
|
if (firstNode) {
|
|
4575
4611
|
defer$1(() => gridApi.ensureNodeVisible(firstNode));
|
|
4576
|
-
const colDefs =
|
|
4577
|
-
if (colDefs
|
|
4578
|
-
const col = colDefs[0];
|
|
4612
|
+
const colDefs = getColumns();
|
|
4613
|
+
if (!isEmpty(colDefs)) {
|
|
4614
|
+
const col = colDefs[0];
|
|
4579
4615
|
const rowIndex = firstNode.rowIndex;
|
|
4580
4616
|
if (rowIndex != null && col != null) {
|
|
4581
4617
|
const colId = col.colId;
|
|
@@ -4606,7 +4642,7 @@ const GridContextProvider = (props) => {
|
|
|
4606
4642
|
}, 250);
|
|
4607
4643
|
}
|
|
4608
4644
|
});
|
|
4609
|
-
}, [_getNewNodes, _rowIdsToNodes, gridApiOp]);
|
|
4645
|
+
}, [_getNewNodes, _rowIdsToNodes, getColumns, gridApiOp]);
|
|
4610
4646
|
const selectRowsById = useCallback((rowIds) => _selectRowsWithOptionalFlash(rowIds, true, false), [_selectRowsWithOptionalFlash]);
|
|
4611
4647
|
const selectRowsByIdWithFlash = useCallback((rowIds) => _selectRowsWithOptionalFlash(rowIds, true, true), [_selectRowsWithOptionalFlash]);
|
|
4612
4648
|
const flashRows = useCallback((rowIds) => _selectRowsWithOptionalFlash(rowIds, false, true), [_selectRowsWithOptionalFlash]);
|
|
@@ -4808,9 +4844,7 @@ const GridContextProvider = (props) => {
|
|
|
4808
4844
|
});
|
|
4809
4845
|
}, [gridApiOp, modifyUpdating, selectNextEditableCell]);
|
|
4810
4846
|
const redrawRows = useCallback((rowNodes) => {
|
|
4811
|
-
gridApiOp((gridApi) => {
|
|
4812
|
-
gridApi.redrawRows(rowNodes ? { rowNodes } : undefined);
|
|
4813
|
-
});
|
|
4847
|
+
gridApiOp((gridApi) => gridApi.redrawRows(rowNodes ? { rowNodes } : undefined));
|
|
4814
4848
|
}, [gridApiOp]);
|
|
4815
4849
|
// waitForExternallySelectedItemsToBeInSync can't use the state as it won't be updated during function execution
|
|
4816
4850
|
const externallySelectedItemsAreInSyncRef = useRef(false);
|
|
@@ -4834,21 +4868,29 @@ const GridContextProvider = (props) => {
|
|
|
4834
4868
|
remove(externalFilters.current, (v) => v === filter);
|
|
4835
4869
|
onFilterChanged().then();
|
|
4836
4870
|
};
|
|
4837
|
-
const isExternalFilterPresent = () => externalFilters.current
|
|
4838
|
-
const doesExternalFilterPass = (node) =>
|
|
4839
|
-
return externalFilters.current.every((filter) => filter(node.data, node));
|
|
4840
|
-
};
|
|
4871
|
+
const isExternalFilterPresent = () => !isEmpty(externalFilters.current);
|
|
4872
|
+
const doesExternalFilterPass = (node) => externalFilters.current.every((filter) => filter(node.data, node));
|
|
4841
4873
|
const getColDef = useCallback((colId) => (!!colId && gridApi?.getColumnDef(colId)) || undefined, [gridApi]);
|
|
4842
|
-
|
|
4874
|
+
/**
|
|
4875
|
+
* Apply column visibility
|
|
4876
|
+
*/
|
|
4843
4877
|
useEffect(() => {
|
|
4844
|
-
if (columnApi)
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4878
|
+
if (!columnApi || !invisibleColumnIds)
|
|
4879
|
+
return;
|
|
4880
|
+
// show all columns that aren't invisible
|
|
4881
|
+
const newVisibleColumns = getColumns((col) => !col.lockVisible && col.colId && !invisibleColumnIds.includes(col.colId) && !isGridCellFiller(col));
|
|
4882
|
+
// If there's no flex column showing add the filler column if defined
|
|
4883
|
+
const visibleColumnsContainsAFlex = newVisibleColumns.some(isFlexColumn);
|
|
4884
|
+
if (!visibleColumnsContainsAFlex) {
|
|
4885
|
+
const fillerColumn = getColumns(isGridCellFiller)[0];
|
|
4886
|
+
fillerColumn && newVisibleColumns.push(fillerColumn);
|
|
4851
4887
|
}
|
|
4888
|
+
columnApi.setColumnsVisible(compact(newVisibleColumns.map(getColId)), true);
|
|
4889
|
+
// Hide the filler column if there's already a flex column
|
|
4890
|
+
const invisibleColumnIdsWithOptionalFiller = visibleColumnsContainsAFlex
|
|
4891
|
+
? [...invisibleColumnIds, GridCellFillerColId]
|
|
4892
|
+
: invisibleColumnIds;
|
|
4893
|
+
columnApi.setColumnsVisible(invisibleColumnIdsWithOptionalFiller, false);
|
|
4852
4894
|
}, [invisibleColumnIds, columnApi, getColumns]);
|
|
4853
4895
|
/**
|
|
4854
4896
|
* Download visible columns as a CSV
|
|
@@ -4859,7 +4901,10 @@ const GridContextProvider = (props) => {
|
|
|
4859
4901
|
const fileName = csvExportParams?.fileName && sanitiseFileName(csvExportParams.fileName);
|
|
4860
4902
|
const columnKeys = columnApi
|
|
4861
4903
|
?.getColumnState()
|
|
4862
|
-
.filter((cs) =>
|
|
4904
|
+
.filter((cs) => {
|
|
4905
|
+
const colDef = gridApi.getColumnDef(cs.colId);
|
|
4906
|
+
return !cs.hide && colDef && !isGridCellFiller(colDef) && colDef.headerComponentParams?.exportable !== false;
|
|
4907
|
+
})
|
|
4863
4908
|
.map((cs) => cs.colId);
|
|
4864
4909
|
gridApi.exportDataAsCsv({
|
|
4865
4910
|
columnKeys,
|
|
@@ -4871,6 +4916,7 @@ const GridContextProvider = (props) => {
|
|
|
4871
4916
|
return (jsx(GridContext.Provider, { value: {
|
|
4872
4917
|
getColDef,
|
|
4873
4918
|
getColumns,
|
|
4919
|
+
getColumnIds,
|
|
4874
4920
|
invisibleColumnIds,
|
|
4875
4921
|
setInvisibleColumnIds,
|
|
4876
4922
|
gridReady,
|
|
@@ -27606,5 +27652,5 @@ const clickActionButton = async (text, container) => {
|
|
|
27606
27652
|
});
|
|
27607
27653
|
};
|
|
27608
27654
|
|
|
27609
|
-
export { ActionButton, ComponentLoadingWrapper, ControlledMenu, Editor, FocusableItem, FormError, GenericCellEditorComponentWrapper, Grid, GridCell, GridCellMultiEditor, GridCellMultiSelectClassRules, GridCellRenderer, GridContext, GridContextProvider, GridFilterButtons, GridFilterColumnsToggle, GridFilterDownloadCsvButton, GridFilterHeaderIconButton, GridFilterQuick, GridFilters, GridFormDropDown, GridFormEditBearing, GridFormMessage, GridFormMultiSelect, GridFormMultiSelectGrid, GridFormPopoverMenu, GridFormSubComponentTextArea, GridFormSubComponentTextInput, GridFormTextArea, GridFormTextInput, GridHeaderSelect, GridIcon, GridLoadableCell, GridNoRowsOverlay, GridPopoutEditMultiSelect, GridPopoutEditMultiSelectGrid, GridPopoverContext, GridPopoverContextProvider, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditBearingCorrectionEditorParams, GridPopoverEditBearingEditorParams, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridSubComponentContext, GridUpdatingContext, GridUpdatingContextProvider, GridWrapper, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, bearingCorrectionRangeValidator, bearingCorrectionValueFormatter, bearingNumberParser, bearingRangeValidator, bearingStringValidator, bearingValueFormatter, clickActionButton, clickMenuOption, clickMultiSelectOption, closeMenu, closePopover, convertDDToDMS, countRows, deselectRow, downloadCsvUseValueFormattersProcessCellCallback, editCell, findActionButton, findCell, findCellContains, findMenuOption, findMultiSelectOption, findOpenPopover, findParentWithClass, findRow, fnOrVar, generateFilterGetter, getMultiSelectOptions, hasParentClass, isCellReadOnly, isFloat, isNotEmpty, openAndClickMenuOption, openAndFindMenuOption, queryMenuOption, queryRow, sanitiseFileName, selectCell, selectRow, stringByteLengthIsInvalid, suppressCellKeyboardEvents, typeInputByLabel, typeInputByPlaceholder, typeOnlyInput, typeOtherInput, typeOtherTextArea, useDeferredPromise, useGenerateOrDefaultId, useGridContext, useGridFilter, useGridPopoverContext, useGridPopoverHook, useMenuState, usePostSortRowsHook, validateMenuOptions, wait$2 as wait };
|
|
27655
|
+
export { ActionButton, ComponentLoadingWrapper, ControlledMenu, Editor, FocusableItem, FormError, GenericCellEditorComponentWrapper, Grid, GridCell, GridCellFiller, GridCellFillerColId, GridCellMultiEditor, GridCellMultiSelectClassRules, GridCellRenderer, GridContext, GridContextProvider, GridFilterButtons, GridFilterColumnsToggle, GridFilterDownloadCsvButton, GridFilterHeaderIconButton, GridFilterQuick, GridFilters, GridFormDropDown, GridFormEditBearing, GridFormMessage, GridFormMultiSelect, GridFormMultiSelectGrid, GridFormPopoverMenu, GridFormSubComponentTextArea, GridFormSubComponentTextInput, GridFormTextArea, GridFormTextInput, GridHeaderSelect, GridIcon, GridLoadableCell, GridNoRowsOverlay, GridPopoutEditMultiSelect, GridPopoutEditMultiSelectGrid, GridPopoverContext, GridPopoverContextProvider, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditBearingCorrectionEditorParams, GridPopoverEditBearingEditorParams, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridSubComponentContext, GridUpdatingContext, GridUpdatingContextProvider, GridWrapper, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, bearingCorrectionRangeValidator, bearingCorrectionValueFormatter, bearingNumberParser, bearingRangeValidator, bearingStringValidator, bearingValueFormatter, clickActionButton, clickMenuOption, clickMultiSelectOption, closeMenu, closePopover, convertDDToDMS, countRows, deselectRow, downloadCsvUseValueFormattersProcessCellCallback, editCell, findActionButton, findCell, findCellContains, findMenuOption, findMultiSelectOption, findOpenPopover, findParentWithClass, findRow, fnOrVar, generateFilterGetter, getMultiSelectOptions, hasParentClass, isCellReadOnly, isFloat, isGridCellFiller, isNotEmpty, openAndClickMenuOption, openAndFindMenuOption, queryMenuOption, queryRow, sanitiseFileName, selectCell, selectRow, stringByteLengthIsInvalid, suppressCellKeyboardEvents, typeInputByLabel, typeInputByPlaceholder, typeOnlyInput, typeOtherInput, typeOtherTextArea, useDeferredPromise, useGenerateOrDefaultId, useGridContext, useGridFilter, useGridPopoverContext, useGridPopoverHook, useMenuState, usePostSortRowsHook, validateMenuOptions, wait$2 as wait };
|
|
27610
27656
|
//# sourceMappingURL=step-ag-grid.esm.js.map
|