@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.
Files changed (177) hide show
  1. package/README.md +27 -2
  2. package/alert/alert.scss +13 -16
  3. package/colorpicker/colorpicker-toggle.scss +1 -1
  4. package/colorpicker/colorpicker.d.ts +1 -1
  5. package/column-resize/resize-strategy.d.ts +1 -1
  6. package/core/m2/_typography.scss +172 -0
  7. package/core/pipes/is-template-ref.pipe.d.ts +2 -2
  8. package/core/style/_elevation.scss +167 -0
  9. package/core/tokens/_m3-tokens.scss +13 -10
  10. package/core/tokens/_token-utils.scss +120 -30
  11. package/core/tokens/m2/mtx/_alert.scss +17 -9
  12. package/core/tokens/m2/mtx/_datetimepicker.scss +3 -3
  13. package/core/tokens/m2/mtx/_drawer.scss +2 -2
  14. package/core/tokens/m2/mtx/_grid.scss +0 -2
  15. package/core/tokens/m2/mtx/_popover.scss +3 -0
  16. package/core/tokens/m2/mtx/_select.scss +2 -4
  17. package/core/tokens/m3/definitions/_index.scss +8 -0
  18. package/core/tokens/m3/definitions/_md-ref-palette.scss +100 -0
  19. package/core/tokens/m3/definitions/_md-ref-typeface.scss +14 -0
  20. package/core/tokens/m3/definitions/_md-sys-color.scss +126 -0
  21. package/core/tokens/m3/definitions/_md-sys-elevation.scss +15 -0
  22. package/core/tokens/m3/definitions/_md-sys-motion.scss +46 -0
  23. package/core/tokens/m3/definitions/_md-sys-shape.scss +24 -0
  24. package/core/tokens/m3/definitions/_md-sys-state.scss +13 -0
  25. package/core/tokens/m3/definitions/_md-sys-typescale.scss +308 -0
  26. package/core/tokens/m3/mtx/_alert.scss +19 -9
  27. package/core/tokens/m3/mtx/_datetimepicker.scss +3 -3
  28. package/core/tokens/m3/mtx/_drawer.scss +2 -2
  29. package/core/tokens/m3/mtx/_grid.scss +0 -2
  30. package/core/tokens/m3/mtx/_popover.scss +3 -0
  31. package/core/tokens/m3/mtx/_select.scss +2 -2
  32. package/core/typography/_all-typography.scss +2 -2
  33. package/datetimepicker/calendar.d.ts +4 -2
  34. package/datetimepicker/calendar.scss +38 -0
  35. package/datetimepicker/datetimepicker-actions.d.ts +32 -0
  36. package/datetimepicker/datetimepicker-actions.scss +18 -0
  37. package/datetimepicker/datetimepicker-animations.d.ts +1 -1
  38. package/datetimepicker/datetimepicker-content.scss +40 -22
  39. package/datetimepicker/datetimepicker-module.d.ts +2 -1
  40. package/datetimepicker/datetimepicker-toggle.scss +1 -1
  41. package/datetimepicker/datetimepicker.d.ts +33 -3
  42. package/datetimepicker/public-api.d.ts +1 -0
  43. package/datetimepicker/time.d.ts +12 -8
  44. package/datetimepicker/time.scss +6 -6
  45. package/dialog/dialog.d.ts +1 -1
  46. package/drawer/drawer-config.d.ts +8 -6
  47. package/drawer/drawer-container.d.ts +12 -68
  48. package/drawer/drawer-container.scss +4 -6
  49. package/drawer/drawer-module.d.ts +2 -2
  50. package/drawer/drawer-ref.d.ts +13 -4
  51. package/drawer/drawer.d.ts +24 -24
  52. package/esm2022/alert/alert-module.mjs +5 -5
  53. package/esm2022/alert/alert.mjs +6 -5
  54. package/esm2022/button/button-loading.mjs +3 -3
  55. package/esm2022/button/button-module.mjs +4 -4
  56. package/esm2022/checkbox-group/checkbox-group-module.mjs +4 -4
  57. package/esm2022/checkbox-group/checkbox-group.mjs +3 -3
  58. package/esm2022/colorpicker/colorpicker-input.mjs +3 -3
  59. package/esm2022/colorpicker/colorpicker-module.mjs +4 -4
  60. package/esm2022/colorpicker/colorpicker-toggle.mjs +6 -6
  61. package/esm2022/colorpicker/colorpicker.mjs +8 -8
  62. package/esm2022/column-resize/column-resize-directives/column-resize-flex.mjs +3 -3
  63. package/esm2022/column-resize/column-resize-directives/column-resize.mjs +3 -3
  64. package/esm2022/column-resize/column-resize-module.mjs +4 -4
  65. package/esm2022/column-resize/column-resize-notifier.mjs +6 -6
  66. package/esm2022/column-resize/column-resize.mjs +3 -3
  67. package/esm2022/column-resize/column-size-store.mjs +3 -3
  68. package/esm2022/column-resize/event-dispatcher.mjs +3 -3
  69. package/esm2022/column-resize/overlay-handle.mjs +3 -3
  70. package/esm2022/column-resize/resizable.mjs +3 -3
  71. package/esm2022/column-resize/resize-strategy.mjs +9 -9
  72. package/esm2022/core/datetime/datetime.module.mjs +8 -8
  73. package/esm2022/core/datetime/native-datetime-adapter.mjs +3 -3
  74. package/esm2022/core/pipes/is-template-ref.pipe.mjs +3 -3
  75. package/esm2022/core/pipes/pipes.module.mjs +4 -4
  76. package/esm2022/core/pipes/to-observable.pipe.mjs +3 -3
  77. package/esm2022/datetimepicker/calendar-body.mjs +3 -3
  78. package/esm2022/datetimepicker/calendar.mjs +10 -6
  79. package/esm2022/datetimepicker/clock.mjs +3 -3
  80. package/esm2022/datetimepicker/datetimepicker-actions.mjs +88 -0
  81. package/esm2022/datetimepicker/datetimepicker-animations.mjs +3 -3
  82. package/esm2022/datetimepicker/datetimepicker-input.mjs +3 -3
  83. package/esm2022/datetimepicker/datetimepicker-intl.mjs +3 -3
  84. package/esm2022/datetimepicker/datetimepicker-module.mjs +24 -7
  85. package/esm2022/datetimepicker/datetimepicker-toggle.mjs +6 -6
  86. package/esm2022/datetimepicker/datetimepicker.mjs +92 -20
  87. package/esm2022/datetimepicker/month-view.mjs +7 -5
  88. package/esm2022/datetimepicker/multi-year-view.mjs +7 -5
  89. package/esm2022/datetimepicker/public-api.mjs +2 -1
  90. package/esm2022/datetimepicker/time.mjs +29 -20
  91. package/esm2022/datetimepicker/year-view.mjs +7 -5
  92. package/esm2022/dialog/dialog-container.mjs +3 -3
  93. package/esm2022/dialog/dialog-module.mjs +4 -4
  94. package/esm2022/dialog/dialog.mjs +3 -3
  95. package/esm2022/drawer/drawer-config.mjs +2 -2
  96. package/esm2022/drawer/drawer-container.mjs +32 -196
  97. package/esm2022/drawer/drawer-module.mjs +7 -7
  98. package/esm2022/drawer/drawer-ref.mjs +27 -18
  99. package/esm2022/drawer/drawer.mjs +98 -121
  100. package/esm2022/grid/cell.mjs +3 -3
  101. package/esm2022/grid/column-menu.mjs +5 -5
  102. package/esm2022/grid/column-resize/column-resize-directives/column-resize-flex.mjs +3 -3
  103. package/esm2022/grid/column-resize/column-resize-directives/column-resize.mjs +3 -3
  104. package/esm2022/grid/column-resize/column-resize-module.mjs +8 -8
  105. package/esm2022/grid/column-resize/overlay-handle.mjs +3 -3
  106. package/esm2022/grid/column-resize/resizable-directives/resizable.mjs +3 -3
  107. package/esm2022/grid/column-resize/resize-strategy.mjs +3 -3
  108. package/esm2022/grid/expansion-toggle.mjs +3 -3
  109. package/esm2022/grid/grid-module.mjs +4 -4
  110. package/esm2022/grid/grid-pipes.mjs +21 -21
  111. package/esm2022/grid/grid-utils.mjs +3 -3
  112. package/esm2022/grid/grid.mjs +5 -5
  113. package/esm2022/grid/selectable-cell.mjs +3 -3
  114. package/esm2022/loader/loader-module.mjs +4 -4
  115. package/esm2022/loader/loader.mjs +3 -3
  116. package/esm2022/photoviewer/photoviewer-module.mjs +4 -4
  117. package/esm2022/photoviewer/photoviewer.mjs +3 -3
  118. package/esm2022/popover/popover-content.mjs +6 -6
  119. package/esm2022/popover/popover-interfaces.mjs +1 -1
  120. package/esm2022/popover/popover-module.mjs +4 -4
  121. package/esm2022/popover/popover-target.mjs +3 -3
  122. package/esm2022/popover/popover-trigger.mjs +3 -3
  123. package/esm2022/popover/popover.mjs +29 -19
  124. package/esm2022/progress/progress-module.mjs +4 -4
  125. package/esm2022/progress/progress.mjs +3 -3
  126. package/esm2022/select/option.mjs +3 -3
  127. package/esm2022/select/select-module.mjs +4 -4
  128. package/esm2022/select/select.mjs +3 -3
  129. package/esm2022/select/templates.mjs +33 -33
  130. package/esm2022/split/split-module.mjs +4 -4
  131. package/esm2022/split/split-pane.mjs +3 -3
  132. package/esm2022/split/split.mjs +3 -3
  133. package/esm2022/tooltip/tooltip-module.mjs +4 -4
  134. package/esm2022/tooltip/tooltip.mjs +20 -18
  135. package/fesm2022/mtxAlert.mjs +9 -8
  136. package/fesm2022/mtxAlert.mjs.map +1 -1
  137. package/fesm2022/mtxButton.mjs +7 -7
  138. package/fesm2022/mtxCheckboxGroup.mjs +7 -7
  139. package/fesm2022/mtxColorpicker.mjs +20 -20
  140. package/fesm2022/mtxColorpicker.mjs.map +1 -1
  141. package/fesm2022/mtxColumnResize.mjs +40 -40
  142. package/fesm2022/mtxCore.mjs +21 -21
  143. package/fesm2022/mtxDatetimepicker.mjs +273 -82
  144. package/fesm2022/mtxDatetimepicker.mjs.map +1 -1
  145. package/fesm2022/mtxDialog.mjs +10 -10
  146. package/fesm2022/mtxDrawer.mjs +160 -340
  147. package/fesm2022/mtxDrawer.mjs.map +1 -1
  148. package/fesm2022/mtxGrid.mjs +68 -68
  149. package/fesm2022/mtxGrid.mjs.map +1 -1
  150. package/fesm2022/mtxLoader.mjs +7 -7
  151. package/fesm2022/mtxPhotoviewer.mjs +7 -7
  152. package/fesm2022/mtxPopover.mjs +44 -34
  153. package/fesm2022/mtxPopover.mjs.map +1 -1
  154. package/fesm2022/mtxProgress.mjs +7 -7
  155. package/fesm2022/mtxSelect.mjs +43 -43
  156. package/fesm2022/mtxSplit.mjs +10 -10
  157. package/fesm2022/mtxTooltip.mjs +23 -21
  158. package/fesm2022/mtxTooltip.mjs.map +1 -1
  159. package/grid/column-menu.scss +0 -1
  160. package/grid/grid.scss +2 -0
  161. package/package.json +7 -7
  162. package/popover/popover-interfaces.d.ts +0 -1
  163. package/popover/popover.d.ts +2 -5
  164. package/prebuilt-themes/azure-blue.css +1 -1
  165. package/prebuilt-themes/cyan-orange.css +1 -1
  166. package/prebuilt-themes/deeppurple-amber.css +1 -1
  167. package/prebuilt-themes/indigo-pink.css +1 -1
  168. package/prebuilt-themes/magenta-violet.css +1 -1
  169. package/prebuilt-themes/pink-bluegrey.css +1 -1
  170. package/prebuilt-themes/purple-green.css +1 -1
  171. package/prebuilt-themes/rose-red.css +1 -1
  172. package/select/option.d.ts +1 -1
  173. package/select/select.scss +2 -2
  174. package/tooltip/_tooltip-theme.scss +19 -15
  175. package/tooltip/tooltip.d.ts +3 -0
  176. package/tooltip/tooltip.scss +61 -29
  177. package/core/typography/_typography.scss +0 -40
