GeezerVison is showing github.com — feat: add commonUI API · cdlinsen/lowcode-engine@be0456f
File treeExpand file treeCollapse file tree Open diff view settings editor-core/src/widgets/title
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +118Lines changed: 118 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 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给我们 |
Collapse file Copy file name to clipboardExpand all lines: packages/designer/src/component-meta.ts +6-2Lines changed: 6 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -48,13 +48,17 @@ export function buildFilter(rule?: string | string[] | RegExp | IPublicTypeNesti | 48 | 48 | return rule; | 49 | 49 | } | 50 | 50 | if (isRegExp(rule)) { | 51 | | - return (testNode: Node | IPublicTypeNodeSchema) => rule.test(testNode.componentName); | | 51 | + return (testNode: Node | IPublicTypeNodeSchema) => { | | 52 | + return rule.test(testNode.componentName); | | 53 | + }; | 52 | 54 | } | 53 | 55 | const list = ensureAList(rule); | 54 | 56 | if (!list) { | 55 | 57 | return null; | 56 | 58 | } | 57 | | - return (testNode: Node | IPublicTypeNodeSchema) => list.includes(testNode.componentName); | | 59 | + return (testNode: Node | IPublicTypeNodeSchema) => { | | 60 | + return list.includes(testNode.componentName); | | 61 | + }; | 58 | 62 | } | 59 | 63 |
| 60 | 64 | export interface IComponentMeta extends IPublicModelComponentMeta<INode> { | |
Collapse file Copy file name to clipboardExpand all lines: packages/designer/src/plugin/plugin-context.ts +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -19,6 +19,7 @@ import { | 19 | 19 | IPublicApiWorkspace, | 20 | 20 | IPublicEnumPluginRegisterLevel, | 21 | 21 | IPublicModelWindow, | | 22 | + IPublicApiCommonUI, | 22 | 23 | } from '@alilc/lowcode-types'; | 23 | 24 | import { | 24 | 25 | IPluginContextOptions, | @@ -45,6 +46,8 @@ export default class PluginContext implements | 45 | 46 | workspace: IPublicApiWorkspace; | 46 | 47 | registerLevel: IPublicEnumPluginRegisterLevel; | 47 | 48 | editorWindow: IPublicModelWindow; | | 49 | + commonUI: IPublicApiCommonUI; | | 50 | + isPluginRegisteredInWorkspace: false; | 48 | 51 |
| 49 | 52 | constructor( | 50 | 53 | options: IPluginContextOptions, | |
Collapse file Copy file name to clipboardExpand all lines: packages/designer/src/plugin/plugin-types.ts +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -18,6 +18,7 @@ import { | 18 | 18 | IPublicTypePluginRegisterOptions, | 19 | 19 | IPublicModelWindow, | 20 | 20 | IPublicEnumPluginRegisterLevel, | | 21 | + IPublicApiCommonUI, | 21 | 22 | } from '@alilc/lowcode-types'; | 22 | 23 | import PluginContext from './plugin-context'; | 23 | 24 |
| @@ -61,6 +62,7 @@ export interface ILowCodePluginContextPrivate { | 61 | 62 | set editorWindow(window: IPublicModelWindow); | 62 | 63 | set registerLevel(level: IPublicEnumPluginRegisterLevel); | 63 | 64 | set isPluginRegisteredInWorkspace(flag: boolean); | | 65 | + set commonUI(commonUI: IPublicApiCommonUI); | 64 | 66 | } | 65 | 67 | export interface ILowCodePluginContextApiAssembler { | 66 | 68 | assembleApis( | |
Collapse file Copy file name to clipboardExpand all lines: packages/editor-core/src/widgets/title/index.tsx +2-8Lines changed: 2 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { Component, isValidElement, ReactNode } from 'react'; | 2 | 2 | import classNames from 'classnames'; | 3 | 3 | 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'; | 5 | 5 | import { intl } from '../../intl'; | 6 | 6 | import { Tip } from '../tip'; | 7 | 7 | import './title.less'; | @@ -36,13 +36,7 @@ import './title.less'; | 36 | 36 | return fragments; | 37 | 37 | } | 38 | 38 |
| 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> { | 46 | 40 | constructor(props: any) { | 47 | 41 | super(props); | 48 | 42 | this.handleClick = this.handleClick.bind(this); | |
Collapse file Copy file name to clipboardExpand all lines: packages/engine/src/engine-core.ts +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -51,6 +51,7 @@ import { | 51 | 51 | Canvas, | 52 | 52 | Workspace, | 53 | 53 | Config, | | 54 | + CommonUI, | 54 | 55 | } from '@alilc/lowcode-shell'; | 55 | 56 | import { isPlainObject } from '@alilc/lowcode-utils'; | 56 | 57 | import './modules/live-editing'; | @@ -111,10 +112,12 @@ const innerSetters = new InnerSetters(); | 111 | 112 | const setters = new Setters(innerSetters); | 112 | 113 |
| 113 | 114 | const material = new Material(editor); | | 115 | +const commonUI = new CommonUI(); | 114 | 116 | editor.set('project', project); | 115 | 117 | editor.set('setters' as any, setters); | 116 | 118 | editor.set('material', material); | 117 | 119 | editor.set('innerHotkey', innerHotkey); | | 120 | +editor.set('commonUI' as any, commonUI); | 118 | 121 | const config = new Config(engineConfig); | 119 | 122 | const event = new Event(commonEvent, { prefix: 'common' }); | 120 | 123 | const logger = new Logger({ level: 'warn', bizName: 'common' }); | @@ -138,6 +141,7 @@ const pluginContextApiAssembler: ILowCodePluginContextApiAssembler = { | 138 | 141 | context.plugins = plugins; | 139 | 142 | context.logger = new Logger({ level: 'warn', bizName: `plugin:${pluginName}` }); | 140 | 143 | context.workspace = workspace; | | 144 | + context.commonUI = commonUI; | 141 | 145 | context.registerLevel = IPublicEnumPluginRegisterLevel.Default; | 142 | 146 | context.isPluginRegisteredInWorkspace = false; | 143 | 147 | }, | @@ -161,6 +165,7 @@ export { | 161 | 165 | common, | 162 | 166 | workspace, | 163 | 167 | canvas, | | 168 | + commonUI, | 164 | 169 | }; | 165 | 170 | // declare this is open-source version | 166 | 171 | export const isOpenSource = true; | |
Collapse file Copy file name to clipboard +43Lines changed: 43 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 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 | +} |
Collapse file Copy file name to clipboardExpand all lines: packages/shell/src/api/index.ts +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -10,4 +10,5 @@ export * from './simulator-host'; | 10 | 10 | export * from './skeleton'; | 11 | 11 | export * from './canvas'; | 12 | 12 | export * from './workspace'; | 13 | | -export * from './config'; | | 13 | +export * from './config'; | | 14 | +export * from './commonUI'; |
Collapse file Copy file name to clipboardExpand all lines: packages/shell/src/index.ts +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -28,6 +28,7 @@ import { | 28 | 28 | Workspace, | 29 | 29 | SimulatorHost, | 30 | 30 | Config, | | 31 | + CommonUI, | 31 | 32 | } from './api'; | 32 | 33 |
| 33 | 34 | export * from './symbols'; | @@ -68,4 +69,5 @@ export { | 68 | 69 | Config, | 69 | 70 | SettingField, | 70 | 71 | SkeletonItem, | | 72 | + CommonUI, | 71 | 73 | }; |
Collapse file Copy file name to clipboard +48Lines changed: 48 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 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 | +} |
|