lowcoder-comps 0.0.31 → 0.0.32

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 (86) hide show
  1. package/1e5cb9c2.js +447 -0
  2. package/24307cf2.js +25 -0
  3. package/256b619e.js +92 -0
  4. package/2b031be2.js +2967 -0
  5. package/2ff2c7a6.js +6 -0
  6. package/2ff7471d.js +9 -0
  7. package/444e09f1.js +268 -0
  8. package/4564a1bc.js +86 -0
  9. package/4a489df6.js +8 -0
  10. package/4a860f5d.js +505 -0
  11. package/4cc9caa5.js +2501 -0
  12. package/64d87c95.js +1536 -0
  13. package/6deaf0be.js +881 -0
  14. package/794e64d5.js +208 -0
  15. package/7a3f27e4.js +391 -0
  16. package/7ae6dd1c.js +319 -0
  17. package/92e85b65.js +65 -0
  18. package/97059d88.js +237 -0
  19. package/98955949.js +134435 -0
  20. package/a408f817.js +796 -0
  21. package/a40faea7.js +11624 -0
  22. package/a969f4ca.js +48428 -0
  23. package/aa1becc7.js +455 -0
  24. package/aa82b740.js +1269 -0
  25. package/c289b0aa.js +1102 -0
  26. package/c4d99b09.js +5 -0
  27. package/c9bb75eb.js +960 -0
  28. package/cb40fdd9.js +933 -0
  29. package/cc799554.js +1276 -0
  30. package/d3700d97.js +2284 -0
  31. package/d622fb26.js +818 -0
  32. package/d8c50a91.js +34 -0
  33. package/dce9fa3f.js +769 -0
  34. package/de8c90a7.js +1284 -0
  35. package/debd9490.js +819 -0
  36. package/df803461.js +220 -0
  37. package/e06dcfb0.js +1089 -0
  38. package/e6388bfd.js +915 -0
  39. package/ee801edf.js +804 -0
  40. package/f7c6b13d.js +19104 -0
  41. package/f8b68c1a.js +1127 -0
  42. package/f9637058.js +16 -0
  43. package/fcee2d3c.js +64 -0
  44. package/fd51bb2f.js +1579 -0
  45. package/index.js +5 -0
  46. package/package.json +4 -3
  47. package/README.md +0 -120
  48. package/index.html +0 -26
  49. package/index.tsx +0 -21
  50. package/jest.config.js +0 -6
  51. package/src/__test__/allComp.test.tsx +0 -61
  52. package/src/app-env.d.ts +0 -3
  53. package/src/comps/calendarComp/calendarComp.tsx +0 -633
  54. package/src/comps/calendarComp/calendarConstants.tsx +0 -1048
  55. package/src/comps/calendarComp/errorBoundary.tsx +0 -30
  56. package/src/comps/chartComp/chartComp.tsx +0 -442
  57. package/src/comps/chartComp/chartConfigs/barChartConfig.tsx +0 -51
  58. package/src/comps/chartComp/chartConfigs/cartesianAxisConfig.tsx +0 -307
  59. package/src/comps/chartComp/chartConfigs/chartUrls.tsx +0 -9
  60. package/src/comps/chartComp/chartConfigs/legendConfig.tsx +0 -55
  61. package/src/comps/chartComp/chartConfigs/lineChartConfig.tsx +0 -96
  62. package/src/comps/chartComp/chartConfigs/pieChartConfig.tsx +0 -83
  63. package/src/comps/chartComp/chartConfigs/scatterChartConfig.tsx +0 -62
  64. package/src/comps/chartComp/chartConstants.tsx +0 -299
  65. package/src/comps/chartComp/chartPropertyView.tsx +0 -235
  66. package/src/comps/chartComp/chartUtils.ts +0 -291
  67. package/src/comps/chartComp/reactEcharts/core.tsx +0 -194
  68. package/src/comps/chartComp/reactEcharts/index.ts +0 -21
  69. package/src/comps/chartComp/reactEcharts/types.ts +0 -76
  70. package/src/comps/chartComp/seriesComp.tsx +0 -119
  71. package/src/comps/imageEditorComp/imageEditorClass.tsx +0 -52
  72. package/src/comps/imageEditorComp/imageEditorConstants.tsx +0 -109
  73. package/src/comps/imageEditorComp/index.tsx +0 -184
  74. package/src/comps/mermaidComp/index.tsx +0 -44
  75. package/src/comps/mermaidComp/mermaid.tsx +0 -29
  76. package/src/global.ts +0 -1
  77. package/src/i18n/comps/index.tsx +0 -29
  78. package/src/i18n/comps/locales/en.ts +0 -163
  79. package/src/i18n/comps/locales/enObj.tsx +0 -198
  80. package/src/i18n/comps/locales/index.ts +0 -7
  81. package/src/i18n/comps/locales/types.tsx +0 -10
  82. package/src/i18n/comps/locales/zh.ts +0 -156
  83. package/src/i18n/comps/locales/zhObj.tsx +0 -4
  84. package/src/index.ts +0 -11
  85. package/tsconfig.json +0 -22
  86. package/vite.config.js +0 -10
