@overmap-ai/forms 1.0.32 → 1.0.33-toast-migration.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.
Files changed (68) hide show
  1. package/dist/form/UUIDPromise/UUIDPromise.d.ts +3 -3
  2. package/dist/form/builder/Root.d.ts +1 -1
  3. package/dist/form/builder/components/FieldBuilder.d.ts +1 -1
  4. package/dist/form/conditions/BaseCondition/BaseCondition.d.ts +1 -1
  5. package/dist/form/conditions/BooleanFieldCondition/BooleanFieldCondition.d.ts +1 -1
  6. package/dist/form/conditions/CheckboxListFieldCondition/CheckboxListFieldCondition.d.ts +1 -1
  7. package/dist/form/conditions/ConditionManager/ConditionManager.d.ts +1 -1
  8. package/dist/form/conditions/ConditionManager/hooks.d.ts +1 -1
  9. package/dist/form/conditions/DateFieldCondition/DateFieldCondition.d.ts +2 -2
  10. package/dist/form/conditions/MultiSelectFieldCondition/MultiSelectFieldCondition.d.ts +1 -1
  11. package/dist/form/conditions/MultiStringFieldCondition/MultiStringFieldCondition.d.ts +1 -1
  12. package/dist/form/conditions/NumberFieldCondition/NumberFieldCondition.d.ts +1 -1
  13. package/dist/form/conditions/OTPFieldCondition/OTPFieldCondition.d.ts +1 -1
  14. package/dist/form/conditions/PassFailFieldCondition/PassFailFieldCondition.d.ts +1 -1
  15. package/dist/form/conditions/RadioFieldCondition/RadioFieldCondition.d.ts +1 -1
  16. package/dist/form/conditions/RatingFieldCondition/RatingFieldCondition.d.ts +1 -1
  17. package/dist/form/conditions/ScanFieldCondition/ScanFieldCondition.d.ts +1 -1
  18. package/dist/form/conditions/StringFieldCondition/StringFieldCondition.d.ts +1 -1
  19. package/dist/form/conditions/TextFieldCondition/TextFieldCondition.d.ts +1 -1
  20. package/dist/form/conditions/UploadFieldCondition/UploadFieldCondition.d.ts +2 -2
  21. package/dist/form/conditions/utils.d.ts +1 -1
  22. package/dist/form/fields/BaseField/BaseField.d.ts +1 -1
  23. package/dist/form/fields/BaseFormElement/BaseFormElement.d.ts +1 -1
  24. package/dist/form/fields/BaseOptionsField/BaseOptionsField.d.ts +1 -1
  25. package/dist/form/fields/BaseStringField/BaseStringField.d.ts +1 -1
  26. package/dist/form/fields/BooleanField/BooleanField.d.ts +1 -1
  27. package/dist/form/fields/BooleanField/BooleanInput.d.ts +1 -1
  28. package/dist/form/fields/CheckboxListField/CheckboxListField.d.ts +1 -1
  29. package/dist/form/fields/DateField/DateField.d.ts +1 -1
  30. package/dist/form/fields/DateField/DateInput.d.ts +1 -1
  31. package/dist/form/fields/FieldSection/FieldSection.d.ts +3 -3
  32. package/dist/form/fields/MultiSelectField/MultiSelectField.d.ts +1 -1
  33. package/dist/form/fields/MultiSelectField/MultiSelectInput.d.ts +1 -1
  34. package/dist/form/fields/MultiStringField/MultiStringField.d.ts +1 -1
  35. package/dist/form/fields/MultiStringField/MultiStringInput.d.ts +1 -1
  36. package/dist/form/fields/NumberField/NumberField.d.ts +1 -1
  37. package/dist/form/fields/NumberField/NumberInput.d.ts +1 -1
  38. package/dist/form/fields/OneTimePasswordField/OTPField.d.ts +1 -1
  39. package/dist/form/fields/OneTimePasswordField/typings.d.ts +1 -1
  40. package/dist/form/fields/PassFailField/PassFailField.d.ts +1 -1
  41. package/dist/form/fields/PassFailField/PassFailInput.d.ts +1 -1
  42. package/dist/form/fields/PassFailField/typings.d.ts +1 -1
  43. package/dist/form/fields/RadioField/RadioField.d.ts +1 -1
  44. package/dist/form/fields/RadioField/RadioInput.d.ts +1 -1
  45. package/dist/form/fields/RatingField/RatingField.d.ts +1 -1
  46. package/dist/form/fields/RatingField/RatingInput.d.ts +1 -1
  47. package/dist/form/fields/ScanField/ScanField.d.ts +1 -1
  48. package/dist/form/fields/ScanField/ScanInput.d.ts +1 -1
  49. package/dist/form/fields/SelectField/SelectField.d.ts +1 -1
  50. package/dist/form/fields/SelectField/SelectInput.d.ts +1 -1
  51. package/dist/form/fields/StringField/StringField.d.ts +1 -1
  52. package/dist/form/fields/StringField/StringInput.d.ts +1 -1
  53. package/dist/form/fields/TextField/TextField.d.ts +1 -1
  54. package/dist/form/fields/TextField/TextInput.d.ts +1 -1
  55. package/dist/form/fields/UploadField/UploadField.d.ts +1 -1
  56. package/dist/form/fields/UploadField/UploadInput.d.ts +1 -1
  57. package/dist/form/fields/components/InputWithLabel.d.ts +1 -1
  58. package/dist/form/fields/constants.d.ts +1 -1
  59. package/dist/form/fields/hooks.d.ts +1 -1
  60. package/dist/form/fields/typings.d.ts +3 -3
  61. package/dist/form/fields/utils.d.ts +1 -1
  62. package/dist/form/schema/FieldSchema.d.ts +1 -1
  63. package/dist/form/utils.d.ts +1 -1
  64. package/dist/forms.js +71 -67
  65. package/dist/forms.js.map +1 -0
  66. package/dist/forms.umd.cjs +70 -66
  67. package/dist/forms.umd.cjs.map +1 -0
  68. package/package.json +37 -49
