@firecms/core 3.0.0-canary.112 → 3.0.0-canary.114

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.
Files changed (40) hide show
  1. package/dist/components/ArrayContainer.d.ts +2 -1
  2. package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +1 -1
  3. package/dist/components/EntityPreview.d.ts +1 -1
  4. package/dist/form/components/FormikArrayContainer.d.ts +2 -1
  5. package/dist/index.es.js +167 -117
  6. package/dist/index.es.js.map +1 -1
  7. package/dist/index.umd.js +166 -116
  8. package/dist/index.umd.js.map +1 -1
  9. package/dist/preview/components/ReferencePreview.d.ts +1 -1
  10. package/dist/types/datasource.d.ts +8 -6
  11. package/dist/types/entity_overrides.d.ts +2 -2
  12. package/dist/types/side_dialogs_controller.d.ts +10 -0
  13. package/dist/util/icons.d.ts +1 -0
  14. package/package.json +5 -5
  15. package/src/components/ArrayContainer.tsx +7 -4
  16. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +13 -8
  17. package/src/components/EntityCollectionView/EntityCollectionView.tsx +1 -1
  18. package/src/components/EntityPreview.tsx +20 -22
  19. package/src/components/HomePage/DefaultHomePage.tsx +7 -9
  20. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +7 -2
  21. package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +3 -3
  22. package/src/components/VirtualTable/fields/VirtualTableInput.tsx +2 -1
  23. package/src/components/VirtualTable/fields/VirtualTableNumberInput.tsx +2 -1
  24. package/src/core/EntityEditView.tsx +20 -18
  25. package/src/core/SideDialogs.tsx +0 -2
  26. package/src/form/components/FormikArrayContainer.tsx +4 -1
  27. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +4 -4
  28. package/src/form/field_bindings/BlockFieldBinding.tsx +2 -1
  29. package/src/form/field_bindings/ReferenceFieldBinding.tsx +5 -4
  30. package/src/hooks/data/delete.ts +2 -1
  31. package/src/hooks/data/useDataSource.tsx +10 -2
  32. package/src/hooks/useBuildNavigationController.tsx +2 -4
  33. package/src/internal/useBuildDataSource.ts +41 -67
  34. package/src/internal/useBuildSideDialogsController.tsx +1 -0
  35. package/src/internal/useBuildSideEntityController.tsx +13 -2
  36. package/src/preview/components/ReferencePreview.tsx +2 -13
  37. package/src/types/datasource.ts +9 -6
  38. package/src/types/entity_overrides.tsx +2 -2
  39. package/src/types/side_dialogs_controller.tsx +13 -0
  40. package/src/util/icons.tsx +8 -2
package/dist/index.umd.js CHANGED
@@ -2688,7 +2688,11 @@
2688
2688
  return iconKey in iconKeysMap ? /* @__PURE__ */ jsxRuntime.jsx(ui.Icon, { iconKey, size: "medium", className }) : void 0;
2689
2689
  }
2690
2690
  const IconForView = React.memo(
2691
- function IconForView2({ collectionOrView, className }) {
2691
+ function IconForView2({
2692
+ collectionOrView,
2693
+ className,
2694
+ size = "medium"
2695
+ }) {
2692
2696
  if (!collectionOrView) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
2693
2697
  const icon = getIcon(collectionOrView.icon, className);
2694
2698
  if (collectionOrView?.icon && icon)
@@ -2705,7 +2709,7 @@
2705
2709
  const iconsCount = ui.coolIconKeys.length;
2706
2710
  if (!key)
2707
2711
  key = ui.coolIconKeys[hashString(collectionOrView.path) % iconsCount];
2708
- return /* @__PURE__ */ jsxRuntime.jsx(ui.Icon, { iconKey: key, size: "medium", className });
2712
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Icon, { iconKey: key, size, className });
2709
2713
  },
2710
2714
  (prevProps, nextProps) => {
2711
2715
  return equal(prevProps.collectionOrView?.icon, nextProps.collectionOrView?.icon);
@@ -3252,8 +3256,6 @@
3252
3256
  const DataSourceContext = React.createContext({});
3253
3257
  const useDataSource = (collection) => {
3254
3258
  const defaultDataSource = React.useContext(DataSourceContext);
3255
- if (collection?.overrides?.dataSource)
3256
- return collection?.overrides.dataSource;
3257
3259
  return defaultDataSource;
3258
3260
  };
3259
3261
  const NavigationContext = React.createContext({});
@@ -3391,7 +3393,7 @@
3391
3393
  itemCount,
3392
3394
  searchString
3393
3395
  }) {
3394
- const dataSource = useDataSource(collection);
3396
+ const dataSource = useDataSource();
3395
3397
  const navigationController = useNavigationController();
3396
3398
  const path = navigationController.resolveAliasesFrom(inputPath);
3397
3399
  const sortByProperty = sortBy ? sortBy[0] : void 0;
@@ -3474,7 +3476,7 @@
3474
3476
  collection,
3475
3477
  useCache = false
3476
3478
  }) {
3477
- const dataSource = useDataSource(collection);
3479
+ const dataSource = useDataSource();
3478
3480
  const navigationController = useNavigationController();
3479
3481
  const path = navigationController.resolveAliasesFrom(inputPath);
3480
3482
  const context = useFireCMSContext();
@@ -3685,7 +3687,8 @@
3685
3687
  }
