@overmap-ai/forms 1.0.13 → 1.0.14-file-size-fixes.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.
- package/dist/forms.js +7 -7
- package/dist/forms.js.map +1 -1
- package/dist/forms.umd.cjs +7 -7
- package/dist/forms.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/forms.js
CHANGED
|
@@ -1200,8 +1200,7 @@ const NumberInput = memo(function NumberInput22(props) {
|
|
|
1200
1200
|
if (helpText)
|
|
1201
1201
|
return helpText;
|
|
1202
1202
|
if (field.maxFileSize) {
|
|
1203
|
-
|
|
1204
|
-
return `Maximum file size: ${size}`;
|
|
1203
|
+
return `Maximum file size: ${field.maxFileSize}MB`;
|
|
1205
1204
|
}
|
|
1206
1205
|
return null;
|
|
1207
1206
|
}, [field.maxFileSize, helpText]);
|
|
@@ -1304,7 +1303,7 @@ const DisplayFile = memo(function DisplayFile2({ file, field, onRemove, disabled
|
|
|
1304
1303
|
url && /* @__PURE__ */ jsx("img", { className: styles$2.previewImage, src: url, alt: name })
|
|
1305
1304
|
] }) });
|
|
1306
1305
|
});
|
|
1307
|
-
const largestSupportedSize = 50
|
|
1306
|
+
const largestSupportedSize = 50;
|
|
1308
1307
|
const _UploadField = class _UploadField extends BaseField {
|
|
1309
1308
|
constructor(options) {
|
|
1310
1309
|
const { extensions, maximum_files, maximum_size, ...base } = options;
|
|
@@ -1337,7 +1336,7 @@ const _UploadField = class _UploadField extends BaseField {
|
|
|
1337
1336
|
new NumberField({
|
|
1338
1337
|
// TODO: Default value
|
|
1339
1338
|
label: "What is the maximum size of each file?",
|
|
1340
|
-
description: "Maximum file size in
|
|
1339
|
+
description: "Maximum file size in megabytes (between 1MB-50MB).",
|
|
1341
1340
|
required: false,
|
|
1342
1341
|
identifier: "maximum_size",
|
|
1343
1342
|
minimum: 1,
|
|
@@ -1376,11 +1375,12 @@ const _UploadField = class _UploadField extends BaseField {
|
|
|
1376
1375
|
}
|
|
1377
1376
|
getFieldValidators() {
|
|
1378
1377
|
const validators = super.getFieldValidators();
|
|
1379
|
-
const
|
|
1378
|
+
const maxFileSizeInMB = this.maxFileSize ?? largestSupportedSize;
|
|
1379
|
+
const maxFileSizeInB = maxFileSizeInMB * 1e3 * 1e3;
|
|
1380
1380
|
const maxFiles = this.maxFiles ?? 1;
|
|
1381
1381
|
validators.push((value) => {
|
|
1382
|
-
if (value && value.some((file) => file.size >
|
|
1383
|
-
return `Files must be at most ${
|
|
1382
|
+
if (value && value.some((file) => file.size > maxFileSizeInB)) {
|
|
1383
|
+
return `Files must be at most ${maxFileSizeInMB}.`;
|
|
1384
1384
|
}
|
|
1385
1385
|
});
|
|
1386
1386
|
validators.push((value) => {
|