@@ -21,11 +21,11 @@ export type AnyField = BaseField<any, any, any, any>;
21
21
  export type TypeOfField<TField extends AnyFormElement> = TField extends BaseFormElement<infer TType, infer _TThis> ? TType : never;
22
22
  export type ValueOfField<TField extends AnyField> = TField extends BaseField<infer _TType, infer TValue, infer _TSerializedValue, infer _TThis> ? TValue : never;
23
23
  export type SerializedValueOfField<TField extends AnyField> = TField extends BaseField<infer _TType, infer _TValue, infer TSerializedValue, infer _TThis> ? TSerializedValue : never;
24
- export type FieldType = TypeOfField<BooleanField> | TypeOfField<CheckboxListField> | TypeOfField<PassFailField> | TypeOfField<DateField> | TypeOfField<MultiSelectField> | TypeOfField<MultiStringField> | TypeOfField<NumberField> | TypeOfField<RadioField> | TypeOfField<RatingField> | TypeOfField<ScanField> | TypeOfField<SelectField> | TypeOfField<StringField> | TypeOfField<TextField> | TypeOfField<UploadField> | TypeOfField<FieldSection> | TypeOfField<OTPField>;
25
- export type FieldValue = ValueOfField<BooleanField> | ValueOfField<CheckboxListField> | ValueOfField<PassFailField> | ValueOfField<DateField> | ValueOfField<MultiSelectField> | ValueOfField<MultiStringField> | ValueOfField<NumberField> | ValueOfField<RadioField> | ValueOfField<RatingField> | ValueOfField<ScanField> | ValueOfField<SelectField> | ValueOfField<StringField> | ValueOfField<TextField> | ValueOfField<UploadField> | ValueOfField<OTPField>;
26
- export type SerializedFieldValue = SerializedValueOfField<BooleanField> | SerializedValueOfField<CheckboxListField> | SerializedValueOfField<PassFailField> | SerializedValueOfField<DateField> | SerializedValueOfField<MultiSelectField> | SerializedValueOfField<MultiStringField> | SerializedValueOfField<NumberField> | SerializedValueOfField<RadioField> | SerializedValueOfField<RatingField> | SerializedValueOfField<ScanField> | SerializedValueOfField<SelectField> | SerializedValueOfField<StringField> | SerializedValueOfField<TextField> | SerializedValueOfField<UploadField> | SerializedValueOfField<OTPField>;
27
24
  export type Field = BooleanField | CheckboxListField | PassFailField | DateField | MultiSelectField | MultiStringField | NumberField | RadioField | RatingField | ScanField | SelectField | StringField | TextField | UploadField | OTPField;
