@telia/teddy 0.0.49 → 0.0.51

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.
@@ -29,17 +29,19 @@ const components_visuallyHidden_visuallyHidden = require("../../visually-hidden/
29
29
  const components_link_link = require("../../link/link.cjs");
30
30
  const components_list_index = require("../../list/index.cjs");
31
31
  const styles = {
32
- "teddy-global-navigation": "_teddy-global-navigation_i1ole_1",
33
- "teddy-global-navigation__mobile-trigger": "_teddy-global-navigation__mobile-trigger_i1ole_6",
34
- "teddy-global-navigation__mobile-header": "_teddy-global-navigation__mobile-header_i1ole_9",
35
- "teddy-global-navigation__mobile": "_teddy-global-navigation__mobile_i1ole_6",
36
- "teddy-global-navigation__link": "_teddy-global-navigation__link_i1ole_26",
37
- "teddy-global-navigation__viewport": "_teddy-global-navigation__viewport_i1ole_29",
38
- "teddy-global-navigation__item-wrapper": "_teddy-global-navigation__item-wrapper_i1ole_32",
39
- "teddy-global-navigation__item-count": "_teddy-global-navigation__item-count_i1ole_36",
40
- "teddy-global-navigation__viewport-wrapper": "_teddy-global-navigation__viewport-wrapper_i1ole_43",
41
- "close-viewport": "_close-viewport_i1ole_1",
42
- "teddy-global-navigation__top-menu-wrapper": "_teddy-global-navigation__top-menu-wrapper_i1ole_54"
32
+ "teddy-global-navigation": "_teddy-global-navigation_1yaoy_1",
33
+ "teddy-global-navigation__mobile-trigger": "_teddy-global-navigation__mobile-trigger_1yaoy_6",
34
+ "teddy-global-navigation__mobile-header": "_teddy-global-navigation__mobile-header_1yaoy_9",
35
+ "teddy-global-navigation__mobile": "_teddy-global-navigation__mobile_1yaoy_6",
36
+ "teddy-global-navigation__link": "_teddy-global-navigation__link_1yaoy_26",
37
+ "teddy-global-navigation__viewport": "_teddy-global-navigation__viewport_1yaoy_29",
38
+ "teddy-global-navigation__item-wrapper": "_teddy-global-navigation__item-wrapper_1yaoy_32",
39
+ "teddy-global-navigation__item-count": "_teddy-global-navigation__item-count_1yaoy_36",
40
+ "teddy-global-navigation__viewport-wrapper": "_teddy-global-navigation__viewport-wrapper_1yaoy_43",
41
+ "close-viewport": "_close-viewport_1yaoy_1",
42
+ "teddy-global-navigation__top-menu-wrapper": "_teddy-global-navigation__top-menu-wrapper_1yaoy_54",
43
+ "teddy-global-navigation__accordion-look": "_teddy-global-navigation__accordion-look_1yaoy_64",
44
+ "teddy-global-navigation__mobile-link--accordion-look": "_teddy-global-navigation__mobile-link--accordion-look_1yaoy_80"
43
45
  };
44
46
  function MyPages(props) {
45
47
  var _a, _b;
@@ -56,7 +58,7 @@ function MyPages(props) {
56
58
  /* @__PURE__ */ jsxRuntime.jsxs(components_drawer_index.Drawer.Content, { asChild: true, size: rootContext == null ? void 0 : rootContext.drawerSize, children: [
57
59
  /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
58
60
  isLoggedIn ? /* @__PURE__ */ jsxRuntime.jsx(LoggedInContent, {}) : /* @__PURE__ */ jsxRuntime.jsx(LoggedOutContent, {}),
59
- /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsxRuntime.jsx(components_button_button.Button, { children: "Lukk" }) }) })
61
+ /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsxRuntime.jsx(components_button_button.Button, { variant: "secondary", children: "Lukk" }) }) })
60
62
  ] })
61
63
  ] });
62
64
  }
@@ -160,7 +162,7 @@ function Search(props) {
160
162
  /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
161
163
  /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Title, { children: "Hva leter du etter?" }),
162
164
  /* @__PURE__ */ jsxRuntime.jsx(SearchField, { ref: searchFieldRef }),
163
- /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsxRuntime.jsx(components_button_button.Button, { children: "Lukk" }) }) })
165
+ /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsxRuntime.jsx(components_button_button.Button, { variant: "secondary", children: "Lukk" }) }) })
164
166
  ]
165
167
  }
166
168
  )
@@ -189,7 +191,7 @@ const ShoppingCart = React.forwardRef(() => {
189
191
  titleSuffix
190
192
  ] }),
191
193
  shoppingCartContent ? shoppingCartContent : null,
192
- /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsxRuntime.jsx(components_button_button.Button, { children: "Lukk" }) }) })
194
+ /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsxRuntime.jsx(components_button_button.Button, { variant: "secondary", children: "Lukk" }) }) })
193
195
  ] })
