import { useCallback, useRef } from 'react'; import * as Editor from '../../../../common/components/editor-utils/EditorUtils'; import Input, { type InputProps } from '../../../../common/components/input/input/Input'; import useReactiveTextInput from '../../../../common/components/input/text-input/useReactiveTextInput'; import { EventEditorUpdateFields } from '../EventEditor'; import { GroupEditorUpdateTextFields } from '../GroupEditor'; interface EntryEditorTextInputProps extends InputProps { field: EventEditorUpdateFields | GroupEditorUpdateTextFields; label: string; initialValue: string; placeholder?: string; submitHandler: (field: EventEditorUpdateFields, value: string) => void; } export default function EntryEditorTextInput({ className, field, label, initialValue, style: givenStyles, submitHandler, maxLength, placeholder, }: EntryEditorTextInputProps) { const ref = useRef(null); const submitCallback = useCallback((newValue: string) => submitHandler(field, newValue), [field, submitHandler]); const { value, onChange, onBlur, onKeyDown } = useReactiveTextInput(initialValue, submitCallback, ref, { submitOnEnter: true, }); return (
{label}
); }