lowcoder-comps 0.0.29 → 0.0.31
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/README.md +120 -0
- package/index.html +26 -0
- package/index.tsx +21 -0
- package/jest.config.js +6 -0
- package/package.json +3 -4
- package/src/__test__/allComp.test.tsx +61 -0
- package/src/app-env.d.ts +3 -0
- package/src/comps/calendarComp/calendarComp.tsx +633 -0
- package/src/comps/calendarComp/calendarConstants.tsx +1048 -0
- package/src/comps/calendarComp/errorBoundary.tsx +30 -0
- package/src/comps/chartComp/chartComp.tsx +442 -0
- package/src/comps/chartComp/chartConfigs/barChartConfig.tsx +51 -0
- package/src/comps/chartComp/chartConfigs/cartesianAxisConfig.tsx +307 -0
- package/src/comps/chartComp/chartConfigs/chartUrls.tsx +9 -0
- package/src/comps/chartComp/chartConfigs/legendConfig.tsx +55 -0
- package/src/comps/chartComp/chartConfigs/lineChartConfig.tsx +96 -0
- package/src/comps/chartComp/chartConfigs/pieChartConfig.tsx +83 -0
- package/src/comps/chartComp/chartConfigs/scatterChartConfig.tsx +62 -0
- package/src/comps/chartComp/chartConstants.tsx +299 -0
- package/src/comps/chartComp/chartPropertyView.tsx +235 -0
- package/src/comps/chartComp/chartUtils.ts +291 -0
- package/src/comps/chartComp/reactEcharts/core.tsx +194 -0
- package/src/comps/chartComp/reactEcharts/index.ts +21 -0
- package/src/comps/chartComp/reactEcharts/types.ts +76 -0
- package/src/comps/chartComp/seriesComp.tsx +119 -0
- package/src/comps/imageEditorComp/imageEditorClass.tsx +52 -0
- package/src/comps/imageEditorComp/imageEditorConstants.tsx +109 -0
- package/src/comps/imageEditorComp/index.tsx +184 -0
- package/src/comps/mermaidComp/index.tsx +44 -0
- package/src/comps/mermaidComp/mermaid.tsx +29 -0
- package/src/global.ts +1 -0
- package/src/i18n/comps/index.tsx +29 -0
- package/src/i18n/comps/locales/en.ts +163 -0
- package/src/i18n/comps/locales/enObj.tsx +198 -0
- package/src/i18n/comps/locales/index.ts +7 -0
- package/src/i18n/comps/locales/types.tsx +10 -0
- package/src/i18n/comps/locales/zh.ts +156 -0
- package/src/i18n/comps/locales/zhObj.tsx +4 -0
- package/src/index.ts +11 -0
- package/tsconfig.json +22 -0
- package/vite.config.js +10 -0
- package/2085da13.js +0 -960
- package/250691b5.js +0 -5
- package/256b619e.js +0 -92
- package/274f545c.js +0 -881
- package/289305a1.js +0 -208
- package/2eae45c2.js +0 -34
- package/2ff2c7a6.js +0 -6
- package/2ff7471d.js +0 -9
- package/335b22a2.js +0 -220
- package/38c826fe.js +0 -1127
- package/44011c1d.js +0 -818
- package/4fc06812.js +0 -64
- package/56a787cf.js +0 -915
- package/590941ff.js +0 -86
- package/6341867f.js +0 -804
- package/657fd065.js +0 -8
- package/78a5e50d.js +0 -1579
- package/820c3641.js +0 -25
- package/88b4e75a.js +0 -2967
- package/8d999722.js +0 -1102
- package/92e85b65.js +0 -65
- package/989caea2.js +0 -505
- package/99b984d1.js +0 -237
- package/9e5f02d6.js +0 -19104
- package/a40faea7.js +0 -11624
- package/abac9104.js +0 -1536
- package/af2f19b3.js +0 -819
- package/af5ee3de.js +0 -268
- package/b24707c2.js +0 -48428
- package/b68f8b69.js +0 -1276
- package/ba68ba65.js +0 -391
- package/bafb8599.js +0 -319
- package/bba60c35.js +0 -2501
- package/bd7c2a8e.js +0 -1089
- package/c71dadea.js +0 -455
- package/d05c1762.js +0 -933
- package/d073ab24.js +0 -134353
- package/d838cd10.js +0 -769
- package/dc36a6eb.js +0 -796
- package/ed143450.js +0 -1284
- package/ee8ec8f2.js +0 -2284
- package/f6755210.js +0 -1269
- package/f9637058.js +0 -16
- package/fba4c8e4.js +0 -447
- package/index.js +0 -5
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import TuiImageEditor from "tui-image-editor";
|
|
3
|
+
|
|
4
|
+
export class ImageEditor extends React.Component<any> {
|
|
5
|
+
rootEl = React.createRef<any>();
|
|
6
|
+
|
|
7
|
+
imageEditorInst: TuiImageEditor | undefined;
|
|
8
|
+
props: any;
|
|
9
|
+
constructor(props: any) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.props = props;
|
|
12
|
+
}
|
|
13
|
+
componentDidMount() {
|
|
14
|
+
if (this.rootEl.current !== null) {
|
|
15
|
+
this.imageEditorInst = new TuiImageEditor(this.rootEl.current, {
|
|
16
|
+
...(this.props as any),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
componentWillUnmount() {
|
|
22
|
+
if (this.imageEditorInst !== undefined) {
|
|
23
|
+
this.imageEditorInst.destroy();
|
|
24
|
+
|
|
25
|
+
this.imageEditorInst = undefined;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
shouldComponentUpdate(nextProps: any) {
|
|
30
|
+
if (
|
|
31
|
+
JSON.stringify([this.props.includeUI.menu, this.props.includeUI.loadImage]) !==
|
|
32
|
+
JSON.stringify([nextProps.includeUI.menu, nextProps.includeUI.loadImage])
|
|
33
|
+
) {
|
|
34
|
+
this.imageEditorInst = new TuiImageEditor(this.rootEl.current as any, {
|
|
35
|
+
...nextProps,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
getInstance() {
|
|
42
|
+
return this.imageEditorInst;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getRootElement() {
|
|
46
|
+
return this.rootEl.current;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
render() {
|
|
50
|
+
return <div ref={this.rootEl} />;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { default as Button } from "antd/es/button";
|
|
3
|
+
import { EventConfigType } from "lowcoder-sdk";
|
|
4
|
+
import { trans } from "i18n/comps";
|
|
5
|
+
|
|
6
|
+
export const saveEvent: EventConfigType = {
|
|
7
|
+
label: trans("imageEditor.save"),
|
|
8
|
+
value: "save",
|
|
9
|
+
description: trans("imageEditor.saveDesc"),
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const Container = styled.div`
|
|
13
|
+
height: 100%;
|
|
14
|
+
width: 100%;
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
.tui-image-editor-container.top .tui-image-editor-controls-logo {
|
|
19
|
+
display: none;
|
|
20
|
+
}
|
|
21
|
+
.tui-image-editor-container .tui-image-editor-header-logo,
|
|
22
|
+
.tui-image-editor-container .tui-image-editor-controls-logo {
|
|
23
|
+
display: none;
|
|
24
|
+
}
|
|
25
|
+
.tui-image-editor-container .tui-image-editor-header-buttons button,
|
|
26
|
+
.tui-image-editor-container .tui-image-editor-header-buttons div,
|
|
27
|
+
.tui-image-editor-container .tui-image-editor-controls-buttons button,
|
|
28
|
+
.tui-image-editor-container .tui-image-editor-controls-buttons div {
|
|
29
|
+
display: none;
|
|
30
|
+
}
|
|
31
|
+
.tie-btn-hand {
|
|
32
|
+
display: none !important;
|
|
33
|
+
}
|
|
34
|
+
.tui-image-editor-container .tui-image-editor-menu,
|
|
35
|
+
.tui-image-editor-container .tui-image-editor-help-menu {
|
|
36
|
+
background-color: #f3f4f6 !important;
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
export const EmbeddedButton = styled(Button)`
|
|
41
|
+
position: absolute;
|
|
42
|
+
right: 8px;
|
|
43
|
+
bottom: 4px;
|
|
44
|
+
z-index: 100;
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
export const customTheme = {
|
|
48
|
+
// image
|
|
49
|
+
"common.bi.image": "",
|
|
50
|
+
"common.bisize.width": "0px",
|
|
51
|
+
"common.bisize.height": "0px",
|
|
52
|
+
"common.backgroundImage": "none",
|
|
53
|
+
"common.backgroundColor": "#f3f4f6",
|
|
54
|
+
"common.border": "1px solid #444",
|
|
55
|
+
|
|
56
|
+
// header
|
|
57
|
+
"header.backgroundImage": "none",
|
|
58
|
+
"header.backgroundColor": "#f3f4f6",
|
|
59
|
+
"header.border": "0px",
|
|
60
|
+
"header.display": "none",
|
|
61
|
+
|
|
62
|
+
// icons default
|
|
63
|
+
"menu.normalIcon.color": "#8a8a8a",
|
|
64
|
+
"menu.activeIcon.color": "#555555",
|
|
65
|
+
"menu.disabledIcon.color": "#434343",
|
|
66
|
+
"menu.hoverIcon.color": "#e9e9e9",
|
|
67
|
+
"submenu.normalIcon.color": "#8a8a8a",
|
|
68
|
+
"submenu.activeIcon.color": "#e9e9e9",
|
|
69
|
+
|
|
70
|
+
"menu.iconSize.width": "24px",
|
|
71
|
+
"menu.iconSize.height": "24px",
|
|
72
|
+
"submenu.iconSize.width": "32px",
|
|
73
|
+
"submenu.iconSize.height": "32px",
|
|
74
|
+
|
|
75
|
+
// submenu primary color
|
|
76
|
+
"submenu.backgroundColor": "#1e1e1e",
|
|
77
|
+
"submenu.partition.color": "#858585",
|
|
78
|
+
|
|
79
|
+
// submenu labels
|
|
80
|
+
"submenu.normalLabel.color": "#858585",
|
|
81
|
+
"submenu.normalLabel.fontWeight": "lighter",
|
|
82
|
+
"submenu.activeLabel.color": "#fff",
|
|
83
|
+
"submenu.activeLabel.fontWeight": "lighter",
|
|
84
|
+
|
|
85
|
+
// checkbox style
|
|
86
|
+
"checkbox.border": "1px solid #ccc",
|
|
87
|
+
"checkbox.backgroundColor": "#fff",
|
|
88
|
+
|
|
89
|
+
// rango style
|
|
90
|
+
"range.pointer.color": "#fff",
|
|
91
|
+
"range.bar.color": "#666",
|
|
92
|
+
"range.subbar.color": "#d1d1d1",
|
|
93
|
+
|
|
94
|
+
"range.disabledPointer.color": "#414141",
|
|
95
|
+
"range.disabledBar.color": "#282828",
|
|
96
|
+
"range.disabledSubbar.color": "#414141",
|
|
97
|
+
|
|
98
|
+
"range.value.color": "#fff",
|
|
99
|
+
"range.value.fontWeight": "lighter",
|
|
100
|
+
"range.value.fontSize": "11px",
|
|
101
|
+
"range.value.border": "1px solid #353535",
|
|
102
|
+
"range.value.backgroundColor": "#151515",
|
|
103
|
+
"range.title.color": "#fff",
|
|
104
|
+
"range.title.fontWeight": "lighter",
|
|
105
|
+
|
|
106
|
+
// colorpicker style
|
|
107
|
+
"colorpicker.button.border": "1px solid #1e1e1e",
|
|
108
|
+
"colorpicker.title.color": "#fff",
|
|
109
|
+
};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BoolControl,
|
|
3
|
+
hiddenPropertyView,
|
|
4
|
+
NameConfig,
|
|
5
|
+
Section,
|
|
6
|
+
sectionNames,
|
|
7
|
+
StringStateControl,
|
|
8
|
+
UICompBuilder,
|
|
9
|
+
withDefault,
|
|
10
|
+
withExposingConfigs,
|
|
11
|
+
eventHandlerControl,
|
|
12
|
+
NameConfigHidden,
|
|
13
|
+
stringExposingStateControl,
|
|
14
|
+
} from "lowcoder-sdk";
|
|
15
|
+
import { useRef } from "react";
|
|
16
|
+
import ReactResizeDetector from "react-resize-detector";
|
|
17
|
+
import _ from "lodash";
|
|
18
|
+
import { RecordConstructorToView } from "lowcoder-core";
|
|
19
|
+
import { Container, customTheme, EmbeddedButton, saveEvent } from "./imageEditorConstants";
|
|
20
|
+
import { ImageEditor } from "./imageEditorClass";
|
|
21
|
+
import { i18nObjs, trans } from "i18n/comps";
|
|
22
|
+
|
|
23
|
+
const childrenMap = {
|
|
24
|
+
src: withDefault(StringStateControl, trans("imageEditor.defaultSrc")),
|
|
25
|
+
name: withDefault(StringStateControl, "Example"),
|
|
26
|
+
crop: withDefault(BoolControl, true),
|
|
27
|
+
flip: withDefault(BoolControl, true),
|
|
28
|
+
rotate: withDefault(BoolControl, true),
|
|
29
|
+
draw: withDefault(BoolControl, true),
|
|
30
|
+
shape: withDefault(BoolControl, true),
|
|
31
|
+
icon: withDefault(BoolControl, true),
|
|
32
|
+
text: withDefault(BoolControl, true),
|
|
33
|
+
mask: withDefault(BoolControl, true),
|
|
34
|
+
filter: withDefault(BoolControl, true),
|
|
35
|
+
dataURI: stringExposingStateControl("dataURI"),
|
|
36
|
+
data: stringExposingStateControl("data"),
|
|
37
|
+
onEvent: eventHandlerControl([saveEvent] as const),
|
|
38
|
+
buttonText: withDefault(StringStateControl, trans("imageEditor.save")),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const ContainerImageEditor = (props: RecordConstructorToView<typeof childrenMap>) => {
|
|
42
|
+
const editorRef = useRef<any>(null);
|
|
43
|
+
const conRef = useRef<HTMLDivElement>(null);
|
|
44
|
+
|
|
45
|
+
const menu = ["crop", "flip", "rotate", "draw", "shape", "icon", "text", "mask", "filter"];
|
|
46
|
+
const menuMap = new Map<string, boolean>();
|
|
47
|
+
menuMap.set("crop", props.crop);
|
|
48
|
+
menuMap.set("flip", props.flip);
|
|
49
|
+
menuMap.set("rotate", props.rotate);
|
|
50
|
+
menuMap.set("draw", props.draw);
|
|
51
|
+
menuMap.set("shape", props.shape);
|
|
52
|
+
menuMap.set("icon", props.icon);
|
|
53
|
+
menuMap.set("text", props.text);
|
|
54
|
+
menuMap.set("mask", props.mask);
|
|
55
|
+
menuMap.set("filter", props.filter);
|
|
56
|
+
let filteredMenu = menu.filter((ele) => {
|
|
57
|
+
return menuMap.get(ele);
|
|
58
|
+
});
|
|
59
|
+
const onResize = () => {
|
|
60
|
+
const editor = editorRef.current;
|
|
61
|
+
const container = conRef.current;
|
|
62
|
+
editor.imageEditorInst.ui.resizeEditor({
|
|
63
|
+
uiSize: { width: container?.clientWidth, height: container?.clientHeight },
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const saveImage = () => {
|
|
68
|
+
let imageEditorInst = editorRef.current.imageEditorInst;
|
|
69
|
+
let dataURL = imageEditorInst.toDataURL();
|
|
70
|
+
props.dataURI.onChange(dataURL);
|
|
71
|
+
props.data.onChange(dataURL.split(",")[1]);
|
|
72
|
+
};
|
|
73
|
+
return (
|
|
74
|
+
<Container ref={conRef}>
|
|
75
|
+
<EmbeddedButton
|
|
76
|
+
type="primary"
|
|
77
|
+
onClick={() => {
|
|
78
|
+
saveImage();
|
|
79
|
+
props.onEvent("save");
|
|
80
|
+
}}
|
|
81
|
+
>
|
|
82
|
+
{props.buttonText.value}
|
|
83
|
+
</EmbeddedButton>
|
|
84
|
+
<ReactResizeDetector onResize={onResize}>
|
|
85
|
+
<div style={{ width: "100%", height: "100%" }}>
|
|
86
|
+
<ImageEditor
|
|
87
|
+
ref={editorRef}
|
|
88
|
+
includeUI={{
|
|
89
|
+
loadImage: {
|
|
90
|
+
path: props.src.value,
|
|
91
|
+
name: props.name.value,
|
|
92
|
+
},
|
|
93
|
+
menu: filteredMenu,
|
|
94
|
+
theme: customTheme,
|
|
95
|
+
uiSize: {
|
|
96
|
+
width: "100%",
|
|
97
|
+
height: "100%",
|
|
98
|
+
},
|
|
99
|
+
menuBarPosition: "bottom",
|
|
100
|
+
locale: i18nObjs.imageEditorLocale ?? {},
|
|
101
|
+
}}
|
|
102
|
+
cssMaxWidth={document.documentElement.clientWidth}
|
|
103
|
+
cssMaxHeight={document.documentElement.clientHeight}
|
|
104
|
+
selectionStyle={{
|
|
105
|
+
cornerSize: 50,
|
|
106
|
+
rotatingPointOffset: 100,
|
|
107
|
+
}}
|
|
108
|
+
usageStatistics={false}
|
|
109
|
+
/>
|
|
110
|
+
</div>
|
|
111
|
+
</ReactResizeDetector>
|
|
112
|
+
</Container>
|
|
113
|
+
);
|
|
114
|
+
};
|
|
115
|
+
let ImageEditorBasicComp = (function () {
|
|
116
|
+
return new UICompBuilder(childrenMap, (props) => {
|
|
117
|
+
return <ContainerImageEditor {...props} />;
|
|
118
|
+
})
|
|
119
|
+
.setPropertyViewFn((children) => {
|
|
120
|
+
return (
|
|
121
|
+
<>
|
|
122
|
+
<Section name={sectionNames.basic}>
|
|
123
|
+
{children.src.propertyView({
|
|
124
|
+
label: trans("imageEditor.src"),
|
|
125
|
+
placeholder: "http://xxx.jpg",
|
|
126
|
+
})}
|
|
127
|
+
{children.name.propertyView({
|
|
128
|
+
label: trans("imageEditor.name"),
|
|
129
|
+
})}
|
|
130
|
+
{children.buttonText.propertyView({
|
|
131
|
+
label: trans("imageEditor.buttonText"),
|
|
132
|
+
})}
|
|
133
|
+
</Section>
|
|
134
|
+
<Section name={sectionNames.interaction}>{children.onEvent.getPropertyView()}</Section>
|
|
135
|
+
<Section name={sectionNames.advanced}>
|
|
136
|
+
{children.crop.propertyView({
|
|
137
|
+
label: "Crop",
|
|
138
|
+
})}
|
|
139
|
+
{children.flip.propertyView({
|
|
140
|
+
label: "Flip",
|
|
141
|
+
})}
|
|
142
|
+
{children.rotate.propertyView({
|
|
143
|
+
label: "Rotate",
|
|
144
|
+
})}
|
|
145
|
+
{children.draw.propertyView({
|
|
146
|
+
label: "Draw",
|
|
147
|
+
})}
|
|
148
|
+
{children.shape.propertyView({
|
|
149
|
+
label: "Shape",
|
|
150
|
+
})}
|
|
151
|
+
{children.icon.propertyView({
|
|
152
|
+
label: "Icon",
|
|
153
|
+
})}
|
|
154
|
+
{children.text.propertyView({
|
|
155
|
+
label: "Text",
|
|
156
|
+
})}
|
|
157
|
+
{children.mask.propertyView({
|
|
158
|
+
label: "Mask",
|
|
159
|
+
})}
|
|
160
|
+
{children.filter.propertyView({
|
|
161
|
+
label: "Filter",
|
|
162
|
+
})}
|
|
163
|
+
</Section>
|
|
164
|
+
<Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
|
|
165
|
+
</>
|
|
166
|
+
);
|
|
167
|
+
})
|
|
168
|
+
.build();
|
|
169
|
+
})();
|
|
170
|
+
|
|
171
|
+
ImageEditorBasicComp = class extends ImageEditorBasicComp {
|
|
172
|
+
override autoHeight(): boolean {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export const ImageEditorComp = withExposingConfigs(ImageEditorBasicComp, [
|
|
178
|
+
new NameConfig("src", trans("imageEditor.srcDesc")),
|
|
179
|
+
new NameConfig("name", trans("imageEditor.nameDesc")),
|
|
180
|
+
new NameConfig("dataURI", trans("imageEditor.dataURIDesc")),
|
|
181
|
+
new NameConfig("data", trans("imageEditor.dataDesc")),
|
|
182
|
+
new NameConfig("buttonText", trans("imageEditor.buttonTextDesc")),
|
|
183
|
+
NameConfigHidden,
|
|
184
|
+
]);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
UICompBuilder,
|
|
3
|
+
Section,
|
|
4
|
+
withExposingConfigs,
|
|
5
|
+
stringExposingStateControl,
|
|
6
|
+
NameConfig,
|
|
7
|
+
eventHandlerControl,
|
|
8
|
+
withMethodExposing,
|
|
9
|
+
} from "lowcoder-sdk";
|
|
10
|
+
|
|
11
|
+
import Mermaid from "./mermaid";
|
|
12
|
+
|
|
13
|
+
const childrenMap = {
|
|
14
|
+
code: stringExposingStateControl(
|
|
15
|
+
"code",
|
|
16
|
+
`graph LR
|
|
17
|
+
Start --> Stop`
|
|
18
|
+
),
|
|
19
|
+
onEvent: eventHandlerControl([
|
|
20
|
+
{
|
|
21
|
+
label: "onChange",
|
|
22
|
+
value: "change",
|
|
23
|
+
description: "",
|
|
24
|
+
},
|
|
25
|
+
]),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const CompBase = new UICompBuilder(childrenMap, (props: any) => {
|
|
29
|
+
const code = props.code.value;
|
|
30
|
+
return <Mermaid code={code} />;
|
|
31
|
+
})
|
|
32
|
+
.setPropertyViewFn((children: any) => {
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
<Section name="Basic">{children.code.propertyView({ label: "code" })}</Section>
|
|
36
|
+
<Section name="Interaction">{children.onEvent.propertyView()}</Section>
|
|
37
|
+
</>
|
|
38
|
+
);
|
|
39
|
+
})
|
|
40
|
+
.build();
|
|
41
|
+
|
|
42
|
+
const AppViewCompTemp = withMethodExposing(CompBase, []);
|
|
43
|
+
|
|
44
|
+
export const MermaidComp = withExposingConfigs(AppViewCompTemp, [new NameConfig("code", "")]);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import mermaid from "mermaid";
|
|
3
|
+
|
|
4
|
+
function escape(str: string): string {
|
|
5
|
+
const entries: { [index: string]: any } = { lt: "<", gt: ">", nbsp: " ", amp: "&", quot: '"' };
|
|
6
|
+
return str
|
|
7
|
+
.replace(/&(lt|gt|nbsp|amp|quot);/gi, function (_, t) {
|
|
8
|
+
return entries[t];
|
|
9
|
+
})
|
|
10
|
+
.trim();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default ({ id = "graphDiv", code = "" }) => {
|
|
14
|
+
const [svg, setSvg] = useState("");
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
mermaid.initialize({ startOnLoad: false });
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!code) return;
|
|
22
|
+
|
|
23
|
+
mermaid.mermaidAPI.render(id, escape(code)).then((res) => {
|
|
24
|
+
setSvg(res.svg);
|
|
25
|
+
});
|
|
26
|
+
}, [code, setSvg]);
|
|
27
|
+
|
|
28
|
+
return <pre className="mermaid" dangerouslySetInnerHTML={{ __html: svg }}></pre>;
|
|
29
|
+
};
|
package/src/global.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../../lowcoder/src/global";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getI18nObjects, getValueByLocale, Translator } from "lowcoder-core";
|
|
2
|
+
import * as localeData from "./locales";
|
|
3
|
+
import { I18nObjects } from "./locales/types";
|
|
4
|
+
|
|
5
|
+
export const { trans, language } = new Translator<typeof localeData.en>(
|
|
6
|
+
localeData,
|
|
7
|
+
REACT_APP_LANGUAGES
|
|
8
|
+
);
|
|
9
|
+
export const i18nObjs = getI18nObjects<I18nObjects>(localeData, REACT_APP_LANGUAGES);
|
|
10
|
+
|
|
11
|
+
export function getEchartsLocale() {
|
|
12
|
+
return getValueByLocale("EN", (locale) => {
|
|
13
|
+
switch (locale.language) {
|
|
14
|
+
case "en":
|
|
15
|
+
return "EN";
|
|
16
|
+
case "zh":
|
|
17
|
+
return "ZH";
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getCalendarLocale() {
|
|
23
|
+
switch (language) {
|
|
24
|
+
case "zh":
|
|
25
|
+
return "zh-cn";
|
|
26
|
+
default:
|
|
27
|
+
return "en-gb";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
export const en = {
|
|
2
|
+
chart: {
|
|
3
|
+
delete: "Delete",
|
|
4
|
+
data: "Data",
|
|
5
|
+
mode: "Mode",
|
|
6
|
+
config: "Configuration",
|
|
7
|
+
UIMode: "UI Mode",
|
|
8
|
+
chartType: "Chart Type",
|
|
9
|
+
xAxis: "X-axis",
|
|
10
|
+
chartSeries: "Chart Series",
|
|
11
|
+
customSeries: "Custom Series",
|
|
12
|
+
add: "Add",
|
|
13
|
+
confirmDelete: "Confirm Delete: ",
|
|
14
|
+
seriesName: "Series Name",
|
|
15
|
+
dataColumns: "Data Columns",
|
|
16
|
+
title: "Title",
|
|
17
|
+
xAxisDirection: "X-axis Direction",
|
|
18
|
+
xAxisName: "X-axis Name",
|
|
19
|
+
xAxisType: "X-axis Type",
|
|
20
|
+
xAxisTypeTooltip:
|
|
21
|
+
"Automatically detected based on X-axis data. For type description, refer to: ",
|
|
22
|
+
logBase: "Log Base",
|
|
23
|
+
yAxisName: "Y-axis Name",
|
|
24
|
+
yAxisType: "Y-axis Type",
|
|
25
|
+
yAxisDataFormat: "Y-axis Data Type",
|
|
26
|
+
yAxisDataFormatTooltip:
|
|
27
|
+
"Indicates the value of each coordinate. Example: '{{value * 100 + \"%\"}}'",
|
|
28
|
+
basicBar: "Basic Bar",
|
|
29
|
+
stackedBar: "Stacked Bar",
|
|
30
|
+
barType: "Bar Chart Type",
|
|
31
|
+
categoryAxis: "Category Axis",
|
|
32
|
+
valueAxis: "Value Axis",
|
|
33
|
+
timeAxis: "Time Axis",
|
|
34
|
+
logAxis: "Log Axis",
|
|
35
|
+
auto: "Default",
|
|
36
|
+
legendPosition: "Legend Position",
|
|
37
|
+
basicLine: "Basic Line",
|
|
38
|
+
stackedLine: "Stacked Line",
|
|
39
|
+
areaLine: "Area Line",
|
|
40
|
+
smooth: "Smooth Curve",
|
|
41
|
+
lineType: "Line Chart Type",
|
|
42
|
+
basicPie: "Basic Pie",
|
|
43
|
+
doughnutPie: "Doughnut Pie",
|
|
44
|
+
rosePie: "Rose Pie",
|
|
45
|
+
pieType: "Pie Chart Type",
|
|
46
|
+
spending: "Spending",
|
|
47
|
+
budget: "Budget",
|
|
48
|
+
bar: "Bar Chart",
|
|
49
|
+
line: "Line Chart",
|
|
50
|
+
scatter: "Scatter Chart",
|
|
51
|
+
pie: "Pie Chart",
|
|
52
|
+
horizontal: "Horizontal",
|
|
53
|
+
vertical: "Vertical",
|
|
54
|
+
noData: "No Data",
|
|
55
|
+
unknown: "Unknown",
|
|
56
|
+
select: "Select",
|
|
57
|
+
unSelect: "Unselect",
|
|
58
|
+
echartsOptionLabel: "Option",
|
|
59
|
+
echartsOptionTooltip: "ECharts Option",
|
|
60
|
+
echartsOptionExamples: "ECharts Examples",
|
|
61
|
+
echartsMapOptionTooltip: "ECharts Map Option",
|
|
62
|
+
echartsMapOptionExamples: "ECharts Map Examples",
|
|
63
|
+
selectDesc: "Triggered when a user selects part of the data in the chart",
|
|
64
|
+
unselectDesc:
|
|
65
|
+
"Triggered when a user unselects part of the data in the chart",
|
|
66
|
+
selectedPointsDesc: "Selected Points",
|
|
67
|
+
lastInteractionDataDesc: "Last Interaction Data",
|
|
68
|
+
dataDesc: "JSON Data for the Chart",
|
|
69
|
+
titleDesc: "Current Chart Title",
|
|
70
|
+
scatterShape: "Scatter Shape",
|
|
71
|
+
circle: "Circle",
|
|
72
|
+
rect: "Rectangle",
|
|
73
|
+
triangle: "Triangle",
|
|
74
|
+
diamond: "Diamond",
|
|
75
|
+
pin: "Pin",
|
|
76
|
+
arrow: "Arrow",
|
|
77
|
+
pointColorLabel: "Point Color",
|
|
78
|
+
pointColorTooltip:
|
|
79
|
+
'Set point color based on series name and value. Variables: seriesName, value. Example: \'{{value < 25000 ? "red" : "green"}}\'',
|
|
80
|
+
mapReady: "Map Ready",
|
|
81
|
+
mapReadyDesc: "Triggers when the map is ready",
|
|
82
|
+
zoomLevelChange: "Zoom Level Change",
|
|
83
|
+
zoomLevelChangeDesc: "Triggers when the map zoom level changes",
|
|
84
|
+
centerPositionChange: "Center Position Change",
|
|
85
|
+
centerPositionChangeDesc: "Triggers when the map center position changes",
|
|
86
|
+
chartEventHandlers: "Chart Event Handlers",
|
|
87
|
+
},
|
|
88
|
+
imageEditor: {
|
|
89
|
+
defaultSrc: "",
|
|
90
|
+
save: "Save",
|
|
91
|
+
saveDesc: "Save Image",
|
|
92
|
+
src: "Image Source",
|
|
93
|
+
name: "Image Name",
|
|
94
|
+
buttonText: "Button Text",
|
|
95
|
+
srcDesc: "Image Source",
|
|
96
|
+
nameDesc: "Image Name",
|
|
97
|
+
dataURIDesc: "Image Data URI",
|
|
98
|
+
dataDesc: "Image Data",
|
|
99
|
+
buttonTextDesc: "Button Text",
|
|
100
|
+
},
|
|
101
|
+
calendar: {
|
|
102
|
+
events: "Events Data",
|
|
103
|
+
resources: "Resources",
|
|
104
|
+
resourcesDefault: "Rooms",
|
|
105
|
+
resourcesName: "Resource Name",
|
|
106
|
+
resourcesEvents : "Resources Events Data",
|
|
107
|
+
editable: "Editable",
|
|
108
|
+
license: "Licence Key",
|
|
109
|
+
licenseTooltip: "Get your licence key from https://fullcalendar.io/purchase to enable premium views like Resource Timeline and Resource Grid.",
|
|
110
|
+
defaultDate: "Default Date",
|
|
111
|
+
defaultDateTooltip: "Initial display date of the calendar",
|
|
112
|
+
defaultView: "Default View",
|
|
113
|
+
defaultViewTooltip: "Initial view of the calendar",
|
|
114
|
+
showEventTime: "Show Event Times",
|
|
115
|
+
showEventTimeTooltip: "Display event time text",
|
|
116
|
+
showWeekends: "Show Weekends",
|
|
117
|
+
showAllDay: "Show All-Day",
|
|
118
|
+
showAllDayTooltip: "Display all-day slot in week and day views",
|
|
119
|
+
dayMaxEvents: "Day Max Events",
|
|
120
|
+
dayMaxEventsTooltip: "Max events per day in month view, 0 for cell height limit",
|
|
121
|
+
eventMaxStack: "Event Max Stack",
|
|
122
|
+
eventMaxStackTooltip: "Max events to stack horizontally in week and day views, 0 for no limit",
|
|
123
|
+
selectInterval: "Selected Interval",
|
|
124
|
+
selectEvent: "Selected Event",
|
|
125
|
+
changeSet: "Changed Event Object",
|
|
126
|
+
headerBtnBackground: "Button Background",
|
|
127
|
+
btnText: "Button Text",
|
|
128
|
+
title: "Title",
|
|
129
|
+
selectBackground: "Selected Background",
|
|
130
|
+
today: "Today",
|
|
131
|
+
month: "Month",
|
|
132
|
+
week: "Week",
|
|
133
|
+
weekdaygrid : "Days of Week",
|
|
134
|
+
daygrid : "Day Events List",
|
|
135
|
+
year: "Year",
|
|
136
|
+
day: "Day",
|
|
137
|
+
list: "Events List",
|
|
138
|
+
timeline: "Resource Timeline", //added by fred
|
|
139
|
+
resourceTimeGridDay: "Resource Grid", //added by fred
|
|
140
|
+
monday: "Monday",
|
|
141
|
+
tuesday: "Tuesday",
|
|
142
|
+
wednesday: "Wednesday",
|
|
143
|
+
thursday: "Thursday",
|
|
144
|
+
friday: "Friday",
|
|
145
|
+
saturday: "Saturday",
|
|
146
|
+
sunday: "Sunday",
|
|
147
|
+
startWeek: "Start From",
|
|
148
|
+
creatEvent: "Create Event",
|
|
149
|
+
editEvent: "Edit Event",
|
|
150
|
+
eventName: "Event Name",
|
|
151
|
+
eventColor: "Event Color",
|
|
152
|
+
eventGroupId: "Group ID",
|
|
153
|
+
groupIdTooltip: "Group ID groups events for drag and resize together.",
|
|
154
|
+
more: "More",
|
|
155
|
+
allDay: "All Day",
|
|
156
|
+
eventNameRequire: "Enter Event Name",
|
|
157
|
+
eventId: "Event ID",
|
|
158
|
+
eventIdRequire: "Enter Event ID",
|
|
159
|
+
eventIdTooltip: "Unique ID for each event",
|
|
160
|
+
eventIdExist: "ID Exists",
|
|
161
|
+
dragDropEventHandlers: "Drag/Drop Event Handlers",
|
|
162
|
+
},
|
|
163
|
+
};
|