@refinedev/antd 5.13.0 → 5.13.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/CHANGELOG.md +12 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/hooks/form/useDrawerForm/useDrawerForm.d.ts +3 -3
- package/dist/hooks/form/useDrawerForm/useDrawerForm.d.ts.map +1 -1
- package/dist/hooks/form/useForm.d.ts +7 -4
- package/dist/hooks/form/useForm.d.ts.map +1 -1
- package/dist/hooks/form/useModalForm/useModalForm.d.ts +5 -5
- package/dist/hooks/form/useModalForm/useModalForm.d.ts.map +1 -1
- package/dist/hooks/form/useStepsForm/useStepsForm.d.ts +5 -5
- package/dist/hooks/form/useStepsForm/useStepsForm.d.ts.map +1 -1
- package/dist/iife/index.js +6 -6
- package/dist/iife/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/hooks/form/useDrawerForm/useDrawerForm.ts +55 -12
- package/src/hooks/form/useForm.ts +48 -14
- package/src/hooks/form/useModalForm/useModalForm.ts +59 -16
- package/src/hooks/form/useStepsForm/useStepsForm.ts +64 -16
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@refinedev/antd",
|
3
|
-
"version": "5.13.
|
3
|
+
"version": "5.13.2",
|
4
4
|
"description": "refine is a React-based framework for building internal tools, rapidly. It ships with Ant Design System, an enterprise-level UI toolkit.",
|
5
5
|
"private": false,
|
6
6
|
"main": "dist/index.js",
|
@@ -25,7 +25,7 @@
|
|
25
25
|
"devDependencies": {
|
26
26
|
"@refinedev/cli": "^2.5.3",
|
27
27
|
"@refinedev/ui-tests": "^1.3.2",
|
28
|
-
"@refinedev/core": "^4.
|
28
|
+
"@refinedev/core": "^4.14.0",
|
29
29
|
"@esbuild-plugins/node-resolve": "^0.1.4",
|
30
30
|
"@testing-library/jest-dom": "^5.16.4",
|
31
31
|
"@testing-library/react": "^13.1.1",
|
@@ -24,12 +24,28 @@ export interface UseDrawerFormConfig extends UseFormConfig {
|
|
24
24
|
}
|
25
25
|
|
26
26
|
export type UseDrawerFormProps<
|
27
|
-
|
27
|
+
TQueryFnData extends BaseRecord = BaseRecord,
|
28
28
|
TError extends HttpError = HttpError,
|
29
29
|
TVariables = {},
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
TData extends BaseRecord = TQueryFnData,
|
31
|
+
TResponse extends BaseRecord = TData,
|
32
|
+
TResponseError extends HttpError = TError,
|
33
|
+
> = UseFormPropsCore<
|
34
|
+
TQueryFnData,
|
35
|
+
TError,
|
36
|
+
TVariables,
|
37
|
+
TData,
|
38
|
+
TResponse,
|
39
|
+
TResponseError
|
40
|
+
> &
|
41
|
+
UseFormProps<
|
42
|
+
TQueryFnData,
|
43
|
+
TError,
|
44
|
+
TVariables,
|
45
|
+
TData,
|
46
|
+
TResponse,
|
47
|
+
TResponseError
|
48
|
+
> &
|
33
49
|
UseDrawerFormConfig &
|
34
50
|
LiveModeProps &
|
35
51
|
FormWithSyncWithLocationParams & {
|
@@ -39,11 +55,20 @@ export type UseDrawerFormProps<
|
|
39
55
|
};
|
40
56
|
|
41
57
|
export type UseDrawerFormReturnType<
|
42
|
-
|
58
|
+
TQueryFnData extends BaseRecord = BaseRecord,
|
43
59
|
TError extends HttpError = HttpError,
|
44
60
|
TVariables = {},
|
45
|
-
|
46
|
-
|
61
|
+
TData extends BaseRecord = TQueryFnData,
|
62
|
+
TResponse extends BaseRecord = TData,
|
63
|
+
TResponseError extends HttpError = TError,
|
64
|
+
> = UseFormReturnType<
|
65
|
+
TQueryFnData,
|
66
|
+
TError,
|
67
|
+
TVariables,
|
68
|
+
TData,
|
69
|
+
TResponse,
|
70
|
+
TResponseError
|
71
|
+
> & {
|
47
72
|
formProps: FormProps<TVariables> & {
|
48
73
|
form: FormInstance<TVariables>;
|
49
74
|
};
|
@@ -68,10 +93,12 @@ export type UseDrawerFormReturnType<
|
|
68
93
|
*/
|
69
94
|
|
70
95
|
export const useDrawerForm = <
|
71
|
-
|
96
|
+
TQueryFnData extends BaseRecord = BaseRecord,
|
72
97
|
TError extends HttpError = HttpError,
|
73
98
|
TVariables = {},
|
74
|
-
|
99
|
+
TData extends BaseRecord = TQueryFnData,
|
100
|
+
TResponse extends BaseRecord = TData,
|
101
|
+
TResponseError extends HttpError = TError,
|
75
102
|
>({
|
76
103
|
syncWithLocation,
|
77
104
|
defaultVisible = false,
|
@@ -79,18 +106,34 @@ export const useDrawerForm = <
|
|
79
106
|
autoResetForm = true,
|
80
107
|
...rest
|
81
108
|
}: UseDrawerFormProps<
|
109
|
+
TQueryFnData,
|
110
|
+
TError,
|
111
|
+
TVariables,
|
82
112
|
TData,
|
113
|
+
TResponse,
|
114
|
+
TResponseError
|
115
|
+
>): UseDrawerFormReturnType<
|
116
|
+
TQueryFnData,
|
83
117
|
TError,
|
84
118
|
TVariables,
|
85
|
-
|
86
|
-
|
119
|
+
TData,
|
120
|
+
TResponse,
|
121
|
+
TResponseError
|
122
|
+
> => {
|
87
123
|
const initiallySynced = React.useRef(false);
|
88
124
|
|
89
125
|
const { visible, show, close } = useModal({
|
90
126
|
defaultVisible,
|
91
127
|
});
|
92
128
|
|
93
|
-
const useFormProps = useForm<
|
129
|
+
const useFormProps = useForm<
|
130
|
+
TQueryFnData,
|
131
|
+
TError,
|
132
|
+
TVariables,
|
133
|
+
TData,
|
134
|
+
TResponse,
|
135
|
+
TResponseError
|
136
|
+
>({
|
94
137
|
...rest,
|
95
138
|
});
|
96
139
|
|
@@ -16,11 +16,20 @@ import {
|
|
16
16
|
} from "@refinedev/core";
|
17
17
|
|
18
18
|
export type UseFormProps<
|
19
|
-
|
19
|
+
TQueryFnData extends BaseRecord = BaseRecord,
|
20
20
|
TError extends HttpError = HttpError,
|
21
21
|
TVariables = {},
|
22
|
-
|
23
|
-
|
22
|
+
TData extends BaseRecord = TQueryFnData,
|
23
|
+
TResponse extends BaseRecord = TData,
|
24
|
+
TResponseError extends HttpError = TError,
|
25
|
+
> = UseFormPropsCore<
|
26
|
+
TQueryFnData,
|
27
|
+
TError,
|
28
|
+
TVariables,
|
29
|
+
TData,
|
30
|
+
TResponse,
|
31
|
+
TResponseError
|
32
|
+
> & {
|
24
33
|
submitOnEnter?: boolean;
|
25
34
|
/**
|
26
35
|
* Shows notification when unsaved changes exist
|
@@ -29,11 +38,20 @@ export type UseFormProps<
|
|
29
38
|
};
|
30
39
|
|
31
40
|
export type UseFormReturnType<
|
32
|
-
|
41
|
+
TQueryFnData extends BaseRecord = BaseRecord,
|
33
42
|
TError extends HttpError = HttpError,
|
34
43
|
TVariables = {},
|
35
|
-
|
36
|
-
|
44
|
+
TData extends BaseRecord = TQueryFnData,
|
45
|
+
TResponse extends BaseRecord = TData,
|
46
|
+
TResponseError extends HttpError = TError,
|
47
|
+
> = UseFormReturnTypeCore<
|
48
|
+
TQueryFnData,
|
49
|
+
TError,
|
50
|
+
TVariables,
|
51
|
+
TData,
|
52
|
+
TResponse,
|
53
|
+
TResponseError
|
54
|
+
> & {
|
37
55
|
form: FormInstance<TVariables>;
|
38
56
|
formProps: FormProps<TVariables>;
|
39
57
|
saveButtonProps: ButtonProps & {
|
@@ -41,7 +59,7 @@ export type UseFormReturnType<
|
|
41
59
|
};
|
42
60
|
onFinish: (
|
43
61
|
values?: TVariables,
|
44
|
-
) => Promise<CreateResponse<
|
62
|
+
) => Promise<CreateResponse<TResponse> | UpdateResponse<TResponse> | void>;
|
45
63
|
};
|
46
64
|
|
47
65
|
/**
|
@@ -52,14 +70,19 @@ export type UseFormReturnType<
|
|
52
70
|
* @typeParam TData - Result data of the query extends {@link https://refine.dev/docs/api-references/interfaceReferences#baserecord `BaseRecord`}
|
53
71
|
* @typeParam TError - Custom error object that extends {@link https://refine.dev/docs/api-references/interfaceReferences#httperror `HttpError`}
|
54
72
|
* @typeParam TVariables - Values for params. default `{}`
|
73
|
+
* @typeParam TData - Result data returned by the `select` function. Extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#baserecord `BaseRecord`}. Defaults to `TQueryFnData`
|
74
|
+
* @typeParam TResponse - Result data returned by the mutation function. Extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#baserecord `BaseRecord`}. Defaults to `TData`
|
75
|
+
* @typeParam TResponseError - Custom error object that extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#httperror `HttpError`}. Defaults to `TError`
|
55
76
|
*
|
56
77
|
*
|
57
78
|
*/
|
58
79
|
export const useForm = <
|
59
|
-
|
80
|
+
TQueryFnData extends BaseRecord = BaseRecord,
|
60
81
|
TError extends HttpError = HttpError,
|
61
82
|
TVariables = {},
|
62
|
-
|
83
|
+
TData extends BaseRecord = TQueryFnData,
|
84
|
+
TResponse extends BaseRecord = TData,
|
85
|
+
TResponseError extends HttpError = TError,
|
63
86
|
>({
|
64
87
|
action,
|
65
88
|
resource,
|
@@ -84,22 +107,33 @@ export const useForm = <
|
|
84
107
|
updateMutationOptions,
|
85
108
|
id: idFromProps,
|
86
109
|
}: UseFormProps<
|
110
|
+
TQueryFnData,
|
111
|
+
TError,
|
112
|
+
TVariables,
|
87
113
|
TData,
|
114
|
+
TResponse,
|
115
|
+
TResponseError
|
116
|
+
> = {}): UseFormReturnType<
|
117
|
+
TQueryFnData,
|
88
118
|
TError,
|
89
119
|
TVariables,
|
90
|
-
|
91
|
-
|
120
|
+
TData,
|
121
|
+
TResponse,
|
122
|
+
TResponseError
|
123
|
+
> => {
|
92
124
|
const [formAnt] = Form.useForm();
|
93
|
-
const formSF = useFormSF<
|
125
|
+
const formSF = useFormSF<TResponse, TVariables>({
|
94
126
|
form: formAnt,
|
95
127
|
});
|
96
128
|
const { form } = formSF;
|
97
129
|
|
98
130
|
const useFormCoreResult = useFormCore<
|
99
|
-
|
131
|
+
TQueryFnData,
|
100
132
|
TError,
|
101
133
|
TVariables,
|
102
|
-
|
134
|
+
TData,
|
135
|
+
TResponse,
|
136
|
+
TResponseError
|
103
137
|
>({
|
104
138
|
onMutationSuccess: onMutationSuccessProp
|
105
139
|
? onMutationSuccessProp
|
@@ -21,7 +21,7 @@ import {
|
|
21
21
|
} from "@refinedev/core";
|
22
22
|
import { useForm, UseFormProps, UseFormReturnType } from "../useForm";
|
23
23
|
|
24
|
-
export type useModalFormFromSFReturnType<
|
24
|
+
export type useModalFormFromSFReturnType<TResponse, TVariables> = {
|
25
25
|
open: boolean;
|
26
26
|
form: FormInstance<TVariables>;
|
27
27
|
show: (id?: BaseKey) => void;
|
@@ -33,7 +33,7 @@ export type useModalFormFromSFReturnType<TData, TVariables> = {
|
|
33
33
|
formValues: {};
|
34
34
|
initialValues: {};
|
35
35
|
formResult: undefined;
|
36
|
-
submit: (values?: TVariables) => Promise<
|
36
|
+
submit: (values?: TVariables) => Promise<TResponse>;
|
37
37
|
/** @deprecated Please use `open` instead. */
|
38
38
|
visible: boolean;
|
39
39
|
};
|
@@ -43,23 +43,48 @@ type useModalFormConfig = {
|
|
43
43
|
};
|
44
44
|
|
45
45
|
export type UseModalFormReturnType<
|
46
|
-
|
46
|
+
TQueryFnData extends BaseRecord = BaseRecord,
|
47
47
|
TError extends HttpError = HttpError,
|
48
48
|
TVariables = {},
|
49
|
-
|
49
|
+
TData extends BaseRecord = TQueryFnData,
|
50
|
+
TResponse extends BaseRecord = TData,
|
51
|
+
TResponseError extends HttpError = TError,
|
50
52
|
> = Omit<
|
51
|
-
UseFormReturnType<
|
53
|
+
UseFormReturnType<
|
54
|
+
TQueryFnData,
|
55
|
+
TError,
|
56
|
+
TVariables,
|
57
|
+
TData,
|
58
|
+
TResponse,
|
59
|
+
TResponseError
|
60
|
+
>,
|
52
61
|
"saveButtonProps" | "deleteButtonProps"
|
53
62
|
> &
|
54
|
-
useModalFormFromSFReturnType<
|
63
|
+
useModalFormFromSFReturnType<TResponse, TVariables>;
|
55
64
|
|
56
65
|
export type UseModalFormProps<
|
57
|
-
|
66
|
+
TQueryFnData extends BaseRecord = BaseRecord,
|
58
67
|
TError extends HttpError = HttpError,
|
59
68
|
TVariables = {},
|
60
|
-
|
61
|
-
|
62
|
-
|
69
|
+
TData extends BaseRecord = TQueryFnData,
|
70
|
+
TResponse extends BaseRecord = TData,
|
71
|
+
TResponseError extends HttpError = TError,
|
72
|
+
> = UseFormPropsCore<
|
73
|
+
TQueryFnData,
|
74
|
+
TError,
|
75
|
+
TVariables,
|
76
|
+
TData,
|
77
|
+
TResponse,
|
78
|
+
TResponseError
|
79
|
+
> &
|
80
|
+
UseFormProps<
|
81
|
+
TQueryFnData,
|
82
|
+
TError,
|
83
|
+
TVariables,
|
84
|
+
TData,
|
85
|
+
TResponse,
|
86
|
+
TResponseError
|
87
|
+
> &
|
63
88
|
UseModalFormConfigSF &
|
64
89
|
useModalFormConfig &
|
65
90
|
LiveModeProps &
|
@@ -76,22 +101,40 @@ export type UseModalFormProps<
|
|
76
101
|
*
|
77
102
|
*/
|
78
103
|
export const useModalForm = <
|
79
|
-
|
104
|
+
TQueryFnData extends BaseRecord = BaseRecord,
|
80
105
|
TError extends HttpError = HttpError,
|
81
106
|
TVariables = {},
|
82
|
-
|
107
|
+
TData extends BaseRecord = TQueryFnData,
|
108
|
+
TResponse extends BaseRecord = TData,
|
109
|
+
TResponseError extends HttpError = TError,
|
83
110
|
>({
|
84
111
|
syncWithLocation,
|
85
112
|
...rest
|
86
113
|
}: UseModalFormProps<
|
114
|
+
TQueryFnData,
|
115
|
+
TError,
|
116
|
+
TVariables,
|
87
117
|
TData,
|
118
|
+
TResponse,
|
119
|
+
TResponseError
|
120
|
+
>): UseModalFormReturnType<
|
121
|
+
TQueryFnData,
|
88
122
|
TError,
|
89
123
|
TVariables,
|
90
|
-
|
91
|
-
|
124
|
+
TData,
|
125
|
+
TResponse,
|
126
|
+
TResponseError
|
127
|
+
> => {
|
92
128
|
const initiallySynced = React.useRef(false);
|
93
129
|
|
94
|
-
const useFormProps = useForm<
|
130
|
+
const useFormProps = useForm<
|
131
|
+
TQueryFnData,
|
132
|
+
TError,
|
133
|
+
TVariables,
|
134
|
+
TData,
|
135
|
+
TResponse,
|
136
|
+
TResponseError
|
137
|
+
>({
|
95
138
|
...rest,
|
96
139
|
});
|
97
140
|
|
@@ -118,7 +161,7 @@ export const useModalForm = <
|
|
118
161
|
|
119
162
|
const { warnWhen, setWarnWhen } = useWarnAboutChange();
|
120
163
|
|
121
|
-
const sunflowerUseModal = useModalFormSF<
|
164
|
+
const sunflowerUseModal = useModalFormSF<TResponse, TVariables>({
|
122
165
|
...rest,
|
123
166
|
form: form,
|
124
167
|
submit: onFinish as any,
|
@@ -12,7 +12,7 @@ import {
|
|
12
12
|
|
13
13
|
import { useForm, UseFormProps, UseFormReturnType } from "../useForm";
|
14
14
|
|
15
|
-
export type UseStepsFormFromSFReturnType<
|
15
|
+
export type UseStepsFormFromSFReturnType<TResponse, TVariables> = {
|
16
16
|
current: number;
|
17
17
|
gotoStep: (step: number) => void;
|
18
18
|
stepsProps: {
|
@@ -26,24 +26,49 @@ export type UseStepsFormFromSFReturnType<TData, TVariables> = {
|
|
26
26
|
initialValues: {};
|
27
27
|
formResult: undefined;
|
28
28
|
form: FormInstance<TVariables>;
|
29
|
-
submit: (values?: TVariables) => Promise<
|
29
|
+
submit: (values?: TVariables) => Promise<TResponse>;
|
30
30
|
};
|
31
31
|
|
32
32
|
export type UseStepsFormReturnType<
|
33
|
-
|
33
|
+
TQueryFnData extends BaseRecord = BaseRecord,
|
34
34
|
TError extends HttpError = HttpError,
|
35
35
|
TVariables = {},
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
TData extends BaseRecord = TQueryFnData,
|
37
|
+
TResponse extends BaseRecord = TData,
|
38
|
+
TResponseError extends HttpError = TError,
|
39
|
+
> = UseFormReturnType<
|
40
|
+
TQueryFnData,
|
41
|
+
TError,
|
42
|
+
TVariables,
|
43
|
+
TData,
|
44
|
+
TResponse,
|
45
|
+
TResponseError
|
46
|
+
> &
|
47
|
+
UseStepsFormFromSFReturnType<TResponse, TVariables>;
|
39
48
|
|
40
49
|
export type UseStepsFormProps<
|
41
|
-
|
50
|
+
TQueryFnData extends BaseRecord = BaseRecord,
|
42
51
|
TError extends HttpError = HttpError,
|
43
52
|
TVariables = {},
|
44
|
-
|
45
|
-
|
46
|
-
|
53
|
+
TData extends BaseRecord = TQueryFnData,
|
54
|
+
TResponse extends BaseRecord = TData,
|
55
|
+
TResponseError extends HttpError = TError,
|
56
|
+
> = UseFormPropsCore<
|
57
|
+
TQueryFnData,
|
58
|
+
TError,
|
59
|
+
TVariables,
|
60
|
+
TData,
|
61
|
+
TResponse,
|
62
|
+
TResponseError
|
63
|
+
> &
|
64
|
+
UseFormProps<
|
65
|
+
TQueryFnData,
|
66
|
+
TError,
|
67
|
+
TVariables,
|
68
|
+
TData,
|
69
|
+
TResponse,
|
70
|
+
TResponseError
|
71
|
+
> &
|
47
72
|
UseStepsFormConfig;
|
48
73
|
|
49
74
|
/**
|
@@ -58,19 +83,42 @@ export type UseStepsFormProps<
|
|
58
83
|
*
|
59
84
|
*/
|
60
85
|
export const useStepsForm = <
|
61
|
-
|
86
|
+
TQueryFnData extends BaseRecord = BaseRecord,
|
62
87
|
TError extends HttpError = HttpError,
|
63
88
|
TVariables = {},
|
64
|
-
|
89
|
+
TData extends BaseRecord = TQueryFnData,
|
90
|
+
TResponse extends BaseRecord = TData,
|
91
|
+
TResponseError extends HttpError = TError,
|
65
92
|
>(
|
66
|
-
props: UseStepsFormProps<
|
67
|
-
|
68
|
-
|
93
|
+
props: UseStepsFormProps<
|
94
|
+
TQueryFnData,
|
95
|
+
TError,
|
96
|
+
TVariables,
|
97
|
+
TData,
|
98
|
+
TResponse,
|
99
|
+
TResponseError
|
100
|
+
> = {},
|
101
|
+
): UseStepsFormReturnType<
|
102
|
+
TQueryFnData,
|
103
|
+
TError,
|
104
|
+
TVariables,
|
105
|
+
TData,
|
106
|
+
TResponse,
|
107
|
+
TResponseError
|
108
|
+
> => {
|
109
|
+
const useFormProps = useForm<
|
110
|
+
TQueryFnData,
|
111
|
+
TError,
|
112
|
+
TVariables,
|
113
|
+
TData,
|
114
|
+
TResponse,
|
115
|
+
TResponseError
|
116
|
+
>({
|
69
117
|
...props,
|
70
118
|
});
|
71
119
|
const { form, formProps } = useFormProps;
|
72
120
|
|
73
|
-
const stepsPropsSunflower = useStepsFormSF<
|
121
|
+
const stepsPropsSunflower = useStepsFormSF<TResponse, TVariables>({
|
74
122
|
isBackValidate: false,
|
75
123
|
form: form,
|
76
124
|
submit: (values: any) => {
|