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