@overmap-ai/core 1.0.28-integrate-forms.13 → 1.0.28-integrate-forms.14

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.
@@ -8796,17 +8796,17 @@ var __publicField = (obj, key, value) => {
8796
8796
  const styles$2 = {
8797
8797
  previewImage
8798
8798
  };
8799
- const convertKilobytesToLargestUnit = (kilobytes) => {
8800
- const units = ["kilobyte", "megabyte"];
8801
- let sizeInUnit = kilobytes;
8799
+ const convertBytesToLargestUnit = (bytes) => {
8800
+ const units = ["byte", "kilobyte", "megabyte"];
8801
+ let sizeInUnit = bytes;
8802
8802
  let unitIndex = 0;
8803
- while (sizeInUnit > 1024 && unitIndex < units.length - 1) {
8804
- sizeInUnit /= 1024;
8803
+ while (sizeInUnit > 1e3 && unitIndex < units.length - 1) {
8804
+ sizeInUnit /= 1e3;
8805
8805
  unitIndex++;
8806
8806
  }
8807
8807
  const formatter = new Intl.NumberFormat([], {
8808
- // 0 for kilobytes, 1 for megabytes
8809
- maximumFractionDigits: unitIndex,
8808
+ // 0 for bytes and kilobytes, 1 for megabytes
8809
+ maximumFractionDigits: Math.max(0, unitIndex - 1),
8810
8810
  style: "unit",
8811
8811
  unit: units[unitIndex]
8812
8812
  });
@@ -8823,8 +8823,7 @@ var __publicField = (obj, key, value) => {
8823
8823
  if (helpText)
8824
8824
  return helpText;
8825
8825
  if (field.maxFileSize) {
8826
- const size = convertKilobytesToLargestUnit(field.maxFileSize);
8827
- return `Maximum file size: ${size}`;
8826
+ return `Maximum file size: ${field.maxFileSize}MB`;
8828
8827
  }
8829
8828
  return null;
8830
8829
  }, [field.maxFileSize, helpText]);
@@ -8893,7 +8892,7 @@ var __publicField = (obj, key, value) => {
8893
8892
  }
8894
8893
  if (resolvedFile) {
8895
8894
  name2 = resolvedFile.name;
8896
- size2 = convertKilobytesToLargestUnit(resolvedFile.size);
8895
+ size2 = convertBytesToLargestUnit(resolvedFile.size);
8897
8896
  } else {
8898
8897
  name2 = "Downloading...";
8899
8898
  size2 = "...";
@@ -8902,7 +8901,7 @@ var __publicField = (obj, key, value) => {
8902
8901
  }, [resolvedFile]);
8903
8902
  React.useEffect(() => {
8904
8903
  if (file instanceof Promise) {
8905
- void file.then(setResolvedFile);
8904
+ file.then(setResolvedFile).catch(console.error);
8906
8905
  } else {
8907
8906
  setResolvedFile(file);
8908
8907
  }
@@ -8929,7 +8928,7 @@ var __publicField = (obj, key, value) => {
8929
8928
  url && /* @__PURE__ */ jsxRuntime.jsx("img", { className: styles$2.previewImage, src: url, alt: name })
8930
8929
  ] }) });
8931
8930
  });
8932
- const largestSupportedSize = 50 * 1024;
8931
+ const largestSupportedSize = 50;
8933
8932
  const _UploadField = class _UploadField extends BaseField {
8934
8933
  constructor(options) {
8935
8934
  const { extensions, maximum_files, maximum_size, ...base } = options;
@@ -8962,7 +8961,7 @@ var __publicField = (obj, key, value) => {
8962
8961
  new NumberField({
8963
8962
  // TODO: Default value
8964
8963
  label: "What is the maximum size of each file?",
8965
- description: "Maximum file size in kilobytes.",
8964
+ description: `Maximum file size in megabytes (between 1MB–${largestSupportedSize}MB).`,
8966
8965
  required: false,
8967
8966
  identifier: "maximum_size",
8968
8967
  minimum: 1,
@@ -9001,11 +9000,12 @@ var __publicField = (obj, key, value) => {
9001
9000
  }
9002
9001
  getFieldValidators() {
9003
9002
  const validators = super.getFieldValidators();
9004
- const maxFileSize = this.maxFileSize ?? largestSupportedSize;
9003
+ const maxFileSizeInMB = this.maxFileSize ?? largestSupportedSize;
9004
+ const maxFileSizeInB = maxFileSizeInMB * 1e3 * 1e3;
9005
9005
  const maxFiles = this.maxFiles || 1;
9006
9006
  validators.push((value) => {
9007
- if (value && value.some((file) => file.size > maxFileSize)) {
9008
- return `Files must be at most ${convertKilobytesToLargestUnit(maxFileSize)}.`;
9007
+ if (value && value.some((file) => file.size > maxFileSizeInB)) {
9008
+ return `Files must be at most ${maxFileSizeInMB}MB.`;
9009
9009
  }
9010
9010
  });
9011
9011
  validators.push((value) => {