Socket
Socket
Sign inDemoInstall

@ag-grid-enterprise/range-selection

Package Overview
Dependencies
Maintainers
3
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ag-grid-enterprise/range-selection - npm Package Compare versions

Comparing version 22.0.0 to 22.1.0

dist/cjs/main.js.map

1

dist/cjs/main.js

@@ -5,1 +5,2 @@ "use strict";

exports.RangeSelectionModule = rangeSelectionModule_1.RangeSelectionModule;
//# sourceMappingURL=main.js.map

@@ -187,1 +187,2 @@ "use strict";

exports.AbstractSelectionHandle = AbstractSelectionHandle;
//# sourceMappingURL=abstractSelectionHandle.js.map

@@ -5,2 +5,3 @@ import { CellComp } from '@ag-grid-community/core';

private valueService;
private eventService;
private gridOptionsWrapper;

@@ -21,2 +22,4 @@ static TEMPLATE: string;

protected onDragEnd(e: MouseEvent): void;
private raiseFillStartEvent;
private raiseFillEndEvent;
private handleValueChanged;

@@ -23,0 +26,0 @@ private clearCellsInRange;

@@ -56,4 +56,4 @@ "use strict";

if (!this.initialXY) {
var _a = this.getGui().getBoundingClientRect(), x_1 = _a.x, y_1 = _a.y;
this.initialXY = { x: x_1, y: y_1 };
var _a = this.getGui().getBoundingClientRect(), left = _a.left, top_1 = _a.top;
this.initialXY = { x: left, y: top_1 };
}

@@ -112,6 +112,27 @@ var _b = this.initialXY, x = _b.x, y = _b.y;

if (finalRange) {
// raising fill events for undo / redo
this.raiseFillStartEvent();
this.handleValueChanged(initialRange, finalRange, e);
this.rangeController.setCellRanges([finalRange]);
this.raiseFillEndEvent(initialRange, finalRange);
}
};
FillHandle.prototype.raiseFillStartEvent = function () {
var fillStartEvent = {
type: core_1.Events.EVENT_FILL_START,
columnApi: this.gridOptionsWrapper.getColumnApi(),
api: this.gridOptionsWrapper.getApi()
};
this.eventService.dispatchEvent(fillStartEvent);
};
FillHandle.prototype.raiseFillEndEvent = function (initialRange, finalRange) {
var fillEndEvent = {
type: core_1.Events.EVENT_FILL_END,
columnApi: this.gridOptionsWrapper.getColumnApi(),
api: this.gridOptionsWrapper.getApi(),
initialRange: initialRange,
finalRange: finalRange
};
this.eventService.dispatchEvent(fillEndEvent);
};
FillHandle.prototype.handleValueChanged = function (initialRange, finalRange, e) {

@@ -187,3 +208,5 @@ var _this = this;

currentValue = _this.processValues(e, values, initialValues, col, rowNode, idx++);
_this.valueService.setValue(rowNode, col, currentValue);
if (col.isCellEditable(rowNode)) {
_this.valueService.setValue(rowNode, col, currentValue);
}
}

@@ -213,3 +236,5 @@ values.push(currentValue);

columns.forEach(function (col) {
_this.valueService.setValue(rowNode, col, null);
if (col.isCellEditable(rowNode)) {
_this.valueService.setValue(rowNode, col, null);
}
});

@@ -465,2 +490,5 @@ finished = this_1.rowPositionUtils.sameRow(currentRow, endRow);

__decorate([
core_1.Autowired('eventService')
], FillHandle.prototype, "eventService", void 0);
__decorate([
core_1.Autowired('gridOptionsWrapper')

@@ -471,1 +499,2 @@ ], FillHandle.prototype, "gridOptionsWrapper", void 0);

exports.FillHandle = FillHandle;
//# sourceMappingURL=fillHandle.js.map

13

dist/cjs/rangeSelection/rangeController.d.ts

@@ -20,6 +20,6 @@ import { CellPosition, CellPositionUtils, Column, GridOptionsWrapper, GridPanel, IRangeController, CellRangeParams, CellRange, RowPosition, RowPositionUtils } from "@ag-grid-community/core";

private bodyScrollListener;
private newestRangeStartCell;
private newestRangeStartCell?;
private dragging;
private draggingCell;
private draggingRange;
private draggingCell?;
private draggingRange?;
autoScrollService: AutoScrollService;

@@ -35,6 +35,3 @@ registerGridComp(gridPanel: GridPanel): void;

extendLatestRangeToCell(cellPosition: CellPosition): void;
updateRangeEnd(params: {
cellRange: CellRange;
cellPosition: CellPosition;
}): void;
updateRangeEnd(cellRange: CellRange, cellPosition: CellPosition, silent?: boolean): void;
private refreshRangeStart;

