aldehyde 0.2.525 → 0.2.527

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.
Files changed (65) hide show
  1. package/lib/controls/icon-selector/icon/phonenode-menu-icon/iconfont.css +99 -99
  2. package/lib/draw-canvas-edit/components/asset-bar/index.less +35 -35
  3. package/lib/draw-canvas-edit/components/main-header/index.less +23 -23
  4. package/lib/lowcode-components/base-table/index.less +61 -61
  5. package/lib/lowcode-components/data-number/index.less +10 -10
  6. package/lib/lowcode-components/date-time/index.less +4 -4
  7. package/lib/lowcode-components/four-angle-glow-border/index.less +49 -49
  8. package/lib/lowcode-components/line-chart/index.d.ts.map +1 -1
  9. package/lib/lowcode-components/line-chart/index.js +13 -7
  10. package/lib/lowcode-components/line-chart/index.js.map +1 -1
  11. package/lib/lowcode-components/lowcode-view/component/font/FontGlobal.css +26 -26
  12. package/lib/lowcode-components/lowcode-view/component/screen-fit/index.less +13 -13
  13. package/lib/lowcode-components/text-scroller/index.less +28 -28
  14. package/package.json +1 -1
  15. package/src/aldehyde/controls/icon-selector/icon/phonenode-menu-icon/iconfont.css +99 -99
  16. package/src/aldehyde/controls/icon-selector/icon/phonenode-menu-icon/iconfont.json +156 -156
  17. package/src/aldehyde/draw-canvas-edit/components/asset-bar/index.less +35 -35
  18. package/src/aldehyde/draw-canvas-edit/components/asset-bar/index.tsx +110 -110
  19. package/src/aldehyde/draw-canvas-edit/components/main-header/index.less +23 -23
  20. package/src/aldehyde/draw-canvas-edit/components/main-header/index.tsx +263 -263
  21. package/src/aldehyde/draw-canvas-edit/components/render/draws/index.ts +7 -7
  22. package/src/aldehyde/draw-canvas-edit/components/render/graphs/base-graph.ts +241 -241
  23. package/src/aldehyde/draw-canvas-edit/components/render/graphs/circle.ts +699 -699
  24. package/src/aldehyde/draw-canvas-edit/components/render/graphs/curve.ts +500 -500
  25. package/src/aldehyde/draw-canvas-edit/components/render/graphs/index.ts +5 -5
  26. package/src/aldehyde/draw-canvas-edit/components/render/graphs/line.ts +493 -493
  27. package/src/aldehyde/draw-canvas-edit/components/render/graphs/rect.ts +680 -680
  28. package/src/aldehyde/draw-canvas-edit/components/render/handlers/drag-handlers.ts +68 -68
  29. package/src/aldehyde/draw-canvas-edit/components/render/handlers/graph-handlers.ts +113 -113
  30. package/src/aldehyde/draw-canvas-edit/components/render/handlers/index.ts +9 -9
  31. package/src/aldehyde/draw-canvas-edit/components/render/handlers/key-move-handlers.ts +49 -49
  32. package/src/aldehyde/draw-canvas-edit/components/render/handlers/link-handlers.ts +45 -45
  33. package/src/aldehyde/draw-canvas-edit/components/render/handlers/shutcut-handlers.ts +45 -45
  34. package/src/aldehyde/draw-canvas-edit/components/render/handlers/text-handlers.ts +81 -81
  35. package/src/aldehyde/draw-canvas-edit/components/render/handlers/zoom-handlers.ts +59 -59
  36. package/src/aldehyde/draw-canvas-edit/components/render/tools/align-tool.ts +89 -89
  37. package/src/aldehyde/draw-canvas-edit/components/render/tools/asset-tool.ts +154 -154
  38. package/src/aldehyde/draw-canvas-edit/components/render/tools/link-tool.ts +222 -222
  39. package/src/aldehyde/draw-canvas-edit/components/render/tools/z-index-tool.ts +224 -224
  40. package/src/aldehyde/draw-canvas-edit/components/render/utils/a-star.ts +116 -116
  41. package/src/aldehyde/draw-canvas-edit/components/render/utils/bezier-scene-func.ts +72 -72
  42. package/src/aldehyde/draw-canvas-edit/components/setting-form/imag-upload.tsx +119 -119
  43. package/src/aldehyde/layout4/imgs/user.svg +26 -26
  44. package/src/aldehyde/lowcode-components/base-color-block/index.tsx +31 -31
  45. package/src/aldehyde/lowcode-components/base-table/index.less +61 -61
  46. package/src/aldehyde/lowcode-components/data-number/index.less +10 -10
  47. package/src/aldehyde/lowcode-components/date-time/index.less +4 -4
  48. package/src/aldehyde/lowcode-components/date-time/index.tsx +64 -64
  49. package/src/aldehyde/lowcode-components/four-angle-glow-border/index.less +49 -49
  50. package/src/aldehyde/lowcode-components/four-angle-glow-border/index.tsx +53 -53
  51. package/src/aldehyde/lowcode-components/line-chart/index.tsx +13 -7
  52. package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-controller.ts +64 -64
  53. package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-definition.ts +77 -77
  54. package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-designer-loader.ts +36 -36
  55. package/src/aldehyde/lowcode-components/lowcode-view/component/component-container.tsx +144 -144
  56. package/src/aldehyde/lowcode-components/lowcode-view/component/font/FontGlobal.css +26 -26
  57. package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/controller.ts +36 -36
  58. package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/definition.ts +53 -53
  59. package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/index.tsx +15 -15
  60. package/src/aldehyde/lowcode-components/lowcode-view/component/layer-builder.tsx +98 -98
  61. package/src/aldehyde/lowcode-components/lowcode-view/component/screen-fit/index.less +13 -13
  62. package/src/aldehyde/lowcode-components/lowcode-view/component/screen-fit/index.tsx +121 -121
  63. package/src/aldehyde/lowcode-components/placeholder-component/index.tsx +81 -81
  64. package/src/aldehyde/lowcode-components/text-scroller/index.less +28 -28
  65. package/src/aldehyde/lowcode-components/text-scroller/index.tsx +173 -173
