UNPKG

ai-form-designer

Version:

vue3+adv的设计器,可视化开发页面表单

369 lines (368 loc) 12.6 kB
import { ComponentSchema } from '../../core/types/ai-form-designer'; import { ShallowRef } from 'vue'; export interface ActivitybarModel { id: string; title: string; icon: string; component: any; visible?: boolean; } export interface RightSidebarModel { id: string; title: string; component: any; visible?: boolean; } export interface ViewsContainersModel { activitybars: ShallowRef<ActivitybarModel[]>; rightSidebars: ShallowRef<RightSidebarModel[]>; } export type Components = Record<string, any>; export interface EventModel { type: string; describe: string; } export interface ActionModel extends EventModel { argsConfigs?: ComponentSchema[]; args?: any[]; } export interface EditConstraintsModel { immovable?: boolean; childImmovable?: boolean; fixedField?: boolean; } export interface ComponentConfigModel { component: any; groupName?: string; icon?: string; defaultSchema: ComponentSchema; editConstraints?: EditConstraintsModel; config: { attribute?: ComponentSchema[]; style?: ComponentSchema[]; event?: EventModel[]; action?: ActionModel[]; }; bindModel?: string; sort?: number; } export type ComponentConfigModelRecords = Record<string, ComponentConfigModel>; export interface PublicMethodModel { describe?: string; methodName?: string; name: string; method?: (...args: any[]) => any; handler: (...args: any[]) => any; } export type PublicMethodsModel = Record<string, PublicMethodModel>; export interface ComponentGroup { list: ComponentSchema[]; title: string; } export type ComponentSchemaGroups = ComponentGroup[]; export declare class PluginManager { initialized: import('vue').Ref<boolean, boolean>; components: Components; componentConfigs: ComponentConfigModelRecords; baseComponentTypes: string[]; componentSchemaGroups: import('vue').Ref<{ list: { [x: string]: any; id?: string | undefined; type: string; label?: string | undefined; field?: string | undefined; componentProps?: any; slotName?: string | undefined; rules?: { [x: string]: any; trigger?: string | string[] | undefined; required?: boolean | undefined; type?: string | undefined; pattern?: (RegExp | string) | undefined; min?: number | undefined; max?: number | undefined; len?: number | undefined; enum?: Array<string | number | boolean | null | undefined> | undefined; whitespace?: boolean | undefined; validator?: string | undefined; isValidator?: boolean | undefined; message?: string | ((a?: string) => string) | undefined; }[] | undefined; noFormItem?: boolean | undefined; input?: boolean | undefined; children?: /*elided*/ any[] | undefined; slots?: { [slotName: string]: ComponentSchema[]; } | undefined; show?: boolean | ((renderCallbackParams: import('../../core/types/ai-form-designer').RenderCallbackParams) => boolean) | undefined; editData?: any; }[]; title: string; }[], ComponentSchemaGroups | { list: { [x: string]: any; id?: string | undefined; type: string; label?: string | undefined; field?: string | undefined; componentProps?: any; slotName?: string | undefined; rules?: { [x: string]: any; trigger?: string | string[] | undefined; required?: boolean | undefined; type?: string | undefined; pattern?: (RegExp | string) | undefined; min?: number | undefined; max?: number | undefined; len?: number | undefined; enum?: Array<string | number | boolean | null | undefined> | undefined; whitespace?: boolean | undefined; validator?: string | undefined; isValidator?: boolean | undefined; message?: string | ((a?: string) => string) | undefined; }[] | undefined; noFormItem?: boolean | undefined; input?: boolean | undefined; children?: /*elided*/ any[] | undefined; slots?: { [slotName: string]: ComponentSchema[]; } | undefined; show?: boolean | ((renderCallbackParams: import('../../core/types/ai-form-designer').RenderCallbackParams) => boolean) | undefined; editData?: any; }[]; title: string; }[]>; hiddenComponents: string[]; formSchemas: ComponentSchema[]; componentGroupNameMap: Record<string, string>; sortedGroups: string[]; viewsContainers: ViewsContainersModel; publicMethods: PublicMethodsModel; /** * 添加组件到插件管理器中 * @param componentType 组件类型 * @param component 组件 */ component(componentType: string, component: any): void; /** * 注册组件到插件管理器中 * @param componentConfig 组件配置 */ registerComponent(componentConfig: ComponentConfigModel): void; /** * 从已记录的基础组件类型中移除特定类型的组件 * @param componentType 要移除的组件类型 */ removeComponent(componentType: string): void; /** * 记录基础组件类型 * @returns baseComponentTypes string[] */ setBaseComponentTypes(baseComponentTypes: string[]): void; /** * 添加基础组件类型 * @returns baseComponentType string */ addBaseComponentTypes(baseComponentType: string): void; /** * 移除已记录的基础组件类型 */ removeBaseComponents(): void; /** * 获取所有插件管理中的所有组件 * @returns components */ getComponents(): Components; /** * 通过type 查询相应的组件 * @returns components */ getComponent(type: string): any; /** * 注册或更新活动栏(Activitybar)模型。 * 如果模型中的组件是一个函数,则异步加载该组件。 * @param activitybar 要注册或更新的活动栏模型 */ registerActivitybar(activitybar: ActivitybarModel): void; /** * 获取所有activitybars * @returns activitybars */ getActivitybars(): ActivitybarModel[]; /** * 隐藏活动栏 * @param value 属性 * @param attr 查询字段 默认值 title */ hideActivitybar(value: string, attr?: string): void; /** * 显示活动栏 * @param value 属性 * @param attr 查询字段 默认值 title */ showActivitybar(value: string, attr?: string): void; /** * 注册右侧栏 */ registerRightSidebar(rightSidebar: RightSidebarModel): void; /** * 获取所有rightSidebars * @returns rightSidebars */ getRightSidebars(): RightSidebarModel[]; /** * 隐藏右侧边栏 * @param value 属性 * @param attr 查询字段 默认值 title */ hideRightSidebar(value: string, attr?: string): void; /** * 显示右侧边栏 * @param value 属性 * @param attr 查询字段 默认值 title */ showRightSidebar(value: string, attr?: string): void; /** * 获取所有插件管理中的所有组件配置 * @returns componentAttrs */ getComponentConfings(): ComponentConfigModelRecords; /** * 通过type获取ComponentConfing * @returns */ getComponentConfingByType(type: string): ComponentConfigModel; /** * 计算componentSchemaGroups */ computedComponentSchemaGroups(): void; /** * 按照分组获取componentSchemaGroups 暂时没啥用 * @returns componentSchemaGroups */ getComponentSchemaGroups(): import('vue').Ref<{ list: { [x: string]: any; id?: string | undefined; type: string; label?: string | undefined; field?: string | undefined; componentProps?: any; slotName?: string | undefined; rules?: { [x: string]: any; trigger?: string | string[] | undefined; required?: boolean | undefined; type?: string | undefined; pattern?: (RegExp | string) | undefined; min?: number | undefined; max?: number | undefined; len?: number | undefined; enum?: Array<string | number | boolean | null | undefined> | undefined; whitespace?: boolean | undefined; validator?: string | undefined; isValidator?: boolean | undefined; message?: string | ((a?: string) => string) | undefined; }[] | undefined; noFormItem?: boolean | undefined; input?: boolean | undefined; children?: /*elided*/ any[] | undefined; slots?: { [slotName: string]: ComponentSchema[]; } | undefined; show?: boolean | ((renderCallbackParams: import('../../core/types/ai-form-designer').RenderCallbackParams) => boolean) | undefined; editData?: any; }[]; title: string; }[], ComponentSchemaGroups | { list: { [x: string]: any; id?: string | undefined; type: string; label?: string | undefined; field?: string | undefined; componentProps?: any; slotName?: string | undefined; rules?: { [x: string]: any; trigger?: string | string[] | undefined; required?: boolean | undefined; type?: string | undefined; pattern?: (RegExp | string) | undefined; min?: number | undefined; max?: number | undefined; len?: number | undefined; enum?: Array<string | number | boolean | null | undefined> | undefined; whitespace?: boolean | undefined; validator?: string | undefined; isValidator?: boolean | undefined; message?: string | ((a?: string) => string) | undefined; }[] | undefined; noFormItem?: boolean | undefined; input?: boolean | undefined; children?: /*elided*/ any[] | undefined; slots?: { [slotName: string]: ComponentSchema[]; } | undefined; show?: boolean | ((renderCallbackParams: import('../../core/types/ai-form-designer').RenderCallbackParams) => boolean) | undefined; editData?: any; }[]; title: string; }[]>; /** * 设置组件分组名称到映射名称的关系 * @param groupName 组件分组名称 * @param mapName 映射的名称 */ setComponentGroupNameMap(groupName: string, mapName: string): void; /** * 清空组件分组名称到映射名称的关系 */ clearComponentGroupNameMap(): void; /** * 设置组件分组的排序 * @param sortedGroups 包含组名和排序字段的对象数组 */ setSortedGroups(sortedGroups: string[]): void; /** * 清空组件分组的排序 */ clearSortedGroups(): void; /** * 添加需要隐藏的组件类型 * @param {*} type * @returns */ hideComponent(type: string): void; /** * 移除需要隐藏的组件类型 * @param {*} type * @returns */ showComponent(type: string): void; /** * 设置需要隐藏的组件类型数组 * @param {*} type[] * @returns */ setHideComponents(types: string[]): void; /** * 设置initialized的状态。 * * @param value 要设置的布尔值。 */ setInitialized(value: boolean): void; /** * 添加公共方法 * @param publicMethod */ addPublicMethod(publicMethod: PublicMethodModel): void; /** * 移除公共方法 * @param methodName */ removePublicMethod(methodName: string): void; } export declare const pluginManager: PluginManager;