@overmap-ai/forms 1.0.32-react-flow-david-fixes.0 → 1.0.32-react-flow-david-fixes.1
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/dist/form/builder/Root.d.ts +1 -2
- package/dist/form/builder/flow/FlowBuilder.d.ts +1 -4
- package/dist/form/builder/index.d.ts +9 -0
- package/dist/form/builder/list/ListBuilder.d.ts +1 -6
- package/dist/form/builder/preview/Preview.d.ts +1 -2
- package/dist/form/builder/utils.d.ts +1 -4
- package/dist/forms.js +171 -126
- package/dist/forms.umd.cjs +172 -127
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { SerializedFieldSection } from '../fields';
|
|
3
3
|
import { FormBuilderSaveHandler } from './typings';
|
|
4
|
-
interface FormBuilderRootProps extends PropsWithChildren {
|
|
4
|
+
export interface FormBuilderRootProps extends PropsWithChildren {
|
|
5
5
|
initialTitle?: string;
|
|
6
6
|
initialDescription?: string;
|
|
7
7
|
initialFields?: SerializedFieldSection[];
|
|
@@ -11,4 +11,3 @@ interface FormBuilderRootProps extends PropsWithChildren {
|
|
|
11
11
|
disableRequiredFields?: boolean;
|
|
12
12
|
}
|
|
13
13
|
export declare const FormBuilderRoot: import('react').NamedExoticComponent<FormBuilderRootProps>;
|
|
14
|
-
export {};
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
|
|
2
|
-
}
|
|
3
|
-
export declare const FormBuilderFlowBuilder: import('react').NamedExoticComponent<FormBuilderFlowBuilderProps>;
|
|
4
|
-
export {};
|
|
1
|
+
export declare const FormBuilderFlowBuilder: import('react').MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type * from './typings';
|
|
2
|
+
export declare const FormBuilder: {
|
|
3
|
+
Root: import('react').NamedExoticComponent<import('./Root').FormBuilderRootProps>;
|
|
4
|
+
FlowBuilder: import('react').MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
|
|
5
|
+
ListBuilder: import('react').MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
|
|
6
|
+
Preview: import('react').NamedExoticComponent<import('./preview').FormBuilderPreviewProps>;
|
|
7
|
+
};
|
|
8
|
+
export { createCondition } from './utils';
|
|
9
|
+
export { createField } from './utils';
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
showFormTitle?: boolean;
|
|
3
|
-
showExplainerText?: boolean;
|
|
4
|
-
}
|
|
5
|
-
export declare const FormBuilderListBuilder: import('react').NamedExoticComponent<FormBuilderListBuilderProps>;
|
|
6
|
-
export {};
|
|
1
|
+
export declare const FormBuilderListBuilder: import('react').MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { BooleanFieldCondition, CheckboxListFieldCondition, DateFieldCondition, MultiSelectFieldCondition, MultiStringFieldCondition, NumberFieldCondition, RadioFieldCondition, ScanFieldCondition, SelectFieldCondition, StringFieldCondition, TextFieldCondition, UploadFieldCondition } from '../conditions';
|
|
2
|
-
import { Field, FieldType
|
|
3
|
-
import { SerializedFieldSection } from '../fields/FieldSection/typings';
|
|
4
|
-
export declare const emptySection: (id?: string, fields?: SerializedOnlyField[]) => SerializedFieldSection;
|
|
5
|
-
export declare const wrapRootFieldsWithFieldSection: (fields: SerializedField[]) => SerializedFieldSection[];
|
|
2
|
+
import { Field, FieldType } from '../fields';
|
|
6
3
|
export declare const createField: (type: Exclude<FieldType, "section">) => Field;
|
|
7
4
|
export declare const createCondition: (field: Field) => BooleanFieldCondition | CheckboxListFieldCondition | DateFieldCondition | MultiSelectFieldCondition | MultiStringFieldCondition | NumberFieldCondition | RadioFieldCondition | ScanFieldCondition | SelectFieldCondition | StringFieldCondition | TextFieldCondition | UploadFieldCondition;
|
package/dist/forms.js
CHANGED
|
@@ -8,10 +8,10 @@ import * as React from "react";
|
|
|
8
8
|
import { memo, forwardRef, useMemo, createContext, useContext, useState, useRef, useCallback, useEffect, Fragment as Fragment$1, use, useLayoutEffect, useId as useId$1 } from "react";
|
|
9
9
|
import "@xyflow/react/dist/style.css";
|
|
10
10
|
import { getBezierPath, BaseEdge, EdgeLabelRenderer, NodeToolbar, Position, Handle, MarkerType, useNodesState, useEdgesState, ReactFlow, Panel } from "@xyflow/react";
|
|
11
|
+
import { useField, useFormikContext, useFormik, FormikProvider } from "formik";
|
|
11
12
|
import { DirectedGraph } from "graphology";
|
|
12
13
|
import { willCreateCycle } from "graphology-dag";
|
|
13
14
|
import { v4 } from "uuid";
|
|
14
|
-
import { useField, useFormikContext, useFormik, FormikProvider } from "formik";
|
|
15
15
|
import { DragDropContext, Droppable, Draggable } from "@hello-pangea/dnd";
|
|
16
16
|
import { Copy, Download, X, Plus, Check, ChevronDown, Minus, Circle, Maximize, FileWarning, File, Upload, Trash2, Settings } from "lucide-react";
|
|
17
17
|
import * as ReactDOM from "react-dom";
|
|
@@ -32,6 +32,12 @@ const FileCard = memo(
|
|
|
32
32
|
})
|
|
33
33
|
);
|
|
34
34
|
FileCard.displayName = "FileCard";
|
|
35
|
+
const SEVERITY_COLOR_MAPPING = {
|
|
36
|
+
danger: "danger",
|
|
37
|
+
warning: "warning",
|
|
38
|
+
info: "base",
|
|
39
|
+
success: "success"
|
|
40
|
+
};
|
|
35
41
|
class Observable {
|
|
36
42
|
constructor() {
|
|
37
43
|
__publicField(this, "observers", /* @__PURE__ */ new Set());
|
|
@@ -189,12 +195,6 @@ const useFormikInput = (props) => {
|
|
|
189
195
|
];
|
|
190
196
|
};
|
|
191
197
|
const EMPTY_ARRAY = [];
|
|
192
|
-
const SEVERITY_COLOR_MAPPING = {
|
|
193
|
-
danger: "danger",
|
|
194
|
-
warning: "warning",
|
|
195
|
-
info: "base",
|
|
196
|
-
success: "success"
|
|
197
|
-
};
|
|
198
198
|
const InputWithHelpText = (props) => {
|
|
199
199
|
const { helpText, children, severity } = props;
|
|
200
200
|
const color = severity ? SEVERITY_COLOR_MAPPING[severity] : "base";
|
|
@@ -35406,7 +35406,8 @@ const getLayoutedElements = (nodes, edges, direction) => {
|
|
|
35406
35406
|
edges
|
|
35407
35407
|
];
|
|
35408
35408
|
};
|
|
35409
|
-
const FormBuilderFlowBuilder = memo((
|
|
35409
|
+
const FormBuilderFlowBuilder = memo(() => {
|
|
35410
|
+
const { handleSubmit, errors } = useFormikContext();
|
|
35410
35411
|
const { onCancel } = use(FormBuilderContext);
|
|
35411
35412
|
const fieldSchema = use(FieldSchemaContext);
|
|
35412
35413
|
const ref = useRef(null);
|
|
@@ -35495,61 +35496,98 @@ const FormBuilderFlowBuilder = memo((_props) => {
|
|
|
35495
35496
|
},
|
|
35496
35497
|
[fieldSchema.fields]
|
|
35497
35498
|
);
|
|
35498
|
-
|
|
35499
|
+
const [titleFieldProps, titleMeta, titleHelpers] = useField("title");
|
|
35500
|
+
const [descriptionFieldProps, _descriptionMeta, descriptionHelpers] = useField("description");
|
|
35501
|
+
return /* @__PURE__ */ jsxs("form", { className: "size-full flex flex-col gap-4", id: formId, onSubmit: handleSubmit, children: [
|
|
35502
|
+
/* @__PURE__ */ jsx(InputWithHelpText, { severity: "danger", helpText: titleMeta.error ?? null, children: /* @__PURE__ */ jsx(
|
|
35503
|
+
Input.Root,
|
|
35504
|
+
{
|
|
35505
|
+
variant: "outline",
|
|
35506
|
+
size: "md",
|
|
35507
|
+
accentColor: titleMeta.error ? SEVERITY_COLOR_MAPPING.danger : "primary",
|
|
35508
|
+
children: /* @__PURE__ */ jsx(
|
|
35509
|
+
Input.Field,
|
|
35510
|
+
{
|
|
35511
|
+
placeholder: "Enter a title",
|
|
35512
|
+
value: titleFieldProps.value ?? "",
|
|
35513
|
+
onChange: (event) => {
|
|
35514
|
+
void titleHelpers.setValue(event.target.value);
|
|
35515
|
+
},
|
|
35516
|
+
maxLength: 100
|
|
35517
|
+
}
|
|
35518
|
+
)
|
|
35519
|
+
}
|
|
35520
|
+
) }),
|
|
35499
35521
|
/* @__PURE__ */ jsx(
|
|
35500
|
-
|
|
35522
|
+
TextArea,
|
|
35501
35523
|
{
|
|
35502
|
-
|
|
35503
|
-
|
|
35504
|
-
|
|
35505
|
-
|
|
35506
|
-
|
|
35507
|
-
|
|
35508
|
-
|
|
35509
|
-
|
|
35510
|
-
|
|
35511
|
-
attributionPosition: "bottom-left",
|
|
35512
|
-
fitView: true,
|
|
35513
|
-
minZoom: 0,
|
|
35514
|
-
isValidConnection: handleValidConnection
|
|
35524
|
+
className: "field-sizing-content",
|
|
35525
|
+
placeholder: "Explain a description",
|
|
35526
|
+
value: descriptionFieldProps.value ?? "",
|
|
35527
|
+
onChange: (event) => {
|
|
35528
|
+
void descriptionHelpers.setValue(event.target.value);
|
|
35529
|
+
},
|
|
35530
|
+
resize: "vertical",
|
|
35531
|
+
maxLength: 1e3,
|
|
35532
|
+
size: "md"
|
|
35515
35533
|
}
|
|
35516
35534
|
),
|
|
35517
|
-
/* @__PURE__ */
|
|
35518
|
-
/* @__PURE__ */ jsx(
|
|
35519
|
-
|
|
35520
|
-
] }) }) }),
|
|
35521
|
-
/* @__PURE__ */ jsxs(Panel, { position: "top-right", className: "flex flex-col items-center gap-2", children: [
|
|
35522
|
-
/* @__PURE__ */ jsxs(
|
|
35523
|
-
ToggleGroup.Root,
|
|
35535
|
+
/* @__PURE__ */ jsxs(Card, { className: "size-full relative", variant: "outline", children: [
|
|
35536
|
+
/* @__PURE__ */ jsx(
|
|
35537
|
+
ReactFlow,
|
|
35524
35538
|
{
|
|
35525
|
-
|
|
35526
|
-
|
|
35527
|
-
|
|
35528
|
-
|
|
35529
|
-
|
|
35530
|
-
|
|
35531
|
-
|
|
35532
|
-
|
|
35533
|
-
|
|
35534
|
-
|
|
35539
|
+
ref,
|
|
35540
|
+
onInit: setReactFlow,
|
|
35541
|
+
nodes: layoutedNodes,
|
|
35542
|
+
onNodesChange: handleNodesChange,
|
|
35543
|
+
edges: layoutedEdges,
|
|
35544
|
+
onEdgesChange: handleEdgesChange,
|
|
35545
|
+
nodeTypes,
|
|
35546
|
+
edgeTypes,
|
|
35547
|
+
onConnect: handleConnect,
|
|
35548
|
+
attributionPosition: "bottom-left",
|
|
35549
|
+
fitView: true,
|
|
35550
|
+
minZoom: 0,
|
|
35551
|
+
isValidConnection: handleValidConnection
|
|
35535
35552
|
}
|
|
35536
35553
|
),
|
|
35537
|
-
/* @__PURE__ */ jsx(
|
|
35538
|
-
|
|
35539
|
-
|
|
35540
|
-
|
|
35541
|
-
|
|
35542
|
-
|
|
35554
|
+
/* @__PURE__ */ jsx(Panel, { position: "top-left", children: /* @__PURE__ */ jsx(ButtonGroup, { className: "flex items-center justify-end gap-2", size: "sm", children: /* @__PURE__ */ jsxs(Button, { type: "button", variant: "surface", onClick: handleAddSection, children: [
|
|
35555
|
+
/* @__PURE__ */ jsx(LuIcon, { icon: "plus" }),
|
|
35556
|
+
" Add section"
|
|
35557
|
+
] }) }) }),
|
|
35558
|
+
/* @__PURE__ */ jsxs(Panel, { position: "top-right", className: "flex flex-col items-center gap-2", children: [
|
|
35559
|
+
/* @__PURE__ */ jsxs(
|
|
35560
|
+
ToggleGroup.Root,
|
|
35561
|
+
{
|
|
35562
|
+
className: "flex flex-col",
|
|
35563
|
+
type: "single",
|
|
35564
|
+
accentColor: "base",
|
|
35565
|
+
size: "sm",
|
|
35566
|
+
value: layoutDirection,
|
|
35567
|
+
onValueChange: setLayoutDirection,
|
|
35568
|
+
children: [
|
|
35569
|
+
/* @__PURE__ */ jsx(ToggleGroup.IconItem, { className: "rounded-b-none", value: "LR", type: "button", children: /* @__PURE__ */ jsx(LuIcon, { icon: "arrow-right-left" }) }),
|
|
35570
|
+
/* @__PURE__ */ jsx(ToggleGroup.IconItem, { className: "rounded-t-none", value: "TB", type: "button", children: /* @__PURE__ */ jsx(LuIcon, { icon: "arrow-down-up" }) })
|
|
35571
|
+
]
|
|
35572
|
+
}
|
|
35573
|
+
),
|
|
35574
|
+
/* @__PURE__ */ jsx(Separator, { size: "sm" }),
|
|
35575
|
+
/* @__PURE__ */ jsxs(ButtonGroup, { className: "flex flex-col ", size: "sm", accentColor: "base", variant: "soft", children: [
|
|
35576
|
+
/* @__PURE__ */ jsx(IconButton, { className: "rounded-b-none", onClick: () => reactFlow == null ? void 0 : reactFlow.zoomIn(), type: "button", children: /* @__PURE__ */ jsx(LuIcon, { icon: "plus" }) }),
|
|
35577
|
+
/* @__PURE__ */ jsx(IconButton, { onClick: () => reactFlow == null ? void 0 : reactFlow.zoomOut(), radius: "none", type: "button", children: /* @__PURE__ */ jsx(LuIcon, { icon: "minus" }) }),
|
|
35578
|
+
/* @__PURE__ */ jsx(IconButton, { className: "rounded-t-none", onClick: () => reactFlow == null ? void 0 : reactFlow.fitView(), type: "button", children: /* @__PURE__ */ jsx(LuIcon, { icon: "square-dashed" }) })
|
|
35579
|
+
] })
|
|
35580
|
+
] }),
|
|
35581
|
+
/* @__PURE__ */ jsx(Panel, { position: "bottom-right", children: /* @__PURE__ */ jsxs(ButtonGroup, { className: "flex items-center justify-end gap-2", size: "sm", children: [
|
|
35582
|
+
onCancel && /* @__PURE__ */ jsx(Button, { type: "button", variant: "soft", accentColor: "base", onClick: onCancel, children: "Cancel" }),
|
|
35583
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", variant: "surface", children: "Save" })
|
|
35584
|
+
] }) })
|
|
35543
35585
|
] }),
|
|
35544
|
-
/* @__PURE__ */ jsx(
|
|
35545
|
-
onCancel && /* @__PURE__ */ jsx(Button, { type: "button", variant: "soft", accentColor: "base", onClick: onCancel, children: "Cancel" }),
|
|
35546
|
-
/* @__PURE__ */ jsx(Button, { type: "submit", variant: "surface", children: "Save" })
|
|
35547
|
-
] }) })
|
|
35586
|
+
!!errors.fields && /* @__PURE__ */ jsx(Text, { size: "xs", accentColor: "danger", children: typeof errors.fields === "string" && errors.fields })
|
|
35548
35587
|
] });
|
|
35549
35588
|
});
|
|
35550
35589
|
FormBuilderFlowBuilder.displayName = "FormBuilderFlowBuilder";
|
|
35551
|
-
const FormBuilderListBuilder = memo((
|
|
35552
|
-
const { showFormTitle = true, showExplainerText = true } = props;
|
|
35590
|
+
const FormBuilderListBuilder = memo(() => {
|
|
35553
35591
|
const { handleSubmit, errors } = useFormikContext();
|
|
35554
35592
|
const { onCancel } = use(FormBuilderContext);
|
|
35555
35593
|
const fieldSchema = use(FieldSchemaContext);
|
|
@@ -35559,43 +35597,41 @@ const FormBuilderListBuilder = memo((props) => {
|
|
|
35559
35597
|
const [titleFieldProps, titleMeta, titleHelpers] = useField("title");
|
|
35560
35598
|
const [descriptionFieldProps, _descriptionMeta, descriptionHelpers] = useField("description");
|
|
35561
35599
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
35562
|
-
|
|
35600
|
+
/* @__PURE__ */ jsx(Text, { accentColor: "base", size: "sm", children: "Create your form using various field types. Sections can be conditionally rendered based on answers to fields in preceding sections." }),
|
|
35563
35601
|
/* @__PURE__ */ jsxs("form", { className: "flex flex-col gap-4", id: formId, onSubmit: handleSubmit, children: [
|
|
35564
|
-
|
|
35565
|
-
|
|
35566
|
-
|
|
35567
|
-
|
|
35568
|
-
|
|
35569
|
-
|
|
35570
|
-
|
|
35571
|
-
|
|
35572
|
-
|
|
35573
|
-
|
|
35574
|
-
|
|
35575
|
-
|
|
35576
|
-
|
|
35577
|
-
|
|
35578
|
-
|
|
35579
|
-
|
|
35580
|
-
|
|
35581
|
-
|
|
35582
|
-
|
|
35583
|
-
|
|
35584
|
-
|
|
35585
|
-
|
|
35586
|
-
|
|
35587
|
-
|
|
35588
|
-
|
|
35589
|
-
|
|
35590
|
-
|
|
35591
|
-
|
|
35592
|
-
|
|
35593
|
-
|
|
35594
|
-
|
|
35595
|
-
|
|
35596
|
-
|
|
35597
|
-
)
|
|
35598
|
-
] }),
|
|
35602
|
+
/* @__PURE__ */ jsx(InputWithHelpText, { severity: "danger", helpText: titleMeta.error ?? null, children: /* @__PURE__ */ jsx(
|
|
35603
|
+
Input.Root,
|
|
35604
|
+
{
|
|
35605
|
+
variant: "outline",
|
|
35606
|
+
size: "md",
|
|
35607
|
+
accentColor: titleMeta.error ? SEVERITY_COLOR_MAPPING.danger : "primary",
|
|
35608
|
+
children: /* @__PURE__ */ jsx(
|
|
35609
|
+
Input.Field,
|
|
35610
|
+
{
|
|
35611
|
+
placeholder: "Enter a title",
|
|
35612
|
+
value: titleFieldProps.value ?? "",
|
|
35613
|
+
onChange: (event) => {
|
|
35614
|
+
void titleHelpers.setValue(event.target.value);
|
|
35615
|
+
},
|
|
35616
|
+
maxLength: 100
|
|
35617
|
+
}
|
|
35618
|
+
)
|
|
35619
|
+
}
|
|
35620
|
+
) }),
|
|
35621
|
+
/* @__PURE__ */ jsx(
|
|
35622
|
+
TextArea,
|
|
35623
|
+
{
|
|
35624
|
+
className: "field-sizing-content",
|
|
35625
|
+
placeholder: "Explain a description",
|
|
35626
|
+
value: descriptionFieldProps.value ?? "",
|
|
35627
|
+
onChange: (event) => {
|
|
35628
|
+
void descriptionHelpers.setValue(event.target.value);
|
|
35629
|
+
},
|
|
35630
|
+
resize: "vertical",
|
|
35631
|
+
maxLength: 1e3,
|
|
35632
|
+
size: "md"
|
|
35633
|
+
}
|
|
35634
|
+
),
|
|
35599
35635
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
35600
35636
|
fieldSchema.fields.map((fieldSection, index) => /* @__PURE__ */ jsx(
|
|
35601
35637
|
FieldSectionWithActions,
|
|
@@ -35786,45 +35822,53 @@ const FormBuilderRoot = memo((props) => {
|
|
|
35786
35822
|
errors.fields = "At least one field is required.";
|
|
35787
35823
|
}
|
|
35788
35824
|
let fieldsToValidate = [];
|
|
35789
|
-
for (const [sectionIndex, section] of form.fields.entries())
|
|
35825
|
+
for (const [sectionIndex, section] of form.fields.entries())
|
|
35790
35826
|
for (const [fieldIndex, field] of section.fields.entries()) {
|
|
35791
35827
|
let fieldSettings = [];
|
|
35792
|
-
|
|
35793
|
-
|
|
35794
|
-
|
|
35795
|
-
|
|
35796
|
-
|
|
35797
|
-
|
|
35798
|
-
|
|
35799
|
-
|
|
35800
|
-
|
|
35801
|
-
|
|
35802
|
-
|
|
35803
|
-
|
|
35804
|
-
|
|
35805
|
-
|
|
35806
|
-
|
|
35807
|
-
|
|
35808
|
-
|
|
35809
|
-
|
|
35810
|
-
|
|
35811
|
-
|
|
35812
|
-
|
|
35813
|
-
|
|
35814
|
-
|
|
35815
|
-
|
|
35816
|
-
|
|
35817
|
-
|
|
35818
|
-
|
|
35819
|
-
|
|
35820
|
-
|
|
35821
|
-
|
|
35822
|
-
|
|
35823
|
-
|
|
35828
|
+
switch (field.type) {
|
|
35829
|
+
case "text":
|
|
35830
|
+
fieldSettings = TextField.getFieldCreationSchema(
|
|
35831
|
+
`fields.${sectionIndex}.fields.${fieldIndex}`
|
|
35832
|
+
).map((field2) => field2.field);
|
|
35833
|
+
break;
|
|
35834
|
+
case "number":
|
|
35835
|
+
fieldSettings = NumberField.getFieldCreationSchema(
|
|
35836
|
+
`fields.${sectionIndex}.fields.${fieldIndex}`
|
|
35837
|
+
).map((field2) => field2.field);
|
|
35838
|
+
break;
|
|
35839
|
+
case "string":
|
|
35840
|
+
fieldSettings = StringField.getFieldCreationSchema(
|
|
35841
|
+
`fields.${sectionIndex}.fields.${fieldIndex}`
|
|
35842
|
+
).map((field2) => field2.field);
|
|
35843
|
+
break;
|
|
35844
|
+
case "select":
|
|
35845
|
+
fieldSettings = SelectField.getFieldCreationSchema(
|
|
35846
|
+
`fields.${sectionIndex}.fields.${fieldIndex}`
|
|
35847
|
+
).map((field2) => field2.field);
|
|
35848
|
+
break;
|
|
35849
|
+
case "multi-select":
|
|
35850
|
+
fieldSettings = MultiSelectField.getFieldCreationSchema(
|
|
35851
|
+
`fields.${sectionIndex}.fields.${fieldIndex}`
|
|
35852
|
+
).map((field2) => field2.field);
|
|
35853
|
+
break;
|
|
35854
|
+
case "upload":
|
|
35855
|
+
fieldSettings = UploadField.getFieldCreationSchema(
|
|
35856
|
+
`fields.${sectionIndex}.fields.${fieldIndex}`
|
|
35857
|
+
).map((field2) => field2.field);
|
|
35858
|
+
break;
|
|
35859
|
+
case "radio":
|
|
35860
|
+
fieldSettings = RadioField.getFieldCreationSchema(
|
|
35861
|
+
`fields.${sectionIndex}.fields.${fieldIndex}`
|
|
35862
|
+
).map((field2) => field2.field);
|
|
35863
|
+
break;
|
|
35864
|
+
case "checkbox-list":
|
|
35865
|
+
fieldSettings = fieldSettings = CheckboxListField.getFieldCreationSchema(
|
|
35866
|
+
`fields.${sectionIndex}.fields.${fieldIndex}`
|
|
35867
|
+
).map((field2) => field2.field);
|
|
35868
|
+
break;
|
|
35824
35869
|
}
|
|
35825
35870
|
fieldsToValidate = [...fieldsToValidate, ...fieldSettings];
|
|
35826
35871
|
}
|
|
35827
|
-
}
|
|
35828
35872
|
const fieldErrors = validateFields(fieldsToValidate, form);
|
|
35829
35873
|
if (fieldErrors) {
|
|
35830
35874
|
errors.fields = fieldErrors.fields;
|
|
@@ -35855,16 +35899,17 @@ const FormBuilderRoot = memo((props) => {
|
|
|
35855
35899
|
validateOnBlur: false,
|
|
35856
35900
|
enableReinitialize
|
|
35857
35901
|
});
|
|
35858
|
-
const schema = useMemo(() => FieldSchema.deserialize(formik.values.fields), [formik.values.fields]);
|
|
35859
35902
|
const observer = useCallback(
|
|
35860
35903
|
(fieldSchema) => {
|
|
35861
35904
|
formik.setFieldValue("fields", fieldSchema.serialize());
|
|
35862
35905
|
},
|
|
35863
35906
|
[formik]
|
|
35864
35907
|
);
|
|
35865
|
-
|
|
35866
|
-
|
|
35867
|
-
|
|
35908
|
+
const schema = useMemo(() => {
|
|
35909
|
+
const schema2 = FieldSchema.deserialize(formik.values.fields);
|
|
35910
|
+
schema2.observe(observer);
|
|
35911
|
+
return schema2;
|
|
35912
|
+
}, [formik.values.fields, observer]);
|
|
35868
35913
|
const contextValue = useMemo(() => {
|
|
35869
35914
|
return {
|
|
35870
35915
|
disableRequiredFields,
|
package/dist/forms.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(global2, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("@overmap-ai/blocks"), require("class-variance-authority"), require("react"), require("@xyflow/react/dist/style.css"), require("@xyflow/react"), require("
|
|
3
|
-
})(this, function(exports2, jsxRuntime, blocks, classVarianceAuthority, React, style_css, react, graphology, graphologyDag, uuid,
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("@overmap-ai/blocks"), require("class-variance-authority"), require("react"), require("@xyflow/react/dist/style.css"), require("@xyflow/react"), require("formik"), require("graphology"), require("graphology-dag"), require("uuid"), require("@hello-pangea/dnd"), require("lucide-react"), require("react-dom"), require("file-saver"), require("react-zxing"), require("lodash.get"), require("lodash.set"), require("@dagrejs/dagre")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "@overmap-ai/blocks", "class-variance-authority", "react", "@xyflow/react/dist/style.css", "@xyflow/react", "formik", "graphology", "graphology-dag", "uuid", "@hello-pangea/dnd", "lucide-react", "react-dom", "file-saver", "react-zxing", "lodash.get", "lodash.set", "@dagrejs/dagre"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.forms = {}, global2.jsxRuntime, global2.blocks, global2.classVarianceAuthority, global2.React, null, global2.react, global2.formik, global2.graphology, global2.graphologyDag, global2.uuid, global2.dnd, global2.lucideReact, global2.ReactDOM, global2.fileSaver, global2.reactZxing, global2.get, global2.set, global2.Dagre));
|
|
3
|
+
})(this, function(exports2, jsxRuntime, blocks, classVarianceAuthority, React, style_css, react, formik, graphology, graphologyDag, uuid, dnd, lucideReact, ReactDOM, fileSaver, reactZxing, get, set, Dagre) {
|
|
4
4
|
"use strict";var __defProp = Object.defineProperty;
|
|
5
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
6
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -34,6 +34,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
34
34
|
})
|
|
35
35
|
);
|
|
36
36
|
FileCard.displayName = "FileCard";
|
|
37
|
+
const SEVERITY_COLOR_MAPPING = {
|
|
38
|
+
danger: "danger",
|
|
39
|
+
warning: "warning",
|
|
40
|
+
info: "base",
|
|
41
|
+
success: "success"
|
|
42
|
+
};
|
|
37
43
|
class Observable {
|
|
38
44
|
constructor() {
|
|
39
45
|
__publicField(this, "observers", /* @__PURE__ */ new Set());
|
|
@@ -191,12 +197,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
191
197
|
];
|
|
192
198
|
};
|
|
193
199
|
const EMPTY_ARRAY = [];
|
|
194
|
-
const SEVERITY_COLOR_MAPPING = {
|
|
195
|
-
danger: "danger",
|
|
196
|
-
warning: "warning",
|
|
197
|
-
info: "base",
|
|
198
|
-
success: "success"
|
|
199
|
-
};
|
|
200
200
|
const InputWithHelpText = (props) => {
|
|
201
201
|
const { helpText, children, severity } = props;
|
|
202
202
|
const color = severity ? SEVERITY_COLOR_MAPPING[severity] : "base";
|
|
@@ -35408,7 +35408,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35408
35408
|
edges
|
|
35409
35409
|
];
|
|
35410
35410
|
};
|
|
35411
|
-
const FormBuilderFlowBuilder = React.memo((
|
|
35411
|
+
const FormBuilderFlowBuilder = React.memo(() => {
|
|
35412
|
+
const { handleSubmit, errors } = formik.useFormikContext();
|
|
35412
35413
|
const { onCancel } = React.use(FormBuilderContext);
|
|
35413
35414
|
const fieldSchema = React.use(FieldSchemaContext);
|
|
35414
35415
|
const ref = React.useRef(null);
|
|
@@ -35497,61 +35498,98 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35497
35498
|
},
|
|
35498
35499
|
[fieldSchema.fields]
|
|
35499
35500
|
);
|
|
35500
|
-
|
|
35501
|
+
const [titleFieldProps, titleMeta, titleHelpers] = formik.useField("title");
|
|
35502
|
+
const [descriptionFieldProps, _descriptionMeta, descriptionHelpers] = formik.useField("description");
|
|
35503
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("form", { className: "size-full flex flex-col gap-4", id: formId, onSubmit: handleSubmit, children: [
|
|
35504
|
+
/* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { severity: "danger", helpText: titleMeta.error ?? null, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
35505
|
+
blocks.Input.Root,
|
|
35506
|
+
{
|
|
35507
|
+
variant: "outline",
|
|
35508
|
+
size: "md",
|
|
35509
|
+
accentColor: titleMeta.error ? SEVERITY_COLOR_MAPPING.danger : "primary",
|
|
35510
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
35511
|
+
blocks.Input.Field,
|
|
35512
|
+
{
|
|
35513
|
+
placeholder: "Enter a title",
|
|
35514
|
+
value: titleFieldProps.value ?? "",
|
|
35515
|
+
onChange: (event) => {
|
|
35516
|
+
void titleHelpers.setValue(event.target.value);
|
|
35517
|
+
},
|
|
35518
|
+
maxLength: 100
|
|
35519
|
+
}
|
|
35520
|
+
)
|
|
35521
|
+
}
|
|
35522
|
+
) }),
|
|
35501
35523
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
35502
|
-
|
|
35524
|
+
blocks.TextArea,
|
|
35503
35525
|
{
|
|
35504
|
-
|
|
35505
|
-
|
|
35506
|
-
|
|
35507
|
-
|
|
35508
|
-
|
|
35509
|
-
|
|
35510
|
-
|
|
35511
|
-
|
|
35512
|
-
|
|
35513
|
-
attributionPosition: "bottom-left",
|
|
35514
|
-
fitView: true,
|
|
35515
|
-
minZoom: 0,
|
|
35516
|
-
isValidConnection: handleValidConnection
|
|
35526
|
+
className: "field-sizing-content",
|
|
35527
|
+
placeholder: "Explain a description",
|
|
35528
|
+
value: descriptionFieldProps.value ?? "",
|
|
35529
|
+
onChange: (event) => {
|
|
35530
|
+
void descriptionHelpers.setValue(event.target.value);
|
|
35531
|
+
},
|
|
35532
|
+
resize: "vertical",
|
|
35533
|
+
maxLength: 1e3,
|
|
35534
|
+
size: "md"
|
|
35517
35535
|
}
|
|
35518
35536
|
),
|
|
35519
|
-
/* @__PURE__ */ jsxRuntime.
|
|
35520
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
35521
|
-
|
|
35522
|
-
] }) }) }),
|
|
35523
|
-
/* @__PURE__ */ jsxRuntime.jsxs(react.Panel, { position: "top-right", className: "flex flex-col items-center gap-2", children: [
|
|
35524
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
35525
|
-
blocks.ToggleGroup.Root,
|
|
35537
|
+
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Card, { className: "size-full relative", variant: "outline", children: [
|
|
35538
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
35539
|
+
react.ReactFlow,
|
|
35526
35540
|
{
|
|
35527
|
-
|
|
35528
|
-
|
|
35529
|
-
|
|
35530
|
-
|
|
35531
|
-
|
|
35532
|
-
|
|
35533
|
-
|
|
35534
|
-
|
|
35535
|
-
|
|
35536
|
-
|
|
35541
|
+
ref,
|
|
35542
|
+
onInit: setReactFlow,
|
|
35543
|
+
nodes: layoutedNodes,
|
|
35544
|
+
onNodesChange: handleNodesChange,
|
|
35545
|
+
edges: layoutedEdges,
|
|
35546
|
+
onEdgesChange: handleEdgesChange,
|
|
35547
|
+
nodeTypes,
|
|
35548
|
+
edgeTypes,
|
|
35549
|
+
onConnect: handleConnect,
|
|
35550
|
+
attributionPosition: "bottom-left",
|
|
35551
|
+
fitView: true,
|
|
35552
|
+
minZoom: 0,
|
|
35553
|
+
isValidConnection: handleValidConnection
|
|
35537
35554
|
}
|
|
35538
35555
|
),
|
|
35539
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.
|
|
35540
|
-
|
|
35541
|
-
|
|
35542
|
-
|
|
35543
|
-
|
|
35544
|
-
|
|
35556
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Panel, { position: "top-left", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.ButtonGroup, { className: "flex items-center justify-end gap-2", size: "sm", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { type: "button", variant: "surface", onClick: handleAddSection, children: [
|
|
35557
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" }),
|
|
35558
|
+
" Add section"
|
|
35559
|
+
] }) }) }),
|
|
35560
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Panel, { position: "top-right", className: "flex flex-col items-center gap-2", children: [
|
|
35561
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
35562
|
+
blocks.ToggleGroup.Root,
|
|
35563
|
+
{
|
|
35564
|
+
className: "flex flex-col",
|
|
35565
|
+
type: "single",
|
|
35566
|
+
accentColor: "base",
|
|
35567
|
+
size: "sm",
|
|
35568
|
+
value: layoutDirection,
|
|
35569
|
+
onValueChange: setLayoutDirection,
|
|
35570
|
+
children: [
|
|
35571
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.ToggleGroup.IconItem, { className: "rounded-b-none", value: "LR", type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "arrow-right-left" }) }),
|
|
35572
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.ToggleGroup.IconItem, { className: "rounded-t-none", value: "TB", type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "arrow-down-up" }) })
|
|
35573
|
+
]
|
|
35574
|
+
}
|
|
35575
|
+
),
|
|
35576
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Separator, { size: "sm" }),
|
|
35577
|
+
/* @__PURE__ */ jsxRuntime.jsxs(blocks.ButtonGroup, { className: "flex flex-col ", size: "sm", accentColor: "base", variant: "soft", children: [
|
|
35578
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { className: "rounded-b-none", onClick: () => reactFlow == null ? void 0 : reactFlow.zoomIn(), type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" }) }),
|
|
35579
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { onClick: () => reactFlow == null ? void 0 : reactFlow.zoomOut(), radius: "none", type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "minus" }) }),
|
|
35580
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { className: "rounded-t-none", onClick: () => reactFlow == null ? void 0 : reactFlow.fitView(), type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "square-dashed" }) })
|
|
35581
|
+
] })
|
|
35582
|
+
] }),
|
|
35583
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Panel, { position: "bottom-right", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.ButtonGroup, { className: "flex items-center justify-end gap-2", size: "sm", children: [
|
|
35584
|
+
onCancel && /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", variant: "soft", accentColor: "base", onClick: onCancel, children: "Cancel" }),
|
|
35585
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "submit", variant: "surface", children: "Save" })
|
|
35586
|
+
] }) })
|
|
35545
35587
|
] }),
|
|
35546
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
35547
|
-
onCancel && /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", variant: "soft", accentColor: "base", onClick: onCancel, children: "Cancel" }),
|
|
35548
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "submit", variant: "surface", children: "Save" })
|
|
35549
|
-
] }) })
|
|
35588
|
+
!!errors.fields && /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "xs", accentColor: "danger", children: typeof errors.fields === "string" && errors.fields })
|
|
35550
35589
|
] });
|
|
35551
35590
|
});
|
|
35552
35591
|
FormBuilderFlowBuilder.displayName = "FormBuilderFlowBuilder";
|
|
35553
|
-
const FormBuilderListBuilder = React.memo((
|
|
35554
|
-
const { showFormTitle = true, showExplainerText = true } = props;
|
|
35592
|
+
const FormBuilderListBuilder = React.memo(() => {
|
|
35555
35593
|
const { handleSubmit, errors } = formik.useFormikContext();
|
|
35556
35594
|
const { onCancel } = React.use(FormBuilderContext);
|
|
35557
35595
|
const fieldSchema = React.use(FieldSchemaContext);
|
|
@@ -35561,43 +35599,41 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35561
35599
|
const [titleFieldProps, titleMeta, titleHelpers] = formik.useField("title");
|
|
35562
35600
|
const [descriptionFieldProps, _descriptionMeta, descriptionHelpers] = formik.useField("description");
|
|
35563
35601
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
35564
|
-
|
|
35602
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { accentColor: "base", size: "sm", children: "Create your form using various field types. Sections can be conditionally rendered based on answers to fields in preceding sections." }),
|
|
35565
35603
|
/* @__PURE__ */ jsxRuntime.jsxs("form", { className: "flex flex-col gap-4", id: formId, onSubmit: handleSubmit, children: [
|
|
35566
|
-
|
|
35567
|
-
|
|
35568
|
-
|
|
35569
|
-
|
|
35570
|
-
|
|
35571
|
-
|
|
35572
|
-
|
|
35573
|
-
|
|
35574
|
-
|
|
35575
|
-
|
|
35576
|
-
|
|
35577
|
-
|
|
35578
|
-
|
|
35579
|
-
|
|
35580
|
-
|
|
35581
|
-
|
|
35582
|
-
|
|
35583
|
-
|
|
35584
|
-
|
|
35585
|
-
|
|
35586
|
-
|
|
35587
|
-
|
|
35588
|
-
|
|
35589
|
-
|
|
35590
|
-
|
|
35591
|
-
|
|
35592
|
-
|
|
35593
|
-
|
|
35594
|
-
|
|
35595
|
-
|
|
35596
|
-
|
|
35597
|
-
|
|
35598
|
-
|
|
35599
|
-
)
|
|
35600
|
-
] }),
|
|
35604
|
+
/* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { severity: "danger", helpText: titleMeta.error ?? null, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
35605
|
+
blocks.Input.Root,
|
|
35606
|
+
{
|
|
35607
|
+
variant: "outline",
|
|
35608
|
+
size: "md",
|
|
35609
|
+
accentColor: titleMeta.error ? SEVERITY_COLOR_MAPPING.danger : "primary",
|
|
35610
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
35611
|
+
blocks.Input.Field,
|
|
35612
|
+
{
|
|
35613
|
+
placeholder: "Enter a title",
|
|
35614
|
+
value: titleFieldProps.value ?? "",
|
|
35615
|
+
onChange: (event) => {
|
|
35616
|
+
void titleHelpers.setValue(event.target.value);
|
|
35617
|
+
},
|
|
35618
|
+
maxLength: 100
|
|
35619
|
+
}
|
|
35620
|
+
)
|
|
35621
|
+
}
|
|
35622
|
+
) }),
|
|
35623
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
35624
|
+
blocks.TextArea,
|
|
35625
|
+
{
|
|
35626
|
+
className: "field-sizing-content",
|
|
35627
|
+
placeholder: "Explain a description",
|
|
35628
|
+
value: descriptionFieldProps.value ?? "",
|
|
35629
|
+
onChange: (event) => {
|
|
35630
|
+
void descriptionHelpers.setValue(event.target.value);
|
|
35631
|
+
},
|
|
35632
|
+
resize: "vertical",
|
|
35633
|
+
maxLength: 1e3,
|
|
35634
|
+
size: "md"
|
|
35635
|
+
}
|
|
35636
|
+
),
|
|
35601
35637
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
35602
35638
|
fieldSchema.fields.map((fieldSection, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
35603
35639
|
FieldSectionWithActions,
|
|
@@ -35788,45 +35824,53 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35788
35824
|
errors.fields = "At least one field is required.";
|
|
35789
35825
|
}
|
|
35790
35826
|
let fieldsToValidate = [];
|
|
35791
|
-
for (const [sectionIndex, section] of form.fields.entries())
|
|
35827
|
+
for (const [sectionIndex, section] of form.fields.entries())
|
|
35792
35828
|
for (const [fieldIndex, field] of section.fields.entries()) {
|
|
35793
35829
|
let fieldSettings = [];
|
|
35794
|
-
|
|
35795
|
-
|
|
35796
|
-
|
|
35797
|
-
|
|
35798
|
-
|
|
35799
|
-
|
|
35800
|
-
|
|
35801
|
-
|
|
35802
|
-
|
|
35803
|
-
|
|
35804
|
-
|
|
35805
|
-
|
|
35806
|
-
|
|
35807
|
-
|
|
35808
|
-
|
|
35809
|
-
|
|
35810
|
-
|
|
35811
|
-
|
|
35812
|
-
|
|
35813
|
-
|
|
35814
|
-
|
|
35815
|
-
|
|
35816
|
-
|
|
35817
|
-
|
|
35818
|
-
|
|
35819
|
-
|
|
35820
|
-
|
|
35821
|
-
|
|
35822
|
-
|
|
35823
|
-
|
|
35824
|
-
|
|
35825
|
-
|
|
35830
|
+
switch (field.type) {
|
|
35831
|
+
case "text":
|
|
35832
|
+
fieldSettings = TextField.getFieldCreationSchema(
|
|
35833
|
+
`fields.${sectionIndex}.fields.${fieldIndex}`
|
|
35834
|
+
).map((field2) => field2.field);
|
|
35835
|
+
break;
|
|
35836
|
+
case "number":
|
|
35837
|
+
fieldSettings = NumberField.getFieldCreationSchema(
|
|
35838
|
+
`fields.${sectionIndex}.fields.${fieldIndex}`
|
|
35839
|
+
).map((field2) => field2.field);
|
|
35840
|
+
break;
|
|
35841
|
+
case "string":
|
|
35842
|
+
fieldSettings = StringField.getFieldCreationSchema(
|
|
35843
|
+
`fields.${sectionIndex}.fields.${fieldIndex}`
|
|
35844
|
+
).map((field2) => field2.field);
|
|
35845
|
+
break;
|
|
35846
|
+
case "select":
|
|
35847
|
+
fieldSettings = SelectField.getFieldCreationSchema(
|
|
35848
|
+
`fields.${sectionIndex}.fields.${fieldIndex}`
|
|
35849
|
+
).map((field2) => field2.field);
|
|
35850
|
+
break;
|
|
35851
|
+
case "multi-select":
|
|
35852
|
+
fieldSettings = MultiSelectField.getFieldCreationSchema(
|
|
35853
|
+
`fields.${sectionIndex}.fields.${fieldIndex}`
|
|
35854
|
+
).map((field2) => field2.field);
|
|
35855
|
+
break;
|
|
35856
|
+
case "upload":
|
|
35857
|
+
fieldSettings = UploadField.getFieldCreationSchema(
|
|
35858
|
+
`fields.${sectionIndex}.fields.${fieldIndex}`
|
|
35859
|
+
).map((field2) => field2.field);
|
|
35860
|
+
break;
|
|
35861
|
+
case "radio":
|
|
35862
|
+
fieldSettings = RadioField.getFieldCreationSchema(
|
|
35863
|
+
`fields.${sectionIndex}.fields.${fieldIndex}`
|
|
35864
|
+
).map((field2) => field2.field);
|
|
35865
|
+
break;
|
|
35866
|
+
case "checkbox-list":
|
|
35867
|
+
fieldSettings = fieldSettings = CheckboxListField.getFieldCreationSchema(
|
|
35868
|
+
`fields.${sectionIndex}.fields.${fieldIndex}`
|
|
35869
|
+
).map((field2) => field2.field);
|
|
35870
|
+
break;
|
|
35826
35871
|
}
|
|
35827
35872
|
fieldsToValidate = [...fieldsToValidate, ...fieldSettings];
|
|
35828
35873
|
}
|
|
35829
|
-
}
|
|
35830
35874
|
const fieldErrors = validateFields(fieldsToValidate, form);
|
|
35831
35875
|
if (fieldErrors) {
|
|
35832
35876
|
errors.fields = fieldErrors.fields;
|
|
@@ -35857,16 +35901,17 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35857
35901
|
validateOnBlur: false,
|
|
35858
35902
|
enableReinitialize
|
|
35859
35903
|
});
|
|
35860
|
-
const schema = React.useMemo(() => FieldSchema.deserialize(formik$1.values.fields), [formik$1.values.fields]);
|
|
35861
35904
|
const observer = React.useCallback(
|
|
35862
35905
|
(fieldSchema) => {
|
|
35863
35906
|
formik$1.setFieldValue("fields", fieldSchema.serialize());
|
|
35864
35907
|
},
|
|
35865
35908
|
[formik$1]
|
|
35866
35909
|
);
|
|
35867
|
-
React.
|
|
35868
|
-
|
|
35869
|
-
|
|
35910
|
+
const schema = React.useMemo(() => {
|
|
35911
|
+
const schema2 = FieldSchema.deserialize(formik$1.values.fields);
|
|
35912
|
+
schema2.observe(observer);
|
|
35913
|
+
return schema2;
|
|
35914
|
+
}, [formik$1.values.fields, observer]);
|
|
35870
35915
|
const contextValue = React.useMemo(() => {
|
|
35871
35916
|
return {
|
|
35872
35917
|
disableRequiredFields,
|