1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | 'use strict'
|
7 |
|
8 | import React, {PropTypes as types} from 'react'
|
9 | import ReactDOM from 'react-dom'
|
10 | import classnames from 'classnames'
|
11 | import {withSpin} from 'apeman-react-spinner'
|
12 | import {clone} from 'asobj'
|
13 |
|
14 |
|
15 | const ApForm = React.createClass({
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | mixins: [],
|
22 |
|
23 | statics: {},
|
24 |
|
25 | propTypes: {
|
26 | centered: types.bool
|
27 | },
|
28 |
|
29 | getInitialState () {
|
30 | return {}
|
31 | },
|
32 |
|
33 | getDefaultProps () {
|
34 | return {
|
35 | centered: false
|
36 | }
|
37 | },
|
38 |
|
39 | render () {
|
40 | const s = this
|
41 | let { props } = s
|
42 | let { spinner } = props
|
43 | let formProps = clone(props, {
|
44 | without: [
|
45 | 'centered', 'spinning', 'spinnerTheme', 'spinner'
|
46 | ]
|
47 | })
|
48 | let className = classnames('ap-form', props.className, {
|
49 | 'ap-form-centered': props.centered
|
50 | })
|
51 | return (
|
52 | <form { ...formProps }
|
53 | className={ className }>
|
54 | <input type='text'
|
55 | name='ap_form_dummy'
|
56 | disabled
|
57 | value={ undefined }
|
58 | placeholder='This is a dummy input to prevent submit on enter'
|
59 | className='ap-form-dummy-input'/>
|
60 | { spinner }
|
61 | { props.children }
|
62 | </form>
|
63 | )
|
64 | },
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 | componentDidMount () {
|
71 | const s = this
|
72 | let { props } = s
|
73 | },
|
74 |
|
75 | componentWillReceiveProps (nextProps) {
|
76 | const s = this
|
77 | }
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | })
|
87 |
|
88 | export default ApForm
|
89 | export default withSpin(ApForm)
|
90 |
|