@overmap-ai/forms 1.0.14 → 1.0.15
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.
- package/dist/fields/UploadField/utils.d.ts +1 -1
- package/dist/forms.js +10 -14
- package/dist/forms.js.map +1 -1
- package/dist/forms.umd.cjs +10 -14
- package/dist/forms.umd.cjs.map +1 -1
- package/package.json +3 -3
package/dist/forms.umd.cjs
CHANGED
|
@@ -1165,17 +1165,17 @@ var __publicField = (obj, key, value) => {
|
|
|
1165
1165
|
const styles$2 = {
|
|
1166
1166
|
previewImage
|
|
1167
1167
|
};
|
|
1168
|
-
const
|
|
1169
|
-
const units = ["kilobyte", "megabyte"];
|
|
1170
|
-
let sizeInUnit =
|
|
1168
|
+
const convertBytesToLargestUnit = (bytes) => {
|
|
1169
|
+
const units = ["byte", "kilobyte", "megabyte"];
|
|
1170
|
+
let sizeInUnit = bytes;
|
|
1171
1171
|
let unitIndex = 0;
|
|
1172
|
-
while (sizeInUnit >
|
|
1173
|
-
sizeInUnit /=
|
|
1172
|
+
while (sizeInUnit > 1e3 && unitIndex < units.length - 1) {
|
|
1173
|
+
sizeInUnit /= 1e3;
|
|
1174
1174
|
unitIndex++;
|
|
1175
1175
|
}
|
|
1176
1176
|
const formatter = new Intl.NumberFormat([], {
|
|
1177
|
-
|
|
1178
|
-
|
|
1177
|
+
maximumFractionDigits: Math.max(0, unitIndex - 1),
|
|
1178
|
+
// 0 for bytes and kilobytes, 1 for megabytes
|
|
1179
1179
|
style: "unit",
|
|
1180
1180
|
unit: units[unitIndex]
|
|
1181
1181
|
});
|
|
@@ -1259,7 +1259,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1259
1259
|
}
|
|
1260
1260
|
if (resolvedFile) {
|
|
1261
1261
|
name2 = resolvedFile.name;
|
|
1262
|
-
size2 =
|
|
1262
|
+
size2 = convertBytesToLargestUnit(resolvedFile.size);
|
|
1263
1263
|
} else {
|
|
1264
1264
|
name2 = "Downloading...";
|
|
1265
1265
|
size2 = "...";
|
|
@@ -1268,7 +1268,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1268
1268
|
}, [resolvedFile]);
|
|
1269
1269
|
React.useEffect(() => {
|
|
1270
1270
|
if (file instanceof Promise) {
|
|
1271
|
-
file.then(setResolvedFile);
|
|
1271
|
+
file.then(setResolvedFile).catch(console.error);
|
|
1272
1272
|
} else {
|
|
1273
1273
|
setResolvedFile(file);
|
|
1274
1274
|
}
|
|
@@ -1594,11 +1594,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1594
1594
|
const attachments = core.selectSubmissionAttachments(submission.offline_id)(sdk.store.getState()) ?? [];
|
|
1595
1595
|
const downloadedAttachments = {};
|
|
1596
1596
|
for (const attachment of attachments) {
|
|
1597
|
-
const promise = sdk.files.fetchFileFromUrl(attachment.file, attachment.file_sha1, attachment.file_name)
|
|
1598
|
-
if (!response.success)
|
|
1599
|
-
throw new Error(`Failed to download attachment ${attachment.file_name}.`);
|
|
1600
|
-
return response.body;
|
|
1601
|
-
});
|
|
1597
|
+
const promise = sdk.files.fetchFileFromUrl(attachment.file, attachment.file_sha1, attachment.file_name);
|
|
1602
1598
|
const fieldAttachments = downloadedAttachments[attachment.field_identifier];
|
|
1603
1599
|
if (fieldAttachments) {
|
|
1604
1600
|
fieldAttachments.push(promise);
|