@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
@@ -0,0 +1,4 @@
1
+ import PageWrapper from "./PageWrapper";
2
+ import ContentBox from "./ContentBox";
3
+ import SettingTitle from "./SettingTitle";
4
+ export { PageWrapper, ContentBox, SettingTitle };
@@ -1,3 +1,4 @@
1
1
  declare const PLUGIN_ID: string;
2
2
  declare const PLUGIN_NAME: string;
3
- export { PLUGIN_ID, PLUGIN_NAME };
3
+ declare const PLUGIN_VERSION: string;
4
+ export { PLUGIN_ID, PLUGIN_NAME, PLUGIN_VERSION };
@@ -20,7 +20,7 @@ function transformToUrl(input) {
20
20
  input = input.replace(/-+/g, "-");
21
21
  return input;
22
22
  }
23
- const version = "0.8.1";
23
+ const version = "0.8.2";
24
24
  const keywords = [];
25
25
  const type = "commonjs";
26
26
  const exports$1 = {
@@ -5496,7 +5496,8 @@ async function createNavItem(data) {
5496
5496
  data: {
5497
5497
  navigation: data.navigation,
5498
5498
  route: data.route || null,
5499
- parent: data.parent || null
5499
+ parent: data.parent || null,
5500
+ order: data.order || 0
5500
5501
  }
5501
5502
  });
5502
5503
  return entity;