@@ -57,2 +54,3 @@ getRangeEdgeColumns(cellRange: CellRange): {

isCellInSpecificRange(cell: CellPosition, range: CellRange): boolean;
isLastCellOfRange(cellRange: CellRange, cell: CellPosition): boolean;
getCellRangeCount(cell: CellPosition): number;

@@ -64,3 +62,2 @@ private isRowInRange;

onDragStop(): void;
private onRangeChanged;
private dispatchChangedEvent;

@@ -67,0 +64,0 @@ private calculateColumnsBetween;

@@ -49,9 +49,3 @@ "use strict";

// notify users and other parts of grid (i.e. status panel) that range has changed
_this.onRangeChanged({ started: false, finished: true });
// notify chart of cell range change
var event_1 = {
id: cellRange.id,
type: core_1.Events.EVENT_CHART_RANGE_SELECTION_CHANGED
};
_this.eventService.dispatchEvent(event_1);
_this.dispatchChangedEvent(false, true, cellRange.id);
}

@@ -73,5 +67,3 @@ });

var allColumns = this.columnController.getAllDisplayedColumns();
var allPositions = [];
rangeColumns.forEach(function (col) { return allPositions.push(allColumns.indexOf(col)); });
allPositions.sort(function (a, b) { return a - b; });
var allPositions = rangeColumns.map(function (c) { return allColumns.indexOf(c); }).sort(function (a, b) { return a - b; });
return core_1._.last(allPositions) - allPositions[0] + 1 === rangeColumns.length;

@@ -81,12 +73,12 @@ };

