import { ActionType } from '@ant-design/pro-table';
import { FormInstance } from 'antd/es/form';
import { TablePros as AntTableProps } from 'antd/es/table';
import { BaseEntity, IPage } from 'nsn-entity';
import { Operation } from 'nsn-enum';
import { Key } from 'react';

export type TableState<T extends BaseEntity, S = {}> = {

  /** 分页数据 */
  page?: IPage<T>;

  /** 编辑窗口显示状态 */
  editVisible?: boolean;

  /** 编辑窗口模式 */
  editType?: Operation.NEW | Operation.EDIT;

  /** 详情窗口显示状态 */
  detailVisible?: boolean;

  /** 当前选中的数据 */
  record?: T;

  /** 搜索表单引用 */
  searchFormRef?: FormInstance;

  /** 搜索表单操作引用 */
  searchActionRef?: ActionType;

  /** 编辑表单引用 */
  editFormRef?: FormInstance;

  /** 编辑表单操作引用 */
  editActionRef?: ActionType;

  /** table 的行默认显示高度 */
  densitySize?: AntTableProps<any>['size'];

  /** 当前选中的行 */
  selectedRows?: Array<T & { [K: string]: any }>;

  /** 当前展开的行 */
  expandedRowKeys?: Array<Key>;

} & {
    [K in keyof S]: S[K];
  };