194
196
  ] });
195
197
  });
@@ -205,10 +207,13 @@ const Desktop = React.forwardRef(() => {
205
207
  const lastScrollPos = React.useRef(0);
206
208
  const topMenuRef = React.useRef(null);
207
209
  const viewPortRef = React.useRef(null);
210
+ const shouldShowViewport = [...components_navigationMenu_globalNavigation_utils.PRIVATE_LINKS.links, ...components_navigationMenu_globalNavigation_utils.BUSINESS_LINKS.links, ...components_navigationMenu_globalNavigation_utils.MDU_LINKS.links].some(
211
+ (link) => link.links.some((subLink) => subLink.link === (rootContext == null ? void 0 : rootContext.pathname)) || link.links.length && link.link === (rootContext == null ? void 0 : rootContext.pathname)
212
+ );
208
213
  const viewPortSize = utils_useSize.useSize(viewPortRef.current);
209
214
  const topMenuSize = utils_useSize.useSize(topMenuRef.current);
210
215
  const topMenuHeight = (topMenuSize == null ? void 0 : topMenuSize.height) ? `${topMenuSize.height}px` : void 0;
211
- const viewPortHeight = (viewPortSize == null ? void 0 : viewPortSize.height) ? `${viewPortSize.height}px` : void 0;
216
+ const viewPortHeight = shouldShowViewport ? "47px" : void 0;
212
217
  const animationTimer = React.useRef(0);
213
218
  const [allowAnimationOfHeight, setAllowAnimationOfHeight] = React.useState(false);
214
219
  const timerRef = React.useRef(void 0);
@@ -276,7 +281,15 @@ const Desktop = React.forwardRef(() => {
276
281
  ),
277
282
  className: styles[`${rootClassName}__top-menu-wrapper`],
278
283
  "data-state": hideMenu ? "closed" : "open",
279
- children: /* @__PURE__ */ jsxRuntime.jsx(components_navigationMenu_navigationMenu.NavigationMenu.TopMenuList, { onFocus: resetAndShowMenu, ref: topMenuRef, children: components_navigationMenu_globalNavigation_utils.LINKS.map((link) => /* @__PURE__ */ jsxRuntime.jsx(components_navigationMenu_navigationMenu.NavigationMenu.TopMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsx(components_navigationMenu_navigationMenu.NavigationMenu.TopMenuTrigger, { value: link.name, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: link.link, children: link.name }) }) }, link.name)) })
284
+ children: /* @__PURE__ */ jsxRuntime.jsx(components_navigationMenu_navigationMenu.NavigationMenu.TopMenuList, { onFocus: resetAndShowMenu, ref: topMenuRef, children: components_navigationMenu_globalNavigation_utils.LINKS.map((link) => /* @__PURE__ */ jsxRuntime.jsx(components_navigationMenu_navigationMenu.NavigationMenu.TopMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsx(
285
+ components_navigationMenu_navigationMenu.NavigationMenu.TopMenuTrigger,
286
+ {
287
+ value: link.name,
288
+ asChild: true,
289
+ onClick: () => rootContext.setPathname(link.link),
290
+ children: link.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsxRuntime.jsx(Link, { href: link.link, children: link.name }) : /* @__PURE__ */ jsxRuntime.jsx("a", { href: link.link, children: link.name })
291
+ }
292
+ ) }, link.name)) })
280
293
  }
281
294
  ),
