@overmap-ai/forms 1.0.10 → 1.0.11-fix-dropdown-buttons.1

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.
@@ -1138,15 +1138,20 @@ var __publicField = (obj, key, value) => {
1138
1138
  const styles$2 = {
1139
1139
  previewImage
1140
1140
  };
1141
- const convertBytesToLargestUnit = (bytes) => {
1142
- const units = ["byte", "kilobyte", "megabyte"];
1143
- let sizeInUnit = bytes;
1141
+ const convertKilobytesToLargestUnit = (kilobytes) => {
1142
+ const units = ["kilobyte", "megabyte"];
1143
+ let sizeInUnit = kilobytes;
1144
1144
  let unitIndex = 0;
1145
1145
  while (sizeInUnit > 1024 && unitIndex < units.length - 1) {
1146
1146
  sizeInUnit /= 1024;
1147
1147
  unitIndex++;
1148
1148
  }
1149
- const formatter = new Intl.NumberFormat([], { maximumFractionDigits: 2, style: "unit", unit: units[unitIndex] });
1149
+ const formatter = new Intl.NumberFormat([], {
1150
+ // 0 for kilobytes, 1 for megabytes
1151
+ maximumFractionDigits: unitIndex,
1152
+ style: "unit",
1153
+ unit: units[unitIndex]
1154
+ });
1150
1155
  return formatter.format(sizeInUnit);
1151
1156
  };
1152
1157
  const NumberInput = React.memo(function NumberInput2(props) {
@@ -1160,7 +1165,7 @@ var __publicField = (obj, key, value) => {
1160
1165
  if (helpText)
1161
1166
  return helpText;
1162
1167
  if (field.maxFileSize) {
1163
- const size = convertBytesToLargestUnit(field.maxFileSize);
1168
+ const size = convertKilobytesToLargestUnit(field.maxFileSize);
1164
1169
  return `Maximum file size: ${size}`;
1165
1170
  }
1166
1171
  return null;
@@ -1228,7 +1233,7 @@ var __publicField = (obj, key, value) => {
1228
1233
  }
1229
1234
  if (resolvedFile) {
1230
1235
  name2 = resolvedFile.name;
1231
- size2 = convertBytesToLargestUnit(resolvedFile.size);
1236
+ size2 = convertKilobytesToLargestUnit(resolvedFile.size);
1232
1237
  } else {
1233
1238
  name2 = "Downloading...";
1234
1239
  size2 = "...";
@@ -1264,7 +1269,7 @@ var __publicField = (obj, key, value) => {
1264
1269
  url && /* @__PURE__ */ jsxRuntime.jsx("img", { className: styles$2.previewImage, src: url, alt: name })
1265
1270
  ] }) });
1266
1271
  });
1267
- const largestSupportedSize = 50 * 1024 * 1024;
1272
+ const largestSupportedSize = 50 * 1024;
1268
1273
  const _UploadField = class _UploadField extends BaseField {
1269
1274
  constructor(options) {
1270
1275
  const { extensions, maximum_files, maximum_size, ...base } = options;
@@ -1291,11 +1296,13 @@ var __publicField = (obj, key, value) => {
1291
1296
  required: false,
1292
1297
  minimum: 1,
1293
1298
  maximum: 10,
1294
- identifier: "maximum_files"
1299
+ identifier: "maximum_files",
1300
+ integers: true
1295
1301
  }),
1296
1302
  new NumberField({
1303
+ // TODO: Default value
1297
1304
  label: "What is the maximum size of each file?",
1298
- description: "Maximum file size in bytes.",
1305
+ description: "Maximum file size in kilobytes.",
1299
1306
  required: false,
1300
1307
  identifier: "maximum_size",
1301
1308
  minimum: 1,
@@ -1338,7 +1345,7 @@ var __publicField = (obj, key, value) => {
1338
1345
  const maxFiles = this.maxFiles ?? 1;
1339
1346
  validators.push((value) => {
1340
1347
  if (value && value.some((file) => file.size > maxFileSize)) {
1341
- return `Files must be at most ${convertBytesToLargestUnit(maxFileSize)}.`;
1348
+ return `Files must be at most ${convertKilobytesToLargestUnit(maxFileSize)}.`;
1342
1349
  }
1343
1350
  });
1344
1351
  validators.push((value) => {
@@ -2118,13 +2125,14 @@ var __publicField = (obj, key, value) => {
2118
2125
  trigger: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ jsxRuntime.jsx(reactIcons.DotsVerticalIcon, {}) }),
2119
2126
  closeOnSelect: false,
2120
2127
  items: actions.map((Action) => {
2121
- var _a;
2128
+ var _a, _b;
2122
2129
  if (Action.disableOnMobile)
2123
2130
  return null;
2124
2131
  const Wrapper = Action.Wrapper ?? DefaultWrapper;
2125
2132
  return {
2126
2133
  ...Action.buttonProps,
2127
2134
  onSelect: (_a = Action.buttonProps) == null ? void 0 : _a.onClick,
2135
+ onClick: (_b = Action.buttonProps) == null ? void 0 : _b.onClick,
2128
2136
  content: /* @__PURE__ */ jsxRuntime.jsx(Wrapper, { ...Action.wrapperProps, children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "2", align: "center", children: [
2129
2137
  /* @__PURE__ */ jsxRuntime.jsx(Action.Icon, {}),
2130
2138
  Action.text