import { jsx as _jsx } from "react/jsx-runtime";
import * as React from 'react';
import { moveCursorToEnd } from './util';
/** The default Spreadsheet DataEditor component */
const DataEditor = ({ onChange, cell }) => {
    const inputRef = React.useRef(null);
    const handleChange = React.useCallback((event) => {
        onChange({
            ...cell,
            value: event.target.value,
            style: cell?.style,
            inputType: cell?.inputType ?? { type: 'text' },
        });
    }, [onChange, cell]);
    React.useEffect(() => {
        if (inputRef.current) {
            moveCursorToEnd(inputRef.current);
        }
    }, [inputRef]);
    const value = cell?.value ?? '';
    return (_jsx("div", { className: "ff-spreadsheet-data-editor", children: _jsx("textarea", { className: "ff-spreadsheet-cell-textarea", style: { ...cell?.style }, ref: inputRef, onChange: handleChange, value: value, autoFocus: true, disabled: cell?.readOnly }) }));
};
export default DataEditor;
//# sourceMappingURL=DataEditor.js.map