@telia/teddy 0.7.14 → 0.7.15
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/components/navigation-menu/global-navigation/global-navigation-root.d.ts +4 -2
- package/dist/components/navigation-menu/global-navigation/utils.cjs +14 -1
- package/dist/components/navigation-menu/global-navigation/utils.d.ts +785 -3
- package/dist/components/navigation-menu/global-navigation/utils.js +14 -1
- package/dist/components/radio-card-group/radio-card-group-item-title.cjs +160 -159
- package/dist/components/radio-card-group/radio-card-group-item-title.js +161 -160
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import React__default, { useEffect } from "react";
|
|
3
3
|
import clsx from "clsx";
|
|
4
|
-
import { MY_PAGE_RETAILER_LINKS, MY_PAGE_LINKS, LOGGED_IN_LINKS_BUSINESS,
|
|
4
|
+
import { MY_PAGE_RETAILER_LINKS, MY_PAGE_LINKS, LOGGED_IN_LINKS_BUSINESS, getLinks, getActiveSubLink, DEFAULT_PRIVATE_LINKS, DEFAULT_BUSINESS_LINKS, DEFAULT_MDU_LINKS } from "../navigation-menu/global-navigation/utils.js";
|
|
5
5
|
import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
|
|
6
6
|
import { useComposedRefs } from "../../utils/composeRefs.js";
|
|
7
7
|
import { VisuallyHidden } from "../visually-hidden/visually-hidden.js";
|
|
@@ -760,23 +760,20 @@ ShoppingCart.displayName = "ShoppingCart";
|
|
|
760
760
|
const Desktop = React__default.forwardRef(() => {
|
|
761
761
|
const rootContext = React__default.useContext(RootContext);
|
|
762
762
|
const [showMenu, setShowMenu] = React__default.useState(false);
|
|
763
|
+
const [isClientSide, setIsClientSide] = React__default.useState(false);
|
|
763
764
|
const topMenuRef = React__default.useRef(null);
|
|
764
|
-
const shouldShowViewport = [
|
|
765
|
-
...PRIVATE_LINKS.links,
|
|
766
|
-
...BUSINESS_LINKS.links,
|
|
767
|
-
...BUSINESS_UKKO_LINKS.links,
|
|
768
|
-
...MDU_LINKS.links
|
|
769
|
-
].some((link) => {
|
|
770
|
-
const sameParent = link.link.split("/")[1] === (rootContext == null ? void 0 : rootContext.pathname.split("/")[1]) || !link.link && (rootContext == null ? void 0 : rootContext.pathname) === "/";
|
|
771
|
-
return link.links.length && link.name === (rootContext == null ? void 0 : rootContext.specifiedLink) && sameParent;
|
|
772
|
-
});
|
|
773
765
|
const topMenuSize = useSize(topMenuRef.current);
|
|
774
|
-
const topMenuHeight = (topMenuSize == null ? void 0 : topMenuSize.height) ? `${topMenuSize.height}px` : void 0;
|
|
775
|
-
const [isClientSide, setIsClientSide] = React__default.useState(false);
|
|
776
766
|
React__default.useEffect(() => {
|
|
777
767
|
setIsClientSide(true);
|
|
778
768
|
}, []);
|
|
779
769
|
if (!rootContext) return null;
|
|
770
|
+
const links = getLinks(rootContext.pathname.includes("bedrift/utstyrsavtale"), rootContext.customLinks);
|
|
771
|
+
const shouldShowViewport = links.flatMap((link) => link.links || []).some((link) => {
|
|
772
|
+
var _a;
|
|
773
|
+
const sameParent = link.link.split("/")[1] === (rootContext == null ? void 0 : rootContext.pathname.split("/")[1]) || !link.link && (rootContext == null ? void 0 : rootContext.pathname) === "/";
|
|
774
|
+
return (((_a = link.links) == null ? void 0 : _a.length) || 0) > 0 && link.name === (rootContext == null ? void 0 : rootContext.specifiedLink) && sameParent;
|
|
775
|
+
});
|
|
776
|
+
const topMenuHeight = (topMenuSize == null ? void 0 : topMenuSize.height) ? `${topMenuSize.height}px` : void 0;
|
|
780
777
|
const { selectedMenuItem, setSelectedMenuItem, linkComponent: Link2, specifiedLink, setSpecifiedLink } = rootContext;
|
|
781
778
|
const currentLocation = rootContext.pathname.endsWith("/") ? rootContext.pathname : `${rootContext.pathname}/`;
|
|
782
779
|
const handleInteractions = (linkName) => {
|
|
@@ -791,7 +788,7 @@ const Desktop = React__default.forwardRef(() => {
|
|
|
791
788
|
style: mergeStyles({ ["--teddy-top-menu-height"]: topMenuHeight }),
|
|
792
789
|
className: styles[`${rootClassName}__top-menu-wrapper`],
|
|
793
790
|
children: /* @__PURE__ */ jsxs(NavigationMenu.TopMenuList, { ref: topMenuRef, children: [
|
|
794
|
-
|
|
791
|
+
links.map((link) => /* @__PURE__ */ jsx(NavigationMenu.TopMenuItem, { children: /* @__PURE__ */ jsx(
|
|
795
792
|
NavigationMenu.TopMenuTrigger,
|
|
796
793
|
{
|
|
797
794
|
value: link.name,
|
|
@@ -810,117 +807,114 @@ const Desktop = React__default.forwardRef(() => {
|
|
|
810
807
|
] })
|
|
811
808
|
}
|
|
812
809
|
) }),
|
|
813
|
-
|
|
810
|
+
links.map((link) => {
|
|
814
811
|
var _a;
|
|
815
812
|
return /* @__PURE__ */ jsx(NavigationMenu.List, { value: link.name, children: (_a = link.links) == null ? void 0 : _a.map(
|
|
816
|
-
(subLink) =>
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
"
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
"
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
813
|
+
(subLink) => /* @__PURE__ */ jsxs(
|
|
814
|
+
NavigationMenu.Item,
|
|
815
|
+
{
|
|
816
|
+
value: subLink.name,
|
|
817
|
+
onMouseEnter: () => setShowMenu(true),
|
|
818
|
+
onMouseLeave: () => setShowMenu(false),
|
|
819
|
+
children: [
|
|
820
|
+
subLink.name === "Logo" ? /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(
|
|
821
|
+
Link2,
|
|
822
|
+
{
|
|
823
|
+
href: subLink.link,
|
|
824
|
+
onMouseEnter: () => handleInteractions(),
|
|
825
|
+
onClick: () => handleInteractions(),
|
|
826
|
+
children: /* @__PURE__ */ jsx(
|
|
827
|
+
"img",
|
|
828
|
+
{
|
|
829
|
+
src: "https://www.telia.no/globalassets/static/svg/telia-primary-default-v2.svg",
|
|
830
|
+
draggable: "false",
|
|
831
|
+
alt: "Telia logo"
|
|
832
|
+
}
|
|
833
|
+
)
|
|
834
|
+
}
|
|
835
|
+
) : /* @__PURE__ */ jsx(
|
|
836
|
+
"a",
|
|
837
|
+
{
|
|
838
|
+
href: subLink.link,
|
|
839
|
+
onMouseEnter: () => handleInteractions(),
|
|
840
|
+
onClick: () => handleInteractions(),
|
|
841
|
+
children: /* @__PURE__ */ jsx(
|
|
842
|
+
"img",
|
|
843
|
+
{
|
|
844
|
+
src: "https://www.telia.no/globalassets/static/svg/telia-primary-default-v2.svg",
|
|
845
|
+
draggable: "false",
|
|
846
|
+
alt: "Telia logo"
|
|
847
|
+
}
|
|
848
|
+
)
|
|
849
|
+
}
|
|
850
|
+
) }) : /* @__PURE__ */ jsx(
|
|
851
|
+
NavigationMenu.Link,
|
|
852
|
+
{
|
|
853
|
+
asChild: true,
|
|
854
|
+
active: selectedMenuItem === subLink.name && currentLocation === subLink.link,
|
|
855
|
+
onFocus: () => {
|
|
856
|
+
handleInteractions(subLink.name);
|
|
857
|
+
setShowMenu(true);
|
|
858
|
+
},
|
|
859
|
+
children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(
|
|
860
|
+
Link2,
|
|
861
|
+
{
|
|
862
|
+
onMouseEnter: () => handleInteractions(subLink.name),
|
|
863
|
+
onClick: () => {
|
|
864
|
+
handleInteractions(subLink.name);
|
|
865
|
+
setShowMenu(false);
|
|
866
|
+
},
|
|
867
|
+
href: subLink.link,
|
|
868
|
+
children: subLink.name
|
|
869
|
+
}
|
|
870
|
+
) : /* @__PURE__ */ jsx(
|
|
871
|
+
"a",
|
|
872
|
+
{
|
|
873
|
+
onMouseEnter: () => handleInteractions(subLink.name),
|
|
874
|
+
onClick: () => {
|
|
875
|
+
handleInteractions(subLink.name);
|
|
876
|
+
setShowMenu(false);
|
|
877
|
+
},
|
|
878
|
+
onFocus: () => {
|
|
879
|
+
setShowMenu(true);
|
|
880
|
+
},
|
|
881
|
+
href: subLink.link,
|
|
882
|
+
children: subLink.name
|
|
883
|
+
}
|
|
884
|
+
)
|
|
885
|
+
}
|
|
886
|
+
),
|
|
887
|
+
/* @__PURE__ */ jsx(
|
|
888
|
+
"div",
|
|
889
|
+
{
|
|
890
|
+
style: mergeStyles({ ["--teddy-viewport-wrapper-height"]: viewPortHeight }),
|
|
891
|
+
className: styles[`${rootClassName}__viewport-wrapper`],
|
|
892
|
+
"data-state": showMenu ? "open" : "closed",
|
|
893
|
+
children: isClientSide && /* @__PURE__ */ jsx(NavigationMenu.Content, { children: !!specifiedLink && subLink.name === specifiedLink && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
894
|
+
subLink.links && subLink.links.length > 0 && /* @__PURE__ */ jsx(
|
|
895
|
+
HightlightedLinksDesktop,
|
|
866
896
|
{
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
setShowMenu(false);
|
|
871
|
-
},
|
|
872
|
-
href: subLink.link,
|
|
873
|
-
children: subLink.name
|
|
897
|
+
listName: subLink.name,
|
|
898
|
+
setShowMenu,
|
|
899
|
+
links: subLink.links
|
|
874
900
|
}
|
|
875
|
-
)
|
|
876
|
-
|
|
901
|
+
),
|
|
902
|
+
subLink.highlightedLinks && subLink.highlightedLinks.length > 0 && /* @__PURE__ */ jsx(
|
|
903
|
+
HightlightedLinksDesktop,
|
|
877
904
|
{
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
},
|
|
883
|
-
onFocus: () => {
|
|
884
|
-
setShowMenu(true);
|
|
885
|
-
},
|
|
886
|
-
href: subLink.link,
|
|
887
|
-
children: subLink.name
|
|
905
|
+
colored: true,
|
|
906
|
+
listName: "Nyttige snarveier",
|
|
907
|
+
setShowMenu,
|
|
908
|
+
links: subLink.highlightedLinks
|
|
888
909
|
}
|
|
889
910
|
)
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
"data-state": showMenu ? "open" : "closed",
|
|
898
|
-
children: isClientSide && /* @__PURE__ */ jsx(NavigationMenu.Content, { children: !!specifiedLink && subLink.name === specifiedLink && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
899
|
-
((_a2 = subLink.links) == null ? void 0 : _a2.length) > 0 && /* @__PURE__ */ jsx(
|
|
900
|
-
HightlightedLinksDesktop,
|
|
901
|
-
{
|
|
902
|
-
listName: subLink.name,
|
|
903
|
-
setShowMenu,
|
|
904
|
-
links: subLink.links
|
|
905
|
-
}
|
|
906
|
-
),
|
|
907
|
-
((_b = subLink.highlightedLinks) == null ? void 0 : _b.length) > 0 && /* @__PURE__ */ jsx(
|
|
908
|
-
HightlightedLinksDesktop,
|
|
909
|
-
{
|
|
910
|
-
colored: true,
|
|
911
|
-
listName: "Nyttige snarveier",
|
|
912
|
-
setShowMenu,
|
|
913
|
-
links: subLink.highlightedLinks
|
|
914
|
-
}
|
|
915
|
-
)
|
|
916
|
-
] }) })
|
|
917
|
-
}
|
|
918
|
-
)
|
|
919
|
-
]
|
|
920
|
-
},
|
|
921
|
-
subLink.name
|
|
922
|
-
);
|
|
923
|
-
}
|
|
911
|
+
] }) })
|
|
912
|
+
}
|
|
913
|
+
)
|
|
914
|
+
]
|
|
915
|
+
},
|
|
916
|
+
subLink.name
|
|
917
|
+
)
|
|
924
918
|
) }, link.name);
|
|
925
919
|
})
|
|
926
920
|
] });
|
|
@@ -990,6 +984,7 @@ function Mobile(props) {
|
|
|
990
984
|
const rootContext = React__default.useContext(RootContext);
|
|
991
985
|
const drawerRef = React__default.useRef(null);
|
|
992
986
|
if (!rootContext) return null;
|
|
987
|
+
const links = getLinks(rootContext.pathname.includes("bedrift/utstyrsavtale"), rootContext.customLinks);
|
|
993
988
|
const { linkComponent: NavLink } = rootContext;
|
|
994
989
|
const classes = clsx([styles[`${rootClassName}__mobile`]], props.className);
|
|
995
990
|
const linkClasses = clsx([styles[`${rootClassName}__link`]]);
|
|
@@ -1023,12 +1018,12 @@ function Mobile(props) {
|
|
|
1023
1018
|
value: rootContext.selectedDomainItem,
|
|
1024
1019
|
onValueChange: (v) => rootContext.setSelectedDomainItem(v, true),
|
|
1025
1020
|
children: [
|
|
1026
|
-
/* @__PURE__ */ jsx(Tabs.List, { children:
|
|
1027
|
-
/* @__PURE__ */ jsx(Fragment, { children:
|
|
1021
|
+
/* @__PURE__ */ jsx(Tabs.List, { children: links.map((link) => /* @__PURE__ */ jsx(Tabs.Trigger, { asChild: true, value: link.name, children: link.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(NavLink, { href: link.link, children: link.name }) : /* @__PURE__ */ jsx("a", { href: link.link, children: link.name }) }, link.name)) }),
|
|
1022
|
+
/* @__PURE__ */ jsx(Fragment, { children: links.map((link) => {
|
|
1028
1023
|
var _a, _b;
|
|
1029
1024
|
return /* @__PURE__ */ jsxs(Tabs.Content, { value: link.name, children: [
|
|
1030
1025
|
/* @__PURE__ */ jsx(Box, { mt: "400", children: (_a = link.links) == null ? void 0 : _a.filter((l) => l.name !== "Logo").map(
|
|
1031
|
-
(subLink) => subLink.links.length > 0 ? /* @__PURE__ */ jsxs(Box, { onClick: () => setSpecifiedLink(subLink.name), className: linkClasses, children: [
|
|
1026
|
+
(subLink) => subLink.links && subLink.links.length > 0 ? /* @__PURE__ */ jsxs(Box, { onClick: () => setSpecifiedLink(subLink.name), className: linkClasses, children: [
|
|
1032
1027
|
/* @__PURE__ */ jsx(Heading, { asChild: true, variant: "title-300", children: /* @__PURE__ */ jsx(Button, { className: styles[`${rootClassName}__sublink-button--mobile`], children: subLink.name }) }),
|
|
1033
1028
|
/* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: "md" })
|
|
1034
1029
|
] }) : /* @__PURE__ */ jsx(Fragment, { children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsxs(NavLink, { href: subLink.link, className: linkClasses, children: [
|
|
@@ -1039,7 +1034,7 @@ function Mobile(props) {
|
|
|
1039
1034
|
/* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: "md" })
|
|
1040
1035
|
] }) })
|
|
1041
1036
|
) }),
|
|
1042
|
-
((_b = link.highlightedLinks) == null ? void 0 : _b.length) > 0 && /* @__PURE__ */ jsx(Box, { className: styles[`${rootClassName}__colored-box--mobile`], children: /* @__PURE__ */ jsx(Box, { mt: "400", pt: "250", pb: "250", pl: "300", children: /* @__PURE__ */ jsx(
|
|
1037
|
+
link.highlightedLinks && ((_b = link.highlightedLinks) == null ? void 0 : _b.length) > 0 && /* @__PURE__ */ jsx(Box, { className: styles[`${rootClassName}__colored-box--mobile`], children: /* @__PURE__ */ jsx(Box, { mt: "400", pt: "250", pb: "250", pl: "300", children: /* @__PURE__ */ jsx(
|
|
1043
1038
|
HighlightedLinks,
|
|
1044
1039
|
{
|
|
1045
1040
|
item: link,
|
|
@@ -1058,33 +1053,30 @@ function Mobile(props) {
|
|
|
1058
1053
|
/* @__PURE__ */ jsx(Icon, { name: "arrow-left" }),
|
|
1059
1054
|
"Tilbake"
|
|
1060
1055
|
] }) }),
|
|
1061
|
-
/* @__PURE__ */ jsx(Box, { mt: "100", children:
|
|
1056
|
+
/* @__PURE__ */ jsx(Box, { mt: "100", children: links.filter((item) => item.name === rootContext.selectedDomainItem).map(
|
|
1062
1057
|
(link) => {
|
|
1063
1058
|
var _a;
|
|
1064
1059
|
return (_a = link.links) == null ? void 0 : _a.filter((l) => l.name !== "Logo").map(
|
|
1065
|
-
(subLink) => {
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
) }) })
|
|
1086
|
-
] });
|
|
1087
|
-
}
|
|
1060
|
+
(subLink) => subLink.links && subLink.links.length > 0 && subLink.name === specifiedLink && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1061
|
+
/* @__PURE__ */ jsx(
|
|
1062
|
+
HighlightedLinks,
|
|
1063
|
+
{
|
|
1064
|
+
item: subLink,
|
|
1065
|
+
listTitle: subLink.name,
|
|
1066
|
+
links: subLink.links,
|
|
1067
|
+
drawerRef
|
|
1068
|
+
}
|
|
1069
|
+
),
|
|
1070
|
+
subLink.highlightedLinks && subLink.highlightedLinks.length > 0 && /* @__PURE__ */ jsx(Box, { className: styles[`${rootClassName}__colored-box--mobile`], children: /* @__PURE__ */ jsx(Box, { mt: "400", pt: "250", pb: "250", pl: "300", children: /* @__PURE__ */ jsx(
|
|
1071
|
+
HighlightedLinks,
|
|
1072
|
+
{
|
|
1073
|
+
item: subLink,
|
|
1074
|
+
listTitle: "Nyttige snarveier",
|
|
1075
|
+
links: subLink.highlightedLinks,
|
|
1076
|
+
drawerRef
|
|
1077
|
+
}
|
|
1078
|
+
) }) })
|
|
1079
|
+
] })
|
|
1088
1080
|
);
|
|
1089
1081
|
}
|
|
1090
1082
|
) })
|
|
@@ -1136,8 +1128,9 @@ const DesktopSimplified = React__default.forwardRef(() => {
|
|
|
1136
1128
|
if (!rootContext) return null;
|
|
1137
1129
|
const { setSelectedMenuItem, linkComponent: Link2 } = rootContext;
|
|
1138
1130
|
const isBusinessRental = rootContext.pathname.includes("bedrift/utstyrsavtale");
|
|
1131
|
+
const links = getLinks(isBusinessRental, rootContext.customLinks);
|
|
1139
1132
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1140
|
-
|
|
1133
|
+
links.map((link) => {
|
|
1141
1134
|
var _a;
|
|
1142
1135
|
return /* @__PURE__ */ jsxs(NavigationMenu.List, { value: link.name, children: [
|
|
1143
1136
|
(_a = link.links) == null ? void 0 : _a.map((subLink) => /* @__PURE__ */ jsxs(NavigationMenu.Item, { value: subLink.name, children: [
|
|
@@ -1193,6 +1186,7 @@ function Root({
|
|
|
1193
1186
|
onCartOpenChange,
|
|
1194
1187
|
drawerSize = "md",
|
|
1195
1188
|
isSimplified,
|
|
1189
|
+
customLinks,
|
|
1196
1190
|
currentPath,
|
|
1197
1191
|
onSearchInputChange,
|
|
1198
1192
|
onSearchKeyDown,
|
|
@@ -1200,10 +1194,10 @@ function Root({
|
|
|
1200
1194
|
onClear,
|
|
1201
1195
|
...props
|
|
1202
1196
|
}) {
|
|
1203
|
-
const [selectedMenuItem, setSelectedMenuItem] = React__default.useState(getInitialMenuItem(currentPath));
|
|
1204
|
-
const [selectedDomainItem, setSelectedDomainItem] = React__default.useState(getInitialDomain(currentPath));
|
|
1197
|
+
const [selectedMenuItem, setSelectedMenuItem] = React__default.useState(getInitialMenuItem(currentPath, customLinks));
|
|
1198
|
+
const [selectedDomainItem, setSelectedDomainItem] = React__default.useState(getInitialDomain(currentPath, customLinks));
|
|
1205
1199
|
const [pathname, setPathname] = React__default.useState(currentPath || "");
|
|
1206
|
-
const [specifiedLink, setSpecifiedLink] = React__default.useState(getInitialMenuItem(currentPath));
|
|
1200
|
+
const [specifiedLink, setSpecifiedLink] = React__default.useState(getInitialMenuItem(currentPath, customLinks));
|
|
1207
1201
|
const classes = clsx([styles[`${rootClassName}`]], className);
|
|
1208
1202
|
useEffect(() => {
|
|
1209
1203
|
setPathname(currentPath || "");
|
|
@@ -1243,7 +1237,8 @@ function Root({
|
|
|
1243
1237
|
onSearchInputChange,
|
|
1244
1238
|
onSearchKeyDown,
|
|
1245
1239
|
searchValue,
|
|
1246
|
-
onClear
|
|
1240
|
+
onClear,
|
|
1241
|
+
customLinks
|
|
1247
1242
|
},
|
|
1248
1243
|
children: /* @__PURE__ */ jsx(Box, { ...props, className: classes, children: /* @__PURE__ */ jsxs(
|
|
1249
1244
|
NavigationMenu,
|
|
@@ -1271,33 +1266,39 @@ function Root({
|
|
|
1271
1266
|
);
|
|
1272
1267
|
}
|
|
1273
1268
|
Root.displayName = "Root";
|
|
1274
|
-
function getInitialDomain(currentPath) {
|
|
1275
|
-
|
|
1269
|
+
function getInitialDomain(currentPath, customLinks) {
|
|
1270
|
+
const privateLinks = (customLinks == null ? void 0 : customLinks.privateLinks) || DEFAULT_PRIVATE_LINKS;
|
|
1271
|
+
const businessLinks = (customLinks == null ? void 0 : customLinks.businessLinks) || DEFAULT_BUSINESS_LINKS;
|
|
1272
|
+
const mduLinks = (customLinks == null ? void 0 : customLinks.mduLinks) || DEFAULT_MDU_LINKS;
|
|
1273
|
+
if (!currentPath) return privateLinks.name;
|
|
1276
1274
|
const locationArray = currentPath ? currentPath.split("/") : [];
|
|
1277
1275
|
const domainPartOfLocation = `/${locationArray[1].toLowerCase()}/`;
|
|
1278
|
-
const initDomain = domainPartOfLocation ===
|
|
1276
|
+
const initDomain = domainPartOfLocation === businessLinks.link ? businessLinks.name : domainPartOfLocation === mduLinks.link ? mduLinks.name : privateLinks.name;
|
|
1279
1277
|
return initDomain;
|
|
1280
1278
|
}
|
|
1281
|
-
function getInitialMenuItem(currentPath) {
|
|
1279
|
+
function getInitialMenuItem(currentPath, customLinks) {
|
|
1282
1280
|
var _a, _b, _c, _d, _e, _f;
|
|
1281
|
+
const privateLinks = (customLinks == null ? void 0 : customLinks.privateLinks) || DEFAULT_PRIVATE_LINKS;
|
|
1282
|
+
const businessLinks = (customLinks == null ? void 0 : customLinks.businessLinks) || DEFAULT_BUSINESS_LINKS;
|
|
1283
|
+
const mduLinks = (customLinks == null ? void 0 : customLinks.mduLinks) || DEFAULT_MDU_LINKS;
|
|
1283
1284
|
if (!currentPath) return;
|
|
1284
1285
|
const locationArray = currentPath ? currentPath.split("/") : [];
|
|
1285
|
-
const initialDomain = getInitialDomain(currentPath);
|
|
1286
|
-
if (initialDomain ===
|
|
1286
|
+
const initialDomain = getInitialDomain(currentPath, customLinks);
|
|
1287
|
+
if (initialDomain === businessLinks.name) {
|
|
1287
1288
|
const mainMenuPartOfLocation2 = locationArray[2];
|
|
1288
|
-
return (_b = (_a =
|
|
1289
|
+
return (_b = (_a = businessLinks.links) == null ? void 0 : _a.find(
|
|
1289
1290
|
(link) => {
|
|
1290
1291
|
var _a2;
|
|
1291
1292
|
return link.link === `/${initialDomain.toLowerCase()}/${mainMenuPartOfLocation2}/` || ((_a2 = link.links) == null ? void 0 : _a2.some((link2) => link2.link === `/${initialDomain.toLowerCase()}/${mainMenuPartOfLocation2}/`));
|
|
1292
1293
|
}
|
|
1293
1294
|
)) == null ? void 0 : _b.name;
|
|
1294
1295
|
}
|
|
1295
|
-
if (initialDomain ===
|
|
1296
|
+
if (initialDomain === mduLinks.name) {
|
|
1296
1297
|
const mainMenuPartOfLocation2 = locationArray[2];
|
|
1297
|
-
return (_d = (_c =
|
|
1298
|
+
return (_d = (_c = mduLinks.links) == null ? void 0 : _c.find((link) => link.link === `/${initialDomain.toLowerCase()}/${mainMenuPartOfLocation2}/`)) == null ? void 0 : _d.name;
|
|
1298
1299
|
}
|
|
1299
1300
|
const mainMenuPartOfLocation = locationArray[1];
|
|
1300
|
-
return (_f = (_e =
|
|
1301
|
+
return (_f = (_e = privateLinks.links) == null ? void 0 : _e.find((link) => {
|
|
1301
1302
|
var _a2;
|
|
1302
1303
|
return link.name.toLowerCase() === mainMenuPartOfLocation || ((_a2 = link.links) == null ? void 0 : _a2.some((link2) => link2.link === `/${mainMenuPartOfLocation}/`));
|
|
1303
1304
|
})) == null ? void 0 : _f.name;
|