@firecms/core 3.0.0-canary.295 → 3.0.0-canary.297

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.
@@ -3,7 +3,7 @@ export interface StorageUploadItemProps {
3
3
  storagePath: string;
4
4
  metadata?: any;
5
5
  entry: StorageFieldItem;
6
- onFileUploadComplete: (value: string, entry: StorageFieldItem, metadata?: any) => Promise<void>;
6
+ onFileUploadComplete: (value: string, entry: StorageFieldItem, metadata?: any, uploadedUrl?: string) => Promise<void>;
7
7
  imageSize: number;
8
8
  simple: boolean;
9
9
  }
package/dist/index.es.js CHANGED
@@ -222,6 +222,15 @@ class EntityReference {
222
222
  get pathWithId() {
223
223
  return `${this.path}/${this.id}`;
224
224
  }
225
+ get pathWithIdAndDatabase() {
226
+ if (this.databaseId) {
227
+ if (this.databaseId === "(default)") {
228
+ return this.pathWithId;
229
+ }
230
+ return `${this.databaseId}:::${this.path}/${this.id}`;
231
+ }
232
+ return this.pathWithId;
233
+ }
225
234
  isEntityReference() {
226
235
  return true;
227
236
  }
@@ -6012,7 +6021,7 @@ const EntityPreviewContainer = React.forwardRef((t0, ref) => {
6012
6021
  const t7 = onClick ? "cursor-pointer" : "";
6013
6022
  let t8;
6014
6023
  if ($[11] !== className || $[12] !== t4 || $[13] !== t5 || $[14] !== t6 || $[15] !== t7) {
6015
- t8 = cls("bg-white dark:bg-surface-900", "min-h-[42px]", t4, "items-center", t5, t6, "flex border rounded-lg", t7, defaultBorderMixin, className);
6024
+ t8 = cls("bg-white dark:bg-surface-900", "min-h-[44px]", t4, "items-center", t5, t6, "flex border rounded-lg", t7, defaultBorderMixin, className);
6016
6025
  $[11] = className;
6017
6026
  $[12] = t4;
6018
6027
  $[13] = t5;
@@ -6097,7 +6106,7 @@ const ReferencePreview = function ReferencePreview2(props) {
6097
6106
  return t0;
6098
6107
  };
6099
6108
  function ReferencePreviewInternal(t0) {
6100
- const $ = c(16);
6109
+ const $ = c(22);
6101
6110
  const {
6102
6111
  disabled,
6103
6112
  reference,
@@ -6135,24 +6144,43 @@ function ReferencePreviewInternal(t0) {
6135
6144
  }
6136
6145
  return t42;
6137
6146
  } else {
6138
- throw Error(`Couldn't find the corresponding collection view for the path: ${reference.path}`);
6147
+ const t42 = size ?? "medium";
6148
+ let t5;
6149
+ if ($[6] !== reference.pathWithId) {
6150
+ t5 = /* @__PURE__ */ jsx(ErrorView, { error: "Unexpected reference value. Click to edit", tooltip: reference.pathWithId });
6151
+ $[6] = reference.pathWithId;
6152
+ $[7] = t5;
6153
+ } else {
6154
+ t5 = $[7];
6155
+ }
6156
+ let t6;
6157
+ if ($[8] !== onClick || $[9] !== t42 || $[10] !== t5) {
6158
+ t6 = /* @__PURE__ */ jsx(EntityPreviewContainer, { onClick, size: t42, children: t5 });
6159
+ $[8] = onClick;
6160
+ $[9] = t42;
6161
+ $[10] = t5;
6162
+ $[11] = t6;
6163
+ } else {
6164
+ t6 = $[11];
6165
+ }
6166
+ return t6;
6139
6167
  }
6140
6168
  }
6141
6169
  let t4;
6142
- if ($[6] !== collection || $[7] !== disabled || $[8] !== hover || $[9] !== includeEntityLink || $[10] !== includeId || $[11] !== onClick || $[12] !== previewProperties || $[13] !== reference || $[14] !== size) {
6170
+ if ($[12] !== collection || $[13] !== disabled || $[14] !== hover || $[15] !== includeEntityLink || $[16] !== includeId || $[17] !== onClick || $[18] !== previewProperties || $[19] !== reference || $[20] !== size) {
6143
6171
  t4 = /* @__PURE__ */ jsx(ReferencePreviewExisting, { reference, collection, previewProperties, size, disabled, includeEntityLink, includeId, onClick, hover });
6144
- $[6] = collection;
6145
- $[7] = disabled;
6146
- $[8] = hover;
6147
- $[9] = includeEntityLink;
6148
- $[10] = includeId;
6149
- $[11] = onClick;
6150
- $[12] = previewProperties;
6151
- $[13] = reference;
6152
- $[14] = size;
6153
- $[15] = t4;
6172
+ $[12] = collection;
6173
+ $[13] = disabled;
6174
+ $[14] = hover;
6175
+ $[15] = includeEntityLink;
6176
+ $[16] = includeId;
6177
+ $[17] = onClick;
6178
+ $[18] = previewProperties;
6179
+ $[19] = reference;
6180
+ $[20] = size;
6181
+ $[21] = t4;
6154
6182
  } else {
6155
- t4 = $[15];
6183
+ t4 = $[21];
6156
6184
  }
6157
6185
  return t4;
6158
6186
  }
@@ -8359,9 +8387,16 @@ function useStorageUploadController({
8359
8387
  propertyKey
8360
8388
  }) ?? "/";
8361
8389
  }, [entityId, entityValues, path, resolvedProperty, propertyKey, storage]);
8362
- const onFileUploadComplete = useCallback(async (uploadedPath, entry, metadata_0) => {
8390
+ const onFileUploadComplete = useCallback(async (uploadedPath, entry, metadata_0, uploadedUrl) => {
8363
8391
  console.debug("onFileUploadComplete", uploadedPath, entry);
8364
8392
  let uploadPathOrDownloadUrl = uploadedPath;
8393
+ if (storage.includeBucketUrl) {
8394
+ if (!uploadedUrl) {
8395
+ console.warn("includeBucketUrl is set but no fully-qualified storage URL was returned by the StorageSource. Falling back to the storage path.");
8396
+ } else {
8397
+ uploadPathOrDownloadUrl = uploadedUrl;
8398
+ }
8399
+ }
8365
8400
  if (storage.storeUrl) {
8366
8401
  uploadPathOrDownloadUrl = (await storageSource.getDownloadURL(uploadedPath)).url;
8367
8402
  }
@@ -8534,10 +8569,11 @@ function StorageUploadProgress({
8534
8569
  path: storagePath,
8535
8570
  metadata
8536
8571
  }).then(async ({
8537
- path
8572
+ path,
8573
+ storageUrl
8538
8574
  }) => {
8539
8575
  console.debug("Upload successful", path);
8540
- await onFileUploadComplete(path, entry, metadata);
8576
+ await onFileUploadComplete(path, entry, metadata, storageUrl);
8541
8577
  if (mounted.current) setLoading(false);
8542
8578
  }).catch((e) => {
8543
8579
  console.warn("Upload error", e);
@@ -10213,10 +10249,6 @@ function getEntityFromCache(path) {
10213
10249
  const entityString = localStorage.getItem(key);
10214
10250
  if (entityString) {
10215
10251
  const entity = JSON.parse(entityString, customReviver);
10216
- console.log("Loaded entity from localStorage:", {
10217
- key,
10218
- entity
10219
- });
10220
10252
  return entity;
10221
10253
  }
10222
10254
  } catch (error) {
@@ -11520,7 +11552,7 @@ const VirtualTable = React__default.memo(function VirtualTable2({
11520
11552
  /* @__PURE__ */ jsx(AssignmentIcon, {}),
11521
11553
  emptyComponent
11522
11554
  ] }) : void 0;
11523
- const virtualListController = {
11555
+ const virtualListController = useMemo(() => ({
11524
11556
  data,
11525
11557
  rowHeight,
11526
11558
  cellRenderer,
@@ -11539,7 +11571,7 @@ const VirtualTable = React__default.memo(function VirtualTable2({
11539
11571
  rowClassName,
11540
11572
  endAdornment,
11541
11573
  AddColumnComponent
11542
- };
11574
+ }), [data, rowHeight, cellRenderer, columns, currentSort, onRowClick, customView, onColumnResizeInternal, onColumnResizeEndInternal, filterInput, onColumnSort, onFilterUpdateInternal, sortByProperty, hoverRow, createFilterField2, rowClassName, endAdornment, AddColumnComponent]);
11543
11575
  return /* @__PURE__ */ jsx("div", { ref: measureRef, style, className: cls("h-full w-full", className), children: /* @__PURE__ */ jsx(VirtualListContext.Provider, { value: virtualListController, children: /* @__PURE__ */ jsx(MemoizedList, { outerRef: tableRef, width: bounds.width, height: bounds.height, itemCount: (data?.length ?? 0) + (endAdornment ? 1 : 0), onScroll, includeAddColumn: Boolean(AddColumnComponent), itemSize: rowHeight }, rowHeight) }) });
11544
11576
  }, equal);
11545
11577
  function MemoizedList({
@@ -23693,7 +23725,15 @@ function SideDialogView({
23693
23725
  pendingClose,
23694
23726
  setPendingClose
23695
23727
  }, children: [
23696
- /* @__PURE__ */ jsxs(Sheet, { open: Boolean(panel), onOpenChange: (open) => !open && onCloseRequest(), title: "Side dialog " + panel?.key, children: [
23728
+ /* @__PURE__ */ jsxs(Sheet, { open: Boolean(panel), onOpenChange: (open) => {
23729
+ if (!open) {
23730
+ const suggestionMenu = document.querySelector('[data-suggestion-menu="true"]');
23731
+ if (suggestionMenu && window.getComputedStyle(suggestionMenu).visibility !== "hidden") {
23732
+ return;
23733
+ }
23734
+ onCloseRequest();
23735
+ }
23736
+ }, title: "Side dialog " + panel?.key, children: [
23697
23737
  panel && /* @__PURE__ */ jsx("div", { className: "transform max-w-[100vw] lg:max-w-[95vw] flex flex-col h-full transition-all duration-250 ease-in-out bg-white dark:bg-surface-900 ", style: {
23698
23738
  width: panel.width,
23699
23739
  transform: `translateX(-${offsetPosition * 200}px)`