colouring-montreal/app/src/frontend/building/data-components/textbox-data-entry.tsx

45 lines
1.3 KiB
TypeScript
Raw Normal View History

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