UNPKG

@quanxi/ui

Version:

全悉组件库

84 lines (83 loc) 3.61 kB
import React from "react"; import * as antd from "antd"; import type { PaginationProps } from "../Pagination/type"; import type { ColumnType as TableColumnType } from "antd/lib/table"; import { RenderedCell } from "rc-table/lib/interface"; import { Option as DropdownOption } from "../Dropdown"; export interface ColumnType<RecordType> extends Omit<TableColumnType<RecordType>, "render"> { hidden?: boolean; resizable?: boolean; type?: "operation" | "expandable" | "customOperation"; render?: (value: any, record: RecordType, index: number, mode?: "expandable") => React.ReactNode | RenderedCell<RecordType> | OperationColumnType<RecordType> | OperationColumnType<RecordType>[] | JSX.Element; } interface OperationColumnPopover<RecordType> { name: string; key: string; onClick: (record: RecordType) => void; disabled?: boolean; hidden?: boolean; } interface OperationColumnPopoverType<RecordType> { type: "popover"; name: string; key: string; icon: React.ReactNode; hidden?: boolean; onHover?: (record: RecordType, index: number) => void; popover: OperationColumnPopover<RecordType>[]; } interface OperationColumnIconType<RecordType> { type?: "icon"; name: string; key: string; icon: React.ReactNode; disabled?: boolean; hidden?: boolean; onClick: (record: RecordType) => void; } interface OperationColumnButtonType<RecordType> { type: "button" | "dropdown"; key: string; name: string | React.ReactNode; btnType: "primary" | "secondary" | "subtle"; items?: DropdownOption[]; disabled?: boolean; popover?: React.ReactNode; onClick?: (record: RecordType) => void; } export type OperationColumnType<RecordType> = OperationColumnPopoverType<RecordType> | OperationColumnIconType<RecordType> | OperationColumnButtonType<RecordType>; export type ColumnsType<RecordType> = ColumnType<RecordType>[]; export type ColumnFilterReset = () => string[] | Promise<string[]>; interface TablePropsType<RecordType> extends Omit<antd.TableProps<RecordType>, "columns" | "pagination"> { className?: string; showColumnFilter?: boolean; columnFilterKey?: string; mini?: boolean; columns?: ColumnsType<RecordType>; pagination?: PaginationProps; onChange?: (pagination: any, filters: any, sorter: any) => void; onColumnsChanged?: (fields: string[], otherFields?: string[]) => void; columnFilterReset?: ColumnFilterReset; specialSequence?: boolean; specialSequenceHandler?: (v: string[], movekeys: string[]) => string[]; isLoading?: boolean; showExpandColumn?: boolean; } /** * 表格 Column 新增配置项 * @param {boolean} hidden 不在表格中显示此列 * @param {boolean} resizable 允许此列进行列宽调整 * @param {"operation"|"expandable"} type 此列类型标识,operation:操作列,expandable:展开区域内展示字段 * * column 配置项参考 https://ant.design/components/table-cn/#Column * 在此基础上添加了 hidden、resizable 配置项 * * hidden - 属性以满足自定义显示列 * * resizable - 属性以满足自定义列宽 * * type - 当前列字段所属类型标识(正常单元格展示则不需要传递此类型标识) operation:操作列 、expandable:展开区域内展示字段 */ export default function Table<RecordType extends object = any>(props: TablePropsType<RecordType>): JSX.Element; export declare function OperationsRender<RecordType extends object = any>(v: OperationColumnType<RecordType>, record: RecordType, index?: number): JSX.Element; export {};