282
295
  components_navigationMenu_globalNavigation_utils.LINKS.map((link) => {
@@ -394,71 +407,103 @@ function Mobile(props) {
394
407
  /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Close, { ref: drawerRef, slot: "floating", "aria-label": "Lukk" }),
395
408
  /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Title, { children: "Meny" }),
396
409
  /* @__PURE__ */ jsxRuntime.jsx(SearchField, {}),
397
- /* @__PURE__ */ jsxRuntime.jsxs(components_tabs_index.Tabs, { value: rootContext.selectedDomainItem, onValueChange: rootContext.setSelectedDomainItem, children: [
398
- /* @__PURE__ */ jsxRuntime.jsx(components_tabs_index.Tabs.List, { children: components_navigationMenu_globalNavigation_utils.LINKS.map((link) => /* @__PURE__ */ jsxRuntime.jsx(components_tabs_index.Tabs.Trigger, { value: link.name, children: link.name }, link.name)) }),
399
- /* @__PURE__ */ jsxRuntime.jsx(components_box_box.Box, { mt: "400", children: components_navigationMenu_globalNavigation_utils.LINKS.map((link) => {
400
- var _a;
401
- return /* @__PURE__ */ jsxRuntime.jsx(components_tabs_index.Tabs.Content, { value: link.name, children: /* @__PURE__ */ jsxRuntime.jsx(
402
- components_accordion_index.Accordion,
403
- {
404
- type: "single",
405
- collapsible: true,
406
- value: rootContext.selectedMenuItem,
407
- onValueChange: rootContext.setSelectedMenuItem,
408
- children: (_a = link.links) == null ? void 0 : _a.filter((l) => l.name !== "Logo").map((subLink) => {
409
- var _a2;
410
- return /* @__PURE__ */ jsxRuntime.jsxs(components_accordion_index.Accordion.Item, { value: subLink.name, children: [
411
- /* @__PURE__ */ jsxRuntime.jsxs(components_accordion_index.Accordion.Header, { className: styles[`${rootClassName}__mobile-header`], children: [
412
- /* @__PURE__ */ jsxRuntime.jsx(
413
- components_link_link.Link,
414
- {
415
- className: linkClasses,
416
- href: "#",
417
- variant: "standalone",
418
- asChild: true,
419
- onClick: () => {
420
- var _a3;
421
- (_a3 = drawerRef.current) == null ? void 0 : _a3.click();
422
- rootContext.setSelectedMenuItem(subLink.name);
423
- rootContext.setPathname(subLink.link);
424
- },
425
- children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsxRuntime.jsx(NavLink, { href: subLink.link, children: subLink.name }) : /* @__PURE__ */ jsxRuntime.jsx("a", { href: subLink.link, children: subLink.name })
426
- }
427
- ),
428
- /* @__PURE__ */ jsxRuntime.jsx(components_accordion_index.Accordion.Trigger, { className: styles[`${rootClassName}__mobile-trigger`], children: /* @__PURE__ */ jsxRuntime.jsxs(components_visuallyHidden_visuallyHidden.VisuallyHidden, { children: [
429
- subLink.name,
430
- " linker"
431
- ] }) })
432
- ] }),
433
- /* @__PURE__ */ jsxRuntime.jsx(components_accordion_index.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(components_list_index.List, { gap: "10", pl: "25", children: (_a2 = subLink.links) == null ? void 0 : _a2.map((subSubLink) => /* @__PURE__ */ jsxRuntime.jsx(components_list_index.List.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(
434
- components_navigationMenu_navigationMenu.NavigationMenu.Link,
435
- {
436
- asChild: true,
437
- variant: "small",
438
- active: components_navigationMenu_globalNavigation_utils.getActiveSubLink(currentLocation, subLink.links || []) === subSubLink.link,
439
- onClick: () => {
440
- var _a3;
441
- (_a3 = drawerRef.current) == null ? void 0 : _a3.click();
442
- rootContext.setPathname(subSubLink.link);
443
- },
444
- children: subSubLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsxRuntime.jsx(NavLink, { href: subSubLink.link, children: /* @__PURE__ */ jsxRuntime.jsxs(components_flex_flex.Flex, { as: "span", gap: "100", children: [
445
- subSubLink.name,
446
- " ",
447
- /* @__PURE__ */ jsxRuntime.jsx(components_icon_icon.Icon, { name: "arrow-right" })
448
- ] }) }) : /* @__PURE__ */ jsxRuntime.jsx("a", { href: subSubLink.link, children: /* @__PURE__ */ jsxRuntime.jsxs(components_flex_flex.Flex, { as: "span", gap: "100", children: [
449
- subSubLink.name,
450
- " ",
451
- /* @__PURE__ */ jsxRuntime.jsx(components_icon_icon.Icon, { name: "arrow-right" })
452
- ] }) })
410
+ /* @__PURE__ */ jsxRuntime.jsxs(
411
+ components_tabs_index.Tabs,
412
+ {
413
+ value: rootContext.selectedDomainItem,
414
+ onValueChange: (v) => rootContext.setSelectedDomainItem(v, true),
415
+ children: [
416
+ /* @__PURE__ */ jsxRuntime.jsx(components_tabs_index.Tabs.List, { children: components_navigationMenu_globalNavigation_utils.LINKS.map((link) => /* @__PURE__ */ jsxRuntime.jsx(components_tabs_index.Tabs.Trigger, { value: link.name, children: link.name }, link.name)) }),
417
+ /* @__PURE__ */ jsxRuntime.jsx(components_box_box.Box, { mt: "400", children: components_navigationMenu_globalNavigation_utils.LINKS.map((link) => {
418
+ var _a;
419
+ return /* @__PURE__ */ jsxRuntime.jsx(components_tabs_index.Tabs.Content, { value: link.name, children: /* @__PURE__ */ jsxRuntime.jsx(
420
+ components_accordion_index.Accordion,
421
+ {
422
+ type: "single",
423
+ collapsible: true,
424
+ value: rootContext.selectedMenuItem,
425
+ onValueChange: (v) => rootContext.setSelectedMenuItem(v, true),
426
+ children: (_a = link.links) == null ? void 0 : _a.filter((l) => l.name !== "Logo").map(
427
+ (subLink) => {
428
+ var _a2;
429
+ return subLink.links.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(components_accordion_index.Accordion.Item, { value: subLink.name, children: [
430
+ /* @__PURE__ */ jsxRuntime.jsxs(components_accordion_index.Accordion.Header, { className: styles[`${rootClassName}__mobile-header`], children: [
431
+ /* @__PURE__ */ jsxRuntime.jsx(
432
+ components_link_link.Link,
433
+ {
434
+ className: linkClasses,
435
+ variant: "standalone",
436
+ asChild: true,
437
+ onClick: () => {
438
+ var _a3;
439
+ (_a3 = drawerRef.current) == null ? void 0 : _a3.click();
440
+ rootContext.setSelectedMenuItem(subLink.name);
441
+ rootContext.setPathname(subLink.link);
442
+ },
443
+ children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsxRuntime.jsx(NavLink, { href: subLink.link, children: subLink.name }) : /* @__PURE__ */ jsxRuntime.jsx("a", { href: subLink.link, children: subLink.name })
444
+ }
445
+ ),
446
+ /* @__PURE__ */ jsxRuntime.jsx(components_accordion_index.Accordion.Trigger, { className: styles[`${rootClassName}__mobile-trigger`], children: /* @__PURE__ */ jsxRuntime.jsxs(components_visuallyHidden_visuallyHidden.VisuallyHidden, { children: [
447
+ subLink.name,
448
+ " linker"
449
+ ] }) })
450
+ ] }),
451
+ /* @__PURE__ */ jsxRuntime.jsx(components_accordion_index.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(components_list_index.List, { gap: "10", pl: "25", children: (_a2 = subLink.links) == null ? void 0 : _a2.map((subSubLink) => /* @__PURE__ */ jsxRuntime.jsx(components_list_index.List.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(
452
+ components_navigationMenu_navigationMenu.NavigationMenu.Link,
453
+ {
454
+ asChild: true,
455
+ variant: "small",
456
+ active: components_navigationMenu_globalNavigation_utils.getActiveSubLink(currentLocation, subLink.links || []) === subSubLink.link,
457
+ onClick: () => {
458
+ var _a3;
459
+ (_a3 = drawerRef.current) == null ? void 0 : _a3.click();
460
+ rootContext.setPathname(subSubLink.link);
461
+ },
462
+ children: subSubLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsxRuntime.jsx(NavLink, { href: subSubLink.link, children: /* @__PURE__ */ jsxRuntime.jsxs(components_flex_flex.Flex, { as: "span", gap: "100", children: [
463
+ subSubLink.name,
464
+ " ",
465
+ /* @__PURE__ */ jsxRuntime.jsx(components_icon_icon.Icon, { name: "arrow-right" })
466
+ ] }) }) : /* @__PURE__ */ jsxRuntime.jsx("a", { href: subSubLink.link, children: /* @__PURE__ */ jsxRuntime.jsxs(components_flex_flex.Flex, { as: "span", gap: "100", children: [
467
+ subSubLink.name,
468
+ " ",
469
+ /* @__PURE__ */ jsxRuntime.jsx(components_icon_icon.Icon, { name: "arrow-right" })
470
+ ] }) })
471
+ }
472
+ ) }, subSubLink.name)) }) })
473
+ ] }, subLink.name) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles[`${rootClassName}__accordion-look`], children: /* @__PURE__ */ jsxRuntime.jsx(
474
+ components_link_link.Link,
475
+ {
476
+ className: clsx([
477
+ linkClasses,
478
+ styles[`${rootClassName}__mobile-link--accordion-look`]
479
+ ]),
480
+ variant: "standalone",
481
+ asChild: true,
482
+ onClick: () => {
483
+ var _a3;
484
+ (_a3 = drawerRef.current) == null ? void 0 : _a3.click();
485
+ rootContext.setSelectedMenuItem(subLink.name);
486
+ rootContext.setPathname(subLink.link);
487
+ },
488
+ children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsxRuntime.jsxs(NavLink, { href: subLink.link, children: [
489
+ subLink.name,
490
+ /* @__PURE__ */ jsxRuntime.jsx(components_icon_icon.Icon, { name: "arrow-right" })
491
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("a", { href: subLink.link, children: [
492
+ subLink.name,
493
+ " ",
494
+ /* @__PURE__ */ jsxRuntime.jsx(components_icon_icon.Icon, { name: "arrow-right" })
495
+ ] })
496
+ }
497
+ ) }, subLink.name);
453
498
  }
454
- ) }, subSubLink.name)) }) })
455
- ] }, subLink.name);
456
- })
457
- }
458
- ) }, link.name);
459
- }) })
460
- ] }),
461
- /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsxRuntime.jsx(components_button_button.Button, { children: "Lukk" }) }) })
499
+ )
500
+ }
501
+ ) }, link.name);
502
+ }) })
503
+ ]
504
+ }
505
+ ),
506
+ /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(components_drawer_index.Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsxRuntime.jsx(components_button_button.Button, { variant: "secondary", children: "Lukk" }) }) })
462
507
  ] })
