@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.js
CHANGED
|
@@ -2792,52 +2792,13 @@ const r=(t,r,o)=>{if(t&&"reportValidity"in t){const s=get(o,r);t.setCustomValidi
|
|
|
2792
2792
|
|
|
2793
2793
|
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__namespace.parse:n__namespace.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__namespace.$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")}
|
|
2794
2794
|
|
|
2795
|
-
function
|
|
2796
|
-
return
|
|
2795
|
+
function isArrayField(field) {
|
|
2796
|
+
return field.type === 'array' && 'fields' in field;
|
|
2797
2797
|
}
|
|
2798
2798
|
|
|
2799
2799
|
const fieldRegistry = new Map();
|
|
2800
2800
|
const componentRegistry = {};
|
|
2801
|
-
const layoutRegistry = {};
|
|
2802
2801
|
const defaultFormComponents = {
|
|
2803
|
-
FormItem: ({
|
|
2804
|
-
className,
|
|
2805
|
-
children
|
|
2806
|
-
}) => /*#__PURE__*/React.createElement('div', {
|
|
2807
|
-
className: className !== null && className !== void 0 ? className : 'form-item'
|
|
2808
|
-
}, children),
|
|
2809
|
-
FormInputLabelWrapper: ({
|
|
2810
|
-
className,
|
|
2811
|
-
orientation,
|
|
2812
|
-
children
|
|
2813
|
-
}) => /*#__PURE__*/React.createElement('div', {
|
|
2814
|
-
'className': className !== null && className !== void 0 ? className : 'form-input-label-wrapper',
|
|
2815
|
-
'data-orientation': orientation !== null && orientation !== void 0 ? orientation : 'vertical'
|
|
2816
|
-
}, children),
|
|
2817
|
-
FormLabel: ({
|
|
2818
|
-
className,
|
|
2819
|
-
children,
|
|
2820
|
-
required,
|
|
2821
|
-
htmlFor
|
|
2822
|
-
}) => /*#__PURE__*/React.createElement('label', {
|
|
2823
|
-
className: className !== null && className !== void 0 ? className : 'form-label',
|
|
2824
|
-
htmlFor
|
|
2825
|
-
}, children, required && /*#__PURE__*/React.createElement('span', {
|
|
2826
|
-
className: 'required-indicator'
|
|
2827
|
-
}, ' *')),
|
|
2828
|
-
FormDescription: ({
|
|
2829
|
-
className,
|
|
2830
|
-
children
|
|
2831
|
-
}) => /*#__PURE__*/React.createElement('p', {
|
|
2832
|
-
className: className !== null && className !== void 0 ? className : 'form-description'
|
|
2833
|
-
}, children),
|
|
2834
|
-
FormMessage: ({
|
|
2835
|
-
className,
|
|
2836
|
-
name
|
|
2837
|
-
}) => /*#__PURE__*/React.createElement('p', {
|
|
2838
|
-
'className': className !== null && className !== void 0 ? className : 'form-message',
|
|
2839
|
-
'data-field': name
|
|
2840
|
-
}),
|
|
2841
2802
|
SubmitButton: ({
|
|
2842
2803
|
className,
|
|
2843
2804
|
children,
|
|
@@ -3032,10 +2993,6 @@ function getFieldComponent(type) {
|
|
|
3032
2993
|
}
|
|
3033
2994
|
return createDefaultFieldComponent(type);
|
|
3034
2995
|
}
|
|
3035
|
-
function getFieldOptions(type) {
|
|
3036
|
-
var _a;
|
|
3037
|
-
return (_a = fieldRegistry.get(type)) === null || _a === void 0 ? void 0 : _a.options;
|
|
3038
|
-
}
|
|
3039
2996
|
function getFieldValidator(type) {
|
|
3040
2997
|
var _a;
|
|
3041
2998
|
return (_a = fieldRegistry.get(type)) === null || _a === void 0 ? void 0 : _a.options.validator;
|
|
@@ -3081,37 +3038,6 @@ function getFormComponents() {
|
|
|
3081
3038
|
...componentRegistry
|
|
3082
3039
|
};
|
|
3083
3040
|
}
|
|
3084
|
-
function registerLayoutComponents(components, config = {}) {
|
|
3085
|
-
const {
|
|
3086
|
-
override = true
|
|
3087
|
-
} = config;
|
|
3088
|
-
Object.keys(components).forEach(key => {
|
|
3089
|
-
const exists = key in layoutRegistry;
|
|
3090
|
-
if (override === 'only' && !exists) return;
|
|
3091
|
-
if (override === false && exists) return;
|
|
3092
|
-
layoutRegistry[key] = components[key];
|
|
3093
|
-
});
|
|
3094
|
-
}
|
|
3095
|
-
function registerLayoutComponent(name, component, config = {}) {
|
|
3096
|
-
const {
|
|
3097
|
-
override = true
|
|
3098
|
-
} = config;
|
|
3099
|
-
const exists = name in layoutRegistry;
|
|
3100
|
-
if (override === 'only' && !exists) return;
|
|
3101
|
-
if (override === false && exists) return;
|
|
3102
|
-
layoutRegistry[name] = component;
|
|
3103
|
-
}
|
|
3104
|
-
function getLayoutComponent(name) {
|
|
3105
|
-
return layoutRegistry[name];
|
|
3106
|
-
}
|
|
3107
|
-
function hasLayoutComponent(name) {
|
|
3108
|
-
return name in layoutRegistry;
|
|
3109
|
-
}
|
|
3110
|
-
function clearLayoutRegistry() {
|
|
3111
|
-
Object.keys(layoutRegistry).forEach(key => {
|
|
3112
|
-
delete layoutRegistry[key];
|
|
3113
|
-
});
|
|
3114
|
-
}
|
|
3115
3041
|
function clearFieldRegistry() {
|
|
3116
3042
|
fieldRegistry.clear();
|
|
3117
3043
|
}
|
|
@@ -3127,106 +3053,6 @@ function resetFormComponentRegistry() {
|
|
|
3127
3053
|
function clearAllRegistries() {
|
|
3128
3054
|
clearFieldRegistry();
|
|
3129
3055
|
clearFormComponentRegistry();
|
|
3130
|
-
clearLayoutRegistry();
|
|
3131
|
-
}
|
|
3132
|
-
|
|
3133
|
-
const RESERVED_PROPS = new Set(['all', 'remaining', 'names', 'has', 'render']);
|
|
3134
|
-
function createTemplateFields(fieldEntries) {
|
|
3135
|
-
const accessedFields = new Set();
|
|
3136
|
-
const handler = {
|
|
3137
|
-
get(_, prop) {
|
|
3138
|
-
if (typeof prop === 'symbol') {
|
|
3139
|
-
return undefined;
|
|
3140
|
-
}
|
|
3141
|
-
if (prop === 'all') {
|
|
3142
|
-
return Array.from(fieldEntries.values()).map(entry => entry.element);
|
|
3143
|
-
}
|
|
3144
|
-
if (prop === 'remaining') {
|
|
3145
|
-
return Array.from(fieldEntries.entries()).filter(([name]) => !accessedFields.has(name)).map(([, entry]) => entry.element);
|
|
3146
|
-
}
|
|
3147
|
-
if (prop === 'names') {
|
|
3148
|
-
return Array.from(fieldEntries.keys());
|
|
3149
|
-
}
|
|
3150
|
-
if (prop === 'has') {
|
|
3151
|
-
return name => fieldEntries.has(name);
|
|
3152
|
-
}
|
|
3153
|
-
if (prop === 'render') {
|
|
3154
|
-
return (...names) => {
|
|
3155
|
-
return names.filter(name => fieldEntries.has(name)).map(name => {
|
|
3156
|
-
accessedFields.add(name);
|
|
3157
|
-
return fieldEntries.get(name).element;
|
|
3158
|
-
});
|
|
3159
|
-
};
|
|
3160
|
-
}
|
|
3161
|
-
if (fieldEntries.has(prop)) {
|
|
3162
|
-
accessedFields.add(prop);
|
|
3163
|
-
return fieldEntries.get(prop).element;
|
|
3164
|
-
}
|
|
3165
|
-
return undefined;
|
|
3166
|
-
},
|
|
3167
|
-
has(_, prop) {
|
|
3168
|
-
if (typeof prop === 'symbol') {
|
|
3169
|
-
return false;
|
|
3170
|
-
}
|
|
3171
|
-
return RESERVED_PROPS.has(prop) || fieldEntries.has(prop);
|
|
3172
|
-
},
|
|
3173
|
-
ownKeys() {
|
|
3174
|
-
return [...RESERVED_PROPS, ...fieldEntries.keys()];
|
|
3175
|
-
},
|
|
3176
|
-
getOwnPropertyDescriptor(_, prop) {
|
|
3177
|
-
if (typeof prop === 'symbol') {
|
|
3178
|
-
return undefined;
|
|
3179
|
-
}
|
|
3180
|
-
if (RESERVED_PROPS.has(prop) || fieldEntries.has(prop)) {
|
|
3181
|
-
return {
|
|
3182
|
-
configurable: true,
|
|
3183
|
-
enumerable: true,
|
|
3184
|
-
value: this.get(_, prop, {})
|
|
3185
|
-
};
|
|
3186
|
-
}
|
|
3187
|
-
return undefined;
|
|
3188
|
-
}
|
|
3189
|
-
};
|
|
3190
|
-
return new Proxy({}, handler);
|
|
3191
|
-
}
|
|
3192
|
-
function createTemplateLayouts(layoutEntries) {
|
|
3193
|
-
const handler = {
|
|
3194
|
-
get(_, prop) {
|
|
3195
|
-
if (typeof prop === 'symbol') {
|
|
3196
|
-
return undefined;
|
|
3197
|
-
}
|
|
3198
|
-
if (prop === 'all') {
|
|
3199
|
-
return Array.from(layoutEntries.values()).map(entry => entry.element);
|
|
3200
|
-
}
|
|
3201
|
-
if (layoutEntries.has(prop)) {
|
|
3202
|
-
return layoutEntries.get(prop).element;
|
|
3203
|
-
}
|
|
3204
|
-
return undefined;
|
|
3205
|
-
},
|
|
3206
|
-
has(_, prop) {
|
|
3207
|
-
if (typeof prop === 'symbol') {
|
|
3208
|
-
return false;
|
|
3209
|
-
}
|
|
3210
|
-
return prop === 'all' || layoutEntries.has(prop);
|
|
3211
|
-
},
|
|
3212
|
-
ownKeys() {
|
|
3213
|
-
return ['all', ...layoutEntries.keys()];
|
|
3214
|
-
},
|
|
3215
|
-
getOwnPropertyDescriptor(_, prop) {
|
|
3216
|
-
if (typeof prop === 'symbol') {
|
|
3217
|
-
return undefined;
|
|
3218
|
-
}
|
|
3219
|
-
if (prop === 'all' || layoutEntries.has(prop)) {
|
|
3220
|
-
return {
|
|
3221
|
-
configurable: true,
|
|
3222
|
-
enumerable: true,
|
|
3223
|
-
value: this.get(_, prop, {})
|
|
3224
|
-
};
|
|
3225
|
-
}
|
|
3226
|
-
return undefined;
|
|
3227
|
-
}
|
|
3228
|
-
};
|
|
3229
|
-
return new Proxy({}, handler);
|
|
3230
3056
|
}
|
|
3231
3057
|
|
|
3232
3058
|
const FieldRenderer = /*#__PURE__*/React.memo(t0 => {
|
|
@@ -3239,6 +3065,10 @@ const FieldRenderer = /*#__PURE__*/React.memo(t0 => {
|
|
|
3239
3065
|
if (field.hidden) {
|
|
3240
3066
|
return null;
|
|
3241
3067
|
}
|
|
3068
|
+
if (!field.name) {
|
|
3069
|
+
console.error(`Field is missing required "name" property. Field type: "${field.type}". ` + "Every field must have a unique name for form state management.");
|
|
3070
|
+
return null;
|
|
3071
|
+
}
|
|
3242
3072
|
let t1;
|
|
3243
3073
|
let t2;
|
|
3244
3074
|
if ($[0] !== field || $[1] !== form || $[2] !== namePrefix) {
|
|
@@ -3250,18 +3080,6 @@ const FieldRenderer = /*#__PURE__*/React.memo(t0 => {
|
|
|
3250
3080
|
t2 = null;
|
|
3251
3081
|
break bb0;
|
|
3252
3082
|
}
|
|
3253
|
-
const FormItemComponent = getFormComponent("FormItem");
|
|
3254
|
-
const FormLabelComponent = getFormComponent("FormLabel");
|
|
3255
|
-
const FormInputLabelWrapper = getFormComponent("FormInputLabelWrapper");
|
|
3256
|
-
const FormDescriptionComponent = getFormComponent("FormDescription");
|
|
3257
|
-
const FormMessageComponent = getFormComponent("FormMessage");
|
|
3258
|
-
if (!FormItemComponent) {
|
|
3259
|
-
console.warn("FormItem component not registered. Use registerFormComponent(\"FormItem\", Component) to register one.");
|
|
3260
|
-
t2 = null;
|
|
3261
|
-
break bb0;
|
|
3262
|
-
}
|
|
3263
|
-
const fieldOptions = getFieldOptions(field.type);
|
|
3264
|
-
const itemClassName = [`form-field-${field.type}`, fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.className, field.className].filter(Boolean).join(" ");
|
|
3265
3083
|
const fieldName = namePrefix ? `${namePrefix}.${field.name}` : field.name;
|
|
3266
3084
|
t1 = jsxRuntime.jsx(Controller, {
|
|
3267
3085
|
control: form.control,
|
|
@@ -3271,36 +3089,18 @@ const FieldRenderer = /*#__PURE__*/React.memo(t0 => {
|
|
|
3271
3089
|
field: formField,
|
|
3272
3090
|
fieldState
|
|
3273
3091
|
} = t3;
|
|
3274
|
-
return jsxRuntime.
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
orientation: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.inputLabelWrapperOrientation,
|
|
3278
|
-
className: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.inputLabelWrapper,
|
|
3279
|
-
children: [field.label && FormLabelComponent && jsxRuntime.jsx(FormLabelComponent, {
|
|
3280
|
-
className: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.labelClassName,
|
|
3281
|
-
required: field.required,
|
|
3282
|
-
htmlFor: fieldName,
|
|
3283
|
-
children: field.label
|
|
3284
|
-
}), jsxRuntime.jsx(FieldComponent, {
|
|
3285
|
-
field: {
|
|
3286
|
-
...field,
|
|
3287
|
-
name: fieldName
|
|
3288
|
-
},
|
|
3289
|
-
formField,
|
|
3290
|
-
fieldState: {
|
|
3291
|
-
invalid: fieldState.invalid,
|
|
3292
|
-
error: fieldState.error,
|
|
3293
|
-
isDirty: fieldState.isDirty,
|
|
3294
|
-
isTouched: fieldState.isTouched
|
|
3295
|
-
}
|
|
3296
|
-
})]
|
|
3297
|
-
}), field.description && FormDescriptionComponent && jsxRuntime.jsx(FormDescriptionComponent, {
|
|
3298
|
-
className: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.descriptionClassName,
|
|
3299
|
-
children: field.description
|
|
3300
|
-
}), FormMessageComponent && jsxRuntime.jsx(FormMessageComponent, {
|
|
3301
|
-
className: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.messageClassName,
|
|
3092
|
+
return jsxRuntime.jsx(FieldComponent, {
|
|
3093
|
+
field: {
|
|
3094
|
+
...field,
|
|
3302
3095
|
name: fieldName
|
|
3303
|
-
}
|
|
3096
|
+
},
|
|
3097
|
+
formField,
|
|
3098
|
+
fieldState: {
|
|
3099
|
+
invalid: fieldState.invalid,
|
|
3100
|
+
error: fieldState.error,
|
|
3101
|
+
isDirty: fieldState.isDirty,
|
|
3102
|
+
isTouched: fieldState.isTouched
|
|
3103
|
+
}
|
|
3304
3104
|
});
|
|
3305
3105
|
}
|
|
3306
3106
|
});
|
|
@@ -3320,134 +3120,267 @@ const FieldRenderer = /*#__PURE__*/React.memo(t0 => {
|
|
|
3320
3120
|
return t1;
|
|
3321
3121
|
});
|
|
3322
3122
|
FieldRenderer.displayName = 'FieldRenderer';
|
|
3323
|
-
|
|
3324
|
-
|
|
3123
|
+
|
|
3124
|
+
function useArrayField(field) {
|
|
3325
3125
|
const {
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3126
|
+
control
|
|
3127
|
+
} = useFormContext();
|
|
3128
|
+
const fieldArray = useFieldArray({
|
|
3129
|
+
control,
|
|
3130
|
+
name: field.name
|
|
3131
|
+
});
|
|
3132
|
+
const {
|
|
3133
|
+
fields: items,
|
|
3134
|
+
append,
|
|
3135
|
+
prepend,
|
|
3136
|
+
remove,
|
|
3137
|
+
move,
|
|
3138
|
+
swap,
|
|
3139
|
+
insert
|
|
3140
|
+
} = fieldArray;
|
|
3141
|
+
const buildEmptyItem = React.useCallback(() => {
|
|
3142
|
+
const item = {};
|
|
3143
|
+
field.fields.forEach(f => {
|
|
3144
|
+
var _a;
|
|
3145
|
+
item[f.name] = (_a = f.defaultValue) !== null && _a !== void 0 ? _a : '';
|
|
3146
|
+
});
|
|
3147
|
+
return item;
|
|
3148
|
+
}, [field.fields]);
|
|
3149
|
+
const handleAppend = React.useCallback(() => {
|
|
3150
|
+
append(buildEmptyItem());
|
|
3151
|
+
}, [append, buildEmptyItem]);
|
|
3152
|
+
const handleAppendWith = React.useCallback(values => {
|
|
3153
|
+
append(values);
|
|
3154
|
+
}, [append]);
|
|
3155
|
+
const handlePrepend = React.useCallback(() => {
|
|
3156
|
+
prepend(buildEmptyItem());
|
|
3157
|
+
}, [prepend, buildEmptyItem]);
|
|
3158
|
+
const handleInsert = React.useCallback((index, values_0) => {
|
|
3159
|
+
insert(index, values_0 !== null && values_0 !== void 0 ? values_0 : buildEmptyItem());
|
|
3160
|
+
}, [insert, buildEmptyItem]);
|
|
3161
|
+
const canAppend = field.maxItems === undefined || items.length < field.maxItems;
|
|
3162
|
+
const canRemove = field.minItems === undefined || items.length > field.minItems;
|
|
3163
|
+
const renderField = React.useCallback((index_0, fieldName) => {
|
|
3164
|
+
const childField = field.fields.find(f_0 => f_0.name === fieldName);
|
|
3165
|
+
if (!childField) {
|
|
3166
|
+
console.warn(`Field "${fieldName}" not found in array field "${field.name}"`);
|
|
3167
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
3357
3168
|
}
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
}
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
});
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3169
|
+
return jsxRuntime.jsx(FieldRenderer, {
|
|
3170
|
+
field: childField,
|
|
3171
|
+
namePrefix: `${field.name}.${index_0}`
|
|
3172
|
+
}, `${field.name}.${index_0}.${fieldName}`);
|
|
3173
|
+
}, [field]);
|
|
3174
|
+
const renderItem = React.useCallback(index_1 => {
|
|
3175
|
+
const result = {};
|
|
3176
|
+
field.fields.forEach(childField_0 => {
|
|
3177
|
+
result[childField_0.name] = jsxRuntime.jsx(FieldRenderer, {
|
|
3178
|
+
field: childField_0,
|
|
3179
|
+
namePrefix: `${field.name}.${index_1}`
|
|
3180
|
+
}, `${field.name}.${index_1}.${childField_0.name}`);
|
|
3181
|
+
});
|
|
3182
|
+
return result;
|
|
3183
|
+
}, [field]);
|
|
3184
|
+
return {
|
|
3185
|
+
fieldArray,
|
|
3186
|
+
append: handleAppend,
|
|
3187
|
+
appendWith: handleAppendWith,
|
|
3188
|
+
prepend: handlePrepend,
|
|
3189
|
+
remove,
|
|
3190
|
+
move,
|
|
3191
|
+
swap,
|
|
3192
|
+
insert: handleInsert,
|
|
3193
|
+
field,
|
|
3194
|
+
items: items.map((item_0, index_2) => ({
|
|
3195
|
+
id: item_0.id,
|
|
3196
|
+
index: index_2
|
|
3197
|
+
})),
|
|
3198
|
+
canAppend,
|
|
3199
|
+
canRemove,
|
|
3200
|
+
renderField,
|
|
3201
|
+
renderItem
|
|
3202
|
+
};
|
|
3203
|
+
}
|
|
3204
|
+
const ArrayFieldRenderer = /*#__PURE__*/React.memo(t0 => {
|
|
3205
|
+
const $ = compilerRuntime.c(28);
|
|
3374
3206
|
const {
|
|
3375
|
-
|
|
3376
|
-
|
|
3207
|
+
field,
|
|
3208
|
+
children
|
|
3377
3209
|
} = t0;
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3210
|
+
const {
|
|
3211
|
+
items,
|
|
3212
|
+
append,
|
|
3213
|
+
remove,
|
|
3214
|
+
move,
|
|
3215
|
+
canAppend,
|
|
3216
|
+
renderItem,
|
|
3217
|
+
field: arrayField
|
|
3218
|
+
} = useArrayField(field);
|
|
3219
|
+
if (field.hidden) {
|
|
3220
|
+
return null;
|
|
3221
|
+
}
|
|
3222
|
+
if (!children) {
|
|
3223
|
+
let t1;
|
|
3224
|
+
if ($[0] !== append || $[1] !== canAppend || $[2] !== field.className || $[3] !== field.description || $[4] !== field.label || $[5] !== items || $[6] !== renderItem) {
|
|
3225
|
+
let t2;
|
|
3226
|
+
if ($[8] !== renderItem) {
|
|
3227
|
+
t2 = t3 => {
|
|
3228
|
+
const {
|
|
3229
|
+
id,
|
|
3230
|
+
index
|
|
3231
|
+
} = t3;
|
|
3232
|
+
return jsxRuntime.jsx("div", {
|
|
3233
|
+
"data-array-item-index": index,
|
|
3234
|
+
children: Object.values(renderItem(index))
|
|
3235
|
+
}, id);
|
|
3236
|
+
};
|
|
3237
|
+
$[8] = renderItem;
|
|
3238
|
+
$[9] = t2;
|
|
3398
3239
|
} else {
|
|
3399
|
-
|
|
3240
|
+
t2 = $[9];
|
|
3400
3241
|
}
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3242
|
+
t1 = jsxRuntime.jsxs("div", {
|
|
3243
|
+
className: field.className,
|
|
3244
|
+
children: [field.label && jsxRuntime.jsx("label", {
|
|
3245
|
+
children: field.label
|
|
3246
|
+
}), field.description && jsxRuntime.jsx("p", {
|
|
3247
|
+
children: field.description
|
|
3248
|
+
}), items.map(t2), canAppend && jsxRuntime.jsx("button", {
|
|
3249
|
+
type: "button",
|
|
3250
|
+
onClick: append,
|
|
3251
|
+
children: "Add Item"
|
|
3252
|
+
})]
|
|
3405
3253
|
});
|
|
3254
|
+
$[0] = append;
|
|
3255
|
+
$[1] = canAppend;
|
|
3256
|
+
$[2] = field.className;
|
|
3257
|
+
$[3] = field.description;
|
|
3258
|
+
$[4] = field.label;
|
|
3259
|
+
$[5] = items;
|
|
3260
|
+
$[6] = renderItem;
|
|
3261
|
+
$[7] = t1;
|
|
3262
|
+
} else {
|
|
3263
|
+
t1 = $[7];
|
|
3406
3264
|
}
|
|
3407
|
-
|
|
3408
|
-
$[1] = namePrefix;
|
|
3409
|
-
$[2] = t1;
|
|
3410
|
-
$[3] = t2;
|
|
3411
|
-
} else {
|
|
3412
|
-
t1 = $[2];
|
|
3413
|
-
t2 = $[3];
|
|
3265
|
+
return t1;
|
|
3414
3266
|
}
|
|
3415
|
-
|
|
3416
|
-
|
|
3267
|
+
let t1;
|
|
3268
|
+
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) {
|
|
3269
|
+
let t2;
|
|
3270
|
+
if ($[21] !== arrayField || $[22] !== children || $[23] !== field.name || $[24] !== move || $[25] !== remove || $[26] !== renderItem) {
|
|
3271
|
+
t2 = t3 => {
|
|
3272
|
+
const {
|
|
3273
|
+
id: id_0,
|
|
3274
|
+
index: index_0
|
|
3275
|
+
} = t3;
|
|
3276
|
+
return children({
|
|
3277
|
+
index: index_0,
|
|
3278
|
+
id: id_0,
|
|
3279
|
+
remove: () => remove(index_0),
|
|
3280
|
+
move: toIndex => move(index_0, toIndex),
|
|
3281
|
+
fields: renderItem(index_0),
|
|
3282
|
+
fieldNames: arrayField.fields.map(_temp),
|
|
3283
|
+
namePrefix: `${field.name}.${index_0}`
|
|
3284
|
+
});
|
|
3285
|
+
};
|
|
3286
|
+
$[21] = arrayField;
|
|
3287
|
+
$[22] = children;
|
|
3288
|
+
$[23] = field.name;
|
|
3289
|
+
$[24] = move;
|
|
3290
|
+
$[25] = remove;
|
|
3291
|
+
$[26] = renderItem;
|
|
3292
|
+
$[27] = t2;
|
|
3293
|
+
} else {
|
|
3294
|
+
t2 = $[27];
|
|
3295
|
+
}
|
|
3296
|
+
t1 = jsxRuntime.jsxs("div", {
|
|
3297
|
+
className: field.className,
|
|
3298
|
+
children: [field.label && jsxRuntime.jsx("label", {
|
|
3299
|
+
children: field.label
|
|
3300
|
+
}), field.description && jsxRuntime.jsx("p", {
|
|
3301
|
+
children: field.description
|
|
3302
|
+
}), items.map(t2)]
|
|
3303
|
+
});
|
|
3304
|
+
$[10] = arrayField;
|
|
3305
|
+
$[11] = children;
|
|
3306
|
+
$[12] = field.className;
|
|
3307
|
+
$[13] = field.description;
|
|
3308
|
+
$[14] = field.label;
|
|
3309
|
+
$[15] = field.name;
|
|
3310
|
+
$[16] = items;
|
|
3311
|
+
$[17] = move;
|
|
3312
|
+
$[18] = remove;
|
|
3313
|
+
$[19] = renderItem;
|
|
3314
|
+
$[20] = t1;
|
|
3315
|
+
} else {
|
|
3316
|
+
t1 = $[20];
|
|
3417
3317
|
}
|
|
3418
3318
|
return t1;
|
|
3419
3319
|
});
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
return
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3320
|
+
ArrayFieldRenderer.displayName = 'ArrayFieldRenderer';
|
|
3321
|
+
function _temp(f) {
|
|
3322
|
+
return f.name;
|
|
3323
|
+
}
|
|
3324
|
+
|
|
3325
|
+
const RESERVED_PROPS = new Set(['all', 'remaining', 'names', 'has', 'render']);
|
|
3326
|
+
function createTemplateFields(fieldEntries) {
|
|
3327
|
+
const accessedFields = new Set();
|
|
3328
|
+
const handler = {
|
|
3329
|
+
get(_, prop) {
|
|
3330
|
+
if (typeof prop === 'symbol') {
|
|
3331
|
+
return undefined;
|
|
3332
|
+
}
|
|
3333
|
+
if (prop === 'all') {
|
|
3334
|
+
return Array.from(fieldEntries.values()).map(entry => entry.element);
|
|
3335
|
+
}
|
|
3336
|
+
if (prop === 'remaining') {
|
|
3337
|
+
return Array.from(fieldEntries.entries()).filter(([name]) => !accessedFields.has(name)).map(([, entry]) => entry.element);
|
|
3338
|
+
}
|
|
3339
|
+
if (prop === 'names') {
|
|
3340
|
+
return Array.from(fieldEntries.keys());
|
|
3341
|
+
}
|
|
3342
|
+
if (prop === 'has') {
|
|
3343
|
+
return name => fieldEntries.has(name);
|
|
3344
|
+
}
|
|
3345
|
+
if (prop === 'render') {
|
|
3346
|
+
return (...names) => {
|
|
3347
|
+
return names.filter(name => fieldEntries.has(name)).map(name => {
|
|
3348
|
+
accessedFields.add(name);
|
|
3349
|
+
return fieldEntries.get(name).element;
|
|
3350
|
+
});
|
|
3351
|
+
};
|
|
3352
|
+
}
|
|
3353
|
+
if (fieldEntries.has(prop)) {
|
|
3354
|
+
accessedFields.add(prop);
|
|
3355
|
+
return fieldEntries.get(prop).element;
|
|
3356
|
+
}
|
|
3357
|
+
return undefined;
|
|
3358
|
+
},
|
|
3359
|
+
has(_, prop) {
|
|
3360
|
+
if (typeof prop === 'symbol') {
|
|
3361
|
+
return false;
|
|
3362
|
+
}
|
|
3363
|
+
return RESERVED_PROPS.has(prop) || fieldEntries.has(prop);
|
|
3364
|
+
},
|
|
3365
|
+
ownKeys() {
|
|
3366
|
+
return [...RESERVED_PROPS, ...fieldEntries.keys()];
|
|
3367
|
+
},
|
|
3368
|
+
getOwnPropertyDescriptor(_, prop) {
|
|
3369
|
+
if (typeof prop === 'symbol') {
|
|
3370
|
+
return undefined;
|
|
3371
|
+
}
|
|
3372
|
+
if (RESERVED_PROPS.has(prop) || fieldEntries.has(prop)) {
|
|
3373
|
+
return {
|
|
3374
|
+
configurable: true,
|
|
3375
|
+
enumerable: true,
|
|
3376
|
+
value: this.get(_, prop, {})
|
|
3377
|
+
};
|
|
3378
|
+
}
|
|
3379
|
+
return undefined;
|
|
3443
3380
|
}
|
|
3444
|
-
}
|
|
3445
|
-
return
|
|
3446
|
-
|
|
3447
|
-
namePrefix: namePrefix
|
|
3448
|
-
});
|
|
3449
|
-
});
|
|
3450
|
-
FormItemRenderer.displayName = 'FormItemRenderer';
|
|
3381
|
+
};
|
|
3382
|
+
return new Proxy({}, handler);
|
|
3383
|
+
}
|
|
3451
3384
|
|
|
3452
3385
|
function deepMerge(target, source) {
|
|
3453
3386
|
const result = {
|
|
@@ -3503,96 +3436,61 @@ function getValidatorForField(field) {
|
|
|
3503
3436
|
}
|
|
3504
3437
|
return zod.z.any();
|
|
3505
3438
|
}
|
|
3506
|
-
function
|
|
3439
|
+
function buildArrayItemSchema(arrayField) {
|
|
3440
|
+
const itemShape = {};
|
|
3441
|
+
for (const field of arrayField.fields) {
|
|
3442
|
+
const validator = getValidatorForField(field);
|
|
3443
|
+
itemShape[field.name] = field.required ? validator : validator.optional();
|
|
3444
|
+
}
|
|
3445
|
+
return zod.z.object(itemShape);
|
|
3446
|
+
}
|
|
3447
|
+
function buildSchema(fields) {
|
|
3507
3448
|
const shape = {};
|
|
3508
|
-
for (const
|
|
3509
|
-
if (
|
|
3510
|
-
let
|
|
3511
|
-
if (
|
|
3512
|
-
|
|
3513
|
-
childItems.push(...column.children);
|
|
3514
|
-
}
|
|
3515
|
-
} else if (item.type === 'section') {
|
|
3516
|
-
childItems = item.children;
|
|
3449
|
+
for (const field of fields) {
|
|
3450
|
+
if (isArrayField(field)) {
|
|
3451
|
+
let arraySchema = zod.z.array(buildArrayItemSchema(field));
|
|
3452
|
+
if (field.minItems !== undefined) {
|
|
3453
|
+
arraySchema = arraySchema.min(field.minItems);
|
|
3517
3454
|
}
|
|
3518
|
-
if (
|
|
3519
|
-
|
|
3520
|
-
} else {
|
|
3521
|
-
const childSchema = buildSchema(childItems);
|
|
3522
|
-
if (childSchema instanceof zod.z.ZodObject) {
|
|
3523
|
-
Object.assign(shape, childSchema.shape);
|
|
3524
|
-
}
|
|
3455
|
+
if (field.maxItems !== undefined) {
|
|
3456
|
+
arraySchema = arraySchema.max(field.maxItems);
|
|
3525
3457
|
}
|
|
3458
|
+
shape[field.name] = arraySchema;
|
|
3526
3459
|
} else {
|
|
3527
|
-
const field = item;
|
|
3528
3460
|
const validator = getValidatorForField(field);
|
|
3529
3461
|
shape[field.name] = field.required ? validator : validator.optional();
|
|
3530
3462
|
}
|
|
3531
3463
|
}
|
|
3532
3464
|
return zod.z.object(shape);
|
|
3533
3465
|
}
|
|
3534
|
-
function
|
|
3466
|
+
function buildArrayItemDefaults(arrayField) {
|
|
3467
|
+
var _a;
|
|
3468
|
+
const item = {};
|
|
3469
|
+
for (const field of arrayField.fields) {
|
|
3470
|
+
item[field.name] = (_a = field.defaultValue) !== null && _a !== void 0 ? _a : '';
|
|
3471
|
+
}
|
|
3472
|
+
return item;
|
|
3473
|
+
}
|
|
3474
|
+
function buildDefaultValues(fields) {
|
|
3535
3475
|
var _a;
|
|
3536
3476
|
const values = {};
|
|
3537
|
-
for (const
|
|
3538
|
-
if (
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
childItems = item.children;
|
|
3546
|
-
}
|
|
3547
|
-
if (item.wrapFieldNames && item.name) {
|
|
3548
|
-
values[item.name] = buildDefaultValues(childItems);
|
|
3477
|
+
for (const field of fields) {
|
|
3478
|
+
if (isArrayField(field)) {
|
|
3479
|
+
if (field.defaultValue && field.defaultValue.length > 0) {
|
|
3480
|
+
values[field.name] = field.defaultValue;
|
|
3481
|
+
} else if (field.minItems && field.minItems > 0) {
|
|
3482
|
+
values[field.name] = Array.from({
|
|
3483
|
+
length: field.minItems
|
|
3484
|
+
}, () => buildArrayItemDefaults(field));
|
|
3549
3485
|
} else {
|
|
3550
|
-
|
|
3486
|
+
values[field.name] = [];
|
|
3551
3487
|
}
|
|
3552
3488
|
} else {
|
|
3553
|
-
const field = item;
|
|
3554
3489
|
values[field.name] = (_a = field.defaultValue) !== null && _a !== void 0 ? _a : '';
|
|
3555
3490
|
}
|
|
3556
3491
|
}
|
|
3557
3492
|
return values;
|
|
3558
3493
|
}
|
|
3559
|
-
function getItemKey(item, index) {
|
|
3560
|
-
if (isLayoutBlock(item)) {
|
|
3561
|
-
return `layout-${item.type}-${index}`;
|
|
3562
|
-
}
|
|
3563
|
-
return item.name;
|
|
3564
|
-
}
|
|
3565
|
-
function extractFields(items) {
|
|
3566
|
-
const fields = [];
|
|
3567
|
-
for (const item of items) {
|
|
3568
|
-
if (isLayoutBlock(item)) {
|
|
3569
|
-
let childItems = [];
|
|
3570
|
-
if (item.type === 'columns') {
|
|
3571
|
-
for (const column of item.columns) {
|
|
3572
|
-
childItems.push(...column.children);
|
|
3573
|
-
}
|
|
3574
|
-
} else if (item.type === 'section') {
|
|
3575
|
-
childItems = item.children;
|
|
3576
|
-
}
|
|
3577
|
-
fields.push(...extractFields(childItems));
|
|
3578
|
-
} else {
|
|
3579
|
-
fields.push(item);
|
|
3580
|
-
}
|
|
3581
|
-
}
|
|
3582
|
-
return fields;
|
|
3583
|
-
}
|
|
3584
|
-
function extractLayouts(items) {
|
|
3585
|
-
const layouts = [];
|
|
3586
|
-
items.forEach((item, index) => {
|
|
3587
|
-
if (isLayoutBlock(item)) {
|
|
3588
|
-
layouts.push({
|
|
3589
|
-
layout: item,
|
|
3590
|
-
index
|
|
3591
|
-
});
|
|
3592
|
-
}
|
|
3593
|
-
});
|
|
3594
|
-
return layouts;
|
|
3595
|
-
}
|
|
3596
3494
|
|
|
3597
3495
|
function hasSchema(props) {
|
|
3598
3496
|
return props.schema !== undefined;
|
|
@@ -3663,47 +3561,41 @@ function FormGeneratorImpl(props) {
|
|
|
3663
3561
|
form: form
|
|
3664
3562
|
}), [form, handleSubmit, mergedDefaultValues]);
|
|
3665
3563
|
const SubmitButton = getFormComponent('SubmitButton');
|
|
3564
|
+
const {
|
|
3565
|
+
regularFields,
|
|
3566
|
+
arrayFields
|
|
3567
|
+
} = React.useMemo(() => {
|
|
3568
|
+
const regular = [];
|
|
3569
|
+
const arrays = [];
|
|
3570
|
+
fields.forEach(field => {
|
|
3571
|
+
if (isArrayField(field)) {
|
|
3572
|
+
arrays.push(field);
|
|
3573
|
+
} else {
|
|
3574
|
+
regular.push(field);
|
|
3575
|
+
}
|
|
3576
|
+
});
|
|
3577
|
+
return {
|
|
3578
|
+
regularFields: regular,
|
|
3579
|
+
arrayFields: arrays
|
|
3580
|
+
};
|
|
3581
|
+
}, [fields]);
|
|
3666
3582
|
const fieldEntries = React.useMemo(() => {
|
|
3667
3583
|
const entries = new Map();
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
if (!field.hidden) {
|
|
3584
|
+
regularFields.forEach((field_0, index) => {
|
|
3585
|
+
if (!field_0.hidden) {
|
|
3671
3586
|
const element = jsxRuntime.jsx(FieldRenderer, {
|
|
3672
|
-
field:
|
|
3673
|
-
},
|
|
3674
|
-
entries.set(
|
|
3675
|
-
field,
|
|
3587
|
+
field: field_0
|
|
3588
|
+
}, field_0.name || `field-${index}`);
|
|
3589
|
+
entries.set(field_0.name, {
|
|
3590
|
+
field: field_0,
|
|
3676
3591
|
element,
|
|
3677
3592
|
accessed: false
|
|
3678
3593
|
});
|
|
3679
3594
|
}
|
|
3680
3595
|
});
|
|
3681
3596
|
return entries;
|
|
3682
|
-
}, [
|
|
3683
|
-
const layoutEntries = React.useMemo(() => {
|
|
3684
|
-
const entries_0 = new Map();
|
|
3685
|
-
const allLayouts = extractLayouts(fields);
|
|
3686
|
-
allLayouts.forEach(({
|
|
3687
|
-
layout,
|
|
3688
|
-
index: index_0
|
|
3689
|
-
}) => {
|
|
3690
|
-
if (!layout.hidden) {
|
|
3691
|
-
const key_0 = layout.name || `layout-${layout.type}-${index_0}`;
|
|
3692
|
-
const element_0 = jsxRuntime.jsx(FormItemRenderer, {
|
|
3693
|
-
item: layout
|
|
3694
|
-
}, key_0);
|
|
3695
|
-
if (layout.name) {
|
|
3696
|
-
entries_0.set(layout.name, {
|
|
3697
|
-
layout,
|
|
3698
|
-
element: element_0
|
|
3699
|
-
});
|
|
3700
|
-
}
|
|
3701
|
-
}
|
|
3702
|
-
});
|
|
3703
|
-
return entries_0;
|
|
3704
|
-
}, [fields]);
|
|
3597
|
+
}, [regularFields]);
|
|
3705
3598
|
const templateFields = React.useMemo(() => createTemplateFields(fieldEntries), [fieldEntries]);
|
|
3706
|
-
const templateLayouts = React.useMemo(() => createTemplateLayouts(layoutEntries), [layoutEntries]);
|
|
3707
3599
|
const buttons = React.useMemo(() => {
|
|
3708
3600
|
const result = {
|
|
3709
3601
|
submit: jsxRuntime.jsx(SubmitButton, {
|
|
@@ -3722,18 +3614,12 @@ function FormGeneratorImpl(props) {
|
|
|
3722
3614
|
}
|
|
3723
3615
|
return result;
|
|
3724
3616
|
}, [SubmitButton, disabled, form.formState.isSubmitting, submitText, showReset, resetText, handleReset]);
|
|
3725
|
-
const renderField = React.useCallback((
|
|
3617
|
+
const renderField = React.useCallback((field_1, options) => {
|
|
3726
3618
|
return jsxRuntime.jsx(FieldRenderer, {
|
|
3727
|
-
field:
|
|
3619
|
+
field: field_1,
|
|
3728
3620
|
namePrefix: options === null || options === void 0 ? void 0 : options.namePrefix
|
|
3729
3621
|
});
|
|
3730
3622
|
}, []);
|
|
3731
|
-
const renderLayout = React.useCallback((layout_0, options_0) => {
|
|
3732
|
-
return jsxRuntime.jsx(FormItemRenderer, {
|
|
3733
|
-
item: layout_0,
|
|
3734
|
-
namePrefix: options_0 === null || options_0 === void 0 ? void 0 : options_0.namePrefix
|
|
3735
|
-
});
|
|
3736
|
-
}, []);
|
|
3737
3623
|
if (!children) {
|
|
3738
3624
|
return jsxRuntime.jsx(FormProvider, {
|
|
3739
3625
|
...form,
|
|
@@ -3741,9 +3627,11 @@ function FormGeneratorImpl(props) {
|
|
|
3741
3627
|
ref: formRef,
|
|
3742
3628
|
onSubmit: handleSubmit,
|
|
3743
3629
|
className: className,
|
|
3744
|
-
children: [
|
|
3745
|
-
|
|
3746
|
-
},
|
|
3630
|
+
children: [regularFields.map((field_2, index_0) => jsxRuntime.jsx(FieldRenderer, {
|
|
3631
|
+
field: field_2
|
|
3632
|
+
}, field_2.name || `field-${index_0}`)), arrayFields.map(arrayField => jsxRuntime.jsx(ArrayFieldRenderer, {
|
|
3633
|
+
field: arrayField
|
|
3634
|
+
}, arrayField.name)), jsxRuntime.jsx(SubmitButton, {
|
|
3747
3635
|
disabled: disabled || form.formState.isSubmitting,
|
|
3748
3636
|
isSubmitting: form.formState.isSubmitting,
|
|
3749
3637
|
children: submitText
|
|
@@ -3753,7 +3641,9 @@ function FormGeneratorImpl(props) {
|
|
|
3753
3641
|
}
|
|
3754
3642
|
const renderProps = {
|
|
3755
3643
|
fields: templateFields,
|
|
3756
|
-
|
|
3644
|
+
arrays: Object.fromEntries(arrayFields.map(arrayField_0 => [arrayField_0.name, {
|
|
3645
|
+
field: arrayField_0
|
|
3646
|
+
}])),
|
|
3757
3647
|
buttons,
|
|
3758
3648
|
title,
|
|
3759
3649
|
description,
|
|
@@ -3761,8 +3651,7 @@ function FormGeneratorImpl(props) {
|
|
|
3761
3651
|
isSubmitting: form.formState.isSubmitting,
|
|
3762
3652
|
isValid: form.formState.isValid,
|
|
3763
3653
|
isDirty: form.formState.isDirty,
|
|
3764
|
-
renderField
|
|
3765
|
-
renderLayout
|
|
3654
|
+
renderField
|
|
3766
3655
|
};
|
|
3767
3656
|
const renderFn = children;
|
|
3768
3657
|
return jsxRuntime.jsx(FormProvider, {
|
|
@@ -3783,6 +3672,7 @@ Object.defineProperty(exports, "z", {
|
|
|
3783
3672
|
enumerable: true,
|
|
3784
3673
|
get: function () { return zod.z; }
|
|
3785
3674
|
});
|
|
3675
|
+
exports.ArrayFieldRenderer = ArrayFieldRenderer;
|
|
3786
3676
|
exports.Controller = Controller;
|
|
3787
3677
|
exports.FieldRenderer = FieldRenderer;
|
|
3788
3678
|
exports.FormGenerator = FormGenerator;
|
|
@@ -3790,24 +3680,20 @@ exports.FormProvider = FormProvider;
|
|
|
3790
3680
|
exports.clearAllRegistries = clearAllRegistries;
|
|
3791
3681
|
exports.clearFieldRegistry = clearFieldRegistry;
|
|
3792
3682
|
exports.clearFormComponentRegistry = clearFormComponentRegistry;
|
|
3793
|
-
exports.clearLayoutRegistry = clearLayoutRegistry;
|
|
3794
3683
|
exports.getFieldComponent = getFieldComponent;
|
|
3795
3684
|
exports.getFormComponent = getFormComponent;
|
|
3796
3685
|
exports.getFormComponents = getFormComponents;
|
|
3797
|
-
exports.getLayoutComponent = getLayoutComponent;
|
|
3798
3686
|
exports.getRegisteredFieldTypes = getRegisteredFieldTypes;
|
|
3799
3687
|
exports.hasFieldType = hasFieldType;
|
|
3800
3688
|
exports.hasFormComponent = hasFormComponent;
|
|
3801
|
-
exports.
|
|
3802
|
-
exports.isLayoutBlock = isLayoutBlock;
|
|
3689
|
+
exports.isArrayField = isArrayField;
|
|
3803
3690
|
exports.registerField = registerField;
|
|
3804
3691
|
exports.registerFields = registerFields;
|
|
3805
3692
|
exports.registerFormComponent = registerFormComponent;
|
|
3806
3693
|
exports.registerFormComponents = registerFormComponents;
|
|
3807
|
-
exports.registerLayoutComponent = registerLayoutComponent;
|
|
3808
|
-
exports.registerLayoutComponents = registerLayoutComponents;
|
|
3809
3694
|
exports.resetFormComponentRegistry = resetFormComponentRegistry;
|
|
3810
3695
|
exports.unregisterField = unregisterField;
|
|
3696
|
+
exports.useArrayField = useArrayField;
|
|
3811
3697
|
exports.useFieldArray = useFieldArray;
|
|
3812
3698
|
exports.useForm = useForm;
|
|
3813
3699
|
exports.useFormContext = useFormContext;
|