import { GridColDef, GridColType, GridFilterModel, GridPaginationModel, GridSortModel } from '@mui/x-data-grid'; import type { StandardSchemaV1 } from '@standard-schema/spec'; export type DataModelId = string | number; export interface DataModel { id: DataModelId; [key: PropertyKey]: unknown; } type RemappedOmit = { [P in keyof T as P extends K ? never : P]: T[P] }; export type OmitId = RemappedOmit; export type DataFieldFormValue = string | string[] | number | boolean | File | null; export type DataFieldRenderFormField = ({ value, onChange, error }: { value: F; onChange: (value: F) => void | Promise; error: string | null; }) => React.ReactNode; export type DataField = RemappedOmit & { type?: GridColType; renderFormField?: DataFieldRenderFormField; }; export interface DataSource { fields: DataField[]; getMany?: (params: { paginationModel: GridPaginationModel; sortModel: GridSortModel; filterModel: GridFilterModel; }) => { items: D[]; itemCount: number; } | Promise<{ items: D[]; itemCount: number; }>; getOne?: (id: DataModelId) => D | Promise; createOne?: (data: Partial>) => D | Promise; updateOne?: (id: DataModelId, data: Partial>) => D | Promise; deleteOne?: (id: DataModelId) => void | Promise; /** * Function to validate form values. Follows the Standard Schema `validate` function format (https://standardschema.dev/). */ validate?: (value: Partial>) => ReturnType>>['~standard']['validate']>; } export {};