bi-sdk-react 0.0.3 → 0.0.5
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/dist/es/css/bi-sdk.css +1 -1
- package/dist/es/js/bi-sdk.es.js +295 -67
- package/dist/types/components/PageDesigner.d.ts +9 -1
- package/dist/types/components/context/DesignerContext.d.ts +5 -2
- package/dist/types/components/context/EnvContext.d.ts +2 -1
- package/dist/types/components/icon/IconFont.d.ts +2 -1
- package/dist/types/components/layout/PageCanvas.d.ts +2 -0
- package/dist/types/components/panel/AiPanel.d.ts +4 -0
- package/dist/types/components/panel/ChatInput.d.ts +13 -6
- package/dist/types/components/panel/DatasetPanel.d.ts +11 -0
- package/dist/types/components/panel/PaneHeader.d.ts +1 -0
- package/dist/types/components/panel/PropertiesPanel.d.ts +3 -1
- package/dist/types/components/plugins/@antd/item-props/CheckboxProps.d.ts +3 -3
- package/dist/types/components/plugins/@antd/item-props/ColProps.d.ts +2 -2
- package/dist/types/components/plugins/@antd/item-props/EchartsProps.d.ts +2 -2
- package/dist/types/components/plugins/@antd/item-props/TextProps.d.ts +1 -0
- package/dist/types/components/plugins/@antd/items/TableRender.d.ts +1 -0
- package/dist/types/components/plugins/@antd/items/TextRender.d.ts +1 -0
- package/dist/types/components/typing.d.ts +97 -2
- package/dist/types/components/utils.d.ts +1 -0
- package/dist/umd/css/bi-sdk.css +1 -1
- package/dist/umd/js/bi-sdk.umd.min.js +299 -71
- package/package.json +1 -1
- package/src/components/PageDesigner.tsx +293 -35
- package/src/components/context/DesignerContext.tsx +15 -3
- package/src/components/context/EnvContext.tsx +4 -1
- package/src/components/icon/IconFont.tsx +15 -11
- package/src/components/layout/PageCanvas.tsx +4 -2
- package/src/components/layout/PageItem.tsx +1 -1
- package/src/components/panel/AiPanel.tsx +609 -43
- package/src/components/panel/ChatInput.tsx +322 -180
- package/src/components/panel/DatasetPanel.tsx +65 -0
- package/src/components/panel/PaneHeader.tsx +3 -2
- package/src/components/panel/PropertiesPanel.tsx +334 -127
- package/src/components/plugins/@antd/index.ts +12 -9
- package/src/components/plugins/@antd/item-props/CapsuleProps.tsx +1 -1
- package/src/components/plugins/@antd/item-props/CheckboxProps.tsx +90 -42
- package/src/components/plugins/@antd/item-props/ColProps.tsx +139 -25
- package/src/components/plugins/@antd/item-props/EchartsProps.tsx +52 -22
- package/src/components/plugins/@antd/item-props/HtmlProps.tsx +8 -9
- package/src/components/plugins/@antd/item-props/SelectProps.tsx +1 -1
- package/src/components/plugins/@antd/item-props/TextProps.tsx +14 -3
- package/src/components/plugins/@antd/items/EchartsRender.tsx +9 -1
- package/src/components/plugins/@antd/items/HtmlRender.tsx +13 -1
- package/src/components/plugins/@antd/items/ListRender.tsx +18 -1
- package/src/components/plugins/@antd/items/TableRender.tsx +16 -1
- package/src/components/plugins/@antd/items/TextRender.tsx +3 -1
- package/src/components/styles.css +20 -0
- package/src/components/typing.ts +111 -2
- package/src/components/utils.ts +40 -0
- package/src/example.tsx +314 -13
|
@@ -1,75 +1,123 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
Form,
|
|
4
|
+
Input,
|
|
5
|
+
Radio,
|
|
6
|
+
InputNumber,
|
|
7
|
+
Table,
|
|
8
|
+
Button,
|
|
9
|
+
Space,
|
|
10
|
+
Switch,
|
|
11
|
+
} from "antd";
|
|
12
|
+
import type { PropEditorProps } from "./types";
|
|
13
|
+
import { DeleteOutlined } from "@ant-design/icons";
|
|
5
14
|
|
|
6
|
-
export type CheckboxOption = { label: string; value: any }
|
|
15
|
+
export type CheckboxOption = { label: string; value: any };
|
|
7
16
|
export type CheckboxModel = {
|
|
8
|
-
var?: string
|
|
9
|
-
layout?:
|
|
10
|
-
lineNumber?: number
|
|
11
|
-
options: CheckboxOption[]
|
|
12
|
-
}
|
|
17
|
+
var?: string;
|
|
18
|
+
layout?: "horizontal" | "vertical" | "grid";
|
|
19
|
+
lineNumber?: number;
|
|
20
|
+
options: CheckboxOption[];
|
|
21
|
+
};
|
|
13
22
|
|
|
14
|
-
export const CheckboxProps: React.FC<PropEditorProps<CheckboxModel>> = ({
|
|
15
|
-
|
|
23
|
+
export const CheckboxProps: React.FC<PropEditorProps<CheckboxModel>> = ({
|
|
24
|
+
model,
|
|
25
|
+
onChange,
|
|
26
|
+
}) => {
|
|
27
|
+
const trigger = (key: keyof CheckboxModel, value: any) =>
|
|
28
|
+
onChange && onChange({ ...model, [key]: value });
|
|
16
29
|
const setOption = (index: number, key: keyof CheckboxOption, value: any) => {
|
|
17
|
-
const options = [...(model.options || [])]
|
|
18
|
-
options[index] = { ...options[index], [key]: value }
|
|
19
|
-
trigger(
|
|
20
|
-
}
|
|
30
|
+
const options = [...(model.options || [])];
|
|
31
|
+
options[index] = { ...options[index], [key]: value };
|
|
32
|
+
trigger("options", options);
|
|
33
|
+
};
|
|
21
34
|
const removeOption = (index: number) => {
|
|
22
|
-
const options = [...(model.options || [])]
|
|
23
|
-
options.splice(index, 1)
|
|
24
|
-
trigger(
|
|
25
|
-
}
|
|
35
|
+
const options = [...(model.options || [])];
|
|
36
|
+
options.splice(index, 1);
|
|
37
|
+
trigger("options", options);
|
|
38
|
+
};
|
|
26
39
|
const addOption = () => {
|
|
27
|
-
trigger(
|
|
28
|
-
}
|
|
40
|
+
trigger("options", [...(model.options || []), { label: "", value: "" }]);
|
|
41
|
+
};
|
|
29
42
|
const columns = [
|
|
30
43
|
{
|
|
31
|
-
title:
|
|
32
|
-
dataIndex:
|
|
33
|
-
render: (_: any, r: CheckboxOption, i: number) =>
|
|
44
|
+
title: "选项标签",
|
|
45
|
+
dataIndex: "label",
|
|
46
|
+
render: (_: any, r: CheckboxOption, i: number) => (
|
|
47
|
+
<Input
|
|
48
|
+
size="small"
|
|
49
|
+
value={r.label}
|
|
50
|
+
onChange={(e) => setOption(i, "label", e.target.value)}
|
|
51
|
+
/>
|
|
52
|
+
),
|
|
34
53
|
},
|
|
35
54
|
{
|
|
36
|
-
title:
|
|
37
|
-
dataIndex:
|
|
38
|
-
render: (_: any, r: CheckboxOption, i: number) =>
|
|
55
|
+
title: "选项值",
|
|
56
|
+
dataIndex: "value",
|
|
57
|
+
render: (_: any, r: CheckboxOption, i: number) => (
|
|
58
|
+
<Input
|
|
59
|
+
size="small"
|
|
60
|
+
value={r.value}
|
|
61
|
+
onChange={(e) => setOption(i, "value", e.target.value)}
|
|
62
|
+
/>
|
|
63
|
+
),
|
|
39
64
|
},
|
|
40
65
|
{
|
|
41
|
-
title:
|
|
66
|
+
title: "操作",
|
|
42
67
|
render: (_: any, r: CheckboxOption, i: number) => (
|
|
43
68
|
<Space>
|
|
44
69
|
<Button danger size="small" onClick={() => removeOption(i)}>
|
|
45
70
|
<DeleteOutlined />
|
|
46
71
|
</Button>
|
|
47
72
|
</Space>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
]
|
|
73
|
+
),
|
|
74
|
+
},
|
|
75
|
+
];
|
|
51
76
|
return (
|
|
52
77
|
<Form labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
|
|
53
78
|
<Form.Item label="变量名">
|
|
54
|
-
<Input
|
|
79
|
+
<Input
|
|
80
|
+
size="small"
|
|
81
|
+
value={model.var}
|
|
82
|
+
onChange={(e) => trigger("var", e.target.value)}
|
|
83
|
+
placeholder="请输入变量名"
|
|
84
|
+
/>
|
|
55
85
|
</Form.Item>
|
|
56
86
|
<Form.Item label="布局">
|
|
57
|
-
<Radio.Group
|
|
87
|
+
<Radio.Group
|
|
88
|
+
size="small"
|
|
89
|
+
value={model.layout}
|
|
90
|
+
onChange={(e) => trigger("layout", e.target.value)}
|
|
91
|
+
>
|
|
58
92
|
<Radio.Button value="horizontal">水平</Radio.Button>
|
|
59
93
|
<Radio.Button value="vertical">垂直</Radio.Button>
|
|
60
94
|
<Radio.Button value="grid">网格</Radio.Button>
|
|
61
95
|
</Radio.Group>
|
|
62
96
|
</Form.Item>
|
|
63
|
-
{model.layout ===
|
|
97
|
+
{model.layout === "grid" && (
|
|
64
98
|
<Form.Item label="网格行数">
|
|
65
|
-
<InputNumber
|
|
99
|
+
<InputNumber
|
|
100
|
+
size="small"
|
|
101
|
+
value={model.lineNumber}
|
|
102
|
+
onChange={(v) => trigger("lineNumber", v)}
|
|
103
|
+
min={1}
|
|
104
|
+
max={10}
|
|
105
|
+
/>
|
|
66
106
|
</Form.Item>
|
|
67
107
|
)}
|
|
68
|
-
<Form.Item>
|
|
69
|
-
<Table
|
|
70
|
-
|
|
108
|
+
<Form.Item labelCol={{ span: 24 }} wrapperCol={{ span: 24 }}>
|
|
109
|
+
<Table
|
|
110
|
+
size="small"
|
|
111
|
+
dataSource={model.options}
|
|
112
|
+
columns={columns as any}
|
|
113
|
+
pagination={false}
|
|
114
|
+
rowKey={(_, i) => String(i)}
|
|
115
|
+
bordered
|
|
116
|
+
/>
|
|
117
|
+
<Button size="small" block onClick={addOption}>
|
|
118
|
+
添加选项
|
|
119
|
+
</Button>
|
|
71
120
|
</Form.Item>
|
|
72
121
|
</Form>
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
|
|
122
|
+
);
|
|
123
|
+
};
|
|
@@ -1,43 +1,157 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Form, InputNumber, Tooltip } from
|
|
3
|
-
import type { PropEditorProps } from
|
|
4
|
-
import { InfoCircleOutlined } from
|
|
5
|
-
import styled from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Form, InputNumber, Tooltip } from "antd";
|
|
3
|
+
import type { PropEditorProps } from "./types";
|
|
4
|
+
import { InfoCircleOutlined } from "@ant-design/icons";
|
|
5
|
+
import styled from "styled-components";
|
|
6
6
|
|
|
7
7
|
const HelpIcon = styled(InfoCircleOutlined)`
|
|
8
8
|
vertical-align: middle;
|
|
9
9
|
margin-left: 2px;
|
|
10
10
|
color: var(--ant-color-text-description);
|
|
11
|
-
|
|
11
|
+
`;
|
|
12
12
|
|
|
13
|
-
export type ColModel = {
|
|
13
|
+
export type ColModel = {
|
|
14
|
+
span?: number;
|
|
15
|
+
xs?: number;
|
|
16
|
+
sm?: number;
|
|
17
|
+
md?: number;
|
|
18
|
+
lg?: number;
|
|
19
|
+
xl?: number;
|
|
20
|
+
xxl?: number;
|
|
21
|
+
};
|
|
14
22
|
|
|
15
|
-
export const ColProps: React.FC<PropEditorProps<ColModel>> = ({
|
|
16
|
-
|
|
23
|
+
export const ColProps: React.FC<PropEditorProps<ColModel>> = ({
|
|
24
|
+
model,
|
|
25
|
+
onChange,
|
|
26
|
+
}) => {
|
|
27
|
+
const trigger = (key: keyof ColModel, value: any) =>
|
|
28
|
+
onChange && onChange({ ...model, [key]: value });
|
|
17
29
|
return (
|
|
18
30
|
<Form labelCol={{ span: 12 }} wrapperCol={{ span: 12 }}>
|
|
19
31
|
<Form.Item label="默认列数">
|
|
20
|
-
<InputNumber
|
|
32
|
+
<InputNumber
|
|
33
|
+
size="small"
|
|
34
|
+
value={model.span}
|
|
35
|
+
min={0}
|
|
36
|
+
max={24}
|
|
37
|
+
step={4}
|
|
38
|
+
onChange={(v) => trigger("span", v || 0)}
|
|
39
|
+
/>
|
|
21
40
|
</Form.Item>
|
|
22
|
-
<Form.Item
|
|
23
|
-
|
|
41
|
+
<Form.Item
|
|
42
|
+
label={
|
|
43
|
+
<>
|
|
44
|
+
xs{" "}
|
|
45
|
+
<Tooltip title="<576px 响应式栅格">
|
|
46
|
+
<HelpIcon />
|
|
47
|
+
</Tooltip>
|
|
48
|
+
</>
|
|
49
|
+
}
|
|
50
|
+
>
|
|
51
|
+
<InputNumber
|
|
52
|
+
size="small"
|
|
53
|
+
value={model.xs}
|
|
54
|
+
min={0}
|
|
55
|
+
max={24}
|
|
56
|
+
step={4}
|
|
57
|
+
onChange={(v) => trigger("xs", v || 0)}
|
|
58
|
+
/>
|
|
24
59
|
</Form.Item>
|
|
25
|
-
<Form.Item
|
|
26
|
-
|
|
60
|
+
<Form.Item
|
|
61
|
+
label={
|
|
62
|
+
<>
|
|
63
|
+
sm{" "}
|
|
64
|
+
<Tooltip title="≥576px 响应式栅格">
|
|
65
|
+
<HelpIcon />
|
|
66
|
+
</Tooltip>
|
|
67
|
+
</>
|
|
68
|
+
}
|
|
69
|
+
>
|
|
70
|
+
<InputNumber
|
|
71
|
+
size="small"
|
|
72
|
+
value={model.sm}
|
|
73
|
+
min={0}
|
|
74
|
+
max={24}
|
|
75
|
+
step={4}
|
|
76
|
+
onChange={(v) => trigger("sm", v || 0)}
|
|
77
|
+
/>
|
|
27
78
|
</Form.Item>
|
|
28
|
-
<Form.Item
|
|
29
|
-
|
|
79
|
+
<Form.Item
|
|
80
|
+
label={
|
|
81
|
+
<>
|
|
82
|
+
md{" "}
|
|
83
|
+
<Tooltip title="≥768px 响应式栅格">
|
|
84
|
+
<HelpIcon />
|
|
85
|
+
</Tooltip>
|
|
86
|
+
</>
|
|
87
|
+
}
|
|
88
|
+
>
|
|
89
|
+
<InputNumber
|
|
90
|
+
size="small"
|
|
91
|
+
value={model.md}
|
|
92
|
+
min={0}
|
|
93
|
+
max={24}
|
|
94
|
+
step={4}
|
|
95
|
+
onChange={(v) => trigger("md", v || 0)}
|
|
96
|
+
/>
|
|
30
97
|
</Form.Item>
|
|
31
|
-
<Form.Item
|
|
32
|
-
|
|
98
|
+
<Form.Item
|
|
99
|
+
label={
|
|
100
|
+
<>
|
|
101
|
+
lg{" "}
|
|
102
|
+
<Tooltip title="≥992px 响应式栅格">
|
|
103
|
+
<HelpIcon />
|
|
104
|
+
</Tooltip>
|
|
105
|
+
</>
|
|
106
|
+
}
|
|
107
|
+
>
|
|
108
|
+
<InputNumber
|
|
109
|
+
size="small"
|
|
110
|
+
value={model.lg}
|
|
111
|
+
min={0}
|
|
112
|
+
max={24}
|
|
113
|
+
step={4}
|
|
114
|
+
onChange={(v) => trigger("lg", v || 0)}
|
|
115
|
+
/>
|
|
33
116
|
</Form.Item>
|
|
34
|
-
<Form.Item
|
|
35
|
-
|
|
117
|
+
<Form.Item
|
|
118
|
+
label={
|
|
119
|
+
<>
|
|
120
|
+
xl{" "}
|
|
121
|
+
<Tooltip title="≥1200px 响应式栅格">
|
|
122
|
+
<HelpIcon />
|
|
123
|
+
</Tooltip>
|
|
124
|
+
</>
|
|
125
|
+
}
|
|
126
|
+
>
|
|
127
|
+
<InputNumber
|
|
128
|
+
size="small"
|
|
129
|
+
value={model.xl}
|
|
130
|
+
min={0}
|
|
131
|
+
max={24}
|
|
132
|
+
step={4}
|
|
133
|
+
onChange={(v) => trigger("xl", v || 0)}
|
|
134
|
+
/>
|
|
36
135
|
</Form.Item>
|
|
37
|
-
<Form.Item
|
|
38
|
-
|
|
136
|
+
<Form.Item
|
|
137
|
+
label={
|
|
138
|
+
<>
|
|
139
|
+
xxl{" "}
|
|
140
|
+
<Tooltip title="≥1600px 响应式栅格">
|
|
141
|
+
<HelpIcon />
|
|
142
|
+
</Tooltip>
|
|
143
|
+
</>
|
|
144
|
+
}
|
|
145
|
+
>
|
|
146
|
+
<InputNumber
|
|
147
|
+
size="small"
|
|
148
|
+
value={model.xxl}
|
|
149
|
+
min={0}
|
|
150
|
+
max={24}
|
|
151
|
+
step={4}
|
|
152
|
+
onChange={(v) => trigger("xxl", v || 0)}
|
|
153
|
+
/>
|
|
39
154
|
</Form.Item>
|
|
40
155
|
</Form>
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
|
|
156
|
+
);
|
|
157
|
+
};
|
|
@@ -1,35 +1,65 @@
|
|
|
1
|
-
import React, { useRef } from
|
|
2
|
-
import { Form } from
|
|
3
|
-
import Editor from
|
|
4
|
-
import type { PropEditorProps } from
|
|
1
|
+
import React, { useRef } from "react";
|
|
2
|
+
import { Form } from "antd";
|
|
3
|
+
import Editor from "@monaco-editor/react";
|
|
4
|
+
import type { PropEditorProps } from "./types";
|
|
5
|
+
import { IconFont } from "../../../icon/IconFont";
|
|
5
6
|
|
|
6
|
-
export type EchartsModel = { script: string }
|
|
7
|
+
export type EchartsModel = { script: string };
|
|
7
8
|
|
|
8
|
-
export const EchartsProps: React.FC<PropEditorProps<EchartsModel>> = ({
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
export const EchartsProps: React.FC<PropEditorProps<EchartsModel>> = ({
|
|
10
|
+
model,
|
|
11
|
+
onChange,
|
|
12
|
+
}) => {
|
|
13
|
+
const ref = useRef<any>(null);
|
|
14
|
+
const setScript = (v?: string) =>
|
|
15
|
+
onChange && onChange({ ...model, script: v || "" });
|
|
11
16
|
const format = () => {
|
|
12
17
|
// Monaco-react does not expose format directly; relying on editor action
|
|
13
|
-
const editor = (ref.current as any)?.editor
|
|
14
|
-
editor?.getAction(
|
|
15
|
-
}
|
|
18
|
+
const editor = (ref.current as any)?.editor;
|
|
19
|
+
editor?.getAction("editor.action.formatDocument")?.run();
|
|
20
|
+
};
|
|
16
21
|
return (
|
|
17
|
-
<Form
|
|
18
|
-
<Form.Item
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
<Form layout="vertical">
|
|
23
|
+
<Form.Item
|
|
24
|
+
label={
|
|
25
|
+
<>
|
|
26
|
+
Echarts 渲染脚本{" "}
|
|
27
|
+
<a onClick={format}>
|
|
28
|
+
<IconFont type="icon-formate" /> 格式化
|
|
29
|
+
</a>
|
|
30
|
+
</>
|
|
31
|
+
}
|
|
32
|
+
className="ant-form-item-label-space"
|
|
33
|
+
>
|
|
34
|
+
<div
|
|
35
|
+
style={{
|
|
36
|
+
border: "1px solid #d9d9d9",
|
|
37
|
+
borderRadius: 4,
|
|
38
|
+
textAlign: "left",
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
<div style={{ color: "#0000ff", fontSize: 14, padding: "0 50px" }}>
|
|
42
|
+
function getOptions(data) {"{"}{" "}
|
|
43
|
+
</div>
|
|
21
44
|
<Editor
|
|
22
|
-
onMount={(editor) => {
|
|
45
|
+
onMount={(editor) => {
|
|
46
|
+
(ref.current as any) = { editor };
|
|
47
|
+
}}
|
|
23
48
|
height="400px"
|
|
24
49
|
defaultLanguage="javascript"
|
|
25
50
|
value={model.script}
|
|
26
|
-
onChange={(v) => setScript(v ||
|
|
27
|
-
options={{
|
|
51
|
+
onChange={(v) => setScript(v || "")}
|
|
52
|
+
options={{
|
|
53
|
+
minimap: { enabled: false },
|
|
54
|
+
scrollBeyondLastLine: false,
|
|
55
|
+
tabSize: 2,
|
|
56
|
+
}}
|
|
28
57
|
/>
|
|
29
|
-
<div style={{ color:
|
|
58
|
+
<div style={{ color: "#0000ff", fontSize: 14, padding: "0 50px" }}>
|
|
59
|
+
{"}"}
|
|
60
|
+
</div>
|
|
30
61
|
</div>
|
|
31
62
|
</Form.Item>
|
|
32
63
|
</Form>
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
|
|
64
|
+
);
|
|
65
|
+
};
|
|
@@ -2,6 +2,7 @@ import React, { useRef } from "react";
|
|
|
2
2
|
import { Form } from "antd";
|
|
3
3
|
import Editor from "@monaco-editor/react";
|
|
4
4
|
import type { PropEditorProps } from "./types";
|
|
5
|
+
import { IconFont } from "../../../icon/IconFont";
|
|
5
6
|
|
|
6
7
|
export type HtmlModel = { template: string };
|
|
7
8
|
|
|
@@ -21,16 +22,14 @@ export const HtmlProps: React.FC<PropEditorProps<HtmlModel>> = ({
|
|
|
21
22
|
<Form layout="vertical">
|
|
22
23
|
<Form.Item
|
|
23
24
|
label={
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
>
|
|
31
|
-
模板 <a onClick={format}>格式化</a>
|
|
32
|
-
</div>
|
|
25
|
+
<>
|
|
26
|
+
模板
|
|
27
|
+
<a onClick={format}>
|
|
28
|
+
<IconFont type="icon-formate" /> 格式化
|
|
29
|
+
</a>
|
|
30
|
+
</>
|
|
33
31
|
}
|
|
32
|
+
className="ant-form-item-label-space"
|
|
34
33
|
>
|
|
35
34
|
<div
|
|
36
35
|
style={{
|
|
@@ -118,7 +118,7 @@ export const SelectProps: React.FC<PropEditorProps<SelectModel>> = ({
|
|
|
118
118
|
onChange={(v) => trigger("multiple", v)}
|
|
119
119
|
/>
|
|
120
120
|
</Form.Item>
|
|
121
|
-
<Form.Item>
|
|
121
|
+
<Form.Item labelCol={{ span: 24 }} wrapperCol={{ span: 24 }}>
|
|
122
122
|
<Table
|
|
123
123
|
size="small"
|
|
124
124
|
dataSource={model.options}
|
|
@@ -2,7 +2,11 @@ import React from "react";
|
|
|
2
2
|
import { Form, Input, Select, Button, Space, ColorPicker } from "antd";
|
|
3
3
|
import type { PropEditorProps } from "./types";
|
|
4
4
|
|
|
5
|
-
export type TextModel = {
|
|
5
|
+
export type TextModel = {
|
|
6
|
+
text?: string;
|
|
7
|
+
customStyle?: React.CSSProperties;
|
|
8
|
+
classNames?: string[];
|
|
9
|
+
};
|
|
6
10
|
|
|
7
11
|
export const TextProps: React.FC<PropEditorProps<TextModel>> = ({
|
|
8
12
|
model,
|
|
@@ -15,7 +19,7 @@ export const TextProps: React.FC<PropEditorProps<TextModel>> = ({
|
|
|
15
19
|
onChange && onChange({ ...model, customStyle: next } as any);
|
|
16
20
|
};
|
|
17
21
|
return (
|
|
18
|
-
<Form>
|
|
22
|
+
<Form layout="vertical">
|
|
19
23
|
<Form.Item label="文本内容">
|
|
20
24
|
<Input.TextArea
|
|
21
25
|
size="small"
|
|
@@ -23,6 +27,14 @@ export const TextProps: React.FC<PropEditorProps<TextModel>> = ({
|
|
|
23
27
|
onChange={(e) => triggerModel("text", e.target.value)}
|
|
24
28
|
/>
|
|
25
29
|
</Form.Item>
|
|
30
|
+
<Form.Item label="类名">
|
|
31
|
+
<Select
|
|
32
|
+
size="small"
|
|
33
|
+
value={model.classNames}
|
|
34
|
+
mode="tags"
|
|
35
|
+
onChange={(value) => triggerModel("classNames", value)}
|
|
36
|
+
/>
|
|
37
|
+
</Form.Item>
|
|
26
38
|
<div
|
|
27
39
|
style={{
|
|
28
40
|
display: "flex",
|
|
@@ -72,7 +84,6 @@ export const TextProps: React.FC<PropEditorProps<TextModel>> = ({
|
|
|
72
84
|
size="small"
|
|
73
85
|
value={model.customStyle?.color}
|
|
74
86
|
onChange={(v) => setStyle("color", v.toHexString())}
|
|
75
|
-
style={{ width: 90 }}
|
|
76
87
|
allowClear={true}
|
|
77
88
|
/>
|
|
78
89
|
</Space.Compact>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
1
|
+
import React, { useContext, useEffect, useRef, useState } from "react";
|
|
2
2
|
import * as echarts from "echarts";
|
|
3
3
|
import { HtmlBaseProps } from "../../../typing";
|
|
4
4
|
import { useDatasource } from "../../../hooks/datasource";
|
|
5
|
+
import { EnvContext } from "../../../context/EnvContext";
|
|
6
|
+
import { getVars } from "../../../utils";
|
|
5
7
|
|
|
6
8
|
export type EchartsRenderProps = {
|
|
7
9
|
item: any;
|
|
@@ -19,6 +21,7 @@ export const EchartsRender: React.FC<EchartsRenderProps> = ({
|
|
|
19
21
|
style,
|
|
20
22
|
className,
|
|
21
23
|
}) => {
|
|
24
|
+
const { initCallback, env } = useContext(EnvContext);
|
|
22
25
|
const chartRef = useRef<HTMLDivElement | null>(null);
|
|
23
26
|
const [chart, setChart] = useState<echarts.ECharts | null>(null);
|
|
24
27
|
const datasource = useDatasource(id, item.datasource);
|
|
@@ -68,12 +71,17 @@ export const EchartsRender: React.FC<EchartsRenderProps> = ({
|
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
};
|
|
74
|
+
const callback = () => {
|
|
75
|
+
const vars = getVars(env, item);
|
|
76
|
+
console.log("callback echarts", vars);
|
|
77
|
+
};
|
|
71
78
|
useEffect(() => {
|
|
72
79
|
if (!chartRef.current) return;
|
|
73
80
|
const next = echarts.init(chartRef.current);
|
|
74
81
|
setChart(next);
|
|
75
82
|
const onResize = () => next.resize();
|
|
76
83
|
window.addEventListener("resize", onResize);
|
|
84
|
+
initCallback({ id: item.id, callback });
|
|
77
85
|
return () => {
|
|
78
86
|
window.removeEventListener("resize", onResize);
|
|
79
87
|
next.dispose();
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import React, { useMemo } from "react";
|
|
1
|
+
import React, { useContext, useEffect, useMemo } from "react";
|
|
2
2
|
import { HtmlBaseProps } from "../../../typing";
|
|
3
3
|
import { useDatasource } from "../../../hooks/datasource";
|
|
4
|
+
import { getVars } from "../../../utils";
|
|
5
|
+
import { EnvContext } from "../../../context/EnvContext";
|
|
4
6
|
|
|
5
7
|
export type HtmlRenderProps = {
|
|
6
8
|
dataSource?: Record<string, any>;
|
|
@@ -27,6 +29,7 @@ export const HtmlRender: React.FC<HtmlRenderProps> = ({
|
|
|
27
29
|
style,
|
|
28
30
|
className,
|
|
29
31
|
}) => {
|
|
32
|
+
const { env, initCallback } = useContext(EnvContext);
|
|
30
33
|
const datasource = useDatasource(id, item.datasource);
|
|
31
34
|
const keys = useMemo(() => Object.keys(datasource || {}), [datasource]);
|
|
32
35
|
const func = (path: string) =>
|
|
@@ -63,6 +66,15 @@ export const HtmlRender: React.FC<HtmlRenderProps> = ({
|
|
|
63
66
|
[template, args]
|
|
64
67
|
);
|
|
65
68
|
|
|
69
|
+
const callback = () => {
|
|
70
|
+
const vars = getVars(env, item);
|
|
71
|
+
console.log("callback html", vars);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
initCallback({ id: item.id, callback });
|
|
76
|
+
}, []);
|
|
77
|
+
|
|
66
78
|
return (
|
|
67
79
|
<div
|
|
68
80
|
id={id}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
MouseEventHandler,
|
|
3
|
+
useContext,
|
|
4
|
+
useEffect,
|
|
5
|
+
useMemo,
|
|
6
|
+
} from "react";
|
|
2
7
|
import { Avatar, Pagination } from "antd";
|
|
3
8
|
import styled, { css } from "styled-components";
|
|
4
9
|
import { HtmlBaseProps } from "../../../typing";
|
|
5
10
|
import { useDatasource } from "../../../hooks/datasource";
|
|
11
|
+
import { getVars } from "../../../utils";
|
|
12
|
+
import { EnvContext } from "../../../context/EnvContext";
|
|
6
13
|
|
|
7
14
|
type DataItem = {
|
|
8
15
|
title?: string;
|
|
@@ -184,6 +191,7 @@ export const ListRender: React.FC<ListRenderProps> = ({
|
|
|
184
191
|
style = {},
|
|
185
192
|
className,
|
|
186
193
|
}) => {
|
|
194
|
+
const { env, initCallback } = useContext(EnvContext);
|
|
187
195
|
const datasource = useDatasource(id, item.datasource);
|
|
188
196
|
const list = datasource || [];
|
|
189
197
|
const pagination = useMemo(() => {
|
|
@@ -208,6 +216,15 @@ export const ListRender: React.FC<ListRenderProps> = ({
|
|
|
208
216
|
bordered ? "p-list--bordered" : undefined,
|
|
209
217
|
className,
|
|
210
218
|
];
|
|
219
|
+
|
|
220
|
+
const callback = () => {
|
|
221
|
+
const vars = getVars(env, item);
|
|
222
|
+
console.log("callback list", vars);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
useEffect(() => {
|
|
226
|
+
initCallback({ id: item.id, callback });
|
|
227
|
+
}, []);
|
|
211
228
|
return (
|
|
212
229
|
<div
|
|
213
230
|
id={id}
|