1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { Injectable, Optional, SkipSelf } from '@angular/core';
|
---|
9 | import { DateAdapter } from '@angular/material/core';
|
---|
10 | import { Subject } from 'rxjs';
|
---|
11 | /** A class representing a range of dates. */
|
---|
12 | export class DateRange {
|
---|
13 | constructor(
|
---|
14 | /** The start date of the range. */
|
---|
15 | start,
|
---|
16 | /** The end date of the range. */
|
---|
17 | end) {
|
---|
18 | this.start = start;
|
---|
19 | this.end = end;
|
---|
20 | }
|
---|
21 | }
|
---|
22 | /**
|
---|
23 | * A selection model containing a date selection.
|
---|
24 | * @docs-private
|
---|
25 | */
|
---|
26 | export class MatDateSelectionModel {
|
---|
27 | constructor(
|
---|
28 | /** The current selection. */
|
---|
29 | selection, _adapter) {
|
---|
30 | this.selection = selection;
|
---|
31 | this._adapter = _adapter;
|
---|
32 | this._selectionChanged = new Subject();
|
---|
33 | /** Emits when the selection has changed. */
|
---|
34 | this.selectionChanged = this._selectionChanged;
|
---|
35 | this.selection = selection;
|
---|
36 | }
|
---|
37 | /**
|
---|
38 | * Updates the current selection in the model.
|
---|
39 | * @param value New selection that should be assigned.
|
---|
40 | * @param source Object that triggered the selection change.
|
---|
41 | */
|
---|
42 | updateSelection(value, source) {
|
---|
43 | const oldValue = this.selection;
|
---|
44 | this.selection = value;
|
---|
45 | this._selectionChanged.next({ selection: value, source, oldValue });
|
---|
46 | }
|
---|
47 | ngOnDestroy() {
|
---|
48 | this._selectionChanged.complete();
|
---|
49 | }
|
---|
50 | _isValidDateInstance(date) {
|
---|
51 | return this._adapter.isDateInstance(date) && this._adapter.isValid(date);
|
---|
52 | }
|
---|
53 | }
|
---|
54 | MatDateSelectionModel.decorators = [
|
---|
55 | { type: Injectable }
|
---|
56 | ];
|
---|
57 | MatDateSelectionModel.ctorParameters = () => [
|
---|
58 | { type: undefined },
|
---|
59 | { type: DateAdapter }
|
---|
60 | ];
|
---|
61 | /**
|
---|
62 | * A selection model that contains a single date.
|
---|
63 | * @docs-private
|
---|
64 | */
|
---|
65 | export class MatSingleDateSelectionModel extends MatDateSelectionModel {
|
---|
66 | constructor(adapter) {
|
---|
67 | super(null, adapter);
|
---|
68 | }
|
---|
69 | /**
|
---|
70 | * Adds a date to the current selection. In the case of a single date selection, the added date
|
---|
71 | * simply overwrites the previous selection
|
---|
72 | */
|
---|
73 | add(date) {
|
---|
74 | super.updateSelection(date, this);
|
---|
75 | }
|
---|
76 | /** Checks whether the current selection is valid. */
|
---|
77 | isValid() {
|
---|
78 | return this.selection != null && this._isValidDateInstance(this.selection);
|
---|
79 | }
|
---|
80 | /**
|
---|
81 | * Checks whether the current selection is complete. In the case of a single date selection, this
|
---|
82 | * is true if the current selection is not null.
|
---|
83 | */
|
---|
84 | isComplete() {
|
---|
85 | return this.selection != null;
|
---|
86 | }
|
---|
87 | /** Clones the selection model. */
|
---|
88 | clone() {
|
---|
89 | const clone = new MatSingleDateSelectionModel(this._adapter);
|
---|
90 | clone.updateSelection(this.selection, this);
|
---|
91 | return clone;
|
---|
92 | }
|
---|
93 | }
|
---|
94 | MatSingleDateSelectionModel.decorators = [
|
---|
95 | { type: Injectable }
|
---|
96 | ];
|
---|
97 | MatSingleDateSelectionModel.ctorParameters = () => [
|
---|
98 | { type: DateAdapter }
|
---|
99 | ];
|
---|
100 | /**
|
---|
101 | * A selection model that contains a date range.
|
---|
102 | * @docs-private
|
---|
103 | */
|
---|
104 | export class MatRangeDateSelectionModel extends MatDateSelectionModel {
|
---|
105 | constructor(adapter) {
|
---|
106 | super(new DateRange(null, null), adapter);
|
---|
107 | }
|
---|
108 | /**
|
---|
109 | * Adds a date to the current selection. In the case of a date range selection, the added date
|
---|
110 | * fills in the next `null` value in the range. If both the start and the end already have a date,
|
---|
111 | * the selection is reset so that the given date is the new `start` and the `end` is null.
|
---|
112 | */
|
---|
113 | add(date) {
|
---|
114 | let { start, end } = this.selection;
|
---|
115 | if (start == null) {
|
---|
116 | start = date;
|
---|
117 | }
|
---|
118 | else if (end == null) {
|
---|
119 | end = date;
|
---|
120 | }
|
---|
121 | else {
|
---|
122 | start = date;
|
---|
123 | end = null;
|
---|
124 | }
|
---|
125 | super.updateSelection(new DateRange(start, end), this);
|
---|
126 | }
|
---|
127 | /** Checks whether the current selection is valid. */
|
---|
128 | isValid() {
|
---|
129 | const { start, end } = this.selection;
|
---|
130 | // Empty ranges are valid.
|
---|
131 | if (start == null && end == null) {
|
---|
132 | return true;
|
---|
133 | }
|
---|
134 | // Complete ranges are only valid if both dates are valid and the start is before the end.
|
---|
135 | if (start != null && end != null) {
|
---|
136 | return this._isValidDateInstance(start) && this._isValidDateInstance(end) &&
|
---|
137 | this._adapter.compareDate(start, end) <= 0;
|
---|
138 | }
|
---|
139 | // Partial ranges are valid if the start/end is valid.
|
---|
140 | return (start == null || this._isValidDateInstance(start)) &&
|
---|
141 | (end == null || this._isValidDateInstance(end));
|
---|
142 | }
|
---|
143 | /**
|
---|
144 | * Checks whether the current selection is complete. In the case of a date range selection, this
|
---|
145 | * is true if the current selection has a non-null `start` and `end`.
|
---|
146 | */
|
---|
147 | isComplete() {
|
---|
148 | return this.selection.start != null && this.selection.end != null;
|
---|
149 | }
|
---|
150 | /** Clones the selection model. */
|
---|
151 | clone() {
|
---|
152 | const clone = new MatRangeDateSelectionModel(this._adapter);
|
---|
153 | clone.updateSelection(this.selection, this);
|
---|
154 | return clone;
|
---|
155 | }
|
---|
156 | }
|
---|
157 | MatRangeDateSelectionModel.decorators = [
|
---|
158 | { type: Injectable }
|
---|
159 | ];
|
---|
160 | MatRangeDateSelectionModel.ctorParameters = () => [
|
---|
161 | { type: DateAdapter }
|
---|
162 | ];
|
---|
163 | /** @docs-private */
|
---|
164 | export function MAT_SINGLE_DATE_SELECTION_MODEL_FACTORY(parent, adapter) {
|
---|
165 | return parent || new MatSingleDateSelectionModel(adapter);
|
---|
166 | }
|
---|
167 | /**
|
---|
168 | * Used to provide a single selection model to a component.
|
---|
169 | * @docs-private
|
---|
170 | */
|
---|
171 | export const MAT_SINGLE_DATE_SELECTION_MODEL_PROVIDER = {
|
---|
172 | provide: MatDateSelectionModel,
|
---|
173 | deps: [[new Optional(), new SkipSelf(), MatDateSelectionModel], DateAdapter],
|
---|
174 | useFactory: MAT_SINGLE_DATE_SELECTION_MODEL_FACTORY,
|
---|
175 | };
|
---|
176 | /** @docs-private */
|
---|
177 | export function MAT_RANGE_DATE_SELECTION_MODEL_FACTORY(parent, adapter) {
|
---|
178 | return parent || new MatRangeDateSelectionModel(adapter);
|
---|
179 | }
|
---|
180 | /**
|
---|
181 | * Used to provide a range selection model to a component.
|
---|
182 | * @docs-private
|
---|
183 | */
|
---|
184 | export const MAT_RANGE_DATE_SELECTION_MODEL_PROVIDER = {
|
---|
185 | provide: MatDateSelectionModel,
|
---|
186 | deps: [[new Optional(), new SkipSelf(), MatDateSelectionModel], DateAdapter],
|
---|
187 | useFactory: MAT_RANGE_DATE_SELECTION_MODEL_FACTORY,
|
---|
188 | };
|
---|
189 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0ZS1zZWxlY3Rpb24tbW9kZWwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvZGF0ZXBpY2tlci9kYXRlLXNlbGVjdGlvbi1tb2RlbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQWtCLFVBQVUsRUFBRSxRQUFRLEVBQUUsUUFBUSxFQUFZLE1BQU0sZUFBZSxDQUFDO0FBQ3pGLE9BQU8sRUFBQyxXQUFXLEVBQUMsTUFBTSx3QkFBd0IsQ0FBQztBQUNuRCxPQUFPLEVBQWEsT0FBTy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