463
508
  ] })
464
509
  ] })
@@ -538,12 +583,24 @@ function Root({
538
583
  appKey,
539
584
  loggedInUser,
540
585
  selectedMenuItem,
541
- setSelectedMenuItem,
586
+ setSelectedMenuItem(v, onlyStateChange) {
587
+ if (appKey === "open-pages" && !onlyStateChange)
588
+ return;
589
+ setSelectedMenuItem(v);
590
+ },
542
591
  linkComponent,
543
592
  selectedDomainItem,
544
- setSelectedDomainItem,
593
+ setSelectedDomainItem(v, onlyStateChange) {
594
+ if (appKey === "open-pages" && !onlyStateChange)
595
+ return;
596
+ setSelectedDomainItem(v);
597
+ },
545
598
  pathname,
546
- setPathname,
599
+ setPathname(v) {
600
+ if (appKey === "open-pages")
601
+ return;
602
+ setPathname(v);
603
+ },
547
604
  onLogoutClick,
548
605
  shoppingCart,
549
606
  shoppingCartNumberOfItems,
@@ -559,7 +616,7 @@ function Root({
559
616
  onTopMenuValueChange: setSelectedDomainItem,
560
617
  value: selectedMenuItem,
561
618
  onValueChange: (v) => {
562
- if (v === "")
619
+ if (v === "" || appKey === "open-pages")
563
620
  return;
564
621
  setSelectedMenuItem(v);
565
622
  },
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import React__default from "react";
3
3
  import clsx from "clsx";
4
- import { MY_PAGE_LINKS, LOGGED_IN_LINKS_BUSINESS, LINKS, getActiveSubLink, PRIVATE_LINKS, BUSINESS_LINKS, MDU_LINKS } from "./utils.js";
4
+ import { MY_PAGE_LINKS, LOGGED_IN_LINKS_BUSINESS, PRIVATE_LINKS, BUSINESS_LINKS, MDU_LINKS, LINKS, getActiveSubLink } from "./utils.js";
5
5
  import { NavigationMenu } from "../navigation-menu.js";
6
6
  import { Box } from "../../box/box.js";
7
7
  import { Drawer } from "../../drawer/index.js";
@@ -27,17 +27,19 @@ import { VisuallyHidden } from "../../visually-hidden/visually-hidden.js";
27
27
  import { Link } from "../../link/link.js";
28
28
  import { List } from "../../list/index.js";
29
29
  const styles = {
30
- "teddy-global-navigation": "_teddy-global-navigation_i1ole_1",
31
- "teddy-global-navigation__mobile-trigger": "_teddy-global-navigation__mobile-trigger_i1ole_6",
32
- "teddy-global-navigation__mobile-header": "_teddy-global-navigation__mobile-header_i1ole_9",
33
- "teddy-global-navigation__mobile": "_teddy-global-navigation__mobile_i1ole_6",
34
- "teddy-global-navigation__link": "_teddy-global-navigation__link_i1ole_26",
35
- "teddy-global-navigation__viewport": "_teddy-global-navigation__viewport_i1ole_29",
36
- "teddy-global-navigation__item-wrapper": "_teddy-global-navigation__item-wrapper_i1ole_32",
37
- "teddy-global-navigation__item-count": "_teddy-global-navigation__item-count_i1ole_36",
38
- "teddy-global-navigation__viewport-wrapper": "_teddy-global-navigation__viewport-wrapper_i1ole_43",
39
- "close-viewport": "_close-viewport_i1ole_1",
40
- "teddy-global-navigation__top-menu-wrapper": "_teddy-global-navigation__top-menu-wrapper_i1ole_54"
30
+ "teddy-global-navigation": "_teddy-global-navigation_1yaoy_1",
31
+ "teddy-global-navigation__mobile-trigger": "_teddy-global-navigation__mobile-trigger_1yaoy_6",
32
+ "teddy-global-navigation__mobile-header": "_teddy-global-navigation__mobile-header_1yaoy_9",
33
+ "teddy-global-navigation__mobile": "_teddy-global-navigation__mobile_1yaoy_6",
34
+ "teddy-global-navigation__link": "_teddy-global-navigation__link_1yaoy_26",
35
+ "teddy-global-navigation__viewport": "_teddy-global-navigation__viewport_1yaoy_29",
36
+ "teddy-global-navigation__item-wrapper": "_teddy-global-navigation__item-wrapper_1yaoy_32",
37
+ "teddy-global-navigation__item-count": "_teddy-global-navigation__item-count_1yaoy_36",
38
+ "teddy-global-navigation__viewport-wrapper": "_teddy-global-navigation__viewport-wrapper_1yaoy_43",
39
+ "close-viewport": "_close-viewport_1yaoy_1",
40
+ "teddy-global-navigation__top-menu-wrapper": "_teddy-global-navigation__top-menu-wrapper_1yaoy_54",
41
+ "teddy-global-navigation__accordion-look": "_teddy-global-navigation__accordion-look_1yaoy_64",
42
+ "teddy-global-navigation__mobile-link--accordion-look": "_teddy-global-navigation__mobile-link--accordion-look_1yaoy_80"
41
43
  };
42
44
  function MyPages(props) {
43
45
  var _a, _b;
@@ -54,7 +56,7 @@ function MyPages(props) {
54
56
  /* @__PURE__ */ jsxs(Drawer.Content, { asChild: true, size: rootContext == null ? void 0 : rootContext.drawerSize, children: [
55
57
  /* @__PURE__ */ jsx(Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
56
58
  isLoggedIn ? /* @__PURE__ */ jsx(LoggedInContent, {}) : /* @__PURE__ */ jsx(LoggedOutContent, {}),
57
- /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { children: "Lukk" }) }) })
59
+ /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
58
60
  ] })
59
61
  ] });
