@connect-soft/form-generator 1.1.0-alpha5 → 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 +335 -453
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +335 -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 +4 -4
- 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 => {
|
|
@@ -3234,18 +3060,6 @@ const FieldRenderer = /*#__PURE__*/memo(t0 => {
|
|
|
3234
3060
|
t2 = null;
|
|
3235
3061
|
break bb0;
|
|
3236
3062
|
}
|
|
3237
|
-
const FormItemComponent = getFormComponent("FormItem");
|
|
3238
|
-
const FormLabelComponent = getFormComponent("FormLabel");
|
|
3239
|
-
const FormInputLabelWrapper = getFormComponent("FormInputLabelWrapper");
|
|
3240
|
-
const FormDescriptionComponent = getFormComponent("FormDescription");
|
|
3241
|
-
const FormMessageComponent = getFormComponent("FormMessage");
|
|
3242
|
-
if (!FormItemComponent) {
|
|
3243
|
-
console.warn("FormItem component not registered. Use registerFormComponent(\"FormItem\", Component) to register one.");
|
|
3244
|
-
t2 = null;
|
|
3245
|
-
break bb0;
|
|
3246
|
-
}
|
|
3247
|
-
const fieldOptions = getFieldOptions(field.type);
|
|
3248
|
-
const itemClassName = [`form-field-${field.type}`, fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.className, field.className].filter(Boolean).join(" ");
|
|
3249
3063
|
const fieldName = namePrefix ? `${namePrefix}.${field.name}` : field.name;
|
|
3250
3064
|
t1 = jsx(Controller, {
|
|
3251
3065
|
control: form.control,
|
|
@@ -3255,36 +3069,18 @@ const FieldRenderer = /*#__PURE__*/memo(t0 => {
|
|
|
3255
3069
|
field: formField,
|
|
3256
3070
|
fieldState
|
|
3257
3071
|
} = t3;
|
|
3258
|
-
return
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
orientation: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.inputLabelWrapperOrientation,
|
|
3262
|
-
className: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.inputLabelWrapper,
|
|
3263
|
-
children: [field.label && FormLabelComponent && jsx(FormLabelComponent, {
|
|
3264
|
-
className: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.labelClassName,
|
|
3265
|
-
required: field.required,
|
|
3266
|
-
htmlFor: fieldName,
|
|
3267
|
-
children: field.label
|
|
3268
|
-
}), jsx(FieldComponent, {
|
|
3269
|
-
field: {
|
|
3270
|
-
...field,
|
|
3271
|
-
name: fieldName
|
|
3272
|
-
},
|
|
3273
|
-
formField,
|
|
3274
|
-
fieldState: {
|
|
3275
|
-
invalid: fieldState.invalid,
|
|
3276
|
-
error: fieldState.error,
|
|
3277
|
-
isDirty: fieldState.isDirty,
|
|
3278
|
-
isTouched: fieldState.isTouched
|
|
3279
|
-
}
|
|
3280
|
-
})]
|
|
3281
|
-
}), field.description && FormDescriptionComponent && jsx(FormDescriptionComponent, {
|
|
3282
|
-
className: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.descriptionClassName,
|
|
3283
|
-
children: field.description
|
|
3284
|
-
}), FormMessageComponent && jsx(FormMessageComponent, {
|
|
3285
|
-
className: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.messageClassName,
|
|
3072
|
+
return jsx(FieldComponent, {
|
|
3073
|
+
field: {
|
|
3074
|
+
...field,
|
|
3286
3075
|
name: fieldName
|
|
3287
|
-
}
|
|
3076
|
+
},
|
|
3077
|
+
formField,
|
|
3078
|
+
fieldState: {
|
|
3079
|
+
invalid: fieldState.invalid,
|
|
3080
|
+
error: fieldState.error,
|
|
3081
|
+
isDirty: fieldState.isDirty,
|
|
3082
|
+
isTouched: fieldState.isTouched
|
|
3083
|
+
}
|
|
3288
3084
|
});
|
|
3289
3085
|
}
|
|
3290
3086
|
});
|
|
@@ -3304,134 +3100,267 @@ const FieldRenderer = /*#__PURE__*/memo(t0 => {
|
|
|
3304
3100
|
return t1;
|
|
3305
3101
|
});
|
|
3306
3102
|
FieldRenderer.displayName = 'FieldRenderer';
|
|
3307
|
-
|
|
3308
|
-
|
|
3103
|
+
|
|
3104
|
+
function useArrayField(field) {
|
|
3309
3105
|
const {
|
|
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
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
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, {});
|
|
3341
3148
|
}
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
}
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
});
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
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);
|
|
3358
3186
|
const {
|
|
3359
|
-
|
|
3360
|
-
|
|
3187
|
+
field,
|
|
3188
|
+
children
|
|
3361
3189
|
} = t0;
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
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;
|
|
3382
3219
|
} else {
|
|
3383
|
-
|
|
3220
|
+
t2 = $[9];
|
|
3384
3221
|
}
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
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
|
+
})]
|
|
3389
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];
|
|
3390
3244
|
}
|
|
3391
|
-
|
|
3392
|
-
$[1] = namePrefix;
|
|
3393
|
-
$[2] = t1;
|
|
3394
|
-
$[3] = t2;
|
|
3395
|
-
} else {
|
|
3396
|
-
t1 = $[2];
|
|
3397
|
-
t2 = $[3];
|
|
3245
|
+
return t1;
|
|
3398
3246
|
}
|
|
3399
|
-
|
|
3400
|
-
|
|
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];
|
|
3401
3297
|
}
|
|
3402
3298
|
return t1;
|
|
3403
3299
|
});
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
return
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
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;
|
|
3427
3360
|
}
|
|
3428
|
-
}
|
|
3429
|
-
return
|
|
3430
|
-
|
|
3431
|
-
namePrefix: namePrefix
|
|
3432
|
-
});
|
|
3433
|
-
});
|
|
3434
|
-
FormItemRenderer.displayName = 'FormItemRenderer';
|
|
3361
|
+
};
|
|
3362
|
+
return new Proxy({}, handler);
|
|
3363
|
+
}
|
|
3435
3364
|
|
|
3436
3365
|
function deepMerge(target, source) {
|
|
3437
3366
|
const result = {
|
|
@@ -3487,96 +3416,61 @@ function getValidatorForField(field) {
|
|
|
3487
3416
|
}
|
|
3488
3417
|
return z.any();
|
|
3489
3418
|
}
|
|
3490
|
-
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) {
|
|
3491
3428
|
const shape = {};
|
|
3492
|
-
for (const
|
|
3493
|
-
if (
|
|
3494
|
-
let
|
|
3495
|
-
if (
|
|
3496
|
-
|
|
3497
|
-
childItems.push(...column.children);
|
|
3498
|
-
}
|
|
3499
|
-
} else if (item.type === 'section') {
|
|
3500
|
-
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);
|
|
3501
3434
|
}
|
|
3502
|
-
if (
|
|
3503
|
-
|
|
3504
|
-
} else {
|
|
3505
|
-
const childSchema = buildSchema(childItems);
|
|
3506
|
-
if (childSchema instanceof z.ZodObject) {
|
|
3507
|
-
Object.assign(shape, childSchema.shape);
|
|
3508
|
-
}
|
|
3435
|
+
if (field.maxItems !== undefined) {
|
|
3436
|
+
arraySchema = arraySchema.max(field.maxItems);
|
|
3509
3437
|
}
|
|
3438
|
+
shape[field.name] = arraySchema;
|
|
3510
3439
|
} else {
|
|
3511
|
-
const field = item;
|
|
3512
3440
|
const validator = getValidatorForField(field);
|
|
3513
3441
|
shape[field.name] = field.required ? validator : validator.optional();
|
|
3514
3442
|
}
|
|
3515
3443
|
}
|
|
3516
3444
|
return z.object(shape);
|
|
3517
3445
|
}
|
|
3518
|
-
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) {
|
|
3519
3455
|
var _a;
|
|
3520
3456
|
const values = {};
|
|
3521
|
-
for (const
|
|
3522
|
-
if (
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
childItems = item.children;
|
|
3530
|
-
}
|
|
3531
|
-
if (item.wrapFieldNames && item.name) {
|
|
3532
|
-
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));
|
|
3533
3465
|
} else {
|
|
3534
|
-
|
|
3466
|
+
values[field.name] = [];
|
|
3535
3467
|
}
|
|
3536
3468
|
} else {
|
|
3537
|
-
const field = item;
|
|
3538
3469
|
values[field.name] = (_a = field.defaultValue) !== null && _a !== void 0 ? _a : '';
|
|
3539
3470
|
}
|
|
3540
3471
|
}
|
|
3541
3472
|
return values;
|
|
3542
3473
|
}
|
|
3543
|
-
function getItemKey(item, index) {
|
|
3544
|
-
if (isLayoutBlock(item)) {
|
|
3545
|
-
return `layout-${item.type}-${index}`;
|
|
3546
|
-
}
|
|
3547
|
-
return item.name;
|
|
3548
|
-
}
|
|
3549
|
-
function extractFields(items) {
|
|
3550
|
-
const fields = [];
|
|
3551
|
-
for (const item of items) {
|
|
3552
|
-
if (isLayoutBlock(item)) {
|
|
3553
|
-
let childItems = [];
|
|
3554
|
-
if (item.type === 'columns') {
|
|
3555
|
-
for (const column of item.columns) {
|
|
3556
|
-
childItems.push(...column.children);
|
|
3557
|
-
}
|
|
3558
|
-
} else if (item.type === 'section') {
|
|
3559
|
-
childItems = item.children;
|
|
3560
|
-
}
|
|
3561
|
-
fields.push(...extractFields(childItems));
|
|
3562
|
-
} else {
|
|
3563
|
-
fields.push(item);
|
|
3564
|
-
}
|
|
3565
|
-
}
|
|
3566
|
-
return fields;
|
|
3567
|
-
}
|
|
3568
|
-
function extractLayouts(items) {
|
|
3569
|
-
const layouts = [];
|
|
3570
|
-
items.forEach((item, index) => {
|
|
3571
|
-
if (isLayoutBlock(item)) {
|
|
3572
|
-
layouts.push({
|
|
3573
|
-
layout: item,
|
|
3574
|
-
index
|
|
3575
|
-
});
|
|
3576
|
-
}
|
|
3577
|
-
});
|
|
3578
|
-
return layouts;
|
|
3579
|
-
}
|
|
3580
3474
|
|
|
3581
3475
|
function hasSchema(props) {
|
|
3582
3476
|
return props.schema !== undefined;
|
|
@@ -3647,47 +3541,41 @@ function FormGeneratorImpl(props) {
|
|
|
3647
3541
|
form: form
|
|
3648
3542
|
}), [form, handleSubmit, mergedDefaultValues]);
|
|
3649
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]);
|
|
3650
3562
|
const fieldEntries = useMemo(() => {
|
|
3651
3563
|
const entries = new Map();
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
if (!field.hidden) {
|
|
3564
|
+
regularFields.forEach((field_0, index) => {
|
|
3565
|
+
if (!field_0.hidden) {
|
|
3655
3566
|
const element = jsx(FieldRenderer, {
|
|
3656
|
-
field:
|
|
3657
|
-
},
|
|
3658
|
-
entries.set(
|
|
3659
|
-
field,
|
|
3567
|
+
field: field_0
|
|
3568
|
+
}, field_0.name || `field-${index}`);
|
|
3569
|
+
entries.set(field_0.name, {
|
|
3570
|
+
field: field_0,
|
|
3660
3571
|
element,
|
|
3661
3572
|
accessed: false
|
|
3662
3573
|
});
|
|
3663
3574
|
}
|
|
3664
3575
|
});
|
|
3665
3576
|
return entries;
|
|
3666
|
-
}, [
|
|
3667
|
-
const layoutEntries = useMemo(() => {
|
|
3668
|
-
const entries_0 = new Map();
|
|
3669
|
-
const allLayouts = extractLayouts(fields);
|
|
3670
|
-
allLayouts.forEach(({
|
|
3671
|
-
layout,
|
|
3672
|
-
index: index_0
|
|
3673
|
-
}) => {
|
|
3674
|
-
if (!layout.hidden) {
|
|
3675
|
-
const key_0 = layout.name || `layout-${layout.type}-${index_0}`;
|
|
3676
|
-
const element_0 = jsx(FormItemRenderer, {
|
|
3677
|
-
item: layout
|
|
3678
|
-
}, key_0);
|
|
3679
|
-
if (layout.name) {
|
|
3680
|
-
entries_0.set(layout.name, {
|
|
3681
|
-
layout,
|
|
3682
|
-
element: element_0
|
|
3683
|
-
});
|
|
3684
|
-
}
|
|
3685
|
-
}
|
|
3686
|
-
});
|
|
3687
|
-
return entries_0;
|
|
3688
|
-
}, [fields]);
|
|
3577
|
+
}, [regularFields]);
|
|
3689
3578
|
const templateFields = useMemo(() => createTemplateFields(fieldEntries), [fieldEntries]);
|
|
3690
|
-
const templateLayouts = useMemo(() => createTemplateLayouts(layoutEntries), [layoutEntries]);
|
|
3691
3579
|
const buttons = useMemo(() => {
|
|
3692
3580
|
const result = {
|
|
3693
3581
|
submit: jsx(SubmitButton, {
|
|
@@ -3706,18 +3594,12 @@ function FormGeneratorImpl(props) {
|
|
|
3706
3594
|
}
|
|
3707
3595
|
return result;
|
|
3708
3596
|
}, [SubmitButton, disabled, form.formState.isSubmitting, submitText, showReset, resetText, handleReset]);
|
|
3709
|
-
const renderField = useCallback((
|
|
3597
|
+
const renderField = useCallback((field_1, options) => {
|
|
3710
3598
|
return jsx(FieldRenderer, {
|
|
3711
|
-
field:
|
|
3599
|
+
field: field_1,
|
|
3712
3600
|
namePrefix: options === null || options === void 0 ? void 0 : options.namePrefix
|
|
3713
3601
|
});
|
|
3714
3602
|
}, []);
|
|
3715
|
-
const renderLayout = useCallback((layout_0, options_0) => {
|
|
3716
|
-
return jsx(FormItemRenderer, {
|
|
3717
|
-
item: layout_0,
|
|
3718
|
-
namePrefix: options_0 === null || options_0 === void 0 ? void 0 : options_0.namePrefix
|
|
3719
|
-
});
|
|
3720
|
-
}, []);
|
|
3721
3603
|
if (!children) {
|
|
3722
3604
|
return jsx(FormProvider, {
|
|
3723
3605
|
...form,
|
|
@@ -3725,9 +3607,11 @@ function FormGeneratorImpl(props) {
|
|
|
3725
3607
|
ref: formRef,
|
|
3726
3608
|
onSubmit: handleSubmit,
|
|
3727
3609
|
className: className,
|
|
3728
|
-
children: [
|
|
3729
|
-
|
|
3730
|
-
},
|
|
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, {
|
|
3731
3615
|
disabled: disabled || form.formState.isSubmitting,
|
|
3732
3616
|
isSubmitting: form.formState.isSubmitting,
|
|
3733
3617
|
children: submitText
|
|
@@ -3737,7 +3621,9 @@ function FormGeneratorImpl(props) {
|
|
|
3737
3621
|
}
|
|
3738
3622
|
const renderProps = {
|
|
3739
3623
|
fields: templateFields,
|
|
3740
|
-
|
|
3624
|
+
arrays: Object.fromEntries(arrayFields.map(arrayField_0 => [arrayField_0.name, {
|
|
3625
|
+
field: arrayField_0
|
|
3626
|
+
}])),
|
|
3741
3627
|
buttons,
|
|
3742
3628
|
title,
|
|
3743
3629
|
description,
|
|
@@ -3745,8 +3631,7 @@ function FormGeneratorImpl(props) {
|
|
|
3745
3631
|
isSubmitting: form.formState.isSubmitting,
|
|
3746
3632
|
isValid: form.formState.isValid,
|
|
3747
3633
|
isDirty: form.formState.isDirty,
|
|
3748
|
-
renderField
|
|
3749
|
-
renderLayout
|
|
3634
|
+
renderField
|
|
3750
3635
|
};
|
|
3751
3636
|
const renderFn = children;
|
|
3752
3637
|
return jsx(FormProvider, {
|
|
@@ -3763,5 +3648,5 @@ function FormGenerator(props) {
|
|
|
3763
3648
|
return FormGeneratorImpl(props);
|
|
3764
3649
|
}
|
|
3765
3650
|
|
|
3766
|
-
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 };
|
|
3767
3652
|
//# sourceMappingURL=index.mjs.map
|