@firecms/core 3.0.0-canary.222 → 3.0.0-canary.223

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
@@ -880,7 +880,11 @@
880
880
  const result = [];
881
881
  for (let i = 0; i < subpathCombinations.length; i++) {
882
882
  const subpathCombination = subpathCombinations[i];
883
- const collection = collections && collections.find((entry) => entry.id === subpathCombination || entry.path === subpathCombination);
883
+ let collection;
884
+ collection = collections && collections.find((entry) => entry.id === subpathCombination);
885
+ if (!collection) {
886
+ collection = collections && collections.find((entry) => entry.path === subpathCombination);
887
+ }
884
888
  if (collection) {
885
889
  const pathOrAlias = collection.id ?? collection.path;
886
890
  const collectionPath = currentFullPath && currentFullPath.length > 0 ? currentFullPath + "/" + pathOrAlias : pathOrAlias;
@@ -12205,6 +12209,10 @@
12205
12209
  addRecentId(collection.id, entity.id);
12206
12210
  }
12207
12211
  const path = collection?.collectionGroup ? entity.path : fullPath ?? entity.path;
12212
+ const defaultSelectedView = resolveDefaultSelectedView(collection ? collection.defaultSelectedView : void 0, {
12213
+ status: "existing",
12214
+ entityId: entity.id
12215
+ });
12208
12216
  navigateToEntity({
12209
12217
  openEntityMode,
12210
12218
  collection,
@@ -12212,7 +12220,8 @@
12212
12220
  path,
12213
12221
  sideEntityController: context.sideEntityController,
12214
12222
  onClose: () => unhighlightEntity?.(entity),
12215
- navigation: context.navigation
12223
+ navigation: context.navigation,
12224
+ selectedTab: defaultSelectedView
12216
12225
  });
12217
12226
  return Promise.resolve(void 0);
12218
12227
  }
@@ -20207,29 +20216,36 @@
20207
20216
  ...result
20208
20217
  };
20209
20218
  }, [userConfigPersistence]);
20210
- const getCollectionFromPaths = React.useCallback((pathSegments) => {
20219
+ const getCollectionById = React.useCallback((id) => {
20211
20220
  const collections_1 = collectionsRef.current;
20212
- if (collections_1 === void 0) throw Error("getCollectionFromPaths: Collections have not been initialised yet");
20213
- let currentCollections = [...collections_1 ?? []];
20221
+ if (collections_1 === void 0) throw Error("getCollectionById: Collections have not been initialised yet");
20222
+ const collection_0 = collections_1.find((c) => c.id === id);
20223
+ if (!collection_0) return void 0;
20224
+ return collection_0;
20225
+ }, []);
20226
+ const getCollectionFromPaths = React.useCallback((pathSegments) => {
20227
+ const collections_2 = collectionsRef.current;
20228
+ if (collections_2 === void 0) throw Error("getCollectionFromPaths: Collections have not been initialised yet");
20229
+ let currentCollections = [...collections_2 ?? []];
20214
20230
  for (let i = 0; i < pathSegments.length; i++) {
20215
20231
  const pathSegment = pathSegments[i];
20216
- const collection_0 = currentCollections.find((c) => c.id === pathSegment || c.path === pathSegment);
20217
- if (!collection_0) return void 0;
20218
- currentCollections = collection_0.subcollections;
20219
- if (i === pathSegments.length - 1) return collection_0;
20232
+ const collection_1 = currentCollections.find((c_0) => c_0.id === pathSegment || c_0.path === pathSegment);
20233
+ if (!collection_1) return void 0;
20234
+ currentCollections = collection_1.subcollections;
20235
+ if (i === pathSegments.length - 1) return collection_1;
20220
20236
  }
20221
20237
  return void 0;
20222
20238
  }, []);
20223
20239
  const getCollectionFromIds = React.useCallback((ids) => {
20224
- const collections_2 = collectionsRef.current;
20225
- if (collections_2 === void 0) throw Error("getCollectionFromIds: Collections have not been initialised yet");
20226
- let currentCollections_0 = [...collections_2 ?? []];
20240
+ const collections_3 = collectionsRef.current;
20241
+ if (collections_3 === void 0) throw Error("getCollectionFromIds: Collections have not been initialised yet");
20242
+ let currentCollections_0 = [...collections_3 ?? []];
20227
20243
  for (let i_0 = 0; i_0 < ids.length; i_0++) {
20228
- const id = ids[i_0];
20229
- const collection_1 = currentCollections_0.find((c_0) => c_0.id === id);
20230
- if (!collection_1) return void 0;
20231
- currentCollections_0 = collection_1.subcollections;
20232
- if (i_0 === ids.length - 1) return collection_1;
20244
+ const id_0 = ids[i_0];
20245
+ const collection_2 = currentCollections_0.find((c_1) => c_1.id === id_0);
20246
+ if (!collection_2) return void 0;
20247
+ currentCollections_0 = collection_2.subcollections;
20248
+ if (i_0 === ids.length - 1) return collection_2;
20233
20249
  }
20234
20250
  return void 0;
20235
20251
  }, []);
@@ -20239,14 +20255,14 @@
20239
20255
  throw Error("Expected path starting with " + fullCollectionPath);
20240
20256
  }, [fullCollectionPath]);
