@overmap-ai/forms 1.0.32 → 1.0.33-toast-migration.0

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
@@ -813,7 +813,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
813
813
  ] });
814
814
  });
815
815
  ImageViewerProvider.displayName = "FileViewerProvider";
816
- const InputWithLabel = (props) => {
816
+ const InputWithLabel = React.memo((props) => {
817
817
  const { className, label, children, severity, inputId, labelId, image } = props;
818
818
  const [resolvedImage, setResolvedImage] = React.useState(void 0);
819
819
  const openImageViewer = useImageViewer();
@@ -845,7 +845,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
845
845
  !!label && /* @__PURE__ */ jsxRuntime.jsx("label", { className: classVarianceAuthority.cx(className, "w-max max-w-full"), htmlFor: inputId, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { accentColor: color, size: "sm", id: labelId, className: "text-wrap", children: label }) }),
846
846
  children
847
847
  ] });
848
- };
848
+ });
849
849
  const InputWithLabelAndHelpText = (props) => {
850
850
  const { children, ...restProps } = props;
851
851
  return /* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { ...restProps, children });
@@ -872,14 +872,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
872
872
  const label = field.required ? `${field.label} *` : field.label;
873
873
  const fieldPropsWithValidation = React.useMemo(() => {
874
874
  const handleChange = (value) => {
875
- helpers.setValue(value, false).then();
875
+ void helpers.setValue(value, false);
876
876
  onValuesChange == null ? void 0 : onValuesChange(field.identifier, value);
877
877
  if (touched || !field.onlyValidateAfterTouched) {
878
878
  helpers.setError(field.getError(value));
879
879
  }
880
880
  };
881
881
  const handleBlur = (value) => {
882
- void helpers.setTouched(true, false).then();
882
+ void helpers.setTouched(true, false);
883
883
  helpers.setError(field.getError(value));
884
884
  };
885
885
  return {
@@ -2163,7 +2163,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2163
2163
  const validators = super.getFieldValidators();
2164
2164
  const length = this.length;
2165
2165
  validators.push((value) => {
2166
- if (!this.isValueBlank(value) && (value.length < length || value.length > length)) {
2166
+ if (!this.isValueBlank(value) && value.length != length) {
2167
2167
  return `Must be ${length} characters.`;
2168
2168
  }
2169
2169
  });
@@ -2268,6 +2268,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2268
2268
  Promise.resolve(promise).then(resolve).catch(reject);
2269
2269
  }, uuid2);
2270
2270
  }
2271
+ // oxlint-disable-next-line no-thenable
2271
2272
  then(onFulfilled, onRejected) {
2272
2273
  const promise = super.then(onFulfilled, onRejected);
2273
2274
  promise.uuid = this.uuid;
@@ -2485,7 +2486,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2485
2486
  const handleRemoveFile = React.useCallback(
2486
2487
  (index) => {
2487
2488
  const files = [...value.files];
2488
- files.splice(index, 1);
2489
+ void files.splice(index, 1);
2489
2490
  onChange({
2490
2491
  ...value,
2491
2492
  files
@@ -25359,7 +25360,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
25359
25360
  return PDF417CodewordDecoder2;
25360
25361
  }()
25361
25362
  );
25362
- const global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
25363
25363
  var PDF417ResultMetadata = (
25364
25364
  /** @class */
25365
25365
  function() {
@@ -25654,8 +25654,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
25654
25654
  if (typeof window !== "undefined") {
25655
25655
  return window["BigInt"] || null;
25656
25656
  }
25657
- if (typeof global$1 !== "undefined") {
25658
- return global$1["BigInt"] || null;
25657
+ if (typeof global !== "undefined") {
25658
+ return global["BigInt"] || null;
25659
25659
  }
25660
25660
  if (typeof self !== "undefined") {
25661
25661
  return self["BigInt"] || null;
@@ -31149,7 +31149,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31149
31149
  ]
31150
31150
  ]);
31151
31151
  const Scanner = React.memo((props) => {
31152
- const { children, open, onOpenChange, defaultOpen, modal, ...rest } = props;
31152
+ const {
31153
+ children,
31154
+ open,
31155
+ onOpenChange,
31156
+ // oxlint-disable-line unbound-method
31157
+ defaultOpen,
31158
+ modal,
31159
+ ...rest
31160
+ } = props;
31153
31161
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Overlay.Root, { open, onOpenChange, defaultOpen, modal, children: [
31154
31162
  !!children && /* @__PURE__ */ jsxRuntime.jsx(blocks.Overlay.Trigger, { asChild: true, children }),
31155
31163
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.Overlay.Content, { children: [
@@ -31557,7 +31565,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31557
31565
  const handleRemove = React.useCallback(
31558
31566
  (index) => {
31559
31567
  const files = [...value];
31560
- files.splice(index, 1);
31568
+ void files.splice(index, 1);
31561
31569
  onChange(files);
31562
31570
  },
31563
31571
  [value, onChange]
@@ -34297,14 +34305,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34297
34305
  fields: this.fields.map((field) => field.serialize())
34298
34306
  };
34299
34307
  }
34300
- static deserialize(data) {
34301
- const fields = data.fields.map(deserializeField);
34302
- const conditions = {};
34303
- for (const [sectionId, serializedConditions] of Object.entries(data.conditions)) {
34304
- conditions[sectionId] = deserializeConditions(fields, serializedConditions);
34305
- }
34306
- return new _FieldSection({ ...data, fields, conditions });
34307
- }
34308
34308
  getOptions() {
34309
34309
  return {
34310
34310
  ...super.getOptions(),
@@ -34400,7 +34400,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34400
34400
  return new Set(Object.keys(this.conditions));
34401
34401
  }
34402
34402
  addConditional(identifier) {
34403
- this.conditions = this.initConditions({ ...this.conditions, [identifier]: [] });
34403
+ this.conditions = this.initConditions({
34404
+ ...this.conditions,
34405
+ [identifier]: []
34406
+ });
34404
34407
  this.notify(this);
34405
34408
  }
34406
34409
  removeConditional(identifier) {
@@ -34416,6 +34419,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34416
34419
  };
34417
34420
  __publicField(_FieldSection, "fieldTypeName", "Section");
34418
34421
  __publicField(_FieldSection, "fieldTypeDescription", "Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");
34422
+ __publicField(_FieldSection, "deserialize", (data) => {
34423
+ const fields = data.fields.map(deserializeField);
34424
+ const conditions = {};
34425
+ for (const [sectionId, serializedConditions] of Object.entries(data.conditions)) {
34426
+ conditions[sectionId] = deserializeConditions(fields, serializedConditions);
34427
+ }
34428
+ return new _FieldSection({ ...data, fields, conditions });
34429
+ });
34419
34430
  let FieldSection = _FieldSection;
34420
34431
  class FieldSchema extends Observable {
34421
34432
  constructor(fields) {
@@ -34882,7 +34893,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34882
34893
  FieldBuilder.displayName = "FieldBuilder";
34883
34894
  const FieldBuilderWithActions = React.memo((props) => {
34884
34895
  const { field, fieldSection, fieldIndex, sectionIndex } = props;
34885
- const { showError } = blocks.useToast();
34886
34896
  const fileInputRef = React.useRef(null);
34887
34897
  const parentPath = `fields.${sectionIndex}.fields`;
34888
34898
  const handleAddField = React.useCallback(
@@ -34908,7 +34918,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34908
34918
  const file = files.item(0);
34909
34919
  if (!file) return;
34910
34920
  if (file.size > maxFileSizeB) {
34911
- showError({
34921
+ blocks.toast.error({
34912
34922
  title: "File upload error",
34913
34923
  description: `The file ${file.name} exceeded the maximum file size`
34914
34924
  });
@@ -34918,7 +34928,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34918
34928
  image: file
34919
34929
  });
34920
34930
  },
34921
- [field, showError]
34931
+ [field]
34922
34932
  );
34923
34933
  const handleMoveUp = React.useCallback(() => {
34924
34934
  moveField("up");
@@ -35694,9 +35704,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
35694
35704
  const images = {};
35695
35705
  const newFields = [];
35696
35706
  for (const section of fields) {
35697
- if (section.type !== "section") {
35698
- throw new Error(`Expected ISerializedField type to be a section. Got ${section.type} instead.`);
35699
- }
35700
35707
  const { fields: sectionFields } = section;
35701
35708
  const newSectionFields = [];
35702
35709
  for (const field of sectionFields) {
@@ -35752,9 +35759,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
35752
35759
  }, [schema.fields, values]);
35753
35760
  const handleSubmit = React.useCallback(
35754
35761
  (values2) => {
35755
- onSubmit == null ? void 0 : onSubmit(
35762
+ void (onSubmit == null ? void 0 : onSubmit(
35756
35763
  excludeUnchangedFields ? changedFieldValues(flattenFields(schema.fields), initialValues, values2) : values2
35757
- );
35764
+ ));
35758
35765
  },
35759
35766
  [excludeUnchangedFields, initialValues, onSubmit, schema.fields]
35760
35767
  );
@@ -35864,43 +35871,39 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
35864
35871
  enableReinitialize = false,
35865
35872
  disableRequiredFields = false
35866
35873
  } = props;
35867
- const { showError } = blocks.useToast();
35868
- const validate = React.useCallback(
35869
- (form) => {
35870
- var _a2;
35871
- const errors = {};
35872
- if (!form.title) {
35873
- errors.title = "Title is required.";
35874
- }
35875
- if (!form.fields || form.fields.length === 0) {
35876
- errors.fields = "At least one field is required.";
35877
- }
35878
- const fieldsToValidate = [];
35879
- for (const [sectionIndex, section] of form.fields.entries())
35880
- for (const [fieldIndex, field] of section.fields.entries()) {
35881
- const fieldSettings = ((_a2 = getFieldCreationSchema(field.type, `fields.${sectionIndex}.fields.${fieldIndex}`)) == null ? void 0 : _a2.map(
35882
- ({ field: field2 }) => field2
35883
- )) ?? [];
35884
- fieldsToValidate.push(...fieldSettings);
35885
- }
35886
- const values = {};
35887
- for (const field of fieldsToValidate) {
35888
- values[field.identifier] = get(form, field.identifier);
35889
- }
35890
- const fieldErrors = validateFields(fieldsToValidate, values);
35891
- if (fieldErrors) {
35892
- errors.fields = fieldErrors.fields;
35893
- }
35894
- if (Object.keys(errors).length > 0) {
35895
- showError({
35896
- title: "Some form settings are invalid",
35897
- description: "Please check settings highlighted in red."
35898
- });
35899
- return errors;
35900
- }
35901
- },
35902
- [showError]
35903
- );
35874
+ const validate = React.useCallback((form) => {
35875
+ var _a2;
35876
+ const errors = {};
35877
+ if (!form.title) {
35878
+ errors.title = "Title is required.";
35879
+ }
35880
+ if (!form.fields || form.fields.length === 0) {
35881
+ errors.fields = "At least one field is required.";
35882
+ }
35883
+ const fieldsToValidate = [];
35884
+ for (const [sectionIndex, section] of form.fields.entries())
35885
+ for (const [fieldIndex, field] of section.fields.entries()) {
35886
+ const fieldSettings = ((_a2 = getFieldCreationSchema(field.type, `fields.${sectionIndex}.fields.${fieldIndex}`)) == null ? void 0 : _a2.map(
35887
+ ({ field: field2 }) => field2
35888
+ )) ?? [];
35889
+ fieldsToValidate.push(...fieldSettings);
35890
+ }
35891
+ const values = {};
35892
+ for (const field of fieldsToValidate) {
35893
+ values[field.identifier] = get(form, field.identifier);
35894
+ }
35895
+ const fieldErrors = validateFields(fieldsToValidate, values);
35896
+ if (fieldErrors) {
35897
+ errors.fields = fieldErrors.fields;
35898
+ }
35899
+ if (Object.keys(errors).length > 0) {
35900
+ blocks.toast.error({
35901
+ title: "Some form settings are invalid",
35902
+ description: "Please check settings highlighted in red."
35903
+ });
35904
+ return errors;
35905
+ }
35906
+ }, []);
35904
35907
  const initialValues = React.useMemo(
35905
35908
  () => ({
35906
35909
  title: initialTitle ?? "",
@@ -35919,7 +35922,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
35919
35922
  });
35920
35923
  const observer = React.useCallback(
35921
35924
  (fieldSchema) => {
35922
- formik$1.setFieldValue("fields", fieldSchema.serialize());
35925
+ void formik$1.setFieldValue("fields", fieldSchema.serialize());
35923
35926
  },
35924
35927
  [formik$1]
35925
35928
  );
@@ -36113,3 +36116,4 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
36113
36116
  exports2.validateFields = validateFields;
36114
36117
  Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
36115
36118
  });
36119
+ //# sourceMappingURL=forms.umd.cjs.map