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