74 lines
1.7 KiB
TypeScript
74 lines
1.7 KiB
TypeScript
import { ResourceField, FieldType } from './config';
|
|
|
|
export interface EnumOption {
|
|
key: string;
|
|
value: string;
|
|
}
|
|
|
|
export interface FieldOverride {
|
|
displayField?: string | string[];
|
|
display?: boolean;
|
|
formatter?: (value: any) => string;
|
|
filterType?: "autocomplete" | "multiselect" | "number-range" | "date-range";
|
|
enumLabels?: Record<string, string>;
|
|
}
|
|
|
|
export interface ResourceOverride {
|
|
fields?: Record<string, FieldOverride>;
|
|
pagination?: boolean;
|
|
hidden?: boolean;
|
|
filterOptions?: {
|
|
mode?: "server" | "client";
|
|
fields?: string[];
|
|
};
|
|
enumOption?: EnumOption;
|
|
}
|
|
|
|
export interface FieldComponentProps {
|
|
name: string;
|
|
field: ResourceField;
|
|
value: any;
|
|
onChange: (val: any) => void;
|
|
disabled?: boolean;
|
|
error?: string;
|
|
baseUrl?: string;
|
|
relationDataMap?: Record<string, any[]>;
|
|
uploadFile?: (file: File) => Promise<string | null>;
|
|
uploading?: boolean;
|
|
}
|
|
|
|
export type FieldComponent = React.ComponentType<FieldComponentProps>;
|
|
|
|
export type FieldComponents = Partial<Record<FieldType, FieldComponent>> & {
|
|
relation?: FieldComponent;
|
|
image?: FieldComponent;
|
|
default?: FieldComponent;
|
|
};
|
|
|
|
export interface CellRendererProps {
|
|
value: any;
|
|
row: any;
|
|
field: ResourceField;
|
|
fieldKey: string;
|
|
config: import('./config').ResourceConfig;
|
|
onNavigate?: (resourceName: string, id: string) => void;
|
|
isMobile?: boolean;
|
|
}
|
|
|
|
export type CellRenderer = React.ComponentType<CellRendererProps>;
|
|
|
|
export interface EnhancedTableComponents {
|
|
cellRenderers?: Partial<Record<FieldType, CellRenderer>>;
|
|
}
|
|
|
|
export interface FilterBarComponents {
|
|
filterInputs?: Record<string, React.ComponentType<{
|
|
field: ResourceField;
|
|
value: any;
|
|
onChange: (val: any) => void;
|
|
options: string[];
|
|
}>>;
|
|
}
|
|
|
|
export type { FieldType };
|