[6a3a178] | 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, Input, Optional, ElementRef, } from '@angular/core';
|
---|
| 9 | import { MatDialog } from './dialog';
|
---|
| 10 | import { _closeDialogVia, MatDialogRef } from './dialog-ref';
|
---|
| 11 | /** Counter used to generate unique IDs for dialog elements. */
|
---|
| 12 | let dialogElementUid = 0;
|
---|
| 13 | /**
|
---|
| 14 | * Button that will close the current dialog.
|
---|
| 15 | */
|
---|
| 16 | export class MatDialogClose {
|
---|
| 17 | constructor(
|
---|
| 18 | /**
|
---|
| 19 | * Reference to the containing dialog.
|
---|
| 20 | * @deprecated `dialogRef` property to become private.
|
---|
| 21 | * @breaking-change 13.0.0
|
---|
| 22 | */
|
---|
| 23 | // The dialog title directive is always used in combination with a `MatDialogRef`.
|
---|
| 24 | // tslint:disable-next-line: lightweight-tokens
|
---|
| 25 | dialogRef, _elementRef, _dialog) {
|
---|
| 26 | this.dialogRef = dialogRef;
|
---|
| 27 | this._elementRef = _elementRef;
|
---|
| 28 | this._dialog = _dialog;
|
---|
| 29 | /** Default to "button" to prevents accidental form submits. */
|
---|
| 30 | this.type = 'button';
|
---|
| 31 | }
|
---|
| 32 | ngOnInit() {
|
---|
| 33 | if (!this.dialogRef) {
|
---|
| 34 | // When this directive is included in a dialog via TemplateRef (rather than being
|
---|
| 35 | // in a Component), the DialogRef isn't available via injection because embedded
|
---|
| 36 | // views cannot be given a custom injector. Instead, we look up the DialogRef by
|
---|
| 37 | // ID. This must occur in `onInit`, as the ID binding for the dialog container won't
|
---|
| 38 | // be resolved at constructor time.
|
---|
| 39 | this.dialogRef = getClosestDialog(this._elementRef, this._dialog.openDialogs);
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
| 42 | ngOnChanges(changes) {
|
---|
| 43 | const proxiedChange = changes['_matDialogClose'] || changes['_matDialogCloseResult'];
|
---|
| 44 | if (proxiedChange) {
|
---|
| 45 | this.dialogResult = proxiedChange.currentValue;
|
---|
| 46 | }
|
---|
| 47 | }
|
---|
| 48 | _onButtonClick(event) {
|
---|
| 49 | // Determinate the focus origin using the click event, because using the FocusMonitor will
|
---|
| 50 | // result in incorrect origins. Most of the time, close buttons will be auto focused in the
|
---|
| 51 | // dialog, and therefore clicking the button won't result in a focus change. This means that
|
---|
| 52 | // the FocusMonitor won't detect any origin change, and will always output `program`.
|
---|
| 53 | _closeDialogVia(this.dialogRef, event.screenX === 0 && event.screenY === 0 ? 'keyboard' : 'mouse', this.dialogResult);
|
---|
| 54 | }
|
---|
| 55 | }
|
---|
| 56 | MatDialogClose.decorators = [
|
---|
| 57 | { type: Directive, args: [{
|
---|
| 58 | selector: '[mat-dialog-close], [matDialogClose]',
|
---|
| 59 | exportAs: 'matDialogClose',
|
---|
| 60 | host: {
|
---|
| 61 | '(click)': '_onButtonClick($event)',
|
---|
| 62 | '[attr.aria-label]': 'ariaLabel || null',
|
---|
| 63 | '[attr.type]': 'type',
|
---|
| 64 | }
|
---|
| 65 | },] }
|
---|
| 66 | ];
|
---|
| 67 | MatDialogClose.ctorParameters = () => [
|
---|
| 68 | { type: MatDialogRef, decorators: [{ type: Optional }] },
|
---|
| 69 | { type: ElementRef },
|
---|
| 70 | { type: MatDialog }
|
---|
| 71 | ];
|
---|
| 72 | MatDialogClose.propDecorators = {
|
---|
| 73 | ariaLabel: [{ type: Input, args: ['aria-label',] }],
|
---|
| 74 | type: [{ type: Input }],
|
---|
| 75 | dialogResult: [{ type: Input, args: ['mat-dialog-close',] }],
|
---|
| 76 | _matDialogClose: [{ type: Input, args: ['matDialogClose',] }]
|
---|
| 77 | };
|
---|
| 78 | /**
|
---|
| 79 | * Title of a dialog element. Stays fixed to the top of the dialog when scrolling.
|
---|
| 80 | */
|
---|
| 81 | export class MatDialogTitle {
|
---|
| 82 | constructor(
|
---|
| 83 | // The dialog title directive is always used in combination with a `MatDialogRef`.
|
---|
| 84 | // tslint:disable-next-line: lightweight-tokens
|
---|
| 85 | _dialogRef, _elementRef, _dialog) {
|
---|
| 86 | this._dialogRef = _dialogRef;
|
---|
| 87 | this._elementRef = _elementRef;
|
---|
| 88 | this._dialog = _dialog;
|
---|
| 89 | /** Unique id for the dialog title. If none is supplied, it will be auto-generated. */
|
---|
| 90 | this.id = `mat-dialog-title-${dialogElementUid++}`;
|
---|
| 91 | }
|
---|
| 92 | ngOnInit() {
|
---|
| 93 | if (!this._dialogRef) {
|
---|
| 94 | this._dialogRef = getClosestDialog(this._elementRef, this._dialog.openDialogs);
|
---|
| 95 | }
|
---|
| 96 | if (this._dialogRef) {
|
---|
| 97 | Promise.resolve().then(() => {
|
---|
| 98 | const container = this._dialogRef._containerInstance;
|
---|
| 99 | if (container && !container._ariaLabelledBy) {
|
---|
| 100 | container._ariaLabelledBy = this.id;
|
---|
| 101 | }
|
---|
| 102 | });
|
---|
| 103 | }
|
---|
| 104 | }
|
---|
| 105 | }
|
---|
| 106 | MatDialogTitle.decorators = [
|
---|
| 107 | { type: Directive, args: [{
|
---|
| 108 | selector: '[mat-dialog-title], [matDialogTitle]',
|
---|
| 109 | exportAs: 'matDialogTitle',
|
---|
| 110 | host: {
|
---|
| 111 | 'class': 'mat-dialog-title',
|
---|
| 112 | '[id]': 'id',
|
---|
| 113 | },
|
---|
| 114 | },] }
|
---|
| 115 | ];
|
---|
| 116 | MatDialogTitle.ctorParameters = () => [
|
---|
| 117 | { type: MatDialogRef, decorators: [{ type: Optional }] },
|
---|
| 118 | { type: ElementRef },
|
---|
| 119 | { type: MatDialog }
|
---|
| 120 | ];
|
---|
| 121 | MatDialogTitle.propDecorators = {
|
---|
| 122 | id: [{ type: Input }]
|
---|
| 123 | };
|
---|
| 124 | /**
|
---|
| 125 | * Scrollable content container of a dialog.
|
---|
| 126 | */
|
---|
| 127 | export class MatDialogContent {
|
---|
| 128 | }
|
---|
| 129 | MatDialogContent.decorators = [
|
---|
| 130 | { type: Directive, args: [{
|
---|
| 131 | selector: `[mat-dialog-content], mat-dialog-content, [matDialogContent]`,
|
---|
| 132 | host: { 'class': 'mat-dialog-content' }
|
---|
| 133 | },] }
|
---|
| 134 | ];
|
---|
| 135 | /**
|
---|
| 136 | * Container for the bottom action buttons in a dialog.
|
---|
| 137 | * Stays fixed to the bottom when scrolling.
|
---|
| 138 | */
|
---|
| 139 | export class MatDialogActions {
|
---|
| 140 | }
|
---|
| 141 | MatDialogActions.decorators = [
|
---|
| 142 | { type: Directive, args: [{
|
---|
| 143 | selector: `[mat-dialog-actions], mat-dialog-actions, [matDialogActions]`,
|
---|
| 144 | host: { 'class': 'mat-dialog-actions' }
|
---|
| 145 | },] }
|
---|
| 146 | ];
|
---|
| 147 | /**
|
---|
| 148 | * Finds the closest MatDialogRef to an element by looking at the DOM.
|
---|
| 149 | * @param element Element relative to which to look for a dialog.
|
---|
| 150 | * @param openDialogs References to the currently-open dialogs.
|
---|
| 151 | */
|
---|
| 152 | function getClosestDialog(element, openDialogs) {
|
---|
| 153 | let parent = element.nativeElement.parentElement;
|
---|
| 154 | while (parent && !parent.classList.contains('mat-dialog-container')) {
|
---|
| 155 | parent = parent.parentElement;
|
---|
| 156 | }
|
---|
| 157 | return parent ? openDialogs.find(dialog => dialog.id === parent.id) : null;
|
---|
| 158 | }
|
---|
| 159 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGlhbG9nLWNvbnRlbnQtZGlyZWN0aXZlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9kaWFsb2cvZGlhbG9nLWNvbnRlbnQtZGlyZWN0aXZlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQ0wsU0F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