devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
96 lines (94 loc) • 3.97 kB
JavaScript
/**
* DevExtreme (cjs/ui/calendar/ui.calendar.selection.strategy.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/
*/
;
exports.default = void 0;
var _type = require("../../core/utils/type");
var _date = _interopRequireDefault(require("../../core/utils/date"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
}
}
let CalendarSelectionStrategy = function() {
function CalendarSelectionStrategy(component) {
this.calendar = component
}
var _proto = CalendarSelectionStrategy.prototype;
_proto.dateOption = function(optionName) {
return this.calendar._dateOption(optionName)
};
_proto.dateValue = function(value, e) {
this.calendar._dateValue(value, e)
};
_proto.skipNavigate = function() {
this.calendar._skipNavigate = true
};
_proto.updateAriaSelected = function(value, previousValue) {
this.calendar._updateAriaSelected(value, previousValue);
if (value[0] && this.calendar.option("currentDate").getTime() === value[0].getTime()) {
this.calendar._updateAriaId(value[0])
}
};
_proto.processValueChanged = function(value, previousValue) {
var _value, _previousValue;
if ((0, _type.isDefined)(value) && !Array.isArray(value)) {
value = [value]
}
if ((0, _type.isDefined)(previousValue) && !Array.isArray(previousValue)) {
previousValue = [previousValue]
}
value = (null === (_value = value) || void 0 === _value ? void 0 : _value.map(item => this._convertToDate(item))) || [];
previousValue = (null === (_previousValue = previousValue) || void 0 === _previousValue ? void 0 : _previousValue.map(item => this._convertToDate(item))) || [];
this._updateViewsValue(value);
this.updateAriaSelected(value, previousValue);
if (!this._currentDateChanged) {
this.calendar._initCurrentDate()
}
this._currentDateChanged = false
};
_proto._isDateDisabled = function(date) {
const min = this.calendar._dateOption("min");
const max = this.calendar._dateOption("max");
const isLessThanMin = (0, _type.isDefined)(min) && date < min && !_date.default.sameDate(min, date);
const isBiggerThanMax = (0, _type.isDefined)(max) && date > max && !_date.default.sameDate(max, date);
return this.calendar._view.isDateDisabled(date) || isLessThanMin || isBiggerThanMax
};
_proto._getLowestDateInArray = function(dates) {
if (dates.length) {
return new Date(Math.min(...dates))
}
};
_proto._convertToDate = function(value) {
return this.calendar._convertToDate(value)
};
_proto._isMaxZoomLevel = function() {
return this.calendar._isMaxZoomLevel()
};
_proto._updateViewsOption = function(optionName, optionValue) {
this.calendar._updateViewsOption(optionName, optionValue)
};
_proto._updateViewsValue = function(value) {
this._updateViewsOption("value", value)
};
_proto._updateCurrentDate = function(value) {
this.calendar.option("currentDate", null !== value && void 0 !== value ? value : new Date)
};
_proto._shouldHandleWeekNumberClick = function() {
const {
selectionMode: selectionMode,
selectWeekOnClick: selectWeekOnClick
} = this.calendar.option();
return selectWeekOnClick && "single" !== selectionMode
};
return CalendarSelectionStrategy
}();
var _default = CalendarSelectionStrategy;
exports.default = _default;
module.exports = exports.default;
module.exports.default = exports.default;