devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
101 lines (100 loc) • 3.69 kB
JavaScript
/**
* DevExtreme (esm/__internal/scheduler/workspaces/m_cells_selection_state.js)
* Version: 25.2.7
* Build date: Tue May 05 2026
*
* Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
export default class CellsSelectionState {
constructor(viewDataProvider) {
this.viewDataProvider = viewDataProvider;
this.focusedCell = null;
this.selectedCells = null;
this.firstSelectedCell = null;
this.prevFocusedCell = null;
this.prevSelectedCells = null
}
getFocusedCell() {
const {
focusedCell: focusedCell
} = this;
if (!focusedCell) {
return
}
const {
groupIndex: groupIndex,
startDate: startDate,
allDay: allDay
} = focusedCell;
const cellInfo = {
groupIndex: groupIndex,
startDate: startDate,
isAllDay: allDay,
index: focusedCell.index
};
const cellPosition = this.viewDataProvider.findCellPositionInMap(cellInfo);
return {
coordinates: cellPosition,
cellData: focusedCell
}
}
setFocusedCell(rowIndex, columnIndex, isAllDay) {
if (rowIndex >= 0) {
const cell = this.viewDataProvider.getCellData(rowIndex, columnIndex, isAllDay);
this.focusedCell = cell
}
}
setSelectedCells(lastCellCoordinates) {
let firstCellCoordinates = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : void 0;
const {
viewDataProvider: viewDataProvider
} = this;
const {
rowIndex: lastRowIndex,
columnIndex: lastColumnIndex,
allDay: isLastCellAllDay
} = lastCellCoordinates;
if (lastRowIndex < 0) {
return
}
const firstCell = firstCellCoordinates ? viewDataProvider.getCellData(firstCellCoordinates.rowIndex, firstCellCoordinates.columnIndex, firstCellCoordinates.allDay) : this.firstSelectedCell;
const lastCell = viewDataProvider.getCellData(lastRowIndex, lastColumnIndex, isLastCellAllDay);
this.firstSelectedCell = firstCell;
this.selectedCells = this.viewDataProvider.getCellsBetween(firstCell, lastCell)
}
setSelectedCellsByData(selectedCellsData) {
this.selectedCells = selectedCellsData
}
getSelectedCells() {
return this.selectedCells
}
releaseSelectedAndFocusedCells() {
this.releaseSelectedCells();
this.releaseFocusedCell()
}
releaseSelectedCells() {
this.prevSelectedCells = this.selectedCells;
this.prevFirstSelectedCell = this.firstSelectedCell;
this.selectedCells = null;
this.firstSelectedCell = null
}
releaseFocusedCell() {
this.prevFocusedCell = this.focusedCell;
this.focusedCell = null
}
restoreSelectedAndFocusedCells() {
this.selectedCells = this.selectedCells || this.prevSelectedCells;
this.focusedCell = this.focusedCell || this.prevFocusedCell;
this.firstSelectedCell = this.firstSelectedCell || this.prevFirstSelectedCell;
this.prevSelectedCells = null;
this.prevFirstSelectedCell = null;
this.prevFocusedCell = null
}
clearSelectedAndFocusedCells() {
this.prevSelectedCells = null;
this.selectedCells = null;
this.prevFocusedCell = null;
this.focusedCell = null
}
}