@telia/teddy 0.2.1 → 0.2.3

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.
@@ -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_LINKS, LOGGED_IN_LINKS_BUSINESS, PRIVATE_LINKS, BUSINESS_LINKS, MDU_LINKS, getActiveSubLink, LINKS } from "../navigation-menu/global-navigation/utils.js";
4
+ import { MY_PAGE_LINKS, LOGGED_IN_LINKS_BUSINESS, PRIVATE_LINKS, BUSINESS_LINKS, BUSINESS_UKKO_LINKS, MDU_LINKS, getLinks, getActiveSubLink } from "../navigation-menu/global-navigation/utils.js";
5
5
  import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
6
6
  import { useComposedRefs, composeRefs } from "../../utils/composeRefs.js";
7
7
  import { VisuallyHidden } from "../visually-hidden/visually-hidden.js";
@@ -41,8 +41,8 @@ import { Flex } from "../flex/flex.js";
41
41
  import "../card/index.js";
42
42
  import { Grid } from "../grid/grid.js";
43
43
  import "../toggle/toggle.js";
44
- import { Accordion } from "../accordion/index.js";
45
- import { Link as Link$1 } from "../link/link.js";
44
+ import "../accordion/index.js";
45
+ import "../link/link.js";
46
46
  import "../badge/badge.js";
47
47
  import "../badge/alert-badge.js";
48
48
  import { CounterBadge } from "../badge/counter-badge.js";
@@ -63,7 +63,6 @@ import { Indicator as Indicator$1 } from "./radio-card-group-indicator.js";
63
63
  import { Body } from "./radio-card-group-item-body.js";
64
64
  import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
65
65
  import { useSize } from "../../utils/useSize.js";
