shinkansen-cogs 1.5.24
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/.husky/pre-commit +4 -0
- package/README.md +11 -0
- package/babel.config.js +72 -0
- package/gulp.sh +42 -0
- package/index.js +7 -0
- package/lib/cogs/checkbox/index.js +1 -0
- package/lib/cogs/email/index.js +1 -0
- package/lib/cogs/index.js +1 -0
- package/lib/cogs/number/index.js +1 -0
- package/lib/cogs/password/index.js +1 -0
- package/lib/cogs/radio/index.js +1 -0
- package/lib/cogs/select/index.js +1 -0
- package/lib/cogs/text/index.js +1 -0
- package/lib/cogs/textarea/index.js +1 -0
- package/lib/components/common/disabled/index.js +1 -0
- package/lib/components/common/readonly/index.js +1 -0
- package/lib/components/common/required/index.js +1 -0
- package/lib/components/common/text-content/index.js +1 -0
- package/lib/components/description/checkbox/index.js +1 -0
- package/lib/components/description/email/index.js +1 -0
- package/lib/components/description/index.js +1 -0
- package/lib/components/description/number/index.js +1 -0
- package/lib/components/description/password/index.js +1 -0
- package/lib/components/description/radio/index.js +1 -0
- package/lib/components/description/select/index.js +1 -0
- package/lib/components/description/text/index.js +1 -0
- package/lib/components/description/textarea/index.js +1 -0
- package/lib/components/error-message/checkbox/index.js +1 -0
- package/lib/components/error-message/email/index.js +1 -0
- package/lib/components/error-message/index.js +1 -0
- package/lib/components/error-message/number/index.js +1 -0
- package/lib/components/error-message/password/index.js +1 -0
- package/lib/components/error-message/radio/index.js +1 -0
- package/lib/components/error-message/select/index.js +1 -0
- package/lib/components/error-message/text/index.js +1 -0
- package/lib/components/error-message/textarea/index.js +1 -0
- package/lib/components/field/checkbox/index.js +1 -0
- package/lib/components/field/email/index.js +1 -0
- package/lib/components/field/index.js +1 -0
- package/lib/components/field/number/index.js +1 -0
- package/lib/components/field/password/index.js +1 -0
- package/lib/components/field/radio/index.js +1 -0
- package/lib/components/field/select/index.js +1 -0
- package/lib/components/field/text/index.js +1 -0
- package/lib/components/field/textarea/index.js +1 -0
- package/lib/components/title/checkbox/index.js +1 -0
- package/lib/components/title/email/index.js +1 -0
- package/lib/components/title/index.js +1 -0
- package/lib/components/title/number/index.js +1 -0
- package/lib/components/title/password/index.js +1 -0
- package/lib/components/title/radio/index.js +1 -0
- package/lib/components/title/select/index.js +1 -0
- package/lib/components/title/text/index.js +1 -0
- package/lib/components/title/textarea/index.js +1 -0
- package/lib/index.js +1 -0
- package/lib/transformers/error-message/index.js +1 -0
- package/package.json +107 -0
- package/src/cogs/checkbox/index.js +138 -0
- package/src/cogs/email/index.js +115 -0
- package/src/cogs/index.js +225 -0
- package/src/cogs/number/index.js +124 -0
- package/src/cogs/password/index.js +115 -0
- package/src/cogs/radio/index.js +149 -0
- package/src/cogs/select/index.js +117 -0
- package/src/cogs/text/index.js +115 -0
- package/src/cogs/textarea/index.js +115 -0
- package/src/components/common/disabled/index.js +9 -0
- package/src/components/common/readonly/index.js +9 -0
- package/src/components/common/required/index.js +9 -0
- package/src/components/common/text-content/index.js +14 -0
- package/src/components/description/checkbox/index.js +19 -0
- package/src/components/description/email/index.js +19 -0
- package/src/components/description/index.js +61 -0
- package/src/components/description/number/index.js +19 -0
- package/src/components/description/password/index.js +19 -0
- package/src/components/description/radio/index.js +19 -0
- package/src/components/description/select/index.js +19 -0
- package/src/components/description/text/index.js +19 -0
- package/src/components/description/textarea/index.js +19 -0
- package/src/components/error-message/checkbox/index.js +19 -0
- package/src/components/error-message/email/index.js +19 -0
- package/src/components/error-message/index.js +103 -0
- package/src/components/error-message/number/index.js +19 -0
- package/src/components/error-message/password/index.js +19 -0
- package/src/components/error-message/radio/index.js +19 -0
- package/src/components/error-message/select/index.js +19 -0
- package/src/components/error-message/text/index.js +19 -0
- package/src/components/error-message/textarea/index.js +19 -0
- package/src/components/field/checkbox/index.js +55 -0
- package/src/components/field/email/index.js +56 -0
- package/src/components/field/index.js +165 -0
- package/src/components/field/number/index.js +65 -0
- package/src/components/field/password/index.js +56 -0
- package/src/components/field/radio/index.js +72 -0
- package/src/components/field/select/index.js +62 -0
- package/src/components/field/text/index.js +56 -0
- package/src/components/field/textarea/index.js +55 -0
- package/src/components/title/checkbox/index.js +19 -0
- package/src/components/title/email/index.js +19 -0
- package/src/components/title/index.js +134 -0
- package/src/components/title/number/index.js +19 -0
- package/src/components/title/password/index.js +19 -0
- package/src/components/title/radio/index.js +19 -0
- package/src/components/title/select/index.js +19 -0
- package/src/components/title/text/index.js +19 -0
- package/src/components/title/textarea/index.js +19 -0
- package/src/index.js +28 -0
- package/src/transformers/error-message/index.js +234 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field component
|
|
3
|
+
*/
|
|
4
|
+
import React, { Component } from 'react'
|
|
5
|
+
import PropTypes from 'prop-types'
|
|
6
|
+
|
|
7
|
+
function onChange () {
|
|
8
|
+
/* */
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function onClick () {
|
|
12
|
+
/* */
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default class Field extends Component {
|
|
16
|
+
getDOMNode = () => this.domNode
|
|
17
|
+
setDOMNode = (domNode) => !!(this.domNode = domNode) || delete this.domNode
|
|
18
|
+
|
|
19
|
+
getClassName () {
|
|
20
|
+
return 'input'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
shouldComponentUpdate (props) {
|
|
24
|
+
return (
|
|
25
|
+
(props.id !== this.props.id) ||
|
|
26
|
+
(props.required !== this.props.required) ||
|
|
27
|
+
(props.disabled !== this.props.disabled) ||
|
|
28
|
+
(props.readOnly !== this.props.readOnly) ||
|
|
29
|
+
(props.tabIndex !== this.props.tabIndex) ||
|
|
30
|
+
(props.accessKey !== this.props.accessKey) ||
|
|
31
|
+
(props.placeholder !== this.props.placeholder) ||
|
|
32
|
+
(props.onChange !== this.props.onChange)
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
render () {
|
|
37
|
+
const {
|
|
38
|
+
id,
|
|
39
|
+
required,
|
|
40
|
+
disabled,
|
|
41
|
+
readOnly,
|
|
42
|
+
tabIndex,
|
|
43
|
+
accessKey,
|
|
44
|
+
placeholder
|
|
45
|
+
} = this.props
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<input
|
|
49
|
+
id={id}
|
|
50
|
+
required={required}
|
|
51
|
+
disabled={disabled}
|
|
52
|
+
readOnly={readOnly}
|
|
53
|
+
tabIndex={tabIndex}
|
|
54
|
+
accessKey={accessKey}
|
|
55
|
+
placeholder={placeholder}
|
|
56
|
+
className={this.getClassName()}
|
|
57
|
+
ref={this.setDOMNode}
|
|
58
|
+
/>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
Field.propTypes = {
|
|
64
|
+
id: PropTypes.string,
|
|
65
|
+
name: PropTypes.string.isRequired,
|
|
66
|
+
required: PropTypes.bool,
|
|
67
|
+
disabled: PropTypes.bool,
|
|
68
|
+
readOnly: PropTypes.bool,
|
|
69
|
+
tabIndex: PropTypes.number,
|
|
70
|
+
accessKey: PropTypes.string,
|
|
71
|
+
placeholder: PropTypes.string,
|
|
72
|
+
onChange: PropTypes.func
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Field.defaultProps = {
|
|
76
|
+
required: false,
|
|
77
|
+
disabled: false,
|
|
78
|
+
readOnly: false,
|
|
79
|
+
onChange
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* ValueField component
|
|
84
|
+
*/
|
|
85
|
+
export class ValueField extends Field {
|
|
86
|
+
getValue () {
|
|
87
|
+
return this.getDOMNode()
|
|
88
|
+
.value
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
setValue (value) {
|
|
92
|
+
this.getDOMNode()
|
|
93
|
+
.value = value
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
shouldComponentUpdate (props) {
|
|
97
|
+
return (
|
|
98
|
+
super.shouldComponentUpdate(props) ||
|
|
99
|
+
(props.value !== this.props.value)
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
handleChange = ({ target: { value } }) => {
|
|
104
|
+
const { onChange } = this.props
|
|
105
|
+
|
|
106
|
+
onChange(value)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
ValueField.propTypes = {
|
|
111
|
+
...Field.propTypes,
|
|
112
|
+
value: PropTypes.string,
|
|
113
|
+
defaultValue: PropTypes.string
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
ValueField.defaultProps = {
|
|
117
|
+
...Field.defaultProps
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* CheckField component
|
|
122
|
+
*/
|
|
123
|
+
export class CheckField extends Field {
|
|
124
|
+
getValue () {
|
|
125
|
+
return this.getDOMNode()
|
|
126
|
+
.checked
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
setValue (checked) {
|
|
130
|
+
this.getDOMNode()
|
|
131
|
+
.checked = checked
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
shouldComponentUpdate (props) {
|
|
135
|
+
return (
|
|
136
|
+
super.shouldComponentUpdate(props) ||
|
|
137
|
+
(props.checked !== this.props.checked) ||
|
|
138
|
+
(props.onClick !== this.props.onClick)
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
handleClick = ({ target: { checked } }) => {
|
|
143
|
+
const { onClick } = this.props
|
|
144
|
+
|
|
145
|
+
onClick(checked)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
handleChange = ({ target: { checked } }) => {
|
|
149
|
+
const { onChange } = this.props
|
|
150
|
+
|
|
151
|
+
onChange(checked)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
CheckField.propTypes = {
|
|
156
|
+
...Field.propTypes,
|
|
157
|
+
checked: PropTypes.bool,
|
|
158
|
+
defaultChecked: PropTypes.bool,
|
|
159
|
+
onClick: PropTypes.func
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
CheckField.defaultProps = {
|
|
163
|
+
...Field.defaultProps,
|
|
164
|
+
onClick
|
|
165
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NumberField component
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import PropTypes from 'prop-types'
|
|
6
|
+
import classnames from 'classnames'
|
|
7
|
+
import { ValueField } from 'shinkansen-cogs/components/field'
|
|
8
|
+
|
|
9
|
+
export default class NumberField extends ValueField {
|
|
10
|
+
getClassName () {
|
|
11
|
+
return classnames(super.getClassName(), 'number')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
render () {
|
|
15
|
+
const {
|
|
16
|
+
id,
|
|
17
|
+
name,
|
|
18
|
+
value,
|
|
19
|
+
defaultValue,
|
|
20
|
+
required,
|
|
21
|
+
disabled,
|
|
22
|
+
readOnly,
|
|
23
|
+
tabIndex,
|
|
24
|
+
accessKey,
|
|
25
|
+
placeholder
|
|
26
|
+
} = this.props
|
|
27
|
+
|
|
28
|
+
const className = this.getClassName()
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<input
|
|
32
|
+
id={id}
|
|
33
|
+
name={name}
|
|
34
|
+
value={value}
|
|
35
|
+
defaultValue={defaultValue}
|
|
36
|
+
required={required}
|
|
37
|
+
disabled={disabled}
|
|
38
|
+
readOnly={readOnly}
|
|
39
|
+
tabIndex={tabIndex}
|
|
40
|
+
accessKey={accessKey}
|
|
41
|
+
placeholder={placeholder}
|
|
42
|
+
onChange={this.handleChange}
|
|
43
|
+
className={className}
|
|
44
|
+
type='number'
|
|
45
|
+
ref={this.setField}
|
|
46
|
+
/>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
NumberField.propTypes = {
|
|
52
|
+
...ValueField.propTypes,
|
|
53
|
+
value: PropTypes.oneOfType([
|
|
54
|
+
PropTypes.string,
|
|
55
|
+
PropTypes.number
|
|
56
|
+
]),
|
|
57
|
+
defaultValue: PropTypes.oneOfType([
|
|
58
|
+
PropTypes.string,
|
|
59
|
+
PropTypes.number
|
|
60
|
+
])
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
NumberField.defaultProps = {
|
|
64
|
+
...ValueField.defaultProps
|
|
65
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PasswordField component
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import classnames from 'classnames'
|
|
6
|
+
import { ValueField } from 'shinkansen-cogs/components/field'
|
|
7
|
+
|
|
8
|
+
export default class PasswordField extends ValueField {
|
|
9
|
+
getClassName () {
|
|
10
|
+
return classnames(super.getClassName(), 'password')
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
render () {
|
|
14
|
+
const {
|
|
15
|
+
id,
|
|
16
|
+
name,
|
|
17
|
+
value,
|
|
18
|
+
defaultValue,
|
|
19
|
+
required,
|
|
20
|
+
disabled,
|
|
21
|
+
readOnly,
|
|
22
|
+
tabIndex,
|
|
23
|
+
accessKey,
|
|
24
|
+
placeholder
|
|
25
|
+
} = this.props
|
|
26
|
+
|
|
27
|
+
const className = this.getClassName()
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<input
|
|
31
|
+
id={id}
|
|
32
|
+
name={name}
|
|
33
|
+
value={value}
|
|
34
|
+
defaultValue={defaultValue}
|
|
35
|
+
required={required}
|
|
36
|
+
disabled={disabled}
|
|
37
|
+
readOnly={readOnly}
|
|
38
|
+
tabIndex={tabIndex}
|
|
39
|
+
accessKey={accessKey}
|
|
40
|
+
placeholder={placeholder}
|
|
41
|
+
onChange={this.handleChange}
|
|
42
|
+
className={className}
|
|
43
|
+
type='password'
|
|
44
|
+
ref={this.setField}
|
|
45
|
+
/>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
PasswordField.propTypes = {
|
|
51
|
+
...ValueField.propTypes
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
PasswordField.defaultProps = {
|
|
55
|
+
...ValueField.defaultProps
|
|
56
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RadioField component
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import PropTypes from 'prop-types'
|
|
6
|
+
import classnames from 'classnames'
|
|
7
|
+
import { CheckField } from 'shinkansen-cogs/components/field'
|
|
8
|
+
|
|
9
|
+
export default class RadioField extends CheckField {
|
|
10
|
+
getClassName () {
|
|
11
|
+
return classnames(super.getClassName(), 'radio')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
handleClick = ({ target: { value } }) => {
|
|
15
|
+
const { onClick } = this.props
|
|
16
|
+
|
|
17
|
+
onClick(value)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
handleChange = ({ target: { value } }) => {
|
|
21
|
+
const { onChange } = this.props
|
|
22
|
+
|
|
23
|
+
onChange(value)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
render () {
|
|
27
|
+
const {
|
|
28
|
+
id,
|
|
29
|
+
name,
|
|
30
|
+
value,
|
|
31
|
+
checked,
|
|
32
|
+
defaultChecked,
|
|
33
|
+
required,
|
|
34
|
+
disabled,
|
|
35
|
+
readOnly,
|
|
36
|
+
tabIndex,
|
|
37
|
+
accessKey
|
|
38
|
+
} = this.props
|
|
39
|
+
|
|
40
|
+
const className = this.getClassName()
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<input
|
|
44
|
+
id={id}
|
|
45
|
+
name={name}
|
|
46
|
+
value={value}
|
|
47
|
+
checked={checked}
|
|
48
|
+
defaultChecked={defaultChecked}
|
|
49
|
+
required={required}
|
|
50
|
+
disabled={disabled}
|
|
51
|
+
readOnly={readOnly}
|
|
52
|
+
tabIndex={tabIndex}
|
|
53
|
+
accessKey={accessKey}
|
|
54
|
+
onClick={this.handleClick}
|
|
55
|
+
onChange={this.handleChange}
|
|
56
|
+
className={className}
|
|
57
|
+
type='radio'
|
|
58
|
+
ref={this.setDOMNode}
|
|
59
|
+
/>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
RadioField.propTypes = {
|
|
65
|
+
...CheckField.propTypes,
|
|
66
|
+
id: PropTypes.string.isRequired,
|
|
67
|
+
value: PropTypes.string.isRequired
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
RadioField.defaultProps = {
|
|
71
|
+
...CheckField.defaultProps
|
|
72
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SelectField component
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import PropTypes from 'prop-types'
|
|
6
|
+
import classnames from 'classnames'
|
|
7
|
+
import { ValueField } from 'shinkansen-cogs/components/field'
|
|
8
|
+
|
|
9
|
+
export default class SelectField extends ValueField {
|
|
10
|
+
getClassName () {
|
|
11
|
+
return classnames(super.getClassName(), 'select')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
render () {
|
|
15
|
+
const {
|
|
16
|
+
id,
|
|
17
|
+
name,
|
|
18
|
+
value,
|
|
19
|
+
defaultValue,
|
|
20
|
+
required,
|
|
21
|
+
disabled,
|
|
22
|
+
readOnly,
|
|
23
|
+
tabIndex,
|
|
24
|
+
accessKey,
|
|
25
|
+
children
|
|
26
|
+
} = this.props
|
|
27
|
+
|
|
28
|
+
const className = this.getClassName()
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<select
|
|
32
|
+
id={id}
|
|
33
|
+
name={name}
|
|
34
|
+
value={value}
|
|
35
|
+
defaultValue={defaultValue}
|
|
36
|
+
required={required}
|
|
37
|
+
disabled={disabled}
|
|
38
|
+
readOnly={readOnly}
|
|
39
|
+
tabIndex={tabIndex}
|
|
40
|
+
accessKey={accessKey}
|
|
41
|
+
onChange={this.handleChange}
|
|
42
|
+
className={className}
|
|
43
|
+
ref={this.setField}>
|
|
44
|
+
{children}
|
|
45
|
+
</select>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
SelectField.propTypes = {
|
|
51
|
+
...ValueField.propTypes,
|
|
52
|
+
children: PropTypes.oneOfType([
|
|
53
|
+
PropTypes.element,
|
|
54
|
+
PropTypes.arrayOf(
|
|
55
|
+
PropTypes.element
|
|
56
|
+
)
|
|
57
|
+
])
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
SelectField.defaultProps = {
|
|
61
|
+
...ValueField.defaultProps
|
|
62
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TextField component
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import classnames from 'classnames'
|
|
6
|
+
import { ValueField } from 'shinkansen-cogs/components/field'
|
|
7
|
+
|
|
8
|
+
export default class TextField extends ValueField {
|
|
9
|
+
getClassName () {
|
|
10
|
+
return classnames(super.getClassName(), 'text')
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
render () {
|
|
14
|
+
const {
|
|
15
|
+
id,
|
|
16
|
+
name,
|
|
17
|
+
value,
|
|
18
|
+
defaultValue,
|
|
19
|
+
required,
|
|
20
|
+
disabled,
|
|
21
|
+
readOnly,
|
|
22
|
+
tabIndex,
|
|
23
|
+
accessKey,
|
|
24
|
+
placeholder
|
|
25
|
+
} = this.props
|
|
26
|
+
|
|
27
|
+
const className = this.getClassName()
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<input
|
|
31
|
+
id={id}
|
|
32
|
+
name={name}
|
|
33
|
+
value={value}
|
|
34
|
+
defaultValue={defaultValue}
|
|
35
|
+
required={required}
|
|
36
|
+
disabled={disabled}
|
|
37
|
+
readOnly={readOnly}
|
|
38
|
+
tabIndex={tabIndex}
|
|
39
|
+
accessKey={accessKey}
|
|
40
|
+
placeholder={placeholder}
|
|
41
|
+
onChange={this.handleChange}
|
|
42
|
+
className={className}
|
|
43
|
+
type='text'
|
|
44
|
+
ref={this.setField}
|
|
45
|
+
/>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
TextField.propTypes = {
|
|
51
|
+
...ValueField.propTypes
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
TextField.defaultProps = {
|
|
55
|
+
...ValueField.defaultProps
|
|
56
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TextareaField component
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import classnames from 'classnames'
|
|
6
|
+
import { ValueField } from 'shinkansen-cogs/components/field'
|
|
7
|
+
|
|
8
|
+
export default class TextareaField extends ValueField {
|
|
9
|
+
getClassName () {
|
|
10
|
+
return classnames(super.getClassName(), 'textarea')
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
render () {
|
|
14
|
+
const {
|
|
15
|
+
id,
|
|
16
|
+
name,
|
|
17
|
+
value,
|
|
18
|
+
defaultValue,
|
|
19
|
+
required,
|
|
20
|
+
disabled,
|
|
21
|
+
readOnly,
|
|
22
|
+
tabIndex,
|
|
23
|
+
accessKey,
|
|
24
|
+
placeholder
|
|
25
|
+
} = this.props
|
|
26
|
+
|
|
27
|
+
const className = this.getClassName()
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<textarea
|
|
31
|
+
id={id}
|
|
32
|
+
name={name}
|
|
33
|
+
value={value}
|
|
34
|
+
defaultValue={defaultValue}
|
|
35
|
+
required={required}
|
|
36
|
+
disabled={disabled}
|
|
37
|
+
readOnly={readOnly}
|
|
38
|
+
tabIndex={tabIndex}
|
|
39
|
+
accessKey={accessKey}
|
|
40
|
+
placeholder={placeholder}
|
|
41
|
+
onChange={this.handleChange}
|
|
42
|
+
className={className}
|
|
43
|
+
ref={this.setField}
|
|
44
|
+
/>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
TextareaField.propTypes = {
|
|
50
|
+
...ValueField.propTypes
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
TextareaField.defaultProps = {
|
|
54
|
+
...ValueField.defaultProps
|
|
55
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CheckboxTitle component
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames'
|
|
5
|
+
import Title from 'shinkansen-cogs/components/title'
|
|
6
|
+
|
|
7
|
+
export default class CheckboxTitle extends Title {
|
|
8
|
+
getClassName () {
|
|
9
|
+
return classnames(super.getClassName(), 'checkbox')
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
CheckboxTitle.propTypes = {
|
|
14
|
+
...Title.propTypes
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
CheckboxTitle.defaultProps = {
|
|
18
|
+
...Title.defaultProps
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EmailTitle component
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames'
|
|
5
|
+
import Title from 'shinkansen-cogs/components/title'
|
|
6
|
+
|
|
7
|
+
export default class EmailTitle extends Title {
|
|
8
|
+
getClassName () {
|
|
9
|
+
return classnames(super.getClassName(), 'email')
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
EmailTitle.propTypes = {
|
|
14
|
+
...Title.propTypes
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
EmailTitle.defaultProps = {
|
|
18
|
+
...Title.defaultProps
|
|
19
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Title component
|
|
3
|
+
*/
|
|
4
|
+
import React, { Component } from 'react'
|
|
5
|
+
import PropTypes from 'prop-types'
|
|
6
|
+
|
|
7
|
+
import TextContent from 'shinkansen-cogs/components/common/text-content'
|
|
8
|
+
import Required from 'shinkansen-cogs/components/common/required'
|
|
9
|
+
import Disabled from 'shinkansen-cogs/components/common/disabled'
|
|
10
|
+
import ReadOnly from 'shinkansen-cogs/components/common/readonly'
|
|
11
|
+
|
|
12
|
+
export default class Title extends Component {
|
|
13
|
+
hasTextContent () {
|
|
14
|
+
const { title } = this.props
|
|
15
|
+
|
|
16
|
+
return !!title
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getTextContent () {
|
|
20
|
+
const { title } = this.props
|
|
21
|
+
|
|
22
|
+
return title
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
isRequired () {
|
|
26
|
+
const { required } = this.props
|
|
27
|
+
|
|
28
|
+
return required
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
isDisabled () {
|
|
32
|
+
const { disabled } = this.props
|
|
33
|
+
|
|
34
|
+
return disabled
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
isReadOnly () {
|
|
38
|
+
const { readOnly } = this.props
|
|
39
|
+
|
|
40
|
+
return readOnly
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getClassName () {
|
|
44
|
+
return 'title'
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
shouldComponentUpdate (props) {
|
|
48
|
+
return (
|
|
49
|
+
(props.id !== this.props.id) ||
|
|
50
|
+
(props.title !== this.props.title) ||
|
|
51
|
+
(props.required !== this.props.required) ||
|
|
52
|
+
(props.disabled !== this.props.disabled) ||
|
|
53
|
+
(props.readOnly !== this.props.readOnly)
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
renderTextContent () {
|
|
58
|
+
if (this.hasTextContent()) {
|
|
59
|
+
const textContent = this.getTextContent()
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<TextContent textContent={textContent} />
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return null
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
renderIsRequired () {
|
|
70
|
+
if (this.isRequired()) {
|
|
71
|
+
return (
|
|
72
|
+
<Required />
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return null
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
renderIsDisabled () {
|
|
80
|
+
if (this.isDisabled()) {
|
|
81
|
+
return (
|
|
82
|
+
<Disabled />
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return null
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
renderIsReadOnly () {
|
|
90
|
+
if (this.isReadOnly()) {
|
|
91
|
+
return (
|
|
92
|
+
<ReadOnly />
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return null
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
render () {
|
|
100
|
+
const { title } = this.props
|
|
101
|
+
|
|
102
|
+
if (title) {
|
|
103
|
+
const { id } = this.props
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<label htmlFor={id} className={this.getClassName()}>
|
|
107
|
+
{this.renderTextContent()}
|
|
108
|
+
</label>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return null
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
Title.propTypes = {
|
|
117
|
+
id: PropTypes.string.isRequired,
|
|
118
|
+
title: PropTypes.string,
|
|
119
|
+
required: PropTypes.bool,
|
|
120
|
+
disabled: PropTypes.bool,
|
|
121
|
+
readOnly: PropTypes.bool,
|
|
122
|
+
children: PropTypes.oneOfType([
|
|
123
|
+
PropTypes.element,
|
|
124
|
+
PropTypes.arrayOf(
|
|
125
|
+
PropTypes.element
|
|
126
|
+
)
|
|
127
|
+
])
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
Title.defaultProps = {
|
|
131
|
+
required: false,
|
|
132
|
+
disabled: false,
|
|
133
|
+
readOnly: false
|
|
134
|
+
}
|