UNPKG

1.68 kBJSXView Raw
1/**
2 * Form component
3 * @class ApForm
4 */
5
6'use strict'
7
8import React, {PropTypes as types} from 'react'
9import ReactDOM from 'react-dom'
10import classnames from 'classnames'
11import {withSpin} from 'apeman-react-spinner'
12import {clone} from 'asobj'
13
14/** @lends ApForm */
15const ApForm = React.createClass({
16
17 // --------------------
18 // Specs
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 // Lifecycle
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 // Custom
81 // ------------------
82
83 // ------------------
84 // Private
85 // ------------------
86})
87
88export default ApForm // Dummy for doc
89export default withSpin(ApForm)
90