aldehyde 0.2.284 → 0.2.285

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 (104) hide show
  1. package/lib/controls/entry-control.d.ts.map +1 -1
  2. package/lib/controls/entry-control.js +4 -0
  3. package/lib/controls/entry-control.js.map +1 -1
  4. package/lib/controls/select/index.d.ts.map +1 -1
  5. package/lib/controls/select/index.js +1 -0
  6. package/lib/controls/select/index.js.map +1 -1
  7. package/lib/controls/view-control.d.ts.map +1 -1
  8. package/lib/controls/view-control.js +1 -0
  9. package/lib/controls/view-control.js.map +1 -1
  10. package/lib/detail/view/act-dtmpl-view.d.ts.map +1 -1
  11. package/lib/detail/view/act-dtmpl-view.js +3 -2
  12. package/lib/detail/view/act-dtmpl-view.js.map +1 -1
  13. package/lib/lowcode-components/bar-chart/index.d.ts +10 -6
  14. package/lib/lowcode-components/bar-chart/index.d.ts.map +1 -1
  15. package/lib/lowcode-components/bar-chart/index.js +91 -11
  16. package/lib/lowcode-components/bar-chart/index.js.map +1 -1
  17. package/lib/lowcode-components/base-map/index.d.ts +10 -6
  18. package/lib/lowcode-components/base-map/index.d.ts.map +1 -1
  19. package/lib/lowcode-components/base-map/index.js +86 -7
  20. package/lib/lowcode-components/base-map/index.js.map +1 -1
  21. package/lib/lowcode-components/base-table/index.d.ts +53 -0
  22. package/lib/lowcode-components/base-table/index.d.ts.map +1 -0
  23. package/lib/lowcode-components/base-table/index.js +158 -0
  24. package/lib/lowcode-components/base-table/index.js.map +1 -0
  25. package/lib/lowcode-components/base-table/index.less +59 -0
  26. package/lib/lowcode-components/capsule-bar-chart/index.d.ts +43 -0
  27. package/lib/lowcode-components/capsule-bar-chart/index.d.ts.map +1 -0
  28. package/lib/lowcode-components/capsule-bar-chart/index.js +179 -0
  29. package/lib/lowcode-components/capsule-bar-chart/index.js.map +1 -0
  30. package/lib/lowcode-components/circular-progress-chart/index.d.ts +26 -0
  31. package/lib/lowcode-components/circular-progress-chart/index.d.ts.map +1 -0
  32. package/lib/lowcode-components/circular-progress-chart/index.js +179 -0
  33. package/lib/lowcode-components/circular-progress-chart/index.js.map +1 -0
  34. package/lib/lowcode-components/column-chart/index.d.ts +11 -6
  35. package/lib/lowcode-components/column-chart/index.d.ts.map +1 -1
  36. package/lib/lowcode-components/column-chart/index.js +115 -16
  37. package/lib/lowcode-components/column-chart/index.js.map +1 -1
  38. package/lib/lowcode-components/data-number/index.d.ts +10 -0
  39. package/lib/lowcode-components/data-number/index.d.ts.map +1 -1
  40. package/lib/lowcode-components/data-number/index.js +80 -6
  41. package/lib/lowcode-components/data-number/index.js.map +1 -1
  42. package/lib/lowcode-components/effectScatter-map/index.d.ts +10 -6
  43. package/lib/lowcode-components/effectScatter-map/index.d.ts.map +1 -1
  44. package/lib/lowcode-components/effectScatter-map/index.js +87 -9
  45. package/lib/lowcode-components/effectScatter-map/index.js.map +1 -1
  46. package/lib/lowcode-components/gauge-chart/index.d.ts +10 -6
  47. package/lib/lowcode-components/gauge-chart/index.d.ts.map +1 -1
  48. package/lib/lowcode-components/gauge-chart/index.js +65 -8
  49. package/lib/lowcode-components/gauge-chart/index.js.map +1 -1
  50. package/lib/lowcode-components/index.d.ts +8 -0
  51. package/lib/lowcode-components/index.d.ts.map +1 -1
  52. package/lib/lowcode-components/index.js +6 -1
  53. package/lib/lowcode-components/index.js.map +1 -1
  54. package/lib/lowcode-components/line-chart/index.d.ts +10 -6
  55. package/lib/lowcode-components/line-chart/index.d.ts.map +1 -1
  56. package/lib/lowcode-components/line-chart/index.js +91 -11
  57. package/lib/lowcode-components/line-chart/index.js.map +1 -1
  58. package/lib/lowcode-components/liquid-chart/index.d.ts +10 -6
  59. package/lib/lowcode-components/liquid-chart/index.d.ts.map +1 -1
  60. package/lib/lowcode-components/liquid-chart/index.js +64 -7
  61. package/lib/lowcode-components/liquid-chart/index.js.map +1 -1
  62. package/lib/lowcode-components/lowcode-view/component/assets.d.ts.map +1 -1
  63. package/lib/lowcode-components/lowcode-view/component/assets.js +46 -0
  64. package/lib/lowcode-components/lowcode-view/component/assets.js.map +1 -1
  65. package/lib/lowcode-components/lowcode-view/component/component-container.d.ts.map +1 -1
  66. package/lib/lowcode-components/lowcode-view/component/component-container.js +30 -29
  67. package/lib/lowcode-components/lowcode-view/component/component-container.js.map +1 -1
  68. package/lib/lowcode-components/pie-chart/index.d.ts +11 -6
  69. package/lib/lowcode-components/pie-chart/index.d.ts.map +1 -1
  70. package/lib/lowcode-components/pie-chart/index.js +102 -15
  71. package/lib/lowcode-components/pie-chart/index.js.map +1 -1
  72. package/lib/lowcode-components/text-scroller/index.d.ts +23 -0
  73. package/lib/lowcode-components/text-scroller/index.d.ts.map +1 -0
  74. package/lib/lowcode-components/text-scroller/index.js +96 -0
  75. package/lib/lowcode-components/text-scroller/index.js.map +1 -0
  76. package/lib/lowcode-components/text-scroller/index.less +29 -0
  77. package/lib/tmpl/control-type-supportor.d.ts.map +1 -1
  78. package/lib/tmpl/control-type-supportor.js +1 -0
  79. package/lib/tmpl/control-type-supportor.js.map +1 -1
  80. package/package.json +1 -1
  81. package/src/aldehyde/controls/entry-control.tsx +12 -0
  82. package/src/aldehyde/controls/select/index.tsx +1 -0
  83. package/src/aldehyde/controls/view-control.tsx +1 -0
  84. package/src/aldehyde/detail/view/act-dtmpl-view.tsx +22 -23
  85. package/src/aldehyde/lowcode-components/bar-chart/index.tsx +100 -19
  86. package/src/aldehyde/lowcode-components/base-map/index.tsx +94 -15
  87. package/src/aldehyde/lowcode-components/base-table/index.less +59 -0
  88. package/src/aldehyde/lowcode-components/base-table/index.tsx +233 -0
  89. package/src/aldehyde/lowcode-components/capsule-bar-chart/index.tsx +219 -0
  90. package/src/aldehyde/lowcode-components/circular-progress-chart/index.tsx +201 -0
  91. package/src/aldehyde/lowcode-components/column-chart/index.tsx +128 -24
  92. package/src/aldehyde/lowcode-components/data-number/index.tsx +89 -7
  93. package/src/aldehyde/lowcode-components/data.d.ts +6 -0
  94. package/src/aldehyde/lowcode-components/effectScatter-map/index.tsx +93 -19
  95. package/src/aldehyde/lowcode-components/gauge-chart/index.tsx +73 -16
  96. package/src/aldehyde/lowcode-components/index.ts +10 -1
  97. package/src/aldehyde/lowcode-components/line-chart/index.tsx +105 -22
  98. package/src/aldehyde/lowcode-components/liquid-chart/index.tsx +70 -15
  99. package/src/aldehyde/lowcode-components/lowcode-view/component/assets.ts +46 -0
  100. package/src/aldehyde/lowcode-components/lowcode-view/component/component-container.tsx +29 -28
  101. package/src/aldehyde/lowcode-components/pie-chart/index.tsx +111 -25
  102. package/src/aldehyde/lowcode-components/text-scroller/index.less +29 -0
  103. package/src/aldehyde/lowcode-components/text-scroller/index.tsx +122 -0
  104. package/src/aldehyde/tmpl/control-type-supportor.tsx +1 -0
