@firecms/core 3.4.0-canary.63041d0 → 3.4.0-canary.d20cc85

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.
Files changed (32) hide show
  1. package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +3 -1
  2. package/dist/components/EntityCollectionView/EntityCollectionBoardView.d.ts +3 -1
  3. package/dist/components/EntityCollectionView/useBoardDataController.d.ts +3 -1
  4. package/dist/components/ReferenceTable/ReferenceSelectionTable.d.ts +10 -1
  5. package/dist/form/EntityForm.d.ts +6 -1
  6. package/dist/hooks/data/useCollectionFetch.d.ts +7 -1
  7. package/dist/index.es.js +177 -112
  8. package/dist/index.es.js.map +1 -1
  9. package/dist/index.umd.js +177 -112
  10. package/dist/index.umd.js.map +1 -1
  11. package/dist/types/datasource.d.ts +17 -4
  12. package/dist/types/entities.d.ts +21 -1
  13. package/dist/util/parent_references_from_path.d.ts +1 -0
  14. package/package.json +4 -4
  15. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +5 -1
  16. package/src/components/EntityCollectionView/EntityCollectionBoardView.tsx +4 -0
  17. package/src/components/EntityCollectionView/EntityCollectionView.tsx +10 -2
  18. package/src/components/EntityCollectionView/useBoardDataController.tsx +11 -0
  19. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +11 -0
  20. package/src/components/common/useDataSourceTableController.tsx +8 -2
  21. package/src/core/EntityEditView.tsx +5 -2
  22. package/src/form/EntityForm.tsx +8 -2
  23. package/src/hooks/data/delete.ts +2 -0
  24. package/src/hooks/data/save.ts +1 -1
  25. package/src/hooks/data/useCollectionFetch.tsx +13 -0
  26. package/src/hooks/data/useEntityFetch.tsx +10 -1
  27. package/src/hooks/useResolvedNavigationFrom.tsx +2 -0
  28. package/src/internal/useBuildDataSource.ts +14 -4
  29. package/src/types/datasource.ts +17 -4
  30. package/src/types/entities.ts +24 -1
  31. package/src/util/entities.ts +3 -1
  32. package/src/util/parent_references_from_path.ts +10 -2
package/dist/index.umd.js CHANGED
@@ -346,10 +346,21 @@
346
346
  * Optional database ID where the entity is stored (if multiple databases are used)
347
347
  */
348
348
  databaseId;