60
62
  }
@@ -158,7 +160,7 @@ function Search(props) {
158
160
  /* @__PURE__ */ jsx(Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
159
161
  /* @__PURE__ */ jsx(Drawer.Title, { children: "Hva leter du etter?" }),
160
162
  /* @__PURE__ */ jsx(SearchField, { ref: searchFieldRef }),
161
- /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { children: "Lukk" }) }) })
163
+ /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
162
164
  ]
163
165
  }
164
166
  )
@@ -187,7 +189,7 @@ const ShoppingCart = React__default.forwardRef(() => {
187
189
  titleSuffix
188
190
  ] }),
189
191
  shoppingCartContent ? shoppingCartContent : null,
190
- /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { children: "Lukk" }) }) })
192
+ /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
191
193
  ] })
192
194
  ] });
193
195
  });
@@ -203,10 +205,13 @@ const Desktop = React__default.forwardRef(() => {
203
205
  const lastScrollPos = React__default.useRef(0);
204
206
  const topMenuRef = React__default.useRef(null);
205
207
  const viewPortRef = React__default.useRef(null);
208
+ const shouldShowViewport = [...PRIVATE_LINKS.links, ...BUSINESS_LINKS.links, ...MDU_LINKS.links].some(
209
+ (link) => link.links.some((subLink) => subLink.link === (rootContext == null ? void 0 : rootContext.pathname)) || link.links.length && link.link === (rootContext == null ? void 0 : rootContext.pathname)
210
+ );
206
211
  const viewPortSize = useSize(viewPortRef.current);
207
212
  const topMenuSize = useSize(topMenuRef.current);
208
213
  const topMenuHeight = (topMenuSize == null ? void 0 : topMenuSize.height) ? `${topMenuSize.height}px` : void 0;
209
- const viewPortHeight = (viewPortSize == null ? void 0 : viewPortSize.height) ? `${viewPortSize.height}px` : void 0;
214
+ const viewPortHeight = shouldShowViewport ? "47px" : void 0;
210
215
  const animationTimer = React__default.useRef(0);
211
216
  const [allowAnimationOfHeight, setAllowAnimationOfHeight] = React__default.useState(false);
212
217
  const timerRef = React__default.useRef(void 0);
@@ -274,7 +279,15 @@ const Desktop = React__default.forwardRef(() => {
274
279
  ),
275
280
  className: styles[`${rootClassName}__top-menu-wrapper`],
276
281
  "data-state": hideMenu ? "closed" : "open",
277
- children: /* @__PURE__ */ jsx(NavigationMenu.TopMenuList, { onFocus: resetAndShowMenu, ref: topMenuRef, children: LINKS.map((link) => /* @__PURE__ */ jsx(NavigationMenu.TopMenuItem, { children: /* @__PURE__ */ jsx(NavigationMenu.TopMenuTrigger, { value: link.name, asChild: true, children: /* @__PURE__ */ jsx(Link2, { href: link.link, children: link.name }) }) }, link.name)) })
282
+ children: /* @__PURE__ */ jsx(NavigationMenu.TopMenuList, { onFocus: resetAndShowMenu, ref: topMenuRef, children: LINKS.map((link) => /* @__PURE__ */ jsx(NavigationMenu.TopMenuItem, { children: /* @__PURE__ */ jsx(
283
+ NavigationMenu.TopMenuTrigger,
284
+ {
285
+ value: link.name,
286
+ asChild: true,
287
+ onClick: () => rootContext.setPathname(link.link),
288
+ 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 })
289
+ }
290
+ ) }, link.name)) })
278
291
  }
