@connect-soft/form-generator 1.1.0-alpha8 → 1.1.0-alpha9
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 +219 -0
- package/dist/index.js +415 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +410 -44
- package/dist/index.mjs.map +1 -1
- package/dist/types/components/form/fields-context.d.ts +26 -0
- package/dist/types/components/form/fields-context.d.ts.map +1 -0
- package/dist/types/components/form/form-generator-typed.d.ts +49 -0
- package/dist/types/components/form/form-generator-typed.d.ts.map +1 -0
- package/dist/types/components/form/form-generator.d.ts +7 -20
- package/dist/types/components/form/form-generator.d.ts.map +1 -1
- package/dist/types/components/form/form-utils.d.ts +4 -2
- package/dist/types/components/form/form-utils.d.ts.map +1 -1
- package/dist/types/components/form/index.d.ts +1 -1
- package/dist/types/components/form/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3407,6 +3407,167 @@ function createTemplateFields(fieldEntries) {
|
|
|
3407
3407
|
return new Proxy({}, handler);
|
|
3408
3408
|
}
|
|
3409
3409
|
|
|
3410
|
+
const FieldsContext = /*#__PURE__*/React.createContext(null);
|
|
3411
|
+
function FieldsProvider(t0) {
|
|
3412
|
+
const $ = compilerRuntime.c(9);
|
|
3413
|
+
const {
|
|
3414
|
+
children,
|
|
3415
|
+
fields,
|
|
3416
|
+
namePrefix
|
|
3417
|
+
} = t0;
|
|
3418
|
+
let map;
|
|
3419
|
+
if ($[0] !== fields || $[1] !== namePrefix) {
|
|
3420
|
+
map = new Map();
|
|
3421
|
+
const addFields = (items, prefix) => {
|
|
3422
|
+
items.forEach(item => {
|
|
3423
|
+
if ("fields" in item && Array.isArray(item.fields)) {
|
|
3424
|
+
const arrayPrefix = prefix ? `${prefix}.${item.name}` : item.name;
|
|
3425
|
+
addFields(item.fields, arrayPrefix);
|
|
3426
|
+
} else {
|
|
3427
|
+
const fieldName = prefix ? `${prefix}.${item.name}` : item.name;
|
|
3428
|
+
map.set(fieldName, item);
|
|
3429
|
+
if (prefix) {
|
|
3430
|
+
map.set(item.name, item);
|
|
3431
|
+
}
|
|
3432
|
+
}
|
|
3433
|
+
});
|
|
3434
|
+
};
|
|
3435
|
+
addFields(fields, namePrefix);
|
|
3436
|
+
$[0] = fields;
|
|
3437
|
+
$[1] = namePrefix;
|
|
3438
|
+
$[2] = map;
|
|
3439
|
+
} else {
|
|
3440
|
+
map = $[2];
|
|
3441
|
+
}
|
|
3442
|
+
const fieldsMap = map;
|
|
3443
|
+
let t1;
|
|
3444
|
+
if ($[3] !== fieldsMap || $[4] !== namePrefix) {
|
|
3445
|
+
t1 = {
|
|
3446
|
+
fields: fieldsMap,
|
|
3447
|
+
namePrefix
|
|
3448
|
+
};
|
|
3449
|
+
$[3] = fieldsMap;
|
|
3450
|
+
$[4] = namePrefix;
|
|
3451
|
+
$[5] = t1;
|
|
3452
|
+
} else {
|
|
3453
|
+
t1 = $[5];
|
|
3454
|
+
}
|
|
3455
|
+
const value = t1;
|
|
3456
|
+
let t2;
|
|
3457
|
+
if ($[6] !== children || $[7] !== value) {
|
|
3458
|
+
t2 = jsxRuntime.jsx(FieldsContext.Provider, {
|
|
3459
|
+
value,
|
|
3460
|
+
children
|
|
3461
|
+
});
|
|
3462
|
+
$[6] = children;
|
|
3463
|
+
$[7] = value;
|
|
3464
|
+
$[8] = t2;
|
|
3465
|
+
} else {
|
|
3466
|
+
t2 = $[8];
|
|
3467
|
+
}
|
|
3468
|
+
return t2;
|
|
3469
|
+
}
|
|
3470
|
+
function useFieldProps(name) {
|
|
3471
|
+
const $ = compilerRuntime.c(23);
|
|
3472
|
+
const context = React.useContext(FieldsContext);
|
|
3473
|
+
const form = useFormContext();
|
|
3474
|
+
if (!context) {
|
|
3475
|
+
throw new Error("useFieldProps must be used within FormGenerator or FieldsProvider");
|
|
3476
|
+
}
|
|
3477
|
+
if (!form) {
|
|
3478
|
+
throw new Error("useFieldProps must be used within a FormProvider context");
|
|
3479
|
+
}
|
|
3480
|
+
const {
|
|
3481
|
+
fields,
|
|
3482
|
+
namePrefix
|
|
3483
|
+
} = context;
|
|
3484
|
+
const fullName = namePrefix ? `${namePrefix}.${name}` : name;
|
|
3485
|
+
let t0;
|
|
3486
|
+
if ($[0] !== fields || $[1] !== fullName || $[2] !== name) {
|
|
3487
|
+
t0 = fields.get(fullName) || fields.get(name);
|
|
3488
|
+
$[0] = fields;
|
|
3489
|
+
$[1] = fullName;
|
|
3490
|
+
$[2] = name;
|
|
3491
|
+
$[3] = t0;
|
|
3492
|
+
} else {
|
|
3493
|
+
t0 = $[3];
|
|
3494
|
+
}
|
|
3495
|
+
const field = t0;
|
|
3496
|
+
if (!field) {
|
|
3497
|
+
throw new Error(`Field "${name}" not found in form fields. ` + `Available fields: ${Array.from(fields.keys()).join(", ")}`);
|
|
3498
|
+
}
|
|
3499
|
+
let t1;
|
|
3500
|
+
if ($[4] !== form.control || $[5] !== fullName) {
|
|
3501
|
+
t1 = {
|
|
3502
|
+
control: form.control,
|
|
3503
|
+
name: fullName
|
|
3504
|
+
};
|
|
3505
|
+
$[4] = form.control;
|
|
3506
|
+
$[5] = fullName;
|
|
3507
|
+
$[6] = t1;
|
|
3508
|
+
} else {
|
|
3509
|
+
t1 = $[6];
|
|
3510
|
+
}
|
|
3511
|
+
const {
|
|
3512
|
+
field: controllerField,
|
|
3513
|
+
fieldState
|
|
3514
|
+
} = useController(t1);
|
|
3515
|
+
let t2;
|
|
3516
|
+
if ($[7] !== field || $[8] !== fullName) {
|
|
3517
|
+
t2 = {
|
|
3518
|
+
...field,
|
|
3519
|
+
name: fullName
|
|
3520
|
+
};
|
|
3521
|
+
$[7] = field;
|
|
3522
|
+
$[8] = fullName;
|
|
3523
|
+
$[9] = t2;
|
|
3524
|
+
} else {
|
|
3525
|
+
t2 = $[9];
|
|
3526
|
+
}
|
|
3527
|
+
let t3;
|
|
3528
|
+
if ($[10] !== fieldState.error || $[11] !== fieldState.invalid || $[12] !== fieldState.isDirty || $[13] !== fieldState.isTouched) {
|
|
3529
|
+
t3 = {
|
|
3530
|
+
invalid: fieldState.invalid,
|
|
3531
|
+
error: fieldState.error,
|
|
3532
|
+
isDirty: fieldState.isDirty,
|
|
3533
|
+
isTouched: fieldState.isTouched
|
|
3534
|
+
};
|
|
3535
|
+
$[10] = fieldState.error;
|
|
3536
|
+
$[11] = fieldState.invalid;
|
|
3537
|
+
$[12] = fieldState.isDirty;
|
|
3538
|
+
$[13] = fieldState.isTouched;
|
|
3539
|
+
$[14] = t3;
|
|
3540
|
+
} else {
|
|
3541
|
+
t3 = $[14];
|
|
3542
|
+
}
|
|
3543
|
+
let t4;
|
|
3544
|
+
if ($[15] !== controllerField.name || $[16] !== controllerField.onBlur || $[17] !== controllerField.onChange || $[18] !== controllerField.ref || $[19] !== controllerField.value || $[20] !== t2 || $[21] !== t3) {
|
|
3545
|
+
t4 = {
|
|
3546
|
+
name: controllerField.name,
|
|
3547
|
+
value: controllerField.value,
|
|
3548
|
+
onChange: controllerField.onChange,
|
|
3549
|
+
onBlur: controllerField.onBlur,
|
|
3550
|
+
ref: controllerField.ref,
|
|
3551
|
+
field: t2,
|
|
3552
|
+
fieldState: t3
|
|
3553
|
+
};
|
|
3554
|
+
$[15] = controllerField.name;
|
|
3555
|
+
$[16] = controllerField.onBlur;
|
|
3556
|
+
$[17] = controllerField.onChange;
|
|
3557
|
+
$[18] = controllerField.ref;
|
|
3558
|
+
$[19] = controllerField.value;
|
|
3559
|
+
$[20] = t2;
|
|
3560
|
+
$[21] = t3;
|
|
3561
|
+
$[22] = t4;
|
|
3562
|
+
} else {
|
|
3563
|
+
t4 = $[22];
|
|
3564
|
+
}
|
|
3565
|
+
return t4;
|
|
3566
|
+
}
|
|
3567
|
+
function useFieldsContext() {
|
|
3568
|
+
return React.useContext(FieldsContext);
|
|
3569
|
+
}
|
|
3570
|
+
|
|
3410
3571
|
function deepMerge(target, source) {
|
|
3411
3572
|
const result = {
|
|
3412
3573
|
...target
|
|
@@ -3517,10 +3678,7 @@ function buildDefaultValues(fields) {
|
|
|
3517
3678
|
return values;
|
|
3518
3679
|
}
|
|
3519
3680
|
|
|
3520
|
-
function
|
|
3521
|
-
return props.schema !== undefined;
|
|
3522
|
-
}
|
|
3523
|
-
function FormGeneratorImpl(props) {
|
|
3681
|
+
function FormGenerator(props) {
|
|
3524
3682
|
const {
|
|
3525
3683
|
fields,
|
|
3526
3684
|
defaultValues,
|
|
@@ -3536,6 +3694,8 @@ function FormGeneratorImpl(props) {
|
|
|
3536
3694
|
ref,
|
|
3537
3695
|
validateTypes
|
|
3538
3696
|
} = props;
|
|
3697
|
+
const onSubmit = props.onSubmit;
|
|
3698
|
+
const formRef = React.useRef(null);
|
|
3539
3699
|
React.useMemo(() => {
|
|
3540
3700
|
if (validateTypes) {
|
|
3541
3701
|
const registeredTypes = getRegisteredFieldTypes();
|
|
@@ -3546,15 +3706,7 @@ function FormGeneratorImpl(props) {
|
|
|
3546
3706
|
validateFieldTypes(fields, registeredTypes, options);
|
|
3547
3707
|
}
|
|
3548
3708
|
}, [fields, validateTypes]);
|
|
3549
|
-
const
|
|
3550
|
-
const onSubmit = props.onSubmit;
|
|
3551
|
-
const formRef = React.useRef(null);
|
|
3552
|
-
const schema = React.useMemo(() => {
|
|
3553
|
-
if (userSchema) {
|
|
3554
|
-
return userSchema;
|
|
3555
|
-
}
|
|
3556
|
-
return buildSchema(fields);
|
|
3557
|
-
}, [fields, userSchema]);
|
|
3709
|
+
const schema = React.useMemo(() => buildSchema(fields), [fields]);
|
|
3558
3710
|
const mergedDefaultValues = React.useMemo(() => {
|
|
3559
3711
|
const builtDefaults = buildDefaultValues(fields);
|
|
3560
3712
|
return defaultValues ? deepMerge(builtDefaults, defaultValues) : builtDefaults;
|
|
@@ -3666,31 +3818,242 @@ function FormGeneratorImpl(props) {
|
|
|
3666
3818
|
if (!children) {
|
|
3667
3819
|
return jsxRuntime.jsx(FormProvider, {
|
|
3668
3820
|
...form,
|
|
3669
|
-
children: jsxRuntime.
|
|
3821
|
+
children: jsxRuntime.jsx(FieldsProvider, {
|
|
3822
|
+
fields: fields,
|
|
3823
|
+
children: jsxRuntime.jsxs("form", {
|
|
3824
|
+
ref: formRef,
|
|
3825
|
+
onSubmit: handleSubmit,
|
|
3826
|
+
className: className,
|
|
3827
|
+
children: [jsxRuntime.jsxs(FieldsWrapper, {
|
|
3828
|
+
children: [regularFields.map((field_2, index_0) => jsxRuntime.jsx(FieldWrapper, {
|
|
3829
|
+
name: field_2.name,
|
|
3830
|
+
type: field_2.type,
|
|
3831
|
+
className: field_2.className,
|
|
3832
|
+
children: jsxRuntime.jsx(FieldRenderer, {
|
|
3833
|
+
field: field_2
|
|
3834
|
+
})
|
|
3835
|
+
}, field_2.name || `field-${index_0}`)), arrayFields.map(arrayField => jsxRuntime.jsx(FieldWrapper, {
|
|
3836
|
+
name: arrayField.name,
|
|
3837
|
+
type: "array",
|
|
3838
|
+
className: arrayField.className,
|
|
3839
|
+
children: jsxRuntime.jsx(ArrayFieldRenderer, {
|
|
3840
|
+
field: arrayField
|
|
3841
|
+
})
|
|
3842
|
+
}, arrayField.name))]
|
|
3843
|
+
}), jsxRuntime.jsx(SubmitButton, {
|
|
3844
|
+
disabled: disabled || form.formState.isSubmitting,
|
|
3845
|
+
isSubmitting: form.formState.isSubmitting,
|
|
3846
|
+
children: submitText
|
|
3847
|
+
})]
|
|
3848
|
+
})
|
|
3849
|
+
})
|
|
3850
|
+
});
|
|
3851
|
+
}
|
|
3852
|
+
const renderProps = {
|
|
3853
|
+
fields: templateFields,
|
|
3854
|
+
arrays: Object.fromEntries(arrayFields.map(arrayField_0 => [arrayField_0.name, {
|
|
3855
|
+
field: arrayField_0
|
|
3856
|
+
}])),
|
|
3857
|
+
buttons,
|
|
3858
|
+
title,
|
|
3859
|
+
description,
|
|
3860
|
+
form: form,
|
|
3861
|
+
isSubmitting: form.formState.isSubmitting,
|
|
3862
|
+
isValid: form.formState.isValid,
|
|
3863
|
+
isDirty: form.formState.isDirty,
|
|
3864
|
+
renderField,
|
|
3865
|
+
FieldWrapper,
|
|
3866
|
+
FieldsWrapper
|
|
3867
|
+
};
|
|
3868
|
+
const renderFn = children;
|
|
3869
|
+
return jsxRuntime.jsx(FormProvider, {
|
|
3870
|
+
...form,
|
|
3871
|
+
children: jsxRuntime.jsx(FieldsProvider, {
|
|
3872
|
+
fields: fields,
|
|
3873
|
+
children: jsxRuntime.jsx("form", {
|
|
3670
3874
|
ref: formRef,
|
|
3671
3875
|
onSubmit: handleSubmit,
|
|
3672
3876
|
className: className,
|
|
3673
|
-
children:
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3877
|
+
children: renderFn(renderProps)
|
|
3878
|
+
})
|
|
3879
|
+
})
|
|
3880
|
+
});
|
|
3881
|
+
}
|
|
3882
|
+
|
|
3883
|
+
function typedField() {
|
|
3884
|
+
return field => field;
|
|
3885
|
+
}
|
|
3886
|
+
function typedFields(fields) {
|
|
3887
|
+
return fields;
|
|
3888
|
+
}
|
|
3889
|
+
function StrictFormGenerator(props) {
|
|
3890
|
+
const {
|
|
3891
|
+
schema,
|
|
3892
|
+
fields,
|
|
3893
|
+
onSubmit,
|
|
3894
|
+
defaultValues,
|
|
3895
|
+
className,
|
|
3896
|
+
submitText = 'Submit',
|
|
3897
|
+
disabled,
|
|
3898
|
+
mode = 'onChange',
|
|
3899
|
+
title,
|
|
3900
|
+
description,
|
|
3901
|
+
showReset = false,
|
|
3902
|
+
resetText = 'Reset',
|
|
3903
|
+
children,
|
|
3904
|
+
ref,
|
|
3905
|
+
validateTypes
|
|
3906
|
+
} = props;
|
|
3907
|
+
const formRef = React.useRef(null);
|
|
3908
|
+
React.useMemo(() => {
|
|
3909
|
+
if (validateTypes) {
|
|
3910
|
+
const registeredTypes = getRegisteredFieldTypes();
|
|
3911
|
+
const options = typeof validateTypes === 'object' ? validateTypes : {
|
|
3912
|
+
throwOnError: false,
|
|
3913
|
+
warn: true
|
|
3914
|
+
};
|
|
3915
|
+
validateFieldTypes(fields, registeredTypes, options);
|
|
3916
|
+
}
|
|
3917
|
+
}, [fields, validateTypes]);
|
|
3918
|
+
const mergedDefaultValues = React.useMemo(() => {
|
|
3919
|
+
const builtDefaults = buildDefaultValues(fields);
|
|
3920
|
+
return defaultValues ? deepMerge(builtDefaults, defaultValues) : builtDefaults;
|
|
3921
|
+
}, [fields, defaultValues]);
|
|
3922
|
+
const form = useForm({
|
|
3923
|
+
resolver: a(schema),
|
|
3924
|
+
defaultValues: mergedDefaultValues,
|
|
3925
|
+
mode
|
|
3926
|
+
});
|
|
3927
|
+
const handleSubmit = form.handleSubmit(async data => {
|
|
3928
|
+
await onSubmit(data);
|
|
3929
|
+
});
|
|
3930
|
+
const handleReset = React.useCallback(() => {
|
|
3931
|
+
form.reset(mergedDefaultValues);
|
|
3932
|
+
}, [form, mergedDefaultValues]);
|
|
3933
|
+
React.useImperativeHandle(ref, () => ({
|
|
3934
|
+
setValues: values => {
|
|
3935
|
+
Object.entries(values).forEach(([key, value]) => {
|
|
3936
|
+
form.setValue(key, value, {
|
|
3937
|
+
shouldValidate: true,
|
|
3938
|
+
shouldDirty: true
|
|
3939
|
+
});
|
|
3940
|
+
});
|
|
3941
|
+
},
|
|
3942
|
+
getValues: () => form.getValues(),
|
|
3943
|
+
reset: values_0 => {
|
|
3944
|
+
if (values_0) {
|
|
3945
|
+
form.reset(deepMerge(mergedDefaultValues, values_0));
|
|
3946
|
+
} else {
|
|
3947
|
+
form.reset(mergedDefaultValues);
|
|
3948
|
+
}
|
|
3949
|
+
},
|
|
3950
|
+
submit: async () => {
|
|
3951
|
+
await handleSubmit();
|
|
3952
|
+
},
|
|
3953
|
+
clearErrors: () => form.clearErrors(),
|
|
3954
|
+
setError: (name, error) => form.setError(name, error),
|
|
3955
|
+
isValid: () => form.formState.isValid,
|
|
3956
|
+
isDirty: () => form.formState.isDirty,
|
|
3957
|
+
form: form
|
|
3958
|
+
}), [form, handleSubmit, mergedDefaultValues]);
|
|
3959
|
+
const SubmitButton = getFormComponent('SubmitButton');
|
|
3960
|
+
const FieldWrapper = getFormComponent('FieldWrapper');
|
|
3961
|
+
const FieldsWrapper = getFormComponent('FieldsWrapper');
|
|
3962
|
+
const {
|
|
3963
|
+
regularFields,
|
|
3964
|
+
arrayFields
|
|
3965
|
+
} = React.useMemo(() => {
|
|
3966
|
+
const regular = [];
|
|
3967
|
+
const arrays = [];
|
|
3968
|
+
fields.forEach(field => {
|
|
3969
|
+
if (isArrayField(field)) {
|
|
3970
|
+
arrays.push(field);
|
|
3971
|
+
} else {
|
|
3972
|
+
regular.push(field);
|
|
3973
|
+
}
|
|
3974
|
+
});
|
|
3975
|
+
return {
|
|
3976
|
+
regularFields: regular,
|
|
3977
|
+
arrayFields: arrays
|
|
3978
|
+
};
|
|
3979
|
+
}, [fields]);
|
|
3980
|
+
const fieldEntries = React.useMemo(() => {
|
|
3981
|
+
const entries = new Map();
|
|
3982
|
+
regularFields.forEach((field_0, index) => {
|
|
3983
|
+
if (!field_0.hidden) {
|
|
3984
|
+
const element = jsxRuntime.jsx(FieldWrapper, {
|
|
3985
|
+
name: field_0.name,
|
|
3986
|
+
type: field_0.type,
|
|
3987
|
+
className: field_0.className,
|
|
3988
|
+
children: jsxRuntime.jsx(FieldRenderer, {
|
|
3989
|
+
field: field_0
|
|
3990
|
+
})
|
|
3991
|
+
}, field_0.name || `field-${index}`);
|
|
3992
|
+
entries.set(field_0.name, {
|
|
3993
|
+
field: field_0,
|
|
3994
|
+
element,
|
|
3995
|
+
accessed: false
|
|
3996
|
+
});
|
|
3997
|
+
}
|
|
3998
|
+
});
|
|
3999
|
+
return entries;
|
|
4000
|
+
}, [regularFields, FieldWrapper]);
|
|
4001
|
+
const templateFields = React.useMemo(() => createTemplateFields(fieldEntries), [fieldEntries]);
|
|
4002
|
+
const buttons = React.useMemo(() => {
|
|
4003
|
+
const result = {
|
|
4004
|
+
submit: jsxRuntime.jsx(SubmitButton, {
|
|
4005
|
+
disabled: disabled || form.formState.isSubmitting,
|
|
4006
|
+
isSubmitting: form.formState.isSubmitting,
|
|
4007
|
+
children: submitText
|
|
4008
|
+
}, "submit")
|
|
4009
|
+
};
|
|
4010
|
+
if (showReset) {
|
|
4011
|
+
result.reset = jsxRuntime.jsx("button", {
|
|
4012
|
+
type: "button",
|
|
4013
|
+
onClick: handleReset,
|
|
4014
|
+
disabled: disabled,
|
|
4015
|
+
children: resetText
|
|
4016
|
+
}, "reset");
|
|
4017
|
+
}
|
|
4018
|
+
return result;
|
|
4019
|
+
}, [SubmitButton, disabled, form.formState.isSubmitting, submitText, showReset, resetText, handleReset]);
|
|
4020
|
+
const renderField = React.useCallback((field_1, options_0) => {
|
|
4021
|
+
return jsxRuntime.jsx(FieldRenderer, {
|
|
4022
|
+
field: field_1,
|
|
4023
|
+
namePrefix: options_0 === null || options_0 === void 0 ? void 0 : options_0.namePrefix
|
|
4024
|
+
});
|
|
4025
|
+
}, []);
|
|
4026
|
+
if (!children) {
|
|
4027
|
+
return jsxRuntime.jsx(FormProvider, {
|
|
4028
|
+
...form,
|
|
4029
|
+
children: jsxRuntime.jsx(FieldsProvider, {
|
|
4030
|
+
fields: fields,
|
|
4031
|
+
children: jsxRuntime.jsxs("form", {
|
|
4032
|
+
ref: formRef,
|
|
4033
|
+
onSubmit: handleSubmit,
|
|
4034
|
+
className: className,
|
|
4035
|
+
children: [jsxRuntime.jsxs(FieldsWrapper, {
|
|
4036
|
+
children: [regularFields.map((field_2, index_0) => jsxRuntime.jsx(FieldWrapper, {
|
|
4037
|
+
name: field_2.name,
|
|
4038
|
+
type: field_2.type,
|
|
4039
|
+
className: field_2.className,
|
|
4040
|
+
children: jsxRuntime.jsx(FieldRenderer, {
|
|
4041
|
+
field: field_2
|
|
4042
|
+
})
|
|
4043
|
+
}, field_2.name || `field-${index_0}`)), arrayFields.map(arrayField => jsxRuntime.jsx(FieldWrapper, {
|
|
4044
|
+
name: arrayField.name,
|
|
4045
|
+
type: "array",
|
|
4046
|
+
className: arrayField.className,
|
|
4047
|
+
children: jsxRuntime.jsx(ArrayFieldRenderer, {
|
|
4048
|
+
field: arrayField
|
|
4049
|
+
})
|
|
4050
|
+
}, arrayField.name))]
|
|
4051
|
+
}), jsxRuntime.jsx(SubmitButton, {
|
|
4052
|
+
disabled: disabled || form.formState.isSubmitting,
|
|
4053
|
+
isSubmitting: form.formState.isSubmitting,
|
|
4054
|
+
children: submitText
|
|
4055
|
+
})]
|
|
4056
|
+
})
|
|
3694
4057
|
})
|
|
3695
4058
|
});
|
|
3696
4059
|
}
|
|
@@ -3713,16 +4076,19 @@ function FormGeneratorImpl(props) {
|
|
|
3713
4076
|
const renderFn = children;
|
|
3714
4077
|
return jsxRuntime.jsx(FormProvider, {
|
|
3715
4078
|
...form,
|
|
3716
|
-
children: jsxRuntime.jsx(
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
4079
|
+
children: jsxRuntime.jsx(FieldsProvider, {
|
|
4080
|
+
fields: fields,
|
|
4081
|
+
children: jsxRuntime.jsx("form", {
|
|
4082
|
+
ref: formRef,
|
|
4083
|
+
onSubmit: handleSubmit,
|
|
4084
|
+
className: className,
|
|
4085
|
+
children: renderFn(renderProps)
|
|
4086
|
+
})
|
|
3721
4087
|
})
|
|
3722
4088
|
});
|
|
3723
4089
|
}
|
|
3724
|
-
function
|
|
3725
|
-
return
|
|
4090
|
+
function createFieldFactory(_schema) {
|
|
4091
|
+
return field => field;
|
|
3726
4092
|
}
|
|
3727
4093
|
|
|
3728
4094
|
Object.defineProperty(exports, "z", {
|
|
@@ -3732,13 +4098,16 @@ Object.defineProperty(exports, "z", {
|
|
|
3732
4098
|
exports.ArrayFieldRenderer = ArrayFieldRenderer;
|
|
3733
4099
|
exports.Controller = Controller;
|
|
3734
4100
|
exports.FieldRenderer = FieldRenderer;
|
|
4101
|
+
exports.FieldsProvider = FieldsProvider;
|
|
3735
4102
|
exports.FormGenerator = FormGenerator;
|
|
3736
4103
|
exports.FormProvider = FormProvider;
|
|
4104
|
+
exports.StrictFormGenerator = StrictFormGenerator;
|
|
3737
4105
|
exports.clearAllRegistries = clearAllRegistries;
|
|
3738
4106
|
exports.clearFieldRegistry = clearFieldRegistry;
|
|
3739
4107
|
exports.clearFormComponentRegistry = clearFormComponentRegistry;
|
|
3740
4108
|
exports.createArrayField = createArrayField;
|
|
3741
4109
|
exports.createField = createField;
|
|
4110
|
+
exports.createFieldFactory = createFieldFactory;
|
|
3742
4111
|
exports.getFieldComponent = getFieldComponent;
|
|
3743
4112
|
exports.getFormComponent = getFormComponent;
|
|
3744
4113
|
exports.getFormComponents = getFormComponents;
|
|
@@ -3752,9 +4121,13 @@ exports.registerFormComponent = registerFormComponent;
|
|
|
3752
4121
|
exports.registerFormComponents = registerFormComponents;
|
|
3753
4122
|
exports.resetFormComponentRegistry = resetFormComponentRegistry;
|
|
3754
4123
|
exports.strictFields = strictFields;
|
|
4124
|
+
exports.typedField = typedField;
|
|
4125
|
+
exports.typedFields = typedFields;
|
|
3755
4126
|
exports.unregisterField = unregisterField;
|
|
3756
4127
|
exports.useArrayField = useArrayField;
|
|
3757
4128
|
exports.useFieldArray = useFieldArray;
|
|
4129
|
+
exports.useFieldProps = useFieldProps;
|
|
4130
|
+
exports.useFieldsContext = useFieldsContext;
|
|
3758
4131
|
exports.useForm = useForm;
|
|
3759
4132
|
exports.useFormContext = useFormContext;
|
|
3760
4133
|
exports.useWatch = useWatch;
|