2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-08-17 21:59:29 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2020-08-19 01:39:06 +01:00
|
|
|
import { CX } from '../constants'
|
2020-03-05 15:44:17 +00:00
|
|
|
import Text from './text'
|
|
|
|
|
2020-08-18 01:57:35 +01:00
|
|
|
class Textarea extends React.PureComponent {
|
2020-03-05 15:44:17 +00:00
|
|
|
|
2020-04-28 06:33:58 +01:00
|
|
|
handleOnChange = (e) => {
|
|
|
|
this.props.onChange(e.target.value)
|
|
|
|
}
|
|
|
|
|
2020-03-05 15:44:17 +00:00
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
placeholder,
|
|
|
|
prependIcon,
|
|
|
|
value,
|
|
|
|
onKeyUp,
|
|
|
|
onFocus,
|
|
|
|
onBlur,
|
2020-04-28 06:33:58 +01:00
|
|
|
title,
|
2020-09-02 23:54:36 +01:00
|
|
|
isRequired,
|
2020-12-17 06:34:00 +00:00
|
|
|
maxLength,
|
2020-03-05 15:44:17 +00:00
|
|
|
} = this.props
|
|
|
|
|
2020-08-19 01:39:06 +01:00
|
|
|
const inputClasses = CX({
|
2020-08-18 21:49:11 +01:00
|
|
|
d: 1,
|
2020-03-05 15:44:17 +00:00
|
|
|
text: 1,
|
|
|
|
outlineNone: 1,
|
|
|
|
lineHeight125: 1,
|
|
|
|
displayBlock: 1,
|
2020-03-11 23:56:18 +00:00
|
|
|
py10: 1,
|
2020-04-29 23:32:49 +01:00
|
|
|
bgTransparent: 1,
|
|
|
|
fs15PX: 1,
|
2020-03-05 15:44:17 +00:00
|
|
|
flexGrow1: 1,
|
2020-08-18 21:43:06 +01:00
|
|
|
maxH100VH: 1,
|
2020-03-05 15:44:17 +00:00
|
|
|
resizeVertical: 1,
|
2020-08-18 21:43:06 +01:00
|
|
|
cPrimary: 1,
|
2020-03-11 23:56:18 +00:00
|
|
|
px5: !!prependIcon,
|
|
|
|
pl15: !prependIcon,
|
2020-03-05 15:44:17 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
{
|
|
|
|
!!title &&
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.mb10, _s.pl15].join(' ')}>
|
2020-03-05 15:44:17 +00:00
|
|
|
<Text size='small' weight='medium' color='secondary'>
|
|
|
|
{title}
|
|
|
|
</Text>
|
|
|
|
</div>
|
|
|
|
}
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.bgPrimary, _s.border1PX, _s.borderColorSecondary, _s.flexRow, _s.radiusSmall, _s.aiCenter].join(' ')}>
|
2020-03-05 15:44:17 +00:00
|
|
|
<textarea
|
|
|
|
className={inputClasses}
|
|
|
|
type='text'
|
|
|
|
placeholder={placeholder}
|
|
|
|
value={value}
|
2020-04-28 06:33:58 +01:00
|
|
|
onChange={this.handleOnChange}
|
2020-03-05 15:44:17 +00:00
|
|
|
onKeyUp={onKeyUp}
|
|
|
|
onFocus={onFocus}
|
|
|
|
onBlur={onBlur}
|
2020-12-17 06:34:00 +00:00
|
|
|
maxLength={maxLength}
|
2020-09-02 23:54:36 +01:00
|
|
|
required={isRequired ? true : undefined}
|
2020-03-05 15:44:17 +00:00
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2020-08-18 01:57:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Textarea.propTypes = {
|
|
|
|
placeholder: PropTypes.string,
|
|
|
|
prependIcon: PropTypes.string,
|
|
|
|
value: PropTypes.string,
|
|
|
|
onChange: PropTypes.func,
|
|
|
|
onKeyUp: PropTypes.func,
|
|
|
|
onFocus: PropTypes.func,
|
|
|
|
onBlur: PropTypes.func,
|
|
|
|
title: PropTypes.string,
|
2020-09-02 23:54:36 +01:00
|
|
|
isRequired: PropTypes.bool,
|
2020-12-17 06:34:00 +00:00
|
|
|
maxLength: PropTypes.number,
|
2020-08-18 01:57:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export default Textarea
|