import { defineCellType } from '../../types';
import { NumberView } from './View';
import { NumberEdit } from './Edit';
export { NumberView, NumberEdit };
export const numberCellType = defineCellType({
    type: 'number',
    ViewComponent: NumberView,
    EditComponent: NumberEdit,
    serialize: (value) => (value != null ? String(value) : ''),
    deserialize: (raw) => {
        if (raw === '') {
            return null;
        }
        const parsed = Number(raw);
        if (!Number.isFinite(parsed)) {
            throw new Error();
        }
        return parsed;
    },
    validate: (value) => {
        if (value != null && typeof value !== 'number') {
            return 'Value must be a number';
        }
        return null;
    },
    editable: true,
    clearable: true,
    onTypeToEdit: ({ key }) => /^\d$/.test(key) ? { value: Number(key) } : undefined,
});
//# sourceMappingURL=index.js.map