@refinedev/core 5.0.5 → 5.0.7
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 +20 -0
- package/dist/components/containers/refine/index.d.cts.map +1 -1
- package/dist/components/containers/refine/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/contexts/refine/types.d.cts +2 -0
- package/dist/contexts/refine/types.d.cts.map +1 -1
- package/dist/contexts/refine/types.d.mts +2 -0
- package/dist/contexts/refine/types.d.mts.map +2 -0
- package/dist/contexts/refine/types.d.ts +2 -0
- package/dist/contexts/refine/types.d.ts.map +1 -1
- package/dist/definitions/helpers/handleRefineOptions/index.d.cts +2 -1
- package/dist/definitions/helpers/handleRefineOptions/index.d.cts.map +1 -1
- package/dist/definitions/helpers/handleRefineOptions/index.d.mts +2 -1
- package/dist/definitions/helpers/handleRefineOptions/index.d.mts.map +2 -1
- package/dist/definitions/helpers/handleRefineOptions/index.d.ts +2 -1
- package/dist/definitions/helpers/handleRefineOptions/index.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/form/index.d.cts.map +1 -1
- package/dist/hooks/form/index.d.ts.map +1 -1
- package/dist/index.cjs +483 -456
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +63 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/containers/refine/index.tsx +6 -1
- package/src/contexts/refine/index.tsx +1 -0
- package/src/contexts/refine/types.ts +2 -0
- package/src/definitions/helpers/handleRefineOptions/index.ts +6 -0
- package/src/hooks/data/useList.ts +34 -22
- package/src/hooks/form/index.ts +20 -4
package/dist/index.mjs
CHANGED
|
@@ -321,6 +321,7 @@ var defaultRefineOptions = {
|
|
|
321
321
|
singular: pluralize.singular
|
|
322
322
|
},
|
|
323
323
|
disableServerSideValidation: false,
|
|
324
|
+
disableRouteChangeHandler: false,
|
|
324
325
|
title: defaultTitle
|
|
325
326
|
};
|
|
326
327
|
var RefineContext = React2.createContext({
|
|
@@ -370,7 +371,8 @@ var handleRefineOptions = /* @__PURE__ */ __name(({
|
|
|
370
371
|
reactQueryDevtoolConfig,
|
|
371
372
|
syncWithLocation,
|
|
372
373
|
undoableTimeout,
|
|
373
|
-
warnWhenUnsavedChanges
|
|
374
|
+
warnWhenUnsavedChanges,
|
|
375
|
+
disableRouteChangeHandler
|
|
374
376
|
} = {}) => {
|
|
375
377
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
376
378
|
const optionsWithDefaults = {
|
|
@@ -396,7 +398,8 @@ var handleRefineOptions = /* @__PURE__ */ __name(({
|
|
|
396
398
|
title: {
|
|
397
399
|
icon: typeof ((_g = options == null ? void 0 : options.title) == null ? void 0 : _g.icon) === "undefined" ? defaultRefineOptions.title.icon : (_h = options == null ? void 0 : options.title) == null ? void 0 : _h.icon,
|
|
398
400
|
text: typeof ((_i = options == null ? void 0 : options.title) == null ? void 0 : _i.text) === "undefined" ? defaultRefineOptions.title.text : (_j = options == null ? void 0 : options.title) == null ? void 0 : _j.text
|
|
399
|
-
}
|
|
401
|
+
},
|
|
402
|
+
disableRouteChangeHandler: (options == null ? void 0 : options.disableRouteChangeHandler) ?? disableRouteChangeHandler ?? defaultRefineOptions.disableRouteChangeHandler
|
|
400
403
|
};
|
|
401
404
|
const disableTelemetryWithDefault = (options == null ? void 0 : options.disableTelemetry) ?? disableTelemetry ?? false;
|
|
402
405
|
const reactQueryWithDefaults = {
|
|
@@ -1538,6 +1541,7 @@ var useIsExistAuthentication = /* @__PURE__ */ __name(() => {
|
|
|
1538
1541
|
// src/hooks/data/useList.ts
|
|
1539
1542
|
import { useEffect as useEffect3 } from "react";
|
|
1540
1543
|
import { getXRay as getXRay10 } from "@refinedev/devtools-internal";
|
|
1544
|
+
import { useMemo } from "react";
|
|
1541
1545
|
import {
|
|
1542
1546
|
useQuery as useQuery4
|
|
1543
1547
|
} from "@tanstack/react-query";
|
|
@@ -1655,6 +1659,31 @@ var useList = /* @__PURE__ */ __name(({
|
|
|
1655
1659
|
dataProviderName: pickedDataProvider
|
|
1656
1660
|
}
|
|
1657
1661
|
});
|
|
1662
|
+
const memoizedSelect = useMemo(() => {
|
|
1663
|
+
return (rawData) => {
|
|
1664
|
+
var _a2;
|
|
1665
|
+
let data = rawData;
|
|
1666
|
+
if (prefferedPagination.mode === "client") {
|
|
1667
|
+
data = {
|
|
1668
|
+
...data,
|
|
1669
|
+
data: data.data.slice(
|
|
1670
|
+
(prefferedPagination.currentPage - 1) * prefferedPagination.pageSize,
|
|
1671
|
+
prefferedPagination.currentPage * prefferedPagination.pageSize
|
|
1672
|
+
),
|
|
1673
|
+
total: data.total
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
if (queryOptions == null ? void 0 : queryOptions.select) {
|
|
1677
|
+
return (_a2 = queryOptions == null ? void 0 : queryOptions.select) == null ? void 0 : _a2.call(queryOptions, data);
|
|
1678
|
+
}
|
|
1679
|
+
return data;
|
|
1680
|
+
};
|
|
1681
|
+
}, [
|
|
1682
|
+
prefferedPagination.currentPage,
|
|
1683
|
+
prefferedPagination.pageSize,
|
|
1684
|
+
prefferedPagination.mode,
|
|
1685
|
+
queryOptions == null ? void 0 : queryOptions.select
|
|
1686
|
+
]);
|
|
1658
1687
|
const queryResponse = useQuery4({
|
|
1659
1688
|
queryKey: keys2().data(pickedDataProvider).resource(identifier ?? "").action("list").params({
|
|
1660
1689
|
...preferredMeta || {},
|
|
@@ -1681,25 +1710,7 @@ var useList = /* @__PURE__ */ __name(({
|
|
|
1681
1710
|
},
|
|
1682
1711
|
...queryOptions,
|
|
1683
1712
|
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
|
-
},
|
|
1713
|
+
select: memoizedSelect,
|
|
1703
1714
|
meta: {
|
|
1704
1715
|
...queryOptions == null ? void 0 : queryOptions.meta,
|
|
1705
1716
|
...getXRay10("useList", resource == null ? void 0 : resource.name)
|
|
@@ -4622,10 +4633,10 @@ var useSetLocale = /* @__PURE__ */ __name(() => {
|
|
|
4622
4633
|
}, "useSetLocale");
|
|
4623
4634
|
|
|
4624
4635
|
// src/hooks/i18n/useTranslate.ts
|
|
4625
|
-
import { useContext as useContext13, useMemo } from "react";
|
|
4636
|
+
import { useContext as useContext13, useMemo as useMemo2 } from "react";
|
|
4626
4637
|
var useTranslate = /* @__PURE__ */ __name(() => {
|
|
4627
4638
|
const { i18nProvider } = useContext13(I18nContext);
|
|
4628
|
-
const fn =
|
|
4639
|
+
const fn = useMemo2(() => {
|
|
4629
4640
|
function translate(key, options, defaultMessage) {
|
|
4630
4641
|
return (i18nProvider == null ? void 0 : i18nProvider.translate(key, options, defaultMessage)) ?? defaultMessage ?? (typeof options === "string" && typeof defaultMessage === "undefined" ? options : key);
|
|
4631
4642
|
}
|
|
@@ -4923,11 +4934,26 @@ var useForm = /* @__PURE__ */ __name((props = {}) => {
|
|
|
4923
4934
|
});
|
|
4924
4935
|
return submissionPromise;
|
|
4925
4936
|
}, "onFinish");
|
|
4926
|
-
const
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4937
|
+
const onFinishRef = React9.useRef(onFinish);
|
|
4938
|
+
React9.useEffect(() => {
|
|
4939
|
+
onFinishRef.current = onFinish;
|
|
4940
|
+
}, [onFinish]);
|
|
4941
|
+
const onFinishAutoSave = React9.useMemo(
|
|
4942
|
+
() => {
|
|
4943
|
+
var _a2;
|
|
4944
|
+
return asyncDebounce(
|
|
4945
|
+
(values) => onFinishRef.current(values, { isAutosave: true }),
|
|
4946
|
+
((_a2 = props.autoSave) == null ? void 0 : _a2.debounce) ?? 1e3,
|
|
4947
|
+
"Cancelled by debounce"
|
|
4948
|
+
);
|
|
4949
|
+
},
|
|
4950
|
+
[(_d = props.autoSave) == null ? void 0 : _d.debounce]
|
|
4930
4951
|
);
|
|
4952
|
+
React9.useEffect(() => {
|
|
4953
|
+
return () => {
|
|
4954
|
+
onFinishAutoSave.cancel();
|
|
4955
|
+
};
|
|
4956
|
+
}, [onFinishAutoSave]);
|
|
4931
4957
|
const overtime = {
|
|
4932
4958
|
elapsedTime
|
|
4933
4959
|
};
|
|
@@ -5017,7 +5043,7 @@ import React15, { useContext as useContext17 } from "react";
|
|
|
5017
5043
|
import React12 from "react";
|
|
5018
5044
|
|
|
5019
5045
|
// src/hooks/deepMemo/index.tsx
|
|
5020
|
-
import { useMemo as
|
|
5046
|
+
import { useMemo as useMemo3 } from "react";
|
|
5021
5047
|
|
|
5022
5048
|
// src/hooks/memoized/index.tsx
|
|
5023
5049
|
import { useRef } from "react";
|
|
@@ -5033,7 +5059,7 @@ var useMemoized = /* @__PURE__ */ __name((value) => {
|
|
|
5033
5059
|
// src/hooks/deepMemo/index.tsx
|
|
5034
5060
|
var useDeepMemo = /* @__PURE__ */ __name((fn, dependencies) => {
|
|
5035
5061
|
const memoizedDependencies = useMemoized(dependencies);
|
|
5036
|
-
const value =
|
|
5062
|
+
const value = useMemo3(fn, memoizedDependencies);
|
|
5037
5063
|
return value;
|
|
5038
5064
|
}, "useDeepMemo");
|
|
5039
5065
|
|
|
@@ -5822,7 +5848,7 @@ var useCanWithoutCache = /* @__PURE__ */ __name(() => {
|
|
|
5822
5848
|
}, "useCanWithoutCache");
|
|
5823
5849
|
|
|
5824
5850
|
// src/hooks/useSelect/index.ts
|
|
5825
|
-
import { useCallback as useCallback9, useEffect as useEffect11, useMemo as
|
|
5851
|
+
import { useCallback as useCallback9, useEffect as useEffect11, useMemo as useMemo4, useRef as useRef2, useState as useState7 } from "react";
|
|
5826
5852
|
import debounce2 from "lodash-es/debounce.js";
|
|
5827
5853
|
import get from "lodash-es/get.js";
|
|
5828
5854
|
import uniqBy from "lodash-es/uniqBy.js";
|
|
@@ -5942,7 +5968,7 @@ var useSelect = /* @__PURE__ */ __name((props) => {
|
|
|
5942
5968
|
...overtimeOptions,
|
|
5943
5969
|
isLoading: queryResult.query.isFetching || defaultValueQueryResult.query.isFetching
|
|
5944
5970
|
});
|
|
5945
|
-
const combinedOptions =
|
|
5971
|
+
const combinedOptions = useMemo4(
|
|
5946
5972
|
() => uniqBy(
|
|
5947
5973
|
selectedOptionsOrder === "in-place" ? [...options, ...selectedOptions] : [...selectedOptions, ...options],
|
|
5948
5974
|
"value"
|
|
@@ -5950,7 +5976,7 @@ var useSelect = /* @__PURE__ */ __name((props) => {
|
|
|
5950
5976
|
[options, selectedOptions]
|
|
5951
5977
|
);
|
|
5952
5978
|
const onSearchFromPropRef = useRef2(onSearchFromProp);
|
|
5953
|
-
const onSearch =
|
|
5979
|
+
const onSearch = useMemo4(() => {
|
|
5954
5980
|
return debounce2((value) => {
|
|
5955
5981
|
if (onSearchFromPropRef.current) {
|
|
5956
5982
|
setSearch(onSearchFromPropRef.current(value));
|
|
@@ -6536,7 +6562,7 @@ var useMenu = /* @__PURE__ */ __name(({ meta, hideOnMissingParameter = true } =
|
|
|
6536
6562
|
import React26, {
|
|
6537
6563
|
createContext as createContext4,
|
|
6538
6564
|
useContext as useContext25,
|
|
6539
|
-
useMemo as
|
|
6565
|
+
useMemo as useMemo5
|
|
6540
6566
|
} from "react";
|
|
6541
6567
|
var MetaContext = createContext4({});
|
|
6542
6568
|
var MetaContextProvider = /* @__PURE__ */ __name(({
|
|
@@ -6544,7 +6570,7 @@ var MetaContextProvider = /* @__PURE__ */ __name(({
|
|
|
6544
6570
|
value
|
|
6545
6571
|
}) => {
|
|
6546
6572
|
const currentValue = useMetaContext();
|
|
6547
|
-
const metaContext =
|
|
6573
|
+
const metaContext = useMemo5(() => {
|
|
6548
6574
|
return {
|
|
6549
6575
|
...currentValue,
|
|
6550
6576
|
...value
|
|
@@ -8064,7 +8090,7 @@ import React39 from "react";
|
|
|
8064
8090
|
|
|
8065
8091
|
// src/hooks/useTelemetryData/index.ts
|
|
8066
8092
|
import { useContext as useContext26 } from "react";
|
|
8067
|
-
var REFINE_VERSION = "5.0.
|
|
8093
|
+
var REFINE_VERSION = "5.0.7";
|
|
8068
8094
|
var useTelemetryData = /* @__PURE__ */ __name(() => {
|
|
8069
8095
|
var _a;
|
|
8070
8096
|
const auth = useIsExistAuthentication();
|
|
@@ -8203,6 +8229,7 @@ var Refine = /* @__PURE__ */ __name(({
|
|
|
8203
8229
|
} = handleRefineOptions({
|
|
8204
8230
|
options
|
|
8205
8231
|
});
|
|
8232
|
+
const disableRouteChangeHandler = optionsWithDefaults.disableRouteChangeHandler;
|
|
8206
8233
|
const queryClient = useDeepMemo(() => {
|
|
8207
8234
|
var _a;
|
|
8208
8235
|
if (reactQueryWithDefaults.clientConfig instanceof QueryClient) {
|
|
@@ -8248,7 +8275,7 @@ var Refine = /* @__PURE__ */ __name(({
|
|
|
8248
8275
|
onLiveEvent,
|
|
8249
8276
|
options: optionsWithDefaults
|
|
8250
8277
|
},
|
|
8251
|
-
/* @__PURE__ */ React41.createElement(UnsavedWarnContextProvider, null, /* @__PURE__ */ React41.createElement(React41.Fragment, null, children, !disableTelemetryWithDefault && /* @__PURE__ */ React41.createElement(Telemetry, null), /* @__PURE__ */ React41.createElement(RouteChangeHandler, null)))
|
|
8278
|
+
/* @__PURE__ */ React41.createElement(UnsavedWarnContextProvider, null, /* @__PURE__ */ React41.createElement(React41.Fragment, null, children, !disableTelemetryWithDefault && /* @__PURE__ */ React41.createElement(Telemetry, null), !disableRouteChangeHandler && /* @__PURE__ */ React41.createElement(RouteChangeHandler, null)))
|
|
8252
8279
|
)))
|
|
8253
8280
|
))))))
|
|
8254
8281
|
)));
|