import React from 'react'; import Sortable from 'sortablejs'; import { DataSchema } from 'amis'; import { FormControlProps, ListenerAction } from 'amis-core'; import CmptActionSelect from './comp-action-select'; import ActionConfigPanel from './action-config-panel'; export interface RendererEvent { eventName: string; eventLabel: string; description?: string; defaultShow?: boolean; isBroadcast?: boolean; owner?: string; dataSchema?: any[]; } export interface RendererAction { actionType: string; actionLabel: string; description?: string; schema?: any; config?: string[]; desc?: (info: any) => string | JSX.Element; } export interface PluginEvents { [propName: string]: RendererEvent[]; } export interface PluginActions { [propName: string]: RendererAction[]; } export interface ActionConfig extends ListenerAction { [propName: string]: any; } export interface ActionEventConfig { [propName: string]: { weight?: number; actions: ActionConfig[]; __isBroadcast?: boolean; }; } export interface ComponentInfo { label: string; value: string; type: string; disabled?: boolean; actions?: ActionTypeNode[]; children?: ComponentInfo[]; } export interface ActionConfigItemsMap { [propName: string]: { schema?: any; config?: string[]; desc?: (info: any) => string | JSX.Element; withComponentId?: boolean; supportComponents?: string[]; }; } export interface ContextVariables { label: string; value?: any; tag?: string | string[]; children?: any[]; } export interface ActionTypeNode extends RendererAction { children?: ActionTypeNode[]; } interface EventControlProps extends FormControlProps { actions: PluginActions; events: PluginEvents; actionTree: ActionTypeNode[]; actionConfigItemsMap?: ActionConfigItemsMap; value: ActionEventConfig; onChange: (value: any, submitOnChange?: boolean, changeImmediately?: boolean) => void; addBroadcast?: (event: RendererEvent) => void; removeBroadcast?: (eventName: string) => void; getComponents: () => ComponentInfo[]; getContextSchemas?: (id?: string, withoutSuper?: boolean) => DataSchema; owner?: string; } interface EventControlState { onEvent: ActionEventConfig; events: RendererEvent[]; eventPanelActive: { [prop: string]: boolean; }; showAcionDialog: boolean; actionData: { eventKey: string; actionIndex?: number; action?: ActionConfig; variables?: ContextVariables[]; } | undefined; type: 'update' | 'add'; rawVariables: ContextVariables[]; actionConfigItems: ActionConfigItemsMap; } export declare class EventControl extends React.Component { target: HTMLElement | null; eventPanelSortMap: { [prop: string]: Sortable; }; drag?: HTMLElement | null; isUnmount: boolean; constructor(props: EventControlProps); componentDidMount(): void; componentDidUpdate(prevProps: EventControlProps, prevState: EventControlState): void; componentWillUnmount(): void; /** * 获取上下文变量 */ loadContextVariables(): Promise; generateEmptyDefault(events: RendererEvent[]): ActionEventConfig; addEvent(event: RendererEvent): void; delEvent(event: string): void; addAction(event: string, config: any): void; updateAction(event: string, index: number, config: any): void; delAction(event: string, action: any, index: number): void; toggleActivePanel(eventKey: string): void; updateWeight(event: string, data: any): void; /** * 更新事件配置 * * @param {string} event * @param {number} actionIndex * @param {*} config * @memberof EventControl */ updateValue(event: string, index: number, config: any): void; submitConfig(type: string, config: any): void; /** * 根据动作类型获取过滤后的组件树 * @param components * @param actionType * @returns */ getComponentTreeSource(actionType: string): ComponentInfo[]; renderConfig(type: string): { type: string; title: string; mode: string; wrapperComponent: string; submitText: string; autoFocus: boolean; preventEnterSubmit: boolean; onSubmit: any; body: { type: string; className: string; columns: ({ body: ({ type: string; tpl: string; className: string; inline: boolean; name?: undefined; disabled?: undefined; options?: undefined; showIcon?: undefined; mode?: undefined; labelField?: undefined; valueField?: undefined; inputClassName?: undefined; autoFill?: undefined; onChange?: undefined; } | { type: string; name: string; disabled: boolean; options: ActionTypeNode[]; showIcon: boolean; className: string; mode: string; labelField: string; valueField: string; inputClassName: string; autoFill: { __actionDesc: string; }; onChange: (value: string, oldVal: any, data: any, form: any) => void; tpl?: undefined; inline?: undefined; })[]; md: number; columnClassName: string; } | { body: ({ type: string; tpl: string; className: string; visibleOn: string; inline: boolean; body?: undefined; } | { type: string; className: string; tpl: string; visibleOn: string; inline?: undefined; body?: undefined; } | { type: string; className: string; body: ({ type: string; name: string; label: string; showIcon: boolean; searchable: boolean; requiredOn: string; selfDisabledAffectChildren: boolean; size: string; source: string; mode: string; autoFill: { __rendererLabel: string; __rendererName: string; __nodeId: string; __nodeSchema: string; }; visibleOn: string; onChange: (value: string, oldVal: any, data: any, form: any) => Promise; asFormItem?: undefined; required?: undefined; component?: undefined; description?: undefined; pluginActions?: undefined; value?: undefined; pipeIn?: undefined; options?: undefined; actionConfigItems?: undefined; actions?: undefined; tpl?: undefined; inline?: undefined; className?: undefined; title?: undefined; variableMode?: undefined; inputMode?: undefined; variables?: undefined; placeholder?: undefined; } | { asFormItem: boolean; label: string; name: string; mode: string; required: boolean; visibleOn: string; component: typeof CmptActionSelect; description: string; pluginActions: PluginActions; type?: undefined; showIcon?: undefined; searchable?: undefined; requiredOn?: undefined; selfDisabledAffectChildren?: undefined; size?: undefined; source?: undefined; autoFill?: undefined; onChange?: undefined; value?: undefined; pipeIn?: undefined; options?: undefined; actionConfigItems?: undefined; actions?: undefined; tpl?: undefined; inline?: undefined; className?: undefined; title?: undefined; variableMode?: undefined; inputMode?: undefined; variables?: undefined; placeholder?: undefined; } | { type: string; label: string; name: string; mode: string; value: string; required: boolean; pipeIn: (value: any) => any; options: { label: string; value: string; }[]; visibleOn: string; showIcon?: undefined; searchable?: undefined; requiredOn?: undefined; selfDisabledAffectChildren?: undefined; size?: undefined; source?: undefined; autoFill?: undefined; onChange?: undefined; asFormItem?: undefined; component?: undefined; description?: undefined; pluginActions?: undefined; actionConfigItems?: undefined; actions?: undefined; tpl?: undefined; inline?: undefined; className?: undefined; title?: undefined; variableMode?: undefined; inputMode?: undefined; variables?: undefined; placeholder?: undefined; } | { asFormItem: boolean; component: typeof ActionConfigPanel; actionConfigItems: ActionConfigItemsMap; actions: PluginActions; type?: undefined; name?: undefined; label?: undefined; showIcon?: undefined; searchable?: undefined; requiredOn?: undefined; selfDisabledAffectChildren?: undefined; size?: undefined; source?: undefined; mode?: undefined; autoFill?: undefined; visibleOn?: undefined; onChange?: undefined; required?: undefined; description?: undefined; pluginActions?: undefined; value?: undefined; pipeIn?: undefined; options?: undefined; tpl?: undefined; inline?: undefined; className?: undefined; title?: undefined; variableMode?: undefined; inputMode?: undefined; variables?: undefined; placeholder?: undefined; } | { type: string; tpl: string; inline: boolean; className: string; visibleOn: string; name?: undefined; label?: undefined; showIcon?: undefined; searchable?: undefined; requiredOn?: undefined; selfDisabledAffectChildren?: undefined; size?: undefined; source?: undefined; mode?: undefined; autoFill?: undefined; onChange?: undefined; asFormItem?: undefined; required?: undefined; component?: undefined; description?: undefined; pluginActions?: undefined; value?: undefined; pipeIn?: undefined; options?: undefined; actionConfigItems?: undefined; actions?: undefined; title?: undefined; variableMode?: undefined; inputMode?: undefined; variables?: undefined; placeholder?: undefined; } | { name: string; title: string; type: string; variableMode: string; inputMode: string; variables: string; className: string; label: string; mode: string; size: string; placeholder: string; visibleOn: string; showIcon?: undefined; searchable?: undefined; requiredOn?: undefined; selfDisabledAffectChildren?: undefined; source?: undefined; autoFill?: undefined; onChange?: undefined; asFormItem?: undefined; required?: undefined; component?: undefined; description?: undefined; pluginActions?: undefined; value?: undefined; pipeIn?: undefined; options?: undefined; actionConfigItems?: undefined; actions?: undefined; tpl?: undefined; inline?: undefined; })[]; tpl?: undefined; visibleOn?: undefined; inline?: undefined; })[]; columnClassName: string; md?: undefined; })[]; }[]; style: { borderStyle: string; }; className: string; }[]; dragRef(ref: any): void; initDragging(): void; genSortPanel(eventKey: string, ele: HTMLElement): Sortable; destroyDragging(): void; getActionType(action: ActionConfig): string; /** * 格式化初始化时的动作配置 * @param action */ formatActionInitConfig(action: ActionConfig): { actionType: string; __componentTreeSource: ComponentInfo[]; __cmptActionType: string; __showSelectCmpt: boolean | undefined; description?: string | undefined; componentId?: string | undefined; args?: Record | undefined; outputVar?: string | undefined; preventDefault?: boolean | undefined; stopPropagation?: boolean | undefined; expression?: string | undefined; execOn?: string | undefined; }; activeActionDialog(data: Pick): void; getAcionConfig(action: ActionConfig): RendererAction; renderActionDesc(action: ActionConfig): JSX.Element | null; render(): JSX.Element; } export declare class EventControlRenderer extends EventControl { } export declare const getEventLabel: (events: RendererEvent[], name: string) => string | undefined; export declare const getEventDesc: (events: RendererEvent[], name: string) => string | undefined; export declare const getActionLabel: (events: RendererAction[], name: string) => string | undefined; /** * 根据不同的动作类型过滤组件树 * @param componentsTree 组件树 * @param actionType 动作类型 * @returns */ export declare const getComponentTreeByType: (componentsTree: ComponentInfo[] | undefined, actionType: string | undefined, pluginActions: { [key: string]: any; } | undefined, actionConfigItems: ActionConfigItemsMap) => ComponentInfo[]; export {};