Skip to content

Commit 381ebbb

Browse files
committed
feat: add commonUI API
1 parent 173978f commit 381ebbb

File tree

15 files changed

+281
-12
lines changed

15 files changed

+281
-12
lines changed

docs/docs/api/commonUI.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
title: commonUI - UI 组件库
3+
sidebar_position: 11
4+
---
5+
6+
## 简介
7+
CommonUI API 是一个专为低代码引擎设计的组件 UI 库,使用它开发的插件,可以保证在不同项目和主题切换中能够保持一致性和兼容性。
8+
9+
## 组件列表
10+
11+
### Tip
12+
13+
提示组件
14+
15+
| 参数 | 说明 | 类型 | 默认值 |
16+
|-----------|--------------|---------------------------------------|--------|
17+
| className | className | string (optional) | |
18+
| children | tip 的内容 | IPublicTypeI18nData \| ReactNode | |
19+
| direction | tip 的方向 | 'top' \| 'bottom' \| 'left' \| 'right' | |
20+
21+
22+
### Title
23+
24+
标题组件
25+
26+
| 参数 | 说明 | 类型 | 默认值 |
27+
|-----------|------------|-----------------------------|--------|
28+
| title | 标题内容 | IPublicTypeTitleContent | |
29+
| className | className | string (optional) | |
30+
| onClick | 点击事件 | () => void (optional) | |
31+
32+
### Balloon
33+
详细文档: [Balloon Documentation](https://fusion.design/pc/component/balloon)
34+
35+
### Breadcrumb
36+
详细文档: [Breadcrumb Documentation](https://fusion.design/pc/component/breadcrumb)
37+
38+
### Button
39+
详细文档: [Button Documentation](https://fusion.design/pc/component/button)
40+
41+
### Card
42+
详细文档: [Card Documentation](https://fusion.design/pc/component/card)
43+
44+
### Checkbox
45+
详细文档: [Checkbox Documentation](https://fusion.design/pc/component/checkbox)
46+
47+
### DatePicker
48+
详细文档: [DatePicker Documentation](https://fusion.design/pc/component/datepicker)
49+
50+
### Dialog
51+
详细文档: [Dialog Documentation](https://fusion.design/pc/component/dialog)
52+
53+
### Dropdown
54+
详细文档: [Dropdown Documentation](https://fusion.design/pc/component/dropdown)
55+
56+
### Form
57+
详细文档: [Form Documentation](https://fusion.design/pc/component/form)
58+
59+
### Icon
60+
详细文档: [Icon Documentation](https://fusion.design/pc/component/icon)
61+
62+
引擎默认主题支持的 icon 列表:https://fusion.design/64063/component/icon?themeid=20133
63+
64+
65+
### Input
66+
详细文档: [Input Documentation](https://fusion.design/pc/component/input)
67+
68+
### Loading
69+
详细文档: [Loading Documentation](https://fusion.design/pc/component/loading)
70+
71+
### Message
72+
详细文档: [Message Documentation](https://fusion.design/pc/component/message)
73+
74+
### Overlay
75+
详细文档: [Overlay Documentation](https://fusion.design/pc/component/overlay)
76+
77+
### Pagination
78+
详细文档: [Pagination Documentation](https://fusion.design/pc/component/pagination)
79+
80+
### Radio
81+
详细文档: [Radio Documentation](https://fusion.design/pc/component/radio)
82+
83+
### Search
84+
详细文档: [Search Documentation](https://fusion.design/pc/component/search)
85+
86+
### Select
87+
详细文档: [Select Documentation](https://fusion.design/pc/component/select)
88+
89+
### SplitButton
90+
详细文档: [SplitButton Documentation](https://fusion.design/pc/component/splitbutton)
91+
92+
### Step
93+
详细文档: [Step Documentation](https://fusion.design/pc/component/step)
94+
95+
### Switch
96+
详细文档: [Switch Documentation](https://fusion.design/pc/component/switch)
97+
98+
### Tab
99+
详细文档: [Tab Documentation](https://fusion.design/pc/component/tab)
100+
101+
### Table
102+
详细文档: [Table Documentation](https://fusion.design/pc/component/table)
103+
104+
### Tree
105+
详细文档: [Tree Documentation](https://fusion.design/pc/component/tree)
106+
107+
### TreeSelect
108+
详细文档: [TreeSelect Documentation](https://fusion.design/pc/component/treeselect)
109+
110+
### Upload
111+
详细文档: [Upload Documentation](https://fusion.design/pc/component/upload)
112+
113+
### Divider
114+
详细文档: [Divider Documentation](https://fusion.design/pc/component/divider)
115+
116+
## 说明
117+
118+
如果需要其他组件,可以提issue给我们

packages/designer/src/component-meta.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,17 @@ export function buildFilter(rule?: string | string[] | RegExp | IPublicTypeNesti
4848
return rule;
4949
}
5050
if (isRegExp(rule)) {
51-
return (testNode: Node | IPublicTypeNodeSchema) => rule.test(testNode.componentName);
51+
return (testNode: Node | IPublicTypeNodeSchema) => {
52+
return rule.test(testNode.componentName);
53+
};
5254
}
5355
const list = ensureAList(rule);
5456
if (!list) {
5557
return null;
5658
}
57-
return (testNode: Node | IPublicTypeNodeSchema) => list.includes(testNode.componentName);
59+
return (testNode: Node | IPublicTypeNodeSchema) => {
60+
return list.includes(testNode.componentName);
61+
};
5862
}
5963

6064
export interface IComponentMeta extends IPublicModelComponentMeta<INode> {

packages/designer/src/plugin/plugin-context.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
IPublicApiWorkspace,
2020
IPublicEnumPluginRegisterLevel,
2121
IPublicModelWindow,
22+
IPublicApiCommonUI,
2223
} from '@alilc/lowcode-types';
2324
import {
2425
IPluginContextOptions,
@@ -45,6 +46,8 @@ export default class PluginContext implements
4546
workspace: IPublicApiWorkspace;
4647
registerLevel: IPublicEnumPluginRegisterLevel;
4748
editorWindow: IPublicModelWindow;
49+
commonUI: IPublicApiCommonUI;
50+
isPluginRegisteredInWorkspace: false;
4851

4952
constructor(
5053
options: IPluginContextOptions,

packages/designer/src/plugin/plugin-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
IPublicTypePluginRegisterOptions,
1919
IPublicModelWindow,
2020
IPublicEnumPluginRegisterLevel,
21+
IPublicApiCommonUI,
2122
} from '@alilc/lowcode-types';
2223
import PluginContext from './plugin-context';
2324

@@ -61,6 +62,7 @@ export interface ILowCodePluginContextPrivate {
6162
set editorWindow(window: IPublicModelWindow);
6263
set registerLevel(level: IPublicEnumPluginRegisterLevel);
6364
set isPluginRegisteredInWorkspace(flag: boolean);
65+
set commonUI(commonUI: IPublicApiCommonUI);
6466
}
6567
export interface ILowCodePluginContextApiAssembler {
6668
assembleApis(

packages/editor-core/src/widgets/title/index.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, isValidElement, ReactNode } from 'react';
22
import classNames from 'classnames';
33
import { createIcon, isI18nData, isTitleConfig } from '@alilc/lowcode-utils';
4-
import { IPublicTypeTitleContent, IPublicTypeI18nData, IPublicTypeTitleConfig } from '@alilc/lowcode-types';
4+
import { IPublicTypeI18nData, IPublicTypeTitleConfig, IPublicTypeTitleProps } from '@alilc/lowcode-types';
55
import { intl } from '../../intl';
66
import { Tip } from '../tip';
77
import './title.less';
@@ -36,13 +36,7 @@ import './title.less';
3636
return fragments;
3737
}
3838

39-
export class Title extends Component<{
40-
title: IPublicTypeTitleContent;
41-
className?: string;
42-
onClick?: () => void;
43-
match?: boolean;
44-
keywords?: string;
45-
}> {
39+
export class Title extends Component<IPublicTypeTitleProps> {
4640
constructor(props: any) {
4741
super(props);
4842
this.handleClick = this.handleClick.bind(this);

packages/engine/src/engine-core.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import {
5151
Canvas,
5252
Workspace,
5353
Config,
54+
CommonUI,
5455
} from '@alilc/lowcode-shell';
5556
import { isPlainObject } from '@alilc/lowcode-utils';
5657
import './modules/live-editing';
@@ -111,10 +112,12 @@ const innerSetters = new InnerSetters();
111112
const setters = new Setters(innerSetters);
112113

113114
const material = new Material(editor);
115+
const commonUI = new CommonUI();
114116
editor.set('project', project);
115117
editor.set('setters' as any, setters);
116118
editor.set('material', material);
117119
editor.set('innerHotkey', innerHotkey);
120+
editor.set('commonUI' as any, commonUI);
118121
const config = new Config(engineConfig);
119122
const event = new Event(commonEvent, { prefix: 'common' });
120123
const logger = new Logger({ level: 'warn', bizName: 'common' });
@@ -138,6 +141,7 @@ const pluginContextApiAssembler: ILowCodePluginContextApiAssembler = {
138141
context.plugins = plugins;
139142
context.logger = new Logger({ level: 'warn', bizName: `plugin:${pluginName}` });
140143
context.workspace = workspace;
144+
context.commonUI = commonUI;
141145
context.registerLevel = IPublicEnumPluginRegisterLevel.Default;
142146
context.isPluginRegisteredInWorkspace = false;
143147
},
@@ -161,6 +165,7 @@ export {
161165
common,
162166
workspace,
163167
canvas,
168+
commonUI,
164169
};
165170
// declare this is open-source version
166171
export const isOpenSource = true;

packages/shell/src/api/commonUI.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { IPublicApiCommonUI } from '@alilc/lowcode-types';
2+
import {
3+
Tip as InnerTip,
4+
Title as InnerTitle,
5+
} from '@alilc/lowcode-editor-core';
6+
import { Balloon, Breadcrumb, Button, Card, Checkbox, DatePicker, Dialog, Dropdown, Form, Icon, Input, Loading, Message, Overlay, Pagination, Radio, Search, Select, SplitButton, Step, Switch, Tab, Table, Tree, TreeSelect, Upload, Divider } from '@alifd/next';
7+
8+
export class CommonUI implements IPublicApiCommonUI {
9+
Balloon = Balloon;
10+
Breadcrumb = Breadcrumb;
11+
Button = Button;
12+
Card = Card;
13+
Checkbox = Checkbox;
14+
DatePicker = DatePicker;
15+
Dialog = Dialog;
16+
Dropdown = Dropdown;
17+
Form = Form;
18+
Icon = Icon;
19+
Input = Input;
20+
Loading = Loading;
21+
Message = Message;
22+
Overlay = Overlay;
23+
Pagination = Pagination;
24+
Radio = Radio;
25+
Search = Search;
26+
Select = Select;
27+
SplitButton = SplitButton;
28+
Step = Step;
29+
Switch = Switch;
30+
Tab = Tab;
31+
Table = Table;
32+
Tree = Tree;
33+
TreeSelect = TreeSelect;
34+
Upload = Upload;
35+
Divider = Divider;
36+
37+
get Tip() {
38+
return InnerTip;
39+
}
40+
get Title() {
41+
return InnerTitle;
42+
}
43+
}

packages/shell/src/api/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ export * from './simulator-host';
1010
export * from './skeleton';
1111
export * from './canvas';
1212
export * from './workspace';
13-
export * from './config';
13+
export * from './config';
14+
export * from './commonUI';

packages/shell/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
Workspace,
2929
SimulatorHost,
3030
Config,
31+
CommonUI,
3132
} from './api';
3233

3334
export * from './symbols';
@@ -68,4 +69,5 @@ export {
6869
Config,
6970
SettingField,
7071
SkeletonItem,
72+
CommonUI,
7173
};
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { IPublicTypeTitleContent } from '../type';
2+
import { Balloon, Breadcrumb, Button, Card, Checkbox, DatePicker, Dialog, Dropdown, Form, Icon, Input, Loading, Message, Overlay, Pagination, Radio, Search, Select, SplitButton, Step, Switch, Tab, Table, Tree, TreeSelect, Upload, Divider } from '@alifd/next';
3+
4+
export interface IPublicApiCommonUI {
5+
Balloon: typeof Balloon;
6+
Breadcrumb: typeof Breadcrumb;
7+
Button: typeof Button;
8+
Card: typeof Card;
9+
Checkbox: typeof Checkbox;
10+
DatePicker: typeof DatePicker;
11+
Dialog: typeof Dialog;
12+
Dropdown: typeof Dropdown;
13+
Form: typeof Form;
14+
Icon: typeof Icon;
15+
Input: typeof Input;
16+
Loading: typeof Loading;
17+
Message: typeof Message;
18+
Overlay: typeof Overlay;
19+
Pagination: typeof Pagination;
20+
Radio: typeof Radio;
21+
Search: typeof Search;
22+
Select: typeof Select;
23+
SplitButton: typeof SplitButton;
24+
Step: typeof Step;
25+
Switch: typeof Switch;
26+
Tab: typeof Tab;
27+
Table: typeof Table;
28+
Tree: typeof Tree;
29+
TreeSelect: typeof TreeSelect;
30+
Upload: typeof Upload;
31+
Divider: typeof Divider;
32+
33+
/**
34+
* Title 组件
35+
* @experimental unstable API, pay extra caution when trying to use this
36+
*/
37+
get Tip(): React.ComponentClass<{}>;
38+
39+
/**
40+
* Tip 组件
41+
* @experimental unstable API, pay extra caution when trying to use this
42+
*/
43+
get Title(): React.ComponentClass<{
44+
title: IPublicTypeTitleContent | undefined;
45+
match?: boolean;
46+
keywords?: string | null;
47+
}>;
48+
}

0 commit comments

Comments
 (0)