import { AnimationEvent } from '@angular/animations'; import { FocusMonitor, FocusOrigin } from '@angular/cdk/a11y'; import { Direction, Directionality } from '@angular/cdk/bidi'; import * as i0 from '@angular/core'; import { OnDestroy, TemplateRef, ApplicationRef, Injector, ViewContainerRef, AfterViewInit, ElementRef, ChangeDetectorRef, QueryList, AfterContentInit, EventEmitter, InjectionToken } from '@angular/core'; import { Subject, Observable } from 'rxjs'; import { BooleanInput } from '@angular/cdk/coercion'; import { NxCheckboxComponent } from '@aposin/ng-aquila/checkbox'; import * as i1 from '@angular/common'; import * as i2 from '@angular/cdk/overlay'; import { Overlay, ScrollStrategy } from '@angular/cdk/overlay'; import * as i3 from '@aposin/ng-aquila/icon'; import { NxTriggerButton } from '@aposin/ng-aquila/overlay'; /** * Context menu content that will be rendered lazily once the menu is opened. */ declare class NxContextMenuContentDirective implements OnDestroy { private readonly _template; private readonly _appRef; private readonly _injector; private readonly _viewContainerRef; private readonly _document; private _portal; private _outlet; /** Emits when the menu content has been attached. */ readonly _attached: Subject; constructor(_template: TemplateRef, _appRef: ApplicationRef, _injector: Injector, _viewContainerRef: ViewContainerRef, _document: Document); /** * Attaches the content with a particular context. * @docs-private */ attach(context?: any): void; /** * Detaches the content. * @docs-private */ detach(): void; ngOnDestroy(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * This directive is intended to be used inside an nx-context-menu tag. * It exists mostly to set the role attribute, disabled state and styling. */ declare class NxContextMenuItemComponent implements OnDestroy, AfterViewInit { private readonly _elementRef; private readonly _document; private readonly _cdr; private readonly _focusMonitor; /** Stream that emits when the context menu item is hovered. */ readonly _hovered: Subject; /** Whether the context menu item is selectable */ set selectable(value: boolean); get selectable(): boolean; private _selectable; /** Whether the context menu item is disabled. */ set disabled(value: BooleanInput); get disabled(): boolean; private _disabled; /** Whether the context menu close on select. */ set disableCloseOnSelect(value: BooleanInput); get disableCloseOnSelect(): boolean; private _disableCloseOnSelect; /** Whether the context menu item is highlighted. */ _highlighted: boolean; /** Whether the context menu item acts as a trigger for a sub-menu. */ _triggersSubmenu: boolean; constructor(_elementRef: ElementRef, _document: Document | null, _cdr: ChangeDetectorRef, _focusMonitor: FocusMonitor); /** Focuses this context menu item. */ focus(origin?: FocusOrigin): void; ngAfterViewInit(): void; ngOnDestroy(): void; /** Returns the host DOM element. */ _getHostElement(): HTMLElement; /** * Blocks the click event from propagating to the origin component if this is disabled. * If not disabled it has no effect * @param event The MouseEvent that happened on click */ _handleClick(event: MouseEvent): void; /** Prevents the default element actions if it is disabled. */ _checkDisabled(event: Event): void; /** Emits to the hover stream. */ _handleMouseEnter(): void; /** Gets the label to be used when determining whether the option should be focused. */ getLabel(): string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; static ngAcceptInputType_selectable: unknown; } declare class NxContextMenuItemCheckboxDirective { checkbox: NxCheckboxComponent; onKeyDown(event: KeyboardEvent): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * This directive is need when [nx-context-menu-item] is not directly under [nx-context-menu]. * @example * * // blocker * // come to rescue * * * * * */ declare class NxContextMenuItemWrapComponent { _items: QueryList; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class NxContextMenuComponent implements AfterContentInit, OnDestroy { private _keyManager; private _items; private _wrap; private readonly _init; private _injector; private _firstItemFocusRef?; /** Config object to be passed into the menu's ngClass */ _classList: { [key: string]: boolean; }; /** Current state of the panel animation. */ _panelAnimationState: 'void' | 'enter'; /** Emits whenever an animation on the menu completes. */ readonly _animationDone: Subject; /** Whether the menu is animating. */ _isAnimating: boolean; /** Parent menu of the current menu panel. */ parentMenu?: NxContextMenuComponent; /** * Layout direction of the menu. * @docs-private */ direction: Direction; /** @docs-private */ templateRef: TemplateRef; /** * Menu content that will be rendered lazily. * @docs-private */ lazyContent: NxContextMenuContentDirective; /** Event emitted when the menu is closed. */ readonly closed: EventEmitter; private readonly _destroyed; private _onClick; constructor(); ngAfterContentInit(): void; ngOnDestroy(): void; /** Stream that emits whenever the hovered menu item changes. */ _hovered(): Observable; /** Handle a keyboard event from the menu, delegating to the appropriate action. */ _handleKeydown(event: KeyboardEvent): void; /** * Focus the first item in the menu. */ focusFirstItem(origin?: FocusOrigin): void; /** * Resets the active item in the menu. This is used when the menu is opened, allowing * the user to start from the first option when pressing the down arrow. */ resetActiveItem(): void; /** Starts the enter animation. */ _startAnimation(): void; /** Resets the panel animation to its initial state. */ _resetAnimation(): void; /** Callback that is invoked when the panel animation completes. */ _onAnimationDone(event: AnimationEvent): void; _onAnimationStart(event: AnimationEvent): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** Default top padding of the menu panel. */ declare const MENU_PANEL_TOP_PADDING = 8; declare const MENU_PANEL_OFFSET_Y = 8; declare const MENU_PANEL_OFFSET_X = 8; type NxContextMenuScrollStrategy = 'close' | 'reposition'; type NxContextMenuMode = 'button' | 'cursor'; /** Injection token that determines the scroll handling while a context-menu is open. */ declare const NX_CONTEXT_MENU_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>; /** * @docs-private * @deprecated No longer used. * @deletion-target 18.0.0 */ declare function NX_CONTEXT_MENU_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): () => ScrollStrategy; /** * @docs-private * @deprecated No longer used. * @deletion-target 18.0.0 */ declare const NX_CONTEXT_MENU_SCROLL_STRATEGY_PROVIDER: { provide: InjectionToken<() => ScrollStrategy>; useFactory: typeof NX_CONTEXT_MENU_SCROLL_STRATEGY_PROVIDER_FACTORY; deps: (typeof Overlay)[]; }; interface Point { x: number; y: number; } /** * This directive is intended to be used in conjunction with an nx-context-menu tag. * It is responsible for toggling the display of the provided context menu instance. */ declare class NxContextMenuTriggerDirective implements AfterContentInit, OnDestroy { #private; private readonly _overlay; private readonly _element; private readonly _viewContainerRef; private readonly _parentMenu; private readonly _contextMenuItemInstance; private readonly _dir; private readonly _triggerButton; private readonly _defaultScrollStrategyFactory; private readonly _cdr; private _portal; private _overlayRef; private _contextMenuOpen; private _closingActionsSubscription; private _contextMenuCloseSubscription; private readonly _documentClickObservable; /** Strategy factory that will be used to handle scrolling while the context-menu panel is open. */ private _scrollStrategyFactory; /** References the context menu instance that the trigger is associated with. */ set contextMenu(contextMenu: NxContextMenuComponent); get contextMenu(): NxContextMenuComponent; private _contextMenu; set scrollStrategy(value: NxContextMenuScrollStrategy | null | undefined); get scrollStrategy(): NxContextMenuScrollStrategy | null | undefined; /** Whether the context menu is open. */ get contextMenuOpen(): boolean; /** The text direction of the containing app. */ private get dir(); /** Data to be passed along to any lazily-rendered content. */ contextMenuData: object; /** * Sets the mode of this context menu trigger. * 'button' (default): Opens by clicking the trigger * 'cursor': Opens at the cursor position by right clicking anywhere on the trigger. */ mode: NxContextMenuMode; /** Event emitted when the associated context menu is opened. */ readonly contextMenuOpened: EventEmitter; /** Event emitted when the associated context menu is closed. */ readonly contextMenuClosed: EventEmitter; private readonly _destroyed; private _rightClicked; constructor(_overlay: Overlay, _element: ElementRef, _viewContainerRef: ViewContainerRef, _parentMenu: NxContextMenuComponent | null, _contextMenuItemInstance: NxContextMenuItemComponent | null, _dir: Directionality | null, _triggerButton: NxTriggerButton | null, _defaultScrollStrategyFactory: () => ScrollStrategy, _cdr: ChangeDetectorRef); ngAfterContentInit(): void; ngOnDestroy(): void; /** Whether the context menu triggers a sub-menu or a top-level one. */ triggersSubmenu(): boolean; /** Toggles the context menu between the open and closed states. */ toggleContextMenu(origin?: FocusOrigin): void; /** Opens the context menu. */ openContextMenu(origin?: FocusOrigin, position?: Point): void; /** Closes the context menu. */ closeContextMenu(): void; private getScrollStrtegyFactory; /** Closes the context menu and does the necessary cleanup. */ private _destroyMenu; /** * This method sets the context menu state to open and focuses the first item if * the context menu was opened via the keyboard. */ private _initContextMenu; /** * Focuses the context menu trigger. */ focus(): void; /** * This method resets the context menu when it's closed, most importantly restoring * focus to the context menu trigger if the context menu was opened via the keyboard. */ private _resetContextMenu; /** Set state rather than toggle to support triggers sharing a menu. */ private _setIsContextMenuOpen; /** * This method checks that a valid instance of NxContextMenuComponent has been passed into * nxContextMenuTriggerFor. If not, an exception is thrown. */ private _checkContextMenu; /** * This method creates the overlay from the provided menu's template and saves its * OverlayRef so that it can be attached to the DOM when openContextMenu is called. */ private _createOverlay; /** * This method builds the configuration object needed to create the overlay, the OverlayState. */ private _getOverlayConfig; /** * Sets the position on a position strategy so the overlay is placed at the cursor. * @param positionStrategy Strategy whose position to update. * @param cursorPosition Position of the cursor. */ private _setPositionToCursor; /** * Sets the appropriate positions on a position strategy * so the overlay connects with the trigger correctly. * @param positionStrategy Strategy whose position to update. */ private _setPosition; /** * Returns a stream that emits whenever an action that should close the context menu occurs. */ private _contextMenuClosingActions; /** Handles mouse presses on the trigger. */ _handleMousedown(event: MouseEvent): void; _handleRightClick(event: MouseEvent): void; /** Handles key presses on the trigger. */ _handleKeydown(event: KeyboardEvent): void; /** Handles click events on the trigger. */ _handleClick(event: MouseEvent): void; private _waitForClose; /** Handles the cases where the user hovers over the trigger. */ private _handleHover; /** Gets the portal that should be attached to the overlay. */ private _getPortal; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } declare class NxContextMenuHeaderComponent { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class NxContextMenuModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } export { MENU_PANEL_OFFSET_X, MENU_PANEL_OFFSET_Y, MENU_PANEL_TOP_PADDING, NX_CONTEXT_MENU_SCROLL_STRATEGY, NX_CONTEXT_MENU_SCROLL_STRATEGY_PROVIDER, NX_CONTEXT_MENU_SCROLL_STRATEGY_PROVIDER_FACTORY, NxContextMenuComponent, NxContextMenuContentDirective, NxContextMenuHeaderComponent, NxContextMenuItemCheckboxDirective, NxContextMenuItemComponent, NxContextMenuItemWrapComponent, NxContextMenuModule, NxContextMenuTriggerDirective }; export type { NxContextMenuMode, NxContextMenuScrollStrategy };