@ram_28/kf-ai-sdk 2.0.13 → 2.0.15
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/README.md +2 -1
- package/dist/FileField-BWrSHNRq.js +296 -0
- package/dist/FileField-eDeuzln8.cjs +1 -0
- package/dist/api.cjs +1 -1
- package/dist/api.mjs +2 -2
- package/dist/auth.cjs +1 -1
- package/dist/auth.mjs +1 -1
- package/dist/bdo.cjs +1 -1
- package/dist/bdo.mjs +228 -472
- package/dist/{client-DnO2KKrw.cjs → client-D5k4SYuw.cjs} +1 -1
- package/dist/{client-iQTqFDNI.js → client-_ayziI1d.js} +33 -32
- package/dist/components/hooks/index.d.ts +9 -3
- package/dist/components/hooks/index.d.ts.map +1 -1
- package/dist/{workflow/components → components/hooks}/useActivityForm/createActivityItemProxy.d.ts +9 -5
- package/dist/components/hooks/useActivityForm/createActivityItemProxy.d.ts.map +1 -0
- package/dist/components/hooks/useActivityForm/createActivityResolver.d.ts +23 -0
- package/dist/components/hooks/useActivityForm/createActivityResolver.d.ts.map +1 -0
- package/dist/components/hooks/useActivityForm/index.d.ts.map +1 -0
- package/dist/{workflow/components → components/hooks}/useActivityForm/types.d.ts +11 -7
- package/dist/components/hooks/useActivityForm/types.d.ts.map +1 -0
- package/dist/{workflow/components → components/hooks}/useActivityForm/useActivityForm.d.ts +2 -2
- package/dist/components/hooks/useActivityForm/useActivityForm.d.ts.map +1 -0
- package/dist/components/hooks/useActivityTable/index.d.ts +4 -0
- package/dist/components/hooks/useActivityTable/index.d.ts.map +1 -0
- package/dist/components/hooks/useActivityTable/types.d.ts +36 -0
- package/dist/components/hooks/useActivityTable/types.d.ts.map +1 -0
- package/dist/components/hooks/useActivityTable/useActivityTable.d.ts +4 -0
- package/dist/components/hooks/useActivityTable/useActivityTable.d.ts.map +1 -0
- package/dist/components/hooks/useBDOTable/index.d.ts +3 -0
- package/dist/components/hooks/useBDOTable/index.d.ts.map +1 -0
- package/dist/components/hooks/useBDOTable/types.d.ts +26 -0
- package/dist/components/hooks/useBDOTable/types.d.ts.map +1 -0
- package/dist/components/hooks/useBDOTable/useBDOTable.d.ts +3 -0
- package/dist/components/hooks/useBDOTable/useBDOTable.d.ts.map +1 -0
- package/dist/components/hooks/useTable/index.d.ts +2 -2
- package/dist/components/hooks/useTable/index.d.ts.map +1 -1
- package/dist/components/hooks/useTable/types.d.ts +11 -10
- package/dist/components/hooks/useTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
- package/dist/createResolver-AIgUwoS6.cjs +1 -0
- package/dist/createResolver-ZHXQ7QMa.js +1078 -0
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +252 -314
- package/dist/{metadata-DpfI3zRN.js → metadata-Cc1mBcLS.js} +1 -1
- package/dist/{metadata-DgLSJkF5.cjs → metadata-DWXQPDav.cjs} +1 -1
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +1 -0
- package/dist/table.d.ts.map +1 -1
- package/dist/table.mjs +16 -192
- package/dist/table.types.d.ts +2 -1
- package/dist/table.types.d.ts.map +1 -1
- package/dist/types/base-fields.d.ts +4 -4
- package/dist/types/base-fields.d.ts.map +1 -1
- package/dist/useTable-CeRklbdT.cjs +1 -0
- package/dist/useTable-DS0-WInw.js +203 -0
- package/dist/workflow/Activity.d.ts +9 -9
- package/dist/workflow/Activity.d.ts.map +1 -1
- package/dist/workflow/client.d.ts.map +1 -1
- package/dist/workflow/createFieldFromMeta.d.ts +29 -0
- package/dist/workflow/createFieldFromMeta.d.ts.map +1 -0
- package/dist/workflow/index.d.ts +1 -2
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/types.d.ts +12 -12
- package/dist/workflow/types.d.ts.map +1 -1
- package/dist/workflow.cjs +1 -1
- package/dist/workflow.d.ts +5 -2
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.mjs +716 -338
- package/dist/workflow.types.d.ts +1 -0
- package/dist/workflow.types.d.ts.map +1 -1
- package/docs/bdo.md +3 -3
- package/docs/gaps.md +410 -0
- package/docs/useActivityTable.md +481 -0
- package/docs/useBDOTable.md +317 -0
- package/docs/useForm.md +4 -1
- package/docs/workflow.md +143 -34
- package/package.json +1 -1
- package/sdk/bdo/fields/UserField.ts +1 -1
- package/sdk/components/hooks/index.ts +28 -5
- package/sdk/components/hooks/useActivityForm/createActivityItemProxy.ts +400 -0
- package/sdk/components/hooks/useActivityForm/createActivityResolver.ts +87 -0
- package/sdk/{workflow/components → components/hooks}/useActivityForm/types.ts +21 -8
- package/sdk/components/hooks/useActivityForm/useActivityForm.ts +628 -0
- package/sdk/components/hooks/useActivityTable/index.ts +8 -0
- package/sdk/components/hooks/useActivityTable/types.ts +45 -0
- package/sdk/components/hooks/useActivityTable/useActivityTable.ts +71 -0
- package/sdk/components/hooks/useBDOTable/index.ts +2 -0
- package/sdk/components/hooks/useBDOTable/types.ts +24 -0
- package/sdk/components/hooks/useBDOTable/useBDOTable.ts +15 -0
- package/sdk/components/hooks/useTable/index.ts +3 -3
- package/sdk/components/hooks/useTable/types.ts +16 -12
- package/sdk/components/hooks/useTable/useTable.ts +56 -49
- package/sdk/table.ts +4 -1
- package/sdk/table.types.ts +7 -4
- package/sdk/types/base-fields.ts +4 -4
- package/sdk/workflow/Activity.ts +14 -13
- package/sdk/workflow/client.ts +21 -8
- package/sdk/workflow/createFieldFromMeta.ts +110 -0
- package/sdk/workflow/index.ts +1 -6
- package/sdk/workflow/types.ts +13 -12
- package/sdk/workflow.ts +11 -2
- package/sdk/workflow.types.ts +7 -0
- package/dist/BaseField-B6da88U7.js +0 -40
- package/dist/BaseField-Drp0-OxL.cjs +0 -1
- package/dist/error-handling-CAoD0Kwb.cjs +0 -1
- package/dist/error-handling-CrhTtD88.js +0 -14
- package/dist/index.esm-Cj63v5ny.js +0 -1014
- package/dist/index.esm-DuwT11sx.cjs +0 -1
- package/dist/workflow/components/useActivityForm/createActivityItemProxy.d.ts.map +0 -1
- package/dist/workflow/components/useActivityForm/createActivityResolver.d.ts +0 -22
- package/dist/workflow/components/useActivityForm/createActivityResolver.d.ts.map +0 -1
- package/dist/workflow/components/useActivityForm/index.d.ts.map +0 -1
- package/dist/workflow/components/useActivityForm/types.d.ts.map +0 -1
- package/dist/workflow/components/useActivityForm/useActivityForm.d.ts.map +0 -1
- package/docs/useTable.md +0 -369
- package/sdk/workflow/components/useActivityForm/createActivityItemProxy.ts +0 -130
- package/sdk/workflow/components/useActivityForm/createActivityResolver.ts +0 -61
- package/sdk/workflow/components/useActivityForm/useActivityForm.ts +0 -386
- /package/dist/{workflow/components → components/hooks}/useActivityForm/index.d.ts +0 -0
- /package/sdk/{workflow/components → components/hooks}/useActivityForm/index.ts +0 -0
|
@@ -1,386 +0,0 @@
|
|
|
1
|
-
// ============================================================
|
|
2
|
-
// USE ACTIVITY FORM HOOK
|
|
3
|
-
// ============================================================
|
|
4
|
-
// React hook for building forms bound to workflow activity input fields.
|
|
5
|
-
// Accepts an Activity class instance and integrates with
|
|
6
|
-
// react-hook-form and the Workflow API client.
|
|
7
|
-
|
|
8
|
-
import { useState, useEffect, useCallback, useMemo, useRef } from "react";
|
|
9
|
-
import { useForm as useReactHookForm } from "react-hook-form";
|
|
10
|
-
import type { Path, FieldValues } from "react-hook-form";
|
|
11
|
-
|
|
12
|
-
import type { Activity } from "../../Activity";
|
|
13
|
-
import type {
|
|
14
|
-
UseActivityFormOptions,
|
|
15
|
-
UseActivityFormReturn,
|
|
16
|
-
AllActivityFields,
|
|
17
|
-
} from "./types";
|
|
18
|
-
|
|
19
|
-
import { createActivityResolver } from "./createActivityResolver";
|
|
20
|
-
import { createActivityItemProxy } from "./createActivityItemProxy";
|
|
21
|
-
import { toError } from "../../../utils/error-handling";
|
|
22
|
-
|
|
23
|
-
// ============================================================
|
|
24
|
-
// MAIN HOOK
|
|
25
|
-
// ============================================================
|
|
26
|
-
|
|
27
|
-
export function useActivityForm<
|
|
28
|
-
A extends Activity<any, any, any>,
|
|
29
|
-
>(
|
|
30
|
-
activity: A,
|
|
31
|
-
options: UseActivityFormOptions<A>,
|
|
32
|
-
): UseActivityFormReturn<A> {
|
|
33
|
-
const {
|
|
34
|
-
activity_instance_id,
|
|
35
|
-
defaultValues = {},
|
|
36
|
-
mode = "onBlur",
|
|
37
|
-
enabled = true,
|
|
38
|
-
} = options;
|
|
39
|
-
|
|
40
|
-
// ============================================================
|
|
41
|
-
// STATE
|
|
42
|
-
// ============================================================
|
|
43
|
-
|
|
44
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
45
|
-
const [loadError, setLoadError] = useState<Error | null>(null);
|
|
46
|
-
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
47
|
-
|
|
48
|
-
// Prevent concurrent draft calls
|
|
49
|
-
const isComputingRef = useRef(false);
|
|
50
|
-
const computeTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
51
|
-
|
|
52
|
-
// ============================================================
|
|
53
|
-
// FIELD DISCOVERY (memoized)
|
|
54
|
-
// ============================================================
|
|
55
|
-
|
|
56
|
-
const fields = useMemo(
|
|
57
|
-
() => activity._getFields(),
|
|
58
|
-
[activity],
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
// Identify readonly fields (editable: false) — these are "computed" in workflow context
|
|
62
|
-
const readonlyFieldNames = useMemo<string[]>(
|
|
63
|
-
() =>
|
|
64
|
-
Object.keys(fields).filter(
|
|
65
|
-
(k) => fields[k].readOnly,
|
|
66
|
-
),
|
|
67
|
-
[fields],
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
// ============================================================
|
|
71
|
-
// RESOLVER (field type validation)
|
|
72
|
-
// ============================================================
|
|
73
|
-
|
|
74
|
-
const resolver = useMemo(
|
|
75
|
-
() => createActivityResolver(activity),
|
|
76
|
-
[activity],
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
// ============================================================
|
|
80
|
-
// REACT HOOK FORM
|
|
81
|
-
// ============================================================
|
|
82
|
-
|
|
83
|
-
const rhf = useReactHookForm({
|
|
84
|
-
mode,
|
|
85
|
-
defaultValues: defaultValues as any,
|
|
86
|
-
resolver,
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// ============================================================
|
|
90
|
-
// ITEM PROXY (always in sync with RHF state)
|
|
91
|
-
// ============================================================
|
|
92
|
-
|
|
93
|
-
const item = useMemo(
|
|
94
|
-
() => createActivityItemProxy(activity, rhf as any),
|
|
95
|
-
[activity, rhf],
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
// ============================================================
|
|
99
|
-
// ACTIVITY OPERATIONS
|
|
100
|
-
// ============================================================
|
|
101
|
-
|
|
102
|
-
const activityRef = useMemo(
|
|
103
|
-
() => activity._getOps(),
|
|
104
|
-
[activity],
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
// ============================================================
|
|
108
|
-
// LOAD EXISTING DATA — activity.read() on mount
|
|
109
|
-
// ============================================================
|
|
110
|
-
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
if (!enabled) return;
|
|
113
|
-
|
|
114
|
-
let active = true;
|
|
115
|
-
|
|
116
|
-
const loadData = async () => {
|
|
117
|
-
setIsLoading(true);
|
|
118
|
-
setLoadError(null);
|
|
119
|
-
|
|
120
|
-
try {
|
|
121
|
-
const data = await activityRef.read(activity_instance_id);
|
|
122
|
-
|
|
123
|
-
if (!active) return;
|
|
124
|
-
|
|
125
|
-
// Populate form with existing data
|
|
126
|
-
if (data && typeof data === "object") {
|
|
127
|
-
rhf.reset({ ...defaultValues, ...data } as any);
|
|
128
|
-
}
|
|
129
|
-
} catch (error) {
|
|
130
|
-
if (!active) return;
|
|
131
|
-
console.error("Failed to read activity data:", error);
|
|
132
|
-
setLoadError(toError(error));
|
|
133
|
-
} finally {
|
|
134
|
-
if (active) {
|
|
135
|
-
setIsLoading(false);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
loadData();
|
|
141
|
-
|
|
142
|
-
return () => {
|
|
143
|
-
active = false;
|
|
144
|
-
};
|
|
145
|
-
}, [enabled, activityRef, activity_instance_id]);
|
|
146
|
-
|
|
147
|
-
// ============================================================
|
|
148
|
-
// DRAFT COMPUTATION ON BLUR
|
|
149
|
-
// ============================================================
|
|
150
|
-
|
|
151
|
-
const triggerDraftComputation = useCallback(
|
|
152
|
-
async (_fieldName: string) => {
|
|
153
|
-
// Only trigger if there are readonly/computed fields that might need updating
|
|
154
|
-
if (readonlyFieldNames.length === 0) return;
|
|
155
|
-
if (isComputingRef.current) return;
|
|
156
|
-
|
|
157
|
-
if (computeTimeoutRef.current) {
|
|
158
|
-
clearTimeout(computeTimeoutRef.current);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
computeTimeoutRef.current = setTimeout(async () => {
|
|
162
|
-
if (isComputingRef.current) return;
|
|
163
|
-
isComputingRef.current = true;
|
|
164
|
-
|
|
165
|
-
try {
|
|
166
|
-
const currentValues = rhf.getValues();
|
|
167
|
-
|
|
168
|
-
// Build payload excluding readonly/computed fields
|
|
169
|
-
const payload: Record<string, unknown> = {};
|
|
170
|
-
const readonlySet = new Set(readonlyFieldNames);
|
|
171
|
-
|
|
172
|
-
Object.keys(currentValues).forEach((key) => {
|
|
173
|
-
if (!readonlySet.has(key)) {
|
|
174
|
-
(payload as any)[key] = (currentValues as any)[key];
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
const response = await activityRef.draftStart(activity_instance_id, payload as any);
|
|
179
|
-
|
|
180
|
-
// Apply computed fields returned from the server
|
|
181
|
-
if (response && typeof response === "object") {
|
|
182
|
-
Object.entries(response).forEach(([key, value]) => {
|
|
183
|
-
if (readonlySet.has(key)) {
|
|
184
|
-
const current = rhf.getValues(key as any);
|
|
185
|
-
if (current !== value) {
|
|
186
|
-
rhf.setValue(key as Path<FieldValues>, value as any, {
|
|
187
|
-
shouldDirty: false,
|
|
188
|
-
shouldValidate: false,
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
} catch (error) {
|
|
195
|
-
console.warn("Draft computation failed:", error);
|
|
196
|
-
} finally {
|
|
197
|
-
isComputingRef.current = false;
|
|
198
|
-
}
|
|
199
|
-
}, 300);
|
|
200
|
-
},
|
|
201
|
-
[activityRef, readonlyFieldNames, rhf],
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
// ============================================================
|
|
205
|
-
// REGISTER (enhanced with onBlur draft computation + auto-disable)
|
|
206
|
-
// ============================================================
|
|
207
|
-
|
|
208
|
-
const register = useCallback(
|
|
209
|
-
(name: string, registerOptions?: any) => {
|
|
210
|
-
const field = fields[name];
|
|
211
|
-
const isReadonly = field ? field.readOnly : false;
|
|
212
|
-
|
|
213
|
-
const originalOnBlur = registerOptions?.onBlur;
|
|
214
|
-
|
|
215
|
-
const enhancedOnBlur = async (e: any) => {
|
|
216
|
-
if (originalOnBlur) {
|
|
217
|
-
await originalOnBlur(e);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// Mode-aware validation
|
|
221
|
-
let isValid = true;
|
|
222
|
-
const shouldTriggerOnBlur =
|
|
223
|
-
mode === "onBlur" || mode === "onTouched" || mode === "all";
|
|
224
|
-
|
|
225
|
-
if (shouldTriggerOnBlur) {
|
|
226
|
-
isValid = await rhf.trigger(name as Path<FieldValues>);
|
|
227
|
-
} else {
|
|
228
|
-
const fieldState = rhf.getFieldState(name as any, rhf.formState);
|
|
229
|
-
isValid = !fieldState.error;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// Fire draft computation if field is valid
|
|
233
|
-
if (isValid) {
|
|
234
|
-
await triggerDraftComputation(name);
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
const result = rhf.register(name as Path<FieldValues>, {
|
|
239
|
-
...registerOptions,
|
|
240
|
-
onBlur: enhancedOnBlur,
|
|
241
|
-
...(isReadonly ? { disabled: true } : {}),
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
// For readonly fields, add disabled flag to the return
|
|
245
|
-
if (isReadonly) {
|
|
246
|
-
return { ...result, disabled: true as const };
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return result;
|
|
250
|
-
},
|
|
251
|
-
[rhf, fields, triggerDraftComputation, mode],
|
|
252
|
-
) as UseActivityFormReturn<A>["register"];
|
|
253
|
-
|
|
254
|
-
// ============================================================
|
|
255
|
-
// HANDLE SUBMIT — activity.update() + activity.draftEnd()
|
|
256
|
-
// ============================================================
|
|
257
|
-
|
|
258
|
-
const handleSubmit = useCallback(
|
|
259
|
-
(
|
|
260
|
-
onSuccess?: (
|
|
261
|
-
data: AllActivityFields<A>,
|
|
262
|
-
e?: React.BaseSyntheticEvent,
|
|
263
|
-
) => void | Promise<void>,
|
|
264
|
-
onError?: (
|
|
265
|
-
error: any,
|
|
266
|
-
e?: React.BaseSyntheticEvent,
|
|
267
|
-
) => void | Promise<void>,
|
|
268
|
-
) => {
|
|
269
|
-
return rhf.handleSubmit(
|
|
270
|
-
async (data, event) => {
|
|
271
|
-
setIsSubmitting(true);
|
|
272
|
-
|
|
273
|
-
try {
|
|
274
|
-
// Build clean payload (exclude readonly/computed fields)
|
|
275
|
-
const cleanedData: Record<string, unknown> = {};
|
|
276
|
-
const readonlySet = new Set(readonlyFieldNames);
|
|
277
|
-
|
|
278
|
-
Object.keys(data).forEach((key) => {
|
|
279
|
-
if (!readonlySet.has(key) && (data as any)[key] !== undefined) {
|
|
280
|
-
cleanedData[key] = (data as any)[key];
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
// Save via activity.update() then activity.draftEnd()
|
|
285
|
-
await activityRef.update(activity_instance_id, cleanedData as any);
|
|
286
|
-
await activityRef.draftEnd(activity_instance_id, cleanedData as any);
|
|
287
|
-
|
|
288
|
-
await onSuccess?.(data as AllActivityFields<A>, event);
|
|
289
|
-
} catch (error) {
|
|
290
|
-
onError?.(toError(error), event);
|
|
291
|
-
} finally {
|
|
292
|
-
setIsSubmitting(false);
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
(errors, event) => {
|
|
296
|
-
onError?.(errors, event);
|
|
297
|
-
},
|
|
298
|
-
);
|
|
299
|
-
},
|
|
300
|
-
[rhf, activityRef, readonlyFieldNames],
|
|
301
|
-
) as UseActivityFormReturn<A>["handleSubmit"];
|
|
302
|
-
|
|
303
|
-
// ============================================================
|
|
304
|
-
// HANDLE COMPLETE — activity.complete()
|
|
305
|
-
// ============================================================
|
|
306
|
-
|
|
307
|
-
const handleComplete = useCallback(
|
|
308
|
-
(
|
|
309
|
-
onSuccess?: (
|
|
310
|
-
data: AllActivityFields<A>,
|
|
311
|
-
e?: React.BaseSyntheticEvent,
|
|
312
|
-
) => void | Promise<void>,
|
|
313
|
-
onError?: (
|
|
314
|
-
error: any,
|
|
315
|
-
e?: React.BaseSyntheticEvent,
|
|
316
|
-
) => void | Promise<void>,
|
|
317
|
-
) => {
|
|
318
|
-
return rhf.handleSubmit(
|
|
319
|
-
async (data, event) => {
|
|
320
|
-
setIsSubmitting(true);
|
|
321
|
-
|
|
322
|
-
try {
|
|
323
|
-
await activityRef.complete(activity_instance_id);
|
|
324
|
-
await onSuccess?.(data as AllActivityFields<A>, event);
|
|
325
|
-
} catch (error) {
|
|
326
|
-
onError?.(toError(error), event);
|
|
327
|
-
} finally {
|
|
328
|
-
setIsSubmitting(false);
|
|
329
|
-
}
|
|
330
|
-
},
|
|
331
|
-
(errors, event) => {
|
|
332
|
-
onError?.(errors, event);
|
|
333
|
-
},
|
|
334
|
-
);
|
|
335
|
-
},
|
|
336
|
-
[rhf, activityRef],
|
|
337
|
-
) as UseActivityFormReturn<A>["handleComplete"];
|
|
338
|
-
|
|
339
|
-
// ============================================================
|
|
340
|
-
// CLEAR ERRORS
|
|
341
|
-
// ============================================================
|
|
342
|
-
|
|
343
|
-
const clearErrors = useCallback((): void => {
|
|
344
|
-
rhf.clearErrors();
|
|
345
|
-
}, [rhf]);
|
|
346
|
-
|
|
347
|
-
// ============================================================
|
|
348
|
-
// RETURN
|
|
349
|
-
// ============================================================
|
|
350
|
-
|
|
351
|
-
const hasError = !!loadError;
|
|
352
|
-
|
|
353
|
-
return {
|
|
354
|
-
// Item proxy
|
|
355
|
-
item,
|
|
356
|
-
|
|
357
|
-
// Activity reference
|
|
358
|
-
activity,
|
|
359
|
-
|
|
360
|
-
// Form methods
|
|
361
|
-
register,
|
|
362
|
-
handleSubmit,
|
|
363
|
-
handleComplete,
|
|
364
|
-
watch: rhf.watch as any,
|
|
365
|
-
setValue: rhf.setValue as any,
|
|
366
|
-
getValues: rhf.getValues as any,
|
|
367
|
-
reset: rhf.reset as any,
|
|
368
|
-
trigger: rhf.trigger as any,
|
|
369
|
-
control: rhf.control as any,
|
|
370
|
-
|
|
371
|
-
// Flattened form state
|
|
372
|
-
errors: rhf.formState.errors as any,
|
|
373
|
-
isValid: rhf.formState.isValid,
|
|
374
|
-
isDirty: rhf.formState.isDirty,
|
|
375
|
-
isSubmitting: rhf.formState.isSubmitting || isSubmitting,
|
|
376
|
-
isSubmitSuccessful: rhf.formState.isSubmitSuccessful,
|
|
377
|
-
|
|
378
|
-
// Loading
|
|
379
|
-
isLoading,
|
|
380
|
-
loadError,
|
|
381
|
-
hasError,
|
|
382
|
-
|
|
383
|
-
// Operations
|
|
384
|
-
clearErrors,
|
|
385
|
-
};
|
|
386
|
-
}
|
|
File without changes
|
|
File without changes
|