import type { PropType } from 'vue';
import { propTypes } from '@/utils/propTypes';
import type { PaginationProps } from './types/pagination';
import type {
  SizeType,
  TableRowSelection,
  BasicColumn,
  TableCustomRecord,
  TableSetting,
} from './types/table';

export const basicProps = {
  //原组件参数
  bordered: propTypes.bool,
  columns: {
    type: [Array] as PropType<BasicColumn[]>,
    default: () => [],
  },
  components: propTypes.object,

  dataSource: {
    type: Array as PropType<Recordable[]>,
    default: undefined,
  },
  expandIcon: {
    type: Function,
    default: undefined,
  },
  expandRowByClick: {
    type: Boolean,
    default: false,
  },
  expandIconColumnIndex: {
    type: Number,
    default: undefined,
  },
  footer: {
    type: Function,
    default: undefined,
  },
  loading: {
    type: [Object, Boolean],
    default: false,
  },
  locale: {
    type: Object,
    default: () => ({
      filterConfirm: '确定',
      filterReset: '重置',
      emptyText: '暂无数据',
    }),
  },
  pagination: {
    type: [Object, Boolean] as PropType<PaginationProps | boolean>,
    default: undefined,
  },
  rowClassName: {
    type: Function as PropType<(record: TableCustomRecord<any>, index: number) => string>,
  },
  rowKey: {
    type: [String, Function] as PropType<string | ((record: Recordable) => string)>,
    default: '',
  },
  rowSelection: {
    type: Object as PropType<TableRowSelection | undefined>,
    default: undefined,
  },
  scroll: {
    type: Object as PropType<{ x: number | true; y: number }>,
    default: undefined,
  },
  showHeader: {
    type: Boolean,
    default: true,
  },
  size: {
    type: String as PropType<SizeType>,
    default: 'middle',
  },
  sortDirections: {
    type: Array,
    default: ['ascend', 'descend'],
  },
  sticky: {
    type: [Object, Boolean],
    default: undefined,
  },
  tableLayout: {
    type: String,
    default: '',
  },
  indentSize: {
    type: Number,
    default: 15,
  },
  //3.0
  rowExpandable: {
    type: Function,
    default: undefined,
  },
  customRow: {
    type: Function,
    default: undefined,
  },
  leftTitle: {
    type: String,
    default: undefined,
  },
  leftTitleTooltip: {
    type: String,
    default: undefined,
  },
  request: {
    type: Function as PropType<(...arg: any[]) => Promise<any>>,
    default: undefined,
  },
  //废弃
  showPagination: {
    type: [String, Boolean],
    default: 'auto',
  },
  actionColumn: {
    type: Object,
    default: undefined,
  },
  // 表格滚动最大高度
  maxHeight: {
    type: Number as PropType<number>,
    default: 0,
  },
  showTableSetting: {
    type: Boolean,
    default: true,
  },
  tableSetting: {
    type: Object as PropType<TableSetting>,
    default: () => ({
      width: 230,
      redo: true,
      size: true,
      setting: true,
      fullscreen: true,
      striped: true,
    }),
  },
  canResize: propTypes.bool.def(true),
  resizeHeightOffset: propTypes.number.def(0),
  //原组件参数
};
