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 { coerceBooleanProperty } from '@angular/cdk/coercion';
|
---|
9 | import { Attribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, Directive, Input, ViewEncapsulation, ViewChild, } from '@angular/core';
|
---|
10 | import { MatButton } from '@angular/material/button';
|
---|
11 | import { merge, of as observableOf, Subscription } from 'rxjs';
|
---|
12 | import { MatDatepickerIntl } from './datepicker-intl';
|
---|
13 | /** Can be used to override the icon of a `matDatepickerToggle`. */
|
---|
14 | export class MatDatepickerToggleIcon {
|
---|
15 | }
|
---|
16 | MatDatepickerToggleIcon.decorators = [
|
---|
17 | { type: Directive, args: [{
|
---|
18 | selector: '[matDatepickerToggleIcon]'
|
---|
19 | },] }
|
---|
20 | ];
|
---|
21 | export class MatDatepickerToggle {
|
---|
22 | constructor(_intl, _changeDetectorRef, defaultTabIndex) {
|
---|
23 | this._intl = _intl;
|
---|
24 | this._changeDetectorRef = _changeDetectorRef;
|
---|
25 | this._stateChanges = Subscription.EMPTY;
|
---|
26 | const parsedTabIndex = Number(defaultTabIndex);
|
---|
27 | this.tabIndex = (parsedTabIndex || parsedTabIndex === 0) ? parsedTabIndex : null;
|
---|
28 | }
|
---|
29 | /** Whether the toggle button is disabled. */
|
---|
30 | get disabled() {
|
---|
31 | if (this._disabled === undefined && this.datepicker) {
|
---|
32 | return this.datepicker.disabled;
|
---|
33 | }
|
---|
34 | return !!this._disabled;
|
---|
35 | }
|
---|
36 | set disabled(value) {
|
---|
37 | this._disabled = coerceBooleanProperty(value);
|
---|
38 | }
|
---|
39 | ngOnChanges(changes) {
|
---|
40 | if (changes['datepicker']) {
|
---|
41 | this._watchStateChanges();
|
---|
42 | }
|
---|
43 | }
|
---|
44 | ngOnDestroy() {
|
---|
45 | this._stateChanges.unsubscribe();
|
---|
46 | }
|
---|
47 | ngAfterContentInit() {
|
---|
48 | this._watchStateChanges();
|
---|
49 | }
|
---|
50 | _open(event) {
|
---|
51 | if (this.datepicker && !this.disabled) {
|
---|
52 | this.datepicker.open();
|
---|
53 | event.stopPropagation();
|
---|
54 | }
|
---|
55 | }
|
---|
56 | _watchStateChanges() {
|
---|
57 | const datepickerStateChanged = this.datepicker ? this.datepicker.stateChanges : observableOf();
|
---|
58 | const inputStateChanged = this.datepicker && this.datepicker.datepickerInput ?
|
---|
59 | this.datepicker.datepickerInput.stateChanges : observableOf();
|
---|
60 | const datepickerToggled = this.datepicker ?
|
---|
61 | merge(this.datepicker.openedStream, this.datepicker.closedStream) :
|
---|
62 | observableOf();
|
---|
63 | this._stateChanges.unsubscribe();
|
---|
64 | this._stateChanges = merge(this._intl.changes, datepickerStateChanged, inputStateChanged, datepickerToggled).subscribe(() => this._changeDetectorRef.markForCheck());
|
---|
65 | }
|
---|
66 | }
|
---|
67 | MatDatepickerToggle.decorators = [
|
---|
68 | { type: Component, args: [{
|
---|
69 | selector: 'mat-datepicker-toggle',
|
---|
70 | template: "<button\n #button\n mat-icon-button\n type=\"button\"\n [attr.aria-haspopup]=\"datepicker ? 'dialog' : null\"\n [attr.aria-label]=\"ariaLabel || _intl.openCalendarLabel\"\n [attr.tabindex]=\"disabled ? -1 : tabIndex\"\n [disabled]=\"disabled\"\n [disableRipple]=\"disableRipple\">\n\n <svg\n *ngIf=\"!_customIcon\"\n class=\"mat-datepicker-toggle-default-icon\"\n viewBox=\"0 0 24 24\"\n width=\"24px\"\n height=\"24px\"\n fill=\"currentColor\"\n focusable=\"false\">\n <path d=\"M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z\"/>\n </svg>\n\n <ng-content select=\"[matDatepickerToggleIcon]\"></ng-content>\n</button>\n",
|
---|
71 | host: {
|
---|
72 | 'class': 'mat-datepicker-toggle',
|
---|
73 | '[attr.tabindex]': 'null',
|
---|
74 | '[class.mat-datepicker-toggle-active]': 'datepicker && datepicker.opened',
|
---|
75 | '[class.mat-accent]': 'datepicker && datepicker.color === "accent"',
|
---|
76 | '[class.mat-warn]': 'datepicker && datepicker.color === "warn"',
|
---|
77 | // Used by the test harness to tie this toggle to its datepicker.
|
---|
78 | '[attr.data-mat-calendar]': 'datepicker ? datepicker.id : null',
|
---|
79 | // Bind the `click` on the host, rather than the inner `button`, so that we can call
|
---|
80 | // `stopPropagation` on it without affecting the user's `click` handlers. We need to stop
|
---|
81 | // it so that the input doesn't get focused automatically by the form field (See #21836).
|
---|
82 | '(click)': '_open($event)',
|
---|
83 | },
|
---|
84 | exportAs: 'matDatepickerToggle',
|
---|
85 | encapsulation: ViewEncapsulation.None,
|
---|
86 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
87 | styles: [".mat-form-field-appearance-legacy .mat-form-field-prefix .mat-datepicker-toggle-default-icon,.mat-form-field-appearance-legacy .mat-form-field-suffix .mat-datepicker-toggle-default-icon{width:1em}.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-prefix .mat-datepicker-toggle-default-icon,.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-suffix .mat-datepicker-toggle-default-icon{display:block;width:1.5em;height:1.5em}.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-prefix .mat-icon-button .mat-datepicker-toggle-default-icon,.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-suffix .mat-icon-button .mat-datepicker-toggle-default-icon{margin:auto}.cdk-high-contrast-active .mat-datepicker-toggle-default-icon{color:CanvasText}\n"]
|
---|
88 | },] }
|
---|
89 | ];
|
---|
90 | MatDatepickerToggle.ctorParameters = () => [
|
---|
91 | { type: MatDatepickerIntl },
|
---|
92 | { type: ChangeDetectorRef },
|
---|
93 | { type: String, decorators: [{ type: Attribute, args: ['tabindex',] }] }
|
---|
94 | ];
|
---|
95 | MatDatepickerToggle.propDecorators = {
|
---|
96 | datepicker: [{ type: Input, args: ['for',] }],
|
---|
97 | tabIndex: [{ type: Input }],
|
---|
98 | ariaLabel: [{ type: Input, args: ['aria-label',] }],
|
---|
99 | disabled: [{ type: Input }],
|
---|
100 | disableRipple: [{ type: Input }],
|
---|
101 | _customIcon: [{ type: ContentChild, args: [MatDatepickerToggleIcon,] }],
|
---|
102 | _button: [{ type: ViewChild, args: ['button',] }]
|
---|
103 | };
|
---|
104 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0ZXBpY2tlci10b2dnbGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvZGF0ZXBpY2tlci9kYXRlcGlja2VyLXRvZ2dsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQWUscUJBQXFCLEVBQUMsTUFBTSx1QkFBdUIsQ0FBQztBQUMxRSxPQUFPLEVBRUwsU0FBUyxFQUNULHVCQUF1QixFQUN2QixpQkFBaUIsRUFDakIsU0FBUyxFQUNULFlBQVksRUFDWixTQUFTLEVBQ1QsS0FBSyxFQUlMLGlCQUFpQixFQUNqQixTQUFTLEdBQ1YsTUFBTSxlQUFlLENBQUM7QUFDdkIsT0FBTyxFQUFDLFNBQVMsRUFBQyxNQUFNLDBCQUEwQixDQUFDO0FBQ25ELE9BQU8sRUFBQyxLQUFLLEVBQWMsRUFBRSxJQUFJLFlBQVksRUFBRSxZQUFZLEVBQUMsTUFBTSxNQUFNLENBQUM7QUFDekUsT0FBTyxFQUFDLGlCQUFpQixFQUFDLE1BQU0sbUJBQW1CLENBQUM7QUFJcEQsbUVBQW1FO0FBSW5FLE1BQU0sT0FBTyx1QkFBdUI7OztZQUhuQyx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