UNPKG

@difizen/mana-core

Version:

77 lines 2.46 kB
/// <reference types="react" /> import type { Event, Disposable } from '@difizen/mana-common'; import type { CommandHandler } from '../command'; /** * Instance of toolbar * Use this token to get the toolbar instance when customizing elements on the toolbar. */ export declare const ToolbarInstance: unique symbol; /** * Factory for instantiating toolbars. */ export declare const ToolbarItemFactory: unique symbol; export interface ToolbarItemFactory { (item: ToolbarNode): ToolbarItem; } export declare const ToolbarNode: unique symbol; type Partial<T> = { [P in keyof T]?: T[P] | undefined; }; export type ToolbarNode = BaseToolbarNode & Partial<CommandHandler>; export interface BaseToolbarNode { /** * The unique ID of the toolbar item. */ readonly id: string; /** * The command to execute. */ readonly command: string; /** * 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. */ /** * show in the `...` dropdown */ readonly extra?: boolean | undefined; /** * The order to display toolbar item inline or in the `...` dropdown. */ readonly order?: string | undefined; /** * When extra, group means that the item will be located in a submenu(s) of the `...` dropdown. * The submenu's title is named by the name in group, e.g. ['menu', 'submenu']. */ readonly group?: string | string[] | undefined; /** * Optional label for the item. */ readonly label?: React.ReactNode | React.FC; /** * Optional tooltip for the item. */ readonly tooltip?: React.ReactNode | React.FC; /** * Optional icon for the item. */ readonly icon?: React.ReactNode | React.FC; /** * Show toolbar item label inline. */ readonly showLabelInline?: boolean | undefined; /** * Custom meta data for the item. */ meta?: Record<string, any> | undefined; } export interface ToolbarItem extends ToolbarNode, Disposable { source: ToolbarNode; onDisposed: Event<void>; } export declare namespace ToolbarItem { function isDefinition(arg: Record<string, any> | undefined): arg is ToolbarNode; function is(arg: Record<string, any> | undefined): arg is ToolbarItem; function getGroupKey(record: ToolbarItem): string; } export {}; //# sourceMappingURL=toolbar-protocol.d.ts.map