MCPcopy Create free account
hub / github.com/angular/components / _previewChanged

Method _previewChanged

src/material/datepicker/month-view.ts:439–466  ·  view source on GitHub ↗

Called when the user has activated a new cell and the preview needs to be updated.

({event, value: cell}: MatCalendarUserEvent<MatCalendarCell<D> | null>)

Source from the content-addressed store, hash-verified

437
438 /** Called when the user has activated a new cell and the preview needs to be updated. */
439 _previewChanged({event, value: cell}: MatCalendarUserEvent<MatCalendarCell<D> | null>) {
440 if (this._rangeStrategy) {
441 // We can assume that this will be a range, because preview
442 // events aren't fired for single date selections.
443 const value = cell ? cell.rawValue! : null;
444 const previewRange = this._rangeStrategy.createPreview(
445 value,
446 this.selected as DateRange<D>,
447 event,
448 );
449 this._previewStart.set(this._getCellCompareValue(previewRange.start));
450 this._previewEnd.set(this._getCellCompareValue(previewRange.end));
451
452 if (this.activeDrag && value) {
453 const dragRange = this._rangeStrategy.createDrag?.(
454 this.activeDrag.value,
455 this.selected as DateRange<D>,
456 value,
457 event,
458 );
459
460 if (dragRange) {
461 this._previewStart.set(this._getCellCompareValue(dragRange.start));
462 this._previewEnd.set(this._getCellCompareValue(dragRange.end));
463 }
464 }
465 }
466 }
467
468 /**
469 * Called when the user has ended a drag. If the drag/drop was successful,

Callers

nothing calls this directly

Calls 4

_getCellCompareValueMethod · 0.95
setMethod · 0.80
createPreviewMethod · 0.65
createDragMethod · 0.65

Tested by

no test coverage detected