@gm-pc/react 1.24.4 → 1.24.7-beta.10
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 +3 -3
- package/src/component/button/button.tsx +5 -1
- package/src/component/button/style.less +3 -1
- package/src/component/dialog/confirm.tsx +28 -8
- package/src/component/dialog/dialog.tsx +24 -14
- package/src/component/dialog/types.ts +4 -0
- package/src/component/form/form_group.tsx +9 -2
- package/src/component/loading/loading.tsx +9 -2
- package/src/component/loading/style.less +1 -1
- package/src/component/loading/types.ts +1 -0
- package/src/component/popup/popup_content_confirm.tsx +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gm-pc/react",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.7-beta.10",
|
|
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.
|
|
27
|
+
"@gm-pc/locales": "^1.24.7-beta.10",
|
|
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": "7f39e8a167416093461fec7e2227556bb851cfa7"
|
|
52
52
|
}
|
|
@@ -80,7 +80,11 @@ const Button: FC<ButtonProps> = ({
|
|
|
80
80
|
disabled={loadFlag || disabled}
|
|
81
81
|
onClick={handleClick}
|
|
82
82
|
>
|
|
83
|
-
{loadFlag &&
|
|
83
|
+
{loadFlag && (
|
|
84
|
+
<div style={{ marginRight: 4 }}>
|
|
85
|
+
<Loading size='1em' type={type} />
|
|
86
|
+
</div>
|
|
87
|
+
)}
|
|
84
88
|
{children}
|
|
85
89
|
</Tag>
|
|
86
90
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.gm-btn {
|
|
2
2
|
height: 30px;
|
|
3
3
|
border-radius: 2px;
|
|
4
|
-
display: inline-
|
|
4
|
+
display: inline-flex;
|
|
5
5
|
text-align: center;
|
|
6
6
|
vertical-align: middle;
|
|
7
7
|
cursor: pointer;
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
font-size: 12px;
|
|
12
12
|
line-height: 30px;
|
|
13
13
|
user-select: none;
|
|
14
|
+
flex-direction: row;
|
|
15
|
+
align-items: center;
|
|
14
16
|
|
|
15
17
|
&.gm-btn-default {
|
|
16
18
|
.gmBtnVariants(var(--gm-color-default), white, white);
|
|
@@ -10,6 +10,11 @@ import { Button } from '../button'
|
|
|
10
10
|
interface InnerProps extends ConfirmProps {
|
|
11
11
|
resolve: any
|
|
12
12
|
reject: any
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated
|
|
15
|
+
* 这个没用
|
|
16
|
+
* */
|
|
17
|
+
confirmLoading?: boolean
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
const Inner: FC<InnerProps> = ({
|
|
@@ -20,27 +25,43 @@ const Inner: FC<InnerProps> = ({
|
|
|
20
25
|
read,
|
|
21
26
|
resolve,
|
|
22
27
|
reject,
|
|
28
|
+
confirmLoading,
|
|
29
|
+
onOk,
|
|
30
|
+
onCancel,
|
|
23
31
|
}) => {
|
|
24
32
|
const [checked, setChecked] = useState<boolean>(false)
|
|
25
33
|
|
|
26
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
|
+
}
|
|
27
47
|
|
|
28
48
|
const buttons: DialogButtonProps[] = [
|
|
29
49
|
{
|
|
30
50
|
text: cancelBtnText || getLocale('取消'),
|
|
31
51
|
btnType: 'default',
|
|
32
52
|
onClick() {
|
|
33
|
-
reject
|
|
53
|
+
const fn = onCancel || reject
|
|
54
|
+
|
|
55
|
+
fn(new Error('cancel'))
|
|
56
|
+
|
|
34
57
|
Dialog.hide()
|
|
35
58
|
},
|
|
36
59
|
},
|
|
37
60
|
{
|
|
38
61
|
text: okBtnText || getLocale('确定'),
|
|
39
62
|
btnType: okBtnType || 'primary',
|
|
40
|
-
onClick
|
|
41
|
-
|
|
42
|
-
Dialog.hide()
|
|
43
|
-
},
|
|
63
|
+
onClick: handleOk,
|
|
64
|
+
loading: loading,
|
|
44
65
|
disabled: read ? !checked : false,
|
|
45
66
|
},
|
|
46
67
|
]
|
|
@@ -61,9 +82,8 @@ const Inner: FC<InnerProps> = ({
|
|
|
61
82
|
key={btn.text}
|
|
62
83
|
type={btn.btnType}
|
|
63
84
|
disabled={btn.disabled}
|
|
64
|
-
onClick={() =>
|
|
65
|
-
|
|
66
|
-
}}
|
|
85
|
+
onClick={() => btn.onClick()}
|
|
86
|
+
loading={btn.loading}
|
|
67
87
|
className='gm-margin-left-10'
|
|
68
88
|
>
|
|
69
89
|
{btn.text}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC } from 'react'
|
|
1
|
+
import React, { FC, useState } from 'react'
|
|
2
2
|
import { DialogProps, DialogStatic } from './types'
|
|
3
3
|
import { getLocale } from '@gm-pc/locales'
|
|
4
4
|
import _ from 'lodash'
|
|
@@ -15,6 +15,7 @@ const Dialog: FC<DialogProps> & DialogStatic = ({
|
|
|
15
15
|
onHide = () => Dialog.hide(),
|
|
16
16
|
children,
|
|
17
17
|
}) => {
|
|
18
|
+
const [loading, setLoading] = useState(false)
|
|
18
19
|
return (
|
|
19
20
|
<Modal
|
|
20
21
|
title={title}
|
|
@@ -26,19 +27,28 @@ const Dialog: FC<DialogProps> & DialogStatic = ({
|
|
|
26
27
|
<div>{children}</div>
|
|
27
28
|
{buttons && (
|
|
28
29
|
<Flex justifyEnd className='gm-dialog-buttons gm-margin-top-10'>
|
|
29
|
-
{_.map(buttons, (btn) =>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
btn.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
{_.map(buttons, (btn) => {
|
|
31
|
+
const isPrimary = btn.btnType === 'primary' || btn.btnType === 'danger'
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Button
|
|
35
|
+
loading={btn.loading || (isPrimary && loading)}
|
|
36
|
+
key={btn.text}
|
|
37
|
+
type={btn.btnType}
|
|
38
|
+
disabled={btn.disabled}
|
|
39
|
+
onClick={() => {
|
|
40
|
+
setLoading(true)
|
|
41
|
+
// console.log('btn.onClick', btn.onClick())
|
|
42
|
+
Promise.resolve(btn.onClick()).finally(() => {
|
|
43
|
+
setLoading(false)
|
|
44
|
+
})
|
|
45
|
+
}}
|
|
46
|
+
className='gm-margin-left-10'
|
|
47
|
+
>
|
|
48
|
+
{btn.text}
|
|
49
|
+
</Button>
|
|
50
|
+
)
|
|
51
|
+
})}
|
|
42
52
|
</Flex>
|
|
43
53
|
)}
|
|
44
54
|
</Modal>
|
|
@@ -11,6 +11,7 @@ interface DialogButtonProps {
|
|
|
11
11
|
onClick(event?: Event): void
|
|
12
12
|
btnType?: ButtonType
|
|
13
13
|
disabled?: boolean
|
|
14
|
+
loading?: boolean
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
interface DialogProps extends ConfigProviderProps {
|
|
@@ -41,6 +42,9 @@ interface ConfirmProps extends SpecificDialogProps {
|
|
|
41
42
|
onValidate?: (value: string) => boolean | void
|
|
42
43
|
/** 阅读提示 */
|
|
43
44
|
read?: boolean | string
|
|
45
|
+
confirmLoading?: boolean
|
|
46
|
+
onOk?: () => any
|
|
47
|
+
onCancel?: (error: any) => any
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
interface PromptProps extends ConfirmProps, ConfigProviderProps {
|
|
@@ -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}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC } from 'react'
|
|
2
2
|
import { LoadingProps } from './types'
|
|
3
3
|
|
|
4
|
-
const Loading: FC<LoadingProps> = ({ size = '1em' }) => {
|
|
4
|
+
const Loading: FC<LoadingProps> = ({ size = '1em', type = 'default' }) => {
|
|
5
5
|
return (
|
|
6
6
|
<svg
|
|
7
7
|
className='gm-loading'
|
|
@@ -11,7 +11,14 @@ const Loading: FC<LoadingProps> = ({ size = '1em' }) => {
|
|
|
11
11
|
}}
|
|
12
12
|
viewBox='0 0 50 50'
|
|
13
13
|
>
|
|
14
|
-
<circle
|
|
14
|
+
<circle
|
|
15
|
+
className='gm-loading-path'
|
|
16
|
+
cx='25'
|
|
17
|
+
cy='25'
|
|
18
|
+
r='20'
|
|
19
|
+
fill='none'
|
|
20
|
+
stroke={type === 'default' ? '#0363ff' : '#fff'}
|
|
21
|
+
/>
|
|
15
22
|
</svg>
|
|
16
23
|
)
|
|
17
24
|
}
|
|
@@ -14,6 +14,7 @@ type ButtonMap = {
|
|
|
14
14
|
text: string
|
|
15
15
|
onClick(): void
|
|
16
16
|
disabled?: boolean
|
|
17
|
+
loading?: boolean
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -27,6 +28,7 @@ export interface PopupContentConfirmProps extends HTMLAttributes<HTMLDivElement>
|
|
|
27
28
|
read?: boolean | string
|
|
28
29
|
className?: string
|
|
29
30
|
style?: CSSProperties
|
|
31
|
+
loading?: boolean
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
const PopupContentConfirm: FC<PopupContentConfirmProps> = ({
|
|
@@ -38,6 +40,7 @@ const PopupContentConfirm: FC<PopupContentConfirmProps> = ({
|
|
|
38
40
|
read,
|
|
39
41
|
className,
|
|
40
42
|
children,
|
|
43
|
+
loading,
|
|
41
44
|
...rest
|
|
42
45
|
}) => {
|
|
43
46
|
const [checked, setChecked] = useState<boolean>(false)
|
|
@@ -51,6 +54,7 @@ const PopupContentConfirm: FC<PopupContentConfirmProps> = ({
|
|
|
51
54
|
onClick() {
|
|
52
55
|
onSave && onSave()
|
|
53
56
|
},
|
|
57
|
+
loading: loading,
|
|
54
58
|
},
|
|
55
59
|
delete: {
|
|
56
60
|
text: getLocale('删除'),
|
|
@@ -58,6 +62,7 @@ const PopupContentConfirm: FC<PopupContentConfirmProps> = ({
|
|
|
58
62
|
onClick() {
|
|
59
63
|
onDelete && onDelete()
|
|
60
64
|
},
|
|
65
|
+
loading: loading,
|
|
61
66
|
disabled: read ? !checked : false,
|
|
62
67
|
},
|
|
63
68
|
}
|
|
@@ -88,6 +93,7 @@ const PopupContentConfirm: FC<PopupContentConfirmProps> = ({
|
|
|
88
93
|
onClick={() => {
|
|
89
94
|
buttonMap[type].onClick()
|
|
90
95
|
}}
|
|
96
|
+
loading={loading}
|
|
91
97
|
disabled={buttonMap[type].disabled}
|
|
92
98
|
>
|
|
93
99
|
{buttonMap[type].text}
|