@firecms/core 3.0.0-canary.231 → 3.0.0-canary.233

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
@@ -68,49 +68,66 @@ function getLastSegment(path) {
68
68
  return cleanPath;
69
69
  }
70
70
  function resolveCollectionPathIds(path, allCollections) {
71
- const cleanPath = removeInitialAndTrailingSlashes(path);
72
- const subpaths = cleanPath.split("/");
73
- if (subpaths.length % 2 === 0) {
74
- throw Error(`resolveCollectionPathIds: Collection paths must have an odd number of segments: ${path}`);
75
- }
76
- const exactMatch = allCollections.find((col) => col.path === cleanPath);
77
- if (exactMatch) {
78
- return exactMatch.path;
79
- }
80
- if (subpaths.length === 1) {
81
- const aliasedCollection = allCollections.find((col) => col.id === subpaths[0]);
82
- return aliasedCollection?.path ?? subpaths[0];
83
- }
84
- let matchingCollection;
85
- let entityIndex = 1;
86
- for (const collection of allCollections) {
87
- const pathSegments = collection.path.split("/");
88
- if (pathSegments.length > 1 && subpaths.slice(0, pathSegments.length).join("/") === collection.path) {
89
- matchingCollection = collection;
90
- entityIndex = pathSegments.length;
71
+ let remainingPath = removeInitialAndTrailingSlashes(path);
72
+ if (!remainingPath) {
73
+ return "";
74
+ }
75
+ let currentCollections = allCollections;
76
+ const resolvedPathParts = [];
77
+ while (remainingPath.length > 0) {
78
+ if (!currentCollections || currentCollections.length === 0) {
79
+ console.warn(`resolveCollectionPathIds: Path structure implies subcollections, but none found before segment starting with "${remainingPath}" in original path "${path}". Appending remaining original path.`);
80
+ resolvedPathParts.push(remainingPath);
81
+ remainingPath = "";
91
82
  break;
92
83
  }
93
- }
94
- if (!matchingCollection) {
95
- const matchingCollections = allCollections.filter((col) => col.id === subpaths[0] || col.path === subpaths[0]);
96
- if (!matchingCollections.length) {
97
- return cleanPath;
84
+ let foundMatch = false;
85
+ const potentialMatches = currentCollections.flatMap((col) => [{
86
+ col,
87
+ match: col.path
88
+ }, {
89
+ col,
90
+ match: col.id
91
+ }]).filter((p) => p.match && remainingPath.startsWith(p.match)).sort((a, b) => b.match.length - a.match.length);
92
+ if (potentialMatches.length > 0) {
93
+ const {
94
+ col: foundCollection,
95
+ match: matchString
96
+ } = potentialMatches[0];
97
+ resolvedPathParts.push(foundCollection.path);
98
+ remainingPath = removeInitialSlash(remainingPath.substring(matchString.length));
99
+ if (remainingPath.length === 0) {
100
+ foundMatch = true;
101
+ break;
102
+ }
103
+ const idSeparatorIndex = remainingPath.indexOf("/");
104
+ let entityId;
105
+ if (idSeparatorIndex > -1) {
106
+ entityId = remainingPath.substring(0, idSeparatorIndex);
107
+ remainingPath = remainingPath.substring(idSeparatorIndex + 1);
108
+ } else {
109
+ entityId = remainingPath;
110
+ remainingPath = "";
111
+ console.warn(`resolveCollectionPathIds: Path seems to end with an entity ID "${entityId}" instead of a collection segment in original path "${path}". This might indicate an invalid input path.`);
112
+ }
113
+ resolvedPathParts.push(entityId);
114
+ currentCollections = foundCollection.subcollections;
115
+ foundMatch = true;
116
+ if (!currentCollections && remainingPath.length > 0) {
117
+ console.warn(`resolveCollectionPathIds: Path continues after entity ID "${entityId}", but no subcollections are defined for the preceding collection "${foundCollection.path}" in path "${path}". Appending remaining original path.`);
118
+ resolvedPathParts.push(remainingPath);
119
+ remainingPath = "";
120
+ break;
121
+ }
98
122
  }
99
- matchingCollection = matchingCollections[0];
100
- }
101
- const entityId = subpaths[entityIndex];
102
- const remainingPath = subpaths.slice(entityIndex + 1);
103
- if (remainingPath.length > 0) {
104
- const subcollectionId = remainingPath[0];
105
- const subcollection = matchingCollection.subcollections?.find((subcol) => subcol.id === subcollectionId);
106
- if (subcollection) {
107
- return `${matchingCollection.path}/${entityId}/${subcollection.path}`;
123
+ if (!foundMatch) {
124
+ console.warn(`resolveCollectionPathIds: Collection definition not found for segment starting with "${remainingPath}" in original path "${path}". Appending remaining original path.`);
125
+ resolvedPathParts.push(remainingPath);
126
+ remainingPath = "";
127
+ break;
108
128
  }
109
129
  }
110
- if (remainingPath.length === 0) {
111
- return `${matchingCollection.path}/${entityId}`;
112
- }
113
- return `${matchingCollection.path}/${entityId}/${remainingPath.join("/")}`;
130
+ return resolvedPathParts.join("/");
114
131
  }
115
132
  function getCollectionByPathOrId(pathOrId, collections) {
116
133
  const subpaths = removeInitialAndTrailingSlashes(pathOrId).split("/");
@@ -6496,7 +6513,7 @@ function _temp$n(t0) {
6496
6513
  return /* @__PURE__ */ jsxs("div", { className: cls(defaultBorderMixin, "last:border-b-0 border-b"), children: [
6497
6514
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row pt-0.5 pb-0.5 gap-2", children: [
6498
6515
  /* @__PURE__ */ jsx("div", { className: "min-w-[140px] w-[25%] py-1", children: /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "font-mono break-words", color: "secondary", children: key }) }, `table-cell-title-${key}-${key}`),
6499
- /* @__PURE__ */ jsx("div", { className: "flex-grow max-w-[75%]", children: childValue && /* @__PURE__ */ jsx(Typography, { children: /* @__PURE__ */ jsx(ErrorBoundary, { children: childValue.toString() }) }) })
6516
+ /* @__PURE__ */ jsx("div", { className: "flex-grow max-w-[75%]", children: childValue && typeof childValue !== "object" && /* @__PURE__ */ jsx(Typography, { children: /* @__PURE__ */ jsx(ErrorBoundary, { children: childValue.toString() }) }) })
6500
6517
  ] }),
6501
6518
  typeof childValue === "object" && /* @__PURE__ */ jsx("div", { className: cls(defaultBorderMixin, "border-l pl-4"), children: /* @__PURE__ */ jsx(KeyValuePreview, { value: childValue }) })
6502
6519
  ] }, `map_preview_table_${key}}`);
@@ -16640,6 +16657,7 @@ function KeyValueFieldBinding(t0) {
16640
16657
  t6 = $[15];
16641
16658
  }
16642
16659
  const title = t6;
16660
+ console.log("minimalistView", propertyKey, minimalistView);
16643
16661
  let t7;
16644
16662
  if ($[16] !== expanded || $[17] !== mapFormView || $[18] !== minimalistView || $[19] !== title) {
16645
16663
  t7 = !minimalistView && /* @__PURE__ */ jsx(ExpandablePanel, { initiallyExpanded: expanded, title, innerClassName: "px-2 md:px-4 pb-2 md:pb-4 pt-1 md:pt-2", children: mapFormView });
@@ -18261,7 +18279,7 @@ function PopupFormFieldInternal({
18261
18279
  underlyingValueHasChanged: false,
18262
18280
  context: formContext,
18263
18281
  partOfArray: false,
18264
- minimalistView: false,
18282
+ minimalistView: true,
18265
18283
  autoFocus: open
18266
18284
  } : void 0;
18267
18285
  let internalForm = /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: "w-[700px] max-w-full max-h-[85vh]", children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, noValidate: true, children: [
@@ -18313,7 +18331,7 @@ function ClearFilterSortButton(t0) {
18313
18331
  if ((filterIsSet || sortIsSet) && (tableController.clearFilter || tableController.setSortBy)) {
18314
18332
  let label;
18315
18333
  if (filterIsSet && sortIsSet) {
18316
- label = "Clear filter and sort";
18334
+ label = "Clear filter/sort";
18317
18335
  } else {
18318
18336
  if (filterIsSet) {
18319
18337
  label = "Clear filter";