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 { Directive, ElementRef, forwardRef, Inject, Input, Optional, } from '@angular/core';
|
---|
9 | import { NG_VALIDATORS, NG_VALUE_ACCESSOR, Validators, } from '@angular/forms';
|
---|
10 | import { DateAdapter, MAT_DATE_FORMATS, } from '@angular/material/core';
|
---|
11 | import { MatFormField, MAT_FORM_FIELD } from '@angular/material/form-field';
|
---|
12 | import { MAT_INPUT_VALUE_ACCESSOR } from '@angular/material/input';
|
---|
13 | import { Subscription } from 'rxjs';
|
---|
14 | import { MatDatepickerInputBase } from './datepicker-input-base';
|
---|
15 | /** @docs-private */
|
---|
16 | export const MAT_DATEPICKER_VALUE_ACCESSOR = {
|
---|
17 | provide: NG_VALUE_ACCESSOR,
|
---|
18 | useExisting: forwardRef(() => MatDatepickerInput),
|
---|
19 | multi: true
|
---|
20 | };
|
---|
21 | /** @docs-private */
|
---|
22 | export const MAT_DATEPICKER_VALIDATORS = {
|
---|
23 | provide: NG_VALIDATORS,
|
---|
24 | useExisting: forwardRef(() => MatDatepickerInput),
|
---|
25 | multi: true
|
---|
26 | };
|
---|
27 | /** Directive used to connect an input to a MatDatepicker. */
|
---|
28 | export class MatDatepickerInput extends MatDatepickerInputBase {
|
---|
29 | constructor(elementRef, dateAdapter, dateFormats, _formField) {
|
---|
30 | super(elementRef, dateAdapter, dateFormats);
|
---|
31 | this._formField = _formField;
|
---|
32 | this._closedSubscription = Subscription.EMPTY;
|
---|
33 | this._validator = Validators.compose(super._getValidators());
|
---|
34 | }
|
---|
35 | /** The datepicker that this input is associated with. */
|
---|
36 | set matDatepicker(datepicker) {
|
---|
37 | if (datepicker) {
|
---|
38 | this._datepicker = datepicker;
|
---|
39 | this._closedSubscription = datepicker.closedStream.subscribe(() => this._onTouched());
|
---|
40 | this._registerModel(datepicker.registerInput(this));
|
---|
41 | }
|
---|
42 | }
|
---|
43 | /** The minimum valid date. */
|
---|
44 | get min() { return this._min; }
|
---|
45 | set min(value) {
|
---|
46 | const validValue = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
|
---|
47 | if (!this._dateAdapter.sameDate(validValue, this._min)) {
|
---|
48 | this._min = validValue;
|
---|
49 | this._validatorOnChange();
|
---|
50 | }
|
---|
51 | }
|
---|
52 | /** The maximum valid date. */
|
---|
53 | get max() { return this._max; }
|
---|
54 | set max(value) {
|
---|
55 | const validValue = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
|
---|
56 | if (!this._dateAdapter.sameDate(validValue, this._max)) {
|
---|
57 | this._max = validValue;
|
---|
58 | this._validatorOnChange();
|
---|
59 | }
|
---|
60 | }
|
---|
61 | /** Function that can be used to filter out dates within the datepicker. */
|
---|
62 | get dateFilter() { return this._dateFilter; }
|
---|
63 | set dateFilter(value) {
|
---|
64 | const wasMatchingValue = this._matchesFilter(this.value);
|
---|
65 | this._dateFilter = value;
|
---|
66 | if (this._matchesFilter(this.value) !== wasMatchingValue) {
|
---|
67 | this._validatorOnChange();
|
---|
68 | }
|
---|
69 | }
|
---|
70 | /**
|
---|
71 | * Gets the element that the datepicker popup should be connected to.
|
---|
72 | * @return The element to connect the popup to.
|
---|
73 | */
|
---|
74 | getConnectedOverlayOrigin() {
|
---|
75 | return this._formField ? this._formField.getConnectedOverlayOrigin() : this._elementRef;
|
---|
76 | }
|
---|
77 | /** Gets the ID of an element that should be used a description for the calendar overlay. */
|
---|
78 | getOverlayLabelId() {
|
---|
79 | if (this._formField) {
|
---|
80 | return this._formField.getLabelId();
|
---|
81 | }
|
---|
82 | return this._elementRef.nativeElement.getAttribute('aria-labelledby');
|
---|
83 | }
|
---|
84 | /** Returns the palette used by the input's form field, if any. */
|
---|
85 | getThemePalette() {
|
---|
86 | return this._formField ? this._formField.color : undefined;
|
---|
87 | }
|
---|
88 | /** Gets the value at which the calendar should start. */
|
---|
89 | getStartValue() {
|
---|
90 | return this.value;
|
---|
91 | }
|
---|
92 | ngOnDestroy() {
|
---|
93 | super.ngOnDestroy();
|
---|
94 | this._closedSubscription.unsubscribe();
|
---|
95 | }
|
---|
96 | /** Opens the associated datepicker. */
|
---|
97 | _openPopup() {
|
---|
98 | if (this._datepicker) {
|
---|
99 | this._datepicker.open();
|
---|
100 | }
|
---|
101 | }
|
---|
102 | _getValueFromModel(modelValue) {
|
---|
103 | return modelValue;
|
---|
104 | }
|
---|
105 | _assignValueToModel(value) {
|
---|
106 | if (this._model) {
|
---|
107 | this._model.updateSelection(value, this);
|
---|
108 | }
|
---|
109 | }
|
---|
110 | /** Gets the input's minimum date. */
|
---|
111 | _getMinDate() {
|
---|
112 | return this._min;
|
---|
113 | }
|
---|
114 | /** Gets the input's maximum date. */
|
---|
115 | _getMaxDate() {
|
---|
116 | return this._max;
|
---|
117 | }
|
---|
118 | /** Gets the input's date filtering function. */
|
---|
119 | _getDateFilter() {
|
---|
120 | return this._dateFilter;
|
---|
121 | }
|
---|
122 | _shouldHandleChangeEvent(event) {
|
---|
123 | return event.source !== this;
|
---|
124 | }
|
---|
125 | }
|
---|
126 | MatDatepickerInput.decorators = [
|
---|
127 | { type: Directive, args: [{
|
---|
128 | selector: 'input[matDatepicker]',
|
---|
129 | providers: [
|
---|
130 | MAT_DATEPICKER_VALUE_ACCESSOR,
|
---|
131 | MAT_DATEPICKER_VALIDATORS,
|
---|
132 | { provide: MAT_INPUT_VALUE_ACCESSOR, useExisting: MatDatepickerInput },
|
---|
133 | ],
|
---|
134 | host: {
|
---|
135 | 'class': 'mat-datepicker-input',
|
---|
136 | '[attr.aria-haspopup]': '_datepicker ? "dialog" : null',
|
---|
137 | '[attr.aria-owns]': '(_datepicker?.opened && _datepicker.id) || null',
|
---|
138 | '[attr.min]': 'min ? _dateAdapter.toIso8601(min) : null',
|
---|
139 | '[attr.max]': 'max ? _dateAdapter.toIso8601(max) : null',
|
---|
140 | // Used by the test harness to tie this input to its calendar. We can't depend on
|
---|
141 | // `aria-owns` for this, because it's only defined while the calendar is open.
|
---|
142 | '[attr.data-mat-calendar]': '_datepicker ? _datepicker.id : null',
|
---|
143 | '[disabled]': 'disabled',
|
---|
144 | '(input)': '_onInput($event.target.value)',
|
---|
145 | '(change)': '_onChange()',
|
---|
146 | '(blur)': '_onBlur()',
|
---|
147 | '(keydown)': '_onKeydown($event)',
|
---|
148 | },
|
---|
149 | exportAs: 'matDatepickerInput',
|
---|
150 | },] }
|
---|
151 | ];
|
---|
152 | MatDatepickerInput.ctorParameters = () => [
|
---|
153 | { type: ElementRef },
|
---|
154 | { type: DateAdapter, decorators: [{ type: Optional }] },
|
---|
155 | { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DATE_FORMATS,] }] },
|
---|
156 | { type: MatFormField, decorators: [{ type: Optional }, { type: Inject, args: [MAT_FORM_FIELD,] }] }
|
---|
157 | ];
|
---|
158 | MatDatepickerInput.propDecorators = {
|
---|
159 | matDatepicker: [{ type: Input }],
|
---|
160 | min: [{ type: Input }],
|
---|
161 | max: [{ type: Input }],
|
---|
162 | dateFilter: [{ type: Input, args: ['matDatepickerFilter',] }]
|
---|
163 | };
|
---|
164 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0ZXBpY2tlci1pbnB1dC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9kYXRlcGlja2VyL2RhdGVwaWNrZXItaW5wdXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUNMLFNBQVMsRUFDVCxVQUFVLEVBQ1YsVUFBVSxFQUNWLE1BQU0sRUFDTixLQUFLLEVBRUwsUUFBUSxHQUNULE1BQU0sZUFBZSxDQUFDO0FBQ3ZCLE9B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