bi-sdk-react 0.0.1

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 (146) hide show
  1. package/dist/es/css/bi-sdk.css +1 -0
  2. package/dist/es/js/bi-sdk.es.js +795 -0
  3. package/dist/es/js/bi-sdk.es.js.LICENSE.txt +9 -0
  4. package/dist/types/components/PageDesigner.d.ts +10 -0
  5. package/dist/types/components/context/DesignerContext.d.ts +15 -0
  6. package/dist/types/components/context/EnvContext.d.ts +15 -0
  7. package/dist/types/components/dnd/DropContainer.d.ts +21 -0
  8. package/dist/types/components/example.d.ts +225 -0
  9. package/dist/types/components/hooks/datasource.d.ts +1 -0
  10. package/dist/types/components/hooks/useDeepCompareEffect.d.ts +1 -0
  11. package/dist/types/components/icon/IconFont.d.ts +6 -0
  12. package/dist/types/components/index.d.ts +10 -0
  13. package/dist/types/components/layout/PageCanvas.d.ts +6 -0
  14. package/dist/types/components/layout/PageItem.d.ts +27 -0
  15. package/dist/types/components/panel/AiPanel.d.ts +8 -0
  16. package/dist/types/components/panel/CascadePanel.d.ts +2 -0
  17. package/dist/types/components/panel/ChatInput.d.ts +28 -0
  18. package/dist/types/components/panel/CodePanel.d.ts +2 -0
  19. package/dist/types/components/panel/ComponentPanel.d.ts +2 -0
  20. package/dist/types/components/panel/DatasourcePanel.d.ts +2 -0
  21. package/dist/types/components/panel/LayerPanel.d.ts +2 -0
  22. package/dist/types/components/panel/PaneHeader.d.ts +6 -0
  23. package/dist/types/components/panel/PropertiesPanel.d.ts +2 -0
  24. package/dist/types/components/panel/ScriptPanel.d.ts +2 -0
  25. package/dist/types/components/panel/VariablesPanel.d.ts +2 -0
  26. package/dist/types/components/panel/index.d.ts +9 -0
  27. package/dist/types/components/plugins/@antd/index.d.ts +22 -0
  28. package/dist/types/components/plugins/@antd/item-props/ButtonProps.d.ts +8 -0
  29. package/dist/types/components/plugins/@antd/item-props/CapsuleProps.d.ts +13 -0
  30. package/dist/types/components/plugins/@antd/item-props/CardProps.d.ts +8 -0
  31. package/dist/types/components/plugins/@antd/item-props/CheckboxProps.d.ts +13 -0
  32. package/dist/types/components/plugins/@antd/item-props/ColProps.d.ts +12 -0
  33. package/dist/types/components/plugins/@antd/item-props/DatePickerProps.d.ts +8 -0
  34. package/dist/types/components/plugins/@antd/item-props/EchartsProps.d.ts +6 -0
  35. package/dist/types/components/plugins/@antd/item-props/HtmlProps.d.ts +6 -0
  36. package/dist/types/components/plugins/@antd/item-props/ImageProps.d.ts +10 -0
  37. package/dist/types/components/plugins/@antd/item-props/InputNumberProps.d.ts +9 -0
  38. package/dist/types/components/plugins/@antd/item-props/InputProps.d.ts +10 -0
  39. package/dist/types/components/plugins/@antd/item-props/ListProps.d.ts +10 -0
  40. package/dist/types/components/plugins/@antd/item-props/PageHeaderProps.d.ts +7 -0
  41. package/dist/types/components/plugins/@antd/item-props/RowProps.d.ts +6 -0
  42. package/dist/types/components/plugins/@antd/item-props/SelectProps.d.ts +16 -0
  43. package/dist/types/components/plugins/@antd/item-props/SpaceProps.d.ts +7 -0
  44. package/dist/types/components/plugins/@antd/item-props/SwitchProps.d.ts +6 -0
  45. package/dist/types/components/plugins/@antd/item-props/TableProps.d.ts +15 -0
  46. package/dist/types/components/plugins/@antd/item-props/TextProps.d.ts +6 -0
  47. package/dist/types/components/plugins/@antd/item-props/index.d.ts +19 -0
  48. package/dist/types/components/plugins/@antd/item-props/types.d.ts +5 -0
  49. package/dist/types/components/plugins/@antd/items/ButtonRender.d.ts +14 -0
  50. package/dist/types/components/plugins/@antd/items/CapsuleRender.d.ts +14 -0
  51. package/dist/types/components/plugins/@antd/items/CardRender.d.ts +12 -0
  52. package/dist/types/components/plugins/@antd/items/CheckboxRender.d.ts +14 -0
  53. package/dist/types/components/plugins/@antd/items/ColRender.d.ts +13 -0
  54. package/dist/types/components/plugins/@antd/items/DatePickerRender.d.ts +14 -0
  55. package/dist/types/components/plugins/@antd/items/EchartsRender.d.ts +10 -0
  56. package/dist/types/components/plugins/@antd/items/HtmlRender.d.ts +20 -0
  57. package/dist/types/components/plugins/@antd/items/ImageRender.d.ts +10 -0
  58. package/dist/types/components/plugins/@antd/items/InputNumberRender.d.ts +17 -0
  59. package/dist/types/components/plugins/@antd/items/InputRender.d.ts +17 -0
  60. package/dist/types/components/plugins/@antd/items/ListRender.d.ts +11 -0
  61. package/dist/types/components/plugins/@antd/items/PageHeaderRender.d.ts +8 -0
  62. package/dist/types/components/plugins/@antd/items/RowRender.d.ts +13 -0
  63. package/dist/types/components/plugins/@antd/items/SelectRender.d.ts +18 -0
  64. package/dist/types/components/plugins/@antd/items/SpaceRender.d.ts +10 -0
  65. package/dist/types/components/plugins/@antd/items/SwitchRender.d.ts +14 -0
  66. package/dist/types/components/plugins/@antd/items/TableRender.d.ts +12 -0
  67. package/dist/types/components/plugins/@antd/items/TextRender.d.ts +9 -0
  68. package/dist/types/components/plugins/@antd/items/index.d.ts +19 -0
  69. package/dist/types/components/typing.d.ts +80 -0
  70. package/dist/types/components/utils.d.ts +9 -0
  71. package/dist/types/example.d.ts +2 -0
  72. package/dist/types/index.d.ts +1 -0
  73. package/dist/umd/css/bi-sdk.css +1 -0
  74. package/dist/umd/js/bi-sdk.umd.min.js +795 -0
  75. package/dist/umd/js/bi-sdk.umd.min.js.LICENSE.txt +9 -0
  76. package/package.json +52 -0
  77. package/src/components/PageDesigner.tsx +509 -0
  78. package/src/components/context/DesignerContext.tsx +71 -0
  79. package/src/components/context/EnvContext.tsx +42 -0
  80. package/src/components/dnd/DropContainer.tsx +474 -0
  81. package/src/components/example.ts +577 -0
  82. package/src/components/hooks/datasource.ts +23 -0
  83. package/src/components/hooks/useDeepCompareEffect.ts +12 -0
  84. package/src/components/icon/IconFont.tsx +16 -0
  85. package/src/components/index.ts +29 -0
  86. package/src/components/layout/PageCanvas.tsx +145 -0
  87. package/src/components/layout/PageItem.tsx +182 -0
  88. package/src/components/panel/AiPanel.tsx +116 -0
  89. package/src/components/panel/CascadePanel.tsx +163 -0
  90. package/src/components/panel/ChatInput.tsx +550 -0
  91. package/src/components/panel/CodePanel.tsx +48 -0
  92. package/src/components/panel/ComponentPanel.tsx +119 -0
  93. package/src/components/panel/DatasourcePanel.tsx +419 -0
  94. package/src/components/panel/LayerPanel.tsx +238 -0
  95. package/src/components/panel/PaneHeader.tsx +34 -0
  96. package/src/components/panel/PropertiesPanel.tsx +394 -0
  97. package/src/components/panel/ScriptPanel.tsx +175 -0
  98. package/src/components/panel/VariablesPanel.tsx +153 -0
  99. package/src/components/panel/index.ts +9 -0
  100. package/src/components/plugins/@antd/index.ts +445 -0
  101. package/src/components/plugins/@antd/item-props/ButtonProps.tsx +91 -0
  102. package/src/components/plugins/@antd/item-props/CapsuleProps.tsx +102 -0
  103. package/src/components/plugins/@antd/item-props/CardProps.tsx +58 -0
  104. package/src/components/plugins/@antd/item-props/CheckboxProps.tsx +75 -0
  105. package/src/components/plugins/@antd/item-props/ColProps.tsx +43 -0
  106. package/src/components/plugins/@antd/item-props/DatePickerProps.tsx +72 -0
  107. package/src/components/plugins/@antd/item-props/EchartsProps.tsx +35 -0
  108. package/src/components/plugins/@antd/item-props/HtmlProps.tsx +61 -0
  109. package/src/components/plugins/@antd/item-props/ImageProps.tsx +43 -0
  110. package/src/components/plugins/@antd/item-props/InputNumberProps.tsx +18 -0
  111. package/src/components/plugins/@antd/item-props/InputProps.tsx +89 -0
  112. package/src/components/plugins/@antd/item-props/ListProps.tsx +69 -0
  113. package/src/components/plugins/@antd/item-props/PageHeaderProps.tsx +20 -0
  114. package/src/components/plugins/@antd/item-props/RowProps.tsx +21 -0
  115. package/src/components/plugins/@antd/item-props/SelectProps.tsx +136 -0
  116. package/src/components/plugins/@antd/item-props/SpaceProps.tsx +52 -0
  117. package/src/components/plugins/@antd/item-props/SwitchProps.tsx +17 -0
  118. package/src/components/plugins/@antd/item-props/TableProps.tsx +200 -0
  119. package/src/components/plugins/@antd/item-props/TextProps.tsx +41 -0
  120. package/src/components/plugins/@antd/item-props/index.ts +20 -0
  121. package/src/components/plugins/@antd/item-props/types.ts +6 -0
  122. package/src/components/plugins/@antd/items/ButtonRender.tsx +63 -0
  123. package/src/components/plugins/@antd/items/CapsuleRender.tsx +49 -0
  124. package/src/components/plugins/@antd/items/CardRender.tsx +119 -0
  125. package/src/components/plugins/@antd/items/CheckboxRender.tsx +56 -0
  126. package/src/components/plugins/@antd/items/ColRender.tsx +78 -0
  127. package/src/components/plugins/@antd/items/DatePickerRender.tsx +117 -0
  128. package/src/components/plugins/@antd/items/EchartsRender.tsx +98 -0
  129. package/src/components/plugins/@antd/items/HtmlRender.tsx +74 -0
  130. package/src/components/plugins/@antd/items/ImageRender.tsx +37 -0
  131. package/src/components/plugins/@antd/items/InputNumberRender.tsx +57 -0
  132. package/src/components/plugins/@antd/items/InputRender.tsx +75 -0
  133. package/src/components/plugins/@antd/items/ListRender.tsx +227 -0
  134. package/src/components/plugins/@antd/items/PageHeaderRender.tsx +74 -0
  135. package/src/components/plugins/@antd/items/RowRender.tsx +47 -0
  136. package/src/components/plugins/@antd/items/SelectRender.tsx +53 -0
  137. package/src/components/plugins/@antd/items/SpaceRender.tsx +54 -0
  138. package/src/components/plugins/@antd/items/SwitchRender.tsx +52 -0
  139. package/src/components/plugins/@antd/items/TableRender.tsx +99 -0
  140. package/src/components/plugins/@antd/items/TextRender.tsx +25 -0
  141. package/src/components/plugins/@antd/items/index.ts +20 -0
  142. package/src/components/styles.css +12 -0
  143. package/src/components/typing.ts +80 -0
  144. package/src/components/utils.ts +37 -0
  145. package/src/example.tsx +136 -0
  146. package/src/index.tsx +17 -0
