@mattisvensson/strapi-plugin-webatlas 0.8.1 → 0.8.2

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 (74) hide show
  1. package/dist/_chunks/SettingTitle-BaaQ_99D.mjs +69 -0
  2. package/dist/_chunks/SettingTitle-BaaQ_99D.mjs.map +1 -0
  3. package/dist/_chunks/SettingTitle-D5oNwpzC.js +67 -0
  4. package/dist/_chunks/SettingTitle-DDZxIqee.js +68 -0
  5. package/dist/_chunks/SettingTitle-DDZxIqee.js.map +1 -0
  6. package/dist/_chunks/SettingTitle-IwvX4Kb5.mjs +68 -0
  7. package/dist/_chunks/{de-Dt80IqMG.mjs → de-B9pq-AJZ.mjs} +10 -3
  8. package/dist/_chunks/{de-Dt80IqMG.mjs.map → de-B9pq-AJZ.mjs.map} +1 -1
  9. package/dist/_chunks/{de-CDBoUBzw.js → de-DlQxM8Tg.js} +10 -3
  10. package/dist/_chunks/{de-CDBoUBzw.js.map → de-DlQxM8Tg.js.map} +1 -1
  11. package/dist/_chunks/{en-BHxDiueo.mjs → en-Dmbcf7gp.mjs} +10 -3
  12. package/dist/_chunks/{en-BHxDiueo.mjs.map → en-Dmbcf7gp.mjs.map} +1 -1
  13. package/dist/_chunks/{en-DfvURaup.js → en-DrhxIwOr.js} +10 -3
  14. package/dist/_chunks/{en-DfvURaup.js.map → en-DrhxIwOr.js.map} +1 -1
  15. package/dist/_chunks/{index--oj1eNcM.js → index--XAogZgv.js} +2 -2
  16. package/dist/_chunks/{index--oj1eNcM.js.map → index--XAogZgv.js.map} +1 -1
  17. package/dist/_chunks/{index-BCPgfhBx.js → index-2lVgPz4a.js} +37 -33
  18. package/dist/_chunks/{index-BKdvSgDB.js → index-B1dEY-gs.js} +1 -1
  19. package/dist/_chunks/{index-DUgh4AJb.js → index-B1mbYb2_.js} +94 -53
  20. package/dist/_chunks/{index-CAged_xE.mjs → index-B2tjc_lG.mjs} +2 -2
  21. package/dist/_chunks/{index-CAged_xE.mjs.map → index-B2tjc_lG.mjs.map} +1 -1
  22. package/dist/_chunks/{index-YzPuPn68.js → index-BFuwbmZy.js} +22 -9
  23. package/dist/_chunks/{index-CTA8agp7.mjs → index-D2Meknib.mjs} +10 -8
  24. package/dist/_chunks/{index-D29zBs5w.mjs → index-D2SIGcj3.mjs} +23 -9
  25. package/dist/_chunks/{index-D29zBs5w.mjs.map → index-D2SIGcj3.mjs.map} +1 -1
  26. package/dist/_chunks/{index-D72CZ5b7.js → index-DH0mFrgH.js} +38 -32
  27. package/dist/_chunks/index-DH0mFrgH.js.map +1 -0
  28. package/dist/_chunks/{index-DTPDMxs_.js → index-DKtlnMlv.js} +23 -8
  29. package/dist/_chunks/{index-YzPuPn68.js.map → index-DKtlnMlv.js.map} +1 -1
  30. package/dist/_chunks/{index-Dxn0NT06.js → index-DOMrViWi.js} +11 -8
  31. package/dist/_chunks/index-DOMrViWi.js.map +1 -0
  32. package/dist/_chunks/{index-BBn1ZvsE.mjs → index-DXRtXlZW.mjs} +36 -30
  33. package/dist/_chunks/index-DXRtXlZW.mjs.map +1 -0
  34. package/dist/_chunks/{index-CtFERXkl.js → index-Df365kgY.js} +95 -54
  35. package/dist/_chunks/index-Df365kgY.js.map +1 -0
  36. package/dist/_chunks/{index-CHRBu9Xy.mjs → index-Dm_GIRd4.mjs} +35 -31
  37. package/dist/_chunks/{index-DMpiX4hP.mjs → index-Dt-mlR1F.mjs} +11 -9
  38. package/dist/_chunks/index-Dt-mlR1F.mjs.map +1 -0
  39. package/dist/_chunks/{index-DJBXRNlE.mjs → index-QFbHwlyj.mjs} +94 -53
  40. package/dist/_chunks/index-QFbHwlyj.mjs.map +1 -0
  41. package/dist/_chunks/{index-Nx4IRYIK.mjs → index-QU9SZ_H9.mjs} +93 -52
  42. package/dist/_chunks/{index-CUlRMqGG.mjs → index-_49Fvwqq.mjs} +22 -8
  43. package/dist/_chunks/{index-Rfm9O167.mjs → index-aAKsnALd.mjs} +1 -1
  44. package/dist/_chunks/{index-CbW6k4FH.js → index-g8wz2qoC.js} +9 -8
  45. package/dist/admin/index.js +1 -1
  46. package/dist/admin/index.mjs +1 -1
  47. package/dist/admin/src/pages/Navigation/RouteItem.d.ts +1 -0
  48. package/dist/admin/src/pages/Settings/ContentBox.d.ts +5 -0
  49. package/dist/admin/src/pages/Settings/PageWrapper.d.ts +2 -1
  50. package/dist/admin/src/pages/Settings/SettingTitle.d.ts +4 -0
  51. package/dist/admin/src/pages/Settings/index.d.ts +4 -0
  52. package/dist/pluginId.d.ts +2 -1
  53. package/dist/server/index.js +61 -52
  54. package/dist/server/index.js.map +1 -1
  55. package/dist/server/index.mjs +61 -52
  56. package/dist/server/index.mjs.map +1 -1
  57. package/dist/server/src/utils/index.d.ts +6 -0
  58. package/dist/server/src/utils/navItemHandler.d.ts +1 -1
  59. package/dist/server/src/utils/reduceDepthOfOrphanedItems.d.ts +2 -0
  60. package/package.json +1 -1
  61. package/dist/_chunks/PageWrapper-Bp9vGwpG.js +0 -54
  62. package/dist/_chunks/PageWrapper-BvOY7VCN.mjs +0 -55
  63. package/dist/_chunks/PageWrapper-BzDrMm2d.js +0 -55
  64. package/dist/_chunks/PageWrapper-BzDrMm2d.js.map +0 -1
  65. package/dist/_chunks/PageWrapper-oLhcg9BA.mjs +0 -56
  66. package/dist/_chunks/PageWrapper-oLhcg9BA.mjs.map +0 -1
  67. package/dist/_chunks/index-BCPgfhBx.js.map +0 -1
  68. package/dist/_chunks/index-CHRBu9Xy.mjs.map +0 -1
  69. package/dist/_chunks/index-CbW6k4FH.js.map +0 -1
  70. package/dist/_chunks/index-CtFERXkl.js.map +0 -1
  71. package/dist/_chunks/index-DJBXRNlE.mjs.map +0 -1
  72. package/dist/_chunks/index-DMpiX4hP.mjs.map +0 -1
  73. package/dist/admin/src/components/modals/fields/Visibility.d.ts +0 -5
  74. package/dist/admin/src/components/modals/fields/index.d.ts +0 -2
