import type { Entity } from "@vertigis/arcgis-extensions/Entity"; import type { ItemKey } from "../ItemKey"; import type { LayoutSlot } from "../designer/LayoutSlot"; import type { DesignerCommandToolBase } from "../designer/commands"; import type { MessageBus } from "../messaging"; import type { ComponentModelBase } from "../models"; /** * Metadata for a component. */ export interface DesignerComponentInfo { /** * Whether the component supports children. Default is `false`. */ canHaveChildren?: boolean; /** * The title of the type of component. E.g "I Want To Menu" or "Results * List". */ componentTypeTitle: string; /** * The default slot. This slot will be given to a child if the child does * not have a slot defined. */ defaultSlot?: string; /** * Whether this model is configurable in designer. If it is not configurable * it means that there is no config attribute in the layout. */ isConfigurable: boolean; /** * The unique ID for the Components layout node. */ layoutId: string; /** * The component's model. */ model?: ComponentModelBase; /** * The slots provided by the component. */ slots?: LayoutSlot[]; } /** * Factory for creating tools. */ export type ToolFactory = (args: CreateToolArgs) => DesignerCommandToolBase | undefined | Promise; /** * Arguments used in the tool factory. */ export interface CreateToolArgs extends Pick { /** * Gets all components from the current layout. */ getAllComponents(): DesignerComponentInfo[]; /** * Gets components from the current layout of a particular name (e.g "iwtm", * "map", or "results-list"). * * @param name The name of the component as it appears in the layout * element. */ getComponentsByName(name: string, namespace?: string): DesignerComponentInfo[]; /** * Gets an item from the app. * * @param key The item's unique key. */ getItem(key: ItemKey): Promise; /** * Gets an item from the app. * * @param type The item's type. * @param id The item's id. */ getItem(type: string, id: string): Promise; /** * Gets an item from the app. * * @param itemUri A URI that unique identifies the item, in the form * "item://type/id". */ getItem(itemUri: string): Promise; /** * Gets items of a particular type from the app. * * @param type The item type. */ getItemsByType(type: string): Promise; /** * A translate function to translate a language key into the browser's * locale. NOTE: Most Web UI components will automatically perform * translation so this should be rarely needed. */ translate(text: string, ...args: unknown[]): string; } /** * Metadata for a tool. Tools are an abstraction on top of command chains that * allow for simpler configuration of complicated actions. Tools are only * configured in Designer. */ export interface ToolManifest { /** * The unique ID for the tool. */ id: string; /** * A function that returns a tool factory promise. */ getTool: () => Promise; }