41 lines
871 B
JavaScript
41 lines
871 B
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
|
|
export default class StringControl extends React.Component {
|
|
static propTypes = {
|
|
onChange: PropTypes.func.isRequired,
|
|
forID: PropTypes.string,
|
|
value: PropTypes.node,
|
|
classNameWrapper: PropTypes.string.isRequired,
|
|
setActiveStyle: PropTypes.func.isRequired,
|
|
setInactiveStyle: PropTypes.func.isRequired,
|
|
};
|
|
|
|
static defaultProps = {
|
|
value: '',
|
|
};
|
|
|
|
render() {
|
|
const {
|
|
forID,
|
|
value,
|
|
onChange,
|
|
classNameWrapper,
|
|
setActiveStyle,
|
|
setInactiveStyle,
|
|
} = this.props;
|
|
|
|
return (
|
|
<input
|
|
type="text"
|
|
id={forID}
|
|
className={classNameWrapper}
|
|
value={value || ''}
|
|
onChange={e => onChange(e.target.value)}
|
|
onFocus={setActiveStyle}
|
|
onBlur={setInactiveStyle}
|
|
/>
|
|
);
|
|
}
|
|
}
|