1 | import React, { PureComponent } from 'react'
|
2 | import PropTypes from 'prop-types'
|
3 | import Button from '../Button'
|
4 |
|
5 | class Submit extends PureComponent {
|
6 | constructor(props) {
|
7 | super(props)
|
8 | this.handleClick = this.handleClick.bind(this)
|
9 | }
|
10 |
|
11 | handleClick(e) {
|
12 | e.persist()
|
13 | setTimeout(() => {
|
14 | this.props.onSubmit(e.target)
|
15 | }, 50)
|
16 | }
|
17 |
|
18 | render() {
|
19 | const {
|
20 | onSubmit, loading, children, formStatus, ...other
|
21 | } = this.props
|
22 | return (
|
23 | <Button
|
24 | type="primary"
|
25 | {...other}
|
26 | disabled={formStatus === 'disabled'}
|
27 | loading={formStatus === 'pending' || loading}
|
28 | onClick={this.handleClick}
|
29 | >
|
30 | { children }
|
31 | </Button>
|
32 | )
|
33 | }
|
34 | }
|
35 |
|
36 | Submit.propTypes = {
|
37 | children: PropTypes.any,
|
38 | formStatus: PropTypes.string,
|
39 | loading: PropTypes.bool,
|
40 | onCollapse: PropTypes.func,
|
41 | onSubmit: PropTypes.func,
|
42 | }
|
43 |
|
44 | export default Submit
|