@refinedev/core 4.12.0 → 4.13.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.
@@ -10,7 +10,7 @@ export declare type ActionParams = {
10
10
  */
11
11
  action?: FormAction;
12
12
  };
13
- declare type ActionFormProps<TData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TSelectData extends BaseRecord = TData> = {
13
+ declare type ActionFormProps<TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError> = {
14
14
  /**
15
15
  * Resource name for API data interactions
16
16
  * @default Resource name that it reads from route
@@ -44,11 +44,11 @@ declare type ActionFormProps<TData extends BaseRecord = BaseRecord, TError exten
44
44
  /**
45
45
  * Called when a mutation is successful
46
46
  */
47
- onMutationSuccess?: (data: CreateResponse<TData> | UpdateResponse<TData>, variables: TVariables, context: any) => void;
47
+ onMutationSuccess?: (data: CreateResponse<TResponse> | UpdateResponse<TResponse>, variables: TVariables, context: any) => void;
48
48
  /**
49
49
  * Called when a mutation encounters an error
50
50
  */
51
- onMutationError?: (error: TError, variables: TVariables, context: any) => void;
51
+ onMutationError?: (error: TResponseError, variables: TVariables, context: any) => void;
52
52
  /**
53
53
  * Duration to wait before executing mutations when `mutationMode = "undoable"`
54
54
  * @default `5000*`
@@ -67,27 +67,27 @@ declare type ActionFormProps<TData extends BaseRecord = BaseRecord, TError exten
67
67
  /**
68
68
  * react-query's [useQuery](https://tanstack.com/query/v4/docs/reference/useQuery) options of useOne hook used while in edit mode.
69
69
  */
70
- queryOptions?: UseQueryOptions<GetOneResponse<TData>, TError, GetOneResponse<TSelectData>>;
70
+ queryOptions?: UseQueryOptions<GetOneResponse<TQueryFnData>, TError, GetOneResponse<TData>>;
71
71
  /**
72
72
  * react-query's [useMutation](https://tanstack.com/query/v4/docs/reference/useMutation) options of useCreate hook used while submitting in create and clone modes.
73
73
  */
74
- createMutationOptions?: UseCreateProps<TData, TError, TVariables>["mutationOptions"];
74
+ createMutationOptions?: UseCreateProps<TResponse, TResponseError, TVariables>["mutationOptions"];
75
75
  /**
76
76
  * react-query's [useMutation](https://tanstack.com/query/v4/docs/reference/useMutation) options of useUpdate hook used while submitting in edit mode.
77
77
  */
78
- updateMutationOptions?: UseUpdateProps<TData, TError, TVariables>["mutationOptions"];
79
- } & SuccessErrorNotification<UpdateResponse<TData> | CreateResponse<TData>, TError, {
78
+ updateMutationOptions?: UseUpdateProps<TResponse, TResponseError, TVariables>["mutationOptions"];
79
+ } & SuccessErrorNotification<UpdateResponse<TResponse> | CreateResponse<TResponse>, TResponseError, {
80
80
  id: BaseKey;
81
81
  values: TVariables;
82
82
  } | TVariables> & ActionParams & LiveModeProps;
83
- export declare type UseFormProps<TData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TSelectData extends BaseRecord = TData> = ActionFormProps<TData, TError, TVariables, TSelectData> & ActionParams & LiveModeProps;
84
- export declare type UseFormReturnType<TData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TSelectData extends BaseRecord = TData> = {
83
+ export declare 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;
84
+ export declare type UseFormReturnType<TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError> = {
85
85
  id?: BaseKey;
86
86
  setId: Dispatch<SetStateAction<BaseKey | undefined>>;
87
- queryResult?: QueryObserverResult<GetOneResponse<TSelectData>>;
88
- mutationResult: UseUpdateReturnType<TData, TError, TVariables> | UseCreateReturnType<TData, TError, TVariables>;
87
+ queryResult?: QueryObserverResult<GetOneResponse<TData>>;
88
+ mutationResult: UseUpdateReturnType<TResponse, TResponseError, TVariables> | UseCreateReturnType<TResponse, TResponseError, TVariables>;
89
89
  formLoading: boolean;
90
- onFinish: (values: TVariables) => Promise<CreateResponse<TData> | UpdateResponse<TData> | void>;
90
+ onFinish: (values: TVariables) => Promise<CreateResponse<TResponse> | UpdateResponse<TResponse> | void>;
91
91
  redirect: (redirect: RedirectAction, idFromFunction?: BaseKey | undefined, routeParams?: Record<string, string | number>) => void;
92
92
  };
93
93
  /**
@@ -95,12 +95,14 @@ export declare type UseFormReturnType<TData extends BaseRecord = BaseRecord, TEr
95
95
  *
96
96
  * @see {@link https://refine.dev/docs/api-references/hooks/form/useForm} for more details.
97
97
  *
98
- * @typeParam TData - Result data of the query extends {@link https://refine.dev/docs/api-references/interfaceReferences#baserecord `BaseRecord`}
99
- * @typeParam TError - Custom error object that extends {@link https://refine.dev/docs/api-references/interfaceReferences#httperror `HttpError`}
98
+ * @typeParam TQueryFnData - Result data returned by the query function. Extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#baserecord `BaseRecord`}
99
+ * @typeParam TError - Custom error object that extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#httperror `HttpError`}
100
100
  * @typeParam TVariables - Values for params. default `{}`
101
- *
101
+ * @typeParam TData - Result data returned by the `select` function. Extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#baserecord `BaseRecord`}. Defaults to `TQueryFnData`
102
+ * @typeParam TResponse - Result data returned by the mutation function. Extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#baserecord `BaseRecord`}. Defaults to `TData`
103
+ * @typeParam TResponseError - Custom error object that extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#httperror `HttpError`}. Defaults to `TError`
102
104
  *
103
105
  */
104
- export declare const useForm: <TData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TSelectData extends BaseRecord = TData>({ resource: resourceFromProps, action: actionFromProps, id: idFromProps, onMutationSuccess, onMutationError, redirect: redirectFromProps, successNotification, errorNotification, meta, metaData, mutationMode: mutationModeProp, liveMode, onLiveEvent, liveParams, undoableTimeout, dataProviderName, invalidates, queryOptions, createMutationOptions, updateMutationOptions, }?: UseFormProps<TData, TError, TVariables, TSelectData>) => UseFormReturnType<TData, TError, TVariables, TSelectData>;
106
+ 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>({ resource: resourceFromProps, action: actionFromProps, id: idFromProps, onMutationSuccess, onMutationError, redirect: redirectFromProps, successNotification, errorNotification, meta, metaData, mutationMode: mutationModeProp, liveMode, onLiveEvent, liveParams, undoableTimeout, dataProviderName, invalidates, queryOptions, createMutationOptions, updateMutationOptions, }?: UseFormProps<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>) => UseFormReturnType<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>;
105
107
  export {};
106
108
  //# sourceMappingURL=useForm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../../src/hooks/form/useForm.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAgB7E,OAAO,EACH,UAAU,EACV,cAAc,EACd,cAAc,EACd,SAAS,EACT,aAAa,EAEb,cAAc,EACd,wBAAwB,EACxB,cAAc,EACd,YAAY,EACZ,OAAO,EACP,UAAU,EACV,UAAU,EAEV,SAAS,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEH,cAAc,EACd,mBAAmB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAQxE,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