@refinedev/core 4.51.0 → 4.52.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 +31 -0
- package/LICENSE +21 -0
- package/dist/components/authenticated/index.d.mts.map +75 -1
- package/dist/components/autoSaveIndicator/index.d.cts.map +1 -1
- package/dist/components/autoSaveIndicator/index.d.mts.map +24 -1
- package/dist/components/autoSaveIndicator/index.d.ts.map +1 -1
- package/dist/components/canAccess/index.d.mts.map +52 -1
- package/dist/components/containers/index.d.mts.map +2 -1
- package/dist/components/containers/refine/index.d.mts.map +11 -1
- package/dist/components/gh-banner/index.d.mts.map +7 -1
- package/dist/components/gh-banner/styles.d.mts.map +2 -1
- package/dist/components/index.d.mts.map +10 -1
- package/dist/components/layoutWrapper/defaultLayout/index.d.mts.map +4 -1
- package/dist/components/layoutWrapper/index.d.mts.map +46 -1
- package/dist/components/pages/auth/components/forgotPassword/index.d.mts.map +7 -1
- package/dist/components/pages/auth/components/index.d.mts.map +5 -1
- package/dist/components/pages/auth/components/login/index.d.mts.map +7 -1
- package/dist/components/pages/auth/components/register/index.d.mts.map +7 -1
- package/dist/components/pages/auth/components/updatePassword/index.d.mts.map +7 -1
- package/dist/components/pages/auth/index.d.mts.map +12 -1
- package/dist/components/pages/auth/types.d.mts.map +179 -1
- package/dist/components/pages/config-error/index.d.mts.map +3 -1
- package/dist/components/pages/config-success/index.d.mts.map +6 -1
- package/dist/components/pages/error/index.d.mts.map +9 -1
- package/dist/components/pages/index.d.mts.map +7 -1
- package/dist/components/pages/login/index.d.mts.map +13 -1
- package/dist/components/pages/ready/index.d.mts.map +8 -1
- package/dist/components/pages/welcome/index.d.mts.map +3 -1
- package/dist/components/routeChangeHandler/index.d.mts.map +3 -1
- package/dist/components/telemetry/index.d.mts.map +3 -1
- package/dist/components/telemetry/types.d.mts.map +16 -1
- package/dist/components/undoableQueue/index.d.mts.map +6 -1
- package/dist/contexts/accessControl/index.d.mts.map +7 -1
- package/dist/contexts/accessControl/types.d.mts.map +84 -1
- package/dist/contexts/auditLog/index.d.mts.map +5 -1
- package/dist/contexts/auditLog/types.d.mts.map +41 -1
- package/dist/contexts/auth/index.d.mts.map +18 -1
- package/dist/contexts/auth/types.d.mts.map +101 -1
- package/dist/contexts/data/index.d.mts.map +10 -1
- package/dist/contexts/data/types.d.mts.map +347 -1
- package/dist/contexts/i18n/index.d.mts.map +7 -1
- package/dist/contexts/i18n/types.d.mts.map +13 -1
- package/dist/contexts/live/index.d.mts.map +5 -1
- package/dist/contexts/live/types.d.mts.map +96 -1
- package/dist/contexts/notification/index.d.mts.map +7 -1
- package/dist/contexts/notification/types.d.mts.map +27 -1
- package/dist/contexts/refine/index.d.mts.map +6 -1
- package/dist/contexts/refine/types.d.mts.map +325 -1
- package/dist/contexts/resource/index.d.mts.map +7 -1
- package/dist/contexts/resource/types.d.mts.map +168 -1
- package/dist/contexts/router/index.d.mts.map +7 -1
- package/dist/contexts/router/legacy/index.d.mts.map +6 -1
- package/dist/contexts/router/legacy/types.d.mts.map +47 -1
- package/dist/contexts/router/picker/index.d.mts.map +15 -1
- package/dist/contexts/router/types.d.mts.map +67 -1
- package/dist/contexts/undoableQueue/index.d.mts.map +6 -1
- package/dist/contexts/undoableQueue/types.d.mts.map +21 -1
- package/dist/contexts/unsavedWarn/index.d.mts.map +5 -1
- package/dist/contexts/unsavedWarn/types.d.mts.map +5 -1
- package/dist/definitions/helpers/async-debounce/index.d.mts.map +18 -1
- package/dist/definitions/helpers/check-router-prop-misuse/index.d.mts.map +4 -1
- package/dist/definitions/helpers/defer-execution/index.d.mts.map +9 -1
- package/dist/definitions/helpers/downloadInBrowser/index.d.mts.map +2 -1
- package/dist/definitions/helpers/flatten-object-keys/index.d.mts.map +4 -1
- package/dist/definitions/helpers/generateDocumentTitle/index.d.mts.map +7 -1
- package/dist/definitions/helpers/handleMultiple/index.d.mts.map +6 -1
- package/dist/definitions/helpers/handlePaginationParams/index.d.mts.map +9 -1
- package/dist/definitions/helpers/handleRefineOptions/index.d.mts.map +26 -1
- package/dist/definitions/helpers/handleUseParams/index.d.mts.map +2 -1
- package/dist/definitions/helpers/hasPermission/index.d.mts.map +2 -1
- package/dist/definitions/helpers/humanizeString/index.d.mts.map +2 -1
- package/dist/definitions/helpers/importCSVMapper/index.d.mts.map +3 -1
- package/dist/definitions/helpers/index.d.mts.map +34 -1
- package/dist/definitions/helpers/keys/index.d.mts.map +64 -1
- package/dist/definitions/helpers/legacy-resource-transform/index.d.mts.map +9 -1
- package/dist/definitions/helpers/menu/create-resource-key.d.mts.map +3 -1
- package/dist/definitions/helpers/menu/create-tree.d.mts.map +13 -1
- package/dist/definitions/helpers/pick-resource/index.d.mts.map +8 -1
- package/dist/definitions/helpers/pickDataProvider/index.d.mts.map +6 -1
- package/dist/definitions/helpers/pickNotDeprecated/index.d.mts.map +2 -1
- package/dist/definitions/helpers/prepare-query-context/index.d.mts.map +3 -1
- package/dist/definitions/helpers/property-path-to-array/index.d.mts.map +2 -1
- package/dist/definitions/helpers/queryKeys/index.d.mts.map +7 -1
- package/dist/definitions/helpers/redirectPage/index.d.mts.map +11 -1
- package/dist/definitions/helpers/routeGenerator/index.d.mts.map +7 -1
- package/dist/definitions/helpers/router/check-by-segments.d.mts.map +9 -1
- package/dist/definitions/helpers/router/compose-route.d.mts.map +11 -1
- package/dist/definitions/helpers/router/get-action-routes-from-resource.d.mts.map +16 -1
- package/dist/definitions/helpers/router/get-default-action-path.d.mts.map +8 -1
- package/dist/definitions/helpers/router/get-parent-prefix-for-resource.d.mts.map +7 -1
- package/dist/definitions/helpers/router/get-parent-resource.d.mts.map +7 -1
- package/dist/definitions/helpers/router/index.d.mts.map +10 -1
- package/dist/definitions/helpers/router/is-parameter.d.mts.map +5 -1
- package/dist/definitions/helpers/router/is-segment-counts-same.d.mts.map +5 -1
- package/dist/definitions/helpers/router/match-resource-from-route.d.mts.map +15 -1
- package/dist/definitions/helpers/router/pick-matched-route.d.mts.map +8 -1
- package/dist/definitions/helpers/router/pick-route-params.d.mts.map +6 -1
- package/dist/definitions/helpers/router/prepare-route-params.d.mts.map +8 -1
- package/dist/definitions/helpers/router/remove-leading-trailing-slashes.d.mts.map +5 -1
- package/dist/definitions/helpers/router/split-to-segments.d.mts.map +5 -1
- package/dist/definitions/helpers/safe-translate/index.d.mts.map +3 -1
- package/dist/definitions/helpers/sanitize-resource/index.d.mts.map +8 -1
- package/dist/definitions/helpers/sequentialPromises/index.d.mts.map +5 -1
- package/dist/definitions/helpers/treeView/createTreeView/index.d.mts.map +6 -1
- package/dist/definitions/helpers/treeView/index.d.mts.map +2 -1
- package/dist/definitions/helpers/useActiveAuthProvider/index.d.cts +7 -7
- package/dist/definitions/helpers/useActiveAuthProvider/index.d.mts +7 -7
- package/dist/definitions/helpers/useActiveAuthProvider/index.d.mts.map +34 -1
- package/dist/definitions/helpers/useActiveAuthProvider/index.d.ts +7 -7
- package/dist/definitions/helpers/useInfinitePagination/index.d.mts.map +4 -1
- package/dist/definitions/helpers/useMediaQuery/index.d.mts.map +2 -1
- package/dist/definitions/helpers/useUserFriendlyName/index.d.mts.map +6 -1
- package/dist/definitions/helpers/userFriendlyResourceName/index.d.mts.map +7 -1
- package/dist/definitions/helpers/userFriendlySeconds/index.d.mts.map +2 -1
- package/dist/definitions/index.d.mts.map +4 -1
- package/dist/definitions/table/index.d.mts.map +34 -1
- package/dist/definitions/upload/file2Base64/index.d.mts.map +2 -1
- package/dist/definitions/upload/index.d.mts.map +2 -1
- package/dist/hooks/accessControl/index.d.mts.map +3 -1
- package/dist/hooks/accessControl/useCan/index.d.mts.map +18 -1
- package/dist/hooks/accessControl/useCanWithoutCache.d.mts.map +3 -1
- package/dist/hooks/auditLog/index.d.mts.map +3 -1
- package/dist/hooks/auditLog/useLog/index.d.mts.map +27 -1
- package/dist/hooks/auditLog/useLogList/index.d.mts.map +22 -1
- package/dist/hooks/auth/index.d.mts.map +11 -1
- package/dist/hooks/auth/useForgotPassword/index.d.mts.map +22 -1
- package/dist/hooks/auth/useGetIdentity/index.d.mts.map +21 -1
- package/dist/hooks/auth/useInvalidateAuthStore/index.d.mts.map +2 -1
- package/dist/hooks/auth/useIsAuthenticated/index.d.mts.map +25 -1
- package/dist/hooks/auth/useIsExistAuthentication/index.d.mts.map +6 -1
- package/dist/hooks/auth/useLogin/index.d.mts.map +22 -1
- package/dist/hooks/auth/useLogout/index.d.mts.map +26 -1
- package/dist/hooks/auth/useOnError/index.d.mts.map +22 -1
- package/dist/hooks/auth/usePermissions/index.d.mts.map +24 -1
- package/dist/hooks/auth/useRegister/index.d.mts.map +22 -1
- package/dist/hooks/auth/useUpdatePassword/index.d.mts.map +23 -1
- package/dist/hooks/breadcrumb/index.d.mts.map +18 -1
- package/dist/hooks/button/actionable-button/index.d.mts.map +8 -1
- package/dist/hooks/button/button-can-access/index.d.mts.map +22 -1
- package/dist/hooks/button/delete-button/index.d.mts.map +28 -1
- package/dist/hooks/button/index.d.mts.map +13 -1
- package/dist/hooks/button/navigation-button/index.d.mts.map +28 -1
- package/dist/hooks/button/refresh-button/index.d.mts.map +14 -1
- package/dist/hooks/data/index.d.cts +12 -12
- package/dist/hooks/data/index.d.cts.map +1 -1
- package/dist/hooks/data/index.d.mts +12 -12
- package/dist/hooks/data/index.d.mts.map +15 -1
- package/dist/hooks/data/index.d.ts +12 -12
- package/dist/hooks/data/index.d.ts.map +1 -1
- package/dist/hooks/data/useApiUrl.d.mts.map +2 -1
- package/dist/hooks/data/useCreate.d.mts.map +49 -1
- package/dist/hooks/data/useCreateMany.d.mts.map +31 -1
- package/dist/hooks/data/useCustom.d.mts.map +63 -1
- package/dist/hooks/data/useCustomMutation.d.mts.map +42 -1
- package/dist/hooks/data/useDataProvider.d.mts.map +7 -1
- package/dist/hooks/data/useDelete.d.mts.map +65 -1
- package/dist/hooks/data/useDeleteMany.d.mts.map +65 -1
- package/dist/hooks/data/useInfiniteList.d.mts.map +74 -1
- package/dist/hooks/data/useList.d.mts.map +73 -1
- package/dist/hooks/data/useMany.d.mts.map +48 -1
- package/dist/hooks/data/useOne.d.mts.map +50 -1
- package/dist/hooks/data/useUpdate.d.mts.map +83 -1
- package/dist/hooks/data/useUpdateMany.d.cts +1 -1
- package/dist/hooks/data/useUpdateMany.d.cts.map +1 -1
- package/dist/hooks/data/useUpdateMany.d.mts +1 -1
- package/dist/hooks/data/useUpdateMany.d.mts.map +84 -1
- package/dist/hooks/data/useUpdateMany.d.ts +1 -1
- package/dist/hooks/data/useUpdateMany.d.ts.map +1 -1
- package/dist/hooks/deepMemo/index.d.mts.map +7 -1
- package/dist/hooks/export/index.d.mts.map +99 -1
- package/dist/hooks/export/types.d.mts.map +21 -1
- package/dist/hooks/form/index.d.mts.map +18 -1
- package/dist/hooks/form/types.d.mts.map +146 -1
- package/dist/hooks/i18n/index.d.mts.map +5 -1
- package/dist/hooks/i18n/useGetLocale.d.mts.map +9 -1
- package/dist/hooks/i18n/useSetLocale.d.mts.map +8 -1
- package/dist/hooks/i18n/useTranslate.d.mts.map +11 -1
- package/dist/hooks/i18n/useTranslation.d.mts.map +18 -1
- package/dist/hooks/import/index.d.mts.map +101 -1
- package/dist/hooks/index.d.mts.map +31 -1
- package/dist/hooks/invalidate/index.d.mts.map +12 -1
- package/dist/hooks/legacy-router/index.d.mts.map +2 -1
- package/dist/hooks/legacy-router/useRouterContext.d.mts.map +10 -1
- package/dist/hooks/live/index.d.mts.map +5 -1
- package/dist/hooks/live/useLiveMode/index.d.mts.map +3 -1
- package/dist/hooks/live/usePublish/index.d.mts.map +3 -1
- package/dist/hooks/live/useResourceSubscription/index.d.mts.map +43 -1
- package/dist/hooks/live/useSubscription/index.d.mts.map +57 -1
- package/dist/hooks/memoized/index.d.mts.map +6 -1
- package/dist/hooks/menu/index.d.mts.map +2 -1
- package/dist/hooks/menu/useMenu.d.mts.map +28 -1
- package/dist/hooks/modal/index.d.mts.map +2 -1
- package/dist/hooks/modal/useModal/index.d.mts.map +13 -1
- package/dist/hooks/navigation/index.d.mts.map +28 -1
- package/dist/hooks/notification/index.d.mts.map +4 -1
- package/dist/hooks/notification/useCancelNotification/index.d.mts.map +8 -1
- package/dist/hooks/notification/useHandleNotification/index.d.mts.map +3 -1
- package/dist/hooks/notification/useNotification/index.d.mts.map +3 -1
- package/dist/hooks/redirection/index.d.mts.map +11 -1
- package/dist/hooks/refine/index.d.mts.map +6 -1
- package/dist/hooks/refine/useMutationMode.d.mts.map +16 -1
- package/dist/hooks/refine/useRefineContext.d.cts +1 -1
- package/dist/hooks/refine/useRefineContext.d.mts +1 -1
- package/dist/hooks/refine/useRefineContext.d.mts.map +20 -1
- package/dist/hooks/refine/useRefineContext.d.ts +1 -1
- package/dist/hooks/refine/useSyncWithLocation.d.mts.map +13 -1
- package/dist/hooks/refine/useTitle.d.mts.map +10 -1
- package/dist/hooks/refine/useWarnAboutChange/index.d.mts.map +16 -1
- package/dist/hooks/resource/index.d.mts.map +3 -1
- package/dist/hooks/resource/useResource/index.d.mts.map +63 -1
- package/dist/hooks/resource/useResourceWithRoute/index.d.mts.map +8 -1
- package/dist/hooks/router/index.d.mts.map +8 -1
- package/dist/hooks/router/use-back/index.d.mts.map +2 -1
- package/dist/hooks/router/use-get-to-path/index.d.mts.map +19 -1
- package/dist/hooks/router/use-go/index.d.mts.map +33 -1
- package/dist/hooks/router/use-link/index.d.mts.map +6 -1
- package/dist/hooks/router/use-parse/index.d.mts.map +5 -1
- package/dist/hooks/router/use-parsed/index.d.mts.map +2 -1
- package/dist/hooks/router/use-router-misuse-warning/index.d.mts.map +3 -1
- package/dist/hooks/router/use-to-path/index.d.mts.map +18 -1
- package/dist/hooks/show/index.d.mts.map +17 -1
- package/dist/hooks/show/types.d.mts.map +52 -1
- package/dist/hooks/show/useShow.d.mts.map +57 -1
- package/dist/hooks/use-refine-options/index.d.mts.map +2 -1
- package/dist/hooks/use-resource-params/index.d.mts.map +43 -1
- package/dist/hooks/use-resource-params/use-action/index.d.mts.map +12 -1
- package/dist/hooks/use-resource-params/use-id/index.d.mts.map +12 -1
- package/dist/hooks/useKeys/index.d.mts.map +5 -1
- package/dist/hooks/useLoadingOvertime/index.d.mts.map +49 -1
- package/dist/hooks/useMeta/index.d.mts.map +19 -1
- package/dist/hooks/useSelect/index.d.cts +6 -0
- package/dist/hooks/useSelect/index.d.cts.map +1 -1
- package/dist/hooks/useSelect/index.d.mts +6 -0
- package/dist/hooks/useSelect/index.d.mts.map +137 -1
- package/dist/hooks/useSelect/index.d.ts +6 -0
- package/dist/hooks/useSelect/index.d.ts.map +1 -1
- package/dist/hooks/useTable/index.d.mts.map +167 -1
- package/dist/hooks/useTelemetryData/index.d.mts.map +3 -1
- package/dist/index.cjs +18 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -7
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +8 -7
- package/dist/index.d.mts.map +25 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +18 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -13
- package/src/components/autoSaveIndicator/index.tsx +21 -7
- package/src/hooks/data/index.ts +28 -12
- package/src/hooks/data/useUpdateMany.ts +1 -1
- package/src/hooks/useSelect/index.ts +15 -1
- package/src/index.tsx +39 -0
|
@@ -1 +1,84 @@
|
|
|
1
|
-
{
|
|
1
|
+
import { type UseMutationOptions, type UseMutationResult } from "@tanstack/react-query";
|
|
2
|
+
import type { BaseKey, BaseRecord, GetListResponse, GetManyResponse, GetOneResponse, HttpError, IQueryKeys, MetaQuery, MutationMode, PrevContext as UpdateContext, UpdateManyResponse } from "../../contexts/data/types";
|
|
3
|
+
import { type UseLoadingOvertimeOptionsProps, type UseLoadingOvertimeReturnType } from "../useLoadingOvertime";
|
|
4
|
+
import type { SuccessErrorNotification } from "../../contexts/notification/types";
|
|
5
|
+
export type OptimisticUpdateManyMapType<TData, TVariables> = {
|
|
6
|
+
list?: ((previous: GetListResponse<TData> | null | undefined, values: TVariables, ids: BaseKey[]) => GetListResponse<TData> | null) | boolean;
|
|
7
|
+
many?: ((previous: GetManyResponse<TData> | null | undefined, values: TVariables, ids: BaseKey[]) => GetManyResponse<TData> | null) | boolean;
|
|
8
|
+
detail?: ((previous: GetOneResponse<TData> | null | undefined, values: TVariables, id: BaseKey) => GetOneResponse<TData> | null) | boolean;
|
|
9
|
+
};
|
|
10
|
+
type UpdateManyParams<TData, TError, TVariables> = {
|
|
11
|
+
/**
|
|
12
|
+
* ids for mutation function
|
|
13
|
+
*/
|
|
14
|
+
ids: BaseKey[];
|
|
15
|
+
/**
|
|
16
|
+
* Resource name for API data interactions
|
|
17
|
+
*/
|
|
18
|
+
resource: string;
|
|
19
|
+
/**
|
|
20
|
+
* [Determines when mutations are executed](/advanced-tutorials/mutation-mode.md)
|
|
21
|
+
*/
|
|
22
|
+
mutationMode?: MutationMode;
|
|
23
|
+
/**
|
|
24
|
+
* Duration in ms to wait before executing the mutation when `mutationMode = "undoable"`
|
|
25
|
+
*/
|
|
26
|
+
undoableTimeout?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Provides a function to cancel the mutation when `mutationMode = "undoable"`
|
|
29
|
+
*/
|
|
30
|
+
onCancel?: (cancelMutation: () => void) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Values for mutation function
|
|
33
|
+
*/
|
|
34
|
+
values: TVariables;
|
|
35
|
+
/**
|
|
36
|
+
* meta data for `dataProvider`
|
|
37
|
+
*/
|
|
38
|
+
meta?: MetaQuery;
|
|
39
|
+
/**
|
|
40
|
+
* meta data for `dataProvider`
|
|
41
|
+
* @deprecated `metaData` is deprecated with refine@4, refine will pass `meta` instead, however, we still support `metaData` for backward compatibility.
|
|
42
|
+
*/
|
|
43
|
+
metaData?: MetaQuery;
|
|
44
|
+
/**
|
|
45
|
+
* If there is more than one `dataProvider`, you should use the `dataProviderName` that you will use.
|
|
46
|
+
* @default "default"
|
|
47
|
+
*/
|
|
48
|
+
dataProviderName?: string;
|
|
49
|
+
/**
|
|
50
|
+
* You can use it to manage the invalidations that will occur at the end of the mutation.
|
|
51
|
+
*/
|
|
52
|
+
invalidates?: Array<keyof IQueryKeys>;
|
|
53
|
+
/**
|
|
54
|
+
* You can use it to manage the invalidations that will occur at the end of the mutation.
|
|
55
|
+
* @default {
|
|
56
|
+
* list: true,
|
|
57
|
+
* many: true,
|
|
58
|
+
* detail: true,
|
|
59
|
+
* }
|
|
60
|
+
*/
|
|
61
|
+
optimisticUpdateMap?: OptimisticUpdateManyMapType<TData, TVariables>;
|
|
62
|
+
} & SuccessErrorNotification<UpdateManyResponse<TData>, TError, {
|
|
63
|
+
ids: BaseKey[];
|
|
64
|
+
values: TVariables;
|
|
65
|
+
}>;
|
|
66
|
+
export type UseUpdateManyReturnType<TData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}> = UseMutationResult<UpdateManyResponse<TData>, TError, UpdateManyParams<TData, TError, TVariables>, UpdateContext<TData>> & UseLoadingOvertimeReturnType;
|
|
67
|
+
export type UseUpdateManyProps<TData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}> = {
|
|
68
|
+
mutationOptions?: Omit<UseMutationOptions<UpdateManyResponse<TData>, TError, UpdateManyParams<TData, TError, TVariables>, UpdateContext<TData>>, "mutationFn" | "onError" | "onSuccess" | "onSettled" | "onMutate">;
|
|
69
|
+
} & UseLoadingOvertimeOptionsProps;
|
|
70
|
+
/**
|
|
71
|
+
* `useUpdateMany` is a modified version of `react-query`'s {@link https://react-query.tanstack.com/reference/useMutation `useMutation`} for multiple update mutations.
|
|
72
|
+
*
|
|
73
|
+
* It uses `updateMany` method as mutation function from the `dataProvider` which is passed to `<Refine>`.
|
|
74
|
+
*
|
|
75
|
+
* @see {@link https://refine.dev/docs/api-reference/core/hooks/data/useUpdateMany} for more details.
|
|
76
|
+
*
|
|
77
|
+
* @typeParam TData - Result data of the query extends {@link https://refine.dev/docs/core/interfaceReferences#baserecord `BaseRecord`}
|
|
78
|
+
* @typeParam TError - Custom error object that extends {@link https://refine.dev/docs/core/interfaceReferences#httperror `HttpError`}
|
|
79
|
+
* @typeParam TVariables - Values for mutation function
|
|
80
|
+
*
|
|
81
|
+
*/
|
|
82
|
+
export declare const useUpdateMany: <TData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}>({ mutationOptions, overtimeOptions, }?: UseUpdateManyProps<TData, TError, TVariables>) => UseUpdateManyReturnType<TData, TError, TVariables>;
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=useUpdateMany.d.ts.map
|
|
@@ -63,7 +63,7 @@ type UpdateManyParams<TData, TError, TVariables> = {
|
|
|
63
63
|
ids: BaseKey[];
|
|
64
64
|
values: TVariables;
|
|
65
65
|
}>;
|
|
66
|
-
type UseUpdateManyReturnType<TData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}> = UseMutationResult<UpdateManyResponse<TData>, TError, UpdateManyParams<TData, TError, TVariables>, UpdateContext<TData>> & UseLoadingOvertimeReturnType;
|
|
66
|
+
export type UseUpdateManyReturnType<TData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}> = UseMutationResult<UpdateManyResponse<TData>, TError, UpdateManyParams<TData, TError, TVariables>, UpdateContext<TData>> & UseLoadingOvertimeReturnType;
|
|
67
67
|
export type UseUpdateManyProps<TData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}> = {
|
|
68
68
|
mutationOptions?: Omit<UseMutationOptions<UpdateManyResponse<TData>, TError, UpdateManyParams<TData, TError, TVariables>, UpdateContext<TData>>, "mutationFn" | "onError" | "onSuccess" | "onSettled" | "onMutate">;
|
|
69
69
|
} & UseLoadingOvertimeOptionsProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUpdateMany.d.ts","sourceRoot":"","sources":["../../../src/hooks/data/useUpdateMany.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAGvB,MAAM,uBAA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IACtC;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,2BAA2B,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;CACtE,GAAG,wBAAwB,CAC1B,kBAAkB,CAAC,KAAK,CAAC,EACzB,MAAM,EACN;IAAE,GAAG,EAAE,OAAO,EAAE,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CACvC,CAAC;AAEF,MAAM,MAAM,uBAAuB,CACjC,KAAK,SAAS,UAAU,GAAG,UAAU,EACrC,MAAM,SAAS,SAAS,GAAG,SAAS,EACpC,UAAU,GAAG,EAAE,IACb,iBAAiB,CACnB,kBAAkB,CAAC,KAAK,CAAC,EACzB,MAAM,EACN,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAC3C,aAAa,CAAC,KAAK,CAAC,CACrB,GACC,4BAA4B,CAAC;AAE/B,MAAM,MAAM,kBAAkB,CAC5B,KAAK,SAAS,UAAU,GAAG,UAAU,EACrC,MAAM,SAAS,SAAS,GAAG,SAAS,EACpC,UAAU,GAAG,EAAE,IACb;IACF,eAAe,CAAC,EAAE,IAAI,CACpB,kBAAkB,CAChB,kBAAkB,CAAC,KAAK,CAAC,EACzB,MAAM,EACN,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAC3C,aAAa,CAAC,KAAK,CAAC,CACrB,EACD,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,UAAU,CAClE,CAAC;CACH,GAAG,8BAA8B,CAAC;AAEnC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,yIAOvB,mBAAmB,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,KAAQ,wBACtD,KAAK,EACL,MAAM,EACN,UAAU,CAocX,CAAC"}
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Hook that memoizes the given dependency array and checks the consecutive calls with deep equality and returns the same value as the first call if dependencies are not changed.
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare const useDeepMemo: <T>(fn: () => T, dependencies: React.DependencyList) => T;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1,99 @@
|
|
|
1
|
-
|
|
1
|
+
import papaparse from "papaparse";
|
|
2
|
+
import type { BaseRecord, CrudFilter, CrudSort, MetaQuery } from "../../contexts/data/types";
|
|
3
|
+
import type { MapDataFn } from "./types";
|
|
4
|
+
export interface ExportOptions {
|
|
5
|
+
filename?: string;
|
|
6
|
+
fieldSeparator?: string;
|
|
7
|
+
quoteStrings?: string;
|
|
8
|
+
decimalSeparator?: string;
|
|
9
|
+
showLabels?: boolean;
|
|
10
|
+
showTitle?: boolean;
|
|
11
|
+
title?: string;
|
|
12
|
+
useTextFile?: boolean;
|
|
13
|
+
useBom?: boolean;
|
|
14
|
+
headers?: string[];
|
|
15
|
+
useKeysAsHeaders?: boolean;
|
|
16
|
+
}
|
|
17
|
+
type UseExportOptionsType<TData extends BaseRecord = BaseRecord, TVariables = any> = {
|
|
18
|
+
/**
|
|
19
|
+
* Resource name for API data interactions
|
|
20
|
+
* @default Resource name that it reads from route
|
|
21
|
+
* @deprecated `resourceName` is deprecated. Use `resource` instead.
|
|
22
|
+
*/
|
|
23
|
+
resourceName?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Resource name for API data interactions
|
|
26
|
+
* @default Resource name that it reads from route
|
|
27
|
+
*/
|
|
28
|
+
resource?: string;
|
|
29
|
+
/**
|
|
30
|
+
* A mapping function that runs for every record. Mapped data will be included in the file contents
|
|
31
|
+
*/
|
|
32
|
+
mapData?: MapDataFn<TData, TVariables>;
|
|
33
|
+
/**
|
|
34
|
+
* Sorts records
|
|
35
|
+
* @deprecated `sorter` is deprecated. Use `sorters` instead.
|
|
36
|
+
*/
|
|
37
|
+
sorter?: CrudSort[];
|
|
38
|
+
/**
|
|
39
|
+
* Sorts records
|
|
40
|
+
*/
|
|
41
|
+
sorters?: CrudSort[];
|
|
42
|
+
/**
|
|
43
|
+
* Filters records
|
|
44
|
+
*/
|
|
45
|
+
filters?: CrudFilter[];
|
|
46
|
+
maxItemCount?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Requests to fetch data are made as batches by page size. By default, it is 20. Used for `getList` method of `DataProvider`
|
|
49
|
+
*/
|
|
50
|
+
pageSize?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Used for exporting options
|
|
53
|
+
* @type [Options](https://github.com/alexcaza/export-to-csv)
|
|
54
|
+
* @deprecated `exportOptions` is deprecated. Use `unparseConfig` instead.
|
|
55
|
+
*/
|
|
56
|
+
exportOptions?: ExportOptions;
|
|
57
|
+
/**
|
|
58
|
+
* Used for exporting options
|
|
59
|
+
* @type [UnparseConfig](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/papaparse)
|
|
60
|
+
*/
|
|
61
|
+
unparseConfig?: papaparse.UnparseConfig;
|
|
62
|
+
/**
|
|
63
|
+
* Metadata query for `dataProvider`
|
|
64
|
+
*/
|
|
65
|
+
meta?: MetaQuery;
|
|
66
|
+
/**
|
|
67
|
+
* Metadata query for `dataProvider`
|
|
68
|
+
* @deprecated `metaData` is deprecated with refine@4, refine will pass `meta` instead, however, we still support `metaData` for backward compatibility.
|
|
69
|
+
*/
|
|
70
|
+
metaData?: MetaQuery;
|
|
71
|
+
/**
|
|
72
|
+
* If there is more than one `dataProvider`, you should use the `dataProviderName` that you will use.
|
|
73
|
+
*/
|
|
74
|
+
dataProviderName?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Callback to handle error events of this hook
|
|
77
|
+
*/
|
|
78
|
+
onError?: (error: any) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Whether to generate download of the CSV in browser environments, defaults to true.
|
|
81
|
+
*/
|
|
82
|
+
download?: boolean;
|
|
83
|
+
};
|
|
84
|
+
type UseExportReturnType = {
|
|
85
|
+
isLoading: boolean;
|
|
86
|
+
triggerExport: () => Promise<string | undefined>;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* `useExport` hook allows you to make your resources exportable.
|
|
90
|
+
*
|
|
91
|
+
* @see {@link https://refine.dev/docs/api-reference/core/hooks/import-export/useExport} for more details.
|
|
92
|
+
*
|
|
93
|
+
* @typeParam TData - Result data of the query extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#baserecord `BaseRecord`}
|
|
94
|
+
* @typeParam TVariables - Values for params.
|
|
95
|
+
*
|
|
96
|
+
*/
|
|
97
|
+
export declare const useExport: <TData extends BaseRecord = BaseRecord, TVariables = any>({ resourceName, resource: resourceFromProps, sorter, sorters, filters, maxItemCount, pageSize, mapData, exportOptions, unparseConfig, meta, metaData, dataProviderName, onError, download, }?: UseExportOptionsType<TData, TVariables>) => UseExportReturnType;
|
|
98
|
+
export {};
|
|
99
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
{"
|
|
1
|
+
import type { MouseEventHandler } from "react";
|
|
2
|
+
export type MapDataFn<TItem, TVariables> = (item: TItem, index?: number, items?: TItem[]) => TVariables;
|
|
3
|
+
export interface LabelKeyObject {
|
|
4
|
+
label: string;
|
|
5
|
+
key: string;
|
|
6
|
+
}
|
|
7
|
+
export type Data = object[];
|
|
8
|
+
export type Headers = LabelKeyObject[] | string[];
|
|
9
|
+
export type SyncClickHandler = (event: MouseEventHandler<HTMLAnchorElement>) => boolean | void;
|
|
10
|
+
export type AsyncClickHandler = (event: MouseEventHandler<HTMLAnchorElement>, done: (proceed?: boolean) => void) => void;
|
|
11
|
+
export interface CSVDownloadProps {
|
|
12
|
+
data: string | Data;
|
|
13
|
+
headers?: Headers;
|
|
14
|
+
enclosingCharacter?: string;
|
|
15
|
+
separator?: string;
|
|
16
|
+
filename?: string;
|
|
17
|
+
uFEFF?: boolean;
|
|
18
|
+
onClick?: SyncClickHandler | AsyncClickHandler;
|
|
19
|
+
asyncOnClick?: boolean;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1,18 @@
|
|
|
1
|
-
{
|
|
1
|
+
import type { UseFormProps, UseFormReturnType } from "./types";
|
|
2
|
+
import type { BaseRecord, HttpError } from "../../contexts/data/types";
|
|
3
|
+
export type { ActionParams, UseFormProps, UseFormReturnType, AutoSaveIndicatorElements, AutoSaveProps, AutoSaveReturnType, FormAction, RedirectAction, RedirectionTypes, FormWithSyncWithLocationParams, } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* This hook orchestrates Refine's data hooks to create, edit, and clone data. It also provides a set of features to make it easier for users to implement their real world needs and handle edge cases such as redirects, invalidation, auto-save and more.
|
|
6
|
+
*
|
|
7
|
+
* @see {@link https://refine.dev/docs/data/hooks/use-form} for more details.
|
|
8
|
+
*
|
|
9
|
+
* @typeParam TQueryFnData - Result data returned by the query function. Extends {@link https://refine.dev/docs/core/interface-references/#baserecord `BaseRecord`}
|
|
10
|
+
* @typeParam TError - Custom error object that extends {@link https://refine.dev/docs/core/interface-references/#httperror `HttpError`}
|
|
11
|
+
* @typeParam TVariables - Values for params. default `{}`
|
|
12
|
+
* @typeParam TData - Result data returned by the `select` function. Extends {@link https://refine.dev/docs/core/interface-references/#baserecord `BaseRecord`}. Defaults to `TQueryFnData`
|
|
13
|
+
* @typeParam TResponse - Result data returned by the mutation function. Extends {@link https://refine.dev/docs/core/interface-references/#baserecord `BaseRecord`}. Defaults to `TData`
|
|
14
|
+
* @typeParam TResponseError - Custom error object that extends {@link https://refine.dev/docs/core/interface-references/#httperror `HttpError`}. Defaults to `TError`
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
export declare const useForm: <TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError>(props?: UseFormProps<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>) => UseFormReturnType<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1,146 @@
|
|
|
1
|
-
{
|
|
1
|
+
import type { Dispatch, SetStateAction } from "react";
|
|
2
|
+
import type { QueryObserverResult, UseQueryOptions } from "@tanstack/react-query";
|
|
3
|
+
import type { OptimisticUpdateMapType, UseUpdateProps, UseUpdateReturnType } from "../data/useUpdate";
|
|
4
|
+
import type { UseCreateProps, UseCreateReturnType } from "../data/useCreate";
|
|
5
|
+
import type { UseLoadingOvertimeOptionsProps, UseLoadingOvertimeReturnType } from "../useLoadingOvertime";
|
|
6
|
+
import type { BaseKey, BaseRecord, CreateResponse, GetOneResponse, HttpError, IQueryKeys, MetaQuery, MutationMode, UpdateResponse } from "../../contexts/data/types";
|
|
7
|
+
import type { LiveModeProps } from "../../contexts/live/types";
|
|
8
|
+
import type { SuccessErrorNotification } from "../../contexts/notification/types";
|
|
9
|
+
import type { Action } from "../../contexts/router/types";
|
|
10
|
+
export type FormAction = Extract<Action, "create" | "edit" | "clone">;
|
|
11
|
+
export type RedirectAction = Extract<Action, "create" | "edit" | "list" | "show"> | false;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated use RedirectAction type instead
|
|
14
|
+
*/
|
|
15
|
+
export type RedirectionTypes = RedirectAction;
|
|
16
|
+
export type AutoSaveProps<TVariables> = {
|
|
17
|
+
autoSave?: {
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
debounce?: number;
|
|
20
|
+
onFinish?: (values: TVariables) => TVariables;
|
|
21
|
+
invalidateOnUnmount?: boolean;
|
|
22
|
+
invalidateOnClose?: boolean;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export type AutoSaveReturnType<TData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}> = {
|
|
26
|
+
autoSaveProps: Pick<UseUpdateReturnType<TData, TError, TVariables>, "data" | "error" | "status">;
|
|
27
|
+
onFinishAutoSave: (values: TVariables) => Promise<UpdateResponse<TData> | void>;
|
|
28
|
+
};
|
|
29
|
+
export type AutoSaveIndicatorElements = Partial<Record<"success" | "error" | "loading" | "idle", React.ReactNode>>;
|
|
30
|
+
export type ActionParams = {
|
|
31
|
+
/**
|
|
32
|
+
* Type of the form mode
|
|
33
|
+
* @default Action that it reads from route otherwise "create" is used
|
|
34
|
+
*/
|
|
35
|
+
action?: FormAction;
|
|
36
|
+
};
|
|
37
|
+
type ActionFormProps<TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError> = {
|
|
38
|
+
/**
|
|
39
|
+
* Resource name for API data interactions
|
|
40
|
+
* @default Resource name that it reads from route
|
|
41
|
+
*/
|
|
42
|
+
resource?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Record id for fetching
|
|
45
|
+
* @default Id that it reads from the URL
|
|
46
|
+
*/
|
|
47
|
+
id?: BaseKey;
|
|
48
|
+
/**
|
|
49
|
+
* Page to redirect after a succesfull mutation
|
|
50
|
+
* @type `"show" | "edit" | "list" | "create" | false`
|
|
51
|
+
* @default `"list"`
|
|
52
|
+
*/
|
|
53
|
+
redirect?: RedirectAction;
|
|
54
|
+
/**
|
|
55
|
+
* Metadata query for dataProvider
|
|
56
|
+
*/
|
|
57
|
+
meta?: MetaQuery;
|
|
58
|
+
/**
|
|
59
|
+
* Metadata query for dataProvider
|
|
60
|
+
* @deprecated `metaData` is deprecated with refine@4, refine will pass `meta` instead, however, we still support `metaData` for backward compatibility.
|
|
61
|
+
*/
|
|
62
|
+
metaData?: MetaQuery;
|
|
63
|
+
/**
|
|
64
|
+
* Metadata to pass for the `useOne` query
|
|
65
|
+
*/
|
|
66
|
+
queryMeta?: MetaQuery;
|
|
67
|
+
/**
|
|
68
|
+
* Metadata to pass for the mutation (`useCreate` for `create` and `clone` actions, `useUpdate` for `edit` action)
|
|
69
|
+
*/
|
|
70
|
+
mutationMeta?: MetaQuery;
|
|
71
|
+
/**
|
|
72
|
+
* [Determines when mutations are executed](/advanced-tutorials/mutation-mode.md)
|
|
73
|
+
* @default `"pessimistic"*`
|
|
74
|
+
*/
|
|
75
|
+
mutationMode?: MutationMode;
|
|
76
|
+
/**
|
|
77
|
+
* Called when a mutation is successful
|
|
78
|
+
*/
|
|
79
|
+
onMutationSuccess?: (data: CreateResponse<TResponse> | UpdateResponse<TResponse>, variables: TVariables, context: any, isAutoSave?: boolean) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Called when a mutation encounters an error
|
|
82
|
+
*/
|
|
83
|
+
onMutationError?: (error: TResponseError, variables: TVariables, context: any, isAutoSave?: boolean) => void;
|
|
84
|
+
/**
|
|
85
|
+
* Duration to wait before executing mutations when `mutationMode = "undoable"`
|
|
86
|
+
* @default `5000*`
|
|
87
|
+
*/
|
|
88
|
+
undoableTimeout?: number;
|
|
89
|
+
/**
|
|
90
|
+
* If there is more than one `dataProvider`, you should use the `dataProviderName` that you will use.
|
|
91
|
+
*/
|
|
92
|
+
dataProviderName?: string;
|
|
93
|
+
/**
|
|
94
|
+
* You can use it to manage the invalidations that will occur at the end of the mutation.
|
|
95
|
+
* @type `all`, `resourceAll`, `list`, `many`, `detail`, `false`
|
|
96
|
+
* @default `["list", "many", "detail"]`
|
|
97
|
+
*/
|
|
98
|
+
invalidates?: Array<keyof IQueryKeys>;
|
|
99
|
+
/**
|
|
100
|
+
* react-query's [useQuery](https://tanstack.com/query/v4/docs/reference/useQuery) options of useOne hook used while in edit mode.
|
|
101
|
+
*/
|
|
102
|
+
queryOptions?: UseQueryOptions<GetOneResponse<TQueryFnData>, TError, GetOneResponse<TData>>;
|
|
103
|
+
/**
|
|
104
|
+
* react-query's [useMutation](https://tanstack.com/query/v4/docs/reference/useMutation) options of useCreate hook used while submitting in create and clone modes.
|
|
105
|
+
*/
|
|
106
|
+
createMutationOptions?: UseCreateProps<TResponse, TResponseError, TVariables>["mutationOptions"];
|
|
107
|
+
/**
|
|
108
|
+
* react-query's [useMutation](https://tanstack.com/query/v4/docs/reference/useMutation) options of useUpdate hook used while submitting in edit mode.
|
|
109
|
+
*/
|
|
110
|
+
updateMutationOptions?: UseUpdateProps<TResponse, TResponseError, TVariables>["mutationOptions"];
|
|
111
|
+
/**
|
|
112
|
+
* If you customize the [`optimisticUpdateMap`](https://refine.dev/docs/api-reference/core/hooks/data/useUpdateMany/#optimisticupdatemap) option, you can use it to manage the invalidations that will occur at the end of the mutation.
|
|
113
|
+
* @default {
|
|
114
|
+
* list: true,
|
|
115
|
+
* many: true,
|
|
116
|
+
* detail: true,
|
|
117
|
+
* }
|
|
118
|
+
*/
|
|
119
|
+
optimisticUpdateMap?: OptimisticUpdateMapType<TResponse, TVariables>;
|
|
120
|
+
} & SuccessErrorNotification<UpdateResponse<TResponse> | CreateResponse<TResponse>, TResponseError, {
|
|
121
|
+
id: BaseKey;
|
|
122
|
+
values: TVariables;
|
|
123
|
+
} | TVariables> & ActionParams & LiveModeProps;
|
|
124
|
+
export type UseFormProps<TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError> = ActionFormProps<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError> & ActionParams & LiveModeProps & UseLoadingOvertimeOptionsProps & AutoSaveProps<TVariables>;
|
|
125
|
+
export type UseFormReturnType<TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError> = {
|
|
126
|
+
id?: BaseKey;
|
|
127
|
+
setId: Dispatch<SetStateAction<BaseKey | undefined>>;
|
|
128
|
+
queryResult?: QueryObserverResult<GetOneResponse<TData>, TError>;
|
|
129
|
+
mutationResult: UseUpdateReturnType<TResponse, TResponseError, TVariables> | UseCreateReturnType<TResponse, TResponseError, TVariables>;
|
|
130
|
+
formLoading: boolean;
|
|
131
|
+
onFinish: (values: TVariables) => Promise<CreateResponse<TResponse> | UpdateResponse<TResponse> | void>;
|
|
132
|
+
redirect: (redirect: RedirectAction, idFromFunction?: BaseKey | undefined, routeParams?: Record<string, string | number>) => void;
|
|
133
|
+
} & UseLoadingOvertimeReturnType & AutoSaveReturnType<TResponse, TResponseError, TVariables>;
|
|
134
|
+
export type FormWithSyncWithLocationParams = {
|
|
135
|
+
/**
|
|
136
|
+
* If true, the form will be synced with the location.
|
|
137
|
+
* If an object is passed, the key property will be used as the key for the query params.
|
|
138
|
+
* By default, query params are placed under the key, `${resource.name}-${action}`.
|
|
139
|
+
*/
|
|
140
|
+
syncWithLocation?: boolean | {
|
|
141
|
+
key?: string;
|
|
142
|
+
syncId?: boolean;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
export {};
|
|
146
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
{"
|
|
1
|
+
export { useSetLocale } from "./useSetLocale";
|
|
2
|
+
export { useTranslate } from "./useTranslate";
|
|
3
|
+
export { useGetLocale } from "./useGetLocale";
|
|
4
|
+
export * from "./useTranslation";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
export type UseGetLocaleType = () => () => string | undefined;
|
|
2
|
+
/**
|
|
3
|
+
* If you need to know the current locale, refine provides the `useGetLocale` hook.
|
|
4
|
+
* It returns the `getLocale` method from `i18nProvider` under the hood.
|
|
5
|
+
*
|
|
6
|
+
* @see {@link https://refine.dev/docs/api-reference/core/hooks/translate/useGetLocale} for more details.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useGetLocale: UseGetLocaleType;
|
|
9
|
+
//# sourceMappingURL=useGetLocale.d.ts.map
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* If you need to change the locale at runtime, refine provides the `useSetLocale` hook.
|
|
3
|
+
* It returns the changeLocale method from `i18nProvider` under the hood.
|
|
4
|
+
*
|
|
5
|
+
* @see {@link https://refine.dev/docs/api-reference/core/hooks/translate/useSetLocale} for more details.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useSetLocale: () => (lang: string) => any;
|
|
8
|
+
//# sourceMappingURL=useSetLocale.d.ts.map
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* If you need to translate the texts in your own components, refine provides the `useTranslate` hook.
|
|
3
|
+
* It returns the translate method from `i18nProvider` under the hood.
|
|
4
|
+
*
|
|
5
|
+
* @see {@link https://refine.dev/docs/api-reference/core/hooks/translate/useTranslate} for more details.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useTranslate: () => {
|
|
8
|
+
(key: string, options?: any, defaultMessage?: string): string;
|
|
9
|
+
(key: string, defaultMessage?: string): string;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=useTranslate.d.ts.map
|
|
@@ -1 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* It combines `useTranslate`, `useSetLocale` and `useGetLocale` hooks for a better developer experience.
|
|
3
|
+
* It returns `i18nProvider` methods under the hood.
|
|
4
|
+
* @returns `translate` method to translate the texts.
|
|
5
|
+
* @returns `changeLocale` method to change the locale
|
|
6
|
+
* @returns `getLocale` method to get the current locale.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://refine.dev/docs/i18n/i18n-provider/} for more details.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useTranslation: () => {
|
|
11
|
+
translate: {
|
|
12
|
+
(key: string, options?: any, defaultMessage?: string | undefined): string;
|
|
13
|
+
(key: string, defaultMessage?: string | undefined): string;
|
|
14
|
+
};
|
|
15
|
+
changeLocale: (lang: string) => any;
|
|
16
|
+
getLocale: () => string | undefined;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useTranslation.d.ts.map
|
|
@@ -1 +1,101 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import papaparse from "papaparse";
|
|
3
|
+
import type { BaseRecord, HttpError, MetaQuery } from "../../contexts/data/types";
|
|
4
|
+
import type { UseCreateReturnType } from "../../hooks/data/useCreate";
|
|
5
|
+
import type { UseCreateManyReturnType } from "../../hooks/data/useCreateMany";
|
|
6
|
+
import type { MapDataFn } from "../export/types";
|
|
7
|
+
export type ImportSuccessResult<TVariables, TData> = {
|
|
8
|
+
request: TVariables[];
|
|
9
|
+
type: "success";
|
|
10
|
+
response: TData[];
|
|
11
|
+
};
|
|
12
|
+
export type ImportErrorResult<TVariables> = {
|
|
13
|
+
request: TVariables[];
|
|
14
|
+
type: "error";
|
|
15
|
+
response: HttpError[];
|
|
16
|
+
};
|
|
17
|
+
export type OnFinishParams<TVariables, TData> = {
|
|
18
|
+
succeeded: ImportSuccessResult<TVariables, TData>[];
|
|
19
|
+
errored: ImportErrorResult<TVariables>[];
|
|
20
|
+
};
|
|
21
|
+
export type OnProgressParams = {
|
|
22
|
+
totalAmount: number;
|
|
23
|
+
processedAmount: number;
|
|
24
|
+
};
|
|
25
|
+
export type ImportOptions<TItem, TVariables = any, TData extends BaseRecord = BaseRecord> = {
|
|
26
|
+
/**
|
|
27
|
+
* Resource name for API data interactions.
|
|
28
|
+
* @default Resource name that it reads from route
|
|
29
|
+
* @deprecated `resourceName` is deprecated. Use `resource` instead.
|
|
30
|
+
*/
|
|
31
|
+
resourceName?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Resource name for API data interactions.
|
|
34
|
+
* @default Resource name that it reads from route
|
|
35
|
+
*/
|
|
36
|
+
resource?: string;
|
|
37
|
+
/**
|
|
38
|
+
* A mapping function that runs for every record. Mapped data will be included in the file contents.
|
|
39
|
+
*/
|
|
40
|
+
mapData?: MapDataFn<TItem, TVariables>;
|
|
41
|
+
/**
|
|
42
|
+
* Custom Papa Parse options.
|
|
43
|
+
* @type [`ParseConfig`](https://www.papaparse.com/docs)
|
|
44
|
+
*/
|
|
45
|
+
paparseOptions?: papaparse.ParseConfig;
|
|
46
|
+
/**
|
|
47
|
+
* Requests batch size. If it is 1, all records are sent one by one. By default, it is [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER) to send all records in one batch. If it is more than 1, `createMany` should be implemented on DataProvider.
|
|
48
|
+
*/
|
|
49
|
+
batchSize?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Called with errors and successful responses when all requests are sent.
|
|
52
|
+
*/
|
|
53
|
+
onFinish?: (results: OnFinishParams<TVariables, TData>) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Metadata query for `dataProvider`
|
|
56
|
+
*/
|
|
57
|
+
meta?: MetaQuery;
|
|
58
|
+
/**
|
|
59
|
+
* Metadata query for `dataProvider`
|
|
60
|
+
* @deprecated `metaData` is deprecated with refine@4, refine will pass `meta` instead, however, we still support `metaData` for backward compatibility.
|
|
61
|
+
*/
|
|
62
|
+
metaData?: MetaQuery;
|
|
63
|
+
/**
|
|
64
|
+
* A callback function that returns a current state of uploading process.
|
|
65
|
+
*
|
|
66
|
+
* Ex: `percentage = onProgressParams.processedAmount / onProgressParams.totalAmount * 100`
|
|
67
|
+
*/
|
|
68
|
+
onProgress?: (onProgressParams: OnProgressParams) => void;
|
|
69
|
+
/**
|
|
70
|
+
* If there is more than one `dataProvider`, you should use the `dataProviderName` that you will use.
|
|
71
|
+
*/
|
|
72
|
+
dataProviderName?: string;
|
|
73
|
+
};
|
|
74
|
+
export type CreatedValuesType<TVariables, TData> = ImportSuccessResult<TVariables, TData> | ImportErrorResult<TVariables>;
|
|
75
|
+
export type HandleChangeType<TVariables, TData> = (onChangeParams: {
|
|
76
|
+
file: Partial<File>;
|
|
77
|
+
}) => Promise<CreatedValuesType<TVariables, TData>[]>;
|
|
78
|
+
export type UseImportInputPropsType = {
|
|
79
|
+
type: "file";
|
|
80
|
+
accept: string;
|
|
81
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
82
|
+
};
|
|
83
|
+
export type UseImportReturnType<TData extends BaseRecord = BaseRecord, TVariables = {}, TError extends HttpError = HttpError> = {
|
|
84
|
+
inputProps: UseImportInputPropsType;
|
|
85
|
+
mutationResult: UseCreateReturnType<TData, TError, TVariables> | UseCreateManyReturnType<TData, TError, TVariables>;
|
|
86
|
+
isLoading: boolean;
|
|
87
|
+
handleChange: HandleChangeType<TVariables, TData>;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* `useImport` hook allows you to handle your csv import logic easily.
|
|
91
|
+
*
|
|
92
|
+
* @see {@link https://refine.dev/docs/api-reference/core/hooks/import-export/useImport} for more details.
|
|
93
|
+
*
|
|
94
|
+
* @typeParam TItem - Interface of parsed csv data
|
|
95
|
+
* @typeParam TData - Result data of the query extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#baserecord `BaseRecord`}
|
|
96
|
+
* @typeParam TError - Custom error object that extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences/#httperror `HttpError`}
|
|
97
|
+
* @typeParam TVariables - Values for mutation function
|
|
98
|
+
*
|
|
99
|
+
*/
|
|
100
|
+
export declare const useImport: <TItem = any, TData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = any>({ resourceName, resource: resourceFromProps, mapData, paparseOptions, batchSize, onFinish, meta, metaData, onProgress, dataProviderName, }?: ImportOptions<TItem, TVariables, TData>) => UseImportReturnType<TData, TVariables, TError>;
|
|
101
|
+
//# sourceMappingURL=index.d.ts.map
|