@linzjs/step-ag-grid 7.11.13 → 7.13.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.
@@ -74,10 +74,6 @@
74
74
  align-items: center;
75
75
  }
76
76
 
77
- .ag-cell.ag-cell-inline-editing:not(.ag-cell-auto-height) {
78
- bottom: 0;
79
- }
80
-
81
77
  .ag-cell-wrap-text {
82
78
  word-break: break-word;
83
79
  }
package/dist/index.js CHANGED
@@ -1978,6 +1978,7 @@ var MenuRadioGroup = React.forwardRef(MenuRadioGroupFr);
1978
1978
 
1979
1979
  var GridContext = React.createContext({
1980
1980
  gridReady: false,
1981
+ externallySelectedItemsAreInSync: false,
1981
1982
  setGridApi: function () {
1982
1983
  console.error("no context provider for setGridApi");
1983
1984
  },
@@ -2019,6 +2020,12 @@ var GridContext = React.createContext({
2019
2020
  return [2 /*return*/];
2020
2021
  });
2021
2022
  }); },
2023
+ focusByRowById: function () { return __awaiter(void 0, void 0, void 0, function () {
2024
+ return __generator(this, function (_a) {
2025
+ console.error("no context provider for focusByRowById");
2026
+ return [2 /*return*/];
2027
+ });
2028
+ }); },
2022
2029
  ensureRowVisible: function () {
2023
2030
  console.error("no context provider for ensureRowVisible");
2024
2031
  return true;
@@ -2080,7 +2087,7 @@ var GridContextProvider = function (props) {
2080
2087
  var _a = React.useState(), gridApi = _a[0], _setGridApi = _a[1];
2081
2088
  var _b = React.useState(false), gridReady = _b[0], setGridReady = _b[1];
2082
2089
  var idsBeforeUpdate = React.useRef([]);
2083
- var externallySelectedItemsAreInSync = React.useRef(false);
2090
+ var _c = React.useState(false), externallySelectedItemsAreInSync = _c[0], setExternallySelectedItemsAreInSync = _c[1];
2084
2091
  var setGridApi = React.useCallback(function (gridApi) {
2085
2092
  _setGridApi(gridApi);
2086
2093
  setGridReady(!!gridApi);
@@ -2245,6 +2252,7 @@ var GridContextProvider = function (props) {
2245
2252
  }
2246
2253
  });
2247
2254
  }); }, [_selectRowsWithOptionalFlash, beforeUpdate]);
2255
+ var focusByRowById = React.useCallback(function (rowId) { return _selectRowsWithOptionalFlash([rowId], false, false); }, [_selectRowsWithOptionalFlash]);
2248
2256
  var getSelectedRows = React.useCallback(function () {
2249
2257
  return gridApiOp(function (gridApi) { return gridApi.getSelectedRows(); }, function () { return []; });
2250
2258
  }, [gridApiOp]);
@@ -2358,9 +2366,6 @@ var GridContextProvider = function (props) {
2358
2366
  gridApi.redrawRows(rowNodes ? { rowNodes: rowNodes } : undefined);
2359
2367
  });
2360
2368
  }, [gridApiOp]);
2361
- var setExternallySelectedItemsAreInSync = React.useCallback(function (inSync) {
2362
- externallySelectedItemsAreInSync.current = inSync;
2363
- }, []);
2364
2369
  var waitForExternallySelectedItemsToBeInSync = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
2365
2370
  var i;
