import React from 'react'; import { ColumnDef } from '@tanstack/react-table'; import { RegisterOptions } from 'react-hook-form'; type OrderBy = Record; interface DynamicTableProps { parent?: TableParentRecord; inEdit?: boolean; model: string; filter?: unknown; connect?: any; headerActions?: any; onConnect?: (value: any) => void; children?: ((options: { context: ContextProps; query: { variables: { where: any; orderBy?: any[]; take: number; skip: number; }; data?: any; loading: boolean; error?: Error; getData: (...args: any[]) => any; }; }) => React.ReactNode) | null; } declare const _default: { yes: string; no: string; all: string; equals: string; in: string; notIn: string; lt: string; lte: string; gt: string; gte: string; not: string; contains: string; startsWith: string; endsWith: string; addFilter: string; nonFilterMsg: string; deleteConfirm: string; select: string; actions: string; relation: string; viewAll: string; viewRelated: string; connected: string; connect: string; disConnect: string; editRow: string; viewRow: string; deleteRow: string; showing: string; of: string; results: string; goToFirstPage: string; goToLastPage: string; goPageNumber: string; setPageSize: string; filter: string; save: string; cancel: string; close: string; create: string; update: string; view: string; isRequired: string; show: string; }; interface AdminSchemaField { id: string; name: string; title: string; type: string; list: boolean; kind: 'scalar' | 'object' | 'enum'; read: boolean; required: boolean; isId: boolean; unique: boolean; create: boolean; order: number; update: boolean; sort: boolean; filter: boolean; editor?: boolean; upload?: boolean; relationField?: boolean; } interface AdminSchemaModel { id: string; name: string; create: boolean; delete: boolean; update: boolean; idField: string; displayFields: string[]; fields: AdminSchemaField[]; } interface AdminSchemaEnum { name: string; fields: string[]; } interface AdminSchema { models: AdminSchemaModel[]; enums: AdminSchemaEnum[]; } type PrismaRecord = Record; type Columns = Record<'boolean' | 'number' | 'enum' | 'DateTime' | 'object' | 'string' | 'list' | 'json', ColumnDef>; type FieldValue = any; interface InputProps { field: AdminSchemaField; value: FieldValue; data: PrismaRecord; disabled: boolean; } type GetColumns = (field: AdminSchemaField, model?: AdminSchemaModel) => Columns; type GetColumnsPartial = (field: AdminSchemaField, model?: AdminSchemaModel) => Partial; type FormInputs = Record<'Default' | 'Editor' | 'Enum' | 'Object' | 'Date' | 'Boolean' | 'Upload', React.FC>; interface ContextProps extends RequireContextProps, SameProps { schema: AdminSchema; children?: React.ReactNode; } interface RequireContextProps { pagesPath: string; pageSize: number; pageSizeOptions: number[]; paginationOptions: number; lang: typeof _default; dir: 'rtl' | 'ltr'; } type ActionButton = Record>; type QueryParams = Record; type OrderByInput = Record; type CreateSaveHandler = (args: { model: string; setCreateModal: (value: boolean) => void; refetchTable: () => void; }) => void | Promise; type UpdateSaveHandler = (args: { model: string; refetchTable: () => void; }) => void | Promise; type CancelHandler = (args: { model: string; setCreateModal?: (value: boolean) => void; }) => void; type ValueHandler = (value: FieldValue, field?: AdminSchemaField, isCreate?: boolean) => FieldValue; type SelectHandler = (values: string[]) => void; interface SameProps { actions?: ('create' | 'update' | 'delete')[]; useSet?: boolean; tableColumns?: GetColumnsPartial; formInputs?: Partial; inputValidation?: Record>; push: (url: string) => void; query: QueryParams; onSelect?: SelectHandler; actionButtons?: ActionButton; onCancelCreate?: CancelHandler; onSaveCreate?: CreateSaveHandler; onSaveUpdate?: UpdateSaveHandler; onCancelUpdate?: CancelHandler; defaultOrderBy?: Record; valueHandler?: ValueHandler; } interface EditPageProps extends SameProps { model: string; update?: boolean; view?: boolean; create?: boolean; } interface FieldError { message?: string; type?: string; ref?: React.Ref; } interface InputPropsWithoutForm extends Omit { name: string; value: FieldValue; error?: FieldError; register?: RegisterOptions; setValue?: (name: string, value: FieldValue) => void; watch?: (name: string) => FieldValue; defaultValue?: FieldValue; disabled: boolean; } type QueryModel = (DynamicTableProps['parent'] | undefined)[]; type UpdateRecordFunction = () => void | Promise; interface TableParentRecord { name: string; field: string; value: PrismaRecord; updateRecord?: UpdateRecordFunction; } type DynamicTableChildrenFunction = (options: { context: ContextProps; query: { variables: { where: PrismaRecord; orderBy?: OrderByInput[]; take: number; skip: number; }; data?: any; loading: boolean; error?: Error; getData: () => void; }; }) => React.ReactNode; interface ModelTableProps extends SameProps, Partial> { model: string; children?: DynamicTableChildrenFunction; language?: Partial; } declare const TableContext: React.Context; declare const useTableContext: () => ContextProps; declare const Inputs: FormInputs; interface FilterComponentsProps { filterValue: any; setFilter: (value: any) => void; field: AdminSchemaField; } interface FilterProps { model: AdminSchemaModel; setAllFilters: (values: { id: string; value: any; }[]) => void; filters: { id: string; value: any; }[]; } declare const Filter: React.FC; declare const BooleanFilter: React.FC; declare const EnumFilter: React.FC; declare const PrismaTable: React.FC; declare const defaultLanguage: { dir: string; header: string; dbName: string; displayName: string; modelName: string; idField: string; displayFields: string; fieldName: string; actions: string; create: string; update: string; delete: string; read: string; filter: string; sort: string; editor: string; upload: string; tableView: string; inputType: string; }; type SettingLanguage = typeof defaultLanguage; declare const Settings: React.FC<{ language?: Partial; }>; export { type ActionButton, type AdminSchema, type AdminSchemaEnum, type AdminSchemaField, type AdminSchemaModel, BooleanFilter, type CancelHandler, type Columns, type ContextProps, type CreateSaveHandler, type DynamicTableChildrenFunction, type EditPageProps, EnumFilter, type FieldError, type FieldValue, Filter, type FormInputs, type GetColumns, type GetColumnsPartial, type InputProps, type InputPropsWithoutForm, Inputs, type ModelTableProps, type OrderByInput, type PrismaRecord, PrismaTable, type QueryModel, type QueryParams, type SelectHandler, type SettingLanguage, Settings, TableContext, type TableParentRecord, type UpdateRecordFunction, type UpdateSaveHandler, type ValueHandler, useTableContext };