@overmap-ai/forms 1.0.32-react-flow-david-fixes.8 → 1.0.32-react-flow-david-fixes.10
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 +2 -0
- package/dist/form/builder/context.d.ts +2 -0
- package/dist/form/fields/utils.d.ts +3 -3
- package/dist/form/schema/FieldSchema.d.ts +3 -0
- package/dist/form/utils.d.ts +1 -1
- package/dist/forms.js +85 -87
- package/dist/forms.umd.cjs +85 -87
- package/package.json +1 -1
|
@@ -7,6 +7,8 @@ export interface FormBuilderRootProps extends PropsWithChildren {
|
|
|
7
7
|
initialFields?: SerializedFieldSection[];
|
|
8
8
|
onSave: FormBuilderSaveHandler;
|
|
9
9
|
onCancel?: () => void;
|
|
10
|
+
hideTitle?: boolean;
|
|
11
|
+
hideDescription?: boolean;
|
|
10
12
|
enableReinitialize?: boolean;
|
|
11
13
|
disableRequiredFields?: boolean;
|
|
12
14
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FieldValues, SerializedFieldValues } from '../typings';
|
|
2
2
|
import { FieldSection } from './FieldSection';
|
|
3
|
-
import {
|
|
3
|
+
import { Field, SerializedField, SerializedOnlyField } from './typings';
|
|
4
4
|
export declare const deserializeField: (serializedField: SerializedOnlyField) => Field;
|
|
5
5
|
export declare const deserialize: (serialized: SerializedField) => Field | FieldSection;
|
|
6
6
|
export declare function deserializeFields(fields: SerializedField[]): (Field | FieldSection)[];
|
|
7
7
|
export declare function deserializeOnlyFields(fields: SerializedOnlyField[]): Field[];
|
|
8
8
|
export declare function flattenFields(fields: (Field | FieldSection)[]): Field[];
|
|
9
9
|
export declare function getFieldsMapping(fields: (Field | FieldSection)[]): Record<string, Field>;
|
|
10
|
-
export declare function serializeFieldValues(fields:
|
|
11
|
-
export declare function deserializeFieldValues(fields:
|
|
10
|
+
export declare function serializeFieldValues(fields: Field[], values: FieldValues): SerializedFieldValues;
|
|
11
|
+
export declare function deserializeFieldValues(fields: Field[], values: SerializedFieldValues): FieldValues;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FieldSection, FieldsManager, SerializedFieldSection } from '../fields';
|
|
2
2
|
import { Observable } from '../observable/Observable';
|
|
3
|
+
import { FieldValues, SerializedFieldValues } from '../typings';
|
|
3
4
|
export declare class FieldSchema extends Observable<FieldSchema> implements FieldsManager<FieldSection> {
|
|
4
5
|
fields: FieldSection[];
|
|
5
6
|
constructor(fields: FieldSection[]);
|
|
@@ -13,4 +14,6 @@ export declare class FieldSchema extends Observable<FieldSchema> implements Fiel
|
|
|
13
14
|
removeField(field: FieldSection): void;
|
|
14
15
|
removeFields(fields: FieldSection[]): void;
|
|
15
16
|
moveField(sourceIndex: number, targetIndex: number): void;
|
|
17
|
+
deserializeValues(values: SerializedFieldValues): FieldValues;
|
|
18
|
+
serializeValues(values: FieldValues): SerializedFieldValues;
|
|
16
19
|
}
|
package/dist/form/utils.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { FormBuilderValues } from './builder';
|
|
|
3
3
|
import { AnyFormElement, FieldValue, SerializedFieldSection } from './fields';
|
|
4
4
|
import { FieldValues } from './typings';
|
|
5
5
|
export declare const hasKeys: (errors: object) => boolean;
|
|
6
|
-
export declare const validateFields: (fields: AnyFormElement[], values: FieldValues
|
|
6
|
+
export declare const validateFields: (fields: AnyFormElement[], values: FieldValues) => FormikErrors<FieldValues | FormBuilderValues> | undefined;
|
|
7
7
|
export declare const initializeFieldValues: (fields: AnyFormElement[], values: FieldValues) => FieldValues;
|
|
8
8
|
export declare const changedFieldValues: (fields: AnyFormElement[], values1: FieldValues, values2: FieldValues) => FieldValues;
|
|
9
9
|
export declare const separateFilesFromFieldValues: (values: FieldValues) => {
|
package/dist/forms.js
CHANGED
|
@@ -34480,6 +34480,12 @@ class FieldSchema extends Observable {
|
|
|
34480
34480
|
this.fields = this.initFields(newFields);
|
|
34481
34481
|
this.notify(this);
|
|
34482
34482
|
}
|
|
34483
|
+
deserializeValues(values) {
|
|
34484
|
+
return deserializeFieldValues(flattenFields(this.fields), values);
|
|
34485
|
+
}
|
|
34486
|
+
serializeValues(values) {
|
|
34487
|
+
return serializeFieldValues(flattenFields(this.fields), values);
|
|
34488
|
+
}
|
|
34483
34489
|
}
|
|
34484
34490
|
const FieldSchemaContext = createContext(new FieldSchema([]));
|
|
34485
34491
|
const FormBuilderContext = createContext({});
|
|
@@ -34492,9 +34498,9 @@ const validateFields = (fields, values) => {
|
|
|
34492
34498
|
for (const field of fields) {
|
|
34493
34499
|
if (field instanceof FieldSection) {
|
|
34494
34500
|
const conditionalSections = sectionElements.filter((section) => field.identifier in section.conditions);
|
|
34495
|
-
const conditionMet = conditionalSections.some(
|
|
34496
|
-
(conditionalSection) => applyConditions(conditionalSection.getConditions(field.identifier),
|
|
34497
|
-
);
|
|
34501
|
+
const conditionMet = conditionalSections.length > 0 ? conditionalSections.some(
|
|
34502
|
+
(conditionalSection) => applyConditions(conditionalSection.getConditions(field.identifier), values)
|
|
34503
|
+
) : true;
|
|
34498
34504
|
if (!conditionMet) continue;
|
|
34499
34505
|
Object.assign(errors, field.getErrors(values));
|
|
34500
34506
|
} else {
|
|
@@ -35478,9 +35484,12 @@ const getLayoutedElements = (nodes, edges, direction) => {
|
|
|
35478
35484
|
edges
|
|
35479
35485
|
];
|
|
35480
35486
|
};
|
|
35487
|
+
const proOptions = {
|
|
35488
|
+
hideAttribution: true
|
|
35489
|
+
};
|
|
35481
35490
|
const FormBuilderFlowBuilder = memo(() => {
|
|
35482
35491
|
const { handleSubmit, errors } = useFormikContext();
|
|
35483
|
-
const { onCancel } = use(FormBuilderContext);
|
|
35492
|
+
const { hideTitle, hideDescription, onCancel } = use(FormBuilderContext);
|
|
35484
35493
|
const fieldSchema = use(FieldSchemaContext);
|
|
35485
35494
|
const ref = useRef(null);
|
|
35486
35495
|
const [reactFlow, setReactFlow] = useState();
|
|
@@ -35571,7 +35580,7 @@ const FormBuilderFlowBuilder = memo(() => {
|
|
|
35571
35580
|
const [titleFieldProps, titleMeta, titleHelpers] = useField("title");
|
|
35572
35581
|
const [descriptionFieldProps, _descriptionMeta, descriptionHelpers] = useField("description");
|
|
35573
35582
|
return /* @__PURE__ */ jsxs("form", { className: "size-full flex flex-col gap-4", id: formId, onSubmit: handleSubmit, children: [
|
|
35574
|
-
/* @__PURE__ */ jsx(InputWithHelpText, { severity: "danger", helpText: titleMeta.error ?? null, children: /* @__PURE__ */ jsx(
|
|
35583
|
+
!hideTitle && /* @__PURE__ */ jsx(InputWithHelpText, { severity: "danger", helpText: titleMeta.error ?? null, children: /* @__PURE__ */ jsx(
|
|
35575
35584
|
Input.Root,
|
|
35576
35585
|
{
|
|
35577
35586
|
variant: "outline",
|
|
@@ -35590,7 +35599,7 @@ const FormBuilderFlowBuilder = memo(() => {
|
|
|
35590
35599
|
)
|
|
35591
35600
|
}
|
|
35592
35601
|
) }),
|
|
35593
|
-
/* @__PURE__ */ jsx(
|
|
35602
|
+
!hideDescription && /* @__PURE__ */ jsx(
|
|
35594
35603
|
TextArea,
|
|
35595
35604
|
{
|
|
35596
35605
|
className: "field-sizing-content",
|
|
@@ -35620,7 +35629,8 @@ const FormBuilderFlowBuilder = memo(() => {
|
|
|
35620
35629
|
attributionPosition: "bottom-left",
|
|
35621
35630
|
fitView: true,
|
|
35622
35631
|
minZoom: 0,
|
|
35623
|
-
isValidConnection: handleValidConnection
|
|
35632
|
+
isValidConnection: handleValidConnection,
|
|
35633
|
+
proOptions
|
|
35624
35634
|
}
|
|
35625
35635
|
),
|
|
35626
35636
|
/* @__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: [
|
|
@@ -35661,79 +35671,69 @@ const FormBuilderFlowBuilder = memo(() => {
|
|
|
35661
35671
|
FormBuilderFlowBuilder.displayName = "FormBuilderFlowBuilder";
|
|
35662
35672
|
const FormBuilderListBuilder = memo(() => {
|
|
35663
35673
|
const { handleSubmit, errors } = useFormikContext();
|
|
35664
|
-
const { onCancel } = use(FormBuilderContext);
|
|
35674
|
+
const { hideTitle, hideDescription, onCancel } = use(FormBuilderContext);
|
|
35665
35675
|
const fieldSchema = use(FieldSchemaContext);
|
|
35666
35676
|
const handleCreateEmptySection = useCallback(() => {
|
|
35667
35677
|
fieldSchema.addField(new FieldSection({ identifier: v4(), fields: [] }));
|
|
35668
35678
|
}, [fieldSchema]);
|
|
35669
35679
|
const [titleFieldProps, titleMeta, titleHelpers] = useField("title");
|
|
35670
35680
|
const [descriptionFieldProps, _descriptionMeta, descriptionHelpers] = useField("description");
|
|
35671
|
-
return /* @__PURE__ */ jsxs("
|
|
35672
|
-
/* @__PURE__ */ jsx(
|
|
35673
|
-
|
|
35674
|
-
|
|
35675
|
-
|
|
35676
|
-
|
|
35677
|
-
|
|
35678
|
-
|
|
35679
|
-
|
|
35680
|
-
children: /* @__PURE__ */ jsx(
|
|
35681
|
-
Input.Field,
|
|
35682
|
-
{
|
|
35683
|
-
placeholder: "Enter a title",
|
|
35684
|
-
value: titleFieldProps.value ?? "",
|
|
35685
|
-
onChange: (event) => {
|
|
35686
|
-
void titleHelpers.setValue(event.target.value);
|
|
35687
|
-
},
|
|
35688
|
-
maxLength: 100
|
|
35689
|
-
}
|
|
35690
|
-
)
|
|
35691
|
-
}
|
|
35692
|
-
) }),
|
|
35693
|
-
/* @__PURE__ */ jsx(
|
|
35694
|
-
TextArea,
|
|
35695
|
-
{
|
|
35696
|
-
className: "field-sizing-content",
|
|
35697
|
-
placeholder: "Explain a description",
|
|
35698
|
-
value: descriptionFieldProps.value ?? "",
|
|
35699
|
-
onChange: (event) => {
|
|
35700
|
-
void descriptionHelpers.setValue(event.target.value);
|
|
35701
|
-
},
|
|
35702
|
-
resize: "vertical",
|
|
35703
|
-
maxLength: 1e3,
|
|
35704
|
-
size: "md"
|
|
35705
|
-
}
|
|
35706
|
-
),
|
|
35707
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
35708
|
-
fieldSchema.fields.map((fieldSection, index) => /* @__PURE__ */ jsx(
|
|
35709
|
-
FieldSectionWithActions,
|
|
35710
|
-
{
|
|
35711
|
-
fieldSection,
|
|
35712
|
-
index
|
|
35713
|
-
},
|
|
35714
|
-
fieldSection.identifier
|
|
35715
|
-
)),
|
|
35716
|
-
/* @__PURE__ */ jsxs(
|
|
35717
|
-
Button,
|
|
35681
|
+
return /* @__PURE__ */ jsxs("form", { className: "flex flex-col gap-4", id: formId, onSubmit: handleSubmit, children: [
|
|
35682
|
+
!hideTitle && /* @__PURE__ */ jsx(InputWithHelpText, { severity: "danger", helpText: titleMeta.error ?? null, children: /* @__PURE__ */ jsx(
|
|
35683
|
+
Input.Root,
|
|
35684
|
+
{
|
|
35685
|
+
variant: "outline",
|
|
35686
|
+
size: "md",
|
|
35687
|
+
accentColor: titleMeta.error ? SEVERITY_COLOR_MAPPING.danger : "primary",
|
|
35688
|
+
children: /* @__PURE__ */ jsx(
|
|
35689
|
+
Input.Field,
|
|
35718
35690
|
{
|
|
35719
|
-
|
|
35720
|
-
|
|
35721
|
-
|
|
35722
|
-
|
|
35723
|
-
|
|
35724
|
-
|
|
35725
|
-
children: [
|
|
35726
|
-
/* @__PURE__ */ jsx(LuIcon, { icon: "plus" }),
|
|
35727
|
-
" Add section"
|
|
35728
|
-
]
|
|
35691
|
+
placeholder: "Enter a title",
|
|
35692
|
+
value: titleFieldProps.value ?? "",
|
|
35693
|
+
onChange: (event) => {
|
|
35694
|
+
void titleHelpers.setValue(event.target.value);
|
|
35695
|
+
},
|
|
35696
|
+
maxLength: 100
|
|
35729
35697
|
}
|
|
35730
35698
|
)
|
|
35731
|
-
|
|
35732
|
-
|
|
35733
|
-
|
|
35734
|
-
|
|
35735
|
-
|
|
35736
|
-
|
|
35699
|
+
}
|
|
35700
|
+
) }),
|
|
35701
|
+
!hideDescription && /* @__PURE__ */ jsx(
|
|
35702
|
+
TextArea,
|
|
35703
|
+
{
|
|
35704
|
+
className: "field-sizing-content",
|
|
35705
|
+
placeholder: "Explain a description",
|
|
35706
|
+
value: descriptionFieldProps.value ?? "",
|
|
35707
|
+
onChange: (event) => {
|
|
35708
|
+
void descriptionHelpers.setValue(event.target.value);
|
|
35709
|
+
},
|
|
35710
|
+
resize: "vertical",
|
|
35711
|
+
maxLength: 1e3,
|
|
35712
|
+
size: "md"
|
|
35713
|
+
}
|
|
35714
|
+
),
|
|
35715
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
35716
|
+
fieldSchema.fields.map((fieldSection, index) => /* @__PURE__ */ jsx(FieldSectionWithActions, { fieldSection, index }, fieldSection.identifier)),
|
|
35717
|
+
/* @__PURE__ */ jsxs(
|
|
35718
|
+
Button,
|
|
35719
|
+
{
|
|
35720
|
+
className: "mb-4",
|
|
35721
|
+
type: "button",
|
|
35722
|
+
variant: "soft",
|
|
35723
|
+
accentColor: "base",
|
|
35724
|
+
size: "sm",
|
|
35725
|
+
onClick: handleCreateEmptySection,
|
|
35726
|
+
children: [
|
|
35727
|
+
/* @__PURE__ */ jsx(LuIcon, { icon: "plus" }),
|
|
35728
|
+
" Add section"
|
|
35729
|
+
]
|
|
35730
|
+
}
|
|
35731
|
+
)
|
|
35732
|
+
] }),
|
|
35733
|
+
!!errors.fields && /* @__PURE__ */ jsx(Text, { size: "xs", accentColor: "danger", children: typeof errors.fields === "string" && errors.fields }),
|
|
35734
|
+
/* @__PURE__ */ jsxs(ButtonGroup, { className: "flex items-center justify-end gap-2", size: "sm", children: [
|
|
35735
|
+
onCancel && /* @__PURE__ */ jsx(Button, { type: "button", variant: "soft", accentColor: "base", onClick: onCancel, children: "Cancel" }),
|
|
35736
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", variant: "surface", children: "Save" })
|
|
35737
35737
|
] })
|
|
35738
35738
|
] });
|
|
35739
35739
|
});
|
|
@@ -35835,20 +35835,10 @@ const FormRenderer = memo(
|
|
|
35835
35835
|
]
|
|
35836
35836
|
}
|
|
35837
35837
|
),
|
|
35838
|
-
/* @__PURE__ */ jsxs(
|
|
35839
|
-
|
|
35840
|
-
|
|
35841
|
-
|
|
35842
|
-
type: "submit",
|
|
35843
|
-
disabled: !formik.isValid,
|
|
35844
|
-
accentColor: "primary",
|
|
35845
|
-
variant: "surface",
|
|
35846
|
-
children: [
|
|
35847
|
-
/* @__PURE__ */ jsx(LuIcon, { icon: "check" }),
|
|
35848
|
-
submitText
|
|
35849
|
-
]
|
|
35850
|
-
}
|
|
35851
|
-
)
|
|
35838
|
+
/* @__PURE__ */ jsxs(Button, { ...buttonProps, type: "submit", accentColor: "primary", variant: "surface", children: [
|
|
35839
|
+
/* @__PURE__ */ jsx(LuIcon, { icon: "check" }),
|
|
35840
|
+
submitText
|
|
35841
|
+
] })
|
|
35852
35842
|
] })
|
|
35853
35843
|
]
|
|
35854
35844
|
}
|
|
@@ -35880,6 +35870,8 @@ const FormBuilderRoot = memo((props) => {
|
|
|
35880
35870
|
initialFields,
|
|
35881
35871
|
onSave,
|
|
35882
35872
|
onCancel,
|
|
35873
|
+
hideTitle = false,
|
|
35874
|
+
hideDescription = false,
|
|
35883
35875
|
enableReinitialize = false,
|
|
35884
35876
|
disableRequiredFields = false
|
|
35885
35877
|
} = props;
|
|
@@ -35941,7 +35933,11 @@ const FormBuilderRoot = memo((props) => {
|
|
|
35941
35933
|
}
|
|
35942
35934
|
fieldsToValidate = [...fieldsToValidate, ...fieldSettings];
|
|
35943
35935
|
}
|
|
35944
|
-
const
|
|
35936
|
+
const values = {};
|
|
35937
|
+
for (const field of fieldsToValidate) {
|
|
35938
|
+
values[field.identifier] = get(form, field.identifier);
|
|
35939
|
+
}
|
|
35940
|
+
const fieldErrors = validateFields(fieldsToValidate, values);
|
|
35945
35941
|
if (fieldErrors) {
|
|
35946
35942
|
errors.fields = fieldErrors.fields;
|
|
35947
35943
|
}
|
|
@@ -35984,10 +35980,12 @@ const FormBuilderRoot = memo((props) => {
|
|
|
35984
35980
|
}, [formik.values.fields, observer]);
|
|
35985
35981
|
const contextValue = useMemo(() => {
|
|
35986
35982
|
return {
|
|
35983
|
+
hideTitle,
|
|
35984
|
+
hideDescription,
|
|
35987
35985
|
disableRequiredFields,
|
|
35988
35986
|
onCancel
|
|
35989
35987
|
};
|
|
35990
|
-
}, [disableRequiredFields, onCancel]);
|
|
35988
|
+
}, [disableRequiredFields, hideDescription, hideTitle, onCancel]);
|
|
35991
35989
|
return /* @__PURE__ */ jsx(FormBuilderContext, { value: contextValue, children: /* @__PURE__ */ jsx(FieldSchemaContext, { value: schema, children: /* @__PURE__ */ jsx(FormikProvider, { value: formik, children }) }) });
|
|
35992
35990
|
});
|
|
35993
35991
|
FormBuilderRoot.displayName = "FormBuilderRoot";
|
package/dist/forms.umd.cjs
CHANGED
|
@@ -34482,6 +34482,12 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
34482
34482
|
this.fields = this.initFields(newFields);
|
|
34483
34483
|
this.notify(this);
|
|
34484
34484
|
}
|
|
34485
|
+
deserializeValues(values) {
|
|
34486
|
+
return deserializeFieldValues(flattenFields(this.fields), values);
|
|
34487
|
+
}
|
|
34488
|
+
serializeValues(values) {
|
|
34489
|
+
return serializeFieldValues(flattenFields(this.fields), values);
|
|
34490
|
+
}
|
|
34485
34491
|
}
|
|
34486
34492
|
const FieldSchemaContext = React.createContext(new FieldSchema([]));
|
|
34487
34493
|
const FormBuilderContext = React.createContext({});
|
|
@@ -34494,9 +34500,9 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
34494
34500
|
for (const field of fields) {
|
|
34495
34501
|
if (field instanceof FieldSection) {
|
|
34496
34502
|
const conditionalSections = sectionElements.filter((section) => field.identifier in section.conditions);
|
|
34497
|
-
const conditionMet = conditionalSections.some(
|
|
34498
|
-
(conditionalSection) => applyConditions(conditionalSection.getConditions(field.identifier),
|
|
34499
|
-
);
|
|
34503
|
+
const conditionMet = conditionalSections.length > 0 ? conditionalSections.some(
|
|
34504
|
+
(conditionalSection) => applyConditions(conditionalSection.getConditions(field.identifier), values)
|
|
34505
|
+
) : true;
|
|
34500
34506
|
if (!conditionMet) continue;
|
|
34501
34507
|
Object.assign(errors, field.getErrors(values));
|
|
34502
34508
|
} else {
|
|
@@ -35480,9 +35486,12 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35480
35486
|
edges
|
|
35481
35487
|
];
|
|
35482
35488
|
};
|
|
35489
|
+
const proOptions = {
|
|
35490
|
+
hideAttribution: true
|
|
35491
|
+
};
|
|
35483
35492
|
const FormBuilderFlowBuilder = React.memo(() => {
|
|
35484
35493
|
const { handleSubmit, errors } = formik.useFormikContext();
|
|
35485
|
-
const { onCancel } = React.use(FormBuilderContext);
|
|
35494
|
+
const { hideTitle, hideDescription, onCancel } = React.use(FormBuilderContext);
|
|
35486
35495
|
const fieldSchema = React.use(FieldSchemaContext);
|
|
35487
35496
|
const ref = React.useRef(null);
|
|
35488
35497
|
const [reactFlow, setReactFlow] = React.useState();
|
|
@@ -35573,7 +35582,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35573
35582
|
const [titleFieldProps, titleMeta, titleHelpers] = formik.useField("title");
|
|
35574
35583
|
const [descriptionFieldProps, _descriptionMeta, descriptionHelpers] = formik.useField("description");
|
|
35575
35584
|
return /* @__PURE__ */ jsxRuntime.jsxs("form", { className: "size-full flex flex-col gap-4", id: formId, onSubmit: handleSubmit, children: [
|
|
35576
|
-
/* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { severity: "danger", helpText: titleMeta.error ?? null, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
35585
|
+
!hideTitle && /* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { severity: "danger", helpText: titleMeta.error ?? null, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
35577
35586
|
blocks.Input.Root,
|
|
35578
35587
|
{
|
|
35579
35588
|
variant: "outline",
|
|
@@ -35592,7 +35601,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35592
35601
|
)
|
|
35593
35602
|
}
|
|
35594
35603
|
) }),
|
|
35595
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
35604
|
+
!hideDescription && /* @__PURE__ */ jsxRuntime.jsx(
|
|
35596
35605
|
blocks.TextArea,
|
|
35597
35606
|
{
|
|
35598
35607
|
className: "field-sizing-content",
|
|
@@ -35622,7 +35631,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35622
35631
|
attributionPosition: "bottom-left",
|
|
35623
35632
|
fitView: true,
|
|
35624
35633
|
minZoom: 0,
|
|
35625
|
-
isValidConnection: handleValidConnection
|
|
35634
|
+
isValidConnection: handleValidConnection,
|
|
35635
|
+
proOptions
|
|
35626
35636
|
}
|
|
35627
35637
|
),
|
|
35628
35638
|
/* @__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: [
|
|
@@ -35663,79 +35673,69 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35663
35673
|
FormBuilderFlowBuilder.displayName = "FormBuilderFlowBuilder";
|
|
35664
35674
|
const FormBuilderListBuilder = React.memo(() => {
|
|
35665
35675
|
const { handleSubmit, errors } = formik.useFormikContext();
|
|
35666
|
-
const { onCancel } = React.use(FormBuilderContext);
|
|
35676
|
+
const { hideTitle, hideDescription, onCancel } = React.use(FormBuilderContext);
|
|
35667
35677
|
const fieldSchema = React.use(FieldSchemaContext);
|
|
35668
35678
|
const handleCreateEmptySection = React.useCallback(() => {
|
|
35669
35679
|
fieldSchema.addField(new FieldSection({ identifier: uuid.v4(), fields: [] }));
|
|
35670
35680
|
}, [fieldSchema]);
|
|
35671
35681
|
const [titleFieldProps, titleMeta, titleHelpers] = formik.useField("title");
|
|
35672
35682
|
const [descriptionFieldProps, _descriptionMeta, descriptionHelpers] = formik.useField("description");
|
|
35673
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("
|
|
35674
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
35675
|
-
|
|
35676
|
-
|
|
35677
|
-
|
|
35678
|
-
|
|
35679
|
-
|
|
35680
|
-
|
|
35681
|
-
|
|
35682
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
35683
|
-
blocks.Input.Field,
|
|
35684
|
-
{
|
|
35685
|
-
placeholder: "Enter a title",
|
|
35686
|
-
value: titleFieldProps.value ?? "",
|
|
35687
|
-
onChange: (event) => {
|
|
35688
|
-
void titleHelpers.setValue(event.target.value);
|
|
35689
|
-
},
|
|
35690
|
-
maxLength: 100
|
|
35691
|
-
}
|
|
35692
|
-
)
|
|
35693
|
-
}
|
|
35694
|
-
) }),
|
|
35695
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
35696
|
-
blocks.TextArea,
|
|
35697
|
-
{
|
|
35698
|
-
className: "field-sizing-content",
|
|
35699
|
-
placeholder: "Explain a description",
|
|
35700
|
-
value: descriptionFieldProps.value ?? "",
|
|
35701
|
-
onChange: (event) => {
|
|
35702
|
-
void descriptionHelpers.setValue(event.target.value);
|
|
35703
|
-
},
|
|
35704
|
-
resize: "vertical",
|
|
35705
|
-
maxLength: 1e3,
|
|
35706
|
-
size: "md"
|
|
35707
|
-
}
|
|
35708
|
-
),
|
|
35709
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
35710
|
-
fieldSchema.fields.map((fieldSection, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
35711
|
-
FieldSectionWithActions,
|
|
35712
|
-
{
|
|
35713
|
-
fieldSection,
|
|
35714
|
-
index
|
|
35715
|
-
},
|
|
35716
|
-
fieldSection.identifier
|
|
35717
|
-
)),
|
|
35718
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
35719
|
-
blocks.Button,
|
|
35683
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("form", { className: "flex flex-col gap-4", id: formId, onSubmit: handleSubmit, children: [
|
|
35684
|
+
!hideTitle && /* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { severity: "danger", helpText: titleMeta.error ?? null, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
35685
|
+
blocks.Input.Root,
|
|
35686
|
+
{
|
|
35687
|
+
variant: "outline",
|
|
35688
|
+
size: "md",
|
|
35689
|
+
accentColor: titleMeta.error ? SEVERITY_COLOR_MAPPING.danger : "primary",
|
|
35690
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
35691
|
+
blocks.Input.Field,
|
|
35720
35692
|
{
|
|
35721
|
-
|
|
35722
|
-
|
|
35723
|
-
|
|
35724
|
-
|
|
35725
|
-
|
|
35726
|
-
|
|
35727
|
-
children: [
|
|
35728
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" }),
|
|
35729
|
-
" Add section"
|
|
35730
|
-
]
|
|
35693
|
+
placeholder: "Enter a title",
|
|
35694
|
+
value: titleFieldProps.value ?? "",
|
|
35695
|
+
onChange: (event) => {
|
|
35696
|
+
void titleHelpers.setValue(event.target.value);
|
|
35697
|
+
},
|
|
35698
|
+
maxLength: 100
|
|
35731
35699
|
}
|
|
35732
35700
|
)
|
|
35733
|
-
|
|
35734
|
-
|
|
35735
|
-
|
|
35736
|
-
|
|
35737
|
-
|
|
35738
|
-
|
|
35701
|
+
}
|
|
35702
|
+
) }),
|
|
35703
|
+
!hideDescription && /* @__PURE__ */ jsxRuntime.jsx(
|
|
35704
|
+
blocks.TextArea,
|
|
35705
|
+
{
|
|
35706
|
+
className: "field-sizing-content",
|
|
35707
|
+
placeholder: "Explain a description",
|
|
35708
|
+
value: descriptionFieldProps.value ?? "",
|
|
35709
|
+
onChange: (event) => {
|
|
35710
|
+
void descriptionHelpers.setValue(event.target.value);
|
|
35711
|
+
},
|
|
35712
|
+
resize: "vertical",
|
|
35713
|
+
maxLength: 1e3,
|
|
35714
|
+
size: "md"
|
|
35715
|
+
}
|
|
35716
|
+
),
|
|
35717
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
35718
|
+
fieldSchema.fields.map((fieldSection, index) => /* @__PURE__ */ jsxRuntime.jsx(FieldSectionWithActions, { fieldSection, index }, fieldSection.identifier)),
|
|
35719
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
35720
|
+
blocks.Button,
|
|
35721
|
+
{
|
|
35722
|
+
className: "mb-4",
|
|
35723
|
+
type: "button",
|
|
35724
|
+
variant: "soft",
|
|
35725
|
+
accentColor: "base",
|
|
35726
|
+
size: "sm",
|
|
35727
|
+
onClick: handleCreateEmptySection,
|
|
35728
|
+
children: [
|
|
35729
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" }),
|
|
35730
|
+
" Add section"
|
|
35731
|
+
]
|
|
35732
|
+
}
|
|
35733
|
+
)
|
|
35734
|
+
] }),
|
|
35735
|
+
!!errors.fields && /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "xs", accentColor: "danger", children: typeof errors.fields === "string" && errors.fields }),
|
|
35736
|
+
/* @__PURE__ */ jsxRuntime.jsxs(blocks.ButtonGroup, { className: "flex items-center justify-end gap-2", size: "sm", children: [
|
|
35737
|
+
onCancel && /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", variant: "soft", accentColor: "base", onClick: onCancel, children: "Cancel" }),
|
|
35738
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "submit", variant: "surface", children: "Save" })
|
|
35739
35739
|
] })
|
|
35740
35740
|
] });
|
|
35741
35741
|
});
|
|
@@ -35837,20 +35837,10 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35837
35837
|
]
|
|
35838
35838
|
}
|
|
35839
35839
|
),
|
|
35840
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
35841
|
-
blocks.
|
|
35842
|
-
|
|
35843
|
-
|
|
35844
|
-
type: "submit",
|
|
35845
|
-
disabled: !formik$1.isValid,
|
|
35846
|
-
accentColor: "primary",
|
|
35847
|
-
variant: "surface",
|
|
35848
|
-
children: [
|
|
35849
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "check" }),
|
|
35850
|
-
submitText
|
|
35851
|
-
]
|
|
35852
|
-
}
|
|
35853
|
-
)
|
|
35840
|
+
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { ...buttonProps, type: "submit", accentColor: "primary", variant: "surface", children: [
|
|
35841
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "check" }),
|
|
35842
|
+
submitText
|
|
35843
|
+
] })
|
|
35854
35844
|
] })
|
|
35855
35845
|
]
|
|
35856
35846
|
}
|
|
@@ -35882,6 +35872,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35882
35872
|
initialFields,
|
|
35883
35873
|
onSave,
|
|
35884
35874
|
onCancel,
|
|
35875
|
+
hideTitle = false,
|
|
35876
|
+
hideDescription = false,
|
|
35885
35877
|
enableReinitialize = false,
|
|
35886
35878
|
disableRequiredFields = false
|
|
35887
35879
|
} = props;
|
|
@@ -35943,7 +35935,11 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35943
35935
|
}
|
|
35944
35936
|
fieldsToValidate = [...fieldsToValidate, ...fieldSettings];
|
|
35945
35937
|
}
|
|
35946
|
-
const
|
|
35938
|
+
const values = {};
|
|
35939
|
+
for (const field of fieldsToValidate) {
|
|
35940
|
+
values[field.identifier] = get(form, field.identifier);
|
|
35941
|
+
}
|
|
35942
|
+
const fieldErrors = validateFields(fieldsToValidate, values);
|
|
35947
35943
|
if (fieldErrors) {
|
|
35948
35944
|
errors.fields = fieldErrors.fields;
|
|
35949
35945
|
}
|
|
@@ -35986,10 +35982,12 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35986
35982
|
}, [formik$1.values.fields, observer]);
|
|
35987
35983
|
const contextValue = React.useMemo(() => {
|
|
35988
35984
|
return {
|
|
35985
|
+
hideTitle,
|
|
35986
|
+
hideDescription,
|
|
35989
35987
|
disableRequiredFields,
|
|
35990
35988
|
onCancel
|
|
35991
35989
|
};
|
|
35992
|
-
}, [disableRequiredFields, onCancel]);
|
|
35990
|
+
}, [disableRequiredFields, hideDescription, hideTitle, onCancel]);
|
|
35993
35991
|
return /* @__PURE__ */ jsxRuntime.jsx(FormBuilderContext, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(FieldSchemaContext, { value: schema, children: /* @__PURE__ */ jsxRuntime.jsx(formik.FormikProvider, { value: formik$1, children }) }) });
|
|
35994
35992
|
});
|
|
35995
35993
|
FormBuilderRoot.displayName = "FormBuilderRoot";
|