@connect-soft/form-generator 1.1.0-alpha4 → 1.1.0-alpha6
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 +117 -59
- package/dist/index.js +339 -453
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +339 -450
- package/dist/index.mjs.map +1 -1
- package/dist/types/components/form/array-field-renderer.d.ts +39 -0
- package/dist/types/components/form/array-field-renderer.d.ts.map +1 -0
- package/dist/types/components/form/create-template-fields.d.ts +1 -2
- package/dist/types/components/form/create-template-fields.d.ts.map +1 -1
- package/dist/types/components/form/field-renderer.d.ts +1 -6
- package/dist/types/components/form/field-renderer.d.ts.map +1 -1
- package/dist/types/components/form/form-generator.d.ts.map +1 -1
- package/dist/types/components/form/form-utils.d.ts +3 -9
- package/dist/types/components/form/form-utils.d.ts.map +1 -1
- package/dist/types/components/form/index.d.ts +4 -2
- package/dist/types/components/form/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -5
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/field-registry.d.ts +1 -53
- package/dist/types/lib/field-registry.d.ts.map +1 -1
- package/dist/types/lib/field-types.d.ts +18 -30
- package/dist/types/lib/field-types.d.ts.map +1 -1
- package/dist/types/lib/index.d.ts +3 -5
- package/dist/types/lib/index.d.ts.map +1 -1
- package/dist/types/lib/template-types.d.ts +14 -16
- package/dist/types/lib/template-types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import React, { createElement, memo, useRef, useMemo,
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import React, { createElement, memo, useCallback, useRef, useMemo, useImperativeHandle } from 'react';
|
|
3
3
|
import * as n$1 from 'zod/v4/core';
|
|
4
4
|
import { c } from 'react/compiler-runtime';
|
|
5
5
|
import { z } from 'zod';
|
|
@@ -2772,52 +2772,13 @@ const r=(t,r,o)=>{if(t&&"reportValidity"in t){const s=get(o,r);t.setCustomValidi
|
|
|
2772
2772
|
|
|
2773
2773
|
function t(r,e){try{var o=r();}catch(r){return e(r)}return o&&o.then?o.then(void 0,e):o}function s(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(".");if(!n[a])if("unionErrors"in t){var u=t.unionErrors[0].errors[0];n[a]={message:u.message,type:u.code};}else n[a]={message:i,type:s};if("unionErrors"in t&&t.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=appendErrors(a,e,n,s,f?[].concat(f,t.message):t.message);}r.shift();}return n}function i(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(".");if(!n[a])if("invalid_union"===t.code&&t.errors.length>0){var u=t.errors[0][0];n[a]={message:u.message,type:u.code};}else n[a]={message:i,type:s};if("invalid_union"===t.code&&t.errors.forEach(function(e){return e.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=appendErrors(a,e,n,s,f?[].concat(f,t.message):t.message);}r.shift();}return n}function a(o$1,a,u){if(void 0===u&&(u={}),function(r){return "_def"in r&&"object"==typeof r._def&&"typeName"in r._def}(o$1))return function(n,i,c){try{return Promise.resolve(t(function(){return Promise.resolve(o$1["sync"===u.mode?"parse":"parseAsync"](n,a)).then(function(e){return c.shouldUseNativeValidation&&o({},c),{errors:{},values:u.raw?Object.assign({},n):e}})},function(r){if(function(r){return Array.isArray(null==r?void 0:r.issues)}(r))return {values:{},errors:s$1(s(r.errors,!c.shouldUseNativeValidation&&"all"===c.criteriaMode),c)};throw r}))}catch(r){return Promise.reject(r)}};if(function(r){return "_zod"in r&&"object"==typeof r._zod}(o$1))return function(s,c,f){try{return Promise.resolve(t(function(){return Promise.resolve(("sync"===u.mode?n$1.parse:n$1.parseAsync)(o$1,s,a)).then(function(e){return f.shouldUseNativeValidation&&o({},f),{errors:{},values:u.raw?Object.assign({},s):e}})},function(r){if(function(r){return r instanceof n$1.$ZodError}(r))return {values:{},errors:s$1(i(r.issues,!f.shouldUseNativeValidation&&"all"===f.criteriaMode),f)};throw r}))}catch(r){return Promise.reject(r)}};throw new Error("Invalid input: not a Zod schema")}
|
|
2774
2774
|
|
|
2775
|
-
function
|
|
2776
|
-
return
|
|
2775
|
+
function isArrayField(field) {
|
|
2776
|
+
return field.type === 'array' && 'fields' in field;
|
|
2777
2777
|
}
|
|
2778
2778
|
|
|
2779
2779
|
const fieldRegistry = new Map();
|
|
2780
2780
|
const componentRegistry = {};
|
|
2781
|
-
const layoutRegistry = {};
|
|
2782
2781
|
const defaultFormComponents = {
|
|
2783
|
-
FormItem: ({
|
|
2784
|
-
className,
|
|
2785
|
-
children
|
|
2786
|
-
}) => /*#__PURE__*/createElement('div', {
|
|
2787
|
-
className: className !== null && className !== void 0 ? className : 'form-item'
|
|
2788
|
-
}, children),
|
|
2789
|
-
FormInputLabelWrapper: ({
|
|
2790
|
-
className,
|
|
2791
|
-
orientation,
|
|
2792
|
-
children
|
|
2793
|
-
}) => /*#__PURE__*/createElement('div', {
|
|
2794
|
-
'className': className !== null && className !== void 0 ? className : 'form-input-label-wrapper',
|
|
2795
|
-
'data-orientation': orientation !== null && orientation !== void 0 ? orientation : 'vertical'
|
|
2796
|
-
}, children),
|
|
2797
|
-
FormLabel: ({
|
|
2798
|
-
className,
|
|
2799
|
-
children,
|
|
2800
|
-
required,
|
|
2801
|
-
htmlFor
|
|
2802
|
-
}) => /*#__PURE__*/createElement('label', {
|
|
2803
|
-
className: className !== null && className !== void 0 ? className : 'form-label',
|
|
2804
|
-
htmlFor
|
|
2805
|
-
}, children, required && /*#__PURE__*/createElement('span', {
|
|
2806
|
-
className: 'required-indicator'
|
|
2807
|
-
}, ' *')),
|
|
2808
|
-
FormDescription: ({
|
|
2809
|
-
className,
|
|
2810
|
-
children
|
|
2811
|
-
}) => /*#__PURE__*/createElement('p', {
|
|
2812
|
-
className: className !== null && className !== void 0 ? className : 'form-description'
|
|
2813
|
-
}, children),
|
|
2814
|
-
FormMessage: ({
|
|
2815
|
-
className,
|
|
2816
|
-
name
|
|
2817
|
-
}) => /*#__PURE__*/createElement('p', {
|
|
2818
|
-
'className': className !== null && className !== void 0 ? className : 'form-message',
|
|
2819
|
-
'data-field': name
|
|
2820
|
-
}),
|
|
2821
2782
|
SubmitButton: ({
|
|
2822
2783
|
className,
|
|
2823
2784
|
children,
|
|
@@ -3012,10 +2973,6 @@ function getFieldComponent(type) {
|
|
|
3012
2973
|
}
|
|
3013
2974
|
return createDefaultFieldComponent(type);
|
|
3014
2975
|
}
|
|
3015
|
-
function getFieldOptions(type) {
|
|
3016
|
-
var _a;
|
|
3017
|
-
return (_a = fieldRegistry.get(type)) === null || _a === void 0 ? void 0 : _a.options;
|
|
3018
|
-
}
|
|
3019
2976
|
function getFieldValidator(type) {
|
|
3020
2977
|
var _a;
|
|
3021
2978
|
return (_a = fieldRegistry.get(type)) === null || _a === void 0 ? void 0 : _a.options.validator;
|
|
@@ -3061,37 +3018,6 @@ function getFormComponents() {
|
|
|
3061
3018
|
...componentRegistry
|
|
3062
3019
|
};
|
|
3063
3020
|
}
|
|
3064
|
-
function registerLayoutComponents(components, config = {}) {
|
|
3065
|
-
const {
|
|
3066
|
-
override = true
|
|
3067
|
-
} = config;
|
|
3068
|
-
Object.keys(components).forEach(key => {
|
|
3069
|
-
const exists = key in layoutRegistry;
|
|
3070
|
-
if (override === 'only' && !exists) return;
|
|
3071
|
-
if (override === false && exists) return;
|
|
3072
|
-
layoutRegistry[key] = components[key];
|
|
3073
|
-
});
|
|
3074
|
-
}
|
|
3075
|
-
function registerLayoutComponent(name, component, config = {}) {
|
|
3076
|
-
const {
|
|
3077
|
-
override = true
|
|
3078
|
-
} = config;
|
|
3079
|
-
const exists = name in layoutRegistry;
|
|
3080
|
-
if (override === 'only' && !exists) return;
|
|
3081
|
-
if (override === false && exists) return;
|
|
3082
|
-
layoutRegistry[name] = component;
|
|
3083
|
-
}
|
|
3084
|
-
function getLayoutComponent(name) {
|
|
3085
|
-
return layoutRegistry[name];
|
|
3086
|
-
}
|
|
3087
|
-
function hasLayoutComponent(name) {
|
|
3088
|
-
return name in layoutRegistry;
|
|
3089
|
-
}
|
|
3090
|
-
function clearLayoutRegistry() {
|
|
3091
|
-
Object.keys(layoutRegistry).forEach(key => {
|
|
3092
|
-
delete layoutRegistry[key];
|
|
3093
|
-
});
|
|
3094
|
-
}
|
|
3095
3021
|
function clearFieldRegistry() {
|
|
3096
3022
|
fieldRegistry.clear();
|
|
3097
3023
|
}
|
|
@@ -3107,106 +3033,6 @@ function resetFormComponentRegistry() {
|
|
|
3107
3033
|
function clearAllRegistries() {
|
|
3108
3034
|
clearFieldRegistry();
|
|
3109
3035
|
clearFormComponentRegistry();
|
|
3110
|
-
clearLayoutRegistry();
|
|
3111
|
-
}
|
|
3112
|
-
|
|
3113
|
-
const RESERVED_PROPS = new Set(['all', 'remaining', 'names', 'has', 'render']);
|
|
3114
|
-
function createTemplateFields(fieldEntries) {
|
|
3115
|
-
const accessedFields = new Set();
|
|
3116
|
-
const handler = {
|
|
3117
|
-
get(_, prop) {
|
|
3118
|
-
if (typeof prop === 'symbol') {
|
|
3119
|
-
return undefined;
|
|
3120
|
-
}
|
|
3121
|
-
if (prop === 'all') {
|
|
3122
|
-
return Array.from(fieldEntries.values()).map(entry => entry.element);
|
|
3123
|
-
}
|
|
3124
|
-
if (prop === 'remaining') {
|
|
3125
|
-
return Array.from(fieldEntries.entries()).filter(([name]) => !accessedFields.has(name)).map(([, entry]) => entry.element);
|
|
3126
|
-
}
|
|
3127
|
-
if (prop === 'names') {
|
|
3128
|
-
return Array.from(fieldEntries.keys());
|
|
3129
|
-
}
|
|
3130
|
-
if (prop === 'has') {
|
|
3131
|
-
return name => fieldEntries.has(name);
|
|
3132
|
-
}
|
|
3133
|
-
if (prop === 'render') {
|
|
3134
|
-
return (...names) => {
|
|
3135
|
-
return names.filter(name => fieldEntries.has(name)).map(name => {
|
|
3136
|
-
accessedFields.add(name);
|
|
3137
|
-
return fieldEntries.get(name).element;
|
|
3138
|
-
});
|
|
3139
|
-
};
|
|
3140
|
-
}
|
|
3141
|
-
if (fieldEntries.has(prop)) {
|
|
3142
|
-
accessedFields.add(prop);
|
|
3143
|
-
return fieldEntries.get(prop).element;
|
|
3144
|
-
}
|
|
3145
|
-
return undefined;
|
|
3146
|
-
},
|
|
3147
|
-
has(_, prop) {
|
|
3148
|
-
if (typeof prop === 'symbol') {
|
|
3149
|
-
return false;
|
|
3150
|
-
}
|
|
3151
|
-
return RESERVED_PROPS.has(prop) || fieldEntries.has(prop);
|
|
3152
|
-
},
|
|
3153
|
-
ownKeys() {
|
|
3154
|
-
return [...RESERVED_PROPS, ...fieldEntries.keys()];
|
|
3155
|
-
},
|
|
3156
|
-
getOwnPropertyDescriptor(_, prop) {
|
|
3157
|
-
if (typeof prop === 'symbol') {
|
|
3158
|
-
return undefined;
|
|
3159
|
-
}
|
|
3160
|
-
if (RESERVED_PROPS.has(prop) || fieldEntries.has(prop)) {
|
|
3161
|
-
return {
|
|
3162
|
-
configurable: true,
|
|
3163
|
-
enumerable: true,
|
|
3164
|
-
value: this.get(_, prop, {})
|
|
3165
|
-
};
|
|
3166
|
-
}
|
|
3167
|
-
return undefined;
|
|
3168
|
-
}
|
|
3169
|
-
};
|
|
3170
|
-
return new Proxy({}, handler);
|
|
3171
|
-
}
|
|
3172
|
-
function createTemplateLayouts(layoutEntries) {
|
|
3173
|
-
const handler = {
|
|
3174
|
-
get(_, prop) {
|
|
3175
|
-
if (typeof prop === 'symbol') {
|
|
3176
|
-
return undefined;
|
|
3177
|
-
}
|
|
3178
|
-
if (prop === 'all') {
|
|
3179
|
-
return Array.from(layoutEntries.values()).map(entry => entry.element);
|
|
3180
|
-
}
|
|
3181
|
-
if (layoutEntries.has(prop)) {
|
|
3182
|
-
return layoutEntries.get(prop).element;
|
|
3183
|
-
}
|
|
3184
|
-
return undefined;
|
|
3185
|
-
},
|
|
3186
|
-
has(_, prop) {
|
|
3187
|
-
if (typeof prop === 'symbol') {
|
|
3188
|
-
return false;
|
|
3189
|
-
}
|
|
3190
|
-
return prop === 'all' || layoutEntries.has(prop);
|
|
3191
|
-
},
|
|
3192
|
-
ownKeys() {
|
|
3193
|
-
return ['all', ...layoutEntries.keys()];
|
|
3194
|
-
},
|
|
3195
|
-
getOwnPropertyDescriptor(_, prop) {
|
|
3196
|
-
if (typeof prop === 'symbol') {
|
|
3197
|
-
return undefined;
|
|
3198
|
-
}
|
|
3199
|
-
if (prop === 'all' || layoutEntries.has(prop)) {
|
|
3200
|
-
return {
|
|
3201
|
-
configurable: true,
|
|
3202
|
-
enumerable: true,
|
|
3203
|
-
value: this.get(_, prop, {})
|
|
3204
|
-
};
|
|
3205
|
-
}
|
|
3206
|
-
return undefined;
|
|
3207
|
-
}
|
|
3208
|
-
};
|
|
3209
|
-
return new Proxy({}, handler);
|
|
3210
3036
|
}
|
|
3211
3037
|
|
|
3212
3038
|
const FieldRenderer = /*#__PURE__*/memo(t0 => {
|
|
@@ -3219,6 +3045,10 @@ const FieldRenderer = /*#__PURE__*/memo(t0 => {
|
|
|
3219
3045
|
if (field.hidden) {
|
|
3220
3046
|
return null;
|
|
3221
3047
|
}
|
|
3048
|
+
if (!field.name) {
|
|
3049
|
+
console.error(`Field is missing required "name" property. Field type: "${field.type}". ` + "Every field must have a unique name for form state management.");
|
|
3050
|
+
return null;
|
|
3051
|
+
}
|
|
3222
3052
|
let t1;
|
|
3223
3053
|
let t2;
|
|
3224
3054
|
if ($[0] !== field || $[1] !== form || $[2] !== namePrefix) {
|
|
@@ -3230,18 +3060,6 @@ const FieldRenderer = /*#__PURE__*/memo(t0 => {
|
|
|
3230
3060
|
t2 = null;
|
|
3231
3061
|
break bb0;
|
|
3232
3062
|
}
|
|
3233
|
-
const FormItemComponent = getFormComponent("FormItem");
|
|
3234
|
-
const FormLabelComponent = getFormComponent("FormLabel");
|
|
3235
|
-
const FormInputLabelWrapper = getFormComponent("FormInputLabelWrapper");
|
|
3236
|
-
const FormDescriptionComponent = getFormComponent("FormDescription");
|
|
3237
|
-
const FormMessageComponent = getFormComponent("FormMessage");
|
|
3238
|
-
if (!FormItemComponent) {
|
|
3239
|
-
console.warn("FormItem component not registered. Use registerFormComponent(\"FormItem\", Component) to register one.");
|
|
3240
|
-
t2 = null;
|
|
3241
|
-
break bb0;
|
|
3242
|
-
}
|
|
3243
|
-
const fieldOptions = getFieldOptions(field.type);
|
|
3244
|
-
const itemClassName = [`form-field-${field.type}`, fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.className, field.className].filter(Boolean).join(" ");
|
|
3245
3063
|
const fieldName = namePrefix ? `${namePrefix}.${field.name}` : field.name;
|
|
3246
3064
|
t1 = jsx(Controller, {
|
|
3247
3065
|
control: form.control,
|
|
@@ -3251,36 +3069,18 @@ const FieldRenderer = /*#__PURE__*/memo(t0 => {
|
|
|
3251
3069
|
field: formField,
|
|
3252
3070
|
fieldState
|
|
3253
3071
|
} = t3;
|
|
3254
|
-
return
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
orientation: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.inputLabelWrapperOrientation,
|
|
3258
|
-
className: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.inputLabelWrapper,
|
|
3259
|
-
children: [field.label && FormLabelComponent && jsx(FormLabelComponent, {
|
|
3260
|
-
className: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.labelClassName,
|
|
3261
|
-
required: field.required,
|
|
3262
|
-
htmlFor: fieldName,
|
|
3263
|
-
children: field.label
|
|
3264
|
-
}), jsx(FieldComponent, {
|
|
3265
|
-
field: {
|
|
3266
|
-
...field,
|
|
3267
|
-
name: fieldName
|
|
3268
|
-
},
|
|
3269
|
-
formField,
|
|
3270
|
-
fieldState: {
|
|
3271
|
-
invalid: fieldState.invalid,
|
|
3272
|
-
error: fieldState.error,
|
|
3273
|
-
isDirty: fieldState.isDirty,
|
|
3274
|
-
isTouched: fieldState.isTouched
|
|
3275
|
-
}
|
|
3276
|
-
})]
|
|
3277
|
-
}), field.description && FormDescriptionComponent && jsx(FormDescriptionComponent, {
|
|
3278
|
-
className: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.descriptionClassName,
|
|
3279
|
-
children: field.description
|
|
3280
|
-
}), FormMessageComponent && jsx(FormMessageComponent, {
|
|
3281
|
-
className: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.messageClassName,
|
|
3072
|
+
return jsx(FieldComponent, {
|
|
3073
|
+
field: {
|
|
3074
|
+
...field,
|
|
3282
3075
|
name: fieldName
|
|
3283
|
-
}
|
|
3076
|
+
},
|
|
3077
|
+
formField,
|
|
3078
|
+
fieldState: {
|
|
3079
|
+
invalid: fieldState.invalid,
|
|
3080
|
+
error: fieldState.error,
|
|
3081
|
+
isDirty: fieldState.isDirty,
|
|
3082
|
+
isTouched: fieldState.isTouched
|
|
3083
|
+
}
|
|
3284
3084
|
});
|
|
3285
3085
|
}
|
|
3286
3086
|
});
|
|
@@ -3300,134 +3100,267 @@ const FieldRenderer = /*#__PURE__*/memo(t0 => {
|
|
|
3300
3100
|
return t1;
|
|
3301
3101
|
});
|
|
3302
3102
|
FieldRenderer.displayName = 'FieldRenderer';
|
|
3303
|
-
|
|
3304
|
-
|
|
3103
|
+
|
|
3104
|
+
function useArrayField(field) {
|
|
3305
3105
|
const {
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3106
|
+
control
|
|
3107
|
+
} = useFormContext();
|
|
3108
|
+
const fieldArray = useFieldArray({
|
|
3109
|
+
control,
|
|
3110
|
+
name: field.name
|
|
3111
|
+
});
|
|
3112
|
+
const {
|
|
3113
|
+
fields: items,
|
|
3114
|
+
append,
|
|
3115
|
+
prepend,
|
|
3116
|
+
remove,
|
|
3117
|
+
move,
|
|
3118
|
+
swap,
|
|
3119
|
+
insert
|
|
3120
|
+
} = fieldArray;
|
|
3121
|
+
const buildEmptyItem = useCallback(() => {
|
|
3122
|
+
const item = {};
|
|
3123
|
+
field.fields.forEach(f => {
|
|
3124
|
+
var _a;
|
|
3125
|
+
item[f.name] = (_a = f.defaultValue) !== null && _a !== void 0 ? _a : '';
|
|
3126
|
+
});
|
|
3127
|
+
return item;
|
|
3128
|
+
}, [field.fields]);
|
|
3129
|
+
const handleAppend = useCallback(() => {
|
|
3130
|
+
append(buildEmptyItem());
|
|
3131
|
+
}, [append, buildEmptyItem]);
|
|
3132
|
+
const handleAppendWith = useCallback(values => {
|
|
3133
|
+
append(values);
|
|
3134
|
+
}, [append]);
|
|
3135
|
+
const handlePrepend = useCallback(() => {
|
|
3136
|
+
prepend(buildEmptyItem());
|
|
3137
|
+
}, [prepend, buildEmptyItem]);
|
|
3138
|
+
const handleInsert = useCallback((index, values_0) => {
|
|
3139
|
+
insert(index, values_0 !== null && values_0 !== void 0 ? values_0 : buildEmptyItem());
|
|
3140
|
+
}, [insert, buildEmptyItem]);
|
|
3141
|
+
const canAppend = field.maxItems === undefined || items.length < field.maxItems;
|
|
3142
|
+
const canRemove = field.minItems === undefined || items.length > field.minItems;
|
|
3143
|
+
const renderField = useCallback((index_0, fieldName) => {
|
|
3144
|
+
const childField = field.fields.find(f_0 => f_0.name === fieldName);
|
|
3145
|
+
if (!childField) {
|
|
3146
|
+
console.warn(`Field "${fieldName}" not found in array field "${field.name}"`);
|
|
3147
|
+
return jsx(Fragment, {});
|
|
3337
3148
|
}
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
}
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
});
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3149
|
+
return jsx(FieldRenderer, {
|
|
3150
|
+
field: childField,
|
|
3151
|
+
namePrefix: `${field.name}.${index_0}`
|
|
3152
|
+
}, `${field.name}.${index_0}.${fieldName}`);
|
|
3153
|
+
}, [field]);
|
|
3154
|
+
const renderItem = useCallback(index_1 => {
|
|
3155
|
+
const result = {};
|
|
3156
|
+
field.fields.forEach(childField_0 => {
|
|
3157
|
+
result[childField_0.name] = jsx(FieldRenderer, {
|
|
3158
|
+
field: childField_0,
|
|
3159
|
+
namePrefix: `${field.name}.${index_1}`
|
|
3160
|
+
}, `${field.name}.${index_1}.${childField_0.name}`);
|
|
3161
|
+
});
|
|
3162
|
+
return result;
|
|
3163
|
+
}, [field]);
|
|
3164
|
+
return {
|
|
3165
|
+
fieldArray,
|
|
3166
|
+
append: handleAppend,
|
|
3167
|
+
appendWith: handleAppendWith,
|
|
3168
|
+
prepend: handlePrepend,
|
|
3169
|
+
remove,
|
|
3170
|
+
move,
|
|
3171
|
+
swap,
|
|
3172
|
+
insert: handleInsert,
|
|
3173
|
+
field,
|
|
3174
|
+
items: items.map((item_0, index_2) => ({
|
|
3175
|
+
id: item_0.id,
|
|
3176
|
+
index: index_2
|
|
3177
|
+
})),
|
|
3178
|
+
canAppend,
|
|
3179
|
+
canRemove,
|
|
3180
|
+
renderField,
|
|
3181
|
+
renderItem
|
|
3182
|
+
};
|
|
3183
|
+
}
|
|
3184
|
+
const ArrayFieldRenderer = /*#__PURE__*/memo(t0 => {
|
|
3185
|
+
const $ = c(28);
|
|
3354
3186
|
const {
|
|
3355
|
-
|
|
3356
|
-
|
|
3187
|
+
field,
|
|
3188
|
+
children
|
|
3357
3189
|
} = t0;
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3190
|
+
const {
|
|
3191
|
+
items,
|
|
3192
|
+
append,
|
|
3193
|
+
remove,
|
|
3194
|
+
move,
|
|
3195
|
+
canAppend,
|
|
3196
|
+
renderItem,
|
|
3197
|
+
field: arrayField
|
|
3198
|
+
} = useArrayField(field);
|
|
3199
|
+
if (field.hidden) {
|
|
3200
|
+
return null;
|
|
3201
|
+
}
|
|
3202
|
+
if (!children) {
|
|
3203
|
+
let t1;
|
|
3204
|
+
if ($[0] !== append || $[1] !== canAppend || $[2] !== field.className || $[3] !== field.description || $[4] !== field.label || $[5] !== items || $[6] !== renderItem) {
|
|
3205
|
+
let t2;
|
|
3206
|
+
if ($[8] !== renderItem) {
|
|
3207
|
+
t2 = t3 => {
|
|
3208
|
+
const {
|
|
3209
|
+
id,
|
|
3210
|
+
index
|
|
3211
|
+
} = t3;
|
|
3212
|
+
return jsx("div", {
|
|
3213
|
+
"data-array-item-index": index,
|
|
3214
|
+
children: Object.values(renderItem(index))
|
|
3215
|
+
}, id);
|
|
3216
|
+
};
|
|
3217
|
+
$[8] = renderItem;
|
|
3218
|
+
$[9] = t2;
|
|
3378
3219
|
} else {
|
|
3379
|
-
|
|
3220
|
+
t2 = $[9];
|
|
3380
3221
|
}
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3222
|
+
t1 = jsxs("div", {
|
|
3223
|
+
className: field.className,
|
|
3224
|
+
children: [field.label && jsx("label", {
|
|
3225
|
+
children: field.label
|
|
3226
|
+
}), field.description && jsx("p", {
|
|
3227
|
+
children: field.description
|
|
3228
|
+
}), items.map(t2), canAppend && jsx("button", {
|
|
3229
|
+
type: "button",
|
|
3230
|
+
onClick: append,
|
|
3231
|
+
children: "Add Item"
|
|
3232
|
+
})]
|
|
3385
3233
|
});
|
|
3234
|
+
$[0] = append;
|
|
3235
|
+
$[1] = canAppend;
|
|
3236
|
+
$[2] = field.className;
|
|
3237
|
+
$[3] = field.description;
|
|
3238
|
+
$[4] = field.label;
|
|
3239
|
+
$[5] = items;
|
|
3240
|
+
$[6] = renderItem;
|
|
3241
|
+
$[7] = t1;
|
|
3242
|
+
} else {
|
|
3243
|
+
t1 = $[7];
|
|
3386
3244
|
}
|
|
3387
|
-
|
|
3388
|
-
$[1] = namePrefix;
|
|
3389
|
-
$[2] = t1;
|
|
3390
|
-
$[3] = t2;
|
|
3391
|
-
} else {
|
|
3392
|
-
t1 = $[2];
|
|
3393
|
-
t2 = $[3];
|
|
3245
|
+
return t1;
|
|
3394
3246
|
}
|
|
3395
|
-
|
|
3396
|
-
|
|
3247
|
+
let t1;
|
|
3248
|
+
if ($[10] !== arrayField || $[11] !== children || $[12] !== field.className || $[13] !== field.description || $[14] !== field.label || $[15] !== field.name || $[16] !== items || $[17] !== move || $[18] !== remove || $[19] !== renderItem) {
|
|
3249
|
+
let t2;
|
|
3250
|
+
if ($[21] !== arrayField || $[22] !== children || $[23] !== field.name || $[24] !== move || $[25] !== remove || $[26] !== renderItem) {
|
|
3251
|
+
t2 = t3 => {
|
|
3252
|
+
const {
|
|
3253
|
+
id: id_0,
|
|
3254
|
+
index: index_0
|
|
3255
|
+
} = t3;
|
|
3256
|
+
return children({
|
|
3257
|
+
index: index_0,
|
|
3258
|
+
id: id_0,
|
|
3259
|
+
remove: () => remove(index_0),
|
|
3260
|
+
move: toIndex => move(index_0, toIndex),
|
|
3261
|
+
fields: renderItem(index_0),
|
|
3262
|
+
fieldNames: arrayField.fields.map(_temp),
|
|
3263
|
+
namePrefix: `${field.name}.${index_0}`
|
|
3264
|
+
});
|
|
3265
|
+
};
|
|
3266
|
+
$[21] = arrayField;
|
|
3267
|
+
$[22] = children;
|
|
3268
|
+
$[23] = field.name;
|
|
3269
|
+
$[24] = move;
|
|
3270
|
+
$[25] = remove;
|
|
3271
|
+
$[26] = renderItem;
|
|
3272
|
+
$[27] = t2;
|
|
3273
|
+
} else {
|
|
3274
|
+
t2 = $[27];
|
|
3275
|
+
}
|
|
3276
|
+
t1 = jsxs("div", {
|
|
3277
|
+
className: field.className,
|
|
3278
|
+
children: [field.label && jsx("label", {
|
|
3279
|
+
children: field.label
|
|
3280
|
+
}), field.description && jsx("p", {
|
|
3281
|
+
children: field.description
|
|
3282
|
+
}), items.map(t2)]
|
|
3283
|
+
});
|
|
3284
|
+
$[10] = arrayField;
|
|
3285
|
+
$[11] = children;
|
|
3286
|
+
$[12] = field.className;
|
|
3287
|
+
$[13] = field.description;
|
|
3288
|
+
$[14] = field.label;
|
|
3289
|
+
$[15] = field.name;
|
|
3290
|
+
$[16] = items;
|
|
3291
|
+
$[17] = move;
|
|
3292
|
+
$[18] = remove;
|
|
3293
|
+
$[19] = renderItem;
|
|
3294
|
+
$[20] = t1;
|
|
3295
|
+
} else {
|
|
3296
|
+
t1 = $[20];
|
|
3397
3297
|
}
|
|
3398
3298
|
return t1;
|
|
3399
3299
|
});
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
return
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3300
|
+
ArrayFieldRenderer.displayName = 'ArrayFieldRenderer';
|
|
3301
|
+
function _temp(f) {
|
|
3302
|
+
return f.name;
|
|
3303
|
+
}
|
|
3304
|
+
|
|
3305
|
+
const RESERVED_PROPS = new Set(['all', 'remaining', 'names', 'has', 'render']);
|
|
3306
|
+
function createTemplateFields(fieldEntries) {
|
|
3307
|
+
const accessedFields = new Set();
|
|
3308
|
+
const handler = {
|
|
3309
|
+
get(_, prop) {
|
|
3310
|
+
if (typeof prop === 'symbol') {
|
|
3311
|
+
return undefined;
|
|
3312
|
+
}
|
|
3313
|
+
if (prop === 'all') {
|
|
3314
|
+
return Array.from(fieldEntries.values()).map(entry => entry.element);
|
|
3315
|
+
}
|
|
3316
|
+
if (prop === 'remaining') {
|
|
3317
|
+
return Array.from(fieldEntries.entries()).filter(([name]) => !accessedFields.has(name)).map(([, entry]) => entry.element);
|
|
3318
|
+
}
|
|
3319
|
+
if (prop === 'names') {
|
|
3320
|
+
return Array.from(fieldEntries.keys());
|
|
3321
|
+
}
|
|
3322
|
+
if (prop === 'has') {
|
|
3323
|
+
return name => fieldEntries.has(name);
|
|
3324
|
+
}
|
|
3325
|
+
if (prop === 'render') {
|
|
3326
|
+
return (...names) => {
|
|
3327
|
+
return names.filter(name => fieldEntries.has(name)).map(name => {
|
|
3328
|
+
accessedFields.add(name);
|
|
3329
|
+
return fieldEntries.get(name).element;
|
|
3330
|
+
});
|
|
3331
|
+
};
|
|
3332
|
+
}
|
|
3333
|
+
if (fieldEntries.has(prop)) {
|
|
3334
|
+
accessedFields.add(prop);
|
|
3335
|
+
return fieldEntries.get(prop).element;
|
|
3336
|
+
}
|
|
3337
|
+
return undefined;
|
|
3338
|
+
},
|
|
3339
|
+
has(_, prop) {
|
|
3340
|
+
if (typeof prop === 'symbol') {
|
|
3341
|
+
return false;
|
|
3342
|
+
}
|
|
3343
|
+
return RESERVED_PROPS.has(prop) || fieldEntries.has(prop);
|
|
3344
|
+
},
|
|
3345
|
+
ownKeys() {
|
|
3346
|
+
return [...RESERVED_PROPS, ...fieldEntries.keys()];
|
|
3347
|
+
},
|
|
3348
|
+
getOwnPropertyDescriptor(_, prop) {
|
|
3349
|
+
if (typeof prop === 'symbol') {
|
|
3350
|
+
return undefined;
|
|
3351
|
+
}
|
|
3352
|
+
if (RESERVED_PROPS.has(prop) || fieldEntries.has(prop)) {
|
|
3353
|
+
return {
|
|
3354
|
+
configurable: true,
|
|
3355
|
+
enumerable: true,
|
|
3356
|
+
value: this.get(_, prop, {})
|
|
3357
|
+
};
|
|
3358
|
+
}
|
|
3359
|
+
return undefined;
|
|
3423
3360
|
}
|
|
3424
|
-
}
|
|
3425
|
-
return
|
|
3426
|
-
|
|
3427
|
-
namePrefix: namePrefix
|
|
3428
|
-
});
|
|
3429
|
-
});
|
|
3430
|
-
FormItemRenderer.displayName = 'FormItemRenderer';
|
|
3361
|
+
};
|
|
3362
|
+
return new Proxy({}, handler);
|
|
3363
|
+
}
|
|
3431
3364
|
|
|
3432
3365
|
function deepMerge(target, source) {
|
|
3433
3366
|
const result = {
|
|
@@ -3483,96 +3416,61 @@ function getValidatorForField(field) {
|
|
|
3483
3416
|
}
|
|
3484
3417
|
return z.any();
|
|
3485
3418
|
}
|
|
3486
|
-
function
|
|
3419
|
+
function buildArrayItemSchema(arrayField) {
|
|
3420
|
+
const itemShape = {};
|
|
3421
|
+
for (const field of arrayField.fields) {
|
|
3422
|
+
const validator = getValidatorForField(field);
|
|
3423
|
+
itemShape[field.name] = field.required ? validator : validator.optional();
|
|
3424
|
+
}
|
|
3425
|
+
return z.object(itemShape);
|
|
3426
|
+
}
|
|
3427
|
+
function buildSchema(fields) {
|
|
3487
3428
|
const shape = {};
|
|
3488
|
-
for (const
|
|
3489
|
-
if (
|
|
3490
|
-
let
|
|
3491
|
-
if (
|
|
3492
|
-
|
|
3493
|
-
childItems.push(...column.children);
|
|
3494
|
-
}
|
|
3495
|
-
} else if (item.type === 'section') {
|
|
3496
|
-
childItems = item.children;
|
|
3429
|
+
for (const field of fields) {
|
|
3430
|
+
if (isArrayField(field)) {
|
|
3431
|
+
let arraySchema = z.array(buildArrayItemSchema(field));
|
|
3432
|
+
if (field.minItems !== undefined) {
|
|
3433
|
+
arraySchema = arraySchema.min(field.minItems);
|
|
3497
3434
|
}
|
|
3498
|
-
if (
|
|
3499
|
-
|
|
3500
|
-
} else {
|
|
3501
|
-
const childSchema = buildSchema(childItems);
|
|
3502
|
-
if (childSchema instanceof z.ZodObject) {
|
|
3503
|
-
Object.assign(shape, childSchema.shape);
|
|
3504
|
-
}
|
|
3435
|
+
if (field.maxItems !== undefined) {
|
|
3436
|
+
arraySchema = arraySchema.max(field.maxItems);
|
|
3505
3437
|
}
|
|
3438
|
+
shape[field.name] = arraySchema;
|
|
3506
3439
|
} else {
|
|
3507
|
-
const field = item;
|
|
3508
3440
|
const validator = getValidatorForField(field);
|
|
3509
3441
|
shape[field.name] = field.required ? validator : validator.optional();
|
|
3510
3442
|
}
|
|
3511
3443
|
}
|
|
3512
3444
|
return z.object(shape);
|
|
3513
3445
|
}
|
|
3514
|
-
function
|
|
3446
|
+
function buildArrayItemDefaults(arrayField) {
|
|
3447
|
+
var _a;
|
|
3448
|
+
const item = {};
|
|
3449
|
+
for (const field of arrayField.fields) {
|
|
3450
|
+
item[field.name] = (_a = field.defaultValue) !== null && _a !== void 0 ? _a : '';
|
|
3451
|
+
}
|
|
3452
|
+
return item;
|
|
3453
|
+
}
|
|
3454
|
+
function buildDefaultValues(fields) {
|
|
3515
3455
|
var _a;
|
|
3516
3456
|
const values = {};
|
|
3517
|
-
for (const
|
|
3518
|
-
if (
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
childItems = item.children;
|
|
3526
|
-
}
|
|
3527
|
-
if (item.wrapFieldNames && item.name) {
|
|
3528
|
-
values[item.name] = buildDefaultValues(childItems);
|
|
3457
|
+
for (const field of fields) {
|
|
3458
|
+
if (isArrayField(field)) {
|
|
3459
|
+
if (field.defaultValue && field.defaultValue.length > 0) {
|
|
3460
|
+
values[field.name] = field.defaultValue;
|
|
3461
|
+
} else if (field.minItems && field.minItems > 0) {
|
|
3462
|
+
values[field.name] = Array.from({
|
|
3463
|
+
length: field.minItems
|
|
3464
|
+
}, () => buildArrayItemDefaults(field));
|
|
3529
3465
|
} else {
|
|
3530
|
-
|
|
3466
|
+
values[field.name] = [];
|
|
3531
3467
|
}
|
|
3532
3468
|
} else {
|
|
3533
|
-
const field = item;
|
|
3534
3469
|
values[field.name] = (_a = field.defaultValue) !== null && _a !== void 0 ? _a : '';
|
|
3535
3470
|
}
|
|
3536
3471
|
}
|
|
3537
3472
|
return values;
|
|
3538
3473
|
}
|
|
3539
|
-
function getItemKey(item, index) {
|
|
3540
|
-
if (isLayoutBlock(item)) {
|
|
3541
|
-
return `layout-${item.type}-${index}`;
|
|
3542
|
-
}
|
|
3543
|
-
return item.name;
|
|
3544
|
-
}
|
|
3545
|
-
function extractFields(items) {
|
|
3546
|
-
const fields = [];
|
|
3547
|
-
for (const item of items) {
|
|
3548
|
-
if (isLayoutBlock(item)) {
|
|
3549
|
-
let childItems = [];
|
|
3550
|
-
if (item.type === 'columns') {
|
|
3551
|
-
for (const column of item.columns) {
|
|
3552
|
-
childItems.push(...column.children);
|
|
3553
|
-
}
|
|
3554
|
-
} else if (item.type === 'section') {
|
|
3555
|
-
childItems = item.children;
|
|
3556
|
-
}
|
|
3557
|
-
fields.push(...extractFields(childItems));
|
|
3558
|
-
} else {
|
|
3559
|
-
fields.push(item);
|
|
3560
|
-
}
|
|
3561
|
-
}
|
|
3562
|
-
return fields;
|
|
3563
|
-
}
|
|
3564
|
-
function extractLayouts(items) {
|
|
3565
|
-
const layouts = [];
|
|
3566
|
-
items.forEach((item, index) => {
|
|
3567
|
-
if (isLayoutBlock(item)) {
|
|
3568
|
-
layouts.push({
|
|
3569
|
-
layout: item,
|
|
3570
|
-
index
|
|
3571
|
-
});
|
|
3572
|
-
}
|
|
3573
|
-
});
|
|
3574
|
-
return layouts;
|
|
3575
|
-
}
|
|
3576
3474
|
|
|
3577
3475
|
function hasSchema(props) {
|
|
3578
3476
|
return props.schema !== undefined;
|
|
@@ -3643,47 +3541,41 @@ function FormGeneratorImpl(props) {
|
|
|
3643
3541
|
form: form
|
|
3644
3542
|
}), [form, handleSubmit, mergedDefaultValues]);
|
|
3645
3543
|
const SubmitButton = getFormComponent('SubmitButton');
|
|
3544
|
+
const {
|
|
3545
|
+
regularFields,
|
|
3546
|
+
arrayFields
|
|
3547
|
+
} = useMemo(() => {
|
|
3548
|
+
const regular = [];
|
|
3549
|
+
const arrays = [];
|
|
3550
|
+
fields.forEach(field => {
|
|
3551
|
+
if (isArrayField(field)) {
|
|
3552
|
+
arrays.push(field);
|
|
3553
|
+
} else {
|
|
3554
|
+
regular.push(field);
|
|
3555
|
+
}
|
|
3556
|
+
});
|
|
3557
|
+
return {
|
|
3558
|
+
regularFields: regular,
|
|
3559
|
+
arrayFields: arrays
|
|
3560
|
+
};
|
|
3561
|
+
}, [fields]);
|
|
3646
3562
|
const fieldEntries = useMemo(() => {
|
|
3647
3563
|
const entries = new Map();
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
if (!field.hidden) {
|
|
3564
|
+
regularFields.forEach((field_0, index) => {
|
|
3565
|
+
if (!field_0.hidden) {
|
|
3651
3566
|
const element = jsx(FieldRenderer, {
|
|
3652
|
-
field:
|
|
3653
|
-
},
|
|
3654
|
-
entries.set(
|
|
3655
|
-
field,
|
|
3567
|
+
field: field_0
|
|
3568
|
+
}, field_0.name || `field-${index}`);
|
|
3569
|
+
entries.set(field_0.name, {
|
|
3570
|
+
field: field_0,
|
|
3656
3571
|
element,
|
|
3657
3572
|
accessed: false
|
|
3658
3573
|
});
|
|
3659
3574
|
}
|
|
3660
3575
|
});
|
|
3661
3576
|
return entries;
|
|
3662
|
-
}, [
|
|
3663
|
-
const layoutEntries = useMemo(() => {
|
|
3664
|
-
const entries_0 = new Map();
|
|
3665
|
-
const allLayouts = extractLayouts(fields);
|
|
3666
|
-
allLayouts.forEach(({
|
|
3667
|
-
layout,
|
|
3668
|
-
index: index_0
|
|
3669
|
-
}) => {
|
|
3670
|
-
if (!layout.hidden) {
|
|
3671
|
-
const key_0 = layout.name || `layout-${layout.type}-${index_0}`;
|
|
3672
|
-
const element_0 = jsx(FormItemRenderer, {
|
|
3673
|
-
item: layout
|
|
3674
|
-
}, key_0);
|
|
3675
|
-
if (layout.name) {
|
|
3676
|
-
entries_0.set(layout.name, {
|
|
3677
|
-
layout,
|
|
3678
|
-
element: element_0
|
|
3679
|
-
});
|
|
3680
|
-
}
|
|
3681
|
-
}
|
|
3682
|
-
});
|
|
3683
|
-
return entries_0;
|
|
3684
|
-
}, [fields]);
|
|
3577
|
+
}, [regularFields]);
|
|
3685
3578
|
const templateFields = useMemo(() => createTemplateFields(fieldEntries), [fieldEntries]);
|
|
3686
|
-
const templateLayouts = useMemo(() => createTemplateLayouts(layoutEntries), [layoutEntries]);
|
|
3687
3579
|
const buttons = useMemo(() => {
|
|
3688
3580
|
const result = {
|
|
3689
3581
|
submit: jsx(SubmitButton, {
|
|
@@ -3702,18 +3594,12 @@ function FormGeneratorImpl(props) {
|
|
|
3702
3594
|
}
|
|
3703
3595
|
return result;
|
|
3704
3596
|
}, [SubmitButton, disabled, form.formState.isSubmitting, submitText, showReset, resetText, handleReset]);
|
|
3705
|
-
const renderField = useCallback((
|
|
3597
|
+
const renderField = useCallback((field_1, options) => {
|
|
3706
3598
|
return jsx(FieldRenderer, {
|
|
3707
|
-
field:
|
|
3599
|
+
field: field_1,
|
|
3708
3600
|
namePrefix: options === null || options === void 0 ? void 0 : options.namePrefix
|
|
3709
3601
|
});
|
|
3710
3602
|
}, []);
|
|
3711
|
-
const renderLayout = useCallback((layout_0, options_0) => {
|
|
3712
|
-
return jsx(FormItemRenderer, {
|
|
3713
|
-
item: layout_0,
|
|
3714
|
-
namePrefix: options_0 === null || options_0 === void 0 ? void 0 : options_0.namePrefix
|
|
3715
|
-
});
|
|
3716
|
-
}, []);
|
|
3717
3603
|
if (!children) {
|
|
3718
3604
|
return jsx(FormProvider, {
|
|
3719
3605
|
...form,
|
|
@@ -3721,9 +3607,11 @@ function FormGeneratorImpl(props) {
|
|
|
3721
3607
|
ref: formRef,
|
|
3722
3608
|
onSubmit: handleSubmit,
|
|
3723
3609
|
className: className,
|
|
3724
|
-
children: [
|
|
3725
|
-
|
|
3726
|
-
},
|
|
3610
|
+
children: [regularFields.map((field_2, index_0) => jsx(FieldRenderer, {
|
|
3611
|
+
field: field_2
|
|
3612
|
+
}, field_2.name || `field-${index_0}`)), arrayFields.map(arrayField => jsx(ArrayFieldRenderer, {
|
|
3613
|
+
field: arrayField
|
|
3614
|
+
}, arrayField.name)), jsx(SubmitButton, {
|
|
3727
3615
|
disabled: disabled || form.formState.isSubmitting,
|
|
3728
3616
|
isSubmitting: form.formState.isSubmitting,
|
|
3729
3617
|
children: submitText
|
|
@@ -3733,7 +3621,9 @@ function FormGeneratorImpl(props) {
|
|
|
3733
3621
|
}
|
|
3734
3622
|
const renderProps = {
|
|
3735
3623
|
fields: templateFields,
|
|
3736
|
-
|
|
3624
|
+
arrays: Object.fromEntries(arrayFields.map(arrayField_0 => [arrayField_0.name, {
|
|
3625
|
+
field: arrayField_0
|
|
3626
|
+
}])),
|
|
3737
3627
|
buttons,
|
|
3738
3628
|
title,
|
|
3739
3629
|
description,
|
|
@@ -3741,8 +3631,7 @@ function FormGeneratorImpl(props) {
|
|
|
3741
3631
|
isSubmitting: form.formState.isSubmitting,
|
|
3742
3632
|
isValid: form.formState.isValid,
|
|
3743
3633
|
isDirty: form.formState.isDirty,
|
|
3744
|
-
renderField
|
|
3745
|
-
renderLayout
|
|
3634
|
+
renderField
|
|
3746
3635
|
};
|
|
3747
3636
|
const renderFn = children;
|
|
3748
3637
|
return jsx(FormProvider, {
|
|
@@ -3759,5 +3648,5 @@ function FormGenerator(props) {
|
|
|
3759
3648
|
return FormGeneratorImpl(props);
|
|
3760
3649
|
}
|
|
3761
3650
|
|
|
3762
|
-
export { Controller, FieldRenderer, FormGenerator, FormProvider, clearAllRegistries, clearFieldRegistry, clearFormComponentRegistry,
|
|
3651
|
+
export { ArrayFieldRenderer, Controller, FieldRenderer, FormGenerator, FormProvider, clearAllRegistries, clearFieldRegistry, clearFormComponentRegistry, getFieldComponent, getFormComponent, getFormComponents, getRegisteredFieldTypes, hasFieldType, hasFormComponent, isArrayField, registerField, registerFields, registerFormComponent, registerFormComponents, resetFormComponentRegistry, unregisterField, useArrayField, useFieldArray, useForm, useFormContext, useWatch };
|
|
3763
3652
|
//# sourceMappingURL=index.mjs.map
|