@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.es.js CHANGED
@@ -879,7 +879,11 @@ function getNavigationEntriesFromPath(props) {
879
879
  const result = [];
880
880
  for (let i = 0; i < subpathCombinations.length; i++) {
881
881
  const subpathCombination = subpathCombinations[i];
882
- const collection = collections && collections.find((entry) => entry.id === subpathCombination || entry.path === subpathCombination);
882
+ let collection;
883
+ collection = collections && collections.find((entry) => entry.id === subpathCombination);
884
+ if (!collection) {
885
+ collection = collections && collections.find((entry) => entry.path === subpathCombination);
886
+ }
883
887
  if (collection) {
884
888
  const pathOrAlias = collection.id ?? collection.path;
885
889
  const collectionPath = currentFullPath && currentFullPath.length > 0 ? currentFullPath + "/" + pathOrAlias : pathOrAlias;
@@ -12204,6 +12208,10 @@ const editEntityAction = {
12204
12208
  addRecentId(collection.id, entity.id);
12205
12209
  }
12206
12210
  const path = collection?.collectionGroup ? entity.path : fullPath ?? entity.path;
12211
+ const defaultSelectedView = resolveDefaultSelectedView(collection ? collection.defaultSelectedView : void 0, {
12212
+ status: "existing",
12213
+ entityId: entity.id
12214
+ });
12207
12215
  navigateToEntity({
12208
12216
  openEntityMode,
12209
12217
  collection,
@@ -12211,7 +12219,8 @@ const editEntityAction = {
12211
12219
  path,
12212
12220
  sideEntityController: context.sideEntityController,
12213
12221
  onClose: () => unhighlightEntity?.(entity),
12214
- navigation: context.navigation
12222
+ navigation: context.navigation,
12223
+ selectedTab: defaultSelectedView
12215
12224
  });
12216
12225
  return Promise.resolve(void 0);
12217
12226
  }
@@ -20206,29 +20215,36 @@ function useBuildNavigationController(props) {
20206
20215
  ...result
20207
20216
  };
20208
20217
  }, [userConfigPersistence]);
20209
- const getCollectionFromPaths = useCallback((pathSegments) => {
20218
+ const getCollectionById = useCallback((id) => {
20210
20219
  const collections_1 = collectionsRef.current;
20211
- if (collections_1 === void 0) throw Error("getCollectionFromPaths: Collections have not been initialised yet");
20212
- let currentCollections = [...collections_1 ?? []];
20220
+ if (collections_1 === void 0) throw Error("getCollectionById: Collections have not been initialised yet");
20221
+ const collection_0 = collections_1.find((c2) => c2.id === id);
20222
+ if (!collection_0) return void 0;
20223
+ return collection_0;
20224
+ }, []);
20225
+ const getCollectionFromPaths = useCallback((pathSegments) => {
20226
+ const collections_2 = collectionsRef.current;
20227
+ if (collections_2 === void 0) throw Error("getCollectionFromPaths: Collections have not been initialised yet");
20228
+ let currentCollections = [...collections_2 ?? []];
20213
20229
  for (let i = 0; i < pathSegments.length; i++) {
20214
20230
  const pathSegment = pathSegments[i];
20215
- const collection_0 = currentCollections.find((c2) => c2.id === pathSegment || c2.path === pathSegment);
20216
- if (!collection_0) return void 0;
20217
- currentCollections = collection_0.subcollections;
20218
- if (i === pathSegments.length - 1) return collection_0;
20231
+ const collection_1 = currentCollections.find((c_0) => c_0.id === pathSegment || c_0.path === pathSegment);
20232
+ if (!collection_1) return void 0;
20233
+ currentCollections = collection_1.subcollections;
20234
+ if (i === pathSegments.length - 1) return collection_1;
20219
20235
  }
20220
20236
  return void 0;
20221
20237
  }, []);
20222
20238
  const getCollectionFromIds = useCallback((ids) => {
20223
- const collections_2 = collectionsRef.current;
20224
- if (collections_2 === void 0) throw Error("getCollectionFromIds: Collections have not been initialised yet");
20225
- let currentCollections_0 = [...collections_2 ?? []];
20239
+ const collections_3 = collectionsRef.current;
20240
+ if (collections_3 === void 0) throw Error("getCollectionFromIds: Collections have not been initialised yet");
20241
+ let currentCollections_0 = [...collections_3 ?? []];
20226
20242
  for (let i_0 = 0; i_0 < ids.length; i_0++) {
20227
- const id = ids[i_0];
20228
- const collection_1 = currentCollections_0.find((c_0) => c_0.id === id);
20229
- if (!collection_1) return void 0;
20230
- currentCollections_0 = collection_1.subcollections;
20231
- if (i_0 === ids.length - 1) return collection_1;
20243
+ const id_0 = ids[i_0];
20244
+ const collection_2 = currentCollections_0.find((c_1) => c_1.id === id_0);
20245
+ if (!collection_2) return void 0;
20246
+ currentCollections_0 = collection_2.subcollections;
20247
+ if (i_0 === ids.length - 1) return collection_2;
20232
20248
  }
20233
20249
  return void 0;
20234
20250
  }, []);
@@ -20238,14 +20254,14 @@ function useBuildNavigationController(props) {
20238
20254
  throw Error("Expected path starting with " + fullCollectionPath);
20239
20255
  }, [fullCollectionPath]);
20240
20256
  const resolveIdsFrom = useCallback((path_3) => {
20241
- const collections_3 = collectionsRef.current ?? [];
20242
- return resolveCollectionPathIds(path_3, collections_3);
20257
+ const collections_4 = collectionsRef.current ?? [];
20258
+ return resolveCollectionPathIds(path_3, collections_4);
20243
20259
  }, []);
20244
20260
  const getAllParentReferencesForPath = useCallback((path_4) => {
20245
- const collections_4 = collectionsRef.current ?? [];
20261
+ const collections_5 = collectionsRef.current ?? [];
20246
20262
  return getParentReferencesFromPath({
20247
20263
  path: path_4,
20248
- collections: collections_4
20264
+ collections: collections_5
20249
20265
  });
20250
20266
  }, []);
20251
20267
  const getParentCollectionIds = useCallback((path_5) => {
@@ -20259,15 +20275,15 @@ function useBuildNavigationController(props) {
20259
20275
  return result_0.map((r) => getCollectionFromPaths(r)?.id).filter(Boolean);
20260
20276
  }, [getAllParentReferencesForPath]);
20261
20277
  const convertIdsToPaths = useCallback((ids_0) => {
20262
- const collections_5 = collectionsRef.current;
20263
- let currentCollections_1 = collections_5;
20278
+ const collections_6 = collectionsRef.current;
20279
+ let currentCollections_1 = collections_6;
20264
20280
  const paths = [];
20265
20281
  for (let i_3 = 0; i_3 < ids_0.length; i_3++) {
20266
- const id_0 = ids_0[i_3];
20267
- const collection_2 = currentCollections_1.find((c_1) => c_1.id === id_0);
20268
- if (!collection_2) throw Error(`Collection with id ${id_0} not found`);
20269
- paths.push(collection_2.path);
20270
- currentCollections_1 = collection_2.subcollections;
20282
+ const id_1 = ids_0[i_3];
20283
+ const collection_3 = currentCollections_1.find((c_2) => c_2.id === id_1);
20284
+ if (!collection_3) throw Error(`Collection with id ${id_1} not found`);
20285
+ paths.push(collection_3.path);
20286
+ currentCollections_1 = collection_3.subcollections;
20271
20287
  }
20272
20288
  return paths;
20273
20289
  }, [getCollectionFromIds]);
@@ -20282,6 +20298,7 @@ function useBuildNavigationController(props) {
20282
20298
  baseCollectionPath,
20283
20299
  initialised,
20284
20300
  getCollection,
20301
+ getCollectionById,
20285
20302
  getCollectionFromPaths,
20286
20303
  getCollectionFromIds,
20287
20304
  isUrlCollectionPath,
@@ -21059,7 +21076,7 @@ function buildSideActions({
21059
21076
  ] });
21060
21077
  }
21061
21078
  function EntityJsonPreview(t0) {
21062
- const $ = c(9);
21079
+ const $ = c(6);
21063
21080
  const {
21064
21081
  values
21065
21082
  } = t0;
@@ -21076,55 +21093,16 @@ function EntityJsonPreview(t0) {
21076
21093
  mode
21077
21094
  } = useModeController();
21078
21095
  const preRef = useRef(null);
21079
- let t2;
21080
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
21081
- t2 = (e) => {
21082
- if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a") {
21083
- if (preRef.current) {
21084
- e.preventDefault();
21085
- e.stopPropagation();
21086
- const selection = window.getSelection();
21087
- const range = document.createRange();
21088
- range.selectNodeContents(preRef.current);
21089
- if (selection) {
21090
- selection.removeAllRanges();
21091
- selection.addRange(range);
21092
- }
21093
- }
21094
- }
21095
- };
21096
- $[2] = t2;
21097
- } else {
21098
- t2 = $[2];
21099
- }
21100
- const handleGlobalKeyDown = t2;
21096
+ const t2 = mode === "dark" ? themes.vsDark : themes.github;
21101
21097
  let t3;
21102
- let t4;
21103
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
21104
- t3 = () => {
21105
- document.addEventListener("keydown", handleGlobalKeyDown);
21106
- return () => {
21107
- document.removeEventListener("keydown", handleGlobalKeyDown);
21108
- };
21109
- };
21110
- t4 = [handleGlobalKeyDown];
21111
- $[3] = t3;
21112
- $[4] = t4;
21113
- } else {
21114
- t3 = $[3];
21115
- t4 = $[4];
21116
- }
21117
- useEffect(t3, t4);
21118
- const t5 = mode === "dark" ? themes.vsDark : themes.github;
21119
- let t6;
21120
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
21121
- t6 = (t72) => {
21098
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
21099
+ t3 = (t42) => {
21122
21100
  const {
21123
21101
  style,
21124
21102
  tokens,
21125
21103
  getLineProps,
21126
21104
  getTokenProps
21127
- } = t72;
21105
+ } = t42;
21128
21106
  return /* @__PURE__ */ jsx("pre", { ref: preRef, style: {
21129
21107
  ...style,
21130
21108
  backgroundColor: "inherit"
@@ -21134,20 +21112,20 @@ function EntityJsonPreview(t0) {
21134
21112
  token
21135
21113
  }), className: "word-break" }, key)) }, i)) });
