@gm-pc/react 1.24.7-beta.6 → 1.24.7-beta.7

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.6",
3
+ "version": "1.24.7-beta.7",
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.6",
27
+ "@gm-pc/locales": "^1.24.7-beta.7",
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": "c762f1339236ce80bc519f8acf1d6d7f9f00cc52"
51
+ "gitHead": "58b7be53ccb4e7c4eeceb175a82fc3c4a05ffe9a"
52
52
  }
@@ -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,20 +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
- <Button
31
- loading={btn.loading}
32
- key={btn.text}
33
- type={btn.btnType}
34
- disabled={btn.disabled}
35
- onClick={() => {
36
- btn.onClick()
37
- }}
38
- className='gm-margin-left-10'
39
- >
40
- {btn.text}
41
- </Button>
42
- ))}
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
+ })}
43
52
  </Flex>
44
53
  )}
45
54
  </Modal>