if (cellRange.startRow && cellRange.endRow) {
var startRowIsFirst = this.rowPositionUtils.before(cellRange.startRow, cellRange.endRow);
return startRowIsFirst ? cellRange.startRow : cellRange.endRow;
return this.rowPositionUtils.before(cellRange.startRow, cellRange.endRow) ?
cellRange.startRow : cellRange.endRow;
}
var pinned = (this.pinnedRowModel.getPinnedTopRowCount() > 0) ? core_1.Constants.PINNED_TOP : undefined;
return { rowIndex: 0, rowPinned: pinned };
var rowPinned = this.pinnedRowModel.getPinnedTopRowCount() > 0 ? core_1.Constants.PINNED_TOP : undefined;
return { rowIndex: 0, rowPinned: rowPinned };
};
RangeController.prototype.getRangeEndRow = function (cellRange) {
if (cellRange.startRow && cellRange.endRow) {
var startRowIsFirst = this.rowPositionUtils.before(cellRange.startRow, cellRange.endRow);
return startRowIsFirst ? cellRange.endRow : cellRange.startRow;
return this.rowPositionUtils.before(cellRange.startRow, cellRange.endRow) ?
cellRange.endRow : cellRange.startRow;
}

@@ -127,3 +119,3 @@ var pinnedBottomRowCount = this.pinnedRowModel.getPinnedBottomRowCount();

// many times to the clipboard.
var existingRange;
var cellRange;
for (var i = 0; i < this.cellRanges.length; i++) {

@@ -138,17 +130,17 @@ var range = this.cellRanges[i];

if (matches) {
existingRange = range;
cellRange = range;
break;
}
}
if (existingRange) {
if (cellRange) {
// we need it at the end of the list, as the dragStart picks the last created
// range as the start point for the drag
var atEndOfList = core_1._.last(this.cellRanges) === existingRange;
var atEndOfList = core_1._.last(this.cellRanges) === cellRange;
if (!atEndOfList) {
core_1._.removeFromArray(this.cellRanges, existingRange);
this.cellRanges.push(existingRange);
core_1._.removeFromArray(this.cellRanges, cellRange);
this.cellRanges.push(cellRange);
}
}
else {
var newRange = {
cellRange = {
startRow: rowForCell,

@@ -159,7 +151,7 @@ endRow: rowForCell,

};
this.cellRanges.push(newRange);
this.cellRanges.push(cellRange);
}
this.newestRangeStartCell = cell;
this.onDragStop();
this.onRangeChanged({ started: false, finished: true });
this.dispatchChangedEvent(false, true, cellRange.id);
};

@@ -171,11 +163,5 @@ RangeController.prototype.extendLatestRangeToCell = function (cellPosition) {

var cellRange = core_1._.last(this.cellRanges);
this.updateRangeEnd({
cellRange: cellRange,
cellPosition: cellPosition
});
this.updateRangeEnd(cellRange, cellPosition);
};
RangeController.prototype.updateRangeEnd = function (params) {
var cellRange = params.cellRange, cellPosition = params.cellPosition;
var beforeCols = __spreadArrays(cellRange.columns);
var beforeEndRow = core_1._.cloneObject(cellRange.endRow);
RangeController.prototype.updateRangeEnd = function (cellRange, cellPosition, silent) {
var endColumn = cellPosition.column;

@@ -188,13 +174,4 @@ var colsToAdd = this.calculateColumnsBetween(cellRange.startColumn, endColumn);

cellRange.endRow = { rowIndex: cellPosition.rowIndex, rowPinned: cellPosition.rowPinned };
this.onRangeChanged({ started: false, finished: true });
var colsChanged = !core_1._.compareArrays(beforeCols, cellRange.columns);
var endRowChanged = JSON.stringify(beforeEndRow) !== JSON.stringify(cellRange.endRow);
if (colsChanged || endRowChanged) {
// Note that we are raising a new event as the Chart shouldn't be notified when other ranges are changed
// or when the chart setCellRanges when the chart gains focus!
var event_2 = {
id: cellRange.id,
type: core_1.Events.EVENT_CHART_RANGE_SELECTION_CHANGED
};
this.eventService.dispatchEvent(event_2);
if (!silent) {
this.dispatchChangedEvent(false, true, cellRange.id);
}

@@ -228,11 +205,6 @@ };

var allColumns = this.columnController.getAllDisplayedColumns();
var allIndices = [];
for (var _i = 0, _a = cellRange.columns; _i < _a.length; _i++) {
var column = _a[_i];
var idx = allColumns.indexOf(column);
if (idx > -1) {
allIndices.push(idx);
}
}
allIndices.sort(function (a, b) { return a - b; });
var allIndices = cellRange.columns
.map(function (c) { return allColumns.indexOf(c); })
.filter(function (i) { return i > -1; })
.sort(function (a, b) { return a - b; });
return {

@@ -292,3 +264,3 @@ left: allColumns[allIndices[0]],

});
this.onRangeChanged({ started: false, finished: true });
this.dispatchChangedEvent(false, true);
};

@@ -299,9 +271,3 @@ RangeController.prototype.createCellRangeFromCellRangeParams = function (params) {

if (params.columns) {
columns = [];
params.columns.forEach(function (key) {
var col = _this.columnController.getColumnWithValidation(key);
if (col) {
columns.push(col);
}
});
columns = params.columns.map(function (c) { return _this.columnController.getColumnWithValidation(c); }).filter(function (c) { return c; });
}

@@ -319,17 +285,11 @@ else {

}
var startRow = undefined;
if (params.rowStartIndex != null) {
startRow = {
rowIndex: params.rowStartIndex,
rowPinned: params.rowStartPinned
};
}
var endRow = undefined;
if (params.rowEndIndex != null) {
endRow = {
rowIndex: params.rowEndIndex,
rowPinned: params.rowEndPinned
};
}
var newRange = {
var startRow = params.rowStartIndex != null ? {
rowIndex: params.rowStartIndex,
rowPinned: params.rowStartPinned
} : undefined;
var endRow = params.rowEndIndex != null ? {
rowIndex: params.rowEndIndex,
rowPinned: params.rowEndPinned
} : undefined;
return {
startRow: startRow,

@@ -340,3 +300,2 @@ endRow: endRow,

};
return newRange;
};

@@ -350,3 +309,3 @@ RangeController.prototype.addCellRange = function (params) {

this.cellRanges.push(newRange);
this.onRangeChanged({ started: false, finished: true });
this.dispatchChangedEvent(false, true, newRange.id);
}

@@ -373,6 +332,5 @@ };

var endRow = this.getRangeEndRow(range);
var moreThanOneCell = startRow.rowPinned !== endRow.rowPinned ||
return startRow.rowPinned !== endRow.rowPinned ||
startRow.rowIndex !== endRow.rowIndex ||
range.columns.length !== 1;
return moreThanOneCell;
};

@@ -386,3 +344,3 @@ RangeController.prototype.removeAllCellRanges = function (silent) {

if (!silent) {
this.onRangeChanged({ started: false, finished: true });
this.dispatchChangedEvent(false, true);
}

@@ -400,6 +358,15 @@ };

RangeController.prototype.isCellInSpecificRange = function (cell, range) {
var columnInRange = range.columns !== null && range.columns.indexOf(cell.column) >= 0;
var columnInRange = range.columns !== null && core_1._.includes(range.columns, cell.column);
var rowInRange = this.isRowInRange(cell.rowIndex, cell.rowPinned, range);
return columnInRange && rowInRange;
};
RangeController.prototype.isLastCellOfRange = function (cellRange, cell) {
var allColumns = this.columnController.getAllDisplayedColumns();
var allPositions = cellRange.columns.map(function (c) { return allColumns.indexOf(c); }).sort(function (a, b) { return a - b; });
var startRow = cellRange.startRow, endRow = cellRange.endRow;
var lastRow = this.rowPositionUtils.before(startRow, endRow) ? endRow : startRow;
var isLastColumn = allColumns.indexOf(cell.column) === core_1._.last(allPositions);
var isLastRow = cell.rowIndex === lastRow.rowIndex && cell.rowPinned === lastRow.rowPinned;
return isLastColumn && isLastRow;
};
// returns the number of ranges this cell is in

@@ -411,9 +378,3 @@ RangeController.prototype.getCellRangeCount = function (cell) {

}
var matchingCount = 0;
this.cellRanges.forEach(function (cellRange) {
if (_this.isCellInSpecificRange(cell, cellRange)) {
matchingCount++;
}
});
return matchingCount;
return this.cellRanges.filter(function (cellRange) { return _this.isCellInSpecificRange(cell, cellRange); }).length;
};

