/** * @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 { Directive, ElementRef, Input, Optional, } from '@angular/core'; import { MatDialog } from './dialog'; import { _closeDialogVia, MatDialogRef } from './dialog-ref'; import * as i0 from "@angular/core"; import * as i1 from "./dialog-ref"; import * as i2 from "./dialog"; /** Counter used to generate unique IDs for dialog elements. */ let dialogElementUid = 0; /** * Button that will close the current dialog. */ export class MatDialogClose { constructor( // The dialog title directive is always used in combination with a `MatDialogRef`. // tslint:disable-next-line: lightweight-tokens dialogRef, _elementRef, _dialog) { this.dialogRef = dialogRef; this._elementRef = _elementRef; this._dialog = _dialog; /** Default to "button" to prevents accidental form submits. */ this.type = 'button'; } ngOnInit() { if (!this.dialogRef) { // When this directive is included in a dialog via TemplateRef (rather than being // in a Component), the DialogRef isn't available via injection because embedded // views cannot be given a custom injector. Instead, we look up the DialogRef by // ID. This must occur in `onInit`, as the ID binding for the dialog container won't // be resolved at constructor time. this.dialogRef = getClosestDialog(this._elementRef, this._dialog.openDialogs); } } ngOnChanges(changes) { const proxiedChange = changes['_matDialogClose'] || changes['_matDialogCloseResult']; if (proxiedChange) { this.dialogResult = proxiedChange.currentValue; } } _onButtonClick(event) { // Determinate the focus origin using the click event, because using the FocusMonitor will // result in incorrect origins. Most of the time, close buttons will be auto focused in the // dialog, and therefore clicking the button won't result in a focus change. This means that // the FocusMonitor won't detect any origin change, and will always output `program`. _closeDialogVia(this.dialogRef, event.screenX === 0 && event.screenY === 0 ? 'keyboard' : 'mouse', this.dialogResult); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatDialogClose, deps: [{ token: i1.MatDialogRef, optional: true }, { token: i0.ElementRef }, { token: i2.MatDialog }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: { ariaLabel: ["aria-label", "ariaLabel"], type: "type", dialogResult: ["mat-dialog-close", "dialogResult"], _matDialogClose: ["matDialogClose", "_matDialogClose"] }, host: { listeners: { "click": "_onButtonClick($event)" }, properties: { "attr.aria-label": "ariaLabel || null", "attr.type": "type" } }, exportAs: ["matDialogClose"], usesOnChanges: true, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatDialogClose, decorators: [{ type: Directive, args: [{ selector: '[mat-dialog-close], [matDialogClose]', exportAs: 'matDialogClose', host: { '(click)': '_onButtonClick($event)', '[attr.aria-label]': 'ariaLabel || null', '[attr.type]': 'type', }, }] }], ctorParameters: function () { return [{ type: i1.MatDialogRef, decorators: [{ type: Optional }] }, { type: i0.ElementRef }, { type: i2.MatDialog }]; }, propDecorators: { ariaLabel: [{ type: Input, args: ['aria-label'] }], type: [{ type: Input }], dialogResult: [{ type: Input, args: ['mat-dialog-close'] }], _matDialogClose: [{ type: Input, args: ['matDialogClose'] }] } }); /** * Title of a dialog element. Stays fixed to the top of the dialog when scrolling. */ export class MatDialogTitle { constructor( // The dialog title directive is always used in combination with a `MatDialogRef`. // tslint:disable-next-line: lightweight-tokens _dialogRef, _elementRef, _dialog) { this._dialogRef = _dialogRef; this._elementRef = _elementRef; this._dialog = _dialog; this.id = `mat-mdc-dialog-title-${dialogElementUid++}`; } ngOnInit() { if (!this._dialogRef) { this._dialogRef = getClosestDialog(this._elementRef, this._dialog.openDialogs); } if (this._dialogRef) { Promise.resolve().then(() => { // Note: we null check the queue, because there are some internal // tests that are mocking out `MatDialogRef` incorrectly. this._dialogRef._containerInstance?._ariaLabelledByQueue?.push(this.id); }); } } ngOnDestroy() { // Note: we null check the queue, because there are some internal // tests that are mocking out `MatDialogRef` incorrectly. const queue = this._dialogRef?._containerInstance?._ariaLabelledByQueue; if (queue) { Promise.resolve().then(() => { const index = queue.indexOf(this.id); if (index > -1) { queue.splice(index, 1); } }); } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatDialogTitle, deps: [{ token: i1.MatDialogRef, optional: true }, { token: i0.ElementRef }, { token: i2.MatDialog }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: { id: "id" }, host: { properties: { "id": "id" }, classAttribute: "mat-mdc-dialog-title mdc-dialog__title" }, exportAs: ["matDialogTitle"], ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatDialogTitle, decorators: [{ type: Directive, args: [{ selector: '[mat-dialog-title], [matDialogTitle]', exportAs: 'matDialogTitle', host: { 'class': 'mat-mdc-dialog-title mdc-dialog__title', '[id]': 'id', }, }] }], ctorParameters: function () { return [{ type: i1.MatDialogRef, decorators: [{ type: Optional }] }, { type: i0.ElementRef }, { type: i2.MatDialog }]; }, propDecorators: { id: [{ type: Input }] } }); /** * Scrollable content container of a dialog. */ export class MatDialogContent { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatDialogContent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]", host: { classAttribute: "mat-mdc-dialog-content mdc-dialog__content" }, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatDialogContent, decorators: [{ type: Directive, args: [{ selector: `[mat-dialog-content], mat-dialog-content, [matDialogContent]`, host: { 'class': 'mat-mdc-dialog-content mdc-dialog__content' }, }] }] }); /** * Container for the bottom action buttons in a dialog. * Stays fixed to the bottom when scrolling. */ export class MatDialogActions { constructor() { /** * Horizontal alignment of action buttons. */ this.align = 'start'; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatDialogActions, deps: [], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: { align: "align" }, host: { properties: { "class.mat-mdc-dialog-actions-align-center": "align === \"center\"", "class.mat-mdc-dialog-actions-align-end": "align === \"end\"" }, classAttribute: "mat-mdc-dialog-actions mdc-dialog__actions" }, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatDialogActions, decorators: [{ type: Directive, args: [{ selector: `[mat-dialog-actions], mat-dialog-actions, [matDialogActions]`, host: { 'class': 'mat-mdc-dialog-actions mdc-dialog__actions', '[class.mat-mdc-dialog-actions-align-center]': 'align === "center"', '[class.mat-mdc-dialog-actions-align-end]': 'align === "end"', }, }] }], propDecorators: { align: [{ type: Input }] } }); /** * Finds the closest MatDialogRef to an element by looking at the DOM. * @param element Element relative to which to look for a dialog. * @param openDialogs References to the currently-open dialogs. */ function getClosestDialog(element, openDialogs) { let parent = element.nativeElement.parentElement; while (parent && !parent.classList.contains('mat-mdc-dialog-container')) { parent = parent.parentElement; } return parent ? openDialogs.find(dialog => dialog.id === parent.id) : null; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGlhbG9nLWNvbnRlbnQtZGlyZWN0aXZlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9kaWFsb2cvZGlhbG9nLWNvbnRlbnQtZGlyZWN0aXZlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIj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