@react-fabric/form 1.0.0-beta.34 → 1.0.0-beta.36

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.
@@ -21,432 +21,47 @@
21
21
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  */
23
23
 
24
- import {
25
- Button,
26
- Collapsable,
27
- Content,
28
- CoreIcons,
29
- Footer,
30
- Modal,
31
- ToggleButtonGroup,
32
- useOverlayService,
33
- } from "@react-fabric/core";
34
- import { type Elements } from "@react-fabric/core/dist/types/types";
24
+ import { Footer } from "@react-fabric/core";
35
25
  import { EMPTY_ARRAY } from "@react-fabric/utilities";
36
- import { Fragment, useCallback, useEffect, useRef, useState } from "react";
37
- import { Controller } from "../form/Controller";
26
+ import { useCallback, useEffect, useRef } from "react";
38
27
  import { Form, type FormRef } from "../form/Form";
39
- import { ArrayInput } from "../input/ArrayInput";
40
- import { Checkbox } from "../input/Checkbox";
41
- import { DateInput } from "../input/DateInput";
42
- import { Field } from "../input/Field";
43
- import { HiddenInput } from "../input/Hidden";
44
- import { Input } from "../input/Input";
45
- import { Number } from "../input/Number";
46
- import { Select } from "../select/Select";
47
28
  import {
48
29
  DATA_TYPES,
49
- type DateSchema,
50
- type DefaultSchema,
51
30
  type FormSchema,
52
- type NumberSchema,
53
- type SchemaDef,
54
- type StringSchema,
55
- type ValueType,
31
+ type SchemaEditorProps,
56
32
  } from "../types/schema";
