xph-crud 0.3.1 → 0.3.2
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/types/common/index.d.ts +1 -1
- package/dist/types/common/src/{componnets → components}/actions/types/actionItem.d.ts +58 -17
- package/dist/types/common/src/components/actions/types/actions.d.ts +30 -0
- package/dist/types/common/src/{componnets → components}/dialog/hooks/useDialogContentMaxHeight.d.ts +1 -1
- package/dist/types/common/src/{componnets → components}/dialog/hooks/useDialogFooter.d.ts +1 -1
- package/dist/types/common/src/{componnets → components}/dialog/hooks/useDialogPosition.d.ts +1 -1
- package/dist/types/common/src/{componnets → components}/dialog/hooks/useDialogSize.d.ts +1 -1
- package/dist/types/common/src/{componnets → components}/dialog/hooks/useDialogZoom.d.ts +1 -1
- package/dist/types/common/src/{componnets → components}/dialog/hooks/useDragDialog.d.ts +1 -1
- package/dist/types/common/src/{componnets → components}/dialog/hooks/useResizeDialog.d.ts +1 -1
- package/dist/types/common/src/components/dialog/types/dialog.d.ts +87 -0
- package/dist/types/common/src/hooks/useExtendCompProps.d.ts +1 -1
- package/dist/types/common/src/types/extendComponent.d.ts +3 -1
- package/dist/types/common/src/utils/getValueByPath.d.ts +4 -4
- package/dist/types/form/src/types/form.d.ts +68 -19
- package/dist/types/form/src/types/formItem.d.ts +100 -23
- package/dist/types/table/src/components/crudFormDialog/index.d.ts +2 -2
- package/dist/types/table/src/components/table/components/cellFunc/types/cellFunc.d.ts +23 -17
- package/dist/types/table/src/types/apiTable.d.ts +72 -21
- package/dist/types/table/src/types/column.d.ts +6 -2
- package/dist/types/table/src/types/crudFormDialog.d.ts +10 -7
- package/dist/types/table/src/types/searchForm.d.ts +3 -1
- package/dist/types/table/src/types/table.d.ts +22 -18
- package/package.json +63 -63
- package/dist/types/common/src/componnets/actions/types/actions.d.ts +0 -18
- package/dist/types/common/src/componnets/dialog/types/dialog.d.ts +0 -32
- /package/dist/types/common/src/{componnets → components}/actions/actions.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/actions/components/button.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/actions/components/dropdown.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/actions/components/index.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/actions/components/more.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/actions/hooks/index.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/actions/hooks/useActionItems.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/actions/hooks/useActionsProps.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/actions/hooks/useExtendActions.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/actions/hooks/useRenderContent.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/actions/types/index.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/auth/auth.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/auth/hooks/index.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/auth/hooks/useAuthProps.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/auth/hooks/useExtendAuth.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/auth/types/index.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/dialog/components/headerBtns/index.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/dialog/components/minimizeDialog/index.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/dialog/dialog.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/dialog/hooks/index.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/dialog/hooks/useDialogActions.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/dialog/hooks/useDialogChangeRecord.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/dialog/hooks/useDialogProps.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/dialog/hooks/useExtendDialog.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/dialog/hooks/useMinResizeRecord.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/dialog/hooks/useMinimizeDialog.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/dialog/hooks/useOnContainerSizeChange.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/dialog/hooks/useOnPropsSizeChange.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/dialog/hooks/usePopperContainerSize.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/dialog/hooks/useTopShowDialog.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/dialog/types/index.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/index.d.ts +0 -0
- /package/dist/types/common/src/{componnets → components}/portal/portal.d.ts +0 -0
|
@@ -2,11 +2,17 @@ import { ButtonProps, MenuProps } from 'antd';
|
|
|
2
2
|
import { TXphExtendComponentPropsMap } from '../../../types';
|
|
3
3
|
|
|
4
4
|
export interface IBaseActionProps {
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* @description 唯一标识
|
|
7
|
+
*/
|
|
6
8
|
key?: string;
|
|
7
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* @description 是否显示
|
|
11
|
+
*/
|
|
8
12
|
ifShow?: boolean | (() => any);
|
|
9
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* @description 权限标识
|
|
15
|
+
*/
|
|
10
16
|
auth?: string | Array<string>;
|
|
11
17
|
}
|
|
12
18
|
export type TComponentType<T extends TXphExtendComponentPropsMap = {}> = {
|
|
@@ -17,40 +23,64 @@ interface IButtonProps extends ButtonProps {
|
|
|
17
23
|
}
|
|
18
24
|
interface IDropdownProps extends Omit<ButtonProps, "onClick"> {
|
|
19
25
|
dropDownItems: {
|
|
26
|
+
/**
|
|
27
|
+
* @description 唯一标识
|
|
28
|
+
*/
|
|
20
29
|
key: string;
|
|
30
|
+
/**
|
|
31
|
+
* @description 显示文本
|
|
32
|
+
*/
|
|
21
33
|
label: string;
|
|
22
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* @description 是否禁用,注意:父级如果disabled为true,子级无法展开(所以相当于是变向的父级禁用,子级也禁用了)
|
|
36
|
+
*/
|
|
23
37
|
disabled?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* @description 图标
|
|
40
|
+
*/
|
|
24
41
|
icon?: React.ReactNode;
|
|
25
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* @description 是否显示
|
|
44
|
+
*/
|
|
26
45
|
ifShow?: boolean | (() => any);
|
|
27
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* @description 权限标识
|
|
48
|
+
*/
|
|
28
49
|
auth?: string | Array<string>;
|
|
29
50
|
}[];
|
|
30
51
|
onClick?: MenuProps["onClick"];
|
|
31
52
|
}
|
|
32
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* @description 组件类型action
|
|
55
|
+
*/
|
|
33
56
|
export interface IComponentActionProps<T extends keyof TComponentType<K>, K extends TXphExtendComponentPropsMap = {}> extends IBaseActionProps {
|
|
34
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* @description 组件
|
|
59
|
+
*/
|
|
35
60
|
component: T;
|
|
36
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* @description 组件属性
|
|
63
|
+
*/
|
|
37
64
|
componentProps?: TComponentType<K>[T];
|
|
38
65
|
}
|
|
39
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* @description 自定义内容action
|
|
68
|
+
*/
|
|
40
69
|
export interface IRenderActionProps extends IBaseActionProps {
|
|
41
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* @description 自定义内容函数
|
|
72
|
+
*/
|
|
42
73
|
render: React.ReactElement;
|
|
43
74
|
}
|
|
44
75
|
/**
|
|
45
|
-
*
|
|
46
|
-
* 这个类型接受两个泛型参数 T 和 K。它使用了 TypeScript 中的映射类型,并从 T 中移除 K 对应的属性。这样做的结果是,返回的类型会继承 T,但移除了 K 对应的属性
|
|
76
|
+
* @description 这个类型接受两个泛型参数 T 和 K。它使用了 TypeScript 中的映射类型,并从 T 中移除 K 对应的属性。这样做的结果是,返回的类型会继承 T,但移除了 K 对应的属性
|
|
47
77
|
*/
|
|
48
78
|
type Without<T, K> = {
|
|
49
79
|
[P in Exclude<keyof T, K>]?: never;
|
|
50
80
|
};
|
|
51
81
|
/**
|
|
52
|
-
*
|
|
53
|
-
|
|
82
|
+
* @description
|
|
83
|
+
这个 `XOR` 类型的定义是一个 TypeScript 中的条件类型,用于实现对多个类型的互斥组合。现在,我会逐步解释这个类型的定义:
|
|
54
84
|
|
|
55
85
|
1. `T extends [infer A, infer B, ...infer Rest]`:这个条件判断首先检查泛型类型 `T` 是否是一个元组类型。如果是的话,它会将元组的第一个类型赋值给 `A`,第二个类型赋值给 `B`,并将剩余的类型赋值给 `Rest`。如果 `T` 不是元组类型,则跳到下一个条件。
|
|
56
86
|
|
|
@@ -62,17 +92,28 @@ type Without<T, K> = {
|
|
|
62
92
|
|
|
63
93
|
5. `: never`:如果 `T` 不是一个元组,并且不止一个元素,则返回 `never` 类型,表示无法匹配任何类型。
|
|
64
94
|
|
|
65
|
-
综上所述,这个 `XOR`
|
|
95
|
+
综上所述,这个 `XOR` 类型的定义通过条件类型实现了对多个类型的互斥组合,并确保在同一时间只能使用其中一个类型
|
|
66
96
|
*/
|
|
67
97
|
type XOR<T extends any[]> = T extends [infer A, infer B, ...infer Rest] ? A | B extends object ? (Without<A, keyof B> & B) | (Without<B, keyof A> & A) | XOR<[A | B, ...Rest]> : A | B : T extends [infer A] ? A : never;
|
|
98
|
+
/**
|
|
99
|
+
* @description 将组件类型映射为 IComponentActionProps
|
|
100
|
+
*/
|
|
68
101
|
type TMapComponentActionProps<T extends TXphExtendComponentPropsMap> = {
|
|
69
102
|
[K in keyof TComponentType<T>]: IComponentActionProps<K, T>;
|
|
70
103
|
}[keyof TComponentType<T>];
|
|
104
|
+
/**
|
|
105
|
+
* @description 合并 IComponentActionProps 和 IRenderActionProps
|
|
106
|
+
*/
|
|
71
107
|
export type TActionItemProps<T extends TXphExtendComponentPropsMap = {}> = XOR<[
|
|
72
108
|
TMapComponentActionProps<T>,
|
|
73
109
|
IRenderActionProps
|
|
74
110
|
]>;
|
|
75
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* @description 判断是否为组件类型action
|
|
113
|
+
*/
|
|
76
114
|
export declare function isComponentActionItemProps(item: TActionItemProps): item is IComponentActionProps<"Button">;
|
|
115
|
+
/**
|
|
116
|
+
* @description 判断是否为自定义内容action
|
|
117
|
+
*/
|
|
77
118
|
export declare function isRenderActionItemProps(item: TActionItemProps): item is IRenderActionProps;
|
|
78
119
|
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TActionItemProps } from './actionItem';
|
|
2
|
+
import { ButtonProps } from 'antd/lib/button';
|
|
3
|
+
import { TXphExtendComponentPropsMap } from '../../../types';
|
|
4
|
+
|
|
5
|
+
export interface IActionsProps<T extends TXphExtendComponentPropsMap = {}> {
|
|
6
|
+
/**
|
|
7
|
+
* @description 类型
|
|
8
|
+
*/
|
|
9
|
+
type?: ButtonProps["type"];
|
|
10
|
+
/**
|
|
11
|
+
* @description 操作项
|
|
12
|
+
*/
|
|
13
|
+
items?: TActionItemProps<T>[];
|
|
14
|
+
/**
|
|
15
|
+
* @description 禁用(items中的componentProps的disabled优先级最高)
|
|
16
|
+
*/
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* @description 自定义内容(items的优先级高于render)
|
|
20
|
+
*/
|
|
21
|
+
render?: React.ReactElement;
|
|
22
|
+
/**
|
|
23
|
+
* @description 超过多少个item自动省略,默认是10(其余全部放在一个dropdown中)
|
|
24
|
+
*/
|
|
25
|
+
max?: number;
|
|
26
|
+
/**
|
|
27
|
+
* @description 是否需要从扩展中继承属性(可能有些特殊情况,不需要使用扩展中的属性)
|
|
28
|
+
*/
|
|
29
|
+
inherit?: boolean;
|
|
30
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDialogChangeRecord, IContainerSizeTarget } from '
|
|
1
|
+
import { IDialogChangeRecord, IContainerSizeTarget } from '.';
|
|
2
2
|
|
|
3
3
|
declare const useDialogZoom: ({ containerSizeTarget, dialogChangeRecord, close, setDialogSize, setDialogPosition, }: {
|
|
4
4
|
containerSizeTarget: React.MutableRefObject<IContainerSizeTarget>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MouseEvent } from 'react';
|
|
2
|
-
import { IContainerSizeTarget } from '
|
|
2
|
+
import { IContainerSizeTarget } from '.';
|
|
3
3
|
|
|
4
4
|
declare const useResizeDialog: ({ containerSizeTarget, dialogRef, minResizeRecord, setDialogSize, setDialogPosition, setMinResizeRecord, }: {
|
|
5
5
|
containerSizeTarget: React.MutableRefObject<IContainerSizeTarget>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ButtonProps } from 'antd';
|
|
2
|
+
|
|
3
|
+
export interface IDialogProps {
|
|
4
|
+
/**
|
|
5
|
+
* @default 700
|
|
6
|
+
* @description 弹窗的宽度
|
|
7
|
+
*/
|
|
8
|
+
width?: number;
|
|
9
|
+
/**
|
|
10
|
+
* @default -
|
|
11
|
+
* @description 弹窗的高度
|
|
12
|
+
*/
|
|
13
|
+
height?: number;
|
|
14
|
+
/**
|
|
15
|
+
* @default false
|
|
16
|
+
* @description 是否显示遮罩
|
|
17
|
+
*/
|
|
18
|
+
mask?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* @default -
|
|
21
|
+
* @description 弹窗的标题
|
|
22
|
+
*/
|
|
23
|
+
title?: string;
|
|
24
|
+
/**
|
|
25
|
+
* @default -
|
|
26
|
+
* @description 确定按钮属性
|
|
27
|
+
*/
|
|
28
|
+
okProps?: Omit<ButtonProps, "children" | "onClick">;
|
|
29
|
+
/**
|
|
30
|
+
* @default -
|
|
31
|
+
* @description 取消按钮属性
|
|
32
|
+
*/
|
|
33
|
+
cancelProps?: Omit<ButtonProps, "children" | "onClick">;
|
|
34
|
+
/**
|
|
35
|
+
* @default "确定"
|
|
36
|
+
* @description 确定按钮文字
|
|
37
|
+
*/
|
|
38
|
+
okText?: string;
|
|
39
|
+
/**
|
|
40
|
+
* @default "取消"
|
|
41
|
+
* @description 取消按钮文字
|
|
42
|
+
*/
|
|
43
|
+
cancelText?: string;
|
|
44
|
+
/**
|
|
45
|
+
* @default -
|
|
46
|
+
* @description 点击确定按钮触发该事件
|
|
47
|
+
*/
|
|
48
|
+
onOk?: (args: any) => Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* @default -
|
|
51
|
+
* @description 点击取消按钮触发该事件
|
|
52
|
+
*/
|
|
53
|
+
onCancel?: (args: any) => Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* @default -
|
|
56
|
+
* @description 底部按钮自定义渲染函数
|
|
57
|
+
*/
|
|
58
|
+
renderFooter?: ({ loading }: {
|
|
59
|
+
loading: boolean;
|
|
60
|
+
}) => React.ReactElement;
|
|
61
|
+
/**
|
|
62
|
+
* @default -
|
|
63
|
+
* @description 顶部标题自定义渲染函数
|
|
64
|
+
*/
|
|
65
|
+
renderTitle?: () => React.ReactElement;
|
|
66
|
+
/**
|
|
67
|
+
* @default -
|
|
68
|
+
* @description 打开的时候会触发该事件
|
|
69
|
+
*/
|
|
70
|
+
onOpen?: () => void;
|
|
71
|
+
/**
|
|
72
|
+
* @default -
|
|
73
|
+
* @description 关闭的时候会触发该事件
|
|
74
|
+
*/
|
|
75
|
+
onClose?: () => void;
|
|
76
|
+
/**
|
|
77
|
+
* @default () => document.body
|
|
78
|
+
* @description 挂载弹窗的容器
|
|
79
|
+
*/
|
|
80
|
+
getPopperContainer?: () => HTMLElement | null;
|
|
81
|
+
}
|
|
82
|
+
export interface IDialogActionType {
|
|
83
|
+
open: () => Promise<void>;
|
|
84
|
+
close: () => void;
|
|
85
|
+
setLoading: (loading: boolean) => void;
|
|
86
|
+
getVisible: () => boolean;
|
|
87
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { IXphActionsProps } from '../
|
|
2
|
+
import { IXphActionsProps } from '../components';
|
|
3
3
|
import { IXphFormProps } from '../../../form';
|
|
4
4
|
import { TXphTableProps } from '../../../table';
|
|
5
5
|
import { IXphDialogProps, IXphAuthProps } from '../..';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare const getValueByPath: (obj: Record<string, any>, path: string) => any;
|
|
2
2
|
/**
|
|
3
3
|
* @description 通过属性为包含.的字符串的对象从值对象中获取值
|
|
4
|
-
* @
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* @example
|
|
5
|
+
* fields { current: 'data.current', pageSize: 'data.pageSize' }
|
|
6
|
+
* values { data: { current: 1, pageSize: 10 } }
|
|
7
|
+
* return { current: 1, pageSize: 10 }
|
|
8
8
|
*/
|
|
9
9
|
export declare const getValuesByPathObj: (fields: Record<string, string>, values: Record<string, any>) => Record<string, any>;
|
|
@@ -7,42 +7,88 @@ export interface IRegister {
|
|
|
7
7
|
(methods: IFormActionType): void;
|
|
8
8
|
}
|
|
9
9
|
export interface IFormProps<T extends TXphExtendComponentPropsMap = {}> {
|
|
10
|
-
items: TFormItemProps<T>[] /** 表单项配置集合 */;
|
|
11
10
|
/**
|
|
12
|
-
* @
|
|
13
|
-
* @description
|
|
11
|
+
* @default []
|
|
12
|
+
* @description 表单项配置集合
|
|
13
|
+
*/
|
|
14
|
+
items: TFormItemProps<T>[];
|
|
15
|
+
/**
|
|
16
|
+
* @default "horizontal"
|
|
17
|
+
* @description 表单布局方式,排除了antd的inline,因为可以使用colProps实现inline布局
|
|
14
18
|
*/
|
|
15
19
|
layout?: "horizontal" | "vertical";
|
|
16
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* @default false
|
|
22
|
+
* @description 表示是否显示 label 后面的冒号 (只有在属性 layout 为 horizontal 时有效)
|
|
23
|
+
*/
|
|
17
24
|
colon?: boolean;
|
|
18
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* @default -
|
|
27
|
+
* @description 设置表单组件禁用,仅对 antd 组件有效
|
|
28
|
+
*/
|
|
19
29
|
disabled?: boolean;
|
|
20
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* @default -
|
|
32
|
+
* @description 表单项组件布局方式(wrapperCol的span与labelCol的span形成24栅格布局)
|
|
33
|
+
*/
|
|
21
34
|
wrapperCol?: ColProps;
|
|
22
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* @default true
|
|
37
|
+
* @description label 标签的文本换行方式
|
|
38
|
+
*/
|
|
23
39
|
labelWrap?: boolean;
|
|
24
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* @default -
|
|
42
|
+
* @description label 标签的文本对齐方式
|
|
43
|
+
*/
|
|
25
44
|
labelAlign?: "left" | "right";
|
|
26
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* @default -
|
|
47
|
+
* @description 表单项label标签布局方式(wrapperCol的span与labelCol的span形成24栅格布局)
|
|
48
|
+
*/
|
|
27
49
|
labelCol?: ColProps;
|
|
28
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* @default -
|
|
52
|
+
* @description 表单项的栅格配置
|
|
53
|
+
*/
|
|
29
54
|
colProps?: ColProps;
|
|
30
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* @default -
|
|
57
|
+
* @description 提交失败自动滚动到第一个错误字段
|
|
58
|
+
*/
|
|
31
59
|
scrollToFirstError?: boolean;
|
|
32
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* @default -
|
|
62
|
+
* @description 设置字段组件的尺寸(仅限 antd 组件)
|
|
63
|
+
*/
|
|
33
64
|
size?: "large" | "middle" | "small";
|
|
34
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* @default -
|
|
67
|
+
* @description 是否可折叠,默认超过5个折叠
|
|
68
|
+
*/
|
|
35
69
|
collapsible?: boolean;
|
|
36
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* @default 5
|
|
72
|
+
* @description 超过多少进行折叠,collapsible为true才生效
|
|
73
|
+
*/
|
|
37
74
|
collapseNum?: number;
|
|
38
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* @default -
|
|
77
|
+
* @description 渲染操作组,用于渲染表单项的操作,这是一个预留项,是否需要操作组由业务自己决定(会跟折叠同行显示)
|
|
78
|
+
*/
|
|
39
79
|
renderActions?: () => React.ReactElement;
|
|
40
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* @default (date: any, format: string) => { return date?.format?.(format || "YYYY-MM-DD HH:mm:ss") ?? date; }
|
|
82
|
+
* @description 时间返回统一处理函数
|
|
83
|
+
*/
|
|
41
84
|
transformDateFunc?: (date: any, format: string) => string;
|
|
42
85
|
/**
|
|
43
|
-
* @
|
|
44
|
-
* @description
|
|
86
|
+
* @default -
|
|
87
|
+
* @description 用于将表单内时间区域的应设成 2 个字段,见下方案例
|
|
45
88
|
* @example
|
|
89
|
+
*
|
|
90
|
+
* // 场景:如果表单内有时间区间组件,获取到的值是一个数组,但是往往我们传递到后台需要是 2 个字段
|
|
91
|
+
*
|
|
46
92
|
* fieldMapToTime: [
|
|
47
93
|
* // data为时间组件在表单内的字段,startTime,endTime为转化后的开始时间与结束时间
|
|
48
94
|
* // 'YYYY-MM-DD'为时间格式,参考moment
|
|
@@ -75,7 +121,10 @@ export interface IFormProps<T extends TXphExtendComponentPropsMap = {}> {
|
|
|
75
121
|
* }
|
|
76
122
|
*/
|
|
77
123
|
fieldMapToTime?: [string, [string, string], (string | [string, string])?][];
|
|
78
|
-
/**
|
|
124
|
+
/**
|
|
125
|
+
* @default -
|
|
126
|
+
* @description 注册事件(useForm使用,form组件会在挂载后调用)
|
|
127
|
+
*/
|
|
79
128
|
register?: IRegister;
|
|
80
129
|
}
|
|
81
130
|
export interface IFormActionType {
|
|
@@ -5,45 +5,122 @@ import { ColProps } from 'antd';
|
|
|
5
5
|
import { IFormActionType } from './form';
|
|
6
6
|
import { TXphExtendComponentPropsMap } from '../../../common';
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* 字符串类型对象
|
|
10
|
-
*/
|
|
11
8
|
export type Recordable<T> = Record<string, T>;
|
|
12
9
|
export type TFunction<T> = T | ((args: Recordable<any>) => T);
|
|
13
10
|
export interface IBaseFormItemProps {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @default -
|
|
13
|
+
* @description 字段名
|
|
14
|
+
*/
|
|
15
|
+
name: string;
|
|
16
|
+
/**
|
|
17
|
+
* @default -
|
|
18
|
+
* @description 标签名
|
|
19
|
+
*/
|
|
20
|
+
label: string;
|
|
21
|
+
/**
|
|
22
|
+
* @default -
|
|
23
|
+
* @description 子节点的值的属性,如 Switch、Checkbox 的是 checked
|
|
24
|
+
*/
|
|
25
|
+
valuePropName?: string;
|
|
26
|
+
/**
|
|
27
|
+
* @default -
|
|
28
|
+
* @description 是否显示(相当于display:none)
|
|
29
|
+
*/
|
|
30
|
+
show?: TFunction<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* @default -
|
|
33
|
+
* @description 是否显示(会新增或删除节点)
|
|
34
|
+
*/
|
|
35
|
+
ifShow?: TFunction<boolean>;
|
|
36
|
+
/**
|
|
37
|
+
* @default -
|
|
38
|
+
* @description 是否必填
|
|
39
|
+
*/
|
|
40
|
+
required?: TFunction<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* @default -
|
|
43
|
+
* @description 是否禁用(当和 Form 同时设置时,以 Item 为准)
|
|
44
|
+
*/
|
|
45
|
+
disabled?: TFunction<boolean>;
|
|
46
|
+
/**
|
|
47
|
+
* @default -
|
|
48
|
+
* @description 组件属性
|
|
49
|
+
*/
|
|
50
|
+
componentProps?: TFunction<Recordable<any>>;
|
|
51
|
+
/**
|
|
52
|
+
* @default -
|
|
53
|
+
* @description 校验规则
|
|
54
|
+
*/
|
|
55
|
+
rules?: Rule[];
|
|
56
|
+
/**
|
|
57
|
+
* @default -
|
|
58
|
+
* @description 表单项组件的布局方式(当和 Form 同时设置时,以 Item 为准)
|
|
59
|
+
*/
|
|
60
|
+
wrapperCol?: ColProps;
|
|
61
|
+
/**
|
|
62
|
+
* @default -
|
|
63
|
+
* @description 表单项label标签布局方式(当和 Form 同时设置时,以 Item 为准)
|
|
64
|
+
*/
|
|
65
|
+
labelCol?: ColProps;
|
|
66
|
+
/**
|
|
67
|
+
* @default -
|
|
68
|
+
* @description 表单项的栅格配置(当和 Form 同时设置时,以 Item 为准)
|
|
69
|
+
*/
|
|
70
|
+
colProps?: ColProps;
|
|
71
|
+
/**
|
|
72
|
+
* @default -
|
|
73
|
+
* @description 是否强制换一行显示该表单项(强制换行后续会跟随换行表单项)
|
|
74
|
+
*/
|
|
75
|
+
forceRow?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* @default -
|
|
78
|
+
* @description 默认值
|
|
79
|
+
*/
|
|
80
|
+
initialValue?: any;
|
|
28
81
|
}
|
|
29
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* @description 自定义渲染函数的props
|
|
84
|
+
*/
|
|
30
85
|
export interface IFRenderProps {
|
|
86
|
+
/**
|
|
87
|
+
* @description 当前项name
|
|
88
|
+
*/
|
|
31
89
|
name: string;
|
|
90
|
+
/**
|
|
91
|
+
* @description 当前项状态
|
|
92
|
+
*/
|
|
32
93
|
disabled: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* @description 组件属性
|
|
96
|
+
*/
|
|
33
97
|
componentProps: Recordable<any>;
|
|
98
|
+
/**
|
|
99
|
+
* @description 表单值
|
|
100
|
+
*/
|
|
34
101
|
model: any;
|
|
102
|
+
/**
|
|
103
|
+
* @description 表单方法实例
|
|
104
|
+
*/
|
|
35
105
|
methods: IFormActionType;
|
|
36
106
|
}
|
|
37
|
-
/** render props */
|
|
38
107
|
/**
|
|
39
|
-
* @description
|
|
108
|
+
* @description render props(自定义渲染函数,若根节点为antd组件,就会和form组件进行双向绑定,model也是响应式的;若根节点为非antd组件,就不会和form组件进行双向绑定,需根据实际业务手动处理表单项的值)
|
|
40
109
|
*/
|
|
41
110
|
export interface IRenderFormItemProps extends IBaseFormItemProps {
|
|
42
|
-
|
|
111
|
+
/**
|
|
112
|
+
* @description 自定义渲染函数
|
|
113
|
+
*/
|
|
114
|
+
render: (props: IFRenderProps) => React.ReactNode;
|
|
43
115
|
}
|
|
44
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* @description component props
|
|
118
|
+
*/
|
|
45
119
|
export interface IComponentFormItemProps<T extends TXphExtendComponentPropsMap = {}> extends IBaseFormItemProps {
|
|
46
|
-
|
|
120
|
+
/**
|
|
121
|
+
* @description 映射组件
|
|
122
|
+
*/
|
|
123
|
+
component: keyof TComponentPropsMap<T>;
|
|
47
124
|
}
|
|
48
125
|
type Without<T, K> = {
|
|
49
126
|
[P in Exclude<keyof T, K>]?: never;
|
|
@@ -5,11 +5,11 @@ import { TXphExtendComponentPropsMap } from '../../../../common';
|
|
|
5
5
|
declare const CrudFormDialog: (props: TCrudFormDialogProps, ref: ForwardedRef<ICrudFormDialogActionType>) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
declare const ForwardedCrudFormDialog: <T extends TXphExtendComponentPropsMap = {}>(props: Omit<import('../../../../common').IXphDialogProps, "onOk" | "onCancel"> & {
|
|
7
7
|
formProps: import('../../../../form').IXphFormProps<T>;
|
|
8
|
-
onOk?: ((
|
|
8
|
+
onOk?: ((event: {
|
|
9
9
|
values: any;
|
|
10
10
|
data: any;
|
|
11
11
|
}) => Promise<any>) | undefined;
|
|
12
|
-
onCancel?: ((
|
|
12
|
+
onCancel?: ((event: {
|
|
13
13
|
values: any;
|
|
14
14
|
data: any;
|
|
15
15
|
}) => Promise<any>) | undefined;
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { IXphActionsProps, TXphExtendComponentPropsMap } from '../../../../../../../common';
|
|
2
2
|
import { IComponentColumnProps, TDataSourceItem } from '../../../../../types';
|
|
3
3
|
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* @description cellFunc中每一项对应的组件componentProps属性映射
|
|
6
|
+
*/
|
|
5
7
|
export type TCellComponentPropsMap<CellFuncExtendPropsMap extends TXphExtendComponentPropsMap = {}, ActionsExtendPropsMap extends TXphExtendComponentPropsMap = {}> = {
|
|
6
8
|
link: {
|
|
7
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* @description 超链接,点击超链接跳转
|
|
11
|
+
*/
|
|
8
12
|
url?: string;
|
|
9
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* @description 点击事件(优先级最高)
|
|
15
|
+
*/
|
|
10
16
|
onClick?: () => void;
|
|
11
17
|
};
|
|
12
18
|
actions: IXphActionsProps<ActionsExtendPropsMap>;
|
|
13
19
|
tag: {
|
|
14
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* @description 标签的枚举
|
|
22
|
+
*/
|
|
15
23
|
enums: Array<{
|
|
16
24
|
label: string;
|
|
17
25
|
value: any;
|
|
@@ -25,7 +33,9 @@ type Without<T, K> = {
|
|
|
25
33
|
[P in Exclude<keyof T, K>]?: never;
|
|
26
34
|
};
|
|
27
35
|
type XOR<T extends any[]> = T extends [infer A, infer B, ...infer Rest] ? A | B extends object ? (Without<A, keyof B> & B) | (Without<B, keyof A> & A) | XOR<[A | B, ...Rest]> : A | B : T extends [infer A] ? A : never;
|
|
28
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* @description cellFunc中每一项的配置
|
|
38
|
+
*/
|
|
29
39
|
interface ICellProps<T extends keyof TCellComponentPropsMap<J, K>, J extends TXphExtendComponentPropsMap = {}, K extends TXphExtendComponentPropsMap = {}> {
|
|
30
40
|
component: T;
|
|
31
41
|
componentProps?: TCellComponentPropsMap<J, K>[T];
|
|
@@ -34,14 +44,10 @@ type TCellFuncPropsMap<J extends TXphExtendComponentPropsMap = {}, K extends TXp
|
|
|
34
44
|
[T in keyof TCellComponentPropsMap<J, K>]: ICellProps<T, J, K>;
|
|
35
45
|
}[keyof TCellComponentPropsMap<J, K>];
|
|
36
46
|
export type TCellProps<J extends TXphExtendComponentPropsMap = {}, K extends TXphExtendComponentPropsMap = {}> = XOR<[TCellFuncPropsMap<J, K>]>;
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
T = TDataSourceItem,
|
|
41
|
-
/** 单元格的扩展组件props映射 */
|
|
42
|
-
J extends TXphExtendComponentPropsMap = {},
|
|
43
|
-
/** 操作组的扩展组件props映射 */
|
|
44
|
-
K extends TXphExtendComponentPropsMap = {}> {
|
|
47
|
+
/**
|
|
48
|
+
* @description CellFunc组件的props
|
|
49
|
+
*/
|
|
50
|
+
export interface ICellFuncProps<T = TDataSourceItem, J extends TXphExtendComponentPropsMap = {}, K extends TXphExtendComponentPropsMap = {}> {
|
|
45
51
|
dslConfig: TCellProps<J, K>[];
|
|
46
52
|
renderPrams: {
|
|
47
53
|
text: any;
|
|
@@ -50,15 +56,15 @@ K extends TXphExtendComponentPropsMap = {}> {
|
|
|
50
56
|
column: Omit<IComponentColumnProps<T, K, K>, "cellFunc">;
|
|
51
57
|
};
|
|
52
58
|
}
|
|
53
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* @description cellFunc中每一项对应的组件的props
|
|
61
|
+
*/
|
|
54
62
|
export interface ICurCellFuncProps<J extends TXphExtendComponentPropsMap = {}, K extends TXphExtendComponentPropsMap = {}, T extends keyof TCellComponentPropsMap<J, K> = keyof TCellComponentPropsMap<J, K>> {
|
|
55
63
|
curComponentProps?: TCellComponentPropsMap<J, K>[T];
|
|
56
64
|
cellFuncProps: ICellFuncProps<TDataSourceItem, J, K>;
|
|
57
65
|
}
|
|
58
66
|
/**
|
|
59
|
-
*
|
|
60
|
-
* 因为渲染是从cellFuncs中的最后一项开始的,所以mainClick是排在后面的组件传递到前面的
|
|
61
|
-
*
|
|
67
|
+
* @description 因为渲染是从cellFuncs中的最后一项开始的,所以mainClick是排在后面的组件传递到前面的
|
|
62
68
|
* 目的:目的是为了将自定义组件的点击事件交给最底层的组件进行调用
|
|
63
69
|
* 注意:因为多个自定义组件可能都有mainClick,所以也需要保证其他组件的正常调用(即:传递给子组件Comp的时候,需要把父组件传递过来的mainClick给手动执行一下)
|
|
64
70
|
*/
|
|
@@ -9,47 +9,98 @@ export interface IFunctionToolbarParams<T = TDataSourceItem> {
|
|
|
9
9
|
loading: boolean;
|
|
10
10
|
selection: T[];
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* @description 扩展antd table的属性
|
|
14
|
+
*/
|
|
13
15
|
export type TApiTableProps<T = TDataSourceItem, J extends TXphExtendComponentPropsMap = {}, K extends TXphExtendComponentPropsMap = {}, L extends TXphExtendComponentPropsMap = {}> = {
|
|
14
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* @default []
|
|
18
|
+
* @description 列配置项
|
|
19
|
+
*/
|
|
15
20
|
columns?: TColumnProps<T, J, K>[];
|
|
16
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* @default true
|
|
23
|
+
* @description 首次是否自动请求
|
|
24
|
+
*/
|
|
17
25
|
autoRequest?: boolean;
|
|
18
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* @default -
|
|
28
|
+
* @description 获取datasource的api
|
|
29
|
+
*/
|
|
19
30
|
api?: (params: any) => Promise<any>;
|
|
20
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* @default -
|
|
33
|
+
* @description 格式化返回的datasource
|
|
34
|
+
*/
|
|
21
35
|
formatDataSource?: (data: any) => any[];
|
|
22
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* @default -
|
|
38
|
+
* @description 是否开启前端自动分页(当api不支持分页时可用)
|
|
39
|
+
*/
|
|
23
40
|
autoPagination?: boolean;
|
|
24
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* @default -
|
|
43
|
+
* @description 单选 / 多选
|
|
44
|
+
*/
|
|
25
45
|
rowSelection?: RowSelectionType | TableRowSelection<T>;
|
|
26
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* @default { pageSize: 20, total: 0, showTotal: (total) => `共:${total} 条`, current: 1, pageSizeOptions: [10, 20, 50, 100], showSizeChanger: true, showQuickJumper: true, }
|
|
48
|
+
* @description 分页配置(因为分页器是独立出来的,使用table的分页器布局需要修改样式)
|
|
49
|
+
*/
|
|
27
50
|
pagination?: false | PaginationProps;
|
|
28
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* @default false
|
|
53
|
+
* @description 表格撑满父容器(virtual为true时,默认fullHeight为true)
|
|
54
|
+
*/
|
|
29
55
|
fullHeight?: boolean;
|
|
30
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* @default -
|
|
58
|
+
* @description 顶部操作栏配置,函数时可以传递参数,参数是什么由调用方决定
|
|
59
|
+
*/
|
|
31
60
|
toolbar?: IXphActionsProps<L> | ((e: IFunctionToolbarParams<T>) => IXphActionsProps<L>);
|
|
32
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* @default { pageSize: "pageSize", current: "current", }
|
|
63
|
+
* @description 分页请求参数中传递到接口的属性名
|
|
64
|
+
*/
|
|
33
65
|
requestFields?: {
|
|
34
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* @default "current"
|
|
68
|
+
* @description 当前页
|
|
69
|
+
*/
|
|
35
70
|
current?: string;
|
|
36
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* @default "pageSize"
|
|
73
|
+
* @description 当前页大小
|
|
74
|
+
*/
|
|
37
75
|
pageSize?: string;
|
|
38
76
|
};
|
|
39
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* @default { current: "current", list: "data", total: "total", }
|
|
79
|
+
* @description 响应结果中获取数据的属性名
|
|
80
|
+
*/
|
|
40
81
|
responseFields?: {
|
|
41
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* @default "current"
|
|
84
|
+
* @description 当前页
|
|
85
|
+
*/
|
|
42
86
|
current?: string;
|
|
43
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* @default "data"
|
|
89
|
+
* @description 列表
|
|
90
|
+
*/
|
|
44
91
|
list?: string;
|
|
45
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* @default "total"
|
|
94
|
+
* @description 所有页总数
|
|
95
|
+
*/
|
|
46
96
|
total?: string;
|
|
47
97
|
};
|
|
48
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* @default -
|
|
100
|
+
* @description 排序、筛选变化时触发
|
|
101
|
+
*/
|
|
49
102
|
onChange?: (filters: any, sorter: any, extra: any) => void;
|
|
50
|
-
} & Omit<TableProps<T>,
|
|
51
|
-
/** 内部控制的属性/重写的属性 */
|
|
52
|
-
"rowSelection" | "columns" | "loading" | "dataSource" | "pagination">;
|
|
103
|
+
} & Omit<TableProps<T>, "rowSelection" | "columns" | "loading" | "dataSource" | "pagination">;
|
|
53
104
|
export type TApiTableActionType = {
|
|
54
105
|
resetAllData: () => Promise<void>;
|
|
55
106
|
resetData: () => Promise<void>;
|
|
@@ -3,10 +3,14 @@ import { TDataSourceItem } from './table';
|
|
|
3
3
|
import { TCellProps } from '../components/table/components/cellFunc/types';
|
|
4
4
|
import { TXphExtendComponentPropsMap } from '../../../common';
|
|
5
5
|
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* @description 扩展一下antd column的属性,不一定要扩展,只是预留
|
|
8
|
+
*/
|
|
7
9
|
type TBaseColumnType<T> = {} & ColumnType<T>;
|
|
8
10
|
export interface IComponentColumnProps<T, J extends TXphExtendComponentPropsMap = {}, K extends TXphExtendComponentPropsMap = {}> extends Omit<TBaseColumnType<T>, "render"> {
|
|
9
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* @description 单元格渲染属性(原理也是使用render渲染不同的内容)
|
|
13
|
+
*/
|
|
10
14
|
cellFunc: ((props: {
|
|
11
15
|
text: any;
|
|
12
16
|
record: T;
|
|
@@ -3,27 +3,30 @@ import { TXphExtendComponentPropsMap, IXphDialogProps, IXphDialogActionType } fr
|
|
|
3
3
|
|
|
4
4
|
export type TCrudFormDialogProps<T extends TXphExtendComponentPropsMap = {}> = Omit<IXphDialogProps, "onOk" | "onCancel"> & {
|
|
5
5
|
formProps: IXphFormProps<T>;
|
|
6
|
-
onOk?: (
|
|
6
|
+
onOk?: (event: {
|
|
7
7
|
values: any;
|
|
8
8
|
data: any;
|
|
9
9
|
}) => Promise<any>;
|
|
10
|
-
onCancel?: (
|
|
10
|
+
onCancel?: (event: {
|
|
11
11
|
values: any;
|
|
12
12
|
data: any;
|
|
13
13
|
}) => Promise<any>;
|
|
14
14
|
};
|
|
15
15
|
export interface IOpenActionConfig {
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* @description 回填表单的内容
|
|
18
|
+
*/
|
|
17
19
|
data: any;
|
|
18
20
|
/**
|
|
19
21
|
* @description 点击确定的回调(如果弹窗传递了onOk属性就不用传这个了,这个是为了方便所有操作都在open函数中处理)
|
|
20
|
-
* @param values 表单项的值(如果弹窗传递了onCancel属性就不用传这个了,这个是为了方便所有操作都在close函数中处理)
|
|
21
22
|
*/
|
|
22
|
-
ok?: (
|
|
23
|
+
ok?: (event: {
|
|
23
24
|
values: any;
|
|
24
25
|
}) => Promise<any>;
|
|
25
|
-
/**
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* @description 点击取消的回调(如果弹窗传递了onCancel属性就不用传这个了,这个是为了方便所有操作都在open函数中处理)
|
|
28
|
+
*/
|
|
29
|
+
cancel?: (event: {
|
|
27
30
|
values: any;
|
|
28
31
|
}) => Promise<any>;
|
|
29
32
|
}
|
|
@@ -5,6 +5,8 @@ export type TSearchFormActionType = IXphFormActionType & {
|
|
|
5
5
|
setFormLoading: (loading: boolean) => void;
|
|
6
6
|
};
|
|
7
7
|
export type TSearchFormProps<T extends TXphExtendComponentPropsMap = {}> = IXphFormProps<T> & {
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* @description 是否显示搜索 & 重置按钮
|
|
10
|
+
*/
|
|
9
11
|
showSearch?: boolean;
|
|
10
12
|
};
|
|
@@ -3,29 +3,33 @@ import { ICrudFormDialogActionType, TCrudFormDialogProps } from './crudFormDialo
|
|
|
3
3
|
import { TApiTableProps, TApiTableActionType } from './apiTable';
|
|
4
4
|
import { TXphExtendComponentPropsMap } from '../../../common';
|
|
5
5
|
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* @description 行数据
|
|
8
|
+
*/
|
|
7
9
|
export type TDataSourceItem = Record<PropertyKey, any>;
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
RecordType = TDataSourceItem,
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
ActionsExtendPropsMap extends TXphExtendComponentPropsMap = {},
|
|
16
|
-
/** 顶部操作栏扩展组件props映射 */
|
|
17
|
-
ToolbarExtendPropsMap extends TXphExtendComponentPropsMap = {},
|
|
18
|
-
/** 表单扩展组件props映射(包括:搜素表单 & 新增/修改表单) */
|
|
19
|
-
FormExtendPropsMap extends TXphExtendComponentPropsMap = {}> = {
|
|
20
|
-
/** 表格配置 */
|
|
10
|
+
/**
|
|
11
|
+
* @description 整个组件的配置
|
|
12
|
+
*/
|
|
13
|
+
export type TTableProps<RecordType = TDataSourceItem, CellFuncExtendPropsMap extends TXphExtendComponentPropsMap = {}, ActionsExtendPropsMap extends TXphExtendComponentPropsMap = {}, ToolbarExtendPropsMap extends TXphExtendComponentPropsMap = {}, FormExtendPropsMap extends TXphExtendComponentPropsMap = {}> = {
|
|
14
|
+
/**
|
|
15
|
+
* @description 表格配置
|
|
16
|
+
*/
|
|
21
17
|
table?: TApiTableProps<RecordType, CellFuncExtendPropsMap, ActionsExtendPropsMap, ToolbarExtendPropsMap>;
|
|
22
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* @description 搜索表单配置项
|
|
20
|
+
*/
|
|
23
21
|
searchForm?: TSearchFormProps<FormExtendPropsMap>;
|
|
24
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* @description (新增 / 修改)表单弹窗配置项
|
|
24
|
+
*/
|
|
25
25
|
crudFormDialog?: TCrudFormDialogProps<FormExtendPropsMap>;
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* @description 分页改变事件
|
|
28
|
+
*/
|
|
27
29
|
onPaginationChange?: (page: number, pageSize: number) => void;
|
|
28
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* @description 列表选中事件
|
|
32
|
+
*/
|
|
29
33
|
onRowSelectionChange?: (selectedRowKeys: React.Key[], selectedRows: RecordType[]) => void;
|
|
30
34
|
};
|
|
31
35
|
export type TTableActionType = TApiTableActionType & ICrudFormDialogActionType;
|
package/package.json
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "xph-crud",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/types/index.d.ts",
|
|
7
|
-
"description": "This is a configurable component library based on React",
|
|
8
|
-
"keywords": [
|
|
9
|
-
"react",
|
|
10
|
-
"ant-design",
|
|
11
|
-
"configurable-component"
|
|
12
|
-
],
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
},
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
},
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "xph-crud",
|
|
3
|
+
"version": "0.3.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/types/index.d.ts",
|
|
7
|
+
"description": "This is a configurable component library based on React",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"react",
|
|
10
|
+
"ant-design",
|
|
11
|
+
"configurable-component"
|
|
12
|
+
],
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"@ant-design/icons": "5.3.2",
|
|
19
|
+
"antd": "^5.14.2",
|
|
20
|
+
"react": "^18.2.0",
|
|
21
|
+
"react-dom": "^18.2.0",
|
|
22
|
+
"dayjs": "^1.11.13"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"lodash-es": "^4.17.21"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/lodash-es": "^4.17.12",
|
|
29
|
+
"@types/node": "^20.14.2",
|
|
30
|
+
"@types/react": "^18.2.66",
|
|
31
|
+
"@types/react-dom": "^18.2.22",
|
|
32
|
+
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
|
33
|
+
"@typescript-eslint/parser": "^7.2.0",
|
|
34
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
35
|
+
"eslint": "^8.57.0",
|
|
36
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
37
|
+
"eslint-plugin-react-refresh": "^0.4.6",
|
|
38
|
+
"typescript": "^5.2.2",
|
|
39
|
+
"vite": "^5.2.0",
|
|
40
|
+
"vite-plugin-dts": "^3.9.1"
|
|
41
|
+
},
|
|
42
|
+
"license": "ISC",
|
|
43
|
+
"author": "XiaoPiHong",
|
|
44
|
+
"homepage": "https://github.com/XiaoPiHong/xph-crud",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/XiaoPiHong/xph-crud/issues",
|
|
47
|
+
"email": "260094892@qq.com"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "https://github.com/XiaoPiHong/xph-crud.git"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=16"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"examples": "vite",
|
|
58
|
+
"build": "tsc && vite build",
|
|
59
|
+
"docs": "cd docs && npm run start",
|
|
60
|
+
"build:docs": "cd docs && npm run build",
|
|
61
|
+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { TActionItemProps } from './actionItem';
|
|
2
|
-
import { ButtonProps } from 'antd/lib/button';
|
|
3
|
-
import { TXphExtendComponentPropsMap } from '../../../types';
|
|
4
|
-
|
|
5
|
-
export interface IActionsProps<T extends TXphExtendComponentPropsMap = {}> {
|
|
6
|
-
/** 类型 */
|
|
7
|
-
type?: ButtonProps["type"];
|
|
8
|
-
/** 操作项 */
|
|
9
|
-
items?: TActionItemProps<T>[];
|
|
10
|
-
/** 禁用(items中的componentProps的disabled优先级最高) */
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
/** 自定义内容(items的优先级高于render) */
|
|
13
|
-
render?: React.ReactElement;
|
|
14
|
-
/** 超过多少个item自动省略,默认是10(其余全部放在一个dropdown中) */
|
|
15
|
-
max?: number;
|
|
16
|
-
/** 是否需要从扩展中继承属性(可能有些特殊情况,不需要使用扩展中的属性) */
|
|
17
|
-
inherit?: boolean;
|
|
18
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ButtonProps } from 'antd';
|
|
2
|
-
|
|
3
|
-
export interface IDialogProps {
|
|
4
|
-
width?: number;
|
|
5
|
-
height?: number;
|
|
6
|
-
mask?: boolean;
|
|
7
|
-
title?: string;
|
|
8
|
-
okProps?: Omit<ButtonProps, "children" | "onClick">;
|
|
9
|
-
cancelProps?: Omit<ButtonProps, "children" | "onClick">;
|
|
10
|
-
okText?: string;
|
|
11
|
-
cancelText?: string;
|
|
12
|
-
/** 点击确定按钮触发该事件 */
|
|
13
|
-
onOk?: (args: any) => Promise<void>;
|
|
14
|
-
/** 点击取消按钮触发该事件 */
|
|
15
|
-
onCancel?: (args: any) => Promise<void>;
|
|
16
|
-
renderFooter?: ({ loading }: {
|
|
17
|
-
loading: boolean;
|
|
18
|
-
}) => React.ReactElement;
|
|
19
|
-
renderTitle?: () => React.ReactElement;
|
|
20
|
-
/** 打开的时候会触发该事件 */
|
|
21
|
-
onOpen?: () => void;
|
|
22
|
-
/** 关闭的时候会触发该事件 */
|
|
23
|
-
onClose?: () => void;
|
|
24
|
-
/** 挂载弹窗的容器,默认是body */
|
|
25
|
-
getPopperContainer?: () => HTMLElement | null;
|
|
26
|
-
}
|
|
27
|
-
export interface IDialogActionType {
|
|
28
|
-
open: () => Promise<void>;
|
|
29
|
-
close: () => void;
|
|
30
|
-
setLoading: (loading: boolean) => void;
|
|
31
|
-
getVisible: () => boolean;
|
|
32
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/types/common/src/{componnets → components}/actions/hooks/useExtendActions.d.ts
RENAMED
|
File without changes
|
/package/dist/types/common/src/{componnets → components}/actions/hooks/useRenderContent.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/types/common/src/{componnets → components}/dialog/components/headerBtns/index.d.ts
RENAMED
|
File without changes
|
/package/dist/types/common/src/{componnets → components}/dialog/components/minimizeDialog/index.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/types/common/src/{componnets → components}/dialog/hooks/useDialogChangeRecord.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/types/common/src/{componnets → components}/dialog/hooks/useMinResizeRecord.d.ts
RENAMED
|
File without changes
|
/package/dist/types/common/src/{componnets → components}/dialog/hooks/useMinimizeDialog.d.ts
RENAMED
|
File without changes
|
/package/dist/types/common/src/{componnets → components}/dialog/hooks/useOnContainerSizeChange.d.ts
RENAMED
|
File without changes
|
/package/dist/types/common/src/{componnets → components}/dialog/hooks/useOnPropsSizeChange.d.ts
RENAMED
|
File without changes
|
/package/dist/types/common/src/{componnets → components}/dialog/hooks/usePopperContainerSize.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|