ag-grid-community 34.0.0 → 34.0.1

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.
@@ -7953,8 +7953,13 @@ function _addColumnDefaultAndTypes(beans, colDef, colId, isAutoCol) {
7953
7953
  if (columnType) {
7954
7954
  assignColumnTypes(beans, columnType, res);
7955
7955
  }
7956
+ const cellDataType = res.cellDataType;
7956
7957
  // merge properties from column definitions
7957
7958
  (0, object_1._mergeDeep)(res, colDef, false, true);
7959
+ if (cellDataType !== undefined) {
7960
+ // `cellDataType: true` in provided def will overwrite inferred result type otherwise
7961
+ res.cellDataType = cellDataType;
7962
+ }
7958
7963
  const autoGroupColDef = gos.get('autoGroupColumnDef');
7959
7964
  const isSortingCoupled = (0, gridOptionsUtils_1._isColumnsSortingCoupledToGroup)(gos);
7960
7965
  if (colDef.rowGroup && autoGroupColDef && isSortingCoupled) {
@@ -10836,7 +10841,7 @@ class DataTypeService extends beanStub_1.BeanStub {
10836
10841
  }
10837
10842
  postProcess(colDef) {
10838
10843
  const cellDataType = colDef.cellDataType;
10839
- if (!cellDataType) {
10844
+ if (!cellDataType || typeof cellDataType !== 'string') {
10840
10845
  return;
10841
10846
  }
10842
10847
  const { dataTypeDefinitions, beans, formatValueFuncs } = this;
@@ -16358,6 +16363,14 @@ function startEditingCell(beans, params) {
16358
16363
  rowPinned: rowPinned || null,
16359
16364
  column,
16360
16365
  };
16366
+ const rowNode = (0, positionUtils_1._getRowNode)(beans, cellPosition);
16367
+ if (!rowNode) {
16368
+ (0, logging_1._warn)(290, { rowIndex, rowPinned });
16369
+ return;
16370
+ }
16371
+ if (!column.isCellEditable(rowNode)) {
16372
+ return;
16373
+ }
16361
16374
  const notPinned = rowPinned == null;
16362
16375
  if (notPinned) {
16363
16376
  (0, scrollApi_1.ensureIndexVisible)(beans, rowIndex);
@@ -16476,6 +16489,9 @@ class EditModelService extends beanStub_1.BeanStub {
16476
16489
  return data;
16477
16490
  }
16478
16491
  getEdit(position) {
16492
+ return this._getEdit(position);
16493
+ }
16494
+ _getEdit(position) {
16479
16495
  if (this.suspendEdits) {
16480
16496
  return undefined;
16481
16497
  }
@@ -16507,13 +16523,21 @@ class EditModelService extends beanStub_1.BeanStub {
16507
16523
  }
16508
16524
  setEdit(position, edit) {
16509
16525
  (this.edits.size === 0 || !this.edits.has(position.rowNode)) && this.edits.set(position.rowNode, new Map());
16510
- this.getEditRow(position.rowNode).set(position.column, edit);
16526
+ const currentEdit = Object.assign({}, this._getEdit(position));
16527
+ Object.keys(edit).forEach((key) => {
16528
+ const value = edit[key];
16529
+ // don't copy unset keys
16530
+ if (value !== undefined) {
16531
+ currentEdit[key] = value;
16532
+ }
16533
+ });
16534
+ this.getEditRow(position.rowNode).set(position.column, currentEdit);
16511
16535
  }
16512
16536
  clearEditValue(position) {
16513
16537
  const { rowNode, column } = position;
16514
16538
  if (rowNode) {
16515
16539
  if (column) {
16516
- const edit = this.getEdit(position);
16540
+ const edit = this._getEdit(position);
16517
16541
  if (edit) {
16518
16542
  edit.newValue = edit.oldValue;
16519
16543
  edit.state = 'changed';
@@ -16552,7 +16576,7 @@ class EditModelService extends beanStub_1.BeanStub {
16552
16576
  return this.getEdit(position)?.state;
16553
16577
  }
16554
16578
  getEditPositions(editMap) {
16555
- if (this.suspendEdits || this.edits.size === 0) {
16579
+ if (this.suspendEdits || (editMap ?? this.edits).size === 0) {
16556
16580
  return [];
16557
16581
  }
16558
16582
  const positions = [];
@@ -16882,6 +16906,8 @@ const rowEditStyleFeature_1 = __webpack_require__(13536);
16882
16906
  const controllers_1 = __webpack_require__(1081);
16883
16907
  const editors_1 = __webpack_require__(78994);
16884
16908
  const refresh_1 = __webpack_require__(11539);
16909
+ // these are event sources for setDataValue that will not cause the editors to close
16910
+ const KEEP_EDITOR_SOURCES = new Set(['undo', 'redo']);
16885
16911
  // stop editing sources that we treat as UI-originated so we follow standard processing.
16886
16912
  const SOURCE_TRANSFORM = {
16887
16913
  paste: 'ui',
@@ -17066,7 +17092,12 @@ class EditService extends beanStub_1.BeanStub {
17066
17092
  // only if ESC is pressed while in the editor for this cell
17067
17093
  this.revertSingleCellEdit(cellCtrl, false);
17068
17094
  }
17069
- (0, editors_1._destroyEditors)(beans, model.getEditPositions());
17095
+ if (this.isBatchEditing()) {
17096
+ this.strategy?.cleanupEditors();
17097
+ }
17098
+ else {
17099
+ (0, editors_1._destroyEditors)(beans, model.getEditPositions());
17100
+ }
17070
17101
  event.preventDefault();
17071
17102
  this.bulkRefresh(position, edits, { suppressFlash: true });
17072
17103
  edits = model.getEditMap();
@@ -17112,6 +17143,7 @@ class EditService extends beanStub_1.BeanStub {
17112
17143
  const { beans } = this;
17113
17144
  const hasValidationErrors = this.model.getCellValidationModel().getCellValidationMap().size > 0 ||
17114
17145
  this.model.getRowValidationModel().getRowValidationMap().size > 0;
17146
+ const editsToDelete = [];
17115
17147
  for (const rowNode of rowNodes) {
17116
17148
  const editRow = edits.get(rowNode);
17117
17149
  for (const column of editRow.keys()) {
@@ -17119,22 +17151,38 @@ class EditService extends beanStub_1.BeanStub {
17119
17151
  const position = { rowNode, column };
17120
17152
  const cellCtrl = (0, controllers_1._getCellCtrl)(beans, position);
17121
17153
  const valueChanged = (0, editors_1._valuesDiffer)(editValue);
17122
- if (!cancel && valueChanged && !hasValidationErrors) {
17123
- // we suppressRefreshCell because the call to rowNode.setDataValue() results in change detection
17124
- // getting triggered, which results in all cells getting refreshed. we do not want this refresh
17125
- // to happen on this call as we want to call it explicitly below. otherwise refresh gets called twice.
17126
- // if we only did this refresh (and not the one below) then the cell would flash and not be forced.
17127
- if (cellCtrl) {
17128
- cellCtrl.suppressRefreshCell = true;
17154
+ const isCancelAfterEnd = cellCtrl?.comp?.getCellEditor()?.isCancelAfterEnd?.();
17155
+ if (!cancel && !isCancelAfterEnd && valueChanged && !hasValidationErrors) {
17156
+ const success = this.setNodeDataValue(rowNode, column, editValue.newValue);
17157
+ if (!success) {
17158
+ editsToDelete.push(position);
17129
17159
  }
17130
- rowNode.setDataValue(column, editValue.newValue, 'commit');
17131
- if (cellCtrl) {
17132
- cellCtrl.suppressRefreshCell = false;
17133
- }
17134
- cellCtrl?.refreshCell(FORCE_REFRESH);
17135
17160
  }
17161
+ cellCtrl?.refreshCell(FORCE_REFRESH);
17136
17162
  }
17137
17163
  }
17164
+ editsToDelete.forEach((position) => {
17165
+ this.model.clearEditValue(position);
17166
+ });
17167
+ }
17168
+ setNodeDataValue(rowNode, column, newValue, refreshCell) {
17169
+ const { beans } = this;
17170
+ const cellCtrl = (0, controllers_1._getCellCtrl)(beans, { rowNode, column });
17171
+ // we suppressRefreshCell because the call to rowNode.setDataValue() results in change detection
17172
+ // getting triggered, which results in all cells getting refreshed. we do not want this refresh
17173
+ // to happen on this call as we want to call it explicitly below. otherwise refresh gets called twice.
17174
+ // if we only did this refresh (and not the one below) then the cell would flash and not be forced.
17175
+ if (cellCtrl) {
17176
+ cellCtrl.suppressRefreshCell = true;
17177
+ }
17178
+ const success = rowNode.setDataValue(column, newValue, 'commit');
17179
+ if (cellCtrl) {
17180
+ cellCtrl.suppressRefreshCell = false;
17181
+ }
17182
+ if (refreshCell) {
17183
+ cellCtrl?.refreshCell(FORCE_REFRESH);
17184
+ }
17185
+ return success;
17138
17186
  }
17139
17187
  setEditMap(edits, params) {
17140
17188
  this.strategy ?? (this.strategy = this.createStrategy());
@@ -17258,8 +17306,8 @@ class EditService extends beanStub_1.BeanStub {
17258
17306
  return;
17259
17307
  }
17260
17308
  this.model.clearEditValue(cellPosition);
17261
- (0, editors_1._destroyEditors)(this.beans, [cellPosition]);
17262
- (0, editors_1._setupEditor)(this.beans, cellPosition);
17309
+ (0, editors_1._destroyEditors)(this.beans, [cellPosition], { silent: true });
17310
+ (0, editors_1._setupEditor)(this.beans, cellPosition, { silent: true });
17263
17311
  (0, editors_1._populateModelValidationErrors)(this.beans);
17264
17312
  cellCtrl?.refreshCell(FORCE_REFRESH);
17265
17313
  // refresh the styles directly rather than through refreshRow as that causes the group cell renderer to
@@ -17351,6 +17399,12 @@ class EditService extends beanStub_1.BeanStub {
17351
17399
  const { beans } = this;
17352
17400
  this.strategy ?? (this.strategy = this.createStrategy());
17353
17401
  const source = this.isBatchEditing() ? 'ui' : 'api';
17402
+ if (!eventSource || KEEP_EDITOR_SOURCES.has(eventSource)) {
17403
+ // editApi or undoRedoApi apply change without involving the editor
17404
+ (0, editors_1._syncFromEditor)(beans, position, newValue, eventSource);
17405
+ // a truthy return here indicates the operation succeeded, and if invoked from rowNode.setDataValue, will not result in a cell value change event
17406
+ return this.setNodeDataValue(position.rowNode, position.column, newValue, false);
17407
+ }
17354
17408
  const existing = this.model.getEdit(position);
17355
17409
  if (existing) {
17356
17410
  if (existing.newValue === newValue) {
@@ -17535,6 +17589,9 @@ class EditService extends beanStub_1.BeanStub {
17535
17589
  const label = translate('ariaPendingChange', 'Pending Change');
17536
17590
  this.beans.ariaAnnounce?.announceValue(label, 'pendingChange');
17537
17591
  }
17592
+ allowedFocusTargetOnValidation(cellPosition) {
17593
+ return (0, controllers_1._getCellCtrl)(this.beans, cellPosition);
17594
+ }
17538
17595
  }
17539
17596
  exports.EditService = EditService;
17540
17597
 
@@ -17575,9 +17632,6 @@ class BaseEditStrategy extends beanStub_1.BeanStub {
17575
17632
  const isFocusCleared = event.type === 'cellFocusCleared';
17576
17633
  // check if any editors open
17577
17634
  if (editSvc.isEditing(undefined, { withOpenEditor: true })) {
17578
- if (cellCtrl && !isFocusCleared && editSvc.checkNavWithValidation(cellCtrl, event) === 'block-stop') {
17579
- return;
17580
- }
17581
17635
  // if focus is clearing, we should stop editing
17582
17636
  // or cancel the editing if `block` and `hasErrors`
17583
17637
  const { column, rowIndex, rowPinned } = event;
@@ -17833,6 +17887,7 @@ class FullRowEditStrategy extends baseEditStrategy_1.BaseEditStrategy {
17833
17887
  constructor() {
17834
17888
  super(...arguments);
17835
17889
  this.beanName = 'fullRow';
17890
+ this.startedRows = [];
17836
17891
  }
17837
17892
  isCellEditable(position, source = 'ui') {
17838
17893
  const editable = super.isCellEditable(position, source);
@@ -17875,9 +17930,8 @@ class FullRowEditStrategy extends baseEditStrategy_1.BaseEditStrategy {
17875
17930
  if (this.rowNode !== rowNode) {
17876
17931
  super.cleanupEditors(position);
17877
17932
  }
17878
- if (!this.model.hasEdits({ rowNode })) {
17879
- this.dispatchRowEvent({ rowNode }, 'rowEditingStarted');
17880
- }
17933
+ this.dispatchRowEvent({ rowNode }, 'rowEditingStarted');
17934
+ this.startedRows.push(rowNode);
17881
17935
  const columns = this.beans.visibleCols.allCols;
17882
17936
  const cells = [];
17883
17937
  columns.forEach((column) => {
@@ -17916,13 +17970,20 @@ class FullRowEditStrategy extends baseEditStrategy_1.BaseEditStrategy {
17916
17970
  if (rowNode && !this.model.hasRowEdits(rowNode)) {
17917
17971
  return false;
17918
17972
  }
17919
- const rowEdits = this.model.getEditRow(rowNode);
17920
- let hadRowEdits = false;
17921
- for (const [, edit] of rowEdits) {
17922
- if ((0, editors_1._valuesDiffer)(edit)) {
17923
- hadRowEdits = true;
17924
- break;
17925
- }
17973
+ const changedRows = [];
17974
+ if (!cancel) {
17975
+ this.model.getEditMap().forEach((rowEdits, rowNode) => {
17976
+ if (!rowEdits || rowEdits.size === 0) {
17977
+ return;
17978
+ }
17979
+ for (const edit of rowEdits.values()) {
17980
+ if ((0, editors_1._valuesDiffer)(edit)) {
17981
+ changedRows.push(rowNode);
17982
+ // early return, we only need to know if there are any edits
17983
+ break;
17984
+ }
17985
+ }
17986
+ });
17926
17987
  }
17927
17988
  // rerun validation, new values might have triggered row validations
17928
17989
  (0, editors_1._populateModelValidationErrors)(this.beans);
@@ -17930,12 +17991,8 @@ class FullRowEditStrategy extends baseEditStrategy_1.BaseEditStrategy {
17930
17991
  return false;
17931
17992
  }
17932
17993
  super.stop(cancel);
17933
- if (rowNode) {
17934
- if (hadRowEdits) {
17935
- this.dispatchRowEvent({ rowNode }, 'rowValueChanged');
17936
- }
17937
- this.dispatchRowEvent({ rowNode }, 'rowEditingStopped');
17938
- }
17994
+ changedRows.forEach((rowNode) => this.dispatchRowEvent({ rowNode }, 'rowValueChanged'));
17995
+ this.cleanupEditors({ rowNode }, true);
17939
17996
  this.rowNode = undefined;
17940
17997
  return true;
17941
17998
  }
@@ -17945,20 +18002,18 @@ class FullRowEditStrategy extends baseEditStrategy_1.BaseEditStrategy {
17945
18002
  if (prev?.rowIndex === rowIndex || event.sourceEvent instanceof KeyboardEvent) {
17946
18003
  return;
17947
18004
  }
17948
- if (this.model.getRowValidationModel().getRowValidationMap().size > 0) {
18005
+ const prevCell = (0, controllers_1._getCellCtrl)(this.beans, prev);
18006
+ if (prevCell &&
18007
+ (this.model.getCellValidationModel().getCellValidation(prevCell) ||
18008
+ this.model.getRowValidationModel().getRowValidation(prevCell))) {
17949
18009
  return;
17950
18010
  }
17951
18011
  super.onCellFocusChanged(event);
17952
- const previous = event['previousParams'];
17953
- if (previous) {
17954
- (0, controllers_1._getRowCtrl)(this.beans, previous)?.refreshRow({ suppressFlash: true, force: true });
17955
- }
17956
18012
  }
17957
- cleanupEditors({ rowNode } = {}, includeEditing) {
17958
- super.cleanupEditors({ rowNode }, includeEditing);
17959
- if (rowNode) {
17960
- this.dispatchRowEvent({ rowNode: this.rowNode }, 'rowEditingStopped');
17961
- }
18013
+ cleanupEditors(position = {}, includeEditing) {
18014
+ super.cleanupEditors(position, includeEditing);
18015
+ this.startedRows.forEach((rowNode) => this.dispatchRowEvent({ rowNode }, 'rowEditingStopped'));
18016
+ this.startedRows.length = 0;
17962
18017
  }
17963
18018
  // returns null if no navigation should be performed
17964
18019
  moveToNextEditingCell(prevCell, backwards, event, source = 'ui') {
@@ -17989,38 +18044,19 @@ class FullRowEditStrategy extends baseEditStrategy_1.BaseEditStrategy {
17989
18044
  return null;
17990
18045
  }
17991
18046
  if (nextCell == null) {
17992
- return preventNavigation;
18047
+ return false;
17993
18048
  }
17994
18049
  const nextPos = nextCell.cellPosition;
17995
18050
  const prevEditable = prevCell.isCellEditable();
17996
18051
  const nextEditable = nextCell.isCellEditable();
17997
18052
  const rowsMatch = nextPos && prevPos.rowIndex === nextPos.rowIndex && prevPos.rowPinned === nextPos.rowPinned;
17998
- if (!rowsMatch) {
17999
- // run validation to gather row-level validation errors
18000
- (0, editors_1._populateModelValidationErrors)(this.beans);
18001
- if (this.model.getRowValidationModel().getRowValidationMap().size > 0) {
18002
- // if there was a previous row validation error, we need to check if that's still the case
18003
- if (this.editSvc.checkNavWithValidation(prevCell, event) === 'block-stop') {
18004
- return true;
18005
- }
18006
- }
18007
- else {
18008
- const rowPreventNavigation = this.editSvc.checkNavWithValidation(prevCell, event) === 'block-stop';
18009
- if (rowPreventNavigation) {
18010
- return true;
18011
- }
18012
- }
18013
- if (preventNavigation && this.model.getRowValidationModel().getRowValidation(prevCell)) {
18014
- return true;
18015
- }
18016
- }
18017
18053
  if (prevEditable) {
18018
18054
  this.setFocusOutOnEditor(prevCell);
18019
18055
  }
18020
18056
  if (nextEditable && !preventNavigation) {
18021
18057
  if (!nextCell.comp?.getCellEditor()) {
18022
18058
  // editor missing because it was outside the viewport during creating phase, attempt to create it now
18023
- (0, editors_1._setupEditor)(this.beans, nextCell, undefined, event, true);
18059
+ (0, editors_1._setupEditor)(this.beans, nextCell, { event, cellStartedEdit: true });
18024
18060
  }
18025
18061
  this.setFocusInOnEditor(nextCell);
18026
18062
  nextCell.focusCell(false, event);
@@ -18029,7 +18065,7 @@ class FullRowEditStrategy extends baseEditStrategy_1.BaseEditStrategy {
18029
18065
  nextCell.focusCell(true, event);
18030
18066
  }
18031
18067
  if (!rowsMatch && !preventNavigation) {
18032
- super.cleanupEditors(nextCell, true);
18068
+ this.cleanupEditors(nextCell, true);
18033
18069
  this.editSvc.startEditing(nextCell, { startedEdit: true, event, source, ignoreEventKey: true });
18034
18070
  }
18035
18071
  prevCell.rowCtrl?.refreshRow({ suppressFlash: true, force: true });
@@ -18038,6 +18074,7 @@ class FullRowEditStrategy extends baseEditStrategy_1.BaseEditStrategy {
18038
18074
  destroy() {
18039
18075
  super.destroy();
18040
18076
  this.rowNode = undefined;
18077
+ this.startedRows.length = 0;
18041
18078
  }
18042
18079
  }
18043
18080
  exports.FullRowEditStrategy = FullRowEditStrategy;
@@ -18125,7 +18162,7 @@ class SingleCellEditStrategy extends baseEditStrategy_1.BaseEditStrategy {
18125
18162
  // undesirable so we suspend the model while we find the next cell.
18126
18163
  this.model.suspend(true);
18127
18164
  }
18128
- else {
18165
+ if (!preventNavigation) {
18129
18166
  // before we stop editing, we need to focus the cell element
18130
18167
  // so the grid doesn't detect that focus has left the grid
18131
18168
  prevCell.eGui.focus();
@@ -18156,7 +18193,7 @@ class SingleCellEditStrategy extends baseEditStrategy_1.BaseEditStrategy {
18156
18193
  return null;
18157
18194
  }
18158
18195
  if (nextCell == null) {
18159
- return preventNavigation;
18196
+ return false;
18160
18197
  }
18161
18198
  const nextPos = nextCell.cellPosition;
18162
18199
  const prevEditable = prevCell.isCellEditable();
@@ -18165,23 +18202,14 @@ class SingleCellEditStrategy extends baseEditStrategy_1.BaseEditStrategy {
18165
18202
  if (!rowsMatch) {
18166
18203
  // run validation to gather row-level validation errors
18167
18204
  (0, editors_1._populateModelValidationErrors)(this.beans);
18168
- if (this.model.getRowValidationModel().getRowValidationMap().size > 0) {
18169
- // if there was a previous row validation error, we need to check if that's still the case
18170
- if (this.editSvc.checkNavWithValidation(prevCell, event) === 'block-stop') {
18171
- return true;
18172
- }
18173
- }
18174
- else {
18205
+ if ((this.model.getRowValidationModel().getRowValidationMap().size ?? 0) === 0) {
18175
18206
  const rowPreventNavigation = this.editSvc.checkNavWithValidation(prevCell, event) === 'block-stop';
18176
18207
  if (rowPreventNavigation) {
18177
18208
  return true;
18178
18209
  }
18179
18210
  }
18180
- if (preventNavigation && this.model.getRowValidationModel().getRowValidation(prevCell)) {
18181
- return true;
18182
- }
18183
18211
  }
18184
- if (prevEditable) {
18212
+ if (prevEditable && !preventNavigation) {
18185
18213
  this.setFocusOutOnEditor(prevCell);
18186
18214
  }
18187
18215
  if (!rowsMatch && !preventNavigation) {
@@ -18193,14 +18221,11 @@ class SingleCellEditStrategy extends baseEditStrategy_1.BaseEditStrategy {
18193
18221
  nextCell.focusCell(false, event);
18194
18222
  if (!nextCell.comp?.getCellEditor()) {
18195
18223
  // editor missing because it was outside the viewport during creating phase, attempt to create it now
18196
- (0, editors_1._setupEditor)(this.beans, nextCell, undefined, event, true);
18224
+ (0, editors_1._setupEditor)(this.beans, nextCell, { event, cellStartedEdit: true });
18197
18225
  }
18198
18226
  this.setFocusInOnEditor(nextCell);
18199
18227
  }
18200
18228
  else {
18201
- if (preventNavigation && this.model.getCellValidationModel().getCellValidation(prevCell)) {
18202
- return true;
18203
- }
18204
18229
  nextCell.focusCell(true, event);
18205
18230
  }
18206
18231
  prevCell.rowCtrl?.refreshRow({ suppressFlash: true, force: true });
@@ -18394,7 +18419,14 @@ function _getRowCtrl(beans, inputs = {}) {
18394
18419
  }
18395
18420
  const { rowModel, rowRenderer } = beans;
18396
18421
  let { rowNode } = inputs;
18397
- rowNode ?? (rowNode = rowId ? (0, positionUtils_1._getRowById)(beans, rowId, rowPinned) : rowModel.getRow(rowIndex));
18422
+ if (!rowNode) {
18423
+ if (rowId) {
18424
+ rowNode = (0, positionUtils_1._getRowById)(beans, rowId, rowPinned);
18425
+ }
18426
+ else if (rowIndex != null) {
18427
+ rowNode = rowModel.getRow(rowIndex);
18428
+ }
18429
+ }
18398
18430
  return rowRenderer.getRowCtrls(rowNode ? [rowNode] : [])?.[0];
18399
18431
  }
18400
18432
  exports._getRowCtrl = _getRowCtrl;
@@ -18513,7 +18545,7 @@ const getCellEditorInstances = (beans, params = {}) => getCellEditorInstanceMap(
18513
18545
  exports.getCellEditorInstances = getCellEditorInstances;
18514
18546
  function _setupEditors(beans, editingCells, position, key, event, cellStartedEdit) {
18515
18547
  if (editingCells.length === 0 && position?.rowNode && position?.column) {
18516
- _setupEditor(beans, position, key, event, cellStartedEdit);
18548
+ _setupEditor(beans, position, { key, event, cellStartedEdit });
18517
18549
  }
18518
18550
  const { valueSvc, editSvc, editModelSvc } = beans;
18519
18551
  const { rowNode, column } = position ?? {};
@@ -18535,7 +18567,11 @@ function _setupEditors(beans, editingCells, position, key, event, cellStartedEdi
18535
18567
  continue;
18536
18568
  }
18537
18569
  const shouldStartEditing = cellStartedEdit && rowNode === curCellCtrl.rowNode && curCellCtrl.column === column;
18538
- _setupEditor(beans, { rowNode: rowNode, column: curCellCtrl.column }, shouldStartEditing ? key : null, shouldStartEditing ? event : null, shouldStartEditing);
18570
+ _setupEditor(beans, { rowNode: rowNode, column: curCellCtrl.column }, {
18571
+ key: shouldStartEditing ? key : null,
18572
+ event: shouldStartEditing ? event : null,
18573
+ cellStartedEdit: shouldStartEditing,
18574
+ });
18539
18575
  }
18540
18576
  return;
18541
18577
  }
@@ -18547,17 +18583,18 @@ function _valuesDiffer({ newValue, oldValue }) {
18547
18583
  return newValue !== oldValue;
18548
18584
  }
18549
18585
  exports._valuesDiffer = _valuesDiffer;
18550
- function _setupEditor(beans, position, key, event, cellStartedEdit) {
18586
+ function _setupEditor(beans, position, params) {
18587
+ const { key, event, cellStartedEdit, silent } = params ?? {};
18551
18588
  const cellCtrl = (0, controllers_1._getCellCtrl)(beans, position);
18552
18589
  const editorComp = cellCtrl?.comp?.getCellEditor();
18553
18590
  const editorParams = _createEditorParams(beans, position, key, cellStartedEdit);
18554
- const oldValue = beans.valueSvc.getValue(position.column, position.rowNode, undefined, 'api');
18591
+ const previousEdit = beans.editModelSvc?.getEdit(position);
18555
18592
  // if key is a single character, then we treat it as user input
18556
18593
  let newValue = key?.length === 1 ? key : editorParams.value;
18557
18594
  if (newValue === undefined) {
18558
- newValue = oldValue;
18595
+ newValue = previousEdit?.oldValue;
18559
18596
  }
18560
- beans.editModelSvc?.setEdit(position, { newValue: newValue ?? exports.UNEDITED, oldValue, state: 'editing' });
18597
+ beans.editModelSvc?.setEdit(position, { newValue: newValue ?? exports.UNEDITED, state: 'editing' });
18561
18598
  if (editorComp) {
18562
18599
  // don't reinitialise, just refresh if possible
18563
18600
  editorComp.refresh?.(editorParams);
@@ -18575,7 +18612,9 @@ function _setupEditor(beans, position, key, event, cellStartedEdit) {
18575
18612
  cellCtrl.editCompDetails = compDetails;
18576
18613
  cellCtrl.comp?.setEditDetails(compDetails, popup, popupLocation, beans.gos.get('reactiveCustomComponents'));
18577
18614
  cellCtrl?.rowCtrl?.refreshRow({ suppressFlash: true });
18578
- beans.editSvc?.dispatchCellEvent(position, null, 'cellEditingStarted');
18615
+ if (!silent) {
18616
+ beans.editSvc?.dispatchCellEvent(position, null, 'cellEditingStarted');
18617
+ }
18579
18618
  }
18580
18619
  return;
18581
18620
  }
@@ -18589,10 +18628,6 @@ function _valueFromEditor(cancel, cellComp) {
18589
18628
  if (!cellEditor) {
18590
18629
  return noValueResult;
18591
18630
  }
18592
- const userWantsToCancel = cellEditor.isCancelAfterEnd?.();
18593
- if (userWantsToCancel) {
18594
- return noValueResult;
18595
- }
18596
18631
  const validationErrors = cellEditor.getValidationErrors?.();
18597
18632
  if ((validationErrors?.length ?? 0) > 0) {
18598
18633
  return noValueResult;
@@ -18687,8 +18722,8 @@ function _syncFromEditors(beans) {
18687
18722
  });
18688
18723
  }
18689
18724
  exports._syncFromEditors = _syncFromEditors;
18690
- function _syncFromEditor(beans, position, newValue, source) {
18691
- const { editModelSvc, valueSvc, eventSvc } = beans;
18725
+ function _syncFromEditor(beans, position, newValue, _source) {
18726
+ const { editModelSvc, valueSvc } = beans;
18692
18727
  if (!editModelSvc) {
18693
18728
  return;
18694
18729
  }
@@ -18696,10 +18731,9 @@ function _syncFromEditor(beans, position, newValue, source) {
18696
18731
  if (!(rowNode && column)) {
18697
18732
  return;
18698
18733
  }
18699
- const oldValue = valueSvc.getValue(column, rowNode, undefined, 'api');
18734
+ const oldValue = editModelSvc.getEdit(position)?.oldValue ?? valueSvc.getValue(column, rowNode, undefined, 'api');
18700
18735
  const cellCtrl = (0, controllers_1._getCellCtrl)(beans, position);
18701
18736
  const hasEditor = !!cellCtrl?.comp?.getCellEditor();
18702
- const prevEditValue = editModelSvc?.getEdit(position)?.newValue;
18703
18737
  // Only handle undefined, null is used to indicate a cleared cell value
18704
18738
  if (newValue === undefined) {
18705
18739
  newValue = exports.UNEDITED;
@@ -18708,40 +18742,35 @@ function _syncFromEditor(beans, position, newValue, source) {
18708
18742
  editModelSvc.setEdit(position, { newValue, oldValue, state: hasEditor ? 'editing' : 'changed' });
18709
18743
  // re-read the value once it's been through all the formatting and parsing
18710
18744
  const { value } = valueSvc.getValueForDisplay(column, rowNode, true);
18711
- editModelSvc.getEdit(position).newValue = value;
18712
- if (prevEditValue === newValue || hasEditor) {
18745
+ newValue = value;
18746
+ // persist newly formatted value
18747
+ editModelSvc.setEdit(position, { newValue });
18748
+ if (newValue === oldValue || hasEditor) {
18713
18749
  // If the value hasn't changed or the editor is currently open, we don't need to dispatch an event
18714
18750
  return;
18715
18751
  }
18716
- const { rowIndex, rowPinned, data } = rowNode;
18717
- eventSvc.dispatchEvent({
18718
- type: 'cellEditValuesChanged',
18719
- value: newValue,
18720
- colDef: column.getColDef(),
18721
- newValue,
18722
- oldValue,
18723
- source,
18724
- column,
18725
- rowIndex,
18726
- rowPinned,
18727
- data,
18728
- node: rowNode,
18752
+ const edit = editModelSvc.getEdit(position);
18753
+ beans.editSvc?.dispatchCellEvent(position, null, 'cellValueChanged', {
18754
+ valueChanged: edit && _valuesDiffer(edit),
18755
+ newValue: edit?.newValue,
18756
+ oldValue: edit?.oldValue,
18729
18757
  });
18730
18758
  }
18731
18759
  exports._syncFromEditor = _syncFromEditor;
18732
- function _destroyEditors(beans, edits) {
18760
+ function _destroyEditors(beans, edits, params) {
18733
18761
  if (!edits) {
18734
18762
  edits = beans.editModelSvc?.getEditPositions();
18735
18763
  }
18736
- edits.forEach((cellPosition) => _destroyEditor(beans, cellPosition));
18764
+ edits.forEach((cellPosition) => _destroyEditor(beans, cellPosition, params));
18737
18765
  }
18738
18766
  exports._destroyEditors = _destroyEditors;
18739
- function _destroyEditor(beans, position) {
18767
+ function _destroyEditor(beans, position, params) {
18768
+ const { editSvc, editModelSvc } = beans;
18740
18769
  const { rowNode, column } = position;
18741
18770
  const cellCtrl = (0, controllers_1._getCellCtrl)(beans, position);
18742
18771
  if (!cellCtrl) {
18743
- if (beans.editModelSvc?.hasEdits(position) && rowNode && column) {
18744
- beans.editModelSvc?.setState(position, 'changed');
18772
+ if (editModelSvc?.hasEdits(position) && rowNode && column) {
18773
+ editModelSvc?.setState(position, 'changed');
18745
18774
  }
18746
18775
  return;
18747
18776
  }
@@ -18751,23 +18780,28 @@ function _destroyEditor(beans, position) {
18751
18780
  return;
18752
18781
  }
18753
18782
  const errorMessages = comp?.getCellEditor()?.getValidationErrors?.();
18754
- const cellValidationModel = beans.editModelSvc?.getCellValidationModel();
18783
+ const cellValidationModel = editModelSvc?.getCellValidationModel();
18755
18784
  if (errorMessages?.length) {
18756
18785
  cellValidationModel?.setCellValidation(position, { errorMessages });
18757
18786
  }
18758
18787
  else {
18759
18788
  cellValidationModel?.clearCellValidation(position);
18760
18789
  }
18761
- comp?.setEditDetails(); // passing nothing stops editing
18762
- if (beans.editModelSvc?.hasEdits(position) && rowNode && column) {
18763
- beans.editModelSvc?.setState(position, 'changed');
18790
+ const wasEditing = editModelSvc?.getEdit(position)?.state === 'editing';
18791
+ if (editModelSvc?.hasEdits(position) && rowNode && column) {
18792
+ editModelSvc?.setState(position, 'changed');
18764
18793
  }
18794
+ comp?.setEditDetails(); // passing nothing stops editing
18765
18795
  comp?.refreshEditStyles(false, false);
18766
18796
  cellCtrl?.refreshCell({ force: true, suppressFlash: true });
18767
- const edit = beans.editModelSvc?.getEdit(position);
18768
- beans.editSvc?.dispatchCellEvent(position, null, 'cellEditingStopped', {
18769
- valueChanged: edit && _valuesDiffer(edit),
18770
- });
18797
+ const edit = editModelSvc?.getEdit(position);
18798
+ if (wasEditing && edit?.state === 'changed' && !params?.silent) {
18799
+ editSvc?.dispatchCellEvent(position, null, 'cellEditingStopped', {
18800
+ valueChanged: edit && _valuesDiffer(edit),
18801
+ newValue: edit?.newValue,
18802
+ oldValue: edit?.oldValue,
18803
+ });
18804
+ }
18771
18805
  }
18772
18806
  exports._destroyEditor = _destroyEditor;
18773
18807
  function _populateModelValidationErrors(beans) {
@@ -20364,7 +20398,7 @@ class RowNode {
20364
20398
  if (!column) {
20365
20399
  return false;
20366
20400
  }
20367
- const oldValue = valueSvc.getValueForDisplay(column, this).value;
20401
+ const oldValue = valueSvc.getValueForDisplay(column, this, undefined, undefined, 'api').value;
20368
20402
  if (gos.get('readOnlyEdit')) {
20369
20403
  const { beans: { eventSvc }, data, rowIndex, rowPinned, } = this;
20370
20404
  eventSvc.dispatchEvent({
@@ -27687,8 +27721,10 @@ class TextFilterHandler extends simpleFilterHandler_1.SimpleFilterHandler {
27687
27721
  }
27688
27722
  updateParams(params) {
27689
27723
  super.updateParams(params);
27690
- this.matcher = params.textMatcher ?? defaultMatcher;
27691
- this.formatter = params.textFormatter ?? (params.caseSensitive ? defaultFormatter : defaultLowercaseFormatter);
27724
+ const filterParams = params.filterParams;
27725
+ this.matcher = filterParams.textMatcher ?? defaultMatcher;
27726
+ this.formatter =
27727
+ filterParams.textFormatter ?? (filterParams.caseSensitive ? defaultFormatter : defaultLowercaseFormatter);
27692
27728
  }
27693
27729
  evaluateNullValue(filterType) {
27694
27730
  const filterTypesAllowNulls = ['notEqual', 'notContains', 'blank'];
@@ -45011,7 +45047,7 @@ class CellCtrl extends beanStub_1.BeanStub {
45011
45047
  }
45012
45048
  onPopupEditorClosed() {
45013
45049
  const { editSvc } = this.beans;
45014
- if (!editSvc?.isEditing(this)) {
45050
+ if (!editSvc?.isEditing(this, { withOpenEditor: true })) {
45015
45051
  return;
45016
45052
  }
45017
45053
  // note: this happens because of a click outside of the grid or if the popupEditor
@@ -45792,6 +45828,15 @@ class CellKeyboardListenerFeature extends beanStub_1.BeanStub {
45792
45828
  }
45793
45829
  onF2KeyDown(event) {
45794
45830
  const { cellCtrl, beans: { editSvc }, } = this;
45831
+ const editing = editSvc?.isEditing();
45832
+ if (editing) {
45833
+ // re-run ALL validations, F2 is used to initiate a new edit. If we have one already in progress,
45834
+ // we want to ensure it's valid before initiating a new edit cycle
45835
+ (0, editors_1._populateModelValidationErrors)(this.beans);
45836
+ if (editSvc?.checkNavWithValidation(undefined, event) === 'block-stop') {
45837
+ return;
45838
+ }
45839
+ }
45795
45840
  editSvc?.startEditing(cellCtrl, { startedEdit: true, event });
45796
45841
  }
45797
45842
  onEscapeKeyDown(event) {
@@ -61277,6 +61322,7 @@ exports.AG_GRID_ERRORS = {
61277
61322
  287: () => '`api.doFilterAction()` requires `enableFilterHandlers = true',
61278
61323
  288: () => '`api.getColumnFilterModel(key, true)` requires `enableFilterHandlers = true',
61279
61324
  289: ({ rowModelType }) => `Row Model '${rowModelType}' is not supported with Batch Editing`,
61325
+ 290: ({ rowIndex, rowPinned }) => `Row with index '${rowIndex}' and pinned state '${rowPinned}' not found`,
61280
61326
  };
61281
61327
  function getError(errorId, args) {
61282
61328
  const msgOrFunc = exports.AG_GRID_ERRORS[errorId];
@@ -63781,7 +63827,7 @@ exports.VanillaFrameworkOverrides = VanillaFrameworkOverrides;
63781
63827
  Object.defineProperty(exports, "__esModule", ({ value: true }));
63782
63828
  exports.VERSION = void 0;
63783
63829
  // DO NOT UPDATE MANUALLY: Generated from script during build time
63784
- exports.VERSION = '34.0.0';
63830
+ exports.VERSION = '34.0.1';
63785
63831
 
63786
63832
 
63787
63833
  /***/ }),