import { StandardMouseEvent } from "../../../base/browser/mouseEvent.js"; import { IAnchor, IContextViewCloseAnimation } from "../../../base/browser/ui/contextview/contextview.js"; import { IHoverAction } from "../../../base/browser/ui/hover/hover.js"; import { IListAccessibilityProvider } from "../../../base/browser/ui/list/listWidget.js"; import { IAction } from "../../../base/common/actions.js"; import { CancellationToken } from "../../../base/common/cancellation.js"; import { IMarkdownString } from "../../../base/common/htmlContent.js"; import { ResolvedKeybinding } from "../../../base/common/keybindings.js"; import { AnchorPosition } from "../../../base/common/layout.js"; import { Disposable, IDisposable } from "../../../base/common/lifecycle.js"; import { ThemeIcon } from "../../../base/common/themables.js"; import { URI } from "../../../base/common/uri.js"; import { IContextViewService } from "../../contextview/browser/contextView.service.js"; import { IKeybindingService } from "../../keybinding/common/keybinding.service.js"; import { IOpenerService } from "../../opener/common/opener.service.js"; import { ILayoutService } from "../../layout/browser/layoutService.service.js"; import { IInstantiationService } from "../../instantiation/common/instantiation.js"; import { IHoverService } from "../../hover/browser/hover.service.js"; export declare const acceptSelectedActionCommand = "acceptSelectedCodeAction"; export declare const previewSelectedActionCommand = "previewSelectedCodeAction"; export interface IActionListDelegate { onHide(didCancel?: boolean): void; onSelect(action: T, preview?: boolean): void; onFilter?(filter: string, cancellationToken: CancellationToken): Promise[]>; onHover?(action: T, cancellationToken: CancellationToken): Promise<{ canPreview: boolean; } | void>; onFocus?(action: T | undefined): void; } /** * Optional hover configuration shown when focusing/hovering over an action list item. */ export interface IActionListItemHover { /** * Content to display in the hover. Pass a function to build the content the first * time the panel opens, for content that is expensive to construct. */ readonly content?: string | IMarkdownString | HTMLElement | (() => HTMLElement); /** Releases an HTMLElement created by {@link content} when a preservation probe does not use it. */ readonly disposeContent?: (content: HTMLElement) => void; /** Actions rendered in the standard hover footer below the content. */ readonly actions?: readonly IHoverAction[]; /** * Optional disposable associated with the hover content (e.g. from rendered markdown). */ readonly disposable?: IDisposable; /** * Enables keyboard access and a clickable row chevron for the hover panel. * The chevron can be hidden with {@link IActionListItemHover.showIndicator}. */ readonly expandable?: boolean; /** Whether to show the expandable hover's row chevron. Defaults to true. */ readonly showIndicator?: boolean; /** * Includes the focused row's toolbar actions and hover-panel controls in one * Tab sequence while the list retains Up/Down navigation ownership. */ readonly tabThroughPanel?: boolean; /** Interactive elements owned by the hover content, in forward Tab order. */ readonly getTabbableElements?: () => readonly HTMLElement[]; /** Whether the hover content supplies its own inset from the panel boundary. */ readonly contentOwnsPadding?: boolean; /** * CSS class set on the hover panel while this item's hover is showing, so a * consumer can style the panel without reaching for the content inside it. */ readonly panelClassName?: string; /** Align the panel's adjoining edge with the outer action widget rather than its inset list. */ readonly alignToParent?: boolean; /** Align the panel's bottom with the parent popup, keeping content above its trigger. */ readonly alignToParentBottom?: boolean; /** Keep the initial top edge as content or rows change, scrolling at the viewport edge. */ readonly preserveVerticalPosition?: boolean; /** Align the panel's top edge with the row that opened it. */ readonly alignToAnchorTop?: boolean; } export interface IActionListUpdateOptions { /** Retain the open hover or submenu when its replacement item has the same id. */ readonly preserveHover?: boolean; /** Keep the current viewport when items are refreshed in place. */ readonly preserveScrollPosition?: boolean; /** Return DOM focus to the filter when focusing an updated item. */ readonly focusFilter?: boolean; /** Animate a visible focused item's move. The caller must respect reduced motion. */ readonly animateItemMove?: boolean; } /** * Optional inline toggle switch rendered inside an action list item, shown on its * own row below the label/detail. Useful for an always-visible boolean sub-control * (e.g. a sandbox toggle) that is independent from selecting the item itself. */ export interface IActionListItemInlineToggle { /** Label shown to the left of the switch. */ readonly label: string; /** Current checked state of the switch. */ readonly checked: boolean; /** Invoked when the user flips the switch. */ readonly onChange: (checked: boolean) => void; /** Optional accessible/hover title for the switch. Defaults to {@link label}. */ readonly title?: string; /** Show an information icon after the label to draw attention to the hover. */ readonly showInfoIcon?: boolean; /** Whether the switch is read-only. */ readonly disabled?: boolean; } export interface IActionListItem { readonly item?: T; readonly kind: ActionListItemKind; readonly group?: { kind?: unknown; icon?: ThemeIcon; title: string; }; readonly disabled?: boolean; readonly label?: string; /** Icon beside the label, separate from the selection indicator. */ readonly labelIcon?: ThemeIcon; /** * Optional detail text displayed as a second line below the label. */ readonly detail?: string; /** Optional link shown at the end of {@link detail}, reached with Tab from the focused item. */ readonly detailLink?: IActionListHeaderLink; /** * Optional inline toggle switch rendered on its own row inside the item. */ readonly inlineToggle?: IActionListItemInlineToggle; /** * Optional toggle switch rendered on the same row as the label. */ readonly standaloneToggle?: IActionListItemInlineToggle; readonly description?: string | IMarkdownString; /** Additional nonvisual text matched by the built-in filter. */ readonly filterText?: string; /** * Optional accessible description used in place of {@link description} for * screen reader labels. Useful when the visual description contains icons * or other non-textual content. */ readonly ariaDescription?: string; /** * Announces that the row opens a dialog, e.g. from a key its owner handles. Rows * with an expandable hover or submenu announce their popup without this. */ readonly opensDialog?: boolean; /** * Optional hover configuration shown when focusing/hovering over the item. */ readonly hover?: IActionListItemHover; /** * Optional actions shown in a nested submenu panel, triggered by a chevron * indicator on the right side of the item. When set, hovering or clicking * the chevron opens an inline submenu with these actions. */ readonly submenuActions?: IAction[]; /** Open a submenu or expandable hover on row activation instead of selecting the item. */ readonly openSubmenuOnClick?: boolean; /** Options for the action list rendered in the nested submenu panel. */ readonly submenuOptions?: IActionListOptions; /** Items that replace this item when the parent list is filtered. */ readonly filterItems?: readonly IActionListItem[]; readonly keybinding?: ResolvedKeybinding; canPreview?: boolean | undefined; readonly hideIcon?: boolean; /** * CSS classes rendered in the item's icon slot, for icons that are not * codicons (e.g. themed file icons). Takes precedence over `group.icon`. */ readonly iconClasses?: readonly string[]; readonly tooltip?: string; /** Called after scrolling makes this item part of the visible virtualized range. */ readonly onDidBecomeVisible?: () => void; /** * Optional toolbar actions shown when the item is focused or hovered. */ readonly toolbarActions?: IAction[]; /** Show toolbar action labels instead of icons. */ readonly toolbarLabels?: boolean; /** IDs of {@link toolbarActions} that open a dialog, so screen readers announce the popup. */ readonly toolbarDialogActionIds?: readonly string[]; /** * Optional section identifier. Items with the same section belong to the same * collapsible group. Only meaningful when the ActionList is created with * collapsible sections. */ readonly section?: string; /** * When true, clicking this item toggles the section's collapsed state * instead of selecting it. */ readonly isSectionToggle?: boolean; /** * Optional CSS class names to add to the row container, separated by spaces. */ readonly className?: string; /** * Height of the row as a multiple of a single action row's, e.g. 2 for a row * twice as tall. Overrides the height the item's kind and content would give it; * values below 1 or that are not finite are ignored. */ readonly heightInLines?: number; /** * Optional badge text to display after the label (e.g., "New"). */ readonly badge?: string; /** Displays the badge before the label instead of after it. */ readonly badgeBeforeLabel?: boolean; /** Badges displayed alongside {@link badge}, each with an optional single CSS class and hover. */ readonly additionalBadges?: readonly { readonly label: string; readonly className?: string; readonly tooltip?: string; }[]; /** * When true, this item is always shown when filtering produces no other results. */ readonly showAlways?: boolean; /** * Optional callback invoked when the item is removed via the built-in remove button. * When set, a close button is automatically added to the item toolbar. */ readonly onRemove?: () => void | Promise; } export declare enum ActionListItemKind { Action = "action", Header = "header", Separator = "separator" } /** * A "Learn more" style link rendered inline in the action list header banner. */ export interface IActionListHeaderLink { /** Visible link text (e.g. "Learn more"). Should be localized. */ readonly label: string; /** Target opened via the opener service when the link is activated. */ readonly uri: URI; } export type IActionListCloseAnimation = IContextViewCloseAnimation; /** * Options for configuring the action list. */ export interface IActionListOptions { /** * When true, shows a filter input. */ readonly showFilter?: boolean; /** * Placeholder text for the filter input. */ readonly filterPlaceholder?: string; /** Initial text for the filter input. */ readonly initialFilterValue?: string; /** Keep focus in the filter while navigating and accepting results, using combobox semantics. */ readonly filterAsCombobox?: boolean; /** Reveals a filter when printable text is typed in a list without a filter input. */ readonly onType?: (text: string) => void; /** Called when the user changes the filter text, but not when it is cleared programmatically. */ readonly onDidChangeFilter?: (text: string) => void; /** * Optional actions shown in the filter row, to the right of the input. */ readonly filterActions?: readonly IAction[]; /** * Section IDs that should be collapsed by default. */ readonly collapsedByDefault?: ReadonlySet; /** * Minimum width for the action list. */ readonly minWidth?: number; /** * Maximum width for the action list. When set, items wider than this are * truncated rather than expanding the popup. */ readonly maxWidth?: number; /** * Maximum number of action rows shown before the list scrolls. Headers and * separators between them still count toward the height. Ignored when the * list is laid out with a fixed content height. */ readonly maxVisibleItems?: number; /** * Optional handler for markdown links activated in item descriptions or hovers. * When unset, links open via the opener service with command links allowed. */ readonly linkHandler?: (uri: URI, item: IActionListItem) => void; /** * Optional callback fired when a section's collapsed state changes. */ readonly onDidToggleSection?: (section: string, collapsed: boolean) => void; /** * When true, descriptions are rendered inline right after the label * instead of aligned to the right. */ readonly inlineDescription?: boolean; /** * Height (in px) used for action items that have a `detail` line. * Defaults to 48. */ readonly detailItemHeight?: number; /** Wrap detail text and measure each row at the available width. */ readonly wrapDetails?: boolean; /** * Height (in px) used for action items that have an `inlineToggle`. * Defaults to 70. */ readonly inlineToggleItemHeight?: number; /** * When true, the group title is shown on the first item of each group * in the description area (aligned to the right). */ readonly showGroupTitleOnFirstItem?: boolean; /** * When true and filtering is enabled, focuses the filter input when the list opens. */ readonly focusFilterOnOpen?: boolean; /** Let the owner lay out the list before calling focus, so initial focus does not scroll past section headings. */ readonly deferInitialFocus?: boolean; /** Controls List range selection independently of checked items. Defaults to true. */ readonly multipleSelectionSupport?: boolean; /** Prevents the List's synthetic double-click selection from activating an item. */ readonly suppressDoubleClickActivation?: boolean; /** Exposes multiple checked options without enabling List range selection. */ readonly ariaMultiselectable?: boolean; /** Optional action item id to focus when the list opens. */ readonly initialFocusItemId?: string; /** Show immediate, persistent previews for the focused or hovered row. */ readonly persistentHover?: boolean; /** Preserve the open submenu while the pointer travels diagonally toward it. */ readonly submenuPointerIntent?: boolean; /** Delay in milliseconds before showing a submenu on pointer hover. Defaults to 500. */ readonly submenuHoverDelay?: number; /** * Controls the gutter kept for the submenu chevron on items that have none. * - `true` (default): kept while some item shows a chevron. * - `'always'`: kept regardless, for lists whose items gain and lose their chevron * while the popup stays open, where a collapsing gutter would shift every row. * - `false`: never kept. */ readonly reserveSubmenuSpace?: boolean | "always"; /** * When true, items without an explicit `tooltip` or `hover` do not get a * default "{keybinding} to Apply" tooltip. Useful for non-code-action lists * where this hint is misleading. */ readonly hideDefaultKeybindingTooltip?: boolean; /** * Stops toolbar pointer events from bubbling to row selection handlers. * Use for submenus where toolbar actions mutate the list in place. */ readonly stopToolbarPointerPropagation?: boolean; /** Includes the focused row's toolbar in keyboard navigation without requiring a hover panel. */ readonly tabThroughItemActions?: boolean; /** * Optional label shown on the right side of the filter row. */ readonly secondaryHeading?: string; /** * Optional text shown below the action list as a footer. */ readonly footerText?: string; /** Replaces its label in footerText with an independently focusable action link. */ readonly footerAction?: IAction; /** * Optional text shown above the action list as a header banner. When set, it is * rendered at the top of the widget, optionally prefixed by {@link headerIcon}. */ readonly headerText?: string; /** * Optional icon shown to the left of {@link headerText} in the header banner. */ readonly headerIcon?: ThemeIcon; /** Optional "Learn more" link rendered inline after {@link headerText}, opened via the opener service. */ readonly headerLink?: IActionListHeaderLink; /** Optional dismiss ("x") button on the header banner; invoked on click, and the banner is removed. */ readonly headerDismiss?: () => void; /** * Optional CSS class name added to the action list container, for scoped styling. */ readonly className?: string; /** * Optional CSS class name added to the containing action widget. */ readonly widgetClassName?: string; /** * Optional CSS class and duration used to animate the containing action widget * before the context view is hidden. */ readonly closeAnimation?: IActionListCloseAnimation; /** * Optional fixed side of the anchor where the action list should render. */ readonly anchorPosition?: AnchorPosition; /** Preferred side, falling back when needed and locking the resolved direction on first layout. `anchorPosition` takes precedence. */ readonly preferredAnchorPosition?: AnchorPosition; /** Uses the available height instead of the usual fractional viewport cap. */ readonly useFullHeight?: boolean; /** * Measures everything the containing popup shows besides the list's rows, including the * list's own filter, header and footer and anything the popup adds around them, such as * tabs. Placement then fits the whole popup beside the anchor, while the viewport cap * still applies to the list and its own chrome. Defaults to the list's own chrome plus * the action widget's padding and border. */ readonly getPopupChromeHeight?: (listElement: HTMLElement) => number; } /** * A standalone action list widget that handles core list rendering, filtering, * hover, submenu, and section management without depending on IContextViewService * or anchor-based positioning. Suitable for embedding directly in any container. */ export declare class ActionListWidget extends Disposable { protected readonly _supportsPreview: boolean; protected readonly _delegate: IActionListDelegate; protected readonly _options: IActionListOptions | undefined; private readonly _keybindingService; private readonly _openerService; private readonly _instantiationService; private readonly _hoverService; readonly domNode: HTMLElement; private readonly _list; private readonly _measuredItemHeights; private _initialFocusItemId; protected readonly _actionLineHeight: number; protected readonly _headerLineHeight = 24; protected readonly _separatorLineHeight = 8; protected _allMenuItems: IActionListItem[]; private readonly cts; private readonly _submenuDisposables; private readonly _submenuContainer; private _submenuHideTimeout; private _submenuShowTimeout; private _pendingSubmenuElement; private _currentSubmenuWidget; private _currentSubmenuElement; private _submenuHoverActionElements; private _submenuPanelClassName; private _layoutSubmenu; private readonly _itemMoveAnimation; private _submenuSide; private _submenuPointerOrigin; private _submenuPointerGraceDeadline; /** The row currently reporting `aria-expanded`, reset when its panel closes. */ private _expandedTrigger; private readonly _collapsedSections; private _filterText; private _imeSessionInProgress; private _isMeasuringWidth; private _suppressHover; private _hoverEnabled; private _ignoreInitialHover; private _keyboardNavigation; private _hasLaidOut; private readonly _filterInput; private readonly _filterContainer; private readonly _footerContainer; private _headerContainer; private readonly _filterCts; private readonly _groupTitleByIndex; private readonly _standaloneToggles; private readonly _itemToolbars; private readonly _itemDetailLinks; private _visibleMenuItems; private readonly _onDidRequestLayout; /** * Fired when the widget's visible item set changes and the parent should * re-layout (e.g. after filtering or collapsing a section). */ readonly onDidRequestLayout: import("../../../base/common/event.js").Event; constructor(user: string, _supportsPreview: boolean, items: readonly IActionListItem[], _delegate: IActionListDelegate, accessibilityProvider: Partial>> | undefined, _options: IActionListOptions | undefined, _keybindingService: IKeybindingService, _openerService: IOpenerService, _instantiationService: IInstantiationService, _hoverService: IHoverService); private _toggleSection; private _revealFirstItemOfSection; private _applyOrUpdateFilter; private _applyFilter; /** * Returns the filter container element, if filter is enabled. * The caller is responsible for appending it to the widget DOM. */ get filterContainer(): HTMLElement | undefined; get footerContainer(): HTMLElement | undefined; get headerContainer(): HTMLElement | undefined; get filterInput(): HTMLInputElement | undefined; get closeAnimation(): IActionListCloseAnimation | undefined; private focusCondition; private _setKeyboardNavigation; private _updateFilterActiveDescendant; focus(): void; clearFocus(): void; getFocusedElement(): IActionListItem | undefined; /** Suspends hover panels while their anchor is hidden or moving, restoring persistent previews when enabled. */ setHoverEnabled(enabled: boolean): void; /** Shows the checked item's hover, falling back to the focused item for persistent previews. */ showHoverForCheckedItem(): void; /** * Replaces the items in the list in place, preserving the current filter, * without closing the widget. When {@link focusItemId} is provided, that item * ({@link IActionListItem.item}'s `id`) is focused; otherwise the previously * focused item is preserved (matched by id). The widget only re-measures when * the number of visible rows changed. */ updateItems(items: readonly IActionListItem[], focusItemId?: string, options?: IActionListUpdateOptions): void; private _animateItemMove; /** * Focuses an item by id, reapplying focus after the current pointer event. * Preserving scroll also retains active combobox focus. */ focusItemById(itemId: string, options?: IActionListUpdateOptions): void; /** Restores focus to an item action without scheduling a later list focus. */ focusItemAction(itemId: string, actionId: string): boolean; private _updateToolbarFocusability; private _focusCheckedOrFirst; hide(didCancel?: boolean): void; /** Update an open searchable list without closing its owning picker. */ setFilter(value: string, focusItemId?: string): void; clearFilter(): boolean; /** * Whether this widget uses dynamic height (has filter or collapsible sections). */ get hasDynamicHeight(): boolean; /** * The height of a single action row in pixels. */ get lineHeight(): number; /** * Returns the height for an action item, using a taller line height * for items with a detail (second line). */ protected _getItemHeight(item: IActionListItem): number; /** Row heights depend on the options of the tab the items belong to, not the shown one. */ private _itemHeightWith; /** * Computes the total height of all items (including collapsed/filtered items). */ computeFullHeight(): number; /** Height the list would need for `items`, leaving out anything in a collapsed section. */ computeHeightForItems(items: readonly IActionListItem[], collapsedSections: ReadonlySet | undefined, options: IActionListOptions | undefined): number; /** * Computes the total height of visible items in the list. */ computeListHeight(): number; private computeMaxVisibleItemsHeightFor; /** * Computes the height of the visible rows through the * {@link IActionListOptions.maxVisibleItems}th action row, or * `Number.POSITIVE_INFINITY` when the list is not capped. */ computeMaxVisibleItemsHeight(): number; /** * Computes the full list height capped through the configured maximum * number of visible action rows. */ computeMaxFullHeight(): number; /** * Lays out the list widget with the given explicit dimensions. */ layout(height: number, width?: number): void; computeMaxWidth(minWidth: number): number; focusPrevious(): void; focusNext(): void; private _focusFilterResult; /** Collapses the section containing the focused row, returning whether it was expanded. */ collapseFocusedSection(): boolean; /** Expands the section containing the focused row, returning whether it was collapsed. */ expandFocusedSection(): boolean; toggleFocusedSection(): boolean; /** The focused row's section, if that section has a toggle that can expand it again. */ private _getFocusedSection; acceptSelected(preview?: boolean): void; private onListSelection; private onFocus; private _removeItem; private _recomputeGroupTitles; private _measureItemWidths; private _computeToolbarWidth; private _getRowElement; private _getTabThroughPanelControls; private _focusFirstTabThroughPanelControl; private _handleTabThroughPanelKeyDown; private _showHoverForElement; private _showSubmenuForItem; private _showSubmenuForElement; private _createSubmenuItems; private _hideSubmenu; /** * Clears the submenu/hover panel. If focus currently lives inside the panel * (e.g. the user clicked a button in the hover content), focus is first moved * back to the list. Otherwise clearing the panel would drop focus to , * which blurs the action widget and dismisses it. */ private _clearSubmenuContainer; private _scheduleSubmenuHide; private _cancelSubmenuHide; private _scheduleSubmenuShow; private _updateSubmenuPointer; private _resetSubmenuPointer; private _usesSubmenuPointerIntent; private _cancelSubmenuShow; private _restoreListFocusBeforeHidingToolbar; private onListHover; private onListClick; } /** * An action list that wraps {@link ActionListWidget} with context-view positioning * and anchor-based height computation. */ export declare class ActionList extends Disposable { private readonly _contextViewService; private readonly _layoutService; private readonly _widget; private readonly _anchor; private _lastMinWidth; private _cachedMaxWidth; private _hasLaidOut; private _showAbove; /** Height to size against instead of the current contents. Survives re-layouts. */ private _fixedContentHeight; private readonly _anchorPosition; private readonly _preferredAnchorPosition; private readonly _useFullHeight; private readonly _wrapDetails; private readonly _getPopupChromeHeight; private readonly _widgetClassName; get domNode(): HTMLElement; get filterContainer(): HTMLElement | undefined; get footerContainer(): HTMLElement | undefined; get headerContainer(): HTMLElement | undefined; get filterInput(): HTMLInputElement | undefined; get closeAnimation(): IActionListCloseAnimation | undefined; get widgetClassName(): string | undefined; /** * Returns the resolved anchor position after the first layout. * Used by the context view delegate to lock the dropdown direction. */ get anchorPosition(): AnchorPosition | undefined; constructor(user: string, preview: boolean, items: readonly IActionListItem[], _delegate: IActionListDelegate, accessibilityProvider: Partial>> | undefined, options: IActionListOptions | undefined, anchor: HTMLElement | StandardMouseEvent | IAnchor, _contextViewService: IContextViewService, _layoutService: ILayoutService, instantiationService: IInstantiationService); focus(): void; showHoverForCheckedItem(): void; setHoverEnabled(enabled: boolean): void; hide(didCancel?: boolean, hideContextView?: boolean): void; setFilter(value: string, focusItemId?: string): void; clearFilter(): boolean; focusPrevious(): void; focusNext(): void; collapseFocusedSection(): boolean; expandFocusedSection(): boolean; toggleFocusedSection(): boolean; acceptSelected(preview?: boolean): void; updateItems(items: readonly IActionListItem[], focusItemId?: string, options?: IActionListUpdateOptions): void; getFocusedElement(): IActionListItem | undefined; /** Height the list would need for `items`, for a caller sizing against other contents. */ computeHeightForItems(items: readonly IActionListItem[], collapsedSections: ReadonlySet | undefined, options: IActionListOptions | undefined): number; focusItemById(itemId: string): void; focusItemAction(itemId: string, actionId: string): boolean; private hasDynamicHeight; private computeActionWidgetVerticalChromeHeight; private computeHeight; layout(minWidth: number, fixedContentHeight?: number): number; }