import React, { useState } from 'react'; import { AutofillDropdown } from './autofill/autofillDropdown'; export interface TextDataEntryInputProps { slug: string; name?: string; onChange?: (key: string, val: any) => void; maxLength?: number; disabled?: boolean; placeholder?: string; valueTransform?: (val: string) => string; autofill?: boolean; } export const DataEntryInput: React.FC = props => { const [isEditing, setEditing] = useState(false); const handleChange = (value: string) => { console.log(value); const transform = props.valueTransform || (x => x); const transformedValue = value === '' ? null : transform(value); props.onChange(props.slug, transformedValue); }; return (
setEditing(true)} onBlur={e => setEditing(false)} > handleChange(e.target.value)} /> { props.autofill && handleChange(value)} onClose={() => setEditing(false)} fieldName={props.slug} fieldValue={props.value} /> }
); };