28
25
  export type FieldClass = typeof BooleanField | typeof CheckboxListField | typeof PassFailField | typeof DateField | typeof MultiSelectField | typeof MultiStringField | typeof NumberField | typeof RadioField | typeof RatingField | typeof ScanField | typeof SelectField | typeof StringField | typeof TextField | typeof UploadField | typeof OTPField;
26
+ export type FieldType = TypeOfField<Field> | TypeOfField<FieldSection>;
27
+ export type FieldValue = ValueOfField<Field>;
28
+ export type SerializedFieldValue = SerializedValueOfField<Field>;
29
29
  export type SerializedField = SerializedTextField | SerializedBooleanField | SerializedNumberField | SerializedDateField | SerializedStringField | SerializedSelectField | SerializedFieldSection | SerializedMultiStringField | SerializedMultiSelectField | SerializedUploadField | SerializedScanField | SerializedRadioField | SerializedRatingField | SerializedCheckboxListField | SerializedOTPField | SerializedPassFailField;
30
30
  export type SerializedOnlyField = Exclude<SerializedField, SerializedFieldSection>;
31
31
  export interface FieldsManager {
@@ -1,6 +1,6 @@
1
1
  import { FieldFilesAndPromises, FieldValues, SerializedFieldValues } from '../typings';
2
- import { FieldSection } from './FieldSection';
3
2
  import { Field, SerializedField, SerializedOnlyField } from './typings';
3
+ import { FieldSection } from './FieldSection';
4
4
  export declare const deserializeField: (serializedField: SerializedOnlyField) => Field;
5
5
  export declare function deserializeFields(fields: SerializedField[]): (Field | FieldSection)[];
6
6
  export declare const deserialize: (serialized: SerializedField) => Field | FieldSection;
@@ -1,7 +1,7 @@
1
+ import { FieldValues, SerializedFieldValues } from '../typings';
1
2
  import { SerializedCondition } from '../conditions';
2
3
  import { Field, FieldSection, FieldSectionManager, SerializedFieldSection } from '../fields';
3
4
  import { Observable } from '../Observable';
4
- import { FieldValues, SerializedFieldValues } from '../typings';
5
5
  export declare class FieldSchema extends Observable<FieldSchema> implements FieldSectionManager {
6
6
  fieldSections: FieldSection[];
7
7
  constructor(fields: FieldSection[]);
@@ -1,6 +1,6 @@
1
1
  import { FormikErrors } from 'formik';
2
- import { AnyFormElement, SerializedFieldSection } from './fields';
3
2
  import { FieldFiles, FieldFilesAndPromises, FieldValues } from './typings';
3
+ import { AnyFormElement, SerializedFieldSection } from './fields';
4
4
  export declare const validateFields: (fields: AnyFormElement[], values: FieldValues) => FormikErrors<FieldValues> | undefined;
5
5
  export declare const cleanFields: (fields: AnyFormElement[], values: FieldValues) => FormikErrors<FieldValues> | undefined;
6
6
  export declare const separateImagesFromFields: (fields: SerializedFieldSection[]) => Promise<{
package/dist/forms.js CHANGED
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import { jsxs, jsx, Fragment as Fragment$1 } from "react/jsx-runtime";
5
- import { Card, LuIcon, Text, Spinner, Overlay, ButtonGroup, Tooltip, IconButton, Separator, Input, Badge, Checkbox, CheckboxGroup, Popover, Button, DayPicker, Menu, OneTimePasswordField, RadioGroup, TextArea, Rating, stopPropagation, Heading, useToast, ToggleGroup } from "@overmap-ai/blocks";
5
+ import { Card, LuIcon, Text, Spinner, Overlay, ButtonGroup, Tooltip, IconButton, Separator, Input, Badge, Checkbox, CheckboxGroup, Popover, Button, DayPicker, Menu, OneTimePasswordField, RadioGroup, TextArea, Rating, stopPropagation, Heading, toast, ToggleGroup } from "@overmap-ai/blocks";
6
6
  import { cx } from "class-variance-authority";
7
7
  import { forwardRef, createElement, memo, createContext, useContext, useRef, useCallback, useState, useEffect, useMemo, Fragment, use, useLayoutEffect, useId } from "react";
8
8
  import "@xyflow/react/dist/style.css";
@@ -825,7 +825,7 @@ const ImageViewerProvider = memo((props) => {
825
825
  ] });
826
826
  });