@@ -482,5 +443,6 @@ RangeController.prototype.isRowInRange = function (rowIndex, floating, cellRange) {

this.gridPanel.addScrollEventListener(this.bodyScrollListener);
this.onRangeChanged({ started: true, finished: false });
this.dispatchChangedEvent(true, false, this.draggingRange.id);
};
RangeController.prototype.onDragging = function (mouseEvent) {
var _this = this;
if (!this.dragging || !mouseEvent) {

@@ -491,5 +453,6 @@ return;

var cellPosition = this.mouseEventService.getCellPositionForEvent(mouseEvent);
var mouseAndStartInPinnedTop = cellPosition && cellPosition.rowPinned === 'top' && this.newestRangeStartCell.rowPinned === 'top';
var mouseAndStartInPinnedBottom = cellPosition && cellPosition.rowPinned === 'bottom' && this.newestRangeStartCell.rowPinned === 'bottom';
var skipVerticalScroll = mouseAndStartInPinnedTop || mouseAndStartInPinnedBottom;
var isMouseAndStartInPinned = function (position) {
return cellPosition && cellPosition.rowPinned === position && _this.newestRangeStartCell.rowPinned === position;
};
var skipVerticalScroll = isMouseAndStartInPinned('top') || isMouseAndStartInPinned('bottom');
this.autoScrollService.check(mouseEvent, skipVerticalScroll);

@@ -511,3 +474,3 @@ if (!cellPosition ||

this.draggingRange.columns = columns;
this.onRangeChanged({ started: false, finished: false });
this.dispatchChangedEvent(false, false, this.draggingRange.id);
};

@@ -518,2 +481,3 @@ RangeController.prototype.onDragStop = function () {

}
var id = this.draggingRange.id;
this.autoScrollService.ensureCleared();

@@ -525,10 +489,6 @@ this.gridPanel.removeScrollEventListener(this.bodyScrollListener);

this.draggingCell = undefined;
this.onRangeChanged({ started: false, finished: true });
this.dispatchChangedEvent(false, true, id);
};
RangeController.prototype.onRangeChanged = function (params) {
var started = params.started, finished = params.finished;
this.dispatchChangedEvent(started, finished);
};
RangeController.prototype.dispatchChangedEvent = function (started, finished) {
var event = {
RangeController.prototype.dispatchChangedEvent = function (started, finished, id) {
var event = Object.freeze({
type: core_1.Events.EVENT_RANGE_SELECTION_CHANGED,

@@ -538,4 +498,5 @@ api: this.gridApi,

started: started,
finished: finished
};
finished: finished,
id: id,
});
this.eventService.dispatchEvent(event);

@@ -547,9 +508,9 @@ };

var fromIndex = allColumns.indexOf(columnFrom);
var toIndex = isSameColumn ? fromIndex : allColumns.indexOf(columnTo);
if (fromIndex < 0) {
console.warn('ag-Grid: column ' + columnFrom.getId() + ' is not visible');
console.warn("ag-Grid: column " + columnFrom.getId() + " is not visible");
return undefined;
}
var toIndex = isSameColumn ? fromIndex : allColumns.indexOf(columnTo);
if (toIndex < 0) {
console.warn('ag-Grid: column ' + columnTo.getId() + ' is not visible');
console.warn("ag-Grid: column " + columnTo.getId() + " is not visible");
return undefined;

@@ -671,1 +632,2 @@ }

}());
//# sourceMappingURL=rangeController.js.map

@@ -48,14 +48,15 @@ "use strict";

}
var newEndRow = {
this.endPosition = {
rowIndex: lastCellHovered.rowIndex,
rowPinned: lastCellHovered.rowPinned,
column: lastCellHovered.column
};
var rowChanged = !this.rowPositionUtils.sameRow(newEndRow, this.rangeController.getRangeEndRow(lastRange));
if (cellRanges.length === 2 && rowChanged) {
this.rangeController.updateRangeEnd({
cellRange: cellRanges[0],
cellPosition: __assign(__assign({}, newEndRow), { column: cellRanges[0].columns[0] })
});
// check if the cell ranges are for a chart
if (cellRanges.length === 2 && cellRanges[0].type === core_1.CellRangeType.DIMENSION && lastRange.type === core_1.CellRangeType.VALUE) {
var rowChanged = !this.rowPositionUtils.sameRow(this.endPosition, this.rangeController.getRangeEndRow(lastRange));
if (rowChanged) {
// ensure the dimension range is kept in sync with the value range (which has the handle)
this.rangeController.updateRangeEnd(cellRanges[0], __assign(__assign({}, this.endPosition), { column: cellRanges[0].columns[0] }), true);
}
}
this.endPosition = __assign(__assign({}, newEndRow), { column: lastCellHovered.column });
this.rangeController.extendLatestRangeToCell(this.endPosition);

@@ -80,1 +81,2 @@ };

exports.RangeHandle = RangeHandle;
//# sourceMappingURL=rangeHandle.js.map

@@ -19,1 +19,2 @@ "use strict";

};
//# sourceMappingURL=rangeSelectionModule.js.map

@@ -5,2 +5,3 @@ import { CellComp } from '@ag-grid-community/core';

private valueService;
private eventService;
private gridOptionsWrapper;

@@ -21,2 +22,4 @@ static TEMPLATE: string;

protected onDragEnd(e: MouseEvent): void;
private raiseFillStartEvent;
private raiseFillEndEvent;
private handleValueChanged;

