@firecms/core 3.0.0-canary.214 → 3.0.0-canary.216

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/index.umd.js CHANGED
@@ -7444,6 +7444,7 @@
7444
7444
  const storage = property.dataType === "string" ? property.storage : property.dataType === "array" && property.of.dataType === "string" ? property.of.storage : void 0;
7445
7445
  const multipleFilesSupported = property.dataType === "array";
7446
7446
  if (!storage) throw Error("Storage meta must be specified");
7447
+ const processFile = storage?.processFile;
7447
7448
  const metadata = storage?.metadata;
7448
7449
  const size = multipleFilesSupported ? "medium" : "large";
7449
7450
  const compression = storage?.imageCompression;
@@ -7520,29 +7521,42 @@
7520
7521
  }, [internalValue, multipleFilesSupported, onChange, storage, storageSource]);
7521
7522
  const onFilesAdded = React.useCallback(async (acceptedFiles) => {
7522
7523
  if (!acceptedFiles.length || disabled) return;
7524
+ if (processFile) {
7525
+ try {
7526
+ acceptedFiles = await Promise.all(acceptedFiles.map(async (file_1) => {
7527
+ const processedFile = await processFile(file_1);
7528
+ if (!processedFile) {
7529
+ return file_1;
7530
+ }
7531
+ return processedFile;
7532
+ }));
7533
+ } catch (e_1) {
7534
+ console.error("Error processing file with custom code. Attempting to continue uploading.", e_1);
7535
+ }
7536
+ }
7523
7537
  let newInternalValue;
7524
7538
  if (multipleFilesSupported) {
7525
- newInternalValue = [...internalValue, ...await Promise.all(acceptedFiles.map(async (file_1) => {
7526
- if (compression && compressionFormat(file_1)) {
7527
- file_1 = await resizeAndCompressImage(file_1, compression);
7539
+ newInternalValue = [...internalValue, ...await Promise.all(acceptedFiles.map(async (file_2) => {
7540
+ if (compression && compressionFormat(file_2)) {
7541
+ file_2 = await resizeAndCompressImage(file_2, compression);
7528
7542
  }
7529
7543
  return {
7530
7544
  id: getRandomId$2(),
7531
- file: file_1,
7532
- fileName: await fileNameBuilder(file_1),
7545
+ file: file_2,
7546
+ fileName: await fileNameBuilder(file_2),
7533
7547
  metadata,
7534
7548
  size
7535
7549
  };
7536
7550
  }))];
7537
7551
  } else {
7538
- let file_2 = acceptedFiles[0];
7539
- if (compression && compressionFormat(file_2)) {
7540
- file_2 = await resizeAndCompressImage(file_2, compression);
7552
+ let file_3 = acceptedFiles[0];
7553
+ if (compression && compressionFormat(file_3)) {
7554
+ file_3 = await resizeAndCompressImage(file_3, compression);
7541
7555
  }
7542
7556
  newInternalValue = [{
7543
7557
  id: getRandomId$2(),
7544
- file: file_2,
7545
- fileName: await fileNameBuilder(file_2),
7558
+ file: file_3,
7559
+ fileName: await fileNameBuilder(file_3),
7546
7560
  metadata,
7547
7561
  size
7548
7562
  }];
@@ -9387,7 +9401,7 @@
9387
9401
  ] }, index_0)) }),
9388
9402
  selectionEnabled && /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: `Select ${entity.id}`, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Checkbox, { size: largeLayout ? "medium" : "small", checked: Boolean(isSelected), onCheckedChange }) })
9389
9403
  ] }),
9390
- !hideId && size !== "xs" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-[138px] overflow-hidden truncate font-mono text-xs text-text-secondary dark:text-text-secondary-dark max-w-full text-ellipsis px-2 align-center flex items-center gap-1", onClick: (event_1) => {
9404
+ !hideId && size !== "xs" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-[138px] overflow-hidden truncate font-mono text-xs text-text-secondary dark:text-text-secondary-dark max-w-full text-ellipsis px-2 align-center justify-center flex items-center gap-1", onClick: (event_1) => {
9391
9405
  event_1.stopPropagation();
9392
9406
  }, children: [
9393
9407
  hasDraft && /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: "Local unsaved changes", className: "inline", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Chip, { colorScheme: "orangeDarker", className: "p-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(ui.EditIcon, { size: 12 }) }) }),