827
827
  ImageViewerProvider.displayName = "FileViewerProvider";
828
- const InputWithLabel = (props) => {
828
+ const InputWithLabel = memo((props) => {
829
829
  const { className, label, children, severity, inputId, labelId, image } = props;
830
830
  const [resolvedImage, setResolvedImage] = useState(void 0);
831
831
  const openImageViewer = useImageViewer();
@@ -857,7 +857,7 @@ const InputWithLabel = (props) => {
857
857
  !!label && /* @__PURE__ */ jsx("label", { className: cx(className, "w-max max-w-full"), htmlFor: inputId, children: /* @__PURE__ */ jsx(Text, { accentColor: color, size: "sm", id: labelId, className: "text-wrap", children: label }) }),
858
858
  children
859
859
  ] });
860
- };
860
+ });
861
861
  const InputWithLabelAndHelpText = (props) => {
862
862
  const { children, ...restProps } = props;
863
863
  return /* @__PURE__ */ jsx(InputWithHelpText, { ...restProps, children });
@@ -884,14 +884,14 @@ const useFormikInput = (props) => {
884
884
  const label = field.required ? `${field.label} *` : field.label;
885
885
  const fieldPropsWithValidation = useMemo(() => {
886
886
  const handleChange = (value) => {
887
- helpers.setValue(value, false).then();
887
+ void helpers.setValue(value, false);
888
888
  onValuesChange == null ? void 0 : onValuesChange(field.identifier, value);
889
889
  if (touched || !field.onlyValidateAfterTouched) {
890
890
  helpers.setError(field.getError(value));
891
891
  }
892
892
  };
893
893
  const handleBlur = (value) => {
894
- void helpers.setTouched(true, false).then();
894
+ void helpers.setTouched(true, false);
895
895
  helpers.setError(field.getError(value));
896
896
  };
897
897
  return {
@@ -2175,7 +2175,7 @@ const _OTPField = class _OTPField extends BaseField {
2175
2175
  const validators = super.getFieldValidators();
2176
2176
  const length = this.length;
2177
2177
  validators.push((value) => {
2178
- if (!this.isValueBlank(value) && (value.length < length || value.length > length)) {
2178
+ if (!this.isValueBlank(value) && value.length != length) {
2179
2179
  return `Must be ${length} characters.`;
2180
2180
  }
2181
2181
  });
@@ -2280,6 +2280,7 @@ class UUIDPromise extends Promise {
2280
2280
  Promise.resolve(promise).then(resolve).catch(reject);
2281
2281
  }, uuid);
2282
2282
  }
2283
+ // oxlint-disable-next-line no-thenable
2283
2284
  then(onFulfilled, onRejected) {
2284
2285
  const promise = super.then(onFulfilled, onRejected);
2285
2286
  promise.uuid = this.uuid;
@@ -2497,7 +2498,7 @@ const PassFailInput = memo((props) => {
2497
2498
  const handleRemoveFile = useCallback(
2498
2499
  (index) => {
2499
2500
  const files = [...value.files];
2500
- files.splice(index, 1);
2501
+ void files.splice(index, 1);
2501
2502
  onChange({
2502
2503
  ...value,
2503
2504
  files
@@ -25371,7 +25372,6 @@ var PDF417CodewordDecoder = (
25371
25372
  return PDF417CodewordDecoder2;
25372
25373
  }()
25373
25374
  );
25374
- const global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
25375
25375
  var PDF417ResultMetadata = (
25376
25376
  /** @class */
25377
25377
  function() {
@@ -25666,8 +25666,8 @@ function getBigIntConstructor() {
25666
25666
  if (typeof window !== "undefined") {
25667
25667
  return window["BigInt"] || null;
25668
25668
  }
25669
- if (typeof global$1 !== "undefined") {
25670
- return global$1["BigInt"] || null;
25669
+ if (typeof global !== "undefined") {
25670
+ return global["BigInt"] || null;
25671
25671
  }
25672
25672
  if (typeof self !== "undefined") {
25673
25673
  return self["BigInt"] || null;
@@ -31161,7 +31161,15 @@ const SCANNER_HINTS = /* @__PURE__ */ new Map([
31161
31161
  ]
31162
31162
  ]);
31163
31163
  const Scanner = memo((props) => {
31164
- const { children, open, onOpenChange, defaultOpen, modal, ...rest } = props;
31164
+ const {
31165
+ children,
31166
+ open,
31167
+ onOpenChange,
31168
+ // oxlint-disable-line unbound-method
31169
+ defaultOpen,
31170
+ modal,
31171
+ ...rest
31172
+ } = props;
31165
31173
  return /* @__PURE__ */ jsxs(Overlay.Root, { open, onOpenChange, defaultOpen, modal, children: [
31166
31174
  !!children && /* @__PURE__ */ jsx(Overlay.Trigger, { asChild: true, children }),
31167
31175
  /* @__PURE__ */ jsxs(Overlay.Content, { children: [
@@ -31569,7 +31577,7 @@ const UploadInput = memo((props) => {
31569
31577
  const handleRemove = useCallback(
31570
31578
  (index) => {
31571
31579
  const files = [...value];
31572
- files.splice(index, 1);
31580
+ void files.splice(index, 1);
31573
31581
  onChange(files);
31574
31582
  },
31575
31583
  [value, onChange]
@@ -34309,14 +34317,6 @@ const _FieldSection = class _FieldSection extends BaseFormElement {
34309
34317
  fields: this.fields.map((field) => field.serialize())
34310
34318
  };
34311
34319
  }
34312
- static deserialize(data) {
34313
- const fields = data.fields.map(deserializeField);
34314
- const conditions = {};
34315
- for (const [sectionId, serializedConditions] of Object.entries(data.conditions)) {
34316
- conditions[sectionId] = deserializeConditions(fields, serializedConditions);
34317
- }
34318
- return new _FieldSection({ ...data, fields, conditions });
34319
- }
34320
34320
  getOptions() {
34321
34321
  return {
34322
34322
  ...super.getOptions(),
@@ -34412,7 +34412,10 @@ const _FieldSection = class _FieldSection extends BaseFormElement {
34412
34412
  return new Set(Object.keys(this.conditions));
34413
34413
  }
34414
34414
  addConditional(identifier) {
34415
- this.conditions = this.initConditions({ ...this.conditions, [identifier]: [] });
34415
+ this.conditions = this.initConditions({
34416
+ ...this.conditions,
34417
+ [identifier]: []
34418
+ });
34416
34419
  this.notify(this);
34417
34420
  }
34418
34421
  removeConditional(identifier) {
@@ -34428,6 +34431,14 @@ const _FieldSection = class _FieldSection extends BaseFormElement {
34428
34431
  };
34429
34432
  __publicField(_FieldSection, "fieldTypeName", "Section");
34430
34433
  __publicField(_FieldSection, "fieldTypeDescription", "Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");
34434
+ __publicField(_FieldSection, "deserialize", (data) => {
34435
+ const fields = data.fields.map(deserializeField);
34436
+ const conditions = {};
34437
+ for (const [sectionId, serializedConditions] of Object.entries(data.conditions)) {
34438
+ conditions[sectionId] = deserializeConditions(fields, serializedConditions);
34439
+ }
34440
+ return new _FieldSection({ ...data, fields, conditions });
34441
+ });
34431
34442
  let FieldSection = _FieldSection;
34432
34443
  class FieldSchema extends Observable {
34433
34444
  constructor(fields) {
@@ -34894,7 +34905,6 @@ const FieldBuilder = memo((props) => {
34894
34905
  FieldBuilder.displayName = "FieldBuilder";
34895
34906
  const FieldBuilderWithActions = memo((props) => {
34896
34907
  const { field, fieldSection, fieldIndex, sectionIndex } = props;
34897
- const { showError } = useToast();
34898
34908
  const fileInputRef = useRef(null);
34899
34909
  const parentPath = `fields.${sectionIndex}.fields`;
34900
34910
  const handleAddField = useCallback(
@@ -34920,7 +34930,7 @@ const FieldBuilderWithActions = memo((props) => {
34920
34930
  const file = files.item(0);
34921
34931
  if (!file) return;
34922
34932
  if (file.size > maxFileSizeB) {
34923
- showError({
34933
+ toast.error({
34924
34934
  title: "File upload error",
34925
34935
  description: `The file ${file.name} exceeded the maximum file size`
34926
34936
  });
@@ -34930,7 +34940,7 @@ const FieldBuilderWithActions = memo((props) => {
34930
34940
  image: file
34931
34941
  });
34932
34942
  },
34933
- [field, showError]
34943
+ [field]
34934
34944
  );
34935
34945
  const handleMoveUp = useCallback(() => {
34936
34946
  moveField("up");
@@ -35706,9 +35716,6 @@ const separateImagesFromFields = async (fields) => {
35706
35716
  const images = {};
35707
35717
  const newFields = [];
35708
35718
  for (const section of fields) {
35709
- if (section.type !== "section") {
35710
- throw new Error(`Expected ISerializedField type to be a section. Got ${section.type} instead.`);
35711
- }
35712
35719
  const { fields: sectionFields } = section;
35713
35720
  const newSectionFields = [];
35714
35721
  for (const field of sectionFields) {
@@ -35764,9 +35771,9 @@ const FormRenderer = memo(
35764
35771
  }, [schema.fields, values]);
35765
35772
  const handleSubmit = useCallback(
35766
35773
  (values2) => {
35767
- onSubmit == null ? void 0 : onSubmit(
35774
+ void (onSubmit == null ? void 0 : onSubmit(
35768
35775
  excludeUnchangedFields ? changedFieldValues(flattenFields(schema.fields), initialValues, values2) : values2
35769
- );
35776
+ ));
35770
35777
  },
35771
35778
  [excludeUnchangedFields, initialValues, onSubmit, schema.fields]
35772
35779
  );
@@ -35876,43 +35883,39 @@ const FormBuilderRoot = memo((props) => {
35876
35883
  enableReinitialize = false,
35877
35884
  disableRequiredFields = false
35878
35885
  } = props;
35879
- const { showError } = useToast();
35880
- const validate = useCallback(
35881
- (form) => {
35882
- var _a2;
35883
- const errors = {};
35884
- if (!form.title) {
35885
- errors.title = "Title is required.";
35886
- }
35887
- if (!form.fields || form.fields.length === 0) {
35888
- errors.fields = "At least one field is required.";
35889
- }
35890
- const fieldsToValidate = [];
35891
- for (const [sectionIndex, section] of form.fields.entries())
35892
- for (const [fieldIndex, field] of section.fields.entries()) {
35893
- const fieldSettings = ((_a2 = getFieldCreationSchema(field.type, `fields.${sectionIndex}.fields.${fieldIndex}`)) == null ? void 0 : _a2.map(
35894
- ({ field: field2 }) => field2
35895
- )) ?? [];
35896
- fieldsToValidate.push(...fieldSettings);
35897
- }
35898
- const values = {};
35899
- for (const field of fieldsToValidate) {
35900
- values[field.identifier] = get(form, field.identifier);
35901
- }
35902
- const fieldErrors = validateFields(fieldsToValidate, values);
35903
- if (fieldErrors) {
35904
- errors.fields = fieldErrors.fields;
35905
- }
35906
- if (Object.keys(errors).length > 0) {
35907
- showError({
35908
- title: "Some form settings are invalid",
35909
- description: "Please check settings highlighted in red."
35910
- });
35911
- return errors;
35912
- }
35913
- },
35914
- [showError]
35915
- );
35886
+ const validate = useCallback((form) => {
35887
+ var _a2;
35888
+ const errors = {};
35889
+ if (!form.title) {
35890
+ errors.title = "Title is required.";
35891
+ }
35892
+ if (!form.fields || form.fields.length === 0) {
35893
+ errors.fields = "At least one field is required.";
35894
+ }
35895
+ const fieldsToValidate = [];
35896
+ for (const [sectionIndex, section] of form.fields.entries())
35897
+ for (const [fieldIndex, field] of section.fields.entries()) {
35898
+ const fieldSettings = ((_a2 = getFieldCreationSchema(field.type, `fields.${sectionIndex}.fields.${fieldIndex}`)) == null ? void 0 : _a2.map(
35899
+ ({ field: field2 }) => field2
35900
+ )) ?? [];
35901
+ fieldsToValidate.push(...fieldSettings);
35902
+ }
35903
+ const values = {};
35904
+ for (const field of fieldsToValidate) {
35905
+ values[field.identifier] = get(form, field.identifier);
35906
+ }
35907
+ const fieldErrors = validateFields(fieldsToValidate, values);
35908
+ if (fieldErrors) {
35909
+ errors.fields = fieldErrors.fields;
35910
+ }
35911
+ if (Object.keys(errors).length > 0) {
35912
+ toast.error({
35913
+ title: "Some form settings are invalid",
35914
+ description: "Please check settings highlighted in red."
35915
+ });
35916
+ return errors;
35917
+ }
35918
+ }, []);
35916
35919
  const initialValues = useMemo(
35917
35920
  () => ({
35918
35921
  title: initialTitle ?? "",
@@ -35931,7 +35934,7 @@ const FormBuilderRoot = memo((props) => {
35931
35934
  });
35932
35935
  const observer = useCallback(
35933
35936
  (fieldSchema) => {
35934
- formik.setFieldValue("fields", fieldSchema.serialize());
35937
+ void formik.setFieldValue("fields", fieldSchema.serialize());
35935
35938
  },
35936
35939
  [formik]
35937
35940
  );
@@ -36125,3 +36128,4 @@ export {
36125
36128
  useScanner,
36126
36129
  validateFields
36127
36130
  };
36131
+ //# sourceMappingURL=forms.js.map