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

49 lines
1.1 KiB
JavaScript
Raw Normal View History

//@flow
import React from "react";
import LabelWithHelpIcon from "./LabelWithHelpIcon";
export type SelectItem = {
value: string,
label: string
};
type Props = {
2018-11-09 14:04:26 +01:00
name?: string,
label?: string,
placeholder?: SelectItem[],
value?: string,
2018-11-09 14:04:26 +01:00
onChange: (value: string, name?: string) => void,
helpText?: string
};
class Textarea extends React.Component<Props> {
field: ?HTMLTextAreaElement;
handleInput = (event: SyntheticInputEvent<HTMLTextAreaElement>) => {
2018-11-09 14:04:26 +01:00
this.props.onChange(event.target.value, this.props.name);
};
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;