@@ -1,5 +1,5 @@
1
- .date-time-component {
2
- width: 100%;
3
- height: 100%;
4
- display: flex;
1
+ .date-time-component {
2
+ width: 100%;
3
+ height: 100%;
4
+ display: flex;
5
5
  }
@@ -1,65 +1,65 @@
1
- import React, { ForwardedRef, forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
2
- import dayjs from "dayjs";
3
- import './index.less';
4
-
5
- export interface DateTimeComponentStyle {
6
- fontSize?: number;
7
- color?: string;
8
- fontFamily?: string;
9
- fontWeight?: number;
10
- alignItems?: string;
11
- justifyContent?: string;
12
- letterSpacing?: string;
13
- formatType?: string;
14
- }
15
-
16
- export interface DateTimeComponentProps {
17
- style?: DateTimeComponentStyle;
18
- }
19
-
20
- export interface DateTimeComponentRef {
21
- updateConfig: (newConfig: DateTimeComponentProps) => void;
22
- setEventHandler: (eventMap: Record<string, Function>) => void;
23
- destroy: () => void;
24
- }
25
-
26
- const defFormatType = "YYYY年MM月DD日 HH时mm分ss秒";
27
-
28
- const DateTimeComponent = forwardRef((props: DateTimeComponentProps, ref: ForwardedRef<DateTimeComponentRef>) => {
29
- const [config, setConfig] = useState<DateTimeComponentProps>({ ...props });
30
- const [datetime, setDateTime] = useState<string>(dayjs().format(config.style?.formatType || defFormatType));
31
- const timeRef = useRef<NodeJS.Timeout | null>(null);
32
- const eventHandlerMap = useRef<Record<string, Function>>({});
33
-
34
- const handleClearInterval = () => {
35
- timeRef.current && clearInterval(timeRef.current);
36
- timeRef.current = null;
37
- }
38
-
39
- useEffect(() => {
40
- timeRef.current = setInterval(() => {
41
- setDateTime(dayjs().format(config.style?.formatType || defFormatType));
42
- }, 1000);
43
- return () => {
44
- handleClearInterval();
45
- }
46
- }, []);
47
-
48
-
49
- useImperativeHandle(ref, () => ({
50
- updateConfig: (newConfig) => setConfig({ ...newConfig }),
51
- setEventHandler: (eventMap) => eventHandlerMap.current = eventMap,
52
- destroy: () => {
53
- handleClearInterval();
54
- }
55
- }));
56
-
57
-
58
- return (
59
- <div className="date-time-component" style={{ ...(config?.style || {}) }}>
60
- {datetime}
61
- </div>
62
- );
63
- });
64
-
1
+ import React, { ForwardedRef, forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
2
+ import dayjs from "dayjs";
3
+ import './index.less';
4
+
5
+ export interface DateTimeComponentStyle {
6
+ fontSize?: number;
7
+ color?: string;
8
+ fontFamily?: string;
9
+ fontWeight?: number;
10
+ alignItems?: string;
11
+ justifyContent?: string;
12
+ letterSpacing?: string;
13
+ formatType?: string;
14
+ }
15
+
16
+ export interface DateTimeComponentProps {
17
+ style?: DateTimeComponentStyle;
18
+ }
19
+
20
+ export interface DateTimeComponentRef {
21
+ updateConfig: (newConfig: DateTimeComponentProps) => void;
22
+ setEventHandler: (eventMap: Record<string, Function>) => void;
23
+ destroy: () => void;
24
+ }
25
+
26
+ const defFormatType = "YYYY年MM月DD日 HH时mm分ss秒";
27
+
28
+ const DateTimeComponent = forwardRef((props: DateTimeComponentProps, ref: ForwardedRef<DateTimeComponentRef>) => {
29
+ const [config, setConfig] = useState<DateTimeComponentProps>({ ...props });
30
+ const [datetime, setDateTime] = useState<string>(dayjs().format(config.style?.formatType || defFormatType));
31
+ const timeRef = useRef<NodeJS.Timeout | null>(null);
32
+ const eventHandlerMap = useRef<Record<string, Function>>({});
33
+
34
+ const handleClearInterval = () => {
35
+ timeRef.current && clearInterval(timeRef.current);
36
+ timeRef.current = null;
37
+ }
38
+
39
+ useEffect(() => {
40
+ timeRef.current = setInterval(() => {
41
+ setDateTime(dayjs().format(config.style?.formatType || defFormatType));
42
+ }, 1000);
43
+ return () => {
44
+ handleClearInterval();
45
+ }
46
+ }, []);
47
+
48
+
49
+ useImperativeHandle(ref, () => ({
50
+ updateConfig: (newConfig) => setConfig({ ...newConfig }),
51
+ setEventHandler: (eventMap) => eventHandlerMap.current = eventMap,
52
+ destroy: () => {
53
+ handleClearInterval();
54
+ }
55
+ }));
56
+
57
+
58
+ return (
59
+ <div className="date-time-component" style={{ ...(config?.style || {}) }}>
60
+ {datetime}
61
+ </div>
62
+ );
63
+ });
64
+
65
65
  export default DateTimeComponent;
@@ -1,50 +1,50 @@
1
- .four-angle-glow {
2
- --fagb-color: #00ebff;
3
- --fagb-width: 2px;
4
- --fagb-length: 8px;
5
- --fagb-radius: 3px;
6
- width: 100%;
7
- height: 100%;
8
- position: relative;
9
-
10
- .angle {
11
- position: absolute;
12
- border: var(--fagb-width) solid var(--fagb-color);
13
- width: var(--fagb-length);
14
- height: var(--fagb-length);
15
- }
16
-
17
- .angle-tl {
18
- margin: -1px 0 0 -1px;
19
- border-right: 0;
20
- border-bottom: 0;
21
- border-top-left-radius: var(--fagb-radius);
22
- }
23
-
24
- .angle-tr {
25
- top: 0;
26
- right: 0;
27
- border-left: 0;
28
- border-bottom: 0;
29
- margin: -1px -1px 0 0;
30
- border-top-right-radius: var(--fagb-radius);
31
- }
32
-
33
- .angle-bl {
34
- bottom: 0;
35
- left: 0;
36
- border-top: 0;
37
- border-right: 0;
38
- margin: 0 0 -1px -1px;
39
- border-bottom-left-radius: var(--fagb-radius);
40
- }
41
-
42
- .angle-br {
43
- bottom: 0;
44
- right: 0;
45
- border-left: 0;
46
- border-top: 0;
47
- margin: 0 -1px -1px 0;
48
- border-bottom-right-radius: var(--fagb-radius);
49
- }
1
+ .four-angle-glow {
2
+ --fagb-color: #00ebff;
3
+ --fagb-width: 2px;
4
+ --fagb-length: 8px;
5
+ --fagb-radius: 3px;
6
+ width: 100%;
7
+ height: 100%;
8
+ position: relative;
9
+
10
+ .angle {
11
+ position: absolute;
12
+ border: var(--fagb-width) solid var(--fagb-color);
13
+ width: var(--fagb-length);
14
+ height: var(--fagb-length);
15
+ }
16
+
17
+ .angle-tl {
18
+ margin: -1px 0 0 -1px;
19
+ border-right: 0;
20
+ border-bottom: 0;
21
+ border-top-left-radius: var(--fagb-radius);
22
+ }
23
+
24
+ .angle-tr {
25
+ top: 0;
26
+ right: 0;
27
+ border-left: 0;
28
+ border-bottom: 0;
29
+ margin: -1px -1px 0 0;
30
+ border-top-right-radius: var(--fagb-radius);
31
+ }
32
+
33
+ .angle-bl {
34
+ bottom: 0;
35
+ left: 0;
36
+ border-top: 0;
37
+ border-right: 0;
38
+ margin: 0 0 -1px -1px;
39
+ border-bottom-left-radius: var(--fagb-radius);
40
+ }
41
+
42
+ .angle-br {
43
+ bottom: 0;
44
+ right: 0;
45
+ border-left: 0;
46
+ border-top: 0;
47
+ margin: 0 -1px -1px 0;
48
+ border-bottom-right-radius: var(--fagb-radius);
49
+ }
50
50
  }
@@ -1,53 +1,53 @@
1
- import './index.less';
2
- import React, { ForwardedRef, forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
3
-
4
- export interface FourAngleGlowBorderStyle {
5
- width?: number;
6
- length?: number;
7
- color?: string;
8
- radius?: number;
9
- }
10
-
11
- export interface FourAngleGlowProps {
12
- style?: FourAngleGlowBorderStyle;
13
- }
14
-
15
- export interface FourAngleGlowBorderRef {
16
- updateConfig: (config: FourAngleGlowProps) => void;
17
- }
18
-
19
- const FourAngleGlowBorder = forwardRef((props: FourAngleGlowProps, ref: ForwardedRef<FourAngleGlowBorderRef>) => {
20
- const [config] = useState<FourAngleGlowProps>({ ...props });
21
- const fourAngleGlowRef = useRef<HTMLDivElement | null>(null);
22
-
23
- const updateStyle = (style: FourAngleGlowBorderStyle) => {
24
- const dom = fourAngleGlowRef.current;
25
- if (dom) {
26
- dom.style.setProperty('--fagb-length', `${style?.length}px`);
27
- dom.style.setProperty('--fagb-color', style?.color);
28
- dom.style.setProperty('--fagb-radius', `${style?.radius}px`);
29
- dom.style.setProperty('--fagb-width', `${style?.width}px`);
30
- }
31
- };
32
-
33
- useImperativeHandle(ref, () => ({
34
- updateConfig: (newConfig) => updateStyle({ ...newConfig.style }),
35
- }));
36
-
37
- useEffect(() => {
38
- updateStyle(config.style);
39
- }, []);
40
-
41
- return (
42
- <div className="four-angle-glow" ref={fourAngleGlowRef}>
43
- <span className="angle angle-tl" />
44
- <span className="angle angle-tr" />
45
- <span className="angle angle-bl" />
46
- <span className="angle angle-br" />
47
- </div>
48
- );
49
- })
50
-
51
- export default FourAngleGlowBorder;
52
-
53
-
1
+ import './index.less';
2
+ import React, { ForwardedRef, forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
3
+
4
+ export interface FourAngleGlowBorderStyle {
5
+ width?: number;
6
+ length?: number;
7
+ color?: string;
8
+ radius?: number;
9
+ }
10
+
11
+ export interface FourAngleGlowProps {
12
+ style?: FourAngleGlowBorderStyle;
13
+ }
14
+
15
+ export interface FourAngleGlowBorderRef {
16
+ updateConfig: (config: FourAngleGlowProps) => void;
17
+ }
18
+
19
+ const FourAngleGlowBorder = forwardRef((props: FourAngleGlowProps, ref: ForwardedRef<FourAngleGlowBorderRef>) => {
20
+ const [config] = useState<FourAngleGlowProps>({ ...props });
21
+ const fourAngleGlowRef = useRef<HTMLDivElement | null>(null);
22
+
23
+ const updateStyle = (style: FourAngleGlowBorderStyle) => {
24
+ const dom = fourAngleGlowRef.current;
25
+ if (dom) {
26
+ dom.style.setProperty('--fagb-length', `${style?.length}px`);
27
+ dom.style.setProperty('--fagb-color', style?.color);
28
+ dom.style.setProperty('--fagb-radius', `${style?.radius}px`);
29
+ dom.style.setProperty('--fagb-width', `${style?.width}px`);
30
+ }
31
+ };
32
+
33
+ useImperativeHandle(ref, () => ({
34
+ updateConfig: (newConfig) => updateStyle({ ...newConfig.style }),
35
+ }));
36
+
37
+ useEffect(() => {
38
+ updateStyle(config.style);
39
+ }, []);
40
+
41
+ return (
42
+ <div className="four-angle-glow" ref={fourAngleGlowRef}>
43
+ <span className="angle angle-tl" />
44
+ <span className="angle angle-tr" />
45
+ <span className="angle angle-bl" />
46
+ <span className="angle angle-br" />
47
+ </div>
48
+ );
49
+ })
50
+
51
+ export default FourAngleGlowBorder;
52
+
53
+
@@ -21,12 +21,14 @@ const defOption = {
21
21
  boundaryGap: true,
22
22
  axisTick: { show: true },
23
23
  axisLabel: {},
24
- min: undefined
24
+ min: undefined,
25
+ max: undefined
25
26
  },
26
27
  yAxis: {
27
28
  type: 'value',
28
29
  axisLabel: {},
29
- min: undefined
30
+ min: undefined,
31
+ max: undefined
30
32
  },
31
33
  legend: { show: false },
32
34
  dataZoom: [],
@@ -325,24 +327,28 @@ const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>
325
327
  const option = _.cloneDeep(defOption);
326
328
  const yAxisLabel = yAxis?.axisLabel;
327
329
  const xAxisLabel = xAxis?.axisLabel;
328
- let xAxisMin, yAxisMin;
330
+ let xAxisMin, yAxisMin, xAxisMax, yAxisMax;
329
331
  // 编辑态无数据显示默认数据
330
332
  const temData = isDesignMode && !tData?.length ? option.series : tData;
331
333
  if (temData?.length && xAxis?.type === "time" && xAxis?.timeCompleteZero) { // 时间轴配置-时间轴0点补全
332
334
  const dataTime = temData.map(r => r.data || []).flat().map(item => new Date(item[0]).getTime());
333
335
  const minTime = Math.min(...dataTime);
334
- xAxisMin = dayjs(minTime).startOf("day").valueOf();
336
+ const maxTime = Math.max(...dataTime);
337
+ xAxisMin = dayjs(minTime).startOf("day").valueOf() + 1; // 时间轴0点补全,+1毫秒,避免显示日期
338
+ xAxisMax = dayjs(maxTime).endOf("day").valueOf();
335
339
  }
336
340
  if (temData?.length && yAxis?.type === "time" && yAxis?.timeCompleteZero) {
337
341
  const dataTime = temData.map(r => r.data || []).flat().map(item => new Date(item[1]).getTime());
338
342
  const minTime = Math.min(...dataTime);
339
- yAxisMin = dayjs(minTime).startOf("day").valueOf();
343
+ const maxTime = Math.max(...dataTime);
344
+ yAxisMin = dayjs(minTime).startOf("day").valueOf() + 1;
345
+ yAxisMax = dayjs(maxTime).endOf("day").valueOf();
340
346
  }
341
347
  option.grid = grid;
342
348
  option.legend = { ...legend, ...legends[legend?.position], data: temData?.filter((item: any) => !item.isMarkLine && item.name).map((r: any) => r.name) };
343
349
  option.tooltip = { trigger: "axis", ...tooltip };
344
- option.xAxis = { ...option.xAxis, ...xAxis, min: xAxisMin, axisTick: { show: xAxis?.axisLine?.show }, axisLabel: xAxisLabel.numFormat && xAxis.type === "value" ? { ...xAxisLabel, formatter: formatNumberUnit } : { ...xAxisLabel, showMinLabel: xAxisMin ? false : null } };
345
- option.yAxis = { ...option.yAxis, ...yAxis, min: yAxisMin, axisLabel: yAxisLabel.numFormat && yAxis.type === "value" ? { ...yAxisLabel, formatter: formatNumberUnit } : { ...yAxisLabel, showMinLabel: yAxisMin ? false : null } };
350
+ option.xAxis = { ...option.xAxis, ...xAxis, min: xAxisMin, max: xAxisMax, axisTick: { show: xAxis?.axisLine?.show }, axisLabel: xAxisLabel.numFormat && xAxis.type === "value" ? { ...xAxisLabel, formatter: formatNumberUnit } : { ...xAxisLabel, showMinLabel: xAxisMin ? false : null } };
351
+ option.yAxis = { ...option.yAxis, ...yAxis, min: yAxisMin, max: yAxisMax, axisLabel: yAxisLabel.numFormat && yAxis.type === "value" ? { ...yAxisLabel, formatter: formatNumberUnit } : { ...yAxisLabel, showMinLabel: yAxisMin ? false : null } };
346
352
  option.dataZoom = dataZoom ? [slider ? { type: "slider" } : undefined, { type: "inside", disabled: false }].filter(Boolean) : [];
347
353
  option.title.text = translate("${暂无数据}");
348
354
  option.title.show = !temData?.length;
@@ -1,64 +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;
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;