57
-
58
- interface Props {
59
- schemaDef: FormSchema;
60
- allowRemove?: boolean;
61
- acceptableTypes?: DATA_TYPES[];
62
-
63
- optionLists?: string[];
64
-
65
- /**
66
- * Footer actions
67
- */
68
- children?: Elements<JSX.Element> | Array<Elements<JSX.Element>>;
69
-
70
- onChange: (schema: FormSchema) => void;
71
- }
72
-
73
- const CUSTOM_LIST = "--CUSTOM--";
74
-
75
- const SchemaField = ({
76
- field,
77
- getModel,
78
- onRemove,
79
- optionLists = EMPTY_ARRAY,
80
- allowRemove,
81
- onTypeChange,
82
- acceptableTypes,
83
- }: {
84
- field: string;
85
- onRemove: () => void;
86
- getModel: () => KeyValue;
87
- onTypeChange: (val: KeyValue) => void;
88
- } & Omit<Props, "schemaDef" | "onChange">) => {
89
- const [type, setType] = useState<DATA_TYPES>();
90
- const [multiple, setMultiple] = useState(false);
91
- const [hasOptions, setHasOptions] = useState(false);
92
- const [customOptions, setCustomOptions] = useState(false);
93
-
94
- const [OptionModal, openOptionModal] = useOverlayService((props) => (
95
- <Modal {...props}>
96
- <Content>
97
- <ArrayInput name={`${field}.options`} onAdd={() => String("")}>
98
- <Controller>
99
- <Input />
100
- </Controller>
101
- </ArrayInput>
102
- </Content>
103
- <Footer
104
- flex
105
- justify="end"
106
- className="sticky bottom-0 border-t bg-base px-6 py-2"
107
- >
108
- <Button variant="link" onClick={props.onClose}>
109
- Close
110
- </Button>
111
- </Footer>
112
- </Modal>
113
- ));
114
-
115
- useEffect(() => {
116
- setTimeout(() => {
117
- const model = getModel();
118
- setType(model.datatype);
119
- setMultiple(model.multiple);
120
- setHasOptions(!!model.optionList);
121
- setCustomOptions(model.optionList === CUSTOM_LIST);
122
- }, 10);
123
- }, []);
124
-
125
- const handleTypeChange = useCallback((type: DATA_TYPES) => {
126
- if (type) {
127
- const modelRef = getModel();
128
- let reset = {
129
- datatype: type,
130
- id: field,
131
- label: modelRef.label,
132
- defaultValue: modelRef.defaultValue,
133
- required: modelRef.required,
134
- multiple: type === DATA_TYPES.AVATAR ? false : modelRef.multiple,
135
- minItems: modelRef.minItems,
136
- maxItems: modelRef.maxItems,
137
- } as DefaultSchema & ValueType;
138
- if (type === DATA_TYPES.STRING) {
139
- reset = Object.assign(reset, {
140
- optionList: modelRef.optionList,
141
- options: modelRef.options,
142
- regex: modelRef.regex,
143
- } as StringSchema);
144
- } else if (type === DATA_TYPES.DATE) {
145
- reset = Object.assign(reset, {
146
- type: "date",
147
- } as DateSchema);
148
- } else if (type === DATA_TYPES.NUMBER || type === DATA_TYPES.RANGE) {
149
- reset = Object.assign(reset, {
150
- min: modelRef.min,
151
- max: modelRef.max,
152
- step: modelRef.step,
153
- } as NumberSchema);
154
- }
155
- if (type === DATA_TYPES.AVATAR) {
156
- setMultiple(false);
157
- }
158
- onTypeChange(reset);
159
- setType(type);
160
- }
161
- }, []);
162
-
163
- return (
164
- <Collapsable key={field} open>
165
- <div className="flex flex-nowrap group/field">
166
- <span className="flex-1 truncate">{field}</span>
167
- {allowRemove && (
168
- <Button
169
- size="sm"
170
- color="danger"
171
- variant="link"
172
- aria-label="Delete"
173
- stopPropagation
174
- icon={CoreIcons.trash}
175
- onClick={onRemove}
176
- className="invisible group-hover/field:visible"
177
- />
178
- )}
179
- </div>
180
- <div className="flex flex-col gap-1 pb-4">
181
- <Controller name={`${field}.id`}>
182
- <HiddenInput hiddenValue={field} />
183
- </Controller>
184
- <Controller name={`${field}.datatype`}>
185
- <Select
186
- inline
187
- label="Type"
188
- placeholder="Data type"
189
- options={acceptableTypes}
190
- onChange={(val) => handleTypeChange(val as unknown as DATA_TYPES)}
191
- />
192
- </Controller>
193
- <Controller name={`${field}.label`}>
194
- <Input
195
- inline
196
- label="Label"
197
- allowClear
198
- placeholder="Label..."
199
- decorateEndShowWhenEmpty
200
- decorateEnd={
201
- <span className="text-sm text-muted/50 px-1">OPTIONAL</span>
202
- }
203
- />
204
- </Controller>
205
- {type === DATA_TYPES.STRING && (
206
- <Fragment>
207
- <Controller name={`${field}.regex`}>
208
- <Input
209
- inline
210
- label="Regex validation"
211
- allowClear
212
- placeholder="Regex value..."
213
- decorateEndShowWhenEmpty
214
- decorateEnd={
215
- <span className="text-sm text-muted/50 px-1">OPTIONAL</span>
216
- }
217
- />
218
- </Controller>
219
- <Field inline label="Option list">
220
- <Controller name={`${field}.optionList`}>
221
- <Select
222
- allowClear
223
- options={[CUSTOM_LIST, ...optionLists]}
224
- onChange={(v) => setCustomOptions(v === CUSTOM_LIST)}
225
- />
226
- </Controller>
227
- {customOptions && (
228
- <Button
229
- icon={CoreIcons.list}
230
- aria-label="Custom options"
231
- onClick={() => {
232
- void openOptionModal();
233
- }}
234
- />
235
- )}
236
- </Field>
237
- {OptionModal}
238
- </Fragment>
239
- )}
240
- {type === DATA_TYPES.FILE && (
241
- <Fragment>
242
- <Controller name={`${field}.accept`}>
243
- <Input
244
- inline
245
- label="Accept types"
246
- allowClear
247
- placeholder="Accept value..."
248
- decorateEndShowWhenEmpty
249
- decorateEnd={
250
- <span className="text-sm text-muted/50 px-1">OPTIONAL</span>
251
- }
252
- />
253
- </Controller>
254
- </Fragment>
255
- )}
256
- {[DATA_TYPES.NUMBER, DATA_TYPES.RANGE].includes(
257
- type as unknown as DATA_TYPES,
258
- ) && (
259
- <Fragment>
260
- <Controller name={`${field}.min`}>
261
- <Number
262
- inline
263
- label="Min value"
264
- allowClear
265
- placeholder="Minimum value..."
266
- decorateEndShowWhenEmpty
267
- decorateEnd={
268
- <span className="text-sm text-muted/50 px-1">OPTIONAL</span>
269
- }
270
- />
271
- </Controller>
272
- <Controller name={`${field}.max`}>
273
- <Number
274
- inline
275
- label="Max value"
276
- allowClear
277
- placeholder="Maximum value..."
278
- decorateEndShowWhenEmpty
279
- decorateEnd={
280
- <span className="text-sm text-muted/50 px-1">OPTIONAL</span>
281
- }
282
- />
283
- </Controller>
284
- <Controller name={`${field}.step`}>
285
- <Number
286
- inline
287
- label="Step value"
288
- allowClear
289
- placeholder="Step value..."
290
- decorateEndShowWhenEmpty
291
- decorateEnd={
292
- <span className="text-sm text-muted/50 px-1">OPTIONAL</span>
293
- }
294
- />
295
- </Controller>
296
- </Fragment>
297
- )}
298
- {type === DATA_TYPES.DATE && (
299
- <Fragment>
300
- <Field inline label="Type" plain>
301
- <Controller name={`${field}.type`}>
302
- <ToggleButtonGroup value="" fullWidth className="flex-1">
303
- <Button className="flex-1" value="date">
304
- Date
305
- </Button>
306
- <Button className="flex-1" value="datetime">
307
- Date Time
308
- </Button>
309
- </ToggleButtonGroup>
310
- </Controller>
311
- </Field>
312
- <Controller name={`${field}.min`}>
313
- <DateInput
314
- inline
315
- label="Min value"
316
- allowClear
317
- placeholder="Minimum value..."
318
- decorateEndShowWhenEmpty
319
- decorateEnd={
320
- <span className="text-sm text-muted/50 px-1">OPTIONAL</span>
321
- }
322
- />
323
- </Controller>
324
- <Controller name={`${field}.max`}>
325
- <DateInput
326
- inline
327
- label="Max value"
328
- allowClear
329
- placeholder="Maximum value..."
330
- decorateEndShowWhenEmpty
331
- decorateEnd={
332
- <span className="text-sm text-muted/50 px-1">OPTIONAL</span>
333
- }
334
- />
335
- </Controller>
336
- </Fragment>
337
- )}
338
- <Field label=" " inline plain>
339
- <Controller name={`${field}.required`}>
340
- <Checkbox label="Required" />
341
- </Controller>
342
- {type !== DATA_TYPES.AVATAR && (
343
- <Controller name={`${field}.multiple`}>
344
- <Checkbox label="Multiple" onChange={setMultiple} />
345
- </Controller>
346
- )}
347
- {hasOptions && (
348
- <Controller name={`${field}.allowCustom`}>
349
- <Checkbox label="Allow custom value" />
350
- </Controller>
351
- )}
352
- </Field>
353
- {multiple && (
354
- <Fragment>
355
- <Controller name={`${field}.minItems`}>
356
- <Number
357
- inline
358
- label="Min items"
359
- allowClear
360
- placeholder="Minimum items..."
361
- decorateEndShowWhenEmpty
362
- decorateEnd={
363
- <span className="text-sm text-muted/50 px-1">OPTIONAL</span>
364
- }
365
- />
366
- </Controller>
367
- <Controller name={`${field}.maxItems`}>
368
- <Number
369
- inline
370
- label="Max items"
371
- allowClear
372
- placeholder="Maximum items..."
373
- decorateEndShowWhenEmpty
374
- decorateEnd={
375
- <span className="text-sm text-muted/50 px-1">OPTIONAL</span>
376
- }
377
- />
378
- </Controller>
379
- </Fragment>
380
- )}
381
- </div>
382
- </Collapsable>
383
- );
384
- };
33
+ import { SchemaArrayForm } from "./components/SchemaArrayForm";
385
34
 
