import type { AgDefaultRegistry } from '../agDefaultRegistry'; import type { AgBaseRegistry, AgWidgetRegistry } from '../agRegistry'; import type { AgDefaultWidgetType } from './agDefaultWidget'; import type { AgBaseWidgetDefinition } from './agWidgetDefinition'; import type { AgWidgetType } from './agWidgetType'; export interface AgWidgetMenuGroup { /** * The label displayed in the UI. Either a localisation key or the display value. */ label: string; /** The list of widgets in this group. */ widgetIds: readonly AgWidgetType[]; /** * If `true`, the group will be collapsed by default. */ collapsed?: boolean; } type ExtractOverride = TWidgetDefinition['id'] extends AgDefaultWidgetType ? Partial> & { id: TWidgetDefinition['id']; } : never; export type AgWidgetOverrideDefinition = ExtractOverride>; type AgCustomWidgetDefinition = AgBaseWidgetDefinition, AgDefaultWidgetType>>; export interface AgBaseCreateWidgetsParams { /** * Configures the widget menu that is displayed in the widgets tab in the edit panel, * and the widget selection input. */ menu?: AgWidgetMenuGroup[]; /** * Overrides to the default widgets. */ overrides?: AgWidgetOverrideDefinition[]; /** * The default widget type created when dragging fields into the layout. */ defaultType?: AgWidgetType; } export interface AgAdditionalCreateWidgetsParams extends AgBaseCreateWidgetsParams { /** * Custom widget definitions. */ additionalTypes: AgCustomWidgetDefinition[]; } export type AgCreateWidgetsParams = [ Exclude, AgDefaultWidgetType> ] extends [never] ? AgBaseCreateWidgetsParams : AgAdditionalCreateWidgetsParams; export interface AgWidgetsConfig { /** * All widget definitions that are being used in studio (default and custom) */ widgets: TRegistry['widgets']; /** * Configures the widget menu that is displayed in the widgets tab in the edit panel, * and the widget selection input. */ menu: AgWidgetMenuGroup[]; /** * The default widget type created when dragging fields into the layout. */ defaultType: AgWidgetType; } export {};