@@ -1,8 +1,16 @@
1
1
  import * as echarts from 'echarts';
2
2
  import React, { useEffect, useRef, useState, ForwardedRef, forwardRef, useImperativeHandle } from 'react';
3
3
  import _ from 'lodash';
4
+ import HydrocarbonService from "../../tmpl/hcservice-v3";
5
+ import { DataConfigProps } from "../data";
4
6
 
5
7
  const defOption = {
8
+ title: {
9
+ text: '暂无数据',
10
+ left: 'center',
11
+ top: 'middle',
12
+ show: false, // 无数据时显示
13
+ },
6
14
  color: ["#5470c6", "#91cc75", "#fac858", "#ee6666", "#73c0de"],
7
15
  padAngle: 0,
8
16
  tooltip: {
@@ -14,15 +22,18 @@ const defOption = {
14
22
  },
15
23
  series: [
16
24
  {
17
- name: 'Access From',
25
+ name: '数值',
18
26
  type: 'pie',
19
27
  radius: ["0%", "50%"],
28
+ padAngle: 0,
29
+ label: {},
30
+ labelLine: {},
20
31
  data: [
21
- { value: 1048, name: 'Search Engine' },
22
- { value: 735, name: 'Direct' },
23
- { value: 580, name: 'Email' },
24
- { value: 484, name: 'Union Ads' },
25
- { value: 300, name: 'Video Ads' }
32
+ { value: 1048, name: 'Value1' },
33
+ { value: 735, name: 'Value2' },
34
+ { value: 580, name: 'Value3' },
35
+ { value: 484, name: 'Value4' },
36
+ { value: 300, name: 'Value5' }
26
37
  ]
27
38
  }
28
39
  ],
@@ -37,9 +48,28 @@ const legends = {
37
48
  rightTop: { right: 5 },
38
49
  leftBottom: { left: 5, bottom: 0 },
39
50
  rightBottom: { right: 5, bottom: 0 },
40
- }
51
+ };
52
+
53
+ // 处理数据格式
54
+ const handleData = (data: { config: { [key: string]: string }, value: { [key: string]: any }[] }[]) => {
55
+ if (!data?.length) {
56
+ return [];
57
+ }
58
+ const temData = data.map((r) => {
59
+ const { config, value } = r;
60
+ const vNames = Object.keys(config).filter((r) => r.startsWith("v")).sort((a, b) => parseInt(a.substring(1)) - parseInt(b.substring(1)));
61
+ return {
62
+ name: config.d1,
63
+ data: vNames.map((r) => ({
64
+ name: config[r],
65
+ value: value[0]?.[r],
66
+ }))
67
+ };
68
+ });
69
+ return temData || [];
70
+ };
41
71
 
42
- export interface ChartComponentStyle {
72
+ export interface ComponentStyle {
43
73
  tooltip?: { show: boolean };
44
74
  color?: string[];
45
75
  grid?: { top: number, let: number, right: number, bottom: number };
@@ -49,29 +79,45 @@ export interface ChartComponentStyle {
49
79
  innerRadius?: number;
50
80
  label?: { [key: string]: any };
51
81
  labelLine?: { [key: string]: any };
82
+ roseType?: string; // 玫瑰图配置
52
83
  }
53
84
 
54
- export interface ChartComponentProps {
55
- style?: ChartComponentStyle;
56
- base: { width: number, height: number }
85
+ export interface ComponentProps {
86
+ style?: ComponentStyle;
87
+ base: { width: number, height: number },
88
+ data?: DataConfigProps;
89
+ isDesignMode?: boolean; // 是否编辑模式
57
90
  }
58
91
 
59
- export interface BaseTextComponentRef {
60
- updateConfig: (newConfig: ChartComponentProps) => void;
92
+ export interface ComponentRef {
93
+ updateConfig: (newConfig: ComponentProps) => void;
94
+ destroy: () => void;
61
95
  }
62
96
 
63
- const Index = forwardRef((props: ChartComponentProps, ref: ForwardedRef<BaseTextComponentRef>) => {
64
- const [config, setConfig] = useState<ChartComponentStyle>(props.style || {});
65
- const [size, setSize] = useState<{ width: number, height: number }>()
97
+ const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>) => {
98
+ const { style, data: propsData, isDesignMode } = props;
99
+ const [config, setConfig] = useState<ComponentStyle>(style || {});
100
+ const [size, setSize] = useState<{ width: number, height: number }>();
101
+ const [dataConfig, setDataConfig] = useState<DataConfigProps>({ ...propsData }); // 数据源配置
102
+ const [data, setData] = useState<{ name: string, data: any }[]>([]);
66
103
  const chartRef = useRef<HTMLDivElement>(null);
67
104
  const chart = useRef<any>(null);
105
+ const pollingIntervalRef = useRef<number | NodeJS.Timeout>(null);
106
+
107
+ const handleDestroy = () => {
108
+ pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
109
+ window.removeEventListener('resize', handleResize);
110
+ chart.current.dispose();
111
+ };
68
112
 
69
113
  useImperativeHandle(ref, () => ({
70
114
  updateConfig: (newConfig) => {
71
- const { base, style } = newConfig;
72
- setConfig({ ...(style || {}) });
115
+ const { base, style: newStyle, data: newDataConfig } = newConfig;
116
+ setConfig({ ...(newStyle || {}) });
73
117
  setSize({ width: base.width, height: base.height });
118
+ setDataConfig(newDataConfig);
74
119
  },
120
+ destroy: handleDestroy,
75
121
  }));
76
122
 
77
123
  // 窗口大小变化时重新调整图表大小
@@ -83,23 +129,63 @@ const Index = forwardRef((props: ChartComponentProps, ref: ForwardedRef<BaseText
83
129
  chart.current = echarts.init(chartRef.current);
84
130
  window.addEventListener('resize', handleResize);
85
131
  return () => {
86
- window.removeEventListener('resize', handleResize);
87
- chart.current.dispose();
132
+ handleDestroy();
88
133
  }
89
134
  }, []);
90
135
 
136
+ // 请求数据
137
+ const getData = async () => {
138
+ const { entities: { config, value } } = await HydrocarbonService.requestMstrucLtmplQueryTop(null, dataConfig?.sourceId, null) || {};
139
+ const temData = handleData(value);
140
+ setData(temData);
141
+ return config;
142
+ };
143
+
144
+ // 初始化请求数据
145
+ const getInitData = async () => {
146
+ pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
147
+ const config = await getData();
148
+ if (config?.requestType === "polling") {
149
+ pollingIntervalRef.current = setInterval(() => { getData() }, config?.pollingInterval || 60000);
150
+ }
151
+ };
152
+
153
+ // 静态数据处理
154
+ useEffect(() => {
155
+ if (dataConfig?.sourceType === 'staticData') {
156
+ setData(handleData(dataConfig.staticData));
157
+ }
158
+ }, [dataConfig?.sourceType, dataConfig?.staticData]);
159
+
160
+ /**
161
+ * 数据源数据请求
162
+ * 1、编辑态不请求数据
163
+ */
164
+ useEffect(() => {
165
+ if (!isDesignMode && dataConfig?.sourceType === 'sourceId' && dataConfig?.sourceId) {
166
+ getInitData();
167
+ } else if (dataConfig?.sourceType === 'sourceId') {
168
+ setData([]);
169
+ }
170
+ }, [dataConfig?.sourceType, dataConfig?.sourceId]);
171
+
91
172
  const renderChart = () => {
92
- const { legend, tooltip, radius, innerRadius, color, label, labelLine, padAngle } = config;
173
+ const { legend, tooltip, radius, innerRadius, color, label, labelLine, padAngle, roseType } = config;
93
174
  const option = _.cloneDeep(defOption);
175
+ // 编辑态无数据显示默认数据
176
+ const temData = isDesignMode && !data?.length ? option.series : data;
94
177
  option.legend = { ...legend, ...legends[legend?.position] };
95
178
  option.tooltip = { trigger: "item", ...tooltip };
96
179
  option.color = color;
97
- option.series = option.series.map((r) => ({
98
- ...r,
180
+ option.title.show = !temData?.length;
181
+ option.series = temData.map(r => ({
182
+ type: "pie",
99
183
  radius: [`${innerRadius}%`, `${radius}%`],
100
184
  padAngle,
101
185
  label,
102
- labelLine
186
+ labelLine,
187
+ roseType,
188
+ ...r
103
189
  }));
104
190
  chart.current.setOption(option, true);
105
191
  }
@@ -107,7 +193,7 @@ const Index = forwardRef((props: ChartComponentProps, ref: ForwardedRef<BaseText
107
193
  if (config) {
108
194
  renderChart();
109
195
  }
110
- }, [config]);
196
+ }, [config, data]);
111
197
 
112
198
  useEffect(() => {
113
199
  if (size) {
@@ -0,0 +1,29 @@
1
+ .text-scroller-container {
2
+ --speed: 10s;
3
+ --container-width: 320px;
4
+
5
+ width: 100%;
6
+ height: 100%;
7
+ overflow: hidden;
8
+ white-space: nowrap;
9
+ position: relative;
10
+
11
+ .text-scroller {
12
+ height: inherit;
13
+ position: absolute;
14
+ color: white;
15
+ animation: scrollText var(--speed) linear infinite;
16
+ display: flex;
17
+ align-items: center;
18
+ }
19
+
20
+ @keyframes scrollText {
21
+ 0% {
22
+ transform: translateX(var(--container-width));
23
+ }
24
+
25
+ 100% {
26
+ transform: translateX(-100%);
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,122 @@
1
+ import React, { forwardRef, ForwardedRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
2
+ import './index.less';
3
+ import _ from "lodash";
4
+ import HydrocarbonService from "../../tmpl/hcservice-v3";
5
+ import { DataConfigProps } from "../data";
6
+
7
+ export interface ComponentStyle {
8
+ speed?: number;
9
+ fontSize?: number;
10
+ color?: string;
11
+ fontFamily?: string;
12
+ fontWeight?: number;
13
+ defaultValue?: string;
14
+ }
15
+
16
+ export interface ComponentProps {
17
+ style?: ComponentStyle;
18
+ data?: DataConfigProps;
19
+ isDesignMode?: boolean; // 是否编辑模式
20
+ }
21
+
22
+ export interface ComponentRef {
23
+ updateConfig: (newConfig: ComponentProps) => void;
24
+ destroy: () => void;
25
+ }
26
+
27
+ const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>) => {
28
+ const { style, data: propsData, isDesignMode } = props;
29
+ const [config, setConfig] = useState<ComponentStyle>(style || {});
30
+ const [speed, setSpeed] = useState<number>(style?.speed || 5);
31
+ const [dataConfig, setDataConfig] = useState<DataConfigProps>({ ...propsData }); // 数据源配置
32
+ const [data, setData] = useState<string>('');
33
+ const textScrollerRef = useRef<HTMLDivElement>(null);
34
+ const textContainerRef = useRef<HTMLDivElement>(null);
35
+ const resizeObserverRef = useRef<ResizeObserver | null>(null);
36
+ const pollingIntervalRef = useRef<number | NodeJS.Timeout>(null);
37
+
38
+ const handleDestroy = () => {
39
+ resizeObserverRef.current && resizeObserverRef.current.disconnect();
40
+ pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
41
+ };
42
+
43
+ useImperativeHandle(ref, () => ({
44
+ updateConfig: (newConfig) => {
45
+ const { style: newStyle, data: newDataConfig } = newConfig;
46
+ setConfig({ ...(newStyle || {}) });
47
+ setSpeed(newStyle?.speed || 5);
48
+ setDataConfig({ ...newDataConfig });
49
+ },
50
+ destroy: handleDestroy,
51
+ }));
52
+
53
+ useEffect(() => {
54
+ if (textContainerRef.current) {
55
+ resizeObserverRef.current = new ResizeObserver(_.debounce((entries) => {
56
+ for (const entry of entries) {
57
+ const { width } = entry.contentRect;
58
+ textContainerRef.current.style.setProperty('--container-width', `${width}px`);
59
+ }
60
+ }, 100));
61
+ // 开始观察
62
+ resizeObserverRef.current.observe(textContainerRef.current);
63
+ }
64
+ return () => {
65
+ handleDestroy();
66
+ }
67
+ }, []);
68
+
69
+ useEffect(() => {
70
+ if (textContainerRef.current) {
71
+ textContainerRef.current.style.setProperty('--speed', `${speed || 5}s`);
72
+ }
73
+ }, [speed]);
74
+
75
+ // 请求数据
76
+ const getData = async () => {
77
+ const { entities: { config, value } } = await HydrocarbonService.requestMstrucLtmplQueryTop(null, dataConfig?.sourceId, null) || {};
78
+ const temData = value?.[0]?.value?.[0]?.v1;
79
+ setData(temData);
80
+ return config;
81
+ };
82
+
83
+ // 初始化请求数据
84
+ const getInitData = async () => {
85
+ pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
86
+ const config = await getData();
87
+ if (config?.requestType === "polling") {
88
+ pollingIntervalRef.current = setInterval(() => { getData() }, config?.pollingInterval || 60000);
89
+ }
90
+ };
91
+
92
+ // 静态数据处理
93
+ useEffect(() => {
94
+ if (dataConfig?.sourceType === 'staticData') {
95
+ const { value } = dataConfig.staticData || {};
96
+ setData(value);
97
+ }
98
+ }, [dataConfig?.sourceType, dataConfig?.staticData]);
99
+
100
+ /**
101
+ * 数据源数据请求
102
+ * 1、编辑态不请求数据
103
+ */
104
+ useEffect(() => {
105
+ if (!isDesignMode && dataConfig?.sourceType === 'sourceId' && dataConfig?.sourceId) {
106
+ getInitData();
107
+ } else if (dataConfig?.sourceType === 'sourceId') {
108
+ setData("文本跑马灯");
109
+ }
110
+ }, [dataConfig?.sourceType, dataConfig?.sourceId]);
111
+
112
+
113
+ return (
114
+ <div className="text-scroller-container" ref={textContainerRef}>
115
+ <div className="text-scroller" style={{ ...config }} ref={textScrollerRef}>
116
+ {data}
117
+ </div>
118
+ </div>
119
+ );
120
+ });
121
+
122
+ export default Index;
@@ -29,6 +29,7 @@ SupportInputTypes.add('timerange-unorder');
29
29
 
30
30
  SupportInputTypes.add('text');
31
31
  SupportInputTypes.add('textarea');
32
+ SupportInputTypes.add('text-view');
32
33
  SupportInputTypes.add('html');
33
34
  SupportInputTypes.add('steps');
34
35
  SupportInputTypes.add('progress');