import { IContextMenuProvider } from "../../contextmenu.js"; import { ActionBar, ActionsOrientation, IActionViewItem, IActionViewItemProvider } from "../actionbar/actionbar.js"; import { AnchorAlignment, IContextViewCloseAnimation } from "../contextview/contextview.js"; import { Action, IAction, IActionRunner } from "../../../common/actions.js"; import { ThemeIcon } from "../../../common/themables.js"; import { ResolvedKeybinding } from "../../../common/keybindings.js"; import { Disposable } from "../../../common/lifecycle.js"; import { IHoverDelegate } from "../hover/hoverDelegate.js"; export interface IToolBarResponsiveBehaviorOptions { readonly enabled: boolean; readonly kind: "last" | "all"; readonly minItems?: number; readonly overflowFrom?: "start" | "end"; readonly actionMinWidth?: number; readonly getActionMinWidth?: (action: IAction) => number | undefined; readonly allowOverflow?: boolean | (() => boolean); readonly getOverflowAction?: (action: IAction, getAnchor: () => HTMLElement | undefined) => IAction; readonly observedElement?: HTMLElement; readonly getAvailableWidth?: () => number; readonly reserveMinWidth?: boolean; } export interface IToolBarOptions { orientation?: ActionsOrientation; actionViewItemProvider?: IActionViewItemProvider; ariaLabel?: string; getKeyBinding?: (action: IAction) => ResolvedKeybinding | undefined; /** * Returns the index at which the secondary-actions trigger is inserted * among the primary actions. Defaults to after all primary actions. */ getSecondaryActionsPosition?: (primaryActions: readonly IAction[]) => number; actionRunner?: IActionRunner; toggleMenuTitle?: string; anchorAlignmentProvider?: () => AnchorAlignment; dropdownMenuClassName?: string; dropdownMenuCloseAnimation?: IContextViewCloseAnimation; renderDropdownAsChildElement?: boolean; /** * Host dropdown menus as popovers inside the dropdown element, see {@link IContextMenuDelegate.hostAsPopover}. */ renderDropdownAsPopover?: boolean; moreIcon?: ThemeIcon; allowContextMenu?: boolean; skipTelemetry?: boolean; hoverDelegate?: IHoverDelegate; trailingSeparator?: boolean; /** * If true, toggled primary items are highlighted with a background color. */ highlightToggledItems?: boolean; /** * Render action with icons (default: `true`) */ icon?: boolean; /** * Render action with label (default: `false`) */ label?: boolean; /** * Controls the responsive behavior of the primary group of the toolbar. * - `enabled`: Whether the responsive behavior is enabled. * - `kind`: The kind of responsive behavior to apply. Can be either `last` to only shrink the last item, or `all` to shrink all items equally. * - `minItems`: The minimum number of items that should always be visible. * - `overflowFrom`: In `all` mode, overflow actions from this end and restore them in reverse order. Defaults to `end`. * - `actionMinWidth`: The minimum width of each action item. Defaults to `ACTION_MIN_WIDTH` (24px). * - `getActionMinWidth`: Optional per-action minimum width override in pixels. * - `allowOverflow`: Whether actions may move into the overflow menu, or a callback that decides from current presentation state. * - `getOverflowAction`: Replaces an action only while it is rendered in the overflow menu. * - `reserveMinWidth`: Whether the toolbar sets a CSS minimum width on itself and its container so that its `minItems` always fit. Defaults to `true`. * When `false`, the surrounding layout may shrink the toolbar below that width, in which case the `minItems` overflow too. */ responsiveBehavior?: IToolBarResponsiveBehaviorOptions; } /** * A widget that combines an action bar for primary actions and a dropdown for secondary actions. */ export declare class ToolBar extends Disposable { private readonly container; private options; protected readonly actionBar: ActionBar; private toggleMenuAction; private toggleMenuActionViewItem; private hasSecondaryActions; private readonly element; private _onDidChangeDropdownVisibility; get onDidChangeDropdownVisibility(): import("../../../common/event.js").Event; private originalPrimaryActions; private originalSecondaryActions; private hiddenActions; private minItemsWidth; private readonly dropdownMenuDisposables; constructor(container: HTMLElement, contextMenuProvider: IContextMenuProvider, options?: IToolBarOptions); set actionRunner(actionRunner: IActionRunner); get actionRunner(): IActionRunner; set context(context: unknown); getElement(): HTMLElement; /** Focuses the item at `index`, or the first item when no index is given. */ focus(index?: number): void; setFocusable(focusable: boolean): void; getItemsWidth(): number; getItemAction(indexOrElement: number | HTMLElement): IAction | undefined; getItemWidth(index: number): number; getItemElement(index: number): HTMLElement | undefined; getItemViewItem(index: number): IActionViewItem | undefined; private getUnshrunkItemWidth; getItemsLength(): number; hasOverflow(): boolean; setAriaLabel(label: string): void; /** * Force the responsive overflow logic to re-evaluate item visibility. * Call this after action view items change their rendered size externally * (e.g. label text changes) without the toolbar being notified. */ relayout(): void; setActions(primaryActions: ReadonlyArray, secondaryActions?: ReadonlyArray): void; isEmpty(): boolean; private get overflowFromStart(); private getSecondaryActionsPosition; private getRenderedPrimaryActionCountBefore; private getToggleMenuActionInsertionIndex; private getPrimaryActionInsertionIndex; private getKeybindingLabel; private getConfiguredActionMinWidth; private getActionMinWidth; private getAvailableWidth; private reserveMinWidth; private applyResponsiveActionMinWidths; private updateActions; private updateOverflowClassName; private pullAction; private clear; dispose(): void; } export declare class ToggleMenuAction extends Action { static readonly ID = "toolbar.toggle.more"; private _menuActions; private toggleDropdownMenu; constructor(toggleDropdownMenu: () => void, title?: string); run(): Promise; get menuActions(): ReadonlyArray; set menuActions(actions: ReadonlyArray); }