UNPKG

4.81 kBTypeScriptView Raw
1import * as React from 'react';
2import { Event, MenuPath } from '../../../common';
3import { Widget } from '../../widgets';
4/** Items whose group is exactly 'navigation' will be rendered inline. */
5export declare const NAVIGATION = "navigation";
6export declare const TAB_BAR_TOOLBAR_CONTEXT_MENU: string[];
7export interface TabBarDelegator extends Widget {
8 getTabBarDelegate(): Widget | undefined;
9}
10export declare namespace TabBarDelegator {
11 function is(candidate?: Widget): candidate is TabBarDelegator;
12}
13interface RegisteredToolbarItem {
14 /**
15 * The unique ID of the toolbar item.
16 */
17 id: string;
18}
19interface RenderedToolbarItem {
20 /**
21 * Optional icon for the item.
22 */
23 icon?: string | (() => string);
24 /**
25 * Optional text of the item.
26 *
27 * Strings in the format `$(iconIdentifier~animationType) will be treated as icon references.
28 * If the iconIdentifier begins with fa-, Font Awesome icons will be used; otherwise it will be treated as Codicon name.
29 *
30 * You can find Codicon classnames here: https://microsoft.github.io/vscode-codicons/dist/codicon.html
31 * You can find Font Awesome classnames here: http://fontawesome.io/icons/
32 * The type of animation can be either `spin` or `pulse`.
33 */
34 text?: string;
35 /**
36 * Optional tooltip for the item.
37 */
38 tooltip?: string;
39}
40interface SelfRenderingToolbarItem {
41 render(widget?: Widget): React.ReactNode;
42}
43interface ExecutableToolbarItem {
44 /**
45 * The command to execute when the item is selected.
46 */
47 command: string;
48}
49export interface MenuToolbarItem {
50 /**
51 * A menu path with which this item is associated.
52 * If accompanied by a command, this data will be passed to the {@link MenuCommandExecutor}.
53 * If no command is present, this menu will be opened.
54 */
55 menuPath: MenuPath;
56}
57interface ConditionalToolbarItem {
58 /**
59 * https://code.visualstudio.com/docs/getstarted/keybindings#_when-clause-contexts
60 */
61 when?: string;
62 /**
63 * Checked before the item is shown.
64 */
65 isVisible?(widget?: Widget): boolean;
66 /**
67 * When defined, the container tool-bar will be updated if this event is fired.
68 *
69 * Note: currently, each item of the container toolbar will be re-rendered if any of the items have changed.
70 */
71 onDidChange?: Event<void>;
72}
73interface InlineToolbarItemMetadata {
74 /**
75 * Priority among the items. Can be negative. The smaller the number the left-most the item will be placed in the toolbar. It is `0` by default.
76 */
77 priority?: number;
78 group: 'navigation' | undefined;
79}
80interface MenuToolbarItemMetadata {
81 /**
82 * Optional group for the item. Default `navigation`.
83 * `navigation` group will be inlined, while all the others will appear in the `...` dropdown.
84 * A group in format `submenu_group_1/submenu 1/.../submenu_group_n/ submenu n/item_group` means that the item will be located in a submenu(s) of the `...` dropdown.
85 * The submenu's title is named by the submenu section name, e.g. `group/<submenu name>/subgroup`.
86 */
87 group: string;
88 /**
89 * Optional ordering string for placing the item within its group
90 */
91 order?: string;
92}
93/**
94 * Representation of an item in the tab
95 */
96export interface TabBarToolbarItem extends RegisteredToolbarItem, ExecutableToolbarItem, RenderedToolbarItem, Omit<ConditionalToolbarItem, 'isVisible'>, Pick<InlineToolbarItemMetadata, 'priority'>, Partial<MenuToolbarItemMetadata> {
97}
98/**
99 * Tab-bar toolbar item backed by a `React.ReactNode`.
100 * Unlike the `TabBarToolbarItem`, this item is not connected to the command service.
101 */
102export interface ReactTabBarToolbarItem extends RegisteredToolbarItem, SelfRenderingToolbarItem, ConditionalToolbarItem, Pick<InlineToolbarItemMetadata, 'priority'>, Pick<Partial<MenuToolbarItemMetadata>, 'group'> {
103}
104export interface AnyToolbarItem extends RegisteredToolbarItem, Partial<ExecutableToolbarItem>, Partial<RenderedToolbarItem>, Partial<SelfRenderingToolbarItem>, Partial<ConditionalToolbarItem>, Partial<MenuToolbarItem>, Pick<InlineToolbarItemMetadata, 'priority'>, Partial<MenuToolbarItemMetadata> {
105}
106export interface MenuDelegate extends MenuToolbarItem, Required<Pick<ConditionalToolbarItem, 'isVisible'>> {
107}
108export declare namespace TabBarToolbarItem {
109 /**
110 * Compares the items by `priority` in ascending. Undefined priorities will be treated as `0`.
111 */
112 const PRIORITY_COMPARATOR: (left: TabBarToolbarItem, right: TabBarToolbarItem) => number;
113 function is(arg: unknown): arg is TabBarToolbarItem;
114}
115export declare namespace MenuToolbarItem {
116 function getMenuPath(item: AnyToolbarItem): MenuPath | undefined;
117}
118export {};
119//# sourceMappingURL=tab-bar-toolbar-types.d.ts.map
\No newline at end of file