3686
3688
  }
3687
3689
  return dataSource.deleteEntity({
3688
- entity
3690
+ entity,
3691
+ collection
3689
3692
  }).then(() => {
3690
3693
  onDeleteSuccess && onDeleteSuccess(entity);
3691
3694
  try {
@@ -4085,7 +4088,6 @@
4085
4088
  );
4086
4089
  let shouldUpdateTopLevelNav = false;
4087
4090
  if (!areCollectionListsEqual(collectionsRef.current ?? [], resolvedCollections)) {
4088
- console.log("Collections need to be updated");
4089
4091
  collectionsRef.current = resolvedCollections;
4090
4092
  shouldUpdateTopLevelNav = true;
4091
4093
  }
@@ -4094,12 +4096,10 @@
4094
4096
  shouldUpdateTopLevelNav = true;
4095
4097
  }
4096
4098
  if (!equal(viewsRef.current, resolvedViews)) {
4097
- console.log("Views need to be updated");
4098
4099
  viewsRef.current = resolvedViews;
4099
4100
  shouldUpdateTopLevelNav = true;
4100
4101
  }
4101
4102
  if (!equal(adminViewsRef.current, resolvedAdminViews)) {
4102
- console.log("Admin views need to be updated");
4103
4103
  adminViewsRef.current = resolvedAdminViews;
4104
4104
  shouldUpdateTopLevelNav = true;
4105
4105
  }
@@ -4969,8 +4969,8 @@
4969
4969
  function renderSkeletonIcon() {
4970
4970
  return /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { width: 24, height: 24 });
4971
4971
  }
4972
- const StorageThumbnail = React.memo(StorageThumbnailInternal, areEqual$2);
4973
- function areEqual$2(prevProps, nextProps) {
4972
+ const StorageThumbnail = React.memo(StorageThumbnailInternal, areEqual$1);
4973
+ function areEqual$1(prevProps, nextProps) {
4974
4974
  return prevProps.size === nextProps.size && prevProps.storagePathOrDownloadUrl === nextProps.storagePathOrDownloadUrl && prevProps.storeUrl === nextProps.storeUrl && prevProps.interactive === nextProps.interactive;
4975
4975
  }
4976
4976
  const URL_CACHE = {};
@@ -5177,15 +5177,18 @@
5177
5177
  hover: disabled ? void 0 : hover,
5178
5178
  size,
5179
5179
  children: [
5180
- imageProperty && /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls("w-10 h-10 mr-2 shrink-0 grow-0", size === "smallest" ? "my-0.5" : "m-2 self-start"), children: /* @__PURE__ */ jsxRuntime.jsx(
5181
- PropertyPreview,
5182
- {
5183
- property: imageProperty,
5184
- propertyKey: imagePropertyKey,
5185
- size: "smallest",
5186
- value: getValueInPath(entity.values, imagePropertyKey)
5187
- }
5188
- ) }),
5180
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("w-10 h-10 mr-2 shrink-0 grow-0", size === "smallest" ? "my-0.5" : "m-2 self-start"), children: [
5181
+ imageProperty && /* @__PURE__ */ jsxRuntime.jsx(
5182
+ PropertyPreview,
5183
+ {
5184
+ property: imageProperty,
5185
+ propertyKey: imagePropertyKey,
5186
+ size: "smallest",
5187
+ value: getValueInPath(entity.values, imagePropertyKey)
5188
+ }
5189
+ ),
5190
+ !imageProperty && /* @__PURE__ */ jsxRuntime.jsx(IconForView, { collectionOrView: collection, size, className: "mr-2" })
5191
+ ] }),
5189
5192
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col flex-grow w-full m-1", children: [
5190
5193
  size !== "smallest" && includeId && (entity ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${size !== "medium" ? "block whitespace-nowrap overflow-hidden truncate" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(
5191
5194
  ui.Typography,
@@ -5265,7 +5268,7 @@
5265
5268
  }
5266
5269
  );
5267
5270
  }
