@telia/teddy 0.1.23 → 0.1.24

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.
@@ -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,28 +260,28 @@ 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_gpawj_1";
265
- const scaleOut = "_scaleOut_gpawj_1";
266
- const enterFromRight = "_enterFromRight_gpawj_1";
267
- const enterFromLeft = "_enterFromLeft_gpawj_1";
268
- const exitToRight = "_exitToRight_gpawj_1";
269
- const exitToLeft = "_exitToLeft_gpawj_1";
263
+ const scaleIn = "_scaleIn_19565_1";
264
+ const scaleOut = "_scaleOut_19565_1";
265
+ const enterFromRight = "_enterFromRight_19565_1";
266
+ const enterFromLeft = "_enterFromLeft_19565_1";
267
+ const exitToRight = "_exitToRight_19565_1";
268
+ const exitToLeft = "_exitToLeft_19565_1";
270
269
  const styles$1 = {
271
- "teddy-navigation-menu": "_teddy-navigation-menu_gpawj_1",
272
- "teddy-navigation-menu__viewport": "_teddy-navigation-menu__viewport_gpawj_34",
273
- "teddy-navigation-menu__separator": "_teddy-navigation-menu__separator_gpawj_37",
274
- "teddy-navigation-menu__list": "_teddy-navigation-menu__list_gpawj_40",
275
- "teddy-navigation-menu__top-menu-list": "_teddy-navigation-menu__top-menu-list_gpawj_66",
276
- "teddy-navigation-menu__top-menu-trigger": "_teddy-navigation-menu__top-menu-trigger_gpawj_87",
277
- "teddy-navigation-menu__top-menu-trigger--small": "_teddy-navigation-menu__top-menu-trigger--small_gpawj_106",
278
- "teddy-navigation-menu__top-menu-trigger--button": "_teddy-navigation-menu__top-menu-trigger--button_gpawj_112",
279
- "teddy-navigation-menu__content": "_teddy-navigation-menu__content_gpawj_187",
280
- "teddy-navigation-menu__trigger": "_teddy-navigation-menu__trigger_gpawj_228",
281
- "teddy-navigation-menu__trigger--small": "_teddy-navigation-menu__trigger--small_gpawj_248",
282
- "teddy-navigation-menu__trigger--button": "_teddy-navigation-menu__trigger--button_gpawj_254",
283
- "teddy-navigation-menu__link": "_teddy-navigation-menu__link_gpawj_322",
284
- "teddy-navigation-menu__link--small": "_teddy-navigation-menu__link--small_gpawj_342",
285
- "teddy-navigation-menu__link--button": "_teddy-navigation-menu__link--button_gpawj_348",
270
+ "teddy-navigation-menu": "_teddy-navigation-menu_19565_1",
271
+ "teddy-navigation-menu__viewport": "_teddy-navigation-menu__viewport_19565_34",
272
+ "teddy-navigation-menu__separator": "_teddy-navigation-menu__separator_19565_37",
273
+ "teddy-navigation-menu__list": "_teddy-navigation-menu__list_19565_40",
274
+ "teddy-navigation-menu__top-menu-list": "_teddy-navigation-menu__top-menu-list_19565_66",
275
+ "teddy-navigation-menu__top-menu-trigger": "_teddy-navigation-menu__top-menu-trigger_19565_87",
276
+ "teddy-navigation-menu__top-menu-trigger--small": "_teddy-navigation-menu__top-menu-trigger--small_19565_106",
277
+ "teddy-navigation-menu__top-menu-trigger--button": "_teddy-navigation-menu__top-menu-trigger--button_19565_112",
278
+ "teddy-navigation-menu__content": "_teddy-navigation-menu__content_19565_187",
279
+ "teddy-navigation-menu__trigger": "_teddy-navigation-menu__trigger_19565_228",
280
+ "teddy-navigation-menu__trigger--small": "_teddy-navigation-menu__trigger--small_19565_248",
281
+ "teddy-navigation-menu__trigger--button": "_teddy-navigation-menu__trigger--button_19565_254",
282
+ "teddy-navigation-menu__link": "_teddy-navigation-menu__link_19565_322",
283
+ "teddy-navigation-menu__link--small": "_teddy-navigation-menu__link--small_19565_342",
284
+ "teddy-navigation-menu__link--button": "_teddy-navigation-menu__link--button_19565_348",
286
285
  scaleIn,
287
286
  scaleOut,
288
287
  enterFromRight,
@@ -678,27 +677,27 @@ const NavigationMenu = Object.assign(Root$1, {
678
677
  TopMenuTrigger
679
678
  });
680
679
  const styles = {
681
- "teddy-global-navigation": "_teddy-global-navigation_1i7an_1",
682
- "teddy-global-navigation__mobile-trigger": "_teddy-global-navigation__mobile-trigger_1i7an_6",
683
- "teddy-global-navigation__mobile-header": "_teddy-global-navigation__mobile-header_1i7an_9",
684
- "teddy-global-navigation__mobile": "_teddy-global-navigation__mobile_1i7an_6",
685
- "teddy-global-navigation__top-icon-wrapper": "_teddy-global-navigation__top-icon-wrapper_1i7an_32",
686
- "teddy-global-navigation__top-menu-icons": "_teddy-global-navigation__top-menu-icons_1i7an_37",
687
- "teddy-global-navigation__link": "_teddy-global-navigation__link_1i7an_41",
688
- "teddy-global-navigation__header": "_teddy-global-navigation__header_1i7an_51",
689
- "teddy-global-navigation__colored-box": "_teddy-global-navigation__colored-box_1i7an_54",
690
- "teddy-global-navigation__colored-box--mobile": "_teddy-global-navigation__colored-box--mobile_1i7an_57",
691
- "teddy-global-navigation__sublink-button--mobile": "_teddy-global-navigation__sublink-button--mobile_1i7an_61",
692
- "teddy-global-navigation__list": "_teddy-global-navigation__list_1i7an_67",
693
- "teddy-global-navigation__viewport": "_teddy-global-navigation__viewport_1i7an_72",
694
- "teddy-global-navigation__item-wrapper": "_teddy-global-navigation__item-wrapper_1i7an_75",
695
- "teddy-global-navigation__item-count": "_teddy-global-navigation__item-count_1i7an_79",
696
- "teddy-global-navigation__viewport-wrapper": "_teddy-global-navigation__viewport-wrapper_1i7an_86",
697
- "close-viewport": "_close-viewport_1i7an_1",
698
- "teddy-global-navigation__top-menu-color": "_teddy-global-navigation__top-menu-color_1i7an_97",
699
- "teddy-global-navigation__top-menu-wrapper": "_teddy-global-navigation__top-menu-wrapper_1i7an_100",
700
- "teddy-global-navigation__accordion-look": "_teddy-global-navigation__accordion-look_1i7an_117",
701
- "teddy-global-navigation__mobile-link--accordion-look": "_teddy-global-navigation__mobile-link--accordion-look_1i7an_133"
680
+ "teddy-global-navigation": "_teddy-global-navigation_1kpy3_1",
681
+ "teddy-global-navigation__mobile-trigger": "_teddy-global-navigation__mobile-trigger_1kpy3_6",
682
+ "teddy-global-navigation__mobile-header": "_teddy-global-navigation__mobile-header_1kpy3_9",
683
+ "teddy-global-navigation__mobile": "_teddy-global-navigation__mobile_1kpy3_6",
684
+ "teddy-global-navigation__top-icon-wrapper": "_teddy-global-navigation__top-icon-wrapper_1kpy3_32",
685
+ "teddy-global-navigation__top-menu-icons": "_teddy-global-navigation__top-menu-icons_1kpy3_37",
686
+ "teddy-global-navigation__link": "_teddy-global-navigation__link_1kpy3_41",
687
+ "teddy-global-navigation__header": "_teddy-global-navigation__header_1kpy3_51",
688
+ "teddy-global-navigation__colored-box": "_teddy-global-navigation__colored-box_1kpy3_54",
689
+ "teddy-global-navigation__colored-box--mobile": "_teddy-global-navigation__colored-box--mobile_1kpy3_57",
690
+ "teddy-global-navigation__sublink-button--mobile": "_teddy-global-navigation__sublink-button--mobile_1kpy3_61",
691
+ "teddy-global-navigation__list": "_teddy-global-navigation__list_1kpy3_67",
692
+ "teddy-global-navigation__viewport": "_teddy-global-navigation__viewport_1kpy3_72",
693
+ "teddy-global-navigation__item-wrapper": "_teddy-global-navigation__item-wrapper_1kpy3_75",
694
+ "teddy-global-navigation__item-count": "_teddy-global-navigation__item-count_1kpy3_79",
695
+ "teddy-global-navigation__viewport-wrapper": "_teddy-global-navigation__viewport-wrapper_1kpy3_86",
696
+ "close-viewport": "_close-viewport_1kpy3_1",
697
+ "teddy-global-navigation__top-menu-color": "_teddy-global-navigation__top-menu-color_1kpy3_102",
698
+ "teddy-global-navigation__top-menu-wrapper": "_teddy-global-navigation__top-menu-wrapper_1kpy3_105",
699
+ "teddy-global-navigation__accordion-look": "_teddy-global-navigation__accordion-look_1kpy3_122",
700
+ "teddy-global-navigation__mobile-link--accordion-look": "_teddy-global-navigation__mobile-link--accordion-look_1kpy3_138"
702
701
  };
703
702
  function MyPages(props) {
704
703
  var _a, _b;
@@ -800,6 +799,7 @@ const SearchField = React__default.forwardRef(
800
799
  SearchField.displayName = "SearchField";
801
800
  function Search(props) {
802
801
  const rootContext = React__default.useContext(RootContext);
802
+ const additionalSearchContent = rootContext == null ? void 0 : rootContext.additionalSearchContent;
803
803
  const searchFieldRef = React__default.useRef(null);
804
804
  return /* @__PURE__ */ jsxs(Drawer, { ...props, children: [
805
805
  /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: /* @__PURE__ */ jsxs("button", { children: [
@@ -819,6 +819,7 @@ function Search(props) {
819
819
  /* @__PURE__ */ jsx(Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
820
820
  /* @__PURE__ */ jsx(Drawer.Title, { children: "Hva leter du etter?" }),
821
821
  /* @__PURE__ */ jsx(SearchField, { ref: searchFieldRef }),
822
+ additionalSearchContent ? additionalSearchContent : null,
822
823
  /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
823
824
  ]
824
825
  }
@@ -864,38 +865,13 @@ const Desktop = React__default.forwardRef(() => {
864
865
  (link) => {
865
866
  const highlightedLinkSelected = [...link.highlightedLinks].some((highlightedLink) => highlightedLink.link === (rootContext == null ? void 0 : rootContext.pathname));
866
867
  const linkSelected = [...link.links].some((subLink) => subLink.link === (rootContext == null ? void 0 : rootContext.pathname));
867
- return linkSelected || highlightedLinkSelected || link.links.length && link.name === (rootContext == null ? void 0 : rootContext.specifiedLink);
868
+ const sameParent = link.link.split("/")[1] === (rootContext == null ? void 0 : rootContext.pathname.split("/")[1]) || !link.link && (rootContext == null ? void 0 : rootContext.pathname) === "/";
869
+ return linkSelected || highlightedLinkSelected || link.links.length && link.name === (rootContext == null ? void 0 : rootContext.specifiedLink) && sameParent;
868
870
  }
869
871
  );
870
872
  const topMenuSize = useSize(topMenuRef.current);
871
873
  const topMenuHeight = (topMenuSize == null ? void 0 : topMenuSize.height) ? `${topMenuSize.height}px` : void 0;
872
874
  const viewPortHeight = shouldShowViewport ? "288px" : void 0;
873
- const [allowAnimationOfHeight, setAllowAnimationOfHeight] = React__default.useState(false);
874
- const timerRef = React__default.useRef(void 0);
875
- React__default.useEffect(() => {
876
- timerRef.current = setTimeout(() => {
877
- setAllowAnimationOfHeight(true);
878
- }, 500);
879
- return () => {
880
- timerRef.current && clearTimeout(timerRef.current);
881
- };
882
- }, []);
883
- const handleScroll = () => {
884
- const scrollY = window.scrollY;
885
- const scrollDirection = scrollY > lastScrollPos.current ? "down" : "up";
886
- if (scrollDirection !== lastScrollDirection.current) {
887
- scrollStartPos.current = scrollY;
888
- }
889
- lastScrollDirection.current = scrollDirection;
890
- lastScrollPos.current = scrollY;
891
- };
892
- const throttledScrollHandler = useDebounceCallback(handleScroll, 5);
893
- React__default.useEffect(() => {
894
- window.addEventListener("scroll", throttledScrollHandler);
895
- return () => {
896
- window.removeEventListener("scroll", throttledScrollHandler);
897
- };
898
- }, [throttledScrollHandler]);
899
875
  if (!rootContext)
900
876
  return null;
901
877
  function resetAndShowMenu() {
@@ -910,8 +886,7 @@ const Desktop = React__default.forwardRef(() => {
910
886
  "div",
911
887
  {
912
888
  style: mergeStyles(
913
- { ["--teddy-top-menu-height"]: topMenuHeight },
914
- allowAnimationOfHeight ? { ["--teddy-motion-duration-controlled"]: teddyMotionDuration300 } : {}
889
+ { ["--teddy-top-menu-height"]: topMenuHeight }
915
890
  ),
916
891
  className: styles[`${rootClassName}__top-menu-wrapper`],
917
892
  children: /* @__PURE__ */ jsx(NavigationMenu.TopMenuList, { onFocus: resetAndShowMenu, ref: topMenuRef, children: LINKS.map((link) => /* @__PURE__ */ jsx(NavigationMenu.TopMenuItem, { children: /* @__PURE__ */ jsx(
@@ -935,17 +910,10 @@ const Desktop = React__default.forwardRef(() => {
935
910
  (subLink) => {
936
911
  var _a2, _b, _c;
937
912
  return /* @__PURE__ */ jsxs(NavigationMenu.Item, { value: subLink.name, children: [
938
- 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: () => {
913
+ 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, onMouseEnter: () => {
939
914
  setSelectedMenuItem("", true);
940
915
  setSpecifiedLink("");
941
- }, children: /* @__PURE__ */ jsx(
942
- "img",
943
- {
944
- src: "https://cdn.voca.teliacompany.com/logo/Telia-primary-default-v2.svg",
945
- draggable: "false",
946
- alt: "Telia logo"
947
- }
948
- ) }) : /* @__PURE__ */ jsx("a", { href: subLink.link, onClick: () => {
916
+ }, onClick: () => {
949
917
  setSelectedMenuItem("", true);
950
918
  setSpecifiedLink("");
951
919
  }, children: /* @__PURE__ */ jsx(
@@ -955,32 +923,54 @@ const Desktop = React__default.forwardRef(() => {
955
923
  draggable: "false",
956
924
  alt: "Telia logo"
957
925
  }
958
- ) }) }) : ((_a2 = subLink.links) == null ? void 0 : _a2.length) ? /* @__PURE__ */ jsx(
926
+ ) }) : /* @__PURE__ */ jsx(
927
+ "a",
928
+ {
929
+ href: subLink.link,
930
+ onMouseEnter: () => {
931
+ setSelectedMenuItem("", true);
932
+ setSpecifiedLink("");
933
+ },
934
+ onClick: () => {
935
+ setSelectedMenuItem("", true);
936
+ setSpecifiedLink("");
937
+ },
938
+ children: /* @__PURE__ */ jsx(
939
+ "img",
940
+ {
941
+ src: "https://cdn.voca.teliacompany.com/logo/Telia-primary-default-v2.svg",
942
+ draggable: "false",
943
+ alt: "Telia logo"
944
+ }
945
+ )
946
+ }
947
+ ) }) : ((_a2 = subLink.links) == null ? void 0 : _a2.length) ? /* @__PURE__ */ jsx(
959
948
  NavigationMenu.Trigger,
960
949
  {
961
950
  asChild: true,
962
951
  active: currentLocation === subLink.link,
963
- onClick: () => {
952
+ children: /* @__PURE__ */ jsx(Button, { onMouseEnter: () => {
964
953
  setSpecifiedLink(subLink.name);
965
954
  setSelectedMenuItem(subLink.name, true);
966
- },
967
- children: /* @__PURE__ */ jsx(Button, { children: subLink.name })
955
+ }, children: subLink.name })
968
956
  }
969
957
  ) : /* @__PURE__ */ jsx(
970
958
  NavigationMenu.Link,
971
959
  {
972
960
  asChild: true,
973
961
  active: selectedMenuItem === subLink.name && currentLocation === subLink.link,
974
- onClick: () => {
962
+ children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { onMouseEnter: () => {
975
963
  setSpecifiedLink(subLink.name);
976
964
  setSelectedMenuItem(subLink.name, true);
977
- },
978
- 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 })
965
+ }, href: subLink.link, children: subLink.name }) : /* @__PURE__ */ jsx("a", { onMouseEnter: () => {
966
+ setSpecifiedLink(subLink.name);
967
+ setSelectedMenuItem(subLink.name, true);
968
+ }, href: subLink.link, children: subLink.name })
979
969
  }
980
970
  ),
981
971
  /* @__PURE__ */ jsx(NavigationMenu.Content, { children: !!specifiedLink && subLink.name === specifiedLink && /* @__PURE__ */ jsxs(Fragment, { children: [
982
972
  ((_b = subLink.links) == null ? void 0 : _b.length) > 0 && /* @__PURE__ */ jsx(Flex, { direction: "column", pt: "400", pl: "150", children: /* @__PURE__ */ jsx(HightlightedLinksDesktop, { listName: subLink.name, links: subLink.links }) }),
983
- ((_c = subLink.highlightedLinks) == null ? void 0 : _c.length) > 0 && /* @__PURE__ */ jsx(Flex, { direction: "column", pt: "400", pl: "400", pr: "400", pb: "40px", className: styles[`${rootClassName}__colored-box`], children: /* @__PURE__ */ jsx(HightlightedLinksDesktop, { listName: "Nyttige snarveier", links: subLink.highlightedLinks }) })
973
+ ((_c = subLink.highlightedLinks) == null ? void 0 : _c.length) > 0 && /* @__PURE__ */ jsx(Flex, { direction: "column", pt: "400", pl: "400", pr: "400", pb: "250", className: styles[`${rootClassName}__colored-box`], children: /* @__PURE__ */ jsx(HightlightedLinksDesktop, { listName: "Nyttige snarveier", links: subLink.highlightedLinks }) })
984
974
  ] }) })
985
975
  ] }, subLink.name);
986
976
  }
@@ -991,13 +981,11 @@ const Desktop = React__default.forwardRef(() => {
991
981
  /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(MyPages, {}) })
992
982
  ] }, link.name);
993
983
  }),
994
- /* @__PURE__ */ jsx(NavigationMenu.Separator, {}),
995
984
  /* @__PURE__ */ jsx(
996
985
  "div",
997
986
  {
998
987
  style: mergeStyles(
999
- { ["--teddy-viewport-wrapper-height"]: viewPortHeight },
1000
- allowAnimationOfHeight ? { ["--teddy-motion-duration-controlled"]: teddyMotionDuration300 } : {}
988
+ { ["--teddy-viewport-wrapper-height"]: viewPortHeight }
1001
989
  ),
1002
990
  className: styles[`${rootClassName}__viewport-wrapper`],
1003
991
  "data-state": hideMenu === null ? "" : hideMenu ? "closed" : "open",
@@ -1014,15 +1002,6 @@ const Desktop = React__default.forwardRef(() => {
1014
1002
  ] });
1015
1003
  });
1016
1004
  Desktop.displayName = "Desktop";
1017
- function useDebounceCallback(callback, delay) {
1018
- const handleCallback = useCallbackRef(callback);
1019
- const debounceTimerRef = React__default.useRef(0);
1020
- React__default.useEffect(() => () => window.clearTimeout(debounceTimerRef.current), []);
1021
- return React__default.useCallback(() => {
1022
- window.clearTimeout(debounceTimerRef.current);
1023
- debounceTimerRef.current = window.setTimeout(handleCallback, delay);
1024
- }, [handleCallback, delay]);
1025
- }
1026
1005
  const HightlightedLinksDesktop = ({ links, listName }) => {
1027
1006
  const rootContext = React__default.useContext(RootContext);
1028
1007
  if (!rootContext)
@@ -1224,6 +1203,7 @@ function Root({
1224
1203
  shoppingCart,
1225
1204
  shoppingCartNumberOfItems,
1226
1205
  onSearchSubmit,
1206
+ additionalSearchContent,
1227
1207
  isCartOpen,
1228
1208
  onCartOpenChange,
1229
1209
  drawerSize = "md",
@@ -1269,6 +1249,7 @@ function Root({
1269
1249
  shoppingCart,
1270
1250
  shoppingCartNumberOfItems,
1271
1251
  onSearchSubmit,
1252
+ additionalSearchContent,
1272
1253
  isCartOpen,
1273
1254
  onCartOpenChange,
1274
1255
  drawerSize,