import './index.less'; import React, { CSSProperties, ReactNode } from 'react'; import { TableProps, ColumnType } from 'antd/es/table'; import { ColumnFilterItem } from 'antd/es/table/interface'; import { FormItemProps, FormProps, FormInstance } from 'antd/es/form'; import { TooltipProps } from 'antd/es/tooltip'; import { IntlType } from './component/intlContext'; import { UseFetchDataAction, RequestData } from './useFetchData'; import { OptionConfig, ToolBarProps } from './component/toolBar'; import { SearchConfig, TableFormItem } from './form'; import { StatusType } from './component/status'; import { ProColumnsValueType, ProColumnsValueTypeFunction } from './defaultRender'; import { DensitySize } from './component/toolBar/DensityIcon'; export type TableRowSelection = TableProps['rowSelection']; export interface ActionType { reload: (resetPageIndex?: boolean) => void; reloadAndRest: () => void; fetchMore: () => void; reset: () => void; clearSelected: () => void; } export interface ColumnsState { show?: boolean; fixed?: 'right' | 'left' | undefined; } export type ValueEnumObj = { [key: string]: { text: ReactNode; status: StatusType; } | ReactNode; }; export type ValueEnumMap = Map; export interface ProColumnType extends Omit, 'render' | 'children' | 'title' | 'filters'>, Partial> { total?: number; index?: number; title?: ReactNode | ((config: ProColumnType, type: ProTableTypes) => ReactNode); /** * custom render */ render?: (text: React.ReactNode, record?: T, index?: number, action?: UseFetchDataAction>) => React.ReactNode | React.ReactNode[]; /** * Customize render, but need to return string */ renderText?: (text: any, record: T, index: number, action: UseFetchDataAction>) => any; /** * Custom search form input */ renderFormItem?: (item: ProColumns, config: { value?: any; onChange?: (value: any) => void; onSelect?: (value: any) => void; type: ProTableTypes; defaultRender: (newItem: ProColumns) => JSX.Element | null; }, form: FormInstance) => JSX.Element | false | null; /** * Search form props */ formItemProps?: { [prop: string]: any; }; /** * Search form defaults */ initialValue?: any; /** * whether to abbreviate */ ellipsis?: boolean | { showTitle?: boolean; tooltip?: boolean | TooltipProps; }; /** * whether to copy */ copyable?: boolean; /** * value type */ valueType?: ProColumnsValueType | ProColumnsValueTypeFunction; /** * An enumeration of values, if there is an enumeration, select will be generated in Search */ valueEnum?: ValueEnumMap | ValueEnumObj; /** * hidden in inquiry form */ hideInSearch?: boolean; /** * hide in table */ hideInTable?: boolean; /** * delete in new form */ hideInForm?: boolean; /** * Filter menu items in header */ filters?: boolean | ColumnFilterItem[]; /** * sorting of forms */ order?: number; needTotal?: boolean; displayOptions?: { format?: string; [x: string]: any; }; } export interface ProColumnGroupType extends ProColumnType { children: ProColumns | ProColumns[]; } export type ProColumns> = ProColumnGroupType | ProColumnType; export type ProTableTypes = 'form' | 'list' | 'table' | 'cardList' | 'advancedform' | undefined; export interface ProTableProps, U extends { [key: string]: any; }> extends Omit, 'columns' | 'rowSelection'> { columns?: ProColumns[]; params?: U; columnsStateMap?: { [key: string]: ColumnsState; }; onColumnsStateChange?: (map: { [key: string]: ColumnsState; }) => void; onSizeChange?: (size: DensitySize) => void; /** * A method to get the dataSource */ request?: (params: U & { pageSize?: number; current?: number; }, sort: { [key: string]: 'ascend' | 'descend'; }, filter: { [key: string]: React.ReactText[]; }) => Promise>; /** * do some processing on the data */ postData?: (data: any[]) => any[]; /** * default data */ defaultData?: T[]; /** * Initialized parameters, can operate table */ actionRef?: React.MutableRefObject | ((actionRef: ActionType) => void); /** * Operate the built-in form */ formRef?: TableFormItem['formRef']; /** * render action bar */ toolBarRender?: ToolBarProps['toolBarRender'] | false; /** * Triggered after data loading is complete */ onLoad?: (dataSource: T[]) => void; /** * Triggered when data loading fails */ onRequestError?: (e: Error) => void; /** * the className for the encapsulated table */ tableClassName?: string; /** * the style for the encapsulated table */ tableStyle?: CSSProperties; /** * title in the upper left corner */ headerTitle?: React.ReactNode; /** * Default action bar configuration */ options?: OptionConfig | false; /** * Whether to show the search form */ search?: boolean | SearchConfig; /** * Form configuration with type="form" and search form * The basic configuration is the same as antd Form * but hijacked the configuration of the form */ form?: Omit; /** * How to format the date * Temporarily only supports moment * string will be formatted as YYYY-DD-MM * number represents the timestamp */ dateFormatter?: 'string' | 'number' | false; /** * Format search form submission data */ beforeSearchSubmit?: (params: Partial) => Partial; /** * Customize the alert of the table * Set or return false to close */ tableAlertRender?: ((props: { intl: IntlType; selectedRowKeys: (string | number)[]; selectedRows: T[]; }) => React.ReactNode) | false; /** * Customize the operation of the alert of the table * Set or return false to close */ tableAlertOptionRender?: ((props: { intl: IntlType; onCleanSelected: () => void; }) => React.ReactNode) | false; rowSelection?: TableProps['rowSelection'] | false; style?: React.CSSProperties; /** * Supported ProTable Types */ type?: ProTableTypes; /** * Fired when the form is submitted */ onSubmit?: (params: U) => void; /** * Fired when the form is reset */ onReset?: () => void; /** * Displayed when empty */ columnEmptyText?: ColumnEmptyText; scrollTop?: boolean; } export type ColumnEmptyText = string | false; /** * 🏆 Use Ant Design Table like a Pro! * faster better more convenient * @param props */ declare const ProviderWarp: , U extends { [key: string]: any; } = Record>(props: ProTableProps) => JSX.Element; export default ProviderWarp;