mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-14 11:53:49 +00:00
e1e8410ba4
migrate pin page migrate copy tag migrate pin input migrate dropdown menus migrate radio buttons migrate switch migrate select migrate textarea migrate colour picker migrate select migrate context menu migrate viewparams remove chakra
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { memo, useCallback, useRef } from 'react';
|
|
|
|
import { AutoTextarea } from '../../../../common/components/input/auto-textarea/AutoTextarea';
|
|
import useReactiveTextInput from '../../../../common/components/input/text-input/useReactiveTextInput';
|
|
|
|
interface MultiLineCellProps {
|
|
initialValue: string;
|
|
handleUpdate: (newValue: string) => void;
|
|
}
|
|
|
|
export default memo(MultiLineCell);
|
|
|
|
function MultiLineCell({ initialValue, handleUpdate }: MultiLineCellProps) {
|
|
const ref = useRef<HTMLTextAreaElement | null>(null);
|
|
const submitCallback = useCallback((newValue: string) => handleUpdate(newValue), [handleUpdate]);
|
|
|
|
const { value, onChange, onBlur, onKeyDown } = useReactiveTextInput(initialValue, submitCallback, ref, {
|
|
submitOnCtrlEnter: true,
|
|
allowKeyboardNavigation: true,
|
|
});
|
|
|
|
return (
|
|
<AutoTextarea
|
|
inputref={ref}
|
|
variant='ghosted'
|
|
fluid
|
|
rows={1}
|
|
value={value}
|
|
onChange={onChange}
|
|
onBlur={onBlur}
|
|
onKeyDown={onKeyDown}
|
|
spellCheck={false}
|
|
/>
|
|
);
|
|
}
|