5268
- const EntityPreviewContainerInner = React__namespace.forwardRef(({
5271
+ const EntityPreviewContainer = React__namespace.forwardRef(({
5269
5272
  children,
5270
5273
  hover,
5271
5274
  onClick,
@@ -5307,9 +5310,7 @@
5307
5310
  }
5308
5311
  );
5309
5312
  });
5310
- EntityPreviewContainerInner.displayName = "EntityPreviewContainer";
5311
- const EntityPreviewContainer = React__namespace.memo(EntityPreviewContainerInner);
5312
- const ReferencePreview = React__namespace.memo(function ReferencePreview2(props) {
5313
+ const ReferencePreview = function ReferencePreview2(props) {
5313
5314
  const reference = props.reference;
5314
5315
  if (!(typeof reference === "object" && "isEntityReference" in reference && reference.isEntityReference())) {
5315
5316
  console.warn("Reference preview received value of type", typeof reference);
@@ -5329,10 +5330,7 @@
5329
5330
  );
5330
5331
  }
5331
5332
  return /* @__PURE__ */ jsxRuntime.jsx(ReferencePreviewInternal, { ...props });
5332
- }, areEqual$1);
5333
- function areEqual$1(prevProps, nextProps) {
5334
- return prevProps.disabled === nextProps.disabled && prevProps.size === nextProps.size && prevProps.hover === nextProps.hover && prevProps.reference?.id === nextProps.reference?.id && prevProps.reference?.path === nextProps.reference?.path && prevProps.includeEntityLink === nextProps.includeEntityLink && prevProps.onClick === nextProps.onClick;
5335
- }
5333
+ };
5336
5334
  function ReferencePreviewInternal({
5337
5335
  disabled,
5338
5336
  reference,
@@ -6293,6 +6291,7 @@
6293
6291
  return /* @__PURE__ */ jsxRuntime.jsx(
6294
6292
  ui.TextareaAutosize,
6295
6293
  {
6294
+ className: ui.focusedDisabled,
6296
6295
  ref,
6297
6296
  style: {
6298
6297
  padding: 0,
@@ -6493,7 +6492,7 @@
6493
6492
  "input",
6494
6493
  {
6495
6494
  ref,
6496
- className: "w-full text-right p-0 m-0 bg-transparent border-none resize-none outline-none font-normal leading-normal text-unset",
6495
+ className: ui.cls("w-full text-right p-0 m-0 bg-transparent border-none resize-none outline-none font-normal leading-normal text-unset", ui.focusedDisabled),
6497
6496
  style: {
6498
6497
  textAlign: align
6499
6498
  },
@@ -6546,8 +6545,8 @@
6546
6545
  onChange: (dateValue) => updateValue(dateValue ?? null),
6547
6546
  size: "medium",
6548
6547
  invisible: true,
6549
- className: "w-full h-full",
6550
- inputClassName: "w-full h-full",
6548
+ inputClassName: ui.cls("w-full h-full", ui.focusedDisabled),
6549
+ className: ui.cls("w-full h-full", ui.focusedDisabled),
6551
6550
  mode,
6552
6551
  locale
6553
6552
  }
@@ -7158,10 +7157,10 @@
7158
7157
  throw Error(`Couldn't find the corresponding collection view for the path: ${path}`);
7159
7158
  }
7160
7159
  }
7161
- return /* @__PURE__ */ jsxRuntime.jsx(TableReferenceFieldSuccess, { ...props, collection });
7160
+ return /* @__PURE__ */ jsxRuntime.jsx(TableReferenceFieldInternal, { ...props, collection });
7162
7161
  }
7163
- const TableReferenceFieldSuccess = React.memo(
7164
- function TableReferenceFieldSuccess2(props) {
7162
+ const TableReferenceFieldInternal = React.memo(
7163
+ function TableReferenceFieldInternal2(props) {
7165
7164
  const {
7166
7165
  name,
7167
7166
  internalValue,
@@ -7196,11 +7195,11 @@
7196
7195
  forceFilter
7197
7196
  }
7198
7197
  );
7199
- const handleOpen = React.useCallback(() => {
7198
+ const handleOpen = () => {
7200
7199
  if (disabled)
7201
7200
  return;
7202
7201
  referenceDialogController.open();
7203
- }, [disabled, referenceDialogController]);
7202
+ };
7204
7203
  const valueNotSet = !internalValue || Array.isArray(internalValue) && internalValue.length === 0;
7205
7204
  const buildSingleReferenceField = () => {
7206
7205
  if (internalValue && !Array.isArray(internalValue) && internalValue.isEntityReference && internalValue.isEntityReference())
@@ -7263,12 +7262,21 @@
7263
7262
  EntityPreviewContainer,
7264
7263
  {
7265
7264
  className: ui.cls(
7266
- "p-4 text-sm font-medium flex items-center gap-4 uppercase",
7265
+ "p-4 text-sm font-medium flex items-center uppercase",
7266
+ multiselect ? "gap-4" : "gap-6",
7267
7267
  disabled ? "text-slate-500" : "cursor-pointer text-slate-700 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-gray-800 group-hover:bg-slate-50 dark:group-hover:bg-gray-800"
7268
7268
  ),
7269
7269
  onClick: handleOpen,
7270
7270
  size: "medium",
7271
7271
  children: [
7272
+ /* @__PURE__ */ jsxRuntime.jsx(
7273
+ IconForView,
7274
+ {
7275
+ size: "small",
7276
+ collectionOrView: collection,
7277
+ className: "text-gray-300 dark:text-gray-600"
7278
+ }
7279
+ ),
7272
7280
  "Edit ",
7273
7281
  title
7274
7282
  ]
@@ -10352,7 +10360,7 @@
10352
10360
  } = collection;
10353
10361
  const [popupCell, setPopupCell] = React.useState(void 0);
10354
10362
  const navigation = useNavigationController();
10355
- const dataSource = useDataSource(collection);
10363
+ const dataSource = useDataSource();
10356
10364
  const resolvedPath = React.useMemo(() => navigation.resolveAliasesFrom(fullPath), [fullPath, navigation.resolveAliasesFrom]);
10357
10365
  const forceFilter = forceFilterFromProps ?? forceFilterFromCollection;
10358
10366
  const paginationEnabled = collection.pagination === void 0 || Boolean(collection.pagination);
@@ -10600,7 +10608,7 @@
10600
10608
  onMultipleEntitiesDelete,
10601
10609
  path
10602
10610
  }) {
10603
- const dataSource = useDataSource(collection);
10611
+ const dataSource = useDataSource();
10604
10612
  const customizationController = useCustomizationController();
10605
10613
  const snackbarController = useSnackbarController();
10606
10614
  const [loading, setLoading] = React.useState(false);
@@ -10895,7 +10903,8 @@
10895
10903
  const analyticsController = useAnalyticsController();
10896
10904
  const customizationController = useCustomizationController();
10897
10905
  const fullPath = navigation.resolveAliasesFrom(pathInput);
10898
- const dataSource = useDataSource(collection);
10906
+ console.trace("Opening reference dialog for path " + fullPath);
10907
+ const dataSource = useDataSource();
10899
10908
  const [entitiesDisplayedFirst, setEntitiesDisplayedFirst] = React.useState([]);
10900
10909
  const toggleEntitySelection = (entity) => {
10901
10910
  let newValue;
@@ -11050,7 +11059,17 @@
11050
11059
  tableController,
11051
11060
  enablePopupIcon: false,
11052
11061
  tableRowActionsBuilder,
11053
- title: /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "subtitle2", children: collection.singularName ? `Select ${collection.singularName}` : `Select from ${collection.name}` }),
11062
+ title: /* @__PURE__ */ jsxRuntime.jsxs(ui.Typography, { variant: "subtitle2", className: "flex flex-row gap-2", children: [
11063
+ /* @__PURE__ */ jsxRuntime.jsx(
11064
+ IconForView,
11065
+ {
11066
+ size: "small",
11067
+ collectionOrView: collection,
11068
+ className: "text-gray-300 dark:text-gray-600"
11069
+ }
11070
+ ),
11071
+ collection.singularName ? `Select ${collection.singularName}` : `Select from ${collection.name}`
11072
+ ] }),
11054
11073
  defaultSize: collection.defaultSize,
11055
11074
  properties: resolvedCollection.properties,
11056
11075
  forceFilter,
@@ -11482,15 +11501,11 @@
11482
11501
  groups
11483
11502
  } = navigationController.topLevelNavigation;
11484
11503
  const [filteredUrls, setFilteredUrls] = React.useState(null);
11485
- const filteredNavigationEntries = filteredUrls ? navigationEntries.filter((entry) => filteredUrls.includes(entry.url)) : navigationEntries;
11504
+ const performingSearch = Boolean(filteredUrls);
11505
+ const filteredNavigationEntries = filteredUrls ? filteredUrls.map((url) => navigationEntries.find((e) => e.url === url)).filter(Boolean) : navigationEntries;
11486
11506
  React.useEffect(() => {
11487
11507
  fuse.current = new Fuse(navigationEntries, {
11488
- keys: [
11489
- "name",
11490
- "description",
11491
- "group",
11492
- "path"
11493
- ]
11508
+ keys: ["name", "description", "group", "path"]
11494
11509
  });
11495
11510
  }, [navigationEntries]);
11496
11511
  const updateSearchResults = React.useCallback(
@@ -11507,7 +11522,8 @@
11507
11522
  },
11508
11523
  []
11509
11524
  );
11510
- const allGroups = [...groups];
11525
+ const filteredGroups = filteredUrls ? filteredNavigationEntries.map((entry) => entry.group) : [];
11526
+ const allGroups = filteredUrls ? filteredGroups.filter((group, index) => filteredGroups.indexOf(group) === index) : [...groups];
11511
11527
  if (filteredNavigationEntries.filter((e) => !e.group).length > 0 || filteredNavigationEntries.length === 0) {
11512
11528
  allGroups.push(void 0);
11513
11529
  }
@@ -11563,7 +11579,7 @@
11563
11579
  ]
11564
11580
  }
11565
11581
  ),
