@focus-reactive/payload-plugin-translator 0.1.6 → 0.2.1
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/dist/client/entities/translation/api/queries/useCollectionTranslationStatus.d.ts +77 -13
- package/dist/client/entities/translation/api/queries/useDocumentTranslation.d.ts +77 -13
- package/dist/client/features/collection-translation-form/model/form-model.d.ts +2 -2
- package/dist/client/features/collection-translation-form/model/form-model.js +13 -10
- package/dist/client/features/translate-document-form/model/form-model.d.ts +2 -2
- package/dist/client/features/translate-document-form/model/form-model.js +13 -10
- package/package.json +5 -10
|
@@ -8,13 +8,15 @@ type Options = {
|
|
|
8
8
|
};
|
|
9
9
|
export declare function useCollectionTranslationStatus({ collection }: Props, options?: Options): {
|
|
10
10
|
invalidate: () => void;
|
|
11
|
-
data: GroupedCollectionTranslationStatus
|
|
11
|
+
data: NoInfer<GroupedCollectionTranslationStatus>;
|
|
12
12
|
error: Error;
|
|
13
13
|
isError: true;
|
|
14
14
|
isPending: false;
|
|
15
|
+
isLoading: false;
|
|
15
16
|
isLoadingError: false;
|
|
16
17
|
isRefetchError: true;
|
|
17
18
|
isSuccess: false;
|
|
19
|
+
isPlaceholderData: false;
|
|
18
20
|
status: "error";
|
|
19
21
|
dataUpdatedAt: number;
|
|
20
22
|
errorUpdatedAt: number;
|
|
@@ -24,23 +26,25 @@ export declare function useCollectionTranslationStatus({ collection }: Props, op
|
|
|
24
26
|
isFetched: boolean;
|
|
25
27
|
isFetchedAfterMount: boolean;
|
|
26
28
|
isFetching: boolean;
|
|
27
|
-
isLoading: boolean;
|
|
28
29
|
isInitialLoading: boolean;
|
|
29
30
|
isPaused: boolean;
|
|
30
|
-
isPlaceholderData: boolean;
|
|
31
31
|
isRefetching: boolean;
|
|
32
32
|
isStale: boolean;
|
|
33
|
-
|
|
33
|
+
isEnabled: boolean;
|
|
34
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NoInfer<GroupedCollectionTranslationStatus>, Error>>;
|
|
34
35
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
36
|
+
promise: Promise<NoInfer<GroupedCollectionTranslationStatus>>;
|
|
35
37
|
} | {
|
|
36
38
|
invalidate: () => void;
|
|
37
|
-
data: GroupedCollectionTranslationStatus
|
|
39
|
+
data: NoInfer<GroupedCollectionTranslationStatus>;
|
|
38
40
|
error: null;
|
|
39
41
|
isError: false;
|
|
40
42
|
isPending: false;
|
|
43
|
+
isLoading: false;
|
|
41
44
|
isLoadingError: false;
|
|
42
45
|
isRefetchError: false;
|
|
43
46
|
isSuccess: true;
|
|
47
|
+
isPlaceholderData: false;
|
|
44
48
|
status: "success";
|
|
45
49
|
dataUpdatedAt: number;
|
|
46
50
|
errorUpdatedAt: number;
|
|
@@ -50,23 +54,25 @@ export declare function useCollectionTranslationStatus({ collection }: Props, op
|
|
|
50
54
|
isFetched: boolean;
|
|
51
55
|
isFetchedAfterMount: boolean;
|
|
52
56
|
isFetching: boolean;
|
|
53
|
-
isLoading: boolean;
|
|
54
57
|
isInitialLoading: boolean;
|
|
55
58
|
isPaused: boolean;
|
|
56
|
-
isPlaceholderData: boolean;
|
|
57
59
|
isRefetching: boolean;
|
|
58
60
|
isStale: boolean;
|
|
59
|
-
|
|
61
|
+
isEnabled: boolean;
|
|
62
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NoInfer<GroupedCollectionTranslationStatus>, Error>>;
|
|
60
63
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
64
|
+
promise: Promise<NoInfer<GroupedCollectionTranslationStatus>>;
|
|
61
65
|
} | {
|
|
62
66
|
invalidate: () => void;
|
|
63
67
|
data: undefined;
|
|
64
68
|
error: Error;
|
|
65
69
|
isError: true;
|
|
66
70
|
isPending: false;
|
|
71
|
+
isLoading: false;
|
|
67
72
|
isLoadingError: true;
|
|
68
73
|
isRefetchError: false;
|
|
69
74
|
isSuccess: false;
|
|
75
|
+
isPlaceholderData: false;
|
|
70
76
|
status: "error";
|
|
71
77
|
dataUpdatedAt: number;
|
|
72
78
|
errorUpdatedAt: number;
|
|
@@ -76,14 +82,42 @@ export declare function useCollectionTranslationStatus({ collection }: Props, op
|
|
|
76
82
|
isFetched: boolean;
|
|
77
83
|
isFetchedAfterMount: boolean;
|
|
78
84
|
isFetching: boolean;
|
|
79
|
-
isLoading: boolean;
|
|
80
85
|
isInitialLoading: boolean;
|
|
81
86
|
isPaused: boolean;
|
|
82
|
-
isPlaceholderData: boolean;
|
|
83
87
|
isRefetching: boolean;
|
|
84
88
|
isStale: boolean;
|
|
85
|
-
|
|
89
|
+
isEnabled: boolean;
|
|
90
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NoInfer<GroupedCollectionTranslationStatus>, Error>>;
|
|
91
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
92
|
+
promise: Promise<NoInfer<GroupedCollectionTranslationStatus>>;
|
|
93
|
+
} | {
|
|
94
|
+
invalidate: () => void;
|
|
95
|
+
data: undefined;
|
|
96
|
+
error: null;
|
|
97
|
+
isError: false;
|
|
98
|
+
isPending: true;
|
|
99
|
+
isLoading: true;
|
|
100
|
+
isLoadingError: false;
|
|
101
|
+
isRefetchError: false;
|
|
102
|
+
isSuccess: false;
|
|
103
|
+
isPlaceholderData: false;
|
|
104
|
+
status: "pending";
|
|
105
|
+
dataUpdatedAt: number;
|
|
106
|
+
errorUpdatedAt: number;
|
|
107
|
+
failureCount: number;
|
|
108
|
+
failureReason: Error | null;
|
|
109
|
+
errorUpdateCount: number;
|
|
110
|
+
isFetched: boolean;
|
|
111
|
+
isFetchedAfterMount: boolean;
|
|
112
|
+
isFetching: boolean;
|
|
113
|
+
isInitialLoading: boolean;
|
|
114
|
+
isPaused: boolean;
|
|
115
|
+
isRefetching: boolean;
|
|
116
|
+
isStale: boolean;
|
|
117
|
+
isEnabled: boolean;
|
|
118
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NoInfer<GroupedCollectionTranslationStatus>, Error>>;
|
|
86
119
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
120
|
+
promise: Promise<NoInfer<GroupedCollectionTranslationStatus>>;
|
|
87
121
|
} | {
|
|
88
122
|
invalidate: () => void;
|
|
89
123
|
data: undefined;
|
|
@@ -93,6 +127,7 @@ export declare function useCollectionTranslationStatus({ collection }: Props, op
|
|
|
93
127
|
isLoadingError: false;
|
|
94
128
|
isRefetchError: false;
|
|
95
129
|
isSuccess: false;
|
|
130
|
+
isPlaceholderData: false;
|
|
96
131
|
status: "pending";
|
|
97
132
|
dataUpdatedAt: number;
|
|
98
133
|
errorUpdatedAt: number;
|
|
@@ -105,10 +140,39 @@ export declare function useCollectionTranslationStatus({ collection }: Props, op
|
|
|
105
140
|
isLoading: boolean;
|
|
106
141
|
isInitialLoading: boolean;
|
|
107
142
|
isPaused: boolean;
|
|
108
|
-
isPlaceholderData: boolean;
|
|
109
143
|
isRefetching: boolean;
|
|
110
144
|
isStale: boolean;
|
|
111
|
-
|
|
145
|
+
isEnabled: boolean;
|
|
146
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NoInfer<GroupedCollectionTranslationStatus>, Error>>;
|
|
147
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
148
|
+
promise: Promise<NoInfer<GroupedCollectionTranslationStatus>>;
|
|
149
|
+
} | {
|
|
150
|
+
invalidate: () => void;
|
|
151
|
+
data: NoInfer<GroupedCollectionTranslationStatus>;
|
|
152
|
+
isError: false;
|
|
153
|
+
error: null;
|
|
154
|
+
isPending: false;
|
|
155
|
+
isLoading: false;
|
|
156
|
+
isLoadingError: false;
|
|
157
|
+
isRefetchError: false;
|
|
158
|
+
isSuccess: true;
|
|
159
|
+
isPlaceholderData: true;
|
|
160
|
+
status: "success";
|
|
161
|
+
dataUpdatedAt: number;
|
|
162
|
+
errorUpdatedAt: number;
|
|
163
|
+
failureCount: number;
|
|
164
|
+
failureReason: Error | null;
|
|
165
|
+
errorUpdateCount: number;
|
|
166
|
+
isFetched: boolean;
|
|
167
|
+
isFetchedAfterMount: boolean;
|
|
168
|
+
isFetching: boolean;
|
|
169
|
+
isInitialLoading: boolean;
|
|
170
|
+
isPaused: boolean;
|
|
171
|
+
isRefetching: boolean;
|
|
172
|
+
isStale: boolean;
|
|
173
|
+
isEnabled: boolean;
|
|
174
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NoInfer<GroupedCollectionTranslationStatus>, Error>>;
|
|
112
175
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
176
|
+
promise: Promise<NoInfer<GroupedCollectionTranslationStatus>>;
|
|
113
177
|
};
|
|
114
178
|
export {};
|
|
@@ -9,13 +9,15 @@ type Options = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare function useDocumentTranslation({ collection, id }: Props, options?: Options): {
|
|
11
11
|
invalidate: () => void;
|
|
12
|
-
data: DocumentTranslation
|
|
12
|
+
data: NoInfer<DocumentTranslation>;
|
|
13
13
|
error: Error;
|
|
14
14
|
isError: true;
|
|
15
15
|
isPending: false;
|
|
16
|
+
isLoading: false;
|
|
16
17
|
isLoadingError: false;
|
|
17
18
|
isRefetchError: true;
|
|
18
19
|
isSuccess: false;
|
|
20
|
+
isPlaceholderData: false;
|
|
19
21
|
status: "error";
|
|
20
22
|
dataUpdatedAt: number;
|
|
21
23
|
errorUpdatedAt: number;
|
|
@@ -25,23 +27,25 @@ export declare function useDocumentTranslation({ collection, id }: Props, option
|
|
|
25
27
|
isFetched: boolean;
|
|
26
28
|
isFetchedAfterMount: boolean;
|
|
27
29
|
isFetching: boolean;
|
|
28
|
-
isLoading: boolean;
|
|
29
30
|
isInitialLoading: boolean;
|
|
30
31
|
isPaused: boolean;
|
|
31
|
-
isPlaceholderData: boolean;
|
|
32
32
|
isRefetching: boolean;
|
|
33
33
|
isStale: boolean;
|
|
34
|
-
|
|
34
|
+
isEnabled: boolean;
|
|
35
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NoInfer<DocumentTranslation>, Error>>;
|
|
35
36
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
37
|
+
promise: Promise<NoInfer<DocumentTranslation>>;
|
|
36
38
|
} | {
|
|
37
39
|
invalidate: () => void;
|
|
38
|
-
data: DocumentTranslation
|
|
40
|
+
data: NoInfer<DocumentTranslation>;
|
|
39
41
|
error: null;
|
|
40
42
|
isError: false;
|
|
41
43
|
isPending: false;
|
|
44
|
+
isLoading: false;
|
|
42
45
|
isLoadingError: false;
|
|
43
46
|
isRefetchError: false;
|
|
44
47
|
isSuccess: true;
|
|
48
|
+
isPlaceholderData: false;
|
|
45
49
|
status: "success";
|
|
46
50
|
dataUpdatedAt: number;
|
|
47
51
|
errorUpdatedAt: number;
|
|
@@ -51,23 +55,25 @@ export declare function useDocumentTranslation({ collection, id }: Props, option
|
|
|
51
55
|
isFetched: boolean;
|
|
52
56
|
isFetchedAfterMount: boolean;
|
|
53
57
|
isFetching: boolean;
|
|
54
|
-
isLoading: boolean;
|
|
55
58
|
isInitialLoading: boolean;
|
|
56
59
|
isPaused: boolean;
|
|
57
|
-
isPlaceholderData: boolean;
|
|
58
60
|
isRefetching: boolean;
|
|
59
61
|
isStale: boolean;
|
|
60
|
-
|
|
62
|
+
isEnabled: boolean;
|
|
63
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NoInfer<DocumentTranslation>, Error>>;
|
|
61
64
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
65
|
+
promise: Promise<NoInfer<DocumentTranslation>>;
|
|
62
66
|
} | {
|
|
63
67
|
invalidate: () => void;
|
|
64
68
|
data: undefined;
|
|
65
69
|
error: Error;
|
|
66
70
|
isError: true;
|
|
67
71
|
isPending: false;
|
|
72
|
+
isLoading: false;
|
|
68
73
|
isLoadingError: true;
|
|
69
74
|
isRefetchError: false;
|
|
70
75
|
isSuccess: false;
|
|
76
|
+
isPlaceholderData: false;
|
|
71
77
|
status: "error";
|
|
72
78
|
dataUpdatedAt: number;
|
|
73
79
|
errorUpdatedAt: number;
|
|
@@ -77,14 +83,42 @@ export declare function useDocumentTranslation({ collection, id }: Props, option
|
|
|
77
83
|
isFetched: boolean;
|
|
78
84
|
isFetchedAfterMount: boolean;
|
|
79
85
|
isFetching: boolean;
|
|
80
|
-
isLoading: boolean;
|
|
81
86
|
isInitialLoading: boolean;
|
|
82
87
|
isPaused: boolean;
|
|
83
|
-
isPlaceholderData: boolean;
|
|
84
88
|
isRefetching: boolean;
|
|
85
89
|
isStale: boolean;
|
|
86
|
-
|
|
90
|
+
isEnabled: boolean;
|
|
91
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NoInfer<DocumentTranslation>, Error>>;
|
|
92
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
93
|
+
promise: Promise<NoInfer<DocumentTranslation>>;
|
|
94
|
+
} | {
|
|
95
|
+
invalidate: () => void;
|
|
96
|
+
data: undefined;
|
|
97
|
+
error: null;
|
|
98
|
+
isError: false;
|
|
99
|
+
isPending: true;
|
|
100
|
+
isLoading: true;
|
|
101
|
+
isLoadingError: false;
|
|
102
|
+
isRefetchError: false;
|
|
103
|
+
isSuccess: false;
|
|
104
|
+
isPlaceholderData: false;
|
|
105
|
+
status: "pending";
|
|
106
|
+
dataUpdatedAt: number;
|
|
107
|
+
errorUpdatedAt: number;
|
|
108
|
+
failureCount: number;
|
|
109
|
+
failureReason: Error | null;
|
|
110
|
+
errorUpdateCount: number;
|
|
111
|
+
isFetched: boolean;
|
|
112
|
+
isFetchedAfterMount: boolean;
|
|
113
|
+
isFetching: boolean;
|
|
114
|
+
isInitialLoading: boolean;
|
|
115
|
+
isPaused: boolean;
|
|
116
|
+
isRefetching: boolean;
|
|
117
|
+
isStale: boolean;
|
|
118
|
+
isEnabled: boolean;
|
|
119
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NoInfer<DocumentTranslation>, Error>>;
|
|
87
120
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
121
|
+
promise: Promise<NoInfer<DocumentTranslation>>;
|
|
88
122
|
} | {
|
|
89
123
|
invalidate: () => void;
|
|
90
124
|
data: undefined;
|
|
@@ -94,6 +128,7 @@ export declare function useDocumentTranslation({ collection, id }: Props, option
|
|
|
94
128
|
isLoadingError: false;
|
|
95
129
|
isRefetchError: false;
|
|
96
130
|
isSuccess: false;
|
|
131
|
+
isPlaceholderData: false;
|
|
97
132
|
status: "pending";
|
|
98
133
|
dataUpdatedAt: number;
|
|
99
134
|
errorUpdatedAt: number;
|
|
@@ -106,10 +141,39 @@ export declare function useDocumentTranslation({ collection, id }: Props, option
|
|
|
106
141
|
isLoading: boolean;
|
|
107
142
|
isInitialLoading: boolean;
|
|
108
143
|
isPaused: boolean;
|
|
109
|
-
isPlaceholderData: boolean;
|
|
110
144
|
isRefetching: boolean;
|
|
111
145
|
isStale: boolean;
|
|
112
|
-
|
|
146
|
+
isEnabled: boolean;
|
|
147
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NoInfer<DocumentTranslation>, Error>>;
|
|
148
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
149
|
+
promise: Promise<NoInfer<DocumentTranslation>>;
|
|
150
|
+
} | {
|
|
151
|
+
invalidate: () => void;
|
|
152
|
+
data: NoInfer<DocumentTranslation>;
|
|
153
|
+
isError: false;
|
|
154
|
+
error: null;
|
|
155
|
+
isPending: false;
|
|
156
|
+
isLoading: false;
|
|
157
|
+
isLoadingError: false;
|
|
158
|
+
isRefetchError: false;
|
|
159
|
+
isSuccess: true;
|
|
160
|
+
isPlaceholderData: true;
|
|
161
|
+
status: "success";
|
|
162
|
+
dataUpdatedAt: number;
|
|
163
|
+
errorUpdatedAt: number;
|
|
164
|
+
failureCount: number;
|
|
165
|
+
failureReason: Error | null;
|
|
166
|
+
errorUpdateCount: number;
|
|
167
|
+
isFetched: boolean;
|
|
168
|
+
isFetchedAfterMount: boolean;
|
|
169
|
+
isFetching: boolean;
|
|
170
|
+
isInitialLoading: boolean;
|
|
171
|
+
isPaused: boolean;
|
|
172
|
+
isRefetching: boolean;
|
|
173
|
+
isStale: boolean;
|
|
174
|
+
isEnabled: boolean;
|
|
175
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NoInfer<DocumentTranslation>, Error>>;
|
|
113
176
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
177
|
+
promise: Promise<NoInfer<DocumentTranslation>>;
|
|
114
178
|
};
|
|
115
179
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UseFormReturn } from
|
|
2
|
-
import type { FormInput, FormValues } from
|
|
1
|
+
import type { UseFormReturn } from "react-hook-form";
|
|
2
|
+
import type { FormInput, FormValues } from "./schema";
|
|
3
3
|
type UseFormReturn_ = {
|
|
4
4
|
form: UseFormReturn<FormValues>;
|
|
5
5
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import { zodResolver } from
|
|
3
|
-
import { useEffect, useMemo } from
|
|
4
|
-
import { useForm } from
|
|
5
|
-
import { defaultValues } from
|
|
6
|
-
import { validationSchema } from
|
|
1
|
+
"use client";
|
|
2
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
3
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
4
|
+
import { useForm } from "react-hook-form";
|
|
5
|
+
import { defaultValues } from "./constants";
|
|
6
|
+
import { validationSchema } from "./schema";
|
|
7
7
|
export const useCollectionTranslationForm = ({ initialValues, disabled } = {})=>{
|
|
8
8
|
const defaultFormValues = useMemo(()=>({
|
|
9
9
|
...defaultValues,
|
|
@@ -14,15 +14,18 @@ export const useCollectionTranslationForm = ({ initialValues, disabled } = {})=>
|
|
|
14
14
|
const form = useForm({
|
|
15
15
|
defaultValues: defaultFormValues,
|
|
16
16
|
resolver: zodResolver(validationSchema),
|
|
17
|
-
mode:
|
|
17
|
+
mode: "onTouched",
|
|
18
18
|
disabled
|
|
19
19
|
});
|
|
20
|
+
const isFirstRender = useRef(true);
|
|
20
21
|
useEffect(()=>{
|
|
22
|
+
if (isFirstRender.current) {
|
|
23
|
+
isFirstRender.current = false;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
21
26
|
form.reset(defaultFormValues);
|
|
22
27
|
}, [
|
|
23
|
-
defaultFormValues
|
|
24
|
-
form,
|
|
25
|
-
form.reset
|
|
28
|
+
defaultFormValues
|
|
26
29
|
]);
|
|
27
30
|
return {
|
|
28
31
|
form
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UseFormReturn } from
|
|
2
|
-
import type { FormInput, FormValues } from
|
|
1
|
+
import type { UseFormReturn } from "react-hook-form";
|
|
2
|
+
import type { FormInput, FormValues } from "./schema";
|
|
3
3
|
type UseFormReturn_ = {
|
|
4
4
|
form: UseFormReturn<FormValues>;
|
|
5
5
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import { zodResolver } from
|
|
3
|
-
import { useEffect, useMemo } from
|
|
4
|
-
import { useForm } from
|
|
5
|
-
import { defaultValues } from
|
|
6
|
-
import { validationSchema } from
|
|
1
|
+
"use client";
|
|
2
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
3
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
4
|
+
import { useForm } from "react-hook-form";
|
|
5
|
+
import { defaultValues } from "./constants";
|
|
6
|
+
import { validationSchema } from "./schema";
|
|
7
7
|
export const useTranslateDocumentForm = ({ initialValues, disabled } = {})=>{
|
|
8
8
|
const defaultFormValues = useMemo(()=>({
|
|
9
9
|
...defaultValues,
|
|
@@ -14,15 +14,18 @@ export const useTranslateDocumentForm = ({ initialValues, disabled } = {})=>{
|
|
|
14
14
|
const form = useForm({
|
|
15
15
|
defaultValues: defaultFormValues,
|
|
16
16
|
resolver: zodResolver(validationSchema),
|
|
17
|
-
mode:
|
|
17
|
+
mode: "onTouched",
|
|
18
18
|
disabled
|
|
19
19
|
});
|
|
20
|
+
const isFirstRender = useRef(true);
|
|
20
21
|
useEffect(()=>{
|
|
22
|
+
if (isFirstRender.current) {
|
|
23
|
+
isFirstRender.current = false;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
21
26
|
form.reset(defaultFormValues);
|
|
22
27
|
}, [
|
|
23
|
-
defaultFormValues
|
|
24
|
-
form,
|
|
25
|
-
form.reset
|
|
28
|
+
defaultFormValues
|
|
26
29
|
]);
|
|
27
30
|
return {
|
|
28
31
|
form
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@focus-reactive/payload-plugin-translator",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Translation plugin for Payload CMS 3.x. Automatically translate your localized content using any translation provider.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "bun run clean && bun run build:swc && bun run build:types && bun run copyfiles",
|
|
49
49
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths --ignore '**/*.test.ts' --ignore '**/*.d.ts' --ignore '**/__tests__/**' --ignore '**/__mocks__/**'",
|
|
50
|
-
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
50
|
+
"build:types": "tsc --emitDeclarationOnly --declaration --outDir dist",
|
|
51
51
|
"copyfiles": "copyfiles -u 1 \"src/**/*.scss\" dist",
|
|
52
52
|
"clean": "rm -rf dist",
|
|
53
53
|
"dev": "bun run build:swc -- --watch",
|
|
54
|
-
"lint": "
|
|
55
|
-
"lint:fix": "
|
|
54
|
+
"lint": "ultracite check",
|
|
55
|
+
"lint:fix": "ultracite fix",
|
|
56
56
|
"test": "vitest run",
|
|
57
57
|
"test:watch": "vitest",
|
|
58
|
-
"check-types": "
|
|
58
|
+
"check-types": "tsgo --noEmit"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@payloadcms/richtext-lexical": "^3.76.0",
|
|
@@ -84,14 +84,9 @@
|
|
|
84
84
|
"@types/react": "19.2.9",
|
|
85
85
|
"@vitest/coverage-v8": "3.2.4",
|
|
86
86
|
"copyfiles": "2.4.1",
|
|
87
|
-
"eslint": "9.0.0",
|
|
88
|
-
"eslint-config-prettier": "9.0.0",
|
|
89
|
-
"next": "15.4.11",
|
|
90
87
|
"payload": "3.79.0",
|
|
91
88
|
"react": "19.0.0",
|
|
92
89
|
"typescript": "5.5.2",
|
|
93
|
-
"eslint-plugin-react-hooks": "6.0.0-rc.2",
|
|
94
|
-
"typescript-eslint": "8.0.0",
|
|
95
90
|
"vitest": "3.2.4"
|
|
96
91
|
}
|
|
97
92
|
}
|