66
- import { useCallbackRef } from "../../utils/useCallbackRef.js";
67
66
  const Title$1 = React__default.forwardRef(
68
67
  ({ className, children, asChild, ...props }, forwardRef) => {
69
68
  const classes = clsx([styles$3[`${rootClassName$3}__title`]], className);
@@ -261,34 +260,22 @@ const Close = React__default.forwardRef(
261
260
  );
262
261
  Close.displayName = "Dialog.Close";
263
262
  const Modal = Object.assign(Root$2, { Trigger: Trigger$1, Content: Content$1, Title, Overlay, Description, Close, Image, Group });
264
- const scaleIn = "_scaleIn_11898_1";
265
- const scaleOut = "_scaleOut_11898_1";
266
- const enterFromRight = "_enterFromRight_11898_1";
267
- const enterFromLeft = "_enterFromLeft_11898_1";
268
- const exitToRight = "_exitToRight_11898_1";
269
- const exitToLeft = "_exitToLeft_11898_1";
270
263
  const styles$1 = {
271
- "teddy-navigation-menu": "_teddy-navigation-menu_11898_1",
272
- "teddy-navigation-menu__viewport": "_teddy-navigation-menu__viewport_11898_34",
273
- "teddy-navigation-menu__separator": "_teddy-navigation-menu__separator_11898_37",
274
- "teddy-navigation-menu__list": "_teddy-navigation-menu__list_11898_40",
275
- "teddy-navigation-menu__top-menu-list": "_teddy-navigation-menu__top-menu-list_11898_66",
276
- "teddy-navigation-menu__top-menu-trigger": "_teddy-navigation-menu__top-menu-trigger_11898_87",
277
- "teddy-navigation-menu__top-menu-trigger--small": "_teddy-navigation-menu__top-menu-trigger--small_11898_106",
278
- "teddy-navigation-menu__top-menu-trigger--button": "_teddy-navigation-menu__top-menu-trigger--button_11898_112",
279
- "teddy-navigation-menu__content": "_teddy-navigation-menu__content_11898_187",
280
- "teddy-navigation-menu__trigger": "_teddy-navigation-menu__trigger_11898_227",
281
- "teddy-navigation-menu__trigger--small": "_teddy-navigation-menu__trigger--small_11898_247",
282
- "teddy-navigation-menu__trigger--button": "_teddy-navigation-menu__trigger--button_11898_253",
283
- "teddy-navigation-menu__link": "_teddy-navigation-menu__link_11898_321",
284
- "teddy-navigation-menu__link--small": "_teddy-navigation-menu__link--small_11898_341",
285
- "teddy-navigation-menu__link--button": "_teddy-navigation-menu__link--button_11898_347",
286
- scaleIn,
287
- scaleOut,
288
- enterFromRight,
289
- enterFromLeft,
290
- exitToRight,
291
- exitToLeft
264
+ "teddy-navigation-menu": "_teddy-navigation-menu_6p30v_1",
265
+ "teddy-navigation-menu__viewport": "_teddy-navigation-menu__viewport_6p30v_34",
266
+ "teddy-navigation-menu__separator": "_teddy-navigation-menu__separator_6p30v_37",
267
+ "teddy-navigation-menu__list": "_teddy-navigation-menu__list_6p30v_40",
268
+ "teddy-navigation-menu__top-menu-list": "_teddy-navigation-menu__top-menu-list_6p30v_66",
269
+ "teddy-navigation-menu__top-menu-trigger": "_teddy-navigation-menu__top-menu-trigger_6p30v_87",
270
+ "teddy-navigation-menu__top-menu-trigger--small": "_teddy-navigation-menu__top-menu-trigger--small_6p30v_106",
271
+ "teddy-navigation-menu__top-menu-trigger--button": "_teddy-navigation-menu__top-menu-trigger--button_6p30v_112",
272
+ "teddy-navigation-menu__content": "_teddy-navigation-menu__content_6p30v_187",
273
+ "teddy-navigation-menu__trigger": "_teddy-navigation-menu__trigger_6p30v_219",
274
+ "teddy-navigation-menu__trigger--small": "_teddy-navigation-menu__trigger--small_6p30v_239",
275
+ "teddy-navigation-menu__trigger--button": "_teddy-navigation-menu__trigger--button_6p30v_245",
276
+ "teddy-navigation-menu__link": "_teddy-navigation-menu__link_6p30v_313",
277
+ "teddy-navigation-menu__link--small": "_teddy-navigation-menu__link--small_6p30v_333",
278
+ "teddy-navigation-menu__link--button": "_teddy-navigation-menu__link--button_6p30v_339"
292
279
  };
293
280
  const rootClassName$1 = "teddy-navigation-menu";
294
281
  const NavigationMenuContext = React__default.createContext({
@@ -534,9 +521,6 @@ const Trigger = React__default.forwardRef(
534
521
  return /* @__PURE__ */ jsx(
535
522
  NavigationMenuPrimitive.Trigger,
536
523
  {
537
- onPointerEnter: (e) => e.preventDefault(),
538
- onPointerMove: (e) => e.preventDefault(),
539
- onPointerLeave: (e) => e.preventDefault(),
540
524
  ...props,
541
525
  ref,
542
526
  "data-active": active ? "true" : void 0,
@@ -557,8 +541,6 @@ const Content = React__default.forwardRef(
557
541
  return /* @__PURE__ */ jsx(
558
542
  NavigationMenuPrimitive.Content,
559
543
  {
560
- onPointerEnter: (e) => e.preventDefault(),
561
- onPointerLeave: (e) => e.preventDefault(),
562
544
  ...props,
563
545
  ref: forwardRef,
564
546
  className: classes
@@ -678,20 +660,23 @@ const NavigationMenu = Object.assign(Root$1, {
678
660
  TopMenuTrigger
679
661
  });
680
662
  const styles = {
681
- "teddy-global-navigation": "_teddy-global-navigation_2fdb8_1",
682
- "teddy-global-navigation__mobile-trigger": "_teddy-global-navigation__mobile-trigger_2fdb8_6",
683
- "teddy-global-navigation__mobile-header": "_teddy-global-navigation__mobile-header_2fdb8_9",
684
- "teddy-global-navigation__mobile": "_teddy-global-navigation__mobile_2fdb8_6",
685
- "teddy-global-navigation__link": "_teddy-global-navigation__link_2fdb8_26",
686
- "teddy-global-navigation__viewport": "_teddy-global-navigation__viewport_2fdb8_29",
687
- "teddy-global-navigation__item-wrapper": "_teddy-global-navigation__item-wrapper_2fdb8_32",
688
- "teddy-global-navigation__item-count": "_teddy-global-navigation__item-count_2fdb8_36",
689
- "teddy-global-navigation__viewport-wrapper": "_teddy-global-navigation__viewport-wrapper_2fdb8_43",
690
- "close-viewport": "_close-viewport_2fdb8_1",
691
- "teddy-global-navigation__top-menu-color": "_teddy-global-navigation__top-menu-color_2fdb8_54",
692
- "teddy-global-navigation__top-menu-wrapper": "_teddy-global-navigation__top-menu-wrapper_2fdb8_57",
693
- "teddy-global-navigation__accordion-look": "_teddy-global-navigation__accordion-look_2fdb8_74",
694
- "teddy-global-navigation__mobile-link--accordion-look": "_teddy-global-navigation__mobile-link--accordion-look_2fdb8_90"
663
+ "teddy-global-navigation": "_teddy-global-navigation_1mn6i_1",
664
+ "teddy-global-navigation__mobile": "_teddy-global-navigation__mobile_1mn6i_6",
665
+ "teddy-global-navigation__top-icon-wrapper": "_teddy-global-navigation__top-icon-wrapper_1mn6i_26",
666
+ "teddy-global-navigation__top-menu-icons": "_teddy-global-navigation__top-menu-icons_1mn6i_31",
667
+ "teddy-global-navigation__link": "_teddy-global-navigation__link_1mn6i_35",
668
+ "teddy-global-navigation__header": "_teddy-global-navigation__header_1mn6i_48",
669
+ "teddy-global-navigation__colored-box": "_teddy-global-navigation__colored-box_1mn6i_51",
670
+ "teddy-global-navigation__colored-box--mobile": "_teddy-global-navigation__colored-box--mobile_1mn6i_55",
671
+ "teddy-global-navigation__sublink-button--mobile": "_teddy-global-navigation__sublink-button--mobile_1mn6i_59",
672
+ "teddy-global-navigation__list": "_teddy-global-navigation__list_1mn6i_65",
673
+ "teddy-global-navigation__viewport": "_teddy-global-navigation__viewport_1mn6i_70",
674
+ "teddy-global-navigation__item-wrapper": "_teddy-global-navigation__item-wrapper_1mn6i_73",
675
+ "teddy-global-navigation__item-count": "_teddy-global-navigation__item-count_1mn6i_77",
676
+ "teddy-global-navigation__viewport-wrapper": "_teddy-global-navigation__viewport-wrapper_1mn6i_84",
677
+ "close-viewport": "_close-viewport_1mn6i_1",
678
+ "teddy-global-navigation__top-menu-color": "_teddy-global-navigation__top-menu-color_1mn6i_100",
679
+ "teddy-global-navigation__top-menu-wrapper": "_teddy-global-navigation__top-menu-wrapper_1mn6i_103"
695
680
  };
696
681
  function MyPages(props) {
697
682
  var _a, _b;
@@ -793,6 +778,7 @@ const SearchField = React__default.forwardRef(
793
778
  SearchField.displayName = "SearchField";
794
779
  function Search(props) {
795
780
  const rootContext = React__default.useContext(RootContext);
781
+ const additionalSearchContent = rootContext == null ? void 0 : rootContext.additionalSearchContent;
796
782
  const searchFieldRef = React__default.useRef(null);
797
783
  return /* @__PURE__ */ jsxs(Drawer, { ...props, children: [
798
784
  /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: /* @__PURE__ */ jsxs("button", { children: [
@@ -812,6 +798,7 @@ function Search(props) {
812
798
  /* @__PURE__ */ jsx(Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
813
799
  /* @__PURE__ */ jsx(Drawer.Title, { children: "Hva leter du etter?" }),
814
800
  /* @__PURE__ */ jsx(SearchField, { ref: searchFieldRef }),
801
+ additionalSearchContent ? additionalSearchContent : null,
815
802
  /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
816
803
  ]
817
804
  }
@@ -846,202 +833,238 @@ const ShoppingCart = React__default.forwardRef(() => {
846
833
  ] });
847
834
  });
848
835
  ShoppingCart.displayName = "ShoppingCart";
849
- const scrollDistanceDownThreshold = 200;
850
- const scrollDistanceUpThreshold = 50;
851
- const ANIMATION_DURATION = 300;
852
836
  const Desktop = React__default.forwardRef(() => {
853
837
  const rootContext = React__default.useContext(RootContext);
854
- const [hideMenu, setHideMenu] = React__default.useState(null);
855
- const lastScrollDirection = React__default.useRef();
856
- const scrollStartPos = React__default.useRef(0);
857
- const lastScrollPos = React__default.useRef(0);
838
+ const [showMenu, setShowMenu] = React__default.useState(false);
858
839
  const topMenuRef = React__default.useRef(null);
859
- const viewPortRef = React__default.useRef(null);
860
- const shouldShowViewport = [...PRIVATE_LINKS.links, ...BUSINESS_LINKS.links, ...MDU_LINKS.links].some(
861
- (link) => !!getActiveSubLink((rootContext == null ? void 0 : rootContext.pathname) || "", link.links) || link.links.length && link.link === (rootContext == null ? void 0 : rootContext.pathname)
862
- );
863
- const viewPortSize = useSize(viewPortRef.current);
840
+ const shouldShowViewport = [
841
+ ...PRIVATE_LINKS.links,
842
+ ...BUSINESS_LINKS.links,
843
+ ...BUSINESS_UKKO_LINKS.links,
844
+ ...MDU_LINKS.links
845
+ ].some((link) => {
846
+ const sameParent = link.link.split("/")[1] === (rootContext == null ? void 0 : rootContext.pathname.split("/")[1]) || !link.link && (rootContext == null ? void 0 : rootContext.pathname) === "/";
847
+ return link.links.length && link.name === (rootContext == null ? void 0 : rootContext.specifiedLink) && sameParent;
848
+ });
864
849
  const topMenuSize = useSize(topMenuRef.current);
865
850
  const topMenuHeight = (topMenuSize == null ? void 0 : topMenuSize.height) ? `${topMenuSize.height}px` : void 0;
866
- const viewPortHeight = shouldShowViewport ? "47px" : void 0;
867
- const animationTimer = React__default.useRef(0);
868
- const [allowAnimationOfHeight, setAllowAnimationOfHeight] = React__default.useState(false);
869
- const timerRef = React__default.useRef(void 0);
870
- React__default.useEffect(() => {
871
- timerRef.current = setTimeout(() => {
872
- setAllowAnimationOfHeight(true);
873
- }, 500);
874
- return () => {
875
- timerRef.current && clearTimeout(timerRef.current);
876
- };
877
- }, []);
878
- const handleScroll = () => {
879
- let compensateHight = 0;
880
- if (animationTimer.current > 0) {
881
- const currentTime = (/* @__PURE__ */ new Date()).getTime();
882
- if (animationTimer.current + ANIMATION_DURATION > currentTime) {
883
- compensateHight = ((topMenuSize == null ? void 0 : topMenuSize.height) || 0) + ((viewPortSize == null ? void 0 : viewPortSize.height) || 0);
884
- } else {
885
- animationTimer.current = 0;
886
- }
887
- }
888
- const scrollY = window.scrollY;
889
- const scrollDirection = scrollY > lastScrollPos.current ? "down" : "up";
890
- const scrollDistance = Math.abs(scrollStartPos.current - scrollY);
891
- if (scrollDirection !== lastScrollDirection.current) {
892
- scrollStartPos.current = scrollY;
893
- }
894
- if (!hideMenu && scrollDirection === lastScrollDirection.current && scrollDirection === "down" && scrollDistance > scrollDistanceDownThreshold + compensateHight) {
895
- setHideMenu(true);
896
- const currentTime = (/* @__PURE__ */ new Date()).getTime();
897
- animationTimer.current = currentTime;
898
- }
899
- if (hideMenu && scrollDirection === lastScrollDirection.current && scrollDirection === "up" && scrollDistance > scrollDistanceUpThreshold + compensateHight || scrollY === 0) {
900
- setHideMenu(false);
901
- const currentTime = (/* @__PURE__ */ new Date()).getTime();
902
- animationTimer.current = currentTime;
903
- }
904
- lastScrollDirection.current = scrollDirection;
905
- lastScrollPos.current = scrollY;
906
- };
907
- const throttledScrollHandler = useDebounceCallback(handleScroll, 5);
908
- React__default.useEffect(() => {
909
- window.addEventListener("scroll", throttledScrollHandler);
910
- return () => {
911
- window.removeEventListener("scroll", throttledScrollHandler);
912
- };
913
- }, [throttledScrollHandler]);
914
851
  if (!rootContext)
915
852
  return null;
916
- function resetAndShowMenu() {
917
- lastScrollDirection.current = null;
918
- scrollStartPos.current = window.scrollY;
919
- lastScrollPos.current = window.scrollY;
920
- setHideMenu(false);
921
- }
922
- const { setSelectedMenuItem, linkComponent: Link2 } = rootContext;
853
+ const { selectedMenuItem, setSelectedMenuItem, linkComponent: Link2, specifiedLink, setSpecifiedLink } = rootContext;
923
854
  const currentLocation = rootContext.pathname.endsWith("/") ? rootContext.pathname : `${rootContext.pathname}/`;
855
+ const handleInteractions = (linkName) => {
856
+ setSpecifiedLink(linkName || "");
857
+ setSelectedMenuItem(linkName || "", true);
858
+ };
859
+ const viewPortHeight = shouldShowViewport ? "333px" : void 0;
924
860
  return /* @__PURE__ */ jsxs(Fragment, { children: [
925
861
  /* @__PURE__ */ jsx("div", { className: styles[`${rootClassName}__top-menu-color`], children: /* @__PURE__ */ jsx(
926
862
  "div",
927
863
  {
928
- style: mergeStyles(
929
- { ["--teddy-top-menu-height"]: topMenuHeight },
930
- allowAnimationOfHeight ? { ["--teddy-motion-duration-controlled"]: teddyMotionDuration300 } : {}
931
- ),
864
+ style: mergeStyles({ ["--teddy-top-menu-height"]: topMenuHeight }),
932
865
  className: styles[`${rootClassName}__top-menu-wrapper`],
933
- "data-state": hideMenu ? "closed" : "open",
934
- children: /* @__PURE__ */ jsx(NavigationMenu.TopMenuList, { onFocus: resetAndShowMenu, ref: topMenuRef, children: LINKS.map((link) => /* @__PURE__ */ jsx(NavigationMenu.TopMenuItem, { children: /* @__PURE__ */ jsx(
935
- NavigationMenu.TopMenuTrigger,
936
- {
937
- value: link.name,
938
- asChild: true,
939
- onClick: () => rootContext.setPathname(link.link),
940
- children: link.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: link.link, children: link.name }) : /* @__PURE__ */ jsx("a", { href: link.link, children: link.name })
941
- }
942
- ) }, link.name)) })
866
+ children: /* @__PURE__ */ jsxs(NavigationMenu.TopMenuList, { ref: topMenuRef, children: [
867
+ getLinks(rootContext.pathname.includes("bedrift/utstyrsavtale")).map((link) => /* @__PURE__ */ jsx(NavigationMenu.TopMenuItem, { children: /* @__PURE__ */ jsx(
868
+ NavigationMenu.TopMenuTrigger,
869
+ {
870
+ value: link.name,
871
+ asChild: true,
872
+ onClick: () => {
873
+ rootContext.setPathname(link.link);
874
+ setSpecifiedLink("");
875
+ },
876
+ children: link.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: link.link, children: link.name }) : /* @__PURE__ */ jsx("a", { href: link.link, children: link.name })
877
+ }
878
+ ) }, link.name)),
879
+ /* @__PURE__ */ jsx(Box, { ml: "auto" }),
880
+ /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(ShoppingCart, {}) }),
881
+ /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(Search, {}) }),
882
+ /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(MyPages, {}) })
883
+ ] })
943
884
  }
944
885
  ) }),
945
- LINKS.map((link) => {
886
+ getLinks(rootContext.pathname.includes("bedrift/utstyrsavtale")).map((link) => {
946
887
  var _a;
947
- return /* @__PURE__ */ jsxs(NavigationMenu.List, { onFocus: resetAndShowMenu, value: link.name, children: [
948
- (_a = link.links) == null ? void 0 : _a.map((subLink) => {
949
- var _a2, _b;
950
- return /* @__PURE__ */ jsxs(NavigationMenu.Item, { value: subLink.name, children: [
951
- subLink.name === "Logo" ? /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subLink.link, onClick: () => setSelectedMenuItem(""), children: /* @__PURE__ */ jsx(
952
- "img",
953
- {
954
- src: "https://cdn.voca.teliacompany.com/logo/Telia-primary-default-v2.svg",
955
- draggable: "false",
956
- alt: "Telia logo"
957
- }
958
- ) }) : /* @__PURE__ */ jsx("a", { href: subLink.link, onClick: () => setSelectedMenuItem(""), children: /* @__PURE__ */ jsx(
959
- "img",
960
- {
961
- src: "https://cdn.voca.teliacompany.com/logo/Telia-primary-default-v2.svg",
962
- draggable: "false",
963
- alt: "Telia logo"
964
- }
965
- ) }) }) : ((_a2 = subLink.links) == null ? void 0 : _a2.length) ? /* @__PURE__ */ jsx(
966
- NavigationMenu.Trigger,
967
- {
968
- asChild: true,
969
- active: currentLocation === subLink.link,
970
- onClick: () => {
971
- rootContext.setPathname(subLink.link);
972
- },
973
- children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subLink.link, children: subLink.name }) : /* @__PURE__ */ jsx("a", { href: subLink.link, children: subLink.name })
974
- }
975
- ) : /* @__PURE__ */ jsx(
976
- NavigationMenu.Link,
977
- {
978
- asChild: true,
979
- active: currentLocation === subLink.link,
980
- onClick: () => {
981
- rootContext.setPathname(subLink.link);
982
- },
983
- children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subLink.link, children: subLink.name }) : /* @__PURE__ */ jsx("a", { href: subLink.link, children: subLink.name })
984
- }
985
- ),
986
- /* @__PURE__ */ jsx(NavigationMenu.Content, { children: /* @__PURE__ */ jsx("ul", { children: (_b = subLink.links) == null ? void 0 : _b.map((subSubLink) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
987
- NavigationMenu.Link,
988
- {
989
- asChild: true,
990
- active: getActiveSubLink(currentLocation, subLink.links || []) === subSubLink.link,
991
- onClick: () => {
992
- rootContext.setPathname(subSubLink.link);
993
- },
994
- variant: "small",
995
- children: subSubLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", align: "center", gap: "25", children: [
996
- subSubLink.name,
997
- "icon" in subSubLink && /* @__PURE__ */ jsx(Icon, { name: subSubLink.icon })
998
- ] }) }) : /* @__PURE__ */ jsx("a", { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", align: "center", gap: "25", children: [
999
- subSubLink.name,
1000
- "icon" in subSubLink && /* @__PURE__ */ jsx(Icon, { name: subSubLink.icon })
1001
- ] }) })
1002
- }
1003
- ) }, subSubLink.name)) }) })
1004
- ] }, subLink.name);
1005
- }),
1006
- /* @__PURE__ */ jsx(Box, { ml: "auto" }),
1007
- /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(ShoppingCart, {}) }),
1008
- /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(Search, {}) }),
1009
- /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(MyPages, {}) })
1010
- ] }, link.name);
1011
- }),
1012
- /* @__PURE__ */ jsx(NavigationMenu.Separator, {}),
1013
- /* @__PURE__ */ jsx(
1014
- "div",
1015
- {
1016
- style: mergeStyles(
1017
- { ["--teddy-viewport-wrapper-height"]: viewPortHeight },
1018
- allowAnimationOfHeight ? { ["--teddy-motion-duration-controlled"]: teddyMotionDuration300 } : {}
1019
- ),
1020
- className: styles[`${rootClassName}__viewport-wrapper`],
1021
- "data-state": hideMenu === null ? "" : hideMenu ? "closed" : "open",
1022
- children: /* @__PURE__ */ jsx(
1023
- NavigationMenu.Viewport,
1024
- {
1025
- onFocus: resetAndShowMenu,
1026
- ref: viewPortRef,
1027
- className: styles[`${rootClassName}__viewport`]
1028
- }
1029
- )
1030
- }
1031
- )
888
+ return /* @__PURE__ */ jsx(NavigationMenu.List, { value: link.name, children: (_a = link.links) == null ? void 0 : _a.map(
889
+ (subLink) => {
890
+ var _a2, _b, _c;
891
+ return /* @__PURE__ */ jsxs(
892
+ NavigationMenu.Item,
893
+ {
894
+ value: subLink.name,
895
+ onMouseEnter: () => setShowMenu(true),
896
+ onMouseLeave: () => setShowMenu(false),
897
+ children: [
898
+ subLink.name === "Logo" ? /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(
899
+ Link2,
900
+ {
901
+ href: subLink.link,
902
+ onMouseEnter: () => handleInteractions(),
903
+ onClick: () => handleInteractions(),
904
+ children: /* @__PURE__ */ jsx(
905
+ "img",
906
+ {
907
+ src: "https://cdn.voca.teliacompany.com/logo/Telia-primary-default-v2.svg",
908
+ draggable: "false",
909
+ alt: "Telia logo"
910
+ }
911
+ )
912
+ }
913
+ ) : /* @__PURE__ */ jsx(
914
+ "a",
915
+ {
916
+ href: subLink.link,
917
+ onMouseEnter: () => handleInteractions(),
918
+ onClick: () => handleInteractions(),
919
+ children: /* @__PURE__ */ jsx(
920
+ "img",
921
+ {
922
+ src: "https://cdn.voca.teliacompany.com/logo/Telia-primary-default-v2.svg",
923
+ draggable: "false",
924
+ alt: "Telia logo"
925
+ }
926
+ )
927
+ }
928
+ ) }) : ((_a2 = subLink.links) == null ? void 0 : _a2.length) ? /* @__PURE__ */ jsx(
929
+ NavigationMenu.Trigger,
930
+ {
931
+ asChild: true,
932
+ active: currentLocation === subLink.link,
933
+ children: /* @__PURE__ */ jsx(
934
+ Button,
935
+ {
936
+ onMouseEnter: () => handleInteractions(subLink.name),
937
+ onKeyDown: () => {
938
+ setShowMenu(true);
939
+ },
940
+ onClick: () => handleInteractions(subLink.name),
941
+ children: subLink.name
942
+ }
943
+ )
944
+ }
945
+ ) : /* @__PURE__ */ jsx(
946
+ NavigationMenu.Link,
947
+ {
948
+ asChild: true,
949
+ active: selectedMenuItem === subLink.name && currentLocation === subLink.link,
950
+ children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(
951
+ Link2,
952
+ {
953
+ onMouseEnter: () => handleInteractions(subLink.name),
954
+ onClick: () => handleInteractions(subLink.name),
955
+ href: subLink.link,
956
+ children: subLink.name
957
+ }
958
+ ) : /* @__PURE__ */ jsx(
959
+ "a",
960
+ {
961
+ onMouseEnter: () => handleInteractions(subLink.name),
962
+ onClick: () => handleInteractions(subLink.name),
963
+ href: subLink.link,
964
+ children: subLink.name
965
+ }
966
+ )
967
+ }
968
+ ),
969
+ typeof window !== "undefined" && /* @__PURE__ */ jsx(
970
+ "div",
971
+ {
972
+ style: mergeStyles({ ["--teddy-viewport-wrapper-height"]: viewPortHeight }),
973
+ className: styles[`${rootClassName}__viewport-wrapper`],
974
+ "data-state": showMenu ? "open" : "closed",
975
+ children: /* @__PURE__ */ jsx(NavigationMenu.Content, { children: !!specifiedLink && subLink.name === specifiedLink && /* @__PURE__ */ jsxs(Fragment, { children: [
976
+ ((_b = subLink.links) == null ? void 0 : _b.length) > 0 && /* @__PURE__ */ jsx(
977
+ HightlightedLinksDesktop,
978
+ {
979
+ listName: subLink.name,
980
+ setShowMenu,
981
+ links: subLink.links
982
+ }
983
+ ),
984
+ ((_c = subLink.highlightedLinks) == null ? void 0 : _c.length) > 0 && /* @__PURE__ */ jsx(
985
+ HightlightedLinksDesktop,
986
+ {
987
+ colored: true,
988
+ listName: "Nyttige snarveier",
989
+ setShowMenu,
990
+ links: subLink.highlightedLinks
991
+ }
992
+ )
993
+ ] }) })
994
+ }
995
+ )
996
+ ]
997
+ },
998
+ subLink.name
999
+ );
1000
+ }
1001
+ ) }, link.name);
1002
+ })
1032
1003
  ] });
