@mattisvensson/strapi-plugin-webatlas 0.5.0 → 0.6.1
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/_chunks/{de-D8LMOTFI.js → de-CL1TIZPg.js} +2 -1
- package/dist/_chunks/{en-BdfmJUs8.js.map → de-CL1TIZPg.js.map} +1 -1
- package/dist/_chunks/{de-BkirTac9.mjs → de-CzVD4dbZ.mjs} +2 -1
- package/dist/_chunks/{de-BkirTac9.mjs.map → de-CzVD4dbZ.mjs.map} +1 -1
- package/dist/_chunks/{en-BdfmJUs8.js → en-Du-Ap60j.js} +2 -1
- package/dist/_chunks/{de-D8LMOTFI.js.map → en-Du-Ap60j.js.map} +1 -1
- package/dist/_chunks/{en-DYbDta3m.mjs → en-Nk6QcTdr.mjs} +2 -1
- package/dist/_chunks/{en-DYbDta3m.mjs.map → en-Nk6QcTdr.mjs.map} +1 -1
- package/dist/_chunks/{index-CJtLrSxU.js → index-B5ji2Qhs.js} +5 -5
- package/dist/_chunks/{index-D4tWVnt1.js → index-BEwslndX.js} +2 -2
- package/dist/_chunks/{index-D4tWVnt1.js.map → index-BEwslndX.js.map} +1 -1
- package/dist/_chunks/{index-BOvKFOKk.js → index-BJHlAfrS.js} +81 -40
- package/dist/_chunks/{index-DTz7wDR7.mjs → index-BKds0CRq.mjs} +1 -1
- package/dist/_chunks/{index-C5ejmUpN.mjs → index-Bfu5AVqu.mjs} +81 -41
- package/dist/_chunks/{index-Ciae_OgQ.js → index-BvqWnL1-.js} +6 -6
- package/dist/_chunks/{index-Ciae_OgQ.js.map → index-BvqWnL1-.js.map} +1 -1
- package/dist/_chunks/{index-LAGFB7iO.mjs → index-C-4C6ezO.mjs} +1 -1
- package/dist/_chunks/{index-CNfpGKSw.mjs → index-C2V-ZFHK.mjs} +82 -40
- package/dist/_chunks/index-C2V-ZFHK.mjs.map +1 -0
- package/dist/_chunks/{index-BAN8PGGJ.js → index-Cp_UPsle.js} +2 -2
- package/dist/_chunks/{index-BAN8PGGJ.js.map → index-Cp_UPsle.js.map} +1 -1
- package/dist/_chunks/{index-CJNR2c7_.js → index-D2CkoDhN.js} +1 -1
- package/dist/_chunks/{index-BfgRvDzx.js → index-DBVU2KOj.js} +1 -1
- package/dist/_chunks/{index-BxnHHgGC.js → index-DCCE7rxt.js} +82 -41
- package/dist/_chunks/index-DCCE7rxt.js.map +1 -0
- package/dist/_chunks/{index-DtFIVZxq.mjs → index-DYKhGn15.mjs} +2 -2
- package/dist/_chunks/{index-DtFIVZxq.mjs.map → index-DYKhGn15.mjs.map} +1 -1
- package/dist/_chunks/{index-Ctq2vsD5.mjs → index-DesLqdi-.mjs} +5 -5
- package/dist/_chunks/{index-CuJP8Fy7.mjs → index-JVvkmiKE.mjs} +6 -6
- package/dist/_chunks/{index-CuJP8Fy7.mjs.map → index-JVvkmiKE.mjs.map} +1 -1
- package/dist/_chunks/{index-CEt9P4TS.mjs → index-mUDowsKQ.mjs} +2 -2
- package/dist/_chunks/{index-CEt9P4TS.mjs.map → index-mUDowsKQ.mjs.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/pages/Navigation/RouteItem.d.ts +1 -0
- package/dist/admin/src/pages/Navigation/SortableRouteItem.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/_chunks/index-BxnHHgGC.js.map +0 -1
- package/dist/_chunks/index-C5ejmUpN.mjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useEffect } from "react";
|
|
3
3
|
import { Thead, Tr, Th, Typography, VisuallyHidden, Td, Flex, LinkButton, Box, Table, Tbody } from "@strapi/design-system";
|
|
4
|
-
import { g as getTranslation, u as useApi } from "./index-
|
|
4
|
+
import { g as getTranslation, u as useApi } from "./index-DesLqdi-.mjs";
|
|
5
5
|
import { Page, Layouts, useNotification } from "@strapi/strapi/admin";
|
|
6
6
|
import { F as FullLoader, C as Center } from "./FullLoader-CrPED_dY.mjs";
|
|
7
7
|
import { E as EmptyBox } from "./EmptyBox-BM4IscSk.mjs";
|
|
@@ -5,7 +5,7 @@ import { Dialog, Typography, Button, Modal, Flex, SingleSelect, SingleSelectOpti
|
|
|
5
5
|
import { useState, useEffect, createContext, useRef, useContext, useReducer, useCallback, useMemo, forwardRef } from "react";
|
|
6
6
|
import { createPortal } from "react-dom";
|
|
7
7
|
import { useIntl } from "react-intl";
|
|
8
|
-
import { u as useApi, g as getTranslation, d as debounce, a as duplicateCheck, t as transformToUrl, U as URLInfo } from "./index-
|
|
8
|
+
import { u as useApi, g as getTranslation, d as debounce, a as duplicateCheck, t as transformToUrl, U as URLInfo } from "./index-JVvkmiKE.mjs";
|
|
9
9
|
import { useFetchClient, useNotification, Page, Layouts } from "@strapi/strapi/admin";
|
|
10
10
|
import { C as Center, F as FullLoader } from "./FullLoader-CrPED_dY.mjs";
|
|
11
11
|
import { E as EmptyBox } from "./EmptyBox-BM4IscSk.mjs";
|
|
@@ -91,12 +91,12 @@ function Delete({ variant, item, onDelete }) {
|
|
|
91
91
|
const { setModalType } = useContext(ModalContext);
|
|
92
92
|
const { formatMessage } = useIntl();
|
|
93
93
|
const { deleteNavigation } = useApi();
|
|
94
|
-
|
|
94
|
+
useNavigate();
|
|
95
95
|
const handleDelete = async () => {
|
|
96
96
|
try {
|
|
97
97
|
if (variant === "NavDelete") {
|
|
98
98
|
await deleteNavigation(item.documentId);
|
|
99
|
-
|
|
99
|
+
onDelete(item);
|
|
100
100
|
} else if (variant === "ItemDelete") {
|
|
101
101
|
const editedItem = { ...item, deleted: true };
|
|
102
102
|
onDelete(editedItem);
|
|
@@ -10568,11 +10568,10 @@ function getProjection(items, activeId, overId, dragOffset) {
|
|
|
10568
10568
|
const activeItem = items[activeItemIndex];
|
|
10569
10569
|
const newItems = arrayMove(items, activeItemIndex, overItemIndex);
|
|
10570
10570
|
const previousItem = newItems[overItemIndex - 1];
|
|
10571
|
-
const nextItem = newItems[overItemIndex + 1];
|
|
10572
10571
|
const dragDepth = getDragDepth(dragOffset, indentationWidth);
|
|
10573
10572
|
const projectedDepth = activeItem && typeof activeItem.depth === "number" ? activeItem.depth + dragDepth : 0;
|
|
10574
|
-
|
|
10575
|
-
|
|
10573
|
+
let maxDepth = getMaxDepth({ previousItem });
|
|
10574
|
+
let minDepth = 0;
|
|
10576
10575
|
let depth = projectedDepth;
|
|
10577
10576
|
if (projectedDepth >= maxDepth) {
|
|
10578
10577
|
depth = maxDepth;
|
|
@@ -10587,12 +10586,6 @@ function getMaxDepth({ previousItem }) {
|
|
|
10587
10586
|
}
|
|
10588
10587
|
return 0;
|
|
10589
10588
|
}
|
|
10590
|
-
function getMinDepth({ nextItem }) {
|
|
10591
|
-
if (nextItem && typeof nextItem.depth === "number") {
|
|
10592
|
-
return nextItem.depth;
|
|
10593
|
-
}
|
|
10594
|
-
return 0;
|
|
10595
|
-
}
|
|
10596
10589
|
function getDragDepth(offset, indentationWidth2) {
|
|
10597
10590
|
return Math.round(offset / indentationWidth2);
|
|
10598
10591
|
}
|
|
@@ -10608,7 +10601,7 @@ function RouteIcon({ type, color = "neutral800" }) {
|
|
|
10608
10601
|
return /* @__PURE__ */ jsx(Box, { width: "16px", height: "16px" });
|
|
10609
10602
|
}
|
|
10610
10603
|
}
|
|
10611
|
-
const RouteItem = forwardRef(({ item, setParentId, setActionItem, ghost, depth, style, wrapperRef, handleProps }, ref) => {
|
|
10604
|
+
const RouteItem = forwardRef(({ item, setParentId, setActionItem, setNavigationItems, ghost, depth, style, wrapperRef, handleProps }, ref) => {
|
|
10612
10605
|
if (!item || !item.route) return null;
|
|
10613
10606
|
const { setModalType } = useContext(ModalContext);
|
|
10614
10607
|
const { formatMessage } = useIntl();
|
|
@@ -10660,6 +10653,17 @@ const RouteItem = forwardRef(({ item, setParentId, setActionItem, ghost, depth,
|
|
|
10660
10653
|
setActionItem(item);
|
|
10661
10654
|
setModalType("ItemDelete");
|
|
10662
10655
|
};
|
|
10656
|
+
const handleRestore = () => {
|
|
10657
|
+
setNavigationItems(
|
|
10658
|
+
(navItems) => navItems?.map((navItem) => {
|
|
10659
|
+
if (navItem.documentId === item.documentId) {
|
|
10660
|
+
delete navItem.update;
|
|
10661
|
+
delete navItem.deleted;
|
|
10662
|
+
}
|
|
10663
|
+
return navItem;
|
|
10664
|
+
})
|
|
10665
|
+
);
|
|
10666
|
+
};
|
|
10663
10667
|
const elStyle = {
|
|
10664
10668
|
marginLeft: depth !== void 0 ? depth * 48 : 0,
|
|
10665
10669
|
opacity: ghost || item.deleted ? 0.5 : 1,
|
|
@@ -10716,18 +10720,24 @@ const RouteItem = forwardRef(({ item, setParentId, setActionItem, ghost, depth,
|
|
|
10716
10720
|
] }),
|
|
10717
10721
|
/* @__PURE__ */ jsxs(Flex, { direction: "row", gap: 4, children: [
|
|
10718
10722
|
type === "internal" && item.status && /* @__PURE__ */ jsx(Status, { variant: itemStatusOptions[item.status].variant, size: "S", children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: itemStatusOptions[item.status].status }) }),
|
|
10719
|
-
/* @__PURE__ */ jsxs(SimpleMenu, { label: "
|
|
10720
|
-
/* @__PURE__ */
|
|
10721
|
-
|
|
10722
|
-
|
|
10723
|
-
|
|
10724
|
-
|
|
10725
|
-
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
10729
|
-
|
|
10730
|
-
|
|
10723
|
+
/* @__PURE__ */ jsxs(SimpleMenu, { label: "Item actions", tag: IconButton, icon: /* @__PURE__ */ jsx(More, {}), children: [
|
|
10724
|
+
!item.deleted && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10725
|
+
/* @__PURE__ */ jsx(MenuItem, { onClick: () => handleEdit(), children: formatMessage({
|
|
10726
|
+
id: getTranslation("edit"),
|
|
10727
|
+
defaultMessage: "Edit"
|
|
10728
|
+
}) }),
|
|
10729
|
+
/* @__PURE__ */ jsx(MenuItem, { onClick: () => handleAddChildren(), children: formatMessage({
|
|
10730
|
+
id: getTranslation("navigation.page.navItem.addChildren"),
|
|
10731
|
+
defaultMessage: "Add children"
|
|
10732
|
+
}) }),
|
|
10733
|
+
/* @__PURE__ */ jsx(MenuItem, { onClick: () => handleDelete(), children: /* @__PURE__ */ jsx(Typography, { textColor: "danger600", children: formatMessage({
|
|
10734
|
+
id: getTranslation("delete"),
|
|
10735
|
+
defaultMessage: "Delete"
|
|
10736
|
+
}) }) })
|
|
10737
|
+
] }),
|
|
10738
|
+
(item.deleted || item.update) && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(MenuItem, { onClick: () => handleRestore(), children: formatMessage({
|
|
10739
|
+
id: getTranslation("restore"),
|
|
10740
|
+
defaultMessage: "Restore"
|
|
10731
10741
|
}) }) })
|
|
10732
10742
|
] })
|
|
10733
10743
|
] })
|
|
@@ -10737,7 +10747,7 @@ const RouteItem = forwardRef(({ item, setParentId, setActionItem, ghost, depth,
|
|
|
10737
10747
|
}
|
|
10738
10748
|
);
|
|
10739
10749
|
});
|
|
10740
|
-
function SortableRouteItem({ item, depth, ...props }) {
|
|
10750
|
+
function SortableRouteItem({ item, depth, setNavigationItems, ...props }) {
|
|
10741
10751
|
if (!item) return null;
|
|
10742
10752
|
const {
|
|
10743
10753
|
isDragging,
|
|
@@ -10756,6 +10766,7 @@ function SortableRouteItem({ item, depth, ...props }) {
|
|
|
10756
10766
|
{
|
|
10757
10767
|
ref: setDraggableNodeRef,
|
|
10758
10768
|
wrapperRef: setDroppableNodeRef,
|
|
10769
|
+
setNavigationItems,
|
|
10759
10770
|
style,
|
|
10760
10771
|
item,
|
|
10761
10772
|
disableInteraction: isSorting,
|
|
@@ -10799,6 +10810,7 @@ function PageWrapper({ navigations, loading = false, children }) {
|
|
|
10799
10810
|
id: getTranslation("navigation.page.selectNavigation"),
|
|
10800
10811
|
defaultMessage: "Select Navigation"
|
|
10801
10812
|
}),
|
|
10813
|
+
selected: true,
|
|
10802
10814
|
onChange: (value) => {
|
|
10803
10815
|
const navItem = navigations.find((nav) => nav.slug === value);
|
|
10804
10816
|
navItem && navigate(`/plugins/webatlas/navigation/${navItem.documentId}`);
|
|
@@ -11800,6 +11812,7 @@ const Navigation = () => {
|
|
|
11800
11812
|
const { getNavigation, updateNavigationItemStructure } = useApi();
|
|
11801
11813
|
const [isSavingNavigation, setIsSavingNavigation] = useState(false);
|
|
11802
11814
|
const [loading, setLoading] = useState(true);
|
|
11815
|
+
const cachedNavigations = useRef(null);
|
|
11803
11816
|
const [projected, setProjected] = useState(null);
|
|
11804
11817
|
const [activeItem, setActiveItem] = useState();
|
|
11805
11818
|
const [activeId, setActiveId] = useState(null);
|
|
@@ -11843,11 +11856,10 @@ const Navigation = () => {
|
|
|
11843
11856
|
}) + ": " + updatedNavigations[0]?.name
|
|
11844
11857
|
});
|
|
11845
11858
|
navigate(`/plugins/webatlas/navigation/${updatedNavigations[0]?.documentId}`);
|
|
11859
|
+
return;
|
|
11846
11860
|
}
|
|
11847
|
-
|
|
11848
|
-
|
|
11849
|
-
setNavigationItems(selectedNav?.items || []);
|
|
11850
|
-
initialNavigationItemsRef.current = cloneDeep$1(selectedNav?.items) || null;
|
|
11861
|
+
cachedNavigations.current = updatedNavigations;
|
|
11862
|
+
switchNavigation(selectedNav, updatedNavigations);
|
|
11851
11863
|
} catch (error) {
|
|
11852
11864
|
console.error("Error fetching navigations: ", error);
|
|
11853
11865
|
toggleNotification({
|
|
@@ -11859,16 +11871,32 @@ const Navigation = () => {
|
|
|
11859
11871
|
});
|
|
11860
11872
|
}
|
|
11861
11873
|
}
|
|
11874
|
+
function switchNavigation(selectedNav, updatedNavigations) {
|
|
11875
|
+
setNavigations(updatedNavigations);
|
|
11876
|
+
setSelectedNavigation(selectedNav);
|
|
11877
|
+
setNavigationItems(selectedNav.items || []);
|
|
11878
|
+
initialNavigationItemsRef.current = cloneDeep$1(selectedNav.items) || null;
|
|
11879
|
+
}
|
|
11862
11880
|
useEffect(() => {
|
|
11863
11881
|
async function fetchNavigations() {
|
|
11864
11882
|
if (!navigationId) {
|
|
11865
|
-
const
|
|
11866
|
-
|
|
11867
|
-
|
|
11868
|
-
|
|
11869
|
-
|
|
11870
|
-
setLoading(false);
|
|
11883
|
+
const navs = await getNavigation({ variant: "namesOnly" });
|
|
11884
|
+
if (navs && navs.length > 0) {
|
|
11885
|
+
navigate(`/plugins/webatlas/navigation/${navs[0].documentId}`);
|
|
11886
|
+
}
|
|
11887
|
+
return;
|
|
11871
11888
|
}
|
|
11889
|
+
if (cachedNavigations.current) {
|
|
11890
|
+
const selectedNav = cachedNavigations.current.find((nav) => nav.documentId === navigationId);
|
|
11891
|
+
if (selectedNav) {
|
|
11892
|
+
switchNavigation(selectedNav, cachedNavigations.current);
|
|
11893
|
+
setLoading(false);
|
|
11894
|
+
return;
|
|
11895
|
+
}
|
|
11896
|
+
}
|
|
11897
|
+
setLoading(true);
|
|
11898
|
+
await loadNavigations();
|
|
11899
|
+
setLoading(false);
|
|
11872
11900
|
}
|
|
11873
11901
|
fetchNavigations();
|
|
11874
11902
|
}, [navigationId]);
|
|
@@ -11922,7 +11950,7 @@ const Navigation = () => {
|
|
|
11922
11950
|
})
|
|
11923
11951
|
});
|
|
11924
11952
|
} finally {
|
|
11925
|
-
loadNavigations();
|
|
11953
|
+
await loadNavigations();
|
|
11926
11954
|
setIsSavingNavigation(false);
|
|
11927
11955
|
}
|
|
11928
11956
|
}
|
|
@@ -11951,7 +11979,16 @@ const Navigation = () => {
|
|
|
11951
11979
|
const activeTreeItem = navigationItems[activeIndex];
|
|
11952
11980
|
navigationItems[activeIndex] = { ...activeTreeItem, depth };
|
|
11953
11981
|
const sortedItems = arrayMove(navigationItems, activeIndex, overIndex);
|
|
11954
|
-
|
|
11982
|
+
const fixedItems = [...sortedItems];
|
|
11983
|
+
fixedItems[0].depth = 0;
|
|
11984
|
+
for (let i = 1; i < fixedItems.length; i++) {
|
|
11985
|
+
const prev = fixedItems[i - 1].depth ?? 0;
|
|
11986
|
+
let curr = fixedItems[i].depth ?? 0;
|
|
11987
|
+
if (curr < 0) curr = 0;
|
|
11988
|
+
if (curr > prev + 1) curr = prev + 1;
|
|
11989
|
+
fixedItems[i].depth = curr;
|
|
11990
|
+
}
|
|
11991
|
+
setNavigationItems(fixedItems);
|
|
11955
11992
|
}
|
|
11956
11993
|
}
|
|
11957
11994
|
function resetState() {
|
|
@@ -12010,6 +12047,7 @@ const Navigation = () => {
|
|
|
12010
12047
|
item,
|
|
12011
12048
|
setParentId,
|
|
12012
12049
|
setActionItem,
|
|
12050
|
+
setNavigationItems,
|
|
12013
12051
|
indentationWidth,
|
|
12014
12052
|
depth: item.id === activeId && projected ? projected.depth : item.depth
|
|
12015
12053
|
},
|
|
@@ -12021,7 +12059,8 @@ const Navigation = () => {
|
|
|
12021
12059
|
{
|
|
12022
12060
|
item: activeItem,
|
|
12023
12061
|
setParentId,
|
|
12024
|
-
setActionItem
|
|
12062
|
+
setActionItem,
|
|
12063
|
+
setNavigationItems
|
|
12025
12064
|
}
|
|
12026
12065
|
) : null }),
|
|
12027
12066
|
document.body
|
|
@@ -12060,7 +12099,9 @@ const Navigation = () => {
|
|
|
12060
12099
|
{
|
|
12061
12100
|
variant: "NavDelete",
|
|
12062
12101
|
item: actionItem,
|
|
12063
|
-
onDelete: () => {
|
|
12102
|
+
onDelete: async () => {
|
|
12103
|
+
cachedNavigations.current = null;
|
|
12104
|
+
navigate("/plugins/webatlas/navigation");
|
|
12064
12105
|
}
|
|
12065
12106
|
}
|
|
12066
12107
|
),
|
|
@@ -12160,3 +12201,4 @@ const App = () => {
|
|
|
12160
12201
|
export {
|
|
12161
12202
|
App as default
|
|
12162
12203
|
};
|
|
12204
|
+
//# sourceMappingURL=index-C2V-ZFHK.mjs.map
|