import React from 'react'; import { BatchActionsProps } from '../components/BatchActions'; import { TableRowSelection } from '../../table/interface'; import { ApolloTableActionType, ApolloColumnType, OrderDirection, Ordering, PageInfo, Variables, } from '.'; import { InputProps } from '../../input'; import { CardProps } from '../../card'; import { TableProps } from '../../table'; import { RadioChangeEvent } from '../../radio'; export type SelectedView = { name: string; id: string; query?: string; orderBy?: { field: string; direction: OrderDirection } | null; filters?: Record; }; export interface SelectedViewsProps { config?: SelectedView[]; store?: { get: () => Promise; add: (params: { name: string; query: string; orderBy: { field: string; direction: OrderDirection } | null; filters: Record; }) => Promise<{ id?: string; success?: boolean }>; remove: (id: string) => Promise<{ success: boolean }>; update: (params: { id: string; name: string }) => Promise<{ success: boolean }>; }; } export interface ApolloTableRowSelection extends TableRowSelection { allowSelectAll?: boolean; onSelectedAllChange?: (isSelectedAll: boolean) => void; } export interface ApolloTableProps extends TableProps { id: string; syncToUrl?: boolean; actionRef?: React.MutableRefObject; cardProps?: CardProps; columns?: Array>; rowSelection?: ApolloTableRowSelection; pageInfo?: PageInfo; options?: | { setting?: boolean; } | false; /** 是否显示筛选控件,默认 true */ search?: | false | { /** 输入框是否是按下回车搜索 */ pressEnterToSearch?: boolean; /** 自定义输入框右边要显示的 */ extra?: React.ReactNode; /** 隐藏筛选标签 */ hideTags?: boolean; /** 隐藏输入框 */ hideQueryField?: boolean; /** 帮助信息 */ helpText?: string | React.ReactNode; /** 查询输入框的属性 */ queryProps?: Omit; /** 排序配置 */ sortOptions?: { field: string; direction: OrderDirection; label: string }[]; /** 默认排序 */ defaultSortValue?: Ordering; // 视图配置 selectedViews?: SelectedViewsProps; // 更多筛选器清除全部按钮回调 onClearAll?: () => void; // 排序发生变化回调 onSortChange?: (e: RadioChangeEvent) => void; }; pagination?: | { /** 一页个数 */ pageSize?: number; /** 当数量小于 pageSize 时是否隐藏分页器 */ hideOnSinglePage?: boolean; } | false; /** 参数发生改变时触发 */ request?: (params: Variables) => Promise | void; /** 防抖时间 */ debounceTime?: number; tableAlertRender?: | ((props: { selectedRowKeys: (number | string)[]; selectedRows: T[]; onCleanSelected: () => void; isSelectedAll: boolean; }) => BatchActionsProps['tableAlertRenderResult']) | false; }