@angular/cdk-experimental 14.0.0-next.5 → 14.0.0-next.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/combobox/combobox-module.d.ts +3 -4
- package/combobox/combobox-popup.d.ts +6 -8
- package/combobox/combobox.d.ts +15 -18
- package/combobox/public-api.d.ts +0 -1
- package/esm2020/column-resize/column-resize-directives/column-resize-flex.mjs +3 -3
- package/esm2020/column-resize/column-resize-directives/column-resize.mjs +3 -3
- package/esm2020/column-resize/column-resize-directives/default-enabled-column-resize-flex.mjs +3 -3
- package/esm2020/column-resize/column-resize-directives/default-enabled-column-resize.mjs +3 -3
- package/esm2020/column-resize/column-resize-module.mjs +8 -8
- package/esm2020/column-resize/column-resize-notifier.mjs +6 -6
- package/esm2020/column-resize/column-resize.mjs +3 -3
- package/esm2020/column-resize/column-size-store.mjs +3 -3
- package/esm2020/column-resize/event-dispatcher.mjs +3 -3
- package/esm2020/column-resize/overlay-handle.mjs +3 -3
- package/esm2020/column-resize/resizable.mjs +3 -3
- package/esm2020/column-resize/resize-strategy.mjs +9 -9
- package/esm2020/combobox/combobox-module.mjs +6 -7
- package/esm2020/combobox/combobox-popup.mjs +12 -23
- package/esm2020/combobox/combobox.mjs +50 -34
- package/esm2020/combobox/public-api.mjs +1 -2
- package/esm2020/dialog/dialog-container.mjs +28 -11
- package/esm2020/dialog/dialog-module.mjs +4 -4
- package/esm2020/dialog/dialog.mjs +3 -3
- package/esm2020/listbox/listbox-module.mjs +4 -4
- package/esm2020/listbox/listbox.mjs +26 -44
- package/esm2020/menu/context-menu.mjs +46 -82
- package/esm2020/menu/menu-aim.mjs +6 -6
- package/esm2020/menu/menu-bar.mjs +16 -13
- package/esm2020/menu/menu-errors.mjs +1 -9
- package/esm2020/menu/menu-group.mjs +3 -3
- package/esm2020/menu/menu-item-checkbox.mjs +3 -3
- package/esm2020/menu/menu-item-radio.mjs +15 -8
- package/esm2020/menu/menu-item-selectable.mjs +3 -3
- package/esm2020/menu/menu-item-trigger.mjs +63 -88
- package/esm2020/menu/menu-item.mjs +29 -37
- package/esm2020/menu/menu-module.mjs +5 -9
- package/esm2020/menu/menu-stack.mjs +10 -6
- package/esm2020/menu/menu-trigger.mjs +43 -0
- package/esm2020/menu/menu.mjs +32 -45
- package/esm2020/menu/public-api.mjs +3 -3
- package/esm2020/popover-edit/edit-event-dispatcher.mjs +3 -3
- package/esm2020/popover-edit/edit-ref.mjs +3 -3
- package/esm2020/popover-edit/edit-services.mjs +3 -3
- package/esm2020/popover-edit/focus-dispatcher.mjs +3 -3
- package/esm2020/popover-edit/focus-escape-notifier.mjs +3 -3
- package/esm2020/popover-edit/lens-directives.mjs +9 -9
- package/esm2020/popover-edit/popover-edit-module.mjs +4 -4
- package/esm2020/popover-edit/popover-edit-position-strategy-factory.mjs +6 -6
- package/esm2020/popover-edit/table-directives.mjs +15 -15
- package/esm2020/scrolling/auto-size-virtual-scroll.mjs +3 -3
- package/esm2020/scrolling/scrolling-module.mjs +4 -4
- package/esm2020/selection/row-selection.mjs +3 -3
- package/esm2020/selection/select-all.mjs +3 -3
- package/esm2020/selection/selection-column.mjs +3 -3
- package/esm2020/selection/selection-module.mjs +4 -4
- package/esm2020/selection/selection-toggle.mjs +3 -3
- package/esm2020/selection/selection.mjs +3 -3
- package/esm2020/table-scroll-container/table-scroll-container-module.mjs +4 -4
- package/esm2020/table-scroll-container/table-scroll-container.mjs +3 -3
- package/esm2020/version.mjs +1 -1
- package/fesm2015/cdk-experimental.mjs +1 -1
- package/fesm2015/cdk-experimental.mjs.map +1 -1
- package/fesm2015/column-resize.mjs +50 -50
- package/fesm2015/column-resize.mjs.map +1 -1
- package/fesm2015/combobox.mjs +63 -106
- package/fesm2015/combobox.mjs.map +1 -1
- package/fesm2015/dialog.mjs +34 -17
- package/fesm2015/dialog.mjs.map +1 -1
- package/fesm2015/listbox.mjs +31 -47
- package/fesm2015/listbox.mjs.map +1 -1
- package/fesm2015/menu.mjs +334 -421
- package/fesm2015/menu.mjs.map +1 -1
- package/fesm2015/popover-edit.mjs +49 -49
- package/fesm2015/popover-edit.mjs.map +1 -1
- package/fesm2015/scrolling.mjs +7 -7
- package/fesm2015/scrolling.mjs.map +1 -1
- package/fesm2015/selection.mjs +19 -19
- package/fesm2015/selection.mjs.map +1 -1
- package/fesm2015/table-scroll-container.mjs +7 -7
- package/fesm2015/table-scroll-container.mjs.map +1 -1
- package/fesm2020/cdk-experimental.mjs +1 -1
- package/fesm2020/cdk-experimental.mjs.map +1 -1
- package/fesm2020/column-resize.mjs +50 -50
- package/fesm2020/column-resize.mjs.map +1 -1
- package/fesm2020/combobox.mjs +62 -103
- package/fesm2020/combobox.mjs.map +1 -1
- package/fesm2020/dialog.mjs +34 -17
- package/fesm2020/dialog.mjs.map +1 -1
- package/fesm2020/listbox.mjs +29 -46
- package/fesm2020/listbox.mjs.map +1 -1
- package/fesm2020/menu.mjs +238 -321
- package/fesm2020/menu.mjs.map +1 -1
- package/fesm2020/popover-edit.mjs +49 -49
- package/fesm2020/popover-edit.mjs.map +1 -1
- package/fesm2020/scrolling.mjs +7 -7
- package/fesm2020/scrolling.mjs.map +1 -1
- package/fesm2020/selection.mjs +19 -19
- package/fesm2020/selection.mjs.map +1 -1
- package/fesm2020/table-scroll-container.mjs +7 -7
- package/fesm2020/table-scroll-container.mjs.map +1 -1
- package/listbox/listbox.d.ts +16 -13
- package/menu/context-menu.d.ts +12 -30
- package/menu/menu-bar.d.ts +2 -2
- package/menu/menu-errors.d.ts +0 -5
- package/menu/menu-item-radio.d.ts +4 -3
- package/menu/menu-item-trigger.d.ts +11 -18
- package/menu/menu-item.d.ts +11 -6
- package/menu/menu-module.d.ts +9 -10
- package/menu/menu-stack.d.ts +7 -6
- package/menu/menu-trigger.d.ts +24 -0
- package/menu/menu.d.ts +7 -23
- package/menu/public-api.d.ts +2 -2
- package/package.json +2 -2
- package/combobox/combobox-panel.d.ts +0 -27
- package/esm2020/combobox/combobox-panel.mjs +0 -48
- package/esm2020/menu/menu-panel.mjs +0 -37
- package/menu/menu-panel.d.ts +0 -30
package/fesm2015/menu.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, Injectable, Directive, EventEmitter, Optional,
|
|
2
|
+
import { InjectionToken, Injectable, Directive, Injector, Inject, EventEmitter, Optional, SkipSelf, Input, Output, Self, ContentChildren, NgModule } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/cdk/overlay';
|
|
4
|
-
import { OverlayConfig, OverlayModule } from '@angular/cdk/overlay';
|
|
4
|
+
import { OverlayConfig, STANDARD_DROPDOWN_BELOW_POSITIONS, STANDARD_DROPDOWN_ADJACENT_POSITIONS, OverlayModule } from '@angular/cdk/overlay';
|
|
5
5
|
import { FocusKeyManager } from '@angular/cdk/a11y';
|
|
6
6
|
import { UP_ARROW, DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW, ENTER, SPACE, TAB, ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
|
|
7
7
|
import { Subject, fromEvent, merge, defer, partition } from 'rxjs';
|
|
8
8
|
import { filter, takeUntil, startWith, mergeMap, mapTo, mergeAll, take, switchMap, skip } from 'rxjs/operators';
|
|
9
|
-
import * as i1$
|
|
9
|
+
import * as i1$2 from '@angular/cdk/collections';
|
|
10
10
|
import { UniqueSelectionDispatcher } from '@angular/cdk/collections';
|
|
11
11
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
12
|
-
import * as
|
|
12
|
+
import * as i1$1 from '@angular/cdk/bidi';
|
|
13
13
|
import { TemplatePortal } from '@angular/cdk/portal';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -29,14 +29,113 @@ const CDK_MENU = new InjectionToken('cdk-menu');
|
|
|
29
29
|
* Use of this source code is governed by an MIT-style license that can be
|
|
30
30
|
* found in the LICENSE file at https://angular.io/license
|
|
31
31
|
*/
|
|
32
|
+
/** Injection token used for an implementation of MenuStack. */
|
|
33
|
+
const MENU_STACK = new InjectionToken('cdk-menu-stack');
|
|
32
34
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
+
* MenuStack allows subscribers to listen for close events (when a MenuStackItem is popped off
|
|
36
|
+
* of the stack) in order to perform closing actions. Upon the MenuStack being empty it emits
|
|
37
|
+
* from the `empty` observable specifying the next focus action which the listener should perform
|
|
38
|
+
* as requested by the closer.
|
|
35
39
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
class MenuStack {
|
|
41
|
+
constructor() {
|
|
42
|
+
/** All MenuStackItems tracked by this MenuStack. */
|
|
43
|
+
this._elements = [];
|
|
44
|
+
/** Emits the element which was popped off of the stack when requested by a closer. */
|
|
45
|
+
this._close = new Subject();
|
|
46
|
+
/** Emits once the MenuStack has become empty after popping off elements. */
|
|
47
|
+
this._empty = new Subject();
|
|
48
|
+
/** Observable which emits the MenuStackItem which has been requested to close. */
|
|
49
|
+
this.closed = this._close;
|
|
50
|
+
/**
|
|
51
|
+
* Observable which emits when the MenuStack is empty after popping off the last element. It
|
|
52
|
+
* emits a FocusNext event which specifies the action the closer has requested the listener
|
|
53
|
+
* perform.
|
|
54
|
+
*/
|
|
55
|
+
this.emptied = this._empty;
|
|
56
|
+
}
|
|
57
|
+
/** @param menu the MenuStackItem to put on the stack. */
|
|
58
|
+
push(menu) {
|
|
59
|
+
this._elements.push(menu);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Pop items off of the stack up to and including `lastItem` and emit each on the close
|
|
63
|
+
* observable. If the stack is empty or `lastItem` is not on the stack it does nothing.
|
|
64
|
+
* @param lastItem the last item to pop off the stack.
|
|
65
|
+
* @param focusNext the event to emit on the `empty` observable if the method call resulted in an
|
|
66
|
+
* empty stack. Does not emit if the stack was initially empty or if `lastItem` was not on the
|
|
67
|
+
* stack.
|
|
68
|
+
*/
|
|
69
|
+
close(lastItem, focusNext) {
|
|
70
|
+
if (this._elements.indexOf(lastItem) >= 0) {
|
|
71
|
+
let poppedElement;
|
|
72
|
+
do {
|
|
73
|
+
poppedElement = this._elements.pop();
|
|
74
|
+
this._close.next(poppedElement);
|
|
75
|
+
} while (poppedElement !== lastItem);
|
|
76
|
+
if (this.isEmpty()) {
|
|
77
|
+
this._empty.next(focusNext);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Pop items off of the stack up to but excluding `lastItem` and emit each on the close
|
|
83
|
+
* observable. If the stack is empty or `lastItem` is not on the stack it does nothing.
|
|
84
|
+
* @param lastItem the element which should be left on the stack
|
|
85
|
+
* @return whether or not an item was removed from the stack
|
|
86
|
+
*/
|
|
87
|
+
closeSubMenuOf(lastItem) {
|
|
88
|
+
let removed = false;
|
|
89
|
+
if (this._elements.indexOf(lastItem) >= 0) {
|
|
90
|
+
removed = this.peek() !== lastItem;
|
|
91
|
+
while (this.peek() !== lastItem) {
|
|
92
|
+
this._close.next(this._elements.pop());
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return removed;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Pop off all MenuStackItems and emit each one on the `close` observable one by one.
|
|
99
|
+
* @param focusNext the event to emit on the `empty` observable once the stack is emptied. Does
|
|
100
|
+
* not emit if the stack was initially empty.
|
|
101
|
+
*/
|
|
102
|
+
closeAll(focusNext) {
|
|
103
|
+
if (!this.isEmpty()) {
|
|
104
|
+
while (!this.isEmpty()) {
|
|
105
|
+
const menuStackItem = this._elements.pop();
|
|
106
|
+
if (menuStackItem) {
|
|
107
|
+
this._close.next(menuStackItem);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
this._empty.next(focusNext);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** Return true if this stack is empty. */
|
|
114
|
+
isEmpty() {
|
|
115
|
+
return !this._elements.length;
|
|
116
|
+
}
|
|
117
|
+
/** Return the length of the stack. */
|
|
118
|
+
length() {
|
|
119
|
+
return this._elements.length;
|
|
120
|
+
}
|
|
121
|
+
/** Get the top most element on the stack. */
|
|
122
|
+
peek() {
|
|
123
|
+
return this._elements[this._elements.length - 1];
|
|
124
|
+
}
|
|
39
125
|
}
|
|
126
|
+
MenuStack.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: MenuStack, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
127
|
+
MenuStack.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: MenuStack });
|
|
128
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: MenuStack, decorators: [{
|
|
129
|
+
type: Injectable
|
|
130
|
+
}] });
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @license
|
|
134
|
+
* Copyright Google LLC All Rights Reserved.
|
|
135
|
+
*
|
|
136
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
137
|
+
* found in the LICENSE file at https://angular.io/license
|
|
138
|
+
*/
|
|
40
139
|
/**
|
|
41
140
|
* Throws an exception when an instance of the PointerFocusTracker is not provided.
|
|
42
141
|
* @docs-private
|
|
@@ -223,9 +322,9 @@ class TargetMenuAim {
|
|
|
223
322
|
this._destroyed.complete();
|
|
224
323
|
}
|
|
225
324
|
}
|
|
226
|
-
TargetMenuAim.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
227
|
-
TargetMenuAim.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
228
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
325
|
+
TargetMenuAim.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: TargetMenuAim, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
326
|
+
TargetMenuAim.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: TargetMenuAim });
|
|
327
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: TargetMenuAim, decorators: [{
|
|
229
328
|
type: Injectable
|
|
230
329
|
}], ctorParameters: function () { return [{ type: i0.NgZone }]; } });
|
|
231
330
|
/**
|
|
@@ -234,9 +333,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
234
333
|
*/
|
|
235
334
|
class CdkTargetMenuAim {
|
|
236
335
|
}
|
|
237
|
-
CdkTargetMenuAim.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
238
|
-
CdkTargetMenuAim.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
239
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
336
|
+
CdkTargetMenuAim.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkTargetMenuAim, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
337
|
+
CdkTargetMenuAim.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.6", type: CdkTargetMenuAim, selector: "[cdkTargetMenuAim]", providers: [{ provide: MENU_AIM, useClass: TargetMenuAim }], exportAs: ["cdkTargetMenuAim"], ngImport: i0 });
|
|
338
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkTargetMenuAim, decorators: [{
|
|
240
339
|
type: Directive,
|
|
241
340
|
args: [{
|
|
242
341
|
selector: '[cdkTargetMenuAim]',
|
|
@@ -252,103 +351,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
252
351
|
* Use of this source code is governed by an MIT-style license that can be
|
|
253
352
|
* found in the LICENSE file at https://angular.io/license
|
|
254
353
|
*/
|
|
255
|
-
/**
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
* emits a FocusNext event which specifies the action the closer has requested the listener
|
|
274
|
-
* perform.
|
|
275
|
-
*/
|
|
276
|
-
this.emptied = this._empty;
|
|
277
|
-
}
|
|
278
|
-
/** @param menu the MenuStackItem to put on the stack. */
|
|
279
|
-
push(menu) {
|
|
280
|
-
this._elements.push(menu);
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Pop items off of the stack up to and including `lastItem` and emit each on the close
|
|
284
|
-
* observable. If the stack is empty or `lastItem` is not on the stack it does nothing.
|
|
285
|
-
* @param lastItem the last item to pop off the stack.
|
|
286
|
-
* @param focusNext the event to emit on the `empty` observable if the method call resulted in an
|
|
287
|
-
* empty stack. Does not emit if the stack was initially empty or if `lastItem` was not on the
|
|
288
|
-
* stack.
|
|
289
|
-
*/
|
|
290
|
-
close(lastItem, focusNext) {
|
|
291
|
-
if (this._elements.indexOf(lastItem) >= 0) {
|
|
292
|
-
let poppedElement;
|
|
293
|
-
do {
|
|
294
|
-
poppedElement = this._elements.pop();
|
|
295
|
-
this._close.next(poppedElement);
|
|
296
|
-
} while (poppedElement !== lastItem);
|
|
297
|
-
if (this.isEmpty()) {
|
|
298
|
-
this._empty.next(focusNext);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Pop items off of the stack up to but excluding `lastItem` and emit each on the close
|
|
304
|
-
* observable. If the stack is empty or `lastItem` is not on the stack it does nothing.
|
|
305
|
-
* @param lastItem the element which should be left on the stack
|
|
306
|
-
* @return whether or not an item was removed from the stack
|
|
307
|
-
*/
|
|
308
|
-
closeSubMenuOf(lastItem) {
|
|
309
|
-
let removed = false;
|
|
310
|
-
if (this._elements.indexOf(lastItem) >= 0) {
|
|
311
|
-
removed = this.peek() !== lastItem;
|
|
312
|
-
while (this.peek() !== lastItem) {
|
|
313
|
-
this._close.next(this._elements.pop());
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
return removed;
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Pop off all MenuStackItems and emit each one on the `close` observable one by one.
|
|
320
|
-
* @param focusNext the event to emit on the `empty` observable once the stack is emptied. Does
|
|
321
|
-
* not emit if the stack was initially empty.
|
|
322
|
-
*/
|
|
323
|
-
closeAll(focusNext) {
|
|
324
|
-
if (!this.isEmpty()) {
|
|
325
|
-
while (!this.isEmpty()) {
|
|
326
|
-
const menuStackItem = this._elements.pop();
|
|
327
|
-
if (menuStackItem) {
|
|
328
|
-
this._close.next(menuStackItem);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
this._empty.next(focusNext);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
/** Return true if this stack is empty. */
|
|
335
|
-
isEmpty() {
|
|
336
|
-
return !this._elements.length;
|
|
337
|
-
}
|
|
338
|
-
/** Return the length of the stack. */
|
|
339
|
-
length() {
|
|
340
|
-
return this._elements.length;
|
|
354
|
+
/** Injection token used for an implementation of MenuStack. */
|
|
355
|
+
const MENU_TRIGGER = new InjectionToken('cdk-menu-trigger');
|
|
356
|
+
class MenuTrigger {
|
|
357
|
+
constructor(injector, menuStack) {
|
|
358
|
+
this.injector = injector;
|
|
359
|
+
this.menuStack = menuStack;
|
|
360
|
+
}
|
|
361
|
+
getChildMenuInjector() {
|
|
362
|
+
this._childMenuInjector =
|
|
363
|
+
this._childMenuInjector ||
|
|
364
|
+
Injector.create({
|
|
365
|
+
providers: [
|
|
366
|
+
{ provide: MENU_TRIGGER, useValue: this },
|
|
367
|
+
{ provide: MENU_STACK, useValue: this.menuStack },
|
|
368
|
+
],
|
|
369
|
+
parent: this.injector,
|
|
370
|
+
});
|
|
371
|
+
return this._childMenuInjector;
|
|
341
372
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
return this._elements[this._elements.length - 1];
|
|
373
|
+
registerChildMenu(child) {
|
|
374
|
+
this.childMenu = child;
|
|
345
375
|
}
|
|
346
376
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
377
|
+
MenuTrigger.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: MenuTrigger, deps: [{ token: i0.Injector }, { token: MENU_STACK }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
378
|
+
MenuTrigger.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: MenuTrigger });
|
|
379
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: MenuTrigger, decorators: [{
|
|
380
|
+
type: Injectable
|
|
381
|
+
}], ctorParameters: function () {
|
|
382
|
+
return [{ type: i0.Injector }, { type: MenuStack, decorators: [{
|
|
383
|
+
type: Inject,
|
|
384
|
+
args: [MENU_STACK]
|
|
385
|
+
}] }];
|
|
386
|
+
} });
|
|
352
387
|
|
|
353
388
|
/**
|
|
354
389
|
* @license
|
|
@@ -381,8 +416,9 @@ function isClickInsideMenuOverlay(target) {
|
|
|
381
416
|
* The directive must be placed along with the `cdkMenuItem` directive in order to enable full
|
|
382
417
|
* functionality.
|
|
383
418
|
*/
|
|
384
|
-
class CdkMenuItemTrigger {
|
|
385
|
-
constructor(_elementRef, _viewContainerRef, _overlay, _ngZone, _parentMenu, _menuAim, _directionality) {
|
|
419
|
+
class CdkMenuItemTrigger extends MenuTrigger {
|
|
420
|
+
constructor(injector, _elementRef, _viewContainerRef, _overlay, _ngZone, menuStack, _parentMenu, _menuAim, _directionality) {
|
|
421
|
+
super(injector, menuStack);
|
|
386
422
|
this._elementRef = _elementRef;
|
|
387
423
|
this._viewContainerRef = _viewContainerRef;
|
|
388
424
|
this._overlay = _overlay;
|
|
@@ -394,8 +430,6 @@ class CdkMenuItemTrigger {
|
|
|
394
430
|
this.opened = new EventEmitter();
|
|
395
431
|
/** Emits when the attached menu is requested to close */
|
|
396
432
|
this.closed = new EventEmitter();
|
|
397
|
-
/** The menu stack for this trigger and its sub-menus. */
|
|
398
|
-
this._menuStack = new MenuStack();
|
|
399
433
|
/** A reference to the overlay which manages the triggered menu */
|
|
400
434
|
this._overlayRef = null;
|
|
401
435
|
/** Emits when this trigger is destroyed. */
|
|
@@ -405,22 +439,6 @@ class CdkMenuItemTrigger {
|
|
|
405
439
|
this._registerCloseHandler();
|
|
406
440
|
this._subscribeToMouseEnter();
|
|
407
441
|
}
|
|
408
|
-
/** Template reference variable to the menu this trigger opens */
|
|
409
|
-
get menuPanel() {
|
|
410
|
-
return this._menuPanel;
|
|
411
|
-
}
|
|
412
|
-
set menuPanel(panel) {
|
|
413
|
-
// If the provided panel already has a stack, that means it already has a trigger configured.
|
|
414
|
-
// Note however that there are some edge cases where two triggers **may** share the same menu,
|
|
415
|
-
// e.g. two triggers in two separate menus.
|
|
416
|
-
if ((typeof ngDevMode === 'undefined' || ngDevMode) && (panel === null || panel === void 0 ? void 0 : panel._menuStack)) {
|
|
417
|
-
throwExistingMenuStackError();
|
|
418
|
-
}
|
|
419
|
-
this._menuPanel = panel;
|
|
420
|
-
if (this._menuPanel) {
|
|
421
|
-
this._menuPanel._menuStack = this._getMenuStack();
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
442
|
/** Open/close the attached menu if the trigger has been configured with one */
|
|
425
443
|
toggle() {
|
|
426
444
|
if (this.hasMenu()) {
|
|
@@ -446,7 +464,7 @@ class CdkMenuItemTrigger {
|
|
|
446
464
|
}
|
|
447
465
|
/** Return true if the trigger has an attached menu */
|
|
448
466
|
hasMenu() {
|
|
449
|
-
return !!this.
|
|
467
|
+
return !!this._menuTemplateRef;
|
|
450
468
|
}
|
|
451
469
|
/** Whether the menu this button is a trigger for is open */
|
|
452
470
|
isMenuOpen() {
|
|
@@ -457,8 +475,7 @@ class CdkMenuItemTrigger {
|
|
|
457
475
|
* @return the menu if it is open, otherwise undefined.
|
|
458
476
|
*/
|
|
459
477
|
getMenu() {
|
|
460
|
-
|
|
461
|
-
return (_a = this.menuPanel) === null || _a === void 0 ? void 0 : _a._menu;
|
|
478
|
+
return this.childMenu;
|
|
462
479
|
}
|
|
463
480
|
/**
|
|
464
481
|
* Subscribe to the mouseenter events and close any sibling menu items if this element is moused
|
|
@@ -472,7 +489,7 @@ class CdkMenuItemTrigger {
|
|
|
472
489
|
});
|
|
473
490
|
this._ngZone.runOutsideAngular(() => {
|
|
474
491
|
fromEvent(this._elementRef.nativeElement, 'mouseenter')
|
|
475
|
-
.pipe(filter(() =>
|
|
492
|
+
.pipe(filter(() => !this.menuStack.isEmpty() && !this.isMenuOpen()), takeUntil(this._destroyed))
|
|
476
493
|
.subscribe(() => {
|
|
477
494
|
if (this._menuAim) {
|
|
478
495
|
this._menuAim.toggle(toggleMenus);
|
|
@@ -489,36 +506,36 @@ class CdkMenuItemTrigger {
|
|
|
489
506
|
* @param event the keyboard event to handle
|
|
490
507
|
*/
|
|
491
508
|
_toggleOnKeydown(event) {
|
|
492
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
509
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
493
510
|
const keyCode = event.keyCode;
|
|
494
511
|
switch (keyCode) {
|
|
495
512
|
case SPACE:
|
|
496
513
|
case ENTER:
|
|
497
514
|
event.preventDefault();
|
|
498
515
|
this.toggle();
|
|
499
|
-
(
|
|
516
|
+
(_a = this.childMenu) === null || _a === void 0 ? void 0 : _a.focusFirstItem('keyboard');
|
|
500
517
|
break;
|
|
501
518
|
case RIGHT_ARROW:
|
|
502
519
|
if (this._parentMenu && this._isParentVertical()) {
|
|
503
520
|
event.preventDefault();
|
|
504
|
-
if (((
|
|
505
|
-
this.
|
|
521
|
+
if (((_b = this._directionality) === null || _b === void 0 ? void 0 : _b.value) === 'rtl') {
|
|
522
|
+
this.menuStack.close(this._parentMenu, 2 /* currentItem */);
|
|
506
523
|
}
|
|
507
524
|
else {
|
|
508
525
|
this.openMenu();
|
|
509
|
-
(
|
|
526
|
+
(_c = this.childMenu) === null || _c === void 0 ? void 0 : _c.focusFirstItem('keyboard');
|
|
510
527
|
}
|
|
511
528
|
}
|
|
512
529
|
break;
|
|
513
530
|
case LEFT_ARROW:
|
|
514
531
|
if (this._parentMenu && this._isParentVertical()) {
|
|
515
532
|
event.preventDefault();
|
|
516
|
-
if (((
|
|
533
|
+
if (((_d = this._directionality) === null || _d === void 0 ? void 0 : _d.value) === 'rtl') {
|
|
517
534
|
this.openMenu();
|
|
518
|
-
(
|
|
535
|
+
(_e = this.childMenu) === null || _e === void 0 ? void 0 : _e.focusFirstItem('keyboard');
|
|
519
536
|
}
|
|
520
537
|
else {
|
|
521
|
-
this.
|
|
538
|
+
this.menuStack.close(this._parentMenu, 2 /* currentItem */);
|
|
522
539
|
}
|
|
523
540
|
}
|
|
524
541
|
break;
|
|
@@ -528,8 +545,8 @@ class CdkMenuItemTrigger {
|
|
|
528
545
|
event.preventDefault();
|
|
529
546
|
this.openMenu();
|
|
530
547
|
keyCode === DOWN_ARROW
|
|
531
|
-
? (
|
|
532
|
-
: (
|
|
548
|
+
? (_f = this.childMenu) === null || _f === void 0 ? void 0 : _f.focusFirstItem('keyboard')
|
|
549
|
+
: (_g = this.childMenu) === null || _g === void 0 ? void 0 : _g.focusLastItem('keyboard');
|
|
533
550
|
}
|
|
534
551
|
break;
|
|
535
552
|
}
|
|
@@ -537,17 +554,17 @@ class CdkMenuItemTrigger {
|
|
|
537
554
|
/** Close out any sibling menu trigger menus. */
|
|
538
555
|
_closeSiblingTriggers() {
|
|
539
556
|
if (this._parentMenu) {
|
|
540
|
-
const menuStack = this._getMenuStack();
|
|
541
557
|
// If nothing was removed from the stack and the last element is not the parent item
|
|
542
558
|
// that means that the parent menu is a menu bar since we don't put the menu bar on the
|
|
543
559
|
// stack
|
|
544
|
-
const isParentMenuBar = !menuStack.closeSubMenuOf(this._parentMenu) &&
|
|
560
|
+
const isParentMenuBar = !this.menuStack.closeSubMenuOf(this._parentMenu) &&
|
|
561
|
+
this.menuStack.peek() !== this._parentMenu;
|
|
545
562
|
if (isParentMenuBar) {
|
|
546
|
-
menuStack.closeAll();
|
|
563
|
+
this.menuStack.closeAll();
|
|
547
564
|
}
|
|
548
565
|
}
|
|
549
566
|
else {
|
|
550
|
-
this.
|
|
567
|
+
this.menuStack.closeAll();
|
|
551
568
|
}
|
|
552
569
|
}
|
|
553
570
|
/** Get the configuration object used to create the overlay */
|
|
@@ -567,32 +584,22 @@ class CdkMenuItemTrigger {
|
|
|
567
584
|
}
|
|
568
585
|
/** Determine and return where to position the opened menu relative to the menu item */
|
|
569
586
|
_getOverlayPositions() {
|
|
570
|
-
|
|
571
|
-
return !this._parentMenu || this._parentMenu.orientation === 'horizontal'
|
|
572
|
-
?
|
|
573
|
-
|
|
574
|
-
{ originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' },
|
|
575
|
-
{ originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top' },
|
|
576
|
-
{ originX: 'end', originY: 'top', overlayX: 'end', overlayY: 'bottom' },
|
|
577
|
-
]
|
|
578
|
-
: [
|
|
579
|
-
{ originX: 'end', originY: 'top', overlayX: 'start', overlayY: 'top' },
|
|
580
|
-
{ originX: 'end', originY: 'bottom', overlayX: 'start', overlayY: 'bottom' },
|
|
581
|
-
{ originX: 'start', originY: 'top', overlayX: 'end', overlayY: 'top' },
|
|
582
|
-
{ originX: 'start', originY: 'bottom', overlayX: 'end', overlayY: 'bottom' },
|
|
583
|
-
];
|
|
587
|
+
var _a;
|
|
588
|
+
return ((_a = this.menuPosition) !== null && _a !== void 0 ? _a : (!this._parentMenu || this._parentMenu.orientation === 'horizontal'
|
|
589
|
+
? STANDARD_DROPDOWN_BELOW_POSITIONS
|
|
590
|
+
: STANDARD_DROPDOWN_ADJACENT_POSITIONS));
|
|
584
591
|
}
|
|
585
592
|
/**
|
|
586
593
|
* Get the portal to be attached to the overlay which contains the menu. Allows for the menu
|
|
587
594
|
* content to change dynamically and be reflected in the application.
|
|
588
595
|
*/
|
|
589
596
|
_getPortal() {
|
|
590
|
-
var _a
|
|
591
|
-
const hasMenuContentChanged =
|
|
592
|
-
if (this.
|
|
593
|
-
this.
|
|
597
|
+
var _a;
|
|
598
|
+
const hasMenuContentChanged = this._menuTemplateRef !== ((_a = this._menuPortal) === null || _a === void 0 ? void 0 : _a.templateRef);
|
|
599
|
+
if (this._menuTemplateRef && (!this._menuPortal || hasMenuContentChanged)) {
|
|
600
|
+
this._menuPortal = new TemplatePortal(this._menuTemplateRef, this._viewContainerRef, undefined, this.getChildMenuInjector());
|
|
594
601
|
}
|
|
595
|
-
return this.
|
|
602
|
+
return this._menuPortal;
|
|
596
603
|
}
|
|
597
604
|
/**
|
|
598
605
|
* @return true if if the enclosing parent menu is configured in a vertical orientation.
|
|
@@ -607,40 +614,18 @@ class CdkMenuItemTrigger {
|
|
|
607
614
|
*/
|
|
608
615
|
_registerCloseHandler() {
|
|
609
616
|
if (!this._parentMenu) {
|
|
610
|
-
this.
|
|
611
|
-
|
|
612
|
-
if (item === ((_a = this._menuPanel) === null || _a === void 0 ? void 0 : _a._menu)) {
|
|
617
|
+
this.menuStack.closed.pipe(takeUntil(this._destroyed)).subscribe(item => {
|
|
618
|
+
if (item === this.childMenu) {
|
|
613
619
|
this.closeMenu();
|
|
614
620
|
}
|
|
615
621
|
});
|
|
616
622
|
}
|
|
617
623
|
}
|
|
618
|
-
/** Get the menu stack for this trigger - either from the parent or this trigger. */
|
|
619
|
-
_getMenuStack() {
|
|
620
|
-
var _a;
|
|
621
|
-
// We use a function since at the construction of the MenuItemTrigger the parent Menu won't have
|
|
622
|
-
// its menu stack set. Therefore we need to reference the menu stack from the parent each time
|
|
623
|
-
// we want to use it.
|
|
624
|
-
return ((_a = this._parentMenu) === null || _a === void 0 ? void 0 : _a._menuStack) || this._menuStack;
|
|
625
|
-
}
|
|
626
624
|
ngOnDestroy() {
|
|
627
625
|
this._destroyOverlay();
|
|
628
|
-
this._resetPanelMenuStack();
|
|
629
626
|
this._destroyed.next();
|
|
630
627
|
this._destroyed.complete();
|
|
631
628
|
}
|
|
632
|
-
/** Set the menu panels menu stack back to null. */
|
|
633
|
-
_resetPanelMenuStack() {
|
|
634
|
-
// If a CdkMenuTrigger is placed in a submenu, each time the trigger is rendered (its parent
|
|
635
|
-
// menu is opened) the panel setter for CdkMenuPanel is called. From the first render onward,
|
|
636
|
-
// the attached CdkMenuPanel has the MenuStack set. Since we throw an error if a panel already
|
|
637
|
-
// has a stack set, we want to reset the attached stack here to prevent the error from being
|
|
638
|
-
// thrown if the trigger re-configures its attached panel (in the case where there is a 1:1
|
|
639
|
-
// relationship between the panel and trigger).
|
|
640
|
-
if (this._menuPanel) {
|
|
641
|
-
this._menuPanel._menuStack = null;
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
629
|
/**
|
|
645
630
|
* Subscribe to the overlays outside pointer events stream and handle closing out the stack if a
|
|
646
631
|
* click occurs outside the menus.
|
|
@@ -652,7 +637,7 @@ class CdkMenuItemTrigger {
|
|
|
652
637
|
.pipe(takeUntil(this._stopOutsideClicksListener))
|
|
653
638
|
.subscribe(event => {
|
|
654
639
|
if (!isClickInsideMenuOverlay(event.target)) {
|
|
655
|
-
this.
|
|
640
|
+
this.menuStack.closeAll();
|
|
656
641
|
}
|
|
657
642
|
});
|
|
658
643
|
}
|
|
@@ -665,9 +650,16 @@ class CdkMenuItemTrigger {
|
|
|
665
650
|
}
|
|
666
651
|
}
|
|
667
652
|
}
|
|
668
|
-
CdkMenuItemTrigger.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
669
|
-
CdkMenuItemTrigger.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
670
|
-
|
|
653
|
+
CdkMenuItemTrigger.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuItemTrigger, deps: [{ token: i0.Injector }, { token: i0.ElementRef }, { token: i0.ViewContainerRef }, { token: i1.Overlay }, { token: i0.NgZone }, { token: MENU_STACK }, { token: CDK_MENU, optional: true }, { token: MENU_AIM, optional: true }, { token: i1$1.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
654
|
+
CdkMenuItemTrigger.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.6", type: CdkMenuItemTrigger, selector: "[cdkMenuTriggerFor]", inputs: { _menuTemplateRef: ["cdkMenuTriggerFor", "_menuTemplateRef"], menuPosition: ["cdkMenuPosition", "menuPosition"] }, outputs: { opened: "cdkMenuOpened", closed: "cdkMenuClosed" }, host: { attributes: { "aria-haspopup": "menu" }, listeners: { "keydown": "_toggleOnKeydown($event)", "click": "toggle()" }, properties: { "attr.aria-expanded": "isMenuOpen()" }, classAttribute: "cdk-menu-trigger" }, providers: [
|
|
655
|
+
{ provide: MENU_TRIGGER, useExisting: CdkMenuItemTrigger },
|
|
656
|
+
{
|
|
657
|
+
provide: MENU_STACK,
|
|
658
|
+
deps: [[new Optional(), new SkipSelf(), new Inject(MENU_STACK)]],
|
|
659
|
+
useFactory: (parentMenuStack) => parentMenuStack || new MenuStack(),
|
|
660
|
+
},
|
|
661
|
+
], exportAs: ["cdkMenuTriggerFor"], usesInheritance: true, ngImport: i0 });
|
|
662
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuItemTrigger, decorators: [{
|
|
671
663
|
type: Directive,
|
|
672
664
|
args: [{
|
|
673
665
|
selector: '[cdkMenuTriggerFor]',
|
|
@@ -679,9 +671,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
679
671
|
'aria-haspopup': 'menu',
|
|
680
672
|
'[attr.aria-expanded]': 'isMenuOpen()',
|
|
681
673
|
},
|
|
674
|
+
providers: [
|
|
675
|
+
{ provide: MENU_TRIGGER, useExisting: CdkMenuItemTrigger },
|
|
676
|
+
{
|
|
677
|
+
provide: MENU_STACK,
|
|
678
|
+
deps: [[new Optional(), new SkipSelf(), new Inject(MENU_STACK)]],
|
|
679
|
+
useFactory: (parentMenuStack) => parentMenuStack || new MenuStack(),
|
|
680
|
+
},
|
|
681
|
+
],
|
|
682
682
|
}]
|
|
683
683
|
}], ctorParameters: function () {
|
|
684
|
-
return [{ type: i0.ElementRef }, { type: i0.ViewContainerRef }, { type: i1.Overlay }, { type: i0.NgZone }, { type:
|
|
684
|
+
return [{ type: i0.Injector }, { type: i0.ElementRef }, { type: i0.ViewContainerRef }, { type: i1.Overlay }, { type: i0.NgZone }, { type: MenuStack, decorators: [{
|
|
685
|
+
type: Inject,
|
|
686
|
+
args: [MENU_STACK]
|
|
687
|
+
}] }, { type: undefined, decorators: [{
|
|
685
688
|
type: Optional
|
|
686
689
|
}, {
|
|
687
690
|
type: Inject,
|
|
@@ -691,12 +694,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
691
694
|
}, {
|
|
692
695
|
type: Inject,
|
|
693
696
|
args: [MENU_AIM]
|
|
694
|
-
}] }, { type:
|
|
697
|
+
}] }, { type: i1$1.Directionality, decorators: [{
|
|
695
698
|
type: Optional
|
|
696
699
|
}] }];
|
|
697
|
-
}, propDecorators: {
|
|
700
|
+
}, propDecorators: { _menuTemplateRef: [{
|
|
698
701
|
type: Input,
|
|
699
702
|
args: ['cdkMenuTriggerFor']
|
|
703
|
+
}], menuPosition: [{
|
|
704
|
+
type: Input,
|
|
705
|
+
args: ['cdkMenuPosition']
|
|
700
706
|
}], opened: [{
|
|
701
707
|
type: Output,
|
|
702
708
|
args: ['cdkMenuOpened']
|
|
@@ -712,26 +718,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
712
718
|
* Use of this source code is governed by an MIT-style license that can be
|
|
713
719
|
* found in the LICENSE file at https://angular.io/license
|
|
714
720
|
*/
|
|
715
|
-
// TODO refactor this to be configurable allowing for custom elements to be removed
|
|
716
|
-
/** Removes all icons from within the given element. */
|
|
717
|
-
function removeIcons(element) {
|
|
718
|
-
for (const icon of Array.from(element.querySelectorAll('mat-icon, .material-icons'))) {
|
|
719
|
-
icon.remove();
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
721
|
/**
|
|
723
722
|
* Directive which provides the ability for an element to be focused and navigated to using the
|
|
724
723
|
* keyboard when residing in a CdkMenu, CdkMenuBar, or CdkMenuGroup. It performs user defined
|
|
725
724
|
* behavior when clicked.
|
|
726
725
|
*/
|
|
727
726
|
class CdkMenuItem {
|
|
728
|
-
constructor(_elementRef, _ngZone, _parentMenu, _menuAim, _dir,
|
|
727
|
+
constructor(_elementRef, _ngZone, _menuStack, _parentMenu, _menuAim, _dir,
|
|
729
728
|
/** Reference to the CdkMenuItemTrigger directive if one is added to the same element */
|
|
730
729
|
// `CdkMenuItem` is commonly used in combination with a `CdkMenuItemTrigger`.
|
|
731
730
|
// tslint:disable-next-line: lightweight-tokens
|
|
732
731
|
_menuTrigger) {
|
|
733
732
|
this._elementRef = _elementRef;
|
|
734
733
|
this._ngZone = _ngZone;
|
|
734
|
+
this._menuStack = _menuStack;
|
|
735
735
|
this._parentMenu = _parentMenu;
|
|
736
736
|
this._menuAim = _menuAim;
|
|
737
737
|
this._dir = _dir;
|
|
@@ -781,7 +781,7 @@ class CdkMenuItem {
|
|
|
781
781
|
return;
|
|
782
782
|
}
|
|
783
783
|
// don't set the tabindex if there are no open sibling or parent menus
|
|
784
|
-
if (!event || !((_a = this.
|
|
784
|
+
if (!event || !((_a = this._menuStack) === null || _a === void 0 ? void 0 : _a.isEmpty())) {
|
|
785
785
|
this._tabindex = 0;
|
|
786
786
|
}
|
|
787
787
|
}
|
|
@@ -797,7 +797,7 @@ class CdkMenuItem {
|
|
|
797
797
|
var _a;
|
|
798
798
|
if (!this.disabled && !this.hasMenu()) {
|
|
799
799
|
this.triggered.next();
|
|
800
|
-
(_a = this.
|
|
800
|
+
(_a = this._menuStack) === null || _a === void 0 ? void 0 : _a.closeAll();
|
|
801
801
|
}
|
|
802
802
|
}
|
|
803
803
|
/** Whether the menu item opens a menu. */
|
|
@@ -825,11 +825,7 @@ class CdkMenuItem {
|
|
|
825
825
|
/** Get the label for this element which is required by the FocusableOption interface. */
|
|
826
826
|
getLabel() {
|
|
827
827
|
var _a;
|
|
828
|
-
|
|
829
|
-
// we know that the current node is an element type
|
|
830
|
-
const clone = this._elementRef.nativeElement.cloneNode(true);
|
|
831
|
-
removeIcons(clone);
|
|
832
|
-
return ((_a = clone.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '';
|
|
828
|
+
return this.typeahead || ((_a = this._elementRef.nativeElement.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '';
|
|
833
829
|
}
|
|
834
830
|
/**
|
|
835
831
|
* Handles keyboard events for the menu item, specifically either triggering the user defined
|
|
@@ -849,16 +845,16 @@ class CdkMenuItem {
|
|
|
849
845
|
if (this._parentMenu && this._isParentVertical() && !this.hasMenu()) {
|
|
850
846
|
event.preventDefault();
|
|
851
847
|
((_a = this._dir) === null || _a === void 0 ? void 0 : _a.value) === 'rtl'
|
|
852
|
-
? (_b = this.
|
|
853
|
-
: (_c = this.
|
|
848
|
+
? (_b = this._menuStack) === null || _b === void 0 ? void 0 : _b.close(this._parentMenu, 1 /* previousItem */)
|
|
849
|
+
: (_c = this._menuStack) === null || _c === void 0 ? void 0 : _c.closeAll(0 /* nextItem */);
|
|
854
850
|
}
|
|
855
851
|
break;
|
|
856
852
|
case LEFT_ARROW:
|
|
857
853
|
if (this._parentMenu && this._isParentVertical() && !this.hasMenu()) {
|
|
858
854
|
event.preventDefault();
|
|
859
855
|
((_d = this._dir) === null || _d === void 0 ? void 0 : _d.value) === 'rtl'
|
|
860
|
-
? (_e = this.
|
|
861
|
-
: (_f = this.
|
|
856
|
+
? (_e = this._menuStack) === null || _e === void 0 ? void 0 : _e.closeAll(0 /* nextItem */)
|
|
857
|
+
: (_f = this._menuStack) === null || _f === void 0 ? void 0 : _f.close(this._parentMenu, 1 /* previousItem */);
|
|
862
858
|
}
|
|
863
859
|
break;
|
|
864
860
|
}
|
|
@@ -869,9 +865,9 @@ class CdkMenuItem {
|
|
|
869
865
|
*/
|
|
870
866
|
_setupMouseEnter() {
|
|
871
867
|
if (!this._isStandaloneItem()) {
|
|
872
|
-
const closeOpenSiblings = () => this._ngZone.run(() => { var _a; return (_a = this.
|
|
868
|
+
const closeOpenSiblings = () => this._ngZone.run(() => { var _a; return (_a = this._menuStack) === null || _a === void 0 ? void 0 : _a.closeSubMenuOf(this._parentMenu); });
|
|
873
869
|
this._ngZone.runOutsideAngular(() => fromEvent(this._elementRef.nativeElement, 'mouseenter')
|
|
874
|
-
.pipe(filter(() => { var _a; return !((_a = this.
|
|
870
|
+
.pipe(filter(() => { var _a; return !((_a = this._menuStack) === null || _a === void 0 ? void 0 : _a.isEmpty()) && !this.hasMenu(); }), takeUntil(this._destroyed))
|
|
875
871
|
.subscribe(() => {
|
|
876
872
|
if (this._menuAim) {
|
|
877
873
|
this._menuAim.toggle(closeOpenSiblings);
|
|
@@ -890,21 +886,13 @@ class CdkMenuItem {
|
|
|
890
886
|
var _a;
|
|
891
887
|
return ((_a = this._parentMenu) === null || _a === void 0 ? void 0 : _a.orientation) === 'vertical';
|
|
892
888
|
}
|
|
893
|
-
/** Get the MenuStack from the parent menu. */
|
|
894
|
-
_getMenuStack() {
|
|
895
|
-
var _a;
|
|
896
|
-
// We use a function since at the construction of the MenuItemTrigger the parent Menu won't have
|
|
897
|
-
// its menu stack set. Therefore we need to reference the menu stack from the parent each time
|
|
898
|
-
// we want to use it.
|
|
899
|
-
return (_a = this._parentMenu) === null || _a === void 0 ? void 0 : _a._menuStack;
|
|
900
|
-
}
|
|
901
889
|
ngOnDestroy() {
|
|
902
890
|
this._destroyed.next();
|
|
903
891
|
}
|
|
904
892
|
}
|
|
905
|
-
CdkMenuItem.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
906
|
-
CdkMenuItem.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
907
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
893
|
+
CdkMenuItem.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuItem, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: MENU_STACK, optional: true }, { token: CDK_MENU, optional: true }, { token: MENU_AIM, optional: true }, { token: i1$1.Directionality, optional: true }, { token: CdkMenuItemTrigger, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
894
|
+
CdkMenuItem.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.6", type: CdkMenuItem, selector: "[cdkMenuItem]", inputs: { disabled: "disabled", typeahead: "typeahead" }, outputs: { triggered: "cdkMenuItemTriggered" }, host: { attributes: { "type": "button", "role": "menuitem" }, listeners: { "blur": "_resetTabIndex()", "mouseout": "_resetTabIndex()", "focus": "_setTabIndex()", "mouseenter": "_setTabIndex($event)", "click": "trigger()", "keydown": "_onKeydown($event)" }, properties: { "tabindex": "_tabindex", "attr.aria-disabled": "disabled || null" }, classAttribute: "cdk-menu-item" }, exportAs: ["cdkMenuItem"], ngImport: i0 });
|
|
895
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuItem, decorators: [{
|
|
908
896
|
type: Directive,
|
|
909
897
|
args: [{
|
|
910
898
|
selector: '[cdkMenuItem]',
|
|
@@ -924,7 +912,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
924
912
|
},
|
|
925
913
|
}]
|
|
926
914
|
}], ctorParameters: function () {
|
|
927
|
-
return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type:
|
|
915
|
+
return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: MenuStack, decorators: [{
|
|
916
|
+
type: Optional
|
|
917
|
+
}, {
|
|
918
|
+
type: Inject,
|
|
919
|
+
args: [MENU_STACK]
|
|
920
|
+
}] }, { type: undefined, decorators: [{
|
|
928
921
|
type: Optional
|
|
929
922
|
}, {
|
|
930
923
|
type: Inject,
|
|
@@ -934,7 +927,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
934
927
|
}, {
|
|
935
928
|
type: Inject,
|
|
936
929
|
args: [MENU_AIM]
|
|
937
|
-
}] }, { type:
|
|
930
|
+
}] }, { type: i1$1.Directionality, decorators: [{
|
|
938
931
|
type: Optional
|
|
939
932
|
}] }, { type: CdkMenuItemTrigger, decorators: [{
|
|
940
933
|
type: Self
|
|
@@ -943,6 +936,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
943
936
|
}] }];
|
|
944
937
|
}, propDecorators: { disabled: [{
|
|
945
938
|
type: Input
|
|
939
|
+
}], typeahead: [{
|
|
940
|
+
type: Input
|
|
946
941
|
}], triggered: [{
|
|
947
942
|
type: Output,
|
|
948
943
|
args: ['cdkMenuItemTriggered']
|
|
@@ -986,9 +981,9 @@ class CdkMenuItemSelectable extends CdkMenuItem {
|
|
|
986
981
|
}
|
|
987
982
|
}
|
|
988
983
|
}
|
|
989
|
-
CdkMenuItemSelectable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
990
|
-
CdkMenuItemSelectable.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
991
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
984
|
+
CdkMenuItemSelectable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuItemSelectable, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
985
|
+
CdkMenuItemSelectable.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.6", type: CdkMenuItemSelectable, inputs: { checked: "checked", name: "name", id: "id" }, outputs: { toggled: "cdkMenuItemToggled" }, usesInheritance: true, ngImport: i0 });
|
|
986
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuItemSelectable, decorators: [{
|
|
992
987
|
type: Directive
|
|
993
988
|
}], propDecorators: { toggled: [{
|
|
994
989
|
type: Output,
|
|
@@ -1044,9 +1039,9 @@ class CdkMenuGroup {
|
|
|
1044
1039
|
this._selectableChanges.complete();
|
|
1045
1040
|
}
|
|
1046
1041
|
}
|
|
1047
|
-
CdkMenuGroup.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1048
|
-
CdkMenuGroup.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1049
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1042
|
+
CdkMenuGroup.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1043
|
+
CdkMenuGroup.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.6", type: CdkMenuGroup, selector: "[cdkMenuGroup]", outputs: { change: "change" }, host: { attributes: { "role": "group" }, classAttribute: "cdk-menu-group" }, providers: [{ provide: UniqueSelectionDispatcher, useClass: UniqueSelectionDispatcher }], queries: [{ propertyName: "_selectableItems", predicate: CdkMenuItemSelectable, descendants: true }], exportAs: ["cdkMenuGroup"], ngImport: i0 });
|
|
1044
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuGroup, decorators: [{
|
|
1050
1045
|
type: Directive,
|
|
1051
1046
|
args: [{
|
|
1052
1047
|
selector: '[cdkMenuGroup]',
|
|
@@ -1111,42 +1106,6 @@ class PointerFocusTracker {
|
|
|
1111
1106
|
}
|
|
1112
1107
|
}
|
|
1113
1108
|
|
|
1114
|
-
/**
|
|
1115
|
-
* @license
|
|
1116
|
-
* Copyright Google LLC All Rights Reserved.
|
|
1117
|
-
*
|
|
1118
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
1119
|
-
* found in the LICENSE file at https://angular.io/license
|
|
1120
|
-
*/
|
|
1121
|
-
/**
|
|
1122
|
-
* Directive applied to an ng-template which wraps a CdkMenu and provides a reference to the
|
|
1123
|
-
* child element it wraps which allows for opening of the CdkMenu in an overlay.
|
|
1124
|
-
*/
|
|
1125
|
-
class CdkMenuPanel {
|
|
1126
|
-
constructor(_templateRef) {
|
|
1127
|
-
this._templateRef = _templateRef;
|
|
1128
|
-
}
|
|
1129
|
-
/**
|
|
1130
|
-
* Set the Menu component on the menu panel. Since we cannot use ContentChild to fetch the
|
|
1131
|
-
* child Menu component, the child Menu must register its self with the parent MenuPanel.
|
|
1132
|
-
*/
|
|
1133
|
-
_registerMenu(child) {
|
|
1134
|
-
var _a;
|
|
1135
|
-
this._menu = child;
|
|
1136
|
-
// The ideal solution would be to affect the CdkMenuPanel injector from the CdkMenuTrigger and
|
|
1137
|
-
// inject the menu stack reference into the child menu and menu items, however this isn't
|
|
1138
|
-
// possible at this time.
|
|
1139
|
-
this._menu._menuStack = this._menuStack;
|
|
1140
|
-
(_a = this._menuStack) === null || _a === void 0 ? void 0 : _a.push(child);
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
CdkMenuPanel.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.4", ngImport: i0, type: CdkMenuPanel, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1144
|
-
CdkMenuPanel.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.4", type: CdkMenuPanel, selector: "ng-template[cdkMenuPanel]", exportAs: ["cdkMenuPanel"], ngImport: i0 });
|
|
1145
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4", ngImport: i0, type: CdkMenuPanel, decorators: [{
|
|
1146
|
-
type: Directive,
|
|
1147
|
-
args: [{ selector: 'ng-template[cdkMenuPanel]', exportAs: 'cdkMenuPanel' }]
|
|
1148
|
-
}], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
|
|
1149
|
-
|
|
1150
1109
|
/**
|
|
1151
1110
|
* @license
|
|
1152
1111
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -1162,16 +1121,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
1162
1121
|
* It also acts as a RadioGroup for elements marked with role `menuitemradio`.
|
|
1163
1122
|
*/
|
|
1164
1123
|
class CdkMenu extends CdkMenuGroup {
|
|
1165
|
-
constructor(_ngZone, _elementRef, _menuAim, _dir
|
|
1166
|
-
// `CdkMenuPanel` is always used in combination with a `CdkMenu`.
|
|
1167
|
-
// tslint:disable-next-line: lightweight-tokens
|
|
1168
|
-
_menuPanel) {
|
|
1124
|
+
constructor(_ngZone, _elementRef, _menuStack, _parentTrigger, _menuAim, _dir) {
|
|
1169
1125
|
super();
|
|
1170
1126
|
this._ngZone = _ngZone;
|
|
1171
1127
|
this._elementRef = _elementRef;
|
|
1128
|
+
this._menuStack = _menuStack;
|
|
1129
|
+
this._parentTrigger = _parentTrigger;
|
|
1172
1130
|
this._menuAim = _menuAim;
|
|
1173
1131
|
this._dir = _dir;
|
|
1174
|
-
this._menuPanel = _menuPanel;
|
|
1175
1132
|
/**
|
|
1176
1133
|
* Sets the aria-orientation attribute and determines where menus will be opened.
|
|
1177
1134
|
* Does not affect styling/layout.
|
|
@@ -1179,14 +1136,11 @@ class CdkMenu extends CdkMenuGroup {
|
|
|
1179
1136
|
this.orientation = 'vertical';
|
|
1180
1137
|
/** Event emitted when the menu is closed. */
|
|
1181
1138
|
this.closed = new EventEmitter();
|
|
1182
|
-
// We provide a default MenuStack implementation in case the menu is an inline menu.
|
|
1183
|
-
// For Menus part of a MenuBar nested within a MenuPanel this will be overwritten
|
|
1184
|
-
// to the correct parent MenuStack.
|
|
1185
|
-
/** Track the Menus making up the open menu stack. */
|
|
1186
|
-
this._menuStack = new NoopMenuStack();
|
|
1187
1139
|
}
|
|
1188
1140
|
ngOnInit() {
|
|
1189
|
-
|
|
1141
|
+
var _a, _b;
|
|
1142
|
+
(_a = this._menuStack) === null || _a === void 0 ? void 0 : _a.push(this);
|
|
1143
|
+
(_b = this._parentTrigger) === null || _b === void 0 ? void 0 : _b.registerChildMenu(this);
|
|
1190
1144
|
}
|
|
1191
1145
|
ngAfterContentInit() {
|
|
1192
1146
|
var _a;
|
|
@@ -1210,6 +1164,7 @@ class CdkMenu extends CdkMenuGroup {
|
|
|
1210
1164
|
}
|
|
1211
1165
|
/** Handle keyboard events for the Menu. */
|
|
1212
1166
|
_handleKeyEvent(event) {
|
|
1167
|
+
var _a, _b;
|
|
1213
1168
|
const keyManager = this._keyManager;
|
|
1214
1169
|
switch (event.keyCode) {
|
|
1215
1170
|
case LEFT_ARROW:
|
|
@@ -1231,28 +1186,16 @@ class CdkMenu extends CdkMenuGroup {
|
|
|
1231
1186
|
case ESCAPE:
|
|
1232
1187
|
if (!hasModifierKey(event)) {
|
|
1233
1188
|
event.preventDefault();
|
|
1234
|
-
this._menuStack.close(this, 2 /* currentItem */);
|
|
1189
|
+
(_a = this._menuStack) === null || _a === void 0 ? void 0 : _a.close(this, 2 /* currentItem */);
|
|
1235
1190
|
}
|
|
1236
1191
|
break;
|
|
1237
1192
|
case TAB:
|
|
1238
|
-
this._menuStack.closeAll();
|
|
1193
|
+
(_b = this._menuStack) === null || _b === void 0 ? void 0 : _b.closeAll();
|
|
1239
1194
|
break;
|
|
1240
1195
|
default:
|
|
1241
1196
|
keyManager.onKeydown(event);
|
|
1242
1197
|
}
|
|
1243
1198
|
}
|
|
1244
|
-
/** Register this menu with its enclosing parent menu panel */
|
|
1245
|
-
_registerWithParentPanel() {
|
|
1246
|
-
var _a;
|
|
1247
|
-
(_a = this._getMenuPanel()) === null || _a === void 0 ? void 0 : _a._registerMenu(this);
|
|
1248
|
-
}
|
|
1249
|
-
/**
|
|
1250
|
-
* Get the enclosing CdkMenuPanel defaulting to the injected reference over the developer
|
|
1251
|
-
* provided reference.
|
|
1252
|
-
*/
|
|
1253
|
-
_getMenuPanel() {
|
|
1254
|
-
return this._menuPanel || this._explicitPanel;
|
|
1255
|
-
}
|
|
1256
1199
|
/**
|
|
1257
1200
|
* Complete the change emitter if there are any nested MenuGroups or register to complete the
|
|
1258
1201
|
* change emitter if a MenuGroup is rendered at some point
|
|
@@ -1301,12 +1244,9 @@ class CdkMenu extends CdkMenuGroup {
|
|
|
1301
1244
|
}
|
|
1302
1245
|
/** Subscribe to the MenuStack close and empty observables. */
|
|
1303
1246
|
_subscribeToMenuStack() {
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
this._menuStack.emptied
|
|
1308
|
-
.pipe(takeUntil(this.closed))
|
|
1309
|
-
.subscribe(event => this._toggleMenuFocus(event));
|
|
1247
|
+
var _a, _b;
|
|
1248
|
+
(_a = this._menuStack) === null || _a === void 0 ? void 0 : _a.closed.pipe(takeUntil(this.closed)).subscribe(item => this._closeOpenMenu(item));
|
|
1249
|
+
(_b = this._menuStack) === null || _b === void 0 ? void 0 : _b.emptied.pipe(takeUntil(this.closed)).subscribe(event => this._toggleMenuFocus(event));
|
|
1310
1250
|
}
|
|
1311
1251
|
/**
|
|
1312
1252
|
* Close the open menu if the current active item opened the requested MenuStackItem.
|
|
@@ -1370,9 +1310,7 @@ class CdkMenu extends CdkMenuGroup {
|
|
|
1370
1310
|
* always visible in the dom.
|
|
1371
1311
|
*/
|
|
1372
1312
|
_isInline() {
|
|
1373
|
-
|
|
1374
|
-
// automatically.
|
|
1375
|
-
return this._menuStack instanceof NoopMenuStack;
|
|
1313
|
+
return !this._menuStack;
|
|
1376
1314
|
}
|
|
1377
1315
|
ngOnDestroy() {
|
|
1378
1316
|
var _a;
|
|
@@ -1386,12 +1324,12 @@ class CdkMenu extends CdkMenuGroup {
|
|
|
1386
1324
|
this.closed.complete();
|
|
1387
1325
|
}
|
|
1388
1326
|
}
|
|
1389
|
-
CdkMenu.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1390
|
-
CdkMenu.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1327
|
+
CdkMenu.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenu, deps: [{ token: i0.NgZone }, { token: i0.ElementRef }, { token: MENU_STACK, optional: true }, { token: MENU_TRIGGER, optional: true }, { token: MENU_AIM, optional: true, self: true }, { token: i1$1.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1328
|
+
CdkMenu.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.6", type: CdkMenu, selector: "[cdkMenu]", inputs: { orientation: ["cdkMenuOrientation", "orientation"] }, outputs: { closed: "closed" }, host: { attributes: { "role": "menu" }, listeners: { "focus": "focusFirstItem()", "keydown": "_handleKeyEvent($event)" }, properties: { "tabindex": "_isInline() ? 0 : null", "class.cdk-menu-inline": "_isInline()", "attr.aria-orientation": "orientation" }, classAttribute: "cdk-menu" }, providers: [
|
|
1391
1329
|
{ provide: CdkMenuGroup, useExisting: CdkMenu },
|
|
1392
1330
|
{ provide: CDK_MENU, useExisting: CdkMenu },
|
|
1393
1331
|
], queries: [{ propertyName: "_nestedGroups", predicate: CdkMenuGroup, descendants: true }, { propertyName: "_allItems", predicate: CdkMenuItem, descendants: true }], exportAs: ["cdkMenu"], usesInheritance: true, ngImport: i0 });
|
|
1394
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1332
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenu, decorators: [{
|
|
1395
1333
|
type: Directive,
|
|
1396
1334
|
args: [{
|
|
1397
1335
|
selector: '[cdkMenu]',
|
|
@@ -1411,16 +1349,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
1411
1349
|
],
|
|
1412
1350
|
}]
|
|
1413
1351
|
}], ctorParameters: function () {
|
|
1414
|
-
return [{ type: i0.NgZone }, { type: i0.ElementRef }, { type:
|
|
1352
|
+
return [{ type: i0.NgZone }, { type: i0.ElementRef }, { type: MenuStack, decorators: [{
|
|
1353
|
+
type: Optional
|
|
1354
|
+
}, {
|
|
1355
|
+
type: Inject,
|
|
1356
|
+
args: [MENU_STACK]
|
|
1357
|
+
}] }, { type: MenuTrigger, decorators: [{
|
|
1358
|
+
type: Optional
|
|
1359
|
+
}, {
|
|
1360
|
+
type: Inject,
|
|
1361
|
+
args: [MENU_TRIGGER]
|
|
1362
|
+
}] }, { type: undefined, decorators: [{
|
|
1415
1363
|
type: Self
|
|
1416
1364
|
}, {
|
|
1417
1365
|
type: Optional
|
|
1418
1366
|
}, {
|
|
1419
1367
|
type: Inject,
|
|
1420
1368
|
args: [MENU_AIM]
|
|
1421
|
-
}] }, { type:
|
|
1422
|
-
type: Optional
|
|
1423
|
-
}] }, { type: CdkMenuPanel, decorators: [{
|
|
1369
|
+
}] }, { type: i1$1.Directionality, decorators: [{
|
|
1424
1370
|
type: Optional
|
|
1425
1371
|
}] }];
|
|
1426
1372
|
}, propDecorators: { orientation: [{
|
|
@@ -1434,9 +1380,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
1434
1380
|
}], _allItems: [{
|
|
1435
1381
|
type: ContentChildren,
|
|
1436
1382
|
args: [CdkMenuItem, { descendants: true }]
|
|
1437
|
-
}], _explicitPanel: [{
|
|
1438
|
-
type: Input,
|
|
1439
|
-
args: ['cdkMenuPanel']
|
|
1440
1383
|
}] } });
|
|
1441
1384
|
|
|
1442
1385
|
/**
|
|
@@ -1453,11 +1396,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
1453
1396
|
*
|
|
1454
1397
|
*/
|
|
1455
1398
|
class CdkMenuBar extends CdkMenuGroup {
|
|
1456
|
-
constructor(
|
|
1399
|
+
constructor(_ngZone, _elementRef, _menuStack, _menuAim, _dir) {
|
|
1457
1400
|
super();
|
|
1458
|
-
this._menuStack = _menuStack;
|
|
1459
1401
|
this._ngZone = _ngZone;
|
|
1460
1402
|
this._elementRef = _elementRef;
|
|
1403
|
+
this._menuStack = _menuStack;
|
|
1461
1404
|
this._menuAim = _menuAim;
|
|
1462
1405
|
this._dir = _dir;
|
|
1463
1406
|
/**
|
|
@@ -1640,13 +1583,13 @@ class CdkMenuBar extends CdkMenuGroup {
|
|
|
1640
1583
|
(_a = this._pointerTracker) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
1641
1584
|
}
|
|
1642
1585
|
}
|
|
1643
|
-
CdkMenuBar.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1644
|
-
CdkMenuBar.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1586
|
+
CdkMenuBar.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuBar, deps: [{ token: i0.NgZone }, { token: i0.ElementRef }, { token: MENU_STACK }, { token: MENU_AIM, optional: true, self: true }, { token: i1$1.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1587
|
+
CdkMenuBar.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.6", type: CdkMenuBar, selector: "[cdkMenuBar]", inputs: { orientation: ["cdkMenuBarOrientation", "orientation"] }, host: { attributes: { "role": "menubar", "tabindex": "0" }, listeners: { "focus": "focusFirstItem()", "keydown": "_handleKeyEvent($event)" }, properties: { "attr.aria-orientation": "orientation" }, classAttribute: "cdk-menu-bar" }, providers: [
|
|
1645
1588
|
{ provide: CdkMenuGroup, useExisting: CdkMenuBar },
|
|
1646
1589
|
{ provide: CDK_MENU, useExisting: CdkMenuBar },
|
|
1647
|
-
{ provide:
|
|
1590
|
+
{ provide: MENU_STACK, useClass: MenuStack },
|
|
1648
1591
|
], queries: [{ propertyName: "_allItems", predicate: CdkMenuItem, descendants: true }], exportAs: ["cdkMenuBar"], usesInheritance: true, ngImport: i0 });
|
|
1649
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1592
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuBar, decorators: [{
|
|
1650
1593
|
type: Directive,
|
|
1651
1594
|
args: [{
|
|
1652
1595
|
selector: '[cdkMenuBar]',
|
|
@@ -1662,18 +1605,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
1662
1605
|
providers: [
|
|
1663
1606
|
{ provide: CdkMenuGroup, useExisting: CdkMenuBar },
|
|
1664
1607
|
{ provide: CDK_MENU, useExisting: CdkMenuBar },
|
|
1665
|
-
{ provide:
|
|
1608
|
+
{ provide: MENU_STACK, useClass: MenuStack },
|
|
1666
1609
|
],
|
|
1667
1610
|
}]
|
|
1668
1611
|
}], ctorParameters: function () {
|
|
1669
|
-
return [{ type:
|
|
1612
|
+
return [{ type: i0.NgZone }, { type: i0.ElementRef }, { type: MenuStack, decorators: [{
|
|
1613
|
+
type: Inject,
|
|
1614
|
+
args: [MENU_STACK]
|
|
1615
|
+
}] }, { type: undefined, decorators: [{
|
|
1670
1616
|
type: Self
|
|
1671
1617
|
}, {
|
|
1672
1618
|
type: Optional
|
|
1673
1619
|
}, {
|
|
1674
1620
|
type: Inject,
|
|
1675
1621
|
args: [MENU_AIM]
|
|
1676
|
-
}] }, { type:
|
|
1622
|
+
}] }, { type: i1$1.Directionality, decorators: [{
|
|
1677
1623
|
type: Optional
|
|
1678
1624
|
}] }];
|
|
1679
1625
|
}, propDecorators: { orientation: [{
|
|
@@ -1690,12 +1636,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
1690
1636
|
* or `CdkMenuGroup` comprise a radio group with unique selection enforced.
|
|
1691
1637
|
*/
|
|
1692
1638
|
class CdkMenuItemRadio extends CdkMenuItemSelectable {
|
|
1693
|
-
constructor(_selectionDispatcher, element, ngZone, parentMenu, menuAim, dir,
|
|
1639
|
+
constructor(_selectionDispatcher, element, ngZone, menuStack, parentMenu, menuAim, dir,
|
|
1694
1640
|
/** Reference to the CdkMenuItemTrigger directive if one is added to the same element */
|
|
1695
1641
|
// `CdkMenuItemRadio` is commonly used in combination with a `CdkMenuItemTrigger`.
|
|
1696
1642
|
// tslint:disable-next-line: lightweight-tokens
|
|
1697
1643
|
menuTrigger) {
|
|
1698
|
-
super(element, ngZone, parentMenu, menuAim, dir, menuTrigger);
|
|
1644
|
+
super(element, ngZone, menuStack, parentMenu, menuAim, dir, menuTrigger);
|
|
1699
1645
|
this._selectionDispatcher = _selectionDispatcher;
|
|
1700
1646
|
this._registerDispatcherListener();
|
|
1701
1647
|
}
|
|
@@ -1715,12 +1661,12 @@ class CdkMenuItemRadio extends CdkMenuItemSelectable {
|
|
|
1715
1661
|
this._removeDispatcherListener();
|
|
1716
1662
|
}
|
|
1717
1663
|
}
|
|
1718
|
-
CdkMenuItemRadio.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1719
|
-
CdkMenuItemRadio.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1664
|
+
CdkMenuItemRadio.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuItemRadio, deps: [{ token: i1$2.UniqueSelectionDispatcher }, { token: i0.ElementRef }, { token: i0.NgZone }, { token: MENU_STACK, optional: true }, { token: CDK_MENU, optional: true }, { token: MENU_AIM, optional: true }, { token: i1$1.Directionality, optional: true }, { token: CdkMenuItemTrigger, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1665
|
+
CdkMenuItemRadio.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.6", type: CdkMenuItemRadio, selector: "[cdkMenuItemRadio]", host: { attributes: { "type": "button", "role": "menuitemradio" }, properties: { "tabindex": "_tabindex", "attr.aria-checked": "checked || null", "attr.aria-disabled": "disabled || null" } }, providers: [
|
|
1720
1666
|
{ provide: CdkMenuItemSelectable, useExisting: CdkMenuItemRadio },
|
|
1721
1667
|
{ provide: CdkMenuItem, useExisting: CdkMenuItemSelectable },
|
|
1722
1668
|
], exportAs: ["cdkMenuItemRadio"], usesInheritance: true, ngImport: i0 });
|
|
1723
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1669
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuItemRadio, decorators: [{
|
|
1724
1670
|
type: Directive,
|
|
1725
1671
|
args: [{
|
|
1726
1672
|
selector: '[cdkMenuItemRadio]',
|
|
@@ -1738,7 +1684,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
1738
1684
|
],
|
|
1739
1685
|
}]
|
|
1740
1686
|
}], ctorParameters: function () {
|
|
1741
|
-
return [{ type: i1$
|
|
1687
|
+
return [{ type: i1$2.UniqueSelectionDispatcher }, { type: i0.ElementRef }, { type: i0.NgZone }, { type: MenuStack, decorators: [{
|
|
1688
|
+
type: Optional
|
|
1689
|
+
}, {
|
|
1690
|
+
type: Inject,
|
|
1691
|
+
args: [MENU_STACK]
|
|
1692
|
+
}] }, { type: undefined, decorators: [{
|
|
1742
1693
|
type: Optional
|
|
1743
1694
|
}, {
|
|
1744
1695
|
type: Inject,
|
|
@@ -1748,7 +1699,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
1748
1699
|
}, {
|
|
1749
1700
|
type: Inject,
|
|
1750
1701
|
args: [MENU_AIM]
|
|
1751
|
-
}] }, { type:
|
|
1702
|
+
}] }, { type: i1$1.Directionality, decorators: [{
|
|
1752
1703
|
type: Optional
|
|
1753
1704
|
}] }, { type: CdkMenuItemTrigger, decorators: [{
|
|
1754
1705
|
type: Self
|
|
@@ -1777,12 +1728,12 @@ class CdkMenuItemCheckbox extends CdkMenuItemSelectable {
|
|
|
1777
1728
|
}
|
|
1778
1729
|
}
|
|
1779
1730
|
}
|
|
1780
|
-
CdkMenuItemCheckbox.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1781
|
-
CdkMenuItemCheckbox.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1731
|
+
CdkMenuItemCheckbox.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuItemCheckbox, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1732
|
+
CdkMenuItemCheckbox.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.6", type: CdkMenuItemCheckbox, selector: "[cdkMenuItemCheckbox]", host: { attributes: { "type": "button", "role": "menuitemcheckbox" }, properties: { "tabindex": "_tabindex", "attr.aria-checked": "checked || null", "attr.aria-disabled": "disabled || null" } }, providers: [
|
|
1782
1733
|
{ provide: CdkMenuItemSelectable, useExisting: CdkMenuItemCheckbox },
|
|
1783
1734
|
{ provide: CdkMenuItem, useExisting: CdkMenuItemSelectable },
|
|
1784
1735
|
], exportAs: ["cdkMenuItemCheckbox"], usesInheritance: true, ngImport: i0 });
|
|
1785
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1736
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuItemCheckbox, decorators: [{
|
|
1786
1737
|
type: Directive,
|
|
1787
1738
|
args: [{
|
|
1788
1739
|
selector: '[cdkMenuItemCheckbox]',
|
|
@@ -1808,6 +1759,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
1808
1759
|
* Use of this source code is governed by an MIT-style license that can be
|
|
1809
1760
|
* found in the LICENSE file at https://angular.io/license
|
|
1810
1761
|
*/
|
|
1762
|
+
// In cases where the first menu item in the context menu is a trigger the submenu opens on a
|
|
1763
|
+
// hover event. We offset the context menu 2px by default to prevent this from occurring.
|
|
1764
|
+
const CONTEXT_MENU_POSITIONS = STANDARD_DROPDOWN_BELOW_POSITIONS.map(position => {
|
|
1765
|
+
const offsetX = position.overlayX === 'start' ? 2 : -2;
|
|
1766
|
+
const offsetY = position.overlayY === 'top' ? 2 : -2;
|
|
1767
|
+
return Object.assign(Object.assign({}, position), { offsetX, offsetY });
|
|
1768
|
+
});
|
|
1811
1769
|
/** Tracks the last open context menu trigger across the entire application. */
|
|
1812
1770
|
class ContextMenuTracker {
|
|
1813
1771
|
/**
|
|
@@ -1822,25 +1780,23 @@ class ContextMenuTracker {
|
|
|
1822
1780
|
}
|
|
1823
1781
|
}
|
|
1824
1782
|
}
|
|
1825
|
-
ContextMenuTracker.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1826
|
-
ContextMenuTracker.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1827
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1783
|
+
ContextMenuTracker.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: ContextMenuTracker, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1784
|
+
ContextMenuTracker.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: ContextMenuTracker, providedIn: 'root' });
|
|
1785
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: ContextMenuTracker, decorators: [{
|
|
1828
1786
|
type: Injectable,
|
|
1829
1787
|
args: [{ providedIn: 'root' }]
|
|
1830
1788
|
}] });
|
|
1831
|
-
/** Injection token for the ContextMenu options object. */
|
|
1832
|
-
const CDK_CONTEXT_MENU_DEFAULT_OPTIONS = new InjectionToken('cdk-context-menu-default-options');
|
|
1833
1789
|
/**
|
|
1834
1790
|
* A directive which when placed on some element opens a the Menu it is bound to when a user
|
|
1835
1791
|
* right-clicks within that element. It is aware of nested Context Menus and the lowest level
|
|
1836
1792
|
* non-disabled context menu will trigger.
|
|
1837
1793
|
*/
|
|
1838
|
-
class CdkContextMenuTrigger {
|
|
1839
|
-
constructor(_viewContainerRef, _overlay, _contextMenuTracker,
|
|
1794
|
+
class CdkContextMenuTrigger extends MenuTrigger {
|
|
1795
|
+
constructor(injector, _viewContainerRef, _overlay, _contextMenuTracker, menuStack, _directionality) {
|
|
1796
|
+
super(injector, menuStack);
|
|
1840
1797
|
this._viewContainerRef = _viewContainerRef;
|
|
1841
1798
|
this._overlay = _overlay;
|
|
1842
1799
|
this._contextMenuTracker = _contextMenuTracker;
|
|
1843
|
-
this._options = _options;
|
|
1844
1800
|
this._directionality = _directionality;
|
|
1845
1801
|
/** Emits when the attached menu is requested to open. */
|
|
1846
1802
|
this.opened = new EventEmitter();
|
|
@@ -1851,25 +1807,10 @@ class CdkContextMenuTrigger {
|
|
|
1851
1807
|
this._overlayRef = null;
|
|
1852
1808
|
/** Emits when the element is destroyed. */
|
|
1853
1809
|
this._destroyed = new Subject();
|
|
1854
|
-
/** The menu stack for this trigger and its associated menus. */
|
|
1855
|
-
this._menuStack = new MenuStack();
|
|
1856
1810
|
/** Emits when the outside pointer events listener on the overlay should be stopped. */
|
|
1857
1811
|
this._stopOutsideClicksListener = merge(this.closed, this._destroyed);
|
|
1858
1812
|
this._setMenuStackListener();
|
|
1859
1813
|
}
|
|
1860
|
-
/** Template reference variable to the menu to open on right click. */
|
|
1861
|
-
get menuPanel() {
|
|
1862
|
-
return this._menuPanel;
|
|
1863
|
-
}
|
|
1864
|
-
set menuPanel(panel) {
|
|
1865
|
-
if ((typeof ngDevMode === 'undefined' || ngDevMode) && panel._menuStack) {
|
|
1866
|
-
throwExistingMenuStackError();
|
|
1867
|
-
}
|
|
1868
|
-
this._menuPanel = panel;
|
|
1869
|
-
if (this._menuPanel) {
|
|
1870
|
-
this._menuPanel._menuStack = this._menuStack;
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1873
1814
|
/** Whether the context menu should be disabled. */
|
|
1874
1815
|
get disabled() {
|
|
1875
1816
|
return this._disabled;
|
|
@@ -1891,7 +1832,7 @@ class CdkContextMenuTrigger {
|
|
|
1891
1832
|
else if (this.isOpen()) {
|
|
1892
1833
|
// since we're moving this menu we need to close any submenus first otherwise they end up
|
|
1893
1834
|
// disconnected from this one.
|
|
1894
|
-
this.
|
|
1835
|
+
this.menuStack.closeSubMenuOf(this.childMenu);
|
|
1895
1836
|
this._overlayRef.getConfig().positionStrategy.setOrigin(coordinates);
|
|
1896
1837
|
this._overlayRef.updatePosition();
|
|
1897
1838
|
}
|
|
@@ -1910,7 +1851,7 @@ class CdkContextMenuTrigger {
|
|
|
1910
1851
|
}
|
|
1911
1852
|
/** Close the opened menu. */
|
|
1912
1853
|
close() {
|
|
1913
|
-
this.
|
|
1854
|
+
this.menuStack.closeAll();
|
|
1914
1855
|
}
|
|
1915
1856
|
/**
|
|
1916
1857
|
* Open the context menu and close any previously open menus.
|
|
@@ -1929,13 +1870,13 @@ class CdkContextMenuTrigger {
|
|
|
1929
1870
|
this._open({ x: event.clientX, y: event.clientY }, true);
|
|
1930
1871
|
// A context menu can be triggered via a mouse right click or a keyboard shortcut.
|
|
1931
1872
|
if (event.button === 2) {
|
|
1932
|
-
(_a = this.
|
|
1873
|
+
(_a = this.childMenu) === null || _a === void 0 ? void 0 : _a.focusFirstItem('mouse');
|
|
1933
1874
|
}
|
|
1934
1875
|
else if (event.button === 0) {
|
|
1935
|
-
(_b = this.
|
|
1876
|
+
(_b = this.childMenu) === null || _b === void 0 ? void 0 : _b.focusFirstItem('keyboard');
|
|
1936
1877
|
}
|
|
1937
1878
|
else {
|
|
1938
|
-
(_c = this.
|
|
1879
|
+
(_c = this.childMenu) === null || _c === void 0 ? void 0 : _c.focusFirstItem('program');
|
|
1939
1880
|
}
|
|
1940
1881
|
}
|
|
1941
1882
|
}
|
|
@@ -1960,24 +1901,11 @@ class CdkContextMenuTrigger {
|
|
|
1960
1901
|
* @param coordinates the location to place the opened menu
|
|
1961
1902
|
*/
|
|
1962
1903
|
_getOverlayPositionStrategy(coordinates) {
|
|
1904
|
+
var _a;
|
|
1963
1905
|
return this._overlay
|
|
1964
1906
|
.position()
|
|
1965
1907
|
.flexibleConnectedTo(coordinates)
|
|
1966
|
-
.
|
|
1967
|
-
.withDefaultOffsetY(this._options.offsetY)
|
|
1968
|
-
.withPositions(this._getOverlayPositions());
|
|
1969
|
-
}
|
|
1970
|
-
/**
|
|
1971
|
-
* Determine and return where to position the opened menu relative to the mouse location.
|
|
1972
|
-
*/
|
|
1973
|
-
_getOverlayPositions() {
|
|
1974
|
-
// TODO: this should be configurable through the injected context menu options
|
|
1975
|
-
return [
|
|
1976
|
-
{ originX: 'end', originY: 'top', overlayX: 'start', overlayY: 'top' },
|
|
1977
|
-
{ originX: 'start', originY: 'top', overlayX: 'end', overlayY: 'top' },
|
|
1978
|
-
{ originX: 'end', originY: 'bottom', overlayX: 'start', overlayY: 'bottom' },
|
|
1979
|
-
{ originX: 'start', originY: 'bottom', overlayX: 'end', overlayY: 'bottom' },
|
|
1980
|
-
];
|
|
1908
|
+
.withPositions((_a = this.menuPosition) !== null && _a !== void 0 ? _a : CONTEXT_MENU_POSITIONS);
|
|
1981
1909
|
}
|
|
1982
1910
|
/**
|
|
1983
1911
|
* Get the portal to be attached to the overlay which contains the menu. Allows for the menu
|
|
@@ -1985,16 +1913,16 @@ class CdkContextMenuTrigger {
|
|
|
1985
1913
|
*/
|
|
1986
1914
|
_getMenuContent() {
|
|
1987
1915
|
var _a;
|
|
1988
|
-
const hasMenuContentChanged = this.
|
|
1989
|
-
if (this.
|
|
1990
|
-
this.
|
|
1916
|
+
const hasMenuContentChanged = this._menuTemplateRef !== ((_a = this._menuPortal) === null || _a === void 0 ? void 0 : _a.templateRef);
|
|
1917
|
+
if (this._menuTemplateRef && (!this._menuPortal || hasMenuContentChanged)) {
|
|
1918
|
+
this._menuPortal = new TemplatePortal(this._menuTemplateRef, this._viewContainerRef, undefined, this.getChildMenuInjector());
|
|
1991
1919
|
}
|
|
1992
|
-
return this.
|
|
1920
|
+
return this._menuPortal;
|
|
1993
1921
|
}
|
|
1994
1922
|
/** Subscribe to the menu stack close events and close this menu when requested. */
|
|
1995
1923
|
_setMenuStackListener() {
|
|
1996
|
-
this.
|
|
1997
|
-
if (item === this.
|
|
1924
|
+
this.menuStack.closed.pipe(takeUntil(this._destroyed)).subscribe(item => {
|
|
1925
|
+
if (item === this.childMenu && this.isOpen()) {
|
|
1998
1926
|
this.closed.next();
|
|
1999
1927
|
this._overlayRef.detach();
|
|
2000
1928
|
}
|
|
@@ -2015,14 +1943,13 @@ class CdkContextMenuTrigger {
|
|
|
2015
1943
|
}
|
|
2016
1944
|
outsideClicks.pipe(takeUntil(this._stopOutsideClicksListener)).subscribe(event => {
|
|
2017
1945
|
if (!isClickInsideMenuOverlay(event.target)) {
|
|
2018
|
-
this.
|
|
1946
|
+
this.menuStack.closeAll();
|
|
2019
1947
|
}
|
|
2020
1948
|
});
|
|
2021
1949
|
}
|
|
2022
1950
|
}
|
|
2023
1951
|
ngOnDestroy() {
|
|
2024
1952
|
this._destroyOverlay();
|
|
2025
|
-
this._resetPanelMenuStack();
|
|
2026
1953
|
this._destroyed.next();
|
|
2027
1954
|
this._destroyed.complete();
|
|
2028
1955
|
}
|
|
@@ -2033,26 +1960,13 @@ class CdkContextMenuTrigger {
|
|
|
2033
1960
|
this._overlayRef = null;
|
|
2034
1961
|
}
|
|
2035
1962
|
}
|
|
2036
|
-
/** Set the menu panels menu stack back to null. */
|
|
2037
|
-
_resetPanelMenuStack() {
|
|
2038
|
-
// If a ContextMenuTrigger is placed in a conditionally rendered view, each time the trigger is
|
|
2039
|
-
// rendered the panel setter for ContextMenuTrigger is called. From the first render onward,
|
|
2040
|
-
// the attached CdkMenuPanel has the MenuStack set. Since we throw an error if a panel already
|
|
2041
|
-
// has a stack set, we want to reset the attached stack here to prevent the error from being
|
|
2042
|
-
// thrown if the trigger re-configures its attached panel (in the case where there is a 1:1
|
|
2043
|
-
// relationship between the panel and trigger).
|
|
2044
|
-
if (this._menuPanel) {
|
|
2045
|
-
this._menuPanel._menuStack = null;
|
|
2046
|
-
}
|
|
2047
|
-
}
|
|
2048
1963
|
}
|
|
2049
|
-
CdkContextMenuTrigger.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
2050
|
-
CdkContextMenuTrigger.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4", ngImport: i0, type: CdkContextMenuTrigger, decorators: [{
|
|
1964
|
+
CdkContextMenuTrigger.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkContextMenuTrigger, deps: [{ token: i0.Injector }, { token: i0.ViewContainerRef }, { token: i1.Overlay }, { token: ContextMenuTracker }, { token: MENU_STACK }, { token: i1$1.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1965
|
+
CdkContextMenuTrigger.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.6", type: CdkContextMenuTrigger, selector: "[cdkContextMenuTriggerFor]", inputs: { _menuTemplateRef: ["cdkContextMenuTriggerFor", "_menuTemplateRef"], menuPosition: ["cdkMenuPosition", "menuPosition"], disabled: ["cdkContextMenuDisabled", "disabled"] }, outputs: { opened: "cdkContextMenuOpened", closed: "cdkContextMenuClosed" }, host: { listeners: { "contextmenu": "_openOnContextMenu($event)" } }, providers: [
|
|
1966
|
+
{ provide: MENU_TRIGGER, useExisting: CdkContextMenuTrigger },
|
|
1967
|
+
{ provide: MENU_STACK, useClass: MenuStack },
|
|
1968
|
+
], exportAs: ["cdkContextMenuTriggerFor"], usesInheritance: true, ngImport: i0 });
|
|
1969
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkContextMenuTrigger, decorators: [{
|
|
2056
1970
|
type: Directive,
|
|
2057
1971
|
args: [{
|
|
2058
1972
|
selector: '[cdkContextMenuTriggerFor]',
|
|
@@ -2061,21 +1975,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
2061
1975
|
'(contextmenu)': '_openOnContextMenu($event)',
|
|
2062
1976
|
},
|
|
2063
1977
|
providers: [
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
{ provide: CDK_CONTEXT_MENU_DEFAULT_OPTIONS, useValue: { offsetX: 2, offsetY: 2 } },
|
|
1978
|
+
{ provide: MENU_TRIGGER, useExisting: CdkContextMenuTrigger },
|
|
1979
|
+
{ provide: MENU_STACK, useClass: MenuStack },
|
|
2067
1980
|
],
|
|
2068
1981
|
}]
|
|
2069
1982
|
}], ctorParameters: function () {
|
|
2070
|
-
return [{ type: i0.ViewContainerRef }, { type: i1.Overlay }, { type: ContextMenuTracker }, { type:
|
|
1983
|
+
return [{ type: i0.Injector }, { type: i0.ViewContainerRef }, { type: i1.Overlay }, { type: ContextMenuTracker }, { type: MenuStack, decorators: [{
|
|
2071
1984
|
type: Inject,
|
|
2072
|
-
args: [
|
|
2073
|
-
}] }, { type:
|
|
1985
|
+
args: [MENU_STACK]
|
|
1986
|
+
}] }, { type: i1$1.Directionality, decorators: [{
|
|
2074
1987
|
type: Optional
|
|
2075
1988
|
}] }];
|
|
2076
|
-
}, propDecorators: {
|
|
1989
|
+
}, propDecorators: { _menuTemplateRef: [{
|
|
2077
1990
|
type: Input,
|
|
2078
1991
|
args: ['cdkContextMenuTriggerFor']
|
|
1992
|
+
}], menuPosition: [{
|
|
1993
|
+
type: Input,
|
|
1994
|
+
args: ['cdkMenuPosition']
|
|
2079
1995
|
}], opened: [{
|
|
2080
1996
|
type: Output,
|
|
2081
1997
|
args: ['cdkContextMenuOpened']
|
|
@@ -2097,7 +2013,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
2097
2013
|
const EXPORTED_DECLARATIONS = [
|
|
2098
2014
|
CdkMenuBar,
|
|
2099
2015
|
CdkMenu,
|
|
2100
|
-
CdkMenuPanel,
|
|
2101
2016
|
CdkMenuItem,
|
|
2102
2017
|
CdkMenuItemRadio,
|
|
2103
2018
|
CdkMenuItemCheckbox,
|
|
@@ -2108,10 +2023,9 @@ const EXPORTED_DECLARATIONS = [
|
|
|
2108
2023
|
];
|
|
2109
2024
|
class CdkMenuModule {
|
|
2110
2025
|
}
|
|
2111
|
-
CdkMenuModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
2112
|
-
CdkMenuModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
2026
|
+
CdkMenuModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2027
|
+
CdkMenuModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuModule, declarations: [CdkMenuBar,
|
|
2113
2028
|
CdkMenu,
|
|
2114
|
-
CdkMenuPanel,
|
|
2115
2029
|
CdkMenuItem,
|
|
2116
2030
|
CdkMenuItemRadio,
|
|
2117
2031
|
CdkMenuItemCheckbox,
|
|
@@ -2120,7 +2034,6 @@ CdkMenuModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version:
|
|
|
2120
2034
|
CdkContextMenuTrigger,
|
|
2121
2035
|
CdkTargetMenuAim], imports: [OverlayModule], exports: [CdkMenuBar,
|
|
2122
2036
|
CdkMenu,
|
|
2123
|
-
CdkMenuPanel,
|
|
2124
2037
|
CdkMenuItem,
|
|
2125
2038
|
CdkMenuItemRadio,
|
|
2126
2039
|
CdkMenuItemCheckbox,
|
|
@@ -2128,8 +2041,8 @@ CdkMenuModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version:
|
|
|
2128
2041
|
CdkMenuGroup,
|
|
2129
2042
|
CdkContextMenuTrigger,
|
|
2130
2043
|
CdkTargetMenuAim] });
|
|
2131
|
-
CdkMenuModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
2132
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
2044
|
+
CdkMenuModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuModule, imports: [[OverlayModule]] });
|
|
2045
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6", ngImport: i0, type: CdkMenuModule, decorators: [{
|
|
2133
2046
|
type: NgModule,
|
|
2134
2047
|
args: [{
|
|
2135
2048
|
imports: [OverlayModule],
|
|
@@ -2158,5 +2071,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.4",
|
|
|
2158
2071
|
* Generated bundle index. Do not edit.
|
|
2159
2072
|
*/
|
|
2160
2073
|
|
|
2161
|
-
export {
|
|
2074
|
+
export { CDK_MENU, CdkContextMenuTrigger, CdkMenu, CdkMenuBar, CdkMenuGroup, CdkMenuItem, CdkMenuItemCheckbox, CdkMenuItemRadio, CdkMenuItemTrigger, CdkMenuModule, CdkTargetMenuAim, ContextMenuTracker, MENU_AIM, MENU_STACK, MENU_TRIGGER, MenuStack, MenuTrigger, TargetMenuAim, isClickInsideMenuOverlay };
|
|
2162
2075
|
//# sourceMappingURL=menu.mjs.map
|