d2coreui 23.0.29 → 23.0.30

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.
@@ -1,77 +1,169 @@
1
- import { _areEqual, _exists, _includes, _isDomLayout, _last, _makeNull, _missing, _removeFromArray, _shallowCompare, AutoScrollService, BeanStub } from "ag-grid-community";
1
+ import { AutoScrollService, BeanStub, _areCellsEqual, _areEqual, _exists, _getAbsoluteRowIndex, _getCellCtrlForEventTarget, _getRowAbove, _getRowBelow, _getRowCtrlForEventTarget, _getRowNode, _getSuppressMultiRanges, _isDomLayout, _isRowBefore, _isSameRow, _isUsingNewCellSelectionAPI, _last, _makeNull, _missing, _warn, isRowNumberCol, _getRowSelectionMode, } from 'ag-grid-community';
2
+ import { DragListenerFeature } from './dragListenerFeature';
3
+ const SelectionMode = {
4
+ NORMAL: 0,
5
+ ALL_COLUMNS: 1,
6
+ };
2
7
  export class RangeSelector extends BeanStub {
3
8
  constructor() {
4
- super(...arguments);
5
- this.beanName = "RangeSelector";
9
+ super();
10
+ this.beanName = 'rangeSvc';
11
+ this.bodyScrollListener = this.onBodyScroll.bind(this);
12
+ this.cellRanges = [];
13
+ this.dragging = false;
14
+ this.intersectionRange = false;
6
15
  }
7
16
  wireBeans(beans) {
8
17
  this.rowModel = beans.rowModel;
9
- this.dragService = beans.dragService;
10
- this.columnModel = beans.columnModel;
11
- this.visibleColsService = beans.visibleColsService;
12
- this.cellNavigationService = beans.cellNavigationService;
13
- this.pinnedRowModel = beans.pinnedRowModel;
14
- this.rowPositionUtils = beans.rowPositionUtils;
15
- this.cellPositionUtils = beans.cellPositionUtils;
16
- this.ctrlsService = beans.ctrlsService;
17
- this.valueService = beans.valueService;
18
- this.eventService = beans.eventService;
19
- this.mouseEventService = beans.mouseEventService;
18
+ this.dragSvc = beans.dragSvc;
19
+ this.colModel = beans.colModel;
20
+ this.visibleCols = beans.visibleCols;
21
+ this.cellNavigation = beans.cellNavigation;
22
+ this.ctrlsSvc = beans.ctrlsSvc;
23
+ this.valueSvc = beans.valueSvc;
20
24
  this.gridApi = beans.gridApi;
21
- this.eGridDiv = beans.eGridDiv;
22
- this.focusService = beans.focusService;
23
- this.gos = beans.gos;
24
25
  }
25
26
  postConstruct() {
26
- this.cellRanges = [];
27
- this.bodyScrollListener = this.onBodyScroll.bind(this);
28
- this.dragging = false;
29
- this.eventService.addEventListener("newColumnsLoaded", () => this.removeAllCellRanges());
30
- this.eventService.addEventListener("columnPivotModeChanged", () => this.removeAllCellRanges());
31
- this.eventService.addEventListener("columnRowGroupChanged", () => this.removeAllCellRanges());
32
- this.eventService.addEventListener("columnPivotChanged", () => this.removeAllCellRanges());
33
- this.eventService.addEventListener("columnGroupOpened", this.refreshLastRangeStart.bind(this));
34
- this.eventService.addEventListener("columnMoved", this.refreshLastRangeStart.bind(this));
35
- this.eventService.addEventListener("columnPinned", this.refreshLastRangeStart.bind(this));
36
- this.eventService.addEventListener("columnVisible", this.onColumnVisibleChange.bind(this));
37
- this.ctrlsService.whenReady(this, () => {
38
- const gridBodyCon = this.ctrlsService.getGridBodyCtrl();
27
+ const onColumnsChanged = this.onColumnsChanged.bind(this);
28
+ const removeAllCellRanges = () => this.removeAllCellRanges();
29
+ const refreshLastRangeStart = this.refreshLastRangeStart.bind(this);
30
+ this.addManagedEventListeners({
31
+ newColumnsLoaded: onColumnsChanged,
32
+ columnVisible: onColumnsChanged,
33
+ columnValueChanged: onColumnsChanged,
34
+ columnPivotModeChanged: removeAllCellRanges,
35
+ columnRowGroupChanged: removeAllCellRanges,
36
+ columnPivotChanged: removeAllCellRanges,
37
+ columnGroupOpened: refreshLastRangeStart,
38
+ columnMoved: refreshLastRangeStart,
39
+ columnPinned: refreshLastRangeStart,
40
+ });
41
+ this.ctrlsSvc.whenReady(this, (p) => {
42
+ const gridBodyCtrl = p.gridBodyCtrl;
39
43
  this.autoScrollService = new AutoScrollService({
40
- scrollContainer: gridBodyCon.getBodyViewportElement(),
44
+ scrollContainer: gridBodyCtrl.eBodyViewport,
41
45
  scrollAxis: 'xy',
42
- getVerticalPosition: () => gridBodyCon.getScrollFeature().getVScrollPosition().top,
43
- setVerticalPosition: (position) => gridBodyCon.getScrollFeature().setVerticalScrollPosition(position),
44
- getHorizontalPosition: () => gridBodyCon.getScrollFeature().getHScrollPosition().left,
45
- setHorizontalPosition: (position) => gridBodyCon.getScrollFeature().setHorizontalScrollPosition(position),
46
+ getVerticalPosition: () => gridBodyCtrl.scrollFeature.getVScrollPosition().top,
47
+ setVerticalPosition: (position) => gridBodyCtrl.scrollFeature.setVerticalScrollPosition(position),
48
+ getHorizontalPosition: () => gridBodyCtrl.scrollFeature.getHScrollPosition().left,
49
+ setHorizontalPosition: (position) => gridBodyCtrl.scrollFeature.setHorizontalScrollPosition(position),
46
50
  shouldSkipVerticalScroll: () => !_isDomLayout(this.gos, 'normal'),
47
- shouldSkipHorizontalScroll: () => !gridBodyCon.getScrollFeature().isHorizontalScrollShowing()
51
+ shouldSkipHorizontalScroll: () => !gridBodyCtrl.scrollFeature.isHorizontalScrollShowing(),
48
52
  });
49
53
  });
50
- const params = {
51
- eElement: this.eGridDiv,
52
- onDragStart: this.onDragStart.bind(this),
53
- onDragStop: this.onDragStop.bind(this),
54
- onDragging: this.onDragging.bind(this)
54
+ }
55
+ onDragStart(mouseEvent) {
56
+ var _a, _b;
57
+ const gos = this.gos;
58
+ if ((_a = _getRowCtrlForEventTarget(gos, mouseEvent.target)) === null || _a === void 0 ? void 0 : _a.isSuppressMouseEvent(mouseEvent)) {
59
+ return;
60
+ }
61
+ const { ctrlKey, metaKey, shiftKey } = mouseEvent;
62
+ const isMultiKey = ctrlKey || metaKey;
63
+ const allowMulti = !_getSuppressMultiRanges(gos);
64
+ const isMultiSelect = allowMulti ? isMultiKey : false;
65
+ const extendRange = shiftKey && !!((_b = this.cellRanges) === null || _b === void 0 ? void 0 : _b.length);
66
+ if (!isMultiSelect && (!extendRange || _exists(_last(this.cellRanges).type))) {
67
+ this.removeAllCellRanges(true);
68
+ }
69
+ const startTarget = this.dragSvc.startTarget;
70
+ if (startTarget) {
71
+ this.updateValuesOnMove(startTarget);
72
+ }
73
+ if (!this.lastCellHovered) {
74
+ return;
75
+ }
76
+ this.dragging = true;
77
+ this.lastMouseEvent = mouseEvent;
78
+ this.intersectionRange = isMultiSelect && this.getCellRangeCount(this.lastCellHovered) > 1;
79
+ if (!extendRange) {
80
+ this.setNewestRangeStartCell(this.lastCellHovered);
81
+ }
82
+ if (this.cellRanges.length > 0) {
83
+ this.draggingRange = _last(this.cellRanges);
84
+ }
85
+ else {
86
+ const mouseRowPosition = {
87
+ rowIndex: this.lastCellHovered.rowIndex,
88
+ rowPinned: this.lastCellHovered.rowPinned,
89
+ };
90
+ const columns = this.getColumnsFromModel([this.lastCellHovered.column]);
91
+ if (!(columns === null || columns === void 0 ? void 0 : columns.length)) {
92
+ return;
93
+ }
94
+ this.draggingRange = {
95
+ startRow: mouseRowPosition,
96
+ endRow: mouseRowPosition,
97
+ columns,
98
+ startColumn: this.newestRangeStartCell.column,
99
+ };
100
+ this.cellRanges.push(this.draggingRange);
101
+ }
102
+ this.ctrlsSvc
103
+ .getGridBodyCtrl()
104
+ .eBodyViewport.addEventListener('scroll', this.bodyScrollListener, { passive: true });
105
+ this.dispatchChangedEvent(true, false, this.draggingRange.id);
106
+ }
107
+ onDragging(mouseEvent) {
108
+ const { dragging, lastCellHovered, newestRangeStartCell, autoScrollService, cellHasChanged } = this;
109
+ if (!dragging || !mouseEvent) {
110
+ return;
111
+ }
112
+ this.updateValuesOnMove(mouseEvent.target);
113
+ this.lastMouseEvent = mouseEvent;
114
+ const isMouseAndStartInPinned = (position) => lastCellHovered && lastCellHovered.rowPinned === position && newestRangeStartCell.rowPinned === position;
115
+ const skipVerticalScroll = isMouseAndStartInPinned('top') || isMouseAndStartInPinned('bottom');
116
+ autoScrollService.check(mouseEvent, skipVerticalScroll);
117
+ if (!cellHasChanged || !lastCellHovered) {
118
+ return;
119
+ }
120
+ const startColumn = newestRangeStartCell === null || newestRangeStartCell === void 0 ? void 0 : newestRangeStartCell.column;
121
+ const currentColumn = lastCellHovered === null || lastCellHovered === void 0 ? void 0 : lastCellHovered.column;
122
+ const columns = this.calculateColumnsBetween(startColumn, currentColumn);
123
+ if (!columns) {
124
+ return;
125
+ }
126
+ const { rowIndex, rowPinned } = lastCellHovered;
127
+ this.draggingRange.endRow = {
128
+ rowIndex,
129
+ rowPinned,
55
130
  };
56
- this.dragService.addDragSource(params);
57
- this.dragService.addDestroyFunc(() => this.dragService.removeDragSource(params));
131
+ this.draggingRange.columns = columns;
132
+ this.dispatchChangedEvent(false, false, this.draggingRange.id);
58
133
  }
59
- cellPositionEquals(cellA, cellB) {
60
- const colsMatch = cellA.column === cellB.column;
61
- const floatingMatch = cellA.rowPinned === cellB.rowPinned;
62
- const indexMatch = cellA.rowIndex === cellB.rowIndex;
63
- return colsMatch && floatingMatch && indexMatch;
134
+ onDragStop() {
135
+ if (!this.dragging) {
136
+ return;
137
+ }
138
+ const { id } = this.draggingRange;
139
+ this.autoScrollService.ensureCleared();
140
+ this.ctrlsSvc.getGridBodyCtrl().eBodyViewport.removeEventListener('scroll', this.bodyScrollListener);
141
+ this.lastMouseEvent = null;
142
+ this.dragging = false;
143
+ this.draggingRange = undefined;
144
+ this.lastCellHovered = undefined;
145
+ if (this.intersectionRange) {
146
+ this.intersectionRange = false;
147
+ this.intersectLastRange();
148
+ }
149
+ this.dispatchChangedEvent(false, true, id);
64
150
  }
65
- onColumnVisibleChange() {
151
+ onColumnsChanged() {
66
152
  this.refreshLastRangeStart();
67
- this.cellRanges.forEach(cellRange => {
153
+ const allColumns = this.visibleCols.allCols;
154
+ for (const cellRange of this.cellRanges) {
68
155
  const beforeCols = cellRange.columns;
69
- cellRange.columns = cellRange.columns.filter(col => col.isVisible());
156
+ cellRange.columns = cellRange.columns.filter((col) => col.isVisible() && allColumns.indexOf(col) !== -1);
70
157
  const colsInRangeChanged = !_areEqual(beforeCols, cellRange.columns);
71
158
  if (colsInRangeChanged) {
72
159
  this.dispatchChangedEvent(false, true, cellRange.id);
73
160
  }
74
- });
161
+ }
162
+ const countBefore = this.cellRanges.length;
163
+ this.cellRanges = this.cellRanges.filter((range) => range.columns.length > 0);
164
+ if (countBefore > this.cellRanges.length) {
165
+ this.dispatchChangedEvent(false, true);
166
+ }
75
167
  }
76
168
  refreshLastRangeStart() {
77
169
  const lastRange = _last(this.cellRanges);
@@ -85,145 +177,206 @@ export class RangeSelector extends BeanStub {
85
177
  if (!rangeColumns.length) {
86
178
  return false;
87
179
  }
88
- const allColumns = this.visibleColsService.getAllCols();
89
- const allPositions = rangeColumns.map(c => allColumns.indexOf(c)).sort((a, b) => a - b);
180
+ const allColumns = this.visibleCols.allCols;
181
+ const allPositions = rangeColumns.map((c) => allColumns.indexOf(c)).sort((a, b) => a - b);
90
182
  return _last(allPositions) - allPositions[0] + 1 === rangeColumns.length;
91
183
  }
92
184
  getRangeStartRow(cellRange) {
185
+ var _a, _b;
93
186
  if (cellRange.startRow && cellRange.endRow) {
94
- return this.rowPositionUtils.before(cellRange.startRow, cellRange.endRow) ?
95
- cellRange.startRow : cellRange.endRow;
187
+ return _isRowBefore(cellRange.startRow, cellRange.endRow) ? cellRange.startRow : cellRange.endRow;
96
188
  }
97
- const rowPinned = this.pinnedRowModel.getPinnedTopRowCount() > 0 ? 'top' : null;
189
+ const pinnedTopRowCount = (_b = (_a = this.beans.pinnedRowModel) === null || _a === void 0 ? void 0 : _a.getPinnedTopRowCount()) !== null && _b !== void 0 ? _b : 0;
190
+ const rowPinned = pinnedTopRowCount > 0 ? 'top' : null;
98
191
  return { rowIndex: 0, rowPinned };
99
192
  }
100
193
  getRangeEndRow(cellRange) {
194
+ var _a, _b;
101
195
  if (cellRange.startRow && cellRange.endRow) {
102
- return this.rowPositionUtils.before(cellRange.startRow, cellRange.endRow) ?
103
- cellRange.endRow : cellRange.startRow;
196
+ return _isRowBefore(cellRange.startRow, cellRange.endRow) ? cellRange.endRow : cellRange.startRow;
104
197
  }
105
- const pinnedBottomRowCount = this.pinnedRowModel.getPinnedBottomRowCount();
198
+ const pinnedBottomRowCount = (_b = (_a = this.beans.pinnedRowModel) === null || _a === void 0 ? void 0 : _a.getPinnedBottomRowCount()) !== null && _b !== void 0 ? _b : 0;
106
199
  const pinnedBottom = pinnedBottomRowCount > 0;
107
200
  if (pinnedBottom) {
108
201
  return {
109
202
  rowIndex: pinnedBottomRowCount - 1,
110
- rowPinned: 'bottom'
203
+ rowPinned: 'bottom',
111
204
  };
112
205
  }
113
206
  return {
114
207
  rowIndex: this.rowModel.getRowCount() - 1,
115
- rowPinned: null
208
+ rowPinned: null,
116
209
  };
117
210
  }
211
+ getRangeRowCount(cellRange) {
212
+ const beans = this.beans;
213
+ const start = this.getRangeStartRow(cellRange);
214
+ const end = this.getRangeEndRow(cellRange);
215
+ const startIndex = _getAbsoluteRowIndex(beans, start);
216
+ const endIndex = _getAbsoluteRowIndex(beans, end);
217
+ return endIndex - startIndex + 1;
218
+ }
118
219
  setRangeToCell(cell, appendRange = false) {
220
+ const { gos } = this;
221
+ const isRowNumbersEnabled = gos.get('rowNumbers');
222
+ const allColumnsRange = isRowNumberCol(cell.column);
223
+ if (isRowNumbersEnabled) {
224
+ this.setSelectionMode(allColumnsRange);
225
+ }
119
226
  const columns = this.calculateColumnsBetween(cell.column, cell.column);
120
227
  if (!columns) {
121
228
  return;
122
229
  }
123
- this.removeAllCellRanges(true);
230
+ const suppressMultiRangeSelections = _getSuppressMultiRanges(this.gos);
231
+ if (suppressMultiRangeSelections || !appendRange || _missing(this.cellRanges)) {
232
+ this.removeAllCellRanges(true);
233
+ }
124
234
  const rowForCell = {
125
235
  rowIndex: cell.rowIndex,
126
- rowPinned: cell.rowPinned
236
+ rowPinned: cell.rowPinned,
127
237
  };
128
- let cellRange;
129
- for (let i = 0; i < this.cellRanges.length; i++) {
130
- const range = this.cellRanges[i];
131
- const matches = (range.columns && range.columns.length === 1 && range.columns[0] === cell.column) &&
132
- this.rowPositionUtils.sameRow(rowForCell, range.startRow) &&
133
- this.rowPositionUtils.sameRow(rowForCell, range.endRow);
134
- if (matches) {
135
- cellRange = range;
238
+ const cellRange = {
239
+ startRow: rowForCell,
240
+ endRow: rowForCell,
241
+ columns,
242
+ startColumn: cell.column,
243
+ };
244
+ this.cellRanges.push(cellRange);
245
+ this.setNewestRangeStartCell(cell);
246
+ this.onDragStop();
247
+ this.dispatchChangedEvent(true, true);
248
+ }
249
+ getRangeLastColumn(cellRange) {
250
+ var _a;
251
+ const firstCol = cellRange.columns[0];
252
+ const lastCol = _last(cellRange.columns);
253
+ return (((_a = this.newestRangeStartCell) === null || _a === void 0 ? void 0 : _a.column) === firstCol ? lastCol : firstCol);
254
+ }
255
+ extendRangeRowCountBy(cellRange, targetCount) {
256
+ const { beans } = this;
257
+ const { startRow, endRow } = cellRange;
258
+ if (!startRow || !endRow) {
259
+ return;
260
+ }
261
+ let stepsMoved = 0;
262
+ let currentRow;
263
+ const isBottomUp = _isRowBefore(endRow, startRow);
264
+ if (isBottomUp) {
265
+ currentRow = startRow;
266
+ }
267
+ else {
268
+ currentRow = endRow;
269
+ }
270
+ const stepFn = targetCount > 0 ? _getRowBelow : _getRowAbove;
271
+ const stepCount = Math.abs(targetCount);
272
+ while (stepsMoved < stepCount) {
273
+ const nextRow = stepFn(beans, currentRow);
274
+ if (!nextRow) {
136
275
  break;
137
276
  }
277
+ currentRow = nextRow;
278
+ stepsMoved++;
279
+ }
280
+ if (stepsMoved !== stepCount) {
281
+ return;
282
+ }
283
+ const cellPosition = Object.assign(Object.assign({}, currentRow), { column: this.getRangeLastColumn(cellRange) });
284
+ this.updateRangeRowBoundary({ cellRange, boundary: isBottomUp ? 'start' : 'end', cellPosition });
285
+ }
286
+ extendRangeColumnCountBy(cellRange, delta) {
287
+ const { columns, startColumn } = cellRange;
288
+ if (delta === 0) {
289
+ return;
290
+ }
291
+ const allColumns = this.getColumnsFromModel();
292
+ if (!allColumns) {
293
+ return;
294
+ }
295
+ const lastColumn = _last(columns);
296
+ const endColumn = startColumn === columns[0] ? lastColumn : columns[0];
297
+ if (!lastColumn || !endColumn) {
298
+ return;
138
299
  }
139
- if (cellRange) {
140
- const atEndOfList = _last(this.cellRanges) === cellRange;
141
- if (!atEndOfList) {
142
- _removeFromArray(this.cellRanges, cellRange);
143
- this.cellRanges.push(cellRange);
300
+ let startIdx = allColumns.indexOf(startColumn);
301
+ const endIdx = allColumns.indexOf(endColumn);
302
+ const isRtlRange = endIdx < startIdx;
303
+ if (isRtlRange) {
304
+ startIdx = endIdx;
305
+ }
306
+ const currentLength = columns.length;
307
+ const targetLength = currentLength + delta;
308
+ if (targetLength <= 0) {
309
+ return;
310
+ }
311
+ const newColumns = [];
312
+ for (let i = startIdx; i < startIdx + targetLength; i++) {
313
+ const col = allColumns[i];
314
+ if (!col) {
315
+ break;
144
316
  }
317
+ newColumns.push(col);
145
318
  }
146
- else {
147
- cellRange = {
148
- startRow: rowForCell,
149
- endRow: rowForCell,
150
- columns: columns,
151
- startColumn: cell.column
152
- };
153
- this.cellRanges.push(cellRange);
319
+ if (newColumns.length === targetLength) {
320
+ if (isRtlRange) {
321
+ const newColumnToFocus = _last(newColumns);
322
+ cellRange.startColumn = newColumnToFocus;
323
+ this.focusCellOnNewColumn(cellRange, newColumnToFocus);
324
+ }
325
+ cellRange.columns = newColumns;
326
+ this.dispatchChangedEvent(true, true, cellRange.id);
154
327
  }
155
- this.newestRangeStartCell = cell;
156
- this.onDragStop();
157
- this.dispatchChangedEvent(true, true, cellRange.id);
158
328
  }
159
329
  extendLatestRangeToCell(cellPosition) {
160
330
  if (this.isEmpty() || !this.newestRangeStartCell) {
161
331
  return;
162
332
  }
163
333
  const cellRange = _last(this.cellRanges);
164
- this.updateRangeEnd(cellRange, cellPosition);
334
+ this.setSelectionMode(isRowNumberCol(cellPosition.column));
335
+ this.updateRangeRowBoundary({ cellRange, boundary: 'end', cellPosition });
165
336
  }
166
- updateRangeEnd(cellRange, cellPosition, silent) {
167
- silent = !!silent;
337
+ updateRangeRowBoundary(params) {
338
+ const { cellRange, boundary, cellPosition, silent = false } = params;
168
339
  const endColumn = cellPosition.column;
169
340
  const colsToAdd = this.calculateColumnsBetween(cellRange.startColumn, endColumn);
170
341
  if (!colsToAdd || this.isLastCellOfRange(cellRange, cellPosition)) {
171
342
  return;
172
343
  }
344
+ if (boundary === 'start') {
345
+ this.focusCellOnNewRow(cellRange, cellPosition);
346
+ }
173
347
  cellRange.columns = colsToAdd;
174
- cellRange.endRow = { rowIndex: cellPosition.rowIndex, rowPinned: cellPosition.rowPinned };
348
+ cellRange[boundary === 'start' ? 'startRow' : 'endRow'] = {
349
+ rowIndex: cellPosition.rowIndex,
350
+ rowPinned: cellPosition.rowPinned,
351
+ };
175
352
  if (!silent) {
176
353
  this.dispatchChangedEvent(true, true, cellRange.id);
177
354
  }
178
355
  }
179
- refreshRangeStart(cellRange) {
180
- const { startColumn, columns } = cellRange;
181
- const moveColInCellRange = (colToMove, moveToFront) => {
182
- const otherCols = cellRange.columns.filter(col => col !== colToMove);
183
- if (colToMove) {
184
- cellRange.startColumn = colToMove;
185
- cellRange.columns = moveToFront ? [colToMove, ...otherCols] : [...otherCols, colToMove];
186
- }
187
- else {
188
- cellRange.columns = otherCols;
189
- }
190
- };
191
- const { left, right } = this.getRangeEdgeColumns(cellRange);
192
- const shouldMoveLeftCol = startColumn === columns[0] && startColumn !== left;
193
- if (shouldMoveLeftCol) {
194
- moveColInCellRange(left, true);
195
- return;
196
- }
197
- const shouldMoveRightCol = startColumn === _last(columns) && startColumn === right;
198
- if (shouldMoveRightCol) {
199
- moveColInCellRange(right, false);
200
- return;
201
- }
202
- }
203
356
  getRangeEdgeColumns(cellRange) {
204
- const allColumns = this.visibleColsService.getAllCols();
357
+ const allColumns = this.visibleCols.allCols;
205
358
  const allIndices = cellRange.columns
206
- .map(c => allColumns.indexOf(c))
207
- .filter(i => i > -1)
359
+ .map((c) => allColumns.indexOf(c))
360
+ .filter((i) => i > -1)
208
361
  .sort((a, b) => a - b);
209
362
  return {
210
363
  left: allColumns[allIndices[0]],
211
- right: allColumns[_last(allIndices)]
364
+ right: allColumns[_last(allIndices)],
212
365
  };
213
366
  }
214
- extendLatestRangeInDirection(key) {
367
+ extendLatestRangeInDirection(event) {
215
368
  if (this.isEmpty() || !this.newestRangeStartCell) {
216
369
  return;
217
370
  }
371
+ const key = event.key;
372
+ const ctrlKey = event.ctrlKey || event.metaKey;
218
373
  const lastRange = _last(this.cellRanges);
219
374
  const startCell = this.newestRangeStartCell;
220
- const firstCol = lastRange.columns[0];
221
- const lastCol = _last(lastRange.columns);
222
375
  const endCellIndex = lastRange.endRow.rowIndex;
223
376
  const endCellFloating = lastRange.endRow.rowPinned;
224
- const endCellColumn = startCell.column === firstCol ? lastCol : firstCol;
377
+ const endCellColumn = this.getRangeLastColumn(lastRange);
225
378
  const endCell = { column: endCellColumn, rowIndex: endCellIndex, rowPinned: endCellFloating };
226
- const newEndCell = this.cellNavigationService.getNextCellToFocus(key, endCell);
379
+ const newEndCell = this.cellNavigation.getNextCellToFocus(key, endCell, ctrlKey);
227
380
  if (!newEndCell) {
228
381
  return;
229
382
  }
@@ -233,7 +386,7 @@ export class RangeSelector extends BeanStub {
233
386
  rowEndIndex: newEndCell.rowIndex,
234
387
  rowEndPinned: newEndCell.rowPinned,
235
388
  columnStart: startCell.column,
236
- columnEnd: newEndCell.column
389
+ columnEnd: newEndCell.column,
237
390
  });
238
391
  return newEndCell;
239
392
  }
@@ -242,56 +395,110 @@ export class RangeSelector extends BeanStub {
242
395
  this.addCellRange(params);
243
396
  }
244
397
  setCellRanges(cellRanges) {
245
- if (_shallowCompare(this.cellRanges, cellRanges)) {
398
+ if (_areEqual(this.cellRanges, cellRanges)) {
399
+ return;
400
+ }
401
+ if (!this.verifyCellRanges(this.gos)) {
246
402
  return;
247
403
  }
248
404
  this.removeAllCellRanges(true);
249
- cellRanges.forEach(newRange => {
250
- if (newRange.columns && newRange.startRow) {
251
- this.newestRangeStartCell = {
252
- rowIndex: newRange.startRow.rowIndex,
253
- rowPinned: newRange.startRow.rowPinned,
254
- column: newRange.columns[0]
255
- };
405
+ for (const cellRange of cellRanges) {
406
+ if (cellRange.columns && cellRange.startRow) {
407
+ const columns = this.getColumnsFromModel(cellRange.columns);
408
+ if (!columns || columns.length === 0) {
409
+ continue;
410
+ }
411
+ cellRange.columns = columns;
412
+ const { startRow } = cellRange;
413
+ this.setNewestRangeStartCell({
414
+ rowIndex: startRow.rowIndex,
415
+ rowPinned: startRow.rowPinned,
416
+ column: cellRange.columns[0],
417
+ });
256
418
  }
257
- this.cellRanges.push(newRange);
258
- });
419
+ this.cellRanges.push(cellRange);
420
+ }
259
421
  this.dispatchChangedEvent(false, true);
260
422
  }
261
- createCellRangeFromCellRangeParams(params) {
262
- let columns;
263
- if (params.columns) {
264
- columns = params.columns.map(c => this.columnModel.getColumnWithValidation(c)).filter(c => c);
423
+ clearCellRangeCellValues(params) {
424
+ const { beans, valueSvc, eventSvc } = this;
425
+ const { cellEventSource = 'rangeSvc', dispatchWrapperEvents, wrapperEventSource = 'deleteKey' } = params;
426
+ let { cellRanges } = params;
427
+ if (dispatchWrapperEvents) {
428
+ eventSvc.dispatchEvent({
429
+ type: 'cellSelectionDeleteStart',
430
+ source: wrapperEventSource,
431
+ });
432
+ eventSvc.dispatchEvent({
433
+ type: 'rangeDeleteStart',
434
+ source: wrapperEventSource,
435
+ });
265
436
  }
266
- else {
267
- const columnStart = this.columnModel.getColumnWithValidation(params.columnStart);
268
- const columnEnd = this.columnModel.getColumnWithValidation(params.columnEnd);
269
- if (!columnStart || !columnEnd) {
270
- return;
271
- }
272
- columns = this.calculateColumnsBetween(columnStart, columnEnd);
437
+ if (!cellRanges) {
438
+ cellRanges = this.cellRanges;
273
439
  }
274
- if (!columns) {
440
+ for (const cellRange of cellRanges) {
441
+ this.forEachRowInRange(cellRange, (rowPosition) => {
442
+ const rowNode = _getRowNode(beans, rowPosition);
443
+ if (!rowNode) {
444
+ return;
445
+ }
446
+ for (let i = 0; i < cellRange.columns.length; i++) {
447
+ const column = this.getColumnFromModel(cellRange.columns[i]);
448
+ if (!(column === null || column === void 0 ? void 0 : column.isCellEditable(rowNode))) {
449
+ continue;
450
+ }
451
+ const emptyValue = valueSvc.getDeleteValue(column, rowNode);
452
+ rowNode.setDataValue(column, emptyValue, cellEventSource);
453
+ }
454
+ });
455
+ }
456
+ if (dispatchWrapperEvents) {
457
+ eventSvc.dispatchEvent({
458
+ type: 'cellSelectionDeleteEnd',
459
+ source: wrapperEventSource,
460
+ });
461
+ eventSvc.dispatchEvent({
462
+ type: 'rangeDeleteEnd',
463
+ source: wrapperEventSource,
464
+ });
465
+ }
466
+ }
467
+ createCellRangeFromCellRangeParams(params) {
468
+ return this.createPartialCellRangeFromRangeParams(params, false);
469
+ }
470
+ createPartialCellRangeFromRangeParams(params, allowEmptyColumns) {
471
+ var _a;
472
+ const { columns: paramColumns, columnStart, columnEnd, rowStartIndex, rowStartPinned, rowEndIndex, rowEndPinned, } = params;
473
+ const columnInfo = this.getColumnsFromParams(paramColumns, columnStart, columnEnd);
474
+ if (!columnInfo || (!allowEmptyColumns && columnInfo.columns.length === 0)) {
275
475
  return;
276
476
  }
277
- const startRow = params.rowStartIndex != null ? {
278
- rowIndex: params.rowStartIndex,
279
- rowPinned: params.rowStartPinned
280
- } : undefined;
281
- const endRow = params.rowEndIndex != null ? {
282
- rowIndex: params.rowEndIndex,
283
- rowPinned: params.rowEndPinned
284
- } : undefined;
477
+ const { columns, startsOnTheRight } = columnInfo;
478
+ const startRow = this.createRowPosition(rowStartIndex, rowStartPinned);
479
+ const endRow = this.createRowPosition(rowEndIndex, rowEndPinned);
285
480
  return {
286
- startRow: startRow,
287
- endRow: endRow,
288
- columns: columns,
289
- startColumn: columns[0]
481
+ startRow,
482
+ endRow,
483
+ columns,
484
+ startColumn: (_a = this.getColumnFromModel(columnStart)) !== null && _a !== void 0 ? _a : (startsOnTheRight ? _last(columns) : columns[0]),
290
485
  };
291
486
  }
292
487
  addCellRange(params) {
488
+ const gos = this.gos;
489
+ if (!this.verifyCellRanges(gos)) {
490
+ return;
491
+ }
492
+ this.setSelectionMode(false);
293
493
  const newRange = this.createCellRangeFromCellRangeParams(params);
294
494
  if (newRange) {
495
+ if (newRange.startRow) {
496
+ this.setNewestRangeStartCell({
497
+ rowIndex: newRange.startRow.rowIndex,
498
+ rowPinned: newRange.startRow.rowPinned,
499
+ column: newRange.startColumn,
500
+ });
501
+ }
295
502
  this.cellRanges.push(newRange);
296
503
  this.dispatchChangedEvent(false, true, newRange.id);
297
504
  }
@@ -303,18 +510,52 @@ export class RangeSelector extends BeanStub {
303
510
  return this.cellRanges.length === 0;
304
511
  }
305
512
  isMoreThanOneCell() {
306
- if (this.cellRanges.length === 0) {
513
+ const len = this.cellRanges.length;
514
+ if (len === 0) {
307
515
  return false;
308
516
  }
309
- else if (this.cellRanges.length > 1) {
517
+ if (len > 1) {
310
518
  return true;
311
519
  }
312
520
  const range = this.cellRanges[0];
313
521
  const startRow = this.getRangeStartRow(range);
314
522
  const endRow = this.getRangeEndRow(range);
315
- return startRow.rowPinned !== endRow.rowPinned ||
523
+ return (startRow.rowPinned !== endRow.rowPinned ||
316
524
  startRow.rowIndex !== endRow.rowIndex ||
317
- range.columns.length !== 1;
525
+ range.columns.length !== 1);
526
+ }
527
+ areAllRangesAbleToMerge() {
528
+ const rowToColumnMap = new Map();
529
+ const len = this.cellRanges.length;
530
+ if (len <= 1) {
531
+ return true;
532
+ }
533
+ for (const range of this.cellRanges) {
534
+ this.forEachRowInRange(range, (row) => {
535
+ const rowName = `${row.rowPinned || 'normal'}_${row.rowIndex}`;
536
+ const columns = rowToColumnMap.get(rowName);
537
+ const currentRangeColIds = range.columns.map((col) => col.getId());
538
+ if (columns) {
539
+ const filteredColumns = currentRangeColIds.filter((col) => columns.indexOf(col) === -1);
540
+ columns.push(...filteredColumns);
541
+ }
542
+ else {
543
+ rowToColumnMap.set(rowName, currentRangeColIds);
544
+ }
545
+ });
546
+ }
547
+ let columnsString;
548
+ for (const val of rowToColumnMap.values()) {
549
+ const currentValString = val.sort().join();
550
+ if (columnsString === undefined) {
551
+ columnsString = currentValString;
552
+ continue;
553
+ }
554
+ if (columnsString !== currentValString) {
555
+ return false;
556
+ }
557
+ }
558
+ return true;
318
559
  }
319
560
  removeAllCellRanges(silent) {
320
561
  if (this.isEmpty()) {
@@ -326,32 +567,20 @@ export class RangeSelector extends BeanStub {
326
567
  this.dispatchChangedEvent(false, true);
327
568
  }
328
569
  }
329
- onBodyScroll() {
330
- this.onDragging(this.lastMouseEvent);
331
- }
332
570
  isCellInAnyRange(cell) {
333
571
  return this.getCellRangeCount(cell) > 0;
334
572
  }
335
573
  isCellInSpecificRange(cell, range) {
336
- const columnInRange = range.columns !== null && _includes(range.columns, cell.column);
574
+ var _a;
575
+ const columnInRange = (_a = range.columns) === null || _a === void 0 ? void 0 : _a.includes(cell.column);
337
576
  const rowInRange = this.isRowInRange(cell.rowIndex, cell.rowPinned, range);
338
577
  return columnInRange && rowInRange;
339
578
  }
340
- isLastCellOfRange(cellRange, cell) {
341
- const { startRow, endRow } = cellRange;
342
- const lastRow = this.rowPositionUtils.before(startRow, endRow) ? endRow : startRow;
343
- const isLastRow = cell.rowIndex === lastRow.rowIndex && cell.rowPinned === lastRow.rowPinned;
344
- const rangeFirstIndexColumn = cellRange.columns[0];
345
- const rangeLastIndexColumn = _last(cellRange.columns);
346
- const lastRangeColumn = cellRange.startColumn === rangeFirstIndexColumn ? rangeLastIndexColumn : rangeFirstIndexColumn;
347
- const isLastColumn = cell.column === lastRangeColumn;
348
- return isLastColumn && isLastRow;
349
- }
350
579
  isBottomRightCell(cellRange, cell) {
351
- const allColumns = this.visibleColsService.getAllCols();
352
- const allPositions = cellRange.columns.map(c => allColumns.indexOf(c)).sort((a, b) => a - b);
580
+ const allColumns = this.visibleCols.allCols;
581
+ const allPositions = cellRange.columns.map((c) => allColumns.indexOf(c)).sort((a, b) => a - b);
353
582
  const { startRow, endRow } = cellRange;
354
- const lastRow = this.rowPositionUtils.before(startRow, endRow) ? endRow : startRow;
583
+ const lastRow = _isRowBefore(startRow, endRow) ? endRow : startRow;
355
584
  const isRightColumn = allColumns.indexOf(cell.column) === _last(allPositions);
356
585
  const isLastRow = cell.rowIndex === lastRow.rowIndex && _makeNull(cell.rowPinned) === _makeNull(lastRow.rowPinned);
357
586
  return isRightColumn && isLastRow;
@@ -360,103 +589,214 @@ export class RangeSelector extends BeanStub {
360
589
  if (this.isEmpty()) {
361
590
  return 0;
362
591
  }
363
- return this.cellRanges.filter(cellRange => this.isCellInSpecificRange(cell, cellRange)).length;
592
+ return this.cellRanges.filter((cellRange) => this.isCellInSpecificRange(cell, cellRange)).length;
364
593
  }
365
- isRowInRange(rowIndex, floating, cellRange) {
594
+ isRowInRange(rowIndex, rowPinned, cellRange) {
366
595
  const firstRow = this.getRangeStartRow(cellRange);
367
596
  const lastRow = this.getRangeEndRow(cellRange);
368
- const thisRow = { rowIndex: rowIndex, rowPinned: floating };
597
+ const thisRow = { rowIndex, rowPinned: rowPinned || null };
369
598
  const equalsFirstRow = thisRow.rowIndex === firstRow.rowIndex && thisRow.rowPinned == firstRow.rowPinned;
370
599
  const equalsLastRow = thisRow.rowIndex === lastRow.rowIndex && thisRow.rowPinned == lastRow.rowPinned;
371
600
  if (equalsFirstRow || equalsLastRow) {
372
601
  return true;
373
602
  }
374
- const afterFirstRow = !this.rowPositionUtils.before(thisRow, firstRow);
375
- const beforeLastRow = this.rowPositionUtils.before(thisRow, lastRow);
603
+ const afterFirstRow = !_isRowBefore(thisRow, firstRow);
604
+ const beforeLastRow = _isRowBefore(thisRow, lastRow);
376
605
  return afterFirstRow && beforeLastRow;
377
606
  }
378
- getDraggingRange() {
379
- return this.draggingRange;
380
- }
381
- onDragStart(mouseEvent) {
382
- const { shiftKey } = mouseEvent;
383
- const mouseCell = this.mouseEventService.getCellPositionForEvent(mouseEvent);
384
- if (_missing(mouseCell)) {
607
+ intersectLastRange(fromMouseClick) {
608
+ if (fromMouseClick && this.dragging) {
385
609
  return;
386
610
  }
387
- if (!shiftKey || _exists(_last(this.cellRanges).type)) {
388
- this.removeAllCellRanges(true);
611
+ if (_getSuppressMultiRanges(this.gos)) {
612
+ return;
389
613
  }
390
- this.dragging = true;
391
- this.draggingCell = mouseCell;
392
- this.lastMouseEvent = mouseEvent;
393
- if (!shiftKey) {
394
- this.newestRangeStartCell = mouseCell;
614
+ if (this.isEmpty()) {
615
+ return;
395
616
  }
396
- if (this.cellRanges.length > 0) {
397
- this.draggingRange = _last(this.cellRanges);
617
+ const lastRange = _last(this.cellRanges);
618
+ const intersectionStartRow = this.getRangeStartRow(lastRange);
619
+ const intersectionEndRow = this.getRangeEndRow(lastRange);
620
+ const newRanges = [];
621
+ for (const range of this.cellRanges.slice(0, -1)) {
622
+ const startRow = this.getRangeStartRow(range);
623
+ const endRow = this.getRangeEndRow(range);
624
+ const cols = range.columns;
625
+ const intersectCols = cols.filter((col) => lastRange.columns.indexOf(col) === -1);
626
+ if (intersectCols.length === cols.length) {
627
+ newRanges.push(range);
628
+ continue;
629
+ }
630
+ if (_isRowBefore(intersectionEndRow, startRow) || _isRowBefore(endRow, intersectionStartRow)) {
631
+ newRanges.push(range);
632
+ continue;
633
+ }
634
+ const rangeCountBefore = newRanges.length;
635
+ if (_isRowBefore(startRow, intersectionStartRow)) {
636
+ const top = {
637
+ columns: [...cols],
638
+ startColumn: lastRange.startColumn,
639
+ startRow: Object.assign({}, startRow),
640
+ endRow: _getRowAbove(this.beans, intersectionStartRow),
641
+ };
642
+ newRanges.push(top);
643
+ }
644
+ if (intersectCols.length > 0) {
645
+ const middle = {
646
+ columns: intersectCols,
647
+ startColumn: intersectCols.includes(lastRange.startColumn)
648
+ ? lastRange.startColumn
649
+ : intersectCols[0],
650
+ startRow: this.rowMax([Object.assign({}, intersectionStartRow), Object.assign({}, startRow)]),
651
+ endRow: this.rowMin([Object.assign({}, intersectionEndRow), Object.assign({}, endRow)]),
652
+ };
653
+ newRanges.push(middle);
654
+ }
655
+ if (_isRowBefore(intersectionEndRow, endRow)) {
656
+ newRanges.push({
657
+ columns: [...cols],
658
+ startColumn: lastRange.startColumn,
659
+ startRow: _getRowBelow(this.beans, intersectionEndRow),
660
+ endRow: Object.assign({}, endRow),
661
+ });
662
+ }
663
+ if (newRanges.length - rangeCountBefore === 1) {
664
+ newRanges[newRanges.length - 1].id = range.id;
665
+ }
398
666
  }
399
- else {
400
- const mouseRowPosition = {
401
- rowIndex: mouseCell.rowIndex,
402
- rowPinned: mouseCell.rowPinned
403
- };
404
- this.draggingRange = {
405
- startRow: mouseRowPosition,
406
- endRow: mouseRowPosition,
407
- columns: [mouseCell.column],
408
- startColumn: this.newestRangeStartCell.column
409
- };
410
- this.cellRanges.push(this.draggingRange);
667
+ this.cellRanges = newRanges;
668
+ if (fromMouseClick) {
669
+ this.dispatchChangedEvent(false, true);
411
670
  }
412
- this.ctrlsService.getGridBodyCtrl().addScrollEventListener(this.bodyScrollListener);
413
- this.dispatchChangedEvent(true, false, this.draggingRange.id);
414
671
  }
415
- onDragging(mouseEvent) {
416
- if (!this.dragging || !mouseEvent) {
672
+ createRangeHighlightFeature(compBean, column, headerComp) {
673
+ }
674
+ setSelectionMode(allColumns) {
675
+ this.selectionMode = SelectionMode.ALL_COLUMNS;
676
+ }
677
+ refreshRangeStart(cellRange) {
678
+ const { startColumn, columns } = cellRange;
679
+ const moveColInCellRange = (colToMove, moveToFront) => {
680
+ const otherCols = cellRange.columns.filter((col) => col !== colToMove);
681
+ if (colToMove) {
682
+ cellRange.startColumn = colToMove;
683
+ cellRange.columns = moveToFront ? [colToMove, ...otherCols] : [...otherCols, colToMove];
684
+ }
685
+ else {
686
+ cellRange.columns = otherCols;
687
+ }
688
+ };
689
+ const { left, right } = this.getRangeEdgeColumns(cellRange);
690
+ const shouldMoveLeftCol = startColumn === columns[0] && startColumn !== left;
691
+ if (shouldMoveLeftCol) {
692
+ moveColInCellRange(left, true);
417
693
  return;
418
694
  }
419
- this.lastMouseEvent = mouseEvent;
420
- const cellPosition = this.mouseEventService.getCellPositionForEvent(mouseEvent);
421
- const isMouseAndStartInPinned = (position) => cellPosition && cellPosition.rowPinned === position && this.newestRangeStartCell.rowPinned === position;
422
- const skipVerticalScroll = isMouseAndStartInPinned('top') || isMouseAndStartInPinned('bottom');
423
- this.autoScrollService.check(mouseEvent, skipVerticalScroll);
424
- if (!cellPosition ||
425
- !this.draggingCell ||
426
- this.cellPositionEquals(this.draggingCell, cellPosition)) {
427
- return;
695
+ const shouldMoveRightCol = startColumn === _last(columns) && startColumn === right;
696
+ if (shouldMoveRightCol) {
697
+ moveColInCellRange(right, false);
428
698
  }
429
- const columns = this.calculateColumnsBetween(this.newestRangeStartCell.column, cellPosition.column);
430
- if (!columns) {
431
- return;
699
+ }
700
+ setNewestRangeStartCell(position) {
701
+ this.newestRangeStartCell = position;
702
+ }
703
+ getColumnsFromParams(columns, columnA, columnB) {
704
+ const noColsInfo = !columns && !columnA && !columnB;
705
+ let processedColumns;
706
+ let startsOnTheRight = false;
707
+ if (noColsInfo || columns) {
708
+ processedColumns = this.getColumnsFromModel(noColsInfo ? undefined : columns);
432
709
  }
433
- this.draggingCell = cellPosition;
434
- this.draggingRange.endRow = {
435
- rowIndex: cellPosition.rowIndex,
436
- rowPinned: cellPosition.rowPinned
437
- };
438
- this.draggingRange.columns = columns;
439
- this.dispatchChangedEvent(false, false, this.draggingRange.id);
440
- this.focusCell(cellPosition);
710
+ else if (columnA && columnB) {
711
+ processedColumns = this.calculateColumnsBetween(columnA, columnB);
712
+ if (processedColumns === null || processedColumns === void 0 ? void 0 : processedColumns.length) {
713
+ startsOnTheRight = processedColumns[0] !== this.getColumnFromModel(columnA);
714
+ }
715
+ }
716
+ return processedColumns
717
+ ? {
718
+ columns: processedColumns,
719
+ startsOnTheRight,
720
+ }
721
+ : undefined;
722
+ }
723
+ createRowPosition(rowIndex, rowPinned) {
724
+ return rowIndex != null ? { rowIndex, rowPinned } : undefined;
441
725
  }
442
- focusCell(cellPosition) {
443
- const cellFocused = this.focusService.isCellFocused(cellPosition);
444
- if (!cellFocused) {
445
- this.focusService.setFocusedCell(cellPosition.rowIndex, cellPosition.column, cellPosition.rowPinned, true);
726
+ verifyCellRanges(gos) {
727
+ const invalid = _isUsingNewCellSelectionAPI(gos) && _getSuppressMultiRanges(gos) && this.cellRanges.length > 1;
728
+ if (invalid) {
729
+ _warn(93);
446
730
  }
731
+ return !invalid;
447
732
  }
448
- onDragStop() {
449
- if (!this.dragging) {
733
+ forEachRowInRange(cellRange, callback) {
734
+ const topRow = this.getRangeStartRow(cellRange);
735
+ const bottomRow = this.getRangeEndRow(cellRange);
736
+ let currentRow = topRow;
737
+ while (currentRow) {
738
+ callback(currentRow);
739
+ if (_isSameRow(currentRow, bottomRow)) {
740
+ break;
741
+ }
742
+ currentRow = _getRowBelow(this.beans, currentRow);
743
+ }
744
+ }
745
+ onBodyScroll() {
746
+ if (this.dragging && this.lastMouseEvent) {
747
+ this.onDragging(this.lastMouseEvent);
748
+ }
749
+ }
750
+ isLastCellOfRange(cellRange, cell) {
751
+ const { startRow, endRow } = cellRange;
752
+ const lastRow = _isRowBefore(startRow, endRow) ? endRow : startRow;
753
+ const isLastRow = cell.rowIndex === lastRow.rowIndex && cell.rowPinned === lastRow.rowPinned;
754
+ const rangeFirstIndexColumn = cellRange.columns[0];
755
+ const rangeLastIndexColumn = _last(cellRange.columns);
756
+ const lastRangeColumn = cellRange.startColumn === rangeFirstIndexColumn ? rangeLastIndexColumn : rangeFirstIndexColumn;
757
+ const isLastColumn = cell.column === lastRangeColumn;
758
+ return isLastColumn && isLastRow;
759
+ }
760
+ rowMax(rows) {
761
+ let max;
762
+ for (const row of rows) {
763
+ if (max === undefined || _isRowBefore(max, row)) {
764
+ max = row;
765
+ }
766
+ }
767
+ return max;
768
+ }
769
+ rowMin(rows) {
770
+ let min;
771
+ for (const row of rows) {
772
+ if (min === undefined || _isRowBefore(row, min)) {
773
+ min = row;
774
+ }
775
+ }
776
+ return min;
777
+ }
778
+ updateValuesOnMove(eventTarget) {
779
+ var _a;
780
+ const cellCtrl = _getCellCtrlForEventTarget(this.gos, eventTarget);
781
+ const cell = cellCtrl === null || cellCtrl === void 0 ? void 0 : cellCtrl.cellPosition;
782
+ this.cellHasChanged = false;
783
+ if (!cell || (this.lastCellHovered && _areCellsEqual(cell, this.lastCellHovered))) {
450
784
  return;
451
785
  }
452
- const { id } = this.draggingRange;
453
- this.autoScrollService.ensureCleared();
454
- this.ctrlsService.getGridBodyCtrl().removeScrollEventListener(this.bodyScrollListener);
455
- this.lastMouseEvent = null;
456
- this.dragging = false;
457
- this.draggingRange = undefined;
458
- this.draggingCell = undefined;
459
- this.dispatchChangedEvent(false, true, id);
786
+ const editing = (_a = this.beans.editSvc) === null || _a === void 0 ? void 0 : _a.isEditing(cellCtrl, {
787
+ withOpenEditor: true,
788
+ });
789
+ if (editing) {
790
+ this.dragSvc.cancelDrag(eventTarget);
791
+ return;
792
+ }
793
+ if (this.lastCellHovered) {
794
+ this.cellHasChanged = true;
795
+ }
796
+ this.lastCellHovered = cell;
797
+ }
798
+ shouldSkipCurrentColumn(currentColumn) {
799
+ return isRowNumberCol(currentColumn);
460
800
  }
461
801
  dispatchChangedEvent(started, finished, id) {
462
802
  this.cellRanges.map((cellRange) => {
@@ -464,11 +804,11 @@ export class RangeSelector extends BeanStub {
464
804
  const lastRow = this.getRangeEndRow(cellRange);
465
805
  const nodesToBeSelected = [];
466
806
  while (true) {
467
- const finishedAllRows = _missing(currentRow) || !currentRow || this.rowPositionUtils.before(lastRow, currentRow);
807
+ const finishedAllRows = _missing(currentRow) || !currentRow || this.before(lastRow, currentRow);
468
808
  if (finishedAllRows || !currentRow || !cellRange.columns) {
469
809
  break;
470
810
  }
471
- const rowNode = this.rowPositionUtils.getRowNode(currentRow);
811
+ const rowNode = _getRowNode(this.beans, currentRow);
472
812
  if (!rowNode) {
473
813
  break;
474
814
  }
@@ -476,7 +816,7 @@ export class RangeSelector extends BeanStub {
476
816
  rowNode.setSelected(true);
477
817
  }
478
818
  nodesToBeSelected.push(rowNode.data);
479
- currentRow = this.cellNavigationService.getRowBelow(currentRow);
819
+ currentRow = _getRowBelow(this.beans, currentRow);
480
820
  }
481
821
  this.gridApi.getSelectedNodes().forEach((node) => {
482
822
  if (!nodesToBeSelected.some(nodeToBeSelected => node.data === nodeToBeSelected)) {
@@ -484,36 +824,53 @@ export class RangeSelector extends BeanStub {
484
824
  }
485
825
  });
486
826
  });
487
- const eventCellSelection = {
488
- type: "cellSelectionChanged",
489
- started: started,
490
- finished: finished,
491
- id: id,
492
- };
493
- this.eventService.dispatchEvent(eventCellSelection);
494
- const eventRangeSelection = {
495
- type: "rangeSelectionChanged",
496
- started: started,
497
- finished: finished,
498
- id: id,
499
- };
500
- this.eventService.dispatchEvent(eventRangeSelection);
827
+ this.eventSvc.dispatchEvent({
828
+ type: 'cellSelectionChanged',
829
+ started,
830
+ finished,
831
+ id,
832
+ });
833
+ this.eventSvc.dispatchEvent({
834
+ type: 'rangeSelectionChanged',
835
+ started,
836
+ finished,
837
+ id,
838
+ });
501
839
  }
502
- calculateColumnsBetween(columnFrom, columnTo) {
503
- const allColumns = this.visibleColsService.getAllCols();
504
- const isSameColumn = columnFrom === columnTo;
505
- const fromIndex = allColumns.indexOf(columnFrom);
840
+ getColumnFromModel(col) {
841
+ return typeof col === 'string' ? this.colModel.getCol(col) : col;
842
+ }
843
+ getColumnsFromModel(cols) {
844
+ const { gos, visibleCols } = this;
845
+ const isRowHeaderActive = gos.get('rowNumbers');
846
+ cols = visibleCols.allCols;
847
+ const columns = [];
848
+ for (const col of cols) {
849
+ const column = this.getColumnFromModel(col);
850
+ if (!column || (isRowHeaderActive && this.shouldSkipCurrentColumn(column))) {
851
+ continue;
852
+ }
853
+ columns.push(column);
854
+ }
855
+ return columns.length ? columns : undefined;
856
+ }
857
+ calculateColumnsBetween(columnA, columnB) {
858
+ const allColumns = this.visibleCols.allCols;
859
+ const fromColumn = this.getColumnFromModel(columnA);
860
+ const toColumn = this.getColumnFromModel(columnB);
861
+ const isSameColumn = fromColumn === toColumn;
862
+ const fromIndex = allColumns.indexOf(fromColumn);
506
863
  if (fromIndex < 0) {
507
- console.warn(`ag-Grid: column ${columnFrom.getId()} is not visible`);
508
- return undefined;
864
+ _warn(178, { colId: fromColumn.getId() });
865
+ return;
509
866
  }
510
- const toIndex = isSameColumn ? fromIndex : allColumns.indexOf(columnTo);
867
+ const toIndex = isSameColumn ? fromIndex : allColumns.indexOf(toColumn);
511
868
  if (toIndex < 0) {
512
- console.warn(`ag-Grid: column ${columnTo.getId()} is not visible`);
513
- return undefined;
869
+ _warn(178, { colId: toColumn.getId() });
870
+ return;
514
871
  }
515
872
  if (isSameColumn) {
516
- return [columnFrom];
873
+ return this.getColumnsFromModel([fromColumn]);
517
874
  }
518
875
  const firstIndex = Math.min(fromIndex, toIndex);
519
876
  const lastIndex = firstIndex === fromIndex ? toIndex : fromIndex;
@@ -521,7 +878,52 @@ export class RangeSelector extends BeanStub {
521
878
  for (let i = firstIndex; i <= lastIndex; i++) {
522
879
  columns.push(allColumns[i]);
523
880
  }
524
- return columns;
881
+ return this.getColumnsFromModel(columns);
882
+ }
883
+ focusCellOnNewColumn(currentRange, column) {
884
+ const { focusSvc } = this.beans;
885
+ const focusedCell = focusSvc.getFocusedCell();
886
+ if (!focusedCell) {
887
+ return;
888
+ }
889
+ if (this.isCellInSpecificRange(focusedCell, currentRange)) {
890
+ focusSvc.setFocusedCell(Object.assign(Object.assign({}, focusedCell), { column, forceBrowserFocus: true, preventScrollOnBrowserFocus: true }));
891
+ }
892
+ }
893
+ focusCellOnNewRow(currentRange, row) {
894
+ const { focusSvc } = this.beans;
895
+ const focusedCell = focusSvc.getFocusedCell();
896
+ if (!focusedCell) {
897
+ return;
898
+ }
899
+ if (this.isCellInSpecificRange(focusedCell, currentRange)) {
900
+ focusSvc.setFocusedCell(Object.assign(Object.assign({}, row), { column: focusedCell.column, forceBrowserFocus: true, preventScrollOnBrowserFocus: true }));
901
+ }
902
+ }
903
+ before(rowA, rowB) {
904
+ switch (rowA.rowPinned) {
905
+ case 'top':
906
+ if (rowB.rowPinned !== 'top') {
907
+ return true;
908
+ }
909
+ break;
910
+ case 'bottom':
911
+ if (rowB.rowPinned !== 'bottom') {
912
+ return false;
913
+ }
914
+ break;
915
+ default:
916
+ if (_exists(rowB.rowPinned)) {
917
+ return rowB.rowPinned !== 'top';
918
+ }
919
+ break;
920
+ }
921
+ return rowA.rowIndex < rowB.rowIndex;
922
+ }
923
+ createDragListenerFeature(eContainer) {
924
+ return new DragListenerFeature(eContainer);
925
+ }
926
+ createCellRangeFeature(beans, ctrl) {
525
927
  }
526
928
  }
527
929
  //# sourceMappingURL=rangeSelector.js.map