@zat-design/sisyphus-react 4.5.0 → 4.5.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/index.esm.css +1 -1
- package/dist/less.esm.css +1 -1
- package/es/ProDrawerForm/components/ProDrawer/index.js +58 -86
- package/es/ProDrawerForm/components/ProModal/index.js +44 -20
- package/es/ProDrawerForm/hooks/useConfirmClose.d.ts +25 -0
- package/es/ProDrawerForm/hooks/useConfirmClose.js +70 -0
- package/es/ProDrawerForm/index.js +7 -11
- package/es/ProDrawerForm/propsType.d.ts +14 -3
- package/es/ProDrawerForm/utils/index.d.ts +19 -0
- package/es/ProDrawerForm/utils/index.js +36 -0
- package/es/ProEditTable/components/RcTable/BaseTable.js +10 -0
- package/es/ProEnum/index.js +6 -3
- package/es/ProForm/components/combination/Group/utils/index.d.ts +17 -17
- package/es/ProForm/components/combination/ProModalSelect/index.js +6 -1
- package/es/ProForm/components/combination/ProModalSelect/utils/mergeSelectedRows.d.ts +14 -0
- package/es/ProForm/components/combination/ProModalSelect/utils/mergeSelectedRows.js +26 -0
- package/es/ProIcon/propsTypes.d.ts +2 -2
- package/es/ProSelect/index.js +23 -11
- package/es/ProSelect/propsType.d.ts +2 -0
- package/es/ProTable/propsType.d.ts +1 -1
- package/es/ProTree/components/ProTreeSelect/index.js +24 -11
- package/es/ProTree/components/ProTreeSelect/propsType.d.ts +6 -0
- package/es/ProTree/components/ProTreeSelect/style/index.less +13 -4
- package/es/ProTree/propsType.d.ts +6 -0
- package/es/ProTree/style/index.less +20 -9
- package/es/ProTree/utils.d.ts +10 -0
- package/es/ProTree/utils.js +26 -0
- package/es/ProTreeModal/style/index.less +1 -1
- package/es/ProViewer/propsType.d.ts +2 -0
- package/es/ProViewer/propsType.js +3 -1
- package/es/index.d.ts +17 -6
- package/es/index.js +10 -0
- package/package.json +7 -13
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import _omit from "lodash/omit";
|
|
2
2
|
import _isArray from "lodash/isArray";
|
|
3
|
-
import { Button, Drawer
|
|
4
|
-
import React, { useCallback, useState, useRef
|
|
3
|
+
import { Button, Drawer } from 'antd';
|
|
4
|
+
import React, { useCallback, useState, useRef } from 'react';
|
|
5
5
|
import { useScroll } from 'ahooks';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import { ReactSVG } from 'react-svg';
|
|
8
8
|
import closeSvg from "../../../assets/close.svg";
|
|
9
|
-
import
|
|
9
|
+
import { useConfirmClose } from "../../hooks/useConfirmClose";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* 抽屉组件
|
|
13
13
|
*/
|
|
14
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
15
15
|
const ProDrawer = ({
|
|
16
16
|
form,
|
|
17
17
|
title,
|
|
@@ -31,67 +31,32 @@ const ProDrawer = ({
|
|
|
31
31
|
children,
|
|
32
32
|
className,
|
|
33
33
|
zIndex,
|
|
34
|
+
destroyOnHidden,
|
|
34
35
|
drawerProps
|
|
35
36
|
}) => {
|
|
36
37
|
const ref = useRef(null);
|
|
37
|
-
const modalRef = useRef(null);
|
|
38
38
|
const {
|
|
39
39
|
top
|
|
40
40
|
} = useScroll(ref) || {};
|
|
41
41
|
const [loading, toggleLoading] = useState(false);
|
|
42
|
-
const [initialSnapshot, setInitialSnapshot] = useState('');
|
|
43
42
|
const noRenderFooter = isView || footer === false || footer === null;
|
|
44
43
|
const {
|
|
45
44
|
mask: drawerMask,
|
|
46
45
|
...restDrawerProps
|
|
47
46
|
} = drawerProps || {};
|
|
48
|
-
|
|
49
|
-
const drawerSize = restDrawerProps?.size;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return () => clearTimeout(timeoutId); // 清理定时器
|
|
62
|
-
}
|
|
63
|
-
setInitialSnapshot('');
|
|
64
|
-
}, [open]); // 当 open 变化时执行
|
|
65
|
-
|
|
66
|
-
// 快照对比
|
|
67
|
-
const compareSnapshots = () => {
|
|
68
|
-
if (!ref.current) return false;
|
|
69
|
-
return ref.current.innerHTML === initialSnapshot;
|
|
70
|
-
};
|
|
71
|
-
const onConfirm = useCallback(async () => {
|
|
72
|
-
// 如果当前是查看状态,或者不需要确认关闭,或者快照对比一致,则直接关闭
|
|
73
|
-
if (isView || !isConfirmClose || compareSnapshots()) {
|
|
74
|
-
onCancel && onCancel();
|
|
75
|
-
} else if (!modalRef.current) {
|
|
76
|
-
modalRef.current = Modal.confirm({
|
|
77
|
-
className: 'width430',
|
|
78
|
-
title: locale?.ProDrawerForm?.isSureClose,
|
|
79
|
-
okText: locale?.ProDrawerForm?.confirm,
|
|
80
|
-
cancelText: locale?.ProDrawerForm?.cancel,
|
|
81
|
-
content: locale?.ProDrawerForm?.secondTipsWhenSave,
|
|
82
|
-
mask: {
|
|
83
|
-
blur: false
|
|
84
|
-
},
|
|
85
|
-
onOk: () => {
|
|
86
|
-
onCancel && onCancel();
|
|
87
|
-
},
|
|
88
|
-
onCancel: () => {
|
|
89
|
-
modalRef.current = null;
|
|
90
|
-
},
|
|
91
|
-
...isConfirmCloseModalProps
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
}, [onCancel, modalRef.current, ref.current]);
|
|
47
|
+
// 抽屉宽度统一走 size(antd v6 width 已废弃);数字优先,自定义 width 兜底
|
|
48
|
+
const drawerSize = restDrawerProps?.size ?? width;
|
|
49
|
+
const {
|
|
50
|
+
markInteracted,
|
|
51
|
+
onConfirm,
|
|
52
|
+
contextHolder
|
|
53
|
+
} = useConfirmClose({
|
|
54
|
+
open,
|
|
55
|
+
isView,
|
|
56
|
+
isConfirmClose,
|
|
57
|
+
isConfirmCloseModalProps,
|
|
58
|
+
onCancel
|
|
59
|
+
});
|
|
95
60
|
const handleFinish = useCallback(async () => {
|
|
96
61
|
try {
|
|
97
62
|
if (open) {
|
|
@@ -164,40 +129,47 @@ const ProDrawer = ({
|
|
|
164
129
|
}
|
|
165
130
|
return defaultFooter;
|
|
166
131
|
};
|
|
167
|
-
return /*#__PURE__*/_jsxs(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
closable: false,
|
|
178
|
-
onClose: onCancel,
|
|
179
|
-
zIndex: zIndex,
|
|
180
|
-
..._omit(restDrawerProps, 'width', 'size'),
|
|
181
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
182
|
-
className: "pro-drawer-close",
|
|
183
|
-
onClick: onConfirm,
|
|
184
|
-
children: /*#__PURE__*/_jsx(ReactSVG, {
|
|
185
|
-
className: "close-icon",
|
|
186
|
-
src: closeSvg
|
|
187
|
-
})
|
|
188
|
-
}), title ? /*#__PURE__*/_jsx("div", {
|
|
189
|
-
className: `pro-drawer-title ${top > 0 ? 'pro-drawer-scrolling' : ''}`,
|
|
190
|
-
children: title
|
|
191
|
-
}) : null, /*#__PURE__*/_jsx("div", {
|
|
192
|
-
ref: ref,
|
|
193
|
-
className: "pro-drawer-content",
|
|
194
|
-
style: {
|
|
195
|
-
marginTop: title ? 64 : 0,
|
|
196
|
-
paddingBottom: noRenderFooter ? 0 : 64,
|
|
197
|
-
height: `calc(100% - ${title ? 64 : 0}px)`
|
|
132
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
133
|
+
children: [contextHolder, /*#__PURE__*/_jsxs(Drawer, {
|
|
134
|
+
size: drawerSize,
|
|
135
|
+
open: open,
|
|
136
|
+
mask: typeof drawerMask === 'object' ? {
|
|
137
|
+
closable: maskClosable,
|
|
138
|
+
...drawerMask
|
|
139
|
+
} : drawerMask ?? {
|
|
140
|
+
blur: false,
|
|
141
|
+
closable: maskClosable
|
|
198
142
|
},
|
|
199
|
-
|
|
200
|
-
|
|
143
|
+
placement: "right",
|
|
144
|
+
rootClassName: classNames(className, 'pro-drawer'),
|
|
145
|
+
closable: false,
|
|
146
|
+
onClose: onConfirm,
|
|
147
|
+
zIndex: zIndex,
|
|
148
|
+
destroyOnHidden: destroyOnHidden,
|
|
149
|
+
..._omit(restDrawerProps, 'width', 'size'),
|
|
150
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
151
|
+
className: "pro-drawer-close",
|
|
152
|
+
onClick: onConfirm,
|
|
153
|
+
children: /*#__PURE__*/_jsx(ReactSVG, {
|
|
154
|
+
className: "close-icon",
|
|
155
|
+
src: closeSvg
|
|
156
|
+
})
|
|
157
|
+
}), title ? /*#__PURE__*/_jsx("div", {
|
|
158
|
+
className: `pro-drawer-title ${top > 0 ? 'pro-drawer-scrolling' : ''}`,
|
|
159
|
+
children: title
|
|
160
|
+
}) : null, /*#__PURE__*/_jsx("div", {
|
|
161
|
+
ref: ref,
|
|
162
|
+
className: "pro-drawer-content",
|
|
163
|
+
onInput: markInteracted,
|
|
164
|
+
onChange: markInteracted,
|
|
165
|
+
style: {
|
|
166
|
+
marginTop: title ? 64 : 0,
|
|
167
|
+
paddingBottom: noRenderFooter ? 0 : 64,
|
|
168
|
+
height: `calc(100% - ${title ? 64 : 0}px)`
|
|
169
|
+
},
|
|
170
|
+
children: children
|
|
171
|
+
}), renderFooter()]
|
|
172
|
+
})]
|
|
201
173
|
});
|
|
202
174
|
};
|
|
203
175
|
export default ProDrawer;
|
|
@@ -3,10 +3,12 @@ import React, { useCallback, useState, useRef } from 'react';
|
|
|
3
3
|
import { Space, Button, Modal } from 'antd';
|
|
4
4
|
import { useScroll, useSize } from 'ahooks';
|
|
5
5
|
import classnames from 'classnames';
|
|
6
|
-
import {
|
|
6
|
+
import { useConfirmClose } from "../../hooks/useConfirmClose";
|
|
7
|
+
|
|
7
8
|
/**
|
|
8
9
|
* 弹窗组件
|
|
9
10
|
*/
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
12
|
const ProModal = ({
|
|
11
13
|
form,
|
|
12
14
|
title,
|
|
@@ -15,6 +17,8 @@ const ProModal = ({
|
|
|
15
17
|
footer,
|
|
16
18
|
isView,
|
|
17
19
|
maskClosable,
|
|
20
|
+
isConfirmClose,
|
|
21
|
+
isConfirmCloseModalProps,
|
|
18
22
|
okText,
|
|
19
23
|
cancelText,
|
|
20
24
|
okLoading,
|
|
@@ -25,6 +29,7 @@ const ProModal = ({
|
|
|
25
29
|
className,
|
|
26
30
|
extraLeft,
|
|
27
31
|
zIndex,
|
|
32
|
+
destroyOnHidden,
|
|
28
33
|
modalProps
|
|
29
34
|
}) => {
|
|
30
35
|
const ref = useRef(null);
|
|
@@ -40,6 +45,17 @@ const ProModal = ({
|
|
|
40
45
|
...restModalProps
|
|
41
46
|
} = modalProps || {};
|
|
42
47
|
const [loading, toggleLoading] = useState(false);
|
|
48
|
+
const {
|
|
49
|
+
markInteracted,
|
|
50
|
+
onConfirm,
|
|
51
|
+
contextHolder
|
|
52
|
+
} = useConfirmClose({
|
|
53
|
+
open,
|
|
54
|
+
isView,
|
|
55
|
+
isConfirmClose,
|
|
56
|
+
isConfirmCloseModalProps,
|
|
57
|
+
onCancel
|
|
58
|
+
});
|
|
43
59
|
const _className = classnames(['pro-modal', className, {
|
|
44
60
|
'pro-modal-scrolling': top > 0,
|
|
45
61
|
'pro-modal-no-footer': noRenderFooter,
|
|
@@ -122,25 +138,33 @@ const ProModal = ({
|
|
|
122
138
|
}
|
|
123
139
|
return defaultFooter;
|
|
124
140
|
};
|
|
125
|
-
return /*#__PURE__*/
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
142
|
+
children: [contextHolder, /*#__PURE__*/_jsx(Modal, {
|
|
143
|
+
className: _className,
|
|
144
|
+
title: title,
|
|
145
|
+
width: width,
|
|
146
|
+
open: open,
|
|
147
|
+
mask: typeof modalMask === 'object' ? {
|
|
148
|
+
closable: maskClosable,
|
|
149
|
+
...modalMask
|
|
150
|
+
} : modalMask ?? {
|
|
151
|
+
blur: false,
|
|
152
|
+
closable: maskClosable
|
|
153
|
+
},
|
|
154
|
+
onCancel: onConfirm,
|
|
155
|
+
footer: renderFooter(),
|
|
156
|
+
okText: okText,
|
|
157
|
+
cancelText: cancelText,
|
|
158
|
+
zIndex: zIndex,
|
|
159
|
+
destroyOnHidden: destroyOnHidden,
|
|
160
|
+
...restModalProps,
|
|
161
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
162
|
+
ref: ref,
|
|
163
|
+
onInput: markInteracted,
|
|
164
|
+
onChange: markInteracted,
|
|
165
|
+
children: children
|
|
166
|
+
})
|
|
167
|
+
})]
|
|
144
168
|
});
|
|
145
169
|
};
|
|
146
170
|
export default ProModal;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ProDrawerFormType } from '../propsType';
|
|
3
|
+
interface UseConfirmCloseParams {
|
|
4
|
+
open?: boolean;
|
|
5
|
+
isView?: boolean;
|
|
6
|
+
isConfirmClose?: boolean;
|
|
7
|
+
isConfirmCloseModalProps?: ProDrawerFormType['isConfirmCloseModalProps'];
|
|
8
|
+
onCancel?: ProDrawerFormType['onCancel'];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 关闭抽屉/弹窗时的二次确认逻辑
|
|
12
|
+
*
|
|
13
|
+
* - markInteracted:绑定到内容容器的 input / change 事件,标记用户真实交互过。
|
|
14
|
+
* setFieldsValue 等程序回填不会派发用户输入事件,因此异步回填不会误触发二次确认。
|
|
15
|
+
* - onConfirm:组件自带关闭入口(右上角 × / 遮罩)的关闭处理。未交互、查看模式或
|
|
16
|
+
* 未开启二次确认时直接关闭;否则弹出二次确认。底部取消按钮不走此逻辑。
|
|
17
|
+
* - contextHolder:Modal.useModal 的上下文占位,需渲染进组件,使二次确认弹框能继承
|
|
18
|
+
* ConfigProvider 的主题 / 国际化(替代静态 Modal.confirm,消除上下文告警)。
|
|
19
|
+
*/
|
|
20
|
+
export declare const useConfirmClose: ({ open, isView, isConfirmClose, isConfirmCloseModalProps, onCancel, }: UseConfirmCloseParams) => {
|
|
21
|
+
markInteracted: () => void;
|
|
22
|
+
onConfirm: () => void;
|
|
23
|
+
contextHolder: import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import { Modal } from 'antd';
|
|
3
|
+
import { shouldConfirmClose } from "../utils";
|
|
4
|
+
import locale from "../../locale";
|
|
5
|
+
/**
|
|
6
|
+
* 关闭抽屉/弹窗时的二次确认逻辑
|
|
7
|
+
*
|
|
8
|
+
* - markInteracted:绑定到内容容器的 input / change 事件,标记用户真实交互过。
|
|
9
|
+
* setFieldsValue 等程序回填不会派发用户输入事件,因此异步回填不会误触发二次确认。
|
|
10
|
+
* - onConfirm:组件自带关闭入口(右上角 × / 遮罩)的关闭处理。未交互、查看模式或
|
|
11
|
+
* 未开启二次确认时直接关闭;否则弹出二次确认。底部取消按钮不走此逻辑。
|
|
12
|
+
* - contextHolder:Modal.useModal 的上下文占位,需渲染进组件,使二次确认弹框能继承
|
|
13
|
+
* ConfigProvider 的主题 / 国际化(替代静态 Modal.confirm,消除上下文告警)。
|
|
14
|
+
*/
|
|
15
|
+
export const useConfirmClose = ({
|
|
16
|
+
open,
|
|
17
|
+
isView,
|
|
18
|
+
isConfirmClose,
|
|
19
|
+
isConfirmCloseModalProps,
|
|
20
|
+
onCancel
|
|
21
|
+
}) => {
|
|
22
|
+
const [modal, contextHolder] = Modal.useModal();
|
|
23
|
+
// 记录用户是否真实交互过表单内容(区别于 setFieldsValue 等程序回填)
|
|
24
|
+
const userInteractedRef = useRef(false);
|
|
25
|
+
const confirmingRef = useRef(false);
|
|
26
|
+
|
|
27
|
+
// open 变化时重置用户交互标记
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
userInteractedRef.current = false;
|
|
30
|
+
}, [open]);
|
|
31
|
+
const markInteracted = useCallback(() => {
|
|
32
|
+
userInteractedRef.current = true;
|
|
33
|
+
}, []);
|
|
34
|
+
const onConfirm = useCallback(() => {
|
|
35
|
+
// 用户真实交互过才弹二次确认;查看模式、未开启确认、或仅程序回填均直接关闭
|
|
36
|
+
if (!shouldConfirmClose({
|
|
37
|
+
isView,
|
|
38
|
+
isConfirmClose,
|
|
39
|
+
userInteracted: userInteractedRef.current
|
|
40
|
+
})) {
|
|
41
|
+
onCancel?.();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (confirmingRef.current) return;
|
|
45
|
+
confirmingRef.current = true;
|
|
46
|
+
modal.confirm({
|
|
47
|
+
className: 'width430',
|
|
48
|
+
title: locale?.ProDrawerForm?.isSureClose,
|
|
49
|
+
okText: locale?.ProDrawerForm?.confirm,
|
|
50
|
+
cancelText: locale?.ProDrawerForm?.cancel,
|
|
51
|
+
content: locale?.ProDrawerForm?.secondTipsWhenSave,
|
|
52
|
+
mask: {
|
|
53
|
+
blur: false
|
|
54
|
+
},
|
|
55
|
+
onOk: () => {
|
|
56
|
+
confirmingRef.current = false;
|
|
57
|
+
onCancel?.();
|
|
58
|
+
},
|
|
59
|
+
onCancel: () => {
|
|
60
|
+
confirmingRef.current = false;
|
|
61
|
+
},
|
|
62
|
+
...isConfirmCloseModalProps
|
|
63
|
+
});
|
|
64
|
+
}, [isView, isConfirmClose, isConfirmCloseModalProps, onCancel, modal]);
|
|
65
|
+
return {
|
|
66
|
+
markInteracted,
|
|
67
|
+
onConfirm,
|
|
68
|
+
contextHolder
|
|
69
|
+
};
|
|
70
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { createContext, forwardRef, useContext, useImperativeHandle, useMemo } from 'react';
|
|
2
2
|
import { ProDrawer, ProModal } from "./components";
|
|
3
3
|
import ProForm from "../ProForm";
|
|
4
|
-
import {
|
|
4
|
+
import { resolveDrawerSize } from "./utils";
|
|
5
5
|
import locale from "../locale";
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
const ProDrawerFormContext = /*#__PURE__*/createContext(null);
|
|
@@ -26,17 +26,13 @@ const ProDrawerForm = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
26
26
|
} = props;
|
|
27
27
|
const nextIsView = isView || disabled;
|
|
28
28
|
const nextOkText = okText ?? (mode === 'Drawer' ? locale?.ProDrawerForm?.save : locale?.ProDrawerForm?.confirm);
|
|
29
|
-
|
|
30
|
-
width
|
|
29
|
+
const {
|
|
30
|
+
width: deprecatedWidth,
|
|
31
|
+
...restPropsWithoutWidth
|
|
31
32
|
} = restProps;
|
|
32
|
-
if (!width && size) {
|
|
33
|
-
width = transformBySize(size);
|
|
34
|
-
}
|
|
35
33
|
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
width = `${width}px`;
|
|
39
|
-
}
|
|
34
|
+
// size 优先;显式传入(已废弃的)width 仍兼容生效并告警
|
|
35
|
+
const width = resolveDrawerSize(size, deprecatedWidth);
|
|
40
36
|
const [form] = ProForm.useForm(originalForm);
|
|
41
37
|
const handleCancel = () => {
|
|
42
38
|
onCloseClean && form.resetFields();
|
|
@@ -56,7 +52,7 @@ const ProDrawerForm = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
56
52
|
source: 'ProDrawerForm'
|
|
57
53
|
},
|
|
58
54
|
children: open ? /*#__PURE__*/_jsx(DrawerModal, {
|
|
59
|
-
...
|
|
55
|
+
...restPropsWithoutWidth,
|
|
60
56
|
isView: nextIsView,
|
|
61
57
|
open: open,
|
|
62
58
|
form: form,
|
|
@@ -26,7 +26,10 @@ export interface ProDrawerFormType {
|
|
|
26
26
|
disabled?: boolean | undefined;
|
|
27
27
|
/** @name 是否查看模式 */
|
|
28
28
|
isView?: boolean | undefined;
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* @name 宽度
|
|
31
|
+
* @deprecated 请改用 `size`,`width` 仅作向后兼容保留,后续版本将移除
|
|
32
|
+
*/
|
|
30
33
|
width?: string | number;
|
|
31
34
|
/** @name 取消按钮文字 */
|
|
32
35
|
cancelText?: ModalProps['cancelText'];
|
|
@@ -38,8 +41,11 @@ export interface ProDrawerFormType {
|
|
|
38
41
|
okDisabled?: boolean;
|
|
39
42
|
/** @name 显示方式 */
|
|
40
43
|
mode?: ShowType;
|
|
41
|
-
/**
|
|
42
|
-
|
|
44
|
+
/**
|
|
45
|
+
* @name 尺寸
|
|
46
|
+
* @description 设计规范三档枚举(small/middle/large),亦支持自定义数字 / 像素 / 百分比
|
|
47
|
+
*/
|
|
48
|
+
size?: DrawerSizeType | number | string;
|
|
43
49
|
/**
|
|
44
50
|
* @name 自动选中第一项
|
|
45
51
|
* @description 只对有input的类型有效
|
|
@@ -92,6 +98,11 @@ export interface ProDrawerFormType {
|
|
|
92
98
|
* @name 关闭时弹框或者抽屉是否清空formValues
|
|
93
99
|
*/
|
|
94
100
|
onCloseClean?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* @name 隐藏时销毁内容
|
|
103
|
+
* @description 透传给底层 antd Drawer/Modal
|
|
104
|
+
*/
|
|
105
|
+
destroyOnHidden?: ModalProps['destroyOnHidden'] | DrawerProps['destroyOnHidden'];
|
|
95
106
|
/** @name 子组件 */
|
|
96
107
|
children?: React.ReactNode;
|
|
97
108
|
/** @name z轴层级 */
|
|
@@ -4,3 +4,22 @@ import { DrawerSizeType } from '../propsType';
|
|
|
4
4
|
* @param size 设计规范的三个尺寸 460 960 1200 对应 'small' | 'middle' | 'large'
|
|
5
5
|
*/
|
|
6
6
|
export declare const transformBySize: (size: DrawerSizeType) => number;
|
|
7
|
+
/**
|
|
8
|
+
* 解析最终尺寸
|
|
9
|
+
*
|
|
10
|
+
* - 显式传入(已废弃的)`width` 时打印警告并优先生效,保证向后兼容。
|
|
11
|
+
* - `size` 命中三档枚举走 `transformBySize`;否则视为自定义数字 / 像素 / 百分比直接返回。
|
|
12
|
+
*/
|
|
13
|
+
export declare const resolveDrawerSize: (size: DrawerSizeType | number | string | undefined, width: number | string | undefined) => number | string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* 关闭抽屉时是否需要弹出二次确认
|
|
16
|
+
*
|
|
17
|
+
* 判定「用户是否真实改动过」依据 userInteracted —— 它由抽屉内容容器上监听到的
|
|
18
|
+
* 真实用户输入事件(input / change)置位。打开后通过 setFieldsValue 异步回填
|
|
19
|
+
* 详情数据属于程序行为,不会派发这些用户事件,因此不会误触发二次确认。
|
|
20
|
+
*/
|
|
21
|
+
export declare const shouldConfirmClose: (params: {
|
|
22
|
+
isView?: boolean;
|
|
23
|
+
isConfirmClose?: boolean;
|
|
24
|
+
userInteracted: boolean;
|
|
25
|
+
}) => boolean;
|
|
@@ -13,4 +13,40 @@ export const transformBySize = size => {
|
|
|
13
13
|
default:
|
|
14
14
|
return 960;
|
|
15
15
|
}
|
|
16
|
+
};
|
|
17
|
+
const SIZE_PRESETS = ['small', 'middle', 'large'];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 解析最终尺寸
|
|
21
|
+
*
|
|
22
|
+
* - 显式传入(已废弃的)`width` 时打印警告并优先生效,保证向后兼容。
|
|
23
|
+
* - `size` 命中三档枚举走 `transformBySize`;否则视为自定义数字 / 像素 / 百分比直接返回。
|
|
24
|
+
*/
|
|
25
|
+
export const resolveDrawerSize = (size, width) => {
|
|
26
|
+
if (width !== undefined && width !== '') {
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
28
|
+
console.warn('[ProDrawerForm] `width` 已废弃,请改用 `size`');
|
|
29
|
+
return width;
|
|
30
|
+
}
|
|
31
|
+
if (SIZE_PRESETS.includes(size)) {
|
|
32
|
+
return transformBySize(size);
|
|
33
|
+
}
|
|
34
|
+
return size;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 关闭抽屉时是否需要弹出二次确认
|
|
39
|
+
*
|
|
40
|
+
* 判定「用户是否真实改动过」依据 userInteracted —— 它由抽屉内容容器上监听到的
|
|
41
|
+
* 真实用户输入事件(input / change)置位。打开后通过 setFieldsValue 异步回填
|
|
42
|
+
* 详情数据属于程序行为,不会派发这些用户事件,因此不会误触发二次确认。
|
|
43
|
+
*/
|
|
44
|
+
export const shouldConfirmClose = params => {
|
|
45
|
+
const {
|
|
46
|
+
isView,
|
|
47
|
+
isConfirmClose,
|
|
48
|
+
userInteracted
|
|
49
|
+
} = params;
|
|
50
|
+
if (isView || !isConfirmClose) return false;
|
|
51
|
+
return userInteracted;
|
|
16
52
|
};
|
|
@@ -2,7 +2,11 @@ import _isFunction from "lodash/isFunction";
|
|
|
2
2
|
import { memo, useCallback } from 'react';
|
|
3
3
|
import { Badge, Table } from 'antd';
|
|
4
4
|
import useEditTableError from "../../utils/useEditTableError";
|
|
5
|
+
|
|
6
|
+
// 可编辑表格虚拟滚动的固定行高(px)。值取自单元格编辑态实际行高,
|
|
7
|
+
// 透传给内部 rc-virtual-list 用于高度计算,减少滚动时的行测量开销。
|
|
5
8
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
|
+
const VIRTUAL_ROW_HEIGHT = 65;
|
|
6
10
|
const BaseTable = ({
|
|
7
11
|
tableProps,
|
|
8
12
|
...resetProps
|
|
@@ -62,6 +66,12 @@ const BaseTable = ({
|
|
|
62
66
|
'data-row-draggable': rowDraggable,
|
|
63
67
|
onClick: () => {}
|
|
64
68
|
}),
|
|
69
|
+
// 虚拟滚动场景下,透传固定行高给内部 rc-virtual-list,帮助其准确计算高度、
|
|
70
|
+
// 减少滚动时的行测量开销(antd 未导出该属性,但会透传到内部虚拟滚动)。
|
|
71
|
+
// 行高 65px 为可编辑表格单元格的固定高度;外部显式传入时以外部为准。
|
|
72
|
+
...(resetProps?.virtual && resetProps?.listItemHeight == null ? {
|
|
73
|
+
listItemHeight: VIRTUAL_ROW_HEIGHT
|
|
74
|
+
} : {}),
|
|
65
75
|
...resetProps,
|
|
66
76
|
rowKey: tableRowKey,
|
|
67
77
|
summary,
|
package/es/ProEnum/index.js
CHANGED
|
@@ -137,14 +137,17 @@ const ProEnum = props => {
|
|
|
137
137
|
let list = [];
|
|
138
138
|
|
|
139
139
|
// 优先使用组件内部自己传入的数据源或者请求得到的数据
|
|
140
|
-
|
|
141
|
-
//
|
|
140
|
+
const sourceList = dataList && dataList.length ? dataList : enumLists;
|
|
141
|
+
// 仅在需要走 transformResponse 时才克隆,避免污染原始字典;
|
|
142
|
+
// 否则直接传引用(下游 ProSelect 等仅只读消费),减少滚动重挂载时的 cloneDeep 开销
|
|
142
143
|
if (!useRequest?.service && transformResponse) {
|
|
143
|
-
list = transformResponse(
|
|
144
|
+
list = transformResponse(_cloneDeep(sourceList));
|
|
144
145
|
if (!Array.isArray(list)) {
|
|
145
146
|
console.error(locale.ProEnum?.errorArrayMessage);
|
|
146
147
|
list = [];
|
|
147
148
|
}
|
|
149
|
+
} else {
|
|
150
|
+
list = sourceList;
|
|
148
151
|
}
|
|
149
152
|
if ( /*#__PURE__*/React.isValidElement(component)) {
|
|
150
153
|
const Component = component;
|
|
@@ -75,38 +75,35 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
75
75
|
confirm?: boolean | import("antd").ModalFuncProps | import("../../../render/propsType").FunctionArgs<any, boolean | import("antd").ModalFuncProps>;
|
|
76
76
|
show?: boolean | ReactiveFunction<any, boolean>;
|
|
77
77
|
component?: React.ReactNode | ReactiveFunction<any, React.ReactNode>;
|
|
78
|
-
isView?: boolean;
|
|
79
|
-
style?: React.CSSProperties;
|
|
80
|
-
trim?: boolean;
|
|
81
|
-
normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
|
|
82
78
|
children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
|
|
83
|
-
prefixCls?: string;
|
|
84
|
-
trigger?: string;
|
|
85
79
|
id?: string;
|
|
80
|
+
prefixCls?: string;
|
|
86
81
|
className?: string;
|
|
87
|
-
|
|
82
|
+
style?: React.CSSProperties;
|
|
88
83
|
status?: "" | "warning" | "error" | "success" | "validating";
|
|
84
|
+
rootClassName?: string;
|
|
85
|
+
isView?: boolean;
|
|
86
|
+
validateTrigger?: string | false | string[];
|
|
89
87
|
getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
|
|
88
|
+
desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
|
|
90
89
|
hidden?: boolean;
|
|
91
90
|
onReset?: () => void;
|
|
92
91
|
vertical?: boolean;
|
|
93
|
-
|
|
94
|
-
validateTrigger?: string | false | string[];
|
|
95
|
-
preserve?: boolean;
|
|
96
|
-
clearNotShow?: boolean;
|
|
97
|
-
labelAlign?: import("antd/es/form/interface").FormLabelAlign;
|
|
92
|
+
valueType?: import("../../../render/propsType").ProFormValueType;
|
|
98
93
|
colon?: boolean;
|
|
99
|
-
layout?: import("antd/es/form/Form").FormItemLayout;
|
|
100
|
-
labelCol?: import("antd").ColProps;
|
|
101
|
-
wrapperCol?: import("antd").ColProps;
|
|
102
94
|
htmlFor?: string;
|
|
95
|
+
labelAlign?: import("antd/es/form/interface").FormLabelAlign;
|
|
96
|
+
labelCol?: import("antd").ColProps;
|
|
103
97
|
getValueFromEvent?: (...args: import("@rc-component/form/lib/interface").EventArgs) => any;
|
|
98
|
+
normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
|
|
104
99
|
shouldUpdate?: import("@rc-component/form/lib/Field").ShouldUpdate<any>;
|
|
100
|
+
trigger?: string;
|
|
105
101
|
validateDebounce?: number;
|
|
106
102
|
valuePropName?: string;
|
|
107
103
|
messageVariables?: Record<string, string>;
|
|
108
104
|
initialValue?: any;
|
|
109
105
|
onMetaChange?: (meta: import("@rc-component/form/lib/Field").MetaEvent) => void;
|
|
106
|
+
preserve?: boolean;
|
|
110
107
|
isListField?: boolean;
|
|
111
108
|
isList?: boolean;
|
|
112
109
|
noStyle?: boolean;
|
|
@@ -114,9 +111,10 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
114
111
|
icons: import("antd/es/form/FormItem").FeedbackIcons;
|
|
115
112
|
};
|
|
116
113
|
validateStatus?: "" | "warning" | "error" | "success" | "validating";
|
|
114
|
+
layout?: import("antd/es/form/Form").FormItemLayout;
|
|
115
|
+
wrapperCol?: import("antd").ColProps;
|
|
117
116
|
help?: React.ReactNode;
|
|
118
117
|
fieldId?: string;
|
|
119
|
-
valueType?: import("../../../render/propsType").ProFormValueType;
|
|
120
118
|
switchValue?: [any, any];
|
|
121
119
|
viewRender?: (value: any, record: any, { form, index, namePath, }: {
|
|
122
120
|
[key: string]: any;
|
|
@@ -124,9 +122,11 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
124
122
|
index?: number;
|
|
125
123
|
}) => string | React.ReactElement<any, any>;
|
|
126
124
|
viewType?: import("../../../render/propsType").ViewType;
|
|
125
|
+
trim?: boolean;
|
|
127
126
|
upperCase?: boolean;
|
|
128
127
|
toISOString?: boolean;
|
|
129
128
|
toCSTString?: boolean;
|
|
129
|
+
clearNotShow?: boolean;
|
|
130
130
|
name: any;
|
|
131
131
|
dependencies: any[];
|
|
132
132
|
tooltip: string | {
|
|
@@ -141,7 +141,7 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
141
141
|
* 创建组件属性
|
|
142
142
|
*/
|
|
143
143
|
export declare const createComponentProps: (column: FlexibleGroupColumnType, formItemProps: any) => {
|
|
144
|
-
componentProps: import("lodash").Omit<any, "
|
|
144
|
+
componentProps: import("lodash").Omit<any, "precision" | "format" | "valueType" | "switchValue" | "dependNames" | "toISOString" | "toCSTString" | "clearNotShow">;
|
|
145
145
|
formItemTransform: {
|
|
146
146
|
getValueProps: any;
|
|
147
147
|
normalize: any;
|