1 | /**
|
2 | * @license
|
3 | * Copyright Google LLC All Rights Reserved.
|
4 | *
|
5 | * Use of this source code is governed by an MIT-style license that can be
|
6 | * found in the LICENSE file at https://angular.io/license
|
7 | */
|
8 | import { Directive, inject, Injectable, Input } from '@angular/core';
|
9 | import { Directionality } from '@angular/cdk/bidi';
|
10 | import { Overlay, OverlayConfig, STANDARD_DROPDOWN_BELOW_POSITIONS, } from '@angular/cdk/overlay';
|
11 | import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
12 | import { _getEventTarget } from '@angular/cdk/platform';
|
13 | import { merge, partition } from 'rxjs';
|
14 | import { skip, takeUntil } from 'rxjs/operators';
|
15 | import { MENU_STACK, MenuStack } from './menu-stack';
|
16 | import { CdkMenuTriggerBase, MENU_TRIGGER } from './menu-trigger-base';
|
17 | import * as i0 from "@angular/core";
|
18 | /** The preferred menu positions for the context menu. */
|
19 | const CONTEXT_MENU_POSITIONS = STANDARD_DROPDOWN_BELOW_POSITIONS.map(position => {
|
20 | // In cases where the first menu item in the context menu is a trigger the submenu opens on a
|
21 | // hover event. We offset the context menu 2px by default to prevent this from occurring.
|
22 | const offsetX = position.overlayX === 'start' ? 2 : -2;
|
23 | const offsetY = position.overlayY === 'top' ? 2 : -2;
|
24 | return { ...position, offsetX, offsetY };
|
25 | });
|
26 | /** Tracks the last open context menu trigger across the entire application. */
|
27 | class ContextMenuTracker {
|
28 | /**
|
29 | * Close the previous open context menu and set the given one as being open.
|
30 | * @param trigger The trigger for the currently open Context Menu.
|
31 | */
|
32 | update(trigger) {
|
33 | if (ContextMenuTracker._openContextMenuTrigger !== trigger) {
|
34 | ContextMenuTracker._openContextMenuTrigger?.close();
|
35 | ContextMenuTracker._openContextMenuTrigger = trigger;
|
36 | }
|
37 | }
|
38 | static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ContextMenuTracker, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
39 | static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ContextMenuTracker, providedIn: 'root' }); }
|
40 | }
|
41 | export { ContextMenuTracker };
|
42 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ContextMenuTracker, decorators: [{
|
43 | type: Injectable,
|
44 | args: [{ providedIn: 'root' }]
|
45 | }] });
|
46 | /**
|
47 | * A directive that opens a menu when a user right-clicks within its host element.
|
48 | * It is aware of nested context menus and will trigger only the lowest level non-disabled context menu.
|
49 | */
|
50 | class CdkContextMenuTrigger extends CdkMenuTriggerBase {
|
51 | /** Whether the context menu is disabled. */
|
52 | get disabled() {
|
53 | return this._disabled;
|
54 | }
|
55 | set disabled(value) {
|
56 | this._disabled = coerceBooleanProperty(value);
|
57 | }
|
58 | constructor() {
|
59 | super();
|
60 | /** The CDK overlay service. */
|
61 | this._overlay = inject(Overlay);
|
62 | /** The directionality of the page. */
|
63 | this._directionality = inject(Directionality, { optional: true });
|
64 | /** The app's context menu tracking registry */
|
65 | this._contextMenuTracker = inject(ContextMenuTracker);
|
66 | this._disabled = false;
|
67 | this._setMenuStackCloseListener();
|
68 | }
|
69 | /**
|
70 | * Open the attached menu at the specified location.
|
71 | * @param coordinates where to open the context menu
|
72 | */
|
73 | open(coordinates) {
|
74 | this._open(coordinates, false);
|
75 | }
|
76 | /** Close the currently opened context menu. */
|
77 | close() {
|
78 | this.menuStack.closeAll();
|
79 | }
|
80 | /**
|
81 | * Open the context menu and closes any previously open menus.
|
82 | * @param event the mouse event which opens the context menu.
|
83 | */
|
84 | _openOnContextMenu(event) {
|
85 | if (!this.disabled) {
|
86 | // Prevent the native context menu from opening because we're opening a custom one.
|
87 | event.preventDefault();
|
88 | // Stop event propagation to ensure that only the closest enabled context menu opens.
|
89 | // Otherwise, any context menus attached to containing elements would *also* open,
|
90 | // resulting in multiple stacked context menus being displayed.
|
91 | event.stopPropagation();
|
92 | this._contextMenuTracker.update(this);
|
93 | this._open({ x: event.clientX, y: event.clientY }, true);
|
94 | // A context menu can be triggered via a mouse right click or a keyboard shortcut.
|
95 | if (event.button === 2) {
|
96 | this.childMenu?.focusFirstItem('mouse');
|
97 | }
|
98 | else if (event.button === 0) {
|
99 | this.childMenu?.focusFirstItem('keyboard');
|
100 | }
|
101 | else {
|
102 | this.childMenu?.focusFirstItem('program');
|
103 | }
|
104 | }
|
105 | }
|
106 | /**
|
107 | * Get the configuration object used to create the overlay.
|
108 | * @param coordinates the location to place the opened menu
|
109 | */
|
110 | _getOverlayConfig(coordinates) {
|
111 | return new OverlayConfig({
|
112 | positionStrategy: this._getOverlayPositionStrategy(coordinates),
|
113 | scrollStrategy: this._overlay.scrollStrategies.reposition(),
|
114 | direction: this._directionality || undefined,
|
115 | });
|
116 | }
|
117 | /**
|
118 | * Get the position strategy for the overlay which specifies where to place the menu.
|
119 | * @param coordinates the location to place the opened menu
|
120 | */
|
121 | _getOverlayPositionStrategy(coordinates) {
|
122 | return this._overlay
|
123 | .position()
|
124 | .flexibleConnectedTo(coordinates)
|
125 | .withLockedPosition()
|
126 | .withGrowAfterOpen()
|
127 | .withPositions(this.menuPosition ?? CONTEXT_MENU_POSITIONS);
|
128 | }
|
129 | /** Subscribe to the menu stack close events and close this menu when requested. */
|
130 | _setMenuStackCloseListener() {
|
131 | this.menuStack.closed.pipe(takeUntil(this.destroyed)).subscribe(({ item }) => {
|
132 | if (item === this.childMenu && this.isOpen()) {
|
133 | this.closed.next();
|
134 | this.overlayRef.detach();
|
135 | }
|
136 | });
|
137 | }
|
138 | /**
|
139 | * Subscribe to the overlays outside pointer events stream and handle closing out the stack if a
|
140 | * click occurs outside the menus.
|
141 | * @param ignoreFirstAuxClick Whether to ignore the first auxclick event outside the menu.
|
142 | */
|
143 | _subscribeToOutsideClicks(ignoreFirstAuxClick) {
|
144 | if (this.overlayRef) {
|
145 | let outsideClicks = this.overlayRef.outsidePointerEvents();
|
146 | // If the menu was triggered by the `contextmenu` event, skip the first `auxclick` event
|
147 | // because it fires when the mouse is released on the same click that opened the menu.
|
148 | if (ignoreFirstAuxClick) {
|
149 | const [auxClicks, nonAuxClicks] = partition(outsideClicks, ({ type }) => type === 'auxclick');
|
150 | outsideClicks = merge(nonAuxClicks, auxClicks.pipe(skip(1)));
|
151 | }
|
152 | outsideClicks.pipe(takeUntil(this.stopOutsideClicksListener)).subscribe(event => {
|
153 | if (!this.isElementInsideMenuStack(_getEventTarget(event))) {
|
154 | this.menuStack.closeAll();
|
155 | }
|
156 | });
|
157 | }
|
158 | }
|
159 | /**
|
160 | * Open the attached menu at the specified location.
|
161 | * @param coordinates where to open the context menu
|
162 | * @param ignoreFirstOutsideAuxClick Whether to ignore the first auxclick outside the menu after opening.
|
163 | */
|
164 | _open(coordinates, ignoreFirstOutsideAuxClick) {
|
165 | if (this.disabled) {
|
166 | return;
|
167 | }
|
168 | if (this.isOpen()) {
|
169 | // since we're moving this menu we need to close any submenus first otherwise they end up
|
170 | // disconnected from this one.
|
171 | this.menuStack.closeSubMenuOf(this.childMenu);
|
172 | this.overlayRef.getConfig().positionStrategy.setOrigin(coordinates);
|
173 | this.overlayRef.updatePosition();
|
174 | }
|
175 | else {
|
176 | this.opened.next();
|
177 | if (this.overlayRef) {
|
178 | this.overlayRef.getConfig().positionStrategy.setOrigin(coordinates);
|
179 | this.overlayRef.updatePosition();
|
180 | }
|
181 | else {
|
182 | this.overlayRef = this._overlay.create(this._getOverlayConfig(coordinates));
|
183 | }
|
184 | this.overlayRef.attach(this.getMenuContentPortal());
|
185 | this._subscribeToOutsideClicks(ignoreFirstOutsideAuxClick);
|
186 | }
|
187 | }
|
188 | static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkContextMenuTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
189 | static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkContextMenuTrigger, isStandalone: true, selector: "[cdkContextMenuTriggerFor]", inputs: { menuTemplateRef: ["cdkContextMenuTriggerFor", "menuTemplateRef"], menuPosition: ["cdkContextMenuPosition", "menuPosition"], menuData: ["cdkContextMenuTriggerData", "menuData"], disabled: ["cdkContextMenuDisabled", "disabled"] }, outputs: { opened: "cdkContextMenuOpened", closed: "cdkContextMenuClosed" }, host: { listeners: { "contextmenu": "_openOnContextMenu($event)" }, properties: { "attr.data-cdk-menu-stack-id": "null" } }, providers: [
|
190 | { provide: MENU_TRIGGER, useExisting: CdkContextMenuTrigger },
|
191 | { provide: MENU_STACK, useClass: MenuStack },
|
192 | ], exportAs: ["cdkContextMenuTriggerFor"], usesInheritance: true, ngImport: i0 }); }
|
193 | }
|
194 | export { CdkContextMenuTrigger };
|
195 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkContextMenuTrigger, decorators: [{
|
196 | type: Directive,
|
197 | args: [{
|
198 | selector: '[cdkContextMenuTriggerFor]',
|
199 | exportAs: 'cdkContextMenuTriggerFor',
|
200 | standalone: true,
|
201 | host: {
|
202 | '[attr.data-cdk-menu-stack-id]': 'null',
|
203 | '(contextmenu)': '_openOnContextMenu($event)',
|
204 | },
|
205 | inputs: [
|
206 | 'menuTemplateRef: cdkContextMenuTriggerFor',
|
207 | 'menuPosition: cdkContextMenuPosition',
|
208 | 'menuData: cdkContextMenuTriggerData',
|
209 | ],
|
210 | outputs: ['opened: cdkContextMenuOpened', 'closed: cdkContextMenuClosed'],
|
211 | providers: [
|
212 | { provide: MENU_TRIGGER, useExisting: CdkContextMenuTrigger },
|
213 | { provide: MENU_STACK, useClass: MenuStack },
|
214 | ],
|
215 | }]
|
216 | }], ctorParameters: function () { return []; }, propDecorators: { disabled: [{
|
217 | type: Input,
|
218 | args: ['cdkContextMenuDisabled']
|
219 | }] } });
|
220 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udGV4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