1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { Component, ViewChild, ElementRef, ChangeDetectionStrategy, ViewEncapsulation, ChangeDetectorRef, EventEmitter, Inject, Optional, } from '@angular/core';
|
---|
9 | import { BasePortalOutlet, CdkPortalOutlet, } from '@angular/cdk/portal';
|
---|
10 | import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
|
---|
11 | import { MatBottomSheetConfig } from './bottom-sheet-config';
|
---|
12 | import { matBottomSheetAnimations } from './bottom-sheet-animations';
|
---|
13 | import { DOCUMENT } from '@angular/common';
|
---|
14 | import { FocusTrapFactory } from '@angular/cdk/a11y';
|
---|
15 | import { _getFocusedElementPierceShadowDom } from '@angular/cdk/platform';
|
---|
16 | // TODO(crisbeto): consolidate some logic between this, MatDialog and MatSnackBar
|
---|
17 | /**
|
---|
18 | * Internal component that wraps user-provided bottom sheet content.
|
---|
19 | * @docs-private
|
---|
20 | */
|
---|
21 | export class MatBottomSheetContainer extends BasePortalOutlet {
|
---|
22 | constructor(_elementRef, _changeDetectorRef, _focusTrapFactory, breakpointObserver, document,
|
---|
23 | /** The bottom sheet configuration. */
|
---|
24 | bottomSheetConfig) {
|
---|
25 | super();
|
---|
26 | this._elementRef = _elementRef;
|
---|
27 | this._changeDetectorRef = _changeDetectorRef;
|
---|
28 | this._focusTrapFactory = _focusTrapFactory;
|
---|
29 | this.bottomSheetConfig = bottomSheetConfig;
|
---|
30 | /** The state of the bottom sheet animations. */
|
---|
31 | this._animationState = 'void';
|
---|
32 | /** Emits whenever the state of the animation changes. */
|
---|
33 | this._animationStateChanged = new EventEmitter();
|
---|
34 | /** Element that was focused before the bottom sheet was opened. */
|
---|
35 | this._elementFocusedBeforeOpened = null;
|
---|
36 | /**
|
---|
37 | * Attaches a DOM portal to the bottom sheet container.
|
---|
38 | * @deprecated To be turned into a method.
|
---|
39 | * @breaking-change 10.0.0
|
---|
40 | */
|
---|
41 | this.attachDomPortal = (portal) => {
|
---|
42 | this._validatePortalAttached();
|
---|
43 | this._setPanelClass();
|
---|
44 | this._savePreviouslyFocusedElement();
|
---|
45 | return this._portalOutlet.attachDomPortal(portal);
|
---|
46 | };
|
---|
47 | this._document = document;
|
---|
48 | this._breakpointSubscription = breakpointObserver
|
---|
49 | .observe([Breakpoints.Medium, Breakpoints.Large, Breakpoints.XLarge])
|
---|
50 | .subscribe(() => {
|
---|
51 | this._toggleClass('mat-bottom-sheet-container-medium', breakpointObserver.isMatched(Breakpoints.Medium));
|
---|
52 | this._toggleClass('mat-bottom-sheet-container-large', breakpointObserver.isMatched(Breakpoints.Large));
|
---|
53 | this._toggleClass('mat-bottom-sheet-container-xlarge', breakpointObserver.isMatched(Breakpoints.XLarge));
|
---|
54 | });
|
---|
55 | }
|
---|
56 | /** Attach a component portal as content to this bottom sheet container. */
|
---|
57 | attachComponentPortal(portal) {
|
---|
58 | this._validatePortalAttached();
|
---|
59 | this._setPanelClass();
|
---|
60 | this._savePreviouslyFocusedElement();
|
---|
61 | return this._portalOutlet.attachComponentPortal(portal);
|
---|
62 | }
|
---|
63 | /** Attach a template portal as content to this bottom sheet container. */
|
---|
64 | attachTemplatePortal(portal) {
|
---|
65 | this._validatePortalAttached();
|
---|
66 | this._setPanelClass();
|
---|
67 | this._savePreviouslyFocusedElement();
|
---|
68 | return this._portalOutlet.attachTemplatePortal(portal);
|
---|
69 | }
|
---|
70 | /** Begin animation of bottom sheet entrance into view. */
|
---|
71 | enter() {
|
---|
72 | if (!this._destroyed) {
|
---|
73 | this._animationState = 'visible';
|
---|
74 | this._changeDetectorRef.detectChanges();
|
---|
75 | }
|
---|
76 | }
|
---|
77 | /** Begin animation of the bottom sheet exiting from view. */
|
---|
78 | exit() {
|
---|
79 | if (!this._destroyed) {
|
---|
80 | this._animationState = 'hidden';
|
---|
81 | this._changeDetectorRef.markForCheck();
|
---|
82 | }
|
---|
83 | }
|
---|
84 | ngOnDestroy() {
|
---|
85 | this._breakpointSubscription.unsubscribe();
|
---|
86 | this._destroyed = true;
|
---|
87 | }
|
---|
88 | _onAnimationDone(event) {
|
---|
89 | if (event.toState === 'hidden') {
|
---|
90 | this._restoreFocus();
|
---|
91 | }
|
---|
92 | else if (event.toState === 'visible') {
|
---|
93 | this._trapFocus();
|
---|
94 | }
|
---|
95 | this._animationStateChanged.emit(event);
|
---|
96 | }
|
---|
97 | _onAnimationStart(event) {
|
---|
98 | this._animationStateChanged.emit(event);
|
---|
99 | }
|
---|
100 | _toggleClass(cssClass, add) {
|
---|
101 | const classList = this._elementRef.nativeElement.classList;
|
---|
102 | add ? classList.add(cssClass) : classList.remove(cssClass);
|
---|
103 | }
|
---|
104 | _validatePortalAttached() {
|
---|
105 | if (this._portalOutlet.hasAttached() && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
---|
106 | throw Error('Attempting to attach bottom sheet content after content is already attached');
|
---|
107 | }
|
---|
108 | }
|
---|
109 | _setPanelClass() {
|
---|
110 | const element = this._elementRef.nativeElement;
|
---|
111 | const panelClass = this.bottomSheetConfig.panelClass;
|
---|
112 | if (Array.isArray(panelClass)) {
|
---|
113 | // Note that we can't use a spread here, because IE doesn't support multiple arguments.
|
---|
114 | panelClass.forEach(cssClass => element.classList.add(cssClass));
|
---|
115 | }
|
---|
116 | else if (panelClass) {
|
---|
117 | element.classList.add(panelClass);
|
---|
118 | }
|
---|
119 | }
|
---|
120 | /** Moves the focus inside the focus trap. */
|
---|
121 | _trapFocus() {
|
---|
122 | const element = this._elementRef.nativeElement;
|
---|
123 | if (!this._focusTrap) {
|
---|
124 | this._focusTrap = this._focusTrapFactory.create(element);
|
---|
125 | }
|
---|
126 | if (this.bottomSheetConfig.autoFocus) {
|
---|
127 | this._focusTrap.focusInitialElementWhenReady();
|
---|
128 | }
|
---|
129 | else {
|
---|
130 | const activeElement = _getFocusedElementPierceShadowDom();
|
---|
131 | // Otherwise ensure that focus is on the container. It's possible that a different
|
---|
132 | // component tried to move focus while the open animation was running. See:
|
---|
133 | // https://github.com/angular/components/issues/16215. Note that we only want to do this
|
---|
134 | // if the focus isn't inside the bottom sheet already, because it's possible that the
|
---|
135 | // consumer turned off `autoFocus` in order to move focus themselves.
|
---|
136 | if (activeElement !== element && !element.contains(activeElement)) {
|
---|
137 | element.focus();
|
---|
138 | }
|
---|
139 | }
|
---|
140 | }
|
---|
141 | /** Restores focus to the element that was focused before the bottom sheet was opened. */
|
---|
142 | _restoreFocus() {
|
---|
143 | const toFocus = this._elementFocusedBeforeOpened;
|
---|
144 | // We need the extra check, because IE can set the `activeElement` to null in some cases.
|
---|
145 | if (this.bottomSheetConfig.restoreFocus && toFocus && typeof toFocus.focus === 'function') {
|
---|
146 | const activeElement = _getFocusedElementPierceShadowDom();
|
---|
147 | const element = this._elementRef.nativeElement;
|
---|
148 | // Make sure that focus is still inside the bottom sheet or is on the body (usually because a
|
---|
149 | // non-focusable element like the backdrop was clicked) before moving it. It's possible that
|
---|
150 | // the consumer moved it themselves before the animation was done, in which case we shouldn't
|
---|
151 | // do anything.
|
---|
152 | if (!activeElement || activeElement === this._document.body || activeElement === element ||
|
---|
153 | element.contains(activeElement)) {
|
---|
154 | toFocus.focus();
|
---|
155 | }
|
---|
156 | }
|
---|
157 | if (this._focusTrap) {
|
---|
158 | this._focusTrap.destroy();
|
---|
159 | }
|
---|
160 | }
|
---|
161 | /** Saves a reference to the element that was focused before the bottom sheet was opened. */
|
---|
162 | _savePreviouslyFocusedElement() {
|
---|
163 | this._elementFocusedBeforeOpened = _getFocusedElementPierceShadowDom();
|
---|
164 | // The `focus` method isn't available during server-side rendering.
|
---|
165 | if (this._elementRef.nativeElement.focus) {
|
---|
166 | Promise.resolve().then(() => this._elementRef.nativeElement.focus());
|
---|
167 | }
|
---|
168 | }
|
---|
169 | }
|
---|
170 | MatBottomSheetContainer.decorators = [
|
---|
171 | { type: Component, args: [{
|
---|
172 | selector: 'mat-bottom-sheet-container',
|
---|
173 | template: "<ng-template cdkPortalOutlet></ng-template>\r\n",
|
---|
174 | // In Ivy embedded views will be change detected from their declaration place, rather than where
|
---|
175 | // they were stamped out. This means that we can't have the bottom sheet container be OnPush,
|
---|
176 | // because it might cause the sheets that were opened from a template not to be out of date.
|
---|
177 | // tslint:disable-next-line:validate-decorators
|
---|
178 | changeDetection: ChangeDetectionStrategy.Default,
|
---|
179 | encapsulation: ViewEncapsulation.None,
|
---|
180 | animations: [matBottomSheetAnimations.bottomSheetState],
|
---|
181 | host: {
|
---|
182 | 'class': 'mat-bottom-sheet-container',
|
---|
183 | 'tabindex': '-1',
|
---|
184 | 'role': 'dialog',
|
---|
185 | 'aria-modal': 'true',
|
---|
186 | '[attr.aria-label]': 'bottomSheetConfig?.ariaLabel',
|
---|
187 | '[@state]': '_animationState',
|
---|
188 | '(@state.start)': '_onAnimationStart($event)',
|
---|
189 | '(@state.done)': '_onAnimationDone($event)'
|
---|
190 | },
|
---|
191 | 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"]
|
---|
192 | },] }
|
---|
193 | ];
|
---|
194 | MatBottomSheetContainer.ctorParameters = () => [
|
---|
195 | { type: ElementRef },
|
---|
196 | { type: ChangeDetectorRef },
|
---|
197 | { type: FocusTrapFactory },
|
---|
198 | { type: BreakpointObserver },
|
---|
199 | { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] },
|
---|
200 | { type: MatBottomSheetConfig }
|
---|
201 | ];
|
---|
202 | MatBottomSheetContainer.propDecorators = {
|
---|
203 | _portalOutlet: [{ type: ViewChild, args: [CdkPortalOutlet, { static: true },] }]
|
---|
204 | };
|
---|
205 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm90dG9tLXNoZWV0LWNvbnRhaW5lci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9ib3R0b20tc2hlZXQvYm90dG9tLXNoZWV0LWNvbnRhaW5lci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQ0wsU0FBUyxFQUdULFNBQVMsRUFFVCxVQUFVLEVBQ1YsdUJBQXVCLEVBQ3ZCLGlCQUFpQixFQUNqQixpQkFBaUIsRUFDakIsWUFBWSxFQUNaLE1BQU0sRUFDTixRQUFRLEdBQ1QsTUFBTSxlQUFlLENBQUM7QUFFdkIsT0FBTyxFQUNMLGdCQUFnQixFQUdoQixlQUFlLEdBRWhCLE1BQU0scUJBQXFCLENBQUM7QUFDN0IsT0FBTyxFQUFDLGtCQUFrQixFQUFFLFdBQVcsRUFBQyxNQUFNLHFCQUFxQixDQUFDO0FBQ3BFLE9BQU8sRUFBQyxvQkFBb0IsRUFBQyxNQUFNLHVCQUF1QixDQUFDO0FBQzNELE9BQU8sRUFBQyx3QkFBd0IsRUFBQyxNQUFNLDJCQUEyQixDQUFDO0FBRW5FLE9BQU8sRUFBQyxRQUFRLEVBQUMsTUFBTSxpQkFBaUIsQ0FBQztBQUN6QyxPQUFPLEVBQVksZ0JBQWdCLEVBQUMsTUFBTSxtQkFBbUIsQ0FBQztBQUM5RCxPQUFPLEVBQUMsaUNBQWlDLEVBQUMsTUFBTSx1QkFBdUIsQ0FBQztBQUV4RSxpRkFBaUY7QUFF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