@@ -0,0 +1,153 @@
1
+ import React, { useContext, useMemo } from "react";
2
+ import styled from "styled-components";
3
+ import { Table, Button, Space, Popconfirm, Modal, Form, Input } from "antd";
4
+ import { PaneHeader } from "./PaneHeader";
5
+ import { DeleteOutlined, EditOutlined } from "@ant-design/icons";
6
+ import { IconFont } from "../icon/IconFont";
7
+ import { DesignerContext } from "../context/DesignerContext";
8
+ import { VariableItem } from "../typing";
9
+
10
+
11
+ const Root = styled.div`
12
+ display: flex;
13
+ flex-direction: column;
14
+ height: 100%;
15
+ .body {
16
+ flex: 1 1 auto;
17
+ display: flex;
18
+ flex-direction: column;
19
+ gap: 12px;
20
+ padding: 12px;
21
+ }
22
+ `;
23
+
24
+ export const VariablesPanel: React.FC = () => {
25
+ const {schema, setSchema} = useContext(DesignerContext);
26
+ const [visible, setVisible] = React.useState(false);
27
+ const [editIndex, setEditIndex] = React.useState(-1);
28
+ const [form] = Form.useForm<VariableItem>();
29
+ const list = useMemo(() => schema.variables || [], [schema.variables]);
30
+ const onUpdateVariables = (data: VariableItem[]) => {
31
+ setSchema({ ...schema, variables: data });
32
+ };
33
+ const columns = [
34
+ {
35
+ title: "名称",
36
+ dataIndex: "name",
37
+ render: (t: string, r: VariableItem) => (
38
+ <div title={t}>
39
+ <IconFont type="icon-drag" /> {t}
40
+ </div>
41
+ ),
42
+ },
43
+ { title: "值", dataIndex: "value" },
44
+ {
45
+ title: "操作",
46
+ width: 60,
47
+ align: "center" as const,
48
+ render: (_: any, r: VariableItem, index: number) => (
49
+ <Space>
50
+ <a
51
+ onClick={() => {
52
+ setEditIndex(index);
53
+ form.setFieldsValue({ name: r.name, value: r.value });
54
+ setVisible(true);
55
+ }}
56
+ >
57
+ <EditOutlined />
58
+ </a>
59
+ <Popconfirm
60
+ title="确认删除吗?"
61
+ okText="确认"
62
+ cancelText="取消"
63
+ onConfirm={() => {
64
+ const next = [...list];
65
+ next.splice(index, 1);
66
+ onUpdateVariables && onUpdateVariables(next);
67
+ }}
68
+ >
69
+ <a>
70
+ <DeleteOutlined />
71
+ </a>
72
+ </Popconfirm>
73
+ </Space>
74
+ ),
75
+ },
76
+ ];
77
+ const handleOk = async () => {
78
+ const vals = await form.validateFields().catch(() => null);
79
+ if (!vals) return;
80
+ const next = [...list];
81
+ if (editIndex === -1) next.push({ ...vals });
82
+ else next[editIndex] = { ...next[editIndex], ...vals };
83
+ onUpdateVariables && onUpdateVariables(next);
84
+ setVisible(false);
85
+ setEditIndex(-1);
86
+ form.resetFields();
87
+ };
88
+ return (
89
+ <Root>
90
+ <PaneHeader
91
+ title="环境变量"
92
+ extra={
93
+ <Space>
94
+ <a
95
+ className="toolbar"
96
+ onClick={() => {
97
+ setEditIndex(-1);
98
+ form.resetFields();
99
+ setVisible(true);
100
+ }}
101
+ >
102
+ +
103
+ </a>
104
+ </Space>
105
+ }
106
+ />
107
+ <div className="body">
108
+ <Table
109
+ rowKey={(r) => r.id || r.name}
110
+ dataSource={list}
111
+ columns={columns as any}
112
+ pagination={false}
113
+ size="small"
114
+ locale={{ emptyText: "暂无环境变量" }}
115
+ />
116
+ </div>
117
+ <Modal
118
+ title="添加环境变量"
119
+ open={visible}
120
+ width={600}
121
+ styles={{
122
+ body: { maxHeight: "calc(100vh - 250px)", overflow: "auto" }
123
+ }}
124
+ onCancel={() => setVisible(false)}
125
+ footer={
126
+ <Space>
127
+ <Button type="primary" onClick={handleOk}>
128
+ 确定
129
+ </Button>
130
+ <Button onClick={() => setVisible(false)}>取消</Button>
131
+ </Space>
132
+ }
133
+ >
134
+ <Form form={form} layout="vertical">
135
+ <Form.Item
136
+ label="环境变量名称"
137
+ name="name"
138
+ rules={[{ required: true, message: "请输入环境变量名称" }]}
139
+ >
140
+ <Input />
141
+ </Form.Item>
142
+ <Form.Item
143
+ label="环境变量值"
144
+ name="value"
145
+ rules={[{ required: true, message: "请输入环境变量值" }]}
146
+ >
147
+ <Input />
148
+ </Form.Item>
149
+ </Form>
150
+ </Modal>
151
+ </Root>
152
+ );
153
+ };
@@ -0,0 +1,9 @@
1
+ export { ComponentPanel } from './ComponentPanel'
2
+ export { LayerPanel } from './LayerPanel'
3
+ export { ScriptPanel } from './ScriptPanel'
4
+ export { DatasourcePanel } from './DatasourcePanel'
5
+ export { VariablesPanel } from './VariablesPanel'
6
+ export { CodePanel } from './CodePanel'
7
+ export { PropertiesPanel } from './PropertiesPanel'
8
+ export { AiPanel } from './AiPanel'
9
+ export { CascadePanel } from './CascadePanel'
@@ -0,0 +1,445 @@
1
+ import { PluginType } from "../../typing";
2
+
3
+ export { PropEditorProps } from "./item-props/types";
4
+
5
+ import {
6
+ ButtonProps,
7
+ CapsuleProps,
8
+ CardProps,
9
+ CheckboxProps,
10
+ ColProps,
11
+ DatePickerProps,
12
+ EchartsProps,
13
+ HtmlProps,
14
+ ImageProps,
15
+ InputNumberProps,
16
+ InputProps,
17
+ ListProps,
18
+ PageHeaderProps,
19
+ RowProps,
20
+ SelectProps,
21
+ SpaceProps,
22
+ SwitchProps,
23
+ TableProps,
24
+ TextProps,
25
+ } from "./item-props";
26
+ import {
27
+ ButtonRender,
28
+ CapsuleRender,
29
+ CardRender,
30
+ CheckboxRender,
31
+ ColRender,
32
+ DatePickerRender,
33
+ EchartsRender,
34
+ HtmlRender,
35
+ ImageRender,
36
+ InputNumberRender,
37
+ InputRender,
38
+ ListRender,
39
+ PageHeaderRender,
40
+ RowRender,
41
+ SelectRender,
42
+ SpaceRender,
43
+ SwitchRender,
44
+ TableRender,
45
+ TextRender,
46
+ } from "./items";
47
+
48
+ export const TextPlugin: PluginType = {
49
+ group: "基础组件",
50
+ key: "b-text",
51
+ label: "文本",
52
+ icon: "icon-text",
53
+ component: TextRender,
54
+ formComponent: TextProps,
55
+ defaultOptions: {
56
+ style: {
57
+ fontSize: 14,
58
+ color: "#444444",
59
+ fontFamily: "'宋体', 'SimSun', serif",
60
+ fontWeight: "normal",
61
+ fontStyle: "normal",
62
+ textDecoration: "none",
63
+ },
64
+ props: { text: "文本内容" },
65
+ },
66
+ };
67
+
68
+ export const ImagePlugin: PluginType = {
69
+ group: "基础组件",
70
+ key: "b-image",
71
+ label: "图片",
72
+ icon: "icon-image",
73
+ component: ImageRender,
74
+ formComponent: ImageProps,
75
+ defaultOptions: {
76
+ props: {
77
+ src: "https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png",
78
+ alt: "",
79
+ href: "",
80
+ width: "100%",
81
+ height: "auto",
82
+ },
83
+ },
84
+ };
85
+
86
+ export const ButtonPlugin: PluginType = {
87
+ group: "基础组件",
88
+ key: "b-button",
89
+ label: "按钮",
90
+ icon: "icon-button",
91
+ component: ButtonRender,
92
+ formComponent: ButtonProps,
93
+ defaultOptions: {
94
+ props: {
95
+ type: "primary",
96
+ size: "default",
97
+ shape: "default",
98
+ block: false,
99
+ ghost: false,
100
+ text: "按钮文本",
101
+ icon: "",
102
+ },
103
+ cascadeIds: [],
104
+ },
105
+ };
106
+
107
+ export const PageHeaderPlugin: PluginType = {
108
+ group: "基础组件",
109
+ key: "b-page-header",
110
+ label: "页面标题",
111
+ icon: "icon-page-header",
112
+ component: PageHeaderRender,
113
+ formComponent: PageHeaderProps,
114
+ defaultOptions: {
115
+ props: { title: "标题", subTitle: "副标题" },
116
+ children: { extra: [] },
117
+ },
118
+ };
119
+
120
+ export const TablePlugin: PluginType = {
121
+ group: "基础组件",
122
+ key: "b-table",
123
+ label: "数据表格",
124
+ icon: "icon-table",
125
+ component: TableRender,
126
+ formComponent: TableProps,
127
+ defaultOptions: {
128
+ datasource: {
129
+ source: "custom",
130
+ datasourceId: null,
131
+ scriptId: null,
132
+ custom: null,
133
+ },
134
+ props: {
135
+ size: "default",
136
+ bordered: true,
137
+ showHeader: true,
138
+ pageSize: 10,
139
+ dataSource: [
140
+ { name: "苹果", count: 12 },
141
+ { name: "华为", count: 803 },
142
+ { name: "OPPO", count: 654 },
143
+ { name: "vivo", count: 719 },
144
+ ],
145
+ columns: [
146
+ { title: "品牌", dataIndex: "name" },
147
+ { title: "日销量(件)", dataIndex: "count" },
148
+ ],
149
+ },
150
+ },
151
+ };
152
+
153
+ export const ListPlugin: PluginType = {
154
+ group: "基础组件",
155
+ key: "b-list",
156
+ label: "列表",
157
+ icon: "icon-unordered-list",
158
+ component: ListRender,
159
+ formComponent: ListProps,
160
+ defaultOptions: {
161
+ datasource: { source: "custom", custom: "[]" },
162
+ props: {
163
+ size: "default",
164
+ itemLayout: "horizontal",
165
+ bordered: true,
166
+ split: true,
167
+ pageSize: 10,
168
+ },
169
+ },
170
+ };
171
+
172
+ export const HtmlPlugin: PluginType = {
173
+ group: "基础组件",
174
+ key: "b-html",
175
+ label: "HTML",
176
+ icon: "icon-html",
177
+ component: HtmlRender,
178
+ formComponent: HtmlProps,
179
+ defaultOptions: {
180
+ datasource: {
181
+ source: "custom",
182
+ datasourceId: null,
183
+ scriptId: null,
184
+ custom: `{"name": "Confucius"}`,
185
+ },
186
+ props: {
187
+ dataSource: { name: "Confucius" },
188
+ template: `<div>{{name}}, welcome to the world of programming.</div>`,
189
+ },
190
+ },
191
+ };
192
+
193
+ export const EchartsPlugin: PluginType = {
194
+ group: "基础组件",
195
+ key: "b-echarts",
196
+ label: "图表",
197
+ icon: "icon-echarts",
198
+ component: EchartsRender,
199
+ formComponent: EchartsProps,
200
+ defaultOptions: {
201
+ datasource: {
202
+ source: "custom",
203
+ datasourceId: null,
204
+ scriptId: null,
205
+ custom:
206
+ '[{"name":"Mon","value":150},{"name":"Tue","value":230},{"name":"Wed","value":224},{"name":"Thu","value":218},{"name":"Fri","value":135},{"name":"Sat","value":147},{"name":"Sun","value":260}]',
207
+ },
208
+ props: {
209
+ script: `
210
+ return {
211
+ xAxis: { type: 'category', data: data.map(i => i.name) },
212
+ yAxis: { type: 'value' },
213
+ series: [{ data: data.map(i => i.value), type: 'line' }]
214
+ }
215
+ `,
216
+ },
217
+ },
218
+ };
219
+
220
+ export const InputPlugin: PluginType = {
221
+ group: "表单组件",
222
+ key: "b-input",
223
+ label: "输入框",
224
+ icon: "icon-form-input",
225
+ component: InputRender,
226
+ formComponent: InputProps,
227
+ defaultOptions: {
228
+ props: {
229
+ var: "",
230
+ size: "default",
231
+ allowClear: true,
232
+ search: false,
233
+ prefix: "",
234
+ suffix: "",
235
+ placeholder: "请输入",
236
+ },
237
+ cascadeIds: [],
238
+ },
239
+ };
240
+
241
+ export const InputNumberPlugin: PluginType = {
242
+ group: "表单组件",
243
+ key: "b-input-number",
244
+ label: "数字输入框",
245
+ icon: "icon-form-input-number",
246
+ component: InputNumberRender,
247
+ formComponent: InputNumberProps,
248
+ defaultOptions: {
249
+ props: {
250
+ var: "",
251
+ size: "default",
252
+ allowClear: true,
253
+ prefix: "",
254
+ suffix: "",
255
+ placeholder: "请输入",
256
+ step: 1,
257
+ min: 0,
258
+ max: 100,
259
+ precision: 0,
260
+ },
261
+ cascadeIds: [],
262
+ },
263
+ };
264
+
265
+ export const SelectPlugin: PluginType = {
266
+ group: "表单组件",
267
+ key: "b-select",
268
+ label: "选择框",
269
+ icon: "icon-form-select",
270
+ component: SelectRender,
271
+ formComponent: SelectProps,
272
+ defaultOptions: {
273
+ props: {
274
+ var: "",
275
+ size: "default",
276
+ allowClear: true,
277
+ multiple: false,
278
+ options: [
279
+ { label: "选项1", value: "1" },
280
+ { label: "选项2", value: "2" },
281
+ ],
282
+ },
283
+ cascadeIds: [],
284
+ },
285
+ };
286
+
287
+ export const CapsulePlugin: PluginType = {
288
+ group: "表单组件",
289
+ key: "b-capsule",
290
+ label: "胶囊选择框",
291
+ icon: "icon-form-capsule",
292
+ component: CapsuleRender,
293
+ formComponent: CapsuleProps,
294
+ defaultOptions: {
295
+ props: {
296
+ var: "",
297
+ size: "default",
298
+ allowClear: true,
299
+ multiple: false,
300
+ options: [
301
+ { label: "选项1", value: "1" },
302
+ { label: "选项2", value: "2" },
303
+ ],
304
+ },
305
+ cascadeIds: [],
306
+ },
307
+ };
308
+
309
+ export const CheckboxPlugin: PluginType = {
310
+ group: "表单组件",
311
+ key: "b-checkbox",
312
+ label: "复选框",
313
+ icon: "icon-form-checkbox",
314
+ component: CheckboxRender,
315
+ formComponent: CheckboxProps,
316
+ defaultOptions: {
317
+ props: {
318
+ var: "",
319
+ layout: "horizontal",
320
+ lineNumber: 3,
321
+ options: [
322
+ { label: "选项1", value: "1" },
323
+ { label: "选项2", value: "2" },
324
+ ],
325
+ },
326
+ cascadeIds: [],
327
+ },
328
+ };
329
+
330
+ export const DatePickerPlugin: PluginType = {
331
+ group: "表单组件",
332
+ key: "b-date-picker",
333
+ label: "日期选择器",
334
+ icon: "icon-form-date-picker",
335
+ component: DatePickerRender,
336
+ formComponent: DatePickerProps,
337
+ defaultOptions: {
338
+ props: {
339
+ var: "",
340
+ size: "default",
341
+ allowClear: true,
342
+ showTime: false,
343
+ type: "date",
344
+ },
345
+ cascadeIds: [],
346
+ },
347
+ };
348
+
349
+ export const SwitchPlugin: PluginType = {
350
+ group: "表单组件",
351
+ key: "b-switch",
352
+ label: "开关",
353
+ icon: "icon-form-switch",
354
+ component: SwitchRender,
355
+ formComponent: SwitchProps,
356
+ defaultOptions: {
357
+ props: {
358
+ var: "",
359
+ size: "default",
360
+ checkedChildren: "开",
361
+ unCheckedChildren: "关",
362
+ },
363
+ cascadeIds: [],
364
+ },
365
+ };
366
+
367
+ export const SpacePlugin: PluginType = {
368
+ group: "容器组件",
369
+ key: "b-space",
370
+ label: "容器",
371
+ icon: "icon-space",
372
+ component: SpaceRender,
373
+ formComponent: SpaceProps,
374
+ defaultOptions: {
375
+ props: { align: "flex-start", direction: "row", size: "8px" },
376
+ children: [],
377
+ },
378
+ };
379
+
380
+ export const CardPlugin: PluginType = {
381
+ group: "容器组件",
382
+ key: "b-card",
383
+ label: "卡片",
384
+ icon: "icon-card",
385
+ component: CardRender,
386
+ formComponent: CardProps,
387
+ defaultOptions: {
388
+ props: {
389
+ title: "标题",
390
+ bordered: true,
391
+ hoverable: true,
392
+ shadow: true,
393
+ size: "default",
394
+ },
395
+ children: { title: [], extra: [], body: [], actions: [] },
396
+ },
397
+ };
398
+
399
+ export const RowPlugin: PluginType = {
400
+ group: "容器组件",
401
+ key: "b-row",
402
+ label: "栅格行",
403
+ icon: "icon-grid-row",
404
+ component: RowRender,
405
+ formComponent: RowProps,
406
+ defaultOptions: {
407
+ props: { gutter: [12, 12] },
408
+ children: [],
409
+ },
410
+ };
411
+
412
+ export const ColPlugin: PluginType = {
413
+ group: "容器组件",
414
+ key: "b-col",
415
+ label: "栅格列",
416
+ icon: "icon-grid-columns",
417
+ component: ColRender,
418
+ formComponent: ColProps,
419
+ defaultOptions: {
420
+ props: { xs: 24, sm: 12, md: 12, lg: 6, xl: 6, xxl: 6, span: 8 },
421
+ children: [],
422
+ },
423
+ };
424
+
425
+ export const plugins: PluginType[] = [
426
+ TextPlugin,
427
+ ImagePlugin,
428
+ ButtonPlugin,
429
+ PageHeaderPlugin,
430
+ TablePlugin,
431
+ ListPlugin,
432
+ HtmlPlugin,
433
+ EchartsPlugin,
434
+ InputPlugin,
435
+ InputNumberPlugin,
436
+ SelectPlugin,
437
+ CapsulePlugin,
438
+ CheckboxPlugin,
439
+ DatePickerPlugin,
440
+ SwitchPlugin,
441
+ SpacePlugin,
442
+ CardPlugin,
443
+ RowPlugin,
444
+ ColPlugin,
445
+ ];
@@ -0,0 +1,91 @@
1
+ import React from "react";
2
+ import {
3
+ ButtonProps as AntButtonProps,
4
+ Form,
5
+ Input,
6
+ Radio,
7
+ Switch,
8
+ } from "antd";
9
+ import type { PropEditorProps } from "./types";
10
+
11
+ export type ButtonModel = {
12
+ text?: string;
13
+ icon?: string;
14
+ } & Pick<AntButtonProps, "type" | "size" | "shape" | "block" | "ghost">;
15
+
16
+ export const ButtonProps: React.FC<PropEditorProps<ButtonModel>> = ({
17
+ model,
18
+ onChange,
19
+ }) => {
20
+ const trigger = (key: keyof ButtonModel, value: any) =>
21
+ onChange && onChange({ ...model, [key]: value });
22
+ return (
23
+ <Form labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
24
+ <Form.Item label="文本">
25
+ <Input
26
+ size="small"
27
+ value={model.text}
28
+ onChange={(e) => trigger("text", e.target.value)}
29
+ placeholder="请输入按钮文本"
30
+ />
31
+ </Form.Item>
32
+ <Form.Item label="图标">
33
+ <Input
34
+ size="small"
35
+ value={model.icon}
36
+ onChange={(e) => trigger("icon", e.target.value)}
37
+ placeholder="请输入按钮图标(antdv 1.7.8)"
38
+ />
39
+ </Form.Item>
40
+ <Form.Item label="类型">
41
+ <Radio.Group
42
+ size="small"
43
+ value={model.type}
44
+ onChange={(e) => trigger("type", e.target.value)}
45
+ >
46
+ <Radio.Button value="default">默认</Radio.Button>
47
+ <Radio.Button value="primary">主要</Radio.Button>
48
+ <Radio.Button value="link">链接</Radio.Button>
49
+ <Radio.Button value="dashed">虚线</Radio.Button>
50
+ <Radio.Button value="text">文本</Radio.Button>
51
+ </Radio.Group>
52
+ </Form.Item>
53
+ <Form.Item label="大小">
54
+ <Radio.Group
55
+ size="small"
56
+ value={model.size}
57
+ onChange={(e) => trigger("size", e.target.value)}
58
+ >
59
+ <Radio.Button value="small">小</Radio.Button>
60
+ <Radio.Button value="middle">中</Radio.Button>
61
+ <Radio.Button value="large">大</Radio.Button>
62
+ </Radio.Group>
63
+ </Form.Item>
64
+ <Form.Item label="形状">
65
+ <Radio.Group
66
+ size="small"
67
+ value={model.shape}
68
+ onChange={(e) => trigger("shape", e.target.value)}
69
+ >
70
+ <Radio.Button value="default">默认</Radio.Button>
71
+ <Radio.Button value="round">圆角</Radio.Button>
72
+ <Radio.Button value="circle">圆形</Radio.Button>
73
+ </Radio.Group>
74
+ </Form.Item>
75
+ <Form.Item label="块级">
76
+ <Switch
77
+ size="small"
78
+ checked={!!model.block}
79
+ onChange={(v) => trigger("block", v)}
80
+ />
81
+ </Form.Item>
82
+ <Form.Item label="幽灵">
83
+ <Switch
84
+ size="small"
85
+ checked={!!model.ghost}
86
+ onChange={(v) => trigger("ghost", v)}
87
+ />
88
+ </Form.Item>
89
+ </Form>
90
+ );
91
+ };