devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
59 lines (58 loc) • 2.32 kB
JavaScript
/**
* DevExtreme (esm/ui/calendar/ui.calendar.multiple.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/
*/
import CalendarSelectionStrategy from "./ui.calendar.selection.strategy";
class CalendarMultiSelectionStrategy extends CalendarSelectionStrategy {
constructor(component) {
super(component);
this.NAME = "MultiSelection"
}
getViewOptions() {
return {
value: this.dateOption("value"),
range: [],
selectionMode: "multi",
onWeekNumberClick: this._shouldHandleWeekNumberClick() ? this._weekNumberClickHandler.bind(this) : null
}
}
selectValue(selectedValue, e) {
var value = [...this.dateOption("value")];
var alreadySelectedIndex = value.findIndex(date => (null === date || void 0 === date ? void 0 : date.toDateString()) === selectedValue.toDateString());
if (alreadySelectedIndex > -1) {
value.splice(alreadySelectedIndex, 1)
} else {
value.push(selectedValue)
}
this.skipNavigate();
this._updateCurrentDate(selectedValue);
this._currentDateChanged = true;
this.dateValue(value, e)
}
updateAriaSelected(value, previousValue) {
var _value, _previousValue;
null !== (_value = value) && void 0 !== _value ? _value : value = this.dateOption("value");
null !== (_previousValue = previousValue) && void 0 !== _previousValue ? _previousValue : previousValue = [];
super.updateAriaSelected(value, previousValue)
}
getDefaultCurrentDate() {
var dates = this.dateOption("value").filter(value => value);
return this._getLowestDateInArray(dates)
}
restoreValue() {
this.calendar.option("value", [])
}
_weekNumberClickHandler(_ref) {
var {
rowDates: rowDates,
event: event
} = _ref;
var selectedDates = rowDates.filter(date => !this._isDateDisabled(date));
this.dateValue(selectedDates, event)
}
}
export default CalendarMultiSelectionStrategy;