21136
21114
  };
21137
- $[5] = t6;
21115
+ $[2] = t3;
21138
21116
  } else {
21139
- t6 = $[5];
21117
+ t3 = $[2];
21140
21118
  }
21141
- let t7;
21142
- if ($[6] !== code || $[7] !== t5) {
21143
- t7 = /* @__PURE__ */ jsx(Highlight, { theme: t5, code, language: "json", children: t6 });
21144
- $[6] = code;
21145
- $[7] = t5;
21146
- $[8] = t7;
21119
+ let t4;
21120
+ if ($[3] !== code || $[4] !== t2) {
21121
+ t4 = /* @__PURE__ */ jsx(Highlight, { theme: t2, code, language: "json", children: t3 });
21122
+ $[3] = code;
21123
+ $[4] = t2;
21124
+ $[5] = t4;
21147
21125
  } else {
21148
- t7 = $[8];
21126
+ t4 = $[5];
21149
21127
  }
21150
- return t7;
21128
+ return t4;
21151
21129
  }
21152
21130
  function createFormexStub(values) {
21153
21131
  const errorMessage = "You are in a read-only context. You cannot modify the formex controller.";
@@ -21285,7 +21263,7 @@ function EntityEditViewInner({
21285
21263
  const subcollectionsCount = subcollections?.length ?? 0;
21286
21264
  const customViews = collection.entityViews;
21287
21265
  const customViewsCount = customViews?.length ?? 0;
21288
- const includeJsonView = true;
21266
+ const includeJsonView = collection.includeJsonView === void 0 ? true : collection.includeJsonView;
21289
21267
  const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0 || includeJsonView;
21290
21268
  const {
21291
21269
  resolvedEntityViews,
@@ -21384,15 +21362,16 @@ function EntityEditViewInner({
21384
21362
  }, Builder: selectedSecondaryForm?.Builder });
21385
21363
  const subcollectionTabs = subcollections && subcollections.map((subcollection_0) => /* @__PURE__ */ jsx(Tab, { className: "text-sm min-w-[120px]", value: subcollection_0.id, children: subcollection_0.name }, `entity_detail_collection_tab_${subcollection_0.name}`));
21386
21364
  const customViewTabs = resolvedEntityViews.map((view) => /* @__PURE__ */ jsx(Tab, { className: "text-sm min-w-[120px]", value: view.key, children: view.name }, `entity_detail_collection_tab_${view.name}`));
21365
+ const shouldShowTopBar = Boolean(barActions) || hasAdditionalViews;
21387
21366
  let result = /* @__PURE__ */ jsxs("div", { className: "relative flex flex-col h-full w-full bg-white dark:bg-surface-900", children: [
21388
- /* @__PURE__ */ jsxs("div", { className: 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", defaultBorderMixin), children: [
21367
+ shouldShowTopBar && /* @__PURE__ */ jsxs("div", { className: 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", defaultBorderMixin), children: [
21389
21368
  barActions,
21390
21369
  /* @__PURE__ */ jsx("div", { className: "flex-grow" }),
21391
21370
  globalLoading && /* @__PURE__ */ jsx("div", { className: "self-center", children: /* @__PURE__ */ jsx(CircularProgress, { size: "small" }) }),
21392
- /* @__PURE__ */ jsxs(Tabs, { value: selectedTab, onValueChange: (value_1) => {
21371
+ hasAdditionalViews && /* @__PURE__ */ jsxs(Tabs, { value: selectedTab, onValueChange: (value_1) => {
21393
21372
  onSideTabClick(value_1);
21394
21373
  }, children: [
21395
- /* @__PURE__ */ jsx(Tab, { disabled: !hasAdditionalViews, value: JSON_TAB_VALUE, innerClassName: "block", className: "text-sm", children: /* @__PURE__ */ jsx(CodeIcon, { size: "small" }) }),
21374
+ includeJsonView && /* @__PURE__ */ jsx(Tab, { disabled: !hasAdditionalViews, value: JSON_TAB_VALUE, innerClassName: "block", className: "text-sm", children: /* @__PURE__ */ jsx(CodeIcon, { size: "small" }) }),
21396
21375
  /* @__PURE__ */ jsx(Tab, { disabled: !hasAdditionalViews, value: MAIN_TAB_VALUE, className: "text-sm min-w-[120px]", children: collection.singularName ?? collection.name }),
21397
21376
  customViewTabs,
21398
21377
  subcollectionTabs
@@ -23031,7 +23010,7 @@ function getFieldId(property) {
23031
23010
  return getDefaultFieldId(property);
23032
23011
  }
23033
23012
  function FireCMSRoute() {
23034
- const $ = c(32);
23013
+ const $ = c(33);
23035
23014
  const location = useLocation$1();
23036
23015
  const navigation = useNavigationController();
23037
23016
  const breadcrumbs = useBreadcrumbsController();
@@ -23144,7 +23123,11 @@ function FireCMSRoute() {
23144
23123
  if ($[18] !== navigation || $[19] !== navigationEntries) {
23145
23124
  t7 = Symbol.for("react.early_return_sentinel");
23146
23125
  bb0: {
23147
- const collection = navigation.getCollection(navigationEntries[0].path);
23126
+ let collection;
23127
+ collection = navigation.getCollectionById(navigationEntries[0].id);
23128
+ if (!collection) {
23129
+ collection = navigation.getCollection(navigationEntries[0].path);
23130
+ }
23148
23131
  if (!collection) {
23149
23132
  t7 = null;
23150
23133
  break bb0;
@@ -23172,48 +23155,56 @@ function FireCMSRoute() {
23172
23155
  return t62;
23173
23156
  }
23174
23157
  if (isSidePanel) {
23175
- let t62;
23176
- if ($[23] !== navigation || $[24] !== navigationEntries) {
23177
- t62 = Symbol.for("react.early_return_sentinel");
23178
- bb1: {
23179
- const lastCollectionEntry = navigationEntries.findLast(_temp2$1);
23180
- if (lastCollectionEntry) {
23181
- const collection_0 = navigation.getCollection(lastCollectionEntry.path);
23158
+ const lastCollectionEntry = navigationEntries.findLast(_temp2$1);
23159
+ if (lastCollectionEntry) {
23160
+ let t62;
23161
+ let t7;
23162
+ if ($[23] !== navigation || $[24] !== navigationEntries) {
23163
+ t7 = Symbol.for("react.early_return_sentinel");
23164
+ bb1: {
23165
+ let collection_0;
23166
+ const firstEntry = navigationEntries[0];
23167
+ collection_0 = navigation.getCollectionById(firstEntry.id);
23168
+ if (!collection_0) {
23169
+ collection_0 = navigation.getCollection(firstEntry.path);
23170
+ }
23182
23171
  if (!collection_0) {
23183
- t62 = null;
23172
+ t7 = null;
23184
23173
  break bb1;
23185
23174
  }
23186
- let t7;
23187
- if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
23188
- t7 = [];
23189
- $[26] = t7;
23175
+ let t8;
23176
+ if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
23177
+ t8 = [];
23178
+ $[27] = t8;
23190
23179
  } else {
23191
- t7 = $[26];
23180
+ t8 = $[27];
23192
23181
  }
23193
- t62 = /* @__PURE__ */ 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}`);
23194
- break bb1;
23182
+ t62 = /* @__PURE__ */ 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}`);
23195
23183
  }
23184
+ $[23] = navigation;
23185
+ $[24] = navigationEntries;
23186
+ $[25] = t62;
23187
+ $[26] = t7;
23188
+ } else {
23189
+ t62 = $[25];
23190
+ t7 = $[26];
23191
+ }
23192
+ if (t7 !== Symbol.for("react.early_return_sentinel")) {
23193
+ return t7;
23196
23194
  }
23197
- $[23] = navigation;
23198
- $[24] = navigationEntries;
23199
- $[25] = t62;
23200
- } else {
23201
- t62 = $[25];
23202
- }
23203
- if (t62 !== Symbol.for("react.early_return_sentinel")) {
23204
23195
  return t62;
23205
23196
  }
23206
23197
  }
23207
23198
  let t6;
23208
- if ($[27] !== isCopy || $[28] !== isNew || $[29] !== navigationEntries || $[30] !== pathname) {
23199
+ if ($[28] !== isCopy || $[29] !== isNew || $[30] !== navigationEntries || $[31] !== pathname) {
23209
23200
  t6 = /* @__PURE__ */ jsx(EntityFullScreenRoute, { pathname, navigationEntries, isNew, isCopy });
23210
- $[27] = isCopy;
23211
- $[28] = isNew;
23212
- $[29] = navigationEntries;
23213
- $[30] = pathname;
23214
- $[31] = t6;
23201
+ $[28] = isCopy;
23202
+ $[29] = isNew;
23203
+ $[30] = navigationEntries;
23204
+ $[31] = pathname;
23205
+ $[32] = t6;
23215
23206
  } else {
23216
- t6 = $[31];
23207
+ t6 = $[32];
23217
23208
  }
23218
23209
  return t6;
23219
23210
  }