/**
 * Props contract passed by `DataTable` to a custom editable-cell editor.
 *
 * This is the standardized Inversion-of-Control (IoC) contract for the
 * `type: 'custom'` editable column. `DataTable` / `EditableCell` own the edit
 * lifecycle (draft value, save/cancel, per-cell loading, read-only transitions);
 * the consumer-provided `renderEditor` owns only the editor UI and maps user
 * interactions to `onChange`, `onSave`, or `onCancel`.
 *
 * The contract is intentionally library-agnostic: it does not depend on Ant
 * Design, a specific form library, or any particular input component.
 *
 * @template TValue - The type of the value being edited.
 * @template TRecord - The type of the full row record.
 *
 * @example
 * ```tsx
 * editable: {
 *   type: 'custom',
 *   renderEditor: ({ value, onChange, onSave, onCancel, isLoading }) => (
 *     <select
 *       value={String(value ?? '')}
 *       disabled={isLoading}
 *       autoFocus
 *       onChange={(e) => {
 *         onChange(e.target.value);
 *         // Commit-on-select: pass the just-selected value to avoid stale draft.
 *         onSave(e.target.value);
 *       }}
 *       onKeyDown={(e) => e.key === 'Escape' && onCancel()}
 *     >
 *       {options.map((opt) => (
 *         <option key={opt.value} value={opt.value}>{opt.label}</option>
 *       ))}
 *     </select>
 *   ),
 * }
 * ```
 */
export type CustomEditorProps<TValue = unknown, TRecord = unknown> = {
    /**
     * The current draft value of the cell while editing.
     */
    value: TValue;
    /**
     * The full data record for the current row.
     */
    record: TRecord;
    /**
     * The key of the column being edited.
     */
    dataIndex: keyof TRecord | string;
    /**
     * Updates the draft value without committing it.
     *
     * @param newValue - The new draft value.
     */
    onChange: (newValue: TValue) => void;
    /**
     * Commits the edit and triggers the `cellEdit.onSave` lifecycle.
     *
     * Accepts an optional final value so an editor can commit the just-selected
     * value directly (e.g. commit-on-select), avoiding a stale-draft race when
     * save is triggered in the same handler as `onChange`. When called with a
     * value, the cell commits that value; otherwise it commits the current draft.
     *
     * @param value - Optional final value to commit instead of the current draft.
     * @returns A promise that resolves when the save completes (if async).
     */
    onSave: (value?: TValue) => Promise<void> | void;
    /**
     * Discards the draft value and returns the cell to read-only mode.
     */
    onCancel: () => void;
    /**
     * Whether a save is currently in flight for this cell. Scoped per cell.
     */
    isLoading: boolean;
};
export default CustomEditorProps;
