@gm-pc/react 1.24.7-beta.7 → 1.24.7-beta.9
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gm-pc/react",
|
|
3
|
-
"version": "1.24.7-beta.
|
|
3
|
+
"version": "1.24.7-beta.9",
|
|
4
4
|
"description": "观麦前端基础组件库",
|
|
5
5
|
"author": "liyatang <liyatang@qq.com>",
|
|
6
6
|
"homepage": "https://github.com/gmfe/gm-pc#readme",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@gm-common/hooks": "^2.10.0",
|
|
26
26
|
"@gm-common/tool": "^2.10.0",
|
|
27
|
-
"@gm-pc/locales": "^1.24.7-beta.
|
|
27
|
+
"@gm-pc/locales": "^1.24.7-beta.9",
|
|
28
28
|
"big.js": "^6.0.1",
|
|
29
29
|
"classnames": "^2.2.5",
|
|
30
30
|
"lodash": "^4.17.19",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"react-router-dom": "^5.2.0",
|
|
49
49
|
"react-window": "^1.8.5"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "b83d17168b78de9248fccce1fb6b7afa6ac4f5a3"
|
|
52
52
|
}
|
|
@@ -10,6 +10,10 @@ import { Button } from '../button'
|
|
|
10
10
|
interface InnerProps extends ConfirmProps {
|
|
11
11
|
resolve: any
|
|
12
12
|
reject: any
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated
|
|
15
|
+
* 这个没用
|
|
16
|
+
* */
|
|
13
17
|
confirmLoading?: boolean
|
|
14
18
|
}
|
|
15
19
|
|
|
@@ -22,28 +26,42 @@ const Inner: FC<InnerProps> = ({
|
|
|
22
26
|
resolve,
|
|
23
27
|
reject,
|
|
24
28
|
confirmLoading,
|
|
29
|
+
onOk,
|
|
30
|
+
onCancel,
|
|
25
31
|
}) => {
|
|
26
32
|
const [checked, setChecked] = useState<boolean>(false)
|
|
27
33
|
|
|
28
34
|
const readText = _.isString(read) ? read : getLocale('我已阅读以上提示,确认删除')
|
|
35
|
+
const [loading, setLoading] = useState<boolean>(false)
|
|
36
|
+
|
|
37
|
+
const handleOk = async () => {
|
|
38
|
+
const fn = onOk || resolve
|
|
39
|
+
try {
|
|
40
|
+
setLoading(true)
|
|
41
|
+
await fn()
|
|
42
|
+
Dialog.hide()
|
|
43
|
+
} finally {
|
|
44
|
+
setLoading(false)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
29
47
|
|
|
30
48
|
const buttons: DialogButtonProps[] = [
|
|
31
49
|
{
|
|
32
50
|
text: cancelBtnText || getLocale('取消'),
|
|
33
51
|
btnType: 'default',
|
|
34
52
|
onClick() {
|
|
35
|
-
reject
|
|
53
|
+
const fn = onCancel || reject
|
|
54
|
+
|
|
55
|
+
fn(new Error('cancel'))
|
|
56
|
+
|
|
36
57
|
Dialog.hide()
|
|
37
58
|
},
|
|
38
59
|
},
|
|
39
60
|
{
|
|
40
61
|
text: okBtnText || getLocale('确定'),
|
|
41
62
|
btnType: okBtnType || 'primary',
|
|
42
|
-
onClick
|
|
43
|
-
|
|
44
|
-
Dialog.hide()
|
|
45
|
-
},
|
|
46
|
-
loading: confirmLoading,
|
|
63
|
+
onClick: handleOk,
|
|
64
|
+
loading: loading,
|
|
47
65
|
disabled: read ? !checked : false,
|
|
48
66
|
},
|
|
49
67
|
]
|
|
@@ -64,9 +82,8 @@ const Inner: FC<InnerProps> = ({
|
|
|
64
82
|
key={btn.text}
|
|
65
83
|
type={btn.btnType}
|
|
66
84
|
disabled={btn.disabled}
|
|
67
|
-
onClick={() =>
|
|
68
|
-
|
|
69
|
-
}}
|
|
85
|
+
onClick={() => btn.onClick()}
|
|
86
|
+
loading={btn.loading}
|
|
70
87
|
className='gm-margin-left-10'
|
|
71
88
|
>
|
|
72
89
|
{btn.text}
|
|
@@ -129,10 +129,17 @@ const FormGroup: FC<FormGroupProps> = ({
|
|
|
129
129
|
export default FormGroup
|
|
130
130
|
|
|
131
131
|
type ActionProps = Omit<FormGroupProps, 'formRefs' | 'onSubmitValidated' | 'onSubmit'> & {
|
|
132
|
-
onSubmit?(event: BaseSyntheticEvent): void
|
|
132
|
+
onSubmit?(event: BaseSyntheticEvent): Promise<void> | void
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
const Action: FC<ActionProps> = ({ onCancel, onSubmit, disabled, saveText, actions }) => {
|
|
136
|
+
const [loading, setLoading] = useState(false)
|
|
137
|
+
|
|
138
|
+
const handleClick = (e: BaseSyntheticEvent) => {
|
|
139
|
+
setLoading(true)
|
|
140
|
+
Promise.resolve(onSubmit?.(e)).finally(() => setLoading(false))
|
|
141
|
+
}
|
|
142
|
+
|
|
136
143
|
return (
|
|
137
144
|
<>
|
|
138
145
|
{onCancel && (
|
|
@@ -141,7 +148,7 @@ const Action: FC<ActionProps> = ({ onCancel, onSubmit, disabled, saveText, actio
|
|
|
141
148
|
<div className='gm-gap-10' />
|
|
142
149
|
</>
|
|
143
150
|
)}
|
|
144
|
-
<Button type='primary' disabled={disabled} onClick={
|
|
151
|
+
<Button type='primary' disabled={disabled} loading={loading} onClick={handleClick}>
|
|
145
152
|
{saveText || getLocale('确定')}
|
|
146
153
|
</Button>
|
|
147
154
|
{actions}
|