@overmap-ai/forms 1.0.32-react-flow-david-fixes.27 → 1.0.32-react-flow-david-fixes.29

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.
@@ -10,7 +10,7 @@ export interface FieldSectionOptions extends FormElementOptions {
10
10
  conditions?: FieldSectionConditions;
11
11
  fields: Field[];
12
12
  }
13
- export declare class FieldSection extends BaseFormElement<"section", FieldSection> implements ConditionManager<Condition>, FieldsManager<Field> {
13
+ export declare class FieldSection extends BaseFormElement<"section", FieldSection> implements ConditionManager<Condition>, FieldsManager {
14
14
  static readonly fieldTypeName = "Section";
15
15
  static readonly fieldTypeDescription = "Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.";
16
16
  readonly type = "section";
@@ -26,12 +26,22 @@ export type Field = BooleanField | CheckboxListField | DateField | MultiSelectFi
26
26
  export type FieldClass = typeof BooleanField | typeof CheckboxListField | typeof DateField | typeof MultiSelectField | typeof MultiStringField | typeof NumberField | typeof RadioField | typeof ScanField | typeof SelectField | typeof StringField | typeof TextField | typeof UploadField | typeof OTPField;
27
27
  export type SerializedField = SerializedTextField | SerializedBooleanField | SerializedNumberField | SerializedDateField | SerializedStringField | SerializedSelectField | SerializedFieldSection | SerializedMultiStringField | SerializedMultiSelectField | SerializedUploadField | SerializedScanField | SerializedRadioField | SerializedCheckboxListField | SerializedOTPField;
28
28
  export type SerializedOnlyField = Exclude<SerializedField, SerializedFieldSection>;
29
- export interface FieldsManager<TField extends AnyFormElement> {
30
- readonly fields: TField[];
31
- getFields(): TField[];
32
- addField(field: TField): void;
33
- addFields(fields: TField[]): void;
29
+ export interface FieldsManager {
30
+ readonly fields: Field[];
31
+ getFields(): Field[];
32
+ addField(field: Field): void;
33
+ addFields(fields: Field[]): void;
34
34
  moveField(sourceIndex: number, targetIndex: number): void;
35
- removeField(field: TField): void;
36
- removeFields(fields: TField[]): void;
35
+ removeField(field: Field): void;
36
+ removeFields(fields: Field[]): void;
37
+ }
38
+ export interface FieldSectionManager {
39
+ readonly fieldSections: FieldSection[];
40
+ getFields(): Field[];
41
+ getFieldSections(): FieldSection[];
42
+ addFieldSection(field: FieldSection): void;
43
+ addFieldSections(fields: FieldSection[]): void;
44
+ moveFieldSection(sourceIndex: number, targetIndex: number): void;
45
+ removeFieldSection(field: FieldSection): void;
46
+ removeFieldSections(fields: FieldSection[]): void;
37
47
  }
@@ -1,19 +1,20 @@
1
- import { FieldSection, FieldsManager, SerializedFieldSection } from '../fields';
1
+ import { Field, FieldSection, FieldSectionManager, SerializedFieldSection } from '../fields';
2
2
  import { Observable } from '../observable/Observable';
3
3
  import { FieldValues, SerializedFieldValues } from '../typings';
4
- export declare class FieldSchema extends Observable<FieldSchema> implements FieldsManager<FieldSection> {
5
- fields: FieldSection[];
4
+ export declare class FieldSchema extends Observable<FieldSchema> implements FieldSectionManager {
5
+ fieldSections: FieldSection[];
6
6
  constructor(fields: FieldSection[]);
7
7
  serialize(): SerializedFieldSection[];
8
8
  static deserialize(serializedSections: SerializedFieldSection[]): FieldSchema;
9
9
  private fieldObserver;
10
10
  private initFields;
11
- addField(field: FieldSection): void;
12
- addFields(fields: FieldSection[]): void;
13
- getFields(): FieldSection[];
14
- removeField(field: FieldSection): void;
15
- removeFields(fields: FieldSection[]): void;
16
- moveField(sourceIndex: number, targetIndex: number): void;
11
+ getFields(): Field[];
12
+ getFieldSections(): FieldSection[];
13
+ addFieldSection(field: FieldSection): void;
14
+ addFieldSections(fields: FieldSection[]): void;
15
+ removeFieldSection(field: FieldSection): void;
16
+ removeFieldSections(fields: FieldSection[]): void;
17
+ moveFieldSection(sourceIndex: number, targetIndex: number): void;
17
18
  deserializeValues(values: SerializedFieldValues): FieldValues;
18
19
  serializeValues(values: FieldValues): SerializedFieldValues;
19
20
  }
package/dist/forms.js CHANGED
@@ -34938,7 +34938,7 @@ let FieldSection = _FieldSection;
34938
34938
  class FieldSchema extends Observable {
34939
34939
  constructor(fields) {
34940
34940
  super();
34941
- __publicField(this, "fields");
34941
+ __publicField(this, "fieldSections");
34942
34942
  // Fields
34943
34943
  __publicField(this, "fieldObserver", () => {
34944
34944
  this.notify(this);
@@ -34947,50 +34947,53 @@ class FieldSchema extends Observable {
34947
34947
  for (const field of fields) field.observe(this.fieldObserver);
34948
34948
  return fields;
34949
34949
  });
34950
- this.fields = this.initFields(fields);
34950
+ this.fieldSections = this.initFields(fields);
34951
34951
  }
34952
34952
  serialize() {
34953
- return this.fields.map((field) => field.serialize());
34953
+ return this.fieldSections.map((field) => field.serialize());
34954
34954
  }
34955
34955
  static deserialize(serializedSections) {
34956
34956
  return new FieldSchema(serializedSections.map(FieldSection.deserialize));
34957
34957
  }
34958
- addField(field) {
34959
- this.fields = this.initFields([...this.fields, field]);
34960
- this.notify(this);
34958
+ getFields() {
34959
+ return this.fieldSections.flatMap((fieldSection) => fieldSection.getFields());
34961
34960
  }
34962
- addFields(fields) {
34963
- this.fields = this.initFields([...this.fields, ...fields]);
34961
+ getFieldSections() {
34962
+ return this.fieldSections;
34963
+ }
34964
+ addFieldSection(field) {
34965
+ this.fieldSections = this.initFields([...this.fieldSections, field]);
34964
34966
  this.notify(this);
34965
34967
  }
34966
- getFields() {
34967
- return this.fields;
34968
+ addFieldSections(fields) {
34969
+ this.fieldSections = this.initFields([...this.fieldSections, ...fields]);
34970
+ this.notify(this);
34968
34971
  }
34969
- removeField(field) {
34970
- const newFields = this.fields.filter((f) => f.identifier !== field.identifier);
34972
+ removeFieldSection(field) {
34973
+ const newFields = this.fieldSections.filter((f) => f.identifier !== field.identifier);
34971
34974
  for (const field2 of newFields) {
34972
34975
  field2.removeConditional(field2.identifier);
34973
34976
  }
34974
- this.fields = this.initFields(newFields);
34977
+ this.fieldSections = this.initFields(newFields);
34975
34978
  this.notify(this);
34976
34979
  }
34977
- removeFields(fields) {
34980
+ removeFieldSections(fields) {
34978
34981
  const fieldsIds = new Set(fields.map((f) => f.identifier));
34979
- this.fields = this.initFields(this.fields.filter((f) => !fieldsIds.has(f.identifier)));
34982
+ this.fieldSections = this.initFields(this.fieldSections.filter((f) => !fieldsIds.has(f.identifier)));
34980
34983
  this.notify(this);
34981
34984
  }
34982
- moveField(sourceIndex, targetIndex) {
34983
- const newFields = [...this.fields];
34985
+ moveFieldSection(sourceIndex, targetIndex) {
34986
+ const newFields = [...this.fieldSections];
34984
34987
  const [removedElement] = newFields.splice(sourceIndex, 1);
34985
34988
  newFields.splice(targetIndex, 0, removedElement);
34986
- this.fields = this.initFields(newFields);
34989
+ this.fieldSections = this.initFields(newFields);
34987
34990
  this.notify(this);
34988
34991
  }
34989
34992
  deserializeValues(values) {
34990
- return deserializeFieldValues(flattenFields(this.fields), values);
34993
+ return deserializeFieldValues(flattenFields(this.fieldSections), values);
34991
34994
  }
34992
34995
  serializeValues(values) {
34993
- return serializeFieldValues(flattenFields(this.fields), values);
34996
+ return serializeFieldValues(flattenFields(this.fieldSections), values);
34994
34997
  }
34995
34998
  }
34996
34999
  const FieldSchemaContext = createContext(new FieldSchema([]));
@@ -35534,7 +35537,7 @@ const FieldSectionNodeComponent = memo((props) => {
35534
35537
  const { fieldSection, index: sectionIndex, layoutDirection } = data;
35535
35538
  const fieldSchema = use(FieldSchemaContext);
35536
35539
  const removeSection = useCallback(() => {
35537
- fieldSchema.removeField(fieldSection);
35540
+ fieldSchema.removeFieldSection(fieldSection);
35538
35541
  }, [fieldSchema, fieldSection]);
35539
35542
  const addField = useCallback(
35540
35543
  (type) => {
@@ -35544,11 +35547,11 @@ const FieldSectionNodeComponent = memo((props) => {
35544
35547
  );
35545
35548
  const handleAddBranch = useCallback(() => {
35546
35549
  const section = new FieldSection({ identifier: v4(), fields: [] });
35547
- fieldSchema.addField(section);
35550
+ fieldSchema.addFieldSection(section);
35548
35551
  fieldSection.addConditional(section.identifier);
35549
35552
  }, [fieldSchema, fieldSection]);
35550
35553
  const handleDuplicate = useCallback(() => {
35551
- fieldSchema.addField(fieldSection.duplicate(v4()));
35554
+ fieldSchema.addFieldSection(fieldSection.duplicate(v4()));
35552
35555
  }, [fieldSchema, fieldSection]);
35553
35556
  const fieldTypeItems = useFieldTypeItems(addField);
35554
35557
  const removeField = useCallback(
@@ -35705,7 +35708,7 @@ const FormBuilderFlowBuilder = memo(() => {
35705
35708
  ref.current.classList.remove("light");
35706
35709
  }, []);
35707
35710
  const initialNodes = useMemo(
35708
- () => fieldSchema.fields.map((fieldSection, index) => ({
35711
+ () => fieldSchema.fieldSections.map((fieldSection, index) => ({
35709
35712
  id: fieldSection.identifier,
35710
35713
  position: { x: 0, y: 0 },
35711
35714
  data: {
@@ -35716,15 +35719,15 @@ const FormBuilderFlowBuilder = memo(() => {
35716
35719
  draggable: true,
35717
35720
  type: "fieldSection"
35718
35721
  })),
35719
- [fieldSchema.fields, layoutDirection]
35722
+ [fieldSchema.fieldSections, layoutDirection]
35720
35723
  );
35721
35724
  const initialEdges = useMemo(() => {
35722
35725
  const es = [];
35723
35726
  const sectionsMapping = {};
35724
- for (const section of fieldSchema.fields) {
35727
+ for (const section of fieldSchema.fieldSections) {
35725
35728
  sectionsMapping[section.identifier] = section;
35726
35729
  }
35727
- for (const section of fieldSchema.fields) {
35730
+ for (const section of fieldSchema.fieldSections) {
35728
35731
  const sectionConditions = section.conditions;
35729
35732
  for (const [conditionSectionId, conditions] of Object.entries(sectionConditions)) {
35730
35733
  es.push({
@@ -35743,7 +35746,7 @@ const FormBuilderFlowBuilder = memo(() => {
35743
35746
  }
35744
35747
  }
35745
35748
  return es;
35746
- }, [fieldSchema.fields]);
35749
+ }, [fieldSchema.fieldSections]);
35747
35750
  const [nodes, setNodes, handleNodesChange] = useNodesState(initialNodes);
35748
35751
  const [edges, setEdges, handleEdgesChange] = useEdgesState(initialEdges);
35749
35752
  useEffect(() => {
@@ -35756,12 +35759,12 @@ const FormBuilderFlowBuilder = memo(() => {
35756
35759
  return getLayoutedElements(nodes, edges, layoutDirection);
35757
35760
  }, [edges, layoutDirection, nodes]);
35758
35761
  const handleAddSection = useCallback(() => {
35759
- fieldSchema.addField(new FieldSection({ identifier: v4(), fields: [] }));
35762
+ fieldSchema.addFieldSection(new FieldSection({ identifier: v4(), fields: [] }));
35760
35763
  }, [fieldSchema]);
35761
35764
  const handleConnect = useCallback(
35762
35765
  (params) => {
35763
35766
  const { source: sourceId, target: targetId } = params;
35764
- const sourceSection = fieldSchema.fields.find(({ identifier }) => identifier === sourceId);
35767
+ const sourceSection = fieldSchema.fieldSections.find(({ identifier }) => identifier === sourceId);
35765
35768
  sourceSection.setOptions({
35766
35769
  conditions: {
35767
35770
  ...sourceSection.conditions,
@@ -35769,19 +35772,19 @@ const FormBuilderFlowBuilder = memo(() => {
35769
35772
  }
35770
35773
  });
35771
35774
  },
35772
- [fieldSchema.fields]
35775
+ [fieldSchema.fieldSections]
35773
35776
  );
35774
35777
  const handleValidConnection = useCallback(
35775
35778
  (edge) => {
35776
35779
  const graph = new DirectedGraph({});
35777
- for (const sourceSection of fieldSchema.fields) {
35780
+ for (const sourceSection of fieldSchema.fieldSections) {
35778
35781
  for (const targetSectionId of Object.keys(sourceSection.conditions)) {
35779
35782
  graph.mergeEdge(sourceSection.identifier, targetSectionId);
35780
35783
  }
35781
35784
  }
35782
35785
  return !willCreateCycle(graph, edge.source, edge.target);
35783
35786
  },
35784
- [fieldSchema.fields]
35787
+ [fieldSchema.fieldSections]
35785
35788
  );
35786
35789
  const [titleFieldProps, titleMeta, titleHelpers] = useField("title");
35787
35790
  const [descriptionFieldProps, _descriptionMeta, descriptionHelpers] = useField("description");
@@ -35918,8 +35921,8 @@ const FieldSectionBuilder = memo((props) => {
35918
35921
  const { fieldSection } = props;
35919
35922
  const fieldSchema = use(FieldSchemaContext);
35920
35923
  const conditionalSections = useMemo(() => {
35921
- return fieldSchema.fields.filter((section) => fieldSection.identifier in section.conditions);
35922
- }, [fieldSchema.fields, fieldSection.identifier]);
35924
+ return fieldSchema.fieldSections.filter((section) => fieldSection.identifier in section.conditions);
35925
+ }, [fieldSchema.fieldSections, fieldSection.identifier]);
35923
35926
  const handleAddConditional = useCallback(
35924
35927
  (conditionalSection) => {
35925
35928
  conditionalSection.addConditional(fieldSection.identifier);
@@ -35928,15 +35931,15 @@ const FieldSectionBuilder = memo((props) => {
35928
35931
  );
35929
35932
  const validFieldSections = useMemo(() => {
35930
35933
  const graph = new DirectedGraph({});
35931
- for (const sourceSection of fieldSchema.fields) {
35934
+ for (const sourceSection of fieldSchema.fieldSections) {
35932
35935
  for (const targetSectionId of Object.keys(sourceSection.conditions)) {
35933
35936
  graph.mergeEdge(sourceSection.identifier, targetSectionId);
35934
35937
  }
35935
35938
  }
35936
- return fieldSchema.fields.filter(
35939
+ return fieldSchema.fieldSections.filter(
35937
35940
  (sourceSection) => !willCreateCycle(graph, sourceSection.identifier, fieldSection.identifier)
35938
35941
  );
35939
- }, [fieldSchema.fields, fieldSection.identifier]);
35942
+ }, [fieldSchema.fieldSections, fieldSection.identifier]);
35940
35943
  return /* @__PURE__ */ jsxs("div", { className: "flex grow w-full flex-col gap-4", children: [
35941
35944
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 w-full overflow-hidden", children: [
35942
35945
  /* @__PURE__ */ jsx(Input.Root, { variant: "outline", size: "md", children: /* @__PURE__ */ jsx(
@@ -36000,17 +36003,17 @@ const FieldSectionWithActions = memo((props) => {
36000
36003
  [fieldSection]
36001
36004
  );
36002
36005
  const removeSection = useCallback(() => {
36003
- fieldSchema.removeField(fieldSection);
36006
+ fieldSchema.removeFieldSection(fieldSection);
36004
36007
  }, [fieldSchema, fieldSection]);
36005
36008
  const moveSection = useCallback(
36006
36009
  (direction) => {
36007
36010
  const targetIndex = direction === "up" ? sectionIndex - 1 : sectionIndex + 1;
36008
- fieldSchema.moveField(sectionIndex, targetIndex);
36011
+ fieldSchema.moveFieldSection(sectionIndex, targetIndex);
36009
36012
  },
36010
36013
  [fieldSchema, sectionIndex]
36011
36014
  );
36012
36015
  const duplicateSection = useCallback(() => {
36013
- fieldSchema.addField(fieldSection.duplicate(v4()));
36016
+ fieldSchema.addFieldSection(fieldSection.duplicate(v4()));
36014
36017
  }, [fieldSchema, fieldSection]);
36015
36018
  const handleCreateField = useCallback(
36016
36019
  (type) => {
@@ -36069,7 +36072,7 @@ const FormBuilderListBuilder = memo(() => {
36069
36072
  const { hideTitle, hideDescription, onCancel } = use(FormBuilderContext);
36070
36073
  const fieldSchema = use(FieldSchemaContext);
36071
36074
  const handleCreateEmptySection = useCallback(() => {
36072
- fieldSchema.addField(new FieldSection({ identifier: v4(), fields: [] }));
36075
+ fieldSchema.addFieldSection(new FieldSection({ identifier: v4(), fields: [] }));
36073
36076
  }, [fieldSchema]);
36074
36077
  const [titleFieldProps, titleMeta, titleHelpers] = useField("title");
36075
36078
  const [descriptionFieldProps, _descriptionMeta, descriptionHelpers] = useField("description");
@@ -36108,7 +36111,7 @@ const FormBuilderListBuilder = memo(() => {
36108
36111
  }
36109
36112
  ),
36110
36113
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
36111
- fieldSchema.fields.map((fieldSection, index) => /* @__PURE__ */ jsx(FieldSectionWithActions, { fieldSection, index }, fieldSection.identifier)),
36114
+ fieldSchema.fieldSections.map((fieldSection, index) => /* @__PURE__ */ jsx(FieldSectionWithActions, { fieldSection, index }, fieldSection.identifier)),
36112
36115
  /* @__PURE__ */ jsxs(
36113
36116
  Button,
36114
36117
  {
@@ -36357,12 +36360,12 @@ const FormBuilderPreview = memo((props) => {
36357
36360
  return {
36358
36361
  title: values.title,
36359
36362
  description: values.description,
36360
- fields: fieldSchema.fields,
36363
+ fields: fieldSchema.fieldSections,
36361
36364
  meta: {
36362
36365
  readonly: false
36363
36366
  }
36364
36367
  };
36365
- }, [fieldSchema.fields, values.description, values.title]);
36368
+ }, [fieldSchema.fieldSections, values.description, values.title]);
36366
36369
  return /* @__PURE__ */ jsx(FormRenderer, { schema: previewSchema, hideTitle: !showFormTitle });
36367
36370
  });
36368
36371
  FormBuilderPreview.displayName = "FormBuilderPreview";
@@ -34940,7 +34940,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
34940
34940
  class FieldSchema extends Observable {
34941
34941
  constructor(fields) {
34942
34942
  super();
34943
- __publicField(this, "fields");
34943
+ __publicField(this, "fieldSections");
34944
34944
  // Fields
34945
34945
  __publicField(this, "fieldObserver", () => {
34946
34946
  this.notify(this);
@@ -34949,50 +34949,53 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
34949
34949
  for (const field of fields) field.observe(this.fieldObserver);
34950
34950
  return fields;
34951
34951
  });
34952
- this.fields = this.initFields(fields);
34952
+ this.fieldSections = this.initFields(fields);
34953
34953
  }
34954
34954
  serialize() {
34955
- return this.fields.map((field) => field.serialize());
34955
+ return this.fieldSections.map((field) => field.serialize());
34956
34956
  }
34957
34957
  static deserialize(serializedSections) {
34958
34958
  return new FieldSchema(serializedSections.map(FieldSection.deserialize));
34959
34959
  }
34960
- addField(field) {
34961
- this.fields = this.initFields([...this.fields, field]);
34962
- this.notify(this);
34960
+ getFields() {
34961
+ return this.fieldSections.flatMap((fieldSection) => fieldSection.getFields());
34963
34962
  }
34964
- addFields(fields) {
34965
- this.fields = this.initFields([...this.fields, ...fields]);
34963
+ getFieldSections() {
34964
+ return this.fieldSections;
34965
+ }
34966
+ addFieldSection(field) {
34967
+ this.fieldSections = this.initFields([...this.fieldSections, field]);
34966
34968
  this.notify(this);
34967
34969
  }
34968
- getFields() {
34969
- return this.fields;
34970
+ addFieldSections(fields) {
34971
+ this.fieldSections = this.initFields([...this.fieldSections, ...fields]);
34972
+ this.notify(this);
34970
34973
  }
34971
- removeField(field) {
34972
- const newFields = this.fields.filter((f) => f.identifier !== field.identifier);
34974
+ removeFieldSection(field) {
34975
+ const newFields = this.fieldSections.filter((f) => f.identifier !== field.identifier);
34973
34976
  for (const field2 of newFields) {
34974
34977
  field2.removeConditional(field2.identifier);
34975
34978
  }
34976
- this.fields = this.initFields(newFields);
34979
+ this.fieldSections = this.initFields(newFields);
34977
34980
  this.notify(this);
34978
34981
  }
34979
- removeFields(fields) {
34982
+ removeFieldSections(fields) {
34980
34983
  const fieldsIds = new Set(fields.map((f) => f.identifier));
34981
- this.fields = this.initFields(this.fields.filter((f) => !fieldsIds.has(f.identifier)));
34984
+ this.fieldSections = this.initFields(this.fieldSections.filter((f) => !fieldsIds.has(f.identifier)));
34982
34985
  this.notify(this);
34983
34986
  }
34984
- moveField(sourceIndex, targetIndex) {
34985
- const newFields = [...this.fields];
34987
+ moveFieldSection(sourceIndex, targetIndex) {
34988
+ const newFields = [...this.fieldSections];
34986
34989
  const [removedElement] = newFields.splice(sourceIndex, 1);
34987
34990
  newFields.splice(targetIndex, 0, removedElement);
34988
- this.fields = this.initFields(newFields);
34991
+ this.fieldSections = this.initFields(newFields);
34989
34992
  this.notify(this);
34990
34993
  }
34991
34994
  deserializeValues(values) {
34992
- return deserializeFieldValues(flattenFields(this.fields), values);
34995
+ return deserializeFieldValues(flattenFields(this.fieldSections), values);
34993
34996
  }
34994
34997
  serializeValues(values) {
34995
- return serializeFieldValues(flattenFields(this.fields), values);
34998
+ return serializeFieldValues(flattenFields(this.fieldSections), values);
34996
34999
  }
34997
35000
  }
34998
35001
  const FieldSchemaContext = React.createContext(new FieldSchema([]));
@@ -35536,7 +35539,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
35536
35539
  const { fieldSection, index: sectionIndex, layoutDirection } = data;
35537
35540
  const fieldSchema = React.use(FieldSchemaContext);
35538
35541
  const removeSection = React.useCallback(() => {
35539
- fieldSchema.removeField(fieldSection);
35542
+ fieldSchema.removeFieldSection(fieldSection);
35540
35543
  }, [fieldSchema, fieldSection]);
35541
35544
  const addField = React.useCallback(
35542
35545
  (type) => {
@@ -35546,11 +35549,11 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
35546
35549
  );
35547
35550
  const handleAddBranch = React.useCallback(() => {
35548
35551
  const section = new FieldSection({ identifier: uuid.v4(), fields: [] });
35549
- fieldSchema.addField(section);
35552
+ fieldSchema.addFieldSection(section);
35550
35553
  fieldSection.addConditional(section.identifier);
35551
35554
  }, [fieldSchema, fieldSection]);
35552
35555
  const handleDuplicate = React.useCallback(() => {
35553
- fieldSchema.addField(fieldSection.duplicate(uuid.v4()));
35556
+ fieldSchema.addFieldSection(fieldSection.duplicate(uuid.v4()));
35554
35557
  }, [fieldSchema, fieldSection]);
35555
35558
  const fieldTypeItems = useFieldTypeItems(addField);
35556
35559
  const removeField = React.useCallback(
@@ -35707,7 +35710,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
35707
35710
  ref.current.classList.remove("light");
35708
35711
  }, []);
35709
35712
  const initialNodes = React.useMemo(
35710
- () => fieldSchema.fields.map((fieldSection, index) => ({
35713
+ () => fieldSchema.fieldSections.map((fieldSection, index) => ({
35711
35714
  id: fieldSection.identifier,
35712
35715
  position: { x: 0, y: 0 },
35713
35716
  data: {
@@ -35718,15 +35721,15 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
35718
35721
  draggable: true,
35719
35722
  type: "fieldSection"
35720
35723
  })),
35721
- [fieldSchema.fields, layoutDirection]
35724
+ [fieldSchema.fieldSections, layoutDirection]
35722
35725
  );
35723
35726
  const initialEdges = React.useMemo(() => {
35724
35727
  const es = [];
35725
35728
  const sectionsMapping = {};
35726
- for (const section of fieldSchema.fields) {
35729
+ for (const section of fieldSchema.fieldSections) {
35727
35730
  sectionsMapping[section.identifier] = section;
35728
35731
  }
35729
- for (const section of fieldSchema.fields) {
35732
+ for (const section of fieldSchema.fieldSections) {
35730
35733
  const sectionConditions = section.conditions;
35731
35734
  for (const [conditionSectionId, conditions] of Object.entries(sectionConditions)) {
35732
35735
  es.push({
@@ -35745,7 +35748,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
35745
35748
  }
35746
35749
  }
35747
35750
  return es;
35748
- }, [fieldSchema.fields]);
35751
+ }, [fieldSchema.fieldSections]);
35749
35752
  const [nodes, setNodes, handleNodesChange] = react.useNodesState(initialNodes);
35750
35753
  const [edges, setEdges, handleEdgesChange] = react.useEdgesState(initialEdges);
35751
35754
  React.useEffect(() => {
@@ -35758,12 +35761,12 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
35758
35761
  return getLayoutedElements(nodes, edges, layoutDirection);
35759
35762
  }, [edges, layoutDirection, nodes]);
35760
35763
  const handleAddSection = React.useCallback(() => {
35761
- fieldSchema.addField(new FieldSection({ identifier: uuid.v4(), fields: [] }));
35764
+ fieldSchema.addFieldSection(new FieldSection({ identifier: uuid.v4(), fields: [] }));
35762
35765
  }, [fieldSchema]);
35763
35766
  const handleConnect = React.useCallback(
35764
35767
  (params) => {
35765
35768
  const { source: sourceId, target: targetId } = params;
35766
- const sourceSection = fieldSchema.fields.find(({ identifier }) => identifier === sourceId);
35769
+ const sourceSection = fieldSchema.fieldSections.find(({ identifier }) => identifier === sourceId);
35767
35770
  sourceSection.setOptions({
35768
35771
  conditions: {
35769
35772
  ...sourceSection.conditions,
@@ -35771,19 +35774,19 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
35771
35774
  }
35772
35775
  });
35773
35776
  },
35774
- [fieldSchema.fields]
35777
+ [fieldSchema.fieldSections]
35775
35778
  );
35776
35779
  const handleValidConnection = React.useCallback(
35777
35780
  (edge) => {
35778
35781
  const graph = new graphology.DirectedGraph({});
35779
- for (const sourceSection of fieldSchema.fields) {
35782
+ for (const sourceSection of fieldSchema.fieldSections) {
35780
35783
  for (const targetSectionId of Object.keys(sourceSection.conditions)) {
35781
35784
  graph.mergeEdge(sourceSection.identifier, targetSectionId);
35782
35785
  }
35783
35786
  }
35784
35787
  return !graphologyDag.willCreateCycle(graph, edge.source, edge.target);
35785
35788
  },
35786
- [fieldSchema.fields]
35789
+ [fieldSchema.fieldSections]
35787
35790
  );
35788
35791
  const [titleFieldProps, titleMeta, titleHelpers] = formik.useField("title");
35789
35792
  const [descriptionFieldProps, _descriptionMeta, descriptionHelpers] = formik.useField("description");
@@ -35920,8 +35923,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
35920
35923
  const { fieldSection } = props;
35921
35924
  const fieldSchema = React.use(FieldSchemaContext);
35922
35925
  const conditionalSections = React.useMemo(() => {
35923
- return fieldSchema.fields.filter((section) => fieldSection.identifier in section.conditions);
35924
- }, [fieldSchema.fields, fieldSection.identifier]);
35926
+ return fieldSchema.fieldSections.filter((section) => fieldSection.identifier in section.conditions);
35927
+ }, [fieldSchema.fieldSections, fieldSection.identifier]);
35925
35928
  const handleAddConditional = React.useCallback(
35926
35929
  (conditionalSection) => {
35927
35930
  conditionalSection.addConditional(fieldSection.identifier);
@@ -35930,15 +35933,15 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
35930
35933
  );
35931
35934
  const validFieldSections = React.useMemo(() => {
35932
35935
  const graph = new graphology.DirectedGraph({});
35933
- for (const sourceSection of fieldSchema.fields) {
35936
+ for (const sourceSection of fieldSchema.fieldSections) {
35934
35937
  for (const targetSectionId of Object.keys(sourceSection.conditions)) {
35935
35938
  graph.mergeEdge(sourceSection.identifier, targetSectionId);
35936
35939
  }
35937
35940
  }
35938
- return fieldSchema.fields.filter(
35941
+ return fieldSchema.fieldSections.filter(
35939
35942
  (sourceSection) => !graphologyDag.willCreateCycle(graph, sourceSection.identifier, fieldSection.identifier)
35940
35943
  );
35941
- }, [fieldSchema.fields, fieldSection.identifier]);
35944
+ }, [fieldSchema.fieldSections, fieldSection.identifier]);
35942
35945
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex grow w-full flex-col gap-4", children: [
35943
35946
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 w-full overflow-hidden", children: [
35944
35947
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Input.Root, { variant: "outline", size: "md", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -36002,17 +36005,17 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
36002
36005
  [fieldSection]
36003
36006
  );
36004
36007
  const removeSection = React.useCallback(() => {
36005
- fieldSchema.removeField(fieldSection);
36008
+ fieldSchema.removeFieldSection(fieldSection);
36006
36009
  }, [fieldSchema, fieldSection]);
36007
36010
  const moveSection = React.useCallback(
36008
36011
  (direction) => {
36009
36012
  const targetIndex = direction === "up" ? sectionIndex - 1 : sectionIndex + 1;
36010
- fieldSchema.moveField(sectionIndex, targetIndex);
36013
+ fieldSchema.moveFieldSection(sectionIndex, targetIndex);
36011
36014
  },
36012
36015
  [fieldSchema, sectionIndex]
36013
36016
  );
36014
36017
  const duplicateSection = React.useCallback(() => {
36015
- fieldSchema.addField(fieldSection.duplicate(uuid.v4()));
36018
+ fieldSchema.addFieldSection(fieldSection.duplicate(uuid.v4()));
36016
36019
  }, [fieldSchema, fieldSection]);
36017
36020
  const handleCreateField = React.useCallback(
36018
36021
  (type) => {
@@ -36071,7 +36074,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
36071
36074
  const { hideTitle, hideDescription, onCancel } = React.use(FormBuilderContext);
36072
36075
  const fieldSchema = React.use(FieldSchemaContext);
36073
36076
  const handleCreateEmptySection = React.useCallback(() => {
36074
- fieldSchema.addField(new FieldSection({ identifier: uuid.v4(), fields: [] }));
36077
+ fieldSchema.addFieldSection(new FieldSection({ identifier: uuid.v4(), fields: [] }));
36075
36078
  }, [fieldSchema]);
36076
36079
  const [titleFieldProps, titleMeta, titleHelpers] = formik.useField("title");
36077
36080
  const [descriptionFieldProps, _descriptionMeta, descriptionHelpers] = formik.useField("description");
@@ -36110,7 +36113,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
36110
36113
  }
36111
36114
  ),
36112
36115
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
36113
- fieldSchema.fields.map((fieldSection, index) => /* @__PURE__ */ jsxRuntime.jsx(FieldSectionWithActions, { fieldSection, index }, fieldSection.identifier)),
36116
+ fieldSchema.fieldSections.map((fieldSection, index) => /* @__PURE__ */ jsxRuntime.jsx(FieldSectionWithActions, { fieldSection, index }, fieldSection.identifier)),
36114
36117
  /* @__PURE__ */ jsxRuntime.jsxs(
36115
36118
  blocks.Button,
36116
36119
  {
@@ -36359,12 +36362,12 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
36359
36362
  return {
36360
36363
  title: values.title,
36361
36364
  description: values.description,
36362
- fields: fieldSchema.fields,
36365
+ fields: fieldSchema.fieldSections,
36363
36366
  meta: {
36364
36367
  readonly: false
36365
36368
  }
36366
36369
  };
36367
- }, [fieldSchema.fields, values.description, values.title]);
36370
+ }, [fieldSchema.fieldSections, values.description, values.title]);
36368
36371
  return /* @__PURE__ */ jsxRuntime.jsx(FormRenderer, { schema: previewSchema, hideTitle: !showFormTitle });
36369
36372
  });
36370
36373
  FormBuilderPreview.displayName = "FormBuilderPreview";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@overmap-ai/forms",
3
- "version": "1.0.32-react-flow-david-fixes.27",
3
+ "version": "1.0.32-react-flow-david-fixes.29",
4
4
  "license": "UNLICENSED",
5
5
  "main": "dist/forms.umd.cjs",
6
6
  "module": "dist/forms.js",