1 | (function (global, factory) {
|
---|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/overlay'), require('@angular/cdk/portal'), require('@angular/core'), require('@angular/material/core'), require('@angular/cdk/bidi'), require('@angular/common'), require('rxjs'), require('rxjs/operators'), require('@angular/cdk/a11y'), require('@angular/cdk/platform'), require('@angular/animations'), require('@angular/cdk/keycodes')) :
|
---|
3 | typeof define === 'function' && define.amd ? define('@angular/material/dialog', ['exports', '@angular/cdk/overlay', '@angular/cdk/portal', '@angular/core', '@angular/material/core', '@angular/cdk/bidi', '@angular/common', 'rxjs', 'rxjs/operators', '@angular/cdk/a11y', '@angular/cdk/platform', '@angular/animations', '@angular/cdk/keycodes'], factory) :
|
---|
4 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ng = global.ng || {}, global.ng.material = global.ng.material || {}, global.ng.material.dialog = {}), global.ng.cdk.overlay, global.ng.cdk.portal, global.ng.core, global.ng.material.core, global.ng.cdk.bidi, global.ng.common, global.rxjs, global.rxjs.operators, global.ng.cdk.a11y, global.ng.cdk.platform, global.ng.animations, global.ng.cdk.keycodes));
|
---|
5 | }(this, (function (exports, overlay, portal, core, core$1, bidi, common, rxjs, operators, a11y, platform, animations, keycodes) { 'use strict';
|
---|
6 |
|
---|
7 | /*! *****************************************************************************
|
---|
8 | Copyright (c) Microsoft Corporation.
|
---|
9 |
|
---|
10 | Permission to use, copy, modify, and/or distribute this software for any
|
---|
11 | purpose with or without fee is hereby granted.
|
---|
12 |
|
---|
13 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
---|
14 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
---|
15 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
---|
16 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
---|
17 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
---|
18 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
---|
19 | PERFORMANCE OF THIS SOFTWARE.
|
---|
20 | ***************************************************************************** */
|
---|
21 | /* global Reflect, Promise */
|
---|
22 | var extendStatics = function (d, b) {
|
---|
23 | extendStatics = Object.setPrototypeOf ||
|
---|
24 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
---|
25 | function (d, b) { for (var p in b)
|
---|
26 | if (Object.prototype.hasOwnProperty.call(b, p))
|
---|
27 | d[p] = b[p]; };
|
---|
28 | return extendStatics(d, b);
|
---|
29 | };
|
---|
30 | function __extends(d, b) {
|
---|
31 | if (typeof b !== "function" && b !== null)
|
---|
32 | throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
---|
33 | extendStatics(d, b);
|
---|
34 | function __() { this.constructor = d; }
|
---|
35 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
---|
36 | }
|
---|
37 | var __assign = function () {
|
---|
38 | __assign = Object.assign || function __assign(t) {
|
---|
39 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
---|
40 | s = arguments[i];
|
---|
41 | for (var p in s)
|
---|
42 | if (Object.prototype.hasOwnProperty.call(s, p))
|
---|
43 | t[p] = s[p];
|
---|
44 | }
|
---|
45 | return t;
|
---|
46 | };
|
---|
47 | return __assign.apply(this, arguments);
|
---|
48 | };
|
---|
49 | function __rest(s, e) {
|
---|
50 | var t = {};
|
---|
51 | for (var p in s)
|
---|
52 | if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
---|
53 | t[p] = s[p];
|
---|
54 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
---|
55 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
---|
56 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
---|
57 | t[p[i]] = s[p[i]];
|
---|
58 | }
|
---|
59 | return t;
|
---|
60 | }
|
---|
61 | function __decorate(decorators, target, key, desc) {
|
---|
62 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
---|
63 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
---|
64 | r = Reflect.decorate(decorators, target, key, desc);
|
---|
65 | else
|
---|
66 | for (var i = decorators.length - 1; i >= 0; i--)
|
---|
67 | if (d = decorators[i])
|
---|
68 | r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
---|
69 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
---|
70 | }
|
---|
71 | function __param(paramIndex, decorator) {
|
---|
72 | return function (target, key) { decorator(target, key, paramIndex); };
|
---|
73 | }
|
---|
74 | function __metadata(metadataKey, metadataValue) {
|
---|
75 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
---|
76 | return Reflect.metadata(metadataKey, metadataValue);
|
---|
77 | }
|
---|
78 | function __awaiter(thisArg, _arguments, P, generator) {
|
---|
79 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
---|
80 | return new (P || (P = Promise))(function (resolve, reject) {
|
---|
81 | function fulfilled(value) { try {
|
---|
82 | step(generator.next(value));
|
---|
83 | }
|
---|
84 | catch (e) {
|
---|
85 | reject(e);
|
---|
86 | } }
|
---|
87 | function rejected(value) { try {
|
---|
88 | step(generator["throw"](value));
|
---|
89 | }
|
---|
90 | catch (e) {
|
---|
91 | reject(e);
|
---|
92 | } }
|
---|
93 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
---|
94 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
---|
95 | });
|
---|
96 | }
|
---|
97 | function __generator(thisArg, body) {
|
---|
98 | var _ = { label: 0, sent: function () { if (t[0] & 1)
|
---|
99 | throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
---|
100 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
---|
101 | function verb(n) { return function (v) { return step([n, v]); }; }
|
---|
102 | function step(op) {
|
---|
103 | if (f)
|
---|
104 | throw new TypeError("Generator is already executing.");
|
---|
105 | while (_)
|
---|
106 | try {
|
---|
107 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
---|
108 | return t;
|
---|
109 | if (y = 0, t)
|
---|
110 | op = [op[0] & 2, t.value];
|
---|
111 | switch (op[0]) {
|
---|
112 | case 0:
|
---|
113 | case 1:
|
---|
114 | t = op;
|
---|
115 | break;
|
---|
116 | case 4:
|
---|
117 | _.label++;
|
---|
118 | return { value: op[1], done: false };
|
---|
119 | case 5:
|
---|
120 | _.label++;
|
---|
121 | y = op[1];
|
---|
122 | op = [0];
|
---|
123 | continue;
|
---|
124 | case 7:
|
---|
125 | op = _.ops.pop();
|
---|
126 | _.trys.pop();
|
---|
127 | continue;
|
---|
128 | default:
|
---|
129 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
---|
130 | _ = 0;
|
---|
131 | continue;
|
---|
132 | }
|
---|
133 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
---|
134 | _.label = op[1];
|
---|
135 | break;
|
---|
136 | }
|
---|
137 | if (op[0] === 6 && _.label < t[1]) {
|
---|
138 | _.label = t[1];
|
---|
139 | t = op;
|
---|
140 | break;
|
---|
141 | }
|
---|
142 | if (t && _.label < t[2]) {
|
---|
143 | _.label = t[2];
|
---|
144 | _.ops.push(op);
|
---|
145 | break;
|
---|
146 | }
|
---|
147 | if (t[2])
|
---|
148 | _.ops.pop();
|
---|
149 | _.trys.pop();
|
---|
150 | continue;
|
---|
151 | }
|
---|
152 | op = body.call(thisArg, _);
|
---|
153 | }
|
---|
154 | catch (e) {
|
---|
155 | op = [6, e];
|
---|
156 | y = 0;
|
---|
157 | }
|
---|
158 | finally {
|
---|
159 | f = t = 0;
|
---|
160 | }
|
---|
161 | if (op[0] & 5)
|
---|
162 | throw op[1];
|
---|
163 | return { value: op[0] ? op[1] : void 0, done: true };
|
---|
164 | }
|
---|
165 | }
|
---|
166 | var __createBinding = Object.create ? (function (o, m, k, k2) {
|
---|
167 | if (k2 === undefined)
|
---|
168 | k2 = k;
|
---|
169 | Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
---|
170 | }) : (function (o, m, k, k2) {
|
---|
171 | if (k2 === undefined)
|
---|
172 | k2 = k;
|
---|
173 | o[k2] = m[k];
|
---|
174 | });
|
---|
175 | function __exportStar(m, o) {
|
---|
176 | for (var p in m)
|
---|
177 | if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
---|
178 | __createBinding(o, m, p);
|
---|
179 | }
|
---|
180 | function __values(o) {
|
---|
181 | var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
---|
182 | if (m)
|
---|
183 | return m.call(o);
|
---|
184 | if (o && typeof o.length === "number")
|
---|
185 | return {
|
---|
186 | next: function () {
|
---|
187 | if (o && i >= o.length)
|
---|
188 | o = void 0;
|
---|
189 | return { value: o && o[i++], done: !o };
|
---|
190 | }
|
---|
191 | };
|
---|
192 | throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
---|
193 | }
|
---|
194 | function __read(o, n) {
|
---|
195 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
---|
196 | if (!m)
|
---|
197 | return o;
|
---|
198 | var i = m.call(o), r, ar = [], e;
|
---|
199 | try {
|
---|
200 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
---|
201 | ar.push(r.value);
|
---|
202 | }
|
---|
203 | catch (error) {
|
---|
204 | e = { error: error };
|
---|
205 | }
|
---|
206 | finally {
|
---|
207 | try {
|
---|
208 | if (r && !r.done && (m = i["return"]))
|
---|
209 | m.call(i);
|
---|
210 | }
|
---|
211 | finally {
|
---|
212 | if (e)
|
---|
213 | throw e.error;
|
---|
214 | }
|
---|
215 | }
|
---|
216 | return ar;
|
---|
217 | }
|
---|
218 | /** @deprecated */
|
---|
219 | function __spread() {
|
---|
220 | for (var ar = [], i = 0; i < arguments.length; i++)
|
---|
221 | ar = ar.concat(__read(arguments[i]));
|
---|
222 | return ar;
|
---|
223 | }
|
---|
224 | /** @deprecated */
|
---|
225 | function __spreadArrays() {
|
---|
226 | for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
---|
227 | s += arguments[i].length;
|
---|
228 | for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
---|
229 | for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
---|
230 | r[k] = a[j];
|
---|
231 | return r;
|
---|
232 | }
|
---|
233 | function __spreadArray(to, from, pack) {
|
---|
234 | if (pack || arguments.length === 2)
|
---|
235 | for (var i = 0, l = from.length, ar; i < l; i++) {
|
---|
236 | if (ar || !(i in from)) {
|
---|
237 | if (!ar)
|
---|
238 | ar = Array.prototype.slice.call(from, 0, i);
|
---|
239 | ar[i] = from[i];
|
---|
240 | }
|
---|
241 | }
|
---|
242 | return to.concat(ar || from);
|
---|
243 | }
|
---|
244 | function __await(v) {
|
---|
245 | return this instanceof __await ? (this.v = v, this) : new __await(v);
|
---|
246 | }
|
---|
247 | function __asyncGenerator(thisArg, _arguments, generator) {
|
---|
248 | if (!Symbol.asyncIterator)
|
---|
249 | throw new TypeError("Symbol.asyncIterator is not defined.");
|
---|
250 | var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
---|
251 | return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
---|
252 | function verb(n) { if (g[n])
|
---|
253 | i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
---|
254 | function resume(n, v) { try {
|
---|
255 | step(g[n](v));
|
---|
256 | }
|
---|
257 | catch (e) {
|
---|
258 | settle(q[0][3], e);
|
---|
259 | } }
|
---|
260 | function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
---|
261 | function fulfill(value) { resume("next", value); }
|
---|
262 | function reject(value) { resume("throw", value); }
|
---|
263 | function settle(f, v) { if (f(v), q.shift(), q.length)
|
---|
264 | resume(q[0][0], q[0][1]); }
|
---|
265 | }
|
---|
266 | function __asyncDelegator(o) {
|
---|
267 | var i, p;
|
---|
268 | return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
---|
269 | function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
---|
270 | }
|
---|
271 | function __asyncValues(o) {
|
---|
272 | if (!Symbol.asyncIterator)
|
---|
273 | throw new TypeError("Symbol.asyncIterator is not defined.");
|
---|
274 | var m = o[Symbol.asyncIterator], i;
|
---|
275 | return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
---|
276 | function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
---|
277 | function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
---|
278 | }
|
---|
279 | function __makeTemplateObject(cooked, raw) {
|
---|
280 | if (Object.defineProperty) {
|
---|
281 | Object.defineProperty(cooked, "raw", { value: raw });
|
---|
282 | }
|
---|
283 | else {
|
---|
284 | cooked.raw = raw;
|
---|
285 | }
|
---|
286 | return cooked;
|
---|
287 | }
|
---|
288 | ;
|
---|
289 | var __setModuleDefault = Object.create ? (function (o, v) {
|
---|
290 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
---|
291 | }) : function (o, v) {
|
---|
292 | o["default"] = v;
|
---|
293 | };
|
---|
294 | function __importStar(mod) {
|
---|
295 | if (mod && mod.__esModule)
|
---|
296 | return mod;
|
---|
297 | var result = {};
|
---|
298 | if (mod != null)
|
---|
299 | for (var k in mod)
|
---|
300 | if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
---|
301 | __createBinding(result, mod, k);
|
---|
302 | __setModuleDefault(result, mod);
|
---|
303 | return result;
|
---|
304 | }
|
---|
305 | function __importDefault(mod) {
|
---|
306 | return (mod && mod.__esModule) ? mod : { default: mod };
|
---|
307 | }
|
---|
308 | function __classPrivateFieldGet(receiver, state, kind, f) {
|
---|
309 | if (kind === "a" && !f)
|
---|
310 | throw new TypeError("Private accessor was defined without a getter");
|
---|
311 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
---|
312 | throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
---|
313 | return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
---|
314 | }
|
---|
315 | function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
---|
316 | if (kind === "m")
|
---|
317 | throw new TypeError("Private method is not writable");
|
---|
318 | if (kind === "a" && !f)
|
---|
319 | throw new TypeError("Private accessor was defined without a setter");
|
---|
320 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
---|
321 | throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
---|
322 | return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
---|
323 | }
|
---|
324 |
|
---|
325 | /**
|
---|
326 | * @license
|
---|
327 | * Copyright Google LLC All Rights Reserved.
|
---|
328 | *
|
---|
329 | * Use of this source code is governed by an MIT-style license that can be
|
---|
330 | * found in the LICENSE file at https://angular.io/license
|
---|
331 | */
|
---|
332 | /**
|
---|
333 | * Configuration for opening a modal dialog with the MatDialog service.
|
---|
334 | */
|
---|
335 | var MatDialogConfig = /** @class */ (function () {
|
---|
336 | function MatDialogConfig() {
|
---|
337 | /** The ARIA role of the dialog element. */
|
---|
338 | this.role = 'dialog';
|
---|
339 | /** Custom class for the overlay pane. */
|
---|
340 | this.panelClass = '';
|
---|
341 | /** Whether the dialog has a backdrop. */
|
---|
342 | this.hasBackdrop = true;
|
---|
343 | /** Custom class for the backdrop. */
|
---|
344 | this.backdropClass = '';
|
---|
345 | /** Whether the user can use escape or clicking on the backdrop to close the modal. */
|
---|
346 | this.disableClose = false;
|
---|
347 | /** Width of the dialog. */
|
---|
348 | this.width = '';
|
---|
349 | /** Height of the dialog. */
|
---|
350 | this.height = '';
|
---|
351 | /** Max-width of the dialog. If a number is provided, assumes pixel units. Defaults to 80vw. */
|
---|
352 | this.maxWidth = '80vw';
|
---|
353 | /** Data being injected into the child component. */
|
---|
354 | this.data = null;
|
---|
355 | /** ID of the element that describes the dialog. */
|
---|
356 | this.ariaDescribedBy = null;
|
---|
357 | /** ID of the element that labels the dialog. */
|
---|
358 | this.ariaLabelledBy = null;
|
---|
359 | /** Aria label to assign to the dialog element. */
|
---|
360 | this.ariaLabel = null;
|
---|
361 | /** Whether the dialog should focus the first focusable element on open. */
|
---|
362 | this.autoFocus = true;
|
---|
363 | /**
|
---|
364 | * Whether the dialog should restore focus to the
|
---|
365 | * previously-focused element, after it's closed.
|
---|
366 | */
|
---|
367 | this.restoreFocus = true;
|
---|
368 | /**
|
---|
369 | * Whether the dialog should close when the user goes backwards/forwards in history.
|
---|
370 | * Note that this usually doesn't include clicking on links (unless the user is using
|
---|
371 | * the `HashLocationStrategy`).
|
---|
372 | */
|
---|
373 | this.closeOnNavigation = true;
|
---|
374 | // TODO(jelbourn): add configuration for lifecycle hooks, ARIA labelling.
|
---|
375 | }
|
---|
376 | return MatDialogConfig;
|
---|
377 | }());
|
---|
378 |
|
---|
379 | /**
|
---|
380 | * @license
|
---|
381 | * Copyright Google LLC All Rights Reserved.
|
---|
382 | *
|
---|
383 | * Use of this source code is governed by an MIT-style license that can be
|
---|
384 | * found in the LICENSE file at https://angular.io/license
|
---|
385 | */
|
---|
386 | /**
|
---|
387 | * Animations used by MatDialog.
|
---|
388 | * @docs-private
|
---|
389 | */
|
---|
390 | var matDialogAnimations = {
|
---|
391 | /** Animation that is applied on the dialog container by default. */
|
---|
392 | dialogContainer: animations.trigger('dialogContainer', [
|
---|
393 | // Note: The `enter` animation transitions to `transform: none`, because for some reason
|
---|
394 | // specifying the transform explicitly, causes IE both to blur the dialog content and
|
---|
395 | // decimate the animation performance. Leaving it as `none` solves both issues.
|
---|
396 | animations.state('void, exit', animations.style({ opacity: 0, transform: 'scale(0.7)' })),
|
---|
397 | animations.state('enter', animations.style({ transform: 'none' })),
|
---|
398 | animations.transition('* => enter', animations.animate('150ms cubic-bezier(0, 0, 0.2, 1)', animations.style({ transform: 'none', opacity: 1 }))),
|
---|
399 | animations.transition('* => void, * => exit', animations.animate('75ms cubic-bezier(0.4, 0.0, 0.2, 1)', animations.style({ opacity: 0 }))),
|
---|
400 | ])
|
---|
401 | };
|
---|
402 |
|
---|
403 | /**
|
---|
404 | * Throws an exception for the case when a ComponentPortal is
|
---|
405 | * attached to a DomPortalOutlet without an origin.
|
---|
406 | * @docs-private
|
---|
407 | */
|
---|
408 | function throwMatDialogContentAlreadyAttachedError() {
|
---|
409 | throw Error('Attempting to attach dialog content after content is already attached');
|
---|
410 | }
|
---|
411 | /**
|
---|
412 | * Base class for the `MatDialogContainer`. The base class does not implement
|
---|
413 | * animations as these are left to implementers of the dialog container.
|
---|
414 | */
|
---|
415 | var _MatDialogContainerBase = /** @class */ (function (_super) {
|
---|
416 | __extends(_MatDialogContainerBase, _super);
|
---|
417 | function _MatDialogContainerBase(_elementRef, _focusTrapFactory, _changeDetectorRef, _document,
|
---|
418 | /** The dialog configuration. */
|
---|
419 | _config, _focusMonitor) {
|
---|
420 | var _this = _super.call(this) || this;
|
---|
421 | _this._elementRef = _elementRef;
|
---|
422 | _this._focusTrapFactory = _focusTrapFactory;
|
---|
423 | _this._changeDetectorRef = _changeDetectorRef;
|
---|
424 | _this._config = _config;
|
---|
425 | _this._focusMonitor = _focusMonitor;
|
---|
426 | /** Emits when an animation state changes. */
|
---|
427 | _this._animationStateChanged = new core.EventEmitter();
|
---|
428 | /** Element that was focused before the dialog was opened. Save this to restore upon close. */
|
---|
429 | _this._elementFocusedBeforeDialogWasOpened = null;
|
---|
430 | /**
|
---|
431 | * Type of interaction that led to the dialog being closed. This is used to determine
|
---|
432 | * whether the focus style will be applied when returning focus to its original location
|
---|
433 | * after the dialog is closed.
|
---|
434 | */
|
---|
435 | _this._closeInteractionType = null;
|
---|
436 | /**
|
---|
437 | * Attaches a DOM portal to the dialog container.
|
---|
438 | * @param portal Portal to be attached.
|
---|
439 | * @deprecated To be turned into a method.
|
---|
440 | * @breaking-change 10.0.0
|
---|
441 | */
|
---|
442 | _this.attachDomPortal = function (portal) {
|
---|
443 | if (_this._portalOutlet.hasAttached() && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
---|
444 | throwMatDialogContentAlreadyAttachedError();
|
---|
445 | }
|
---|
446 | return _this._portalOutlet.attachDomPortal(portal);
|
---|
447 | };
|
---|
448 | _this._ariaLabelledBy = _config.ariaLabelledBy || null;
|
---|
449 | _this._document = _document;
|
---|
450 | return _this;
|
---|
451 | }
|
---|
452 | /** Initializes the dialog container with the attached content. */
|
---|
453 | _MatDialogContainerBase.prototype._initializeWithAttachedContent = function () {
|
---|
454 | this._setupFocusTrap();
|
---|
455 | // Save the previously focused element. This element will be re-focused
|
---|
456 | // when the dialog closes.
|
---|
457 | this._capturePreviouslyFocusedElement();
|
---|
458 | // Move focus onto the dialog immediately in order to prevent the user
|
---|
459 | // from accidentally opening multiple dialogs at the same time.
|
---|
460 | this._focusDialogContainer();
|
---|
461 | };
|
---|
462 | /**
|
---|
463 | * Attach a ComponentPortal as content to this dialog container.
|
---|
464 | * @param portal Portal to be attached as the dialog content.
|
---|
465 | */
|
---|
466 | _MatDialogContainerBase.prototype.attachComponentPortal = function (portal) {
|
---|
467 | if (this._portalOutlet.hasAttached() && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
---|
468 | throwMatDialogContentAlreadyAttachedError();
|
---|
469 | }
|
---|
470 | return this._portalOutlet.attachComponentPortal(portal);
|
---|
471 | };
|
---|
472 | /**
|
---|
473 | * Attach a TemplatePortal as content to this dialog container.
|
---|
474 | * @param portal Portal to be attached as the dialog content.
|
---|
475 | */
|
---|
476 | _MatDialogContainerBase.prototype.attachTemplatePortal = function (portal) {
|
---|
477 | if (this._portalOutlet.hasAttached() && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
---|
478 | throwMatDialogContentAlreadyAttachedError();
|
---|
479 | }
|
---|
480 | return this._portalOutlet.attachTemplatePortal(portal);
|
---|
481 | };
|
---|
482 | /** Moves focus back into the dialog if it was moved out. */
|
---|
483 | _MatDialogContainerBase.prototype._recaptureFocus = function () {
|
---|
484 | if (!this._containsFocus()) {
|
---|
485 | var focusContainer = !this._config.autoFocus || !this._focusTrap.focusInitialElement();
|
---|
486 | if (focusContainer) {
|
---|
487 | this._elementRef.nativeElement.focus();
|
---|
488 | }
|
---|
489 | }
|
---|
490 | };
|
---|
491 | /** Moves the focus inside the focus trap. */
|
---|
492 | _MatDialogContainerBase.prototype._trapFocus = function () {
|
---|
493 | // If we were to attempt to focus immediately, then the content of the dialog would not yet be
|
---|
494 | // ready in instances where change detection has to run first. To deal with this, we simply
|
---|
495 | // wait for the microtask queue to be empty.
|
---|
496 | if (this._config.autoFocus) {
|
---|
497 | this._focusTrap.focusInitialElementWhenReady();
|
---|
498 | }
|
---|
499 | else if (!this._containsFocus()) {
|
---|
500 | // Otherwise ensure that focus is on the dialog container. It's possible that a different
|
---|
501 | // component tried to move focus while the open animation was running. See:
|
---|
502 | // https://github.com/angular/components/issues/16215. Note that we only want to do this
|
---|
503 | // if the focus isn't inside the dialog already, because it's possible that the consumer
|
---|
504 | // turned off `autoFocus` in order to move focus themselves.
|
---|
505 | this._elementRef.nativeElement.focus();
|
---|
506 | }
|
---|
507 | };
|
---|
508 | /** Restores focus to the element that was focused before the dialog opened. */
|
---|
509 | _MatDialogContainerBase.prototype._restoreFocus = function () {
|
---|
510 | var previousElement = this._elementFocusedBeforeDialogWasOpened;
|
---|
511 | // We need the extra check, because IE can set the `activeElement` to null in some cases.
|
---|
512 | if (this._config.restoreFocus && previousElement &&
|
---|
513 | typeof previousElement.focus === 'function') {
|
---|
514 | var activeElement = platform._getFocusedElementPierceShadowDom();
|
---|
515 | var element = this._elementRef.nativeElement;
|
---|
516 | // Make sure that focus is still inside the dialog or is on the body (usually because a
|
---|
517 | // non-focusable element like the backdrop was clicked) before moving it. It's possible that
|
---|
518 | // the consumer moved it themselves before the animation was done, in which case we shouldn't
|
---|
519 | // do anything.
|
---|
520 | if (!activeElement || activeElement === this._document.body || activeElement === element ||
|
---|
521 | element.contains(activeElement)) {
|
---|
522 | if (this._focusMonitor) {
|
---|
523 | this._focusMonitor.focusVia(previousElement, this._closeInteractionType);
|
---|
524 | this._closeInteractionType = null;
|
---|
525 | }
|
---|
526 | else {
|
---|
527 | previousElement.focus();
|
---|
528 | }
|
---|
529 | }
|
---|
530 | }
|
---|
531 | if (this._focusTrap) {
|
---|
532 | this._focusTrap.destroy();
|
---|
533 | }
|
---|
534 | };
|
---|
535 | /** Sets up the focus trap. */
|
---|
536 | _MatDialogContainerBase.prototype._setupFocusTrap = function () {
|
---|
537 | this._focusTrap = this._focusTrapFactory.create(this._elementRef.nativeElement);
|
---|
538 | };
|
---|
539 | /** Captures the element that was focused before the dialog was opened. */
|
---|
540 | _MatDialogContainerBase.prototype._capturePreviouslyFocusedElement = function () {
|
---|
541 | if (this._document) {
|
---|
542 | this._elementFocusedBeforeDialogWasOpened = platform._getFocusedElementPierceShadowDom();
|
---|
543 | }
|
---|
544 | };
|
---|
545 | /** Focuses the dialog container. */
|
---|
546 | _MatDialogContainerBase.prototype._focusDialogContainer = function () {
|
---|
547 | // Note that there is no focus method when rendering on the server.
|
---|
548 | if (this._elementRef.nativeElement.focus) {
|
---|
549 | this._elementRef.nativeElement.focus();
|
---|
550 | }
|
---|
551 | };
|
---|
552 | /** Returns whether focus is inside the dialog. */
|
---|
553 | _MatDialogContainerBase.prototype._containsFocus = function () {
|
---|
554 | var element = this._elementRef.nativeElement;
|
---|
555 | var activeElement = platform._getFocusedElementPierceShadowDom();
|
---|
556 | return element === activeElement || element.contains(activeElement);
|
---|
557 | };
|
---|
558 | return _MatDialogContainerBase;
|
---|
559 | }(portal.BasePortalOutlet));
|
---|
560 | _MatDialogContainerBase.decorators = [
|
---|
561 | { type: core.Directive }
|
---|
562 | ];
|
---|
563 | _MatDialogContainerBase.ctorParameters = function () { return [
|
---|
564 | { type: core.ElementRef },
|
---|
565 | { type: a11y.FocusTrapFactory },
|
---|
566 | { type: core.ChangeDetectorRef },
|
---|
567 | { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [common.DOCUMENT,] }] },
|
---|
568 | { type: MatDialogConfig },
|
---|
569 | { type: a11y.FocusMonitor }
|
---|
570 | ]; };
|
---|
571 | _MatDialogContainerBase.propDecorators = {
|
---|
572 | _portalOutlet: [{ type: core.ViewChild, args: [portal.CdkPortalOutlet, { static: true },] }]
|
---|
573 | };
|
---|
574 | /**
|
---|
575 | * Internal component that wraps user-provided dialog content.
|
---|
576 | * Animation is based on https://material.io/guidelines/motion/choreography.html.
|
---|
577 | * @docs-private
|
---|
578 | */
|
---|
579 | var MatDialogContainer = /** @class */ (function (_super) {
|
---|
580 | __extends(MatDialogContainer, _super);
|
---|
581 | function MatDialogContainer() {
|
---|
582 | var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
---|
583 | /** State of the dialog animation. */
|
---|
584 | _this._state = 'enter';
|
---|
585 | return _this;
|
---|
586 | }
|
---|
587 | /** Callback, invoked whenever an animation on the host completes. */
|
---|
588 | MatDialogContainer.prototype._onAnimationDone = function (_a) {
|
---|
589 | var toState = _a.toState, totalTime = _a.totalTime;
|
---|
590 | if (toState === 'enter') {
|
---|
591 | this._trapFocus();
|
---|
592 | this._animationStateChanged.next({ state: 'opened', totalTime: totalTime });
|
---|
593 | }
|
---|
594 | else if (toState === 'exit') {
|
---|
595 | this._restoreFocus();
|
---|
596 | this._animationStateChanged.next({ state: 'closed', totalTime: totalTime });
|
---|
597 | }
|
---|
598 | };
|
---|
599 | /** Callback, invoked when an animation on the host starts. */
|
---|
600 | MatDialogContainer.prototype._onAnimationStart = function (_a) {
|
---|
601 | var toState = _a.toState, totalTime = _a.totalTime;
|
---|
602 | if (toState === 'enter') {
|
---|
603 | this._animationStateChanged.next({ state: 'opening', totalTime: totalTime });
|
---|
604 | }
|
---|
605 | else if (toState === 'exit' || toState === 'void') {
|
---|
606 | this._animationStateChanged.next({ state: 'closing', totalTime: totalTime });
|
---|
607 | }
|
---|
608 | };
|
---|
609 | /** Starts the dialog exit animation. */
|
---|
610 | MatDialogContainer.prototype._startExitAnimation = function () {
|
---|
611 | this._state = 'exit';
|
---|
612 | // Mark the container for check so it can react if the
|
---|
613 | // view container is using OnPush change detection.
|
---|
614 | this._changeDetectorRef.markForCheck();
|
---|
615 | };
|
---|
616 | return MatDialogContainer;
|
---|
617 | }(_MatDialogContainerBase));
|
---|
618 | MatDialogContainer.decorators = [
|
---|
619 | { type: core.Component, args: [{
|
---|
620 | selector: 'mat-dialog-container',
|
---|
621 | template: "<ng-template cdkPortalOutlet></ng-template>\n",
|
---|
622 | encapsulation: core.ViewEncapsulation.None,
|
---|
623 | // Using OnPush for dialogs caused some G3 sync issues. Disabled until we can track them down.
|
---|
624 | // tslint:disable-next-line:validate-decorators
|
---|
625 | changeDetection: core.ChangeDetectionStrategy.Default,
|
---|
626 | animations: [matDialogAnimations.dialogContainer],
|
---|
627 | host: {
|
---|
628 | 'class': 'mat-dialog-container',
|
---|
629 | 'tabindex': '-1',
|
---|
630 | 'aria-modal': 'true',
|
---|
631 | '[id]': '_id',
|
---|
632 | '[attr.role]': '_config.role',
|
---|
633 | '[attr.aria-labelledby]': '_config.ariaLabel ? null : _ariaLabelledBy',
|
---|
634 | '[attr.aria-label]': '_config.ariaLabel',
|
---|
635 | '[attr.aria-describedby]': '_config.ariaDescribedBy || null',
|
---|
636 | '[@dialogContainer]': '_state',
|
---|
637 | '(@dialogContainer.start)': '_onAnimationStart($event)',
|
---|
638 | '(@dialogContainer.done)': '_onAnimationDone($event)',
|
---|
639 | },
|
---|
640 | styles: [".mat-dialog-container{display:block;padding:24px;border-radius:4px;box-sizing:border-box;overflow:auto;outline:0;width:100%;height:100%;min-height:inherit;max-height:inherit}.cdk-high-contrast-active .mat-dialog-container{outline:solid 1px}.mat-dialog-content{display:block;margin:0 -24px;padding:0 24px;max-height:65vh;overflow:auto;-webkit-overflow-scrolling:touch}.mat-dialog-title{margin:0 0 20px;display:block}.mat-dialog-actions{padding:8px 0;display:flex;flex-wrap:wrap;min-height:52px;align-items:center;box-sizing:content-box;margin-bottom:-24px}.mat-dialog-actions[align=end]{justify-content:flex-end}.mat-dialog-actions[align=center]{justify-content:center}.mat-dialog-actions .mat-button-base+.mat-button-base,.mat-dialog-actions .mat-mdc-button-base+.mat-mdc-button-base{margin-left:8px}[dir=rtl] .mat-dialog-actions .mat-button-base+.mat-button-base,[dir=rtl] .mat-dialog-actions .mat-mdc-button-base+.mat-mdc-button-base{margin-left:0;margin-right:8px}\n"]
|
---|
641 | },] }
|
---|
642 | ];
|
---|
643 |
|
---|
644 | /**
|
---|
645 | * @license
|
---|
646 | * Copyright Google LLC All Rights Reserved.
|
---|
647 | *
|
---|
648 | * Use of this source code is governed by an MIT-style license that can be
|
---|
649 | * found in the LICENSE file at https://angular.io/license
|
---|
650 | */
|
---|
651 | // TODO(jelbourn): resizing
|
---|
652 | // Counter for unique dialog ids.
|
---|
653 | var uniqueId = 0;
|
---|
654 | /**
|
---|
655 | * Reference to a dialog opened via the MatDialog service.
|
---|
656 | */
|
---|
657 | var MatDialogRef = /** @class */ (function () {
|
---|
658 | function MatDialogRef(_overlayRef, _containerInstance,
|
---|
659 | /** Id of the dialog. */
|
---|
660 | id) {
|
---|
661 | var _this = this;
|
---|
662 | if (id === void 0) { id = "mat-dialog-" + uniqueId++; }
|
---|
663 | this._overlayRef = _overlayRef;
|
---|
664 | this._containerInstance = _containerInstance;
|
---|
665 | this.id = id;
|
---|
666 | /** Whether the user is allowed to close the dialog. */
|
---|
667 | this.disableClose = this._containerInstance._config.disableClose;
|
---|
668 | /** Subject for notifying the user that the dialog has finished opening. */
|
---|
669 | this._afterOpened = new rxjs.Subject();
|
---|
670 | /** Subject for notifying the user that the dialog has finished closing. */
|
---|
671 | this._afterClosed = new rxjs.Subject();
|
---|
672 | /** Subject for notifying the user that the dialog has started closing. */
|
---|
673 | this._beforeClosed = new rxjs.Subject();
|
---|
674 | /** Current state of the dialog. */
|
---|
675 | this._state = 0 /* OPEN */;
|
---|
676 | // Pass the id along to the container.
|
---|
677 | _containerInstance._id = id;
|
---|
678 | // Emit when opening animation completes
|
---|
679 | _containerInstance._animationStateChanged.pipe(operators.filter(function (event) { return event.state === 'opened'; }), operators.take(1))
|
---|
680 | .subscribe(function () {
|
---|
681 | _this._afterOpened.next();
|
---|
682 | _this._afterOpened.complete();
|
---|
683 | });
|
---|
684 | // Dispose overlay when closing animation is complete
|
---|
685 | _containerInstance._animationStateChanged.pipe(operators.filter(function (event) { return event.state === 'closed'; }), operators.take(1)).subscribe(function () {
|
---|
686 | clearTimeout(_this._closeFallbackTimeout);
|
---|
687 | _this._finishDialogClose();
|
---|
688 | });
|
---|
689 | _overlayRef.detachments().subscribe(function () {
|
---|
690 | _this._beforeClosed.next(_this._result);
|
---|
691 | _this._beforeClosed.complete();
|
---|
692 | _this._afterClosed.next(_this._result);
|
---|
693 | _this._afterClosed.complete();
|
---|
694 | _this.componentInstance = null;
|
---|
695 | _this._overlayRef.dispose();
|
---|
696 | });
|
---|
697 | _overlayRef.keydownEvents()
|
---|
698 | .pipe(operators.filter(function (event) {
|
---|
699 | return event.keyCode === keycodes.ESCAPE && !_this.disableClose && !keycodes.hasModifierKey(event);
|
---|
700 | }))
|
---|
701 | .subscribe(function (event) {
|
---|
702 | event.preventDefault();
|
---|
703 | _closeDialogVia(_this, 'keyboard');
|
---|
704 | });
|
---|
705 | _overlayRef.backdropClick().subscribe(function () {
|
---|
706 | if (_this.disableClose) {
|
---|
707 | _this._containerInstance._recaptureFocus();
|
---|
708 | }
|
---|
709 | else {
|
---|
710 | _closeDialogVia(_this, 'mouse');
|
---|
711 | }
|
---|
712 | });
|
---|
713 | }
|
---|
714 | /**
|
---|
715 | * Close the dialog.
|
---|
716 | * @param dialogResult Optional result to return to the dialog opener.
|
---|
717 | */
|
---|
718 | MatDialogRef.prototype.close = function (dialogResult) {
|
---|
719 | var _this = this;
|
---|
720 | this._result = dialogResult;
|
---|
721 | // Transition the backdrop in parallel to the dialog.
|
---|
722 | this._containerInstance._animationStateChanged.pipe(operators.filter(function (event) { return event.state === 'closing'; }), operators.take(1))
|
---|
723 | .subscribe(function (event) {
|
---|
724 | _this._beforeClosed.next(dialogResult);
|
---|
725 | _this._beforeClosed.complete();
|
---|
726 | _this._overlayRef.detachBackdrop();
|
---|
727 | // The logic that disposes of the overlay depends on the exit animation completing, however
|
---|
728 | // it isn't guaranteed if the parent view is destroyed while it's running. Add a fallback
|
---|
729 | // timeout which will clean everything up if the animation hasn't fired within the specified
|
---|
730 | // amount of time plus 100ms. We don't need to run this outside the NgZone, because for the
|
---|
731 | // vast majority of cases the timeout will have been cleared before it has the chance to fire.
|
---|
732 | _this._closeFallbackTimeout = setTimeout(function () { return _this._finishDialogClose(); }, event.totalTime + 100);
|
---|
733 | });
|
---|
734 | this._state = 1 /* CLOSING */;
|
---|
735 | this._containerInstance._startExitAnimation();
|
---|
736 | };
|
---|
737 | /**
|
---|
738 | * Gets an observable that is notified when the dialog is finished opening.
|
---|
739 | */
|
---|
740 | MatDialogRef.prototype.afterOpened = function () {
|
---|
741 | return this._afterOpened;
|
---|
742 | };
|
---|
743 | /**
|
---|
744 | * Gets an observable that is notified when the dialog is finished closing.
|
---|
745 | */
|
---|
746 | MatDialogRef.prototype.afterClosed = function () {
|
---|
747 | return this._afterClosed;
|
---|
748 | };
|
---|
749 | /**
|
---|
750 | * Gets an observable that is notified when the dialog has started closing.
|
---|
751 | */
|
---|
752 | MatDialogRef.prototype.beforeClosed = function () {
|
---|
753 | return this._beforeClosed;
|
---|
754 | };
|
---|
755 | /**
|
---|
756 | * Gets an observable that emits when the overlay's backdrop has been clicked.
|
---|
757 | */
|
---|
758 | MatDialogRef.prototype.backdropClick = function () {
|
---|
759 | return this._overlayRef.backdropClick();
|
---|
760 | };
|
---|
761 | /**
|
---|
762 | * Gets an observable that emits when keydown events are targeted on the overlay.
|
---|
763 | */
|
---|
764 | MatDialogRef.prototype.keydownEvents = function () {
|
---|
765 | return this._overlayRef.keydownEvents();
|
---|
766 | };
|
---|
767 | /**
|
---|
768 | * Updates the dialog's position.
|
---|
769 | * @param position New dialog position.
|
---|
770 | */
|
---|
771 | MatDialogRef.prototype.updatePosition = function (position) {
|
---|
772 | var strategy = this._getPositionStrategy();
|
---|
773 | if (position && (position.left || position.right)) {
|
---|
774 | position.left ? strategy.left(position.left) : strategy.right(position.right);
|
---|
775 | }
|
---|
776 | else {
|
---|
777 | strategy.centerHorizontally();
|
---|
778 | }
|
---|
779 | if (position && (position.top || position.bottom)) {
|
---|
780 | position.top ? strategy.top(position.top) : strategy.bottom(position.bottom);
|
---|
781 | }
|
---|
782 | else {
|
---|
783 | strategy.centerVertically();
|
---|
784 | }
|
---|
785 | this._overlayRef.updatePosition();
|
---|
786 | return this;
|
---|
787 | };
|
---|
788 | /**
|
---|
789 | * Updates the dialog's width and height.
|
---|
790 | * @param width New width of the dialog.
|
---|
791 | * @param height New height of the dialog.
|
---|
792 | */
|
---|
793 | MatDialogRef.prototype.updateSize = function (width, height) {
|
---|
794 | if (width === void 0) { width = ''; }
|
---|
795 | if (height === void 0) { height = ''; }
|
---|
796 | this._overlayRef.updateSize({ width: width, height: height });
|
---|
797 | this._overlayRef.updatePosition();
|
---|
798 | return this;
|
---|
799 | };
|
---|
800 | /** Add a CSS class or an array of classes to the overlay pane. */
|
---|
801 | MatDialogRef.prototype.addPanelClass = function (classes) {
|
---|
802 | this._overlayRef.addPanelClass(classes);
|
---|
803 | return this;
|
---|
804 | };
|
---|
805 | /** Remove a CSS class or an array of classes from the overlay pane. */
|
---|
806 | MatDialogRef.prototype.removePanelClass = function (classes) {
|
---|
807 | this._overlayRef.removePanelClass(classes);
|
---|
808 | return this;
|
---|
809 | };
|
---|
810 | /** Gets the current state of the dialog's lifecycle. */
|
---|
811 | MatDialogRef.prototype.getState = function () {
|
---|
812 | return this._state;
|
---|
813 | };
|
---|
814 | /**
|
---|
815 | * Finishes the dialog close by updating the state of the dialog
|
---|
816 | * and disposing the overlay.
|
---|
817 | */
|
---|
818 | MatDialogRef.prototype._finishDialogClose = function () {
|
---|
819 | this._state = 2 /* CLOSED */;
|
---|
820 | this._overlayRef.dispose();
|
---|
821 | };
|
---|
822 | /** Fetches the position strategy object from the overlay ref. */
|
---|
823 | MatDialogRef.prototype._getPositionStrategy = function () {
|
---|
824 | return this._overlayRef.getConfig().positionStrategy;
|
---|
825 | };
|
---|
826 | return MatDialogRef;
|
---|
827 | }());
|
---|
828 | /**
|
---|
829 | * Closes the dialog with the specified interaction type. This is currently not part of
|
---|
830 | * `MatDialogRef` as that would conflict with custom dialog ref mocks provided in tests.
|
---|
831 | * More details. See: https://github.com/angular/components/pull/9257#issuecomment-651342226.
|
---|
832 | */
|
---|
833 | // TODO: TODO: Move this back into `MatDialogRef` when we provide an official mock dialog ref.
|
---|
834 | function _closeDialogVia(ref, interactionType, result) {
|
---|
835 | // Some mock dialog ref instances in tests do not have the `_containerInstance` property.
|
---|
836 | // For those, we keep the behavior as is and do not deal with the interaction type.
|
---|
837 | if (ref._containerInstance !== undefined) {
|
---|
838 | ref._containerInstance._closeInteractionType = interactionType;
|
---|
839 | }
|
---|
840 | return ref.close(result);
|
---|
841 | }
|
---|
842 |
|
---|
843 | /** Injection token that can be used to access the data that was passed in to a dialog. */
|
---|
844 | var MAT_DIALOG_DATA = new core.InjectionToken('MatDialogData');
|
---|
845 | /** Injection token that can be used to specify default dialog options. */
|
---|
846 | var MAT_DIALOG_DEFAULT_OPTIONS = new core.InjectionToken('mat-dialog-default-options');
|
---|
847 | /** Injection token that determines the scroll handling while the dialog is open. */
|
---|
848 | var MAT_DIALOG_SCROLL_STRATEGY = new core.InjectionToken('mat-dialog-scroll-strategy');
|
---|
849 | /** @docs-private */
|
---|
850 | function MAT_DIALOG_SCROLL_STRATEGY_FACTORY(overlay) {
|
---|
851 | return function () { return overlay.scrollStrategies.block(); };
|
---|
852 | }
|
---|
853 | /** @docs-private */
|
---|
854 | function MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay) {
|
---|
855 | return function () { return overlay.scrollStrategies.block(); };
|
---|
856 | }
|
---|
857 | /** @docs-private */
|
---|
858 | var MAT_DIALOG_SCROLL_STRATEGY_PROVIDER = {
|
---|
859 | provide: MAT_DIALOG_SCROLL_STRATEGY,
|
---|
860 | deps: [overlay.Overlay],
|
---|
861 | useFactory: MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY,
|
---|
862 | };
|
---|
863 | /**
|
---|
864 | * Base class for dialog services. The base dialog service allows
|
---|
865 | * for arbitrary dialog refs and dialog container components.
|
---|
866 | */
|
---|
867 | var _MatDialogBase = /** @class */ (function () {
|
---|
868 | function _MatDialogBase(_overlay, _injector, _defaultOptions, _parentDialog, _overlayContainer, scrollStrategy, _dialogRefConstructor, _dialogContainerType, _dialogDataToken) {
|
---|
869 | var _this = this;
|
---|
870 | this._overlay = _overlay;
|
---|
871 | this._injector = _injector;
|
---|
872 | this._defaultOptions = _defaultOptions;
|
---|
873 | this._parentDialog = _parentDialog;
|
---|
874 | this._overlayContainer = _overlayContainer;
|
---|
875 | this._dialogRefConstructor = _dialogRefConstructor;
|
---|
876 | this._dialogContainerType = _dialogContainerType;
|
---|
877 | this._dialogDataToken = _dialogDataToken;
|
---|
878 | this._openDialogsAtThisLevel = [];
|
---|
879 | this._afterAllClosedAtThisLevel = new rxjs.Subject();
|
---|
880 | this._afterOpenedAtThisLevel = new rxjs.Subject();
|
---|
881 | this._ariaHiddenElements = new Map();
|
---|
882 | // TODO (jelbourn): tighten the typing right-hand side of this expression.
|
---|
883 | /**
|
---|
884 | * Stream that emits when all open dialog have finished closing.
|
---|
885 | * Will emit on subscribe if there are no open dialogs to begin with.
|
---|
886 | */
|
---|
887 | this.afterAllClosed = rxjs.defer(function () { return _this.openDialogs.length ?
|
---|
888 | _this._getAfterAllClosed() :
|
---|
889 | _this._getAfterAllClosed().pipe(operators.startWith(undefined)); });
|
---|
890 | this._scrollStrategy = scrollStrategy;
|
---|
891 | }
|
---|
892 | Object.defineProperty(_MatDialogBase.prototype, "openDialogs", {
|
---|
893 | /** Keeps track of the currently-open dialogs. */
|
---|
894 | get: function () {
|
---|
895 | return this._parentDialog ? this._parentDialog.openDialogs : this._openDialogsAtThisLevel;
|
---|
896 | },
|
---|
897 | enumerable: false,
|
---|
898 | configurable: true
|
---|
899 | });
|
---|
900 | Object.defineProperty(_MatDialogBase.prototype, "afterOpened", {
|
---|
901 | /** Stream that emits when a dialog has been opened. */
|
---|
902 | get: function () {
|
---|
903 | return this._parentDialog ? this._parentDialog.afterOpened : this._afterOpenedAtThisLevel;
|
---|
904 | },
|
---|
905 | enumerable: false,
|
---|
906 | configurable: true
|
---|
907 | });
|
---|
908 | _MatDialogBase.prototype._getAfterAllClosed = function () {
|
---|
909 | var parent = this._parentDialog;
|
---|
910 | return parent ? parent._getAfterAllClosed() : this._afterAllClosedAtThisLevel;
|
---|
911 | };
|
---|
912 | _MatDialogBase.prototype.open = function (componentOrTemplateRef, config) {
|
---|
913 | var _this = this;
|
---|
914 | config = _applyConfigDefaults(config, this._defaultOptions || new MatDialogConfig());
|
---|
915 | if (config.id && this.getDialogById(config.id) &&
|
---|
916 | (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
---|
917 | throw Error("Dialog with id \"" + config.id + "\" exists already. The dialog id must be unique.");
|
---|
918 | }
|
---|
919 | var overlayRef = this._createOverlay(config);
|
---|
920 | var dialogContainer = this._attachDialogContainer(overlayRef, config);
|
---|
921 | var dialogRef = this._attachDialogContent(componentOrTemplateRef, dialogContainer, overlayRef, config);
|
---|
922 | // If this is the first dialog that we're opening, hide all the non-overlay content.
|
---|
923 | if (!this.openDialogs.length) {
|
---|
924 | this._hideNonDialogContentFromAssistiveTechnology();
|
---|
925 | }
|
---|
926 | this.openDialogs.push(dialogRef);
|
---|
927 | dialogRef.afterClosed().subscribe(function () { return _this._removeOpenDialog(dialogRef); });
|
---|
928 | this.afterOpened.next(dialogRef);
|
---|
929 | // Notify the dialog container that the content has been attached.
|
---|
930 | dialogContainer._initializeWithAttachedContent();
|
---|
931 | return dialogRef;
|
---|
932 | };
|
---|
933 | /**
|
---|
934 | * Closes all of the currently-open dialogs.
|
---|
935 | */
|
---|
936 | _MatDialogBase.prototype.closeAll = function () {
|
---|
937 | this._closeDialogs(this.openDialogs);
|
---|
938 | };
|
---|
939 | /**
|
---|
940 | * Finds an open dialog by its id.
|
---|
941 | * @param id ID to use when looking up the dialog.
|
---|
942 | */
|
---|
943 | _MatDialogBase.prototype.getDialogById = function (id) {
|
---|
944 | return this.openDialogs.find(function (dialog) { return dialog.id === id; });
|
---|
945 | };
|
---|
946 | _MatDialogBase.prototype.ngOnDestroy = function () {
|
---|
947 | // Only close the dialogs at this level on destroy
|
---|
948 | // since the parent service may still be active.
|
---|
949 | this._closeDialogs(this._openDialogsAtThisLevel);
|
---|
950 | this._afterAllClosedAtThisLevel.complete();
|
---|
951 | this._afterOpenedAtThisLevel.complete();
|
---|
952 | };
|
---|
953 | /**
|
---|
954 | * Creates the overlay into which the dialog will be loaded.
|
---|
955 | * @param config The dialog configuration.
|
---|
956 | * @returns A promise resolving to the OverlayRef for the created overlay.
|
---|
957 | */
|
---|
958 | _MatDialogBase.prototype._createOverlay = function (config) {
|
---|
959 | var overlayConfig = this._getOverlayConfig(config);
|
---|
960 | return this._overlay.create(overlayConfig);
|
---|
961 | };
|
---|
962 | /**
|
---|
963 | * Creates an overlay config from a dialog config.
|
---|
964 | * @param dialogConfig The dialog configuration.
|
---|
965 | * @returns The overlay configuration.
|
---|
966 | */
|
---|
967 | _MatDialogBase.prototype._getOverlayConfig = function (dialogConfig) {
|
---|
968 | var state = new overlay.OverlayConfig({
|
---|
969 | positionStrategy: this._overlay.position().global(),
|
---|
970 | scrollStrategy: dialogConfig.scrollStrategy || this._scrollStrategy(),
|
---|
971 | panelClass: dialogConfig.panelClass,
|
---|
972 | hasBackdrop: dialogConfig.hasBackdrop,
|
---|
973 | direction: dialogConfig.direction,
|
---|
974 | minWidth: dialogConfig.minWidth,
|
---|
975 | minHeight: dialogConfig.minHeight,
|
---|
976 | maxWidth: dialogConfig.maxWidth,
|
---|
977 | maxHeight: dialogConfig.maxHeight,
|
---|
978 | disposeOnNavigation: dialogConfig.closeOnNavigation
|
---|
979 | });
|
---|
980 | if (dialogConfig.backdropClass) {
|
---|
981 | state.backdropClass = dialogConfig.backdropClass;
|
---|
982 | }
|
---|
983 | return state;
|
---|
984 | };
|
---|
985 | /**
|
---|
986 | * Attaches a dialog container to a dialog's already-created overlay.
|
---|
987 | * @param overlay Reference to the dialog's underlying overlay.
|
---|
988 | * @param config The dialog configuration.
|
---|
989 | * @returns A promise resolving to a ComponentRef for the attached container.
|
---|
990 | */
|
---|
991 | _MatDialogBase.prototype._attachDialogContainer = function (overlay, config) {
|
---|
992 | var userInjector = config && config.viewContainerRef && config.viewContainerRef.injector;
|
---|
993 | var injector = core.Injector.create({
|
---|
994 | parent: userInjector || this._injector,
|
---|
995 | providers: [{ provide: MatDialogConfig, useValue: config }]
|
---|
996 | });
|
---|
997 | var containerPortal = new portal.ComponentPortal(this._dialogContainerType, config.viewContainerRef, injector, config.componentFactoryResolver);
|
---|
998 | var containerRef = overlay.attach(containerPortal);
|
---|
999 | return containerRef.instance;
|
---|
1000 | };
|
---|
1001 | /**
|
---|
1002 | * Attaches the user-provided component to the already-created dialog container.
|
---|
1003 | * @param componentOrTemplateRef The type of component being loaded into the dialog,
|
---|
1004 | * or a TemplateRef to instantiate as the content.
|
---|
1005 | * @param dialogContainer Reference to the wrapping dialog container.
|
---|
1006 | * @param overlayRef Reference to the overlay in which the dialog resides.
|
---|
1007 | * @param config The dialog configuration.
|
---|
1008 | * @returns A promise resolving to the MatDialogRef that should be returned to the user.
|
---|
1009 | */
|
---|
1010 | _MatDialogBase.prototype._attachDialogContent = function (componentOrTemplateRef, dialogContainer, overlayRef, config) {
|
---|
1011 | // Create a reference to the dialog we're creating in order to give the user a handle
|
---|
1012 | // to modify and close it.
|
---|
1013 | var dialogRef = new this._dialogRefConstructor(overlayRef, dialogContainer, config.id);
|
---|
1014 | if (componentOrTemplateRef instanceof core.TemplateRef) {
|
---|
1015 | dialogContainer.attachTemplatePortal(new portal.TemplatePortal(componentOrTemplateRef, null, { $implicit: config.data, dialogRef: dialogRef }));
|
---|
1016 | }
|
---|
1017 | else {
|
---|
1018 | var injector = this._createInjector(config, dialogRef, dialogContainer);
|
---|
1019 | var contentRef = dialogContainer.attachComponentPortal(new portal.ComponentPortal(componentOrTemplateRef, config.viewContainerRef, injector));
|
---|
1020 | dialogRef.componentInstance = contentRef.instance;
|
---|
1021 | }
|
---|
1022 | dialogRef
|
---|
1023 | .updateSize(config.width, config.height)
|
---|
1024 | .updatePosition(config.position);
|
---|
1025 | return dialogRef;
|
---|
1026 | };
|
---|
1027 | /**
|
---|
1028 | * Creates a custom injector to be used inside the dialog. This allows a component loaded inside
|
---|
1029 | * of a dialog to close itself and, optionally, to return a value.
|
---|
1030 | * @param config Config object that is used to construct the dialog.
|
---|
1031 | * @param dialogRef Reference to the dialog.
|
---|
1032 | * @param dialogContainer Dialog container element that wraps all of the contents.
|
---|
1033 | * @returns The custom injector that can be used inside the dialog.
|
---|
1034 | */
|
---|
1035 | _MatDialogBase.prototype._createInjector = function (config, dialogRef, dialogContainer) {
|
---|
1036 | var userInjector = config && config.viewContainerRef && config.viewContainerRef.injector;
|
---|
1037 | // The dialog container should be provided as the dialog container and the dialog's
|
---|
1038 | // content are created out of the same `ViewContainerRef` and as such, are siblings
|
---|
1039 | // for injector purposes. To allow the hierarchy that is expected, the dialog
|
---|
1040 | // container is explicitly provided in the injector.
|
---|
1041 | var providers = [
|
---|
1042 | { provide: this._dialogContainerType, useValue: dialogContainer },
|
---|
1043 | { provide: this._dialogDataToken, useValue: config.data },
|
---|
1044 | { provide: this._dialogRefConstructor, useValue: dialogRef }
|
---|
1045 | ];
|
---|
1046 | if (config.direction && (!userInjector ||
|
---|
1047 | !userInjector.get(bidi.Directionality, null, core.InjectFlags.Optional))) {
|
---|
1048 | providers.push({
|
---|
1049 | provide: bidi.Directionality,
|
---|
1050 | useValue: { value: config.direction, change: rxjs.of() }
|
---|
1051 | });
|
---|
1052 | }
|
---|
1053 | return core.Injector.create({ parent: userInjector || this._injector, providers: providers });
|
---|
1054 | };
|
---|
1055 | /**
|
---|
1056 | * Removes a dialog from the array of open dialogs.
|
---|
1057 | * @param dialogRef Dialog to be removed.
|
---|
1058 | */
|
---|
1059 | _MatDialogBase.prototype._removeOpenDialog = function (dialogRef) {
|
---|
1060 | var index = this.openDialogs.indexOf(dialogRef);
|
---|
1061 | if (index > -1) {
|
---|
1062 | this.openDialogs.splice(index, 1);
|
---|
1063 | // If all the dialogs were closed, remove/restore the `aria-hidden`
|
---|
1064 | // to a the siblings and emit to the `afterAllClosed` stream.
|
---|
1065 | if (!this.openDialogs.length) {
|
---|
1066 | this._ariaHiddenElements.forEach(function (previousValue, element) {
|
---|
1067 | if (previousValue) {
|
---|
1068 | element.setAttribute('aria-hidden', previousValue);
|
---|
1069 | }
|
---|
1070 | else {
|
---|
1071 | element.removeAttribute('aria-hidden');
|
---|
1072 | }
|
---|
1073 | });
|
---|
1074 | this._ariaHiddenElements.clear();
|
---|
1075 | this._getAfterAllClosed().next();
|
---|
1076 | }
|
---|
1077 | }
|
---|
1078 | };
|
---|
1079 | /**
|
---|
1080 | * Hides all of the content that isn't an overlay from assistive technology.
|
---|
1081 | */
|
---|
1082 | _MatDialogBase.prototype._hideNonDialogContentFromAssistiveTechnology = function () {
|
---|
1083 | var overlayContainer = this._overlayContainer.getContainerElement();
|
---|
1084 | // Ensure that the overlay container is attached to the DOM.
|
---|
1085 | if (overlayContainer.parentElement) {
|
---|
1086 | var siblings = overlayContainer.parentElement.children;
|
---|
1087 | for (var i = siblings.length - 1; i > -1; i--) {
|
---|
1088 | var sibling = siblings[i];
|
---|
1089 | if (sibling !== overlayContainer &&
|
---|
1090 | sibling.nodeName !== 'SCRIPT' &&
|
---|
1091 | sibling.nodeName !== 'STYLE' &&
|
---|
1092 | !sibling.hasAttribute('aria-live')) {
|
---|
1093 | this._ariaHiddenElements.set(sibling, sibling.getAttribute('aria-hidden'));
|
---|
1094 | sibling.setAttribute('aria-hidden', 'true');
|
---|
1095 | }
|
---|
1096 | }
|
---|
1097 | }
|
---|
1098 | };
|
---|
1099 | /** Closes all of the dialogs in an array. */
|
---|
1100 | _MatDialogBase.prototype._closeDialogs = function (dialogs) {
|
---|
1101 | var i = dialogs.length;
|
---|
1102 | while (i--) {
|
---|
1103 | // The `_openDialogs` property isn't updated after close until the rxjs subscription
|
---|
1104 | // runs on the next microtask, in addition to modifying the array as we're going
|
---|
1105 | // through it. We loop through all of them and call close without assuming that
|
---|
1106 | // they'll be removed from the list instantaneously.
|
---|
1107 | dialogs[i].close();
|
---|
1108 | }
|
---|
1109 | };
|
---|
1110 | return _MatDialogBase;
|
---|
1111 | }());
|
---|
1112 | _MatDialogBase.decorators = [
|
---|
1113 | { type: core.Directive }
|
---|
1114 | ];
|
---|
1115 | _MatDialogBase.ctorParameters = function () { return [
|
---|
1116 | { type: overlay.Overlay },
|
---|
1117 | { type: core.Injector },
|
---|
1118 | { type: undefined },
|
---|
1119 | { type: undefined },
|
---|
1120 | { type: overlay.OverlayContainer },
|
---|
1121 | { type: undefined },
|
---|
1122 | { type: core.Type },
|
---|
1123 | { type: core.Type },
|
---|
1124 | { type: core.InjectionToken }
|
---|
1125 | ]; };
|
---|
1126 | /**
|
---|
1127 | * Service to open Material Design modal dialogs.
|
---|
1128 | */
|
---|
1129 | var MatDialog = /** @class */ (function (_super) {
|
---|
1130 | __extends(MatDialog, _super);
|
---|
1131 | function MatDialog(overlay, injector,
|
---|
1132 | /**
|
---|
1133 | * @deprecated `_location` parameter to be removed.
|
---|
1134 | * @breaking-change 10.0.0
|
---|
1135 | */
|
---|
1136 | location, defaultOptions, scrollStrategy, parentDialog, overlayContainer) {
|
---|
1137 | return _super.call(this, overlay, injector, defaultOptions, parentDialog, overlayContainer, scrollStrategy, MatDialogRef, MatDialogContainer, MAT_DIALOG_DATA) || this;
|
---|
1138 | }
|
---|
1139 | return MatDialog;
|
---|
1140 | }(_MatDialogBase));
|
---|
1141 | MatDialog.decorators = [
|
---|
1142 | { type: core.Injectable }
|
---|
1143 | ];
|
---|
1144 | MatDialog.ctorParameters = function () { return [
|
---|
1145 | { type: overlay.Overlay },
|
---|
1146 | { type: core.Injector },
|
---|
1147 | { type: common.Location, decorators: [{ type: core.Optional }] },
|
---|
1148 | { type: MatDialogConfig, decorators: [{ type: core.Optional }, { type: core.Inject, args: [MAT_DIALOG_DEFAULT_OPTIONS,] }] },
|
---|
1149 | { type: undefined, decorators: [{ type: core.Inject, args: [MAT_DIALOG_SCROLL_STRATEGY,] }] },
|
---|
1150 | { type: MatDialog, decorators: [{ type: core.Optional }, { type: core.SkipSelf }] },
|
---|
1151 | { type: overlay.OverlayContainer }
|
---|
1152 | ]; };
|
---|
1153 | /**
|
---|
1154 | * Applies default options to the dialog config.
|
---|
1155 | * @param config Config to be modified.
|
---|
1156 | * @param defaultOptions Default options provided.
|
---|
1157 | * @returns The new configuration object.
|
---|
1158 | */
|
---|
1159 | function _applyConfigDefaults(config, defaultOptions) {
|
---|
1160 | return Object.assign(Object.assign({}, defaultOptions), config);
|
---|
1161 | }
|
---|
1162 |
|
---|
1163 | /**
|
---|
1164 | * @license
|
---|
1165 | * Copyright Google LLC All Rights Reserved.
|
---|
1166 | *
|
---|
1167 | * Use of this source code is governed by an MIT-style license that can be
|
---|
1168 | * found in the LICENSE file at https://angular.io/license
|
---|
1169 | */
|
---|
1170 | /** Counter used to generate unique IDs for dialog elements. */
|
---|
1171 | var dialogElementUid = 0;
|
---|
1172 | /**
|
---|
1173 | * Button that will close the current dialog.
|
---|
1174 | */
|
---|
1175 | var MatDialogClose = /** @class */ (function () {
|
---|
1176 | function MatDialogClose(
|
---|
1177 | /**
|
---|
1178 | * Reference to the containing dialog.
|
---|
1179 | * @deprecated `dialogRef` property to become private.
|
---|
1180 | * @breaking-change 13.0.0
|
---|
1181 | */
|
---|
1182 | // The dialog title directive is always used in combination with a `MatDialogRef`.
|
---|
1183 | // tslint:disable-next-line: lightweight-tokens
|
---|
1184 | dialogRef, _elementRef, _dialog) {
|
---|
1185 | this.dialogRef = dialogRef;
|
---|
1186 | this._elementRef = _elementRef;
|
---|
1187 | this._dialog = _dialog;
|
---|
1188 | /** Default to "button" to prevents accidental form submits. */
|
---|
1189 | this.type = 'button';
|
---|
1190 | }
|
---|
1191 | MatDialogClose.prototype.ngOnInit = function () {
|
---|
1192 | if (!this.dialogRef) {
|
---|
1193 | // When this directive is included in a dialog via TemplateRef (rather than being
|
---|
1194 | // in a Component), the DialogRef isn't available via injection because embedded
|
---|
1195 | // views cannot be given a custom injector. Instead, we look up the DialogRef by
|
---|
1196 | // ID. This must occur in `onInit`, as the ID binding for the dialog container won't
|
---|
1197 | // be resolved at constructor time.
|
---|
1198 | this.dialogRef = getClosestDialog(this._elementRef, this._dialog.openDialogs);
|
---|
1199 | }
|
---|
1200 | };
|
---|
1201 | MatDialogClose.prototype.ngOnChanges = function (changes) {
|
---|
1202 | var proxiedChange = changes['_matDialogClose'] || changes['_matDialogCloseResult'];
|
---|
1203 | if (proxiedChange) {
|
---|
1204 | this.dialogResult = proxiedChange.currentValue;
|
---|
1205 | }
|
---|
1206 | };
|
---|
1207 | MatDialogClose.prototype._onButtonClick = function (event) {
|
---|
1208 | // Determinate the focus origin using the click event, because using the FocusMonitor will
|
---|
1209 | // result in incorrect origins. Most of the time, close buttons will be auto focused in the
|
---|
1210 | // dialog, and therefore clicking the button won't result in a focus change. This means that
|
---|
1211 | // the FocusMonitor won't detect any origin change, and will always output `program`.
|
---|
1212 | _closeDialogVia(this.dialogRef, event.screenX === 0 && event.screenY === 0 ? 'keyboard' : 'mouse', this.dialogResult);
|
---|
1213 | };
|
---|
1214 | return MatDialogClose;
|
---|
1215 | }());
|
---|
1216 | MatDialogClose.decorators = [
|
---|
1217 | { type: core.Directive, args: [{
|
---|
1218 | selector: '[mat-dialog-close], [matDialogClose]',
|
---|
1219 | exportAs: 'matDialogClose',
|
---|
1220 | host: {
|
---|
1221 | '(click)': '_onButtonClick($event)',
|
---|
1222 | '[attr.aria-label]': 'ariaLabel || null',
|
---|
1223 | '[attr.type]': 'type',
|
---|
1224 | }
|
---|
1225 | },] }
|
---|
1226 | ];
|
---|
1227 | MatDialogClose.ctorParameters = function () { return [
|
---|
1228 | { type: MatDialogRef, decorators: [{ type: core.Optional }] },
|
---|
1229 | { type: core.ElementRef },
|
---|
1230 | { type: MatDialog }
|
---|
1231 | ]; };
|
---|
1232 | MatDialogClose.propDecorators = {
|
---|
1233 | ariaLabel: [{ type: core.Input, args: ['aria-label',] }],
|
---|
1234 | type: [{ type: core.Input }],
|
---|
1235 | dialogResult: [{ type: core.Input, args: ['mat-dialog-close',] }],
|
---|
1236 | _matDialogClose: [{ type: core.Input, args: ['matDialogClose',] }]
|
---|
1237 | };
|
---|
1238 | /**
|
---|
1239 | * Title of a dialog element. Stays fixed to the top of the dialog when scrolling.
|
---|
1240 | */
|
---|
1241 | var MatDialogTitle = /** @class */ (function () {
|
---|
1242 | function MatDialogTitle(
|
---|
1243 | // The dialog title directive is always used in combination with a `MatDialogRef`.
|
---|
1244 | // tslint:disable-next-line: lightweight-tokens
|
---|
1245 | _dialogRef, _elementRef, _dialog) {
|
---|
1246 | this._dialogRef = _dialogRef;
|
---|
1247 | this._elementRef = _elementRef;
|
---|
1248 | this._dialog = _dialog;
|
---|
1249 | /** Unique id for the dialog title. If none is supplied, it will be auto-generated. */
|
---|
1250 | this.id = "mat-dialog-title-" + dialogElementUid++;
|
---|
1251 | }
|
---|
1252 | MatDialogTitle.prototype.ngOnInit = function () {
|
---|
1253 | var _this = this;
|
---|
1254 | if (!this._dialogRef) {
|
---|
1255 | this._dialogRef = getClosestDialog(this._elementRef, this._dialog.openDialogs);
|
---|
1256 | }
|
---|
1257 | if (this._dialogRef) {
|
---|
1258 | Promise.resolve().then(function () {
|
---|
1259 | var container = _this._dialogRef._containerInstance;
|
---|
1260 | if (container && !container._ariaLabelledBy) {
|
---|
1261 | container._ariaLabelledBy = _this.id;
|
---|
1262 | }
|
---|
1263 | });
|
---|
1264 | }
|
---|
1265 | };
|
---|
1266 | return MatDialogTitle;
|
---|
1267 | }());
|
---|
1268 | MatDialogTitle.decorators = [
|
---|
1269 | { type: core.Directive, args: [{
|
---|
1270 | selector: '[mat-dialog-title], [matDialogTitle]',
|
---|
1271 | exportAs: 'matDialogTitle',
|
---|
1272 | host: {
|
---|
1273 | 'class': 'mat-dialog-title',
|
---|
1274 | '[id]': 'id',
|
---|
1275 | },
|
---|
1276 | },] }
|
---|
1277 | ];
|
---|
1278 | MatDialogTitle.ctorParameters = function () { return [
|
---|
1279 | { type: MatDialogRef, decorators: [{ type: core.Optional }] },
|
---|
1280 | { type: core.ElementRef },
|
---|
1281 | { type: MatDialog }
|
---|
1282 | ]; };
|
---|
1283 | MatDialogTitle.propDecorators = {
|
---|
1284 | id: [{ type: core.Input }]
|
---|
1285 | };
|
---|
1286 | /**
|
---|
1287 | * Scrollable content container of a dialog.
|
---|
1288 | */
|
---|
1289 | var MatDialogContent = /** @class */ (function () {
|
---|
1290 | function MatDialogContent() {
|
---|
1291 | }
|
---|
1292 | return MatDialogContent;
|
---|
1293 | }());
|
---|
1294 | MatDialogContent.decorators = [
|
---|
1295 | { type: core.Directive, args: [{
|
---|
1296 | selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]",
|
---|
1297 | host: { 'class': 'mat-dialog-content' }
|
---|
1298 | },] }
|
---|
1299 | ];
|
---|
1300 | /**
|
---|
1301 | * Container for the bottom action buttons in a dialog.
|
---|
1302 | * Stays fixed to the bottom when scrolling.
|
---|
1303 | */
|
---|
1304 | var MatDialogActions = /** @class */ (function () {
|
---|
1305 | function MatDialogActions() {
|
---|
1306 | }
|
---|
1307 | return MatDialogActions;
|
---|
1308 | }());
|
---|
1309 | MatDialogActions.decorators = [
|
---|
1310 | { type: core.Directive, args: [{
|
---|
1311 | selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]",
|
---|
1312 | host: { 'class': 'mat-dialog-actions' }
|
---|
1313 | },] }
|
---|
1314 | ];
|
---|
1315 | /**
|
---|
1316 | * Finds the closest MatDialogRef to an element by looking at the DOM.
|
---|
1317 | * @param element Element relative to which to look for a dialog.
|
---|
1318 | * @param openDialogs References to the currently-open dialogs.
|
---|
1319 | */
|
---|
1320 | function getClosestDialog(element, openDialogs) {
|
---|
1321 | var parent = element.nativeElement.parentElement;
|
---|
1322 | while (parent && !parent.classList.contains('mat-dialog-container')) {
|
---|
1323 | parent = parent.parentElement;
|
---|
1324 | }
|
---|
1325 | return parent ? openDialogs.find(function (dialog) { return dialog.id === parent.id; }) : null;
|
---|
1326 | }
|
---|
1327 |
|
---|
1328 | /**
|
---|
1329 | * @license
|
---|
1330 | * Copyright Google LLC All Rights Reserved.
|
---|
1331 | *
|
---|
1332 | * Use of this source code is governed by an MIT-style license that can be
|
---|
1333 | * found in the LICENSE file at https://angular.io/license
|
---|
1334 | */
|
---|
1335 | var MatDialogModule = /** @class */ (function () {
|
---|
1336 | function MatDialogModule() {
|
---|
1337 | }
|
---|
1338 | return MatDialogModule;
|
---|
1339 | }());
|
---|
1340 | MatDialogModule.decorators = [
|
---|
1341 | { type: core.NgModule, args: [{
|
---|
1342 | imports: [
|
---|
1343 | overlay.OverlayModule,
|
---|
1344 | portal.PortalModule,
|
---|
1345 | core$1.MatCommonModule,
|
---|
1346 | ],
|
---|
1347 | exports: [
|
---|
1348 | MatDialogContainer,
|
---|
1349 | MatDialogClose,
|
---|
1350 | MatDialogTitle,
|
---|
1351 | MatDialogContent,
|
---|
1352 | MatDialogActions,
|
---|
1353 | core$1.MatCommonModule,
|
---|
1354 | ],
|
---|
1355 | declarations: [
|
---|
1356 | MatDialogContainer,
|
---|
1357 | MatDialogClose,
|
---|
1358 | MatDialogTitle,
|
---|
1359 | MatDialogActions,
|
---|
1360 | MatDialogContent,
|
---|
1361 | ],
|
---|
1362 | providers: [
|
---|
1363 | MatDialog,
|
---|
1364 | MAT_DIALOG_SCROLL_STRATEGY_PROVIDER,
|
---|
1365 | ],
|
---|
1366 | entryComponents: [MatDialogContainer],
|
---|
1367 | },] }
|
---|
1368 | ];
|
---|
1369 |
|
---|
1370 | /**
|
---|
1371 | * @license
|
---|
1372 | * Copyright Google LLC All Rights Reserved.
|
---|
1373 | *
|
---|
1374 | * Use of this source code is governed by an MIT-style license that can be
|
---|
1375 | * found in the LICENSE file at https://angular.io/license
|
---|
1376 | */
|
---|
1377 |
|
---|
1378 | /**
|
---|
1379 | * Generated bundle index. Do not edit.
|
---|
1380 | */
|
---|
1381 |
|
---|
1382 | exports.MAT_DIALOG_DATA = MAT_DIALOG_DATA;
|
---|
1383 | exports.MAT_DIALOG_DEFAULT_OPTIONS = MAT_DIALOG_DEFAULT_OPTIONS;
|
---|
1384 | exports.MAT_DIALOG_SCROLL_STRATEGY = MAT_DIALOG_SCROLL_STRATEGY;
|
---|
1385 | exports.MAT_DIALOG_SCROLL_STRATEGY_FACTORY = MAT_DIALOG_SCROLL_STRATEGY_FACTORY;
|
---|
1386 | exports.MAT_DIALOG_SCROLL_STRATEGY_PROVIDER = MAT_DIALOG_SCROLL_STRATEGY_PROVIDER;
|
---|
1387 | exports.MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY = MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY;
|
---|
1388 | exports.MatDialog = MatDialog;
|
---|
1389 | exports.MatDialogActions = MatDialogActions;
|
---|
1390 | exports.MatDialogClose = MatDialogClose;
|
---|
1391 | exports.MatDialogConfig = MatDialogConfig;
|
---|
1392 | exports.MatDialogContainer = MatDialogContainer;
|
---|
1393 | exports.MatDialogContent = MatDialogContent;
|
---|
1394 | exports.MatDialogModule = MatDialogModule;
|
---|
1395 | exports.MatDialogRef = MatDialogRef;
|
---|
1396 | exports.MatDialogTitle = MatDialogTitle;
|
---|
1397 | exports._MatDialogBase = _MatDialogBase;
|
---|
1398 | exports._MatDialogContainerBase = _MatDialogContainerBase;
|
---|
1399 | exports._closeDialogVia = _closeDialogVia;
|
---|
1400 | exports.matDialogAnimations = matDialogAnimations;
|
---|
1401 | exports.throwMatDialogContentAlreadyAttachedError = throwMatDialogContentAlreadyAttachedError;
|
---|
1402 |
|
---|
1403 | Object.defineProperty(exports, '__esModule', { value: true });
|
---|
1404 |
|
---|
1405 | })));
|
---|
1406 | //# sourceMappingURL=material-dialog.umd.js.map
|
---|