@ng-matero/extensions 14.2.2 → 14.3.0

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