11566
- /* @__PURE__ */ jsxRuntime.jsx(FavouritesView, { hidden: Boolean(filteredUrls) }),
11582
+ /* @__PURE__ */ jsxRuntime.jsx(FavouritesView, { hidden: performingSearch }),
11567
11583
  additionalChildrenStart,
11568
11584
  additionalPluginChildrenStart,
11569
11585
  allGroups.map((group, index) => {
@@ -11580,7 +11596,7 @@
11580
11596
  });
11581
11597
  }
11582
11598
  const thisGroupCollections = filteredNavigationEntries.filter((entry) => entry.group === group || !entry.group && group === void 0);
11583
- if (thisGroupCollections.length === 0 && AdditionalCards.length === 0)
11599
+ if (thisGroupCollections.length === 0 && (AdditionalCards.length === 0 || performingSearch))
11584
11600
  return null;
11585
11601
  return /* @__PURE__ */ jsxRuntime.jsx(
11586
11602
  NavigationGroup,
@@ -12244,7 +12260,7 @@
12244
12260
  }) {
12245
12261
  const context = useFireCMSContext();
12246
12262
  const fullPath = fullPathProp ?? collectionProp.path;
12247
- const dataSource = useDataSource(collectionProp);
12263
+ const dataSource = useDataSource();
12248
12264
  const navigation = useNavigationController();
12249
12265
  const sideEntityController = useSideEntityController();
12250
12266
  const authController = useAuthController();
@@ -12378,7 +12394,7 @@
12378
12394
  value,
12379
12395
  property,
12380
12396
  entityId
12381
- }) => dataSource.checkUniqueField(fullPath, name, value, entityId, collection.databaseId),
12397
+ }) => dataSource.checkUniqueField(fullPath, name, value, entityId, collection),
12382
12398
  [fullPath]
12383
12399
  );
