@ng-matero/extensions 13.2.2 → 13.3.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 (60) hide show
  1. package/colorpicker/colorpicker-toggle.d.ts +7 -5
  2. package/core/datetime/datetime-formats.d.ts +2 -0
  3. package/datetimepicker/datetimepicker-toggle.d.ts +3 -3
  4. package/esm2020/colorpicker/colorpicker-toggle.mjs +29 -18
  5. package/esm2020/core/datetime/datetime-formats.mjs +1 -1
  6. package/esm2020/datetimepicker/datetimepicker-input.mjs +6 -1
  7. package/esm2020/datetimepicker/datetimepicker-toggle.mjs +23 -16
  8. package/esm2020/datetimepicker/datetimepicker.mjs +6 -4
  9. package/esm2020/grid/cell.component.mjs +8 -4
  10. package/esm2020/grid/column-menu.component.mjs +11 -17
  11. package/esm2020/grid/grid.component.mjs +12 -7
  12. package/esm2020/popover/popover-animations.mjs +10 -13
  13. package/esm2020/popover/popover-content.mjs +90 -0
  14. package/esm2020/popover/popover-interfaces.mjs +1 -1
  15. package/esm2020/popover/popover-module.mjs +9 -7
  16. package/esm2020/popover/popover-target.mjs +3 -3
  17. package/esm2020/popover/popover-trigger.mjs +214 -184
  18. package/esm2020/popover/popover-types.mjs +1 -1
  19. package/esm2020/popover/popover.mjs +188 -133
  20. package/esm2020/popover/public-api.mjs +2 -1
  21. package/esm2020/select/option.component.mjs +4 -6
  22. package/esm2020/select/select.component.mjs +121 -31
  23. package/fesm2015/mtxColorpicker.mjs +27 -14
  24. package/fesm2015/mtxColorpicker.mjs.map +1 -1
  25. package/fesm2015/mtxCore.mjs.map +1 -1
  26. package/fesm2015/mtxDatetimepicker.mjs +34 -18
  27. package/fesm2015/mtxDatetimepicker.mjs.map +1 -1
  28. package/fesm2015/mtxGrid.mjs +28 -25
  29. package/fesm2015/mtxGrid.mjs.map +1 -1
  30. package/fesm2015/mtxPopover.mjs +520 -352
  31. package/fesm2015/mtxPopover.mjs.map +1 -1
  32. package/fesm2015/mtxSelect.mjs +172 -83
  33. package/fesm2015/mtxSelect.mjs.map +1 -1
  34. package/fesm2020/mtxColorpicker.mjs +25 -14
  35. package/fesm2020/mtxColorpicker.mjs.map +1 -1
  36. package/fesm2020/mtxCore.mjs.map +1 -1
  37. package/fesm2020/mtxDatetimepicker.mjs +32 -18
  38. package/fesm2020/mtxDatetimepicker.mjs.map +1 -1
  39. package/fesm2020/mtxGrid.mjs +28 -25
  40. package/fesm2020/mtxGrid.mjs.map +1 -1
  41. package/fesm2020/mtxPopover.mjs +514 -350
  42. package/fesm2020/mtxPopover.mjs.map +1 -1
  43. package/fesm2020/mtxSelect.mjs +170 -83
  44. package/fesm2020/mtxSelect.mjs.map +1 -1
  45. package/grid/cell.component.d.ts +5 -3
  46. package/grid/column-menu.component.d.ts +4 -6
  47. package/grid/grid.component.d.ts +7 -5
  48. package/package.json +1 -1
  49. package/popover/popover-animations.d.ts +1 -1
  50. package/popover/popover-content.d.ts +43 -0
  51. package/popover/popover-interfaces.d.ts +37 -31
  52. package/popover/popover-module.d.ts +4 -3
  53. package/popover/popover-target.d.ts +2 -2
  54. package/popover/popover-trigger.d.ts +67 -62
  55. package/popover/popover-types.d.ts +6 -1
  56. package/popover/popover.d.ts +99 -71
  57. package/popover/popover.scss +2 -0
  58. package/popover/public-api.d.ts +1 -0
  59. package/select/option.component.d.ts +7 -6
  60. package/select/select.component.d.ts +61 -22
@@ -1,18 +1,127 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, TemplateRef, Component, ChangeDetectionStrategy, ViewEncapsulation, Optional, HostBinding, Input, Output, ViewChild, Directive, HostListener, NgModule } from '@angular/core';
3
- import * as i2 from '@angular/common';
4
- import { CommonModule } from '@angular/common';
2
+ import { InjectionToken, Directive, Inject, EventEmitter, TemplateRef, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, ViewChild, ContentChild, Optional, NgModule } from '@angular/core';
3
+ import * as i1 from '@angular/common';
4
+ import { DOCUMENT, CommonModule } from '@angular/common';
5
5
  import * as i1$1 from '@angular/cdk/overlay';
6
- import { OverlayConfig, OverlayModule } from '@angular/cdk/overlay';
6
+ import { Overlay, OverlayConfig, OverlayModule } from '@angular/cdk/overlay';
7
7
  import * as i3 from '@angular/cdk/a11y';
8
8
  import { isFakeMousedownFromScreenReader, A11yModule } from '@angular/cdk/a11y';
9
9
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
10
- import { ESCAPE } from '@angular/cdk/keycodes';
10
+ import { ESCAPE, hasModifierKey, ENTER, SPACE } from '@angular/cdk/keycodes';
11
+ import { Subject, Subscription, of, merge } from 'rxjs';
11
12
  import { trigger, state, style, transition, animate } from '@angular/animations';
12
- import * as i1 from '@angular/cdk/bidi';
13
- import { TemplatePortal } from '@angular/cdk/portal';
14
- import { Subject } from 'rxjs';
15
- import { takeUntil } from 'rxjs/operators';
13
+ import { TemplatePortal, DomPortalOutlet } from '@angular/cdk/portal';
14
+ import { filter, take, takeUntil } from 'rxjs/operators';
15
+ import * as i2 from '@angular/cdk/bidi';
16
+
17
+ /**
18
+ * Below are all the animations for the mtx-popover component.
19
+ * Animation duration and timing values are based on AngularJS Material.
20
+ */
21
+ /**
22
+ * This animation controls the popover panel's entry and exit from the page.
23
+ *
24
+ * When the popover panel is added to the DOM, it scales in and fades in its border.
25
+ *
26
+ * When the popover panel is removed from the DOM, it simply fades out after a brief
27
+ * delay to display the ripple.
28
+ */
29
+ const transformPopover = trigger('transformPopover', [
30
+ state('void', style({
31
+ opacity: 0,
32
+ transform: 'scale(0.8)',
33
+ })),
34
+ transition('void => enter', animate('120ms cubic-bezier(0, 0, 0.2, 1)', style({
35
+ opacity: 1,
36
+ transform: 'scale(1)',
37
+ }))),
38
+ transition('* => void', animate('100ms 25ms linear', style({ opacity: 0 }))),
39
+ ]);
40
+
41
+ /**
42
+ * Injection token that can be used to reference instances of `MtxPopoverContent`. It serves
43
+ * as alternative token to the actual `MtxPopoverContent` class which could cause unnecessary
44
+ * retention of the class and its directive metadata.
45
+ */
46
+ const MTX_POPOVER_CONTENT = new InjectionToken('MtxPopoverContent');
47
+ class _MtxPopoverContentBase {
48
+ constructor(_template, _componentFactoryResolver, _appRef, _injector, _viewContainerRef, _document, _changeDetectorRef) {
49
+ this._template = _template;
50
+ this._componentFactoryResolver = _componentFactoryResolver;
51
+ this._appRef = _appRef;
52
+ this._injector = _injector;
53
+ this._viewContainerRef = _viewContainerRef;
54
+ this._document = _document;
55
+ this._changeDetectorRef = _changeDetectorRef;
56
+ /** Emits when the popover content has been attached. */
57
+ this._attached = new Subject();
58
+ }
59
+ /**
60
+ * Attaches the content with a particular context.
61
+ * @docs-private
62
+ */
63
+ attach(context = {}) {
64
+ if (!this._portal) {
65
+ this._portal = new TemplatePortal(this._template, this._viewContainerRef);
66
+ }
67
+ this.detach();
68
+ if (!this._outlet) {
69
+ this._outlet = new DomPortalOutlet(this._document.createElement('div'), this._componentFactoryResolver, this._appRef, this._injector);
70
+ }
71
+ const element = this._template.elementRef.nativeElement;
72
+ // Because we support opening the same popover from different triggers (which in turn have their
73
+ // own `OverlayRef` panel), we have to re-insert the host element every time, otherwise we
74
+ // risk it staying attached to a pane that's no longer in the DOM.
75
+ element.parentNode.insertBefore(this._outlet.outletElement, element);
76
+ // When `MtxPopoverContent` is used in an `OnPush` component, the insertion of the popover
77
+ // content via `createEmbeddedView` does not cause the content to be seen as "dirty"
78
+ // by Angular. This causes the `@ContentChildren` for popover items within the popover to
79
+ // not be updated by Angular. By explicitly marking for check here, we tell Angular that
80
+ // it needs to check for new popover items and update the `@ContentChild` in `MtxPopover`.
81
+ // @breaking-change 9.0.0 Make change detector ref required
82
+ if (this._changeDetectorRef) {
83
+ this._changeDetectorRef.markForCheck();
84
+ }
85
+ this._portal.attach(this._outlet, context);
86
+ this._attached.next();
87
+ }
88
+ /**
89
+ * Detaches the content.
90
+ * @docs-private
91
+ */
92
+ detach() {
93
+ if (this._portal.isAttached) {
94
+ this._portal.detach();
95
+ }
96
+ }
97
+ ngOnDestroy() {
98
+ if (this._outlet) {
99
+ this._outlet.dispose();
100
+ }
101
+ }
102
+ }
103
+ /** @nocollapse */ _MtxPopoverContentBase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: _MtxPopoverContentBase, deps: [{ token: i0.TemplateRef }, { token: i0.ComponentFactoryResolver }, { token: i0.ApplicationRef }, { token: i0.Injector }, { token: i0.ViewContainerRef }, { token: DOCUMENT }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
104
+ /** @nocollapse */ _MtxPopoverContentBase.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.6", type: _MtxPopoverContentBase, ngImport: i0 });
105
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: _MtxPopoverContentBase, decorators: [{
106
+ type: Directive
107
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.ComponentFactoryResolver }, { type: i0.ApplicationRef }, { type: i0.Injector }, { type: i0.ViewContainerRef }, { type: undefined, decorators: [{
108
+ type: Inject,
109
+ args: [DOCUMENT]
110
+ }] }, { type: i0.ChangeDetectorRef }]; } });
111
+ /**
112
+ * Popover content that will be rendered lazily once the popover is opened.
113
+ */
114
+ class MtxPopoverContent extends _MtxPopoverContentBase {
115
+ }
116
+ /** @nocollapse */ MtxPopoverContent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: MtxPopoverContent, deps: null, target: i0.ɵɵFactoryTarget.Directive });
117
+ /** @nocollapse */ MtxPopoverContent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.6", type: MtxPopoverContent, selector: "ng-template[mtxPopoverContent]", providers: [{ provide: MTX_POPOVER_CONTENT, useExisting: MtxPopoverContent }], usesInheritance: true, ngImport: i0 });
118
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: MtxPopoverContent, decorators: [{
119
+ type: Directive,
120
+ args: [{
121
+ selector: 'ng-template[mtxPopoverContent]',
122
+ providers: [{ provide: MTX_POPOVER_CONTENT, useExisting: MtxPopoverContent }],
123
+ }]
124
+ }] });
16
125
 
