aldehyde 0.2.270 → 0.2.271
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/controls/entry-control.d.ts.map +1 -1
- package/lib/controls/entry-control.js +1 -1
- package/lib/controls/entry-control.js.map +1 -1
- package/lib/controls/select/index.d.ts.map +1 -1
- package/lib/controls/select/index.js.map +1 -1
- package/lib/controls/upload/index.d.ts.map +1 -1
- package/lib/controls/upload/index.js.map +1 -1
- package/lib/controls/upload/mult-file-upload.d.ts.map +1 -1
- package/lib/controls/upload/mult-file-upload.js +41 -23
- package/lib/controls/upload/mult-file-upload.js.map +1 -1
- package/lib/detail/edit/fields-edit-card.js +1 -1
- package/lib/detail/edit/fields-edit-card.js.map +1 -1
- package/lib/detail/edit/row-edit-card.d.ts.map +1 -1
- package/lib/detail/edit/row-edit-card.js +1 -1
- package/lib/detail/edit/row-edit-card.js.map +1 -1
- package/lib/detail/edit/row-editor.js +1 -1
- package/lib/detail/edit/row-editor.js.map +1 -1
- package/lib/form/dtmpl-form.d.ts.map +1 -1
- package/lib/form/dtmpl-form.js +4 -4
- package/lib/form/dtmpl-form.js.map +1 -1
- package/lib/form/field-group-form.d.ts +1 -0
- package/lib/form/field-group-form.d.ts.map +1 -1
- package/lib/form/field-group-form.js +2 -1
- package/lib/form/field-group-form.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/layout/menu/l2menu-message-bar.js +5 -5
- package/lib/layout/menu/l2menu-message-bar.js.map +1 -1
- package/lib/layout2/page.d.ts.map +1 -1
- package/lib/layout2/page.js +11 -3
- package/lib/layout2/page.js.map +1 -1
- package/lib/lowcode-components/bar-chart/index.d.ts +36 -0
- package/lib/lowcode-components/bar-chart/index.d.ts.map +1 -0
- package/lib/lowcode-components/bar-chart/index.js +85 -0
- package/lib/lowcode-components/bar-chart/index.js.map +1 -0
- package/lib/lowcode-components/base-color-block/index.d.ts +17 -0
- package/lib/lowcode-components/base-color-block/index.d.ts.map +1 -0
- package/lib/lowcode-components/base-color-block/index.js +10 -0
- package/lib/lowcode-components/base-color-block/index.js.map +1 -0
- package/lib/lowcode-components/base-image/index.d.ts +14 -0
- package/lib/lowcode-components/base-image/index.d.ts.map +1 -0
- package/lib/lowcode-components/base-image/index.js +23 -0
- package/lib/lowcode-components/base-image/index.js.map +1 -0
- package/lib/lowcode-components/base-text/index.d.ts +31 -0
- package/lib/lowcode-components/base-text/index.d.ts.map +1 -0
- package/lib/lowcode-components/base-text/index.js +43 -0
- package/lib/lowcode-components/base-text/index.js.map +1 -0
- package/lib/lowcode-components/column-chart/index.d.ts +36 -0
- package/lib/lowcode-components/column-chart/index.d.ts.map +1 -0
- package/lib/lowcode-components/column-chart/index.js +85 -0
- package/lib/lowcode-components/column-chart/index.js.map +1 -0
- package/lib/lowcode-components/date-time/index.d.ts +23 -0
- package/lib/lowcode-components/date-time/index.d.ts.map +1 -0
- package/lib/lowcode-components/date-time/index.js +34 -0
- package/lib/lowcode-components/date-time/index.js.map +1 -0
- package/lib/lowcode-components/four-angle-glow-border/index.d.ts +17 -0
- package/lib/lowcode-components/four-angle-glow-border/index.d.ts.map +1 -0
- package/lib/lowcode-components/four-angle-glow-border/index.js +28 -0
- package/lib/lowcode-components/four-angle-glow-border/index.js.map +1 -0
- package/lib/lowcode-components/index.d.ts +23 -0
- package/lib/lowcode-components/index.d.ts.map +1 -0
- package/lib/lowcode-components/index.js +21 -0
- package/lib/lowcode-components/index.js.map +1 -0
- package/lib/lowcode-components/line-chart/index.d.ts +50 -0
- package/lib/lowcode-components/line-chart/index.d.ts.map +1 -0
- package/lib/lowcode-components/line-chart/index.js +94 -0
- package/lib/lowcode-components/line-chart/index.js.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/abstract-controller.d.ts +51 -0
- package/lib/lowcode-components/lowcode-view/component/abstract-controller.d.ts.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/abstract-controller.js +36 -0
- package/lib/lowcode-components/lowcode-view/component/abstract-controller.js.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/abstract-definition.d.ts +70 -0
- package/lib/lowcode-components/lowcode-view/component/abstract-definition.d.ts.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/abstract-definition.js +12 -0
- package/lib/lowcode-components/lowcode-view/component/abstract-definition.js.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/abstract-designer-controller.d.ts +28 -0
- package/lib/lowcode-components/lowcode-view/component/abstract-designer-controller.d.ts.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/abstract-designer-controller.js +60 -0
- package/lib/lowcode-components/lowcode-view/component/abstract-designer-controller.js.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/abstract-designer-loader.d.ts +15 -0
- package/lib/lowcode-components/lowcode-view/component/abstract-designer-loader.d.ts.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/abstract-designer-loader.js +31 -0
- package/lib/lowcode-components/lowcode-view/component/abstract-designer-loader.js.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/assets.d.ts +10 -0
- package/lib/lowcode-components/lowcode-view/component/assets.d.ts.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/assets.js +83 -0
- package/lib/lowcode-components/lowcode-view/component/assets.js.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/component-container.d.ts +9 -0
- package/lib/lowcode-components/lowcode-view/component/component-container.d.ts.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/component-container.js +68 -0
- package/lib/lowcode-components/lowcode-view/component/component-container.js.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/component-controller.d.ts +22 -0
- package/lib/lowcode-components/lowcode-view/component/component-controller.d.ts.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/component-controller.js +102 -0
- package/lib/lowcode-components/lowcode-view/component/component-controller.js.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/component-definition.d.ts +12 -0
- package/lib/lowcode-components/lowcode-view/component/component-definition.d.ts.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/component-definition.js +15 -0
- package/lib/lowcode-components/lowcode-view/component/component-definition.js.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/layer-builder.d.ts +22 -0
- package/lib/lowcode-components/lowcode-view/component/layer-builder.d.ts.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/layer-builder.js +83 -0
- package/lib/lowcode-components/lowcode-view/component/layer-builder.js.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/loading.d.ts +4 -0
- package/lib/lowcode-components/lowcode-view/component/loading.d.ts.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/loading.js +18 -0
- package/lib/lowcode-components/lowcode-view/component/loading.js.map +1 -0
- package/lib/lowcode-components/lowcode-view/index.d.ts +9 -0
- package/lib/lowcode-components/lowcode-view/index.d.ts.map +1 -0
- package/lib/lowcode-components/lowcode-view/index.js +89 -0
- package/lib/lowcode-components/lowcode-view/index.js.map +1 -0
- package/lib/lowcode-components/lowcode-view/interface.d.ts +139 -0
- package/lib/lowcode-components/lowcode-view/interface.d.ts.map +1 -0
- package/lib/lowcode-components/lowcode-view/interface.js +2 -0
- package/lib/lowcode-components/lowcode-view/interface.js.map +1 -0
- package/lib/lowcode-components/lowcode-view/lowcode-constant.d.ts +11 -0
- package/lib/lowcode-components/lowcode-view/lowcode-constant.d.ts.map +1 -0
- package/lib/lowcode-components/lowcode-view/lowcode-constant.js +10 -0
- package/lib/lowcode-components/lowcode-view/lowcode-constant.js.map +1 -0
- package/lib/module/dtmpl-edit-page.js +3 -2
- package/lib/module/dtmpl-edit-page.js.map +1 -1
- package/lib/module/dtmpl-view-drawer.d.ts.map +1 -1
- package/lib/module/dtmpl-view-drawer.js +2 -2
- package/lib/module/dtmpl-view-drawer.js.map +1 -1
- package/lib/routable/ltmpl-route.d.ts.map +1 -1
- package/lib/routable/ltmpl-route.js.map +1 -1
- package/lib/table/relation-table.d.ts +10 -0
- package/lib/table/relation-table.d.ts.map +1 -1
- package/lib/table/relation-table.js +126 -29
- package/lib/table/relation-table.js.map +1 -1
- package/lib/tmpl/control-type-supportor.js +1 -1
- package/lib/tmpl/control-type-supportor.js.map +1 -1
- package/lib/tmpl/hc-data-source.d.ts.map +1 -1
- package/lib/tmpl/hc-data-source.js +13 -10
- package/lib/tmpl/hc-data-source.js.map +1 -1
- package/lib/tmpl/interface.d.ts +4 -0
- package/lib/tmpl/interface.d.ts.map +1 -1
- package/lib/tmpl/interface.js.map +1 -1
- package/lib/welcome/HCWelcome.d.ts.map +1 -1
- package/lib/welcome/HCWelcome.js +1 -6
- package/lib/welcome/HCWelcome.js.map +1 -1
- package/package.json +2 -2
- package/src/aldehyde/controls/entry-control.tsx +1 -3
- package/src/aldehyde/controls/select/index.tsx +0 -1
- package/src/aldehyde/controls/upload/index.tsx +0 -1
- package/src/aldehyde/controls/upload/mult-file-upload.tsx +45 -23
- package/src/aldehyde/detail/edit/fields-edit-card.tsx +1 -1
- package/src/aldehyde/detail/edit/row-edit-card.tsx +2 -14
- package/src/aldehyde/detail/edit/row-editor.tsx +1 -1
- package/src/aldehyde/form/dtmpl-form.tsx +5 -8
- package/src/aldehyde/form/field-group-form.tsx +4 -0
- package/src/aldehyde/index.tsx +3 -0
- package/src/aldehyde/layout/menu/l2menu-message-bar.tsx +6 -6
- package/src/aldehyde/layout2/page.tsx +13 -3
- package/src/aldehyde/lowcode-components/bar-chart/index.tsx +116 -0
- package/src/aldehyde/lowcode-components/base-color-block/index.tsx +32 -0
- package/src/aldehyde/lowcode-components/base-image/index.tsx +45 -0
- package/src/aldehyde/lowcode-components/base-text/index.less +20 -0
- package/src/aldehyde/lowcode-components/base-text/index.tsx +88 -0
- package/src/aldehyde/lowcode-components/column-chart/index.tsx +116 -0
- package/src/aldehyde/lowcode-components/date-time/index.less +5 -0
- package/src/aldehyde/lowcode-components/date-time/index.tsx +65 -0
- package/src/aldehyde/lowcode-components/four-angle-glow-border/index.less +50 -0
- package/src/aldehyde/lowcode-components/four-angle-glow-border/index.tsx +53 -0
- package/src/aldehyde/lowcode-components/index.ts +36 -0
- package/src/aldehyde/lowcode-components/line-chart/index.tsx +122 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-controller.ts +64 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-definition.ts +77 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-designer-controller.ts +63 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-designer-loader.ts +34 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/assets.ts +89 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/component-container.tsx +88 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/component-controller.ts +99 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/component-definition.ts +24 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/font/DingTalk JinBuTi.ttf +0 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/font/DouyinSansBold.ttf +0 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/font/FontGlobal.css +27 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/font//344/274/230/350/256/276/346/240/207/351/242/230/351/273/221.ttf +0 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/font//345/272/236/351/227/250/346/255/243/351/201/223/346/240/207/351/242/230/344/275/223/345/205/215/350/264/271/347/211/210.ttf +0 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/layer-builder.tsx +91 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/loading.tsx +23 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/screen-fit/index.less +13 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/screen-fit/index.tsx +122 -0
- package/src/aldehyde/lowcode-components/lowcode-view/index.less +12 -0
- package/src/aldehyde/lowcode-components/lowcode-view/index.tsx +107 -0
- package/src/aldehyde/lowcode-components/lowcode-view/interface.ts +190 -0
- package/src/aldehyde/lowcode-components/lowcode-view/lowcode-constant.tsx +12 -0
- package/src/aldehyde/module/dtmpl-edit-page.tsx +3 -3
- package/src/aldehyde/module/dtmpl-view-drawer.tsx +1 -2
- package/src/aldehyde/routable/ltmpl-route.tsx +0 -1
- package/src/aldehyde/table/relation-table.tsx +155 -40
- package/src/aldehyde/tmpl/control-type-supportor.tsx +1 -1
- package/src/aldehyde/tmpl/hc-data-source.tsx +14 -11
- package/src/aldehyde/tmpl/interface.tsx +5 -1
- package/src/aldehyde/welcome/HCWelcome.js +1 -6
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface UpdateOptions {
|
|
2
|
+
reRender: boolean;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 设计器自定义组件控制器的顶级抽象接口,用于控制自定义组件的整个生命周期
|
|
7
|
+
* @param I 组件实例类型,若组件为React的class组件,则I=class的实例化对象。
|
|
8
|
+
* 若组件为React的函数式组件,则I=forwardRef钩子传递出的ref引用(当然你也可以有其他自定义的实现)
|
|
9
|
+
* 若组件为纯Js实现的组件,则I=组件实例化对象(可参考Echarts活G2创建实例后的返回值)
|
|
10
|
+
* @param C 组件配置类型,即组件的完整属性类型
|
|
11
|
+
*/
|
|
12
|
+
abstract class AbstractController<I = any, C = any> {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 组件实例引用
|
|
16
|
+
* @protected
|
|
17
|
+
*/
|
|
18
|
+
protected instance: I | null = null;
|
|
19
|
+
/**
|
|
20
|
+
* 组件配置(包括组件数据)
|
|
21
|
+
* @protected
|
|
22
|
+
*/
|
|
23
|
+
public config: C | null = null;
|
|
24
|
+
/**
|
|
25
|
+
* 组件所处容器的dom元素
|
|
26
|
+
* @protected
|
|
27
|
+
*/
|
|
28
|
+
public container: HTMLElement | null = null;
|
|
29
|
+
|
|
30
|
+
/******************生命周期******************/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 创建组件并将组件挂载到指定的容器中
|
|
34
|
+
* @param container 容器
|
|
35
|
+
* @param config 组件配置
|
|
36
|
+
*/
|
|
37
|
+
public abstract create(container: HTMLElement, config: C): Promise<void>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 更新组件配置,并触发组件重新渲染
|
|
41
|
+
* @param config 组件属性(参数)
|
|
42
|
+
* @param upOp 操作类型
|
|
43
|
+
*/
|
|
44
|
+
public abstract update(config: C, upOp?: UpdateOptions): void;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 销毁组件
|
|
48
|
+
*/
|
|
49
|
+
public destroy(): void {
|
|
50
|
+
this.instance = null;
|
|
51
|
+
this.config = null;
|
|
52
|
+
this.container = null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
/******************普通方法******************/
|
|
57
|
+
/**
|
|
58
|
+
* 获取组件配置数据
|
|
59
|
+
*/
|
|
60
|
+
public abstract getConfig(): C | null;
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default AbstractController;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import AbstractController from "./abstract-controller";
|
|
2
|
+
import React, { ComponentType } from "react";
|
|
3
|
+
import AbstractDesignerController from "./abstract-designer-controller";
|
|
4
|
+
|
|
5
|
+
export type ClazzTemplate<C> = new () => C | null;
|
|
6
|
+
|
|
7
|
+
export interface ActionInfo {
|
|
8
|
+
name: string;
|
|
9
|
+
id: string;
|
|
10
|
+
handler: (controller: AbstractDesignerController, params?: any) => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ICategorize {
|
|
14
|
+
key: string;
|
|
15
|
+
name: string;
|
|
16
|
+
icon?: ComponentType;
|
|
17
|
+
parentKey?: string;
|
|
18
|
+
iconType?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 组件基础信息
|
|
23
|
+
*/
|
|
24
|
+
export interface BaseInfoType {
|
|
25
|
+
/**
|
|
26
|
+
* 组件显示名称
|
|
27
|
+
*/
|
|
28
|
+
compName: string;
|
|
29
|
+
/**
|
|
30
|
+
* 组件标识
|
|
31
|
+
*/
|
|
32
|
+
compKey: string;
|
|
33
|
+
/**
|
|
34
|
+
* 主分类
|
|
35
|
+
*/
|
|
36
|
+
categorize?: string;
|
|
37
|
+
/**
|
|
38
|
+
* 子分类
|
|
39
|
+
*/
|
|
40
|
+
subCategorize?: string;
|
|
41
|
+
/**
|
|
42
|
+
* 版本
|
|
43
|
+
*/
|
|
44
|
+
version?: string;
|
|
45
|
+
/**
|
|
46
|
+
* 初始宽度
|
|
47
|
+
*/
|
|
48
|
+
width?: number;
|
|
49
|
+
/**
|
|
50
|
+
* 初始高度
|
|
51
|
+
*/
|
|
52
|
+
height?: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 自动扫描抽象组件定义核心类。
|
|
57
|
+
* 对于所有继承并实现了该抽象类的子类,都会被自动扫描到并注册到设计器中。
|
|
58
|
+
* 因此,所有要接入设计器的react组件都应该按照该类的约定实现其所有的方法。
|
|
59
|
+
*
|
|
60
|
+
* 泛型说明:
|
|
61
|
+
* C: 组件控制器类,用于指定当前组件定义对应的控制器类
|
|
62
|
+
* P: 组件配置类型,用于指定当前组件的配置数据(config属性的类型)
|
|
63
|
+
*/
|
|
64
|
+
export abstract class AbstractDefinition<C extends AbstractController = AbstractController, P = any> {
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 返回组件基础信息,用于在组件列表中展示
|
|
68
|
+
*/
|
|
69
|
+
abstract getBaseInfo(): BaseInfoType;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 返回React组件Controller控制器的类模板,在画布中创建组件实例时会根据该方法的返回值实例化组件控制器并保存。
|
|
73
|
+
* 后续将通过该控制器的实例对象来控制组件的生命周期
|
|
74
|
+
*/
|
|
75
|
+
abstract getController(): ClazzTemplate<C> | null;
|
|
76
|
+
}
|
|
77
|
+
|
package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-designer-controller.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import AbstractController from "./abstract-controller";
|
|
2
|
+
import { ComponentBaseProps, IFilterConfigType, ThemeItemType } from "../interface";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* AbstractDesignerController继承自AbstractController,在泛型的定义和约束上和AbstractController完全保持一致。
|
|
6
|
+
* 此外,AbstractDesignerController扩展了一些自定义组件所需的特有方法,如:修改组件数据等
|
|
7
|
+
*/
|
|
8
|
+
abstract class AbstractDesignerController<I = any, C = any> extends AbstractController<I, C> {
|
|
9
|
+
//轮询请求定时器
|
|
10
|
+
protected interval: NodeJS.Timeout | null = null;
|
|
11
|
+
//上一次数据连接状态 true:成功 false:失败
|
|
12
|
+
protected lastReqState: boolean = true;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 更新组件数据,且必须触发组件的重新渲染
|
|
16
|
+
* @param data
|
|
17
|
+
*/
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
19
|
+
public changeData(data: any): void {
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 加载组件数据,用于在预览(展示)模式下渲染完组件后根据当前组件的数据配置自动加载并更新组件数组。
|
|
25
|
+
* 注:若自定义组件有自己的数据加载方式,则需要覆写此方法
|
|
26
|
+
*/
|
|
27
|
+
public loadComponentData(): void {
|
|
28
|
+
const { data } = this.config as ComponentBaseProps;
|
|
29
|
+
if (!data) return;
|
|
30
|
+
const { sourceType } = data!;
|
|
31
|
+
switch (sourceType) {
|
|
32
|
+
case "static":
|
|
33
|
+
//静态数据不做处理,组件首次渲染时默认读取静态数据
|
|
34
|
+
break;
|
|
35
|
+
case "api":
|
|
36
|
+
console.log("请求数据");
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 更新本组件的主题样式方法,用于在全局切换主题时使用
|
|
43
|
+
* @param newTheme 新主题
|
|
44
|
+
*/
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
46
|
+
public updateTheme(newTheme: ThemeItemType): void {
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public updateFilter(filter: IFilterConfigType): void {
|
|
50
|
+
if (this.config && (this.config as ComponentBaseProps).filter)
|
|
51
|
+
(this.config as ComponentBaseProps)!.filter = filter;
|
|
52
|
+
if (!this.container)
|
|
53
|
+
return;
|
|
54
|
+
if (filter?.enable) {
|
|
55
|
+
this.container.style.filter = `blur(${filter.blur}px) brightness(${filter.brightness}) contrast(${filter.contrast}) opacity(${filter.opacity}) saturate(${filter.saturate}) hue-rotate(${filter.hueRotate}deg)`
|
|
56
|
+
} else {
|
|
57
|
+
this.container.style.filter = 'none';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default AbstractDesignerController;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AbstractDefinition } from "./abstract-definition";
|
|
2
|
+
import { compsConfig } from "./assets";
|
|
3
|
+
import ComponentDefinition from "./component-definition";
|
|
4
|
+
|
|
5
|
+
class AbstractDesignerLoader {
|
|
6
|
+
|
|
7
|
+
//自定义组件信息映射
|
|
8
|
+
public definitionMap: Record<string, AbstractDefinition> = {};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 加载设计器
|
|
12
|
+
*/
|
|
13
|
+
public load(): void {
|
|
14
|
+
//扫描组件
|
|
15
|
+
this.scanComponents();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 组件挂载
|
|
20
|
+
*/
|
|
21
|
+
protected scanComponents(): void {
|
|
22
|
+
Object.keys(compsConfig || {}).forEach((key) => {
|
|
23
|
+
const definition: AbstractDefinition = new ComponentDefinition({ componentType: key, componentNode: compsConfig[key].componentNode });
|
|
24
|
+
const compKey = definition.getBaseInfo()?.compKey;
|
|
25
|
+
if (compKey) {
|
|
26
|
+
this.definitionMap[compKey] = definition;
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const abstractDesignerLoader = new AbstractDesignerLoader();
|
|
34
|
+
export default abstractDesignerLoader;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { BaseInfoType } from "../interface";
|
|
2
|
+
// 组件
|
|
3
|
+
import BaseTextComponent from "../../base-text";
|
|
4
|
+
import BaseImage from "../../base-image";
|
|
5
|
+
import DateTime from "../../date-time";
|
|
6
|
+
import BaseColorBlock from "../../base-color-block";
|
|
7
|
+
import FourAngleGlowBorder from "../../four-angle-glow-border";
|
|
8
|
+
import BaseLineChart from "../../line-chart";
|
|
9
|
+
import BarChart from "../../bar-chart";
|
|
10
|
+
import ColumnChart from "../../column-chart";
|
|
11
|
+
|
|
12
|
+
interface ComponentItemConfig {
|
|
13
|
+
baseInfo: BaseInfoType, // 基础信息
|
|
14
|
+
componentNode: any, // 组件实例
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 组件配置 key:同compKey
|
|
18
|
+
export const compsConfig: { [key: string]: ComponentItemConfig } = {
|
|
19
|
+
BaseText: {
|
|
20
|
+
componentNode: BaseTextComponent,
|
|
21
|
+
baseInfo: {
|
|
22
|
+
compName: "基础文本",
|
|
23
|
+
compKey: "BaseText",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
BaseImage: {
|
|
27
|
+
componentNode: BaseImage,
|
|
28
|
+
baseInfo: {
|
|
29
|
+
compName: "基础图片",
|
|
30
|
+
compKey: "BaseImage",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
DateTime: {
|
|
34
|
+
componentNode: DateTime,
|
|
35
|
+
baseInfo: {
|
|
36
|
+
compName: "当前时间",
|
|
37
|
+
compKey: "DateTime",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
BaseColorBlock: {
|
|
41
|
+
componentNode: BaseColorBlock,
|
|
42
|
+
baseInfo: {
|
|
43
|
+
compName: "基础色块",
|
|
44
|
+
compKey: "BaseColorBlock",
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
FourAngleGlowBorder: {
|
|
48
|
+
componentNode: FourAngleGlowBorder,
|
|
49
|
+
baseInfo: {
|
|
50
|
+
compName: "四角辉光边框",
|
|
51
|
+
compKey: "FourAngleGlowBorder",
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
BaseLineChart: {
|
|
55
|
+
componentNode: BaseLineChart,
|
|
56
|
+
baseInfo: {
|
|
57
|
+
compName: "折线图",
|
|
58
|
+
compKey: "BaseLineChart",
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
AreaChart: {
|
|
62
|
+
componentNode: BaseLineChart,
|
|
63
|
+
baseInfo: {
|
|
64
|
+
compName: "面积图",
|
|
65
|
+
compKey: "AreaChart",
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
StepLineChart: {
|
|
69
|
+
componentNode: BaseLineChart,
|
|
70
|
+
baseInfo: {
|
|
71
|
+
compName: "阶梯图",
|
|
72
|
+
compKey: "StepLineChart",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
ColumnChart: {
|
|
76
|
+
componentNode: ColumnChart,
|
|
77
|
+
baseInfo: {
|
|
78
|
+
compName: "柱状图",
|
|
79
|
+
compKey: "ColumnChart",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
BarChart: {
|
|
83
|
+
componentNode: BarChart,
|
|
84
|
+
baseInfo: {
|
|
85
|
+
compName: "条形图",
|
|
86
|
+
compKey: "BarChart",
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { memo, Suspense, useEffect, useRef, useState } from "react";
|
|
2
|
+
import Loading from "./loading";
|
|
3
|
+
import { ILayerItem, LayerManagerDataType } from "../interface";
|
|
4
|
+
import AbstractDesignerController from "./abstract-designer-controller";
|
|
5
|
+
import abstractDesignerLoader from "./abstract-designer-loader";
|
|
6
|
+
|
|
7
|
+
const registerProxy = (compId: string, controller: AbstractDesignerController) => {
|
|
8
|
+
controller.changeData = new Proxy(controller.changeData, {
|
|
9
|
+
apply(target, thisArg, argus) {
|
|
10
|
+
return target.apply(thisArg, argus as any);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ComponentContainerProps {
|
|
16
|
+
layer: ILayerItem;
|
|
17
|
+
layerManager: LayerManagerDataType
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const ComponentContainer = memo((props: ComponentContainerProps) => {
|
|
21
|
+
const { layer, layerManager } = props;
|
|
22
|
+
const ref = useRef(null);
|
|
23
|
+
const [compController, setCompController] = useState<{ [key: string]: AbstractDesignerController }>({})
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
//通过ref创建组件,并将组件实例存入Map中。后续通过Map匹配到具体实例,调用实例的对象方法进行组件的更新操作
|
|
27
|
+
const { elemConfigs } = layerManager;
|
|
28
|
+
const componentDefine = abstractDesignerLoader.definitionMap[layer.type];
|
|
29
|
+
if (componentDefine) {
|
|
30
|
+
const Controller = componentDefine.getController() as any;
|
|
31
|
+
if (Controller) {
|
|
32
|
+
let config;
|
|
33
|
+
if (layer.id! in compController!) {
|
|
34
|
+
//重新编组后,被编组组件会重新渲染,需从之前的实例中获取原有数据
|
|
35
|
+
config = compController![layer.id!].getConfig();
|
|
36
|
+
} else if (layer.id! in elemConfigs!) {
|
|
37
|
+
config = elemConfigs![layer.id!];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 此处注意,执行顺序尤为重要!!!
|
|
41
|
+
* 第一步:动态代理绑定在前,
|
|
42
|
+
* 第二步:赋值controller在后,
|
|
43
|
+
* 第三步:最后才是执行create方法。
|
|
44
|
+
*/
|
|
45
|
+
//todo 此处逻辑应该使用设计模式优化,而非写死
|
|
46
|
+
registerProxy(layer.id!, Controller);
|
|
47
|
+
setCompController(val => ({ ...val, [layer.id]: Controller }))
|
|
48
|
+
Controller.create(ref.current!, config).then(() => {
|
|
49
|
+
//在组件完全渲染完毕后进行数据的加载和事件的注册
|
|
50
|
+
Controller.loadComponentData();
|
|
51
|
+
//设置组件滤镜效果(todo 考虑是否应该在此处设置?)
|
|
52
|
+
Controller.updateFilter(Controller.getConfig()?.filter);
|
|
53
|
+
//渲染后删除elemConfigs中的映射关系(需要观察是否会造成其他问题)
|
|
54
|
+
delete elemConfigs![layer.id!];
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, []);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<Suspense fallback={<Loading />}>
|
|
62
|
+
<div
|
|
63
|
+
id={layer.id}
|
|
64
|
+
data-type={layer.type}
|
|
65
|
+
data-lock={layer.lock}
|
|
66
|
+
data-hide={layer.hide}
|
|
67
|
+
key={layer.id + ''}
|
|
68
|
+
style={{
|
|
69
|
+
width: layer.width,
|
|
70
|
+
height: layer.height,
|
|
71
|
+
transform: layer.transform || `translate(${layer.x!}px, ${layer.y!}px)`,
|
|
72
|
+
position: 'absolute',
|
|
73
|
+
visibility: layer.hide ? "hidden" : "visible",
|
|
74
|
+
border: 'none'
|
|
75
|
+
}} className={"lc-comp-item"}>
|
|
76
|
+
<div ref={ref} style={{
|
|
77
|
+
width: '100%',
|
|
78
|
+
height: '100%',
|
|
79
|
+
pointerEvents: 'auto',
|
|
80
|
+
position: 'relative'
|
|
81
|
+
}} />
|
|
82
|
+
</div>
|
|
83
|
+
</Suspense>
|
|
84
|
+
)
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
export default ComponentContainer;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { ComponentType, ClassType, createElement } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
import { message } from "antd";
|
|
4
|
+
import { UpdateOptions } from "./abstract-controller";
|
|
5
|
+
import AbstractDesignerController from "./abstract-designer-controller";
|
|
6
|
+
|
|
7
|
+
const merge = (originalData: any, newData: any): any => {
|
|
8
|
+
if (!originalData && newData)
|
|
9
|
+
return newData;
|
|
10
|
+
if (originalData && !newData)
|
|
11
|
+
return originalData;
|
|
12
|
+
Object.keys(newData).forEach(key => {
|
|
13
|
+
const newValue = newData[key];
|
|
14
|
+
if (originalData.hasOwnProperty(key)) {
|
|
15
|
+
if (Array.isArray(newValue)) {
|
|
16
|
+
originalData[key] = newValue;
|
|
17
|
+
} else if (newValue
|
|
18
|
+
&& typeof newValue === "object"
|
|
19
|
+
&& Object.keys(newValue).length > 0
|
|
20
|
+
&& originalData[key]
|
|
21
|
+
&& typeof originalData[key] === "object"
|
|
22
|
+
&& !!originalData[key]) {
|
|
23
|
+
merge(originalData[key], newValue);
|
|
24
|
+
} else {
|
|
25
|
+
originalData[key] = newValue;
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
originalData[key] = newValue;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return originalData;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class ComponentUtil {
|
|
35
|
+
public static async createAndRender<T, P = any>(container: HTMLElement, Template: ClassType<P, any, any>, props?: any): Promise<T | null> {
|
|
36
|
+
if (!container)
|
|
37
|
+
throw new Error("create react node failed, container is null");
|
|
38
|
+
return new Promise<T | null>((resolve) => {
|
|
39
|
+
try {
|
|
40
|
+
createRoot(container).render(createElement(Template, {
|
|
41
|
+
ref: (instance: T) => resolve(instance),
|
|
42
|
+
...props,
|
|
43
|
+
isDesignMode: false // 组件中传参是否是编辑页
|
|
44
|
+
}))
|
|
45
|
+
} catch (e: unknown) {
|
|
46
|
+
console.error('create react node failed ', e)
|
|
47
|
+
resolve(null);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
export class ComponentController extends AbstractDesignerController {
|
|
55
|
+
|
|
56
|
+
private componentNode: ComponentType; // 组件实例
|
|
57
|
+
private componentType: string; // 组件类型
|
|
58
|
+
|
|
59
|
+
constructor({ componentType, componentNode }) {
|
|
60
|
+
super();
|
|
61
|
+
this.componentType = componentType;
|
|
62
|
+
this.componentNode = componentNode;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async create(container: HTMLElement, config: { [key: string]: any }): Promise<void> {
|
|
66
|
+
this.config = config;
|
|
67
|
+
this.container = container;
|
|
68
|
+
this.instance = await ComponentUtil.createAndRender(container, this.componentNode, config);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
destroy(): void {
|
|
72
|
+
this.instance?.destroy?.();
|
|
73
|
+
this.instance = null;
|
|
74
|
+
this.config = null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
getConfig(): { [key: string]: any } | null {
|
|
78
|
+
return this.config;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
update(config: { [key: string]: any }, upOp?: UpdateOptions | undefined): void {
|
|
82
|
+
this.config = merge(this.config, config);
|
|
83
|
+
upOp = upOp || { reRender: true };
|
|
84
|
+
if (upOp.reRender) {
|
|
85
|
+
this.instance?.updateConfig(this.config!);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
changeData(data: any) {
|
|
91
|
+
if (this.componentType === "BaseText" && typeof data !== 'string') {
|
|
92
|
+
message.warning('数据类型错误, 基础文本仅接受字符串类型的数据: ', data);
|
|
93
|
+
this.config!.data!.staticData = "";
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
this.config!.data!.staticData = data;
|
|
97
|
+
this.instance?.updateConfig(this.config!);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ComponentType } from "react";
|
|
2
|
+
import { BaseInfoType } from "../interface";
|
|
3
|
+
import { ComponentController } from "./component-controller";
|
|
4
|
+
import { compsConfig } from "./assets";
|
|
5
|
+
|
|
6
|
+
export default class ComponentDefinition {
|
|
7
|
+
|
|
8
|
+
private componentType: string; // 组件类型
|
|
9
|
+
private componentNode: ComponentType; // 组件实例
|
|
10
|
+
|
|
11
|
+
constructor({ componentType, componentNode }) {
|
|
12
|
+
this.componentType = componentType;
|
|
13
|
+
this.componentNode = componentNode;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getBaseInfo(): BaseInfoType {
|
|
17
|
+
return compsConfig[this.componentType].baseInfo;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getController(): any | null {
|
|
21
|
+
return new ComponentController({ componentNode: this.componentNode, componentType: this.componentType });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@font-face {
|
|
2
|
+
font-family: "DingTalk JinBuTi";
|
|
3
|
+
src: url('./DingTalk JinBuTi.ttf');
|
|
4
|
+
font-weight: normal;
|
|
5
|
+
font-style: normal;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
@font-face {
|
|
9
|
+
font-family: "DouyinSansBold";
|
|
10
|
+
src: url('./DouyinSansBold.ttf');
|
|
11
|
+
font-weight: normal;
|
|
12
|
+
font-style: normal;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@font-face {
|
|
16
|
+
font-family: "优设标题黑";
|
|
17
|
+
src: url('./优设标题黑.ttf');
|
|
18
|
+
font-weight: normal;
|
|
19
|
+
font-style: normal;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@font-face {
|
|
23
|
+
font-family: "庞门正道标题体免费版";
|
|
24
|
+
src: url('./庞门正道标题体免费版.ttf');
|
|
25
|
+
font-weight: normal;
|
|
26
|
+
font-style: normal;
|
|
27
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { createElement, ReactElement } from "react";
|
|
2
|
+
import cloneDeep from "lodash/cloneDeep";
|
|
3
|
+
import ComponentContainer from "./component-container";
|
|
4
|
+
import { ILayerItem, LayerManagerDataType, } from "../interface";
|
|
5
|
+
|
|
6
|
+
export enum LayerOrder {
|
|
7
|
+
ASC,
|
|
8
|
+
DESC,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
class LayerBuilder {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 解析函数
|
|
15
|
+
*/
|
|
16
|
+
public parser = (layerManager: LayerManagerDataType, order: LayerOrder = LayerOrder.DESC): ILayerItem[] => {
|
|
17
|
+
const { layerHeader, layerConfigs } = layerManager;
|
|
18
|
+
const layerMap = cloneDeep(layerConfigs);
|
|
19
|
+
let sourceLayerArr: ILayerItem[] = [];
|
|
20
|
+
|
|
21
|
+
const iterateLayers = (currentLayer: ILayerItem, res: ILayerItem[]): void => {
|
|
22
|
+
if (currentLayer) {
|
|
23
|
+
res.push(currentLayer);
|
|
24
|
+
if (currentLayer.childHeader) {
|
|
25
|
+
let childLayer = layerMap[currentLayer.childHeader];
|
|
26
|
+
iterateLayers(childLayer, res);
|
|
27
|
+
}
|
|
28
|
+
let next = currentLayer.next;
|
|
29
|
+
while (next) {
|
|
30
|
+
const nextLayer = layerMap[next!];
|
|
31
|
+
if (nextLayer?.childHeader)
|
|
32
|
+
iterateLayers(layerMap[nextLayer.childHeader], res);
|
|
33
|
+
nextLayer && res.push(nextLayer);
|
|
34
|
+
next = nextLayer?.next;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
iterateLayers(layerMap[layerHeader!], sourceLayerArr);
|
|
40
|
+
|
|
41
|
+
if (order === LayerOrder.ASC)
|
|
42
|
+
sourceLayerArr = sourceLayerArr.reverse();
|
|
43
|
+
|
|
44
|
+
// 构建树结构
|
|
45
|
+
const resData: ILayerItem[] = [];
|
|
46
|
+
for (const layerItem of sourceLayerArr) {
|
|
47
|
+
if (!layerItem?.pid) {
|
|
48
|
+
// 根节点
|
|
49
|
+
resData.push(layerItem);
|
|
50
|
+
} else {
|
|
51
|
+
// 非根节点,将其加入父节点的 children 中
|
|
52
|
+
const parent = layerMap[layerItem.pid];
|
|
53
|
+
if (parent) {
|
|
54
|
+
parent.children = parent.children || [];
|
|
55
|
+
parent.children.push(layerItem);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return resData;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
private order: number = 1;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 构建设计器主画布组件
|
|
66
|
+
* @param layerMap
|
|
67
|
+
*/
|
|
68
|
+
public buildCanvasComponents = (layerManager: LayerManagerDataType): ReactElement[] => {
|
|
69
|
+
const res: ReactElement[] = [];
|
|
70
|
+
//渲染顺序,先渲染顶层容器,再逐步渲染底层的子容器
|
|
71
|
+
this.parser(layerManager, LayerOrder.ASC).forEach((item: ILayerItem) => {
|
|
72
|
+
res.push(this.buildComponents(layerManager, item));
|
|
73
|
+
});
|
|
74
|
+
//重置排序编号
|
|
75
|
+
this.order = 1;
|
|
76
|
+
return res;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private buildComponents = (layerManager: LayerManagerDataType, layer: ILayerItem): ReactElement => {
|
|
80
|
+
const { layerConfigs } = layerManager;
|
|
81
|
+
const targetLayer = layerConfigs[layer.id!];
|
|
82
|
+
//给每个图层重新设置排序编号,用于在图层移动的过程中提供更好的体验
|
|
83
|
+
if (targetLayer)
|
|
84
|
+
targetLayer.order = this.order++;
|
|
85
|
+
return createElement(ComponentContainer, { layer, key: layer.id, layerManager });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const layerBuilder = new LayerBuilder();
|
|
91
|
+
export default layerBuilder;
|