@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.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 => {
|
|
@@ -3254,18 +3080,6 @@ const FieldRenderer = /*#__PURE__*/React.memo(t0 => {
|
|
|
3254
3080
|
t2 = null;
|
|
3255
3081
|
break bb0;
|
|
3256
3082
|
}
|
|
3257
|
-
const FormItemComponent = getFormComponent("FormItem");
|
|
3258
|
-
const FormLabelComponent = getFormComponent("FormLabel");
|
|
3259
|
-
const FormInputLabelWrapper = getFormComponent("FormInputLabelWrapper");
|
|
3260
|
-
const FormDescriptionComponent = getFormComponent("FormDescription");
|
|
3261
|
-
const FormMessageComponent = getFormComponent("FormMessage");
|
|
3262
|
-
if (!FormItemComponent) {
|
|
3263
|
-
console.warn("FormItem component not registered. Use registerFormComponent(\"FormItem\", Component) to register one.");
|
|
3264
|
-
t2 = null;
|
|
3265
|
-
break bb0;
|
|
3266
|
-
}
|
|
3267
|
-
const fieldOptions = getFieldOptions(field.type);
|
|
3268
|
-
const itemClassName = [`form-field-${field.type}`, fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.className, field.className].filter(Boolean).join(" ");
|
|
3269
3083
|
const fieldName = namePrefix ? `${namePrefix}.${field.name}` : field.name;
|
|
3270
3084
|
t1 = jsxRuntime.jsx(Controller, {
|
|
3271
3085
|
control: form.control,
|
|
@@ -3275,36 +3089,18 @@ const FieldRenderer = /*#__PURE__*/React.memo(t0 => {
|
|
|
3275
3089
|
field: formField,
|
|
3276
3090
|
fieldState
|
|
3277
3091
|
} = t3;
|
|
3278
|
-
return jsxRuntime.
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
orientation: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.inputLabelWrapperOrientation,
|
|
3282
|
-
className: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.inputLabelWrapper,
|
|
3283
|
-
children: [field.label && FormLabelComponent && jsxRuntime.jsx(FormLabelComponent, {
|
|
3284
|
-
className: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.labelClassName,
|
|
3285
|
-
required: field.required,
|
|
3286
|
-
htmlFor: fieldName,
|
|
3287
|
-
children: field.label
|
|
3288
|
-
}), jsxRuntime.jsx(FieldComponent, {
|
|
3289
|
-
field: {
|
|
3290
|
-
...field,
|
|
3291
|
-
name: fieldName
|
|
3292
|
-
},
|
|
3293
|
-
formField,
|
|
3294
|
-
fieldState: {
|
|
3295
|
-
invalid: fieldState.invalid,
|
|
3296
|
-
error: fieldState.error,
|
|
3297
|
-
isDirty: fieldState.isDirty,
|
|
3298
|
-
isTouched: fieldState.isTouched
|
|
3299
|
-
}
|
|
3300
|
-
})]
|
|
3301
|
-
}), field.description && FormDescriptionComponent && jsxRuntime.jsx(FormDescriptionComponent, {
|
|
3302
|
-
className: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.descriptionClassName,
|
|
3303
|
-
children: field.description
|
|
3304
|
-
}), FormMessageComponent && jsxRuntime.jsx(FormMessageComponent, {
|
|
3305
|
-
className: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.messageClassName,
|
|
3092
|
+
return jsxRuntime.jsx(FieldComponent, {
|
|
3093
|
+
field: {
|
|
3094
|
+
...field,
|
|
3306
3095
|
name: fieldName
|
|
3307
|
-
}
|
|
3096
|
+
},
|
|
3097
|
+
formField,
|
|
3098
|
+
fieldState: {
|
|
3099
|
+
invalid: fieldState.invalid,
|
|
3100
|
+
error: fieldState.error,
|
|
3101
|
+
isDirty: fieldState.isDirty,
|
|
3102
|
+
isTouched: fieldState.isTouched
|
|
3103
|
+
}
|
|
3308
3104
|
});
|
|
3309
3105
|
}
|
|
3310
3106
|
});
|
|
@@ -3324,134 +3120,267 @@ const FieldRenderer = /*#__PURE__*/React.memo(t0 => {
|
|
|
3324
3120
|
return t1;
|
|
3325
3121
|
});
|
|
3326
3122
|
FieldRenderer.displayName = 'FieldRenderer';
|
|
3327
|
-
|
|
3328
|
-
|
|
3123
|
+
|
|
3124
|
+
function useArrayField(field) {
|
|
3329
3125
|
const {
|
|
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
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
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, {});
|
|
3361
3168
|
}
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
}
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
});
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
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);
|
|
3378
3206
|
const {
|
|
3379
|
-
|
|
3380
|
-
|
|
3207
|
+
field,
|
|
3208
|
+
children
|
|
3381
3209
|
} = t0;
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
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;
|
|
3402
3239
|
} else {
|
|
3403
|
-
|
|
3240
|
+
t2 = $[9];
|
|
3404
3241
|
}
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
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
|
+
})]
|
|
3409
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];
|
|
3410
3264
|
}
|
|
3411
|
-
|
|
3412
|
-
$[1] = namePrefix;
|
|
3413
|
-
$[2] = t1;
|
|
3414
|
-
$[3] = t2;
|
|
3415
|
-
} else {
|
|
3416
|
-
t1 = $[2];
|
|
3417
|
-
t2 = $[3];
|
|
3265
|
+
return t1;
|
|
3418
3266
|
}
|
|
3419
|
-
|
|
3420
|
-
|
|
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];
|
|
3421
3317
|
}
|
|
3422
3318
|
return t1;
|
|
3423
3319
|
});
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
return
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
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;
|
|
3447
3380
|
}
|
|
3448
|
-
}
|
|
3449
|
-
return
|
|
3450
|
-
|
|
3451
|
-
namePrefix: namePrefix
|
|
3452
|
-
});
|
|
3453
|
-
});
|
|
3454
|
-
FormItemRenderer.displayName = 'FormItemRenderer';
|
|
3381
|
+
};
|
|
3382
|
+
return new Proxy({}, handler);
|
|
3383
|
+
}
|
|
3455
3384
|
|
|
3456
3385
|
function deepMerge(target, source) {
|
|
3457
3386
|
const result = {
|
|
@@ -3507,96 +3436,61 @@ function getValidatorForField(field) {
|
|
|
3507
3436
|
}
|
|
3508
3437
|
return zod.z.any();
|
|
3509
3438
|
}
|
|
3510
|
-
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) {
|
|
3511
3448
|
const shape = {};
|
|
3512
|
-
for (const
|
|
3513
|
-
if (
|
|
3514
|
-
let
|
|
3515
|
-
if (
|
|
3516
|
-
|
|
3517
|
-
childItems.push(...column.children);
|
|
3518
|
-
}
|
|
3519
|
-
} else if (item.type === 'section') {
|
|
3520
|
-
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);
|
|
3521
3454
|
}
|
|
3522
|
-
if (
|
|
3523
|
-
|
|
3524
|
-
} else {
|
|
3525
|
-
const childSchema = buildSchema(childItems);
|
|
3526
|
-
if (childSchema instanceof zod.z.ZodObject) {
|
|
3527
|
-
Object.assign(shape, childSchema.shape);
|
|
3528
|
-
}
|
|
3455
|
+
if (field.maxItems !== undefined) {
|
|
3456
|
+
arraySchema = arraySchema.max(field.maxItems);
|
|
3529
3457
|
}
|
|
3458
|
+
shape[field.name] = arraySchema;
|
|
3530
3459
|
} else {
|
|
3531
|
-
const field = item;
|
|
3532
3460
|
const validator = getValidatorForField(field);
|
|
3533
3461
|
shape[field.name] = field.required ? validator : validator.optional();
|
|
3534
3462
|
}
|
|
3535
3463
|
}
|
|
3536
3464
|
return zod.z.object(shape);
|
|
3537
3465
|
}
|
|
3538
|
-
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) {
|
|
3539
3475
|
var _a;
|
|
3540
3476
|
const values = {};
|
|
3541
|
-
for (const
|
|
3542
|
-
if (
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
childItems = item.children;
|
|
3550
|
-
}
|
|
3551
|
-
if (item.wrapFieldNames && item.name) {
|
|
3552
|
-
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));
|
|
3553
3485
|
} else {
|
|
3554
|
-
|
|
3486
|
+
values[field.name] = [];
|
|
3555
3487
|
}
|
|
3556
3488
|
} else {
|
|
3557
|
-
const field = item;
|
|
3558
3489
|
values[field.name] = (_a = field.defaultValue) !== null && _a !== void 0 ? _a : '';
|
|
3559
3490
|
}
|
|
3560
3491
|
}
|
|
3561
3492
|
return values;
|
|
3562
3493
|
}
|
|
3563
|
-
function getItemKey(item, index) {
|
|
3564
|
-
if (isLayoutBlock(item)) {
|
|
3565
|
-
return `layout-${item.type}-${index}`;
|
|
3566
|
-
}
|
|
3567
|
-
return item.name;
|
|
3568
|
-
}
|
|
3569
|
-
function extractFields(items) {
|
|
3570
|
-
const fields = [];
|
|
3571
|
-
for (const item of items) {
|
|
3572
|
-
if (isLayoutBlock(item)) {
|
|
3573
|
-
let childItems = [];
|
|
3574
|
-
if (item.type === 'columns') {
|
|
3575
|
-
for (const column of item.columns) {
|
|
3576
|
-
childItems.push(...column.children);
|
|
3577
|
-
}
|
|
3578
|
-
} else if (item.type === 'section') {
|
|
3579
|
-
childItems = item.children;
|
|
3580
|
-
}
|
|
3581
|
-
fields.push(...extractFields(childItems));
|
|
3582
|
-
} else {
|
|
3583
|
-
fields.push(item);
|
|
3584
|
-
}
|
|
3585
|
-
}
|
|
3586
|
-
return fields;
|
|
3587
|
-
}
|
|
3588
|
-
function extractLayouts(items) {
|
|
3589
|
-
const layouts = [];
|
|
3590
|
-
items.forEach((item, index) => {
|
|
3591
|
-
if (isLayoutBlock(item)) {
|
|
3592
|
-
layouts.push({
|
|
3593
|
-
layout: item,
|
|
3594
|
-
index
|
|
3595
|
-
});
|
|
3596
|
-
}
|
|
3597
|
-
});
|
|
3598
|
-
return layouts;
|
|
3599
|
-
}
|
|
3600
3494
|
|
|
3601
3495
|
function hasSchema(props) {
|
|
3602
3496
|
return props.schema !== undefined;
|
|
@@ -3667,47 +3561,41 @@ function FormGeneratorImpl(props) {
|
|
|
3667
3561
|
form: form
|
|
3668
3562
|
}), [form, handleSubmit, mergedDefaultValues]);
|
|
3669
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]);
|
|
3670
3582
|
const fieldEntries = React.useMemo(() => {
|
|
3671
3583
|
const entries = new Map();
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
if (!field.hidden) {
|
|
3584
|
+
regularFields.forEach((field_0, index) => {
|
|
3585
|
+
if (!field_0.hidden) {
|
|
3675
3586
|
const element = jsxRuntime.jsx(FieldRenderer, {
|
|
3676
|
-
field:
|
|
3677
|
-
},
|
|
3678
|
-
entries.set(
|
|
3679
|
-
field,
|
|
3587
|
+
field: field_0
|
|
3588
|
+
}, field_0.name || `field-${index}`);
|
|
3589
|
+
entries.set(field_0.name, {
|
|
3590
|
+
field: field_0,
|
|
3680
3591
|
element,
|
|
3681
3592
|
accessed: false
|
|
3682
3593
|
});
|
|
3683
3594
|
}
|
|
3684
3595
|
});
|
|
3685
3596
|
return entries;
|
|
3686
|
-
}, [
|
|
3687
|
-
const layoutEntries = React.useMemo(() => {
|
|
3688
|
-
const entries_0 = new Map();
|
|
3689
|
-
const allLayouts = extractLayouts(fields);
|
|
3690
|
-
allLayouts.forEach(({
|
|
3691
|
-
layout,
|
|
3692
|
-
index: index_0
|
|
3693
|
-
}) => {
|
|
3694
|
-
if (!layout.hidden) {
|
|
3695
|
-
const key_0 = layout.name || `layout-${layout.type}-${index_0}`;
|
|
3696
|
-
const element_0 = jsxRuntime.jsx(FormItemRenderer, {
|
|
3697
|
-
item: layout
|
|
3698
|
-
}, key_0);
|
|
3699
|
-
if (layout.name) {
|
|
3700
|
-
entries_0.set(layout.name, {
|
|
3701
|
-
layout,
|
|
3702
|
-
element: element_0
|
|
3703
|
-
});
|
|
3704
|
-
}
|
|
3705
|
-
}
|
|
3706
|
-
});
|
|
3707
|
-
return entries_0;
|
|
3708
|
-
}, [fields]);
|
|
3597
|
+
}, [regularFields]);
|
|
3709
3598
|
const templateFields = React.useMemo(() => createTemplateFields(fieldEntries), [fieldEntries]);
|
|
3710
|
-
const templateLayouts = React.useMemo(() => createTemplateLayouts(layoutEntries), [layoutEntries]);
|
|
3711
3599
|
const buttons = React.useMemo(() => {
|
|
3712
3600
|
const result = {
|
|
3713
3601
|
submit: jsxRuntime.jsx(SubmitButton, {
|
|
@@ -3726,18 +3614,12 @@ function FormGeneratorImpl(props) {
|
|
|
3726
3614
|
}
|
|
3727
3615
|
return result;
|
|
3728
3616
|
}, [SubmitButton, disabled, form.formState.isSubmitting, submitText, showReset, resetText, handleReset]);
|
|
3729
|
-
const renderField = React.useCallback((
|
|
3617
|
+
const renderField = React.useCallback((field_1, options) => {
|
|
3730
3618
|
return jsxRuntime.jsx(FieldRenderer, {
|
|
3731
|
-
field:
|
|
3619
|
+
field: field_1,
|
|
3732
3620
|
namePrefix: options === null || options === void 0 ? void 0 : options.namePrefix
|
|
3733
3621
|
});
|
|
3734
3622
|
}, []);
|
|
3735
|
-
const renderLayout = React.useCallback((layout_0, options_0) => {
|
|
3736
|
-
return jsxRuntime.jsx(FormItemRenderer, {
|
|
3737
|
-
item: layout_0,
|
|
3738
|
-
namePrefix: options_0 === null || options_0 === void 0 ? void 0 : options_0.namePrefix
|
|
3739
|
-
});
|
|
3740
|
-
}, []);
|
|
3741
3623
|
if (!children) {
|
|
3742
3624
|
return jsxRuntime.jsx(FormProvider, {
|
|
3743
3625
|
...form,
|
|
@@ -3745,9 +3627,11 @@ function FormGeneratorImpl(props) {
|
|
|
3745
3627
|
ref: formRef,
|
|
3746
3628
|
onSubmit: handleSubmit,
|
|
3747
3629
|
className: className,
|
|
3748
|
-
children: [
|
|
3749
|
-
|
|
3750
|
-
},
|
|
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, {
|
|
3751
3635
|
disabled: disabled || form.formState.isSubmitting,
|
|
3752
3636
|
isSubmitting: form.formState.isSubmitting,
|
|
3753
3637
|
children: submitText
|
|
@@ -3757,7 +3641,9 @@ function FormGeneratorImpl(props) {
|
|
|
3757
3641
|
}
|
|
3758
3642
|
const renderProps = {
|
|
3759
3643
|
fields: templateFields,
|
|
3760
|
-
|
|
3644
|
+
arrays: Object.fromEntries(arrayFields.map(arrayField_0 => [arrayField_0.name, {
|
|
3645
|
+
field: arrayField_0
|
|
3646
|
+
}])),
|
|
3761
3647
|
buttons,
|
|
3762
3648
|
title,
|
|
3763
3649
|
description,
|
|
@@ -3765,8 +3651,7 @@ function FormGeneratorImpl(props) {
|
|
|
3765
3651
|
isSubmitting: form.formState.isSubmitting,
|
|
3766
3652
|
isValid: form.formState.isValid,
|
|
3767
3653
|
isDirty: form.formState.isDirty,
|
|
3768
|
-
renderField
|
|
3769
|
-
renderLayout
|
|
3654
|
+
renderField
|
|
3770
3655
|
};
|
|
3771
3656
|
const renderFn = children;
|
|
3772
3657
|
return jsxRuntime.jsx(FormProvider, {
|
|
@@ -3787,6 +3672,7 @@ Object.defineProperty(exports, "z", {
|
|
|
3787
3672
|
enumerable: true,
|
|
3788
3673
|
get: function () { return zod.z; }
|
|
3789
3674
|
});
|
|
3675
|
+
exports.ArrayFieldRenderer = ArrayFieldRenderer;
|
|
3790
3676
|
exports.Controller = Controller;
|
|
3791
3677
|
exports.FieldRenderer = FieldRenderer;
|
|
3792
3678
|
exports.FormGenerator = FormGenerator;
|
|
@@ -3794,24 +3680,20 @@ exports.FormProvider = FormProvider;
|
|
|
3794
3680
|
exports.clearAllRegistries = clearAllRegistries;
|
|
3795
3681
|
exports.clearFieldRegistry = clearFieldRegistry;
|
|
3796
3682
|
exports.clearFormComponentRegistry = clearFormComponentRegistry;
|
|
3797
|
-
exports.clearLayoutRegistry = clearLayoutRegistry;
|
|
3798
3683
|
exports.getFieldComponent = getFieldComponent;
|
|
3799
3684
|
exports.getFormComponent = getFormComponent;
|
|
3800
3685
|
exports.getFormComponents = getFormComponents;
|
|
3801
|
-
exports.getLayoutComponent = getLayoutComponent;
|
|
3802
3686
|
exports.getRegisteredFieldTypes = getRegisteredFieldTypes;
|
|
3803
3687
|
exports.hasFieldType = hasFieldType;
|
|
3804
3688
|
exports.hasFormComponent = hasFormComponent;
|
|
3805
|
-
exports.
|
|
3806
|
-
exports.isLayoutBlock = isLayoutBlock;
|
|
3689
|
+
exports.isArrayField = isArrayField;
|
|
3807
3690
|
exports.registerField = registerField;
|
|
3808
3691
|
exports.registerFields = registerFields;
|
|
3809
3692
|
exports.registerFormComponent = registerFormComponent;
|
|
3810
3693
|
exports.registerFormComponents = registerFormComponents;
|
|
3811
|
-
exports.registerLayoutComponent = registerLayoutComponent;
|
|
3812
|
-
exports.registerLayoutComponents = registerLayoutComponents;
|
|
3813
3694
|
exports.resetFormComponentRegistry = resetFormComponentRegistry;
|
|
3814
3695
|
exports.unregisterField = unregisterField;
|
|
3696
|
+
exports.useArrayField = useArrayField;
|
|
3815
3697
|
exports.useFieldArray = useFieldArray;
|
|
3816
3698
|
exports.useForm = useForm;
|
|
3817
3699
|
exports.useFormContext = useFormContext;
|