17
126
  /**
18
127
  * Throws an exception for the case when popover trigger doesn't have a valid mtx-popover instance
@@ -41,190 +150,182 @@ function throwMtxPopoverInvalidPositionEnd() {
41
150
  Example: <mtx-popover [position]="['below', 'after']" #popover="mtxPopover"></mtx-popover>`);
42
151
  }
43
152
 
44
- /**
45
- * Below are all the animations for the md-popover component.
46
- * Animation duration and timing values are based on AngularJS Material.
47
- */
48
- /**
49
- * This animation controls the popover panel's entry and exit from the page.
50
- *
51
- * When the popover panel is added to the DOM, it scales in and fades in its border.
52
- *
53
- * When the popover panel is removed from the DOM, it simply fades out after a brief
54
- * delay to display the ripple.
55
- */
56
- const transformPopover = trigger('transformPopover', [
57
- state('enter', style({
58
- opacity: 1,
59
- transform: `scale(1)`,
60
- })),
61
- transition('void => *', [
62
- style({
63
- opacity: 0,
64
- transform: `scale(0)`,
65
- }),
66
- animate(`200ms cubic-bezier(0.25, 0.8, 0.25, 1)`),
67
- ]),
68
- transition('* => void', [animate('50ms 100ms linear', style({ opacity: 0 }))]),
69
- ]);
70
-
153
+ /** Injection token to be used to override the default options for `mtx-popover`. */
154
+ const MTX_POPOVER_DEFAULT_OPTIONS = new InjectionToken('mtx-popover-default-options', {
155
+ providedIn: 'root',
156
+ factory: MTX_POPOVER_DEFAULT_OPTIONS_FACTORY,
157
+ });
158
+ /** @docs-private */
159
+ function MTX_POPOVER_DEFAULT_OPTIONS_FACTORY() {
160
+ return {
161
+ backdropClass: 'cdk-overlay-transparent-backdrop',
162
+ };
163
+ }
164
+ let popoverPanelUid = 0;
71
165
  class MtxPopover {
72
- constructor(_dir, _elementRef, zone) {
73
- this._dir = _dir;
166
+ constructor(_elementRef, _ngZone, _defaultOptions) {
74
167
  this._elementRef = _elementRef;
75
- this.zone = zone;
76
- this.role = 'dialog';
77
- /** Settings for popover, view setters and getters for more detail */
78
- this._position = ['below', 'after'];
79
- this._triggerEvent = 'hover';
80
- this._scrollStrategy = 'reposition';
81
- this._enterDelay = 100;
82
- this._leaveDelay = 100;
83
- this._panelOffsetX = 0;
84
- this._panelOffsetY = 0;
85
- this._closeOnPanelClick = false;
86
- this._closeOnBackdropClick = true;
87
- this._disableAnimation = false;
88
- this._focusTrapEnabled = true;
89
- this._focusTrapAutoCaptureEnabled = true;
90
- this._arrowOffsetX = 20;
91
- this._arrowOffsetY = 20;
92
- this._arrowWidth = 16;
93
- this._arrowHeight = 16;
94
- /** Config object to be passed into the popover's ngClass */
168
+ this._ngZone = _ngZone;
169
+ this._defaultOptions = _defaultOptions;
170
+ this._triggerEvent = this._defaultOptions.triggerEvent ?? 'hover';
171
+ this._enterDelay = this._defaultOptions.enterDelay ?? 100;
172
+ this._leaveDelay = this._defaultOptions.leaveDelay ?? 100;
173
+ this._position = this._defaultOptions.position ?? ['below', 'after'];
174
+ this._panelOffsetX = this._defaultOptions.xOffset ?? 0;
175
+ this._panelOffsetY = this._defaultOptions.yOffset ?? 0;
176
+ this._arrowWidth = this._defaultOptions.arrowWidth ?? 16;
177
+ this._arrowHeight = this._defaultOptions.arrowHeight ?? 16;
178
+ this._arrowOffsetX = this._defaultOptions.arrowOffsetX ?? 20;
179
+ this._arrowOffsetY = this._defaultOptions.arrowOffsetY ?? 20;
180
+ this._closeOnPanelClick = this._defaultOptions.closeOnPanelClick ?? false;
181
+ this._closeOnBackdropClick = this._defaultOptions.closeOnBackdropClick ?? true;
182
+ this._focusTrapEnabled = this._defaultOptions.focusTrapEnabled ?? false;
183
+ this._focusTrapAutoCaptureEnabled = this._defaultOptions.focusTrapAutoCaptureEnabled ?? false;
184
+ this._hasBackdrop = this._defaultOptions.hasBackdrop;
185
+ this._elevation = this._defaultOptions.elevation ?? 8;
186
+ this._elevationPrefix = 'mat-elevation-z';
187
+ /** Config object to be passed into the popover's ngClass. */
95
188
  this._classList = {};
96
- /** Whether popover's `targetElement` is defined */
97
- this.containerPositioning = false;
189
+ /** Current state of the panel animation. */
190
+ this._panelAnimationState = 'void';
191
+ /** Emits whenever an animation on the popover completes. */
192
+ this._animationDone = new Subject();
193
+ /** Whether the popover is animating. */
194
+ this._isAnimating = false;
98
195
  /** Closing disabled on popover */
99
196
  this.closeDisabled = false;
100
- /** Emits the current animation state whenever it changes. */
101
- this._onAnimationStateChange = new EventEmitter();
197
+ /** Config object to be passed into the popover's arrow ngStyle */
198
+ this.arrowStyles = null;
199
+ /** Class or list of classes to be added to the overlay panel. */
200
+ this.overlayPanelClass = this._defaultOptions.overlayPanelClass || '';
201
+ /** Class to be added to the backdrop element. */
202
+ this.backdropClass = this._defaultOptions.backdropClass;
102
203
  /** Event emitted when the popover is closed. */
103
204
  this.closed = new EventEmitter();
104
- this.setPositionClasses();
105
- }
106
- /** Position of the popover. */
107
- get position() {
108
- return this._position;
109
- }
110
- set position(value) {
111
- if (!['before', 'after', 'above', 'below'].includes(value[0])) {
112
- throwMtxPopoverInvalidPositionStart();
113
- }
114
- if (!['before', 'after', 'above', 'below', 'center'].includes(value[1])) {
115
- throwMtxPopoverInvalidPositionEnd();
116
- }
117
- this._position = value;
118
- this.setPositionClasses();
205
+ this.panelId = `mtx-popover-panel-${popoverPanelUid++}`;
119
206
  }
120
- /** Popover trigger event */
207
+ /** Popover's trigger event. */
121
208
  get triggerEvent() {
122
209
  return this._triggerEvent;
123
210
  }
124
211
  set triggerEvent(value) {
125
212
  this._triggerEvent = value;
126
213
  }
127
- /** Popover scroll strategy */
128
- get scrollStrategy() {
129
- return this._scrollStrategy;
130
- }
131
- set scrollStrategy(value) {
132
- this._scrollStrategy = value;
133
- }
134
- /** Popover enter delay */
214
+ /** Popover's enter delay. */
135
215
  get enterDelay() {
136
216
  return this._enterDelay;
137
217
  }
138
218
  set enterDelay(value) {
139
219
  this._enterDelay = value;
140
220
  }
141
- /** Popover leave delay */
221
+ /** Popover's leave delay. */
142
222
  get leaveDelay() {
143
223
  return this._leaveDelay;
144
224
  }
145
225
  set leaveDelay(value) {
146
226
  this._leaveDelay = value;
147
227
  }
148
- /** Popover target offset x */
228
+ /** Popover's position. */
229
+ get position() {
230
+ return this._position;
231
+ }
232
+ set position(value) {
233
+ if (!['before', 'after', 'above', 'below'].includes(value[0])) {
234
+ throwMtxPopoverInvalidPositionStart();
235
+ }
236
+ if (!['before', 'after', 'above', 'below', 'center'].includes(value[1])) {
237
+ throwMtxPopoverInvalidPositionEnd();
238
+ }
239
+ this._position = value;
240
+ this.setPositionClasses();
241
+ }
242
+ /** Popover-panel's X offset. */
149
243
  get xOffset() {
150
244
  return this._panelOffsetX;
151
245
  }
152
246
  set xOffset(value) {
153
247
  this._panelOffsetX = value;
154
248
  }
155
- /** Popover target offset y */
249
+ /** Popover-panel's Y offset. */
156
250
  get yOffset() {
157
251
  return this._panelOffsetY;
158
252
  }
159
253
  set yOffset(value) {
160
254
  this._panelOffsetY = value;
161
255
  }
162
- /** Popover arrow offset x */
163
- get arrowOffsetX() {
164
- return this._arrowOffsetX;
165
- }
166
- set arrowOffsetX(value) {
167
- this._arrowOffsetX = value;
168
- }
169
- /** Popover arrow offset y */
170
- get arrowOffsetY() {
171
- return this._arrowOffsetY;
172
- }
173
- set arrowOffsetY(value) {
174
- this._arrowOffsetY = value;
175
- }
176
- /** Popover arrow width */
256
+ /** Popover-arrow's width. */
177
257
  get arrowWidth() {
178
258
  return this._arrowWidth;
179
259
  }
180
260
  set arrowWidth(value) {
181
261
  this._arrowWidth = value;
182
262
  }
183
- /** Popover arrow height */
263
+ /** Popover-arrow's height. */
184
264
  get arrowHeight() {
185
265
  return this._arrowHeight;
186
266
  }
187
267
  set arrowHeight(value) {
188
268
  this._arrowHeight = value;
189
269
  }
190
- /** Popover close on container click */
270
+ /** Popover-arrow's X offset. */
271
+ get arrowOffsetX() {
272
+ return this._arrowOffsetX;
273
+ }
274
+ set arrowOffsetX(value) {
275
+ this._arrowOffsetX = value;
276
+ }
277
+ /** Popover-arrow's Y offset. */
278
+ get arrowOffsetY() {
279
+ return this._arrowOffsetY;
280
+ }
281
+ set arrowOffsetY(value) {
282
+ this._arrowOffsetY = value;
283
+ }
284
+ /** Whether popover can be closed when click the popover-panel. */
191
285
  get closeOnPanelClick() {
192
286
  return this._closeOnPanelClick;
193
287
  }
194
288
  set closeOnPanelClick(value) {
195
289
  this._closeOnPanelClick = coerceBooleanProperty(value);
196
290
  }
197
- /** Popover close on backdrop click */
291
+ /** Whether popover can be closed when click the backdrop. */
198
292
  get closeOnBackdropClick() {
199
293
  return this._closeOnBackdropClick;
200
294
  }
201
295
  set closeOnBackdropClick(value) {
202
296
  this._closeOnBackdropClick = coerceBooleanProperty(value);
203
297
  }
204
- /** Disable animations of popover and all child elements */
205
- get disableAnimation() {
206
- return this._disableAnimation;
207
- }
208
- set disableAnimation(value) {
209
- this._disableAnimation = coerceBooleanProperty(value);
210
- }
211
- /** Popover focus trap using cdkTrapFocus */
298
+ /** Whether enable focus trap using `cdkTrapFocus`. */
212
299
  get focusTrapEnabled() {
213
300
  return this._focusTrapEnabled;
214
301
  }
215
302
  set focusTrapEnabled(value) {
216
303
  this._focusTrapEnabled = coerceBooleanProperty(value);
217
304
  }
218
- /** Popover focus trap auto capture using cdkTrapFocusAutoCapture */
305
+ /** Whether enable focus trap auto capture using `cdkTrapFocusAutoCapture`. */
219
306
  get focusTrapAutoCaptureEnabled() {
220
307
  return this._focusTrapAutoCaptureEnabled;
221
308
  }
222
309
  set focusTrapAutoCaptureEnabled(value) {
223
310
  this._focusTrapAutoCaptureEnabled = coerceBooleanProperty(value);
224
311
  }
312
+ /** Whether the popover has a backdrop. It will always be false if the trigger event is hover. */
313
+ get hasBackdrop() {
314
+ return this._hasBackdrop;
315
+ }
316
+ set hasBackdrop(value) {
317
+ this._hasBackdrop = coerceBooleanProperty(value);
318
+ }
319
+ /** Popover-panel's elevation (0~24). */
320
+ get elevation() {
321
+ return Math.max(0, Math.min(Math.round(this._elevation), 24));
322
+ }
323
+ set elevation(value) {
324
+ this._elevation = value;
325
+ }
225
326
  /**
226
327
  * This method takes classes set on the host md-popover element and applies them on the
227
- * popover template that displays in the overlay container. Otherwise, it's difficult
328
+ * popover template that displays in the overlay container. Otherwise, it's difficult
228
329
  * to style the containing popover from outside the component.
229
330
  * @param classes list of class names
230
331
  */
@@ -240,7 +341,7 @@ class MtxPopover {
240
341
  }
241
342
  /**
242
343
  * This method takes classes set on the host md-popover element and applies them on the
243
- * popover template that displays in the overlay container. Otherwise, it's difficult
344
+ * popover template that displays in the overlay container. Otherwise, it's difficult
244
345
  * to style the containing popover from outside the component.
245
346
  * @deprecated Use `panelClass` instead.
246
347
  * @breaking-change 8.0.0
@@ -251,47 +352,46 @@ class MtxPopover {
251
352
  set classList(classes) {
252
353
  this.panelClass = classes;
253
354
  }
355
+ ngOnInit() {
356
+ this.setPositionClasses();
357
+ }
254
358
  ngOnDestroy() {
255
- this._emitCloseEvent();
256
359
  this.closed.complete();
257
360
  }
258
361
  /** Handle a keyboard event from the popover, delegating to the appropriate action. */
259
362
  _handleKeydown(event) {
260
- switch (event.keyCode) {
363
+ const keyCode = event.keyCode;
364
+ switch (keyCode) {
261
365
  case ESCAPE:
262
- this._emitCloseEvent();
263
- return;
366
+ if (!hasModifierKey(event)) {
367
+ event.preventDefault();
368
+ this.closed.emit('keydown');
369
+ }
370
+ break;
264
371
  }
265
372
  }
266
- /**
267
- * This emits a close event to which the trigger is subscribed. When emitted, the
268
- * trigger will close the popover.
269
- */
270
- _emitCloseEvent() {
271
- this.closed.emit();
272
- }
273
- /** Close popover on click if closeOnPanelClick is true */
274
- onClick() {
373
+ /** Close popover on click if `closeOnPanelClick` is true. */
374
+ _handleClick() {
275
375
  if (this.closeOnPanelClick) {
276
- this._emitCloseEvent();
376
+ this.closed.emit('click');
277
377
  }
278
378
  }
279
- /** Disables close of popover when leaving trigger element and mouse over the popover */
280
- onMouseOver() {
379
+ /** Disables close of popover when leaving trigger element and mouse over the popover. */
380
+ _handleMouseOver() {
281
381
  if (this.triggerEvent === 'hover') {
282
382
  this.closeDisabled = true;
283
383
  }
284
384
  }
285
- /** Enables close of popover when mouse leaving popover element */
286
- onMouseLeave() {
385
+ /** Enables close of popover when mouse leaving popover element. */
386
+ _handleMouseLeave() {
287
387
  if (this.triggerEvent === 'hover') {
288
388
  setTimeout(() => {
289
389
  this.closeDisabled = false;
290
- this._emitCloseEvent();
390
+ this.closed.emit();
291
391
  }, this.leaveDelay);
292
392
  }
293
393
  }
294
- /** Sets the current styles for the popover to allow for dynamically changing settings */
394
+ /** Sets the current styles for the popover to allow for dynamically changing settings. */
295
395
  setCurrentStyles(pos = this.position) {
296
396
  const left = pos[1] === 'after'
297
397
  ? `${this.arrowOffsetX - this.arrowWidth / 2}px`
@@ -305,16 +405,13 @@ class MtxPopover {
305
405
  ? `calc(50% - ${this.arrowHeight / 2}px)`
306
406
  : '';
307
407
  const top = pos[1] === 'below' ? `${this.arrowOffsetY - this.arrowHeight / 2}px` : '';
308
- this.popoverArrowStyles =
408
+ this.arrowStyles =
309
409
  pos[0] === 'above' || pos[0] === 'below'
310
410
  ? {
311
- left: this._dir.value === 'ltr' ? left : right,
312
- right: this._dir.value === 'ltr' ? right : left,
411
+ left: this.direction === 'ltr' ? left : right,
412
+ right: this.direction === 'ltr' ? right : left,
313
413
  }
314
- : {
315
- top,
316
- bottom,
317
- };
414
+ : { top, bottom };
318
415
  }
319
416
  /**
320
417
  * It's necessary to set position-based classes to ensure the popover panel animation
@@ -334,49 +431,85 @@ class MtxPopover {
334
431
  this._classList['mtx-popover-below-center'] = pos[0] === 'below' && pos[1] === 'center';
335
432
  this._classList['mtx-popover-below-after'] = pos[0] === 'below' && pos[1] === 'after';
336
433
  }
434
+ /** Sets the popover-panel's elevation. */
435
+ setElevation() {
436
+ const newElevation = `${this._elevationPrefix}${this.elevation}`;
437
+ if (this._previousElevation) {
438
+ this._classList[this._previousElevation] = false;
439
+ }
440
+ this._classList[newElevation] = true;
441
+ this._previousElevation = newElevation;
442
+ }
443
+ /** Starts the enter animation. */
444
+ _startAnimation() {
445
+ // @breaking-change 8.0.0 Combine with _resetAnimation.
446
+ this._panelAnimationState = 'enter';
447
+ }
448
+ /** Resets the panel animation to its initial state. */
449
+ _resetAnimation() {
450
+ // @breaking-change 8.0.0 Combine with _startAnimation.
451
+ this._panelAnimationState = 'void';
452
+ }
453
+ /** Callback that is invoked when the panel animation completes. */
454
+ _onAnimationDone(event) {
455
+ this._animationDone.next(event);
456
+ this._isAnimating = false;
457
+ }
458
+ _onAnimationStart(event) {
459
+ this._isAnimating = true;
460
+ }
337
461
  }
338
- /** @nocollapse */ MtxPopover.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: MtxPopover, deps: [{ token: i1.Directionality, optional: true }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
339
- /** @nocollapse */ MtxPopover.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.6", type: MtxPopover, selector: "mtx-popover", inputs: { position: "position", triggerEvent: "triggerEvent", scrollStrategy: "scrollStrategy", enterDelay: "enterDelay", leaveDelay: "leaveDelay", xOffset: "xOffset", yOffset: "yOffset", arrowOffsetX: "arrowOffsetX", arrowOffsetY: "arrowOffsetY", arrowWidth: "arrowWidth", arrowHeight: "arrowHeight", closeOnPanelClick: "closeOnPanelClick", closeOnBackdropClick: "closeOnBackdropClick", disableAnimation: "disableAnimation", focusTrapEnabled: "focusTrapEnabled", focusTrapAutoCaptureEnabled: "focusTrapAutoCaptureEnabled", panelClass: ["class", "panelClass"], classList: "classList" }, outputs: { closed: "closed" }, host: { properties: { "attr.role": "this.role" } }, viewQueries: [{ propertyName: "templateRef", first: true, predicate: TemplateRef, descendants: true }], exportAs: ["mtxPopover"], ngImport: i0, template: "<ng-template>\r\n <div class=\"mtx-popover-panel mat-elevation-z8\" role=\"dialog\"\r\n [ngClass]=\"_classList\"\r\n [ngStyle]=\"popoverPanelStyles\"\r\n (keydown)=\"_handleKeydown($event)\"\r\n (click)=\"onClick()\"\r\n (mouseover)=\"onMouseOver()\"\r\n (mouseleave)=\"onMouseLeave()\"\r\n [@.disabled]=\"disableAnimation\"\r\n [@transformPopover]=\"'enter'\">\r\n <div class=\"mtx-popover-direction-arrow\" [ngStyle]=\"popoverArrowStyles\"></div>\r\n <div class=\"mtx-popover-content\"\r\n [ngStyle]=\"popoverContentStyles\"\r\n [cdkTrapFocus]=\"focusTrapEnabled\"\r\n [cdkTrapFocusAutoCapture]=\"focusTrapAutoCaptureEnabled\">\r\n <ng-content></ng-content>\r\n </div>\r\n </div>\r\n</ng-template>\r\n", styles: [".mtx-popover-panel{max-height:calc(100vh - 48px);padding:8px;border-radius:4px;font-size:16px}.mtx-popover-panel[class*=mtx-popover-below]{margin-top:calc(.5em + 2px)}.mtx-popover-panel[class*=mtx-popover-above]{margin-bottom:calc(.5em + 2px)}.mtx-popover-panel[class*=mtx-popover-before]{margin-right:calc(.5em + 2px)}[dir=rtl] .mtx-popover-panel[class*=mtx-popover-before]{margin-right:auto;margin-left:calc(.5em + 2px)}.mtx-popover-panel[class*=mtx-popover-after]{margin-left:calc(.5em + 2px)}[dir=rtl] .mtx-popover-panel[class*=mtx-popover-after]{margin-left:auto;margin-right:calc(.5em + 2px)}.mtx-popover-direction-arrow{position:absolute}.mtx-popover-direction-arrow:before,.mtx-popover-direction-arrow:after{position:absolute;display:inline-block;content:\"\";border-width:.5em;border-style:solid}.mtx-popover-direction-arrow:after{border-width:calc(.5em - 1px)}[class*=mtx-popover-below] .mtx-popover-direction-arrow,[class*=mtx-popover-above] .mtx-popover-direction-arrow{width:1em}[class*=mtx-popover-below] .mtx-popover-direction-arrow:after,[class*=mtx-popover-above] .mtx-popover-direction-arrow:after{left:1px}[dir=rtl] [class*=mtx-popover-below] .mtx-popover-direction-arrow:after,[dir=rtl] [class*=mtx-popover-above] .mtx-popover-direction-arrow:after{right:1px;left:auto}[class*=mtx-popover-below] .mtx-popover-direction-arrow{top:0}[class*=mtx-popover-below] .mtx-popover-direction-arrow:before,[class*=mtx-popover-below] .mtx-popover-direction-arrow:after{bottom:0;border-top-width:0}[class*=mtx-popover-above] .mtx-popover-direction-arrow{bottom:0}[class*=mtx-popover-above] .mtx-popover-direction-arrow:before,[class*=mtx-popover-above] .mtx-popover-direction-arrow:after{top:0;border-bottom-width:0}[class*=mtx-popover-before] .mtx-popover-direction-arrow,[class*=mtx-popover-after] .mtx-popover-direction-arrow{height:1em}[class*=mtx-popover-before] .mtx-popover-direction-arrow:after,[class*=mtx-popover-after] .mtx-popover-direction-arrow:after{top:1px}[class*=mtx-popover-before] .mtx-popover-direction-arrow{right:0}[class*=mtx-popover-before] .mtx-popover-direction-arrow:before,[class*=mtx-popover-before] .mtx-popover-direction-arrow:after{left:0;border-right-width:0}[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow{right:auto;left:0}[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow:before,[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow:after{left:auto;right:0;border-left-width:0}[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow:before{border-right-width:.5em}[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow:after{border-right-width:calc(.5em - 1px)}[class*=mtx-popover-after] .mtx-popover-direction-arrow{left:0}[class*=mtx-popover-after] .mtx-popover-direction-arrow:before,[class*=mtx-popover-after] .mtx-popover-direction-arrow:after{right:0;border-left-width:0}[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow{left:auto;right:0}[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow:before,[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow:after{right:auto;left:0;border-right-width:0}[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow:before{border-left-width:.5em}[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow:after{border-left-width:calc(.5em - 1px)}\n"], directives: [{ type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i3.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }], animations: [transformPopover], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
462
+ /** @nocollapse */ MtxPopover.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: MtxPopover, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: MTX_POPOVER_DEFAULT_OPTIONS }], target: i0.ɵɵFactoryTarget.Component });
463
+ /** @nocollapse */ MtxPopover.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.6", type: MtxPopover, selector: "mtx-popover", inputs: { backdropClass: "backdropClass", ariaLabel: ["aria-label", "ariaLabel"], ariaLabelledby: ["aria-labelledby", "ariaLabelledby"], ariaDescribedby: ["aria-describedby", "ariaDescribedby"], triggerEvent: "triggerEvent", enterDelay: "enterDelay", leaveDelay: "leaveDelay", position: "position", xOffset: "xOffset", yOffset: "yOffset", arrowWidth: "arrowWidth", arrowHeight: "arrowHeight", arrowOffsetX: "arrowOffsetX", arrowOffsetY: "arrowOffsetY", closeOnPanelClick: "closeOnPanelClick", closeOnBackdropClick: "closeOnBackdropClick", focusTrapEnabled: "focusTrapEnabled", focusTrapAutoCaptureEnabled: "focusTrapAutoCaptureEnabled", hasBackdrop: "hasBackdrop", elevation: "elevation", panelClass: ["class", "panelClass"], classList: "classList" }, outputs: { closed: "closed" }, queries: [{ propertyName: "lazyContent", first: true, predicate: MTX_POPOVER_CONTENT, descendants: true }], viewQueries: [{ propertyName: "templateRef", first: true, predicate: TemplateRef, descendants: true }], exportAs: ["mtxPopover"], ngImport: i0, template: "<ng-template>\r\n <div class=\"mtx-popover-panel\"\r\n [id]=\"panelId\"\r\n [ngClass]=\"_classList\"\r\n (keydown)=\"_handleKeydown($event)\"\r\n (click)=\"_handleClick()\"\r\n (mouseover)=\"_handleMouseOver()\"\r\n (mouseleave)=\"_handleMouseLeave()\"\r\n [@transformPopover]=\"_panelAnimationState\"\r\n (@transformPopover.start)=\"_onAnimationStart($event)\"\r\n (@transformPopover.done)=\"_onAnimationDone($event)\"\r\n tabindex=\"-1\"\r\n role=\"dialog\"\r\n [attr.aria-label]=\"ariaLabel || null\"\r\n [attr.aria-labelledby]=\"ariaLabelledby || null\"\r\n [attr.aria-describedby]=\"ariaDescribedby || null\"\r\n [cdkTrapFocus]=\"focusTrapEnabled\"\r\n [cdkTrapFocusAutoCapture]=\"focusTrapAutoCaptureEnabled\">\r\n <div class=\"mtx-popover-content\">\r\n <ng-content></ng-content>\r\n </div>\r\n <div class=\"mtx-popover-direction-arrow\" [ngStyle]=\"arrowStyles\"></div>\r\n </div>\r\n</ng-template>\r\n", styles: [".mtx-popover-panel{position:relative;max-height:calc(100vh - 48px);padding:8px;border-radius:4px;font-size:16px;outline:0}.mtx-popover-panel[class*=mtx-popover-below]{margin-top:calc(.5em + 2px)}.mtx-popover-panel[class*=mtx-popover-above]{margin-bottom:calc(.5em + 2px)}.mtx-popover-panel[class*=mtx-popover-before]{margin-right:calc(.5em + 2px)}[dir=rtl] .mtx-popover-panel[class*=mtx-popover-before]{margin-right:auto;margin-left:calc(.5em + 2px)}.mtx-popover-panel[class*=mtx-popover-after]{margin-left:calc(.5em + 2px)}[dir=rtl] .mtx-popover-panel[class*=mtx-popover-after]{margin-left:auto;margin-right:calc(.5em + 2px)}.mtx-popover-direction-arrow{position:absolute}.mtx-popover-direction-arrow:before,.mtx-popover-direction-arrow:after{position:absolute;display:inline-block;content:\"\";border-width:.5em;border-style:solid}.mtx-popover-direction-arrow:after{border-width:calc(.5em - 1px)}[class*=mtx-popover-below] .mtx-popover-direction-arrow,[class*=mtx-popover-above] .mtx-popover-direction-arrow{width:1em}[class*=mtx-popover-below] .mtx-popover-direction-arrow:after,[class*=mtx-popover-above] .mtx-popover-direction-arrow:after{left:1px}[dir=rtl] [class*=mtx-popover-below] .mtx-popover-direction-arrow:after,[dir=rtl] [class*=mtx-popover-above] .mtx-popover-direction-arrow:after{right:1px;left:auto}[class*=mtx-popover-below] .mtx-popover-direction-arrow{top:0}[class*=mtx-popover-below] .mtx-popover-direction-arrow:before,[class*=mtx-popover-below] .mtx-popover-direction-arrow:after{bottom:0;border-top-width:0}[class*=mtx-popover-above] .mtx-popover-direction-arrow{bottom:0}[class*=mtx-popover-above] .mtx-popover-direction-arrow:before,[class*=mtx-popover-above] .mtx-popover-direction-arrow:after{top:0;border-bottom-width:0}[class*=mtx-popover-before] .mtx-popover-direction-arrow,[class*=mtx-popover-after] .mtx-popover-direction-arrow{height:1em}[class*=mtx-popover-before] .mtx-popover-direction-arrow:after,[class*=mtx-popover-after] .mtx-popover-direction-arrow:after{top:1px}[class*=mtx-popover-before] .mtx-popover-direction-arrow{right:0}[class*=mtx-popover-before] .mtx-popover-direction-arrow:before,[class*=mtx-popover-before] .mtx-popover-direction-arrow:after{left:0;border-right-width:0}[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow{right:auto;left:0}[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow:before,[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow:after{left:auto;right:0;border-left-width:0}[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow:before{border-right-width:.5em}[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow:after{border-right-width:calc(.5em - 1px)}[class*=mtx-popover-after] .mtx-popover-direction-arrow{left:0}[class*=mtx-popover-after] .mtx-popover-direction-arrow:before,[class*=mtx-popover-after] .mtx-popover-direction-arrow:after{right:0;border-left-width:0}[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow{left:auto;right:0}[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow:before,[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow:after{right:auto;left:0;border-right-width:0}[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow:before{border-left-width:.5em}[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow:after{border-left-width:calc(.5em - 1px)}\n"], directives: [{ type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }, { type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], animations: [transformPopover], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
340
464
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: MtxPopover, decorators: [{
341
465
  type: Component,
342
- args: [{ selector: 'mtx-popover', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, animations: [transformPopover], exportAs: 'mtxPopover', template: "<ng-template>\r\n <div class=\"mtx-popover-panel mat-elevation-z8\" role=\"dialog\"\r\n [ngClass]=\"_classList\"\r\n [ngStyle]=\"popoverPanelStyles\"\r\n (keydown)=\"_handleKeydown($event)\"\r\n (click)=\"onClick()\"\r\n (mouseover)=\"onMouseOver()\"\r\n (mouseleave)=\"onMouseLeave()\"\r\n [@.disabled]=\"disableAnimation\"\r\n [@transformPopover]=\"'enter'\">\r\n <div class=\"mtx-popover-direction-arrow\" [ngStyle]=\"popoverArrowStyles\"></div>\r\n <div class=\"mtx-popover-content\"\r\n [ngStyle]=\"popoverContentStyles\"\r\n [cdkTrapFocus]=\"focusTrapEnabled\"\r\n [cdkTrapFocusAutoCapture]=\"focusTrapAutoCaptureEnabled\">\r\n <ng-content></ng-content>\r\n </div>\r\n </div>\r\n</ng-template>\r\n", styles: [".mtx-popover-panel{max-height:calc(100vh - 48px);padding:8px;border-radius:4px;font-size:16px}.mtx-popover-panel[class*=mtx-popover-below]{margin-top:calc(.5em + 2px)}.mtx-popover-panel[class*=mtx-popover-above]{margin-bottom:calc(.5em + 2px)}.mtx-popover-panel[class*=mtx-popover-before]{margin-right:calc(.5em + 2px)}[dir=rtl] .mtx-popover-panel[class*=mtx-popover-before]{margin-right:auto;margin-left:calc(.5em + 2px)}.mtx-popover-panel[class*=mtx-popover-after]{margin-left:calc(.5em + 2px)}[dir=rtl] .mtx-popover-panel[class*=mtx-popover-after]{margin-left:auto;margin-right:calc(.5em + 2px)}.mtx-popover-direction-arrow{position:absolute}.mtx-popover-direction-arrow:before,.mtx-popover-direction-arrow:after{position:absolute;display:inline-block;content:\"\";border-width:.5em;border-style:solid}.mtx-popover-direction-arrow:after{border-width:calc(.5em - 1px)}[class*=mtx-popover-below] .mtx-popover-direction-arrow,[class*=mtx-popover-above] .mtx-popover-direction-arrow{width:1em}[class*=mtx-popover-below] .mtx-popover-direction-arrow:after,[class*=mtx-popover-above] .mtx-popover-direction-arrow:after{left:1px}[dir=rtl] [class*=mtx-popover-below] .mtx-popover-direction-arrow:after,[dir=rtl] [class*=mtx-popover-above] .mtx-popover-direction-arrow:after{right:1px;left:auto}[class*=mtx-popover-below] .mtx-popover-direction-arrow{top:0}[class*=mtx-popover-below] .mtx-popover-direction-arrow:before,[class*=mtx-popover-below] .mtx-popover-direction-arrow:after{bottom:0;border-top-width:0}[class*=mtx-popover-above] .mtx-popover-direction-arrow{bottom:0}[class*=mtx-popover-above] .mtx-popover-direction-arrow:before,[class*=mtx-popover-above] .mtx-popover-direction-arrow:after{top:0;border-bottom-width:0}[class*=mtx-popover-before] .mtx-popover-direction-arrow,[class*=mtx-popover-after] .mtx-popover-direction-arrow{height:1em}[class*=mtx-popover-before] .mtx-popover-direction-arrow:after,[class*=mtx-popover-after] .mtx-popover-direction-arrow:after{top:1px}[class*=mtx-popover-before] .mtx-popover-direction-arrow{right:0}[class*=mtx-popover-before] .mtx-popover-direction-arrow:before,[class*=mtx-popover-before] .mtx-popover-direction-arrow:after{left:0;border-right-width:0}[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow{right:auto;left:0}[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow:before,[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow:after{left:auto;right:0;border-left-width:0}[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow:before{border-right-width:.5em}[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow:after{border-right-width:calc(.5em - 1px)}[class*=mtx-popover-after] .mtx-popover-direction-arrow{left:0}[class*=mtx-popover-after] .mtx-popover-direction-arrow:before,[class*=mtx-popover-after] .mtx-popover-direction-arrow:after{right:0;border-left-width:0}[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow{left:auto;right:0}[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow:before,[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow:after{right:auto;left:0;border-right-width:0}[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow:before{border-left-width:.5em}[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow:after{border-left-width:calc(.5em - 1px)}\n"] }]
343
- }], ctorParameters: function () { return [{ type: i1.Directionality, decorators: [{
344
- type: Optional
345
- }] }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { role: [{
346
- type: HostBinding,
347
- args: ['attr.role']
348
- }], position: [{
466
+ args: [{ selector: 'mtx-popover', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, animations: [transformPopover], exportAs: 'mtxPopover', template: "<ng-template>\r\n <div class=\"mtx-popover-panel\"\r\n [id]=\"panelId\"\r\n [ngClass]=\"_classList\"\r\n (keydown)=\"_handleKeydown($event)\"\r\n (click)=\"_handleClick()\"\r\n (mouseover)=\"_handleMouseOver()\"\r\n (mouseleave)=\"_handleMouseLeave()\"\r\n [@transformPopover]=\"_panelAnimationState\"\r\n (@transformPopover.start)=\"_onAnimationStart($event)\"\r\n (@transformPopover.done)=\"_onAnimationDone($event)\"\r\n tabindex=\"-1\"\r\n role=\"dialog\"\r\n [attr.aria-label]=\"ariaLabel || null\"\r\n [attr.aria-labelledby]=\"ariaLabelledby || null\"\r\n [attr.aria-describedby]=\"ariaDescribedby || null\"\r\n [cdkTrapFocus]=\"focusTrapEnabled\"\r\n [cdkTrapFocusAutoCapture]=\"focusTrapAutoCaptureEnabled\">\r\n <div class=\"mtx-popover-content\">\r\n <ng-content></ng-content>\r\n </div>\r\n <div class=\"mtx-popover-direction-arrow\" [ngStyle]=\"arrowStyles\"></div>\r\n </div>\r\n</ng-template>\r\n", styles: [".mtx-popover-panel{position:relative;max-height:calc(100vh - 48px);padding:8px;border-radius:4px;font-size:16px;outline:0}.mtx-popover-panel[class*=mtx-popover-below]{margin-top:calc(.5em + 2px)}.mtx-popover-panel[class*=mtx-popover-above]{margin-bottom:calc(.5em + 2px)}.mtx-popover-panel[class*=mtx-popover-before]{margin-right:calc(.5em + 2px)}[dir=rtl] .mtx-popover-panel[class*=mtx-popover-before]{margin-right:auto;margin-left:calc(.5em + 2px)}.mtx-popover-panel[class*=mtx-popover-after]{margin-left:calc(.5em + 2px)}[dir=rtl] .mtx-popover-panel[class*=mtx-popover-after]{margin-left:auto;margin-right:calc(.5em + 2px)}.mtx-popover-direction-arrow{position:absolute}.mtx-popover-direction-arrow:before,.mtx-popover-direction-arrow:after{position:absolute;display:inline-block;content:\"\";border-width:.5em;border-style:solid}.mtx-popover-direction-arrow:after{border-width:calc(.5em - 1px)}[class*=mtx-popover-below] .mtx-popover-direction-arrow,[class*=mtx-popover-above] .mtx-popover-direction-arrow{width:1em}[class*=mtx-popover-below] .mtx-popover-direction-arrow:after,[class*=mtx-popover-above] .mtx-popover-direction-arrow:after{left:1px}[dir=rtl] [class*=mtx-popover-below] .mtx-popover-direction-arrow:after,[dir=rtl] [class*=mtx-popover-above] .mtx-popover-direction-arrow:after{right:1px;left:auto}[class*=mtx-popover-below] .mtx-popover-direction-arrow{top:0}[class*=mtx-popover-below] .mtx-popover-direction-arrow:before,[class*=mtx-popover-below] .mtx-popover-direction-arrow:after{bottom:0;border-top-width:0}[class*=mtx-popover-above] .mtx-popover-direction-arrow{bottom:0}[class*=mtx-popover-above] .mtx-popover-direction-arrow:before,[class*=mtx-popover-above] .mtx-popover-direction-arrow:after{top:0;border-bottom-width:0}[class*=mtx-popover-before] .mtx-popover-direction-arrow,[class*=mtx-popover-after] .mtx-popover-direction-arrow{height:1em}[class*=mtx-popover-before] .mtx-popover-direction-arrow:after,[class*=mtx-popover-after] .mtx-popover-direction-arrow:after{top:1px}[class*=mtx-popover-before] .mtx-popover-direction-arrow{right:0}[class*=mtx-popover-before] .mtx-popover-direction-arrow:before,[class*=mtx-popover-before] .mtx-popover-direction-arrow:after{left:0;border-right-width:0}[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow{right:auto;left:0}[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow:before,[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow:after{left:auto;right:0;border-left-width:0}[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow:before{border-right-width:.5em}[dir=rtl] [class*=mtx-popover-before] .mtx-popover-direction-arrow:after{border-right-width:calc(.5em - 1px)}[class*=mtx-popover-after] .mtx-popover-direction-arrow{left:0}[class*=mtx-popover-after] .mtx-popover-direction-arrow:before,[class*=mtx-popover-after] .mtx-popover-direction-arrow:after{right:0;border-left-width:0}[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow{left:auto;right:0}[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow:before,[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow:after{right:auto;left:0;border-right-width:0}[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow:before{border-left-width:.5em}[dir=rtl] [class*=mtx-popover-after] .mtx-popover-direction-arrow:after{border-left-width:calc(.5em - 1px)}\n"] }]
467
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: undefined, decorators: [{
468
+ type: Inject,
469
+ args: [MTX_POPOVER_DEFAULT_OPTIONS]
470
+ }] }]; }, propDecorators: { backdropClass: [{
349
471
  type: Input
472
+ }], ariaLabel: [{
473
+ type: Input,
474
+ args: ['aria-label']
475
+ }], ariaLabelledby: [{
476
+ type: Input,
477
+ args: ['aria-labelledby']
478
+ }], ariaDescribedby: [{
479
+ type: Input,
480
+ args: ['aria-describedby']
350
481
  }], triggerEvent: [{
351
482
  type: Input
352
- }], scrollStrategy: [{
353
- type: Input
354
483
  }], enterDelay: [{
355
484
  type: Input
356
485
  }], leaveDelay: [{
357
486
  type: Input
487
+ }], position: [{
488
+ type: Input
358
489
  }], xOffset: [{
359
490
  type: Input
360
491
  }], yOffset: [{
361
492
  type: Input
362
- }], arrowOffsetX: [{
363
- type: Input
364
- }], arrowOffsetY: [{
365
- type: Input
366
493
  }], arrowWidth: [{
367
494
  type: Input
368
495
  }], arrowHeight: [{
369
496
  type: Input
497
+ }], arrowOffsetX: [{
498
+ type: Input
499
+ }], arrowOffsetY: [{
500
+ type: Input
370
501
  }], closeOnPanelClick: [{
371
502
  type: Input
372
503
  }], closeOnBackdropClick: [{
373
504
  type: Input
374
- }], disableAnimation: [{
375
- type: Input
376
505
  }], focusTrapEnabled: [{
377
506
  type: Input
378
507
  }], focusTrapAutoCaptureEnabled: [{
379
508
  type: Input
509
+ }], hasBackdrop: [{
510
+ type: Input
511
+ }], elevation: [{
512
+ type: Input
380
513
  }], panelClass: [{
381
514
  type: Input,
382
515
  args: ['class']
@@ -387,41 +520,78 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImpor
387
520
  }], templateRef: [{
388
521
  type: ViewChild,
389
522
  args: [TemplateRef]
523
+ }], lazyContent: [{
524
+ type: ContentChild,
525
+ args: [MTX_POPOVER_CONTENT]
390
526
  }] } });
391
527
 
528
+ /** Injection token that determines the scroll handling while the popover is open. */
529
+ const MTX_POPOVER_SCROLL_STRATEGY = new InjectionToken('mtx-popover-scroll-strategy');
530
+ /** @docs-private */
531
+ function MTX_POPOVER_SCROLL_STRATEGY_FACTORY(overlay) {
532
+ return () => overlay.scrollStrategies.reposition();
533
+ }
534
+ /** @docs-private */
535
+ const MTX_POPOVER_SCROLL_STRATEGY_FACTORY_PROVIDER = {
536
+ provide: MTX_POPOVER_SCROLL_STRATEGY,
537
+ deps: [Overlay],
538
+ useFactory: MTX_POPOVER_SCROLL_STRATEGY_FACTORY,
539
+ };
392
540
  /**
393
- * This directive is intended to be used in conjunction with an mtx-popover tag. It is
541
+ * This directive is intended to be used in conjunction with an `mtx-popover` tag. It is
394
542
  * responsible for toggling the display of the provided popover instance.
395
543
  */
396
544
  class MtxPopoverTrigger {
397
- constructor(_overlay, _elementRef, _viewContainerRef, _dir, _changeDetectorRef) {
545
+ constructor(_overlay, _elementRef, _viewContainerRef, scrollStrategy, _dir, _changeDetectorRef, _focusMonitor) {
398
546
  this._overlay = _overlay;
399
547
  this._elementRef = _elementRef;
400
548
  this._viewContainerRef = _viewContainerRef;
401
549
  this._dir = _dir;
402
550
  this._changeDetectorRef = _changeDetectorRef;
403
- this.ariaHaspopup = true;
404
- this.popoverOpened$ = new Subject();
405
- this.popoverClosed$ = new Subject();
551
+ this._focusMonitor = _focusMonitor;
406
552
  this._overlayRef = null;
407
553
  this._popoverOpen = false;
408
554
  this._halt = false;
409
- // tracking input type is necessary so it's possible to only auto-focus
555
+ this._positionSubscription = Subscription.EMPTY;
556
+ this._popoverCloseSubscription = Subscription.EMPTY;
557
+ this._closingActionsSubscription = Subscription.EMPTY;
558
+ // Tracking input type is necessary so it's possible to only auto-focus
410
559
  // the first item of the list when the popover is opened via the keyboard
411
- this._openedByMouse = false;
412
- this._onDestroy = new Subject();
560
+ this._openedBy = undefined;
413
561
  /** Event emitted when the associated popover is opened. */
414
562
  this.popoverOpened = new EventEmitter();
415
563
  /** Event emitted when the associated popover is closed. */
416
564
  this.popoverClosed = new EventEmitter();
565
+ this._scrollStrategy = scrollStrategy;
566
+ }
567
+ /** References the popover instance that the trigger is associated with. */
568
+ get popover() {
569
+ return this._popover;
570
+ }
571
+ set popover(popover) {
572
+ if (popover === this._popover) {
573
+ return;
574
+ }
575
+ this._popover = popover;
576
+ this._popoverCloseSubscription.unsubscribe();
577
+ if (popover) {
578
+ this._popoverCloseSubscription = popover.closed.subscribe((reason) => {
579
+ this._destroyPopover();
580
+ });
581
+ }
417
582
  }
418
- ngAfterViewInit() {
583
+ ngAfterContentInit() {
419
584
  this._checkPopover();
420
585
  this._setCurrentConfig();
421
- this.popover.closed.subscribe(() => this.closePopover());
422
586
  }
423
587
  ngOnDestroy() {
424
- this.destroyPopover();
588
+ if (this._overlayRef) {
589
+ this._overlayRef.dispose();
590
+ this._overlayRef = null;
591
+ }
592
+ this._positionSubscription.unsubscribe();
593
+ this._popoverCloseSubscription.unsubscribe();
594
+ this._closingActionsSubscription.unsubscribe();
425
595
  }
426
596
  _setCurrentConfig() {
427
597
  if (this.triggerEvent) {
@@ -433,12 +603,18 @@ class MtxPopoverTrigger {
433
603
  get popoverOpen() {
434
604
  return this._popoverOpen;
435
605
  }
436
- onClick(event) {
606
+ /** The text direction of the containing app. */
607
+ get dir() {
608
+ return this._dir && this._dir.value === 'rtl' ? 'rtl' : 'ltr';
609
+ }
610
+ /** Handles mouse click on the trigger. */
611
+ _handleClick(event) {
437
612
  if (this.popover.triggerEvent === 'click') {
438
613
  this.togglePopover();
439
614
  }
440
615
  }
441
- onMouseEnter(event) {
616
+ /** Handles mouse enter on the trigger. */
617
+ _handleMouseEnter(event) {
442
618
  this._halt = false;
443
619
  if (this.popover.triggerEvent === 'hover') {
444
620
  this._mouseoverTimer = setTimeout(() => {
@@ -446,7 +622,8 @@ class MtxPopoverTrigger {
446
622
  }, this.popover.enterDelay);
447
623
  }
448
624
  }
449
- onMouseLeave(event) {
625
+ /** Handles mouse leave on the trigger. */
626
+ _handleMouseLeave(event) {
450
627
  if (this.popover.triggerEvent === 'hover') {
451
628
  if (this._mouseoverTimer) {
452
629
  clearTimeout(this._mouseoverTimer);
@@ -464,117 +641,119 @@ class MtxPopoverTrigger {
464
641
  }
465
642
  }
466
643
  }
644
+ /** Handles mouse presses on the trigger. */
645
+ _handleMousedown(event) {
646
+ if (!isFakeMousedownFromScreenReader(event)) {
647
+ // Since right or middle button clicks won't trigger the `click` event,
648
+ // we shouldn't consider the popover as opened by mouse in those cases.
649
+ this._openedBy = event.button === 0 ? 'mouse' : undefined;
650
+ }
651
+ }
652
+ /** Handles key presses on the trigger. */
653
+ _handleKeydown(event) {
654
+ const keyCode = event.keyCode;
655
+ // Pressing enter on the trigger will trigger the click handler later.
656
+ if (keyCode === ENTER || keyCode === SPACE) {
657
+ this._openedBy = 'keyboard';
658
+ }
659
+ }
467
660
  /** Toggles the popover between the open and closed states. */
468
661
  togglePopover() {
469
662
  return this._popoverOpen ? this.closePopover() : this.openPopover();
470
663
  }
471
664
  /** Opens the popover. */
472
665
  openPopover() {
473
- if (!this._popoverOpen && !this._halt) {
474
- this._createOverlay().attach(this._portal);
475
- this._subscribeToBackdrop();
476
- this._subscribeToDetachments();
477
- this._initPopover();
666
+ if (this._popoverOpen || this._halt) {
667
+ return;
668
+ }
669
+ this._checkPopover();
670
+ const overlayRef = this._createOverlay();
671
+ const overlayConfig = overlayRef.getConfig();
672
+ this._setPosition(overlayConfig.positionStrategy);
673
+ if (this.popover.triggerEvent === 'click') {
674
+ overlayConfig.hasBackdrop = this.popover.hasBackdrop ?? true;
675
+ }
676
+ overlayRef.attach(this._getPortal());
677
+ if (this.popover.lazyContent) {
678
+ this.popover.lazyContent.attach(this.popoverData);
679
+ }
680
+ this._closingActionsSubscription = this._popoverClosingActions().subscribe(() => this.closePopover());
681
+ this._initPopover();
682
+ if (this.popover instanceof MtxPopover) {
683
+ this.popover._startAnimation();
478
684
  }
479
685
  }
480
686
  /** Closes the popover. */
481
687
  closePopover() {
482
- if (this._overlayRef) {
483
- this._overlayRef.detach();
484
- this._resetPopover();
688
+ this.popover.closed.emit();
689
+ }
690
+ /**
691
+ * Focuses the popover trigger.
692
+ * @param origin Source of the popover trigger's focus.
693
+ */
694
+ focus(origin, options) {
695
+ if (this._focusMonitor && origin) {
696
+ this._focusMonitor.focusVia(this._elementRef, origin, options);
697
+ }
698
+ else {
699
+ this._elementRef.nativeElement.focus(options);
485
700
  }
486
- this.destroyPopover();
487
701
  }
488
702
  /** Removes the popover from the DOM. */
489
- destroyPopover() {
703
+ _destroyPopover(reason) {
704
+ if (!this._overlayRef || !this.popoverOpen) {
705
+ return;
706
+ }
707
+ // Clear the timeout for hover event.
490
708
  if (this._mouseoverTimer) {
491
709
  clearTimeout(this._mouseoverTimer);
492
710
  this._mouseoverTimer = null;
493
711
  }
494
- if (this._overlayRef) {
495
- this._overlayRef.dispose();
496
- this._overlayRef = null;
497
- this._cleanUpSubscriptions();
498
- }
499
- this._onDestroy.next();
500
- this._onDestroy.complete();
501
- }
502
- /** Focuses the popover trigger. */
503
- focus() {
504
- this._elementRef.nativeElement.focus();
505
- }
506
- /** The text direction of the containing app. */
507
- get dir() {
508
- return this._dir && this._dir.value === 'rtl' ? 'rtl' : 'ltr';
509
- }
510
- /**
511
- * This method ensures that the popover closes when the overlay backdrop is clicked.
512
- * We do not use first() here because doing so would not catch clicks from within
513
- * the popover, and it would fail to unsubscribe properly. Instead, we unsubscribe
514
- * explicitly when the popover is closed or destroyed.
515
- */
516
- _subscribeToBackdrop() {
517
- if (this._overlayRef) {
518
- /** Only subscribe to backdrop if trigger event is click */
519
- if (this.triggerEvent === 'click' && this.popover.closeOnBackdropClick === true) {
520
- this._overlayRef
521
- .backdropClick()
522
- .pipe(takeUntil(this.popoverClosed$), takeUntil(this._onDestroy))
523
- .subscribe(() => {
524
- this.popover._emitCloseEvent();
712
+ const popover = this.popover;
713
+ this._closingActionsSubscription.unsubscribe();
714
+ this._overlayRef.detach();
715
+ this._openedBy = undefined;
716
+ if (popover instanceof MtxPopover) {
717
+ popover._resetAnimation();
718
+ if (popover.lazyContent) {
719
+ // Wait for the exit animation to finish before detaching the content.
720
+ popover._animationDone
721
+ .pipe(filter(event => event.toState === 'void'), take(1),
722
+ // Interrupt if the content got re-attached.
723
+ takeUntil(popover.lazyContent._attached))
724
+ .subscribe({
725
+ next: () => popover.lazyContent.detach(),
726
+ // No matter whether the content got re-attached, reset the popover.
727
+ complete: () => this._setIsPopoverOpen(false),
525
728
  });
526
729
  }
730
+ else {
731
+ this._setIsPopoverOpen(false);
732
+ }
527
733
  }
528
- }
529
- _subscribeToDetachments() {
530
- if (this._overlayRef) {
531
- this._overlayRef
532
- .detachments()
533
- .pipe(takeUntil(this.popoverClosed$), takeUntil(this._onDestroy))
534
- .subscribe(() => {
535
- this._setPopoverClosed();
536
- });
734
+ else {
735
+ this._setIsPopoverOpen(false);
736
+ if (popover.lazyContent) {
737
+ popover.lazyContent.detach();
738
+ }
537
739
  }
538
740
  }
539
741
  /**
540
- * This method sets the popover state to open and focuses the first item if
541
- * the popover was opened via the keyboard.
742
+ * This method sets the popover state to open.
542
743
  */
543
744
  _initPopover() {
544
- this._setPopoverOpened();
545
- }
546
- /**
547
- * This method resets the popover when it's closed, most importantly restoring
548
- * focus to the popover trigger if the popover was opened via the keyboard.
549
- */
550
- _resetPopover() {
551
- this._setPopoverClosed();
552
- // Focus only needs to be reset to the host element if the popover was opened
553
- // by the keyboard and manually shifted to the first popover item.
554
- if (!this._openedByMouse) {
555
- this.focus();
556
- }
557
- this._openedByMouse = false;
745
+ this.popover.direction = this.dir;
746
+ this.popover.setElevation();
747
+ this._setIsPopoverOpen(true);
558
748
  }
559
- /** set state rather than toggle to support triggers sharing a popover */
560
- _setPopoverOpened() {
561
- if (!this._popoverOpen) {
562
- this._popoverOpen = true;
563
- this.popoverOpened$.next();
564
- this.popoverOpened.emit();
565
- }
566
- }
567
- /** set state rather than toggle to support triggers sharing a popover */
568
- _setPopoverClosed() {
569
- if (this._popoverOpen) {
570
- this._popoverOpen = false;
571
- this.popoverClosed$.next();
572
- this.popoverClosed.emit();
573
- }
749
+ // set state rather than toggle to support triggers sharing a popover
750
+ _setIsPopoverOpen(isOpen) {
751
+ this._popoverOpen = isOpen;
752
+ this._popoverOpen ? this.popoverOpened.emit() : this.popoverClosed.emit();
574
753
  }
575
754
  /**
576
- * This method checks that a valid instance of MdPopover has been passed into
577
- * mdPopoverTriggerFor. If not, an exception is thrown.
755
+ * This method checks that a valid instance of MdPopover has been passed into
756
+ * `mtxPopoverTriggerFor`. If not, an exception is thrown.
578
757
  */
579
758
  _checkPopover() {
580
759
  if (!this.popover) {
@@ -582,16 +761,20 @@ class MtxPopoverTrigger {
582
761
  }
583
762
  }
584
763
  /**
585
- * This method creates the overlay from the provided popover's template and saves its
586
- * OverlayRef so that it can be attached to the DOM when openPopover is called.
764
+ * This method creates the overlay from the provided popover's template and saves its
765
+ * OverlayRef so that it can be attached to the DOM when openPopover is called.
587
766
  */
588
767
  _createOverlay() {
589
768
  if (!this._overlayRef) {
590
- this._portal = new TemplatePortal(this.popover.templateRef, this._viewContainerRef);
591
769
  const config = this._getOverlayConfig();
592
770
  this._subscribeToPositions(config.positionStrategy);
593
771
  this._overlayRef = this._overlay.create(config);
594
772
  }
773
+ else {
774
+ const overlayConfig = this._overlayRef.getConfig();
775
+ const positionStrategy = overlayConfig.positionStrategy;
776
+ positionStrategy.setOrigin(this._getTargetElement());
777
+ }
595
778
  return this._overlayRef;
596
779
  }
597
780
  /**
@@ -599,32 +782,24 @@ class MtxPopoverTrigger {
599
782
  * @returns OverlayConfig
600
783
  */
601
784
  _getOverlayConfig() {
602
- const overlayState = new OverlayConfig();
603
- overlayState.positionStrategy = this._getPosition();
604
- /** Display overlay backdrop if trigger event is click */
605
- if (this.triggerEvent === 'click') {
606
- overlayState.hasBackdrop = true;
607
- overlayState.backdropClass = 'cdk-overlay-transparent-backdrop';
608
- }
609
- overlayState.direction = this._dir;
610
- overlayState.scrollStrategy = this._getOverlayScrollStrategy(this.popover.scrollStrategy);
611
- return overlayState;
785
+ return new OverlayConfig({
786
+ positionStrategy: this._overlay
787
+ .position()
788
+ .flexibleConnectedTo(this._getTargetElement())
789
+ .withLockedPosition()
790
+ .withGrowAfterOpen()
791
+ .withTransformOriginOn('.mtx-popover-panel'),
792
+ backdropClass: this.popover.backdropClass || 'cdk-overlay-transparent-backdrop',
793
+ panelClass: this.popover.overlayPanelClass,
794
+ scrollStrategy: this._scrollStrategy(),
795
+ direction: this._dir,
796
+ });
612
797
  }
613
- /**
614
- * This method returns the scroll strategy used by the cdk/overlay.
615
- */
616
- _getOverlayScrollStrategy(strategy) {
617
- switch (strategy) {
618
- case 'noop':
619
- return this._overlay.scrollStrategies.noop();
620
- case 'close':
621
- return this._overlay.scrollStrategies.close();
622
- case 'block':
623
- return this._overlay.scrollStrategies.block();
624
- case 'reposition':
625
- default:
626
- return this._overlay.scrollStrategies.reposition();
798
+ _getTargetElement() {
799
+ if (this.targetElement) {
800
+ return this.targetElement.elementRef;
627
801
  }
802
+ return this._elementRef;
628
803
  }
629
804
  /**
630
805
  * Listens to changes in the position of the overlay and sets the correct classes
@@ -648,18 +823,16 @@ class MtxPopoverTrigger {
648
823
  : [posX, posY];
649
824
  // required for ChangeDetectionStrategy.OnPush
650
825
  this._changeDetectorRef.markForCheck();
651
- this.popover.zone.run(() => {
652
- this.popover.setCurrentStyles(pos);
653
- this.popover.setPositionClasses(pos);
654
- });
826
+ this.popover.setCurrentStyles(pos);
827
+ this.popover.setPositionClasses(pos);
655
828
  });
656
829
  }
657
830
  /**
658
- * This method builds the position strategy for the overlay, so the popover is properly connected
659
- * to the trigger.
660
- * @returns ConnectedPositionStrategy
831
+ * Sets the appropriate positions on a position strategy
832
+ * so the overlay connects with the trigger correctly.
833
+ * @param positionStrategy Strategy whose position to update.
661
834
  */
662
- _getPosition() {
835
+ _setPosition(positionStrategy) {
663
836
  const [originX, origin2ndX, origin3rdX] = this.popover.position[0] === 'before' || this.popover.position[1] === 'after'
664
837
  ? ['start', 'center', 'end']
665
838
  : this.popover.position[0] === 'after' || this.popover.position[1] === 'before'
@@ -688,16 +861,6 @@ class MtxPopoverTrigger {
688
861
  const offsetY = this.popover.yOffset && !isNaN(Number(this.popover.yOffset))
689
862
  ? Number(this.popover.yOffset)
690
863
  : 0;
691
- /**
692
- * For overriding position element, when `mtxPopoverTargetAt` has a valid element reference.
693
- * Useful for sticking popover to parent element and offsetting arrow to trigger element.
694
- * If undefined defaults to the trigger element reference.
695
- */
696
- let element = this._elementRef;
697
- if (typeof this.targetElement !== 'undefined') {
698
- this.popover.containerPositioning = true;
699
- element = this.targetElement._elementRef;
700
- }
701
864
  let positions = [{ originX, originY, overlayX, overlayY }];
702
865
  if (this.popover.position[0] === 'above' || this.popover.position[0] === 'below') {
703
866
  positions = [
@@ -755,47 +918,59 @@ class MtxPopoverTrigger {
755
918
  },
756
919
  ];
757
920
  }
758
- return this._overlay
759
- .position()
760
- .flexibleConnectedTo(element)
761
- .withLockedPosition()
921
+ positionStrategy
762
922
  .withPositions(positions)
763
923
  .withDefaultOffsetX(offsetX)
764
924
  .withDefaultOffsetY(offsetY);
765
925
  }
766
- _cleanUpSubscriptions() {
767
- if (this._backdropSubscription) {
768
- this._backdropSubscription.unsubscribe();
769
- }
770
- if (this._positionSubscription) {
771
- this._positionSubscription.unsubscribe();
772
- }
773
- if (this._detachmentsSubscription) {
774
- this._detachmentsSubscription.unsubscribe();
775
- }
776
- }
777
- _handleMousedown(event) {
778
- if (event && !isFakeMousedownFromScreenReader(event)) {
779
- this._openedByMouse = true;
926
+ /** Returns a stream that emits whenever an action that should close the popover occurs. */
927
+ _popoverClosingActions() {
928
+ const backdrop = this.popover.triggerEvent === 'click' && this.popover.closeOnBackdropClick === true
929
+ ? this._overlayRef.backdropClick()
930
+ : of();
931
+ const detachments = this._overlayRef.detachments();
932
+ return merge(backdrop, detachments);
933
+ }
934
+ /** Gets the portal that should be attached to the overlay. */
935
+ _getPortal() {
936
+ // Note that we can avoid this check by keeping the portal on the popover panel.
937
+ // While it would be cleaner, we'd have to introduce another required method on
938
+ // `MtxPopoverPanel`, making it harder to consume.
939
+ if (!this._portal || this._portal.templateRef !== this.popover.templateRef) {
940
+ this._portal = new TemplatePortal(this.popover.templateRef, this._viewContainerRef);
780
941
  }
942
+ return this._portal;
781
943
  }
782
944
  }
783
- /** @nocollapse */ MtxPopoverTrigger.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: MtxPopoverTrigger, deps: [{ token: i1$1.Overlay }, { token: i0.ElementRef }, { token: i0.ViewContainerRef }, { token: i1.Directionality, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
784
- /** @nocollapse */ MtxPopoverTrigger.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.6", type: MtxPopoverTrigger, selector: "[mtxPopoverTriggerFor]", inputs: { popover: ["mtxPopoverTriggerFor", "popover"], targetElement: ["mtxPopoverTargetAt", "targetElement"], triggerEvent: ["mtxPopoverTriggerOn", "triggerEvent"] }, outputs: { popoverOpened: "popoverOpened", popoverClosed: "popoverClosed" }, host: { listeners: { "click": "onClick($event)", "mouseenter": "onMouseEnter($event)", "mouseleave": "onMouseLeave($event)", "mousedown": "_handleMousedown($event)" }, properties: { "attr.aria-haspopup": "this.ariaHaspopup" } }, exportAs: ["mtxPopoverTrigger"], ngImport: i0 });
945
+ /** @nocollapse */ MtxPopoverTrigger.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: MtxPopoverTrigger, deps: [{ token: i1$1.Overlay }, { token: i0.ElementRef }, { token: i0.ViewContainerRef }, { token: MTX_POPOVER_SCROLL_STRATEGY }, { token: i2.Directionality, optional: true }, { token: i0.ChangeDetectorRef }, { token: i3.FocusMonitor }], target: i0.ɵɵFactoryTarget.Directive });
946
+ /** @nocollapse */ MtxPopoverTrigger.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.6", type: MtxPopoverTrigger, selector: "[mtx-popover-trigger-for], [mtxPopoverTriggerFor]", inputs: { popover: ["mtxPopoverTriggerFor", "popover"], popoverData: ["mtxPopoverTriggerData", "popoverData"], targetElement: ["mtxPopoverTargetAt", "targetElement"], triggerEvent: ["mtxPopoverTriggerOn", "triggerEvent"] }, outputs: { popoverOpened: "popoverOpened", popoverClosed: "popoverClosed" }, host: { attributes: { "aria-haspopup": "true" }, listeners: { "click": "_handleClick($event)", "mouseenter": "_handleMouseEnter($event)", "mouseleave": "_handleMouseLeave($event)", "mousedown": "_handleMousedown($event)", "keydown": "_handleKeydown($event)" }, properties: { "attr.aria-expanded": "popoverOpen || null", "attr.aria-controls": "popoverOpen ? popover.panelId : null" } }, exportAs: ["mtxPopoverTrigger"], ngImport: i0 });
785
947
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: MtxPopoverTrigger, decorators: [{
786
948
  type: Directive,
787
949
  args: [{
788
- selector: '[mtxPopoverTriggerFor]',
950
+ selector: '[mtx-popover-trigger-for], [mtxPopoverTriggerFor]',
789
951
  exportAs: 'mtxPopoverTrigger',
952
+ host: {
953
+ 'aria-haspopup': 'true',
954
+ '[attr.aria-expanded]': 'popoverOpen || null',
955
+ '[attr.aria-controls]': 'popoverOpen ? popover.panelId : null',
956
+ '(click)': '_handleClick($event)',
957
+ '(mouseenter)': '_handleMouseEnter($event)',
958
+ '(mouseleave)': '_handleMouseLeave($event)',
959
+ '(mousedown)': '_handleMousedown($event)',
960
+ '(keydown)': '_handleKeydown($event)',
961
+ },
790
962
  }]
791
- }], ctorParameters: function () { return [{ type: i1$1.Overlay }, { type: i0.ElementRef }, { type: i0.ViewContainerRef }, { type: i1.Directionality, decorators: [{
963
+ }], ctorParameters: function () { return [{ type: i1$1.Overlay }, { type: i0.ElementRef }, { type: i0.ViewContainerRef }, { type: undefined, decorators: [{
964
+ type: Inject,
965
+ args: [MTX_POPOVER_SCROLL_STRATEGY]
966
+ }] }, { type: i2.Directionality, decorators: [{
792
967
  type: Optional
793
- }] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { ariaHaspopup: [{
794
- type: HostBinding,
795
- args: ['attr.aria-haspopup']
796
- }], popover: [{
968
+ }] }, { type: i0.ChangeDetectorRef }, { type: i3.FocusMonitor }]; }, propDecorators: { popover: [{
797
969
  type: Input,
798
970
  args: ['mtxPopoverTriggerFor']
971
+ }], popoverData: [{
972
+ type: Input,
973
+ args: ['mtxPopoverTriggerData']
799
974
  }], targetElement: [{
800
975
  type: Input,
801
976
  args: ['mtxPopoverTargetAt']
@@ -806,23 +981,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImpor
806
981
  type: Output
807
982
  }], popoverClosed: [{
808
983
  type: Output
809
- }], onClick: [{
810
- type: HostListener,
811
- args: ['click', ['$event']]
812
- }], onMouseEnter: [{
813
- type: HostListener,
814
- args: ['mouseenter', ['$event']]
815
- }], onMouseLeave: [{
816
- type: HostListener,
817
- args: ['mouseleave', ['$event']]
818
- }], _handleMousedown: [{
819
- type: HostListener,
820
- args: ['mousedown', ['$event']]
821
984
  }] } });
822
985
 
823
986
  class MtxPopoverTarget {
824
- constructor(_elementRef) {
825
- this._elementRef = _elementRef;
987
+ constructor(elementRef) {
988
+ this.elementRef = elementRef;
826
989
  }
827
990
  }
828
991
  /** @nocollapse */ MtxPopoverTarget.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: MtxPopoverTarget, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
@@ -838,14 +1001,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImpor
838
1001
  class MtxPopoverModule {
839
1002
  }
840
1003
  /** @nocollapse */ MtxPopoverModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: MtxPopoverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
841
- /** @nocollapse */ MtxPopoverModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: MtxPopoverModule, declarations: [MtxPopover, MtxPopoverTrigger, MtxPopoverTarget], imports: [OverlayModule, CommonModule, A11yModule], exports: [MtxPopover, MtxPopoverTrigger, MtxPopoverTarget] });
842
- /** @nocollapse */ MtxPopoverModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: MtxPopoverModule, imports: [[OverlayModule, CommonModule, A11yModule]] });
1004
+ /** @nocollapse */ MtxPopoverModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: MtxPopoverModule, declarations: [MtxPopover, MtxPopoverTrigger, MtxPopoverTarget, MtxPopoverContent], imports: [CommonModule, OverlayModule, A11yModule], exports: [MtxPopover, MtxPopoverTrigger, MtxPopoverTarget, MtxPopoverContent] });
1005
+ /** @nocollapse */ MtxPopoverModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: MtxPopoverModule, providers: [MTX_POPOVER_SCROLL_STRATEGY_FACTORY_PROVIDER], imports: [[CommonModule, OverlayModule, A11yModule]] });
843
1006
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: MtxPopoverModule, decorators: [{
844
1007
  type: NgModule,
845
1008
  args: [{
846
- imports: [OverlayModule, CommonModule, A11yModule],
847
- exports: [MtxPopover, MtxPopoverTrigger, MtxPopoverTarget],
848
- declarations: [MtxPopover, MtxPopoverTrigger, MtxPopoverTarget],
1009
+ imports: [CommonModule, OverlayModule, A11yModule],
1010
+ exports: [MtxPopover, MtxPopoverTrigger, MtxPopoverTarget, MtxPopoverContent],
1011
+ declarations: [MtxPopover, MtxPopoverTrigger, MtxPopoverTarget, MtxPopoverContent],
1012
+ providers: [MTX_POPOVER_SCROLL_STRATEGY_FACTORY_PROVIDER],
849
1013
  }]
850
1014
  }] });
851
1015
 
@@ -853,5 +1017,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImpor
853
1017
  * Generated bundle index. Do not edit.
854
1018
  */
855
1019
 
856
- export { MtxPopover, MtxPopoverModule, MtxPopoverTarget, MtxPopoverTrigger, transformPopover };
1020
+ export { MTX_POPOVER_CONTENT, MTX_POPOVER_DEFAULT_OPTIONS, MTX_POPOVER_DEFAULT_OPTIONS_FACTORY, MTX_POPOVER_SCROLL_STRATEGY, MTX_POPOVER_SCROLL_STRATEGY_FACTORY, MTX_POPOVER_SCROLL_STRATEGY_FACTORY_PROVIDER, MtxPopover, MtxPopoverContent, MtxPopoverModule, MtxPopoverTarget, MtxPopoverTrigger, _MtxPopoverContentBase, transformPopover };
857
1021
  //# sourceMappingURL=mtxPopover.mjs.map