@refinedev/antd 5.34.2 → 5.36.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 +84 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/hooks/form/useDrawerForm/useDrawerForm.d.ts +1 -1
- package/dist/hooks/form/useDrawerForm/useDrawerForm.d.ts.map +1 -1
- package/dist/hooks/form/useForm.d.ts +1 -1
- package/dist/hooks/form/useForm.d.ts.map +1 -1
- package/dist/hooks/form/useModalForm/useModalForm.d.ts +1 -1
- package/dist/hooks/form/useModalForm/useModalForm.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 +3 -3
- package/src/hooks/form/useDrawerForm/useDrawerForm.ts +22 -2
- package/src/hooks/form/useForm.ts +3 -0
- package/src/hooks/form/useModalForm/useModalForm.ts +18 -2
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@refinedev/antd",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.36.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.
|
29
|
+
"@refinedev/cli": "^2.11.0",
|
30
30
|
"@refinedev/ui-tests": "^1.13.0",
|
31
|
-
"@refinedev/core": "^4.
|
31
|
+
"@refinedev/core": "^4.40.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",
|
@@ -14,6 +14,7 @@ import {
|
|
14
14
|
useParsed,
|
15
15
|
useGo,
|
16
16
|
useModal,
|
17
|
+
useInvalidate,
|
17
18
|
} from "@refinedev/core";
|
18
19
|
|
19
20
|
import { useForm, UseFormProps, UseFormReturnType } from "../useForm";
|
@@ -104,6 +105,8 @@ export const useDrawerForm = <
|
|
104
105
|
defaultVisible = false,
|
105
106
|
autoSubmitClose = true,
|
106
107
|
autoResetForm = true,
|
108
|
+
autoSave,
|
109
|
+
invalidates,
|
107
110
|
...rest
|
108
111
|
}: UseDrawerFormProps<
|
109
112
|
TQueryFnData,
|
@@ -120,13 +123,18 @@ export const useDrawerForm = <
|
|
120
123
|
TResponse,
|
121
124
|
TResponseError
|
122
125
|
> => {
|
126
|
+
const invalidate = useInvalidate();
|
123
127
|
const [initiallySynced, setInitiallySynced] = React.useState(false);
|
124
128
|
|
125
129
|
const { visible, show, close } = useModal({
|
126
130
|
defaultVisible,
|
127
131
|
});
|
128
132
|
|
129
|
-
const {
|
133
|
+
const {
|
134
|
+
resource,
|
135
|
+
action: actionFromParams,
|
136
|
+
identifier,
|
137
|
+
} = useResource(rest.resource);
|
130
138
|
|
131
139
|
const parsed = useParsed();
|
132
140
|
const go = useGo();
|
@@ -159,10 +167,13 @@ export const useDrawerForm = <
|
|
159
167
|
: {}),
|
160
168
|
...rest.meta,
|
161
169
|
},
|
170
|
+
autoSave,
|
171
|
+
invalidates,
|
162
172
|
...rest,
|
163
173
|
});
|
164
174
|
|
165
|
-
const { form, formProps, formLoading, id, setId, onFinish } =
|
175
|
+
const { form, formProps, formLoading, id, setId, onFinish, autoSaveProps } =
|
176
|
+
useFormProps;
|
166
177
|
|
167
178
|
React.useEffect(() => {
|
168
179
|
if (initiallySynced === false && syncWithLocationKey) {
|
@@ -241,6 +252,15 @@ export const useDrawerForm = <
|
|
241
252
|
};
|
242
253
|
|
243
254
|
const handleClose = useCallback(() => {
|
255
|
+
if (autoSaveProps.status === "success" && autoSave?.invalidateOnClose) {
|
256
|
+
invalidate({
|
257
|
+
id,
|
258
|
+
invalidates: invalidates || ["list", "many", "detail"],
|
259
|
+
dataProviderName: rest.dataProviderName,
|
260
|
+
resource: identifier,
|
261
|
+
});
|
262
|
+
}
|
263
|
+
|
244
264
|
if (warnWhen) {
|
245
265
|
const warnWhenConfirm = window.confirm(
|
246
266
|
translate(
|
@@ -118,6 +118,7 @@ export const useForm = <
|
|
118
118
|
updateMutationOptions,
|
119
119
|
id: idFromProps,
|
120
120
|
overtimeOptions,
|
121
|
+
optimisticUpdateMap,
|
121
122
|
disableServerSideValidation: disableServerSideValidationProp = false,
|
122
123
|
}: UseFormProps<
|
123
124
|
TQueryFnData,
|
@@ -249,6 +250,8 @@ export const useForm = <
|
|
249
250
|
updateMutationOptions,
|
250
251
|
id: idFromProps,
|
251
252
|
overtimeOptions,
|
253
|
+
optimisticUpdateMap,
|
254
|
+
autoSave,
|
252
255
|
});
|
253
256
|
|
254
257
|
const { formLoading, onFinish, queryResult, id, onFinishAutoSave } =
|
@@ -14,6 +14,7 @@ import {
|
|
14
14
|
FormWithSyncWithLocationParams,
|
15
15
|
useParsed,
|
16
16
|
useGo,
|
17
|
+
useInvalidate,
|
17
18
|
} from "@refinedev/core";
|
18
19
|
import { useForm, UseFormProps, UseFormReturnType } from "../useForm";
|
19
20
|
import { useModal } from "@hooks/modal";
|
@@ -112,6 +113,8 @@ export const useModalForm = <
|
|
112
113
|
defaultVisible = false,
|
113
114
|
autoSubmitClose = true,
|
114
115
|
autoResetForm = true,
|
116
|
+
autoSave,
|
117
|
+
invalidates,
|
115
118
|
...rest
|
116
119
|
}: UseModalFormProps<
|
117
120
|
TQueryFnData,
|
@@ -129,6 +132,7 @@ export const useModalForm = <
|
|
129
132
|
TResponseError
|
130
133
|
> => {
|
131
134
|
const [initiallySynced, setInitiallySynced] = React.useState(false);
|
135
|
+
const invalidate = useInvalidate();
|
132
136
|
|
133
137
|
const {
|
134
138
|
resource,
|
@@ -168,10 +172,13 @@ export const useModalForm = <
|
|
168
172
|
: {}),
|
169
173
|
...rest.meta,
|
170
174
|
},
|
175
|
+
autoSave,
|
176
|
+
invalidates,
|
171
177
|
...rest,
|
172
178
|
});
|
173
179
|
|
174
|
-
const { form, formProps, id, setId, formLoading, onFinish } =
|
180
|
+
const { form, formProps, id, setId, formLoading, onFinish, autoSaveProps } =
|
181
|
+
useFormProps;
|
175
182
|
|
176
183
|
const translate = useTranslate();
|
177
184
|
|
@@ -263,6 +270,15 @@ export const useModalForm = <
|
|
263
270
|
};
|
264
271
|
|
265
272
|
const handleClose = useCallback(() => {
|
273
|
+
if (autoSaveProps.status === "success" && autoSave?.invalidateOnClose) {
|
274
|
+
invalidate({
|
275
|
+
id,
|
276
|
+
invalidates: invalidates || ["list", "many", "detail"],
|
277
|
+
dataProviderName: rest.dataProviderName,
|
278
|
+
resource: identifier,
|
279
|
+
});
|
280
|
+
}
|
281
|
+
|
266
282
|
if (warnWhen) {
|
267
283
|
const warnWhenConfirm = window.confirm(
|
268
284
|
translate(
|
@@ -280,7 +296,7 @@ export const useModalForm = <
|
|
280
296
|
|
281
297
|
setId?.(undefined);
|
282
298
|
sunflowerUseModal.close();
|
283
|
-
}, [warnWhen]);
|
299
|
+
}, [warnWhen, autoSaveProps.status]);
|
284
300
|
|
285
301
|
const handleShow = useCallback(
|
286
302
|
(showId?: BaseKey) => {
|