@@ -1,20 +1,16 @@
1
- import * as i1$1 from '@angular/cdk/overlay';
2
- import { OverlayConfig, OverlayModule } from '@angular/cdk/overlay';
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, TemplateRef, Injector, InjectFlags, Injectable, SkipSelf, NgModule } from '@angular/core';
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 { Directionality } from '@angular/cdk/bidi';
8
- import { Subject, merge, of } from 'rxjs';
9
- import { coerceCssPixelValue, coerceArray } from '@angular/cdk/coercion';
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 BasePortalOutlet {
72
+ class MtxDrawerContainer extends CdkDialogContainer {
77
73
  get _drawerPosition() {
78
- return `mtx-drawer-${this.drawerConfig.position}`;
74
+ return `mtx-drawer-${this._config.position}`;
79
75
  }
80
- get _drawerWidth() {
81
- return this.drawerConfig.position === 'left' || this.drawerConfig.position === 'right'
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
- /** Element that was focused before the drawer was opened. */
115
- this._elementFocusedBeforeOpened = null;
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
- /** Attach a component portal as content to this drawer container. */
133
- attachComponentPortal(portal) {
134
- this._validatePortalAttached();
135
- this._setPanelClass();
136
- this._savePreviouslyFocusedElement();
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
- /** Attach a template portal as content to this drawer container. */
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 drawer exiting from view. */
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
- this._breakpointSubscription.unsubscribe();
107
+ super.ngOnDestroy();
162
108
  this._destroyed = true;
163
109
  }
164
110
  _onAnimationDone(event) {
165
- if (event.toState === 'hidden') {
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
- _toggleClass(cssClass, add) {
177
- this._elementRef.nativeElement.classList.toggle(cssClass, add);
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.0.1", ngImport: i0, type: MtxDrawerContainer, decorators: [{
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
- 'role': 'dialog',
297
- 'aria-modal': 'true',
298
- '[attr.aria-label]': 'drawerConfig?.ariaLabel',
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: "<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"] }]
303
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1.FocusTrapFactory }, { type: i1.InteractivityChecker }, { type: i0.NgZone }, { type: i2.BreakpointObserver }, { type: undefined, decorators: [{
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
- constructor(containerInstance, _overlayRef) {
318
- this._overlayRef = _overlayRef;
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 = containerInstance.drawerConfig.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
- _overlayRef.dispose();
183
+ this._ref.close(this._result);
338
184
  });
339
- _overlayRef
340
- .detachments()
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(_overlayRef.backdropClick(), _overlayRef.keydownEvents().pipe(filter(event => event.keyCode === ESCAPE))).subscribe(event => {
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._overlayRef.dispose();
212
+ this._ref.close(this._result);
371
213
  }, event.totalTime + 100);
372
- this._overlayRef.detachBackdrop();
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._afterDismissed;
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._overlayRef.backdropClick();
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._overlayRef.keydownEvents();
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
- /** Reference to the currently opened drawer. */
409
- get _openedDrawerRef() {
410
- const parent = this._parentDrawer;
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
- set _openedDrawerRef(value) {
414
- if (this._parentDrawer) {
415
- this._parentDrawer._openedDrawerRef = value;
416
- }
417
- else {
418
- this._drawerRefAtThisLevel = value;
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, _injector, _parentDrawer, _defaultOptions) {
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._drawerRefAtThisLevel = null;
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
- const _config = _applyConfigDefaults(this._defaultOptions || new MtxDrawerConfig(), config);
430
- const overlayRef = this._createOverlay(_config);
431
- const container = this._attachContainer(overlayRef, _config);
432
- const ref = new MtxDrawerRef(container, overlayRef);
433
- if (componentOrTemplateRef instanceof TemplateRef) {
434
- container.attachTemplatePortal(new TemplatePortal(componentOrTemplateRef, null, {
435
- $implicit: _config.data,
436
- drawerRef: ref,
437
- }));
438
- }
439
- else {
440
- const portal = new ComponentPortal(componentOrTemplateRef, undefined, this._createInjector(_config, ref));
441
- const contentRef = container.attachComponentPortal(portal);
442
- ref.instance = contentRef.instance;
443
- }
444
- // When the drawer is dismissed, clear the reference to it.
445
- ref.afterDismissed().subscribe(() => {
446
- // Clear the drawer ref if it hasn't already been replaced by a newer one.
447
- if (this._openedDrawerRef == ref) {
448
- this._openedDrawerRef = null;
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
- if (this._openedDrawerRef) {
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-visible drawer.
466
- * @param result Data to pass to the drawer instance.
334
+ * Dismisses all of the currently-open drawers.
467
335
  */
468
- dismiss(result) {
469
- if (this._openedDrawerRef) {
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
- * Attaches the drawer container component to the overlay.
340
+ * Finds an open drawer by its id.
341
+ * @param id ID to use when looking up the drawer.
480
342
  */
481
- _attachContainer(overlayRef, config) {
482
- const userInjector = config && config.viewContainerRef && config.viewContainerRef.injector;
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
- * Creates a new overlay and places it in the correct location.
493
- * @param config The user-specified drawer config.
494
- */
495
- _createOverlay(config) {
496
- const overlayConfig = new OverlayConfig({
497
- direction: config.direction,
498
- hasBackdrop: config.hasBackdrop,
499
- disposeOnNavigation: config.closeOnNavigation,
500
- maxWidth: '100%',
501
- scrollStrategy: config.scrollStrategy || this._overlay.scrollStrategies.block(),
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.0.1", ngImport: i0, type: MtxDrawer, deps: [{ token: i1$1.Overlay }, { token: i0.Injector }, { token: MtxDrawer, optional: true, skipSelf: true }, { token: MTX_DRAWER_DEFAULT_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
531
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: MtxDrawer, providedIn: 'root' }); }
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.0.1", ngImport: i0, type: MtxDrawer, decorators: [{
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: i1$1.Overlay }, { type: i0.Injector }, { type: MtxDrawer, decorators: [{
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.0.1", ngImport: i0, type: MtxDrawerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
558
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.1", ngImport: i0, type: MtxDrawerModule, imports: [OverlayModule, PortalModule, MatCommonModule, MtxDrawerContainer], exports: [MtxDrawerContainer, MatCommonModule] }); }
559
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: MtxDrawerModule, providers: [MtxDrawer], imports: [OverlayModule, PortalModule, MatCommonModule, MatCommonModule] }); }
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.0.1", ngImport: i0, type: MtxDrawerModule, decorators: [{
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: [OverlayModule, PortalModule, MatCommonModule, MtxDrawerContainer],
384
+ imports: [DialogModule, PortalModule, MatCommonModule, MtxDrawerContainer],
565
385
  exports: [MtxDrawerContainer, MatCommonModule],
566
386
  providers: [MtxDrawer],
567
387
  }]