import { jsx } from 'react/jsx-runtime';
import * as React from 'react';
import { moveCursorToEnd } from './util.js';
import EditableCell from './EditableCell.js';

/** The default Spreadsheet DataEditor component */
const DataEditor = ({ onChange, cell }) => {
    const inputRef = React.useRef(null);
    const handleChange = React.useCallback((value) => {
        const { contextDisable, ...cellWithoutContext } = cell;
        onChange({
            ...cellWithoutContext,
            value,
            inputType: cellWithoutContext.inputType ?? { type: 'text' },
        });
    }, [onChange, cell]);
    React.useEffect(() => {
        if (inputRef.current) {
            moveCursorToEnd(inputRef.current);
        }
    }, []);
    const value = cell?.value ?? '';
    return (jsx("div", { className: "ff-spreadsheet-data-editor", children: jsx(EditableCell, { ref: inputRef, initialValue: value, onChange: handleChange, className: "ff-spreadsheet-cell-textarea", style: {
                ...cell?.style, width: '100%', height: '100%',
                borderTop: '',
                borderBottom: '',
                borderLeft: '',
                borderRight: '',
            } }) }));
};

export { DataEditor as default };
//# sourceMappingURL=DataEditor.js.map
