devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
158 lines (153 loc) • 5.77 kB
JavaScript
/**
* DevExtreme (cjs/__internal/scheduler/workspaces/m_cells_selection_state.js)
* Version: 23.2.6
* Build date: Wed May 01 2024
*
* Copyright (c) 2012 - 2024 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;
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) {
descriptor.writable = true
}
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor)
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) {
_defineProperties(Constructor.prototype, protoProps)
}
if (staticProps) {
_defineProperties(Constructor, staticProps)
}
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, "string");
return "symbol" === typeof key ? key : String(key)
}
function _toPrimitive(input, hint) {
if ("object" !== typeof input || null === input) {
return input
}
var prim = input[Symbol.toPrimitive];
if (void 0 !== prim) {
var res = prim.call(input, hint || "default");
if ("object" !== typeof res) {
return res
}
throw new TypeError("@@toPrimitive must return a primitive value.")
}
return ("string" === hint ? String : Number)(input)
}
let CellsSelectionState = function() {
function CellsSelectionState(_viewDataProvider) {
this._viewDataProvider = _viewDataProvider;
this._focusedCell = null;
this._selectedCells = null;
this._firstSelectedCell = null;
this._prevFocusedCell = null;
this._prevSelectedCells = null
}
var _proto = CellsSelectionState.prototype;
_proto.setFocusedCell = function(rowIndex, columnIndex, isAllDay) {
if (rowIndex >= 0) {
const cell = this._viewDataProvider.getCellData(rowIndex, columnIndex, isAllDay);
this._focusedCell = cell
}
};
_proto.setSelectedCells = function(lastCellCoordinates) {
let firstCellCoordinates = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : void 0;
const viewDataProvider = this._viewDataProvider;
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)
};
_proto.setSelectedCellsByData = function(selectedCellsData) {
this._selectedCells = selectedCellsData
};
_proto.getSelectedCells = function() {
return this._selectedCells
};
_proto.releaseSelectedAndFocusedCells = function() {
this.releaseSelectedCells();
this.releaseFocusedCell()
};
_proto.releaseSelectedCells = function() {
this._prevSelectedCells = this._selectedCells;
this._prevFirstSelectedCell = this._firstSelectedCell;
this._selectedCells = null;
this._firstSelectedCell = null
};
_proto.releaseFocusedCell = function() {
this._prevFocusedCell = this._focusedCell;
this._focusedCell = null
};
_proto.restoreSelectedAndFocusedCells = function() {
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
};
_proto.clearSelectedAndFocusedCells = function() {
this._prevSelectedCells = null;
this._selectedCells = null;
this._prevFocusedCell = null;
this._focusedCell = null
};
_createClass(CellsSelectionState, [{
key: "viewDataProvider",
get: function() {
return this._viewDataProvider
}
}, {
key: "focusedCell",
get: function() {
const focusedCell = this._focusedCell;
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
}
}
}]);
return CellsSelectionState
}();
exports.default = CellsSelectionState;