1033
1004
  });
1034
1005
  Desktop.displayName = "Desktop";
1035
- function useDebounceCallback(callback, delay) {
1036
- const handleCallback = useCallbackRef(callback);
1037
- const debounceTimerRef = React__default.useRef(0);
1038
- React__default.useEffect(() => () => window.clearTimeout(debounceTimerRef.current), []);
1039
- return React__default.useCallback(() => {
1040
- window.clearTimeout(debounceTimerRef.current);
1041
- debounceTimerRef.current = window.setTimeout(handleCallback, delay);
1042
- }, [handleCallback, delay]);
1043
- }
1006
+ const HightlightedLinksDesktop = ({ links, listName, colored, setShowMenu }) => {
1007
+ const rootContext = React__default.useContext(RootContext);
1008
+ if (!rootContext)
1009
+ return null;
1010
+ const { linkComponent: Link2, setSpecifiedLink, setSelectedMenuItem } = rootContext;
1011
+ const currentLocation = rootContext.pathname.endsWith("/") ? rootContext.pathname : `${rootContext.pathname}/`;
1012
+ const firstPart = links.slice(0, 4);
1013
+ const secondPart = links.slice(4);
1014
+ return /* @__PURE__ */ jsxs(Box, { pt: "40px", pb: "40px", className: colored ? styles[`${rootClassName}__colored-box`] : "", children: [
1015
+ /* @__PURE__ */ jsx(Heading, { pl: "100", pb: "100", variant: "title-200", as: "h2", children: listName }),
1016
+ /* @__PURE__ */ jsxs(Flex, { gap: "400", children: [
1017
+ /* @__PURE__ */ jsx(Box, { children: firstPart == null ? void 0 : firstPart.map((subSubLink) => {
1018
+ return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
1019
+ NavigationMenu.Link,
1020
+ {
1021
+ asChild: true,
1022
+ variant: "small",
1023
+ active: getActiveSubLink(currentLocation, links || []) === subSubLink.link,
1024
+ onClick: () => {
1025
+ rootContext.setPathname(subSubLink.link);
1026
+ setSpecifiedLink("");
1027
+ setSelectedMenuItem("", true);
1028
+ setShowMenu(false);
1029
+ },
1030
+ children: subSubLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "100", align: "center", children: [
1031
+ subSubLink.name,
1032
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1033
+ ] }) }) : /* @__PURE__ */ jsx("a", { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "100", align: "center", children: [
1034
+ subSubLink.name,
1035
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1036
+ ] }) })
1037
+ }
1038
+ ) }, subSubLink.name);
1039
+ }) }),
1040
+ /* @__PURE__ */ jsx(Box, { children: secondPart.map((subSubLink) => {
1041
+ return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
1042
+ NavigationMenu.Link,
1043
+ {
1044
+ asChild: true,
1045
+ variant: "small",
1046
+ active: getActiveSubLink(currentLocation, links || []) === subSubLink.link,
1047
+ onClick: () => {
1048
+ rootContext.setPathname(subSubLink.link);
1049
+ setSpecifiedLink("");
1050
+ setSelectedMenuItem("", true);
1051
+ setShowMenu(false);
1052
+ },
1053
+ children: subSubLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "100", align: "center", children: [
1054
+ subSubLink.name,
1055
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1056
+ ] }) }) : /* @__PURE__ */ jsx("a", { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "100", align: "center", children: [
1057
+ subSubLink.name,
1058
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1059
+ ] }) })
1060
+ }
1061
+ ) }, subSubLink.name);
1062
+ }) })
1063
+ ] })
1064
+ ] });
1065
+ };
1044
1066
  function Mobile(props) {
1067
+ const [specifiedLink, setSpecifiedLink] = React__default.useState("");
1045
1068
  const rootContext = React__default.useContext(RootContext);
1046
1069
  const drawerRef = React__default.useRef(null);
1047
1070
  if (!rootContext)
@@ -1049,129 +1072,152 @@ function Mobile(props) {
1049
1072
  const { linkComponent: NavLink } = rootContext;
1050
1073
  const classes = clsx([styles[`${rootClassName}__mobile`]], props.className);
1051
1074
  const linkClasses = clsx([styles[`${rootClassName}__link`]]);
1052
- const currentLocation = rootContext.pathname;
1053
- return /* @__PURE__ */ jsx(Flex, { ...props, className: classes, children: /* @__PURE__ */ jsxs(Flex, { flexGrow: "1", justify: "between", align: "center", gap: "200", children: [
1054
- /* @__PURE__ */ jsx(Box, { flexShrink: "0", children: /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: rootContext.appKey === "open-pages" ? /* @__PURE__ */ jsx(NavLink, { href: "/", children: /* @__PURE__ */ jsx(Icon, { size: "lg", name: "telia-logo", "aria-label": "Telia logo" }) }) : /* @__PURE__ */ jsx("a", { href: "/", children: /* @__PURE__ */ jsx(Icon, { size: "lg", name: "telia-logo", "aria-label": "Telia logo" }) }) }) }),
1055
- /* @__PURE__ */ jsxs(Flex, { flexBasis: "0", gap: { sm: "100", md: "200" }, children: [
1056
- /* @__PURE__ */ jsx(ShoppingCart, {}),
1057
- /* @__PURE__ */ jsx(MyPages, {}),
1058
- /* @__PURE__ */ jsxs(Drawer, { children: [
1059
- /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: /* @__PURE__ */ jsxs("button", { children: [
1060
- /* @__PURE__ */ jsx(Icon, { name: "menu", size: "sm" }),
1061
- " Meny"
1062
- ] }) }) }),
1063
- /* @__PURE__ */ jsxs(Drawer.Content, { gap: "400", size: rootContext.drawerSize, children: [
1064
- /* @__PURE__ */ jsx(Drawer.Close, { ref: drawerRef, slot: "floating", "aria-label": "Lukk" }),
1065
- /* @__PURE__ */ jsx(Drawer.Title, { children: "Meny" }),
1066
- /* @__PURE__ */ jsx(SearchField, {}),
1067
- /* @__PURE__ */ jsxs(
1068
- Tabs,
1069
- {
1070
- value: rootContext.selectedDomainItem,
1071
- onValueChange: (v) => rootContext.setSelectedDomainItem(v, true),
1072
- children: [
1073
- /* @__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)) }),
1074
- /* @__PURE__ */ jsx(Box, { mt: "400", children: LINKS.map((link) => {
1075
- var _a;
1076
- return /* @__PURE__ */ jsx(Tabs.Content, { value: link.name, children: /* @__PURE__ */ jsx(
1077
- Accordion,
1078
- {
1079
- type: "single",
1080
- collapsible: true,
1081
- value: rootContext.selectedMenuItem,
1082
- onValueChange: (v) => rootContext.setSelectedMenuItem(v, true),
1083
- children: (_a = link.links) == null ? void 0 : _a.filter((l) => l.name !== "Logo").map(
1084
- (subLink) => {
1085
- var _a2;
1086
- return subLink.links.length > 0 ? /* @__PURE__ */ jsxs(Accordion.Item, { value: subLink.name, children: [
1087
- /* @__PURE__ */ jsxs(Accordion.Header, { className: styles[`${rootClassName}__mobile-header`], children: [
1088
- /* @__PURE__ */ jsx(
1089
- Link$1,
1090
- {
1091
- className: linkClasses,
1092
- variant: "standalone",
1093
- asChild: true,
1094
- onClick: () => {
1095
- var _a3;
1096
- (_a3 = drawerRef.current) == null ? void 0 : _a3.click();
1097
- rootContext.setSelectedMenuItem(subLink.name);
1098
- rootContext.setPathname(subLink.link);
1099
- },
1100
- children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(NavLink, { href: subLink.link, children: subLink.name }) : /* @__PURE__ */ jsx("a", { href: subLink.link, children: subLink.name })
1101
- }
1102
- ),
1103
- /* @__PURE__ */ jsx(Accordion.Trigger, { className: styles[`${rootClassName}__mobile-trigger`], children: /* @__PURE__ */ jsxs(VisuallyHidden, { children: [
1104
- subLink.name,
1105
- " linker"
1106
- ] }) })
1107
- ] }),
1108
- /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(List$1, { gap: "10", pl: "25", children: (_a2 = subLink.links) == null ? void 0 : _a2.map((subSubLink) => /* @__PURE__ */ jsx(List$1.Item, { children: /* @__PURE__ */ jsx(
1109
- NavigationMenu.Link,
1110
- {
1111
- asChild: true,
1112
- variant: "small",
1113
- active: getActiveSubLink(currentLocation, subLink.links || []) === subSubLink.link,
1114
- onClick: () => {
1115
- var _a3;
1116
- (_a3 = drawerRef.current) == null ? void 0 : _a3.click();
1117
- rootContext.setPathname(subSubLink.link);
1118
- },
1119
- children: subSubLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(NavLink, { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "icon" in subSubLink ? "25" : "100", align: "center", children: [
1120
- subSubLink.name,
1121
- "icon" in subSubLink ? /* @__PURE__ */ jsx(Icon, { name: subSubLink.icon }) : /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1122
- ] }) }) : /* @__PURE__ */ jsx("a", { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "icon" in subSubLink ? "25" : "100", align: "center", children: [
1123
- subSubLink.name,
1124
- "icon" in subSubLink ? /* @__PURE__ */ jsx(Icon, { name: subSubLink.icon }) : /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1125
- ] }) })
1126
- }
1127
- ) }, subSubLink.name)) }) })
1128
- ] }, subLink.name) : /* @__PURE__ */ jsx("div", { className: styles[`${rootClassName}__accordion-look`], children: /* @__PURE__ */ jsx(
1129
- Link$1,
1075
+ const headerClasses = clsx([styles[`${rootClassName}__header`]]);
1076
+ return /* @__PURE__ */ jsx(Flex, { ...props, className: classes, children: /* @__PURE__ */ jsxs(
1077
+ Flex,
1078
+ {
1079
+ flexGrow: "1",
1080
+ justify: "between",
1081
+ align: "center",
1082
+ gap: "200",
1083
+ className: styles[`${rootClassName}__top-icon-wrapper`],
1084
+ children: [
1085
+ /* @__PURE__ */ jsx(Box, { flexShrink: "0", children: /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: rootContext.appKey === "open-pages" ? /* @__PURE__ */ jsx(NavLink, { href: "/", children: /* @__PURE__ */ jsx(Icon, { size: "lg", name: "telia-logo", "aria-label": "Telia logo" }) }) : /* @__PURE__ */ jsx("a", { href: "/", children: /* @__PURE__ */ jsx(Icon, { size: "lg", name: "telia-logo", "aria-label": "Telia logo" }) }) }) }),
1086
+ /* @__PURE__ */ jsxs(Flex, { flexBasis: "0", gap: { sm: "100", md: "200" }, className: styles[`${rootClassName}__top-menu-icons`], children: [
1087
+ /* @__PURE__ */ jsx(Search, {}),
1088
+ /* @__PURE__ */ jsx(ShoppingCart, {}),
1089
+ /* @__PURE__ */ jsx(MyPages, {}),
1090
+ /* @__PURE__ */ jsxs(Drawer, { children: [
1091
+ /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: /* @__PURE__ */ jsxs("button", { children: [
1092
+ /* @__PURE__ */ jsx(Icon, { name: "menu", size: "sm" }),
1093
+ " Meny"
1094
+ ] }) }) }),
1095
+ /* @__PURE__ */ jsxs(Drawer.Content, { gap: "400", size: rootContext.drawerSize, children: [
1096
+ /* @__PURE__ */ jsx(Drawer.Close, { ref: drawerRef, slot: "floating", "aria-label": "Lukk" }),
1097
+ !specifiedLink ? /* @__PURE__ */ jsxs(Fragment, { children: [
1098
+ /* @__PURE__ */ jsx(Drawer.Title, { children: "Meny" }),
1099
+ /* @__PURE__ */ jsxs(
1100
+ Tabs,
1101
+ {
1102
+ value: rootContext.selectedDomainItem,
1103
+ onValueChange: (v) => rootContext.setSelectedDomainItem(v, true),
1104
+ children: [
1105
+ /* @__PURE__ */ jsx(Tabs.List, { children: getLinks(rootContext.pathname.includes("bedrift/utstyrsavtale")).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)) }),
1106
+ /* @__PURE__ */ jsx(Fragment, { children: getLinks(rootContext.pathname.includes("bedrift/utstyrsavtale")).map((link) => {
1107
+ var _a, _b;
1108
+ return /* @__PURE__ */ jsxs(Tabs.Content, { value: link.name, children: [
1109
+ /* @__PURE__ */ jsx(Box, { mt: "400", children: (_a = link.links) == null ? void 0 : _a.filter((l) => l.name !== "Logo").map(
1110
+ (subLink) => subLink.links.length > 0 ? /* @__PURE__ */ jsxs(Box, { onClick: () => setSpecifiedLink(subLink.name), className: linkClasses, children: [
1111
+ /* @__PURE__ */ jsx(Heading, { asChild: true, variant: "title-300", children: /* @__PURE__ */ jsx(Button, { className: styles[`${rootClassName}__sublink-button--mobile`], children: subLink.name }) }),
1112
+ /* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: "md" })
1113
+ ] }) : /* @__PURE__ */ jsx(Fragment, { children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsxs(NavLink, { href: subLink.link, className: linkClasses, children: [
1114
+ /* @__PURE__ */ jsx(Heading, { variant: "title-300", as: "h2", className: headerClasses, children: subLink.name }),
1115
+ /* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: "md" })
1116
+ ] }) : /* @__PURE__ */ jsxs("a", { href: subLink.link, className: linkClasses, children: [
1117
+ /* @__PURE__ */ jsx(Heading, { variant: "title-300", as: "h2", children: subLink.name }),
1118
+ /* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: "md" })
1119
+ ] }) })
1120
+ ) }),
1121
+ ((_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(
1122
+ HighlightedLinks,
1130
1123
  {
1131
- className: clsx([
1132
- linkClasses,
1133
- styles[`${rootClassName}__mobile-link--accordion-look`]
1134
- ]),
1135
- variant: "standalone",
1136
- asChild: true,
1137
- onClick: () => {
1138
- var _a3;
1139
- (_a3 = drawerRef.current) == null ? void 0 : _a3.click();
1140
- rootContext.setSelectedMenuItem(subLink.name);
1141
- rootContext.setPathname(subLink.link);
1142
- },
1143
- children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsxs(NavLink, { href: subLink.link, children: [
1144
- subLink.name,
1145
- /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1146
- ] }) : /* @__PURE__ */ jsxs("a", { href: subLink.link, children: [
1147
- subLink.name,
1148
- " ",
1149
- /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1150
- ] })
1124
+ item: link,
1125
+ links: link.highlightedLinks,
1126
+ drawerRef,
1127
+ listTitle: "Nyttige snarveier"
1151
1128
  }
1152
- ) }, subLink.name);
1153
- }
1154
- )
1155
- }
1156
- ) }, link.name);
1157
- }) })
1158
- ]
1159
- }
1160
- ),
1161
- /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
1129
+ ) }) })
1130
+ ] }, link.name);
1131
+ }) })
1132
+ ]
1133
+ }
1134
+ )
1135
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1136
+ /* @__PURE__ */ jsx(Drawer.Title, { children: /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "secondary", onClick: () => setSpecifiedLink(""), children: [
1137
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-left" }),
1138
+ "Tilbake"
1139
+ ] }) }),
1140
+ /* @__PURE__ */ jsx(Box, { mt: "100", children: getLinks(rootContext.pathname.includes("bedrift/utstyrsavtale")).map(
1141
+ (link) => {
1142
+ var _a;
1143
+ return (_a = link.links) == null ? void 0 : _a.filter((l) => l.name !== "Logo").map(
1144
+ (subLink) => {
1145
+ var _a2;
1146
+ return subLink.links.length > 0 && subLink.name === specifiedLink && /* @__PURE__ */ jsxs(Fragment, { children: [
1147
+ /* @__PURE__ */ jsx(
1148
+ HighlightedLinks,
1149
+ {
1150
+ item: subLink,
1151
+ listTitle: subLink.name,
1152
+ links: subLink.links,
1153
+ drawerRef
1154
+ }
1155
+ ),
1156
+ ((_a2 = subLink.highlightedLinks) == null ? void 0 : _a2.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(
1157
+ HighlightedLinks,
1158
+ {
1159
+ item: subLink,
1160
+ listTitle: "Nyttige snarveier",
1161
+ links: subLink.highlightedLinks,
1162
+ drawerRef
1163
+ }
1164
+ ) }) })
1165
+ ] });
1166
+ }
1167
+ );
1168
+ }
1169
+ ) })
1170
+ ] })
1171
+ ] })
1172
+ ] })
1162
1173
  ] })
1163
- ] })
1164
- ] })
1165
- ] }) });
1174
+ ]
1175
+ }
1176
+ ) });
1166
1177
  }
