@refinedev/core 4.56.0 → 4.57.5
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 +194 -2
- package/README.md +6 -4
- package/dist/components/authenticated/index.d.cts +6 -1
- package/dist/components/authenticated/index.d.cts.map +1 -1
- package/dist/components/authenticated/index.d.mts +6 -1
- package/dist/components/authenticated/index.d.mts.map +6 -1
- package/dist/components/authenticated/index.d.ts +6 -1
- package/dist/components/authenticated/index.d.ts.map +1 -1
- package/dist/contexts/refine/index.d.cts.map +1 -1
- package/dist/contexts/refine/index.d.ts.map +1 -1
- package/dist/hooks/data/useCreate.d.cts.map +1 -1
- package/dist/hooks/data/useCreate.d.ts.map +1 -1
- package/dist/hooks/data/useCreateMany.d.cts.map +1 -1
- package/dist/hooks/data/useCreateMany.d.ts.map +1 -1
- package/dist/hooks/data/useCustom.d.cts.map +1 -1
- package/dist/hooks/data/useCustom.d.ts.map +1 -1
- package/dist/hooks/data/useCustomMutation.d.cts.map +1 -1
- package/dist/hooks/data/useCustomMutation.d.ts.map +1 -1
- package/dist/hooks/data/useDelete.d.cts.map +1 -1
- package/dist/hooks/data/useDelete.d.ts.map +1 -1
- package/dist/hooks/data/useDeleteMany.d.cts.map +1 -1
- package/dist/hooks/data/useDeleteMany.d.ts.map +1 -1
- package/dist/hooks/data/useInfiniteList.d.cts.map +1 -1
- package/dist/hooks/data/useInfiniteList.d.ts.map +1 -1
- package/dist/hooks/data/useList.d.cts.map +1 -1
- package/dist/hooks/data/useList.d.ts.map +1 -1
- package/dist/hooks/data/useMany.d.cts.map +1 -1
- package/dist/hooks/data/useMany.d.ts.map +1 -1
- package/dist/hooks/data/useOne.d.cts.map +1 -1
- package/dist/hooks/data/useOne.d.ts.map +1 -1
- package/dist/hooks/data/useUpdate.d.cts.map +1 -1
- package/dist/hooks/data/useUpdate.d.ts.map +1 -1
- package/dist/hooks/data/useUpdateMany.d.cts.map +1 -1
- package/dist/hooks/data/useUpdateMany.d.ts.map +1 -1
- package/dist/hooks/form/index.d.cts.map +1 -1
- package/dist/hooks/form/index.d.ts.map +1 -1
- package/dist/hooks/navigation/index.d.cts.map +1 -1
- package/dist/hooks/navigation/index.d.ts.map +1 -1
- package/dist/hooks/show/index.d.cts.map +1 -1
- package/dist/hooks/show/index.d.ts.map +1 -1
- package/dist/hooks/useLoadingOvertime/index.d.cts +7 -1
- package/dist/hooks/useLoadingOvertime/index.d.cts.map +1 -1
- package/dist/hooks/useLoadingOvertime/index.d.mts +7 -1
- package/dist/hooks/useLoadingOvertime/index.d.mts.map +7 -1
- package/dist/hooks/useLoadingOvertime/index.d.ts +7 -1
- package/dist/hooks/useLoadingOvertime/index.d.ts.map +1 -1
- package/dist/hooks/useSelect/index.d.cts.map +1 -1
- package/dist/hooks/useSelect/index.d.ts.map +1 -1
- package/dist/hooks/useTable/index.d.cts +1 -1
- package/dist/hooks/useTable/index.d.cts.map +1 -1
- package/dist/hooks/useTable/index.d.mts +1 -1
- package/dist/hooks/useTable/index.d.mts.map +1 -1
- package/dist/hooks/useTable/index.d.ts +1 -1
- package/dist/hooks/useTable/index.d.ts.map +1 -1
- package/dist/index.cjs +22 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +22 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/components/authenticated/index.tsx +9 -1
- package/src/contexts/refine/index.tsx +1 -0
- package/src/hooks/auth/useLogin/index.ts +6 -2
- package/src/hooks/data/useCreate.ts +1 -2
- package/src/hooks/data/useCreateMany.ts +1 -2
- package/src/hooks/data/useCustom.ts +1 -2
- package/src/hooks/data/useCustomMutation.ts +1 -2
- package/src/hooks/data/useDelete.ts +1 -2
- package/src/hooks/data/useDeleteMany.ts +1 -2
- package/src/hooks/data/useInfiniteList.ts +1 -2
- package/src/hooks/data/useList.ts +1 -2
- package/src/hooks/data/useMany.ts +24 -5
- package/src/hooks/data/useOne.ts +1 -2
- package/src/hooks/data/useUpdate.ts +6 -7
- package/src/hooks/data/useUpdateMany.ts +1 -2
- package/src/hooks/form/index.ts +4 -2
- package/src/hooks/navigation/index.ts +5 -0
- package/src/hooks/show/index.ts +3 -8
- package/src/hooks/useLoadingOvertime/index.ts +19 -3
- package/src/hooks/useSelect/index.ts +3 -2
- package/src/hooks/useTable/index.ts +5 -13
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@refinedev/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.57.5",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Refine is a React meta-framework for building enterprise-level, data-intensive applications rapidly with support for modern UI libraries and headless integrations.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/refinedev/refine.git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"module": "dist/index.mjs",
|
|
28
28
|
"typings": "dist/index.d.ts",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@refinedev/devtools-internal": "1.1.
|
|
30
|
+
"@refinedev/devtools-internal": "1.1.16",
|
|
31
31
|
"@tanstack/react-query": "^4.10.1",
|
|
32
32
|
"lodash": "^4.17.21",
|
|
33
33
|
"lodash-es": "^4.17.21",
|
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
} from "@hooks";
|
|
12
12
|
import type { GoConfig } from "../../contexts/router/types";
|
|
13
13
|
|
|
14
|
+
export type AuthCheckParams = any;
|
|
15
|
+
|
|
14
16
|
export type AuthenticatedCommonProps = {
|
|
15
17
|
/**
|
|
16
18
|
* Unique key to identify the component.
|
|
@@ -44,9 +46,13 @@ export type AuthenticatedCommonProps = {
|
|
|
44
46
|
*/
|
|
45
47
|
loading?: React.ReactNode;
|
|
46
48
|
/**
|
|
47
|
-
* Content to show if user is logged in
|
|
49
|
+
* Content to show if user is logged in.
|
|
48
50
|
*/
|
|
49
51
|
children?: React.ReactNode;
|
|
52
|
+
/**
|
|
53
|
+
* optional params to be passed to the Auth Provider's check method via the useIsAuthenticated hook.
|
|
54
|
+
*/
|
|
55
|
+
params?: AuthCheckParams;
|
|
50
56
|
};
|
|
51
57
|
|
|
52
58
|
export type LegacyAuthenticatedProps = {
|
|
@@ -97,6 +103,7 @@ export function Authenticated({
|
|
|
97
103
|
children,
|
|
98
104
|
fallback: fallbackContent,
|
|
99
105
|
loading: loadingContent,
|
|
106
|
+
params,
|
|
100
107
|
}: AuthenticatedProps | LegacyAuthenticatedProps): JSX.Element | null {
|
|
101
108
|
const activeAuthProvider = useActiveAuthProvider();
|
|
102
109
|
const routerType = useRouterType();
|
|
@@ -119,6 +126,7 @@ export function Authenticated({
|
|
|
119
126
|
} = {},
|
|
120
127
|
} = useIsAuthenticated({
|
|
121
128
|
v3LegacyAuthProviderCompatible: isLegacyAuth,
|
|
129
|
+
params,
|
|
122
130
|
});
|
|
123
131
|
|
|
124
132
|
// Authentication status
|
|
@@ -175,7 +175,9 @@ export function useLogin<TVariables = {}>({
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
setTimeout(() => {
|
|
179
|
+
invalidateAuthStore();
|
|
180
|
+
}, 32);
|
|
179
181
|
},
|
|
180
182
|
onError: (error: any) => {
|
|
181
183
|
open?.(buildNotification(error));
|
|
@@ -219,7 +221,9 @@ export function useLogin<TVariables = {}>({
|
|
|
219
221
|
}
|
|
220
222
|
}
|
|
221
223
|
|
|
222
|
-
|
|
224
|
+
setTimeout(() => {
|
|
225
|
+
invalidateAuthStore();
|
|
226
|
+
}, 32);
|
|
223
227
|
|
|
224
228
|
close?.("login-error");
|
|
225
229
|
},
|
|
@@ -315,9 +315,8 @@ export const useCreate = <
|
|
|
315
315
|
const { mutate, mutateAsync, ...mutation } = mutationResult;
|
|
316
316
|
|
|
317
317
|
const { elapsedTime } = useLoadingOvertime({
|
|
318
|
+
...overtimeOptions,
|
|
318
319
|
isLoading: mutation.isLoading,
|
|
319
|
-
interval: overtimeOptions?.interval,
|
|
320
|
-
onInterval: overtimeOptions?.onInterval,
|
|
321
320
|
});
|
|
322
321
|
|
|
323
322
|
// this function is used to make the `variables` parameter optional
|
|
@@ -293,9 +293,8 @@ export const useCreateMany = <
|
|
|
293
293
|
const { mutate, mutateAsync, ...mutation } = mutationResult;
|
|
294
294
|
|
|
295
295
|
const { elapsedTime } = useLoadingOvertime({
|
|
296
|
+
...overtimeOptions,
|
|
296
297
|
isLoading: mutation.isLoading,
|
|
297
|
-
interval: overtimeOptions?.interval,
|
|
298
|
-
onInterval: overtimeOptions?.onInterval,
|
|
299
298
|
});
|
|
300
299
|
|
|
301
300
|
// this function is used to make the `variables` parameter optional
|
|
@@ -217,9 +217,8 @@ export const useCustom = <
|
|
|
217
217
|
},
|
|
218
218
|
});
|
|
219
219
|
const { elapsedTime } = useLoadingOvertime({
|
|
220
|
+
...overtimeOptions,
|
|
220
221
|
isLoading: queryResponse.isFetching,
|
|
221
|
-
interval: overtimeOptions?.interval,
|
|
222
|
-
onInterval: overtimeOptions?.onInterval,
|
|
223
222
|
});
|
|
224
223
|
|
|
225
224
|
return { ...queryResponse, overtime: { elapsedTime } };
|
|
@@ -215,9 +215,8 @@ export const useCustomMutation = <
|
|
|
215
215
|
);
|
|
216
216
|
|
|
217
217
|
const { elapsedTime } = useLoadingOvertime({
|
|
218
|
+
...overtimeOptions,
|
|
218
219
|
isLoading: mutation.isLoading,
|
|
219
|
-
interval: overtimeOptions?.interval,
|
|
220
|
-
onInterval: overtimeOptions?.onInterval,
|
|
221
220
|
});
|
|
222
221
|
|
|
223
222
|
return { ...mutation, overtime: { elapsedTime } };
|
|
@@ -493,9 +493,8 @@ export const useDelete = <
|
|
|
493
493
|
});
|
|
494
494
|
|
|
495
495
|
const { elapsedTime } = useLoadingOvertime({
|
|
496
|
+
...overtimeOptions,
|
|
496
497
|
isLoading: mutation.isLoading,
|
|
497
|
-
interval: overtimeOptions?.interval,
|
|
498
|
-
onInterval: overtimeOptions?.onInterval,
|
|
499
498
|
});
|
|
500
499
|
|
|
501
500
|
return { ...mutation, overtime: { elapsedTime } };
|
|
@@ -524,9 +524,8 @@ export const useDeleteMany = <
|
|
|
524
524
|
});
|
|
525
525
|
|
|
526
526
|
const { elapsedTime } = useLoadingOvertime({
|
|
527
|
+
...overtimeOptions,
|
|
527
528
|
isLoading: mutation.isLoading,
|
|
528
|
-
interval: overtimeOptions?.interval,
|
|
529
|
-
onInterval: overtimeOptions?.onInterval,
|
|
530
529
|
});
|
|
531
530
|
|
|
532
531
|
return { ...mutation, overtime: { elapsedTime } };
|
|
@@ -320,9 +320,8 @@ export const useInfiniteList = <
|
|
|
320
320
|
});
|
|
321
321
|
|
|
322
322
|
const { elapsedTime } = useLoadingOvertime({
|
|
323
|
+
...overtimeOptions,
|
|
323
324
|
isLoading: queryResponse.isFetching,
|
|
324
|
-
interval: overtimeOptions?.interval,
|
|
325
|
-
onInterval: overtimeOptions?.onInterval,
|
|
326
325
|
});
|
|
327
326
|
|
|
328
327
|
return { ...queryResponse, overtime: { elapsedTime } };
|
|
@@ -326,9 +326,8 @@ export const useList = <
|
|
|
326
326
|
});
|
|
327
327
|
|
|
328
328
|
const { elapsedTime } = useLoadingOvertime({
|
|
329
|
+
...overtimeOptions,
|
|
329
330
|
isLoading: queryResponse.isFetching,
|
|
330
|
-
interval: overtimeOptions?.interval,
|
|
331
|
-
onInterval: overtimeOptions?.onInterval,
|
|
332
331
|
});
|
|
333
332
|
|
|
334
333
|
return { ...queryResponse, overtime: { elapsedTime } };
|
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
type UseLoadingOvertimeReturnType,
|
|
38
38
|
useLoadingOvertime,
|
|
39
39
|
} from "../useLoadingOvertime";
|
|
40
|
+
import warnOnce from "warn-once";
|
|
40
41
|
|
|
41
42
|
export type UseManyProps<TQueryFnData, TError, TData> = {
|
|
42
43
|
/**
|
|
@@ -133,17 +134,24 @@ export const useMany = <
|
|
|
133
134
|
|
|
134
135
|
const combinedMeta = getMeta({ resource, meta: preferredMeta });
|
|
135
136
|
|
|
137
|
+
const hasIds = Array.isArray(ids);
|
|
138
|
+
const hasResource = Boolean(resource?.name);
|
|
139
|
+
const manuallyEnabled = queryOptions?.enabled === true;
|
|
140
|
+
|
|
141
|
+
warnOnce(!hasIds && !manuallyEnabled, idsWarningMessage(ids, resource?.name));
|
|
142
|
+
warnOnce(!hasResource && !manuallyEnabled, resourceWarningMessage());
|
|
143
|
+
|
|
136
144
|
useResourceSubscription({
|
|
137
145
|
resource: identifier,
|
|
138
146
|
types: ["*"],
|
|
139
147
|
params: {
|
|
140
|
-
ids: ids,
|
|
148
|
+
ids: ids ?? [],
|
|
141
149
|
meta: combinedMeta,
|
|
142
150
|
metaData: combinedMeta,
|
|
143
151
|
subscriptionType: "useMany",
|
|
144
152
|
...liveParams,
|
|
145
153
|
},
|
|
146
|
-
channel: `resources/${resource
|
|
154
|
+
channel: `resources/${resource?.name ?? ""}`,
|
|
147
155
|
enabled: isEnabled,
|
|
148
156
|
liveMode,
|
|
149
157
|
onLiveEvent,
|
|
@@ -163,7 +171,7 @@ export const useMany = <
|
|
|
163
171
|
.data(pickedDataProvider)
|
|
164
172
|
.resource(identifier)
|
|
165
173
|
.action("many")
|
|
166
|
-
.ids(...ids)
|
|
174
|
+
.ids(...(ids ?? []))
|
|
167
175
|
.params({
|
|
168
176
|
...(preferredMeta || {}),
|
|
169
177
|
})
|
|
@@ -193,6 +201,7 @@ export const useMany = <
|
|
|
193
201
|
),
|
|
194
202
|
);
|
|
195
203
|
},
|
|
204
|
+
enabled: hasIds && hasResource,
|
|
196
205
|
...queryOptions,
|
|
197
206
|
onSuccess: (data) => {
|
|
198
207
|
queryOptions?.onSuccess?.(data);
|
|
@@ -231,10 +240,20 @@ export const useMany = <
|
|
|
231
240
|
});
|
|
232
241
|
|
|
233
242
|
const { elapsedTime } = useLoadingOvertime({
|
|
243
|
+
...overtimeOptions,
|
|
234
244
|
isLoading: queryResponse.isFetching,
|
|
235
|
-
interval: overtimeOptions?.interval,
|
|
236
|
-
onInterval: overtimeOptions?.onInterval,
|
|
237
245
|
});
|
|
238
246
|
|
|
239
247
|
return { ...queryResponse, overtime: { elapsedTime } };
|
|
240
248
|
};
|
|
249
|
+
|
|
250
|
+
const idsWarningMessage = (
|
|
251
|
+
ids: BaseKey[],
|
|
252
|
+
resource: string,
|
|
253
|
+
) => `[useMany]: Missing "ids" prop. Expected an array of ids, but got "${typeof ids}". Resource: "${resource}"
|
|
254
|
+
|
|
255
|
+
See https://refine.dev/docs/data/hooks/use-many/#ids-`;
|
|
256
|
+
|
|
257
|
+
const resourceWarningMessage = () => `[useMany]: Missing "resource" prop. Expected a string, but got undefined.
|
|
258
|
+
|
|
259
|
+
See https://refine.dev/docs/data/hooks/use-many/#resource-`;
|
package/src/hooks/data/useOne.ts
CHANGED
|
@@ -244,9 +244,8 @@ export const useOne = <
|
|
|
244
244
|
});
|
|
245
245
|
|
|
246
246
|
const { elapsedTime } = useLoadingOvertime({
|
|
247
|
+
...overtimeOptions,
|
|
247
248
|
isLoading: queryResponse.isFetching,
|
|
248
|
-
interval: overtimeOptions?.interval,
|
|
249
|
-
onInterval: overtimeOptions?.onInterval,
|
|
250
249
|
});
|
|
251
250
|
|
|
252
251
|
return { ...queryResponse, overtime: { elapsedTime } };
|
|
@@ -240,7 +240,7 @@ export const useUpdate = <
|
|
|
240
240
|
metaData = metaDataFromProps,
|
|
241
241
|
dataProviderName = dataProviderNameFromProps,
|
|
242
242
|
}) => {
|
|
243
|
-
if (
|
|
243
|
+
if (typeof id === "undefined") throw missingIdError;
|
|
244
244
|
if (!values) throw missingValuesError;
|
|
245
245
|
if (!resourceName) throw missingResourceError;
|
|
246
246
|
|
|
@@ -321,7 +321,7 @@ export const useUpdate = <
|
|
|
321
321
|
detail: true,
|
|
322
322
|
},
|
|
323
323
|
}) => {
|
|
324
|
-
if (
|
|
324
|
+
if (typeof id === "undefined") throw missingIdError;
|
|
325
325
|
if (!values) throw missingValuesError;
|
|
326
326
|
if (!resourceName) throw missingResourceError;
|
|
327
327
|
|
|
@@ -462,7 +462,7 @@ export const useUpdate = <
|
|
|
462
462
|
dataProviderName = dataProviderNameFromProps,
|
|
463
463
|
invalidates = invalidatesFromProps ?? ["list", "many", "detail"],
|
|
464
464
|
} = variables;
|
|
465
|
-
if (
|
|
465
|
+
if (typeof id === "undefined") throw missingIdError;
|
|
466
466
|
if (!resourceName) throw missingResourceError;
|
|
467
467
|
|
|
468
468
|
const { identifier } = select(resourceName);
|
|
@@ -495,7 +495,7 @@ export const useUpdate = <
|
|
|
495
495
|
meta = metaFromProps,
|
|
496
496
|
metaData = metaDataFromProps,
|
|
497
497
|
} = variables;
|
|
498
|
-
if (
|
|
498
|
+
if (typeof id === "undefined") throw missingIdError;
|
|
499
499
|
if (!values) throw missingValuesError;
|
|
500
500
|
if (!resourceName) throw missingResourceError;
|
|
501
501
|
|
|
@@ -586,7 +586,7 @@ export const useUpdate = <
|
|
|
586
586
|
errorNotification = errorNotificationFromProps,
|
|
587
587
|
values = valuesFromProps,
|
|
588
588
|
} = variables;
|
|
589
|
-
if (
|
|
589
|
+
if (typeof id === "undefined") throw missingIdError;
|
|
590
590
|
if (!values) throw missingValuesError;
|
|
591
591
|
if (!resourceName) throw missingResourceError;
|
|
592
592
|
|
|
@@ -639,9 +639,8 @@ export const useUpdate = <
|
|
|
639
639
|
const { mutate, mutateAsync, ...mutation } = mutationResult;
|
|
640
640
|
|
|
641
641
|
const { elapsedTime } = useLoadingOvertime({
|
|
642
|
+
...overtimeOptions,
|
|
642
643
|
isLoading: mutation.isLoading,
|
|
643
|
-
interval: overtimeOptions?.interval,
|
|
644
|
-
onInterval: overtimeOptions?.onInterval,
|
|
645
644
|
});
|
|
646
645
|
|
|
647
646
|
// this function is used to make the `variables` parameter optional
|
|
@@ -676,9 +676,8 @@ export const useUpdateMany = <
|
|
|
676
676
|
const { mutate, mutateAsync, ...mutation } = mutationResult;
|
|
677
677
|
|
|
678
678
|
const { elapsedTime } = useLoadingOvertime({
|
|
679
|
+
...overtimeOptions,
|
|
679
680
|
isLoading: mutation.isLoading,
|
|
680
|
-
interval: overtimeOptions?.interval,
|
|
681
|
-
onInterval: overtimeOptions?.onInterval,
|
|
682
681
|
});
|
|
683
682
|
|
|
684
683
|
// this function is used to make the `variables` parameter optional
|
package/src/hooks/form/index.ts
CHANGED
|
@@ -169,14 +169,17 @@ export const useForm = <
|
|
|
169
169
|
liveParams: props.liveParams,
|
|
170
170
|
meta: { ...combinedMeta, ...props.queryMeta },
|
|
171
171
|
dataProviderName: props.dataProviderName,
|
|
172
|
+
overtimeOptions: { enabled: false },
|
|
172
173
|
});
|
|
173
174
|
|
|
174
175
|
const createMutation = useCreate<TResponse, TResponseError, TVariables>({
|
|
175
176
|
mutationOptions: props.createMutationOptions,
|
|
177
|
+
overtimeOptions: { enabled: false },
|
|
176
178
|
});
|
|
177
179
|
|
|
178
180
|
const updateMutation = useUpdate<TResponse, TResponseError, TVariables>({
|
|
179
181
|
mutationOptions: props.updateMutationOptions,
|
|
182
|
+
overtimeOptions: { enabled: false },
|
|
180
183
|
});
|
|
181
184
|
|
|
182
185
|
const mutationResult = isEdit ? updateMutation : createMutation;
|
|
@@ -184,9 +187,8 @@ export const useForm = <
|
|
|
184
187
|
const formLoading = isMutationLoading || queryResult.isFetching;
|
|
185
188
|
|
|
186
189
|
const { elapsedTime } = useLoadingOvertime({
|
|
190
|
+
...props.overtimeOptions,
|
|
187
191
|
isLoading: formLoading,
|
|
188
|
-
interval: props.overtimeOptions?.interval,
|
|
189
|
-
onInterval: props.overtimeOptions?.onInterval,
|
|
190
192
|
});
|
|
191
193
|
|
|
192
194
|
React.useEffect(() => {
|
|
@@ -85,6 +85,7 @@ export const useNavigation = () => {
|
|
|
85
85
|
return go({
|
|
86
86
|
to: composeRoute(createActionRoute, resourceItem?.meta, parsed, meta),
|
|
87
87
|
type: "path",
|
|
88
|
+
query: meta.query,
|
|
88
89
|
}) as string;
|
|
89
90
|
};
|
|
90
91
|
|
|
@@ -138,6 +139,7 @@ export const useNavigation = () => {
|
|
|
138
139
|
id: encodedId,
|
|
139
140
|
}),
|
|
140
141
|
type: "path",
|
|
142
|
+
query: meta.query,
|
|
141
143
|
}) as string;
|
|
142
144
|
};
|
|
143
145
|
|
|
@@ -192,6 +194,7 @@ export const useNavigation = () => {
|
|
|
192
194
|
id: encodedId,
|
|
193
195
|
}),
|
|
194
196
|
type: "path",
|
|
197
|
+
query: meta.query,
|
|
195
198
|
}) as string;
|
|
196
199
|
};
|
|
197
200
|
|
|
@@ -245,6 +248,7 @@ export const useNavigation = () => {
|
|
|
245
248
|
id: encodedId,
|
|
246
249
|
}),
|
|
247
250
|
type: "path",
|
|
251
|
+
query: meta.query,
|
|
248
252
|
}) as string;
|
|
249
253
|
};
|
|
250
254
|
|
|
@@ -295,6 +299,7 @@ export const useNavigation = () => {
|
|
|
295
299
|
return go({
|
|
296
300
|
to: composeRoute(listActionRoute, resourceItem?.meta, parsed, meta),
|
|
297
301
|
type: "path",
|
|
302
|
+
query: meta.query,
|
|
298
303
|
}) as string;
|
|
299
304
|
};
|
|
300
305
|
|
package/src/hooks/show/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import warnOnce from "warn-once";
|
|
2
|
-
import { useMeta, useOne, useResourceParams
|
|
2
|
+
import { useMeta, useOne, useResourceParams } from "@hooks";
|
|
3
3
|
import { pickNotDeprecated } from "@definitions/helpers";
|
|
4
4
|
|
|
5
5
|
import type { UseShowProps, UseShowReturnType } from "./types";
|
|
@@ -71,21 +71,16 @@ export const useShow = <
|
|
|
71
71
|
},
|
|
72
72
|
meta: combinedMeta,
|
|
73
73
|
metaData: combinedMeta,
|
|
74
|
+
overtimeOptions,
|
|
74
75
|
...useOneProps,
|
|
75
76
|
});
|
|
76
77
|
|
|
77
|
-
const { elapsedTime } = useLoadingOvertime({
|
|
78
|
-
isLoading: queryResult.isFetching,
|
|
79
|
-
interval: overtimeOptions?.interval,
|
|
80
|
-
onInterval: overtimeOptions?.onInterval,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
78
|
return {
|
|
84
79
|
queryResult,
|
|
85
80
|
query: queryResult,
|
|
86
81
|
showId,
|
|
87
82
|
setShowId,
|
|
88
|
-
overtime:
|
|
83
|
+
overtime: queryResult.overtime,
|
|
89
84
|
};
|
|
90
85
|
};
|
|
91
86
|
|
|
@@ -27,6 +27,13 @@ type UseLoadingOvertimeCoreReturnType = {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
export type UseLoadingOvertimeCoreProps = {
|
|
30
|
+
/**
|
|
31
|
+
* If true, the elapsed time will be calculated. If set to false; the elapsed time will be `undefined`.
|
|
32
|
+
*
|
|
33
|
+
* @default: true
|
|
34
|
+
*/
|
|
35
|
+
enabled?: boolean;
|
|
36
|
+
|
|
30
37
|
/**
|
|
31
38
|
* The loading state. If true, the elapsed time will be calculated.
|
|
32
39
|
*/
|
|
@@ -63,6 +70,7 @@ export type UseLoadingOvertimeCoreProps = {
|
|
|
63
70
|
* });
|
|
64
71
|
*/
|
|
65
72
|
export const useLoadingOvertime = ({
|
|
73
|
+
enabled: enabledProp,
|
|
66
74
|
isLoading,
|
|
67
75
|
interval: intervalProp,
|
|
68
76
|
onInterval: onIntervalProp,
|
|
@@ -75,11 +83,17 @@ export const useLoadingOvertime = ({
|
|
|
75
83
|
// pick props or refine context options
|
|
76
84
|
const interval = intervalProp ?? overtime.interval;
|
|
77
85
|
const onInterval = onIntervalProp ?? overtime?.onInterval;
|
|
86
|
+
const enabled =
|
|
87
|
+
typeof enabledProp !== "undefined"
|
|
88
|
+
? enabledProp
|
|
89
|
+
: typeof overtime.enabled !== "undefined"
|
|
90
|
+
? overtime.enabled
|
|
91
|
+
: true;
|
|
78
92
|
|
|
79
93
|
useEffect(() => {
|
|
80
94
|
let intervalFn: ReturnType<typeof setInterval>;
|
|
81
95
|
|
|
82
|
-
if (isLoading) {
|
|
96
|
+
if (enabled && isLoading) {
|
|
83
97
|
intervalFn = setInterval(() => {
|
|
84
98
|
// increase elapsed time
|
|
85
99
|
setElapsedTime((prevElapsedTime) => {
|
|
@@ -93,11 +107,13 @@ export const useLoadingOvertime = ({
|
|
|
93
107
|
}
|
|
94
108
|
|
|
95
109
|
return () => {
|
|
96
|
-
|
|
110
|
+
if (typeof intervalFn !== "undefined") {
|
|
111
|
+
clearInterval(intervalFn);
|
|
112
|
+
}
|
|
97
113
|
// reset elapsed time
|
|
98
114
|
setElapsedTime(undefined);
|
|
99
115
|
};
|
|
100
|
-
}, [isLoading, interval]);
|
|
116
|
+
}, [isLoading, interval, enabled]);
|
|
101
117
|
|
|
102
118
|
useEffect(() => {
|
|
103
119
|
// call onInterval callback
|
|
@@ -303,6 +303,7 @@ export const useSelect = <
|
|
|
303
303
|
defaultValueQueryOptions?.onSuccess?.(data);
|
|
304
304
|
},
|
|
305
305
|
},
|
|
306
|
+
overtimeOptions: { enabled: false },
|
|
306
307
|
meta: combinedMeta,
|
|
307
308
|
metaData: combinedMeta,
|
|
308
309
|
liveMode: "off",
|
|
@@ -341,6 +342,7 @@ export const useSelect = <
|
|
|
341
342
|
queryOptions?.onSuccess?.(data);
|
|
342
343
|
},
|
|
343
344
|
},
|
|
345
|
+
overtimeOptions: { enabled: false },
|
|
344
346
|
successNotification,
|
|
345
347
|
errorNotification,
|
|
346
348
|
meta: combinedMeta,
|
|
@@ -352,9 +354,8 @@ export const useSelect = <
|
|
|
352
354
|
});
|
|
353
355
|
|
|
354
356
|
const { elapsedTime } = useLoadingOvertime({
|
|
357
|
+
...overtimeOptions,
|
|
355
358
|
isLoading: queryResult.isFetching || defaultValueQueryResult.isFetching,
|
|
356
|
-
interval: overtimeOptions?.interval,
|
|
357
|
-
onInterval: overtimeOptions?.onInterval,
|
|
358
359
|
});
|
|
359
360
|
|
|
360
361
|
const combinedOptions = useMemo(
|
|
@@ -44,10 +44,9 @@ import type {
|
|
|
44
44
|
import type { LiveModeProps } from "../../contexts/live/types";
|
|
45
45
|
import type { SuccessErrorNotification } from "../../contexts/notification/types";
|
|
46
46
|
import type { BaseListProps } from "../data/useList";
|
|
47
|
-
import {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
useLoadingOvertime,
|
|
47
|
+
import type {
|
|
48
|
+
UseLoadingOvertimeOptionsProps,
|
|
49
|
+
UseLoadingOvertimeReturnType,
|
|
51
50
|
} from "../useLoadingOvertime";
|
|
52
51
|
|
|
53
52
|
type SetFilterBehavior = "merge" | "replace";
|
|
@@ -510,6 +509,7 @@ export function useTable<
|
|
|
510
509
|
? unionSorters(preferredPermanentSorters, sorters)
|
|
511
510
|
: undefined,
|
|
512
511
|
queryOptions,
|
|
512
|
+
overtimeOptions,
|
|
513
513
|
successNotification,
|
|
514
514
|
errorNotification,
|
|
515
515
|
meta: combinedMeta,
|
|
@@ -571,12 +571,6 @@ export function useTable<
|
|
|
571
571
|
[preferredPermanentSorters],
|
|
572
572
|
);
|
|
573
573
|
|
|
574
|
-
const { elapsedTime } = useLoadingOvertime({
|
|
575
|
-
isLoading: queryResult.isFetching,
|
|
576
|
-
interval: overtimeOptions?.interval,
|
|
577
|
-
onInterval: overtimeOptions?.onInterval,
|
|
578
|
-
});
|
|
579
|
-
|
|
580
574
|
return {
|
|
581
575
|
tableQueryResult: queryResult,
|
|
582
576
|
tableQuery: queryResult,
|
|
@@ -594,8 +588,6 @@ export function useTable<
|
|
|
594
588
|
? Math.ceil((queryResult.data?.total ?? 0) / pageSize)
|
|
595
589
|
: 1,
|
|
596
590
|
createLinkForSyncWithLocation,
|
|
597
|
-
overtime:
|
|
598
|
-
elapsedTime,
|
|
599
|
-
},
|
|
591
|
+
overtime: queryResult.overtime,
|
|
600
592
|
};
|
|
601
593
|
}
|