@@ -19,7 +19,7 @@ function transformToUrl(input) {
19
19
  input = input.replace(/-+/g, "-");
20
20
  return input;
21
21
  }
22
- const version = "0.8.1";
22
+ const version = "0.8.2";
23
23
  const keywords = [];
24
24
  const type = "commonjs";
25
25
  const exports = {
@@ -5495,7 +5495,8 @@ async function createNavItem(data) {
5495
5495
  data: {
5496
5496
  navigation: data.navigation,
5497
5497
  route: data.route || null,
5498
- parent: data.parent || null
5498
+ parent: data.parent || null,
5499
+ order: data.order || 0
5499
5500
  }
5500
5501
  });
5501
5502
  return entity;
@@ -5506,8 +5507,6 @@ async function createNavItem(data) {
5506
5507
  async function updateNavItem(documentId, data) {
5507
5508
  try {
5508
5509
  const updateData = {};
5509
- if (data.navigation !== void 0 && data.navigation !== null && data.navigation !== "") updateData.navigation = data.navigation;
5510
- if (data.route !== void 0 && data.route !== null && data.route !== "") updateData.route = data.route;
5511
5510
  if (data.parent !== void 0) updateData.parent = data.parent;
5512
5511
  if (data.order !== void 0 && typeof data.order === "number") updateData.order = data.order;
5513
5512
  return await strapi.documents(waNavItem).update({
@@ -5528,6 +5527,24 @@ async function deleteNavItem(documentId) {
5528
5527
  console.log(e);
5529
5528
  }
5530
5529
  }
5530
+ function reduceDepthOfOrphanedItems(navigationItems, itemId) {
5531
+ const navigationItemsCopy = JSON.parse(JSON.stringify(navigationItems));
5532
+ const startItemIndex = navigationItemsCopy.findIndex((item) => item.documentId === itemId);
5533
+ if (startItemIndex === -1) return;
5534
+ const startItem = navigationItemsCopy[startItemIndex];
5535
+ for (let i = startItemIndex + 1; i < navigationItemsCopy.length; i++) {
5536
+ const currentItem = navigationItemsCopy[i];
5537
+ if (!currentItem) continue;
5538
+ if (currentItem.depth === 0) break;
5539
+ if (currentItem.depth > startItem.depth) {
5540
+ currentItem.depth = Math.max(0, currentItem.depth - 1);
5541
+ } else {
5542
+ break;
5543
+ }
5544
+ }
5545
+ navigationItemsCopy.splice(startItemIndex, 1);
5546
+ return navigationItemsCopy;
5547
+ }
5531
5548
  async function createExternalRoute(data) {
5532
5549
  try {
5533
5550
  return await strapi.documents(waRoute).create({
@@ -5560,19 +5577,6 @@ const admin = ({ strapi: strapi2 }) => ({
5560
5577
  console.log(err);
5561
5578
  return "Error. Couldn't update config";
5562
5579
  }
5563
- if (newConfigMerged.selectedContentTypes) {
5564
- try {
5565
- const routes2 = await strapi2.documents(waRoute).findMany();
5566
- const invalidRoutes = routes2.filter(
5567
- (route2) => !newConfigMerged.selectedContentTypes.find((type2) => type2.uid === route2.relatedContentType)
5568
- );
5569
- for (const route2 of invalidRoutes) {
5570
- await strapi2.documents(waRoute).delete({ documentId: route2.documentId });
5571
- }
5572
- } catch (err) {
5573
- console.log(err);
5574
- }
5575
- }
5576
5580
  return newConfigMerged;
5577
5581
  },
5578
5582
  async getConfig() {
@@ -5716,31 +5720,28 @@ const admin = ({ strapi: strapi2 }) => ({
5716
5720
  async updateNavigationItemStructure(navigationId, navigationItems) {
5717
5721
  if (!navigationId || !navigationItems) return;
5718
5722
  let error = false;
5719
- let groupIndices = [];
5720
- let parentIds = [];
5721
5723
  const newNavItemsMap = /* @__PURE__ */ new Map();
5722
5724
  for (const [index2, item] of navigationItems.entries()) {
5723
- if (!item.route && item.documentId) {
5724
- try {
5725
- console.warn("Navigation item without route found. Deleting it. ", item);
5726
- await deleteNavItem(item.documentId);
5727
- } catch (error2) {
5728
- console.error("Error deleting navigation item without route ", error2);
5729
- }
5730
- continue;
5731
- }
5732
5725
  if (item.deleted) {
5733
5726
  try {
5734
5727
  item.documentId && await deleteNavItem(item.documentId);
5728
+ const newItems = reduceDepthOfOrphanedItems(navigationItems, item.documentId);
5729
+ if (!newItems) throw new Error("Failed to reduce depth of orphaned items");
5730
+ navigationItems = newItems;
5735
5731
  } catch (error2) {
5736
5732
  error2 = true;
5737
5733
  console.error("Error deleting navigation item ", error2);
5738
5734
  }
5739
5735
  continue;
5740
5736
  }
5741
- if (item.parent?.documentId.startsWith("temp-")) {
5742
- const newItem = newNavItemsMap.get(item.parent.documentId);
5743
- item.isNew.parent = newItem?.documentId;
5737
+ if (!item.route && item.documentId) {
5738
+ try {
5739
+ console.warn("Navigation item without route found. Deleting it. ", item);
5740
+ await deleteNavItem(item.documentId);
5741
+ } catch (error2) {
5742
+ console.error("Error deleting navigation item without route ", error2);
5743
+ }
5744
+ continue;
5744
5745
  }
5745
5746
  if (item.update && !item.isNew) {
5746
5747
  try {
@@ -5755,9 +5756,12 @@ const admin = ({ strapi: strapi2 }) => ({
5755
5756
  console.error("Error updating route ", error2);
5756
5757
  }
5757
5758
  }
5758
- const previousItem = navigationItems[index2 - 1];
5759
+ }
5760
+ let parentIds = [];
5761
+ let groupIndices = [];
5762
+ for (const [index2, item] of navigationItems.entries()) {
5759
5763
  if (typeof item.depth !== "number") {
5760
- return;
5764
+ continue;
5761
5765
  }
5762
5766
  if (item.depth === 0) {
5763
5767
  if (groupIndices[0] !== void 0) {
@@ -5766,25 +5770,34 @@ const admin = ({ strapi: strapi2 }) => ({
5766
5770
  groupIndices[0] = 0;
5767
5771
  }
5768
5772
  parentIds = [];
5769
- } else if (typeof previousItem.depth === "number" && item.depth === previousItem.depth + 1) {
5770
- parentIds.push(previousItem.documentId);
5771
- groupIndices[item.depth] = 0;
5772
- } else if (typeof previousItem.depth === "number" && item.depth <= previousItem.depth) {
5773
- const diff = previousItem.depth - item.depth;
5774
- for (let i = 0; i < diff; i++) {
5775
- parentIds.pop();
5776
- groupIndices.pop();
5773
+ } else {
5774
+ const previousItem = navigationItems[index2 - 1];
5775
+ if (previousItem && typeof previousItem.depth === "number") {
5776
+ if (item.depth === previousItem.depth + 1) {
5777
+ parentIds.push(previousItem.documentId.startsWith("temp-") ? newNavItemsMap.get(previousItem.documentId)?.documentId || previousItem.documentId : previousItem.documentId);
5778
+ groupIndices[item.depth] = 0;
5779
+ } else if (item.depth <= previousItem.depth) {
5780
+ const diff = previousItem.depth - item.depth;
5781
+ for (let i = 0; i < diff; i++) {
5782
+ parentIds.pop();
5783
+ groupIndices.pop();
5784
+ }
5785
+ groupIndices[item.depth] = (groupIndices[item.depth] || 0) + 1;
5786
+ } else {
5787
+ groupIndices[item.depth] = (groupIndices[item.depth] || 0) + 1;
5788
+ }
5777
5789
  }
5778
- groupIndices[item.depth] = (groupIndices[item.depth] || 0) + 1;
5779
5790
  }
5791
+ const calculatedParent = parentIds.at(-1) || null;
5792
+ const calculatedOrder = groupIndices[item.depth] || 0;
5780
5793
  try {
5781
5794
  if (item.isNew) {
5782
5795
  if (item.isNew.route) {
5783
5796
  await createNavItem({
5784
5797
  route: item.isNew.route,
5785
- parent: item.isNew.parent,
5798
+ parent: calculatedParent,
5786
5799
  navigation: item.isNew.navigation,
5787
- order: groupIndices[item.depth]
5800
+ order: calculatedOrder
5788
5801
  });
5789
5802
  } else {
5790
5803
  const newRoute = await createExternalRoute({
@@ -5793,23 +5806,19 @@ const admin = ({ strapi: strapi2 }) => ({
5793
5806
  fullPath: item.route.fullPath,
5794
5807
  wrapper: item.route.wrapper,
5795
5808
  internal: item.route.internal
5796
- // isOverride: item.route.isOverride,
5797
- // active: item.route.active,
5798
5809
  });
5799
5810
  const newNavItem = await createNavItem({
5800
5811
  route: newRoute.documentId,
5801
5812
  navigation: navigationId,
5802
- parent: item.isNew.parent,
5803
- order: groupIndices[item.depth]
5813
+ parent: calculatedParent,
5814
+ order: calculatedOrder
5804
5815
  });
5805
5816
  if (newNavItem) newNavItemsMap.set(item.documentId, newNavItem);
5806
5817
  }
5807
5818
  } else {
5808
5819
  await updateNavItem(item.documentId, {
5809
- navigation: void 0,
5810
- route: void 0,
5811
- order: groupIndices[item.depth] || 0,
5812
- parent: parentIds.at(-1) || null
5820
+ order: calculatedOrder,
5821
+ parent: calculatedParent
5813
5822
  });
5814
5823
  }
5815
5824
  } catch (errorMsg) {