import { IListAccessibilityProvider } from "../../../base/browser/ui/list/listWidget.js"; import { Disposable, IDisposable } from "../../../base/common/lifecycle.js"; import { ThemeIcon } from "../../../base/common/themables.js"; import { URI } from "../../../base/common/uri.js"; import { IAccessibilityService } from "../../accessibility/common/accessibility.service.js"; import { IContextViewService } from "../../contextview/browser/contextView.service.js"; import { IHoverService } from "../../hover/browser/hover.service.js"; import { IInstantiationService } from "../../instantiation/common/instantiation.js"; import { IKeybindingService } from "../../keybinding/common/keybinding.service.js"; import { IActionListDelegate, IActionListItem, IActionListOptions, IActionListUpdateOptions } from "./actionList.js"; /** Labels for the keys a {@link TabbedActionListWidget} handles itself, for help text. */ export declare function getTabbedActionListKeybindingLabels(keybindingService: IKeybindingService): { readonly nextTab: string; readonly previousTab: string; readonly back: string; }; /** * Result of {@link ITabbedActionListShowOptions.createActionList}. The list * options are recomputed on every tab switch so callers can vary filter * visibility, width, etc. by tab. */ export interface ITabbedActionListBuildResult { readonly items: readonly IActionListItem[]; readonly listOptions?: IActionListOptions; } /** * Describes one tab in a {@link TabbedActionListWidget}. The {@link id} * is the stable identity used everywhere the widget reasons about a * tab (initial selection, change events, `createActionList` callback); * {@link label}, {@link tooltip}, and {@link icon} are presentation only. */ export interface ITabDescriptor { /** Stable identifier used for tab identity and selection callbacks. */ readonly id: string; /** Visible label. Defaults to {@link id}. Localize at the call site. */ readonly label?: string; /** Hover tooltip. Defaults to {@link label} ?? {@link id}. */ readonly tooltip?: string; /** * Optional leading icon rendered before the label: a theme icon, or images for * light and dark themes, e.g. one an extension contributed. */ readonly icon?: ThemeIcon | { readonly light: URI; readonly dark: URI; }; } /** * An icon button rendered at the trailing edge of the tab bar. Unlike a tab, * running it does not change the active tab. */ export interface ITabBarAction { /** Stable identifier, used as the button's `data-id` for tests. */ readonly id: string; readonly icon: ThemeIcon; readonly tooltip: string; /** When true, the button is pushed to the far end of the tab bar. */ readonly alignEnd?: boolean; /** When true, use the workbench hover instead of the button's native title. */ readonly useManagedHover?: boolean; /** When true, the button renders in its pressed state. */ readonly checked?: boolean; /** When set, the button is disabled and its managed hover explains why instead of showing {@link tooltip}. */ readonly disabledReason?: string; run(): void; } /** * Options for {@link TabbedActionListWidget.show}. The widget renders a * tab bar above an `ActionList` inside a single popup. Consumers describe * how to compute items for each tab; the widget handles tab switching and * lifecycle internally. */ export interface ITabbedActionListShowOptions { /** Logical user / source identifier passed through to {@link ActionList}. */ readonly user: string; /** Element the popup is anchored to. */ readonly anchor: HTMLElement; /** Tabs rendered in order. */ readonly tabs: readonly ITabDescriptor[]; /** Initially active tab id. Must match an entry in {@link tabs}. */ readonly initialTab: string; /** Computes a tab's list, or its resting contents when `forSizing` is true. */ createActionList(activeTab: string, forSizing?: boolean): ITabbedActionListBuildResult; /** Item delegate (selection, hide, focus). */ readonly delegate: IActionListDelegate; /** Optional accessibility provider passed to the underlying list. */ readonly accessibilityProvider?: Partial>>; /** Optional fixed popup width. */ readonly width?: number; /** Context view layer used when the picker must render above another context view. */ readonly contextViewLayer?: number; /** Optional class name to add to the tab bar element (in addition to `.tabbed-action-list-tabbar`). Must be a single class. */ readonly tabBarClassName?: string; /** * Computes the class names on the popup's `.action-widget` element. Re-evaluated * whenever the popup re-renders or its list is refreshed, so state that changes * while the popup stays open is not replayed stale on a tab switch. */ readonly widgetClassNames?: (activeTab: string) => readonly string[]; /** Attaches behavior scoped to the popup's `.action-widget` element for its lifetime. */ renderWidget?(container: HTMLElement): IDisposable; /** Tab whose contents fix the popup's height, so switching tabs scrolls instead of resizing. */ readonly sizingTab?: string; /** Remeasures the popup when its content mode changes, without dismissing it or changing its anchor side. */ readonly sizingKey?: string; /** Show the checked item's hover after the popup has been positioned. */ readonly showCheckedItemHover?: boolean; /** Optional icon buttons rendered after the tabs. */ readonly tabBarActions?: readonly ITabBarAction[]; /** * When tabs show their label beside their icon. `active` labels only the active tab, * and a tab with no icon always shows its label. Defaults to `always`. */ readonly tabLabels?: "always" | "active" | "never"; /** * When true, the list's filter row is rendered inside the tab bar in place of the * tabs, rather than as its own row below them. */ readonly filterInTabBar?: boolean; /** Whether the tabs and list are collapsed, leaving only the footer. Re-read on refresh. */ readonly isBodyCollapsed?: () => boolean; /** Renders content pinned below the list, e.g. a persistent option row. */ renderFooter?(container: HTMLElement, activeTab: string): IDisposable; /** Focuses a footer control when the body is collapsed. */ focusFooter?(): void; /** * Renders the body when the active tab has no items, e.g. a sign-in prompt. * When it returns `undefined` the empty list is shown instead. */ renderEmpty?(container: HTMLElement, activeTab: string): IDisposable | undefined; /** * Opens the focused item's details when Right Arrow is pressed in the list. * Returns false when the item has no details. */ openItemDetails?(item: IActionListItem): boolean; } export interface ITabbedActionListRefreshOptions extends IActionListUpdateOptions { readonly focusItemId?: string; /** Keeps the popup's measured size, for refreshes that only change item state such as a checked row. */ readonly preserveSize?: boolean; } export interface ITabbedActionListDetailsOptions { readonly label: string; readonly backLabel: string; /** Renders a fixed heading beside an icon-only Back button. */ renderHeader?(container: HTMLElement): IDisposable; render(container: HTMLElement): IDisposable; focus?(container: HTMLElement): void; restoreFocus?(): boolean; onBack?(): void; } /** * A widget that shows a tabbed action list in a context view popup */ export declare class TabbedActionListWidget extends Disposable { private readonly _contextViewService; private readonly _instantiationService; private readonly _accessibilityService; private readonly _keybindingService; private readonly _hoverService; private readonly _onDidChangeTab; readonly onDidChangeTab: import("../../../base/common/event.js").Event; private readonly _onDidHide; readonly onDidHide: import("../../../base/common/event.js").Event; private readonly _activePopup; private _swappingTab; private _refreshActiveList; private _showDetails; private _hideDetails; private _focusItemAction; private _focusItem; private _detailsVisible; /** Boxes and labels from the last render, so the next one can animate from them. */ private _previousTabBoxes; private _previousTabTexts; /** List height from {@link ITabbedActionListShowOptions.sizingTab}, recomputed when items change. */ private _fixedListHeight; private _fixedPopupHeight; private _hasMeasuredSizingTab; private _sizingKey; /** Side of the anchor the popup opened on, kept across tab swaps so it cannot jump sides. */ private _anchorPosition; get isVisible(): boolean; get isShowingDetails(): boolean; constructor(_contextViewService: IContextViewService, _instantiationService: IInstantiationService, _accessibilityService: IAccessibilityService, _keybindingService: IKeybindingService, _hoverService: IHoverService); /** * Shows the popup anchored to {@link ITabbedActionListShowOptions.anchor}. * If a popup is already visible, it is replaced in place. */ show(options: ITabbedActionListShowOptions): void; /** Boxes of the currently rendered tabs, keyed by tab id. */ private _measureTabBoxes; /** Grows and shrinks the tabs from the boxes the previous render left them in. */ private _animateTabResize; /** Keeps a closing tab's label on screen, collapsed to nothing by the time it settles. */ private _holdLabelWhileShrinking; hide(): void; /** * Rebuilds the active tab and remeasures its resting sizing contents without dismissing the popup. * Focus is retained, and `preserveHover` keeps the live detail panel. */ refreshActiveList(options?: ITabbedActionListRefreshOptions): void; /** Shows a drill-in page while retaining the list's filter, expansion, scroll, and focus state. */ showDetails(options: ITabbedActionListDetailsOptions): void; hideDetails(): void; focusItemAction(itemId: string, actionId: string): boolean; /** Focuses a list row by its item's `id`. Returns whether the list took focus. */ focusItem(itemId: string): boolean; /** Renders the caller's empty body, or nothing when it declines to handle the empty tab. */ private _renderEmptyBody; dispose(): void; }