@@ -5507,8 +5508,6 @@ async function createNavItem(data) {
5507
5508
  async function updateNavItem(documentId, data) {
5508
5509
  try {
5509
5510
  const updateData = {};
5510
- if (data.navigation !== void 0 && data.navigation !== null && data.navigation !== "") updateData.navigation = data.navigation;
5511
- if (data.route !== void 0 && data.route !== null && data.route !== "") updateData.route = data.route;
5512
5511
  if (data.parent !== void 0) updateData.parent = data.parent;
5513
5512
  if (data.order !== void 0 && typeof data.order === "number") updateData.order = data.order;
5514
5513
  return await strapi.documents(waNavItem).update({
@@ -5529,6 +5528,24 @@ async function deleteNavItem(documentId) {
5529
5528
  console.log(e);
5530
5529
  }
5531
5530
  }
5531
+ function reduceDepthOfOrphanedItems(navigationItems, itemId) {
5532
+ const navigationItemsCopy = JSON.parse(JSON.stringify(navigationItems));
5533
+ const startItemIndex = navigationItemsCopy.findIndex((item) => item.documentId === itemId);
5534
+ if (startItemIndex === -1) return;
5535
+ const startItem = navigationItemsCopy[startItemIndex];
5536
+ for (let i = startItemIndex + 1; i < navigationItemsCopy.length; i++) {
5537
+ const currentItem = navigationItemsCopy[i];
5538
+ if (!currentItem) continue;
5539
+ if (currentItem.depth === 0) break;
5540
+ if (currentItem.depth > startItem.depth) {
5541
+ currentItem.depth = Math.max(0, currentItem.depth - 1);
5542
+ } else {
5543
+ break;
5544
+ }
5545
+ }
5546
+ navigationItemsCopy.splice(startItemIndex, 1);
5547
+ return navigationItemsCopy;
5548
+ }
5532
5549
  async function createExternalRoute(data) {
5533
5550
  try {
5534
5551
  return await strapi.documents(waRoute).create({
@@ -5561,19 +5578,6 @@ const admin = ({ strapi: strapi2 }) => ({
5561
5578
  console.log(err);
5562
5579
  return "Error. Couldn't update config";
5563
5580
  }
5564
- if (newConfigMerged.selectedContentTypes) {
5565
- try {
5566
- const routes2 = await strapi2.documents(waRoute).findMany();
5567
- const invalidRoutes = routes2.filter(
5568
- (route2) => !newConfigMerged.selectedContentTypes.find((type2) => type2.uid === route2.relatedContentType)
5569
- );
5570
- for (const route2 of invalidRoutes) {
5571
- await strapi2.documents(waRoute).delete({ documentId: route2.documentId });
5572
- }
5573
- } catch (err) {
5574
- console.log(err);
5575
- }
5576
- }
5577
5581
  return newConfigMerged;
5578
5582
  },
5579
5583
  async getConfig() {
@@ -5717,31 +5721,28 @@ const admin = ({ strapi: strapi2 }) => ({
5717
5721
  async updateNavigationItemStructure(navigationId, navigationItems) {
5718
5722
  if (!navigationId || !navigationItems) return;
5719
5723
  let error = false;
5720
- let groupIndices = [];
5721
- let parentIds = [];
5722
5724
  const newNavItemsMap = /* @__PURE__ */ new Map();
5723
5725
  for (const [index2, item] of navigationItems.entries()) {
5724
- if (!item.route && item.documentId) {
5725
- try {
5726
- console.warn("Navigation item without route found. Deleting it. ", item);
5727
- await deleteNavItem(item.documentId);
5728
- } catch (error2) {
5729
- console.error("Error deleting navigation item without route ", error2);
5730
- }
5731
- continue;
5732
- }
5733
5726
  if (item.deleted) {
5734
5727
  try {
5735
5728
  item.documentId && await deleteNavItem(item.documentId);
5729
+ const newItems = reduceDepthOfOrphanedItems(navigationItems, item.documentId);
5730
+ if (!newItems) throw new Error("Failed to reduce depth of orphaned items");
5731
+ navigationItems = newItems;
5736
5732
  } catch (error2) {
5737
5733
  error2 = true;
5738
5734
  console.error("Error deleting navigation item ", error2);
5739
5735
  }
5740
5736
  continue;
5741
5737
  }
5742
- if (item.parent?.documentId.startsWith("temp-")) {
5743
- const newItem = newNavItemsMap.get(item.parent.documentId);
5744
- item.isNew.parent = newItem?.documentId;
5738
+ if (!item.route && item.documentId) {
5739
+ try {
5740
+ console.warn("Navigation item without route found. Deleting it. ", item);
5741
+ await deleteNavItem(item.documentId);
5742
+ } catch (error2) {
5743
+ console.error("Error deleting navigation item without route ", error2);
5744
+ }
5745
+ continue;
5745
5746
  }
5746
5747
  if (item.update && !item.isNew) {
5747
5748
  try {
@@ -5756,9 +5757,12 @@ const admin = ({ strapi: strapi2 }) => ({
5756
5757
  console.error("Error updating route ", error2);
5757
5758
  }
5758
5759
  }
5759
- const previousItem = navigationItems[index2 - 1];
5760
+ }
5761
+ let parentIds = [];
5762
+ let groupIndices = [];
5763
+ for (const [index2, item] of navigationItems.entries()) {
5760
5764
  if (typeof item.depth !== "number") {
5761
- return;
5765
+ continue;
5762
5766
  }
5763
5767
  if (item.depth === 0) {
5764
5768
  if (groupIndices[0] !== void 0) {
@@ -5767,25 +5771,34 @@ const admin = ({ strapi: strapi2 }) => ({
5767
5771
  groupIndices[0] = 0;
5768
5772
  }
5769
5773
  parentIds = [];
5770
- } else if (typeof previousItem.depth === "number" && item.depth === previousItem.depth + 1) {
5771
- parentIds.push(previousItem.documentId);
5772
- groupIndices[item.depth] = 0;
5773
- } else if (typeof previousItem.depth === "number" && item.depth <= previousItem.depth) {
5774
- const diff = previousItem.depth - item.depth;
5775
- for (let i = 0; i < diff; i++) {
5776
- parentIds.pop();
5777
- groupIndices.pop();
5774
+ } else {
5775
+ const previousItem = navigationItems[index2 - 1];
5776
+ if (previousItem && typeof previousItem.depth === "number") {
5777
+ if (item.depth === previousItem.depth + 1) {
5778
+ parentIds.push(previousItem.documentId.startsWith("temp-") ? newNavItemsMap.get(previousItem.documentId)?.documentId || previousItem.documentId : previousItem.documentId);
5779
+ groupIndices[item.depth] = 0;
5780
+ } else if (item.depth <= previousItem.depth) {
5781
+ const diff = previousItem.depth - item.depth;
5782
+ for (let i = 0; i < diff; i++) {
5783
+ parentIds.pop();
5784
+ groupIndices.pop();
5785
+ }
5786
+ groupIndices[item.depth] = (groupIndices[item.depth] || 0) + 1;
5787
+ } else {
5788
+ groupIndices[item.depth] = (groupIndices[item.depth] || 0) + 1;
5789
+ }
5778
5790
  }
5779
- groupIndices[item.depth] = (groupIndices[item.depth] || 0) + 1;
5780
5791
  }
5792
+ const calculatedParent = parentIds.at(-1) || null;
5793
+ const calculatedOrder = groupIndices[item.depth] || 0;
5781
5794
  try {
5782
5795
  if (item.isNew) {
5783
5796
  if (item.isNew.route) {
5784
5797
  await createNavItem({
5785
5798
  route: item.isNew.route,
5786
- parent: item.isNew.parent,
5799
+ parent: calculatedParent,
5787
5800
  navigation: item.isNew.navigation,
5788
- order: groupIndices[item.depth]
5801
+ order: calculatedOrder
5789
5802
  });
5790
5803
  } else {
5791
5804
  const newRoute = await createExternalRoute({
@@ -5794,23 +5807,19 @@ const admin = ({ strapi: strapi2 }) => ({
5794
5807
  fullPath: item.route.fullPath,
5795
5808
  wrapper: item.route.wrapper,
5796
5809
  internal: item.route.internal
5797
- // isOverride: item.route.isOverride,
5798
- // active: item.route.active,
5799
5810
  });
5800
5811
  const newNavItem = await createNavItem({
5801
5812
  route: newRoute.documentId,
5802
5813
  navigation: navigationId,
5803
- parent: item.isNew.parent,
5804
- order: groupIndices[item.depth]
5814
+ parent: calculatedParent,
5815
+ order: calculatedOrder
5805
5816
  });
5806
5817
  if (newNavItem) newNavItemsMap.set(item.documentId, newNavItem);
5807
5818
  }
5808
5819
  } else {
5809
5820
  await updateNavItem(item.documentId, {
5810
- navigation: void 0,
5811
- route: void 0,
5812
- order: groupIndices[item.depth] || 0,
5813
- parent: parentIds.at(-1) || null
5821
+ order: calculatedOrder,
5822
+ parent: calculatedParent
5814
5823
  });
5815
5824
  }
5816
5825
  } catch (errorMsg) {