/** * @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, Input, Optional, ElementRef, } from '@angular/core'; import { MatLegacyDialog } from './dialog'; import { MatLegacyDialogRef } from './dialog-ref'; import { _closeDialogVia } from '@angular/material/dialog'; 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. * @deprecated Use `MatDialogClose` from `@angular/material/dialog` instead. See https://material.angular.io/guide/mdc-migration for information about migrating. * @breaking-change 17.0.0 */ export class MatLegacyDialogClose { constructor( /** * Reference to the containing dialog. * @deprecated `dialogRef` property to become private. * @breaking-change 13.0.0 */ // 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: MatLegacyDialogClose, deps: [{ token: i1.MatLegacyDialogRef, optional: true }, { token: i0.ElementRef }, { token: i2.MatLegacyDialog }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: MatLegacyDialogClose, 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: MatLegacyDialogClose, 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.MatLegacyDialogRef, decorators: [{ type: Optional }] }, { type: i0.ElementRef }, { type: i2.MatLegacyDialog }]; }, 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. * @deprecated Use `MatDialogTitle` from `@angular/material/dialog` instead. See https://material.angular.io/guide/mdc-migration for information about migrating. * @breaking-change 17.0.0 */ export class MatLegacyDialogTitle { 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; /** Unique id for the dialog title. If none is supplied, it will be auto-generated. */ this.id = `mat-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: MatLegacyDialogTitle, deps: [{ token: i1.MatLegacyDialogRef, optional: true }, { token: i0.ElementRef }, { token: i2.MatLegacyDialog }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: MatLegacyDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: { id: "id" }, host: { properties: { "id": "id" }, classAttribute: "mat-dialog-title" }, exportAs: ["matDialogTitle"], ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatLegacyDialogTitle, decorators: [{ type: Directive, args: [{ selector: '[mat-dialog-title], [matDialogTitle]', exportAs: 'matDialogTitle', host: { 'class': 'mat-dialog-title', '[id]': 'id', }, }] }], ctorParameters: function () { return [{ type: i1.MatLegacyDialogRef, decorators: [{ type: Optional }] }, { type: i0.ElementRef }, { type: i2.MatLegacyDialog }]; }, propDecorators: { id: [{ type: Input }] } }); /** * Scrollable content container of a dialog. * @deprecated Use `MatDialogContent` from `@angular/material/dialog` instead. See https://material.angular.io/guide/mdc-migration for information about migrating. * @breaking-change 17.0.0 */ export class MatLegacyDialogContent { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatLegacyDialogContent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: MatLegacyDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]", host: { classAttribute: "mat-dialog-content" }, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatLegacyDialogContent, decorators: [{ type: Directive, args: [{ selector: `[mat-dialog-content], mat-dialog-content, [matDialogContent]`, host: { 'class': 'mat-dialog-content' }, }] }] }); /** * Container for the bottom action buttons in a dialog. * Stays fixed to the bottom when scrolling. * @deprecated Use `MatDialogActions` from `@angular/material/dialog` instead. See https://material.angular.io/guide/mdc-migration for information about migrating. * @breaking-change 17.0.0 */ export class MatLegacyDialogActions { 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: MatLegacyDialogActions, deps: [], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: MatLegacyDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: { align: "align" }, host: { properties: { "class.mat-dialog-actions-align-center": "align === \"center\"", "class.mat-dialog-actions-align-end": "align === \"end\"" }, classAttribute: "mat-dialog-actions" }, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatLegacyDialogActions, decorators: [{ type: Directive, args: [{ selector: `[mat-dialog-actions], mat-dialog-actions, [matDialogActions]`, host: { 'class': 'mat-dialog-actions', '[class.mat-dialog-actions-align-center]': 'align === "center"', '[class.mat-dialog-actions-align-end]': 'align === "end"', }, }] }], propDecorators: { align: [{ type: Input }] } }); // TODO(crisbeto): this utility shouldn't be necessary anymore, because the dialog ref is provided // both to component and template dialogs through DI. We need to keep it around, because there are // some internal wrappers around `MatDialog` that happened to work by accident, because we had this // fallback logic in place. /** * 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-dialog-container')) { parent = parent.parentElement; } return parent ? openDialogs.find(dialog => dialog.id === parent.id) : null; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGlhbG9nLWNvbnRlbnQtZGlyZWN0aXZlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9sZWdhY3ktZGlhbG9nL2RpYWxvZy1jb250ZW50LWRpcmVjdGl2ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUNMLFNBQVMsRUFDVCxLQUFLLEVBR0wsUUFBUSxFQUVSLFVBQVUsR0FFWCxNQUFNLGVBQWUsQ0FBQztBQUN2QixPQUFPLEVBQUMsZUFBZSxFQUFDLE1BQU0sVUFBVSxDQUFDO0FBQ3pDLE9BQU8sRUFBQyxrQkFBa0IsRUFBQyxNQUFNLGNBQWMsQ0FBQztBQUNoRCxPQUFPLEVBQUMsZUFBZSxFQUFDLE1BQU0sMEJBQTBCLENBQUM7Ozs7QUFFekQsK0RBQStEO0FBQy9ELElBQUksZ0JBQWdCLEdBQUcsQ0FBQyxDQUFDO0FBRXpCOzs7O0dBSUc7QUFVSCxNQUFNLE9BQU8sb0JBQW9CO0lBWS9CO0lBQ0U7Ozs7T0FJRztJQUNILGtGQUFrRjtJQUNsRiwrQ0FBK0M7SUFDNUIsU0FBa0MsRUFDN0MsV0FBb0MsRUFDcEMsT0FBd0I7UUFGYixjQUFTLEdBQVQsU0FBUyxDQUF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