@angular/cdk-experimental 14.0.0-next.8 → 14.0.0-next.9
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/dialog/dialog-config.d.ts +6 -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 +4 -4
- package/esm2020/combobox/combobox-popup.mjs +3 -3
- package/esm2020/combobox/combobox.mjs +3 -3
- package/esm2020/dialog/dialog-config.mjs +1 -1
- package/esm2020/dialog/dialog-container.mjs +5 -5
- package/esm2020/dialog/dialog-module.mjs +4 -4
- package/esm2020/dialog/dialog.mjs +5 -5
- package/esm2020/listbox/listbox-module.mjs +4 -4
- package/esm2020/listbox/listbox.mjs +6 -6
- package/esm2020/menu/context-menu.mjs +12 -48
- package/esm2020/menu/menu-aim.mjs +6 -6
- package/esm2020/menu/menu-bar.mjs +39 -130
- package/esm2020/menu/menu-base.mjs +129 -0
- package/esm2020/menu/menu-group.mjs +9 -9
- package/esm2020/menu/menu-interface.mjs +1 -1
- package/esm2020/menu/menu-item-checkbox.mjs +3 -3
- package/esm2020/menu/menu-item-radio.mjs +4 -6
- package/esm2020/menu/menu-item-selectable.mjs +3 -3
- package/esm2020/menu/menu-item-trigger.mjs +30 -90
- package/esm2020/menu/menu-item.mjs +36 -22
- package/esm2020/menu/menu-module.mjs +4 -4
- package/esm2020/menu/menu-stack.mjs +26 -5
- package/esm2020/menu/menu-trigger.mjs +35 -8
- package/esm2020/menu/menu.mjs +43 -127
- 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/combobox.mjs +10 -10
- package/fesm2015/dialog.mjs +13 -12
- package/fesm2015/dialog.mjs.map +1 -1
- package/fesm2015/listbox.mjs +10 -10
- package/fesm2015/menu.mjs +353 -445
- package/fesm2015/menu.mjs.map +1 -1
- package/fesm2015/popover-edit.mjs +49 -49
- package/fesm2015/scrolling.mjs +7 -7
- package/fesm2015/selection.mjs +19 -19
- package/fesm2015/table-scroll-container.mjs +7 -7
- package/fesm2020/cdk-experimental.mjs +1 -1
- package/fesm2020/cdk-experimental.mjs.map +1 -1
- package/fesm2020/column-resize.mjs +50 -50
- package/fesm2020/combobox.mjs +10 -10
- package/fesm2020/dialog.mjs +12 -12
- package/fesm2020/dialog.mjs.map +1 -1
- package/fesm2020/listbox.mjs +10 -10
- package/fesm2020/menu.mjs +345 -435
- package/fesm2020/menu.mjs.map +1 -1
- package/fesm2020/popover-edit.mjs +49 -49
- package/fesm2020/scrolling.mjs +7 -7
- package/fesm2020/selection.mjs +19 -19
- package/fesm2020/table-scroll-container.mjs +7 -7
- package/menu/context-menu.d.ts +3 -24
- package/menu/menu-bar.d.ts +9 -50
- package/menu/menu-base.d.ts +64 -0
- package/menu/menu-group.d.ts +2 -2
- package/menu/menu-interface.d.ts +1 -1
- package/menu/menu-item-radio.d.ts +2 -2
- package/menu/menu-item-trigger.d.ts +4 -27
- package/menu/menu-item.d.ts +3 -3
- package/menu/menu-stack.d.ts +17 -2
- package/menu/menu-trigger.d.ts +29 -5
- package/menu/menu.d.ts +9 -49
- package/package.json +2 -2
package/fesm2015/menu.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken,
|
|
2
|
+
import { InjectionToken, Optional, SkipSelf, Inject, Injectable, Directive, EventEmitter, Injector, Self, Input, Output, ContentChildren, NgModule } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/cdk/overlay';
|
|
4
4
|
import { OverlayConfig, STANDARD_DROPDOWN_BELOW_POSITIONS, STANDARD_DROPDOWN_ADJACENT_POSITIONS, OverlayModule } from '@angular/cdk/overlay';
|
|
5
|
-
import { FocusKeyManager } from '@angular/cdk/a11y';
|
|
6
5
|
import { UP_ARROW, DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW, ENTER, SPACE, TAB, ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
|
|
7
|
-
import {
|
|
8
|
-
import { filter, takeUntil, startWith, mergeMap, mapTo, mergeAll, take, switchMap, skip } from 'rxjs/operators';
|
|
6
|
+
import { filter, takeUntil, startWith, mergeMap, mapTo, mergeAll, switchMap, take, skip } from 'rxjs/operators';
|
|
9
7
|
import * as i1$2 from '@angular/cdk/collections';
|
|
10
8
|
import { UniqueSelectionDispatcher } from '@angular/cdk/collections';
|
|
11
9
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
10
|
+
import { Subject, fromEvent, merge, defer, partition } from 'rxjs';
|
|
12
11
|
import * as i1$1 from '@angular/cdk/bidi';
|
|
13
12
|
import { TemplatePortal } from '@angular/cdk/portal';
|
|
13
|
+
import { FocusKeyManager } from '@angular/cdk/a11y';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* @license
|
|
@@ -31,6 +31,18 @@ const CDK_MENU = new InjectionToken('cdk-menu');
|
|
|
31
31
|
*/
|
|
32
32
|
/** Injection token used for an implementation of MenuStack. */
|
|
33
33
|
const MENU_STACK = new InjectionToken('cdk-menu-stack');
|
|
34
|
+
/** A provider that provides the parent menu stack, or a new menu stack if there is no parent one. */
|
|
35
|
+
const PARENT_OR_NEW_MENU_STACK_PROVIDER = {
|
|
36
|
+
provide: MENU_STACK,
|
|
37
|
+
deps: [[new Optional(), new SkipSelf(), new Inject(MENU_STACK)]],
|
|
38
|
+
useFactory: (parentMenuStack) => parentMenuStack || new MenuStack(),
|
|
39
|
+
};
|
|
40
|
+
/** A provider that provides the parent menu stack, or a new menu stack if there is no parent one. */
|
|
41
|
+
const PARENT_OR_NEW_INLINE_MENU_STACK_PROVIDER = {
|
|
42
|
+
provide: MENU_STACK,
|
|
43
|
+
deps: [[new Optional(), new SkipSelf(), new Inject(MENU_STACK)]],
|
|
44
|
+
useFactory: (parentMenuStack) => parentMenuStack || MenuStack.inline(),
|
|
45
|
+
};
|
|
34
46
|
/**
|
|
35
47
|
* MenuStack allows subscribers to listen for close events (when a MenuStackItem is popped off
|
|
36
48
|
* of the stack) in order to perform closing actions. Upon the MenuStack being empty it emits
|
|
@@ -53,6 +65,12 @@ class MenuStack {
|
|
|
53
65
|
* perform.
|
|
54
66
|
*/
|
|
55
67
|
this.emptied = this._empty;
|
|
68
|
+
this._hasInlineMenu = false;
|
|
69
|
+
}
|
|
70
|
+
static inline() {
|
|
71
|
+
const stack = new MenuStack();
|
|
72
|
+
stack._hasInlineMenu = true;
|
|
73
|
+
return stack;
|
|
56
74
|
}
|
|
57
75
|
/** @param menu the MenuStackItem to put on the stack. */
|
|
58
76
|
push(menu) {
|
|
@@ -122,10 +140,13 @@ class MenuStack {
|
|
|
122
140
|
peek() {
|
|
123
141
|
return this._elements[this._elements.length - 1];
|
|
124
142
|
}
|
|
143
|
+
hasInlineMenu() {
|
|
144
|
+
return this._hasInlineMenu;
|
|
145
|
+
}
|
|
125
146
|
}
|
|
126
|
-
MenuStack.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
127
|
-
MenuStack.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
128
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
147
|
+
MenuStack.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: MenuStack, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
148
|
+
MenuStack.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: MenuStack });
|
|
149
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: MenuStack, decorators: [{
|
|
129
150
|
type: Injectable
|
|
130
151
|
}] });
|
|
131
152
|
|
|
@@ -322,9 +343,9 @@ class TargetMenuAim {
|
|
|
322
343
|
this._destroyed.complete();
|
|
323
344
|
}
|
|
324
345
|
}
|
|
325
|
-
TargetMenuAim.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
326
|
-
TargetMenuAim.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
327
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
346
|
+
TargetMenuAim.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: TargetMenuAim, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
347
|
+
TargetMenuAim.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: TargetMenuAim });
|
|
348
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: TargetMenuAim, decorators: [{
|
|
328
349
|
type: Injectable
|
|
329
350
|
}], ctorParameters: function () { return [{ type: i0.NgZone }]; } });
|
|
330
351
|
/**
|
|
@@ -333,9 +354,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6",
|
|
|
333
354
|
*/
|
|
334
355
|
class CdkTargetMenuAim {
|
|
335
356
|
}
|
|
336
|
-
CdkTargetMenuAim.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
337
|
-
CdkTargetMenuAim.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
338
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
357
|
+
CdkTargetMenuAim.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkTargetMenuAim, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
358
|
+
CdkTargetMenuAim.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.9", type: CdkTargetMenuAim, selector: "[cdkTargetMenuAim]", providers: [{ provide: MENU_AIM, useClass: TargetMenuAim }], exportAs: ["cdkTargetMenuAim"], ngImport: i0 });
|
|
359
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkTargetMenuAim, decorators: [{
|
|
339
360
|
type: Directive,
|
|
340
361
|
args: [{
|
|
341
362
|
selector: '[cdkTargetMenuAim]',
|
|
@@ -357,6 +378,29 @@ class MenuTrigger {
|
|
|
357
378
|
constructor(injector, menuStack) {
|
|
358
379
|
this.injector = injector;
|
|
359
380
|
this.menuStack = menuStack;
|
|
381
|
+
/** Emits when the attached menu is requested to open */
|
|
382
|
+
this.opened = new EventEmitter();
|
|
383
|
+
/** Emits when the attached menu is requested to close */
|
|
384
|
+
this.closed = new EventEmitter();
|
|
385
|
+
/** A reference to the overlay which manages the triggered menu */
|
|
386
|
+
this._overlayRef = null;
|
|
387
|
+
/** Emits when this trigger is destroyed. */
|
|
388
|
+
this._destroyed = new Subject();
|
|
389
|
+
/** Emits when the outside pointer events listener on the overlay should be stopped. */
|
|
390
|
+
this._stopOutsideClicksListener = merge(this.closed, this._destroyed);
|
|
391
|
+
}
|
|
392
|
+
ngOnDestroy() {
|
|
393
|
+
this._destroyOverlay();
|
|
394
|
+
this._destroyed.next();
|
|
395
|
+
this._destroyed.complete();
|
|
396
|
+
}
|
|
397
|
+
/** Whether the attached menu is open. */
|
|
398
|
+
isOpen() {
|
|
399
|
+
var _a;
|
|
400
|
+
return !!((_a = this._overlayRef) === null || _a === void 0 ? void 0 : _a.hasAttached());
|
|
401
|
+
}
|
|
402
|
+
registerChildMenu(child) {
|
|
403
|
+
this.childMenu = child;
|
|
360
404
|
}
|
|
361
405
|
getChildMenuInjector() {
|
|
362
406
|
this._childMenuInjector =
|
|
@@ -370,14 +414,18 @@ class MenuTrigger {
|
|
|
370
414
|
});
|
|
371
415
|
return this._childMenuInjector;
|
|
372
416
|
}
|
|
373
|
-
|
|
374
|
-
|
|
417
|
+
/** Destroy and unset the overlay reference it if exists */
|
|
418
|
+
_destroyOverlay() {
|
|
419
|
+
if (this._overlayRef) {
|
|
420
|
+
this._overlayRef.dispose();
|
|
421
|
+
this._overlayRef = null;
|
|
422
|
+
}
|
|
375
423
|
}
|
|
376
424
|
}
|
|
377
|
-
MenuTrigger.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
378
|
-
MenuTrigger.ɵ
|
|
379
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
380
|
-
type:
|
|
425
|
+
MenuTrigger.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: MenuTrigger, deps: [{ token: i0.Injector }, { token: MENU_STACK }], target: i0.ɵɵFactoryTarget.Directive });
|
|
426
|
+
MenuTrigger.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.9", type: MenuTrigger, ngImport: i0 });
|
|
427
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: MenuTrigger, decorators: [{
|
|
428
|
+
type: Directive
|
|
381
429
|
}], ctorParameters: function () {
|
|
382
430
|
return [{ type: i0.Injector }, { type: MenuStack, decorators: [{
|
|
383
431
|
type: Inject,
|
|
@@ -426,28 +474,16 @@ class CdkMenuItemTrigger extends MenuTrigger {
|
|
|
426
474
|
this._parentMenu = _parentMenu;
|
|
427
475
|
this._menuAim = _menuAim;
|
|
428
476
|
this._directionality = _directionality;
|
|
429
|
-
/** Emits when the attached menu is requested to open */
|
|
430
|
-
this.opened = new EventEmitter();
|
|
431
|
-
/** Emits when the attached menu is requested to close */
|
|
432
|
-
this.closed = new EventEmitter();
|
|
433
|
-
/** A reference to the overlay which manages the triggered menu */
|
|
434
|
-
this._overlayRef = null;
|
|
435
|
-
/** Emits when this trigger is destroyed. */
|
|
436
|
-
this._destroyed = new Subject();
|
|
437
|
-
/** Emits when the outside pointer events listener on the overlay should be stopped. */
|
|
438
|
-
this._stopOutsideClicksListener = merge(this.closed, this._destroyed);
|
|
439
477
|
this._registerCloseHandler();
|
|
440
478
|
this._subscribeToMouseEnter();
|
|
441
479
|
}
|
|
442
480
|
/** Open/close the attached menu if the trigger has been configured with one */
|
|
443
481
|
toggle() {
|
|
444
|
-
|
|
445
|
-
this.isMenuOpen() ? this.closeMenu() : this.openMenu();
|
|
446
|
-
}
|
|
482
|
+
this.isOpen() ? this.close() : this.open();
|
|
447
483
|
}
|
|
448
484
|
/** Open the attached menu. */
|
|
449
|
-
|
|
450
|
-
if (!this.
|
|
485
|
+
open() {
|
|
486
|
+
if (!this.isOpen()) {
|
|
451
487
|
this.opened.next();
|
|
452
488
|
this._overlayRef = this._overlayRef || this._overlay.create(this._getOverlayConfig());
|
|
453
489
|
this._overlayRef.attach(this._getPortal());
|
|
@@ -455,21 +491,13 @@ class CdkMenuItemTrigger extends MenuTrigger {
|
|
|
455
491
|
}
|
|
456
492
|
}
|
|
457
493
|
/** Close the opened menu. */
|
|
458
|
-
|
|
459
|
-
if (this.
|
|
494
|
+
close() {
|
|
495
|
+
if (this.isOpen()) {
|
|
460
496
|
this.closed.next();
|
|
461
497
|
this._overlayRef.detach();
|
|
462
498
|
}
|
|
463
499
|
this._closeSiblingTriggers();
|
|
464
500
|
}
|
|
465
|
-
/** Return true if the trigger has an attached menu */
|
|
466
|
-
hasMenu() {
|
|
467
|
-
return !!this._menuTemplateRef;
|
|
468
|
-
}
|
|
469
|
-
/** Whether the menu this button is a trigger for is open */
|
|
470
|
-
isMenuOpen() {
|
|
471
|
-
return this._overlayRef ? this._overlayRef.hasAttached() : false;
|
|
472
|
-
}
|
|
473
501
|
/**
|
|
474
502
|
* Get a reference to the rendered Menu if the Menu is open and it is visible in the DOM.
|
|
475
503
|
* @return the menu if it is open, otherwise undefined.
|
|
@@ -485,11 +513,11 @@ class CdkMenuItemTrigger extends MenuTrigger {
|
|
|
485
513
|
// Closes any sibling menu items and opens the menu associated with this trigger.
|
|
486
514
|
const toggleMenus = () => this._ngZone.run(() => {
|
|
487
515
|
this._closeSiblingTriggers();
|
|
488
|
-
this.
|
|
516
|
+
this.open();
|
|
489
517
|
});
|
|
490
518
|
this._ngZone.runOutsideAngular(() => {
|
|
491
519
|
fromEvent(this._elementRef.nativeElement, 'mouseenter')
|
|
492
|
-
.pipe(filter(() => !this.menuStack.isEmpty() && !this.
|
|
520
|
+
.pipe(filter(() => !this.menuStack.isEmpty() && !this.isOpen()), takeUntil(this._destroyed))
|
|
493
521
|
.subscribe(() => {
|
|
494
522
|
if (this._menuAim) {
|
|
495
523
|
this._menuAim.toggle(toggleMenus);
|
|
@@ -516,34 +544,24 @@ class CdkMenuItemTrigger extends MenuTrigger {
|
|
|
516
544
|
(_a = this.childMenu) === null || _a === void 0 ? void 0 : _a.focusFirstItem('keyboard');
|
|
517
545
|
break;
|
|
518
546
|
case RIGHT_ARROW:
|
|
519
|
-
if (this._parentMenu && this._isParentVertical()) {
|
|
547
|
+
if (this._parentMenu && this._isParentVertical() && ((_b = this._directionality) === null || _b === void 0 ? void 0 : _b.value) !== 'rtl') {
|
|
520
548
|
event.preventDefault();
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
}
|
|
524
|
-
else {
|
|
525
|
-
this.openMenu();
|
|
526
|
-
(_c = this.childMenu) === null || _c === void 0 ? void 0 : _c.focusFirstItem('keyboard');
|
|
527
|
-
}
|
|
549
|
+
this.open();
|
|
550
|
+
(_c = this.childMenu) === null || _c === void 0 ? void 0 : _c.focusFirstItem('keyboard');
|
|
528
551
|
}
|
|
529
552
|
break;
|
|
530
553
|
case LEFT_ARROW:
|
|
531
|
-
if (this._parentMenu && this._isParentVertical()) {
|
|
554
|
+
if (this._parentMenu && this._isParentVertical() && ((_d = this._directionality) === null || _d === void 0 ? void 0 : _d.value) === 'rtl') {
|
|
532
555
|
event.preventDefault();
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
(_e = this.childMenu) === null || _e === void 0 ? void 0 : _e.focusFirstItem('keyboard');
|
|
536
|
-
}
|
|
537
|
-
else {
|
|
538
|
-
this.menuStack.close(this._parentMenu, 2 /* currentItem */);
|
|
539
|
-
}
|
|
556
|
+
this.open();
|
|
557
|
+
(_e = this.childMenu) === null || _e === void 0 ? void 0 : _e.focusFirstItem('keyboard');
|
|
540
558
|
}
|
|
541
559
|
break;
|
|
542
560
|
case DOWN_ARROW:
|
|
543
561
|
case UP_ARROW:
|
|
544
562
|
if (!this._isParentVertical()) {
|
|
545
563
|
event.preventDefault();
|
|
546
|
-
this.
|
|
564
|
+
this.open();
|
|
547
565
|
keyCode === DOWN_ARROW
|
|
548
566
|
? (_f = this.childMenu) === null || _f === void 0 ? void 0 : _f.focusFirstItem('keyboard')
|
|
549
567
|
: (_g = this.childMenu) === null || _g === void 0 ? void 0 : _g.focusLastItem('keyboard');
|
|
@@ -616,16 +634,11 @@ class CdkMenuItemTrigger extends MenuTrigger {
|
|
|
616
634
|
if (!this._parentMenu) {
|
|
617
635
|
this.menuStack.closed.pipe(takeUntil(this._destroyed)).subscribe(item => {
|
|
618
636
|
if (item === this.childMenu) {
|
|
619
|
-
this.
|
|
637
|
+
this.close();
|
|
620
638
|
}
|
|
621
639
|
});
|
|
622
640
|
}
|
|
623
641
|
}
|
|
624
|
-
ngOnDestroy() {
|
|
625
|
-
this._destroyOverlay();
|
|
626
|
-
this._destroyed.next();
|
|
627
|
-
this._destroyed.complete();
|
|
628
|
-
}
|
|
629
642
|
/**
|
|
630
643
|
* Subscribe to the overlays outside pointer events stream and handle closing out the stack if a
|
|
631
644
|
* click occurs outside the menus.
|
|
@@ -642,42 +655,29 @@ class CdkMenuItemTrigger extends MenuTrigger {
|
|
|
642
655
|
});
|
|
643
656
|
}
|
|
644
657
|
}
|
|
645
|
-
/** Destroy and unset the overlay reference it if exists */
|
|
646
|
-
_destroyOverlay() {
|
|
647
|
-
if (this._overlayRef) {
|
|
648
|
-
this._overlayRef.dispose();
|
|
649
|
-
this._overlayRef = null;
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
658
|
}
|
|
653
|
-
CdkMenuItemTrigger.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
654
|
-
CdkMenuItemTrigger.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
659
|
+
CdkMenuItemTrigger.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.9", 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 });
|
|
660
|
+
CdkMenuItemTrigger.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.9", 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": "isOpen()" }, classAttribute: "cdk-menu-trigger" }, providers: [
|
|
655
661
|
{ 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
|
-
},
|
|
662
|
+
PARENT_OR_NEW_MENU_STACK_PROVIDER,
|
|
661
663
|
], exportAs: ["cdkMenuTriggerFor"], usesInheritance: true, ngImport: i0 });
|
|
662
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
664
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuItemTrigger, decorators: [{
|
|
663
665
|
type: Directive,
|
|
664
666
|
args: [{
|
|
665
667
|
selector: '[cdkMenuTriggerFor]',
|
|
666
668
|
exportAs: 'cdkMenuTriggerFor',
|
|
667
669
|
host: {
|
|
668
|
-
'(keydown)': '_toggleOnKeydown($event)',
|
|
669
|
-
'(click)': 'toggle()',
|
|
670
670
|
'class': 'cdk-menu-trigger',
|
|
671
671
|
'aria-haspopup': 'menu',
|
|
672
|
-
'
|
|
672
|
+
'(keydown)': '_toggleOnKeydown($event)',
|
|
673
|
+
'(click)': 'toggle()',
|
|
674
|
+
'[attr.aria-expanded]': 'isOpen()',
|
|
673
675
|
},
|
|
676
|
+
inputs: ['_menuTemplateRef: cdkMenuTriggerFor', 'menuPosition: cdkMenuPosition'],
|
|
677
|
+
outputs: ['opened: cdkMenuOpened', 'closed: cdkMenuClosed'],
|
|
674
678
|
providers: [
|
|
675
679
|
{ 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
|
-
},
|
|
680
|
+
PARENT_OR_NEW_MENU_STACK_PROVIDER,
|
|
681
681
|
],
|
|
682
682
|
}]
|
|
683
683
|
}], ctorParameters: function () {
|
|
@@ -697,19 +697,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6",
|
|
|
697
697
|
}] }, { type: i1$1.Directionality, decorators: [{
|
|
698
698
|
type: Optional
|
|
699
699
|
}] }];
|
|
700
|
-
}
|
|
701
|
-
type: Input,
|
|
702
|
-
args: ['cdkMenuTriggerFor']
|
|
703
|
-
}], menuPosition: [{
|
|
704
|
-
type: Input,
|
|
705
|
-
args: ['cdkMenuPosition']
|
|
706
|
-
}], opened: [{
|
|
707
|
-
type: Output,
|
|
708
|
-
args: ['cdkMenuOpened']
|
|
709
|
-
}], closed: [{
|
|
710
|
-
type: Output,
|
|
711
|
-
args: ['cdkMenuClosed']
|
|
712
|
-
}] } });
|
|
700
|
+
} });
|
|
713
701
|
|
|
714
702
|
/**
|
|
715
703
|
* @license
|
|
@@ -776,12 +764,11 @@ class CdkMenuItem {
|
|
|
776
764
|
* is not in a menu bar.
|
|
777
765
|
*/
|
|
778
766
|
_setTabIndex(event) {
|
|
779
|
-
var _a;
|
|
780
767
|
if (this.disabled) {
|
|
781
768
|
return;
|
|
782
769
|
}
|
|
783
770
|
// don't set the tabindex if there are no open sibling or parent menus
|
|
784
|
-
if (!event || !
|
|
771
|
+
if (!event || !this._menuStack.isEmpty()) {
|
|
785
772
|
this._tabindex = 0;
|
|
786
773
|
}
|
|
787
774
|
}
|
|
@@ -794,21 +781,19 @@ class CdkMenuItem {
|
|
|
794
781
|
* on the cdkMenuItemTriggered emitter and close all open menus.
|
|
795
782
|
*/
|
|
796
783
|
trigger() {
|
|
797
|
-
var _a;
|
|
798
784
|
if (!this.disabled && !this.hasMenu()) {
|
|
799
785
|
this.triggered.next();
|
|
800
|
-
|
|
786
|
+
this._menuStack.closeAll();
|
|
801
787
|
}
|
|
802
788
|
}
|
|
803
789
|
/** Whether the menu item opens a menu. */
|
|
804
790
|
hasMenu() {
|
|
805
|
-
|
|
806
|
-
return !!((_a = this._menuTrigger) === null || _a === void 0 ? void 0 : _a.hasMenu());
|
|
791
|
+
return !!this._menuTrigger;
|
|
807
792
|
}
|
|
808
793
|
/** Return true if this MenuItem has an attached menu and it is open. */
|
|
809
794
|
isMenuOpen() {
|
|
810
795
|
var _a;
|
|
811
|
-
return !!((_a = this._menuTrigger) === null || _a === void 0 ? void 0 : _a.
|
|
796
|
+
return !!((_a = this._menuTrigger) === null || _a === void 0 ? void 0 : _a.isOpen());
|
|
812
797
|
}
|
|
813
798
|
/**
|
|
814
799
|
* Get a reference to the rendered Menu if the Menu is open and it is visible in the DOM.
|
|
@@ -834,7 +819,7 @@ class CdkMenuItem {
|
|
|
834
819
|
* @param event the keyboard event to handle
|
|
835
820
|
*/
|
|
836
821
|
_onKeydown(event) {
|
|
837
|
-
var _a, _b
|
|
822
|
+
var _a, _b;
|
|
838
823
|
switch (event.keyCode) {
|
|
839
824
|
case SPACE:
|
|
840
825
|
case ENTER:
|
|
@@ -842,19 +827,35 @@ class CdkMenuItem {
|
|
|
842
827
|
this.trigger();
|
|
843
828
|
break;
|
|
844
829
|
case RIGHT_ARROW:
|
|
845
|
-
if (this._parentMenu && this._isParentVertical()
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
830
|
+
if (this._parentMenu && this._isParentVertical()) {
|
|
831
|
+
if (((_a = this._dir) === null || _a === void 0 ? void 0 : _a.value) === 'rtl') {
|
|
832
|
+
if (this._menuStack.hasInlineMenu() || this._menuStack.length() > 1) {
|
|
833
|
+
event.preventDefault();
|
|
834
|
+
this._menuStack.close(this._parentMenu, 1 /* previousItem */);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
else if (!this.hasMenu()) {
|
|
838
|
+
if (this._menuStack.hasInlineMenu()) {
|
|
839
|
+
event.preventDefault();
|
|
840
|
+
this._menuStack.closeAll(0 /* nextItem */);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
850
843
|
}
|
|
851
844
|
break;
|
|
852
845
|
case LEFT_ARROW:
|
|
853
|
-
if (this._parentMenu && this._isParentVertical()
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
846
|
+
if (this._parentMenu && this._isParentVertical()) {
|
|
847
|
+
if (((_b = this._dir) === null || _b === void 0 ? void 0 : _b.value) !== 'rtl') {
|
|
848
|
+
if (this._menuStack.hasInlineMenu() || this._menuStack.length() > 1) {
|
|
849
|
+
event.preventDefault();
|
|
850
|
+
this._menuStack.close(this._parentMenu, 1 /* previousItem */);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
else if (!this.hasMenu()) {
|
|
854
|
+
if (this._menuStack.hasInlineMenu()) {
|
|
855
|
+
event.preventDefault();
|
|
856
|
+
this._menuStack.closeAll(0 /* nextItem */);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
858
859
|
}
|
|
859
860
|
break;
|
|
860
861
|
}
|
|
@@ -865,9 +866,9 @@ class CdkMenuItem {
|
|
|
865
866
|
*/
|
|
866
867
|
_setupMouseEnter() {
|
|
867
868
|
if (!this._isStandaloneItem()) {
|
|
868
|
-
const closeOpenSiblings = () => this._ngZone.run(() =>
|
|
869
|
+
const closeOpenSiblings = () => this._ngZone.run(() => this._menuStack.closeSubMenuOf(this._parentMenu));
|
|
869
870
|
this._ngZone.runOutsideAngular(() => fromEvent(this._elementRef.nativeElement, 'mouseenter')
|
|
870
|
-
.pipe(filter(() =>
|
|
871
|
+
.pipe(filter(() => !this._menuStack.isEmpty() && !this.hasMenu()), takeUntil(this._destroyed))
|
|
871
872
|
.subscribe(() => {
|
|
872
873
|
if (this._menuAim) {
|
|
873
874
|
this._menuAim.toggle(closeOpenSiblings);
|
|
@@ -890,9 +891,9 @@ class CdkMenuItem {
|
|
|
890
891
|
this._destroyed.next();
|
|
891
892
|
}
|
|
892
893
|
}
|
|
893
|
-
CdkMenuItem.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
894
|
-
CdkMenuItem.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
895
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
894
|
+
CdkMenuItem.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuItem, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: MENU_STACK }, { 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 });
|
|
895
|
+
CdkMenuItem.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.9", 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 });
|
|
896
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuItem, decorators: [{
|
|
896
897
|
type: Directive,
|
|
897
898
|
args: [{
|
|
898
899
|
selector: '[cdkMenuItem]',
|
|
@@ -913,8 +914,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6",
|
|
|
913
914
|
}]
|
|
914
915
|
}], ctorParameters: function () {
|
|
915
916
|
return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: MenuStack, decorators: [{
|
|
916
|
-
type: Optional
|
|
917
|
-
}, {
|
|
918
917
|
type: Inject,
|
|
919
918
|
args: [MENU_STACK]
|
|
920
919
|
}] }, { type: undefined, decorators: [{
|
|
@@ -981,9 +980,9 @@ class CdkMenuItemSelectable extends CdkMenuItem {
|
|
|
981
980
|
}
|
|
982
981
|
}
|
|
983
982
|
}
|
|
984
|
-
CdkMenuItemSelectable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
985
|
-
CdkMenuItemSelectable.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
986
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
983
|
+
CdkMenuItemSelectable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuItemSelectable, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
984
|
+
CdkMenuItemSelectable.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.9", type: CdkMenuItemSelectable, inputs: { checked: "checked", name: "name", id: "id" }, outputs: { toggled: "cdkMenuItemToggled" }, usesInheritance: true, ngImport: i0 });
|
|
985
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuItemSelectable, decorators: [{
|
|
987
986
|
type: Directive
|
|
988
987
|
}], propDecorators: { toggled: [{
|
|
989
988
|
type: Output,
|
|
@@ -1017,6 +1016,10 @@ class CdkMenuGroup {
|
|
|
1017
1016
|
ngAfterContentInit() {
|
|
1018
1017
|
this._registerMenuSelectionListeners();
|
|
1019
1018
|
}
|
|
1019
|
+
ngOnDestroy() {
|
|
1020
|
+
this._selectableChanges.next();
|
|
1021
|
+
this._selectableChanges.complete();
|
|
1022
|
+
}
|
|
1020
1023
|
/**
|
|
1021
1024
|
* Register the child selectable elements with the change emitter and ensure any new child
|
|
1022
1025
|
* elements do so as well.
|
|
@@ -1034,14 +1037,10 @@ class CdkMenuGroup {
|
|
|
1034
1037
|
.pipe(takeUntil(this._selectableChanges))
|
|
1035
1038
|
.subscribe(() => this.change.next(selectable));
|
|
1036
1039
|
}
|
|
1037
|
-
ngOnDestroy() {
|
|
1038
|
-
this._selectableChanges.next();
|
|
1039
|
-
this._selectableChanges.complete();
|
|
1040
|
-
}
|
|
1041
1040
|
}
|
|
1042
|
-
CdkMenuGroup.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1043
|
-
CdkMenuGroup.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1044
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1041
|
+
CdkMenuGroup.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1042
|
+
CdkMenuGroup.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.9", 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 });
|
|
1043
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuGroup, decorators: [{
|
|
1045
1044
|
type: Directive,
|
|
1046
1045
|
args: [{
|
|
1047
1046
|
selector: '[cdkMenuGroup]',
|
|
@@ -1106,6 +1105,128 @@ class PointerFocusTracker {
|
|
|
1106
1105
|
}
|
|
1107
1106
|
}
|
|
1108
1107
|
|
|
1108
|
+
/**
|
|
1109
|
+
* @license
|
|
1110
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1111
|
+
*
|
|
1112
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1113
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1114
|
+
*/
|
|
1115
|
+
class CdkMenuBase extends CdkMenuGroup {
|
|
1116
|
+
constructor(_elementRef, menuStack, dir) {
|
|
1117
|
+
super();
|
|
1118
|
+
this._elementRef = _elementRef;
|
|
1119
|
+
this.menuStack = menuStack;
|
|
1120
|
+
this.dir = dir;
|
|
1121
|
+
/**
|
|
1122
|
+
* Sets the aria-orientation attribute and determines where menus will be opened.
|
|
1123
|
+
* Does not affect styling/layout.
|
|
1124
|
+
*/
|
|
1125
|
+
this.orientation = 'vertical';
|
|
1126
|
+
/** Emits when the MenuBar is destroyed. */
|
|
1127
|
+
this.destroyed = new Subject();
|
|
1128
|
+
}
|
|
1129
|
+
ngAfterContentInit() {
|
|
1130
|
+
super.ngAfterContentInit();
|
|
1131
|
+
this._setKeyManager();
|
|
1132
|
+
this._subscribeToMenuOpen();
|
|
1133
|
+
this._subscribeToMenuStackClosed();
|
|
1134
|
+
}
|
|
1135
|
+
ngOnDestroy() {
|
|
1136
|
+
super.ngOnDestroy();
|
|
1137
|
+
this.destroyed.next();
|
|
1138
|
+
this.destroyed.complete();
|
|
1139
|
+
}
|
|
1140
|
+
/** Place focus on the first MenuItem in the menu and set the focus origin. */
|
|
1141
|
+
focusFirstItem(focusOrigin = 'program') {
|
|
1142
|
+
this.keyManager.setFocusOrigin(focusOrigin);
|
|
1143
|
+
this.keyManager.setFirstItemActive();
|
|
1144
|
+
}
|
|
1145
|
+
/** Place focus on the last MenuItem in the menu and set the focus origin. */
|
|
1146
|
+
focusLastItem(focusOrigin = 'program') {
|
|
1147
|
+
this.keyManager.setFocusOrigin(focusOrigin);
|
|
1148
|
+
this.keyManager.setLastItemActive();
|
|
1149
|
+
}
|
|
1150
|
+
/** Return true if this menu has been configured in a horizontal orientation. */
|
|
1151
|
+
isHorizontal() {
|
|
1152
|
+
return this.orientation === 'horizontal';
|
|
1153
|
+
}
|
|
1154
|
+
/** Return true if the MenuBar has an open submenu. */
|
|
1155
|
+
hasOpenSubmenu() {
|
|
1156
|
+
return !!this.openItem;
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Close the open menu if the current active item opened the requested MenuStackItem.
|
|
1160
|
+
* @param item the MenuStackItem requested to be closed.
|
|
1161
|
+
*/
|
|
1162
|
+
closeOpenMenu(menu) {
|
|
1163
|
+
var _a, _b, _c;
|
|
1164
|
+
const keyManager = this.keyManager;
|
|
1165
|
+
const trigger = this.openItem;
|
|
1166
|
+
if (menu === ((_a = trigger === null || trigger === void 0 ? void 0 : trigger.getMenuTrigger()) === null || _a === void 0 ? void 0 : _a.getMenu())) {
|
|
1167
|
+
(_b = trigger === null || trigger === void 0 ? void 0 : trigger.getMenuTrigger()) === null || _b === void 0 ? void 0 : _b.close();
|
|
1168
|
+
// If the user has moused over a sibling item we want to focus the element under mouse focus
|
|
1169
|
+
// not the trigger which previously opened the now closed menu.
|
|
1170
|
+
if (trigger) {
|
|
1171
|
+
keyManager.setActiveItem(((_c = this.pointerTracker) === null || _c === void 0 ? void 0 : _c.activeElement) || trigger);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
/** Setup the FocusKeyManager with the correct orientation for the menu. */
|
|
1176
|
+
_setKeyManager() {
|
|
1177
|
+
var _a;
|
|
1178
|
+
this.keyManager = new FocusKeyManager(this.items).withWrap().withTypeAhead().withHomeAndEnd();
|
|
1179
|
+
if (this.isHorizontal()) {
|
|
1180
|
+
this.keyManager.withHorizontalOrientation(((_a = this.dir) === null || _a === void 0 ? void 0 : _a.value) || 'ltr');
|
|
1181
|
+
}
|
|
1182
|
+
else {
|
|
1183
|
+
this.keyManager.withVerticalOrientation();
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
/**
|
|
1187
|
+
* Subscribe to the menu trigger's open events in order to track the trigger which opened the menu
|
|
1188
|
+
* and stop tracking it when the menu is closed.
|
|
1189
|
+
*/
|
|
1190
|
+
_subscribeToMenuOpen() {
|
|
1191
|
+
const exitCondition = merge(this.items.changes, this.destroyed);
|
|
1192
|
+
this.items.changes
|
|
1193
|
+
.pipe(startWith(this.items), mergeMap((list) => list
|
|
1194
|
+
.filter(item => item.hasMenu())
|
|
1195
|
+
.map(item => item.getMenuTrigger().opened.pipe(mapTo(item), takeUntil(exitCondition)))), mergeAll(), switchMap((item) => {
|
|
1196
|
+
this.openItem = item;
|
|
1197
|
+
return item.getMenuTrigger().closed;
|
|
1198
|
+
}), takeUntil(this.destroyed))
|
|
1199
|
+
.subscribe(() => (this.openItem = undefined));
|
|
1200
|
+
}
|
|
1201
|
+
/** Subscribe to the MenuStack close and empty observables. */
|
|
1202
|
+
_subscribeToMenuStackClosed() {
|
|
1203
|
+
this.menuStack.closed
|
|
1204
|
+
.pipe(takeUntil(this.destroyed))
|
|
1205
|
+
.subscribe(item => this.closeOpenMenu(item));
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
CdkMenuBase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuBase, deps: [{ token: i0.ElementRef }, { token: MENU_STACK }, { token: i1$1.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1209
|
+
CdkMenuBase.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.9", type: CdkMenuBase, host: { listeners: { "focus": "focusFirstItem()" }, properties: { "attr.aria-orientation": "orientation" } }, queries: [{ propertyName: "items", predicate: CdkMenuItem, descendants: true }], usesInheritance: true, ngImport: i0 });
|
|
1210
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuBase, decorators: [{
|
|
1211
|
+
type: Directive,
|
|
1212
|
+
args: [{
|
|
1213
|
+
host: {
|
|
1214
|
+
'[attr.aria-orientation]': 'orientation',
|
|
1215
|
+
'(focus)': 'focusFirstItem()',
|
|
1216
|
+
},
|
|
1217
|
+
}]
|
|
1218
|
+
}], ctorParameters: function () {
|
|
1219
|
+
return [{ type: i0.ElementRef }, { type: MenuStack, decorators: [{
|
|
1220
|
+
type: Inject,
|
|
1221
|
+
args: [MENU_STACK]
|
|
1222
|
+
}] }, { type: i1$1.Directionality, decorators: [{
|
|
1223
|
+
type: Optional
|
|
1224
|
+
}] }];
|
|
1225
|
+
}, propDecorators: { items: [{
|
|
1226
|
+
type: ContentChildren,
|
|
1227
|
+
args: [CdkMenuItem, { descendants: true }]
|
|
1228
|
+
}] } });
|
|
1229
|
+
|
|
1109
1230
|
/**
|
|
1110
1231
|
* @license
|
|
1111
1232
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -1120,56 +1241,42 @@ class PointerFocusTracker {
|
|
|
1120
1241
|
*
|
|
1121
1242
|
* It also acts as a RadioGroup for elements marked with role `menuitemradio`.
|
|
1122
1243
|
*/
|
|
1123
|
-
class CdkMenu extends
|
|
1124
|
-
constructor(_ngZone,
|
|
1125
|
-
|
|
1244
|
+
class CdkMenu extends CdkMenuBase {
|
|
1245
|
+
constructor(_ngZone, elementRef, menuStack, _parentTrigger, _menuAim, dir) {
|
|
1246
|
+
var _a;
|
|
1247
|
+
super(elementRef, menuStack, dir);
|
|
1126
1248
|
this._ngZone = _ngZone;
|
|
1127
|
-
this._elementRef = _elementRef;
|
|
1128
|
-
this._menuStack = _menuStack;
|
|
1129
1249
|
this._parentTrigger = _parentTrigger;
|
|
1130
1250
|
this._menuAim = _menuAim;
|
|
1131
|
-
this._dir = _dir;
|
|
1132
|
-
/**
|
|
1133
|
-
* Sets the aria-orientation attribute and determines where menus will be opened.
|
|
1134
|
-
* Does not affect styling/layout.
|
|
1135
|
-
*/
|
|
1136
|
-
this.orientation = 'vertical';
|
|
1137
1251
|
/** Event emitted when the menu is closed. */
|
|
1138
1252
|
this.closed = new EventEmitter();
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
(
|
|
1253
|
+
this.destroyed.subscribe(this.closed);
|
|
1254
|
+
if (!this._isInline()) {
|
|
1255
|
+
this.menuStack.push(this);
|
|
1256
|
+
}
|
|
1257
|
+
(_a = this._parentTrigger) === null || _a === void 0 ? void 0 : _a.registerChildMenu(this);
|
|
1144
1258
|
}
|
|
1145
1259
|
ngAfterContentInit() {
|
|
1146
1260
|
var _a;
|
|
1147
1261
|
super.ngAfterContentInit();
|
|
1148
1262
|
this._completeChangeEmitter();
|
|
1149
|
-
this.
|
|
1150
|
-
this._subscribeToMenuOpen();
|
|
1151
|
-
this._subscribeToMenuStack();
|
|
1263
|
+
this._subscribeToMenuStackEmptied();
|
|
1152
1264
|
this._subscribeToMouseManager();
|
|
1153
|
-
(_a = this._menuAim) === null || _a === void 0 ? void 0 : _a.initialize(this, this.
|
|
1154
|
-
}
|
|
1155
|
-
/** Place focus on the first MenuItem in the menu and set the focus origin. */
|
|
1156
|
-
focusFirstItem(focusOrigin = 'program') {
|
|
1157
|
-
this._keyManager.setFocusOrigin(focusOrigin);
|
|
1158
|
-
this._keyManager.setFirstItemActive();
|
|
1265
|
+
(_a = this._menuAim) === null || _a === void 0 ? void 0 : _a.initialize(this, this.pointerTracker);
|
|
1159
1266
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
this.
|
|
1267
|
+
ngOnDestroy() {
|
|
1268
|
+
var _a;
|
|
1269
|
+
super.ngOnDestroy();
|
|
1270
|
+
this.closed.complete();
|
|
1271
|
+
(_a = this.pointerTracker) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
1164
1272
|
}
|
|
1165
1273
|
/** Handle keyboard events for the Menu. */
|
|
1166
1274
|
_handleKeyEvent(event) {
|
|
1167
|
-
|
|
1168
|
-
const keyManager = this._keyManager;
|
|
1275
|
+
const keyManager = this.keyManager;
|
|
1169
1276
|
switch (event.keyCode) {
|
|
1170
1277
|
case LEFT_ARROW:
|
|
1171
1278
|
case RIGHT_ARROW:
|
|
1172
|
-
if (this.
|
|
1279
|
+
if (this.isHorizontal()) {
|
|
1173
1280
|
event.preventDefault();
|
|
1174
1281
|
keyManager.setFocusOrigin('keyboard');
|
|
1175
1282
|
keyManager.onKeydown(event);
|
|
@@ -1177,7 +1284,7 @@ class CdkMenu extends CdkMenuGroup {
|
|
|
1177
1284
|
break;
|
|
1178
1285
|
case UP_ARROW:
|
|
1179
1286
|
case DOWN_ARROW:
|
|
1180
|
-
if (!this.
|
|
1287
|
+
if (!this.isHorizontal()) {
|
|
1181
1288
|
event.preventDefault();
|
|
1182
1289
|
keyManager.setFocusOrigin('keyboard');
|
|
1183
1290
|
keyManager.onKeydown(event);
|
|
@@ -1186,11 +1293,11 @@ class CdkMenu extends CdkMenuGroup {
|
|
|
1186
1293
|
case ESCAPE:
|
|
1187
1294
|
if (!hasModifierKey(event)) {
|
|
1188
1295
|
event.preventDefault();
|
|
1189
|
-
|
|
1296
|
+
this.menuStack.close(this, 2 /* currentItem */);
|
|
1190
1297
|
}
|
|
1191
1298
|
break;
|
|
1192
1299
|
case TAB:
|
|
1193
|
-
|
|
1300
|
+
this.menuStack.closeAll();
|
|
1194
1301
|
break;
|
|
1195
1302
|
default:
|
|
1196
1303
|
keyManager.onKeydown(event);
|
|
@@ -1200,6 +1307,9 @@ class CdkMenu extends CdkMenuGroup {
|
|
|
1200
1307
|
* Complete the change emitter if there are any nested MenuGroups or register to complete the
|
|
1201
1308
|
* change emitter if a MenuGroup is rendered at some point
|
|
1202
1309
|
*/
|
|
1310
|
+
// TODO(mmalerba): This doesnt' quite work. It causes change events to stop
|
|
1311
|
+
// firing for radio items directly in the menu if a second group of options
|
|
1312
|
+
// is added in a menu-group.
|
|
1203
1313
|
_completeChangeEmitter() {
|
|
1204
1314
|
if (this._hasNestedGroups()) {
|
|
1205
1315
|
this.change.complete();
|
|
@@ -1216,58 +1326,21 @@ class CdkMenu extends CdkMenuGroup {
|
|
|
1216
1326
|
// order to ensure that we return true iff there are child CdkMenuGroup elements.
|
|
1217
1327
|
return this._nestedGroups.length > 0 && !(this._nestedGroups.first instanceof CdkMenu);
|
|
1218
1328
|
}
|
|
1219
|
-
/** Setup the FocusKeyManager with the correct orientation for the menu. */
|
|
1220
|
-
_setKeyManager() {
|
|
1221
|
-
var _a;
|
|
1222
|
-
this._keyManager = new FocusKeyManager(this._allItems)
|
|
1223
|
-
.withWrap()
|
|
1224
|
-
.withTypeAhead()
|
|
1225
|
-
.withHomeAndEnd();
|
|
1226
|
-
if (this._isHorizontal()) {
|
|
1227
|
-
this._keyManager.withHorizontalOrientation(((_a = this._dir) === null || _a === void 0 ? void 0 : _a.value) || 'ltr');
|
|
1228
|
-
}
|
|
1229
|
-
else {
|
|
1230
|
-
this._keyManager.withVerticalOrientation();
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
1329
|
/**
|
|
1234
1330
|
* Set the PointerFocusTracker and ensure that when mouse focus changes the key manager is updated
|
|
1235
1331
|
* with the latest menu item under mouse focus.
|
|
1236
1332
|
*/
|
|
1237
1333
|
_subscribeToMouseManager() {
|
|
1238
1334
|
this._ngZone.runOutsideAngular(() => {
|
|
1239
|
-
this.
|
|
1240
|
-
this.
|
|
1335
|
+
this.pointerTracker = new PointerFocusTracker(this.items);
|
|
1336
|
+
this.pointerTracker.entered
|
|
1241
1337
|
.pipe(takeUntil(this.closed))
|
|
1242
|
-
.subscribe(item => this.
|
|
1338
|
+
.subscribe(item => this.keyManager.setActiveItem(item));
|
|
1243
1339
|
});
|
|
1244
1340
|
}
|
|
1245
|
-
/** Subscribe to the MenuStack close and empty observables. */
|
|
1246
|
-
_subscribeToMenuStack() {
|
|
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));
|
|
1250
|
-
}
|
|
1251
|
-
/**
|
|
1252
|
-
* Close the open menu if the current active item opened the requested MenuStackItem.
|
|
1253
|
-
* @param item the MenuStackItem requested to be closed.
|
|
1254
|
-
*/
|
|
1255
|
-
_closeOpenMenu(menu) {
|
|
1256
|
-
var _a, _b, _c;
|
|
1257
|
-
const keyManager = this._keyManager;
|
|
1258
|
-
const trigger = this._openItem;
|
|
1259
|
-
if (menu === ((_a = trigger === null || trigger === void 0 ? void 0 : trigger.getMenuTrigger()) === null || _a === void 0 ? void 0 : _a.getMenu())) {
|
|
1260
|
-
(_b = trigger === null || trigger === void 0 ? void 0 : trigger.getMenuTrigger()) === null || _b === void 0 ? void 0 : _b.closeMenu();
|
|
1261
|
-
// If the user has moused over a sibling item we want to focus the element under mouse focus
|
|
1262
|
-
// not the trigger which previously opened the now closed menu.
|
|
1263
|
-
if (trigger) {
|
|
1264
|
-
keyManager.setActiveItem(((_c = this._pointerTracker) === null || _c === void 0 ? void 0 : _c.activeElement) || trigger);
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
1341
|
/** Set focus the either the current, previous or next item based on the FocusNext event. */
|
|
1269
1342
|
_toggleMenuFocus(event) {
|
|
1270
|
-
const keyManager = this.
|
|
1343
|
+
const keyManager = this.keyManager;
|
|
1271
1344
|
switch (event) {
|
|
1272
1345
|
case 0 /* nextItem */:
|
|
1273
1346
|
keyManager.setFocusOrigin('keyboard');
|
|
@@ -1285,73 +1358,45 @@ class CdkMenu extends CdkMenuGroup {
|
|
|
1285
1358
|
break;
|
|
1286
1359
|
}
|
|
1287
1360
|
}
|
|
1288
|
-
// TODO(andy9775): remove duplicate logic between menu an menu bar
|
|
1289
|
-
/**
|
|
1290
|
-
* Subscribe to the menu trigger's open events in order to track the trigger which opened the menu
|
|
1291
|
-
* and stop tracking it when the menu is closed.
|
|
1292
|
-
*/
|
|
1293
|
-
_subscribeToMenuOpen() {
|
|
1294
|
-
const exitCondition = merge(this._allItems.changes, this.closed);
|
|
1295
|
-
this._allItems.changes
|
|
1296
|
-
.pipe(startWith(this._allItems), mergeMap((list) => list
|
|
1297
|
-
.filter(item => item.hasMenu())
|
|
1298
|
-
.map(item => item.getMenuTrigger().opened.pipe(mapTo(item), takeUntil(exitCondition)))), mergeAll(), switchMap((item) => {
|
|
1299
|
-
this._openItem = item;
|
|
1300
|
-
return item.getMenuTrigger().closed;
|
|
1301
|
-
}), takeUntil(this.closed))
|
|
1302
|
-
.subscribe(() => (this._openItem = undefined));
|
|
1303
|
-
}
|
|
1304
|
-
/** Return true if this menu has been configured in a horizontal orientation. */
|
|
1305
|
-
_isHorizontal() {
|
|
1306
|
-
return this.orientation === 'horizontal';
|
|
1307
|
-
}
|
|
1308
1361
|
/**
|
|
1309
1362
|
* Return true if this menu is an inline menu. That is, it does not exist in a pop-up and is
|
|
1310
1363
|
* always visible in the dom.
|
|
1311
1364
|
*/
|
|
1312
1365
|
_isInline() {
|
|
1313
|
-
return !this.
|
|
1314
|
-
}
|
|
1315
|
-
ngOnDestroy() {
|
|
1316
|
-
var _a;
|
|
1317
|
-
super.ngOnDestroy();
|
|
1318
|
-
this._emitClosedEvent();
|
|
1319
|
-
(_a = this._pointerTracker) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
1366
|
+
return !this._parentTrigger;
|
|
1320
1367
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1368
|
+
_subscribeToMenuStackEmptied() {
|
|
1369
|
+
this.menuStack.emptied
|
|
1370
|
+
.pipe(takeUntil(this.destroyed))
|
|
1371
|
+
.subscribe(event => this._toggleMenuFocus(event));
|
|
1325
1372
|
}
|
|
1326
1373
|
}
|
|
1327
|
-
CdkMenu.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1328
|
-
CdkMenu.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1374
|
+
CdkMenu.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenu, deps: [{ token: i0.NgZone }, { token: i0.ElementRef }, { token: MENU_STACK }, { token: MENU_TRIGGER, optional: true }, { token: MENU_AIM, optional: true, self: true }, { token: i1$1.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1375
|
+
CdkMenu.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.9", type: CdkMenu, selector: "[cdkMenu]", outputs: { closed: "closed" }, host: { attributes: { "role": "menu" }, listeners: { "keydown": "_handleKeyEvent($event)" }, properties: { "tabindex": "_isInline() ? 0 : null", "class.cdk-menu-inline": "_isInline()" }, classAttribute: "cdk-menu" }, providers: [
|
|
1329
1376
|
{ provide: CdkMenuGroup, useExisting: CdkMenu },
|
|
1330
1377
|
{ provide: CDK_MENU, useExisting: CdkMenu },
|
|
1331
|
-
|
|
1332
|
-
|
|
1378
|
+
PARENT_OR_NEW_INLINE_MENU_STACK_PROVIDER,
|
|
1379
|
+
], queries: [{ propertyName: "_nestedGroups", predicate: CdkMenuGroup, descendants: true }], exportAs: ["cdkMenu"], usesInheritance: true, ngImport: i0 });
|
|
1380
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenu, decorators: [{
|
|
1333
1381
|
type: Directive,
|
|
1334
1382
|
args: [{
|
|
1335
1383
|
selector: '[cdkMenu]',
|
|
1336
1384
|
exportAs: 'cdkMenu',
|
|
1337
1385
|
host: {
|
|
1338
|
-
'[tabindex]': '_isInline() ? 0 : null',
|
|
1339
1386
|
'role': 'menu',
|
|
1340
1387
|
'class': 'cdk-menu',
|
|
1388
|
+
'[tabindex]': '_isInline() ? 0 : null',
|
|
1341
1389
|
'[class.cdk-menu-inline]': '_isInline()',
|
|
1342
|
-
'[attr.aria-orientation]': 'orientation',
|
|
1343
|
-
'(focus)': 'focusFirstItem()',
|
|
1344
1390
|
'(keydown)': '_handleKeyEvent($event)',
|
|
1345
1391
|
},
|
|
1346
1392
|
providers: [
|
|
1347
1393
|
{ provide: CdkMenuGroup, useExisting: CdkMenu },
|
|
1348
1394
|
{ provide: CDK_MENU, useExisting: CdkMenu },
|
|
1395
|
+
PARENT_OR_NEW_INLINE_MENU_STACK_PROVIDER,
|
|
1349
1396
|
],
|
|
1350
1397
|
}]
|
|
1351
1398
|
}], ctorParameters: function () {
|
|
1352
1399
|
return [{ type: i0.NgZone }, { type: i0.ElementRef }, { type: MenuStack, decorators: [{
|
|
1353
|
-
type: Optional
|
|
1354
|
-
}, {
|
|
1355
1400
|
type: Inject,
|
|
1356
1401
|
args: [MENU_STACK]
|
|
1357
1402
|
}] }, { type: MenuTrigger, decorators: [{
|
|
@@ -1369,17 +1414,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6",
|
|
|
1369
1414
|
}] }, { type: i1$1.Directionality, decorators: [{
|
|
1370
1415
|
type: Optional
|
|
1371
1416
|
}] }];
|
|
1372
|
-
}, propDecorators: {
|
|
1373
|
-
type: Input,
|
|
1374
|
-
args: ['cdkMenuOrientation']
|
|
1375
|
-
}], closed: [{
|
|
1417
|
+
}, propDecorators: { closed: [{
|
|
1376
1418
|
type: Output
|
|
1377
1419
|
}], _nestedGroups: [{
|
|
1378
1420
|
type: ContentChildren,
|
|
1379
1421
|
args: [CdkMenuGroup, { descendants: true }]
|
|
1380
|
-
}], _allItems: [{
|
|
1381
|
-
type: ContentChildren,
|
|
1382
|
-
args: [CdkMenuItem, { descendants: true }]
|
|
1383
1422
|
}] } });
|
|
1384
1423
|
|
|
1385
1424
|
/**
|
|
@@ -1395,40 +1434,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6",
|
|
|
1395
1434
|
* this directive is applied to should contain components marked with CdkMenuItem.
|
|
1396
1435
|
*
|
|
1397
1436
|
*/
|
|
1398
|
-
class CdkMenuBar extends
|
|
1399
|
-
constructor(_ngZone,
|
|
1400
|
-
super();
|
|
1437
|
+
class CdkMenuBar extends CdkMenuBase {
|
|
1438
|
+
constructor(_ngZone, elementRef, menuStack, _menuAim, dir) {
|
|
1439
|
+
super(elementRef, menuStack, dir);
|
|
1401
1440
|
this._ngZone = _ngZone;
|
|
1402
|
-
this._elementRef = _elementRef;
|
|
1403
|
-
this._menuStack = _menuStack;
|
|
1404
1441
|
this._menuAim = _menuAim;
|
|
1405
|
-
this._dir = _dir;
|
|
1406
|
-
/**
|
|
1407
|
-
* Sets the aria-orientation attribute and determines where menus will be opened.
|
|
1408
|
-
* Does not affect styling/layout.
|
|
1409
|
-
*/
|
|
1410
1442
|
this.orientation = 'horizontal';
|
|
1411
|
-
/** Emits when the MenuBar is destroyed. */
|
|
1412
|
-
this._destroyed = new Subject();
|
|
1413
1443
|
}
|
|
1414
1444
|
ngAfterContentInit() {
|
|
1415
1445
|
var _a;
|
|
1416
1446
|
super.ngAfterContentInit();
|
|
1417
|
-
this.
|
|
1418
|
-
this._subscribeToMenuOpen();
|
|
1419
|
-
this._subscribeToMenuStack();
|
|
1447
|
+
this._subscribeToMenuStackEmptied();
|
|
1420
1448
|
this._subscribeToMouseManager();
|
|
1421
|
-
(_a = this._menuAim) === null || _a === void 0 ? void 0 : _a.initialize(this, this.
|
|
1422
|
-
}
|
|
1423
|
-
/** Place focus on the first MenuItem in the menu and set the focus origin. */
|
|
1424
|
-
focusFirstItem(focusOrigin = 'program') {
|
|
1425
|
-
this._keyManager.setFocusOrigin(focusOrigin);
|
|
1426
|
-
this._keyManager.setFirstItemActive();
|
|
1449
|
+
(_a = this._menuAim) === null || _a === void 0 ? void 0 : _a.initialize(this, this.pointerTracker);
|
|
1427
1450
|
}
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
this.
|
|
1451
|
+
ngOnDestroy() {
|
|
1452
|
+
var _a;
|
|
1453
|
+
super.ngOnDestroy();
|
|
1454
|
+
(_a = this.pointerTracker) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
1432
1455
|
}
|
|
1433
1456
|
/**
|
|
1434
1457
|
* Handle keyboard events, specifically changing the focused element and/or toggling the active
|
|
@@ -1437,7 +1460,7 @@ class CdkMenuBar extends CdkMenuGroup {
|
|
|
1437
1460
|
*/
|
|
1438
1461
|
_handleKeyEvent(event) {
|
|
1439
1462
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1440
|
-
const keyManager = this.
|
|
1463
|
+
const keyManager = this.keyManager;
|
|
1441
1464
|
switch (event.keyCode) {
|
|
1442
1465
|
case UP_ARROW:
|
|
1443
1466
|
case DOWN_ARROW:
|
|
@@ -1447,100 +1470,60 @@ class CdkMenuBar extends CdkMenuGroup {
|
|
|
1447
1470
|
// For a horizontal menu if the left/right keys were clicked, or a vertical menu if the
|
|
1448
1471
|
// up/down keys were clicked: if the current menu is open, close it then focus and open the
|
|
1449
1472
|
// next menu.
|
|
1450
|
-
if ((this.
|
|
1451
|
-
(!this.
|
|
1473
|
+
if ((this.isHorizontal() && horizontalArrows) ||
|
|
1474
|
+
(!this.isHorizontal() && !horizontalArrows)) {
|
|
1452
1475
|
event.preventDefault();
|
|
1453
1476
|
const prevIsOpen = (_a = keyManager.activeItem) === null || _a === void 0 ? void 0 : _a.isMenuOpen();
|
|
1454
|
-
(_c = (_b = keyManager.activeItem) === null || _b === void 0 ? void 0 : _b.getMenuTrigger()) === null || _c === void 0 ? void 0 : _c.
|
|
1477
|
+
(_c = (_b = keyManager.activeItem) === null || _b === void 0 ? void 0 : _b.getMenuTrigger()) === null || _c === void 0 ? void 0 : _c.close();
|
|
1455
1478
|
keyManager.setFocusOrigin('keyboard');
|
|
1456
1479
|
keyManager.onKeydown(event);
|
|
1457
1480
|
if (prevIsOpen) {
|
|
1458
|
-
(_e = (_d = keyManager.activeItem) === null || _d === void 0 ? void 0 : _d.getMenuTrigger()) === null || _e === void 0 ? void 0 : _e.
|
|
1481
|
+
(_e = (_d = keyManager.activeItem) === null || _d === void 0 ? void 0 : _d.getMenuTrigger()) === null || _e === void 0 ? void 0 : _e.open();
|
|
1459
1482
|
}
|
|
1460
1483
|
}
|
|
1461
1484
|
break;
|
|
1462
1485
|
case ESCAPE:
|
|
1463
1486
|
event.preventDefault();
|
|
1464
|
-
(_g = (_f = keyManager.activeItem) === null || _f === void 0 ? void 0 : _f.getMenuTrigger()) === null || _g === void 0 ? void 0 : _g.
|
|
1487
|
+
(_g = (_f = keyManager.activeItem) === null || _f === void 0 ? void 0 : _f.getMenuTrigger()) === null || _g === void 0 ? void 0 : _g.close();
|
|
1465
1488
|
break;
|
|
1466
1489
|
case TAB:
|
|
1467
|
-
(_j = (_h = keyManager.activeItem) === null || _h === void 0 ? void 0 : _h.getMenuTrigger()) === null || _j === void 0 ? void 0 : _j.
|
|
1490
|
+
(_j = (_h = keyManager.activeItem) === null || _h === void 0 ? void 0 : _h.getMenuTrigger()) === null || _j === void 0 ? void 0 : _j.close();
|
|
1468
1491
|
break;
|
|
1469
1492
|
default:
|
|
1470
1493
|
keyManager.onKeydown(event);
|
|
1471
1494
|
}
|
|
1472
1495
|
}
|
|
1473
|
-
/** Setup the FocusKeyManager with the correct orientation for the menu bar. */
|
|
1474
|
-
_setKeyManager() {
|
|
1475
|
-
var _a;
|
|
1476
|
-
this._keyManager = new FocusKeyManager(this._allItems)
|
|
1477
|
-
.withWrap()
|
|
1478
|
-
.withTypeAhead()
|
|
1479
|
-
.withHomeAndEnd();
|
|
1480
|
-
if (this._isHorizontal()) {
|
|
1481
|
-
this._keyManager.withHorizontalOrientation(((_a = this._dir) === null || _a === void 0 ? void 0 : _a.value) || 'ltr');
|
|
1482
|
-
}
|
|
1483
|
-
else {
|
|
1484
|
-
this._keyManager.withVerticalOrientation();
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
1496
|
/**
|
|
1488
1497
|
* Set the PointerFocusTracker and ensure that when mouse focus changes the key manager is updated
|
|
1489
1498
|
* with the latest menu item under mouse focus.
|
|
1490
1499
|
*/
|
|
1491
1500
|
_subscribeToMouseManager() {
|
|
1492
1501
|
this._ngZone.runOutsideAngular(() => {
|
|
1493
|
-
this.
|
|
1494
|
-
this.
|
|
1495
|
-
if (this.
|
|
1496
|
-
this.
|
|
1502
|
+
this.pointerTracker = new PointerFocusTracker(this.items);
|
|
1503
|
+
this.pointerTracker.entered.pipe(takeUntil(this.destroyed)).subscribe(item => {
|
|
1504
|
+
if (this.hasOpenSubmenu()) {
|
|
1505
|
+
this.keyManager.setActiveItem(item);
|
|
1497
1506
|
}
|
|
1498
1507
|
});
|
|
1499
1508
|
});
|
|
1500
1509
|
}
|
|
1501
|
-
/** Subscribe to the MenuStack close and empty observables. */
|
|
1502
|
-
_subscribeToMenuStack() {
|
|
1503
|
-
this._menuStack.closed
|
|
1504
|
-
.pipe(takeUntil(this._destroyed))
|
|
1505
|
-
.subscribe(item => this._closeOpenMenu(item));
|
|
1506
|
-
this._menuStack.emptied
|
|
1507
|
-
.pipe(takeUntil(this._destroyed))
|
|
1508
|
-
.subscribe(event => this._toggleOpenMenu(event));
|
|
1509
|
-
}
|
|
1510
|
-
/**
|
|
1511
|
-
* Close the open menu if the current active item opened the requested MenuStackItem.
|
|
1512
|
-
* @param item the MenuStackItem requested to be closed.
|
|
1513
|
-
*/
|
|
1514
|
-
_closeOpenMenu(menu) {
|
|
1515
|
-
var _a, _b, _c;
|
|
1516
|
-
const trigger = this._openItem;
|
|
1517
|
-
const keyManager = this._keyManager;
|
|
1518
|
-
if (menu === ((_a = trigger === null || trigger === void 0 ? void 0 : trigger.getMenuTrigger()) === null || _a === void 0 ? void 0 : _a.getMenu())) {
|
|
1519
|
-
(_b = trigger === null || trigger === void 0 ? void 0 : trigger.getMenuTrigger()) === null || _b === void 0 ? void 0 : _b.closeMenu();
|
|
1520
|
-
// If the user has moused over a sibling item we want to focus the element under mouse focus
|
|
1521
|
-
// not the trigger which previously opened the now closed menu.
|
|
1522
|
-
if (trigger) {
|
|
1523
|
-
keyManager.setActiveItem(((_c = this._pointerTracker) === null || _c === void 0 ? void 0 : _c.activeElement) || trigger);
|
|
1524
|
-
}
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
1510
|
/**
|
|
1528
1511
|
* Set focus to either the current, previous or next item based on the FocusNext event, then
|
|
1529
1512
|
* open the previous or next item.
|
|
1530
1513
|
*/
|
|
1531
1514
|
_toggleOpenMenu(event) {
|
|
1532
1515
|
var _a, _b, _c, _d;
|
|
1533
|
-
const keyManager = this.
|
|
1516
|
+
const keyManager = this.keyManager;
|
|
1534
1517
|
switch (event) {
|
|
1535
1518
|
case 0 /* nextItem */:
|
|
1536
1519
|
keyManager.setFocusOrigin('keyboard');
|
|
1537
1520
|
keyManager.setNextItemActive();
|
|
1538
|
-
(_b = (_a = keyManager.activeItem) === null || _a === void 0 ? void 0 : _a.getMenuTrigger()) === null || _b === void 0 ? void 0 : _b.
|
|
1521
|
+
(_b = (_a = keyManager.activeItem) === null || _a === void 0 ? void 0 : _a.getMenuTrigger()) === null || _b === void 0 ? void 0 : _b.open();
|
|
1539
1522
|
break;
|
|
1540
1523
|
case 1 /* previousItem */:
|
|
1541
1524
|
keyManager.setFocusOrigin('keyboard');
|
|
1542
1525
|
keyManager.setPreviousItemActive();
|
|
1543
|
-
(_d = (_c = keyManager.activeItem) === null || _c === void 0 ? void 0 : _c.getMenuTrigger()) === null || _d === void 0 ? void 0 : _d.
|
|
1526
|
+
(_d = (_c = keyManager.activeItem) === null || _c === void 0 ? void 0 : _c.getMenuTrigger()) === null || _d === void 0 ? void 0 : _d.open();
|
|
1544
1527
|
break;
|
|
1545
1528
|
case 2 /* currentItem */:
|
|
1546
1529
|
if (keyManager.activeItem) {
|
|
@@ -1550,46 +1533,18 @@ class CdkMenuBar extends CdkMenuGroup {
|
|
|
1550
1533
|
break;
|
|
1551
1534
|
}
|
|
1552
1535
|
}
|
|
1553
|
-
|
|
1554
|
-
* @return true if the menu bar is configured to be horizontal.
|
|
1555
|
-
*/
|
|
1556
|
-
_isHorizontal() {
|
|
1557
|
-
return this.orientation === 'horizontal';
|
|
1558
|
-
}
|
|
1559
|
-
/**
|
|
1560
|
-
* Subscribe to the menu trigger's open events in order to track the trigger which opened the menu
|
|
1561
|
-
* and stop tracking it when the menu is closed.
|
|
1562
|
-
*/
|
|
1563
|
-
_subscribeToMenuOpen() {
|
|
1564
|
-
const exitCondition = merge(this._allItems.changes, this._destroyed);
|
|
1565
|
-
this._allItems.changes
|
|
1566
|
-
.pipe(startWith(this._allItems), mergeMap((list) => list
|
|
1567
|
-
.filter(item => item.hasMenu())
|
|
1568
|
-
.map(item => item.getMenuTrigger().opened.pipe(mapTo(item), takeUntil(exitCondition)))), mergeAll(), switchMap((item) => {
|
|
1569
|
-
this._openItem = item;
|
|
1570
|
-
return item.getMenuTrigger().closed;
|
|
1571
|
-
}), takeUntil(this._destroyed))
|
|
1572
|
-
.subscribe(() => (this._openItem = undefined));
|
|
1573
|
-
}
|
|
1574
|
-
/** Return true if the MenuBar has an open submenu. */
|
|
1575
|
-
_hasOpenSubmenu() {
|
|
1576
|
-
return !!this._openItem;
|
|
1577
|
-
}
|
|
1578
|
-
ngOnDestroy() {
|
|
1536
|
+
_subscribeToMenuStackEmptied() {
|
|
1579
1537
|
var _a;
|
|
1580
|
-
|
|
1581
|
-
this._destroyed.next();
|
|
1582
|
-
this._destroyed.complete();
|
|
1583
|
-
(_a = this._pointerTracker) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
1538
|
+
(_a = this.menuStack) === null || _a === void 0 ? void 0 : _a.emptied.pipe(takeUntil(this.destroyed)).subscribe(event => this._toggleOpenMenu(event));
|
|
1584
1539
|
}
|
|
1585
1540
|
}
|
|
1586
|
-
CdkMenuBar.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1587
|
-
CdkMenuBar.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1541
|
+
CdkMenuBar.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.9", 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 });
|
|
1542
|
+
CdkMenuBar.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.9", type: CdkMenuBar, selector: "[cdkMenuBar]", host: { attributes: { "role": "menubar", "tabindex": "0" }, listeners: { "keydown": "_handleKeyEvent($event)" }, classAttribute: "cdk-menu-bar" }, providers: [
|
|
1588
1543
|
{ provide: CdkMenuGroup, useExisting: CdkMenuBar },
|
|
1589
1544
|
{ provide: CDK_MENU, useExisting: CdkMenuBar },
|
|
1590
|
-
{ provide: MENU_STACK,
|
|
1591
|
-
],
|
|
1592
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1545
|
+
{ provide: MENU_STACK, useFactory: () => MenuStack.inline() },
|
|
1546
|
+
], exportAs: ["cdkMenuBar"], usesInheritance: true, ngImport: i0 });
|
|
1547
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuBar, decorators: [{
|
|
1593
1548
|
type: Directive,
|
|
1594
1549
|
args: [{
|
|
1595
1550
|
selector: '[cdkMenuBar]',
|
|
@@ -1598,14 +1553,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6",
|
|
|
1598
1553
|
'role': 'menubar',
|
|
1599
1554
|
'class': 'cdk-menu-bar',
|
|
1600
1555
|
'tabindex': '0',
|
|
1601
|
-
'[attr.aria-orientation]': 'orientation',
|
|
1602
|
-
'(focus)': 'focusFirstItem()',
|
|
1603
1556
|
'(keydown)': '_handleKeyEvent($event)',
|
|
1604
1557
|
},
|
|
1605
1558
|
providers: [
|
|
1606
1559
|
{ provide: CdkMenuGroup, useExisting: CdkMenuBar },
|
|
1607
1560
|
{ provide: CDK_MENU, useExisting: CdkMenuBar },
|
|
1608
|
-
{ provide: MENU_STACK,
|
|
1561
|
+
{ provide: MENU_STACK, useFactory: () => MenuStack.inline() },
|
|
1609
1562
|
],
|
|
1610
1563
|
}]
|
|
1611
1564
|
}], ctorParameters: function () {
|
|
@@ -1622,13 +1575,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6",
|
|
|
1622
1575
|
}] }, { type: i1$1.Directionality, decorators: [{
|
|
1623
1576
|
type: Optional
|
|
1624
1577
|
}] }];
|
|
1625
|
-
}
|
|
1626
|
-
type: Input,
|
|
1627
|
-
args: ['cdkMenuBarOrientation']
|
|
1628
|
-
}], _allItems: [{
|
|
1629
|
-
type: ContentChildren,
|
|
1630
|
-
args: [CdkMenuItem, { descendants: true }]
|
|
1631
|
-
}] } });
|
|
1578
|
+
} });
|
|
1632
1579
|
|
|
1633
1580
|
/**
|
|
1634
1581
|
* A directive providing behavior for the "menuitemradio" ARIA role, which behaves similarly to
|
|
@@ -1661,12 +1608,12 @@ class CdkMenuItemRadio extends CdkMenuItemSelectable {
|
|
|
1661
1608
|
this._removeDispatcherListener();
|
|
1662
1609
|
}
|
|
1663
1610
|
}
|
|
1664
|
-
CdkMenuItemRadio.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1665
|
-
CdkMenuItemRadio.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1611
|
+
CdkMenuItemRadio.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuItemRadio, deps: [{ token: i1$2.UniqueSelectionDispatcher }, { token: i0.ElementRef }, { token: i0.NgZone }, { token: MENU_STACK }, { 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 });
|
|
1612
|
+
CdkMenuItemRadio.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.9", type: CdkMenuItemRadio, selector: "[cdkMenuItemRadio]", host: { attributes: { "type": "button", "role": "menuitemradio" }, properties: { "tabindex": "_tabindex", "attr.aria-checked": "checked || null", "attr.aria-disabled": "disabled || null" } }, providers: [
|
|
1666
1613
|
{ provide: CdkMenuItemSelectable, useExisting: CdkMenuItemRadio },
|
|
1667
1614
|
{ provide: CdkMenuItem, useExisting: CdkMenuItemSelectable },
|
|
1668
1615
|
], exportAs: ["cdkMenuItemRadio"], usesInheritance: true, ngImport: i0 });
|
|
1669
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1616
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuItemRadio, decorators: [{
|
|
1670
1617
|
type: Directive,
|
|
1671
1618
|
args: [{
|
|
1672
1619
|
selector: '[cdkMenuItemRadio]',
|
|
@@ -1685,8 +1632,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6",
|
|
|
1685
1632
|
}]
|
|
1686
1633
|
}], ctorParameters: function () {
|
|
1687
1634
|
return [{ type: i1$2.UniqueSelectionDispatcher }, { type: i0.ElementRef }, { type: i0.NgZone }, { type: MenuStack, decorators: [{
|
|
1688
|
-
type: Optional
|
|
1689
|
-
}, {
|
|
1690
1635
|
type: Inject,
|
|
1691
1636
|
args: [MENU_STACK]
|
|
1692
1637
|
}] }, { type: undefined, decorators: [{
|
|
@@ -1728,12 +1673,12 @@ class CdkMenuItemCheckbox extends CdkMenuItemSelectable {
|
|
|
1728
1673
|
}
|
|
1729
1674
|
}
|
|
1730
1675
|
}
|
|
1731
|
-
CdkMenuItemCheckbox.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1732
|
-
CdkMenuItemCheckbox.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1676
|
+
CdkMenuItemCheckbox.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuItemCheckbox, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1677
|
+
CdkMenuItemCheckbox.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.9", type: CdkMenuItemCheckbox, selector: "[cdkMenuItemCheckbox]", host: { attributes: { "type": "button", "role": "menuitemcheckbox" }, properties: { "tabindex": "_tabindex", "attr.aria-checked": "checked || null", "attr.aria-disabled": "disabled || null" } }, providers: [
|
|
1733
1678
|
{ provide: CdkMenuItemSelectable, useExisting: CdkMenuItemCheckbox },
|
|
1734
1679
|
{ provide: CdkMenuItem, useExisting: CdkMenuItemSelectable },
|
|
1735
1680
|
], exportAs: ["cdkMenuItemCheckbox"], usesInheritance: true, ngImport: i0 });
|
|
1736
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1681
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuItemCheckbox, decorators: [{
|
|
1737
1682
|
type: Directive,
|
|
1738
1683
|
args: [{
|
|
1739
1684
|
selector: '[cdkMenuItemCheckbox]',
|
|
@@ -1780,9 +1725,9 @@ class ContextMenuTracker {
|
|
|
1780
1725
|
}
|
|
1781
1726
|
}
|
|
1782
1727
|
}
|
|
1783
|
-
ContextMenuTracker.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1784
|
-
ContextMenuTracker.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1785
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1728
|
+
ContextMenuTracker.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: ContextMenuTracker, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1729
|
+
ContextMenuTracker.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: ContextMenuTracker, providedIn: 'root' });
|
|
1730
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: ContextMenuTracker, decorators: [{
|
|
1786
1731
|
type: Injectable,
|
|
1787
1732
|
args: [{ providedIn: 'root' }]
|
|
1788
1733
|
}] });
|
|
@@ -1798,17 +1743,7 @@ class CdkContextMenuTrigger extends MenuTrigger {
|
|
|
1798
1743
|
this._overlay = _overlay;
|
|
1799
1744
|
this._contextMenuTracker = _contextMenuTracker;
|
|
1800
1745
|
this._directionality = _directionality;
|
|
1801
|
-
/** Emits when the attached menu is requested to open. */
|
|
1802
|
-
this.opened = new EventEmitter();
|
|
1803
|
-
/** Emits when the attached menu is requested to close. */
|
|
1804
|
-
this.closed = new EventEmitter();
|
|
1805
1746
|
this._disabled = false;
|
|
1806
|
-
/** A reference to the overlay which manages the triggered menu. */
|
|
1807
|
-
this._overlayRef = null;
|
|
1808
|
-
/** Emits when the element is destroyed. */
|
|
1809
|
-
this._destroyed = new Subject();
|
|
1810
|
-
/** Emits when the outside pointer events listener on the overlay should be stopped. */
|
|
1811
|
-
this._stopOutsideClicksListener = merge(this.closed, this._destroyed);
|
|
1812
1747
|
this._setMenuStackListener();
|
|
1813
1748
|
}
|
|
1814
1749
|
/** Whether the context menu should be disabled. */
|
|
@@ -1880,11 +1815,6 @@ class CdkContextMenuTrigger extends MenuTrigger {
|
|
|
1880
1815
|
}
|
|
1881
1816
|
}
|
|
1882
1817
|
}
|
|
1883
|
-
/** Whether the attached menu is open. */
|
|
1884
|
-
isOpen() {
|
|
1885
|
-
var _a;
|
|
1886
|
-
return !!((_a = this._overlayRef) === null || _a === void 0 ? void 0 : _a.hasAttached());
|
|
1887
|
-
}
|
|
1888
1818
|
/**
|
|
1889
1819
|
* Get the configuration object used to create the overlay.
|
|
1890
1820
|
* @param coordinates the location to place the opened menu
|
|
@@ -1948,25 +1878,13 @@ class CdkContextMenuTrigger extends MenuTrigger {
|
|
|
1948
1878
|
});
|
|
1949
1879
|
}
|
|
1950
1880
|
}
|
|
1951
|
-
ngOnDestroy() {
|
|
1952
|
-
this._destroyOverlay();
|
|
1953
|
-
this._destroyed.next();
|
|
1954
|
-
this._destroyed.complete();
|
|
1955
|
-
}
|
|
1956
|
-
/** Destroy and unset the overlay reference it if exists. */
|
|
1957
|
-
_destroyOverlay() {
|
|
1958
|
-
if (this._overlayRef) {
|
|
1959
|
-
this._overlayRef.dispose();
|
|
1960
|
-
this._overlayRef = null;
|
|
1961
|
-
}
|
|
1962
|
-
}
|
|
1963
1881
|
}
|
|
1964
|
-
CdkContextMenuTrigger.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1965
|
-
CdkContextMenuTrigger.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1882
|
+
CdkContextMenuTrigger.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.9", 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 });
|
|
1883
|
+
CdkContextMenuTrigger.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "14.0.0-next.9", type: CdkContextMenuTrigger, selector: "[cdkContextMenuTriggerFor]", inputs: { _menuTemplateRef: ["cdkContextMenuTriggerFor", "_menuTemplateRef"], menuPosition: ["cdkContextMenuPosition", "menuPosition"], disabled: ["cdkContextMenuDisabled", "disabled"] }, outputs: { opened: "cdkContextMenuOpened", closed: "cdkContextMenuClosed" }, host: { listeners: { "contextmenu": "_openOnContextMenu($event)" } }, providers: [
|
|
1966
1884
|
{ provide: MENU_TRIGGER, useExisting: CdkContextMenuTrigger },
|
|
1967
1885
|
{ provide: MENU_STACK, useClass: MenuStack },
|
|
1968
1886
|
], exportAs: ["cdkContextMenuTriggerFor"], usesInheritance: true, ngImport: i0 });
|
|
1969
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1887
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkContextMenuTrigger, decorators: [{
|
|
1970
1888
|
type: Directive,
|
|
1971
1889
|
args: [{
|
|
1972
1890
|
selector: '[cdkContextMenuTriggerFor]',
|
|
@@ -1974,6 +1892,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6",
|
|
|
1974
1892
|
host: {
|
|
1975
1893
|
'(contextmenu)': '_openOnContextMenu($event)',
|
|
1976
1894
|
},
|
|
1895
|
+
inputs: ['_menuTemplateRef: cdkContextMenuTriggerFor', 'menuPosition: cdkContextMenuPosition'],
|
|
1896
|
+
outputs: ['opened: cdkContextMenuOpened', 'closed: cdkContextMenuClosed'],
|
|
1977
1897
|
providers: [
|
|
1978
1898
|
{ provide: MENU_TRIGGER, useExisting: CdkContextMenuTrigger },
|
|
1979
1899
|
{ provide: MENU_STACK, useClass: MenuStack },
|
|
@@ -1986,19 +1906,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.6",
|
|
|
1986
1906
|
}] }, { type: i1$1.Directionality, decorators: [{
|
|
1987
1907
|
type: Optional
|
|
1988
1908
|
}] }];
|
|
1989
|
-
}, propDecorators: {
|
|
1990
|
-
type: Input,
|
|
1991
|
-
args: ['cdkContextMenuTriggerFor']
|
|
1992
|
-
}], menuPosition: [{
|
|
1993
|
-
type: Input,
|
|
1994
|
-
args: ['cdkMenuPosition']
|
|
1995
|
-
}], opened: [{
|
|
1996
|
-
type: Output,
|
|
1997
|
-
args: ['cdkContextMenuOpened']
|
|
1998
|
-
}], closed: [{
|
|
1999
|
-
type: Output,
|
|
2000
|
-
args: ['cdkContextMenuClosed']
|
|
2001
|
-
}], disabled: [{
|
|
1909
|
+
}, propDecorators: { disabled: [{
|
|
2002
1910
|
type: Input,
|
|
2003
1911
|
args: ['cdkContextMenuDisabled']
|
|
2004
1912
|
}] } });
|
|
@@ -2023,8 +1931,8 @@ const EXPORTED_DECLARATIONS = [
|
|
|
2023
1931
|
];
|
|
2024
1932
|
class CdkMenuModule {
|
|
2025
1933
|
}
|
|
2026
|
-
CdkMenuModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
2027
|
-
CdkMenuModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1934
|
+
CdkMenuModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1935
|
+
CdkMenuModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuModule, declarations: [CdkMenuBar,
|
|
2028
1936
|
CdkMenu,
|
|
2029
1937
|
CdkMenuItem,
|
|
2030
1938
|
CdkMenuItemRadio,
|
|
@@ -2041,8 +1949,8 @@ CdkMenuModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version:
|
|
|
2041
1949
|
CdkMenuGroup,
|
|
2042
1950
|
CdkContextMenuTrigger,
|
|
2043
1951
|
CdkTargetMenuAim] });
|
|
2044
|
-
CdkMenuModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
2045
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
1952
|
+
CdkMenuModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuModule, imports: [[OverlayModule]] });
|
|
1953
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.9", ngImport: i0, type: CdkMenuModule, decorators: [{
|
|
2046
1954
|
type: NgModule,
|
|
2047
1955
|
args: [{
|
|
2048
1956
|
imports: [OverlayModule],
|