devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
94 lines (93 loc) • 3.31 kB
JavaScript
/**
* DevExtreme (cjs/__internal/scheduler/workspaces/cells_selection_state.js)
* Version: 26.1.4
* Build date: Fri Jul 24 2026
*
* Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
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 cellPosition = this.viewDataProvider.findCellPositionInMap(focusedCell);
return {
coordinates: cellPosition,
cellData: focusedCell
}
}
setFocusedCell(rowIndex, columnIndex, isAllDay) {
if (rowIndex >= 0) {
this.focusedCell = this.viewDataProvider.getCellData(rowIndex, columnIndex, isAllDay)
}
}
setSelectedCells(lastCellCoordinates, firstCellCoordinates) {
const {
viewDataProvider: viewDataProvider
} = this;
const {
rowIndex: lastRowIndex,
columnIndex: lastColumnIndex,
allDay: isLastCellAllDay
} = lastCellCoordinates;
if (lastRowIndex < 0) {
return
}
const lastCell = viewDataProvider.getCellData(lastRowIndex, lastColumnIndex, isLastCellAllDay);
const firstCell = firstCellCoordinates ? viewDataProvider.getCellData(firstCellCoordinates.rowIndex, firstCellCoordinates.columnIndex, firstCellCoordinates.allDay) : this.firstSelectedCell ?? lastCell;
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 ?? null;
this.prevSelectedCells = null;
this.prevFirstSelectedCell = null;
this.prevFocusedCell = null
}
clearSelectedAndFocusedCells() {
this.prevSelectedCells = null;
this.selectedCells = null;
this.prevFocusedCell = null;
this.focusedCell = null
}
}
exports.default = CellsSelectionState;