279
292
  ),
280
293
  LINKS.map((link) => {
@@ -392,71 +405,103 @@ function Mobile(props) {
392
405
  /* @__PURE__ */ jsx(Drawer.Close, { ref: drawerRef, slot: "floating", "aria-label": "Lukk" }),
393
406
  /* @__PURE__ */ jsx(Drawer.Title, { children: "Meny" }),
394
407
  /* @__PURE__ */ jsx(SearchField, {}),
395
- /* @__PURE__ */ jsxs(Tabs, { value: rootContext.selectedDomainItem, onValueChange: rootContext.setSelectedDomainItem, children: [
396
- /* @__PURE__ */ jsx(Tabs.List, { children: LINKS.map((link) => /* @__PURE__ */ jsx(Tabs.Trigger, { value: link.name, children: link.name }, link.name)) }),
397
- /* @__PURE__ */ jsx(Box, { mt: "400", children: LINKS.map((link) => {
398
- var _a;
399
- return /* @__PURE__ */ jsx(Tabs.Content, { value: link.name, children: /* @__PURE__ */ jsx(
400
- Accordion,
401
- {
402
- type: "single",
403
- collapsible: true,
404
- value: rootContext.selectedMenuItem,
405
- onValueChange: rootContext.setSelectedMenuItem,
406
- children: (_a = link.links) == null ? void 0 : _a.filter((l) => l.name !== "Logo").map((subLink) => {
407
- var _a2;
408
- return /* @__PURE__ */ jsxs(Accordion.Item, { value: subLink.name, children: [
409
- /* @__PURE__ */ jsxs(Accordion.Header, { className: styles[`${rootClassName}__mobile-header`], children: [
410
- /* @__PURE__ */ jsx(
411
- Link,
412
- {
413
- className: linkClasses,
414
- href: "#",
415
- variant: "standalone",
416
- asChild: true,
417
- onClick: () => {
418
- var _a3;
419
- (_a3 = drawerRef.current) == null ? void 0 : _a3.click();
420
- rootContext.setSelectedMenuItem(subLink.name);
421
- rootContext.setPathname(subLink.link);
422
- },
423
- 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 })
424
- }
425
- ),
426
- /* @__PURE__ */ jsx(Accordion.Trigger, { className: styles[`${rootClassName}__mobile-trigger`], children: /* @__PURE__ */ jsxs(VisuallyHidden, { children: [
427
- subLink.name,
428
- " linker"
429
- ] }) })
430
- ] }),
431
- /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(List, { gap: "10", pl: "25", children: (_a2 = subLink.links) == null ? void 0 : _a2.map((subSubLink) => /* @__PURE__ */ jsx(List.Item, { children: /* @__PURE__ */ jsx(
432
- NavigationMenu.Link,
433
- {
434
- asChild: true,
435
- variant: "small",
436
- active: getActiveSubLink(currentLocation, subLink.links || []) === subSubLink.link,
437
- onClick: () => {
438
- var _a3;
439
- (_a3 = drawerRef.current) == null ? void 0 : _a3.click();
440
- rootContext.setPathname(subSubLink.link);
441
- },
442
- children: subSubLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(NavLink, { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "100", children: [
443
- subSubLink.name,
444
- " ",
445
- /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
446
- ] }) }) : /* @__PURE__ */ jsx("a", { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "100", children: [
447
- subSubLink.name,
448
- " ",
449
- /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
450
- ] }) })
408
+ /* @__PURE__ */ jsxs(
409
+ Tabs,
410
+ {
411
+ value: rootContext.selectedDomainItem,
412
+ onValueChange: (v) => rootContext.setSelectedDomainItem(v, true),
413
+ children: [
414
+ /* @__PURE__ */ jsx(Tabs.List, { children: LINKS.map((link) => /* @__PURE__ */ jsx(Tabs.Trigger, { value: link.name, children: link.name }, link.name)) }),
415
+ /* @__PURE__ */ jsx(Box, { mt: "400", children: LINKS.map((link) => {
416
+ var _a;
417
+ return /* @__PURE__ */ jsx(Tabs.Content, { value: link.name, children: /* @__PURE__ */ jsx(
418
+ Accordion,
419
+ {
420
+ type: "single",
421
+ collapsible: true,
422
+ value: rootContext.selectedMenuItem,
423
+ onValueChange: (v) => rootContext.setSelectedMenuItem(v, true),
424
+ children: (_a = link.links) == null ? void 0 : _a.filter((l) => l.name !== "Logo").map(
425
+ (subLink) => {
426
+ var _a2;
427
+ return subLink.links.length > 0 ? /* @__PURE__ */ jsxs(Accordion.Item, { value: subLink.name, children: [
428
+ /* @__PURE__ */ jsxs(Accordion.Header, { className: styles[`${rootClassName}__mobile-header`], children: [
429
+ /* @__PURE__ */ jsx(
430
+ Link,
431
+ {
432
+ className: linkClasses,
433
+ variant: "standalone",
434
+ asChild: true,
435
+ onClick: () => {
436
+ var _a3;
437
+ (_a3 = drawerRef.current) == null ? void 0 : _a3.click();
438
+ rootContext.setSelectedMenuItem(subLink.name);
439
+ rootContext.setPathname(subLink.link);
440
+ },
441
+ 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 })
442
+ }
443
+ ),
444
+ /* @__PURE__ */ jsx(Accordion.Trigger, { className: styles[`${rootClassName}__mobile-trigger`], children: /* @__PURE__ */ jsxs(VisuallyHidden, { children: [
445
+ subLink.name,
446
+ " linker"
447
+ ] }) })
448
+ ] }),
449
+ /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(List, { gap: "10", pl: "25", children: (_a2 = subLink.links) == null ? void 0 : _a2.map((subSubLink) => /* @__PURE__ */ jsx(List.Item, { children: /* @__PURE__ */ jsx(
450
+ NavigationMenu.Link,
451
+ {
452
+ asChild: true,
453
+ variant: "small",
454
+ active: getActiveSubLink(currentLocation, subLink.links || []) === subSubLink.link,
455
+ onClick: () => {
456
+ var _a3;
457
+ (_a3 = drawerRef.current) == null ? void 0 : _a3.click();
458
+ rootContext.setPathname(subSubLink.link);
459
+ },
460
+ children: subSubLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(NavLink, { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "100", children: [
461
+ subSubLink.name,
462
+ " ",
463
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
464
+ ] }) }) : /* @__PURE__ */ jsx("a", { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "100", children: [
465
+ subSubLink.name,
466
+ " ",
467
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
468
+ ] }) })
469
+ }
470
+ ) }, subSubLink.name)) }) })
471
+ ] }, subLink.name) : /* @__PURE__ */ jsx("div", { className: styles[`${rootClassName}__accordion-look`], children: /* @__PURE__ */ jsx(
472
+ Link,
473
+ {
474
+ className: clsx([
475
+ linkClasses,
476
+ styles[`${rootClassName}__mobile-link--accordion-look`]
477
+ ]),
478
+ variant: "standalone",
479
+ asChild: true,
480
+ onClick: () => {
481
+ var _a3;
482
+ (_a3 = drawerRef.current) == null ? void 0 : _a3.click();
483
+ rootContext.setSelectedMenuItem(subLink.name);
484
+ rootContext.setPathname(subLink.link);
485
+ },
486
+ children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsxs(NavLink, { href: subLink.link, children: [
487
+ subLink.name,
488
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
489
+ ] }) : /* @__PURE__ */ jsxs("a", { href: subLink.link, children: [
490
+ subLink.name,
491
+ " ",
492
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
493
+ ] })
494
+ }
495
+ ) }, subLink.name);
451
496
  }
452
- ) }, subSubLink.name)) }) })
453
- ] }, subLink.name);
454
- })
455
- }
456
- ) }, link.name);
457
- }) })
458
- ] }),
459
- /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { children: "Lukk" }) }) })
497
+ )
498
+ }
499
+ ) }, link.name);
500
+ }) })
501
+ ]
502
+ }
503
+ ),
504
+ /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
460
505
  ] })