20241
20257
  const resolveIdsFrom = React.useCallback((path_3) => {
20242
- const collections_3 = collectionsRef.current ?? [];
20243
- return resolveCollectionPathIds(path_3, collections_3);
20258
+ const collections_4 = collectionsRef.current ?? [];
20259
+ return resolveCollectionPathIds(path_3, collections_4);
20244
20260
  }, []);
20245
20261
  const getAllParentReferencesForPath = React.useCallback((path_4) => {
20246
- const collections_4 = collectionsRef.current ?? [];
20262
+ const collections_5 = collectionsRef.current ?? [];
20247
20263
  return getParentReferencesFromPath({
20248
20264
  path: path_4,
20249
- collections: collections_4
20265
+ collections: collections_5
20250
20266
  });
20251
20267
  }, []);
20252
20268
  const getParentCollectionIds = React.useCallback((path_5) => {
@@ -20260,15 +20276,15 @@
20260
20276
  return result_0.map((r) => getCollectionFromPaths(r)?.id).filter(Boolean);
20261
20277
  }, [getAllParentReferencesForPath]);
20262
20278
  const convertIdsToPaths = React.useCallback((ids_0) => {
20263
- const collections_5 = collectionsRef.current;
20264
- let currentCollections_1 = collections_5;
20279
+ const collections_6 = collectionsRef.current;
20280
+ let currentCollections_1 = collections_6;
20265
20281
  const paths = [];
20266
20282
  for (let i_3 = 0; i_3 < ids_0.length; i_3++) {
20267
- const id_0 = ids_0[i_3];
20268
- const collection_2 = currentCollections_1.find((c_1) => c_1.id === id_0);
20269
- if (!collection_2) throw Error(`Collection with id ${id_0} not found`);
20270
- paths.push(collection_2.path);
20271
- currentCollections_1 = collection_2.subcollections;
20283
+ const id_1 = ids_0[i_3];
20284
+ const collection_3 = currentCollections_1.find((c_2) => c_2.id === id_1);
20285
+ if (!collection_3) throw Error(`Collection with id ${id_1} not found`);
20286
+ paths.push(collection_3.path);
20287
+ currentCollections_1 = collection_3.subcollections;
20272
20288
  }
20273
20289
  return paths;
20274
20290
  }, [getCollectionFromIds]);
@@ -20283,6 +20299,7 @@
20283
20299
  baseCollectionPath,
20284
20300
  initialised,
20285
20301
  getCollection,
20302
+ getCollectionById,
20286
20303
  getCollectionFromPaths,
20287
20304
  getCollectionFromIds,
20288
20305
  isUrlCollectionPath,
@@ -21286,7 +21303,7 @@
21286
21303
  const subcollectionsCount = subcollections?.length ?? 0;
21287
21304
  const customViews = collection.entityViews;
21288
21305
  const customViewsCount = customViews?.length ?? 0;
21289
- const includeJsonView = true;
21306
+ const includeJsonView = collection.includeJsonView === void 0 ? true : collection.includeJsonView;
21290
21307
  const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0 || includeJsonView;