2366
2371
  return __generator(this, function (_a) {
@@ -2369,7 +2374,7 @@ var GridContextProvider = function (props) {
2369
2374
  i = 0;
2370
2375
  _a.label = 1;
2371
2376
  case 1:
2372
- if (!(i < 5000 / 200 && !externallySelectedItemsAreInSync.current)) return [3 /*break*/, 4];
2377
+ if (!(i < 5000 / 200 && !externallySelectedItemsAreInSync)) return [3 /*break*/, 4];
2373
2378
  return [4 /*yield*/, wait$2(200)];
2374
2379
  case 2:
2375
2380
  _a.sent();
@@ -2380,7 +2385,7 @@ var GridContextProvider = function (props) {
2380
2385
  case 4: return [2 /*return*/];
2381
2386
  }
2382
2387
  });
2383
- }); }, []);
2388
+ }); }, [externallySelectedItemsAreInSync]);
2384
2389
  return (jsxRuntime.jsx(GridContext.Provider, __assign({ value: {
2385
2390
  gridReady: gridReady,
2386
2391
  setGridApi: setGridApi,
@@ -2391,6 +2396,7 @@ var GridContextProvider = function (props) {
2391
2396
  selectRowsWithFlashDiff: selectRowsWithFlashDiff,
2392
2397
  flashRows: flashRows,
2393
2398
  flashRowsDiff: flashRowsDiff,
2399
+ focusByRowById: focusByRowById,
2394
2400
  getSelectedRows: getSelectedRows,
2395
2401
  getSelectedRowIds: getSelectedRowIds,
2396
2402
  editingCells: editingCells,
@@ -2400,6 +2406,7 @@ var GridContextProvider = function (props) {
2400
2406
  stopEditing: stopEditing,
2401
2407
  updatingCells: updatingCells,
2402
2408
  redrawRows: redrawRows,
2409
+ externallySelectedItemsAreInSync: externallySelectedItemsAreInSync,
2403
2410
  setExternallySelectedItemsAreInSync: setExternallySelectedItemsAreInSync,
2404
2411
  waitForExternallySelectedItemsToBeInSync: waitForExternallySelectedItemsToBeInSync
2405
2412
  } }, { children: props.children })));
@@ -2731,7 +2738,7 @@ var GridHeaderSelect = function (_a) {
2731
2738
  */
2732
2739
  var Grid = function (params) {
2733
2740
  var _a, _b, _c;
2734
- var _d = React.useContext(GridContext), gridReady = _d.gridReady, setGridApi = _d.setGridApi, setQuickFilter = _d.setQuickFilter, ensureRowVisible = _d.ensureRowVisible, selectRowsById = _d.selectRowsById, ensureSelectedRowIsVisible = _d.ensureSelectedRowIsVisible, sizeColumnsToFit = _d.sizeColumnsToFit, setExternallySelectedItemsAreInSync = _d.setExternallySelectedItemsAreInSync;
2741
+ var _d = React.useContext(GridContext), gridReady = _d.gridReady, setGridApi = _d.setGridApi, setQuickFilter = _d.setQuickFilter, ensureRowVisible = _d.ensureRowVisible, selectRowsById = _d.selectRowsById, focusByRowById = _d.focusByRowById, ensureSelectedRowIsVisible = _d.ensureSelectedRowIsVisible, sizeColumnsToFit = _d.sizeColumnsToFit, externallySelectedItemsAreInSync = _d.externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync = _d.setExternallySelectedItemsAreInSync;
2735
2742
  var checkUpdating = React.useContext(GridUpdatingContext).checkUpdating;
2736
2743
  var _e = React.useState(""), internalQuickFilter = _e[0], setInternalQuickFilter = _e[1];
2737
2744
  var lastSelectedIds = React.useRef([]);
@@ -2742,13 +2749,27 @@ var Grid = function (params) {
2742
2749
  */
2743
2750
  var hasSelectedFirstItem = React.useRef(false);
2744
2751
  React.useEffect(function () {
2745
- if (!gridReady || !params.autoSelectFirstRow || hasSelectedFirstItem.current || !params.rowData)
2752
+ if (!gridReady || hasSelectedFirstItem.current || !params.rowData || !externallySelectedItemsAreInSync)
2746
2753
  return;
2747
2754
  hasSelectedFirstItem.current = true;
2748
2755
  if (isNotEmpty(params.rowData) && lodashEs.isEmpty(params.externalSelectedItems)) {
2749
- selectRowsById([params.rowData[0].id]);
2756
+ var firstRowId = params.rowData[0].id;
2757
+ if (params.autoSelectFirstRow) {
2758
+ selectRowsById([firstRowId]);
2759
+ }
2760
+ else {
2761
+ focusByRowById(firstRowId);
2762
+ }
2750
2763
  }
2751
- }, [gridReady, params, params.autoSelectFirstRow, params.rowData, selectRowsById]);
2764
+ }, [
2765
+ externallySelectedItemsAreInSync,
2766
+ focusByRowById,
2767
+ gridReady,
2768
+ params,
2769
+ params.autoSelectFirstRow,
2770
+ params.rowData,
2771
+ selectRowsById,
2772
+ ]);
2752
2773
  /**
2753
2774
  * AgGrid checkbox select does not pass clicks within cell but not on the checkbox to checkbox.
2754
2775
  * This passes the event to the checkbox when you click anywhere in the cell.
@@ -2843,7 +2864,7 @@ var Grid = function (params) {
2843
2864
  checkboxSelection: true,
2844
2865
  headerComponent: GridHeaderSelect,
2845
2866
  suppressHeaderKeyboardEvent: function (e) {
2846
- if (e.event.key === "Enter" && !e.event.repeat) {
2867
+ if ((e.event.key === "Enter" || e.event.key === " ") && !e.event.repeat) {
2847
2868
  var selectedNodeCount = e.api.getSelectedRows().length;
2848
2869
  if (selectedNodeCount == 0) {
2849
2870
  e.api.selectAllFiltered();
@@ -2932,16 +2953,22 @@ var Grid = function (params) {
2932
2953
  }, [columnDefs === null || columnDefs === void 0 ? void 0 : columnDefs.length, sizeColumnsToFit]);
2933
2954
  return (jsxRuntime.jsxs("div", __assign({ "data-testid": params["data-testid"], className: clsx("Grid-container", "ag-theme-alpine", staleGrid && "Grid-sortIsStale", gridReady && params.rowData && "Grid-ready") }, { children: [params.quickFilter && (jsxRuntime.jsx("div", __assign({ className: "Grid-quickFilter" }, { children: jsxRuntime.jsx("input", { "aria-label": "Search", className: "lui-margin-top-xxs lui-margin-bottom-xxs Grid-quickFilterBox", type: "text", placeholder: (_a = params.quickFilterPlaceholder) !== null && _a !== void 0 ? _a : "Search...", value: internalQuickFilter, onChange: function (event) {
2934
2955
  setInternalQuickFilter(event.target.value);
2935
- } }) }))), jsxRuntime.jsx(agGridReact.AgGridReact, { animateRows: params.animateRows, rowClassRules: params.rowClassRules, defaultColDef: params.defaultColDef, getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: (_b = params.rowSelection) !== null && _b !== void 0 ? _b : "multiple", suppressBrowserResizeObserver: true, colResizeDefault: "shift", onFirstDataRendered: sizeColumnsToFit, onGridSizeChanged: sizeColumnsToFit, suppressClickEdit: true, onCellKeyPress: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, onCellEditingStopped: onCellEditingStopped, domLayout: params.domLayout, columnDefs: columnDefs, rowData: params.rowData, noRowsOverlayComponent: noRowsOverlayComponent, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: (_c = params.postSortRows) !== null && _c !== void 0 ? _c : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection })] })));
2956
+ } }) }))), jsxRuntime.jsx(agGridReact.AgGridReact, { animateRows: params.animateRows, rowClassRules: params.rowClassRules, defaultColDef: params.defaultColDef, getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: (_b = params.rowSelection) !== null && _b !== void 0 ? _b : "multiple", suppressBrowserResizeObserver: true, colResizeDefault: "shift", onFirstDataRendered: sizeColumnsToFit, onGridSizeChanged: sizeColumnsToFit, suppressClickEdit: true, onCellKeyPress: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, onCellEditingStopped: onCellEditingStopped, domLayout: params.domLayout, columnDefs: columnDefs, rowData: params.rowData, noRowsOverlayComponent: noRowsOverlayComponent, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: (_c = params.postSortRows) !== null && _c !== void 0 ? _c : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved })] })));
2936
2957
  };
2937
2958
 
2938
2959
  var GridCellMultiSelectClassRules = {
2939
- "ag-selected-for-edit": function (_a) {
2940
- var api = _a.api, node = _a.node, colDef = _a.colDef;
2941
- return api
2942
- .getSelectedNodes()
2943
- .map(function (row) { return row.id; })
2944
- .includes(node.id) && api.getEditingCells().some(function (cell) { return cell.column.getColDef() === colDef; });
2960
+ "ag-selected-for-edit": function (params) {
2961
+ var _a;
2962
+ var api = params.api, node = params.node, colDef = params.colDef;
2963
+ var cep = colDef.cellEditorSelector
2964
+ ? (_a = colDef.cellEditorSelector(params)) === null || _a === void 0 ? void 0 : _a.params
2965
+ : colDef.cellEditorParams;
2966
+ return ((cep === null || cep === void 0 ? void 0 : cep.multiEdit) &&
2967
+ api
2968
+ .getSelectedNodes()
2969
+ .map(function (row) { return row.id; })
2970
+ .includes(node.id) &&
2971
+ api.getEditingCells().some(function (cell) { return cell.column.getColDef() === colDef; }));
2945
2972
  }
2946
2973
  };
2947
2974
 
@@ -2963,27 +2990,28 @@ var GridCellRenderer = function (props) {
2963
2990
  var infoText = infoFn ? infoFn(props) : undefined;
2964
2991
  return (jsxRuntime.jsx(GridLoadableCell, __assign({ isLoading: checkUpdating((_b = (_a = colDef.field) !== null && _a !== void 0 ? _a : colDef.colId) !== null && _b !== void 0 ? _b : "", props.data.id) }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [typeof warningText === "string" && jsxRuntime.jsx(GridIcon, { icon: "ic_warning", title: warningText }), typeof infoText === "string" && jsxRuntime.jsx(GridIcon, { icon: "ic_info", title: infoText }), jsxRuntime.jsx("div", __assign({ style: { display: "flex", flex: 1, overflow: "hidden" } }, { children: ((_c = colDef === null || colDef === void 0 ? void 0 : colDef.cellRendererParams) === null || _c === void 0 ? void 0 : _c.originalCellRenderer) ? (jsxRuntime.jsx(colDef.cellRendererParams.originalCellRenderer, __assign({}, props))) : (jsxRuntime.jsx("span", __assign({ title: props.valueFormatted }, { children: props.valueFormatted }))) })), fnOrVar((_d = props.colDef) === null || _d === void 0 ? void 0 : _d.editable, props) && (rendererParams === null || rendererParams === void 0 ? void 0 : rendererParams.rightHoverElement) && (jsxRuntime.jsx("div", __assign({ style: { display: "flex", alignItems: "center" } }, { children: rendererParams === null || rendererParams === void 0 ? void 0 : rendererParams.rightHoverElement })))] }) })));
2965
2992
  };
2993
+ var suppressCellKeyboardEvents = function (e) {
2994
+ var _a, _b, _c, _d;
2995
+ var shortcutKeys = (_b = (_a = e.colDef.cellRendererParams) === null || _a === void 0 ? void 0 : _a.shortcutKeys) !== null && _b !== void 0 ? _b : {};
2996
+ var exec = shortcutKeys[e.event.key];
2997
+ if (!e.editing && !e.event.repeat && e.event.type === "keypress" && exec) {
2998
+ var editable = fnOrVar((_c = e.colDef) === null || _c === void 0 ? void 0 : _c.editable, e);
2999
+ return editable ? (_d = exec(e)) !== null && _d !== void 0 ? _d : true : true;
3000
+ }
3001
+ // It's important that aggrid doesn't trigger edit on enter
3002
+ // as the incorrect selected rows will be returned
3003
+ return !["ArrowLeft", "ArrowRight", "ArrowDown", "ArrowUp", "Tab", " ", "Home", "End", "PageUp", "PageDown"].includes(e.event.key);
3004
+ };
2966
3005
  /*
2967
3006
  * All cells should use this
2968
3007
  */
2969
3008
  var GridCell = function (props, custom) {
2970
3009
  var _a;
2971
3010
  return __assign(__assign(__assign(__assign(__assign(__assign({ colId: props.field, sortable: !!((props === null || props === void 0 ? void 0 : props.field) || (props === null || props === void 0 ? void 0 : props.valueGetter)), resizable: true }, ((custom === null || custom === void 0 ? void 0 : custom.editor) && {
2972
- cellClassRules: custom.multiEdit ? GridCellMultiSelectClassRules : undefined,
3011
+ cellClassRules: GridCellMultiSelectClassRules,
2973
3012
  editable: (_a = props.editable) !== null && _a !== void 0 ? _a : true,
2974
- cellEditor: GenericCellEditorComponentWrapper(custom)
2975
- })), { suppressKeyboardEvent: function (e) {
2976
- var _a, _b, _c, _d;
2977
- var shortcutKeys = (_b = (_a = e.colDef.cellRendererParams) === null || _a === void 0 ? void 0 : _a.shortcutKeys) !== null && _b !== void 0 ? _b : {};
2978
- var exec = shortcutKeys[e.event.key];
2979
- if (!e.editing && !e.event.repeat && e.event.type === "keypress" && exec) {
2980
- var editable = fnOrVar((_c = e.colDef) === null || _c === void 0 ? void 0 : _c.editable, e);
2981
- return editable ? (_d = exec(e)) !== null && _d !== void 0 ? _d : true : true;
2982
- }
2983
- // It's important that aggrid doesn't trigger edit on enter
2984
- // as the incorrect selected rows will be returned
2985
- return !["ArrowLeft", "ArrowRight", "ArrowDown", "ArrowUp", "Tab", " "].includes(e.event.key);
2986
- } }), ((custom === null || custom === void 0 ? void 0 : custom.editorParams) && {
3013
+ cellEditor: GenericCellEditorComponentWrapper(custom === null || custom === void 0 ? void 0 : custom.editor)
3014
+ })), { suppressKeyboardEvent: suppressCellKeyboardEvents }), ((custom === null || custom === void 0 ? void 0 : custom.editorParams) && {
2987
3015
  cellEditorParams: __assign(__assign({}, custom.editorParams), { multiEdit: custom.multiEdit })
2988
3016
  })), {
2989
3017
  // Default value formatter, otherwise react freaks out on objects
@@ -2997,12 +3025,13 @@ var GridCell = function (props, custom) {
2997
3025
  return JSON.stringify(params.value);
2998
3026
  } }), props), { cellRenderer: GridCellRenderer, cellRendererParams: __assign({ originalCellRenderer: props.cellRenderer }, props.cellRendererParams) });
2999
3027
  };
3000
- var GenericCellEditorComponentWrapper = function (custom) {
3028
+ var GenericCellEditorComponentWrapper = function (editor) {
3029
+ var obj = { editor: editor };
3001
3030
  return React.forwardRef(function GenericCellEditorComponentFr(cellEditorParams, _) {
3002
3031
  var valueFormatted = cellEditorParams.formatValue
3003
3032
  ? cellEditorParams.formatValue(cellEditorParams.value)
3004
3033
  : "Missing formatter";
3005
- return (jsxRuntime.jsxs(GridPopoverContextProvider, __assign({ props: cellEditorParams }, { children: [jsxRuntime.jsx(cellEditorParams.colDef.cellRenderer, __assign({}, cellEditorParams, { valueFormatted: valueFormatted }, cellEditorParams.colDef.cellRendererParams)), (custom === null || custom === void 0 ? void 0 : custom.editor) && jsxRuntime.jsx(custom.editor, __assign({}, cellEditorParams))] })));
3034
+ return (jsxRuntime.jsxs(GridPopoverContextProvider, __assign({ props: cellEditorParams }, { children: [jsxRuntime.jsx(cellEditorParams.colDef.cellRenderer, __assign({}, cellEditorParams, { valueFormatted: valueFormatted }, cellEditorParams.colDef.cellRendererParams)), obj.editor && jsxRuntime.jsx(obj.editor, __assign({}, cellEditorParams))] })));
3006
3035
  });
3007
3036
  };
3008
3037
 
@@ -24842,6 +24871,7 @@ exports.queryRow = queryRow;
24842
24871
  exports.selectCell = selectCell;
24843
24872
  exports.selectRow = selectRow;
24844
24873
  exports.stringByteLengthIsInvalid = stringByteLengthIsInvalid;
24874
+ exports.suppressCellKeyboardEvents = suppressCellKeyboardEvents;
24845
24875
  exports.typeOtherInput = typeOtherInput;
24846
24876
  exports.typeOtherTextArea = typeOtherTextArea;
24847
24877
  exports.useDeferredPromise = useDeferredPromise;