Skip to content

Commit 8356298

Browse files
JackLianliujuping
authored andcommitted
docs: add doc for api/model/component-meta
1 parent b754e61 commit 8356298

23 files changed

Lines changed: 268 additions & 53 deletions

docs/docs/api/canvas.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ createLocation(locationData: IPublicTypeLocationData): IPublicModelDropLocation;
6262
```typescript
6363
/**
6464
* 创建一个滚动控制器 Scroller,赋予一个视图滚动的基本能力,
65-
* a Scroller is a controller that gives a view (IPublicModelScrollable) the ability scrolling
65+
* a Scroller is a controller that gives a view (IPublicTypeScrollable) the ability scrolling
6666
* to some cordination by api scrollTo.
6767
*
6868
* when a scroller is inited, will need to pass is a scrollable, which has a scrollTarget.
6969
* and when scrollTo(options: { left?: number; top?: number }) is called, scroller will
7070
* move scrollTarget`s top-left corner to (options.left, options.top) that passed in.
7171
* @since v1.1.0
7272
*/
73-
createScroller(scrollable: IPublicModelScrollable): IPublicModelScroller;
73+
createScroller(scrollable: IPublicTypeScrollable): IPublicModelScroller;
7474

7575
```
7676

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
---
2+
title: ComponentMeta
3+
sidebar_position: 15
4+
---
5+
6+
> **@types** [IPublicModelComponentMeta](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/component-meta.ts)<br/>
7+
> **@since** v1.0.0
8+
9+
## 基本介绍
10+
11+
组件元数据信息模型
12+
13+
## 属性
14+
15+
### componentName
16+
17+
组件名
18+
19+
`@type {string}`
20+
21+
### isContainer
22+
23+
是否是「容器型」组件
24+
25+
`@type {boolean}`
26+
27+
### isMinimalRenderUnit
28+
是否是最小渲染单元
29+
30+
当组件需要重新渲染时:
31+
- 若为最小渲染单元,则只渲染当前组件,
32+
- 若不为最小渲染单元,则寻找到上层最近的最小渲染单元进行重新渲染,直至根节点。
33+
34+
`@type {boolean}`
35+
36+
### isModal
37+
38+
是否为「模态框」组件
39+
40+
`@type {boolean}`
41+
42+
### configure
43+
44+
获取用于设置面板显示用的配置
45+
46+
`@type {IPublicTypeFieldConfig[]}`
47+
48+
相关类型:[IPublicTypeFieldConfig](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/field-config.ts)
49+
50+
### title
51+
52+
标题
53+
54+
`@type {string | IPublicTypeI18nData | ReactElement}`
55+
56+
相关类型:[IPublicTypeI18nData](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/i18n-data.ts)
57+
58+
### icon
59+
60+
图标
61+
62+
`@type {IPublicTypeIconType}`
63+
64+
相关类型:[IPublicTypeIconType](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/icon-type.ts)
65+
66+
### npm
67+
68+
组件 npm 信息
69+
70+
`@type {IPublicTypeNpmInfo}`
71+
72+
相关类型:[IPublicTypeNpmInfo](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/npm-info.ts)
73+
74+
### availableActions
75+
76+
获取元数据
77+
78+
`@type {IPublicTypeTransformedComponentMetadata}`
79+
80+
相关类型:[IPublicTypeTransformedComponentMetadata](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/transformed-component-metadata.ts)
81+
82+
### advanced
83+
84+
组件元数据中高级配置部分
85+
86+
`@type {IPublicTypeAdvanced}`
87+
88+
相关类型:[IPublicTypeAdvanced](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/advanced.ts)
89+
90+
## 方法
91+
92+
### setNpm
93+
94+
设置 npm 信息
95+
96+
```typescript
97+
/**
98+
* 设置 npm 信息
99+
* set method for npm inforamtion
100+
* @param npm
101+
*/
102+
setNpm(npm: IPublicTypeNpmInfo): void;
103+
```
104+
105+
相关类型:[IPublicTypeNpmInfo](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/npm-info.ts)
106+
107+
### getMetadata
108+
109+
获取元数据
110+
111+
```typescript
112+
/**
113+
* 获取元数据
114+
* get component metadata
115+
*/
116+
getMetadata(): IPublicTypeTransformedComponentMetadata;
117+
```
118+
119+
相关类型:[IPublicTypeTransformedComponentMetadata](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/transformed-component-metadata.ts)
120+
121+
### checkNestingUp
122+
123+
检测当前对应节点是否可被放置在父节点中
124+
125+
```typescript
126+
/**
127+
* 检测当前对应节点是否可被放置在父节点中
128+
* check if the current node could be placed in parent node
129+
* @param my 当前节点
130+
* @param parent 父节点
131+
*/
132+
checkNestingUp(my: IPublicModelNode | IPublicTypeNodeData, parent: any): boolean;
133+
```
134+
135+
相关类型:
136+
- [IPublicModelNode](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/node.ts)
137+
- [IPublicTypeNodeData](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/node-data.ts)
138+
139+
140+
### checkNestingDown
141+
142+
检测目标节点是否可被放置在父节点中
143+
144+
```typescript
145+
/**
146+
* 检测目标节点是否可被放置在父节点中
147+
* check if the target node(s) could be placed in current node
148+
* @param my 当前节点
149+
* @param parent 父节点
150+
*/
151+
checkNestingDown(
152+
my: IPublicModelNode | IPublicTypeNodeData,
153+
target: IPublicTypeNodeSchema | IPublicModelNode | IPublicTypeNodeSchema[],
154+
): boolean;
155+
```
156+
157+
相关类型:
158+
- [IPublicModelNode](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/node.ts)
159+
- [IPublicTypeNodeData](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/node-data.ts)
160+
- [IPublicTypeNodeSchema](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/node-schema.ts)
161+
162+
163+
### refreshMetadata
164+
165+
刷新元数据,会触发元数据的重新解析和刷新
166+
167+
```typescript
168+
/**
169+
* 刷新元数据,会触发元数据的重新解析和刷新
170+
* refresh metadata
171+
*/
172+
refreshMetadata(): void;
173+
```

docs/docs/api/model/resource.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sidebar_position: 13
44
---
55

66
> **[@experimental](./#experimental)**<br/>
7-
> **@types** [IPublicModelWindow](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/resource.ts)<br/>
7+
> **@types** [IPublicModelResource](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/resource.ts)<br/>
88
> **@since** v1.1.0
99
1010
## 属性
@@ -43,4 +43,4 @@ sidebar_position: 13
4343

4444
资源配置信息
4545

46-
`@type {Object}`
46+
`@type {Object}`

packages/designer/src/component-meta.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class ComponentMeta implements IComponentMeta {
110110

111111
private _transformedMetadata?: IPublicTypeTransformedComponentMetadata;
112112

113-
get configure() {
113+
get configure(): IPublicTypeFieldConfig[] {
114114
const config = this._transformedMetadata?.configure;
115115
return config?.combined || config?.props || [];
116116
}
@@ -272,8 +272,11 @@ export class ComponentMeta implements IComponentMeta {
272272
this.parseMetadata(this.getMetadata());
273273
}
274274

275-
private transformMetadata(metadta: IPublicTypeComponentMetadata): IPublicTypeTransformedComponentMetadata {
276-
const result = this.designer.componentActions.getRegisteredMetadataTransducers().reduce((prevMetadata, current) => {
275+
private transformMetadata(
276+
metadta: IPublicTypeComponentMetadata,
277+
): IPublicTypeTransformedComponentMetadata {
278+
const registeredTransducers = this.designer.componentActions.getRegisteredMetadataTransducers();
279+
const result = registeredTransducers.reduce((prevMetadata, current) => {
277280
return current(prevMetadata);
278281
}, preprocessMetadata(metadta));
279282

packages/designer/src/designer/designer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
IPublicTypePropsTransducer,
1313
IShellModelFactory,
1414
IPublicModelDragObject,
15-
IPublicModelScrollable,
15+
IPublicTypeScrollable,
1616
IPublicModelScroller,
1717
IPublicTypeLocationData,
1818
IPublicEnumTransformStage,
@@ -70,7 +70,7 @@ export interface IDesigner {
7070

7171
get editor(): IPublicModelEditor;
7272

73-
createScroller(scrollable: IPublicModelScrollable): IPublicModelScroller;
73+
createScroller(scrollable: IPublicTypeScrollable): IPublicModelScroller;
7474

7575
/**
7676
* 创建插入位置,考虑放到 dragon 中
@@ -302,7 +302,7 @@ export class Designer implements IDesigner {
302302
this._dropLocation = undefined;
303303
}
304304

305-
createScroller(scrollable: IPublicModelScrollable): IPublicModelScroller {
305+
createScroller(scrollable: IPublicTypeScrollable): IPublicModelScroller {
306306
return new Scroller(scrollable);
307307
}
308308

packages/designer/src/designer/scroller.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { isElement } from '@alilc/lowcode-utils';
2-
import { IPublicModelScrollTarget, IPublicModelScrollable, IPublicModelScroller } from '@alilc/lowcode-types';
2+
import { IPublicModelScrollTarget, IPublicTypeScrollable, IPublicModelScroller } from '@alilc/lowcode-types';
33

44
export interface IScrollTarget extends IPublicModelScrollTarget {
55
}
@@ -13,6 +13,14 @@ export class ScrollTarget implements IScrollTarget {
1313
return 'scrollY' in this.target ? this.target.scrollY : this.target.scrollTop;
1414
}
1515

16+
private doc?: HTMLElement;
17+
18+
constructor(private target: Window | Element) {
19+
if (isWindow(target)) {
20+
this.doc = target.document.documentElement;
21+
}
22+
}
23+
1624
scrollTo(options: { left?: number; top?: number }) {
1725
this.target.scrollTo(options);
1826
}
@@ -28,14 +36,6 @@ export class ScrollTarget implements IScrollTarget {
2836
get scrollWidth(): number {
2937
return ((this.doc || this.target) as any).scrollWidth;
3038
}
31-
32-
private doc?: HTMLElement;
33-
34-
constructor(private target: Window | Element) {
35-
if (isWindow(target)) {
36-
this.doc = target.document.documentElement;
37-
}
38-
}
3939
}
4040

4141
function isWindow(obj: any): obj is Window {
@@ -53,9 +53,9 @@ export interface IScroller extends IPublicModelScroller {
5353
}
5454
export class Scroller implements IScroller {
5555
private pid: number | undefined;
56-
scrollable: IPublicModelScrollable;
56+
scrollable: IPublicTypeScrollable;
5757

58-
constructor(scrollable: IPublicModelScrollable) {
58+
constructor(scrollable: IPublicTypeScrollable) {
5959
this.scrollable = scrollable;
6060
}
6161

packages/designer/src/simulator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ComponentType } from 'react';
2-
import { IPublicTypeComponentMetadata, IPublicTypeNodeSchema, IPublicModelScrollable, IPublicTypeComponentInstance, IPublicModelSensor, IPublicTypeNodeInstance } from '@alilc/lowcode-types';
2+
import { IPublicTypeComponentMetadata, IPublicTypeNodeSchema, IPublicTypeScrollable, IPublicTypeComponentInstance, IPublicModelSensor, IPublicTypeNodeInstance } from '@alilc/lowcode-types';
33
import { Point, ScrollTarget, ILocateEvent } from './designer';
44
import { BuiltinSimulatorRenderer } from './builtin-simulator/renderer';
55
import { Node, INode } from './document';
@@ -8,7 +8,7 @@ export type AutoFit = '100%';
88
// eslint-disable-next-line no-redeclare
99
export const AutoFit = '100%';
1010

11-
export interface IScrollable extends IPublicModelScrollable {
11+
export interface IScrollable extends IPublicTypeScrollable {
1212
}
1313
export interface IViewport extends IScrollable {
1414

packages/plugin-outline-pane/src/controllers/pane-controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from '@alilc/lowcode-utils';
99
import {
1010
IPublicModelDragObject,
11-
IPublicModelScrollable,
11+
IPublicTypeScrollable,
1212
IPublicModelSensor,
1313
IPublicTypeLocationChildrenDetail,
1414
IPublicTypeLocationDetailType,
@@ -24,7 +24,7 @@ import { IndentTrack } from '../helper/indent-track';
2424
import DwellTimer from '../helper/dwell-timer';
2525
import { ITreeBoard, TreeMaster } from './tree-master';
2626

27-
export class PaneController implements IPublicModelSensor, ITreeBoard, IPublicModelScrollable {
27+
export class PaneController implements IPublicModelSensor, ITreeBoard, IPublicTypeScrollable {
2828
private pluginContext: IPublicModelPluginContext;
2929

3030
private treeMaster?: TreeMaster;

packages/shell/src/api/canvas.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
IPublicApiCanvas,
33
IPublicModelDropLocation,
44
IPublicModelScrollTarget,
5-
IPublicModelScrollable,
5+
IPublicTypeScrollable,
66
IPublicModelScroller,
77
IPublicTypeLocationData,
88
IPublicModelEditor,
@@ -58,7 +58,7 @@ export class Canvas implements IPublicApiCanvas {
5858
return new InnerScrollTarget(shell);
5959
}
6060

61-
createScroller(scrollable: IPublicModelScrollable): IPublicModelScroller {
61+
createScroller(scrollable: IPublicTypeScrollable): IPublicModelScroller {
6262
return this[designerSymbol].createScroller(scrollable);
6363
}
6464

@@ -78,4 +78,4 @@ export class Canvas implements IPublicApiCanvas {
7878
get dropLocation() {
7979
return ShellDropLocation.create((this[designerSymbol] as any).dropLocation || null);
8080
}
81-
}
81+
}

packages/shell/src/model/component-meta.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
IComponentMeta as InnerComponentMeta,
33
INode,
44
} from '@alilc/lowcode-designer';
5-
import { IPublicTypeNodeData, IPublicTypeNodeSchema, IPublicModelComponentMeta, IPublicTypeI18nData, IPublicTypeIconType, IPublicTypeNpmInfo, IPublicTypeTransformedComponentMetadata, IPublicModelNode, IPublicTypeAdvanced } from '@alilc/lowcode-types';
5+
import { IPublicTypeNodeData, IPublicTypeNodeSchema, IPublicModelComponentMeta, IPublicTypeI18nData, IPublicTypeIconType, IPublicTypeNpmInfo, IPublicTypeTransformedComponentMetadata, IPublicModelNode, IPublicTypeAdvanced, IPublicTypeFieldConfig } from '@alilc/lowcode-types';
66
import { componentMetaSymbol, nodeSymbol } from '../symbols';
77
import { ReactElement } from 'react';
88

@@ -56,7 +56,7 @@ export class ComponentMeta implements IPublicModelComponentMeta {
5656
/**
5757
* 元数据配置
5858
*/
59-
get configure(): any {
59+
get configure(): IPublicTypeFieldConfig[] {
6060
return this[componentMetaSymbol].configure;
6161
}
6262

0 commit comments

Comments
 (0)