import * as i1 from '@sbb-esta/angular/core'; import { FocusOrigin, FocusableOption } from '@angular/cdk/a11y'; import * as i2 from '@angular/cdk/overlay'; import { ScrollStrategy } from '@angular/cdk/overlay'; import * as i0 from '@angular/core'; import { InjectionToken, OnDestroy, TemplateRef, EventEmitter, AfterViewInit, AfterContentInit, OnInit, QueryList, WritableSignal } from '@angular/core'; import { SafeHtml } from '@angular/platform-browser'; import { Subject, Observable } from 'rxjs'; import * as i1$1 from '@angular/cdk/portal'; import * as i3 from '@sbb-esta/angular/icon'; import * as i1$2 from '@angular/cdk/scrolling'; /** * Injection token that can be used to reference instances of `SbbMenuContent`. It serves * as alternative token to the actual `SbbMenuContent` class which could cause unnecessary * retention of the class and its directive metadata. */ declare const SBB_MENU_CONTENT: InjectionToken; /** * Menu content that will be rendered lazily once the menu is opened. */ declare class SbbMenuContent implements OnDestroy { private _template; private _appRef; private _injector; private _viewContainerRef; private _document; private _changeDetectorRef; private _portal; private _outlet; /** Emits when the menu content has been attached. */ readonly _attached: Subject; constructor(...args: unknown[]); /** * 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; } type SbbMenuPositionX = 'before' | 'after' | undefined; type SbbMenuPositionY = 'above' | 'below' | undefined; /** * Injection token used to provide the parent menu to menu-specific components. * @docs-private */ declare const SBB_MENU_PANEL: InjectionToken>; /** * Interface for a custom menu panel that can be used with `sbbMenuTriggerFor`. * @docs-private */ interface SbbMenuPanel { triggerContext: SbbMenuTriggerContext; xPosition: SbbMenuPositionX; yPosition: SbbMenuPositionY; overlapTrigger: boolean; templateRef: TemplateRef; readonly closed: EventEmitter; parentMenu?: SbbMenuPanel | undefined; focusFirstItem: (origin?: FocusOrigin) => void; resetActiveItem: () => void; setPositionClasses?: (x: SbbMenuPositionX, y: SbbMenuPositionY) => void; setElevation?(depth: number): void; lazyContent?: SbbMenuContent; backdropClass?: string; overlayPanelClass?: string | string[]; hasBackdrop?: boolean; readonly panelId?: string; } /** * Single item inside a `sbb-menu`. Provides the menu item styling and accessibility treatment. */ declare class SbbMenuItem implements FocusableOption, AfterViewInit, OnDestroy { private _elementRef; private _document; private _focusMonitor; private _changeDetectorRef; _parentMenu?: SbbMenuPanel | null | undefined; /** Whether the menu item is disabled. */ disabled: boolean; /** ARIA role for the menu item. */ role: 'menuitem' | 'menuitemradio' | 'menuitemcheckbox'; /** Stream that emits when the menu item is hovered. */ readonly _hovered: Subject; /** Stream that emits when the menu item is focused. */ readonly _focused: Subject; /** Whether the menu item is highlighted. */ _highlighted: boolean; /** Whether the menu item acts as a trigger for a sub-menu. */ _triggersSubmenu: boolean; constructor(...args: unknown[]); /** Focuses the menu item. */ focus(origin?: FocusOrigin, options?: FocusOptions): void; ngAfterViewInit(): void; ngOnDestroy(): void; /** Used to set the `tabindex`. */ _getTabIndex(): string; /** Returns the host DOM element. */ _getHostElement(): HTMLElement; /** 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; _setHighlighted(isHighlighted: boolean): void; _hasFocus(): boolean; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; static ngAcceptInputType_disabled: unknown; } /** Default `sbb-menu` options that can be overridden. */ interface SbbMenuDefaultOptions { /** The x-axis position of the menu. */ xPosition?: SbbMenuPositionX; /** The y-axis position of the menu. */ yPosition?: SbbMenuPositionY; /** Whether the menu should overlap the menu trigger. */ overlapTrigger: boolean; /** Class to be applied to the menu's backdrop. */ backdropClass: string; /** Class or list of classes to be applied to the menu's overlay panel. */ overlayPanelClass?: string | string[]; /** Whether the menu has a backdrop. */ hasBackdrop?: boolean; } /** Injection token to be used to override the default options for `sbb-menu`. */ declare const SBB_MENU_DEFAULT_OPTIONS: InjectionToken; /** @docs-private */ declare function SBB_MENU_DEFAULT_OPTIONS_FACTORY(): SbbMenuDefaultOptions; type SbbMenuPlainAnimationState = 'enter' | 'void' | 'enter-usermenu'; interface SbbMenuAnimationStateWithParams { value: SbbMenuPlainAnimationState; params?: { [key: string]: string; }; } type SbbMenuAnimationState = SbbMenuPlainAnimationState | SbbMenuAnimationStateWithParams; /** Reason why the menu was closed. */ type SbbMenuCloseReason = void | 'click' | 'keydown' | 'tab'; declare class SbbMenu implements AfterContentInit, SbbMenuPanel, OnInit, OnDestroy { private _elementRef; private _defaultOptions; private _changeDetectorRef; private _injector; private _keyManager; private _xPosition; private _yPosition; private _firstItemFocusRef?; private _exitFallbackTimeout; private _previousElevation; private _elevationPrefix; private _baseElevation; /** All items inside the menu. Includes items nested inside another menu. */ _allItems: QueryList; /** Only the direct descendant menu items. */ _directDescendantItems: QueryList; /** Classes to be applied to the menu panel. */ _classList: { [key: string]: boolean; }; /** Current state of the panel animation. */ _panelAnimationState: SbbMenuAnimationState; /** Emits whenever an animation on the menu completes. */ readonly _animationDone: Subject<"enter" | "void">; /** Whether the menu is animating. */ _isAnimating: WritableSignal; /** Parent menu of the current menu panel. */ parentMenu: SbbMenuPanel | undefined; /** Class or list of classes to be added to the overlay panel. */ overlayPanelClass: string | string[]; /** Class to be added to the backdrop element. */ backdropClass: string; /** aria-label for the menu panel. */ ariaLabel: string; /** aria-labelledby for the menu panel. */ ariaLabelledby: string; /** aria-describedby for the menu panel. */ ariaDescribedby: string; /** Position of the menu in the X axis. */ get xPosition(): SbbMenuPositionX; set xPosition(value: SbbMenuPositionX); /** Position of the menu in the Y axis. */ get yPosition(): SbbMenuPositionY; set yPosition(value: SbbMenuPositionY); /** @docs-private */ templateRef: TemplateRef; /** * Menu content that will be rendered lazily. * @docs-private */ lazyContent: SbbMenuContent; /** Whether the menu should overlap its trigger. */ overlapTrigger: boolean; /** Whether the menu has a backdrop. */ hasBackdrop: boolean | undefined; /** * This method takes classes set on the host sbb-menu element and applies them on the * menu template that displays in the overlay container. Otherwise, it's difficult * to style the containing menu from outside the component. * @param classes list of class names */ set panelClass(classes: string); private _previousPanelClass; get triggerContext(): SbbMenuTriggerContext; set triggerContext(value: SbbMenuTriggerContext); private _triggerContext; /** Event emitted when the menu is closed. */ readonly closed: EventEmitter; readonly panelId: string; /** Whether animations are currently disabled. */ protected _animationsDisabled: boolean; constructor(...args: unknown[]); ngOnInit(): void; 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; /** Whether to display the menu header which mirrors the trigger content. */ _hasHeader(): boolean; /** * Focus the first item in the menu. * @param origin Action from which the focus originated. Used to set the correct styling. */ 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; /** * Sets the menu panel elevation. * @param depth Number of parent menus that come before the menu. */ setElevation(depth: number): void; /** * Adds classes to the menu panel based on its position. Can be used by * consumers to add specific styling based on the position. * @param posX Position of the menu along the x axis. * @param posY Position of the menu along the y axis. * @docs-private */ setPositionClasses(posX?: SbbMenuPositionX, posY?: SbbMenuPositionY): void; /** Callback that is invoked when the panel animation completes. */ protected _onAnimationDone(state: string): void; protected _onAnimationStart(state: string): void; _setIsOpen(isOpen: boolean): void; /** Gets the menu panel DOM node. */ private _resolvePanel; /** * Sets up a stream that will keep track of any newly-added menu items and will update the list * of direct descendants. We collect the descendants this way, because `_allItems` can include * items that are part of child menus, and using a custom way of registering items is unreliable * when it comes to maintaining the item order. */ private _updateDirectDescendants; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; static ngAcceptInputType_overlapTrigger: unknown; static ngAcceptInputType_hasBackdrop: unknown; } type SbbMenuTriggerType = 'default' | 'headless' | 'breadcrumb' | 'usermenu' | 'contextmenu'; interface SbbMenuTriggerContext extends SbbMenuInheritedTriggerContext { width?: number; height?: number; scalingFactor?: number; templateContent?: TemplateRef; elementContent?: SafeHtml; } interface SbbMenuInheritedTriggerContext { type: SbbMenuTriggerType; xPosition?: SbbMenuPositionX; yPosition?: SbbMenuPositionY; xOffset?: number; yOffset?: number; panelWidth?: number; animationStartStateResolver?: (context: SbbMenuTriggerContext) => SbbMenuAnimationState; } /** Injection token for SbbMenuInheritedTriggerContext */ declare const SBB_MENU_INHERITED_TRIGGER_CONTEXT: InjectionToken; /** Injection token that determines the scroll handling while the menu is open. */ declare const SBB_MENU_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>; declare const _SbbMenuTriggerMixinBase: i1.AbstractConstructor & { new (): {}; }; /** Directive applied to an element that should trigger a `sbb-menu`. */ declare class SbbMenuTrigger extends _SbbMenuTriggerMixinBase implements OnInit, AfterContentInit, OnDestroy { private _overlay; private _element; private _viewContainerRef; private _inheritedTriggerContext; private _menuItemInstance; private _focusMonitor; private _sanitizer; private _breakpointObserver; private _changeDetectorRef; private _ngZone; private _portal; private _overlayRef; private _menuOpen; private _breakpointSubscription; private _closingActionsSubscription; private _hoverSubscription; private _menuCloseSubscription; private _scrollStrategy; private _pendingRemoval; /** * We're specifically looking for a `SbbMenu` here since the generic `SbbMenuPanel` * interface lacks some functionality around nested menus and animations. */ _parentSbbMenu: SbbMenu | undefined; /** * Handles touch start events on the trigger. * Needs to be an arrow function so we can easily use addEventListener and removeEventListener. */ private _handleTouchStart; _openedBy: Exclude | undefined; /** Variant of which trigger is used. */ _type: SbbMenuTriggerType; /** References the menu instance that the headless trigger is associated with. */ set sbbMenuHeadlessTriggerFor(menu: SbbMenuPanel | null); /** References the menu instance that the trigger is associated with. */ get menu(): SbbMenuPanel | null; set menu(menu: SbbMenuPanel | null); private _menu; /** Inits the menu for the different trigger types. Method is intentionally placed after corresponding inputs. */ private _setMenu; /** Data to be passed along to any lazily-rendered content. */ menuData: any; /** * Whether focus should be restored when the menu is closed. * Note that disabling this option can have accessibility implications * and it's up to you to manage focus, if you decide to turn it off. */ restoreFocus: boolean; /** Event emitted when the associated menu is opened. */ readonly menuOpened: EventEmitter; /** Event emitted when the associated menu is closed. */ readonly menuClosed: EventEmitter; _triggerContent: TemplateRef; private _scalingFactor; constructor(...args: unknown[]); ngOnInit(): void; ngAfterContentInit(): void; ngOnDestroy(): void; /** Whether the menu is open. */ get menuOpen(): boolean; /** Whether the menu triggers a sub-menu or a top-level one. */ triggersSubmenu(): boolean; /** Toggles the menu between the open and closed states. */ toggleMenu(): void; /** Opens the menu. */ openMenu(): void; /** Internal method to open menu providing option to auto focus on first item. */ private _openMenu; /** Closes the menu. */ closeMenu(): void; /** * Focuses the menu trigger. * @param origin Source of the menu trigger's focus. */ focus(origin?: FocusOrigin, options?: FocusOptions): void; /** * Updates the position of the menu to ensure that it fits all options within the viewport. */ updatePosition(): void; /** Closes the menu and does the necessary cleanup. */ private _destroyMenu; /** Updates the menu elevation based on the amount of parent menus that it has. */ private _setMenuElevation; private _setIsMenuOpen; /** * 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 openMenu is called. */ private _createOverlay; /** * This method builds the configuration object needed to create the overlay, the OverlayState. * @returns OverlayConfig */ private _getOverlayConfig; /** * Listens to changes in the position of the overlay and sets the correct classes * on the menu based on the new position. This ensures the animation origin is always * correct, even if a fallback position is used for the overlay. */ private _subscribeToPositions; /** * 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 menu occurs. */ private _menuClosingActions; /** Handles mouse presses on the trigger. */ _handleMousedown(event: MouseEvent): void; /** Handles key presses on the trigger. */ _handleKeydown(event: KeyboardEvent): void; /** Handles click events on the trigger. */ _handleClick(event: MouseEvent): void; /** Handles the cases where the user hovers over the trigger. */ private _handleHover; /** Gets the portal that should be attached to the overlay. */ private _getPortal; /** * Determines whether the trigger owns a specific menu panel, at the current point in time. * This allows us to distinguish the case where the same panel is passed into multiple triggers * and multiple are open at a time. */ private _ownsMenu; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } declare const _sbbContextmenuInheritedTriggerContext: SbbMenuInheritedTriggerContext; /** Directive applied to an element that should trigger a `sbb-menu`. */ declare class SbbContextmenuTrigger extends SbbMenuTrigger { /** * Custom trigger icon. * Must be a valid svgIcon input for sbb-icon. * * e.g. svgIcon="plus-small" */ svgIcon: string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class SbbMenuDynamicTrigger { readonly _templateRef: TemplateRef; constructor(...args: unknown[]); static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * Throws an exception for the case when menu's x-position value isn't valid. * In other words, it doesn't match 'before' or 'after'. * @docs-private */ declare function throwSbbMenuInvalidPositionX(): void; /** * Throws an exception for the case when menu's y-position value isn't valid. * In other words, it doesn't match 'above' or 'below'. * @docs-private */ declare function throwSbbMenuInvalidPositionY(): void; /** * Throws an exception for the case when a menu is assigned * to a trigger that is placed inside the same menu. * @docs-private */ declare function throwSbbMenuRecursiveError(): void; declare class SbbMenuModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } export { SBB_MENU_CONTENT, SBB_MENU_DEFAULT_OPTIONS, SBB_MENU_DEFAULT_OPTIONS_FACTORY, SBB_MENU_INHERITED_TRIGGER_CONTEXT, SBB_MENU_PANEL, SBB_MENU_SCROLL_STRATEGY, SbbContextmenuTrigger, SbbMenu, SbbMenuContent, SbbMenuDynamicTrigger, SbbMenuItem, SbbMenuModule, SbbMenuTrigger, _sbbContextmenuInheritedTriggerContext, throwSbbMenuInvalidPositionX, throwSbbMenuInvalidPositionY, throwSbbMenuRecursiveError }; export type { SbbMenuAnimationState, SbbMenuAnimationStateWithParams, SbbMenuCloseReason, SbbMenuDefaultOptions, SbbMenuInheritedTriggerContext, SbbMenuPanel, SbbMenuPlainAnimationState, SbbMenuPositionX, SbbMenuPositionY, SbbMenuTriggerContext, SbbMenuTriggerType };