@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.
@@ -1 +1 @@
1
- export declare const convertKilobytesToLargestUnit: (kilobytes: number) => string;
1
+ export declare const convertBytesToLargestUnit: (bytes: number) => string;
@@ -8799,17 +8799,17 @@ const previewImage = "_previewImage_1ig84_1";
8799
8799
  const styles$2 = {
8800
8800
  previewImage
8801
8801
  };
8802
- const convertKilobytesToLargestUnit = (kilobytes) => {
8803
- const units = ["kilobyte", "megabyte"];
8804
- let sizeInUnit = kilobytes;
8802
+ const convertBytesToLargestUnit = (bytes) => {
8803
+ const units = ["byte", "kilobyte", "megabyte"];
8804
+ let sizeInUnit = bytes;
8805
8805
  let unitIndex = 0;
8806
- while (sizeInUnit > 1024 && unitIndex < units.length - 1) {
8807
- sizeInUnit /= 1024;
8806
+ while (sizeInUnit > 1e3 && unitIndex < units.length - 1) {
8807
+ sizeInUnit /= 1e3;
8808
8808
  unitIndex++;
8809
8809
  }
8810
8810
  const formatter = new Intl.NumberFormat([], {
8811
- // 0 for kilobytes, 1 for megabytes
8812
- maximumFractionDigits: unitIndex,
8811
+ // 0 for bytes and kilobytes, 1 for megabytes
8812
+ maximumFractionDigits: Math.max(0, unitIndex - 1),
8813
8813
  style: "unit",
8814
8814
  unit: units[unitIndex]
8815
8815
  });
@@ -8826,8 +8826,7 @@ const NumberInput = memo(function NumberInput22(props) {
8826
8826
  if (helpText)
8827
8827
  return helpText;
8828
8828
  if (field.maxFileSize) {
8829
- const size = convertKilobytesToLargestUnit(field.maxFileSize);
8830
- return `Maximum file size: ${size}`;
8829
+ return `Maximum file size: ${field.maxFileSize}MB`;
8831
8830
  }
8832
8831
  return null;
8833
8832
  }, [field.maxFileSize, helpText]);
@@ -8896,7 +8895,7 @@ const DisplayFile = memo(function DisplayFile2({ file, field, onRemove, disabled
8896
8895
  }
8897
8896
  if (resolvedFile) {
8898
8897
  name2 = resolvedFile.name;
8899
- size2 = convertKilobytesToLargestUnit(resolvedFile.size);
8898
+ size2 = convertBytesToLargestUnit(resolvedFile.size);
8900
8899
  } else {
8901
8900
  name2 = "Downloading...";
8902
8901
  size2 = "...";
@@ -8905,7 +8904,7 @@ const DisplayFile = memo(function DisplayFile2({ file, field, onRemove, disabled
8905
8904
  }, [resolvedFile]);
8906
8905
  useEffect(() => {
8907
8906
  if (file instanceof Promise) {
8908
- void file.then(setResolvedFile);
8907
+ file.then(setResolvedFile).catch(console.error);
8909
8908
  } else {
8910
8909
  setResolvedFile(file);
8911
8910
  }
@@ -8932,7 +8931,7 @@ const DisplayFile = memo(function DisplayFile2({ file, field, onRemove, disabled
8932
8931
  url && /* @__PURE__ */ jsx("img", { className: styles$2.previewImage, src: url, alt: name })
8933
8932
  ] }) });
8934
8933
  });
8935
- const largestSupportedSize = 50 * 1024;
8934
+ const largestSupportedSize = 50;
8936
8935
  const _UploadField = class _UploadField extends BaseField {
8937
8936
  constructor(options) {
8938
8937
  const { extensions, maximum_files, maximum_size, ...base } = options;
@@ -8965,7 +8964,7 @@ const _UploadField = class _UploadField extends BaseField {
8965
8964
  new NumberField({
8966
8965
  // TODO: Default value
8967
8966
  label: "What is the maximum size of each file?",
8968
- description: "Maximum file size in kilobytes.",
8967
+ description: `Maximum file size in megabytes (between 1MB–${largestSupportedSize}MB).`,
8969
8968
  required: false,
8970
8969
  identifier: "maximum_size",
8971
8970
  minimum: 1,
@@ -9004,11 +9003,12 @@ const _UploadField = class _UploadField extends BaseField {
9004
9003
  }
9005
9004
  getFieldValidators() {
9006
9005
  const validators = super.getFieldValidators();
9007
- const maxFileSize = this.maxFileSize ?? largestSupportedSize;
9006
+ const maxFileSizeInMB = this.maxFileSize ?? largestSupportedSize;
9007
+ const maxFileSizeInB = maxFileSizeInMB * 1e3 * 1e3;
9008
9008
  const maxFiles = this.maxFiles || 1;
9009
9009
  validators.push((value) => {
9010
- if (value && value.some((file) => file.size > maxFileSize)) {
9011
- return `Files must be at most ${convertKilobytesToLargestUnit(maxFileSize)}.`;
9010
+ if (value && value.some((file) => file.size > maxFileSizeInB)) {
9011
+ return `Files must be at most ${maxFileSizeInMB}MB.`;
9012
9012
  }
9013
9013
  });
9014
9014
  validators.push((value) => {