@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.es.js +25 -11
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +25 -11
- package/dist/index.umd.js.map +1 -1
- package/dist/types/properties.d.ts +6 -0
- package/package.json +5 -5
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +1 -1
- package/src/types/properties.ts +7 -0
- package/src/util/useStorageUploadController.tsx +17 -0
package/dist/index.es.js
CHANGED
|
@@ -7443,6 +7443,7 @@ function useStorageUploadController({
|
|
|
7443
7443
|
const storage = property.dataType === "string" ? property.storage : property.dataType === "array" && property.of.dataType === "string" ? property.of.storage : void 0;
|
|
7444
7444
|
const multipleFilesSupported = property.dataType === "array";
|
|
7445
7445
|
if (!storage) throw Error("Storage meta must be specified");
|
|
7446
|
+
const processFile = storage?.processFile;
|
|
7446
7447
|
const metadata = storage?.metadata;
|
|
7447
7448
|
const size = multipleFilesSupported ? "medium" : "large";
|
|
7448
7449
|
const compression = storage?.imageCompression;
|
|
@@ -7519,29 +7520,42 @@ function useStorageUploadController({
|
|
|
7519
7520
|
}, [internalValue, multipleFilesSupported, onChange, storage, storageSource]);
|
|
7520
7521
|
const onFilesAdded = useCallback(async (acceptedFiles) => {
|
|
7521
7522
|
if (!acceptedFiles.length || disabled) return;
|
|
7523
|
+
if (processFile) {
|
|
7524
|
+
try {
|
|
7525
|
+
acceptedFiles = await Promise.all(acceptedFiles.map(async (file_1) => {
|
|
7526
|
+
const processedFile = await processFile(file_1);
|
|
7527
|
+
if (!processedFile) {
|
|
7528
|
+
return file_1;
|
|
7529
|
+
}
|
|
7530
|
+
return processedFile;
|
|
7531
|
+
}));
|
|
7532
|
+
} catch (e_1) {
|
|
7533
|
+
console.error("Error processing file with custom code. Attempting to continue uploading.", e_1);
|
|
7534
|
+
}
|
|
7535
|
+
}
|
|
7522
7536
|
let newInternalValue;
|
|
7523
7537
|
if (multipleFilesSupported) {
|
|
7524
|
-
newInternalValue = [...internalValue, ...await Promise.all(acceptedFiles.map(async (
|
|
7525
|
-
if (compression && compressionFormat(
|
|
7526
|
-
|
|
7538
|
+
newInternalValue = [...internalValue, ...await Promise.all(acceptedFiles.map(async (file_2) => {
|
|
7539
|
+
if (compression && compressionFormat(file_2)) {
|
|
7540
|
+
file_2 = await resizeAndCompressImage(file_2, compression);
|
|
7527
7541
|
}
|
|
7528
7542
|
return {
|
|
7529
7543
|
id: getRandomId$2(),
|
|
7530
|
-
file:
|
|
7531
|
-
fileName: await fileNameBuilder(
|
|
7544
|
+
file: file_2,
|
|
7545
|
+
fileName: await fileNameBuilder(file_2),
|
|
7532
7546
|
metadata,
|
|
7533
7547
|
size
|
|
7534
7548
|
};
|
|
7535
7549
|
}))];
|
|
7536
7550
|
} else {
|
|
7537
|
-
let
|
|
7538
|
-
if (compression && compressionFormat(
|
|
7539
|
-
|
|
7551
|
+
let file_3 = acceptedFiles[0];
|
|
7552
|
+
if (compression && compressionFormat(file_3)) {
|
|
7553
|
+
file_3 = await resizeAndCompressImage(file_3, compression);
|
|
7540
7554
|
}
|
|
7541
7555
|
newInternalValue = [{
|
|
7542
7556
|
id: getRandomId$2(),
|
|
7543
|
-
file:
|
|
7544
|
-
fileName: await fileNameBuilder(
|
|
7557
|
+
file: file_3,
|
|
7558
|
+
fileName: await fileNameBuilder(file_3),
|
|
7545
7559
|
metadata,
|
|
7546
7560
|
size
|
|
7547
7561
|
}];
|
|
@@ -9386,7 +9400,7 @@ const EntityCollectionRowActions = function EntityCollectionRowActions2({
|
|
|
9386
9400
|
] }, index_0)) }),
|
|
9387
9401
|
selectionEnabled && /* @__PURE__ */ jsx(Tooltip, { title: `Select ${entity.id}`, children: /* @__PURE__ */ jsx(Checkbox, { size: largeLayout ? "medium" : "small", checked: Boolean(isSelected), onCheckedChange }) })
|
|
9388
9402
|
] }),
|
|
9389
|
-
!hideId && size !== "xs" && /* @__PURE__ */ 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) => {
|
|
9403
|
+
!hideId && size !== "xs" && /* @__PURE__ */ 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) => {
|
|
9390
9404
|
event_1.stopPropagation();
|
|
9391
9405
|
}, children: [
|
|
9392
9406
|
hasDraft && /* @__PURE__ */ jsx(Tooltip, { title: "Local unsaved changes", className: "inline", children: /* @__PURE__ */ jsx(Chip, { colorScheme: "orangeDarker", className: "p-0.5", children: /* @__PURE__ */ jsx(EditIcon, { size: 12 }) }) }),
|