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.
- package/dist/es/css/bi-sdk.css +1 -0
- package/dist/es/js/bi-sdk.es.js +795 -0
- package/dist/es/js/bi-sdk.es.js.LICENSE.txt +9 -0
- package/dist/types/components/PageDesigner.d.ts +10 -0
- package/dist/types/components/context/DesignerContext.d.ts +15 -0
- package/dist/types/components/context/EnvContext.d.ts +15 -0
- package/dist/types/components/dnd/DropContainer.d.ts +21 -0
- package/dist/types/components/example.d.ts +225 -0
- package/dist/types/components/hooks/datasource.d.ts +1 -0
- package/dist/types/components/hooks/useDeepCompareEffect.d.ts +1 -0
- package/dist/types/components/icon/IconFont.d.ts +6 -0
- package/dist/types/components/index.d.ts +10 -0
- package/dist/types/components/layout/PageCanvas.d.ts +6 -0
- package/dist/types/components/layout/PageItem.d.ts +27 -0
- package/dist/types/components/panel/AiPanel.d.ts +8 -0
- package/dist/types/components/panel/CascadePanel.d.ts +2 -0
- package/dist/types/components/panel/ChatInput.d.ts +28 -0
- package/dist/types/components/panel/CodePanel.d.ts +2 -0
- package/dist/types/components/panel/ComponentPanel.d.ts +2 -0
- package/dist/types/components/panel/DatasourcePanel.d.ts +2 -0
- package/dist/types/components/panel/LayerPanel.d.ts +2 -0
- package/dist/types/components/panel/PaneHeader.d.ts +6 -0
- package/dist/types/components/panel/PropertiesPanel.d.ts +2 -0
- package/dist/types/components/panel/ScriptPanel.d.ts +2 -0
- package/dist/types/components/panel/VariablesPanel.d.ts +2 -0
- package/dist/types/components/panel/index.d.ts +9 -0
- package/dist/types/components/plugins/@antd/index.d.ts +22 -0
- package/dist/types/components/plugins/@antd/item-props/ButtonProps.d.ts +8 -0
- package/dist/types/components/plugins/@antd/item-props/CapsuleProps.d.ts +13 -0
- package/dist/types/components/plugins/@antd/item-props/CardProps.d.ts +8 -0
- package/dist/types/components/plugins/@antd/item-props/CheckboxProps.d.ts +13 -0
- package/dist/types/components/plugins/@antd/item-props/ColProps.d.ts +12 -0
- package/dist/types/components/plugins/@antd/item-props/DatePickerProps.d.ts +8 -0
- package/dist/types/components/plugins/@antd/item-props/EchartsProps.d.ts +6 -0
- package/dist/types/components/plugins/@antd/item-props/HtmlProps.d.ts +6 -0
- package/dist/types/components/plugins/@antd/item-props/ImageProps.d.ts +10 -0
- package/dist/types/components/plugins/@antd/item-props/InputNumberProps.d.ts +9 -0
- package/dist/types/components/plugins/@antd/item-props/InputProps.d.ts +10 -0
- package/dist/types/components/plugins/@antd/item-props/ListProps.d.ts +10 -0
- package/dist/types/components/plugins/@antd/item-props/PageHeaderProps.d.ts +7 -0
- package/dist/types/components/plugins/@antd/item-props/RowProps.d.ts +6 -0
- package/dist/types/components/plugins/@antd/item-props/SelectProps.d.ts +16 -0
- package/dist/types/components/plugins/@antd/item-props/SpaceProps.d.ts +7 -0
- package/dist/types/components/plugins/@antd/item-props/SwitchProps.d.ts +6 -0
- package/dist/types/components/plugins/@antd/item-props/TableProps.d.ts +15 -0
- package/dist/types/components/plugins/@antd/item-props/TextProps.d.ts +6 -0
- package/dist/types/components/plugins/@antd/item-props/index.d.ts +19 -0
- package/dist/types/components/plugins/@antd/item-props/types.d.ts +5 -0
- package/dist/types/components/plugins/@antd/items/ButtonRender.d.ts +14 -0
- package/dist/types/components/plugins/@antd/items/CapsuleRender.d.ts +14 -0
- package/dist/types/components/plugins/@antd/items/CardRender.d.ts +12 -0
- package/dist/types/components/plugins/@antd/items/CheckboxRender.d.ts +14 -0
- package/dist/types/components/plugins/@antd/items/ColRender.d.ts +13 -0
- package/dist/types/components/plugins/@antd/items/DatePickerRender.d.ts +14 -0
- package/dist/types/components/plugins/@antd/items/EchartsRender.d.ts +10 -0
- package/dist/types/components/plugins/@antd/items/HtmlRender.d.ts +20 -0
- package/dist/types/components/plugins/@antd/items/ImageRender.d.ts +10 -0
- package/dist/types/components/plugins/@antd/items/InputNumberRender.d.ts +17 -0
- package/dist/types/components/plugins/@antd/items/InputRender.d.ts +17 -0
- package/dist/types/components/plugins/@antd/items/ListRender.d.ts +11 -0
- package/dist/types/components/plugins/@antd/items/PageHeaderRender.d.ts +8 -0
- package/dist/types/components/plugins/@antd/items/RowRender.d.ts +13 -0
- package/dist/types/components/plugins/@antd/items/SelectRender.d.ts +18 -0
- package/dist/types/components/plugins/@antd/items/SpaceRender.d.ts +10 -0
- package/dist/types/components/plugins/@antd/items/SwitchRender.d.ts +14 -0
- package/dist/types/components/plugins/@antd/items/TableRender.d.ts +12 -0
- package/dist/types/components/plugins/@antd/items/TextRender.d.ts +9 -0
- package/dist/types/components/plugins/@antd/items/index.d.ts +19 -0
- package/dist/types/components/typing.d.ts +80 -0
- package/dist/types/components/utils.d.ts +9 -0
- package/dist/types/example.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/umd/css/bi-sdk.css +1 -0
- package/dist/umd/js/bi-sdk.umd.min.js +795 -0
- package/dist/umd/js/bi-sdk.umd.min.js.LICENSE.txt +9 -0
- package/package.json +52 -0
- package/src/components/PageDesigner.tsx +509 -0
- package/src/components/context/DesignerContext.tsx +71 -0
- package/src/components/context/EnvContext.tsx +42 -0
- package/src/components/dnd/DropContainer.tsx +474 -0
- package/src/components/example.ts +577 -0
- package/src/components/hooks/datasource.ts +23 -0
- package/src/components/hooks/useDeepCompareEffect.ts +12 -0
- package/src/components/icon/IconFont.tsx +16 -0
- package/src/components/index.ts +29 -0
- package/src/components/layout/PageCanvas.tsx +145 -0
- package/src/components/layout/PageItem.tsx +182 -0
- package/src/components/panel/AiPanel.tsx +116 -0
- package/src/components/panel/CascadePanel.tsx +163 -0
- package/src/components/panel/ChatInput.tsx +550 -0
- package/src/components/panel/CodePanel.tsx +48 -0
- package/src/components/panel/ComponentPanel.tsx +119 -0
- package/src/components/panel/DatasourcePanel.tsx +419 -0
- package/src/components/panel/LayerPanel.tsx +238 -0
- package/src/components/panel/PaneHeader.tsx +34 -0
- package/src/components/panel/PropertiesPanel.tsx +394 -0
- package/src/components/panel/ScriptPanel.tsx +175 -0
- package/src/components/panel/VariablesPanel.tsx +153 -0
- package/src/components/panel/index.ts +9 -0
- package/src/components/plugins/@antd/index.ts +445 -0
- package/src/components/plugins/@antd/item-props/ButtonProps.tsx +91 -0
- package/src/components/plugins/@antd/item-props/CapsuleProps.tsx +102 -0
- package/src/components/plugins/@antd/item-props/CardProps.tsx +58 -0
- package/src/components/plugins/@antd/item-props/CheckboxProps.tsx +75 -0
- package/src/components/plugins/@antd/item-props/ColProps.tsx +43 -0
- package/src/components/plugins/@antd/item-props/DatePickerProps.tsx +72 -0
- package/src/components/plugins/@antd/item-props/EchartsProps.tsx +35 -0
- package/src/components/plugins/@antd/item-props/HtmlProps.tsx +61 -0
- package/src/components/plugins/@antd/item-props/ImageProps.tsx +43 -0
- package/src/components/plugins/@antd/item-props/InputNumberProps.tsx +18 -0
- package/src/components/plugins/@antd/item-props/InputProps.tsx +89 -0
- package/src/components/plugins/@antd/item-props/ListProps.tsx +69 -0
- package/src/components/plugins/@antd/item-props/PageHeaderProps.tsx +20 -0
- package/src/components/plugins/@antd/item-props/RowProps.tsx +21 -0
- package/src/components/plugins/@antd/item-props/SelectProps.tsx +136 -0
- package/src/components/plugins/@antd/item-props/SpaceProps.tsx +52 -0
- package/src/components/plugins/@antd/item-props/SwitchProps.tsx +17 -0
- package/src/components/plugins/@antd/item-props/TableProps.tsx +200 -0
- package/src/components/plugins/@antd/item-props/TextProps.tsx +41 -0
- package/src/components/plugins/@antd/item-props/index.ts +20 -0
- package/src/components/plugins/@antd/item-props/types.ts +6 -0
- package/src/components/plugins/@antd/items/ButtonRender.tsx +63 -0
- package/src/components/plugins/@antd/items/CapsuleRender.tsx +49 -0
- package/src/components/plugins/@antd/items/CardRender.tsx +119 -0
- package/src/components/plugins/@antd/items/CheckboxRender.tsx +56 -0
- package/src/components/plugins/@antd/items/ColRender.tsx +78 -0
- package/src/components/plugins/@antd/items/DatePickerRender.tsx +117 -0
- package/src/components/plugins/@antd/items/EchartsRender.tsx +98 -0
- package/src/components/plugins/@antd/items/HtmlRender.tsx +74 -0
- package/src/components/plugins/@antd/items/ImageRender.tsx +37 -0
- package/src/components/plugins/@antd/items/InputNumberRender.tsx +57 -0
- package/src/components/plugins/@antd/items/InputRender.tsx +75 -0
- package/src/components/plugins/@antd/items/ListRender.tsx +227 -0
- package/src/components/plugins/@antd/items/PageHeaderRender.tsx +74 -0
- package/src/components/plugins/@antd/items/RowRender.tsx +47 -0
- package/src/components/plugins/@antd/items/SelectRender.tsx +53 -0
- package/src/components/plugins/@antd/items/SpaceRender.tsx +54 -0
- package/src/components/plugins/@antd/items/SwitchRender.tsx +52 -0
- package/src/components/plugins/@antd/items/TableRender.tsx +99 -0
- package/src/components/plugins/@antd/items/TextRender.tsx +25 -0
- package/src/components/plugins/@antd/items/index.ts +20 -0
- package/src/components/styles.css +12 -0
- package/src/components/typing.ts +80 -0
- package/src/components/utils.ts +37 -0
- package/src/example.tsx +136 -0
- package/src/index.tsx +17 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Form, Input } from 'antd'
|
|
3
|
+
import type { PropEditorProps } from './types'
|
|
4
|
+
|
|
5
|
+
export type PageHeaderModel = { title?: string; subTitle?: string }
|
|
6
|
+
|
|
7
|
+
export const PageHeaderProps: React.FC<PropEditorProps<PageHeaderModel>> = ({ model, onChange }) => {
|
|
8
|
+
const trigger = (key: keyof PageHeaderModel, value: any) => onChange && onChange({ ...model, [key]: value })
|
|
9
|
+
return (
|
|
10
|
+
<Form layout="vertical">
|
|
11
|
+
<Form.Item label="标题">
|
|
12
|
+
<Input size="small" value={model.title} onChange={e => trigger('title', e.target.value)} placeholder="请输入标题" />
|
|
13
|
+
</Form.Item>
|
|
14
|
+
<Form.Item label="副标题">
|
|
15
|
+
<Input size="small" value={model.subTitle} onChange={e => trigger('subTitle', e.target.value)} placeholder="请输入副标题" />
|
|
16
|
+
</Form.Item>
|
|
17
|
+
</Form>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Form, InputNumber } from 'antd'
|
|
3
|
+
import type { PropEditorProps } from './types'
|
|
4
|
+
|
|
5
|
+
export type RowModel = { gutter?: [number, number] }
|
|
6
|
+
|
|
7
|
+
export const RowProps: React.FC<PropEditorProps<RowModel>> = ({ model, onChange }) => {
|
|
8
|
+
const trigger = (key: keyof RowModel, value: any) => onChange && onChange({ ...model, [key]: value })
|
|
9
|
+
const gutter = model.gutter || [0, 0]
|
|
10
|
+
return (
|
|
11
|
+
<Form labelCol={{ span: 12 }} wrapperCol={{ span: 12 }}>
|
|
12
|
+
<Form.Item label="列间距">
|
|
13
|
+
<InputNumber size="small" value={gutter[0]} min={0} step={4} onChange={v => trigger('gutter', [v || 0, gutter[1]])} />
|
|
14
|
+
</Form.Item>
|
|
15
|
+
<Form.Item label="行间距">
|
|
16
|
+
<InputNumber size="small" value={gutter[1]} min={0} step={4} onChange={v => trigger('gutter', [gutter[0], v || 0])} />
|
|
17
|
+
</Form.Item>
|
|
18
|
+
</Form>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
Form,
|
|
4
|
+
Input,
|
|
5
|
+
Radio,
|
|
6
|
+
Switch,
|
|
7
|
+
Table,
|
|
8
|
+
Button,
|
|
9
|
+
Space,
|
|
10
|
+
type SelectProps as AntSelectProps,
|
|
11
|
+
} from "antd";
|
|
12
|
+
import type { PropEditorProps } from "./types";
|
|
13
|
+
import { DeleteOutlined } from "@ant-design/icons";
|
|
14
|
+
|
|
15
|
+
export type SelectOption = { label: string; value: any };
|
|
16
|
+
export type SelectModel = {
|
|
17
|
+
var?: string;
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
size?: AntSelectProps["size"];
|
|
20
|
+
allowClear?: boolean;
|
|
21
|
+
multiple?: boolean;
|
|
22
|
+
options: SelectOption[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const SelectProps: React.FC<PropEditorProps<SelectModel>> = ({
|
|
26
|
+
model,
|
|
27
|
+
onChange,
|
|
28
|
+
}) => {
|
|
29
|
+
const trigger = (key: keyof SelectModel, value: any) =>
|
|
30
|
+
onChange && onChange({ ...model, [key]: value });
|
|
31
|
+
const setOption = (index: number, key: keyof SelectOption, value: any) => {
|
|
32
|
+
const options = [...(model.options || [])];
|
|
33
|
+
options[index] = { ...options[index], [key]: value };
|
|
34
|
+
trigger("options", options);
|
|
35
|
+
};
|
|
36
|
+
const removeOption = (index: number) => {
|
|
37
|
+
const options = [...(model.options || [])];
|
|
38
|
+
options.splice(index, 1);
|
|
39
|
+
trigger("options", options);
|
|
40
|
+
};
|
|
41
|
+
const addOption = () => {
|
|
42
|
+
trigger("options", [...(model.options || []), { label: "", value: "" }]);
|
|
43
|
+
};
|
|
44
|
+
const columns = [
|
|
45
|
+
{
|
|
46
|
+
title: "选项标签",
|
|
47
|
+
dataIndex: "label",
|
|
48
|
+
render: (_: any, r: SelectOption, i: number) => (
|
|
49
|
+
<Input
|
|
50
|
+
size="small"
|
|
51
|
+
value={r.label}
|
|
52
|
+
onChange={(e) => setOption(i, "label", e.target.value)}
|
|
53
|
+
/>
|
|
54
|
+
),
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
title: "选项值",
|
|
58
|
+
dataIndex: "value",
|
|
59
|
+
render: (_: any, r: SelectOption, i: number) => (
|
|
60
|
+
<Input
|
|
61
|
+
size="small"
|
|
62
|
+
value={r.value}
|
|
63
|
+
onChange={(e) => setOption(i, "value", e.target.value)}
|
|
64
|
+
/>
|
|
65
|
+
),
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
title: "操作",
|
|
69
|
+
render: (_: any, r: SelectOption, i: number) => (
|
|
70
|
+
<Space>
|
|
71
|
+
<Button danger size="small" onClick={() => removeOption(i)}>
|
|
72
|
+
<DeleteOutlined />
|
|
73
|
+
</Button>
|
|
74
|
+
</Space>
|
|
75
|
+
),
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
return (
|
|
79
|
+
<Form labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
|
|
80
|
+
<Form.Item label="变量名">
|
|
81
|
+
<Input
|
|
82
|
+
size="small"
|
|
83
|
+
value={model.var}
|
|
84
|
+
onChange={(e) => trigger("var", e.target.value)}
|
|
85
|
+
placeholder="请输入变量名"
|
|
86
|
+
/>
|
|
87
|
+
</Form.Item>
|
|
88
|
+
<Form.Item label="占位符">
|
|
89
|
+
<Input
|
|
90
|
+
size="small"
|
|
91
|
+
value={model.placeholder}
|
|
92
|
+
onChange={(e) => trigger("placeholder", e.target.value)}
|
|
93
|
+
placeholder="请输入占位符"
|
|
94
|
+
/>
|
|
95
|
+
</Form.Item>
|
|
96
|
+
<Form.Item label="大小">
|
|
97
|
+
<Radio.Group
|
|
98
|
+
size="small"
|
|
99
|
+
value={model.size}
|
|
100
|
+
onChange={(e) => trigger("size", e.target.value)}
|
|
101
|
+
>
|
|
102
|
+
<Radio.Button value="small">小</Radio.Button>
|
|
103
|
+
<Radio.Button value="middle">中</Radio.Button>
|
|
104
|
+
<Radio.Button value="large">大</Radio.Button>
|
|
105
|
+
</Radio.Group>
|
|
106
|
+
</Form.Item>
|
|
107
|
+
<Form.Item label="清除图标">
|
|
108
|
+
<Switch
|
|
109
|
+
size="small"
|
|
110
|
+
checked={!!model.allowClear}
|
|
111
|
+
onChange={(v) => trigger("allowClear", v)}
|
|
112
|
+
/>
|
|
113
|
+
</Form.Item>
|
|
114
|
+
<Form.Item label="多选">
|
|
115
|
+
<Switch
|
|
116
|
+
size="small"
|
|
117
|
+
checked={!!model.multiple}
|
|
118
|
+
onChange={(v) => trigger("multiple", v)}
|
|
119
|
+
/>
|
|
120
|
+
</Form.Item>
|
|
121
|
+
<Form.Item>
|
|
122
|
+
<Table
|
|
123
|
+
size="small"
|
|
124
|
+
dataSource={model.options}
|
|
125
|
+
columns={columns as any}
|
|
126
|
+
pagination={false}
|
|
127
|
+
rowKey={(_, i) => String(i)}
|
|
128
|
+
bordered
|
|
129
|
+
/>
|
|
130
|
+
<Button size="small" block onClick={addOption}>
|
|
131
|
+
添加选项
|
|
132
|
+
</Button>
|
|
133
|
+
</Form.Item>
|
|
134
|
+
</Form>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Form, Radio, type SpaceProps as AntSpaceProps } from "antd";
|
|
3
|
+
import type { PropEditorProps } from "./types";
|
|
4
|
+
|
|
5
|
+
export type SpaceModel = {
|
|
6
|
+
direction?: AntSpaceProps["orientation"];
|
|
7
|
+
} & Pick<AntSpaceProps, "size" | "align">;
|
|
8
|
+
|
|
9
|
+
export const SpaceProps: React.FC<PropEditorProps<SpaceModel>> = ({
|
|
10
|
+
model,
|
|
11
|
+
onChange,
|
|
12
|
+
}) => {
|
|
13
|
+
const trigger = (key: keyof SpaceModel, value: any) =>
|
|
14
|
+
onChange && onChange({ ...model, [key]: value });
|
|
15
|
+
return (
|
|
16
|
+
<Form labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
|
|
17
|
+
<Form.Item label="方向">
|
|
18
|
+
<Radio.Group
|
|
19
|
+
size="small"
|
|
20
|
+
value={model.direction}
|
|
21
|
+
onChange={(e) => trigger("direction", e.target.value)}
|
|
22
|
+
>
|
|
23
|
+
<Radio.Button value="horizontal">水平</Radio.Button>
|
|
24
|
+
<Radio.Button value="vertical">垂直</Radio.Button>
|
|
25
|
+
</Radio.Group>
|
|
26
|
+
</Form.Item>
|
|
27
|
+
<Form.Item label="大小">
|
|
28
|
+
<Radio.Group
|
|
29
|
+
size="small"
|
|
30
|
+
value={model.size}
|
|
31
|
+
onChange={(e) => trigger("size", e.target.value)}
|
|
32
|
+
>
|
|
33
|
+
<Radio.Button value="small">小</Radio.Button>
|
|
34
|
+
<Radio.Button value="middle">中</Radio.Button>
|
|
35
|
+
<Radio.Button value="large">大</Radio.Button>
|
|
36
|
+
</Radio.Group>
|
|
37
|
+
</Form.Item>
|
|
38
|
+
<Form.Item label="对齐">
|
|
39
|
+
<Radio.Group
|
|
40
|
+
size="small"
|
|
41
|
+
value={model.align}
|
|
42
|
+
onChange={(e) => trigger("align", e.target.value)}
|
|
43
|
+
>
|
|
44
|
+
<Radio.Button value="start">开始</Radio.Button>
|
|
45
|
+
<Radio.Button value="end">结束</Radio.Button>
|
|
46
|
+
<Radio.Button value="center">居中</Radio.Button>
|
|
47
|
+
<Radio.Button value="baseline">基线</Radio.Button>
|
|
48
|
+
</Radio.Group>
|
|
49
|
+
</Form.Item>
|
|
50
|
+
</Form>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Form, Input } from 'antd'
|
|
3
|
+
import type { PropEditorProps } from './types'
|
|
4
|
+
|
|
5
|
+
export type SwitchModel = { var?: string }
|
|
6
|
+
|
|
7
|
+
export const SwitchProps: React.FC<PropEditorProps<SwitchModel>> = ({ model, onChange }) => {
|
|
8
|
+
const trigger = (key: keyof SwitchModel, value: any) => onChange && onChange({ ...model, [key]: value })
|
|
9
|
+
return (
|
|
10
|
+
<Form labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
|
|
11
|
+
<Form.Item label="变量名">
|
|
12
|
+
<Input size="small" value={model.var} onChange={e => trigger('var', e.target.value)} placeholder="请输入变量名" />
|
|
13
|
+
</Form.Item>
|
|
14
|
+
</Form>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Form,
|
|
4
|
+
Radio,
|
|
5
|
+
Switch,
|
|
6
|
+
InputNumber,
|
|
7
|
+
Divider,
|
|
8
|
+
Table,
|
|
9
|
+
Space,
|
|
10
|
+
Button,
|
|
11
|
+
Modal,
|
|
12
|
+
Input,
|
|
13
|
+
type TableProps as AntTableProps,
|
|
14
|
+
} from "antd";
|
|
15
|
+
import type { PropEditorProps } from "./types";
|
|
16
|
+
import {
|
|
17
|
+
AlignCenterOutlined,
|
|
18
|
+
AlignLeftOutlined,
|
|
19
|
+
AlignRightOutlined,
|
|
20
|
+
DeleteOutlined,
|
|
21
|
+
EditOutlined,
|
|
22
|
+
} from "@ant-design/icons";
|
|
23
|
+
|
|
24
|
+
export type TableColumnModel = {
|
|
25
|
+
title: string;
|
|
26
|
+
dataIndex: string;
|
|
27
|
+
width?: string;
|
|
28
|
+
align?: "left" | "center" | "right";
|
|
29
|
+
ellipsis?: boolean;
|
|
30
|
+
};
|
|
31
|
+
export type TableModel = {
|
|
32
|
+
pageSize?: number;
|
|
33
|
+
columns: TableColumnModel[];
|
|
34
|
+
} & Pick<AntTableProps, "bordered" | "showHeader" | "size">;
|
|
35
|
+
|
|
36
|
+
export const TableProps: React.FC<PropEditorProps<TableModel>> = ({
|
|
37
|
+
model,
|
|
38
|
+
onChange,
|
|
39
|
+
}) => {
|
|
40
|
+
const trigger = (key: keyof TableModel, value: any) =>
|
|
41
|
+
onChange && onChange({ ...model, [key]: value });
|
|
42
|
+
const setColumn = (index: number, col: Partial<TableColumnModel>) => {
|
|
43
|
+
const columns = [...(model.columns || [])];
|
|
44
|
+
columns[index] = { ...columns[index], ...col };
|
|
45
|
+
trigger("columns", columns);
|
|
46
|
+
};
|
|
47
|
+
const removeColumn = (index: number) => {
|
|
48
|
+
const columns = [...(model.columns || [])];
|
|
49
|
+
columns.splice(index, 1);
|
|
50
|
+
trigger("columns", columns);
|
|
51
|
+
};
|
|
52
|
+
const addColumn = () => {
|
|
53
|
+
trigger("columns", [
|
|
54
|
+
...(model.columns || []),
|
|
55
|
+
{ title: "", dataIndex: "", width: "", align: "left", ellipsis: false },
|
|
56
|
+
]);
|
|
57
|
+
};
|
|
58
|
+
const [editVisible, setEditVisible] = useState(false);
|
|
59
|
+
const [editingIndex, setEditingIndex] = useState<number | null>(null);
|
|
60
|
+
const editingForm =
|
|
61
|
+
editingIndex != null && model.columns[editingIndex]
|
|
62
|
+
? model.columns[editingIndex]
|
|
63
|
+
: { title: "", dataIndex: "", width: "", align: "left", ellipsis: false };
|
|
64
|
+
const columns = [
|
|
65
|
+
{ title: "列名", dataIndex: "title" },
|
|
66
|
+
{ title: "数据索引", dataIndex: "dataIndex" },
|
|
67
|
+
{
|
|
68
|
+
title: "操作",
|
|
69
|
+
width: 80,
|
|
70
|
+
align: "center" as const,
|
|
71
|
+
render: (_: any, r: TableColumnModel, i: number) => (
|
|
72
|
+
<Space>
|
|
73
|
+
<a
|
|
74
|
+
onClick={() => {
|
|
75
|
+
setEditingIndex(i);
|
|
76
|
+
setEditVisible(true);
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<EditOutlined />
|
|
80
|
+
</a>
|
|
81
|
+
<a onClick={() => removeColumn(i)}>
|
|
82
|
+
<DeleteOutlined />
|
|
83
|
+
</a>
|
|
84
|
+
</Space>
|
|
85
|
+
),
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
return (
|
|
89
|
+
<div>
|
|
90
|
+
<Form labelCol={{ span: 12 }} wrapperCol={{ span: 12 }}>
|
|
91
|
+
<Form.Item label="大小">
|
|
92
|
+
<Radio.Group
|
|
93
|
+
size="small"
|
|
94
|
+
value={model.size}
|
|
95
|
+
onChange={(e) => trigger("size", e.target.value)}
|
|
96
|
+
>
|
|
97
|
+
<Radio.Button value="small">小</Radio.Button>
|
|
98
|
+
<Radio.Button value="middle">中</Radio.Button>
|
|
99
|
+
<Radio.Button value="large">大</Radio.Button>
|
|
100
|
+
</Radio.Group>
|
|
101
|
+
</Form.Item>
|
|
102
|
+
<Form.Item label="边框">
|
|
103
|
+
<Switch
|
|
104
|
+
size="small"
|
|
105
|
+
checked={!!model.bordered}
|
|
106
|
+
onChange={(v) => trigger("bordered", v)}
|
|
107
|
+
/>
|
|
108
|
+
</Form.Item>
|
|
109
|
+
<Form.Item label="显示表头">
|
|
110
|
+
<Switch
|
|
111
|
+
size="small"
|
|
112
|
+
checked={!!model.showHeader}
|
|
113
|
+
onChange={(v) => trigger("showHeader", v)}
|
|
114
|
+
/>
|
|
115
|
+
</Form.Item>
|
|
116
|
+
<Form.Item label="分页大小">
|
|
117
|
+
<InputNumber
|
|
118
|
+
size="small"
|
|
119
|
+
value={model.pageSize}
|
|
120
|
+
onChange={(v) => trigger("pageSize", v)}
|
|
121
|
+
/>
|
|
122
|
+
</Form.Item>
|
|
123
|
+
</Form>
|
|
124
|
+
<Divider>表格列设置</Divider>
|
|
125
|
+
<Table
|
|
126
|
+
size="small"
|
|
127
|
+
dataSource={model.columns}
|
|
128
|
+
rowKey={(_, i) => String(i)}
|
|
129
|
+
columns={columns as any}
|
|
130
|
+
pagination={false}
|
|
131
|
+
bordered
|
|
132
|
+
/>
|
|
133
|
+
<Button size="small" onClick={addColumn} block>
|
|
134
|
+
添加列
|
|
135
|
+
</Button>
|
|
136
|
+
<Modal
|
|
137
|
+
title="编辑列"
|
|
138
|
+
open={editVisible}
|
|
139
|
+
footer={null}
|
|
140
|
+
width={400}
|
|
141
|
+
onCancel={() => setEditVisible(false)}
|
|
142
|
+
>
|
|
143
|
+
<Form layout="vertical">
|
|
144
|
+
<div
|
|
145
|
+
style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 12 }}
|
|
146
|
+
>
|
|
147
|
+
<Form.Item label="列名">
|
|
148
|
+
<Input
|
|
149
|
+
value={editingForm.title}
|
|
150
|
+
onChange={(e) =>
|
|
151
|
+
setColumn(editingIndex!, { title: e.target.value })
|
|
152
|
+
}
|
|
153
|
+
/>
|
|
154
|
+
</Form.Item>
|
|
155
|
+
<Form.Item label="数据索引">
|
|
156
|
+
<Input
|
|
157
|
+
value={editingForm.dataIndex}
|
|
158
|
+
onChange={(e) =>
|
|
159
|
+
setColumn(editingIndex!, { dataIndex: e.target.value })
|
|
160
|
+
}
|
|
161
|
+
/>
|
|
162
|
+
</Form.Item>
|
|
163
|
+
<Form.Item label="宽度">
|
|
164
|
+
<Input
|
|
165
|
+
value={editingForm.width}
|
|
166
|
+
onChange={(e) =>
|
|
167
|
+
setColumn(editingIndex!, { width: e.target.value })
|
|
168
|
+
}
|
|
169
|
+
/>
|
|
170
|
+
</Form.Item>
|
|
171
|
+
<Form.Item label="对齐">
|
|
172
|
+
<Radio.Group
|
|
173
|
+
value={editingForm.align}
|
|
174
|
+
onChange={(e) =>
|
|
175
|
+
setColumn(editingIndex!, { align: e.target.value })
|
|
176
|
+
}
|
|
177
|
+
>
|
|
178
|
+
<Radio.Button value="left">
|
|
179
|
+
<AlignLeftOutlined />
|
|
180
|
+
</Radio.Button>
|
|
181
|
+
<Radio.Button value="center">
|
|
182
|
+
<AlignCenterOutlined />
|
|
183
|
+
</Radio.Button>
|
|
184
|
+
<Radio.Button value="right">
|
|
185
|
+
<AlignRightOutlined />
|
|
186
|
+
</Radio.Button>
|
|
187
|
+
</Radio.Group>
|
|
188
|
+
</Form.Item>
|
|
189
|
+
<Form.Item label="省略">
|
|
190
|
+
<Switch
|
|
191
|
+
checked={!!editingForm.ellipsis}
|
|
192
|
+
onChange={(v) => setColumn(editingIndex!, { ellipsis: v })}
|
|
193
|
+
/>
|
|
194
|
+
</Form.Item>
|
|
195
|
+
</div>
|
|
196
|
+
</Form>
|
|
197
|
+
</Modal>
|
|
198
|
+
</div>
|
|
199
|
+
);
|
|
200
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Form, Input, Select, Button } from 'antd'
|
|
3
|
+
import type { PropEditorProps } from './types'
|
|
4
|
+
|
|
5
|
+
export type TextModel = { text?: string }
|
|
6
|
+
|
|
7
|
+
export const TextProps: React.FC<PropEditorProps<TextModel>> = ({ model, customStyle = {}, onChange }) => {
|
|
8
|
+
const triggerModel = (key: keyof TextModel, value: any) => onChange && onChange({ ...model, [key]: value })
|
|
9
|
+
const setStyle = (key: string, value: any) => {
|
|
10
|
+
const next = { ...customStyle, [key]: value }
|
|
11
|
+
onChange && onChange({ ...model, customStyle: next } as any)
|
|
12
|
+
}
|
|
13
|
+
return (
|
|
14
|
+
<Form>
|
|
15
|
+
<Form.Item label="文本内容">
|
|
16
|
+
<Input.TextArea size="small" value={model.text} onChange={e => triggerModel('text', e.target.value)} />
|
|
17
|
+
</Form.Item>
|
|
18
|
+
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
|
19
|
+
<Input.Group compact>
|
|
20
|
+
<Select size="small" value={customStyle.fontFamily} style={{ width: 90 }} onChange={v => setStyle('fontFamily', v)}>
|
|
21
|
+
<Select.Option value="'黑体', 'SimHei', sans-serif">黑体</Select.Option>
|
|
22
|
+
<Select.Option value="'宋体', 'SimSun', serif">宋体</Select.Option>
|
|
23
|
+
<Select.Option value="'仿宋', 'FangSong', serif">仿宋</Select.Option>
|
|
24
|
+
<Select.Option value="'楷体', 'KaiTi', serif">楷体</Select.Option>
|
|
25
|
+
<Select.Option value="Arial, sans-serif">Arial</Select.Option>
|
|
26
|
+
</Select>
|
|
27
|
+
<Select size="small" value={customStyle.fontSize} style={{ width: 90 }} onChange={v => setStyle('fontSize', v)}>
|
|
28
|
+
{['12px','14px','16px','20px','22px','24px','32px','48px'].map(s => <Select.Option key={s} value={s}>{s}</Select.Option>)}
|
|
29
|
+
</Select>
|
|
30
|
+
<Input size="small" type="color" value={customStyle.color} onChange={e => setStyle('color', e.target.value)} style={{ width: 90 }} />
|
|
31
|
+
</Input.Group>
|
|
32
|
+
<Input.Group compact>
|
|
33
|
+
<Button type={customStyle.fontWeight === 'bold' ? 'primary' : undefined} size="small" onClick={() => setStyle('fontWeight', customStyle.fontWeight === 'bold' ? 'normal' : 'bold')}>B</Button>
|
|
34
|
+
<Button type={customStyle.fontStyle === 'italic' ? 'primary' : undefined} size="small" onClick={() => setStyle('fontStyle', customStyle.fontStyle === 'italic' ? 'normal' : 'italic')}>I</Button>
|
|
35
|
+
<Button type={customStyle.textDecoration === 'underline' ? 'primary' : undefined} size="small" onClick={() => setStyle('textDecoration', customStyle.textDecoration === 'underline' ? 'none' : 'underline')}>U</Button>
|
|
36
|
+
</Input.Group>
|
|
37
|
+
</div>
|
|
38
|
+
</Form>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { ButtonProps } from './ButtonProps'
|
|
2
|
+
export { InputProps } from './InputProps'
|
|
3
|
+
export { InputNumberProps } from './InputNumberProps'
|
|
4
|
+
export { SelectProps } from './SelectProps'
|
|
5
|
+
export { CheckboxProps } from './CheckboxProps'
|
|
6
|
+
export { CapsuleProps } from './CapsuleProps'
|
|
7
|
+
export { DatePickerProps } from './DatePickerProps'
|
|
8
|
+
export { SwitchProps } from './SwitchProps'
|
|
9
|
+
export { TextProps } from './TextProps'
|
|
10
|
+
export { HtmlProps } from './HtmlProps'
|
|
11
|
+
export { EchartsProps } from './EchartsProps'
|
|
12
|
+
export { ImageProps } from './ImageProps'
|
|
13
|
+
export { CardProps } from './CardProps'
|
|
14
|
+
export { ListProps } from './ListProps'
|
|
15
|
+
export { TableProps } from './TableProps'
|
|
16
|
+
export { PageHeaderProps } from './PageHeaderProps'
|
|
17
|
+
export { RowProps } from './RowProps'
|
|
18
|
+
export { ColProps } from './ColProps'
|
|
19
|
+
export { SpaceProps } from './SpaceProps'
|
|
20
|
+
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Button, type ButtonProps } from "antd";
|
|
2
|
+
import React, { MouseEventHandler, useContext } from "react";
|
|
3
|
+
import { HtmlBaseProps, SchemaItemType } from "../../../typing";
|
|
4
|
+
import { EnvContext } from "../../../context/EnvContext";
|
|
5
|
+
import { IconFont } from "../../../icon/IconFont";
|
|
6
|
+
import { handleCallback } from "../../../utils";
|
|
7
|
+
|
|
8
|
+
export type ButtonRenderProps = {
|
|
9
|
+
text?: string;
|
|
10
|
+
type?: ButtonProps["type"];
|
|
11
|
+
icon?: ButtonProps["icon"];
|
|
12
|
+
size?: ButtonProps["size"];
|
|
13
|
+
block?: ButtonProps["block"];
|
|
14
|
+
shape?: ButtonProps["shape"];
|
|
15
|
+
ghost?: ButtonProps["ghost"];
|
|
16
|
+
item?: SchemaItemType;
|
|
17
|
+
} & HtmlBaseProps;
|
|
18
|
+
|
|
19
|
+
export const ButtonRender: React.FC<ButtonRenderProps> = ({
|
|
20
|
+
id,
|
|
21
|
+
text = "按钮",
|
|
22
|
+
type = "middle",
|
|
23
|
+
icon,
|
|
24
|
+
size,
|
|
25
|
+
block = false,
|
|
26
|
+
shape = "default",
|
|
27
|
+
ghost = false,
|
|
28
|
+
item,
|
|
29
|
+
style,
|
|
30
|
+
className,
|
|
31
|
+
}) => {
|
|
32
|
+
const { env, callbacks } = useContext(EnvContext);
|
|
33
|
+
const danger = type === "danger";
|
|
34
|
+
const realType = danger ? "default" : type;
|
|
35
|
+
const click: MouseEventHandler = () => {
|
|
36
|
+
if (env && item && callbacks) handleCallback(env, item, callbacks);
|
|
37
|
+
};
|
|
38
|
+
const iconNode =
|
|
39
|
+
typeof icon === "string" ? (
|
|
40
|
+
icon ? (
|
|
41
|
+
<IconFont type={icon} />
|
|
42
|
+
) : undefined
|
|
43
|
+
) : (
|
|
44
|
+
icon
|
|
45
|
+
);
|
|
46
|
+
return (
|
|
47
|
+
<Button
|
|
48
|
+
id={id}
|
|
49
|
+
type={realType as any}
|
|
50
|
+
icon={iconNode as any}
|
|
51
|
+
size={size}
|
|
52
|
+
block={block}
|
|
53
|
+
shape={["round", "circle"].includes(shape) ? (shape as any) : undefined}
|
|
54
|
+
ghost={ghost}
|
|
55
|
+
danger={danger}
|
|
56
|
+
onClick={click}
|
|
57
|
+
style={style}
|
|
58
|
+
className={className}
|
|
59
|
+
>
|
|
60
|
+
{text}
|
|
61
|
+
</Button>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Radio, type RadioGroupProps } from "antd";
|
|
2
|
+
import React, { useContext } from "react";
|
|
3
|
+
import { HtmlBaseProps, SchemaItemType } from "../../../typing";
|
|
4
|
+
import { EnvContext } from "../../../context/EnvContext";
|
|
5
|
+
import { handleCallback, setVar } from "../../../utils";
|
|
6
|
+
|
|
7
|
+
export type CapsuleRenderProps = {
|
|
8
|
+
var?: string;
|
|
9
|
+
size?: RadioGroupProps['size']
|
|
10
|
+
options?: { label: string; value: any }[];
|
|
11
|
+
item?: SchemaItemType;
|
|
12
|
+
onChange?: (v: any) => void;
|
|
13
|
+
} & HtmlBaseProps;
|
|
14
|
+
|
|
15
|
+
export const CapsuleRender: React.FC<CapsuleRenderProps> = ({
|
|
16
|
+
id,
|
|
17
|
+
var: varName = "",
|
|
18
|
+
size = "middle",
|
|
19
|
+
options = [],
|
|
20
|
+
item,
|
|
21
|
+
onChange,
|
|
22
|
+
style,
|
|
23
|
+
className,
|
|
24
|
+
}) => {
|
|
25
|
+
const { env, callbacks } = useContext(EnvContext);
|
|
26
|
+
const change = (v: any) => {
|
|
27
|
+
if (onChange) onChange(v);
|
|
28
|
+
if (env && item && varName) setVar(env, item, varName, v);
|
|
29
|
+
if (env && item && callbacks) handleCallback(env, item, callbacks);
|
|
30
|
+
};
|
|
31
|
+
return (
|
|
32
|
+
<span id={id}>
|
|
33
|
+
<Radio.Group
|
|
34
|
+
id={id}
|
|
35
|
+
size={size as any}
|
|
36
|
+
buttonStyle="solid"
|
|
37
|
+
onChange={(e) => change(e.target.value)}
|
|
38
|
+
style={style}
|
|
39
|
+
className={className}
|
|
40
|
+
>
|
|
41
|
+
{options.map((op) => (
|
|
42
|
+
<Radio.Button key={op.value} value={op.value}>
|
|
43
|
+
{op.label}
|
|
44
|
+
</Radio.Button>
|
|
45
|
+
))}
|
|
46
|
+
</Radio.Group>
|
|
47
|
+
</span>
|
|
48
|
+
);
|
|
49
|
+
};
|