/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { Injectable, Optional, SkipSelf } from '@angular/core'; import { DateAdapter } from '@angular/material/core'; import { Subject } from 'rxjs'; import * as i0 from "@angular/core"; import * as i1 from "@angular/material/core"; /** A class representing a range of dates. */ export class DateRange { constructor( /** The start date of the range. */ start, /** The end date of the range. */ end) { this.start = start; this.end = end; } } /** * A selection model containing a date selection. * @docs-private */ export class MatDateSelectionModel { constructor( /** The current selection. */ selection, _adapter) { this.selection = selection; this._adapter = _adapter; this._selectionChanged = new Subject(); /** Emits when the selection has changed. */ this.selectionChanged = this._selectionChanged; this.selection = selection; } /** * Updates the current selection in the model. * @param value New selection that should be assigned. * @param source Object that triggered the selection change. */ updateSelection(value, source) { const oldValue = this.selection; this.selection = value; this._selectionChanged.next({ selection: value, source, oldValue }); } ngOnDestroy() { this._selectionChanged.complete(); } _isValidDateInstance(date) { return this._adapter.isDateInstance(date) && this._adapter.isValid(date); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatDateSelectionModel, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatDateSelectionModel }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatDateSelectionModel, decorators: [{ type: Injectable }], ctorParameters: function () { return [{ type: undefined }, { type: i1.DateAdapter }]; } }); /** * A selection model that contains a single date. * @docs-private */ export class MatSingleDateSelectionModel extends MatDateSelectionModel { constructor(adapter) { super(null, adapter); } /** * Adds a date to the current selection. In the case of a single date selection, the added date * simply overwrites the previous selection */ add(date) { super.updateSelection(date, this); } /** Checks whether the current selection is valid. */ isValid() { return this.selection != null && this._isValidDateInstance(this.selection); } /** * Checks whether the current selection is complete. In the case of a single date selection, this * is true if the current selection is not null. */ isComplete() { return this.selection != null; } /** Clones the selection model. */ clone() { const clone = new MatSingleDateSelectionModel(this._adapter); clone.updateSelection(this.selection, this); return clone; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatSingleDateSelectionModel, deps: [{ token: i1.DateAdapter }], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatSingleDateSelectionModel }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatSingleDateSelectionModel, decorators: [{ type: Injectable }], ctorParameters: function () { return [{ type: i1.DateAdapter }]; } }); /** * A selection model that contains a date range. * @docs-private */ export class MatRangeDateSelectionModel extends MatDateSelectionModel { constructor(adapter) { super(new DateRange(null, null), adapter); } /** * Adds a date to the current selection. In the case of a date range selection, the added date * fills in the next `null` value in the range. If both the start and the end already have a date, * the selection is reset so that the given date is the new `start` and the `end` is null. */ add(date) { let { start, end } = this.selection; if (start == null) { start = date; } else if (end == null) { end = date; } else { start = date; end = null; } super.updateSelection(new DateRange(start, end), this); } /** Checks whether the current selection is valid. */ isValid() { const { start, end } = this.selection; // Empty ranges are valid. if (start == null && end == null) { return true; } // Complete ranges are only valid if both dates are valid and the start is before the end. if (start != null && end != null) { return (this._isValidDateInstance(start) && this._isValidDateInstance(end) && this._adapter.compareDate(start, end) <= 0); } // Partial ranges are valid if the start/end is valid. return ((start == null || this._isValidDateInstance(start)) && (end == null || this._isValidDateInstance(end))); } /** * Checks whether the current selection is complete. In the case of a date range selection, this * is true if the current selection has a non-null `start` and `end`. */ isComplete() { return this.selection.start != null && this.selection.end != null; } /** Clones the selection model. */ clone() { const clone = new MatRangeDateSelectionModel(this._adapter); clone.updateSelection(this.selection, this); return clone; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatRangeDateSelectionModel, deps: [{ token: i1.DateAdapter }], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatRangeDateSelectionModel }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatRangeDateSelectionModel, decorators: [{ type: Injectable }], ctorParameters: function () { return [{ type: i1.DateAdapter }]; } }); /** @docs-private */ export function MAT_SINGLE_DATE_SELECTION_MODEL_FACTORY(parent, adapter) { return parent || new MatSingleDateSelectionModel(adapter); } /** * Used to provide a single selection model to a component. * @docs-private */ export const MAT_SINGLE_DATE_SELECTION_MODEL_PROVIDER = { provide: MatDateSelectionModel, deps: [[new Optional(), new SkipSelf(), MatDateSelectionModel], DateAdapter], useFactory: MAT_SINGLE_DATE_SELECTION_MODEL_FACTORY, }; /** @docs-private */ export function MAT_RANGE_DATE_SELECTION_MODEL_FACTORY(parent, adapter) { return parent || new MatRangeDateSelectionModel(adapter); } /** * Used to provide a range selection model to a component. * @docs-private */ export const MAT_RANGE_DATE_SELECTION_MODEL_PROVIDER = { provide: MatDateSelectionModel, deps: [[new Optional(), new SkipSelf(), MatDateSelectionModel], DateAdapter], useFactory: MAT_RANGE_DATE_SELECTION_MODEL_FACTORY, }; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0ZS1zZWxlY3Rpb24tbW9kZWwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvZGF0ZXBpY2tlci9kYXRlLXNlbGVjdGlvbi1tb2RlbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQWtCLFVBQVUsRUFBRSxRQUFRLEVBQUUsUUFBUSxFQUFZLE1BQU0s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