@linzjs/step-ag-grid 29.1.4 → 29.1.6
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/components/Grid.d.ts +1 -1
- package/dist/src/components/GridPopoverHook.d.ts +0 -1
- package/dist/src/contexts/GridContext.d.ts +5 -4
- package/dist/step-ag-grid.cjs +55 -65
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +56 -66
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +13 -4
- package/src/components/GridCell.tsx +5 -24
- package/src/components/GridPopoverHook.tsx +0 -1
- package/src/components/gridForm/GridFormDropDown.tsx +44 -35
- package/src/contexts/GridContext.tsx +6 -1
- package/src/contexts/GridContextProvider.tsx +3 -5
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +0 -1
- package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +4 -6
|
@@ -88,4 +88,4 @@ export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
|
|
|
88
88
|
/**
|
|
89
89
|
* Wrapper for AgGrid to add commonly used functionality.
|
|
90
90
|
*/
|
|
91
|
-
export declare const Grid: <TData extends GridBaseRow = GridBaseRow>({ "data-testid": dataTestId, defaultPostSort, rowSelection, suppressColumnVirtualization, theme, sizeColumns, selectColumnPinned, contextMenuSelectRow, singleClickEdit, rowData, rowHeight, selectable, ...params }: GridProps<TData>) => ReactElement;
|
|
91
|
+
export declare const Grid: <TData extends GridBaseRow = GridBaseRow>({ "data-testid": dataTestId, defaultPostSort, rowSelection, suppressColumnVirtualization, theme, sizeColumns, selectColumnPinned, contextMenuSelectRow, singleClickEdit, rowData, rowHeight, selectable, onCellFocused: paramsOnCellFocused, ...params }: GridProps<TData>) => ReactElement;
|
|
@@ -10,5 +10,4 @@ export declare const CancelPromise: () => Promise<boolean>;
|
|
|
10
10
|
export declare const useGridPopoverHook: <TData extends GridBaseRow>({ className, save, invalid, dontSaveOnExternalClick, }: GridPopoverHookProps<TData>) => {
|
|
11
11
|
popoverWrapper: (children: ReactElement) => import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
triggerSave: (reason?: string) => Promise<void>;
|
|
13
|
-
gridPopoverOpen: boolean;
|
|
14
13
|
};
|
|
@@ -11,6 +11,10 @@ export interface AutoSizeColumnsProps {
|
|
|
11
11
|
export type AutoSizeColumnsResult = {
|
|
12
12
|
width: number;
|
|
13
13
|
} | null;
|
|
14
|
+
export interface StartCellEditingProps {
|
|
15
|
+
rowId: number;
|
|
16
|
+
colId: string;
|
|
17
|
+
}
|
|
14
18
|
export interface GridContextType<TData extends GridBaseRow> {
|
|
15
19
|
gridReady: boolean;
|
|
16
20
|
gridRenderState: () => null | 'empty' | 'rows-visible';
|
|
@@ -37,10 +41,7 @@ export interface GridContextType<TData extends GridBaseRow> {
|
|
|
37
41
|
getFirstRowId: () => number;
|
|
38
42
|
autoSizeColumns: (props?: AutoSizeColumnsProps) => AutoSizeColumnsResult;
|
|
39
43
|
sizeColumnsToFit: () => void;
|
|
40
|
-
startCellEditing: ({ rowId, colId }:
|
|
41
|
-
rowId: number;
|
|
42
|
-
colId: string;
|
|
43
|
-
}) => Promise<void>;
|
|
44
|
+
startCellEditing: ({ rowId, colId }: StartCellEditingProps) => Promise<void>;
|
|
44
45
|
resetFocusedCellAfterCellEditing: () => void;
|
|
45
46
|
updatingCells: (props: {
|
|
46
47
|
selectedRows: GridBaseRow[];
|
package/dist/step-ag-grid.cjs
CHANGED
|
@@ -2762,7 +2762,7 @@ agGridCommunity.ModuleRegistry.registerModules([agGridCommunity.AllCommunityModu
|
|
|
2762
2762
|
/**
|
|
2763
2763
|
* Wrapper for AgGrid to add commonly used functionality.
|
|
2764
2764
|
*/
|
|
2765
|
-
const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection = 'multiple', suppressColumnVirtualization = true, theme = 'ag-theme-step-default', sizeColumns = 'auto', selectColumnPinned = 'left', contextMenuSelectRow = false, singleClickEdit = false, rowData, rowHeight = theme === 'ag-theme-step-default' ? 40 : theme === 'ag-theme-step-compact' ? 36 : 40, selectable, ...params }) => {
|
|
2765
|
+
const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection = 'multiple', suppressColumnVirtualization = true, theme = 'ag-theme-step-default', sizeColumns = 'auto', selectColumnPinned = 'left', contextMenuSelectRow = false, singleClickEdit = false, rowData, rowHeight = theme === 'ag-theme-step-default' ? 40 : theme === 'ag-theme-step-compact' ? 36 : 40, selectable, onCellFocused: paramsOnCellFocused, ...params }) => {
|
|
2766
2766
|
const { gridReady, gridRenderState, setApis, ensureRowVisible, getFirstRowId, selectRowsById, focusByRowById, ensureSelectedRowIsVisible, autoSizeColumns, sizeColumnsToFit, externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync, isExternalFilterPresent, doesExternalFilterPass, setOnBulkEditingComplete, getColDef, showNoRowsOverlay, prePopupOps, startCellEditing, } = useGridContext();
|
|
2767
2767
|
const { updatedDep, updatingCols } = React.useContext(GridUpdatingContext);
|
|
2768
2768
|
const gridDivRef = React.useRef(null);
|
|
@@ -3158,7 +3158,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3158
3158
|
}
|
|
3159
3159
|
}, [clearHighlightRowClasses]);
|
|
3160
3160
|
const onCellFocused = React.useCallback((event) => {
|
|
3161
|
-
if (!
|
|
3161
|
+
if (!paramsOnCellFocused || event.rowIndex == null) {
|
|
3162
3162
|
return;
|
|
3163
3163
|
}
|
|
3164
3164
|
const api = event.api;
|
|
@@ -3172,8 +3172,16 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3172
3172
|
if (!colDef || typeof colDef === 'string') {
|
|
3173
3173
|
return;
|
|
3174
3174
|
}
|
|
3175
|
-
|
|
3176
|
-
|
|
3175
|
+
// Prevent repeated callbacks to cell focus when it focus didn't change
|
|
3176
|
+
const { sourceEvent } = event;
|
|
3177
|
+
if (sourceEvent) {
|
|
3178
|
+
if (window.__stepaggrid_lastfocuseventtarget === sourceEvent.target) {
|
|
3179
|
+
return;
|
|
3180
|
+
}
|
|
3181
|
+
window.__stepaggrid_lastfocuseventtarget = sourceEvent.target;
|
|
3182
|
+
}
|
|
3183
|
+
paramsOnCellFocused({ colDef, data });
|
|
3184
|
+
}, [paramsOnCellFocused]);
|
|
3177
3185
|
const onRowDragEnd = React.useCallback((event) => {
|
|
3178
3186
|
clearHighlightRowClasses();
|
|
3179
3187
|
gridElementRef.current = undefined;
|
|
@@ -3256,7 +3264,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
|
|
|
3256
3264
|
enableClickSelection: params.enableClickSelection ?? false,
|
|
3257
3265
|
mode: rowSelection == 'single' ? 'singleRow' : 'multiRow',
|
|
3258
3266
|
}
|
|
3259
|
-
: undefined, rowHeight: rowHeight, animateRows: params.animateRows ?? false, rowClassRules: params.rowClassRules, getRowId: getRowId, onGridSizeChanged: onGridSizeChanged, suppressColumnVirtualisation: suppressColumnVirtualization, suppressClickEdit: true, onColumnVisible: setInitialContentSize, onRowDataUpdated: onRowDataChanged, onCellFocused: onCellFocused, onCellKeyDown: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, domLayout: params.domLayout, onColumnResized: onColumnResized, defaultColDef: defaultColDef, columnDefs: columnDefsAdjusted, selectionColumnDef: selectionColumnDef, rowData: rowData, postSortRows: params.onRowDragEnd || !defaultPostSort ? undefined : postSortRows, onModelUpdated: onModelUpdated, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, quickFilterParser: quickFilterParser, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved, noRowsOverlayComponent: noRowsOverlayComponent, alwaysShowVerticalScroll: params.alwaysShowVerticalScroll, isExternalFilterPresent: isExternalFilterPresent, doesExternalFilterPass: doesExternalFilterPass, maintainColumnOrder: true, preventDefaultOnContextMenu: true, onCellContextMenu: gridContextMenu.cellContextMenu, rowDragText: params.rowDragText, onRowDragCancel: clearHighlightRowClasses, onRowDragMove: onRowDragMove, onRowDragEnd: onRowDragEnd, suppressCellFocus: params.suppressCellFocus, pinnedTopRowData: params.pinnedTopRowData, pinnedBottomRowData: params.pinnedBottomRowData, onRowClicked: params.onRowClicked, onRowDoubleClicked: params.onRowDoubleClicked }) })] }));
|
|
3267
|
+
: undefined, rowHeight: rowHeight, animateRows: params.animateRows ?? false, rowClassRules: params.rowClassRules, getRowId: getRowId, onGridSizeChanged: onGridSizeChanged, suppressColumnVirtualisation: suppressColumnVirtualization, suppressClickEdit: true, onColumnVisible: setInitialContentSize, onRowDataUpdated: onRowDataChanged, onCellFocused: onCellFocused, onCellKeyDown: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, domLayout: params.domLayout, onColumnResized: onColumnResized, defaultColDef: defaultColDef, columnDefs: columnDefsAdjusted, selectionColumnDef: selectionColumnDef, rowData: rowData, postSortRows: params.onRowDragEnd || !defaultPostSort ? undefined : postSortRows, onModelUpdated: onModelUpdated, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, quickFilterParser: quickFilterParser, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved, noRowsOverlayComponent: noRowsOverlayComponent, alwaysShowVerticalScroll: params.alwaysShowVerticalScroll, isExternalFilterPresent: isExternalFilterPresent, doesExternalFilterPass: doesExternalFilterPass, maintainColumnOrder: true, preventDefaultOnContextMenu: true, onCellContextMenu: gridContextMenu.cellContextMenu, rowDragText: params.rowDragText, onRowDragCancel: clearHighlightRowClasses, onRowDragMove: onRowDragMove, onRowDragEnd: onRowDragEnd, suppressCellFocus: params.suppressCellFocus, pinnedTopRowData: params.pinnedTopRowData, pinnedBottomRowData: params.pinnedBottomRowData, onRowClicked: params.onRowClicked, onRowDoubleClicked: params.onRowDoubleClicked, suppressStartEditOnTab: true }) })] }));
|
|
3260
3268
|
};
|
|
3261
3269
|
const quickFilterParser = (filterStr) => {
|
|
3262
3270
|
// filter is exact matches exactly groups separated by commas
|
|
@@ -3401,14 +3409,10 @@ const GridCell = (props, custom) => {
|
|
|
3401
3409
|
resizable: true,
|
|
3402
3410
|
valueSetter: custom?.editor ? blockValueSetter : undefined,
|
|
3403
3411
|
editable: props.editable ?? !!custom?.editor,
|
|
3404
|
-
...(custom?.editor
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
}
|
|
3409
|
-
: {
|
|
3410
|
-
cellEditor: CellEditorToBlockEditing,
|
|
3411
|
-
}),
|
|
3412
|
+
...(custom?.editor && {
|
|
3413
|
+
cellClassRules: GridCellMultiSelectClassRules,
|
|
3414
|
+
cellEditor: GenericCellEditorComponentWrapper(custom?.editor),
|
|
3415
|
+
}),
|
|
3412
3416
|
suppressKeyboardEvent: suppressCellKeyboardEvents,
|
|
3413
3417
|
...(custom?.editorParams
|
|
3414
3418
|
? {
|
|
@@ -3435,19 +3439,6 @@ const GridCell = (props, custom) => {
|
|
|
3435
3439
|
},
|
|
3436
3440
|
};
|
|
3437
3441
|
};
|
|
3438
|
-
/**
|
|
3439
|
-
* Ag-grid will start its own editor if editable is true and there is no cell editor
|
|
3440
|
-
* like in the case of a cell that is editable because it triggers a modal.
|
|
3441
|
-
* This will block that editor.
|
|
3442
|
-
*/
|
|
3443
|
-
const CellEditorToBlockEditing = ({ stopEditing }) => {
|
|
3444
|
-
React.useEffect(() => {
|
|
3445
|
-
lodashEs.defer(() => {
|
|
3446
|
-
stopEditing();
|
|
3447
|
-
});
|
|
3448
|
-
}, [stopEditing]);
|
|
3449
|
-
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
3450
|
-
};
|
|
3451
3442
|
const GenericCellEditorComponentWrapper = (editor) => {
|
|
3452
3443
|
const obj = { editor };
|
|
3453
3444
|
return React.forwardRef(function GenericCellEditorComponentFr(cellEditorParams, _) {
|
|
@@ -4010,7 +4001,6 @@ const useGridPopoverHook = ({ className, save, invalid, dontSaveOnExternalClick,
|
|
|
4010
4001
|
return {
|
|
4011
4002
|
popoverWrapper,
|
|
4012
4003
|
triggerSave,
|
|
4013
|
-
gridPopoverOpen: isOpen,
|
|
4014
4004
|
};
|
|
4015
4005
|
};
|
|
4016
4006
|
|
|
@@ -4035,7 +4025,7 @@ const GridFormDropDown = (props) => {
|
|
|
4035
4025
|
// Save triggers during async action processing which triggers another selectItem(), this ref blocks that
|
|
4036
4026
|
const [filter, setFilter] = React.useState(props.filterDefaultValue ?? '');
|
|
4037
4027
|
const [filteredValues, setFilteredValues] = React.useState();
|
|
4038
|
-
const [options, setOptions] = React.useState(null);
|
|
4028
|
+
const [options, setOptions] = React.useState(!!propOptions && typeof propOptions !== 'function' ? propOptions : null);
|
|
4039
4029
|
const subComponentIsValid = React.useRef(false);
|
|
4040
4030
|
const subComponentInitialValue = React.useRef(null);
|
|
4041
4031
|
const [subSelectedValue, setSubSelectedValue] = React.useState(null);
|
|
@@ -4102,55 +4092,58 @@ const GridFormDropDown = (props) => {
|
|
|
4102
4092
|
selectedRows,
|
|
4103
4093
|
subSelectedValue,
|
|
4104
4094
|
]);
|
|
4105
|
-
const { popoverWrapper
|
|
4095
|
+
const { popoverWrapper } = useGridPopoverHook({
|
|
4106
4096
|
className: props.className,
|
|
4107
4097
|
invalid: () => !options || !!(selectedItem && !subComponentIsValid.current),
|
|
4108
4098
|
save,
|
|
4109
4099
|
dontSaveOnExternalClick: true,
|
|
4110
4100
|
});
|
|
4111
4101
|
// Load up options list if it's async function
|
|
4112
|
-
const prevIsOpen = usePrevious(gridPopoverOpen);
|
|
4113
|
-
const prevFilter = usePrevious(filter);
|
|
4114
4102
|
React.useEffect(() => {
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
}
|
|
4103
|
+
// If options is null then we need to load/reload
|
|
4104
|
+
// Options will be set to null during a reload based filter, or on open popup
|
|
4105
|
+
if (options !== null) {
|
|
4106
|
+
return;
|
|
4107
|
+
}
|
|
4108
|
+
// propOptions is a const list
|
|
4109
|
+
if (typeof propOptions !== 'function') {
|
|
4110
|
+
if (propOptions) {
|
|
4111
|
+
setOptions(propOptions);
|
|
4112
|
+
}
|
|
4113
|
+
return;
|
|
4125
4114
|
}
|
|
4126
|
-
|
|
4115
|
+
// propOptions is function, probably loading from web
|
|
4116
|
+
void (async () => {
|
|
4117
|
+
const r = await propOptions(selectedRows, filter);
|
|
4118
|
+
setOptions(r ?? []);
|
|
4119
|
+
})();
|
|
4120
|
+
}, [filter, options, propOptions, selectedRows]);
|
|
4127
4121
|
// Local filtering.
|
|
4128
4122
|
React.useEffect(() => {
|
|
4129
|
-
if (props.filtered
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
console.error('Cannot filter non-string labels', option);
|
|
4136
|
-
return undefined;
|
|
4137
|
-
}
|
|
4138
|
-
return textMatch(option.label || '', filter) ? option : undefined;
|
|
4139
|
-
})
|
|
4140
|
-
.filter((r) => r !== undefined));
|
|
4123
|
+
if (props.filtered !== 'local') {
|
|
4124
|
+
return;
|
|
4125
|
+
}
|
|
4126
|
+
if (options == null) {
|
|
4127
|
+
setFilteredValues([]);
|
|
4128
|
+
return;
|
|
4141
4129
|
}
|
|
4130
|
+
setFilteredValues(lodashEs.compact(options.map((option) => {
|
|
4131
|
+
if (option.label != null && typeof option.label !== 'string') {
|
|
4132
|
+
console.warn('GridFormDropDown: Cannot filter non-string labels', option);
|
|
4133
|
+
return undefined;
|
|
4134
|
+
}
|
|
4135
|
+
return textMatch(option.label || '', filter) ? option : undefined;
|
|
4136
|
+
})));
|
|
4142
4137
|
}, [props.filtered, filter, options]);
|
|
4143
4138
|
const reSearchOnFilterChange = React.useMemo(() => debounce(() => {
|
|
4144
4139
|
setOptions(null);
|
|
4145
4140
|
}, 500), []);
|
|
4146
|
-
const previousFilter =
|
|
4147
|
-
// Reload filtering.
|
|
4141
|
+
const previousFilter = usePrevious(filter);
|
|
4148
4142
|
React.useEffect(() => {
|
|
4149
|
-
if (previousFilter
|
|
4150
|
-
previousFilter.current = filter;
|
|
4143
|
+
if (previousFilter != null && previousFilter != filter && props.filtered === 'reload') {
|
|
4151
4144
|
void reSearchOnFilterChange();
|
|
4152
4145
|
}
|
|
4153
|
-
}, [filter, props, reSearchOnFilterChange]);
|
|
4146
|
+
}, [filter, previousFilter, props.filtered, reSearchOnFilterChange]);
|
|
4154
4147
|
let lastHeader = null;
|
|
4155
4148
|
let showHeader = null;
|
|
4156
4149
|
return popoverWrapper(jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.filtered && (jsxRuntime.jsxs("div", { className: 'GridFormDropDown-filter', children: [jsxRuntime.jsx(FocusableItem, { className: 'filter-item', onFocus: () => {
|
|
@@ -5539,12 +5532,9 @@ const GridContextProvider = (props) => {
|
|
|
5539
5532
|
const preRow = gridApi.getFocusedCell();
|
|
5540
5533
|
// If we don't do this ag-grid will do its own continuation of an edit on tab, we don't want that as
|
|
5541
5534
|
// we are managing it ourselves
|
|
5542
|
-
gridApi.
|
|
5543
|
-
if (
|
|
5544
|
-
|
|
5545
|
-
}
|
|
5546
|
-
else {
|
|
5547
|
-
gridApi.tabToPreviousCell();
|
|
5535
|
+
const didTab = tabDirection === 1 ? gridApi.tabToNextCell() : gridApi.tabToPreviousCell();
|
|
5536
|
+
if (!didTab) {
|
|
5537
|
+
break;
|
|
5548
5538
|
}
|
|
5549
5539
|
if (gridApi.isDestroyed()) {
|
|
5550
5540
|
return true;
|