12384
12400
  const onValueChange = ({
@@ -12758,7 +12774,7 @@
12758
12774
  sortBy,
12759
12775
  onCountChange
12760
12776
  }) {
12761
- const dataSource = useDataSource(collection);
12777
+ const dataSource = useDataSource();
12762
12778
  const navigation = useNavigationController();
12763
12779
  const [count, setCount] = React.useState(void 0);
12764
12780
  const [error, setError] = React.useState(void 0);
@@ -13279,7 +13295,8 @@
13279
13295
  onInternalIdAdded,
13280
13296
  includeAddButton,
13281
13297
  newDefaultEntry,
13282
- onValueChange
13298
+ onValueChange,
13299
+ className
13283
13300
  }) {
13284
13301
  const hasValue = value && Array.isArray(value) && value.length > 0;
13285
13302
  const internalIdsRef = React.useRef(buildIdsMap(value));
@@ -13368,6 +13385,7 @@
13368
13385
  children: (droppableProvided, droppableSnapshot) => /* @__PURE__ */ jsxRuntime.jsxs(
13369
13386
  "div",
13370
13387
  {
13388
+ className,
13371
13389
  ...droppableProvided.droppableProps,
13372
13390
  ref: droppableProvided.innerRef,
13373
13391
  children: [
@@ -13438,7 +13456,7 @@
13438
13456
  ref: provided.innerRef,
13439
13457
  ...provided.draggableProps,
13440
13458
  style: provided.draggableProps.style,
13441
- className: `${isDragging || onHover ? ui.fieldBackgroundHoverMixin : ""} mb-1 rounded-md opacity-100`,
13459
+ className: `${isDragging || onHover ? "hover:bg-slate-50 dark:hover:bg-gray-800 dark:hover:bg-opacity-20" : ""} mb-1 rounded-md opacity-100`,
13442
13460
  children: /* @__PURE__ */ jsxRuntime.jsxs(
13443
13461
  "div",
13444
13462
  {
@@ -13447,7 +13465,7 @@
13447
13465
  /* @__PURE__ */ jsxRuntime.jsx(
13448
13466
  "div",
13449
13467
  {
13450
- className: "flex-grow w-[calc(100%-48px)] text-text-primary dark:text-text-primary-dark bg-white dark:bg-gray-900 bg-opacity-80 dark:bg-opacity-80",
13468
+ className: "flex-grow w-[calc(100%-48px)] text-text-primary dark:text-text-primary-dark",
13451
13469
  children: buildEntry(index, internalId)
13452
13470
  }
13453
13471
  ),
@@ -13757,7 +13775,8 @@
13757
13775
  onInternalIdAdded,
13758
13776
  includeAddButton,
13759
13777
  newDefaultEntry = null,
13760
- setFieldValue
13778
+ setFieldValue,
13779
+ className
13761
13780
  }) {
13762
13781
  return /* @__PURE__ */ jsxRuntime.jsx(
13763
13782
  ArrayContainer,
@@ -13771,6 +13790,7 @@
13771
13790
  onInternalIdAdded,
13772
13791
  includeAddButton,
13773
13792
  newDefaultEntry,
13793
+ className,
13774
13794
  onValueChange: (value2) => setFieldValue(name, value2)
13775
13795
  }
13776
13796
  );
@@ -14110,10 +14130,10 @@
14110
14130
  forceFilter: ofProperty.forceFilter
14111
14131
  }
14112
14132
  );
14113
- const onEntryClick = React.useCallback((e) => {
14133
+ const onEntryClick = (e) => {
14114
14134
  e.preventDefault();
14115
14135
  referenceDialogController.open();
14116
- }, [referenceDialogController]);
14136
+ };
14117
14137
  const buildEntry = React.useCallback((index, internalId) => {
14118
14138
  const entryValue = value && value.length > index ? value[index] : void 0;
14119
14139
  if (!entryValue)
@@ -14141,7 +14161,7 @@
14141
14161
  icon: getIconForProperty(property, "small"),
14142
14162
  required: property.validation?.required,
14143
14163
  title: property.name,
14144
- className: "flex-grow text-text-secondary dark:text-text-secondary-dark"
14164
+ className: "flex flex-grow text-text-secondary dark:text-text-secondary-dark"
14145
14165
  }
14146
14166
  ),
14147
14167
  Array.isArray(value) && /* @__PURE__ */ jsxRuntime.jsxs(ui.Typography, { variant: "caption", className: "px-4", children: [
@@ -14174,7 +14194,7 @@
14174
14194
  ui.Button,
14175
14195
  {
14176
14196
  className: "my-4 justify-center text-left",
14177
- variant: "outlined",
14197
+ variant: "text",
14178
14198
  color: "primary",
14179
14199
  disabled: isSubmitting,
14180
14200
  onClick: onEntryClick,
@@ -14933,10 +14953,10 @@
14933
14953
  forceFilter: property.forceFilter
14934
14954
  }
14935
14955
  );
14936
- const onEntryClick = React.useCallback((e) => {
14956
+ const onEntryClick = (e) => {
14937
14957
  e.preventDefault();
14938
14958
  referenceDialogController.open();
14939
- }, [referenceDialogController]);
14959
+ };
14940
14960
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
14941
14961
  !minimalistView && /* @__PURE__ */ jsxRuntime.jsx(
14942
14962
  LabelWithIconAndTooltip,
@@ -14978,7 +14998,13 @@
14978
14998
  onClick: onEntryClick,
14979
14999
  size: "medium",
14980
15000
  children: [
14981
- /* @__PURE__ */ jsxRuntime.jsx(EmptyValue, {}),
15001
+ /* @__PURE__ */ jsxRuntime.jsx(
15002
+ IconForView,
15003
+ {
15004
+ collectionOrView: collection,
15005
+ className: "text-gray-300 dark:text-gray-600"
15006
+ }
15007
+ ),
14982
15008
  `Edit ${property.name}`.toUpperCase()
14983
15009
  ]
14984
15010
  }
@@ -16083,6 +16109,7 @@
16083
16109
  FormikArrayContainer,
16084
16110
  {
16085
16111
  value,
16112
+ className: "flex flex-col gap-3",
16086
16113
  name: propertyKey,
16087
16114
  addLabel: property.name ? "Add entry to " + property.name : "Add entry",
16088
16115
  buildEntry,
@@ -16164,7 +16191,7 @@
16164
16191
  formex$1.setFieldValue(typeFieldName, newType);
16165
16192
  formex$1.setFieldValue(valueFieldName, newSelectedProperty ? getDefaultValueFor(newSelectedProperty) : null);
16166
16193
  };
16167
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls(ui.paperMixin, "bg-transparent p-2 mb-4"), children: [
16194
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls(ui.paperMixin, "bg-transparent p-2"), children: [
16168
16195
  /* @__PURE__ */ jsxRuntime.jsx(
16169
16196
  formex.Field,
16170
16197
  {
@@ -17315,7 +17342,7 @@
17315
17342
  }, false, 2e3);
17316
17343
  const inputCollection = collection;
17317
17344
  const authController = useAuthController();
17318
- const dataSource = useDataSource(collection);
17345
+ const dataSource = useDataSource();
17319
17346
  const sideDialogContext = useSideDialogContext();
17320
17347
  const sideEntityController = useSideEntityController();
17321
17348
  const snackbarController = useSnackbarController();
@@ -17337,7 +17364,7 @@
17337
17364
  if (mustSetCustomId) {
17338
17365
  return void 0;
17339
17366
  } else {
17340
- return dataSource.generateEntityId(path);
17367
+ return dataSource.generateEntityId(path, collection);
17341
17368
  }
17342
17369
  } else {
17343
17370
  return entityIdProp;
@@ -17354,8 +17381,8 @@
17354
17381
  entityId
17355
17382
  }
17356
17383
  );
17357
- const selectedTabRef = React.useRef(defaultSelectedView ?? MAIN_TAB_VALUE);
17358
- const mainViewVisible = selectedTabRef.current === MAIN_TAB_VALUE;
17384
+ const [selectedTab, setSelectedTab] = React.useState(defaultSelectedView ?? MAIN_TAB_VALUE);
17385
+ const mainViewVisible = selectedTab === MAIN_TAB_VALUE;
17359
17386
  const subcollections = (collection.subcollections ?? []).filter((c) => !c.hideFromNavigation);
17360
17387
  const subcollectionsCount = subcollections?.length ?? 0;
17361
17388
  const customViews = collection.entityViews;
@@ -17415,7 +17442,7 @@
17415
17442
  sideEntityController.replace({
17416
17443
  path,
17417
17444
  entityId: updatedEntity.id,
17418
- selectedSubPath: MAIN_TAB_VALUE === selectedTabRef.current ? void 0 : selectedTabRef.current,
17445
+ selectedSubPath: MAIN_TAB_VALUE === selectedTab ? void 0 : selectedTab,
17419
17446
  updateUrl: true,
17420
17447
  collection
17421
17448
  });
@@ -17563,13 +17590,13 @@
17563
17590
  formex: formex$1
17564
17591
  };
17565
17592
  const resolvedEntityViews = customViews ? customViews.map((e) => resolveEntityView(e, customizationController.entityViews)).filter(Boolean) : [];
17566
- const selectedEntityView = resolvedEntityViews.find((e) => e.key === selectedTabRef.current);
17567
- const shouldShowEntityActions = !autoSave && (selectedTabRef.current === MAIN_TAB_VALUE || selectedEntityView?.includeActions);
17593
+ const selectedEntityView = resolvedEntityViews.find((e) => e.key === selectedTab);
17594
+ const shouldShowEntityActions = !autoSave && (selectedTab === MAIN_TAB_VALUE || selectedEntityView?.includeActions);
17568
17595
  const customViewsView = customViews && resolvedEntityViews.map(
17569
17596
  (customView, colIndex) => {
17570
17597
  if (!customView)
17571
17598
  return null;
17572
- if (selectedTabRef.current !== customView.key)
17599
+ if (selectedTab !== customView.key)
17573
17600
  return null;
17574
17601
  const Builder = customView.Builder;
17575
17602
  if (!Builder) {
@@ -17604,7 +17631,7 @@
17604
17631
  (subcollection, colIndex) => {
17605
17632
  const subcollectionId = subcollection.id ?? subcollection.path;
17606
17633
  const fullPath = usedEntity ? `${path}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollectionId)}` : void 0;
17607
- if (selectedTabRef.current !== subcollectionId)
17634
+ if (selectedTab !== subcollectionId)
17608
17635
  return null;
17609
17636
  return /* @__PURE__ */ jsxRuntime.jsxs(
17610
17637
  "div",
@@ -17638,14 +17665,16 @@
17638
17665
  onValuesAreModified(false);
17639
17666
  }, []);
17640
17667
  const onSideTabClick = (value) => {
17641
- selectedTabRef.current = value;
17642
- sideEntityController.replace({
17643
- path,
17644
- entityId,
17645
- selectedSubPath: value === MAIN_TAB_VALUE ? void 0 : value,
17646
- updateUrl: true,
17647
- collection
17648
- });
17668
+ setSelectedTab(value);
17669
+ if (status === "existing") {
17670
+ sideEntityController.replace({
17671
+ path,
17672
+ entityId,
17673
+ selectedSubPath: value === MAIN_TAB_VALUE ? void 0 : value,
17674
+ updateUrl: true,
17675
+ collection
17676
+ });
17677
+ }
17649
17678
  };
17650
17679
  const onIdUpdateError = React.useCallback((error) => {
17651
17680
  snackbarController.open({
@@ -17710,7 +17739,7 @@
17710
17739
  name,
17711
17740
  value,
17712
17741
  property
17713
- }) => dataSource.checkUniqueField(path, name, value, entityId, collection.databaseId),
17742
+ }) => dataSource.checkUniqueField(path, name, value, entityId, collection),
17714
17743
  [dataSource, path, entityId]
17715
17744
  );
17716
17745
  const validationSchema = React.useMemo(
@@ -18048,7 +18077,7 @@
18048
18077
  /* @__PURE__ */ jsxRuntime.jsxs(
18049
18078
  ui.Tabs,
18050
18079
  {
18051
- value: selectedTabRef.current,
18080
+ value: selectedTab,
18052
18081
  onValueChange: (value) => {
18053
18082
  onSideTabClick(value);
18054
18083
  },
@@ -18263,11 +18292,9 @@
18263
18292
  setDrawerCloseRequested(false);
18264
18293
  };
18265
18294
  const onCloseRequest = (force) => {
18266
- console.log("onCloseRequest", blocked, force);
18267
18295
  if (blocked && !force) {
18268
18296
  setDrawerCloseRequested(true);
18269
18297
  } else {
18270
- console.log("onCloseRequest closing");
18271
18298
  sideDialogsController.close();
18272
18299
  panel?.onClose?.();
18273
18300
  }
@@ -18461,6 +18488,15 @@
18461
18488
  initialised.current = true;
18462
18489
  }
18463
18490
  }, [location, navigation.loading, navigation.isUrlCollectionPath, navigation.buildUrlCollectionPath, navigation.resolveAliasesFrom, sideDialogsController, smallLayout, navigation]);
18491
+ React.useEffect(() => {
18492
+ const updatedSidePanels = sideDialogsController.sidePanels.map((sidePanelProps) => {
18493
+ if (sidePanelProps.additional) {
18494
+ return propsToSidePanel(sidePanelProps.additional, navigation.buildUrlCollectionPath, navigation.resolveAliasesFrom, smallLayout);
18495
+ }
18496
+ return sidePanelProps;
18497
+ });
18498
+ sideDialogsController.setSidePanels(updatedSidePanels);
18499
+ }, [smallLayout]);
18464
18500
  const close = React.useCallback(() => {
18465
18501
  sideDialogsController.close();
18466
18502
  }, [sideDialogsController]);
@@ -18553,7 +18589,8 @@
18553
18589
  urlPath: newPath,
18554
18590
  parentUrlPath: buildUrlCollectionPath(collectionPath),
18555
18591
  width: entityViewWidth,
18556
- onClose: props.onClose
18592
+ onClose: props.onClose,
18593
+ additional: props
18557
18594
  };
18558
18595
  };
18559
18596
  function useBuildSideDialogsController() {
@@ -18646,6 +18683,7 @@
18646
18683
  }, [location, navigate, sidePanels]);
18647
18684
  return {
18648
18685
  sidePanels,
18686
+ setSidePanels: updateSidePanels,
18649
18687
  close,
18650
18688
  open,
18651
18689
  replace
@@ -18681,7 +18719,8 @@
18681
18719
  orderBy,
18682
18720
  order
18683
18721
  }) => {
18684
- return delegate.fetchCollection({
18722
+ const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
18723
+ return usedDelegate.fetchCollection({
18685
18724
  path,
18686
18725
  filter,
18687
18726
  limit,
@@ -18721,10 +18760,10 @@
18721
18760
  onError
18722
18761
  }) => {
18723
18762
  const collection = collectionProp ?? navigationController.getCollection(path);
18724
- Boolean(collection?.collectionGroup);
18725
- if (!delegate.listenCollection)
18763
+ const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
18764
+ if (!usedDelegate.listenCollection)
18726
18765
  throw Error("useBuildDataSource delegate not initialised");
18727
- return delegate.listenCollection({
18766
+ return usedDelegate.listenCollection({
18728
18767
  path,
18729
18768
  filter,
18730
18769
  limit,
@@ -18748,11 +18787,14 @@
18748
18787
  path,
18749
18788
  entityId,
18750
18789
  collection
18751
- }) => delegate.fetchEntity({
18752
- path,
18753
- entityId,
18754
- collection
18755
- }), [delegate]),
18790
+ }) => {
18791
+ const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
18792
+ return usedDelegate.fetchEntity({
18793
+ path,
18794
+ entityId,
18795
+ collection
18796
+ });
18797
+ }, [delegate.fetchEntity]),
18756
18798
  /**
18757
18799
  *
18758
18800
  * @param path
@@ -18770,9 +18812,10 @@
18770
18812
  onUpdate,
18771
18813
  onError
18772
18814
  }) => {
18773
- if (!delegate.listenEntity)
18815
+ const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
18816
+ if (!usedDelegate.listenEntity)
18774
18817
  throw Error("useBuildDataSource delegate not initialised");
18775
- return delegate.listenEntity({
18818
+ return usedDelegate.listenEntity({
18776
18819
  path,
18777
18820
  entityId,
18778
18821
  onUpdate,
@@ -18799,6 +18842,7 @@
18799
18842
  status
18800
18843
  }) => {
18801
18844
  const collection = collectionProp ?? navigationController.getCollection(path);
18845
+ const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
18802
18846
  console.log("useBuildDatasource save", {
18803
18847
  path,
18804
18848
  entityId,
@@ -18814,29 +18858,29 @@
18814
18858
  fields: propertyConfigs
18815
18859
  }) : void 0;
18816
18860
  const properties = resolvedCollection?.properties;
18817
- const firestoreValues = delegate.cmsToDelegateModel(
18861
+ const firestoreValues = usedDelegate.cmsToDelegateModel(
18818
18862
  values
18819
18863
  );
18820
- const updatedFirestoreValues = properties ? updateDateAutoValues(
18864
+ const updatedValues = properties ? updateDateAutoValues(
18821
18865
  {
18822
18866
  inputValues: firestoreValues,
18823
18867
  properties,
18824
18868
  status,
18825
- timestampNowValue: delegate.currentTime?.() ?? /* @__PURE__ */ new Date(),
18826
- setDateToMidnight: delegate.setDateToMidnight
18869
+ timestampNowValue: usedDelegate.currentTime?.() ?? /* @__PURE__ */ new Date(),
18870
+ setDateToMidnight: usedDelegate.setDateToMidnight
18827
18871
  }
18828
18872
  ) : firestoreValues;
18829
- return delegate.saveEntity({
18873
+ return usedDelegate.saveEntity({
18830
18874
  path,
18831
18875
  collection,
18832
18876
  entityId,
18833
- values: updatedFirestoreValues,
18877
+ values: updatedValues,
18834
18878
  status
18835
18879
  }).then((res) => {
18836
18880
  return {
18837
18881
  id: res.id,
18838
18882
  path: res.path,
18839
- values: delegate.delegateToCMSModel(updatedFirestoreValues)
18883
+ values: usedDelegate.delegateToCMSModel(updatedValues)
18840
18884
  };
18841
18885
  });
18842
18886
  }, [delegate.saveEntity, navigationController.getCollection]),
@@ -18847,9 +18891,11 @@
18847
18891
  * @group Firestore
18848
18892
  */
18849
18893
  deleteEntity: React.useCallback(({
18850
- entity
18894
+ entity,
18895
+ collection
18851
18896
  }) => {
18852
- return delegate.deleteEntity({ entity });
18897
+ const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
18898
+ return usedDelegate.deleteEntity({ entity, collection });
18853
18899
  }, [delegate.deleteEntity]),
18854
18900
  /**
18855
18901
  * Check if the given property is unique in the given collection
@@ -18861,11 +18907,13 @@
18861
18907
  * @return `true` if there are no other fields besides the given entity
18862
18908
  * @group Firestore
18863
18909
  */
18864
- checkUniqueField: React.useCallback((path, name, value, entityId, databaseId) => {
18865
- return delegate.checkUniqueField(path, name, value, entityId, databaseId);
18910
+ checkUniqueField: React.useCallback((path, name, value, entityId, collection) => {
18911
+ const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
18912
+ return usedDelegate.checkUniqueField(path, name, value, entityId, collection);
18866
18913
  }, [delegate.checkUniqueField]),
18867
- generateEntityId: React.useCallback((path) => {
18868
- return delegate.generateEntityId(path);
18914
+ generateEntityId: React.useCallback((path, collection) => {
18915
+ const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
18916
+ return usedDelegate.generateEntityId(path, collection);
18869
18917
  }, [delegate.generateEntityId]),
18870
18918
  countEntities: delegate.countEntities ? async ({
18871
18919
  path,
@@ -18874,7 +18922,8 @@
18874
18922
  order,
18875
18923
  orderBy
18876
18924
  }) => {
18877
- return delegate.countEntities({
18925
+ const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
18926
+ return usedDelegate.countEntities({
18878
18927
  path,
18879
18928
  filter,
18880
18929
  orderBy,
@@ -18900,9 +18949,10 @@
18900
18949
  );
18901
18950
  }, [delegate.isFilterCombinationValid]),
18902
18951
  initTextSearch: React.useCallback(async (props) => {
18903
- if (!delegate.initTextSearch)
18952
+ const usedDelegate = props.collection?.overrides?.dataSourceDelegate ?? delegate;
18953
+ if (!usedDelegate.initTextSearch)
18904
18954
  return false;
18905
- return delegate.initTextSearch(props);
18955
+ return usedDelegate.initTextSearch(props);
18906
18956
  }, [delegate.initTextSearch])
18907
18957
  };
18908
18958
  }