/**
 * V21 Table 表格
 * 封装 Ant Design Table，应用 V21 设计系统样式
 */
import React from "react";
import { Table as AntTable } from "antd";
import type { TableProps as AntTableProps } from "antd";
import classNames from "classnames";
import "./ui.css";

export interface TableProps<
  RecordType = unknown,
> extends AntTableProps<RecordType> {
  /** 使用 V21 样式 */
  v21?: boolean;
}

function Table<RecordType extends object = Record<string, unknown>>({
  className,
  v21 = true,
  ...rest
}: TableProps<RecordType>) {
  const v21Class = classNames(v21 && "xx-table", className);
  return <AntTable<RecordType> className={v21Class} {...rest} />;
}

export default Table as <RecordType extends object = Record<string, unknown>>(
  props: TableProps<RecordType> & React.RefAttributes<HTMLDivElement>,
) => React.ReactElement;