1167
1178
  Mobile.displayName = "Mobile";
1179
+ const HighlightedLinks = ({
1180
+ listTitle,
1181
+ links,
1182
+ item,
1183
+ drawerRef
1184
+ }) => {
1185
+ const rootContext = React__default.useContext(RootContext);
1186
+ if (!rootContext)
1187
+ return null;
1188
+ const { linkComponent: NavLink } = rootContext;
1189
+ const currentLocation = rootContext.pathname;
1190
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1191
+ /* @__PURE__ */ jsx(Heading, { pl: "100", pb: "100", variant: "title-200", as: "h2", children: listTitle }),
1192
+ /* @__PURE__ */ jsx(List$1, { gap: "10", pl: "25", children: links == null ? void 0 : links.map((subSubLink) => /* @__PURE__ */ jsx(List$1.Item, { children: /* @__PURE__ */ jsx(
1193
+ NavigationMenu.Link,
1194
+ {
1195
+ asChild: true,
1196
+ variant: "small",
1197
+ active: getActiveSubLink(currentLocation, item.links || []) === subSubLink.link,
1198
+ onClick: () => {
1199
+ var _a;
1200
+ (_a = drawerRef == null ? void 0 : drawerRef.current) == null ? void 0 : _a.click();
1201
+ rootContext.setPathname(subSubLink.link);
1202
+ },
1203
+ children: subSubLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(NavLink, { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "icon" in subSubLink ? "25" : "100", align: "center", children: [
1204
+ subSubLink.name,
1205
+ subSubLink.icon ? /* @__PURE__ */ jsx(Icon, { name: subSubLink.icon }) : /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1206
+ ] }) }) : /* @__PURE__ */ jsx("a", { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "icon" in subSubLink ? "25" : "100", align: "center", children: [
1207
+ subSubLink.name,
1208
+ subSubLink.icon ? /* @__PURE__ */ jsx(Icon, { name: subSubLink.icon }) : /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1209
+ ] }) })
1210
+ }
1211
+ ) }, subSubLink.name)) })
1212
+ ] });
1213
+ };
1168
1214
  const DesktopSimplified = React__default.forwardRef(() => {
1169
1215
  const rootContext = React__default.useContext(RootContext);
1170
1216
  if (!rootContext)
1171
1217
  return null;
1172
1218
  const { setSelectedMenuItem, linkComponent: Link2 } = rootContext;
1173
1219
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1174
- LINKS.map((link) => {
1220
+ getLinks(rootContext.pathname.includes("bedrift/utstyrsavtale")).map((link) => {
1175
1221
  var _a;
1176
1222
  return /* @__PURE__ */ jsxs(NavigationMenu.List, { value: link.name, children: [
1177
1223
  (_a = link.links) == null ? void 0 : _a.map((subLink) => /* @__PURE__ */ jsx(NavigationMenu.Item, { value: subLink.name, children: subLink.name === "Logo" && /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subLink.link, onClick: () => setSelectedMenuItem(""), children: /* @__PURE__ */ jsx(
@@ -1220,6 +1266,7 @@ function Root({
1220
1266
  shoppingCart,
1221
1267
  shoppingCartNumberOfItems,
1222
1268
  onSearchSubmit,
1269
+ additionalSearchContent,
1223
1270
  isCartOpen,
1224
1271
  onCartOpenChange,
1225
1272
  drawerSize = "md",
@@ -1230,7 +1277,11 @@ function Root({
1230
1277
  const [selectedMenuItem, setSelectedMenuItem] = React__default.useState(getInitialMenuItem(currentPath));
1231
1278
  const [selectedDomainItem, setSelectedDomainItem] = React__default.useState(getInitialDomain(currentPath));
1232
1279
  const [pathname, setPathname] = React__default.useState(currentPath || "");
1280
+ const [specifiedLink, setSpecifiedLink] = React__default.useState(getInitialMenuItem(currentPath));
1233
1281
  const classes = clsx([styles[`${rootClassName}`]], className);
1282
+ useEffect(() => {
1283
+ setPathname(currentPath || "");
1284
+ }, [currentPath]);
1234
1285
  return /* @__PURE__ */ jsx(
1235
1286
  RootContext.Provider,
1236
1287
  {
@@ -1260,9 +1311,12 @@ function Root({
1260
1311
  shoppingCart,
1261
1312
  shoppingCartNumberOfItems,
1262
1313
  onSearchSubmit,
1314
+ additionalSearchContent,
1263
1315
  isCartOpen,
1264
1316
  onCartOpenChange,
1265
- drawerSize
1317
+ drawerSize,
1318
+ specifiedLink,
1319
+ setSpecifiedLink
1266
1320
  },
1267
1321
  children: /* @__PURE__ */ jsx(Box, { ...props, className: classes, children: /* @__PURE__ */ jsxs(
1268
1322
  NavigationMenu,
@@ -1321,7 +1375,7 @@ function getInitialMenuItem(currentPath) {
1321
1375
  const mainMenuPartOfLocation = locationArray[1];
1322
1376
  return (_f = (_e = PRIVATE_LINKS.links) == null ? void 0 : _e.find((link) => {
1323
1377
  var _a2;
1324
- return link.link === `/${mainMenuPartOfLocation}/` || ((_a2 = link.links) == null ? void 0 : _a2.some((link2) => link2.link === `/${mainMenuPartOfLocation}/`));
1378
+ return link.name.toLowerCase() === mainMenuPartOfLocation || ((_a2 = link.links) == null ? void 0 : _a2.some((link2) => link2.link === `/${mainMenuPartOfLocation}/`));
1325
1379
  })) == null ? void 0 : _f.name;
1326
1380
  }
1327
1381
  Root.displayName = "GlobalNavigation";
@@ -1330,6 +1384,7 @@ export {
1330
1384
  Content$2 as C,
1331
1385
  Desktop as D,
1332
1386
  GlobalNavigation as G,
1387
+ HighlightedLinks as H,
1333
1388
  ItemContext as I,
1334
1389
  Modal as M,
1335
1390
  NavigationMenu as N,