import { StandardMouseEvent } from "../../mouseEvent.js"; import { Disposable, IDisposable } from "../../../common/lifecycle.js"; import { AnchorAlignment, AnchorAxisAlignment, AnchorPosition, IRect } from "../../../common/layout.js"; import { OmitOptional } from "../../../common/types.js"; export { AnchorAlignment, AnchorAxisAlignment, AnchorPosition } from "../../../common/layout.js"; export declare enum ContextViewDOMPosition { ABSOLUTE = 1, FIXED = 2, FIXED_SHADOW = 3, /** * Hosts the view inside the container (the owner) as a manual popover, * so focus stays inside the owner while the view renders in the top layer. */ POPOVER = 4, /** * Like {@link ContextViewDOMPosition.POPOVER}, with the view in a shadow root. */ POPOVER_SHADOW = 5 } export declare function isPopoverDOMPosition(domPosition: ContextViewDOMPosition): boolean; export interface IContextViewRenderContext { /** * Where the view is actually hosted. A popover position can fall back * to a fixed position when the popover cannot be shown. */ readonly domPosition: ContextViewDOMPosition; } export interface IContextViewOptions { /** * Returns the container to use when a popover cannot be shown in its owner. * Defaults to the owner's document body. */ readonly getFallbackContainer?: (owner: HTMLElement) => HTMLElement; } export interface IAnchor { x: number; y: number; width?: number; height?: number; } export declare function isAnchor(obj: unknown): obj is IAnchor | OmitOptional; export interface IDelegate { /** * The anchor where to position the context view. * Use a `HTMLElement` to position the view at the element, * a `StandardMouseEvent` to position it at the mouse position * or an `IAnchor` to position it at a specific location. */ getAnchor(): HTMLElement | StandardMouseEvent | IAnchor; render(container: HTMLElement, context?: IContextViewRenderContext): IDisposable | null; focus?(): void; layout?(): void; anchorAlignment?: AnchorAlignment; anchorPosition?: AnchorPosition; anchorAxisAlignment?: AnchorAxisAlignment; canRelayout?: boolean; onDOMEvent?(e: Event, activeElement: HTMLElement): void; onHide?(data?: unknown): void; closeAnimation?: IContextViewCloseAnimation; /** * context views with higher layers are rendered higher in z-index order */ layer?: number; } export interface IContextViewCloseAnimation { readonly className: string; readonly duration: number; /** Requirements must match one ancestor; a nested array accepts any listed class. */ readonly requiredAncestorClasses?: readonly (string | readonly string[])[]; } export declare function hasRequiredAncestorClasses(element: HTMLElement, classNames: IContextViewCloseAnimation["requiredAncestorClasses"]): boolean; export declare const CONTEXT_VIEW_MENU_MOTION_CLASS = "context-view-menu-motion"; export declare const CONTEXT_VIEW_MENU_MOTION_CLOSING_CLASS = "context-view-menu-motion-closing"; export declare const CONTEXT_VIEW_MENU_MOTION_CLOSE_ANIMATION_DURATION = 150; export declare const CONTEXT_VIEW_MENU_MOTION_ANCESTOR_CLASSES: readonly [ readonly [ "modern-ui", "modern-ui-frosted-glass" ], "monaco-enable-motion" ]; export declare const CONTEXT_VIEW_CLOSE_ANIMATION_DURATION_VARIABLE = "--vscode-context-view-close-animation-duration"; export declare const CONTEXT_VIEW_MENU_MOTION_SHADOW_VARIABLE = "--vscode-context-view-menu-motion-shadow"; /** Inherited while an opacity animation isolates descendant menu backdrops. */ export declare const CONTEXT_VIEW_MENU_MOTION_BACKDROP_OPACITY_VARIABLE = "--vscode-context-view-menu-motion-backdrop-opacity"; export declare const CONTEXT_VIEW_MENU_MOTION_CLOSE_START_OPACITY_VARIABLE = "--vscode-context-view-menu-motion-close-start-opacity"; export declare const CONTEXT_VIEW_MENU_MOTION_CLOSE_START_TRANSFORM_VARIABLE = "--vscode-context-view-menu-motion-close-start-transform"; export declare const CONTEXT_VIEW_MENU_MOTION_OPEN_DURATION_MS = 250; export declare const CONTEXT_VIEW_MENU_MOTION_EASING = "cubic-bezier(0.22, 1, 0.36, 1)"; export declare const contextViewMenuCloseAnimation: IContextViewCloseAnimation; export interface IContextViewProvider { showContextView(delegate: IDelegate, container?: HTMLElement): void; hideContextView(): void; layout(): void; } export declare function getAnchorRect(anchor: HTMLElement | StandardMouseEvent | IAnchor): IRect; /** * The context view of the document that contains focus, including * context views hosted in a shadow root. */ export declare function getFocusedContextView(doc: Document): HTMLElement | undefined; /** * Whether focus is inside a context view of the document, including * context views hosted in a shadow root. */ export declare function isContextViewFocused(doc: Document): boolean; export declare class ContextView extends Disposable { private readonly options; private static readonly BUBBLE_UP_EVENTS; private static readonly BUBBLE_DOWN_EVENTS; private static readonly ISOLATED_KEY_EVENTS; private container; private view; private useFixedPosition; private useShadowDOM; private delegate; private toDisposeOnClean; private toDisposeOnSetContainer; private hidingContextView; private shadowRoot; private shadowRootHostElement; private domPosition; private readonly toDisposeOnPopoverHide; private focusToRestore; private showCount; constructor(container: HTMLElement, domPosition: ContextViewDOMPosition, options?: IContextViewOptions); setContainer(container: HTMLElement | null, domPosition: ContextViewDOMPosition): void; show(delegate: IDelegate): void; getViewElement(): HTMLElement; /** * The position the view is hosted at, after any popover fallback. */ getEffectiveDOMPosition(): ContextViewDOMPosition; private getPopoverElement; private showPopover; private trackPopoverOwner; private isPopoverOwnerLost; private checkPopoverOwner; private hideWithoutRestoringFocus; private restorePopoverFocus; private hidePopover; layout(): void; private doLayout; hide(data?: unknown, skipAnimation?: boolean): void; private isVisible; private completeHideAnimation; private prepareMenuCloseAnimation; private onDOMEvent; dispose(): void; }