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

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,
@@ -21060,7 +21077,7 @@
21060
21077
  ] });
21061
21078
  }
21062
21079
  function EntityJsonPreview(t0) {
21063
- const $ = reactCompilerRuntime.c(9);
21080
+ const $ = reactCompilerRuntime.c(6);
21064
21081
  const {
21065
21082
  values
21066
21083
  } = t0;
@@ -21077,55 +21094,16 @@
21077
21094
  mode
21078
21095
  } = useModeController();
21079
21096
  const preRef = React.useRef(null);
21080
- let t2;
21081
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
21082
- t2 = (e) => {
21083
- if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a") {
21084
- if (preRef.current) {
21085
- e.preventDefault();
21086
- e.stopPropagation();
21087
- const selection = window.getSelection();
21088
- const range = document.createRange();
21089
- range.selectNodeContents(preRef.current);
21090
- if (selection) {
21091
- selection.removeAllRanges();
21092
- selection.addRange(range);
21093
- }
21094
- }
21095
- }
21096
- };
21097
- $[2] = t2;
21098
- } else {
21099
- t2 = $[2];
21100
- }
21101
- const handleGlobalKeyDown = t2;
21097
+ const t2 = mode === "dark" ? prismReactRenderer.themes.vsDark : prismReactRenderer.themes.github;
21102
21098
  let t3;
21103
- let t4;
21104
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
21105
- t3 = () => {
21106
- document.addEventListener("keydown", handleGlobalKeyDown);
21107
- return () => {
21108
- document.removeEventListener("keydown", handleGlobalKeyDown);
21109
- };
21110
- };
21111
- t4 = [handleGlobalKeyDown];
21112
- $[3] = t3;
21113
- $[4] = t4;
21114
- } else {
21115
- t3 = $[3];
21116
- t4 = $[4];
21117
- }
21118
- React.useEffect(t3, t4);
21119
- const t5 = mode === "dark" ? prismReactRenderer.themes.vsDark : prismReactRenderer.themes.github;
21120
- let t6;
21121
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
21122
- t6 = (t72) => {
21099
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
21100
+ t3 = (t42) => {
21123
21101
  const {
21124
21102
  style,
21125
21103
  tokens,
21126
21104
  getLineProps,
21127
21105
  getTokenProps
21128
- } = t72;
21106
+ } = t42;
21129
21107
  return /* @__PURE__ */ jsxRuntime.jsx("pre", { ref: preRef, style: {
21130
21108
  ...style,
21131
21109
  backgroundColor: "inherit"
@@ -21135,20 +21113,20 @@
21135
21113
  token
21136
21114
  }), className: "word-break" }, key)) }, i)) });
21137
21115
  };
21138
- $[5] = t6;
21116
+ $[2] = t3;
21139
21117
  } else {
21140
- t6 = $[5];
21118
+ t3 = $[2];
21141
21119
  }
21142
- let t7;
21143
- if ($[6] !== code || $[7] !== t5) {
21144
- t7 = /* @__PURE__ */ jsxRuntime.jsx(prismReactRenderer.Highlight, { theme: t5, code, language: "json", children: t6 });
21145
- $[6] = code;
21146
- $[7] = t5;
21147
- $[8] = t7;
21120
+ let t4;
21121
+ if ($[3] !== code || $[4] !== t2) {
21122
+ t4 = /* @__PURE__ */ jsxRuntime.jsx(prismReactRenderer.Highlight, { theme: t2, code, language: "json", children: t3 });
21123
+ $[3] = code;
21124
+ $[4] = t2;
21125
+ $[5] = t4;
21148
21126
  } else {
21149
- t7 = $[8];
21127
+ t4 = $[5];
21150
21128
  }
21151
- return t7;
21129
+ return t4;
21152
21130
  }
21153
21131
  function createFormexStub(values) {
21154
21132
  const errorMessage = "You are in a read-only context. You cannot modify the formex controller.";
@@ -21286,7 +21264,7 @@
21286
21264
  const subcollectionsCount = subcollections?.length ?? 0;
21287
21265
  const customViews = collection.entityViews;
21288
21266
  const customViewsCount = customViews?.length ?? 0;
21289
- const includeJsonView = true;
21267
+ const includeJsonView = collection.includeJsonView === void 0 ? true : collection.includeJsonView;
21290
21268
  const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0 || includeJsonView;
21291
21269
  const {
21292
21270
  resolvedEntityViews,
@@ -21385,15 +21363,16 @@
21385
21363
  }, Builder: selectedSecondaryForm?.Builder });
21386
21364
  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
