@refinedev/core 5.0.5 → 5.0.6
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 +10 -0
- package/dist/hooks/data/useList.d.cts.map +1 -1
- package/dist/hooks/data/useList.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/index.cjs +477 -454
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +56 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/data/useList.ts +34 -22
- package/src/hooks/form/index.ts +20 -4
package/dist/index.mjs
CHANGED
|
@@ -1538,6 +1538,7 @@ var useIsExistAuthentication = /* @__PURE__ */ __name(() => {
|
|
|
1538
1538
|
// src/hooks/data/useList.ts
|
|
1539
1539
|
import { useEffect as useEffect3 } from "react";
|
|
1540
1540
|
import { getXRay as getXRay10 } from "@refinedev/devtools-internal";
|
|
1541
|
+
import { useMemo } from "react";
|
|
1541
1542
|
import {
|
|
1542
1543
|
useQuery as useQuery4
|
|
1543
1544
|
} from "@tanstack/react-query";
|
|
@@ -1655,6 +1656,31 @@ var useList = /* @__PURE__ */ __name(({
|
|
|
1655
1656
|
dataProviderName: pickedDataProvider
|
|
1656
1657
|
}
|
|
1657
1658
|
});
|
|
1659
|
+
const memoizedSelect = useMemo(() => {
|
|
1660
|
+
return (rawData) => {
|
|
1661
|
+
var _a2;
|
|
1662
|
+
let data = rawData;
|
|
1663
|
+
if (prefferedPagination.mode === "client") {
|
|
1664
|
+
data = {
|
|
1665
|
+
...data,
|
|
1666
|
+
data: data.data.slice(
|
|
1667
|
+
(prefferedPagination.currentPage - 1) * prefferedPagination.pageSize,
|
|
1668
|
+
prefferedPagination.currentPage * prefferedPagination.pageSize
|
|
1669
|
+
),
|
|
1670
|
+
total: data.total
|
|
1671
|
+
};
|
|
1672
|
+
}
|
|
1673
|
+
if (queryOptions == null ? void 0 : queryOptions.select) {
|
|
1674
|
+
return (_a2 = queryOptions == null ? void 0 : queryOptions.select) == null ? void 0 : _a2.call(queryOptions, data);
|
|
1675
|
+
}
|
|
1676
|
+
return data;
|
|
1677
|
+
};
|
|
1678
|
+
}, [
|
|
1679
|
+
prefferedPagination.currentPage,
|
|
1680
|
+
prefferedPagination.pageSize,
|
|
1681
|
+
prefferedPagination.mode,
|
|
1682
|
+
queryOptions == null ? void 0 : queryOptions.select
|
|
1683
|
+
]);
|
|
1658
1684
|
const queryResponse = useQuery4({
|
|
1659
1685
|
queryKey: keys2().data(pickedDataProvider).resource(identifier ?? "").action("list").params({
|
|
1660
1686
|
...preferredMeta || {},
|
|
@@ -1681,25 +1707,7 @@ var useList = /* @__PURE__ */ __name(({
|
|
|
1681
1707
|
},
|
|
1682
1708
|
...queryOptions,
|
|
1683
1709
|
enabled: typeof (queryOptions == null ? void 0 : queryOptions.enabled) !== "undefined" ? queryOptions == null ? void 0 : queryOptions.enabled : !!(resource == null ? void 0 : resource.name),
|
|
1684
|
-
select:
|
|
1685
|
-
var _a2;
|
|
1686
|
-
let data = rawData;
|
|
1687
|
-
const { currentPage, mode, pageSize } = prefferedPagination;
|
|
1688
|
-
if (mode === "client") {
|
|
1689
|
-
data = {
|
|
1690
|
-
...data,
|
|
1691
|
-
data: data.data.slice(
|
|
1692
|
-
(currentPage - 1) * pageSize,
|
|
1693
|
-
currentPage * pageSize
|
|
1694
|
-
),
|
|
1695
|
-
total: data.total
|
|
1696
|
-
};
|
|
1697
|
-
}
|
|
1698
|
-
if (queryOptions == null ? void 0 : queryOptions.select) {
|
|
1699
|
-
return (_a2 = queryOptions == null ? void 0 : queryOptions.select) == null ? void 0 : _a2.call(queryOptions, data);
|
|
1700
|
-
}
|
|
1701
|
-
return data;
|
|
1702
|
-
},
|
|
1710
|
+
select: memoizedSelect,
|
|
1703
1711
|
meta: {
|
|
1704
1712
|
...queryOptions == null ? void 0 : queryOptions.meta,
|
|
1705
1713
|
...getXRay10("useList", resource == null ? void 0 : resource.name)
|
|
@@ -4622,10 +4630,10 @@ var useSetLocale = /* @__PURE__ */ __name(() => {
|
|
|
4622
4630
|
}, "useSetLocale");
|
|
4623
4631
|
|
|
4624
4632
|
// src/hooks/i18n/useTranslate.ts
|
|
4625
|
-
import { useContext as useContext13, useMemo } from "react";
|
|
4633
|
+
import { useContext as useContext13, useMemo as useMemo2 } from "react";
|
|
4626
4634
|
var useTranslate = /* @__PURE__ */ __name(() => {
|
|
4627
4635
|
const { i18nProvider } = useContext13(I18nContext);
|
|
4628
|
-
const fn =
|
|
4636
|
+
const fn = useMemo2(() => {
|
|
4629
4637
|
function translate(key, options, defaultMessage) {
|
|
4630
4638
|
return (i18nProvider == null ? void 0 : i18nProvider.translate(key, options, defaultMessage)) ?? defaultMessage ?? (typeof options === "string" && typeof defaultMessage === "undefined" ? options : key);
|
|
4631
4639
|
}
|
|
@@ -4923,11 +4931,26 @@ var useForm = /* @__PURE__ */ __name((props = {}) => {
|
|
|
4923
4931
|
});
|
|
4924
4932
|
return submissionPromise;
|
|
4925
4933
|
}, "onFinish");
|
|
4926
|
-
const
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4934
|
+
const onFinishRef = React9.useRef(onFinish);
|
|
4935
|
+
React9.useEffect(() => {
|
|
4936
|
+
onFinishRef.current = onFinish;
|
|
4937
|
+
}, [onFinish]);
|
|
4938
|
+
const onFinishAutoSave = React9.useMemo(
|
|
4939
|
+
() => {
|
|
4940
|
+
var _a2;
|
|
4941
|
+
return asyncDebounce(
|
|
4942
|
+
(values) => onFinishRef.current(values, { isAutosave: true }),
|
|
4943
|
+
((_a2 = props.autoSave) == null ? void 0 : _a2.debounce) ?? 1e3,
|
|
4944
|
+
"Cancelled by debounce"
|
|
4945
|
+
);
|
|
4946
|
+
},
|
|
4947
|
+
[(_d = props.autoSave) == null ? void 0 : _d.debounce]
|
|
4930
4948
|
);
|
|
4949
|
+
React9.useEffect(() => {
|
|
4950
|
+
return () => {
|
|
4951
|
+
onFinishAutoSave.cancel();
|
|
4952
|
+
};
|
|
4953
|
+
}, [onFinishAutoSave]);
|
|
4931
4954
|
const overtime = {
|
|
4932
4955
|
elapsedTime
|
|
4933
4956
|
};
|
|
@@ -5017,7 +5040,7 @@ import React15, { useContext as useContext17 } from "react";
|
|
|
5017
5040
|
import React12 from "react";
|
|
5018
5041
|
|
|
5019
5042
|
// src/hooks/deepMemo/index.tsx
|
|
5020
|
-
import { useMemo as
|
|
5043
|
+
import { useMemo as useMemo3 } from "react";
|
|
5021
5044
|
|
|
5022
5045
|
// src/hooks/memoized/index.tsx
|
|
5023
5046
|
import { useRef } from "react";
|
|
@@ -5033,7 +5056,7 @@ var useMemoized = /* @__PURE__ */ __name((value) => {
|
|
|
5033
5056
|
// src/hooks/deepMemo/index.tsx
|
|
5034
5057
|
var useDeepMemo = /* @__PURE__ */ __name((fn, dependencies) => {
|
|
5035
5058
|
const memoizedDependencies = useMemoized(dependencies);
|
|
5036
|
-
const value =
|
|
5059
|
+
const value = useMemo3(fn, memoizedDependencies);
|
|
5037
5060
|
return value;
|
|
5038
5061
|
}, "useDeepMemo");
|
|
5039
5062
|
|
|
@@ -5822,7 +5845,7 @@ var useCanWithoutCache = /* @__PURE__ */ __name(() => {
|
|
|
5822
5845
|
}, "useCanWithoutCache");
|
|
5823
5846
|
|
|
5824
5847
|
// src/hooks/useSelect/index.ts
|
|
5825
|
-
import { useCallback as useCallback9, useEffect as useEffect11, useMemo as
|
|
5848
|
+
import { useCallback as useCallback9, useEffect as useEffect11, useMemo as useMemo4, useRef as useRef2, useState as useState7 } from "react";
|
|
5826
5849
|
import debounce2 from "lodash-es/debounce.js";
|
|
5827
5850
|
import get from "lodash-es/get.js";
|
|
5828
5851
|
import uniqBy from "lodash-es/uniqBy.js";
|
|
@@ -5942,7 +5965,7 @@ var useSelect = /* @__PURE__ */ __name((props) => {
|
|
|
5942
5965
|
...overtimeOptions,
|
|
5943
5966
|
isLoading: queryResult.query.isFetching || defaultValueQueryResult.query.isFetching
|
|
5944
5967
|
});
|
|
5945
|
-
const combinedOptions =
|
|
5968
|
+
const combinedOptions = useMemo4(
|
|
5946
5969
|
() => uniqBy(
|
|
5947
5970
|
selectedOptionsOrder === "in-place" ? [...options, ...selectedOptions] : [...selectedOptions, ...options],
|
|
5948
5971
|
"value"
|
|
@@ -5950,7 +5973,7 @@ var useSelect = /* @__PURE__ */ __name((props) => {
|
|
|
5950
5973
|
[options, selectedOptions]
|
|
5951
5974
|
);
|
|
5952
5975
|
const onSearchFromPropRef = useRef2(onSearchFromProp);
|
|
5953
|
-
const onSearch =
|
|
5976
|
+
const onSearch = useMemo4(() => {
|
|
5954
5977
|
return debounce2((value) => {
|
|
5955
5978
|
if (onSearchFromPropRef.current) {
|
|
5956
5979
|
setSearch(onSearchFromPropRef.current(value));
|
|
@@ -6536,7 +6559,7 @@ var useMenu = /* @__PURE__ */ __name(({ meta, hideOnMissingParameter = true } =
|
|
|
6536
6559
|
import React26, {
|
|
6537
6560
|
createContext as createContext4,
|
|
6538
6561
|
useContext as useContext25,
|
|
6539
|
-
useMemo as
|
|
6562
|
+
useMemo as useMemo5
|
|
6540
6563
|
} from "react";
|
|
6541
6564
|
var MetaContext = createContext4({});
|
|
6542
6565
|
var MetaContextProvider = /* @__PURE__ */ __name(({
|
|
@@ -6544,7 +6567,7 @@ var MetaContextProvider = /* @__PURE__ */ __name(({
|
|
|
6544
6567
|
value
|
|
6545
6568
|
}) => {
|
|
6546
6569
|
const currentValue = useMetaContext();
|
|
6547
|
-
const metaContext =
|
|
6570
|
+
const metaContext = useMemo5(() => {
|
|
6548
6571
|
return {
|
|
6549
6572
|
...currentValue,
|
|
6550
6573
|
...value
|
|
@@ -8064,7 +8087,7 @@ import React39 from "react";
|
|
|
8064
8087
|
|
|
8065
8088
|
// src/hooks/useTelemetryData/index.ts
|
|
8066
8089
|
import { useContext as useContext26 } from "react";
|
|
8067
|
-
var REFINE_VERSION = "5.0.
|
|
8090
|
+
var REFINE_VERSION = "5.0.6";
|
|
8068
8091
|
var useTelemetryData = /* @__PURE__ */ __name(() => {
|
|
8069
8092
|
var _a;
|
|
8070
8093
|
const auth = useIsExistAuthentication();
|