diff --git a/src/components/FormBuilder/FormItemsRenderer.d.ts b/src/components/FormBuilder/FormItemsRenderer.d.ts index 3181bdd..3ac7e34 100644 --- a/src/components/FormBuilder/FormItemsRenderer.d.ts +++ b/src/components/FormBuilder/FormItemsRenderer.d.ts @@ -3,7 +3,7 @@ import type { FormItemProps, Rule } from "antd/es/form"; import type { FormListFieldData } from "antd/es/form/FormList"; import type { Gutter } from "antd/es/grid/row"; import type { NamePath } from "rc-field-form/lib/interface"; -import type { CSSProperties, ReactElement, ReactNode } from "react"; +import type { CSSProperties, Key, ReactElement, ReactNode } from "react"; import type { FORM_ITEM_RENDER_TYPE_MAP } from "../../enum/formItemRender"; import type { DeepPartial } from "./FormBuilder"; @@ -98,7 +98,7 @@ export interface FormOptionBase< Dependencies = NamePath, > { /** React 需要的 key,如果传递了唯一的 name,则不需要 */ - key?: string; + key?: Key; /** 表单项字段名 */ name?: Name; /** 表单项标签 */ diff --git a/src/components/Table/index.d.ts b/src/components/Table/index.d.ts index 967b6c1..aff7a41 100644 --- a/src/components/Table/index.d.ts +++ b/src/components/Table/index.d.ts @@ -1,11 +1,33 @@ -import type { ProTableProps } from "@ant-design/pro-table"; -import type { TableProps as AntdTableProps } from "antd"; +import type { ProColumns, ProTableProps } from "@ant-design/pro-components"; +import type { TableProps as AntdTableProps, TableColumnType } from "antd"; import type { FC } from "react"; +/** 保留 Ant Design 推导的嵌套元组路径,移除宽泛字符串和普通数组 */ +type StrictTableDataIndex = DataIndex extends string + ? never + : DataIndex extends readonly unknown[] + ? number extends DataIndex["length"] ? never : DataIndex + : DataIndex extends number ? DataIndex : never; + +/** 表格字段索引,支持一级字段和嵌套字段路径提示 */ +export type TableDataIndex + = | Extract + | StrictTableDataIndex["dataIndex"]>>; + +/** 表格列配置 */ +export type TableColumn = Omit, "children" | "dataIndex"> & { + /** 当前列对应的数据字段 */ + dataIndex?: TableDataIndex; + /** 多级表头子列 */ + children?: TableColumn[]; +}; + /** - * TablePro 组件属性 + * Table 组件属性 */ -export type TableProps = Omit & ProTableProps & { +export type TableProps, ValueType = "text"> = Omit, "columns"> & Omit, "columns"> & { + /** 表格列配置 */ + columns: TableColumn[]; /** 当一个路由下存在多个表格的情况下 需要给每一个表格设置一个唯一存储索引 若没有设置则使用默认索引,请注意缓存数据会被覆盖 */ storeIndex?: string; /** 是否禁用内容区滚动,默认 false */ @@ -25,5 +47,5 @@ export type TableProps = Omit(props: TableProps) => ReturnType; +declare const Table: , ValueType = "text">(props: TableProps) => ReturnType; export default Table;