xph-crud 0.3.2 → 0.3.4
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.
- package/dist/index.js +303 -297
- package/dist/index.umd.cjs +8 -8
- package/dist/types/common/src/components/actions/types/actionItem.d.ts +13 -13
- package/dist/types/common/src/components/actions/types/actions.d.ts +6 -6
- package/dist/types/common/src/components/auth/types/index.d.ts +9 -0
- package/dist/types/common/src/components/dialog/types/dialog.d.ts +42 -30
- package/dist/types/common/src/components/index.d.ts +3 -0
- package/dist/types/common/src/hooks/useAsyncState.d.ts +2 -2
- package/dist/types/common/src/utils/getValueByPath.d.ts +3 -0
- package/dist/types/common/src/utils/uuid.d.ts +3 -0
- package/dist/types/form/index.d.ts +1 -0
- package/dist/types/form/src/helper.d.ts +1 -1
- package/dist/types/form/src/hooks/useApiComonentCache.d.ts +6 -9
- package/dist/types/form/src/hooks/useForm.d.ts +1 -1
- package/dist/types/form/src/types/form.d.ts +50 -37
- package/dist/types/form/src/types/formItem.d.ts +37 -35
- package/dist/types/table/index.d.ts +3 -2
- package/dist/types/table/src/components/table/components/cellFunc/types/cellFunc.d.ts +12 -3
- package/dist/types/table/src/types/apiTable.d.ts +24 -44
- package/dist/types/table/src/types/column.d.ts +1 -1
- package/dist/types/table/src/types/crudFormDialog.d.ts +13 -3
- package/dist/types/table/src/types/searchForm.d.ts +4 -1
- package/dist/types/table/src/types/table.d.ts +5 -5
- package/package.json +1 -1
|
@@ -14,95 +14,75 @@ export interface IFunctionToolbarParams<T = TDataSourceItem> {
|
|
|
14
14
|
*/
|
|
15
15
|
export type TApiTableProps<T = TDataSourceItem, J extends TXphExtendComponentPropsMap = {}, K extends TXphExtendComponentPropsMap = {}, L extends TXphExtendComponentPropsMap = {}> = {
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @description 列配置项
|
|
17
|
+
* 列配置项,默认为`[]`
|
|
19
18
|
*/
|
|
20
19
|
columns?: TColumnProps<T, J, K>[];
|
|
21
20
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @description 首次是否自动请求
|
|
21
|
+
* 首次是否自动请求,默认为`true`
|
|
24
22
|
*/
|
|
25
23
|
autoRequest?: boolean;
|
|
26
24
|
/**
|
|
27
|
-
*
|
|
28
|
-
* @description 获取datasource的api
|
|
25
|
+
* 获取datasource的api
|
|
29
26
|
*/
|
|
30
27
|
api?: (params: any) => Promise<any>;
|
|
31
28
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @description 格式化返回的datasource
|
|
29
|
+
* 格式化返回的datasource
|
|
34
30
|
*/
|
|
35
31
|
formatDataSource?: (data: any) => any[];
|
|
36
32
|
/**
|
|
37
|
-
*
|
|
38
|
-
* @description 是否开启前端自动分页(当api不支持分页时可用)
|
|
33
|
+
* 是否开启前端自动分页(当api不支持分页时可用)
|
|
39
34
|
*/
|
|
40
35
|
autoPagination?: boolean;
|
|
41
36
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @description 单选 / 多选
|
|
37
|
+
* 单选 / 多选
|
|
44
38
|
*/
|
|
45
39
|
rowSelection?: RowSelectionType | TableRowSelection<T>;
|
|
46
40
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
41
|
+
* 分页配置(因为分页器是独立出来的,使用table的分页器布局需要修改样式)
|
|
42
|
+
* 默认为`{ pageSize: 20, total: 0, showTotal: (total) => `共:$\\{total\\} 条`, current: 1, pageSizeOptions: [10, 20, 50, 100], showSizeChanger: true, showQuickJumper: true, }`
|
|
49
43
|
*/
|
|
50
44
|
pagination?: false | PaginationProps;
|
|
51
45
|
/**
|
|
52
|
-
*
|
|
53
|
-
* @description 表格撑满父容器(virtual为true时,默认fullHeight为true)
|
|
46
|
+
* 表格撑满父容器(virtual为true时,默认fullHeight为true),默认为`false`
|
|
54
47
|
*/
|
|
55
48
|
fullHeight?: boolean;
|
|
56
49
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @description 顶部操作栏配置,函数时可以传递参数,参数是什么由调用方决定
|
|
50
|
+
* 顶部操作栏配置,函数时可以传递参数,参数是什么由调用方决定
|
|
59
51
|
*/
|
|
60
52
|
toolbar?: IXphActionsProps<L> | ((e: IFunctionToolbarParams<T>) => IXphActionsProps<L>);
|
|
61
53
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
54
|
+
* 分页请求参数中传递到接口的属性名
|
|
55
|
+
* 默认为`{ pageSize: "pageSize", current: "current", }`
|
|
64
56
|
*/
|
|
65
57
|
requestFields?: {
|
|
66
|
-
/**
|
|
67
|
-
* @default "current"
|
|
68
|
-
* @description 当前页
|
|
69
|
-
*/
|
|
70
58
|
current?: string;
|
|
71
|
-
/**
|
|
72
|
-
* @default "pageSize"
|
|
73
|
-
* @description 当前页大小
|
|
74
|
-
*/
|
|
75
59
|
pageSize?: string;
|
|
76
60
|
};
|
|
77
61
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
62
|
+
* 响应结果中获取数据的属性名
|
|
63
|
+
* 默认为`{ current: "current", list: "data", total: "total", }`
|
|
80
64
|
*/
|
|
81
65
|
responseFields?: {
|
|
82
|
-
/**
|
|
83
|
-
* @default "current"
|
|
84
|
-
* @description 当前页
|
|
85
|
-
*/
|
|
86
66
|
current?: string;
|
|
87
|
-
/**
|
|
88
|
-
* @default "data"
|
|
89
|
-
* @description 列表
|
|
90
|
-
*/
|
|
91
67
|
list?: string;
|
|
92
|
-
/**
|
|
93
|
-
* @default "total"
|
|
94
|
-
* @description 所有页总数
|
|
95
|
-
*/
|
|
96
68
|
total?: string;
|
|
97
69
|
};
|
|
98
70
|
/**
|
|
99
|
-
*
|
|
100
|
-
* @description 排序、筛选变化时触发
|
|
71
|
+
* 排序、筛选变化时触发
|
|
101
72
|
*/
|
|
102
73
|
onChange?: (filters: any, sorter: any, extra: any) => void;
|
|
103
74
|
} & Omit<TableProps<T>, "rowSelection" | "columns" | "loading" | "dataSource" | "pagination">;
|
|
104
75
|
export type TApiTableActionType = {
|
|
76
|
+
/**
|
|
77
|
+
* 重置事件(重置页码、表单后重新请求)
|
|
78
|
+
*/
|
|
105
79
|
resetAllData: () => Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* 重置事件(重置表单后重新请求)
|
|
82
|
+
*/
|
|
106
83
|
resetData: () => Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* 刷新数据
|
|
86
|
+
*/
|
|
107
87
|
reloadData: () => Promise<void>;
|
|
108
88
|
} & TableRef;
|
|
@@ -9,7 +9,7 @@ import { TXphExtendComponentPropsMap } from '../../../common';
|
|
|
9
9
|
type TBaseColumnType<T> = {} & ColumnType<T>;
|
|
10
10
|
export interface IComponentColumnProps<T, J extends TXphExtendComponentPropsMap = {}, K extends TXphExtendComponentPropsMap = {}> extends Omit<TBaseColumnType<T>, "render"> {
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* 单元格渲染属性(原理也是使用render渲染不同的内容)
|
|
13
13
|
*/
|
|
14
14
|
cellFunc: ((props: {
|
|
15
15
|
text: any;
|
|
@@ -2,11 +2,20 @@ import { IXphFormProps, IXphFormActionType } from '../../../form';
|
|
|
2
2
|
import { TXphExtendComponentPropsMap, IXphDialogProps, IXphDialogActionType } from '../../../common';
|
|
3
3
|
|
|
4
4
|
export type TCrudFormDialogProps<T extends TXphExtendComponentPropsMap = {}> = Omit<IXphDialogProps, "onOk" | "onCancel"> & {
|
|
5
|
+
/**
|
|
6
|
+
* crud弹窗的form配置
|
|
7
|
+
*/
|
|
5
8
|
formProps: IXphFormProps<T>;
|
|
9
|
+
/**
|
|
10
|
+
* crud弹窗点击确定的回调
|
|
11
|
+
*/
|
|
6
12
|
onOk?: (event: {
|
|
7
13
|
values: any;
|
|
8
14
|
data: any;
|
|
9
15
|
}) => Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* crud弹窗点击取消回调
|
|
18
|
+
*/
|
|
10
19
|
onCancel?: (event: {
|
|
11
20
|
values: any;
|
|
12
21
|
data: any;
|
|
@@ -14,22 +23,23 @@ export type TCrudFormDialogProps<T extends TXphExtendComponentPropsMap = {}> = O
|
|
|
14
23
|
};
|
|
15
24
|
export interface IOpenActionConfig {
|
|
16
25
|
/**
|
|
17
|
-
*
|
|
26
|
+
* 回填表单的内容
|
|
18
27
|
*/
|
|
19
28
|
data: any;
|
|
20
29
|
/**
|
|
21
|
-
*
|
|
30
|
+
* 点击确定的回调(如果弹窗传递了onOk属性就不用传这个了,这个是为了方便所有操作都在open函数中处理)
|
|
22
31
|
*/
|
|
23
32
|
ok?: (event: {
|
|
24
33
|
values: any;
|
|
25
34
|
}) => Promise<any>;
|
|
26
35
|
/**
|
|
27
|
-
*
|
|
36
|
+
* 点击取消的回调(如果弹窗传递了onCancel属性就不用传这个了,这个是为了方便所有操作都在open函数中处理)
|
|
28
37
|
*/
|
|
29
38
|
cancel?: (event: {
|
|
30
39
|
values: any;
|
|
31
40
|
}) => Promise<any>;
|
|
32
41
|
}
|
|
33
42
|
export interface ICrudFormDialogActionType extends IXphFormActionType, Omit<IXphDialogActionType, "open"> {
|
|
43
|
+
/** 打开crud弹窗 */
|
|
34
44
|
open: (config: IOpenActionConfig) => Promise<void>;
|
|
35
45
|
}
|
|
@@ -2,11 +2,14 @@ import { IXphFormProps, IXphFormActionType } from '../../../form';
|
|
|
2
2
|
import { TXphExtendComponentPropsMap } from '../../../common';
|
|
3
3
|
|
|
4
4
|
export type TSearchFormActionType = IXphFormActionType & {
|
|
5
|
+
/**
|
|
6
|
+
* 设置表单的loading
|
|
7
|
+
*/
|
|
5
8
|
setFormLoading: (loading: boolean) => void;
|
|
6
9
|
};
|
|
7
10
|
export type TSearchFormProps<T extends TXphExtendComponentPropsMap = {}> = IXphFormProps<T> & {
|
|
8
11
|
/**
|
|
9
|
-
*
|
|
12
|
+
* 是否显示搜索 & 重置按钮
|
|
10
13
|
*/
|
|
11
14
|
showSearch?: boolean;
|
|
12
15
|
};
|
|
@@ -12,23 +12,23 @@ export type TDataSourceItem = Record<PropertyKey, any>;
|
|
|
12
12
|
*/
|
|
13
13
|
export type TTableProps<RecordType = TDataSourceItem, CellFuncExtendPropsMap extends TXphExtendComponentPropsMap = {}, ActionsExtendPropsMap extends TXphExtendComponentPropsMap = {}, ToolbarExtendPropsMap extends TXphExtendComponentPropsMap = {}, FormExtendPropsMap extends TXphExtendComponentPropsMap = {}> = {
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* 表格配置
|
|
16
16
|
*/
|
|
17
17
|
table?: TApiTableProps<RecordType, CellFuncExtendPropsMap, ActionsExtendPropsMap, ToolbarExtendPropsMap>;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* 搜索表单配置项
|
|
20
20
|
*/
|
|
21
21
|
searchForm?: TSearchFormProps<FormExtendPropsMap>;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* (新增 / 修改)表单弹窗配置项
|
|
24
24
|
*/
|
|
25
25
|
crudFormDialog?: TCrudFormDialogProps<FormExtendPropsMap>;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* 分页改变事件
|
|
28
28
|
*/
|
|
29
29
|
onPaginationChange?: (page: number, pageSize: number) => void;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* 列表选中事件
|
|
32
32
|
*/
|
|
33
33
|
onRowSelectionChange?: (selectedRowKeys: React.Key[], selectedRows: RecordType[]) => void;
|
|
34
34
|
};
|