@@ -1,299 +0,0 @@
1
- import {
2
- jsonControl,
3
- JSONObject,
4
- stateComp,
5
- toJSONObjectArray,
6
- toObject,
7
- BoolControl,
8
- withDefault,
9
- StringControl,
10
- NumberControl,
11
- FunctionControl,
12
- dropdownControl,
13
- eventHandlerControl,
14
- valueComp,
15
- withType,
16
- ValueFromOption,
17
- uiChildren,
18
- clickEvent,
19
- } from "lowcoder-sdk";
20
- import { RecordConstructorToComp, RecordConstructorToView } from "lowcoder-core";
21
- import { BarChartConfig } from "./chartConfigs/barChartConfig";
22
- import { XAxisConfig, YAxisConfig } from "./chartConfigs/cartesianAxisConfig";
23
- import { LegendConfig } from "./chartConfigs/legendConfig";
24
- import { LineChartConfig } from "./chartConfigs/lineChartConfig";
25
- import { PieChartConfig } from "./chartConfigs/pieChartConfig";
26
- import { ScatterChartConfig } from "./chartConfigs/scatterChartConfig";
27
- import { SeriesListComp } from "./seriesComp";
28
- import { EChartsOption } from "echarts";
29
- import { i18nObjs, trans } from "i18n/comps";
30
-
31
- export const ChartTypeOptions = [
32
- {
33
- label: trans("chart.bar"),
34
- value: "bar",
35
- },
36
- {
37
- label: trans("chart.line"),
38
- value: "line",
39
- },
40
- {
41
- label: trans("chart.scatter"),
42
- value: "scatter",
43
- },
44
- {
45
- label: trans("chart.pie"),
46
- value: "pie",
47
- },
48
- ] as const;
49
-
50
- const chartModeOptions = [
51
- {
52
- label: trans("chart.UIMode"),
53
- value: "ui",
54
- },
55
- {
56
- label: "ECharts JSON",
57
- value: "json",
58
- },
59
- {
60
- label: "Map",
61
- value: "map",
62
- },
63
- ] as const;
64
-
65
- export const UIEventOptions = [
66
- {
67
- label: trans("chart.select"),
68
- value: "select",
69
- description: trans("chart.selectDesc"),
70
- },
71
- {
72
- label: trans("chart.unSelect"),
73
- value: "unselect",
74
- description: trans("chart.unselectDesc"),
75
- },
76
- ] as const;
77
-
78
- export const MapEventOptions = [
79
- {
80
- label: trans("chart.mapReady"),
81
- value: "mapReady",
82
- description: trans("chart.mapReadyDesc"),
83
- },
84
- {
85
- label: trans("chart.zoomLevelChange"),
86
- value: "zoomLevelChange",
87
- description: trans("chart.zoomLevelChangeDesc"),
88
- },
89
- {
90
- label: trans("chart.centerPositionChange"),
91
- value: "centerPositionChange",
92
- description: trans("chart.centerPositionChangeDesc"),
93
- },
94
- ] as const;
95
-
96
- export const XAxisDirectionOptions = [
97
- {
98
- label: trans("chart.horizontal"),
99
- value: "horizontal",
100
- },
101
- {
102
- label: trans("chart.vertical"),
103
- value: "vertical",
104
- },
105
- ] as const;
106
-
107
- export type XAxisDirectionType = ValueFromOption<typeof XAxisDirectionOptions>;
108
-
109
- export const noDataAxisConfig = {
110
- animation: false,
111
- xAxis: {
112
- type: "category",
113
- name: trans("chart.noData"),
114
- nameLocation: "middle",
115
- data: [],
116
- axisLine: {
117
- lineStyle: {
118
- color: "#8B8FA3",
119
- },
120
- },
121
- },
122
- yAxis: {
123
- type: "value",
124
- axisLabel: {
125
- color: "#8B8FA3",
126
- },
127
- splitLine: {
128
- lineStyle: {
129
- color: "#F0F0F0",
130
- },
131
- },
132
- },
133
- tooltip: {
134
- show: false,
135
- },
136
- series: [
137
- {
138
- data: [700],
139
- type: "line",
140
- itemStyle: {
141
- opacity: 0,
142
- },
143
- },
144
- ],
145
- } as EChartsOption;
146
-
147
- export const noDataPieChartConfig = {
148
- animation: false,
149
- tooltip: {
150
- show: false,
151
- },
152
- legend: {
153
- formatter: trans("chart.unknown"),
154
- top: "bottom",
155
- selectedMode: false,
156
- },
157
- color: ["#B8BBCC", "#CED0D9", "#DCDEE6", "#E6E6EB"],
158
- series: [
159
- {
160
- type: "pie",
161
- radius: "35%",
162
- center: ["25%", "50%"],
163
- silent: true,
164
- label: {
165
- show: false,
166
- },
167
- data: [
168
- {
169
- name: "1",
170
- value: 70,
171
- },
172
- {
173
- name: "2",
174
- value: 68,
175
- },
176
- {
177
- name: "3",
178
- value: 48,
179
- },
180
- {
181
- name: "4",
182
- value: 40,
183
- },
184
- ],
185
- },
186
- {
187
- type: "pie",
188
- radius: "35%",
189
- center: ["75%", "50%"],
190
- silent: true,
191
- label: {
192
- show: false,
193
- },
194
- data: [
195
- {
196
- name: "1",
197
- value: 70,
198
- },
199
- {
200
- name: "2",
201
- value: 68,
202
- },
203
- {
204
- name: "3",
205
- value: 48,
206
- },
207
- {
208
- name: "4",
209
- value: 40,
210
- },
211
- ],
212
- },
213
- ],
214
- } as EChartsOption;
215
-
216
- export type ChartSize = { w: number; h: number };
217
-
218
- export const getDataKeys = (data: Array<JSONObject>) => {
219
- if (!data) {
220
- return [];
221
- }
222
- const dataKeys: Array<string> = [];
223
- data.slice(0, 50).forEach((d) => {
224
- Object.keys(d).forEach((key) => {
225
- if (!dataKeys.includes(key)) {
226
- dataKeys.push(key);
227
- }
228
- });
229
- });
230
- return dataKeys;
231
- };
232
-
233
- const ChartOptionMap = {
234
- bar: BarChartConfig,
235
- line: LineChartConfig,
236
- pie: PieChartConfig,
237
- scatter: ScatterChartConfig,
238
- };
239
-
240
- const ChartOptionComp = withType(ChartOptionMap, "bar");
241
- export type CharOptionCompType = keyof typeof ChartOptionMap;
242
-
243
- export const chartUiModeChildren = {
244
- title: StringControl,
245
- data: jsonControl(toJSONObjectArray, i18nObjs.defaultDataSource),
246
- xAxisKey: valueComp<string>(""), // x-axis, key from data
247
- xAxisDirection: dropdownControl(XAxisDirectionOptions, "horizontal"),
248
- series: SeriesListComp,
249
- xConfig: XAxisConfig,
250
- yConfig: YAxisConfig,
251
- legendConfig: LegendConfig,
252
- chartConfig: ChartOptionComp,
253
- onUIEvent: eventHandlerControl(UIEventOptions),
254
- };
255
-
256
- const chartJsonModeChildren = {
257
- echartsOption: jsonControl(toObject, i18nObjs.defaultEchartsJsonOption),
258
- }
259
-
260
- const chartMapModeChildren = {
261
- mapInstance: stateComp(),
262
- getMapInstance: FunctionControl,
263
- mapApiKey: withDefault(StringControl, ''),
264
- mapZoomLevel: withDefault(NumberControl, 3),
265
- mapCenterLng: withDefault(NumberControl, 15.932644),
266
- mapCenterLat: withDefault(NumberControl, 50.942063),
267
- mapOptions: jsonControl(toObject, i18nObjs.defaultMapJsonOption),
268
- onMapEvent: eventHandlerControl(MapEventOptions),
269
- showCharts: withDefault(BoolControl, true),
270
- }
271
-
272
- export type UIChartDataType = {
273
- seriesName: string;
274
- // coordinate chart
275
- x?: any;
276
- y?: any;
277
- // pie or funnel
278
- itemName?: any;
279
- value?: any;
280
- };
281
-
282
- export type NonUIChartDataType = {
283
- name: string;
284
- value: any;
285
- }
286
-
287
- export const chartChildrenMap = {
288
- mode: dropdownControl(chartModeOptions, "ui"),
289
- selectedPoints: stateComp<Array<UIChartDataType>>([]),
290
- lastInteractionData: stateComp<Array<UIChartDataType> | NonUIChartDataType>({}),
291
- onEvent: eventHandlerControl([clickEvent] as const),
292
- ...chartUiModeChildren,
293
- ...chartJsonModeChildren,
294
- ...chartMapModeChildren,
295
- };
296
-
297
- const chartUiChildrenMap = uiChildren(chartChildrenMap);
298
- export type ChartCompPropsType = RecordConstructorToView<typeof chartUiChildrenMap>;
299
- export type ChartCompChildrenType = RecordConstructorToComp<typeof chartUiChildrenMap>;
@@ -1,235 +0,0 @@
1
- import { changeChildAction, CompAction } from "lowcoder-core";
2
- import { ChartCompChildrenType, ChartTypeOptions, getDataKeys } from "./chartConstants";
3
- import { newSeries } from "./seriesComp";
4
- import {
5
- CustomModal,
6
- Dropdown,
7
- hiddenPropertyView,
8
- Option,
9
- RedButton,
10
- Section,
11
- sectionNames,
12
- controlItem,
13
- } from "lowcoder-sdk";
14
- import { trans } from "i18n/comps";
15
- import { examplesUrl, mapExamplesUrl, mapOptionUrl, optionUrl } from "./chartConfigs/chartUrls";
16
-
17
- export function chartPropertyView(
18
- children: ChartCompChildrenType,
19
- dispatch: (action: CompAction) => void
20
- ) {
21
- const series = children.series.getView();
22
- const columnOptions = getDataKeys(children.data.getView()).map((key) => ({
23
- label: key,
24
- value: key,
25
- }));
26
-
27
- const uiModePropertyView = (
28
- <>
29
- <Section name={trans("chart.data")}>
30
- {children.data.propertyView({
31
- label: trans("chart.data"),
32
- })}
33
- <Dropdown
34
- value={children.chartConfig.children.compType.getView()}
35
- options={ChartTypeOptions}
36
- label={trans("chart.chartType")}
37
- onChange={(value) => {
38
- // keep the previous value
39
- if (children.chartConfig.children.comp.children.hasOwnProperty("showLabel")) {
40
- children.chartConfig.dispatchChangeValueAction({
41
- compType: value as any,
42
- comp: {
43
- showLabel: (
44
- children.chartConfig.children.comp.children as any
45
- ).showLabel.toJsonValue(),
46
- },
47
- });
48
- } else {
49
- children.chartConfig.dispatchChangeValueAction({
50
- compType: value,
51
- });
52
- }
53
- }}
54
- />
55
- <Dropdown
56
- value={children.xAxisKey.getView()}
57
- options={columnOptions}
58
- label={trans("chart.xAxis")}
59
- onChange={(value) => {
60
- dispatch(changeChildAction("xAxisKey", value));
61
- }}
62
- />
63
- <Option
64
- items={series}
65
- title={trans("chart.chartSeries")}
66
- itemTitle={(s) => s.getView().seriesName}
67
- popoverTitle={(s) => s.getView().columnName}
68
- content={(s, index) => (
69
- <>
70
- {s.getPropertyViewWithData(columnOptions)}
71
- {
72
- <RedButton
73
- onClick={() => {
74
- CustomModal.confirm({
75
- title: trans("chart.delete"),
76
- content: trans("chart.confirmDelete") + `${s.getView().seriesName}?`,
77
- onConfirm: () =>
78
- children.series.dispatch(children.series.deleteAction(index)),
79
- confirmBtnType: "delete",
80
- okText: trans("chart.delete"),
81
- });
82
- }}
83
- >
84
- {trans("chart.delete")}
85
- </RedButton>
86
- }
87
- </>
88
- )}
89
- onAdd={() => {
90
- if (columnOptions.length <= 0) {
91
- return;
92
- }
93
- children.series.dispatch(
94
- children.series.pushAction(
95
- newSeries(trans("chart.customSeries"), columnOptions[0].value)
96
- )
97
- );
98
- }}
99
- onMove={(fromIndex, toIndex) => {
100
- const action = children.series.arrayMoveAction(fromIndex, toIndex);
101
- children.series.dispatch(action);
102
- }}
103
- hide={(s) => s.getView().hide}
104
- onHide={(s, hide) => s.children.hide.dispatchChangeValueAction(hide)}
105
- dataIndex={(s) => s.getView().dataIndex}
106
- />
107
- </Section>
108
- <Section name={sectionNames.interaction}>
109
- <div style={{display: 'flex', flexDirection: 'column', gap: '8px'}}>
110
- {children.onUIEvent.propertyView({title: trans("chart.chartEventHandlers")})}
111
- </div>
112
- {/* <div style={{display: 'flex', flexDirection: 'column', gap: '8px'}}>
113
- {children.onEvent.propertyView()}
114
- </div> */}
115
- </Section>
116
- <Section name={sectionNames.layout}>
117
- {children.title.propertyView({ label: trans("chart.title") })}
118
- {children.chartConfig.children.compType.getView() !== "pie" && (
119
- <>
120
- {children.xAxisDirection.propertyView({
121
- label: trans("chart.xAxisDirection"),
122
- radioButton: true,
123
- })}
124
- {children.xConfig.getPropertyView()}
125
- {children.yConfig.getPropertyView()}
126
- </>
127
- )}
128
- {children.legendConfig.getPropertyView()}
129
- {hiddenPropertyView(children)}
130
- </Section>
131
- <Section name={sectionNames.style}>{children.chartConfig.getPropertyView()}</Section>
132
- </>
133
- );
134
-
135
- const jsonModePropertyView = (
136
- <>
137
- <Section name={trans("chart.config")}>
138
- {children.echartsOption.propertyView({
139
- label: trans("chart.echartsOptionLabel"),
140
- styleName: "higher",
141
- tooltip: (
142
- <div>
143
- <a href={optionUrl} target="_blank" rel="noopener noreferrer">
144
- {trans("chart.echartsOptionTooltip")}
145
- </a>
146
- <br />
147
- <a href={examplesUrl} target="_blank" rel="noopener noreferrer">
148
- {trans("chart.echartsOptionExamples")}
149
- </a>
150
- </div>
151
- ),
152
- })}
153
- </Section>
154
- <Section name={sectionNames.interaction}>
155
- {children.onEvent.propertyView()}
156
- </Section>
157
- <Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
158
- </>
159
- );
160
-
161
- const mapModePropertyView = (
162
- <>
163
- <Section name={'Map Configuration'}>
164
- {children.mapApiKey.propertyView({
165
- label: "API Key"
166
- })}
167
- {children.mapZoomLevel.propertyView({
168
- label: "Zoom Level"
169
- })}
170
- {controlItem({}, (
171
- <b style={{marginTop: '8px'}}>
172
- {'Center Position'}
173
- </b>
174
- ))}
175
- {children.mapCenterLng.propertyView({
176
- label: "Longitude"
177
- })}
178
- {children.mapCenterLat.propertyView({
179
- label: "Latitude"
180
- })}
181
- {children.showCharts.propertyView({
182
- label: "Show Charts"
183
- })}
184
- </Section>
185
- <Section name={'Map Data'}>
186
- {children.mapOptions.propertyView({
187
- label: trans("chart.echartsOptionLabel"),
188
- styleName: "higher",
189
- tooltip: (
190
- <div>
191
- <a href={mapOptionUrl} target="_blank" rel="noopener noreferrer">
192
- {trans("chart.echartsMapOptionTooltip")}
193
- </a>
194
- <br />
195
- <a href={mapExamplesUrl} target="_blank" rel="noopener noreferrer">
196
- {trans("chart.echartsMapOptionExamples")}
197
- </a>
198
- </div>
199
- ),
200
- })}
201
- </Section>
202
- <Section name={sectionNames.interaction}>
203
- <div style={{display: 'flex', flexDirection: 'column', gap: '8px'}}>
204
- {children.onMapEvent.propertyView({title: trans("chart.chartEventHandlers")})}
205
- </div>
206
- <div style={{display: 'flex', flexDirection: 'column', gap: '8px'}}>
207
- {children.onEvent.propertyView()}
208
- </div>
209
- </Section>
210
- <Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
211
- </>
212
- );
213
-
214
- const getChatConfigByMode = (mode: string) => {
215
- switch(mode) {
216
- case "ui":
217
- return uiModePropertyView;
218
- case "json":
219
- return jsonModePropertyView;
220
- case "map":
221
- return mapModePropertyView;
222
- }
223
- }
224
- return (
225
- <>
226
- <Section name={trans("chart.mode")}>
227
- {children.mode.propertyView({
228
- label: "",
229
- radioButton: true,
230
- })}
231
- </Section>
232
- {getChatConfigByMode(children.mode.getView())}
233
- </>
234
- );
235
- }