docs: 参照协议规范,完善所有 schema 和 asset 相关描述

This commit is contained in:
humphry.hy 2021-12-13 19:47:11 +08:00
parent 1a2f82154b
commit 820f8c046c
8 changed files with 327 additions and 47 deletions

View File

@ -1,6 +1,7 @@
import { NpmInfo } from './npm';
import { PropConfig } from './prop-config';
import { Snippet, ComponentMetadata } from './metadata';
import { I18nData } from './i18n';
/**
* external资源的信息
@ -27,7 +28,7 @@ export interface Package {
*/
library: string;
/**
* todo
* @todo
*/
async?: boolean;
/**
@ -77,11 +78,13 @@ export interface ComponentItem {
/**
*
*/
group?: string;
group?: string | I18nData;
/**
*
*/
category?: string;
category?: string | I18nData;
/**
*
*/
@ -93,7 +96,7 @@ export interface ComponentItem {
*/
export interface ComponentDescription extends ComponentMetadata {
/**
* todo
* @todo
*/
keywords: string[];
}

View File

@ -50,11 +50,20 @@ export interface FieldExtraProps {
* compatiable vision display
*/
display?: 'accordion' | 'inline' | 'block' | 'plain' | 'popup' | 'entry';
// todo 这个 omit 是否合理?
// @todo 这个 omit 是否合理?
/**
* @todo
*/
liveTextEditing?: Omit<LiveTextEditingConfig, 'propTarget'>;
}
/**
*
*/
export interface FieldConfig extends FieldExtraProps {
/**
* @todo
*/
type?: 'field' | 'group';
/**
* the name of this setting field, which used in quickEditor
@ -78,11 +87,11 @@ export interface FieldConfig extends FieldExtraProps {
*/
extraProps?: FieldExtraProps;
/**
* todo
* @todo
*/
description?: TitleContent;
/**
* todo
* @todo
*/
isExtends?: boolean;
}

View File

@ -9,7 +9,14 @@ import { NodeSchema, NodeData, ComponentSchema } from './schema';
import { SettingTarget } from './setting-target';
import { I18nData } from './i18n';
/**
*
*/
export type NestingFilter = (testNode: any, currentNode: any) => boolean;
/**
*
* a a, FormField Form Column Table
*/
export interface NestingRule {
/**
*
@ -33,26 +40,64 @@ export interface NestingRule {
ancestorWhitelist?: string[] | string | RegExp | NestingFilter;
}
/**
*
*/
export interface ComponentConfigure {
/**
*
*/
isContainer?: boolean;
/**
*
*/
isModal?: boolean;
/**
*
*/
isNullNode?: boolean;
/**
*
*/
descriptor?: string;
/**
*
* a a, FormField Form Column Table
*/
nestingRule?: NestingRule;
/**
*
*
*/
isMinimalRenderUnit?: boolean;
/**
* cssSelector
*/
rootSelector?: string;
/**
* copy, move, remove | *
* `'copy'`, `'move'`, `'remove'`
*/
disableBehaviors?: string[] | string;
/**
*
*/
actions?: ComponentAction[];
}
export interface Snippet {
/**
* title
*/
title?: string;
/**
* snippet
*/
screenshot?: string;
/**
* @todo snippet
*/
label?: string;
schema?: NodeSchema;
}
@ -70,26 +115,61 @@ export interface AutorunItem {
autorun: (target: SettingTarget) => any;
}
/**
*
*/
export interface Experimental {
/**
* @todo
*/
context?: { [contextInfoName: string]: any };
/**
* @todo
*/
snippets?: Snippet[];
/**
* @todo
*/
view?: ComponentType<any>;
/**
* @todo
*/
transducers?: any;
/**
* @deprecated
* @deprecated prop
*/
initials?: InitialItem[];
/**
* @todo
*/
filters?: FilterItem[];
/**
* @todo
*/
autoruns?: AutorunItem[];
/**
* callbacks onNodeAddonResize
*/
callbacks?: Callbacks;
/**
* @todo
*/
initialChildren?: NodeData[] | ((target: SettingTarget) => NodeData[]);
/**
* @todo
*/
isAbsoluteLayoutContainer?: boolean;
/**
* @todo
*/
hideSelectTools?: boolean;
/**
* handle上必须有明确的标识以便事件路由判断
* NWSE ReactElement
*/
/**
* resize
* - hover
* - mousedown
* - dragstart resizing hud
@ -111,6 +191,10 @@ export interface Experimental {
* Live Text Editing children
*/
liveTextEditing?: LiveTextEditingConfig[];
/**
* @todo
*/
isTopFixed?: boolean;
}
@ -120,11 +204,11 @@ export interface Experimental {
*/
export interface LiveTextEditingConfig {
/**
* todo
* @todo
*/
propTarget: string;
/**
* todo
* @todo
*/
selector?: string;
/**
@ -144,22 +228,58 @@ export type ConfigureSupportEvent = string | {
description?: string;
};
export type ConfigureSupport = {
/**
*
*/
export interface ConfigureSupport {
/**
*
*/
events?: ConfigureSupportEvent[];
/**
* className
*/
className?: boolean;
/**
*
*/
style?: boolean;
/**
*
*/
lifecycles?: any[];
// general?: boolean;
/**
*
*/
loop?: boolean;
/**
*
*/
condition?: boolean;
};
}
/**
*
*/
export interface Configure {
/**
*
*/
props?: FieldConfig[];
/**
*
*/
component?: ComponentConfigure;
/**
*
*/
supports?: ConfigureSupport;
}
/**
*
*/
export interface ActionContentObject {
/**
*
@ -175,6 +295,9 @@ export interface ActionContentObject {
action?: (currentNode: any) => void;
}
/**
* @todo
*/
export interface ComponentAction {
/**
* behaviorName
@ -203,7 +326,13 @@ export function isActionContentObject(obj: any): obj is ActionContentObject {
return obj && typeof obj === 'object';
}
/**
* meta
*/
export interface ComponentMetadata {
/**
*
*/
componentName: string;
/**
* unique id
@ -217,22 +346,67 @@ export interface ComponentMetadata {
* svg icon for component
*/
icon?: IconType;
/**
*
*/
tags?: string[];
/**
*
*/
description?: string;
/**
*
*/
docUrl?: string;
/**
*
*/
screenshot?: string;
/**
*
*/
devMode?: 'procode' | 'lowcode';
/**
* npm
*/
npm?: NpmInfo;
/**
*
*/
props?: PropConfig[];
/**
*
*/
configure?: FieldConfig[] | Configure;
/**
*
*/
experimental?: Experimental;
/**
* @todo
*/
schema?: ComponentSchema;
/**
*
*/
snippets?: Snippet[];
/**
*
*/
group?: string | I18nData;
/**
*
*/
category?: string | I18nData;
/**
*
*/
priority?: number;
}
/**
* @todo
*/
export interface TransformedComponentMetadata extends ComponentMetadata {
configure: Configure & { combined?: FieldConfig[] };
}
@ -242,12 +416,10 @@ export interface TransformedComponentMetadata extends ComponentMetadata {
*/
/**
* hooks & events
* callbacks onNodeAddonResize
*/
export interface Callbacks {
/**
* hooks
*/
// hooks
onMouseDownHook?: (e: MouseEvent, currentNode: any) => any;
onDblClickHook?: (e: MouseEvent, currentNode: any) => any;
onClickHook?: (e: MouseEvent, currentNode: any) => any;
@ -258,9 +430,7 @@ export interface Callbacks {
onHoverHook?: (currentNode: any) => boolean;
onChildMoveHook?: (childNode: any, currentNode: any) => boolean;
/**
* events
*/
// events
onNodeRemove?: (removedNode: any, currentNode: any) => void;
onNodeAdd?: (addedNode: any, currentNode: any) => void;
onSubtreeModified?: (currentNode: any, options: any) => void;

View File

@ -1,10 +1,34 @@
/**
* npm
*/
export interface NpmInfo {
/**
*
*/
componentName?: string;
/**
*
*/
package: string;
/**
*
*/
version?: string;
/**
*
*/
destructuring?: boolean;
/**
*
*/
exportName?: string;
/**
*
*/
subName?: string;
/**
*
*/
main?: string;
}

View File

@ -38,10 +38,28 @@ export interface Exact {
isRequired?: boolean;
}
/**
*
*/
export interface PropConfig {
/**
*
*/
name: string;
/**
*
*/
propType: PropType;
/**
*
*/
description?: string;
/**
*
*/
defaultValue?: any;
/**
* @todo
*/
setter?: any;
}

View File

@ -12,6 +12,7 @@ import { UtilsMap } from './utils';
import { AppConfig } from './app-config';
// 转换成一个 .jsx 文件内 React Class 类 render 函数返回的 jsx 代码
/**
* -
*/
@ -50,9 +51,7 @@ export interface NodeSchema {
*/
isLocked?: boolean;
/**
* ------- future support -----
*/
// ------- future support -----
conditionGroup?: string;
title?: string;
ignore?: boolean;
@ -77,25 +76,53 @@ export function isDOMText(data: any): data is DOMText {
export type DOMText = string;
/**
*
*/
export interface ContainerSchema extends NodeSchema {
/**
* 'Block' | 'Page' | 'Component';
*/
componentName: string;
/**
*
*/
fileName: string;
/**
* @todo
*/
meta?: Record<string, unknown>;
/**
*
*/
state?: {
[key: string]: CompositeValue;
};
/**
*
*/
methods?: {
[key: string]: JSExpression | JSFunction;
};
/**
*
*/
lifeCycles?: {
[key: string]: JSExpression | JSFunction;
};
/**
*
*/
css?: string;
/**
*
*/
dataSource?: DataSource;
/**
*
*/
defaultProps?: CompositeObject;
// @todo propDefinitions
}
/**
@ -122,25 +149,69 @@ export interface BlockSchema extends ContainerSchema {
componentName: 'Block';
}
/**
* @todo
*/
export type RootSchema = PageSchema | ComponentSchema | BlockSchema;
/**
* Slot schema
*/
export interface SlotSchema extends NodeSchema {
componentName: 'Slot';
name?: string;
params?: string[];
}
/**
*
*/
export interface ProjectSchema {
/**
*
*/
version: string;
/**
*
*/
componentsMap: ComponentsMap;
/**
*
*
* 1,
*/
componentsTree: RootSchema[];
/**
*
*/
i18n?: I18nMap;
/**
*
*/
utils?: UtilsMap;
/**
* @todo
*/
constants?: JSONObject;
/**
*
*/
css?: string;
/**
*
*/
dataSource?: DataSource;
/**
*
*/
config?: AppConfig | Record<string, any>;
/**
* @todo
*/
id?: string;
/**
*
*/
meta?: Record<string, any>;
}

View File

@ -77,7 +77,7 @@ export interface SettingTarget {
*/
setExtraPropValue: (propName: string, value: any) => void;
// todo 补充 node 定义
// @todo 补充 node 定义
/**
* node
*/

View File

@ -17,24 +17,12 @@ export interface JSExpression {
compiled?: string;
}
/**
*
*/
export interface JSFunction {
type: 'JSFunction';
/**
*
*/
value: string;
}
/**
*
* @see https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#feHTW
*/
export interface JSFunction {
type: 'JSFunction';
/**
*
*/
@ -42,27 +30,21 @@ export interface JSFunction {
/** 源码 */
compiled?: string;
}
/**
*
*/
export interface JSFunction {
type: 'JSFunction';
/**
*
*/
value: string;
/**
*
*/
mock?: any;
/**
* extTypeevents
*/
[key: string]: any;
}
/**
* Slot
*/
export interface JSSlot {
type: 'JSSlot';
title?: string;
@ -74,6 +56,9 @@ export interface JSSlot {
name?: string;
}
/**
* @todo
*/
export interface JSBlock {
type: 'JSBlock';
value: NodeSchema;