@refinedev/antd 5.32.0 → 5.33.0
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 +16 -0
- package/dist/components/buttons/refresh/index.d.ts +1 -1
- package/dist/components/buttons/refresh/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/hooks/form/useDrawerForm/useDrawerForm.d.ts.map +1 -1
- package/dist/hooks/form/useModalForm/useModalForm.d.ts.map +1 -1
- package/dist/hooks/form/useStepsForm/useStepsForm.d.ts +1 -1
- package/dist/hooks/form/useStepsForm/useStepsForm.d.ts.map +1 -1
- package/dist/iife/index.js +6 -14
- package/dist/iife/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/buttons/refresh/index.tsx +30 -19
- package/src/hooks/form/useDrawerForm/useDrawerForm.ts +21 -13
- package/src/hooks/form/useModalForm/useModalForm.ts +19 -13
- package/src/hooks/form/useStepsForm/useStepsForm.ts +1 -1
- package/src/types/sunflower.d.ts +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@refinedev/antd",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.33.0",
|
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
|
"sideEffects": [
|
@@ -26,9 +26,9 @@
|
|
26
26
|
"react-dom": "^17.0.0 || ^18.0.0"
|
27
27
|
},
|
28
28
|
"devDependencies": {
|
29
|
-
"@refinedev/cli": "^2.7.
|
30
|
-
"@refinedev/ui-tests": "^1.
|
31
|
-
"@refinedev/core": "^4.
|
29
|
+
"@refinedev/cli": "^2.7.5",
|
30
|
+
"@refinedev/ui-tests": "^1.12.0",
|
31
|
+
"@refinedev/core": "^4.33.0",
|
32
32
|
"@esbuild-plugins/node-resolve": "^0.1.4",
|
33
33
|
"@testing-library/jest-dom": "^5.16.4",
|
34
34
|
"@testing-library/react": "^13.1.1",
|
@@ -52,7 +52,7 @@
|
|
52
52
|
"dependencies": {
|
53
53
|
"@ant-design/icons": "5.0.1",
|
54
54
|
"@ant-design/pro-layout": "7.8.3",
|
55
|
-
"@refinedev/ui-types": "^1.
|
55
|
+
"@refinedev/ui-types": "^1.21.0",
|
56
56
|
"@tanstack/react-query": "^4.10.1",
|
57
57
|
"antd": "^5.0.5",
|
58
58
|
"dayjs": "^1.10.7",
|
@@ -2,10 +2,11 @@ import React from "react";
|
|
2
2
|
import { Button } from "antd";
|
3
3
|
import { RedoOutlined } from "@ant-design/icons";
|
4
4
|
import {
|
5
|
-
useOne,
|
6
5
|
useTranslate,
|
7
6
|
useResource,
|
8
|
-
|
7
|
+
useInvalidate,
|
8
|
+
queryKeys,
|
9
|
+
pickDataProvider,
|
9
10
|
} from "@refinedev/core";
|
10
11
|
import {
|
11
12
|
RefineButtonClassNames,
|
@@ -14,9 +15,11 @@ import {
|
|
14
15
|
|
15
16
|
import { RefreshButtonProps } from "../types";
|
16
17
|
|
18
|
+
import { useQueryClient } from "@tanstack/react-query";
|
19
|
+
|
17
20
|
/**
|
18
21
|
* `<RefreshButton>` uses Ant Design's {@link https://ant.design/components/button/ `<Button>`} component
|
19
|
-
* to update the data shown on the page via the {@link https://refine.dev/docs/api-reference/core/hooks/
|
22
|
+
* to update the data shown on the page via the {@link https://refine.dev/docs/api-reference/core/hooks/invalidate/useInvalidate `useInvalidate`} hook.
|
20
23
|
*
|
21
24
|
* @see {@link https://refine.dev/docs/api-reference/antd/components/buttons/refresh-button} for more details.
|
22
25
|
*/
|
@@ -25,36 +28,44 @@ export const RefreshButton: React.FC<RefreshButtonProps> = ({
|
|
25
28
|
resourceNameOrRouteName: propResourceNameOrRouteName,
|
26
29
|
recordItemId,
|
27
30
|
hideText = false,
|
28
|
-
meta,
|
29
|
-
metaData,
|
30
31
|
dataProviderName,
|
31
32
|
children,
|
32
33
|
onClick,
|
34
|
+
meta: _meta,
|
35
|
+
metaData: _metaData,
|
33
36
|
...rest
|
34
37
|
}) => {
|
35
38
|
const translate = useTranslate();
|
36
39
|
|
37
|
-
const
|
40
|
+
const queryClient = useQueryClient();
|
41
|
+
const invalidates = useInvalidate();
|
42
|
+
|
43
|
+
const { resources, identifier, id } = useResource(
|
38
44
|
resourceNameFromProps ?? propResourceNameOrRouteName,
|
39
45
|
);
|
40
46
|
|
41
|
-
const
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
},
|
47
|
-
meta: pickNotDeprecated(meta, metaData),
|
48
|
-
metaData: pickNotDeprecated(meta, metaData),
|
49
|
-
liveMode: "off",
|
50
|
-
dataProviderName,
|
47
|
+
const isInvalidating = !!queryClient.isFetching({
|
48
|
+
queryKey: queryKeys(
|
49
|
+
identifier,
|
50
|
+
pickDataProvider(identifier, dataProviderName, resources),
|
51
|
+
).detail(recordItemId ?? id),
|
51
52
|
});
|
52
53
|
|
54
|
+
const handleInvalidate = () => {
|
55
|
+
invalidates({
|
56
|
+
id: recordItemId ?? id,
|
57
|
+
invalidates: ["detail"],
|
58
|
+
dataProviderName,
|
59
|
+
resource: identifier,
|
60
|
+
});
|
61
|
+
};
|
62
|
+
|
53
63
|
return (
|
54
64
|
<Button
|
55
|
-
|
56
|
-
|
57
|
-
|
65
|
+
onClick={(e) => {
|
66
|
+
onClick ? onClick(e) : handleInvalidate();
|
67
|
+
}}
|
68
|
+
icon={<RedoOutlined spin={isInvalidating} />}
|
58
69
|
data-testid={RefineButtonTestIds.RefreshButton}
|
59
70
|
className={RefineButtonClassNames.RefreshButton}
|
60
71
|
{...rest}
|
@@ -120,23 +120,12 @@ export const useDrawerForm = <
|
|
120
120
|
TResponse,
|
121
121
|
TResponseError
|
122
122
|
> => {
|
123
|
+
const [initiallySynced, setInitiallySynced] = React.useState(false);
|
124
|
+
|
123
125
|
const { visible, show, close } = useModal({
|
124
126
|
defaultVisible,
|
125
127
|
});
|
126
128
|
|
127
|
-
const useFormProps = useForm<
|
128
|
-
TQueryFnData,
|
129
|
-
TError,
|
130
|
-
TVariables,
|
131
|
-
TData,
|
132
|
-
TResponse,
|
133
|
-
TResponseError
|
134
|
-
>({
|
135
|
-
...rest,
|
136
|
-
});
|
137
|
-
const [initiallySynced, setInitiallySynced] = React.useState(false);
|
138
|
-
const { form, formProps, formLoading, id, setId, onFinish } = useFormProps;
|
139
|
-
|
140
129
|
const { resource, action: actionFromParams } = useResource(rest.resource);
|
141
130
|
|
142
131
|
const parsed = useParsed();
|
@@ -156,6 +145,25 @@ export const useDrawerForm = <
|
|
156
145
|
? `drawer-${resource?.identifier ?? resource?.name}-${action}`
|
157
146
|
: undefined;
|
158
147
|
|
148
|
+
const useFormProps = useForm<
|
149
|
+
TQueryFnData,
|
150
|
+
TError,
|
151
|
+
TVariables,
|
152
|
+
TData,
|
153
|
+
TResponse,
|
154
|
+
TResponseError
|
155
|
+
>({
|
156
|
+
meta: {
|
157
|
+
...(syncWithLocationKey
|
158
|
+
? { [syncWithLocationKey]: undefined }
|
159
|
+
: {}),
|
160
|
+
...rest.meta,
|
161
|
+
},
|
162
|
+
...rest,
|
163
|
+
});
|
164
|
+
|
165
|
+
const { form, formProps, formLoading, id, setId, onFinish } = useFormProps;
|
166
|
+
|
159
167
|
React.useEffect(() => {
|
160
168
|
if (initiallySynced === false && syncWithLocationKey) {
|
161
169
|
const openStatus = parsed?.params?.[syncWithLocationKey]?.open;
|
@@ -130,19 +130,6 @@ export const useModalForm = <
|
|
130
130
|
> => {
|
131
131
|
const [initiallySynced, setInitiallySynced] = React.useState(false);
|
132
132
|
|
133
|
-
const useFormProps = useForm<
|
134
|
-
TQueryFnData,
|
135
|
-
TError,
|
136
|
-
TVariables,
|
137
|
-
TData,
|
138
|
-
TResponse,
|
139
|
-
TResponseError
|
140
|
-
>({
|
141
|
-
...rest,
|
142
|
-
});
|
143
|
-
|
144
|
-
const { form, formProps, id, setId, formLoading, onFinish } = useFormProps;
|
145
|
-
|
146
133
|
const {
|
147
134
|
resource,
|
148
135
|
action: actionFromParams,
|
@@ -167,6 +154,25 @@ export const useModalForm = <
|
|
167
154
|
? `modal-${identifier}-${action}`
|
168
155
|
: undefined;
|
169
156
|
|
157
|
+
const useFormProps = useForm<
|
158
|
+
TQueryFnData,
|
159
|
+
TError,
|
160
|
+
TVariables,
|
161
|
+
TData,
|
162
|
+
TResponse,
|
163
|
+
TResponseError
|
164
|
+
>({
|
165
|
+
meta: {
|
166
|
+
...(syncWithLocationKey
|
167
|
+
? { [syncWithLocationKey]: undefined }
|
168
|
+
: {}),
|
169
|
+
...rest.meta,
|
170
|
+
},
|
171
|
+
...rest,
|
172
|
+
});
|
173
|
+
|
174
|
+
const { form, formProps, id, setId, formLoading, onFinish } = useFormProps;
|
175
|
+
|
170
176
|
const translate = useTranslate();
|
171
177
|
|
172
178
|
const { warnWhen, setWarnWhen } = useWarnAboutChange();
|
@@ -14,7 +14,7 @@ import { useForm, UseFormProps, UseFormReturnType } from "../useForm";
|
|
14
14
|
|
15
15
|
export type UseStepsFormFromSFReturnType<TResponse, TVariables> = {
|
16
16
|
current: number;
|
17
|
-
gotoStep: (step: number) =>
|
17
|
+
gotoStep: (step: number) => Promise<TVariables> | true;
|
18
18
|
stepsProps: {
|
19
19
|
current: number;
|
20
20
|
onChange: (currentStep: number) => void;
|
package/src/types/sunflower.d.ts
CHANGED
@@ -11,7 +11,7 @@ declare module "sunflower-antd" {
|
|
11
11
|
config: UseStepsFormConfig,
|
12
12
|
) => {
|
13
13
|
current: number;
|
14
|
-
gotoStep: (step: number) =>
|
14
|
+
gotoStep: (step: number) => Promise<TVariables> | true;
|
15
15
|
stepsProps: {
|
16
16
|
current: number;
|
17
17
|
onChange: (currentStep: number) => void;
|