21291
21308
  const {
21292
21309
  resolvedEntityViews,
@@ -21385,15 +21402,16 @@
21385
21402
  }, Builder: selectedSecondaryForm?.Builder });
21386
21403
  const subcollectionTabs = subcollections && subcollections.map((subcollection_0) => /* @__PURE__ */ jsxRuntime.jsx(ui.Tab, { className: "text-sm min-w-[120px]", value: subcollection_0.id, children: subcollection_0.name }, `entity_detail_collection_tab_${subcollection_0.name}`));
21387
21404
  const customViewTabs = resolvedEntityViews.map((view) => /* @__PURE__ */ jsxRuntime.jsx(ui.Tab, { className: "text-sm min-w-[120px]", value: view.key, children: view.name }, `entity_detail_collection_tab_${view.name}`));
21405
+ const shouldShowTopBar = Boolean(barActions) || hasAdditionalViews;
21388
21406
  let result = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex flex-col h-full w-full bg-white dark:bg-surface-900", children: [
21389
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("h-14 flex overflow-visible overflow-x-scroll w-full no-scrollbar h-14 border-b pl-2 pr-2 pt-1 flex items-end bg-surface-50 dark:bg-surface-900", ui.defaultBorderMixin), children: [
21407
+ shouldShowTopBar && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("h-14 flex overflow-visible overflow-x-scroll w-full no-scrollbar h-14 border-b pl-2 pr-2 pt-1 flex items-end bg-surface-50 dark:bg-surface-900", ui.defaultBorderMixin), children: [
21390
21408
  barActions,
21391
21409
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-grow" }),
21392
21410
  globalLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "self-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.CircularProgress, { size: "small" }) }),
21393
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Tabs, { value: selectedTab, onValueChange: (value_1) => {
21411
+ hasAdditionalViews && /* @__PURE__ */ jsxRuntime.jsxs(ui.Tabs, { value: selectedTab, onValueChange: (value_1) => {
21394
21412
  onSideTabClick(value_1);
21395
21413
  }, children: [
21396
- /* @__PURE__ */ jsxRuntime.jsx(ui.Tab, { disabled: !hasAdditionalViews, value: JSON_TAB_VALUE, innerClassName: "block", className: "text-sm", children: /* @__PURE__ */ jsxRuntime.jsx(ui.CodeIcon, { size: "small" }) }),
21414
+ includeJsonView && /* @__PURE__ */ jsxRuntime.jsx(ui.Tab, { disabled: !hasAdditionalViews, value: JSON_TAB_VALUE, innerClassName: "block", className: "text-sm", children: /* @__PURE__ */ jsxRuntime.jsx(ui.CodeIcon, { size: "small" }) }),
21397
21415
  /* @__PURE__ */ jsxRuntime.jsx(ui.Tab, { disabled: !hasAdditionalViews, value: MAIN_TAB_VALUE, className: "text-sm min-w-[120px]", children: collection.singularName ?? collection.name }),
21398
21416
  customViewTabs,
21399
21417
  subcollectionTabs
@@ -23032,7 +23050,7 @@
23032
23050
  return getDefaultFieldId(property);
23033
23051
  }
23034
23052
  function FireCMSRoute() {
23035
- const $ = reactCompilerRuntime.c(32);
23053
+ const $ = reactCompilerRuntime.c(33);
23036
23054
  const location = reactRouter.useLocation();
23037
23055
  const navigation = useNavigationController();
23038
23056
  const breadcrumbs = useBreadcrumbsController();
@@ -23145,7 +23163,11 @@
23145
23163
  if ($[18] !== navigation || $[19] !== navigationEntries) {
23146
23164
  t7 = Symbol.for("react.early_return_sentinel");
23147
23165
  bb0: {
23148
- const collection = navigation.getCollection(navigationEntries[0].path);
23166
+ let collection;
23167
+ collection = navigation.getCollectionById(navigationEntries[0].id);
23168
+ if (!collection) {
23169
+ collection = navigation.getCollection(navigationEntries[0].path);
23170
+ }
23149
23171
  if (!collection) {
23150
23172
  t7 = null;
23151
23173
  break bb0;
@@ -23173,48 +23195,56 @@
23173
23195
  return t62;
23174
23196
  }
23175
23197
  if (isSidePanel) {
23176
- let t62;
23177
- if ($[23] !== navigation || $[24] !== navigationEntries) {
23178
- t62 = Symbol.for("react.early_return_sentinel");
23179
- bb1: {
23180
- const lastCollectionEntry = navigationEntries.findLast(_temp2$1);
23181
- if (lastCollectionEntry) {
23182
- const collection_0 = navigation.getCollection(lastCollectionEntry.path);
23198
+ const lastCollectionEntry = navigationEntries.findLast(_temp2$1);
23199
+ if (lastCollectionEntry) {
23200
+ let t62;
23201
+ let t7;
23202
+ if ($[23] !== navigation || $[24] !== navigationEntries) {
23203
+ t7 = Symbol.for("react.early_return_sentinel");
23204
+ bb1: {
23205
+ let collection_0;
23206
+ const firstEntry = navigationEntries[0];
23207
+ collection_0 = navigation.getCollectionById(firstEntry.id);
23183
23208
  if (!collection_0) {
23184
- t62 = null;
23209
+ collection_0 = navigation.getCollection(firstEntry.path);
23210
+ }
23211
+ if (!collection_0) {
23212
+ t7 = null;
23185
23213
  break bb1;
23186
23214
  }
23187
- let t7;
23188
- if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
23189
- t7 = [];
23190
- $[26] = t7;
23215
+ let t8;
23216
+ if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
23217
+ t8 = [];
23218
+ $[27] = t8;
23191
23219
  } else {
23192
- t7 = $[26];
23220
+ t8 = $[27];
23193
23221
  }
23194
- t62 = /* @__PURE__ */ jsxRuntime.jsx(EntityCollectionView, { isSubCollection: false, parentCollectionIds: t7, fullPath: collection_0.id, updateUrl: true, ...collection_0, Actions: toArray(collection_0.Actions) }, `collection_view_${collection_0.id ?? collection_0.path}`);
23195
- break bb1;
23222
+ t62 = /* @__PURE__ */ jsxRuntime.jsx(EntityCollectionView, { isSubCollection: false, parentCollectionIds: t8, fullPath: collection_0.id, updateUrl: true, ...collection_0, Actions: toArray(collection_0.Actions) }, `collection_view_${collection_0.id ?? collection_0.path}`);
23196
23223
  }
23224
+ $[23] = navigation;
23225
+ $[24] = navigationEntries;
23226
+ $[25] = t62;
23227
+ $[26] = t7;
23228
+ } else {
23229
+ t62 = $[25];
23230
+ t7 = $[26];
23231
+ }
23232
+ if (t7 !== Symbol.for("react.early_return_sentinel")) {
23233
+ return t7;
23197
23234
  }
23198
- $[23] = navigation;
23199
- $[24] = navigationEntries;
23200
- $[25] = t62;
23201
- } else {
23202
- t62 = $[25];
23203
- }
23204
- if (t62 !== Symbol.for("react.early_return_sentinel")) {
23205
23235
  return t62;
23206
23236
  }
23207
23237
  }
23208
23238
  let t6;
23209
- if ($[27] !== isCopy || $[28] !== isNew || $[29] !== navigationEntries || $[30] !== pathname) {
23239
+ if ($[28] !== isCopy || $[29] !== isNew || $[30] !== navigationEntries || $[31] !== pathname) {
23210
23240
  t6 = /* @__PURE__ */ jsxRuntime.jsx(EntityFullScreenRoute, { pathname, navigationEntries, isNew, isCopy });
23211
- $[27] = isCopy;
23212
- $[28] = isNew;
23213
- $[29] = navigationEntries;
23214
- $[30] = pathname;
23215
- $[31] = t6;
23241
+ $[28] = isCopy;
23242
+ $[29] = isNew;
23243
+ $[30] = navigationEntries;
23244
+ $[31] = pathname;
23245
+ $[32] = t6;
23216
23246
  } else {
23217
- t6 = $[31];
23247
+ t6 = $[32];
23218
23248
  }
23219
23249
  return t6;
23220
23250
  }