@@ -23,0 +26,0 @@ private clearCellsInRange;

@@ -38,3 +38,3 @@ var __extends = (this && this.__extends) || (function () {

};
import { Autowired, _ } from '@ag-grid-community/core';
import { Autowired, Events, _ } from '@ag-grid-community/core';
import { AbstractSelectionHandle } from "./abstractSelectionHandle";

@@ -55,4 +55,4 @@ var FillHandle = /** @class */ (function (_super) {

if (!this.initialXY) {
var _a = this.getGui().getBoundingClientRect(), x_1 = _a.x, y_1 = _a.y;
this.initialXY = { x: x_1, y: y_1 };
var _a = this.getGui().getBoundingClientRect(), left = _a.left, top_1 = _a.top;
this.initialXY = { x: left, y: top_1 };
}

@@ -111,6 +111,27 @@ var _b = this.initialXY, x = _b.x, y = _b.y;

if (finalRange) {
// raising fill events for undo / redo
this.raiseFillStartEvent();
this.handleValueChanged(initialRange, finalRange, e);
this.rangeController.setCellRanges([finalRange]);
this.raiseFillEndEvent(initialRange, finalRange);
}
};
FillHandle.prototype.raiseFillStartEvent = function () {
var fillStartEvent = {
type: Events.EVENT_FILL_START,
columnApi: this.gridOptionsWrapper.getColumnApi(),
api: this.gridOptionsWrapper.getApi()
};
this.eventService.dispatchEvent(fillStartEvent);
};
FillHandle.prototype.raiseFillEndEvent = function (initialRange, finalRange) {
var fillEndEvent = {
type: Events.EVENT_FILL_END,
columnApi: this.gridOptionsWrapper.getColumnApi(),
api: this.gridOptionsWrapper.getApi(),
initialRange: initialRange,
finalRange: finalRange
};
this.eventService.dispatchEvent(fillEndEvent);
};
FillHandle.prototype.handleValueChanged = function (initialRange, finalRange, e) {

@@ -186,3 +207,5 @@ var _this = this;

currentValue = _this.processValues(e, values, initialValues, col, rowNode, idx++);
_this.valueService.setValue(rowNode, col, currentValue);
if (col.isCellEditable(rowNode)) {
_this.valueService.setValue(rowNode, col, currentValue);
}
}

@@ -212,3 +235,5 @@ values.push(currentValue);

columns.forEach(function (col) {
_this.valueService.setValue(rowNode, col, null);
if (col.isCellEditable(rowNode)) {
_this.valueService.setValue(rowNode, col, null);
}
});

@@ -464,2 +489,5 @@ finished = this_1.rowPositionUtils.sameRow(currentRow, endRow);

__decorate([
Autowired('eventService')
], FillHandle.prototype, "eventService", void 0);
__decorate([
Autowired('gridOptionsWrapper')

@@ -466,0 +494,0 @@ ], FillHandle.prototype, "gridOptionsWrapper", void 0);

@@ -20,6 +20,6 @@ import { CellPosition, CellPositionUtils, Column, GridOptionsWrapper, GridPanel, IRangeController, CellRangeParams, CellRange, RowPosition, RowPositionUtils } from "@ag-grid-community/core";

private bodyScrollListener;
private newestRangeStartCell;
private newestRangeStartCell?;
private dragging;
private draggingCell;
private draggingRange;
private draggingCell?;
private draggingRange?;
autoScrollService: AutoScrollService;

@@ -35,6 +35,3 @@ registerGridComp(gridPanel: GridPanel): void;

extendLatestRangeToCell(cellPosition: CellPosition): void;
updateRangeEnd(params: {
cellRange: CellRange;
cellPosition: CellPosition;
}): void;
updateRangeEnd(cellRange: CellRange, cellPosition: CellPosition, silent?: boolean): void;
private refreshRangeStart;

@@ -57,2 +54,3 @@ getRangeEdgeColumns(cellRange: CellRange): {

isCellInSpecificRange(cell: CellPosition, range: CellRange): boolean;
isLastCellOfRange(cellRange: CellRange, cell: CellPosition): boolean;
getCellRangeCount(cell: CellPosition): number;

@@ -64,3 +62,2 @@ private isRowInRange;

onDragStop(): void;
private onRangeChanged;
private dispatchChangedEvent;

@@ -67,0 +64,0 @@ private calculateColumnsBetween;

@@ -14,3 +14,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

};
import { Autowired, Bean, Constants, Events, PostConstruct, _ } from "@ag-grid-community/core";
import { Autowired, Bean, Constants, Events, PostConstruct, _, } from "@ag-grid-community/core";
var RangeController = /** @class */ (function () {

@@ -48,9 +48,3 @@ function RangeController() {

// notify users and other parts of grid (i.e. status panel) that range has changed
_this.onRangeChanged({ started: false, finished: true });
// notify chart of cell range change
var event_1 = {
id: cellRange.id,
type: Events.EVENT_CHART_RANGE_SELECTION_CHANGED
};
_this.eventService.dispatchEvent(event_1);
_this.dispatchChangedEvent(false, true, cellRange.id);
}

@@ -72,5 +66,3 @@ });

var allColumns = this.columnController.getAllDisplayedColumns();
var allPositions = [];
rangeColumns.forEach(function (col) { return allPositions.push(allColumns.indexOf(col)); });
allPositions.sort(function (a, b) { return a - b; });
var allPositions = rangeColumns.map(function (c) { return allColumns.indexOf(c); }).sort(function (a, b) { return a - b; });
return _.last(allPositions) - allPositions[0] + 1 === rangeColumns.length;

@@ -80,12 +72,12 @@ };

if (cellRange.startRow && cellRange.endRow) {
var startRowIsFirst = this.rowPositionUtils.before(cellRange.startRow, cellRange.endRow);
return startRowIsFirst ? cellRange.startRow : cellRange.endRow;
return this.rowPositionUtils.before(cellRange.startRow, cellRange.endRow) ?
cellRange.startRow : cellRange.endRow;
}
var pinned = (this.pinnedRowModel.getPinnedTopRowCount() > 0) ? Constants.PINNED_TOP : undefined;
return { rowIndex: 0, rowPinned: pinned };
var rowPinned = this.pinnedRowModel.getPinnedTopRowCount() > 0 ? Constants.PINNED_TOP : undefined;
return { rowIndex: 0, rowPinned: rowPinned };
};
RangeController.prototype.getRangeEndRow = function (cellRange) {
if (cellRange.startRow && cellRange.endRow) {
var startRowIsFirst = this.rowPositionUtils.before(cellRange.startRow, cellRange.endRow);
return startRowIsFirst ? cellRange.endRow : cellRange.startRow;
return this.rowPositionUtils.before(cellRange.startRow, cellRange.endRow) ?
cellRange.endRow : cellRange.startRow;
}

@@ -126,3 +118,3 @@ var pinnedBottomRowCount = this.pinnedRowModel.getPinnedBottomRowCount();

// many times to the clipboard.
var existingRange;
var cellRange;
for (var i = 0; i < this.cellRanges.length; i++) {

@@ -137,17 +129,17 @@ var range = this.cellRanges[i];

if (matches) {
existingRange = range;
cellRange = range;
break;
}
}
if (existingRange) {
if (cellRange) {
// we need it at the end of the list, as the dragStart picks the last created
// range as the start point for the drag
var atEndOfList = _.last(this.cellRanges) === existingRange;
var atEndOfList = _.last(this.cellRanges) === cellRange;
if (!atEndOfList) {
_.removeFromArray(this.cellRanges, existingRange);
this.cellRanges.push(existingRange);
_.removeFromArray(this.cellRanges, cellRange);
this.cellRanges.push(cellRange);
}
}
else {
var newRange = {
cellRange = {
startRow: rowForCell,

@@ -158,7 +150,7 @@ endRow: rowForCell,

};
this.cellRanges.push(newRange);
this.cellRanges.push(cellRange);
}
this.newestRangeStartCell = cell;
this.onDragStop();
this.onRangeChanged({ started: false, finished: true });
this.dispatchChangedEvent(false, true, cellRange.id);
};

@@ -170,11 +162,5 @@ RangeController.prototype.extendLatestRangeToCell = function (cellPosition) {

var cellRange = _.last(this.cellRanges);
this.updateRangeEnd({
cellRange: cellRange,
cellPosition: cellPosition
});
this.updateRangeEnd(cellRange, cellPosition);
};
RangeController.prototype.updateRangeEnd = function (params) {
var cellRange = params.cellRange, cellPosition = params.cellPosition;
var beforeCols = __spreadArrays(cellRange.columns);
var beforeEndRow = _.cloneObject(cellRange.endRow);
RangeController.prototype.updateRangeEnd = function (cellRange, cellPosition, silent) {
var endColumn = cellPosition.column;

@@ -187,13 +173,4 @@ var colsToAdd = this.calculateColumnsBetween(cellRange.startColumn, endColumn);

cellRange.endRow = { rowIndex: cellPosition.rowIndex, rowPinned: cellPosition.rowPinned };
this.onRangeChanged({ started: false, finished: true });
var colsChanged = !_.compareArrays(beforeCols, cellRange.columns);
var endRowChanged = JSON.stringify(beforeEndRow) !== JSON.stringify(cellRange.endRow);
if (colsChanged || endRowChanged) {
// Note that we are raising a new event as the Chart shouldn't be notified when other ranges are changed
// or when the chart setCellRanges when the chart gains focus!
var event_2 = {
id: cellRange.id,
type: Events.EVENT_CHART_RANGE_SELECTION_CHANGED
};
this.eventService.dispatchEvent(event_2);
if (!silent) {
this.dispatchChangedEvent(false, true, cellRange.id);
}

@@ -227,11 +204,6 @@ };

var allColumns = this.columnController.getAllDisplayedColumns();
var allIndices = [];
for (var _i = 0, _a = cellRange.columns; _i < _a.length; _i++) {
var column = _a[_i];
var idx = allColumns.indexOf(column);
if (idx > -1) {
allIndices.push(idx);
}
}
allIndices.sort(function (a, b) { return a - b; });
var allIndices = cellRange.columns
.map(function (c) { return allColumns.indexOf(c); })
.filter(function (i) { return i > -1; })
.sort(function (a, b) { return a - b; });
return {

@@ -291,3 +263,3 @@ left: allColumns[allIndices[0]],

});
this.onRangeChanged({ started: false, finished: true });
this.dispatchChangedEvent(false, true);
};

@@ -298,9 +270,3 @@ RangeController.prototype.createCellRangeFromCellRangeParams = function (params) {

if (params.columns) {
columns = [];
params.columns.forEach(function (key) {
var col = _this.columnController.getColumnWithValidation(key);
if (col) {
columns.push(col);
}
});
columns = params.columns.map(function (c) { return _this.columnController.getColumnWithValidation(c); }).filter(function (c) { return c; });
}

@@ -318,17 +284,11 @@ else {

}
var startRow = undefined;
if (params.rowStartIndex != null) {
startRow = {
rowIndex: params.rowStartIndex,
rowPinned: params.rowStartPinned
};
}
var endRow = undefined;
if (params.rowEndIndex != null) {
endRow = {
rowIndex: params.rowEndIndex,
rowPinned: params.rowEndPinned
};
}
var newRange = {
var startRow = params.rowStartIndex != null ? {
rowIndex: params.rowStartIndex,
rowPinned: params.rowStartPinned
} : undefined;
var endRow = params.rowEndIndex != null ? {
rowIndex: params.rowEndIndex,
rowPinned: params.rowEndPinned
} : undefined;
return {
startRow: startRow,

@@ -339,3 +299,2 @@ endRow: endRow,

};
return newRange;
};

@@ -349,3 +308,3 @@ RangeController.prototype.addCellRange = function (params) {

this.cellRanges.push(newRange);
this.onRangeChanged({ started: false, finished: true });
this.dispatchChangedEvent(false, true, newRange.id);
}

@@ -372,6 +331,5 @@ };

var endRow = this.getRangeEndRow(range);
var moreThanOneCell = startRow.rowPinned !== endRow.rowPinned ||
return startRow.rowPinned !== endRow.rowPinned ||
startRow.rowIndex !== endRow.rowIndex ||
range.columns.length !== 1;
return moreThanOneCell;
};

@@ -385,3 +343,3 @@ RangeController.prototype.removeAllCellRanges = function (silent) {

if (!silent) {
this.onRangeChanged({ started: false, finished: true });
this.dispatchChangedEvent(false, true);
}

@@ -399,6 +357,15 @@ };

RangeController.prototype.isCellInSpecificRange = function (cell, range) {
var columnInRange = range.columns !== null && range.columns.indexOf(cell.column) >= 0;
var columnInRange = range.columns !== null && _.includes(range.columns, cell.column);
var rowInRange = this.isRowInRange(cell.rowIndex, cell.rowPinned, range);
return columnInRange && rowInRange;
};
RangeController.prototype.isLastCellOfRange = function (cellRange, cell) {
var allColumns = this.columnController.getAllDisplayedColumns();
var allPositions = cellRange.columns.map(function (c) { return allColumns.indexOf(c); }).sort(function (a, b) { return a - b; });
var startRow = cellRange.startRow, endRow = cellRange.endRow;
var lastRow = this.rowPositionUtils.before(startRow, endRow) ? endRow : startRow;
var isLastColumn = allColumns.indexOf(cell.column) === _.last(allPositions);
var isLastRow = cell.rowIndex === lastRow.rowIndex && cell.rowPinned === lastRow.rowPinned;
return isLastColumn && isLastRow;
};
// returns the number of ranges this cell is in

@@ -410,9 +377,3 @@ RangeController.prototype.getCellRangeCount = function (cell) {

}
var matchingCount = 0;
this.cellRanges.forEach(function (cellRange) {
if (_this.isCellInSpecificRange(cell, cellRange)) {
matchingCount++;
}
});
return matchingCount;
return this.cellRanges.filter(function (cellRange) { return _this.isCellInSpecificRange(cell, cellRange); }).length;
};