461
506
  ] })
462
507
  ] })
@@ -536,12 +581,24 @@ function Root({
536
581
  appKey,
537
582
  loggedInUser,
538
583
  selectedMenuItem,
539
- setSelectedMenuItem,
584
+ setSelectedMenuItem(v, onlyStateChange) {
585
+ if (appKey === "open-pages" && !onlyStateChange)
586
+ return;
587
+ setSelectedMenuItem(v);
588
+ },
540
589
  linkComponent,
541
590
  selectedDomainItem,
542
- setSelectedDomainItem,
591
+ setSelectedDomainItem(v, onlyStateChange) {
592
+ if (appKey === "open-pages" && !onlyStateChange)
593
+ return;
594
+ setSelectedDomainItem(v);
595
+ },
543
596
  pathname,
544
- setPathname,
597
+ setPathname(v) {
598
+ if (appKey === "open-pages")
599
+ return;
600
+ setPathname(v);
601
+ },
545
602
  onLogoutClick,
546
603
  shoppingCart,
547
604
  shoppingCartNumberOfItems,
@@ -557,7 +614,7 @@ function Root({
557
614
  onTopMenuValueChange: setSelectedDomainItem,
558
615
  value: selectedMenuItem,
559
616
  onValueChange: (v) => {
560
- if (v === "")
617
+ if (v === "" || appKey === "open-pages")
561
618
  return;
562
619
  setSelectedMenuItem(v);
563
620
  },