Files
SCM-Manager/scm-ui-components/packages/ui-components/src/forms/Textarea.js

48 lines
1014 B
JavaScript
Raw Normal View History

//@flow
import React from "react";
2018-10-04 10:16:20 +02:00
import { LabelWithHelpIcon } from "../index";
export type SelectItem = {
value: string,
label: string
};
type Props = {
label?: string,
placeholder?: SelectItem[],
value?: string,
onChange: string => void,
helpText?: string
};
class Textarea extends React.Component<Props> {
field: ?HTMLTextAreaElement;
handleInput = (event: SyntheticInputEvent<HTMLTextAreaElement>) => {
this.props.onChange(event.target.value);
};
render() {
2018-10-02 13:34:04 +02:00
const { placeholder, value, label, helpText } = this.props;
return (
<div className="field">
2018-10-04 10:16:20 +02:00
<LabelWithHelpIcon label={label} helpText={helpText} />
2018-10-02 13:04:34 +02:00
<div className="control">
<textarea
className="textarea"
ref={input => {
this.field = input;
}}
placeholder={placeholder}
onChange={this.handleInput}
value={value}
/>
</div>
</div>
);
}
}
export default Textarea;