@@ -481,5 +442,6 @@ RangeController.prototype.isRowInRange = function (rowIndex, floating, cellRange) {

this.gridPanel.addScrollEventListener(this.bodyScrollListener);
this.onRangeChanged({ started: true, finished: false });
this.dispatchChangedEvent(true, false, this.draggingRange.id);
};
RangeController.prototype.onDragging = function (mouseEvent) {
var _this = this;
if (!this.dragging || !mouseEvent) {

@@ -490,5 +452,6 @@ return;

var cellPosition = this.mouseEventService.getCellPositionForEvent(mouseEvent);
var mouseAndStartInPinnedTop = cellPosition && cellPosition.rowPinned === 'top' && this.newestRangeStartCell.rowPinned === 'top';
var mouseAndStartInPinnedBottom = cellPosition && cellPosition.rowPinned === 'bottom' && this.newestRangeStartCell.rowPinned === 'bottom';
var skipVerticalScroll = mouseAndStartInPinnedTop || mouseAndStartInPinnedBottom;
var isMouseAndStartInPinned = function (position) {
return cellPosition && cellPosition.rowPinned === position && _this.newestRangeStartCell.rowPinned === position;
};
var skipVerticalScroll = isMouseAndStartInPinned('top') || isMouseAndStartInPinned('bottom');
this.autoScrollService.check(mouseEvent, skipVerticalScroll);

@@ -510,3 +473,3 @@ if (!cellPosition ||

this.draggingRange.columns = columns;
this.onRangeChanged({ started: false, finished: false });
this.dispatchChangedEvent(false, false, this.draggingRange.id);
};

@@ -517,2 +480,3 @@ RangeController.prototype.onDragStop = function () {

}
var id = this.draggingRange.id;
this.autoScrollService.ensureCleared();

@@ -524,10 +488,6 @@ this.gridPanel.removeScrollEventListener(this.bodyScrollListener);

this.draggingCell = undefined;
this.onRangeChanged({ started: false, finished: true });
this.dispatchChangedEvent(false, true, id);
};
RangeController.prototype.onRangeChanged = function (params) {
var started = params.started, finished = params.finished;
this.dispatchChangedEvent(started, finished);
};
RangeController.prototype.dispatchChangedEvent = function (started, finished) {
var event = {
RangeController.prototype.dispatchChangedEvent = function (started, finished, id) {
var event = Object.freeze({
type: Events.EVENT_RANGE_SELECTION_CHANGED,

@@ -537,4 +497,5 @@ api: this.gridApi,

started: started,
finished: finished
};
finished: finished,
id: id,
});
this.eventService.dispatchEvent(event);

@@ -546,9 +507,9 @@ };

var fromIndex = allColumns.indexOf(columnFrom);
var toIndex = isSameColumn ? fromIndex : allColumns.indexOf(columnTo);
if (fromIndex < 0) {
console.warn('ag-Grid: column ' + columnFrom.getId() + ' is not visible');
console.warn("ag-Grid: column " + columnFrom.getId() + " is not visible");
return undefined;
}
var toIndex = isSameColumn ? fromIndex : allColumns.indexOf(columnTo);
if (toIndex < 0) {
console.warn('ag-Grid: column ' + columnTo.getId() + ' is not visible');
console.warn("ag-Grid: column " + columnTo.getId() + " is not visible");
return undefined;

@@ -555,0 +516,0 @@ }

@@ -25,3 +25,3 @@ var __extends = (this && this.__extends) || (function () {

};
import { _ } from "@ag-grid-community/core";
import { _, CellRangeType } from "@ag-grid-community/core";
import { AbstractSelectionHandle } from "./abstractSelectionHandle";

@@ -47,14 +47,15 @@ var RangeHandle = /** @class */ (function (_super) {

}
var newEndRow = {
this.endPosition = {
rowIndex: lastCellHovered.rowIndex,
rowPinned: lastCellHovered.rowPinned,
column: lastCellHovered.column
};
var rowChanged = !this.rowPositionUtils.sameRow(newEndRow, this.rangeController.getRangeEndRow(lastRange));
if (cellRanges.length === 2 && rowChanged) {
this.rangeController.updateRangeEnd({
cellRange: cellRanges[0],
cellPosition: __assign(__assign({}, newEndRow), { column: cellRanges[0].columns[0] })
});
// check if the cell ranges are for a chart
if (cellRanges.length === 2 && cellRanges[0].type === CellRangeType.DIMENSION && lastRange.type === CellRangeType.VALUE) {
var rowChanged = !this.rowPositionUtils.sameRow(this.endPosition, this.rangeController.getRangeEndRow(lastRange));
if (rowChanged) {
// ensure the dimension range is kept in sync with the value range (which has the handle)
this.rangeController.updateRangeEnd(cellRanges[0], __assign(__assign({}, this.endPosition), { column: cellRanges[0].columns[0] }), true);
}
}
this.endPosition = __assign(__assign({}, newEndRow), { column: lastCellHovered.column });
this.rangeController.extendLatestRangeToCell(this.endPosition);

@@ -61,0 +62,0 @@ };

{
"name": "@ag-grid-enterprise/range-selection",
"version": "22.0.0",
"version": "22.1.0",
"description": "Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components",
"main": "./dist/cjs/main.js",
"module": "./dist/es6/main.js",
"types": "./dist/es6/main.d.ts",
"scripts": {
"build-cjs": "tsc -p tsconfig.es5.json",
"build-cjs": "tsc -p tsconfig.json",
"build-es6": "tsc -p tsconfig.es6.json",
"build-docs": "tsc -p tsconfig.docs.json",
"package": "node ../../common-build/rollup/build.js",
"package": "node ../../module-build/rollup/build.js",
"build": "npm run build-cjs && npm run build-es6"

@@ -44,4 +44,4 @@ },

"dependencies": {
"@ag-grid-community/core": "~22.0.0",
"@ag-grid-enterprise/core": "~22.0.0"
"@ag-grid-community/core": "~22.1.0",
"@ag-grid-enterprise/core": "~22.1.0"
},

@@ -54,2 +54,2 @@ "devDependencies": {

}
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc