feat: added detailed definition of some skeleton.add parameters

This commit is contained in:
liujuping 2023-02-10 17:53:16 +08:00 committed by 林熠
parent ac211009b4
commit c905aa27c3
4 changed files with 14 additions and 16 deletions

View File

@ -26,6 +26,7 @@ import {
PluginClassSet, PluginClassSet,
IPublicTypeWidgetBaseConfig, IPublicTypeWidgetBaseConfig,
IPublicTypeWidgetConfigArea, IPublicTypeWidgetConfigArea,
IPublicTypeSkeletonConfig,
} from '@alilc/lowcode-types'; } from '@alilc/lowcode-types';
const logger = new Logger({ level: 'warn', bizName: 'skeleton' }); const logger = new Logger({ level: 'warn', bizName: 'skeleton' });
@ -66,6 +67,8 @@ export class Skeleton {
readonly stages: Area<StageConfig, Stage>; readonly stages: Area<StageConfig, Stage>;
readonly widgets: IWidget[] = [];
constructor(readonly editor: Editor, readonly viewName: string = 'global') { constructor(readonly editor: Editor, readonly viewName: string = 'global') {
makeObservable(this); makeObservable(this);
this.leftArea = new Area( this.leftArea = new Area(
@ -179,6 +182,7 @@ export class Skeleton {
this.setupPlugins(); this.setupPlugins();
this.setupEvents(); this.setupEvents();
} }
/** /**
* setup events * setup events
* *
@ -277,8 +281,6 @@ export class Skeleton {
this.editor.eventBus.emit(event, ...args); this.editor.eventBus.emit(event, ...args);
} }
readonly widgets: IWidget[] = [];
createWidget(config: IPublicTypeWidgetBaseConfig | IWidget) { createWidget(config: IPublicTypeWidgetBaseConfig | IWidget) {
if (isWidget(config)) { if (isWidget(config)) {
return config; return config;
@ -377,7 +379,7 @@ export class Skeleton {
return restConfig; return restConfig;
} }
add(config: IPublicTypeWidgetBaseConfig, extraConfig?: Record<string, any>) { add(config: IPublicTypeSkeletonConfig, extraConfig?: Record<string, any>) {
const parsedConfig = { const parsedConfig = {
...this.parseConfig(config), ...this.parseConfig(config),
...extraConfig, ...extraConfig,

View File

@ -6,6 +6,7 @@ import {
TipContent, TipContent,
IPublicTypeWidgetConfigArea, IPublicTypeWidgetConfigArea,
IPublicTypeWidgetBaseConfig, IPublicTypeWidgetBaseConfig,
IPublicTypePanelDockPanelProps,
} from '@alilc/lowcode-types'; } from '@alilc/lowcode-types';
import { IWidget } from './widget/widget'; import { IWidget } from './widget/widget';
@ -63,8 +64,8 @@ export function isDockConfig(obj: any): obj is DockConfig {
export interface DialogDockConfig extends IDockBaseConfig { export interface DialogDockConfig extends IDockBaseConfig {
type: 'DialogDock'; type: 'DialogDock';
dialogProps?: { dialogProps?: {
title?: IPublicTypeTitleContent;
[key: string]: any; [key: string]: any;
title?: IPublicTypeTitleContent;
}; };
} }
@ -85,16 +86,11 @@ export function isPanelConfig(obj: any): obj is PanelConfig {
export type HelpTipConfig = string | { url?: string; content?: string | ReactElement }; export type HelpTipConfig = string | { url?: string; content?: string | ReactElement };
export interface PanelProps { export interface PanelProps extends IPublicTypePanelDockPanelProps {
title?: IPublicTypeTitleContent; title?: IPublicTypeTitleContent;
icon?: any; // 冗余字段 icon?: any; // 冗余字段
description?: string | IPublicTypeI18nData; description?: string | IPublicTypeI18nData;
hideTitleBar?: boolean; // panel.props 兼容,不暴露
help?: HelpTipConfig; // 显示问号帮助 help?: HelpTipConfig; // 显示问号帮助
width?: number; // panel.props
height?: number; // panel.props
maxWidth?: number; // panel.props
maxHeight?: number; // panel.props
hiddenWhenInit?: boolean; // when this is true, by default will be hidden hiddenWhenInit?: boolean; // when this is true, by default will be hidden
condition?: (widget: IWidget) => any; condition?: (widget: IWidget) => any;
onInit?: (widget: IWidget) => any; onInit?: (widget: IWidget) => any;

View File

@ -4,7 +4,7 @@ import {
SkeletonEvents, SkeletonEvents,
} from '@alilc/lowcode-editor-skeleton'; } from '@alilc/lowcode-editor-skeleton';
import { skeletonSymbol } from '../symbols'; import { skeletonSymbol } from '../symbols';
import { IPublicApiSkeleton, IPublicTypeDisposable, IPublicTypeWidgetBaseConfig, IPublicTypeWidgetConfigArea } from '@alilc/lowcode-types'; import { IPublicApiSkeleton, IPublicTypeDisposable, IPublicTypeSkeletonConfig, IPublicTypeWidgetConfigArea } from '@alilc/lowcode-types';
const innerSkeletonSymbol = Symbol('skeleton'); const innerSkeletonSymbol = Symbol('skeleton');
export class Skeleton implements IPublicApiSkeleton { export class Skeleton implements IPublicApiSkeleton {
@ -38,7 +38,7 @@ export class Skeleton implements IPublicApiSkeleton {
* @param extraConfig * @param extraConfig
* @returns * @returns
*/ */
add(config: IPublicTypeWidgetBaseConfig, extraConfig?: Record<string, any>) { add(config: IPublicTypeSkeletonConfig, extraConfig?: Record<string, any>) {
const configWithName = { const configWithName = {
...config, ...config,
pluginName: this.pluginName, pluginName: this.pluginName,
@ -51,7 +51,7 @@ export class Skeleton implements IPublicApiSkeleton {
* @param config * @param config
* @returns * @returns
*/ */
remove(config: IPublicTypeWidgetBaseConfig): number | undefined { remove(config: IPublicTypeSkeletonConfig): number | undefined {
const { area, name } = config; const { area, name } = config;
const skeleton = this[skeletonSymbol]; const skeleton = this[skeletonSymbol];
if (!normalizeArea(area)) { if (!normalizeArea(area)) {

View File

@ -1,4 +1,4 @@
import { IPublicTypeDisposable, IPublicTypeWidgetBaseConfig } from '../type'; import { IPublicTypeDisposable, IPublicTypeSkeletonConfig } from '../type';
export interface IPublicApiSkeleton { export interface IPublicApiSkeleton {
@ -9,7 +9,7 @@ export interface IPublicApiSkeleton {
* @param extraConfig * @param extraConfig
* @returns * @returns
*/ */
add(config: IPublicTypeWidgetBaseConfig, extraConfig?: Record<string, any>): any; add(config: IPublicTypeSkeletonConfig, extraConfig?: Record<string, any>): any;
/** /**
* *
@ -17,7 +17,7 @@ export interface IPublicApiSkeleton {
* @param config * @param config
* @returns * @returns
*/ */
remove(config: IPublicTypeWidgetBaseConfig): number | undefined; remove(config: IPublicTypeSkeletonConfig): number | undefined;
/** /**
* Panel * Panel