zy-react-library 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import type { FormItemProps, Rule } from "antd/es/form";
3
3
  import type { FormListFieldData } from "antd/es/form/FormList";
4
4
  import type { Gutter } from "antd/es/grid/row";
5
5
  import type { NamePath } from "rc-field-form/lib/interface";
6
- import type { CSSProperties, ReactElement, ReactNode } from "react";
6
+ import type { CSSProperties, Key, ReactElement, ReactNode } from "react";
7
7
  import type { FORM_ITEM_RENDER_TYPE_MAP } from "../../enum/formItemRender";
8
8
  import type { DeepPartial } from "./FormBuilder";
9
9
 
@@ -98,7 +98,7 @@ export interface FormOptionBase<
98
98
  Dependencies = NamePath<Values>,
99
99
  > {
100
100
  /** React 需要的 key,如果传递了唯一的 name,则不需要 */
101
- key?: string;
101
+ key?: Key;
102
102
  /** 表单项字段名 */
103
103
  name?: Name;
104
104
  /** 表单项标签 */
@@ -1,11 +1,33 @@
1
- import type { ProTableProps } from "@ant-design/pro-table";
2
- import type { TableProps as AntdTableProps } from "antd";
1
+ import type { ProColumns, ProTableProps } from "@ant-design/pro-components";
2
+ import type { TableProps as AntdTableProps, TableColumnType } from "antd";
3
3
  import type { FC } from "react";
4
4
 
5
+ /** 保留 Ant Design 推导的嵌套元组路径,移除宽泛字符串和普通数组 */
6
+ type StrictTableDataIndex<DataIndex> = DataIndex extends string
7
+ ? never
8
+ : DataIndex extends readonly unknown[]
9
+ ? number extends DataIndex["length"] ? never : DataIndex
10
+ : DataIndex extends number ? DataIndex : never;
11
+
12
+ /** 表格字段索引,支持一级字段和嵌套字段路径提示 */
13
+ export type TableDataIndex<DataSource>
14
+ = | Extract<keyof DataSource, string | number>
15
+ | StrictTableDataIndex<NonNullable<TableColumnType<DataSource>["dataIndex"]>>;
16
+
17
+ /** 表格列配置 */
18
+ export type TableColumn<DataSource, ValueType = "text"> = Omit<ProColumns<DataSource, ValueType>, "children" | "dataIndex"> & {
19
+ /** 当前列对应的数据字段 */
20
+ dataIndex?: TableDataIndex<DataSource>;
21
+ /** 多级表头子列 */
22
+ children?: TableColumn<DataSource, ValueType>[];
23
+ };
24
+
5
25
  /**
6
- * TablePro 组件属性
26
+ * Table 组件属性
7
27
  */
8
- export type TableProps<DataSource, U, ValueType> = Omit<AntdTableProps, "columns"> & ProTableProps<DataSource, U, ValueType> & {
28
+ export type TableProps<DataSource, U = Record<string, unknown>, ValueType = "text"> = Omit<AntdTableProps<DataSource>, "columns"> & Omit<ProTableProps<DataSource, U, ValueType>, "columns"> & {
29
+ /** 表格列配置 */
30
+ columns: TableColumn<DataSource, ValueType>[];
9
31
  /** 当一个路由下存在多个表格的情况下 需要给每一个表格设置一个唯一存储索引 若没有设置则使用默认索引,请注意缓存数据会被覆盖 */
10
32
  storeIndex?: string;
11
33
  /** 是否禁用内容区滚动,默认 false */
@@ -25,5 +47,5 @@ export type TableProps<DataSource, U, ValueType> = Omit<AntdTableProps, "columns
25
47
  /**
26
48
  * 表格组件
27
49
  */
28
- declare const Table: <DataSource, U, ValueType = "text">(props: TableProps<DataSource, U, ValueType>) => ReturnType<FC>;
50
+ declare const Table: <DataSource, U = Record<string, unknown>, ValueType = "text">(props: TableProps<DataSource, U, ValueType>) => ReturnType<FC>;
29
51
  export default Table;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zy-react-library",
3
3
  "private": false,
4
- "version": "1.4.0",
4
+ "version": "1.4.1",
5
5
  "type": "module",
6
6
  "description": "",
7
7
  "author": "LiuJiaNan",