source: trip-planner-front/node_modules/@angular/material/bundles/material-bottom-sheet.umd.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 44.4 KB
RevLine 
[6a3a178]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/layout'), require('@angular/animations'), require('@angular/common'), require('@angular/cdk/a11y'), require('@angular/cdk/platform'), require('@angular/cdk/bidi'), require('rxjs'), require('@angular/cdk/keycodes'), require('rxjs/operators')) :
3 typeof define === 'function' && define.amd ? define('@angular/material/bottom-sheet', ['exports', '@angular/cdk/overlay', '@angular/cdk/portal', '@angular/core', '@angular/material/core', '@angular/cdk/layout', '@angular/animations', '@angular/common', '@angular/cdk/a11y', '@angular/cdk/platform', '@angular/cdk/bidi', 'rxjs', '@angular/cdk/keycodes', 'rxjs/operators'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ng = global.ng || {}, global.ng.material = global.ng.material || {}, global.ng.material.bottomSheet = {}), global.ng.cdk.overlay, global.ng.cdk.portal, global.ng.core, global.ng.material.core, global.ng.cdk.layout, global.ng.animations, global.ng.common, global.ng.cdk.a11y, global.ng.cdk.platform, global.ng.cdk.bidi, global.rxjs, global.ng.cdk.keycodes, global.rxjs.operators));
5}(this, (function (exports, i1, portal, i0, core, layout, animations, common, a11y, platform, bidi, rxjs, keycodes, operators) { 'use strict';
6
7 function _interopNamespace(e) {
8 if (e && e.__esModule) return e;
9 var n = Object.create(null);
10 if (e) {
11 Object.keys(e).forEach(function (k) {
12 if (k !== 'default') {
13 var d = Object.getOwnPropertyDescriptor(e, k);
14 Object.defineProperty(n, k, d.get ? d : {
15 enumerable: true,
16 get: function () {
17 return e[k];
18 }
19 });
20 }
21 });
22 }
23 n['default'] = e;
24 return Object.freeze(n);
25 }
26
27 var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
28 var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
29
30 /*! *****************************************************************************
31 Copyright (c) Microsoft Corporation.
32
33 Permission to use, copy, modify, and/or distribute this software for any
34 purpose with or without fee is hereby granted.
35
36 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
37 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
38 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
39 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
40 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
41 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
42 PERFORMANCE OF THIS SOFTWARE.
43 ***************************************************************************** */
44 /* global Reflect, Promise */
45 var extendStatics = function (d, b) {
46 extendStatics = Object.setPrototypeOf ||
47 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
48 function (d, b) { for (var p in b)
49 if (Object.prototype.hasOwnProperty.call(b, p))
50 d[p] = b[p]; };
51 return extendStatics(d, b);
52 };
53 function __extends(d, b) {
54 if (typeof b !== "function" && b !== null)
55 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
56 extendStatics(d, b);
57 function __() { this.constructor = d; }
58 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
59 }
60 var __assign = function () {
61 __assign = Object.assign || function __assign(t) {
62 for (var s, i = 1, n = arguments.length; i < n; i++) {
63 s = arguments[i];
64 for (var p in s)
65 if (Object.prototype.hasOwnProperty.call(s, p))
66 t[p] = s[p];
67 }
68 return t;
69 };
70 return __assign.apply(this, arguments);
71 };
72 function __rest(s, e) {
73 var t = {};
74 for (var p in s)
75 if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
76 t[p] = s[p];
77 if (s != null && typeof Object.getOwnPropertySymbols === "function")
78 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
79 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
80 t[p[i]] = s[p[i]];
81 }
82 return t;
83 }
84 function __decorate(decorators, target, key, desc) {
85 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
86 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
87 r = Reflect.decorate(decorators, target, key, desc);
88 else
89 for (var i = decorators.length - 1; i >= 0; i--)
90 if (d = decorators[i])
91 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
92 return c > 3 && r && Object.defineProperty(target, key, r), r;
93 }
94 function __param(paramIndex, decorator) {
95 return function (target, key) { decorator(target, key, paramIndex); };
96 }
97 function __metadata(metadataKey, metadataValue) {
98 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
99 return Reflect.metadata(metadataKey, metadataValue);
100 }
101 function __awaiter(thisArg, _arguments, P, generator) {
102 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
103 return new (P || (P = Promise))(function (resolve, reject) {
104 function fulfilled(value) { try {
105 step(generator.next(value));
106 }
107 catch (e) {
108 reject(e);
109 } }
110 function rejected(value) { try {
111 step(generator["throw"](value));
112 }
113 catch (e) {
114 reject(e);
115 } }
116 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
117 step((generator = generator.apply(thisArg, _arguments || [])).next());
118 });
119 }
120 function __generator(thisArg, body) {
121 var _ = { label: 0, sent: function () { if (t[0] & 1)
122 throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
123 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
124 function verb(n) { return function (v) { return step([n, v]); }; }
125 function step(op) {
126 if (f)
127 throw new TypeError("Generator is already executing.");
128 while (_)
129 try {
130 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)
131 return t;
132 if (y = 0, t)
133 op = [op[0] & 2, t.value];
134 switch (op[0]) {
135 case 0:
136 case 1:
137 t = op;
138 break;
139 case 4:
140 _.label++;
141 return { value: op[1], done: false };
142 case 5:
143 _.label++;
144 y = op[1];
145 op = [0];
146 continue;
147 case 7:
148 op = _.ops.pop();
149 _.trys.pop();
150 continue;
151 default:
152 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
153 _ = 0;
154 continue;
155 }
156 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
157 _.label = op[1];
158 break;
159 }
160 if (op[0] === 6 && _.label < t[1]) {
161 _.label = t[1];
162 t = op;
163 break;
164 }
165 if (t && _.label < t[2]) {
166 _.label = t[2];
167 _.ops.push(op);
168 break;
169 }
170 if (t[2])
171 _.ops.pop();
172 _.trys.pop();
173 continue;
174 }
175 op = body.call(thisArg, _);
176 }
177 catch (e) {
178 op = [6, e];
179 y = 0;
180 }
181 finally {
182 f = t = 0;
183 }
184 if (op[0] & 5)
185 throw op[1];
186 return { value: op[0] ? op[1] : void 0, done: true };
187 }
188 }
189 var __createBinding = Object.create ? (function (o, m, k, k2) {
190 if (k2 === undefined)
191 k2 = k;
192 Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
193 }) : (function (o, m, k, k2) {
194 if (k2 === undefined)
195 k2 = k;
196 o[k2] = m[k];
197 });
198 function __exportStar(m, o) {
199 for (var p in m)
200 if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
201 __createBinding(o, m, p);
202 }
203 function __values(o) {
204 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
205 if (m)
206 return m.call(o);
207 if (o && typeof o.length === "number")
208 return {
209 next: function () {
210 if (o && i >= o.length)
211 o = void 0;
212 return { value: o && o[i++], done: !o };
213 }
214 };
215 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
216 }
217 function __read(o, n) {
218 var m = typeof Symbol === "function" && o[Symbol.iterator];
219 if (!m)
220 return o;
221 var i = m.call(o), r, ar = [], e;
222 try {
223 while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
224 ar.push(r.value);
225 }
226 catch (error) {
227 e = { error: error };
228 }
229 finally {
230 try {
231 if (r && !r.done && (m = i["return"]))
232 m.call(i);
233 }
234 finally {
235 if (e)
236 throw e.error;
237 }
238 }
239 return ar;
240 }
241 /** @deprecated */
242 function __spread() {
243 for (var ar = [], i = 0; i < arguments.length; i++)
244 ar = ar.concat(__read(arguments[i]));
245 return ar;
246 }
247 /** @deprecated */
248 function __spreadArrays() {
249 for (var s = 0, i = 0, il = arguments.length; i < il; i++)
250 s += arguments[i].length;
251 for (var r = Array(s), k = 0, i = 0; i < il; i++)
252 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
253 r[k] = a[j];
254 return r;
255 }
256 function __spreadArray(to, from, pack) {
257 if (pack || arguments.length === 2)
258 for (var i = 0, l = from.length, ar; i < l; i++) {
259 if (ar || !(i in from)) {
260 if (!ar)
261 ar = Array.prototype.slice.call(from, 0, i);
262 ar[i] = from[i];
263 }
264 }
265 return to.concat(ar || from);
266 }
267 function __await(v) {
268 return this instanceof __await ? (this.v = v, this) : new __await(v);
269 }
270 function __asyncGenerator(thisArg, _arguments, generator) {
271 if (!Symbol.asyncIterator)
272 throw new TypeError("Symbol.asyncIterator is not defined.");
273 var g = generator.apply(thisArg, _arguments || []), i, q = [];
274 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
275 function verb(n) { if (g[n])
276 i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
277 function resume(n, v) { try {
278 step(g[n](v));
279 }
280 catch (e) {
281 settle(q[0][3], e);
282 } }
283 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
284 function fulfill(value) { resume("next", value); }
285 function reject(value) { resume("throw", value); }
286 function settle(f, v) { if (f(v), q.shift(), q.length)
287 resume(q[0][0], q[0][1]); }
288 }
289 function __asyncDelegator(o) {
290 var i, p;
291 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
292 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; }
293 }
294 function __asyncValues(o) {
295 if (!Symbol.asyncIterator)
296 throw new TypeError("Symbol.asyncIterator is not defined.");
297 var m = o[Symbol.asyncIterator], i;
298 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);
299 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); }); }; }
300 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
301 }
302 function __makeTemplateObject(cooked, raw) {
303 if (Object.defineProperty) {
304 Object.defineProperty(cooked, "raw", { value: raw });
305 }
306 else {
307 cooked.raw = raw;
308 }
309 return cooked;
310 }
311 ;
312 var __setModuleDefault = Object.create ? (function (o, v) {
313 Object.defineProperty(o, "default", { enumerable: true, value: v });
314 }) : function (o, v) {
315 o["default"] = v;
316 };
317 function __importStar(mod) {
318 if (mod && mod.__esModule)
319 return mod;
320 var result = {};
321 if (mod != null)
322 for (var k in mod)
323 if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
324 __createBinding(result, mod, k);
325 __setModuleDefault(result, mod);
326 return result;
327 }
328 function __importDefault(mod) {
329 return (mod && mod.__esModule) ? mod : { default: mod };
330 }
331 function __classPrivateFieldGet(receiver, state, kind, f) {
332 if (kind === "a" && !f)
333 throw new TypeError("Private accessor was defined without a getter");
334 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
335 throw new TypeError("Cannot read private member from an object whose class did not declare it");
336 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
337 }
338 function __classPrivateFieldSet(receiver, state, value, kind, f) {
339 if (kind === "m")
340 throw new TypeError("Private method is not writable");
341 if (kind === "a" && !f)
342 throw new TypeError("Private accessor was defined without a setter");
343 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
344 throw new TypeError("Cannot write private member to an object whose class did not declare it");
345 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
346 }
347
348 /**
349 * @license
350 * Copyright Google LLC All Rights Reserved.
351 *
352 * Use of this source code is governed by an MIT-style license that can be
353 * found in the LICENSE file at https://angular.io/license
354 */
355 /** Injection token that can be used to access the data that was passed in to a bottom sheet. */
356 var MAT_BOTTOM_SHEET_DATA = new i0.InjectionToken('MatBottomSheetData');
357 /**
358 * Configuration used when opening a bottom sheet.
359 */
360 var MatBottomSheetConfig = /** @class */ (function () {
361 function MatBottomSheetConfig() {
362 /** Data being injected into the child component. */
363 this.data = null;
364 /** Whether the bottom sheet has a backdrop. */
365 this.hasBackdrop = true;
366 /** Whether the user can use escape or clicking outside to close the bottom sheet. */
367 this.disableClose = false;
368 /** Aria label to assign to the bottom sheet element. */
369 this.ariaLabel = null;
370 /**
371 * Whether the bottom sheet should close when the user goes backwards/forwards in history.
372 * Note that this usually doesn't include clicking on links (unless the user is using
373 * the `HashLocationStrategy`).
374 */
375 this.closeOnNavigation = true;
376 // Note that this is disabled by default, because while the a11y recommendations are to focus
377 // the first focusable element, doing so prevents screen readers from reading out the
378 // rest of the bottom sheet content.
379 /** Whether the bottom sheet should focus the first focusable element on open. */
380 this.autoFocus = false;
381 /**
382 * Whether the bottom sheet should restore focus to the
383 * previously-focused element, after it's closed.
384 */
385 this.restoreFocus = true;
386 }
387 return MatBottomSheetConfig;
388 }());
389
390 /**
391 * @license
392 * Copyright Google LLC All Rights Reserved.
393 *
394 * Use of this source code is governed by an MIT-style license that can be
395 * found in the LICENSE file at https://angular.io/license
396 */
397 /** Animations used by the Material bottom sheet. */
398 var matBottomSheetAnimations = {
399 /** Animation that shows and hides a bottom sheet. */
400 bottomSheetState: animations.trigger('state', [
401 animations.state('void, hidden', animations.style({ transform: 'translateY(100%)' })),
402 animations.state('visible', animations.style({ transform: 'translateY(0%)' })),
403 animations.transition('visible => void, visible => hidden', animations.animate(core.AnimationDurations.COMPLEX + " " + core.AnimationCurves.ACCELERATION_CURVE)),
404 animations.transition('void => visible', animations.animate(core.AnimationDurations.EXITING + " " + core.AnimationCurves.DECELERATION_CURVE)),
405 ])
406 };
407
408 // TODO(crisbeto): consolidate some logic between this, MatDialog and MatSnackBar
409 /**
410 * Internal component that wraps user-provided bottom sheet content.
411 * @docs-private
412 */
413 var MatBottomSheetContainer = /** @class */ (function (_super) {
414 __extends(MatBottomSheetContainer, _super);
415 function MatBottomSheetContainer(_elementRef, _changeDetectorRef, _focusTrapFactory, breakpointObserver, document,
416 /** The bottom sheet configuration. */
417 bottomSheetConfig) {
418 var _this = _super.call(this) || this;
419 _this._elementRef = _elementRef;
420 _this._changeDetectorRef = _changeDetectorRef;
421 _this._focusTrapFactory = _focusTrapFactory;
422 _this.bottomSheetConfig = bottomSheetConfig;
423 /** The state of the bottom sheet animations. */
424 _this._animationState = 'void';
425 /** Emits whenever the state of the animation changes. */
426 _this._animationStateChanged = new i0.EventEmitter();
427 /** Element that was focused before the bottom sheet was opened. */
428 _this._elementFocusedBeforeOpened = null;
429 /**
430 * Attaches a DOM portal to the bottom sheet container.
431 * @deprecated To be turned into a method.
432 * @breaking-change 10.0.0
433 */
434 _this.attachDomPortal = function (portal) {
435 _this._validatePortalAttached();
436 _this._setPanelClass();
437 _this._savePreviouslyFocusedElement();
438 return _this._portalOutlet.attachDomPortal(portal);
439 };
440 _this._document = document;
441 _this._breakpointSubscription = breakpointObserver
442 .observe([layout.Breakpoints.Medium, layout.Breakpoints.Large, layout.Breakpoints.XLarge])
443 .subscribe(function () {
444 _this._toggleClass('mat-bottom-sheet-container-medium', breakpointObserver.isMatched(layout.Breakpoints.Medium));
445 _this._toggleClass('mat-bottom-sheet-container-large', breakpointObserver.isMatched(layout.Breakpoints.Large));
446 _this._toggleClass('mat-bottom-sheet-container-xlarge', breakpointObserver.isMatched(layout.Breakpoints.XLarge));
447 });
448 return _this;
449 }
450 /** Attach a component portal as content to this bottom sheet container. */
451 MatBottomSheetContainer.prototype.attachComponentPortal = function (portal) {
452 this._validatePortalAttached();
453 this._setPanelClass();
454 this._savePreviouslyFocusedElement();
455 return this._portalOutlet.attachComponentPortal(portal);
456 };
457 /** Attach a template portal as content to this bottom sheet container. */
458 MatBottomSheetContainer.prototype.attachTemplatePortal = function (portal) {
459 this._validatePortalAttached();
460 this._setPanelClass();
461 this._savePreviouslyFocusedElement();
462 return this._portalOutlet.attachTemplatePortal(portal);
463 };
464 /** Begin animation of bottom sheet entrance into view. */
465 MatBottomSheetContainer.prototype.enter = function () {
466 if (!this._destroyed) {
467 this._animationState = 'visible';
468 this._changeDetectorRef.detectChanges();
469 }
470 };
471 /** Begin animation of the bottom sheet exiting from view. */
472 MatBottomSheetContainer.prototype.exit = function () {
473 if (!this._destroyed) {
474 this._animationState = 'hidden';
475 this._changeDetectorRef.markForCheck();
476 }
477 };
478 MatBottomSheetContainer.prototype.ngOnDestroy = function () {
479 this._breakpointSubscription.unsubscribe();
480 this._destroyed = true;
481 };
482 MatBottomSheetContainer.prototype._onAnimationDone = function (event) {
483 if (event.toState === 'hidden') {
484 this._restoreFocus();
485 }
486 else if (event.toState === 'visible') {
487 this._trapFocus();
488 }
489 this._animationStateChanged.emit(event);
490 };
491 MatBottomSheetContainer.prototype._onAnimationStart = function (event) {
492 this._animationStateChanged.emit(event);
493 };
494 MatBottomSheetContainer.prototype._toggleClass = function (cssClass, add) {
495 var classList = this._elementRef.nativeElement.classList;
496 add ? classList.add(cssClass) : classList.remove(cssClass);
497 };
498 MatBottomSheetContainer.prototype._validatePortalAttached = function () {
499 if (this._portalOutlet.hasAttached() && (typeof ngDevMode === 'undefined' || ngDevMode)) {
500 throw Error('Attempting to attach bottom sheet content after content is already attached');
501 }
502 };
503 MatBottomSheetContainer.prototype._setPanelClass = function () {
504 var element = this._elementRef.nativeElement;
505 var panelClass = this.bottomSheetConfig.panelClass;
506 if (Array.isArray(panelClass)) {
507 // Note that we can't use a spread here, because IE doesn't support multiple arguments.
508 panelClass.forEach(function (cssClass) { return element.classList.add(cssClass); });
509 }
510 else if (panelClass) {
511 element.classList.add(panelClass);
512 }
513 };
514 /** Moves the focus inside the focus trap. */
515 MatBottomSheetContainer.prototype._trapFocus = function () {
516 var element = this._elementRef.nativeElement;
517 if (!this._focusTrap) {
518 this._focusTrap = this._focusTrapFactory.create(element);
519 }
520 if (this.bottomSheetConfig.autoFocus) {
521 this._focusTrap.focusInitialElementWhenReady();
522 }
523 else {
524 var activeElement = platform._getFocusedElementPierceShadowDom();
525 // Otherwise ensure that focus is on the container. It's possible that a different
526 // component tried to move focus while the open animation was running. See:
527 // https://github.com/angular/components/issues/16215. Note that we only want to do this
528 // if the focus isn't inside the bottom sheet already, because it's possible that the
529 // consumer turned off `autoFocus` in order to move focus themselves.
530 if (activeElement !== element && !element.contains(activeElement)) {
531 element.focus();
532 }
533 }
534 };
535 /** Restores focus to the element that was focused before the bottom sheet was opened. */
536 MatBottomSheetContainer.prototype._restoreFocus = function () {
537 var toFocus = this._elementFocusedBeforeOpened;
538 // We need the extra check, because IE can set the `activeElement` to null in some cases.
539 if (this.bottomSheetConfig.restoreFocus && toFocus && typeof toFocus.focus === 'function') {
540 var activeElement = platform._getFocusedElementPierceShadowDom();
541 var element = this._elementRef.nativeElement;
542 // Make sure that focus is still inside the bottom sheet or is on the body (usually because a
543 // non-focusable element like the backdrop was clicked) before moving it. It's possible that
544 // the consumer moved it themselves before the animation was done, in which case we shouldn't
545 // do anything.
546 if (!activeElement || activeElement === this._document.body || activeElement === element ||
547 element.contains(activeElement)) {
548 toFocus.focus();
549 }
550 }
551 if (this._focusTrap) {
552 this._focusTrap.destroy();
553 }
554 };
555 /** Saves a reference to the element that was focused before the bottom sheet was opened. */
556 MatBottomSheetContainer.prototype._savePreviouslyFocusedElement = function () {
557 var _this = this;
558 this._elementFocusedBeforeOpened = platform._getFocusedElementPierceShadowDom();
559 // The `focus` method isn't available during server-side rendering.
560 if (this._elementRef.nativeElement.focus) {
561 Promise.resolve().then(function () { return _this._elementRef.nativeElement.focus(); });
562 }
563 };
564 return MatBottomSheetContainer;
565 }(portal.BasePortalOutlet));
566 MatBottomSheetContainer.decorators = [
567 { type: i0.Component, args: [{
568 selector: 'mat-bottom-sheet-container',
569 template: "<ng-template cdkPortalOutlet></ng-template>\r\n",
570 // In Ivy embedded views will be change detected from their declaration place, rather than where
571 // they were stamped out. This means that we can't have the bottom sheet container be OnPush,
572 // because it might cause the sheets that were opened from a template not to be out of date.
573 // tslint:disable-next-line:validate-decorators
574 changeDetection: i0.ChangeDetectionStrategy.Default,
575 encapsulation: i0.ViewEncapsulation.None,
576 animations: [matBottomSheetAnimations.bottomSheetState],
577 host: {
578 'class': 'mat-bottom-sheet-container',
579 'tabindex': '-1',
580 'role': 'dialog',
581 'aria-modal': 'true',
582 '[attr.aria-label]': 'bottomSheetConfig?.ariaLabel',
583 '[@state]': '_animationState',
584 '(@state.start)': '_onAnimationStart($event)',
585 '(@state.done)': '_onAnimationDone($event)'
586 },
587 styles: [".mat-bottom-sheet-container{padding:8px 16px;min-width:100vw;box-sizing:border-box;display:block;outline:0;max-height:80vh;overflow:auto}.cdk-high-contrast-active .mat-bottom-sheet-container{outline:1px solid}.mat-bottom-sheet-container-xlarge,.mat-bottom-sheet-container-large,.mat-bottom-sheet-container-medium{border-top-left-radius:4px;border-top-right-radius:4px}.mat-bottom-sheet-container-medium{min-width:384px;max-width:calc(100vw - 128px)}.mat-bottom-sheet-container-large{min-width:512px;max-width:calc(100vw - 256px)}.mat-bottom-sheet-container-xlarge{min-width:576px;max-width:calc(100vw - 384px)}\n"]
588 },] }
589 ];
590 MatBottomSheetContainer.ctorParameters = function () { return [
591 { type: i0.ElementRef },
592 { type: i0.ChangeDetectorRef },
593 { type: a11y.FocusTrapFactory },
594 { type: layout.BreakpointObserver },
595 { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [common.DOCUMENT,] }] },
596 { type: MatBottomSheetConfig }
597 ]; };
598 MatBottomSheetContainer.propDecorators = {
599 _portalOutlet: [{ type: i0.ViewChild, args: [portal.CdkPortalOutlet, { static: true },] }]
600 };
601
602 /**
603 * @license
604 * Copyright Google LLC All Rights Reserved.
605 *
606 * Use of this source code is governed by an MIT-style license that can be
607 * found in the LICENSE file at https://angular.io/license
608 */
609 var MatBottomSheetModule = /** @class */ (function () {
610 function MatBottomSheetModule() {
611 }
612 return MatBottomSheetModule;
613 }());
614 MatBottomSheetModule.decorators = [
615 { type: i0.NgModule, args: [{
616 imports: [
617 i1.OverlayModule,
618 core.MatCommonModule,
619 portal.PortalModule,
620 ],
621 exports: [MatBottomSheetContainer, core.MatCommonModule],
622 declarations: [MatBottomSheetContainer],
623 entryComponents: [MatBottomSheetContainer],
624 },] }
625 ];
626
627 /**
628 * @license
629 * Copyright Google LLC All Rights Reserved.
630 *
631 * Use of this source code is governed by an MIT-style license that can be
632 * found in the LICENSE file at https://angular.io/license
633 */
634 /**
635 * Reference to a bottom sheet dispatched from the bottom sheet service.
636 */
637 var MatBottomSheetRef = /** @class */ (function () {
638 function MatBottomSheetRef(containerInstance, _overlayRef) {
639 var _this = this;
640 this._overlayRef = _overlayRef;
641 /** Subject for notifying the user that the bottom sheet has been dismissed. */
642 this._afterDismissed = new rxjs.Subject();
643 /** Subject for notifying the user that the bottom sheet has opened and appeared. */
644 this._afterOpened = new rxjs.Subject();
645 this.containerInstance = containerInstance;
646 this.disableClose = containerInstance.bottomSheetConfig.disableClose;
647 // Emit when opening animation completes
648 containerInstance._animationStateChanged.pipe(operators.filter(function (event) { return event.phaseName === 'done' && event.toState === 'visible'; }), operators.take(1))
649 .subscribe(function () {
650 _this._afterOpened.next();
651 _this._afterOpened.complete();
652 });
653 // Dispose overlay when closing animation is complete
654 containerInstance._animationStateChanged
655 .pipe(operators.filter(function (event) { return event.phaseName === 'done' && event.toState === 'hidden'; }), operators.take(1))
656 .subscribe(function () {
657 clearTimeout(_this._closeFallbackTimeout);
658 _overlayRef.dispose();
659 });
660 _overlayRef.detachments().pipe(operators.take(1)).subscribe(function () {
661 _this._afterDismissed.next(_this._result);
662 _this._afterDismissed.complete();
663 });
664 rxjs.merge(_overlayRef.backdropClick(), _overlayRef.keydownEvents().pipe(operators.filter(function (event) { return event.keyCode === keycodes.ESCAPE; }))).subscribe(function (event) {
665 if (!_this.disableClose &&
666 (event.type !== 'keydown' || !keycodes.hasModifierKey(event))) {
667 event.preventDefault();
668 _this.dismiss();
669 }
670 });
671 }
672 /**
673 * Dismisses the bottom sheet.
674 * @param result Data to be passed back to the bottom sheet opener.
675 */
676 MatBottomSheetRef.prototype.dismiss = function (result) {
677 var _this = this;
678 if (!this._afterDismissed.closed) {
679 // Transition the backdrop in parallel to the bottom sheet.
680 this.containerInstance._animationStateChanged.pipe(operators.filter(function (event) { return event.phaseName === 'start'; }), operators.take(1)).subscribe(function (event) {
681 // The logic that disposes of the overlay depends on the exit animation completing, however
682 // it isn't guaranteed if the parent view is destroyed while it's running. Add a fallback
683 // timeout which will clean everything up if the animation hasn't fired within the specified
684 // amount of time plus 100ms. We don't need to run this outside the NgZone, because for the
685 // vast majority of cases the timeout will have been cleared before it has fired.
686 _this._closeFallbackTimeout = setTimeout(function () {
687 _this._overlayRef.dispose();
688 }, event.totalTime + 100);
689 _this._overlayRef.detachBackdrop();
690 });
691 this._result = result;
692 this.containerInstance.exit();
693 }
694 };
695 /** Gets an observable that is notified when the bottom sheet is finished closing. */
696 MatBottomSheetRef.prototype.afterDismissed = function () {
697 return this._afterDismissed;
698 };
699 /** Gets an observable that is notified when the bottom sheet has opened and appeared. */
700 MatBottomSheetRef.prototype.afterOpened = function () {
701 return this._afterOpened;
702 };
703 /**
704 * Gets an observable that emits when the overlay's backdrop has been clicked.
705 */
706 MatBottomSheetRef.prototype.backdropClick = function () {
707 return this._overlayRef.backdropClick();
708 };
709 /**
710 * Gets an observable that emits when keydown events are targeted on the overlay.
711 */
712 MatBottomSheetRef.prototype.keydownEvents = function () {
713 return this._overlayRef.keydownEvents();
714 };
715 return MatBottomSheetRef;
716 }());
717
718 /**
719 * @license
720 * Copyright Google LLC All Rights Reserved.
721 *
722 * Use of this source code is governed by an MIT-style license that can be
723 * found in the LICENSE file at https://angular.io/license
724 */
725 /** Injection token that can be used to specify default bottom sheet options. */
726 var MAT_BOTTOM_SHEET_DEFAULT_OPTIONS = new i0.InjectionToken('mat-bottom-sheet-default-options');
727 /**
728 * Service to trigger Material Design bottom sheets.
729 */
730 var MatBottomSheet = /** @class */ (function () {
731 function MatBottomSheet(_overlay, _injector, _parentBottomSheet, _defaultOptions) {
732 this._overlay = _overlay;
733 this._injector = _injector;
734 this._parentBottomSheet = _parentBottomSheet;
735 this._defaultOptions = _defaultOptions;
736 this._bottomSheetRefAtThisLevel = null;
737 }
738 Object.defineProperty(MatBottomSheet.prototype, "_openedBottomSheetRef", {
739 /** Reference to the currently opened bottom sheet. */
740 get: function () {
741 var parent = this._parentBottomSheet;
742 return parent ? parent._openedBottomSheetRef : this._bottomSheetRefAtThisLevel;
743 },
744 set: function (value) {
745 if (this._parentBottomSheet) {
746 this._parentBottomSheet._openedBottomSheetRef = value;
747 }
748 else {
749 this._bottomSheetRefAtThisLevel = value;
750 }
751 },
752 enumerable: false,
753 configurable: true
754 });
755 MatBottomSheet.prototype.open = function (componentOrTemplateRef, config) {
756 var _this = this;
757 var _config = _applyConfigDefaults(this._defaultOptions || new MatBottomSheetConfig(), config);
758 var overlayRef = this._createOverlay(_config);
759 var container = this._attachContainer(overlayRef, _config);
760 var ref = new MatBottomSheetRef(container, overlayRef);
761 if (componentOrTemplateRef instanceof i0.TemplateRef) {
762 container.attachTemplatePortal(new portal.TemplatePortal(componentOrTemplateRef, null, {
763 $implicit: _config.data,
764 bottomSheetRef: ref
765 }));
766 }
767 else {
768 var portal$1 = new portal.ComponentPortal(componentOrTemplateRef, undefined, this._createInjector(_config, ref));
769 var contentRef = container.attachComponentPortal(portal$1);
770 ref.instance = contentRef.instance;
771 }
772 // When the bottom sheet is dismissed, clear the reference to it.
773 ref.afterDismissed().subscribe(function () {
774 // Clear the bottom sheet ref if it hasn't already been replaced by a newer one.
775 if (_this._openedBottomSheetRef == ref) {
776 _this._openedBottomSheetRef = null;
777 }
778 });
779 if (this._openedBottomSheetRef) {
780 // If a bottom sheet is already in view, dismiss it and enter the
781 // new bottom sheet after exit animation is complete.
782 this._openedBottomSheetRef.afterDismissed().subscribe(function () { return ref.containerInstance.enter(); });
783 this._openedBottomSheetRef.dismiss();
784 }
785 else {
786 // If no bottom sheet is in view, enter the new bottom sheet.
787 ref.containerInstance.enter();
788 }
789 this._openedBottomSheetRef = ref;
790 return ref;
791 };
792 /**
793 * Dismisses the currently-visible bottom sheet.
794 * @param result Data to pass to the bottom sheet instance.
795 */
796 MatBottomSheet.prototype.dismiss = function (result) {
797 if (this._openedBottomSheetRef) {
798 this._openedBottomSheetRef.dismiss(result);
799 }
800 };
801 MatBottomSheet.prototype.ngOnDestroy = function () {
802 if (this._bottomSheetRefAtThisLevel) {
803 this._bottomSheetRefAtThisLevel.dismiss();
804 }
805 };
806 /**
807 * Attaches the bottom sheet container component to the overlay.
808 */
809 MatBottomSheet.prototype._attachContainer = function (overlayRef, config) {
810 var userInjector = config && config.viewContainerRef && config.viewContainerRef.injector;
811 var injector = i0.Injector.create({
812 parent: userInjector || this._injector,
813 providers: [{ provide: MatBottomSheetConfig, useValue: config }]
814 });
815 var containerPortal = new portal.ComponentPortal(MatBottomSheetContainer, config.viewContainerRef, injector);
816 var containerRef = overlayRef.attach(containerPortal);
817 return containerRef.instance;
818 };
819 /**
820 * Creates a new overlay and places it in the correct location.
821 * @param config The user-specified bottom sheet config.
822 */
823 MatBottomSheet.prototype._createOverlay = function (config) {
824 var overlayConfig = new i1.OverlayConfig({
825 direction: config.direction,
826 hasBackdrop: config.hasBackdrop,
827 disposeOnNavigation: config.closeOnNavigation,
828 maxWidth: '100%',
829 scrollStrategy: config.scrollStrategy || this._overlay.scrollStrategies.block(),
830 positionStrategy: this._overlay.position().global().centerHorizontally().bottom('0')
831 });
832 if (config.backdropClass) {
833 overlayConfig.backdropClass = config.backdropClass;
834 }
835 return this._overlay.create(overlayConfig);
836 };
837 /**
838 * Creates an injector to be used inside of a bottom sheet component.
839 * @param config Config that was used to create the bottom sheet.
840 * @param bottomSheetRef Reference to the bottom sheet.
841 */
842 MatBottomSheet.prototype._createInjector = function (config, bottomSheetRef) {
843 var userInjector = config && config.viewContainerRef && config.viewContainerRef.injector;
844 var providers = [
845 { provide: MatBottomSheetRef, useValue: bottomSheetRef },
846 { provide: MAT_BOTTOM_SHEET_DATA, useValue: config.data }
847 ];
848 if (config.direction && (!userInjector ||
849 !userInjector.get(bidi.Directionality, null, i0.InjectFlags.Optional))) {
850 providers.push({
851 provide: bidi.Directionality,
852 useValue: { value: config.direction, change: rxjs.of() }
853 });
854 }
855 return i0.Injector.create({ parent: userInjector || this._injector, providers: providers });
856 };
857 return MatBottomSheet;
858 }());
859 MatBottomSheet.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function MatBottomSheet_Factory() { return new MatBottomSheet(i0__namespace.ɵɵinject(i1__namespace.Overlay), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(MatBottomSheet, 12), i0__namespace.ɵɵinject(MAT_BOTTOM_SHEET_DEFAULT_OPTIONS, 8)); }, token: MatBottomSheet, providedIn: MatBottomSheetModule });
860 MatBottomSheet.decorators = [
861 { type: i0.Injectable, args: [{ providedIn: MatBottomSheetModule },] }
862 ];
863 MatBottomSheet.ctorParameters = function () { return [
864 { type: i1.Overlay },
865 { type: i0.Injector },
866 { type: MatBottomSheet, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] },
867 { type: MatBottomSheetConfig, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [MAT_BOTTOM_SHEET_DEFAULT_OPTIONS,] }] }
868 ]; };
869 /**
870 * Applies default options to the bottom sheet config.
871 * @param defaults Object containing the default values to which to fall back.
872 * @param config The configuration to which the defaults will be applied.
873 * @returns The new configuration object with defaults applied.
874 */
875 function _applyConfigDefaults(defaults, config) {
876 return Object.assign(Object.assign({}, defaults), config);
877 }
878
879 /**
880 * @license
881 * Copyright Google LLC All Rights Reserved.
882 *
883 * Use of this source code is governed by an MIT-style license that can be
884 * found in the LICENSE file at https://angular.io/license
885 */
886
887 /**
888 * Generated bundle index. Do not edit.
889 */
890
891 exports.MAT_BOTTOM_SHEET_DATA = MAT_BOTTOM_SHEET_DATA;
892 exports.MAT_BOTTOM_SHEET_DEFAULT_OPTIONS = MAT_BOTTOM_SHEET_DEFAULT_OPTIONS;
893 exports.MatBottomSheet = MatBottomSheet;
894 exports.MatBottomSheetConfig = MatBottomSheetConfig;
895 exports.MatBottomSheetContainer = MatBottomSheetContainer;
896 exports.MatBottomSheetModule = MatBottomSheetModule;
897 exports.MatBottomSheetRef = MatBottomSheetRef;
898 exports.matBottomSheetAnimations = matBottomSheetAnimations;
899
900 Object.defineProperty(exports, '__esModule', { value: true });
901
902})));
903//# sourceMappingURL=material-bottom-sheet.umd.js.map
Note: See TracBrowser for help on using the repository browser.