386
35
  export const SchemaEditor = ({
387
36
  schemaDef,
388
- allowRemove,
37
+ dynamic,
389
38
  acceptableTypes,
390
39
  optionLists = EMPTY_ARRAY,
391
40
  children,
41
+ onSubmit,
392
42
  onChange,
393
- }: Props) => {
394
- const formRef = useRef<FormRef<KeyValue>>(null);
395
- const [schemaFields, setSchemaFields] = useState<string[]>([]);
396
-
397
- useEffect(() => {
398
- const schemaMap = Object.fromEntries(
399
- schemaDef.map((schema) => [schema.id, schema]),
400
- );
43
+ }: SchemaEditorProps) => {
44
+ const formRef = useRef<FormRef<{ schema: FormSchema }>>(null);
401
45
 
402
- const currentModel: KeyValue = formRef.current?.getValues() ?? {};
403
-
404
- const schema = Object.fromEntries(
405
- Object.keys(schemaMap).map((field) => [
406
- field,
407
- currentModel[field] ?? schemaMap[field],
408
- ]),
409
- );
410
- formRef.current?.setValues(schema);
411
- setTimeout(() => {
412
- setSchemaFields(Object.keys(schema));
413
- }, 100);
414
- }, [schemaDef]);
415
-
416
- const handleChange = useCallback((model: KeyValue<SchemaDef>) => {
417
- onChange?.(Object.values(model));
46
+ const handleChange = useCallback((model: { schema: FormSchema }) => {
47
+ onChange?.(model.schema);
418
48
  }, []);
419
49
 
420
- const handleTypeChange = useCallback((field: string, val: KeyValue) => {
421
- formRef.current?.setValue(field, val);
50
+ const handleSubmit = useCallback((model: { schema: FormSchema }) => {
51
+ onSubmit?.(model.schema);
422
52
  }, []);
423
53
 
424
- const handleRemove = useCallback((field: string) => {
425
- const newSchema: KeyValue = formRef.current?.getValues() ?? {};
426
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
427
- delete newSchema[field];
428
- formRef.current?.setValues(newSchema);
429
- setTimeout(() => {
430
- setSchemaFields(Object.keys(newSchema));
431
- }, 100);
432
- }, []);
54
+ useEffect(() => {
55
+ formRef.current?.setValues({ schema: schemaDef });
56
+ }, [schemaDef]);
433
57
 
434
58
  return (
435
- <Form formRef={formRef} onSubmit={handleChange}>
436
- <Content className="divide-y">
437
- {schemaFields.map((field) => (
438
- <SchemaField
439
- key={field}
440
- field={field}
441
- allowRemove={allowRemove}
442
- optionLists={optionLists}
443
- onRemove={() => handleRemove(field)}
444
- getModel={() => formRef.current?.getValues()[field]}
445
- onTypeChange={(val: KeyValue) => handleTypeChange(field, val)}
446
- acceptableTypes={acceptableTypes ?? Object.values(DATA_TYPES)}
447
- />
448
- ))}
449
- </Content>
59
+ <Form formRef={formRef} onChange={handleChange} onSubmit={handleSubmit}>
60
+ <SchemaArrayForm
61
+ dynamic={dynamic}
62
+ optionLists={optionLists}
63
+ acceptableTypes={acceptableTypes ?? Object.values(DATA_TYPES)}
64
+ />
450
65
  {children && (
451
66
  <Footer flex className="border-t bg-base px-6 py-2">
452
67
  {children}
@@ -0,0 +1,74 @@
1
+ /*
2
+ * React Fabric
3
+ * @version: 1.0.0
4
+ *
5
+ *
6
+ * The MIT License (MIT)
7
+ * Copyright (c) 2025 Adarsh Pastakia
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
10
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
11
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
16
+ * portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ import {
25
+ Button,
26
+ Content,
27
+ Footer,
28
+ Modal,
29
+ type ModalProps,
30
+ } from "@react-fabric/core";
31
+ import { yup } from "@react-fabric/utilities";
32
+ import { useCallback } from "react";
33
+ import { Controller } from "../../form/Controller";
34
+ import { Form } from "../../form/Form";
35
+ import { ArrayInput } from "../../input/ArrayInput";
36
+ import { Input } from "../../input/Input";
37
+
38
+ const fieldSchema = yup.object({
39
+ fields: yup.array(yup.string().trim().required()).required().min(1),
40
+ });
41
+
42
+ export const AddSchemaFields = (props: ModalProps) => {
43
+ const handleSubmit = useCallback((model: KeyValue) => {
44
+ props.onClose(
45
+ model.fields
46
+ .map((f: string) => f.split(",").map((ff) => ff.trim()))
47
+ .flat(2),
48
+ );
49
+ }, []);
50
+
51
+ return (
52
+ <Modal {...props}>
53
+ <Form
54
+ schema={fieldSchema}
55
+ defaultValues={{ fields: [" "] }}
56
+ onSubmit={handleSubmit}
57
+ >
58
+ <Content>
59
+ <ArrayInput minItems={1} name="fields" onAdd={() => String("")}>
60
+ <Controller>
61
+ <Input autoFocus />
62
+ </Controller>
63
+ </ArrayInput>
64
+ <p className="text-sm text-muted">
65
+ Provide list of fields or comma-separated value
66
+ </p>
67
+ </Content>
68
+ <Footer flex justify="end" className="px-2 py-1">
69
+ <Button type="submit">Add</Button>
70
+ </Footer>
71
+ </Form>
72
+ </Modal>
73
+ );
74
+ };
@@ -0,0 +1,158 @@
1
+ /*
2
+ * React Fabric
3
+ * @version: 1.0.0
4
+ *
5
+ *
6
+ * The MIT License (MIT)
7
+ * Copyright (c) 2025 Adarsh Pastakia
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
10
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
11
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
16
+ * portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ import { DndContext, type DragEndEvent } from "@dnd-kit/core";
25
+ import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
26
+ import { SortableContext } from "@dnd-kit/sortable";
27
+ import {
28
+ Button,
29
+ Content,
30
+ CoreIcons,
31
+ Header,
32
+ useOverlayService,
33
+ } from "@react-fabric/core";
34
+ import { isArray } from "@react-fabric/utilities";
35
+ import { type PropsWithChildren, useCallback, useState } from "react";
36
+ import { useFieldArray, useFormContext } from "react-hook-form";
37
+ import { DATA_TYPES, type SchemaEditorProps } from "../../types/schema";
38
+ import { AddSchemaFields } from "./AddSchemaFields";
39
+ import { SchemaField } from "./SchemaField";
40
+
41
+ export const SchemaArrayForm = ({
42
+ dynamic,
43
+ acceptableTypes,
44
+ optionLists,
45
+ }: Partial<SchemaEditorProps>) => {
46
+ const form = useFormContext();
47
+ const [defaultOpen, setDefaultOpen] = useState(true);
48
+ const { fields, append, remove, move } = useFieldArray({
49
+ name: "schema",
50
+ control: form.control,
51
+ });
52
+
53
+ const handleTypeChange = useCallback((index: number, val: KeyValue) => {
54
+ form.setValue(`schema.${index}`, val);
55
+ }, []);
56
+
57
+ const handleRemove = useCallback((index: number) => {
58
+ remove(index);
59
+ }, []);
60
+
61
+ const [AddModal, openAddfields] = useOverlayService(AddSchemaFields);
62
+ const handleAdd = useCallback(() => {
63
+ void openAddfields().then((fields) => {
64
+ if (isArray(fields)) {
65
+ const existing = form
66
+ .getValues()
67
+ .schema.map((field: KeyValue) => field.id);
68
+ fields.forEach((field) => {
69
+ if (!existing.includes(field)) {
70
+ append({
71
+ id: field,
72
+ datatype: DATA_TYPES.STRING,
73
+ label: "",
74
+ });
75
+ }
76
+ });
77
+ }
78
+ });
79
+ }, []);
80
+
81
+ const Wrapper = useCallback(
82
+ ({ children }: PropsWithChildren) => {
83
+ if (dynamic) {
84
+ // pass id list to dnd context
85
+ const idMap = fields.map((item) => item.id);
86
+ const handleDragEnd = (e: DragEndEvent) => {
87
+ if (e.over && e.active.id !== e.over.id) {
88
+ // find index of item and drop over
89
+ const active = idMap.indexOf(`${e.active.id}`);
90
+ const end = idMap.indexOf(`${e.over.id}`);
91
+ move(active, end);
92
+ }
93
+ };
94
+ return (
95
+ <DndContext
96
+ onDragEnd={handleDragEnd}
97
+ modifiers={[restrictToVerticalAxis]}
98
+ >
99
+ <SortableContext items={idMap}>{children}</SortableContext>
100
+ </DndContext>
101
+ );
102
+ }
103
+
104
+ return children;
105
+ },
106
+ [dynamic, fields],
107
+ );
108
+ // @ts-expect-error ignore
109
+ Wrapper.displayName = "SortableWrapper";
110
+
111
+ return (
112
+ <Wrapper>
113
+ <Header flex justify="end" className="gap-1 px-2">
114
+ {dynamic && (
115
+ <Button
116
+ size="sm"
117
+ variant="link"
118
+ icon={CoreIcons.insert}
119
+ aria-label="add field"
120
+ onClick={handleAdd}
121
+ />
122
+ )}
123
+ <Button
124
+ size="sm"
125
+ variant="link"
126
+ icon={CoreIcons.colapseAllVar}
127
+ aria-label="collapse all"
128
+ onClick={() => setDefaultOpen(false)}
129
+ />
130
+ <Button
131
+ size="sm"
132
+ variant="link"
133
+ icon={CoreIcons.expandAllVar}
134
+ aria-label="expand all"
135
+ onClick={() => setDefaultOpen(true)}
136
+ />
137
+ </Header>
138
+ <Content className="divide-y">
139
+ {fields.map((field, index) => (
140
+ <SchemaField
141
+ key={index}
142
+ defaultOpen={defaultOpen}
143
+ id={form.getValues().schema[index].id}
144
+ fieldId={field.id}
145
+ field={`schema.${index}`}
146
+ dynamic={dynamic}
147
+ optionLists={optionLists}
148
+ onRemove={() => handleRemove(index)}
149
+ getModel={() => form.getValues().schema[index]}
150
+ onTypeChange={(val: KeyValue) => handleTypeChange(index, val)}
151
+ acceptableTypes={acceptableTypes ?? Object.values(DATA_TYPES)}
152
+ />
153
+ ))}
154
+ </Content>
155
+ {AddModal}
156
+ </Wrapper>
157
+ );
158
+ };