bi-sdk-react 0.0.49 → 0.0.51
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/js/bi-sdk.es.js +55 -31
- package/dist/types/components/context/PageContext.d.ts +1 -2
- package/dist/types/components/layout/PageItem.d.ts +1 -0
- package/dist/types/components/plugins/@antd/index.d.ts +2 -0
- package/dist/types/components/plugins/@antd/item-props/DrawerProps.d.ts +20 -0
- package/dist/types/components/plugins/@antd/item-props/ModalProps.d.ts +18 -0
- package/dist/types/components/plugins/@antd/item-props/index.d.ts +2 -0
- package/dist/types/components/plugins/@antd/items/DrawerRender.d.ts +19 -0
- package/dist/types/components/plugins/@antd/items/ModalRender.d.ts +17 -0
- package/dist/types/components/plugins/@antd/items/index.d.ts +2 -0
- package/dist/umd/js/bi-sdk.umd.min.js +55 -31
- package/package.json +1 -1
- package/src/components/context/PageContext.tsx +2 -12
- package/src/components/dnd/DropContainer.tsx +34 -0
- package/src/components/hooks/datasource.ts +6 -6
- package/src/components/icon/IconFont.tsx +1 -1
- package/src/components/layout/PageItem.tsx +17 -2
- package/src/components/panel/LayerPanel.tsx +7 -6
- package/src/components/plugins/@antd/index.ts +56 -0
- package/src/components/plugins/@antd/item-props/DrawerProps.tsx +157 -0
- package/src/components/plugins/@antd/item-props/ModalProps.tsx +136 -0
- package/src/components/plugins/@antd/item-props/index.ts +2 -0
- package/src/components/plugins/@antd/items/DrawerRender.tsx +166 -0
- package/src/components/plugins/@antd/items/ModalRender.tsx +146 -0
- package/src/components/plugins/@antd/items/index.ts +2 -1
- package/src/example.tsx +2 -1
package/package.json
CHANGED
|
@@ -44,8 +44,7 @@ type PageContextType = {
|
|
|
44
44
|
) => void;
|
|
45
45
|
getVars: (id: string) => Record<string, any>;
|
|
46
46
|
setVar: (item: SchemaItemType, key: string, value: any) => void;
|
|
47
|
-
|
|
48
|
-
setItemData: (id: string, data: any) => void;
|
|
47
|
+
setItemData?: (id: string, data: any) => void;
|
|
49
48
|
};
|
|
50
49
|
|
|
51
50
|
export const PageContext = createContext<PageContextType>({
|
|
@@ -78,7 +77,6 @@ export const PageContext = createContext<PageContextType>({
|
|
|
78
77
|
handleCallback: () => {},
|
|
79
78
|
getVars: () => ({}),
|
|
80
79
|
setVar: () => {},
|
|
81
|
-
getItemData: () => {},
|
|
82
80
|
setItemData: () => {},
|
|
83
81
|
});
|
|
84
82
|
|
|
@@ -110,8 +108,8 @@ export const PageProvider: React.FC<PageProviderProps> = ({
|
|
|
110
108
|
datasetAdd,
|
|
111
109
|
fetch,
|
|
112
110
|
children,
|
|
111
|
+
setItemData,
|
|
113
112
|
}) => {
|
|
114
|
-
const [itemDatas, setItemDatas] = useState<Record<string, any>>({});
|
|
115
113
|
const [deviceWidth, setDeviceWidth] = useState<number>(0);
|
|
116
114
|
const updateSelectedItem = (props?: Partial<SchemaItemType> | null) => {
|
|
117
115
|
setSelectedItem?.(Object.assign(selectedItem!, props || {}));
|
|
@@ -175,13 +173,6 @@ export const PageProvider: React.FC<PageProviderProps> = ({
|
|
|
175
173
|
});
|
|
176
174
|
};
|
|
177
175
|
|
|
178
|
-
const getItemData = (id: string) => {
|
|
179
|
-
return itemDatas[id] || {};
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const setItemData = (id: string, data: any) => {
|
|
183
|
-
setItemDatas((d) => ({ ...d, [id]: data }));
|
|
184
|
-
};
|
|
185
176
|
|
|
186
177
|
useEffect(() => {
|
|
187
178
|
const nextGlobal: Record<string, any> = {};
|
|
@@ -218,7 +209,6 @@ export const PageProvider: React.FC<PageProviderProps> = ({
|
|
|
218
209
|
handleCallback,
|
|
219
210
|
getVars,
|
|
220
211
|
setVar,
|
|
221
|
-
getItemData,
|
|
222
212
|
setItemData,
|
|
223
213
|
}}
|
|
224
214
|
>
|
|
@@ -4,6 +4,7 @@ import { PageItem, PageItemProps } from "../layout/PageItem";
|
|
|
4
4
|
import { HtmlBaseProps, SchemaItemType } from "../typing";
|
|
5
5
|
import styled from "styled-components";
|
|
6
6
|
import { PageContext } from "../context/PageContext";
|
|
7
|
+
import { uuid } from "../utils";
|
|
7
8
|
|
|
8
9
|
type DropContainerProps = {
|
|
9
10
|
rootComponent?: React.ComponentType<any>;
|
|
@@ -441,6 +442,38 @@ export const DropContainer: React.FC<DropContainerProps> = ({
|
|
|
441
442
|
return () => cleanup();
|
|
442
443
|
}, []);
|
|
443
444
|
|
|
445
|
+
const onCopy = (item: SchemaItemType) => {
|
|
446
|
+
// 递归复制函数,确保所有子节点都有新的 ID
|
|
447
|
+
const cloneItem = (node: SchemaItemType): SchemaItemType => {
|
|
448
|
+
const newNode = { ...node, id: uuid() };
|
|
449
|
+
|
|
450
|
+
if (node.children) {
|
|
451
|
+
if (Array.isArray(node.children)) {
|
|
452
|
+
newNode.children = node.children.map(cloneItem);
|
|
453
|
+
} else {
|
|
454
|
+
const newChildren: Record<string, SchemaItemType[]> = {};
|
|
455
|
+
Object.keys(node.children).forEach((key) => {
|
|
456
|
+
newChildren[key] = (node.children as Record<string, SchemaItemType[]>)[
|
|
457
|
+
key
|
|
458
|
+
].map(cloneItem);
|
|
459
|
+
});
|
|
460
|
+
newNode.children = newChildren;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return newNode;
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
const newItem = cloneItem(item);
|
|
467
|
+
const index = list.findIndex((i) => i.id === item.id);
|
|
468
|
+
|
|
469
|
+
if (index !== -1) {
|
|
470
|
+
const newList = [...list];
|
|
471
|
+
newList.splice(index + 1, 0, newItem);
|
|
472
|
+
console.log(newList);
|
|
473
|
+
onListChange?.(newList);
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
|
|
444
477
|
// Determine classes
|
|
445
478
|
const classes = [
|
|
446
479
|
className,
|
|
@@ -483,6 +516,7 @@ export const DropContainer: React.FC<DropContainerProps> = ({
|
|
|
483
516
|
parentList={memoList}
|
|
484
517
|
onListChange={onListChange}
|
|
485
518
|
index={index}
|
|
519
|
+
onCopy={onCopy}
|
|
486
520
|
onDelete={() =>
|
|
487
521
|
onListChange?.(memoList.filter((i: any) => i.id !== child.id))
|
|
488
522
|
}
|
|
@@ -23,10 +23,10 @@ export const useDatasource = ({ item, signal }: Props): any => {
|
|
|
23
23
|
try {
|
|
24
24
|
const next = JSON.parse(item?.datasource?.custom || "[]");
|
|
25
25
|
setDatasource(next);
|
|
26
|
-
setItemData(item.id || "", next);
|
|
26
|
+
setItemData?.(item.id || "", next);
|
|
27
27
|
} catch (e) {
|
|
28
28
|
setDatasource(null);
|
|
29
|
-
setItemData(item.id || "", null);
|
|
29
|
+
setItemData?.(item.id || "", null);
|
|
30
30
|
}
|
|
31
31
|
break;
|
|
32
32
|
case "dataset":
|
|
@@ -39,7 +39,7 @@ export const useDatasource = ({ item, signal }: Props): any => {
|
|
|
39
39
|
},
|
|
40
40
|
);
|
|
41
41
|
setDatasource(null);
|
|
42
|
-
setItemData(item.id || "", null);
|
|
42
|
+
setItemData?.(item.id || "", null);
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
const vars = getVars(item.id || "");
|
|
@@ -47,17 +47,17 @@ export const useDatasource = ({ item, signal }: Props): any => {
|
|
|
47
47
|
.dataset(item?.datasource.dataset.id, vars)
|
|
48
48
|
.then((res) => {
|
|
49
49
|
setDatasource(res || null);
|
|
50
|
-
setItemData(item.id || "", res || null);
|
|
50
|
+
setItemData?.(item.id || "", res || null);
|
|
51
51
|
})
|
|
52
52
|
.catch((err) => {
|
|
53
53
|
console.error("dataset fetch error", err);
|
|
54
54
|
setDatasource(null);
|
|
55
|
-
setItemData(item.id || "", null);
|
|
55
|
+
setItemData?.(item.id || "", null);
|
|
56
56
|
});
|
|
57
57
|
break;
|
|
58
58
|
default:
|
|
59
59
|
setDatasource(null);
|
|
60
|
-
setItemData(item.id || "", null);
|
|
60
|
+
setItemData?.(item.id || "", null);
|
|
61
61
|
break;
|
|
62
62
|
}
|
|
63
63
|
}, [item?.datasource, signal]);
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { createFromIconfontCN } from "@ant-design/icons";
|
|
3
3
|
|
|
4
4
|
const IconFontCN = createFromIconfontCN({
|
|
5
|
-
scriptUrl: "https://at.alicdn.com/t/c/
|
|
5
|
+
scriptUrl: "https://at.alicdn.com/t/c/font_5072483_3ofyyta7h1e.js",
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
export type IconFontProps = {
|
|
@@ -4,7 +4,7 @@ import { PageContext } from "../context/PageContext";
|
|
|
4
4
|
import { SchemaItemType } from "../typing";
|
|
5
5
|
import styled from "styled-components";
|
|
6
6
|
import { IconFont } from "../icon/IconFont";
|
|
7
|
-
import { DeleteOutlined } from "@ant-design/icons";
|
|
7
|
+
import { CopyOutlined, DeleteOutlined } from "@ant-design/icons";
|
|
8
8
|
import { Button, Dropdown, Modal, Space, Tooltip, Typography } from "antd";
|
|
9
9
|
import ReactDOM from "react-dom";
|
|
10
10
|
import { Editor } from "@monaco-editor/react";
|
|
@@ -12,6 +12,7 @@ import { Editor } from "@monaco-editor/react";
|
|
|
12
12
|
export type PageItemProps = {
|
|
13
13
|
id?: string;
|
|
14
14
|
item: SchemaItemType;
|
|
15
|
+
onCopy?: (item: SchemaItemType) => void;
|
|
15
16
|
onDelete?: () => void;
|
|
16
17
|
ancestors: SchemaItemType[];
|
|
17
18
|
parentList?: any[];
|
|
@@ -67,9 +68,10 @@ const Toolbar: React.FC<{
|
|
|
67
68
|
ancestors: SchemaItemType[];
|
|
68
69
|
onAddAt?: (e: any) => void;
|
|
69
70
|
onDelete?: (e: any) => void;
|
|
71
|
+
onCopy?: (e: any) => void;
|
|
70
72
|
onUpdate?: () => void;
|
|
71
73
|
onSelect?: (item: SchemaItemType) => void;
|
|
72
|
-
}> = ({ item, ancestors, onAddAt, onDelete, onUpdate, onSelect }) => {
|
|
74
|
+
}> = ({ item, ancestors, onAddAt, onDelete, onCopy, onUpdate, onSelect }) => {
|
|
73
75
|
const [code, setCode] = useState(JSON.stringify(item || {}, null, 2));
|
|
74
76
|
const [visible, setVisible] = useState(false);
|
|
75
77
|
const editRef = useRef<any>(null);
|
|
@@ -190,6 +192,11 @@ const Toolbar: React.FC<{
|
|
|
190
192
|
<IconFont type="icon-json" />
|
|
191
193
|
</a>
|
|
192
194
|
</Tooltip>
|
|
195
|
+
<Tooltip title="复制">
|
|
196
|
+
<a onClick={onCopy}>
|
|
197
|
+
<CopyOutlined />
|
|
198
|
+
</a>
|
|
199
|
+
</Tooltip>
|
|
193
200
|
<Tooltip title="删除">
|
|
194
201
|
<a onClick={onDelete}>
|
|
195
202
|
<DeleteOutlined />
|
|
@@ -218,6 +225,7 @@ const Toolbar: React.FC<{
|
|
|
218
225
|
*/
|
|
219
226
|
export const PageItem: React.FC<PageItemProps> = ({
|
|
220
227
|
item,
|
|
228
|
+
onCopy,
|
|
221
229
|
onDelete,
|
|
222
230
|
ancestors,
|
|
223
231
|
parentList,
|
|
@@ -252,6 +260,11 @@ export const PageItem: React.FC<PageItemProps> = ({
|
|
|
252
260
|
});
|
|
253
261
|
};
|
|
254
262
|
|
|
263
|
+
const handleCopy = (e: any) => {
|
|
264
|
+
e.stopPropagation();
|
|
265
|
+
if (onCopy) onCopy(item);
|
|
266
|
+
};
|
|
267
|
+
|
|
255
268
|
const handleAddAtItem = (e: any) => {
|
|
256
269
|
e.stopPropagation();
|
|
257
270
|
if (onAddAtItem) onAddAtItem(item);
|
|
@@ -303,6 +316,7 @@ export const PageItem: React.FC<PageItemProps> = ({
|
|
|
303
316
|
|
|
304
317
|
if (selectedItem && selectedItem === item && designable) {
|
|
305
318
|
const div = document.createElement("div");
|
|
319
|
+
div.setAttribute("id", "page-item-toolbar")
|
|
306
320
|
div.style.position = "absolute";
|
|
307
321
|
div.style.zIndex = "1000";
|
|
308
322
|
div.style.display = "flex";
|
|
@@ -378,6 +392,7 @@ export const PageItem: React.FC<PageItemProps> = ({
|
|
|
378
392
|
item={item}
|
|
379
393
|
ancestors={ancestors}
|
|
380
394
|
onAddAt={fetch?.ai?.chat ? handleAddAtItem : undefined}
|
|
395
|
+
onCopy={handleCopy}
|
|
381
396
|
onDelete={handleDelete}
|
|
382
397
|
onUpdate={forceUpdate}
|
|
383
398
|
onSelect={onSelect}
|
|
@@ -43,7 +43,7 @@ export const LayerPanel: React.FC = () => {
|
|
|
43
43
|
const [expandedKeys, setExpandedKeys] = useState<string[]>([]);
|
|
44
44
|
const selectedKeys = useMemo(
|
|
45
45
|
() => (selectedItem ? [selectedItem.id!] : []),
|
|
46
|
-
[selectedItem]
|
|
46
|
+
[selectedItem],
|
|
47
47
|
);
|
|
48
48
|
const realItems = useMemo(() => {
|
|
49
49
|
const compute = (list: any[] = []) => {
|
|
@@ -139,11 +139,12 @@ export const LayerPanel: React.FC = () => {
|
|
|
139
139
|
const { slot, origin } = info.node.dataRef;
|
|
140
140
|
origin[slot] = origin[slot] || [];
|
|
141
141
|
origin[slot].push(dragObj);
|
|
142
|
+
} else {
|
|
143
|
+
loop(data, dropKey, (item: any) => {
|
|
144
|
+
item.children = item.children || [];
|
|
145
|
+
item.children.push(dragObj);
|
|
146
|
+
});
|
|
142
147
|
}
|
|
143
|
-
loop(data, dropKey, (item: any) => {
|
|
144
|
-
item.children = item.children || [];
|
|
145
|
-
item.children.push(dragObj);
|
|
146
|
-
});
|
|
147
148
|
} else if (
|
|
148
149
|
(info.node.children || []).length > 0 &&
|
|
149
150
|
info.node.expanded &&
|
|
@@ -217,7 +218,7 @@ export const LayerPanel: React.FC = () => {
|
|
|
217
218
|
draggable={{
|
|
218
219
|
icon: false,
|
|
219
220
|
nodeDraggable(node: any) {
|
|
220
|
-
return
|
|
221
|
+
return node.dataRef.type !== "slot";
|
|
221
222
|
},
|
|
222
223
|
}}
|
|
223
224
|
showIcon={false}
|
|
@@ -9,12 +9,14 @@ import {
|
|
|
9
9
|
CheckboxProps,
|
|
10
10
|
ColProps,
|
|
11
11
|
DatePickerProps,
|
|
12
|
+
DrawerProps,
|
|
12
13
|
EchartsProps,
|
|
13
14
|
HtmlProps,
|
|
14
15
|
ImageProps,
|
|
15
16
|
InputNumberProps,
|
|
16
17
|
InputProps,
|
|
17
18
|
ListProps,
|
|
19
|
+
ModalProps,
|
|
18
20
|
PageHeaderProps,
|
|
19
21
|
RowProps,
|
|
20
22
|
SelectProps,
|
|
@@ -30,12 +32,14 @@ import {
|
|
|
30
32
|
CheckboxRender,
|
|
31
33
|
ColRender,
|
|
32
34
|
DatePickerRender,
|
|
35
|
+
DrawerRender,
|
|
33
36
|
EchartsRender,
|
|
34
37
|
HtmlRender,
|
|
35
38
|
ImageRender,
|
|
36
39
|
InputNumberRender,
|
|
37
40
|
InputRender,
|
|
38
41
|
ListRender,
|
|
42
|
+
ModalRender,
|
|
39
43
|
PageHeaderRender,
|
|
40
44
|
RowRender,
|
|
41
45
|
SelectRender,
|
|
@@ -425,6 +429,56 @@ export const ColPlugin: PluginType = {
|
|
|
425
429
|
},
|
|
426
430
|
};
|
|
427
431
|
|
|
432
|
+
export const ModalPlugin: PluginType = {
|
|
433
|
+
group: "容器组件",
|
|
434
|
+
key: "b-modal",
|
|
435
|
+
label: "弹窗",
|
|
436
|
+
icon: "icon-modal",
|
|
437
|
+
component: ModalRender,
|
|
438
|
+
formComponent: ModalProps,
|
|
439
|
+
defaultOptions: {
|
|
440
|
+
props: {
|
|
441
|
+
title: "标题",
|
|
442
|
+
width: 400,
|
|
443
|
+
okType: "primary",
|
|
444
|
+
okText: "确定",
|
|
445
|
+
cancelText: "取消",
|
|
446
|
+
maskClosable: true,
|
|
447
|
+
mask: true,
|
|
448
|
+
closable: true,
|
|
449
|
+
keyboard: true,
|
|
450
|
+
footer: false,
|
|
451
|
+
},
|
|
452
|
+
children: [],
|
|
453
|
+
},
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
export const DrawerPlugin: PluginType = {
|
|
457
|
+
group: "容器组件",
|
|
458
|
+
key: "b-drawer",
|
|
459
|
+
label: "抽屉",
|
|
460
|
+
icon: "icon-drawer",
|
|
461
|
+
component: DrawerRender,
|
|
462
|
+
formComponent: DrawerProps,
|
|
463
|
+
defaultOptions: {
|
|
464
|
+
props: {
|
|
465
|
+
title: "标题",
|
|
466
|
+
size: 400,
|
|
467
|
+
placement: "right",
|
|
468
|
+
okType: "primary",
|
|
469
|
+
okText: "确定",
|
|
470
|
+
cancelText: "取消",
|
|
471
|
+
closable: true,
|
|
472
|
+
keyboard: true,
|
|
473
|
+
maskClosable: true,
|
|
474
|
+
mask: true,
|
|
475
|
+
resizable: true,
|
|
476
|
+
footer: false,
|
|
477
|
+
},
|
|
478
|
+
children: [],
|
|
479
|
+
},
|
|
480
|
+
};
|
|
481
|
+
|
|
428
482
|
export const plugins: PluginType[] = [
|
|
429
483
|
TextPlugin,
|
|
430
484
|
ImagePlugin,
|
|
@@ -445,4 +499,6 @@ export const plugins: PluginType[] = [
|
|
|
445
499
|
CardPlugin,
|
|
446
500
|
RowPlugin,
|
|
447
501
|
ColPlugin,
|
|
502
|
+
ModalPlugin,
|
|
503
|
+
DrawerPlugin,
|
|
448
504
|
];
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { InfoCircleOutlined } from "@ant-design/icons";
|
|
2
|
+
import { Form, Input, InputNumber, Radio, Switch, Tooltip } from "antd";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import styled from "styled-components";
|
|
5
|
+
import type { PropEditorProps } from "./types";
|
|
6
|
+
|
|
7
|
+
const HelpIcon = styled(InfoCircleOutlined)`
|
|
8
|
+
vertical-align: middle;
|
|
9
|
+
margin-left: 2px;
|
|
10
|
+
color: var(--ant-color-text-description);
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export type DrawerModel = {
|
|
14
|
+
title?: string;
|
|
15
|
+
size?: number;
|
|
16
|
+
okType?: "primary" | "link" | "text" | "dashed" | "default";
|
|
17
|
+
okText?: string;
|
|
18
|
+
cancelText?: string;
|
|
19
|
+
resizable?: boolean;
|
|
20
|
+
placement?: "top" | "bottom" | "left" | "right";
|
|
21
|
+
closable?: boolean;
|
|
22
|
+
keyboard?: boolean;
|
|
23
|
+
mask?: boolean;
|
|
24
|
+
maskClosable?: boolean;
|
|
25
|
+
footer?: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 抽屉属性编辑器
|
|
30
|
+
*/
|
|
31
|
+
export const DrawerProps: React.FC<PropEditorProps<DrawerModel>> = ({
|
|
32
|
+
model,
|
|
33
|
+
onChange,
|
|
34
|
+
}) => {
|
|
35
|
+
const trigger = (key: keyof DrawerModel, value: any) =>
|
|
36
|
+
onChange && onChange({ ...model, [key]: value });
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Form labelCol={{ span: 8 }} wrapperCol={{ span: 16 }}>
|
|
40
|
+
<Form.Item label="标题">
|
|
41
|
+
<Input
|
|
42
|
+
size="small"
|
|
43
|
+
value={model.title}
|
|
44
|
+
onChange={(e) => trigger("title", e.target.value)}
|
|
45
|
+
/>
|
|
46
|
+
</Form.Item>
|
|
47
|
+
<Form.Item label="宽度">
|
|
48
|
+
<InputNumber
|
|
49
|
+
size="small"
|
|
50
|
+
style={{ width: "100px" }}
|
|
51
|
+
value={model.size}
|
|
52
|
+
suffix="px"
|
|
53
|
+
onChange={(v) => trigger("size", v)}
|
|
54
|
+
/>
|
|
55
|
+
</Form.Item>
|
|
56
|
+
<Form.Item label="抽屉位置">
|
|
57
|
+
<Radio.Group
|
|
58
|
+
size="small"
|
|
59
|
+
value={model.placement}
|
|
60
|
+
onChange={(e) => trigger("placement", e.target.value)}
|
|
61
|
+
>
|
|
62
|
+
<Radio.Button value="top">顶部</Radio.Button>
|
|
63
|
+
<Radio.Button value="bottom">底部</Radio.Button>
|
|
64
|
+
<Radio.Button value="left">左侧</Radio.Button>
|
|
65
|
+
<Radio.Button value="right">右侧</Radio.Button>
|
|
66
|
+
</Radio.Group>
|
|
67
|
+
</Form.Item>
|
|
68
|
+
<Form.Item label="确认按钮文字">
|
|
69
|
+
<Input
|
|
70
|
+
size="small"
|
|
71
|
+
style={{ width: "100px" }}
|
|
72
|
+
value={model.okText}
|
|
73
|
+
onChange={(e) => trigger("okText", e.target.value)}
|
|
74
|
+
/>
|
|
75
|
+
</Form.Item>
|
|
76
|
+
<Form.Item label="取消按钮文字">
|
|
77
|
+
<Input
|
|
78
|
+
size="small"
|
|
79
|
+
style={{ width: "100px" }}
|
|
80
|
+
value={model.cancelText}
|
|
81
|
+
onChange={(e) => trigger("cancelText", e.target.value)}
|
|
82
|
+
/>
|
|
83
|
+
</Form.Item>
|
|
84
|
+
<Form.Item label="确认按钮类型">
|
|
85
|
+
<Radio.Group
|
|
86
|
+
size="small"
|
|
87
|
+
value={model.okType}
|
|
88
|
+
onChange={(e) => trigger("okType", e.target.value)}
|
|
89
|
+
>
|
|
90
|
+
<Radio.Button value="default">默认</Radio.Button>
|
|
91
|
+
<Radio.Button value="primary">主要</Radio.Button>
|
|
92
|
+
<Radio.Button value="dashed">虚线</Radio.Button>
|
|
93
|
+
</Radio.Group>
|
|
94
|
+
</Form.Item>
|
|
95
|
+
<Form.Item label="关闭按钮">
|
|
96
|
+
<Switch
|
|
97
|
+
size="small"
|
|
98
|
+
checked={model.closable}
|
|
99
|
+
onChange={(v) => trigger("closable", v)}
|
|
100
|
+
/>
|
|
101
|
+
</Form.Item>
|
|
102
|
+
<Form.Item
|
|
103
|
+
label={
|
|
104
|
+
<>
|
|
105
|
+
ESC关闭{" "}
|
|
106
|
+
<Tooltip title="是否支持键盘 esc 关闭">
|
|
107
|
+
<HelpIcon />
|
|
108
|
+
</Tooltip>
|
|
109
|
+
</>
|
|
110
|
+
}
|
|
111
|
+
>
|
|
112
|
+
<Switch
|
|
113
|
+
size="small"
|
|
114
|
+
checked={model.keyboard}
|
|
115
|
+
onChange={(v) => trigger("keyboard", v)}
|
|
116
|
+
/>
|
|
117
|
+
</Form.Item>
|
|
118
|
+
<Form.Item label="显示遮罩">
|
|
119
|
+
<Switch
|
|
120
|
+
size="small"
|
|
121
|
+
checked={model.mask}
|
|
122
|
+
onChange={(v) => trigger("mask", v)}
|
|
123
|
+
/>
|
|
124
|
+
</Form.Item>
|
|
125
|
+
<Form.Item
|
|
126
|
+
label={
|
|
127
|
+
<>
|
|
128
|
+
遮罩关闭{" "}
|
|
129
|
+
<Tooltip title="点击遮罩层是否允许关闭">
|
|
130
|
+
<HelpIcon />
|
|
131
|
+
</Tooltip>
|
|
132
|
+
</>
|
|
133
|
+
}
|
|
134
|
+
>
|
|
135
|
+
<Switch
|
|
136
|
+
size="small"
|
|
137
|
+
checked={model.maskClosable}
|
|
138
|
+
onChange={(v) => trigger("maskClosable", v)}
|
|
139
|
+
/>
|
|
140
|
+
</Form.Item>
|
|
141
|
+
<Form.Item label="可调整大小">
|
|
142
|
+
<Switch
|
|
143
|
+
size="small"
|
|
144
|
+
checked={model.resizable}
|
|
145
|
+
onChange={(v) => trigger("resizable", v)}
|
|
146
|
+
/>
|
|
147
|
+
</Form.Item>
|
|
148
|
+
{/* <Form.Item label="显示底部">
|
|
149
|
+
<Switch
|
|
150
|
+
size="small"
|
|
151
|
+
checked={model.footer}
|
|
152
|
+
onChange={(v) => trigger("footer", v)}
|
|
153
|
+
/>
|
|
154
|
+
</Form.Item> */}
|
|
155
|
+
</Form>
|
|
156
|
+
);
|
|
157
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { InfoCircleOutlined } from "@ant-design/icons";
|
|
2
|
+
import { Form, Input, InputNumber, Radio, Switch, Tooltip } from "antd";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import styled from "styled-components";
|
|
5
|
+
import type { PropEditorProps } from "./types";
|
|
6
|
+
|
|
7
|
+
const HelpIcon = styled(InfoCircleOutlined)`
|
|
8
|
+
vertical-align: middle;
|
|
9
|
+
margin-left: 2px;
|
|
10
|
+
color: var(--ant-color-text-description);
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export type ModalModel = {
|
|
14
|
+
title?: string;
|
|
15
|
+
width?: number;
|
|
16
|
+
okType?: "primary" | "link" | "text" | "dashed" | "default";
|
|
17
|
+
okText?: string;
|
|
18
|
+
cancelText?: string;
|
|
19
|
+
closable?: boolean;
|
|
20
|
+
keyboard?: boolean;
|
|
21
|
+
mask?: boolean;
|
|
22
|
+
maskClosable?: boolean;
|
|
23
|
+
footer?: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 模态框属性编辑器
|
|
28
|
+
*/
|
|
29
|
+
export const ModalProps: React.FC<PropEditorProps<ModalModel>> = ({
|
|
30
|
+
model,
|
|
31
|
+
onChange,
|
|
32
|
+
}) => {
|
|
33
|
+
const trigger = (key: keyof ModalModel, value: any) =>
|
|
34
|
+
onChange && onChange({ ...model, [key]: value });
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Form labelCol={{ span: 8 }} wrapperCol={{ span: 16 }}>
|
|
38
|
+
<Form.Item label="标题">
|
|
39
|
+
<Input
|
|
40
|
+
size="small"
|
|
41
|
+
value={model.title}
|
|
42
|
+
onChange={(e) => trigger("title", e.target.value)}
|
|
43
|
+
/>
|
|
44
|
+
</Form.Item>
|
|
45
|
+
<Form.Item label="宽度">
|
|
46
|
+
<InputNumber
|
|
47
|
+
size="small"
|
|
48
|
+
style={{ width: "100px" }}
|
|
49
|
+
value={model.width}
|
|
50
|
+
suffix="px"
|
|
51
|
+
onChange={(v) => trigger("width", v)}
|
|
52
|
+
/>
|
|
53
|
+
</Form.Item>
|
|
54
|
+
<Form.Item label="确认按钮文字">
|
|
55
|
+
<Input
|
|
56
|
+
size="small"
|
|
57
|
+
style={{ width: "100px" }}
|
|
58
|
+
value={model.okText}
|
|
59
|
+
onChange={(e) => trigger("okText", e.target.value)}
|
|
60
|
+
/>
|
|
61
|
+
</Form.Item>
|
|
62
|
+
<Form.Item label="取消按钮文字">
|
|
63
|
+
<Input
|
|
64
|
+
size="small"
|
|
65
|
+
style={{ width: "100px" }}
|
|
66
|
+
value={model.cancelText}
|
|
67
|
+
onChange={(e) => trigger("cancelText", e.target.value)}
|
|
68
|
+
/>
|
|
69
|
+
</Form.Item>
|
|
70
|
+
<Form.Item label="确认按钮类型">
|
|
71
|
+
<Radio.Group
|
|
72
|
+
size="small"
|
|
73
|
+
value={model.okType}
|
|
74
|
+
onChange={(e) => trigger("okType", e.target.value)}
|
|
75
|
+
>
|
|
76
|
+
<Radio.Button value="default">默认</Radio.Button>
|
|
77
|
+
<Radio.Button value="primary">主要</Radio.Button>
|
|
78
|
+
<Radio.Button value="dashed">虚线</Radio.Button>
|
|
79
|
+
</Radio.Group>
|
|
80
|
+
</Form.Item>
|
|
81
|
+
<Form.Item label="关闭按钮">
|
|
82
|
+
<Switch
|
|
83
|
+
size="small"
|
|
84
|
+
checked={model.closable}
|
|
85
|
+
onChange={(v) => trigger("closable", v)}
|
|
86
|
+
/>
|
|
87
|
+
</Form.Item>
|
|
88
|
+
<Form.Item
|
|
89
|
+
label={
|
|
90
|
+
<>
|
|
91
|
+
ESC关闭{" "}
|
|
92
|
+
<Tooltip title="是否支持键盘 esc 关闭">
|
|
93
|
+
<HelpIcon />
|
|
94
|
+
</Tooltip>
|
|
95
|
+
</>
|
|
96
|
+
}
|
|
97
|
+
>
|
|
98
|
+
<Switch
|
|
99
|
+
size="small"
|
|
100
|
+
checked={model.keyboard}
|
|
101
|
+
onChange={(v) => trigger("keyboard", v)}
|
|
102
|
+
/>
|
|
103
|
+
</Form.Item>
|
|
104
|
+
<Form.Item label="显示遮罩">
|
|
105
|
+
<Switch
|
|
106
|
+
size="small"
|
|
107
|
+
checked={model.mask}
|
|
108
|
+
onChange={(v) => trigger("mask", v)}
|
|
109
|
+
/>
|
|
110
|
+
</Form.Item>
|
|
111
|
+
<Form.Item
|
|
112
|
+
label={
|
|
113
|
+
<>
|
|
114
|
+
遮罩关闭{" "}
|
|
115
|
+
<Tooltip title="点击遮罩层是否允许关闭">
|
|
116
|
+
<HelpIcon />
|
|
117
|
+
</Tooltip>
|
|
118
|
+
</>
|
|
119
|
+
}
|
|
120
|
+
>
|
|
121
|
+
<Switch
|
|
122
|
+
size="small"
|
|
123
|
+
checked={model.maskClosable}
|
|
124
|
+
onChange={(v) => trigger("maskClosable", v)}
|
|
125
|
+
/>
|
|
126
|
+
</Form.Item>
|
|
127
|
+
{/* <Form.Item label="显示底部">
|
|
128
|
+
<Switch
|
|
129
|
+
size="small"
|
|
130
|
+
checked={model.footer}
|
|
131
|
+
onChange={(v) => trigger("footer", v)}
|
|
132
|
+
/>
|
|
133
|
+
</Form.Item> */}
|
|
134
|
+
</Form>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
@@ -16,5 +16,7 @@ export { TableProps } from './TableProps'
|
|
|
16
16
|
export { PageHeaderProps } from './PageHeaderProps'
|
|
17
17
|
export { RowProps } from './RowProps'
|
|
18
18
|
export { ColProps } from './ColProps'
|
|
19
|
+
export { ModalProps } from './ModalProps'
|
|
19
20
|
export { SpaceProps } from './SpaceProps'
|
|
21
|
+
export { DrawerProps } from './DrawerProps'
|
|
20
22
|
|