@ng-matero/extensions 18.0.3 → 18.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -2
- package/alert/alert.scss +13 -16
- package/colorpicker/colorpicker-toggle.scss +1 -1
- package/colorpicker/colorpicker.d.ts +1 -1
- package/column-resize/resize-strategy.d.ts +1 -1
- package/core/m2/_typography.scss +172 -0
- package/core/pipes/is-template-ref.pipe.d.ts +2 -2
- package/core/style/_elevation.scss +167 -0
- package/core/tokens/_m3-tokens.scss +13 -10
- package/core/tokens/_token-utils.scss +120 -30
- package/core/tokens/m2/mtx/_alert.scss +17 -9
- package/core/tokens/m2/mtx/_datetimepicker.scss +3 -3
- package/core/tokens/m2/mtx/_drawer.scss +2 -2
- package/core/tokens/m2/mtx/_grid.scss +0 -2
- package/core/tokens/m2/mtx/_popover.scss +3 -0
- package/core/tokens/m2/mtx/_select.scss +2 -4
- package/core/tokens/m3/definitions/_index.scss +8 -0
- package/core/tokens/m3/definitions/_md-ref-palette.scss +100 -0
- package/core/tokens/m3/definitions/_md-ref-typeface.scss +14 -0
- package/core/tokens/m3/definitions/_md-sys-color.scss +126 -0
- package/core/tokens/m3/definitions/_md-sys-elevation.scss +15 -0
- package/core/tokens/m3/definitions/_md-sys-motion.scss +46 -0
- package/core/tokens/m3/definitions/_md-sys-shape.scss +24 -0
- package/core/tokens/m3/definitions/_md-sys-state.scss +13 -0
- package/core/tokens/m3/definitions/_md-sys-typescale.scss +308 -0
- package/core/tokens/m3/mtx/_alert.scss +19 -9
- package/core/tokens/m3/mtx/_datetimepicker.scss +3 -3
- package/core/tokens/m3/mtx/_drawer.scss +2 -2
- package/core/tokens/m3/mtx/_grid.scss +0 -2
- package/core/tokens/m3/mtx/_popover.scss +3 -0
- package/core/tokens/m3/mtx/_select.scss +2 -2
- package/core/typography/_all-typography.scss +2 -2
- package/datetimepicker/calendar.d.ts +4 -2
- package/datetimepicker/calendar.scss +38 -0
- package/datetimepicker/datetimepicker-actions.d.ts +32 -0
- package/datetimepicker/datetimepicker-actions.scss +18 -0
- package/datetimepicker/datetimepicker-animations.d.ts +1 -1
- package/datetimepicker/datetimepicker-content.scss +40 -22
- package/datetimepicker/datetimepicker-module.d.ts +2 -1
- package/datetimepicker/datetimepicker-toggle.scss +1 -1
- package/datetimepicker/datetimepicker.d.ts +33 -3
- package/datetimepicker/public-api.d.ts +1 -0
- package/datetimepicker/time.d.ts +12 -8
- package/datetimepicker/time.scss +6 -6
- package/dialog/dialog.d.ts +1 -1
- package/drawer/drawer-config.d.ts +8 -6
- package/drawer/drawer-container.d.ts +12 -68
- package/drawer/drawer-container.scss +4 -6
- package/drawer/drawer-module.d.ts +2 -2
- package/drawer/drawer-ref.d.ts +13 -4
- package/drawer/drawer.d.ts +24 -24
- package/esm2022/alert/alert-module.mjs +5 -5
- package/esm2022/alert/alert.mjs +6 -5
- package/esm2022/button/button-loading.mjs +3 -3
- package/esm2022/button/button-module.mjs +4 -4
- package/esm2022/checkbox-group/checkbox-group-module.mjs +4 -4
- package/esm2022/checkbox-group/checkbox-group.mjs +3 -3
- package/esm2022/colorpicker/colorpicker-input.mjs +3 -3
- package/esm2022/colorpicker/colorpicker-module.mjs +4 -4
- package/esm2022/colorpicker/colorpicker-toggle.mjs +6 -6
- package/esm2022/colorpicker/colorpicker.mjs +8 -8
- package/esm2022/column-resize/column-resize-directives/column-resize-flex.mjs +3 -3
- package/esm2022/column-resize/column-resize-directives/column-resize.mjs +3 -3
- package/esm2022/column-resize/column-resize-module.mjs +4 -4
- package/esm2022/column-resize/column-resize-notifier.mjs +6 -6
- package/esm2022/column-resize/column-resize.mjs +3 -3
- package/esm2022/column-resize/column-size-store.mjs +3 -3
- package/esm2022/column-resize/event-dispatcher.mjs +3 -3
- package/esm2022/column-resize/overlay-handle.mjs +3 -3
- package/esm2022/column-resize/resizable.mjs +3 -3
- package/esm2022/column-resize/resize-strategy.mjs +9 -9
- package/esm2022/core/datetime/datetime.module.mjs +8 -8
- package/esm2022/core/datetime/native-datetime-adapter.mjs +3 -3
- package/esm2022/core/pipes/is-template-ref.pipe.mjs +3 -3
- package/esm2022/core/pipes/pipes.module.mjs +4 -4
- package/esm2022/core/pipes/to-observable.pipe.mjs +3 -3
- package/esm2022/datetimepicker/calendar-body.mjs +3 -3
- package/esm2022/datetimepicker/calendar.mjs +10 -6
- package/esm2022/datetimepicker/clock.mjs +3 -3
- package/esm2022/datetimepicker/datetimepicker-actions.mjs +88 -0
- package/esm2022/datetimepicker/datetimepicker-animations.mjs +3 -3
- package/esm2022/datetimepicker/datetimepicker-input.mjs +3 -3
- package/esm2022/datetimepicker/datetimepicker-intl.mjs +3 -3
- package/esm2022/datetimepicker/datetimepicker-module.mjs +24 -7
- package/esm2022/datetimepicker/datetimepicker-toggle.mjs +6 -6
- package/esm2022/datetimepicker/datetimepicker.mjs +92 -20
- package/esm2022/datetimepicker/month-view.mjs +7 -5
- package/esm2022/datetimepicker/multi-year-view.mjs +7 -5
- package/esm2022/datetimepicker/public-api.mjs +2 -1
- package/esm2022/datetimepicker/time.mjs +29 -20
- package/esm2022/datetimepicker/year-view.mjs +7 -5
- package/esm2022/dialog/dialog-container.mjs +3 -3
- package/esm2022/dialog/dialog-module.mjs +4 -4
- package/esm2022/dialog/dialog.mjs +3 -3
- package/esm2022/drawer/drawer-config.mjs +2 -2
- package/esm2022/drawer/drawer-container.mjs +32 -196
- package/esm2022/drawer/drawer-module.mjs +7 -7
- package/esm2022/drawer/drawer-ref.mjs +27 -18
- package/esm2022/drawer/drawer.mjs +98 -121
- package/esm2022/grid/cell.mjs +3 -3
- package/esm2022/grid/column-menu.mjs +5 -5
- package/esm2022/grid/column-resize/column-resize-directives/column-resize-flex.mjs +3 -3
- package/esm2022/grid/column-resize/column-resize-directives/column-resize.mjs +3 -3
- package/esm2022/grid/column-resize/column-resize-module.mjs +8 -8
- package/esm2022/grid/column-resize/overlay-handle.mjs +3 -3
- package/esm2022/grid/column-resize/resizable-directives/resizable.mjs +3 -3
- package/esm2022/grid/column-resize/resize-strategy.mjs +3 -3
- package/esm2022/grid/expansion-toggle.mjs +3 -3
- package/esm2022/grid/grid-module.mjs +4 -4
- package/esm2022/grid/grid-pipes.mjs +21 -21
- package/esm2022/grid/grid-utils.mjs +3 -3
- package/esm2022/grid/grid.mjs +5 -5
- package/esm2022/grid/selectable-cell.mjs +3 -3
- package/esm2022/loader/loader-module.mjs +4 -4
- package/esm2022/loader/loader.mjs +3 -3
- package/esm2022/photoviewer/photoviewer-module.mjs +4 -4
- package/esm2022/photoviewer/photoviewer.mjs +3 -3
- package/esm2022/popover/popover-content.mjs +6 -6
- package/esm2022/popover/popover-interfaces.mjs +1 -1
- package/esm2022/popover/popover-module.mjs +4 -4
- package/esm2022/popover/popover-target.mjs +3 -3
- package/esm2022/popover/popover-trigger.mjs +3 -3
- package/esm2022/popover/popover.mjs +29 -19
- package/esm2022/progress/progress-module.mjs +4 -4
- package/esm2022/progress/progress.mjs +3 -3
- package/esm2022/select/option.mjs +3 -3
- package/esm2022/select/select-module.mjs +4 -4
- package/esm2022/select/select.mjs +3 -3
- package/esm2022/select/templates.mjs +33 -33
- package/esm2022/split/split-module.mjs +4 -4
- package/esm2022/split/split-pane.mjs +3 -3
- package/esm2022/split/split.mjs +3 -3
- package/esm2022/tooltip/tooltip-module.mjs +4 -4
- package/esm2022/tooltip/tooltip.mjs +20 -18
- package/fesm2022/mtxAlert.mjs +9 -8
- package/fesm2022/mtxAlert.mjs.map +1 -1
- package/fesm2022/mtxButton.mjs +7 -7
- package/fesm2022/mtxCheckboxGroup.mjs +7 -7
- package/fesm2022/mtxColorpicker.mjs +20 -20
- package/fesm2022/mtxColorpicker.mjs.map +1 -1
- package/fesm2022/mtxColumnResize.mjs +40 -40
- package/fesm2022/mtxCore.mjs +21 -21
- package/fesm2022/mtxDatetimepicker.mjs +273 -82
- package/fesm2022/mtxDatetimepicker.mjs.map +1 -1
- package/fesm2022/mtxDialog.mjs +10 -10
- package/fesm2022/mtxDrawer.mjs +160 -340
- package/fesm2022/mtxDrawer.mjs.map +1 -1
- package/fesm2022/mtxGrid.mjs +68 -68
- package/fesm2022/mtxGrid.mjs.map +1 -1
- package/fesm2022/mtxLoader.mjs +7 -7
- package/fesm2022/mtxPhotoviewer.mjs +7 -7
- package/fesm2022/mtxPopover.mjs +44 -34
- package/fesm2022/mtxPopover.mjs.map +1 -1
- package/fesm2022/mtxProgress.mjs +7 -7
- package/fesm2022/mtxSelect.mjs +43 -43
- package/fesm2022/mtxSplit.mjs +10 -10
- package/fesm2022/mtxTooltip.mjs +23 -21
- package/fesm2022/mtxTooltip.mjs.map +1 -1
- package/grid/column-menu.scss +0 -1
- package/grid/grid.scss +2 -0
- package/package.json +7 -7
- package/popover/popover-interfaces.d.ts +0 -1
- package/popover/popover.d.ts +2 -5
- package/prebuilt-themes/azure-blue.css +1 -1
- package/prebuilt-themes/cyan-orange.css +1 -1
- package/prebuilt-themes/deeppurple-amber.css +1 -1
- package/prebuilt-themes/indigo-pink.css +1 -1
- package/prebuilt-themes/magenta-violet.css +1 -1
- package/prebuilt-themes/pink-bluegrey.css +1 -1
- package/prebuilt-themes/purple-green.css +1 -1
- package/prebuilt-themes/rose-red.css +1 -1
- package/select/option.d.ts +1 -1
- package/select/select.scss +2 -2
- package/tooltip/_tooltip-theme.scss +19 -15
- package/tooltip/tooltip.d.ts +3 -0
- package/tooltip/tooltip.scss +61 -29
- package/core/typography/_typography.scss +0 -40
package/fesm2022/mtxDrawer.mjs
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { BasePortalOutlet, CdkPortalOutlet, TemplatePortal, ComponentPortal, PortalModule } from '@angular/cdk/portal';
|
|
1
|
+
import { CdkDialogContainer, Dialog, DialogConfig, DialogModule } from '@angular/cdk/dialog';
|
|
2
|
+
import { CdkPortalOutlet, PortalModule } from '@angular/cdk/portal';
|
|
4
3
|
import * as i0 from '@angular/core';
|
|
5
|
-
import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Optional, Inject, ViewChild, InjectionToken,
|
|
4
|
+
import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Optional, Inject, ViewChild, InjectionToken, Injectable, SkipSelf, NgModule } from '@angular/core';
|
|
6
5
|
import { MatCommonModule } from '@angular/material/core';
|
|
7
|
-
import {
|
|
8
|
-
import { Subject, merge,
|
|
9
|
-
import {
|
|
10
|
-
import * as i2 from '@angular/cdk/layout';
|
|
11
|
-
import { Breakpoints } from '@angular/cdk/layout';
|
|
12
|
-
import { _getFocusedElementPierceShadowDom } from '@angular/cdk/platform';
|
|
6
|
+
import { coerceCssPixelValue } from '@angular/cdk/coercion';
|
|
7
|
+
import { Subject, merge, defer } from 'rxjs';
|
|
8
|
+
import { filter, take, startWith } from 'rxjs/operators';
|
|
13
9
|
import { DOCUMENT } from '@angular/common';
|
|
14
10
|
import { trigger, state, style, transition, animate } from '@angular/animations';
|
|
15
11
|
import * as i1 from '@angular/cdk/a11y';
|
|
12
|
+
import * as i3 from '@angular/cdk/overlay';
|
|
16
13
|
import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
|
|
17
|
-
import { filter, take } from 'rxjs/operators';
|
|
18
14
|
|
|
19
15
|
/**
|
|
20
16
|
* Configuration used when opening a drawer.
|
|
@@ -47,7 +43,7 @@ class MtxDrawerConfig {
|
|
|
47
43
|
* previously-focused element, after it's closed.
|
|
48
44
|
*/
|
|
49
45
|
this.restoreFocus = true;
|
|
50
|
-
/** Position of the drawer */
|
|
46
|
+
/** Position of the drawer. */
|
|
51
47
|
this.position = 'right';
|
|
52
48
|
}
|
|
53
49
|
}
|
|
@@ -73,84 +69,34 @@ const mtxDrawerAnimations = {
|
|
|
73
69
|
* Internal component that wraps user-provided drawer content.
|
|
74
70
|
* @docs-private
|
|
75
71
|
*/
|
|
76
|
-
class MtxDrawerContainer extends
|
|
72
|
+
class MtxDrawerContainer extends CdkDialogContainer {
|
|
77
73
|
get _drawerPosition() {
|
|
78
|
-
return `mtx-drawer-${this.
|
|
74
|
+
return `mtx-drawer-${this._config.position}`;
|
|
79
75
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
? coerceCssPixelValue(this.drawerConfig.width)
|
|
83
|
-
: '100vw';
|
|
84
|
-
}
|
|
85
|
-
get _drawerHeight() {
|
|
86
|
-
return this.drawerConfig.position === 'top' || this.drawerConfig.position === 'bottom'
|
|
87
|
-
? coerceCssPixelValue(this.drawerConfig.height)
|
|
88
|
-
: '100vh';
|
|
89
|
-
}
|
|
90
|
-
_getDrawerSize() {
|
|
91
|
-
return {
|
|
92
|
-
width: this._drawerWidth,
|
|
93
|
-
height: this._drawerHeight,
|
|
94
|
-
minWidth: coerceCssPixelValue(this.drawerConfig.minWidth),
|
|
95
|
-
minHeight: coerceCssPixelValue(this.drawerConfig.minHeight),
|
|
96
|
-
maxWidth: coerceCssPixelValue(this.drawerConfig.maxWidth),
|
|
97
|
-
maxHeight: coerceCssPixelValue(this.drawerConfig.maxHeight),
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
constructor(_elementRef, _changeDetectorRef, _focusTrapFactory, _interactivityChecker, _ngZone, breakpointObserver, document,
|
|
101
|
-
/** The drawer configuration. */
|
|
102
|
-
drawerConfig) {
|
|
103
|
-
super();
|
|
104
|
-
this._elementRef = _elementRef;
|
|
105
|
-
this._changeDetectorRef = _changeDetectorRef;
|
|
106
|
-
this._focusTrapFactory = _focusTrapFactory;
|
|
107
|
-
this._interactivityChecker = _interactivityChecker;
|
|
108
|
-
this._ngZone = _ngZone;
|
|
109
|
-
this.drawerConfig = drawerConfig;
|
|
76
|
+
constructor(elementRef, focusTrapFactory, document, config, checker, ngZone, overlayRef, focusMonitor) {
|
|
77
|
+
super(elementRef, focusTrapFactory, document, config, checker, ngZone, overlayRef, focusMonitor);
|
|
110
78
|
/** The state of the drawer animations. */
|
|
111
79
|
this._animationState = 'void';
|
|
112
80
|
/** Emits whenever the state of the animation changes. */
|
|
113
81
|
this._animationStateChanged = new EventEmitter();
|
|
114
|
-
/**
|
|
115
|
-
this.
|
|
116
|
-
/**
|
|
117
|
-
* Attaches a DOM portal to the drawer container.
|
|
118
|
-
* @deprecated To be turned into a method.
|
|
119
|
-
* @breaking-change 10.0.0
|
|
120
|
-
*/
|
|
121
|
-
this.attachDomPortal = (portal) => {
|
|
122
|
-
this._validatePortalAttached();
|
|
123
|
-
this._setPanelClass();
|
|
124
|
-
this._savePreviouslyFocusedElement();
|
|
125
|
-
return this._portalOutlet.attachDomPortal(portal);
|
|
126
|
-
};
|
|
127
|
-
this._document = document;
|
|
128
|
-
this._breakpointSubscription = breakpointObserver
|
|
129
|
-
.observe([Breakpoints.Medium, Breakpoints.Large, Breakpoints.XLarge])
|
|
130
|
-
.subscribe(() => { });
|
|
82
|
+
/** Whether the component has been destroyed. */
|
|
83
|
+
this._destroyed = false;
|
|
131
84
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
this.
|
|
137
|
-
return this._portalOutlet.attachComponentPortal(portal);
|
|
85
|
+
_contentAttached() {
|
|
86
|
+
// Delegate to the original dialog-container initialization (i.e. saving the
|
|
87
|
+
// previous element, setting up the focus trap and moving focus to the container).
|
|
88
|
+
super._contentAttached();
|
|
89
|
+
this.enter();
|
|
138
90
|
}
|
|
139
|
-
/**
|
|
140
|
-
attachTemplatePortal(portal) {
|
|
141
|
-
this._validatePortalAttached();
|
|
142
|
-
this._setPanelClass();
|
|
143
|
-
this._savePreviouslyFocusedElement();
|
|
144
|
-
return this._portalOutlet.attachTemplatePortal(portal);
|
|
145
|
-
}
|
|
146
|
-
/** Begin animation of drawer entrance into view. */
|
|
91
|
+
/** Begin animation of bottom sheet entrance into view. */
|
|
147
92
|
enter() {
|
|
148
93
|
if (!this._destroyed) {
|
|
149
94
|
this._animationState = 'visible';
|
|
95
|
+
this._changeDetectorRef.markForCheck();
|
|
150
96
|
this._changeDetectorRef.detectChanges();
|
|
151
97
|
}
|
|
152
98
|
}
|
|
153
|
-
/** Begin animation of the
|
|
99
|
+
/** Begin animation of the bottom sheet exiting from view. */
|
|
154
100
|
exit() {
|
|
155
101
|
if (!this._destroyed) {
|
|
156
102
|
this._animationState = 'hidden';
|
|
@@ -158,14 +104,11 @@ class MtxDrawerContainer extends BasePortalOutlet {
|
|
|
158
104
|
}
|
|
159
105
|
}
|
|
160
106
|
ngOnDestroy() {
|
|
161
|
-
|
|
107
|
+
super.ngOnDestroy();
|
|
162
108
|
this._destroyed = true;
|
|
163
109
|
}
|
|
164
110
|
_onAnimationDone(event) {
|
|
165
|
-
if (event.toState === '
|
|
166
|
-
this._restoreFocus();
|
|
167
|
-
}
|
|
168
|
-
else if (event.toState === 'visible') {
|
|
111
|
+
if (event.toState === 'visible') {
|
|
169
112
|
this._trapFocus();
|
|
170
113
|
}
|
|
171
114
|
this._animationStateChanged.emit(event);
|
|
@@ -173,139 +116,30 @@ class MtxDrawerContainer extends BasePortalOutlet {
|
|
|
173
116
|
_onAnimationStart(event) {
|
|
174
117
|
this._animationStateChanged.emit(event);
|
|
175
118
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
_validatePortalAttached() {
|
|
180
|
-
if (this._portalOutlet.hasAttached()) {
|
|
181
|
-
throw Error('Attempting to attach drawer content after content is already attached');
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
_setPanelClass() {
|
|
185
|
-
const element = this._elementRef.nativeElement;
|
|
186
|
-
element.classList.add(...coerceArray(this.drawerConfig.panelClass || []));
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Focuses the provided element. If the element is not focusable, it will add a tabIndex
|
|
190
|
-
* attribute to forcefully focus it. The attribute is removed after focus is moved.
|
|
191
|
-
* @param element The element to focus.
|
|
192
|
-
*/
|
|
193
|
-
_forceFocus(element, options) {
|
|
194
|
-
if (!this._interactivityChecker.isFocusable(element)) {
|
|
195
|
-
element.tabIndex = -1;
|
|
196
|
-
// The tabindex attribute should be removed to avoid navigating to that element again
|
|
197
|
-
this._ngZone.runOutsideAngular(() => {
|
|
198
|
-
element.addEventListener('blur', () => element.removeAttribute('tabindex'));
|
|
199
|
-
element.addEventListener('mousedown', () => element.removeAttribute('tabindex'));
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
element.focus(options);
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Focuses the first element that matches the given selector within the focus trap.
|
|
206
|
-
* @param selector The CSS selector for the element to set focus to.
|
|
207
|
-
*/
|
|
208
|
-
_focusByCssSelector(selector, options) {
|
|
209
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
210
|
-
const elementToFocus = this._elementRef.nativeElement.querySelector(selector);
|
|
211
|
-
if (elementToFocus) {
|
|
212
|
-
this._forceFocus(elementToFocus, options);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Moves the focus inside the focus trap. When autoFocus is not set to 'bottom-sheet',
|
|
217
|
-
* if focus cannot be moved then focus will go to the drawer container.
|
|
218
|
-
*/
|
|
219
|
-
_trapFocus() {
|
|
220
|
-
const element = this._elementRef.nativeElement;
|
|
221
|
-
if (!this._focusTrap) {
|
|
222
|
-
this._focusTrap = this._focusTrapFactory.create(element);
|
|
223
|
-
}
|
|
224
|
-
// If were to attempt to focus immediately, then the content of the drawer would not
|
|
225
|
-
// yet be ready in instances where change detection has to run first. To deal with this,
|
|
226
|
-
// we simply wait for the microtask queue to be empty when setting focus when autoFocus
|
|
227
|
-
// isn't set to drawer. If the element inside the drawer can't be focused,
|
|
228
|
-
// then the container is focused so the user can't tab into other elements behind it.
|
|
229
|
-
switch (this.drawerConfig.autoFocus) {
|
|
230
|
-
case false:
|
|
231
|
-
case 'dialog':
|
|
232
|
-
// eslint-disable-next-line no-case-declarations
|
|
233
|
-
const activeElement = _getFocusedElementPierceShadowDom();
|
|
234
|
-
// Ensure that focus is on the drawer container. It's possible that a different
|
|
235
|
-
// component tried to move focus while the open animation was running. See:
|
|
236
|
-
// https://github.com/angular/components/issues/16215. Note that we only want to do this
|
|
237
|
-
// if the focus isn't inside the drawer already, because it's possible that the
|
|
238
|
-
// consumer specified `autoFocus` in order to move focus themselves.
|
|
239
|
-
if (activeElement !== element && !element.contains(activeElement)) {
|
|
240
|
-
element.focus();
|
|
241
|
-
}
|
|
242
|
-
break;
|
|
243
|
-
case true:
|
|
244
|
-
case 'first-tabbable':
|
|
245
|
-
this._focusTrap.focusInitialElementWhenReady();
|
|
246
|
-
break;
|
|
247
|
-
case 'first-heading':
|
|
248
|
-
this._focusByCssSelector('h1, h2, h3, h4, h5, h6, [role="heading"]');
|
|
249
|
-
break;
|
|
250
|
-
default:
|
|
251
|
-
this._focusByCssSelector(this.drawerConfig.autoFocus);
|
|
252
|
-
break;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
/** Restores focus to the element that was focused before the drawer was opened. */
|
|
256
|
-
_restoreFocus() {
|
|
257
|
-
const toFocus = this._elementFocusedBeforeOpened;
|
|
258
|
-
// We need the extra check, because IE can set the `activeElement` to null in some cases.
|
|
259
|
-
if (this.drawerConfig.restoreFocus && toFocus && typeof toFocus.focus === 'function') {
|
|
260
|
-
const activeElement = _getFocusedElementPierceShadowDom();
|
|
261
|
-
const element = this._elementRef.nativeElement;
|
|
262
|
-
// Make sure that focus is still inside the drawer or is on the body (usually because a
|
|
263
|
-
// non-focusable element like the backdrop was clicked) before moving it. It's possible that
|
|
264
|
-
// the consumer moved it themselves before the animation was done, in which case we shouldn't
|
|
265
|
-
// do anything.
|
|
266
|
-
if (!activeElement ||
|
|
267
|
-
activeElement === this._document.body ||
|
|
268
|
-
activeElement === element ||
|
|
269
|
-
element.contains(activeElement)) {
|
|
270
|
-
toFocus.focus();
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
if (this._focusTrap) {
|
|
274
|
-
this._focusTrap.destroy();
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
/** Saves a reference to the element that was focused before the drawer was opened. */
|
|
278
|
-
_savePreviouslyFocusedElement() {
|
|
279
|
-
this._elementFocusedBeforeOpened = _getFocusedElementPierceShadowDom();
|
|
280
|
-
// The `focus` method isn't available during server-side rendering.
|
|
281
|
-
if (this._elementRef.nativeElement.focus) {
|
|
282
|
-
this._ngZone.runOutsideAngular(() => {
|
|
283
|
-
Promise.resolve().then(() => this._elementRef.nativeElement.focus());
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: MtxDrawerContainer, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i1.FocusTrapFactory }, { token: i1.InteractivityChecker }, { token: i0.NgZone }, { token: i2.BreakpointObserver }, { token: DOCUMENT, optional: true }, { token: MtxDrawerConfig }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
288
|
-
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.1", type: MtxDrawerContainer, isStandalone: true, selector: "mtx-drawer-container", host: { attributes: { "tabindex": "-1", "role": "dialog", "aria-modal": "true" }, listeners: { "@state.start": "_onAnimationStart($event)", "@state.done": "_onAnimationDone($event)" }, properties: { "class": "_drawerPosition", "attr.aria-label": "drawerConfig?.ariaLabel", "@state": "_animationState" }, classAttribute: "mtx-drawer-container" }, viewQueries: [{ propertyName: "_portalOutlet", first: true, predicate: CdkPortalOutlet, descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"mtx-drawer-content-wrapper\" [style]=\"_getDrawerSize()\">\n <ng-template cdkPortalOutlet></ng-template>\n</div>\n", styles: [".mtx-drawer-container{display:block;outline:0;background-color:var(--mtx-drawer-container-background-color);color:var(--mtx-drawer-container-text-color);box-shadow:var(--mtx-drawer-container-elevation-shadow)}.cdk-high-contrast-active .mtx-drawer-container{outline:1px solid}.mtx-drawer-content-wrapper{box-sizing:border-box;padding:8px 16px;overflow:auto}.mtx-drawer-right{transform:translate(100%);border-top-left-radius:var(--mtx-drawer-container-shape);border-bottom-left-radius:var(--mtx-drawer-container-shape)}.mtx-drawer-left{transform:translate(-100%);border-top-right-radius:var(--mtx-drawer-container-shape);border-bottom-right-radius:var(--mtx-drawer-container-shape)}.mtx-drawer-bottom{transform:translateY(100%);border-top-left-radius:var(--mtx-drawer-container-shape);border-top-right-radius:var(--mtx-drawer-container-shape)}.mtx-drawer-top{transform:translateY(-100%);border-bottom-left-radius:var(--mtx-drawer-container-shape);border-bottom-right-radius:var(--mtx-drawer-container-shape)}\n"], dependencies: [{ kind: "directive", type: CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }], animations: [mtxDrawerAnimations.drawerState], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None }); }
|
|
119
|
+
_captureInitialFocus() { }
|
|
120
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: MtxDrawerContainer, deps: [{ token: i0.ElementRef }, { token: i1.FocusTrapFactory }, { token: DOCUMENT, optional: true }, { token: MtxDrawerConfig }, { token: i1.InteractivityChecker }, { token: i0.NgZone }, { token: i3.OverlayRef }, { token: i1.FocusMonitor }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
121
|
+
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.1.2", type: MtxDrawerContainer, isStandalone: true, selector: "mtx-drawer-container", host: { attributes: { "tabindex": "-1" }, listeners: { "@state.start": "_onAnimationStart($event)", "@state.done": "_onAnimationDone($event)" }, properties: { "class": "_drawerPosition", "id": "_config.id", "attr.role": "_config.role", "attr.aria-modal": "_config.isModal", "attr.aria-label": "_config.ariaLabel", "@state": "_animationState" }, classAttribute: "mtx-drawer-container" }, viewQueries: [{ propertyName: "_portalOutlet", first: true, predicate: CdkPortalOutlet, descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<ng-template cdkPortalOutlet></ng-template>\n", styles: [".mtx-drawer-container{display:block;width:100%;padding:8px 16px;overflow:auto;outline:0;box-sizing:border-box;background-color:var(--mtx-drawer-container-background-color);color:var(--mtx-drawer-container-text-color);box-shadow:var(--mtx-drawer-container-elevation-shadow)}.cdk-high-contrast-active .mtx-drawer-container{outline:1px solid}.mtx-drawer-right{transform:translate(100%);border-top-left-radius:var(--mtx-drawer-container-shape);border-bottom-left-radius:var(--mtx-drawer-container-shape)}.mtx-drawer-left{transform:translate(-100%);border-top-right-radius:var(--mtx-drawer-container-shape);border-bottom-right-radius:var(--mtx-drawer-container-shape)}.mtx-drawer-bottom{transform:translateY(100%);border-top-left-radius:var(--mtx-drawer-container-shape);border-top-right-radius:var(--mtx-drawer-container-shape)}.mtx-drawer-top{transform:translateY(-100%);border-bottom-left-radius:var(--mtx-drawer-container-shape);border-bottom-right-radius:var(--mtx-drawer-container-shape)}\n"], dependencies: [{ kind: "directive", type: CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }], animations: [mtxDrawerAnimations.drawerState], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None }); }
|
|
289
122
|
}
|
|
290
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.
|
|
123
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: MtxDrawerContainer, decorators: [{
|
|
291
124
|
type: Component,
|
|
292
125
|
args: [{ selector: 'mtx-drawer-container', changeDetection: ChangeDetectionStrategy.Default, encapsulation: ViewEncapsulation.None, animations: [mtxDrawerAnimations.drawerState], host: {
|
|
293
126
|
'class': 'mtx-drawer-container',
|
|
294
127
|
'[class]': '_drawerPosition',
|
|
295
128
|
'tabindex': '-1',
|
|
296
|
-
'
|
|
297
|
-
'
|
|
298
|
-
'[attr.aria-
|
|
129
|
+
'[id]': '_config.id',
|
|
130
|
+
'[attr.role]': '_config.role',
|
|
131
|
+
'[attr.aria-modal]': '_config.isModal',
|
|
132
|
+
'[attr.aria-label]': '_config.ariaLabel',
|
|
299
133
|
'[@state]': '_animationState',
|
|
300
134
|
'(@state.start)': '_onAnimationStart($event)',
|
|
301
135
|
'(@state.done)': '_onAnimationDone($event)',
|
|
302
|
-
}, standalone: true, imports: [CdkPortalOutlet], template: "<
|
|
303
|
-
}], ctorParameters: () => [{ type: i0.ElementRef }, { type:
|
|
136
|
+
}, standalone: true, imports: [CdkPortalOutlet], template: "<ng-template cdkPortalOutlet></ng-template>\n", styles: [".mtx-drawer-container{display:block;width:100%;padding:8px 16px;overflow:auto;outline:0;box-sizing:border-box;background-color:var(--mtx-drawer-container-background-color);color:var(--mtx-drawer-container-text-color);box-shadow:var(--mtx-drawer-container-elevation-shadow)}.cdk-high-contrast-active .mtx-drawer-container{outline:1px solid}.mtx-drawer-right{transform:translate(100%);border-top-left-radius:var(--mtx-drawer-container-shape);border-bottom-left-radius:var(--mtx-drawer-container-shape)}.mtx-drawer-left{transform:translate(-100%);border-top-right-radius:var(--mtx-drawer-container-shape);border-bottom-right-radius:var(--mtx-drawer-container-shape)}.mtx-drawer-bottom{transform:translateY(100%);border-top-left-radius:var(--mtx-drawer-container-shape);border-top-right-radius:var(--mtx-drawer-container-shape)}.mtx-drawer-top{transform:translateY(-100%);border-bottom-left-radius:var(--mtx-drawer-container-shape);border-bottom-right-radius:var(--mtx-drawer-container-shape)}\n"] }]
|
|
137
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i1.FocusTrapFactory }, { type: undefined, decorators: [{
|
|
304
138
|
type: Optional
|
|
305
139
|
}, {
|
|
306
140
|
type: Inject,
|
|
307
141
|
args: [DOCUMENT]
|
|
308
|
-
}] }, { type: MtxDrawerConfig }], propDecorators: { _portalOutlet: [{
|
|
142
|
+
}] }, { type: MtxDrawerConfig }, { type: i1.InteractivityChecker }, { type: i0.NgZone }, { type: i3.OverlayRef }, { type: i1.FocusMonitor }], propDecorators: { _portalOutlet: [{
|
|
309
143
|
type: ViewChild,
|
|
310
144
|
args: [CdkPortalOutlet, { static: true }]
|
|
311
145
|
}] } });
|
|
@@ -314,14 +148,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImpor
|
|
|
314
148
|
* Reference to a drawer dispatched from the drawer service.
|
|
315
149
|
*/
|
|
316
150
|
class MtxDrawerRef {
|
|
317
|
-
|
|
318
|
-
|
|
151
|
+
/** Instance of the component making up the content of the drawer. */
|
|
152
|
+
get instance() {
|
|
153
|
+
return this._ref.componentInstance;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* `ComponentRef` of the component opened into the drawer. Will be
|
|
157
|
+
* null when the drawer is opened using a `TemplateRef`.
|
|
158
|
+
*/
|
|
159
|
+
get componentRef() {
|
|
160
|
+
return this._ref.componentRef;
|
|
161
|
+
}
|
|
162
|
+
constructor(_ref, config, containerInstance) {
|
|
163
|
+
this._ref = _ref;
|
|
319
164
|
/** Subject for notifying the user that the drawer has been dismissed. */
|
|
320
165
|
this._afterDismissed = new Subject();
|
|
321
166
|
/** Subject for notifying the user that the drawer has opened and appeared. */
|
|
322
167
|
this._afterOpened = new Subject();
|
|
323
168
|
this.containerInstance = containerInstance;
|
|
324
|
-
this.disableClose =
|
|
169
|
+
this.disableClose = config.disableClose;
|
|
170
|
+
this.id = _ref.id;
|
|
325
171
|
// Emit when opening animation completes
|
|
326
172
|
containerInstance._animationStateChanged
|
|
327
173
|
.pipe(filter(event => event.phaseName === 'done' && event.toState === 'visible'), take(1))
|
|
@@ -334,16 +180,12 @@ class MtxDrawerRef {
|
|
|
334
180
|
.pipe(filter(event => event.phaseName === 'done' && event.toState === 'hidden'), take(1))
|
|
335
181
|
.subscribe(() => {
|
|
336
182
|
clearTimeout(this._closeFallbackTimeout);
|
|
337
|
-
|
|
183
|
+
this._ref.close(this._result);
|
|
338
184
|
});
|
|
339
|
-
|
|
340
|
-
.
|
|
341
|
-
.pipe(take(1))
|
|
342
|
-
.subscribe(() => {
|
|
343
|
-
this._afterDismissed.next(this._result);
|
|
344
|
-
this._afterDismissed.complete();
|
|
185
|
+
_ref.overlayRef.detachments().subscribe(() => {
|
|
186
|
+
this._ref.close(this._result);
|
|
345
187
|
});
|
|
346
|
-
merge(
|
|
188
|
+
merge(this.backdropClick(), this.keydownEvents().pipe(filter(event => event.keyCode === ESCAPE))).subscribe(event => {
|
|
347
189
|
if (!this.disableClose &&
|
|
348
190
|
(event.type !== 'keydown' || !hasModifierKey(event))) {
|
|
349
191
|
event.preventDefault();
|
|
@@ -356,7 +198,7 @@ class MtxDrawerRef {
|
|
|
356
198
|
* @param result Data to be passed back to the drawer opener.
|
|
357
199
|
*/
|
|
358
200
|
dismiss(result) {
|
|
359
|
-
if (!this._afterDismissed.closed) {
|
|
201
|
+
if (this.containerInstance && !this._afterDismissed.closed) {
|
|
360
202
|
// Transition the backdrop in parallel to the drawer.
|
|
361
203
|
this.containerInstance._animationStateChanged
|
|
362
204
|
.pipe(filter(event => event.phaseName === 'start'), take(1))
|
|
@@ -367,17 +209,18 @@ class MtxDrawerRef {
|
|
|
367
209
|
// amount of time plus 100ms. We don't need to run this outside the NgZone, because for the
|
|
368
210
|
// vast majority of cases the timeout will have been cleared before it has fired.
|
|
369
211
|
this._closeFallbackTimeout = setTimeout(() => {
|
|
370
|
-
this.
|
|
212
|
+
this._ref.close(this._result);
|
|
371
213
|
}, event.totalTime + 100);
|
|
372
|
-
this.
|
|
214
|
+
this._ref.overlayRef.detachBackdrop();
|
|
373
215
|
});
|
|
374
216
|
this._result = result;
|
|
375
217
|
this.containerInstance.exit();
|
|
218
|
+
this.containerInstance = null;
|
|
376
219
|
}
|
|
377
220
|
}
|
|
378
221
|
/** Gets an observable that is notified when the drawer is finished closing. */
|
|
379
222
|
afterDismissed() {
|
|
380
|
-
return this.
|
|
223
|
+
return this._ref.closed;
|
|
381
224
|
}
|
|
382
225
|
/** Gets an observable that is notified when the drawer has opened and appeared. */
|
|
383
226
|
afterOpened() {
|
|
@@ -387,13 +230,13 @@ class MtxDrawerRef {
|
|
|
387
230
|
* Gets an observable that emits when the overlay's backdrop has been clicked.
|
|
388
231
|
*/
|
|
389
232
|
backdropClick() {
|
|
390
|
-
return this.
|
|
233
|
+
return this._ref.backdropClick;
|
|
391
234
|
}
|
|
392
235
|
/**
|
|
393
236
|
* Gets an observable that emits when keydown events are targeted on the overlay.
|
|
394
237
|
*/
|
|
395
238
|
keydownEvents() {
|
|
396
|
-
return this.
|
|
239
|
+
return this._ref.keydownEvents;
|
|
397
240
|
}
|
|
398
241
|
}
|
|
399
242
|
|
|
@@ -401,139 +244,125 @@ class MtxDrawerRef {
|
|
|
401
244
|
const MTX_DRAWER_DATA = new InjectionToken('MtxDrawerData');
|
|
402
245
|
/** Injection token that can be used to specify default drawer options. */
|
|
403
246
|
const MTX_DRAWER_DEFAULT_OPTIONS = new InjectionToken('mtx-drawer-default-options');
|
|
247
|
+
// Counter for unique drawer ids.
|
|
248
|
+
let uniqueId = 0;
|
|
404
249
|
/**
|
|
405
250
|
* Service to trigger Material Design bottom sheets.
|
|
406
251
|
*/
|
|
407
252
|
class MtxDrawer {
|
|
408
|
-
/**
|
|
409
|
-
get
|
|
410
|
-
|
|
411
|
-
return parent ? parent._openedDrawerRef : this._drawerRefAtThisLevel;
|
|
253
|
+
/** Keeps track of the currently-open dialogs. */
|
|
254
|
+
get openDrawers() {
|
|
255
|
+
return this._parentDrawer ? this._parentDrawer.openDrawers : this._openDrawersAtThisLevel;
|
|
412
256
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
257
|
+
/** Stream that emits when a drawer has been opened. */
|
|
258
|
+
get afterOpened() {
|
|
259
|
+
return this._parentDrawer ? this._parentDrawer.afterOpened : this._afterOpenedAtThisLevel;
|
|
260
|
+
}
|
|
261
|
+
_getAfterAllDismissed() {
|
|
262
|
+
const parent = this._parentDrawer;
|
|
263
|
+
return parent ? parent._getAfterAllDismissed() : this._afterAllDismissedAtThisLevel;
|
|
420
264
|
}
|
|
421
|
-
constructor(_overlay,
|
|
265
|
+
constructor(_overlay, injector, _parentDrawer, _defaultOptions) {
|
|
422
266
|
this._overlay = _overlay;
|
|
423
|
-
this._injector = _injector;
|
|
424
267
|
this._parentDrawer = _parentDrawer;
|
|
425
268
|
this._defaultOptions = _defaultOptions;
|
|
426
|
-
this.
|
|
269
|
+
this._openDrawersAtThisLevel = [];
|
|
270
|
+
this._afterAllDismissedAtThisLevel = new Subject();
|
|
271
|
+
this._afterOpenedAtThisLevel = new Subject();
|
|
272
|
+
/**
|
|
273
|
+
* Stream that emits when all open drawer have finished closing.
|
|
274
|
+
* Will emit on subscribe if there are no open drawers to begin with.
|
|
275
|
+
*/
|
|
276
|
+
this.afterAllDismissed = defer(() => this.openDrawers.length
|
|
277
|
+
? this._getAfterAllDismissed()
|
|
278
|
+
: this._getAfterAllDismissed().pipe(startWith(undefined)));
|
|
279
|
+
this._dialog = injector.get(Dialog);
|
|
427
280
|
}
|
|
428
281
|
open(componentOrTemplateRef, config) {
|
|
429
|
-
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
282
|
+
let drawerRef;
|
|
283
|
+
const _config = { ...(this._defaultOptions || new MtxDrawerConfig()), ...config };
|
|
284
|
+
_config.id = _config.id || `mtx-drawer-${uniqueId++}`;
|
|
285
|
+
_config.width =
|
|
286
|
+
_config.position === 'left' || _config.position === 'right'
|
|
287
|
+
? coerceCssPixelValue(_config.width)
|
|
288
|
+
: '100vw';
|
|
289
|
+
_config.height =
|
|
290
|
+
_config.position === 'top' || _config.position === 'bottom'
|
|
291
|
+
? coerceCssPixelValue(_config.height)
|
|
292
|
+
: '100vh';
|
|
293
|
+
this._dialog.open(componentOrTemplateRef, {
|
|
294
|
+
..._config,
|
|
295
|
+
// Disable closing since we need to sync it up to the animation ourselves.
|
|
296
|
+
disableClose: true,
|
|
297
|
+
// Disable closing on detachments so that we can sync up the animation.
|
|
298
|
+
closeOnOverlayDetachments: false,
|
|
299
|
+
container: {
|
|
300
|
+
type: MtxDrawerContainer,
|
|
301
|
+
providers: () => [
|
|
302
|
+
// Provide our config as the CDK config as well since it has the same interface as the
|
|
303
|
+
// CDK one, but it contains the actual values passed in by the user for things like
|
|
304
|
+
// `disableClose` which we disable for the CDK dialog since we handle it ourselves.
|
|
305
|
+
{ provide: MtxDrawerConfig, useValue: _config },
|
|
306
|
+
{ provide: DialogConfig, useValue: _config },
|
|
307
|
+
],
|
|
308
|
+
},
|
|
309
|
+
scrollStrategy: _config.scrollStrategy || this._overlay.scrollStrategies.block(),
|
|
310
|
+
positionStrategy: this._overlay.position().global()[_config.position]('0'),
|
|
311
|
+
templateContext: () => ({ drawerRef }),
|
|
312
|
+
providers: (cdkRef, _cdkConfig, container) => {
|
|
313
|
+
drawerRef = new MtxDrawerRef(cdkRef, _config, container);
|
|
314
|
+
return [
|
|
315
|
+
{ provide: MtxDrawerRef, useValue: drawerRef },
|
|
316
|
+
{ provide: MTX_DRAWER_DATA, useValue: _config.data },
|
|
317
|
+
];
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
this.openDrawers.push(drawerRef);
|
|
321
|
+
this.afterOpened.next(drawerRef);
|
|
322
|
+
drawerRef.afterDismissed().subscribe(() => {
|
|
323
|
+
const index = this.openDrawers.indexOf(drawerRef);
|
|
324
|
+
if (index > -1) {
|
|
325
|
+
this.openDrawers.splice(index, 1);
|
|
326
|
+
if (!this.openDrawers.length) {
|
|
327
|
+
this._getAfterAllDismissed().next();
|
|
328
|
+
}
|
|
449
329
|
}
|
|
450
330
|
});
|
|
451
|
-
|
|
452
|
-
// If a drawer is already in view, dismiss it and enter the
|
|
453
|
-
// new drawer after exit animation is complete.
|
|
454
|
-
this._openedDrawerRef.afterDismissed().subscribe(() => ref.containerInstance.enter());
|
|
455
|
-
this._openedDrawerRef.dismiss();
|
|
456
|
-
}
|
|
457
|
-
else {
|
|
458
|
-
// If no drawer is in view, enter the new drawer.
|
|
459
|
-
ref.containerInstance.enter();
|
|
460
|
-
}
|
|
461
|
-
this._openedDrawerRef = ref;
|
|
462
|
-
return ref;
|
|
331
|
+
return drawerRef;
|
|
463
332
|
}
|
|
464
333
|
/**
|
|
465
|
-
* Dismisses the currently-
|
|
466
|
-
* @param result Data to pass to the drawer instance.
|
|
334
|
+
* Dismisses all of the currently-open drawers.
|
|
467
335
|
*/
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
this._openedDrawerRef.dismiss(result);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
ngOnDestroy() {
|
|
474
|
-
if (this._drawerRefAtThisLevel) {
|
|
475
|
-
this._drawerRefAtThisLevel.dismiss();
|
|
476
|
-
}
|
|
336
|
+
dismissAll() {
|
|
337
|
+
this._dismissDrawers(this.openDrawers);
|
|
477
338
|
}
|
|
478
339
|
/**
|
|
479
|
-
*
|
|
340
|
+
* Finds an open drawer by its id.
|
|
341
|
+
* @param id ID to use when looking up the drawer.
|
|
480
342
|
*/
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
const injector = Injector.create({
|
|
484
|
-
parent: userInjector || this._injector,
|
|
485
|
-
providers: [{ provide: MtxDrawerConfig, useValue: config }],
|
|
486
|
-
});
|
|
487
|
-
const containerPortal = new ComponentPortal(MtxDrawerContainer, config.viewContainerRef, injector);
|
|
488
|
-
const containerRef = overlayRef.attach(containerPortal);
|
|
489
|
-
return containerRef.instance;
|
|
343
|
+
getDrawerById(id) {
|
|
344
|
+
return this.openDrawers.find(drawer => drawer.id === id);
|
|
490
345
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
positionStrategy: this._overlay.position().global()[config.position]('0'),
|
|
503
|
-
});
|
|
504
|
-
if (config.backdropClass) {
|
|
505
|
-
overlayConfig.backdropClass = config.backdropClass;
|
|
506
|
-
}
|
|
507
|
-
return this._overlay.create(overlayConfig);
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
* Creates an injector to be used inside of a drawer component.
|
|
511
|
-
* @param config Config that was used to create the drawer.
|
|
512
|
-
* @param drawerRef Reference to the drawer.
|
|
513
|
-
*/
|
|
514
|
-
_createInjector(config, drawerRef) {
|
|
515
|
-
const userInjector = config && config.viewContainerRef && config.viewContainerRef.injector;
|
|
516
|
-
const providers = [
|
|
517
|
-
{ provide: MtxDrawerRef, useValue: drawerRef },
|
|
518
|
-
{ provide: MTX_DRAWER_DATA, useValue: config.data },
|
|
519
|
-
];
|
|
520
|
-
if (config.direction &&
|
|
521
|
-
(!userInjector ||
|
|
522
|
-
!userInjector.get(Directionality, null, InjectFlags.Optional))) {
|
|
523
|
-
providers.push({
|
|
524
|
-
provide: Directionality,
|
|
525
|
-
useValue: { value: config.direction, change: of() },
|
|
526
|
-
});
|
|
346
|
+
ngOnDestroy() {
|
|
347
|
+
// Only dismiss the drawers at this level on destroy
|
|
348
|
+
// since the parent service may still be active.
|
|
349
|
+
this._dismissDrawers(this._openDrawersAtThisLevel);
|
|
350
|
+
this._afterAllDismissedAtThisLevel.complete();
|
|
351
|
+
this._afterOpenedAtThisLevel.complete();
|
|
352
|
+
}
|
|
353
|
+
_dismissDrawers(drawers) {
|
|
354
|
+
let i = drawers.length;
|
|
355
|
+
while (i--) {
|
|
356
|
+
drawers[i].dismiss();
|
|
527
357
|
}
|
|
528
|
-
return Injector.create({ parent: userInjector || this._injector, providers });
|
|
529
358
|
}
|
|
530
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.
|
|
531
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.
|
|
359
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: MtxDrawer, deps: [{ token: i3.Overlay }, { token: i0.Injector }, { token: MtxDrawer, optional: true, skipSelf: true }, { token: MTX_DRAWER_DEFAULT_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
360
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: MtxDrawer, providedIn: 'root' }); }
|
|
532
361
|
}
|
|
533
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.
|
|
362
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: MtxDrawer, decorators: [{
|
|
534
363
|
type: Injectable,
|
|
535
364
|
args: [{ providedIn: 'root' }]
|
|
536
|
-
}], ctorParameters: () => [{ type:
|
|
365
|
+
}], ctorParameters: () => [{ type: i3.Overlay }, { type: i0.Injector }, { type: MtxDrawer, decorators: [{
|
|
537
366
|
type: Optional
|
|
538
367
|
}, {
|
|
539
368
|
type: SkipSelf
|
|
@@ -543,25 +372,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImpor
|
|
|
543
372
|
type: Inject,
|
|
544
373
|
args: [MTX_DRAWER_DEFAULT_OPTIONS]
|
|
545
374
|
}] }] });
|
|
546
|
-
/**
|
|
547
|
-
* Applies default options to the drawer config.
|
|
548
|
-
* @param defaults Object containing the default values to which to fall back.
|
|
549
|
-
* @param config The configuration to which the defaults will be applied.
|
|
550
|
-
* @returns The new configuration object with defaults applied.
|
|
551
|
-
*/
|
|
552
|
-
function _applyConfigDefaults(defaults, config) {
|
|
553
|
-
return { ...defaults, ...config };
|
|
554
|
-
}
|
|
555
375
|
|
|
556
376
|
class MtxDrawerModule {
|
|
557
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.
|
|
558
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.
|
|
559
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.
|
|
377
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: MtxDrawerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
378
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.1.2", ngImport: i0, type: MtxDrawerModule, imports: [DialogModule, PortalModule, MatCommonModule, MtxDrawerContainer], exports: [MtxDrawerContainer, MatCommonModule] }); }
|
|
379
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: MtxDrawerModule, providers: [MtxDrawer], imports: [DialogModule, PortalModule, MatCommonModule, MatCommonModule] }); }
|
|
560
380
|
}
|
|
561
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.
|
|
381
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: MtxDrawerModule, decorators: [{
|
|
562
382
|
type: NgModule,
|
|
563
383
|
args: [{
|
|
564
|
-
imports: [
|
|
384
|
+
imports: [DialogModule, PortalModule, MatCommonModule, MtxDrawerContainer],
|
|
565
385
|
exports: [MtxDrawerContainer, MatCommonModule],
|
|
566
386
|
providers: [MtxDrawer],
|
|
567
387
|
}]
|