MCPcopy Create free account
hub / github.com/UI5/webcomponents / _multipleSelection

Method _multipleSelection

packages/main/src/DayPicker.ts:623–657  ·  view source on GitHub ↗

* Called when at least one day is selected and the user presses "Shift". * @param timestamp * @private

(timestamp: number)

Source from the content-addressed store, hash-verified

621 * @private
622 */
623 _multipleSelection(timestamp: number) {
624 const min = Math.min(...this.selectedDates);
625 const max = Math.max(...this.selectedDates);
626 let start;
627 let end;
628 let toggle = false;
629
630 if (timestamp < min) {
631 start = timestamp;
632 end = min;
633 } else if (timestamp >= min && timestamp <= max) { // inside the current range - toggle all between the selected and focused
634 const distanceToMin = Math.abs(timestamp - min);
635 const distanceToMax = Math.abs(timestamp - max);
636
637 if (distanceToMin < distanceToMax) {
638 start = timestamp;
639 end = max;
640 } else {
641 start = min;
642 end = timestamp;
643 }
644 toggle = true;
645 } else {
646 start = max;
647 end = timestamp;
648 }
649
650 const startDate = CalendarDate.fromTimestamp(start * 1000);
651 const endDate = CalendarDate.fromTimestamp(end * 1000);
652
653 while (startDate.valueOf() <= endDate.valueOf()) {
654 this[toggle ? "_toggleTimestampInSelection" : "_addTimestampToSelection"](startDate.valueOf() / 1000);
655 startDate.setDate(startDate.getDate() + 1);
656 }
657 }
658
659 /**
660 * Set the hovered day as the "_secondTimestamp".

Callers 1

_updateSelectedDatesMethod · 0.95

Calls 4

fromTimestampMethod · 0.80
valueOfMethod · 0.80
setDateMethod · 0.80
getDateMethod · 0.80

Tested by

no test coverage detected