jett.admin.npmpackage 1.0.92 → 1.0.93
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.js +99 -17
- package/dist/index.mjs +99 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -795,31 +795,92 @@ var AppSideBar = ({
|
|
|
795
795
|
const extractUrlFromOnClick = (onClick) => {
|
|
796
796
|
if (!onClick || typeof onClick !== "function") return null;
|
|
797
797
|
const funcString = onClick.toString();
|
|
798
|
-
|
|
798
|
+
let match = funcString.match(/window\.location\.href\s*=\s*`([^`]+)`/);
|
|
799
|
+
if (!match) {
|
|
800
|
+
match = funcString.match(/window\.location\.href\s*=\s*["']([^"']+)["']/);
|
|
801
|
+
}
|
|
799
802
|
if (match && match[1]) {
|
|
800
803
|
try {
|
|
801
804
|
if (match[1].startsWith("http://") || match[1].startsWith("https://")) {
|
|
802
805
|
const url = new URL(match[1]);
|
|
803
|
-
return
|
|
806
|
+
return {
|
|
807
|
+
pathname: url.pathname,
|
|
808
|
+
search: url.search,
|
|
809
|
+
fullPath: url.pathname + url.search
|
|
810
|
+
};
|
|
804
811
|
}
|
|
805
812
|
if (match[1].startsWith("/")) {
|
|
806
813
|
const url = new URL(match[1], window.location.origin);
|
|
807
|
-
return
|
|
814
|
+
return {
|
|
815
|
+
pathname: url.pathname,
|
|
816
|
+
search: url.search,
|
|
817
|
+
fullPath: url.pathname + url.search
|
|
818
|
+
};
|
|
808
819
|
}
|
|
809
820
|
return null;
|
|
810
821
|
} catch {
|
|
811
|
-
const pathMatch = match[1].match(/^([^?]+)
|
|
812
|
-
|
|
822
|
+
const pathMatch = match[1].match(/^([^?]+)(\?.*)?$/);
|
|
823
|
+
if (pathMatch) {
|
|
824
|
+
return {
|
|
825
|
+
pathname: pathMatch[1],
|
|
826
|
+
search: pathMatch[2] || "",
|
|
827
|
+
fullPath: match[1]
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
return null;
|
|
813
831
|
}
|
|
814
832
|
}
|
|
815
833
|
return null;
|
|
816
834
|
};
|
|
817
|
-
const
|
|
818
|
-
if (!
|
|
819
|
-
const
|
|
835
|
+
const currentUrlMatches = (menuUrlData, currentPath, currentSearch) => {
|
|
836
|
+
if (!menuUrlData || !currentPath) return false;
|
|
837
|
+
const normalizedMenuPath = menuUrlData.pathname.replace(/\/$/, "") || "/";
|
|
820
838
|
const normalizedCurrentPath = currentPath.replace(/\/$/, "") || "/";
|
|
821
|
-
if (
|
|
822
|
-
|
|
839
|
+
if (normalizedMenuPath === "/orgselector" && normalizedCurrentPath === "/orgselector") {
|
|
840
|
+
const menuPathParam = new URLSearchParams(menuUrlData.search).get("path");
|
|
841
|
+
const currentPathParam = new URLSearchParams(currentSearch).get("path");
|
|
842
|
+
if (menuPathParam && currentPathParam) {
|
|
843
|
+
return menuPathParam === currentPathParam;
|
|
844
|
+
}
|
|
845
|
+
if (menuPathParam && !currentPathParam) {
|
|
846
|
+
return false;
|
|
847
|
+
}
|
|
848
|
+
if (!menuPathParam && currentPathParam) {
|
|
849
|
+
return false;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
if (normalizedMenuPath === "/users/users" && normalizedCurrentPath === "/users/users") {
|
|
853
|
+
const menuParams = new URLSearchParams(menuUrlData.search);
|
|
854
|
+
const currentParams = new URLSearchParams(currentSearch);
|
|
855
|
+
const menuRole = menuParams.get("role");
|
|
856
|
+
const currentRole = currentParams.get("role");
|
|
857
|
+
if (menuRole && currentRole) {
|
|
858
|
+
return menuRole === currentRole;
|
|
859
|
+
}
|
|
860
|
+
if (menuRole && !currentRole || !menuRole && currentRole) {
|
|
861
|
+
return false;
|
|
862
|
+
}
|
|
863
|
+
return true;
|
|
864
|
+
}
|
|
865
|
+
if (normalizedMenuPath === normalizedCurrentPath) {
|
|
866
|
+
if (menuUrlData.search) {
|
|
867
|
+
const menuParams = new URLSearchParams(menuUrlData.search);
|
|
868
|
+
const currentParams = new URLSearchParams(currentSearch);
|
|
869
|
+
for (const [key, value] of menuParams.entries()) {
|
|
870
|
+
if (key === "auth") {
|
|
871
|
+
continue;
|
|
872
|
+
}
|
|
873
|
+
if (currentParams.get(key) !== value) {
|
|
874
|
+
return false;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
return true;
|
|
878
|
+
}
|
|
879
|
+
return true;
|
|
880
|
+
}
|
|
881
|
+
if (normalizedCurrentPath.startsWith(normalizedMenuPath + "/")) {
|
|
882
|
+
return true;
|
|
883
|
+
}
|
|
823
884
|
return false;
|
|
824
885
|
};
|
|
825
886
|
const navItemsLocal = navItems ?? navItemsConstant;
|
|
@@ -827,27 +888,28 @@ var AppSideBar = ({
|
|
|
827
888
|
const sideBarLogoLocal = sideBarLogo ?? logo_white_default;
|
|
828
889
|
const detectAndSetActiveMenu = (0, import_react12.useCallback)(() => {
|
|
829
890
|
const currentPath = window.location.pathname;
|
|
891
|
+
const currentSearch = window.location.search;
|
|
830
892
|
const newOpenMenus = /* @__PURE__ */ new Set();
|
|
831
893
|
let foundActivePath = null;
|
|
832
894
|
navItemsLocal.forEach((item, index) => {
|
|
833
895
|
if (!item.isDropDown && item.onClick && typeof item.onClick === "function") {
|
|
834
|
-
const
|
|
835
|
-
if (
|
|
896
|
+
const itemUrlData = extractUrlFromOnClick(item.onClick);
|
|
897
|
+
if (itemUrlData && currentUrlMatches(itemUrlData, currentPath, currentSearch)) {
|
|
836
898
|
foundActivePath = `menu-${index}`;
|
|
837
899
|
}
|
|
838
900
|
}
|
|
839
901
|
if (item.options && item.options.length > 0) {
|
|
840
902
|
item.options.forEach((option, optionsIndex) => {
|
|
841
903
|
if (option.onClick && typeof option.onClick === "function") {
|
|
842
|
-
const
|
|
843
|
-
if (
|
|
904
|
+
const optionUrlData = extractUrlFromOnClick(option.onClick);
|
|
905
|
+
if (optionUrlData && currentUrlMatches(optionUrlData, currentPath, currentSearch)) {
|
|
844
906
|
const menuKey = `menu-${index}`;
|
|
845
907
|
newOpenMenus.add(menuKey);
|
|
846
908
|
foundActivePath = `menu-${index}-option-${optionsIndex}`;
|
|
847
909
|
if (option.options && option.options.length > 0) {
|
|
848
910
|
option.options.forEach((subOption, subIndex) => {
|
|
849
|
-
const
|
|
850
|
-
if (
|
|
911
|
+
const subOptionUrlData = extractUrlFromOnClick(subOption.onClick);
|
|
912
|
+
if (subOptionUrlData && currentUrlMatches(subOptionUrlData, currentPath, currentSearch)) {
|
|
851
913
|
const subMenuKey = `menu-${index}-option-${optionsIndex}`;
|
|
852
914
|
newOpenMenus.add(subMenuKey);
|
|
853
915
|
foundActivePath = `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
|
|
@@ -864,18 +926,38 @@ var AppSideBar = ({
|
|
|
864
926
|
setActiveMenuPath(foundActivePath);
|
|
865
927
|
}
|
|
866
928
|
}, [navItemsLocal]);
|
|
929
|
+
const [currentUrl, setCurrentUrl] = (0, import_react12.useState)(
|
|
930
|
+
() => window.location.pathname + window.location.search
|
|
931
|
+
);
|
|
867
932
|
(0, import_react12.useEffect)(() => {
|
|
868
933
|
detectAndSetActiveMenu();
|
|
934
|
+
setCurrentUrl(window.location.pathname + window.location.search);
|
|
869
935
|
}, [detectAndSetActiveMenu]);
|
|
870
936
|
(0, import_react12.useEffect)(() => {
|
|
937
|
+
let lastUrl = window.location.pathname + window.location.search;
|
|
871
938
|
const handleLocationChange = () => {
|
|
872
|
-
|
|
939
|
+
const newUrl = window.location.pathname + window.location.search;
|
|
940
|
+
if (newUrl !== lastUrl) {
|
|
941
|
+
lastUrl = newUrl;
|
|
942
|
+
setCurrentUrl(newUrl);
|
|
943
|
+
detectAndSetActiveMenu();
|
|
944
|
+
}
|
|
873
945
|
};
|
|
874
946
|
window.addEventListener("popstate", handleLocationChange);
|
|
947
|
+
const checkInterval = setInterval(() => {
|
|
948
|
+
const newUrl = window.location.pathname + window.location.search;
|
|
949
|
+
if (newUrl !== lastUrl) {
|
|
950
|
+
handleLocationChange();
|
|
951
|
+
}
|
|
952
|
+
}, 250);
|
|
875
953
|
return () => {
|
|
876
954
|
window.removeEventListener("popstate", handleLocationChange);
|
|
955
|
+
clearInterval(checkInterval);
|
|
877
956
|
};
|
|
878
957
|
}, [detectAndSetActiveMenu]);
|
|
958
|
+
(0, import_react12.useEffect)(() => {
|
|
959
|
+
detectAndSetActiveMenu();
|
|
960
|
+
}, [currentUrl, detectAndSetActiveMenu]);
|
|
879
961
|
const toggleMobileMenu = () => {
|
|
880
962
|
setIsMobileMenuOpen(!isMobileMenuOpen);
|
|
881
963
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -766,31 +766,92 @@ var AppSideBar = ({
|
|
|
766
766
|
const extractUrlFromOnClick = (onClick) => {
|
|
767
767
|
if (!onClick || typeof onClick !== "function") return null;
|
|
768
768
|
const funcString = onClick.toString();
|
|
769
|
-
|
|
769
|
+
let match = funcString.match(/window\.location\.href\s*=\s*`([^`]+)`/);
|
|
770
|
+
if (!match) {
|
|
771
|
+
match = funcString.match(/window\.location\.href\s*=\s*["']([^"']+)["']/);
|
|
772
|
+
}
|
|
770
773
|
if (match && match[1]) {
|
|
771
774
|
try {
|
|
772
775
|
if (match[1].startsWith("http://") || match[1].startsWith("https://")) {
|
|
773
776
|
const url = new URL(match[1]);
|
|
774
|
-
return
|
|
777
|
+
return {
|
|
778
|
+
pathname: url.pathname,
|
|
779
|
+
search: url.search,
|
|
780
|
+
fullPath: url.pathname + url.search
|
|
781
|
+
};
|
|
775
782
|
}
|
|
776
783
|
if (match[1].startsWith("/")) {
|
|
777
784
|
const url = new URL(match[1], window.location.origin);
|
|
778
|
-
return
|
|
785
|
+
return {
|
|
786
|
+
pathname: url.pathname,
|
|
787
|
+
search: url.search,
|
|
788
|
+
fullPath: url.pathname + url.search
|
|
789
|
+
};
|
|
779
790
|
}
|
|
780
791
|
return null;
|
|
781
792
|
} catch {
|
|
782
|
-
const pathMatch = match[1].match(/^([^?]+)
|
|
783
|
-
|
|
793
|
+
const pathMatch = match[1].match(/^([^?]+)(\?.*)?$/);
|
|
794
|
+
if (pathMatch) {
|
|
795
|
+
return {
|
|
796
|
+
pathname: pathMatch[1],
|
|
797
|
+
search: pathMatch[2] || "",
|
|
798
|
+
fullPath: match[1]
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
return null;
|
|
784
802
|
}
|
|
785
803
|
}
|
|
786
804
|
return null;
|
|
787
805
|
};
|
|
788
|
-
const
|
|
789
|
-
if (!
|
|
790
|
-
const
|
|
806
|
+
const currentUrlMatches = (menuUrlData, currentPath, currentSearch) => {
|
|
807
|
+
if (!menuUrlData || !currentPath) return false;
|
|
808
|
+
const normalizedMenuPath = menuUrlData.pathname.replace(/\/$/, "") || "/";
|
|
791
809
|
const normalizedCurrentPath = currentPath.replace(/\/$/, "") || "/";
|
|
792
|
-
if (
|
|
793
|
-
|
|
810
|
+
if (normalizedMenuPath === "/orgselector" && normalizedCurrentPath === "/orgselector") {
|
|
811
|
+
const menuPathParam = new URLSearchParams(menuUrlData.search).get("path");
|
|
812
|
+
const currentPathParam = new URLSearchParams(currentSearch).get("path");
|
|
813
|
+
if (menuPathParam && currentPathParam) {
|
|
814
|
+
return menuPathParam === currentPathParam;
|
|
815
|
+
}
|
|
816
|
+
if (menuPathParam && !currentPathParam) {
|
|
817
|
+
return false;
|
|
818
|
+
}
|
|
819
|
+
if (!menuPathParam && currentPathParam) {
|
|
820
|
+
return false;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
if (normalizedMenuPath === "/users/users" && normalizedCurrentPath === "/users/users") {
|
|
824
|
+
const menuParams = new URLSearchParams(menuUrlData.search);
|
|
825
|
+
const currentParams = new URLSearchParams(currentSearch);
|
|
826
|
+
const menuRole = menuParams.get("role");
|
|
827
|
+
const currentRole = currentParams.get("role");
|
|
828
|
+
if (menuRole && currentRole) {
|
|
829
|
+
return menuRole === currentRole;
|
|
830
|
+
}
|
|
831
|
+
if (menuRole && !currentRole || !menuRole && currentRole) {
|
|
832
|
+
return false;
|
|
833
|
+
}
|
|
834
|
+
return true;
|
|
835
|
+
}
|
|
836
|
+
if (normalizedMenuPath === normalizedCurrentPath) {
|
|
837
|
+
if (menuUrlData.search) {
|
|
838
|
+
const menuParams = new URLSearchParams(menuUrlData.search);
|
|
839
|
+
const currentParams = new URLSearchParams(currentSearch);
|
|
840
|
+
for (const [key, value] of menuParams.entries()) {
|
|
841
|
+
if (key === "auth") {
|
|
842
|
+
continue;
|
|
843
|
+
}
|
|
844
|
+
if (currentParams.get(key) !== value) {
|
|
845
|
+
return false;
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
return true;
|
|
849
|
+
}
|
|
850
|
+
return true;
|
|
851
|
+
}
|
|
852
|
+
if (normalizedCurrentPath.startsWith(normalizedMenuPath + "/")) {
|
|
853
|
+
return true;
|
|
854
|
+
}
|
|
794
855
|
return false;
|
|
795
856
|
};
|
|
796
857
|
const navItemsLocal = navItems ?? navItemsConstant;
|
|
@@ -798,27 +859,28 @@ var AppSideBar = ({
|
|
|
798
859
|
const sideBarLogoLocal = sideBarLogo ?? logo_white_default;
|
|
799
860
|
const detectAndSetActiveMenu = useCallback(() => {
|
|
800
861
|
const currentPath = window.location.pathname;
|
|
862
|
+
const currentSearch = window.location.search;
|
|
801
863
|
const newOpenMenus = /* @__PURE__ */ new Set();
|
|
802
864
|
let foundActivePath = null;
|
|
803
865
|
navItemsLocal.forEach((item, index) => {
|
|
804
866
|
if (!item.isDropDown && item.onClick && typeof item.onClick === "function") {
|
|
805
|
-
const
|
|
806
|
-
if (
|
|
867
|
+
const itemUrlData = extractUrlFromOnClick(item.onClick);
|
|
868
|
+
if (itemUrlData && currentUrlMatches(itemUrlData, currentPath, currentSearch)) {
|
|
807
869
|
foundActivePath = `menu-${index}`;
|
|
808
870
|
}
|
|
809
871
|
}
|
|
810
872
|
if (item.options && item.options.length > 0) {
|
|
811
873
|
item.options.forEach((option, optionsIndex) => {
|
|
812
874
|
if (option.onClick && typeof option.onClick === "function") {
|
|
813
|
-
const
|
|
814
|
-
if (
|
|
875
|
+
const optionUrlData = extractUrlFromOnClick(option.onClick);
|
|
876
|
+
if (optionUrlData && currentUrlMatches(optionUrlData, currentPath, currentSearch)) {
|
|
815
877
|
const menuKey = `menu-${index}`;
|
|
816
878
|
newOpenMenus.add(menuKey);
|
|
817
879
|
foundActivePath = `menu-${index}-option-${optionsIndex}`;
|
|
818
880
|
if (option.options && option.options.length > 0) {
|
|
819
881
|
option.options.forEach((subOption, subIndex) => {
|
|
820
|
-
const
|
|
821
|
-
if (
|
|
882
|
+
const subOptionUrlData = extractUrlFromOnClick(subOption.onClick);
|
|
883
|
+
if (subOptionUrlData && currentUrlMatches(subOptionUrlData, currentPath, currentSearch)) {
|
|
822
884
|
const subMenuKey = `menu-${index}-option-${optionsIndex}`;
|
|
823
885
|
newOpenMenus.add(subMenuKey);
|
|
824
886
|
foundActivePath = `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
|
|
@@ -835,18 +897,38 @@ var AppSideBar = ({
|
|
|
835
897
|
setActiveMenuPath(foundActivePath);
|
|
836
898
|
}
|
|
837
899
|
}, [navItemsLocal]);
|
|
900
|
+
const [currentUrl, setCurrentUrl] = useState3(
|
|
901
|
+
() => window.location.pathname + window.location.search
|
|
902
|
+
);
|
|
838
903
|
useEffect(() => {
|
|
839
904
|
detectAndSetActiveMenu();
|
|
905
|
+
setCurrentUrl(window.location.pathname + window.location.search);
|
|
840
906
|
}, [detectAndSetActiveMenu]);
|
|
841
907
|
useEffect(() => {
|
|
908
|
+
let lastUrl = window.location.pathname + window.location.search;
|
|
842
909
|
const handleLocationChange = () => {
|
|
843
|
-
|
|
910
|
+
const newUrl = window.location.pathname + window.location.search;
|
|
911
|
+
if (newUrl !== lastUrl) {
|
|
912
|
+
lastUrl = newUrl;
|
|
913
|
+
setCurrentUrl(newUrl);
|
|
914
|
+
detectAndSetActiveMenu();
|
|
915
|
+
}
|
|
844
916
|
};
|
|
845
917
|
window.addEventListener("popstate", handleLocationChange);
|
|
918
|
+
const checkInterval = setInterval(() => {
|
|
919
|
+
const newUrl = window.location.pathname + window.location.search;
|
|
920
|
+
if (newUrl !== lastUrl) {
|
|
921
|
+
handleLocationChange();
|
|
922
|
+
}
|
|
923
|
+
}, 250);
|
|
846
924
|
return () => {
|
|
847
925
|
window.removeEventListener("popstate", handleLocationChange);
|
|
926
|
+
clearInterval(checkInterval);
|
|
848
927
|
};
|
|
849
928
|
}, [detectAndSetActiveMenu]);
|
|
929
|
+
useEffect(() => {
|
|
930
|
+
detectAndSetActiveMenu();
|
|
931
|
+
}, [currentUrl, detectAndSetActiveMenu]);
|
|
850
932
|
const toggleMobileMenu = () => {
|
|
851
933
|
setIsMobileMenuOpen(!isMobileMenuOpen);
|
|
852
934
|
};
|