UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

58 lines (57 loc) 2.18 kB
/** * DevExtreme (esm/__internal/ui/calendar/m_calendar.multiple.selection.strategy.js) * Version: 24.2.7 * Build date: Mon Apr 28 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import CalendarSelectionStrategy from "./m_calendar.selection.strategy"; class CalendarMultiSelectionStrategy extends CalendarSelectionStrategy { constructor(component) { super(component); this.NAME = "MultiSelection" } getViewOptions() { return { value: this.dateOption("value"), range: [], selectionMode: "multiple", onWeekNumberClick: this._shouldHandleWeekNumberClick() ? this._weekNumberClickHandler.bind(this) : null } } selectValue(selectedValue, e) { const value = [...this.dateOption("value")]; const 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) { value ?? (value = this.dateOption("value")); previousValue ?? (previousValue = []); super.updateAriaSelected(value, previousValue) } getDefaultCurrentDate() { const dates = this.dateOption("value").filter(Boolean); return this._getLowestDateInArray(dates) } restoreValue() { this.calendar.option("value", []) } _weekNumberClickHandler(_ref) { let { rowDates: rowDates, event: event } = _ref; const selectedDates = rowDates.filter((date => !this._isDateDisabled(date))); this.dateValue(selectedDates, event) } } export default CalendarMultiSelectionStrategy;