349
- constructor(id, path, databaseId) {
349
+ /**
350
+ * `path` split at its real segment boundaries, e.g. `["nodes", "node/42", "edges"]`.
351
+ *
352
+ * `path` is a single flattened string, so a parent entity id containing "/" cannot be
353
+ * recovered from it. This keeps each segment whole.
354
+ *
355
+ * Optional, and never derived by splitting `path` — a guess would be wrong in exactly
356
+ * the case the field exists for. Absent means "not known here", not "no slashes".
357
+ */
358
+ pathSegments;
359
+ constructor(id, path, databaseId, pathSegments) {
350
360
  this.id = id;
351
361
  this.path = path;
352
362
  this.databaseId = databaseId;
363
+ this.pathSegments = pathSegments;
353
364
  }
354
365
  get pathWithId() {
355
366
  return `${this.path}/${this.id}`;
@@ -720,7 +731,7 @@
720
731
  if (!entity) {
721
732
  throw new Error("getReferenceFrom: entity is null or undefined");
722
733
  }
723
- return new EntityReference(entity.id, entity.path, entity.databaseId);
734
+ return new EntityReference(entity.id, entity.path, entity.databaseId, entity.pathSegments);
724
735
  }
725
736
  function traverseValuesProperties(inputValues, properties, operation) {
726
737
  const safeInputValues = inputValues ?? {};
@@ -4613,9 +4624,10 @@
4613
4624
  return fireCMSContextRef.current;
4614
4625
  };
4615
4626
  function useCollectionFetch(t0) {
4616
- const $ = reactCompilerRuntime.c(26);
4627
+ const $ = reactCompilerRuntime.c(27);
4617
4628
  const {
4618
4629
  path: inputPath,
4630
+ pathSegments,
4619
4631
  collection,
4620
4632
  filterValues,
4621
4633
  sortBy,
@@ -4649,10 +4661,16 @@
4649
4661
  const [dataLoadingError, setDataLoadingError] = React.useState();
4650
4662
  const [noMoreToLoad, setNoMoreToLoad] = React.useState(false);
4651
4663
  let t3;
4652
- if ($[4] !== collection || $[5] !== context || $[6] !== currentSort || $[7] !== dataSource || $[8] !== filterValues || $[9] !== itemCount || $[10] !== path || $[11] !== searchString || $[12] !== sortByProperty) {
4664
+ if ($[4] !== collection || $[5] !== context || $[6] !== currentSort || $[7] !== dataSource || $[8] !== filterValues || $[9] !== itemCount || $[10] !== path || $[11] !== pathSegments || $[12] !== searchString || $[13] !== sortByProperty) {
4653
4665
  t3 = () => {
4654
4666
  setDataLoading(true);
4655
4667
  const onEntitiesUpdate = async (entities) => {
4668
+ if (pathSegments) {
4669
+ entities = entities.map((e) => e.pathSegments ? e : {
4670
+ ...e,
4671
+ pathSegments
4672
+ });
4673
+ }
4656
4674
  if (collection.callbacks?.onFetch) {
4657
4675
  try {
4658
4676
  entities = await Promise.all(entities.map((entity) => collection.callbacks.onFetch({
@@ -4662,8 +4680,8 @@
4662
4680
  context
4663
4681
  })));
4664
4682
  } catch (t42) {
4665
- const e = t42;
4666
- console.error(e);
4683
+ const e_0 = t42;
4684
+ console.error(e_0);
4667
4685
  }
4668
4686
  }
4669
4687
  setDataLoading(false);
@@ -4680,6 +4698,7 @@
4680
4698
  if (dataSource.listenCollection) {
4681
4699
  return dataSource.listenCollection({
4682
4700
  path,
4701
+ pathSegments,
4683
4702
  collection,
4684
4703
  onUpdate: onEntitiesUpdate,
4685
4704
  onError,
@@ -4693,6 +4712,7 @@
4693
4712
  } else {
4694
4713
  dataSource.fetchCollection({
4695
4714
  path,
4715
+ pathSegments,
4696
4716
  collection,
4697
4717
  searchString,
4698
4718
  filter: filterValues,
@@ -4711,54 +4731,55 @@
4711
4731
  $[8] = filterValues;
4712
4732
  $[9] = itemCount;
4713
4733
  $[10] = path;
4714
- $[11] = searchString;
4715
- $[12] = sortByProperty;
4716
- $[13] = t3;
4734
+ $[11] = pathSegments;
4735
+ $[12] = searchString;
4736
+ $[13] = sortByProperty;
4737
+ $[14] = t3;
4717
4738
  } else {
4718
- t3 = $[13];
4739
+ t3 = $[14];
4719
4740
  }
4720
4741
  let t4;
4721
- if ($[14] !== currentSort || $[15] !== filterValues || $[16] !== itemCount || $[17] !== path || $[18] !== searchString || $[19] !== sortByProperty) {
4742
+ if ($[15] !== currentSort || $[16] !== filterValues || $[17] !== itemCount || $[18] !== path || $[19] !== searchString || $[20] !== sortByProperty) {
4722
4743
  t4 = [path, itemCount, currentSort, sortByProperty, filterValues, searchString];
4723
- $[14] = currentSort;
4724
- $[15] = filterValues;
4725
- $[16] = itemCount;
4726
- $[17] = path;
4727
- $[18] = searchString;
4728
- $[19] = sortByProperty;
4729
- $[20] = t4;
4744
+ $[15] = currentSort;
4745
+ $[16] = filterValues;
4746
+ $[17] = itemCount;
4747
+ $[18] = path;
4748
+ $[19] = searchString;
4749
+ $[20] = sortByProperty;
4750
+ $[21] = t4;
4730
4751
  } else {
4731
- t4 = $[20];
4752
+ t4 = $[21];
4732
4753
  }
4733
4754
  React.useEffect(t3, t4);
4734
4755
  let t5;
4735
- if ($[21] !== data || $[22] !== dataLoading || $[23] !== dataLoadingError || $[24] !== noMoreToLoad) {
4756
+ if ($[22] !== data || $[23] !== dataLoading || $[24] !== dataLoadingError || $[25] !== noMoreToLoad) {
4736
4757
  t5 = {
4737
4758
  data,
4738
4759
  dataLoading,
4739
4760
  dataLoadingError,
4740
4761
  noMoreToLoad
4741
4762
  };
4742
- $[21] = data;
4743
- $[22] = dataLoading;
4744
- $[23] = dataLoadingError;
4745
- $[24] = noMoreToLoad;
4746
- $[25] = t5;
4763
+ $[22] = data;
4764
+ $[23] = dataLoading;
4765
+ $[24] = dataLoadingError;
4766
+ $[25] = noMoreToLoad;
4767
+ $[26] = t5;
4747
4768
  } else {
4748
- t5 = $[25];
4769
+ t5 = $[26];
4749
4770
  }
4750
4771
  return t5;
4751
4772
  }
4752
4773
  function _temp2$f() {
4753
4774
  }
4754
- function _temp$D(e_0) {
4775
+ function _temp$D(e_1) {
4755
4776
  return {
4756
- ...e_0
4777
+ ...e_1
4757
4778
  };
4758
4779
  }
4759
4780
  const CACHE = {};
4760
4781
  function useEntityFetch(t0) {
4761
- const $ = reactCompilerRuntime.c(21);
4782
+ const $ = reactCompilerRuntime.c(19);
4762
4783
  const {
4763
4784
  path: inputPath,
4764
4785
  pathSegments: inputPathSegments,
@@ -4770,30 +4791,32 @@
4770
4791
  const useCache = t1 === void 0 ? false : t1;
4771
4792
  const dataSource = useDataSource();
4772
4793
  const navigationController = useNavigationController();
4773
- let path;
4774
4794
  let t2;
4775
- if ($[0] !== inputPath || $[1] !== inputPathSegments || $[2] !== navigationController) {
4776
- path = navigationController.resolveIdsFrom(inputPath);
4777
- t2 = inputPathSegments ?? path.split("/");
4795
+ if ($[0] !== inputPath || $[1] !== navigationController) {
4796
+ t2 = navigationController.resolveIdsFrom(inputPath);
4778
4797
  $[0] = inputPath;
4779
- $[1] = inputPathSegments;
4780
- $[2] = navigationController;
4781
- $[3] = path;
4782
- $[4] = t2;
4798
+ $[1] = navigationController;
4799
+ $[2] = t2;
4783
4800
  } else {
4784
- path = $[3];
4785
- t2 = $[4];
4801
+ t2 = $[2];
4786
4802
  }
4787
- const pathSegments = t2;
4803
+ const path = t2;
4804
+ const pathSegments = inputPathSegments;
4788
4805
  const context = useFireCMSContext();
4789
4806
  const [entity, setEntity] = React.useState();
4790
4807
  const [dataLoading, setDataLoading] = React.useState(true);
4791
4808
  const [dataLoadingError, setDataLoadingError] = React.useState();
4792
4809
  let t3;
4793
- if ($[5] !== collection || $[6] !== context || $[7] !== dataSource || $[8] !== databaseId || $[9] !== entityId || $[10] !== path || $[11] !== pathSegments || $[12] !== useCache) {
4810
+ if ($[3] !== collection || $[4] !== context || $[5] !== dataSource || $[6] !== databaseId || $[7] !== entityId || $[8] !== path || $[9] !== pathSegments || $[10] !== useCache) {
4794
4811
  t3 = () => {
4795
4812
  setDataLoading(true);
4796
4813
  const onEntityUpdate = async (updatedEntity) => {
4814
+ if (updatedEntity && pathSegments && !updatedEntity.pathSegments) {
4815
+ updatedEntity = {
4816
+ ...updatedEntity,
4817
+ pathSegments
4818
+ };
4819
+ }
4797
4820
  if (collection.callbacks?.onFetch && updatedEntity) {
4798
4821
  try {
4799
4822
  updatedEntity = await collection.callbacks.onFetch({
@@ -4851,41 +4874,41 @@
4851
4874
  }
4852
4875
  }
4853
4876
  };
4854
- $[5] = collection;
4855
- $[6] = context;
4856
- $[7] = dataSource;
4857
- $[8] = databaseId;
4858
- $[9] = entityId;
4859
- $[10] = path;
4860
- $[11] = pathSegments;
4861
- $[12] = useCache;
4862
- $[13] = t3;
4877
+ $[3] = collection;
4878
+ $[4] = context;
4879
+ $[5] = dataSource;
4880
+ $[6] = databaseId;
4881
+ $[7] = entityId;
4882
+ $[8] = path;
4883
+ $[9] = pathSegments;
4884
+ $[10] = useCache;
4885
+ $[11] = t3;
4863
4886
  } else {
4864
- t3 = $[13];
4887
+ t3 = $[11];
4865
4888
  }
4866
4889
  let t4;
4867
- if ($[14] !== entityId || $[15] !== path) {
4890
+ if ($[12] !== entityId || $[13] !== path) {
4868
4891
  t4 = [entityId, path];
4869
- $[14] = entityId;
4870
- $[15] = path;
4871
- $[16] = t4;
4892
+ $[12] = entityId;
4893
+ $[13] = path;
4894
+ $[14] = t4;
4872
4895
  } else {
4873
- t4 = $[16];
4896
+ t4 = $[14];
4874
4897
  }
4875
4898
  React.useEffect(t3, t4);
4876
4899
  let t5;
4877
- if ($[17] !== dataLoading || $[18] !== dataLoadingError || $[19] !== entity) {
4900
+ if ($[15] !== dataLoading || $[16] !== dataLoadingError || $[17] !== entity) {
4878
4901
  t5 = {
4879
4902
  entity,
4880
4903
  dataLoading,
4881
4904
  dataLoadingError
4882
4905
  };
4883
- $[17] = dataLoading;
4884
- $[18] = dataLoadingError;
4885
- $[19] = entity;
4886
- $[20] = t5;
4906
+ $[15] = dataLoading;
4907
+ $[16] = dataLoadingError;
4908
+ $[17] = entity;
4909
+ $[18] = t5;
4887
4910
  } else {
4888
- t5 = $[20];
4911
+ t5 = $[18];
4889
4912
  }
4890
4913
  return t5;
4891
4914
  }
@@ -4948,7 +4971,7 @@
4948
4971
  return dataSource.saveEntity({
4949
4972
  collection,
4950
4973
  path: resolvedPath,
4951
- pathSegments: pathSegments ?? resolvedPath.split("/"),
4974
+ pathSegments,
4952
4975
  entityId,
4953
4976
  values: updatedValues,
4954
4977
  previousValues,
@@ -5032,6 +5055,8 @@
5032
5055
  }
5033
5056
  }
5034
5057
  return dataSource.deleteEntity({
5058
+ // Carried by the entity from the fetch that produced it; undefined if unknown.
5059
+ pathSegments: entity.pathSegments,
5035
5060
  entity,
5036
5061
  collection
5037
5062
  }).then(() => {
@@ -5073,6 +5098,8 @@
5073
5098
  }
5074
5099
  return dataSource.fetchEntity({
5075
5100
  path: entry.path,
5101
+ // The navigation entry already knows the real segment boundaries.
5102
+ pathSegments: entry.pathSegments,
5076
5103
  entityId: entry.entityId,
5077
5104
  collection
5078
5105
  }).then((entity) => {
@@ -16719,6 +16746,7 @@
16719
16746
  }
16720
16747
  function EntityForm({
16721
16748
  path,
16749
+ pathSegments,
16722
16750
  fullIdPath,
16723
16751
  entityId: entityIdProp,
16724
16752
  collection,
@@ -16785,7 +16813,7 @@
16785
16813
  if (mustSetCustomId) {
16786
16814
  return void 0;
16787
16815
  } else {
16788
- return dataSource.generateEntityId(path, collection);
16816
+ return dataSource.generateEntityId(path, collection, pathSegments);
16789
16817
  }
16790
16818
  } else {
16791
16819
  return entityIdProp;
@@ -17098,7 +17126,7 @@
17098
17126
  const uniqueFieldValidator = React.useCallback(({
17099
17127
  name,
17100
17128
  value
17101
- }) => dataSource.checkUniqueField(path, name, value, entityId, collection), [dataSource, path, entityId]);
17129
+ }) => dataSource.checkUniqueField(path, name, value, entityId, collection, pathSegments), [dataSource, path, entityId]);
17102
17130
  const validationSchema = React.useMemo(() => entityId ? getYupEntitySchema(entityId, resolvedCollection.properties, uniqueFieldValidator) : void 0, [entityId, resolvedCollection.properties, uniqueFieldValidator]);
17103
17131
  useOnAutoSave(autoSave, formex$1, lastSavedValues, save);
17104
17132
  const prevEntityValuesRef = React.useRef(entity?.values);
@@ -20066,7 +20094,7 @@
20066
20094
  const navigation = useNavigationController();
20067
20095
  const dataSource = useDataSource();
20068
20096
  const resolvedPath = React.useMemo(() => navigation.resolveIdsFrom(fullPath), [fullPath, navigation.resolveIdsFrom]);
20069
- const resolvedPathSegments = React.useMemo(() => pathSegments ?? resolvedPath.split("/"), [pathSegments, resolvedPath]);
20097
+ const resolvedPathSegments = pathSegments;
20070
20098
  const forceFilter = forceFilterFromProps ?? forceFilterFromCollection;
20071
20099
  const paginationEnabled = collection.pagination === void 0 || Boolean(collection.pagination);
20072
20100
  const pageSize = typeof collection.pagination === "number" ? collection.pagination : DEFAULT_PAGE_SIZE$1;
@@ -20074,6 +20102,7 @@
20074
20102
  if (!dataSource.isFilterCombinationValid) return true;
20075
20103
  return dataSource.isFilterCombinationValid({
20076
20104
  path: resolvedPath,
20105
+ pathSegments: resolvedPathSegments,
20077
20106
  collection,
20078
20107
  filterValues,
20079
20108
  sortBy
@@ -20162,6 +20191,12 @@
20162
20191
  React.useEffect(() => {
20163
20192
  setDataLoading(true);
20164
20193
  const onEntitiesUpdate = async (entities) => {
20194
+ if (resolvedPathSegments) {
20195
+ entities = entities.map((e) => e.pathSegments ? e : {
20196
+ ...e,
20197
+ pathSegments: resolvedPathSegments
20198
+ });
20199
+ }
20165
20200
  if (collection.callbacks?.onFetch) {
20166
20201
  try {
20167
20202
  entities = await Promise.all(entities.map((entity) => collection.callbacks.onFetch({
@@ -20170,14 +20205,14 @@
20170
20205
  entity,
20171
20206
  context
20172
20207
  })));
20173
- } catch (e) {
20174
- console.error(e);
20208
+ } catch (e_0) {
20209
+ console.error(e_0);
20175
20210
  }
20176
20211
  }
20177
20212
  setDataLoading(false);
20178
20213
  setDataLoadingError(void 0);
20179
- setRawData(entities.map((e_0) => ({
20180
- ...e_0
20214
+ setRawData(entities.map((e_1) => ({
20215
+ ...e_1
20181
20216
  // values: sanitizeData(e.values, resolvedCollection.properties)
20182
20217
  })));
20183
20218
  setNoMoreToLoad(!itemCount || entities.length < itemCount);
@@ -20218,8 +20253,8 @@
20218
20253
  return () => {
20219
20254
  };
20220
20255
  }
20221
- } catch (e_1) {
20222
- onError(e_1 instanceof Error ? e_1 : new Error(String(e_1)));
20256
+ } catch (e_2) {
20257
+ onError(e_2 instanceof Error ? e_2 : new Error(String(e_2)));
20223
20258
  return () => {
20224
20259
  };
20225
20260
  }
@@ -20731,6 +20766,7 @@
20731
20766
  multiselect,
20732
20767
  collection,
20733
20768
  path: pathInput,
20769
+ pathSegments,
20734
20770
  selectedEntityIds: selectedEntityIdsProp,
20735
20771
  description,
20736
20772
  forceFilter,
@@ -20773,6 +20809,7 @@
20773
20809
  if (selectedEntityIds && collection) {
20774
20810
  Promise.all(selectedEntityIds.map((entityId) => dataSource.fetchEntity({
20775
20811
  path: fullPath,
20812
+ pathSegments,
20776
20813
  entityId,
20777
20814
  collection
20778
20815
  }))).then((entities) => {
@@ -24371,6 +24408,7 @@
24371
24408
  const DEFAULT_PAGE_SIZE = 20;
24372
24409
  function useBoardDataController({
24373
24410
  fullPath,
24411
+ pathSegments,
24374
24412
  collection,
24375
24413
  columnProperty,
24376
24414
  columns,
@@ -24383,6 +24421,7 @@
24383
24421
  const dataSource = useDataSource();
24384
24422
  const navigation = useNavigationController();
24385
24423
  const resolvedPath = React.useMemo(() => navigation.resolveIdsFrom(fullPath), [fullPath, navigation.resolveIdsFrom]);
24424
+ const resolvedPathSegments = pathSegments;
24386
24425
  const dataSourceRef = React.useRef(dataSource);
24387
24426
  const collectionRef = React.useRef(collection);
24388
24427
  const contextRef = React.useRef(context);
@@ -24394,11 +24433,13 @@
24394
24433
  const orderPropertyRef = React.useRef(orderProperty);
24395
24434
  const searchStringRef = React.useRef(searchString);
24396
24435
  const resolvedPathRef = React.useRef(resolvedPath);
24436
+ const resolvedPathSegmentsRef = React.useRef(resolvedPathSegments);
24397
24437
  filterValuesRef.current = filterValues;
24398
24438
  columnPropertyRef.current = columnProperty;
24399
24439
  orderPropertyRef.current = orderProperty;
24400
24440
  searchStringRef.current = searchString;
24401
24441
  resolvedPathRef.current = resolvedPath;
24442
+ resolvedPathSegmentsRef.current = resolvedPathSegments;
24402
24443
  const [columnItemCounts, setColumnItemCounts] = React.useState(() => {
24403
24444
  const initial = {};
24404
24445
  columns.forEach((col) => {
@@ -24445,6 +24486,7 @@
24445
24486
  const currentOrderProperty = orderPropertyRef.current;
24446
24487
  const currentSearchString = searchStringRef.current;
24447
24488
  const currentResolvedPath = resolvedPathRef.current;
24489
+ const currentPathSegments = resolvedPathSegmentsRef.current;
24448
24490
  const columnFilter = {
24449
24491
  ...currentFilterValues,
24450
24492
  [currentColumnProperty]: ["==", column]
@@ -24501,6 +24543,7 @@
24501
24543
  if (currentDataSource.listenCollection) {
24502
24544
  const unsubscribe = currentDataSource.listenCollection({
24503
24545
  path: currentResolvedPath,
24546
+ pathSegments: currentPathSegments,
24504
24547
  collection: currentCollection,
24505
24548
  onUpdate,
24506
24549
  onError,
@@ -24515,6 +24558,7 @@
24515
24558
  } else {
24516
24559
  currentDataSource.fetchCollection({
24517
24560
  path: currentResolvedPath,
24561
+ pathSegments: currentPathSegments,
24518
24562
  collection: currentCollection,
24519
24563
  searchString: currentSearchString,
24520
24564
  filter: columnFilter,
@@ -24543,6 +24587,7 @@
24543
24587
  const currentColumnProperty = columnPropertyRef.current;
24544
24588
  const currentSearchString = searchStringRef.current;
24545
24589
  const currentResolvedPath = resolvedPathRef.current;
24590
+ const currentPathSegments = resolvedPathSegmentsRef.current;
24546
24591
  const currentColumns = columns;
24547
24592
  const currentColumnItemCounts = columnItemCounts;
24548
24593
  const timeoutId = setTimeout(() => {
@@ -24557,6 +24602,7 @@
24557
24602
  };
24558
24603
  currentDataSource.countEntities({
24559
24604
  path: currentResolvedPath,
24605
+ pathSegments: currentPathSegments,
24560
24606
  collection: currentCollection,
24561
24607
  filter: columnFilter,
24562
24608
  searchString: currentSearchString
@@ -24801,6 +24847,7 @@
24801
24847
  collection,
24802
24848
  tableController,
24803
24849
  fullPath,
24850
+ pathSegments,
24804
24851
  parentCollectionIds = [],
24805
24852
  columnProperty,
24806
24853
  onEntityClick,
@@ -24894,6 +24941,7 @@
24894
24941
  const columns = localColumnsOrder;
24895
24942
  const boardDataController = useBoardDataController({
24896
24943
  fullPath,
24944
+ pathSegments,
24897
24945
  collection,
24898
24946
  columnProperty,
24899
24947
  columns,
@@ -25439,7 +25487,7 @@
25439
25487
  return t0;
25440
25488
  }
25441
25489
  function PopupFormFieldLoading(t0) {
25442
- const $ = reactCompilerRuntime.c(21);
25490
+ const $ = reactCompilerRuntime.c(22);
25443
25491
  const {
25444
25492
  tableKey,
25445
25493
  entityId,
@@ -25447,6 +25495,7 @@
25447
25495
  propertyKey,
25448
25496
  collection: inputCollection,
25449
25497
  path,
25498
+ pathSegments,
25450
25499
  cellRect,
25451
25500
  open,
25452
25501
  onClose,
@@ -25457,33 +25506,35 @@
25457
25506
  const [entity, setEntity] = React.useState(void 0);
25458
25507
  let t1;
25459
25508
  let t2;
25460
- if ($[0] !== dataSource || $[1] !== entityId || $[2] !== inputCollection || $[3] !== path) {
25509
+ if ($[0] !== dataSource || $[1] !== entityId || $[2] !== inputCollection || $[3] !== path || $[4] !== pathSegments) {
25461
25510
  t1 = () => {
25462
25511
  if (entityId && inputCollection) {
25463
25512
  dataSource.fetchEntity({
25464
25513
  path,
25514
+ pathSegments,
25465
25515
  entityId,
25466
25516
  collection: inputCollection
25467
25517
  }).then(setEntity);
25468
25518
  }
25469
25519
  };
25470
- t2 = [entityId, inputCollection, dataSource, path];
25520
+ t2 = [entityId, inputCollection, dataSource, path, pathSegments];
25471
25521
  $[0] = dataSource;
25472
25522
  $[1] = entityId;
25473
25523
  $[2] = inputCollection;
25474
25524
  $[3] = path;
25475
- $[4] = t1;
25476
- $[5] = t2;
25525
+ $[4] = pathSegments;
25526
+ $[5] = t1;
25527
+ $[6] = t2;
25477
25528
  } else {
25478
- t1 = $[4];
25479
- t2 = $[5];
25529
+ t1 = $[5];
25530
+ t2 = $[6];
25480
25531
  }
25481
25532
  React.useEffect(t1, t2);
25482
25533
  if (!entity) {
25483
25534
  return null;
25484
25535
  }
25485
25536
  let t3;
25486
- if ($[6] !== cellRect || $[7] !== container || $[8] !== customFieldValidator || $[9] !== entityId || $[10] !== inputCollection || $[11] !== onCellValueChange || $[12] !== onClose || $[13] !== open || $[14] !== path || $[15] !== propertyKey || $[16] !== tableKey) {
25537
+ if ($[7] !== cellRect || $[8] !== container || $[9] !== customFieldValidator || $[10] !== entityId || $[11] !== inputCollection || $[12] !== onCellValueChange || $[13] !== onClose || $[14] !== open || $[15] !== path || $[16] !== propertyKey || $[17] !== tableKey) {
25487
25538
  t3 = {
25488
25539
  tableKey,
25489
25540
  entityId,
@@ -25497,29 +25548,29 @@
25497
25548
  onCellValueChange,
25498
25549
  container
25499
25550
  };
25500
- $[6] = cellRect;
25501
- $[7] = container;
25502
- $[8] = customFieldValidator;
25503
- $[9] = entityId;
25504
- $[10] = inputCollection;
25505
- $[11] = onCellValueChange;
25506
- $[12] = onClose;
25507
- $[13] = open;
25508
- $[14] = path;
25509
- $[15] = propertyKey;
25510
- $[16] = tableKey;
25511
- $[17] = t3;
25551
+ $[7] = cellRect;
25552
+ $[8] = container;
25553
+ $[9] = customFieldValidator;
25554
+ $[10] = entityId;
25555
+ $[11] = inputCollection;
25556
+ $[12] = onCellValueChange;
25557
+ $[13] = onClose;
25558
+ $[14] = open;
25559
+ $[15] = path;
25560
+ $[16] = propertyKey;
25561
+ $[17] = tableKey;
25562
+ $[18] = t3;
25512
25563
  } else {
25513
- t3 = $[17];
25564
+ t3 = $[18];
25514
25565
  }
25515
25566
  let t4;
25516
- if ($[18] !== entity || $[19] !== t3) {
25567
+ if ($[19] !== entity || $[20] !== t3) {
25517
25568
  t4 = /* @__PURE__ */ jsxRuntime.jsx(PopupFormFieldInternal, { ...t3, entity });
25518
- $[18] = entity;
25519
- $[19] = t3;
25520
- $[20] = t4;
25569
+ $[19] = entity;
25570
+ $[20] = t3;
25571
+ $[21] = t4;
25521
25572
  } else {
25522
- t4 = $[20];
25573
+ t4 = $[21];
25523
25574
  }
25524
25575
  return t4;
25525
25576
  }
@@ -26559,7 +26610,7 @@
26559
26610
  breadcrumbs.updateCount(fullPath, docsCount);
26560
26611
  }
26561
26612
  }, [docsCount, fullPath, breadcrumbs.updateCount]);
26562
- const countFetcher = /* @__PURE__ */ jsxRuntime.jsx(EntitiesCount, { fullPath, collection, filter: tableController.filterValues, sortBy: tableController.sortBy, onCountChange: setDocsCount });
26613
+ const countFetcher = /* @__PURE__ */ jsxRuntime.jsx(EntitiesCount, { fullPath, pathSegments, collection, filter: tableController.filterValues, sortBy: tableController.sortBy, onCountChange: setDocsCount });
26563
26614
  const buildAdditionalHeaderWidget = React.useCallback(({
26564
26615
  property: property_2,
26565
26616
  propertyKey: propertyKey_1,
@@ -26606,7 +26657,7 @@
26606
26657
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("overflow-hidden h-full w-full rounded-md flex flex-col", className), ref: containerRef, children: [
26607
26658
  countFetcher,
26608
26659
  /* @__PURE__ */ jsxRuntime.jsx(CollectionTableToolbar, { loading: tableController.dataLoading, onTextSearch: textSearchEnabled && textSearchInitialised ? tableController.setSearchString : void 0, onTextSearchClick: textSearchEnabled && !textSearchInitialised ? onTextSearchClick : void 0, initialSearchString: tableController.searchString, textSearchLoading, viewModeToggle: viewModeToggleElement, actionsStart: /* @__PURE__ */ jsxRuntime.jsx(EntityCollectionViewStartActions, { parentCollectionIds: parentCollectionIds ?? [], collection, tableController, path: fullPath, relativePath: collection.path, selectionController: usedSelectionController, collectionEntitiesCount: docsCount, resolvedProperties: resolvedCollection.properties }), actions: /* @__PURE__ */ jsxRuntime.jsx(EntityCollectionViewActions, { parentCollectionIds: parentCollectionIds ?? [], collection, tableController, onMultipleDeleteClick, onNewClick, path: fullPath, relativePath: collection.path, selectionController: usedSelectionController, selectionEnabled, collectionEntitiesCount: docsCount }) }),
26609
- tableController.dataLoadingError ? pluginErrorView ?? /* @__PURE__ */ jsxRuntime.jsx(CollectionDataErrorBanner, { error: tableController.dataLoadingError }) : viewMode === "kanban" && enabledViews.includes("kanban") ? /* @__PURE__ */ jsxRuntime.jsx(EntityCollectionBoardView, { collection, tableController, fullPath, parentCollectionIds, columnProperty: selectedKanbanProperty, onEntityClick, selectionController: usedSelectionController, selectionEnabled, highlightedEntities: highlightedEntity ? [highlightedEntity] : [], deletedEntities, emptyComponent: canCreateEntities && tableController.filterValues === void 0 && tableController.sortBy === void 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center", children: [
26660
+ tableController.dataLoadingError ? pluginErrorView ?? /* @__PURE__ */ jsxRuntime.jsx(CollectionDataErrorBanner, { error: tableController.dataLoadingError }) : viewMode === "kanban" && enabledViews.includes("kanban") ? /* @__PURE__ */ jsxRuntime.jsx(EntityCollectionBoardView, { collection, tableController, fullPath, pathSegments, parentCollectionIds, columnProperty: selectedKanbanProperty, onEntityClick, selectionController: usedSelectionController, selectionEnabled, highlightedEntities: highlightedEntity ? [highlightedEntity] : [], deletedEntities, emptyComponent: canCreateEntities && tableController.filterValues === void 0 && tableController.sortBy === void 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center", children: [
26610
26661
  /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "subtitle2", children: t("so_empty") }),
26611
26662
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Button, { onClick: onNewClick, className: "mt-4", children: [
26612
26663
  /* @__PURE__ */ jsxRuntime.jsx(ui.AddIcon, {}),
@@ -26643,7 +26694,7 @@
26643
26694
  });
26644
26695
  }
26645
26696
  } }, `collection_table_${fullPath}`),
26646
- popupCell && /* @__PURE__ */ jsxRuntime.jsx(PopupFormField, { open: Boolean(popupCell), onClose: onPopupClose, cellRect: popupCell?.cellRect, propertyKey: popupCell?.propertyKey, collection, entityId: popupCell.entityId, tableKey: tableKey.current, customFieldValidator: uniqueFieldValidator, path: resolvedFullPath, onCellValueChange: onValueChange, container: containerRef.current }, `popup_form_${popupCell?.propertyKey}_${popupCell?.entityId}`),
26697
+ popupCell && /* @__PURE__ */ jsxRuntime.jsx(PopupFormField, { pathSegments, open: Boolean(popupCell), onClose: onPopupClose, cellRect: popupCell?.cellRect, propertyKey: popupCell?.propertyKey, collection, entityId: popupCell.entityId, tableKey: tableKey.current, customFieldValidator: uniqueFieldValidator, path: resolvedFullPath, onCellValueChange: onValueChange, container: containerRef.current }, `popup_form_${popupCell?.propertyKey}_${popupCell?.entityId}`),
26647
26698
  deleteEntityClicked && /* @__PURE__ */ jsxRuntime.jsx(DeleteEntityDialog, { entityOrEntitiesToDelete: deleteEntityClicked, path: fullPath, collection, callbacks: collection.callbacks, open: Boolean(deleteEntityClicked), onEntityDelete: internalOnEntityDelete, onMultipleEntitiesDelete: internalOnMultipleEntitiesDelete, onClose: () => setDeleteEntityClicked(void 0) })
26648
26699
  ] });
26649
26700
  }, (a, b) => {
@@ -26654,7 +26705,8 @@
26654
26705
  collection,
26655
26706
  filter,
26656
26707
  sortBy,
26657
- onCountChange
26708
+ onCountChange,
26709
+ pathSegments
26658
26710
  }) {
26659
26711
  const dataSource = useDataSource();
26660
26712
  const navigation = useNavigationController();
@@ -26663,15 +26715,17 @@
26663
26715
  const sortByProperty = sortBy ? sortBy[0] : void 0;
26664
26716
  const currentSort = sortBy ? sortBy[1] : void 0;
26665
26717
  const resolvedPath = React.useMemo(() => navigation.resolveIdsFrom(fullPath), [fullPath, navigation.resolveIdsFrom]);
26718
+ const resolvedPathSegments = pathSegments;
26666
26719
  React.useEffect(() => {
26667
26720
  if (dataSource.countEntities) dataSource.countEntities({
26668
26721
  path: resolvedPath,
26722
+ pathSegments: resolvedPathSegments,
26669
26723
  collection,
26670
26724
  filter,
26671
26725
  orderBy: sortByProperty,
26672
26726
  order: currentSort
26673
26727
  }).then(setCount).catch(setError);
26674
- }, [fullPath, dataSource.countEntities, resolvedPath, collection, filter, sortByProperty, currentSort]);
26728
+ }, [fullPath, dataSource.countEntities, resolvedPath, resolvedPathSegments, collection, filter, sortByProperty, currentSort]);
26675
26729
  React.useEffect(() => {
26676
26730
  if (onCountChange && count !== void 0) {
26677
26731
  setError(void 0);
@@ -28459,7 +28513,8 @@
28459
28513
  const {
28460
28514
  path,
28461
28515
  collections = [],
28462
- currentFullPath
28516
+ currentFullPath,
28517
+ currentPathSegments = []
28463
28518
  } = props;
28464
28519
  const subpaths = removeInitialAndTrailingSlashes(path).split("/");
28465
28520
  const subpathCombinations = getCollectionPathsCombinations(subpaths);
@@ -28469,12 +28524,14 @@
28469
28524
  const collection = collections && collections.find((entry) => entry.id === subpathCombination || entry.path === subpathCombination);
28470
28525
  if (collection) {
28471
28526
  const collectionPath = currentFullPath && currentFullPath.length > 0 ? currentFullPath + "/" + collection.path : collection.path;
28527
+ const collectionSegments = [...currentPathSegments, ...collection.path.split("/")];
28472
28528
  const restOfThePath = removeInitialAndTrailingSlashes(removeInitialAndTrailingSlashes(path).replace(subpathCombination, ""));
28473
28529
  const nextSegments = restOfThePath.length > 0 ? restOfThePath.split("/") : [];
28474
28530
  if (nextSegments.length > 0) {
28475
28531
  const entityId = decodeEntityId(nextSegments[0]);
28476
28532
  const fullPath = collectionPath + "/" + entityId;
28477
- result.push(new EntityReference(entityId, collectionPath));
28533
+ const entitySegments = [...collectionSegments, entityId];
28534
+ result.push(new EntityReference(entityId, collectionPath, void 0, collectionSegments));
28478
28535
  if (nextSegments.length > 1) {
28479
28536
  const newPath = nextSegments.slice(1).join("/");
28480
28537
  if (!collection) {
@@ -28484,7 +28541,8 @@
28484
28541
  result.push(...getParentReferencesFromPath({
28485
28542
  path: newPath,
28486
28543
  collections: collection.subcollections,
28487
- currentFullPath: fullPath
28544
+ currentFullPath: fullPath,
28545
+ currentPathSegments: entitySegments
28488
28546
  }));
28489
28547
  }
28490
28548
  }
@@ -30284,7 +30342,7 @@
30284
30342
  const subcollectionId = subcollection.id ?? subcollection.path;
30285
30343
  const newFullPath = usedEntity ? `${path}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollection.path)}` : void 0;
30286
30344
  const newFullIdPath = fullIdPath && usedEntity ? `${fullIdPath}/${encodeEntityId(usedEntity.id)}/${removeInitialAndTrailingSlashes(subcollectionId)}` : void 0;
30287
- const newPathSegments = usedEntity ? [...pathSegments ?? path.split("/"), usedEntity.id, ...removeInitialAndTrailingSlashes(subcollection.path).split("/")] : void 0;
30345
+ const newPathSegments = usedEntity && pathSegments ? [...pathSegments, usedEntity.id, ...removeInitialAndTrailingSlashes(subcollection.path).split("/")] : void 0;
30288
30346
  if (selectedTab !== subcollectionId) return null;
30289
30347
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex-1 h-full overflow-auto w-full", role: "tabpanel", children: [
30290
30348
  globalLoading && /* @__PURE__ */ jsxRuntime.jsx(CircularProgressCenter, {}),
@@ -30307,7 +30365,7 @@
30307
30365
  /* @__PURE__ */ jsxRuntime.jsx(EntityView, { className: "px-8 h-full overflow-auto", entity, path, collection }),
30308
30366
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-16" })
30309
30367
  ] }) }) : null;
30310
- const entityView = /* @__PURE__ */ jsxRuntime.jsx(EntityForm, { fullIdPath, collection, path, entityId: entityId ?? usedEntity?.id, onValuesModified, entity, initialDirtyValues, openEntityMode: layout, forceActionsAtTheBottom: actionsAtTheBottom, initialStatus: status, className: ui.cls((!mainViewVisible || !canEdit) && !selectedSecondaryForm ? "hidden" : "", formProps?.className), EntityFormActionsComponent: EntityEditViewFormActions, disabled: !canEdit, ...formProps, onEntityChange: (entity_0) => {
30368
+ const entityView = /* @__PURE__ */ jsxRuntime.jsx(EntityForm, { fullIdPath, collection, path, pathSegments, entityId: entityId ?? usedEntity?.id, onValuesModified, entity, initialDirtyValues, openEntityMode: layout, forceActionsAtTheBottom: actionsAtTheBottom, initialStatus: status, className: ui.cls((!mainViewVisible || !canEdit) && !selectedSecondaryForm ? "hidden" : "", formProps?.className), EntityFormActionsComponent: EntityEditViewFormActions, disabled: !canEdit, ...formProps, onEntityChange: (entity_0) => {
30311
30369
  setUsedEntity(entity_0);
30312
30370
  formProps?.onEntityChange?.(entity_0);
30313
30371
  }, onStatusChange: (status_0) => {
@@ -31016,11 +31074,14 @@
31016
31074
  */
31017
31075
  deleteEntity: React.useCallback(({
31018
31076
  entity,
31077
+ pathSegments: pathSegments_4,
31019
31078
  collection: collection_4
31020
31079
  }) => {
31021
31080
  const usedDelegate_4 = collection_4?.overrides?.dataSourceDelegate ?? delegate;
31022
31081
  return usedDelegate_4.deleteEntity({
31023
31082
  entity,
31083
+ // Falls back to what the entity carries from the fetch that produced it.
31084
+ pathSegments: pathSegments_4 ?? entity.pathSegments,
31024
31085
  collection: collection_4
31025
31086
  });
31026
31087
  }, [delegate.deleteEntity]),
@@ -31034,16 +31095,17 @@
31034
31095
  * @return `true` if there are no other fields besides the given entity
31035
31096
  * @group Firestore
31036
31097
  */
31037
- checkUniqueField: React.useCallback((path_4, name, value, entityId_2, collection_5) => {
31098
+ checkUniqueField: React.useCallback((path_4, name, value, entityId_2, collection_5, pathSegments_5) => {
31038
31099
  const usedDelegate_5 = collection_5?.overrides?.dataSourceDelegate ?? delegate;
31039
- return usedDelegate_5.checkUniqueField(path_4, name, value, entityId_2, collection_5);
31100
+ return usedDelegate_5.checkUniqueField(path_4, name, value, entityId_2, collection_5, pathSegments_5);
31040
31101
  }, [delegate.checkUniqueField]),
31041
- generateEntityId: React.useCallback((path_5, collection_6) => {
31102
+ generateEntityId: React.useCallback((path_5, collection_6, pathSegments_6) => {
31042
31103
  const usedDelegate_6 = collection_6?.overrides?.dataSourceDelegate ?? delegate;
31043
- return usedDelegate_6.generateEntityId(path_5, collection_6);
31104
+ return usedDelegate_6.generateEntityId(path_5, collection_6, pathSegments_6);
31044
31105
  }, [delegate.generateEntityId]),
31045
31106
  countEntities: delegate.countEntities ? async ({
31046
31107
  path: path_6,
31108
+ pathSegments: pathSegments_7,
31047
31109
  collection: collection_7,
31048
31110
  filter: filter_1,
31049
31111
  order: order_1,
@@ -31052,6 +31114,7 @@
31052
31114
  const usedDelegate_7 = collection_7?.overrides?.dataSourceDelegate ?? delegate;
31053
31115
  return usedDelegate_7.countEntities({
31054
31116
  path: path_6,
31117
+ pathSegments: pathSegments_7,
31055
31118
  filter: filter_1,
31056
31119
  orderBy: orderBy_1,
31057
31120
  order: order_1,
@@ -31060,6 +31123,7 @@
31060
31123
  } : void 0,
31061
31124
  isFilterCombinationValid: React.useCallback(({
31062
31125
  path: path_7,
31126
+ pathSegments: pathSegments_8,
31063
31127
  databaseId,
31064
31128
  filterValues,
31065
31129
  sortBy
@@ -31067,6 +31131,7 @@
31067
31131
  if (!delegate.isFilterCombinationValid) return true;
31068
31132
  return delegate.isFilterCombinationValid({
31069
31133
  path: path_7,
31134
+ pathSegments: pathSegments_8,
31070
31135
  databaseId,
31071
31136
  filterValues,
31072
31137
  sortBy