@ram_28/kf-ai-sdk 1.0.8 → 1.0.10
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/components/hooks/index.d.ts +2 -1
- package/dist/components/hooks/index.d.ts.map +1 -1
- package/dist/components/hooks/useForm/apiClient.d.ts +4 -4
- package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
- package/dist/components/hooks/useForm/expressionValidator.utils.d.ts +3 -3
- package/dist/components/hooks/useForm/expressionValidator.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/index.d.ts +7 -4
- package/dist/components/hooks/useForm/index.d.ts.map +1 -1
- package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts +5 -5
- package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts +7 -6
- package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/schemaParser.utils.d.ts +8 -8
- package/dist/components/hooks/useForm/schemaParser.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/types.d.ts +130 -112
- package/dist/components/hooks/useForm/types.d.ts.map +1 -1
- package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
- package/dist/index.cjs +13 -13
- package/dist/index.mjs +2082 -2067
- package/package.json +1 -1
- package/sdk/components/hooks/index.ts +24 -4
- package/sdk/components/hooks/useForm/apiClient.ts +5 -5
- package/sdk/components/hooks/useForm/expressionValidator.utils.ts +11 -11
- package/sdk/components/hooks/useForm/index.ts +41 -45
- package/sdk/components/hooks/useForm/optimizedExpressionValidator.utils.ts +7 -7
- package/sdk/components/hooks/useForm/ruleClassifier.utils.ts +21 -20
- package/sdk/components/hooks/useForm/schemaParser.utils.ts +36 -41
- package/sdk/components/hooks/useForm/types.ts +156 -141
- package/sdk/components/hooks/useForm/useForm.ts +155 -142
|
@@ -6,8 +6,6 @@ import type {
|
|
|
6
6
|
UseFormRegister,
|
|
7
7
|
Mode,
|
|
8
8
|
FieldValues as RHFFieldValues,
|
|
9
|
-
SubmitHandler,
|
|
10
|
-
SubmitErrorHandler,
|
|
11
9
|
FieldErrors,
|
|
12
10
|
Path,
|
|
13
11
|
PathValue,
|
|
@@ -21,22 +19,31 @@ import type {
|
|
|
21
19
|
// ============================================================
|
|
22
20
|
|
|
23
21
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* HandleSubmit follows React Hook Form's signature pattern
|
|
23
|
+
*
|
|
24
|
+
* - onSuccess: Called with the API response data on successful submission
|
|
25
|
+
* - onError: Called with either FieldErrors (validation failed) or Error (API failed)
|
|
26
|
+
*
|
|
27
|
+
* Internal flow:
|
|
28
|
+
* 1. RHF validation + Cross-field validation → FAILS → onError(fieldErrors)
|
|
29
|
+
* 2. Clean data & call API → FAILS → onError(apiError)
|
|
30
|
+
* 3. SUCCESS → onSuccess(responseData)
|
|
26
31
|
*/
|
|
27
|
-
export type
|
|
28
|
-
(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
export type HandleSubmit<T extends RHFFieldValues> = (
|
|
33
|
+
onSuccess?: (data: T, e?: React.BaseSyntheticEvent) => void | Promise<void>,
|
|
34
|
+
onError?: (
|
|
35
|
+
error: FieldErrors<T> | Error,
|
|
36
|
+
e?: React.BaseSyntheticEvent
|
|
37
|
+
) => void | Promise<void>
|
|
38
|
+
) => (e?: React.BaseSyntheticEvent) => Promise<void>;
|
|
33
39
|
|
|
34
40
|
// ============================================================
|
|
35
|
-
//
|
|
41
|
+
// EXPRESSION TREE TYPES
|
|
36
42
|
// ============================================================
|
|
37
43
|
|
|
38
44
|
/**
|
|
39
45
|
* Expression tree node types from backend validation system
|
|
46
|
+
* Used for evaluating validation rules, computed fields, and default values
|
|
40
47
|
*/
|
|
41
48
|
export interface ExpressionTree {
|
|
42
49
|
Type:
|
|
@@ -62,10 +69,15 @@ export interface ExpressionTree {
|
|
|
62
69
|
Value?: any;
|
|
63
70
|
}
|
|
64
71
|
|
|
72
|
+
// ============================================================
|
|
73
|
+
// SCHEMA DEFINITION TYPES (BDO - Business Data Object)
|
|
74
|
+
// ============================================================
|
|
75
|
+
|
|
65
76
|
/**
|
|
66
|
-
*
|
|
77
|
+
* Validation rule from BDO schema
|
|
78
|
+
* Defines a validation, computation, or business logic rule
|
|
67
79
|
*/
|
|
68
|
-
export interface
|
|
80
|
+
export interface SchemaValidationRule {
|
|
69
81
|
Id: string;
|
|
70
82
|
Name: string;
|
|
71
83
|
Description: string;
|
|
@@ -76,9 +88,9 @@ export interface ValidationRule {
|
|
|
76
88
|
}
|
|
77
89
|
|
|
78
90
|
/**
|
|
79
|
-
*
|
|
91
|
+
* Formula definition for computed fields
|
|
80
92
|
*/
|
|
81
|
-
export interface
|
|
93
|
+
export interface ComputedFieldFormula {
|
|
82
94
|
Id?: string;
|
|
83
95
|
Name?: string;
|
|
84
96
|
Description?: string;
|
|
@@ -88,17 +100,17 @@ export interface Formula {
|
|
|
88
100
|
}
|
|
89
101
|
|
|
90
102
|
/**
|
|
91
|
-
*
|
|
103
|
+
* Default value expression for a field
|
|
92
104
|
*/
|
|
93
|
-
export interface
|
|
105
|
+
export interface DefaultValueExpression {
|
|
94
106
|
Expression: string;
|
|
95
107
|
ExpressionTree: ExpressionTree;
|
|
96
108
|
}
|
|
97
109
|
|
|
98
110
|
/**
|
|
99
|
-
*
|
|
111
|
+
* Reference field configuration for dynamic lookups
|
|
100
112
|
*/
|
|
101
|
-
export interface
|
|
113
|
+
export interface ReferenceFieldConfig {
|
|
102
114
|
Mode: "Dynamic" | "Static";
|
|
103
115
|
Reference?: {
|
|
104
116
|
BusinessObject: string;
|
|
@@ -108,7 +120,7 @@ export interface ReferenceField {
|
|
|
108
120
|
LhsField: string;
|
|
109
121
|
Operator: string;
|
|
110
122
|
RhsType: string;
|
|
111
|
-
RhsValue?:
|
|
123
|
+
RhsValue?: DefaultValueExpression;
|
|
112
124
|
}>;
|
|
113
125
|
};
|
|
114
126
|
Sort?: Array<{
|
|
@@ -119,21 +131,21 @@ export interface ReferenceField {
|
|
|
119
131
|
}
|
|
120
132
|
|
|
121
133
|
/**
|
|
122
|
-
*
|
|
134
|
+
* Field options configuration for select/dropdown fields
|
|
123
135
|
*/
|
|
124
|
-
export interface
|
|
136
|
+
export interface FieldOptionsConfig {
|
|
125
137
|
Mode: "Static" | "Dynamic";
|
|
126
138
|
Items?: Array<{
|
|
127
139
|
Value: string | number | boolean;
|
|
128
140
|
Label: string;
|
|
129
141
|
}>;
|
|
130
|
-
Reference?:
|
|
142
|
+
Reference?: ReferenceFieldConfig["Reference"];
|
|
131
143
|
}
|
|
132
144
|
|
|
133
145
|
/**
|
|
134
|
-
*
|
|
146
|
+
* BDO field definition structure
|
|
135
147
|
*/
|
|
136
|
-
export interface
|
|
148
|
+
export interface BDOFieldDefinition {
|
|
137
149
|
Id: string;
|
|
138
150
|
Name: string;
|
|
139
151
|
Type:
|
|
@@ -148,16 +160,16 @@ export interface BackendFieldDefinition {
|
|
|
148
160
|
| "ActivityFlow";
|
|
149
161
|
Required?: boolean;
|
|
150
162
|
Unique?: boolean;
|
|
151
|
-
DefaultValue?:
|
|
152
|
-
Formula?:
|
|
163
|
+
DefaultValue?: DefaultValueExpression;
|
|
164
|
+
Formula?: ComputedFieldFormula;
|
|
153
165
|
Computed?: boolean;
|
|
154
|
-
Validation?: string[] |
|
|
155
|
-
Values?:
|
|
166
|
+
Validation?: string[] | SchemaValidationRule[]; // Array of rule IDs OR inline validation rule objects
|
|
167
|
+
Values?: FieldOptionsConfig;
|
|
156
168
|
Items?: {
|
|
157
169
|
Type: string;
|
|
158
|
-
Property?: Record<string,
|
|
170
|
+
Property?: Record<string, BDOFieldDefinition>;
|
|
159
171
|
};
|
|
160
|
-
Property?: Record<string,
|
|
172
|
+
Property?: Record<string, BDOFieldDefinition>;
|
|
161
173
|
Description?: string;
|
|
162
174
|
}
|
|
163
175
|
|
|
@@ -165,9 +177,9 @@ export interface BackendFieldDefinition {
|
|
|
165
177
|
* Business Object Rule definitions from BDO schema
|
|
166
178
|
*/
|
|
167
179
|
export interface BusinessObjectRules {
|
|
168
|
-
Computation?: Record<string,
|
|
169
|
-
Validation?: Record<string,
|
|
170
|
-
BusinessLogic?: Record<string,
|
|
180
|
+
Computation?: Record<string, SchemaValidationRule>;
|
|
181
|
+
Validation?: Record<string, SchemaValidationRule>;
|
|
182
|
+
BusinessLogic?: Record<string, SchemaValidationRule>;
|
|
171
183
|
}
|
|
172
184
|
|
|
173
185
|
/**
|
|
@@ -189,7 +201,7 @@ export interface RolePermission {
|
|
|
189
201
|
}
|
|
190
202
|
|
|
191
203
|
/**
|
|
192
|
-
* Complete BDO
|
|
204
|
+
* Complete BDO (Business Data Object) schema structure
|
|
193
205
|
*/
|
|
194
206
|
export interface BDOSchema {
|
|
195
207
|
Id: string;
|
|
@@ -197,7 +209,7 @@ export interface BDOSchema {
|
|
|
197
209
|
Kind: "BusinessObject";
|
|
198
210
|
Description: string;
|
|
199
211
|
Rules: BusinessObjectRules;
|
|
200
|
-
Fields: Record<string,
|
|
212
|
+
Fields: Record<string, BDOFieldDefinition>;
|
|
201
213
|
RolePermission: Record<string, RolePermission>;
|
|
202
214
|
Roles: Record<
|
|
203
215
|
string,
|
|
@@ -208,13 +220,6 @@ export interface BDOSchema {
|
|
|
208
220
|
>;
|
|
209
221
|
}
|
|
210
222
|
|
|
211
|
-
/**
|
|
212
|
-
* Complete backend schema response structure (legacy support)
|
|
213
|
-
*/
|
|
214
|
-
export interface BackendSchema {
|
|
215
|
-
[fieldName: string]: BackendFieldDefinition;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
223
|
// ============================================================
|
|
219
224
|
// FORM CONFIGURATION TYPES
|
|
220
225
|
// ============================================================
|
|
@@ -234,18 +239,6 @@ export type FormMode = Mode;
|
|
|
234
239
|
*/
|
|
235
240
|
export type RuleType = "Validation" | "Computation" | "BusinessLogic";
|
|
236
241
|
|
|
237
|
-
/**
|
|
238
|
-
* Rule execution context
|
|
239
|
-
*/
|
|
240
|
-
export interface RuleExecutionContext<T> {
|
|
241
|
-
ruleType: RuleType;
|
|
242
|
-
ruleId: string;
|
|
243
|
-
fieldName: keyof T;
|
|
244
|
-
fieldValue: any;
|
|
245
|
-
formValues: Partial<T>;
|
|
246
|
-
rule: ValidationRule;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
242
|
/**
|
|
250
243
|
* useForm hook options with strict typing
|
|
251
244
|
*/
|
|
@@ -289,26 +282,14 @@ export interface UseFormOptions<
|
|
|
289
282
|
/** User role for permission enforcement */
|
|
290
283
|
userRole?: string;
|
|
291
284
|
|
|
292
|
-
/**
|
|
293
|
-
onSuccess?: (data: T) => void;
|
|
294
|
-
|
|
295
|
-
/** Error callback */
|
|
296
|
-
onError?: (error: Error) => void;
|
|
297
|
-
|
|
298
|
-
/** Schema load error callback */
|
|
285
|
+
/** Schema load error callback (separate concern from form submission) */
|
|
299
286
|
onSchemaError?: (error: Error) => void;
|
|
300
287
|
|
|
301
|
-
/** Submit error callback */
|
|
302
|
-
onSubmitError?: (error: Error) => void;
|
|
303
|
-
|
|
304
|
-
/** Computation rule callback (called when computation rules are triggered) */
|
|
305
|
-
onComputationRule?: (context: RuleExecutionContext<T>) => Promise<Partial<T>>;
|
|
306
|
-
|
|
307
288
|
/** Skip schema fetching (use for testing) */
|
|
308
289
|
skipSchemaFetch?: boolean;
|
|
309
290
|
|
|
310
291
|
/** Manual schema (use instead of fetching) */
|
|
311
|
-
schema?:
|
|
292
|
+
schema?: BDOSchema;
|
|
312
293
|
|
|
313
294
|
/**
|
|
314
295
|
* Trigger draft API call on every field change (after validation passes)
|
|
@@ -319,7 +300,7 @@ export interface UseFormOptions<
|
|
|
319
300
|
}
|
|
320
301
|
|
|
321
302
|
// ============================================================
|
|
322
|
-
//
|
|
303
|
+
// FORM FIELD CONFIGURATION TYPES
|
|
323
304
|
// ============================================================
|
|
324
305
|
|
|
325
306
|
/**
|
|
@@ -337,98 +318,108 @@ export interface FieldPermission {
|
|
|
337
318
|
}
|
|
338
319
|
|
|
339
320
|
/**
|
|
340
|
-
*
|
|
321
|
+
* Field input types for form rendering
|
|
322
|
+
*/
|
|
323
|
+
export type FormFieldType =
|
|
324
|
+
| "text"
|
|
325
|
+
| "number"
|
|
326
|
+
| "email"
|
|
327
|
+
| "password"
|
|
328
|
+
| "date"
|
|
329
|
+
| "datetime-local"
|
|
330
|
+
| "checkbox"
|
|
331
|
+
| "select"
|
|
332
|
+
| "textarea"
|
|
333
|
+
| "reference";
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Select option for dropdown fields
|
|
337
|
+
*/
|
|
338
|
+
export interface SelectOption {
|
|
339
|
+
value: any;
|
|
340
|
+
label: string;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Field rule IDs by category
|
|
345
|
+
*/
|
|
346
|
+
export interface FieldRuleIds {
|
|
347
|
+
validation: string[];
|
|
348
|
+
computation: string[];
|
|
349
|
+
businessLogic: string[];
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Form field configuration for rendering
|
|
354
|
+
* Contains all metadata needed to render and validate a form field
|
|
341
355
|
*/
|
|
342
|
-
export interface
|
|
343
|
-
/** Field name */
|
|
356
|
+
export interface FormFieldConfig {
|
|
357
|
+
/** Field name/identifier */
|
|
344
358
|
name: string;
|
|
345
359
|
|
|
346
|
-
/** Field type */
|
|
347
|
-
type:
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
| "email"
|
|
351
|
-
| "password"
|
|
352
|
-
| "date"
|
|
353
|
-
| "datetime-local"
|
|
354
|
-
| "checkbox"
|
|
355
|
-
| "select"
|
|
356
|
-
| "textarea"
|
|
357
|
-
| "reference";
|
|
358
|
-
|
|
359
|
-
/** Field label (derived from name or schema) */
|
|
360
|
+
/** Field input type */
|
|
361
|
+
type: FormFieldType;
|
|
362
|
+
|
|
363
|
+
/** Display label */
|
|
360
364
|
label: string;
|
|
361
365
|
|
|
362
366
|
/** Whether field is required */
|
|
363
367
|
required: boolean;
|
|
364
368
|
|
|
365
|
-
/** Whether field is computed (read-only) */
|
|
369
|
+
/** Whether field is computed (read-only, auto-calculated) */
|
|
366
370
|
computed: boolean;
|
|
367
371
|
|
|
368
372
|
/** Default value */
|
|
369
373
|
defaultValue?: any;
|
|
370
374
|
|
|
371
375
|
/** Select options (for select/reference fields) */
|
|
372
|
-
options?:
|
|
373
|
-
value: any;
|
|
374
|
-
label: string;
|
|
375
|
-
}>;
|
|
376
|
+
options?: SelectOption[];
|
|
376
377
|
|
|
377
|
-
/** Validation
|
|
378
|
+
/** Validation configuration */
|
|
378
379
|
validation: any;
|
|
379
380
|
|
|
380
381
|
/** Field description/help text */
|
|
381
382
|
description?: string;
|
|
382
383
|
|
|
383
|
-
/**
|
|
384
|
-
|
|
384
|
+
/** Original BDO field definition (for advanced use) */
|
|
385
|
+
_bdoField: BDOFieldDefinition;
|
|
385
386
|
|
|
386
387
|
/** Field permissions for current user */
|
|
387
388
|
permission: FieldPermission;
|
|
388
389
|
|
|
389
|
-
/**
|
|
390
|
-
rules:
|
|
391
|
-
validation: string[];
|
|
392
|
-
computation: string[];
|
|
393
|
-
businessLogic: string[];
|
|
394
|
-
};
|
|
390
|
+
/** Associated rule IDs by category */
|
|
391
|
+
rules: FieldRuleIds;
|
|
395
392
|
}
|
|
396
393
|
|
|
397
394
|
/**
|
|
398
|
-
* Form schema after processing
|
|
395
|
+
* Form schema configuration after processing
|
|
396
|
+
* Contains all fields and rules ready for form rendering
|
|
399
397
|
*/
|
|
400
|
-
export interface
|
|
401
|
-
/** All fields */
|
|
402
|
-
fields: Record<string,
|
|
398
|
+
export interface FormSchemaConfig {
|
|
399
|
+
/** All fields by name */
|
|
400
|
+
fields: Record<string, FormFieldConfig>;
|
|
403
401
|
|
|
404
|
-
/** Field names in order */
|
|
402
|
+
/** Field names in display order */
|
|
405
403
|
fieldOrder: string[];
|
|
406
404
|
|
|
407
|
-
/**
|
|
405
|
+
/** Names of computed fields */
|
|
408
406
|
computedFields: string[];
|
|
409
407
|
|
|
410
|
-
/**
|
|
408
|
+
/** Names of required fields */
|
|
411
409
|
requiredFields: string[];
|
|
412
410
|
|
|
413
411
|
/** Cross-field validation rules */
|
|
414
|
-
crossFieldValidation:
|
|
412
|
+
crossFieldValidation: SchemaValidationRule[];
|
|
415
413
|
|
|
416
414
|
/** Classified rules by type */
|
|
417
415
|
rules: {
|
|
418
|
-
validation: Record<string,
|
|
419
|
-
computation: Record<string,
|
|
420
|
-
businessLogic: Record<string,
|
|
416
|
+
validation: Record<string, SchemaValidationRule>;
|
|
417
|
+
computation: Record<string, SchemaValidationRule>;
|
|
418
|
+
businessLogic: Record<string, SchemaValidationRule>;
|
|
421
419
|
};
|
|
422
420
|
|
|
423
421
|
/** Field-to-rule mapping for quick lookup */
|
|
424
|
-
fieldRules: Record<
|
|
425
|
-
string,
|
|
426
|
-
{
|
|
427
|
-
validation: string[];
|
|
428
|
-
computation: string[];
|
|
429
|
-
businessLogic: string[];
|
|
430
|
-
}
|
|
431
|
-
>;
|
|
422
|
+
fieldRules: Record<string, FieldRuleIds>;
|
|
432
423
|
|
|
433
424
|
/** Role permissions */
|
|
434
425
|
rolePermissions?: Record<string, RolePermission>;
|
|
@@ -454,8 +445,38 @@ export interface UseFormReturn<
|
|
|
454
445
|
options?: RegisterOptions<T, K>
|
|
455
446
|
) => ReturnType<UseFormRegister<T>>;
|
|
456
447
|
|
|
457
|
-
/**
|
|
458
|
-
|
|
448
|
+
/**
|
|
449
|
+
* Handle form submission with optional callbacks
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* // Basic usage - no callbacks
|
|
453
|
+
* <form onSubmit={form.handleSubmit()}>
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* // With success callback
|
|
457
|
+
* <form onSubmit={form.handleSubmit((data) => {
|
|
458
|
+
* toast.success("Saved!");
|
|
459
|
+
* navigate("/products/" + data._id);
|
|
460
|
+
* })}>
|
|
461
|
+
*
|
|
462
|
+
* @example
|
|
463
|
+
* // With both callbacks
|
|
464
|
+
* <form onSubmit={form.handleSubmit(
|
|
465
|
+
* (data) => toast.success("Saved!"),
|
|
466
|
+
* (error) => {
|
|
467
|
+
* if (error instanceof Error) {
|
|
468
|
+
* toast.error(error.message); // API error
|
|
469
|
+
* } else {
|
|
470
|
+
* toast.error("Please fix the form errors"); // Validation errors
|
|
471
|
+
* }
|
|
472
|
+
* }
|
|
473
|
+
* )}>
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* // Programmatic submission
|
|
477
|
+
* await form.handleSubmit(onSuccess, onError)();
|
|
478
|
+
*/
|
|
479
|
+
handleSubmit: HandleSubmit<T>;
|
|
459
480
|
|
|
460
481
|
/** Watch field values with strict typing */
|
|
461
482
|
watch: <K extends Path<T> | readonly Path<T>[]>(
|
|
@@ -522,9 +543,6 @@ export interface UseFormReturn<
|
|
|
522
543
|
/** Schema fetch error */
|
|
523
544
|
loadError: Error | null;
|
|
524
545
|
|
|
525
|
-
/** Form submission error */
|
|
526
|
-
submitError: Error | null;
|
|
527
|
-
|
|
528
546
|
/** Any error active */
|
|
529
547
|
hasError: boolean;
|
|
530
548
|
|
|
@@ -532,11 +550,11 @@ export interface UseFormReturn<
|
|
|
532
550
|
// SCHEMA INFORMATION WITH STRICT TYPING
|
|
533
551
|
// ============================================================
|
|
534
552
|
|
|
535
|
-
/** Raw
|
|
536
|
-
schema:
|
|
553
|
+
/** Raw BDO schema */
|
|
554
|
+
schema: BDOSchema | null;
|
|
537
555
|
|
|
538
|
-
/** Processed schema for rendering */
|
|
539
|
-
|
|
556
|
+
/** Processed schema configuration for rendering */
|
|
557
|
+
schemaConfig: FormSchemaConfig | null;
|
|
540
558
|
|
|
541
559
|
/** Computed field names as typed array */
|
|
542
560
|
computedFields: Array<keyof T>;
|
|
@@ -548,11 +566,11 @@ export interface UseFormReturn<
|
|
|
548
566
|
// FIELD HELPERS WITH STRICT TYPING
|
|
549
567
|
// ============================================================
|
|
550
568
|
|
|
551
|
-
/** Get field
|
|
552
|
-
getField: <K extends keyof T>(fieldName: K) =>
|
|
569
|
+
/** Get field configuration with strict typing */
|
|
570
|
+
getField: <K extends keyof T>(fieldName: K) => FormFieldConfig | null;
|
|
553
571
|
|
|
554
|
-
/** Get all
|
|
555
|
-
getFields: () => Record<keyof T,
|
|
572
|
+
/** Get all field configurations with strict typing */
|
|
573
|
+
getFields: () => Record<keyof T, FormFieldConfig>;
|
|
556
574
|
|
|
557
575
|
/** Check if field exists with strict typing */
|
|
558
576
|
hasField: <K extends keyof T>(fieldName: K) => boolean;
|
|
@@ -567,9 +585,6 @@ export interface UseFormReturn<
|
|
|
567
585
|
// OPERATIONS
|
|
568
586
|
// ============================================================
|
|
569
587
|
|
|
570
|
-
/** Submit form manually */
|
|
571
|
-
submit: () => Promise<void>;
|
|
572
|
-
|
|
573
588
|
/** Refresh schema */
|
|
574
589
|
refreshSchema: () => Promise<void>;
|
|
575
590
|
|
|
@@ -581,13 +596,13 @@ export interface UseFormReturn<
|
|
|
581
596
|
}
|
|
582
597
|
|
|
583
598
|
// ============================================================
|
|
584
|
-
//
|
|
599
|
+
// RESULT TYPES
|
|
585
600
|
// ============================================================
|
|
586
601
|
|
|
587
602
|
/**
|
|
588
|
-
* Expression evaluation context
|
|
603
|
+
* Expression evaluation context
|
|
589
604
|
*/
|
|
590
|
-
export interface
|
|
605
|
+
export interface ExpressionContext<T = Record<string, any>> {
|
|
591
606
|
/** Current form values */
|
|
592
607
|
formValues: Partial<T>;
|
|
593
608
|
|
|
@@ -599,9 +614,9 @@ export interface EvaluationContext<T = Record<string, any>> {
|
|
|
599
614
|
}
|
|
600
615
|
|
|
601
616
|
/**
|
|
602
|
-
*
|
|
617
|
+
* Field validation result
|
|
603
618
|
*/
|
|
604
|
-
export interface
|
|
619
|
+
export interface FieldValidationResult<T = Record<string, any>> {
|
|
605
620
|
/** Is validation passing */
|
|
606
621
|
isValid: boolean;
|
|
607
622
|
|