21365
  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}`));
21366
+ const shouldShowTopBar = Boolean(barActions) || hasAdditionalViews;
21388
21367
  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: [
21368
+ 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
21369
  barActions,
21391
21370
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-grow" }),
21392
21371
  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) => {
21372
+ hasAdditionalViews && /* @__PURE__ */ jsxRuntime.jsxs(ui.Tabs, { value: selectedTab, onValueChange: (value_1) => {
21394
21373
  onSideTabClick(value_1);
21395
21374
  }, 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" }) }),
21375
+ 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
21376
  /* @__PURE__ */ jsxRuntime.jsx(ui.Tab, { disabled: !hasAdditionalViews, value: MAIN_TAB_VALUE, className: "text-sm min-w-[120px]", children: collection.singularName ?? collection.name }),
21398
21377
  customViewTabs,
21399
21378
  subcollectionTabs
@@ -23032,7 +23011,7 @@
23032
23011
  return getDefaultFieldId(property);
23033
23012
  }
23034
23013
  function FireCMSRoute() {
23035
- const $ = reactCompilerRuntime.c(32);
23014
+ const $ = reactCompilerRuntime.c(33);
23036
23015
  const location = reactRouter.useLocation();
23037
23016
  const navigation = useNavigationController();
23038
23017
  const breadcrumbs = useBreadcrumbsController();
@@ -23145,7 +23124,11 @@
23145
23124
  if ($[18] !== navigation || $[19] !== navigationEntries) {
23146
23125
  t7 = Symbol.for("react.early_return_sentinel");
23147
23126
  bb0: {
23148
- const collection = navigation.getCollection(navigationEntries[0].path);
23127
+ let collection;
23128
+ collection = navigation.getCollectionById(navigationEntries[0].id);
23129
+ if (!collection) {
23130
+ collection = navigation.getCollection(navigationEntries[0].path);
23131
+ }
23149
23132
  if (!collection) {
23150
23133
  t7 = null;
23151
23134
  break bb0;
@@ -23173,48 +23156,56 @@
23173
23156
  return t62;
23174
23157
  }
23175
23158
  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);
23159
+ const lastCollectionEntry = navigationEntries.findLast(_temp2$1);
23160
+ if (lastCollectionEntry) {
23161
+ let t62;
23162
+ let t7;
23163
+ if ($[23] !== navigation || $[24] !== navigationEntries) {
23164
+ t7 = Symbol.for("react.early_return_sentinel");
23165
+ bb1: {
23166
+ let collection_0;
23167
+ const firstEntry = navigationEntries[0];
23168
+ collection_0 = navigation.getCollectionById(firstEntry.id);
23169
+ if (!collection_0) {
23170
+ collection_0 = navigation.getCollection(firstEntry.path);
23171
+ }
23183
23172
  if (!collection_0) {
23184
- t62 = null;
23173
+ t7 = null;
23185
23174
  break bb1;
23186
23175
  }
23187
- let t7;
23188
- if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
23189
- t7 = [];
23190
- $[26] = t7;
23176
+ let t8;
23177
+ if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
23178
+ t8 = [];
23179
+ $[27] = t8;
23191
23180
  } else {
23192
- t7 = $[26];
23181
+ t8 = $[27];
23193
23182
  }
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;
23183
+ 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
23184
  }
23185
+ $[23] = navigation;
23186
+ $[24] = navigationEntries;
23187
+ $[25] = t62;
23188
+ $[26] = t7;
23189
+ } else {
23190
+ t62 = $[25];
23191
+ t7 = $[26];
23192
+ }
23193
+ if (t7 !== Symbol.for("react.early_return_sentinel")) {
23194
+ return t7;
23197
23195
  }
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
23196
  return t62;
23206
23197
  }
23207
23198
  }
23208
23199
  let t6;
23209
- if ($[27] !== isCopy || $[28] !== isNew || $[29] !== navigationEntries || $[30] !== pathname) {
23200
+ if ($[28] !== isCopy || $[29] !== isNew || $[30] !== navigationEntries || $[31] !== pathname) {
23210
23201
  t6 = /* @__PURE__ */ jsxRuntime.jsx(EntityFullScreenRoute, { pathname, navigationEntries, isNew, isCopy });
23211
- $[27] = isCopy;
23212
- $[28] = isNew;
23213
- $[29] = navigationEntries;
23214
- $[30] = pathname;
23215
- $[31] = t6;
23202
+ $[28] = isCopy;
23203
+ $[29] = isNew;
23204
+ $[30] = navigationEntries;
23205
+ $[31] = pathname;
23206
+ $[32] = t6;
23216
23207
  } else {
23217
- t6 = $[31];
23208
+ t6 = $[32];
23218
23209
  }
23219
23210
  return t6;
23220
23211
  }