@refinedev/core 5.0.2 → 5.0.4
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 +30 -0
- package/dist/hooks/data/useCustom.d.cts.map +1 -1
- package/dist/hooks/data/useCustom.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/form/index.d.cts.map +1 -1
- package/dist/hooks/form/index.d.ts.map +1 -1
- package/dist/hooks/useTable/index.d.cts.map +1 -1
- package/dist/hooks/useTable/index.d.ts.map +1 -1
- package/dist/index.cjs +18 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +18 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/data/useCustom.ts +3 -1
- package/src/hooks/data/useInfiniteList.ts +3 -4
- package/src/hooks/data/useList.ts +3 -1
- package/src/hooks/data/useMany.ts +3 -1
- package/src/hooks/form/index.ts +3 -1
- package/src/hooks/useTable/index.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@refinedev/core",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"private": false,
|
|
5
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": {
|
|
@@ -114,6 +114,8 @@ export type UseCustomReturnType<TData, TError> = {
|
|
|
114
114
|
};
|
|
115
115
|
} & UseLoadingOvertimeReturnType;
|
|
116
116
|
|
|
117
|
+
const EMPTY_OBJECT = Object.freeze({}) as any;
|
|
118
|
+
|
|
117
119
|
export const useCustom = <
|
|
118
120
|
TQueryFnData extends BaseRecord = BaseRecord,
|
|
119
121
|
TError extends HttpError = HttpError,
|
|
@@ -231,7 +233,7 @@ export const useCustom = <
|
|
|
231
233
|
return {
|
|
232
234
|
query: queryResponse,
|
|
233
235
|
result: {
|
|
234
|
-
data: queryResponse.data?.data ||
|
|
236
|
+
data: queryResponse.data?.data || EMPTY_OBJECT,
|
|
235
237
|
},
|
|
236
238
|
overtime: { elapsedTime },
|
|
237
239
|
};
|
|
@@ -250,7 +250,8 @@ export const useInfiniteList = <
|
|
|
250
250
|
queryFn: (context) => {
|
|
251
251
|
const paginationProperties = {
|
|
252
252
|
...prefferedPagination,
|
|
253
|
-
currentPage:
|
|
253
|
+
currentPage:
|
|
254
|
+
(context.pageParam as number) ?? prefferedPagination.currentPage,
|
|
254
255
|
};
|
|
255
256
|
|
|
256
257
|
const meta = {
|
|
@@ -260,7 +261,7 @@ export const useInfiniteList = <
|
|
|
260
261
|
|
|
261
262
|
return getList<TQueryFnData>({
|
|
262
263
|
resource: resource?.name || "",
|
|
263
|
-
pagination:
|
|
264
|
+
pagination: paginationProperties,
|
|
264
265
|
filters: prefferedFilters,
|
|
265
266
|
sorters: prefferedSorters,
|
|
266
267
|
meta,
|
|
@@ -345,8 +346,6 @@ export const useInfiniteList = <
|
|
|
345
346
|
isLoading: queryResponse.isFetching,
|
|
346
347
|
});
|
|
347
348
|
|
|
348
|
-
queryResponse.data?.pages;
|
|
349
|
-
|
|
350
349
|
return {
|
|
351
350
|
query: queryResponse,
|
|
352
351
|
result: {
|
|
@@ -101,6 +101,8 @@ export type UseListReturnType<TData, TError> = {
|
|
|
101
101
|
};
|
|
102
102
|
} & UseLoadingOvertimeReturnType;
|
|
103
103
|
|
|
104
|
+
const EMPTY_ARRAY = Object.freeze([]) as [];
|
|
105
|
+
|
|
104
106
|
/**
|
|
105
107
|
* `useList` is a modified version of `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/guides/queries `useQuery`} used for retrieving items from a `resource` with pagination, sort, and filter configurations.
|
|
106
108
|
*
|
|
@@ -315,7 +317,7 @@ export const useList = <
|
|
|
315
317
|
return {
|
|
316
318
|
query: queryResponse,
|
|
317
319
|
result: {
|
|
318
|
-
data: queryResponse?.data?.data ||
|
|
320
|
+
data: queryResponse?.data?.data || EMPTY_ARRAY,
|
|
319
321
|
total: queryResponse?.data?.total,
|
|
320
322
|
},
|
|
321
323
|
overtime: { elapsedTime },
|
|
@@ -85,6 +85,8 @@ export type UseManyProps<TQueryFnData, TError, TData> = {
|
|
|
85
85
|
LiveModeProps &
|
|
86
86
|
UseLoadingOvertimeOptionsProps;
|
|
87
87
|
|
|
88
|
+
const EMPTY_ARRAY = Object.freeze([]) as [];
|
|
89
|
+
|
|
88
90
|
/**
|
|
89
91
|
* `useMany` is a modified version of `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/guides/queries `useQuery`} used for retrieving multiple items from a `resource`.
|
|
90
92
|
*
|
|
@@ -259,7 +261,7 @@ export const useMany = <
|
|
|
259
261
|
return {
|
|
260
262
|
query: queryResponse,
|
|
261
263
|
result: {
|
|
262
|
-
data: queryResponse?.data?.data ||
|
|
264
|
+
data: queryResponse?.data?.data || EMPTY_ARRAY,
|
|
263
265
|
},
|
|
264
266
|
overtime: { elapsedTime },
|
|
265
267
|
};
|
package/src/hooks/form/index.ts
CHANGED
|
@@ -159,8 +159,10 @@ export const useForm = <
|
|
|
159
159
|
id,
|
|
160
160
|
queryOptions: {
|
|
161
161
|
// Only enable the query if it's not a create action and the `id` is defined
|
|
162
|
-
enabled: !isCreate && id !== undefined,
|
|
163
162
|
...props.queryOptions,
|
|
163
|
+
// AND the external enabled condition (if provided) is also true
|
|
164
|
+
enabled:
|
|
165
|
+
!isCreate && id !== undefined && (props.queryOptions?.enabled ?? true),
|
|
164
166
|
},
|
|
165
167
|
liveMode: props.liveMode,
|
|
166
168
|
onLiveEvent: props.onLiveEvent,
|
|
@@ -176,6 +176,7 @@ export type useTableReturnType<
|
|
|
176
176
|
|
|
177
177
|
const defaultPermanentFilter: CrudFilter[] = [];
|
|
178
178
|
const defaultPermanentSorter: CrudSort[] = [];
|
|
179
|
+
const EMPTY_ARRAY = Object.freeze([]) as [];
|
|
179
180
|
|
|
180
181
|
export function useTable<
|
|
181
182
|
TQueryFnData extends BaseRecord = BaseRecord,
|
|
@@ -434,7 +435,7 @@ export function useTable<
|
|
|
434
435
|
createLinkForSyncWithLocation,
|
|
435
436
|
overtime: queryResult.overtime,
|
|
436
437
|
result: {
|
|
437
|
-
data: queryResult.result?.data ||
|
|
438
|
+
data: queryResult.result?.data || EMPTY_ARRAY,
|
|
438
439
|
total: queryResult.result?.total,
|
|
439
440
|
},
|
|
440
441
|
};
|