@firecms/core 3.0.0-canary.225 → 3.0.0-canary.227

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
@@ -71,23 +71,46 @@ function resolveCollectionPathIds(path, allCollections) {
71
71
  const cleanPath = removeInitialAndTrailingSlashes(path);
72
72
  const subpaths = cleanPath.split("/");
73
73
  if (subpaths.length % 2 === 0) {
74
- throw Error(`resolveCollectionPathAliases: Collection paths must have an odd number of segments: ${path}`);
75
- }
76
- const aliasedCollection = allCollections.find((col) => col.id === subpaths[0]);
77
- let resolvedAliased;
78
- if (aliasedCollection) {
79
- resolvedAliased = aliasedCollection.path;
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;
91
+ break;
92
+ }
80
93
  }
81
- if (subpaths.length > 1) {
82
- const segmentCollection = getCollectionByPathOrId(resolvedAliased ?? subpaths[0], allCollections);
83
- if (!segmentCollection?.subcollections) {
94
+ if (!matchingCollection) {
95
+ const matchingCollections = allCollections.filter((col) => col.id === subpaths[0] || col.path === subpaths[0]);
96
+ if (!matchingCollections.length) {
84
97
  return cleanPath;
85
98
  }
86
- const restOfThePath = cleanPath.split("/").slice(2).join("/");
87
- return (resolvedAliased ?? subpaths[0]) + "/" + subpaths[1] + "/" + resolveCollectionPathIds(restOfThePath, segmentCollection.subcollections);
88
- } else {
89
- return resolvedAliased ?? cleanPath;
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}`;
108
+ }
109
+ }
110
+ if (remainingPath.length === 0) {
111
+ return `${matchingCollection.path}/${entityId}`;
90
112
  }
113
+ return `${matchingCollection.path}/${entityId}/${remainingPath.join("/")}`;
91
114
  }
92
115
  function getCollectionByPathOrId(pathOrId, collections) {
93
116
  const subpaths = removeInitialAndTrailingSlashes(pathOrId).split("/");
@@ -10483,7 +10506,30 @@ const VirtualTable = React__default.memo(function VirtualTable2({
10483
10506
  useEffect(() => {
10484
10507
  setColumns(columnsProp);
10485
10508
  }, [columnsProp]);
10486
- const [measureRef, bounds] = useMeasure();
10509
+ const [_, setForceUpdate] = useState(false);
10510
+ useEffect(() => {
10511
+ if (tableRef.current) {
10512
+ const resizeObserver = new ResizeObserver(() => {
10513
+ setForceUpdate((prev) => !prev);
10514
+ });
10515
+ resizeObserver.observe(tableRef.current);
10516
+ return () => {
10517
+ if (tableRef.current) {
10518
+ resizeObserver.unobserve(tableRef.current);
10519
+ }
10520
+ resizeObserver.disconnect();
10521
+ };
10522
+ }
10523
+ return () => {
10524
+ };
10525
+ }, [tableRef]);
10526
+ const [measureRef, bounds] = useMeasure({
10527
+ debounce: 50,
10528
+ polyfill: ResizeObserver,
10529
+ scroll: true,
10530
+ // This is important for handling zooming in react-flow
10531
+ offsetSize: true
10532
+ });
10487
10533
  const onColumnResizeInternal = useCallback((params) => {
10488
10534
  if (debug) console.log("onColumnResizeInternal", params);
10489
10535
  setColumns(columns.map((column) => column.key === params.column.key ? params.column : column));
@@ -12207,7 +12253,7 @@ const editEntityAction = {
12207
12253
  if (collection) {
12208
12254
  addRecentId(collection.id, entity.id);
12209
12255
  }
12210
- const path = collection?.collectionGroup ? entity.path : fullPath ?? entity.path;
12256
+ const path = collection?.collectionGroup ? collection.id : fullPath ?? collection?.id ?? entity.path;
12211
12257
  const defaultSelectedView = resolveDefaultSelectedView(collection ? collection.defaultSelectedView : void 0, {
12212
12258
  status: "existing",
12213
12259
  entityId: entity.id
@@ -12243,7 +12289,7 @@ const copyEntityAction = {
12243
12289
  path: entity.path,
12244
12290
  entityId: entity.id
12245
12291
  });
12246
- const path = collection?.collectionGroup ? entity.path : fullPath ?? entity.path;
12292
+ const path = collection?.collectionGroup ? collection.id : fullPath ?? collection?.id ?? entity.path;
12247
12293
  navigateToEntity({
12248
12294
  openEntityMode,
12249
12295
  collection,
@@ -18423,9 +18469,9 @@ const EntityCollectionView = React__default.memo(function EntityCollectionView2(
18423
18469
  ...collectionProp
18424
18470
  }) {
18425
18471
  const context = useFireCMSContext();
18472
+ const navigation = useNavigationController();
18426
18473
  const fullPath = fullPathProp ?? collectionProp.path;
18427
18474
  const dataSource = useDataSource();
18428
- const navigation = useNavigationController();
18429
18475
  const sideEntityController = useSideEntityController();
18430
18476
  const authController = useAuthController();
18431
18477
  const userConfigPersistence = useUserConfigurationPersistence();