2019-08-23 12:35:17 -04:00
|
|
|
import React, { Fragment } from 'react';
|
|
|
|
|
2019-10-17 12:00:01 -04:00
|
|
|
import { BaseDataEntryProps } from './data-entry';
|
2019-11-07 02:39:26 -05:00
|
|
|
import { DataTitleCopyable } from './data-title';
|
2019-08-23 12:35:17 -04:00
|
|
|
|
2019-10-17 12:00:01 -04:00
|
|
|
interface TextboxDataEntryProps extends BaseDataEntryProps {
|
|
|
|
value: string;
|
|
|
|
placeholder?: string;
|
|
|
|
maxLength?: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
const TextboxDataEntry: React.FunctionComponent<TextboxDataEntryProps> = (props) => {
|
2019-08-23 12:35:17 -04:00
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
<DataTitleCopyable
|
|
|
|
slug={props.slug}
|
|
|
|
title={props.title}
|
|
|
|
tooltip={props.tooltip}
|
2019-11-22 14:30:03 -05:00
|
|
|
disabled={props.disabled || props.value == undefined}
|
2019-08-23 12:35:17 -04:00
|
|
|
copy={props.copy}
|
|
|
|
/>
|
|
|
|
<textarea
|
|
|
|
className="form-control"
|
|
|
|
id={props.slug}
|
|
|
|
name={props.slug}
|
|
|
|
value={props.value || ''}
|
2019-10-17 12:00:01 -04:00
|
|
|
maxLength={props.maxLength}
|
2019-08-23 12:35:17 -04:00
|
|
|
rows={5}
|
|
|
|
disabled={props.mode === 'view' || props.disabled}
|
|
|
|
placeholder={props.placeholder}
|
2019-10-17 12:00:01 -04:00
|
|
|
onChange={e =>
|
|
|
|
props.onChange(
|
|
|
|
props.slug,
|
|
|
|
e.target.value === '' ?
|
|
|
|
null :
|
|
|
|
e.target.value
|
|
|
|
)
|
|
|
|
}
|
2019-08-23 12:35:17 -04:00
|
|
|
></textarea>
|
|
|
|
</Fragment>
|
|
|
|
);
|
2019-11-07 03:13:30 -05:00
|
|
|
};
|
2019-08-23 12:35:17 -04:00
|
|
|
|
|
|
|
export default TextboxDataEntry;
|